Skip to content

Commit

Permalink
Enhanced Iron Boots
Browse files Browse the repository at this point in the history
  • Loading branch information
lilDavid committed Nov 25, 2023
1 parent 0ddb071 commit cf44371
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 36 deletions.
2 changes: 2 additions & 0 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,8 @@ void DrawEnhancementsMenu() {
UIWidgets::Tooltip("Allows equipping the tunic and boots to c-buttons");
UIWidgets::PaddedEnhancementCheckbox("Equipment Toggle", "gEquipmentCanBeRemoved", true, false);
UIWidgets::Tooltip("Allows equipment to be removed by toggling it off on\nthe equipment subscreen.");
UIWidgets::PaddedEnhancementCheckbox("Extra Underwater Actions", "gEnhancedIronBoots", true, false);
UIWidgets::Tooltip("Allows opening chests and using your sword and Bombchus when underwater with Iron Boots");
UIWidgets::PaddedEnhancementCheckbox("Link's Cow in Both Time Periods", "gCowOfTime", true, false);
UIWidgets::Tooltip("Allows the Lon Lon Ranch obstacle course reward to be shared across time periods");
UIWidgets::PaddedEnhancementCheckbox("Enable visible guard vision", "gGuardVision", true, false);
Expand Down
76 changes: 43 additions & 33 deletions soh/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,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 (CVarGetInteger("gEnhancedIronBoots", 0) && Player_GetEnvironmentalHazard(play) == 2) {
if (gSaveContext.buttonStatus[0] == BTN_DISABLED) {
sp28 = 1;
}

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

gSaveContext.buttonStatus[0] = BTN_DISABLED;
}

for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) {
if ((gSaveContext.equips.buttonItems[i] >= ITEM_SHIELD_DEKU) &&
Expand All @@ -981,7 +989,9 @@ 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)) {
(gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT) &&
(CVarGetInteger("gEnhancedIronBoots", 0)
&& gSaveContext.equips.buttonItems[i] != ITEM_BOMBCHU)) {
if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) {
sp28 = 1;
}
Expand Down Expand Up @@ -1441,7 +1451,7 @@ void Inventory_SwapAgeEquipment(void) {
u16 shieldEquipValue;

if (LINK_AGE_IN_YEARS == YEARS_CHILD) {


for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) {
if (i != 0) {
Expand Down Expand Up @@ -1483,13 +1493,13 @@ void Inventory_SwapAgeEquipment(void) {
gSaveContext.equips.buttonItems[3] = gSaveContext.inventory.items[SLOT_OCARINA];
gSaveContext.equips.cButtonSlots[1] = SLOT_BOMB;
gSaveContext.equips.cButtonSlots[2] = SLOT_OCARINA;

gSaveContext.equips.equipment = (EQUIP_VALUE_SWORD_MASTER << (EQUIP_TYPE_SWORD * 4)) |
(EQUIP_VALUE_SHIELD_HYLIAN << (EQUIP_TYPE_SHIELD * 4)) |
(EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) |
(EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4));

if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) &&
if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) &&
gSaveContext.equips.buttonItems[0] == ITEM_NONE) {
gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4));
}
Expand Down Expand Up @@ -1814,14 +1824,14 @@ u8 Return_Item(u8 itemID, ModIndex modId, ItemID returnItem) {

/**
* @brief Adds the given item to Link's inventory.
*
*
* NOTE: This function has been edited to be safe to use with a NULL play.
* If you need to add to this function, be sure you check if the play is not
* NULL before doing any operations requiring it.
*
* @param play
* @param item
* @return u8
*
* @param play
* @param item
* @return u8
*/
u8 Item_Give(PlayState* play, u8 item) {
lusprintf(__FILE__, __LINE__, 2, "Item Give - item: %#x", item);
Expand Down Expand Up @@ -1902,10 +1912,10 @@ u8 Item_Give(PlayState* play, u8 item) {

// In rando, when buying Giant's Knife, also check
// without the Koriri Sword in case we don't have it
if (ALL_EQUIP_VALUE(EQUIP_TYPE_SWORD) ==
if (ALL_EQUIP_VALUE(EQUIP_TYPE_SWORD) ==
((1 << EQUIP_INV_SWORD_KOKIRI) | (1 << EQUIP_INV_SWORD_MASTER) | (1 << EQUIP_INV_SWORD_BIGGORON) |
(1 << EQUIP_INV_SWORD_BROKENGIANTKNIFE)) ||
(IS_RANDO && ALL_EQUIP_VALUE(EQUIP_TYPE_SWORD) ==
(1 << EQUIP_INV_SWORD_BROKENGIANTKNIFE)) ||
(IS_RANDO && ALL_EQUIP_VALUE(EQUIP_TYPE_SWORD) ==
((1 << EQUIP_INV_SWORD_MASTER) | (1 << EQUIP_INV_SWORD_BIGGORON) | (1 << EQUIP_INV_SWORD_BROKENGIANTKNIFE)))) {

gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE);
Expand All @@ -1917,7 +1927,7 @@ u8 Item_Give(PlayState* play, u8 item) {
}
}
}

} else if (item == ITEM_SWORD_MASTER) {
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER;
gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4));
Expand Down Expand Up @@ -2657,7 +2667,7 @@ u8 Item_CheckObtainability(u8 item) {
return ITEM_NONE;
}
}

