diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2023-11-05 07:43:24 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-05 07:43:24 -0600 |
| commit | 20bb36c16419fb2811ea68583ba00a53abe739e6 (patch) | |
| tree | 0463b2f6b8362905cbcf2cdd4e9d889b5098bcac /soh/src | |
| parent | 051314e8b1f452cbfa62abe7decac73b8b5ae071 (diff) | |
| parent | 129f410aba106b10b72e79a0d075464e95021db4 (diff) | |
Merge pull request #3352 from Archez/mergeDevelopIntoRando4
Merge develop into develop-rando
Diffstat (limited to 'soh/src')
56 files changed, 1053 insertions, 439 deletions
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/game.c b/soh/src/code/game.c index 4167a5a96..b46aa4ebd 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -93,7 +93,7 @@ void func_800C4344(GameState* gameState) { HREG(95) = CHECK_BTN_ALL(selectedInput->press.button, hReg82); } - if (gIsCtrlr2Valid) { + if (CVarGetInteger("gRegEditEnabled", 0) || gIsCtrlr2Valid) { func_8006390C(&gameState->input[1]); } diff --git a/soh/src/code/main.c b/soh/src/code/main.c index b59a825c1..9d52833fd 100644 --- a/soh/src/code/main.c +++ b/soh/src/code/main.c @@ -65,8 +65,10 @@ int main(int argc, char** argv) CrashHandlerRegisterCallback(CrashHandler_PrintSohData); BootCommands_Init(); + Heaps_Alloc(); Main(0); DeinitOTR(); + Heaps_Free(); return 0; } @@ -87,7 +89,6 @@ void Main(void* arg) { PreNmiBuff_Init(gAppNmiBufferPtr); Fault_Init(); SysCfb_Init(0); - Heaps_Alloc(); sysHeap = (uintptr_t)gSystemHeap; fb = SysCfb_GetFbPtr(0); gSystemHeapSize = 1024 * 1024 * 4; @@ -156,6 +157,4 @@ void Main(void* arg) { osDestroyThread(&sGraphThread); func_800FBFD8(); osSyncPrintf("mainproc 実行終了\n"); // "End of execution" - - Heaps_Free(); } diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 1a122cc9b..79a3c8ace 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -2451,7 +2451,7 @@ void func_80030488(PlayState* play) { void Actor_DisableLens(PlayState* play) { if (play->actorCtx.lensActive) { play->actorCtx.lensActive = false; - func_800876C8(play); + Magic_Reset(play); } } diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 783731506..a177e29e7 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -2138,8 +2138,6 @@ s32 Camera_Parallel1(Camera* camera) { OLib_Vec3fDiffToVecSphGeo(&atToEyeDir, at, eye); OLib_Vec3fDiffToVecSphGeo(&atToEyeNextDir, at, eyeNext); - camera->play->manualCamera = false; - switch (camera->animState) { case 0: case 0xA: @@ -7888,6 +7886,15 @@ s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags) { break; } } + + // Clear free camera if an action is performed that would move the camera (targeting, first person, talking) + if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1 && + ((mode >= CAM_MODE_TARGET && mode <= CAM_MODE_BATTLE) || + (mode >= CAM_MODE_FIRSTPERSON && mode <= CAM_MODE_CLIMBZ) || mode == CAM_MODE_HANGZ || + mode == CAM_MODE_FOLLOWBOOMERANG)) { + camera->play->manualCamera = false; + } + func_8005A02C(camera); camera->mode = mode; return 0x80000000 | mode; diff --git a/soh/src/code/z_debug.c b/soh/src/code/z_debug.c index 8eb9de5a8..267846eb4 100644 --- a/soh/src/code/z_debug.c +++ b/soh/src/code/z_debug.c @@ -24,12 +24,35 @@ Color_RGBA8 printTextColors[] = { }; InputCombo inputCombos[REG_GROUPS] = { - { BTN_L, BTN_CUP }, { BTN_L, BTN_CLEFT }, { BTN_L, BTN_CDOWN }, { BTN_L, BTN_A }, { BTN_R, BTN_CDOWN }, - { BTN_L, BTN_CRIGHT }, { BTN_L, BTN_R }, { BTN_L, BTN_DLEFT }, { BTN_L, BTN_DRIGHT }, { BTN_L, BTN_DUP }, - { BTN_L, BTN_B }, { BTN_L, BTN_Z }, { BTN_L, BTN_DDOWN }, { BTN_R, BTN_A }, { BTN_R, BTN_B }, - { BTN_R, BTN_Z }, { BTN_R, BTN_L }, { BTN_R, BTN_CUP }, { BTN_R, BTN_CRIGHT }, { BTN_R, BTN_DLEFT }, - { BTN_R, BTN_CLEFT }, { BTN_R, BTN_START }, { BTN_L, BTN_START }, { BTN_R, BTN_DRIGHT }, { BTN_R, BTN_DUP }, - { BTN_START, BTN_R }, { BTN_START, BTN_A }, { BTN_START, BTN_B }, { BTN_START, BTN_CRIGHT }, + { BTN_L, BTN_CUP }, //REG + { BTN_L, BTN_CLEFT }, //SREG + { BTN_L, BTN_CDOWN }, //OREG + { BTN_L, BTN_A }, //PREG + { BTN_R, BTN_CDOWN }, //QREG + { BTN_L, BTN_CRIGHT }, //MREG + { BTN_L, BTN_R }, //YREG + { BTN_L, BTN_DLEFT }, //DREG + { BTN_L, BTN_DRIGHT }, //UREG + { BTN_L, BTN_DUP }, //IREG + { BTN_L, BTN_B }, //ZREG + { BTN_L, BTN_Z }, //CREG + { BTN_L, BTN_DDOWN }, //NREG + { BTN_R, BTN_A }, //KREG + { BTN_R, BTN_B }, //XREG + { BTN_R, BTN_Z }, //cREG + { BTN_R, BTN_L }, //sREG + { BTN_R, BTN_CUP }, //iREG + { BTN_R, BTN_CRIGHT }, //WREG + { BTN_R, BTN_DLEFT }, //AREG + { BTN_R, BTN_CLEFT }, //VREG + { BTN_R, BTN_START }, //HREG + { BTN_L, BTN_START }, //GREG + { BTN_R, BTN_DRIGHT }, //mREG + { BTN_R, BTN_DUP }, //nREG + { BTN_START, BTN_R }, //BREG + { BTN_START, BTN_A }, //dREG + { BTN_START, BTN_B }, //kREG + { BTN_START, BTN_CRIGHT }, //bREG }; char regChar[] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb"; 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_game_over.c b/soh/src/code/z_game_over.c index 4b10cb5e2..2d46a1899 100644 --- a/soh/src/code/z_game_over.c +++ b/soh/src/code/z_game_over.c @@ -57,6 +57,7 @@ void GameOver_Update(PlayState* play) { if (gSaveContext.buttonStatus[0] != BTN_ENABLED) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + Interface_RandoRestoreSwordless(); } else { gSaveContext.equips.buttonItems[0] = ITEM_NONE; } diff --git a/soh/src/code/z_kaleido_setup.c b/soh/src/code/z_kaleido_setup.c index e9f097a45..77cc43e99 100644 --- a/soh/src/code/z_kaleido_setup.c +++ b/soh/src/code/z_kaleido_setup.c @@ -15,7 +15,7 @@ void KaleidoSetup_Update(PlayState* play) { if (pauseCtx->state == 0 && pauseCtx->debugState == 0 && play->gameOverCtx.state == GAMEOVER_INACTIVE && play->sceneLoadFlag == 0 && play->transitionMode == 0 && gSaveContext.cutsceneIndex < 0xFFF0 && gSaveContext.nextCutsceneIndex < 0xFFF0 && !Play_InCsMode(play) && - play->shootingGalleryStatus <= 1 && gSaveContext.magicState != 8 && gSaveContext.magicState != 9 && + play->shootingGalleryStatus <= 1 && gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY && gSaveContext.magicState != MAGIC_STATE_FILL && (play->sceneNum != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38))) { u8 easyPauseBufferEnabled = CVarGetInteger("gCheatEasyPauseBufferEnabled", 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 75c85e3e4..ec25d2062 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -811,6 +811,20 @@ void func_80082850(PlayState* play, s16 maxAlpha) { } } +// buttonStatus[0] is used to represent if the B button is disabled, but also tracks +// the last active B button item during mini-games/epona (temp B) +// Since ITEM_NONE is the same as BTN_DISABLED (255), we need a different value to help us track +// that the player was swordless before like ITEM_NONE_FE (254) +#define SWORDLESS_STATUS ITEM_NONE_FE + +// Restores swordless state when using the custom value for temp B and then clears temp B +void Interface_RandoRestoreSwordless(void) { + if (IS_RANDO && gSaveContext.buttonStatus[0] == SWORDLESS_STATUS) { + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + gSaveContext.buttonStatus[0] = BTN_ENABLED; + } +} + void func_80083108(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; Player* player = GET_PLAYER(play); @@ -818,13 +832,20 @@ void func_80083108(PlayState* play) { s16 i; s16 sp28 = 0; + // Check for the player being swordless in rando (no item on B and swordless flag set) + // Child is always assumed due to not finding kokiri sword yet. Adult is only checked with MS shuffle on. + u8 randoIsSwordless = IS_RANDO && (LINK_IS_CHILD || Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) && + gSaveContext.equips.buttonItems[0] == ITEM_NONE && Flags_GetInfTable(INFTABLE_SWORDLESS); + u8 randoWasSwordlessBefore = IS_RANDO && gSaveContext.buttonStatus[0] == SWORDLESS_STATUS; + u8 randoCanTrackSwordless = randoIsSwordless && !randoWasSwordlessBefore; + if ((gSaveContext.cutsceneIndex < 0xFFF0) || ((play->sceneNum == SCENE_LON_LON_RANCH) && (gSaveContext.cutsceneIndex == 0xFFF0))) { gSaveContext.unk_13E7 = 0; - if ((player->stateFlags1 & 0x00800000) || (play->shootingGalleryStatus > 1) || + if ((player->stateFlags1 & PLAYER_STATE1_ON_HORSE) || (play->shootingGalleryStatus > 1) || ((play->sceneNum == SCENE_BOMBCHU_BOWLING_ALLEY) && Flags_GetSwitch(play, 0x38))) { - if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { + if (gSaveContext.equips.buttonItems[0] != ITEM_NONE || randoCanTrackSwordless) { gSaveContext.unk_13E7 = 1; if (gSaveContext.buttonStatus[0] == BTN_DISABLED) { @@ -837,9 +858,14 @@ void func_80083108(PlayState* play) { if ((gSaveContext.equips.buttonItems[0] != ITEM_SLINGSHOT) && (gSaveContext.equips.buttonItems[0] != ITEM_BOW) && (gSaveContext.equips.buttonItems[0] != ITEM_BOMBCHU) && - (gSaveContext.equips.buttonItems[0] != ITEM_NONE)) { + (gSaveContext.equips.buttonItems[0] != ITEM_NONE || randoCanTrackSwordless)) { gSaveContext.buttonStatus[0] = gSaveContext.equips.buttonItems[0]; + // Track swordless status for restoration later + if (randoCanTrackSwordless) { + gSaveContext.buttonStatus[0] = SWORDLESS_STATUS; + } + if ((play->sceneNum == SCENE_BOMBCHU_BOWLING_ALLEY) && Flags_GetSwitch(play, 0x38)) { gSaveContext.equips.buttonItems[0] = ITEM_BOMBCHU; Interface_LoadItemIcon1(play, 0); @@ -875,11 +901,11 @@ void func_80083108(PlayState* play) { Interface_ChangeAlpha(8); } else if ((play->sceneNum == SCENE_BOMBCHU_BOWLING_ALLEY) && Flags_GetSwitch(play, 0x38)) { Interface_ChangeAlpha(8); - } else if (player->stateFlags1 & 0x00800000) { + } else if (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) { Interface_ChangeAlpha(12); } } else { - if (player->stateFlags1 & 0x00800000) { + if (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) { Interface_ChangeAlpha(12); } } @@ -891,6 +917,12 @@ void func_80083108(PlayState* play) { if (play->interfaceCtx.unk_260 != 0) { if (gSaveContext.equips.buttonItems[0] != ITEM_FISHING_POLE) { gSaveContext.buttonStatus[0] = gSaveContext.equips.buttonItems[0]; + + // Track swordless status for restoration later + if (randoCanTrackSwordless) { + gSaveContext.buttonStatus[0] = SWORDLESS_STATUS; + } + gSaveContext.equips.buttonItems[0] = ITEM_FISHING_POLE; gSaveContext.unk_13EA = 0; Interface_LoadItemIcon1(play, 0); @@ -904,6 +936,8 @@ void func_80083108(PlayState* play) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; gSaveContext.unk_13EA = 0; + Interface_RandoRestoreSwordless(); + if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { Interface_LoadItemIcon1(play, 0); } @@ -974,7 +1008,7 @@ void func_80083108(PlayState* play) { } Interface_ChangeAlpha(50); - } else if ((player->stateFlags1 & 0x00200000) || (player->stateFlags2 & PLAYER_STATE2_CRAWLING)) { + } else if ((player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) || (player->stateFlags2 & PLAYER_STATE2_CRAWLING)) { if (gSaveContext.buttonStatus[0] != BTN_DISABLED) { gSaveContext.buttonStatus[0] = BTN_DISABLED; gSaveContext.buttonStatus[1] = BTN_DISABLED; @@ -988,7 +1022,7 @@ void func_80083108(PlayState* play) { Interface_ChangeAlpha(50); } } else if ((gSaveContext.eventInf[0] & 0xF) == 1) { - if (player->stateFlags1 & 0x00800000) { + if (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) { if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) && (gSaveContext.equips.buttonItems[0] != ITEM_BOW)) { if (gSaveContext.inventory.items[SLOT_BOW] == ITEM_NONE) { @@ -1009,6 +1043,8 @@ void func_80083108(PlayState* play) { (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_BGS) && (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + + Interface_RandoRestoreSwordless(); } else { gSaveContext.buttonStatus[0] = gSaveContext.equips.buttonItems[0]; } @@ -1048,8 +1084,12 @@ void func_80083108(PlayState* play) { (gSaveContext.equips.buttonItems[0] == ITEM_BOW) || (gSaveContext.equips.buttonItems[0] == ITEM_BOMBCHU) || (gSaveContext.equips.buttonItems[0] == ITEM_NONE)) { - if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0)) { + if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0) || + randoWasSwordlessBefore) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + + Interface_RandoRestoreSwordless(); + sp28 = 1; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { @@ -1071,8 +1111,12 @@ void func_80083108(PlayState* play) { (gSaveContext.equips.buttonItems[0] == ITEM_BOW) || (gSaveContext.equips.buttonItems[0] == ITEM_BOMBCHU) || (gSaveContext.equips.buttonItems[0] == ITEM_NONE)) { - if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0)) { + if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0) || + randoWasSwordlessBefore) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + + Interface_RandoRestoreSwordless(); + sp28 = 1; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { @@ -1394,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) { @@ -1412,15 +1456,20 @@ void Inventory_SwapAgeEquipment(void) { } // When becoming adult, remove swordless flag since we'll get master sword + // (Unless Master Sword is shuffled) // Only in rando to keep swordless link bugs in vanilla - if (IS_RANDO) { + if (IS_RANDO && !Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) { Flags_UnsetInfTable(INFTABLE_SWORDLESS); } gSaveContext.childEquips.equipment = gSaveContext.equips.equipment; - if (gSaveContext.adultEquips.buttonItems[0] == ITEM_NONE) { - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + if (gSaveContext.adultEquips.buttonItems[0] == ITEM_NONE && !(IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && gSaveContext.adultEquips.equipment)) { + if (!IS_RANDO || !Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) { + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + } else { + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + } if (gSaveContext.inventory.items[SLOT_NUT] != ITEM_NONE) { gSaveContext.equips.buttonItems[1] = ITEM_NUT; @@ -1433,7 +1482,16 @@ 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 = 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; @@ -1467,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; } @@ -1507,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++) { @@ -1531,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); } @@ -1550,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)) && @@ -1558,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]; } } } @@ -1583,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; @@ -1626,11 +1688,13 @@ void func_80084BF4(PlayState* play, u16 flag) { (gSaveContext.equips.buttonItems[0] == ITEM_BOMBCHU) || (gSaveContext.equips.buttonItems[0] == ITEM_FISHING_POLE)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + Interface_RandoRestoreSwordless(); Interface_LoadItemIcon1(play, 0); } } else if (gSaveContext.equips.buttonItems[0] == ITEM_NONE) { if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + Interface_RandoRestoreSwordless(); Interface_LoadItemIcon1(play, 0); } } @@ -1829,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; @@ -1851,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); } @@ -1860,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]; @@ -2196,14 +2264,14 @@ u8 Item_Give(PlayState* play, u8 item) { } return Return_Item(item, MOD_NONE, item); } else if (item == ITEM_MAGIC_SMALL) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { if (play != NULL) { Magic_Fill(play); } } if (play != NULL) { - func_80087708(play, 12, 5); + Magic_RequestChange(play, 12, MAGIC_ADD); } if (!Flags_GetInfTable(INFTABLE_198)) { @@ -2213,13 +2281,13 @@ u8 Item_Give(PlayState* play, u8 item) { return Return_Item(item, MOD_NONE, item); } else if (item == ITEM_MAGIC_LARGE) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { if (play != NULL) { Magic_Fill(play); } } if (play != NULL) { - func_80087708(play, 24, 5); + Magic_RequestChange(play, 24, MAGIC_ADD); } if (!Flags_GetInfTable(INFTABLE_198)) { @@ -2328,7 +2396,7 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { slot = SLOT(item); if (item == RG_MAGIC_SINGLE) { gSaveContext.isMagicAcquired = true; - gSaveContext.magicFillTarget = 0x30; + gSaveContext.magicFillTarget = MAGIC_NORMAL_METER; Magic_Fill(play); return Return_Item_Entry(giEntry, RG_NONE); } else if (item == RG_MAGIC_DOUBLE) { @@ -2336,7 +2404,7 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { gSaveContext.isMagicAcquired = true; } gSaveContext.isDoubleMagicAcquired = true; - gSaveContext.magicFillTarget = 0x60; + gSaveContext.magicFillTarget = MAGIC_DOUBLE_METER; gSaveContext.magicLevel = 0; Magic_Fill(play); return Return_Item_Entry(giEntry, RG_NONE); @@ -2556,6 +2624,13 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { return Return_Item_Entry(giEntry, RG_NONE); } + if (item == RG_MASTER_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); + } + temp = gSaveContext.inventory.items[slot]; osSyncPrintf("Item_Register(%d)=%d %d\n", slot, item, temp); INV_CONTENT(item) = item; @@ -2591,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; @@ -2782,6 +2856,13 @@ s32 Inventory_HasSpecificBottle(u8 bottleItem) { } } +void byteSwapInventory() { + gSaveContext.inventory.equipment = BE16SWAP(gSaveContext.inventory.equipment); + gSaveContext.inventory.upgrades = BE32SWAP(gSaveContext.inventory.upgrades); + gSaveContext.inventory.questItems = BE32SWAP(gSaveContext.inventory.questItems); + gSaveContext.inventory.gsTokens = BE16SWAP(gSaveContext.inventory.gsTokens); +} + void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 button) { osSyncPrintf("item_no=%x, c_no=%x, Pt=%x Item_Register=%x\n", item, button, gSaveContext.equips.cButtonSlots[button - 1], @@ -2793,7 +2874,14 @@ void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 button) { item = ITEM_MILK_HALF; } - gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item; + if (CVarGetInteger("gRestoreRBAValues",0)) { + byteSwapInventory(); + gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item; + byteSwapInventory(); + } else { + gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item; + } + gSaveContext.equips.buttonItems[button] = item; Interface_LoadItemIcon1(play, button); @@ -3126,96 +3214,96 @@ void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { void Magic_Fill(PlayState* play) { if (gSaveContext.isMagicAcquired) { gSaveContext.prevMagicState = gSaveContext.magicState; - gSaveContext.magicFillTarget = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30; - gSaveContext.magicState = 9; + gSaveContext.magicFillTarget = (gSaveContext.isDoubleMagicAcquired + 1) * MAGIC_NORMAL_METER; + gSaveContext.magicState = MAGIC_STATE_FILL; } } -void func_800876C8(PlayState* play) { - if ((gSaveContext.magicState != 8) && (gSaveContext.magicState != 9)) { - if (gSaveContext.magicState == 10) { +void Magic_Reset(PlayState* play) { + if ((gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { + if (gSaveContext.magicState == MAGIC_STATE_ADD) { gSaveContext.prevMagicState = gSaveContext.magicState; } - gSaveContext.magicState = 5; + gSaveContext.magicState = MAGIC_STATE_RESET; } } -s32 func_80087708(PlayState* play, s16 arg1, s16 arg2) { +s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type) { if (!gSaveContext.isMagicAcquired) { - return 0; + return false; } - if ((arg2 != 5) && (gSaveContext.magic - arg1) < 0) { + if ((type != 5) && (gSaveContext.magic - amount) < 0) { if (gSaveContext.magicCapacity != 0) { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - return 0; + return false; } - switch (arg2) { - case 0: - case 2: - if ((gSaveContext.magicState == 0) || (gSaveContext.magicState == 7)) { - if (gSaveContext.magicState == 7) { + switch (type) { + case MAGIC_CONSUME_NOW: + case MAGIC_CONSUME_NOW_ALT: + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { play->actorCtx.lensActive = false; } - gSaveContext.magicTarget = gSaveContext.magic - arg1; - gSaveContext.magicState = 1; + gSaveContext.magicTarget = gSaveContext.magic - amount; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; return 1; } else { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - return 0; + return false; } - case 1: - if ((gSaveContext.magicState == 0) || (gSaveContext.magicState == 7)) { - if (gSaveContext.magicState == 7) { + case MAGIC_CONSUME_WAIT_NO_PREVIEW: + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { play->actorCtx.lensActive = false; } - gSaveContext.magicTarget = gSaveContext.magic - arg1; - gSaveContext.magicState = 6; - return 1; + gSaveContext.magicTarget = gSaveContext.magic - amount; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_3; + return true; } else { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - return 0; + return false; } - case 3: - if (gSaveContext.magicState == 0) { + case MAGIC_CONSUME_LENS: + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { if (gSaveContext.magic != 0) { play->interfaceCtx.unk_230 = 80; - gSaveContext.magicState = 7; - return 1; + gSaveContext.magicState = MAGIC_STATE_CONSUME_LENS; + return true; } else { - return 0; + return false; } } else { - if (gSaveContext.magicState == 7) { - return 1; + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + return true; } else { - return 0; + return false; } } - case 4: - if ((gSaveContext.magicState == 0) || (gSaveContext.magicState == 7)) { - if (gSaveContext.magicState == 7) { + case MAGIC_CONSUME_WAIT_PREVIEW: + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { play->actorCtx.lensActive = false; } - gSaveContext.magicTarget = gSaveContext.magic - arg1; - gSaveContext.magicState = 4; - return 1; + gSaveContext.magicTarget = gSaveContext.magic - amount; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_2; + return true; } else { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - return 0; + return false; } - case 5: + case MAGIC_ADD: if (gSaveContext.magicCapacity >= gSaveContext.magic) { - gSaveContext.magicTarget = gSaveContext.magic + arg1; + gSaveContext.magicTarget = gSaveContext.magic + amount; if (gSaveContext.magicTarget >= gSaveContext.magicCapacity) { gSaveContext.magicTarget = gSaveContext.magicCapacity; } - gSaveContext.magicState = 10; - return 1; + gSaveContext.magicState = MAGIC_STATE_ADD; + return true; } break; } @@ -3264,8 +3352,8 @@ void Interface_UpdateMagicBar(PlayState* play) { s16 temp; switch (gSaveContext.magicState) { - case 8: - temp = gSaveContext.magicLevel * 0x30; + case MAGIC_STATE_STEP_CAPACITY: + temp = gSaveContext.magicLevel * MAGIC_NORMAL_METER; if (gSaveContext.magicCapacity != temp) { if (gSaveContext.magicCapacity < temp) { gSaveContext.magicCapacity += 8; @@ -3279,11 +3367,11 @@ void Interface_UpdateMagicBar(PlayState* play) { } } } else { - gSaveContext.magicState = 9; + gSaveContext.magicState = MAGIC_STATE_FILL; } break; - case 9: + case MAGIC_STATE_FILL: gSaveContext.magic += 4; if (gSaveContext.gameMode == 0 && gSaveContext.sceneSetupIndex < 4) { @@ -3300,32 +3388,32 @@ void Interface_UpdateMagicBar(PlayState* play) { } break; - case 1: + case MAGIC_STATE_CONSUME_SETUP: sMagicBorderRatio = 2; - gSaveContext.magicState = 2; + gSaveContext.magicState = MAGIC_STATE_CONSUME; break; - case 2: + case MAGIC_STATE_CONSUME: gSaveContext.magic -= 2; if (gSaveContext.magic <= 0) { gSaveContext.magic = 0; - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { sMagicBorder = sMagicBorder_ori; } } else if (gSaveContext.magic == gSaveContext.magicTarget) { - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { sMagicBorder = sMagicBorder_ori; } } - case 3: - case 4: - case 6: + case MAGIC_STATE_METER_FLASH_1: + case MAGIC_STATE_METER_FLASH_2: + case MAGIC_STATE_METER_FLASH_3: temp = sMagicBorderIndexes[sMagicBorderStep]; borderChangeR = ABS(sMagicBorder.r - sMagicBorderColors[temp][0]) / sMagicBorderRatio; borderChangeG = ABS(sMagicBorder.g - sMagicBorderColors[temp][1]) / sMagicBorderRatio; @@ -3362,16 +3450,16 @@ void Interface_UpdateMagicBar(PlayState* play) { } break; - case 5: + case MAGIC_STATE_RESET: if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { sMagicBorder = sMagicBorder_ori; } - gSaveContext.magicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; break; - case 7: + case MAGIC_STATE_CONSUME_LENS: if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->sceneLoadFlag == 0) && (play->transitionMode == 0) && !Play_InCsMode(play)) { @@ -3388,7 +3476,7 @@ void Interface_UpdateMagicBar(PlayState* play) { play->actorCtx.lensActive = false; Audio_PlaySoundGeneral(NA_SE_SY_GLASSMODE_OFF, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - gSaveContext.magicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { @@ -3440,7 +3528,7 @@ void Interface_UpdateMagicBar(PlayState* play) { } break; - case 10: + case MAGIC_STATE_ADD: gSaveContext.magic += 4; Audio_PlaySoundGeneral(NA_SE_SY_GAUGE_UP - SFX_FLAG, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (gSaveContext.magic >= gSaveContext.magicTarget) { @@ -3451,7 +3539,7 @@ void Interface_UpdateMagicBar(PlayState* play) { break; default: - gSaveContext.magicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; break; } } @@ -3584,7 +3672,7 @@ void Interface_DrawMagicBar(PlayState* play) { ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); - if (gSaveContext.magicState == 4) { + if (gSaveContext.magicState == MAGIC_STATE_METER_FLASH_2) { // Yellow part of the bar indicating the amount of magic to be subtracted gDPSetPrimColor(OVERLAY_DISP++, 0, 0, magicbar_yellow.r, magicbar_yellow.g, magicbar_yellow.b, interfaceCtx->magicAlpha); @@ -5231,7 +5319,7 @@ void Interface_Draw(PlayState* play) { Interface_DrawLineupTick(play); } - if (fullUi || gSaveContext.magicState > 0) { + if (fullUi || gSaveContext.magicState > MAGIC_STATE_IDLE) { Interface_DrawMagicBar(play); } @@ -5709,6 +5797,7 @@ void Interface_Draw(PlayState* play) { (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) { if (gSaveContext.buttonStatus[0] != BTN_ENABLED) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + Interface_RandoRestoreSwordless(); } else { gSaveContext.equips.buttonItems[0] = ITEM_NONE; } @@ -6414,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; } } @@ -6527,7 +6616,7 @@ void Interface_Update(PlayState* play) { ((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) { if ((gSaveContext.isMagicAcquired != 0) && (gSaveContext.magicLevel == 0)) { gSaveContext.magicLevel = gSaveContext.isDoubleMagicAcquired + 1; - gSaveContext.magicState = 8; + gSaveContext.magicState = MAGIC_STATE_STEP_CAPACITY; osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("魔法スター─────ト!!!!!!!!!\n"); // "Magic Start!!!!!!!!!" osSyncPrintf("MAGIC_MAX=%d\n", gSaveContext.magicLevel); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index fb4628834..112a71888 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -9,6 +9,7 @@ #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/randomizer/randomizer_entrance.h" #include <overlays/actors/ovl_En_Niw/z_en_niw.h> +#include <overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h> #include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" @@ -264,6 +265,19 @@ void GivePlayerRandoRewardRequiem(PlayState* play, RandomizerCheck check) { } } +void GivePlayerRandoRewardMasterSword(PlayState* play, RandomizerCheck check) { + Player* player = GET_PLAYER(play); + + if (gSaveContext.entranceIndex == 0x02CA && LINK_IS_ADULT && player != NULL && + !Player_InBlockingCsMode(play, player) && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && + !Flags_GetRandomizerInf(RAND_INF_TOT_MASTER_SWORD)) { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_MASTER_SWORD); + GiveItemEntryWithoutActor(play, getItemEntry); + player->pendingFlag.flagID = RAND_INF_TOT_MASTER_SWORD; + player->pendingFlag.flagType = FLAG_RANDOMIZER_INF; + } +} + u8 CheckStoneCount() { u8 stoneCount = 0; @@ -545,7 +559,7 @@ void Play_Init(GameState* thisx) { if (gSaveContext.gameMode != 0 || gSaveContext.cutsceneIndex >= 0xFFF0) { gSaveContext.nayrusLoveTimer = 0; - func_800876C8(play); + Magic_Reset(play); gSaveContext.sceneSetupIndex = (gSaveContext.cutsceneIndex & 0xF) + 4; } else if (!LINK_IS_ADULT && IS_DAY) { gSaveContext.sceneSetupIndex = 0; @@ -654,12 +668,12 @@ void Play_Init(GameState* thisx) { Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL); // In order to keep bunny hood equipped on first load, we need to pre-set the age reqs for the item and slot if ((CVarGetInteger("gMMBunnyHood", BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA && CVarGetInteger("gAdultBunnyHood", 0)) || CVarGetInteger("gTimelessEquipment", 0)) { - gItemAgeReqs[ITEM_MASK_BUNNY] = 9; + gItemAgeReqs[ITEM_MASK_BUNNY] = AGE_REQ_NONE; if(INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY) - gSlotAgeReqs[SLOT_TRADE_CHILD] = 9; + gSlotAgeReqs[SLOT_TRADE_CHILD] = AGE_REQ_NONE; } else { - gItemAgeReqs[ITEM_MASK_BUNNY] = gSlotAgeReqs[SLOT_TRADE_CHILD] = 1; + gItemAgeReqs[ITEM_MASK_BUNNY] = gSlotAgeReqs[SLOT_TRADE_CHILD] = AGE_REQ_CHILD; } func_800304DC(play, &play->actorCtx, play->linkActorEntry); @@ -1432,6 +1446,7 @@ skip: GivePlayerRandoRewardZeldaLightArrowsGift(play, RC_TOT_LIGHT_ARROWS_CUTSCENE); GivePlayerRandoRewardNocturne(play, RC_SHEIK_IN_KAKARIKO); GivePlayerRandoRewardRequiem(play, RC_SHEIK_AT_COLOSSUS); + GivePlayerRandoRewardMasterSword(play, RC_TOT_MASTER_SWORD); } } @@ -2314,17 +2329,8 @@ void Play_PerformSave(PlayState* play) { if (play != NULL && gSaveContext.fileNum != 0xFF) { Play_SaveSceneFlags(play); gSaveContext.savedSceneNum = play->sceneNum; - if (gSaveContext.temporaryWeapon) { - gSaveContext.equips.buttonItems[0] = ITEM_NONE; - GET_PLAYER(play)->currentSwordItemId = ITEM_NONE; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE); - Save_SaveFile(); - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI; - GET_PLAYER(play)->currentSwordItemId = ITEM_SWORD_KOKIRI; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI); - } else { - Save_SaveFile(); - } + Save_SaveFile(); + uint8_t triforceHuntCompleted = IS_RANDO && gSaveContext.triforcePiecesCollected == Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED) && diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 32a3e6e48..820f2c672 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -34,9 +34,82 @@ s16 sBootData[PLAYER_BOOTS_MAX][17] = { // Used to map action params to model groups u8 sActionModelGroups[] = { - 3, 15, 10, 2, 2, 5, 10, 11, 6, 6, 6, 6, 6, 6, 6, 6, 9, 9, 7, 7, 8, 3, 3, 6, 3, 3, 3, 3, 12, 13, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_NONE + PLAYER_MODELGROUP_15, // PLAYER_IA_LAST_USED + PLAYER_MODELGROUP_10, // PLAYER_IA_FISHING_POLE + PLAYER_MODELGROUP_SWORD, // PLAYER_IA_SWORD_MASTER + PLAYER_MODELGROUP_SWORD, // PLAYER_IA_SWORD_KOKIRI + PLAYER_MODELGROUP_BGS, // PLAYER_IA_SWORD_BIGGORON + PLAYER_MODELGROUP_10, // PLAYER_IA_DEKU_STICK + PLAYER_MODELGROUP_HAMMER, // PLAYER_IA_HAMMER + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_BOW + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_BOW_FIRE + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_BOW_ICE + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_BOW_LIGHT + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_BOW_0C + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_BOW_0D + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_BOW_0E + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_SLINGSHOT + PLAYER_MODELGROUP_HOOKSHOT, // PLAYER_IA_HOOKSHOT + PLAYER_MODELGROUP_HOOKSHOT, // PLAYER_IA_LONGSHOT + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_IA_BOMB + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_IA_BOMBCHU + PLAYER_MODELGROUP_BOOMERANG, // PLAYER_IA_BOOMERANG + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MAGIC_SPELL_15 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MAGIC_SPELL_16 + PLAYER_MODELGROUP_BOW_SLINGSHOT, // PLAYER_IA_MAGIC_SPELL_17 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_FARORES_WIND + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_NAYRUS_LOVE + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_DINS_FIRE + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_DEKU_NUT + PLAYER_MODELGROUP_OCARINA, // PLAYER_IA_OCARINA_FAIRY + PLAYER_MODELGROUP_OOT, // PLAYER_IA_OCARINA_OF_TIME + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_FISH + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_FIRE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_BUG + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_BIG_POE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_RUTOS_LETTER + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POTION_RED + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POTION_BLUE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POTION_GREEN + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_MILK_FULL + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_MILK_HALF + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_FAIRY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_ZELDAS_LETTER + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_WEIRD_EGG + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_CHICKEN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MAGIC_BEAN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_POCKET_EGG + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_POCKET_CUCCO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_COJIRO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_ODD_MUSHROOM + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_ODD_POTION + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_POACHERS_SAW + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_BROKEN_GORONS_SWORD + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_PRESCRIPTION + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_FROG + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_EYEDROPS + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_CLAIM_CHECK + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_KEATON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_SKULL + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_SPOOKY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_BUNNY_HOOD + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GORON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_ZORA + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GERUDO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_TRUTH + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_LENS_OF_TRUTH + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_SHIELD_DEKU + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_SHIELD_HYLIAN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_SHIELD_MIRROR + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_TUNIC_KOKIRI + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_TUNIC_GORON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_TUNIC_ZORA + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_BOOTS_KOKIRI + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_BOOTS_IRON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_BOOTS_HOVER }; TextTriggerEntry sTextTriggers[] = { @@ -47,68 +120,208 @@ TextTriggerEntry sTextTriggers[] = { }; // Used to map model groups to model types for [animation, left hand, right hand, sheath, waist] -u8 gPlayerModelTypes[][5] = { - { 2, 0, 10, 16, 20 }, { 1, 2, 9, 19, 20 }, { 1, 2, 10, 17, 20 }, { 0, 0, 8, 18, 20 }, - { 0, 0, 8, 18, 20 }, { 3, 4, 9, 19, 20 }, { 4, 1, 11, 18, 20 }, { 5, 0, 8, 18, 20 }, - { 0, 6, 8, 18, 20 }, { 4, 0, 15, 18, 20 }, { 3, 1, 9, 18, 20 }, { 3, 5, 9, 18, 20 }, - { 0, 0, 13, 18, 20 }, { 0, 0, 14, 18, 20 }, { 0, 7, 8, 18, 20 }, { 0, 2, 8, 19, 20 }, +u8 gPlayerModelTypes[PLAYER_MODELGROUP_MAX][PLAYER_MODELGROUPENTRY_MAX] = { + /* PLAYER_MODELGROUP_0 */ + { + PLAYER_ANIMTYPE_2, + PLAYER_MODELTYPE_LH_OPEN, + PLAYER_MODELTYPE_RH_SHIELD, + PLAYER_MODELTYPE_SHEATH_16, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD */ + { + PLAYER_ANIMTYPE_1, + PLAYER_MODELTYPE_LH_SWORD, + PLAYER_MODELTYPE_RH_CLOSED, + PLAYER_MODELTYPE_SHEATH_19, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_SWORD */ + { + PLAYER_ANIMTYPE_1, + PLAYER_MODELTYPE_LH_SWORD, + PLAYER_MODELTYPE_RH_SHIELD, + PLAYER_MODELTYPE_SHEATH_17, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_DEFAULT */ + { + PLAYER_ANIMTYPE_0, + PLAYER_MODELTYPE_LH_OPEN, + PLAYER_MODELTYPE_RH_OPEN, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_4 */ + { + PLAYER_ANIMTYPE_0, + PLAYER_MODELTYPE_LH_OPEN, + PLAYER_MODELTYPE_RH_OPEN, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_BGS */ + { + PLAYER_ANIMTYPE_3, + PLAYER_MODELTYPE_LH_BGS, + PLAYER_MODELTYPE_RH_CLOSED, + PLAYER_MODELTYPE_SHEATH_19, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_BOW_SLINGSHOT */ + { + PLAYER_ANIMTYPE_4, + PLAYER_MODELTYPE_LH_CLOSED, + PLAYER_MODELTYPE_RH_BOW_SLINGSHOT, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_EXPLOSIVES */ + { + PLAYER_ANIMTYPE_5, + PLAYER_MODELTYPE_LH_OPEN, + PLAYER_MODELTYPE_RH_OPEN, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_BOOMERANG */ + { + PLAYER_ANIMTYPE_0, + PLAYER_MODELTYPE_LH_BOOMERANG, + PLAYER_MODELTYPE_RH_OPEN, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_HOOKSHOT */ + { + PLAYER_ANIMTYPE_4, + PLAYER_MODELTYPE_LH_OPEN, + PLAYER_MODELTYPE_RH_HOOKSHOT, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_10 */ + { + PLAYER_ANIMTYPE_3, + PLAYER_MODELTYPE_LH_CLOSED, + PLAYER_MODELTYPE_RH_CLOSED, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_HAMMER */ + { + PLAYER_ANIMTYPE_3, + PLAYER_MODELTYPE_LH_HAMMER, + PLAYER_MODELTYPE_RH_CLOSED, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_OCARINA */ + { + PLAYER_ANIMTYPE_0, + PLAYER_MODELTYPE_LH_OPEN, + PLAYER_MODELTYPE_RH_OCARINA, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_OOT */ + { + PLAYER_ANIMTYPE_0, + PLAYER_MODELTYPE_LH_OPEN, + PLAYER_MODELTYPE_RH_OOT, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_BOTTLE */ + { + PLAYER_ANIMTYPE_0, + PLAYER_MODELTYPE_LH_BOTTLE, + PLAYER_MODELTYPE_RH_OPEN, + PLAYER_MODELTYPE_SHEATH_18, + PLAYER_MODELTYPE_WAIST + }, + /* PLAYER_MODELGROUP_15 */ + { + PLAYER_ANIMTYPE_0, + PLAYER_MODELTYPE_LH_SWORD, + PLAYER_MODELTYPE_RH_OPEN, + PLAYER_MODELTYPE_SHEATH_19, + PLAYER_MODELTYPE_WAIST + }, }; -Gfx* sPlayerRightHandShieldDLs[] = { +Gfx* sPlayerRightHandShieldDLs[PLAYER_SHIELD_MAX * 4] = { + // PLAYER_SHIELD_NONE gLinkAdultRightHandClosedNearDL, gLinkChildRightHandClosedNearDL, gLinkAdultRightHandClosedFarDL, gLinkChildRightHandClosedFarDL, + // PLAYER_SHIELD_DEKU gLinkAdultRightHandClosedNearDL, gLinkChildRightFistAndDekuShieldNearDL, gLinkAdultRightHandClosedFarDL, gLinkChildRightFistAndDekuShieldFarDL, + // PLAYER_SHIELD_HYLIAN gLinkAdultRightHandHoldingHylianShieldNearDL, gLinkChildRightHandClosedNearDL, gLinkAdultRightHandHoldingHylianShieldFarDL, gLinkChildRightHandClosedFarDL, + // PLAYER_SHIELD_MIRROR gLinkAdultRightHandHoldingMirrorShieldNearDL, gLinkChildRightHandClosedNearDL, gLinkAdultRightHandHoldingMirrorShieldFarDL, gLinkChildRightHandClosedFarDL, }; -Gfx* sSheathWithSwordDLs[] = { +Gfx* sSheathWithSwordDLs[(PLAYER_SHIELD_MAX + 2) * 4] = { + // PLAYER_SHIELD_NONE gLinkAdultMasterSwordAndSheathNearDL, gLinkChildSwordAndSheathNearDL, gLinkAdultMasterSwordAndSheathFarDL, gLinkChildSwordAndSheathFarDL, + // PLAYER_SHIELD_DEKU gLinkAdultMasterSwordAndSheathNearDL, gLinkChildDekuShieldSwordAndSheathNearDL, gLinkAdultMasterSwordAndSheathFarDL, gLinkChildDekuShieldSwordAndSheathFarDL, + // PLAYER_SHIELD_HYLIAN gLinkAdultHylianShieldSwordAndSheathNearDL, gLinkChildHylianShieldSwordAndSheathNearDL, gLinkAdultHylianShieldSwordAndSheathFarDL, gLinkChildHylianShieldSwordAndSheathFarDL, + // PLAYER_SHIELD_MIRROR gLinkAdultMirrorShieldSwordAndSheathNearDL, gLinkChildSwordAndSheathNearDL, gLinkAdultMirrorShieldSwordAndSheathFarDL, gLinkChildSwordAndSheathFarDL, + // PLAYER_SHIELD_NONE (child, no sword) NULL, NULL, NULL, NULL, + // PLAYER_SHIELD_DEKU (child, no sword) NULL, gLinkChildDekuShieldWithMatrixDL, NULL, gLinkChildDekuShieldWithMatrixDL, }; -Gfx* sSheathWithoutSwordDLs[] = { +Gfx* sSheathWithoutSwordDLs[(PLAYER_SHIELD_MAX + 2) * 4] = { + // PLAYER_SHIELD_NONE gLinkAdultSheathNearDL, gLinkChildSheathNearDL, gLinkAdultSheathFarDL, gLinkChildSheathFarDL, + // PLAYER_SHIELD_DEKU gLinkAdultSheathNearDL, gLinkChildDekuShieldAndSheathNearDL, gLinkAdultSheathFarDL, gLinkChildDekuShieldAndSheathFarDL, + // PLAYER_SHIELD_HYLIAN gLinkAdultHylianShieldAndSheathNearDL, gLinkChildHylianShieldAndSheathNearDL, gLinkAdultHylianShieldAndSheathFarDL, gLinkChildHylianShieldAndSheathFarDL, + // PLAYER_SHIELD_MIRROR gLinkAdultMirrorShieldAndSheathNearDL, gLinkChildSheathNearDL, gLinkAdultMirrorShieldAndSheathFarDL, gLinkChildSheathFarDL, + // PLAYER_SHIELD_NONE (child, no sword) NULL, NULL, NULL, NULL, + // PLAYER_SHIELD_DEKU (child, no sword) gLinkAdultSheathNearDL, gLinkChildDekuShieldWithMatrixDL, gLinkAdultSheathNearDL, @@ -116,8 +329,10 @@ Gfx* sSheathWithoutSwordDLs[] = { }; Gfx* gPlayerLeftHandBgsDLs[] = { + // Biggoron Sword gLinkAdultLeftHandHoldingBgsNearDL, gLinkChildLeftHandHoldingMasterSwordDL, gLinkAdultLeftHandHoldingBgsFarDL, gLinkChildLeftHandHoldingMasterSwordDL, + // Broken Giant's Knife gLinkAdultHandHoldingBrokenGiantsKnifeDL, gLinkChildLeftHandHoldingMasterSwordDL, gLinkAdultHandHoldingBrokenGiantsKnifeFarDL, gLinkChildLeftHandHoldingMasterSwordDL, }; @@ -267,10 +482,28 @@ Gfx* sFirstPersonRightHandHoldingWeaponDLs[] = { }; // Indexed by model types (left hand, right hand, sheath or waist) -Gfx** sPlayerDListGroups[] = { - gPlayerLeftHandOpenDLs, gPlayerLeftHandClosedDLs, sPlayerLeftHandSwordDLs, sPlayerLeftHandSwordDLs2, gPlayerLeftHandBgsDLs, sPlayerLeftHandHammerDLs, gPlayerLeftHandBoomerangDLs, - sPlayerLeftHandBottleDLs, sPlayerRightHandOpenDLs, sPlayerRightHandClosedDLs, sPlayerRightHandShieldDLs, sPlayerRightHandBowSlingshotDLs, sPlayerRightHandBowSlingshotDLs2, sPlayerRightHandOcarinaDLs, - sPlayerRightHandOotDLs, sPlayerRightHandHookshotDLs, sSwordAndSheathDLs, sSheathDLs, sSheathWithSwordDLs, sSheathWithoutSwordDLs, sPlayerWaistDLs, +Gfx** sPlayerDListGroups[PLAYER_MODELTYPE_MAX] = { + gPlayerLeftHandOpenDLs, // PLAYER_MODELTYPE_LH_OPEN + gPlayerLeftHandClosedDLs, // PLAYER_MODELTYPE_LH_CLOSED + sPlayerLeftHandSwordDLs, // PLAYER_MODELTYPE_LH_SWORD + sPlayerLeftHandSwordDLs2, // PLAYER_MODELTYPE_LH_SWORD_2 + gPlayerLeftHandBgsDLs, // PLAYER_MODELTYPE_LH_BGS + sPlayerLeftHandHammerDLs, // PLAYER_MODELTYPE_LH_HAMMER + gPlayerLeftHandBoomerangDLs, // PLAYER_MODELTYPE_LH_BOOMERANG + sPlayerLeftHandBottleDLs, // PLAYER_MODELTYPE_LH_BOTTLE + sPlayerRightHandOpenDLs, // PLAYER_MODELTYPE_RH_OPEN + sPlayerRightHandClosedDLs, // PLAYER_MODELTYPE_RH_CLOSED + sPlayerRightHandShieldDLs, // PLAYER_MODELTYPE_RH_SHIELD + sPlayerRightHandBowSlingshotDLs, // PLAYER_MODELTYPE_RH_BOW_SLINGSHOT + sPlayerRightHandBowSlingshotDLs2, // PLAYER_MODELTYPE_RH_BOW_SLINGSHOT_2 + sPlayerRightHandOcarinaDLs, // PLAYER_MODELTYPE_RH_OCARINA + sPlayerRightHandOotDLs, // PLAYER_MODELTYPE_RH_OOT + sPlayerRightHandHookshotDLs, // PLAYER_MODELTYPE_RH_HOOKSHOT + sSwordAndSheathDLs, // PLAYER_MODELTYPE_SHEATH_16 + sSheathDLs, // PLAYER_MODELTYPE_SHEATH_17 + sSheathWithSwordDLs, // PLAYER_MODELTYPE_SHEATH_18 + sSheathWithoutSwordDLs, // PLAYER_MODELTYPE_SHEATH_19 + sPlayerWaistDLs, // PLAYER_MODELTYPE_WAIST }; Gfx gCullBackDList[] = { @@ -342,7 +575,7 @@ uint8_t Player_IsCustomLinkModel() { s32 Player_InBlockingCsMode(PlayState* play, Player* this) { return (this->stateFlags1 & 0x20000080) || (this->csMode != 0) || (play->sceneLoadFlag == 0x14) || (this->stateFlags1 & 1) || (this->stateFlags3 & 0x80) || - ((gSaveContext.magicState != 0) && (Player_ActionToMagicSpell(this, this->itemAction) >= 0)); + ((gSaveContext.magicState != MAGIC_STATE_IDLE) && (Player_ActionToMagicSpell(this, this->itemAction) >= 0)); } s32 Player_InCsMode(PlayState* play) { @@ -362,8 +595,9 @@ s32 Player_IsChildWithHylianShield(Player* this) { s32 Player_ActionToModelGroup(Player* this, s32 actionParam) { s32 modelGroup = sActionModelGroups[actionParam]; - if ((modelGroup == 2) && Player_IsChildWithHylianShield(this)) { - return 1; + if ((modelGroup == PLAYER_MODELGROUP_SWORD) && Player_IsChildWithHylianShield(this)) { + // child, using kokiri sword with hylian shield equipped + return PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD; } else { return modelGroup; } @@ -374,15 +608,15 @@ void Player_SetModelsForHoldingShield(Player* this) { ((this->itemAction < 0) || (this->itemAction == this->heldItemAction))) { if ((CVarGetInteger("gShieldTwoHanded", 0) && (this->heldItemAction != PLAYER_IA_DEKU_STICK) || !Player_HoldsTwoHandedWeapon(this)) && !Player_IsChildWithHylianShield(this)) { - this->rightHandType = 10; - this->rightHandDLists = &sPlayerDListGroups[10][gSaveContext.linkAge]; - if (this->sheathType == 18) { - this->sheathType = 16; - } else if (this->sheathType == 19) { - this->sheathType = 17; + this->rightHandType = PLAYER_MODELTYPE_RH_SHIELD; + this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][gSaveContext.linkAge]; + if (this->sheathType == PLAYER_MODELTYPE_SHEATH_18) { + this->sheathType = PLAYER_MODELTYPE_SHEATH_16; + } else if (this->sheathType == PLAYER_MODELTYPE_SHEATH_19) { + this->sheathType = PLAYER_MODELTYPE_SHEATH_17; } this->sheathDLists = &sPlayerDListGroups[this->sheathType][gSaveContext.linkAge]; - this->modelAnimType = 2; + this->modelAnimType = PLAYER_ANIMTYPE_2; this->itemAction = -1; } } @@ -390,11 +624,11 @@ void Player_SetModelsForHoldingShield(Player* this) { void Player_SetModels(Player* this, s32 modelGroup) { // Left hand - this->leftHandType = gPlayerModelTypes[modelGroup][1]; + this->leftHandType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_LEFT_HAND]; this->leftHandDLists = &sPlayerDListGroups[this->leftHandType][gSaveContext.linkAge]; // Right hand - this->rightHandType = gPlayerModelTypes[modelGroup][2]; + this->rightHandType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_RIGHT_HAND]; this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][gSaveContext.linkAge]; if (CVarGetInteger("gBowSlingShotAmmoFix", 0) && this->rightHandType == 11) { // If holding Bow/Slingshot @@ -402,7 +636,7 @@ void Player_SetModels(Player* this, s32 modelGroup) { } // Sheath - this->sheathType = gPlayerModelTypes[modelGroup][3]; + this->sheathType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_SHEATH]; this->sheathDLists = &sPlayerDListGroups[this->sheathType][gSaveContext.linkAge]; // Waist @@ -414,14 +648,14 @@ void Player_SetModels(Player* this, s32 modelGroup) { void Player_SetModelGroup(Player* this, s32 modelGroup) { this->modelGroup = modelGroup; - if (modelGroup == 1) { - this->modelAnimType = 0; + if (modelGroup == PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD) { + this->modelAnimType = PLAYER_ANIMTYPE_0; } else { - this->modelAnimType = gPlayerModelTypes[modelGroup][0]; + this->modelAnimType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_ANIM]; } - if ((this->modelAnimType < 3) && (this->currentShield == PLAYER_SHIELD_NONE)) { - this->modelAnimType = 0; + if ((this->modelAnimType < PLAYER_ANIMTYPE_3) && (this->currentShield == PLAYER_SHIELD_NONE)) { + this->modelAnimType = PLAYER_ANIMTYPE_0; } Player_SetModels(this, modelGroup); @@ -435,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); @@ -541,7 +775,7 @@ s32 Player_HasMirrorShieldEquipped(PlayState* play) { s32 Player_HasMirrorShieldSetToDraw(PlayState* play) { Player* this = GET_PLAYER(play); - return (this->rightHandType == 10) && (this->currentShield == PLAYER_SHIELD_MIRROR); + return (this->rightHandType == PLAYER_MODELTYPE_RH_SHIELD) && (this->currentShield == PLAYER_SHIELD_MIRROR); } s32 Player_ActionToMagicSpell(Player* this, s32 actionParam) { @@ -744,8 +978,8 @@ Color_RGB8 sGauntletColors[] = { }; Gfx* sBootDListGroups[][2] = { - { gLinkAdultLeftIronBootDL, gLinkAdultRightIronBootDL }, - { gLinkAdultLeftHoverBootDL, gLinkAdultRightHoverBootDL }, + { gLinkAdultLeftIronBootDL, gLinkAdultRightIronBootDL }, // PLAYER_BOOTS_IRON + { gLinkAdultLeftHoverBootDL, gLinkAdultRightHoverBootDL }, // PLAYER_BOOTS_HOVER }; void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, @@ -828,9 +1062,9 @@ void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dL gSPDisplayList(POLY_OPA_DISP++, gLinkAdultLeftGauntletPlate1DL); gSPDisplayList(POLY_OPA_DISP++, gLinkAdultRightGauntletPlate1DL); gSPDisplayList(POLY_OPA_DISP++, - (sLeftHandType == 0) ? gLinkAdultLeftGauntletPlate2DL : gLinkAdultLeftGauntletPlate3DL); + (sLeftHandType == PLAYER_MODELTYPE_LH_OPEN) ? gLinkAdultLeftGauntletPlate2DL : gLinkAdultLeftGauntletPlate3DL); gSPDisplayList(POLY_OPA_DISP++, - (sRightHandType == 8) ? gLinkAdultRightGauntletPlate2DL : gLinkAdultRightGauntletPlate3DL); + (sRightHandType == PLAYER_MODELTYPE_RH_OPEN) ? gLinkAdultRightGauntletPlate2DL : gLinkAdultRightGauntletPlate3DL); } if (boots != 0) { @@ -1045,40 +1279,40 @@ s32 Player_OverrideLimbDrawGameplayDefault(PlayState* play, s32 limbIndex, Gfx** if (limbIndex == PLAYER_LIMB_L_HAND) { Gfx** dLists = this->leftHandDLists; - if ((sLeftHandType == 4) && (gSaveContext.swordHealth <= 0.0f)) { + if ((sLeftHandType == PLAYER_MODELTYPE_LH_BGS) && (gSaveContext.swordHealth <= 0.0f)) { dLists += 4; - } else if ((sLeftHandType == 6) && (this->stateFlags1 & 0x2000000)) { + } else if ((sLeftHandType == PLAYER_MODELTYPE_LH_BOOMERANG) && (this->stateFlags1 & 0x2000000)) { dLists = &gPlayerLeftHandOpenDLs[gSaveContext.linkAge]; sLeftHandType = 0; - } else if ((this->leftHandType == 0) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { + } else if ((this->leftHandType == PLAYER_MODELTYPE_LH_OPEN) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { dLists = &gPlayerLeftHandClosedDLs[gSaveContext.linkAge]; - sLeftHandType = 1; + sLeftHandType = PLAYER_MODELTYPE_LH_CLOSED; } *dList = ResourceMgr_LoadGfxByName(dLists[sDListsLodOffset]); } else if (limbIndex == PLAYER_LIMB_R_HAND) { Gfx** dLists = this->rightHandDLists; - if (sRightHandType == 10) { + if (sRightHandType == PLAYER_MODELTYPE_RH_SHIELD) { dLists += this->currentShield * 4; - } else if ((this->rightHandType == 8) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { + } else if ((this->rightHandType == PLAYER_MODELTYPE_RH_OPEN) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { dLists = &sPlayerRightHandClosedDLs[gSaveContext.linkAge]; - sRightHandType = 9; + sRightHandType = PLAYER_MODELTYPE_RH_CLOSED; } *dList = ResourceMgr_LoadGfxByName(dLists[sDListsLodOffset]); } else if (limbIndex == PLAYER_LIMB_SHEATH) { Gfx** dLists = this->sheathDLists; - if ((this->sheathType == 18) || (this->sheathType == 19)) { + if ((this->sheathType == PLAYER_MODELTYPE_SHEATH_18) || (this->sheathType == PLAYER_MODELTYPE_SHEATH_19)) { dLists += this->currentShield * 4; if (!LINK_IS_ADULT && (this->currentShield < PLAYER_SHIELD_HYLIAN) && (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI)) { - dLists += 16; + dLists += PLAYER_SHIELD_MAX * 4; } - } else if (!LINK_IS_ADULT && ((this->sheathType == 16) || (this->sheathType == 17)) && + } else if (!LINK_IS_ADULT && ((this->sheathType == PLAYER_MODELTYPE_SHEATH_16) || (this->sheathType == PLAYER_MODELTYPE_SHEATH_17)) && (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI)) { - dLists = &sSheathWithSwordDLs[16]; + dLists = &sSheathWithSwordDLs[PLAYER_SHIELD_MAX * 4]; } if (dLists[sDListsLodOffset] != NULL) { @@ -1481,7 +1715,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve func_80090A28(this, spE4); func_800906D4(play, this, spE4); - } else if ((*dList != NULL) && (this->leftHandType == 7)) { + } else if ((*dList != NULL) && (this->leftHandType == PLAYER_MODELTYPE_LH_BOTTLE)) { Color_RGB8* bottleColor = &sBottleColors[Player_ActionToBottle(this, this->itemAction)]; OPEN_DISPS(play->state.gfxCtx); @@ -1522,9 +1756,9 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve } else if (limbIndex == PLAYER_LIMB_R_HAND) { Actor* heldActor = this->heldActor; - if (this->rightHandType == 0xFF) { + if (this->rightHandType == PLAYER_MODELTYPE_RH_FF) { Matrix_Get(&this->shieldMf); - } else if ((this->rightHandType == 11) || (this->rightHandType == 12)) { + } else if ((this->rightHandType == PLAYER_MODELTYPE_RH_BOW_SLINGSHOT) || (this->rightHandType == PLAYER_MODELTYPE_RH_BOW_SLINGSHOT_2)) { s32 stringModelToUse = gSaveContext.linkAge; if(CVarGetInteger("gBowSlingShotAmmoFix", 0)){ stringModelToUse = Player_HoldsSlingshot(this); @@ -1569,7 +1803,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve Matrix_Pop(); CLOSE_DISPS(play->state.gfxCtx); - } else if ((this->actor.scale.y >= 0.0f) && (this->rightHandType == 10)) { + } else if ((this->actor.scale.y >= 0.0f) && (this->rightHandType == PLAYER_MODELTYPE_RH_SHIELD)) { Matrix_Get(&this->shieldMf); Player_UpdateShieldCollider(play, this, &this->shieldQuad, sRightHandLimbModelShieldQuadVertices); } @@ -1631,7 +1865,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve } } else if (this->actor.scale.y >= 0.0f) { if (limbIndex == PLAYER_LIMB_SHEATH) { - if ((this->rightHandType != 10) && (this->rightHandType != 0xFF)) { + if ((this->rightHandType != PLAYER_MODELTYPE_RH_SHIELD) && (this->rightHandType != PLAYER_MODELTYPE_RH_FF)) { if (Player_IsChildWithHylianShield(this)) { Player_UpdateShieldCollider(play, this, &this->shieldQuad, sSheathLimbModelShieldQuadVertices); } @@ -1673,46 +1907,55 @@ u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { return size + 0x8800 + 0x90; } -u8 sPauseModelGroupBySword[] = { 2, 2, 5 }; +u8 sPauseModelGroupBySword[] = { + PLAYER_MODELGROUP_SWORD, // PLAYER_SWORD_KOKIRI + PLAYER_MODELGROUP_SWORD, // PLAYER_SWORD_MASTER + PLAYER_MODELGROUP_BGS, // PLAYER_SWORD_BIGGORON +}; s32 Player_OverrideLimbDrawPause(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* arg) { - u8* ptr = arg; - u8 modelGroup = sPauseModelGroupBySword[ptr[0] > 0 ? ptr[0] - 1 : 0]; + u8* playerSwordAndShield = arg; + // SOH: Ensure positive value from playerSwordAndShield[] to avoid OOB array access. + // This can occur in the case where playerSwordAndShield[0] is PLAYER_SWORD_NONE + u8 modelGroup = sPauseModelGroupBySword[playerSwordAndShield[0] > 0 ? playerSwordAndShield[0] - PLAYER_SWORD_KOKIRI : 0]; s32 type; s32 dListOffset = 0; Gfx** dLists; size_t ptrSize = sizeof(uint32_t); - if ((modelGroup == 2) && !LINK_IS_ADULT && (ptr[1] == 2)) { - modelGroup = 1; + if ((modelGroup == PLAYER_MODELGROUP_SWORD) && !LINK_IS_ADULT && (playerSwordAndShield[1] == PLAYER_SHIELD_HYLIAN)) { + modelGroup = PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD; } if (limbIndex == PLAYER_LIMB_L_HAND) { - type = gPlayerModelTypes[modelGroup][1]; + type = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_LEFT_HAND]; sLeftHandType = type; - if (ptr[0] == 0) - type = 0; + // SOH: Handle unexpected swordless case. Previously OOB array access is avoided, but we want the + // hand model-type to be set to open (otherwise it is set to holding sword model-type) + if (playerSwordAndShield[0] == PLAYER_SWORD_NONE) { + type = PLAYER_MODELTYPE_LH_OPEN; + } - if ((type == 4) && (gSaveContext.swordHealth <= 0.0f)) { + if ((type == PLAYER_MODELTYPE_LH_BGS) && (gSaveContext.swordHealth <= 0.0f)) { dListOffset = 4; } } else if (limbIndex == PLAYER_LIMB_R_HAND) { - type = gPlayerModelTypes[modelGroup][2]; + type = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_RIGHT_HAND]; sRightHandType = type; - if (type == 10) { - dListOffset = ptr[1] * ptrSize; + if (type == PLAYER_MODELTYPE_RH_SHIELD) { + dListOffset = playerSwordAndShield[1] * ptrSize; } } else if (limbIndex == PLAYER_LIMB_SHEATH) { - type = gPlayerModelTypes[modelGroup][3]; - if ((type == 18) || (type == 19)) { - dListOffset = ptr[1] * ptrSize; - } else if (type == 16 && CVarGetInteger("gPauseLiveLink", 0)) { - //if (ptr[0] == 1) + type = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_SHEATH]; + if ((type == PLAYER_MODELTYPE_SHEATH_18) || (type == PLAYER_MODELTYPE_SHEATH_19)) { + dListOffset = playerSwordAndShield[1] * ptrSize; + } else if (type == PLAYER_MODELTYPE_SHEATH_16 && CVarGetInteger("gPauseLiveLink", 0)) { + //if (playerSwordAndShield[0] == 1) //dListOffset = 4; } } else if (limbIndex == PLAYER_LIMB_WAIST) { - type = gPlayerModelTypes[modelGroup][4]; + type = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_WAIST]; if (Player_IsCustomLinkModel()) { return 0; @@ -1750,7 +1993,7 @@ void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* static Vp viewport = { 128, 224, 511, 0, 128, 224, 511, 0 }; static Lights1 lights1 = gdSPDefLights1(80, 80, 80, 255, 255, 255, 84, 84, 172); static Vec3f lightDir = { 89.8f, 0.0f, 89.8f }; - u8 sp12C[2]; + u8 playerSwordAndShield[2]; Gfx* opaRef; Gfx* xluRef; Gfx* kalRef; @@ -1788,8 +2031,8 @@ void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* gSPMatrix(POLY_OPA_DISP++, lookAtMtx, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - sp12C[0] = sword; - sp12C[1] = shield; + playerSwordAndShield[0] = sword; + playerSwordAndShield[1] = shield; Matrix_SetTranslateRotateYXZ(pos->x - ((CVarGetInteger("gPauseLiveLink", 0) && LINK_AGE_IN_YEARS == YEARS_ADULT) ? 25 : 0), pos->y - (CVarGetInteger("gPauseTriforce", 0) ? 16 : 0), pos->z, rot); @@ -1809,7 +2052,7 @@ void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* gSPSegment(POLY_OPA_DISP++, 0x0C, gCullBackDList); Player_DrawImpl(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, tunic, boots, 0, - Player_OverrideLimbDrawPause, NULL, &sp12C); + Player_OverrideLimbDrawPause, NULL, &playerSwordAndShield); if (CVarGetInteger("gPauseTriforce", 0)) { @@ -1874,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 @@ -1949,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 @@ -1960,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 @@ -1983,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 @@ -2054,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 1612c0fdc..057460b62 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -168,12 +168,13 @@ 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)) { - gSaveContext.inventory.equipment |= gBitFlags[1] << gEquipShifts[EQUIP_SWORD]; - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - gSaveContext.equips.equipment &= ~0xF; - gSaveContext.equips.equipment |= 2; + 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 |= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER); + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + gSaveContext.equips.equipment &= ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_MASTER << (EQUIP_TYPE_SWORD * 4); + } } if (!(IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE))) { diff --git a/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index ec85332b0..93ff272f4 100644 --- a/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -308,7 +308,7 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) { f32 sp5C; f32 sp58; - if ((player->actor.draw != NULL) && (player->rightHandType == 15)) { + if ((player->actor.draw != NULL) && (player->rightHandType == PLAYER_MODELTYPE_RH_HOOKSHOT)) { OPEN_DISPS(play->state.gfxCtx); if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { diff --git a/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 850f793da..d257a7fd9 100644 --- a/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -55,7 +55,7 @@ void ArrowFire_Init(Actor* thisx, PlayState* play) { } void ArrowFire_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); LOG_STRING("消滅"); // "Disappearance" } diff --git a/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 2d63f9890..94d7ecabc 100644 --- a/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -56,7 +56,7 @@ void ArrowIce_Init(Actor* thisx, PlayState* play) { } void ArrowIce_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); LOG_STRING("消滅"); // "Disappearance" } diff --git a/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index 3bea3b09f..9ddfb96a6 100644 --- a/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -56,7 +56,7 @@ void ArrowLight_Init(Actor* thisx, PlayState* play) { } void ArrowLight_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); LOG_STRING("消滅"); // "Disappearance" } diff --git a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 7223e936f..e8b2be4df 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -741,7 +741,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, PlayState* play) { switch (actionIndex) { case FAIRY_UPGRADE_MAGIC: gSaveContext.isMagicAcquired = true; - gSaveContext.magicFillTarget = 0x30; + gSaveContext.magicFillTarget = MAGIC_NORMAL_METER; Interface_ChangeAlpha(9); break; case FAIRY_UPGRADE_DOUBLE_MAGIC: @@ -749,7 +749,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, PlayState* play) { gSaveContext.isMagicAcquired = true; } gSaveContext.isDoubleMagicAcquired = true; - gSaveContext.magicFillTarget = 0x60; + gSaveContext.magicFillTarget = MAGIC_DOUBLE_METER; gSaveContext.magicLevel = 0; Interface_ChangeAlpha(9); break; diff --git a/soh/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/soh/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c index 7680adb6f..26a02aa96 100644 --- a/soh/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/soh/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c @@ -91,7 +91,7 @@ void BgTokiSwd_Init(Actor* thisx, PlayState* play) { Player* player = GET_PLAYER(gPlayState); player->currentSwordItemId = ITEM_NONE; gSaveContext.equips.buttonItems[0] = ITEM_NONE; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); } } @@ -122,7 +122,9 @@ void func_808BAF40(BgTokiSwd* this, PlayState* play) { if (!LINK_IS_ADULT || (Flags_GetEventChkInf(EVENTCHKINF_LEARNED_PRELUDE_OF_LIGHT) && !IS_RANDO) || IS_RANDO) { if (Actor_HasParent(&this->actor, play)) { if (!LINK_IS_ADULT) { - Item_Give(play, ITEM_SWORD_MASTER); + if (!IS_RANDO || !Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) { + Item_Give(play, ITEM_SWORD_MASTER); + } play->csCtx.segment = D_808BB2F0; } else { play->csCtx.segment = D_808BB7A0; @@ -184,6 +186,11 @@ void BgTokiSwd_Draw(Actor* thisx, PlayState* play2) { BgTokiSwd* this = (BgTokiSwd*)thisx; s32 pad[3]; + // Do not draw the Master Sword in the pedestal if the player has not found it yet + if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && !CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)) { + return; + } + OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 13cc46e38..cb00dbee8 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -153,6 +153,8 @@ void func_808FD27C(PlayState* play, Vec3f* position, Vec3f* velocity, f32 scale) } } +static u8 hasFoundMasterSword; + void BossGanon2_Init(Actor* thisx, PlayState* play) { BossGanon2* this = (BossGanon2*)thisx; s32 pad; @@ -175,6 +177,11 @@ void BossGanon2_Init(Actor* thisx, PlayState* play) { func_808FD5C4(this, play); this->actor.naviEnemyId = 0x3E; this->actor.gravity = 0.0f; + + hasFoundMasterSword = 1; + if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && !CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)) { + hasFoundMasterSword = 0; + } } void BossGanon2_Destroy(Actor* thisx, PlayState* play) { @@ -2895,6 +2902,11 @@ void func_80905DA8(BossGanon2* this, PlayState* play) { effect->velocity.y += effect->accel.y; effect->velocity.z += effect->accel.z; if (effect->type == 1) { + // Prevent invisible master sword from making spark effect/sound when landing in the ground + // and prevent the player from picking it up if the player has not found the master sword + if (IS_RANDO && !hasFoundMasterSword) { + continue; + } if (effect->unk_2E == 0) { effect->unk_38.z += 1.0f; effect->unk_38.y = (2.0f * M_PI) / 5.0f; @@ -2955,6 +2967,11 @@ void func_809060E8(PlayState* play) { for (i = 0; i < 1; i++) { if (effect->type == 1) { + // Do not draw the master sword in the ground if the player has not found it yet + if (IS_RANDO && !hasFoundMasterSword) { + continue; + } + FrameInterpolation_RecordOpenChild("Ganon 809060E8 0", i); Vec3f spA0; diff --git a/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 85d47753a..0dd33a8ac 100644 --- a/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -273,7 +273,7 @@ u32 func_809EF73C(EnDns* this) { } u32 func_809EF800(EnDns* this) { - if (gBitFlags[4] & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SHIELD, EQUIP_INV_SHIELD_DEKU)) { return 1; } if (gSaveContext.rupees < this->dnsItemEntry->itemPrice) { diff --git a/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 9cbd8b8ca..2d05c116c 100644 --- a/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -278,7 +278,7 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, PlayState* play) { break; } if ((player->actor.yDistToWater != BGCHECK_Y_MIN) && - (floorY < (player->actor.world.pos.y - player->actor.yDistToWater))) { + (floorY < (player->actor.world.pos.y + player->actor.yDistToWater*(CVarGetInteger("gEnemySpawnsOverWaterboxes", 0) ? 1 : -1)))) { break; } spawnPos.y = floorY; diff --git a/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index bb9ee05c2..037b4b594 100644 --- a/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -565,7 +565,8 @@ s32 EnGirlA_CanBuy_BluePotion(PlayState* play, EnGirlA* this) { } s32 EnGirlA_CanBuy_Longsword(PlayState* play, EnGirlA* this) { - if ((gBitFlags[2] & gSaveContext.inventory.equipment) && !(gBitFlags[3] & gSaveContext.inventory.equipment)) { + if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BIGGORON) && + !CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE)) { return CANBUY_RESULT_CANT_GET_NOW; } if (gSaveContext.rupees < this->basePrice) { @@ -578,7 +579,7 @@ s32 EnGirlA_CanBuy_Longsword(PlayState* play, EnGirlA* this) { } s32 EnGirlA_CanBuy_HylianShield(PlayState* play, EnGirlA* this) { - if (gBitFlags[5] & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SHIELD, EQUIP_INV_SHIELD_HYLIAN)) { return CANBUY_RESULT_CANT_GET_NOW; } if (gSaveContext.rupees < this->basePrice) { @@ -591,7 +592,7 @@ s32 EnGirlA_CanBuy_HylianShield(PlayState* play, EnGirlA* this) { } s32 EnGirlA_CanBuy_DekuShield(PlayState* play, EnGirlA* this) { - if (gBitFlags[4] & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SHIELD, EQUIP_INV_SHIELD_DEKU)) { return CANBUY_RESULT_CANT_GET_NOW; } if (gSaveContext.rupees < this->basePrice) { @@ -608,7 +609,7 @@ s32 EnGirlA_CanBuy_GoronTunic(PlayState* play, EnGirlA* this) { (!IS_RANDO || Randomizer_GetSettingValue(RSK_SHOPSANITY) == RO_SHOPSANITY_OFF)) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gBitFlags[9] & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_GORON)) { return CANBUY_RESULT_CANT_GET_NOW; } if (gSaveContext.rupees < this->basePrice) { @@ -625,7 +626,7 @@ s32 EnGirlA_CanBuy_ZoraTunic(PlayState* play, EnGirlA* this) { (!IS_RANDO || Randomizer_GetSettingValue(RSK_SHOPSANITY) == RO_SHOPSANITY_OFF)) { return CANBUY_RESULT_CANT_GET_NOW; } - if (gBitFlags[10] & gSaveContext.inventory.equipment) { + if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_ZORA)) { return CANBUY_RESULT_CANT_GET_NOW; } if (gSaveContext.rupees < this->basePrice) { diff --git a/soh/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/soh/src/overlays/actors/ovl_En_Gm/z_en_gm.c index f461e781c..4986f24f6 100644 --- a/soh/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/soh/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -99,9 +99,9 @@ s32 func_80A3D7C8(void) { } else if ((IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MERCHANTS) != RO_SHUFFLE_MERCHANTS_OFF) && !Flags_GetRandomizerInf(RAND_INF_MERCHANTS_MEDIGORON)) { return 1; - } else if (!(gBitFlags[2] & gSaveContext.inventory.equipment)) { // Don't have giant's knife + } else if (!CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BIGGORON)) { // Don't have giant's knife return 1; - } else if (gBitFlags[3] & gSaveContext.inventory.equipment) { // Have broken giant's knife + } else if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE)) { // Have broken giant's knife return 2; } else { return 3; diff --git a/soh/src/overlays/actors/ovl_En_Go/z_en_go.c b/soh/src/overlays/actors/ovl_En_Go/z_en_go.c index ea9b13561..3094f2171 100644 --- a/soh/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/soh/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -120,7 +120,7 @@ u16 EnGo_GetTextID(PlayState* play, Actor* thisx) { } else { return 0x3041; } - } else if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1) || (Flags_GetInfTable(INFTABLE_10D))) { + } else if (CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_GORON) || (Flags_GetInfTable(INFTABLE_10D))) { if (Flags_GetInfTable(INFTABLE_SPOKE_TO_GORON_LINK)) { return 0x3038; } else { @@ -651,7 +651,7 @@ void EnGo_Init(Actor* thisx, PlayState* play) { switch (this->actor.params & 0xF0) { case 0x00: Actor_SetScale(&this->actor, 0.008f); - if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + if (CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_GORON)) { EnGo_SetMovedPos(this, play); EnGo_SetupAction(this, EnGo_CurledUp); } else { diff --git a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c index 02c4d37a7..a4aede2e5 100644 --- a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -527,7 +527,7 @@ u16 EnGo2_GetTextIdGoronCityLink(PlayState* play, EnGo2* this) { if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) { return Flags_GetInfTable(INFTABLE_10F) ? 0x3042 : 0x3041; - } else if (CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + } else if (CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_GORON)) { return Flags_GetInfTable(INFTABLE_SPOKE_TO_GORON_LINK) ? 0x3038 : 0x3037; } else if (Flags_GetInfTable(INFTABLE_STOPPED_GORON_LINKS_ROLLING)) { this->unk_20C = 0; @@ -1221,7 +1221,7 @@ s32 EnGo2_IsCameraModified(EnGo2* this, PlayState* play) { return true; } else if (((!IS_RANDO && !CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) || (IS_RANDO && !Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_FIRE_TEMPLE))) && - CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_GORON)) { return true; } else { return false; @@ -1280,7 +1280,7 @@ void EnGo2_SelectGoronWakingUp(EnGo2* this) { case GORON_CITY_LINK: if (((!IS_RANDO && !CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) || (IS_RANDO && !Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_FIRE_TEMPLE))) && - CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_GORON)) { EnGo2_WakingUp(this); break; } @@ -1642,7 +1642,7 @@ void EnGo2_Init(Actor* thisx, PlayState* play) { this->actor.home.pos = this->actor.world.pos; if (((!IS_RANDO && !CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) || (IS_RANDO && !Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_FIRE_TEMPLE))) && - CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_GORON)) { EnGo2_GetItemAnimation(this, play); } else { this->actionFunc = EnGo2_CurledUp; @@ -2140,7 +2140,7 @@ s32 EnGo2_OverrideLimbDraw(PlayState* play, s32 limb, Gfx** dList, Vec3f* pos, V Matrix_RotateX(float1, MTXMODE_APPLY); float1 = (vec1.x / (f32)0x8000) * M_PI; Matrix_RotateZ(float1, MTXMODE_APPLY); - Matrix_Translate(-2800.0f + CVarGetFloat("gCosmetics.Goron_NeckLength", 0.0f), 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-2800.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limb == 10) { vec1 = this->interactInfo.torsoRot; diff --git a/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c index 75b7479f3..ad3bd0ab5 100644 --- a/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ b/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c @@ -95,7 +95,7 @@ u16 EnKz_GetTextNoMaskAdult(PlayState* play, EnKz* this) { if (INV_CONTENT(ITEM_TRADE_ADULT) >= ITEM_FROG) { if (!Flags_GetInfTable(INFTABLE_139)) { if (!IS_RANDO) { - return CHECK_OWNED_EQUIP(EQUIP_TUNIC, 2) ? 0x401F : 0x4012; + return CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_ZORA) ? 0x401F : 0x4012; } else { return 0x4012; } @@ -272,7 +272,7 @@ void func_80A9CB18(EnKz* this, PlayState* play) { player->actor.textId = this->actor.textId; } else { if (!IS_RANDO) { - this->actor.textId = CHECK_OWNED_EQUIP(EQUIP_TUNIC, 2) ? 0x401F : 0x4012; + this->actor.textId = CHECK_OWNED_EQUIP(EQUIP_TYPE_TUNIC, EQUIP_INV_TUNIC_ZORA) ? 0x401F : 0x4012; } else { this->actor.textId = 0x4012; } diff --git a/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index e088b9f10..6f8624518 100644 --- a/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -85,9 +85,9 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) { this->unk_1CA = 0; if (player->stateFlags2 & 0x20000) { - if (!gSaveContext.isMagicAcquired || gSaveContext.magicState || + if (!gSaveContext.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || (((this->actor.params & 0xFF00) >> 8) && - !(func_80087708(play, (this->actor.params & 0xFF00) >> 8, 0)))) { + !(Magic_RequestChange(play, (this->actor.params & 0xFF00) >> 8, MAGIC_CONSUME_NOW)))) { Audio_PlaySoundGeneral(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, @@ -116,7 +116,7 @@ void EnMThunder_Destroy(Actor* thisx, PlayState* play) { EnMThunder* this = (EnMThunder*)thisx; if (this->unk_1CA != 0) { - func_800876C8(play); + Magic_Reset(play); } Collider_DestroyCylinder(play, &this->collider); @@ -158,8 +158,8 @@ void func_80A9F408(EnMThunder* this, PlayState* play) { if (this->unk_1CA == 0) { if (player->unk_858 >= 0.1f) { - if ((gSaveContext.magicState) || (((this->actor.params & 0xFF00) >> 8) && - !(func_80087708(play, (this->actor.params & 0xFF00) >> 8, 4)))) { + if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || (((this->actor.params & 0xFF00) >> 8) && + !(Magic_RequestChange(play, (this->actor.params & 0xFF00) >> 8, MAGIC_CONSUME_WAIT_PREVIEW)))) { func_80A9F350(this, play); func_80A9EFE0(this, func_80A9F350); this->unk_1C8 = 0; @@ -193,7 +193,7 @@ void func_80A9F408(EnMThunder* this, PlayState* play) { } else { player->stateFlags2 &= ~0x20000; if ((this->actor.params & 0xFF00) >> 8) { - gSaveContext.magicState = 1; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } if (player->unk_858 < 0.85f) { this->collider.info.toucher.dmgFlags = D_80AA044C[this->unk_1C7]; diff --git a/soh/src/overlays/actors/ovl_En_Md/z_en_md.c b/soh/src/overlays/actors/ovl_En_Md/z_en_md.c index d757a5a02..14d9cbb7b 100644 --- a/soh/src/overlays/actors/ovl_En_Md/z_en_md.c +++ b/soh/src/overlays/actors/ovl_En_Md/z_en_md.c @@ -384,7 +384,8 @@ u16 EnMd_GetTextKokiriForest(PlayState* play, EnMd* this) { return 0x1034; } - if ((CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1) && (CUR_EQUIP_VALUE(EQUIP_SWORD) == 1)) { + if ((CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_DEKU) && + (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_KOKIRI)) { return 0x1033; } diff --git a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 2ae32e916..460c788b2 100644 --- a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -2531,6 +2531,15 @@ void EnOssan_DrawKokiriShopkeeper(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } +s32 EnGo2_OverrideLimbDrawGoronShopkeeper (PlayState* play, s32 limb, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnOssan* this = (EnOssan*)thisx; + + if (limb == 17) { + Matrix_Translate(CVarGetFloat("gCosmetics.Goron_NeckLength", 0.0f), 0.0f, 0.0f, MTXMODE_APPLY); + } + return 0; +} + void EnOssan_DrawGoronShopkeeper(Actor* thisx, PlayState* play) { static void* sGoronShopkeeperEyeTextures[] = { gGoronCsEyeOpenTex, gGoronCsEyeHalfTex, gGoronCsEyeClosedTex }; EnOssan* this = (EnOssan*)thisx; @@ -2541,7 +2550,7 @@ void EnOssan_DrawGoronShopkeeper(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronShopkeeperEyeTextures[this->eyeTextureIdx])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(gGoronCsMouthNeutralTex)); - SkelAnime_DrawSkeletonOpa(play, &this->skelAnime, NULL, NULL, this); + SkelAnime_DrawSkeletonOpa(play, &this->skelAnime, EnGo2_OverrideLimbDrawGoronShopkeeper, NULL, this); EnOssan_DrawCursor(play, this, this->cursorX, this->cursorY, this->cursorZ, this->drawCursor); EnOssan_DrawStickDirectionPrompts(play, this); diff --git a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c index 4a2201ab7..bfd4dfbbe 100644 --- a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c +++ b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c @@ -195,7 +195,7 @@ void UseBow(Actor* thisx, PlayState* play, u8 started, u8 arrowType) { } else if (started == 0) { if (this->itemTimer <= 0) { if (AMMO(ITEM_BOW) > 0) { - if (arrowType >= 1 && !func_80087708(play, magicArrowCosts[arrowType], 0)) { + if (arrowType >= 1 && !Magic_RequestChange(play, magicArrowCosts[arrowType], MAGIC_CONSUME_NOW)) { func_80078884(NA_SE_SY_ERROR); this->canMove = 1; return; @@ -455,7 +455,7 @@ void UseSpell(Actor* thisx, PlayState* play, u8 started, u8 spellType) { if (started == 0 && this->usedSpell != 0) { this->itemTimer = 10; - gSaveContext.magicState = 5; + gSaveContext.magicState = MAGIC_STATE_RESET; switch (this->usedSpell) { case 1: @@ -487,7 +487,7 @@ void UseSpell(Actor* thisx, PlayState* play, u8 started, u8 spellType) { break; } - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; this->magicTimer--; if (this->magicTimer <= 0) { gSaveContext.magic--; @@ -497,7 +497,7 @@ void UseSpell(Actor* thisx, PlayState* play, u8 started, u8 spellType) { this->itemTimer = 10; this->usedSpell = 0; - gSaveContext.magicState = 5; + gSaveContext.magicState = MAGIC_STATE_RESET; } } } diff --git a/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 49207d643..a3265d724 100644 --- a/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -298,15 +298,15 @@ void EnRr_SetupReleasePlayer(EnRr* this, PlayState* play) { this->wobbleSizeTarget = 2048.0f; tunic = 0; shield = 0; - if (CUR_EQUIP_VALUE(EQUIP_SHIELD) != 3 /* Mirror shield */) { - shield = Inventory_DeleteEquipment(play, EQUIP_SHIELD); + if (CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_MIRROR) { + shield = Inventory_DeleteEquipment(play, EQUIP_TYPE_SHIELD); if (shield != 0) { this->eatenShield = shield; this->retreat = true; } } - if (CUR_EQUIP_VALUE(EQUIP_TUNIC) != 1 /* Kokiri tunic */ && !IS_RANDO /* Randomizer Save File */) { - tunic = Inventory_DeleteEquipment(play, EQUIP_TUNIC); + if (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) != EQUIP_VALUE_TUNIC_KOKIRI && !IS_RANDO /* Randomizer Save File */) { + tunic = Inventory_DeleteEquipment(play, EQUIP_TYPE_TUNIC); if (tunic != 0) { this->eatenTunic = tunic; this->retreat = true; diff --git a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 0a3172fd0..e83393899 100644 --- a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -136,7 +136,7 @@ void EnTorch2_Init(Actor* thisx, PlayState* play2) { sInput.cur.stick_x = sInput.cur.stick_y = 0; this->currentShield = PLAYER_SHIELD_HYLIAN; this->heldItemAction = this->heldItemId = PLAYER_IA_SWORD_MASTER; - Player_SetModelGroup(this, 2); + Player_SetModelGroup(this, PLAYER_MODELGROUP_SWORD); play->playerInit(this, play, &gDarkLinkSkel); this->actor.naviEnemyId = 0x26; this->cylinder.base.acFlags = AC_ON | AC_TYPE_PLAYER; @@ -568,7 +568,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { // Causes Dark Link to shield in place when Link is using magic attacks other than the spin attack - if ((gSaveContext.magicState == 3) && (player->meleeWeaponState == 0 || (player->meleeWeaponAnimation < SPIN_ATTACK_1H) || + if ((gSaveContext.magicState == MAGIC_STATE_METER_FLASH_1) && (player->meleeWeaponState == 0 || (player->meleeWeaponAnimation < SPIN_ATTACK_1H) || (player->meleeWeaponAnimation > BIG_SPIN_2H))) { sStickTilt = 0.0f; input->cur.stick_x = 0; diff --git a/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 9991f20eb..69c33f5f5 100644 --- a/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -328,7 +328,11 @@ void EnWallmas_WaitToDrop(EnWallmas* this, PlayState* play) { } if (this->timer == 0) { - EnWallmas_SetupDrop(this, play); + if (this->actor.params == WMT_SHADOWTAG && (player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE)) { + this->timer = 0x82; // Prevents Shadow Tag Hand from dropping when talking to an NPC or Signpost. + } else { + EnWallmas_SetupDrop(this, play); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c index c72a82df6..83f799877 100644 --- a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -376,7 +376,7 @@ void EnXc_SetupSerenadeAction(EnXc* this, PlayState* play) { } // Player is adult and does not have iron boots and has not learned Serenade - if ((!CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1) && !Flags_GetEventChkInf(EVENTCHKINF_LEARNED_SERENADE_OF_WATER)) && LINK_IS_ADULT) { + if ((!CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, EQUIP_INV_BOOTS_IRON) && !Flags_GetEventChkInf(EVENTCHKINF_LEARNED_SERENADE_OF_WATER)) && LINK_IS_ADULT) { this->action = SHEIK_ACTION_SERENADE; osSyncPrintf("水のセレナーデ シーク誕生!!!!!!!!!!!!!!!!!!\n"); } else { @@ -390,7 +390,7 @@ s32 EnXc_SerenadeCS(EnXc* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 stateFlags = player->stateFlags1; - if (((CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1) && !IS_RANDO) || + if (((CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, EQUIP_INV_BOOTS_IRON) && !IS_RANDO) || (Flags_GetTreasure(play, 2) && IS_RANDO)) && !Flags_GetEventChkInf(EVENTCHKINF_LEARNED_SERENADE_OF_WATER) && !(stateFlags & 0x20000000) && !Play_InCsMode(play)) { @@ -2247,7 +2247,7 @@ void EnXc_SetupDialogueAction(EnXc* this, PlayState* play) { this->actor.textId = TEXT_SHEIK_HAVE_HOOK; } } else if (IS_RANDO && gPlayState->sceneNum == SCENE_INSIDE_GANONS_CASTLE) { - if (CHECK_OWNED_EQUIP(EQUIP_SWORD, 1) && INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT && + if (CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER) && INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT && CUR_CAPACITY(UPG_QUIVER) >= 30 && gSaveContext.isMagicAcquired) { this->actor.textId = TEXT_SHEIK_HAVE_HOOK; } else { diff --git a/soh/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c b/soh/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c index c0841180b..4a47b456e 100644 --- a/soh/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ b/soh/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c @@ -545,7 +545,7 @@ void EnZl2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, { Player* player = GET_PLAYER(play); Matrix_Push(); - if (player->rightHandType == 0xFF) { + if (player->rightHandType == PLAYER_MODELTYPE_RH_FF) { Matrix_Put(&player->shieldMf); Matrix_Translate(180.0f, 979.0f, -375.0f, MTXMODE_APPLY); Matrix_RotateZYX(-0x5DE7, -0x53E9, 0x3333, MTXMODE_APPLY); diff --git a/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 2c23aa82d..d07f2de50 100644 --- a/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -1810,7 +1810,7 @@ void func_80B5772C(EnZl3* this, PlayState* play) { } void func_80B57754(EnZl3* this, PlayState* play) { - if (gSaveContext.magicState == 0) { + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { Actor_Spawn(&play->actorCtx, play, ACTOR_OCEFF_WIPE4, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, true); func_80B56DA4(this); diff --git a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c index ecb16dcb6..3f8de83ba 100644 --- a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -5125,16 +5125,6 @@ void Fishing_HandleOwnerDialog(Fishing* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { this->unk_15C = 0; - - Player* player = GET_PLAYER(play); - - if (gSaveContext.temporaryWeapon) { - player->currentSwordItemId = ITEM_NONE; - gSaveContext.equips.buttonItems[0] = ITEM_NONE; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE); - gSaveContext.temporaryWeapon = false; - } - if (D_80B7A68C != 0) { D_80B7A688 = 1; D_80B7A68C = 0; diff --git a/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c b/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c index 882c6b46e..73a588ab3 100644 --- a/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c +++ b/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c @@ -65,7 +65,7 @@ void MagicDark_Init(Actor* thisx, PlayState* play) { void MagicDark_Destroy(Actor* thisx, PlayState* play) { if (gSaveContext.nayrusLoveTimer == 0) { - func_800876C8(play); + Magic_Reset(play); } } diff --git a/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c b/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c index 75be6e0bc..b245c988c 100644 --- a/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c +++ b/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c @@ -93,7 +93,7 @@ void MagicFire_Init(Actor* thisx, PlayState* play) { } void MagicFire_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); } void MagicFire_UpdateBeforeCast(Actor* thisx, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c b/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c index 90ca0e269..ac7a35036 100644 --- a/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c +++ b/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c @@ -70,7 +70,7 @@ void MagicWind_Init(Actor* thisx, PlayState* play) { void MagicWind_Destroy(Actor* thisx, PlayState* play) { MagicWind* this = (MagicWind*)thisx; SkelCurve_Destroy(play, &this->skelCurve); - func_800876C8(play); + Magic_Reset(play); // "wipe out" LOG_STRING("消滅"); } diff --git a/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 178921453..8aa68b160 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -70,7 +70,7 @@ void OceffSpot_Destroy(Actor* thisx, PlayState* play) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode1); LightContext_RemoveLight(play, &play->lightCtx, this->lightNode2); - func_800876C8(play); + Magic_Reset(play); if ((gSaveContext.nayrusLoveTimer != 0) && (play->actorCtx.actorLists[ACTORCAT_PLAYER].length != 0)) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index d4d9acb92..3869fa6e4 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -60,7 +60,7 @@ void OceffStorm_Destroy(Actor* thisx, PlayState* play) { OceffStorm* this = (OceffStorm*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index 41b2d2905..0076a6385 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -40,7 +40,7 @@ void OceffWipe_Destroy(Actor* thisx, PlayState* play) { OceffWipe* this = (OceffWipe*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index 13a955640..38014b5e2 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -40,7 +40,7 @@ void OceffWipe2_Destroy(Actor* thisx, PlayState* play) { OceffWipe2* this = (OceffWipe2*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index eb85a2816..df3fc1a87 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -43,7 +43,7 @@ void OceffWipe3_Destroy(Actor* thisx, PlayState* play) { OceffWipe3* this = (OceffWipe3*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index 043db276d..5a66b2991 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -39,7 +39,7 @@ void OceffWipe4_Init(Actor* thisx, PlayState* play) { void OceffWipe4_Destroy(Actor* thisx, PlayState* play) { OceffWipe4* this = (OceffWipe4*)thisx; - func_800876C8(play); + Magic_Reset(play); } void OceffWipe4_Update(Actor* thisx, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index a4d933c58..556b8ccd5 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -17,6 +17,7 @@ #include "overlays/actors/ovl_En_Fish/z_en_fish.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" #include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" +#include "overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_link_child/object_link_child.h" #include "textures/icon_item_24_static/icon_item_24_static.h" @@ -2224,7 +2225,7 @@ s32 func_8083442C(Player* this, PlayState* play) { s32 magicArrowType; if ((this->heldItemAction >= PLAYER_IA_BOW_FIRE) && (this->heldItemAction <= PLAYER_IA_BOW_0E) && - (gSaveContext.magicState != 0)) { + (gSaveContext.magicState != MAGIC_STATE_IDLE)) { func_80078884(NA_SE_SY_ERROR); } else { func_80833638(this, func_808351D4); @@ -2240,7 +2241,7 @@ s32 func_8083442C(Player* this, PlayState* play) { if (this->unk_860 >= 0) { if ((magicArrowType >= 0) && (magicArrowType <= 2) && - !func_80087708(play, sMagicArrowCosts[magicArrowType], 0)) { + !Magic_RequestChange(play, sMagicArrowCosts[magicArrowType], MAGIC_CONSUME_NOW)) { arrowType = ARROW_NORMAL; } @@ -2979,7 +2980,7 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { } if (actionParam == PLAYER_IA_LENS_OF_TRUTH) { - if (func_80087708(play, 0, 3)) { + if (Magic_RequestChange(play, 0, MAGIC_CONSUME_LENS)) { if (play->actorCtx.lensActive) { Actor_DisableLens(play); } else { @@ -3004,7 +3005,7 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { temp = Player_ActionToMagicSpell(this, actionParam); if (temp >= 0) { if (((actionParam == PLAYER_IA_FARORES_WIND) && (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 0)) || - ((gSaveContext.magicCapacity != 0) && (gSaveContext.magicState == 0) && + ((gSaveContext.magicCapacity != 0) && (gSaveContext.magicState == MAGIC_STATE_IDLE) && (gSaveContext.magic >= sMagicSpellCosts[temp]))) { this->itemAction = actionParam; this->unk_6AD = 4; @@ -3856,7 +3857,7 @@ void func_8083819C(Player* this, PlayState* play) { if (this->currentShield == PLAYER_SHIELD_DEKU && (CVarGetInteger("gFireproofDekuShield", 0) == 0)) { Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_SHIELD, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, true); - Inventory_DeleteEquipment(play, EQUIP_SHIELD); + Inventory_DeleteEquipment(play, EQUIP_TYPE_SHIELD); Message_StartTextbox(play, 0x305F, NULL); } } @@ -4981,7 +4982,7 @@ void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { func_80835DE4(play, this, func_808507F4, 0); this->unk_84F = magicSpell - 3; - func_80087708(play, sMagicSpellCosts[magicSpell], 4); + Magic_RequestChange(play, sMagicSpellCosts[magicSpell], MAGIC_CONSUME_WAIT_PREVIEW); u8 isFastFarores = CVarGetInteger("gFastFarores", 0) && this->itemAction == PLAYER_IA_FARORES_WIND; @@ -9740,7 +9741,7 @@ void Player_Init(Actor* thisx, PlayState* play2) { } if (gSaveContext.nayrusLoveTimer != 0) { - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; func_80846A00(play, this, 1); this->stateFlags3 &= ~PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } @@ -10590,20 +10591,20 @@ void Player_UseTunicBoots(Player* this, PlayState* play) { actionParam = Player_ItemToItemAction(item); if (actionParam >= PLAYER_IA_BOOTS_KOKIRI) { u16 bootsValue = actionParam - PLAYER_IA_BOOTS_KOKIRI + 1; - if (CUR_EQUIP_VALUE(EQUIP_BOOTS) == bootsValue) { - Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_KOKIRI + 1); + if (CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS) == bootsValue) { + Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_KOKIRI); } else { - Inventory_ChangeEquipment(EQUIP_BOOTS, bootsValue); + Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, bootsValue); } Player_SetEquipmentData(play, this); - func_808328EC(this, CUR_EQUIP_VALUE(EQUIP_BOOTS) == PLAYER_BOOTS_IRON + 1 ? NA_SE_PL_WALK_HEAVYBOOTS + func_808328EC(this, CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS) == EQUIP_VALUE_BOOTS_IRON ? NA_SE_PL_WALK_HEAVYBOOTS : NA_SE_PL_CHANGE_ARMS); } else if (actionParam >= PLAYER_IA_TUNIC_KOKIRI) { u16 tunicValue = actionParam - PLAYER_IA_TUNIC_KOKIRI + 1; - if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == tunicValue) { - Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_KOKIRI + 1); + if (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) == tunicValue) { + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, EQUIP_VALUE_TUNIC_KOKIRI); } else { - Inventory_ChangeEquipment(EQUIP_TUNIC, tunicValue); + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, tunicValue); } Player_SetEquipmentData(play, this); func_808328EC(this, NA_SE_PL_CHANGE_ARMS); @@ -10666,8 +10667,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { func_80848C74(play, this); } - if ((this->stateFlags3 & PLAYER_STATE3_RESTORE_NAYRUS_LOVE) && (gSaveContext.nayrusLoveTimer != 0) && (gSaveContext.magicState == 0)) { - gSaveContext.magicState = 3; + if ((this->stateFlags3 & PLAYER_STATE3_RESTORE_NAYRUS_LOVE) && (gSaveContext.nayrusLoveTimer != 0) && (gSaveContext.magicState == MAGIC_STATE_IDLE)) { + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; func_80846A00(play, this, 1); this->stateFlags3 &= ~PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } @@ -11253,7 +11254,7 @@ void Player_Draw(Actor* thisx, PlayState* play2) { pos.y = -130.0f; pos.z = -150.0f; scale = 0.046f; - } else if (CUR_EQUIP_VALUE(EQUIP_SWORD) != 2) { + } else if (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_MASTER) { pos.x = 25.0f; pos.y = -228.0f; pos.z = 60.0f; @@ -11373,7 +11374,7 @@ void Player_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyQuad(play, &this->meleeWeaponQuads[1]); Collider_DestroyQuad(play, &this->shieldQuad); - func_800876C8(play); + Magic_Reset(play); gSaveContext.linkAge = play->linkAgeOnLoad; @@ -12715,8 +12716,7 @@ s32 func_8084DFF4(PlayState* play, Player* this) { equipItem = giEntry.itemId; equipNow = CVarGetInteger("gAskToEquip", 0) && giEntry.modIndex == MOD_NONE && equipItem >= ITEM_SWORD_KOKIRI && equipItem <= ITEM_TUNIC_ZORA && - ((gItemAgeReqs[equipItem] == 9 || gItemAgeReqs[equipItem] == gSaveContext.linkAge) || - CVarGetInteger("gTimelessEquipment", 0)); + CHECK_AGE_REQ_ITEM(equipItem); Message_StartTextbox(play, giEntry.textId, &this->actor); // RANDOTODO: Macro this boolean check. @@ -12774,16 +12774,16 @@ s32 func_8084DFF4(PlayState* play, Player* this) { if (equipItem >= ITEM_SWORD_KOKIRI && equipItem <= ITEM_SWORD_BGS) { gSaveContext.equips.buttonItems[0] = equipItem; - Inventory_ChangeEquipment(EQUIP_SWORD, equipItem - ITEM_SWORD_KOKIRI + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, equipItem - ITEM_SWORD_KOKIRI + 1); func_808328EC(this, NA_SE_IT_SWORD_PUTAWAY); } else if (equipItem >= ITEM_SHIELD_DEKU && equipItem <= ITEM_SHIELD_MIRROR) { - Inventory_ChangeEquipment(EQUIP_SHIELD, equipItem - ITEM_SHIELD_DEKU + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, equipItem - ITEM_SHIELD_DEKU + 1); func_808328EC(&this->actor, NA_SE_IT_SHIELD_REMOVE); Player_SetEquipmentData(play, this); } else if (equipItem == ITEM_TUNIC_GORON || equipItem == ITEM_TUNIC_ZORA) { - Inventory_ChangeEquipment(EQUIP_TUNIC, equipItem - ITEM_TUNIC_KOKIRI + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, equipItem - ITEM_TUNIC_KOKIRI + 1); func_808328EC(this, NA_SE_PL_CHANGE_ARMS); Player_SetEquipmentData(play, this); } @@ -13098,39 +13098,39 @@ void func_8084EAC0(Player* this, PlayState* play) { } if (CVarGetInteger("gBlueManaPercentRestore", 0)) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, + Magic_RequestChange(play, (gSaveContext.magicLevel * 48 * CVarGetInteger("gBluePotionMana", 100) / 100 + 15) / 16 * 16, - 5); + MAGIC_ADD); } else { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, CVarGetInteger("gBluePotionMana", 100), 5); + Magic_RequestChange(play, CVarGetInteger("gBluePotionMana", 100), MAGIC_ADD); ; } } else if (CVarGetInteger("gGreenPotionEffect", 0) && this->itemAction == PLAYER_IA_BOTTLE_POTION_GREEN) { if (CVarGetInteger("gGreenPercentRestore", 0)) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, + Magic_RequestChange(play, (gSaveContext.magicLevel * 48 * CVarGetInteger("gGreenPotionMana", 100) / 100 + 15) / 16 * 16, - 5); + MAGIC_ADD); } else { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, CVarGetInteger("gGreenPotionMana", 100), 5); + Magic_RequestChange(play, CVarGetInteger("gGreenPotionMana", 100), MAGIC_ADD); ; } } else if (CVarGetInteger("gMilkEffect", 0) && (this->itemAction == PLAYER_IA_BOTTLE_MILK_FULL || @@ -13174,7 +13174,7 @@ void func_8084EAC0(Player* this, PlayState* play) { func_8083C0E8(this, play); func_8005B1A4(Play_GetCamera(play, 0)); } else if (this->unk_850 == 1) { - if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != 9)) { + if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { func_80832B78(play, this, &gPlayerAnim_link_bottle_drink_demo_end); this->unk_850 = 2; Player_UpdateBottleHeld(play, this, ITEM_BOTTLE, PLAYER_IA_BOTTLE); @@ -13933,7 +13933,7 @@ void func_808507F4(Player* this, PlayState* play) { u8 isFastFarores = CVarGetInteger("gFastFarores", 0) && this->itemAction == PLAYER_IA_FARORES_WIND; if (LinkAnimation_Update(play, &this->skelAnime)) { if (this->unk_84F < 0) { - if ((this->itemAction == PLAYER_IA_NAYRUS_LOVE) || isFastFarores || (gSaveContext.magicState == 0)) { + if ((this->itemAction == PLAYER_IA_NAYRUS_LOVE) || isFastFarores || (gSaveContext.magicState == MAGIC_STATE_IDLE)) { func_80839FFC(this, play); func_8005B1A4(Play_GetCamera(play, 0)); } @@ -13944,10 +13944,10 @@ void func_808507F4(Player* this, PlayState* play) { if (func_80846A00(play, this, this->unk_84F) != NULL) { this->stateFlags1 |= PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE; if ((this->unk_84F != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { - gSaveContext.magicState = 1; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } } else { - func_800876C8(play); + Magic_Reset(play); } } else { LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, D_80854A64[this->unk_84F], 0.83f * (isFastFarores ? 2 : 1)); @@ -14946,9 +14946,19 @@ void func_80852648(PlayState* play, Player* this, CsCmdActorAction* arg2) { this->heldItemId = ITEM_NONE; this->modelGroup = this->nextModelGroup = Player_ActionToModelGroup(this, PLAYER_IA_NONE); this->leftHandDLists = gPlayerLeftHandOpenDLs; - Inventory_ChangeEquipment(EQUIP_SWORD, 2); + + // If MS sword is shuffled and not in the players inventory, then we need to unequip the current sword + // and set swordless flag to mimic Link having his weapon knocked out of his hand in the Ganon fight + if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && !CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)) { + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + Flags_SetInfTable(INFTABLE_SWORDLESS); + return; + } + + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_MASTER); gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - Inventory_DeleteEquipment(play, 0); + Inventory_DeleteEquipment(play, EQUIP_TYPE_SWORD); } } @@ -15135,17 +15145,6 @@ s32 Player_IsDroppingFish(PlayState* play) { s32 Player_StartFishing(PlayState* play) { Player* this = GET_PLAYER(play); - if (gSaveContext.linkAge == 1) { - if (!CHECK_OWNED_EQUIP(EQUIP_SWORD, 0)) { - gSaveContext.temporaryWeapon = true; - } - if (this->heldItemId == ITEM_NONE) { - this->currentSwordItemId = ITEM_SWORD_KOKIRI; - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI); - } - } - func_80832564(play, this); func_80835F44(play, this, ITEM_FISHING_POLE); return 1; diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 630a1159a..5de6df23d 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1266,18 +1266,14 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { if (ABS(this->stickRelX) > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DRIGHT))) { if (this->stickRelX > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT))) { this->questType[this->buttonIndex] += 1; - while ((this->questType[this->buttonIndex] == QUEST_MASTER && !ResourceMgr_GameHasMasterQuest()) || - (this->questType[this->buttonIndex] == QUEST_RANDOMIZER && !hasRandomizerQuest())) { - // If Master Quest is selected without a Master Quest OTR present or when Randomizer Quest is - // selected without a loaded Randomizer seed, skip past it. + while (this->questType[this->buttonIndex] == QUEST_MASTER && !ResourceMgr_GameHasMasterQuest()) { + // If Master Quest is selected without a Master Quest OTR present, skip past it. this->questType[this->buttonIndex] += 1; } } else if (this->stickRelX < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT))) { this->questType[this->buttonIndex] -= 1; - while ((this->questType[this->buttonIndex] == QUEST_MASTER && !ResourceMgr_GameHasMasterQuest()) || - (this->questType[this->buttonIndex] == QUEST_RANDOMIZER && !hasRandomizerQuest())) { - // If Master Quest is selected without a Master Quest OTR present or when Randomizer Quest is - // selected without a loaded Randomizer seed, skip past it. + while (this->questType[this->buttonIndex] == QUEST_MASTER && !ResourceMgr_GameHasMasterQuest()) { + // If Master Quest is selected without a Master Quest OTR present, skip past it. this->questType[this->buttonIndex] -= 1; } } @@ -1304,6 +1300,8 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { this->prevConfigMode = this->configMode; this->configMode = CM_ROTATE_TO_BOSS_RUSH_MENU; return; + } else if (this->questType[this->buttonIndex] == QUEST_RANDOMIZER && !hasRandomizerQuest()) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); osSyncPrintf("Selected Dungeon Quest: %d\n", IS_MASTER_QUEST); @@ -2236,7 +2234,11 @@ void FileChoose_DrawWindowContents(GameState* thisx) { case QUEST_RANDOMIZER: DrawSeedHashSprites(this); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->logoAlpha); + if (hasRandomizerQuest()) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->logoAlpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0x40, 0x40, 0x40, this->logoAlpha); + } FileChoose_DrawTextureI8(this->state.gfxCtx, gTitleTheLegendOfTextTex, 72, 8, 156, 108, 72, 8, 1024, 1024); FileChoose_DrawTextureI8(this->state.gfxCtx, gTitleOcarinaOfTimeTMTextTex, 96, 8, 154, 163, 96, 8, 1024, 1024); FileChoose_DrawImageRGBA32(this->state.gfxCtx, 160, 135, ResourceMgr_GameHasOriginal() ? gTitleZeldaShieldLogoTex : gTitleZeldaShieldLogoMQTex, 160, 160); @@ -2937,7 +2939,7 @@ void FileChoose_FadeOut(GameState* thisx) { */ void FileChoose_LoadGame(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; - u16 swordEquipMask; + u16 swordEquipValue; s32 pad; Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -2987,8 +2989,8 @@ void FileChoose_LoadGame(GameState* thisx) { gSaveContext.unk_13EE = 0x32; gSaveContext.nayrusLoveTimer = 0; gSaveContext.healthAccumulator = 0; - gSaveContext.magicState = 0; - gSaveContext.prevMagicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; + gSaveContext.prevMagicState = MAGIC_STATE_IDLE; gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; gSaveContext.skyboxTime = 0; gSaveContext.nextTransitionType = 0xFF; @@ -3024,9 +3026,9 @@ void FileChoose_LoadGame(GameState* thisx) { (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) { gSaveContext.equips.buttonItems[0] = ITEM_NONE; - swordEquipMask = BOMSWAP16(gEquipMasks[EQUIP_SWORD]) & gSaveContext.equips.equipment; - gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_SWORD]; - gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipMask - 1] << BOMSWAP16(gEquipShifts[EQUIP_SWORD])); + swordEquipValue = (BOMSWAP16(gEquipMasks[EQUIP_TYPE_SWORD]) & gSaveContext.equips.equipment) >> (EQUIP_TYPE_SWORD * 4); + gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_TYPE_SWORD]; + gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipValue - 1] << BOMSWAP16(gEquipShifts[EQUIP_TYPE_SWORD])); } } @@ -3124,7 +3126,7 @@ static void (*gFileSelectUpdateFuncs[])(GameState*) = { FileChoose_SelectModeUpdate, }; -static const char* randoWarningText[] = { +static const char* randoVersionWarningText[] = { // English "This save was created on a different version of SoH.\nThings may be broken. Play at your own risk.", // German @@ -3133,7 +3135,7 @@ static const char* randoWarningText[] = { "Cette sauvegarde a été créée sur une version\ndifférente de SoH.\nCertaines fonctionnalités peuvent être corrompues." }; -void FileChoose_DrawRandoSaveWarning(GameState* thisx) { +void FileChoose_DrawRandoSaveVersionWarning(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; OPEN_DISPS(this->state.gfxCtx); @@ -3170,7 +3172,7 @@ void FileChoose_DrawRandoSaveWarning(GameState* thisx) { (SCREEN_WIDTH - 32) << 2, (SCREEN_HEIGHT - bottomOffset) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, texCoordinateHeightScale << 1); - Interface_DrawTextLine(this->state.gfxCtx, randoWarningText[gSaveContext.language], 36, + Interface_DrawTextLine(this->state.gfxCtx, randoVersionWarningText[gSaveContext.language], 36, SCREEN_HEIGHT - height, 255, 255, 255, textAlpha, 0.8f, 1); } } @@ -3178,6 +3180,77 @@ void FileChoose_DrawRandoSaveWarning(GameState* thisx) { CLOSE_DISPS(this->state.gfxCtx); } +static const char* noRandoGeneratedText[] = { + // English + "No Randomizer seed currently available.\nGenerate one in the Randomizer Settings" +#if defined(__WIIU__) || defined(__SWITCH__) + ".", +#else + ",\nor drop a spoiler log on the game window.", +#endif + // German + "No Randomizer seed currently available.\nGenerate one in the Randomizer Settings" +#if defined(__WIIU__) || defined(__SWITCH__) + ".", +#else + ",\nor drop a spoiler log on the game window.", +#endif + // French + "Aucune Seed de Randomizer actuellement disponible.\nGénérez-en une dans les \"Randomizer Settings\"" +#if (defined(__WIIU__) || defined(__SWITCH__)) + "." +#else + "\nou glissez un spoilerlog sur la fenêtre du jeu." +#endif +}; + +void FileChoose_DrawNoRandoGeneratedWarning(GameState* thisx) { + FileChooseContext* this = (FileChooseContext*)thisx; + + OPEN_DISPS(this->state.gfxCtx); + + // Draw rando seed warning when build version doesn't match for Major or Minor number + if (this->configMode == CM_QUEST_MENU && this->questType[this->buttonIndex] == QUEST_RANDOMIZER && !hasRandomizerQuest()) { + uint8_t textAlpha = 225; + uint8_t textboxAlpha = 170; + float textboxScale = 0.7f; + + // float math to get a S5.10 number that will squish the texture + float texCoordinateHeightF = 512 / textboxScale; + uint16_t texCoordinateHeightScale = texCoordinateHeightF + 0.5f; + float texCoordinateWidthF = 512 / textboxScale; + uint16_t texCoordinateWidthScale = texCoordinateWidthF + 0.5f; + uint16_t textboxWidth = 256 * textboxScale; + uint16_t textboxHeight = 64 * textboxScale; + uint8_t leftOffset = 72; + uint8_t bottomOffset = 84; + uint8_t textVerticalOffset; +#if defined(__WIIU__) || defined(__SWITCH__) + textVerticalOffset = 127; // 2 lines +#else + textVerticalOffset = 122; // 3 lines +#endif + + Gfx_SetupDL_39Opa(this->state.gfxCtx); + gDPSetAlphaDither(POLY_OPA_DISP++, G_AD_DISABLE); + gSPClearGeometryMode(POLY_OPA_DISP++, G_SHADE); + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, + 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, textboxAlpha); + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gDefaultMessageBackgroundTex, G_IM_FMT_I, 128, 64, 0, G_TX_MIRROR, + G_TX_MIRROR, 7, 0, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(POLY_OPA_DISP++, leftOffset << 2, (SCREEN_HEIGHT - bottomOffset - textboxHeight) << 2, + (textboxWidth + leftOffset) << 2, (SCREEN_HEIGHT - bottomOffset) << 2, G_TX_RENDERTILE, 0, 0, + texCoordinateWidthScale << 1, texCoordinateHeightScale << 1); + + Interface_DrawTextLine(this->state.gfxCtx, noRandoGeneratedText[gSaveContext.language], 80, textVerticalOffset, + 255, 255, 255, textAlpha, 0.6f, 1); + } + + CLOSE_DISPS(this->state.gfxCtx); +} + void FileChoose_Main(GameState* thisx) { static void* controlsTextures[] = { gFileSelControlsENGTex, @@ -3369,8 +3442,10 @@ void FileChoose_Main(GameState* thisx) { gSPTextureRectangle(POLY_OPA_DISP++, 0x0168, 0x0330, 0x03A8, 0x0370, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400); } - // Draw rando save warning over the controls text, but before the screen fill fade out - FileChoose_DrawRandoSaveWarning(&this->state); + // Draw rando save version warning over the controls text, but before the screen fill fade out + FileChoose_DrawRandoSaveVersionWarning(&this->state); + + FileChoose_DrawNoRandoGeneratedWarning(&this->state); gDPPipeSync(POLY_OPA_DISP++); gSPDisplayList(POLY_OPA_DISP++, sScreenFillSetupDL); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c index 5b55f4144..3aa4a25d6 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c @@ -576,18 +576,18 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { } } } else { - i = curSection - 0x34; + i = curSection - 0x34; // 0 <= i < 4 if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.inventory.equipment ^= (1 << gEquipShifts[i]); + gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(i, 0); } if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { - gSaveContext.inventory.equipment ^= (2 << gEquipShifts[i]); + gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(i, 1); } if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.inventory.equipment ^= (4 << gEquipShifts[i]); + gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(i, 2); } if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { - gSaveContext.inventory.equipment ^= (8 << gEquipShifts[i]); + gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(i, 3); } } } else if (curSection < 0x44) { 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 dd6ea6a16..d255f40d2 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 @@ -108,7 +108,7 @@ void KaleidoScope_DrawPlayerWork(PlayState* play) { pos.y = -130.0f; pos.z = -150.0f; scale = 0.046f; - } else if (CUR_EQUIP_VALUE(EQUIP_SWORD) != 2 && !CVarGetInteger("gPauseTriforce", 0)) { + } else if (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_MASTER && !CVarGetInteger("gPauseTriforce", 0)) { pos.x = 25.0f; pos.y = -228.0f; pos.z = 60.0f; @@ -153,8 +153,10 @@ void KaleidoScope_DrawPlayerWork(PlayState* play) { extern int fbTest; gsSPSetFB(play->state.gfxCtx->polyOpa.p++, fbTest); Player_DrawPause(play, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime, &pos, &link_kaleido_rot, scale, - CUR_EQUIP_VALUE(EQUIP_SWORD), CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1, CUR_EQUIP_VALUE(EQUIP_SHIELD), - CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1); + SWORD_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD)), + TUNIC_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC)), + SHIELD_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD)), + BOOTS_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS))); gsSPResetFB(play->state.gfxCtx->polyOpa.p++); } @@ -464,7 +466,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { if ((pauseCtx->cursorY[PAUSE_EQUIP] == 0) && (pauseCtx->cursorX[PAUSE_EQUIP] == 3)) { if (gSaveContext.bgsFlag != 0) { cursorItem = ITEM_HEART_PIECE_2; - } else if (gBitFlags[3] & gSaveContext.inventory.equipment) { + } else if (CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE)) { cursorItem = ITEM_SWORD_KNIFE; } } @@ -476,7 +478,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { osSyncPrintf("kscope->select_name[Display_Equipment] = %d\n", pauseCtx->cursorItem[PAUSE_EQUIP]); - if (!(CHECK_EQUIPMENT_AGE(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]))) { + if (!(CHECK_AGE_REQ_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]))) { pauseCtx->nameColorSet = 1; } @@ -511,7 +513,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { (pauseCtx->unk_1E4 == 0) && CHECK_BTN_ANY(input->press.button, buttonsToCheck) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { - if (CHECK_EQUIPMENT_AGE(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP])) { + if (CHECK_AGE_REQ_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP])) { if (CHECK_BTN_ALL(input->press.button, BTN_A)) { // Allow Link to remove his equipment from the equipment subscreen by toggling on/off @@ -523,28 +525,28 @@ void KaleidoScope_DrawEquipment(PlayState* play) { // 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 + && CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_BIGGORON && CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)){ // And we have the Master Sword + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_MASTER); // "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 + if (pauseCtx->cursorY[PAUSE_EQUIP] == 1 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD)) { + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_NONE); // 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) + if (pauseCtx->cursorY[PAUSE_EQUIP] == 2 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC)) { + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, EQUIP_VALUE_TUNIC_KOKIRI); // "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) + if (pauseCtx->cursorY[PAUSE_EQUIP] == 3 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS)) { + Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_KOKIRI); // "Unequip" it (by equipping Kokiri Boots) goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it } } @@ -568,7 +570,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; } if ((gSaveContext.equips.buttonItems[0] == ITEM_SWORD_BGS) && (gSaveContext.bgsFlag == 0) && - (gBitFlags[3] & gSaveContext.inventory.equipment)) { + CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE)) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; } } @@ -643,7 +645,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { for (k = 0, temp = rowStart + 1, bit = rowStart, j = point; k < 3; k++, bit++, j += 4, temp++) { if ((gBitFlags[bit] & gSaveContext.inventory.equipment) && (pauseCtx->cursorSpecialPos == 0)) { - if (CHECK_EQUIPMENT_AGE(i, k + 1)) { + if (CHECK_AGE_REQ_EQUIP(i, k + 1)) { if (temp == cursorSlot) { pauseCtx->equipVtx[j].v.ob[0] = pauseCtx->equipVtx[j + 2].v.ob[0] = pauseCtx->equipVtx[j].v.ob[0] - 2; @@ -702,7 +704,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { for (k = 0, bit = rowStart, point = 4; k < 3; k++, point += 4, temp++, bit++) { int itemId = ITEM_SWORD_KOKIRI + temp; - bool age_restricted = !CHECK_ITEM_AGE(itemId); + bool age_restricted = !CHECK_AGE_REQ_ITEM(itemId); if (age_restricted) { gDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255); gSPGrayscale(POLY_KAL_DISP++, true); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 2fe8fddb7..744606910 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -33,7 +33,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gDPPipeSync(POLY_KAL_DISP++); - if (!CHECK_SLOT_AGE(SLOT(item))) { + if (!CHECK_AGE_REQ_SLOT(SLOT(item))) { gDPSetPrimColor(POLY_KAL_DISP++, 0, 0, 100, 100, 100, pauseCtx->alpha); } else { gDPSetPrimColor(POLY_KAL_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); @@ -490,7 +490,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; - if (!CHECK_SLOT_AGE(cursorSlot)) { + if (!CHECK_AGE_REQ_SLOT(cursorSlot)) { pauseCtx->nameColorSet = 1; } @@ -540,8 +540,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { gSlotAgeReqs[SLOT_TRADE_CHILD] = gItemAgeReqs[ITEM_MASK_BUNNY] = ((((CVarGetInteger("gMMBunnyHood", BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA) && CVarGetInteger("gAdultBunnyHood", 0)) || CVarGetInteger("gTimelessEquipment", 0)) && INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY) - ? 9 - : 1; + ? AGE_REQ_NONE + : AGE_REQ_CHILD; } if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE) && cursorSlot == SLOT_TRADE_ADULT && CHECK_BTN_ALL(input->press.button, BTN_A)) { @@ -566,7 +566,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } if (CHECK_BTN_ANY(input->press.button, buttonsToCheck)) { - if (CHECK_SLOT_AGE(cursorSlot) && + if (CHECK_AGE_REQ_SLOT(cursorSlot) && (cursorItem != ITEM_SOLD_OUT) && (cursorItem != ITEM_NONE)) { KaleidoScope_SetupItemEquip(play, cursorItem, cursorSlot, pauseCtx->itemVtx[index].v.ob[0] * 10, @@ -618,7 +618,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { if (gSaveContext.inventory.items[i] != ITEM_NONE) { if ((pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && (pauseCtx->cursorSpecialPos == 0)) { - if (CHECK_SLOT_AGE(i)) { + if (CHECK_AGE_REQ_SLOT(i)) { if ((sEquipState == 2) && (i == 3)) { gDPSetPrimColor(POLY_KAL_DISP++, 0, 0, magicArrowEffectsR[pauseCtx->equipTargetItem - 0xBF], magicArrowEffectsG[pauseCtx->equipTargetItem - 0xBF], @@ -653,7 +653,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[j + 0], 4, 0); int itemId = gSaveContext.inventory.items[i]; - bool not_acquired = !CHECK_ITEM_AGE(itemId); + bool not_acquired = !CHECK_AGE_REQ_ITEM(itemId); if (not_acquired) { gDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255); gSPGrayscale(POLY_KAL_DISP++, true); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h index a3c97d9b2..6f4ed7ad2 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h @@ -8,9 +8,19 @@ extern u8 gAmmoItems[]; extern s16 D_8082AAEC[]; extern s16 D_8082AB2C[]; extern u8 gEquipAgeReqs[][4]; +extern u8 gSlotAgeReqs[]; +extern u8 gItemAgeReqs[]; extern u8 gAreaGsFlags[]; extern bool gSelectingMask; +#define AGE_REQ_ADULT LINK_AGE_ADULT +#define AGE_REQ_CHILD LINK_AGE_CHILD +#define AGE_REQ_NONE 9 + +#define CHECK_AGE_REQ_EQUIP(i, j) (CVarGetInteger("gTimelessEquipment", 0) || (gEquipAgeReqs[i][j] == AGE_REQ_NONE) || (gEquipAgeReqs[i][j] == ((void)0, gSaveContext.linkAge))) +#define CHECK_AGE_REQ_SLOT(slotIndex) (CVarGetInteger("gTimelessEquipment", 0) || (gSlotAgeReqs[slotIndex] == AGE_REQ_NONE) || gSlotAgeReqs[slotIndex] == ((void)0, gSaveContext.linkAge)) +#define CHECK_AGE_REQ_ITEM(itemIndex) (CVarGetInteger("gTimelessEquipment", 0) || (gItemAgeReqs[itemIndex] == AGE_REQ_NONE) || (gItemAgeReqs[itemIndex] == gSaveContext.linkAge)) + void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx); s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s32 point); void KaleidoScope_DrawDebugEditor(PlayState* play); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 642fec066..87c4a99f5 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -734,20 +734,147 @@ static u16 D_8082ABEC[] = { }; u8 gSlotAgeReqs[] = { - 1, 9, 9, 0, 0, 9, 1, 9, 9, 0, 0, 9, 1, 9, 1, 0, 0, 9, 9, 9, 9, 9, 0, 1, + AGE_REQ_CHILD, // SLOT_DEKU_STICK + AGE_REQ_NONE, // SLOT_DEKU_NUT + AGE_REQ_NONE, // SLOT_BOMB + AGE_REQ_ADULT, // SLOT_BOW + AGE_REQ_ADULT, // SLOT_ARROW_FIRE + AGE_REQ_NONE, // SLOT_DINS_FIRE + AGE_REQ_CHILD, // SLOT_SLINGSHOT + AGE_REQ_NONE, // SLOT_OCARINA + AGE_REQ_NONE, // SLOT_BOMBCHU + AGE_REQ_ADULT, // SLOT_HOOKSHOT + AGE_REQ_ADULT, // SLOT_ARROW_ICE + AGE_REQ_NONE, // SLOT_FARORES_WIND + AGE_REQ_CHILD, // SLOT_BOOMERANG + AGE_REQ_NONE, // SLOT_LENS_OF_TRUTH + AGE_REQ_CHILD, // SLOT_MAGIC_BEAN + AGE_REQ_ADULT, // SLOT_HAMMER + AGE_REQ_ADULT, // SLOT_ARROW_LIGHT + AGE_REQ_NONE, // SLOT_NAYRUS_LOVE + AGE_REQ_NONE, // SLOT_BOTTLE_1 + AGE_REQ_NONE, // SLOT_BOTTLE_2 + AGE_REQ_NONE, // SLOT_BOTTLE_3 + AGE_REQ_NONE, // SLOT_BOTTLE_4 + AGE_REQ_ADULT, // SLOT_TRADE_ADULT + AGE_REQ_CHILD, // SLOT_TRADE_CHILD }; u8 gEquipAgeReqs[][4] = { - { 0, 1, 0, 0 }, - { 9, 1, 9, 0 }, - { 0, 9, 0, 0 }, - { 9, 9, 0, 0 }, + { + AGE_REQ_ADULT, // 0 UPG_QUIVER + AGE_REQ_CHILD, // EQUIP_TYPE_SWORD EQUIP_VALUE_SWORD_KOKIRI + AGE_REQ_ADULT, // EQUIP_TYPE_SWORD EQUIP_VALUE_SWORD_MASTER + AGE_REQ_ADULT // EQUIP_TYPE_SWORD EQUIP_VALUE_SWORD_BIGGORON + }, + { + AGE_REQ_NONE, // 0 UPG_BOMB_BAG + AGE_REQ_CHILD, // EQUIP_TYPE_SHIELD EQUIP_VALUE_SHIELD_DEKU + AGE_REQ_NONE, // EQUIP_TYPE_SHIELD EQUIP_VALUE_SHIELD_HYLIAN + AGE_REQ_ADULT // EQUIP_TYPE_SHIELD EQUIP_VALUE_SHIELD_MIRROR + }, + { + AGE_REQ_ADULT, // 0 UPG_STRENGTH + AGE_REQ_NONE, // EQUIP_TYPE_TUNIC EQUIP_VALUE_TUNIC_KOKIRI + AGE_REQ_ADULT, // EQUIP_TYPE_TUNIC EQUIP_VALUE_TUNIC_GORON + AGE_REQ_ADULT // EQUIP_TYPE_TUNIC EQUIP_VALUE_TUNIC_ZORA + }, + { + AGE_REQ_NONE, // 0 UPG_SCALE + AGE_REQ_NONE, // EQUIP_TYPE_BOOTS EQUIP_VALUE_BOOTS_KOKIRI + AGE_REQ_ADULT, // EQUIP_TYPE_BOOTS EQUIP_VALUE_BOOTS_IRON + AGE_REQ_ADULT // EQUIP_TYPE_BOOTS EQUIP_VALUE_BOOTS_HOVER + }, + }; u8 gItemAgeReqs[] = { - 1, 9, 9, 0, 0, 9, 1, 9, 9, 9, 0, 0, 0, 9, 1, 9, 1, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 1, 9, 0, 9, 0, 0, 9, 0, 0, 1, 1, 1, 0, 0, 0, 9, 9, 9, 1, 0, 0, 9, 9, 0, + AGE_REQ_CHILD, // ITEM_DEKU_STICK + AGE_REQ_NONE, // ITEM_DEKU_NUT + AGE_REQ_NONE, // ITEM_BOMB + AGE_REQ_ADULT, // ITEM_BOW + AGE_REQ_ADULT, // ITEM_ARROW_FIRE + AGE_REQ_NONE, // ITEM_DINS_FIRE + AGE_REQ_CHILD, // ITEM_SLINGSHOT + AGE_REQ_NONE, // ITEM_OCARINA_FAIRY + AGE_REQ_NONE, // ITEM_OCARINA_OF_TIME + AGE_REQ_NONE, // ITEM_BOMBCHU + AGE_REQ_ADULT, // ITEM_HOOKSHOT + AGE_REQ_ADULT, // ITEM_LONGSHOT + AGE_REQ_ADULT, // ITEM_ARROW_ICE + AGE_REQ_NONE, // ITEM_FARORES_WIND + AGE_REQ_CHILD, // ITEM_BOOMERANG + AGE_REQ_NONE, // ITEM_LENS_OF_TRUTH + AGE_REQ_CHILD, // ITEM_MAGIC_BEAN + AGE_REQ_ADULT, // ITEM_HAMMER + AGE_REQ_ADULT, // ITEM_ARROW_LIGHT + AGE_REQ_NONE, // ITEM_NAYRUS_LOVE + AGE_REQ_NONE, // ITEM_BOTTLE_EMPTY + AGE_REQ_NONE, // ITEM_BOTTLE_POTION_RED + AGE_REQ_NONE, // ITEM_BOTTLE_POTION_GREEN + AGE_REQ_NONE, // ITEM_BOTTLE_POTION_BLUE + AGE_REQ_NONE, // ITEM_BOTTLE_FAIRY + AGE_REQ_NONE, // ITEM_BOTTLE_FISH + AGE_REQ_NONE, // ITEM_BOTTLE_MILK_FULL + AGE_REQ_NONE, // ITEM_BOTTLE_RUTOS_LETTER + AGE_REQ_NONE, // ITEM_BOTTLE_BLUE_FIRE + AGE_REQ_NONE, // ITEM_BOTTLE_BUG + AGE_REQ_NONE, // ITEM_BOTTLE_BIG_POE + AGE_REQ_NONE, // ITEM_BOTTLE_MILK_HALF + AGE_REQ_NONE, // ITEM_BOTTLE_POE + AGE_REQ_CHILD, // ITEM_WEIRD_EGG + AGE_REQ_CHILD, // ITEM_CHICKEN + AGE_REQ_CHILD, // ITEM_ZELDAS_LETTER + AGE_REQ_CHILD, // ITEM_MASK_KEATON + AGE_REQ_CHILD, // ITEM_MASK_SKULL + AGE_REQ_CHILD, // ITEM_MASK_SPOOKY + AGE_REQ_CHILD, // ITEM_MASK_BUNNY_HOOD + AGE_REQ_CHILD, // ITEM_MASK_GORON + AGE_REQ_CHILD, // ITEM_MASK_ZORA + AGE_REQ_CHILD, // ITEM_MASK_GERUDO + AGE_REQ_CHILD, // ITEM_MASK_TRUTH + AGE_REQ_CHILD, // ITEM_SOLD_OUT + AGE_REQ_ADULT, // ITEM_POCKET_EGG + AGE_REQ_ADULT, // ITEM_POCKET_CUCCO + AGE_REQ_ADULT, // ITEM_COJIRO + AGE_REQ_ADULT, // ITEM_ODD_MUSHROOM + AGE_REQ_ADULT, // ITEM_ODD_POTION + AGE_REQ_ADULT, // ITEM_POACHERS_SAW + AGE_REQ_ADULT, // ITEM_BROKEN_GORONS_SWORD + AGE_REQ_ADULT, // ITEM_PRESCRIPTION + AGE_REQ_ADULT, // ITEM_EYEBALL_FROG + AGE_REQ_ADULT, // ITEM_EYE_DROPS + AGE_REQ_ADULT, // ITEM_CLAIM_CHECK + AGE_REQ_ADULT, // ITEM_BOW_FIRE + AGE_REQ_ADULT, // ITEM_BOW_ICE + AGE_REQ_ADULT, // ITEM_BOW_LIGHT + AGE_REQ_CHILD, // ITEM_SWORD_KOKIRI + AGE_REQ_ADULT, // ITEM_SWORD_MASTER + AGE_REQ_ADULT, // ITEM_SWORD_BIGGORON + AGE_REQ_CHILD, // ITEM_SHIELD_DEKU + AGE_REQ_NONE, // ITEM_SHIELD_HYLIAN + AGE_REQ_ADULT, // ITEM_SHIELD_MIRROR + AGE_REQ_NONE, // ITEM_TUNIC_KOKIRI + AGE_REQ_ADULT, // ITEM_TUNIC_GORON + AGE_REQ_ADULT, // ITEM_TUNIC_ZORA + AGE_REQ_NONE, // ITEM_BOOTS_KOKIRI + AGE_REQ_ADULT, // ITEM_BOOTS_IRON + AGE_REQ_ADULT, // ITEM_BOOTS_HOVER + AGE_REQ_CHILD, // ITEM_BULLET_BAG_30 + AGE_REQ_CHILD, // ITEM_BULLET_BAG_40 + AGE_REQ_CHILD, // ITEM_BULLET_BAG_50 + AGE_REQ_ADULT, // ITEM_QUIVER_30 + AGE_REQ_ADULT, // ITEM_QUIVER_40 + AGE_REQ_ADULT, // ITEM_QUIVER_50 + AGE_REQ_NONE, // ITEM_BOMB_BAG_20 + AGE_REQ_NONE, // ITEM_BOMB_BAG_30 + AGE_REQ_NONE, // ITEM_BOMB_BAG_40 + AGE_REQ_CHILD, // ITEM_STRENGTH_GORONS_BRACELET + AGE_REQ_ADULT, // ITEM_STRENGTH_SILVER_GAUNTLETS + AGE_REQ_ADULT, // ITEM_STRENGTH_GOLD_GAUNTLETS + AGE_REQ_NONE, // ITEM_SCALE_SILVER + AGE_REQ_NONE, // ITEM_SCALE_GOLDEN + AGE_REQ_ADULT, // ITEM_GIANTS_KNIFE }; u8 gAreaGsFlags[] = { @@ -3424,7 +3551,7 @@ void KaleidoScope_Update(PlayState* play) pauseCtx->worldMapPoints[3] = 1; } - if (CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1)) { + if (CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, EQUIP_INV_BOOTS_IRON)) { pauseCtx->worldMapPoints[3] = 2; } @@ -3578,7 +3705,7 @@ void KaleidoScope_Update(PlayState* play) pauseCtx->worldMapPoints[11] = 2; } - if (CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1)) { + if (CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, EQUIP_INV_BOOTS_IRON)) { pauseCtx->worldMapPoints[11] = 1; } @@ -4167,8 +4294,8 @@ void KaleidoScope_Update(PlayState* play) gSaveContext.health = CVarGetInteger("gFullHealthSpawn", 0) ? gSaveContext.healthCapacity : 0x30; Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); gSaveContext.healthAccumulator = 0; - gSaveContext.magicState = 0; - gSaveContext.prevMagicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; + gSaveContext.prevMagicState = MAGIC_STATE_IDLE; osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("MAGIC_NOW=%d ", gSaveContext.magic); osSyncPrintf("Z_MAGIC_NOW_NOW=%d → ", gSaveContext.magicFillTarget); @@ -4251,6 +4378,9 @@ void KaleidoScope_Update(PlayState* play) gSaveContext.buttonStatus[buttonIndex] = sButtonStatusSave[buttonIndex]; } + // Used to clear swordless temp B after unpause so minigame/epona handling restarts + Interface_RandoRestoreSwordless(); + interfaceCtx->unk_1FA = interfaceCtx->unk_1FC = 0; osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("i=%d LAST_TIME_TYPE=%d\n", i, gSaveContext.unk_13EE); |
