Merge pull request #11192 from reaperrr/fix-effectwh
Fix direct hit check in CreateEffectWarhead
This commit is contained in:
@@ -47,7 +47,20 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (healthTraits.Where(x => x.Shape.OuterRadius.Length > warhead.TargetExtraSearchRadius.Length).Any())
|
if (healthTraits.Where(x => x.Shape.OuterRadius.Length > warhead.TargetExtraSearchRadius.Length).Any())
|
||||||
emitError("Actor type `{0}` has a health radius exceeding the victim scan radius of a warhead on `{1}`!"
|
emitError("Actor type `{0}` has a health radius exceeding the victim scan radius of a SpreadDamageWarhead on `{1}`!"
|
||||||
|
.F(actorInfo.Key, weaponInfo.Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
var effectWarheads = weaponInfo.Value.Warheads.OfType<CreateEffectWarhead>();
|
||||||
|
|
||||||
|
foreach (var warhead in effectWarheads)
|
||||||
|
{
|
||||||
|
// This warhead cannot affect this actor.
|
||||||
|
if (!warhead.ValidTargets.Overlaps(targetable))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (healthTraits.Where(x => x.Shape.OuterRadius.Length > warhead.TargetSearchRadius.Length).Any())
|
||||||
|
emitError("Actor type `{0}` has a health radius exceeding the victim scan radius of a CreateEffectWarhead on `{1}`!"
|
||||||
.F(actorInfo.Key, weaponInfo.Key));
|
.F(actorInfo.Key, weaponInfo.Key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ 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];
|
||||||
|
|
||||||
@@ -72,17 +75,17 @@ 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 unit in world.ActorMap.GetActorsAt(cell))
|
foreach (var victim in world.FindActorsInCircle(pos, TargetSearchRadius))
|
||||||
{
|
{
|
||||||
if (checkTargetType && !IsValidAgainst(unit, firedBy))
|
if (checkTargetType && !IsValidAgainst(victim, firedBy))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var healthInfo = unit.Info.TraitInfoOrDefault<HealthInfo>();
|
var healthInfo = victim.Info.TraitInfoOrDefault<HealthInfo>();
|
||||||
if (healthInfo == null)
|
if (healthInfo == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If the impact position is within any actor's HitShape, we have a direct hit
|
// If the impact position is within any actor's HitShape, we have a direct hit
|
||||||
if ((unit.CenterPosition - pos).LengthSquared <= healthInfo.Shape.DistanceFromEdge(pos, unit).LengthSquared)
|
if (healthInfo.Shape.DistanceFromEdge(pos, victim).Length <= 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user