function psieffect_on()
	level.add_pp_effector("yantar_underground_psi.ppe", 2007, true)
end

function psieffect_off()
	level.add_pp_effector("yantar_underground_psi.ppe", 2007, false)
end

function relocate_lebedev_pda(gg, npc)
	dialogs.relocate_item_section(npc, "sta_lebedev_pda", "out")
end

function relocate_mil_scanner_2(gg, npc)
	dialogs.relocate_item_section(npc, "mil_scanner_2", "out")
end


function spawn_nov()
	local obj=alife():create("mar_nebo_balon",vector():set(-143.119,1.336,-278.883),74288,3377)
	local params=amk.read_stalker_params(obj)
	params.custom="[logic]\ncfg = scripts\\marsh\\nov_1.ltx"
	amk.write_stalker_params(params,obj)
	local obj=alife():create("mar_nebo",vector():set(-144.082,1.336,-277.854),73573,3377)
	local params=amk.read_stalker_params(obj)
	params.custom="[logic]\ncfg = scripts\\marsh\\nov_2.ltx"
	amk.write_stalker_params(params,obj)
	local obj=alife():create("mar_novice_2",vector():set(-139.132,1.336,-273.451),76158,3377)
	local params=amk.read_stalker_params(obj)
	params.custom="[logic]\ncfg = scripts\\marsh\\nov_3.ltx"
	amk.write_stalker_params(params,obj)
	local obj=alife():create("mar_novice_4",vector():set(-145.820,1.336,-271.957),72514,3377)
	local params=amk.read_stalker_params(obj)
	params.custom="[logic]\ncfg = scripts\\marsh\\nov_4.ltx"
	amk.write_stalker_params(params,obj)
end

 function spawn_marsh_killer()
	local obj = alife():create("av_killer",vector():set(249.966,0.274,-161.132),294869,3510)
	local params = amk.read_stalker_params(obj)
	params.custom="[logic]\ncfg = scripts\\marsh\\marsh_killer.ltx"
	params.sid = 15045
	amk.write_stalker_params(params,obj)
end	

function shram_delete()
	local sim = alife()
	local se_obj = sim:story_object(15045) 
	if se_obj then 
		sim:release(se_obj, true)
	end
end

function gg_kill()
	if not has_alife_info("marsh_kontr_dialog_end") then
	dialogs_marsh.gg_death()
	end
end

function gg_death()
	level.add_cam_effector("camera_effects\\prison_1.anm", 25, false, "") 
	level.add_pp_effector("fire_hit.ppe", 2011, false)
	level.add_cam_effector("camera_effects\\fusker.anm", 999, false, "")     
	local snd_obj = xr_sound.get_safe_sound_object([[actor\pain_3]]) 
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	level.add_cam_effector("camera_effects\\hit_back_left.anm", 26, false, "")	
	local gg = db.actor 
	gg:kill(gg) 
end	

function teleport_kolokol()
	db.actor:give_info_portion("zombi")
	level.add_pp_effector ("teleport.ppe", 25006, false)
	db.actor:set_actor_position(vector():set(289.747,0.142,-161.392))
	dialogs_marsh.dopa()	
	spawn_restrictor.create_hram_restr_2()
	spawn_restrictor.create_hram_restr_3()
	spawn_restrictor.create_hram_restr_4()
	spawn_restrictor.create_hram_restr_5()	
end

function teleport_kolokol_2()
	dialogs_marsh.delete_delete()
	dialogs_marsh.delete_3()
	dialogs_marsh.gg_kill()
	level.add_pp_effector("total_recall.ppe", 2008, false) 
	local snd_obj = xr_sound.get_safe_sound_object([[new\start_affect]]) 
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0) 
	level.add_cam_effector("camera_effects\\hit_back_left.anm", 26, false, "")
	local snd_obj = xr_sound.get_safe_sound_object([[anomaly\teleport_work_1]])
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	level.add_cam_effector("camera_effects\\prison_1.anm", 25, false, "") 
	level.add_pp_effector("yantar_underground_psi.ppe", 2007, false)
	level.add_pp_effector ("teleport.ppe", 25006, false)
	db.actor:set_actor_position(vector():set(289.747,0.142,-161.392))
	db.actor:give_info_portion("kontroler")
