Add freeze timer hook for Gold Skulltula collection (#4445)

* Add freeze timer hook for Gold Skulltula collection

* Remove unused player references

* Replace magic number text IDs

* Separate hook for freezing player on token collection

* Revert one unintended change
This commit is contained in:
Jordan Longstaff 2024-10-21 22:18:34 -04:00 committed by GitHub
parent 17d8487730
commit 3a4bd1164a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 5 deletions

View File

@ -348,6 +348,7 @@ typedef enum {
VB_GIVE_ITEM_FROM_ITEM_00,
// Opt: *EnSi
VB_GIVE_ITEM_SKULL_TOKEN,
VB_FREEZE_ON_SKULL_TOKEN,
// Opt: *EnCow
VB_GIVE_ITEM_FROM_COW,
// Opt: *EnDns

View File

@ -529,6 +529,11 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li
*should = false;
}
break;
case VB_FREEZE_ON_SKULL_TOKEN:
if (CVarGetInteger(CVAR_ENHANCEMENT("SkulltulaFreeze"), 0)) {
*should = false;
}
break;
case VB_DAMPE_IN_GRAVEYARD_DESPAWN:
if (CVarGetInteger(CVAR_ENHANCEMENT("DampeAllNight"), 0)) {
*should = LINK_IS_ADULT || gPlayState->sceneNum != SCENE_GRAVEYARD;

View File

@ -5,6 +5,7 @@
*/
#include "z_en_si.h"
#include "soh/Enhancements/custom-message/CustomMessageTypes.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOOKSHOT_DRAGS)
@ -96,8 +97,10 @@ void func_80AFB768(EnSi* this, PlayState* play) {
this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER;
if (GameInteractor_Should(VB_GIVE_ITEM_SKULL_TOKEN, true, this)) {
Item_Give(play, ITEM_SKULL_TOKEN);
player->actor.freezeTimer = 10;
Message_StartTextbox(play, 0xB4, NULL);
if (GameInteractor_Should(VB_FREEZE_ON_SKULL_TOKEN, true, this)) {
player->actor.freezeTimer = 10;
}
Message_StartTextbox(play, TEXT_GS_NO_FREEZE, NULL);
Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET);
}
this->actionFunc = func_80AFB950;
@ -120,8 +123,10 @@ void func_80AFB89C(EnSi* this, PlayState* play) {
if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_HOOKSHOT_ATTACHED)) {
if (GameInteractor_Should(VB_GIVE_ITEM_SKULL_TOKEN, true, this)) {
Item_Give(play, ITEM_SKULL_TOKEN);
player->actor.freezeTimer = 10;
Message_StartTextbox(play, 0xB4, NULL);
if (GameInteractor_Should(VB_FREEZE_ON_SKULL_TOKEN, true, this)) {
player->actor.freezeTimer = 10;
}
Message_StartTextbox(play, TEXT_GS_NO_FREEZE, NULL);
Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET);
}
this->actionFunc = func_80AFB950;
@ -131,7 +136,7 @@ void func_80AFB89C(EnSi* this, PlayState* play) {
void func_80AFB950(EnSi* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if (Message_GetState(&play->msgCtx) != TEXT_STATE_CLOSING && GameInteractor_Should(VB_GIVE_ITEM_SKULL_TOKEN, true, this)) {
if (Message_GetState(&play->msgCtx) != TEXT_STATE_CLOSING && GameInteractor_Should(VB_FREEZE_ON_SKULL_TOKEN, true, this)) {
player->actor.freezeTimer = 10;
} else {
SET_GS_FLAGS((this->actor.params & 0x1F00) >> 8, this->actor.params & 0xFF);