############
# Cloaking #
############

########################
# NSC Special Cloaks   #
########################

utility_component_template = {
	key = "FRIGATE_CLOAK"
	size = aux
	icon = "GFX_ship_part_cloak_psi"
	icon_frame = 1
	power = @power_S5
	resources = {
		category = ship_components
		cost = {
			alloys = 50
			exotic_gases = 5
			rare_crystals = 5
		}
		upkeep = {
			energy = 0.5
			alloys = 0.1
		}
	}

	modifier = {
		ship_cloaking_strength_add = 6
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_speed_mult = 0.25
			ship_evasion_add = 15
		}
	}
	custom_tooltip = "CLOAKING_FRIGATE_TOOLTIP"

	ship_limit = 1
	
	potential = {
		is_ship_size = frigate
	}
	prerequisites = { "tech_cloaking_1" }
	component_set = "FRIGATE_CLOAKING"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
	}
	ai_weight = {
		weight = @basic_cloaking_weight
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}


utility_component_template = {
	key = "BATTLECRUISER_CLOAK"
	size = aux
	icon = "GFX_ship_part_cloak_3"
	icon_frame = 1
	power = @power_S5
	resources = {
		category = ship_components
		cost = {
			alloys = 50
			exotic_gases = 10
			rare_crystals = 10
		}
		upkeep = {
			energy = 0.275
			alloys = 0.055
		}
	}

	modifier = {
		ship_cloaking_strength_add = 3
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_speed_mult = -0.5
			ship_shield_reduction = 0.8
		}
	}
	custom_tooltip = "CLOAKING_BATTLECRUISER_TOOLTIP"

	ship_limit = 1
	
	potential = {
		ship_uses_battlecruiser_cloaks = yes
	}
	prerequisites = { "tech_Battlecruiser_1" "tech_cloaking_3" }
	component_set = "BATTLECRUISER_CLOAKING"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
	}
	ai_weight = {
		weight = @elite_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}
########################
# Corvettes & Frigates #
########################

# Basic Cloaking Device
utility_component_template = {
	key = "CORVETTE_CLOAKING_1"
	size = aux
	icon = "GFX_ship_part_cloak_1"
	icon_frame = 1
	power = @power_S2
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t1_cost_alloys
			exotic_gases = @cloak_s_t1_cost_strategic_resources
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t1_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t1_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t1_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_low_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_1_TOOLTIP"

	ship_limit = 1

	blocked_by = {
		CORVETTE_CLOAKING_2
		CORVETTE_CLOAKING_3
		CORVETTE_CLOAKING_DARK_MATTER
		CORVETTE_CLOAKING_PSI
	}
	potential = {
		ship_uses_corvette_cloaks = yes
	}
	prerequisites = { "tech_cloaking_1" }
	component_set = "CLOAKING_1"
	upgrades_to = "CORVETTE_CLOAKING_2"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}

	ai_weight = {
		weight = @basic_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

# Advanced Cloaking Device
utility_component_template = {
	key = "CORVETTE_CLOAKING_2"
	size = aux
	icon = "GFX_ship_part_cloak_2"
	icon_frame = 1
	power = @power_S3
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t2_cost_alloys
			exotic_gases = @cloak_s_t2_cost_strategic_resources
			rare_crystals = @cloak_s_t2_cost_strategic_resources
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t2_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t2_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t2_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_low_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_2_TOOLTIP"

	ship_limit = 1

	blocked_by = {
		CORVETTE_CLOAKING_1
		CORVETTE_CLOAKING_3
		CORVETTE_CLOAKING_DARK_MATTER
		CORVETTE_CLOAKING_PSI
	}
	potential = {
		ship_uses_corvette_cloaks = yes
	}
	prerequisites = { "tech_cloaking_2" }
	component_set = "CLOAKING_2"
	upgrades_to = "CORVETTE_CLOAKING_3"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @advanced_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

# Elite Cloaking Device
utility_component_template = {
	key = "CORVETTE_CLOAKING_3"
	size = aux
	icon = "GFX_ship_part_cloak_3"
	icon_frame = 1
	power = @power_S4
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t3_cost_alloys
			exotic_gases = @cloak_s_t3_cost_strategic_resources
			rare_crystals = @cloak_s_t3_cost_strategic_resources
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t3_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t3_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t3_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_medium_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_3_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		CORVETTE_CLOAKING_1
		CORVETTE_CLOAKING_2
		CORVETTE_CLOAKING_DARK_MATTER
		CORVETTE_CLOAKING_PSI
	}
	potential = {
		ship_uses_corvette_cloaks = yes
	}
	prerequisites = { "tech_cloaking_3" }
	component_set = "CLOAKING_3"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @elite_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

# Dark Matter Cloaking Device
utility_component_template = {
	key = "CORVETTE_CLOAKING_DARK_MATTER"
	size = aux
	icon = "GFX_ship_part_cloak_dark_matter"
	icon_frame = 1
	power = @power_S5
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t4_cost_alloys
			exotic_gases = @cloak_s_t4_cost_strategic_resources
			sr_dark_matter = @cloak_s_cost_sr_dark_matter
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t4_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t4_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t4_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_high_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 0.5
		}
	}
	custom_tooltip = "CLOAKING_DARK_MATTER_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		CORVETTE_CLOAKING_1
		CORVETTE_CLOAKING_2
		CORVETTE_CLOAKING_3
		CORVETTE_CLOAKING_PSI
	}
	potential = {
		ship_uses_corvette_cloaks = yes
	}
	prerequisites = { "tech_cloaking_dark_matter" }
	component_set = "CLOAKING_DARK_MATTER"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @dark_matter_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = sr_dark_matter }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

