From b98c8b4abb38aa26300f436827bfbf35e4a07904 Mon Sep 17 00:00:00 2001 From: Sarge-117 <108380086+Sarge-117@users.noreply.github.com> Date: Sun, 31 Jul 2022 18:35:05 -0700 Subject: [PATCH] Minor enhancement: Allow toggling on equipment screen (#813) * Allow Equipment Toggle Allow player to toggle equipment on/off on the equipment subscreen. For tunics and boots, this will revert them to Kokiri Tunic/Kokiri Boots. For shields, it will un-equip the shield entirely. For swords, only BGS/Giant's Knife is affected, and it will revert to Master Sword. * Set up Cvar and check for MS Set up the cvar/imgui and add a check that we own the Master Sword (in case we're in the Ganon fight) --- libultraship/libultraship/ImGuiImpl.cpp | 2 + .../ovl_kaleido_scope/z_kaleido_equipment.c | 39 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 8997f6192..da3469301 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1140,6 +1140,8 @@ namespace SohImGui { Tooltip("Displays an icon and plays a sound when Stone of Agony\nshould be activated, for those without rumble"); EnhancementCheckbox("Assignable Tunics and Boots", "gAssignableTunicsAndBoots"); Tooltip("Allows equipping the tunic and boots to c-buttons"); + EnhancementCheckbox("Equipment Toggle", "gEquipmentCanBeRemoved"); + Tooltip("Allows equipment to be removed by toggling it off on\nthe equipment subscreen."); EnhancementCheckbox("Link's Cow in Both Time Periods", "gCowOfTime"); Tooltip("Allows the Lon Lon Ranch obstacle course reward to be\nshared across time periods"); EnhancementCheckbox("Enable visible guard vision", "gGuardVision"); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index edcc21c07..eaa2bb24a 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -515,12 +515,49 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == ((void)0, gSaveContext.linkAge))) { if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + + // Allow Link to remove his equipment from the equipment subscreen by toggling on/off + // Shields will be un-equipped entirely, and tunics/boots will revert to Kokiri Tunic/Kokiri Boots + // Only BGS/Giant's Knife is affected, and it will revert to Master Sword. + + // If we have the feature toggled on + if (CVar_GetS32("gEquipmentCanBeRemoved", 0)) { + + // If we're on the "swords" section of the equipment screen AND we're on a currently-equipped BGS/Giant's Knife + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == 3 + && CUR_EQUIP_VALUE(EQUIP_SWORD) == 3 && CHECK_OWNED_EQUIP(0,1)){ // And we have the Master Sword + Inventory_ChangeEquipment(EQUIP_SWORD, 2); // "Unequip" it by equipping Master Sword + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + gSaveContext.infTable[29] = 0; + goto RESUME_EQUIPMENT_SWORD; // Skip to here so we don't re-equip it + } + + // If we're on the "shields" section of the equipment screen AND we're on a currently-equipped shield + if (pauseCtx->cursorY[PAUSE_EQUIP] == 1 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_SHIELD)) { + Inventory_ChangeEquipment(EQUIP_SHIELD, 0); // Unequip it + goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it + } + + // If we're on the "tunics" section of the equipment screen AND we're on a currently-equipped tunic + if (pauseCtx->cursorY[PAUSE_EQUIP] == 2 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_TUNIC)) { + Inventory_ChangeEquipment(EQUIP_TUNIC, 1); // "Unequip" it (by equipping Kokiri Tunic) + goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it + } + + // If we're on the "boots" section of the equipment screen AND we're on currently-equipped boots + if (pauseCtx->cursorY[PAUSE_EQUIP] == 3 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_BOOTS)) { + Inventory_ChangeEquipment(EQUIP_BOOTS, 1); // "Unequip" it (by equipping Kokiri Boots) + goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it + } + } + if (CHECK_OWNED_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP] - 1)) { Inventory_ChangeEquipment(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]); } else { goto EQUIP_FAIL; } + RESUME_EQUIPMENT: if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { gSaveContext.infTable[29] = 0; gSaveContext.equips.buttonItems[0] = cursorItem; @@ -537,7 +574,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; } } - + RESUME_EQUIPMENT_SWORD: Interface_LoadItemIcon1(globalCtx, 0); }