Skip to content

Commit

Permalink
Much cleaner weaponbob/playerbob decoupling.
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesLove committed Jul 23, 2021
1 parent 599b961 commit ef50b9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 34 deletions.
32 changes: 3 additions & 29 deletions prboom2/src/p_pspr.c
Expand Up @@ -617,35 +617,9 @@ void A_WeaponReady(player_t *player, pspdef_t *psp)
if (!player->morphTics)
{
int angle = (128 * leveltime) & FINEMASK;
// Temporarily set and use player bob calculations so that the weapon will continue bobbing
// whether or not player_bobbing is active
if(!player_bobbing)
{
player->bob = (FixedMul(player->momx, player->momx) + FixedMul(player->momy, player->momy)) >> 2;
if (!prboom_comp[PC_PRBOOM_FRICTION].state &&
compatibility_level >= boom_202_compatibility &&
compatibility_level <= lxdoom_1_compatibility &&
player->mo->friction > ORIG_FRICTION) // ice?
{
if (player->bob > (MAXBOB >> 2))
player->bob = MAXBOB >> 2;
}
else
{
if (player->bob > MAXBOB)
player->bob = MAXBOB;
}
psp->sx = FRACUNIT + FixedMul(player->bob, finecosine[angle]);
angle &= FINEANGLES / 2 - 1;
psp->sy = WEAPONTOP + FixedMul(player->bob, finesine[angle]);
player->bob = 0;
}
else
{
psp->sx = FRACUNIT + FixedMul(player->bob, finecosine[angle]);
angle &= FINEANGLES / 2 - 1;
psp->sy = WEAPONTOP + FixedMul(player->bob, finesine[angle]);
}
psp->sx = FRACUNIT + FixedMul(player->bob, finecosine[angle]);
angle &= FINEANGLES / 2 - 1;
psp->sy = WEAPONTOP + FixedMul(player->bob, finesine[angle]);
}
}

Expand Down
11 changes: 6 additions & 5 deletions prboom2/src/p_user.c
Expand Up @@ -179,11 +179,8 @@ void P_CalcHeight (player_t* player)

if (mbf_features)
{
if (player_bobbing)
{
player->bob = (FixedMul(player->momx, player->momx) +
player->bob = (FixedMul(player->momx, player->momx) +
FixedMul(player->momy, player->momy)) >> 2;
}
}
else
{
Expand Down Expand Up @@ -225,7 +222,11 @@ void P_CalcHeight (player_t* player)
}

angle = (FINEANGLES / 20 * leveltime) & FINEMASK;
bob = FixedMul(player->bob / 2, finesine[angle]);

if(!player_bobbing)
bob = 0;
else
bob = FixedMul(player->bob / 2, finesine[angle]);

// move viewheight

Expand Down

0 comments on commit ef50b9a

Please sign in to comment.