# Psionic Cloaking Device
utility_component_template = {
	key = "CORVETTE_CLOAKING_PSI"
	size = aux
	icon = "GFX_ship_part_cloak_psi"
	icon_frame = 1
	power = @power_S5
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t5_cost_alloys
			rare_crystals = @cloak_s_t5_cost_strategic_resources
			sr_zro = @cloak_s_cost_sr_zro
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t5_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t5_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t5_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_high_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
			has_non_psionic_shields = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_PSI_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		CORVETTE_CLOAKING_1
		CORVETTE_CLOAKING_2
		CORVETTE_CLOAKING_3
		CORVETTE_CLOAKING_DARK_MATTER
	}
	potential = {
		ship_uses_corvette_cloaks = yes
	}
	prerequisites = { "tech_cloaking_psi" }
	component_set = "CLOAKING_PSI"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @psi_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = sr_zro }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

##############
# Destroyers #
##############

utility_component_template = {
	key = "DESTROYER_CLOAKING_2"
	size = aux
	icon = "GFX_ship_part_cloak_2"
	icon_frame = 1
	power = @power_S3
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t2_cost_alloys
			exotic_gases = @cloak_s_t2_cost_strategic_resources
			rare_crystals = @cloak_s_t2_cost_strategic_resources
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t2_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t2_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t2_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_low_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_2_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		DESTROYER_CLOAKING_3
		DESTROYER_CLOAKING_DARK_MATTER
		DESTROYER_CLOAKING_PSI
	}
	potential = {
		ship_uses_destroyer_cloaks = yes
	}
	prerequisites = { "tech_cloaking_2" }
	component_set = "CLOAKING_2"
	upgrades_to = "DESTROYER_CLOAKING_3"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @advanced_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

utility_component_template = {
	key = "DESTROYER_CLOAKING_3"
	size = aux
	icon = "GFX_ship_part_cloak_3"
	icon_frame = 1
	power = @power_S4
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t3_cost_alloys
			exotic_gases = @cloak_s_t3_cost_strategic_resources
			rare_crystals = @cloak_s_t3_cost_strategic_resources
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t3_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t3_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t3_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_low_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_3_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		DESTROYER_CLOAKING_2
		DESTROYER_CLOAKING_DARK_MATTER
		DESTROYER_CLOAKING_PSI
	}
	potential = {
		ship_uses_destroyer_cloaks = yes
	}
	prerequisites = { "tech_cloaking_3" }
	component_set = "CLOAKING_3"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @elite_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

utility_component_template = {
	key = "DESTROYER_CLOAKING_DARK_MATTER"
	size = aux
	icon = "GFX_ship_part_cloak_dark_matter"
	icon_frame = 1
	power = @power_S5
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t4_cost_alloys
			exotic_gases = @cloak_s_t4_cost_strategic_resources
			sr_dark_matter = @cloak_s_cost_sr_dark_matter
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t4_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t4_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t4_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_medium_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 0.5
		}
	}
	custom_tooltip = "CLOAKING_DARK_MATTER_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		DESTROYER_CLOAKING_2
		DESTROYER_CLOAKING_3
		DESTROYER_CLOAKING_PSI
	}
	potential = {
		ship_uses_destroyer_cloaks = yes
	}
	prerequisites = { "tech_cloaking_dark_matter" }
	component_set = "CLOAKING_DARK_MATTER"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @dark_matter_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = sr_dark_matter }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

