ai_goal_police

From Valve Developer Community

Revision as of 03:06, 20 January 2009 by VDCBot (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search


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.

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.)

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

  • Targetname:

Name <string>
The targetname other entities refer to this entity by.
  • Parentname:

Parent <targetname>
Specifies the targetname of this entity's movement parent. Entities with parents move with their parent.
  • Angles:

Pitch Yaw Roll (Y Z X) <angle>
This entity's angular orientation in the world.
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

  • Targetname:

Kill
Removes this entity from the world.
KillHierarchy
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 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
  • Parentname:

SetParent <targetname>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Attach to a named attachment on the current parent. The entity will teleport so that the position of its root bone matches that of the attachment.
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 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

  • Targetname:

OnUser1 to OnUser4
Fired in response to the FireUser inputs; see User Inputs and Outputs.
OnKilled (New with Left 4 Dead)
Fired when the entity is killed and removed from the game.
  • 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.
Personal tools