local ids_func = Idstring

Hooks:PostHook(CopBase, "post_init", "postinithook", function(self)
	self:federales_hacks()
end)

function CopBase:federales_hacks()
    local unit_name = self._unit:name()
	local faction = tweak_data.levels:get_ai_group_type()
	local difficulty = Global.game_settings and Global.game_settings.difficulty or "normal"
	local difficulty_index = tweak_data:difficulty_to_index(difficulty)
    
	-- turn blu into zeals!
	local blue_swat = unit_name == ids_func("units/pd2_dlc_bex/characters/ene_swat_policia_federale/ene_swat_policia_federale")
	or unit_name == ids_func("units/pd2_dlc_bex/characters/ene_swat_policia_federale/ene_swat_policia_sniper_husk")
	
	--swap snipers/fbi shields to city and normal vars
	local switch_mat_config_sniper = unit_name == ids_func("units/pd2_dlc_bex/characters/ene_swat_policia_sniper/ene_swat_policia_sniper")
	or unit_name == ids_func("units/pd2_dlc_bex/characters/ene_swat_policia_sniper/ene_swat_policia_sniper_husk")
	
	local switch_mat_config_shield = unit_name == ids_func("units/pd2_dlc_bex/characters/ene_swat_shield_policia_federale_mp9/ene_swat_shield_policia_federale_mp9") 
	or unit_name == ids_func("units/pd2_dlc_bex/characters/ene_swat_shield_policia_federale_mp9/ene_swat_shield_policia_federale_mp9_husk")	
	
	if faction == "federales" and difficulty_index == 3 or difficulty_index == 4 or difficulty_index == 5 then
		if self._unit:damage() and self._unit:damage():has_sequence("swap_mats_to_fbi") and switch_mat_config_sniper then
			self._unit:damage():run_sequence_simple("swap_mats_to_fbi")
		end
	elseif difficulty_index == 6 and faction == "federales" or difficulty_index == 7 and faction == "federales" then
		if self._unit:damage() and self._unit:damage():has_sequence("swap_mats_to_city") and switch_mat_config_sniper then
			self._unit:damage():run_sequence_simple("swap_mats_to_city")
		elseif self._unit:damage() and self._unit:damage():has_sequence("swap_mats_to_city") and switch_mat_config_shield then
			self._unit:damage():run_sequence_simple("swap_mats_to_city")		
		end	
	--[[this shit works and it works fine. however the accs are wrong which is why i disabled it haha. if i can get accessory swapping figured out, i can legitimately port all of resmods factions to vanilla haha.
	elseif difficulty_index == 8 and faction == "federales" then
		if self._unit:damage() and self._unit:damage():has_sequence("toggle_zeal_swat") and blue_swat then
			self._unit:damage():run_sequence_simple("toggle_zeal_swat")
		end--]]	
	end
end