Everything you need to know about func_tanks
In this tutorial I will tell you what you should do if you want to set up a func_tank in Half-Life 2. This tutorial also applies to those who already know how to make them in Half-Life 1 because in the Source engine, things are a little different.
The first thing you want to do is to create the body of the weapon out of brushes. A good height for those brushes is around 44 units from the ground or whatever the user will stand on.
Next, draw an info_player_start sized trigger_multiple with the TRIGGER texture and place it in a way that the player will be inside it when he controls the gun. Name it mgun_controlpoint or something.
Now, entitise the gun brushes into a func_tank.
1. Drag the origin to wherever you want the gun to rotate around (the cursor will change to a crosshair when pointing at it in any of the 2D views).
2. Give it a name like mgun or something
3. Pitch Yaw Roll - choose the direction you want it to face in game. Easily done with the yellow line protruding out of the origin that will point towards the business end.
4. Control Volume ? select the trigger_multiple you set up earlier
5. Yaw Rate to Pitch Range - the values are in degrees and degrees per second. Range means either way around value in Pitch Yaw Roll so entering ?60? for yaw range will mean the weapon can be aimed 60? left of the centre and 60? right of the centre.
6. Barrel Length to Barrel Vertical ? to acquire the correct values, create a brush that will span from the guns origin to the end of the barrel. The Barrel Length is the brushes dimension along the x-axis, the Barrel Horizontal is the size of the brush along the y-axis and the Barrel Vertical is the height of the brush. If the end of the barrel is before the origin along the y-axis or the end is lower than the origin, you will need to make the number negative in the Barrel Horizontal and Barrel Vertical parts respectively.
7. Rate of Fire ? shots per second as opposed to delay between shots
8. Damage per Bullet ? 1-10 is weak, 11-20 is average, 20+ is obviously stronger
9. Bullet accuracy ? I recommend Small cone
10. NPC Man Point ? if you want it NPC controllable, select whatever you entered for Control Volume.
11. Effect Handling ? Use Individual Settings and Combine Cannon leaves the bullets appearance looking like the ones fired from the pistol or SMG and also means you will have to set up a fire sound for the gun. AR2 makes the gun and its bullets sound and look (respectively) like the combine bunker turrets in Half-Life 2.
12. Ammo type ? base damage of the bullets fired from the func_tank. Make sure you select Pistol, SMG1 or AR2. Whichever one you choose matters if you entered 0 for Damage per Bullet. Don?t select None or Combine Heavy Cannon if you want the func_tank to actually work.
13. FLAGS ? check ?Controllable? if you want to be able to use it and/or ?NPC Controllable? if you want NPCs to be able to use it.
The following NPCs are able to function as gunners
? Npc_combine_s
? Npc_citizen
Now this is why when people properly set func_tanks up, they don?t fire:
1. switch off SmartEdit in the func_tanks properties
2. select where it says ammotype
3. on the right change ammotype to bullet and enter the number 3 for its value. I think 1 and 2 work as well
4. click ?apply? and close
Hammer will think what you have just done here is wrong and will think the keyvalue bullet is an error if you click ?Check for Problems? but it?ll be OK. If you don?t want any errors then download my modified FGD file (included with example map).
This is what I have changed (where the text shown in red was replaced with text shown in blue):
Original
// dvs: FIXME: move into an episodic FGD
@SolidClass base(BaseTank) = func_tank : "Brush Gun Turret"
[
ammotype (choices) : "Ammo type" : "" =
[
"" : "None"
"Pistol" : "Pistol"
"SMG1" : "SMG1"
"AR2" : "AR2"
"CombineHeavyCannon" : "Combine Heavy Cannon"
]
Modified
// dvs: FIXME: move into an episodic FGD
@SolidClass base(BaseTank) = func_tank : "Brush Gun Turret"
[
bullet (choices) : "Ammo type" : "" =
[
"0" : "None"
"1" : "Pistol"
"2" : "SMG1"
"3" : "AR2"
"4" : "Combine Heavy Cannon"
]
Keep your original FGD file just in case and in Hammer remove the old FGD and replace with the modified one.
Your func_tank should now work correctly. If you want to make your gun more realistic then keep reading. Here?s a few things you can do:
Fire sound
Put an ambient_generic above your func_tanks origin, name it mgun_sound select a sound file (like weapons/ar2/fire1.wav, weapons/smg1/smg1_fire1.wav or npc/sniper/sniper1.wav) and under outputs in the func_tank, click add, select ?OnFire?, target ?mgun_sound? and select ?PlaySound?.
Muzzle flash
Place an env_muzzleflash at the end of your barrel and call it mgun_muzzleflash, parent it to your func_tank, angle it the same way as your func_tank. Under outputs in the func_tank, click add, select ?OnFire?, target mgun_muzzleflash and select ?Fire?. The muzzle flash is made of multiple sprites so is more 3D and realistic.
Shell ejection
Create an env_shooter next to your func_tank where you want the shells to come from. Call it mgun_eject, parent it to your func_tank and the direction of the shells should point away from the func_tank, out of the side and maybe pitched up a bit. Gib Angles should be ideally the same as the direction of your func_tank. The shell models should be either models/weapons/shell.mdl or models/weapons/rifleshell.mdl. For Simulate select Point. Under the env_shooters spawnflags, make sure ?Repeatable? is checked. Under outputs in the func_tank, click add, select ?OnFire?, target mgun_eject and select ?Shoot?.
Mechanical pivot
This will make what allows your turret to rotate to be represented as a physical entity (well, actually two). Create 2 func_physboxes of these shapes (the dark one is textured falsely for clarity and the unit scale depicted is 2).
Mechanical barrel
You can make gattling guns as func_tanks with the Source engine complete with spinning barrels. It?s basically a func_rotating parented to the func_tank.
I?m sure there?s loads more stuff you can do. In the example map, there are 3 working func_tanks including a 4-barrel gattling gun, each with mechanical pivots, shell dispenser and muzzle flashes.