# ##################################################
#
# Radial Effect / Aura components
#
# ##################################################

### Variables

@shipAuraRange = 80
@stationSmallAuraRange = 70
@stationMediumAuraRange = 90
@stationLargeAuraRange = 110


### Empty Aura-slot
utility_component_template = {
	key = "SHIP_AURA_EMPTY"
	size = small
	icon = "GFX_ship_part_empty_ftl_drive"
	icon_frame = 1
	power = 0

	component_set = "ship_aura_components"

	ai_weight = {
		weight = 1
	}
}

### Empty Aura-slot
utility_component_template = {
	key = "STATION_SMALL_AURA_EMPTY"
	size = small
	icon = "GFX_ship_part_empty_ftl_drive"
	icon_frame = 1
	power = 0

	component_set = "station_small_aura_components"

	ai_weight = {
		weight = 1
	}
}

### Empty Aura-slot
utility_component_template = {
	key = "STATION_MEDIUM_AURA_EMPTY"
	size = small
	icon = "GFX_ship_part_empty_ftl_drive"
	icon_frame = 1
	power = 0

	component_set = "station_medium_aura_components"

	ai_weight = {
		weight = 1
	}
}

### Empty Aura-slot
utility_component_template = {
	key = "STATION_LARGE_AURA_EMPTY"
	size = small
	icon = "GFX_ship_part_empty_ftl_drive"
	icon_frame = 1
	power = 0

	component_set = "station_large_aura_components"

	ai_weight = {
		weight = 1
	}
}

# #################
# Reworked Auras
# #################

#Offensive
utility_component_template = {
	key = "SHIP_AURA_SHIELD_DAMPENER"
	size = medium
	icon = "GFX_ship_part_aura_shield_dampener"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_titan_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	hostile_aura = {
		name = "aura_shield_dampener"
		radius = @shipAuraRange
		apply_on = ships

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = hostile_shield_dampener
			priority = 1
		}

		modifier = {
			ship_shield_mult = -0.20
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

utility_component_template = {
	key = "SHIP_AURA_QUANTUM_DESTABILIZER"
	size = medium
	icon = "GFX_ship_part_aura_quantum_destabilizer"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_titan_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	hostile_aura = {
		name = "aura_quantum_destabilizer"
		radius = @shipAuraRange
		apply_on = ships

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = hostile_quantum_destabilizer
			priority = 10
		}

		modifier = {
			ship_fire_rate_mult = -0.10
		}
	}

	ai_weight = {
		weight = 10
	}
}

utility_component_template = {
	key = "SHIP_AURA_SUBSPACE_SNARE"
	size = medium
	icon = "GFX_ship_part_aura_snare"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_titan_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	hostile_aura = {
		name = "aura_ship_subspace_snare"
		radius = @shipAuraRange
		apply_on = fleets

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = hostile_snare_aura
			priority = 1
		}

		modifier = {
			ship_emergency_ftl_min_days_mult = 1
			ship_disengage_chance_mult = -0.20
		}
	}

	ai_weight = {
		weight = 10
	}
}

#Defensive
utility_component_template = {
	key = "SHIP_AURA_INSPIRING_PRESENCE"
	size = medium
	icon = "GFX_ship_part_aura_inspiring_presence"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_titan_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_inspiring_presence"
		radius = @shipAuraRange
		apply_on = ships

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_inspiring_presence
			priority = 20
		}

		modifier = {
			ship_fire_rate_mult = 0.05
		}
	}

	ai_weight = {
		weight = 10
	}
}

utility_component_template = {
	key = "SHIP_AURA_TARGETING_GRID"
	size = medium
	icon = "GFX_ship_part_aura_targeting_grid"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_titan_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_targeting_grid"
		radius = @shipAuraRange
		apply_on = ships

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_targeting_grid
			priority = 20
		}

		modifier = {
			ship_tracking_add = 10
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2.0
			is_ai = yes
			is_preferred_weapons = weapon_type_kinetic
		}
	}
}

