From 9fa9ec6b5aea30e506ff5ca42f80a9bfa65a70c6 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 1 Apr 2010 22:04:22 +1300 Subject: [PATCH] added list of valid target categories to WeaponInfo --- OpenRA.Game/Combat.cs | 20 +++++++------------- OpenRA.Game/GameRules/WeaponInfo.cs | 1 + 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/OpenRA.Game/Combat.cs b/OpenRA.Game/Combat.cs index 07cefee7c7..cbb70cd0f3 100644 --- a/OpenRA.Game/Combat.cs +++ b/OpenRA.Game/Combat.cs @@ -109,25 +109,19 @@ namespace OpenRA public static bool WeaponValidForTarget(WeaponInfo weapon, Actor target) { - return true; // massive hack, and very wrong. - - /*var projectile = Rules.ProjectileInfo[weapon.Projectile]; - var warhead = Rules.WarheadInfo[weapon.Warhead]; var unit = target.traits.GetOrDefault(); - if (warhead.EffectivenessAgainst(target.Info.Traits.Get().Armor) <= 0) + if (!weapon.ValidTargets.Contains(target.Info.Category)) return false; - if (target.traits.Contains()) - return projectile.ASW; - - if (unit != null && unit.Altitude > 0) - return projectile.AA; - - if (projectile.UnderWater && !target.Info.Traits.Get().WaterBound) + if (weapon.Warheads.All( w => w.EffectivenessAgainst(target.Info.Traits.Get().Armor) <= 0)) return false; - return projectile.AG;*/ + /* todo: access to UnderWater is interesting */ +// if (projectile.UnderWater && !target.Info.Traits.Get().WaterBound) +// return false; + + return true; } public static bool HasAnyValidWeapons(Actor self, Actor target) diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index dd6a81b594..d1ac12186a 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -81,6 +81,7 @@ namespace OpenRA.GameRules public readonly int ROF = 1; public readonly int Burst = 1; public readonly bool Charges = false; + public readonly string[] ValidTargets = { "Vehicle", "Infantry" }; public IProjectileInfo Projectile; public List Warheads = new List();