diff --git a/resources/dialogue/dorm_dialogues.json b/resources/dialogue/dorm_dialogues.json index 0be1cfa..48b0e90 100644 --- a/resources/dialogue/dorm_dialogues.json +++ b/resources/dialogue/dorm_dialogues.json @@ -616,6 +616,7 @@ "cutscenes": [{ "id": "sleep_cutscene001", "background": "resources/test_cutscene001.png", + "onFadeInCallback": "on_sleep_cutscene", "durationMs": 5000, "fadeOutMs": 500, "fadeInMs": 500, diff --git a/resources/start_dorm.lua b/resources/start_dorm.lua index 1907238..a35c4cc 100644 --- a/resources/start_dorm.lua +++ b/resources/start_dorm.lua @@ -99,6 +99,7 @@ else game_api.start_cutscene("sleep_cutscene001") game_api.setIntValue("need_sleep", 0) game_api.set_player_hp(200) +--game_api.set_day() - done in cutscene end end @@ -110,6 +111,11 @@ function on_locked_door_click() game_api.start_dialogue("door_locked_dialog001") end +function on_sleep_cutscene() + print("Cutscene 2 done!") + night_time = true + game_api.set_day() +end function on_alik_door_click() diff --git a/resources/start_uni_interior.lua b/resources/start_uni_interior.lua index 00124fc..efc0679 100644 --- a/resources/start_uni_interior.lua +++ b/resources/start_uni_interior.lua @@ -468,6 +468,7 @@ end function on_sleep_cutscene() print("Cutscene 2 done!") night_time = true + game_api.set_night() --game_api.set_trigger_zone_enabled(1, false) game_api.set_npc_enabled(0, false) game_api.switch_navigation(5) diff --git a/src/Game.cpp b/src/Game.cpp index d93b8e2..229ad59 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -271,6 +271,7 @@ namespace ZL locations["uni_interior"]->setup(uniInteriorParams, &menuManager.questJournal); locations["uni_interior"]->scriptEngine.setGlobalStore(&globalInts); locations["uni_interior"]->scriptEngine.setGlobalFloatStore(&globalFloats); + locations["uni_interior"]->requestNightDayTransition = [this](bool isNight) { this->isNight = isNight; }; locations["uni_interior"]->requestDarklandsTransition = [this]() { return startDarklandsTransition(); }; locations["uni_interior"]->requestAdvanceDarklandsHud = [this]() { menuManager.advanceUniIntDarklandsHud(); }; if (locations["uni_interior"]->player) @@ -299,6 +300,7 @@ namespace ZL locations["uni_exterior"]->setup(uniExteriorParams, &menuManager.questJournal); locations["uni_exterior"]->scriptEngine.setGlobalStore(&globalInts); locations["uni_exterior"]->scriptEngine.setGlobalFloatStore(&globalFloats); + locations["uni_exterior"]->requestNightDayTransition = [this](bool isNight) { this->isNight = isNight; }; locations["uni_exterior"]->requestDarklandsTransition = [this]() { return startDarklandsTransition(); }; if (locations["uni_exterior"]->player) locations["uni_exterior"]->player->onDeathAnimComplete = [this]() { startDarklandsTransition(); }; @@ -361,6 +363,7 @@ namespace ZL locations["location_dorm"]->setup(params_dorm, &menuManager.questJournal); locations["location_dorm"]->scriptEngine.setGlobalStore(&globalInts); locations["location_dorm"]->scriptEngine.setGlobalFloatStore(&globalFloats); + locations["location_dorm"]->requestNightDayTransition = [this](bool isNight) { this->isNight = isNight; }; locations["location_dorm"]->requestDarklandsTransition = [this]() { return startDarklandsTransition(); }; if (locations["location_dorm"]->player) locations["location_dorm"]->player->onDeathAnimComplete = [this]() { startDarklandsTransition(); }; diff --git a/src/Location.h b/src/Location.h index 605fc2d..250d1cb 100644 --- a/src/Location.h +++ b/src/Location.h @@ -109,6 +109,8 @@ namespace ZL // request the transition without coupling Location to Game directly. std::function requestDarklandsTransition; + std::function requestNightDayTransition; + // Set by Game after setup(). Lua calls this to advance the uni_interior HUD // from step12 to step13 (trigger-zone encounter hint). std::function requestAdvanceDarklandsHud; diff --git a/src/ScriptEngine.cpp b/src/ScriptEngine.cpp index 6f32abb..5f1af77 100644 --- a/src/ScriptEngine.cpp +++ b/src/ScriptEngine.cpp @@ -204,6 +204,18 @@ namespace ZL { game->requestDarklandsTransition(); }); + + api.set_function("set_day", + [game]() { + game->requestNightDayTransition(false); + }); + + api.set_function("set_night", + [game]() { + game->requestNightDayTransition(true); + std::cout << "Set night called" << std::endl; + }); + // advance_darklands_hud() // Advances the uni_interior darklands HUD from step12 to step13. // Call when the player enters the ghost trigger zone in darklands.