change direction from degrees to 8-way cardinal names

This commit is contained in:
Demur Rumed 2025-04-17 01:19:09 +00:00
commit 2a3714cd9b

View file

@ -180,10 +180,16 @@ void RegisterOnInterfaceUpdateHook() {
if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_CUSTOM_MODIFIER1)) { if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_CUSTOM_MODIFIER1)) {
Player* player = GET_PLAYER(gPlayState); Player* player = GET_PLAYER(gPlayState);
if (player != NULL) { if (player != NULL) {
char ttsAnnounceBuf[16]; u16 angle = (u16)player->actor.world.rot.y;
int angle = (int)(player->actor.world.rot.y / (65536 / 360.0)); const char* ttsAnnounce = (angle > 0xf000 || angle < 0x1000) ? "south"
int annouceBuf = snprintf(ttsAnnounceBuf, sizeof(ttsAnnounceBuf), "facing %d", angle); : angle < 0x3000 ? "southeast"
SpeechSynthesizer::Instance->Speak(ttsAnnounceBuf, "en-US"); : angle < 0x5000 ? "east"
: angle < 0x7000 ? "northeast"
: angle < 0x9000 ? "north"
: angle < 0xB000 ? "northwest"
: angle < 0xD000 ? "west"
: "southwest";
SpeechSynthesizer::Instance->Speak(ttsAnnounce, "en-US");
} }
} }