function create_level_changer(
p_story_id, -- STORY_ID нового level_changer (понадобится нам позже)
p_position, -- вектор, координаты точки, в которой будет располагаться центр нового level_changer
p_lvertex_id, -- level_vertext_id - идентифицируют уровень, на котором будет создан level_changer
p_gvertex_id, -- game_vertext_id 

p_dest_lv, -- level_vertex_id - идентифицируют уровень, на который level_changer будет перебрасывать игрока 
p_dest_gv, -- game_vertex_id
p_dest_pos, -- координаты точки, в которой на новом уровне окажется игрок
p_dest_dir, -- направрение взгляда игрока
p_dest_level, -- название уровня, например "L11_Pripyat"
p_silent -- следует задать 1, чтобы подавить вопрос о смене уровня (автоматический переход)
)
local obj = alife():create("level_changer", p_position, p_lvertex_id, p_gvertex_id)

level.map_add_object_spot(obj.id, "level_changer", "")

local packet = net_packet()
obj:STATE_Write(packet)

-- свойства cse_alife_object
local game_vertex_id = packet:r_u16()
local cse_alife_object__unk1_f32 = packet:r_float()
local cse_alife_object__unk2_u32 = packet:r_u32()
local level_vertex_id = packet:r_u32()
local object_flags = packet:r_u32()
local custom_data = packet:r_stringZ()
local story_id = packet:r_u32()
local spawn_story_id = packet:r_u32()

-- свойства cse_shape
local shape_count = packet:r_u8()
for i=1,shape_count do
local shape_type = packet:r_u8()
if shape_type == 0 then
-- sphere
local center = packet:r_vec3()
local radius = packet:r_float()
else
-- box
local axis_x_x = packet:r_float()
local axis_x_y = packet:r_float()
local axis_x_z = packet:r_float()
local axis_y_x = packet:r_float()
local axis_y_y = packet:r_float()
local axis_y_z = packet:r_float()
local axis_z_x = packet:r_float()
local axis_z_y = packet:r_float()
local axis_z_z = packet:r_float()
local offset_x = packet:r_float()
local offset_y = packet:r_float()
local offset_z = packet:r_float()
end
end

-- свойства cse_alife_space_restrictor
local restrictor_type = packet:r_u8()

-- свойства cse_level_changer
local dest_game_vertex_id = packet:r_u16() 
local dest_level_vertex_id = packet:r_u32() 
local dest_position = packet:r_vec3()
local dest_direction = packet:r_vec3()
local dest_level_name = packet:r_stringZ()
local dest_graph_point = packet:r_stringZ()
local silent_mode = packet:r_u8()


packet:w_begin(game_vertex_id) -- game_vertex_id
packet:w_float(cse_alife_object__unk1_f32)
packet:w_u32(cse_alife_object__unk2_u32) 
packet:w_u32(level_vertex_id) -- level_vertex_id
packet:w_u32( bit_not(193) ) -- object_flags = -193 = 0xFFFFFF3E
packet:w_stringZ(custom_data)
packet:w_u32(p_story_id) -- story_id
packet:w_u32(spawn_story_id)

packet:w_u8(1) -- количество фигур
-- packet:w_u8(0) -- тип фигуры: сфера
-- packet:w_vec3(vector():set(0, 0, 0)) -- sphere_center
-- packet:w_float(3.0)
packet:w_u8(1) -- тип фигуры: box
packet:w_float(1) -- axis_x_x
packet:w_float(0) -- axis_x_y
packet:w_float(0) -- axis_x_z
packet:w_float(0) -- axis_y_x
packet:w_float(1) -- axis_y_y - высота
packet:w_float(0) -- axis_y_z
packet:w_float(0) -- axis_z_x
packet:w_float(0) -- axis_z_y
packet:w_float(1) -- axis_z_z
packet:w_float(0) -- offset_x
packet:w_float(0) -- offset_y
packet:w_float(0) -- offset_z

packet:w_u8(3) -- restrictor_type

