---------------------------------------------------------------------
-- Привет от Сяка 
---------------------------------------------------------------------

local math_random = math.random
local math_atan2 = math.atan2
local math_sin = math.sin
local math_cos = math.cos
local string_find = string.find
local string_format = string.format
local string_gsub = string.gsub

function add_new_escape_100()
add_new_lc(9100,4426,"to_escape","info_way100a",3)
end
function add_new_agroprom_101()
add_new_lc(9101,2826,"to_agroprom","info_way101a",4)
end
function add_new_yantar_102()
add_new_lc(9102,4427,"to_yantar","info_way102a",1)
del_value("rat_caught")
end
function add_new_agroprom_103()
add_new_lc(9103,8355,"to_agroprom","info_way103a",3)
end
function add_new_mil_104()
add_new_lc(9104,6941,"to_military","info_way104a",1)
end
function add_new_rostok_105()
add_new_lc(9105,7482,"to_rostok","info_way105a",4)
end
function add_new_radar_106()
add_new_lc(9106,8356,"to_radar","info_way106a",1)
end
function add_new_darkvalley_107()
add_new_lc(9107,9109,"to_darkvalley","info_way107a",2)
end
function add_new_yantar_108()
add_new_lc(9108,9108,"to_yantar","info_way108a",3)
end
function add_new_radar_109()
add_new_lc(9109,5157,"to_radar","info_way109a",1)
end
function add_new_mil_110()
add_new_lc(9110,5158,"to_military","info_way110a",1)
end
function add_new_darkvalley_111()
add_new_lc(9111,7483,"to_darkvalley","info_way111a",3)
end
function add_new_military_01()
add_new_lc(1008,9390,"to_military","info_way112a",3)
end
function add_new_military()
add_new_lc(592,6851,"to_military","info_way113a",1)
end
--' болото-старая деревня
function add_new_rostok()
add_new_lc(97101,13109,"to_old_village","info_way114a",1)
end
function add_new_to_garbage()
add_new_lc(11504,13822,"to_garbage","info_way_arhara_peshera_cvalka",2)
end
function add_new_to_agro()
add_new_lc(11505,13823,"to_agroprom","info_way_arhara_peshera_agro",4)
end
--' открывается переход Свалка-Пещера/Выдаст Лысый/
function add_new_to_peshera1()
add_new_lc(11502,3793,"to_cave","info_way_arhara_cvalka_peshera",4)
end
--' открывается переход Агро-Пещера/Выдаст Крот/
function add_new_agro_peshera()
add_new_lc(11503,4395,"to_cave","info_way_arhara_agro_peshera",2)
end
--' кордон-болота
function add_new_to_peshera2()
add_new_lc(14002,2823,"to_swamp","info_way_arhara_kordon_boloto",4)
end
function add_new_to_les()
add_new_lc(97071,5150,"to_forgotten_forest","info_way_arhara_td_les",4)
end
function add_new_to_peshera3()
add_new_lc(97081,522,"to_cave","info_way_arhara_labirint_peshera",4)
end
function add_new_to_labirint()
add_new_lc(97021,13686,"to_labirinth","info_way_arhara_peshera_labirint",2)
end
function add_new_labirint_to_yantar()
add_new_lc(11512,335,"to_yantar","info_way_arhara_labirint_yantar",1)
end
function add_new_labirint_to_earth()
add_new_lc(11511,314,"to_undiscovered_land","info_way_arhara_labirint_earth",1)
end
function add_new_yantar_to_labirint()
add_new_lc(11515,8352,"to_labirinth","info_way_arhara_yantar_labirint",3)
end

function add_new_atp_to_military()
add_new_lc(97091,132,"to_military","info_way_arhara_atp_military",2)
end
function add_new_atp_to_kordon()
add_new_lc(97092,133,"to_escape","info_way_arhara_atp_kordon",3)
end
function add_new_atp_to_svalka()
add_new_lc(97093,183,"to_bar","info_way_arhara_atp_svalka",2)
end
--' Припять-Старая Деревня
function add_new_military_to_earth()
add_new_lc(97100,10243,"to_old_village","info_way_arhara_pripyt_village",4)
end
--' открывается сразу 2 перехода
function add_new_td_to_earth()
add_new_lc(11513,5151,"to_undiscovered_land","info_way_arhara_td_earth",4)
add_new_lc(11514,7478,"to_undiscovered_land","info_way_arhara_military_earth",3)
end
function add_new_svalka_to_earth()
add_new_lc(12506,3792,"to_undiscovered_land","info_way_arhara_svalka_earth",2)
end
function add_new_earth_to_labirint()
add_new_lc(11510,774,"to_labirinth","info_way_arhara_earth_labirint",4)
end
--' открывается сразу 2 перехода
function add_new_radar_to_warlab()
add_new_lc(97094,9085,"to_army_lab","info_way_arhara_radar_warlab",4)
add_new_lc(97095,14961,"to_x16","info_way_arhara_warlab_brainlab",4)
end
--' х18-Военная Лаборатория
function add_new_warlab_to_brainlab()
add_new_lc(97098,5867,"to_army_lab","info_way_arhara_x18_warlab",1)
end
function add_new_warlab_to_skladu()
add_new_lc(97097,14827,"to_military","info_way_arhara_warlab_skladu",1)
end

function add_new_village_to_limansk()
add_new_lc(11529,12993,"to_limansk","info_way_arhara_village_limansk",4)
end
function add_new_village_to_hospital()
	add_new_lc(11531,12994,"to_hospital","info_way_arhara_village_hospital",1)
--	release(story_object(97101))
end
function add_new_chaes_to_generator()
add_new_lc(97103,10857,"to_generators","info_way_arhara_chaes_generator",3)
end
function add_new_hospital_to_agroprom()
add_new_lc(97104,2219,"to_agroprom","info_way_arhara_hospital_agroprom",3)
end
function add_new_agroprom_to_marsh1()
add_new_lc(97105,4344,"to_swamp","info_way_arhara_agroprom_marsh1",3)
end
function add_new_bar_to_atp()
add_new_lc(97001,6453,"to_atp","info_way_arhara_bar_atp",4)
local obj = create("m_inventory_box_sed_village",xyz(-17.22,-0.70,321.17),17535,1391)
	map_spot(obj.id, "level_changer4", "to_atp")
