
------ bandit_companion_task_1

function bandit_companion_task_1_complete(a,b)
	local squad = get_story_squad("bandit_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function bandit_companion_task_1_not_complete(a,b)
	return not bandit_companion_task_1_complete(a,b)
end 

function bandit_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("val_smart_terrain_7_4_bandit_trader_stalker_task_3")
	a:stop_talk()
	b:stop_talk()
end

function bandit_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"bandit", 50})
end

------ army_companion_task_1

function army_companion_task_1_complete(a,b)
	local squad = get_story_squad("army_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function army_companion_task_1_not_complete(a,b)
	return not army_companion_task_1_complete(a,b)
end 

function army_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("agr_smart_terrain_1_6_army_trader_stalker_task_4")
	a:stop_talk()
	b:stop_talk()
end

function army_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"army", 50})
end


------ freedom_companion_task_1

function freedom_companion_task_1_complete(a,b)
	local squad = get_story_squad("freedom_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function freedom_companion_task_1_not_complete(a,b)
	return not freedom_companion_task_1_complete(a,b)
end 

function freedom_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("mil_smart_terrain_7_7_freedom_leader_stalker_task_6")
	a:stop_talk()
	b:stop_talk()
end

function freedom_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"freedom", 50})
end


------ dolg_companion_task_1

function dolg_companion_task_1_complete(a,b)
	local squad = get_story_squad("dolg_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function dolg_companion_task_1_not_complete(a,b)
	return not dolg_companion_task_1_complete(a,b)
end 

function dolg_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("bar_dolg_general_petrenko_stalker_task_4")
	a:stop_talk()
	b:stop_talk()
end

function dolg_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"dolg", 50})
end


------ killer_companion_task_1

function killer_companion_task_1_complete(a,b)
	local squad = get_story_squad("killer_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function killer_companion_task_1_not_complete(a,b)
	return not killer_companion_task_1_complete(a,b)
end 

function killer_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("cit_killers_merc_trader_stalker_task_3")
	a:stop_talk()
	b:stop_talk()
end

function killer_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"killer", 50})
end



------ stalker_companion_task_1

function stalker_companion_task_1_complete(a,b)
	local squad = get_story_squad("stalker_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function stalker_companion_task_1_not_complete(a,b)
	return not stalker_companion_task_1_complete(a,b)
end 

function stalker_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("esc_2_12_stalker_wolf_task_2")
	a:stop_talk()
	b:stop_talk()
end

function stalker_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"stalker", 50})
end


------ csky_companion_task_1

function csky_companion_task_1_complete(a,b)
	local squad = get_story_squad("csky_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function csky_companion_task_1_not_complete(a,b)
	return not csky_companion_task_1_complete(a,b)
end 

function csky_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("mar_base_stalker_barmen_task_4")
	a:stop_talk()
	b:stop_talk()
end

function csky_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"csky", 50})
end


------ monolith_companion_task_1

function monolith_companion_task_1_complete(a,b)
	local squad = get_story_squad("monolith_companion_task_1")
	if not (squad) then 
		return false
	end
	
	local id = squad:commander_id()
	local npc = db.storage[id] and db.storage[id].object
	if not (npc) then 
		return false
	end
	
	local total_loot_count = 0
	local npc
	for k in squad:squad_members() do
		local npc = db.storage[k.id] and db.storage[k.id].object
		if (npc) then 
			total_loot_count = total_loot_count + (alun_utils.load_var(npc,"s_loot_count") or 0)
		end
	end
	
	if (total_loot_count >= 9) then 
		return true
	end
	
	return false
end

function monolith_companion_task_1_not_complete(a,b)
	return not monolith_companion_task_1_complete(a,b)
end 

function monolith_companion_task_1_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("pri_monolith_monolith_trader_stalker_task_7")
	a:stop_talk()
	b:stop_talk()
end

function monolith_companion_task_1_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(2500,4000),"in")
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"monolith", 50})
end



------ ecolog_companion_task_3

function ecolog_companion_task_3_complete(a,b)
	return xr_conditions.has_task_target_anomaly() ~= true and xr_conditions.check_nearest_smart_dist_le(nil,nil,{40,"yan_smart_terrain_6_4"}) or false
end

function ecolog_companion_task_3_not_complete(a,b)
	return not ecolog_companion_task_3_complete(a,b)
end 

function ecolog_companion_task_3_complete_task(a,b)
	task_manager.get_task_manager():set_task_completed("yan_stalker_sakharov_task_2")
	a:stop_talk()
	b:stop_talk()
end

function ecolog_companion_task_3_give_reward(a,b)
	dialogs.relocate_money(db.actor,math.random(4500,7000),"in")
	if (math.random() <= 0.5) then
		coc_treasure_manager.create_random_stash()
	end
	xr_effects.inc_faction_goodwill_to_actor(db.actor, nil, {"ecolog", 50})
end

