Ai goal police
From Valve Developer Community
Makes a npc_metropolice guard ("police") an area against a target entity. If the target comes within range, the officer will chase it out of range - administering stunstick beatings if necessary. Note that it is not required for standard metrocop player provocation/chase behaviour.Trigger it by sending a SetPoliceGoal input, with its targetname as a parameter.
This AI goal will override any AI relationships (so you will not have to use an ai_relationship to make the officer not attack the player just because npc_metropolice hates the player by default). However, behaviour is influenced by whether the "Gordon pre-criminal" global has been set.
| Table of contents |
Police Behavior
The officer will walk to his post (located in the very center of the guard post area) and stand there facing the direction specified.
If the specified police targets (NPCs or the player) enters the guard post area, the officer will be provoked.
If the officer doesn't have a stun stick, he will just give verbal warnings when provoked.
If the officer has a stun stick, he will also activate it to warn the target, and will suppress (beat) those who dares to get within his reach. (This does damage.)
If provoked enough, the officer will finally (by default) leave his post to give chase to the target until its out of the guard post area, after which he will return to his post (if he can find his way back to it).
Knock Outs
The officer can also use his stun stick to knock a target (
To do: Just the player?) out in one hit if instructed to do so by the Knock-out target past crossing plane flag, or the EnableKnockOut input.
If the player is knocked out, the whole screen will turn white so the player can't see anything, but he can still move around just as normal, so this needs to be combined with sending the OnKnockOut output to other entities to be realistic. (In HL2, the player normally wakes up outside the guard post area, presumably having been carried there.)
Keyvalues
- targetname <target_source>
- Defines the name that other entities refer to this entity by.
- hammerid [Episode Two Update]
- <integer readonly> This id is used for debugging purposes in Hammer.
- parentname <target_destination>
- Specifies the targetname of this entity's Parent in a movement hierarchy. Child entities move with their Parent.
- Pitch Yaw Roll (Y Z X)
- This entity's angular orientation in the world (also used for angular effect entities).
- The guarding officer will turn to face this angle by default. The "crossing plane" runs 90 degress across this direction.
- policeradius
- <float> Radius to police - The radius of the guard post area. If a police target enters this area, the officer will be provoked.
- policetarget
- <target_destination> Target to police - Specifies what target to protect the area against. (You can set this to
!playerto make it guard the area against the player.) (Must be specified.)
Flags
- 2 : Knock-out target past crossing plane
- While the police target is behind the crossing plane (defined by the angles keyvalue) knock out will be enabled for the officer.
- 4 : Do not leave post
- The officer will not leave his post to chase the target, no matter how provoked he will be. This is very useful when guarding entrances, as the target may otherwise lure the officer away from it and then circle around him and get past him. (You can try this tactic in HL2 with the officer who wants you to put the can in the trash at the beginning of the d1_trainstation_02 map.)
Inputs
- Kill
- Removes this entity from the world.
- Removes this entity and all its children from the world.
- AddOutput <string>
- Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
- Format:
<key> <value> - Format:
<output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>
- Causes this entity's OnUser1-4 outputs to be fired. See User Inputs and Outputs.
- SetParent <target_destination>
- Changes the entity's parent in the movement hierarchy.
- SetParentAttachment <string>
- Change this entity to attach to a specific attachment point on its parent. Entities must be parented before being sent this input. The parameter passed in should be the name of the attachment.
- SetParentAttachmentMaintainOffset <string> [Episode One Update]
- Change this entity to attach to a specific attachment point on it's parent. Entities must be parented before being sent this input. The parameter passed in should be the name of the attachment. The entity will maintain it's position relative to the Parent's Origin and Angles at the time it is attached.
- Removes this entity from its current movement hierarchy.
- EnableKnockOut
- Tells the goal to make the active policing NPC knock out its target.
- DisableKnockOut
- Stop the active policing NPC from trying to knock out its target.
Outputs
- Fired in response to FireUser1-4 inputs. See User Inputs and Outputs.
- !activator = activator
- OnFirstWarning
- Fires the first time a policing officer warns a target.
- OnSecondWarning
- Fires the second time a policing officer warns a target.
- OnLastWarning
- Fires when a policing officer warns a target for the last time.
- OnSupressingTarget
- Fires when a policing officer starts to suppress (ie. beat) a target.
- OnKnockOut
- Fires when a target has been knocked out.
Categories: TODO | Parentable Entities | AI | Entities

