-- Andrey "Bandicoot" Zakoliukin --

local money_for_relation = 1000

function transfer_money_for_relation(first_speaker, second_speaker)
	dialogs.relocate_money(second_speaker, money_for_relation, "out")
end

function has_money_for_relation(first_speaker, second_speaker)
	return (first_speaker:money()>=money_for_relation)
end

function not_has_money_for_relation(first_speaker, second_speaker)
	return (first_speaker:money()<money_for_relation)
end

function show_money_for_relation(first_speaker, second_speaker)
	local news_caption = game.translate_string("st_upgr_cost")..": "
	local news_text = tostring(money_for_relation).." "..game.translate_string("st_rubles")
		db.actor:give_talk_message2(news_caption, news_text, "ui_iconsTotal_found_money", "iconed_answer_item")
end


function transfer_detector_advanced(first_speaker, second_speaker)
	if not has_alife_info("esc_joined_stalkers") then
		dialogs.relocate_item_section_to_actor(first_speaker, second_speaker, "detector_advanced")
		dialogs.relocate_item_section_to_actor(first_speaker, second_speaker, "antirad", 5)
		db.actor:give_info_portion("esc_joined_stalkers")
	end
end


-- stalker trader functions

function is_smart_captured_by_bandits()
	return xr_conditions.smart_captured_by_faction(nil,nil,{"esc_smart_terrain_6_6","bandit"})
end

function is_smart_not_captured_by_bandits()
	return not xr_conditions.smart_captured_by_faction(nil,nil,{"esc_smart_terrain_6_6","bandit"})
end


-- transfer functions

function actor_has_habar(first_speaker, second_speaker)
		return first_speaker:object("esc_trader_habar") ~= nil
end

function actor_hasnt_habar(first_speaker, second_speaker)
		return not actor_has_habar(first_speaker, second_speaker)
end

function transfer_habar(first_speaker, second_speaker)
		dialogs.relocate_item_section_from_actor(first_speaker, second_speaker, "esc_trader_habar")
end

function transfer_pistol(first_speaker, second_speaker)
		dialogs.transfer_any_pistol_from_actor(first_speaker, second_speaker)
end

function transfer_pistol_driver(first_speaker, second_speaker)
		dialogs.transfer_any_pistol_from_actor(first_speaker, second_speaker)
end

function transfer_gun(first_speaker, second_speaker)
		dialogs.transfer_any_gun_from_actor(first_speaker, second_speaker)
end

function transfer_leader_pda(first_speaker, second_speaker)
		dialogs.relocate_item_section_from_actor(first_speaker, second_speaker, "device_pda_military")
end

function actor_has_general_pda(first_speaker, second_speaker)
		return first_speaker:object("device_pda_military") ~= nil
end

function actor_hasnt_general_pda(first_speaker, second_speaker)
		return not actor_has_general_pda(first_speaker, second_speaker)
end

function transfer_prisoner_pistol(first_speaker, second_speaker)
		dialogs.transfer_any_pistol_from_actor(first_speaker, second_speaker)
end

function transfer_prisoner_shootgun(first_speaker, second_speaker)
		dialogs.transfer_any_shootgun_from_actor(first_speaker, second_speaker)
end

function transfer_prisoner_gun(first_speaker, second_speaker)
		dialogs.transfer_any_gun_from_actor(first_speaker, second_speaker)
end

function transfer_device_pda_driver(first_speaker, second_speaker)
		dialogs.relocate_item_section_from_actor(first_speaker, second_speaker, "esc_device_pda_driver")
end

function actor_has_device_pda_driver(first_speaker, second_speaker)
		return first_speaker:object("esc_device_pda_driver") ~= nil
end

function actor_hasnt_device_pda_driver(first_speaker, second_speaker)
		return not actor_has_device_pda_driver(first_speaker, second_speaker)
end

function give_money_for_support(first_speaker, second_speaker)
		dialogs.relocate_money(first_speaker, 500, "out")
end



-- rewards functions

function esc_additional_quest_5c_reward(first_speaker, second_speaker)
	task_manager.get_task_manager():immediate_give_reward(first_speaker,second_speaker,"esc_additional_quest_5c")
end

function esc_additional_quest_4c_reward(first_speaker, second_speaker)
	task_manager.get_task_manager():immediate_give_reward(first_speaker,second_speaker,"esc_additional_quest_4c")
end

function esc_additional_quest_6b_reward(first_speaker, second_speaker)
	task_manager.get_task_manager():immediate_give_reward(first_speaker,second_speaker,"esc_additional_quest_6b")
end

function esc_eliminate_smart_military_6_6_reward_reward(first_speaker, second_speaker)
	task_manager.get_task_manager():immediate_give_reward(first_speaker,second_speaker,"esc_eliminate_smart_military_6_6_reward")
end



-- transfer functions "relocate_item"

function transfer_military_pda_to_military(first_speaker, second_speaker)
	dialogs.relocate_item_section(second_speaker, "esc_mechanic_flash_card_1", "in", 1)
end

function transfer_military_pda_to_stalker(first_speaker, second_speaker)
	dialogs.relocate_item_section(second_speaker, "esc_mechanic_flash_card_3", "in", 1)
end
