Skip to content

Commit

Permalink
MM Bunny Hood enhancement (#181)
Browse files Browse the repository at this point in the history
Allow bunny hood in boss rooms

Use math instead of array

Allow other masks with enhancement because why not
  • Loading branch information
Sirius902 authored Apr 17, 2022
1 parent a11038f commit fe6dbd2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
4 changes: 4 additions & 0 deletions libultraship/libultraship/GameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions libultraship/libultraship/GameSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion libultraship/libultraship/SohImGuiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -639,4 +644,4 @@ namespace SohImGui {
ImTextureID GetTextureByName(const std::string& name) {
return GetTextureByID(DefaultAssets[name]->textureId);
}
}
}
6 changes: 5 additions & 1 deletion soh/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 22 additions & 5 deletions soh/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit fe6dbd2

Please sign in to comment.