Skip to content

Commit

Permalink
Extra Underwater Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lilDavid committed Nov 25, 2024
1 parent 3d9ff44 commit 6cdea07
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 13 deletions.
55 changes: 55 additions & 0 deletions soh/soh/Enhancements/Mods/lilDavid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern "C" {
void func_809B45E0(EnArrow*, PlayState*);
void func_809B4640(EnArrow*, PlayState*);
void func_80ADFE80(EnPoh*, PlayState*);
int func_808332B8(Player*);
}

#define AUTHOR "lilDavid"
Expand Down Expand Up @@ -123,6 +124,55 @@ static void OnConfigurationChanged() {
});


// Extra Underwater Actions

COND_VB_SHOULD(VB_PLAYER_OPEN_CHEST_OR_LIFT_OBJECT, CVarGetInteger(CVAR("EnhancedIronBoots"), 0), {
Player* player = GET_PLAYER(gPlayState);
Input* sControlInput = &gPlayState->state.input[0];

if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) &&
!(player->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) &&
player->stateFlags2 & PLAYER_STATE2_UNDERWATER &&
player->getItemId != GI_NONE)
{
*should = true;
}
})

COND_VB_SHOULD(VB_PLAYER_SHOW_OPEN_GRAB_OR_DROP_DO_ACTION, CVarGetInteger(CVAR("EnhancedIronBoots"), 0), {
Player* player = GET_PLAYER(gPlayState);
int inWaterWithoutBoots = func_808332B8(player);

if (
(!(player->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) || (player->heldActor == NULL)) &&
(player->interactRangeActor != NULL) &&
(player->getItemId < 0 && !inWaterWithoutBoots)
) {
*should = true;
}
})

COND_VB_SHOULD(VB_PLAYER_BE_ABLE_TO_USE_ITEM_UNDERWATER, CVarGetInteger(CVAR("EnhancedIronBoots"), 0), {
s8 itemAction = va_arg(args, s8);

if (Player_ActionToMeleeWeapon(itemAction) != 0 || itemAction == PLAYER_IA_BOMBCHU)
*should = true;
});

COND_VB_SHOULD(VB_DISABLE_B_BUTTON_UNDERWATER, CVarGetInteger(CVAR("EnhancedIronBoots"), 0), {
if (Player_GetEnvironmentalHazard(gPlayState) != 2)
return;

*should = false;
});

COND_VB_SHOULD(VB_DISABLE_C_BUTTON_UNDERWATER, CVarGetInteger(CVAR("EnhancedIronBoots"), 0), {
s16 index = va_arg(args, s16);

if (gSaveContext.equips.buttonItems[index] == ITEM_BOMBCHU)
*should = false;
});

// Catch Poes with a Bottle

