function delete_black_doctor_timer()
	timer("run", 15.0, "braad_test.delete_black_doctor()")
end

function luis_killself_timer()
	timer("run", 1.0, "braad_test.luis_killself()")
end

-- Выдадим тайник на АТП от Жилы и заспавним туда особое пиво, 60 банок
function add_krysyk_pomer_treasure()
	got_treasure("atp_arhara_secret_2")
	local se_obj = story_object(18018)
	if se_obj then
        	create_parent("oceanic815",60,se_obj)
	end
end

function main_friend(npc)
	npc:set_relation(game_object.friend, db.actor)
end

function zombie_blow()
	create("burer_strong",xyz(-108.363,21.564,-35.483),312,1529)
	create("m_poltergeist_dd",xyz(-108.363,21.564,-35.483),312,1529)
	create("bloodsucker_effector",xyz(-146.986,-19.088,-72.524),1082,1457)
	create("cat_strong",xyz(-85.379,-19.090,-49.233),9988,1495)
	create("cat_strong",xyz(-85.379,-19.090,-49.233),9988,1495)
	create("cat_strong",xyz(-85.379,-19.090,-49.233),9988,1495)
	create("cat_strong",xyz(-85.379,-19.090,-49.233),9988,1495)
	create("cat_strong",xyz(-86.602,-19.090,-171.465),9340,1455)
	create("cat_strong",xyz(-86.602,-19.090,-171.465),9340,1455)
end

function radar_man()
	create("m_controller_old_fat",xyz(-61.979244232178,-21.8962020874,35.8896102905),195,2727)
	create("m_controller_old",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_babka_normal",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_babka_strong",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_immortal",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_normal",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_normal",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_immortal",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_blow",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
	create("zombie_normal",xyz(0.86928582191467,-23.69577599,1.777916193),6155,2703)
end

function killactor (sid)
	timer("run", 7.0, "braad_test.killactor_spawn()")
local npc = level_story_object (9623)
    if npc == nil or npc:alive () == false then
       return
    end
    npc:set_relation (game_object.enemy, db.actor)
local npc = level_story_object (9624)
    if npc == nil or npc:alive () == false then
       return
    end
    npc:set_relation (game_object.enemy, db.actor)
local npc = level_story_object (9625)
    if npc == nil or npc:alive () == false then
       return
    end
    npc:set_relation (game_object.enemy, db.actor)
local npc = level_story_object (9905)
    if npc == nil or npc:alive () == false then
       return
    end
    npc:set_relation (game_object.enemy, db.actor)
end

function killactor_spawn()
	create("killer_boevik2",xyz(43.09783554,-8.13079166,14.410468),345215,1582)
	create("killer_boevik1",xyz(59.50757599,-8.5839643,9.3478708),358211,1570)
	create("killer_boevik3",xyz(59.52076721,-8.7670116,22.850177765),358227,1559)
	create("killer_boevik4",xyz(40.780555725,-8.319325447,19.2897949),343015,1582)
	create("killer_boevik5",xyz(46.9849434,-8.1420059,20.492004),348191,1582)
	create("killer_boevik6",xyz(51.40478897,-8.08700466,13.5054283),351374,1582)
	timer("run", 60.0, "braad_test.yakut_ograblen_sms()")
end
function yakut_ograblen_sms()
	sms("%c[sender]"..translate("name_mechenii")..":\\n%c[sms_red]"..translate("sms_strelok_yakut_ograblen_0"), nil, "meceniy", 13000, nil, [[sms\strelok\yakut_ograblen_sms]])
	timer("run", 13.0, "braad_test.yakut_ograblen_task()")
end
function yakut_ograblen_task()
	give_info("yakut_ograblen_before")
end

function kill_npc(sid)
local npc = level_story_object (9630)
    if npc == nil or npc:alive () == false then
       return
    end
    npc:kill(npc)
end

function take_yakut_agro2_spot()
	sak.add_spot_of_docent(9650)
end

function new_comp()
	create("computer_new",xyz(27.945556640625,-6.619695186615,-14.894629478455),6746,1140)
end

function release_actor_items(first_speaker,second_speaker)
	set_value("actor_money",db.actor:money()) --сохраняем деньги
	db.money = 0
	db.actor:give_money(-db.actor:money())
	give_info("pda_dont_work")
	second_speaker:stop_talk()
	first_speaker:stop_talk()
	timer("run", 0.6, "braad_test.start_gavr_sleep()")
end

function start_gavr_sleep()
	_G.Dream:sleep(1 + get_value("energy_drink", 0))
end

function release_actor_money()
  local num = db.actor:money()
  db.actor:give_money(-num)
  game_stats.money_quest_update(-num)
end

function friendactor()
	relation_registry.set_community_goodwill("stalker", db.actor:id(), relation_registry.community_goodwill("stalker", db.actor:id())+25)
end

function esc_sniper_dead()
	local value = get_value("esc_sniper_dead", 0)+1
	set_value("esc_sniper_dead", value)
  end
function atak_larger_have()
	return get_value("esc_sniper_dead", 0) > 11
end

function zahar_naemnik_dead()
	local value = get_value("zahar_naemnik_dead", 0)+1
	set_value("zahar_naemnik_dead", value)
  end
function zahar_naemnik_have()
	return get_value("zahar_naemnik_dead", 0) > 5
end

function sms_new()
	sms("%c[sender]"..translate("name_prizrak")..":\\n%c[sms_red]"..translate("sms_new_dan2_text"), 6, "prizrak", 15000) --, nil, [[sms\prizrak\sms_new_dan2_text]])
end

function delete_smart()
  local se_obj = server_object("ros_smart_stalker1")
  if se_obj then
    release(se_obj, true)
  end
end

function spawn_church_band()
	create("prov_ruk",xyz(-3.481797,3.3647267818451,12.3242),137219,3418)
	create("add_church_ban1",xyz(294.5813,7.1353683,-153.27551),327543,3531)
	create("add_church_ban2",xyz(294.5813,7.1353683,-153.27551),327543,3531)
	create("add_church_ban3",xyz(294.5813,7.1353683,-153.27551),327543,3531)
end

