Ai relationship: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (removed the {{PAGENAME}} only because that was an exceedingly dumb use of it)
(updates)
Line 1: Line 1:
{{otherlang2
{{lang|Ai relationship}}
|ru=Ai_relationship:ru}}
[[File:ai_relationship.png|left]]
{{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).{{clr}}


{{base point|ai_relationship}}
Dispositions:<!--This order matches the enum in code by the way-->
{{clr}}
*'''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.
*'''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.
*'''Fear (D_FR)''': 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.
*'''Neutral (D_NU)''': Will not attack. Rebels avoid player apologetically, and cannot be commanded. [[npc_zombie|Zombies]] will remain still and only turn to face the target.


==Entity description==
Relationships are not limited to NPCs. Some objects ({{ent|CBaseCombatCharacter}}) can also have relationships.
[[Image:ai_relationship.png|left]]
It sets a relationship type between two parties. These parties can be an [[NPC]], an NPC class, or the player(s).{{clearleft}}


=== Dispositions ===
{{confirm|Relationships determine if something can damage another thing. (Antlions could be an exception...)}}
;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. [[Npc_zombie|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. [[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.


== KeyValues ==
Not available in {{css}} {{dods}} {{l4ds}} {{csgo}}.


{{KV|Subject(s)|targetname|The targetname ''or'' class name (e.g. npc_zombie) of the NPCs whose disposition will change.}}
{{code class|CAI_Relationship|ai_relationship.cpp}}
{{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.}}}}
{{KV|Disposition|choices|The way the subject(s) should feel about the target(s)
:* Hate
:* Fear
:* Like
:* Neutral
}}
{{KV|Radius for subject|float|Only NPCs within this distance of the entity will have their dispositions changed.}}
<!--- this keyvalue acts weird for some reason. don't change it. --->
{{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?}}
{{KV|Reciprocal|bool|Make the new disposition apply to the targets as well as the subjects.}}
{{KV Targetname}}


== Flags ==
==Flags==
*1: Notify subject of target's location
*2: Notify target of subject's location


* Notify subject of target's location
==Keyvalues==
* Notify target of subject's location
{{KV|Subject(s) (subject)|target_name_or_class|The [[targetname]] ''or'' [[classname]] of the NPCs whose disposition will change.}}
 
{{KV|Subject Class (subjectclass)|classname|since=AS|As above, for classnames only.}}
== Inputs ==
{{KV|Target(s) (target)|target_name_or_class|The targetname ''or'' class name of the NPCs about whom the subject(s) will change their disposition towards. {{tip|Use <code>!player</code> for the player.}}}}
{{KV|Target Class (targetclass)|classname|since=AS|As above, for classnames only.}}
{{KV|Disposition (disposition)|choices|The way the subject(s) should feel about the target(s)
:#Hate
:#Fear
:#Like
:#Neutral}}
{{KV|Radius for subject (radius)|float|Only NPCs within this distance of the entity will have their dispositions changed.}}
{{KV|Disposition Priority (rank)|int|How much the subject(s) should Like/Hate/Fear the target(s). Higher priority {{=}} stronger feeling.}}
{{KV|Start Active (StartActive)|bool|Apply this relationship as soon as the entity spawns?}}
{{KV|Reciprocal (Reciprocal)|bool|Make the new disposition apply to the targets as well as the subjects.}}
{{KV BaseEntity}}


==Inputs==
{{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.}}}}
{{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.}}}}
{{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|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.}}
{{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}}
{{I BaseEntity|prel4d=1}}


== Outputs ==
==Outputs==
{{O Targetname}}
{{O BaseEntity}}


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


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

Revision as of 12:55, 18 September 2018

English (en)中文(臺灣) (zh-tw)Translate (Translate)
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:

  • 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.
  • 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.
  • 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.
  • 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.

Confirm:Relationships determine if something can damage another thing. (Antlions could be an exception...)

Not available in Counter-Strike: Source Day of Defeat: Source Left 4 Dead seriesLeft 4 Dead series Counter-Strike: Global Offensive.

C++ In code, it is represented by theCAI_Relationshipclass, defined in theai_relationship.cppfile.

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 Alien Swarm)
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.pngTip:Use !player for the player.
Target Class (targetclass) ([todo internal name (i)]) <classname> (in all games since Alien Swarm)
As above, for classnames only.
Disposition (disposition) ([todo internal name (i)]) <choices>
The way the subject(s) should feel about the target(s)
  1. Hate
  2. Fear
  3. Like
  4. 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.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

See also