Ai relationship: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Removed link to nonexistent page Disposition. If this page has been moved to a different name since 2008, please revert and fix my edit.)
No edit summary
Line 1: Line 1:
{{wrongtitle|title=ai_relationship}}
{{toc-right}}


== Entity description ==
[[Image:{{PAGENAME}}.png|left]]
[[Image:{{PAGENAME}}.png|right]]
Sets a relationship type between two parties. These parties can be an [[NPC]], an NPC class, or the player(s).
There are four types of relation: Neutral, hate, like and fear. Certain NPC classes will react differently when in these states.


{{TODO|Do some more behavioral research on NPC(s) and post your observations below. Possibly these results could later on be placed in the corresponding article of each NPC instead.}}
{{base point|ai_relationship}} It sets a relationship type between two parties. These parties can be an [[NPC]], an NPC class, or the player(s).{{clearleft}}


== Dispositions ==
;Like
: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.
;Neutral
;Neutral
:Will not attack. Rebels avoid player apologetically, and cannot be commanded. [[Npc_zombie|Zombies]] will remain still and only turn to face the target.
:Will not attack. Rebels avoid player apologetically, and cannot be commanded. [[Npc_zombie|Zombies]] will remain still and only turn to face the target.
;Hate
;Hate
:Considers the target an enemy/enemies and will attack.
:Considers the target an enemy/enemies and will attack.
;Like
: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.
;Fear
;Fear
:Avoids the target. [[Npc_headcrab|Headcrabs]] run away without attacking. [[Npc_metropolice|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.
:Avoids the target. [[Npc_headcrab|Headcrabs]] run away without attacking. [[Npc_metropolice|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.
{{note|The relationship can refer to the player as <code>!player</code> (single-player) or any client as <code>player</code> (single-player or multiplayer).}}


== See also ==
== See also ==
* [[List of default AI relationships]]
* [[List of default AI relationships]]


== Keyvalues ==
== KeyValues ==
* {{KV Targetname}}
 
* '''subject'''
{{KV|Subject(s)|targetname|The targetname ''or'' class name (e.g. npc_zombie) of the NPCs whose disposition will change.}}
:<target_name_or_class> This is the NPC(s) whose disposition will change.
{{KV|Target(s)|targetname|The targetname ''or'' class name of the NPCs about whom the subject(s) will change their disposition. {{tip|Use <code>!player</code> for the player.}}}}
* '''target'''
{{KV|Disposition|choices|The way the subject(s) should feel about the target(s)
:<target_name_or_class> This is the NPC(s) ( or <code>!player</code> or <code>player</code> ) about whom the Subject(s) will change their disposition.
:* Hate
* '''disposition'''
:* Fear
:<choices> Choose the way the Subject(s) should feel about the target(s)
:* Like
:{| class=standard-table
:* Neutral
! Literal Value || Description
}}
|-
{{KV|Radius for subject|float|Only NPCs within this distance of the entity will have their dispositions changed.}}
| 1 || Hate
{{KV|Disposition Priority|int|How much the subject(s) should Like/Hate/Fear the target(s). Higher priority = stronger feeling.}}
|-
{{KV|Start Active|bool|Apply this relationship as soon as the entity spawns?}}
| 2 || Fear
{{KV|Reciprocal|bool|Make the new disposition apply to the targets as well as the subjects.}}
|-
{{KV Targetname}}
| 3 || Like
|-
| 4 || Neutral
|}
* '''radius'''
:<float> Radius for subject
* '''rank'''
:<integer> How much the Subject(s) should Like/Hate/Fear the target(s). Higher priority = stronger feeling.
* '''StartActive'''
: {{boolean}}
* '''Reciprocal'''
: {{boolean}} Set this to have the new relationship mirrored by target


== Flags ==
== Flags ==
* {{EP1 add|1 : Notify subject of target's location}}
 
* {{EP1 add|2 : Notify target of subject's location}}
* Notify subject of target's location
* Notify target of subject's location


== Inputs ==
== Inputs ==
* {{I Targetname}}
* '''ApplyRelationship'''
:Apply relationship changes
* '''RevertRelationship'''
:Revert relationship changes


* '''{{EP1 add|RevertToDefaultRelationship}}'''
{{IO|ApplyRelationship|Apply relationship changes. This will change all subject entities' relationships to all target entities. {{note|Once you fire <code>ApplyRelationship</code>, the entity is on until you send a <code>Disable</code> or <code>RevertRelationship</code> 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.}}}}
: 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.
{{IO|RevertRelationship|Revert relationship changes. This will return the relationship to what it was at the time the <code>ApplyRelationship</code> input was called (or when this ai_relationship was spawned if ''Start Active'' is set).}}
{{IO|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.}}
{{I Targetname}}


== Outputs ==
== Outputs ==
* {{O Targetname}}
{{O Targetname}}


[[Category:AI]]
[[Category:AI]]
[[Category:Entities]]

Revision as of 15:48, 29 June 2011

Ai relationship.png

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

Like
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.
Neutral
Will not attack. Rebels avoid player apologetically, and cannot be commanded. Zombies will remain still and only turn to face the target.
Hate
Considers the target an enemy/enemies and will attack.
Fear
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.

See also

KeyValues

Subject(s) ([todo internal name (i)]) <targetname>
The targetname or class name (e.g. npc_zombie) of the NPCs whose disposition will change.
Target(s) ([todo internal name (i)]) <targetname>
The targetname or class name of the NPCs about whom the subject(s) will change their disposition.
Tip.pngTip:Use !player for the player.
Disposition ([todo internal name (i)]) <choices>
The way the subject(s) should feel about the target(s)
  • Hate
  • Fear
  • Like
  • Neutral
Radius for subject ([todo internal name (i)]) <float>
Only NPCs within this distance of the entity will have their dispositions changed.
Disposition Priority ([todo internal name (i)]) <integer>
Start Active ([todo internal name (i)]) <boolean>
Apply this relationship as soon as the entity spawns?
Reciprocal ([todo internal name (i)]) <boolean>
Make the new disposition apply to the targets as well as the subjects.
Name (targetname) <string>[ Edit ]
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

Flags

  • Notify subject of target's location
  • Notify target of subject's location

Inputs

ApplyRelationship
Apply relationship changes. This will change all subject entities' relationships to all target entities.
Note.pngNote:Once you fire ApplyRelationship, the entity is on until you send a Disable or RevertRelationship input. During the time any entities that spawn who match the subject or target names will be affected.
Warning.pngWarning: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.


Outputs