diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index 55007f65d8..d33e4b3997 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -10,13 +10,14 @@ #endregion using System.Collections.Generic; +using OpenRA.GameRules; using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Traits; using OpenRA.Traits; namespace OpenRA.Mods.Common.Warheads { - public class CreateEffectWarhead : Warhead + public class CreateEffectWarhead : Warhead, IRulesetLoaded { [Desc("List of explosion sequences that can be used.")] [SequenceReference("Image")] public readonly string[] Explosions = new string[0]; @@ -30,9 +31,6 @@ namespace OpenRA.Mods.Common.Warheads [Desc("Remap explosion effect to player color, if art supports it.")] public readonly bool UsePlayerPalette = false; - [Desc("Search radius around impact for 'direct hit' check.")] - public readonly WDist TargetSearchRadius = new WDist(2048); - [Desc("List of sounds that can be played on impact.")] public readonly string[] ImpactSounds = new string[0]; @@ -42,6 +40,16 @@ namespace OpenRA.Mods.Common.Warheads [Desc("What impact types should this effect NOT apply to.", "Overrides ValidImpactTypes.")] public readonly ImpactType InvalidImpactTypes = ImpactType.None; + [Desc("Scan radius for victims around impact. If set to zero (default), it will automatically scale to the largest health shape.", + "Custom overrides should not be necessary under normal circumstances.")] + public WDist VictimScanRadius = WDist.Zero; + + public void RulesetLoaded(Ruleset rules, WeaponInfo wi) + { + if (VictimScanRadius == WDist.Zero) + VictimScanRadius = Util.MinimumRequiredVictimScanRadius(rules); + } + public ImpactType GetImpactType(World world, CPos cell, WPos pos, Actor firedBy) { // Missiles need a margin because they sometimes explode a little above ground @@ -75,7 +83,7 @@ namespace OpenRA.Mods.Common.Warheads public bool GetDirectHit(World world, CPos cell, WPos pos, Actor firedBy, bool checkTargetType = false) { - foreach (var victim in world.FindActorsInCircle(pos, TargetSearchRadius)) + foreach (var victim in world.FindActorsInCircle(pos, VictimScanRadius)) { if (checkTargetType && !IsValidAgainst(victim, firedBy)) continue; diff --git a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs index 5c8f14b944..f4c4c0e6d0 100644 --- a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs @@ -21,17 +21,21 @@ 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(1536); - [Desc("Damage percentage at each range step")] public readonly int[] Falloff = { 100, 37, 14, 5, 0 }; [Desc("Ranges at which each Falloff step is defined. Overrides Spread.")] public WDist[] Range = null; + [Desc("Extra search radius beyond maximum spread. If set to zero (default), it will automatically scale to the largest health shape.", + "Custom overrides should not be necessary under normal circumstances.")] + public WDist VictimScanRadius = WDist.Zero; + public void RulesetLoaded(Ruleset rules, WeaponInfo info) { + if (VictimScanRadius == WDist.Zero) + VictimScanRadius = Util.MinimumRequiredVictimScanRadius(rules); + if (Range != null) { if (Range.Length != 1 && Range.Length != Falloff.Length) @@ -58,7 +62,7 @@ namespace OpenRA.Mods.Common.Warheads // 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); + var hitActors = world.FindActorsInCircle(pos, Range[Range.Length - 1] + VictimScanRadius); foreach (var victim in hitActors) {