diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index f6db2e950..ce5a18b6e 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -141,6 +141,9 @@ typedef enum { // Opt: *EnItem00 // Vanilla condition: Flags_GetCollectible(play, this->collectibleFlag) VB_ITEM00_DESPAWN, + // Opt: *ItemBHeart + // Vanilla condition: Flags_GetCollectible(play, 0x1F) + VB_ITEM_B_HEART_DESPAWN, // Opt: *EnTk // Vanilla condition: gSaveContext.dayTime <= 0xC000 || gSaveContext.dayTime >= 0xE000 || LINK_IS_ADULT || play->sceneNum != SCENE_GRAVEYARD VB_DAMPE_IN_GRAVEYARD_DESPAWN, diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 35f9df9f6..552758443 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -689,6 +689,17 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void } break; } + case VB_ITEM_B_HEART_DESPAWN: { + ItemBHeart* itemBHeart = static_cast(optionalArg); + RandomizerCheck rc = OTRGlobals::Instance->gRandomizer->GetCheckFromActor(itemBHeart->actor.id, gPlayState->sceneNum, itemBHeart->actor.params); + if (rc != RC_UNKNOWN_CHECK) { + itemBHeart->sohItemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rc, true, (GetItemID)Rando::StaticData::GetLocation(rc)->GetVanillaItem()); + itemBHeart->actor.draw = (ActorFunc)ItemBHeart_DrawRandomizedItem; + itemBHeart->actor.update = (ActorFunc)ItemBHeart_UpdateRandomizedItem; + *should = Rando::Context::GetInstance()->GetItemLocation(rc)->HasObtained(); + } + break; + } case VB_MALON_ALREADY_TAUGHT_EPONAS_SONG: { *should = Flags_GetRandomizerInf(RAND_INF_LEARNED_EPONA_SONG); break; @@ -1348,16 +1359,6 @@ void RandomizerOnActorInitHandler(void* actorRef) { } } - if (actor->id == ACTOR_ITEM_B_HEART) { - ItemBHeart* itemBHeart = static_cast(actorRef); - RandomizerCheck rc = OTRGlobals::Instance->gRandomizer->GetCheckFromActor(itemBHeart->actor.id, gPlayState->sceneNum, itemBHeart->actor.params); - if (rc != RC_UNKNOWN_CHECK) { - itemBHeart->sohItemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rc, true, (GetItemID)Rando::StaticData::GetLocation(rc)->GetVanillaItem()); - itemBHeart->actor.draw = (ActorFunc)ItemBHeart_DrawRandomizedItem; - itemBHeart->actor.update = (ActorFunc)ItemBHeart_UpdateRandomizedItem; - } - } - if (actor->id == ACTOR_EN_DNS) { EnDns* enDns = static_cast(actorRef); s16 respawnData = gSaveContext.respawn[RESPAWN_MODE_RETURN].data & ((1 << 8) - 1); diff --git a/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c b/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c index 5015a3908..85a81af85 100644 --- a/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c +++ b/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c @@ -6,6 +6,7 @@ #include "z_item_b_heart.h" #include "objects/object_gi_hearts/object_gi_hearts.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS 0 @@ -39,7 +40,7 @@ static InitChainEntry sInitChain[] = { void ItemBHeart_Init(Actor* thisx, PlayState* play) { ItemBHeart* this = (ItemBHeart*)thisx; - if (Flags_GetCollectible(play, 0x1F)) { + if (GameInteractor_Should(VB_ITEM_B_HEART_DESPAWN, Flags_GetCollectible(play, 0x1F), this)) { Actor_Kill(&this->actor); } else { Actor_ProcessInitChain(&this->actor, sInitChain);