diff --git a/OpenRa.Game/Effects/Parachute.cs b/OpenRa.Game/Effects/Parachute.cs new file mode 100644 index 0000000000..20bdfc0814 --- /dev/null +++ b/OpenRa.Game/Effects/Parachute.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.Traits; +using OpenRa.Graphics; + +namespace OpenRa.Effects +{ + class Parachute : IEffect + { + readonly Animation anim; + readonly Animation paraAnim; + readonly float2 location; + + readonly Actor cargo; + readonly Player owner; + + float altitude; + const float fallRate = .3f; + + public Parachute(Player owner, string image, float2 location, int altitude, Actor cargo) + { + this.location = location; + this.altitude = altitude; + this.cargo = cargo; + this.owner = owner; + + anim = new Animation(image); + anim.PlayFetchIndex("idle", () => 0); + anim.Tick(); + + paraAnim = new Animation("parach"); + paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle")); + } + + public void Tick(World world) + { + paraAnim.Tick(); + + altitude -= fallRate; + + if (altitude <= 0) + world.AddFrameEndTask(w => + { + w.Remove(this); + cargo.CancelActivity(); + cargo.CenterLocation = location; + cargo.Location = ((1 / 24f) * location).ToInt2(); + w.Add(cargo); + }); + } + + public IEnumerable Render() + { + var pos = location - new float2(0, altitude); + yield return new Renderable(anim.Image, location - .5f * anim.Image.size, PaletteType.Shadow, 0); + yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, owner.Palette, 2); + yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size, owner.Palette, 3); + } + } +} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 2db8498fd4..e57cf60c69 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -83,6 +83,7 @@ + diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml index 22b8bd1998..dac09e2711 100644 --- a/mods/ra/rules.yaml +++ b/mods/ra/rules.yaml @@ -1027,6 +1027,21 @@ U2: WithShadow: IronCurtainable: +BADR: + Inherits: ^Plane + Unit: + HP: 60 + Armor: light + ROT: 5 + Sight: 0 + Speed: 16 + Plane: + RenderUnit: + WithShadow: + IronCurtainable: + Cargo: + Passengers: 5 + PBOX: Inherits: ^Building Buildable: diff --git a/mods/ra/sequences.xml b/mods/ra/sequences.xml index 47d231f898..c6f0ce7331 100644 --- a/mods/ra/sequences.xml +++ b/mods/ra/sequences.xml @@ -408,7 +408,7 @@ - + @@ -1041,10 +1041,14 @@ - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/mods/ra/units.ini b/mods/ra/units.ini index 97225b3480..196f7c2c07 100644 --- a/mods/ra/units.ini +++ b/mods/ra/units.ini @@ -208,7 +208,7 @@ LongDesc=Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicle [U2] Traits=Unit, Plane, RenderUnit, WithShadow, IronCurtainable [BADR] -Traits=Unit, Plane, RenderUnit, WithShadow, IronCurtainable +Traits=Unit, Plane, RenderUnit, WithShadow, IronCurtainable, Cargo