Turrets, turrets, turrets. The next step in my new race (2 hulls designed, no coding yet), and I have no idea how to make them.

Obviously the art is fine, but the turret mapping and so on…

…[size=150]I have no idea how it works.[/size]



Should you start running out of ideas for turrets, consider the “chop shop” approach.

You can get create some rather epic designs.

Here is a quick guide on what you need to do to get your own turrets in the game from the Modding Guide.
For the purpose of the exercise i will reference the “Mega Weapon” series of turrets from the Unity Mod.

The first thing you need to do is create the text file and Code the Weapon:
In “\unit\data\bitmaps\modules” you will find all the weapons and modules for Unity. If we take a closer look at cruiser_mega_plasma.txt

unlockcost = 0
lockable = 0
armour_penetration = 100
category = "WEAPONS"
classname = "SIM_PlasmaLauncherModule"
cost = 524
crew_required = 8
damage = 180
description = "Plasma is a efficient method to cleanly dispose of unwanted garbage.  So if you can't bring the garbage to the plasma, take the plasma to the garbage"
fire_interval = 3500
fuel = 3000
guiname = "Mega Plasma Launcher"
hitpoints = 320
icon = turret
min_range = 500
max_range = 2500
name = "cruiser_siege_cannon"
optimum_range = 1800
powerconsumed = 60
restricted = "unit"
shield_penetration = 100
size = "CRUISER"
sound = data/sounds/fusion_torpedo2.ogg
soundvolume = 1.0
speed = 6.0
spritesize = 14.0
tracking_speed = 0.8
turnspeed = 0.5
turret_sprite = "mega_plas_v1"  <-- this is what we are interested in
turretsize = 30.0
weight = 327.5
slot_type = TURRET
uisortpos = 60040

So now we have the weapon code, we need to tell the game how it looks when on a ship and how it looks as an icon when your building the ship.

The link between the the Weapon Code and what images to use were is controled with the line that reads turret_sprite = "mega_plas_v. This tells the game what turret mapping (from the race file) to use in the different parts of the game for this particular module.

Turret Mapping.
In “\unit\data\races\unit.txt” we have all the configuration of Unity race, but we are only interested in the turret mapping . . . It is worth to note that the turret mapping is for both your new custom weapons and the weapons avaliable to all races.

turret_auto_v1 = unit_turret_auto_v1.dds,turrets_unit.dds,0
turret_auto_v2 = unit_turret_auto_v2.dds,turrets_unit.dds,1
turret_auto_v3 = unit_turret_auto_v3.dds,turrets_unit.dds,2
turret_auto_v4 = unit_turret_auto_v4.dds,turrets_unit.dds,3
turret_auto_v5 = unit_turret_auto_v5.dds,turrets_unit.dds,4
turret_auto_v6 = unit_turret_auto_v6.dds,turrets_unit.dds,5
turret_bull_v1 = unit_turret_bull_v1.dds,turrets_unit.dds,6
turret_bull_v2 = unit_turret_bull_v2.dds,turrets_unit.dds,7
turret_bull_v3 = unit_turret_bull_v3.dds,turrets_unit.dds,8
turret_bull_v4 = unit_turret_bull_v4.dds,turrets_unit.dds,9
turret_bull_v5 = unit_turret_bull_v5.dds,turrets_unit.dds,10
turret_bull_v6 = unit_turret_bull_v6.dds,turrets_unit.dds,11
turret_las_v1 = unit_turret_las_v1.dds,turrets_unit.dds,12
mega_bull_v1 = turret_mega_bull_v0.dds,turrets_unit_mega.dds,0
mega_auto_v1 = turret_mega_auto_v0.dds,turrets_unit_mega.dds,1
mega_las_v1 = turret_mega_las_v0.dds,turrets_unit_mega.dds,2
mega_rail_v1 = turret_mega_rail_v0.dds,turrets_unit_mega.dds,3
mega_plas_v1 = turret_mega_plas_v0.dds,turrets_unit_mega.dds,4

If we look closely we will see that the first 20 lines are the turret maps for the modules that are accesable to all races. The last few lines are for the custom weapons we have introduced into the mod

Each line can be broken down into 4 components [A] = [B] , [C] , [D]

[A] = mega_plas_v1, This part of the code is the reference used in the modules text file (turret_sprite = “mega_plas_v1”)

[B] = turret_mega_plas_v0.dds, This tells the game what graphic file to be used in the ship builder screen. Please note that you will need an alpha channel or the graphic will not show in the shp builder

[C] = turrets_unit_mega.dds, This tells the game what graphic file to be used in the battle (Please note that the file can only contain up to a maximum of 32 turrets. If you have more than 32 turrets you will need multiple files ).

Its important to note that the Turret Mapping DDS file is broken up into an 8 x 8 grid. No matter how big the file is it will ONLY EVER be broken into an 8 x 8 grid.
Therefore if you have a:

  • 512x512 dds file, each turret must be contained within a space of 64x64.
  • 1024 x 1024 dds file, each turret must be contained within a space of 128x128.

Now at this point it is rather useful for your graphics editor to have a grid overlay and a snap to grid function as it makes it very easy to ensure that your turrets sit in neat little rows.

When you create your grid overlay, have the lines every 32 pixles. This way in a 512x512 image (as an example) the area for one turret will have a horizontal and vertical center line as well as a border to help with placement

The image can be seperated into 2 sections:

  • Working Turrets: The top half of the file contains the images of the turrets when they are working
  • Broken Turrets: The bottom half of the file contains the images of the turrets when they are broken

If you look at the attached image you can see 2 copies of the turrets (you might have to scroll around to see them)
You will notice that the lower half turrets are darker. This is to help with the damaged effect
(in this case I decrease the colour saturation and lightness by half.)

Now we look at the alpha channel:

If you look at the “broken turret” section you will notice that there are bits missing to help with the damaged effect
Same method is used in the hulk files for the ships.

[D] = 4, Since the in game graphic file has many turret, we need to tell the game which particular turret we are interested in. So the file is split into an 8 x 8 grid with the top left corner starting as 0.

So, the image is broken down like this.
[0] [1] [2] [3] [4] [5] [6] [7]
[8] [9] etc etc . . .

So if you scroll back up and look at the ingame graphics file, you can see that the plasma turret is the 5th one along which is ID 4.

If you have any more questions let me know