Skip to content

Commit

Permalink
MERGE PR 277
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin452 committed May 2, 2024
1 parent 8df4b1a commit a661ca2
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]": {
Expand Down
44 changes: 38 additions & 6 deletions include/text_options_strings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,33 @@
#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")
#define TEXT_OPT_METAL_CAP _("GET METAL CAP")
#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
Expand Down Expand Up @@ -178,17 +194,33 @@
#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")
#define TEXT_OPT_METAL_CAP _("Get METAL Cap")
#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
14 changes: 14 additions & 0 deletions src/game/mario_actions_airborne.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 8 additions & 0 deletions src/game/mario_actions_moving.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
38 changes: 26 additions & 12 deletions src/game/options_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand All @@ -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],
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/pc/cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct CheatList {
bool HugeMario;
bool TinyMario;
unsigned int StayInLevel;
unsigned int BLJAnywhere;
bool UnlockDoors;
bool ForeverShell;
bool ForeverCap;
Expand Down

0 comments on commit a661ca2

Please sign in to comment.