From d5f395493b9aa80cd872b0d5bf4080929a62be6e Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 26 May 2025 10:49:44 +0200 Subject: [PATCH] Show item name and player in ap item pickup notification --- .../GameInteractor_HookTable.h | 2 +- .../game-interactor/GameInteractor_Hooks.cpp | 4 ++-- .../game-interactor/GameInteractor_Hooks.h | 2 +- .../Enhancements/randomizer/hook_handlers.cpp | 22 +++++++++++++------ soh/soh/Network/Archipelago/Archipelago.cpp | 13 ++++++++++- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index 6066c906c..a318deeea 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -70,5 +70,5 @@ DEFINE_HOOK(OnFileDropped, (std::string filePath)); DEFINE_HOOK(OnAssetAltChange, ()); DEFINE_HOOK(OnKaleidoUpdate, ()); -DEFINE_HOOK(OnRandomizerItemGivenHooks, (uint32_t rc)); +DEFINE_HOOK(OnRandomizerItemGivenHooks, (uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped)); DEFINE_HOOK(OnArchipelagoItemRecieved, (uint32_t rc)); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index c1bc5e17d..f34e00421 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -304,8 +304,8 @@ void GameInteractor_ExecuteOnKaleidoUpdate() { // Mark: Randomizer -void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc) { - GameInteractor::Instance->ExecuteHooks(rc); +void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped) { + GameInteractor::Instance->ExecuteHooks(rc, gi, isGiSkipped); } // MARK: Archipelago diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index 8a1f13608..bb55cb6d8 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -82,7 +82,7 @@ void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void)); void GameInteractor_ExecuteOnKaleidoUpdate(); // Mark: - Randomizer -void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc); +void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped); // Mark: - Archipelago void GameInteractor_ExecuteOnArchipelagoItemRecieved(uint32_t rc); diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 3c8e23b2c..e678e0dae 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -307,6 +307,7 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() { GetItemEntry getItemEntry; RandomizerCheck rc = randomizerQueuedChecks.front(); auto loc = Rando::Context::GetInstance()->GetItemLocation(rc); + uint8_t isGiSkipped = 0; if (rc == RC_ARCHIPELAGO_RECIEVED_ITEM) { getItemEntry = Rando::Context::GetInstance()->GetArchipelagoGIEntry(); @@ -324,6 +325,7 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() { randomizerQueuedItemEntry = getItemEntry; SPDLOG_INFO("Queueing Item mod {} item {} from RC {}", getItemEntry.modIndex, getItemEntry.itemId, static_cast(rc)); + if ( // Skipping ItemGet animation incompatible with checks that require closing a text box to finish rc != RC_HF_OCARINA_OF_TIME_ITEM && rc != RC_SPIRIT_TEMPLE_SILVER_GAUNTLETS_CHEST && @@ -342,10 +344,12 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() { getItemEntry.getItemCategory == ITEM_CATEGORY_SKULLTULA_TOKEN || getItemEntry.getItemCategory == ITEM_CATEGORY_LESSER))))) { Item_DropCollectible(gPlayState, &spawnPos, ITEM00_SOH_GIVE_ITEM_ENTRY | 0x8000); + + isGiSkipped = 1; } } - GameInteractor_ExecuteOnRandomizerItemGivenHooks((uint32_t)rc); + GameInteractor_ExecuteOnRandomizerItemGivenHooks((uint32_t)rc, getItemEntry, isGiSkipped); randomizerQueuedChecks.pop(); } @@ -1048,12 +1052,16 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_l .suffix = SohUtils::GetItemName(item00->itemEntry.itemId), }); } else if (item00->itemEntry.modIndex == MOD_RANDOMIZER) { - Notification::Emit({ - .message = "You found ", - .suffix = Rando::StaticData::RetrieveItem((RandomizerGet)item00->itemEntry.getItemId) - .GetName() - .english, - }); + if (!(item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_PROGRESSIVE || + item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_USEFUL || + item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_JUNK)) { + Notification::Emit({ + .message = "You found ", + .suffix = Rando::StaticData::RetrieveItem((RandomizerGet)item00->itemEntry.getItemId) + .GetName() + .english, + }); + } } // This is typically called when you close the text box after getting an item, in case a previous diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index a52d2cb51..3c46d90c0 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -14,6 +14,7 @@ #include "soh/Enhancements/randomizer/context.h" #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" +#include "soh/Notification/Notification.h" #include "soh/ShipInit.hpp" #include "soh/SaveManager.h" @@ -352,11 +353,21 @@ void InitArchipelagoData(bool isDebug) { void RegisterArchipelago() { COND_HOOK(GameInteractor::OnRandomizerItemGivenHooks, IS_ARCHIPELAGO, - [](uint32_t rc) { + [](uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped) { if (rc == RC_ARCHIPELAGO_RECIEVED_ITEM) { gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex++; } else { ArchipelagoClient::GetInstance().CheckLocation((RandomizerCheck)rc); + + if (isGiSkipped && gi.modIndex == MOD_RANDOMIZER && + (gi.getItemId == RG_ARCHIPELAGO_ITEM_PROGRESSIVE || gi.getItemId == RG_ARCHIPELAGO_ITEM_USEFUL || + gi.getItemId == RG_ARCHIPELAGO_ITEM_JUNK)) { + Notification::Emit({ + .prefix = std::string(gSaveContext.ship.quest.data.archipelago.locations[rc].itemName), + .message = " for ", + .suffix = std::string(gSaveContext.ship.quest.data.archipelago.locations[rc].playerName) + }); + } } }); }