From 74da2a2c7248d86cda953d17f91238544216adad Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 26 Aug 2015 22:20:30 +0200 Subject: [PATCH 1/3] Add TargetExtraSearchRadius to SpreadDamageWarhead Allows to customize the victim scan radius. Necessary to ensure that actors where health radius is close enough, but CenterPosition isn't, properly receive damage. --- OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs index 53c3946f1d..6a0e11255e 100644 --- a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs @@ -19,6 +19,9 @@ namespace OpenRA.Mods.Common.Warheads [Desc("Range between falloff steps.")] public readonly WDist Spread = new WDist(43); + [Desc("Extra search radius beyond maximum spread. Required to ensure damage to actors with large health radius.")] + public readonly WDist TargetExtraSearchRadius = new WDist(2048); + [Desc("Damage percentage at each range step")] public readonly int[] Falloff = { 100, 37, 14, 5, 2, 1, 0 }; @@ -46,7 +49,10 @@ namespace OpenRA.Mods.Common.Warheads InitializeRange(); var world = firedBy.World; - var hitActors = world.FindActorsInCircle(pos, Range[Range.Length - 1]); + + // This only finds actors where the center is within the search radius, + // so we need to search beyond the maximum spread to account for actors with large health radius + var hitActors = world.FindActorsInCircle(pos, Range[Range.Length - 1] + TargetExtraSearchRadius); foreach (var victim in hitActors) { From 33dc50d29cd8935131632648ac07412ca07ec76e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 11 Sep 2015 19:28:42 +0200 Subject: [PATCH 2/3] Fix Bullet to consider DistanceAboveTerrain --- OpenRA.Mods.Common/Effects/Bullet.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Effects/Bullet.cs b/OpenRA.Mods.Common/Effects/Bullet.cs index ac65568ad7..7df3fec900 100644 --- a/OpenRA.Mods.Common/Effects/Bullet.cs +++ b/OpenRA.Mods.Common/Effects/Bullet.cs @@ -164,8 +164,14 @@ namespace OpenRA.Mods.Common.Effects if (info.ContrailLength > 0) contrail.Update(pos); - if (ticks++ >= length || (info.Blockable && world.ActorMap - .GetUnitsAt(world.Map.CellContaining(pos)).Any(a => a.Info.HasTraitInfo()))) + var cell = world.Map.CellContaining(pos); + var height = world.Map.DistanceAboveTerrain(pos); + + var shouldExplode = height.Length <= 0 // Hit the ground + || ticks++ >= length // Flight length reached/exceeded + || (info.Blockable && world.ActorMap.GetUnitsAt(cell).Any(a => a.Info.HasTraitInfo())); // Hit a wall or other blocking obstacle + + if (shouldExplode) Explode(world); } From 4c41f8f65608cd1a4455dad159f77b9df793fd2e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 11 Sep 2015 19:05:21 +0200 Subject: [PATCH 3/3] Lint check for SpreadDamageWarhead victim scan radius bonus --- .../Lint/CheckTargetHealthRadius.cs | 55 +++++++++++++++++++ OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + 2 files changed, 56 insertions(+) create mode 100644 OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs diff --git a/OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs b/OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs new file mode 100644 index 0000000000..e13081670e --- /dev/null +++ b/OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs @@ -0,0 +1,55 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Linq; +using OpenRA.Mods.Common.Traits; +using OpenRA.Mods.Common.Warheads; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Lint +{ + class CheckTargetHealthRadius : ILintRulesPass + { + public void Run(Action emitError, Action emitWarning, Ruleset rules) + { + foreach (var actorInfo in rules.Actors) + { + var healthTraits = actorInfo.Value.TraitInfos().ToList(); + if (!healthTraits.Any()) + continue; + + var targetable = actorInfo.Value.TraitInfos().SelectMany(x => x.GetTargetTypes()).ToList(); + if (!targetable.Any()) + continue; + + foreach (var weaponInfo in rules.Weapons) + { + var warheads = weaponInfo.Value.Warheads.OfType().Where(dw => dw.Damage > 0); + + foreach (var warhead in warheads) + { + // This is a special warhead, like the one on `weathering` in D2k. + if (!warhead.DamageTypes.Any()) + continue; + + // This warhead cannot affect this actor. + if (!warhead.ValidTargets.Overlaps(targetable)) + continue; + + if (healthTraits.Where(x => x.Radius.Length > warhead.TargetExtraSearchRadius.Length).Any()) + emitError("Actor type `{0}` has a health radius exceeding the victim scan radius of a warhead on `{1}`!" + .F(actorInfo.Key, weaponInfo.Key)); + } + } + } + } + } +} diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 8cd4b9ab44..e6e3568a65 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -191,6 +191,7 @@ +