diff --git a/OpenRA.Mods.RA/Activities/TransformIntoActor.cs b/OpenRA.Mods.RA/Activities/TransformIntoActor.cs index e30f733575..a5c4d1f37a 100644 --- a/OpenRA.Mods.RA/Activities/TransformIntoActor.cs +++ b/OpenRA.Mods.RA/Activities/TransformIntoActor.cs @@ -45,24 +45,28 @@ namespace OpenRA.Mods.RA.Activities public IActivity Tick( Actor self ) { if (isCanceled) return NextActivity; - - self.World.AddFrameEndTask( _ => + + self.World.AddFrameEndTask(_ => { - var oldHP = self.GetMaxHP(); - var newHP = Rules.Info[actor].Traits.Get().HP; - var newHealth = (transferPercentage) ? (int)((float)self.Health/oldHP*newHP) : Math.Min(self.Health, newHP); - - self.Health = 0; - self.World.Remove( self ); + self.World.Remove(self); foreach (var s in sounds) Sound.PlayToPlayer(self.Owner, s, self.CenterLocation); - var a = self.World.CreateActor( actor, self.Location + offset, self.Owner ); - a.Health = newHealth; - } ); + var a = self.World.CreateActor(actor, self.Location + offset, self.Owner); + a.Health = GetHealthToTransfer(self, a, transferPercentage); + }); return this; } public void Cancel(Actor self) { isCanceled = true; NextActivity = null; } + + public static int GetHealthToTransfer(Actor from, Actor to, bool transferPercentage) + { + var oldHP = from.GetMaxHP(); + var newHP = to.GetMaxHP(); + return (transferPercentage) + ? (int)((float)from.Health / oldHP * newHP) + : Math.Min(from.Health, newHP); + } } } diff --git a/OpenRA.Mods.RA/Activities/UndeployMcv.cs b/OpenRA.Mods.RA/Activities/UndeployMcv.cs index dd3312a0b7..a312b3e7ac 100755 --- a/OpenRA.Mods.RA/Activities/UndeployMcv.cs +++ b/OpenRA.Mods.RA/Activities/UndeployMcv.cs @@ -33,6 +33,7 @@ namespace OpenRA.Mods.RA.Activities w.Remove(self); var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner); + mcv.Health = TransformIntoActor.GetHealthToTransfer(self, mcv, true); mcv.traits.Get().Facing = 96; }