-- ============================================
-- NPC PATROL WAYPOINTS
-- ============================================

local function step2()
    game_api.npc_walk_to(0, 1.03298, 0, -4.61801, step1)
end

function step1()
    game_api.npc_walk_to(0, -6.65295, 0, 4.15397, step2)
end

step1()

game_api.start_dialogue("dialog_start001")

phone_picked_up = false
journal_picked_up = false

function on_npc_interact(npc_index)
	if npc_index == 2 then
		local player_alik_aware = game_api.getIntValue("player_alik_aware")
		local player_container_aware = game_api.getIntValue("player_container_aware")
		if player_container_aware == 1 then
		game_api.start_dialogue("dialog_alik003")
		elseif player_alik_aware == 1 then
		game_api.start_dialogue("dialog_alik002")
		game_api.setIntValue("player_container_aware", 1)
		else
		game_api.start_dialogue("dialog_alik001")
		end
	end
	if npc_index == 0 then
		game_api.start_dialogue("dialog_female_student001")
	end
	if npc_index == 1 then
		game_api.start_dialogue("dialog_female_student002")
	end
end


function on_phone_pickup()
game_api.pickup_item("phone")
game_api.deactivate_interactive_object("Phone001")
game_api.start_dialogue("dialog_phone_pickup001")
phone_picked_up = true
end

function on_journal_pickup()
game_api.pickup_item("journal")
game_api.deactivate_interactive_object("Journal001")
game_api.start_dialogue("dialog_journal_pickup001")
journal_picked_up = true
end

function pickup_phone_zone001_enter_callback()
	print("pickup_phone_zone001_enter_callback--!")
	if (not phone_picked_up) or (not journal_picked_up) then
    game_api.start_dialogue("dialog_phone001")
	game_api.switch_navigation(1)
	end
end

function pickup_phone_zone001_exit_callback()
    print("pickup_phone_zone001_exit_callback--!")
	game_api.switch_navigation(0)
end

game_api.set_trigger_zone_callbacks("pickup_phone_zone001",
    pickup_phone_zone001_enter_callback,
    pickup_phone_zone001_exit_callback
)

function ladder_zone001_enter_callback()
game_api.start_dialogue("dialog_second_floor001")
end

game_api.set_trigger_zone_callbacks("ladder_zone001",
    ladder_zone001_enter_callback,
    nil
)

function on_bed_sleep()
local need_sleep = game_api.getIntValue("need_sleep")
print("Lua script need sleep =")
print(need_sleep)
if (need_sleep==0) then
game_api.start_dialogue("dialog_no_sleep001")
else
game_api.start_cutscene("sleep_cutscene001")
game_api.setIntValue("need_sleep", 0)
game_api.set_player_hp(200)
end
end

game_api.set_location_callbacks(
    function()
		print("Enter location dorm")
        local hp = game_api.getFloatValue("player_hp")
		game_api.set_player_hp(hp)
    end,
    function()
		print("Exit location dorm")
        local hp = game_api.get_player_hp()
		game_api.setFloatValue("player_hp", hp)
    end
)


print("Lua script loaded successfully--!")