
function sms_voronin()
	if level.name()=="jupiter" and 
	has_alife_info("aver_killer_dialog_end") and
	not has_alife_info("sms_voronin_complete") then
	db.actor:give_info_portion("sms_voronin_complete")
	amk.g_start_timer("sms_voronin",0,0,5)
	end
end

function quest_koltsov()
    amk.g_start_timer("quest_koltsov",0,0,2)
end

function kill_koltsov(gg, npc) 
	npc:kill(koltsov) 
end

function arhiv_complete()
	if db.actor:object("doc_koltsov") then
		return true
	end
	return false
end

 function spawn_monstr_iupiter()
	amk.spawn_item("gigant_normal",vector():set(-339.504,14.236,334.852), 46146, 3701)
	amk.spawn_item("pseudodog_strong",vector():set(-402.014,17.263,379.971), 42991, 3701, 15)
end

function spawn_monstr_iupiter_2()
	amk.spawn_item("snork_strong",vector():set(78.684,3.171,336.620), 848786, 3728, 5)
	amk.spawn_item("snork_strong",vector():set(70.801,4.653,326.081), 836380, 3725, 7)
	amk.spawn_item("tushkano_normal",vector():set(69.341,3.236,344.972), 834018, 3728, 8)
	amk.spawn_item("tushkano_normal",vector():set(93.969,4.738,330.546), 875337, 3733, 12)
end
 
 function spawn_semenovna()
	local obj = alife():create("semenovna",vector():set(-331.163,20.675,450.997),156203,3703)
	local params = amk.read_stalker_params(obj)
	params.custom="[logic]\ncfg = scripts\\zaton\\semenovna.ltx"
	params.sid = 15048
	amk.write_stalker_params(params,obj)
end

function quest_mogila()
    amk.g_start_timer("quest_mogila",0,0,2)
end

function mogila_martyshka_complete()
	if db.actor:object("kukla") and db.actor:has_info("mogila_martyshki") then
		db.actor:iterate_inventory(function (dummy, item) 
		if item:section() == "kukla" then 
			db.actor:drop_item(item)
			amk.remove_item(item) 
		end 
	end, nil)
	db.actor:give_info_portion("sms_nagrada")
		return true
	end
	return false
end

function start_sms_nagrada()
    amk.g_start_timer("sms_nagrada",0,0,5)
end

function start_sms_krohobor()
	if has_alife_info("krohobor_aleksandr_end") then
    amk.g_start_timer("sms_krohobor",0,0,5)
	end
end

function spawn_nagrada()
    local JupBox_1 = alife():object("jupiter_inventory_box_01")
	if db.actor then
	alife():create("wpn_pecheneg",JupBox_1.position, JupBox_1.m_level_vertex_id, JupBox_1.m_game_vertex_id, JupBox_1.id)
	for i=1, 2 do 
		alife():create("ammo_7.62x54r",JupBox_1.position, JupBox_1.m_level_vertex_id, JupBox_1.m_game_vertex_id, JupBox_1.id) 
    end
	end
end

function upi_repair_kit_for_azot_transfer(npc,gg)
	dialogs.relocate_item_section(npc,"instrumrem","out")
	dialogs.relocate_item_section(npc,"instrumcal","out")
	dialogs.relocate_money(npc,2000,"in")
end

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

function upi_dodge_quest_search()
   	local car_dodge = level_object_by_sid(15002) 
      	if car_dodge then
	     	if car_dodge:position():distance_to(db.actor:position()) < 5 then
            	return true
     		end
		end
	return false
end

function upi_dodge_quest_near()
   	local car_dodge = level_object_by_sid(15002) 
     	local azot = level_object_by_sid(151) 
      	if car_dodge and azot then
		if distance_between(car_dodge, azot) < 40 then
			return true
		end
       	end
	return false	
end

function upi_dodge_quest_antirad(npc, gg)
	dialogs.relocate_item_section(npc, "antirad", "in", 4)
	dialogs.relocate_item_section(npc, "medkit_scientic", "in", 2)
end

function upi_dodge_quest_reward(npc, gg)
	dialogs.relocate_item_section(npc, "vodka", "in", 3)
	dialogs.relocate_item_section(npc, "ammo_5.45x39_ap", "in", 3)
	dialogs.relocate_item_section(npc, "stalker_outfit_bb", "in")
end


function upi_gront_items(npc, gg)
    dialogs.relocate_item_section(npc, "antirad", "in", 2)
	dialogs.relocate_item_section(npc, "antiseptic", "in", 3)
	dialogs.relocate_item_section(npc, "army_fast", "in", 1)
    dialogs.relocate_item_section(npc, "medkit_army", "in",2)
end

function upi_document_quest_have()
	if db.actor:object("doc_9") then
		return true
	end
	return false
end

function container_quest_have()
	if db.actor:object("container_ozerskiy") then
		return true
	end
	return false
end

function container_reward(gg, npc)
		dialogs.relocate_item_section(npc, "container_ozerskiy", "out")
end

function container_quest_end(npc, gg)
    	dialogs.relocate_item_section(gg, "det_artefact_pro", "in")
end
	

function upi_document_quest_spawn()
	amk.spawn_item("doc_9",vector():set(-426.6008605957,26.06965637207,-383.62799072266),138111,3664)
	local obj = level_object_by_sid (150)
	if obj ~= nil then
		dialogs.companion_start_following(obj, db.actor)
		dialogs.companion_beh_walk_low_aggr(db.actor, obj)
	end
end


function upi_document_ecolog_quest_end(gg, npc)
		dialogs.relocate_item_section(gg, "doc_9", "out")
end		
		

function upi_document_ecolog_quest_reward(npc, gg)
    	dialogs.relocate_item_section(npc, "medkit_scientic", "in")
    	dialogs.relocate_item_section(npc, "detector_advances", "in")
		dialogs.relocate_money(npc, 10000, "in")
end

function upi_document_quest_fail()
     	local npc = level_object_by_sid(150)
	if npc then
		if not npc:alive() then
			return true
		end
	end
	return false
end

function upi_about_csky_talk_reward(gg, npc)
    	dialogs.relocate_item_section(npc, "ammo_5.45x39_fmj", "in", 3)
    	dialogs.relocate_item_section(npc, "medkit_army", "in", 1)
    	dialogs.relocate_item_section(npc, "antiseptic", "in", 1)
end
	