function transfer_deneg(first_speaker, second_speaker)
    got_money(1400)
    got("detector_simple")
	got("arc_art_box_8basic")
	give_info("biznes_remove_special_item")
	lost("arc_art_box_1basic",1)
	disable_info("biznes_remove_special_item")
	
end
   

function give_weapon_from_trader(trader, actor)
	got("arc_art_box_1basic")
end

function otday_art (first_speaker, second_speaker)
    lost("amk_af_night_star")
end

function have_a_art2 (player, stalker)
	local has_art=player:object("amk_af_night_star") ~= nil
	local has_container=player:object("arc_art_box_1basic") ~= nil
    return has_art and has_container
end




function trader_alredy_give_job(trader, actor)
	if (has_info("agroprom_military_case") and not has_info("agroprom_military_case_done")) or
	   (has_info("escape_blockpost_case") and not has_info("escape_blockpost_case_done")) or
	   (has_info("tutorial_artefact_start") and not has_info("tutorial_artefact_done")) or
	   (has_info("tutorial_wounded_start") and not has_info("esc_serious_talk"))
	then
		return true
	end
	return false 
end

function trader_give_extra_job(trader, actor)
	if has_info("escape_blockpost_case") and not has_info("escape_blockpost_case_done")
	then
		return true
	end
	return false
end

function bandits_die(actor,npc)
	if has_info("esc_kill_bandits_quest_kill") and not has_info("esc_kill_bandits_noquest_kill")
	then
		return true
	end
	return false
end

function trader_need_extra_job(trader, actor)
	if not has_info("escape_blockpost_case") and 
	    has_info("esc_return")
	then
		return true
	end
	return false
end

function is_tutorial()
	return not has_info("tutorial_end")
end

function is_not_tutorial()
	return has_info("tutorial_end")
end

function is_not_tutorial_art(actor, trader)
	local tutorial_artefact = db.actor:object("af_blood_tutorial")
	if (has_info("tutorial_artefact_start") and not has_info("tutorial_artefact_done")
		and  tutorial_artefact ~= nil) or has_info("tutorial_artefact_done")
	then
		return true
	end
	return false
end

function not_final_job(trader, actor)
	return not has_info("escape_blockpost_case_done")
end

function trader_test(actor, npc)
 	printf ("!!!")	
	return true
end



function trader_dont_give_job(first_speaker, second_speaker)
	return not trader_alredy_give_job(first_speaker, second_speaker)
end

function finalize_quests(first_speaker, second_speaker)
	if tutorial_artefact_end(first_speaker, second_speaker) == true or
	   tutorial_wounded_end(first_speaker, second_speaker) == true
	then
		return true
	end
	return false
end

function not_finalize_quests(first_speaker, second_speaker)
	return not this.finalize_quests(first_speaker, second_speaker)	
end

function tutorial_artefact_end(first_speaker, second_speaker)
	local tutorial_artefact = first_speaker:object("af_blood_tutorial")
	if has_info("tutorial_artefact_start") and 
	   not has_info("tutorial_artefact_done") and
	   tutorial_artefact ~= nil
	then
		return true
	end
	return false
end

function tutorial_artefact_have_not(first_speaker, second_speaker)
	local tutorial_artefact = first_speaker:object("af_blood_tutorial")
	if has_info("tutorial_artefact_start") and 
	   not has_info("tutorial_artefact_done") and
	   tutorial_artefact == nil
	then
		return true
	end
	return false
end

function tutorial_wounded_end(first_speaker, second_speaker)
	-- local wounded_flash = first_speaker:object("esc_wounded_flash")
	if has_info("tutorial_wounded_start")	and 
		has_info("tutorial_wounded_give_info")	and 	
	   not has_info("esc_serious_talk")
 -- and   wounded_flash ~= nil
	then
		return true
	end
	return false
end

