359 lines
9.6 KiB
Lua
359 lines
9.6 KiB
Lua
|
|
|
|
hall_door_opened = false
|
|
teacher_door_opened = false
|
|
lection_is_over = false
|
|
|
|
player_hold_book = false
|
|
player_hold_knife = false
|
|
teacher_arrived = false
|
|
teacher_told_about_book = false
|
|
|
|
night_time = false
|
|
|
|
player_in_darklands = false
|
|
|
|
player_ghost_aware = false
|
|
|
|
function lection_hall_zone001_enter_callback()
|
|
--game_api.start_dialogue("")
|
|
--Start cutscene
|
|
if (lection_is_over == false) then
|
|
game_api.start_cutscene("test_cutscene_01")
|
|
end
|
|
end
|
|
|
|
game_api.set_trigger_zone_callbacks("lection_hall_zone001",
|
|
lection_hall_zone001_enter_callback,
|
|
nil
|
|
)
|
|
|
|
function knife_dialog_zone001_enter_callback()
|
|
print("knife_dialog_zone001_enter_callback--!")
|
|
if (player_hold_knife == false) then
|
|
if lection_is_over then
|
|
game_api.start_dialogue("knife_dialog001")
|
|
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
|
|
|
|
function knife_dialog_zone001_exit_callback()
|
|
print("knife_dialog_zone001_exit_callback--!")
|
|
if (lection_is_over) then
|
|
if (teacher_door_opened) then
|
|
game_api.switch_navigation(3)
|
|
else
|
|
game_api.switch_navigation(2)
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
game_api.set_trigger_zone_callbacks("knife_dialog_zone001",
|
|
knife_dialog_zone001_enter_callback,
|
|
knife_dialog_zone001_exit_callback
|
|
)
|
|
|
|
|
|
function on_knife_pickup()
|
|
game_api.pickup_item("knife")
|
|
game_api.deactivate_interactive_object("Knife001")
|
|
game_api.set_npc_enabled(1, false)
|
|
player_hold_knife = true
|
|
game_api.set_trigger_zone_enabled(2, true)
|
|
game_api.npc_walk_to(0, -4.57412, 0, 6.78495, on_teacher_arrived2)
|
|
end
|
|
|
|
function on_book_pickup()
|
|
if (teacher_told_about_book) then
|
|
if not player_hold_book then
|
|
game_api.pickup_item("book")
|
|
game_api.deactivate_interactive_object("Book001")
|
|
player_hold_book = true
|
|
else
|
|
game_api.remove_item("book")
|
|
game_api.activate_interactive_object("Book001")
|
|
player_hold_book = false
|
|
end
|
|
end
|
|
end
|
|
|
|
function on_bookshelf_clicked()
|
|
if not player_hold_book then
|
|
game_api.pickup_item("book")
|
|
game_api.deactivate_interactive_object("Book001")
|
|
player_hold_book = true
|
|
game_api.set_trigger_zone_enabled(3, true)
|
|
else
|
|
game_api.remove_item("book")
|
|
game_api.activate_interactive_object("Book001")
|
|
player_hold_book = false
|
|
game_api.set_trigger_zone_enabled(3, false)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
function on_npc_interact(npc_index)
|
|
print("[Lua] NPC interaction! Index: " .. tostring(npc_index))
|
|
if npc_index == 1 then
|
|
if (player_ghost_aware) then
|
|
game_api.start_dialogue("aiperi_dialog001")
|
|
else
|
|
game_api.start_dialogue("knife_dialog001")
|
|
end
|
|
end
|
|
if npc_index == 0 then
|
|
if (player_ghost_aware) then
|
|
game_api.start_dialogue("teacher_dialog003")
|
|
else
|
|
game_api.start_dialogue("teacher_dialog001")
|
|
end
|
|
--game_api.set_trigger_zone_enabled(2, false)
|
|
end
|
|
if npc_index == 2 then
|
|
game_api.start_dialogue("dialog_with_ghost001")
|
|
player_ghost_aware = true
|
|
end
|
|
end
|
|
|
|
function teacher_zone001_enter_callback()
|
|
game_api.start_dialogue("teacher_dialog002")
|
|
game_api.set_trigger_zone_enabled(2, false)
|
|
teacher_told_about_book = true
|
|
end
|
|
|
|
|
|
function on_locked_door_click()
|
|
game_api.start_dialogue("door_dialog001")
|
|
-- Example: uncomment and replace "DoorName" to animate a door open over 1.5 seconds
|
|
-- game_api.rotate_object("DoorName", 90, 1.5, function()
|
|
-- print("Door finished opening!")
|
|
-- end)
|
|
end
|
|
|
|
function on_library_door_click()
|
|
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
|
|
end
|
|
|
|
function on_teachers_door_click()
|
|
if (not teacher_arrived) then
|
|
game_api.start_dialogue("door_dialog001")
|
|
else
|
|
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
|
|
end
|
|
end
|
|
|
|
function on_hall_door_click()
|
|
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
|
|
end
|
|
|
|
|
|
function on_teacher_arrived()
|
|
print("Teacher arrived")
|
|
end
|
|
|
|
function on_teacher_arrived2()
|
|
print("Teacher arrived2")
|
|
end
|
|
|
|
function book_dialog_zone001_enter_callback()
|
|
if (night_time == false) then
|
|
game_api.start_dialogue("book_dialog001")
|
|
game_api.switch_navigation(5)
|
|
end
|
|
if (player_in_darklands) then
|
|
game_api.start_dialogue("ghost_dialog002")
|
|
game_api.set_trigger_zone_enabled(3, false)
|
|
end
|
|
end
|
|
|
|
function book_dialog_zone001_exit_callback()
|
|
if (night_time == false) then
|
|
game_api.switch_navigation(3)
|
|
end
|
|
end
|
|
|
|
function on_computer_clicked()
|
|
print("on_computer_clicked--")
|
|
if (night_time == false) then
|
|
if (player_hold_book) then
|
|
game_api.start_cutscene("test_cutscene_02")
|
|
else
|
|
game_api.start_dialogue("book_dialog002")
|
|
end
|
|
end
|
|
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.switch_navigation(2)
|
|
game_api.npc_walk_to(0, 3.19574, 0, 6.45595, on_teacher_arrived)
|
|
teacher_arrived = true
|
|
end
|
|
|
|
|
|
game_api.set_cutscene_callback("test_cutscene_01", function()
|
|
print("Cutscene done!")
|
|
lection_is_over = true
|
|
game_api.set_npc_enabled(1, true)
|
|
game_api.npc_walk_to(0, 0.758123, 0, 6.50063, on_teacher_arrived_intermediate)
|
|
end)
|
|
|
|
game_api.set_cutscene_callback("test_cutscene_02", function()
|
|
print("Cutscene 2 done!")
|
|
night_time = true
|
|
--game_api.set_trigger_zone_enabled(1, false)
|
|
game_api.set_npc_enabled(0, false)
|
|
game_api.switch_navigation(5)
|
|
game_api.rotate_object("Room_N_2_Leaf001", 90, 0.01, nil)
|
|
game_api.activate_interactive_object("Room_Cover_Corridor_001")
|
|
game_api.activate_interactive_object("Room_Cover_Main_Hall_001")
|
|
game_api.activate_interactive_object("Room_Cover_North_1_001")
|
|
game_api.activate_interactive_object("Room_Cover_North_2_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.fade_object("Room_Cover_Corridor_001", 1, 0.01, nil)
|
|
game_api.fade_object("Room_Cover_South_3_001", 1, 0.01, nil)
|
|
game_api.fade_object("Room_Cover_North_1_001", 1, 0.01, nil)
|
|
game_api.fade_object("Room_Cover_Main_Hall_001", 1, 0.01, nil)
|
|
game_api.activate_interactive_object("Note001")
|
|
|
|
end)
|
|
|
|
function on_note_pickup()
|
|
game_api.start_dialogue("note_dialog001")
|
|
game_api.pickup_item("note_spell")
|
|
game_api.deactivate_interactive_object("Note001")
|
|
end
|
|
|
|
function on_report_card_pickup()
|
|
game_api.start_dialogue("dialog_report_card001")
|
|
end
|
|
function on_bookshelf_teacher_clicked()
|
|
game_api.start_dialogue("dialog_report_card001")
|
|
end
|
|
|
|
|
|
game_api.set_darklands_callbacks(
|
|
function()
|
|
game_api.start_dialogue("ghost_dialog001")
|
|
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.switch_navigation(6)
|
|
player_in_darklands = true
|
|
|
|
end,
|
|
function()
|
|
player_in_darklands = false
|
|
game_api.start_cutscene("test_cutscene_03")
|
|
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(4, false)
|
|
game_api.set_npc_enabled(5, false)
|
|
game_api.switch_navigation(3)
|
|
game_api.setIntValue("day", 1)
|
|
game_api.setIntValue("need_sleep", 1)
|
|
game_api.set_player_hp(10)
|
|
end
|
|
)
|
|
|
|
|
|
game_api.set_trigger_zone_callbacks("teacher_dialog_zone001",
|
|
teacher_zone001_enter_callback,
|
|
nil
|
|
)
|
|
|
|
game_api.set_trigger_zone_callbacks("book_dialog_zone001",
|
|
book_dialog_zone001_enter_callback,
|
|
book_dialog_zone001_exit_callback
|
|
)
|
|
|
|
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
|
|
game_api.deactivate_interactive_object("Room_Cover_North_1_001")
|
|
game_api.deactivate_interactive_object("Note001")
|
|
|
|
|
|
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)
|
|
|
|
function setDay1setup()
|
|
game_api.switch_navigation(5)
|
|
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
|
|
game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001")
|
|
game_api.deactivate_interactive_object("Room_Cover_North_1_001")
|
|
game_api.activate_interactive_object("Room_Cover_North_2_001")
|
|
game_api.deactivate_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.deactivate_interactive_object("Room_Cover_South_3_001")
|
|
game_api.set_npc_enabled(0, true)
|
|
game_api.set_npc_enabled(1, true)
|
|
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)
|
|
end
|
|
|
|
|
|
|
|
game_api.set_location_callbacks(
|
|
function()
|
|
print("Enter location uni interior")
|
|
local hp = game_api.getFloatValue("player_hp")
|
|
game_api.set_player_hp(hp)
|
|
--[[
|
|
local need_sleep = game_api.getIntValue("need_sleep")
|
|
local day = game_api.getIntValue("day")
|
|
if (day==1) then
|
|
setDay1setup()
|
|
end]]
|
|
end,
|
|
function()
|
|
print("Exit location uni interior")
|
|
local hp = game_api.get_player_hp()
|
|
game_api.setFloatValue("player_hp", hp)
|
|
end
|
|
)
|
|
|
|
|
|
print("Lua script loaded successfully!") |