Criterion: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (recategorize)
m (→‎See also: Unicodifying, replaced: See Also → See also)
 
(8 intermediate revisions by 3 users not shown)
Line 2: Line 2:
[[Category:AI Programming]]
[[Category:AI Programming]]


Criterion is a match condition. If it doesn't match, it scores 0. If it does match, the score is its weight value.
A '''criterion''' is a match condition. If it doesn't match, it scores 0. If it does match, the score is its weight value.


The Response system checks each [[Rules|rule]] against the set, give it a numeric score based on the rule's set of criteria. Then the system picks one rule with the highest score, dispatch a response that the rule points.
The Response system checks each [[Rules|rule]] against the set, give it a numeric score based on the rule's set of criteria. Then the system picks one rule with the highest score, dispatch a response that the rule points.
Line 11: Line 11:


==matchkey==
==matchkey==
Many keyvalue pairs are updated in <code>BaseEntity.cpp - ModifyOrAppendCriteria( AI_CriteriaSet& set )</code>, <code>AI_Speech.cpp - CAI_ExpresserHost_DoModifyOrAppendCriteria( CAI_BaseNPC *pSpeaker, AI_CriteriaSet& set )</code> and player and NPC codes.
Many keyvalue pairs are updated in <code>ModifyOrAppendCriteria( AI_CriteriaSet& set )</code> & <code>CAI_ExpresserHost_DoModifyOrAppendCriteria( CAI_BaseNPC *pSpeaker, AI_CriteriaSet& set )</code> and player and NPC codes.


Also mappers can set keyvalue pairs via [[Contexts]] system.
Also mappers can set keyvalue pairs via the [[Context]] system.


*[[Concepts|Concept]]
*[[concept]]
*Map
*map
*Classname
*classname
*Name
*name
*Health
*health
*HealthFrac
*healthFrac
*PlayerHealth
*playerHealth
*Player
*player
*PlayerWeapon
*playerWeapon
*PlayerActivity
*playerActivity
*PlayerSpeed
*playerSpeed
*NPCState
*npcstate
*distancetoplayer
*distancetoplayer
*seeplayer
*seeplayer
Line 54: Line 54:


==other options==
==other options==
*weight = floating point weighting for score assuming criteria match (default value 1.0)
*weight nnn: floating point weighting for score assuming criteria match (default value 1.0)


*required:  if a rule has one or more criteria with the required flag set, then if any such criteria fail, the entire rule receives a score of zero
*required:  if a rule has one or more criteria with the required flag set, then if any such criteria fail, the entire rule receives a score of zero


==Base criteria==
==See also==
Here are base criteria defined in <code>response_rules.txt</code>.
*[[List of HL2 criteria]]
 
===Question / Answer concepts===
 
criterion "ConceptTalkAnswer" "Concept" "TLK_ANSWER" required weight 1
 
criterion "ConceptTalkQuestion" "Concept" "TLK_QUESTION" required // weight 1 implied
 
criterion "ConceptTalkAnswerCitizen" "Concept" "TLK_ANSWER_CIT" required weight 1
 
criterion "ConceptTalkQuestionCitizen" "Concept" "TLK_QUESTION_CIT" required
 
criterion "ConceptTalkAnswerVort" "Concept" "TLK_ANSWER_VORT" required weight 1
 
criterion "ConceptTalkQuestionVort" "Concept" "TLK_QUESTION_VORT" required
 
 
 
===General concepts===
 
criterion "ConceptTalkIdle" "Concept" "TLK_IDLE" required
 
criterion "ConceptTalkStare" "Concept" "TLK_STARE" required
 
criterion "ConceptTalkUse" "Concept" "TLK_USE" required
 
criterion "ConceptTalkStartFollow" "Concept" "TLK_STARTFOLLOW" required
 
criterion "ConceptTalkStopFollow" "Concept" "TLK_STOPFOLLOW" required
 
criterion "ConceptTalkStop" "Concept" "TLK_STOP" required
 
criterion "ConceptTalkNoShoot" "Concept" "TLK_NOSHOOT" required
 
criterion "ConceptTalkHello" "Concept" "TLK_HELLO" required
 
criterion "ConceptTalkPHello" "Concept" "TLK_PHELLO" required
 
criterion "ConceptTalkPIdle" "Concept" "TLK_PIDLE" required
 
criterion "ConceptTalkPQuestion" "Concept" "TLK_PQUESTION" required
 
criterion "ConceptTalkPlayerHurt1" "Concept" "TLK_PLHURT1" required
 
