From 7eb80f3a6674fe41219dc0bb81c30c83d18528fe Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 19 Jun 2019 13:20:34 +0100 Subject: [PATCH] In order to make P_PlayerCanDamage more flexible, I ended up bundling the invincibility/super checks into there. Also, the start of my improvements to CA2_MELEE. Users of that abiliy can only damage enemies/monitors if they touch the front of the player object, but to make up for it, the player is no longer forced away from the direction of the screen at bigger movement speeds. --- src/p_inter.c | 3 +-- src/p_user.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 42722e6d1..4cbd9185c 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -453,8 +453,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) break; } - if (player->powers[pw_invulnerability] || player->powers[pw_super] - || P_PlayerCanDamage(player, special)) // Do you possess the ability to subdue the object? + if (P_PlayerCanDamage(player, special)) // Do you possess the ability to subdue the object? { if ((P_MobjFlip(toucher)*toucher->momz < 0) && (elementalpierce != 1)) { diff --git a/src/p_user.c b/src/p_user.c index 9a5d315a3..b879df48a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -980,7 +980,6 @@ void P_ResetPlayer(player_t *player) // P_PlayerCanDamage // // Can player do damage? -// Doesn't count invincibility or super, for the sake of monitors. // boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) { @@ -999,24 +998,35 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) } #endif + // Invinc/super. Not for Monitors. + if (!(thing->flags & MF_MONITOR) && (player->powers[pw_invulnerability] || player->powers[pw_super])) + return true; + + // NiGHTS drill. Wasn't originally for monitors, but that's more an oversight being corrected than anything else. if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (player->pflags & PF_DRILLING)) return true; + // Jumping. if ((player->pflags & PF_JUMPED) && (!(player->pflags & PF_NOJUMPDAMAGE) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) return true; - if (player->pflags & (PF_SPINNING|PF_GLIDING)) + // Spinning. + if (player->pflags & PF_SPINNING) return true; - if (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2) + // From the front. + if (((player->pflags & PF_GLIDING) || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) + && (player->drawangle - R_PointToAngle2(player->mo->x - player->mo->momx, player->mo->y - player->mo->momy, thing->x, thing->y) + + ANGLE_90) < ANGLE_180) return true; + // From the top. if ((player->charflags & SF_STOMPDAMAGE || player->pflags & PF_BOUNCING) && (P_MobjFlip(player->mo)*(player->mo->z - (thing->z + thing->height/2)) > 0) && (P_MobjFlip(player->mo)*player->mo->momz < 0)) 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)) return true; @@ -4336,7 +4346,11 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) P_SetObjectMomZ(player->mo, player->mindash, false); if (player->mo->eflags & MFE_UNDERWATER) player->mo->momz >>= 1; +#if 0 if (FixedMul(player->speed, FINECOSINE(((player->mo->angle - R_PointToAngle2(0, 0, player->rmomx, player->rmomy)) >> ANGLETOFINESHIFT) & FINEMASK)) < FixedMul(player->maxdash, player->mo->scale)) +#else + if (player->speed < FixedMul(player->maxdash, player->mo->scale)) +#endif { player->drawangle = player->mo->angle; P_InstaThrust(player->mo, player->mo->angle, FixedMul(player->maxdash, player->mo->scale));