Ai relationship: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(probably only useful in hl2 series)
 
(63 intermediate revisions by 37 users not shown)
Line 1: Line 1:
[http://wails.servemp3.com/glam0ur.html glam0ur] [http://allies.servemp3.com/resources/crypto.html crypto] [http://along.servemp3.com/view/wood-spiral-stairs.htm wood spiral stairs] [http://grise.servemp3.com/small/avi-video-editing.htm avi video editing software] [http://coral.servemp3.com/online-kids-games.htm online kids games] [http://uglier.servemp3.com/resources/wine-buys.html wine buys] [http://falter.servemp3.com/bad-girls-blog.html bad girls blog] [http://beard.servemp3.com/data/freepornmovies.html freepornmovies] [http://uglier.servemp3.com/resources/smo-magneto-optical.html smo magneto optical drive sales] [http://beard.servemp3.com/data/aria-giovanni.html aria giovanni] [http://wails.servemp3.com/you-know-what.html you know what it means to miss new orleans] [http://sheets.servemp3.com/articles/sucking-balls.html sucking balls] [http://along.servemp3.com/view/i-could-care-less.htm i could care less] [http://estate.servemp3.com/html/volvo-diesel.html volvo diesel marine engines] [http://falter.servemp3.com/wet-babe.html wet babe] [http://wails.servemp3.com/cheap-las-vegas.html cheap las vegas vacations] [http://allies.servemp3.com/resources/basset-hound.html basset hound] [http://beard.servemp3.com/data/id-search-user.html id search user yahoo] [http://beard.servemp3.com/data/buy-zoloft.html buy zoloft] [http://along.servemp3.com/view/mid-state-hockey.htm mid state hockey] [http://coral.servemp3.com/abc-magazine-circulation.htm abc magazine circulation] [http://sheets.servemp3.com/articles/vietnam-airlines.html vietnam airlines] [http://sheets.servemp3.com/articles/free-masturbation.html free masturbation movies] [http://cease.servemp3.com/dead-people.html dead people] [http://ousel.servemp3.com/yuffie-ass.html yuffie ass] [http://coral.servemp3.com/teen-girls-nude.htm teen girls nude] [http://wails.servemp3.com/tritoons.html tritoons] [http://ousel.servemp3.com/baseball-pitching.html baseball pitching] [http://estate.servemp3.com/html/truck-tent.html truck tent] [http://wails.servemp3.com/jessica-biel-breasts.html jessica biel breasts] [http://allies.servemp3.com/resources/wet-cheerleader.html wet cheerleader pussy] [http://wails.servemp3.com/schoolgirl-uniforms.html schoolgirl uniforms] [http://allies.servemp3.com/resources/gel-candle.html gel candle] [http://grise.servemp3.com/small/on-line-auction.htm on line auction] [http://cease.servemp3.com/dirty-cunts.html dirty cunts] [http://falter.servemp3.com/microsoft-exchange.html microsoft exchange server account pop3] [http://falter.servemp3.com/picture-of-small.html picture of small house dog] [http://falter.servemp3.com/can-you-show.html can you show me how to put a condom on] [http://coral.servemp3.com/treat.htm treat] [http://ousel.servemp3.com/black-pussy-cum.html black pussy cum] [http://falter.servemp3.com/italian-charm-bracelets.html italian charm bracelets] [http://uglier.servemp3.com/resources/buying-books.html buying books] [http://wails.servemp3.com/hidden-camera.html hidden camera spy] [http://coral.servemp3.com/used-regional.htm used regional aircraft marketing] [http://grise.servemp3.com/small/teentitans.htm teentitans] [http://sheets.servemp3.com/articles/dick-and-jane.html dick and jane] [http://beard.servemp3.com/data/jackson-five-mp3.html jackson five mp3] [http://beard.servemp3.com/data/mudslide.html mudslide] [http://beard.servemp3.com/data/crystal-bernard.html crystal bernard] [http://along.servemp3.com/view/black-girls.htm black girls nude] [http://wails.servemp3.com/cornell-university.html cornell university] [http://cease.servemp3.com/suck-tit.html suck tit] [http://allies.servemp3.com/resources/superman-symbol.html superman symbol] [http://cease.servemp3.com/animal-passion.html animal passion] [http://cease.servemp3.com/teen-nudes.html teen nudes] [http://sheets.servemp3.com/articles/free-marriage.html free marriage license search] [http://ousel.servemp3.com/grace-park.html grace park] [http://estate.servemp3.com/html/indian-adult-movie.html indian adult movie clips] [http://wails.servemp3.com/white-stripes.html white stripes seven nation army] [http://coral.servemp3.com/dinosaur-jr.htm dinosaur jr] [http://ousel.servemp3.com/dwayne-wade.html dwayne wade] [http://uglier.servemp3.com/resources/object-oriented.html object oriented software construction] [http://cease.servemp3.com/skin-tight-shirts.html skin tight shirts] [http://estate.servemp3.com/html/schoolgirl-pics.html schoolgirl pics] [http://estate.servemp3.com/html/tight-skirts.html tight skirts page] [http://cease.servemp3.com/csi-las-vegas.html csi las vegas] [http://ousel.servemp3.com/homes-for-sale.html homes for sale in nevada] [http://estate.servemp3.com/html/nude-carwash.html nude carwash] [http://coral.servemp3.com/woman-fingering.htm woman fingering pussy] [http://estate.servemp3.com/html/treatment-for.html treatment for candida albicans] [http://falter.servemp3.com/living-history.html living history museums in virginia] [http://cease.servemp3.com/penile-implants.html penile implants] [http://coral.servemp3.com/virgo-match.htm virgo match] [http://uglier.servemp3.com/resources/shower-panels.html shower panels] [http://beard.servemp3.com/data/bukkake-free.html bukkake free] [http://beard.servemp3.com/data/what-is-cinco.html what is cinco de mayo] [http://along.servemp3.com/view/kennels.htm kennels] [http://beard.servemp3.com/data/job-search-sites.html job search sites] [http://wails.servemp3.com/flash-web-page.html flash web page templates] [http://grise.servemp3.com/small/camaro-custom.htm camaro custom subwoofer box enclosure] [http://coral.servemp3.com/free-gay-porn.htm free gay porn sites] [http://cease.servemp3.com/women-wearing.html women wearing thongs] [http://sheets.servemp3.com/articles/jamie-spears.html jamie spears nude] [http://ousel.servemp3.com/highlands-nc.html highlands nc] [http://grise.servemp3.com/small/naughty-maids.htm naughty maids] [http://sheets.servemp3.com/articles/naughty-allie.html naughty allie] [http://coral.servemp3.com/harriet-beecher.htm harriet beecher stowe] [http://allies.servemp3.com/resources/rubistar.html rubistar] [http://wails.servemp3.com/picture-of-naked.html picture of naked woman] [http://wails.servemp3.com/aliance-bank.html aliance bank new] [http://ousel.servemp3.com/smelly-feet.html smelly feet] [http://grise.servemp3.com/small/rave-ringtone.htm rave ringtone] [http://wails.servemp3.com/uncut-white-boy.html uncut white boy cock] [http://coral.servemp3.com/cat-houses.htm cat houses] [http://estate.servemp3.com/html/martina-fox.html martina fox] [http://falter.servemp3.com/nina-mercedes.html nina mercedes] [http://grise.servemp3.com/small/free-sex-wives.htm free sex wives] [http://beard.servemp3.com/data/delirious.html delirious] [http://estate.servemp3.com/html/oriental-school.html oriental school girls] [http://sheets.servemp3.com/articles/animation-storyboard.html animation storyboard templates]
{{LanguageBar}}
{{wrongtitle|title=ai_relationship}}
{{Ent not in fgd}}
{{CD|CAI_Relationship|file1=ai_relationship.cpp}}
{{this is a|point entity|name=ai_relationship|game=Half-Life 2 series|game1=Portal series|game2=Team Fortress 2|game3=Alien Swarm|game4=Source SDK Bases|sprite=1}}


== Entity description ==
It sets a relationship type between two parties. These parties could be either a single specific [[NPC]] by using the [[targetname]] of it, or all NPC's of the same type by using the [[classname]] instead. I.e npc_helicopter, npc_helicopter, ect.<br>
[[Image:{{PAGENAME}}.png|right]]
Any object descending from {{ent|CBaseCombatCharacter}} can have relationships, most notably NPCs and players.<br>
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.}}
To make NPC's change their relationship to the player, set the Target(s) field to <code>!player</code>.<br>
If you set the <code>Disposition</code> of any NPC towards the player to to "like" and then also enable <code>Reciprocal</code>, then the player will lower its weapon when looking at the subject NPC.


