From 5dd82f59e227da2ff2c6971a53212ebead4c9fb6 Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Mon, 30 Oct 2023 15:56:36 +0000 Subject: Player Equip Docs (#3282) * hopefully everything * update docs for MS shuffle sections --- soh/src/code/code_80097A00.c | 18 ++++----- soh/src/code/z_demo.c | 4 +- soh/src/code/z_elf_message.c | 4 +- soh/src/code/z_message_PAL.c | 2 +- soh/src/code/z_parameter.c | 94 +++++++++++++++++++++++++------------------- soh/src/code/z_player_lib.c | 26 ++++++------ soh/src/code/z_sram.c | 9 ++--- 7 files changed, 85 insertions(+), 72 deletions(-) (limited to 'soh/src/code') diff --git a/soh/src/code/code_80097A00.c b/soh/src/code/code_80097A00.c index e2c8a61ef..9e20d66aa 100644 --- a/soh/src/code/code_80097A00.c +++ b/soh/src/code/code_80097A00.c @@ -191,22 +191,22 @@ void Inventory_ChangeEquipment(s16 equipment, u16 value) { u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) { Player* player = GET_PLAYER(play); s32 pad; - u16 sp26 = gSaveContext.equips.equipment & gEquipMasks[equipment]; + u16 equipValue = gSaveContext.equips.equipment & gEquipMasks[equipment]; // "Erasing equipment item = %d zzz=%d" - osSyncPrintf("装備アイテム抹消 = %d zzz=%d\n", equipment, sp26); + osSyncPrintf("装備アイテム抹消 = %d zzz=%d\n", equipment, equipValue); - if (sp26) { - sp26 >>= gEquipShifts[equipment]; + if (equipValue) { + equipValue >>= gEquipShifts[equipment]; gSaveContext.equips.equipment &= gEquipNegMasks[equipment]; - gSaveContext.inventory.equipment ^= gBitFlags[sp26 - 1] << gEquipShifts[equipment]; + gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG(equipment, equipValue - 1); - if (equipment == EQUIP_TUNIC) { - gSaveContext.equips.equipment |= 0x0100; + if (equipment == EQUIP_TYPE_TUNIC) { + gSaveContext.equips.equipment |= EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4); } - if (equipment == EQUIP_SWORD) { + if (equipment == EQUIP_TYPE_SWORD) { gSaveContext.equips.buttonItems[0] = ITEM_NONE; gSaveContext.infTable[29] = 1; } @@ -215,7 +215,7 @@ u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) { play->pauseCtx.cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; } - return sp26; + return equipValue; } void Inventory_ChangeUpgrade(s16 upgrade, s16 value) { diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c index e0b17fe72..1955a9235 100644 --- a/soh/src/code/z_demo.c +++ b/soh/src/code/z_demo.c @@ -994,9 +994,9 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB gSaveContext.nextTransitionType = 2; break; case 71: - gSaveContext.equips.equipment |= 0x0100; + gSaveContext.equips.equipment |= EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4); Player_SetEquipmentData(play, player); - gSaveContext.equips.equipment |= 0x1000; + gSaveContext.equips.equipment |= EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4); Player_SetEquipmentData(play, player); play->linkAgeOnLoad = 1; play->nextEntranceIndex = 0x0053; diff --git a/soh/src/code/z_elf_message.c b/soh/src/code/z_elf_message.c index 6c5558faf..e586c1bcc 100644 --- a/soh/src/code/z_elf_message.c +++ b/soh/src/code/z_elf_message.c @@ -46,8 +46,8 @@ u32 ElfMessage_CheckCondition(ElfMessage* msg) { return ((msg->byte0 & 1) == 1) == ((msg->byte1 & 0x0F) == CUR_UPG_VALUE(UPG_STRENGTH)); case (ELF_MSG_CONDITION_BOOTS << 4): return ((msg->byte0 & 1) == 1) == - (((gBitFlags[msg->byte3 - ITEM_BOOTS_KOKIRI] << gEquipShifts[EQUIP_BOOTS]) & - gSaveContext.inventory.equipment) != 0); + (CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, + msg->byte3 - ITEM_BOOTS_KOKIRI + EQUIP_INV_BOOTS_KOKIRI) != 0); case (ELF_MSG_CONDITION_SONG << 4): return ((msg->byte0 & 1) == 1) == (CHECK_QUEST_ITEM(msg->byte3 - ITEM_SONG_MINUET + QUEST_SONG_MINUET) != 0); diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 78eac4ece..da0f5f55f 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1617,7 +1617,7 @@ void Message_OpenText(PlayState* play, u16 textId) { // Increments text id based on piece of heart count, assumes the piece of heart text is all // in order and that you don't have more than the intended amount of heart pieces. textId += (gSaveContext.inventory.questItems & 0xF0000000 & 0xF0000000) >> 0x1C; - } else if (!IS_RANDO && (msgCtx->textId == 0xC && CHECK_OWNED_EQUIP(EQUIP_SWORD, 2))) { + } else if (!IS_RANDO && (msgCtx->textId == 0xC && CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BIGGORON))) { textId = 0xB; // Traded Giant's Knife for Biggoron Sword } else if (!IS_RANDO && (msgCtx->textId == 0xB4 && (Flags_GetEventChkInf(EVENTCHKINF_SPOKE_TO_CURSED_MAN_IN_SKULL_HOUSE)))) { textId = 0xB5; // Destroyed Gold Skulltula diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index cf3192c3d..ec25d2062 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1438,7 +1438,7 @@ Gfx* Gfx_TextureI8(Gfx* displayListHead, void* texture, s16 textureWidth, s16 te void Inventory_SwapAgeEquipment(void) { s16 i; - u16 temp; + u16 shieldEquipValue; if (LINK_AGE_IN_YEARS == YEARS_CHILD) { @@ -1483,8 +1483,15 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.cButtonSlots[1] = SLOT_BOMB; gSaveContext.equips.cButtonSlots[2] = SLOT_OCARINA; - gSaveContext.equips.equipment = (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && - gSaveContext.equips.buttonItems[0] == ITEM_NONE) ? 0x1120 :0x1122; + 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) && + gSaveContext.equips.buttonItems[0] == ITEM_NONE) { + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + } // Set the dpad to nothing gSaveContext.equips.buttonItems[4] = ITEM_NONE; @@ -1518,13 +1525,13 @@ void Inventory_SwapAgeEquipment(void) { } else { // When becoming child, set swordless flag if player doesn't have kokiri sword // Only in rando to keep swordless link bugs in vanilla - if (IS_RANDO && (1 << 0 & gSaveContext.inventory.equipment) == 0) { + if (IS_RANDO && (EQUIP_INV_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4) & gSaveContext.inventory.equipment) == 0) { Flags_SetInfTable(INFTABLE_SWORDLESS); } // When using enhancements, set swordless flag if player doesn't have kokiri sword or hasn't equipped a sword yet. // Then set the child equips button items to item none to ensure kokiri sword is not equipped - if ((CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) && ((1 << 0 & gSaveContext.inventory.equipment) == 0 || Flags_GetInfTable(INFTABLE_SWORDLESS))) { + if ((CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) && ((EQUIP_INV_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4) & gSaveContext.inventory.equipment) == 0 || Flags_GetInfTable(INFTABLE_SWORDLESS))) { Flags_SetInfTable(INFTABLE_SWORDLESS); gSaveContext.childEquips.buttonItems[0] = ITEM_NONE; } @@ -1558,10 +1565,10 @@ void Inventory_SwapAgeEquipment(void) { } gSaveContext.equips.equipment = gSaveContext.childEquips.equipment; - gSaveContext.equips.equipment &= 0xFFF0; + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); // Equips kokiri sword in the inventory screen only if kokiri sword exists in inventory and a sword has been equipped already - if (!((1 << 0 & gSaveContext.inventory.equipment) == 0) && !Flags_GetInfTable(INFTABLE_SWORDLESS)) { - gSaveContext.equips.equipment |= 0x0001; + if (!((EQUIP_INV_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4) & gSaveContext.inventory.equipment) == 0) && !Flags_GetInfTable(INFTABLE_SWORDLESS)) { + gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4); } } else if (gSaveContext.childEquips.buttonItems[0] != ITEM_NONE) { for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { @@ -1582,15 +1589,15 @@ void Inventory_SwapAgeEquipment(void) { } gSaveContext.equips.equipment = gSaveContext.childEquips.equipment; - gSaveContext.equips.equipment &= 0xFFF0; - gSaveContext.equips.equipment |= 0x0001; + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4); } else if (IS_RANDO && Randomizer_GetSettingValue(RSK_STARTING_AGE) == RO_AGE_ADULT) { /*If in rando and starting age is adult, childEquips is not initialized and buttonItems[0] will be ITEM_NONE. When changing age from adult -> child, reset equips to "default" (only kokiri tunic/boots equipped, no sword, no C-button items, no D-Pad items). When becoming child, set swordless flag if player doesn't have kokiri sword Only in rando to keep swordless link bugs in vanilla*/ - if (1 << 0 & gSaveContext.inventory.equipment == 0) { + if (EQUIP_INV_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4) & gSaveContext.inventory.equipment == 0) { Flags_SetInfTable(INFTABLE_SWORDLESS); } @@ -1601,7 +1608,10 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.cButtonSlots[i-1] = ITEM_NONE; } } - gSaveContext.equips.equipment = 0x1111; + gSaveContext.equips.equipment = (EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4)) | + (EQUIP_VALUE_SHIELD_DEKU << (EQUIP_TYPE_SHIELD * 4)) | + (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | + (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); } if ((CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) && @@ -1609,17 +1619,18 @@ void Inventory_SwapAgeEquipment(void) { Flags_SetInfTable(INFTABLE_SWORDLESS); if (gSaveContext.childEquips.equipment == 0) { // force equip kokiri tunic and boots in scenario gSaveContext.childEquips.equipment is uninitialized - gSaveContext.equips.equipment &= 0xFFF0; - gSaveContext.equips.equipment |= 0x1100; + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.equipment |= (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | + (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); } } } CVarSetInteger("gSwitchTimeline", 0); - temp = gEquipMasks[EQUIP_SHIELD] & gSaveContext.equips.equipment; - if (temp != 0) { - temp >>= gEquipShifts[EQUIP_SHIELD]; - if (!(gBitFlags[temp + 3] & gSaveContext.inventory.equipment)) { - gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_SHIELD]; + shieldEquipValue = gEquipMasks[EQUIP_TYPE_SHIELD] & gSaveContext.equips.equipment; + if (shieldEquipValue != 0) { + shieldEquipValue >>= gEquipShifts[EQUIP_TYPE_SHIELD]; + if (!CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SHIELD, shieldEquipValue - 1)) { + gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_TYPE_SHIELD]; } } } @@ -1634,10 +1645,10 @@ void Interface_InitHorsebackArchery(PlayState* play) { } void func_800849EC(PlayState* play) { - gSaveContext.inventory.equipment |= gBitFlags[2] << gEquipShifts[EQUIP_SWORD]; - gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; + gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BIGGORON); + gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE); - if (gBitFlags[3] & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE)) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; } else { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; @@ -1882,17 +1893,21 @@ u8 Item_Give(PlayState* play, u8 item) { return Return_Item(item, MOD_NONE, ITEM_NONE); } else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_BGS)) { - gSaveContext.inventory.equipment |= gBitFlags[item - ITEM_SWORD_KOKIRI] << gEquipShifts[EQUIP_SWORD]; + gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, item - ITEM_SWORD_KOKIRI + EQUIP_INV_SWORD_KOKIRI); // Both Giant's Knife and Biggoron Sword have the same Item ID, so this part handles both of them if (item == ITEM_SWORD_BGS) { gSaveContext.swordHealth = 8; // In rando, when buying Giant's Knife, also check - // for 0xE in case we don't have Kokiri Sword - if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF || (IS_RANDO && ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xE)) { + // without the Koriri Sword in case we don't have it + 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_MASTER) | (1 << EQUIP_INV_SWORD_BIGGORON) | (1 << EQUIP_INV_SWORD_BROKENGIANTKNIFE)))) { - gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; + gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE); if (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; @@ -1904,8 +1919,8 @@ u8 Item_Give(PlayState* play, u8 item) { } else if (item == ITEM_SWORD_MASTER) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - gSaveContext.equips.equipment &= 0xFFF0; - gSaveContext.equips.equipment |= 0x0002; + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_MASTER << (EQUIP_TYPE_SWORD * 4); if (play != NULL) { Interface_LoadItemIcon1(play, 0); } @@ -1913,13 +1928,13 @@ u8 Item_Give(PlayState* play, u8 item) { return Return_Item(item, MOD_NONE, ITEM_NONE); } else if ((item >= ITEM_SHIELD_DEKU) && (item <= ITEM_SHIELD_MIRROR)) { - gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_SHIELD]); + gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_SHIELD, item - ITEM_SHIELD_DEKU); return Return_Item(item, MOD_NONE, ITEM_NONE); } else if ((item >= ITEM_TUNIC_KOKIRI) && (item <= ITEM_TUNIC_ZORA)) { - gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_TUNIC_KOKIRI] << gEquipShifts[EQUIP_TUNIC]); + gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_TUNIC, item - ITEM_TUNIC_KOKIRI); return Return_Item(item, MOD_NONE, ITEM_NONE); } else if ((item >= ITEM_BOOTS_KOKIRI) && (item <= ITEM_BOOTS_HOVER)) { - gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_BOOTS_KOKIRI] << gEquipShifts[EQUIP_BOOTS]); + gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_BOOTS, item - ITEM_BOOTS_KOKIRI); return Return_Item(item, MOD_NONE, ITEM_NONE); } else if ((item == ITEM_KEY_BOSS) || (item == ITEM_COMPASS) || (item == ITEM_DUNGEON_MAP)) { gSaveContext.inventory.dungeonItems[gSaveContext.mapIndex] |= gBitFlags[item - ITEM_KEY_BOSS]; @@ -2610,8 +2625,8 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { } if (item == RG_MASTER_SWORD) { - if (!CHECK_OWNED_EQUIP(EQUIP_SWORD, 1)) { - gSaveContext.inventory.equipment |= gBitFlags[1] << gEquipShifts[EQUIP_SWORD]; + if (!CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)) { + gSaveContext.inventory.equipment |= gBitFlags[1] << gEquipShifts[EQUIP_TYPE_SWORD]; } return Return_Item_Entry(giEntry, RG_NONE); } @@ -2651,26 +2666,25 @@ u8 Item_CheckObtainability(u8 item) { } else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_BGS)) { if (item == ITEM_SWORD_BGS) { return ITEM_NONE; - } else if ((gBitFlags[item - ITEM_SWORD_KOKIRI] << gEquipShifts[EQUIP_SWORD]) & - gSaveContext.inventory.equipment) { + } else if (CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, item - ITEM_SWORD_KOKIRI + EQUIP_INV_SWORD_KOKIRI)) { return IS_RANDO ? ITEM_NONE : item; } else { return ITEM_NONE; } } else if ((item >= ITEM_SHIELD_DEKU) && (item <= ITEM_SHIELD_MIRROR)) { - if ((gBitFlags[item - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_SHIELD]) & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP(EQUIP_TYPE_SHIELD, item - ITEM_SHIELD_DEKU + EQUIP_INV_SHIELD_DEKU)) { return IS_RANDO ? ITEM_NONE : item; } else { return ITEM_NONE; } } else if ((item >= ITEM_TUNIC_KOKIRI) && (item <= ITEM_TUNIC_ZORA)) { - if ((gBitFlags[item - ITEM_TUNIC_KOKIRI] << gEquipShifts[EQUIP_TUNIC]) & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, item - ITEM_TUNIC_KOKIRI + EQUIP_INV_TUNIC_KOKIRI)) { return IS_RANDO ? ITEM_NONE : item; } else { return ITEM_NONE; } } else if ((item >= ITEM_BOOTS_KOKIRI) && (item <= ITEM_BOOTS_HOVER)) { - if ((gBitFlags[item - ITEM_BOOTS_KOKIRI] << gEquipShifts[EQUIP_BOOTS]) & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, item - ITEM_BOOTS_KOKIRI + EQUIP_INV_BOOTS_KOKIRI)) { return IS_RANDO ? ITEM_NONE : item; } else { return ITEM_NONE; @@ -6489,11 +6503,11 @@ void Interface_Update(PlayState* play) { D_80125A58 = Player_GetEnvironmentalHazard(play); if (D_80125A58 == 1) { - if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == 2 || CVarGetInteger("gSuperTunic", 0) != 0) { + if (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) == EQUIP_VALUE_TUNIC_GORON || CVarGetInteger("gSuperTunic", 0) != 0) { D_80125A58 = 0; } } else if ((Player_GetEnvironmentalHazard(play) >= 2) && (Player_GetEnvironmentalHazard(play) < 5)) { - if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == 3 || CVarGetInteger("gSuperTunic", 0) != 0) { + if (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) == EQUIP_VALUE_TUNIC_ZORA || CVarGetInteger("gSuperTunic", 0) != 0) { D_80125A58 = 0; } } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index f4b71fc0a..820f2c672 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -669,9 +669,9 @@ void func_8008EC70(Player* this) { void Player_SetEquipmentData(PlayState* play, Player* this) { if (this->csMode != 0x56) { - this->currentShield = CUR_EQUIP_VALUE(EQUIP_SHIELD); - this->currentTunic = CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1; - this->currentBoots = CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1; + this->currentShield = SHIELD_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD)); + this->currentTunic = TUNIC_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC)); + this->currentBoots = BOOTS_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS)); this->currentSwordItemId = B_BTN_ITEM; Player_SetModelGroup(this, Player_ActionToModelGroup(this, this->heldItemAction)); Player_SetBootData(play, this); @@ -2117,11 +2117,11 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* if (CVarGetInteger("gPauseLiveLink", 0) || CVarGetInteger("gPauseTriforce", 0)) { uintptr_t anim = 0; // Initialise anim - if (CUR_EQUIP_VALUE(EQUIP_SWORD) >= 3) { + if (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) >= EQUIP_VALUE_SWORD_BIGGORON) { EquipedStance = 1; - } else if (CUR_EQUIP_VALUE(EQUIP_SHIELD) == 0) { + } else if (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SWORD_NONE) { EquipedStance = 2; - } else if (CUR_EQUIP_VALUE(EQUIP_SHIELD) == 2 && LINK_AGE_IN_YEARS == YEARS_CHILD) { + } else if (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SWORD_MASTER && LINK_AGE_IN_YEARS == YEARS_CHILD) { EquipedStance = 3; } else { // Link is idle so revert to 0 @@ -2192,8 +2192,8 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* if (FrameCountSinceLastAnim >= SwitchAtFrame) { LastAnim = SelectedAnim; if (LastAnim==1) { - if ((CUR_EQUIP_VALUE(EQUIP_SWORD)!=PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)!= PLAYER_SHIELD_NONE)) { // if the player has a sword and shield equipped - if ((LINK_AGE_IN_YEARS == YEARS_ADULT) || (CUR_EQUIP_VALUE(EQUIP_SHIELD) == PLAYER_SHIELD_DEKU)) { // if he's an adult or a kid with the deku shield + if ((CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE)) { // if the player has a sword and shield equipped + if ((LINK_AGE_IN_YEARS == YEARS_ADULT) || (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_DEKU)) { // if he's an adult or a kid with the deku shield SelectedAnim = (rand() % (6 - 2 + 1)) + 2; // select any 5 animations that aren't the default standing anim } else { //else if he's a child with a shield that isn't the deku shield s16 randval = (rand() % (5 - 2 + 1)) + 2; // 4 animations @@ -2203,15 +2203,15 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* SelectedAnim=randval; } } - } else if ((CUR_EQUIP_VALUE(EQUIP_SWORD) != PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)==PLAYER_SHIELD_NONE)) { // if the player has a sword equipped but no shield + } else if ((CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_NONE)) { // if the player has a sword equipped but no shield s16 randval = (rand() % (5 - 2 + 1)) + 2; // 4 animations if (randval==4) { //if its the shield anim SelectedAnim==6; // set to yawn anim } else { SelectedAnim=randval; } - } else if ((CUR_EQUIP_VALUE(EQUIP_SWORD) == PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)!=PLAYER_SHIELD_NONE)) { //if the player has a shield equipped but no sword - if ((LINK_AGE_IN_YEARS == YEARS_ADULT) || (CUR_EQUIP_VALUE(EQUIP_SHIELD) == PLAYER_SHIELD_DEKU)) {// if he's an adult or a kid with the deku shield + } else if ((CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE)) { //if the player has a shield equipped but no sword + if ((LINK_AGE_IN_YEARS == YEARS_ADULT) || (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_DEKU)) {// if he's an adult or a kid with the deku shield s16 randval = (rand() % (5 - 2 + 1)) + 2; // 4 animations if (randval==5) { //if its the sword anim SelectedAnim==6; // set to yawn anim @@ -2226,7 +2226,7 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* SelectedAnim=randval; } } - } else if ((CUR_EQUIP_VALUE(EQUIP_SWORD) == PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)==PLAYER_SHIELD_NONE)) { // if the player has no sword or shield equipped + } else if ((CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_NONE)) { // if the player has no sword or shield equipped s16 randval = (rand() % (4 - 2 + 1)) + 2; // 3 animations if (randval==4) { //if its the shield anim SelectedAnim==6; // set to yawn anim @@ -2297,7 +2297,7 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* srcTable = gLinkPauseChildJointTable; } } else { - if (sword == 3) { + if (sword == PLAYER_SWORD_BIGGORON) { srcTable = gLinkPauseAdultBgsJointTable; } else if (shield != PLAYER_SHIELD_NONE) { srcTable = gLinkPauseAdultShieldJointTable; diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 225b29dc7..057460b62 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -168,13 +168,12 @@ void Sram_OpenSave() { } } - // check for owning kokiri sword.. to restore master sword? bug or debug feature? - if (LINK_AGE_IN_YEARS == YEARS_ADULT && !CHECK_OWNED_EQUIP(EQUIP_SWORD, 1)) { + if (LINK_AGE_IN_YEARS == YEARS_ADULT && !CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)) { if (!IS_RANDO || !Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) { - gSaveContext.inventory.equipment |= gBitFlags[1] << gEquipShifts[EQUIP_SWORD]; + gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER); gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - gSaveContext.equips.equipment &= ~0xF; - gSaveContext.equips.equipment |= 2; + gSaveContext.equips.equipment &= ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_MASTER << (EQUIP_TYPE_SWORD * 4); } } -- cgit v1.2.3