Add cheat to remove star/key requirements on doors

This commit is contained in:
DimensionWarped 2020-05-26 18:30:19 -05:00
parent e3401f1547
commit 3e332f4c98
4 changed files with 32 additions and 1 deletions

View File

@ -132,6 +132,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

View File

@ -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
@ -904,6 +905,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) {
@ -933,6 +939,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;
@ -998,7 +1005,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;

View File

@ -96,6 +96,7 @@ static const u8 optsCheatsStr[][64] = {
{ TEXT_OPT_CHEAT7 },
{ TEXT_OPT_CHEAT8 },
{ TEXT_OPT_CHEAT9 },
{ TEXT_OPT_CHEAT10 },
};
static const u8 bindStr[][32] = {
@ -257,6 +258,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 ),
};

View File

@ -13,6 +13,7 @@ struct CheatList {
bool ExitAnywhere;
bool HugeMario;
bool TinyMario;
bool UnlockDoors;
};
extern struct CheatList Cheats;