Adapt SpreadDamageWH to ImpactOrientation

The ImpactOrientation needs to be computed from
point of impact to target if the target wasn't hit directly.

Also adapted warhead code to use WarheadArgs consistently,
as well as pass HitShape instead of just HitShapeInfo
(both needed for future and/or downstream features).
This commit is contained in:
reaperrr
2020-04-22 00:24:04 +02:00
committed by teinarss
parent 8513a83331
commit baf58f53b3

View File

@@ -87,9 +87,21 @@ namespace OpenRA.Mods.Common.Warheads
continue;
var localModifiers = args.DamageModifiers.Append(GetDamageFalloff(falloffDistance));
var impactOrientation = args.ImpactOrientation;
// If a warhead lands outside the victim's HitShape, we need to calculate the vertical and horizontal impact angles
// from impact position, rather than last projectile facing/angle.
if (falloffDistance > 0)
{
var towardsTargetYaw = (victim.CenterPosition - args.ImpactPosition).Yaw;
var impactAngle = Util.GetVerticalAngle(args.ImpactPosition, victim.CenterPosition);
impactOrientation = new WRot(WAngle.Zero, impactAngle, towardsTargetYaw);
}
var updatedWarheadArgs = new WarheadArgs(args)
{
DamageModifiers = localModifiers.ToArray(),
ImpactOrientation = impactOrientation,
};
InflictDamage(victim, firedBy, closestActiveShape.First, updatedWarheadArgs);