local level_scripts = {
	escape_tasks,
	garbage_tasks,
	agroprom_tasks,
	darkvalley_tasks,
	bar_rostok_tasks,
    yantar_tasks,
    mil_tasks,
	radar_tasks,
	pripyat_tasks
}


local jump_level_by_name = {
	l01_escape				= "l02_garbage",
	l02_garbage				= "l03_agroprom",
	l03_agroprom			= "l03u_agr_underground",
	l03u_agr_underground	= "l04_darkvalley",
	l04_darkvalley			= "l04u_labx18",
	l04u_labx18				= "l05_bar",
	l05_bar					= "l06_rostok",
	l06_rostok				= "l07_military",
	l07_military			= "l08_yantar",
	l08_yantar				= "l08u_brainlab",
	l08u_brainlab			= "l10_radar",
	l10_radar				= "l10u_bunker",
	l10u_bunker				= "l11_pripyat",
	l11_pripyat				= "l12_stancia",
	l12_stancia				= "l12u_sarcofag",
	l12u_sarcofag			= "l12u_control_monolith",
	l12u_control_monolith	= "l12_stancia_2",
	l12_stancia_2			= "l01_escape"
}

function proceed()
	if db.actor == nil then
		return
	end
	for k, v in pairs( level_scripts ) do
		v.proceed()
	end

end

function autojump()
end

function process_info_portion(info_id)
	if db.actor == nil then
		return
	end
	for k, v in pairs( level_scripts ) do
		if v.process_info_portion(info_id) then
			return
		end
	end
end

function add_location(sid, location, hint)
	local sim = alife()
	if sim then
		local obj = sim:story_object(sid)

		if obj then
			if hint then
				if(_G.dev_debug) then
					level.map_add_object_spot(obj.id, location, hint)
				end
			else
				if(_G.dev_debug) then
					level.map_add_object_spot(obj.id, location, "")
				end
			end
		end
	end
end

function remove_location(sid, location)
	local sim = alife()
	if sim then
		local obj = sim:story_object(sid)
        if(_G.dev_debug) then
			if obj and level.map_has_object_spot(obj.id, location) then
				level.map_remove_object_spot(obj.id, location)
			end
		end
	end
end

function remove_location_safe(sid, location)
	local sim = alife()
	if sim then
		local obj = sim:story_object(sid)
		if obj then
            if(_G.dev_debug) then
	           for a = 1, level.map_has_object_spot(obj.id, location), 1 do
	               level.map_remove_object_spot(obj.id, location)
	           end
			end
		end
	end
end

function is_map_spot_present(sid, location)
	local sim = alife()
	if sim then
		local obj = sim:story_object(sid)
        if(_G.dev_debug) then
	        if obj and level.map_has_object_spot(obj.id, location) ~= 0 then
	           return true
	        end
		end
	end
	return false
end


function add_lchanger_location()
	local sim = alife()
	if sim then
------------------------------ MARSH -------------------------------------------
		local obj = sim:story_object(311)
		set_lchanger_mapspot(obj, "level_changer_up_right", "st_lchanger_to_escape")

		obj = sim:story_object(312)
		set_lchanger_mapspot(obj, "level_changer_right", "st_lchanger_to_escape")

		obj = sim:story_object(313)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_agroprom")
------------------------------ ESCAPE ------------------------------------------
		obj = sim:story_object(445)
		set_lchanger_mapspot(obj, "level_changer_left", "st_lchanger_to_marsh")

		obj = sim:story_object(446)
		set_lchanger_mapspot(obj, "level_changer_down_left", "st_lchanger_to_marsh")

		obj = sim:story_object(443)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_garbage")

		obj = sim:story_object(444)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_garbage")

		obj = sim:story_object(447)
		set_lchanger_mapspot(obj, "level_changer_up_right", "st_lchanger_to_darkvalley")
------------------------------ GARBAGE -----------------------------------------
		obj = sim:story_object(713)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_escape")

		obj = sim:story_object(714)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_escape")

		obj = sim:story_object(726)
		set_lchanger_mapspot(obj, "level_changer_right", "st_lchanger_to_darkvalley")

		obj = sim:story_object(716)
		set_lchanger_mapspot(obj, "level_changer_right", "st_lchanger_to_darkvalley")

		obj = sim:story_object(712)
		set_lchanger_mapspot(obj, "level_changer_down_left", "st_lchanger_to_agroprom")

		obj = sim:story_object(707)
		set_lchanger_mapspot(obj, "level_changer_down_left", "st_lchanger_to_agroprom")

		obj = sim:story_object(704)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_red_forest")

		obj = sim:story_object(705)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_military")
