Tutorials

Mounted Gun (Orange Box)



Setting up the stand.

Step 1. Create a prop_static with the model of:
models/props_combine/combine_barricade_short01a.mdl

Place this where you want the gun to be mounted. This could be substituted with a pile of rubble or otherwise. Here it is used to give me an idea of how high the gun should be mounted. (45-50 units if you wish to do it with a brush.)

Setting up the gun model.

Step 1. Create a prop_dynamic with the model of:

models/props_combine/bunker_gun01.mdl

Place this on top of your barricade, with the feet resting on the edges.

news post image

Name the prop_dynamic:

  • Barricade_Gun_Model, or something to that effect.
  • Disable Shadows: Yes
  • Start Fade Dist: 1000
  • End Fade Dist: 2000
  • Collisions: Not Solid
  • Default Animation: idle_inactive



news post image

Setting up the func_tank.

Step 1. Create a 16x16x16 cube centered over the models feet, textured with tools/toolsblockbullets.

news post image

Tie this block to func_tank. (Ctrl + T) Now, copy the following settings. Most settings should be left default, unless otherwise noted.

  • Name: Barricade_Gun_Tank
  • Parent: Barricade_Gun_Model //Obviously the model that is being used for the turret.
  • Control Volume: Barricade_Gun_ControlVolume
  • Yaw Rate: 200 //How fast does it yaw? (Turn left to right)
  • Yaw Range: 60 //How far can it turn?
  • Pitch Rate: 120 //How far does it pitch? (Turn up to down)
  • Pitch Range: 60 //How far can it turn?
  • Barrel Length: 31 //Length from orgin of func_tank to the end of the muzzleflash sprite.



Used for sprite placement.

  • Barrel Vertical: 8
  • Rate of Fire: 15 //How fast does it fire?
  • Damage per Bullet: 9 //How much do the bullets do?
  • Damage Per Bullet Vs Player: 5 //How much do the bullets do to PLAYERS?
  • Firing Persistence: 4 //AI: How long to keep firing at last known position, after loosing sight of target.
  • Firing Persistence2: 2 //AI: How long to occasionaly shoot after last position.
  • Bullet Accuracy: Small Cone //How accurate is the gun?
  • Maximum Target Range: 2500 //AI: How far away can you aquire the target from?



//DO NOT CHANGE ANY VALUES BELOW, UNLESS YOU KNOW WHAT YOU ARE DOING.

  • Gun Base Attachment: aimrotation
  • Gun Barrel Attachment: muzzle
  • Gun Yaw Pose Param: aim_yaw
  • Gun Pitch Pose Param: aim_pitch
  • Gun Pitch Pose Center: 7.5


//DO NOT CHANGE ANY VALUES ABOVE, UNLESS YOU KNOW WHAT YOU ARE DOING. (Is related to the bunkergun model, and code.)

  • Ammountion Count: -1 //How much ammo does this gun have?
  • NPC Man Point: Barricade_Gun_Manpoint
  • Player Lock Time: 0.1 //AI: How long to be tracking the player before shooting?
  • Effect Handling: AR2 //Effects sounds
  • Ammo Type: AR2 //What ammo does it use, how much damage, etc. MODDERS: Uses ammotypes defined in hl2_gamerules.cpp



news post image

Step 1.5: Go to the func_tank's flags, and check:

  • Active
  • Controllable
  • NPC Controlable
  • Non-Solid



Step 2: Create a 80x35x128+-ish brush, texture it with tools/toolstrigger, and tie it to a trigger_multiple. These numbers do not need to be exact, and can be changed for your liking. This defines in what area the player can "Use" the func_tank. If he is pushed out of it, he will stop using it.

THIS MUST BE TALLER THEN THE PLAYER HEIGHT.

Name the trigger_multiple: Barricade_Gun_ControlVolume
And under Flags check:
Clients

news post image

Step 3: Create an info_target and inch or so off the ground, with the name:
Barricade_Gun_Manpoint

Place it exactly 32 units behind the centre of the func_tank volume. This is used for AI's controlling the gun, and tells them where to stand, so animations work.

news post image

Setting up the outputs

This one's a bit of a doozy. You have to set several animations, with delays, so I'll do it like this.

Output | Targetname | Input | Parameter | Delay.

  • OnFire | Barricade_Gun_Model | SetAnimation | Fire
  • OnGotControler | Barricade_Gun_Model | SetAnimation | Activate
  • OnGotControler | Barricade_Gun_Model | SetDefaultAnimation | Idle | 0.1
  • OnGotPlayerControler | Barricade_Gun_Model | SetAnimation | Activate
  • OnGotPlayerControler | Barricade_Gun_Model | SetDefaultAnimation | Idle | 0.1
  • OnLostControler | Barricade_Gun_Model | SetAnimation | Retract
  • OnLostControler | Barricade_Gun_Model | SetDefaultAnimation | Idle | 0.1
  • OnLostPlayerControler | Barricade_Gun_Model | SetAnimation | Retract
  • OnLostPlayerControler | Barricade_Gun_Model | SetDefaultAnimation | idle_inactive | 0.1



And since that's confusing:

news post image

If you compile that, (after putting in the rest of the map, and a spawn...) and go into game, it should work.

Adding some cool effects.

Because frankly, effects are awesome. Were going to create a light that turns on when the gun is in use, and turns off when it's not (And moves with it).

Create a env_sprite, with the following settings:

  • Name: Barricade_Gun_Model_Sprite_Glow
  • Parent: Barricade_Gun_Model
  • Render Mode: Worldspace Glow
  • Scale: .3
  • HDR Color Scale: .5
  • FX Amount: 215
  • FX Color: 225 255 255
  • Render Mode: Additive



Place this at the tip of the barrel, near the small flashlight. Create a point_spotlight, so that there's an actual effect:

  • Name: Barricade_Gun_Model_Sprite_Spotlight
  • Parent: Barricade_Gun_Model
  • Spotlight Width: 18
  • Spotlight Length: 128
  • HDR Color Scale: .7
  • Color: 225 255 255



news post image

Now, to make it move with the gun, create a logic auto with the following outputs:

  • OnMapSpawn | Barricade_Gun_Model_Spite_Glow | SetParentAttachment | muzzle
  • OnMapSpawn | Barricade_Gun_Model_Sprite_Spotlight | SetParentAttachment | muzzle



news post image

Now, we've got a light that tracks around. Pretty cool, but you know, it could be cooler.
Add two more Outputs:

  • OnMapSpawn | Barricade_Gun_Model_Sprite_Glow | HideSprite
  • OnMapSpawn | Barricade_Gun_Model_Sprite_Spotlight | LightOff



This could also be accomplished by checking the flags inside of the Spotlight, and the Sprite, but that would require you going back to those entites.

Go to the func_tank, and add these Outputs:

  • OnGotController | Barricade_Gun_Model_Sprite_Spotlight | LightOn | 0.15
  • OnGotController | Barricade_Gun_Model_Sprite_Glow | ShowSprite | 0.2
  • OnLostController | Barricade_Gun_Model_Sprite_Spotlight | LightOff | 0.05
  • OnLostController | Barricade_Gun_Model_Sprite_Glow | HideSprite | 0.1



Duplicate your efforts for OnGotPlayerController, and OnLostPlayerController.

news post image

InGame Screenies:

news post image
news post image
news post image

- Lord Ned

View comments ( 13 )

Back to top