diff --git a/src/playsim/p_pspr.cpp b/src/playsim/p_pspr.cpp index b5ecf78f05..dac435ae3f 100644 --- a/src/playsim/p_pspr.cpp +++ b/src/playsim/p_pspr.cpp @@ -670,6 +670,7 @@ enum WOFFlags WOF_ADD = 1 << 2, WOF_INTERPOLATE = 1 << 3, WOF_RELATIVE = 1 << 4, + WOF_ZEROY = 1 << 5, }; DEFINE_ACTION_FUNCTION(AActor, A_OverlayScale) @@ -680,7 +681,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_OverlayScale) PARAM_FLOAT(wy) PARAM_INT(flags) - if (!ACTION_CALL_FROM_PSPRITE()) + if (!ACTION_CALL_FROM_PSPRITE() || ((flags & WOF_KEEPX) && (flags & WOF_KEEPY))) return 0; DPSprite *pspr = self->player->FindPSprite(((layer != 0) ? layer : stateinfo->mPSPIndex)); @@ -688,20 +689,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_OverlayScale) if (pspr == nullptr) return 0; - if (flags & WOF_ADD) - { - if (!(flags & WOF_KEEPX)) - pspr->scalex += wx; - if (!(flags & WOF_KEEPY)) - pspr->scaley += (wy != 0.0 ? wy : wx); - } - else - { - if (!(flags & WOF_KEEPX)) - pspr->scalex = wx; - if (!(flags & WOF_KEEPY)) - pspr->scaley = (wy != 0.0 ? wy : wx); - } + if (!(flags & WOF_ZEROY) && wy == 0.0) + wy = wx; + + if (!(flags & WOF_KEEPX)) + pspr->scalex = (flags & WOF_ADD) ? pspr->scalex + wx : wx; + if (!(flags & WOF_KEEPY)) + pspr->scaley = (flags & WOF_ADD) ? pspr->scaley + wy : wy; if (!(flags & WOF_INTERPOLATE)) { @@ -755,7 +749,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_OverlayPivot) PARAM_FLOAT(wy) PARAM_INT(flags) - if (!ACTION_CALL_FROM_PSPRITE()) + if (!ACTION_CALL_FROM_PSPRITE() || ((flags & WOF_KEEPX) && (flags & WOF_KEEPY))) return 0; DPSprite *pspr = self->player->FindPSprite(((layer != 0) ? layer : stateinfo->mPSPIndex)); @@ -763,21 +757,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_OverlayPivot) if (pspr == nullptr) return 0; - if (flags & WOF_ADD) + if (flags & WOF_RELATIVE) { - if (!(flags & WOF_KEEPX)) - pspr->px += wx; - if (!(flags & WOF_KEEPY)) - pspr->py += (wy != 0.0 ? wy : wx); - } - else - { - if (!(flags & WOF_KEEPX)) - pspr->px = wx; - if (!(flags & WOF_KEEPY)) - pspr->py = (wy != 0.0 ? wy : wx); + DAngle rot = pspr->rotation; + double c = rot.Cos(), s = rot.Sin(); + double nx = wx * c + wy * s; + double ny = wx * s - wy * c; + wx = nx; wy = ny; } + if (!(flags & WOF_KEEPX)) + pspr->px = (flags & WOF_ADD) ? pspr->px + wx : wx; + if (!(flags & WOF_KEEPY)) + pspr->py = (flags & WOF_ADD) ? pspr->py + wy : wy; + if (!(flags & WOF_INTERPOLATE)) { pspr->oldpx = pspr->px; diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index dd13c6ad8c..e36c30b7eb 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -489,7 +489,9 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, // Big thanks to IvanDobrovski who helped me modify this. if (psp->rotation != 0.0 || psp->scalex != 1.0 || psp->scaley != 1.0) { - float radang = psp->rotation * (pi::pi() / 180.); + FAngle rot = (float)psp->rotation; + rot.Normalized360(); + float radang = rot.Radians(); float cosang = cos(radang); float sinang = sin(radang); diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index 215d53b17b..c391832da3 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -695,6 +695,7 @@ enum EWeaponOffsetFlags WOF_ADD = 1 << 2, WOF_INTERPOLATE = 1 << 3, WOF_RELATIVE = 1 << 4, + WOF_ZEROY = 1 << 5, }; // Flags for psprite layers