CAI_BaseNPC

From Source Entities
Jump to navigation Jump to search

CAI_BaseNPC is a code class inherited by NPC entities (but not NextBots). Entities that inherit this class are "real" NPCs.

ConVars/Commands[edit | edit source]

ConVar/CommandParameters or default valueParameter TypeEffect
ai_show_think_tolerance0MillisecondsShows a red arrow over any NPCs that take more than the specified time to think. 0 disables.
ai_debug_dyninteractions00 disables, 1 enablesShows info about dynamic interactions.
ai_test_moveprobe_ignoresmall00 disables, 1 enablesAllows some large NPCs to become non-solid to small VPhysics NPCs if the large NPC's movement is urgent.
sk_npc_head2MultiplierMultiplies damage done when the NPC is hit on the head.
sk_npc_chest1MultiplierMultiplies damage done when the NPC is hit in the chest.
sk_npc_stomach1MultiplierMultiplies damage done when the NPC is hit in the tummy wummy.
sk_npc_arm1MultiplierMultiplies damage done when the NPC is hit in the arm.
sk_npc_leg1MultiplierMultiplies damage done when the NPC is hit in the leg.
showhitlocation00 disables, 1 enablesPrints to the console where player attacks hit NPCs.
ai_debug_squads00 disables, 1 enablesShows an arrow over each NPC that's part of a squad. NPCs that are part of the same squad will have a line connecting them.
ai_debug_loners00 disables, 1 enablesShows an arrow over each NPC not in any squad.
ai_reaction_delay_idle0.3SecondsUpon spotting an enemy, idle NPCs will take this long to react.
ai_reaction_delay_alert0.3SecondsUpon spotting an enemy, alert NPCs will take this long to react.
ai_block_damage00 disables, 1 enablesNPCs stop taking damage.
ai_debug_avoidancebounds00 disables, 1 enablesShows solidity of QPhysics NPCs in a scripted sequence with blue boxes. A box will turn pink if the player ends up inside it.
ai_report_task_timings_on_limit00 disables, 1 enablesPrints more verbose information when an issue is reported by think_limit.
ai_think_limit_label00 disables, 1 enablesShows information above an NPC when an issue is reported by think_limit. To do: What do these things mean..?
ai_setupbones_debug00 disables, 1 enablesShows NPC skeletons.
ai_no_select_box00 disables, 1 enablesDisables the red box drawn when the NPC is selected with npc_select.
ai_lead_time0Do not alter. NPCs will try to aim ahead of enemies when the target is moving, including NPCs that fire bullets (causing them to miss very frequently).
ai_auto_contact_solver10 disables, 1 enablesSmall physics objects resting on an NPC's head become non-solid and get pushed away.
sv_test_scripted_sequences00 disables, 1 enables"Tests for scripted sequences that are embedded in the world. Run through your map with this set to check for NPCs falling through the world."
npc_height_adjust10 disables, 1 enablesMakes NPC movement on stairs look more realistic.
ai_debug_efficiency00 disables, 1 enablesConfirm: No effect.
ai_debug_doors00 disables, 1 enablesNo effect.
ai_debug_enemies00 disables, 1 enablesNo effect.
ai_rebalance_thinks10 disables, 1 enablesNo effect.
ai_use_efficiency10 disables, 1 enablesNo effect.
ai_use_frame_think_limits10 disables, 1 enablesNo effect.
ai_default_efficient00 disables, 1 enablesNo effect.
ai_efficiency_override00 disables, 1 enablesNo effect.
ai_use_think_optimizations10 disables, 1 enablesNo effect.
ai_shot_stats_term1000Arbitrary numberNo effect.
ai_shot_stats00 disables, 1 enablesNo effect.
ai_debug_think_ticks00 disables, 1 enablesTo do: Effect description.
ai_frametime_limit50To do: Effect description.
ai_shot_bias1To do: Effect description.
ai_spread_defocused_cone_multiplier3To do: Effect description.
ai_spread_cone_focus_time0.6To do: Effect description.
ai_spread_pattern_focus_time0.8To do: Effect description.
ai_strong_optimizations00 disables, 1 enablesTo do: Effect description.
ai_LOS_mode00 disables, 1 enablesTo do: Effect description.

Flags[edit | edit source]

  • 1: Wait Till Seen
  • 2: Gag (No idle sounds until angry)
  • 4: Fall to ground (unchecked means teleport to ground)
  • 8: Drop Healthkit when dead
  • 16: Efficient - Don't acquire enemies or avoid obstacles
  • 128: Wait For Script[Clarify]
  • 256: Long Visibility/Shoot
  • 512: Fade Corpse
  • 4096: Do Alternate collision for this NPC (player avoidance) Note: This flag is disabled in Hl2.pngEpisodic for player companions because the StartScripting input does this.
  • 8192: Don't drop weapon on death
  • 16384: Ignore player push - Don't give way to player.

Keyvalues[edit | edit source]

Weapon Held (additionalequipment) <choices>
Gives the NPC a weapon. NPCs may attack oddly or not attack if they don't know how to use a particular weapon. Values available vary by game. Any weapon classname may be inserted.
Health (health) <integer>
How close to dying the entity is. Note: Most NPCs will not read this keyvalue, instead preferring a convar associated with them.
Maximum Health (max_health) <integer>
Health cannot exceed this amount.
Squad Name (squadname) <string>
NPCs that are in the same squad will share information about enemies, and will take turns attacking and covering each other.
Target Path Corner/Track (target) <target_destination>
If set, the name of a path_track entity that this NPC will move to after spawning or when told to Wake. If that entity is part of a path, the NPC will move through all of it.
Sleep State (sleepstate) <choices>
Holds the NPC in stasis until specified condition. See also Wake Radius and Wake Squad.
  • 0: None
  • 1: Waiting for threat[Clarify]
  • 2: Waiting for PVS
  • 3: Waiting for input, ignore PVS
  • 4: Auto PVS[Clarify]
  • 5: Auto PVS after PVS[Clarify]
