From 598e9017b121ba0894bb97d3b50b3b4981bf0d14 Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 13 Aug 2019 20:11:44 +0100 Subject: [PATCH] Fix P_PlayerCanDamage for CA_FLY and CA_BOUNCE to be less lenient in causing damage, by making them based off the top and bottom of the player object respectively rather than its vertical center. --- src/p_user.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index b74cafd21..1bf906061 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1051,6 +1051,8 @@ void P_ResetPlayer(player_t *player) // boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) { + fixed_t bottomheight, topheight; + if (!player->mo || player->spectator || !thing || P_MobjWasRemoved(thing)) return false; @@ -1090,13 +1092,26 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) return true; // From the top/bottom. - if (P_MobjFlip(player->mo)*(player->mo->z - (thing->z + thing->height/2)) > 0) + bottomheight = player->mo->z; + topheight = player->mo->z + player->mo->height; + + if (player->mo->eflags & MFE_VERTICALFLIP) { - if ((player->charflags & SF_STOMPDAMAGE || player->pflags & PF_BOUNCING) && (P_MobjFlip(player->mo)*player->mo->momz < 0)) + fixed_t swap = bottomheight; + bottomheight = topheight; + topheight = swap; + } + + if (P_MobjFlip(player->mo)*(bottomheight - (thing->z + thing->height/2)) > 0) + { + if ((player->charflags & SF_STOMPDAMAGE || player->pflags & PF_BOUNCING) && (P_MobjFlip(player->mo)*(player->mo->momz - thing->momz) < 0)) + return true; + } + else if (P_MobjFlip(player->mo)*(topheight - (thing->z + thing->height/2)) < 0) + { + if (player->charability == CA_FLY && player->panim == PA_ABILITY && (P_MobjFlip(player->mo)*(player->mo->momz - thing->momz) > 0)) return true; } - else if (player->charability == CA_FLY && player->panim == PA_ABILITY) - return true; // Shield stomp. if (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL || (player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) && (player->pflags & PF_SHIELDABILITY))