diff --git a/OpenRA.Mods.RA/CrushableInfantry.cs b/OpenRA.Mods.RA/CrushableInfantry.cs new file mode 100644 index 0000000000..972703c35a --- /dev/null +++ b/OpenRA.Mods.RA/CrushableInfantry.cs @@ -0,0 +1,60 @@ +#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 System.Collections.Generic; +using System.Linq; +using OpenRA.Traits; +using OpenRA.Mods.RA.Effects; +using OpenRA.Mods.RA.Move; + +namespace OpenRA.Mods.RA +{ + class CrushableInfantryInfo : ITraitInfo, Requires + { + public readonly string CrushSound = "squish2.aud"; + public readonly string CorpseSequence = "die-crushed"; + public readonly string[] CrushClasses = { "infantry" }; + public readonly int WarnProbability = 90; + public object Create(ActorInitializer init) { return new CrushableInfantry(init.self, this); } + } + + class CrushableInfantry : ICrushable + { + readonly Actor self; + readonly CrushableInfantryInfo Info; + + public CrushableInfantry(Actor self, CrushableInfantryInfo info) + { + this.self = self; + this.Info = info; + } + + public void WarnCrush(Actor crusher) + { + if (self.World.SharedRandom.Next(100) <= Info.WarnProbability) + self.Trait().OnNudge(self, crusher, true); + } + + public void OnCrush(Actor crusher) + { + Sound.Play(Info.CrushSound); + self.World.AddFrameEndTask(w => w.Add(new Corpse(self, Info.CorpseSequence))); + self.Kill(crusher); + } + + public bool CrushableBy(string[] crushClasses, Player crushOwner) + { + if (crushOwner.Stances[self.Owner] == Stance.Ally) + return false; + + return Info.CrushClasses.Intersect(crushClasses).Any(); + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 9193efc384..644c2850c1 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -352,6 +352,7 @@ + diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 84d7d10b9f..4cb499cf01 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -33,7 +33,7 @@ ^Tank: AppearsOnRadar: Mobile: - Crushes: wall, crate + Crushes: wall, crate, infantry TerrainSpeeds: Clear: 80 Rough: 70 @@ -124,6 +124,7 @@ ActorLostNotification: Notification: unitlost.aud SpawnViceroid: + CrushableInfantry: ^CivInfantry: Inherits: ^Infantry diff --git a/mods/cnc/rules/infantry.yaml b/mods/cnc/rules/infantry.yaml index 12c762f698..e1e9964164 100644 --- a/mods/cnc/rules/infantry.yaml +++ b/mods/cnc/rules/infantry.yaml @@ -18,7 +18,8 @@ E1: AttackFrontal: PrimaryWeapon: M16 RenderInfantryProne: - IdleAnimations: idle1,idle2,idle3,idle4 + IdleAnimations: idle1,idle2,idle3,idle4 + E2: Inherits: ^Infantry Valued: diff --git a/mods/cnc/sequences/civilian.yaml b/mods/cnc/sequences/civilian.yaml index ade9cd0903..a467b58508 100644 --- a/mods/cnc/sequences/civilian.yaml +++ b/mods/cnc/sequences/civilian.yaml @@ -47,6 +47,9 @@ c1: Start: 182 Length: 4 Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 c2: stand: Start: 0 @@ -96,7 +99,9 @@ c2: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c3: stand: Start: 0 @@ -146,7 +151,9 @@ c3: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c4: stand: Start: 0 @@ -196,7 +203,9 @@ c4: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c5: stand: Start: 0 @@ -246,7 +255,9 @@ c5: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c6: stand: Start: 0 @@ -296,7 +307,9 @@ c6: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c7: stand: Start: 0 @@ -346,7 +359,9 @@ c7: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c8: stand: Start: 0 @@ -396,7 +411,9 @@ c8: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c9: stand: Start: 0 @@ -446,7 +463,9 @@ c9: Start: 182 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 c10: stand: Start: 0 @@ -495,4 +514,7 @@ c10: die6: Start: 182 Length: 4 - Tick: 80 \ No newline at end of file + Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 \ No newline at end of file diff --git a/mods/cnc/sequences/infantry.yaml b/mods/cnc/sequences/infantry.yaml index 44b9cf463c..7b24b180a7 100644 --- a/mods/cnc/sequences/infantry.yaml +++ b/mods/cnc/sequences/infantry.yaml @@ -103,6 +103,9 @@ e1: Start: 366 Length: 11 Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 e2: stand: Start: 0 @@ -183,6 +186,9 @@ e2: Start: 494 Length: 11 Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 e3: stand: Start: 0 @@ -263,6 +269,9 @@ e3: Start: 382 Length: 11 Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 e4: stand: Start: 0 @@ -343,11 +352,13 @@ e4: Start: 494 Length: 10 Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 muzzle: flame Start: 0 Length: 13 Facings: 8 - e5: stand: Start: 0 @@ -428,11 +439,13 @@ e5: Start: 494 Length: 10 Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 muzzle: chem Start: 0 Length: 13 Facings: 8 - e6: stand: Start: 0 @@ -505,7 +518,9 @@ e6: Start: 130 Length: 4 Tick: 80 - + die-crushed: squish + Start: 0 + Length: 1 rmbo: stand: Start: 0 @@ -589,4 +604,7 @@ rmbo: die6: Start: 308 Length: 4 - Tick: 80 \ No newline at end of file + Tick: 80 + die-crushed: squish + Start: 0 + Length: 1 \ No newline at end of file