Fix missing despawn branch for heart containers (#4350)

This commit is contained in:
Garrett Cox 2024-09-20 17:37:34 -05:00 committed by GitHub
parent 74c93b0182
commit 5d8841777a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 11 deletions

View File

@ -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,

View File

@ -689,6 +689,17 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void
}
break;
}
case VB_ITEM_B_HEART_DESPAWN: {
ItemBHeart* itemBHeart = static_cast<ItemBHeart*>(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<ItemBHeart*>(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<EnDns*>(actorRef);
s16 respawnData = gSaveContext.respawn[RESPAWN_MODE_RETURN].data & ((1 << 8) - 1);

View File

@ -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);