From b6554a84093e716de8490ec35dccee0a35aa4121 Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Sun, 18 Aug 2024 05:45:10 +0200 Subject: [PATCH] Fix skeleton key (#4296) --- soh/soh/Enhancements/mods.cpp | 10 ++++++++-- soh/soh/Enhancements/randomizer/draw.cpp | 16 ++++++++-------- .../overlays/actors/ovl_En_Daiku/z_en_daiku.c | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index f84f99b52..8b3adca0f 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -32,6 +32,7 @@ #include "src/overlays/actors/ovl_Fishing/z_fishing.h" #include "src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h" #include "src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h" +#include "src/overlays/actors/ovl_Door_Gerudo/z_door_gerudo.h" #include "src/overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_link_boy/object_link_boy.h" #include "objects/object_link_child/object_link_child.h" @@ -1754,11 +1755,12 @@ void RegisterRandomizerCompasses() { }); } +extern "C" void func_8099485C(DoorGerudo* gerudoDoor, PlayState* play); + void RegisterSkeletonKey() { GameInteractor::Instance->RegisterGameHook([](void* refActor) { - Actor* actor = static_cast(refActor); - if (Flags_GetRandomizerInf(RAND_INF_HAS_SKELETON_KEY)) { + Actor* actor = static_cast(refActor); if (actor->id == ACTOR_EN_DOOR) { EnDoor* door = (EnDoor*)actor; door->lockTimer = 0; @@ -1767,6 +1769,10 @@ void RegisterSkeletonKey() { if (shutterDoor->doorType == SHUTTER_KEY_LOCKED) { shutterDoor->unk_16E = 0; } + } else if (actor->id == ACTOR_DOOR_GERUDO) { + DoorGerudo* gerudoDoor = (DoorGerudo*)actor; + gerudoDoor->actionFunc = func_8099485C; + gerudoDoor->dyna.actor.world.pos.y = gerudoDoor->dyna.actor.home.pos.y + 200.0f; } } }); diff --git a/soh/soh/Enhancements/randomizer/draw.cpp b/soh/soh/Enhancements/randomizer/draw.cpp index 11e4a430b..e643acd70 100644 --- a/soh/soh/Enhancements/randomizer/draw.cpp +++ b/soh/soh/Enhancements/randomizer/draw.cpp @@ -563,7 +563,7 @@ Color_RGBA8 GetSkeletonKeyColor() { return color; } -int test = 0; +int skeletonKeyRotation = 0; extern "C" void Randomizer_DrawSkeletonKey(PlayState* play, GetItemEntry* getItemEntry) { OPEN_DISPS(play->state.gfxCtx); @@ -572,24 +572,24 @@ extern "C" void Randomizer_DrawSkeletonKey(PlayState* play, GetItemEntry* getIte Gfx_SetupDL_25Opa(play->state.gfxCtx); - test += 1; + skeletonKeyRotation += 1; - if (test > 40) { - test -= 80; + if (skeletonKeyRotation > 40) { + skeletonKeyRotation -= 80; } - Matrix_RotateZ(M_PI / 40 * test, MTXMODE_APPLY); - Matrix_RotateY(M_PI / 40 * test, MTXMODE_APPLY); + Matrix_RotateZ(M_PI / 40 * skeletonKeyRotation, MTXMODE_APPLY); + Matrix_RotateY(M_PI / 40 * skeletonKeyRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); gDPSetGrayscaleColor(POLY_OPA_DISP++, color.r, color.g, color.b, color.a); gSPGrayscale(POLY_OPA_DISP++, true); - + gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gGiSmallKeyDL); gSPGrayscale(POLY_OPA_DISP++, false); - + CLOSE_DISPS(play->state.gfxCtx); } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/soh/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 715a48c37..50ec1532e 100644 --- a/soh/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/soh/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -382,7 +382,7 @@ void EnDaiku_Jailed(EnDaiku* this, PlayState* play) { void EnDaiku_WaitFreedom(EnDaiku* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Flags_GetSwitch(play, this->actor.params >> 8 & 0x3F)) { + if (Flags_GetSwitch(play, this->actor.params >> 8 & 0x3F) || (IS_RANDO && Flags_GetRandomizerInf(RAND_INF_HAS_SKELETON_KEY))) { this->actor.flags |= ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY; EnDaiku_UpdateText(this, play); }