Working on night mode and how player goes in

This commit is contained in:
Vladislav Khorev 2026-06-04 21:41:32 +03:00
parent 1d3bea452c
commit 9221ab68ac
8 changed files with 550 additions and 274 deletions

View File

@ -1,17 +1,88 @@
{ {
"lights": [ "lights": [
{ {
"id": "lamp_library", "id": "lamp_library",
"positionX": 3.76222, "positionX": 3.76222,
"positionY": 5.0, "positionY": 5.0,
"positionZ": 4.16035, "positionZ": 4.16035,
"directionX": 0.0, "directionX": 0.0,
"directionY": -1.0, "directionY": -1.0,
"directionZ": 0.0, "directionZ": 0.0,
"colorR": 4.0, "colorR": 4.0,
"colorG": 3.2, "colorG": 3.2,
"colorB": 2.4, "colorB": 2.4,
"autoLight": false "autoLight": true,
} "autoLightDistance": 6.0
] },
{
"id": "lamp_teacher_room",
"positionX": -4.15666,
"positionY": 5.0,
"positionZ": 4.27091,
"directionX": 0.0,
"directionY": -1.0,
"directionZ": 0.0,
"colorR": 4.0,
"colorG": 3.2,
"colorB": 2.4,
"autoLight": true,
"autoLightDistance": 6.0
},
{
"id": "lamp_student_room",
"positionX": 3.60541,
"positionY": 5.0,
"positionZ": -4.36552,
"directionX": 0.0,
"directionY": -1.0,
"directionZ": 0.0,
"colorR": 4.0,
"colorG": 3.2,
"colorB": 2.4,
"autoLight": true,
"autoLightDistance": 6.0
},
{
"id": "lamp_s1_room",
"positionX": -3.90337,
"positionY": 5.0,
"positionZ": -4.00563,
"directionX": 0.0,
"directionY": -1.0,
"directionZ": 0.0,
"colorR": 4.0,
"colorG": 3.2,
"colorB": 2.4,
"autoLight": true,
"autoLightDistance": 6.0
},
{
"id": "lamp_s0_room",
"positionX": -3.90337,
"positionY": 5.0,
"positionZ": -12.485,
"directionX": 0.0,
"directionY": -1.0,
"directionZ": 0.0,
"colorR": 4.0,
"colorG": 3.2,
"colorB": 2.4,
"autoLight": true,
"autoLightDistance": 6.0
},
{
"id": "lamp_hall_room",
"positionX": 0.0,
"positionY": 5.0,
"positionZ": 11.7949,
"directionX": 0.0,
"directionY": -1.0,
"directionZ": 0.0,
"colorR": 4.0,
"colorG": 3.2,
"colorB": 2.4,
"autoLight": true,
"autoLightDistance": 6.0
}
]
} }

View File