------------------------------ DARKVALLEY --------------------------------------
		obj = sim:story_object(1127)
		set_lchanger_mapspot(obj, "level_changer_left", "st_lchanger_to_garbage")

		obj = sim:story_object(1128)
		set_lchanger_mapspot(obj, "level_changer_left", "st_lchanger_to_garbage")

		obj = sim:story_object(1126)
		set_lchanger_mapspot(obj, "level_changer_down_left", "st_lchanger_to_escape")
------------------------------ AGROPROM ----------------------------------------
		obj = sim:story_object(1028)
		set_lchanger_mapspot(obj, "level_changer_up_right", "st_lchanger_to_garbage")

		obj = sim:story_object(1029)
		set_lchanger_mapspot(obj, "level_changer_up_right", "st_lchanger_to_garbage")

		obj = sim:story_object(1032)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_marsh")

		obj = sim:story_object(1030)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_yantar")

		obj = sim:story_object(1031)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_yantar")
--[[
		obj = sim:story_object(1025)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_agroprom_und")

		obj = sim:story_object(1026)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_agroprom_und")
]]
------------------------------ AGROPROM UND ------------------------------------
		obj = sim:story_object(1371)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_agroprom")
------------------------------ YANTAR ------------------------------------------
		obj = sim:story_object(811)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_agroprom")

		obj = sim:story_object(812)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_agroprom")

		obj = sim:story_object(813)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_red_forest")
------------------------------ RED FOREST --------------------------------------
		obj = sim:story_object(526)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_garbage")

		obj = sim:story_object(527)
		set_lchanger_mapspot(obj, "level_changer_left_up", "st_lchanger_to_limansk")

		obj = sim:story_object(528)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_military")

		obj = sim:story_object(529)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_yantar")
------------------------------ MILITARY ----------------------------------------
		obj = sim:story_object(1266)
		set_lchanger_mapspot(obj, "level_changer_left_up", "st_lchanger_to_red_forest")

		obj = sim:story_object(1265)
		set_lchanger_mapspot(obj, "level_changer_down", "st_lchanger_to_garbage")
------------------------------ LIMANSK -----------------------------------------
		obj = sim:story_object(620)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_hospital")
------------------------------ HOSPITAL ----------------------------------------
		obj = sim:story_object(234)
		set_lchanger_mapspot(obj, "level_changer_up", "st_lchanger_to_aes")
	end
end

function set_lchanger_mapspot(obj, spot, hint)
    if obj then
		local obj_id = obj.id
        local ce_obj = level.object_by_id(obj_id)
        if ce_obj then
            if ce_obj:is_level_changer_enabled() then
	            if level.map_has_object_spot(obj_id, spot) == 0 then
	                level.map_add_object_spot(obj_id, spot, hint)
	            end
            end
        else
            if level.map_has_object_spot(obj_id, spot) == 0 then
                level.map_add_object_spot(obj_id, spot, hint)
            end
        end
    end
end

function del_lchanger_mapspot(sid)
    local ce_obj = level_object_by_sid(sid)
    if ce_obj then
		local spot = ""
		if sid == 313 or sid == 443 or sid == 444 or sid == 704 or sid == 705
		or sid == 1030 or sid == 1031 or sid == 1371 or sid == 813 or sid == 528
		or sid == 620 or sid == 234 then
			spot = "level_changer_up"
		elseif sid == 311 or sid == 447 or sid == 1028 or sid == 1029 then
			spot = "level_changer_up_right"
		elseif sid == 312 or sid == 726 or sid == 716 then
			spot = "level_changer_right"
--		elseif sid == then
--			spot = "level_changer_right_down"
		elseif sid == 713 or sid == 714 or sid == 1032 --or sid == 1025 or sid == 1026
		or sid == 811 or sid == 812 or sid == 526 or sid == 529 or sid == 1265 then
			spot = "level_changer_down"
		elseif sid == 446 or sid == 712 or sid == 707 or sid == 1126 then
			spot = "level_changer_down_left"
		elseif sid == 445 or sid == 1127 or sid == 1128 then
			spot = "level_changer_left"
		elseif sid == 527 or sid == 1266 then
			spot = "level_changer_left_up"
		end
		if level.map_has_object_spot(ce_obj:id(), spot) ~= 0 then
            level.map_remove_object_spot(ce_obj:id(), spot)
        end
    end
end

function set_task_state(id_state, id_task, id_subtask)
	if db.actor then
		db.actor:set_task_state(id_state, id_task, id_subtask)
	end
end

function notify_new_task()
end
