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.
This commit is contained in:
James R 2023-03-11 04:35:59 -08:00
parent ee4011cca6
commit 8c1771112c
3 changed files with 15 additions and 2 deletions

View file

@ -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
},

View file

@ -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

View file

@ -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: