diff --git a/OpenRa.Game/Traits/ChronoshiftPower.cs b/OpenRa.Game/Traits/ChronoshiftPower.cs index 4a735b2d2e..b8a0add34c 100644 --- a/OpenRa.Game/Traits/ChronoshiftPower.cs +++ b/OpenRa.Game/Traits/ChronoshiftPower.cs @@ -48,20 +48,24 @@ namespace OpenRa.Traits var chronosphere = self.World.Actors.Where(a => a.Owner == self.Owner && a.traits.Contains()).FirstOrDefault(); - if (chronosphere != null) - chronosphere.traits.Get().PlayCustomAnim( chronosphere, "active" ); - - // Trigger screen desaturate effect - foreach (var a in self.World.Actors.Where(a => a.traits.Contains())) - a.traits.Get().DoChronoshift(); - - Sound.Play("chrono2.aud"); - - order.TargetActor.traits.Get().Activate(order.TargetActor, + + bool success = order.TargetActor.traits.Get().Activate(order.TargetActor, order.TargetLocation, (int)((Info as ChronoshiftPowerInfo).Duration * 25 * 60), (Info as ChronoshiftPowerInfo).KillCargo, chronosphere); + + if (success) + { + Sound.Play("chrono2.aud"); + + // Trigger screen desaturate effect + foreach (var a in self.World.Actors.Where(a => a.traits.Contains())) + a.traits.Get().DoChronoshift(); + + if (chronosphere != null) + chronosphere.traits.Get().PlayCustomAnim(chronosphere, "active"); + } Game.controller.CancelInputMode(); FinishActivate(); diff --git a/OpenRa.Game/Traits/Chronoshiftable.cs b/OpenRa.Game/Traits/Chronoshiftable.cs index 9c6de67a25..68ae9d2ec4 100644 --- a/OpenRa.Game/Traits/Chronoshiftable.cs +++ b/OpenRa.Game/Traits/Chronoshiftable.cs @@ -37,7 +37,7 @@ namespace OpenRa.Traits } } - public virtual void Activate(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere) + public virtual bool Activate(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere) { /// Set up return-to-sender info chronoshiftOrigin = self.Location; @@ -57,6 +57,8 @@ namespace OpenRa.Traits // Set up the teleport self.CancelActivity(); self.QueueActivity(new Activities.Teleport(targetLocation)); + + return true; } } } diff --git a/OpenRa.Mods.Aftermath/DemoTruck.cs b/OpenRa.Mods.Aftermath/DemoTruck.cs index f67776abeb..7db3518b65 100644 --- a/OpenRa.Mods.Aftermath/DemoTruck.cs +++ b/OpenRa.Mods.Aftermath/DemoTruck.cs @@ -17,9 +17,10 @@ namespace OpenRa.Mods.Aftermath public DemoTruck(Actor self) : base(self) { } // Explode on chronoshift - public override void Activate(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere) + public override bool Activate(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere) { Detonate(self, chronosphere); + return false; } // Fire primary on death @@ -31,14 +32,26 @@ namespace OpenRa.Mods.Aftermath public void Detonate(Actor self, Actor detonatedBy) { - self.InflictDamage(detonatedBy, self.Health, Rules.WarheadInfo["Super"]); var unit = self.traits.GetOrDefault(); + var info = self.Info.Traits.Get(); var altitude = unit != null ? unit.Altitude : 0; int2 detonateLocation = self.CenterLocation.ToInt2(); - self.World.AddFrameEndTask( - w => w.Add(new Bullet(self.Info.Traits.Get().PrimaryWeapon, detonatedBy.Owner, detonatedBy, - detonateLocation, detonateLocation, altitude, altitude))); + self.World.AddFrameEndTask( w => + { + // Fire weapon + w.Add(new Bullet(info.PrimaryWeapon, detonatedBy.Owner, detonatedBy, + detonateLocation, detonateLocation, altitude, altitude)); + + var weapon = Rules.WeaponInfo[info.PrimaryWeapon]; + if (!string.IsNullOrEmpty(weapon.Report)) + Sound.Play(weapon.Report + ".aud"); + + // Remove from world + self.Health = 0; + detonatedBy.Owner.Kills++; + w.Remove(self); + } ); } } }