diff --git a/src/game/interaction.c b/src/game/interaction.c index 999416cb..87b5fdc9 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -29,6 +29,7 @@ #include "pc/configfile.h" #include "pc/network/network.h" #include "pc/lua/smlua_hooks.h" +#include "pc/cheats.h" enum InteractionFlag { INT_GROUND_POUND_OR_TWIRL = (1 << 0), // 0x01 @@ -2249,7 +2250,7 @@ void check_death_barrier(struct MarioState *m) { } void check_lava_boost(struct MarioState *m) { - if (m->action == ACT_BUBBLED) { return; } + if (m->action == ACT_BUBBLED || (Cheats.enabled && Cheats.godMode)) { return; } if (!(m->action & ACT_FLAG_RIDING_SHELL) && m->pos[1] < m->floorHeight + 10.0f) { if (!(m->flags & MARIO_METAL_CAP)) { m->hurtCounter += (m->flags & MARIO_CAP_ON_HEAD) ? 12 : 18; diff --git a/src/game/mario.c b/src/game/mario.c index 5d8cad2a..057c2622 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1542,12 +1542,11 @@ void update_mario_inputs(struct MarioState *m) { debug_print_speed_action_normal(m); - /* Moonjump cheat */ - while (Cheats.MoonJump == true && Cheats.EnableCheats == true && m->controller->buttonDown & L_TRIG ){ - m->vel[1] = 25; - break; // TODO: Unneeded break? + if (Cheats.enabled && Cheats.moonJump && m->controller->buttonDown & L_TRIG) { + set_mario_action(m, ACT_FREEFALL, 0); + m->faceAngle[1] = m->intendedYaw - approach_s32((s16)(m->intendedYaw - m->faceAngle[1]), 0, 0x800, 0x800); + m->vel[1] = 30; } - /*End of moonjump cheat */ /* Developer stuff */ #ifdef DEVELOPMENT @@ -1874,7 +1873,7 @@ static void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capM } } -void func_sh_8025574C(void) { +void queue_particle_rumble(void) { if (gMarioState->particleFlags & PARTICLE_HORIZONTAL_STAR) { queue_rumble_data_mario(gMarioState, 5, 80); } else if (gMarioState->particleFlags & PARTICLE_VERTICAL_STAR) { @@ -1992,22 +1991,13 @@ s32 execute_mario_action(UNUSED struct Object *o) { } } - /** - * Cheat stuff - */ - if (Cheats.EnableCheats) { - if (Cheats.GodMode) - gMarioState->health = 0x880; + if (Cheats.enabled) { + if (Cheats.godMode) { gMarioState->health = 0x880; } - if (Cheats.InfiniteLives && gMarioState->numLives < 99) - gMarioState->numLives += 1; + if (Cheats.infiniteLives && gMarioState->numLives < 100) { gMarioState->numLives = 100; } - if (Cheats.SuperSpeed && gMarioState->controller->stickMag > 0.5f) - gMarioState->forwardVel += 100; + if (Cheats.superSpeed && gMarioState->controller->stickMag > 0.5f) { gMarioState->forwardVel += 100; } } - /** - * End of cheat stuff - */ if (gMarioState->action) { if (gMarioState->action != ACT_BUBBLED) { @@ -2122,7 +2112,7 @@ s32 execute_mario_action(UNUSED struct Object *o) { play_infinite_stairs_music(); gMarioState->marioObj->oInteractStatus = 0; - func_sh_8025574C(); + queue_particle_rumble(); return gMarioState->particleFlags; } diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index bec7eacd..98d61a63 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -22,6 +22,7 @@ #include "pc/configfile.h" #include "pc/network/network.h" #include "pc/lua/smlua.h" +#include "pc/cheats.h" void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3) { s32 animFrame = m->marioObj->header.gfx.animInfo.animFrame; @@ -68,6 +69,8 @@ s32 lava_boost_on_wall(struct MarioState *m) { } s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) { + if (Cheats.enabled && Cheats.godMode) { return FALSE; } + f32 fallHeight; f32 damageHeight; diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 88154e00..4a9831f7 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -467,13 +467,11 @@ void update_walking_speed(struct MarioState *m) { m->forwardVel = 48.0f; } - /* Handles the "Super responsive controls" cheat. The content of the "else" is Mario's original code for turning around.*/ - - if (Cheats.Responsive == true && Cheats.EnableCheats == true ) { + // handles the "Super responsive controls" cheat. The content of the "else" is Mario's original code for turning around. + if (Cheats.enabled && Cheats.responsive) { m->faceAngle[1] = m->intendedYaw; - } - else { - m->faceAngle[1] = m->intendedYaw - approach_s32((s16)(m->intendedYaw - m->faceAngle[1]), 0, 0x800, 0x800); + } else { + m->faceAngle[1] = m->intendedYaw - approach_s32((s16)(m->intendedYaw - m->faceAngle[1]), 0, 0x800, 0x800); } apply_slope_accel(m); } diff --git a/src/game/mario_step.c b/src/game/mario_step.c index ba1507b1..a1e1d921 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -10,6 +10,7 @@ #include "mario_step.h" #include "pc/lua/smlua.h" #include "game/hardcoded.h" +#include "pc/cheats.h" static s16 sMovingSandSpeeds[] = { 12, 8, 4, 0 }; @@ -108,7 +109,7 @@ void mario_bonk_reflection(struct MarioState *m, u32 negateSpeed) { } u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed) { - if (m->action & ACT_FLAG_RIDING_SHELL) { + if (m->action & ACT_FLAG_RIDING_SHELL || (Cheats.enabled && Cheats.godMode)) { m->quicksandDepth = 0.0f; } else { if (m->quicksandDepth < 1.1f) { diff --git a/src/pc/cheats.h b/src/pc/cheats.h index 531c392f..0bf1ab42 100644 --- a/src/pc/cheats.h +++ b/src/pc/cheats.h @@ -4,12 +4,12 @@ #include struct CheatList { - bool EnableCheats; - bool MoonJump; - bool GodMode; - bool InfiniteLives; - bool SuperSpeed; - bool Responsive; + bool enabled; + bool moonJump; + bool godMode; + bool infiniteLives; + bool superSpeed; + bool responsive; }; extern struct CheatList Cheats; diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index 6f076659..5b337fa7 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -67,7 +67,7 @@ void parse_cli_opts(int argc, char* argv[]) { arg_uint("--client ", argv[++i], &gCLIOpts.NetworkPort); } else if (strcmp(argv[i], "--cheats") == 0) // Enable cheats menu - Cheats.EnableCheats = true; + Cheats.enabled = true; else if (strcmp(argv[i], "--poolsize") == 0) // Main pool size arg_uint("--poolsize", argv[++i], &gCLIOpts.PoolSize); diff --git a/src/pc/djui/djui_panel_cheats.c b/src/pc/djui/djui_panel_cheats.c index ee4b2de4..3d3d0c8d 100644 --- a/src/pc/djui/djui_panel_cheats.c +++ b/src/pc/djui/djui_panel_cheats.c @@ -10,28 +10,28 @@ void djui_panel_cheats_create(struct DjuiBase* caller) { { { - struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Moon jump", &Cheats.MoonJump); + struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Moon jump", &Cheats.moonJump); djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&checkbox->base, 1.0f, 32); defaultBase = &checkbox->base; } { - struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "God mode", &Cheats.GodMode); + struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "God mode", &Cheats.godMode); djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&checkbox->base, 1.0f, 32); } { - struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Infinite lives", &Cheats.InfiniteLives); + struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Infinite lives", &Cheats.infiniteLives); djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&checkbox->base, 1.0f, 32); } { - struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Super speed", &Cheats.SuperSpeed); + struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Super speed", &Cheats.superSpeed); djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&checkbox->base, 1.0f, 32); } { - struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Responsive controls", &Cheats.Responsive); + struct DjuiCheckbox* checkbox = djui_checkbox_create(&body->base, "Responsive controls", &Cheats.responsive); djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&checkbox->base, 1.0f, 32); } diff --git a/src/pc/djui/djui_panel_pause.c b/src/pc/djui/djui_panel_pause.c index e41a605d..405209b6 100644 --- a/src/pc/djui/djui_panel_pause.c +++ b/src/pc/djui/djui_panel_pause.c @@ -36,7 +36,7 @@ void djui_panel_pause_create(struct DjuiBase* caller) { if (gDjuiChatBoxFocus) { djui_chat_box_toggle(); } f32 bodyHeight = 64 * 5 + 16 * 4; - if (Cheats.EnableCheats) { bodyHeight += 64 + 16; } + if (Cheats.enabled) { bodyHeight += 64 + 16; } struct DjuiBase* defaultBase = NULL; struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\P\\#1be700\\A\\#00b3ff\\U\\#ffef00\\S\\#ff0800\\E"); @@ -66,7 +66,7 @@ void djui_panel_pause_create(struct DjuiBase* caller) { djui_interactable_hook_click(&button1->base, djui_panel_options_create); defaultBase = &button1->base; - if (Cheats.EnableCheats) { + if (Cheats.enabled) { struct DjuiButton* button1 = djui_button_create(&body->base, "Cheats"); djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&button1->base, 1.0f, 64); diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 4cdaad71..13d78c00 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -101,7 +101,7 @@ bool network_init(enum NetworkType inNetworkType) { #else gServerSettings.headlessServer = 0; #endif - Cheats.EnableCheats = gServerSettings.enableCheats; + Cheats.enabled = gServerSettings.enableCheats; // initialize the network system gNetworkSentJoin = false; diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 413a9635..ccb728a8 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -174,7 +174,7 @@ void network_receive_join(struct Packet* p) { packet_read(p, eeprom, sizeof(u8) * 512); packet_read(p, &modCount, sizeof(u8)); - Cheats.EnableCheats = gServerSettings.enableCheats; + Cheats.enabled = gServerSettings.enableCheats; struct StringLinkedList head = { 0 }; for (s32 i = 0; i < modCount; i++) {