From 83be8b11806380203471dd595d3562f15b3ed85b Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Thu, 9 May 2024 01:21:31 +0100 Subject: [PATCH] [Enhancement] Power Crouch Stab (#273) * power crouch stab * update gi enum --------- Co-authored-by: Archez --- mm/2s2h/BenGui/BenMenuBar.cpp | 8 ++++++++ mm/2s2h/Enhancements/Enhancements.cpp | 1 + mm/2s2h/Enhancements/Enhancements.h | 1 + mm/2s2h/Enhancements/GameInteractor/GameInteractor.h | 1 + mm/2s2h/Enhancements/Restorations/PowerCrouchStab.cpp | 10 ++++++++++ mm/2s2h/Enhancements/Restorations/PowerCrouchStab.h | 6 ++++++ mm/src/overlays/actors/ovl_player_actor/z_player.c | 4 +++- 7 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 mm/2s2h/Enhancements/Restorations/PowerCrouchStab.cpp create mode 100644 mm/2s2h/Enhancements/Restorations/PowerCrouchStab.h diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index e3930f1b6..c52a99f49 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -347,6 +347,14 @@ void DrawEnhancementsMenu() { ImGui::EndMenu(); } + if (UIWidgets::BeginMenu("Restorations")) { + UIWidgets::CVarCheckbox("Power Crouch Stab", "gEnhancements.Restorations.PowerCrouchStab", { + .tooltip = "Crouch stabs will use the power of Link's previous melee attack, as is in MM JP 1.0 and OOT." + }); + + ImGui::EndMenu(); + } + if (UIWidgets::BeginMenu("Graphics")) { MotionBlur_RenderMenuOptions(); ImGui::SeparatorText("Other"); diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index f00768e8c..1de640507 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -20,6 +20,7 @@ void InitEnhancements() { RegisterEnableSunsSong(); // Restorations + RegisterPowerCrouchStab(); RegisterSideRoll(); // Cutscenes diff --git a/mm/2s2h/Enhancements/Enhancements.h b/mm/2s2h/Enhancements/Enhancements.h index 56ed3c0c6..9f53f3d4e 100644 --- a/mm/2s2h/Enhancements/Enhancements.h +++ b/mm/2s2h/Enhancements/Enhancements.h @@ -11,6 +11,7 @@ #include "Minigames/AlwaysWinDoggyRace.h" #include "Cutscenes/SkipEntranceCutscenes.h" #include "Cutscenes/HideTitleCards.h" +#include "Restorations/PowerCrouchStab.h" #include "Restorations/SideRoll.h" #include "Graphics/PlayAsKafei.h" #include "Songs/EnableSunsSong.h" diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h index 3cce15a83..14c35b22a 100644 --- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h +++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h @@ -35,6 +35,7 @@ typedef enum { GI_VB_DOGGY_RACE_SET_MAX_SPEED, GI_VB_LOWER_RAZOR_SWORD_DURABILITY, GI_VB_SET_BLAST_MASK_COOLDOWN_TIMER, + GI_VB_PATCH_POWER_CROUCH_STAB, GI_VB_PATCH_SIDEROLL, GI_VB_PREVENT_MASK_TRANSFORMATION_CS, GI_VB_SONG_AVAILABLE_TO_PLAY, diff --git a/mm/2s2h/Enhancements/Restorations/PowerCrouchStab.cpp b/mm/2s2h/Enhancements/Restorations/PowerCrouchStab.cpp new file mode 100644 index 000000000..273008f9f --- /dev/null +++ b/mm/2s2h/Enhancements/Restorations/PowerCrouchStab.cpp @@ -0,0 +1,10 @@ +#include +#include "Enhancements/GameInteractor/GameInteractor.h" + +void RegisterPowerCrouchStab() { + REGISTER_VB_SHOULD(GI_VB_PATCH_POWER_CROUCH_STAB, { + if (CVarGetInteger("gEnhancements.Restorations.PowerCrouchStab", 0)) { + *should = false; + } + }); +} diff --git a/mm/2s2h/Enhancements/Restorations/PowerCrouchStab.h b/mm/2s2h/Enhancements/Restorations/PowerCrouchStab.h new file mode 100644 index 000000000..64747487f --- /dev/null +++ b/mm/2s2h/Enhancements/Restorations/PowerCrouchStab.h @@ -0,0 +1,6 @@ +#ifndef RESTORATIONS_POWER_CROUCH_STAB_H +#define RESTORATIONS_POWER_CROUCH_STAB_H + +void RegisterPowerCrouchStab(); + +#endif // RESTORATIONS_POWER_CROUCH_STAB_H diff --git a/mm/src/overlays/actors/ovl_player_actor/z_player.c b/mm/src/overlays/actors/ovl_player_actor/z_player.c index 5559e8654..eaee75ef9 100644 --- a/mm/src/overlays/actors/ovl_player_actor/z_player.c +++ b/mm/src/overlays/actors/ovl_player_actor/z_player.c @@ -9988,7 +9988,9 @@ s32 func_8083FD80(Player* this, PlayState* play) { if (!Player_IsGoronOrDeku(this) && (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && (this->transformation != PLAYER_FORM_ZORA) && sPlayerUseHeldItem) { //! Calling this function sets the meleeWeaponQuads' damage properties correctly, patching "Power Crouch Stab". - func_8083375C(this, PLAYER_MWA_STAB_1H); + if (GameInteractor_Should(GI_VB_PATCH_POWER_CROUCH_STAB, true, NULL)) { + func_8083375C(this, PLAYER_MWA_STAB_1H); + } Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_defense_kiru); this->av1.actionVar1 = 1; this->meleeWeaponAnimation = PLAYER_MWA_STAB_1H;