Add DetonationAltitude to NukePower
And RemoveMissileOnDetonation boolean. Allows airburst, and optionally missile continuing until it hits the ground (without a second explosion).
This commit is contained in:
@@ -33,6 +33,8 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
readonly WPos ascendTarget;
|
readonly WPos ascendTarget;
|
||||||
readonly WPos descendSource;
|
readonly WPos descendSource;
|
||||||
readonly WPos descendTarget;
|
readonly WPos descendTarget;
|
||||||
|
readonly WDist detonationAltitude;
|
||||||
|
readonly bool removeOnDetonation;
|
||||||
readonly int impactDelay;
|
readonly int impactDelay;
|
||||||
readonly int turn;
|
readonly int turn;
|
||||||
readonly string trailImage;
|
readonly string trailImage;
|
||||||
@@ -45,9 +47,11 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
int ticks, trailTicks;
|
int ticks, trailTicks;
|
||||||
int launchDelay;
|
int launchDelay;
|
||||||
bool isLaunched;
|
bool isLaunched;
|
||||||
|
bool detonated;
|
||||||
|
|
||||||
public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence,
|
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 detonationAltitude, bool removeOnDetonation, WDist velocity, int launchDelay, int impactDelay,
|
||||||
|
bool skipAscent, string flashType,
|
||||||
string trailImage, string[] trailSequences, string trailPalette, bool trailUsePlayerPalette, int trailDelay, int trailInterval)
|
string trailImage, string[] trailSequences, string trailPalette, bool trailUsePlayerPalette, int trailDelay, int trailInterval)
|
||||||
{
|
{
|
||||||
this.firedBy = firedBy;
|
this.firedBy = firedBy;
|
||||||
@@ -74,6 +78,8 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
ascendTarget = launchPos + offset;
|
ascendTarget = launchPos + offset;
|
||||||
descendSource = targetPos + offset;
|
descendSource = targetPos + offset;
|
||||||
descendTarget = targetPos;
|
descendTarget = targetPos;
|
||||||
|
this.detonationAltitude = detonationAltitude;
|
||||||
|
this.removeOnDetonation = removeOnDetonation;
|
||||||
|
|
||||||
anim = new Animation(firedBy.World, name);
|
anim = new Animation(firedBy.World, name);
|
||||||
|
|
||||||
@@ -100,14 +106,15 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
if (ticks == turn)
|
if (ticks == turn)
|
||||||
anim.PlayRepeating(downSequence);
|
anim.PlayRepeating(downSequence);
|
||||||
|
|
||||||
if (ticks < turn)
|
var isDescending = ticks >= turn;
|
||||||
|
if (!isDescending)
|
||||||
pos = WPos.LerpQuadratic(ascendSource, ascendTarget, WAngle.Zero, ticks, turn);
|
pos = WPos.LerpQuadratic(ascendSource, ascendTarget, WAngle.Zero, ticks, turn);
|
||||||
else
|
else
|
||||||
pos = WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn, impactDelay - turn);
|
pos = WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn, impactDelay - turn);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(trailImage) && --trailTicks < 0)
|
if (!string.IsNullOrEmpty(trailImage) && --trailTicks < 0)
|
||||||
{
|
{
|
||||||
var trailPos = ticks < turn ? WPos.LerpQuadratic(ascendSource, ascendTarget, WAngle.Zero, ticks - trailDelay, turn)
|
var trailPos = !isDescending ? WPos.LerpQuadratic(ascendSource, ascendTarget, WAngle.Zero, ticks - trailDelay, turn)
|
||||||
: WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn - trailDelay, impactDelay - 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),
|
world.AddFrameEndTask(w => w.Add(new SpriteEffect(trailPos, w, trailImage, trailSequences.Random(world.SharedRandom),
|
||||||
@@ -116,23 +123,31 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
trailTicks = trailInterval;
|
trailTicks = trailInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticks == impactDelay)
|
var dat = world.Map.DistanceAboveTerrain(pos);
|
||||||
Explode(world);
|
if (ticks == impactDelay || (isDescending && dat <= detonationAltitude))
|
||||||
|
Explode(world, ticks == impactDelay || removeOnDetonation);
|
||||||
|
|
||||||
world.ScreenMap.Update(this, pos, anim.Image);
|
world.ScreenMap.Update(this, pos, anim.Image);
|
||||||
|
|
||||||
ticks++;
|
ticks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Explode(World world)
|
void Explode(World world, bool removeProjectile)
|
||||||
{
|
{
|
||||||
world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); });
|
if (removeProjectile)
|
||||||
|
world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); });
|
||||||
|
|
||||||
|
if (detonated)
|
||||||
|
return;
|
||||||
|
|
||||||
weapon.Impact(Target.FromPos(pos), firedBy.PlayerActor, Enumerable.Empty<int>());
|
weapon.Impact(Target.FromPos(pos), firedBy.PlayerActor, Enumerable.Empty<int>());
|
||||||
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
|
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
|
||||||
|
|
||||||
foreach (var flash in world.WorldActor.TraitsImplementing<FlashPaletteEffect>())
|
foreach (var flash in world.WorldActor.TraitsImplementing<FlashPaletteEffect>())
|
||||||
if (flash.Info.Type == flashType)
|
if (flash.Info.Type == flashType)
|
||||||
flash.Enable(-1);
|
flash.Enable(-1);
|
||||||
|
|
||||||
|
detonated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Offset from the actor the missile spawns on.")]
|
[Desc("Offset from the actor the missile spawns on.")]
|
||||||
public readonly WVec SpawnOffset = WVec.Zero;
|
public readonly WVec SpawnOffset = WVec.Zero;
|
||||||
|
|
||||||
|
[Desc("Altitude offset from the target position at which the warhead should detonate.")]
|
||||||
|
public readonly WDist DetonationAltitude = WDist.Zero;
|
||||||
|
|
||||||
|
[Desc("Should nuke missile projectile be removed on detonation above ground.",
|
||||||
|
"'False' will make the missile continue until it hits the ground and disappears (without triggering another explosion).")]
|
||||||
|
public readonly bool RemoveMissileOnDetonation = true;
|
||||||
|
|
||||||
[Desc("Palette to use for the missile weapon image.")]
|
[Desc("Palette to use for the missile weapon image.")]
|
||||||
[PaletteReference("IsPlayerPalette")] public readonly string MissilePalette = "effect";
|
[PaletteReference("IsPlayerPalette")] public readonly string MissilePalette = "effect";
|
||||||
|
|
||||||
@@ -133,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
|
var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
|
||||||
var missile = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown,
|
var missile = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown,
|
||||||
self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
|
self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
|
||||||
targetPosition,
|
targetPosition, info.DetonationAltitude, info.RemoveMissileOnDetonation,
|
||||||
info.FlightVelocity, info.MissileDelay, info.FlightDelay, info.SkipAscent,
|
info.FlightVelocity, info.MissileDelay, info.FlightDelay, info.SkipAscent,
|
||||||
info.FlashType,
|
info.FlashType,
|
||||||
info.TrailImage, info.TrailSequences, info.TrailPalette, info.TrailUsePlayerPalette, info.TrailDelay, info.TrailInterval);
|
info.TrailImage, info.TrailSequences, info.TrailPalette, info.TrailUsePlayerPalette, info.TrailDelay, info.TrailInterval);
|
||||||
|
|||||||
Reference in New Issue
Block a user