This article's documentation is for anything that uses the Source engine. Click here for more information.

Npc kill: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
This command flags the NPC with a note to kill itself, so if AI is not running (due to the [[ai_disable]] command), the command will be ignored.
This command flags the NPC with a note to kill itself, so if AI is not running (due to the [[ai_disable]] command), the command will be ignored.
{{Note|<code>npc_kill</code> requires <code>[[developer]]</code> console variable to be set to 1 or higher to work.}}
{{Note|<code>npc_kill</code> requires <code>[[developer]]</code> console variable to be set to 1 or higher to work.}}
{{note|Some NPCs ignore this command, for example [[npc_sniper]] and [[npc_helicopter]]. {{workaround|Use <code>ent_fire <name> sethealth 0</code> to kill them.}}}}
==Usage==
==Usage==
* <code>npc_kill</code>
* <code>npc_kill</code>
Line 11: Line 12:
* <code>npc_kill <name></code>
* <code>npc_kill <name></code>
** This will kill all NPCs whose classnames match the specified name, or whose targetnames match the specified name.
** This will kill all NPCs whose classnames match the specified name, or whose targetnames match the specified name.
*<code>npc_kill *</code>
** This will kill all NPCs in the map.





Revision as of 07:32, 4 June 2024

npc_kill is a console command available in all Source Source games. The npc_kill console command is a debugging tool that kills NPCs. The command kills NPCs by dealing enough damage to kill them, so the "OnDamaged" and "OnDeath" outputs will be fired.

This command flags the NPC with a note to kill itself, so if AI is not running (due to the ai_disable command), the command will be ignored.

Note.pngNote:npc_kill requires developer console variable to be set to 1 or higher to work.
Note.pngNote:Some NPCs ignore this command, for example npc_sniper and npc_helicopter.
PlacementTip.pngWorkaround:Use ent_fire <name> sethealth 0 to kill them.

Usage

  • npc_kill
    • This will kill the NPC under your crosshair, if any.
  • npc_kill <entity index>
    • This will kill the NPC matching the specified entity index, if any.
  • npc_kill <name>
    • This will kill all NPCs whose classnames match the specified name, or whose targetnames match the specified name.
  • npc_kill *
    • This will kill all NPCs in the map.


See also