Ai goal police
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 the selected npc_metropolice a SetPoliceGoal input, with the ai_goal_police 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.
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.)
Before activating his stunstick (if equipped, not essential though), the officer will push the player back a number of times before unholstering it, and finally activating it.
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 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.)
This does not work on other NPCs, if you want this effect on Citizens you would have to script it or something of similar effect.
Keyvalues
- Name (targetname) <string>[ Edit ]
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentname
ortarget
).
Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
- Parent (parentname) <targetname>
- Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma.
- Pitch Yaw Roll (Y Z X) (angles) <QAngle>
- This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
- 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
!player
to 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
- SetParent <string >
- Move with this entity. See Entity Hierarchy (parenting).
- SetParentAttachment <string >
- Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
- SetParentAttachmentMaintainOffset <string >
- As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
- ClearParent
- Removes this entity from the the movement hierarchy, leaving it free to move independently.
- 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
- 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.