-
Notifications
You must be signed in to change notification settings - Fork 152
Unequip Items/Masks from C-Buttons #1429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
accdec7
v0.1
OtherBlue 9cb98f5
Merge branch 'unequip-c-items' of https://github.com/OtherBlue/2ship2…
OtherBlue 927a760
works on all items and all buttons
OtherBlue 1f460ca
mask support
OtherBlue 03a7d8e
clang format my worst enemy
OtherBlue ae62d41
update keeping VB's alphabetical
OtherBlue 038e5ac
Merge branch 'HarbourMasters:develop' into unequip-c-items
OtherBlue f474d75
Merge branch 'HarbourMasters:develop' into unequip-c-items
OtherBlue 51f5b3c
addressing feedback
OtherBlue 0a11dbc
claaang formaaat
OtherBlue 254fa8e
fix GameInteractor_Should calls
OtherBlue f221450
Update GameInteractor_VanillaBehavior.h
OtherBlue 7f57bc1
allow unequipping magic arrows from bow item
OtherBlue 43ed640
cleanup
OtherBlue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| #include <libultraship/bridge.h> | ||
| #include "2s2h/GameInteractor/GameInteractor.h" | ||
| #include "2s2h/ShipInit.hpp" | ||
| #include "2s2h_assets.h" | ||
|
|
||
| extern "C" { | ||
| #include "z64.h" | ||
| #include "functions.h" | ||
| #include "macros.h" | ||
| #include "variables.h" | ||
| #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" | ||
| } | ||
|
|
||
| #define CVAR_DPAD_NAME "gEnhancements.Dpad.DpadEquips" | ||
| #define CVAR_DPAD CVarGetInteger(CVAR_DPAD_NAME, 0) | ||
| #define CVAR_NAME "gEnhancements.Equipment.ItemUnequip" | ||
| #define CVAR CVarGetInteger(CVAR_NAME, 0) | ||
|
|
||
| void RegisterDpadPageSwitchPrevention() { | ||
| COND_VB_SHOULD(VB_KALEIDO_SWITCH_PAGE_WITH_DPAD, CVAR_DPAD, { | ||
| u16 button = va_arg(args, int); | ||
| Input* input = &gPlayState->state.input[0]; | ||
|
|
||
| if (CHECK_BTN_ALL(input->cur.button, button)) { | ||
| PauseContext* pauseCtx = &gPlayState->pauseCtx; | ||
|
|
||
| // Prevent page switching with D-pad when on item or mask page | ||
| if ((pauseCtx->pageIndex == PAUSE_ITEM || pauseCtx->pageIndex == PAUSE_MASK) && | ||
| pauseCtx->mainState <= PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG) { | ||
| *should = false; | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| void RegisterItemUnequip() { | ||
| COND_VB_SHOULD(VB_KALEIDO_EQUIP_ITEM_TO_BUTTON, CVAR, { | ||
| u16 cursorSlot = va_arg(args, int); | ||
| u16 cursorItem = va_arg(args, int); | ||
|
|
||
| PauseContext* pauseCtx = &gPlayState->pauseCtx; | ||
| s32 targetSlot = -1; | ||
| bool isDpad = false; | ||
|
|
||
| // Determine which button was pressed based on equipTargetCBtn | ||
| switch (pauseCtx->equipTargetCBtn) { | ||
| case PAUSE_EQUIP_C_LEFT: | ||
| targetSlot = EQUIP_SLOT_C_LEFT; | ||
| break; | ||
| case PAUSE_EQUIP_C_DOWN: | ||
| targetSlot = EQUIP_SLOT_C_DOWN; | ||
| break; | ||
| case PAUSE_EQUIP_C_RIGHT: | ||
| targetSlot = EQUIP_SLOT_C_RIGHT; | ||
| break; | ||
| case PAUSE_EQUIP_D_RIGHT: | ||
| targetSlot = EQUIP_SLOT_D_RIGHT; | ||
| isDpad = true; | ||
| break; | ||
| case PAUSE_EQUIP_D_LEFT: | ||
| targetSlot = EQUIP_SLOT_D_LEFT; | ||
| isDpad = true; | ||
| break; | ||
| case PAUSE_EQUIP_D_DOWN: | ||
| targetSlot = EQUIP_SLOT_D_DOWN; | ||
| isDpad = true; | ||
| break; | ||
| case PAUSE_EQUIP_D_UP: | ||
| targetSlot = EQUIP_SLOT_D_UP; | ||
| isDpad = true; | ||
| break; | ||
| default: | ||
| return; | ||
| } | ||
|
|
||
| u8 equippedItem; | ||
| u8 equippedSlot; | ||
| bool shouldUnequip = false; | ||
| bool isMask = cursorSlot >= ITEM_NUM_SLOTS; | ||
|
|
||
| // C-buttons vs D-pad | ||
| if (!isDpad) { | ||
| equippedItem = BUTTON_ITEM_EQUIP(0, targetSlot); | ||
| equippedSlot = C_SLOT_EQUIP(0, targetSlot); | ||
| } else { | ||
| equippedItem = DPAD_BUTTON_ITEM_EQUIP(0, targetSlot); | ||
| equippedSlot = DPAD_SLOT_EQUIP(0, targetSlot); | ||
| } | ||
|
|
||
| // Check if we should unequip | ||
| if (equippedItem == cursorItem) { | ||
| if (isMask) { | ||
| // For masks, check the slot matches (cursorSlot is already offset by ITEM_NUM_SLOTS) | ||
| if (equippedSlot == cursorSlot) { | ||
| shouldUnequip = true; | ||
| } | ||
| } | ||
| // For bottles, we need to check the slot too (since there are multiple bottle items) | ||
| else if (cursorItem >= ITEM_BOTTLE && cursorItem <= ITEM_OBABA_DRINK) { | ||
| if (equippedSlot == cursorSlot) { | ||
| shouldUnequip = true; | ||
| } | ||
| } else { | ||
| shouldUnequip = true; | ||
| } | ||
| } | ||
| // Handle magic arrows (bow variants) | ||
| else if (cursorItem == ITEM_ARROW_FIRE && equippedItem == ITEM_BOW_FIRE) { | ||
| shouldUnequip = true; | ||
| } else if (cursorItem == ITEM_ARROW_ICE && equippedItem == ITEM_BOW_ICE) { | ||
| shouldUnequip = true; | ||
| } else if (cursorItem == ITEM_ARROW_LIGHT && equippedItem == ITEM_BOW_LIGHT) { | ||
| shouldUnequip = true; | ||
| } | ||
|
|
||
| if (shouldUnequip) { | ||
| if (!isDpad) { | ||
| // C-buttons | ||
| BUTTON_ITEM_EQUIP(0, targetSlot) = ITEM_NONE; | ||
| C_SLOT_EQUIP(0, targetSlot) = SLOT_NONE; | ||
| Interface_LoadItemIconImpl(gPlayState, targetSlot); | ||
| } else { | ||
| // D-pad | ||
| DPAD_BUTTON_ITEM_EQUIP(0, targetSlot) = ITEM_NONE; | ||
| DPAD_SLOT_EQUIP(0, targetSlot) = SLOT_NONE; | ||
| // Manually clear D-pad icon | ||
| gPlayState->interfaceCtx.iconItemSegment[DPAD_BUTTON(targetSlot) + EQUIP_SLOT_MAX] = | ||
| (char*)gEmptyTexture; | ||
| } | ||
|
|
||
| Audio_PlaySfx(NA_SE_SY_DECIDE); | ||
| *should = false; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| static RegisterShipInitFunc initFunc(RegisterItemUnequip, { CVAR_NAME }); | ||
| static RegisterShipInitFunc initDpadPageSwitch(RegisterDpadPageSwitchPrevention, { CVAR_DPAD_NAME }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -661,6 +661,12 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { | |||
| } | ||||
| // #endregion | ||||
|
|
||||
| // Item unequip enhancement | ||||
|
||||
| // Item unequip enhancement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.