Skip to content

Commit

Permalink
Added cvar "player-autoswitch-ammo" autoswitch weapon when after coll…
Browse files Browse the repository at this point in the history
…ecting ammo for a weapon which had previously ran out of ammo; 0= never 1= if better 2= always.
  • Loading branch information
danij committed Sep 18, 2006
1 parent 6d071dd commit d7c2cca
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 33 deletions.
49 changes: 33 additions & 16 deletions doomsday/plugins/common/src/mn_menu.c
Expand Up @@ -109,7 +109,8 @@ void M_ToggleVar(int option, void *data);

void M_OpenDCP(int option, void *data);
void M_ChangeMessages(int option, void *data);
void M_AutoSwitch(int option, void *data);
void M_WeaponAutoSwitch(int option, void *data);
void M_AmmoAutoSwitch(int option, void *data);
void M_HUDInfo(int option, void *data);
void M_HUDScale(int option, void *data);
void M_SfxVol(int option, void *data);
Expand Down Expand Up @@ -987,40 +988,41 @@ static MenuItem_t WeaponItems[] = {
#endif
{ITT_EFUNC, 0, "Use with Next/Previous :", M_ToggleVar, 0, NULL, "player-weapon-nextmode"},
{ITT_EMPTY, 0, NULL, NULL, 0},
{ITT_LRFUNC, 0, "AUTOSWITCH :", M_AutoSwitch, 0},
{ITT_LRFUNC, 0, "WEAPON AUTO SWITCH :", M_WeaponAutoSwitch, 0},
{ITT_LRFUNC, 0, "AMMO AUTO SWITCH :", M_AmmoAutoSwitch, 0},
#if __JDOOM__
{ITT_EFUNC, 0, "BERSERK AUTOSWITCH :", M_ToggleVar, 0, NULL, "player-autoswitch-berserk"}
{ITT_EFUNC, 0, "BERSERK AUTO SWITCH :", M_ToggleVar, 0, NULL, "player-autoswitch-berserk"}
#endif
};

static Menu_t WeaponDef = {
#if !__JDOOM__
60, 30,
50, 30,
#else
78, 44,
68, 44,
#endif
M_DrawWeaponMenu,
#if __DOOM64TC__
18, WeaponItems,
19, WeaponItems,
#elif __JDOOM__
17, WeaponItems,
18, WeaponItems,
#elif __JHERETIC__
15, WeaponItems,
16, WeaponItems,
#elif __JHEXEN__
11, WeaponItems,
12, WeaponItems,
#endif
0, MENU_OPTIONS, 1,
hu_font_a,
cfg.menuColor2,
LINEHEIGHT_A,
#ifdef __DOOM64TC__
0, 18
0, 19
#elif __JDOOM__
0, 17
0, 18
#elif __JHERETIC__
0, 15
0, 16
#elif __JHEXEN__
0, 11
0, 12
#endif
};

Expand Down Expand Up @@ -2972,17 +2974,21 @@ void M_DrawWeaponMenu(void)
#if __JHEXEN__
M_WriteMenuText(menu, 8, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 10, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 11, autoswitch[cfg.ammoAutoSwitch]);
#elif __JHERETIC__
M_WriteMenuText(menu, 12, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 14, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 15, autoswitch[cfg.ammoAutoSwitch]);
#elif __DOOM64TC__
M_WriteMenuText(menu, 14, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 16, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 17, yesno[berserkAutoSwitch != 0]);
M_WriteMenuText(menu, 17, autoswitch[cfg.ammoAutoSwitch]);
M_WriteMenuText(menu, 18, yesno[berserkAutoSwitch != 0]);
#elif __JDOOM__
M_WriteMenuText(menu, 13, yesno[cfg.weaponNextMode]);
M_WriteMenuText(menu, 15, autoswitch[cfg.weaponAutoSwitch]);
M_WriteMenuText(menu, 16, yesno[berserkAutoSwitch != 0]);
M_WriteMenuText(menu, 16, autoswitch[cfg.ammoAutoSwitch]);
M_WriteMenuText(menu, 17, yesno[berserkAutoSwitch != 0]);
#endif
}

