mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-29 19:18:58 -07:00
Move Shadow Tag Mode hook to its own file (#5179)
* Move Shadow Tag Mode hook to its own file * Rename initFunc
This commit is contained in:
parent
d8acc32876
commit
db8440e744
2 changed files with 50 additions and 33 deletions
50
soh/soh/Enhancements/ExtraModes/ShadowTag.cpp
Normal file
50
soh/soh/Enhancements/ExtraModes/ShadowTag.cpp
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#include <libultraship/bridge.h>
|
||||||
|
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||||
|
#include "soh/ShipInit.hpp"
|
||||||
|
#include "functions.h"
|
||||||
|
|
||||||
|
extern "C" PlayState* gPlayState;
|
||||||
|
|
||||||
|
static constexpr int32_t CVAR_SHADOW_TAG_DEFAULT = 0;
|
||||||
|
#define CVAR_SHADOW_TAG_NAME CVAR_ENHANCEMENT("ShadowTag")
|
||||||
|
#define CVAR_SHADOW_TAG_VALUE CVarGetInteger(CVAR_SHADOW_TAG_NAME, CVAR_SHADOW_TAG_DEFAULT)
|
||||||
|
|
||||||
|
static bool shouldSpawn = false;
|
||||||
|
static uint16_t delayTimer = 60;
|
||||||
|
|
||||||
|
static constexpr s8 ROOM_GREEN_POE = 16;
|
||||||
|
static constexpr s8 ROOM_BLUE_POE = 13;
|
||||||
|
static constexpr s8 ROOM_RED_POE = 12;
|
||||||
|
|
||||||
|
void OnPlayerUpdateShadowTag() {
|
||||||
|
if (gPlayState->sceneNum == SCENE_FOREST_TEMPLE) {
|
||||||
|
switch (gPlayState->roomCtx.curRoom.num) {
|
||||||
|
case ROOM_GREEN_POE:
|
||||||
|
case ROOM_BLUE_POE:
|
||||||
|
case ROOM_RED_POE:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldSpawn && (delayTimer <= 0)) {
|
||||||
|
Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_WALLMAS, 0, 0, 0, 0, 0, 0, 3, false);
|
||||||
|
shouldSpawn = false;
|
||||||
|
} else {
|
||||||
|
delayTimer--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetShadowTagSpawnTimer() {
|
||||||
|
shouldSpawn = true;
|
||||||
|
delayTimer = 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterShadowTag() {
|
||||||
|
COND_HOOK(OnPlayerUpdate, CVAR_SHADOW_TAG_VALUE, OnPlayerUpdateShadowTag);
|
||||||
|
COND_HOOK(OnSceneSpawnActors, true, []() { ResetShadowTagSpawnTimer(); });
|
||||||
|
COND_HOOK(OnSceneInit, true, [](int16_t) { ResetShadowTagSpawnTimer(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegisterShipInitFunc initFunc_ShadowTag(RegisterShadowTag, { CVAR_SHADOW_TAG_NAME });
|
|
@ -159,38 +159,6 @@ void RegisterRupeeDash() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterShadowTag() {
|
|
||||||
static bool shouldSpawn = false;
|
|
||||||
static uint16_t delayTimer = 60;
|
|
||||||
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
|
|
||||||
if (!CVarGetInteger(CVAR_ENHANCEMENT("ShadowTag"), 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (gPlayState->sceneNum == SCENE_FOREST_TEMPLE && // Forest Temple Scene
|
|
||||||
gPlayState->roomCtx.curRoom.num == 16 || // Green Poe Room
|
|
||||||
gPlayState->roomCtx.curRoom.num == 13 || // Blue Poe Room
|
|
||||||
gPlayState->roomCtx.curRoom.num == 12) { // Red Poe Room
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (shouldSpawn && (delayTimer <= 0)) {
|
|
||||||
Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_WALLMAS, 0, 0, 0, 0, 0, 0, 3, false);
|
|
||||||
shouldSpawn = false;
|
|
||||||
} else {
|
|
||||||
delayTimer--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneSpawnActors>([]() {
|
|
||||||
shouldSpawn = true;
|
|
||||||
delayTimer = 60;
|
|
||||||
});
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](int16_t sceneNum) {
|
|
||||||
shouldSpawn = true;
|
|
||||||
delayTimer = 60;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool hasAffectedHealth = false;
|
static bool hasAffectedHealth = false;
|
||||||
void UpdatePermanentHeartLossState() {
|
void UpdatePermanentHeartLossState() {
|
||||||
if (!GameInteractor::IsSaveLoaded())
|
if (!GameInteractor::IsSaveLoaded())
|
||||||
|
@ -1015,7 +983,6 @@ void InitMods() {
|
||||||
RegisterTTS();
|
RegisterTTS();
|
||||||
RegisterOcarinaTimeTravel();
|
RegisterOcarinaTimeTravel();
|
||||||
RegisterRupeeDash();
|
RegisterRupeeDash();
|
||||||
RegisterShadowTag();
|
|
||||||
RegisterPermanentHeartLoss();
|
RegisterPermanentHeartLoss();
|
||||||
RegisterDeleteFileOnDeath();
|
RegisterDeleteFileOnDeath();
|
||||||
RegisterHyperBosses();
|
RegisterHyperBosses();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue