-- snp основной скрипт

local taken_item_snp_section={
	["snp_pda1"]=function(obj)
		give_info("snp_borov1_start")
		find_and_release("dead_military_esc")
	end,
	["snp_note1"]=function(obj)
		if not has_info("snp_find_name1_have") then
			se_obj = create("kotobegemot_bar",xyz(115.00399780273,-5.3044028282166,14.159286499023),33614,1239)
			ai:assign_story_id(se_obj.id,19901)
			give_info("snp_find_name1_have")
		end
	end,
	["snp_pda2"]=function(obj)
		give_info("snpt_kordon1_have")
	end,
	["snp_pda3"]=function(obj)
		if not has_info("snp_almaz0") then
			snp_spawn.suslov_marsh_sms2()
			give_info("snp_almaz0")
		end
	end,
	["snp_pda4"]=function(obj)
		give_info("snpt_sd4_have")
	end,
	["snp_pda5"]=function(obj)
		if not has_info("snpt_pp1_have2") then
			-- Прайм заболел
			release(object_by_section_offline("bibliofrend_talk_zaton"))
			--se_obj = object_by_section_offline("bibliofrend_zaton")
			--se_obj:set_visual_name("monsters\\bibliotekar\\bibliotekar_black")
			local obj = create("bibliofrend_talk_black_zaton",xyz(124.68988037109,-7.3328924179077,177.81799316406),1180494,3686)
			--ai:assign_story_id(obj.id,19927)
			ai:assign_story_id(obj.id,19926)
			give_info("snpt_pp1_have2")
		end
	end,
	["snp_pda6"]=function(obj)
		if not has_info("snp_semetskiy_pda_have") then
			create_teleport("tele_limansk4",xyz(-11.73425579071,-0.16019485890865,-141.75788879395),19162,2993)
			db.actor:give_game_news("%c[sender]"..user_name().."\\n%c[default]"..translate("checking_taken_item_snp_0"), "ui\\ui_iconsTotal", Frect():set(498,47,83,47), 5000, 20000)
			voice("device\\pda\\pda_tip"):play(db.actor, 5, sound_object.s2d)
			give_info("snp_semetskiy_pda_have")
		end
	end,
	["snp_pda7"]=function(obj)
		if not has_info("snpt_2chaes2_done") then
			local timeout = 5
			sms("%c[sender]"..translate("name_proper_semidesyatii")..":\\n%c[sms_red]"..translate("sms_proper70_snp_pda7_0"), timeout, "proper70", 20000, nil, [[sms\proper70\snp_pda7]])
			timeout = timeout+11
			sms("%c[sender]"..translate("name_strelok")..":\\n%c[sms_red]"..translate("sms_strelok_snp_pda7_0"), timeout, "strelok", 20000, nil, [[sms\strelok\snp_pda7]])
			give_info("snpt_2chaes2_done")
		end
	end,
	["snp_pda8"]=function(obj)
		if not has_info("snpt_mg2_have2") then
			local timeout = 3
			sms("%c[sender]"..translate("name_strelok")..":\\n%c[sms_red]"..translate("sms_strelok_snp_pda8_0"), timeout, "strelok", 20000, nil, [[sms\strelok\snp_pda8]])
			timeout = timeout+13
			sms("%c[sender]"..translate("name_brodyaga")..":\\n%c[sms_red]"..translate("sms_brodaga_snp_pda8_0"), timeout, "brodaga", 20000, nil, [[sms\brodaga\snp_pda8]])
			se_obj = create("brodaga_zaton",xyz(122.5481262207,-7.3221473693848,185.99839782715),1176929,3686)
			ai:assign_story_id(se_obj.id,19914)
			give_info("snpt_mg2_have2")
			timer("run", 22.5, "snp.gena_start()")
		end
	end,
	["snp_pda9"]=function(obj)
		give_info("snpt_cp2_have")
	end,
	["snp_pda10"]=function(obj)
		lost_item("snp_pda10")
		create_teleport("snp_uagro1_tp1",db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id())
	end,
	["snp_pda11"]=function(obj)
		lost_item("snp_pda11")
		give_info("emb17")
	end,
	["snp_pda12"]=function(obj)
		lost_item("snp_pda12")
		give_info("embt_vp1_done")
	end,
	["snp_pda13"]=function(obj)
		lost_item("snp_pda13")
		sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("checking_taken_item_snp_4_0"), nil, "fenrir", 20000, nil, [[sms\fenrir\item_snp_4]])
	end,
	["snp_pda14"]=function(obj)
		give_info("snpt_2chaes3_have")
	end,
	["snp_biopart%d"]=function(obj)
		if obj:section() == "snp_biopart4" then
			lost_item("snp_note30")
			give_info("snpt_vp3_done")
			snp_spawn.n_inventory_box_vp6()
		end
		local i = string.sub(obj:section(),12,12)
		local p = "snp_bioradar_parts"..i
		if not has_info(p) then
			if tonumber(i) < 5 then
				release(obj:id())
				create("snpbiopart",xyz(0,0,0),0,0,0)
			end
			give_info(p)
		end
	end,
	["snp_almaz_note2"]=function(obj)
		if not has_info("snp_almaz_note2") then
			lost_item("snp_almaz_note1")
			local obj = create("n_inventory_box_almaz3",xyz(48.840072631836,2.2752776145935,-27.195747375488),162369,2137)
			map_spot(obj.id, "treasure", "Cache")
			sms("Received a tip on the cache", nil, nil, 10000)
			give_info("snp_almaz_note2")
		end
	end,
	["af_idol_monolita"]=function(obj)
		if has_info("snp_almaz3") and not has_info("snp_almaz_done") then
			voice([[heart\5]]):stop()
		end
	end,
	["snp_note10"]=function(obj)
		if not has_info("snp_note10_have") then
			local obj = create("n_inventory_box_kl1_2",xyz(-199.62145996094,10.08634185791,-256.50994873047),868,3234)
			map_spot(obj.id, "treasure", "Cache")
			sms("Received a tip on the cache", nil, nil, 10000)
			give_info("snp_note10_have")
		end
	end,
	["snp_note13"]=function(obj)
		if not has_info("snp_note13_have") then
			lost_item("snp_note12")
			local obj = create("n_inventory_box_kl1",xyz(-116.12890625,27.069087982178,17.880420684814),10076,3240)
			map_spot(obj.id, "treasure", "Cache")
			sms("Received a tip on the cache", nil, nil, 10000)
			give_info("snp_note13_have")
		end
	end,
	["snp_note20"]=function(obj)
		if not has_info("snp_note20_have") then
			local obj = create("n_inventory_box_cp4_1",xyz(47.505016326904,8.9497900009155,-104.69525146484),159188,2136)
			map_spot(obj.id, "treasure", "Cache")
			sms("Received a tip on the cache", nil, nil, 10000)
			give_info("snp_note20_have")
		end
	end,
	["snp_plan"]=function(obj)
		give_info("snpt_sd1_have")
	end,
	["snp_prime_maz_green"]=function(obj)
		give_info("snp_bibliofrend_black1_have1")
	end,
	["dictofon_fenrir"]=function(obj)
		if has_info("snp_bioradar_parts5") and not has_info("snpt_2chaes1_done") then
			give_info("snpt_2chaes1_done")
			sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("checking_taken_item_snp_5_0"), 6, "fenrir", 60000, nil, [[sms\fenrir\item_snp_5]])
			timer("run", 60, "snp.fenrir_gone()")
		end
	end,
	["wpn_m4_m1"]=function(obj)
		if has_info("snp_wolffrend3_done") and not has_info("zvezda_proroka_done") then
                snp.zvezda_proroka_done()
		end
	end,
	["wpn_ognemet"]=function(obj)
		if not has_info("fli_have_3") and not has_info("acv_annigilator") then
			obj:set_condition(0.01)
		end
	end,
	["wpn_vihlop"]=function(obj)
		if not has_info("agroprom_military_case_done") then
			obj:set_condition(0.01)
		end
	end,
	["wpn_vintorez"]=function(obj)
		if not has_info("escape_meceniy_start") then
			obj:set_condition(0.01)
		end
	end,
	["wpn_topor"]=function(obj)
		if has_info("krest_topor") then
			give_info("krest_topor_done")
		end
	end,
	["ammo_gravi"]=function(obj)
		release(server_object(obj:id()))
	end,
	 ["ammo_rpo-a"]=function(obj)
		 release(server_object(obj:id()))
	 end,
	["letter"]=function(obj)
		local sobj=server_object(obj:id())
		local data = sobj:get_ini_lua_table()
		if data and data["letters"] and data["letters"].letter_id then
			local id=math.modf(data["letters"].letter_id)
			db.actor:add_article("letter_"..id)
			local letters_id=container:get("letters_id")
			letters_id[id]=true
			release(sobj)
			archievements.acv_count_event("acv_ptln", 30, "acv_ptln")
		else
			log("! WARNING take letter but not have correct custom_data.ignoring.")
		end
	end,
	["fli_code%d+"]=function(obj)
		if not has_info("teleport_started") then
			local code_id = obj:section():match("fli_code(%d+)")
			if not has_info("fli_have"..code_id) then
				give_info("fli_have"..code_id)
				fly_island.spawn_zanoza(tonumber(code_id))
			end
			if not has_info("fli_have_1") and has("fli_code36") and has("fli_code29") and has("fli_code37") and has("fli_code33") and has("fli_code35") and has("fli_code31") and has("fli_code9") and has("fli_code1") then
				give_info("fli_have_1")
			end
		end
	end,
	["af_sunlight"]=function(obj)
		if has_info("info_amk_recipt_fake") and not has_info("teleport_started") and not has_info("info_amk_recipt_fake_done") then
			sms("%c[sender]"..translate("name_osvedomitel")..":\\n%c[sms_red]"..translate("checking_taken_item_snp_6_0"), nil, "osvedomitel", 19000, nil, [[sms\osvedomitel\osvedomitel_sms]])
			give_info("info_amk_recipt_fake_done")
		end
	end,	
	["fli_pda1"]=function(obj)
		if not has_info("fli_nolik_done") then
			sms("%c[sender]"..translate("name_strelok_(misli_vsluh)")..":\\n%c[sms_red]"..translate("sms_strelok_fli_pda1_0"), 10, "strelok", 30000, nil, [[sms\strelok\fli_pda1]])
			give_info("fli_nolik_done")
		end
	end,	
}
setmetatable(taken_item_snp_section,_G.patternSearchTable)

-- общий калбек на подъем предмета
function checking_taken_item_snp(obj)
	local check_section=taken_item_snp_section[obj:section()]
	if check_section then
		check_section(obj)
	end
	if has("snp_note24") and has("snp_note23") then --????????
		lost_item("snp_note23")
		lost_item("snp_note24")
		give_info("emb0")
	end
end

