diff --git a/soh/soh/Enhancements/UnsheatheWithoutSlashing.cpp b/soh/soh/Enhancements/UnsheatheWithoutSlashing.cpp new file mode 100644 index 000000000..bb215eb7a --- /dev/null +++ b/soh/soh/Enhancements/UnsheatheWithoutSlashing.cpp @@ -0,0 +1,18 @@ +#include +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/ShipInit.hpp" + +#define CVAR_UNSHEATHE_NAME CVAR_ENHANCEMENT("UnsheatheWithoutSlashing") +#define CVAR_UNSHEATHE_VALUE CVarGetInteger(CVAR_UNSHEATHE_NAME, 0) + +void RegisterUnsheatheWithoutSlashing() { + COND_VB_SHOULD(VB_USE_HELD_ITEM_AFTER_CHANGE, CVAR_UNSHEATHE_VALUE, { + Player* player = va_arg(args, Player*); + ItemID heldItemId = static_cast(player->heldItemId); + if ((heldItemId == ITEM_SWORD_KOKIRI) || (heldItemId == ITEM_SWORD_MASTER)) { + *should = false; + } + }); +} + +static RegisterShipInitFunc initFunc(RegisterUnsheatheWithoutSlashing, { CVAR_UNSHEATHE_NAME }); diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index 370ddac3d..5bbc637ac 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -2386,6 +2386,14 @@ typedef enum { // - `*EnMk` VB_USE_EYEDROP_DIALOGUE, + // #### `result` + // ```c + // (this->modelAnimType != PLAYER_ANIMTYPE_3) && (play->shootingGalleryStatus == 0) + // ``` + // #### `args` + // - `*Player` + VB_USE_HELD_ITEM_AFTER_CHANGE, + // #### `result` // ```c // (shapeRotY < -0x2E93) || (shapeRotY >= 0x7C19) diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index 0aef6b311..850555820 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -776,6 +776,9 @@ void SohMenu::AddMenuEnhancements() { "Allows Strength to be toggled on and off by pressing A on the Strength Upgrade " "in the Equipment Subscreen of the Pause Menu. This allows performing some glitches " "that require the player to not have Strength.")); + AddWidget(path, "Unsheathe Sword Without Slashing", WIDGET_CVAR_CHECKBOX) + .CVar(CVAR_ENHANCEMENT("UnsheatheWithoutSlashing")) + .Options(CheckboxOptions().Tooltip("Allows Link to unsheathe sword without slashing automatically.")); AddWidget(path, "Sword Toggle Options", WIDGET_CVAR_COMBOBOX) .CVar(CVAR_ENHANCEMENT("SwordToggle")) .PreFunc( 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 b652b51e7..0ed97f64d 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -2834,8 +2834,10 @@ s32 Player_UpperAction_Sword(Player* this, PlayState* play) { s32 Player_UpperAction_ChangeHeldItem(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->upperSkelAnime) || ((Player_ItemToItemAction(this->heldItemId) == this->heldItemAction) && - (sUseHeldItem = - (sUseHeldItem || ((this->modelAnimType != PLAYER_ANIMTYPE_3) && (play->shootingGalleryStatus == 0)))))) { + (sUseHeldItem = (sUseHeldItem || GameInteractor_Should(VB_USE_HELD_ITEM_AFTER_CHANGE, + ((this->modelAnimType != PLAYER_ANIMTYPE_3) && + (play->shootingGalleryStatus == 0)), + this))))) { Player_SetUpperActionFunc(this, sItemActionUpdateFuncs[this->heldItemAction]); this->unk_834 = 0; this->idleType = PLAYER_IDLE_DEFAULT;