Fixing inconsistency between day and nights on uni_int location

This commit is contained in:
Vladislav Khorev 2026-06-11 21:19:39 +03:00
parent f52b6872b0
commit a9f4025333
10 changed files with 154 additions and 54 deletions

View File

@ -18,7 +18,7 @@
"hysteresis": 0.5, "hysteresis": 0.5,
"enabled": true "enabled": true
},{ },{
"id": "darklands_exit002", "id": "darklands_exit003",
"positionX": 13.3522, "positionX": 13.3522,
"positionY": 0.0, "positionY": 0.0,
"positionZ": -10.0046, "positionZ": -10.0046,
@ -26,13 +26,21 @@
"hysteresis": 0.5, "hysteresis": 0.5,
"enabled": true "enabled": true
},{ },{
"id": "darklands_exit002", "id": "darklands_exit004",
"positionX": 9.92273, "positionX": 9.92273,
"positionY": 0.0, "positionY": 0.0,
"positionZ": -15.5795, "positionZ": -15.5795,
"radius": 3.3, "radius": 3.3,
"hysteresis": 0.5, "hysteresis": 0.5,
"enabled": true "enabled": true
},{
"id": "darklands_exit005",
"positionX": 8.57705,
"positionY": 0.0,
"positionZ": -4.06573,
"radius": 5.0,
"hysteresis": 0.7,
"enabled": true
} }
] ]
} }

View File

