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

	if db.actor:has_info("autojump_enabled") then
		local jname = jump_level_by_name[level.name()]
		if jname ~= nil then
			get_console():execute("flush")
			get_console():execute("jump_to_level "..jname)
		end
	end
end

function autojump()
	db.actor:give_info_portion("autojump_enabled")
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
				level.map_add_object_spot(obj.id, location, hint)
			else
				level.map_add_object_spot(obj.id, location, "")
			end
		end
	end
end

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

function remove_location_safe(sid, location)
	local sim = alife()
	if sim then
		local obj = sim:story_object(sid)
		if obj 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

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

function add_lchanger_location()
	local sim = alife()
	if sim then
		-- escape
		local obj = sim:story_object(91)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end

		-- garbage
		obj = sim:story_object(191)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_agroprom")
		end
		obj = sim:story_object(192)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_agroprom")
		end
		obj = sim:story_object(193)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_escape")
		end
		obj = sim:story_object(194)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_bar")
		end
		obj = sim:story_object(195)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_darkvalley")
		end
		obj = sim:story_object(196)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_darkvalley")
		end
		
		-- Kostya_levels
		local obj = sim:story_object(11501)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Рыжий Лес")
		end
		obj = sim:story_object(11502)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Пещеру")
		end
		obj = sim:story_object(11503)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Пещеру")
		end	
		obj = sim:story_object(11504)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end	
		obj = sim:story_object(11505)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_agroprom")
		end	
		obj = sim:story_object(11506)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Лесную Чащу")
		end	
		obj = sim:story_object(11507)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end	
		obj = sim:story_object(11508)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_darkvalley")
		end	
		obj = sim:story_object(11509)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_military")
		end	
		obj = sim:story_object(11510)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Логово")
		end	
		obj = sim:story_object(11511)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Лесную Чащу")
		end	
		obj = sim:story_object(11512)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_yantar")
		end	
		obj = sim:story_object(11513)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Лесную Чащу")
		end	
		obj = sim:story_object(11514)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Лесную Чащу")
		end	
		obj = sim:story_object(11515)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Логово")
		end	
		obj = sim:story_object(11516)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На АТП")
		end	
		obj = sim:story_object(11517)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Рыжий Лес")
		end	
		obj = sim:story_object(11518)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Потерянную Деревню")
		end	
		obj = sim:story_object(11519)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Генераторы")
		end	
		obj = sim:story_object(11520)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Генераторы")
		end
		obj = sim:story_object(11521)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Припять")
		end
		obj = sim:story_object(11522)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Варлаб")
		end
		obj = sim:story_object(11524)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На АТП")
		end
		obj = sim:story_object(11525)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Лиманск")
		end
		obj = sim:story_object(11526)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Радар")
		end
		obj = sim:story_object(11527)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Забытый Лес")
		end
		obj = sim:story_object(11528)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Рыжий Лес")
		end
		obj = sim:story_object(11529)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Лиманск")
		end
		obj = sim:story_object(11530)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Госпиталь")
		end
		obj = sim:story_object(11531)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Госпиталь")
		end
		obj = sim:story_object(11532)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Потерянную Деревню")
		end
		obj = sim:story_object(11534)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Болото")
		end
		obj = sim:story_object(11535)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Болото")
		end
		obj = sim:story_object(11536)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Болото")
		end
		obj = sim:story_object(11537)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Кордон")
		end
		obj = sim:story_object(11538)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Кордон")
		end
		obj = sim:story_object(11539)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Агропром")
		end
		obj = sim:story_object(11540)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "На Склады")
		end
		obj = sim:story_object(11541)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "В Рыжий Лес")
		end
		-----------------------------
		
		-- agroprom
		obj = sim:story_object(391)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end
		obj = sim:story_object(392)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end

		-- darkvalley
		obj = sim:story_object(415)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end
		obj = sim:story_object(416)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end
		obj = sim:story_object(417)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_escape")
		end

		-- rostok
		obj = sim:story_object(608)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_yantar")
		end
		
		-- bar
		obj = sim:story_object(592)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_military")
		end
		obj = sim:story_object(593)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_garbage")
		end
		obj = sim:story_object(594)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "bar_rostok")
		end

		-- military
		obj = sim:story_object(771)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_bar")
		end
		obj = sim:story_object(773)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_radar")
		end

		-- yantar
		obj = sim:story_object(925)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_rostok")
		end

		-- radar
		obj = sim:story_object(1007)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_pripyat")
		end
		obj = sim:story_object(1008)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_military")
		end

		-- pripyat
		obj = sim:story_object(833)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_radar")
		end
		obj = sim:story_object(832)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "to_aes")
		end
                        -- aes (++16.03.2008 by SA):
		obj = sim:story_object(31410)
		if obj then
			level.map_add_object_spot(obj.id, "level_changer", "To Pripyat")
		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
