From 8c1771112cd9f6436b3a4a74baee3df73368cbef Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 11 Mar 2023 04:35:59 -0800 Subject: [PATCH] Fix Bubble Shield duplicate collisions Bubble Shield could collide with the same object up to 5 times per tic! (3 times at least!) 1) P_CheckPosition from MFE_ONGROUND being unset. 2) P_CheckPosition AGAIN from MFE_ONGROUND being unset while literally being on the ground. This one's probably a bug in general but it's beyond the scope of this commit. It's also scary movement code, yiiiikes... 3) P_MoveOrigin to teleport the Bubble to its holder's position. 4) If something moves into the Bubble. 5) If something moves into the player holding the Bubble. This generated extra unwated hitlag, especially noticeable against invincible players. To reduce these to one collision only, the Bubble is now MF_NOCLIPTHING except while calling P_MoveOrigin. The player's own hitbox is also disabled for Bubble collisions. --- src/info.c | 2 +- src/k_collide.c | 13 ++++++++++++- src/p_mobj.c | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/info.c b/src/info.c index cb00a3bff..aa2befa3d 100644 --- a/src/info.c +++ b/src/info.c @@ -23907,7 +23907,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_SOLID|MF_NOCLIP|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SOLID|MF_NOCLIP|MF_NOCLIPTHING|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/k_collide.c b/src/k_collide.c index 7964c3140..307d7c85d 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -678,6 +678,17 @@ void K_LightningShieldAttack(mobj_t *actor, fixed_t size) boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2) { + if (t1->type == MT_PLAYER) + { + // Bubble Shield already has a hitbox, and it gets + // teleported every tic so the Bubble itself will + // always make contact with other objects. + // + // Therefore, we don't need a second, smaller hitbox + // on the player. It'll just cause unwanted hitlag. + return true; + } + if (t2->type == MT_PLAYER) { // Counter desyncs @@ -697,7 +708,7 @@ boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2) } // Player Damage - P_DamageMobj(t2, ((t1->type == MT_BUBBLESHIELD) ? t1->target : t1), t1, 1, DMG_NORMAL|DMG_WOMBO); + P_DamageMobj(t2, t1->target, t1, 1, DMG_NORMAL|DMG_WOMBO); S_StartSound(t1, sfx_s3k44); } else diff --git a/src/p_mobj.c b/src/p_mobj.c index 8799901da..c5d70ead5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8246,7 +8246,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj) desty = mobj->target->y; } + mobj->flags &= ~(MF_NOCLIPTHING); P_MoveOrigin(mobj, destx, desty, mobj->target->z); + mobj->flags |= MF_NOCLIPTHING; break; } case MT_FLAMESHIELD: