mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 03:12:00 -04:00
Add "last used weapon" binding
This commit is contained in:
parent
ede79db438
commit
6f6629ac56
@ -223,6 +223,9 @@ typedef struct player_s
|
||||
int num_visitedlevels;
|
||||
level_t *visitedlevels;
|
||||
|
||||
// Last used weapon (last readyweapon).
|
||||
weapontype_t lastweapon;
|
||||
|
||||
} player_t;
|
||||
|
||||
|
||||
|
22
src/g_game.c
22
src/g_game.c
@ -318,6 +318,23 @@ static int G_NextWeapon(int direction)
|
||||
return weapon_order_table[i].weapon_num;
|
||||
}
|
||||
|
||||
static weapontype_t LastWeapon(void)
|
||||
{
|
||||
const weapontype_t weapon = players[consoleplayer].lastweapon;
|
||||
|
||||
if (weapon < wp_fist || weapon >= NUMWEAPONS || !WeaponSelectable(weapon))
|
||||
{
|
||||
return wp_nochange;
|
||||
}
|
||||
|
||||
if (demo_compatibility && weapon == wp_supershotgun)
|
||||
{
|
||||
return wp_shotgun;
|
||||
}
|
||||
|
||||
return weapon;
|
||||
}
|
||||
|
||||
static weapontype_t WeaponSSG(void)
|
||||
{
|
||||
const player_t *player = &players[consoleplayer];
|
||||
@ -788,6 +805,10 @@ void G_BuildTiccmd(ticcmd_t* cmd)
|
||||
boom_weapon_state_injection = false;
|
||||
newweapon = P_SwitchWeapon(&players[consoleplayer]); // phares
|
||||
}
|
||||
else if (M_InputGameActive(input_lastweapon))
|
||||
{
|
||||
newweapon = LastWeapon();
|
||||
}
|
||||
else
|
||||
{ // phares 02/26/98: Added gamemode checks
|
||||
// [FG] prev/next weapon keys and buttons
|
||||
@ -2937,6 +2958,7 @@ void G_PlayerReborn(int player)
|
||||
p->usedown = p->attackdown = true; // don't do anything immediately
|
||||
p->playerstate = PST_LIVE;
|
||||
p->health = initial_health; // Ty 03/12/98 - use dehacked values
|
||||
p->lastweapon = wp_fist;
|
||||
p->readyweapon = p->pendingweapon = wp_pistol;
|
||||
p->weaponowned[wp_fist] = true;
|
||||
p->weaponowned[wp_pistol] = true;
|
||||
|
@ -699,6 +699,7 @@ void M_BindInputVariables(void)
|
||||
BIND_INPUT(input_weapon8, "Switch to weapon 8 (Chainsaw)");
|
||||
BIND_INPUT(input_weapon9, "Switch to weapon 9 (Super Shotgun)");
|
||||
BIND_INPUT(input_weapontoggle, "Switch between the two most-preferred weapons with ammo");
|
||||
BIND_INPUT(input_lastweapon, "Switch to last used weapon");
|
||||
|
||||
BIND_INPUT(input_menu_reloadlevel, "Restart current level/demo");
|
||||
BIND_INPUT(input_menu_nextlevel, "Go to next level");
|
||||
|
@ -56,6 +56,7 @@ enum
|
||||
input_weapon8,
|
||||
input_weapon9,
|
||||
input_weapontoggle,
|
||||
input_lastweapon,
|
||||
|
||||
input_menu_up,
|
||||
input_menu_down,
|
||||
|
@ -1361,6 +1361,7 @@ static setup_menu_t keys_settings2[] = {
|
||||
{"Chainsaw", S_INPUT, KB_X, M_SPC, {0}, m_scrn, input_weapon8},
|
||||
{"SSG", S_INPUT, KB_X, M_SPC, {0}, m_scrn, input_weapon9},
|
||||
{"Best", S_INPUT, KB_X, M_SPC, {0}, m_scrn, input_weapontoggle},
|
||||
{"Last", S_INPUT, KB_X, M_SPC, {0}, m_scrn, input_lastweapon},
|
||||
MI_GAP,
|
||||
// [FG] prev/next weapon keys and buttons
|
||||
{"Prev", S_INPUT, KB_X, M_SPC, {0}, m_scrn, input_prevweapon},
|
||||
|
@ -588,6 +588,7 @@ void A_Lower(player_t *player, pspdef_t *psp)
|
||||
|
||||
if (player->pendingweapon < NUMWEAPONS || !mbf21)
|
||||
{
|
||||
player->lastweapon = player->readyweapon;
|
||||
player->readyweapon = player->pendingweapon;
|
||||
}
|
||||
|
||||
|
@ -989,11 +989,15 @@ static void saveg_read_player_t(player_t *str)
|
||||
level.map = saveg_read32();
|
||||
array_push(str->visitedlevels, level);
|
||||
}
|
||||
|
||||
// [Woof!]: weapontype_t lastweapon;
|
||||
str->lastweapon = saveg_read_enum();
|
||||
}
|
||||
else
|
||||
{
|
||||
str->num_visitedlevels = 0;
|
||||
array_clear(str->visitedlevels);
|
||||
str->lastweapon = wp_nochange;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1158,6 +1162,9 @@ static void saveg_write_player_t(player_t *str)
|
||||
saveg_write32(level->episode);
|
||||
saveg_write32(level->map);
|
||||
}
|
||||
|
||||
// [Woof!]: weapontype_t lastweapon;
|
||||
saveg_write_enum(str->lastweapon);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user