From 17d903fd52df849338f4745c2f0c967083f9d5f9 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Fri, 10 Jul 2026 13:24:23 +0300 Subject: [PATCH] Rewrite callbacks from scripts --- resources/start_dorm.lua | 175 +++---- resources/start_uni_exterior.lua | 180 ++++---- resources/start_uni_interior.lua | 760 +++++++++++++++---------------- 3 files changed, 563 insertions(+), 552 deletions(-) diff --git a/resources/start_dorm.lua b/resources/start_dorm.lua index 0a76f90..e82ffac 100644 --- a/resources/start_dorm.lua +++ b/resources/start_dorm.lua @@ -14,7 +14,7 @@ journal_picked_up = false function on_npc_interact(npc_index) if npc_index == 0 then - --[[ + --[[ local player_alik_aware = game_api.getIntValue("alik_aware") local player_container_aware = game_api.getIntValue("player_container_aware") if player_container_aware == 1 then @@ -26,7 +26,6 @@ function on_npc_interact(npc_index) game_api.start_dialogue("dialog_alik001") end]] game_api.start_dialogue("dialog_alik002") - end end @@ -106,22 +105,40 @@ function on_alik_door_click() end end +function callback_deactivate_cover_alik_room() + game_api.deactivate_interactive_object("Room_Cover_LivingRoom_W_S_2_001") + game_api.set_npc_enabled(0, true) + game_api.npc_rotate_to(0, 90) +end + +function callback_deactivate_cover_bathroom() + game_api.deactivate_interactive_object("Room_Cover_Bath_W_N_2_001") +end + +function callback_deactivate_cover_main_hall() + game_api.deactivate_interactive_object("Room_Cover_Main_Hall_And_Corridors_002") +end + +function callback_deactivate_cover_utility_room_n() + game_api.deactivate_interactive_object("Room_Cover_Utility_W_N_3_001") +end + +function callback_deactivate_cover_utility_room_s() + game_api.deactivate_interactive_object("Room_Cover_Utility_W_S_3_001") +end + function alik_door_open_callback() if (alik_door_opened == false) then alik_door_opened = true game_api.rotate_object("Door_Room_-1_-1_1_Leaf_001", -90, 0.5, nil) - game_api.fade_object("Room_Cover_LivingRoom_W_S_2_001", 0, 0.5, function() - game_api.deactivate_interactive_object("Room_Cover_LivingRoom_W_S_2_001") - game_api.set_npc_enabled(0, true) - game_api.npc_rotate_to(0, 90) - end) + game_api.fade_object("Room_Cover_LivingRoom_W_S_2_001", 0, 0.5, callback_deactivate_cover_alik_room) if (bathroom_door_opened) then game_api.switch_navigation(5) -- all open else game_api.switch_navigation(4) --b end - + game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end end @@ -147,9 +164,7 @@ function on_player_bathroom_click() game_api.start_dialogue("door_bathroom_dialog001") game_api.rotate_object("Door_Bath_-1_1_1_Leaf_002", -90, 0.5, nil) - game_api.fade_object("Room_Cover_Bath_W_N_2_001", 0, 0.5, function() - game_api.deactivate_interactive_object("Room_Cover_Bath_W_N_2_001") - end) + game_api.fade_object("Room_Cover_Bath_W_N_2_001", 0, 0.5, callback_deactivate_cover_bathroom) if (player_door_opened) then @@ -161,7 +176,7 @@ function on_player_bathroom_click() else game_api.switch_navigation(1) --ca end - + game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end end @@ -175,18 +190,12 @@ function on_player_door_click() game_api.player_stop() game_api.rotate_object("Door_Room_-1_1_1_Leaf_001", 90, 0.25, nil) - game_api.fade_object("Room_Cover_Main_Hall_And_Corridors_002", 0, 0.5, function() - game_api.deactivate_interactive_object("Room_Cover_Main_Hall_And_Corridors_002") - end) + game_api.fade_object("Room_Cover_Main_Hall_And_Corridors_002", 0, 0.5, callback_deactivate_cover_main_hall) - game_api.fade_object("Room_Cover_Utility_W_N_3_001", 0, 0.5, function() - game_api.deactivate_interactive_object("Room_Cover_Utility_W_N_3_001") - end) + game_api.fade_object("Room_Cover_Utility_W_N_3_001", 0, 0.5, callback_deactivate_cover_utility_room_n) - game_api.fade_object("Room_Cover_Utility_W_S_3_001", 0, 0.5, function() - game_api.deactivate_interactive_object("Room_Cover_Utility_W_S_3_001") - end) + game_api.fade_object("Room_Cover_Utility_W_S_3_001", 0, 0.5, callback_deactivate_cover_utility_room_s) if (bathroom_door_opened) then game_api.switch_navigation(3) --a @@ -195,57 +204,64 @@ function on_player_door_click() end game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end - end end +function callback_enter_night() + game_api.start_dialogue("dialog_video001") + closeAlikDoor() +end + game_api.set_enter_night_callback( - function() - game_api.start_dialogue("dialog_video001") - closeAlikDoor() - end + callback_enter_night ) -game_api.set_chat_callbacks( - function() - if (not game_api.is_night()) and (not game_api.is_dawn()) then - local aiperi_chat_opened = game_api.getIntValue("aiperi_chat_opened") +function callback_aiperi_chat() + if (not game_api.is_night()) and (not game_api.is_dawn()) then + local aiperi_chat_opened = game_api.getIntValue("aiperi_chat_opened") - if aiperi_chat_opened == 0 then - game_api.setIntValue("aiperi_chat_opened", 1) - local aiperi_knife_aware = game_api.getIntValue("aiperi_knife_aware") - local aiperi_talked_after_knife = game_api.getIntValue("aiperi_talked_after_knife") + if aiperi_chat_opened == 0 then + game_api.setIntValue("aiperi_chat_opened", 1) + local aiperi_knife_aware = game_api.getIntValue("aiperi_knife_aware") + local aiperi_talked_after_knife = game_api.getIntValue("aiperi_talked_after_knife") - if (player_hold_knife) and (aiperi_talked_after_knife == 0) then - game_api.start_dialogue("dialog_chat_aiperi003") - game_api.setIntValue("aiperi_talked_after_knife", 1) - else - if aiperi_knife_aware == 0 then - local lection_is_over = game_api.getIntValue("lection_is_over") - if (lection_is_over == 1) then - game_api.start_dialogue("dialog_chat_aiperi002") - else - game_api.start_dialogue("dialog_chat_aiperi001") - end + if (player_hold_knife) and (aiperi_talked_after_knife == 0) then + game_api.start_dialogue("dialog_chat_aiperi003") + game_api.setIntValue("aiperi_talked_after_knife", 1) + else + if aiperi_knife_aware == 0 then + local lection_is_over = game_api.getIntValue("lection_is_over") + if (lection_is_over == 1) then + game_api.start_dialogue("dialog_chat_aiperi002") + else + game_api.start_dialogue("dialog_chat_aiperi001") end end end end - end, - function() - local parents_chat_opened = game_api.getIntValue("parents_chat_opened") - if parents_chat_opened == 0 then - game_api.setIntValue("parents_chat_opened", 1) - game_api.start_dialogue("dialog_chat_parents001") - end - end, - function() - local news_chat_opened = game_api.getIntValue("news_chat_opened") - if news_chat_opened == 0 then - game_api.setIntValue("news_chat_opened", 1) - game_api.start_dialogue("dialog_chat_news001") - end end +end + +function callback_parents_chat() + local parents_chat_opened = game_api.getIntValue("parents_chat_opened") + if parents_chat_opened == 0 then + game_api.setIntValue("parents_chat_opened", 1) + game_api.start_dialogue("dialog_chat_parents001") + end +end + +function callback_news_chat() + local news_chat_opened = game_api.getIntValue("news_chat_opened") + if news_chat_opened == 0 then + game_api.setIntValue("news_chat_opened", 1) + game_api.start_dialogue("dialog_chat_news001") + end +end + +game_api.set_chat_callbacks( + callback_aiperi_chat, + callback_parents_chat, + callback_news_chat ) function on_aiperi_dialog_over() @@ -288,34 +304,39 @@ function on_toilet_click() game_api.start_dialogue("dialog_toilet001") end +function callback_enter_location() + print("Enter location dorm") + local hp = game_api.getFloatValue("player_hp") + game_api.set_player_hp(hp) + game_api.set_teleport_active(0, false) + if (game_api.is_night()) then + closeAlikDoor() + end +end + +function callback_exit_location() + print("Exit location dorm") + local hp = game_api.get_player_hp() + game_api.setFloatValue("player_hp", hp) +end game_api.set_location_callbacks( - function() - print("Enter location dorm") - local hp = game_api.getFloatValue("player_hp") - game_api.set_player_hp(hp) - game_api.set_teleport_active(0, false) - if (game_api.is_night()) then - closeAlikDoor() - end - end, - function() - print("Exit location dorm") - local hp = game_api.get_player_hp() - game_api.setFloatValue("player_hp", hp) - end + callback_enter_location, + callback_exit_location ) +function callback_call_taxi() + game_api.set_teleport_active(0, true) + game_api.set_trigger_zone_enabled(0, false) +end + game_api.deactivate_interactive_object("Room_Cover_LivingRoom_W_N_2_001") 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.set_call_taxi_callback( - function() - game_api.set_teleport_active(0, true) - game_api.set_trigger_zone_enabled(0, false) - end + callback_call_taxi ) diff --git a/resources/start_uni_exterior.lua b/resources/start_uni_exterior.lua index 98710e1..f295170 100644 --- a/resources/start_uni_exterior.lua +++ b/resources/start_uni_exterior.lua @@ -1,15 +1,14 @@ print("Lua script loaded successfully!") +function callback_enter_location() +end + +function callback_exit_location() +end + game_api.set_location_callbacks( - function() - -- player just arrived here - if game_api.is_darklands() then - -- arrived while in darklands mode - end - end, - function() - -- player is about to leave - end + callback_enter_location, + callback_exit_location ) function darklands_exit001_enter_callback() @@ -42,57 +41,64 @@ function dialog_contaier002_get_coursework() game_api.quest_set_objective_completed("ghost_coursework", "ghost_coursework_find") end +function callback_enter_night() + game_api.start_dialogue("dialog_video001") +end + game_api.set_enter_night_callback( - function() - game_api.start_dialogue("dialog_video001") - end + callback_enter_night ) -function on_darklands_over() - game_api.set_player_hp(10) + +function callback_exit_darklands() + game_api.start_cutscene("darklands_exit001") + print("Setting to day 1----") + game_api.setIntValue("day", 1) + game_api.set_dawn() + game_api.setIntValue("morning_player_can_leave", 1) end game_api.set_darklands_callbacks( nil, - function() - game_api.start_cutscene("darklands_exit001") - print("Setting to day 1----") - game_api.setIntValue("day", 1) - game_api.set_dawn() - game_api.setIntValue("morning_player_can_leave", 1) - end + callback_exit_darklands ) +function callback_enter_night() + game_api.deactivate_interactive_object("car001") + game_api.deactivate_interactive_object("car001wheels") + game_api.switch_navigation(1) +end + game_api.set_enter_night_callback( - function() - game_api.deactivate_interactive_object("car001") - game_api.deactivate_interactive_object("car001wheels") - game_api.switch_navigation(1) - end + callback_enter_night ) -game_api.set_location_callbacks( - function() - print("Enter location uni exterior") - local hp = game_api.getFloatValue("player_hp") - game_api.set_player_hp(hp) - game_api.set_teleport_active(0, false) - if (game_api.is_night()) then - game_api.deactivate_interactive_object("car001") - game_api.deactivate_interactive_object("car001wheels") - game_api.switch_navigation(1) - else - game_api.activate_interactive_object("car001") - game_api.activate_interactive_object("car001wheels") - game_api.switch_navigation(0) - end - end, - function() - print("Exit location uni exterior") - local hp = game_api.get_player_hp() - game_api.setFloatValue("player_hp", hp) +function callback_enter_location() + print("Enter location uni exterior") + local hp = game_api.getFloatValue("player_hp") + game_api.set_player_hp(hp) + game_api.set_teleport_active(0, false) + if (game_api.is_night()) then + game_api.deactivate_interactive_object("car001") + game_api.deactivate_interactive_object("car001wheels") + game_api.switch_navigation(1) + else + game_api.activate_interactive_object("car001") + game_api.activate_interactive_object("car001wheels") + game_api.switch_navigation(0) end +end + +function callback_exit_location() + print("Exit location uni exterior") + local hp = game_api.get_player_hp() + game_api.setFloatValue("player_hp", hp) +end + +game_api.set_location_callbacks( + callback_enter_location, + callback_exit_location ) game_api.set_trigger_zone_callbacks("darklands_exit001", @@ -123,11 +129,13 @@ function taxi_zone001_enter_callback() game_api.set_trigger_zone_enabled(0, false) end +function callback_call_taxi() + game_api.set_teleport_active(0, true) + game_api.set_trigger_zone_enabled(0, false) +end + game_api.set_call_taxi_callback( - function() - game_api.set_teleport_active(0, true) - game_api.set_trigger_zone_enabled(0, false) - end + callback_call_taxi ) @@ -136,44 +144,50 @@ game_api.set_trigger_zone_callbacks("taxi_zone001", nil ) -game_api.set_chat_callbacks( - function() - if (not game_api.is_night()) and (not game_api.is_dawn()) then - local aiperi_chat_opened = game_api.getIntValue("aiperi_chat_opened") +function callback_aiperi_chat() + if (not game_api.is_night()) and (not game_api.is_dawn()) then + local aiperi_chat_opened = game_api.getIntValue("aiperi_chat_opened") - if aiperi_chat_opened == 0 then - game_api.setIntValue("aiperi_chat_opened", 1) - local aiperi_knife_aware = game_api.getIntValue("aiperi_knife_aware") - local aiperi_talked_after_knife = game_api.getIntValue("aiperi_talked_after_knife") + if aiperi_chat_opened == 0 then + game_api.setIntValue("aiperi_chat_opened", 1) + local aiperi_knife_aware = game_api.getIntValue("aiperi_knife_aware") + local aiperi_talked_after_knife = game_api.getIntValue("aiperi_talked_after_knife") - if (player_hold_knife) and (aiperi_talked_after_knife == 0) then - game_api.start_dialogue("dialog_chat_aiperi003") - game_api.setIntValue("aiperi_talked_after_knife", 1) - else - if aiperi_knife_aware == 0 then - local lection_is_over = game_api.getIntValue("lection_is_over") - if (lection_is_over == 1) then - game_api.start_dialogue("dialog_chat_aiperi002") - else - game_api.start_dialogue("dialog_chat_aiperi001") - end + if (player_hold_knife) and (aiperi_talked_after_knife == 0) then + game_api.start_dialogue("dialog_chat_aiperi003") + game_api.setIntValue("aiperi_talked_after_knife", 1) + else + if aiperi_knife_aware == 0 then + local lection_is_over = game_api.getIntValue("lection_is_over") + if (lection_is_over == 1) then + game_api.start_dialogue("dialog_chat_aiperi002") + else + game_api.start_dialogue("dialog_chat_aiperi001") end end end end - end, - function() - local parents_chat_opened = game_api.getIntValue("parents_chat_opened") - if parents_chat_opened == 0 then - game_api.setIntValue("parents_chat_opened", 1) - game_api.start_dialogue("dialog_chat_parents001") - end - end, - function() - local news_chat_opened = game_api.getIntValue("news_chat_opened") - if news_chat_opened == 0 then - game_api.setIntValue("news_chat_opened", 1) - game_api.start_dialogue("dialog_chat_news001") - end end +end + +function callback_parents_chat() + local parents_chat_opened = game_api.getIntValue("parents_chat_opened") + if parents_chat_opened == 0 then + game_api.setIntValue("parents_chat_opened", 1) + game_api.start_dialogue("dialog_chat_parents001") + end +end + +function callback_news_chat() + local news_chat_opened = game_api.getIntValue("news_chat_opened") + if news_chat_opened == 0 then + game_api.setIntValue("news_chat_opened", 1) + game_api.start_dialogue("dialog_chat_news001") + end +end + +game_api.set_chat_callbacks( + callback_aiperi_chat, + callback_parents_chat, + callback_news_chat ) diff --git a/resources/start_uni_interior.lua b/resources/start_uni_interior.lua index 0de0017..522565e 100644 --- a/resources/start_uni_interior.lua +++ b/resources/start_uni_interior.lua @@ -76,7 +76,7 @@ function knife_dialog_zone001_enter_callback() if (player_hold_knife == false) then local lection_is_over = game_api.getIntValue("lection_is_over") if lection_is_over == 1 then - if (player_hold_key==1) then + if (player_hold_key == 1) then game_api.start_dialogue("knife_dialog002") else game_api.start_dialogue("knife_dialog001") @@ -165,7 +165,7 @@ function on_bookshelf2_clicked() if (game_api.is_night()) or (day >= 1) then game_api.start_dialogue("book_dialog007") else - if (teacher_told_about_book and (player_hold_book==false)) then + if (teacher_told_about_book and (player_hold_book == false)) then game_api.start_dialogue("book_dialog010") else game_api.start_dialogue("book_dialog007") @@ -178,7 +178,7 @@ function on_bookshelf3_clicked() if (game_api.is_night()) or (day >= 1) then game_api.start_dialogue("book_dialog008") else - if (teacher_told_about_book and (player_hold_book==false)) then + if (teacher_told_about_book and (player_hold_book == false)) then game_api.start_dialogue("book_dialog011") else game_api.start_dialogue("book_dialog008") @@ -191,7 +191,7 @@ function on_bookshelf4_clicked() if (game_api.is_night()) or (day >= 1) then game_api.start_dialogue("book_dialog009") else - if (teacher_told_about_book and (player_hold_book==false)) then + if (teacher_told_about_book and (player_hold_book == false)) then game_api.start_dialogue("book_dialog012") else game_api.start_dialogue("book_dialog009") @@ -204,7 +204,7 @@ function on_bookshelf5_clicked() if (game_api.is_night()) or (day >= 1) then game_api.start_dialogue("book_dialog013") else - if (teacher_told_about_book and (player_hold_book==false)) then + if (teacher_told_about_book and (player_hold_book == false)) then game_api.start_dialogue("book_dialog014") else game_api.start_dialogue("book_dialog013") @@ -216,7 +216,6 @@ function on_cake_clicked() game_api.start_dialogue("cake_dialog001") end - function on_npc_interact(npc_index) local player_ghost_aware = game_api.getIntValue("ghost_aware") local player_hold_key = game_api.getIntValue("player_hold_key") @@ -227,7 +226,7 @@ function on_npc_interact(npc_index) if (game_api.is_dawn()) or (day > 0) then game_api.start_dialogue("dialog_aiperi_morning001") else - if (player_hold_key==1) then + if (player_hold_key == 1) then game_api.start_dialogue("knife_dialog002") else game_api.start_dialogue("knife_dialog001") @@ -235,7 +234,6 @@ function on_npc_interact(npc_index) end end if npc_index == 0 then - if (day == 0) then if (teacher_told_about_book) then game_api.start_dialogue("teacher_dialog006") @@ -334,9 +332,29 @@ function on_library_door_click() print("Library door step 5") end +function callback_deactivate_cover_s3() + game_api.deactivate_interactive_object("Room_Cover_South_3_001") +end + +function callback_deactivate_cover_n3() + game_api.deactivate_interactive_object("Room_Cover_North_3_001") +end + +function callback_deactivate_cover_corridor() + game_api.deactivate_interactive_object("Room_Cover_Corridor_001") +end + +function callback_deactivate_cover_main_hall() + game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001") +end + +--Room_Cover_North_3_001 +--Room_Cover_Main_Hall_001 + + function on_teachers_door_click() print("on_teachers_door_click---") - + local player_hold_key = game_api.getIntValue("player_hold_key") local day = game_api.getIntValue("day") @@ -344,13 +362,11 @@ function on_teachers_door_click() print(day) if (day == 0) and not game_api.is_dawn() then - if (player_hold_key==1) then + if (player_hold_key == 1) 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(3) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end @@ -368,9 +384,7 @@ function on_teachers_door_click() if (morning_can_open_door_index == 3) then morning_did_open_door_index = 3 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.fade_object("Room_Cover_Corridor_001", 0, 0.5, callback_deactivate_cover_corridor) game_api.switch_navigation(10) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") else @@ -378,54 +392,42 @@ function on_teachers_door_click() --s1 + s3 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(11) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") elseif (morning_did_open_door_index == 2) then --s2 + s3 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(15) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") elseif (morning_did_open_door_index == 5) then --n3 + s3 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(13) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") elseif (morning_did_open_door_index == 4) then --n2 + s3 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(14) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") elseif (morning_did_open_door_index == 6) then --hall + s3 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(12) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") else --Player was in corridor, but tries to open the teacher's door --s3 only 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(10) game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end @@ -438,14 +440,10 @@ function on_teachers_door_click() if (morning_can_open_door_index == 3) then morning_did_open_door_index = 3 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.fade_object("Room_Cover_Corridor_001", 0, 0.5, callback_deactivate_cover_corridor) else 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) end game_api.switch_navigation(10) @@ -471,9 +469,7 @@ function on_hall_door_click() 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.fade_object("Room_Cover_Main_Hall_001", 0, 0.5, callback_deactivate_cover_main_hall) game_api.set_npc_enabled(0, true) game_api.set_npc_enabled(6, true) game_api.npc_rotate_to(6, 180) @@ -492,7 +488,7 @@ end function on_s1_door_click() local day = game_api.getIntValue("day") - if (day == 0) and(game_api.is_dawn()) then + if (day == 0) and (game_api.is_dawn()) then if not (morning_did_open_door_index == 1) then game_api.start_dialogue("door_dialog007") game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg") @@ -512,7 +508,7 @@ end function on_s2_door_click() local day = game_api.getIntValue("day") - if (day == 0) and(game_api.is_dawn()) then + if (day == 0) and (game_api.is_dawn()) then if not (morning_did_open_door_index == 2) then game_api.start_dialogue("door_dialog007") game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg") @@ -532,7 +528,7 @@ end function on_n2_door_click() local day = game_api.getIntValue("day") - if (day == 0) and(game_api.is_dawn()) then + if (day == 0) and (game_api.is_dawn()) then if not (morning_did_open_door_index == 4) then game_api.start_dialogue("door_dialog007") game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg") @@ -642,7 +638,7 @@ function on_sleep_cutscene() game_api.set_object_alpha("Room_Cover_South_3_001", 1) game_api.set_object_alpha("Room_Cover_Main_Hall_001", 1) game_api.activate_interactive_object("Note001") - + game_api.deactivate_interactive_object("car001") game_api.deactivate_interactive_object("car001wheels") teacher_door_opened = false @@ -650,9 +646,7 @@ end function on_teacher_arrived_intermediate() 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.deactivate_interactive_object("Room_Cover_North_3_001") - end) + game_api.fade_object("Room_Cover_North_3_001", 0, 0.5, callback_deactivate_cover_n3) game_api.switch_navigation(2) game_api.npc_walk_to(0, 4.94194, 0, 6.64111, on_teacher_arrived) teacher_arrived = true @@ -665,7 +659,7 @@ function on_lection_cutscene_fadein_callback() game_api.player_set_rotation(180) end -game_api.set_cutscene_callback("lection_cutscene001", function() +function callback_on_lection_cutscene_over() print("Cutscene done!") game_api.setIntValue("lection_is_over", 1) @@ -679,7 +673,9 @@ game_api.set_cutscene_callback("lection_cutscene001", function() if (aiperi_knife_aware == 0) then game_api.set_chat_unread(0, true, CONST_MSG_WHERE) end -end) +end + +game_api.set_cutscene_callback("lection_cutscene001", callback_on_lection_cutscene_over) function on_note_pickup() @@ -714,140 +710,141 @@ end first_time_darklands = true -game_api.set_darklands_callbacks( - function() - if (first_time_darklands) then - game_api.start_dialogue("ghost_dialog001") - first_time_darklands = false - end +function callback_enter_darklands() + if (first_time_darklands) then + game_api.start_dialogue("ghost_dialog001") + first_time_darklands = false + end - 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(1, false) - game_api.set_npc_enabled(6, false) + game_api.set_npc_enabled(0, false) + game_api.set_npc_enabled(1, false) + game_api.set_npc_enabled(6, false) - if (ghost_gone) then - 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) - else - game_api.set_npc_enabled(2, true) - game_api.set_npc_enabled(3, true) - game_api.set_npc_enabled(4, true) - game_api.set_npc_enabled(5, true) - - game_api.npc_set_hp(3, 35) - game_api.npc_set_hp(4, 35) - game_api.npc_set_hp(5, 35) - - 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(5, 5.0, 0, 12) - end - - game_api.switch_navigation(5) - end, - function() - game_api.start_cutscene("darklands_exit001") - game_api.set_npc_enabled(0, false) - game_api.set_npc_enabled(1, false) + if (ghost_gone) then 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) - game_api.set_npc_enabled(6, false) + else + game_api.set_npc_enabled(2, true) + game_api.set_npc_enabled(3, true) + game_api.set_npc_enabled(4, true) + game_api.set_npc_enabled(5, true) - --game_api.setIntValue("need_sleep", 1) - --player_left_darklands = true - morning_did_open_door_index = 0 - setDay1MorningSetup() - game_api.set_dawn() + game_api.npc_set_hp(3, 35) + game_api.npc_set_hp(4, 35) + game_api.npc_set_hp(5, 35) + + 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(5, 5.0, 0, 12) + end + + game_api.switch_navigation(5) +end + +function callback_exit_darklands() + game_api.start_cutscene("darklands_exit001") + 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) + game_api.set_npc_enabled(6, false) + + --game_api.setIntValue("need_sleep", 1) + --player_left_darklands = true + morning_did_open_door_index = 0 + setDay1MorningSetup() + game_api.set_dawn() - local px = game_api.get_player_x() - local pz = game_api.get_player_z() - - print("darklands exit px = ") - print(px) - - print("darklands exit pz = ") - print(pz) - + local px = game_api.get_player_x() + local pz = game_api.get_player_z() - if (pz > 8.2) 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 - elseif (pz <= 8.2) and (pz > 7.8) then - - --Corridor near the hall - - if (teacher_door_opened) then - game_api.deactivate_interactive_object("Room_Cover_South_3_001") - end - morning_can_open_door_index = 0 - game_api.player_set_position(px, 0, 7.7) - - elseif (pz <= 7.8) and (pz > 0) and (px >= 1.5 + 0.1) 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 - elseif (pz <= 7.8) and (pz > 0) and (px <= -1.5 - 0.1) then - if (teacher_door_opened) then - game_api.deactivate_interactive_object("Room_Cover_Corridor_001") - else - game_api.activate_interactive_object("Room_Cover_Corridor_001") - end + print("darklands exit px = ") + print(px) + + print("darklands exit pz = ") + print(pz) + + + if (pz > 8.2) 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 + elseif (pz <= 8.2) and (pz > 7.8) then + --Corridor near the hall + + if (teacher_door_opened) then game_api.deactivate_interactive_object("Room_Cover_South_3_001") - morning_can_open_door_index = 3 - elseif (pz <= 0.0) and (pz > -8) and (px >= 1.5 + 0.1) 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 - elseif (pz <= 0.0) and (pz > -8) and (px <= -1.5 - 0.1) 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 - elseif (pz <= -8.0) and (px <= -1.5-0.1) 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 + end + morning_can_open_door_index = 0 + game_api.player_set_position(px, 0, 7.7) + elseif (pz <= 7.8) and (pz > 0) and (px >= 1.5 + 0.1) 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 + elseif (pz <= 7.8) and (pz > 0) and (px <= -1.5 - 0.1) then + if (teacher_door_opened) then + game_api.deactivate_interactive_object("Room_Cover_Corridor_001") else - --All set before - if (teacher_door_opened) then - game_api.deactivate_interactive_object("Room_Cover_South_3_001") - end - morning_can_open_door_index = 0 - if (px >=1.4) and (px < 1.6) then - -- stick to 1.4 - print("Edge case with px = ") - print (px) - game_api.player_set_position(1.3, 0, pz) - end - - if (px <=-1.4) and (px > -1.6) then - -- stick to -1.48 - print("Edge case2 with px = ") - print (px) - game_api.player_set_position(-1.3, 0, pz) - end + game_api.activate_interactive_object("Room_Cover_Corridor_001") + end + game_api.deactivate_interactive_object("Room_Cover_South_3_001") + morning_can_open_door_index = 3 + elseif (pz <= 0.0) and (pz > -8) and (px >= 1.5 + 0.1) 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 + elseif (pz <= 0.0) and (pz > -8) and (px <= -1.5 - 0.1) 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 + elseif (pz <= -8.0) and (px <= -1.5 - 0.1) 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 + else + --All set before + if (teacher_door_opened) then + game_api.deactivate_interactive_object("Room_Cover_South_3_001") + end + morning_can_open_door_index = 0 + if (px >= 1.4) and (px < 1.6) then + -- stick to 1.4 + print("Edge case with px = ") + print(px) + game_api.player_set_position(1.3, 0, pz) end - - if (morning_can_open_door_index == 0) or (morning_can_open_door_index == 3) then - game_api.setIntValue("morning_player_can_leave", 1) - game_api.setIntValue("morning_aiperi_save_again", 0) - else - game_api.setIntValue("morning_player_can_leave", 0) - local morning_aiperi_talked = game_api.getIntValue("morning_aiperi_talked") - if (morning_aiperi_talked == 1) then - game_api.setIntValue("morning_aiperi_save_again", 1) - end + if (px <= -1.4) and (px > -1.6) then + -- stick to -1.48 + print("Edge case2 with px = ") + print(px) + game_api.player_set_position(-1.3, 0, pz) end end -) + + + if (morning_can_open_door_index == 0) or (morning_can_open_door_index == 3) then + game_api.setIntValue("morning_player_can_leave", 1) + game_api.setIntValue("morning_aiperi_save_again", 0) + else + game_api.setIntValue("morning_player_can_leave", 0) + local morning_aiperi_talked = game_api.getIntValue("morning_aiperi_talked") + if (morning_aiperi_talked == 1) then + game_api.setIntValue("morning_aiperi_save_again", 1) + end + end +end + +game_api.set_darklands_callbacks( + callback_enter_darklands, + callback_exit_darklands) game_api.set_trigger_zone_callbacks("teacher_dialog_zone001", @@ -877,10 +874,9 @@ function setDay0setup() game_api.set_npc_enabled(4, false) game_api.set_npc_enabled(5, false) game_api.set_npc_enabled(6, false) - + game_api.activate_interactive_object("car001") game_api.activate_interactive_object("car001wheels") - end function setDay1setup() @@ -918,9 +914,9 @@ function setDay1setup() game_api.set_npc_enabled(6, true) game_api.npc_set_position(1, 0.98998, 0, -7.525) - + game_api.deactivate_interactive_object("Cake001") - + game_api.activate_interactive_object("car001") game_api.activate_interactive_object("car001wheels") end @@ -956,7 +952,7 @@ function setDay1MorningSetup() 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.deactivate_interactive_object("car001") game_api.deactivate_interactive_object("car001wheels") @@ -1064,7 +1060,7 @@ function setDay1NightSetup() game_api.set_npc_enabled(4, false) game_api.set_npc_enabled(5, false) game_api.set_npc_enabled(6, false) - + game_api.deactivate_interactive_object("car001") game_api.deactivate_interactive_object("car001wheels") @@ -1108,110 +1104,114 @@ function setDay1NightSetup() end end -game_api.set_enter_night_callback( - function() - game_api.start_dialogue("dialog_video001") - setDay1NightSetup() - game_api.switch_navigation(16) - - - -- Fix player's position if the door is spawned near him: - - if (pz <= 8.2) and (pz > 7.8) then - --Corridor near the hall - game_api.player_set_position(px, 0, 7.7) - elseif (pz <= 7.8) and (px>=-1.6) and (px<=1.6) then - - --Player in doors, he should stick to the corridor - if (px >=1.4) and (px < 1.6) then - game_api.player_set_position(1.3, 0, pz) - end - - if (px <=-1.4) and (px > -1.6) then - game_api.player_set_position(-1.3, 0, pz) - end - end - --------------- - - +function callback_enter_night() + game_api.start_dialogue("dialog_video001") + setDay1NightSetup() + game_api.switch_navigation(16) + + + -- Fix player's position if the door is spawned near him: + + if (pz <= 8.2) and (pz > 7.8) then + --Corridor near the hall + game_api.player_set_position(px, 0, 7.7) + elseif (pz <= 7.8) and (px >= -1.6) and (px <= 1.6) then + --Player in doors, he should stick to the corridor + if (px >= 1.4) and (px < 1.6) then + game_api.player_set_position(1.3, 0, pz) + end + + if (px <= -1.4) and (px > -1.6) then + game_api.player_set_position(-1.3, 0, pz) + end end -) + --------------- +end + +game_api.set_enter_night_callback(callback_enter_night) + +function callback_aiperi_chat() + local player_hold_key = game_api.getIntValue("player_hold_key") + + if (game_api.is_night()) then + if (game_api.is_dawn()) then + local morning_player_can_leave = game_api.getIntValue("morning_player_can_leave") + + if morning_player_can_leave == 0 then + game_api.start_dialogue("phone_morning_aiperi001") + else + game_api.start_dialogue("cancel_phone_morning_aiperi001") + end + else + local day = game_api.getIntValue("day") + local asked_help_locked = game_api.getIntValue("asked_help_locked") + + if (day == 0) then + if (asked_help_locked == 0) then + game_api.start_dialogue("phone_night_aiperi001") + end + else + game_api.start_dialogue("cancel_phone_night_aiperi001") + end + end + game_api.setIntValue("aiperi_talked_after_knife", 1) + game_api.setIntValue("aiperi_chat_opened", 1) + else + local aiperi_chat_opened = game_api.getIntValue("aiperi_chat_opened") + local aiperi_knife_aware = game_api.getIntValue("aiperi_knife_aware") + local aiperi_talked_after_knife = game_api.getIntValue("aiperi_talked_after_knife") + local lection_is_over = game_api.getIntValue("lection_is_over") + + if (player_hold_knife) and (aiperi_talked_after_knife == 0) then + game_api.start_dialogue("dialog_chat_aiperi003") + game_api.setIntValue("aiperi_talked_after_knife", 1) + else + print("dialogx step 2") + if aiperi_chat_opened == 0 then + print("dialogx step 3") + game_api.setIntValue("aiperi_chat_opened", 1) + if aiperi_knife_aware == 0 then + print("dialogx step 4") + if (lection_is_over == 1) then + print("dialogx step 5") + if (player_hold_key == 0) then + print("dialogx step 6") + game_api.start_dialogue("dialog_chat_aiperi002") + end + else + game_api.start_dialogue("dialog_chat_aiperi001") + end + end + end + end + end +end + +function callback_parents_chat() + local parents_chat_opened = game_api.getIntValue("parents_chat_opened") + if parents_chat_opened == 0 then + game_api.setIntValue("parents_chat_opened", 1) + game_api.start_dialogue("dialog_chat_parents001") + end +end + +function callback_news_chat() + local news_chat_opened = game_api.getIntValue("news_chat_opened") + if news_chat_opened == 0 then + game_api.setIntValue("news_chat_opened", 1) + game_api.start_dialogue("dialog_chat_news001") + end +end game_api.set_chat_callbacks( - function() - local player_hold_key = game_api.getIntValue("player_hold_key") - - if (game_api.is_night()) then - if (game_api.is_dawn()) then - local morning_player_can_leave = game_api.getIntValue("morning_player_can_leave") - - if morning_player_can_leave == 0 then - game_api.start_dialogue("phone_morning_aiperi001") - else - game_api.start_dialogue("cancel_phone_morning_aiperi001") - end - else - local day = game_api.getIntValue("day") - local asked_help_locked = game_api.getIntValue("asked_help_locked") - - if (day == 0) then - if (asked_help_locked == 0) then - game_api.start_dialogue("phone_night_aiperi001") - end - else - game_api.start_dialogue("cancel_phone_night_aiperi001") - end - end - game_api.setIntValue("aiperi_talked_after_knife", 1) - game_api.setIntValue("aiperi_chat_opened", 1) - else - - local aiperi_chat_opened = game_api.getIntValue("aiperi_chat_opened") - local aiperi_knife_aware = game_api.getIntValue("aiperi_knife_aware") - local aiperi_talked_after_knife = game_api.getIntValue("aiperi_talked_after_knife") - local lection_is_over = game_api.getIntValue("lection_is_over") - - if (player_hold_knife) and (aiperi_talked_after_knife == 0) then - game_api.start_dialogue("dialog_chat_aiperi003") - game_api.setIntValue("aiperi_talked_after_knife", 1) - else - print("dialogx step 2") - if aiperi_chat_opened == 0 then - print("dialogx step 3") - game_api.setIntValue("aiperi_chat_opened", 1) - if aiperi_knife_aware == 0 then - print("dialogx step 4") - if (lection_is_over == 1) then - print("dialogx step 5") - if (player_hold_key == 0) then - print("dialogx step 6") - game_api.start_dialogue("dialog_chat_aiperi002") - end - else - game_api.start_dialogue("dialog_chat_aiperi001") - end - end - end - end - - end - end, - function() - local parents_chat_opened = game_api.getIntValue("parents_chat_opened") - if parents_chat_opened == 0 then - game_api.setIntValue("parents_chat_opened", 1) - game_api.start_dialogue("dialog_chat_parents001") - end - end, - function() - local news_chat_opened = game_api.getIntValue("news_chat_opened") - if news_chat_opened == 0 then - game_api.setIntValue("news_chat_opened", 1) - game_api.start_dialogue("dialog_chat_news001") - end - end + callback_aiperi_chat, + callback_parents_chat, + callback_news_chat ) +function callback_aiperi_dialog_morning() + game_api.start_dialogue("dialog_aiperi_morning001") +end function on_aiperi_opens_door() print("on_aiperi_opens_door") @@ -1222,14 +1222,10 @@ function on_aiperi_opens_door() 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.fade_object("Room_Cover_Corridor_001", 0, 0.5, callback_deactivate_cover_corridor) if (teacher_door_opened) then - 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(12) else game_api.switch_navigation(6) @@ -1238,11 +1234,9 @@ function on_aiperi_opens_door() --Aiperi incoming game_api.npc_set_position(1, 0, 0, 6.5) game_api.set_npc_enabled(1, true) - game_api.npc_walk_to(1, 0.0, 0, 9.1, function() - game_api.start_dialogue("dialog_aiperi_morning001") - end) + game_api.npc_walk_to(1, 0.0, 0, 9.1, callback_aiperi_dialog_morning) game_api.player_walk_to(0.0, 0.0, 10.0, nil) - + game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end elseif (morning_can_open_door_index == 5) then @@ -1250,14 +1244,10 @@ function on_aiperi_opens_door() 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.fade_object("Room_Cover_Corridor_001", 0, 0.5, callback_deactivate_cover_corridor) if (teacher_door_opened) then - 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(13) else game_api.switch_navigation(7) @@ -1266,11 +1256,9 @@ function on_aiperi_opens_door() --Aiperi incoming game_api.npc_set_position(1, 0.0, 0, 6.43818) game_api.set_npc_enabled(1, true) - game_api.npc_walk_to(1, 2.34349, 0, 6.31229, function() - game_api.start_dialogue("dialog_aiperi_morning001") - end) + game_api.npc_walk_to(1, 2.34349, 0, 6.31229, callback_aiperi_dialog_morning) game_api.player_walk_to(3.52174, 0, 6.28993, nil) - + game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end elseif (morning_can_open_door_index == 4) then @@ -1279,13 +1267,9 @@ function on_aiperi_opens_door() game_api.start_dialogue("door_unlock_dialog001") 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.deactivate_interactive_object("Room_Cover_Corridor_001") - end) + game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, callback_deactivate_cover_corridor) if (teacher_door_opened) then - 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(14) else game_api.switch_navigation(0) @@ -1294,11 +1278,9 @@ function on_aiperi_opens_door() --Aiperi incoming game_api.npc_set_position(1, 0, 0, -1.7911) game_api.set_npc_enabled(1, true) - game_api.npc_walk_to(1, 2.11898, 0, -1.7074, function() - game_api.start_dialogue("dialog_aiperi_morning001") - end) + game_api.npc_walk_to(1, 2.11898, 0, -1.7074, callback_aiperi_dialog_morning) game_api.player_walk_to(3.36055, 0, -2.0345, nil) - + game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end elseif (morning_can_open_door_index == 2) then @@ -1307,14 +1289,10 @@ function on_aiperi_opens_door() game_api.start_dialogue("door_unlock_dialog001") 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.deactivate_interactive_object("Room_Cover_Corridor_001") - end) + game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, callback_deactivate_cover_corridor) if (teacher_door_opened) then - 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(15) else game_api.switch_navigation(9) @@ -1322,11 +1300,9 @@ function on_aiperi_opens_door() --Aiperi incoming game_api.npc_set_position(1, 0, 0, -1.7911) game_api.set_npc_enabled(1, true) - game_api.npc_walk_to(1, -2.454, 0, -1.61871, function() - game_api.start_dialogue("dialog_aiperi_morning001") - end) + game_api.npc_walk_to(1, -2.454, 0, -1.61871, callback_aiperi_dialog_morning) game_api.player_walk_to(-3.63363, 0, -1.50727, nil) - + game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end elseif (morning_can_open_door_index == 1) then @@ -1335,13 +1311,9 @@ function on_aiperi_opens_door() game_api.start_dialogue("door_unlock_dialog001") 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.deactivate_interactive_object("Room_Cover_Corridor_001") - end) + game_api.fade_object("Room_Cover_Corridor_001", 0, 0.5, callback_deactivate_cover_corridor) if (teacher_door_opened) then - 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.fade_object("Room_Cover_South_3_001", 0, 0.5, callback_deactivate_cover_s3) game_api.switch_navigation(11) else game_api.switch_navigation(8) @@ -1350,11 +1322,9 @@ function on_aiperi_opens_door() --Aiperi incoming game_api.npc_set_position(1, 0, 0, -9.77948) game_api.set_npc_enabled(1, true) - game_api.npc_walk_to(1, -2.53977, 0, -9.77852, function() - game_api.start_dialogue("dialog_aiperi_morning001") - end) + game_api.npc_walk_to(1, -2.53977, 0, -9.77852, callback_aiperi_dialog_morning) game_api.player_walk_to(-3.64494, 0, -9.66711, nil) - + game_api.play_sound("audio/702171__foxfire__door-opening.ogg") end end @@ -1364,70 +1334,70 @@ function on_aiperi_morning_dialog_finished() game_api.npc_walk_to(1, 0.98998, 0, -7.525, nil) end -game_api.set_location_callbacks( - function() - print("Enter location uni interior-") - --player_left_darklands = false - local hp = game_api.getFloatValue("player_hp") - game_api.set_player_hp(hp) - local day = game_api.getIntValue("day") +function callback_enter_location() + print("Enter location uni interior-") + --player_left_darklands = false + local hp = game_api.getFloatValue("player_hp") + game_api.set_player_hp(hp) + local day = game_api.getIntValue("day") - print("day is:") - print(day) + print("day is:") + 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 + 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(16) - else - print("entered day setup") - setDay1setup() - game_api.switch_navigation(3) - end - end - - if (day > 0) and (game_api.is_night() == false) then + 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(16) + else print("entered day setup") setDay1setup() game_api.switch_navigation(3) end + end - print("entered exited-") + if (day > 0) and (game_api.is_night() == false) then + print("entered day setup") + setDay1setup() + game_api.switch_navigation(3) + end - if (was_darklands) and (game_api.is_darklands() == false) and game_api.is_dawn() then - --Player died in exterior and then in the morning returned back - print("setDay1MorningSetup entered-") - setDay1MorningSetup() - end - end, - function() - print("Exit location uni interior") - --player_left_darklands = false - local hp = game_api.get_player_hp() - game_api.setFloatValue("player_hp", hp) + print("entered exited-") + + if (was_darklands) and (game_api.is_darklands() == false) and game_api.is_dawn() then + --Player died in exterior and then in the morning returned back + print("setDay1MorningSetup entered-") + setDay1MorningSetup() + end +end + +function callback_exit_location() + print("Exit location uni interior") + --player_left_darklands = false + local hp = game_api.get_player_hp() + game_api.setFloatValue("player_hp", hp) - --[[ + --[[ 0 - day0 1 - darklands 2 - morning @@ -1436,21 +1406,25 @@ game_api.set_location_callbacks( ]] - local day = game_api.getIntValue("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 + 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 + +game_api.set_location_callbacks( + callback_enter_location, + callback_exit_location ) @@ -1472,10 +1446,12 @@ function debugAllOpen() game_api.rotate_object("Room_N_2_Leaf001", -90, 0.5, nil) end -game_api.set_cutscene_callback("game_complete_cutscene001", function() +function callback_game_complete_cutscene() print("---Cutscene done!") game_api.return_to_main_menu() -end) +end + +game_api.set_cutscene_callback("game_complete_cutscene001", callback_game_complete_cutscene)