From 881529c7bf1889241fb91156347b48d79a24db94 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 15 Aug 2022 23:08:31 -0400 Subject: [PATCH] Sets `z_en_box.c` to set `player->getItemEntry` --- soh/soh/OTRGlobals.h | 1 + soh/src/overlays/actors/ovl_En_Box/z_en_box.c | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 750dd911e..5be94cb40 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -105,6 +105,7 @@ bool Randomizer_ObtainedFreestandingIceTrap(RandomizerCheck randomizerCheck, Get bool Randomizer_ItemIsIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId); int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx); GetItemEntry ItemTable_Retrieve(int16_t getItemID); +GetItemEntry ItemTable_RetrieveEntry(s16 modIndex, s16 getItemID); #endif #endif diff --git a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c index a3e384ec5..a2f57ad6a 100644 --- a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -70,7 +70,7 @@ static InitChainEntry sInitChain[] = { }; static UNK_TYPE sUnused; -int32_t sItem; +GetItemEntry sItem; void EnBox_SetupAction(EnBox* this, EnBoxActionFunc actionFunc) { this->actionFunc = actionFunc; @@ -446,40 +446,43 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { func_8002DBD0(&this->dyna.actor, &sp4C, &player->actor.world.pos); if (sp4C.z > -50.0f && sp4C.z < 0.0f && fabsf(sp4C.y) < 10.0f && fabsf(sp4C.x) < 20.0f && Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { - sItem = Randomizer_GetRandomizedItem(this->dyna.actor.params >> 5 & 0x7F, this->dyna.actor.id, this->dyna.actor.params, globalCtx->sceneNum).getItemId; + sItem = Randomizer_GetRandomizedItem(this->dyna.actor.params >> 5 & 0x7F, this->dyna.actor.id, this->dyna.actor.params, globalCtx->sceneNum); + GetItemEntry blueRupee = ItemTable_RetrieveEntry(MOD_NONE, GI_RUPEE_BLUE); // RANDOTODO treasure chest game rando if (Randomizer_GetSettingValue(RSK_SHUFFLE_CHEST_MINIGAME)) { if (gSaveContext.n64ddFlag && globalCtx->sceneNum == 16 && (this->dyna.actor.params & 0x60) != 0x20) { if((this->dyna.actor.params & 0xF) < 2) { if(Flags_GetCollectible(globalCtx, 0x1B)) { - sItem = GI_RUPEE_BLUE; + sItem = blueRupee; } } if((this->dyna.actor.params & 0xF) >= 2 && (this->dyna.actor.params & 0xF) < 4) { if(Flags_GetCollectible(globalCtx, 0x1C)) { - sItem = GI_RUPEE_BLUE; + sItem = blueRupee; } } if((this->dyna.actor.params & 0xF) >= 4 && (this->dyna.actor.params & 0xF) < 6) { if(Flags_GetCollectible(globalCtx, 0x1D)) { - sItem = GI_RUPEE_BLUE; + sItem = blueRupee; } } if((this->dyna.actor.params & 0xF) >= 6 && (this->dyna.actor.params & 0xF) < 8) { if(Flags_GetCollectible(globalCtx, 0x1E)) { - sItem = GI_RUPEE_BLUE; + sItem = blueRupee; } } if((this->dyna.actor.params & 0xF) >= 8 && (this->dyna.actor.params & 0xF) < 10) { if(Flags_GetCollectible(globalCtx, 0x1F)) { - sItem = GI_RUPEE_BLUE; + sItem = blueRupee; } } } } - - func_8002F554(&this->dyna.actor, globalCtx, 0 - sItem); + // Chests need to have a negative getItemId in order to not immediately give their item + // when approaching. + sItem.getItemId = 0 - sItem.getItemId; + GiveItemEntryFromActorWithFixedRange(&this->dyna.actor, globalCtx, sItem); } if (Flags_GetTreasure(globalCtx, this->dyna.actor.params & 0x1F)) { EnBox_SetupAction(this, EnBox_Open); @@ -591,7 +594,7 @@ void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { } if (((!gSaveContext.n64ddFlag && ((this->dyna.actor.params >> 5 & 0x7F) == 0x7C)) || - (gSaveContext.n64ddFlag && sItem == GI_ICE_TRAP)) && + (gSaveContext.n64ddFlag && sItem.getItemId == RG_ICE_TRAP)) && this->actionFunc == EnBox_Open && this->skelanime.curFrame > 45 && this->iceSmokeTimer < 100) EnBox_SpawnIceSmoke(this, globalCtx); }