diff --git a/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs b/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs index 7b2a7efd19..f8d9211abf 100644 --- a/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs +++ b/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs @@ -35,14 +35,20 @@ namespace OpenRA.Mods.Common.Effects readonly WPos descendTarget; readonly int impactDelay; readonly int turn; + readonly string trailImage; + readonly string[] trailSequences; + readonly string trailPalette; + readonly int trailInterval; + readonly int trailDelay; WPos pos; - int ticks; + int ticks, trailTicks; int launchDelay; bool isLaunched; public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence, - WPos launchPos, WPos targetPos, WDist velocity, int launchDelay, int impactDelay, bool skipAscent, string flashType) + WPos launchPos, WPos targetPos, WDist velocity, int launchDelay, int impactDelay, bool skipAscent, string flashType, + string trailImage, string[] trailSequences, string trailPalette, bool trailUsePlayerPalette, int trailDelay, int trailInterval) { this.firedBy = firedBy; this.weapon = weapon; @@ -53,6 +59,15 @@ namespace OpenRA.Mods.Common.Effects this.impactDelay = impactDelay; turn = skipAscent ? 0 : impactDelay / 2; this.flashType = flashType; + this.trailImage = trailImage; + this.trailSequences = trailSequences; + this.trailPalette = trailPalette; + if (trailUsePlayerPalette) + trailPalette += firedBy.InternalName; + + this.trailInterval = trailInterval; + this.trailDelay = trailDelay; + trailTicks = trailDelay; var offset = new WVec(WDist.Zero, WDist.Zero, velocity * (impactDelay - turn)); ascendSource = launchPos; @@ -90,6 +105,17 @@ namespace OpenRA.Mods.Common.Effects else pos = WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn, impactDelay - turn); + if (!string.IsNullOrEmpty(trailImage) && --trailTicks < 0) + { + var trailPos = ticks < turn ? WPos.LerpQuadratic(ascendSource, ascendTarget, WAngle.Zero, ticks - trailDelay, turn) + : WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn - trailDelay, impactDelay - turn); + + world.AddFrameEndTask(w => w.Add(new SpriteEffect(trailPos, w, trailImage, trailSequences.Random(world.SharedRandom), + trailPalette, false, false, 0))); + + trailTicks = trailInterval; + } + if (ticks == impactDelay) Explode(world); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index 2a7e1211ef..0860f30810 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -41,6 +41,24 @@ namespace OpenRA.Mods.Common.Traits [Desc("Custom palette is a player palette BaseName.")] public readonly bool IsPlayerPalette = false; + [Desc("Trail animation.")] + public readonly string TrailImage = null; + + [Desc("Loop a randomly chosen sequence of TrailImage from this list while this projectile is moving.")] + [SequenceReference("TrailImage")] public readonly string[] TrailSequences = { "idle" }; + + [Desc("Interval in ticks between each spawned Trail animation.")] + public readonly int TrailInterval = 1; + + [Desc("Delay in ticks until trail animation is spawned.")] + public readonly int TrailDelay = 1; + + [Desc("Palette used to render the trail sequence.")] + [PaletteReference("TrailUsePlayerPalette")] public readonly string TrailPalette = "effect"; + + [Desc("Use the Player Palette to render the trail sequence.")] + public readonly bool TrailUsePlayerPalette = false; + [Desc("Travel time - split equally between ascent and descent.")] public readonly int FlightDelay = 400; @@ -117,7 +135,8 @@ namespace OpenRA.Mods.Common.Traits self.CenterPosition + body.LocalToWorld(info.SpawnOffset), targetPosition, info.FlightVelocity, info.MissileDelay, info.FlightDelay, info.SkipAscent, - info.FlashType); + info.FlashType, + info.TrailImage, info.TrailSequences, info.TrailPalette, info.TrailUsePlayerPalette, info.TrailDelay, info.TrailInterval); self.World.AddFrameEndTask(w => w.Add(missile));