summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorAdam Bird <Archez@users.noreply.github.com>2022-11-14 06:13:21 -0500
committerGitHub <noreply@github.com>2022-11-14 12:13:21 +0100
commit15a9975200f89e221a2ba55f132e7d1f682add59 (patch)
tree15cdef640547f9841ae4c161ec9790ea4d9c3b8a /soh/src/code
parent8be2c4ddd747641ac7f12201a1732f384766649f (diff)
Entrance Rando (#1760)
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/z_demo.c6
-rw-r--r--soh/src/code/z_parameter.c7
-rw-r--r--soh/src/code/z_play.c15
-rw-r--r--soh/src/code/z_sram.c14
4 files changed, 42 insertions, 0 deletions
diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c
index 8f5a5fd31..4133d4dab 100644
--- a/soh/src/code/z_demo.c
+++ b/soh/src/code/z_demo.c
@@ -31,6 +31,8 @@
#include "scenes/misc/hakaana_ouke/hakaana_ouke_scene.h"
+#include "soh/Enhancements/randomizer/randomizer_entrance.h"
+
u16 D_8011E1C0 = 0;
u16 D_8011E1C4 = 0;
@@ -1236,6 +1238,10 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
play->fadeTransition = 3;
break;
}
+
+ if (randoCsSkip) {
+ Entrance_OverrideCutsceneEntrance(cmd->base);
+ }
}
}
diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c
index 0a8d11a4b..0c3afc651 100644
--- a/soh/src/code/z_parameter.c
+++ b/soh/src/code/z_parameter.c
@@ -4,6 +4,7 @@
#include "textures/do_action_static/do_action_static.h"
#include "textures/icon_item_static/icon_item_static.h"
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
+#include "soh/Enhancements/randomizer/randomizer_entrance.h"
#ifdef _MSC_VER
#include <stdlib.h>
@@ -6361,6 +6362,12 @@ void Interface_Update(PlayState* play) {
gSaveContext.respawnFlag = -2;
play->nextEntranceIndex = gSaveContext.entranceIndex;
+
+ // In ER, handle sun song respawn from last entrance from grottos
+ if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES)) {
+ Grotto_ForceGrottoReturn();
+ }
+
play->sceneLoadFlag = 0x14;
gSaveContext.sunsSongState = SUNSSONG_INACTIVE;
func_800F6964(30);
diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c
index 8bc51042e..9f5b35447 100644
--- a/soh/src/code/z_play.c
+++ b/soh/src/code/z_play.c
@@ -7,6 +7,7 @@
#include <ImGuiImpl.h>
#include "soh/frame_interpolation.h"
#include "soh/Enhancements/debugconsole.h"
+#include "soh/Enhancements/randomizer/randomizer_entrance.h"
#include <overlays/actors/ovl_En_Niw/z_en_niw.h>
#include <time.h>
@@ -158,6 +159,11 @@ void Play_Destroy(GameState* thisx) {
PlayState* play = (PlayState*)thisx;
Player* player = GET_PLAYER(play);
+ // In ER, remove link from epona when entering somewhere that doesn't support epona
+ if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHUFFLE_OVERWORLD_ENTRANCES)) {
+ Entrance_HandleEponaState();
+ }
+
play->state.gfxCtx->callback = NULL;
play->state.gfxCtx->callbackParam = 0;
SREG(91) = 0;
@@ -512,6 +518,7 @@ void Play_Init(GameState* thisx) {
play,
gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].scene,
gEntranceTable[((void)0, gSaveContext.sceneSetupIndex) + ((void)0, gSaveContext.entranceIndex)].spawn);
+
osSyncPrintf("\nSCENE_NO=%d COUNTER=%d\n", ((void)0, gSaveContext.entranceIndex), gSaveContext.sceneSetupIndex);
Cutscene_HandleEntranceTriggers(play);
@@ -1754,6 +1761,10 @@ void* Play_LoadFile(PlayState* play, RomFile* file) {
}
void Play_InitEnvironment(PlayState* play, s16 skyboxId) {
+ // For entrance rando, ensure the correct weather state and sky mode is applied
+ if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES)) {
+ Entrance_OverrideWeatherState();
+ }
Skybox_Init(&play->state, &play->skyboxCtx, skyboxId);
Environment_Init(play, &play->envCtx, 0);
}
@@ -1781,6 +1792,10 @@ void Play_InitScene(PlayState* play, s32 spawn)
void Play_SpawnScene(PlayState* play, s32 sceneNum, s32 spawn) {
OTRPlay_SpawnScene(play, sceneNum, spawn);
+
+ if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES)) {
+ Entrance_OverrideSpawnScene(sceneNum, spawn);
+ }
}
void func_800C016C(PlayState* play, Vec3f* src, Vec3f* dest) {
diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c
index a2017ce9a..406cba1fb 100644
--- a/soh/src/code/z_sram.c
+++ b/soh/src/code/z_sram.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <soh/Enhancements/randomizer/randomizerTypes.h>
#include <soh/Enhancements/randomizer/randomizer_inf.h>
+#include "soh/Enhancements/randomizer/randomizer_entrance.h"
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
#define NUM_DUNGEONS 8
@@ -196,6 +197,19 @@ void Sram_OpenSave() {
}
}
+ // Setup the modified entrance table and entrance shuffle table for rando
+ if (gSaveContext.n64ddFlag) {
+ Entrance_Init();
+ if (!CVar_GetS32("gRememberSaveLocation", 0) || gSaveContext.savedSceneNum == SCENE_YOUSEI_IZUMI_TATE ||
+ gSaveContext.savedSceneNum == SCENE_KAKUSIANA) {
+ Entrance_SetSavewarpEntrance();
+ }
+ } else {
+ // When going from a rando save to a vanilla save within the same game instance
+ // we need to reset the entrance table back to its vanilla state
+ Entrance_ResetEntranceTable();
+ }
+
osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex);
osSyncPrintf(VT_RST);