Wake Radius (wakeradius) <float>
Auto-wake if player is within this distance, in world units.
Wake Squad (wakesquad) <boolean>
If yes, wake all of the NPC's squadmates if this NPC is woken.
Ignore unseen enemies (ignoreunseenenemies) <boolean>
Prefer visible enemies, regardless of distance or relationship priority.
Hint Group (hintgroup) <string>
Hint groups are used by NPCs to restrict their hint-node searching to a subset of the map's hint nodes. Only hint nodes with matching hint group names will be considered by this NPC.
Hint Limit Nav (hintlimiting) <boolean>
If yes, limits NPC to using specified hint group for navigation.
Enemy Filter (enemyfilter) <target_destination>
Filter by which to filter potential enemies.
Waiting to Rappel? (waitingtorappel) <boolean>
If yes, this NPC spawns suspended in air and awaits a BeginRappel input. It will then spawn a zipline and slide down. When it hits the ground, NPC will cut away the line and try to move forward a few feet to make room for the next NPC. The NPC will not attempt to clear its landing space if it cannot do so by taking a few steps forward.

Inputs[edit | edit source]

SetRelationship <string>
Sets a relationship for this entity, without requiring an ai_relationship entity to be set up.
Format: target_name_or_class disposition priority
SetEnemyFilter <target_destination>
Sets Enemy Filter.
SetHealth <integer>
Sets Health.
BeginRappel
If this is a rappelling NPC, tells it to begin rappelling.
SetSquad <string>
Changes what squad the NPC is a part of. Leaving the parameter blank will remove the NPC from any existing squad.
Wake
Takes the NPC out of sleep. It will move toward Target Path Track regardless of if it was sleeping (if it does, ever).
UpdateEnemyMemory <string>
Update (or create) this NPC's memory of the given entity.
ForgetEntity <string>
Clears out the NPC's knowledge of a named entity.
IgnoreDangerSounds <float>
Ignore danger sounds for the specified number of seconds. Clarify: What is a "danger sound"?
Break
Makes the NPC die and disappear. Some NPCs (e.g. manhacks) may leave behind evidence of their death.
StartScripting
Puts the NPC into a "scripted" state. It will ignore a variety of stimuli, such as +use, danger sounds, and idle speech.
ExitScripting
Puts the NPC into their normal AI again.
GagEnable
Prevents the NPC from making any vocalized sounds or speech, unless they are in a choreographed scene.
GagDisable
Allow the NPC to make vocalizations again.
InsideTransition (Not in FGD)
Tells the NPC to stop any choreography (but not scripted speech) its a part of. Usually this is only done by a trigger_changelevel when the NPC is inside the associated trigger_transition and a level transition occurs.
HolsterWeapon
Makes the NPC put their weapon away. They may take it back out if sent the UnholsterWeapon input.
UnholsterWeapon
Makes the NPC take out their weapon, if they have one.
HolsterAndDestroyWeapon
Makes the NPC holster their weapon and then never unholster it again.
Note: The weapon is not destroyed if the NPC already has it holstered.
ForceInteractionWithNPC <string>
Force the NPC to use a dynamic interaction with another NPC.
Format: [target NPC name] [dynamic interaction name].
To do: Where do you find a dynamic interaction name?
ActivateSpeedModifier (Not in FGD)
Does nothing.
DisableSpeedModifier (Not in FGD)
Does nothing.
SetSpeedModRadius (Not in FGD)
Does nothing.
SetSpeedModSpeed (Not in FGD)
Does nothing.

Outputs[edit | edit source]

OnDamaged
Fires when this NPC takes damage.
OnDeath
Fires when this NPC is killed.
OnHalfHealth
Fires when this NPC reaches half of its maximum health.
OnFoundEnemy <target_destination>
Fires when this NPC establishes line of sight to an enemy. Automatically puts the targetname of the found NPC as the input parameter, unless overridden by the mapper.
OnLostEnemy
Fires when this NPC loses its enemy, usually due to the enemy running away, or because this NPC has selected a newer, more dangerous enemy. This output will not fire if the enemy had just died.
OnLostEnemyLOS
Fires when this NPC loses line of sight to its enemy.
OnFoundPlayer <target_destination>
Fires when this NPC establishes line of sight to an enemy player. Automatically puts a pointer to the player as the input parameter, unless overridden by the mapper.
OnLostPlayer
Fires when this NPC loses sight to an enemy player.
OnHearWorld
Fires when this NPC hears a "world" sound.
OnHearPlayer
Fires when this NPC hears a "player" sound.
OnHearCombat
Fires when this NPC hears a combat sound.
OnDamagedByPlayer
Fires when this NPC is hurt by a player.
OnDamagedByPlayerSquad
Fires when this NPC is hurt by anyone in the player squad.
OnDenyCommanderUse
Fired when this NPC has refused to join the player's squad.
OnRappelTouchdown
If this NPC rappels, fires when the NPC is done rappelling.
OnWake
Fired when this NPC comes out of a sleep state.
OnSleep
Fired when this NPC enters a sleep state. To do: What can cause this?
OnForcedInteractionStarted
Fired when the NPC starts a forced interaction.
OnForcedInteractionAborted
Fired when the NPC aborts a forced interaction for some reason (target NPC died, couldn't be pathed to, etc).
OnForcedInteractionFinished
Fired when a forced interaction is finished as it was meant to.