if ((item >= ITEM_SONG_MINUET) && (item <= ITEM_SONG_STORMS)) {
return ITEM_NONE;
} else if ((item >= ITEM_MEDALLION_FOREST) && (item <= ITEM_MEDALLION_LIGHT)) {
Expand Down Expand Up @@ -2921,7 +2931,7 @@ bool Inventory_HatchPocketCucco(PlayState* play) {
return Inventory_ReplaceItem(play, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO);
}

if (!PLAYER_HAS_SHUFFLED_ADULT_TRADE_ITEM(ITEM_POCKET_EGG)) {
if (!PLAYER_HAS_SHUFFLED_ADULT_TRADE_ITEM(ITEM_POCKET_EGG)) {
return 0;
}

Expand Down Expand Up @@ -2960,7 +2970,7 @@ void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 l
}
doAction = newName[loadOffset];
}

char* segment = interfaceCtx->doActionSegment[loadOffset];
interfaceCtx->doActionSegment[loadOffset] = action != DO_ACTION_NONE ? doAction : gEmptyTexture;
gSegments[7] = interfaceCtx->doActionSegment[loadOffset];
Expand Down Expand Up @@ -3027,7 +3037,7 @@ void Interface_LoadActionLabelB(PlayState* play, u16 action) {
}

interfaceCtx->unk_1FC = action;

char* segment = interfaceCtx->doActionSegment[1];
interfaceCtx->doActionSegment[1] = action != DO_ACTION_NONE ? doAction : gEmptyTexture;
osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK);
Expand All @@ -3052,7 +3062,7 @@ s32 Health_ChangeBy(PlayState* play, s16 healthChange) {
if (healthChange < 0) {
gSaveContext.health = 0;
}

return 0;
}

Expand Down Expand Up @@ -3121,7 +3131,7 @@ void Rupees_ChangeBy(s16 rupeeChange) {

void GameplayStats_UpdateAmmoUsed(s16 item, s16 ammoUsed) {

switch (item) {
switch (item) {
case ITEM_STICK:
gSaveContext.sohStats.count[COUNT_AMMO_USED_STICK] += ammoUsed;
break;
Expand Down Expand Up @@ -4307,7 +4317,7 @@ void Interface_DrawItemButtons(PlayState* play) {
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);

gSPWideTextureRectangle(OVERLAY_DISP++, C_Up_BTN_Pos[0]-LabelX_Navi << 2, C_Up_BTN_Pos[1]+LabelY_Navi << 2,
gSPWideTextureRectangle(OVERLAY_DISP++, C_Up_BTN_Pos[0]-LabelX_Navi << 2, C_Up_BTN_Pos[1]+LabelY_Navi << 2,
(C_Up_BTN_Pos[0]-LabelX_Navi + 32) << 2, (C_Up_BTN_Pos[1]+LabelY_Navi + 8) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);

}
Expand Down Expand Up @@ -4425,7 +4435,7 @@ void Interface_DrawItemButtons(PlayState* play) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, cRightButtonColor.r, cRightButtonColor.g, cRightButtonColor.b, interfaceCtx->cRightAlpha);
}

OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, ((u8*)gButtonBackgroundTex), 32, 32,
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, ((u8*)gButtonBackgroundTex), 32, 32,
ItemIconPos[temp-1][0], ItemIconPos[temp-1][1], ItemIconWidthFactor[temp-1][0],
ItemIconWidthFactor[temp-1][0], ItemIconWidthFactor[temp-1][1], ItemIconWidthFactor[temp-1][1]);

Expand Down Expand Up @@ -4500,8 +4510,8 @@ void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) {
{ C_DOWN_BUTTON_X+X_Margins_CD, C_DOWN_BUTTON_Y+Y_Margins_CD },
{ C_RIGHT_BUTTON_X+X_Margins_CR, C_RIGHT_BUTTON_Y+Y_Margins_CR },
{ DPAD_UP_X+X_Margins_DPad_Items, DPAD_UP_Y+Y_Margins_DPad_Items },
{ DPAD_DOWN_X+X_Margins_DPad_Items, DPAD_DOWN_Y+Y_Margins_DPad_Items },
{ DPAD_LEFT_X+X_Margins_DPad_Items, DPAD_LEFT_Y+Y_Margins_DPad_Items },
{ DPAD_DOWN_X+X_Margins_DPad_Items, DPAD_DOWN_Y+Y_Margins_DPad_Items },
{ DPAD_LEFT_X+X_Margins_DPad_Items, DPAD_LEFT_Y+Y_Margins_DPad_Items },
{ DPAD_RIGHT_X+X_Margins_DPad_Items, DPAD_RIGHT_Y+Y_Margins_DPad_Items }
};
u16 ItemsSlotsAlpha[8] = {
Expand Down Expand Up @@ -4877,11 +4887,11 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) {
}

