From 622bfa9512147624ac949ae584a41f8ba0476544 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 11 Mar 2023 05:14:37 -0800 Subject: [PATCH] Count nullHitlag for inflictor player too Cancel hitlag of inflictor player too if the inflictor is a constant damage source and the target is invincible. --- src/d_player.h | 6 ++++-- src/p_inter.c | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index baa83d1a7..6641b30d6 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -641,8 +641,10 @@ struct player_t INT16 lastsidehit, lastlinehit; - // These track how many things tried to damage you, not - // whether you actually took damage. + // TimesHit tracks how many times something tried to + // damage you or how many times you tried to damage + // something else. It does not track whether damage was + // actually dealt. UINT8 timeshit; // times hit this tic UINT8 timeshitprev; // times hit before // That's TIMES HIT, not TIME SHIT, you doofus! -- in memoriam diff --git a/src/p_inter.c b/src/p_inter.c index e0bc2eed1..df9e69b71 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2060,6 +2060,7 @@ static void AddNullHitlag(player_t *player, tic_t oldHitlag) boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { player_t *player; + player_t *playerInflictor; boolean force = false; INT32 laglength = 6; @@ -2138,10 +2139,15 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } player = target->player; + playerInflictor = inflictor ? inflictor->player : NULL; + + if (playerInflictor) + { + AddTimesHit(playerInflictor); + } if (player) // Player is the target { - AddTimesHit(player); if (player->pflags & PF_GODMODE) @@ -2208,11 +2214,13 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (invincible && type != DMG_STUMBLE) { const INT32 oldHitlag = target->hitlag; + const INT32 oldHitlagInflictor = inflictor ? inflictor->hitlag : 0; laglength = max(laglength / 2, 1); K_SetHitLagForObjects(target, inflictor, laglength, false); AddNullHitlag(player, oldHitlag); + AddNullHitlag(playerInflictor, oldHitlagInflictor); if (player->timeshit > player->timeshitprev) {