-- общий калбек на взятие тайника без уникальных предметов
local check_treasure_section={
	["n_inventory_box_yantar1"]=function(obj)
		x16_17()
	end,
	["emb_inventory_box_%w+"]=function(box)
		emb.worker()
	end,
--	["[%w_]*shadow$"]=function(box)
--		snp_shadow.worker()
--	end,
	["[%w_]*inventory_box_fli[%w_]*"]=function(box)
		fly_island.final_worker(box:section())
	end,
	["n_inventory_box_dt1"]=function(box)
		give_info("snpt_dt1_have")
	end,
	["n_inventory_box_dt2"]=function(box)
		release(object_by_section_offline("bibliofrend_talk_black_zaton"))
		--se_obj = object_by_section_offline("bibliofrend_zaton")
		--se_obj:set_visual_name("monsters\\bibliotekar\\bibliotekar")
		local obj = create("bibliofrend_talk_zaton",xyz(124.68988037109,-7.3328924179077,177.81799316406),1180494,3686)
		ai:assign_story_id(obj.id,19926)
		give_info("snpt_dt2_have")
	end,
	["n_inventory_box_dt3"]=function(box)
		lost_item("gena_note1")
		local obj = create("n_inventory_box_cp11",xyz(-12.712896537781,-5.1684684944153,193.19522900391),90728,2195)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_agro1"]=function(box)
--		if has_info("snpt_agro1_fail") then
--			sms("%c[sender]"..translate("name_komanda_sozdatelei_op_2")..":\\n%c[sms_red]"..translate("sms_komanda_OP_2_n_inventory_box_agro1_1_0")..user_name()..translate("sms_komanda_OP_2_n_inventory_box_agro1_1_1"), 3, "op2", 40000, nil, [[sms\komanda_OP_2\n_inventory_box_agro1_1]])
--		else
--			sms("%c[sender]"..translate("name_komanda_sozdatelei_op_2")..":\\n%c[sms_red]"..translate("sms_komanda_OP_2_n_inventory_box_agro1_2_0")..user_name()..translate("sms_komanda_OP_2_n_inventory_box_agro1_2_1"), 3, "op2", 30000, nil, [[sms\komanda_OP_2\n_inventory_box_agro1_2]])
--		end
		give_info("snpt_agro1_have")
	end,
	["n_inventory_box_kordon2"]=function(box)
		local obj = create("n_inventory_box_kordon2_2",xyz(65.351554870605,8.6025924682617,39.333652496338),301349,423)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_kordon2_2"]=function(box)
		lost_item("fli_note15")
	end,
	["n_inventory_box_kordon5"]=function(box)
		give_info("snpt_kordon2_done")
	end,	
	["n_inventory_box_vp1"]=function(box)
		give_info("no_teleport_near_heli_btr")
		se_obj = object_by_section_offline("snp_pda13")
		if se_obj then
			release(se_obj)
		end
		create_restrictor_out(db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id(),30,"snp.heli_vp1_fail")
		snp_spawn.n_inventory_box_vp1()
	end,
	["n_inventory_box_vp1_2"]=function(box)
		local obj = create("n_inventory_box_vp1_3",xyz(13.420848846436,15.939820289612,376.03521728516),219643,3760)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_vp1_3"]=function(box)
		lost_item("snp_note3")
		create_restrictor(xyz(81.403007507324,12.320181846619,354.12557983398),302206,3760,1,"snp_spawn.n_inventory_box_vp1_4")
	end,	
	["n_inventory_box_vp1_4"]=function(box)
		lost_item("snp_note4")
		give_info("snpt_vp2_done")
		sms("%c[sender]"..translate("name_obitel_zla")..":\\n%c[sms_red]"..translate("sms_resident_evil_resident_evil_1_0"), 3, "resident_evil", 20000, nil, [[sms\resident_evil\resident_evil_1]])
	end,
	["n_inventory_box_vp7"]=function(box)
		if not has_info("snpt_kl1_found2") then
			sms("%c[sender]"..translate("name_dotsent")..":\\n%c[sms_red]"..translate("sms_docent_n_inventory_box_vp7_0"), nil, "docent", 30000, nil, [[sms\docent\n_inventory_box_vp7]])
			give_info("snpt_kl1_fail")
		end
		give_info("snpt_kl1_have2")
		move_ariadna_to_bar()
	end,
	["n_inventory_box_limansk1"]=function(box)
		local obj = create("n_inventory_box_limansk1_2",xyz(-54.28849029541,4.0246248245239,159.91932678223),9647,3010)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,	
	["n_inventory_box_limansk1_2"]=function(box)
		lost_item("snp_note5")
		give_info("snpt_limansk1_have")
	end,	
	["n_inventory_box_limansk2"]=function(box)
		local obj = create("n_inventory_box_limansk2_1",xyz(83.74320251465,22.1644155263901,91.979831542969),51783,3020)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_limansk2_1"]=function(box)
		lost_item("snp_note14")
		create_restrictor(xyz(78.972717285156,33.845104217529,185.52560424805),51783,3020,1,"snp_spawn.n_inventory_box_limansk2_1")
	end,
	["n_inventory_box_limansk2_2"]=function(box)
		give_info("snpt_limansk2_have")
	end,
	["n_inventory_box_limansk3"]=function(box)
		give_info("snpt_limansk3_done")
		sms("%c[sender]"..translate("name_obitel_zla")..":\\n%c[sms_red]"..translate("sms_resident_evil_resident_evil_2_0"), 3, "resident_evil", 15000, nil, [[sms\resident_evil\resident_evil_2]])
	end,
	["n_inventory_box_limansk4"]=function(box)
		give_info("snpt_limansk4_have")
		lost_item("snp_pda6")
		snp_spawn.n_inventory_box_limansk4()
	end,
	["n_inventory_box_limansk12"]=function(box)
		lost_item("snp_note46")
	end,
	["n_inventory_box_almaz1"]=function(box)
		lost_item("snp_pda3")
	end,
	["n_inventory_box_almaz14"]=function(box)
		voice([[snp\heartbeat100]]):stop()
		lost_item("snp_almaz_note13")
		give_info("snp_almaz1")
		sms("%c[sender]"..translate("name_ten_monolita")..":\\n%c[sms_red]"..translate("sms_shadow_monolit_n_inventory_box_almaz14_0"), 5, "shadow_monolit", 22000, nil, [[sms\shadow_monolit\n_inventory_box_almaz14]])
		create_teleport("tele_almaz_act",xyz(166.77569580078,43.172966003418,386.25317382813),172634,2987)
		create("zone_monolith_snp",xyz(174.08480834961,55.11833190918,386.01168823242),172632,2987)
		start_sound()
	end,
	["n_inventory_box_x101"]=function(box)
		local obj = create("n_inventory_box_x101_2",xyz(-30.335075378418,-11.727508544922,48.893642425537),1960,2744)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_x101_2"]=function(box)
		lost_item("snp_note6")
		local obj = create("n_inventory_box_x101_3",xyz(-17.047734069824,-9.5494222640991,-34.517933197021),3773,2665)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_x101_3"]=function(box)
		give_info("snpt_x101_have")
		lost_item("snp_note7")
		say([[monsters\bloodsucker\bloodsucker_script_attack_0]])
		create("deathclaw_strong",xyz(-19.920612335205,-9.5487899780273,-41.595027923584),3546,2665)
	end,
	["n_inventory_box_x81"]=function(box)
		create_teleport("tele_kl1",xyz(-126.73837280273,-7.9817929267883,-57.95435333252),8203,3240)
	end,
	["n_inventory_box_x82"]=function(box)
		give_info("snpt_x82_done")
	end,	
	["n_inventory_box_x83"]=function(box)
		create_level_changer(220101, vector():set(16.434181213379,-7.8957762718201,19.228824615479), 6993, 3211, 413, 2483, vector():set(-36.416271209717,-34.481643676758,13.138676643372), vector():set(0,0,0), "l12u_control_monolith", 0, 0.5)
		create_restrictor(xyz(16.434181213379,-7.8957762718201,19.228824615479),6993,3211,3,"snp.gena_bum1")
	end,
	["n_inventory_box_kl1"]=function(box)
		give_info("snpt_x81_done")
		lost_item("snp_note9")
		lost_item("snp_note13")
	end,
	["n_inventory_box_kl3"]=function(box)
		if not has_info("snpt_kl1_found1") then
			sms("%c[sender]"..translate("name_dotsent")..":\\n%c[sms_red]"..translate("sms_docent_n_inventory_box_kl3_0"), nil, "docent", 30000, nil, [[sms\docent\n_inventory_box_kl3]])
			give_info("snpt_kl1_fail")
		end
		give_info("snpt_kl1_have1")
		move_ariadna_to_bar()
	end,
	["n_inventory_box_sd2"]=function(box)
		give_info("snpt_sd2_have")
	end,
	["n_inventory_box_cp1"]=function(box)
		give_info("snpt_cp1_have")
	end,
	["n_inventory_box_pp1"]=function(box)
		give_info("snpt_pp1_have1")
		create_restrictor(xyz(14.366353034973,26.801988601685,3.5365107059479),21893,3792,2,"snp_spawn.n_inventory_box_pp1")
		sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("sms_fenrir_n_inventory_box_pp1_0"), 10, "fenrir", 20000, nil, [[sms\fenrir\n_inventory_box_pp1]])
	end,
	["n_inventory_box_td1"]=function(box)
		if not has_info("snpt_td1_have1") then
			give_info("snpt_td1_have1")
		else
			give_info("snpt_td1_have2")
		end
	end,
	["n_inventory_box_garbage1"]=function(box)
		snp_spawn.n_inventory_box_garbage1()
	end,
	["n_inventory_box_garbage2"]=function(box)
		snp_spawn.n_inventory_box_garbage2()
	end,
	["n_inventory_box_garbage3_1"]=function(box)
		sms("%c[sender]"..translate("name_istochnik_neizvesten")..":\\n%c[sms_red]"..translate("check_treasure_8_0"), nil, "nodata", 10000)
		create_teleport("snp_receipt_parts2_tp2",xyz(69.402984619141,7.087566614151,98.179962158203),239958,370)
	end,
	["n_inventory_box_garbage3_2"]=function(box)
		create_teleport("snp_receipt_parts2_tp4",xyz(36.57763671875,9.8525171279907,235.24243164063),209829,359)
		local obj = create("n_inventory_box_garbage3_3",xyz(88.548858642578,14.494812965393,-150.32049560547),255908,412)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_garbage3_3"]=function(box)
		give_info("snp_receipt_parts2_have")
		lost_item("snp_note19")
	end,
	["n_inventory_box_cp2"]=function(box)
		local obj = create("n_inventory_box_cp3",xyz(209.37040710449,2.7850260734558,87.78483581543),257446,2145)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_cp3"]=function(box)
		give_info("snp_receipt_parts1_have")
		lost_item("snp_note17")
	end,
	["n_inventory_box_cp11"]=function(box)
		lost_item("gena_note2")
		local obj = create("n_inventory_box_gen2",xyz(58.491859436035,32.280834197998,-551.94244384766),404600,3117)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_cp4_1"]=function(box)
		lost_item("snp_note20")
		local obj = create("n_inventory_box_cp4_2",xyz(47.559024810791,8.9481220245361,-164.22630310059),159135,2136)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_cp4_2"]=function(box)
		lost_item("snp_note21")
		create_teleport("snp_cp_tp1",xyz(146.888671875,11.983012199402,116.23860931396),243444,2174)
	end,
	["n_inventory_box_cp4_3"]=function(box)
		give_info("snp_receipt_parts4_have")
		lost_item("snp_note22")
	end,
	["n_inventory_box_x161"]=function(box)
		give_info("snp_receipt_parts3_have")
		snp_spawn.n_inventory_box_x161()
		se_obj = create("lobsang_zaton",xyz(132.97550964355,-7.3394374847412,189.05435180664),1194666,3686)
		ai:assign_story_id(se_obj.id,19906)
	end,
	["n_inventory_box_jupiter1"]=function(box)
		give_info("snp_receipt_parts5_have")
	end,
	["n_inventory_box_jupiter8"]=function(box)
		local obj = create("n_inventory_box_jupiter8_2",xyz(387.51806640625,15.237261772156,-85.501846313477),1328997,3744)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_jupiter8_2"]=function(box)
		lost_item("snp_note44")
		snp_spawn.n_inventory_box_jupiter8_2()
	end,
	["n_inventory_box_jupiter11"]=function(box)
		lost_item("snp_note26")
	end,
	["n_inventory_box_2chaes1"]=function(box)
		create_item_and_restrictor("fenrir_2chaes",xyz(941.21911621094,13.052788734436,273.22985839844),250079,2642)
		sms("%c[sender]"..translate("name_strelok")..":\\n%c[sms_red]"..translate("sms_strelok_n_inventory_box_2chaes1_0"), 4, "strelok", 15000, nil, [[sms\strelok\n_inventory_box_2chaes1]])
	end,
	["n_inventory_box_2chaes2"]=function(box)
		sms("%c[sender]"..translate("name_komanda_sozdatelei_op_2")..":\\n%c[sms_red]"..translate("sms_komanda_OP_2_n_inventory_box_2chaes2_1_0")..user_name()..translate("sms_komanda_OP_2_n_inventory_box_2chaes2_1_1"), 3, "op2", 50000, nil, [[sms\komanda_OP_2\n_inventory_box_2chaes2_1]])
		release_teleport("fli_block_tp1")
		release_teleport("fli_block_tp2")
	end,
	["n_inventory_box_as2"]=function(box)
		se_obj = create("n_inventory_box_dt3",xyz(42.53,4.75,369.95),17428,1246)
		map_spot(se_obj.id,"crlc_mdl","check_treasure_0")
	end,
	["n_inventory_box_mg1"]=function(box)
		local obj = create("n_inventory_box_limansk12",xyz(10.524602584839,1.8927528858185,-391.09912109375),30960,3006)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_mg2"]=function(box)
		give_info("snpt_mg2_have1")
		create_restrictor(xyz(-74.212478637695,2.7899203300476,64.743927001953),272032,3622,80,"snp_spawn.snpt_mg2_lastday")
	end,
	["n_inventory_box_bar1"]=function(box)
		give_info("snpt_bar1_done")
	end,
	["n_inventory_box_bar2"]=function(box)
		give_info("snpt_bar2_done")
	end,
	["n_inventory_box_gen2"]=function(box)
		lost_item("gena_note3")
		local obj = create("n_inventory_box_x83",xyz(-93.740013122559,-15.946046447754,112.18583679199),1380,3837)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_hospital2"]=function(box)
		release_teleport("fli99_tp3")
	end,
	["n_inventory_box_warlab1"]=function(box)
		give_info("snpt_warlab1_done")
	end,
	["n_inventory_box_zaton1"]=function(box)
		local obj = create("n_inventory_box_zaton1_2",xyz(-394.79879760742,53.038612365723,-337.77597045898),185627,3664)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["n_inventory_box_zaton1_2"]=function(box)
		lost_item("fli_note14")
	end,
	["n_inventory_box_zaton3"]=function(box)
		give_info("snpt_zaton1_done")
		create_teleport("snp_zaton_tp1", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id())
	end,
	["n_inventory_box_zaton5"]=function(box)
		give_info("snpt_zaton3_done")
	end,
	["n_inventory_box_zaton6"]=function(box)
		give_info("snpt_zaton4_done")
	end,
	["n_inventory_box_hospital3"]=function(box)
		give_info("snpt_hospital1_done")
	end,
	["n_inventory_box_x181"]=function(box)
		give_info("snpt_x181_done")
	end,
	["n_inventory_box_x162"]=function(box)
		give_info("snpt_x161_done")
		give_info("snp_video_arhiv_done")
		archievements.acv_task()
		sms("%c[sender]"..translate("name_anna")..":\\n%c[sms_red]"..translate("sms_anna_anna_1_0"), 3, "anna", 30000, nil, [[sms\anna\anna_1]])
		if not has_info("sidor_delo_done") then
			sms("%c[sender]"..translate("name_anna")..":\\n%c[sms_red]"..translate("sms_anna_anna_2_0"), 21, "anna", 40000, nil, [[sms\anna\anna_2]])
		end
		local obj = create("vesker_zaton",xyz(128.0725402832,-7.3395228385925,189.58338928223),1186465,3686)
		ai:assign_story_id(obj.id,19933)
	end,
	["n_inventory_box_bum1"]=function(box)
		lost_item("gena_note4")
		create_teleport("gena_tp1", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id())
		timer("run", 1, "snp.gena_oso1_start()")
	end,
	["n_inventory_box_profi%d"]=function(box)
		local section=box:section()
		if section == "n_inventory_box_profi1" then
			release_teleport("snp_profi_tp1")
		elseif section == "n_inventory_box_profi2" then
			create_teleport("snp_profi_tp2", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id())
		elseif section == "n_inventory_box_profi3" then
			release_teleport("snp_profi_tp2")
		elseif section == "n_inventory_box_profi4" then
			release_teleport("snp_profi_tp4")
		elseif section == "n_inventory_box_profi5" then
			release_teleport("snp_profi_tp5_1")
			release_teleport("snp_profi_tp5_2")
		elseif section == "n_inventory_box_profi6" then
			release_teleport("snp_profi_tp6")
		end
		snp_spawn.all_letters()
	end,
	["v_inventory_box0"]=function(box)
		sms("%c[sender]"..translate("name_volazar")..":\\n%c[sms_red]"..translate("sms_volazar_v_inventory_box0_0")..user_name()..translate("sms_volazar_v_inventory_box0_1"), 3, "vol_new", 40000, nil, [[sms\volazar\v_inventory_box0]])
		give_info("vol_info_temp")
		give_info("vol_fly")
	end,
	["a_inventory_box31"]=function(box)
		give_info("taynik_bandit_x18_have")
	end,
	["a_inventory_box62"]=function(box)
		svoboda_peremirie.hameleon_spawn()
	end,
	
}

setmetatable(check_treasure_section,_G.patternSearchTable)

function check_treasure(box)
	local check_section=check_treasure_section[box:section()]
	if check_section then
		check_section(box)
	end
end

-- общий калбек на взятие предмета из тайника, вызывается из take_item_from_box, и только один раз, независимо от количества лоадов.
local take_box_sections={
	["emb_container"]=function(object) 
		give_info("emb_container_have")
	end,
	["emb_note25"]=function(object) 
		give_info("emb14")
	end,
	["snp_almaz_note1"]=function(object) 
		release(object_by_section_offline("suslov_marsh"))
		create_teleport("tele_tulza_2",xyz(-359.7,11.113,510.093),139086,3477)
		local obj = create("snp_almaz_note2",xyz(30.251602172852,-0.85134720802307,-27.375852584839),139607,2131)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,	
	["snp_almaz_note3"]=function(object) 
		lost_item("snp_almaz_note2")
		local obj = create("n_inventory_box_almaz4",xyz(-7.8711194992065,2.2752339839935,-27.166484832764),92225,2131)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_almaz_note4"]=function(object) 
		lost_item("snp_almaz_note3")
		local obj = create("n_inventory_box_almaz5",xyz(-33.041538238525,5.4613304138184,-31.517143249512),65385,2132)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_almaz_note5"]=function(object) 
		lost_item("snp_almaz_note4")
		local obj = create("n_inventory_box_almaz6",xyz(47.762790679932,8.6410655975342,-31.51616859436),156324,2137)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_almaz_note6"]=function(object) 
		lost_item("snp_almaz_note5")
		local obj = create("n_inventory_box_almaz7",xyz(-18.499711990356,1.4957152605057,-25.481069564819),80006,2160)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,	
	["snp_almaz_note7"]=function(object) 
		lost_item("snp_almaz_note6")
		local obj = create("n_inventory_box_almaz8",xyz(44.441833496094,4.6751842498779,-25.246084213257),157056,2228)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
		create_teleport("tele_almaz8",xyz(48.973514556885,5.4608883857727,-17.918466567993),164628,2228)
	end,
	["snp_almaz_note8"]=function(object) 
		lost_item("snp_almaz_note7")
		create_restrictor(xyz(-136.21276855469,12.617782592773,10.618383407593),3688,2252,2,"snp_spawn.n_inventory_box_almaz9")
		release_teleport("tele_almaz8")
	end,
	["snp_almaz_note9"]=function(object) 
		lost_item("snp_almaz_note8")
		local obj = create("n_inventory_box_almaz10",xyz(-208.36692810059,8.6610012054443,42.246055603027),4289,2252)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_almaz_note10"]=function(object) 
		lost_item("snp_almaz_note9")
		local obj = create("n_inventory_box_almaz11",xyz(-216.12236022949,5.4740557670593,86.903327941895),78,2141)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
		create("snp_almaz_note10_tele",xyz(-208.19,8.66,47.50),14509,2250)
	end,
	["snp_almaz_note11"]=function(object) 
		lost_item("snp_almaz_note10")
		local obj = create("n_inventory_box_almaz11a",xyz(-50.975608825684,3.5477068424225,-289.13818359375),137857,3756)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
		create("snp_almaz_note11_tele",xyz(-216.00,5.48,82.06),14509,2250)
	end,
	["snp_almaz_note11a"]=function(object) 
		lost_item("snp_almaz_note11")
		local obj = create("n_inventory_box_almaz12",xyz(855.42320800781,8.4400463104248,64.832587585449),160821,2604)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
		find_and_release("snp_almaz_note11_tele")
	end,
	["snp_almaz_note12"]=function(object) 
		lost_item("snp_almaz_note11a")
		local obj = create("n_inventory_box_almaz13",xyz(86.640037536621,59.932830810547,116.73533630371),57849,2566)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_almaz_note13"]=function(object) 
		lost_item("snp_almaz_note12")
		sms("%c[sender]"..translate("name_kotobegemot")..":\\n%c[sms_red]"..translate("sms_kotobegemot_snp_almaz_note13_1_0"), 5, "kotobegemot", 30000, nil, [[sms\kotobegemot\snp_almaz_note13_1]])	
	end,	
	["snp_note11"]=function(object) 
		lost_item("snp_note10")
		local obj = create("n_inventory_box_kl1_3",xyz(-133.72560119629,-4.0903553962708,-153.58737182617),4283,3238)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_note12"]=function(object) 
		lost_item("snp_note11")
		local obj = create("snp_note13",xyz(-200.10061645508,-0.75918161869049,-77.472457885742),3782,3238)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_note26"]=function(object) 
		if has_info("snp_tmp1") then
			give_info("snpt_jupiter2_have")
--		else
--			give_info("snpt_jupiter2_fail")
--			sms("%c[sender]"..translate("name_obitel_zla")..":\\n%c[sms_red]"..translate("sms_resident_evil_resident_evil_3_0"), nil, "resident_evil", 10000, nil, [[sms\resident_evil\resident_evil_3]])
		end
		give_info("snp_tmp_reset")
		disable_info("snp_tmp_reset")
	end,
	["snp_note27"]=function(object) 
		give_info("snpt_jupiter3_have1")
	end,	
	["snp_note29"]=function(object) 
		local obj = create("n_inventory_box_vp5",xyz(-111.72229003906,0.99149996042252,-103.54452514648),82836,3759)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["snp_note30"]=function(object) 
		lost_item("snp_note29")
		local obj = create("n_inventory_box_vp6",xyz(205.22360229492,-25.027803421021,-258.54818725586),419629,3765)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
	end,
	["af_fobos"]=function(object) 
		if not has_info("snpt_jupiter5_done") then
			give_info("snpt_jupiter5_done")
			give_info("actor_cant_move")
			sms("%c[sender]"..translate("name_boroda")..":\\n%c[sms_red]"..translate("sms_boroda_af_fobos_1_0"), 3, "boroda", 30000, nil, [[sms\boroda\af_fobos_1]])
			timer("run",41,"snp_spawn.snpt_jupiter6_run1()")
	                timer("run",38,"snp.otpuskaem_igroka()")
		end
	end,
	["af_kamen_udachy2"]=function(object) 
		if has_info("snp_kamen_udachy_not_found") then
			sms("%c[sender]"..translate("name_proper_semidesyatii")..":\\n%c[sms_red]"..translate("sms_proper70_snp_kamen_udachy_not_found_0"), nil, "proper70", 50000, nil, [[sms\proper70\snp_kamen_udachy_not_found]])
			give_info("snp_kamen_udachy_fail")
		end
		give_info("snp_kamen_udachy_have")
	end,
	["snp_pftp"]=function(object) 
		if not has_info("snp_pftp_have") then
			sms("%c[sender]"..translate("name_pftp")..":\\n%c[sms_red]"..translate("sms_pftp_pftp_0"), nil, "nano", 50000, nil, [[sms\pftp\pftp]])
			give_info("snp_pftp_have")
		end
	end,	
	["fli_note7"]=function(object) 
		if has_info("fli_have_3") and not has_info("fli_have_4") then
			timer("fli_teleport_actor", 10, "fli99_tp1")
			give_info("fli_have_4")
		end
	end,
	["fli_bomba"]=function(object) 
		fly_island.worker()
	end,	
	["snp_pda_profi1"]=function(object) 
		release(server_object(object:id()))
		for i=1,20 do
			release(server_object(db.actor:object("snp_profi"..tostring(i)):id()))
		end
		sms("check_treasure_item_5", nil, "nano", 10000)
		release_teleport("snp_profi_tp0")
		voice([[snp\pripyat_1986]]):play_at_pos(db.actor, xyz(0,30,0), 120, sound_object.s3d)
		give_info("snp_profi_done")
	end,
	
}
function check_treasure_item(obj)
	local func=take_box_sections[obj:section()]
	if func then
		func(obj)
	end
end

function almaz_skull_droped(obj)
	if 	has_info("snp_almaz2") and 
		not has_info("snp_almaz_skull_droped") and 
		level.name()=="av_peshera" and
		db.actor:position():distance_to(vector():set(174.08480834961,55.11833190918,386.01168823242)) < 2   -- позиция аномалии
	then
		give_info("snp_almaz_skull_droped")
		level.start_stop_menu(level.main_input_receiver(), true)
		amk.remove_item(obj)
		level.add_pp_effector("teleport.ppe", 1626, false)
		lost_all("snp_skull")
		timer("run", 10, "snp_spawn.almaz_done()")
	end
end

function borov1_done()
	lost_item("snp_pda1")
	create("snp_note1",xyz(60.12,1.30,203.08),28310,1243)
end

function kotobegemot1_done()
	lost_item("snp_note1")