criterion "ConceptTalkPlayerHurt2" "Concept" "TLK_PLHURT2" required
 
criterion "ConceptTalkPlayerHurt3" "Concept" "TLK_PLHURT3" required
 
criterion "ConceptTalkPlayerPushed" "Concept" "TLK_PLPUSH" required
 
criterion "ConceptTalkSmell" "Concept" "TLK_SMELL" required
 
criterion "ConceptTalkWound" "Concept" "TLK_WOUND" required
 
criterion "ConceptTalkMortal" "Concept" "TLK_MORTAL" required
 
criterion "ConceptTalkDanger" "Concept" "TLK_DANGER" required
 
criterion "ConceptTalkResume" "Concept" "TLK_RESUME" required
 
criterion "ConceptTalkHeal" "Concept" "TLK_HEAL" required
 
criterion "ConceptTalkTourGuideStayPut" "Concept" "TLK_TGSTAYPUT" required
 
criterion "ConceptTalkTourGuideFind" "Concept" "TLK_TGFIND" required
 
criterion "ConceptTalkTourGuideSeek" "Concept" "TLK_TGSEEK" required
 
criterion "ConceptTalkTourGuideLostYou" "Concept" "TLK_TGLOSTYOU" required
 
criterion "ConceptTalkTourGuideCatchUp" "Concept" "TLK_TGCATCHUP" required
 
criterion "ConceptTalkTourGuideEndTour" "Concept" "TLK_TGENDTOUR" required
 
criterion "ConceptTalkSelected" "Concept" "TLK_SELECTED" required
 
criterion "ConceptTalkCommanded" "Concept" "TLK_COMMANDED" required
 
criterion "ConceptTalkCommandFailed" "Concept" "TLK_COMMAND_FAILED" required
 
criterion "ConceptTalkBetrayed" "Concept" "TLK_BETRAYED" required
 
criterion "ConceptTalkGiveAmmo" "Concept" "TLK_GIVEAMMO" required
 
criterion "ConceptTalkAllyKilled" "Concept" "TLK_ALLY_KILLED" required
 
criterion "ConceptSeeCombine" "Concept" "TLK_SEE_COMBINE" required
 
criterion "ConceptEnemyDead" "Concept" "TLK_ENEMY_DEAD" required
 
criterion "ConceptTalkWatchOut" "Concept" "TLK_WATCHOUT" required
 
criterion "ConceptTalkAttacking" "Concept" "TLK_ATTACKING" required
 
criterion "ConceptTalkDeath" "Concept" "TLK_DEATH" required
 
criterion "ConceptTalkHelpMe" "Concept" "TLK_HELP_ME" required
 
criterion "ConceptTalkPlayerPhysAttack" "Concept" "TLK_PLYR_PHYSATK" required
 
criterion "ConceptDissolveScream" "Concept" "TLK_DISSOLVESCREAM" required
 
criterion "ConceptElectrocuteScream" "Concept" "TLK_ELECTROCUTESCREAM" required
 
criterion "ConceptNewWeapon" "Concept" "TLK_NEWWEAPON" required
 
criterion "ConceptShot" "Concept" "TLK_SHOT" required
 
criterion "ConceptPlayerReload" "Concept" "TLK_PLRELOAD" required
 
criterion "ConceptPlayerDead" "Concept" "TLK_PLDEAD" required
 
criterion "ConceptHideAndReload" "Concept" "TLK_HIDEANDRELOAD" required
 
criterion "ConceptStartCombat" "Concept" "TLK_STARTCOMBAT" required
 
criterion "ConceptJoinPlayer" "Concept" "TLK_JOINPLAYER" required
 
 
 
===Lead behavior===
 
criterion "ConceptLeadStart" "Concept" "TLK_LEAD_START" required // Spoken once when the NPC first starts to lead the player
 
criterion "ConceptLeadWaitOver" "Concept" "TLK_LEAD_WAITOVER" required // Spoken when the player arrives at an NPC waiting to lead the player
 
criterion "ConceptLeadAttractPlayer" "Concept" "TLK_LEAD_ATTRACTPLAYER" required // Nag spoken by a NPC waiting to lead the player, trying to attract the player
 
criterion "ConceptLeadCatchup" "Concept" "TLK_LEAD_CATCHUP" required // Spoken by the NPC when the player's lagging behind
 
criterion "ConceptLeadComingBack" "Concept" "TLK_LEAD_COMINGBACK" required // Spoken when the NPC comes back to find a lost player
 
