From 0393fdad6d66d110af8e570ba38e0639e57f2269 Mon Sep 17 00:00:00 2001 From: gymnast86 Date: Sat, 2 May 2026 06:08:09 -0700 Subject: [PATCH] fishing hole bottle check --- src/d/actor/d_a_mg_rod.cpp | 17 ++++++++++++++++- src/d/d_msg_flow.cpp | 11 +++++++++++ src/dusk/randomizer/game/randomizer_context.hpp | 3 +++ src/dusk/randomizer/game/tools.cpp | 10 ++++++++++ src/dusk/randomizer/game/tools.h | 1 + .../randomizer/generator/data/locations.yaml | 5 ++--- 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/d/actor/d_a_mg_rod.cpp b/src/d/actor/d_a_mg_rod.cpp index 956a9e3cff..b0a72903b8 100644 --- a/src/d/actor/d_a_mg_rod.cpp +++ b/src/d/actor/d_a_mg_rod.cpp @@ -25,7 +25,10 @@ #include #include +#if TARGET_PC +#include "dusk/randomizer/game/verify_item_functions.h" #include "dusk/version.hpp" +#endif class dmg_rod_HIO_c : public JORReflexible { public: @@ -4031,6 +4034,17 @@ static void uki_catch(dmg_rod_class* i_this) { } else if (mgfish->mCaughtType == MG_CATCH_BIN) { i_this->msgflow.init(actor, 0x139A, 0, NULL); dComIfGs_onEventBit(dSv_event_flag_c::saveBitLabels[468]); +#if TARGET_PC + if (randomizer_IsActive()) { + // In rando, give the player the fishing bottle randomized item. Then save + // the itemId for later since the textbox happens after we've already given the player + // the item. If we didn't save it and the item is progressive, then we get the wrong + // text for the item. + u8 itemId = verifyProgressiveItem(randomizer_getItemAtLocation("Fishing Hole Bottle")); + g_randomizerState.mFishingBottleItemId = itemId; + execItemGet(itemId); + } else +#endif dComIfGs_setEmptyBottle(); } else if (mgfish->mCaughtType == MG_CATCH_KN) { i_this->msgflow.init(actor, 0x139C, 0, NULL); @@ -4297,7 +4311,8 @@ static void uki_main(dmg_rod_class* i_this) { } if (!dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[468])) { - if (cM_rndF(1.0f) <= 0.5f) { + // Always succeed the rng check in rando for fishing bottle + if (cM_rndF(1.0f) <= 0.5f IF_DUSK(|| randomizer_IsActive())) { cXyz bin_pos(6800.0f, 30.0f, -270.0f); bin_pos -= player->current.pos; diff --git a/src/d/d_msg_flow.cpp b/src/d/d_msg_flow.cpp index 92d12ac3bf..35ac92acc0 100644 --- a/src/d/d_msg_flow.cpp +++ b/src/d/d_msg_flow.cpp @@ -511,6 +511,17 @@ int dMsgFlow_c::setNormalMsg(mesg_flow_node* i_flowNode_p, fopAc_ac_c* i_speaker inf_p = (BE(u16)*)getMsgDataBlock("INF1"); msg_no = (inf_p + (var_r29->msg_index) * 10)[10]; +#if TARGET_PC + if (randomizer_IsActive()) { + // If this is the fishing hole bottle message, override it + // with the item message for the randomized item + if (msg_no == 0x71E && g_randomizerState.mFishingBottleItemId != 0) { + msg_no = getItemMessageID(g_randomizerState.mFishingBottleItemId); + g_randomizerState.mFishingBottleItemId = 0; + } + } +#endif + // "Message Set" OS_REPORT("\x1B[44;37mメッセ−ジセット          \x1B[m|:"); diff --git a/src/dusk/randomizer/game/randomizer_context.hpp b/src/dusk/randomizer/game/randomizer_context.hpp index 72b9bb98ff..5989b9629b 100644 --- a/src/dusk/randomizer/game/randomizer_context.hpp +++ b/src/dusk/randomizer/game/randomizer_context.hpp @@ -100,6 +100,9 @@ public: u8 mTimeChange{}; u8 mEventItemQueue[EVENT_ITEM_QUEUE_SIZE]; bool mRoomReloadingState{false}; + + // TODO: Probably a better way to handle this + u8 mFishingBottleItemId{}; }; extern RandomizerState g_randomizerState; diff --git a/src/dusk/randomizer/game/tools.cpp b/src/dusk/randomizer/game/tools.cpp index 403e8e2b53..8f1769fd4f 100644 --- a/src/dusk/randomizer/game/tools.cpp +++ b/src/dusk/randomizer/game/tools.cpp @@ -114,4 +114,14 @@ bool playerIsOnTitleScreen() { // Player is either on title screen movie stage (S_MV000) or on title screen map layer 10 return strcmp(dComIfGp_getStartStageName(), "S_MV000") == 0 || (strcmp(dComIfGp_getStartStageName(), "F_SP102") == 0 && dComIfG_play_c::getLayerNo(0) == 10); +} + +u16 getItemMessageID(u8 itemId) { + // If heart piece, choose from the different heart piece messages + if (itemId == dItemNo_Randomizer_KAKERA_HEART_e) { + static u32 const heartPieceMessage[5] = {0x86, 0x9C, 0x9D, 0x9E, 0x9F}; + return heartPieceMessage[dComIfGs_getMaxLife() % 5]; + } + + return itemId + 0x65; } \ No newline at end of file diff --git a/src/dusk/randomizer/game/tools.h b/src/dusk/randomizer/game/tools.h index fc43ba88c3..5826a5f7bf 100644 --- a/src/dusk/randomizer/game/tools.h +++ b/src/dusk/randomizer/game/tools.h @@ -13,3 +13,4 @@ int initCreatePlayerItem(u32 item, u32 flag, const cXyz* pos, int roomNo, const */ int getStageID(const char* stage = NULL); bool playerIsOnTitleScreen(); +u16 getItemMessageID(u8 itemId); diff --git a/src/dusk/randomizer/generator/data/locations.yaml b/src/dusk/randomizer/generator/data/locations.yaml index e3672726c3..b2ddec6124 100644 --- a/src/dusk/randomizer/generator/data/locations.yaml +++ b/src/dusk/randomizer/generator/data/locations.yaml @@ -3478,7 +3478,6 @@ - Location Name Lookup Metadata: Iza Raging Rapids Minigame -# TODO - Name: Fishing Hole Bottle Original Item: Empty Bottle Categories: @@ -3486,8 +3485,8 @@ - Fishing Hole - ARC - REL - Metadata: - - None + - Location Name Lookup + Metadata: Fishing Hole Bottle - Name: Fishing Hole Heart Piece Original Item: Piece of Heart