if (i != 0) {
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[i], 8, 8,
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[i], 8, 8,
ItemIconPos[button][0], ItemIconPos[button][1], 8, 8, 1 << 10, 1 << 10);
}

OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[ammo], 8, 8,
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[ammo], 8, 8,
ItemIconPos[button][0] + 6, ItemIconPos[button][1], 8, 8, 1 << 10, 1 << 10);

}
Expand Down Expand Up @@ -5386,7 +5396,7 @@ void Interface_Draw(PlayState* play) {
PosY_adjust = 6;
PosX_adjust = -10;
}

s16 BbtnPosX;
s16 BbtnPosY;
s16 X_Margins_BtnB_label;
Expand Down Expand Up @@ -5704,7 +5714,7 @@ void Interface_Draw(PlayState* play) {
CarrotsPosY = CVarGetInteger("gCarrotsPosY", 0);
if (CVarGetInteger("gCarrotsPosType", 0) == 1) {//Anchor Left
if (CVarGetInteger("gCarrotsUseMargins", 0) != 0) {CarrotsMargins_X = Left_HUD_Margin;};
CarrotsPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger("gCarrotsPosX", 0)+CarrotsMargins_X);
CarrotsPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger("gCarrotsPosX", 0)+CarrotsMargins_X);
} else if (CVarGetInteger("gCarrotsPosType", 0) == 2) {//Anchor Right
if (CVarGetInteger("gCarrotsUseMargins", 0) != 0) {CarrotsMargins_X = Right_HUD_Margin;};
CarrotsPosX = OTRGetDimensionFromRightEdge(CVarGetInteger("gCarrotsPosX", 0)+CarrotsMargins_X);
Expand Down Expand Up @@ -6214,7 +6224,7 @@ void Interface_Draw(PlayState* play) {
for (svar1 = 0; svar1 < 5; svar1++) {
// clang-format off
//svar5 = svar5 + 8;
//svar5 = OTRGetRectDimensionFromLeftEdge(gSaveContext.timerX[svar6]);
//svar5 = OTRGetRectDimensionFromLeftEdge(gSaveContext.timerX[svar6]);
OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, digitTextures[timerDigits[svar1]], 8, 16,
svar5 + timerDigitLeftPos[svar1],
svar2, digitWidth[svar1], VREG(42), VREG(43) << 1,
Expand Down Expand Up @@ -6358,7 +6368,7 @@ void Interface_Update(PlayState* play) {
Left_HUD_Margin = CVarGetInteger("gHUDMargin_L", 0);
Right_HUD_Margin = CVarGetInteger("gHUDMargin_R", 0);
Bottom_HUD_Margin = CVarGetInteger("gHUDMargin_B", 0);

GameInteractor_ExecuteOnInterfaceUpdate();

if (CHECK_BTN_ALL(debugInput->press.button, BTN_DLEFT)) {
Expand Down
9 changes: 6 additions & 3 deletions soh/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,9 @@ void func_80835F44(PlayState* play, Player* this, s32 item) {

if ((actionParam == PLAYER_IA_NONE) || !(this->stateFlags1 & PLAYER_STATE1_IN_WATER) ||
((this->actor.bgCheckFlags & 1) &&
((actionParam == PLAYER_IA_HOOKSHOT) || (actionParam == PLAYER_IA_LONGSHOT))) ||
((actionParam == PLAYER_IA_HOOKSHOT) || (actionParam == PLAYER_IA_LONGSHOT) ||
(CVarGetInteger("gEnhancedIronBoots", 0) &&
((Player_ActionToSword(actionParam) != 0) || (actionParam == PLAYER_IA_BOMBCHU))))) ||
((actionParam >= PLAYER_IA_SHIELD_DEKU) && (actionParam <= PLAYER_IA_BOOTS_HOVER))) {

if ((play->bombchuBowlingStatus == 0) &&
Expand Down Expand Up @@ -6386,7 +6388,7 @@ s32 func_8083E5A8(Player* this, PlayState* play) {
this->getItemEntry = (GetItemEntry)GET_ITEM_NONE;
}
} else if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && !(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) &&
!(this->stateFlags2 & PLAYER_STATE2_UNDERWATER)) {
(CVarGetInteger("gEnhancedIronBoots", 0) || !(this->stateFlags2 & PLAYER_STATE2_UNDERWATER))) {
if (this->getItemId != GI_NONE) {
GetItemEntry giEntry;
if (this->getItemEntry.objectId == OBJECT_INVALID) {
Expand Down Expand Up @@ -9841,7 +9843,8 @@ void func_808473D4(PlayState* play, Player* this) {
} else if ((!(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) || (heldActor == NULL)) &&
(interactRangeActor != NULL) &&
((!sp1C && (this->getItemId == GI_NONE)) ||
(this->getItemId < 0 && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER)))) {
(this->getItemId < 0 && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER)) ||
CVarGetInteger("gEnhancedIronBoots", 0) && this->stateFlags2 & PLAYER_STATE2_UNDERWATER)) {
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 cf44371

Please sign in to comment.