Snarkpit Articles


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.

As you can see I have made the gun 8 units in height and 40 units away from the floor; that way when an NPC wants to use it, its hands will look like it?s holding the turret. You can make it higher but not by much because you still have to see what you?re aiming at. Also make sure your gun faces East in Hammer (you specify the real direction in entity properties) that?ll make sure the game knows which way the bullets come out of the end of the barrel.

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).

The dark physbox will be placed on what holds the turret up (a wall, a post), will be phys_hinged down the centre with the supporter and be targeted by a phys_keepupright. The centre should be on the same point as the func_tanks origin in the Top 2D view. The light physbox should be parented and tied to the func_tank with a phys_contraint. It will be directly under the turret and line up with the dark physbox like this:

Hinge both physboxes perpendicular to the direction of the func_tank through the func_tanks origin and give them a mass scale of 10,000 so that they can?t be interfered with a Gravity Gun.

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.


Post ReplyView Topic
Discussion
0 starsPosted by Virgil on Wed Nov 24th 2010 at 4:30am

Please someone respond, the download link won't work and in the first picture I want to use that turret!!! Please help!
[author]
Posted by hl_world on Thu Sep 13th 2007 at 9:43pm

No, you're confused. Assuming you already have an info_player_start, you create a trigger_multiple brush that the info_player_start entity can fit inside. You get a trigger_multiple of the exact size of the player.
0 starsPosted by CoNny on Thu Sep 13th 2007 at 8:03pm

Its a good tutorial but Im afraid that Im stuck at the "info_sized_player triger_multipel" Im going to find out in another tutorial but note that you should tell us more details on that in the update...
[author]
Posted by hl_world on Wed Aug 15th 2007 at 3:57pm

Exactly as it is in the x/y view - east=right, west=left, north=up and south=down.
0 starsPosted by Glus_Master on Wed Aug 15th 2007 at 3:41pm

Um how do you know which way is East?
0 starsPosted by quanta on Mon Jul 2nd 2007 at 2:21pm

0 starsPosted by Imbrifer on Sat Jun 9th 2007 at 4:23pm

I found the example map before I read the tutorial, but both are great. I made a slick big ol' gun with sound, muzzleflash and ejection. I made a part of it 'recoil' (when you fire, a func_tracktrain parented to the other parts of the gun jerks back, simulating gun recoil) but it crashes HL2. Wish I could figure it out - I'd drop it in my next map smiley
[author]
Posted by hl_world on Thu Apr 12th 2007 at 3:03pm

Poisonic - i'm not sure about multiplayer as i don't bother with HL:DM when mapping although I don't see why not.
sir_frags - strange problem you have there. Maybe something to do with your mouse axis settings ingame like "invert mouse".

Did everyone find the example map useful?
0 starsPosted by sir_frags on Sun Apr 1st 2007 at 4:41pm

Most helpful..most accurate...kudos on posting example map. My only problem is that the gun points in the opposite direction I look in when I fire. That is, if I look left, gun goes right. If I look up, gun goes down.
0 starsPosted by poisonic on Wed Feb 21st 2007 at 4:57pm

A good tuttoral

A noob question does it work in m maps aswel ?
Post ReplyView Topic