se_obj = create("n_inventory_box_dt1",xyz(-198.42,0.04,64.85),26867,1374)
map_spot(se_obj.id,"crlc_mdl","kotobegemot1_treasure_0")
end

function kotobegemot2_done()
	local obj = create("n_inventory_box_uagro1",xyz(-80.046859436035,0.33554920554161,-74.513531799316),2743,717)
	map_spot(obj.id, "treasure", "Cache")
	local obj = create("n_inventory_box_uagro2",xyz(-76.056887817383,5.0370149612427,-71.1019128418),3053,717)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function kotobegemot3_done()
	create_trup("suslov_marsh",xyz(-179.94078063965,-1.9289412498474,-317.0966796875),50507,3365,19910)
	local obj = create_restrictor(xyz(-179.94078063965,-1.9289412498474,-317.0966796875),50507,3365,5,"snp_spawn.suslov_marsh_sms1")
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function kotobegemot4_done()
	got("wpn_mp5_m5",1)
	got("ammo_5.7x28_ap",2)
end
function kotobegemot5_done()
	local obj = create("n_inventory_box_zaton6",xyz(472.22393798828,45.309955596924,32.999851226807),1732117,3693)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function fenrir1_done()
	local obj = create_item_and_restrictor("n_inventory_box_kordon1",xyz(-279.7380065918,-0.36574172973633,-54.755081176758),771,66)
	map_spot(obj.id,"crlc_big","fenrir1_done_0")
end
function fenrir2_done()
	local obj = create("n_inventory_box_vp1",xyz(152.8119354248,35.794906616211,192.96481323242),366789,3769)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
	create("snp_pda13",xyz(137.0463104248,28.907472610474,241.01393127441),365077,3769)
end
function fenrir3_done()
	give_info("snp_tmp_reset")
	disable_info("snp_tmp_reset")
	sms("%c[sender]"..translate("name_kotobegemot")..":\\n%c[sms_red]"..translate("sms_kotobegemot_fenrir3_done_1_0"), 2, "kotobegemot", 30000, nil, [[sms\kotobegemot\fenrir3_done_1]])
	create_item_and_restrictor("n_inventory_box_limansk1",xyz(-15.645086288452,31.041418075562,204.26181030273),18361,3010)
end
function fenrir5_done()
	create_item_and_restrictor("n_inventory_box_sd2",xyz(-68.083503723145,16.592102050781,16.235578536987),11195,3326)
end
function fenrir6_done()
	create_restrictor(xyz(111.94484710693,26.06196975708,206.38247680664),222943,2163,8,"snp_spawn.n_inventory_box_cp1")
end
function fenrir7_done()
	create("snp_pda4",xyz(89.451782226563,8.0235919952393,-36.271701812744),40758,3336)
end
function fenrir8_done()
	local obj = create("n_inventory_box_limansk2",xyz(153.16612243652,-3.9684197902679,191.56245422363),48566,3010)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function fenrir9_done()
	local obj = create("n_inventory_box_pp1",xyz(34.707355499268,26.599336624146,-34.705635070801),19879,3797)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function fenrir10_done()
	lost("snp_pda5",1)
end
function fenrir11_done()
	create_teleport("snp_dt_tp1",xyz(-247.21,3.90,36.29),12157,1423)
end
function fenrir12_done()
	create_item_and_restrictor("n_inventory_box_garbage1",xyz(-43.013954162598,15.852832794189,-192.50405883789),146745,267)
	create_item_and_restrictor("n_inventory_box_garbage2",xyz(-140.48768615723,11.519528388977,-4.1077198982239),76863,320)
end
function fenrir14_done()
	sms("%c[sender]"..translate("name_anna")..":\\n%c[sms_red]"..translate("sms_anna_fenrir14_done_0"), 3, "anna", 30000, nil, [[sms\anna\fenrir14_done]])
	sms("%c[sender]"..translate("name_strelok")..":\\n%c[sms_red]"..translate("sms_strelok_fenrir14_done_0"), 9, "strelok", 30000, nil, [[sms\strelok\fenrir14_done]])
new_spawn.start_snp_kamen_timer()
end
function fenrir15_done()
	sms("%c[sender]"..translate("name_anna")..":\\n%c[sms_red]"..translate("sms_anna_fenrir15_done_0"), 3, "anna", 30000, nil, [[sms\anna\fenrir15_done]])
	sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("sms_fenrir_fenrir15_done_0"), 10, "fenrir", 3000, nil, [[sms\fenrir\fenrir15_done]])
--	create("wolffrend_zaton2",xyz(244.71939086914,18.52823638916,530.84967041016),1385170,3687)
--	local obj = create("wolffrend_talk_zaton2",xyz(244.79071044922,18.458442687988,530.23742675781),1385169,3687)
--      ai:assign_story_id(obj.id,19924)
--	ai:assign_story_id(obj.id,19925)
--	create_restrictor(xyz(244.71939086914,18.52823638916,530.84967041016),1385170,3687,20,"snp_spawn.snp_found_vogak")
end
function fenrir16_done()
	local obj = create("n_inventory_box_x181",xyz(5.69282579422,-6.828028678894,-5.3396325111389),3531,1135)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
	create_restrictor(xyz(9.7957534790039,-7.004012298634,-3.883784532547),4183,1135,2,"snp_spawn.n_inventory_box_x181_1")
end

function wolffrend3_done()
	sms("wolffrend3_done_0", nil, nil, 20000)
--	snp_shadow.worker()
end

function bibliofrend1_done()
	local obj = create("n_inventory_box_td1",xyz(43.687808990479,8.059473991394,-48.321968078613),229941,1075)
	map_spot(obj.id, "treasure", "Cache")
	local obj = create("n_inventory_box_td1",xyz(49.53458404541,4.5404696464539,-24.940389633179),236607,1088)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function bibliofrend_black2_done()
	lost("snp_prime_maz_green",1)
	lost("snp_prime_tabletki",1)
end

function resident_evil2_done()
	local obj = create("n_inventory_box_cp2",xyz(209.30194091797,12.337078094482,98.220161437988),257446,2145)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function resident_evil3_done()
	local obj = create_restrictor(xyz(64.295387268066,14.247812271118,141.46493530273),235901,364,1,"snp_spawn.snp_receipt_parts2_1")
	map_spot(obj.id,"crlc_big","resident_evil3_done_0")
	set_value("snp_spot_id",obj.id)
end
function resident_evil4_done()
	local obj = create("n_inventory_box_x161",xyz(19.222473144531,2.6730494499207,10.203114509583),4529,1537)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function resident_evil7_done()
	local obj = create("n_inventory_box_2chaes1",xyz(888.90844726563,18.115972518921,308.2389831543),165937,2615)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function resident_evil8_done()
	sms("resident_evil8_done_0", nil, nil, 20000)
	local obj = create("n_inventory_box_as1",xyz(18.167123794556,-5.2449584007263,436.44525146484),365693,1808)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function resident_evil9_done()
	local obj = create("n_inventory_box_jupiter2",xyz(-131.712,33.441,-495.356),496987,3714)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
	create_restrictor(xyz(-131.71226501465,33.441413879395,-495.35614013672),496987,3714,3,"snp_spawn.n_inventory_box_jupiter2")
	create_car("vehicle_btr",xyz(-157.93148803711,26.787044525146,-469.19927978516),450749,3714, "scripts\\technics\\snp_btr.ltx")
	create_car("vehicle_btr",xyz(-116.92964172363,26.800518035889,-467.65985107422),523498,3714, "scripts\\technics\\snp_btr.ltx")
end
function resident_evil10_done()
	snp_spawn.n_inventory_box_agro1()
end
function resident_evil11_done()
	create_restrictor(xyz(-173.85223388672,24.41708946228,46.521488189697),162421,3600,3,"snp.spawn_brodaga")
end
function resident_evil12_done()
	sms("resident_evil12_done_0", nil, nil, 20000)
	local obj = create("n_inventory_box_sarcofag1",xyz(31.045442581177,21.825170516968,10.412265777588),6350,2423)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function resident_evil13_done()
	create_restrictor(xyz(-36.414665222168,-8.9850168228149,-38.975612640381),140,3155,1,"snp_spawn.n_inventory_box_warlab1")
end

function proper70_start_done1()
	drink_vodka()
	lost_item("dictofon_fenrir")
	timer("run2",4,"snp.proper70_start_done2()")
end
function proper70_start_done2()
	level.add_cam_effector("camera_effects\\radar_stop.anm", 2506, false, "")
	timer("run2",14,"snp.proper70_start_done3()")
end
function proper70_start_done3()
	_G.Dream:sleep(3 + get_value("energy_drink", 0))
	timer("run2",2,"snp.proper70_start_done4()")
end
function proper70_start_done4()
	local obj = object_by_section("proper70_limansk")
	if obj then
		release(server_object(obj:id()))
	end
	local obj = create("n_inventory_box_limansk3",xyz(-64.228126525879,-0.44177567958832,-133.02131652832),1016,2996)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function proper70_sms1()
	local text = "%c[sender]"..translate("name_proper_semidesyatii")..":\\n%c[sms_red]"..translate("proper70_sms1").."\n"
	db.actor:give_talk_message(text, "ui\\ui_iconsTotal", Frect():set(0,658,83,47), "iconed_answer_item")
	sms(text, nil, "proper70", 30000, nil, [[sms\proper70\proper70_sms1]])
end
function proper701_done()
	sms("%c[sender]"..translate("name_anna")..":\\n%c[sms_red]"..translate("sms_anna_proper701_done_0"), 2, "anna", 30000, nil, [[sms\anna\proper701_done]])
	got("af_teleport")
end
function proper_teleport_dal()
	got("af_teleport")
end
function proper703_done()
	release(object_by_section_offline("snp_semetskiy"))
	create_restrictor(xyz(-100.15243530273,-1.140389919281,-16.317848205566),243214,3620,1,"snp.gena_start")
end
function proper705_done()
	local obj = create("n_inventory_box_jupiter3",xyz(0.0003257321077399,9.8299655914307,173.87929992676),716376,3724)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function proper706_have()
	lost_all("snp_pda7")
	release(object_by_section_offline("snp_ucheniy1"))
end
function proper7010_done()
	create_teleport("tele_limansk5",xyz(44.667556762695,3.6490089893341,340.65399169922),52431,3025)
end
function proper7012_done()
	got("af_zvezda_proroka",1)
	del_value("snp_make_zp")
end
function proper7013_done()
	sms("proper7013_done_0", nil, nil, 20000)
	local obj = create("n_inventory_box_zaton2",xyz(203.38031005859,54.482738494873,20.770593643188),1317929,3684)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function proper7014_done()
--	lost_item("snp_pftp")
end
function proper7015_done()
	local obj = create("n_inventory_box_x162",xyz(113.93637084961,38.142959594727,-17.945663757324),7084,1543)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function anna1_done()
	local obj = create("n_inventory_box_x81",xyz(-111.18604278564,-32.319286346436,87.424247741699),257,3832)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
	snp_spawn.n_inventory_box_x81()
end
function anna4_done()
	local obj = create("n_inventory_box_kordon5",xyz(20.258415222168,19.372343063354,709.37756347656),297580,1)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function ludmila_start_done()
	create_trup("snp_ucheniy2",xyz(10.804178237915,37.729103088379,64.052787780762),91279,2575,19919)
	create("zone_roy_fly",xyz(10.804,37.729,64.052),91279,2575)
end
function ludmila1_done()
	release(object_by_section_offline("snp_ucheniy2"))
	local obj = create("n_inventory_box_vp4",xyz(-44.927261352539,7.6782546043396,-95.03076171875),143417,3759)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
    find_and_release("zone_roy_fly")
end
function ludmila2_done()
	local obj = create("n_inventory_box_x82",xyz(-71.280982971191,-5.6220226287842,70.717254638672),4851,3841)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function ariadna3_done()
	game.start_tutorial("finish_dopa_dream")
end
function ariadna_talk()
	db.actor:run_talk_dialog(object_by_section("ariadna_zaton"))
end
function ariadna4_done()
    db.actor:hide_weapon()
    level.disable_input()
	timer("run",4,"snp.op2_done1()")
end

function op2_done1()
	release(server_object(object_by_section("skadovsk_radio"):id()))
	xr_sound.stop_all_sound_object()
	level.add_pp_effector("agr_u_fade.ppe", 2009, false)
	level.hide_indicators()
	timer("run",5.5,"snp.op2_done2()")
end
function op2_done2()
	local f = getFS()
	if f:exist("$game_settings$", "credits.ltx") == nil then
		local f1 = f:update_path("$game_settings$", "game_setup.ltx")
		local f2 = f:update_path("$game_settings$", "credits.ltx")
		f:file_copy(f1, f2)
	end

	xr_effects.game_credits()
end

function lobsang1_done()
	create("snp_note20",xyz(-123.56,2.64,-265.17),71235,3752)
end
function lobsang2_done()
	local obj = create("n_inventory_box_zaton3",xyz(322.16027832031,31.884847640991,-509.40014648438),1661631,3694)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function brodaga_start_done()
	create_teleport("snp_mg_tp1",db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id())
end
function brodaga1_done()
	create_restrictor(xyz(152.49157714844,10.798604011536,135.94035339355),39883,1204,1,"snp_spawn.snpt_bar1_restr1")
end
function brodaga2_done()
	create_restrictor(xyz(134.34739685059,1.77443754673,209.43351745605),945793,3732,80,"snp_spawn.snpt_jupiter4_restr1")
	create_restrictor(xyz(155.5616607666,1.2630597352982,217.27157592773),981446,3732,1,"snp_spawn.snpt_jupiter4_restr2")
	create_restrictor(xyz(166.08932495117,-1.0351370573044,216.90351867676),996813,3732,0.5,"snp_spawn.snpt_jupiter4_restr3")
end
function brodaga3_done()
	local obj = create("n_inventory_box_hospital3",xyz(-92.732971191406,36.388934326172,718.83197021484),1801,3034)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function boroda_start_done()
	create_restrictor(xyz(398.89025878906,42.905143737793,-186.23631286621),1344338,3743,1,"snp_spawn.snpt_jupiter5_run0")
end
function boroda2_done()
	local obj = create("n_inventory_box_bar2",xyz(157.58059692383,2.3406450748444,99.714075622559),41404,1210)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function bubulyka1_done()
	local obj = create("n_inventory_box_x101",xyz(-35.10555267334,-12.319800376892,38.615665435791),1883,2740)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function bubulyka2_done()
	create("snp_plan",xyz(127.46975708008,15.725096702576,-85.388702392578),8868,3329)
end
function bubulyka3_done()
	local obj = create("n_inventory_box_jupiter1",xyz(223.76635742188,-27.385223388672,118.8678894043),1099877,3740)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
	create_restrictor(xyz(225.84899902344,-7.6801772117615,121.92847442627),1103327,3740,5,"snp_spawn.n_inventory_box_jupiter1")
end
function bubulyka5_done()
	create_trup("snp_semetskiy",xyz(-8.7067518234253,2.8850204944611,-137.86454772949),20691,2993,19912)
	timer("run", 2.0, "snp.stalk_semetskiy_delete()")
end
--' удаляем живого Семецкого из Лиманска, если он уже появился
function stalk_semetskiy_delete()
if has_info("semetskiy_lima_spawn") then
local se_obj = server_object("stalk_semetskiy")
  if se_obj then
    release(se_obj, true)
  end
 end
end
function bubulyka7_done()
	local obj = create("n_inventory_box_zaton5",xyz(-474.8293762207,49.513092041016,-363.09838867188),369480,3669)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function sviblov1_done()
	local obj = create("n_inventory_box_almaz1",xyz(-323.99597167969,23.688106536865,504.12481689453),12873,3361)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function monolith1_done()
	local obj = create("n_inventory_box_almaz14",xyz(-108.42949676514,40.053085327148,479.11297607422),151147,2987)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
	start_sound()
end

function kalmyk1_done()
	got("snp_prime_maz",1)
end

function ginekolog1_done()
	got("snp_prime_tabletki",1)
end

function sakharov1_done()
	create_trup("snp_ucheniy1",xyz(150.7462310791,12.494668960571,291.85235595703),66667,2546,19913)
end

function klenov1_done()
	create("snp_pda9",xyz(109.70481872559,4.0410284996033,131.71212768555),227060,2173)
end

function osvedomitel1_done()
	got("karta_peschera",1)
end
-- По квесту на блокнот Доцента
function docent1_done()
	create_restrictor(xyz(342.96533203125,-10.53200340271,265.6682434082),487247,3769,6,"snp_spawn.n_inventory_box_vp7") -- увеличен радиус рестриктора в реке
	create_restrictor(xyz(375.67,-13.86,339.41),486932,3769,40,"snp_spawn.n_inventory_box_vp7") -- добавлен ещё один рестриктор в реке, чтобы наверняка его задеть
	create_restrictor(xyz(-149.70997619629,0.07987043261528,-325.49044799805),8641,3241,2,"snp_spawn.n_inventory_box_kl3")
	local obj = create("n_inventory_box_vp7",xyz(438.14892578125,-3.9284706115723,348.73168945313),487247,3769)
	map_spot(obj.id, "treasure", "Cache")
	local obj = create("n_inventory_box_kl3",xyz(-151.22601318359,4.3636498451233,-330.02380371094),6006,3239)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function docent2_done()
	got("bioradar2",1)
end
function docent4_done()
	got("snp_rings",1)
	got("bullion_gild",1)
	del_value("snp_make_rings")
end

function snpt_kordon1_done()
	lost_item("snp_pda2")
	lost_item("snp_note2")
end
function snpt_limansk4_done()
	lost_all("snp_note25")
	lost_all("snp_receipt")
end
function snpt_x101_done()
	lost("snp_note8",1)
end
function snpt_sd1_done()
	lost("snp_plan",1)
end
function snpt_sd4_done()
	lost_item("snp_pda4")
end
function snpt_cp2_done()
	lost_all("snp_pda9")
end
function snpt_garbage1_done()
	lost_item("snp_note16")
end
function snpt_jupiter3_have2()
	lost_all("snp_note27")
end
function snpt_mg2_done()
	lost_item("snp_note28")
	lost_item("snp_pda8")
	got_money(500000)
end
function snpt_kl1_done()
	lost_all("snp_note31")
end
function snpt_2chaes3_done()
	lost_all("snp_pda14")
end

function receipt_parts1_done()
	lost_item("snp_note18")
end

function spawn_fenrir_resident()
	local obj
	if has_info("snp_kotobegemot2_done") and has_info("doki_dimak_done") then
		obj = create("skadovsk_radio",xyz(124.41,-6.15,175.72),1180491,3686)
                obj:set_direction(0,3.2,0)
		obj = create("fenrir_zaton",xyz(138.73059082031,-7.3394303321838,178.58042907715),1203766,3686)
		ai:assign_story_id(obj.id,19902)
--		create("wolffrend_zaton",xyz(137.85824584961,-7.3402981758118,176.09548950195),1202652,3686)
--		obj = create("wolffrend_talk_zaton",xyz(137.19732666016,-7.3405375480652,176.83992004395),1201535,3686)
--		ai:assign_story_id(obj.id,19925)
		obj = create("resident_evil_zaton",xyz(125.20777893066,-7.3201112747192,181.31158447266),1181686,3686)
		ai:assign_story_id(obj.id,19903)
--		create("bibliofrend_zaton",xyz(123.07048034668,-7.3236355781555,177.8239440918),1178118,3686)
		obj = create("bibliofrend_talk_zaton",xyz(124.68988037109,-7.3328924179077,177.81799316406),1180494,3686)
		ai:assign_story_id(obj.id,19926)
		obj = create("anna_zaton",xyz(130.02600097656,-7.3398327827454,177.09588623047),1189961,3686)
		ai:assign_story_id(obj.id,19904)
		obj = create("bubulyka_zaton",xyz(125.23503112793,-7.3206615447998,189.49803161621),1181710,3686)
		ai:assign_story_id(obj.id,19905)
		local obj = create("n_inventory_box_jupiter10",xyz(-394.78768920898,11.417579650879,-16.300596237183),51619,3708)
		map_spot(obj.id, "treasure", "Cache")
		sms("Received a tip on the cache", nil, nil, 10000)
		create("yashik_smeley",xyz(-390.25207519531,11.416480064392,-15.570077896118),58648,3708)
		create("yashik_smeley",xyz(-390.9560546875,11.416576385498,-15.566843032837),57648,3708)
		create("yashik_smeley",xyz(-391.61871337891,11.416634559631,-15.565946578979),57648,3708)
		create("yashik_smeley",xyz(-392.30261230469,11.416634559631,-15.56485748291),56659,3708)
	end
end

function fenrir_gone()
	give_info("snp_fenrir13_done")
	create_restrictor(xyz(-62.68639755249,-0.44013518095016,-138.39880371094),1086,2996,1,"snp_spawn.n_inventory_box_limansk3")
end

function spawn_bunker_jupiter()
	local obj
	obj = object_by_section_offline("fenrir_2chaes")
	if obj then
		release(obj)
	end
	release(object_by_section_offline("resident_evil_zaton"))
	release(object_by_section_offline("anna_zaton"))
	create_trup("fenrir_jupiter",xyz(-223.81423950195,-2.3742883205414,83.036392211914),335931,3708,19911)
	obj = create("proper70_jupiter",xyz(-227.50967407227,-3.3744874000549,79.343292236328),331133,3708)
	ai:assign_story_id(obj.id,19907)
	obj = create("resident_evil_jupiter",xyz(-223.96179199219,-3.5705282688141,78.559143066406),337165,3708)
	--ai:assign_story_id(obj.id,19908)
	ai:assign_story_id(obj.id,19903)
	obj = create("anna_jupiter",xyz(-222.07434082031,-3.3452470302582,83.116653442383),340907,3708)
	ai:assign_story_id(obj.id,19909)
	give_info("snp_anna2_done")
end

function spawn_brodaga()
	sms("%c[sender]"..translate("name_obitel_zla")..":\\n%c[sms_red]"..translate("spawn_brodaga_0_0"), nil, "resident_evil", 20000, nil, [[sms\resident_evil\spawn_brodaga]])
	create_wounded("brodaga_mg",xyz(-79.084762573242,0.13354560732841,156.9275970459),266398,3621)
	create("medkit",xyz(0,0,0),0,0,0)
end

function brodaga_give_medkit(first_speaker, second_speaker)
	if not has_info("snpt_mg1_done") then
		dialogs.transfer_medkit(first_speaker, second_speaker)
		give_info("snpt_mg1_done")
	end
end

function move_ariadna_to_bar()
	if has_info("snpt_kl1_have1") and has_info("snpt_kl1_have2") then
		local obj = object_by_section_offline("marsh_ariadna2")
		if obj then
			release(obj)
		else
			obj = object_by_section_offline("marsh_ariadna")
			if obj then
				release(obj)
			end
		end
		obj = create("ariadna_bar",xyz(115.2995300293,-5.3040218353271,12.653481483459),33757,1239)
		ai:assign_story_id(obj.id,19917)
	end
end

-- Вертолеты в ВП
function heli_vp1()
	heli_vp1_done(1)
end
function heli_vp2()
	heli_vp1_done(2)
end
function heli_vp3()
	heli_vp1_done(3)
end
function heli_vp4()
	heli_vp1_done(4)
end
function heli_vp5()
	heli_vp1_done(5)
end
function heli_vp6()
	heli_vp1_done(6)
end
function heli_vp1_done(num)
	give_info("snp_tmp"..tostring(num))
	if  has_info("snp_tmp1") and has_info("snp_tmp2") and has_info("snp_tmp3") and has_info("snp_tmp4") and has_info("snp_tmp5") and has_info("snp_tmp6") then
		if not has_info("snpt_vp1_have") then
			give_info("snpt_vp1_have")
			disable_info("no_teleport_near_heli_btr")
			sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("sms_fenrir_heli_vp1_done_0"), nil, "fenrir", 11000, nil, [[sms\fenrir\heli_vp1_done]])
			local obj = create("n_inventory_box_vp1_2",xyz(101.78779602051,16.476371765137,378.32775878906),321990,3760)
			map_spot(obj.id, "treasure", "Cache")
			sms("Received a tip on the cache", nil, nil, 10000)
			create("zone_ozero",xyz(58.848209381104,1.0079244375229,367.44982910156),276095,3760)
		end
	end
end
function heli_vp1_fail()
	if not has_info("snpt_vp1_have") then
		give_info("snp_tmp_reset")
		disable_info("snp_tmp_reset")
		give_info("snpt_vp1_fail")
	end
end

-- стрелял в вульфа - враг Фенриру
function actor_shoot_wolffrend()
	local obj
	if not has_info("fenrir_enemy") then
		sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("actor_shoot_wolffrend_0_0"), nil, "fenrir", 30000)
		obj = object_by_section("wolffrend_talk_zaton")
		if obj then
			release(server_object(obj:id()))
		end
		relation_registry.set_community_goodwill ("stalker", "actor", -5000)
		db.actor:set_character_community("monolith", 0, 0)
		give_info("fenrir_enemy")
	end
end

-- стрелял в библика - враг Обители Зла
function actor_shoot_bibliofrend()
	local obj
	if not has_info("resident_evil_enemy") then
		sms("%c[sender]"..translate("name_obitel_zla")..":\\n%c[sms_red]"..translate("actor_shoot_bibliofrend_0_0"), nil, "resident_evil", 30000)
		obj = object_by_section("bibliofrend_talk_zaton")
		if obj then
			release(server_object(obj:id()))
		end
		relation_registry.set_community_goodwill ("stalker", "actor", -5000)
		db.actor:set_character_community("monolith", 0, 0)
		give_info("resident_evil_enemy")
	end
end

-- воскрешение Фенрира
local fenrir = nil
function fenrir_recurrection()
	local art = object_by_section_nobinder("af_zvezda_proroka")
	fenrir = object_by_section("fenrir_jupiter")
	if art:position():distance_to(fenrir:position()) > 2.5 then return end

	level.start_stop_menu(level.main_input_receiver(), true)
	xr_effects.disable_ui()
	amk.remove_item(art)
	level.add_cam_effector("camera_effects\\radar_stop.anm", 2920, false, "")
	local snd = voice("ambient\\sparks1")
	snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	timer("run4",snd:length()/1000+1,"snp.fenrir_recurrection2()")
	timer("run5",15,"snp.fenrir_recurrection5()")
end
function fenrir_recurrection2()
	level.add_pp_effector("teleport.ppe", 2921, false)
	local snd = voice("ambient\\mon_explosion")
	snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	timer("run",0.5,"snp.fenrir_recurrection3()")
	timer("run2",snd:length()/1000+2,"snp.fenrir_recurrection4()")
end
function fenrir_recurrection3()
	release(server_object(fenrir:id()))
	release(server_object(object_by_section("resident_evil_jupiter"):id()))
	release(server_object(object_by_section("anna_jupiter"):id()))
	give_info("teleport_started")
	db.actor:set_actor_position(xyz(-223.79437255859,-3.5704712867737,78.461990356445))
	db.actor:set_actor_direction(0)
	give_info("teleport_finished")
	level.remove_cam_effector(2920)
	level.add_cam_effector("camera_effects\\radar_stop.anm", 2920, false, "")
end
function fenrir_recurrection4()
	say("ambient\\earthquake")
end
function fenrir_recurrection5()
	level.add_pp_effector("agr_u_fade.ppe", 2923, false)
	timer("run3",6,"snp.fenrir_recurrection6()")
end
function fenrir_recurrection6()
	level.remove_pp_effector(2923)
	level.add_pp_effector("deadcity_wake.ppe", 2924, false)
	local snd = voice("ambient\\rnd_outdoor\\rnd_boar3")
	snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	timer("run",snd:length()/1000+2,"snp.fenrir_recurrection7()")
end
function fenrir_recurrection7()
	level.remove_pp_effector(2924)
	level.add_pp_effector("deadcity_wake.ppe", 2924, false)
	local snd = voice("ambient\\rnd_outdoor\\rnd_boar2")
	snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	timer("run",snd:length()/1000+2,"snp.fenrir_recurrection8()")
end
function fenrir_recurrection8()
	level.remove_pp_effector(2924)
	level.add_pp_effector("deadcity_wake.ppe", 2924, false)
	local snd = voice("ambient\\rnd_outdoor\\rnd_boar3")
	snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	timer("run",snd:length()/1000+2,"snp.fenrir_recurrection9()")
end
function fenrir_recurrection9()
	level.remove_pp_effector(2924)
	level.add_pp_effector("deadcity_wake.ppe", 2924, false)
	local snd = voice("ambient\\rnd_outdoor\\rnd_boar2")
	snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	timer("run",snd:length()/1000+4,"snp.fenrir_recurrection10()")
end
function fenrir_recurrection10()
	local obj = create("fenrir_jupiter",xyz(-223.79888916016,-3.3462553024292,81.488891601563),337173,3708)
	ai:assign_story_id(obj.id,19911)
	say("ambient\\random\\rnd_respawn")
	level.add_cam_effector("camera_effects\\prison_1.anm", 2925, false, "")
	timer("run",14,"snp.fenrir_recurrection11()")
end
function fenrir_recurrection11()
	xr_effects.enable_ui()
	give_info("snp_fenrir_resurrected")
end

-- Сборка биорадара
function snp_bioradar_parts_have_all()
	return
		has("part_bear_paw",1) and
		has("part_frog_leg",1) and
		has("part_parazit",1) and
		has("part_biomassa_growth",1) and
		has("part_stinger_sting",1) and
		has("part_winger_liver",1) and
		has("part_nosales_tongue",1) and
		has("part_fang_wolf",1) and
		has("part_spider_gland",1) and
		has("part_rotan_heart",1) and
		has("part_plague_hand",1) and
		has("part_carlic_hand",1) and
		has("part_vypolzen_hrebet",1) and
		has("part_raptor_kogot",1) and
		has("part_zanoza_leg",1) and
		has("part_flesh_eye",1) and
		has("part_boar_leg",1) and
		has("part_dog_tail",1) and
		has("part_psevdodog_tail",1) and
		has("part_krovosos_jaw",1) and
		has("part_burer_hand",1) and
		has("part_zombie_hand",1) and
		has("part_snork_leg",1) and
		has("part_face_tushkano",1) and
		has("part_hand_kontroler",1) and
		has("part_poltergeist_glas",1) and
		has("part_psevdogigant_hand",1) and
		has("part_tail_cat",1) and
		has("part_chimera_kogot",1) and
		has("part_fracture_hand",1) and
		has("part_deathclaw_antler",1) and
		has("part_digitis_biblio",1) and
		has("part_tarakan",1) and
		has("part_tarakan_strong",1) and
		has("part_zombie_teeth",1) and
		has("part_spleen_rat",1) and
		has("part_gnomius",1) 
end
function snp_bioradar_parts()
	if snp_bioradar_parts_have_all() then
		give_info("snp_bioradar_parts")
		return true
	end
	return false
end

function snp_bioradar_parts0_have_all()
	return
		has("bioradar",2)
end
function snp_bioradar_parts0()
	if snp_bioradar_parts0_have_all() then
		give_info("snp_bioradar_parts0")
		return true
	end
	return false
end

function snp_bioradar_parts_done_have_all()
	return
		snp_bioradar_parts_have_all() and
		snp_bioradar_parts0_have_all() and
		has("snpbiopart",4) and
		has("snp_biopart5",1) and
		has("snp_biopart6",1) and
		has("snp_biopart7",1)
end
function snp_bioradar_parts_done()
	if not has_info("snp_bioradar_parts_done") then
		lost("part_bear_paw",1)
		lost("part_frog_leg",1)
		lost("part_parazit",1)
		lost("part_biomassa_growth",1)
		lost("part_stinger_sting",1)
		lost("part_winger_liver",1)
		lost("part_nosales_tongue",1)
		lost("part_fang_wolf",1)
		lost("part_spider_gland",1)
		lost("part_rotan_heart",1)
		lost("part_plague_hand",1)
		lost("part_carlic_hand",1)
		lost("part_vypolzen_hrebet",1)
		lost("part_raptor_kogot",1)
		lost("part_zanoza_leg",1)
		lost("part_flesh_eye",1)
		lost("part_boar_leg",1)
		lost("part_dog_tail",1)
		lost("part_psevdodog_tail",1)
		lost("part_krovosos_jaw",1)
		lost("part_burer_hand",1)
		lost("part_zombie_hand",1)
		lost("part_snork_leg",1)
		lost("part_face_tushkano",1)
		lost("part_hand_kontroler",1)
		lost("part_poltergeist_glas",1)
		lost("part_psevdogigant_hand",1)
		lost("part_tail_cat",1)
		lost("part_chimera_kogot",1)
		lost("part_fracture_hand",1)
		lost("part_deathclaw_antler",1)
		lost("part_digitis_biblio",1)
		lost("part_tarakan",1)
		lost("part_tarakan_strong",1)
		lost("part_zombie_teeth",1)
		lost("part_spleen_rat",1)
		lost("part_gnomius",1)
		lost("bioradar",2)
		lost("snpbiopart",4)
		lost("snp_biopart5",1)
		lost("snp_biopart6",1)
		lost("snp_biopart7",1)
		give_info("snp_bioradar_parts_done")
	end
end

-- Алмазные черепа
function snp_almaz_have()
	return
		has("snp_skull",13)
end
function snp_almaz_dospehi_have()
	return
		has("snp_suriken",1) and
		has("snp_suriken2",1) and
		has("snp_shield",1) and
		has("wpn_sword",1)
end

-- Вступление в монолит по сюжету при входе в Лабиринт
local almaz_joined
function join_monolith()
	if not almaz_joined then --do not need every call to engine on every check  :))) only on first function call
		almaz_joined=get_value("almaz_joined",false) 
	end
	if almaz_joined then --do not need check on every item taked...
		return
	end
	if  has_info("snp_kotobegemot3_done") and --if not joined - check if allowed join
		not has_info("snp_almaz_done") and
		not has("amulet") and
		level.name()=="av_peshera" and
		snp_almaz_dospehi_have()
	then --if allowed join
		local config = ini_file([[creatures\game_relations.ltx]])
		local communities_relations=container:get("before_almaz_joined", {})
		config:iterate_lines("communities_relations", --store all relation values to all communities
			function(result, community, value)
				if result then
					communities_relations[community]=relation_registry.community_goodwill(community, db.actor:id())
				end
			end)
		db.actor:set_character_community("monolith", 0, 0)
		set_value("almaz_joined",true) --set flag on already joined
	end
end

-- колбы
function make_four_kolba_have()
	if has_info("snp_proper703_done") and
		has("kolba_krasn_poln",4) then

		give_info("snp_make_four_kolba_have")
		return true
	end
	return false
end
function make_four_kolba_done()
	lost("kolba_krasn_poln",4)
end

-- части Звезды Пророка
function zvezda_parts1_have()
	if has_info("snp_proper706_done") and
		has("af_gelion",1) and
		has("af_electro_crystal_thorn",1) and
		has("af_spiral",1)	then

			give_info("snp_zvezda_parts1_have")
		return true
	end
	return false
end

function zvezda_parts1_done()
	lost("af_gelion",1)
	lost("af_electro_crystal_thorn",1)
	lost("af_spiral",1)
end
function zvezda_parts2_have()
	if has_info("snp_proper708_done") and
		has("af_fobos",1) and
		has("af_gold_mincer_meat",7) and
		has("af_part_monolit",1) then

			give_info("snp_zvezda_parts2_have")
		return true
	end
	return false
end
function zvezda_parts2_done()
	lost("af_fobos",1)
	lost("af_gold_mincer_meat",7)
	lost("af_part_monolit",1)

	local obj = create("ludmila_zaton",xyz(130.02600097656,-7.3398327827454,177.09588623047),1189961,3686)
	ai:assign_story_id(obj.id,19916)
end
function zvezda_parts3_have()
	if has_info("snp_proper7010_done") and
		has("af_encelad",1) and
		has("af_life_heart",5) and
		has("af_buliz",30) and
		has("art_acumm",50) then

			give_info("snp_zvezda_parts3_have")
		return true
	end
	return false
end
function zvezda_parts3_done()
	lost("af_encelad",1)
	lost("af_life_heart",5)
	lost("af_buliz",30)
	lost("art_acumm",50)
	set_value("snp_make_zp", game.minutes()+10)
end
function zp_ready()
	return has_info("snp_proper7011_done") and not has_info("snp_proper7012_done") and game.minutes() > get_value("snp_make_zp", 0)
end

-- Камень Удачи
function kamen_udachy_have()
	return has_info("snp_fenrir14_done") and has("af_kamen_udachy2")
end
function kamen_udachy_done()
	lost("af_kamen_udachy2",1)
end

-- Эмбрион вульфа
function embrion_vogak_have()
	return has_info("snp_wolffrend2_done") and has("mutant_wolf_cocoon")
end
function embrion_vogak_done()
	lost("mutant_wolf_cocoon",1)
end

-- Завершение Звезды Пророка
function zvezda_proroka_done()
	local obj
	local timeout = 3
	sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("sms_fenrir_zvezda_proroka_done_0")..user_name()..translate("sms_fenrir_zvezda_proroka_done_1"), timeout, "fenrir", 41000, nil, [[sms\fenrir\zvezda_proroka_done]])
	timeout = timeout+45
	sms("%c[sender]"..translate("name_proper_semidesyatii")..":\\n%c[sms_red]"..translate("sms_proper70_zvezda_proroka_done_0"), timeout, "proper70", 20000, nil, [[sms\proper70\zvezda_proroka_done]])
	timeout = timeout+7
	sms("%c[sender]"..translate("name_obitel_zla")..":\\n%c[sms_red]"..translate("sms_resident_evil_zvezda_proroka_done_1_0"), timeout, "resident_evil", 20000, nil, [[sms\resident_evil\zvezda_proroka_done_1]])
	timeout = timeout+10
	sms("%c[sender]"..translate("name_strelok")..":\\n%c[sms_red]"..translate("sms_strelok_zvezda_proroka_done_0"), timeout, "strelok", 20000, nil, [[sms\strelok\zvezda_proroka_done]])
	timeout = timeout+12
	sms("%c[sender]"..translate("name_obitel_zla")..":\\n%c[sms_red]"..translate("sms_resident_evil_zvezda_proroka_done_2_0"), timeout, "resident_evil", 40000, nil, [[sms\resident_evil\zvezda_proroka_done_2]])
	create_restrictor(xyz(-192.9940032959,0.75845563411713,-274.79794311523),389153,3710,2,"snp_spawn.n_inventory_box_jupiter11_1")
	-- Возвращаем Вульфа на Скадовск/нет, не возвращаем
--	create("wolffrend_zaton",xyz(137.85824584961,-7.3402981758118,176.09548950195),1202652,3686)
--	obj = create("wolffrend_talk_zaton",xyz(137.19732666016,-7.3405375480652,176.83992004395),1201535,3686)
--	ai:assign_story_id(obj.id,19925)
	disable_info("snp_wolffrend_skadovsk_done")
	give_info("zvezda_proroka_done")
end

-- Слиток на кольца
function snp_slitok_have()
	return has_info("snp_anna4_done") and has("bullion_gild")
end
function snp_slitok_done()
	lost("bullion_gild",1)
	set_value("snp_make_rings", game.minutes()+120)
end
function rings_ready()
	return has_info("snp_docent3_done") and not has_info("snp_rings_have") and game.minutes() > get_value("snp_make_rings", 0)
end

-- Видеоархив
function video_9_have()
	return has_info("snp_proper7014_done") and has("snp_video_arhiv",9)
end
function video_10_have()
	return has_info("snpt_x161_done") and has("snp_video_arhiv",10)
end
function video_10_done()
	lost("snp_video_arhiv",10)
end

-- БТР на вышках на свалке
function btr_garbage1_done(num)
	if has_info("snpt_garbage1_fail") then return end

	give_info("snp_tmp"..tostring(num))

	if  has_info("snp_tmp1") and has_info("snp_tmp2") and has_info("snp_tmp3") and has_info("snp_tmp4") then
		give_info("snp_tmp_reset")
		disable_info("snp_tmp_reset")
		disable_info("no_teleport_near_heli_btr")

		if not has_info("snpt_garbage1_have1") then
			give_info("snpt_garbage1_have1")
			sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("sms_fenrir_snpt_garbage1_have1_0"), 2, "fenrir", 7000, nil, [[sms\fenrir\snpt_garbage1_have1]])
		else
			give_info("snpt_garbage1_have2")
			sms("%c[sender]"..translate("name_fenrir")..":\\n%c[sms_red]"..translate("sms_fenrir_snpt_garbage1_have2_0"), 2, "fenrir", 10000, nil, [[sms\fenrir\snpt_garbage1_have2]])
			-- убираем Фенрира и Вульфа со Скадовска
			release(object_by_section_offline("fenrir_zaton"))
--			release(object_by_section_offline("wolffrend_zaton"))
--			release(object_by_section_offline("wolffrend_talk_zaton"))
		end
	end
end
function btr_garbage1_fail()
	if has_info("no_teleport_near_heli_btr") then
		disable_info("no_teleport_near_heli_btr")
		give_info("snp_tmp_reset")
		disable_info("snp_tmp_reset")
		give_info("snpt_garbage1_fail")
	end
end

-- x-16-Янтарь
function x16_1()
	local obj = create("n_inventory_box_yantar1",xyz(-25.592491149902,-19.088596343994,-23.444808959961),29512,1492)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
	create_restrictor(xyz(-175.38716125488,-19.114255905151,-42.668083190918),697,1498,2,"snp.x16_2")
end
function x16_2()
	voice([[snp\zat_b42_controller_warning_1]]):play(db.actor, 0, sound_object.s2d)
	create_restrictor(xyz(-55.783111572266,-18.853202819824,-67.143280029297),19582,1456,2,"snp.x16_3")
end
function x16_3()
	voice([[snp\zat_b42_controller_warning_2]]):play(db.actor, 0, sound_object.s2d)
	create_restrictor(xyz(-57.88639831543,-17.625261306763,-134.35594177246),18645,1491,1,"snp.x16_4")
end
function x16_4()
	voice([[script_sound\help\soldier\soldier_help_1]]):play(db.actor, 0, sound_object.s2d)
	create_restrictor(xyz(-26.142684936523,-18.399806976318,-82.548286437988),29275,1492,3,"snp.x16_5")
end
function x16_5()
	voice([[sms\strelok\x16_5]]):play(db.actor, 0, sound_object.s2d)
	voice([[ambient\special\marsh_generator]]):play(db.actor, 3, sound_object.s2d)
	create_teleport("snp_x16_tp1",xyz(-145.96894836426,-18.254137039185,-60.513942718506),1275,1457)
end
function x16_6()
	release_teleport("snp_x16_tp1")
	create_restrictor(xyz(-25.592491149902,-19.088596343994,-23.444808959961),29512,1492,10,"snp.x16_7")
end
function x16_7()
	voice([[script_sound\threat\stop\soldier\soldier_stop_1]]):play(db.actor, 0, sound_object.s2d)
	create_teleport("snp_x16_tp2",xyz(-25.592491149902,-19.088596343994,-23.444808959961),29512,1492)
end
function x16_8()
	release_teleport("snp_x16_tp2")
	voice([[meceniy\atmopheric\smex]]):play(db.actor, 2, sound_object.s2d)
	create_restrictor(xyz(-241.3547668457,-18.260984420776,-44.497436523438),158,1458,2,"snp.x16_9")
end
function x16_9()
	voice([[sms\strelok\x16_9]]):play(db.actor, 0, sound_object.s2d)
	create_restrictor(xyz(-70.197463989258,-17.122535705566,-97.257064819336),14118,1496,2,"snp.x16_10")
end
function x16_10()
	voice([[sms\strelok\x16_10]]):play(db.actor, 0, sound_object.s2d)
	create_restrictor(xyz(-26.588277816772,-17.868045806885,-97.226081848145),29255,1492,1.5,"snp.x16_11")
end
function x16_11()
	voice([[ambient\zhar]]):play(db.actor, 0, sound_object.s2d)
	create_teleport("snp_x16_tp3",xyz(-87.297988891602,-18.268096923828,-96.16625213623),9080,1496)
end
function x16_12()
	release_teleport("snp_x16_tp3")
	voice([[script_replics\comandir_1\normal\comandir_to_soldier_4]]):play(db.actor, 2, sound_object.s2d)
	create_teleport("snp_x16_tp4",xyz(-25.592491149902,-19.088596343994,-23.444808959961),29512,1492)
end
function x16_13()
	release_teleport("snp_x16_tp4")
	voice([[sms\strelok\x16_13]]):play(db.actor, 2, sound_object.s2d)
	create_restrictor(xyz(-147.08406066895,-19.088594436646,-76.49592590332),1077,1457,2,"snp.x16_14")
end
function x16_14()
	voice([[snp\tube_breath]]):play(db.actor, 0, sound_object.s2d)
	create_teleport("snp_x16_tp5",xyz(-144.91662597656,-18.236173629761,-77.360313415527),1255,1457)
end
function x16_15()
	release_teleport("snp_x16_tp5")
	create_restrictor(xyz(-25.592491149902,-19.088596343994,-23.444808959961),29512,1492,8,"snp.x16_16")
end
function x16_16()
	voice([[snp\podoidi_blije]]):play(db.actor, 0, sound_object.s2d)
end
function x16_17()
	voice([[script_sound\reactions\dead_enemy\soldier\soldier_dead_enemy_1]]):play(db.actor, 2, sound_object.s2d)
	timer("run",6,"snp.x16_18()")
end
function x16_18()
	create_teleport("snp_x16_tp6", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id())
end
function x16_19()
	release_teleport("snp_x16_tp6")
end

-- Эмбрионы
-- выдача рецепта по эмбрионам
function emb_found_receipt()
	sms("emb_found_receipt_0", nil, nil, 20000)
end

function emb_zahar1_done()
	local obj = create("n_inventory_box_vp2",xyz(-177.54525756836,9.833262214661,-344.69392700195),38158,3753)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

-- Жена Сахарова
function gena_start()
	local timeout = 2
	sms("%c[sender]"..translate("name_elza")..":\\n%c[sms_red]"..translate("gena_start_0_0"), timeout, "elsa", 6000, nil, [[sms\elza\gena_start_1]])
	timeout = timeout+10
	sms("%c[sender]"..translate("name_strelok")..":\\n%c[sms_red]"..translate("sms_strelok_gena_start_2_0"), timeout, "strelok", 20000, nil, [[sms\strelok\gena_start_2]])
	timeout = timeout+13
	sms("%c[sender]"..translate("name_saharov")..":\\n%c[sms_red]"..translate("sms_saharov_gena_start_3_0"), timeout, "saharov", 20000, nil, [[sms\saharov\gena_start_3]])
	give_info("gena_sakharov1_start")
end

function gena_bum1()
	local box=create("n_inventory_box_bum1",xyz(-4.2317895889282,-29.182376098633,11.760759353638),1804,2481)
	xr_box.del_flag(box)
end

function gena_sakharov1_done()
	local obj = create("n_inventory_box_as2",xyz(-244.18141174316,-2.3535263061523,293.23202514648),88245,1797)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end
function gena_sakharov2_done()
	create_teleport("gena_tp2", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id())
end

function gena_oso1_start()
	all_spawn_fix.release_allspawn_object("mon_stalker") 
	local restrictions_bum = {
		["mon_monolith_proektor_restr"] = true,
		["mon_guard_offline_restr"] = true
	}
	remove_all_restrictions(restrictions_bum)
	local obj = create("gena_oso",xyz(17.6547775268555,-41.4733619689941,25.9469795227051),2945,2512)
	ai:assign_story_id(obj.id,19932)
end

function gena_oso1_done()
	release_teleport("gena_tp1")
	lost_item("gena_note5")
	local obj = create("elsa_yantar",xyz(25.738025665283,-11.717874526978,-273.18176269531),51613,1480)
	ai:assign_story_id(obj.id,19931)
	timer("teleport_jumpto", 0.2, "spawn_level_changer.jumpTo(\"gena_exit5\")")
end

function gena_finish()
	release_teleport("gena_tp2")
	release(object_by_section_offline("gena_oso"))
	create(ai:spawn_id(1307))
end

function otpuskaem_igroka()
	disable_info("actor_cant_move")
end

----------------- Разные утилиты -------------------

-- установка object_flags непися при скриптовом спавне
function set_stalker_oflags(obj,oflags)
	netpacket:modify(obj, "object_flags", oflags)
end

-- поиск онлайнового объекта скриптового спавна по секции
function object_by_section(section)
	local obj
	for k,v in pairs(db.storage) do
		obj = level_object(k)
		if obj:section() == section then
			return obj
		end
	end
	return nil
end

-- поиск онлайнового неприбинденного объекта (отсутствует в db.storage) скриптового спавна по секции
function object_by_section_nobinder(section)
	local obj
	for i=1,65534 do
		obj=level_object(i)
		if obj and obj:section() == section then
			return obj
		end
	end
	return nil
end

-- поиск оффлайнового объекта скриптового спавна по секции - server_object() тут не работает
function object_by_section_offline(section)
	local obj
	for i=1,65534 do
		obj = server_object(i)
		if obj and obj:section_name() == section then
			return obj
		end
	end
	return nil
end

-- удаление всех онлайновых обьектов по секции
function release_all_online(section)
	local obj
	for k,v in pairs(db.storage) do
		obj = level_object(k)
		if obj:section() == section then
			release(server_object(obj:id()))
		end
	end
