From b0bf51ec5c145722c9f7636b8f265e1cd3ab6000 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Dec 2020 21:07:38 +0100 Subject: [PATCH] - Duke/RR: Selecting the alternative weapon must set the proper bits in 'subweapon'. Otherwise the weapon cycling breaks. Fixes #182 --- source/games/duke/src/player_d.cpp | 26 +++++++++++++---- source/games/duke/src/player_r.cpp | 45 ++++++++++++++++++++++++------ wadsrc/static/menudef.txt | 8 +++--- 3 files changed, 62 insertions(+), 17 deletions(-) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index cb0adb17d..2285317d3 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1190,22 +1190,38 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum { if (weap == WeaponSel_Alt) { + j = p->curr_weapon; switch (p->curr_weapon) { case SHRINKER_WEAPON: - j = isPlutoPak() ? GROW_WEAPON : p->curr_weapon; + if (p->ammo_amount[GROW_WEAPON] > 0 && p->gotweapon[GROW_WEAPON] && isPlutoPak()) + { + j = GROW_WEAPON; + p->subweapon |= (1 << GROW_WEAPON); + } break; case GROW_WEAPON: - j = SHRINKER_WEAPON; + if (p->ammo_amount[SHRINKER_WEAPON] > 0 && p->gotweapon[SHRINKER_WEAPON]) + { + j = SHRINKER_WEAPON; + p->subweapon &= ~(1 << GROW_WEAPON); + } break; case FREEZE_WEAPON: - j = isWorldTour() ? FLAMETHROWER_WEAPON : p->curr_weapon; + if (p->ammo_amount[FLAMETHROWER_WEAPON] > 0 && p->gotweapon[FLAMETHROWER_WEAPON] && isWorldTour()) + { + j = FLAMETHROWER_WEAPON; + p->subweapon |= (1 << FLAMETHROWER_WEAPON); + } break; case FLAMETHROWER_WEAPON: - j = FREEZE_WEAPON; + if (p->ammo_amount[FREEZE_WEAPON] > 0 && p->gotweapon[FREEZE_WEAPON]) + { + j = FREEZE_WEAPON; + p->subweapon &= ~(1 << FLAMETHROWER_WEAPON); + } break; default: - j = p->curr_weapon; break; } } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 227536991..56fc223a2 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -984,34 +984,63 @@ void selectweapon_r(int snum, int weap) { if (weap == WeaponSel_Alt) { + j = p->curr_weapon; switch (p->curr_weapon) { case THROWSAW_WEAPON: - j = BUZZSAW_WEAPON; + if (p->ammo_amount[BUZZSAW_WEAPON] > 0) + { + j = BUZZSAW_WEAPON; + p->subweapon = 1 << BUZZSAW_WEAPON; + } break; case BUZZSAW_WEAPON: - j = THROWSAW_WEAPON; + if (p->ammo_amount[THROWSAW_WEAPON] > 0) + { + j = THROWSAW_WEAPON; + p->subweapon = 0; + } break; case POWDERKEG_WEAPON: - j = BOWLING_WEAPON; + if (p->ammo_amount[BOWLING_WEAPON] > 0) + { + j = BOWLING_WEAPON; + p->subweapon = 1 << BOWLING_WEAPON; + } break; case BOWLING_WEAPON: - j = POWDERKEG_WEAPON; + if (p->ammo_amount[POWDERKEG_WEAPON] > 0) + { + j = POWDERKEG_WEAPON; + p->subweapon = 0; + } break; case KNEE_WEAPON: - j = isRRRA() ? SLINGBLADE_WEAPON : p->curr_weapon; + if (isRRRA()) + { + j = SLINGBLADE_WEAPON; + p->subweapon = 2; + } break; case SLINGBLADE_WEAPON: j = KNEE_WEAPON; + p->subweapon = 0; break; case DYNAMITE_WEAPON: - j = isRRRA() ? CHICKEN_WEAPON : p->curr_weapon; + if (p->ammo_amount[CHICKEN_WEAPON] > 0 && isRRRA()) + { + j = CHICKEN_WEAPON; + p->subweapon = 4; + } break; case CHICKEN_WEAPON: - j = DYNAMITE_WEAPON; + if (p->ammo_amount[DYNAMITE_WEAPON] > 0) + { + j = DYNAMITE_WEAPON; + p->subweapon = 0; + } break; default: - j = p->curr_weapon; break; } } diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 7803c7520..7d877fbe1 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -498,10 +498,6 @@ OptionMenu "ActionControlsMenu" protected { Control "$CNTRLMNU_ALTATTACK" , "+alt_fire" } - ifnotgame(Exhumed) - { - Control "$CNTRLMNU_ALTWEAPON" , "weapalt" - } StaticText "" Control "$CNTRLMNU_USE" , "+open" @@ -563,6 +559,10 @@ OptionMenu "WeaponsControlMenu" protected StaticText "" Control "$CNTRLMNU_NEXTWEAPON" , "weapnext" Control "$CNTRLMNU_PREVIOUSWEAPON" , "weapprev" + ifnotgame(Exhumed) + { + Control "$CNTRLMNU_ALTWEAPON" , "weapalt" + } StaticText "" Control "$CNTRLMNU_SLOT1" , "slot 1"