utility_component_template = {
	key = "SHIP_AURA_NANOBOT_CLOUD"
	size = medium
	icon = "GFX_ship_part_aura_nanobot"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_titan_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_nanobot_cloud"
		radius = @shipAuraRange
		apply_on = ships

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_nanobot_cloud
			priority = 20
		}

		modifier = {
			ship_hull_regen_add_perc = 0.05
			ship_armor_regen_add_perc = 0.15
		}
	}

	ai_weight = {
		weight = 10
	}
}

utility_component_template = { #Archaeo Detection Scrambler
	key = "SHIP_AURA_DETECTION_SCRAMBLER"
	size = medium
	icon = "GFX_ship_part_aura_detection_scrambler"
	icon_frame = 1
	power = 0

	resources = {
		category = ship_components
		cost = {
			minor_artifacts = @minor_artifacts_cost_xl
		}
	}

	potential = {
		ship_uses_titan_components = yes
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_detection_scrambler"
		radius = @shipAuraRange
		apply_on = ships

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_detection_scrambler
			priority = 20
		}

		modifier = { #This Archaeo component doesn't get bonus effect from the AP
			ship_evasion_add = 5
		}
	}

	prerequisites = { "tech_archaeo_detection_scrambler" }

	ai_weight = {
		weight = 10
	}
}

# #################
# Hostile Auras
# #################

utility_component_template = {
	key = "STATION_MEDIUM_AURA_SHIELD_DAMPENER"
	size = medium
	icon = "GFX_ship_part_aura_shield_dampener"
	icon_frame = 1
	power = 0
	hidden = yes

	component_set = "station_medium_aura_components"

	hostile_aura = {
		name = "aura_shield_dampener"
		radius = @stationMediumAuraRange
		apply_on = ships

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = hostile_inhibitor_aura
			priority = 1
		}

		modifier = {
			ship_shield_mult = -0.25
			ship_shield_regen_add_perc = -0.05
		}
	}

	ai_weight = {
		weight = 10
	}
}

# ####################
# Juggernaut Auras
# ####################

