From 5a22ce632107ef4fdc8de8fdf98e552661c7d27b Mon Sep 17 00:00:00 2001 From: gymnast86 Date: Fri, 1 May 2026 05:23:43 -0700 Subject: [PATCH] charlo donation check --- src/d/actor/d_a_npc_prayer.cpp | 9 ++++++++ src/d/d_event_manager.cpp | 9 ++++++++ src/d/d_msg_flow.cpp | 9 ++++++++ .../randomizer/game/randomizer_context.cpp | 11 ++++++++++ .../generator/data/flow_patches.yaml | 21 ++++++++++++++++++- .../randomizer/generator/data/locations.yaml | 5 ++--- 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/d/actor/d_a_npc_prayer.cpp b/src/d/actor/d_a_npc_prayer.cpp index 7233ccc683..bb7ced4d69 100644 --- a/src/d/actor/d_a_npc_prayer.cpp +++ b/src/d/actor/d_a_npc_prayer.cpp @@ -7,6 +7,9 @@ #include "d/actor/d_a_npc_prayer.h" #include "d/d_com_inf_game.h" +#if TARGET_PC +#include "dusk/randomizer/game/verify_item_functions.h" +#endif static NPC_PRAY_HIO_CLASS l_HIO; @@ -720,6 +723,12 @@ fpc_ProcID daNpcPray_c::createHeart() { mDoMtx_stack_c::ZXYrotS(rot); mDoMtx_stack_c::multVec(&offset, &offset); pos += offset; +#if TARGET_PC + if (randomizer_IsActive()) { + u8 itemId = verifyProgressiveItem(randomizer_getItemAtLocation("Charlo Donation Blessing")); + return fopAcM_createItemForBoss(&pos, itemId, fopAcM_GetRoomNo(this), &rot, &size, 0.0f, 0.0f, 0); + } +#endif return fopAcM_createItemForBoss(&pos, dItemNo_KAKERA_HEART_e, fopAcM_GetRoomNo(this), &rot, &size, 0.0f, 0.0f, 0); } diff --git a/src/d/d_event_manager.cpp b/src/d/d_event_manager.cpp index 598b973b84..b016203602 100644 --- a/src/d/d_event_manager.cpp +++ b/src/d/d_event_manager.cpp @@ -14,6 +14,9 @@ #include "d/d_s_play.h" #include "SSystem/SComponent/c_counter.h" #include +#if TARGET_PC +#include "dusk/randomizer/game/verify_item_functions.h" +#endif #if DEBUG static dEvM_HIO_c l_HIO; @@ -333,6 +336,12 @@ bool dEvent_manager_c::setObjectArchive(char* arcname) { if (arcname != NULL) { rt = dComIfG_getObjectRes(arcname, DataFileName); +#if TARGET_PC + // Pretty hacky, but change the itemId for the event of charlo giving us the heart piece + if (randomizer_IsActive() && strcmp(arcname, "Prayer") == 0) { + static_cast(rt)[0x927] = verifyProgressiveItem(randomizer_getItemAtLocation("Charlo Donation Blessing")); + } +#endif int base_status = mEventList[BASE_ACTOR].init((char*)rt, -1); #if DEBUG diff --git a/src/d/d_msg_flow.cpp b/src/d/d_msg_flow.cpp index 324238ca37..92d12ac3bf 100644 --- a/src/d/d_msg_flow.cpp +++ b/src/d/d_msg_flow.cpp @@ -657,6 +657,15 @@ int dMsgFlow_c::branchNodeProc(fopAc_ac_c* i_speaker_p, fopAc_ac_c** i_talkPartn int dMsgFlow_c::eventNodeProc(fopAc_ac_c* i_speaker_p, fopAc_ac_c** i_talkPartners) { mesg_flow_node_event* node = NULL; node = &mFlowNodeTBL[mNodeIdx].event; +#if TARGET_PC + // Overwrite this node if we have a patch for it + if (randomizer_IsActive()) { + u32 key = (dMsgObject_getGroupID() << 16) | mNodeIdx; + if (randomizer_GetContext().mFlowPatches.contains(key)) { + node = reinterpret_cast(&randomizer_GetContext().mFlowPatches[key]); + } + } +#endif int proc_status = (this->*mEventList[node->event_idx])(node, i_speaker_p); switch (node->event_idx) { diff --git a/src/dusk/randomizer/game/randomizer_context.cpp b/src/dusk/randomizer/game/randomizer_context.cpp index e2241ad108..9506dd0f0d 100644 --- a/src/dusk/randomizer/game/randomizer_context.cpp +++ b/src/dusk/randomizer/game/randomizer_context.cpp @@ -867,6 +867,17 @@ void GenerateAndWriteSeed(std::string& generationStatusMsg) { branch->param = flowNode["parameters"].as(); branch->next_node_idx = flowNode["next node index"].as(); } + else if (type == "event") { + auto event = reinterpret_cast(&value); + event->type = 3; + event->event_idx = flowNode["event"].as(); + event->next_node_idx = flowNode["next node index"].as(); + u32 params = flowNode["parameters"].as(); + event->params[0] = (params >> 24) & 0xFF; + event->params[1] = (params >> 16) & 0xFF; + event->params[2] = (params >> 8) & 0xFF; + event->params[3] = params & 0xFF; + } u32 key = (groupNo << 16) | index; randoData.mFlowPatches[key] = value; diff --git a/src/dusk/randomizer/generator/data/flow_patches.yaml b/src/dusk/randomizer/generator/data/flow_patches.yaml index e3264eb806..4f4c66794b 100644 --- a/src/dusk/randomizer/generator/data/flow_patches.yaml +++ b/src/dusk/randomizer/generator/data/flow_patches.yaml @@ -15,7 +15,26 @@ next node index: 0x340 #3: # zel_03.bmg -#4: # zel_04.bmg +4: # zel_04.bmg - Castle Town + # Patch Charlo to check for 100 rupees instead of 30 + - index: 0x34A + type: branch + num results: 2 + query: 6 + parameters: 0x0064 + next node index: 0x222 + # Patch Charlo to take 100 rupees from Link instead of 30 + - index: 0x34E + type: event + event: 41 + parameters: 0x00000064 + next node index: 0x226 + # Patch Charlo to add 100 rupees to his counter instead of 30 + - index: 0x357 + type: event + event: 3 + parameters: 0x00000064 + next node index: 0x22B #5: # zel_05.bmg #6: # zel_06.bmg #7: # zel_07.bmg diff --git a/src/dusk/randomizer/generator/data/locations.yaml b/src/dusk/randomizer/generator/data/locations.yaml index 34f9d04f34..740a9744c2 100644 --- a/src/dusk/randomizer/generator/data/locations.yaml +++ b/src/dusk/randomizer/generator/data/locations.yaml @@ -2242,7 +2242,6 @@ - Flag: 0x49 Stage: 57 -# TODO - Name: Charlo Donation Blessing Original Item: Piece of Heart Categories: @@ -2251,8 +2250,8 @@ - Castle Town - ObjectARC - Boss - Metadata: - - None + - Location Name Lookup + Metadata: Charlo Donation Blessing # TODO - Name: STAR Prize 1