"Explosion" debug command

This commit is contained in:
Joonas Rikkonen
2017-06-19 19:26:53 +03:00
parent 5cd2a5a838
commit d2ab71b07d
3 changed files with 36 additions and 4 deletions

View File

@@ -72,6 +72,14 @@ namespace Barotrauma
return (Duration == 0.0f) ? structureDamage : structureDamage * deltaTime;
}
public Attack(float damage, float structureDamage, float bleedingDamage, float range = 0.0f)
{
Range = range;
this.damage = damage;
this.structureDamage = structureDamage;
this.bleedingDamage = bleedingDamage;
}
public Attack(XElement element)
{
try
@@ -106,9 +114,7 @@ namespace Barotrauma
Duration = ToolBox.GetAttributeFloat(element, "duration", 0.0f);
priority = ToolBox.GetAttributeFloat(element, "priority", 1.0f);
statusEffects = new List<StatusEffect>();
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
@@ -117,6 +123,10 @@ namespace Barotrauma
particleEmitterPrefab = new ParticleEmitterPrefab(subElement);
break;
case "statuseffect":
if (statusEffects == null)
{
statusEffects = new List<StatusEffect>();
}
statusEffects.Add(StatusEffect.Load(subElement));
break;
}
@@ -141,6 +151,11 @@ namespace Barotrauma
var effectType = attackResult.Damage > 0.0f ? ActionType.OnUse : ActionType.OnFailure;
if (statusEffects == null)
{
return attackResult;
}
foreach (StatusEffect effect in statusEffects)
{
if (effect.Targets.HasFlag(StatusEffect.TargetType.This) && attacker is Character)

View File

@@ -558,7 +558,7 @@ namespace Barotrauma
healedCharacter.AddDamage(CauseOfDeath.Damage, -healedCharacter.MaxHealth, null);
healedCharacter.Oxygen = 100.0f;
healedCharacter.Bleeding = 0.0f;
healedCharacter.Stun = 0.0f;
healedCharacter.SetStun(0.0f, true);
}
break;
@@ -600,6 +600,14 @@ namespace Barotrauma
case "water":
if (GameMain.Client == null) Hull.EditWater = !Hull.EditWater;
break;
case "explosion":
Vector2 explosionPos = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
float range = 500, force = 10, damage=50;
if (commands.Length > 1) float.TryParse(commands[1], out range);
if (commands.Length > 2) float.TryParse(commands[2], out force);
if (commands.Length > 3) float.TryParse(commands[3], out damage);
new Explosion(range, force, damage, damage).Explode(explosionPos);
break;
case "fire":
if (GameMain.Client == null) Hull.EditFire = !Hull.EditFire;

View File

@@ -18,6 +18,15 @@ namespace Barotrauma
private bool sparks, shockwave, flames, smoke;
public Explosion(float range, float force, float damage, float structureDamage)
{
attack = new Attack(damage, structureDamage, 0.0f, range);
this.force = force;
sparks = true;
shockwave = true;
flames = true;
}
public Explosion(XElement element)
{
attack = new Attack(element);