mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 19:38:06 -04:00
implement player view/weapon bobbing (off, full, 75%) (#710)
* implement player view/weapon bobbing (full, 75%, off) * fix STRICTMODE typo * rename cosmetic_bobfactor to bobfactor * simplify matters, connect to the existing cosmetic_bobbing feature * keep 1 the default value * de-obfuscate cosmetic_bobbing == 2
This commit is contained in:
parent
d51fdc9fb2
commit
a46f18e118
@ -187,6 +187,9 @@ typedef struct player_s
|
||||
// [crispy] weapon recoil pitch
|
||||
fixed_t recoilpitch, oldrecoilpitch;
|
||||
|
||||
// [crispy] variable player view bob
|
||||
fixed_t bob2;
|
||||
|
||||
} player_t;
|
||||
|
||||
|
||||
|
@ -121,7 +121,7 @@ int monkeys, default_monkeys;
|
||||
// [FG] centered weapon sprite
|
||||
int center_weapon;
|
||||
|
||||
boolean cosmetic_bobbing;
|
||||
int cosmetic_bobbing;
|
||||
|
||||
char *MAPNAME(int e, int m)
|
||||
{
|
||||
|
@ -437,7 +437,7 @@ extern int doom_weapon_toggles; // killough 10/98
|
||||
// [FG] centered weapon sprite
|
||||
extern int center_weapon;
|
||||
|
||||
extern boolean cosmetic_bobbing;
|
||||
extern int cosmetic_bobbing;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3103,6 +3103,10 @@ static const char *weapon_attack_alignment_strings[] = {
|
||||
"OFF", "CENTERED", "BOBBING", NULL
|
||||
};
|
||||
|
||||
static const char *default_bobfactor_strings[] = {
|
||||
"OFF", "FULL", "75%", NULL
|
||||
};
|
||||
|
||||
static void M_UpdateCenteredWeaponItem(void)
|
||||
{
|
||||
DISABLE_ITEM(!STRICTMODE(cosmetic_bobbing), weap_settings1[weap_center]);
|
||||
@ -3129,7 +3133,7 @@ setup_menu_t weap_settings1[] = // Weapons Settings screen
|
||||
|
||||
{"Cosmetic",S_SKIP|S_TITLE,m_null,M_X,M_Y+weap_title1*M_SPC},
|
||||
|
||||
{"Enable Bobbing",S_YESNO,m_null,M_X, M_Y+weap_bobbing*M_SPC, {"cosmetic_bobbing"}, 0, M_UpdateCenteredWeaponItem},
|
||||
{"Player View/Weapon Bobbing",S_CHOICE,m_null,M_X, M_Y+weap_bobbing*M_SPC, {"cosmetic_bobbing"}, 0, M_UpdateCenteredWeaponItem, default_bobfactor_strings},
|
||||
|
||||
{"Enable Recoil Pitch", S_YESNO,m_null,M_X, M_Y+ weap_recoilpitch*M_SPC, {"weapon_recoilpitch"}},
|
||||
|
||||
|
@ -348,8 +348,8 @@ default_t defaults[] = {
|
||||
{
|
||||
"cosmetic_bobbing",
|
||||
(config_t *) &cosmetic_bobbing, NULL,
|
||||
{1}, {0,1}, number, ss_weap, wad_no,
|
||||
"1 to enable cosmetic player bobbing (view moving up/down slightly)"
|
||||
{1}, {0,2}, number, ss_weap, wad_no,
|
||||
"Player View/Weapon Bobbing (0 = off, 1 = full, 2 = 75%)"
|
||||
},
|
||||
|
||||
// [FG] centered or bobbing weapon sprite
|
||||
|
@ -1056,6 +1056,8 @@ void P_SetupPsprites(player_t *player)
|
||||
// Called every tic by player thinking routine.
|
||||
//
|
||||
|
||||
#define BOBBING_75 2
|
||||
|
||||
#define WEAPON_CENTERED 1
|
||||
#define WEAPON_BOBBING 2
|
||||
|
||||
@ -1097,7 +1099,7 @@ void P_MovePsprites(player_t *player)
|
||||
psp->sy2 -= (last_sy - 32 * FRACUNIT);
|
||||
}
|
||||
}
|
||||
else if (psp->state && center_weapon)
|
||||
else if (psp->state && (cosmetic_bobbing == BOBBING_75 || center_weapon))
|
||||
{
|
||||
// [FG] don't center during lowering and raising states
|
||||
if (psp->state->misc1 ||
|
||||
@ -1109,9 +1111,9 @@ void P_MovePsprites(player_t *player)
|
||||
else if (!player->attackdown || center_weapon == WEAPON_BOBBING)
|
||||
{
|
||||
int angle = (128*leveltime) & FINEMASK;
|
||||
psp->sx2 = FRACUNIT + FixedMul(player->bob, finecosine[angle]);
|
||||
psp->sx2 = FRACUNIT + FixedMul(player->bob2, finecosine[angle]);
|
||||
angle &= FINEANGLES/2-1;
|
||||
psp->sy2 = WEAPONTOP + FixedMul(player->bob, finesine[angle]);
|
||||
psp->sy2 = WEAPONTOP + FixedMul(player->bob2, finesine[angle]);
|
||||
}
|
||||
// [FG] center the weapon sprite horizontally and push up vertically
|
||||
else if (center_weapon == WEAPON_CENTERED)
|
||||
|
@ -826,6 +826,7 @@ static void saveg_read_player_t(player_t *str)
|
||||
|
||||
// fixed_t bob;
|
||||
str->bob = saveg_read32();
|
||||
str->bob2 = str->bob;
|
||||
|
||||
// fixed_t momx;
|
||||
str->momx = saveg_read32();
|
||||
|
@ -86,6 +86,9 @@ void P_Bob(player_t *player, angle_t angle, fixed_t move)
|
||||
// Calculate the walking / running height adjustment
|
||||
//
|
||||
|
||||
// [crispy] variable player view bob
|
||||
static const int bobfactors[3] = {0, 4, 3};
|
||||
|
||||
void P_CalcHeight (player_t* player)
|
||||
{
|
||||
int angle;
|
||||
@ -125,6 +128,9 @@ void P_CalcHeight (player_t* player)
|
||||
player->bob = MAXBOB;
|
||||
}
|
||||
|
||||
// [crispy] variable player view bob
|
||||
player->bob2 = bobfactors[cosmetic_bobbing] * player->bob / 4;
|
||||
|
||||
if (!onground || player->cheats & CF_NOMOMENTUM)
|
||||
{
|
||||
player->viewz = player->mo->z + VIEWHEIGHT;
|
||||
@ -143,7 +149,7 @@ void P_CalcHeight (player_t* player)
|
||||
}
|
||||
|
||||
angle = (FINEANGLES/20*leveltime)&FINEMASK;
|
||||
bob = cosmetic_bobbing ? FixedMul(player->bob/2,finesine[angle]) : 0;
|
||||
bob = FixedMul(player->bob2/2,finesine[angle]);
|
||||
|
||||
// move viewheight
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user