utility_component_template = {
	key = "DESTROYER_CLOAKING_PSI"
	size = aux
	icon = "GFX_ship_part_cloak_psi"
	icon_frame = 1
	power = @power_S5
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_s_t5_cost_alloys
			rare_crystals = @cloak_s_t5_cost_strategic_resources
			sr_zro = @cloak_s_cost_sr_zro
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_s_t5_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_s_t5_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_s_t5_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_high_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
			has_non_psionic_shields = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}

	custom_tooltip = "CLOAKING_PSI_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		DESTROYER_CLOAKING_2
		DESTROYER_CLOAKING_3
		DESTROYER_CLOAKING_DARK_MATTER
	}
	potential = {
		ship_uses_destroyer_cloaks = yes
	}
	prerequisites = { "tech_cloaking_psi" }
	component_set = "CLOAKING_PSI"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @psi_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = sr_zro }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

############
# Cruisers #
############

utility_component_template = {
	key = "CRUISER_CLOAKING_3"
	size = aux
	icon = "GFX_ship_part_cloak_3"
	icon_frame = 1
	power = @power_M4
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_m_t3_cost_alloys
			exotic_gases = @cloak_m_t3_cost_strategic_resources
			rare_crystals = @cloak_m_t3_cost_strategic_resources
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_m_t3_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_m_t3_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_m_t3_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_low_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_3_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		CRUISER_CLOAKING_DARK_MATTER
		CRUISER_CLOAKING_PSI
	}
	potential = {
		ship_uses_cruiser_cloaks = yes
	}
	prerequisites = { "tech_cloaking_3" }
	component_set = "CLOAKING_3"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @elite_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

utility_component_template = {
	key = "CRUISER_CLOAKING_DARK_MATTER"
	size = aux
	icon = "GFX_ship_part_cloak_dark_matter"
	icon_frame = 1
	power = @power_M5
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_m_t4_cost_alloys
			exotic_gases = @cloak_m_t4_cost_strategic_resources
			sr_dark_matter = @cloak_m_cost_sr_dark_matter
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_m_t4_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_m_t4_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_m_t4_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_low_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 0.5
		}
	}
	custom_tooltip = "CLOAKING_DARK_MATTER_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		CRUISER_CLOAKING_3
		CRUISER_CLOAKING_PSI
	}
	potential = {
		ship_uses_cruiser_cloaks = yes
	}
	prerequisites = { "tech_cloaking_dark_matter" }
	component_set = "CLOAKING_DARK_MATTER"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @dark_matter_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = exotic_gases }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = sr_dark_matter }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

utility_component_template = {
	key = "CRUISER_CLOAKING_PSI"
	size = aux
	icon = "GFX_ship_part_cloak_psi"
	icon_frame = 1
	power = @power_M5
	resources = {
		category = ship_components
		cost = {
			alloys = @cloak_m_t5_cost_alloys
			rare_crystals = @cloak_m_t5_cost_strategic_resources
			sr_zro = @cloak_m_cost_sr_zro
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = no
				}
			}
			energy = @cloak_m_t5_upkeep_energy
		}
		upkeep = {
			trigger = {
				from = {
					country_uses_bio_ships = yes
				}
			}
			food = @cloak_m_t5_upkeep_energy
		}
		upkeep = {
			alloys = @cloak_m_t5_upkeep_alloys
		}
	}

	modifier = {
		ship_cloaking_strength_add = @cloaking_medium_strength
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
			has_non_psionic_shields = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_PSI_TOOLTIP"

	ship_limit = 1
	blocked_by = {
		CRUISER_CLOAKING_3
		CRUISER_CLOAKING_DARK_MATTER
	}
	potential = {
		ship_uses_cruiser_cloaks = yes
	}
	prerequisites = { "tech_cloaking_psi" }
	component_set = "CLOAKING_PSI"
	ai_tags = {
		gunship_stealth
		explosive_stealth
		carrier_stealth
		screen_stealth
		artillery_stealth
		brawler_stealth
		energy_torpedoes_stealth
		buffer_role_stealth
		debuffer_role_stealth
	}
	ai_weight = {
		weight = @psi_cloaking_weight
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = sr_zro }
		}
		modifier = {
			factor = 0
			no_resource_for_component = { RESOURCE = rare_crystals }
		}
		inline_script = ship_components/weights/roles_cloaking_devices
	}
}