function trader_dont_has_job(first_speaker, second_speaker)
    if trader_need_military_case(first_speaker, second_speaker) == false and
	   trader_need_blockpost_box(first_speaker, second_speaker) == false
	then
		return true
	end
	return false
end

--' Escape tutorial artefact
function have_tutorial_artefact(first_speaker, second_speaker)
  	return first_speaker:object("af_blood_tutorial") ~= nil
end
function give_medkit(first_speaker, second_speaker)
	got("medkit")
end
function give_tutorial_artefact(first_speaker, second_speaker)
	lost("af_blood_tutorial")
end

--' Meet fox
function have_fox_info(first_speaker, second_speaker)
  	return first_speaker:object("fox_flash") ~= nil
end

--' fox help
function transfer_medikit_to_fox (player, wounded)
	wounded:set_relation(game_object.friend, player)
	give_info("escape_fox_heal")
end

function give_weapon_to_actor (trader, actor)
--	got("wpn_pm")
	got("vodka")
	got("ammo_9x18_fmj")
	got("ammo_9x18_fmj")
end

--' Escape blockpost box
-- Спавним кейс скриптом в диалоге с Сидором, рандомно в 7ми местах
function blockpost_case_spawn()
local b = {
	{position={x=-126.6884,y=-29.420,z=-388.704},gv=0,lv=594270},
	{position={x=-126.57,y=-29.00,z=-373.20},gv=25,lv=126770},
	{position={x=-140.91,y=-29.49,z=-356.74},gv=19,lv=109722}, 
	{position={x=-139.33,y=-29.51,z=-356.74},gv=19,lv=111250},
	{position={x=-140.80,y=-28.825,z=-352.61},gv=19,lv=110482},
	{position={x=-136.09,y=-28.45,z=-359.23},gv=19,lv=114324},
	{position={x=-140.68,y=-25.44,z=-359.58},gv=19,lv=116591}
}
	local a = table.random(b)
	create("quest_case_01", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
end

function have_blockpost_case(first_speaker, second_speaker)
  	return first_speaker:object("quest_case_01") ~= nil
end

function give_blockpost_case(first_speaker, second_speaker)
	lost("quest_case_01")
end

function give_blockpost_case_reward(first_speaker, second_speaker)
	got_money(2000)
end

--' Agroprom military case
function trader_need_military_case(first_speaker, second_speaker)
    if has_info("esc_serious_talk") and
	   not has_info("agroprom_military_case")
	then
		return true
	end
	return false
end

--' Escape trader artefact
function have_artefact_from_fleshes(first_speaker, second_speaker)
	if db.actor:object("af_vyvert") ~= nil or
	   db.actor:object("af_gravi") ~= nil or
	   db.actor:object("af_gold_fish") ~= nil
	then
		return true
	end
  	return false
end

--' Ящик с блокпоста
function trader_need_blockpost_box(first_speaker, second_speaker)
    if has_info("tutorial_end") and
	   has_info("esc_trader_speak") and
	   not has_info("escape_blockpost_case")
	then
		return true
	end
	return false
end

--' tutorial wounded in vagon
function wounded_need_help(first_speaker, second_speaker)
	return not has_info( "tutorial_wounded_help" )
end

--' trader needs military documents
function trader_need_military_document(first_speaker, second_speaker)
    if has_info("escape_blockpost_case_done") and
	   not has_info("agroprom_military_case")
	then
		return true
	end
	return false
end

--' trader dialog about docs from labx18
function actor_has_documents (actor, npc)
	if db.actor:object("dar_document4") then
		return true
	else
		return false
	end
end

--' Escape dynamite for Wolf
function transfer_wolf_reward(first_speaker, second_speaker)
	got("af_medusa")
	got("wpn_pmm")
        got("ammo_9x18_pmm")
end

function wolf_additional_reward(first_speaker, second_speaker)
    got("medkit")
    got("bandage")
    got("wpn_fort")
    got("grenade_f1") 
    got("ammo_9x18_pmm",2)
end

--' Escape Wounded's flash
function wounded_give_flash()
	if not has_info("escape_trader_sidor") then
		give_info("escape_trader_sidor")
		got("esc_wounded_flash")
	end
  escape_dialog.outfit_bandit_m1_spawn()
end

-- Спавним куртку для Шустрого рандомно на Кордоне
function outfit_bandit_m1_spawn()
local b = {
	{position={x=141.11,y=4.52,z=342.23},gv=232,lv=446391},
	{position={x=22.76,y=21.44,z=678.70},gv=208,lv=302449},
	{position={x=110.65,y=1.87,z=458.97},gv=223,lv=416175}, 
	{position={x=-15.35,y=3.98,z=261.06},gv=184,lv=267404},
	{position={x=344.76,y=16.72,z=243.95},gv=250,lv=586532},
	{position={x=57.97,y=19.38,z=156.77},gv=97,lv=345136},
	{position={x=-2.19,y=21.94,z=156.99},gv=174,lv=236464},
	{position={x=6.33,y=14.34,z=93.44},gv=92,lv=283125},
	{position={x=-241.29,y=-13.82,z=-12.86},gv=67,lv=14603},
	{position={x=-206.83,y=-36.38,z=-275.25},gv=38,lv=46406}
}
	local a = table.random(b)
	local obj = create("bandit_outfit_box", xyz(a.position.x,a.position.y,a.position.z), a.lv, a.gv)
	map_spot(obj.id, "treasure", "Cache")
	sms("Received a tip on the cache", nil, nil, 10000)
end

function have_wounded_flash(first_speaker, second_speaker)
  	return first_speaker:object("esc_wounded_flash") ~= nil
end
function dont_have_wounded_flash(first_speaker, second_speaker)
  	return not have_wounded_flash(first_speaker, second_speaker)
end

function give_wounded_flash(first_speaker, second_speaker)
	lost("esc_wounded_flash")
	got_money(1500)
end

function give_knife_to_actor(first_speaker, second_speaker)
	got("wpn_knife")
end

--' Escape bandits factory
function give_factory_reward_trader(first_speaker, second_speaker)
	got_money(500)
end

--' Give X-18 documents read
function give_documents_reward (first_speaker, second_speaker)
	got_money(1000)
end

--' Kill killers raid
function give_reward_killers(first_speaker, second_speaker)
	got_money(2500)
end

--' Soldiers on bridge
function has_soldiers_bribe(actor, npc)
	return has_money(500)
end

function give_soldiers_bribe(actor, npc)
	lost_money(500)	
end

function fox_pay_money(actor, npc)
	got_money(1500)	
--	got_treasure("esc_secret_truck_goods")
        sak_dialog.fox_got_treasure()
end

function run_tutorial_pda(first_speaker, second_speaker)
	printf("!-!-!")
	first_speaker:stop_talk()
    second_speaker:stop_talk()
	game.start_tutorial("part_1_pda")
end

function wolf_precond_univ (actor, npc)
	return has_info("esc_kill_bandits_quest_done") or (has_info("tutorial_wounded_give_info") and not has_info("esc_kill_bandits_quest_have"))
end

--------------------------------------------------------------------------------------------------------
-- Trader Factions - ABC1 Mod by Speed aka LW. Правка Архара
--------------------------------------------------------------------------------------------------------
function is_actor_stalker()
	return db.actor:character_community() == "actor"
end

function factions_repair_checkduty_r(trader, actor)
   if relation_registry.community_goodwill ("dolg", db.actor:id ()) < 0 then
		local chkgoodwill = relation_registry.community_goodwill("dolg",  db.actor:id())
		if chkgoodwill > -100 and has_money(250000) then return true end
		if chkgoodwill < -100 and chkgoodwill >= -1000 and has_money(250000) then return true end
		if chkgoodwill < -1000 and has_money(350000) then return true end
   end
return false
end

function factions_repair_checkduty_j(trader, actor)
local whatami = db.actor:character_community()
   if (relation_registry.community_goodwill ("dolg", db.actor:id()) >= 0) and (has_money(250000)) and (whatami ~= "actor_dolg") and (whatami == "actor") then return true
   else return false
   end
end

function factions_repair_checkfree_r(trader, actor)
   if relation_registry.community_goodwill ("freedom", db.actor:id()) < 0 then
		local chkgoodwill = relation_registry.community_goodwill("freedom",  db.actor:id())
		if chkgoodwill > -100 and has_money(250000) then return true end
		if chkgoodwill < -100 and chkgoodwill >= -1000 and  has_money(250000) then return true end
		if chkgoodwill < -1000 and has_money(350000) then return true end
   else return false
   end
return false
end

function factions_repair_checkfree_j(trader, actor)
local whatami = db.actor:character_community()
   if (relation_registry.community_goodwill ("freedom", db.actor:id()) >= 0) and (has_money(250000)) and (whatami ~= "actor_freedom") and (whatami == "actor") then return true
   else return false
   end
end

function factions_repair_checkstalker_r(trader, actor)
	local whatami = db.actor:character_community()
    local gulag = xr_gulag.get_gulag_by_name ("esc_lager")
	-- logf("testing stalker " .. whatami)
	if (gulag) then
		if (gulag:npc_is_enemy_to_anybody(db.actor)) and (has_money(250000)) and (whatami ~= "monolith") and (whatami ~= "bandit") and (whatami ~= "military") and (whatami ~= "killer") then
	       return true
		end
	end
    return false
end

function factions_repair_checkstalker(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 250000
    local gulag = xr_gulag.get_gulag_by_name ("esc_lager")
	if (gulag) then
		if gulag:npc_is_enemy_to_anybody(db.actor) and has_money(250000) then
			item_name_and_price = translate("list_factions_repair_4").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
			db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
		end
	end
end

function factions_repair_setstalker_r(trader, actor)
	local howmuch = 250000
    local gulag = xr_gulag.get_gulag_by_name ("esc_lager")
	if (gulag) then
		if gulag:npc_is_enemy_to_anybody(db.actor) and has_money(250000) then
			local chkgoodwill = relation_registry.community_goodwill("stalker",  db.actor:id())
			xr_gulag.setGulagRelation ("esc_lager", game_object.neutral, db.actor)	
			relation_registry.set_community_goodwill ("stalker", db.actor:id(), 120)	
			lost_money(howmuch)
			archievements.acv_count_event("acv_xam", 3, "acv_xam")
		end
	end
end

function factions_repair_checkduty(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 0
	if db.actor ~= nil then 
	  if relation_registry.community_goodwill ("dolg", db.actor:id()) < 0 then
		local chkgoodwill = relation_registry.community_goodwill("dolg",  db.actor:id())
		if chkgoodwill > -100 and has_money(250000) then howmuch = 250000 	end
		if chkgoodwill < -100 and chkgoodwill >= -1000 and has_money(250000) then howmuch = 250000 end
		if chkgoodwill < -1000 and has_money(350000) then howmuch = 350000 end
		item_name_and_price = translate("list_factions_repair_0").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
		db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
	  elseif (relation_registry.community_goodwill ("dolg", db.actor:id()) >= 0) and (has_money(250000)) then
		howmuch = 250000
		item_name_and_price = translate("list_factions_repair_1").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
		db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
	  end
    end
end

function factions_repair_checkfree(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 0
  if db.actor ~= nil then 
   if relation_registry.community_goodwill ("freedom", db.actor:id()) < 0 then
		local chkgoodwill = relation_registry.community_goodwill("freedom",  db.actor:id ())
		if chkgoodwill > -100 and has_money(250000) then howmuch = 250000 end
		if chkgoodwill < -100 and chkgoodwill >= -1000 and has_money(350000) then howmuch = 350000 end
		if chkgoodwill < -1000 and  has_money(350000) then howmuch = 350000 end
		item_name_and_price = translate("list_factions_repair_2").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
		db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
	elseif (relation_registry.community_goodwill ("freedom", db.actor:id()) >= 0) and (has_money(350000)) then
		howmuch = 350000
		item_name_and_price = translate("list_factions_repair_3").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
		db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
	end
  end
end

function factions_repair_setduty_r(trader, actor)
	local howmuch = 0
	if db.actor ~= nil then 
		local chkgoodwill = relation_registry.community_goodwill("dolg",  db.actor:id())
		if chkgoodwill > -100 and has_money(250000) then howmuch = 250000 end
		if chkgoodwill < -100 and chkgoodwill >= -1000 and has_money(250000) then howmuch = 250000 end
		if chkgoodwill < -1000 and  has_money(350000) then howmuch = 350000 end
		lost_money(howmuch)
		relation_registry.set_community_goodwill ("dolg", db.actor:id(), 500)
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_setduty_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(350000)
		db.actor:set_character_community("actor_dolg", 0, 0)
		local chkgoodwill = relation_registry.community_goodwill("dolg",  db.actor:id())
		if chkgoodwill > 0 then 
			chkgoodwill = chkgoodwill + 200
			relation_registry.set_community_goodwill ("dolg", db.actor:id(), chkgoodwill)
		else
			relation_registry.set_community_goodwill ("dolg", db.actor:id (), 200)
		end
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_setfree_r(trader, actor)
	local howmuch = 0
	if db.actor ~= nil then 
		local chkgoodwill = relation_registry.community_goodwill("freedom",  db.actor:id())
		if chkgoodwill > -100 and has_money(250000) then howmuch = 250000 end
		if chkgoodwill < -100 and chkgoodwill >= -1000 and has_money(250000) then howmuch = 25000 end
		if chkgoodwill < -1000 and  has_money(350000) then howmuch = 350000 end
		lost_money(howmuch)
		relation_registry.set_community_goodwill ("freedom", db.actor:id(), 1000)
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_setfree_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(350000)
		db.actor:set_character_community("actor_freedom", 0, 0)
		local chkgoodwill = relation_registry.community_goodwill("freedom",  db.actor:id())
		if chkgoodwill > 0 then 
			chkgoodwill = chkgoodwill + 250
			relation_registry.set_community_goodwill ("freedom", db.actor:id(), chkgoodwill)
		else
			relation_registry.set_community_goodwill ("freedom", db.actor:id(), 250)
		end
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_checkmon_j(trader, actor)
   local whatami = db.actor:character_community()
   local playhitemb = db.actor:object("h_2")
   if (playhitemb ~= nil or db.joinfactions == "yes") and (has_money(250000)) and (whatami ~= "monolith") and (whatami == "actor") then return true
   else return false
   end
end

function factions_repair_checkmonolith(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 250000
		if  has_money(250000) then
			item_name_and_price = translate("list_factions_repair_5").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
			db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
		end
end

function factions_repair_setmon_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(250000)
		db.actor:set_character_community("monolith", 0, 0)
		local chkgoodwill = relation_registry.community_goodwill("monolith",  db.actor:id())
		if chkgoodwill > 0 then 
			chkgoodwill = chkgoodwill + 200
			relation_registry.set_community_goodwill ("monolith", db.actor:id(), chkgoodwill)
		else
			relation_registry.set_community_goodwill ("monolith", db.actor:id(), 200)
		end
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_bandit_j(trader, actor)
   local whatami = db.actor:character_community()
   local playhitemb = db.actor:object("h_2")
   if (playhitemb ~= nil or db.joinfactions == "yes") and (has_money(250000)) and (whatami ~= "bandit") and (whatami == "actor") then return true
   else return false
   end
end

function factions_repair_checkbandit(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 250000
		if  has_money(250000) then
			item_name_and_price = translate("list_factions_repair_7").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
			db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
		end
end

function factions_repair_setbandit_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(250000)
		db.actor:set_character_community("bandit", 0, 0)
		local chkgoodwill = relation_registry.community_goodwill("bandit",  db.actor:id())
		if chkgoodwill > 0 then 
			chkgoodwill = chkgoodwill + 200
			relation_registry.set_community_goodwill ("bandit", db.actor:id(), chkgoodwill)
		else
			relation_registry.set_community_goodwill ("bandit", db.actor:id(), 200)
		end
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end


function factions_repair_mil_j(trader, actor)
   local whatami = db.actor:character_community()
   local playhitemb = db.actor:object("h_2")
   if (playhitemb ~= nil or db.joinfactions == "yes") and (has_money(400000)) and (whatami ~= "military") and (whatami == "actor") then return true
   else return false
   end
end

function factions_repair_checkmil(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 400000
		if  has_money(400000) then
			item_name_and_price = translate("list_factions_repair_6").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
			db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
		end
end

function factions_repair_setmil_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(400000)
		db.actor:set_character_community("military", 0, 0)
		local chkgoodwill = relation_registry.community_goodwill("military",  db.actor:id())
		if chkgoodwill > 0 then 
			chkgoodwill = chkgoodwill + 200
			relation_registry.set_community_goodwill ("military", db.actor:id(), chkgoodwill)
		else
			relation_registry.set_community_goodwill ("military", db.actor:id(), 200)
		end
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_kill_j(trader, actor)
   local whatami = db.actor:character_community()
   local playhitemb = db.actor:object("h_2")
   if (playhitemb ~= nil or db.joinfactions == "yes") and (has_money(300000)) and (whatami ~= "killer") and (whatami == "actor") then return true
   else return false
   end
end

function factions_repair_checkkill(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 300000
		if  has_money(300000) then
			item_name_and_price = translate("list_factions_repair_8").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
			db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
		end
end

function factions_repair_setkill_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(300000)
		db.actor:set_character_community("killer", 0, 0)
		local chkgoodwill = relation_registry.community_goodwill("military",  db.actor:id())
		if chkgoodwill > 0 then 
			chkgoodwill = chkgoodwill + 200
			relation_registry.set_community_goodwill ("killer", db.actor:id(), chkgoodwill)
		else
			relation_registry.set_community_goodwill ("killer", db.actor:id(), 200)
		end
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_eco_j(trader, actor)
   local whatami = db.actor:character_community()
   if (has_money(300000)) and (whatami ~= "ecolog") and (whatami == "actor") then return true
   else return false
   end
end

function factions_repair_checkeco(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 500000
		if  has_money(300000) then
			item_name_and_price = translate("list_factions_repair_10").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
			db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
		end
end

function factions_repair_seteco_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(300000)
		db.actor:set_character_community("ecolog", 0, 0)
		local chkgoodwill = relation_registry.community_goodwill("ecolog",  db.actor:id())
		if chkgoodwill > 0 then 
			chkgoodwill = chkgoodwill + 200
			relation_registry.set_community_goodwill ("ecolog", db.actor:id(), chkgoodwill)
		else
			relation_registry.set_community_goodwill ("ecolog", db.actor:id(), 200)
		end
		archievements.acv_count_event("acv_xam", 3, "acv_xam")
	end
end

function factions_repair_quit_j(trader, actor)
   local whatami = db.actor:character_community()
   if (whatami == "actor_dolg") or (whatami == "actor_freedom") or (whatami == "monolith") or (whatami == "bandit") or (whatami == "military") or (whatami == "killer") or (whatami == "ecolog") then
	   if (has_money(250000)) then return true end
   end
   return false
end

function factions_repair_checkquit(first_speaker, second_speaker)
	local task_texture, task_rect = get_texture_info("ui_iconsTotal_lost_money")
	local item_name_and_price = ""
	local howmuch = 250000
		if  has_money(250000) then
			item_name_and_price = translate("list_factions_repair_9").." %c[255,238,155,23]"..howmuch.."Ru%c[default]"
			db.actor:give_talk_message(item_name_and_price, task_texture, task_rect, "iconed_trade_info")
		end
end

function factions_repair_setquit_j(trader, actor)
	if db.actor ~= nil then 
		lost_money(250000)
		db.actor:set_character_community("actor", 0, 0)
	end
end

function sherstuk_is_friend()
	lost_money(50000)
	disable_info("sherstuk_enemy")
end

function transfer_babok(first_speaker, second_speaker)
    got("stalker_outfit_v1")
end
 
function otday_britvu(first_speaker, second_speaker)
 lost("britva",1) 
end
 
function have_a_britva(stalker, player)
    return stalker:object ("britva") ~= nil
end

--' спавним нычку с бритвой на Кордоне, и двух сосычей, чтобы жизнь медом не казалась))
function nychka_britva_spawn()
	local obj = create("m_inventory_box41",xyz(367.4817199707,15.058229446411,-37.764579772949),594078,0)
	map_spot(obj.id, "treasure", "Cache of Wolf")
	sms("Received a tip on the cache", nil, nil, 10000)
	create("bloodsucker_weak",xyz(362.52444458008,14.946105003357,-40.518566131592),593099,0)
	create("bloodsucker_effector",xyz(362.52444458016,14.946105003357,-40.518566131592),593099,0)
	create("bloodsucker_effector",xyz(354.77905273438,15.000102996826,-35.064975738525),590991,140)
	create("af_soul",xyz(350.12689208984,15.249977111816,-30.440357208252),589301,140)
	create("ammo_12x70_kart",xyz(350.12689208974,15.249977111816,-30.440357208252),589301,140)
	create("ammo_12x70_kart",xyz(350.12689208975,15.249977111816,-30.440357208252),589301,140)
end

--' спавним бабок, изломов и зомбаков в тоннеле
function set_fake_dist(obj_id,dist)
	level.client_spawn_manager():add(obj_id, 0, 
		function (idist, id, obj)
			if obj then
				obj:set_fake_death_dist(idist)
			end
		end
	, dist)
end

function spawn_monstrov()
	local sobj=create("zombie_babka_strong",xyz(347.241,15.268,-22.261),588175,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_weak",xyz(345.909,15.309,-21.251),587560,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_strong",xyz(345.017,15.337,-20.104),587239,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell14",xyz(344.102,15.374,-19.065),586922,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_strong",xyz(344.843,15.646,-17.884),587241,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_weak",xyz(343.712,15.615,-17.337),586611,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_strong",xyz(342.589,15.466,-17.543),585987,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell7",xyz(343.297,16.087,-16.211),586301,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_normal",xyz(343.762,16.903,-14.991),586615,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_trup2",xyz(344.401,17.73,-13.843),586929,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_strong",xyz(347.272,15.018,-28.654),588166,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_normal",xyz(346.771,14.916,-31.344),587862,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell12",xyz(348.883,15.14,-30.414),588749,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_strong",xyz(349.189,14.88,-32.09),589028,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_strong",xyz(351.25,15.016,-32.629),589817,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_strong",xyz(335.5146484375,15.526147842407,-24.381948471069),582810,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell5",xyz(337.42208862305,15.166791915894,-22.637878417969),583783,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell1",xyz(339.53707885742,15.396614074707,-21.737270355225),584725,2)
	set_fake_dist(sobj.id,9)
--	local sobj=create("vodjanoj",xyz(340.76348876953,15.21498298645,-20.280544281006),585351,2)
--	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_normal",xyz(340.78348876953,15.21498298645,-20.280544281006),585351,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell16",xyz(341.79803466797,15.088324546814,-21.24963760376),585667,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell2",xyz(342.17352294922,15.02472626495361,-24.172626495361),585977,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_weak",xyz(344.59268188477,14.9133244247437,-23.765293121338),586915,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell11",xyz(344.65268188477,14.9133244247437,-23.765293121338),586915,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell6",xyz(345.34234619141,15.056350708008,-26.022947311401),587231,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell1",xyz(346.16473388672,15.022896766663,-27.525096893311),587868,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell7",xyz(347.2350769043,14.901352882385,-26.870290756226),588169,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_weak",xyz(347.2550769043,14.901352882385,-26.870290756226),588169,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_strong",xyz(348.99685668945,14.80908870697,-26.603900909424),589033,140)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell3",xyz(344.51086425781,15.289694786072,-20.780237197876),586919,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell6",xyz(342.46298217773,14.983442306519,-22.337327957153),585980,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell7",xyz(342.46498217773,14.983442306519,-22.337327957153),585980,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_normal",xyz(342.46698217773,14.983442306519,-22.337327957153),585980,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell4",xyz(343.66607666016,14.936946868896,-23.076726913452),586603,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_strong",xyz(327.13098144531,16.580987930298,-23.365896224976),578734,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_trup",xyz(327.13098144641,16.580987930298,-23.365896224976),578734,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell10",xyz(327.13098144651,16.580987930298,-23.365896224976),578734,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell",xyz(327.13098144681,16.580987930298,-23.365896224976),578734,2)
	set_fake_dist(sobj.id,9)
	local sobj=create("fracture_strong",xyz(314.18695068359,16.467681884766,10.048849105835),572322,139)
	local sobj=create("zombie_hell5",xyz(314.18695068559,16.467681884766,10.048849105835),572322,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("fracture_strong",xyz(314.18695068379,16.467681884766,10.048849105835),572322,139)
	local sobj=create("zombie_babka_strong",xyz(315.18695068379,16.467681884766,10.048849105835),572322,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell7",xyz(314.17795068379,16.467681884766,10.048849105835),572322,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell2",xyz(314.18695068779,16.467681884766,10.048849105835),572322,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("fracture_strong",xyz(307.77069091797,16.160615921021,-4.0254411697388),568966,139)
	local sobj=create("zombie_trup",xyz(307.77069091997,16.160615921021,-4.0254411697388),568966,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("fracture_strong",xyz(307.77069091807,16.160615921021,-4.0254411697388),568966,139)
	local sobj=create("zombie_babka_weak",xyz(308.77069091807,16.160615921021,-4.0254411697388),568966,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_trup2",xyz(309.77069091807,16.160615921021,-4.0254411697388),568966,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("fracture_strong",xyz(313.89013671875,15.640267372131,6.0813541412354),571947,139)
	local sobj=create("zombie_hell4",xyz(314.89013671875,15.640267372131,6.0813541412354),571947,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell1",xyz(315.89013671875,15.640267372131,6.0813541412354),571947,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_weak",xyz(313.89013671675,15.640267372131,6.0813541412354),571947,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell2",xyz(313.89213671675,15.640267372131,6.0813541412354),571947,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("fracture_strong",xyz(313.89013671885,15.640267372131,6.0813541412354),571947,139)
	local sobj=create("zombie_hell3",xyz(277.44,14.43,29.05),549552,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell4",xyz(285.06,15.17,24.50),554633,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell5",xyz(286.22,14.61,7.68),555564,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell6",xyz(296.33,15.48,6.24),561954,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell7",xyz(301.25,15.60,2.55),564983,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell8",xyz(299.34,17.45,30.20),564159,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell9",xyz(289.77,16.61,37.29),557938,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell10",xyz(298.52,15.46,13.43),563271,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_hell11",xyz(302.41,15.39,11.33),565858,139)
	set_fake_dist(sobj.id,9)
	local sobj=create("zombie_babka_weak",xyz(328.72,15.88,-9.01),579778,2)
	set_fake_dist(sobj.id,9)
end

function collector_spawn_vodjanoj()
	local sobj=create("vodjanoj",xyz(-167.10,-60.45,391.87),3558,10541)
	set_fake_dist(sobj.id,9)
end
