Make projectiles use most sensible blocker scan radius

By default, but allow custom overrides.
This commit is contained in:
reaperrr
2017-01-20 15:20:35 +01:00
committed by Chris Forbes
parent 9f9d1f9e5f
commit 033268a7ba
5 changed files with 77 additions and 28 deletions

View File

@@ -22,7 +22,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Projectiles
{
[Desc("Not a sprite, but an engine effect.")]
public class LaserZapInfo : IProjectileInfo
public class LaserZapInfo : IProjectileInfo, IRulesetLoaded<WeaponInfo>
{
[Desc("The width of the zap.")]
public readonly WDist Width = new WDist(86);
@@ -46,9 +46,6 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Maximum offset at the maximum range.")]
public readonly WDist Inaccuracy = WDist.Zero;
[Desc("Extra search radius beyond beam width. Required to ensure affecting actors with large health radius.")]
public readonly WDist TargetExtraSearchRadius = new WDist(1536);
[Desc("Beam can be blocked.")]
public readonly bool Blockable = false;
@@ -77,11 +74,21 @@ namespace OpenRA.Mods.Common.Projectiles
[PaletteReference] public readonly string HitAnimPalette = "effect";
[Desc("Scan radius for actors with projectile-blocking trait. If set to zero (default), it will automatically scale",
"to the blocker with the largest health shape. Only set custom values if you know what you're doing.")]
public WDist BlockerScanRadius = WDist.Zero;
public IProjectile Create(ProjectileArgs args)
{
var c = UsePlayerColor ? args.SourceActor.Owner.Color.RGB : Color;
return new LaserZap(this, args, c);
}
public void RulesetLoaded(Ruleset rules, WeaponInfo wi)
{
if (BlockerScanRadius == WDist.Zero)
BlockerScanRadius = Util.MinimumRequiredBlockerScanRadius(rules);
}
}
public class LaserZap : IProjectile, ISync
@@ -126,7 +133,7 @@ namespace OpenRA.Mods.Common.Projectiles
// Check for blocking actors
WPos blockedPos;
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, source, target,
info.Width, info.TargetExtraSearchRadius, out blockedPos))
info.Width, info.BlockerScanRadius, out blockedPos))
{
target = blockedPos;
}