From 626b5937ce43a877f0bba87275d045950c254e45 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 26 Nov 2023 20:32:46 +0100 Subject: [PATCH] port: possibly fix reloading and some altmodes in N64 schemes --- src/game/bondgun.c | 34 ++++++++++++++++++++++++++++------ src/game/bondmove.c | 3 ++- src/game/lv.c | 31 +++++++++++++++++++------------ 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/game/bondgun.c b/src/game/bondgun.c index b614d2c33..b63ab0d2c 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -11719,25 +11719,43 @@ void bgunSetTriggerOn(s32 handnum, bool on) */ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu, bool fromdedicatedbutton) { +#ifndef PLATFORM_N64 + const bool extcontrols = PLAYER_EXTCFG().extcontrols; +#endif switch (bgunGetWeaponNum(HAND_RIGHT)) { case WEAPON_SNIPERRIFLE: - if (usedowntime < 0) { + if (extcontrols && usedowntime < 0) { return USETIMER_CONTINUE; } - // g_Vars.currentplayer->gunctrl.invertgunfunc = !g_Vars.currentplayer->gunctrl.invertgunfunc; + + // At 25 ticks (or B+Z), start showing the new function g_Vars.currentplayer->gunctrl.invertgunfunc = true; // B+Z immediately triggers crouch or stand if (trigpressed) { - g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; + if (extcontrols) { + g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; + } return USETIMER_STOP; } + if (fromdedicatedbutton) { g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; return USETIMER_CONTINUE; } - if (ABS(usedowntime) < 0) { +#ifndef PLATFORM_N64 + bool docontinue; + if (extcontrols) { + docontinue = (ABS(usedowntime) < 0); + } else { + // Don't do anything if B hasn't been held for 50/60ths of a second + docontinue = (usedowntime < TICKS(50)); + } + if (docontinue) { +#else + if (usedowntime < TICKS(50)) { +#endif return USETIMER_CONTINUE; } @@ -11747,13 +11765,17 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac // Do crouch or stand g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; - return USETIMER_STOP; + return (extcontrols ? USETIMER_STOP : USETIMER_REPEAT); case WEAPON_RCP120: case WEAPON_LAPTOPGUN: case WEAPON_DRAGON: case WEAPON_REMOTEMINE: // These weapons use temporary alt functions - g_Vars.currentplayer->gunctrl.invertgunfunc = !g_Vars.currentplayer->gunctrl.invertgunfunc; + if (extcontrols) { + g_Vars.currentplayer->gunctrl.invertgunfunc = !g_Vars.currentplayer->gunctrl.invertgunfunc; + } else { + g_Vars.currentplayer->gunctrl.invertgunfunc = true; + } if (fromactivemenu && bgunIsUsingSecondaryFunction() == true) { g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 5718ac203..da6886b12 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1806,7 +1806,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (controlmode == CONTROLMODE_PC) { g_Vars.currentplayer->bondactivateorreload = g_Vars.currentplayer->bondactivateorreload | JO_ACTION_ACTIVATE; } else { - g_Vars.currentplayer->bondactivateorreload = movedata.btapcount; + g_Vars.currentplayer->bondactivateorreload = movedata.btapcount ? + (g_Vars.currentplayer->bondactivateorreload | JO_ACTION_ACTIVATE | JO_ACTION_RELOAD) : 0; } bmoveHandleActivate(); diff --git a/src/game/lv.c b/src/game/lv.c index e100aeda9..1c746b77d 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -1287,23 +1287,30 @@ Gfx *lvRender(Gfx *gdl) } // Handle opening doors and reloading - if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_RELOAD) { - if (g_Vars.currentplayer->hands[HAND_RIGHT].state != HANDSTATE_RELOAD) { - bgunReloadIfPossible(HAND_RIGHT); - } - - if (g_Vars.currentplayer->hands[HAND_LEFT].state != HANDSTATE_RELOAD) { - bgunReloadIfPossible(HAND_LEFT); - } - - g_Vars.currentplayer->bondactivateorreload = (g_Vars.currentplayer->bondactivateorreload & ~JO_ACTION_RELOAD) | (g_Vars.currentplayer->bondactivateorreload & 0x0); - } if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_ACTIVATE) { - currentPlayerInteract(false); + if (!currentPlayerInteract(false)) { +#ifndef PLATFORM_N64 + // n64 behavior: interact sucessful, cancel reload + if (!PLAYER_EXTCFG().extcontrols) { + g_Vars.currentplayer->bondactivateorreload = (g_Vars.currentplayer->bondactivateorreload & ~JO_ACTION_RELOAD); + } +#endif + } } else if (g_Vars.currentplayer->eyespy && g_Vars.currentplayer->eyespy->active && g_Vars.currentplayer->eyespy->opendoor) { currentPlayerInteract(true); + g_Vars.currentplayer->bondactivateorreload = (g_Vars.currentplayer->bondactivateorreload & ~JO_ACTION_RELOAD); + } + + if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_RELOAD) { + if (g_Vars.currentplayer->hands[HAND_RIGHT].state != HANDSTATE_RELOAD) { + bgunReloadIfPossible(HAND_RIGHT); + } + if (g_Vars.currentplayer->hands[HAND_LEFT].state != HANDSTATE_RELOAD) { + bgunReloadIfPossible(HAND_LEFT); + } + g_Vars.currentplayer->bondactivateorreload = (g_Vars.currentplayer->bondactivateorreload & ~JO_ACTION_RELOAD); } propsTestForPickup();