Fix shield objects not being properly flipped

This commit is contained in:
JugadorXEI 2024-05-22 21:00:22 +02:00
parent 20138f3d67
commit 4c7ec4bae0
2 changed files with 15 additions and 1 deletions

View file

@ -13285,6 +13285,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (player->curshield != KSHIELD_BUBBLE)
{
mobj_t *shield = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BUBBLESHIELD);
// MT_BUBBLESHIELD doesn't have MF_NOBLOCKMAP so we need to remove this manually.
// Otherwise if you roll a bubble shield while flipped, the visuals look too mismatched.
shield->eflags &= ~MFE_VERTICALFLIP;
P_SetScale(shield, (shield->destscale = (5*shield->destscale)>>2));
P_SetTarget(&shield->target, player->mo);
S_StartSound(player->mo, sfx_s3k3f);

View file

@ -8355,6 +8355,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
P_SetScale(mobj, (mobj->destscale = (5*mobj->target->scale)>>2));
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + mobj->target->height/2);
// Taken from K_FlipFromObject. We just want to flip the visual according to its target, but that's it.
mobj->eflags = (mobj->eflags & ~MFE_VERTICALFLIP)|(mobj->target->eflags & MFE_VERTICALFLIP);
break;
}
case MT_BUBBLESHIELD:
@ -8461,8 +8464,14 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->extravalue2 = mobj->target->player->bubbleblowup;
P_SetScale(mobj, (mobj->destscale = scale));
// For some weird reason, the Bubble Shield is the exception flip-wise, it has the offset baked into the sprite.
// So instead of simply flipping the object, we have to do a position offset.
fixed_t positionOffset = 0;
if (P_IsObjectFlipped(mobj->target))
positionOffset -= 8 * mobj->scale;
mobj->flags &= ~(MF_NOCLIPTHING);
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z);
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + positionOffset);
mobj->flags |= MF_NOCLIPTHING;
break;
}
@ -8550,6 +8559,8 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
}
}
// Taken from K_FlipFromObject. We just want to flip the visual according to its target, but that's it.
mobj->eflags = (mobj->eflags & ~MFE_VERTICALFLIP)|(mobj->target->eflags & MFE_VERTICALFLIP);
P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + mobj->target->height/2);
mobj->angle = K_MomentumAngle(mobj->target);