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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user