function spawn_bonus_box_marsh()
local b = {
	{position={x=-55.95,y=0.57,z=-85.44},gv=3395,lv=110210},
	{position={x=-175.02,y=4.44,z=-325.35},gv=3365,lv=52772},
	{position={x=187.09,y=2.635,z=488.94},gv=3485,lv=248471},
	{position={x=55.71,y=1.80,z=-219.285},gv=3443,lv=168151},
	{position={x=260.58,y=2.40,z=271.60},gv=3515,lv=304283},
	{position={x=111.09,y=8.90,z=-147.05},gv=3465,lv=201660}, 
	{position={x=-251.56,y=0.38,z=47.73},gv=3355,lv=19829},
	{position={x=18.41,y=-0.0855,z=11.51},gv=3418,lv=147818},
	{position={x=447.00,y=0.1525,z=-40.75},gv=3548,lv=437314},
	{position={x=-126.61,y=1.03,z=-279.46},gv=3381,lv=81231},
	{position={x=72.36,y=1.105,z=124.63},gv=3449,lv=175687},
	{position={x=281.869,y=0.41,z=-187.192},gv=3510,lv=316520},
	{position={x=-46.91,y=1.20,z=293.80},gv=3402,lv=115761},
	{position={x=576.56,y=2.80,z=452.53},gv=3568,lv=516712},
	{position={x=121.50,y=2.41,z=361.91},gv=3459,lv=204227},
	{position={x=-195.55,y=6.935,z=524.72},gv=3393,lv=114648},
	{position={x=-179.26,y=2.48,z=420.60},gv=3361,lv=51777},
	{position={x=-324.93,y=20.26,z=512.00},gv=3362,lv=49050},
	{position={x=527.60,y=4.272,z=-168.19},gv=3563,lv=498149},
	{position={x=453.21,y=0.60,z=-168.69},gv=3554,lv=436726},
	{position={x=278.96,y=4.95,z=42.77},gv=3519,lv=316215},
	{position={x=253.00,y=7.345,z=69.805},gv=3516,lv=297434},
	{position={x=539.97,y=11.92,z=249.00},gv=3557,lv=504529},
	{position={x=598.57,y=4.60,z=447.92},gv=3578,lv=521984},
	{position={x=185.53,y=13.00,z=532.56},gv=3484,lv=247436},
	{position={x=188.94,y=11.24,z=532.56},gv=3484,lv=250659},
	{position={x=389.906,y=2.52,z=223.75},gv=3546,lv=396641},
	{position={x=339.50,y=0.04,z=282.01},gv=3540,lv=358251}
}

	local indeses={}
	local first_spawn=not has_info("murka_spawn")
	log("first spawn "..(first_spawn and "yes" or "no"))
	if first_spawn then
		for i=1,table.size(b) do
			indeses[i]=i
		end
	else
		indeses=get_value("free_murka_spots",nil)
		if not indeses then
			abort("invalid spawn sequince")
		end
	end

	local main_spawn=table.random(indeses)
	indeses[main_spawn]=nil
	local fake_spawn={}
	for i=1,4 do 
		local fake_index=table.random(indeses)
		table.insert(fake_spawn,fake_index)
		indeses[fake_index]=nil
	end
	if first_spawn then
		set_value("free_murka_spots",indeses)
	end
	local main_pos=b[main_spawn]
	local se_obj = create(first_spawn and "space_restrictor" or "m_inventory_box_bonus_marsh", xyz(main_pos.position.x,main_pos.position.y,main_pos.position.z), main_pos.lv, main_pos.gv)
	if first_spawn then
		se_obj:set_ini_lua_string("[logic]\ncfg = scripts\\marsh\\marsh_murka_restr_1.ltx")
		se_obj:add_shape(2.5)
	end
	map_spot(se_obj.id, "crlc_big", "murka_spot")
	for index in pairs(fake_spawn) do
		local fake_pos=b[fake_spawn[index]]
		local se_obj = create("space_restrictor", xyz(fake_pos.position.x,fake_pos.position.y,fake_pos.position.z), fake_pos.lv, fake_pos.gv)
		se_obj:set_ini_lua_string("[logic]\ncfg = scripts\\marsh\\marsh_murka_restr.ltx")
		se_obj:add_shape(2.0)
		map_spot(se_obj.id, "crlc_big", "murka_spot")
	end
	if not first_spawn then
		del_value("free_murka_spots")
	end
end

function sed_village()
	local obj = create("m_inventory_box_sed_village",xyz(-70.64,-2.70,-272.62),103976,3407)
	map_spot(obj.id, "level_changer3", "sed_village_0")
end

-- правка вылета и неубирания худа при взятии рюкзака калмыка - перенесено в калбек на подъем
function mina_band2(obj)
	if level.main_input_receiver() then
		level.start_stop_menu(level.main_input_receiver(), true)
	end

	amk_particle.amk_particle({
		particle="explosions\\explosion_fuelcan",
		pos=db.actor:position(),
		sound=[[weapons\t_rgd5_explosion]]
	})

	local h = hit()
	h.draftsman = db.actor
	h.direction = vector():set(0,0,0)
	h:bone("bip01_spine")
	h.type = hit.explosion
	h.power = 1.8
	h.impulse = 500
	db.actor:hit(h)

	level.add_pp_effector("amk_shoot.ppe", 2011, false)
	level.add_pp_effector( "agr_u_fade.ppe", 8120804, false ) -- чтоб красивее было

	timer("run", 1, "braad_test.mina_band3()")
	release(snp.object_by_section_offline("prov_ruk"))
	braad_test.kalmyak_tele2()
end

function mina_band3()
	release(server_object(db.actor:object("grenade_rgd5_new"):id()))
end

-- правка вылета и неубирания худа при взятии рюкзака калмыка - перенесено в калбек на подъем
function kalmyak_tele2()
   give_info("teleport_started")
   level.add_pp_effector ("blink.ppe", 234, false)
   level.add_pp_effector("teleport.ppe", 2006, false)
   db.actor:set_actor_position(patrol("kalmyak_tele_walk"):point(0))
   local dir = patrol("kalmyak_tele_look"):point(0):sub(patrol("kalmyak_tele_look"):point(0))
   db.actor:set_actor_direction(-dir:getH())
   give_info("teleport_finished")
   give_info("kalmyak_vstreca_start")
end

function kalmyak_vrag(actor, npc)
    xr_gulag.setGulagEnemy("kalmyak_marsh", actor)
end

function kalmyak_spawn()
	local obj = create("a_inventory_box1",xyz(-199.24903869629,0.60609865188599,130.58129),38203,3383)
	map_spot(obj.id, "crlc_big", "set_kalmyak_ruk_0")
	local se_obj = create("space_restrictor",xyz(-194.6745300293,0.58615601062775,133.2268),38203,3383)
	local custom = "[logic]\ncfg = scripts\\marsh\\mar_kalmyak_restr1.ltx"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(3.0)
	local se_obj = create("space_restrictor",xyz(-190.16891479492,-0.44136956334114,125.738),38203,3383)
	local custom = "[logic]\ncfg = scripts\\marsh\\mar_kalmyak_restr2.ltx"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(3.0)
	local se_obj = create("space_restrictor",xyz(-192.65054321289,-0.32059952616692,119.033),38203,3383)
	local custom = "[logic]\ncfg = scripts\\marsh\\mar_kalmyak_restr3.ltx"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(3.0)
	local se_obj = create("space_restrictor",xyz(-201.21597290039,0.26242354512215,116.694),38203,3383)
	local custom = "[logic]\ncfg = scripts\\marsh\\mar_kalmyak_restr4.ltx"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(3.0)
	local se_obj = create("space_restrictor",xyz(-206.72094726563,-0.32424575090408,123.919),37907,3383)
	local custom = "[logic]\ncfg = scripts\\marsh\\mar_kalmyak_restr5.ltx"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(3.0)
	local se_obj = create("space_restrictor",xyz(-203.21374511719,-0.32538011670113,137.027),37907,3383)
	local custom = "[logic]\ncfg = scripts\\marsh\\mar_kalmyak_restr6.ltx"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(3.0)
end

function set_kalmyak()
	map_spot(server_object("kalmyak_marsh").id,"crlc_big","set_kalmyak_0")
end
function remove_kalmyak()
	del_map_spot(server_object("kalmyak_marsh").id,"crlc_big")
