mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-24 04:29:34 -04:00
Fix stutter in weapon switching animation (#1082)
* Weapon switching fix proof-of-concept * Fix switching anim with bobbing disabled * Use enum
This commit is contained in:
parent
6dafe9b7b0
commit
a2c40bbd2a
33
src/p_pspr.c
33
src/p_pspr.c
@ -38,6 +38,15 @@
|
|||||||
#define WEAPONBOTTOM (FRACUNIT*128)
|
#define WEAPONBOTTOM (FRACUNIT*128)
|
||||||
#define WEAPONTOP (FRACUNIT*32)
|
#define WEAPONTOP (FRACUNIT*32)
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
weapswitch_none,
|
||||||
|
weapswitch_lowering,
|
||||||
|
weapswitch_raising,
|
||||||
|
} weapswitch_t;
|
||||||
|
|
||||||
|
static weapswitch_t switching;
|
||||||
|
|
||||||
#define BFGCELLS bfgcells /* Ty 03/09/98 externalized in p_inter.c */
|
#define BFGCELLS bfgcells /* Ty 03/09/98 externalized in p_inter.c */
|
||||||
|
|
||||||
extern void P_Thrust(player_t *, angle_t, fixed_t);
|
extern void P_Thrust(player_t *, angle_t, fixed_t);
|
||||||
@ -145,6 +154,7 @@ static void P_BringUpWeapon(player_t *player)
|
|||||||
S_StartSound(player->mo, sfx_sawup);
|
S_StartSound(player->mo, sfx_sawup);
|
||||||
|
|
||||||
newstate = weaponinfo[player->pendingweapon].upstate;
|
newstate = weaponinfo[player->pendingweapon].upstate;
|
||||||
|
switching = weapswitch_raising;
|
||||||
|
|
||||||
player->pendingweapon = wp_nochange;
|
player->pendingweapon = wp_nochange;
|
||||||
|
|
||||||
@ -475,8 +485,11 @@ void A_WeaponReady(player_t *player, pspdef_t *psp)
|
|||||||
// change weapon (pending weapon should already be validated)
|
// change weapon (pending weapon should already be validated)
|
||||||
statenum_t newstate = weaponinfo[player->readyweapon].downstate;
|
statenum_t newstate = weaponinfo[player->readyweapon].downstate;
|
||||||
P_SetPsprite(player, ps_weapon, newstate);
|
P_SetPsprite(player, ps_weapon, newstate);
|
||||||
|
switching = weapswitch_lowering;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
switching = weapswitch_none;
|
||||||
|
|
||||||
// check for fire
|
// check for fire
|
||||||
// the missile launcher and bfg do not auto fire
|
// the missile launcher and bfg do not auto fire
|
||||||
@ -1065,8 +1078,7 @@ void P_SetupPsprites(player_t *player)
|
|||||||
void P_MovePsprites(player_t *player)
|
void P_MovePsprites(player_t *player)
|
||||||
{
|
{
|
||||||
pspdef_t *psp = player->psprites;
|
pspdef_t *psp = player->psprites;
|
||||||
weaponinfo_t *winfo;
|
int i;
|
||||||
int i, state;
|
|
||||||
|
|
||||||
// a null state means not active
|
// a null state means not active
|
||||||
// drop tic count and possibly change state
|
// drop tic count and possibly change state
|
||||||
@ -1084,26 +1096,18 @@ void P_MovePsprites(player_t *player)
|
|||||||
psp->sx2 = psp->sx;
|
psp->sx2 = psp->sx;
|
||||||
psp->sy2 = psp->sy;
|
psp->sy2 = psp->sy;
|
||||||
|
|
||||||
winfo = &weaponinfo[player->readyweapon];
|
|
||||||
state = psp->state - states;
|
|
||||||
|
|
||||||
#define LOWERING (psp->state->action.p2 == (actionf_p2)A_Lower || \
|
|
||||||
state == winfo->downstate)
|
|
||||||
#define RAISING (psp->state->action.p2 == (actionf_p2)A_Raise || \
|
|
||||||
state == winfo->upstate)
|
|
||||||
|
|
||||||
if (psp->state && !cosmetic_bobbing)
|
if (psp->state && !cosmetic_bobbing)
|
||||||
{
|
{
|
||||||
static fixed_t last_sy = WEAPONTOP;
|
static fixed_t last_sy = WEAPONTOP;
|
||||||
|
|
||||||
psp->sx2 = FRACUNIT;
|
psp->sx2 = FRACUNIT;
|
||||||
|
|
||||||
if (!psp->state->misc1 && !LOWERING && !RAISING)
|
if (!psp->state->misc1 && !switching)
|
||||||
{
|
{
|
||||||
last_sy = psp->sy2;
|
last_sy = psp->sy2;
|
||||||
psp->sy2 = WEAPONTOP;
|
psp->sy2 = WEAPONTOP;
|
||||||
}
|
}
|
||||||
else if (LOWERING)
|
else if (switching == weapswitch_lowering)
|
||||||
{
|
{
|
||||||
// We want to move smoothly from where we were
|
// We want to move smoothly from where we were
|
||||||
psp->sy2 -= (last_sy - WEAPONTOP);
|
psp->sy2 -= (last_sy - WEAPONTOP);
|
||||||
@ -1112,7 +1116,7 @@ void P_MovePsprites(player_t *player)
|
|||||||
else if (psp->state && (cosmetic_bobbing == BOBBING_75 || center_weapon || uncapped))
|
else if (psp->state && (cosmetic_bobbing == BOBBING_75 || center_weapon || uncapped))
|
||||||
{
|
{
|
||||||
// [FG] don't center during lowering and raising states
|
// [FG] don't center during lowering and raising states
|
||||||
if (psp->state->misc1 || LOWERING || RAISING)
|
if (psp->state->misc1 || switching)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
// [FG] not attacking means idle
|
// [FG] not attacking means idle
|
||||||
@ -1128,9 +1132,6 @@ void P_MovePsprites(player_t *player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef LOWERING
|
|
||||||
#undef RAISING
|
|
||||||
|
|
||||||
player->psprites[ps_flash].sx2 = player->psprites[ps_weapon].sx2;
|
player->psprites[ps_flash].sx2 = player->psprites[ps_weapon].sx2;
|
||||||
player->psprites[ps_flash].sy2 = player->psprites[ps_weapon].sy2;
|
player->psprites[ps_flash].sy2 = player->psprites[ps_weapon].sy2;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user