Fix Chronoshift / Demotruck interaction
This commit is contained in:
@@ -48,20 +48,24 @@ namespace OpenRa.Traits
|
||||
|
||||
var chronosphere = self.World.Actors.Where(a => a.Owner == self.Owner
|
||||
&& a.traits.Contains<Chronosphere>()).FirstOrDefault();
|
||||
if (chronosphere != null)
|
||||
chronosphere.traits.Get<RenderBuilding>().PlayCustomAnim( chronosphere, "active" );
|
||||
|
||||
bool success = order.TargetActor.traits.Get<Chronoshiftable>().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<ChronoshiftPaletteEffect>()))
|
||||
a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift();
|
||||
|
||||
Sound.Play("chrono2.aud");
|
||||
|
||||
order.TargetActor.traits.Get<Chronoshiftable>().Activate(order.TargetActor,
|
||||
order.TargetLocation,
|
||||
(int)((Info as ChronoshiftPowerInfo).Duration * 25 * 60),
|
||||
(Info as ChronoshiftPowerInfo).KillCargo,
|
||||
chronosphere);
|
||||
if (chronosphere != null)
|
||||
chronosphere.traits.Get<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
|
||||
}
|
||||
|
||||
Game.controller.CancelInputMode();
|
||||
FinishActivate();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Unit>();
|
||||
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
||||
var altitude = unit != null ? unit.Altitude : 0;
|
||||
int2 detonateLocation = self.CenterLocation.ToInt2();
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(new Bullet(self.Info.Traits.Get<AttackBaseInfo>().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);
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user