Skip to content

Commit

Permalink
Merge pull request #5 from aMannus/christmas-tree
Browse files Browse the repository at this point in the history
Move ending to christmas tree code
  • Loading branch information
Caladius authored Nov 4, 2023
2 parents 51459c2 + 711b392 commit 40f07b5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
1 change: 1 addition & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef enum {
extern "C" {
#endif
uint8_t GameInteractor_NoUIActive();
void GameInteractor_SetNoUIActive(uint8_t state);
GILinkSize GameInteractor_GetLinkSize();
void GameInteractor_SetLinkSize(GILinkSize size);
uint8_t GameInteractor_InvisibleLinkActive();
Expand Down
4 changes: 4 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor_State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ uint8_t GameInteractor_NoUIActive() {
return GameInteractor::State::NoUIActive;
}

void GameInteractor_SetNoUIActive(uint8_t state) {
GameInteractor::State::NoUIActive = state;
}

// MARK: - GameInteractor::State::LinkSize
GILinkSize GameInteractor_GetLinkSize() {
return GameInteractor::State::LinkSize;
Expand Down
38 changes: 0 additions & 38 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,52 +670,14 @@ void RegisterTriforceHunt() {
}

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
28 changes: 24 additions & 4 deletions soh/src/overlays/actors/ovl_En_ChristmasTree/z_en_christmastree.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void EnChristmasTree_Draw(Actor* thisx, PlayState* play);

void EnChristmasTree_Wait(EnChristmasTree* this, PlayState* play);
void EnChristmasTree_Talk(EnChristmasTree* this, PlayState* play);
void EnChristmasTree_SetupEndTitle(EnChristmasTree* this, PlayState* play);

static ColliderCylinderInit sCylinderInit = {
{
Expand Down Expand Up @@ -73,20 +74,39 @@ void EnChristmasTree_Talk(EnChristmasTree* this, PlayState* play) {
u8 dialogState = Message_GetState(&play->msgCtx);
if (dialogState != TEXT_STATE_CHOICE) {
if ((dialogState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { // advanced final textbox
this->actionFunc = EnChristmasTree_Wait;

// Teleport to credits when goal is reached.
if (gSaveContext.triforcePiecesCollected >= Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED)) {
gSaveContext.sohStats.itemTimestamp[TIMESTAMP_TRIFORCE_COMPLETED] = GAMEPLAYSTAT_TOTAL_TIME;
gSaveContext.sohStats.gameComplete = 1;
Flags_SetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY);
Play_PerformSave(play);
GameInteractor_SetTriforceHuntCreditsWarpActive(true);
this->actionFunc = EnChristmasTree_SetupEndTitle;
} else {
this->actionFunc = EnChristmasTree_Wait;
}
}
}
}

void EnChristmasTree_SetupEndTitle(EnChristmasTree* this, PlayState* play) {
Player* player = GET_PLAYER(play);

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_SetNoUIActive(1);


Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_END_TITLE, 0, 0, 0, 0, 0, 0, 2, false);

player->stateFlags1 = PLAYER_STATE1_INPUT_DISABLED;

Flags_SetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY);

this->actionFunc = EnChristmasTree_Wait;
}

void EnChristmasTree_Update(Actor* thisx, PlayState* play) {
Expand Down

0 comments on commit 40f07b5

Please sign in to comment.