Add crush check and move crush effect into a custom warhead
This commit is contained in:
@@ -7,7 +7,11 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
class Infantry : ICrushable
|
class Infantry : ICrushable
|
||||||
{
|
{
|
||||||
public Infantry(Actor self){}
|
readonly Actor self;
|
||||||
|
public Infantry(Actor self)
|
||||||
|
{
|
||||||
|
this.self = self;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsCrushableByFriend()
|
public bool IsCrushableByFriend()
|
||||||
{
|
{
|
||||||
@@ -22,7 +26,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
{
|
{
|
||||||
Sound.Play("squishy2.aud");
|
self.InflictDamage(crusher, self.Health, Rules.WarheadInfo["Crush"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<UnitMovementType> CrushableBy()
|
public IEnumerable<UnitMovementType> CrushableBy()
|
||||||
|
|||||||
@@ -22,6 +22,29 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
|
// Does this belong here?
|
||||||
|
|
||||||
|
// Get the crushable actors
|
||||||
|
foreach (var a in Game.world.Actors.Where(b => b.traits.WithInterface<ICrushable>().Any()))
|
||||||
|
{
|
||||||
|
// Are there any units in the same cell that can crush this?
|
||||||
|
foreach( var ios in a.traits.WithInterface<IOccupySpace>() )
|
||||||
|
foreach( var cell in ios.OccupiedCells() )
|
||||||
|
{
|
||||||
|
// There should only be one (counterexample: An infantry and a tank try to pick up a crate at the same time.)
|
||||||
|
// If there is more than one, do action on the first crusher
|
||||||
|
var crusher = GetUnitsAt(cell).Where(b => a != b && Game.IsActorCrushableByActor(a, b)).FirstOrDefault();
|
||||||
|
if (crusher != null)
|
||||||
|
{
|
||||||
|
Log.Write("{0} crushes {1}", crusher.Info.Name, a.Info.Name);
|
||||||
|
// Apply the crush action
|
||||||
|
foreach (var crush in a.traits.WithInterface<ICrushable>())
|
||||||
|
{
|
||||||
|
crush.OnCrush(crusher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
SanityCheck();
|
SanityCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -657,6 +657,7 @@ Super
|
|||||||
Organic
|
Organic
|
||||||
Nuke
|
Nuke
|
||||||
UnitExplodeWarhead
|
UnitExplodeWarhead
|
||||||
|
Crush
|
||||||
|
|
||||||
[HE]
|
[HE]
|
||||||
ImpactSound=kaboom25
|
ImpactSound=kaboom25
|
||||||
@@ -669,6 +670,10 @@ Explosion=8
|
|||||||
InfDeath=3
|
InfDeath=3
|
||||||
ImpactSound=kaboom15
|
ImpactSound=kaboom15
|
||||||
|
|
||||||
|
[Crush]
|
||||||
|
Verses=100%,100%,100%,100%,100%
|
||||||
|
ImpactSound=squishy2
|
||||||
|
|
||||||
[General]
|
[General]
|
||||||
OreChance=.02
|
OreChance=.02
|
||||||
LowPowerSlowdown=3
|
LowPowerSlowdown=3
|
||||||
|
|||||||
Reference in New Issue
Block a user