Expand Down Expand Up @@ -3016,7 +3022,7 @@ void M_WeaponOrder(int option, void *data)
}
}

void M_AutoSwitch(int option, void *data)
void M_WeaponAutoSwitch(int option, void *data)
{
if(option == RIGHT_DIR)
{
Expand All @@ -3027,6 +3033,17 @@ void M_AutoSwitch(int option, void *data)
cfg.weaponAutoSwitch--;
}

void M_AmmoAutoSwitch(int option, void *data)
{
if(option == RIGHT_DIR)
{
if(cfg.ammoAutoSwitch < 2)
cfg.ammoAutoSwitch++;
}
else if(cfg.ammoAutoSwitch > 0)
cfg.ammoAutoSwitch--;
}

void M_DrawHUDMenu(void)
{
Menu_t *menu = &HUDDef;
Expand Down
29 changes: 19 additions & 10 deletions doomsday/plugins/common/src/p_player.c
Expand Up @@ -245,7 +245,7 @@ weapontype_t P_MaybeChangeWeapon(player_t *player, weapontype_t weapon,
}
else if(ammo != AM_NOAMMO) // Player is about to be given some ammo.
{
if(!player->ammo[ammo] || force)
if((!player->ammo[ammo] && cfg.ammoAutoSwitch != 0) || force)
{ // We were down to zero, so select a new weapon.

// Iterate the weapon order array and see if the player owns a
Expand All @@ -265,18 +265,27 @@ weapontype_t P_MaybeChangeWeapon(player_t *player, weapontype_t weapon,
continue;

// Does the weapon use this type of ammo?
if(winf->mode[lvl].ammotype[ammo])
{
// FIXME: Have we got enough of ALL used ammo types?
// Problem, since the ammo has not been given yet (could
// be an object that gives several ammo types eg backpack)
// we can't test for this with what we know!

// This routine should be called AFTER the new ammo has
// been given. Somewhat complex logic to decipher first...
if(!(winf->mode[lvl].ammotype[ammo]))
continue;

// FIXME: Have we got enough of ALL used ammo types?
// Problem, since the ammo has not been given yet (could
// be an object that gives several ammo types eg backpack)
// we can't test for this with what we know!

// This routine should be called AFTER the new ammo has
// been given. Somewhat complex logic to decipher first...

if(cfg.ammoAutoSwitch == 2)
{ // Always change weapon mode
returnval = candidate;
break;
}
else if(cfg.ammoAutoSwitch == 1 &&
player->readyweapon == candidate)
{ // readyweapon has a higher priority so don't change.
break;
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/doom64tc/data/conhelp.txt
Expand Up @@ -795,6 +795,9 @@ desc = Player movement speed while airborne.
[player-autoswitch]
desc = Change weapon automatically when picking one up. 1=If better 2=Always

[player-autoswitch-ammo]
desc = Change weapon automatically when picking up ammo. 1=If better 2=Always

[player-autoswitch-berserk]
desc = Change to fist automatically when picking up berserk pack

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/doom64tc/include/d_config.h
Expand Up @@ -108,6 +108,7 @@ typedef struct jdoom_config_s {
byte usePatchReplacement;
byte moveCheckZ; // if true, mobjs can move over/under each other.
byte weaponAutoSwitch;
byte ammoAutoSwitch;
byte berserkAutoSwitch;
int weaponOrder[NUMWEAPONS];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/doom64tc/src/d_console.c
Expand Up @@ -152,6 +152,7 @@ cvar_t gameCVars[] = {

// Weapon switch preferences
{"player-autoswitch", 0, CVT_BYTE, &cfg.weaponAutoSwitch, 0, 2},
{"player-autoswitch-ammo", 0, CVT_BYTE, &cfg.ammoAutoSwitch, 0, 2},
{"player-autoswitch-berserk", 0, CVT_BYTE, &cfg.berserkAutoSwitch, 0, 1},

// Weapon Order preferences
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/doom64tc/src/d_main.c
Expand Up @@ -286,7 +286,8 @@ void D_PreInit(void)
cfg.moveCheckZ = true;
cfg.jumpPower = 9;
cfg.airborneMovement = 1;
cfg.weaponAutoSwitch = true;
cfg.weaponAutoSwitch = 1; // IF BETTER
cfg.ammoAutoSwitch = 0; // never
cfg.secretMsg = true;
cfg.netJumping = true;
cfg.netEpisode = 1;
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jdoom/data/conhelp.txt
Expand Up @@ -789,6 +789,9 @@ desc = Player movement speed while airborne.
[player-autoswitch]
desc = Change weapon automatically when picking one up. 1=If better 2=Always

[player-autoswitch-ammo]
desc = Change weapon automatically when picking up ammo. 1=If better 2=Always

[player-autoswitch-berserk]
desc = Change to fist automatically when picking up berserk pack

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/include/d_config.h
Expand Up @@ -109,6 +109,7 @@ typedef struct jdoom_config_s {
byte usePatchReplacement;
byte moveCheckZ; // if true, mobjs can move over/under each other.
byte weaponAutoSwitch;
byte ammoAutoSwitch;
byte berserkAutoSwitch;
int weaponOrder[NUMWEAPONS];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/src/d_console.c
Expand Up @@ -150,6 +150,7 @@ cvar_t gameCVars[] = {

// Weapon switch preferences
{"player-autoswitch", 0, CVT_BYTE, &cfg.weaponAutoSwitch, 0, 2},
{"player-autoswitch-ammo", 0, CVT_BYTE, &cfg.ammoAutoSwitch, 0, 2},
{"player-autoswitch-berserk", 0, CVT_BYTE, &cfg.berserkAutoSwitch, 0, 1},

// Weapon Order preferences
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jdoom/src/d_main.c
Expand Up @@ -409,7 +409,8 @@ void D_PreInit(void)
cfg.moveCheckZ = true;
cfg.jumpPower = 9;
cfg.airborneMovement = 1;
cfg.weaponAutoSwitch = true;
cfg.weaponAutoSwitch = 1; // if better
cfg.ammoAutoSwitch = 0; // never
cfg.secretMsg = true;
cfg.netJumping = true;
cfg.netEpisode = 1;
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jheretic/data/conhelp.txt
Expand Up @@ -726,6 +726,9 @@ desc = Player movement speed while airborne.
[player-autoswitch]
desc = Change weapon automatically when picking one up. 1=If better 2=Always

[player-autoswitch-ammo]
desc = Change weapon automatically when picking up ammo. 1=If better 2=Always

[player-weapon-order0]
desc = Weapon change order, slot 0.

Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/include/h_config.h
Expand Up @@ -102,7 +102,7 @@ typedef struct jheretic_config_s {
byte usePatchReplacement;
byte moveCheckZ; // if true, mobjs can move over/under each other.
byte weaponAutoSwitch;

byte ammoAutoSwitch;
int weaponOrder[NUMWEAPONS];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
byte secretMsg;
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jheretic/src/h_console.c
Expand Up @@ -147,6 +147,7 @@ cvar_t gameCVars[] = {

// Weapon switch preferences
{"player-autoswitch", 0, CVT_BYTE, &cfg.weaponAutoSwitch, 0, 2},
{"player-autoswitch-ammo", 0, CVT_BYTE, &cfg.ammoAutoSwitch, 0, 2},

// Weapon Order preferences
{"player-weapon-order0", 0, CVT_INT, &cfg.weaponOrder[0], 0, NUMWEAPONS},
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jheretic/src/h_main.c
Expand Up @@ -305,7 +305,8 @@ void H_PreInit(void)
cfg.moveCheckZ = true;
cfg.jumpPower = 9;
cfg.airborneMovement = 1;
cfg.weaponAutoSwitch = true;
cfg.weaponAutoSwitch = 1; // IF BETTER
cfg.ammoAutoSwitch = 0; // never
cfg.secretMsg = true;
cfg.netJumping = true;
cfg.netEpisode = 1;
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jhexen/data/conhelp.txt
Expand Up @@ -786,6 +786,9 @@ desc = Player movement speed while airborne and NOT flying.
[player-autoswitch]
desc = Change weapon automatically when picking one up. 1=If better 2=Always

[player-autoswitch-ammo]
desc = Change weapon automatically when picking up ammo. 1=If better 2=Always

[player-weapon-order0]
desc = Weapon change order, slot 0.

Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jhexen/include/x_config.h
Expand Up @@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* In addition, as a special exception, we, the authors of deng
Expand Down Expand Up @@ -112,6 +112,7 @@ typedef struct {
byte msgShow;
float msgColor[3];
byte weaponAutoSwitch;
byte ammoAutoSwitch;
int weaponOrder[NUMWEAPONS];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
float inventoryTimer; // Number of seconds until the invetory auto-hides.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/jhexen/src/h2_main.c
Expand Up @@ -291,6 +291,8 @@ void H2_PreInit(void)
cfg.jumpEnabled = cfg.netJumping = true; // true by default in Hexen
cfg.jumpPower = 9;
cfg.airborneMovement = 1;
cfg.weaponAutoSwitch = 1; // IF BETTER
cfg.ammoAutoSwitch = 0; // never
cfg.netMap = 1;
cfg.netSkill = sk_medium;
cfg.netColor = 8; // Use the default color by default.
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jhexen/src/hconsole.c
Expand Up @@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* In addition, as a special exception, we, the authors of deng
Expand Down Expand Up @@ -153,6 +153,7 @@ cvar_t gameCVars[] = {

// Weapon switch preferences
{"player-autoswitch", 0, CVT_BYTE, &cfg.weaponAutoSwitch, 0, 2},
{"player-autoswitch-ammo", 0, CVT_BYTE, &cfg.ammoAutoSwitch, 0, 2},

// Weapon Order preferences
{"player-weapon-order0", 0, CVT_INT, &cfg.weaponOrder[0], 0, NUMWEAPONS},
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/wolftc/data/conhelp.txt
Expand Up @@ -789,6 +789,9 @@ desc = Player movement speed while airborne.
[player-autoswitch]
desc = Change weapon automatically when picking one up. 1=If better 2=Always

[player-autoswitch-ammo]
desc = Change weapon automatically when picking up ammo. 1=If better 2=Always

[player-autoswitch-berserk]
desc = Change to fist automatically when picking up berserk pack

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/wolftc/include/d_config.h
Expand Up @@ -106,6 +106,7 @@ typedef struct jdoom_config_s {
byte usePatchReplacement;
byte moveCheckZ; // if true, mobjs can move over/under each other.
byte weaponAutoSwitch;
byte ammoAutoSwitch;
byte berserkAutoSwitch;
int weaponOrder[NUMWEAPONS];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/wolftc/src/d_console.c
Expand Up @@ -153,6 +153,7 @@ cvar_t gameCVars[] = {

// Weapon switch preferences
{"player-autoswitch", 0, CVT_BYTE, &cfg.weaponAutoSwitch, 0, 2},
{"player-autoswitch-ammo", 0, CVT_BYTE, &cfg.ammoAutoSwitch, 0, 2},
{"player-autoswitch-berserk", 0, CVT_BYTE, &cfg.berserkAutoSwitch, 0, 1},

// Weapon Order preferences
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/wolftc/src/d_main.c
Expand Up @@ -409,7 +409,8 @@ void D_PreInit(void)
cfg.moveCheckZ = true;
cfg.jumpPower = 9;
cfg.airborneMovement = 1;
cfg.weaponAutoSwitch = true;
cfg.weaponAutoSwitch = 1; // IF BETTER
cfg.ammoAutoSwitch = 0; // never
cfg.secretMsg = true;
cfg.netJumping = true;
cfg.netEpisode = 1;
Expand Down

0 comments on commit d7c2cca

Please sign in to comment.