diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index 66b5f728ba..25b7074a32 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -3239,6 +3239,13 @@ typedef enum { // #### `result` // ```c + // false if Link is adult, water level is lowered, and entering Lake from Domain + // ``` + // #### `args` + // - `Player*` + VB_LAKE_HYLIA_PREVENT_DOMAIN_SWIM, + + // #### `result` // true if Goron Link is talking // ``` // #### `args` diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 85deb7d66c..65c29c184e 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -1851,6 +1851,17 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_l *should = false; break; } + case VB_LAKE_HYLIA_PREVENT_DOMAIN_SWIM: { + // Don't swim as adult coming from Domain to Lake with low water. + // Caused by waterbox first frame y surface always being -1313.0f + Player* player = va_arg(args, Player*); + if (gPlayState->sceneNum == SCENE_LAKE_HYLIA && LINK_IS_ADULT && + !Flags_GetEventChkInf(EVENTCHKINF_RAISED_LAKE_HYLIA_WATER) && player->actor.world.pos.y > -1550.0f && + player->actor.world.pos.y < -1500.0f) { + *should = false; + } + break; + } case VB_BE_ELIGIBLE_FOR_RAINBOW_BRIDGE: { *should = MeetsRainbowBridgeRequirements(); break; diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index c37d4b61df..3bde2e1eb1 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -3335,6 +3335,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos } if (actorCtx->total > ACTOR_NUMBER_MAX) { + LUSLOG_WARN("Actor_Spawn: Actor number max exceeded"); // "Actor set number exceeded" osSyncPrintf(VT_COL(YELLOW, BLACK) "Actorセット数オーバー\n" VT_RST); return NULL; @@ -3358,6 +3359,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos actor = ZELDA_ARENA_MALLOC_DEBUG(dbEntry->instanceSize); if (actor == NULL) { + LUSLOG_WARN("Actor_Spawn: Cannot allocate actor %s (0x%x)", dbEntry->name, actorId); // "Actor class cannot be reserved! %s " osSyncPrintf(VT_COL(RED, WHITE) "Actorクラス確保できません! %s <サイズ=%dバイト>\n", VT_RST, dbEntry->name, dbEntry->instanceSize); @@ -4930,7 +4932,7 @@ s32 Flags_GetEventChkInf(s32 flag) { * Sets "eventChkInf" flag. */ void Flags_SetEventChkInf(s32 flag) { - u8 previouslyOff = !Flags_GetEventChkInf(flag); + s32 previouslyOff = !Flags_GetEventChkInf(flag); gSaveContext.eventChkInf[flag >> 4] |= (1 << (flag & 0xF)); if (previouslyOff) { LUSLOG_INFO("EventChkInf Flag Set - %#x", flag); @@ -4942,7 +4944,7 @@ void Flags_SetEventChkInf(s32 flag) { * Unsets "eventChkInf" flag. */ void Flags_UnsetEventChkInf(s32 flag) { - u8 previouslyOn = Flags_GetEventChkInf(flag); + s32 previouslyOn = Flags_GetEventChkInf(flag); gSaveContext.eventChkInf[flag >> 4] &= ~(1 << (flag & 0xF)); if (previouslyOn) { LUSLOG_INFO("EventChkInf Flag Unset - %#x", flag); @@ -4961,7 +4963,7 @@ s32 Flags_GetItemGetInf(s32 flag) { * Sets "itemGetInf" flag. */ void Flags_SetItemGetInf(s32 flag) { - u8 previouslyOff = !Flags_GetItemGetInf(flag); + s32 previouslyOff = !Flags_GetItemGetInf(flag); gSaveContext.itemGetInf[flag >> 4] |= (1 << (flag & 0xF)); if (previouslyOff) { LUSLOG_INFO("ItemGetInf Flag Set - %#x", flag); @@ -4973,7 +4975,7 @@ void Flags_SetItemGetInf(s32 flag) { * Unsets "itemGetInf" flag. */ void Flags_UnsetItemGetInf(s32 flag) { - u8 previouslyOn = Flags_GetItemGetInf(flag); + s32 previouslyOn = Flags_GetItemGetInf(flag); gSaveContext.itemGetInf[flag >> 4] &= ~(1 << (flag & 0xF)); if (previouslyOn) { LUSLOG_INFO("ItemGetInf Flag Unset - %#x", flag); @@ -4992,7 +4994,7 @@ s32 Flags_GetInfTable(s32 flag) { * Sets "infTable" flag. */ void Flags_SetInfTable(s32 flag) { - u8 previouslyOff = !Flags_GetInfTable(flag); + s32 previouslyOff = !Flags_GetInfTable(flag); gSaveContext.infTable[flag >> 4] |= (1 << (flag & 0xF)); if (previouslyOff) { LUSLOG_INFO("InfTable Flag Set - %#x", flag); @@ -5004,7 +5006,7 @@ void Flags_SetInfTable(s32 flag) { * Unsets "infTable" flag. */ void Flags_UnsetInfTable(s32 flag) { - u8 previouslyOn = Flags_GetInfTable(flag); + s32 previouslyOn = Flags_GetInfTable(flag); gSaveContext.infTable[flag >> 4] &= ~(1 << (flag & 0xF)); if (previouslyOn) { LUSLOG_INFO("InfTable Flag Unset - %#x", flag); @@ -5023,7 +5025,7 @@ s32 Flags_GetEventInf(s32 flag) { * Sets "eventInf" flag. */ void Flags_SetEventInf(s32 flag) { - u8 previouslyOff = !Flags_GetEventInf(flag); + s32 previouslyOff = !Flags_GetEventInf(flag); gSaveContext.eventInf[flag >> 4] |= (1 << (flag & 0xF)); if (previouslyOff) { LUSLOG_INFO("EventInf Flag Set - %#x", flag); @@ -5035,7 +5037,7 @@ void Flags_SetEventInf(s32 flag) { * Unsets "eventInf" flag. */ void Flags_UnsetEventInf(s32 flag) { - u8 previouslyOn = Flags_GetEventInf(flag); + s32 previouslyOn = Flags_GetEventInf(flag); gSaveContext.eventInf[flag >> 4] &= ~(1 << (flag & 0xF)); if (previouslyOn) { LUSLOG_INFO("EventInf Flag Unset - %#x", flag); 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 394760402b..85997712a2 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -6629,32 +6629,36 @@ void func_8083C8DC(Player* this, PlayState* play, s16 arg2) { func_8083C858(this, play); } -s32 func_8083C910(PlayState* play, Player* this, f32 arg2) { - WaterBox* sp2C; - f32 sp28; +/** + * @return false if player starting movement is swimming, otherwise true + */ +s32 Player_SetStartingMovement(PlayState* play, Player* this, f32 arg2) { + WaterBox* waterbox; + f32 ySurface; - sp28 = this->actor.world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp28, &sp2C) != - 0) { - sp28 -= this->actor.world.pos.y; - if (this->ageProperties->unk_24 <= sp28) { + ySurface = this->actor.world.pos.y; + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, + &waterbox) && + GameInteractor_Should(VB_LAKE_HYLIA_PREVENT_DOMAIN_SWIM, true, this)) { + ySurface -= this->actor.world.pos.y; + if (this->ageProperties->unk_24 <= ySurface) { Player_SetupAction(play, this, Player_Action_8084D7C4, 0); Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); this->stateFlags1 |= PLAYER_STATE1_IN_WATER | PLAYER_STATE1_IN_CUTSCENE; this->av2.actionVar2 = 20; this->linearVelocity = 2.0f; Player_SetBootData(play, this); - return 0; + return false; } } func_80838E70(play, this, arg2, this->actor.shape.rot.y); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; - return 1; + return true; } void Player_StartMode_Idle(PlayState* play, Player* this) { - if (func_8083C910(play, this, 180.0f)) { + if (Player_SetStartingMovement(play, this, 180.0f)) { this->av2.actionVar2 = -20; } } @@ -6662,7 +6666,7 @@ void Player_StartMode_Idle(PlayState* play, Player* this) { void Player_StartMode_MoveForwardSlow(PlayState* play, Player* this) { this->linearVelocity = 2.0f; gSaveContext.entranceSpeed = 2.0f; - if (func_8083C910(play, this, 120.0f)) { + if (Player_SetStartingMovement(play, this, 120.0f)) { this->av2.actionVar2 = -15; } } @@ -6674,7 +6678,7 @@ void Player_StartMode_MoveForward(PlayState* play, Player* this) { this->linearVelocity = gSaveContext.entranceSpeed; - if (func_8083C910(play, this, 800.0f)) { + if (Player_SetStartingMovement(play, this, 800.0f)) { this->av2.actionVar2 = -80 / this->linearVelocity; if (this->av2.actionVar2 < -20) { this->av2.actionVar2 = -20;