Ignore damage modifiers when killing a unit via actor.Kill(). Fixes surrender desync (#460); Fixes invulnerable actors surviving in situations where they should be killed (bridge death, losing/surrender, etc).

This commit is contained in:
Paul Chote
2011-07-21 21:05:49 +12:00
parent 6ede28fdbe
commit c79f5b5365
2 changed files with 16 additions and 9 deletions

View File

@@ -34,8 +34,16 @@ namespace OpenRA.Mods.RA.Activities
if( !target.Trait<IOccupySpace>().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<IDamageModifier>()
.Concat(self.Owner.PlayerActor.TraitsImplementing<IDamageModifier>())
.Select(t => t.GetDamageModifier(self, null)).Product();
if (target.IsInWorld && modifier > 0)
target.Kill(self);
})));
return NextActivity;
}
}