From 798fbf7b90d909b73272cad9a769e8025ba85f42 Mon Sep 17 00:00:00 2001 From: Not actually throwaway <98854201+throwaway29292@users.noreply.github.com> Date: Wed, 1 May 2024 17:55:22 +0200 Subject: [PATCH 1/2] Add a cheat to allow dual-wielding all guns. The cheat's name is "Gameplay/(Two-Handed)" --- src/game/cheats.c | 13 +++++++++++++ src/game/game_0b0fd0.c | 7 ++++++- src/game/inv.c | 11 +++++++++++ src/include/constants.h | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/game/cheats.c b/src/game/cheats.c index 71ac21ca8..260a390b3 100644 --- a/src/game/cheats.c +++ b/src/game/cheats.c @@ -100,6 +100,9 @@ struct cheat g_Cheats[] = { { L_MPWEAPONS_114, WEAPON_DMC, 0, 0, CHEATFLAG_FIRINGRANGE }, // DMC { L_MPWEAPONS_115, WEAPON_AR53, 0, 0, CHEATFLAG_FIRINGRANGE }, // AR53 { L_MPWEAPONS_116, WEAPON_RCP45, 0, 0, CHEATFLAG_FIRINGRANGE }, // RC-P45 +#ifndef PLATFORM_N64 + { L_MPWEAPONS_215, 0, SOLOSTAGEINDEX_EXTRACTION, DIFF_A, CHEATFLAG_COMPLETION }, // dual wield all guns cheat +#endif }; u32 cheatIsUnlocked(s32 cheat_id) @@ -1090,6 +1093,16 @@ struct menuitem g_CheatsGameplayMenuItems[] = { 0, cheatCheckboxMenuHandler, }, +#ifndef PLATFORM_N64 + { + MENUITEMTYPE_CHECKBOX, + CHEAT_DUALWIELDALLGUNS, + 0, + (uintptr_t)&cheatGetNameIfUnlocked, + 0, + cheatCheckboxMenuHandler, + }, +#endif { MENUITEMTYPE_SEPARATOR, 0, diff --git a/src/game/game_0b0fd0.c b/src/game/game_0b0fd0.c index 719959461..d30a54946 100644 --- a/src/game/game_0b0fd0.c +++ b/src/game/game_0b0fd0.c @@ -286,7 +286,12 @@ void currentPlayerZoomIn(f32 fovpersec) bool weaponHasFlag(s32 itemid, u32 flag) { struct weapon *weapon = weaponFindById(itemid); - +#ifndef PLATFORM_N64 //always return, that weapon is dual-wieldable if player sets the cheat. + if (cheatIsActive(CHEAT_DUALWIELDALLGUNS) && (flag == WEAPONFLAG_DUALWIELD)) + { + return true; + } +#endif if (!weapon) { return false; } diff --git a/src/game/inv.c b/src/game/inv.c index 825e21fe9..3cba713e1 100644 --- a/src/game/inv.c +++ b/src/game/inv.c @@ -510,6 +510,17 @@ s32 invGiveWeaponsByProp(struct prop *prop) weapon = prop->weapon; weaponnum = weapon->weaponnum; otherweaponnum; +#ifndef PLATFORM_N64 + //This piece of code makes the cheat work in singleplayer. + if (cheatIsActive(CHEAT_DUALWIELDALLGUNS) && !g_Vars.normmplayerisrunning) + { + if(invHasSingleWeaponExcAllGuns(weaponnum) && (invHasDoubleWeaponExcAllGuns(weapon->weaponnum, weapon->weaponnum)==0)) + { + invGiveDoubleWeapon(weaponnum, weaponnum); + numgiven = 2; + } + } +#endif if (cheatIsActive(CHEAT_PERFECTDARKNESS) && weaponnum == WEAPON_NIGHTVISION) { return 1; diff --git a/src/include/constants.h b/src/include/constants.h index e51ec894a..22b5edc10 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -449,6 +449,7 @@ #define CHEAT_DMC 39 #define CHEAT_AR53 40 #define CHEAT_RCP45 41 +#define CHEAT_DUALWIELDALLGUNS 42 #define CHEATFLAG_TIMED 0 #define CHEATFLAG_ALWAYSON 1 From d8a26fa2211d9ffeead8894a23ca3b4f1b2be0dd Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 14 May 2024 10:56:50 +0200 Subject: [PATCH 2/2] port: clean up whitespace --- src/game/cheats.c | 2 +- src/game/game_0b0fd0.c | 14 ++++++++------ src/game/inv.c | 14 +++++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/game/cheats.c b/src/game/cheats.c index 260a390b3..4567f5e30 100644 --- a/src/game/cheats.c +++ b/src/game/cheats.c @@ -101,7 +101,7 @@ struct cheat g_Cheats[] = { { L_MPWEAPONS_115, WEAPON_AR53, 0, 0, CHEATFLAG_FIRINGRANGE }, // AR53 { L_MPWEAPONS_116, WEAPON_RCP45, 0, 0, CHEATFLAG_FIRINGRANGE }, // RC-P45 #ifndef PLATFORM_N64 - { L_MPWEAPONS_215, 0, SOLOSTAGEINDEX_EXTRACTION, DIFF_A, CHEATFLAG_COMPLETION }, // dual wield all guns cheat + { L_MPWEAPONS_215, 0, SOLOSTAGEINDEX_EXTRACTION, DIFF_A, CHEATFLAG_COMPLETION }, // Dual wield all guns #endif }; diff --git a/src/game/game_0b0fd0.c b/src/game/game_0b0fd0.c index d30a54946..3747c37a4 100644 --- a/src/game/game_0b0fd0.c +++ b/src/game/game_0b0fd0.c @@ -286,16 +286,18 @@ void currentPlayerZoomIn(f32 fovpersec) bool weaponHasFlag(s32 itemid, u32 flag) { struct weapon *weapon = weaponFindById(itemid); -#ifndef PLATFORM_N64 //always return, that weapon is dual-wieldable if player sets the cheat. - if (cheatIsActive(CHEAT_DUALWIELDALLGUNS) && (flag == WEAPONFLAG_DUALWIELD)) - { - return true; - } -#endif + if (!weapon) { return false; } +#ifndef PLATFORM_N64 + // always dual-wieldable if cheat is enabled + if (cheatIsActive(CHEAT_DUALWIELDALLGUNS) && (flag == WEAPONFLAG_DUALWIELD)) { + return true; + } +#endif + return (weapon->flags & flag) != 0; } diff --git a/src/game/inv.c b/src/game/inv.c index 3cba713e1..04fce4a8a 100644 --- a/src/game/inv.c +++ b/src/game/inv.c @@ -510,14 +510,14 @@ s32 invGiveWeaponsByProp(struct prop *prop) weapon = prop->weapon; weaponnum = weapon->weaponnum; otherweaponnum; + #ifndef PLATFORM_N64 - //This piece of code makes the cheat work in singleplayer. - if (cheatIsActive(CHEAT_DUALWIELDALLGUNS) && !g_Vars.normmplayerisrunning) - { - if(invHasSingleWeaponExcAllGuns(weaponnum) && (invHasDoubleWeaponExcAllGuns(weapon->weaponnum, weapon->weaponnum)==0)) - { - invGiveDoubleWeapon(weaponnum, weaponnum); - numgiven = 2; + // always allow picking up a second gun if dual wield cheat is on + if (!g_Vars.normmplayerisrunning && cheatIsActive(CHEAT_DUALWIELDALLGUNS)) { + if (invHasSingleWeaponExcAllGuns(weaponnum) && !invHasDoubleWeaponExcAllGuns(weaponnum, weaponnum)) { + if (invGiveDoubleWeapon(weaponnum, weaponnum)) { + return 2; + } } } #endif