Enabled a Cheat menu

Enabled a cheat menu. It includes 4 cheats, and all of them rely on the global "Enable cheats" option so the user can quickly turn all the selected cheats off and back on.
This commit is contained in:
Daniel 2020-05-17 22:56:06 +01:00
parent 166d1b3a73
commit 28fc53c207
5 changed files with 68 additions and 3 deletions

View File

@ -1,4 +1,4 @@
#ifndef TEXT_STRINGS_H
#ifndef TEXT_STRINGS_H
#define TEXT_STRINGS_H
#include "text_menu_strings.h"
@ -45,6 +45,13 @@
#define TEXT_BIND_LEFT _("Stick Left")
#define TEXT_BIND_RIGHT _("Stick Right")
#define TEXT_OPT_CHEATS _("CHEATS")
#define TEXT_OPT_CHEAT1 _("Enable cheats")
#define TEXT_OPT_CHEAT2 _("Moonjump (Press L)")
#define TEXT_OPT_CHEAT3 _("Invincible Mario")
#define TEXT_OPT_CHEAT4 _("Infinite lives")
#define TEXT_OPT_CHEAT5 _("Super speed")
/**
* Global Symbols
*/

View File

@ -31,6 +31,7 @@
#include "engine/surface_collision.h"
#include "level_table.h"
#include "thread6.h"
#include "pc/configfile.h"
#ifdef BETTERCAMERA
#include "bettercamera.h"
#endif
@ -1396,7 +1397,12 @@ void update_mario_inputs(struct MarioState *m) {
update_mario_geometry_inputs(m);
debug_print_speed_action_normal(m);
/* Moonjump cheat */
while (cheatMoonjump == true && cheatEnablecheats == true && m->controller->buttonDown & L_TRIG ){
m->vel[1] = 25;
break;
}
/*End of moonjump cheat */
if (gCameraMovementFlags & CAM_MOVE_C_UP_MODE) {
if (m->action & ACT_FLAG_ALLOW_FIRST_PERSON) {
m->input |= INPUT_FIRST_PERSON;
@ -1717,7 +1723,24 @@ void func_sh_8025574C(void) {
*/
s32 execute_mario_action(UNUSED struct Object *o) {
s32 inLoop = TRUE;
/**
* Cheat stuff
*/
while (cheatGodmode == true && cheatEnablecheats == true){
gMarioState->health = 0x880;
break;
}
while (cheatInfinitelives == true && cheatEnablecheats == true && gMarioState->numLives < 99){
gMarioState->numLives += 1;
break;
}
while (cheatSuperspeed == true && cheatEnablecheats == true && gMarioState->forwardVel > 0 ){
gMarioState->forwardVel += 100;
break;
}
/**
* End of cheat stuff
*/
if (gMarioState->action) {
gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
mario_reset_bodystate(gMarioState);

View File

@ -50,6 +50,8 @@ static const u8 menuStr[][32] = {
{ TEXT_OPT_VIDEO },
{ TEXT_OPT_AUDIO },
{ TEXT_EXIT_GAME },
{ TEXT_OPT_CHEATS },
};
static const u8 optsCameraStr[][32] = {
@ -75,6 +77,14 @@ static const u8 optsAudioStr[][32] = {
{ TEXT_OPT_MVOLUME },
};
static const u8 optsCheatsStr[][64] = {
{ TEXT_OPT_CHEAT1 },
{ TEXT_OPT_CHEAT2 },
{ TEXT_OPT_CHEAT3 },
{ TEXT_OPT_CHEAT4 },
{ TEXT_OPT_CHEAT5 },
};
static const u8 bindStr[][32] = {
{ TEXT_OPT_UNBOUND },
{ TEXT_OPT_PRESSKEY },
@ -207,6 +217,15 @@ static struct Option optsAudio[] = {
DEF_OPT_SCROLL( optsAudioStr[0], &configMasterVolume, 0, MAX_VOLUME, 1 ),
};
static struct Option optsCheats[] = {
DEF_OPT_TOGGLE( optsCheatsStr[0], &cheatEnablecheats ),
DEF_OPT_TOGGLE( optsCheatsStr[1], &cheatMoonjump ),
DEF_OPT_TOGGLE( optsCheatsStr[2], &cheatGodmode ),
DEF_OPT_TOGGLE( optsCheatsStr[3], &cheatInfinitelives ),
DEF_OPT_TOGGLE( optsCheatsStr[4], &cheatSuperspeed),
};
/* submenu definitions */
#ifdef BETTERCAMERA
@ -215,6 +234,7 @@ static struct SubMenu menuCamera = DEF_SUBMENU( menuStr[4], optsCamera );
static struct SubMenu menuControls = DEF_SUBMENU( menuStr[5], optsControls );
static struct SubMenu menuVideo = DEF_SUBMENU( menuStr[6], optsVideo );
static struct SubMenu menuAudio = DEF_SUBMENU( menuStr[7], optsAudio );
static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[9], optsCheats );
/* main options menu definition */
@ -226,6 +246,8 @@ static struct Option optsMain[] = {
DEF_OPT_SUBMENU( menuStr[6], &menuVideo ),
DEF_OPT_SUBMENU( menuStr[7], &menuAudio ),
DEF_OPT_BUTTON ( menuStr[8], optmenu_act_exit ),
DEF_OPT_SUBMENU( menuStr[9], &menuCheats ),
};
static struct SubMenu menuMain = DEF_SUBMENU( menuStr[3], optsMain );

View File

@ -37,6 +37,14 @@ bool configFullscreen = false;
unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point
unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME
// Cheat stuff
bool cheatEnablecheats = false;
bool cheatMoonjump = false;
bool cheatGodmode = false;
bool cheatInfinitelives = false;
bool cheatSuperspeed = false;
// Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse)
unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 };
unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1002, 0x1101 };

View File

@ -24,6 +24,11 @@ extern unsigned int configKeyStickUp[];
extern unsigned int configKeyStickDown[];
extern unsigned int configKeyStickLeft[];
extern unsigned int configKeyStickRight[];
extern bool cheatMoonjump;
extern bool cheatGodmode;
extern bool cheatEnablecheats;
extern bool cheatInfinitelives;
extern bool cheatSuperspeed;
#ifdef BETTERCAMERA
extern unsigned int configCameraXSens;
extern unsigned int configCameraYSens;