Fix ignited spray/TNT issue when going underwater

This commit is contained in:
carnivoroussociety 2021-08-12 19:19:07 +10:00 committed by Christoph Oelckers
parent 23b8707fc2
commit 1a344fe09b

View file

@ -144,7 +144,7 @@ enum
QAV *weaponQAV[kQAVEnd]; QAV *weaponQAV[kQAVEnd];
static bool sub_4B1A4(PLAYER *pPlayer) static bool checkFired6or7(PLAYER *pPlayer)
{ {
switch (pPlayer->curWeapon) switch (pPlayer->curWeapon)
{ {
@ -154,6 +154,10 @@ static bool sub_4B1A4(PLAYER *pPlayer)
case 5: case 5:
case 6: case 6:
return 1; return 1;
case 7:
if (VanillaMode() || DemoRecordStatus())
return 0;
return 1;
} }
break; break;
case 6: case 6:
@ -651,7 +655,7 @@ void WeaponRaise(PLAYER *pPlayer)
void WeaponLower(PLAYER *pPlayer) void WeaponLower(PLAYER *pPlayer)
{ {
assert(pPlayer != NULL); assert(pPlayer != NULL);
if (sub_4B1A4(pPlayer)) if (checkFired6or7(pPlayer))
return; return;
pPlayer->throwPower = 0; pPlayer->throwPower = 0;
int prevState = pPlayer->weaponState; int prevState = pPlayer->weaponState;
@ -726,26 +730,26 @@ void WeaponLower(PLAYER *pPlayer)
StartQAV(pPlayer, 11, -1, 0); StartQAV(pPlayer, 11, -1, 0);
} }
break; break;
case 7: // throwing ignited alt fire spray
if (VanillaMode() || DemoRecordStatus() || (pPlayer->input.newWeapon != 0))
break;
pPlayer->weaponState = 1;
StartQAV(pPlayer, 11, -1, 0);
break;
} }
break; break;
case 6: case 6:
switch (prevState) switch (prevState)
{ {
case 1: case 1:
if (VanillaMode()) if (!VanillaMode() && (pPlayer->input.newWeapon == 7)) // do not put away lighter if TNT was selected while throwing a spray can
{
StartQAV(pPlayer, 7, -1, 0);
}
else
{
if (pPlayer->newWeapon == 7)
{ {
pPlayer->weaponState = 2; pPlayer->weaponState = 2;
StartQAV(pPlayer, 17, -1, 0); StartQAV(pPlayer, 17, -1, 0);
WeaponRaise(pPlayer); WeaponRaise(pPlayer);
return; return;
} }
} StartQAV(pPlayer, 7, -1, 0);
break; break;
case 2: case 2:
WeaponRaise(pPlayer); WeaponRaise(pPlayer);
@ -1748,7 +1752,7 @@ uint8_t gWeaponUpgrade[][13] = {
int WeaponUpgrade(PLAYER *pPlayer, int newWeapon) int WeaponUpgrade(PLAYER *pPlayer, int newWeapon)
{ {
int weapon = pPlayer->curWeapon; int weapon = pPlayer->curWeapon;
if (!sub_4B1A4(pPlayer) && (cl_weaponswitch&1) && (gWeaponUpgrade[pPlayer->curWeapon][newWeapon] || (cl_weaponswitch&2))) if (!checkFired6or7(pPlayer) && (cl_weaponswitch&1) && (gWeaponUpgrade[pPlayer->curWeapon][newWeapon] || (cl_weaponswitch&2)))
weapon = newWeapon; weapon = newWeapon;
return weapon; return weapon;
} }
@ -2015,7 +2019,7 @@ void WeaponProcess(PLAYER *pPlayer) {
} }
if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->curWeapon)) if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->curWeapon))
{ {
if (sub_4B1A4(pPlayer)) if (checkFired6or7(pPlayer))
{ {
if (pPlayer->curWeapon == 7) if (pPlayer->curWeapon == 7)
{ {
@ -2236,7 +2240,7 @@ void WeaponProcess(PLAYER *pPlayer) {
pPlayer->newWeapon = 0; pPlayer->newWeapon = 0;
return; return;
} }
if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->newWeapon) && !sub_4B1A4(pPlayer)) if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->newWeapon) && !checkFired6or7(pPlayer))
{ {
pPlayer->newWeapon = 0; pPlayer->newWeapon = 0;
return; return;