Creating NPC-Controlled Mounted Guns

From Valve Developer Community
Jump to: navigation, search

This tutorial will teach you how to add a Survivor NPC who will use a mounted gun to kill infected that come within it field of fire.


Making an Emplacement

  1. Create an emplacement for your mounted gun. The survivor NPC we will be using does not take damage and does not interact with survivors or infected. Having this emplacement accessible to zombies will interfere with suspension of disbelief. Consider placing your mounted gun in a location that appears inaccessible to common infected to hide the NPC's invulnerability.
  2. Add a prop_mounted_machine_gun to the emplacement. Ensure you have the right gun. Neither prop_minigun nor prop_minigun_l4d1 will work in this situation.
3.Add an area for the NPC to spawn in. If you want the survivors to see the NPC walk to the gun, ensure they cannot see the NPC when it spawns, as it will appear out of nowhere.

Adding the NPC

  1. Create a prop_ragdoll out of sight of the survivors.
  2. Set its name to MountedGunRagdoll, or something similar.
  3. Set its World Model to "survivor_manager.mdl".
  4. Create an info_l4d1_survivor_spawn where you want the NPC to be created.
  5. Set its name to "MountedGunSurvivor", or something similar.
  6. Set its character to "Louis"
  7. Navigate to the Model tab and set the animation of the info_l4d1_survivor_spawn to animHack.

Creating a Trigger

  1. Create a logic_relay
  2. Add an output to kill the prop_ragdoll. Set the output name to OnTrigger, the target to whatever you named the prop_ragdoll, and the input to Kill. This will precache the NPC so the game will not crash on the creation of the NPC.
  3. Create a second input to create the NPC. Set the output to OnTrigger, the target to the name of the info_l4d1_survivor_spawn, and the input to SpawnSurvivor. Add some delay to ensure the NPC is spawned after the prop_ragdoll is killed


When this logic_relay is triggered, it will kill the ragdoll and spawn a Louis NPC at the location of the info_l4d1_survivor_spawn who will pathfind to the nearest M60 and use it. The NPC will target and destroy all zombies within its range and destroy them. The NPC already has animations that will play when needed. The NPC will also spawn with a pistol which it will use to kill infected on its way to the mounted gun.

Note.png Note: The perfect aim of this NPC, combined with the massive damage put out by the machine gun, means that this NPC can severely unbalance a fight. Ensure that the NPC is blocked by brushes, and/or that custom director scripts are used to scale the difficulty of hordes or finales.