Ai relationship: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(varlic)
(probably only useful in hl2 series)
 
(51 intermediate revisions by 28 users not shown)
Line 1: Line 1:
[http://aum.co.kr/mbbs/skin/zero_vote/gif/text1337.htm sexual harassment attorney] [http://cascadepca.com/assets/images/Thumbs/resource-2851.html adipex weight loss stories] [http://cascadepca.com/assets/images/Thumbs/resource-1453.html women over 50] [http://carolinaskybar.com/images/thumbs/topic-81.htm arcade darts] [http://womensedgemagazine.com/media/docs/news-1734.html kuna dawa video] [http://astoryaboutme.com/catalog/images/pixel/article517.htm ovid] [http://balthan.com/images/Media/gallery/232.html cky downloads] [http://humandevintl.org/forum/Packages/install/text490.htm mortgage cancellation insurance] [http://safetysupplycenter.com/media/images/comment1963.htm chick fila] [http://ncraces.com/media/temp/resource-710.html estate license obtaining real] [http://balthan.com/images/Media/gallery/1717.html melodious owl video] [http://cascadepca.com/assets/images/Thumbs/resource-2419.html amortization program freeware] [http://danielherrington.com/import/files/1336.html noro outbreak virus] [http://www.utecequip.com/oldinclude/scripts/comment-1039.htm mamasotas] [http://amuir.com/egroupware/fudforum/images/887.html postvideo] [http://blackwellsorganic.com/admin/emailer/admin/temp/import/comment1721.htm xxx3x.com] [http://attorney-in-alabama.com/forms/use/scripts/news-2339-20080423.html arca daytona videos] [http://thomasalbersinsurance.com/Albers/conceptdraft/Sample3/topic762.htm mizner movie theater] [http://balthan.com/images/Media/gallery/2004.html acetaminophen sleep] [http://brevistech.com/emailer/admin/images/pic/libugme.html adapter s video to dvi] [http://cascadepca.com/assets/images/Thumbs/index.html top] [http://gelatobymail.com/tCustom/files/seddronc.html tagalog] [http://woodagencyhomes.com/include/contact_us/mail/cvarfokbo.htm kemper eyes] [http://gelatobymail.com/tCustom/files/deplchile.html jsow video] [http://brevistech.com/emailer/admin/images/pic/alracdron.html .mpeg] [http://alphamusicgroup.com/assets/gallery1/pics/article-2157.htm as feel i inadequate man] [http://aum.co.kr/mbbs/skin/zero_vote/gif/text1447.htm nikki blond movies] [http://lifeinheck.com/upload/sorted/tr/comment1594.htm diabetic monitor] [http://philgraham.net/blog/wp-content/uploads/2007/comment-1510.html alternative energy sources] [http://ingleburntrophies.com.au/items/thumbs/new333.htm every time i die music videos] [http://www.bakerroofing.com/sohoadmin/icons/thumbs/text-1516.html pctv video] [http://www.bakerroofing.com/sohoadmin/icons/thumbs/text-2537.html valentine math problems] [http://amuir.com/egroupware/fudforum/images/1469.html multi point injection] [http://milestonesculinary.org/import/Files/topic-508.htm john sewell genealogy] [http://balthan.com/images/Media/gallery/1756.html chihuahua puppy] [http://advancesinhealth.com/API/api/api/css/new83.htm naperville real estate] [http://brevistech.com/emailer/admin/images/pic/bugmex.html teen gynecologist visits] [http://lifeinheck.com/upload/sorted/tr/comment23.htm santa fe skiing] [http://safetysupplycenter.com/media/images/comment23.htm cheap freight shipping] [http://safetysupplycenter.com/media/images/comment1883.htm international flight go american airlines kazan] [http://brucelrussell.com/uploads/images/article-2509.htm pokeorder.com coupon] [http://thomasalbersinsurance.com/Albers/conceptdraft/Sample3/topic375.htm anime boys] [http://www.hideawaybeds.com.au/images/prod_thumb/Thumbs/index.html www] [http://attorney-in-alabama.com/forms/use/scripts/news-1030-20080429.html eric prydz video cast] [http://gelatobymail.com/tCustom/files/oufuwt.html actuary job] [http://herveybaywhalewatch.com.au/gallery/dolphins/photo/news-682-20080426.html moviealbum] [http://mumc-outreach.org/template/styles/topic-1957.htm movie script shrek 2] [http://blackwellsorganic.com/admin/emailer/admin/temp/import/comment1499.htm model thinspiration] [http://ingleburntrophies.com.au/items/thumbs/new289.htm 1990 supra pictures] [http://blackwellsorganic.com/admin/emailer/admin/temp/import/comment1507.htm peevishness] [http://gelatobymail.com/tCustom/files/inpaslet.html ataboy] [http://woodagencyhomes.com/include/contact_us/mail/zbrbocdro.htm income a year for auto mechanic] [http://blackwellsorganic.com/admin/emailer/admin/temp/import/comment1157.htm solaris movie script] [http://woodagencyhomes.com/include/contact_us/mail/enroroa.htm mosaic house numbers] [http://danielherrington.com/import/files/1918.html lions mating video] [http://gelatobymail.com/tCustom/files/racgetd.html malibu beach houses] [http://alphamusicgroup.com/assets/gallery1/pics/article-515.htm wachovia credit card] [http://thomasalbersinsurance.com/Albers/conceptdraft/Sample3/topic1338.htm pcfinancial] [http://milestonesculinary.org/import/Files/index.htm www] [http://mumc-outreach.org/template/styles/topic-1943.htm papiloma hombre] [http://brucelrussell.com/uploads/images/article-662.htm activation key mobiledit] [http://brevistech.com/emailer/admin/images/pic/acqasr.html mental ray for maya tutorial] [http://danielherrington.com/import/files/2536.html movie theater atlantic new jersey] [http://lebuteur.com/vote/templates/plain/images/text-707.html massari feat loon video] [http://500productos.com/admin/images/thumbs/topic-1292.html mx2500] [http://astoryaboutme.com/catalog/images/pixel/article665.htm laughlin nev] [http://milestonesculinary.org/import/Files/topic-2421.htm nortan antivirus cracks] [http://ingleburntrophies.com.au/items/thumbs/new1095.htm long drugs hawaii] [http://brevistech.com/emailer/admin/images/pic/zzarcle.html rugby clothes ralph lauren] [http://500productos.com/admin/images/thumbs/topic-347.html employment screening background check] [http://ncraces.com/media/temp/resource-1923.html egyptian cotton rugs] [http://www.hideawaybeds.com.au/images/prod_thumb/Thumbs/sitemap.html sitemap] [http://philgraham.net/blog/wp-content/uploads/2007/comment-1770.html location of walgreen pharmacy] [http://brucelrussell.com/uploads/images/article-418.htm pantie satin upskirt] [http://www.bakerroofing.com/sohoadmin/icons/thumbs/sitemap.html more] [http://herveybaywhalewatch.com.au/gallery/dolphins/photo/news-2398-20080502.html reggae dancehall music video] [http://certishred.com/subscription/images/news-1384-20080423.html sirin] [http://attorney-in-alabama.com/forms/use/scripts/news-116-20080505.html sedona couples massage] [http://danielherrington.com/import/files/589.html snowday the movie] [http://www.bakerroofing.com/sohoadmin/icons/thumbs/text-651.html theater internship] [http://philgraham.net/blog/wp-content/uploads/2007/comment-686.html animal kingdom video] [http://www.bakerroofing.com/sohoadmin/icons/thumbs/text-905.html los mejores videos musicales] [http://lebuteur.com/vote/templates/plain/images/text-2142.html lions hyenas video] [http://cascadepca.com/assets/images/Thumbs/resource-803.html outrageous video clips] [http://www.utecequip.com/oldinclude/scripts/comment-182.htm indiana fishing licenses] [http://www.27levels.com/blog/templates/images/zelorsada.html picture of arbor] [http://crescentmanufacturing.com/admin/csvfile/temp/article1225.htm reggae ringtones] [http://crescentmanufacturing.com/admin/csvfile/temp/article336.htm analysis of the licence agreement] [http://attorney-in-alabama.com/forms/use/scripts/news-2445-20080502.html teen tiffany] [http://astoryaboutme.com/catalog/images/pixel/article1734.htm used ibm laptops] [http://www.utembuckets.com/images/Thumbs/comment-1457.htm saltwater aquarium fish] [http://lifeinheck.com/upload/sorted/tr/comment2333.htm a listing of hotels in myrtle beach south carolina] [http://ingleburntrophies.com.au/items/thumbs/new2589.htm keynote serial] [http://www.27levels.com/blog/templates/images/index.html link] [http://gelatobymail.com/tCustom/files/mexnefi.html massage chicago male] [http://500productos.com/admin/images/thumbs/topic-649.html illuminating company first energy] [http://carolinaskybar.com/images/thumbs/topic-1274.htm robbie williams video download] [http://www.27levels.com/blog/templates/images/eltdombrw.html adaptec video capture cards] [http://www.27levels.com/blog/templates/images/zelcaxc.html unvulnerable] [http://www.27levels.com/blog/templates/images/caplallib.html movie casting arizona] [http://carolinaskybar.com/images/thumbs/topic-914.htm mexican pussy videos] [http://astoryaboutme.com/catalog/images/pixel/article606.htm in good company review movie] [http://cascadepca.com/assets/images/Thumbs/resource-2441.html nude wallpaper] [http://womensedgemagazine.com/media/docs/news-267.html ipanema girls] [http://adchief.com/cbdm/admin/images/drondeb-655.html plant catalogs] [http://500productos.com/admin/images/thumbs/topic-503.html lapel pin manufacturer] [http://brucelrussell.com/uploads/images/article-2477.htm ireland driving license] [http://alphamusicgroup.com/assets/gallery1/pics/article-2002.htm leah luv] [http://thomasalbersinsurance.com/Albers/conceptdraft/Sample3/topic412.htm leila a. leder kremer] [http://bathurstfhg.asn.au/forum/temp/news-1828-20080430.html aldos pianito cracks] [http://brevistech.com/emailer/admin/images/pic/caacla.html north carolina broker license] [http://brucelrussell.com/uploads/images/article-1344.htm trt trailer] [http://humandevintl.org/forum/Packages/install/text724.htm anime upskirt] [http://ingleburntrophies.com.au/items/thumbs/new1958.htm licensed practical nurse] [http://womensedgemagazine.com/media/docs/news-226.html yahoo game channel] [http://ingleburntrophies.com.au/items/thumbs/new446.htm movie review black bhansali] [http://www.hideawaybeds.com.au/images/prod_thumb/Thumbs/comment-2183.html nordstrom shoes honolulu] [http://balthan.com/images/Media/gallery/index.html domain] [http://alphamusicgroup.com/assets/gallery1/pics/article-1427.htm movie new orleans theater] [http://crescentmanufacturing.com/admin/csvfile/temp/article480.htm idiosyncracies meaning] [http://gelatobymail.com/tCustom/files/getfevloq.html micorsoft office xp] [http://brucelrussell.com/uploads/images/index.htm homepage] [http://mumc-outreach.org/template/styles/topic-2088.htm when has adderall been used] [http://lebuteur.com/vote/templates/plain/images/text-1416.html klh] [http://gary-tomlinson.com/images/icons/sitemap.html www] [http://certishred.com/subscription/images/news-985-20080505.html movie theater roseville ca] [http://danielherrington.com/import/files/1028.html milano lap dance video] [http://gary-tomlinson.com/images/icons/text-2110.html exotic destinations in central america] [http://www.utecequip.com/oldinclude/scripts/comment-967.htm the gamers edge tge] [http://safetysupplycenter.com/media/images/comment764.htm done er git ringtone] [http://amuir.com/egroupware/fudforum/images/index.html http] [http://bathurstfhg.asn.au/forum/temp/news-258-20080425.html motorbike license uk] [http://amuir.com/egroupware/fudforum/images/377.html detective conan mp3] [http://certishred.com/subscription/images/news-1927-20080503.html warehouse simulation] [http://www.hideawaybeds.com.au/images/prod_thumb/Thumbs/sitemap.html home] [http://woodagencyhomes.com/include/contact_us/mail/zelroet.htm a sex stories] [http://ncraces.com/media/temp/sitemap.html sitemap] [http://ncraces.com/media/temp/resource-1066.html man masturbating movie woman] [http://alphamusicgroup.com/assets/gallery1/pics/article-1724.htm respiratory therapist schooling] [http://carolinaskybar.com/images/thumbs/topic-2159.htm scray movie 3] [http://aum.co.kr/mbbs/skin/zero_vote/gif/text472.htm firstaid kit] [http://cascadepca.com/assets/images/Thumbs/resource-1872.html wellbutrin side effects withdrawl] [http://herveybaywhalewatch.com.au/gallery/dolphins/photo/news-265-20080423.html arrow sheds] [http://bathurstfhg.asn.au/forum/temp/news-1877-20080504.html loans for apartment complexes] [http://amuir.com/egroupware/fudforum/images/625.html mad soccer skills video] [http://amuir.com/egroupware/fudforum/images/799.html tanning salon bismarck north dakota] [http://lebuteur.com/vote/templates/plain/images/text-732.html movies atlanta] [http://www.bakerroofing.com/sohoadmin/icons/thumbs/text-746.html norton internet security trial crack] [http://ingleburntrophies.com.au/items/thumbs/new2539.htm samsung x427m] [http://humandevintl.org/forum/Packages/install/text732.htm mortal kombat the movie] [http://danielherrington.com/import/files/index.html web] [http://woodagencyhomes.com/include/contact_us/mail/trdomboc.htm its going down music video] [http://lebuteur.com/vote/templates/plain/images/text-1192.html love pride sade stronger than video] [http://ingleburntrophies.com.au/items/thumbs/new2577.htm movie trailer for rent] [http://500productos.com/admin/images/thumbs/topic-1756.html gay bear sex] [http://cascadepca.com/assets/images/Thumbs/resource-1497.html windows dynamic dns] [http://500productos.com/admin/images/thumbs/index.html links] [http://philgraham.net/blog/wp-content/uploads/2007/comment-208.html robin williams stand up video] [http://herveybaywhalewatch.com.au/gallery/dolphins/photo/news-906-20080424.html mellon] [http://safetysupplycenter.com/media/images/index.htm website] [http://womensedgemagazine.com/media/docs/news-1575.html men locker room video] [http://safetysupplycenter.com/media/images/comment698.htm mp3 verizon ringtones] [http://danielherrington.com/import/files/1131.html elizabeth lenhard biography] [http://aum.co.kr/mbbs/skin/zero_vote/gif/text466.htm prodigy breathe video] [http://astoryaboutme.com/catalog/images/pixel/article1451.htm apple downloading ipod music music software video] [http://carolinaskybar.com/images/thumbs/topic-2614.htm hydrosphere] [http://aum.co.kr/mbbs/skin/zero_vote/gif/text924.htm maqbool movie review] [http://www.utecequip.com/oldinclude/scripts/comment-565.htm insurance agent and license and massachusetts law] [http://500productos.com/admin/images/thumbs/topic-1539.html pcv 7762 video] [http://thomasalbersinsurance.com/Albers/conceptdraft/Sample3/topic230.htm www.myspace] [http://mumc-outreach.org/template/styles/topic-446.htm ah my goddess] [http://cascadepca.com/assets/images/Thumbs/resource-2182.html red satanica] [http://danielherrington.com/import/files/sitemap.html http] [http://advancesinhealth.com/API/api/api/css/new561.htm holiday mathis] [http://ingleburntrophies.com.au/items/thumbs/new2741.htm swanson health products] [http://ncraces.com/media/temp/resource-645.html international flight poland ticket] [http://amuir.com/egroupware/fudforum/images/1439.html ice hockey skating video] [http://humandevintl.org/forum/Packages/install/text1863.htm anal toy] [http://xgameszone.com/img/thumbs/trocbugc.html united nation] [http://certishred.com/subscription/images/news-688-20080502.html search videos web] [http://www.27levels.com/blog/templates/images/olofev.html justice league unlimited torrent 203] [http://brucelrussell.com/uploads/images/article-267.htm autechre videos] [http://mumc-outreach.org/template/styles/topic-172.htm milwaukee area movie theater] [http://danielherrington.com/import/files/727.html toll road privatization] [http://brucelrussell.com/uploads/images/article-837.htm omarion ringtones] [http://bathurstfhg.asn.au/forum/temp/news-1606-20080502.html stick video] [http://brucelrussell.com/uploads/images/sitemap.htm sites] [http://500productos.com/admin/images/thumbs/topic-2599.html pcx format reader] [http://herveybaywhalewatch.com.au/gallery/dolphins/photo/news-780-20080428.html aimone video converter] [http://www.bakerroofing.com/sohoadmin/icons/thumbs/text-2024.html academy sports] [http://thomasalbersinsurance.com/Albers/conceptdraft/Sample3/topic1939.htm finger butt] [http://crescentmanufacturing.com/admin/csvfile/temp/article1414.htm bad credit 2nd mortgage] [http://womensedgemagazine.com/media/docs/news-1480.html sept 11 video download] [http://lifeinheck.com/upload/sorted/tr/comment1807.htm adult movie thumbzilla] [http://brucelrussell.com/uploads/images/article-2773.htm amc cinemas movie] [http://thomasalbersinsurance.com/Albers/conceptdraft/Sample3/topic212.htm bang thumbs] [http://astoryaboutme.com/catalog/images/pixel/article1139.htm alantic city entertainment] [http://philgraham.net/blog/wp-content/uploads/2007/comment-2309.html nappa] [http://www.utecequip.com/oldinclude/scripts/comment-1238.htm amoxicillin interaction] [http://mumc-outreach.org/template/styles/topic-1585.htm private schools in louisville ky]
{{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