end
	

function teleport_prohod_1()
	level.add_pp_effector ("teleport.ppe", 25006, false)
	db.actor:set_actor_position(vector():set(289.747,0.142,-161.392))
	dialogs_marsh.dopa()
	db.actor:disable_info_portion("teleport_hram_1")
	db.actor:disable_info_portion("teleport_hram_2")
end 

function teleport_prohod_2()
	level.add_pp_effector ("teleport.ppe", 25006, false)
	db.actor:set_actor_position(vector():set(289.747,0.142,-161.392))
	dialogs_marsh.dopa()
	db.actor:disable_info_portion("teleport_hram_3")
end 

function teleport_prohod_3()
	level.add_pp_effector ("teleport.ppe", 15039, false)
	db.actor:set_actor_position(vector():set(289.747,0.142,-161.392))
	dialogs_marsh.dopa()
	db.actor:disable_info_portion("teleport_hram_4")
end

function teleport_prohod_4()
	level.add_pp_effector ("teleport.ppe", 25006, false)
	db.actor:set_actor_position(vector():set(289.747,0.142,-161.392))
	dialogs_marsh.dopa()
	db.actor:disable_info_portion("teleport_hram_5")
end


function dopa()
	local snd_obj = xr_sound.get_safe_sound_object([[anomaly\teleport_work_1]])
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
	level.add_cam_effector("camera_effects\\prison_1.anm", 25, false, "") 
	level.add_pp_effector("yantar_underground_psi.ppe", 2007, false) 
	level.add_pp_effector("total_recall.ppe", 2008, false) 
	local snd_obj = xr_sound.get_safe_sound_object([[new\start_affect]]) 
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0) 
	level.add_cam_effector("camera_effects\\hit_back_left.anm", 26, false, "")
end
 

function zvon()
	if has_alife_info("dialog_sheph_3_end") then
	dialogs_marsh.zvon_kolokola_on()
	dialogs_marsh.zvon_kolokola_off()
		if has_alife_info("psieffect") then
		dialogs_marsh.psieffect_on()
			if not has_alife_info("psieffect") then
			dialogs_marsh.psieffect_off()
			end
		end
	end
end	

function zvon_kolokola_on()
	local htime = level.get_time_hours()
	if htime<=0 then
	db.actor:give_info_portion("nabat_on")
	end
end

function zvon_kolokola_off()
	local rtime = level.get_time_hours()
	if rtime >=5 then
	db.actor:disable_info_portion("nabat_on")	
	end
end

function psieffector()
	if not has_alife_info("psieffect")then
	dialogs_marsh.psieffect_on()
	end
end


function lebedev_pda_quest_have()
	if db.actor:object("sta_lebedev_pda") then
		return true
	end
	return false
end

function mar_repair_kit_for_skorp_quest_have()
	if db.actor:object("instrumrem") then
		return true
	end
	return false
end

function spawn_machete()
	local MarBox_1 = alife():object("mar_smart_terrain_3_7_box")
	for i=1, 3 do
		alife():create("ammo_7.62x39_ap",MarBox_1.position, MarBox_1.m_level_vertex_id, MarBox_1.m_game_vertex_id, MarBox_1.id)
	end
		alife():create("wpn_machette",MarBox_1.position, MarBox_1.m_level_vertex_id, MarBox_1.m_game_vertex_id, MarBox_1.id)
end

function machete_quest_have()
	if db.actor:object("wpn_machette") then
		return true
	end
	return false
end

