Tweaked next/prev weapon behavior underwater

This commit is contained in:
carnivoroussociety 2021-08-13 22:39:16 +10:00 committed by Christoph Oelckers
parent 5aa27bad3b
commit 1957fc53be

View file

@ -2091,6 +2091,7 @@ void WeaponProcess(PLAYER *pPlayer) {
return; return;
break; break;
} }
const int prevNewWeaponVal = pPlayer->input.getNewWeapon(); // used to fix scroll issue for banned weapons
if (VanillaMode()) if (VanillaMode())
{ {
if (pPlayer->nextWeapon) if (pPlayer->nextWeapon)
@ -2202,6 +2203,25 @@ void WeaponProcess(PLAYER *pPlayer) {
} }
if (pPlayer->newWeapon) if (pPlayer->newWeapon)
{ {
if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->newWeapon) && !checkFired6or7(pPlayer)) // skip banned weapons when underwater and using next/prev weapon key inputs
{
const bool next = prevNewWeaponVal == WeaponSel_Next, prev = prevNewWeaponVal == WeaponSel_Prev;
if ((next || prev) && !VanillaMode() && !DemoRecordStatus()) // if player switched weapons
{
PLAYER tmpPlayer = *pPlayer;
tmpPlayer.curWeapon = pPlayer->newWeapon; // set current banned weapon to curweapon so WeaponFindNext() can find the next weapon
for (int i = 0; i < 3; i++) // attempt twice to find a new weapon
{
tmpPlayer.curWeapon = WeaponFindNext(&tmpPlayer, NULL, next ? 1 : 0);
if (!BannedUnderwater(tmpPlayer.curWeapon)) // if new weapon is not a banned weapon, set to new current weapon
{
pPlayer->newWeapon = tmpPlayer.curWeapon;
pPlayer->weaponMode[pPlayer->newWeapon] = 0;
break;
}
}
}
}
if (pPlayer->newWeapon == 6) if (pPlayer->newWeapon == 6)
{ {
if (pPlayer->curWeapon == 6) if (pPlayer->curWeapon == 6)