packet:w_u16(p_dest_gv) -- destination game_vertex_id
packet:w_s32(p_dest_lv) -- destination level_vertex_id
packet:w_vec3(p_dest_pos) -- destination position
packet:w_vec3(p_dest_dir) -- destination direction (направление взгляда)
packet:w_stringZ(p_dest_level) -- destination level name
packet:w_stringZ("start_actor_02") -- some string, always const
packet:w_u8(p_silent) -- 1 for silent level changing

packet:r_seek(0)
obj:STATE_Read(packet, packet:w_tell())
 news_manager.send_tip(db.actor, "Переход открыт!", nil, nil, 20000)
end

------------------------------ Переходы ----------------------------------------------------

function tropa_dead_city()
	-- создается переход c Янтаря в Мёртвый Город
	if (not has_alife_info("info_tropa_dead_city")) then
	y_level.create_level_changer(15014, vector():set( -24.646,0.231,0 ),29988,1500,
        85682,
        3594,
        vector():set( -257.120,3.651,-138.280 ),
        vector():set( 0,0,0 ),"dead_city",0)
        db.actor:give_info_portion("info_tropa_dead_city")
	end
end


function tropa_x16()
	-- создается переход c Янтаря в Лабораторию Х-16
	if (not has_alife_info("info_tropa_yantar_to_x16")) then
	y_level.create_level_changer(15035, vector():set( 3.014,-5.435,-13.980 ),40759,1461,
        7774,
        1541,
        vector():set( 147.420,34.815,-16.560 ),
        vector():set( 0,-1.597,0 ),"l08u_brainlab",1)
        db.actor:give_info_portion("info_tropa_yantar_to_x16")
	end
end


function tropa_dead_city_atp()
	-- создается переход из Мёртвого Города на АТП
	if (not has_alife_info("info_tropa_dead_city_to_atp")) then
	y_level.create_level_changer(15015, vector():set( 145.852,1.084,-138.786 ),480427,3654,
        839201,
        2848,
        vector():set( 323.746,-5.719,-367.760 ),
        vector():set( 0,0,0 ),"atp_for_test22",0)
        db.actor:give_info_portion("info_tropa_dead_city_to_atp")
	end
end


function tropa_military_atp()	
	-- создается переход c Военных Складов на АТП
	if (not has_alife_info("info_military_to_atp")) then
	y_level.create_level_changer(15023, vector():set( -383.019,-14.075,399.236 ),364,1848,
        1005985,
        2860,
        vector():set( 438.538,-4.856,-25.308 ),
        vector():set( 0,1.56,-1.0 ),"atp_for test22",0)
        db.actor:give_info_portion("info_military_to_atp")
	end
end


function tropa_av_peshera()
	-- создается переход из Рыжего Леса в Логово
	if (not has_alife_info("info_tropa_red_forest_av_peshera")) then
	y_level.create_level_changer(15021, vector():set( 251.160,5.081,107.941 ),153209,3319,
        6973,
        2912,
        vector():set( -373.501,84.917,203.121 ),
        vector():set( 0,-3.15,0 ),"av_peshera",0)
        db.actor:give_info_portion("info_tropa_red_forest_av_peshera")
	end
end


function tropa_peshera()
	-- создается переход из Рыжего Леса в Пещеру
	if (not has_alife_info("info_tropa_red_forest_peshera")) then
	y_level.create_level_changer(15022, vector():set( 201.826,4.555,116.989 ),130978,3319,
        32106,
        2880,
        vector():set( -11.002,-2.493,-0.036 ),
        vector():set( 0,1.56,-1 ),"peshera",0)
        db.actor:give_info_portion("info_tropa_red_forest_peshera")
	end
end


function lift_v_x8()
	-- создается переход из Восточной Припяти в Х-8
	if (not has_alife_info("lift_x8")) then
	y_level.create_level_changer(15013, vector():set(-78.087,0.302,101.594),111631,3754,
        3749,
        3838,
        vector():set(-77.6999969482422,-7.77326774597168,93.8000030517578),
        vector():set(   0.0,-3.15,-1.0 ),"labx8",0)
        db.actor:give_info_portion("lift_x8")
	end
