diff --git a/OpenRA.Mods.RA/Air/EjectOnDeath.cs b/OpenRA.Mods.RA/Air/EjectOnDeath.cs index d1ed8c28da..d3824b9c2b 100644 --- a/OpenRA.Mods.RA/Air/EjectOnDeath.cs +++ b/OpenRA.Mods.RA/Air/EjectOnDeath.cs @@ -35,9 +35,7 @@ namespace OpenRA.Mods.RA if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10 && self.Owner.WinState != WinState.Lost) { - self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot, - Util.CenterOfCell(self.CenterLocation.ToCPos()), aircraft.Altitude))); - + self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot, self.CenterPosition))); Sound.Play(info.ChuteSound, self.CenterLocation); } else diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index de3dd20ed5..54d169feec 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -19,48 +19,46 @@ namespace OpenRA.Mods.RA.Effects public class Parachute : IEffect { readonly Animation paraAnim; - readonly PPos location; - + readonly WVec parachuteOffset; readonly Actor cargo; + WPos pos; + WVec fallRate = new WVec(0, 0, 13); - int2 offset; - float altitude; - const float fallRate = .3f; - - public Parachute(Actor cargo, PPos location, int altitude) + public Parachute(Actor cargo, WPos dropPosition) { - this.location = location; - this.altitude = altitude; this.cargo = cargo; var pai = cargo.Info.Traits.GetOrDefault(); paraAnim = new Animation(pai != null ? pai.ParachuteSprite : "parach"); paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle")); - if (pai != null) offset = pai.Offset; + if (pai != null) + parachuteOffset = pai.Offset; - cargo.Trait().SetPxPosition(cargo, location); + // Adjust x,y to match the target subcell + cargo.Trait().SetPosition(cargo, new CPos(dropPosition)); + var cp = cargo.CenterPosition; + pos = new WPos(cp.X, cp.Y, dropPosition.Z); } public void Tick(World world) { paraAnim.Tick(); - altitude -= fallRate; + pos -= fallRate; - if (altitude <= 0) + if (pos.Z <= 0) + { world.AddFrameEndTask(w => - { - w.Remove(cargo); - w.Remove(this); - var loc = location.ToCPos(); - cargo.CancelActivity(); - cargo.Trait().SetPosition(cargo, loc); - w.Add(cargo); + { + w.Remove(this); + cargo.CancelActivity(); + w.Add(cargo); - foreach( var npl in cargo.TraitsImplementing() ) - npl.OnLanded(); - }); + foreach (var npl in cargo.TraitsImplementing()) + npl.OnLanded(); + }); + } } public IEnumerable Render(WorldRenderer wr) @@ -74,12 +72,11 @@ namespace OpenRA.Mods.RA.Effects var shadow = wr.Palette("shadow"); foreach (var c in rc) { - yield return c.WithPalette(shadow); - yield return c.WithPxOffset(new float2(0, -altitude)).WithZOffset(c.ZOffset + (int)altitude + 2); + yield return c.WithPalette(shadow).WithZOffset(-1); + yield return c.WithPos(pos); } - var pos = location.ToFloat2() - new float2(0, altitude); - yield return new Renderable(paraAnim.Image, pos + offset, rc.First().Palette, 3); + yield return new Renderable(paraAnim.Image, pos + parachuteOffset, 1, rc.First().Palette, 1f); } } } diff --git a/OpenRA.Mods.RA/ParaDrop.cs b/OpenRA.Mods.RA/ParaDrop.cs index 07788b529a..9ea27934dc 100644 --- a/OpenRA.Mods.RA/ParaDrop.cs +++ b/OpenRA.Mods.RA/ParaDrop.cs @@ -52,14 +52,7 @@ namespace OpenRA.Mods.RA droppedAt.Add(self.Location); var a = cargo.Unload(self); - - var aircraft = self.Trait(); - self.World.AddFrameEndTask(w => w.Add( - new Parachute(a, - Util.CenterOfCell(self.CenterLocation.ToCPos()), - aircraft.Altitude) - )); - + self.World.AddFrameEndTask(w => w.Add(new Parachute(a, self.CenterPosition))); Sound.Play(info.ChuteSound, self.CenterLocation); } } diff --git a/OpenRA.Mods.RA/ParachuteAttachment.cs b/OpenRA.Mods.RA/ParachuteAttachment.cs index 3e1882fd79..f6850ebc9e 100644 --- a/OpenRA.Mods.RA/ParachuteAttachment.cs +++ b/OpenRA.Mods.RA/ParachuteAttachment.cs @@ -15,7 +15,7 @@ namespace OpenRA.Mods.RA class ParachuteAttachmentInfo : TraitInfo { public readonly string ParachuteSprite = "parach"; - public readonly int2 Offset = new int2(0,0); + public readonly WVec Offset = WVec.Zero; } class ParachuteAttachment {} diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 9ec3d9b5ab..790802e87c 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -116,7 +116,7 @@ GpsDot: String:Infantry ParachuteAttachment: - Offset: 0,-10 + Offset: 0,0,427 CrushableInfantry: CrushSound: squishy2.aud RepairableNear: