From bbbd2520b1611f18da2df7ba13751d9da2694636 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Tue, 9 Apr 2024 23:57:07 -0400 Subject: [PATCH] vb lh sun (#106) * underwater working pre func_80B858B4 replacement * underwater item update handled by hookhandlers * vb lh sun * remove unused should --- .../Enhancements/randomizer/hook_handlers.cpp | 44 +++++++++++++++++++ .../ovl_Item_Etcetera/z_item_etcetera.c | 14 +----- .../ovl_Item_Etcetera/z_item_etcetera.h | 2 + 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 31ba23427..ce24e11d9 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -277,6 +277,8 @@ void ItemBHeart_UpdateRandomizedItem(Actor* actor, PlayState* play) { void ItemEtcetera_DrawRandomizedItem(ItemEtcetera* itemEtcetera, PlayState* play) { EnItem00_CustomItemsParticles(&itemEtcetera->actor, play, itemEtcetera->sohItemEntry); + func_8002EBCC(&itemEtcetera->actor, play, 0); + func_8002ED80(&itemEtcetera->actor, play, 0); GetItemEntry_Draw(play, itemEtcetera->sohItemEntry); } @@ -296,6 +298,44 @@ void ItemEtcetera_func_80B858B4_Randomized(ItemEtcetera* itemEtcetera, PlayState } } +void ItemEtcetera_func_80B85824_Randomized(ItemEtcetera* itemEtcetera, PlayState* play) { + if ((itemEtcetera->actor.params & 0xFF) != 7) { + return; + } + + if (itemEtcetera->actor.xzDistToPlayer < 30.0f && + fabsf(itemEtcetera->actor.yDistToPlayer) < 50.0f) { + + Flags_SetTreasure(play, 0x1F); + Actor_Kill(&itemEtcetera->actor); + } +} + +void ItemEtcetera_MoveRandomizedFireArrowDown(ItemEtcetera* itemEtcetera, PlayState* play) { + Actor_UpdateBgCheckInfo(play, &itemEtcetera->actor, 10.0f, 10.0f, 0.0f, 5); + Actor_MoveForward(&itemEtcetera->actor); + if (!(itemEtcetera->actor.bgCheckFlags & 1)) { + ItemEtcetera_SpawnSparkles(itemEtcetera, play); + } + itemEtcetera->actor.shape.rot.y += 0x400; + ItemEtcetera_func_80B85824_Randomized(itemEtcetera, play); +} + +void ItemEtcetera_UpdateRandomizedFireArrow(ItemEtcetera* itemEtcetera, PlayState* play) { + if ((play->csCtx.state != CS_STATE_IDLE) && (play->csCtx.npcActions[0] != NULL)) { + if (play->csCtx.npcActions[0]->action == 2) { + itemEtcetera->actor.draw = (ActorFunc)ItemEtcetera_DrawRandomizedItem; + itemEtcetera->actor.gravity = -0.1f; + itemEtcetera->actor.minVelocityY = -4.0f; + itemEtcetera->actionFunc = ItemEtcetera_MoveRandomizedFireArrowDown; + } + } else { + itemEtcetera->actor.gravity = -0.1f; + itemEtcetera->actor.minVelocityY = -4.0f; + itemEtcetera->actionFunc = ItemEtcetera_MoveRandomizedFireArrowDown; + } +} + void EnCow_MoveForRandomizer(EnCow* enCow, PlayState* play) { bool moved = false; @@ -991,6 +1031,10 @@ void RandomizerOnActorInitHandler(void* actorRef) { itemEtcetera->futureActionFunc = (ItemEtceteraActionFunc)ItemEtcetera_func_80B858B4_Randomized; break; } + case ITEM_ETC_ARROW_FIRE: { + itemEtcetera->futureActionFunc = (ItemEtceteraActionFunc)ItemEtcetera_UpdateRandomizedFireArrow; + break; + } } } } diff --git a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index db42bc15b..8a26860f7 100644 --- a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -120,24 +120,13 @@ void func_80B857D0(ItemEtcetera* this, PlayState* play) { void func_80B85824(ItemEtcetera* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { - if ((this->actor.params & 0xFF) == 7) { - if (IS_RANDO) { - Flags_SetTreasure(play, 0x1F); - } - } - if ((this->actor.params & 0xFF) == 1) { Flags_SetEventChkInf(EVENTCHKINF_OBTAINED_RUTOS_LETTER); Flags_SetSwitch(play, 0xB); } Actor_Kill(&this->actor); } else { - if (!IS_RANDO) { - Actor_OfferGetItem(&this->actor, play, this->getItemId, 30.0f, 50.0f); - } else { - GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE); - GiveItemEntryFromActor(&this->actor, play, getItemEntry, 30.0f, 50.0f); - } + Actor_OfferGetItem(&this->actor, play, this->getItemId, 30.0f, 50.0f); } } @@ -233,7 +222,6 @@ void ItemEtcetera_DrawThroughLens(Actor* thisx, PlayState* play) { void ItemEtcetera_Draw(Actor* thisx, PlayState* play) { ItemEtcetera* this = (ItemEtcetera*)thisx; - s32 type = this->actor.params & 0xFF; func_8002EBCC(&this->actor, play, 0); func_8002ED80(&this->actor, play, 0); diff --git a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h index ceec9c8b1..5293292a4 100644 --- a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h +++ b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h @@ -38,4 +38,6 @@ typedef enum { /* 0x0D */ ITEM_ETC_KEY_SMALL_CHEST_GAME } ItemEtceteraType; +void ItemEtcetera_SpawnSparkles(ItemEtcetera* ItemEtcetera, PlayState* play); + #endif