end


function tropa_darkvalley()
	-- создается переход с Кордона в Тёмную Долину
	if (not has_alife_info("info_tropa_escape_to_darkvalley")) then
	y_level.create_level_changer(15029, vector():set( 383.255,15.177,-58.042 ),594452,0,
        121686,
        815,
        vector():set( -45.070,0.434,-559.317 ),
        vector():set( 0,0,0 ),"l04_darkvalley",0)
        db.actor:give_info_portion("info_tropa_escape_to_darkvalley")
	end
end


function tropa_marsh()
	-- создаются переходы с Кордона на Болота
	if (not has_alife_info("info_tropa_escape_to_marsh_1")) then
	y_level.create_level_changer(15032, vector():set( -146.927,6.851,234.959 ),103572,167,
        528737,
        3580,
        vector():set( 674.673,8.377,418.678 ),
        vector():set( 0,1.56,-1 ),"marsh",0)
        db.actor:give_info_portion("info_tropa_escape_to_marsh_1")
	end	
	-----------------------------------------------------------------------------------------
	if (not has_alife_info("info_tropa_escape_to_marsh_2")) then
	y_level.create_level_changer(15033, vector():set( -247.764,-25.937,-324.444 ),11222,37,
        519277,
        3573,
        vector():set( 597.578,0.821,-186.237 ),
        vector():set( 0,1.56,-1 ),"marsh",0)
        db.actor:give_info_portion("info_tropa_escape_to_marsh_2")
	end
end


function tropa_tunnel()
	if (not has_alife_info("info_tropa_tunnel_1")) then
	y_level.create_level_changer(15041, vector():set( 116.315,-9.098,49.442 ),401225,1558,
        318456,
        4040,
        vector():set( -124.899,21.639,-74.782 ),
        vector():set( 0,-1.56,-1 ),"garbage_old",0)
        db.actor:give_info_portion("info_tropa_tunnel_1")
	end	
	-----------------------------------------------------------------------------------------
	if (not has_alife_info("info_tropa_tunnel_2")) then
	y_level.create_level_changer(15042, vector():set( 246.264,11.640,-108.452 ),1158685,4333,
        103931,
        4344,
        vector():set( -72.173,-13.903,-20.698 ),
        vector():set( 0,0,0 ),"yantar_old",0)
        db.actor:give_info_portion("info_tropa_tunnel_2")
	end
	-----------------------------------------------------------------------------------------
	if (not has_alife_info("info_tropa_tunnel_3")) then
	y_level.create_level_changer(15043, vector():set( -70.048,-10.766,-25.851 ),210155,4384,
        1154464,
        4333,
        vector():set( 242.686,11.654,-106.314 ),
        vector():set( 0,1.56,-1 ),"garbage_old",0)
        db.actor:give_info_portion("info_tropa_tunnel_3")
	end	
	-----------------------------------------------------------------------------------------
	if (not has_alife_info("info_tropa_tunnel_4")) then
	y_level.create_level_changer(15044, vector():set( -129.295,21.651,-72.502 ),304646,4040,
        401215,
        1558,
        vector():set( 108.081,-13.024,45.651 ),
        vector():set( 0,1.56,-1 ),"alife_l07_military",0)
        db.actor:give_info_portion("info_tropa_tunnel_4")
	end
end

function tropa_zona()
	-- создается переход с Кордона в Пещеру
	if (not has_alife_info("info_tropa_kanjon_to_peschera")) then
	y_level.create_level_changer(31425, vector():set( -269.842,11.063,219.124 ),524434,3930,
        1597,
        2863,
        vector():set( -174.425,-2.352,-77.691 ),
        vector():set( 0,0,0 ),"l04_darkvalley",1)
        db.actor:give_info_portion("info_tropa_kanjon_to_peschera")
	end
end



function delete_chaes2_sar()
	local sim = alife()
	local se_obj = sim:story_object(31320)
	if se_obj then
		sim:release(se_obj, true)
	end 
	local actor = db.actor
end

