Working on the player respawn correctly
This commit is contained in:
1 parent
27b4b19df4
commit
2659951d8e
20 files changed
+6972
-86
No files matched your search
@@ -11,7 +11,11 @@ teacher_told_about_book = false
|
||||
|
||||
night_time = false
|
||||
|
||||
player_in_darklands = false
|
||||
player_left_darklands = false
|
||||
|
||||
|
||||
morning_can_open_door_index = 0
|
||||
morning_did_open_door_index = 0
|
||||
|
||||
player_ghost_aware = false
|
||||
|
||||
@@ -32,6 +36,9 @@ game_api.set_trigger_zone_callbacks("lection_hall_zone001",
|
||||
|
||||
function knife_dialog_zone001_enter_callback()
|
||||
print("knife_dialog_zone001_enter_callback--!")
|
||||
local day = game_api.getIntValue("day")
|
||||
|
||||
if (day == 0) then
|
||||
if (player_hold_knife == false) then
|
||||
if lection_is_over then
|
||||
game_api.start_dialogue("knife_dialog001")
|
||||
@@ -43,9 +50,13 @@ function knife_dialog_zone001_enter_callback()
|
||||
game_api.set_trigger_zone_enabled(1, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function knife_dialog_zone001_exit_callback()
|
||||
local day = game_api.getIntValue("day")
|
||||
|
||||
if (day == 0) then
|
||||
print("knife_dialog_zone001_exit_callback--!")
|
||||
if (lection_is_over) then
|
||||
if (teacher_door_opened) then
|
||||
@@ -54,7 +65,7 @@ function knife_dialog_zone001_exit_callback()
|
||||
game_api.switch_navigation(2)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
game_api.set_trigger_zone_callbacks("knife_dialog_zone001",
|
||||
@@ -105,17 +116,27 @@ 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
|
||||
local player_alik_aware = game_api.getIntValue("player_alik_aware")
|
||||
if player_alik_aware ==1 then
|
||||
game_api.start_dialogue("aiperi_dialog002")
|
||||
|
||||
local day = game_api.getIntValue("day")
|
||||
|
||||
if (day == 0) then
|
||||
game_api.start_dialogue("knife_dialog001")
|
||||
else
|
||||
game_api.start_dialogue("aiperi_dialog001")
|
||||
game_api.setIntValue("player_alik_aware", 1)
|
||||
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
|
||||
else
|
||||
game_api.start_dialogue("aiperi_dialog003")
|
||||
end
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("knife_dialog001")
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
if npc_index == 0 then
|
||||
if (player_ghost_aware) then
|
||||
@@ -165,17 +186,24 @@ 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
|
||||
print("on_library_door_click---")
|
||||
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
|
||||
else
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
end
|
||||
|
||||
elseif (night_time) then
|
||||
game_api.start_dialogue("door_night_dialog001")
|
||||
else
|
||||
if (not lection_is_over) then
|
||||
@@ -185,10 +213,26 @@ function on_library_door_click()
|
||||
end
|
||||
|
||||
function on_teachers_door_click()
|
||||
if (not teacher_arrived) then
|
||||
print("on_teachers_door_click---")
|
||||
if (player_left_darklands) then
|
||||
if (morning_can_open_door_index == 3) then
|
||||
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
|
||||
|
||||
elseif (not teacher_arrived) then
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
else
|
||||
if (not teacher_door_opened) then
|
||||
elseif (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()
|
||||
@@ -196,11 +240,27 @@ function on_teachers_door_click()
|
||||
end)
|
||||
game_api.switch_navigation(3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function on_hall_door_click()
|
||||
if (not hall_door_opened) then
|
||||
print("on_hall_door_click---")
|
||||
if (player_left_darklands) then
|
||||
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
|
||||
|
||||
elseif (not hall_door_opened) then
|
||||
hall_door_opened = true
|
||||
game_api.switch_navigation(1)
|
||||
game_api.rotate_object("Hall_Leaf001", 90, 0.5, nil)
|
||||
@@ -211,6 +271,78 @@ function on_hall_door_click()
|
||||
end
|
||||
end
|
||||
|
||||
function on_s1_door_click()
|
||||
if (player_left_darklands) then
|
||||
if (morning_can_open_door_index==1) then
|
||||
if (morning_did_open_door_index == 0) then
|
||||
morning_did_open_door_index = 1
|
||||
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.switch_navigation(8)
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function on_s2_door_click()
|
||||
if (player_left_darklands) then
|
||||
if (morning_can_open_door_index == 2) then
|
||||
if (morning_did_open_door_index == 0) then
|
||||
morning_did_open_door_index = 2
|
||||
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.switch_navigation(9)
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
end
|
||||
end
|
||||
|
||||
function on_n2_door_click()
|
||||
print("player_left_darklands")
|
||||
print(player_left_darklands)
|
||||
print("morning_can_open_door_index")
|
||||
print(morning_can_open_door_index)
|
||||
print("morning_did_open_door_index")
|
||||
print(morning_did_open_door_index)
|
||||
if (player_left_darklands) then
|
||||
if (morning_can_open_door_index==4) then
|
||||
if (morning_did_open_door_index == 0) then
|
||||
morning_did_open_door_index = 4
|
||||
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.switch_navigation(11)
|
||||
else
|
||||
--game_api.start_dialogue("door_opened_dialog001")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function on_teacher_arrived()
|
||||
print("Teacher arrived")
|
||||
@@ -221,14 +353,15 @@ 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
|
||||
if (game_api.is_darklands()) then
|
||||
game_api.start_dialogue("ghost_dialog002")
|
||||
game_api.set_trigger_zone_enabled(3, false)
|
||||
else
|
||||
if (night_time == false) then
|
||||
game_api.start_dialogue("book_dialog001")
|
||||
game_api.switch_navigation(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function book_dialog_zone001_exit_callback()
|
||||
@@ -239,13 +372,20 @@ 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
|
||||
local day = game_api.getIntValue("day")
|
||||
|
||||
if (day == 1) then
|
||||
-- TODO: some dialog like I don't need it
|
||||
else
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
function on_teacher_arrived_intermediate()
|
||||
@@ -275,7 +415,7 @@ game_api.set_cutscene_callback("test_cutscene_02", function()
|
||||
game_api.set_object_rotation("Room_N_2_Leaf001", 0)
|
||||
game_api.set_object_rotation("Hall_Leaf001", 0)
|
||||
game_api.set_object_rotation("Room_S_2_Leaf001", 0)
|
||||
|
||||
|
||||
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")
|
||||
@@ -351,13 +491,12 @@ game_api.set_darklands_callbacks(
|
||||
game_api.npc_set_position(4, -5.0,0,12)
|
||||
game_api.npc_set_position(5, 5.0,0,12)
|
||||
end
|
||||
|
||||
night_time = false
|
||||
|
||||
game_api.switch_navigation(6)
|
||||
player_in_darklands = true
|
||||
|
||||
end,
|
||||
function()
|
||||
player_in_darklands = false
|
||||
game_api.start_cutscene("darklands_exit001")
|
||||
game_api.set_npc_enabled(0, false)
|
||||
game_api.set_npc_enabled(1, false)
|
||||
@@ -365,11 +504,46 @@ game_api.set_darklands_callbacks(
|
||||
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(0) -- todo fix
|
||||
game_api.setIntValue("day", 1)
|
||||
game_api.setIntValue("need_sleep", 1)
|
||||
game_api.set_player_hp(10)
|
||||
player_left_darklands = true
|
||||
morning_did_open_door_index = 0
|
||||
setDay1MorningSetup()
|
||||
--game_api.switch_navigation(7)
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
else
|
||||
--All set before
|
||||
morning_can_open_door_index = 0
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
@@ -433,15 +607,15 @@ function setDay1setup()
|
||||
end
|
||||
|
||||
function setDay1MorningSetup()
|
||||
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.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.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)
|
||||
@@ -450,7 +624,6 @@ game_api.activate_interactive_object("Room_Cover_Main_Hall_001")
|
||||
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)
|
||||
@@ -461,17 +634,47 @@ game_api.activate_interactive_object("Room_Cover_Main_Hall_001")
|
||||
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)
|
||||
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)
|
||||
|
||||
if morning_did_open_door_index == 1 then
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_1_001")
|
||||
game_api.set_object_rotation("Room_S_0_Leaf001", 90)
|
||||
game_api.switch_navigation(8)
|
||||
elseif morning_did_open_door_index == 2 then
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_2_001")
|
||||
game_api.set_object_rotation("Room_S_1_Leaf001", 90)
|
||||
game_api.switch_navigation(9)
|
||||
elseif morning_did_open_door_index == 3 then
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
game_api.set_object_rotation("Room_S_2_Leaf001", 90)
|
||||
game_api.switch_navigation(10)
|
||||
elseif morning_did_open_door_index == 4 then
|
||||
game_api.deactivate_interactive_object("Room_Cover_North_2_001")
|
||||
game_api.set_object_rotation("Room_N_1_Leaf001", -90)
|
||||
game_api.switch_navigation(11)
|
||||
elseif morning_did_open_door_index == 5 then
|
||||
game_api.deactivate_interactive_object("Room_Cover_North_3_001")
|
||||
game_api.set_object_rotation("Room_N_2_Leaf001", -90)
|
||||
game_api.switch_navigation(12)
|
||||
elseif morning_did_open_door_index == 6 then
|
||||
game_api.deactivate_interactive_object("Room_Cover_Main_Hall_001")
|
||||
game_api.set_object_rotation("Hall_Leaf001", 90)
|
||||
game_api.switch_navigation(13)
|
||||
else
|
||||
game_api.switch_navigation(7)
|
||||
end
|
||||
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)
|
||||
|
||||
@@ -479,21 +682,23 @@ game_api.set_location_callbacks(
|
||||
local day = game_api.getIntValue("day")
|
||||
if (day>0) and (need_sleep==1) then
|
||||
setDay1MorningSetup()
|
||||
game_api.switch_navigation(0)
|
||||
--game_api.switch_navigation(7)
|
||||
elseif (day>0) then
|
||||
setDay1setup()
|
||||
game_api.switch_navigation(5)
|
||||
game_api.switch_navigation(3)
|
||||
else
|
||||
setDay0setup()
|
||||
game_api.switch_navigation(0)
|
||||
--Do nothing, it should have been already set up
|
||||
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)
|
||||
end
|
||||
)
|
||||
|
||||
setDay0setup()
|
||||
game_api.switch_navigation(0)
|
||||
|
||||
print("Lua script loaded successfully!")
|
||||
Reference in new issue
Block a user