From e4c9073884e552f3ee4f5616ac278baaec04a725 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 13 Dec 2009 13:32:19 +1300 Subject: [PATCH] much better sub behavior --- OpenRa.Game/Combat.cs | 13 ++++++++++++- OpenRa.Game/Effects/Bullet.cs | 2 +- OpenRa.Game/Traits/AttackBase.cs | 1 + OpenRa.Game/Traits/RenderSubmarine.cs | 2 +- sequences.xml | 3 +++ session.ini | 1 + units.ini | 3 ++- 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index 33365a4fc0..b487f2d3f5 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -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()) return true; if (projectile.AA && target.traits.Contains()) 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; + } } } diff --git a/OpenRa.Game/Effects/Bullet.cs b/OpenRa.Game/Effects/Bullet.cs index f5f72cebe5..ae930e97f6 100644 --- a/OpenRa.Game/Effects/Bullet.cs +++ b/OpenRa.Game/Effects/Bullet.cs @@ -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); } } } diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 815bf85337..8543574d0a 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -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); } diff --git a/OpenRa.Game/Traits/RenderSubmarine.cs b/OpenRa.Game/Traits/RenderSubmarine.cs index 73d0fd64c1..95804a4479 100644 --- a/OpenRa.Game/Traits/RenderSubmarine.cs +++ b/OpenRa.Game/Traits/RenderSubmarine.cs @@ -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> Render(Actor self) diff --git a/sequences.xml b/sequences.xml index a0bafed9f6..57931dcbf1 100644 --- a/sequences.xml +++ b/sequences.xml @@ -652,4 +652,7 @@ + + + \ No newline at end of file diff --git a/session.ini b/session.ini index 0139c33220..c4714e409f 100644 --- a/session.ini +++ b/session.ini @@ -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 diff --git a/units.ini b/units.ini index 6690292869..591401ee13 100755 --- a/units.ini +++ b/units.ini @@ -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