end
function add_new_gener_to_pripyat()
add_new_lc(97106,1830,"to_central_pripiat","info_way_arhara_gener_pripyat",3)
end
function add_new_chaes2_to_chaes()
add_new_lc(97102,11299,"to_aes","info_way_arhara_chaes2_chaes",3)
end
function add_new_gener_to_hospital()
add_new_lc(11521,1558,"to_hospital","info_way_arhara_gener_hospital",1)
end
function add_new_warlab_to_generators()
add_new_lc(97096,14782,"to_generators","info_way_arhara_warlab_generators",1)
end
function add_new_limansk_to_generators()
add_new_lc(97107,12451,"to_generators","info_way_arhara_limansk_generators",2)
end
function add_new_forest_to_warlab()
add_new_lc(97108,14320,"to_army_lab","info_way_arhara_forest_warlab",1)
end
--' переходы МГ
function add_new_dcity()
add_new_lc(97109,1287,"to_limansk","info_way_arhara_dcity_limansk",1)
add_new_lc(97110,1288,"to_atp","info_way_arhara_dead_city_atp",2)
add_new_lc(97111,1289,"to_yantar","info_way_arhara_dcity_rostok",3)
add_new_lc(97112,302,"to_dead_city","info_way_arhara_atp_dead_city",4)
end
function add_new_dcity_to_zaton()
add_new_lc(97113,1446,"to_bunker_d6","info_way_arhara_dcity_zaton",2)
end
function add_new_lima_to_dead_city()
add_new_lc(97114,12395,"to_dead_city","info_way_arhara_lima_dcity",2)
end

-- Убрана привязка к номеру секции - переделано на spawn_story_id. 
-- levchn больше не нужен. 
-- При добавлении сюда новых переходов прописывать им в алспавне spawn_story_id, равный story_id.
function add_new_lc(levch,levchn,levchm,info,dir)
	local objt = story_object(levch)
	if not objt then
--  create(levchn)
		create(ai:spawn_id(levch))
	end
	local obj = story_object(levch)
	if obj then
		--level_map_spot(obj.id, "level_changer"..tostring(dir),levchm)
		map_spot(obj.id, "level_changer"..tostring(dir),levchm)
		give_info(info)
		info_received(obj)
	end
end

function add_new_military_false()
	local obj = story_object(5212)
	level_map_spot(obj.id, "level_changer1","to_aes")
	give_info("info_way_false")
	info_received(obj)
end

function add_new_item_in(item,sidlh)
	local nps = sidlh.id
	amk.spawn_item_in_inv(item,nps) 
end

function add_new_lcitem()
	amk.spawn_item("sak_document",xyz(350,-51.74,-24.45),2031,93051) -- документ под трупом ученого в рж лесу
	amk.spawn_item("rad_document6",xyz(621.95,-42.64,187.38),1910,224619) -- дело в кунге у монолитовцев
	amk.spawn_item("amk_zapiska",xyz(-132.93,11.04,-203.2),629,105467) --записка на третьем этаже Агропрома
	amk.spawn_item("garbage_pda",xyz(-226,-7.37,-132.36),252,208345) -- ПДА в лагере бандитов на свалке
	amk.spawn_item("rad_document6",xyz(-28.4,-0.26,-173.55),676,211656) -- дело в вагончике Агропрома
	amk.spawn_item("rad_pda",xyz(530.7,-49.41,-241.61),2061,180657) -- ПДА в вагончике to_radarе
	amk.spawn_item("rad_document6",xyz(-139.6,-25.03,-355.6),19,116593) -- дело to_escape
	amk.spawn_item("playboy2",xyz(112.87,-1.94,1.6),117,413895)
	amk.spawn_item("playboy1",xyz(138.57,-3.5,22.0),1237,37466)
	amk.spawn_item("playboy4",xyz(-156.23,1.44,-162.05),669,82783)
	amk.spawn_item("playboy5",xyz(-19.52,-3.22,-19.91),1593,287481)
	amk.spawn_item("playboy6",xyz(-52.11,-10.52,35.31),1608,257284)
	amk.spawn_item("playboy7",xyz(41.4,5.45,-84.15),1100,226116)
	amk.spawn_item("playboy8",xyz(-135.57,1.29,-523.72),832,22097)
	amk.spawn_item("playboy9",xyz(-6.19,-4.21,201.42),2195,94368)
	amk.spawn_item("playboy10",xyz(306.45,-38.06,-23.05),1930,69058)
	create("playboy3",xyz(-135.43301696777,1.996345615387,-316.58770751953),77667,3374)
	create("playboy11",xyz(56.888690948486,0.94940025806427,2.6317048072815),29547,2011)
	create("playboy12",xyz(139.89819335938,-6.5692377090454,-72.478149414063),577165,2830)
	create("playboy13",xyz(292.20834350586,13.639252662659,-155.84591674805),325954,3531)
--amk.spawn_item("m_inventory_seif",xyz(306.47,-39.39,-26.22),1930,69058)
	for a=1000,20000,1 do
		local obj=server_object(a)
		if obj and 
			(string_find(obj:name(),"af_") and 
			not string_find(obj:name(),"esc_af_")  and 
			not string_find(obj:name(),"pri_af_" ) and 
			not string_find(obj:name(),"af_dumm")) then
			release(obj,true)
		end
	end
end
function volk_document_start()
amk.spawn_item("sak_document2",xyz(-80,-1.30,153),163,187916) -- документ под жд насыпью Кордона
end
function add_doktor_book()
amk.spawn_item("sak_book4",xyz(-3.77,-4.25,191.19),2195,97948) --книга доктора
end
function add_notebook()
amk.spawn_item("notebook",xyz(23.87,-5.65,-18.38),1140,6287) 
end
function add_diplomat()
create("diplomat",xyz(-100.60708618164,22.614040374756,-24.21527671814),505,1529)
yantar_tasks.x16_mutant_spawn()
end
function add_new_103item()
amk.spawn_item("quest_case_06",xyz(-196.5,2.48,92.88),678,40284) --кейс в кунге дезертира
end
function add_sak_plan()
amk.spawn_item("sak_plan",xyz(-213.13,2.96,92.58),535,22245) -- мешок плана в кунге дезертира 
end
function add_krot_pda()
amk.spawn_item("agroprom_pda",xyz(254.866424,-0.201872,79.064804),498,428654) --ПДА в ЖД тоннеле Агропрома
end

function add_und_pda()
local luber_pda={
    {position={x=8.5273504257202,y=1.2388761043549,z=-13.359372138977},gv=1023,lv=184000},
    {position={x=25.12565612793,y=6.1939692497253,z=-18.986362457275},gv=1054,lv=205168},
    {position={x=40.580104827881,y=0.37885156273842,z=-78.42790222168},gv=1081,lv=225232},
    {position={x=33.421375274658,y=4.5415067672729,z=-79.862113952637},gv=1079,lv=215642},
    {position={x=0.40938287973404,y=1.1748021841049,z=-12.560703277588},gv=1023,lv=174834}
}
	local a = table.random(luber_pda)
	local obj = create("borov_bandit", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
	local obj = create("und_pda",obj.position, obj.m_level_vertex_id, obj.m_game_vertex_id, obj.id)
	map_spot(obj.id,"find_item_location","und_pda_name")
end

function add_seif()
	amk.spawn_item("inventory_sakbox_03",xyz(15.52,-12.43,8.59),1156,5132) --Сейф в подземелье X-18
end
function give_seif(obj)
	lost_item(obj)
	amk.spawn_item("m_inventory_seif",xyz(34.37,-3.37,-37.29),1997,21736)  --передача сейфа
end

function add_gauss()
	create("prototip_gp",xyz(114.031,4.033,-283.717),306805,968) -- Гаусс-пистолет в ТД
	create("gungauss_shield_teleport",xyz(111.727,4.008,-285.72),306802,968)
	local obj = create("shield_generator",xyz(114.497,6.374,-283.672),306805,968)
	map_spot(obj.id, "green_location", "teleport generator")
	local obj = create("shield_generator",xyz(113.774,7.298,-287.84),310717,968)
	map_spot(obj.id, "green_location", "teleport generator")
	local obj = create("shield_generator",xyz(124.674,0.306,-286.704),316437,968)
	map_spot(obj.id, "green_location", "teleport generator")
	local obj = create("shield_generator",xyz(177.621,0.933,-245.962),378419,976)
	map_spot(obj.id, "green_location", "teleport generator")
	local obj = create("shield_generator",xyz(132.361,0.319,-245.27),330957,956)
	map_spot(obj.id, "green_location", "teleport generator")
	local obj = create("shield_generator",xyz(111.415,-4.467,-225.243),311535,957)
	map_spot(obj.id, "green_location", "teleport generator")
	local obj = create("shield_generator",xyz(152.585,10.573,-240.625),351356,958)
	map_spot(obj.id, "green_location", "teleport generator")
	local obj = create("shield_generator",xyz(121.562,24.16,-259.682),337826,965)
	map_spot(obj.id, "green_location", "teleport generator")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function add_medusa_green()
	create("af_medusa_green",xyz(5.3799324035645,-0.00055783987045288,222.37449645996),192846,2883)
end
function add_pellicle_red()
	amk.spawn_item("af_dummy_pellicle_red",xyz(-239.99,4.85,99.93),1362,13956)
end
function add_blood_green()
	amk.spawn_item("af_blood_green",xyz(55.34,1.27,40.89),1511,68094) --Изумрудная кровь на Янтаре 
	create("arahnid",xyz(75.406539916992,0.34422329068184,23.229085922241),79415,1512)
	create("arahnid",xyz(41.926971435547,0.037857890129089,20.751808166504),60400,1445)
	create("spider",xyz(106.78483581543,-8.8652667999268,-212.50025939941),96215,1472)
	create("spider",xyz(106.78483581543,-8.8652667999268,-212.50025939941),96215,1472)
	create("spider",xyz(106.78483581543,-8.8652667999268,-212.50025939941),96215,1472)
	create("spider",xyz(106.78483581543,-8.8652667999268,-212.50025939941),96215,1472)
	create("spider",xyz(106.78483581543,-8.8652667999268,-212.50025939941),96215,1472)
	create("arahnid",xyz(58.236850738525,-0.84842598438263,-20.68497467041),69709,1508)
	create("arahnid_strong",xyz(56.451206207275,0.046565324068069,-60.764457702637),68827,1516)
	create("arahnid_strong",xyz(27.053871154785,0.084938794374466,-9.735237121582),52620,1507)
	create("arahnid_strong",xyz(90.896003723145,0.028825730085373,12.075715065002),87194,1513)
	create("arahnid_strong",xyz(15.076522827148,0.030788093805313,19.65348815918),46805,1445)
end
function add_battery_red()
	amk.spawn_item("af_dummy_battery_red",xyz(668.9,-45.79,-39.93),1896,227187) --Рубиновая батарейка на Радаре
end
function add_two_corpses()
	local obj=amk.spawn_item("yan_ecolog_respawn_2",xyz(187.84,5.18,-360.68),938,386349)
	netpacket:modify(obj, "health", 0, "upd.health", 0)
	create("scaintist_docs",obj.position, obj.m_level_vertex_id, obj.m_game_vertex_id, obj.id)
	local sobj=amk.spawn_item("yan_ecolog_respawn_2",xyz(187.66,5.03,-375.97),938,386327)
	netpacket:modify(sobj, "health", 0, "upd.health", 0)
	create("inventory_sakbox_05",sobj.position, sobj.m_level_vertex_id, sobj.m_game_vertex_id, sobj.id)
end

function agroprom_wpm()
	local obj = story_object(9115)
	create("wpn_vintorez_m1",obj.position, obj.m_level_vertex_id, obj.m_game_vertex_id, obj.id)
	create("zasada_tonnel_agro_2",xyz(-120.86868286133,14.998485565186,-192.318359375),118958,642)
	create("agro_elite_rpg",xyz(-170.82591247559,5.3163747787476,-182.25466918945),66088,667)
	create("zasada_tonnel_agro_1",xyz(-121.89569091797,4.9972257614136,-198.87106323242),118189,617)
	create("soldier_mines_regular",xyz(-196.39508056641,7.3849902153015,-223.58135986328),39867,555)
	create("soldier_mines_veteran",xyz(-175.36352539063,7.3837895393372,-154.81077575684),61033,560)
	create("soldier_mines_regular",xyz(-106.75975036621,7.3841366767883,-136.29498291016),132868,696)
	create("soldier_mines_veteran",xyz(-108.10691833496,7.3828616142273,-207.12539672852),132051,552)
end
function add_books()
	local obj = story_object(18005)
	create("sak_book_warlab",obj.position, obj.m_level_vertex_id, obj.m_game_vertex_id, obj.id)
	local obj = story_object(5433)
	create("sak_book1",obj.position, obj.m_level_vertex_id, obj.m_game_vertex_id, obj.id)
	local obj = story_object(5244)
	create("sak_book2",obj.position, obj.m_level_vertex_id, obj.m_game_vertex_id, obj.id)
	local obj = story_object(31201)
	create("sak_book3",obj.position, obj.m_level_vertex_id, obj.m_game_vertex_id, obj.id)
end
function add_new_111item()
	create("soldier_mines_veteran",xyz(69.474830627441,0.55580735206604,25.300632476807),305190,671)
	create("soldier_mines_regular",xyz(63.35139465332,-0.20042996108532,-0.63388842344284),299977,462)
	create("soldier_mines_veteran",xyz(9.7593650817871,0.97461330890656,37.45044708252),250081,490)
	local obj = create("dynamite",xyz(54.160469055176,0.78570091724396,23.48705291748),292636,461)
	map_spot(obj.id, "crlc_big", "add_new_111item_0")
end
function dynamite_metka_delete()
	local obj
	for a=1,65534,1 do
		obj=server_object(a)
		if obj and string.find(obj:name(),"dynamite") then
			del_map_spot(obj.id,"crlc_big")
			break
		end
	end
end
function info_received(lc_obj)
	local lc_data = netpacket:get(server_object(lc_obj.id))
	local path_to=translate(ai:level_name(graph:vertex(lc_data.dest_game_vertex_id):level_id()))
	
	local level_id_from=graph:vertex(lc_obj.m_game_vertex_id):level_id()
	local path_from=translate(ai:level_name(level_id_from))
	amk.send_tip("","%c[green]"..translate("create_lc_0").." "..path_from.." - "..path_to..".%c[default]",0,10,"gen_info")
end

function add_drug()
amk.spawn_item("dogfrend",xyz(80.702026367188,0.60556876659393,163.72595214844),364,249786) 
end
function info_strelok_pda()
  amk.send_tip("",translate("info_strelok_pda_0"),0,10,"gen_info")
end
function info_artmod()
  amk.send_tip("",translate("info_artmod_0"),0,10,"gen_info")
end
function info_doktor()
  amk.send_tip("",translate("info_doktor_0"),0,10,"gen_info")
end
function info_teleport()
  amk.send_tip("",translate("info_teleport_0"),0,10,"gen_info")
end

local point_drop={
    {x=-240, y=-7, z=300},
    {x=-250, y=-5, z=294},
	{x=55, y=18, z=157},
    {x=67, y=22, z=154},
	{x=7, y=-1, z=115},
    {x=12, y=1, z=125},
	{x=35, y=60, z=30}, 
	{x=17, y=50, z=35},
	{x=376, y=-1, z=15},
	{x=393, y=2, z=65},
    {x=80, y=8, z=-16},
	{x=88, y=12, z=-24},
	{x=7, y=3, z=11},
	{x=15, y=7, z=19},
	{x=-126, y=19, z=-28},
	{x=-134, y=23, z=-36}
	}

function check_droped_item(obj)
	local info=nil
	
	if obj:section()=="sak_resiver_yantar" then
		if level.name()=="l07_military" and 
			has_info("yan_scientist_teleport_01_start") and
			amk.check_npc_in_box(db.actor, point_drop[1],point_drop[2])~= false 
		then
			info="yan_scientist_teleport_01_done"
			amk.remove_item(obj)
			amk.spawn_item("m_sak_resiver_yantar",xyz(-244.62,-5.98,299.94),1797,89408)
		elseif level.name()=="l01_escape" and 
			has_info("yan_scientist_teleport_02_start") and
			amk.check_npc_in_box(db.actor, point_drop[3],point_drop[4])~= false 
		then
			info="yan_scientist_teleport_02_done"
			amk.remove_item(obj)
			amk.spawn_item("m_sak_resiver_yantar",xyz(62.99,29.23,154.39),97,359827)
		elseif level.name()=="l11_pripyat" and 
			has_info("yan_scientist_teleport_03_start") and
			amk.check_npc_in_box(db.actor, point_drop[5],point_drop[6])~= false 
		then
			info="yan_scientist_teleport_03_done"
			amk.remove_item(obj)
			amk.spawn_item("m_sak_resiver_yantar",xyz(9.47,0.32,119.13),2166,113785)
		elseif level.name()=="l12_stancia" and 
			has_info("life_heart_sahar_start") and
			amk.check_npc_in_box(db.actor, point_drop[9],point_drop[10])~= false 
		then
			info="life_heart_sahar_have"
			amk.remove_item(obj)
			amk.spawn_item("m_sak_resiver_yantar",xyz(387.51,0.16,31.10),2384,168953)
		end

	elseif obj:section()=="poison_gaz_ballon" then
		if level.name()=="l08u_brainlab" and 
			has_info("ohota_suker_start") and
			amk.check_npc_in_box(db.actor, point_drop[11],point_drop[12])~= false 
		then
			amk.remove_item(obj)
			create("poison_ballon1",xyz(84.25,10.17,-20.63),6077,1544)
		elseif level.name()=="l08u_brainlab" and 
			has_info("ohota_suker_start") and has_info("ohota_suker_have1") and
			amk.check_npc_in_box(db.actor, point_drop[13],point_drop[14])~= false 
		then
			amk.remove_item(obj)
			create("poison_ballon2",xyz(11.52,5.59,15.10),4459,1537)
		elseif level.name()=="l08u_brainlab" and 
			has_info("ohota_suker_start") and has_info("ohota_suker_have2") and
			amk.check_npc_in_box(db.actor, point_drop[15],point_drop[16])~= false 
		then
			amk.remove_item(obj)
			create("poison_ballon3",xyz(-129.898,21.564,-32.961),3,1529)
		end
	
	elseif obj:section()=="af_gold_fish" then
		if level.name()=="l12u_sarcofag" and 
			has_info("strelok_pda_have") and
		 	amk.check_npc_in_box(db.actor, point_drop[7],point_drop[8])~= false 
		then
			amk_mod.af_flash(obj) get_sarcofag_stancia()
		end
	
	elseif obj:section()=="af_life_heart" then
		deadman_to_life(obj)
	end 
	if info==nil or has_info(info) then
		return
	end

	give_info(info)
end

function agr_ratcatcher__id()
for a=5000,6000,1 do
		local obj=server_object(a)
		if (obj and obj.name and obj:name() == "agr_ratcatcher") then
		set_value("agr_ratcatcher_id", a) 
		end
	end
end

-- список неписей, которых можно воскресить живым сердцем. 
-- story_id   = story_id непися
-- _umer = true - у непися есть поршень с приставкой "_umer"
-- info  = дополнительные поршни, которые выдаются при смерти
-- script = функция, которая воскрешает непися при скриптовом спавне
-- при добавлении непися в эту таблицу в info_arhara_way нужно добавить поршень "nu"..story_id, а также в алспауне прописать spawn_story_id, равное story_id
local nepis = {
	-- Кордон
	{story_id = 4},					-- Шустрый
	{story_id = 5},					-- Лис
	{story_id = 6},					-- Волк
	{story_id = 7},					-- Толик
	{story_id = 9},					-- Петруха
	{story_id = 22, info = {"esc_fanat_die"}},	-- Фанат
	{story_id = 32},					-- Кузнецов
	{story_id = 92},					-- Проводник
	-- Пещера
	{story_id = 19801},				-- Хабарыч
	{story_id = 19802},				-- Стаханов
	{story_id = 19803},				-- Фима Уголь
	-- Свалка
	{story_id = 107, info = {"gar_hellcar_death"}},	-- Бес
	{story_id = 115},					-- Прапор
	{story_id = 9509, info = {"death_artem"}},		-- Кулинар
	{story_id = 9510, info = {"death_voron"}},		-- Ворон
	{story_id = 100, info = {"garbage_meetstalker_die"}},	-- Серый
	{story_id = 104, info = {"gar_dm_novice_dead"}},		-- Юрик
	-- Агропром
	{story_id = 302, info = {"agr_krot_dead"}},	-- Крот
	{story_id = 370},					-- Дезертир
	{story_id = 9506},				-- Шерстюк
--	{story_id = 14006},				-- Чук
--	{story_id = 14007},				-- Гек
	-- Забытый Лес
	{story_id = 30118, trup = true, script = "buusty_dialog.himik_resurrect()"},	-- Химик труп
	{story_id = 30124, script = "buusty_dialog.himik_resurrect()"},				-- Химик живой
	-- Темная Долина
	{story_id = 400, _umer = true},	-- Макс Любер
	{story_id = 406},					-- Пуля
	{story_id = 422, info = {"val_sos_dead", "val_sos_got_medkit"}},	-- Мессер
	{story_id = 425, info = {"val_borov_dead"}},	-- Боров
	{story_id = 9507},					-- Жила
	-- Бар
	{story_id = 505},					-- Иванцов
	{story_id = 506},					-- Петренко
	{story_id = 507, info = {"bar_voronin_dead"}},	-- Воронин
	{story_id = 19805},					-- Гарик
	{story_id = 515},					-- Осведомитель
	{story_id = 504},					-- Охотник в Баре
	{story_id = 510},					-- Бром (которому ружьё принести нужно)
	{story_id = 607},					-- Лысый
	{story_id = 516},					-- Пличко
	{story_id = 519},					-- Барин
	{story_id = 9619},					-- Фримен
	{story_id = 518},					-- Киценко (командир южного блокпоста)
	{story_id = 9613},					-- Захар
	{story_id = 97115},					-- Клык в Баре
	-- Дикая Территория
	{story_id = 503, info = {"bar_heli_scene_professor_die"}},	-- Круглов на ДТ
	-- Янтарь
	{story_id = 900, info = {"yan_scientist_die"}},		-- Круглов на Янтаре
	{story_id = 905},					-- Семенов на Янтаре
	{story_id = 19028, info = {"chernomor_umer"}},	-- Черномор вылеченный
	-- Армейские Склады
	{story_id = 702},					-- Макс
	{story_id = 707},					-- Лукаш
	{story_id = 728},					-- Повар
	{story_id = 734},					-- Скряга
--	{story_id = 19804},					-- Витамин
	{story_id = 775},					-- Шуруп
	{story_id = 19810},					-- Сэр Бармалей (охранник на входе на базу Свободы)
	{story_id = 724},					-- Кэп (командир Барьера)
	-- ЧАЭС2
	{story_id = 9969, script = "kostya_dialog.tm_brother_2chaes_spawn()"},	-- Брат Тени Монолита
	-- Болота
	{story_id = 19811},					-- Дьяк
	{story_id = 14003},					-- Калмык
	-- Военная Лаборатория
	{story_id = 19809},					-- Сольвадор
	{story_id = 19820},					-- Андерсен в Военной Лаборатории
	{story_id = 22005}, 				-- Лентяй
	-- НЗ
	{story_id = 9973},					-- Старик
	{story_id = 9974},					-- Отшельник
	-- Генераторы
	{story_id = 19806},					-- Земляк
	{story_id = 19807},					-- Андерсен
	{story_id = 481516},				-- Тамбовский
	-- ДШ
	{story_id = 30116,trup=true}		-- Гульнара
}
function deadman_to_life(art)
	local obj
	for a=1,#nepis do 
		obj = story_object(nepis[a].story_id)
		if obj and not obj:alive() and obj.position:distance_to(db.actor:position()) < 2 then

			-- снимаем нужные поршни
			if not nepis[a].trup then
				disable_info("nu"..tostring(nepis[a].story_id))
			end
			if nepis[a]._umer then
				disable_info(obj:name().."_umer")
			end
			if nepis[a].info then
				for b=1,#nepis[a].info do 
					disable_info(nepis[a].info[b])
				end
			end

			--  воскрешаем
			level.start_stop_menu(level.main_input_receiver(), true)
			amk_mod.af_flash(art)
			amk.send_tip("%c[255,0,255,0]"..translate("new_stalker_found").." "..archievements.get_npc_name(obj)..". "..translate("new_stalker_added").."%c[default]", translate("name_lokalnaya_set"), 0, 15, "questman_death")
			release(obj)
			if nepis[a].script then
				loadstring(nepis[a].script)()
			else
				create(ai:spawn_id(nepis[a].story_id))
			end
			return
		end
	end
end
function nepis_umer()
	local obj, name, nu
	for a=1,#nepis,1 do
		obj = story_object(nepis[a].story_id)
		if  obj and not obj:alive() then
			name=obj:name()
			nu="nu"..tostring(nepis[a].story_id)
			
			if nepis[a]._umer then
				give_info(name.."_umer")
			end
			
			if not nepis[a].trup and not has_info(nu) then
				give_info(nu)
				archievements.send_umer_info(obj)
			end
		end
	end
end

-- проверка для уборщика по списку воскрешаемых ЖС
function can_be_resurrected(obj)
	for a=1,#nepis do
		if obj:story_id() == nepis[a].story_id then
--			log(string.format("Воскресить ЖС: "..obj:name()))
			return true
		end
	end
	return false
end

-- проверка что все квестовики живы
function all_questmen_alive()
	local obj
	for a=1,#nepis do
		obj = story_object(nepis[a].story_id)
		if obj and not obj:alive() then
--			log(string.format("Мёртвый квестовик: "..nepis[a].story_id))
			return false
		end
	end
	return true
end

function af_zone_off(af)
 local anom=amk_anoms.get_nearest_anomaly(db.actor)
 local sid=server_object(anom)
  level.add_pp_effector("teleport.ppe", 1524, false)
  amk.remove_item(af)
  release(sid,true)
end
function inv_item_cond(item,val)
local obj=db.actor:object(item)
	if obj~=nil then
	  obj:set_condition(val)
	end
end

local points={
	["l01_escape"]={
		["to"]={
			{position={x=-219.202,y=-22.075,z=-159.398},gv=47,lv=34720,view = {0.3,0.0,0}},
			{position={x=-244.69,y=-14.27,z=-16.33},gv=67,lv=12579,view = {0.0,-1.3,0}}, 
			{position={x=107.54,y=-7.14,z=1.09},gv=119,lv=408816,view = {0.0,-1.6,0}}, 
			{position={x=-178.170,y=-29.79,z=-355.42},gv=207,lv=308103,view = {0.0,-3.2,0}}, 
			{position={x=33.69,y=5.02,z=407.89},gv=246,lv=565356,view = {0.0,0.0,0}}, 
			{position={x=220.57,y=7.62,z=100.55},gv=152,lv=511605,view = {0.0,0.0,0}} 
		},
		["from"]={position={x=-192.05,y=-16.80,z=-134.01},gv=57,lv=52976}
	},
	["l11_pripyat"]={
		["to"]={
	                {position={x=-81.33,y=0.01,z=269.98},gv=2164,lv=53489,view = {0.3,3.1,0}},
			{position={x=49.78,y=-3.6,z=120.99},gv=2166,lv=161768,view = {0.3,1.6,0}}, 
			{position={x=191.20,y=-2.0,z=219.52},gv=2219,lv=260280,view = {0.0,3.2,0}}, 
			{position={x=164.51,y=-3.89,z=80.83},gv=2145,lv=250751,view = {0.0,1.55,0}}, 
			{position={x=-97.65,y=-2.4,z=71.81},gv=2140,lv=18233,view = {-0.1,1.6,0}}, 
			{position={x=116.64,y=-0.61,z=216.98},gv=2163,lv=226288,view = {0.0,0.0,0}}		
		},
		["from"]={position={x=-67.54,y=-0.53,z=257.42},gv=2151,lv=23504}
	},
	["l07_military"]={
		["to"]={
			{position={x=81.65,y=-12.57,z=60.67},gv=1558,lv=379105,view = {0.0,3.14,0}}, 
			{position={x=-35.96,y=-21.29,z=375.80},gv=1821,lv=272475,view = {0.0,-1.5,0}}, 
			{position={x=-264.86,y=-22.6,z=275.85},gv=1797,lv=72698,view = {0.0,1.6,0}},
			{position={x=-340.59,y=-13.62,z=388.84},gv=1847,lv=12469,view = {0.0,1.3,0}}		
		},
		["from"]={position={x=-47.36,y=-12.97,z=48.40},gv=1609,lv=261566}
	},
	["l08_yantar"]={
		["to"]={
			{position={x=165.06,y=-8.19,z=-103.95},gv=1442,lv=131181,view = {0.0,1.6,0}}, 
			{position={x=92.58,y=0.02,z=-39.23},gv=1515,lv=87813,view = {0.0,1.6,0}},
			{position={x=34.48,y=0.04,z=18.19},gv=1445,lv=56341,view = {0.2,3.0,0}},
			{position={x=24.61,y=0.02,z=-62.60},gv=1505,lv=51069,view = {0.0,1.6,0}}, 
			{position={x=-60.17,y=-10.21,z=-202.66},gv=1447,lv=17529,view = {0.0,3.0,0}} 
		},
		["from"]={position={x=5.60,y=-11.88,z=-270.88},gv=1448,lv=41893}
	},
	["l12_stancia"]={
		["to"]={
			{position={x=361.97,y=0,z=38.45},gv=2384,lv=154943,view = {0.3,1.6,0}}
		},
		["from"]={position={x=23.58,y=56,z=25.68},gv=2417,lv=5160}
	},
	["l12u_sarcofag"]={
		["to"]={
			{position={x=361.97,y=0,z=38.45},gv=2384,lv=154943,view = {0.3,1.6,0}}
		},
		["from"]={position={x=23.58,y=56,z=25.68},gv=2417,lv=5160}
	}	
}
	
function get_kordon_military() get_teleport("l01_escape","l07_military",1,9121) end
function get_kordon_yantar() get_teleport("l01_escape","l08_yantar",1,9121) end
function get_kordon_pripyat() get_teleport("l01_escape","l11_pripyat",1,9121) end
function get_pripyat_military() get_teleport("l11_pripyat","l07_military",1,9122) end
function get_pripyat_yantar() get_teleport("l11_pripyat","l08_yantar",1,9122) end
function get_pripyat_kordon() get_teleport("l11_pripyat","l01_escape",1,9122) end
function get_military_kordon() get_teleport("l07_military","l01_escape",1,9123) end
function get_military_pripyat() get_teleport("l07_military","l11_pripyat",1,9123) end
function get_military_yantar() get_teleport("l07_military","l08_yantar",1,9123) end
function get_yantar_military() get_teleport("l08_yantar","l07_military",1,9124) end
function get_yantar_kordon() get_teleport("l08_yantar","l01_escape",1,9124) end
function get_yantar_pripyat() get_teleport("l08_yantar","l11_pripyat",1,9124) end
function get_kordon_militaryr() get_teleport("l01_escape","l07_military",0,9121) end
function get_kordon_yantarr() get_teleport("l01_escape","l08_yantar",0,9121) end
function get_kordon_pripyatr() get_teleport("l01_escape","l11_pripyat",0,9121) end
function get_pripyat_militaryr() get_teleport("l11_pripyat","l07_military",0,9122) end
function get_pripyat_yantarr() get_teleport("l11_pripyat","l08_yantar",0,9122) end
function get_pripyat_kordonr() get_teleport("l11_pripyat","l01_escape",0,9122) end
function get_military_kordonr() get_teleport("l07_military","l01_escape",0,9123) end
function get_military_pripyatr() get_teleport("l07_military","l11_pripyat",0,9123) end
function get_military_yantarr() get_teleport("l07_military","l08_yantar",0,9123) end
function get_yantar_militaryr() get_teleport("l08_yantar","l07_military",0,9124) end
function get_yantar_kordonr() get_teleport("l08_yantar","l01_escape",0,9124) end
function get_yantar_pripyatr() get_teleport("l08_yantar","l11_pripyat",0,9124) end
function get_sarcofag_stancia() get_teleport("l12u_sarcofag","l12_stancia",1,9125) end

function get_teleport(level_from,level_to,made,sidlc)
	if not points[level_from] or not points[level_to] then
		log("! ERROR sak.get_teleport() not known level for build teleport!")
		return
	end
	local position_from=points[level_from].from
	local position_to= made==0 and table.random(points[level_to].to) or points[level_to].to[1]
	local view_direction
	if position_to.view then
		view_direction = vector():set(position_to.view[1],position_to.view[2],position_to.view[3])
	else
		view_direction = vector():set(0,0,0)
	end
	local vec_from=vector():set(position_from.position.x,position_from.position.y,position_from.position.z)
	local lc_obj = create_level_changer(sidlc, 
		vec_from, 
		position_from.lv, position_from.gv, 
		position_to.lv, position_to.gv, 
		vector():set(position_to.position.x,position_to.position.y,position_to.position.z), 
		view_direction, level_to, 1, 1)
	local eff_obj=create("zone_teleport",
		vec_from, 
		position_from.lv, position_from.gv)
	
	local tp_info={
		["level"]=level_from,["lc"]=lc_obj.id,["eff"]=eff_obj.id
	}
	del_value("sak_teleport")
	set_value("sak_teleport",tp_info)
	info_teleport()
end

function out_teleport()
	local tp_info=get_value("sak_teleport",nil)
	if not tp_info then
		return
	end
	if not tp_info.level or tp_info.level==level.name() then --никуда не улетали, оказывается
		return
	end
	local stp_obj=server_object(tp_info.lc)
	local seff_obj=server_object(tp_info.eff)
	if stp_obj then
		release(stp_obj)
	end
	if seff_obj then
		release(seff_obj)
	end
	del_value("sak_teleport")
end

function add_3repair_item_outfit()
	got("repair_item_outfit",3)
end
function add_3repair_item_weapon()
	got("repair_item_weapon",3)
end
function add_repair_item_outfit()
	got("repair_item_outfit",1)
end
function add_repair_item_weapon()
	got("repair_item_weapon",1)
end
function add_medkit(first_speaker, second_speaker)
     got("medkit")
     got("snotvornoe_tele")
end
-- Разговор с Монголом - делаем бандюков нейтралами
function set_community(actor, npc)
	relation_registry.set_community_goodwill("bandit", 0, 500)
end
-- Делаем бандитов врагами при убийстве Борова
function bandits_enemy(actor, npc)
	if xr_conditions.killed_by_actor(actor, npc) then
		sms("bandits_enemy_0", 1, nil, 10000)
	end
	relation_registry.set_community_goodwill("bandit", 0, -1500)
end
function drink_vodka()
	db.actor:eat(db.actor:object("vodka"))
end
function take_trasure(npc, npc1)
	_G.Treasure:dialog(npc)
end
function have_trasure(first_speaker, second_speaker)
	local tres=80
	local ran=math_random(100)
	if ran > tres then 
		give_info("have_sak_treasure")
	else 
		give_info("havent_sak_treasure")
	end
end

local hit_sound={
	[[characters_voice\human_01\stalker\fight\hit\hit_1]],
	[[characters_voice\human_01\stalker\fight\hit\hit_2]],
	[[characters_voice\human_01\stalker\fight\hit\hit_3]],
	[[characters_voice\human_01\stalker\fight\hit\hit_6]],
	[[characters_voice\human_01\stalker\fight\hit\hit_7]],
	[[characters_voice\human_01\stalker\fight\hit\hit_8]]
}
function zombie_checkup()
	if db.actor ~= nil then
		if math_random() > 0.7 	and not _G.Inventory:on_belt("af_serpantin") then
			local a=math_random()
			local h = hit()
			h.draftsman = db.actor
			h.direction = vector():set(0,0,0)
			h:bone("bip01_spine") -- чтобv учитvвалась броня
			h.type = hit.telepatic
			h.power = 0.3+a/2
			h.impulse = 1.0
			db.actor:hit(h)
			h.type = hit.strike
			db.actor:hit(h)
			h.type = hit.radiation
			db.actor:hit(h)
			level.add_pp_effector("alcohol.ppe", 100, false)
			local rnd=math_random(1,6)
			local snd_obj=voice(hit_sound[rnd])
			snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
			archievements.acv_count_event("acv_fzom", 100, "acv_fzom")
		end
	end
end

function add_spot_of_docent(a)
	local old_spot=get_value("spot_of_nps", 0)
	if old_spot~=0 then
		local obj_old = story_object(old_spot)
		if obj_old then
			del_map_spot(obj_old.id,'blue_location')
		end
	end
	local obj = story_object(a)
	if obj and iAmStalker[obj:clsid()] then
		map_spot(obj.id,'blue_location',obj:name().."_sak")
		old_spot=a
		set_value("spot_of_nps", old_spot)
	end
end

function add_tail()
	local lname = level.name()
	if lname=="l04_darkvalley" then	
		local obj=story_object(425)
		if obj and iAmStalker[obj:clsid()] and obj:alive() then
			if has_info("val_bandit_talk") then
				ai:iterate_alife_objects(function(obj_b)
					if obj_b:clsid()==clsid.script_stalker and obj_b:community()=="bandit" then
						relation_registry.set_personal_relation(obj_b.id,db.actor:id(),game_object.neutral)
					end
				end)
				relation_registry.set_community_goodwill("bandit", 0, 500)
			end
		elseif relation_registry.community_goodwill("bandit", 0) >= 0 then
			relation_registry.set_community_goodwill("bandit", 0, -500)
		end
	elseif lname=="l40_dshor" then
		if not has_info("dshor_ssorimsya") then
			ai:iterate_alife_objects(function(obj_b)
				if obj_b:clsid()==clsid.script_stalker and obj_b:community()=="bandit" then
					relation_registry.set_personal_relation(obj_b.id,db.actor:id(),game_object.neutral)
				end
			end)
			relation_registry.set_community_goodwill("bandit", 0, 300)
		else
			relation_registry.set_community_goodwill("bandit", 0, -500)
		end
	elseif relation_registry.community_goodwill("bandit", 0) >= 0 then
		relation_registry.set_community_goodwill("bandit", 0, -500)
	end

	if (lname=="l05_bar" or lname=="zaton")
		and not ( has_info("bar_random") or has_info("bar_smile")
		or has_info("bar_rock") or has_info("bar_rockn")
		or has_info("bar_modern") or has_info("bar_retro") or has_info("bar_new") )
	then
		give_info("bar_random")
	elseif lname=="l01_escape" then
		give_info("sidor_music")
	end

	if lname=="l06_rostok" and has_info("zahar_naemnik_start") then
		give_info("zahar_naemnik_begin")
	elseif lname=="l01_escape" and has_info("prizrak_finalzver_start") then
		give_info("info_spawn_zver")
	elseif lname~="l05_bar" and has_info("info_way_false") then
		give_info("informer_out")
	end
end
function add_borov_treasure()
	got_treasure("mil_borov_secret")
end
function add_krysyk_treasure()
	local obj = create("a_inventory_box10",xyz(199.876,5.292,-190.582),625844,4494)
	map_spot(obj.id, "crlc_big", "krysyk_treasure")
end
function add_krysyk_pda()
	create("a_inventory_box7",xyz(112.569,0.223,-37.212),414672,124)
	db.actor:add_article_text("tex_bandit_krisyk_pomer","tex_bandit_krisyk_pomer_add")
end
-- Продолжение Крысюк - Жила:
function krysyk_enemy(first_speaker, second_speaker)
	first_speaker:stop_talk()	
	second_speaker:stop_talk()
	second_speaker:set_relation(game_object.enemy, first_speaker)
	give_info("bandit_krisyk_finish")
	give_info("bandit_krisyk_enemy")
end
function krysyk_umer()
	if has_info("bandit_krisyk_finish") then 
		give_info("bandit_krisyk_finish2")
	else
		give_info("bandit_krisyk_umer2")
	end
end
function bandit_krisyk_finish2()
	timer("smska_borova", 1.0, "sak.smska_borova()")
end
function smska_borova()
	sms("%c[sender]"..translate("name_mechenii")..":\\n%c[sms_red]"..translate("sms_strelok_smska_borova"), nil, "meceniy", 8000, nil, [[sms\strelok\smska_borova]])
end

function smska_borova_no_pda()
	sms("%c[sender]"..translate("name_mechenii")..":\\n%c[sms_red]"..translate("sms_strelok_smska_borova2"), 3, "meceniy", 8000, nil, [[sms\strelok\smska_borova2]])
	sms("%c[sender]"..translate("name_borov")..":\\n%c[sms_red]"..translate("sms_borov_smska_borova_0"), 13, "borov", 10000, nil, [[sms\borov\smska_borova]])
	disable_info("bandit_krisyk_have")
end
