From fc2f525052f2afa5b1dcbe949ce722cd1092008c Mon Sep 17 00:00:00 2001 From: ph Date: Sun, 14 Jun 2026 11:55:37 -0700 Subject: [PATCH] fix halfmilk RBA (#6670) --- .../Restorations/BottleAdventure.cpp | 16 ++++++++++++++++ .../vanilla-behavior/GIVanillaBehavior.h | 10 ++++++++++ soh/src/code/z_parameter.c | 7 +++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/soh/soh/Enhancements/Restorations/BottleAdventure.cpp b/soh/soh/Enhancements/Restorations/BottleAdventure.cpp index 22cc74e679..ef4a8d4e8a 100644 --- a/soh/soh/Enhancements/Restorations/BottleAdventure.cpp +++ b/soh/soh/Enhancements/Restorations/BottleAdventure.cpp @@ -452,6 +452,11 @@ void DoRBA(uint8_t itemToPutInBottle) { } } +bool DoHalfMilkRBA(uint8_t item) { + auto itemOnCRight = gSaveContext.equips.buttonItems[3]; + return (item == ITEM_BOTTLE) && (gSaveContext.inventory.items[itemOnCRight] == ITEM_MILK_BOTTLE); +} + void RegisterBottleAdventure() { REGISTER_VB_SHOULD(VB_SET_BUTTON_ITEM_FROM_C_BUTTON_SLOT, { // if we aren't dealing with the b button, early return @@ -476,6 +481,17 @@ void RegisterBottleAdventure() { auto itemToPutInBottle = static_cast(va_arg(args, int32_t)); DoRBA(itemToPutInBottle); }); + + REGISTER_VB_SHOULD(VB_EMPTY_BOTTLE_TO_HALF_MILK, { + // if we aren't dealing with a bottle on b, early return + auto buttonBottleIsOn = static_cast(va_arg(args, int32_t)); + if (buttonBottleIsOn != 0) { + return; + } + + auto item = static_cast(va_arg(args, int32_t)); + *should = DoHalfMilkRBA(item); + }); } static RegisterShipInitFunc initFunc(RegisterBottleAdventure); diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index 1b64f2b4d7..c252a62599 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -620,6 +620,16 @@ typedef enum { // - Player* VB_EMPTYING_BOTTLE, + // #### `result` + // ```c + // (gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] == ITEM_MILK_BOTTLE) && + // (item == ITEM_BOTTLE) + // ``` + // #### `args` + // - `int32_t` (button - promoted from `u8`) + // - `int32_t` (item - promoted from `u8`) + VB_EMPTY_BOTTLE_TO_HALF_MILK, + // #### `result` // ```c // (Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play) diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index e96929a109..c378d15f48 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -2671,8 +2671,11 @@ void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 button) { gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]]); // Special case to only empty half of a Lon Lon Milk Bottle - if ((gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] == ITEM_MILK_BOTTLE) && - (item == ITEM_BOTTLE)) { + if (GameInteractor_Should( + VB_EMPTY_BOTTLE_TO_HALF_MILK, + (gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] == ITEM_MILK_BOTTLE) && + (item == ITEM_BOTTLE), + button, item)) { item = ITEM_MILK_HALF; }