Ai relationship
Jump to navigation
Jump to search
Template:Base point It sets a relationship type between two parties. These parties can be an NPC, an NPC class, or the player(s).
Dispositions:
- Error (D_ER): Rarely, a problem can occur and result in this disposition. NPCs will probably behave similar to Neutral.
- Hate (D_HT): Considers the target an enemy/enemies and will attack.
- Fear (D_FR): 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.
- Like (D_LI): Will not attack the target. Rebels follow automatically, and can be commanded. The player's weapon will play lowering animations when looking at the target. Zombies will remain still and only turn to face the target.
- Neutral (D_NU): Will not attack. Rebels avoid player apologetically, and cannot be commanded. Zombies will remain still and only turn to face the target.
Relationships are not limited to NPCs. Some objects (CBaseCombatCharacter) can also have relationships.

Flags
- 1: Notify subject of target's location
- 2: Notify target of subject's location
Keyvalues
- Subject(s) (subject) ([todo internal name (i)]) <target_name_or_class>
- The targetname or classname of the NPCs whose disposition will change.
- Subject Class (subjectclass) ([todo internal name (i)]) <classname> (in all games since
)
- As above, for classnames only.
- Target(s) (target) ([todo internal name (i)]) <target_name_or_class>
- The targetname or class name of the NPCs about whom the subject(s) will change their disposition towards.
Tip:Use
!player
for the player.
- Target Class (targetclass) ([todo internal name (i)]) <classname> (in all games since
)
- As above, for classnames only.
- Disposition (disposition) ([todo internal name (i)]) <choices>
- The way the subject(s) should feel about the target(s)
- Hate
- Fear
- Like
- Neutral
- Radius for subject (radius) ([todo internal name (i)]) <float>
- Only NPCs within this distance of the entity will have their dispositions changed.
- Disposition Priority (rank) ([todo internal name (i)]) <integer>
- How much the subject(s) should Like/Hate/Fear the target(s). Higher priority = stronger feeling.
- Start Active (StartActive) ([todo internal name (i)]) <boolean>
- Apply this relationship as soon as the entity spawns?
- Reciprocal (Reciprocal) ([todo internal name (i)]) <boolean>
- Make the new disposition apply to the targets as well as the subjects.
Inputs
- ApplyRelationship
- 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 aDisable
orRevertRelationship
input. 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.
- RevertRelationship
- Revert relationship changes. This will return the relationship to what it was at the time the
ApplyRelationship
input was called (or when this ai_relationship was spawned if Start Active is set).
- RevertToDefaultRelationship
- 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.