diff --git a/source/core/gameinput.h b/source/core/gameinput.h index f540ac1bd..6af32022e 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -111,10 +111,6 @@ struct PlayerAngles } } - // Miscellaneous helpers. - double angLOOKANGHALF(double const interpfrac) { return angLERPLOOKANG(interpfrac).Normalized180().Degrees() * (128. / 45.); } - double angLOOKINGARC(double const interpfrac) { return fabs(angLERPLOOKANG(interpfrac).Normalized180().Degrees() * (1024. / 1620.)); } - // Legacy, to be removed. DAngle horizSUM(const double interpfrac = 1) { return ZzHORIZON() + interpolatedvalue(PrevViewAngles.Pitch, ViewAngles.Pitch, interpfrac); } diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index 4bf63906c..6bd30438d 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -133,8 +133,10 @@ void displayweapon_r(int snum, double interpfrac) TiltStatus = p->TiltStatus; } - look_anghalf = p->Angles.angLOOKANGHALF(interpfrac); - looking_arc = p->Angles.angLOOKINGARC(interpfrac); + auto playerLook = interpolatedvalue(p->Angles.PrevViewAngles.Yaw, p->Angles.ViewAngles.Yaw, interpfrac); + + look_anghalf = playerLook.Normalized180().Degrees() * (128. / 45.); + looking_arc = fabs(playerLook.Normalized180().Degrees() * (1024. / 1620.)); hard_landing *= 8.; gun_pos -= fabs(p->GetActor()->spr.scale.X < 0.125 ? BobVal(weapon_sway * 4.) * 32 : BobVal(weapon_sway * 0.5) * 16); diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index 48ec4c5a8..044ac2296 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -1000,13 +1000,12 @@ void DrawWeapons(double interpfrac) nShade = PlayerList[nLocalPlayer].pActor->spr.shade; } - double const look_anghalf = PlayerList[nLocalPlayer].Angles.angLOOKANGHALF(interpfrac); - double const looking_arc = PlayerList[nLocalPlayer].Angles.angLOOKINGARC(interpfrac); + const auto weaponOffsets = PlayerList[nLocalPlayer].Angles.getWeaponOffsets(interpfrac); + const auto angle = -weaponOffsets.second; + xOffset += weaponOffsets.first.X; + yOffset += weaponOffsets.first.Y; - xOffset -= look_anghalf; - yOffset += looking_arc; - - seq_DrawGunSequence(var_28, PlayerList[nLocalPlayer].nSeqSize2, xOffset, yOffset, nShade, nPal, screenalign); + seq_DrawGunSequence(var_28, PlayerList[nLocalPlayer].nSeqSize2, xOffset, yOffset, nShade, nPal, angle, screenalign); if (nWeapon != kWeaponM60) return; @@ -1042,7 +1041,7 @@ void DrawWeapons(double interpfrac) nSeqOffset = var_30 + 4; } - seq_DrawGunSequence(nSeqOffset, PlayerList[nLocalPlayer].nSeqSize2, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(nSeqOffset, PlayerList[nLocalPlayer].nSeqSize2, xOffset, yOffset, nShade, nPal, angle); return; } case 1: @@ -1055,25 +1054,25 @@ void DrawWeapons(double interpfrac) return; } - seq_DrawGunSequence(var_30 + 8, edx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 8, edx, xOffset, yOffset, nShade, nPal, angle); if (nClip <= 3) { return; } - seq_DrawGunSequence(var_30 + 9, edx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 9, edx, xOffset, yOffset, nShade, nPal, angle); if (nClip <= 6) { return; } - seq_DrawGunSequence(var_30 + 10, edx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 10, edx, xOffset, yOffset, nShade, nPal, angle); if (nClip <= 25) { return; } - seq_DrawGunSequence(var_30 + 11, edx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 11, edx, xOffset, yOffset, nShade, nPal, angle); return; } case 2: @@ -1086,25 +1085,25 @@ void DrawWeapons(double interpfrac) return; } - seq_DrawGunSequence(var_30 + 8, dx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 8, dx, xOffset, yOffset, nShade, nPal, angle); if (nClip <= 3) { return; } - seq_DrawGunSequence(var_30 + 9, dx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 9, dx, xOffset, yOffset, nShade, nPal, angle); if (nClip <= 6) { return; } - seq_DrawGunSequence(var_30 + 10, dx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 10, dx, xOffset, yOffset, nShade, nPal, angle); if (nClip <= 25) { return; } - seq_DrawGunSequence(var_30 + 11, dx, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(var_30 + 11, dx, xOffset, yOffset, nShade, nPal, angle); return; } @@ -1141,7 +1140,7 @@ void DrawWeapons(double interpfrac) nSeqOffset = var_30 + 17; } - seq_DrawGunSequence(nSeqOffset, ax, xOffset, yOffset, nShade, nPal); + seq_DrawGunSequence(nSeqOffset, ax, xOffset, yOffset, nShade, nPal, angle); return; } } diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index b9dda1f84..b9a8a0c31 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -426,7 +426,7 @@ void seq_DrawPilotLightSeq(double xOffset, double yOffset) // //--------------------------------------------------------------------------- -int seq_DrawGunSequence(int nSeqOffset, int16_t dx, double xOffs, double yOffs, int nShade, int nPal, bool align) +int seq_DrawGunSequence(int nSeqOffset, int16_t dx, double xOffs, double yOffs, int nShade, int nPal, DAngle angle, bool align) { int nFrame = SeqBase[nSeqOffset] + dx; int nFrameBase = FrameBase[nFrame]; @@ -461,7 +461,7 @@ int seq_DrawGunSequence(int nSeqOffset, int16_t dx, double xOffs, double yOffs, alpha = 0.3; } - hud_drawsprite(x + xOffs, y + yOffs, 65536, 0, nTile, nShade, nPal, stat, alpha); + hud_drawsprite(x + xOffs, y + yOffs, 65536, angle.Buildfang(), nTile, nShade, nPal, stat, alpha); nFrameBase++; } diff --git a/source/games/exhumed/src/sequence.h b/source/games/exhumed/src/sequence.h index c3fa7acff..475781695 100644 --- a/source/games/exhumed/src/sequence.h +++ b/source/games/exhumed/src/sequence.h @@ -137,7 +137,7 @@ int seq_GetSeqPicnum2(int16_t nSeq, int16_t nFrame); int seq_GetSeqPicnum(int16_t nSeq, int16_t edx, int16_t ebx); void seq_DrawStatusSequence(int16_t nSequence, uint16_t edx, int16_t ebx); -int seq_DrawGunSequence(int nSeqOffset, int16_t dx, double xOffs, double yOffs, int nShade, int nPal, bool align = false); +int seq_DrawGunSequence(int nSeqOffset, int16_t dx, double xOffs, double yOffs, int nShade, int nPal, DAngle angle, bool align = false); int16_t seq_GetFrameFlag(int16_t val, int16_t nFrame); int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx); int seq_PlotArrowSequence(int nSprite, int16_t nSeq, int nVal);