From 5f1c365a0c4148053470bd14aa32c89f76681c9b Mon Sep 17 00:00:00 2001 From: aMannus Date: Sun, 14 Aug 2022 23:11:11 +0200 Subject: [PATCH] Eliminated copy pasta --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 58 +++++++++------------ 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 93a49ac42..898bc0c51 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -17,6 +17,7 @@ s32 func_80AFB748(EnSi* this, GlobalContext* globalCtx); void func_80AFB768(EnSi* this, GlobalContext* globalCtx); void func_80AFB89C(EnSi* this, GlobalContext* globalCtx); void func_80AFB950(EnSi* this, GlobalContext* globalCtx); +void Randomizer_GrantSkullReward(EnSi* this, GlobalContext* globalCtx); s32 textId = 0xB4; s32 giveItemId = ITEM_SKULL_TOKEN; @@ -99,22 +100,7 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; if (gSaveContext.n64ddFlag) { - getItem = Randomizer_GetRandomizedItem(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); - getItemId = getItem.getItemId; - if (getItem.getItemId == RG_ICE_TRAP) { - player->pendingIceTrap = true; - textId = 0xF8; - } else { - textId = getItem.textId; - giveItemId = getItem.itemId; - if (getItem.modIndex == MOD_NONE) { - Item_Give(globalCtx, giveItemId); - } else if (getItem.modIndex == MOD_RANDOMIZER) { - Randomizer_Item_Give(globalCtx, getItem); - } - } - player->getItemEntry = getItem; - //player->getItemId = getItemId; + Randomizer_GrantSkullReward(this, globalCtx); } else { Item_Give(globalCtx, giveItemId); } @@ -139,30 +125,13 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { } void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Math_SmoothStepToF(&this->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f); Actor_SetScale(&this->actor, this->actor.scale.x); this->actor.shape.rot.y += 0x400; if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { if (gSaveContext.n64ddFlag) { - getItem = Randomizer_GetRandomizedItem(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); - getItemId = getItem.getItemId; - if (getItemId == RG_ICE_TRAP) { - player->pendingIceTrap = true; - textId = 0xF8; - } else { - textId = getItem.textId; - giveItemId = getItem.itemId; - if (getItem.modIndex == MOD_NONE) { - Item_Give(globalCtx, giveItemId); - } else if (getItem.modIndex == MOD_RANDOMIZER) { - Randomizer_Item_Give(globalCtx, getItem); - } - } - //player->getItemId = getItemId; - player->getItemEntry = getItem; + Randomizer_GrantSkullReward(this, globalCtx); } else { Item_Give(globalCtx, giveItemId); } @@ -217,3 +186,24 @@ void EnSi_Draw(Actor* thisx, GlobalContext* globalCtx) { } } + +void Randomizer_GrantSkullReward(EnSi* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + getItem = Randomizer_GetRandomizedItem(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + getItemId = getItem.getItemId; + if (getItemId == RG_ICE_TRAP) { + player->pendingIceTrap = true; + textId = 0xF8; + } else { + textId = getItem.textId; + giveItemId = getItem.itemId; + if (getItem.modIndex == MOD_NONE) { + Item_Give(globalCtx, giveItemId); + } else if (getItem.modIndex == MOD_RANDOMIZER) { + Randomizer_Item_Give(globalCtx, getItem); + } + } + // player->getItemId = getItemId; + player->getItemEntry = getItem; +} \ No newline at end of file