criterion "ConceptLeadRetrieve" "Concept" "TLK_LEAD_RETRIEVE" required // Spoken when the NPC has come back to the player, and is now resuming the lead
 
criterion "ConceptLeadArrival" "Concept" "TLK_LEAD_ARRIVAL" required // Spoken when the leading NPC reaches the target point
 
criterion "ConceptLeadSuccess" "Concept" "TLK_LEAD_SUCCESS" required // Spoken when the player and the leading NPC have both reached the target point
 
criterion "ConceptLeadMissingWeapon" "Concept" "TLK_LEAD_MISSING_WEAPON" required // Spoken when the NPC refuses to lead the player because he's missing a weapon
 
 
 
===Citizen responses===
 
criterion "ConceptCRPlayerShotGunship" "Concept" "TLK_CITIZEN_RESPONSE_SHOT_GUNSHIP" required
 
criterion "ConceptCRPlayerKilledGunship" "Concept" "TLK_CITIZEN_RESPONSE_KILLEd_GUNSHIP" required
 
criterion "ConceptCRVitalNPCDied" "Concept" "TLK_VITALNPC_DIED" required
 
 
 
criterion "PlayerAlive" "PlayerHealth" ">0" required
 
criterion "PlayerDead" "PlayerHealth" "<=0" required
 
criterion "PlayerWounded" "PlayerHealthFrac" ">0,<=.5"
 
criterion "NPCAlive" "Health" ">0" required
 
criterion "NPCAlert" "NPCState" ">=[NPCState::Idle],<[NPCState::Alert]"
 
criterion "NPCIdle" "NPCState" "[NPCState::Idle]" required
 
criterion "PlayerNear" "distancetoplayer" "<500" required
 
criterion "SeePlayer" "seeplayer" "1" required
 
criterion "SeenByPlayer" "seenbyplayer" "1" required
 
criterion "NoRecentCombat" "timesincecombat" ">25" required
 
 
 
criterion "ShotInLeg" "shotloc" "leg" required weight 0
 
criterion "ShotInArm" "shotloc" "arm" required weight 0
 
criterion "ShotInGut" "shotloc" "gut" required weight 0
 
 
 
criterion "EnemyIsMortar" "enemy" "func_tankmortar" required
 
 
===Global states===
 
criterion "IsGordonCriminal" "gordon_precriminal" "0" required
 
criterion "IsGordonPreCriminal" "gordon_precriminal" "1" required

Latest revision as of 08:43, 8 January 2024

Stub

This article or section is a stub. You can help by expanding it.

A criterion is a match condition. If it doesn't match, it scores 0. If it does match, the score is its weight value.

The Response system checks each rule against the set, give it a numeric score based on the rule's set of criteria. Then the system picks one rule with the highest score, dispatch a response that the rule points.

criterion <criterionname> <matchkey> <matchvalue> weight nnn required

matchkey

Many keyvalue pairs are updated in ModifyOrAppendCriteria( AI_CriteriaSet& set ) & CAI_ExpresserHost_DoModifyOrAppendCriteria( CAI_BaseNPC *pSpeaker, AI_CriteriaSet& set ) and player and NPC codes.

Also mappers can set keyvalue pairs via the Context system.

  • concept
  • map
  • classname
  • name
  • health
  • healthFrac
  • playerHealth
  • player
  • playerWeapon
  • playerActivity
  • playerSpeed
  • npcstate
  • distancetoplayer
  • seeplayer
  • seenbyplayer
  • timesincecombat
  • shotloc
  • enemy
  • gordon_precriminal
  • attacking_with_weapon
  • hurt_by_fire
  • numselected
  • useradio
  • commandpoint_dist_to_npc
  • commandpoint_dist_to_player
  • numjoining
  • reinforcement

matchvalue

  • "0"; numeric match to value 0
  • "1"; numeric match to value 1
  • "weapon_smg1"; string match to weapon_smg1 string
  • "[npcstate::idle]"; match enumeration by looking up numeric value
  • ">0"; match if greater than zero
  • ">10,<=50"; match if greater than ten and less than or equal to 50
  • ">0,<[npcstate::alert]"; match if greater than zer and les then value of enumeration for alert
  • "!=0"; match if not equal to zero

other options

  • weight nnn: floating point weighting for score assuming criteria match (default value 1.0)
  • required: if a rule has one or more criteria with the required flag set, then if any such criteria fail, the entire rule receives a score of zero

See also