# Strike Craft
utility_component_template = {
	key = "SHIP_AURA_STRIKE_CRAFT"
	size = medium
	icon = "GFX_ship_part_aura_strike_craft"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_juggernaut_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_strike_craft"
		system_wide = yes

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_strike_craft
			priority = 1
		}

		modifier = {
			weapon_type_strike_craft_weapon_damage_mult = 0.2
			weapon_type_strike_craft_speed_mult = 0.2
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

# Weapon Range
utility_component_template = {
	key = "SHIP_AURA_RANGE"
	size = medium
	icon = "GFX_ship_part_aura_range"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_juggernaut_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_range"
		system_wide = yes

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_range
			priority = 1
		}

		modifier = {
			ship_weapon_range_mult = 0.4
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

# Hyperlane
utility_component_template = {
	key = "SHIP_AURA_HYPERLANE"
	size = medium
	icon = "GFX_ship_part_aura_hyperlane"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_starbase_components = yes
			ship_uses_juggernaut_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_hyperlane"
		system_wide = yes

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_hyperlane
			priority = 1
		}

		modifier = {
			ship_windup_mult = -0.4
			ship_winddown_mult = -0.4
			ship_jumpdrive_cooldown_mult = -0.4
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

# PD Penetration
utility_component_template = {
	key = "SHIP_AURA_PD_PENETRATION"
	size = medium
	icon = "GFX_ship_part_aura_pd_penetration"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			ship_uses_juggernaut_components = yes
			ship_uses_dsc_components = yes
		}
	}
	component_set = "ship_aura_components"

	hostile_aura = {
		name = "aura_pd_penetration"
		system_wide = yes

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = hostile_pd_penetration
			priority = 1
		}

		modifier = {
			weapon_type_point_defense_weapon_damage_mult = -0.3
			weapon_type_point_defense_weapon_fire_rate_mult = -0.3
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

# Bombardment
utility_component_template = {
	key = "SHIP_AURA_BOMBARDMENT"
	size = medium
	icon = "GFX_ship_part_aura_bombardment"
	icon_frame = 1
	power = 0

	potential = {
		ship_uses_juggernaut_components = yes
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_bombardment"
		system_wide = yes

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = friendly_bombardment
			priority = 1
		}

		modifier = {
			ship_orbital_bombardment_mult = 0.3
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

###################
# Offspring Auras #
###################

utility_component_template = {
	key = "SHIP_AURA_OFFSPRING"
	size = medium
	icon = "GFX_offspring_aura"
	icon_frame = 1
	power = 0

	potential = {
		OR = {
			from = {
				country_uses_bio_ships = no
			}
			is_arkship_ship = yes
		}
		ship_uses_offspring_components = yes
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "OFFSPRING_AURA"
		system_wide = yes

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = offspring_aura
			priority = 1
		}
		limit = {
			exists = owner
			owner = { has_origin = origin_progenitor_hive }
		}
		modifier = {
			ship_military_speed_mult = 0.55
			ship_evasion_mult = 0.55
			ship_fire_rate_mult = 0.55
			ship_accuracy_mult = 0.55
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

utility_component_template = {
	key = "SHIP_BIO_AURA_OFFSPRING"
	size = medium
	icon = "GFX_offspring_aura"
	icon_frame = 1
	power = 0

	potential = {
		is_arkship_ship = no
		from = {
			country_uses_bio_ships = yes
		}
		ship_uses_offspring_components = yes
	}
	component_set = "ship_aura_components"

	ship_modifier = {
		bioship_growth_progress_add = 2
	}

	friendly_aura = {
		name = "OFFSPRING_AURA"
		system_wide = yes

		stack_info = {			#A ship can only be affected by one aura of a certain id. If multiple auras have the same ID the one with the highest priority will be applied.
			id = offspring_aura
			priority = 1
		}
		limit = {
			exists = owner
			owner = { has_origin = origin_progenitor_hive }
		}
		modifier = {
			ship_military_speed_mult = 0.55
			ship_evasion_mult = 0.55
			ship_fire_rate_mult = 0.55
			ship_accuracy_mult = 0.55
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			is_ai = yes
			is_preferred_weapons = weapon_type_energy
		}
	}
}

utility_component_template = {
	key = "SHIP_AURA_BATTLEFIELD_REPAIRS"
	size = medium
	icon = "GFX_ship_part_aura_battlefield_repairs"
	icon_frame = 1
	power = 0

	potential = {
		is_ship_size = constructor
	}
	component_set = "ship_aura_components"

	friendly_aura = {
		name = "aura_battlefield_repairs"
		system_wide = yes
		apply_on = ships

		stack_info = {
			id = friendly_battlefield_repairs
			priority = 20
		}

		modifier = {
			ship_hull_regen_add_perc = 0.05
		}
	}

	ai_weight = {
		weight = 10
	}
}

utility_component_template = {
	key = "SHIP_AURA_ELECTROMAGNETIC_DISRUPTOR"
	size = medium
	icon = "GFX_ship_part_aura_snare"
	icon_frame = 1
	power = 0

	potential = {
		is_ship_size = science
	}
	component_set = "ship_aura_components"

	hostile_aura = {
		name = "aura_electromagnetic_disruptor"
		system_wide = yes
		apply_on = ships

		stack_info = {
			id = hostile_electromagnetic_disruptor
			priority = 20
		}

		limit = {
			OR = {
				AND = {
					exists = owner
					owner = { is_machine_empire = yes }
				}
				has_sapient_combat_computer = yes
				has_autonomous_combat_computer = yes
			}
		}

		modifier = {
			ship_accuracy_mult = -0.25
			ship_fire_rate_mult = -0.25
			ship_speed_reduction = 0.25
		}
	}

	ai_weight = {
		weight = 10
	}
}
