much better sub behavior

This commit is contained in:
Chris Forbes
2009-12-13 13:32:19 +13:00
parent 5eb373790b
commit e4c9073884
7 changed files with 21 additions and 4 deletions

View File

@@ -56,9 +56,20 @@ namespace OpenRa.Game
{
var projectile = Rules.ProjectileInfo[weapon.Projectile];
if (projectile.ASW) return false; // we don't support ASW yet. change this when subs can be identified.
if (projectile.ASW && target.traits.Contains<RenderSubmarine>()) return true;
if (projectile.AA && target.traits.Contains<Helicopter>()) return true;
if (projectile.UnderWater && !target.Info.WaterBound) return false;
return projectile.AG;
}
public static bool HasAnyValidWeapons(Actor self, Actor target)
{
if (self.Info.Primary != null &&
WeaponValidForTarget(Rules.WeaponInfo[self.Info.Primary], target)) return true;
if (self.Info.Secondary != null &&
WeaponValidForTarget(Rules.WeaponInfo[self.Info.Secondary], target)) return true;
return false;
}
}
}

View File

@@ -80,7 +80,7 @@ namespace OpenRa.Game.Effects
yield return Tuple.New(anim.Image, highPos, Owner.Palette);
}
else
yield return Tuple.New(anim.Image, pos, Owner.Palette);
yield return Tuple.New(anim.Image, pos, Projectile.UnderWater ? 8 : Owner.Palette);
}
}
}

View File

@@ -129,6 +129,7 @@ namespace OpenRa.Game.Traits
{
if (lmb || underCursor == null) return null;
if (underCursor.Owner == self.Owner) return null;
if (!Combat.HasAnyValidWeapons(self, underCursor)) return null;
return Order.Attack(self, underCursor);
}

View File

@@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits
if (remainingSurfaceTime <= 0)
OnSurface();
remainingSurfaceTime = (int)(Rules.General.SubmergeDelay * 60 / 25);
remainingSurfaceTime = (int)(Rules.General.SubmergeDelay * 60 * 25);
}
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)

View File

@@ -652,4 +652,7 @@
<sequence name="run-6" start="44" length="6" />
<sequence name="run-7" start="50" length="6" />
</unit>
<unit name="missile">
<sequence name="idle" start="0" length="32" />
</unit>
</sequences>

View File

@@ -10,4 +10,5 @@ s2=Multi1,mcv,600,12505,0,Guard,None
s3=Multi3,mcv,600,2910,0,Guard,None
s4=Multi7,3tnk,600,13017,0,Guard,None
s5=Multi7,ca,600,13765,0,Guard,None

View File

@@ -94,7 +94,8 @@ PT
Description=Submarine
WaterBound=yes
BuiltAt=spen
Traits=Unit, Mobile, RenderSubmarine
Traits=Unit, Mobile, RenderSubmarine, AttackBase
FireDelay=2
[DD]
Description=Destroyer
WaterBound=yes