ai_goal_police

From Valve Developer Community
Jump to: navigation, search
English (en)Translate (Translate)
Class hierarchy
CAI_PoliceGoal
CBaseEntity
ai_goal_police.cpp
Ai goal police.png

ai_goal_police is a point entity available in Half-Life 2 Half-Life 2, Half-Life 2: Episode One Half-Life 2: Episode One, Half-Life 2: Episode Two Half-Life 2: Episode Two, and Half-Life 2: Deathmatch Half-Life 2: Deathmatch.

Entity description

Makes an 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 weapon_stunstick beatings if necessary. Note that it is not required for standard metrocop player provocation/chase behavior.

Trigger it by sending the selected npc_metropolice a SetPoliceGoal input, with the ai_goal_police's 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, behavior is influenced by whether the "Gordon pre-criminal" global has been set.

Note.pngNote:This entity is also in the code for Portal. Its functionality is not guaranteed.


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 Target (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 (other nearby officers may attack for the officer if they have a stun stick). 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 holding it up, 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. The crossing plane runs perpendicular to this entity's Pitch Yaw Roll

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 function for NPCs, if you want this effect on citizens you would have to script it or something of similar effect.

Flags

  • 2: Knock-out target past crossing plane
While the police target is behind the crossing plane (defined by this entity's Pitch Yaw Roll) knock out behavior described above 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. (Multiple examples of use on d1_trainstation_02.)

Keyvalues

Name (targetname) <string>
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Radius (policeradius) <float>
The radius of the area to police. If a target enters this area, the officer will be provoked.
Target (policetarget) <targetname>
Specifies what target to protect the area against. (!player is an option.) Must be specified.

Inputs

EnableKnockOut
Enables knock out behavior described above.
DisableKnockOut
Disables knock out behavior described above.

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.