Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cheat: Stay in level after star #228

Open
wants to merge 8 commits into
base: nightly
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/text_options_strings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
#define TEXT_OPT_CHEAT7 _("EXIT COURSE AT ANY TIME")
#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)")

#else // VERSION

Expand Down Expand Up @@ -134,6 +139,11 @@
#define TEXT_OPT_CHEAT7 _("Exit course at any time")
#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)")

#endif // VERSION

Expand Down
2 changes: 1 addition & 1 deletion include/text_strings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,4 @@
#define TEXT_MENU_STARS_DE _(" GEHEIME STERNE")
#endif

#endif
#endif
12 changes: 11 additions & 1 deletion src/game/interaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "seq_ids.h"
#include "course_table.h"
#include "thread6.h"
#include "pc/cheats.h"

#define INT_GROUND_POUND_OR_TWIRL (1 << 0) // 0x01
#define INT_PUNCH (1 << 1) // 0x02
Expand Down Expand Up @@ -766,6 +767,11 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
u32 starIndex;
u32 starGrabAction = ACT_STAR_DANCE_EXIT;
u32 noExit = (o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) != 0;
u8 stayInLevelCommon = (Cheats.StayInLevel > 0 && Cheats.EnableCheats == TRUE && !(m->controller->buttonDown & L_TRIG) &&
!(gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2 || gCurrLevelNum == LEVEL_BOWSER_3));
if (Cheats.StayInLevel > 0 && stayInLevelCommon == TRUE) {
noExit = TRUE;
}
u32 grandStar = (o->oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) != 0;

if (m->health >= 0x100) {
Expand Down Expand Up @@ -825,7 +831,11 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
return set_mario_action(m, ACT_JUMBO_STAR_CUTSCENE, 0);
}

return set_mario_action(m, starGrabAction, noExit + 2 * grandStar);
if (Cheats.StayInLevel != 2 || stayInLevelCommon == FALSE) {
return set_mario_action(m, starGrabAction, noExit + 2 * grandStar);
}
//If nonstop StayInLevel is enabled, autosave
save_file_do_save(gCurrSaveFileNum - 1);
}

return FALSE;
Expand Down
8 changes: 8 additions & 0 deletions src/game/mario_actions_cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "thread6.h"
#include "../../include/libc/stdlib.h"
#include "../pc/pc_main.h"
#include "pc/cheats.h"

// TODO: put this elsewhere
enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME, SAVE_OPT_CONTINUE_DONT_SAVE };
Expand Down Expand Up @@ -645,6 +646,13 @@ void general_star_dance_handler(struct MarioState *m, s32 isInWater) {
set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, dialogID);
} else {
set_mario_action(m, isInWater ? ACT_WATER_IDLE : ACT_IDLE, 0);
if (Cheats.StayInLevel > 0 && Cheats.EnableCheats == TRUE) {
set_fov_function(CAM_FOV_DEFAULT);
// fix camera bug when getting a star underwater with StayInLevel cheat enabled
if (isInWater) {
cutscene_exit_painting_end(m->area->camera);
}
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/game/options_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ static const u8 optsCheatsStr[][64] = {
{ TEXT_OPT_CHEAT7 },
{ TEXT_OPT_CHEAT8 },
{ TEXT_OPT_CHEAT9 },
{ TEXT_OPT_CHEAT10 },
};

static const u8 optsStayInLevelStr[][32] = {
{ TEXT_CHEAT_STAY1 },
{ TEXT_CHEAT_STAY2 },
{ TEXT_CHEAT_STAY3 },
};

static const u8 bindStr[][32] = {
Expand Down Expand Up @@ -129,6 +136,12 @@ static const u8 *vsyncChoices[] = {
optsVideoStr[6],
};

static const u8 *stayInLevelChoices[] = {
optsStayInLevelStr[0],
optsStayInLevelStr[1],
optsStayInLevelStr[2],
};

enum OptType {
OPT_INVALID = 0,
OPT_TOGGLE,
Expand Down Expand Up @@ -261,6 +274,7 @@ static struct Option optsCheats[] = {
DEF_OPT_TOGGLE( optsCheatsStr[6], &Cheats.ExitAnywhere ),
DEF_OPT_TOGGLE( optsCheatsStr[7], &Cheats.HugeMario ),
DEF_OPT_TOGGLE( optsCheatsStr[8], &Cheats.TinyMario ),
DEF_OPT_CHOICE( optsCheatsStr[9], &Cheats.StayInLevel, stayInLevelChoices ),

};

Expand Down
1 change: 1 addition & 0 deletions src/pc/cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct CheatList {
bool ExitAnywhere;
bool HugeMario;
bool TinyMario;
unsigned int StayInLevel;
};

extern struct CheatList Cheats;
Expand Down