Skip to content

Commit

Permalink
Added All games: Sequential cycling of player weapons using next/prev…
Browse files Browse the repository at this point in the history
… until the current weapon is fully lowered (for example, if the player owns weapons one through four and four is currently readied; cycling the previous weapon three times in quick succession will select weapon one without). Added "Sequential" item to the Weapons option menu. Added cvar "player-weapon-cycle-sequential".
  • Loading branch information
danij-deng committed May 21, 2010
1 parent dfe7653 commit 0b8cfdd
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 56 deletions.
121 changes: 74 additions & 47 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -866,47 +866,51 @@ static menuitem_t WeaponItems[] = {
#if __JDOOM64__
{ITT_LRFUNC, 0, "10 :", M_WeaponOrder, 9 << NUM_WEAPON_TYPES },
#endif
{ITT_EFUNC, 0, "Use with Next/Previous :", M_ToggleVar, 0, NULL, "player-weapon-nextmode"},
{ITT_EMPTY, 0, NULL, NULL, 0},
{ITT_EMPTY, 0, "AUTOSWITCH", NULL, 0},
{ITT_LRFUNC, 0, "PICKUP WEAPON :", M_WeaponAutoSwitch, 0},
{ITT_EFUNC, 0, " IF NOT FIRING :", M_ToggleVar, 0, NULL, "player-autoswitch-notfiring"},
{ITT_LRFUNC, 0, "PICKUP AMMO :", M_AmmoAutoSwitch, 0},
{ITT_EMPTY, 0, "Cycling", NULL, 0 },
{ITT_EFUNC, 0, "Use Priority Order :", M_ToggleVar, 0, NULL, "player-weapon-nextmode"},
{ITT_LRFUNC, 0, "Sequential :", M_ToggleVar, 0, NULL, "player-weapon-cycle-sequential"},
{ITT_EMPTY, 0, NULL, NULL, 0},
{ITT_EMPTY, 0, "Autoswitch", NULL, 0},
{ITT_LRFUNC, 0, "Pickup Weapon :", M_WeaponAutoSwitch, 0},
{ITT_EFUNC, 0, " If Not Firing :", M_ToggleVar, 0, NULL, "player-autoswitch-notfiring"},
{ITT_LRFUNC, 0, "Pickup Ammo :", M_AmmoAutoSwitch, 0},
#if __JDOOM__ || __JDOOM64__
{ITT_EFUNC, 0, "PICKUP BERSERK :", M_ToggleVar, 0, NULL, "player-autoswitch-berserk"}
{ITT_EFUNC, 0, "Pickup Beserk :", M_ToggleVar, 0, NULL, "player-autoswitch-berserk"}
#endif
};

static menu_t WeaponDef = {
MNF_NOHOTKEYS,
#if __JDOOM__ || __JDOOM64__
68, 34,
#else
78, 28,
78, 40,
#elif __JHERETIC__
78, 26,
#else // __JHEXEN__
78, 38,
#endif
M_DrawWeaponMenu,
#if __JDOOM64__
18, WeaponItems,
21,
#elif __JDOOM__
17, WeaponItems,
20,
#elif __JHERETIC__
15, WeaponItems,
18,
#elif __JHEXEN__
11, WeaponItems,
14,
#endif
0, MENU_OPTIONS,
WeaponItems,
1, MENU_OPTIONS,
GF_FONTA,
cfg.menuColor2,
LINEHEIGHT_A,
#if __JDOOM64__
0, 21
#elif __JDOOM__
0, 20
#if __JDOOM__ || __JDOOM64__
0, 17, { 17, 40 }
#elif __JHERETIC__
0, 18
#elif __JHEXEN__
0, 15, { 15, 26 }
#else // __JHEXEN__
0, 14
#endif
#endif
};

static menuitem_t GameplayItems[] = {
Expand Down Expand Up @@ -1517,7 +1521,7 @@ void Hu_MenuTicker(timespan_t ticLength)
void Hu_MenuPageString(char* page, const menu_t* menu)
{
sprintf(page, "PAGE %i/%i", (menu->firstItem + menu->numVisItems/2) / menu->numVisItems + 1,
(menu->itemCount + menu->numVisItems/2) / menu->numVisItems);
(int)ceil((float)menu->itemCount/menu->numVisItems));
}

static void M_UpdateMenuVisibleItems(void)
Expand Down Expand Up @@ -2810,27 +2814,46 @@ void M_DrawGameplay(void)

