From fe6dbd2a5b38e63db5fde84091a68803892cc0f1 Mon Sep 17 00:00:00 2001 From: Sirius902 <10891979+Sirius902@users.noreply.github.com> Date: Sun, 17 Apr 2022 08:26:49 -0700 Subject: [PATCH] MM Bunny Hood enhancement (#181) Allow bunny hood in boss rooms Use math instead of array Allow other masks with enhancement because why not --- libultraship/libultraship/GameSettings.cpp | 4 +++ libultraship/libultraship/GameSettings.h | 1 + libultraship/libultraship/SohImGuiImpl.cpp | 7 ++++- soh/src/code/z_parameter.c | 6 ++++- .../actors/ovl_player_actor/z_player.c | 27 +++++++++++++++---- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp index 678555c7d..1b8d473b2 100644 --- a/libultraship/libultraship/GameSettings.cpp +++ b/libultraship/libultraship/GameSettings.cpp @@ -61,6 +61,9 @@ namespace Game { Settings.enhancements.minimal_ui = stob(Conf[EnhancementSection]["minimal_ui"]); CVar_SetS32("gMinimalUI", Settings.enhancements.minimal_ui); + Settings.enhancements.mm_bunny_hood = stob(Conf[EnhancementSection]["mm_bunny_hood"]); + CVar_SetS32("gMMBunnyHood", Settings.enhancements.mm_bunny_hood); + // Audio Settings.audio.master = Ship::stof(Conf[AudioSection]["master"]); CVar_SetFloat("gGameMasterVolume", Settings.audio.master); @@ -152,6 +155,7 @@ namespace Game { Conf[EnhancementSection]["disable_lod"] = std::to_string(Settings.enhancements.disable_lod); Conf[EnhancementSection]["animated_pause_menu"] = std::to_string(Settings.enhancements.animated_pause_menu); Conf[EnhancementSection]["minimal_ui"] = std::to_string(Settings.enhancements.minimal_ui); + Conf[EnhancementSection]["mm_bunny_hood"] = std::to_string(Settings.enhancements.mm_bunny_hood); // Controllers Conf[ControllerSection]["gyro_sensitivity"] = std::to_string(Settings.controller.gyro_sensitivity); diff --git a/libultraship/libultraship/GameSettings.h b/libultraship/libultraship/GameSettings.h index 17079c9bf..340e93d26 100644 --- a/libultraship/libultraship/GameSettings.h +++ b/libultraship/libultraship/GameSettings.h @@ -24,6 +24,7 @@ struct SoHConfigType { bool disable_lod = false; bool animated_pause_menu = false; bool minimal_ui = false; + bool mm_bunny_hood = false; } enhancements; // Controller diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index b7e6e01ab..93dcd2492 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -413,6 +413,11 @@ namespace SohImGui { needs_save = true; } + if (ImGui::Checkbox("MM Bunny Hood", &Game::Settings.enhancements.mm_bunny_hood)) { + CVar_SetS32("gMMBunnyHood", Game::Settings.enhancements.mm_bunny_hood); + needs_save = true; + } + ImGui::Text("Graphics"); ImGui::Separator(); @@ -639,4 +644,4 @@ namespace SohImGui { ImTextureID GetTextureByName(const std::string& name) { return GetTextureByID(DefaultAssets[name]->textureId); } -} \ No newline at end of file +} diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 1653cdaaf..dc96ba133 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -919,7 +919,11 @@ void func_80083108(GlobalContext* globalCtx) { if (interfaceCtx->restrictions.tradeItems != 0) { for (i = 1; i < 4; i++) { - if ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && + if ((CVar_GetS32("gMMBunnyHood", 0) != 0) + && (gSaveContext.equips.buttonItems[i] >= ITEM_MASK_KEATON) + && (gSaveContext.equips.buttonItems[i] <= ITEM_MASK_TRUTH)) { + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } else if ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { sp28 = 1; diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index a2a810175..734ba015e 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -1875,10 +1875,20 @@ void func_80833DF8(Player* this, GlobalContext* globalCtx) { s32 i; if (this->currentMask != PLAYER_MASK_NONE) { - maskActionParam = this->currentMask - 1 + PLAYER_AP_MASK_KEATON; - if (!func_80833C98(C_BTN_ITEM(0), maskActionParam) && !func_80833C98(C_BTN_ITEM(1), maskActionParam) && - !func_80833C98(C_BTN_ITEM(2), maskActionParam)) { - this->currentMask = PLAYER_MASK_NONE; + if (CVar_GetS32("gMMBunnyHood", 0) != 0) { + s32 maskItem = this->currentMask - PLAYER_MASK_KEATON + ITEM_MASK_KEATON; + + if (gSaveContext.equips.buttonItems[0] != maskItem && gSaveContext.equips.buttonItems[1] != maskItem && + gSaveContext.equips.buttonItems[2] != maskItem && gSaveContext.equips.buttonItems[3] != maskItem) { + this->currentMask = PLAYER_MASK_NONE; + func_808328EC(this, NA_SE_PL_CHANGE_ARMS); + } + } else { + maskActionParam = this->currentMask - 1 + PLAYER_AP_MASK_KEATON; + if (!func_80833C98(C_BTN_ITEM(0), maskActionParam) && !func_80833C98(C_BTN_ITEM(1), maskActionParam) && + !func_80833C98(C_BTN_ITEM(2), maskActionParam)) { + this->currentMask = PLAYER_MASK_NONE; + } } } @@ -5942,7 +5952,11 @@ void func_8083DFE0(Player* this, f32* arg1, s16* arg2) { s16 yawDiff = this->currentYaw - *arg2; if (this->swordState == 0) { - this->linearVelocity = CLAMP(this->linearVelocity, -(R_RUN_SPEED_LIMIT / 100.0f), (R_RUN_SPEED_LIMIT / 100.0f)); + float maxSpeed = R_RUN_SPEED_LIMIT / 100.0f; + if (CVar_GetS32("gMMBunnyHood", 0) != 0 && this->currentMask == PLAYER_MASK_BUNNY) { + maxSpeed *= 1.5f; + } + this->linearVelocity = CLAMP(this->linearVelocity, -maxSpeed, maxSpeed); } if (ABS(yawDiff) > 0x6000) { @@ -7523,6 +7537,9 @@ void func_80842180(Player* this, GlobalContext* globalCtx) { func_80837268(this, &sp2C, &sp2A, 0.018f, globalCtx); if (!func_8083C484(this, &sp2C, &sp2A)) { + if (CVar_GetS32("gMMBunnyHood", 0) != 0 && this->currentMask == PLAYER_MASK_BUNNY) { + sp2C *= 1.5f; + } func_8083DF68(this, sp2C, sp2A); func_8083DDC8(this, globalCtx);