function relocate_machette_1(gg, npc)
	dialogs.relocate_item_section(npc, "wpn_machette", "out")
end

function relocate_machette_2(npc, gg)
	dialogs.relocate_item_section(gg, "wpn_machette", "in")
end

function mar_repair_kit_for_skorp_quest_reward(npc, gg)
	dialogs.relocate_item_section(npc, "instrumrem", "out")
	dialogs.relocate_item_section(npc, "wpn_toz34_ba", "in")
	dialogs.relocate_money(gg, 1000, "in")
end

function mar_guide_teleport_1(gg, npc)
	lwc_guide.start_guide_camp(patrol("marsh_walk_1"):point(0))
end

function mar_guide_teleport_2(gg, npc)
	lwc_guide.start_guide_camp(patrol("marsh_walk_2"):point(0))
end

function start_timer_sanchast()
    amk.g_start_timer("sanchast",0,0,7)
end

function start_timer_sms_marsh()
    amk.g_start_timer("sms_marsh",0,0,3)
end

function sms_marsh(first_speaker,second_speaker) 
	news_manager.send_tip(db.actor, "%c[255,255,128,128]Каланча:\n%c[default] Кайдановский, зайдите, пожалуйста, ко мне.", nil, nil, 30000) 
end

function relocate_cs_outfit(npc, gg)
	dialogs.relocate_item_section(gg, "sky_heavy_bc", "in")
end

function relocate_vss_tk1(npc, gg)
	dialogs.relocate_item_section(gg, "wpn_vss_tk1", "in")
end

function relocate_patrony(npc, gg)
	dialogs.relocate_item_section(gg, "ammo_9x39_sp5", "in",3)
end

function mar_suslov_hram(gg, npc)
    dialogs.relocate_item_section(npc, "ammo_5.45x39_ap", "in", 3)
	dialogs.relocate_item_section(npc, "ammo_12x70_buck", "in", 3)
    dialogs.relocate_item_section(npc, "medkit", "in", 3)
    dialogs.relocate_item_section(npc, "bandage", "in", 5)
end

function zachistka_vyshka()
	if has_alife_info("zahvat_1")then
	db.actor:give_info_portion("zachistka_1")
		return true
	end
	return false
end

function zachistka_hram()
	if has_alife_info("zahvat_2")then
	db.actor:give_info_portion("zachistka_2")
		return true
	end
	return false
end

function zachistka_blokpost()
	if has_alife_info("zahvat_3")then
	db.actor:give_info_portion("zachistka_3")
		return true
	end
	return false
end

function zachistka_s_hutor()
	if has_alife_info("zahvat_4")then
	db.actor:give_info_portion("zachistka_bolot")
		return true
	end
	return false
end

function delete_delete()
	local sim = alife()
	local obj 
    for a=1835,1844 do
		local se_obj = sim:story_object(a) 
		if se_obj then 
		sim:release(se_obj, true) 
		end
	end
end 

		
function delete_1()
	for a=1845,1846 do
	local npc = alife():story_object(a)
		if npc then
			alife():set_switch_offline (npc.id, true)
			alife():set_switch_online (npc.id, false)
			alife():set_interactive (npc.id, false)
		end
	end		
end	

function delete_2()
	for a=1845,1846 do
	local npc = alife():story_object(a)
		if npc then
			alife():set_switch_offline (npc.id, true)
			alife():set_switch_online (npc.id, false)
			alife():set_interactive (npc.id, false)
		end
	end
	for a=1852,1853 do
	local npc = alife():story_object(a)
		if npc then
			alife():set_switch_offline (npc.id, true)
			alife():set_switch_online (npc.id, false)
			alife():set_interactive (npc.id, false)
		end
	end	
end	

function delete_3()
	local sim = alife()
	local obj 
    for a=1847,1848 do
		local se_obj = sim:story_object(a) 
		if se_obj then 
		sim:release(se_obj, true) 
		end
	end
end 

		