From 8f805248ca2add822c499c4582f0e7e0ad03dd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 21 Jun 2014 15:55:40 +0200 Subject: [PATCH 01/11] StyleCop --- OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs index 24bb609e82..666e916881 100644 --- a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs @@ -45,8 +45,8 @@ namespace OpenRA.Mods.RA { var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary { - new LocationInit( order.TargetLocation ), - new OwnerInit( self.Owner ), + new LocationInit(order.TargetLocation), + new OwnerInit(self.Owner), }) : null; if (flare != null) From 1a0bb726e634c5e37f4729e2d932637382fbde69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 21 Jun 2014 15:55:54 +0200 Subject: [PATCH 02/11] document for modders --- OpenRA.Mods.RA/Crate.cs | 5 ++++- OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index df94f6de89..cf45a6ef05 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -18,8 +18,11 @@ namespace OpenRA.Mods.RA { class CrateInfo : ITraitInfo, IOccupySpaceInfo, Requires { - public readonly int Lifetime = 5; // Seconds + [Desc("Seconds")] + public readonly int Lifetime = 5; + public readonly string[] TerrainTypes = { }; + public object Create(ActorInitializer init) { return new Crate(init, this); } } diff --git a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs index 666e916881..8076e8f2b1 100644 --- a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs @@ -24,7 +24,8 @@ namespace OpenRA.Mods.RA [ActorReference] public string FlareType = "flare"; - public readonly int FlareTime = 25 * 60 * 2; // 2 minutes + [Desc("In game ticks. Default value equates to 2 minutes.")] + public readonly int FlareTime = 25 * 60 * 2; public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); } } From 2907273ef212685b2e09629f3b14fc59ef3b4bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 21 Jun 2014 17:33:14 +0200 Subject: [PATCH 03/11] new trait Parachtuable that decides on the fate upon landing --- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + OpenRA.Mods.RA/Parachutable.cs | 66 ++++++++++++++++++++++++++++ mods/d2k/rules/defaults.yaml | 1 + mods/ra/rules/defaults.yaml | 1 + mods/ra/sequences/misc.yaml | 4 ++ 5 files changed, 73 insertions(+) create mode 100644 OpenRA.Mods.RA/Parachutable.cs diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 613ee4bcba..6222220704 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -520,6 +520,7 @@ + diff --git a/OpenRA.Mods.RA/Parachutable.cs b/OpenRA.Mods.RA/Parachutable.cs new file mode 100644 index 0000000000..0f29cc98df --- /dev/null +++ b/OpenRA.Mods.RA/Parachutable.cs @@ -0,0 +1,66 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using OpenRA.Mods.RA.Effects; +using OpenRA.Mods.RA.Render; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class ParachutableInfo : ITraitInfo + { + public readonly bool KilledOnImpassableTerrain = true; + + public readonly string GroundImpactSound = "squishy2.aud"; + public readonly string GroundCorpseSequence = "corpse"; + public readonly string GroundCorpsePalette = "effect"; + + public readonly string WaterImpactSound = "splash9.aud"; + public readonly string WaterCorpseSequence = "small_splash"; + public readonly string WaterCorpsePalette = "effect"; + + public object Create(ActorInitializer init) { return new Parachutable(init, this); } + } + + class Parachutable : INotifyParachuteLanded + { + readonly Actor self; + readonly ParachutableInfo info; + readonly IPositionable positionable; + + public Parachutable(ActorInitializer init, ParachutableInfo info) + { + this.self = init.self; + this.info = info; + + positionable = self.TraitOrDefault(); + } + + public void OnLanded() + { + if (!info.KilledOnImpassableTerrain) + return; + + if (positionable.CanEnterCell(self.Location)) + return; + + var terrain = self.World.Map.GetTerrainInfo(self.Location); + + var sound = terrain.IsWater ? info.WaterImpactSound : info.GroundImpactSound; + Sound.Play(sound, self.CenterPosition); + + var sequence = terrain.IsWater ? info.WaterCorpseSequence : info.GroundCorpseSequence; + var palette = terrain.IsWater ? info.WaterCorpsePalette : info.GroundCorpsePalette; + self.World.AddFrameEndTask(w => w.Add(new Explosion(w, self.OccupiesSpace.CenterPosition, sequence, palette))); + + self.Kill(self); + } + } +} diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 621aaac7ce..b42f8a0486 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -196,6 +196,7 @@ LuaScriptEvents: ScriptTriggers: DeathSounds: + Parachutable: ^Plane: AppearsOnRadar: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 950d309d75..5cdfce8f49 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -175,6 +175,7 @@ DeathSounds@ZAPPED: DeathSound: Zapped InfDeaths: 6 + Parachutable: ^Ship: AppearsOnRadar: diff --git a/mods/ra/sequences/misc.yaml b/mods/ra/sequences/misc.yaml index 1c46d17d88..c18d94299d 100644 --- a/mods/ra/sequences/misc.yaml +++ b/mods/ra/sequences/misc.yaml @@ -72,6 +72,10 @@ explosion: small_napalm: napalm1 Start: 0 Length: * + corpse: corpse1 + Start: 0 + Length: 6 + Tick: 1600 pips: groups: From a38d43019abcfae4a74cfa09cb5c80e9fda94020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 21 Jun 2014 17:35:04 +0200 Subject: [PATCH 04/11] new setting to allow unlucky paratroopers --- OpenRA.Mods.RA/CrateSpawner.cs | 2 +- OpenRA.Mods.RA/EjectOnDeath.cs | 5 ++++- OpenRA.Mods.RA/ParaDrop.cs | 6 ++++-- OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs | 2 +- OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs | 5 ++++- mods/ra/rules/defaults.yaml | 3 +++ mods/ra/rules/structures.yaml | 1 + 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.RA/CrateSpawner.cs b/OpenRA.Mods.RA/CrateSpawner.cs index 938c089f40..bd95dc0abe 100644 --- a/OpenRA.Mods.RA/CrateSpawner.cs +++ b/OpenRA.Mods.RA/CrateSpawner.cs @@ -99,7 +99,7 @@ namespace OpenRA.Mods.RA plane.CancelActivity(); plane.QueueActivity(new FlyAttack(Target.FromCell(w, p))); - plane.Trait().SetLZ(p); + plane.Trait().SetLZ(p, true); plane.Trait().Load(plane, crate); } else diff --git a/OpenRA.Mods.RA/EjectOnDeath.cs b/OpenRA.Mods.RA/EjectOnDeath.cs index 31cf09fe9d..94e501ff14 100644 --- a/OpenRA.Mods.RA/EjectOnDeath.cs +++ b/OpenRA.Mods.RA/EjectOnDeath.cs @@ -24,6 +24,9 @@ namespace OpenRA.Mods.RA public readonly string ChuteSound = "chute1.aud"; public readonly bool EjectInAir = false; public readonly bool EjectOnGround = false; + + [Desc("Risks stuck units when they don't have the Paratrooper trait.")] + public readonly bool AllowUnsuitableCell = false; } public class EjectOnDeath : INotifyKilled @@ -47,7 +50,7 @@ namespace OpenRA.Mods.RA new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) }); - if (IsSuitableCell(self, pilot)) + if (info.AllowUnsuitableCell || IsSuitableCell(self, pilot)) { if (cp.Z > 0) { diff --git a/OpenRA.Mods.RA/ParaDrop.cs b/OpenRA.Mods.RA/ParaDrop.cs index 08a7ca1540..ab6af54edb 100644 --- a/OpenRA.Mods.RA/ParaDrop.cs +++ b/OpenRA.Mods.RA/ParaDrop.cs @@ -24,13 +24,15 @@ namespace OpenRA.Mods.RA public class ParaDrop : ITick { + bool checkForSuitableCell; readonly List droppedAt = new List(); CPos lz; - public void SetLZ(CPos lz) + public void SetLZ(CPos lz, bool checkLandingCell) { this.lz = lz; droppedAt.Clear(); + checkForSuitableCell = checkLandingCell; } public void Tick(Actor self) @@ -45,7 +47,7 @@ namespace OpenRA.Mods.RA FinishedDropping(self); else { - if (!IsSuitableCell(cargo.Peek(self), self.Location)) + if (checkForSuitableCell && !IsSuitableCell(cargo.Peek(self), self.Location)) return; // unload a dude here diff --git a/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs index 8819cf94d2..c4ce0967bb 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA.Scripting [Desc("Command transport to paradrop passengers near the target cell.")] public void Paradrop(CPos cell) { - paradrop.SetLZ(cell); + paradrop.SetLZ(cell, true); self.QueueActivity(new FlyAttack(Target.FromCell(self.World, cell))); } } diff --git a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs index 8076e8f2b1..46f13bc778 100644 --- a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs @@ -27,6 +27,9 @@ namespace OpenRA.Mods.RA [Desc("In game ticks. Default value equates to 2 minutes.")] public readonly int FlareTime = 25 * 60 * 2; + [Desc("Risks stuck units when they don't have the Paratrooper trait.")] + public readonly bool AllowImpassableCells = false; + public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); } } @@ -66,7 +69,7 @@ namespace OpenRA.Mods.RA a.CancelActivity(); a.QueueActivity(new FlyAttack(Target.FromOrder(self.World, order))); - a.Trait().SetLZ(order.TargetLocation); + a.Trait().SetLZ(order.TargetLocation, !info.AllowImpassableCells); var cargo = a.Trait(); foreach (var i in items) diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 5cdfce8f49..ab675e7652 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -43,6 +43,7 @@ SuccessRate: 20 EjectOnGround: yes EjectInAir: no + AllowUnsuitableCell: no Huntable: LuaScriptEvents: Demolishable: @@ -99,6 +100,7 @@ SuccessRate: 20 EjectOnGround: yes EjectInAir: no + AllowUnsuitableCell: no Huntable: LuaScriptEvents: Demolishable: @@ -235,6 +237,7 @@ SuccessRate: 50 EjectOnGround: no EjectInAir: yes + AllowUnsuitableCell: yes GivesBounty: GpsDot: String: Plane diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index c2f5f9d5c8..82ad7a130a 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -905,6 +905,7 @@ AFLD: LongDesc: A Badger drops a squad of infantry\nanywhere on the map. DropItems: E1,E1,E1,E3,E3 SelectTargetSound: slcttgt1.aud + AllowImpassableCells: false ProductionBar: SupportPowerChargeBar: PrimaryBuilding: From e04ff180602416f1be33c1a0b6bcf67277059225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 22 Jun 2014 14:18:04 +0200 Subject: [PATCH 05/11] @pchote's quest against legacy truth value definitions --- mods/ra/rules/defaults.yaml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index ab675e7652..ba43db8d03 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -41,9 +41,9 @@ EjectOnDeath: PilotActor: e1 SuccessRate: 20 - EjectOnGround: yes - EjectInAir: no - AllowUnsuitableCell: no + EjectOnGround: true + EjectInAir: false + AllowUnsuitableCell: false Huntable: LuaScriptEvents: Demolishable: @@ -98,9 +98,9 @@ EjectOnDeath: PilotActor: e1 SuccessRate: 20 - EjectOnGround: yes - EjectInAir: no - AllowUnsuitableCell: no + EjectOnGround: true + EjectInAir: false + AllowUnsuitableCell: false Huntable: LuaScriptEvents: Demolishable: @@ -214,7 +214,7 @@ ^Plane: AppearsOnRadar: - UseLocation: yes + UseLocation: true SelectionDecorations: Selectable: Voice: GenericVoice @@ -235,9 +235,9 @@ EjectOnDeath: PilotActor: E1 SuccessRate: 50 - EjectOnGround: no - EjectInAir: yes - AllowUnsuitableCell: yes + EjectOnGround: false + EjectInAir: true + AllowUnsuitableCell: true GivesBounty: GpsDot: String: Plane @@ -281,7 +281,7 @@ GivesExperience: CaptureNotification: EditorAppearance: - RelativeToTopLeft: yes + RelativeToTopLeft: true ShakeOnDeath: ProximityCaptor: Types: Building @@ -326,7 +326,7 @@ Palette: terrain GivesExperience: EditorAppearance: - RelativeToTopLeft: yes + RelativeToTopLeft: true UseTerrainPalette: true AutoTargetIgnore: ProximityCaptor: @@ -429,7 +429,7 @@ RadarColorFromTerrain: Terrain: Tree EditorAppearance: - RelativeToTopLeft: yes + RelativeToTopLeft: true UseTerrainPalette: true ProximityCaptor: Types: Tree @@ -464,11 +464,11 @@ LuaScriptEvents: TargetableUnit: TargetTypes: Ground - RequiresForceFire: yes + RequiresForceFire: true AutoTargetIgnore: Capturable: Type: husk - AllowAllies: yes + AllowAllies: true CaptureThreshold: 1.0 TransformOnCapture: ForceHealthPercentage: 25 @@ -505,7 +505,7 @@ BelowUnits: TargetableBuilding: TargetTypes: Ground, Water - RequiresForceFire: yes + RequiresForceFire: true Building: Footprint: ____ ____ Dimensions: 4,2 @@ -532,7 +532,7 @@ RadarColorFromTerrain: Terrain: Tree EditorAppearance: - RelativeToTopLeft: yes + RelativeToTopLeft: true UseTerrainPalette: true ProximityCaptor: Types: Tree From ff1be8daeaba13570107a2a10a9c10975a02af86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 22 Jun 2014 14:49:00 +0200 Subject: [PATCH 06/11] merge ParachuteAttachment and Parachutable --- OpenRA.Mods.RA/Effects/Parachute.cs | 9 +++++---- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 - OpenRA.Mods.RA/Parachutable.cs | 3 +++ OpenRA.Mods.RA/ParachuteAttachment.cs | 22 ---------------------- OpenRA.Utility/UpgradeRules.cs | 13 +++++++++++++ mods/ra/rules/defaults.yaml | 3 +-- 6 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 OpenRA.Mods.RA/ParachuteAttachment.cs diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index f05adcc035..1767e334a7 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -28,12 +28,13 @@ namespace OpenRA.Mods.RA.Effects { this.cargo = cargo; - var pai = cargo.Info.Traits.GetOrDefault(); - paraAnim = new Animation(cargo.World, pai != null ? pai.ParachuteSprite : "parach"); + var parachutableInfo = cargo.Info.Traits.GetOrDefault(); + var sprite = parachutableInfo != null ? parachutableInfo.ParachuteSprite : "parach"; + paraAnim = new Animation(cargo.World, sprite); paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle")); - if (pai != null) - parachuteOffset = pai.Offset; + if (parachutableInfo != null) + parachuteOffset = parachutableInfo.ParachuteOffset; // Adjust x,y to match the target subcell cargo.Trait().SetPosition(cargo, cargo.World.Map.CellContaining(dropPosition)); diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 6222220704..60f4dac608 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -279,7 +279,6 @@ - diff --git a/OpenRA.Mods.RA/Parachutable.cs b/OpenRA.Mods.RA/Parachutable.cs index 0f29cc98df..75e2586b67 100644 --- a/OpenRA.Mods.RA/Parachutable.cs +++ b/OpenRA.Mods.RA/Parachutable.cs @@ -26,6 +26,9 @@ namespace OpenRA.Mods.RA public readonly string WaterCorpseSequence = "small_splash"; public readonly string WaterCorpsePalette = "effect"; + public readonly string ParachuteSprite = "parach"; + public readonly WVec ParachuteOffset = WVec.Zero; + public object Create(ActorInitializer init) { return new Parachutable(init, this); } } diff --git a/OpenRA.Mods.RA/ParachuteAttachment.cs b/OpenRA.Mods.RA/ParachuteAttachment.cs deleted file mode 100644 index f6850ebc9e..0000000000 --- a/OpenRA.Mods.RA/ParachuteAttachment.cs +++ /dev/null @@ -1,22 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - class ParachuteAttachmentInfo : TraitInfo - { - public readonly string ParachuteSprite = "parach"; - public readonly WVec Offset = WVec.Zero; - } - - class ParachuteAttachment {} -} \ No newline at end of file diff --git a/OpenRA.Utility/UpgradeRules.cs b/OpenRA.Utility/UpgradeRules.cs index 5d707c7f00..80c7df9c69 100644 --- a/OpenRA.Utility/UpgradeRules.cs +++ b/OpenRA.Utility/UpgradeRules.cs @@ -252,6 +252,19 @@ namespace OpenRA.Utility node.Key = "StoresResources"; } + // ParachuteAttachment was merged into Parachutable + if (engineVersion < 20140701) + { + if (depth == 1 && node.Key == "ParachuteAttachment") + { + node.Key = "Parachutable"; + + foreach (var subnode in node.Value.Nodes) + if (subnode.Key == "Offset") + subnode.Key = "ParachuteOffset"; + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index ba43db8d03..ea847021f2 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -151,8 +151,6 @@ GivesBounty: GpsDot: String: Infantry - ParachuteAttachment: - Offset: 0,0,427 CrushableInfantry: CrushSound: squishy2.aud UpdatesPlayerStatistics: @@ -178,6 +176,7 @@ DeathSound: Zapped InfDeaths: 6 Parachutable: + ParachuteOffset: 0,0,427 ^Ship: AppearsOnRadar: From ef01fb289b6e82f52b1beccaed02ffa05a0779de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 22 Jun 2014 15:34:52 +0200 Subject: [PATCH 07/11] make the parachute animation optional instead of hard-coding default sprite sequences --- OpenRA.Mods.RA/Effects/Parachute.cs | 19 ++++++++++++------- OpenRA.Mods.RA/Parachutable.cs | 3 ++- OpenRA.Utility/UpgradeRules.cs | 3 +++ mods/d2k/bits/parach.shp | Bin 13262 -> 0 bytes mods/ra/rules/defaults.yaml | 2 ++ mods/ra/rules/misc.yaml | 3 +++ 6 files changed, 22 insertions(+), 8 deletions(-) delete mode 100644 mods/d2k/bits/parach.shp diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index 1767e334a7..b614161533 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Effects { public class Parachute : IEffect { - readonly Animation paraAnim; + readonly Animation parachute; readonly WVec parachuteOffset; readonly Actor cargo; WPos pos; @@ -29,9 +29,12 @@ namespace OpenRA.Mods.RA.Effects this.cargo = cargo; var parachutableInfo = cargo.Info.Traits.GetOrDefault(); - var sprite = parachutableInfo != null ? parachutableInfo.ParachuteSprite : "parach"; - paraAnim = new Animation(cargo.World, sprite); - paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle")); + var parachuteSprite = parachutableInfo != null ? parachutableInfo.ParachuteSequence : null; + if (parachuteSprite != null) + { + parachute = new Animation(cargo.World, parachuteSprite); + parachute.PlayThen("open", () => parachute.PlayRepeating("idle")); + } if (parachutableInfo != null) parachuteOffset = parachutableInfo.ParachuteOffset; @@ -44,7 +47,8 @@ namespace OpenRA.Mods.RA.Effects public void Tick(World world) { - paraAnim.Tick(); + if (parachute != null) + parachute.Tick(); pos -= fallRate; @@ -79,8 +83,9 @@ namespace OpenRA.Mods.RA.Effects yield return c.OffsetBy(pos - c.Pos); } - foreach (var r in paraAnim.Render(pos, parachuteOffset, 1, rc.First().Palette, 1f)) - yield return r; + if (parachute != null) + foreach (var r in parachute.Render(pos, parachuteOffset, 1, rc.First().Palette, 1f)) + yield return r; } } } diff --git a/OpenRA.Mods.RA/Parachutable.cs b/OpenRA.Mods.RA/Parachutable.cs index 75e2586b67..76a1b9eeba 100644 --- a/OpenRA.Mods.RA/Parachutable.cs +++ b/OpenRA.Mods.RA/Parachutable.cs @@ -26,7 +26,8 @@ namespace OpenRA.Mods.RA public readonly string WaterCorpseSequence = "small_splash"; public readonly string WaterCorpsePalette = "effect"; - public readonly string ParachuteSprite = "parach"; + [Desc("Requires the sub-sequences \"open\" and \"idle\".")] + public readonly string ParachuteSequence = null; public readonly WVec ParachuteOffset = WVec.Zero; public object Create(ActorInitializer init) { return new Parachutable(init, this); } diff --git a/OpenRA.Utility/UpgradeRules.cs b/OpenRA.Utility/UpgradeRules.cs index 80c7df9c69..12551fb493 100644 --- a/OpenRA.Utility/UpgradeRules.cs +++ b/OpenRA.Utility/UpgradeRules.cs @@ -263,6 +263,9 @@ namespace OpenRA.Utility if (subnode.Key == "Offset") subnode.Key = "ParachuteOffset"; } + + if (depth == 2 && node.Key == "ParachuteSprite") + node.Key = "ParachuteSequence"; } UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); diff --git a/mods/d2k/bits/parach.shp b/mods/d2k/bits/parach.shp deleted file mode 100644 index 6ab15cd9caf722989339db13a12dd03d83492004..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13262 zcmeI2U5eB|5XT!=5CmbthXp|p_CXjB1W^yt_$4{amSQ9)BryLl^%p!ua%A7(YJ`<=1+C~LQoD6ZH?dW1J(+vH(Qt7Xz$DRUgvP&hV@|5Z^-t8 zHrWIe2i>%(K6$Zb7K`(+#0{fhK$$N6>{BMt9>rlwlUt% z+0G$E$Ob5zR1Pw%G>EF*328@=$FoX-m0M);A3bM}U$1vjGms z<2qwVvjKTAGO8o5C^H!{Ea+5LYX}&@;e3GD%cr;*KMrw3Z~dfYMr$rj$ugn!d;#Bu)0S!2%s+lH3AHYe~x2pKfH; z#kt#`E;3Y5M9BzG6JGr@#z0Y+QZh&deKX ztax`P)N%4mnxXiRlR0G?>U;1zxxP)g1!njb+IF@dGZglz3z}++QmkK6X8qCO-Z5W) zuX;9l?)E2(3>p{Snk7#R$?Is(mN9eN&R{}V^t5BcF&M!&$??dU8HmY`%s=QdV%YXg z>TuW6f}yrSTciv-CLE;`7|_SAklAqBcEWzVRc!7O4?I&8R%FJg-E%C&{~%8%iwwW; zqx`4u^+>7=-D=+BFafp7Y)#o?+n+8ni>Cs$mnl^wK#Cf+=I7Wc_t@7zQDmsb(CJm2 z0_az;DRVf$ipmcf8Jvr8%Od2KcV*~L;3yJ1K1ib$C)$^sQ- diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index ea847021f2..5d3eeba251 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -177,6 +177,8 @@ InfDeaths: 6 Parachutable: ParachuteOffset: 0,0,427 + KilledOnImpassableTerrain: true + ParachuteSequence: parach ^Ship: AppearsOnRadar: diff --git a/mods/ra/rules/misc.yaml b/mods/ra/rules/misc.yaml index ba8c2109f7..93051c793f 100644 --- a/mods/ra/rules/misc.yaml +++ b/mods/ra/rules/misc.yaml @@ -60,6 +60,9 @@ CRATE: Crate: Lifetime: 120 TerrainTypes: Clear, Rough, Road, Water, Ore, Beach + Parachutable: + KilledOnImpassableTerrain: false + ParachuteSequence: parach GiveCashCrateAction: Amount: 1000 SelectionShares: 50 From 18a77e00394ab8ff1d448955b5a45607ab023e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 1 Jul 2014 20:22:28 +0200 Subject: [PATCH 08/11] make the parachute palettes configurable --- OpenRA.Mods.RA/Effects/Parachute.cs | 8 +++++--- OpenRA.Mods.RA/Parachutable.cs | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index b614161533..cf94fe6e18 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -18,6 +18,7 @@ namespace OpenRA.Mods.RA.Effects { public class Parachute : IEffect { + readonly ParachutableInfo parachutableInfo; readonly Animation parachute; readonly WVec parachuteOffset; readonly Actor cargo; @@ -28,7 +29,7 @@ namespace OpenRA.Mods.RA.Effects { this.cargo = cargo; - var parachutableInfo = cargo.Info.Traits.GetOrDefault(); + parachutableInfo = cargo.Info.Traits.GetOrDefault(); var parachuteSprite = parachutableInfo != null ? parachutableInfo.ParachuteSequence : null; if (parachuteSprite != null) { @@ -74,7 +75,7 @@ namespace OpenRA.Mods.RA.Effects if (!rc.Any()) yield break; - var shadow = wr.Palette("shadow"); + var shadow = wr.Palette(parachutableInfo.ParachuteShadowPalette); foreach (var c in rc) { if (!c.IsDecoration) @@ -83,8 +84,9 @@ namespace OpenRA.Mods.RA.Effects yield return c.OffsetBy(pos - c.Pos); } + var palette = !string.IsNullOrEmpty(parachutableInfo.ParachutePalette) ? wr.Palette(parachutableInfo.ParachutePalette) : rc.First().Palette; if (parachute != null) - foreach (var r in parachute.Render(pos, parachuteOffset, 1, rc.First().Palette, 1f)) + foreach (var r in parachute.Render(pos, parachuteOffset, 1, palette, 1f)) yield return r; } } diff --git a/OpenRA.Mods.RA/Parachutable.cs b/OpenRA.Mods.RA/Parachutable.cs index 76a1b9eeba..e4d630d3f9 100644 --- a/OpenRA.Mods.RA/Parachutable.cs +++ b/OpenRA.Mods.RA/Parachutable.cs @@ -28,6 +28,8 @@ namespace OpenRA.Mods.RA [Desc("Requires the sub-sequences \"open\" and \"idle\".")] public readonly string ParachuteSequence = null; + public readonly string ParachutePalette = null; + public readonly string ParachuteShadowPalette = "shadow"; public readonly WVec ParachuteOffset = WVec.Zero; public object Create(ActorInitializer init) { return new Parachutable(init, this); } From 4a7687d7e4b20fa9beace0a478c92537c5140643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 1 Jul 2014 21:21:09 +0200 Subject: [PATCH 09/11] add a customizable parachute shadow closes #3335 --- OpenRA.Mods.RA/Effects/Parachute.cs | 26 +++++++++++++++++++++----- OpenRA.Mods.RA/Parachutable.cs | 8 ++++++++ mods/ra/bits/parach-shadow.shp | Bin 0 -> 60 bytes mods/ra/rules/defaults.yaml | 1 + mods/ra/sequences/misc.yaml | 5 +++++ 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 mods/ra/bits/parach-shadow.shp diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index cf94fe6e18..3f86af57e6 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA.Effects { readonly ParachutableInfo parachutableInfo; readonly Animation parachute; + readonly Animation shadow; readonly WVec parachuteOffset; readonly Actor cargo; WPos pos; @@ -37,6 +38,13 @@ namespace OpenRA.Mods.RA.Effects parachute.PlayThen("open", () => parachute.PlayRepeating("idle")); } + var shadowSprite = parachutableInfo != null ? parachutableInfo.ShadowSequence : null; + if (shadowSprite != null) + { + shadow = new Animation(cargo.World, shadowSprite); + shadow.PlayRepeating("idle"); + } + if (parachutableInfo != null) parachuteOffset = parachutableInfo.ParachuteOffset; @@ -51,6 +59,9 @@ namespace OpenRA.Mods.RA.Effects if (parachute != null) parachute.Tick(); + if (shadow != null) + shadow.Tick(); + pos -= fallRate; if (pos.Z <= 0) @@ -75,18 +86,23 @@ namespace OpenRA.Mods.RA.Effects if (!rc.Any()) yield break; - var shadow = wr.Palette(parachutableInfo.ParachuteShadowPalette); + var parachuteShadowPalette = wr.Palette(parachutableInfo.ParachuteShadowPalette); foreach (var c in rc) { - if (!c.IsDecoration) - yield return c.WithPalette(shadow).WithZOffset(c.ZOffset - 1).AsDecoration(); + if (!c.IsDecoration && shadow == null) + yield return c.WithPalette(parachuteShadowPalette).WithZOffset(c.ZOffset - 1).AsDecoration(); yield return c.OffsetBy(pos - c.Pos); } - var palette = !string.IsNullOrEmpty(parachutableInfo.ParachutePalette) ? wr.Palette(parachutableInfo.ParachutePalette) : rc.First().Palette; + var shadowPalette = !string.IsNullOrEmpty(parachutableInfo.ShadowPalette) ? wr.Palette(parachutableInfo.ShadowPalette) : rc.First().Palette; + if (shadow != null) + foreach (var r in shadow.Render(pos, parachuteOffset, 1, shadowPalette, 1f)) + yield return r; + + var parachutePalette = !string.IsNullOrEmpty(parachutableInfo.ParachutePalette) ? wr.Palette(parachutableInfo.ParachutePalette) : rc.First().Palette; if (parachute != null) - foreach (var r in parachute.Render(pos, parachuteOffset, 1, palette, 1f)) + foreach (var r in parachute.Render(pos, parachuteOffset, 1, parachutePalette, 1f)) yield return r; } } diff --git a/OpenRA.Mods.RA/Parachutable.cs b/OpenRA.Mods.RA/Parachutable.cs index e4d630d3f9..b8d0d39c44 100644 --- a/OpenRA.Mods.RA/Parachutable.cs +++ b/OpenRA.Mods.RA/Parachutable.cs @@ -28,10 +28,18 @@ namespace OpenRA.Mods.RA [Desc("Requires the sub-sequences \"open\" and \"idle\".")] public readonly string ParachuteSequence = null; + [Desc("Optional, otherwise defaults to the palette the actor is using.")] public readonly string ParachutePalette = null; + [Desc("Used to clone the actor with this palette and render it with a visual offset below.")] public readonly string ParachuteShadowPalette = "shadow"; + public readonly WVec ParachuteOffset = WVec.Zero; + [Desc("Alternative to ParachuteShadowPalette which disables it and allows to set a custom sprite sequence instead.")] + public readonly string ShadowSequence = null; + [Desc("Optional, otherwise defaults to the palette the actor is using.")] + public readonly string ShadowPalette = null; + public object Create(ActorInitializer init) { return new Parachutable(init, this); } } diff --git a/mods/ra/bits/parach-shadow.shp b/mods/ra/bits/parach-shadow.shp new file mode 100644 index 0000000000000000000000000000000000000000..7d848c88a424dfe29931843356f3ccd99a957af1 GIT binary patch literal 60 wcmZQ%00ABbHXv!kpvJ(^0OH$#2qf^2pMl{Y8v{!LmjmAkX$A+?e*!?20C|)K Date: Thu, 3 Jul 2014 18:04:48 +0200 Subject: [PATCH 10/11] make the fallrate customizable --- OpenRA.Mods.RA/Effects/Parachute.cs | 8 ++++++-- OpenRA.Mods.RA/Parachutable.cs | 2 ++ mods/d2k/rules/defaults.yaml | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index 3f86af57e6..20f1d3abdd 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -24,13 +24,17 @@ namespace OpenRA.Mods.RA.Effects readonly WVec parachuteOffset; readonly Actor cargo; WPos pos; - WVec fallRate = new WVec(0, 0, 13); + WVec fallVector; public Parachute(Actor cargo, WPos dropPosition) { this.cargo = cargo; parachutableInfo = cargo.Info.Traits.GetOrDefault(); + + if (parachutableInfo != null) + fallVector = new WVec(0, 0, parachutableInfo.FallRate); + var parachuteSprite = parachutableInfo != null ? parachutableInfo.ParachuteSequence : null; if (parachuteSprite != null) { @@ -62,7 +66,7 @@ namespace OpenRA.Mods.RA.Effects if (shadow != null) shadow.Tick(); - pos -= fallRate; + pos -= fallVector; if (pos.Z <= 0) { diff --git a/OpenRA.Mods.RA/Parachutable.cs b/OpenRA.Mods.RA/Parachutable.cs index b8d0d39c44..2391db913e 100644 --- a/OpenRA.Mods.RA/Parachutable.cs +++ b/OpenRA.Mods.RA/Parachutable.cs @@ -35,6 +35,8 @@ namespace OpenRA.Mods.RA public readonly WVec ParachuteOffset = WVec.Zero; + public readonly int FallRate = 13; + [Desc("Alternative to ParachuteShadowPalette which disables it and allows to set a custom sprite sequence instead.")] public readonly string ShadowSequence = null; [Desc("Optional, otherwise defaults to the palette the actor is using.")] diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index b42f8a0486..08863b5172 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -197,6 +197,7 @@ ScriptTriggers: DeathSounds: Parachutable: + FallRate: 130 ^Plane: AppearsOnRadar: From 5e7e677ca9db98c81fe522d70406a75e0a09c4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 3 Jul 2014 18:22:50 +0200 Subject: [PATCH 11/11] fix shadow sprite not being rendered on the ground --- OpenRA.Mods.RA/Effects/Parachute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index 20f1d3abdd..db9fbd2bbb 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Effects var shadowPalette = !string.IsNullOrEmpty(parachutableInfo.ShadowPalette) ? wr.Palette(parachutableInfo.ShadowPalette) : rc.First().Palette; if (shadow != null) - foreach (var r in shadow.Render(pos, parachuteOffset, 1, shadowPalette, 1f)) + foreach (var r in shadow.Render(pos - new WVec(0, 0, pos.Z), WVec.Zero, 1, shadowPalette, 1f)) yield return r; var parachutePalette = !string.IsNullOrEmpty(parachutableInfo.ParachutePalette) ? wr.Palette(parachutableInfo.ParachutePalette) : rc.First().Palette;