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

Add level reset cheat #402

Open
wants to merge 2 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
2 changes: 2 additions & 0 deletions include/text_options_strings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,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 _("LEVEL RESET (PRESS L)")

#else // VERSION

Expand Down Expand Up @@ -148,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 _("Level Reset (Press L)")

#endif // VERSION

Expand Down
13 changes: 13 additions & 0 deletions src/game/mario.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,19 @@ void update_mario_inputs(struct MarioState *m) {
}
/*End of moonjump cheat */

/* Level reset cheat */
if (Cheats.LevelReset
&& Cheats.EnableCheats
&& m->controller->buttonDown & L_TRIG
// Prevent crashing if there's no warp destination
&& sWarpDest.areaIdx != 0) {
m->health = 0x880;
m->numCoins = 0;
gHudDisplay.coins = 0;
sWarpDest.type = 2;
}
/* End of level reset cheat */

if (gCameraMovementFlags & CAM_MOVE_C_UP_MODE) {
if (m->action & ACT_FLAG_ALLOW_FIRST_PERSON) {
m->input |= INPUT_FIRST_PERSON;
Expand Down
13 changes: 13 additions & 0 deletions src/game/object_list_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "platform_displacement.h"
#include "profiler.h"
#include "spawn_object.h"
#include "pc/cheats.h"


/**
Expand Down Expand Up @@ -409,6 +410,18 @@ void set_object_respawn_info_bits(struct Object *obj, u8 bits) {
u32 *info32;
u16 *info16;

/* Level reset cheat */
/*
* Force objects to respawn on level reset
*
* NOTE: This forces objects to respawn in cases where they wouldn't with
* the cheat disabled. The GameShark code also has this problem.
*/
if (Cheats.LevelReset && Cheats.EnableCheats) {
return;
}
/* End of level reset cheat */

switch (obj->respawnInfoType) {
case RESPAWN_INFO_TYPE_32:
info32 = (u32 *) obj->respawnInfo;
Expand Down
2 changes: 2 additions & 0 deletions src/game/options_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static const u8 optsCheatsStr[][64] = {
{ TEXT_OPT_CHEAT7 },
{ TEXT_OPT_CHEAT8 },
{ TEXT_OPT_CHEAT9 },
{ TEXT_OPT_CHEAT10 },
};

static const u8 bindStr[][32] = {
Expand Down Expand Up @@ -279,6 +280,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.LevelReset ),

};

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;
bool LevelReset;
};

extern struct CheatList Cheats;
Expand Down