WiseNPCrappel: NPC police rappel

From Valve Developer Community
Jump to navigation Jump to search


This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

Note.pngNote:This is part of a series of tutorials on NPC’s.
Rapelling

The sample file for this project, at the page bottom, illustrates:

  1. Player spawns in cement room with hole in ceiling.
  2. Combine police rappels from hole.
  3. Once on ground begins attacking player.

These are very simple to setup in your maps.

I’m doing more in this project than is necessary.

  1. You don’t have to spawn the NPC with an npc_template_maker. Using one however is better on performance and keeps the NPC hidden until needed.
  2. You don’t need the aiscripted_schedule. But it is a simple addition creating a much better effect.

The simple method is to:

  1. Place an npc_metropolice entity in the map where you want it to rappel from.
  2. Set the property Waiting to rappel to Yes.
  3. From any other entity, like a trigger, send the input BeginRappel.

Using the simple method requires that you hide the npc_metropolice until its time to rappel.

Entities

In this project the trigger_once is used to spawn the npc_metropolice by way of an npc_template_maker.

trigger_once

Class: trigger_once
Keyvalues Comments
Start disabled No
Flag
Checkbox-on.png Clients
My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnTrigger rappel1maker Spawn

npc_template_maker

Class: npc_template_maker
Keyvalues Comments
Start disabled Yes
Num of NPCs 1
Frequency 1
Max live NPCs 1
Name of template NPC rappel1
My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnSpawnNPC rappel1 BeginRappel 0.25

npc_metropolice

Class: npc_metropolice
Keyvalues Comments
Waiting to Rappel Yes
Weapons SMG
Number of manhacks None
Pistols start drawn Yes
Flag
Checkbox-on.png Clients
Checkbox-on.png Simple cops
Checkbox-on.png Fall to ground
Checkbox-on.png Template NPC
My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnRappelTouchdown rappel1ss StartSchedule 0.0

aiscripted_schedule

Class: aiscripted_schedule
Keyvalues Comments
Name rappel1ss
AI state to set Set state to COMBAT
Schedule to run Set enemy to Goal Entity AND Run to Goal Entity
Interruptability Damage or Death
Goal entity !player

Setup in Hammer

In the image below you can see the npc_metropolice waiting to rappel, and the trigger_once that will begin the rappel.

I’ve placed info_node entities on the ground in random spots to give the NPC Police walking hints.

That’s all there is to it. Give them enough room to rappel and they can drop off ledges, from planes or out of holes in the ceiling.

See also