###############
# Battleships #
###############

# utility_component_template = {
	# key = "BATTLESHIP_CLOAKING_DARK_MATTER"
	# size = aux
	# icon = "GFX_ship_part_cloak_dark_matter"
	# icon_frame = 1
	# power = @power_L5
	# resources = {
		# category = ship_components
		# cost = {
			# alloys = @cloak_l_t4_cost_alloys
			# exotic_gases = @cloak_l_t4_cost_strategic_resources
			# sr_dark_matter = @cloak_l_cost_sr_dark_matter
		# }
		# upkeep = {
			# trigger = {
				# from = {
					# country_uses_bio_ships = no
				# }
			# }
			# energy = @cloak_l_t4_upkeep_energy
		# }
		# upkeep = {
			# trigger = {
				# from = {
					# country_uses_bio_ships = yes
				# }
			# }
			# food = @cloak_l_t4_upkeep_energy
		# }
		# upkeep = {
			# alloys = @cloak_l_t4_upkeep_alloys
		# }
	# }

	# modifier = {
		# ship_cloaking_strength_add = @cloaking_very_low_strength
	# }

	# triggered_ship_modifier = {
		# potential = {
			# is_cloaked = yes
		# }
		# modifier = {
			# ship_shield_reduction = 0.5
		# }
	# }
	# custom_tooltip = "CLOAKING_DARK_MATTER_TOOLTIP"

	# ship_limit = 1
	# blocked_by = {
		# BATTLESHIP_CLOAKING_PSI
	# }
	# potential = {
		# ship_uses_battleship_cloaks = yes
	# }
	# prerequisites = { "tech_cloaking_dark_matter" }
	# component_set = "CLOAKING_DARK_MATTER"
	# ai_tags = {
		# gunship_stealth
		# explosive_stealth
		# carrier_stealth
		# screen_stealth
		# artillery_stealth
		# brawler_stealth
		# energy_torpedoes_stealth
		# buffer_role_stealth
		# debuffer_role_stealth
	# }
	# ai_weight = {
		# weight = @dark_matter_cloaking_weight
		# modifier = {
			# factor = 0
			# no_resource_for_component = { RESOURCE = exotic_gases }
		# }
		# modifier = {
			# factor = 0
			# no_resource_for_component = { RESOURCE = sr_dark_matter }
		# }
		# inline_script = ship_components/weights/roles_cloaking_devices
	# }
# }

# utility_component_template = {
	# key = "BATTLESHIP_CLOAKING_PSI"
	# size = aux
	# icon = "GFX_ship_part_cloak_psi"
	# icon_frame = 1
	# power = @power_L5
	# resources = {
		# category = ship_components
		# cost = {
			# alloys = @cloak_l_t5_cost_alloys
			# rare_crystals = @cloak_l_t5_cost_strategic_resources
			# sr_zro = @cloak_l_cost_sr_zro
		# }
		# upkeep = {
			# trigger = {
				# from = {
					# country_uses_bio_ships = no
				# }
			# }
			# energy = @cloak_l_t5_upkeep_energy
		# }
		# upkeep = {
			# trigger = {
				# from = {
					# country_uses_bio_ships = yes
				# }
			# }
			# food = @cloak_l_t5_upkeep_energy
		# }
		# upkeep = {
			# alloys = @cloak_l_t5_upkeep_alloys
		# }
	# }

	# modifier = {
		# ship_cloaking_strength_add = @cloaking_low_strength
	# }

	# triggered_ship_modifier = {
		# potential = {
			# is_cloaked = yes
			# has_non_psionic_shields = yes
		# }
		# modifier = {
			# ship_shield_reduction = 1
		# }
	# }
	# custom_tooltip = "CLOAKING_PSI_TOOLTIP"

	# ship_limit = 1
	# blocked_by = {
		# BATTLESHIP_CLOAKING_DARK_MATTER
	# }
	# potential = {
		# ship_uses_battleship_cloaks = yes
	# }
	# prerequisites = { "tech_cloaking_psi" }
	# component_set = "CLOAKING_PSI"
	# ai_tags = {
		# gunship_stealth
		# explosive_stealth
		# carrier_stealth
		# screen_stealth
		# artillery_stealth
		# brawler_stealth
		# energy_torpedoes_stealth
		# buffer_role_stealth
		# debuffer_role_stealth
	# }
	# ai_weight = {
		# weight = @psi_cloaking_weight
		# modifier = {
			# factor = 0
			# no_resource_for_component = { RESOURCE = sr_zro }
		# }
		# modifier = {
			# factor = 0
			# no_resource_for_component = { RESOURCE = rare_crystals }
		# }
		# inline_script = ship_components/weights/roles_cloaking_devices
	# }
