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: