Add crushable infantry support, enabled in C&C.
This commit is contained in:
60
OpenRA.Mods.RA/CrushableInfantry.cs
Normal file
60
OpenRA.Mods.RA/CrushableInfantry.cs
Normal file
@@ -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<MobileInfo>
|
||||
{
|
||||
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<Mobile>().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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,6 +352,7 @@
|
||||
<Compile Include="Render\WithBuildingExplosion.cs" />
|
||||
<Compile Include="Reloads.cs" />
|
||||
<Compile Include="AnnounceOnKill.cs" />
|
||||
<Compile Include="CrushableInfantry.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,6 +19,7 @@ E1:
|
||||
PrimaryWeapon: M16
|
||||
RenderInfantryProne:
|
||||
IdleAnimations: idle1,idle2,idle3,idle4
|
||||
|
||||
E2:
|
||||
Inherits: ^Infantry
|
||||
Valued:
|
||||
|
||||
@@ -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
|
||||
@@ -496,3 +515,6 @@ c10:
|
||||
Start: 182
|
||||
Length: 4
|
||||
Tick: 80
|
||||
die-crushed: squish
|
||||
Start: 0
|
||||
Length: 1
|
||||
@@ -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
|
||||
@@ -590,3 +605,6 @@ rmbo:
|
||||
Start: 308
|
||||
Length: 4
|
||||
Tick: 80
|
||||
die-crushed: squish
|
||||
Start: 0
|
||||
Length: 1
|
||||
Reference in New Issue
Block a user