void M_DrawWeaponMenu(void)
{
menu_t *menu = &WeaponDef;
int i = 0;
char *autoswitch[] = { "NEVER", "IF BETTER", "ALWAYS" };
menu_t* menu = &WeaponDef;
int i = 0;
char* autoswitch[] = { "NEVER", "IF BETTER", "ALWAYS" };
#if __JHEXEN__
char *weaponids[] = { "First", "Second", "Third", "Fourth"};
char* weaponids[] = { "First", "Second", "Third", "Fourth"};
#endif

#if __JDOOM__ || __JDOOM64__
byte berserkAutoSwitch = cfg.berserkAutoSwitch;
char buf[1024];
#endif
#if __JHERETIC__
patchid_t token;
#endif

MN_DrawTitle("WEAPONS", menu->y - 26);
#if __JDOOM__ || __JDOOM64__
Hu_MenuPageString(buf, menu);
DGL_Color4f(1, .7f, .3f, Hu_MenuAlpha());
M_DrawTextFragment3(buf, SCREENWIDTH/2, menu->y - 12, GF_FONTA, DTF_ALIGN_TOP);
#elif __JHERETIC__
DGL_Color4f(1, 1, 1, Hu_MenuAlpha());

// Draw the page arrows.
token = dpInvPageLeft[!menu->firstItem || (menuTime & 8)];
M_DrawPatch(token, menu->x, menu->y - 22);
token = dpInvPageRight[menu->firstItem + menu->numVisItems >= menu->itemCount || (menuTime & 8)];
M_DrawPatch(token, 312 - menu->x, menu->y - 22);
#endif

/**
* \kludge Inform the user how to change the order.
*/
if(itemOn - 1 >= 0 && itemOn - 1 < NUM_WEAPON_TYPES)
{
const char* str = "Use left/right to move weapon up/down";
#if __JDOOM__
DGL_Color4f(1, .7f, .3f, menuAlpha);
#else
DGL_Color4f(cfg.menuColor2[0], cfg.menuColor2[1], cfg.menuColor2[2], menuAlpha);
M_DrawTextFragment3(str, SCREENWIDTH/2, SCREENHEIGHT-2, GF_FONTA, DTF_ALIGN_BOTTOM);
#endif
M_DrawTextFragment3(str, SCREENWIDTH/2, SCREENHEIGHT/2 + (95/cfg.menuScale), GF_FONTA, DTF_ALIGN_BOTTOM);
}

for(i = 0; i < NUM_WEAPON_TYPES; ++i)
Expand All @@ -2855,27 +2878,31 @@ void M_DrawWeaponMenu(void)
}

#if __JHEXEN__
M_WriteMenuText(menu, 5, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 8, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 9, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 10, autoswitch[cfg.ammoAutoSwitch]);
M_WriteMenuText(menu, 7, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 8, yesno[cfg.weaponCycleSequential]);
M_WriteMenuText(menu, 11, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 12, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 13, autoswitch[cfg.ammoAutoSwitch]);
#elif __JHERETIC__
M_WriteMenuText(menu, 9, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 12, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 13, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 14, autoswitch[cfg.ammoAutoSwitch]);
#elif __JDOOM64__
M_WriteMenuText(menu, 11, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 14, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 15, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 16, autoswitch[cfg.ammoAutoSwitch]);
M_WriteMenuText(menu, 17, yesno[berserkAutoSwitch != 0]);
M_WriteMenuText(menu, 12, yesno[cfg.weaponCycleSequential]);
M_WriteMenuText(menu, 15, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 16, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 17, autoswitch[cfg.ammoAutoSwitch]);
#elif __JDOOM64__
M_WriteMenuText(menu, 12, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 13, yesno[cfg.weaponCycleSequential]);
M_WriteMenuText(menu, 16, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 17, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 18, autoswitch[cfg.ammoAutoSwitch]);
M_WriteMenuText(menu, 19, yesno[cfg.berserkAutoSwitch != 0]);
#elif __JDOOM__
M_WriteMenuText(menu, 10, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 13, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 14, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 15, autoswitch[cfg.ammoAutoSwitch]);
M_WriteMenuText(menu, 16, yesno[berserkAutoSwitch != 0]);
M_WriteMenuText(menu, 12, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 13, yesno[cfg.weaponCycleSequential]);
M_WriteMenuText(menu, 16, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 17, yesno[cfg.noWeaponAutoSwitchIfFiring]);
M_WriteMenuText(menu, 18, autoswitch[cfg.ammoAutoSwitch]);
M_WriteMenuText(menu, 19, yesno[cfg.berserkAutoSwitch != 0]);
#endif
}

