From a96adc4a9af6fe63f9468303708045a42d5992ae Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Fri, 18 Apr 2025 02:53:48 +0000 Subject: [PATCH] check for freestanding item directly below player while swimming don't detect sun actor --- soh/soh/Enhancements/tts/tts.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index 856bef90a..0162c4430 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -200,16 +200,28 @@ void RegisterOnInterfaceUpdateHook() { Actor* readOut = NULL; Player* player = GET_PLAYER(gPlayState); if (player != NULL) { - for (int i = 0; i < ACTORCAT_MAX; i++) { - if (i == ACTORCAT_PLAYER) - continue; - for (Actor* actor = gPlayState->actorCtx.actorLists[i].head; actor != NULL; actor = actor->next) { - if (actor->id == ACTOR_EN_ELF && actor->params == FAIRY_NAVI) + if (player->focusActor != NULL) { + readOut = player->focusActor; + } else { + for (int i = 0; i < ACTORCAT_MAX; i++) { + if (i == ACTORCAT_PLAYER) continue; - u16 reverseYaw = (actor->yawTowardsPlayer + 0x8000) - player->actor.world.rot.y; - if ((reverseYaw < 0x2000 || reverseYaw > 0xE000) && actor->xyzDistToPlayerSq < minDist) { - readOut = actor; - minDist = actor->xyzDistToPlayerSq; + for (Actor* actor = gPlayState->actorCtx.actorLists[i].head; actor != NULL; + actor = actor->next) { + if ((actor->id == ACTOR_EN_ELF && actor->params == FAIRY_NAVI) || + actor->id == ACTOR_SHOT_SUN) + continue; + if (actor->id == ACTOR_EN_ITEM00 && (player->stateFlags1 & PLAYER_STATE1_IN_WATER) && + player->currentBoots != PLAYER_BOOTS_IRON && actor->xzDistToPlayer < 40 && + actor->world.pos.z < player->actor.world.pos.z) { + SpeechSynthesizer::Instance->Speak("item below", "en-US"); + goto spoke; + } + u16 reverseYaw = (actor->yawTowardsPlayer + 0x8000) - player->actor.world.rot.y; + if ((reverseYaw < 0x2000 || reverseYaw > 0xE000) && actor->xyzDistToPlayerSq < minDist) { + readOut = actor; + minDist = actor->xyzDistToPlayerSq; + } } } } @@ -225,6 +237,7 @@ void RegisterOnInterfaceUpdateHook() { } } } + spoke: static int16_t lostHealth = 0; static int16_t prevHealth = 0;