remove silly exploit on undeploying MCV
This commit is contained in:
@@ -46,23 +46,27 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
|
|
||||||
self.World.AddFrameEndTask( _ =>
|
self.World.AddFrameEndTask(_ =>
|
||||||
{
|
{
|
||||||
var oldHP = self.GetMaxHP();
|
self.World.Remove(self);
|
||||||
var newHP = Rules.Info[actor].Traits.Get<OwnedActorInfo>().HP;
|
|
||||||
var newHealth = (transferPercentage) ? (int)((float)self.Health/oldHP*newHP) : Math.Min(self.Health, newHP);
|
|
||||||
|
|
||||||
self.Health = 0;
|
|
||||||
self.World.Remove( self );
|
|
||||||
foreach (var s in sounds)
|
foreach (var s in sounds)
|
||||||
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
||||||
|
|
||||||
var a = self.World.CreateActor( actor, self.Location + offset, self.Owner );
|
var a = self.World.CreateActor(actor, self.Location + offset, self.Owner);
|
||||||
a.Health = newHealth;
|
a.Health = GetHealthToTransfer(self, a, transferPercentage);
|
||||||
} );
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
w.Remove(self);
|
w.Remove(self);
|
||||||
|
|
||||||
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
||||||
|
mcv.Health = TransformIntoActor.GetHealthToTransfer(self, mcv, true);
|
||||||
mcv.traits.Get<Unit>().Facing = 96;
|
mcv.traits.Get<Unit>().Facing = 96;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user