CAI_BaseNPC
Jump to navigation
Jump to search
Code classes:
CAI_BaseNPC
(NPCs)CBaseCombatCharacter
CBaseFlex
CBaseAnimatingOverlay
CBaseAnimating
(models)CBaseEntity
(all ents)
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/Command | Parameters or default value | Parameter Type | Effect |
---|---|---|---|
ai_show_think_tolerance | 0 | Milliseconds | Shows a red arrow over any NPCs that take more than the specified time to think. 0 disables. |
ai_debug_dyninteractions | 0 | 0 disables, 1 enables | Shows info about dynamic interactions. |
ai_test_moveprobe_ignoresmall | 0 | 0 disables, 1 enables | Allows some large NPCs to become non-solid to small VPhysics NPCs if the large NPC's movement is urgent. |
sk_npc_head | 2 | Multiplier | Multiplies damage done when the NPC is hit on the head. |
sk_npc_chest | 1 | Multiplier | Multiplies damage done when the NPC is hit in the chest. |
sk_npc_stomach | 1 | Multiplier | Multiplies damage done when the NPC is hit in the tummy wummy. |
sk_npc_arm | 1 | Multiplier | Multiplies damage done when the NPC is hit in the arm. |
sk_npc_leg | 1 | Multiplier | Multiplies damage done when the NPC is hit in the leg. |
showhitlocation | 0 | 0 disables, 1 enables | Prints to the console where player attacks hit NPCs. |
ai_debug_squads | 0 | 0 disables, 1 enables | Shows 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_loners | 0 | 0 disables, 1 enables | Shows an arrow over each NPC not in any squad. |
ai_reaction_delay_idle | 0.3 | Seconds | Upon spotting an enemy, idle NPCs will take this long to react. |
ai_reaction_delay_alert | 0.3 | Seconds | Upon spotting an enemy, alert NPCs will take this long to react. |
ai_block_damage | 0 | 0 disables, 1 enables | NPCs stop taking damage. |
ai_debug_avoidancebounds | 0 | 0 disables, 1 enables | Shows 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_limit | 0 | 0 disables, 1 enables | Prints more verbose information when an issue is reported by think_limit . |
ai_think_limit_label | 0 | 0 disables, 1 enables | Shows information above an NPC when an issue is reported by think_limit . To do: What do these things mean..? |
ai_setupbones_debug | 0 | 0 disables, 1 enables | Shows NPC skeletons. |
ai_no_select_box | 0 | 0 disables, 1 enables | Disables the red box drawn when the NPC is selected with npc_select . |
ai_lead_time | 0 | Do 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_solver | 1 | 0 disables, 1 enables | Small physics objects resting on an NPC's head become non-solid and get pushed away. |
sv_test_scripted_sequences | 0 | 0 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_adjust | 1 | 0 disables, 1 enables | Makes NPC movement on stairs look more realistic. |
ai_debug_efficiency | 0 | 0 disables, 1 enables | Confirm: No effect. |
ai_debug_doors | 0 | 0 disables, 1 enables | No effect. |
ai_debug_enemies | 0 | 0 disables, 1 enables | No effect. |
ai_rebalance_thinks | 1 | 0 disables, 1 enables | No effect. |
ai_use_efficiency | 1 | 0 disables, 1 enables | No effect. |
ai_use_frame_think_limits | 1 | 0 disables, 1 enables | No effect. |
ai_default_efficient | 0 | 0 disables, 1 enables | No effect. |
ai_efficiency_override | 0 | 0 disables, 1 enables | No effect. |
ai_use_think_optimizations | 1 | 0 disables, 1 enables | No effect. |
ai_shot_stats_term | 1000 | Arbitrary number | No effect. |
ai_shot_stats | 0 | 0 disables, 1 enables | No effect. |
ai_debug_think_ticks | 0 | 0 disables, 1 enables | To do: Effect description. |
ai_frametime_limit | 50 | To do: Effect description. | |
ai_shot_bias | 1 | To do: Effect description. | |
ai_spread_defocused_cone_multiplier | 3 | To do: Effect description. | |
ai_spread_cone_focus_time | 0.6 | To do: Effect description. | |
ai_spread_pattern_focus_time | 0.8 | To do: Effect description. | |
ai_strong_optimizations | 0 | 0 disables, 1 enables | To do: Effect description. |
ai_LOS_mode | 0 | 0 disables, 1 enables | To 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
- 1024: Think outside PVS
- 2048: Template NPC - Does not spawn immediately. For use with
npc_template_maker
.
- 4096: Do Alternate collision for this NPC (player avoidance) Note: This flag is disabled in Episodic 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 associatedtrigger_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.