AT and AP mine traits

This commit is contained in:
Paul Chote
2009-12-23 03:49:49 -08:00
parent eae88e7774
commit a9010d1947
8 changed files with 113 additions and 2 deletions

View File

@@ -239,6 +239,14 @@ namespace OpenRa.Game
{
return IsActorCrushableByMovementType(a, b.traits.WithInterface<IMovement>().FirstOrDefault().GetMovementType());
}
public static bool IsActorPathableToCrush(Actor a, UnitMovementType umt)
{
return a != null &&
a.traits.WithInterface<ICrushable>()
.Any(c => c.IsPathableCrush(umt, a.Owner));
}
public static bool IsActorCrushableByMovementType(Actor a, UnitMovementType umt)
{
return a != null &&

View File

@@ -162,6 +162,8 @@
<Compile Include="Traits\Activities\Move.cs" />
<Compile Include="Traits\Activities\Follow.cs" />
<Compile Include="Traits\Activities\Turn.cs" />
<Compile Include="Traits\APMine.cs" />
<Compile Include="Traits\ATMine.cs" />
<Compile Include="Traits\AttackBase.cs" />
<Compile Include="Traits\AttackInfo.cs" />
<Compile Include="Traits\AttackTurreted.cs" />

View File

@@ -56,7 +56,7 @@ namespace OpenRa.Game
}
// Replicate real-ra behavior of not being able to enter a cell if there is a mixture of crushable and uncrushable units
if (checkForBlocked && (Game.UnitInfluence.GetUnitsAt(newHere).Any(a => !Game.IsActorCrushableByMovementType(a, umt))))
if (checkForBlocked && (Game.UnitInfluence.GetUnitsAt(newHere).Any(a => !Game.IsActorPathableToCrush(a, umt))))
continue;
if (customBlock != null && customBlock(newHere))

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRa.Game.GameRules;
using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits
{
class APMine : ICrushable
{
readonly Actor self;
public APMine(Actor self)
{
this.self = self;
}
public void OnCrush(Actor crusher)
{
Game.world.AddFrameEndTask(_ =>
{
Game.world.Remove(self);
Game.world.Add(new Explosion(self.CenterLocation.ToInt2(), 5, false));
crusher.InflictDamage(crusher, Rules.General.APMineDamage, Rules.WarheadInfo["APMine"]);
});
}
public bool IsPathableCrush(UnitMovementType umt, Player player)
{
return (player != Game.LocalPlayer); // Units should avoid friendly mines
}
public bool IsCrushableBy(UnitMovementType umt, Player player)
{
// Mines should explode indiscriminantly of player
switch (umt)
{
case UnitMovementType.Foot: return true;
default: return false;
}
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRa.Game.GameRules;
using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits
{
class ATMine : ICrushable
{
readonly Actor self;
public ATMine(Actor self)
{
this.self = self;
}
public void OnCrush(Actor crusher)
{
Game.world.AddFrameEndTask(_ =>
{
Game.world.Remove(self);
Game.world.Add(new Explosion(self.CenterLocation.ToInt2(), 3, false));
crusher.InflictDamage(crusher, Rules.General.AVMineDamage, Rules.WarheadInfo["ATMine"]);
});
}
public bool IsPathableCrush(UnitMovementType umt, Player player)
{
return (player != Game.LocalPlayer); // Units should avoid friendly mines
}
public bool IsCrushableBy(UnitMovementType umt, Player player)
{
// Mines should explode indiscriminantly of player
switch (umt)
{
case UnitMovementType.Wheel:
case UnitMovementType.Track: return true;
default: return false;
}
}
}
}

View File

@@ -17,7 +17,12 @@ namespace OpenRa.Game.Traits
{
self.InflictDamage(crusher, self.Health, Rules.WarheadInfo["Crush"]);
}
public bool IsPathableCrush(UnitMovementType umt, Player player)
{
return IsCrushableBy(umt, player);
}
public bool IsCrushableBy(UnitMovementType umt, Player player)
{
if (player == Game.LocalPlayer) return false;

View File

@@ -63,5 +63,6 @@ namespace OpenRa.Game.Traits
{
void OnCrush(Actor crusher);
bool IsCrushableBy(UnitMovementType umt, Player player);
bool IsPathableCrush(UnitMovementType umt, Player player);
}
}

View File

@@ -658,6 +658,8 @@ Organic
Nuke
UnitExplodeWarhead
Crush
APMine
ATMine
[HE]
ImpactSound=kaboom25
@@ -674,6 +676,15 @@ ImpactSound=kaboom15
Verses=100%,100%,100%,100%,100%
ImpactSound=squishy2
[ATMine]
Verses=0%,0%,100%,100%,0%
ImpactSound=mineblo1
[APMine]
Verses=100%,0%,0%,0%,0%
ImpactSound=mine1
InfDeath=2
[General]
OreChance=.02
LowPowerSlowdown=3