TutorialsBack to Tutorials
Manhack DispenserThis Tutorial shows how you can create a Manhack dispenser that is disabled and enabled by a Combine Interface, and spawns the manhacks as hacked, if the Interface is.
Start by adding a npc_manhack in the map, naming it something like manhack1 and checking the spawn flag for Template NPC. Create a npc_template_maker, name it something like maker_manhacks, and select manhack1 as Name of template NPC. As Max Live NPCs you can have whatever you want but I would suggest something around 2 or 3. Use Radius 1 and check the spawn flag Always use radius spawn, Infinite Children, and Do Not Drop. Start the maker Disabled.
Create a prop_dynamic as the Manhack Dispenser. As the model I used the Combine Cannon Power Generator from EP2 (models/combine_turrets/combine_cannon_powergen.mdl). If you can't see the EP2 models in Hammer you have to export them into the mod files using programs like GCFScape (even though the mod knows how to mount the files, Hammer doesn't). Name the prop something like model_dispenser. Add outputs Toggle the template maker OnAnimationDone and disable the hurt_dispenser OnAnimationDone.
Add an ambient_generic near the model door. Name it something like sound_manhack_dispenser and use the Sound Name "NPC_CombineCamera.Deploy". Go back to the template maker and add an output for the ambient_generic to PlaySound OnSpawnNPC.
Create a small trigger textured trigger_push inside just so that it cover the hole. Use Push Direction Up, and only check the spawn flag NPCs. Create an info_target inside the hole, just below the model's door, and name it something like target_manhacks. Now wrap a trigger_hurt around the dispenser model. Name it hurt_dispenser and only check the spawn flag NPCs.
Now create and empty box room in a remote location. It doesn't have to be big, just enough for the Manhack to spawn. This is because the template maker can't spawn the Manhack inside model, so they need to be teleported there. Move the npc_template_maker into the room. Create a trigger_teleport brush to cover the whole room. Again only check the spawn flag NPCs, and in Remote Destination select target_manhacks.
Create two logic_relays. First one named relay_dispenser_close. Add the following outputs: SetAnimation "close" to model_dispenser. Enable the relay_dispenser_open, and Disable relay_dispenser_close. Enable hurt_dispenser. Name the second logic_relay relay_dispenser_open and add the outputs: SetAnimation "open" to model_dispenser. Enable relay_dispenser_close, and Disable relay_dispenser_open.
The last thing to do is to call the two logic_relays that enable and disable the dispenser, and to hack the Manhacks when necessary. Add a hlss_combine_interface into the map. Change "Can Toggle Manhacks" to Yes. Add outputs to call relay_dispenser_open OnManhacksEnabled, and to call relay_dispenser_close OnManhacksDisabled.
To allow the Manhacks to be hacked when the Interface is hacked, add a trigger_multiple to cover the room where the template maker is. Name it dispenser_hacker and have it Start Disabled. Back in the Interface add outputs to Enable the trigger_multiple OnHackedOn, and to Disable OnHackedOff. In the trigger_multiple spawn flags once again only check NPCs. Finally add an output to "!activator" to "SetHackedOn". This calls the "SetHackedOn" input function on any entity (if they have it), which in this case is our unlucky Manhack. Because of "!activator" the link will appear red in Hammer.
Back to Tutorials