From 3be1aa71ee2b028ceaafd221a33f14ea7ef08917 Mon Sep 17 00:00:00 2001 From: Llennpie <44985633+Llennpie@users.noreply.github.com> Date: Fri, 24 Dec 2021 20:50:18 -0500 Subject: [PATCH] Add Mario scale modifier, other cheats to UI --- src/game/mario.c | 11 +++++----- src/game/mario.h | 2 ++ src/moon/imgui/imgui_impl.cpp | 21 ++++++++++++++----- src/moon/saturn/saturn.cpp | 7 ++++++- .../ui/screens/options/categories/mcheats.cpp | 4 ++-- src/pc/cheats.h | 3 +-- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/game/mario.c b/src/game/mario.c index 8a256404..c7dac42c 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1210,6 +1210,8 @@ s32 set_water_plunge_action(struct MarioState *m) { u8 sSquishScaleOverTime[16] = { 0x46, 0x32, 0x32, 0x3C, 0x46, 0x50, 0x50, 0x3C, 0x28, 0x14, 0x14, 0x1E, 0x32, 0x3C, 0x3C, 0x28 }; +float mario_scale_size = 2.5f; + /** * Applies the squish to Mario's model via scaling. */ @@ -1219,11 +1221,8 @@ void squish_mario_model(struct MarioState *m) { // Also handles the Tiny Mario and Huge Mario cheats. if (m->squishTimer == 0) { if (Cheats.EnableCheats) { - if (Cheats.HugeMario) { - vec3f_set(m->marioObj->header.gfx.scale, 2.5f, 2.5f, 2.5f); - } - else if (Cheats.TinyMario) { - vec3f_set(m->marioObj->header.gfx.scale, 0.2f, 0.2f, 0.2f); + if (Cheats.ScaleMario) { + vec3f_set(m->marioObj->header.gfx.scale, mario_scale_size, mario_scale_size, mario_scale_size); } else { vec3f_set(m->marioObj->header.gfx.scale, 1.0f, 1.0f, 1.0f); @@ -1757,7 +1756,7 @@ s32 execute_mario_action(UNUSED struct Object *o) { if (Cheats.GodMode) gMarioState->health = 0x880; - if (Cheats.InfiniteLives && gMarioState->numLives < 99) + if (Cheats.InfiniteLives && gMarioState->numLives < 4) gMarioState->numLives += 1; if (Cheats.SuperSpeed && gMarioState->forwardVel > 0) diff --git a/src/game/mario.h b/src/game/mario.h index 0859fb81..07a09043 100644 --- a/src/game/mario.h +++ b/src/game/mario.h @@ -55,4 +55,6 @@ extern int current_cap_state; extern int current_eye_state; extern int current_hand_state; +extern float mario_scale_size; + #endif // MARIO_H diff --git a/src/moon/imgui/imgui_impl.cpp b/src/moon/imgui/imgui_impl.cpp index f8cdc9c9..135413f0 100644 --- a/src/moon/imgui/imgui_impl.cpp +++ b/src/moon/imgui/imgui_impl.cpp @@ -22,6 +22,7 @@ #include "moon/utils/moon-env.h" #include "pc/controller/controller_keyboard.h" #include "moon/ui/screens/addons/addons-view.h" +#include "pc/cheats.h" #include @@ -494,10 +495,6 @@ namespace MoonInternal { ImGui::Dummy(ImVec2(0, 5)); - ImGui::Checkbox("God Mode", &enable_god); - - ImGui::Dummy(ImVec2(0, 5)); - const char* levelList[] = { "Castle Grounds", "Castle Inside", "Bob-omb Battlefield", "Whomp's Fortress", "Princess's Secret Slide", "Tower of the Wing Cap", @@ -508,7 +505,8 @@ namespace MoonInternal { "Snowman's Land", "Wet-Dry World", "Tall, Tall Mountain", "Tiny, Huge Island", "Tick Tock Clock", "Wing Mario Over the Rainbow", "Rainbow Ride", "Bowser in the Sky" }; - ImGui::Combo("Level", ¤t_level_sel, levelList, IM_ARRAYSIZE(levelList)); + ImGui::Text("Warp to Level"); + ImGui::Combo("###warp_to_level", ¤t_level_sel, levelList, IM_ARRAYSIZE(levelList)); if (ImGui::Button("Warp")) { switch (current_level_sel) { @@ -598,6 +596,19 @@ namespace MoonInternal { ImGui::Dummy(ImVec2(0, 5)); + if (ImGui::CollapsingHeader("Cheats")) { + ImGui::Checkbox("God Mode", &enable_god); // agent x version better!!! + ImGui::Checkbox("Infinite Lives", &Cheats.InfiniteLives); + ImGui::Checkbox("Moon Jump", &Cheats.MoonJump); ImGui::SameLine(); HelpMarker( + "Hold L in mid-air to Moon Jump!"); + ImGui::Checkbox("Responsive Controls", &Cheats.Responsive); + ImGui::Checkbox("Super Speed", &Cheats.SuperSpeed); + ImGui::Checkbox("Custom Mario Scale", &Cheats.ScaleMario); + if (Cheats.ScaleMario) { + ImGui::SliderFloat("Scale ###mario_scale", &mario_scale_size, 0.2f, 5.0f); + } + } + /* const char* skyStates[] = { "Default", "Night", "Green", "Blue", "Pink"}; ImGui::Combo("Skybox", &selected_sky_item, skyStates, IM_ARRAYSIZE(skyStates)); diff --git a/src/moon/saturn/saturn.cpp b/src/moon/saturn/saturn.cpp index 7607b0e0..3ce3efa6 100644 --- a/src/moon/saturn/saturn.cpp +++ b/src/moon/saturn/saturn.cpp @@ -30,6 +30,7 @@ extern "C" { #include "sm64.h" #include "game/behavior_actions.h" #include "game/behaviors/yoshi.inc.h" +#include "pc/cheats.h" } bool camera_frozen; @@ -71,9 +72,13 @@ namespace MoonInternal { camera_frozen = false; enable_shadows = true; - enable_god = false; + enable_god = true; enable_yoshi = false; + Cheats.EnableCheats = true; + Cheats.InfiniteLives = true; + Cheats.ExitAnywhere = true; + MoonInternal::load_cc_directory(); MoonInternal::load_cc_file(cc_array[configColorCode]); apply_editor_from_cc(); diff --git a/src/moon/ui/screens/options/categories/mcheats.cpp b/src/moon/ui/screens/options/categories/mcheats.cpp index 3d310b6a..ef9dd773 100644 --- a/src/moon/ui/screens/options/categories/mcheats.cpp +++ b/src/moon/ui/screens/options/categories/mcheats.cpp @@ -17,6 +17,6 @@ MCheatsCategory::MCheatsCategory() : MoonCategory("TEXT_OPT_CHEATS"){ this->catOptions.push_back(new MWValue(22, 125, "TEXT_OPT_CHEAT5", {.bvar = &Cheats.SuperSpeed }, true)); this->catOptions.push_back(new MWValue(22, 142, "TEXT_OPT_CHEAT6", {.bvar = &Cheats.Responsive }, true)); this->catOptions.push_back(new MWValue(22, 159, "TEXT_OPT_CHEAT7", {.bvar = &Cheats.ExitAnywhere }, true)); - this->catOptions.push_back(new MWValue(22, 176, "TEXT_OPT_CHEAT8", {.bvar = &Cheats.HugeMario }, true)); - this->catOptions.push_back(new MWValue(22, 193, "TEXT_OPT_CHEAT9", {.bvar = &Cheats.TinyMario }, true)); + //this->catOptions.push_back(new MWValue(22, 176, "TEXT_OPT_CHEAT8", {.bvar = &Cheats.HugeMario }, true)); + //this->catOptions.push_back(new MWValue(22, 193, "TEXT_OPT_CHEAT9", {.bvar = &Cheats.TinyMario }, true)); } \ No newline at end of file diff --git a/src/pc/cheats.h b/src/pc/cheats.h index eaf71ab4..ecbfcfcb 100644 --- a/src/pc/cheats.h +++ b/src/pc/cheats.h @@ -11,8 +11,7 @@ struct CheatList { bool SuperSpeed; bool Responsive; bool ExitAnywhere; - bool HugeMario; - bool TinyMario; + bool ScaleMario; }; extern struct CheatList Cheats;