Heal and revive debug commands can also be used on other characters than the controlled one
This commit is contained in:
@@ -220,7 +220,10 @@ namespace Barotrauma
|
|||||||
NewMessage(" ", Color.Cyan);
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
NewMessage("heal: restore the controlled character to full health", Color.Cyan);
|
NewMessage("heal: restore the controlled character to full health", Color.Cyan);
|
||||||
|
NewMessage("heal [character name]: restore the specified character to full health", Color.Cyan);
|
||||||
NewMessage("revive: bring the controlled character back from the dead", Color.Cyan);
|
NewMessage("revive: bring the controlled character back from the dead", Color.Cyan);
|
||||||
|
NewMessage("revive [character name]: bring the specified character back from the dead", Color.Cyan);
|
||||||
|
NewMessage("killmonsters: immediately kills all AI-controlled enemies in the level", Color.Cyan);
|
||||||
|
|
||||||
NewMessage(" ", Color.Cyan);
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
@@ -464,44 +467,11 @@ namespace Barotrauma
|
|||||||
case "control":
|
case "control":
|
||||||
if (commands.Length < 2) break;
|
if (commands.Length < 2) break;
|
||||||
|
|
||||||
int characterIndex;
|
var character = FindMatchingCharacter(commands);
|
||||||
string characterName;
|
|
||||||
if (int.TryParse(commands.Last(), out characterIndex))
|
|
||||||
{
|
|
||||||
characterName = string.Join(" ", commands.Skip(1).Take(commands.Length-2)).ToLowerInvariant();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
characterName = string.Join(" ", commands.Skip(1)).ToLowerInvariant();
|
|
||||||
characterIndex = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var matchingCharacters = Character.CharacterList.FindAll(c => !c.IsRemotePlayer && c.Name.ToLowerInvariant() == characterName);
|
if (character != null)
|
||||||
|
|
||||||
if (!matchingCharacters.Any())
|
|
||||||
{
|
{
|
||||||
ThrowError("Matching characters not found");
|
Character.Controlled = character;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (characterIndex==-1)
|
|
||||||
{
|
|
||||||
Character.Controlled = matchingCharacters.First();
|
|
||||||
if (matchingCharacters.Count > 1)
|
|
||||||
{
|
|
||||||
NewMessage(
|
|
||||||
"Found multiple matching characters. "+
|
|
||||||
"Use \"control [charactername] [0-"+(matchingCharacters.Count-1)+"]\" to choose which character to control.",
|
|
||||||
Color.LightGray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (characterIndex<0 || characterIndex>= matchingCharacters.Count)
|
|
||||||
{
|
|
||||||
ThrowError("Character index out of range. Select an index between 0 and " + (matchingCharacters.Count - 1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Character.Controlled = matchingCharacters[characterIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -522,18 +492,39 @@ namespace Barotrauma
|
|||||||
Entity.DumpIds(count);
|
Entity.DumpIds(count);
|
||||||
break;
|
break;
|
||||||
case "heal":
|
case "heal":
|
||||||
if (Character.Controlled != null)
|
Character healedCharacter = null;
|
||||||
|
if (commands.Length == 1)
|
||||||
{
|
{
|
||||||
Character.Controlled.AddDamage(CauseOfDeath.Damage, -Character.Controlled.MaxHealth, null);
|
healedCharacter = Character.Controlled;
|
||||||
Character.Controlled.Oxygen = 100.0f;
|
|
||||||
Character.Controlled.Bleeding = 0.0f;
|
|
||||||
Character.Controlled.AnimController.StunTimer = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
healedCharacter = FindMatchingCharacter(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (healedCharacter != null)
|
||||||
|
{
|
||||||
|
healedCharacter.AddDamage(CauseOfDeath.Damage, -healedCharacter.MaxHealth, null);
|
||||||
|
healedCharacter.Oxygen = 100.0f;
|
||||||
|
healedCharacter.Bleeding = 0.0f;
|
||||||
|
healedCharacter.AnimController.StunTimer = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "revive":
|
case "revive":
|
||||||
if (Character.Controlled != null)
|
Character reveivedCharacter = null;
|
||||||
|
if (commands.Length == 1)
|
||||||
{
|
{
|
||||||
Character.Controlled.Revive(false);
|
reveivedCharacter = Character.Controlled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reveivedCharacter = FindMatchingCharacter(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reveivedCharacter != null)
|
||||||
|
{
|
||||||
|
reveivedCharacter.Revive(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "freecamera":
|
case "freecamera":
|
||||||
@@ -808,6 +799,53 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Character FindMatchingCharacter(string[] commands)
|
||||||
|
{
|
||||||
|
if (commands.Length < 2) return null;
|
||||||
|
|
||||||
|
int characterIndex;
|
||||||
|
string characterName;
|
||||||
|
if (int.TryParse(commands.Last(), out characterIndex))
|
||||||
|
{
|
||||||
|
characterName = string.Join(" ", commands.Skip(1).Take(commands.Length - 2)).ToLowerInvariant();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
characterName = string.Join(" ", commands.Skip(1)).ToLowerInvariant();
|
||||||
|
characterIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var matchingCharacters = Character.CharacterList.FindAll(c => !c.IsRemotePlayer && c.Name.ToLowerInvariant() == characterName);
|
||||||
|
|
||||||
|
if (!matchingCharacters.Any())
|
||||||
|
{
|
||||||
|
NewMessage("Matching characters not found", Color.Red);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (characterIndex == -1)
|
||||||
|
{
|
||||||
|
if (matchingCharacters.Count > 1)
|
||||||
|
{
|
||||||
|
NewMessage(
|
||||||
|
"Found multiple matching characters. " +
|
||||||
|
"Use \"" + commands[0] + " [charactername] [0-" + (matchingCharacters.Count - 1) + "]\" to choose a specific character.",
|
||||||
|
Color.LightGray);
|
||||||
|
}
|
||||||
|
return matchingCharacters[0];
|
||||||
|
}
|
||||||
|
else if (characterIndex < 0 || characterIndex >= matchingCharacters.Count)
|
||||||
|
{
|
||||||
|
ThrowError("Character index out of range. Select an index between 0 and " + (matchingCharacters.Count - 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return matchingCharacters[characterIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void NewMessage(string msg, Color color)
|
public static void NewMessage(string msg, Color color)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty((msg))) return;
|
if (String.IsNullOrEmpty((msg))) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user