end

function set_red_contr()
	-- правка по потере мозга при сейв/лоаде.
	local se_obj = create("space_restrictor",xyz(-175.13674926,1.3927493095,423.02426147),54657,3361)
	local custom = "[logic]\nactive = sr_idle\n[sr_idle]\non_actor_inside = nil %=braad_test.spawn_red_contr%"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(50.0)
	map_spot(server_object("marsh_controller").id,"crlc_big","set_red_contr_0")
end

function spawn_red_contr()
	create("kontrik_red_mozg",xyz(-175.13674926,1.3927493095,423.02426147),54657,3361)
	create("biomassa",xyz(-211.56413269043,0.51584661006927,404.93756103516),36169,3361)
	create("biomassa",xyz(-178.06753540039,1.4863713979721,438.43334960938),52748,3361)
	create("biomassa",xyz(-163.55537414551,0.21918168663979,376.12561035156),62031,3371)
	for i=1,3 do
		create("zombie_hell"..tostring(math.random(15)),xyz(-175.13674926,1.3927493095,423.02426147),54657,3361)
	end
end

function remove_red_contr()
	local obj = server_object("marsh_controller")
	if obj then
		del_map_spot(obj.id,"crlc_big")
	end
end

function kashei_spawn()
	local obj = create("a_inventory_box5",xyz(406.22711181641,3.4233021736145,236.834),407402,3546)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function set_kashei()
	map_spot(server_object("kashei").id,"blue_location","set_kashei_0")
end
function remove_kashei()
	del_map_spot(server_object("kashei").id,"blue_location")
end
function reregistr_kashei()
	local kashei=server_object("kashei")
	if kashei then
		kashei:set_ini_lua_string("[logic]\ncfg = scripts\\marsh\\mar_kashei_new.ltx")
		ai:assign_story_id(kashei.id,14100)
	else
		log("! ERROR not found kashei in objects")
	end
end

function friendactornebo()
	relation_registry.set_community_goodwill("nebo", db.actor:id(), relation_registry.community_goodwill("nebo", db.actor:id())+30)
end

function kot_krovosos()
local position = db.actor:position()
	position.x = position.x + 25
local obj = create("bloodsucker_strong",position, db.actor:level_vertex_id(), db.actor:game_vertex_id())
local obj = create("burer_strong",position, db.actor:level_vertex_id(), db.actor:game_vertex_id())
end

function spawn_blizn_krug1()
	local obj = server_object("blizn_krug1")
	create("mono_note",obj.position,obj.m_level_vertex_id,obj.m_game_vertex_id,obj.id)
end
--- ищем монолитовцев вешаем метки
function set_televizor()
	map_spot(server_object("mar_treasure_19").id,"crlc_big","set_televizor_0")
	map_spot(server_object("dog_marsh").id,"crlc_big","set_televizor2_0")
	map_spot(server_object("bloodsuker_mar2").id,"crlc_big","set_televizor3_0")
	map_spot(server_object("bloodsuker_mar3").id,"crlc_big","set_televizor4_0")
	map_spot(server_object("marsh_zombi_hutor").id,"crlc_big","set_televizor5_0")
end
function remove_televizor()
	del_map_spot(server_object("mar_treasure_19").id,"crlc_big")
	del_map_spot(server_object("dog_marsh").id,"crlc_big")
	del_map_spot(server_object("bloodsuker_mar2").id,"crlc_big")
	del_map_spot(server_object("bloodsuker_mar3").id,"crlc_big")
	del_map_spot(server_object("marsh_zombi_hutor").id,"crlc_big")
end

function set_kot()
	map_spot(server_object("kot").id,"crlc_big","set_kot_0")
end
function remove_kot()
	del_map_spot(server_object("kot").id,"crlc_big")
end

function set_giant()
	map_spot(server_object("gigant_red_strong1").id,"crlc_big","set_giant_0")
end
function remove_giant()
	del_map_spot(server_object("gigant_red_strong1").id,"crlc_big")
end

function luis_killself()
local npc
	for i=0,65534 do
        npc = level_object(i)
        if npc and npc:name() == "brat_luis" then
		npc:kill(npc)
		say([[weapons\hpsa\hpsa_shoot]])
	break
        end
    end
end

function francuz_killself()
local npc
	for i=0,65534 do
        npc = level_object(i)
        if npc and npc:name() == "francuz" then
		npc:kill(npc)
		say([[weapons\colt\colt1911_shoot]])
	break
        end
    end
end

function zahar_to_red_forest()
  -- создается переход c АТП в КЛ
	local obj = create_lc(14101,xyz(-226.61,2.947,323.843),47907,2799,57555,3280,
	vector():set(-11.645,0.859,-426.491),
	vector():set(0,0,0),"red_forest",0)
	map_spot(obj.id, "level_changer1", "to_red_forest")

	local se_obj = create("lim_zone_teleport1",xyz(40.821,11.0686,215.0173),48310,3020)
	set_value("lim_zone_teleport1", se_obj.id)
	local se_obj = create("lim_zone_teleport2",xyz(60.28,3.30,350.82),55227,3025)
	set_value("lim_zone_teleport2", se_obj.id)
	create("hos_zone_teleport1",xyz(-86.273,25.844,674.829),3736,3044)
	create("hos_zone_teleport2",xyz(-104.113,34.25,615.65),127,3028)
	create("hos_zone_teleport3",xyz(-92.780,33.493,719.939),1801,3034)
end