# }

#######################################
# Science Ships and Observation Posts #
#######################################

# These go in a unique ship component slot and are automatically
# equipped when the relevant technology is researched.


utility_component_template = {
	key = "SCIENCE_CLOAKING_EMPTY"
	size = small
	icon = "GFX_ship_part_empty_ftl_drive"
	icon_frame = 1
	power = 0

	potential = {
		ship_uses_civilian_cloaks = yes
	}
	prerequisites = { }
	component_set = "science_cloaking_components"
	upgrades_to = "SCIENCE_CLOAKING_1"

	ai_weight = {
		weight = 5
	}
}

utility_component_template = {
	key = "SCIENCE_CLOAKING_1"
	size = small
	icon = "GFX_ship_part_cloak_1"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_low_strength
	}
	inline_script = ship_components/cloaking_ship_shield_reduction
	custom_tooltip = "CLOAKING_1_TOOLTIP"

	potential = {
		ship_uses_civilian_cloaks = yes
	}
	prerequisites = { "tech_cloaking_1" }
	component_set = "science_cloaking_components"
	upgrades_to = "SCIENCE_CLOAKING_2"

	ai_weight = {
		weight = @basic_cloaking_weight
	}
}

utility_component_template = {
	key = "SCIENCE_CLOAKING_2"
	size = small
	icon = "GFX_ship_part_cloak_2"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_low_strength
	}
	inline_script = ship_components/cloaking_ship_shield_reduction
	custom_tooltip = "CLOAKING_2_TOOLTIP"

	potential = {
		ship_uses_civilian_cloaks = yes
	}
	prerequisites = { "tech_cloaking_2" }
	component_set = "science_cloaking_components"
	upgrades_to = "SCIENCE_CLOAKING_3"

	ai_weight = {
		weight = @advanced_cloaking_weight
	}
}

utility_component_template = {
	key = "SCIENCE_CLOAKING_3"
	size = small
	icon = "GFX_ship_part_cloak_3"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_medium_strength
	}
	inline_script = ship_components/cloaking_ship_shield_reduction
	custom_tooltip = "CLOAKING_3_TOOLTIP"

	potential = {
		ship_uses_civilian_cloaks = yes
	}
	prerequisites = { "tech_cloaking_3" }
	component_set = "science_cloaking_components"
	upgrades_to = "SCIENCE_CLOAKING_DARK_MATTER"

	ai_weight = {
		weight = @elite_cloaking_weight
	}
}

utility_component_template = {
	key = "SCIENCE_CLOAKING_DARK_MATTER"
	size = small
	icon = "GFX_ship_part_cloak_dark_matter"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_high_strength
	}
	inline_script = ship_components/dark_matter_cloaking_ship_shield_reduction
	custom_tooltip = "CLOAKING_DARK_MATTER_TOOLTIP"

	potential = {
		ship_uses_civilian_cloaks = yes
	}
	prerequisites = { "tech_cloaking_dark_matter" }
	component_set = "science_cloaking_components"
	upgrades_to = "SCIENCE_CLOAKING_PSI"

	ai_weight = {
		weight = @dark_matter_cloaking_weight
	}
}

utility_component_template = {
	key = "SCIENCE_CLOAKING_PSI"
	size = small
	icon = "GFX_ship_part_cloak_psi"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_high_strength
	}
	inline_script = ship_components/psi_cloaking_ship_shield_reduction
	custom_tooltip = "CLOAKING_PSI_TOOLTIP"

	potential = {
		ship_uses_civilian_cloaks = yes
	}
	prerequisites = { "tech_cloaking_psi" }
	component_set = "science_cloaking_components"

	ai_weight = {
		weight = @psi_cloaking_weight
	}
}

