npc_metropoliceguard ("police") an area against a target entity. If the target comes within range, the officer will chase it out of range - administering
weapon_stunstickbeatings if necessary. Note that it is not required for standard metrocop player provocation/chase behavior.
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.
In code, it is represented by class
CAI_PoliceGoal, defined in
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).
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.
- 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
- Radius (policeradius)
- The radius of the area to police. If a target enters this area, the officer will be provoked.
- Target (policetarget)
- Specifies what target to protect the area against. (
!playeris an option.) Must be specified.
- Classname (classname)
- The classname defines the type of entity. Classnames can be changed using
AddOutput, which will influence how the engine deals with the entity in certain circumstances.
- Name (targetname)
- The name that other entities refer to this entity by.
- Global Entity Name (globalname)
- Name by which this entity is linked to another entity in a different map. When the player transitions to a new map, entities in the new map with globalnames matching entities in the previous map will have the previous map's state copied over their state.
- Parent (parentname)
- 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. Every entity can be parented, even point entities. Entities which are parented will be forced to transition to the next map, such as from a
trigger_transition. Some entities which aren't intended to be parented may not function correctly.
phys_constraintcan be used as a workaround to parenting.
- Origin (X Y Z) (origin)
- The position of this entity's center in the world. Rotating entities typically rotate around their origin.
- Pitch Yaw Roll (X Y Z) (angles)
- 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.Note:This works on brush entities, although Hammer doesn't show the new angles.
- Flags (spawnflags)
- Toggles features of an entity, its specific number is determined by the combination of flags added.
- Response Contexts (ResponseContext)
- Pre-defined response system contexts for this entity. Format is
key:value,key:value,.... Contexts may be filtered.
- Effects (effects)
- Combination of effect flags to use.
- Local Time (ltime)
- The local time of the entity, independent of the global clock. Used mainly for physics calculations.
- Next Think (nextthink)
- Amount of time before the entity thinks again.
- Hammer ID (hammerid)
- The entity's Hammer ID. Mainly used by plugins and debugging commands, such as
ent_keyvalue. Can be manually assigned with the "hammerid" or "id" keyvalue. Entities spawned at run-time are not assigned any Hammer ID.
- Enables knock out behavior described above.
- Disables knock out behavior described above.
- Removes this entity and any entities parented to it from the world.
- Functions the same as
Kill, although this entity and any entities parented to it are killed on the same frame.
- Move with this entity. See Entity Hierarchy (parenting).
- 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.
- As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
- Removes this entity from the the movement hierarchy, leaving it free to move independently.
- Evaluates a keyvalue/output on this entity.
<output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
- Fire the
OnUseroutputs; see User Inputs and Outputs.
- Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input.
This input is not included in Valve's FGDs.
- Dispatches a special effect from the entity's origin. Removed and replaced entirely by the particle system since .
- Dispatches a response to the entity. See Response and Concept.
- Adds to the entity's list of response contexts. Format is
- Remove a context from this entity's list. The name should match the key of an existing context.
- Removes all contexts from this entity's list.
- Fires the first time a policing officer warns a target.
- Fires the second time a policing officer warns a target.
- Fires when a policing officer warns a target for the last time.
- Fires when a policing officer starts to suppress (ie. beat) a target.
- Fires when a target has been knocked out.
- These outputs each fire in response to the firing of the like-numbered
FireUser4Input; see User Inputs and Outputs.