Skip to content

Commit

Permalink
Despawn Kakariko objects only when in Triforce Hunt Mode, clean up GB…
Browse files Browse the repository at this point in the history
…K event order.

Disabling End Title until that can be sorted.
  • Loading branch information
Caladius committed Nov 4, 2023
1 parent c2a7517 commit 51459c2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 49 deletions.
78 changes: 41 additions & 37 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,18 +641,16 @@ void RegisterMirrorModeHandler() {
f32 triforcePieceScale;

void RegisterTriforceHunt() {
static int eventTimer = -1;
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
Player* player = GET_PLAYER(gPlayState);
uint8_t currentPieces = gSaveContext.triforcePiecesCollected;
uint8_t requiredPieces = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED);

if (!GameInteractor::IsGameplayPaused() &&
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT)) {

// Warp to credits
if (GameInteractor::State::TriforceHuntCreditsWarpActive) {
eventTimer = 1;
GameInteractor::State::TriforceHuntCreditsWarpActive = 0;
}

Expand All @@ -666,52 +664,58 @@ void RegisterTriforceHunt() {
GameInteractor::State::TriforceHuntPieceGiven = 0;
}
}

if (currentPieces >= requiredPieces && eventTimer >= 1 && eventTimer <= 30) {
eventTimer++;
} else if (eventTimer > 30 && eventTimer <= 31) {
gPlayState->nextEntranceIndex = 0xDB;
gSaveContext.nextCutsceneIndex = 0x8000;
gPlayState->sceneLoadFlag = 0x14;
gPlayState->fadeTransition = 3;
eventTimer = 32;
}

if (gPlayState->sceneNum == SCENE_KAKARIKO_VILLAGE && eventTimer == 32) {
player->actor.world.pos.x = -1441.043;
player->actor.world.pos.y = 55.037;
player->actor.world.pos.z = 578.224;
player->actor.shape.rot.x = 0;
player->actor.shape.rot.y = 17681;
player->actor.shape.rot.z = 0;

GameInteractor::State::NoUIActive = 1;
Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_END_TITLE, 0, 0, 0, 0, 0, 0, 2, false);
eventTimer = 33;
}

});

GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!gPlayState) {
return;
}
Player* player = GET_PLAYER(gPlayState);
if (eventTimer == 33) {
player->actor.freezeTimer = 60;
}

});

}

void RegisterGrantGanonsBossKey() {
static uint16_t eventTimer = -1;
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
Player* player = GET_PLAYER(gPlayState);
Actor* aplayer = &GET_PLAYER(gPlayState)->actor;
// Triforce Hunt needs the check if the player isn't being teleported to the credits scene.
if (!GameInteractor::IsGameplayPaused() && Flags_GetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY) &&
gPlayState->sceneLoadFlag != 0x14 && (1 << 0 & gSaveContext.inventory.dungeonItems[SCENE_GANONS_TOWER]) == 0) {
GetItemEntry getItemEntry =
ItemTableManager::Instance->RetrieveItemEntry(MOD_RANDOMIZER, RG_GANONS_CASTLE_BOSS_KEY);
GiveItemEntryWithoutActor(gPlayState, getItemEntry);
if (gPlayState->sceneNum == SCENE_KAKARIKO_VILLAGE) {
eventTimer = 0;
} else {
eventTimer = 1;
}
}

if (!GameInteractor::IsGameplayPaused() && gSaveContext.inventory.dungeonItems[SCENE_GANONS_TOWER] > 0
&& eventTimer == 0) {
eventTimer = 1;
}
if (eventTimer >= 1 && eventTimer <= 3) {
eventTimer++;
}
if (eventTimer == 4) {
if (gPlayState->sceneNum == SCENE_KAKARIKO_VILLAGE) {
player->actor.world.pos.x = -929.336;
player->actor.world.pos.y = 0;
player->actor.world.pos.z = 446.178;
player->actor.shape.rot.x = 0;
player->actor.shape.rot.y = 17537;
player->actor.shape.rot.z = 0;
GameInteractor::State::NoUIActive = 1;

if (!Actor_FindNearby(gPlayState, aplayer, ACTOR_END_TITLE, ACTORCAT_ITEMACTION, 1000)) {
//Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_END_TITLE, 0, 0, 0, 0, 0, 0, 2, false);
}

player->stateFlags1 = PLAYER_STATE1_INPUT_DISABLED;
} else {
eventTimer = 5;
}
}
if (eventTimer == 5) {
eventTimer = -1;
GameInteractor::State::NoUIActive = 0;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ void EnChristmasTree_Init(Actor* thisx, PlayState* play) {
this->actor.targetMode = 1;
this->actor.textId = 0x406B; // Hijacking bean seller text ID so I'm sure it doesn't clash

this->actor.shape.rot.y = -14784;

this->actionFunc = EnChristmasTree_Wait;
}

Expand Down
16 changes: 9 additions & 7 deletions soh/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ void EnWood02_Init(Actor* thisx, PlayState* play2) {
f32 floorY;
s16 extraRot;

if (gPlayState->sceneNum == SCENE_KAKARIKO_VILLAGE && this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) {
Actor_Kill(this);
}
if (Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT) == 1) {
if (gPlayState->sceneNum == SCENE_KAKARIKO_VILLAGE && this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) {
Actor_Kill(this);
}

if (gPlayState->sceneNum == SCENE_KAKARIKO_VILLAGE && this->actor.params >= 0) {
this->actor.world.pos.x = 754.051;
this->actor.world.pos.y = 80.0;
this->actor.world.pos.z = 1429.908;
if (gPlayState->sceneNum == SCENE_KAKARIKO_VILLAGE && this->actor.params >= 0) {
this->actor.world.pos.x = 754.051;
this->actor.world.pos.y = 80.0;
this->actor.world.pos.z = 1429.908;
}
}

// The tree in Kakariko's day scene does not have the same params to spawn the GS
Expand Down
10 changes: 5 additions & 5 deletions soh/src/overlays/actors/ovl_End_Title/z_end_title.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ void EndTitle_DrawFull(Actor* thisx, PlayState* play) {
gDPLoadTextureTile(OVERLAY_DISP++, sOcarinaOfTimeTex, G_IM_FMT_IA, G_IM_SIZ_8b, 112, 16, 0, 0, 112 - 1, 16 - 1, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 0, 0, 0, 0);
gSPTextureRectangle(OVERLAY_DISP++, 104 << 2, 177 << 2, 216 << 2, 192 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);

D_801614B0.a = 255;
D_801614B0.r = 205;
D_801614B0.g = 168;
D_801614B0.b = 130;
D_801614B0.a = 0;
//D_801614B0.r = 205;
//D_801614B0.g = 168;
//D_801614B0.b = 130;

gSPGrayscale(OVERLAY_DISP++, true);
//gSPGrayscale(OVERLAY_DISP++, true);
} else {
if (D_801614B0.a > 0)

Expand Down

0 comments on commit 51459c2

Please sign in to comment.