From Valve Developer Community
ai_relationship is a point entity available in all Source games.
Entity descriptionNPC, an NPC class, or the player(s).
- Will not attack the target. Rebels follow automatically, and can be commanded. The player will lower his gun until the target shows signs of hostility (but can still shoot the target before this). Zombies will remain still and only turn to face the target.
- Will not attack. Rebels avoid player apologetically, and cannot be commanded. Zombies will remain still and only turn to face the target.
- Considers the target an enemy/enemies and will attack.
- Avoids the target. Headcrabs run away without attacking. Metropolice attacks. Rebels avoid without attacking, and cannot be commanded. Zombies will occasionally also swipe at the target as if it is in their flight path, but these swipes will afflict no damage to player, unless the zombie has been attacked.
- The targetname or class name (e.g. npc_zombie) of the NPCs whose disposition will change.
- The targetname or class name of the NPCs about whom the subject(s) will change their disposition. Tip:Use
!playerfor the player.
- The way the subject(s) should feel about the target(s)
- Radius for subject
- Only NPCs within this distance of the entity will have their dispositions changed.
- Disposition Priority
- To do: add description
- Start Active
- Apply this relationship as soon as the entity spawns?
- Make the new disposition apply to the targets as well as the subjects.
- The targetname that other entities refer to this entity by.
- Entity Scripts
<scriptlist>(New with Left 4 Dead 2)
- Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
- Script think function
<string>(New with Left 4 Dead 2)
- Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call. Note:Try to avoid expensive operations in this function, as it may cause performance problems.
- Notify subject of target's location
- Notify target of subject's location
- Apply relationship changes. This will change all subject entities' relationships to all target entities. Note:Once you fire
ApplyRelationship, the entity is on until you send a
RevertRelationshipinput. During the time any entities that spawn who match the subject or target names will be affected.Warning:Unpredictable results may occur when two ai_relationship entities refer to the same set or subset of target or subject entities. This situation should be avoided.
- Revert relationship changes. This will return the relationship to what it was at the time the
ApplyRelationshipinput was called (or when this ai_relationship was spawned if Start Active is set).
- Revert relationship changes to the default relationship, which may have changed since this ai_relationship was applied. This returns control of the entity relationship to the code.
- Removes this entity from the world.
- Removes this entity and all its children from the world.
- Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
<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.
<script>(New with Left 4 Dead 2)
- Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
<string>(New with Left 4 Dead 2)
- Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console. Bug:Warning:Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
<string>(New with Left 4 Dead 2) !FGD
- Execute a VScript function in the scope of the receiving entity. Note:This input is missing from some games FGD files.
<origin>(New with Alien Swarm) !FGD
- Set this entity's origin in the map. Note:This input is missing from some games FGD files.
<angles>(New with Alien Swarm) !FGD
- Set this entity's angles in the map. Note:This input is missing from some games FGD files.
- These Outputs each fire in response to the firing of the like-numbered
FireUser4Input; see User Inputs and Outputs.
(New with Left 4 Dead)
- This Output fires when the entity is killed and removed from the game.