Refactor handling of hit radii in projectiles.
penev discovered that the RulesetLoaded functions of projectiles were never being called, meaning that their blocking calculations were not properly accounting for actors with large hitboxes. The best fix for this is to change FindActorsOnLine to always account for the largest actor's hit radius, rather than forcing callers to pass the largest radius. Per the comment in Util.cs, as a result, move this computation to ActorMap. I decided to simplify by not making a separate calculation for actors that block projectiles only; this may cause a small performance degradation as the search space is a bit larger. Similarly to this, I've removed the ability to specify a search radius manually. Because this is only a search radius, setting a value smaller than the largest eligible actor makes no sense; that would lead to completely inconsistent blocking. Setting a larger value, on the other hand, would make no difference. CreateEffectWarhead was the only place in core code any of these search radii were set, and that's because 0 was a mysterious magic value that made the warhead incapable of hitting actors. I replaced it with a boolean flag that more clearly indicates the actual behaviour. Fixes #14151.
This commit is contained in:
@@ -90,29 +90,12 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[PaletteReference]
|
||||
public readonly string HitAnimPalette = "effect";
|
||||
|
||||
[Desc("Scan radius for actors damaged by beam. If set to zero (default), it will automatically scale to the largest health shape.",
|
||||
"Only set custom values if you know what you're doing.")]
|
||||
public WDist AreaVictimScanRadius = WDist.Zero;
|
||||
|
||||
[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 bc = BeamPlayerColor ? Color.FromArgb(BeamColor.A, args.SourceActor.Owner.Color.RGB) : BeamColor;
|
||||
var hc = HelixPlayerColor ? Color.FromArgb(HelixColor.A, args.SourceActor.Owner.Color.RGB) : HelixColor;
|
||||
return new Railgun(args, this, bc, hc);
|
||||
}
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, WeaponInfo wi)
|
||||
{
|
||||
if (BlockerScanRadius == WDist.Zero)
|
||||
BlockerScanRadius = Util.MinimumRequiredBlockerScanRadius(rules);
|
||||
|
||||
if (AreaVictimScanRadius == WDist.Zero)
|
||||
AreaVictimScanRadius = Util.MinimumRequiredVictimScanRadius(rules);
|
||||
}
|
||||
}
|
||||
|
||||
public class Railgun : IProjectile
|
||||
@@ -156,7 +139,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
// Check for blocking actors
|
||||
WPos blockedPos;
|
||||
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(args.SourceActor.World, target, args.Source,
|
||||
info.BeamWidth, info.BlockerScanRadius, out blockedPos))
|
||||
info.BeamWidth, out blockedPos))
|
||||
target = blockedPos;
|
||||
|
||||
// Note: WAngle.Sin(x) = 1024 * Math.Sin(2pi/1024 * x)
|
||||
@@ -205,7 +188,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
args.Weapon.Impact(Target.FromPos(target), args.SourceActor, args.DamageModifiers);
|
||||
else
|
||||
{
|
||||
var actors = world.FindActorsOnLine(args.Source, target, info.BeamWidth, info.AreaVictimScanRadius);
|
||||
var actors = world.FindActorsOnLine(args.Source, target, info.BeamWidth);
|
||||
foreach (var a in actors)
|
||||
args.Weapon.Impact(Target.FromActor(a), args.SourceActor, args.DamageModifiers);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user