--[[
Copyright: © Èðáès , Real Wolf
]]

local npc, f_sp, s_sp
local tbl_sect = {	ded_ami = { killer_outfit = true,
			    mercenary_exo = true,
			    mercenary_scientific = true
			  },

		novicov = { specops_outfit = true,
                sky_heavy = true,
			    military_outfit = true,
			    military_gas = true,
				stalker_outfit = true
			  },
			  
		bar_tehnik = { specops_outfit = true,
			    military_outfit = true,
				stalker_outfit = true,
				scientific_outfit = true,
				exo_outfit = true
			  },

		bender = { specops_outfit = true,
			    military_outfit = true,
				stalker_outfit = true
			  },

		azot = { specops_outfit = true,
			    military_outfit = true,
			    military_gas = true,
				stalker_outfit = true
			  },			  
		
		dragon_kluk = { proseva = true,
			       dragon_exo = true
			     },

		skorpion = { sky_heavy = true,
				stalker_outfit = true
		},

		kardan = { stalker_outfit = true,
						scientific_outfit = true,
						exo_outfit = true,
						specops_outfit = true,
						military_outfit = true						
			 },

		bar_dolg_petrenko = { dolg_outfit = true,
			   dolg_military = true,
			   duty_exo = true,
			   dolg_scientific_outfit = true,
			   military_outfit = true
			 },
			 
		escape_trader = {  stalker_outfit = true,
						scientific_outfit = true,
						specops_outfit = true,
						military_outfit = true,
						leather_raincoat = true
			 },			 

		mil_freedom_member0002 = { specops_free = true,
					   svoboda_light_outfit = true,
					   svoboda_heavy_outfit = true,
					   freedom_exo = true,
					   freedom_scientific = true,
					   stalker_outfit = true,
					   specops_free = true
					 }
		}
		
local npc_tbl = { azot = "upi_repair_kit_for_azot_quest_end" }
		
function start_dialog(first_speaker, second_speaker)
	npc = second_speaker
	f_sp = first_speaker
	s_sp = second_speaker	
end

function is_not_slot(gg, npc)
	if db.actor:item_in_slot(1) == nil and db.actor:item_in_slot(2) == nil then
		return true
	end
	return false
end

function precond(gg, npc)
	if npc_tbl[npc:name()] then
		if has_alife_info(npc_tbl[npc:name()]) then
			return true
		end
	else
		return true
	end
	return false
end	

function precond_1(gg, npc)
	if db.actor:item_in_slot(1) ~= nil or db.actor:item_in_slot(2) ~= nil then
		return true
	end
	return false
end

function is_not_outfit()
	local outf = db.actor:item_in_slot(6)
	if outf == nil then
		return true
	end
	return false
end

function is_allowed_outfit()
	if db.actor:item_in_slot(6) == nil then return false end
	if tbl_sect[npc:section()] then
		if npc:name() == "escape_trader" then return true end
		local tbl = tbl_sect[npc:section()]
		local ro = lwc_ui_upgrade.GetRealSect(0)
		if tbl[ro] then
			return true
		end
	elseif tbl_sect[npc:name()] then
		local tbl = tbl_sect[npc:name()]
		local ro = lwc_ui_upgrade.GetRealSect(0)
		if tbl[ro] then
			return true
		end
	end
	return false
end

function is_outfit()
	if db.actor:item_in_slot(6) == nil then return false end
	if tbl_sect[npc:section()] then
		if npc:name() == "escape_trader" then return false end
		local tbl = tbl_sect[npc:section()]
		local ro = lwc_ui_upgrade.GetRealSect(0)
		if tbl[ro] then
			return false
		end
	elseif tbl_sect[npc:name()] then
		local tbl = tbl_sect[npc:name()]
		local ro = lwc_ui_upgrade.GetRealSect(0)
		if tbl[ro] then
			return false
		end
	end
	return true
end

function start_upgrade()
	f_sp:stop_talk()
	s_sp:stop_talk()
	local spwn = lwc_ui_upgrade.upgrade_menu(get_hud())
	level.start_stop_menu(spwn,true)		
end


function start_upgrade_weapons()
	f_sp:stop_talk()
	s_sp:stop_talk()
	local spwn = lwc_ui_main_upgrade.upg_main_menu(get_hud())
	level.start_stop_menu(spwn,true)		
end