From a661ca28264c0ab173a171a9a8d821db34724532 Mon Sep 17 00:00:00 2001 From: quentin452 <42176772+quentin452@users.noreply.github.com> Date: Thu, 2 May 2024 23:07:14 +0200 Subject: [PATCH] MERGE PR 277 https://github.com/sm64pc/sm64ex/pull/277 --- .vscode/settings.json | 4 ++- include/text_options_strings.h.in | 44 ++++++++++++++++++++++++++----- src/game/mario_actions_airborne.c | 14 ++++++++++ src/game/mario_actions_moving.c | 8 ++++++ src/game/options_menu.c | 38 +++++++++++++++++--------- src/pc/cheats.h | 1 + 6 files changed, 90 insertions(+), 19 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0f0a20553..1acf4727f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -99,7 +99,9 @@ "graph_node.h": "c", "windows.h": "c", "ingame_menu.h": "c", - "stdlib.h": "c" + "stdlib.h": "c", + "cheats.h": "c", + "external.h": "c" }, "git.ignoreLimitWarning": true, "[cpp]": { diff --git a/include/text_options_strings.h.in b/include/text_options_strings.h.in index 710f14b0e..71e3e33a5 100644 --- a/include/text_options_strings.h.in +++ b/include/text_options_strings.h.in @@ -95,10 +95,8 @@ #define TEXT_OPT_CHEAT8 _("HUGE MARIO") #define TEXT_OPT_CHEAT9 _("TINY MARIO") #define TEXT_OPT_CHEAT10 _("STAY IN LEVEL AFTER STAR") -#define TEXT_CHEAT_STAY1 _("DISABLED") -#define TEXT_CHEAT_STAY2 _("ENABLED (NORMAL)") -#define TEXT_CHEAT_STAY3 _("ENABLED (NON-STOP)") #define TEXT_OPT_CHEAT11 _("NO KEYS REQUIRED") +#define TEXT_OPT_CHEAT12 _("BLJ ANYWHERE") #define TEXT_OPT_FOREVER_SHELL _("FOREVER SHELL") #define TEXT_OPT_FOREVER_CAP _("FOREVER CAP") #define TEXT_OPT_WING_CAP _("GET WING CAP") @@ -106,6 +104,24 @@ #define TEXT_OPT_VANISH_CAP _("GET VANISH CAP") #define TEXT_OPT_NORMAL_CAP _("RESET CAP") +#define TEXT_CHEAT_STAY1 _("DISABLED") +#define TEXT_CHEAT_STAY2 _("ENABLED (NORMAL)") +#define TEXT_CHEAT_STAY3 _("ENABLED (NON-STOP)") + +#define TEXT_OPT_BLJCHT1 _("DISABLED") +#define TEXT_OPT_BLJCHT2 _("ENABLED") +#define TEXT_OPT_BLJCHT3 _("ENABLED - BOOST: 1") +#define TEXT_OPT_BLJCHT4 _("ENABLED - BOOST: 2") +#define TEXT_OPT_BLJCHT5 _("ENABLED - BOOST: 3") +#define TEXT_OPT_BLJCHT6 _("ENABLED - BOOST: 4") +#define TEXT_OPT_BLJCHT7 _("ENABLED - BOOST: 5") +#define TEXT_OPT_BLJCHT8 _("RAPID FIRE") +#define TEXT_OPT_BLJCHT9 _("RAPID FIRE - BOOST: 1") +#define TEXT_OPT_BLJCHT10 _("RAPID FIRE - BOOST: 2") +#define TEXT_OPT_BLJCHT11 _("RAPID FIRE - BOOST: 3") +#define TEXT_OPT_BLJCHT12 _("RAPID FIRE - BOOST: 4") +#define TEXT_OPT_BLJCHT13 _("RAPID FIRE - BOOST: 5") + #else // VERSION // Markers @@ -178,10 +194,8 @@ #define TEXT_OPT_CHEAT8 _("Huge Mario") #define TEXT_OPT_CHEAT9 _("Tiny Mario") #define TEXT_OPT_CHEAT10 _("Stay in level after star") -#define TEXT_CHEAT_STAY1 _("Disabled") -#define TEXT_CHEAT_STAY2 _("Enabled (Normal)") -#define TEXT_CHEAT_STAY3 _("Enabled (Non-Stop)") #define TEXT_OPT_CHEAT11 _("No Keys Required") +#define TEXT_OPT_CHEAT12 _("BLJ Anywhere") #define TEXT_OPT_FOREVER_SHELL _("Forever Shell") #define TEXT_OPT_FOREVER_CAP _("Forever Cap") #define TEXT_OPT_WING_CAP _("Get WING Cap") @@ -189,6 +203,24 @@ #define TEXT_OPT_VANISH_CAP _("Get VANISH Cap") #define TEXT_OPT_NORMAL_CAP _("Reset Cap") +#define TEXT_CHEAT_STAY1 _("Disabled") +#define TEXT_CHEAT_STAY2 _("Enabled (Normal)") +#define TEXT_CHEAT_STAY3 _("Enabled (Non-Stop)") + +#define TEXT_OPT_BLJCHT1 _("Disabled") +#define TEXT_OPT_BLJCHT2 _("Enabled") +#define TEXT_OPT_BLJCHT3 _("Enabled - Boost: 1") +#define TEXT_OPT_BLJCHT4 _("Enabled - Boost: 2") +#define TEXT_OPT_BLJCHT5 _("Enabled - Boost: 3") +#define TEXT_OPT_BLJCHT6 _("Enabled - Boost: 4") +#define TEXT_OPT_BLJCHT7 _("Enabled - Boost: 5") +#define TEXT_OPT_BLJCHT8 _("Rapid Fire") +#define TEXT_OPT_BLJCHT9 _("Rapid Fire - Boost: 1") +#define TEXT_OPT_BLJCHT10 _("Rapid Fire - Boost: 2") +#define TEXT_OPT_BLJCHT11 _("Rapid Fire - Boost: 3") +#define TEXT_OPT_BLJCHT12 _("Rapid Fire - Boost: 4") +#define TEXT_OPT_BLJCHT13 _("Rapid Fire - Boost: 5") + #endif // VERSION #endif // TEXT_OPTIONS_STRINGS_H diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index dd2b9472d..786558ef5 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -15,6 +15,7 @@ #include "save_file.h" #include "thread6.h" #include "bettercamera.h" +#include "pc/cheats.h" void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3) { s32 animFrame = m->marioObj->header.gfx.unk38.animFrame; @@ -370,6 +371,19 @@ u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation, stepResult = perform_air_step(m, stepArg); switch (stepResult) { case AIR_STEP_NONE: + // BLJ anywhere cheat + if (Cheats.BLJAnywhere > 0 && Cheats.EnableCheats == TRUE && m->action == ACT_LONG_JUMP + && m->forwardVel < 1.0f && m->pos[1] - 50.0f < m->floorHeight) { + if (Cheats.BLJAnywhere < 7) { + if (m->controller->buttonPressed & A_BUTTON) { + m->forwardVel -= (Cheats.BLJAnywhere - 1) * 2.5f; + m->vel[1] = -50.0f; + } + } else if (m->controller->buttonDown & A_BUTTON) { + m->forwardVel -= (Cheats.BLJAnywhere - 7) * 2.5f; + m->vel[1] = -50.0f; + } + } set_mario_animation(m, animation); break; diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index a31c1e134..47740b7d3 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -6,6 +6,7 @@ #include "engine/math_util.h" #include "engine/surface_collision.h" #include "mario_step.h" +#include "game_init.h" #include "area.h" #include "interaction.h" #include "mario_actions_object.h" @@ -1880,6 +1881,13 @@ s32 act_long_jump_land(struct MarioState *m) { } #endif + // BLJ anywhere cheat + if (Cheats.BLJAnywhere >= 7 && Cheats.EnableCheats == TRUE && m->forwardVel < 1.0f + && (m->controller->buttonDown & A_BUTTON)) { + set_jumping_action(m, ACT_LONG_JUMP, 0); + return FALSE; + } + if (!(m->input & INPUT_Z_DOWN)) { m->input &= ~INPUT_A_PRESSED; } diff --git a/src/game/options_menu.c b/src/game/options_menu.c index d897a7b9a..cdf34fc24 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -85,11 +85,11 @@ static const u8 optsAutosaveStr[][32] = { }; static const u8 optsCheatsStr[][64] = { - { TEXT_OPT_CHEAT1 }, { TEXT_OPT_CHEAT2 }, { TEXT_OPT_CHEAT3 }, { TEXT_OPT_CHEAT4 }, - { TEXT_OPT_CHEAT5 }, { TEXT_OPT_CHEAT6 }, { TEXT_OPT_CHEAT7 }, { TEXT_OPT_CHEAT8 }, - { TEXT_OPT_CHEAT9 }, { TEXT_OPT_CHEAT10 }, { TEXT_OPT_CHEAT11 }, { TEXT_OPT_FOREVER_SHELL }, - { TEXT_OPT_FOREVER_CAP }, { TEXT_OPT_WING_CAP }, { TEXT_OPT_METAL_CAP }, { TEXT_OPT_VANISH_CAP }, - { TEXT_OPT_NORMAL_CAP }, + { TEXT_OPT_CHEAT1 }, { TEXT_OPT_CHEAT2 }, { TEXT_OPT_CHEAT3 }, { TEXT_OPT_CHEAT4 }, + { TEXT_OPT_CHEAT5 }, { TEXT_OPT_CHEAT6 }, { TEXT_OPT_CHEAT7 }, { TEXT_OPT_CHEAT8 }, + { TEXT_OPT_CHEAT9 }, { TEXT_OPT_CHEAT10 }, { TEXT_OPT_CHEAT11 }, { TEXT_OPT_CHEAT12 }, + { TEXT_OPT_FOREVER_SHELL }, { TEXT_OPT_FOREVER_CAP }, { TEXT_OPT_WING_CAP }, { TEXT_OPT_METAL_CAP }, + { TEXT_OPT_VANISH_CAP }, { TEXT_OPT_NORMAL_CAP }, }; static const u8 optsStayInLevelStr[][32] = { @@ -106,6 +106,13 @@ static const u8 bindStr[][32] = { { TEXT_OPT_DEADZONE }, { TEXT_OPT_RUMBLE }, }; +static const u8 optsBLJCheatStr[][32] = { + { TEXT_OPT_BLJCHT1 }, { TEXT_OPT_BLJCHT2 }, { TEXT_OPT_BLJCHT3 }, { TEXT_OPT_BLJCHT4 }, + { TEXT_OPT_BLJCHT5 }, { TEXT_OPT_BLJCHT6 }, { TEXT_OPT_BLJCHT7 }, { TEXT_OPT_BLJCHT8 }, + { TEXT_OPT_BLJCHT9 }, { TEXT_OPT_BLJCHT10 }, { TEXT_OPT_BLJCHT11 }, { TEXT_OPT_BLJCHT12 }, + { TEXT_OPT_BLJCHT13 }, +}; + static const u8 *filterChoices[] = { optsVideoStr[2], optsVideoStr[3], @@ -131,6 +138,13 @@ static const u8 *stayInLevelChoices[] = { optsStayInLevelStr[2], }; +static const u8 *bljCheatChoices[] = { + optsBLJCheatStr[0], optsBLJCheatStr[1], optsBLJCheatStr[2], optsBLJCheatStr[3], + optsBLJCheatStr[4], optsBLJCheatStr[5], optsBLJCheatStr[6], optsBLJCheatStr[7], + optsBLJCheatStr[8], optsBLJCheatStr[9], optsBLJCheatStr[10], optsBLJCheatStr[11], + optsBLJCheatStr[12], +}; + enum OptType { OPT_INVALID = 0, OPT_TOGGLE, @@ -281,7 +295,6 @@ static struct Option optsAudio[] = { static struct Option optsOther[] = { DEF_OPT_CHOICE(optsAutosaveStr[0], &configAutosave, autosaveChoices), }; - static struct Option optsCheats[] = { DEF_OPT_TOGGLE(optsCheatsStr[0], &Cheats.EnableCheats), DEF_OPT_TOGGLE(optsCheatsStr[1], &Cheats.MoonJump), @@ -294,12 +307,13 @@ static struct Option optsCheats[] = { DEF_OPT_TOGGLE(optsCheatsStr[8], &Cheats.TinyMario), DEF_OPT_CHOICE(optsCheatsStr[9], &Cheats.StayInLevel, stayInLevelChoices), DEF_OPT_TOGGLE(optsCheatsStr[10], &Cheats.UnlockDoors), - DEF_OPT_TOGGLE(optsCheatsStr[11], &Cheats.ForeverShell), - DEF_OPT_TOGGLE(optsCheatsStr[12], &Cheats.ForeverCap), - DEF_OPT_BUTTON(optsCheatsStr[13], setCap_Wing), - DEF_OPT_BUTTON(optsCheatsStr[14], setCap_Metal), - DEF_OPT_BUTTON(optsCheatsStr[15], setCap_Vanish), - DEF_OPT_BUTTON(optsCheatsStr[16], setCap_Normal), + DEF_OPT_CHOICE(optsCheatsStr[11], &Cheats.BLJAnywhere, bljCheatChoices), + DEF_OPT_TOGGLE(optsCheatsStr[12], &Cheats.ForeverShell), + DEF_OPT_TOGGLE(optsCheatsStr[13], &Cheats.ForeverCap), + DEF_OPT_BUTTON(optsCheatsStr[14], setCap_Wing), + DEF_OPT_BUTTON(optsCheatsStr[15], setCap_Metal), + DEF_OPT_BUTTON(optsCheatsStr[16], setCap_Vanish), + DEF_OPT_BUTTON(optsCheatsStr[17], setCap_Normal), }; /* submenu definitions */ diff --git a/src/pc/cheats.h b/src/pc/cheats.h index c07957799..b50259ee8 100644 --- a/src/pc/cheats.h +++ b/src/pc/cheats.h @@ -14,6 +14,7 @@ struct CheatList { bool HugeMario; bool TinyMario; unsigned int StayInLevel; + unsigned int BLJAnywhere; bool UnlockDoors; bool ForeverShell; bool ForeverCap;