function spawn_zombi_restr1()
	create("lim_sniper",xyz(36.775608062744,28.541257858276,197.56105041504),46539,3003)
	create("lim_sniper_ohr1",xyz(3.7273268699,13.70157623291,196.73896789551),26776,3010)
	create("lim_sniper_ohr2",xyz(15.121144294,13.698766708374,196.21144104004),34620,3010)
	create("lim_sniper_ohr3",xyz(4.3583545684,17.090801239014,198.5705871582),27241,3010)
	create("zombi_restr1",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr2",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr3",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr4",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr5",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	timer("run", 10.0, "braad_test.spawn_zombi_restr2()")
end
function spawn_zombi_restr2()
	create("zombi_restr1",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr2",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr3",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr4",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr5",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	timer("run", 10.0, "braad_test.spawn_zombi_restr3()")
end
function spawn_zombi_restr3()
	create("zombi_restr1",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr2",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr3",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr4",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
	create("zombi_restr5",xyz(5.4863138198853,10.999716758728,155.81025695801),28057,3010)
end

function spawn_glushitel()
	local obj = create("taynik_glushitel",xyz(-0.595,28.288,182.718),24359,3003)
	obj:set_direction(0,3.14,0)
end

function taynik_glushitel_delete()
	find_and_release("taynik_glushitel")
end
function glushitel_delete()
	lost_item("glushitel")
end

function start_glushitel_reload()
	lost("glushitel")
	local gtime = game.minutes()
	set_value("glushitel_reload", gtime + 300)
end

function is_reload_ready()
	local gtime = game.minutes()
	local ftime = get_value("glushitel_reload", 0)
	if gtime >= ftime then
		return true
	else
		return false
	end
end

function is_reload_not_ready()
	local gtime = game.minutes()
	local ftime = get_value("glushitel_reload", 0)
	if gtime <= ftime then
		return true
	else
		return false
	end
end

function clear_reload()
	spawn_restrictor.borman_glushitel_sr()
	del_value("glushitel_reload")
end

function set_xalyava()
	map_spot(server_object("esc_xalyava").id,"crlc_big","set_xalyava_0")
end

-- Нейтралим наймов и чн с военными, чтобы не мешали
function begin_xalyava()
    local obj
	for a=1,8 do
        obj = server_object("xalyava_naem"..a)
        if obj then
			relation_registry.set_community_goodwill("military", obj.id, 5000)
	    end
	end
	obj = server_object("xalyava")
	if obj then
		relation_registry.set_community_goodwill("military", obj.id, 5000)
    end
	obj = server_object("xalyava_drug")
	if obj then
		relation_registry.set_community_goodwill("military", obj.id, 5000)
    end
end

function remove_xalyava()
	del_map_spot(server_object("esc_xalyava").id,"crlc_big")
end

function speech_xalyava()
	sms("%c[sender]"..translate("name_halyava")..":\\n%c[sms_red]"..translate("sms_xalyava_speech_xalyava_0"), nil, "haliava", 60000, nil, [[sms\xalyava\speech_xalyava]])
end
-----------------------------turell---------------------------------------------------
function test_turrel()
local info_name = "info_turret_escape_spawn"
   if (get_value(info_name, false) == false) and
   (level:name() == "l01_escape") then
   set_value(info_name, true)
turret_mgun.create_turret("turret_nato",level_name, vector():set(-201.338,-20.307,-147.54),"bandit", "", 200,100) end
end

function turrel()
    turret_mgun.create_turret("turret_army", "l01_escape", vector():set(-191.44,-18.49,-151.513),62977,46, "military", "esc_blokpost", 120, 90)
end

function alife_dir(section,position,levelvertex,gamevertex,direction)
	local obj = create(section,position,levelvertex,gamevertex)
	map_spot(obj.id,"crlc_big","alife_dir_0")
end

function lim_turrel()
    if not has_info("lim_spawn_lim_turrel") then
alife_dir("trenoga_lim1",vector():set(61.824359893799,14.957581520081,246.21290588379),58766,3021,
          vector():set(0.17578122019768,0,0.98442924022675))
    give_info("lim_spawn_lim_turrel")
    end
end
-----------------------------turell---------------------------------------------------

function drink_vodka()
	db.actor:eat(db.actor:object("vodka"))
end

function rereg_scromnyi()
	netpacket:modify(server_object("scromnyi"), "custom_data", "[logic]\ncfg = scripts\\mil\\mil_scromnyi_new.ltx", "story_id", 14102)
end

-- Поменяем. Раби не превратится в зомби, а застрелится
function rabi_mad()
--[[
	local npc
	for i=0,65534 do
        npc = level_object(i)
        if npc and npc:alive() and npc:name() == "rabi" then
		npc:set_character_community("zombied", 0, 0)
	break
        end
    end
end
--]]
	timer("run", 4.25, "braad_test.rabi_killself()")
end

function rabi_killself()
local npc
	for i=0,65534 do
        npc = level_object(i)
        if npc and npc:name() == "rabi" then
		npc:kill(npc)
		say([[weapons\beretta\beretta_shoot]])
	break
        end
    end
end


function del_lim()
    if not has_info("info_del_lim_teleport") then
		local obj_id = get_value("lim_zone_teleport1", -1, true)
		local se_obj = server_object(obj_id)
        if se_obj then
          release(se_obj, true)
        end
		local obj_id = get_value("lim_zone_teleport2", -1, true)
		local se_obj = server_object(obj_id)
        if se_obj then
          release(se_obj, true)
        end
	give_info("info_del_lim_teleport")
	end
end

function speech_teleport()
	sms("%c[sender]"..translate("name_sviblov")..":\\n%c[sms_red]"..translate("speech_teleport_0_0"), nil, "sviblov", 20000, nil, [[sms\sviblov\speech_teleport]])
	give_info("nebo_kurier_first")
end

function kurier_dead()
local npc
	for i=0,65534 do
        npc = level_object(i)
        if npc and npc:name() == "nebo_kurier" then
		npc:kill(npc)
	break
        end
	end
end

function kurier_health(obj)
	if db.actor.health < 1 then
		db.actor.health = db.actor.health + 0.6
	end
end

function doctor_dal()
	got("medkit_scientic",1)
	got("antirad",1)
	db.actor:eat(db.actor:object("medkit_scientic"))
	db.actor:eat(db.actor:object("antirad"))
end

function actor_sleep_in_doc()
	_G.Dream:sleep(4 + get_value("energy_drink", 0))
end

function delete_black_doctor()
  local se_obj = server_object("black_doctor")
  if se_obj then
    release(se_obj, true)
  end
end

function spawn_shadowman()
	local obj = create("a_inventory_box4",xyz(23.914667129517,3.9985284805298,26.488586425781),80890,3263)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function speech_shadowman()
	sms("%c[sender]"..translate("name_shedoumen")..":\\n%c[sms_red]"..translate("speech_shadowman_0_0"), nil, "shadowman", 5000, nil, [[sms\shadowman\speech_shadowman]])
	timer("run", 10.0, "braad_test.shadowman_red_spn1()")
end
function shadowman_red_spn1()
	create("boar_normal_sh1",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh2",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh3",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh4",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh5",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("snork_normal_sh1",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh2",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh3",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh4",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh5",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	timer("run", 30.0, "braad_test.shadowman_red_spn2()")
end
function shadowman_red_spn2()
	create("boar_normal_sh6",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh7",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh8",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh9",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh10",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("snork_normal_sh6",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh7",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh8",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh9",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh10",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	timer("run", 30.0, "braad_test.shadowman_red_spn3()")
end
function shadowman_red_spn3()
	create("boar_normal_sh11",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh12",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh13",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh14",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("boar_normal_sh15",xyz(-9.1997413635254,0.043906480073929,-36.546310424805),60673,3290)
	create("snork_normal_sh11",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh12",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh13",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh14",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
	create("snork_normal_sh15",xyz(-22.176950454712,0.78433322906494,18.689910888672),49490,3263)
end

function mitya_is_dead()
	if not has_info("klyak_forest_doc_next") then
		timer("mitya_sms",math.random(180,200),"braad_test.mitya_sms()")
	end
end

function set_green()
	map_spot(server_object("green_forest").id,"crlc_big","set_green_0")
end
function remove_green()
	del_map_spot(server_object("green_forest").id,"crlc_big")
end

function grab_set1(actor, npc)
    xr_gulag.setGulagEnemy("grab_mitya_marsh", actor)
end

function mitya_kill()
local npc
	for i=0,65534 do
        npc = level_object(i)
        if npc and npc:name() == "mitya" then
		npc:kill(npc)
		say([[weapons\toz34_shoot_both]])
	break
        end
    end
end

function mitya_sms()
	sms("%c[sender]"..translate("name_sidorovich")..":\\n%c[sms_red]"..translate("sms_sidor_mitya_sms_0"), nil, "sidor", 30000, nil, [[sms\sidor\mitya_sms]])
	give_info("mitya_dead_sms_sidor")
end

function spawn_green()
	local obj = create("a_inventory_box3",xyz(228.335338,-7.298178,67.8218),143611,3319)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
--	timer("run", 3.0, "arhara_dialog.sms_denis_wound_start()")
end

function clear_actor(npc)
    local npc = db.actor
    npc:iterate_inventory(__del_item, npc)
end

function __del_item(npc, item)
    local section = item:section()
    if protected_items.actor_items_keep(section) == true then
        return false
    end
    release(server_object(item:id()), true)
end

function actor_has_money_50000()
  return has_money(50000)
end

function give_money_50000(t1,t2)
  lost_money(50000)
end

function actor_has_money_10000()
  return has_money(10000)
end

function give_money_10000(t1,t2)
  lost_money(10000)
end

function del_kot_marsh()
	local se_obj = server_object("kot")
	if se_obj then
   		release(se_obj, true)
	end
end

function spawn_zombi_forest()
    if not has_info("info_contr_spawn") then
		create("zombie_beee",xyz(-139.66778564453,-6.2611632347107,-57.55558013916),7320,3240)
		create("zombie_beee",xyz(-139.66778564453,-6.2611632347107,-57.55558013916),7320,3240)
		create("zombie_beee",xyz(-139.66778564453,-6.2611632347107,-57.55558013916),7320,3240)
		create("zombie_beee",xyz(-166.70251464844,2.2021112442017,-43.638122558594),4559,3240)
		create("zombie_beee",xyz(-166.70251464844,2.2021112442017,-43.638122558594),4559,3240)
		create("zombie_beee",xyz(-166.70251464844,2.2021112442017,-43.638122558594),4559,3240)
		create("zombie_beee",xyz(-150.7121887207,2.2457160949707,-32.752670288086),6685,3240)
		create("zombie_beee",xyz(-150.7121887207,2.2457160949707,-32.752670288086),6685,3240)
		create("zombie_beee",xyz(-150.7121887207,2.2457160949707,-32.752670288086),6685,3240)
    give_info("info_contr_spawn")
   end
end

function spawn_denis()
	create("killer_denis1",xyz(-154.03199768066,2.179135799408,-29.984512329102),6074,3240)
	create("killer_denis2",xyz(-168.93768310547,2.1791498661041,-25.87652015686),4320,3240)
	create("killer_denis3",xyz(-153.88787841797,2.1781146526337,-38.099498748779),6064,3240)
	create("killer_denis4",xyz(-150.86233520508,2.3751785755157,-45.025329589844),6540,3240)
	create("killer_denis5",xyz(-157.27326965332,2.2941052913666,-50.785617828369),5652,3240)
	create("killer_denis6",xyz(-115.58462524414,2.3102631568909,-55.957679748535),9854,3240)
	create("killer_denis7",xyz(-112.0415725708,2.3187811374664,-54.043090820313),10286,3240)
	create("killer_denis8",xyz(-103.67635345459,2.3016946315765,-56.758888244629),11667,3250)
	create("killer_denis9",xyz(-164.65612792969,2.2453947067261,-42.774707794189),4821,3240)
end

function spawn_ag_restr()
local se_obj = create("space_restrictor",xyz(-163.7038269043,0.33191874623299,-299.45358276367),73168,447)
local custom = "[logic]\ncfg = scripts\\agr\\agr_restr.ltx"
se_obj:set_ini_lua_string(custom)
se_obj:add_shape(60.0)
end

function gener_na_boloto_vert()
  -- вертушечный переход1
	create_lc(18100, vector():set(-104.6570892334,37.470596313477,-467.96307373047),214585,3096,208062,3484,
        vector():set(237.60340881348,26.244289398193,621.69653320313),
        vector():set(0,0,0),"marsh",1)
end

function boloto_na_gener_vert()
  -- вертушечный переход2
	create_lc(18101, vector():set(345.39685058594,7.8543429374695,-69.320671081543),360152,3528,216969,3096,
        vector():set(-102.54923248291,37.5275001525879,-466.853424072266),
        vector():set(0,0,0),"generators",1)
end

function sarcofag_derevny()
  -- фото-переход
	create_lc(18109, vector():set(-21.340265274048,69.629508972168,-31.520132064819),598,2417,35513,3335,
        vector():set(72.72,2.47,-68.49),
        vector():set(0,-1.6,0),"lost_village",1)
end

function control_monol_svalka()
  -- молния-переход
	create_lc(18110, vector():set(0.076748996973038,-34.357418060303,17.889852523804),1757,2512,137004,319,
        vector():set(-57.10103225708,17.666576385498,17.847587585449),
        vector():set(0,0,0),"l02_garbage",1)
end

function saxar_perexod()
  -- Сахар-переход
	create_lc(18111, vector():set(-111.25610351563,1.9637259244919,-289.08743286133),3983,1486,7244,1543,
        vector():set(-49.463424682617,27.120641708374,-11.838829040527),
        vector():set(0,0,0),"l08u_brainlab",1)
end

function mozg_yantar()
  -- мозг-переход
	create_lc(18112, vector():set(-45.602458953857,18.978830337524,-12.382658958435),2892,1530,62547,1505,
        vector():set(45.247611999512,9.7975540161133,-59.355667114258),
        vector():set(0,0,0),"l08_yantar",1)
end

function BitvaKL_rukzak()
	local obj = create("a_inventory_box6",xyz(201.8493347168,-2.1620719432831,-79.324325561523),129996,3316)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function bitvakl_pda_take()
    if not has_info("bitvakl_xvatit_spawn") then
		give_info("bitvakl_xvatit_spawn")
		say([[monsters\controller\controller_script_attack_0]])
		bitvakl_spawn()
		spawn_restrictor.bitvakl_sr1()
	end
end

local klpoints={
    {position={x=179.3902130127,y=-2.5856237411499,z=-67.094398498535},
        gv=3316,
        lv=119687},
    {position={x=232.40454101563,y=-1.7396693229675,z=-57.155769348145},
        gv=3316,
        lv=145476},
    {position={x=261.00622558594,y=-1.1188377141953,z=-96.045272827148},
        gv=3315,
        lv=156751},
    {position={x=237.57501220703,y=-4.7059030532837,z=-143.82832336426},
        gv=3315,
        lv=147314},
    {position={x=198.4962310791,y=-7.1063375473022,z=-139.28036499023},
        gv=3315,
        lv=129206},
    {position={x=200.56958007813,y=-6.1743240356445,z=-40.731639862061},
        gv=3317,
        lv=130430},
    {position={x=171.90243530273,y=-3.933501958847,z=-113.88834381104},
        gv=3315,
        lv=116166}
}
function bitvakl_spawn()
    local a, se_obj
	sms("%c[sender]"..translate("name_istochnik_neizvesten")..":\\n%c[sms_red]"..translate("sms_net_bitvakl_spawn_0"), nil, "nodata", 6000, nil, [[sms\net\bitvakl_spawn]])
	se_obj = create("af_blood_green",xyz(220.36111450195,-11.267262458801,-101.5218963623),138102,3315)
	for i=1,table.getn(klpoints) do
		a = klpoints[i]
		se_obj = create("m_controller_normal", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
		for i=1,1 do
			se_obj = create("zombie_normal", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
			se_obj = create("zombie_hell10", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
			se_obj = create("zombie_hell11", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
			se_obj = create("zombie_hell12", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
			se_obj = create("zombie_hell15", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
			se_obj = create("zombie_babka_strong", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
		end
	end
end

function lima_dead_city()
	create_lc(18113, db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id(),100962,3593,
        vector():set(-239.38876342773,-2.0321259498596,300.58901977539),
        vector():set(0,-2.41,0),"dead_city",1)
end

function dead_city_atpeshka()
  	if not has_info("dead_city_atpeshka" ) then
		local obj = create_lc(18114, vector():set(72.183212280273,-1.8766392469406,-207.6682434082),425926,3646,368029,2813,
		vector():set(-6.6572103500366,-2.087566614151,-367.70422363281),
		vector():set(0,0,0),"atp_for_test22",1)
		map_spot(obj.id, "level_changer2", "to_atp")
        	give_info("dead_city_atpeshka")
	end
	create("imitator_tele_final1",xyz(70.47,-1.87,-207.24),230761,3609)
end

function lab_under()
      -- создается переход с Х-8 в Путепровод Припять-1.
	local obj = create_lc(130022, vector():set(-62.54,-24.87,94.16),5923,3840,7,3771,
	vector():set(-59.74,8.16,435.01),
	vector():set(0,-2.4,0 ),"jupiter_underground",0)
        map_spot(obj.id, "level_changer3", "to_provod_1")
end

function under_pri1()
      -- создается переход из Путепровода Припять-1 в Восточную Припять.
	local obj = create_lc(130023, vector():set(82.61710357666,28.351526260376,-222.54681396484),40755,3827,415475,3765,
	vector():set(185.36628723145,-0.50833475589752,-257.73150634766),
	vector():set(0,0,0 ),"pripyat",0)
        map_spot(obj.id, "level_changer1", "to_east_pripiat")
end

function pri1_jup()
      -- создается переход с Восточной Припяти на Юпитер.
	local obj = create_lc(130024, vector():set(311.923400878906,1.0266540527344,155.452056884766),403978,3767,14261,3700,
	vector():set(-423.471588134766,-2.11602973937988,-232.060592651367),
	vector():set(0,-1.25,0 ),"jupiter",0)
        map_spot(obj.id, "level_changer2", "to_jupiter")
end

function jup_under()
      -- создается переход с Юпитера в Путепровод Припять-1.
	local obj = create_lc(130025, vector():set(317.50564575195,13.820494651794,-330.11264038086),1222808,3745,1239,3772,
	vector():set(-46.7059990844727,8.31999969482422,455.630987792969),
	vector():set(0,-3.2,0 ),"jupiter_underground",0)
        map_spot(obj.id, "level_changer3", "to_provod_1")
end

function pri1_zaton()
	local obj
      -- создается переход с Восточной Припяти на Затон
	obj = create_lc(130026, vector():set(172.45,-0.42,421.48),402199,3769,306096,3665,
	vector():set(-322.25,19.39,618.42),
	vector():set(0,3.14,0 ),"zaton",0)
        map_spot(obj.id, "level_changer1", "to_zaton")

	-- создается переход с Затона в Восточную Припять
	obj = create_lc(130030, vector():set(-323.57330322266,19.470890045166,627.18048095703),303639,3665,403721,3769,
	vector():set(173.92,-0.42,410.81),
	vector():set(0,3.4,0 ),"pripyat",0)
        map_spot(obj.id, "level_changer1", "to_east_pripiat")
end

function pri1_pri()
	-- создается переход с Восточной Припяти в Центральную Припять
	local obj = create_lc(130028, vector():set(-231.28132629395,-1.2101984024048,31.831085205078),6811,3750,258340,2149,
	vector():set(184.60,-2.20,235.68),
	vector():set(0,1.5,0 ),"l11_pripyat",0)
        map_spot(obj.id, "level_changer4", "to_central_pripiat")
end

function pri_pri1()
	-- создается переход с Центральной Припяти в Восточную Припять
	local obj = create_lc(130029, vector():set(189.59794616699,-2.1057658195496,232.89511108398),259791,2149,10983,3750,
	vector():set(-223.17,-0.79,34.10),
	vector():set(0,-1.6,0 ),"pripyat",0)
        map_spot(obj.id, "level_changer2", "to_east_pripiat")
end

function zat_jup()
      -- создается переход с Затона на Юпитер.
	local obj = create_lc(130031, vector():set(-289.74868774414,40.953075408936,-477.16955566406),369405,3669,751730,3723,
	vector():set(22.69,-2.83,475.46),
	vector():set(0,-3.24,0 ),"jupiter",0)
        map_spot(obj.id, "level_changer3", "to_jupiter")
end

function jup_zat()
      -- создается переход с Юпитера на Затон
	local obj = create_lc(130032, vector():set(-167.937,-1.468,484.276),433738,3711,373226,3669,
	vector():set(-285.567,41.011,-468.729),
	vector():set(0,-1.5,0 ),"zaton",0,3.0)
        map_spot(obj.id, "level_changer1", "to_zaton")
end

function jup_pri()
	-- создается переход с Юпитера в Восточную Припять.
	local obj = create_lc(130033, vector():set(-436.270477,-1.556059,-265.591339),4661,3700,232248,3756,
	vector():set(304.50463867188,-0.50692754983902,160.43954467773),
	vector():set(0,1.3,0 ),"pripyat",0)
        map_spot(obj.id, "level_changer4", "to_east_pripiat")
end

function lab_sar()
	-- создается переход с Лабиринта в Саркофаг.
	local obj = create_lc(130035, vector():set(-228.39886474609,17.315053939819,183.03189086914),99826,2950,7755,2417,
	vector():set(43.911926269531,49.282817840576,-31.283910751343),
	vector():set(0,0,0 ),"l12u_sarcofag",0)
        map_spot(obj.id, "level_changer2", "to_sarcofag")
end

function kor_bar_pri()
	local obj
	-- создается переход с Бара на Кордон.
	obj = create_lc(130038, vector():set(130.17,-3.86,9.72),35953,1238,11366,4,
	vector():set(-247.05,-24.80,-134.18),
	vector():set(0.05,-1.55,0 ),"l01_escape",0,1.8,true)
	netpacket:modify(obj,"custom_data","[pt_move_if_reject]\npath = way_bar_reject_to_escape")

	-- создается переход с Бара в Центральную Припять.
	obj = create_lc(130039, vector():set(130.25,-5.10,11.30),35953,1238,23504,2151,
	vector():set(-105.2287902832,-0.57660186290741,259.98217773438),
	vector():set(0,0,0 ),"l11_pripyat",0,1.8,true)

end

function pri_bar()
	-- создается переход с Центральной Припяти в Бар.
	local obj = create_lc(130040, vector():set(-108.4627532959,-0.087667495012283,272.69674072266),23517,2151,41941,1230,
	vector():set(161.09335327148,-0.0012683868408203,44.192863464355),
	vector():set(0,0,0 ),"l05_bar",0,1.8,true)
end

function kor_bar()
	-- создается переход с Кордона в Бар.
	local obj = create_lc(130037, vector():set(-239.00,-25.50,-133.31),12817,4,41941,1230,
	vector():set(161.09335327148,-0.0012683868408203,44.192863464355),
	vector():set(0,0,0 ),"l05_bar",0,1.8,true)
	netpacket:modify(obj,"custom_data","[pt_move_if_reject]\npath = way_escape_reject_to_bar")
end

function create_sarkbunker_exit()
	-- создается переход c САРКОФАГА в Х-10
	local obj = create_lc(31410, vector():set(-13.26,47.71,46.57 ),200,2417,7698,2773,
	vector():set(7.6585369,-23.5286808,17.2495479),
	vector():set(-0.00754,0,-0.999971508 ),"l10u_bunker",0)
	map_spot(obj.id, "level_changer3", "to_x10")

	-- создается переход из ЛАБ Х-10 в САРКОФАГ
	local obj = create_lc(31510, vector():set(20.072347640991,-23.523380279541,15.896005630493),8597,2773,414,2417,
	vector():set(-8.1581792831421,49.238555908203,44.329990386963),
	vector():set(0.0,-3.2,-1.0 ),"l12u_sarcofag",0)
	map_spot(obj.id, "level_changer1", "to_sarcofag")
end

function create_sarchaes2_exit()
	-- создается переход c САРКОФАГА на ЧАЭС-2
	local obj = create_lc(31610, vector():set(77.10116577,58.2671585,51.8668289),6406,2417,191103,2623,
	vector():set(655.869,0.156,141.635),
	vector():set(0.0,1.5,0.0),"l12_stancia_2",0)
	map_spot(obj.id, "level_changer1", "to_stancia_2")

	 -- создается переход c ЧАЭС-2 в САРКОФАГ
	local obj = create_lc(31710, vector():set(666.87,0.16,141.43),193046,2623,6406,2417,
	vector():set(93.37,60.52,52.52),
	vector():set(0.0,-3.2,0.0),"l12u_sarcofag",0)
	map_spot(obj.id, "level_changer3", "to_sarcofag")
end

-- Скриптовые переходы ОП-2.1
function darkscape_out()
	local obj
	-- создается переход из ТЛ в Чернобыль-1
	obj = create_lc(130041, vector():set(452.29,-1.28,-527.70),980887,4609,115711,8987,
	vector():set(-260.50,-85.78,621.28),
	vector():set(0,2.95,0 ),"l57_outskirts",0)
        map_spot(obj.id, "level_changer3", "to_chernobyl_1")

	-- создается переход из Чернобыля-1 в ТЛ
	obj = create_lc(130064, vector():set(-261.54,-85.57,629.83),114078,8987,975540,4609,
	vector():set(445.97,-1.59,-504.07),
	vector():set(0,0.55,0),"l41_darkscape_ogse",0)
        map_spot(obj.id, "level_changer1", "to_darkscape")
end

function marsh_zavod()
	local obj
	-- создается переход с Болот на Металлургический Завод.
	obj = create_lc(130042, vector():set(57.59,10.64,530.33),169752,3484,200182,8300,
	vector():set(164.26,-2.04,217.77),
	vector():set(0,-2.3,0 ),"l56_rostok_factory",0)
        map_spot(obj.id, "level_changer4", "to_met_plant")

	-- создается переход с Металлургического Завода на Болота.
	obj = create_lc(130043, vector():set(156.06,-2.77,221.36),193911,8304,173552,3484,
	vector():set(64.73,10.62,530.42),
	vector():set(0,-2.3,0 ),"marsh",0)
        map_spot(obj.id, "level_changer2", "to_swamp")
end

function military_forgotten()
	local obj
	-- создается переход со Складов на Стройплощадку
	obj = create_lc(130044, vector():set(142.11,-4.86,385.53),413521,1810,5885,9196,
	vector():set(-246.82,7.11,237.38),
	vector():set(0,-1.75,0 ),"l58_forgotten",0,6.5)
        map_spot(obj.id, "level_changer2", "to_construction_camp")

	-- создается переход со Стройплощадки на Склады
	obj = create_lc(130045, vector():set(-252.03,6.86,235.72),3822,9196,412803,1812,
	vector():set(137.06,-3.09,400.73),
	vector():set(0,1.5,0 ),"l07_military",0)
        map_spot(obj.id, "level_changer4", "to_military")
end

function darkscape_darkvalley()
	-- создается переход из Тёмной Лощины в ТД
	local obj = create_lc(130046, vector():set(-397.17758178711,1.3607201576233,638.25067138672),57679,4667,120811,815,
	vector():set(-45.26,0.43,-539.45),
	vector():set(0,0,0 ),"l04_darkvalley",0,3.5,true)
       	map_spot(obj.id, "level_changer", "to_darkvalley")
	netpacket:modify(obj,"custom_data","[pt_move_if_reject]\npath = way_darkscape_reject_to_darkvalley")
end

function darkvalley_darkscape()
	-- создается переход из Тёмной Долины в Тёмную Лощину
	local obj = story_object(417)
	if not obj then
		obj=create(ai:spawn_id(417))
	end
	map_spot(obj.id, "level_changer3", "to_darkscape")
end

function darkscape_escape()
	-- создается переход из Тёмной Лощины на Кордон
	local obj = create_lc(130047,vector():set(-608.302,-2.325,-392.696),811,4699,592029,0,
	vector():set(358.09,15.18,-35.86),
	vector():set(0,1.00,0 ),"l01_escape",0,3.5,true)
	netpacket:modify(obj,"custom_data","[pt_move_if_reject]\npath = way_darkscape_reject_to_escape")
        map_spot(obj.id, "level_changer4", "to_escape")
end

function escape_darkscape()
	-- создается переход с Кордона в Тёмную Лощину
	local obj = story_object(6002)
	if not obj then
		obj=create(ai:spawn_id(6002))
	end
	map_spot(obj.id, "level_changer2", "to_darkscape")
end

function bunkerd6_bunkerx10()
	-- создается переход из Бункера Д-6 В Лабораторию Х-10
	local obj = create_lc(130048, vector():set(11.38,8.61,79.52),37394,10313,4117,2782,
	vector():set(-11.42,-8.99,7.06),
	vector():set(0,-1.6,0 ),"l10u_bunker",0)
        map_spot(obj.id, "level_changer4", "to_x10")
end

function jup_x17()
	local obj
	-- создается переход с Юпитера в Х-17
	obj = create_lc(130049, vector():set(377.882,-5.074,360.301),1315193,3742,4460,5730,
	vector():set(-1.31,-0.01,-3.81),
	vector():set(0,0,0),"l47u_lab_x17",0)
        map_spot(obj.id, "level_changer3", "to_x17")

	-- создается переход из Х-17 на Юпитер
	obj = create_lc(130050, vector():set(0.83,-0.01,-8.62),4911,5731,1314232,3742,
	vector():set(377.064,-5.465,366.685),
	vector():set(0,0,0),"jupiter",0)
        map_spot(obj.id, "level_changer1", "to_jupiter")
end

function jup_kur()
	-- создается переход с Юпитера в Курчатов-37
	local obj = create_lc(130051, vector():set(449.85,27.67,-163.05),1430633,3741,49989,4258,
	vector():set(-7.53,-11.27,136.78),
	vector():set(0,-1.6,0 ),"l37_kurchatov",0)
        map_spot(obj.id, "level_changer2", "to_kurchatov")
end

function kur_jup()
	-- создается переход с Курчатов-37 на Юпитер
	local obj = create_lc(130052, vector():set(-14.72,-11.27,137.05),45964,4258,1417802,3741,
	vector():set(442.05,27.67,-163.56),
	vector():set(0,1.55,0 ),"jupiter",0)
        map_spot(obj.id, "level_changer4", "to_jupiter")
end

function kur_x14()
	-- создается переход с Курчатов-37 в Х-14
	local obj = create_lc(130053, vector():set(175.00,-15.58,-201.41),176808,4251,26911,4295,
	vector():set(157.75,51.91,-3.74),
	vector():set(0,0,0 ),"l39u_lab_x14",0)
        map_spot(obj.id, "level_changer3", "to_x14")
end

function x14_ss()
	-- создается переход из Х-14 на Научную Станцию
	local obj = create_lc(130054, vector():set(-280.58,37.59,-34.39),5087,4363,360823,5600,
	vector():set(85.10,-3.09,-37.36),
	vector():set(0,1.6,0 ),"l46_science_station",0)
        map_spot(obj.id, "level_changer2", "to_science_station")
end

function ss_jup()
	-- создается переход с Научной Станции на Юпитер
	local obj = create_lc(130055, vector():set(195.52,3.36,286.18),476697,5666,1469832,3744,
	vector():set(477.78,-5.94,-20.58),
	vector():set(0,0,0 ),"jupiter",0)
        map_spot(obj.id, "level_changer1", "to_jupiter")
end

function jup_ss()
	-- создается переход с Юпитера на Научную Станцию
	local obj = create_lc(130056, vector():set(477.67,-5.87,-27.33),1468940,3744,476689,5666,
	vector():set(194.95,4.01,279.81),
	vector():set(0,2.4,0 ),"l46_science_station",0)
        map_spot(obj.id, "level_changer3", "to_science_station")
end

function ss_forg()
	local obj
	-- создается переход с Научной Станции на Стройплощадку
	obj = create_lc(130057, vector():set(-291.58,8.02,42.54),534,5646,134659,9350,
	vector():set(-96.90,3.99,255.04),
	vector():set(0,-3.2,0 ),"l58_forgotten",0)
        map_spot(obj.id, "level_changer4", "to_construction_camp")

	-- создается переход со Стройплощадки на Научную Станцию
	obj = create_lc(130058, vector():set(-99.36,4.45,265.07),131429,9350,1674,5553,
	vector():set(-282.84,6.94,36.86),
	vector():set(0,-2.3,0 ),"l46_science_station",0)
        map_spot(obj.id, "level_changer1", "to_science_station")
end

function warlab_radar()
	-- создается переход с Варлаба на Радар
	local obj = create_lc(130059, vector():set(8.54,9.36,21.53),5593,3197,67298,1930,
	vector():set(303.20,-39.39,-25.75),
	vector():set(0,0,0 ),"l10_radar",0)
        map_spot(obj.id, "level_changer3", "to_radar")
end

function coll_zaton()
	local obj
	-- создается переход из Коллектора на Затон
	obj = create_lc(130060, vector():set(-270.18,-40.26,468.22),777,10524,709848,3670,
	vector():set(-105.30,-1.29,222.30),
	vector():set(0,-1.6,0 ),"zaton",0)
        map_spot(obj.id, "level_changer4", "to_zaton")

	-- создается переход с Затона в Коллектор
	obj = create_lc(130061, vector():set(-107.75,-0.42,223.87),1146037,3686,740,10523,
	vector():set(-276.42,-45.68,471.33),
	vector():set(0,1.25,0 ),"l62u_collector",0)
        map_spot(obj.id, "level_changer1", "to_l62u_collector")
end

function dshor_coll()
	local obj
	-- создается переход из Долины Шорохов в Коллектор
	obj = create_lc(130062, vector():set(-369.93,-5.46,-198.89),32184,4190,4347,10504,
	vector():set(-103.27,-57.98,321.88),
	vector():set(0,3.1,0 ),"l62u_collector",0)
        map_spot(obj.id, "level_changer3", "to_l62u_collector")

	-- создается переход из Коллектора в ДШ
	obj = create_lc(130063, vector():set(-103.24,-55.80,327.64),4352,10547,40762,4190,
	vector():set(-355.32,-10.00,-200.74),
	vector():set(0,-1.65,0 ),"l40_dshor",0)
        map_spot(obj.id, "level_changer1", "to_l40_dshor")
end

function chaes1_chaes2()
	-- создается переход с ЧАЭС-1 на ЧАЭС-2
	local obj = create_lc(130065, xyz(117.719,-0.101,-76.401),61940,2376,12671,2518,
	vector():set(-32.536,-0.012,62.984),
	vector():set(0,0,0 ),"l12_stancia",0)
        map_spot(obj.id, "level_changer4", "to_stancia_2")
end

function mg_vok()
	-- создается переход с МГ На Вокзал
	local obj = create_lc(130066, vector():set(-404.94,0.38,166.67),4989,3583,479781,11196,
	vector():set(110.146,1.265,152.001),
	vector():set(0.0,1.5,0.0),"l64_railstation",0)
        map_spot(obj.id, "level_changer4", "to_l64_railstation")
end

function vok_mg()
	-- создается переход с Вокзала в МГ
	local obj = create_lc(130067, vector():set(129.46,0.78,155.44),493507,11196,6464,3583,
	vector():set(-398.71,-6.16,161.26),
	vector():set(0.0,-2.25,0.0),"dead_city",0)
        map_spot(obj.id, "level_changer2", "to_dead_city")
end

function pri_damned()
	local obj
	-- создается переход с Ц.Припяти в Подземелье Припяти
	obj = create_lc(130068, vector():set(-122.00,-2.90,90.00),6490,2140,66735,5782,
	vector():set(70.63,-0.00,-120.60),
	vector():set(0.0,0.88,0.0),"l49u_damned",0)
        map_spot(obj.id, "level_changer4", "to_damned")

	-- создается переход из Подземелья Припяти в Ц.Припять
	obj = create_lc(130069, vector():set(-67.37,26.00,567.18),18124,5835,79848,2266,
	vector():set(-19.73,0.57,425.26),
	vector():set(0,0.0,0 ),"l11_pripyat",0)
	netpacket:modify(obj,"custom_data","[pt_move_if_reject]\npath = way_damned_reject_to_pripyat")
        map_spot(obj.id, "level_changer2", "to_central_pripiat")
end

-- Последний переход 	130069

function create_lc(story_id, pos, lv, gv, dlv, dgv, dpos, ddir, lvl_name, silent, radius, quiet)
	local obj = create_level_changer(story_id, pos, lv, gv, dlv, dgv, dpos, ddir, lvl_name, silent, radius)
	if not quiet then
		local level_id_from=graph:vertex(gv):level_id()
		local level_id_to=graph:vertex(dgv):level_id()
		local path_from=translate(ai:level_name(level_id_from))
		local path_to=translate(ai:level_name(level_id_to))
		sms("%c[green]"..translate("create_lc_0").." "..path_from.." - "..path_to..".%c[default]", nil, nil, 10000)
	end
	return obj
end