Expand Down
12 changes: 9 additions & 3 deletions doomsday/plugins/common/src/p_player.c
Expand Up @@ -609,7 +609,7 @@ boolean P_CheckAmmo(player_t* plr)
*/
weapontype_t P_PlayerFindWeapon(player_t* player, boolean prev)
{
weapontype_t* list, w = 0;
weapontype_t* list, w = 0, initial;
int lvl, i;
#if __JDOOM__
static weapontype_t wp_list[] = {
Expand Down Expand Up @@ -653,11 +653,17 @@ weapontype_t P_PlayerFindWeapon(player_t* player, boolean prev)
for(i = 0; i < NUM_WEAPON_TYPES; ++i)
{
w = list[i];
if(w == player->readyWeapon)
if(!cfg.weaponCycleSequential || player->pendingWeapon == WT_NOCHANGE)
{
if(w == player->readyWeapon)
break;
}
else if(w == player->pendingWeapon)
break;
}

// Locate the next or previous weapon owned by the player.
initial = w;
for(;;)
{
// Move the iterator.
Expand All @@ -674,7 +680,7 @@ weapontype_t P_PlayerFindWeapon(player_t* player, boolean prev)
w = list[i];

// Have we circled around?
if(w == player->readyWeapon)
if(w == initial)
break;

// Available in this game mode? And a valid weapon?
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jdoom/data/conhelp.txt
Expand Up @@ -853,6 +853,9 @@ desc = Weapon change order, slot 7.
[player-weapon-order8]
desc = Weapon change order, slot 8.

[player-weapon-cycle-sequential]
desc = 1=Allow sequential weapon cycling whilst lowering.

[player-weapon-nextmode]
desc = 1=Use custom weapon order with Next/Previous weapon.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/include/d_config.h
Expand Up @@ -113,6 +113,7 @@ typedef struct jdoom_config_s {
byte berserkAutoSwitch;
int weaponOrder[NUM_WEAPON_TYPES];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
byte weaponCycleSequential; // if true multiple next/prev weapon impulses can be chained to allow the user to "count-click-switch".
byte secretMsg;
float filterStrength;
int plrViewHeight;
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/src/d_console.c
Expand Up @@ -168,6 +168,7 @@ cvar_t gameCVars[] = {
{"player-weapon-order8", 0, CVT_INT, &cfg.weaponOrder[8], 0, NUM_WEAPON_TYPES},

{"player-weapon-nextmode", 0, CVT_BYTE, &cfg.weaponNextMode, 0, 1},
{"player-weapon-cycle-sequential", 0, CVT_BYTE, &cfg.weaponCycleSequential, 0, 1},

// Misc
{"player-camera-noclip", 0, CVT_INT, &cfg.cameraNoClip, 0, 1},
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/src/d_main.c
Expand Up @@ -519,6 +519,7 @@ void G_PreInit(void)
cfg.weaponOrder[7] = WT_SEVENTH;
cfg.weaponOrder[8] = WT_FIRST;

cfg.weaponCycleSequential = true;
cfg.berserkAutoSwitch = true;

// Use the DOOM transition by default.
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jdoom64/data/conhelp.txt
Expand Up @@ -846,6 +846,9 @@ desc = Weapon change order, slot 7.
[player-weapon-order8]
desc = Weapon change order, slot 8.

[player-weapon-cycle-sequential]
desc = 1=Allow sequential weapon cycling whilst lowering.

[player-weapon-nextmode]
desc = 1=Use custom weapon order with Next/Previous weapon.

Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jdoom64/include/d_config.h
Expand Up @@ -110,10 +110,11 @@ typedef struct jdoom64_config_s {
byte moveCheckZ; // If true, mobjs can move over/under each other.
byte weaponAutoSwitch;
byte noWeaponAutoSwitchIfFiring;
byte weaponCycleSequential; // if true multiple next/prev weapon impulses can be chained to allow the user to "count-click-switch".
byte weaponNextMode; // if true use the weaponOrder for next/previous.
byte ammoAutoSwitch;
byte berserkAutoSwitch;
int weaponOrder[NUM_WEAPON_TYPES];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
byte weaponRecoil; // jd64
byte secretMsg;
float filterStrength;
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom64/src/d_console.c
Expand Up @@ -169,6 +169,7 @@ cvar_t gameCVars[] = {
{"player-weapon-order9", 0, CVT_INT, &cfg.weaponOrder[9], 0, NUM_WEAPON_TYPES},

{"player-weapon-nextmode", 0, CVT_BYTE, &cfg.weaponNextMode, 0, 1},
{"player-weapon-cycle-sequential", 0, CVT_BYTE, &cfg.weaponCycleSequential, 0, 1},

// Misc
{"player-camera-noclip", 0, CVT_INT, &cfg.cameraNoClip, 0, 1},
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom64/src/d_main.c
Expand Up @@ -396,6 +396,7 @@ void G_PreInit(void)
cfg.weaponOrder[9] = WT_FIRST;
cfg.weaponRecoil = true;

cfg.weaponCycleSequential = true;
cfg.berserkAutoSwitch = true;

// Do the common pre init routine.
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jheretic/data/conhelp.txt
Expand Up @@ -790,6 +790,9 @@ desc = Weapon change order, slot 7.
[player-weapon-order8]
desc = Weapon change order, slot 8.

[player-weapon-cycle-sequential]
desc = 1=Allow sequential weapon cycling whilst lowering.

[player-weapon-nextmode]
desc = 1= Use custom weapon order with Next/Previous weapon.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jheretic/include/h_config.h
Expand Up @@ -110,6 +110,7 @@ typedef struct jheretic_config_s {
byte weaponAutoSwitch;
byte noWeaponAutoSwitchIfFiring;
byte ammoAutoSwitch;
byte weaponCycleSequential; // if true multiple next/prev weapon impulses can be chained to allow the user to "count-click-switch".
int weaponOrder[NUM_WEAPON_TYPES];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
byte secretMsg;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jheretic/src/h_console.c
Expand Up @@ -158,8 +158,8 @@ cvar_t gameCVars[] = {
{"player-weapon-order7", 0, CVT_INT, &cfg.weaponOrder[7], 0, NUM_WEAPON_TYPES},
{"player-weapon-order8", 0, CVT_INT, &cfg.weaponOrder[8], 0, NUM_WEAPON_TYPES},

{"player-weapon-nextmode", 0, CVT_BYTE,
&cfg.weaponNextMode, 0, 1},
{"player-weapon-nextmode", 0, CVT_BYTE, &cfg.weaponNextMode, 0, 1},
{"player-weapon-cycle-sequential", 0, CVT_BYTE, &cfg.weaponCycleSequential, 0, 1},

// Misc
{"player-camera-noclip", 0, CVT_INT, &cfg.cameraNoClip, 0, 1},
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/jheretic/src/h_main.c
Expand Up @@ -413,6 +413,8 @@ void G_PreInit(void)
cfg.weaponOrder[6] = WT_EIGHTH; // gauntlets \ beak
cfg.weaponOrder[7] = WT_FIRST; // staff \ beak

cfg.weaponCycleSequential = true;

cfg.menuEffects = 0;
cfg.hudFog = 5;

Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jhexen/data/conhelp.txt
Expand Up @@ -835,6 +835,9 @@ desc = Weapon change order, slot 2.
[player-weapon-order3]
desc = Weapon change order, slot 3.

[player-weapon-cycle-sequential]
desc = 1=Allow sequential weapon cycling whilst lowering.

[player-weapon-nextmode]
desc = 1= Use custom weapon order with Next/Previous weapon.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/include/x_config.h
Expand Up @@ -112,6 +112,7 @@ typedef struct {
byte weaponAutoSwitch;
byte noWeaponAutoSwitchIfFiring;
byte ammoAutoSwitch;
byte weaponCycleSequential; // if true multiple next/prev weapon impulses can be chained to allow the user to "count-click-switch".
int weaponOrder[NUM_WEAPON_TYPES];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
float filterStrength;
Expand Down
4 changes: 1 addition & 3 deletions doomsday/plugins/jhexen/src/h2_main.c
Expand Up @@ -370,9 +370,7 @@ void G_PreInit(void)
cfg.weaponOrder[2] = WT_SECOND;
cfg.weaponOrder[3] = WT_FIRST;

// Hexen has a nifty "Ethereal Travel" screen, so don't show the
// console during map setup.
Con_SetInteger("con-show-during-setup", 0, true);
cfg.weaponCycleSequential = true;

// Do the common pre init routine.
G_CommonPreInit();
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/src/hconsole.c
Expand Up @@ -153,6 +153,7 @@ cvar_t gameCVars[] = {
{"player-weapon-order3", 0, CVT_INT, &cfg.weaponOrder[3], 0, NUM_WEAPON_TYPES},

{"player-weapon-nextmode", 0, CVT_BYTE, &cfg.weaponNextMode, 0, 1},
{"player-weapon-cycle-sequential", 0, CVT_BYTE, &cfg.weaponCycleSequential, 0, 1},

// Misc
{"player-camera-noclip", 0, CVT_INT, &cfg.cameraNoClip, 0, 1},
Expand Down

0 comments on commit 0b8cfdd

Please sign in to comment.