From ca0d993c1a36f15d3ce0ca0a5041a22746edc78b Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 2 Apr 2010 16:03:24 +1300 Subject: [PATCH] add radius to Selectable, used to adjust distance for damage calculation --- OpenRA.Game/Combat.cs | 4 +++- OpenRA.Game/Traits/Selectable.cs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Combat.cs b/OpenRA.Game/Combat.cs index a04b6d1eb1..5c2de3bb14 100644 --- a/OpenRA.Game/Combat.cs +++ b/OpenRA.Game/Combat.cs @@ -116,7 +116,9 @@ namespace OpenRA static float GetDamageToInflict(Actor target, ProjectileArgs args, WarheadInfo warhead, float modifier) { - var distance = (target.CenterLocation - args.dest).Length; + var selectable = target.Info.Traits.GetOrDefault(); + var radius = selectable != null ? selectable.Radius : 0; + var distance = Math.Max(0, (target.CenterLocation - args.dest).Length - radius); var rawDamage = warhead.Damage * modifier * (float)Math.Exp(-distance / warhead.Spread); var multiplier = warhead.EffectivenessAgainst(target.Info.Traits.Get().Armor); return rawDamage * multiplier; diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index d836a7502c..ea69959b64 100755 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -25,6 +25,7 @@ namespace OpenRA.Traits public readonly int Priority = 10; public readonly int[] Bounds = null; public readonly string Voice = "GenericVoice"; + public readonly float Radius = 10; } public class Selectable {}