COND_VB_SHOULD(VB_BOTTLE_ACTOR, CVarGetInteger(CVAR("MMPoeBottling"), 0), {
Expand Down Expand Up @@ -189,6 +239,11 @@ static void DrawMenu() {
}
UIWidgets::Tooltip("Catch Poes by swinging an empty bottle at them instead of from a text box like you can in Majora's Mask.");

if (UIWidgets::PaddedEnhancementCheckbox("Extra Underwater Actions", CVAR("EnhancedIronBoots"))) {
OnConfigurationChanged();
}
UIWidgets::Tooltip("Allows opening chests and using your sword and Bombchus when underwater with Iron Boots");

UIWidgets::EnhancementCheckbox("Visual Small Key Display", CVAR("VisualSmallKeys.Enabled"));
UIWidgets::Tooltip("Displays Small Key count using multiple icons rather than a numeric counter");
const bool disableKeySpacing = !CVarGetInteger(CVAR("VisualSmallKeys.Enabled"), 0);
Expand Down
29 changes: 29 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,35 @@ typedef enum {
// Opt: *Actor
VB_BOTTLE_ACTOR,

/*** Extra Underwater Actions ***/
/* Vanilla condition:
```
CHECK_BTN_ALL(sControlInput->press.button, BTN_A) &&
!(this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) &&
!(this->stateFlags2 & PLAYER_STATE2_UNDERWATER)
```
*/
VB_PLAYER_OPEN_CHEST_OR_LIFT_OBJECT,
/* Vanilla condition:
```
(!(this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) || (heldActor == NULL)) &&
(interactRangeActor != NULL) &&
(
(!sp1C && (this->getItemId == GI_NONE)) ||
(this->getItemId < 0 && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER))
)
```
*/
VB_PLAYER_SHOW_OPEN_GRAB_OR_DROP_DO_ACTION,
// Vanilla condition: (itemAction == PLAYER_IA_HOOKSHOT) || (itemAction == PLAYER_IA_LONGSHOT)
// Opt: s32 (itemAction)
VB_PLAYER_BE_ABLE_TO_USE_ITEM_UNDERWATER,
// Vanilla condition: true
VB_DISABLE_B_BUTTON_UNDERWATER,
// Vanilla condition: (gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) && (gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT)
// Opt: s16 (button index)
VB_DISABLE_C_BUTTON_UNDERWATER,

/*** Catch Poes With a Bottle ***/
// Vanilla condition: true
// Opt: *EnPoh
Expand Down
26 changes: 20 additions & 6 deletions soh/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,11 +967,19 @@ void func_80083108(PlayState* play) {
gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] =
gSaveContext.buttonStatus[7] = gSaveContext.buttonStatus[8] = BTN_DISABLED;
} else if ((Player_GetEnvironmentalHazard(play) >= 2) && (Player_GetEnvironmentalHazard(play) < 5)) {
if (gSaveContext.buttonStatus[0] != BTN_DISABLED) {
sp28 = 1;
}
if (GameInteractor_Should(VB_DISABLE_B_BUTTON_UNDERWATER, true)) {
if (gSaveContext.buttonStatus[0] != BTN_DISABLED) {
sp28 = 1;
}

gSaveContext.buttonStatus[0] = BTN_DISABLED;
gSaveContext.buttonStatus[0] = BTN_DISABLED;
} else {
if (gSaveContext.buttonStatus[0] == BTN_DISABLED) {
sp28 = 1;
}

gSaveContext.buttonStatus[0] = BTN_ENABLED;
}

for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) {
if ((gSaveContext.equips.buttonItems[i] >= ITEM_SHIELD_DEKU) &&
Expand All @@ -983,8 +991,14 @@ void func_80083108(PlayState* play) {

gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED;
} else if (Player_GetEnvironmentalHazard(play) == 2) {
if ((gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) &&
(gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT)) {
if (GameInteractor_Should(
VB_DISABLE_C_BUTTON_UNDERWATER,
(
(gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) &&
(gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT)
),
i
)) {
if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) {
sp28 = 1;
}
Expand Down
35 changes: 28 additions & 7 deletions soh/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -3432,7 +3432,11 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) {

if ((itemAction == PLAYER_IA_NONE) || !(this->stateFlags1 & PLAYER_STATE1_IN_WATER) ||
((this->actor.bgCheckFlags & 1) &&
((itemAction == PLAYER_IA_HOOKSHOT) || (itemAction == PLAYER_IA_LONGSHOT)))) {
GameInteractor_Should(
VB_PLAYER_BE_ABLE_TO_USE_ITEM_UNDERWATER,
(itemAction == PLAYER_IA_HOOKSHOT) || (itemAction == PLAYER_IA_LONGSHOT),
itemAction
))) {

if ((play->bombchuBowlingStatus == 0) &&
(((itemAction == PLAYER_IA_DEKU_STICK) && (AMMO(ITEM_STICK) == 0)) ||
Expand Down Expand Up @@ -7337,8 +7341,16 @@ s32 Player_ActionHandler_2(Player* this, PlayState* play) {
this->getItemId = GI_NONE;
this->getItemEntry = (GetItemEntry)GET_ITEM_NONE;
}
} else if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && !(this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) &&
!(this->stateFlags2 & PLAYER_STATE2_UNDERWATER)) {
} else if (
GameInteractor_Should(
VB_PLAYER_OPEN_CHEST_OR_LIFT_OBJECT,
(
CHECK_BTN_ALL(sControlInput->press.button, BTN_A) &&
!(this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) &&
!(this->stateFlags2 & PLAYER_STATE2_UNDERWATER)
)
)
) {
if (this->getItemId != GI_NONE) {
GetItemEntry giEntry;
if (this->getItemEntry.objectId == OBJECT_INVALID) {
Expand Down Expand Up @@ -10975,10 +10987,19 @@ void Player_UpdateInterface(PlayState* play, Player* this) {
(!(this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) ||
((heldActor != NULL) && (heldActor->id == ACTOR_EN_RU1)))) {
doAction = DO_ACTION_OPEN;
} else if ((!(this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) || (heldActor == NULL)) &&
(interactRangeActor != NULL) &&
((!sp1C && (this->getItemId == GI_NONE)) ||
(this->getItemId < 0 && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER)))) {
} else if (
GameInteractor_Should(
VB_PLAYER_SHOW_OPEN_GRAB_OR_DROP_DO_ACTION,
(
(!(this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) || (heldActor == NULL)) &&
(interactRangeActor != NULL) &&
(
(!sp1C && (this->getItemId == GI_NONE)) ||
(this->getItemId < 0 && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER))
)
)
)
) {
if (this->getItemId < 0) {
doAction = DO_ACTION_OPEN;
} else if ((interactRangeActor->id == ACTOR_BG_TOKI_SWD) && LINK_IS_ADULT) {
Expand Down

0 comments on commit 6cdea07

Please sign in to comment.