end

-- Спавн тайника/предмета с установкой рестриктора
-- Описание: рестриктор спавнится по координатам объекта. Параметры задаются в конфиге объекта:
-- r_radius   = радиус рестриктора. по умолчанию = 5
-- r_function = функция, которую вызвать при входе в рестриктор, без кавычек, скобок и параметров
-- Возвращает ссылку на объект
function create_item_and_restrictor(section,pos,lv,gv)
	-- спавним объект
	local obj = create(section,pos,lv,gv)

	local radius = rx_utils.read_from_ini(nil, section, "r_radius", nil, nil)
	local func = rx_utils.read_from_ini(nil, section, "r_function", nil, 1)

	if func then
		if not radius then radius = 5 end
		-- функция есть - спавним рестриктор
		create_restrictor(pos,lv,gv,radius,func)
	end

	return obj
end

-- Спавн типичного рестриктора на вход. func = вызываемая при входе функция.
function create_restrictor(pos,lv,gv,radius,func)
	local se_obj = create("space_restrictor",pos,lv,gv)
	local custom = "[logic]\nactive = sr_idle\n[sr_idle]\non_actor_inside = nil %="..func.."%"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(radius)
	return se_obj
end

-- Спавн типичного рестриктора на выход. func = вызываемая при выходе функция.
function create_restrictor_out(pos,lv,gv,radius,func)
	local se_obj = create("space_restrictor",pos,lv,gv)
	local custom = "[logic]\nactive = sr_idle\n[sr_idle]\non_actor_outside = nil %="..func.."%"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(radius)
	return se_obj
end

-- Спавн типичного рестриктора на вход со сработкой в определенное время.
function create_restrictor_timer(pos,lv,gv,radius,time,func)
	local se_obj = create("space_restrictor",pos,lv,gv)
	local custom = "[logic]\nactive = sr_idle\n[sr_idle]\non_actor_inside = {=in_timer("..time..")} nil %="..func.."%"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(radius)	
	return se_obj
end

-- Спавн типичного рестриктора на вход со сработкой в определенное время для сюжета оп Теням.
function create_restrictor_timer_pftp(pos,lv,gv,radius,time,func)
	local se_obj = create("space_restrictor",pos,lv,gv)
	local custom = "[logic]\nactive = sr_idle\n[sr_idle]\non_actor_inside = {=in_timer_pftp("..time..")} nil %="..func.."%"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(radius)	
	return se_obj
end

-- Спавн зоны на основе рестриктора. При входе в зону выдается поршень info, при выходе - снимается. Работать начинает при входе ГГ в зону
-- off - поршень, при выдаче которого зона отключается.
function create_zone(pos,lv,gv,radius,info,off)
	local se_obj = create("space_restrictor",pos,lv,gv)
	local custom =
	"[logic]\n"..
	"active = sr_idle@in\n"..

	"[sr_idle@in]\n"..
	"on_actor_inside = sr_idle@out %+"..info.."%\n"..
	"on_info = {+"..off.."} nil %-"..info.."%\n"..

	"[sr_idle@out]\n"..
	"on_actor_outside = sr_idle@in %-"..info.."%\n"..
	"on_info = {+"..off.."} nil %-"..info.."%\n"
	se_obj:set_ini_lua_string(custom)
	se_obj:add_shape(radius)	
	return se_obj
end

-- Убираем ПЫСсовские рестрикторы на территории, чтобы не вылетало по путям. На входе список рестрикторов
function remove_all_restrictions(restrictions)
	local obj
	for id=1, 65534 do
		obj = level_object(id)
		if obj and restrictions[obj:name()] then
--			log("name:"..obj:name())
			release(server_object(obj:id()))
		end
	end
end

-- Спавн трупа
function create_trup(section,pos,lv,gv,sid)
	local obj = create(section,pos,lv,gv)
	netpacket:modify(obj, "story_id", sid or -1, "health", 0, "upd.health", 0)
	return obj
end

-- Спавн раненого
function create_wounded(section,pos,lv,gv,sid)
	local obj = create(section,pos,lv,gv)
	netpacket:modify(obj, "story_id", sid or -1, "health", 0.1, "upd.health", 0.05)
	return obj
end

function invul_on()
	db.actor:invulnerable(true)
end
function invul_off()
	db.actor:invulnerable(false)
end

function move_on()
	local obj = db.actor:object("ballast")
	if obj then
		release(server_object(obj:id()))
	end
end
function move_off()
	amk.spawn_item_in_inv("ballast", db.actor)
end

-- Пьем водку
function drink_vodka()
	create("vodka",xyz(0,0,0),0,0,0)
	timer("run",0.2,"snp.drink_vodka_chunk()")
end
function drink_vodka_chunk()
	db.actor:eat(db.actor:object("vodka"))
end

-- Бъем морду
function do_punch()
	local active_slot = db.actor:active_slot()
	if active_slot == 1 or active_slot == 2	then
		local active_item = db.actor:active_item()
		if active_item then
			db.actor:drop_item(active_item)
		end
	end

        db.actor.health = -0.20
	set_inactivate_input_time(20)
	say([[affects\hit_fist]])
	level.add_cam_effector("camera_effects\\fusker.anm", 999, false, "")
end

-- подсчет количества вертолетов в онлайне для бойни на Юпитере
function count_heli()
	local count = 0
	for k,v in pairs(db.heli) do
		if v:section() == "snp_helicopter" then
			count = count+1
		end
	end
	return count
end

-- подсчет количества бтр в онлайне
function count_btr()
	local count = 0
	for k,v in pairs(db.btr) do
		count = count+1
	end
	return count
end

function net_spawn()
	start_sound()
	emb.start_sound()

	-- спавн бункера
	if has_info("snp_resident_evil8_done") and not has_info("spawn_bunker_jupiter") and level.name()=="jupiter" then
		spawn_bunker_jupiter()
		give_info("spawn_bunker_jupiter")
	end
	-- финальное удаление Снегиря
	if has_info("fli_snegir1_done") and not has_info("fli_snegir_remove") and level.name()~="l01_escape" then
		release(object_by_section_offline("maria_kordon"))
		release(object_by_section_offline("snegir_kordon"))
		give_info("fli_snegir_remove")
	end
	-- перемещение Котобегемота и Ариадны на Скадовск
	if has_info("snp_docent2_done") and not has_info("ariadna_kot_to_skadovsk") and level.name()~="l05_bar" then
		release(object_by_section_offline("kotobegemot_bar"))
		release(object_by_section_offline("ariadna_bar"))
		local obj = create("kotobegemot_zaton",xyz(132.33285522461,-7.3398036956787,177.00312805176),1193473,3686)
		ai:assign_story_id(obj.id,19920)
		obj = create("ariadna_zaton",xyz(133.59469604492,-7.3404812812805,177.0399017334),1195789,3686)
		ai:assign_story_id(obj.id,19921)
		give_info("ariadna_kot_to_skadovsk")

	end
	-- перемещение бункера на Скадовск
	if has_info("snp_proper7013_done") and not has_info("bunker_to_skadovsk") and level.name()~="jupiter" then
		release(object_by_section_offline("fenrir_jupiter"))
		release(object_by_section_offline("proper70_jupiter"))
		local obj = create("fenrir_zaton",xyz(138.73059082031,-7.3394303321838,178.58042907715),1203766,3686)
		ai:assign_story_id(obj.id,19902)
		obj = create("resident_evil_zaton",xyz(125.20777893066,-7.3201112747192,181.31158447266),1181686,3686)
		ai:assign_story_id(obj.id,19903)
		obj = create("proper70_zaton",xyz(126.26544952393,-7.3198008537292,176.6022644043),1182876,3686)
		--ai:assign_story_id(obj.id,19922)
		ai:assign_story_id(obj.id,19907)
		obj = create("anna_zaton2",xyz(138.39352416992,-7.3401217460632,179.81733703613),1203770,3686)
		ai:assign_story_id(obj.id,19923)
		give_info("bunker_to_skadovsk")
                snp.delete_cheytac_m1()
	end
	-- удаление Вожака с плато
	if has_info("snp_wolffrend3_done") and not has_info("snp_vogak_remove") and level.name()~="zaton" then
		release(object_by_section_offline("wolffrend_zaton2"))
		release(object_by_section_offline("wolffrend_talk_zaton2"))
		give_info("snp_vogak_remove")
	end
end

-- апдейт раз в полсекунды
function update()
	-- отсечка на Юпитере
	if  has_info("no_teleport_near_heli_btr") and	has_info("snp_boroda_start_done") and not has_info("snp_parad_start") and not has_info("snpt_jupiter5_fail") then

		if db.actor:position().y < 40 then
			give_info("snpt_jupiter5_fail")
			sms("%c[sender]"..translate("name_boroda")..":\\n%c[sms_red]"..translate("sms_boroda_snpt_jupiter5_fail_0"), nil, "boroda", 20000, nil, [[sms\boroda\snpt_jupiter5_fail]])

		elseif has_info("snpt_jupiter5_have1") and not has_info("snpt_jupiter5_have2") and count_heli() == 0 then
			snp_spawn.create_snpt_jupiter5_restr3()
			give_info("snpt_jupiter5_have2")

		end
	end
end

-- запуск сюжетных звуков
function start_sound()
	if     has_info("snp_monolith1_done") and not has_info("snp_almaz1") and level.name()=="av_peshera" then
		voice([[snp\heartbeat100]]):play_at_pos(db.actor, xyz(-108.429,40.053,479.112), 0, sound_object.s3d+sound_object.looped)
	elseif has_info("snp_almaz1") and not has_info("snp_almaz2") and level.name()=="av_peshera" then
		voice([[snp\heartbeat100]]):play_at_pos(db.actor, xyz(174.084,55.118,386.011), 0, sound_object.s3d+sound_object.looped)
    	elseif has_info("metall_detector_have") and not has_info("taynik_gila_have") and level.name()=="puzir" then
        	voice([[zwuk\metall_detector]]):play_at_pos(db.actor, xyz(203.425,5.21,-224.669), 0, sound_object.s3d+sound_object.looped)
	end
end

function play_snd_rnd_ratchant()
	voice([[ambient\random\rnd_ratchant]]):play_no_feedback(db.actor, sound_object.s2d, 1, vector(), 1.0)
end

-- для диалогов
function bubulyka_answer1()
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	db.actor:give_talk_message(translate("bubulyka_answer1_0")..", "..user_name()..translate("bubulyka_answer1_1"), task_texture, task_rect, "simple_answer_item")
        say([[characters_voice\human_01\stalker\reactions\story\laughter_10]])
end

function delete_cheytac_m1()
	find_and_release("wpn_cheytac_m1")
end

function box_cp10_shadow_fenrir()
local obj = create("n_inventory_box_cp10_shadow",xyz(-177.47,15.62,52.40),158503,3599)
map_spot(obj.id, "treasure", "fenrir_treasure_dc")
end

function akims_spawn_trups()
	create_trup("esc_akims_trups",xyz(30.27,15.93,665.31),310620,207)
	create_trup("esc_akims_trups2",xyz(29.58,15.75,660.86),309757,206)
	create_trup("esc_akims_trups",xyz(34.01,15.75,661.45),315651,207)
	create_trup("esc_akims_trups2",xyz(23.07,18.01,664.28),306449,207)
	create_trup("esc_akims_trups",xyz(22.97,20.35,659.22),307258,206)
end

function dam_mono_spawn_trups()
	create_trup("dam_mono_trup",xyz(-7.79,-0.00,-24.45),36954,5773)
	create_trup("dam_mono_trup",xyz(0.25,-0.00,-9.64),39468,5773)
	create_trup("dam_mono_trup",xyz(10.68,0.37,-15.09),42889,5778)
	create_trup("dam_mono_trup",xyz(42.87,-0.00,-33.97),59033,5789)
	create_trup("dam_mono_trup",xyz(30.36,1.59,-8.09),52012,5790)
end

function dsh_spawn_trups()
	create_trup("ds_bandit_respawn_2",xyz(-329.82,-3.38,354.93),61091,4107)
	create_trup("cit_bandit_respawn_1",xyz(-318.20,-3.01,337.14),68976,3851)
	create_trup("cit_bandit_respawn_2",xyz(-302.07,-1.37,360.96),85817,3851)
	create_trup("agr_bandit_respawn_1",xyz(-331.58,-5.84,373.99),59587,4107)
	create_trup("gar_bandit_respawn_1",xyz(-292.18,-2.15,349.77),89534,3851)
end