@ -658,7 +658,7 @@
"type": "Line", "type": "Line",
"speaker": "Бекзат", "speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png", "portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Мне некогда деградировать, мне нужно сегодня 100% быть на лекции!", "text": "Мне некогда деградировать сегодня, у меня много дел!",
"next": "end_1" "next": "end_1"
}, },
{ {

View File

@ -206,7 +206,7 @@
"type": "Line", "type": "Line",
"speaker": "Бекзат", "speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png", "portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Мне некогда деградировать, мне нужно сегодня 100% быть на лекции!", "text": "Мне некогда деградировать сегодня, у меня много дел!",
"next": "end_1" "next": "end_1"
}, },
{ {

View File

@ -1266,7 +1266,7 @@
"type": "Line", "type": "Line",
"speaker": "Бекзат", "speaker": "Бекзат",
"portrait": "resources/dialogue/portrait_hero_neutral.png", "portrait": "resources/dialogue/portrait_hero_neutral.png",
"text": "Мне некогда деградировать сейчас!", "text": "Мне некогда деградировать сегодня, у меня много дел!",
"next": "end_1" "next": "end_1"
}, },
{ {

View File

@ -106,6 +106,9 @@ function on_bed_sleep()
game_api.setIntValue("need_sleep", 0) game_api.setIntValue("need_sleep", 0)
game_api.set_player_hp(200) game_api.set_player_hp(200)
--game_api.set_day() - done in cutscene --game_api.set_day() - done in cutscene
local day = game_api.getIntValue("day")
game_api.setIntValue("day", day+1)
print("Setting to day 1----x")
end end
end end

View File

@ -84,6 +84,15 @@ game_api.set_trigger_zone_callbacks("darklands_exit003",
darklands_exit001_enter_callback, darklands_exit001_enter_callback,
nil nil
) )
game_api.set_trigger_zone_callbacks("darklands_exit004",
darklands_exit001_enter_callback,
nil
)
game_api.set_trigger_zone_callbacks("darklands_exit005",
darklands_exit001_enter_callback,
nil
)
function taxi_zone001_enter_callback() function taxi_zone001_enter_callback()

View File

@ -8,11 +8,21 @@ player_hold_key = false
teacher_arrived = false teacher_arrived = false
teacher_told_about_book = false teacher_told_about_book = false
night_time = false
--player_left_darklands = false --player_left_darklands = false
was_darklands = false --was_darklands = false
--[[
0 - day0
1 - darklands
2 - morning
3 - night
4 - day
]]
was_state_when_player_left = 0
was_day_when_player_left = 0
morning_can_open_door_index = 0 morning_can_open_door_index = 0
morning_did_open_door_index = 0 morning_did_open_door_index = 0
@ -58,7 +68,7 @@ function knife_dialog_zone001_enter_callback()
game_api.switch_navigation(4) game_api.switch_navigation(4)
end end
else else
if (night_time == false) then if (game_api.is_night() == false) then
game_api.start_dialogue("knife_dialog_second001") game_api.start_dialogue("knife_dialog_second001")
game_api.set_trigger_zone_enabled(1, false) game_api.set_trigger_zone_enabled(1, false)
end end
@ -103,7 +113,7 @@ function on_book_pickup()
if (teacher_told_about_book) then if (teacher_told_about_book) then
print("on_book_pickup step1") print("on_book_pickup step1")
if not player_hold_book then if not player_hold_book then
if (night_time) or (day >= 1) then if (game_api.is_night()) or (day >= 1) then
game_api.start_dialogue("book_dialog006") game_api.start_dialogue("book_dialog006")
else else
game_api.pickup_item("book") game_api.pickup_item("book")
@ -224,7 +234,7 @@ function on_library_door_click()
local day = game_api.getIntValue("day") local day = game_api.getIntValue("day")
if (day == 0) then if (day == 0) then
if (night_time) then if (game_api.is_night()) then
game_api.start_dialogue("door_night_dialog001") game_api.start_dialogue("door_night_dialog001")
else else
if (not lection_is_over) then if (not lection_is_over) then
@ -247,13 +257,6 @@ function on_library_door_click()
print("Library door step 4") print("Library door step 4")
end end
print("Library door step5") print("Library door step5")
--[[
if (game_api.is_night() and not game.is_dawn()) then
game_api.start_dialogue("door_dialog001")
end
if (game_api.is_night() and game.is_dawn() and not (morning_did_open_door_index == 4) then
game_api.start_dialogue("door_dialog001")
end]]
end end
print("Library door step 5") print("Library door step 5")
end end
@ -266,7 +269,7 @@ function on_teachers_door_click()
print("day is") print("day is")
print(day) print(day)
if (day == 0) then if (day == 0) and not game_api.is_dawn() then
if (player_hold_key) then if (player_hold_key) then
if (not teacher_door_opened) then if (not teacher_door_opened) then
teacher_door_opened = true teacher_door_opened = true
@ -373,7 +376,7 @@ function on_hall_door_click()
local day = game_api.getIntValue("day") local day = game_api.getIntValue("day")
if (day == 0) then if (day == 0) and not game_api.is_dawn() then
if (not hall_door_opened) then if (not hall_door_opened) then
hall_door_opened = true hall_door_opened = true
game_api.switch_navigation(1) game_api.switch_navigation(1)
@ -499,7 +502,7 @@ function book_dialog_zone001_enter_callback()
game_api.advance_darklands_hud() game_api.advance_darklands_hud()
else else
print("book_dialog_zone001_enter_callback step 3") print("book_dialog_zone001_enter_callback step 3")
if (player_hold_book) and (night_time == false) then if (player_hold_book) and (game_api.is_night() == false) then
print("book_dialog_zone001_enter_callback step 4") print("book_dialog_zone001_enter_callback step 4")
game_api.start_dialogue("book_dialog001") game_api.start_dialogue("book_dialog001")
game_api.switch_navigation(0) game_api.switch_navigation(0)
@ -510,7 +513,7 @@ end
function book_dialog_zone001_exit_callback() function book_dialog_zone001_exit_callback()
print("book_dialog_zone001_exit_callback step 1") print("book_dialog_zone001_exit_callback step 1")
if (player_hold_book) and (night_time == false) then if (player_hold_book) and (game_api.is_night() == false) then
game_api.switch_navigation(3) game_api.switch_navigation(3)
end end
end end
@ -519,17 +522,15 @@ function on_computer_clicked()
print("on_computer_clicked--") print("on_computer_clicked--")
local day = game_api.getIntValue("day") local day = game_api.getIntValue("day")
if (day == 1) then if game_api.is_darklands() then
-- TODO: some dialog like I don't need it game_api.start_dialogue("computer_dialog004")
elseif (day >= 1) or game_api.is_dawn() then
print("on_computer_clicked--1") print("on_computer_clicked--1")
game_api.start_dialogue("computer_dialog003") game_api.start_dialogue("computer_dialog003")
else else
if game_api.is_darklands() then
game_api.start_dialogue("computer_dialog004")
else
if teacher_told_about_book then if teacher_told_about_book then
print("on_computer_clicked--2") print("on_computer_clicked--2")
if (night_time == false) then if (game_api.is_night() == false) then
print("on_computer_clicked--3") print("on_computer_clicked--3")
if (player_hold_book) then if (player_hold_book) then
print("on_computer_clicked--4") print("on_computer_clicked--4")
@ -547,13 +548,12 @@ function on_computer_clicked()
print("on_computer_clicked--7") print("on_computer_clicked--7")
game_api.start_dialogue("computer_dialog001") game_api.start_dialogue("computer_dialog001")
end end
end
end end
end end
function on_sleep_cutscene() function on_sleep_cutscene()
print("Cutscene 2 done!") print("Cutscene 2 done!")
night_time = true
game_api.set_night() game_api.set_night()
--game_api.set_trigger_zone_enabled(1, false) --game_api.set_trigger_zone_enabled(1, false)
game_api.set_npc_enabled(0, false) game_api.set_npc_enabled(0, false)
@ -662,8 +662,6 @@ game_api.set_darklands_callbacks(
game_api.npc_set_position(5, 5.0, 0, 12) game_api.npc_set_position(5, 5.0, 0, 12)
end end
night_time = false
game_api.switch_navigation(5) game_api.switch_navigation(5)
end, end,
function() function()
@ -674,8 +672,7 @@ game_api.set_darklands_callbacks(
game_api.set_npc_enabled(3, false) game_api.set_npc_enabled(3, false)
game_api.set_npc_enabled(4, false) game_api.set_npc_enabled(4, false)
game_api.set_npc_enabled(5, false) game_api.set_npc_enabled(5, false)
game_api.setIntValue("day", 1)
print("Setting to day 1----x")
--game_api.setIntValue("need_sleep", 1) --game_api.setIntValue("need_sleep", 1)
--player_left_darklands = true --player_left_darklands = true
morning_did_open_door_index = 0 morning_did_open_door_index = 0
@ -902,7 +899,7 @@ function setDay1MorningSetup()
end end
function setDay1NightSetup() function setDay1NightSetup()
night_time = true
teacher_door_opened = false teacher_door_opened = false
print("setDay1NightSetup") print("setDay1NightSetup")
@ -1168,6 +1165,67 @@ game_api.set_location_callbacks(
print("day is:") print("day is:")
print(day) print(day)
local resetState = false
if not (day == was_day_when_player_left) then
resetState = true
elseif (was_state_when_player_left == 1) and game_api.is_darklands() == false then
resetState = true
elseif (was_state_when_player_left == 2) and (game_api.is_darklands() or game_api.is_dawn() == false) then
resetState = true
elseif (was_state_when_player_left == 3) and (game_api.is_darklands() or game_api.is_night() == false) then
resetState = true
elseif (was_state_when_player_left == 4) and (game_api.is_night() or game_api.is_darklands()) then
resetState = true
end
if (day > 0) and resetState then
if (game_api.is_darklands()) then
--Currently not possible
print("Entered darklands setup")
elseif (game_api.is_dawn()) then
print("setDay1MorningSetup entered-")
setDay1MorningSetup()
elseif (game_api.is_night()) then
print("entered night setup")
setDay1NightSetup()
game_api.switch_navigation(17)
else
print("entered day setup")
setDay1setup()
game_api.switch_navigation(3)
end
end
--[[
local day = game_api.getIntValue("day")
if (day == 0)then
was_state_when_player_left = 0
elseif game_api.is_darklands() then
was_state_when_player_left = 1
elseif game_api.is_dawn() then
was_state_when_player_left = 2
elseif game_api.is_night() then
was_state_when_player_left = 3
else
was_state_when_player_left = 4
end
possible situation combinations:
left from darklands
left from morning
left from day
left from night
arrive in darklands
arrive in morning
arrive in day
arrive in night
]]
if (day > 0) and (game_api.is_night() == false) then if (day > 0) and (game_api.is_night() == false) then
print("entered day setup") print("entered day setup")
setDay1setup() setDay1setup()
@ -1182,18 +1240,6 @@ game_api.set_location_callbacks(
setDay1MorningSetup() setDay1MorningSetup()
end end
--[[
local need_sleep = game_api.getIntValue("need_sleep")
local day = game_api.getIntValue("day")
if (day > 0) and (need_sleep == 1) then
setDay1MorningSetup()
elseif (day > 0) then
setDay1setup()
game_api.switch_navigation(3)
else
--Do nothing, it should have been already set up
end]]
end, end,
function() function()
print("Exit location uni interior") print("Exit location uni interior")
@ -1201,7 +1247,30 @@ game_api.set_location_callbacks(
local hp = game_api.get_player_hp() local hp = game_api.get_player_hp()
game_api.setFloatValue("player_hp", hp) game_api.setFloatValue("player_hp", hp)
was_darklands = game_api.is_darklands()
--[[
0 - day0
1 - darklands
2 - morning
3 - night
4 - day
]]
local day = game_api.getIntValue("day")
was_day_when_player_left = day
if (day == 0)then
was_state_when_player_left = 0
elseif game_api.is_darklands() then
was_state_when_player_left = 1
elseif game_api.is_dawn() then
was_state_when_player_left = 2
elseif game_api.is_night() then
was_state_when_player_left = 3
else
was_state_when_player_left = 4
end
end end
) )

View File

@ -65,7 +65,7 @@ namespace ZL
Game::Game() Game::Game()
: newTickCount(0) : newTickCount(0)
, lastTickCount(0) , lastTickCount(0)
, menuManager(renderer) , menuManager(renderer, globalInts)
, audioPlayer(std::make_unique<AudioPlayerAsync>()) , audioPlayer(std::make_unique<AudioPlayerAsync>())
{ {
} }

View File

@ -75,8 +75,9 @@ namespace ZL {
} }
} }
MenuManager::MenuManager(Renderer& iRenderer) : MenuManager::MenuManager(Renderer& iRenderer, std::unordered_map<std::string, int>& globalInts) :
renderer(iRenderer) renderer(iRenderer),
globalInts(globalInts)
{ {
} }
@ -492,13 +493,22 @@ namespace ZL {
}); });
uiManager.setButtonCallback("videoSkip", [this](const std::string&) { uiManager.setButtonCallback("videoSkip", [this](const std::string&) {
closePhoneEntirely(); closePhoneEntirely();
if (isNight) if (isNight)
{ {
startDialogueFunc("dialog_video002"); startDialogueFunc("dialog_video002");
} }
else else
{ {
startNightTransitionFunc(); auto day = globalInts["day"];
if (day == 0)
{
startDialogueFunc("dialog_video003");
}
else
{
startNightTransitionFunc();
}
} }
}); });
} }

View File

@ -38,13 +38,14 @@ namespace ZL {
UiManager uiManager; UiManager uiManager;
UiManager topUiManager; UiManager topUiManager;
ZL::Quest::QuestJournal questJournal; ZL::Quest::QuestJournal questJournal;
std::unordered_map<std::string, int>& globalInts;
// Global night mode state — persists across location transitions. // Global night mode state — persists across location transitions.
bool isNight = false; bool isNight = false;
bool isDawn = false; // sub-variant of night: brighter pink ambient, same lighting bool isDawn = false; // sub-variant of night: brighter pink ambient, same lighting
MenuManager(Renderer& iRenderer); MenuManager(Renderer& iRenderer, std::unordered_map<std::string, int>& globalInts);
void setup(Inventory& inv, const std::string& zipFile); void setup(Inventory& inv, const std::string& zipFile);