From 8735dffd045a0a87cdff89f7e8410de06efe7116 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 3 Dec 2017 15:36:20 +0200 Subject: [PATCH] Added console command for killing characters --- .../BarotraumaShared/Source/DebugConsole.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index 7c237cb9d..adebef33a 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -722,12 +722,30 @@ namespace Barotrauma } })); + commands.Add(new Command("kill", "kill [character]: Immediately kills the specified character.", (string[] args) => + { + Character killedCharacter = null; + if (args.Length == 0) + { + killedCharacter = Character.Controlled; + } + else + { + killedCharacter = FindMatchingCharacter(args); + } + + if (killedCharacter != null) + { + killedCharacter.AddDamage(CauseOfDeath.Damage, killedCharacter.MaxHealth * 2, null); + } + })); + commands.Add(new Command("killmonsters", "killmonsters: Immediately kills all AI-controlled enemies in the level.", (string[] args) => { foreach (Character c in Character.CharacterList) { if (!(c.AIController is EnemyAIController)) continue; - c.AddDamage(CauseOfDeath.Damage, 10000.0f, null); + c.AddDamage(CauseOfDeath.Damage, c.MaxHealth * 2, null); } }));