- fixed: FTranslatedLineTarget::angleFromSource returned the attack angle, not the angle between actors when returned from P_LineAttack.

For most attack functions this is wrong, it's only the Hexen fighter attack needing this particular value, so it has been split up into two return values now.
This commit is contained in:
Christoph Oelckers 2016-12-06 11:04:54 +01:00
parent daaa6e7831
commit b2d1b0d7a6
7 changed files with 10 additions and 9 deletions

View File

@ -1540,6 +1540,7 @@ struct FTranslatedLineTarget
{
AActor *linetarget;
DAngle angleFromSource;
DAngle attackAngleFromSource;
bool unlinked; // found by a trace that went through an unlinked portal.
};

View File

@ -3588,6 +3588,7 @@ struct aim_t
res.linetarget = th;
res.pitch = pitch;
res.angleFromSource = (th->Pos() - startpos).Angle();
res.attackAngleFromSource = res.angleFromSource; // at this point we do not have an attack angle so it's the same as the actual angle between actors.
res.unlinked = unlinked;
res.frac = frac;
}
@ -4506,7 +4507,9 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
if (victim != NULL)
{
victim->linetarget = trace.Actor;
victim->angleFromSource = trace.SrcAngleFromTarget;
victim->attackAngleFromSource = trace.SrcAngleFromTarget;
// With arbitrary portals this cannot be calculated so using the actual attack angle is the only option.
victim->angleFromSource = trace.unlinked? victim->attackAngleFromSource : t1->AngleTo(trace.Actor);
victim->unlinked = trace.unlinked;
}
}

View File

@ -846,6 +846,7 @@ struct FTranslatedLineTarget
{
Actor linetarget;
double angleFromSource;
double attackAngleFromSource;
bool unlinked; // found by a trace that went through an unlinked portal.
native void TraceBleed(int damage, Actor missile);

View File

@ -40,11 +40,7 @@ extend class Actor
void AdjustPlayerAngle(FTranslatedLineTarget t)
{
// normally this will adjust relative to the actual direction to the target,
// but with arbitrary portals that cannot be calculated so using the actual
// attack angle is the only option.
double atkangle = t.unlinked ? t.angleFromSource : AngleTo(t.linetarget);
double difference = deltaangle(Angle, atkangle);
double difference = t.angleFromSource;
if (abs(difference) > MAX_ANGLE_ADJUST)
{
if (difference > 0)

View File

@ -253,7 +253,7 @@ class FWeapAxe : FighterWeapon
{
if (t.linetarget.bIsMonster || t.linetarget.player)
{
t.linetarget.Thrust(power, t.angleFromSource);
t.linetarget.Thrust(power, t.attackAngleFromSource);
}
AdjustPlayerAngle(t);

View File

@ -77,7 +77,7 @@ class FWeapFist : FighterWeapon
(t.linetarget.Mass < 10000000 && (t.linetarget.bIsMonster)))
{
if (!t.linetarget.bDontThrust)
t.linetarget.Thrust(power, t.angleFromSource);
t.linetarget.Thrust(power, t.attackAngleFromSource);
}
AdjustPlayerAngle(t);
return true;

View File

@ -80,7 +80,7 @@ class FWeapHammer : FighterWeapon
AdjustPlayerAngle(t);
if (t.linetarget.bIsMonster || t.linetarget.player)
{
t.linetarget.Thrust(10, t.angleFromSource);
t.linetarget.Thrust(10, t.attackAngleFromSource);
}
weaponspecial = false; // Don't throw a hammer
return;