From 3b747b41becd8296b8e14b291426ca77f94fc9dc Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 18 Jul 2022 09:05:32 +0200 Subject: [PATCH] Cleanup and freeze fix Don't freeze the player when the skulltula token check is something else than a token. Also some cleanup and declaring variables more globally within z_en_si.c --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 40 ++++++++++--------- .../actors/ovl_player_actor/z_player.c | 1 - 2 files changed, 21 insertions(+), 20 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 9293a436f..91fe0126c 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 @@ -18,6 +18,10 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx); void func_80AFB89C(EnSi* this, GlobalContext* globalCtx); void func_80AFB950(EnSi* this, GlobalContext* globalCtx); +s32 textId = 0xB4; +s32 giveItemId = ITEM_SKULL_TOKEN; +s32 getItemId; + static ColliderCylinderInit sCylinderInit = { { COLTYPE_NONE, @@ -93,15 +97,13 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - s32 textId = 0xB4; - s32 itemGiveId = ITEM_SKULL_TOKEN; if (gSaveContext.n64ddFlag) { - s32 getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); textId = sGetItemTable[getItemId - 1].textId; - itemGiveId = sGetItemTable[getItemId - 1].itemId; + giveItemId = sGetItemTable[getItemId - 1].itemId; } - Item_Give(globalCtx, itemGiveId); - if (CVar_GetS32("gSkulltulaFreeze", 0) != 1 || itemGiveId != ITEM_SKULL_TOKEN) { + Item_Give(globalCtx, giveItemId); + if (CVar_GetS32("gSkulltulaFreeze", 0) != 1 || giveItemId != ITEM_SKULL_TOKEN) { player->actor.freezeTimer = 20; } Message_StartTextbox(globalCtx, textId, NULL); @@ -124,14 +126,12 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { this->actor.shape.rot.y += 0x400; if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { - s32 textId = 0xB4; - s32 itemGiveId = ITEM_SKULL_TOKEN; if (gSaveContext.n64ddFlag) { - s32 getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + giveItemId = sGetItemTable[getItemId - 1].itemId; textId = sGetItemTable[getItemId - 1].textId; - itemGiveId = sGetItemTable[getItemId - 1].itemId; } - Item_Give(globalCtx, itemGiveId); + Item_Give(globalCtx, giveItemId); Message_StartTextbox(globalCtx, textId, NULL); Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); this->actionFunc = func_80AFB950; @@ -141,7 +141,7 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { void func_80AFB950(EnSi* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_CLOSING && CVar_GetS32("gSkulltulaFreeze", 0) != 1) { + if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_CLOSING && (CVar_GetS32("gSkulltulaFreeze", 0) != 1 || giveItemId != ITEM_SKULL_TOKEN)) { player->actor.freezeTimer = 10; } else { SET_GS_FLAGS((this->actor.params & 0x1F00) >> 8, this->actor.params & 0xFF); @@ -167,14 +167,16 @@ void EnSi_Draw(Actor* thisx, GlobalContext* globalCtx) { if (!gSaveContext.n64ddFlag) { GetItem_Draw(globalCtx, GID_SKULL_TOKEN_2); } else { - f32 mtxScale = 1.5f; - Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - s32 randoGetItemId = - GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); - if (randoGetItemId >= GI_MINUET_OF_FOREST && randoGetItemId <= GI_DOUBLE_DEFENSE) { - EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItemId); + f32 mtxScale; + getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + if (getItemId >= GI_MINUET_OF_FOREST && getItemId <= GI_DOUBLE_DEFENSE) { + EnItem00_CustomItemsParticles(&this->actor, globalCtx, getItemId); } - GetItem_Draw(globalCtx, GetItemModelFromId(randoGetItemId)); + if (getItemId != ITEM_SKULL_TOKEN) { + mtxScale = 1.5f; + Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); + } + GetItem_Draw(globalCtx, GetItemModelFromId(getItemId)); } } diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 330c53738..6f4800a9f 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -6,7 +6,6 @@ #include "ultra64.h" #include "global.h" -#include "z64player.h" #include "overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.h" #include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h"