diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index 0a30982818..f74a8572ab 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -70,18 +70,19 @@ namespace OpenRA.Traits } } - public void InflictDamage(Actor self, Actor attacker, int damage, WarheadInfo warhead) + public void InflictDamage(Actor self, Actor attacker, int damage, WarheadInfo warhead, bool ignoreModifiers) { if (IsDead) return; /* overkill! don't count extra hits as more kills! */ var oldState = this.DamageState; - /* apply the damage modifiers, if we have any. */ var modifier = (float)self.TraitsImplementing() .Concat(self.Owner.PlayerActor.TraitsImplementing()) .Select(t => t.GetDamageModifier(attacker, warhead)).Product(); + + if (!ignoreModifiers) + damage = damage > 0 ? (int)(damage * modifier) : damage; - damage = damage > 0 ? (int)(damage * modifier) : damage; hp = Exts.Clamp(hp - damage, 0, MaxHP); var ai = new AttackInfo @@ -175,16 +176,14 @@ namespace OpenRA.Traits { var health = self.TraitOrDefault(); if (health == null) return; - health.InflictDamage(self, attacker, damage, warhead); + health.InflictDamage(self, attacker, damage, warhead, false); } public static void Kill(this Actor self, Actor attacker) { var health = self.TraitOrDefault(); if (health == null) return; - - /* hack. Fix for proper */ - health.InflictDamage(self, attacker, int.MaxValue, null); + health.InflictDamage(self, attacker, health.MaxHP, null, true); } } } diff --git a/OpenRA.Mods.RA/Activities/Demolish.cs b/OpenRA.Mods.RA/Activities/Demolish.cs index f96e14b213..7808acf48d 100644 --- a/OpenRA.Mods.RA/Activities/Demolish.cs +++ b/OpenRA.Mods.RA/Activities/Demolish.cs @@ -34,8 +34,16 @@ namespace OpenRA.Mods.RA.Activities if( !target.Trait().OccupiedCells().Any( x => x.First == self.Location ) ) return NextActivity; - self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, - () => { if (target.IsInWorld) target.Kill(self); }))); + self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () => + { + // Invulnerable actors can't be demolished + var modifier = (float)target.TraitsImplementing() + .Concat(self.Owner.PlayerActor.TraitsImplementing()) + .Select(t => t.GetDamageModifier(self, null)).Product(); + + if (target.IsInWorld && modifier > 0) + target.Kill(self); + }))); return NextActivity; } }