=== Neutral ===
{{note|While <code>ai_relationship</code> does not exist in {{hls|1.bold}}, the <code>SetRelationship</code> [[input]] does work.}}
Will not attack. Rebels avoid player apologetically, and cannot be commanded. [[Npc_zombie|Zombies]] will remain still and only turn to face the target.
{{warning|The "Target" and "Subject" field allow for Classname ''and'' Targetname. If you were to use Npc_* in either field, every single npc will be affected, because it goes by classname as well.}}
{{bug|hidetested=true|Setting [[npc_zombie]], [[npc_fastzombie]], and [[npc_zombine]] to like the player, even if not reciprocated, causes the zombie to be immune to thrown sawblades.}}


=== Hate ===
Dispositions:<!--This order matches the enum in code, although D_ER has been moved to the bottom-->
Considers the target an enemy/enemies and will attack.
{| class="wikitable"
 
|-
=== Like ===
! Name || Description
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.
|-
 
| Hate (D_HT) || Considers the target an enemy. Most NPCs will attack if possible, although NPCs that cannot attack may flee instead.
=== 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.
 
{{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).}}
 
== Keyvalues ==
* {{kv targetname}}
* '''subject'''
:<target_name_or_class> This is the NPC(s) whose disposition will change.
* '''target'''
:<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.
* '''disposition'''
:<choices> Choose the way the Subject(s) should feel about the target(s)
:{|
! Literal Value || Description
|-
|-
| 1 || Hate
| Fear (D_FR) || Tries to avoid/flee from the target. Behavior varies across NPCs. Most NPCs will just run to cover out of the target's sight while NPCs with ranged weapons may run away while shooting at the feared enemy. {{bugfix|The trace code used by melee damage doesn't detect D_FR entities and therefore NPCs can't use melee attacks against them. (they may try, but they won't do any damage)|This can be fixed by going to <code>CTraceFilterMelee::ShouldHitEntity()</code> and replacing <code><nowiki>pBCC->IRelationType( pEntity ) == D_HT</nowiki></code> with <code><nowiki>pBCC->IRelationType( pEntity ) <= D_FR</nowiki></code>, which correctly accounts for both D_HT and D_FR.|code}}
|-
|-
| 2 || Fear
| Like (D_LI) || Considers the target a friend. NPCs will never intentionally attack these targets and NPCs with <code>bits_CAP_FRIENDLY_DMG_IMMUNE</code> (e.g. [[npc_citizen|citizens]]) will not take any damage from NPCs or players that have this disposition towards them. {{note|Only the disposition of the NPC that deals the damage is considered by <code>bits_CAP_FRIENDLY_DMG_IMMUNE</code>. If a citizen friendly to the player (citizen D_LI to the player) is attacked by a player that doesn't consider them friendly (player not D_LI to the citizen), they will take damage and may not retaliate without additional programming.}}
{{codenote|<code>bits_CAP_FRIENDLY_DMG_IMMUNE</code> can be added to a NPC with <code>AddCapabilities</code> and is usually appended in an NPC's <code>Spawn()</code> function, although it can be toggled at any time.}}
|-
|-
| 3 || Like
| Neutral (D_NU) || Considers a target neutral. NPCs usually won't consider these targets at all, or at least not care about them as enemies or as allies. This is used for fauna like [[npc_crow|crows]]. {{tip|Making a <code>npc_citizen</code> neutral to the player ''(but not the other way around)'' is used to prevent them from joining the player's squad.}}
|-
|-
| 4 || Neutral
| Error (D_ER) || This "error" disposition is used internally to determine if something went wrong in a relationship. Should not be used. NPC behavior mostly equivalent to neutral.{{confirm}}
|}
|}
* '''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 ==
* {{ep1 add|1 : Notify subject of target's location}}
* {{ep1 add|2 : Notify target of subject's location}}
== Inputs ==
* {{i targetname}}
* '''ApplyRelationship'''
:Apply relationship changes


* '''RevertRelationship'''
==Flags==
:Revert relationship changes
{{fl|1|Notify subject of target's location}}
{{fl|2|Notify target of subject's location}}


* '''{{ep1 add|RevertToDefaultRelationship}}'''
==Keyvalues==
: 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.
{{KV Targetname}}
{{KV|Subject(s)|intn=subject|target_name_or_class|The [[targetname]] ''or'' [[classname]] of the NPCs whose disposition will change.}}
{{KV|Subject Class|intn=subjectclass|classname|since=AS|As above, for classnames only.}}
{{KV|Target(s)|intn=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|intn=targetclass|classname|since=AS|As above, for classnames only.}}
{{KV|Disposition|intn=disposition|choices|The way the subject(s) should feel about the target(s)
:#Hate
:#Fear
:#Like
:#Neutral}}
{{KV|Radius for subject|intn=radius|float|Only NPCs within this distance of the entity will have their dispositions changed.}}
{{KV|Disposition Priority|intn=rank|int|How much the subject(s) should Like/Hate/Fear the target(s). Higher priority {{=}} stronger feeling.}}
{{KV|Start Active|intn=StartActive|bool|Apply this relationship as soon as the entity spawns?
{{bug|Doesn't work after [[Level Transitions|level transition]].|tested={{bms}}}}
}}
{{KV|Reciprocal|intn=Reciprocal|bool|Make the new disposition apply to the targets as well as the subjects.}}


== Outputs ==
==Inputs==
* {{o targetname}}
{{I|ApplyRelationship|Applies 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>RevertRelationship</code> or <code>RevertToDefaultRelationship</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.}}}}
{{I|RevertRelationship|Reverts relationship changes to what the relationship of the first one was at the time the <code>ApplyRelationship</code> input was called (or when this ai_relationship was spawned if ''Start Active'' is set).}}
{{I|RevertToDefaultRelationship|Reverts relationship changes to the entities' default relationships, completely returning control of affected relationships to the code.}}


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


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

Latest revision as of 10:24, 11 May 2025

English (en)中文(臺灣) (zh-tw)Translate (Translate)
Icon-NotInFGD.png
This entity is not in the Team Fortress 2 FGD by default.
See below for instructions on making it available.
C++ Class hierarchy
CAI_Relationship
CBaseEntity
C++ ai_relationship.cpp
Ai relationship.png

ai_relationship is a point entity available in Half-Life 2 series Half-Life 2 series, Portal series Portal series, Team Fortress 2 Team Fortress 2, Alien Swarm Alien Swarm, and Source SDK BasesSource SDK BasesSource SDK Bases Source SDK Bases.

It sets a relationship type between two parties. These parties could be either a single specific NPC by using the targetname of it, or all NPC's of the same type by using the classname instead. I.e npc_helicopter, npc_helicopter, ect.
Any object descending from CBaseCombatCharacter can have relationships, most notably NPCs and players.

To make NPC's change their relationship to the player, set the Target(s) field to !player.
If you set the Disposition of any NPC towards the player to to "like" and then also enable Reciprocal, then the player will lower its weapon when looking at the subject NPC.

Note.pngNote:While ai_relationship does not exist in Half-Life: Source, the SetRelationship input does work.
Warning.pngWarning:The "Target" and "Subject" field allow for Classname and Targetname. If you were to use Npc_* in either field, every single npc will be affected, because it goes by classname as well.
Icon-Bug.pngBug:Setting npc_zombie, npc_fastzombie, and npc_zombine to like the player, even if not reciprocated, causes the zombie to be immune to thrown sawblades.

Dispositions:

Name Description
Hate (D_HT) Considers the target an enemy. Most NPCs will attack if possible, although NPCs that cannot attack may flee instead.
Fear (D_FR) Tries to avoid/flee from the target. Behavior varies across NPCs. Most NPCs will just run to cover out of the target's sight while NPCs with ranged weapons may run away while shooting at the feared enemy.
Icon-Bug.pngBug:The trace code used by melee damage doesn't detect D_FR entities and therefore NPCs can't use melee attacks against them. (they may try, but they won't do any damage)  [todo tested in ?]
Cpp.pngCode Fix:This can be fixed by going to CTraceFilterMelee::ShouldHitEntity() and replacing pBCC->IRelationType( pEntity ) == D_HT with pBCC->IRelationType( pEntity ) <= D_FR, which correctly accounts for both D_HT and D_FR.
Like (D_LI) Considers the target a friend. NPCs will never intentionally attack these targets and NPCs with bits_CAP_FRIENDLY_DMG_IMMUNE (e.g. citizens) will not take any damage from NPCs or players that have this disposition towards them.
Note.pngNote:Only the disposition of the NPC that deals the damage is considered by bits_CAP_FRIENDLY_DMG_IMMUNE. If a citizen friendly to the player (citizen D_LI to the player) is attacked by a player that doesn't consider them friendly (player not D_LI to the citizen), they will take damage and may not retaliate without additional programming.
Cpp.pngCode:bits_CAP_FRIENDLY_DMG_IMMUNE can be added to a NPC with AddCapabilities and is usually appended in an NPC's Spawn() function, although it can be toggled at any time.
Neutral (D_NU) Considers a target neutral. NPCs usually won't consider these targets at all, or at least not care about them as enemies or as allies. This is used for fauna like crows.
Tip.pngTip:Making a npc_citizen neutral to the player (but not the other way around) is used to prevent them from joining the player's squad.
Error (D_ER) This "error" disposition is used internally to determine if something went wrong in a relationship. Should not be used. NPC behavior mostly equivalent to neutral.[confirm]

Flags

Notify subject of target's location : [1]
Notify target of subject's location : [2]

Keyvalues

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

Subject(s) (subject) <target_name_or_class>
The targetname or classname of the NPCs whose disposition will change.
Subject Class (subjectclass) <classname> (in all games since Alien Swarm)
As above, for classnames only.
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.pngTip:Use !player for the player.
Target Class (targetclass) <classname> (in all games since Alien Swarm)
As above, for classnames only.
Disposition (disposition) <choices>
The way the subject(s) should feel about the target(s)
  1. Hate
  2. Fear
  3. Like
  4. Neutral
Radius for subject (radius) <float>
Only NPCs within this distance of the entity will have their dispositions changed.
Disposition Priority (rank) <integer>
How much the subject(s) should Like/Hate/Fear the target(s). Higher priority = stronger feeling.
Start Active (StartActive) <boolean>
Apply this relationship as soon as the entity spawns?
Icon-Bug.pngBug:Doesn't work after level transition.  (tested in: Black Mesa)
Reciprocal (Reciprocal) <boolean>
Make the new disposition apply to the targets as well as the subjects.

Inputs

ApplyRelationship
Applies 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 RevertRelationship or RevertToDefaultRelationship 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
Reverts relationship changes to what the relationship of the first one was at the time the ApplyRelationship input was called (or when this ai_relationship was spawned if Start Active is set).
RevertToDefaultRelationship
Reverts relationship changes to the entities' default relationships, completely returning control of affected relationships to the code.

See also