Make warheads use the the most sensible victim scan radius
By default, but allow custom overrides.
This commit is contained in:
@@ -10,13 +10,14 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Warheads
|
namespace OpenRA.Mods.Common.Warheads
|
||||||
{
|
{
|
||||||
public class CreateEffectWarhead : Warhead
|
public class CreateEffectWarhead : Warhead, IRulesetLoaded<WeaponInfo>
|
||||||
{
|
{
|
||||||
[Desc("List of explosion sequences that can be used.")]
|
[Desc("List of explosion sequences that can be used.")]
|
||||||
[SequenceReference("Image")] public readonly string[] Explosions = new string[0];
|
[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.")]
|
[Desc("Remap explosion effect to player color, if art supports it.")]
|
||||||
public readonly bool UsePlayerPalette = false;
|
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.")]
|
[Desc("List of sounds that can be played on impact.")]
|
||||||
public readonly string[] ImpactSounds = new string[0];
|
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.")]
|
[Desc("What impact types should this effect NOT apply to.", "Overrides ValidImpactTypes.")]
|
||||||
public readonly ImpactType InvalidImpactTypes = ImpactType.None;
|
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)
|
public ImpactType GetImpactType(World world, CPos cell, WPos pos, Actor firedBy)
|
||||||
{
|
{
|
||||||
// Missiles need a margin because they sometimes explode a little above ground
|
// 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)
|
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))
|
if (checkTargetType && !IsValidAgainst(victim, firedBy))
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -21,17 +21,21 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
[Desc("Range between falloff steps.")]
|
[Desc("Range between falloff steps.")]
|
||||||
public readonly WDist Spread = new WDist(43);
|
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")]
|
[Desc("Damage percentage at each range step")]
|
||||||
public readonly int[] Falloff = { 100, 37, 14, 5, 0 };
|
public readonly int[] Falloff = { 100, 37, 14, 5, 0 };
|
||||||
|
|
||||||
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
|
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
|
||||||
public WDist[] Range = null;
|
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)
|
public void RulesetLoaded(Ruleset rules, WeaponInfo info)
|
||||||
{
|
{
|
||||||
|
if (VictimScanRadius == WDist.Zero)
|
||||||
|
VictimScanRadius = Util.MinimumRequiredVictimScanRadius(rules);
|
||||||
|
|
||||||
if (Range != null)
|
if (Range != null)
|
||||||
{
|
{
|
||||||
if (Range.Length != 1 && Range.Length != Falloff.Length)
|
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,
|
// 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
|
// 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)
|
foreach (var victim in hitActors)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user