diff --git a/src/actor.h b/src/actor.h index 25669dfec..12bb4dc28 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1540,6 +1540,7 @@ struct FTranslatedLineTarget { AActor *linetarget; DAngle angleFromSource; + DAngle attackAngleFromSource; bool unlinked; // found by a trace that went through an unlinked portal. }; diff --git a/src/p_map.cpp b/src/p_map.cpp index 8cbe38f0e..16a5933d5 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -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; } } diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index c19925899..147b23e4e 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -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); diff --git a/wadsrc/static/zscript/hexen/baseweapons.txt b/wadsrc/static/zscript/hexen/baseweapons.txt index a1e1af9bd..f08794648 100644 --- a/wadsrc/static/zscript/hexen/baseweapons.txt +++ b/wadsrc/static/zscript/hexen/baseweapons.txt @@ -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) diff --git a/wadsrc/static/zscript/hexen/fighteraxe.txt b/wadsrc/static/zscript/hexen/fighteraxe.txt index a0d1deba1..1ff44a52f 100644 --- a/wadsrc/static/zscript/hexen/fighteraxe.txt +++ b/wadsrc/static/zscript/hexen/fighteraxe.txt @@ -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); diff --git a/wadsrc/static/zscript/hexen/fighterfist.txt b/wadsrc/static/zscript/hexen/fighterfist.txt index 712055e6e..289822789 100644 --- a/wadsrc/static/zscript/hexen/fighterfist.txt +++ b/wadsrc/static/zscript/hexen/fighterfist.txt @@ -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; diff --git a/wadsrc/static/zscript/hexen/fighterhammer.txt b/wadsrc/static/zscript/hexen/fighterhammer.txt index 655e59379..f1b06b75c 100644 --- a/wadsrc/static/zscript/hexen/fighterhammer.txt +++ b/wadsrc/static/zscript/hexen/fighterhammer.txt @@ -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;