@ -192,6 +192,12 @@ function on_player_door_click()
end end
game_api.set_enter_night_callback(
function()
game_api.start_dialogue("dialog_video001")
end
)
game_api.set_location_callbacks( game_api.set_location_callbacks(
function() function()
print("Enter location dorm") print("Enter location dorm")
@ -207,14 +213,6 @@ game_api.set_location_callbacks(
game_api.deactivate_interactive_object("Room_Cover_LivingRoom_W_N_2_001") game_api.deactivate_interactive_object("Room_Cover_LivingRoom_W_N_2_001")
--debug
--game_api.deactivate_interactive_object("Room_Cover_Bath_W_N_2_001")
--game_api.deactivate_interactive_object("Room_Cover_LivingRoom_W_S_2_001")
--game_api.deactivate_interactive_object("Room_Cover_Main_Hall_And_Corridors_002")
--game_api.deactivate_interactive_object("Room_Cover_Utility_W_N_3_001")
--game_api.deactivate_interactive_object("Room_Cover_Utility_W_S_3_001")
--debug end
game_api.rotate_object("Door_Utility_-1_1_2_Leaf_001", 90, 0.01, nil) game_api.rotate_object("Door_Utility_-1_1_2_Leaf_001", 90, 0.01, nil)
game_api.rotate_object("Door_Utility_-1_-1_2_Leaf_001", -90, 0.01, nil) game_api.rotate_object("Door_Utility_-1_-1_2_Leaf_001", -90, 0.01, nil)

View File

@ -32,6 +32,12 @@ game_api.start_dialogue("dialog_contaier001")
end end
end end
game_api.set_enter_night_callback(
function()
game_api.start_dialogue("dialog_video001")
end
)
game_api.set_darklands_callbacks( game_api.set_darklands_callbacks(
nil, nil,
function() function()

View File

@ -1,5 +1,3 @@
hall_door_opened = false hall_door_opened = false
teacher_door_opened = false teacher_door_opened = false
lection_is_over = false lection_is_over = false
@ -23,27 +21,27 @@ player_ghost_aware = false
ghost_gone = false ghost_gone = false
function dialog_aiperi_give_key() function dialog_aiperi_give_key()
if (player_hold_key == false) then if (player_hold_key == false) then
game_api.pickup_item("teacher_room_key") game_api.pickup_item("teacher_room_key")
game_api.quest_unlock("aiperi_knife") game_api.quest_unlock("aiperi_knife")
game_api.quest_set_objective_completed("aiperi_knife", "aiperi_knife_keys") game_api.quest_set_objective_completed("aiperi_knife", "aiperi_knife_keys")
player_hold_key = true player_hold_key = true
end end
end end
function lection_hall_zone001_enter_callback() function lection_hall_zone001_enter_callback()
--game_api.start_dialogue("") --game_api.start_dialogue("")
--Start cutscene --Start cutscene
if (lection_is_over == false) then if (lection_is_over == false) then
game_api.player_stop() game_api.player_stop()
game_api.start_cutscene("test_cutscene_01") game_api.start_cutscene("test_cutscene_01")
game_api.quest_set_objective_completed("study_beginning", "study_beginning_lecture") game_api.quest_set_objective_completed("study_beginning", "study_beginning_lecture")
end end
end end
game_api.set_trigger_zone_callbacks("lection_hall_zone001", game_api.set_trigger_zone_callbacks("lection_hall_zone001",
lection_hall_zone001_enter_callback, lection_hall_zone001_enter_callback,
nil nil
) )
function knife_dialog_zone001_enter_callback() function knife_dialog_zone001_enter_callback()
@ -51,21 +49,21 @@ function knife_dialog_zone001_enter_callback()
local day = game_api.getIntValue("day") local day = game_api.getIntValue("day")
if (day == 0) then if (day == 0) then
if (player_hold_knife == false) then if (player_hold_knife == false) then
if lection_is_over then if lection_is_over then
if (player_hold_key) then if (player_hold_key) then
game_api.start_dialogue("knife_dialog002") game_api.start_dialogue("knife_dialog002")
else
game_api.start_dialogue("knife_dialog001")
end
game_api.switch_navigation(4)
end
else else
game_api.start_dialogue("knife_dialog001") if (night_time == false) then
game_api.start_dialogue("knife_dialog_second001")
game_api.set_trigger_zone_enabled(1, false)
end
end end
game_api.switch_navigation(4)
end
else
if (night_time == false) then
game_api.start_dialogue("knife_dialog_second001")
game_api.set_trigger_zone_enabled(1, false)
end
end
end end
end end
@ -73,31 +71,31 @@ function knife_dialog_zone001_exit_callback()
local day = game_api.getIntValue("day") local day = game_api.getIntValue("day")
if (day == 0) then if (day == 0) then
print("knife_dialog_zone001_exit_callback--!") print("knife_dialog_zone001_exit_callback--!")
if (lection_is_over) then if (lection_is_over) then
if (teacher_door_opened) then if (teacher_door_opened) then
game_api.switch_navigation(3) game_api.switch_navigation(3)
else else
game_api.switch_navigation(2) game_api.switch_navigation(2)
end end
end end
end end
end end
game_api.set_trigger_zone_callbacks("knife_dialog_zone001", game_api.set_trigger_zone_callbacks("knife_dialog_zone001",
knife_dialog_zone001_enter_callback, knife_dialog_zone001_enter_callback,
knife_dialog_zone001_exit_callback knife_dialog_zone001_exit_callback
) )
function on_knife_pickup() function on_knife_pickup()
game_api.pickup_item("knife") game_api.pickup_item("knife")
game_api.deactivate_interactive_object("Knife001") game_api.deactivate_interactive_object("Knife001")
game_api.set_npc_enabled(1, false) game_api.set_npc_enabled(1, false)
player_hold_knife = true player_hold_knife = true
game_api.set_trigger_zone_enabled(2, true) game_api.set_trigger_zone_enabled(2, true)
game_api.npc_walk_to(0, -4.57412, 0, 6.78495, on_teacher_arrived2) game_api.npc_walk_to(0, -4.57412, 0, 6.78495, on_teacher_arrived2)
game_api.quest_set_objective_completed("aiperi_knife", "aiperi_knife_take") game_api.quest_set_objective_completed("aiperi_knife", "aiperi_knife_take")
end end
function on_book_pickup() function on_book_pickup()
@ -105,27 +103,27 @@ function on_book_pickup()
local day = game_api.getIntValue("day") local day = game_api.getIntValue("day")
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 (night_time) or (day >= 1) then
game_api.start_dialogue("book_dialog006") game_api.start_dialogue("book_dialog006")
else
game_api.pickup_item("book")
game_api.deactivate_interactive_object("Book001")
player_hold_book = true
game_api.quest_set_objective_completed("study_project", "study_project_book")
game_api.start_dialogue("book_dialog003")
--game_api.set_trigger_zone_enabled(3, true)
end
else else
game_api.pickup_item("book") game_api.remove_item("book")
game_api.deactivate_interactive_object("Book001") game_api.activate_interactive_object("Book001")
player_hold_book = true player_hold_book = false
game_api.quest_set_objective_completed("study_project", "study_project_book") game_api.start_dialogue("book_dialog004")
game_api.start_dialogue("book_dialog003") --game_api.set_trigger_zone_enabled(3, false)
--game_api.set_trigger_zone_enabled(3, true)
end end
else else
game_api.remove_item("book") print("on_book_pickup step2")
game_api.activate_interactive_object("Book001") game_api.start_dialogue("book_dialog005")
player_hold_book = false
game_api.start_dialogue("book_dialog004")
--game_api.set_trigger_zone_enabled(3, false)
end
else
print("on_book_pickup step2")
game_api.start_dialogue("book_dialog005")
end end
end end
@ -144,36 +142,30 @@ function on_bookshelf_clicked()
on_book_pickup() on_book_pickup()
end end
function on_npc_interact(npc_index) function on_npc_interact(npc_index)
print("[Lua] NPC interaction! Index: " .. tostring(npc_index)) print("[Lua] NPC interaction! Index: " .. tostring(npc_index))
if npc_index == 1 then if npc_index == 1 then
local day = game_api.getIntValue("day")
local day = game_api.getIntValue("day") if (day == 0) then
if (player_hold_key) then
if (day == 0) then
if (player_hold_key) then
game_api.start_dialogue("knife_dialog002") game_api.start_dialogue("knife_dialog002")
else else
game_api.start_dialogue("knife_dialog001") game_api.start_dialogue("knife_dialog001")
end
else
if (player_ghost_aware) then
local player_alik_aware = game_api.getIntValue("player_alik_aware")
if player_alik_aware == 1 then
game_api.start_dialogue("aiperi_dialog002")
else
game_api.start_dialogue("aiperi_dialog001")
game_api.setIntValue("player_alik_aware", 1)
end end
else else
if (player_ghost_aware) then game_api.start_dialogue("aiperi_dialog003")
local player_alik_aware = game_api.getIntValue("player_alik_aware")
if player_alik_aware ==1 then
game_api.start_dialogue("aiperi_dialog002")
else
game_api.start_dialogue("aiperi_dialog001")
game_api.setIntValue("player_alik_aware", 1)
end
else
game_api.start_dialogue("aiperi_dialog003")
end
end end
end
end end
if npc_index == 0 then if npc_index == 0 then
if (player_ghost_aware) then if (player_ghost_aware) then
@ -184,7 +176,7 @@ function on_npc_interact(npc_index)
if (report_card_signed == 1) then if (report_card_signed == 1) then
game_api.start_dialogue("teacher_dialog002") game_api.start_dialogue("teacher_dialog002")
elseif (player_has_coursework == 1 and player_has_report_card==1) then elseif (player_has_coursework == 1 and player_has_report_card == 1) then
game_api.start_dialogue("teacher_dialog005") game_api.start_dialogue("teacher_dialog005")
game_api.remove_item("coursework") game_api.remove_item("coursework")
game_api.setIntValue("report_card_signed", 1) game_api.setIntValue("report_card_signed", 1)
@ -199,52 +191,60 @@ function on_npc_interact(npc_index)
end end
if npc_index == 2 then if npc_index == 2 then
if (player_ghost_aware) then if (player_ghost_aware) then
local report_card_signed = game_api.getIntValue("report_card_signed") local report_card_signed = game_api.getIntValue("report_card_signed")
if (report_card_signed==1) then if (report_card_signed == 1) then
game_api.start_dialogue("dialog_with_ghost003") game_api.start_dialogue("dialog_with_ghost003")
else
game_api.start_dialogue("dialog_with_ghost002")
end
else else
game_api.start_dialogue("dialog_with_ghost002") game_api.start_dialogue("dialog_with_ghost001")
end --player_ghost_aware = true
else
game_api.start_dialogue("dialog_with_ghost001")
--player_ghost_aware = true
end end
end end
end end
function on_quest_over() function on_quest_over()
ghost_gone = true ghost_gone = true
game_api.set_npc_enabled(2, false) game_api.set_npc_enabled(2, false)
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.quest_set_objective_completed("ghost_release", "ghost_release_show") game_api.quest_set_objective_completed("ghost_release", "ghost_release_show")
end end
function on_first_ghost_dialog_over() function on_first_ghost_dialog_over()
print("on_first_ghost_dialog_over") print("on_first_ghost_dialog_over")
player_ghost_aware = true player_ghost_aware = true
game_api.quest_unlock("ghost_lore") game_api.quest_unlock("ghost_lore")
end end
function on_darklands_over() function on_darklands_over()
game_api.set_player_hp(10) game_api.set_player_hp(10)
game_api.resetPlayerAfterDeath() game_api.resetPlayerAfterDeath()
end end
function teacher_zone001_enter_callback() function teacher_zone001_enter_callback()
game_api.start_dialogue("teacher_dialog002") game_api.start_dialogue("teacher_dialog002")
game_api.set_trigger_zone_enabled(2, false) game_api.set_trigger_zone_enabled(2, false)
teacher_told_about_book = true teacher_told_about_book = true
game_api.player_stop() game_api.player_stop()
end end
function on_library_door_click() function on_library_door_click()
print("on_library_door_click---") print("on_library_door_click---")
if (player_left_darklands) then local day = game_api.getIntValue("day")
if (morning_can_open_door_index==5) then
if (day == 0) then
if (night_time) then
game_api.start_dialogue("door_night_dialog001")
else
if (not lection_is_over) then
game_api.start_dialogue("door_dialog001")
end
end
else
if (morning_can_open_door_index == 5) then
if (morning_did_open_door_index == 0) then if (morning_did_open_door_index == 0) then
morning_did_open_door_index = 5 morning_did_open_door_index = 5
game_api.start_dialogue("door_unlock_dialog001") game_api.start_dialogue("door_unlock_dialog001")
@ -258,17 +258,75 @@ function on_library_door_click()
game_api.start_dialogue("door_dialog001") game_api.start_dialogue("door_dialog001")
end end
elseif (night_time) then end
--[[
--if (player_left_darklands) then
if (morning_can_open_door_index == 5) then
if (morning_did_open_door_index == 0) then
morning_did_open_door_index = 5
game_api.start_dialogue("door_unlock_dialog001")
game_api.rotate_object("Room_N_2_Leaf001", -90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end)
game_api.switch_navigation(12)
end
elseif (night_time && day == 0) 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
game_api.start_dialogue("door_dialog001") game_api.start_dialogue("door_dialog001")
end end
end end]]
end end
function on_teachers_door_click() function on_teachers_door_click()
print("on_teachers_door_click---") print("on_teachers_door_click---")
local day = game_api.getIntValue("day")
print("day is")
print(day)
if (day == 0) then
if (player_hold_key) then
if (not teacher_door_opened) then
teacher_door_opened = true
game_api.rotate_object("Room_S_2_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_South_3_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
end)
game_api.switch_navigation(3)
end
else
game_api.start_dialogue("door_teacher_dialog001")
end
else
print("morning_can_open_door_index is")
print(morning_can_open_door_index)
if (morning_can_open_door_index == 3) then
print("morning_did_open_door_index is")
print(morning_did_open_door_index)
if (morning_did_open_door_index == 0) then
morning_did_open_door_index = 3
game_api.start_dialogue("door_unlock_dialog001")
game_api.rotate_object("Room_S_2_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end)
game_api.switch_navigation(10)
end
else
game_api.start_dialogue("door_dialog001")
end
end
--[[
if (player_left_darklands) then if (player_left_darklands) then
if (morning_can_open_door_index == 3) then if (morning_can_open_door_index == 3) then
if (morning_did_open_door_index == 0) then if (morning_did_open_door_index == 0) then
@ -277,28 +335,59 @@ function on_teachers_door_click()
game_api.rotate_object("Room_S_2_Leaf001", 90, 0.5, nil) game_api.rotate_object("Room_S_2_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function() game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001") game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end) end)
game_api.switch_navigation(10) game_api.switch_navigation(10)
end end
else else
game_api.start_dialogue("door_dialog001") game_api.start_dialogue("door_dialog001")
end end
elseif (not player_hold_key) then elseif (not player_hold_key) then
game_api.start_dialogue("door_teacher_dialog001") game_api.start_dialogue("door_teacher_dialog001")
elseif (not teacher_door_opened) then elseif (not teacher_door_opened) then
teacher_door_opened = true teacher_door_opened = true
game_api.rotate_object("Room_S_2_Leaf001", 90, 0.5, nil) game_api.rotate_object("Room_S_2_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_South_3_001", 0, 0.5, function() game_api.fade_object("Room_Cover_South_3_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_South_3_001") game_api.deactivate_interactive_object("Room_Cover_South_3_001")
end) end)
game_api.switch_navigation(3) game_api.switch_navigation(3)
end end]]
end end
function on_hall_door_click() function on_hall_door_click()
print("on_hall_door_click---") print("on_hall_door_click---")
local day = game_api.getIntValue("day")
if (day == 0) then
if (not hall_door_opened) then
hall_door_opened = true
game_api.switch_navigation(1)
game_api.rotate_object("Hall_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_Main_Hall_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001")
end)
game_api.set_npc_enabled(0, true)
end
else
if (morning_can_open_door_index == 6) then
if (morning_did_open_door_index == 0) then
morning_did_open_door_index = 6
game_api.start_dialogue("door_unlock_dialog001")
game_api.rotate_object("Hall_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end)
game_api.switch_navigation(13)
end
else
game_api.start_dialogue("door_dialog001")
end
end
--[[
if (player_left_darklands) then if (player_left_darklands) then
if (morning_can_open_door_index == 6) then if (morning_can_open_door_index == 6) then
if (morning_did_open_door_index == 0) then if (morning_did_open_door_index == 0) then
@ -307,14 +396,13 @@ function on_hall_door_click()
game_api.rotate_object("Hall_Leaf001", 90, 0.5, nil) game_api.rotate_object("Hall_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function() game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001") game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end) end)
game_api.switch_navigation(13) game_api.switch_navigation(13)
end end
else else
game_api.start_dialogue("door_dialog001") game_api.start_dialogue("door_dialog001")
end end
elseif (not hall_door_opened) then elseif (not hall_door_opened) then
hall_door_opened = true hall_door_opened = true
game_api.switch_navigation(1) game_api.switch_navigation(1)
@ -323,33 +411,37 @@ function on_hall_door_click()
game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001") game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001")
end) end)
game_api.set_npc_enabled(0, true) game_api.set_npc_enabled(0, true)
end end]]
end end
function on_s1_door_click() function on_s1_door_click()
if (player_left_darklands) then
if (morning_can_open_door_index==1) then
--if (player_left_darklands) then
if (morning_can_open_door_index == 1) then
if (morning_did_open_door_index == 0) then if (morning_did_open_door_index == 0) then
morning_did_open_door_index = 1 morning_did_open_door_index = 1
game_api.start_dialogue("door_unlock_dialog001") game_api.start_dialogue("door_unlock_dialog001")
game_api.rotate_object("Room_S_0_Leaf001", 90, 0.5, nil) game_api.rotate_object("Room_S_0_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function() game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001") game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end) end)
game_api.switch_navigation(8) game_api.switch_navigation(8)
end end
else else
game_api.start_dialogue("door_dialog001") game_api.start_dialogue("door_dialog001")
end end
else --else
game_api.start_dialogue("door_dialog001") -- game_api.start_dialogue("door_dialog001")
end --end
end end
function on_s2_door_click() function on_s2_door_click()
if (player_left_darklands) then --if (player_left_darklands) then
if (morning_can_open_door_index == 2) then if (morning_can_open_door_index == 2) then
if (morning_did_open_door_index == 0) then if (morning_did_open_door_index == 0) then
morning_did_open_door_index = 2 morning_did_open_door_index = 2
@ -357,16 +449,16 @@ function on_s2_door_click()
game_api.rotate_object("Room_S_1_Leaf001", 90, 0.5, nil) game_api.rotate_object("Room_S_1_Leaf001", 90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function() game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001") game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end) end)
game_api.switch_navigation(9) game_api.switch_navigation(9)
end end
else else
game_api.start_dialogue("door_dialog001") game_api.start_dialogue("door_dialog001")
end end
else --else
game_api.start_dialogue("door_dialog001") -- game_api.start_dialogue("door_dialog001")
end --end
end end
function on_n2_door_click() function on_n2_door_click()
@ -376,15 +468,15 @@ function on_n2_door_click()
print(morning_can_open_door_index) print(morning_can_open_door_index)
print("morning_did_open_door_index") print("morning_did_open_door_index")
print(morning_did_open_door_index) print(morning_did_open_door_index)
if (player_left_darklands) then --if (player_left_darklands) then
if (morning_can_open_door_index==4) then if (morning_can_open_door_index == 4) then
if (morning_did_open_door_index == 0) then if (morning_did_open_door_index == 0) then
morning_did_open_door_index = 4 morning_did_open_door_index = 4
game_api.start_dialogue("door_unlock_dialog001") game_api.start_dialogue("door_unlock_dialog001")
game_api.rotate_object("Room_N_1_Leaf001", -90, 0.5, nil) game_api.rotate_object("Room_N_1_Leaf001", -90, 0.5, nil)
game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function() game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001") game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
end) end)
game_api.switch_navigation(11) game_api.switch_navigation(11)
else else
@ -393,18 +485,17 @@ function on_n2_door_click()
else else
game_api.start_dialogue("door_dialog001") game_api.start_dialogue("door_dialog001")
end end
else --else
game_api.start_dialogue("door_dialog001") -- game_api.start_dialogue("door_dialog001")
end --end
end end
function on_teacher_arrived() function on_teacher_arrived()
print("Teacher arrived") print("Teacher arrived")
end end
function on_teacher_arrived2() function on_teacher_arrived2()
print("Teacher arrived2") print("Teacher arrived2")
end end
function book_dialog_zone001_enter_callback() function book_dialog_zone001_enter_callback()
@ -415,7 +506,6 @@ function book_dialog_zone001_enter_callback()
game_api.set_trigger_zone_enabled(3, false) game_api.set_trigger_zone_enabled(3, false)
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 (night_time == false) then
print("book_dialog_zone001_enter_callback step 4") print("book_dialog_zone001_enter_callback step 4")
@ -426,15 +516,15 @@ function book_dialog_zone001_enter_callback()
end end
end 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 (night_time == false) then
game_api.switch_navigation(3) game_api.switch_navigation(3)
end end
end end
function on_computer_clicked() 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 (day == 1) then
@ -443,30 +533,30 @@ print("on_computer_clicked--")
game_api.start_dialogue("computer_dialog003") game_api.start_dialogue("computer_dialog003")
else 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 (night_time == 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")
game_api.quest_set_objective_completed("study_project", "study_project_write") game_api.quest_set_objective_completed("study_project", "study_project_write")
game_api.start_cutscene("computer_cutscene001") game_api.start_cutscene("computer_cutscene001")
else
print("on_computer_clicked--5")
game_api.start_dialogue("book_dialog002")
end
else else
print("on_computer_clicked--5") print("on_computer_clicked--6")
game_api.start_dialogue("book_dialog002") game_api.start_dialogue("computer_dialog002")
end end
else else
print("on_computer_clicked--6") print("on_computer_clicked--7")
game_api.start_dialogue("computer_dialog002")
end
else
print("on_computer_clicked--7")
game_api.start_dialogue("computer_dialog001") game_api.start_dialogue("computer_dialog001")
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 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)
@ -491,34 +581,31 @@ function on_sleep_cutscene()
end end
function on_teacher_arrived_intermediate() function on_teacher_arrived_intermediate()
game_api.rotate_object("Room_N_2_Leaf001", -90, 0.5, nil) game_api.rotate_object("Room_N_2_Leaf001", -90, 0.5, nil)
game_api.fade_object("Room_Cover_North_3_001", 0, 0.5, function() game_api.fade_object("Room_Cover_North_3_001", 0, 0.5, function()
game_api.deactivate_interactive_object("Room_Cover_North_3_001") game_api.deactivate_interactive_object("Room_Cover_North_3_001")
end) end)
game_api.switch_navigation(2) game_api.switch_navigation(2)
game_api.npc_walk_to(0, 3.19574, 0, 6.45595, on_teacher_arrived) game_api.npc_walk_to(0, 3.19574, 0, 6.45595, on_teacher_arrived)
teacher_arrived = true teacher_arrived = true
end end
game_api.set_cutscene_callback("test_cutscene_01", function() game_api.set_cutscene_callback("test_cutscene_01", function()
print("Cutscene done!") print("Cutscene done!")
lection_is_over = true lection_is_over = true
game_api.set_npc_enabled(1, true) game_api.set_npc_enabled(1, true)
game_api.npc_walk_to(0, 0.758123, 0, 6.50063, on_teacher_arrived_intermediate) game_api.npc_walk_to(0, 0.758123, 0, 6.50063, on_teacher_arrived_intermediate)
end) end)
function on_note_pickup() function on_note_pickup()
game_api.start_dialogue("note_dialog001") game_api.start_dialogue("note_dialog001")
game_api.pickup_item("note_spell") game_api.pickup_item("note_spell")
game_api.deactivate_interactive_object("Note001") game_api.deactivate_interactive_object("Note001")
end end
function on_report_card_pickup() function on_report_card_pickup()
if player_ghost_aware then
if player_ghost_aware then
local player_has_report_card = game_api.getIntValue("player_has_report_card") local player_has_report_card = game_api.getIntValue("player_has_report_card")
local report_card_signed = game_api.getIntValue("report_card_signed") local report_card_signed = game_api.getIntValue("report_card_signed")
@ -531,18 +618,21 @@ if player_ghost_aware then
game_api.setIntValue("player_has_report_card", 1) game_api.setIntValue("player_has_report_card", 1)
game_api.quest_set_objective_completed("ghost_release", "ghost_release_reportcard") game_api.quest_set_objective_completed("ghost_release", "ghost_release_reportcard")
end end
else else
game_api.start_dialogue("dialog_report_card001") game_api.start_dialogue("dialog_report_card001")
end end
end end
function on_bookshelf_teacher_clicked() function on_bookshelf_teacher_clicked()
on_report_card_pickup() on_report_card_pickup()
end end
first_time_darklands = true first_time_darklands = true
game_api.set_darklands_callbacks( game_api.set_darklands_callbacks(
function() function()
if (first_time_darklands) then if (first_time_darklands) then
game_api.start_dialogue("ghost_dialog001") game_api.start_dialogue("ghost_dialog001")
first_time_darklands = false first_time_darklands = false
@ -568,17 +658,17 @@ game_api.set_darklands_callbacks(
game_api.npc_set_hp(4, 35) game_api.npc_set_hp(4, 35)
game_api.npc_set_hp(5, 35) game_api.npc_set_hp(5, 35)
game_api.npc_set_position(3, 0,0,-6.4) game_api.npc_set_position(3, 0, 0, -6.4)
game_api.npc_set_position(4, -5.0,0,12) game_api.npc_set_position(4, -5.0, 0, 12)
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 night_time = false
game_api.switch_navigation(6) game_api.switch_navigation(6)
end, end,
function() function()
game_api.start_cutscene("darklands_exit001") game_api.start_cutscene("darklands_exit001")
game_api.set_npc_enabled(0, false) game_api.set_npc_enabled(0, false)
game_api.set_npc_enabled(1, false) game_api.set_npc_enabled(1, false)
game_api.set_npc_enabled(2, false) game_api.set_npc_enabled(2, false)
@ -600,23 +690,23 @@ game_api.set_darklands_callbacks(
game_api.activate_interactive_object("Room_Cover_Corridor_001") game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001") game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001")
morning_can_open_door_index = 6 morning_can_open_door_index = 6
elseif (pz <= 8.0) and (pz > 0) and (px>=1.5) then elseif (pz <= 8.0) and (pz > 0) and (px >= 1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001") game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_North_3_001") game_api.deactivate_interactive_object("Room_Cover_North_3_001")
morning_can_open_door_index = 5 morning_can_open_door_index = 5
elseif (pz <= 8.0) and (pz > 0) and (px<=-1.5) then elseif (pz <= 8.0) and (pz > 0) and (px <= -1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001") game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_South_3_001") game_api.deactivate_interactive_object("Room_Cover_South_3_001")
morning_can_open_door_index = 3 morning_can_open_door_index = 3
elseif (pz <= 0.0) and (pz > -8) and (px>=1.5) then elseif (pz <= 0.0) and (pz > -8) and (px >= 1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001") game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_North_2_001") game_api.deactivate_interactive_object("Room_Cover_North_2_001")
morning_can_open_door_index = 4 morning_can_open_door_index = 4
elseif (pz <= 0.0) and (pz > -8) and (px<=-1.5) then elseif (pz <= 0.0) and (pz > -8) and (px <= -1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001") game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_South_2_001") game_api.deactivate_interactive_object("Room_Cover_South_2_001")
morning_can_open_door_index = 2 morning_can_open_door_index = 2
elseif (pz <= -8.0) and (px<=-1.5) then elseif (pz <= -8.0) and (px <= -1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001") game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_South_1_001") game_api.deactivate_interactive_object("Room_Cover_South_1_001")
morning_can_open_door_index = 1 morning_can_open_door_index = 1
@ -624,37 +714,37 @@ game_api.set_darklands_callbacks(
--All set before --All set before
morning_can_open_door_index = 0 morning_can_open_door_index = 0
end end
end end
) )
game_api.set_trigger_zone_callbacks("teacher_dialog_zone001", game_api.set_trigger_zone_callbacks("teacher_dialog_zone001",
teacher_zone001_enter_callback, teacher_zone001_enter_callback,
nil nil
) )
game_api.set_trigger_zone_callbacks("book_dialog_zone001", game_api.set_trigger_zone_callbacks("book_dialog_zone001",
book_dialog_zone001_enter_callback, book_dialog_zone001_enter_callback,
book_dialog_zone001_exit_callback book_dialog_zone001_exit_callback
) )
function setDay0setup() function setDay0setup()
game_api.deactivate_interactive_object("Room_Cover_Corridor_001") game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_North_1_001") game_api.deactivate_interactive_object("Room_Cover_North_1_001")
game_api.deactivate_interactive_object("Room_Cover_North_2_001") game_api.deactivate_interactive_object("Room_Cover_North_2_001")
game_api.rotate_object("Room_N_1_Leaf001", -90, 0.01, nil) game_api.rotate_object("Room_N_1_Leaf001", -90, 0.01, nil)
--game_api.set_object_rotation("Room_N_1_Leaf001", -90) --game_api.set_object_rotation("Room_N_1_Leaf001", -90)
game_api.deactivate_interactive_object("Note001") game_api.deactivate_interactive_object("Note001")
game_api.set_npc_enabled(0, false) game_api.set_npc_enabled(0, false)
game_api.set_npc_enabled(1, false) game_api.set_npc_enabled(1, false)
game_api.set_npc_enabled(2, false) game_api.set_npc_enabled(2, false)
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)
end end
function setDay1setup() function setDay1setup()
@ -756,32 +846,121 @@ function setDay1MorningSetup()
end end
end end
function setDay1NightSetup()
night_time = true
print("setDay1NightSetup")
morning_did_open_door_index = 0
game_api.deactivate_interactive_object("Room_Cover_North_1_001")
game_api.activate_interactive_object("Room_Cover_North_2_001")
game_api.activate_interactive_object("Room_Cover_North_3_001")
game_api.activate_interactive_object("Room_Cover_South_1_001")
game_api.activate_interactive_object("Room_Cover_South_2_001")
game_api.activate_interactive_object("Room_Cover_South_3_001")
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
game_api.activate_interactive_object("Room_Cover_Main_Hall_001")
game_api.set_object_rotation("Room_N_0_Leaf001", 0)
game_api.set_object_rotation("Room_N_1_Leaf001", 0)
game_api.set_object_rotation("Room_N_2_Leaf001", 0)
game_api.set_object_rotation("Room_S_0_Leaf001", 0)
game_api.set_object_rotation("Room_S_1_Leaf001", 0)
game_api.set_object_rotation("Room_S_2_Leaf001", 0)
game_api.set_object_rotation("Hall_Leaf001", 0)
game_api.set_object_alpha("Room_Cover_North_1_001", 1)
game_api.set_object_alpha("Room_Cover_North_2_001", 1)
game_api.set_object_alpha("Room_Cover_North_3_001", 1)
game_api.set_object_alpha("Room_Cover_South_1_001", 1)
game_api.set_object_alpha("Room_Cover_South_2_001", 1)
game_api.set_object_alpha("Room_Cover_South_3_001", 1)
game_api.set_object_alpha("Room_Cover_Corridor_001", 1)
game_api.set_object_alpha("Room_Cover_Main_Hall_001", 1)
game_api.set_npc_enabled(0, false)
game_api.set_npc_enabled(1, false)
game_api.set_npc_enabled(2, false)
game_api.set_npc_enabled(3, false)
game_api.set_npc_enabled(4, false)
game_api.set_npc_enabled(5, false)
local px = game_api.get_player_x()
local pz = game_api.get_player_z()
if (pz > 8.0) then
game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001")
morning_can_open_door_index = 6
print("(pz > 8.0)")
elseif (pz <= 8.0) and (pz > 0) and (px >= 1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_North_3_001")
morning_can_open_door_index = 5
print("(pz <= 8.0) and (pz > 0) and (px >= 1.5)")
elseif (pz <= 8.0) and (pz > 0) and (px <= -1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
morning_can_open_door_index = 3
print("(pz <= 8.0) and (pz > 0) and (px <= -1.5)")
elseif (pz <= 0.0) and (pz > -8) and (px >= 1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_North_2_001")
morning_can_open_door_index = 4
print("(pz <= 0.0) and (pz > -8) and (px >= 1.5)")
elseif (pz <= 0.0) and (pz > -8) and (px <= -1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_South_2_001")
morning_can_open_door_index = 2
print("(pz <= 0.0) and (pz > -8) and (px <= -1.5)")
elseif (pz <= -8.0) and (px <= -1.5) then
game_api.activate_interactive_object("Room_Cover_Corridor_001")
game_api.deactivate_interactive_object("Room_Cover_South_1_001")
morning_can_open_door_index = 1
print("(pz <= -8.0) and (px <= -1.5)")
else
--All set before
morning_can_open_door_index = 0
print("pz and px not working")
end
end
game_api.set_enter_night_callback(
function()
game_api.start_dialogue("dialog_video001")
setDay1NightSetup()
end
)
game_api.set_location_callbacks( game_api.set_location_callbacks(
function() function()
print("Enter location uni interior") print("Enter location uni interior")
player_left_darklands = false player_left_darklands = false
local hp = game_api.getFloatValue("player_hp") local hp = game_api.getFloatValue("player_hp")
game_api.set_player_hp(hp) game_api.set_player_hp(hp)
local need_sleep = game_api.getIntValue("need_sleep") local need_sleep = game_api.getIntValue("need_sleep")
local day = game_api.getIntValue("day") local day = game_api.getIntValue("day")
if (day>0) and (need_sleep==1) then if (day > 0) and (need_sleep == 1) then
setDay1MorningSetup() setDay1MorningSetup()
--game_api.switch_navigation(7) --game_api.switch_navigation(7)
elseif (day>0) then elseif (day > 0) then
setDay1setup() setDay1setup()
game_api.switch_navigation(3) game_api.switch_navigation(3)
else else
--Do nothing, it should have been already set up --Do nothing, it should have been already set up
end end
end, end,
function() function()
print("Exit location uni interior") print("Exit location uni interior")
player_left_darklands = false player_left_darklands = false
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)
end end
) )
setDay0setup() setDay0setup()

View File

@ -15,7 +15,6 @@
#endif #endif
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
#include <emscripten.h> #include <emscripten.h>
#endif #endif
@ -1191,7 +1190,11 @@ namespace ZL
if (darklandsFlashAlpha >= 1.0f) { if (darklandsFlashAlpha >= 1.0f) {
if (isNightTransition) { if (isNightTransition) {
menuManager.isNight = !menuManager.isNight; menuManager.isNight = !menuManager.isNight;
if (currentLocation) currentLocation->dialogueSystem.startDialogue("dialog_video001"); if (currentLocation)
{
//currentLocation->dialogueSystem.startDialogue("dialog_video001");
currentLocation->scriptEngine.callTriggerNightEnterCallback();
}
} else { } else {
isDarklands = !isDarklands; isDarklands = !isDarklands;

View File

@ -362,6 +362,7 @@ namespace ZL {
money_ -= amount; money_ -= amount;
} }
void MenuManager::openPhoneBank() { void MenuManager::openPhoneBank() {
uiManager.pushMenuFromSavedRoot(phoneBankRoot); uiManager.pushMenuFromSavedRoot(phoneBankRoot);
uiManager.setText("balanceText", formatMoney(money_)); uiManager.setText("balanceText", formatMoney(money_));

View File

@ -25,6 +25,7 @@ namespace ZL {
sol::protected_function locationExitCallback; sol::protected_function locationExitCallback;
sol::protected_function darklandsEnterCallback; sol::protected_function darklandsEnterCallback;
sol::protected_function darklandsExitCallback; sol::protected_function darklandsExitCallback;
sol::protected_function triggerNightEnterCallback;
}; };
ScriptEngine::ScriptEngine() = default; ScriptEngine::ScriptEngine() = default;
@ -318,6 +319,12 @@ namespace ZL {
this_impl->darklandsExitCallback = onExit.as<sol::protected_function>(); this_impl->darklandsExitCallback = onExit.as<sol::protected_function>();
}); });
api.set_function("set_enter_night_callback",
[this_impl = impl.get()](sol::object onEnter) {
if (onEnter.is<sol::protected_function>())
this_impl->triggerNightEnterCallback = onEnter.as<sol::protected_function>();
});
api.set_function("set_trigger_zone_enabled", api.set_function("set_trigger_zone_enabled",
[game](int index, bool value) { [game](int index, bool value) {
auto& triggerZones = game->triggerZones; auto& triggerZones = game->triggerZones;
@ -742,6 +749,15 @@ namespace ZL {
} }
} }
void ScriptEngine::callTriggerNightEnterCallback() {
if (!impl || !impl->triggerNightEnterCallback.valid()) return;
auto result = impl->triggerNightEnterCallback();
if (!result.valid()) {
sol::error err = result;
std::cerr << "[SCRIPT] trigger night enter callback error: " << err.what() << "\n";
}
}
void ScriptEngine::callDarklandsExitCallback() { void ScriptEngine::callDarklandsExitCallback() {
if (!impl || !impl->darklandsExitCallback.valid()) return; if (!impl || !impl->darklandsExitCallback.valid()) return;
auto result = impl->darklandsExitCallback(); auto result = impl->darklandsExitCallback();

View File

@ -44,6 +44,8 @@ public:
void callDarklandsEnterCallback(); void callDarklandsEnterCallback();
void callDarklandsExitCallback(); void callDarklandsExitCallback();
void callTriggerNightEnterCallback();
void callCutsceneCompleteCallback(const std::string& cutsceneId); void callCutsceneCompleteCallback(const std::string& cutsceneId);
private: private: