diff --git a/include/text_options_strings.h.in b/include/text_options_strings.h.in index 8c6732e4..fa178b37 100644 --- a/include/text_options_strings.h.in +++ b/include/text_options_strings.h.in @@ -149,6 +149,7 @@ #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 _("No Keys Required") #endif // VERSION diff --git a/src/game/interaction.c b/src/game/interaction.c index 7a9c5203..f7b19f2c 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -23,6 +23,7 @@ #include "sm64.h" #include "sound_init.h" #include "thread6.h" +#include "pc/cheats.h" #define INT_GROUND_POUND_OR_TWIRL (1 << 0) // 0x01 #define INT_PUNCH (1 << 1) // 0x02 @@ -893,6 +894,11 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj u32 actionArg; if (m->action == ACT_WALKING || m->action == ACT_DECELERATING) { + if (Cheats.EnableCheats && Cheats.UnlockDoors) { + /* If the unlock doors cheat is enabled, skip key checks */ + goto postkeycheck; + } + if (warpDoorId == 1 && !(saveFlags & SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR)) { if (!(saveFlags & SAVE_FLAG_HAVE_KEY_2)) { if (!sDisplayingDoorText) { @@ -922,6 +928,7 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj doorAction = ACT_UNLOCKING_KEY_DOOR; } +postkeycheck: if (m->action == ACT_WALKING || m->action == ACT_DECELERATING) { actionArg = should_push_or_pull_door(m, o) + 0x00000004; @@ -987,7 +994,27 @@ u32 interact_door(struct MarioState *m, UNUSED u32 interactType, struct Object * s16 numStars = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1); if (m->action == ACT_WALKING || m->action == ACT_DECELERATING) { - if (numStars >= requiredNumStars) { + if (Cheats.EnableCheats && Cheats.UnlockDoors) { + /* If the UnlockDoors Cheat is enabled, it's the same as the approach with >= requiredNumStars, + * but never use the action that 'unlocks' the door for the save file */ + u32 actionArg = should_push_or_pull_door(m, o); + u32 enterDoorAction; + + if (actionArg & 0x00000001) { + enterDoorAction = ACT_PULLING_DOOR; + } else { + enterDoorAction = ACT_PUSHING_DOOR; + } + + m->interactObj = o; + m->usedObj = o; + + if (o->oInteractionSubtype & INT_SUBTYPE_STAR_DOOR) { + enterDoorAction = ACT_ENTERING_STAR_DOOR; + } + + return set_mario_action(m, enterDoorAction, actionArg); + } else if (numStars >= requiredNumStars) { u32 actionArg = should_push_or_pull_door(m, o); u32 enterDoorAction; u32 doorSaveFileFlag; diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 56ebdebe..b6bb118e 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -105,6 +105,7 @@ static const u8 optsCheatsStr[][64] = { { TEXT_OPT_CHEAT7 }, { TEXT_OPT_CHEAT8 }, { TEXT_OPT_CHEAT9 }, + { TEXT_OPT_CHEAT10 }, }; static const u8 bindStr[][32] = { @@ -282,6 +283,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_TOGGLE( optsCheatsStr[9], &Cheats.UnlockDoors ), }; diff --git a/src/pc/cheats.h b/src/pc/cheats.h index eaf71ab4..f515cdfa 100644 --- a/src/pc/cheats.h +++ b/src/pc/cheats.h @@ -13,6 +13,7 @@ struct CheatList { bool ExitAnywhere; bool HugeMario; bool TinyMario; + bool UnlockDoors; }; extern struct CheatList Cheats;