#####################################################
# Gravity Snares - Cloaking Devices (Grand Archive) #
#####################################################

# These go in a unique ship component slot and are automatically
# equipped when the relevant technology is researched.

utility_component_template = {
	key = "GRAVITY_SNARE_CLOAKING_EMPTY"
	size = small
	icon = "GFX_ship_part_empty_ftl_drive"
	icon_frame = 1
	power = 0

	potential = {
		ship_uses_gravity_snare_cloaks = yes
	}
	prerequisites = { }
	component_set = "science_cloaking_components"
	upgrades_to = "GRAVITY_SNARE_CLOAKING_1"

	ai_weight = {
		weight = 5
	}
}

utility_component_template = {
	key = "GRAVITY_SNARE_CLOAKING_1"
	size = small
	icon = "GFX_ship_part_cloak_1"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_low_strength
		ship_capture_chance_add = 0.03
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_1_TOOLTIP"

	potential = {
		ship_uses_gravity_snare_cloaks = yes
	}
	prerequisites = { "tech_cloaking_1" }
	component_set = "science_cloaking_components"
	upgrades_to = "GRAVITY_SNARE_CLOAKING_2"

	ai_weight = {
		weight = @basic_cloaking_weight
	}
}

utility_component_template = {
	key = "GRAVITY_SNARE_CLOAKING_2"
	size = small
	icon = "GFX_ship_part_cloak_2"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_low_strength
		ship_capture_chance_add = 0.06
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_2_TOOLTIP"

	potential = {
		ship_uses_gravity_snare_cloaks = yes
	}
	prerequisites = { "tech_cloaking_2" }
	component_set = "science_cloaking_components"
	upgrades_to = "GRAVITY_SNARE_CLOAKING_3"

	ai_weight = {
		weight = @advanced_cloaking_weight
	}
}

utility_component_template = {
	key = "GRAVITY_SNARE_CLOAKING_3"
	size = small
	icon = "GFX_ship_part_cloak_3"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_medium_strength
		ship_capture_chance_add = 0.09
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}
	custom_tooltip = "CLOAKING_3_TOOLTIP"

	potential = {
		ship_uses_gravity_snare_cloaks = yes
	}
	prerequisites = { "tech_cloaking_3" }
	component_set = "science_cloaking_components"
	upgrades_to = "GRAVITY_SNARE_CLOAKING_DARK_MATTER"

	ai_weight = {
		weight = @elite_cloaking_weight
	}
}

utility_component_template = {
	key = "GRAVITY_SNARE_CLOAKING_DARK_MATTER"
	size = small
	icon = "GFX_ship_part_cloak_dark_matter"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_high_strength
		ship_capture_chance_add = 0.12
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
		}
		modifier = {
			ship_shield_reduction = 0.5
		}
	}
	custom_tooltip = "CLOAKING_DARK_MATTER_TOOLTIP"

	potential = {
		ship_uses_gravity_snare_cloaks = yes
	}
	prerequisites = { "tech_cloaking_dark_matter" }
	component_set = "science_cloaking_components"
	upgrades_to = "GRAVITY_SNARE_CLOAKING_PSI"

	ai_weight = {
		weight = @dark_matter_cloaking_weight
	}
}

utility_component_template = {
	key = "GRAVITY_SNARE_CLOAKING_PSI"
	size = small
	icon = "GFX_ship_part_cloak_psi"
	icon_frame = 1
	power = 0

	modifier = {
		ship_cloaking_strength_add = @cloaking_very_high_strength
		ship_capture_chance_add = 0.15
	}

	triggered_ship_modifier = {
		potential = {
			is_cloaked = yes
			has_non_psionic_shields = yes
		}
		modifier = {
			ship_shield_reduction = 1
		}
	}

	custom_tooltip = "CLOAKING_PSI_TOOLTIP"

	potential = {
		ship_uses_gravity_snare_cloaks = yes
	}
	prerequisites = { "tech_cloaking_psi" }
	component_set = "science_cloaking_components"

	ai_weight = {
		weight = @psi_cloaking_weight
	}
}
