# Psionic Auras
# -----------------------
#	patron = <patron_type>				# Key of the Psionic Patron of this Aura type (optional)
#	background = "GFX_X"				# Will also require "GFX_X_header"
#										# If not defined, this aura will not automatically appear throught Covenant, but it can still be spawned via script
# 	on_start = {}						# Effects when the Aura is created
# 	on_gain_level = {}					# Effects when Aura's intensity gains a level
# 	on_progress_complete = {}			# Effects when Aura's intensity has reached its maximum value (depends on intensity levels, overrides on_gain_level)
# 	on_vanish = {}						# Effects when Aura's intensity is below 0 (called when Psionic Aura is destroyed, so it doesn't support randomness)
# 	on_monthly = {}						# Effects executed monthly after every aura has updated its progress
#
# 	triggered_system_modifier = {}		# Triggered modifier applying to every system affected by the aura (scope = system)
#								Additionally these common modifiers, are implemented triggered modifiers to fleets and planets
#								automatically depending on their owner and its relation with the aura owner
#	owner_fleet_modifier = {}			# Triggered modifier applying to fleets owned by the aura owner affected by the aura (scope = fleet)
#	rival_fleet_modifier = {}			# Triggered modifier applying to fleets owned by empires hostile to the aura owner (rivals or at war with) affected by the aura (scope = fleet)
#	neutral_fleet_modifier = {}			# Triggered modifier applying to every other fleets affected by the aura (scope = fleet)
#	owner_planet_modifier = {}			# Triggered modifier applying to planets owned by the aura owner affected by the aura (scope = planet)
#	rival_planet_modifier = {}			# Triggered modifier applying to planets owned by empires hostile to the aura owner (rivals or at war with) affected by the aura (scope = planet)
#	neutral_planet_modifier = {}		# Triggered modifier applying to every other planets affected by the aura (scope = planet)
#
#	Note on scopes used by triggers: every scope has a FROM scope which corresponds to the aura owner
#
# -----------------------
# Each Aura has an associated Intensity value from 0 to the completion value (generated by the end of the final intensity level).
# Intensity is divided in one or more levels. Each level can have different modifiers associated with it.
#
# intensity_level = {					# Use this keyword to list all intensity levels, in the correct order. You need at least one.
# 		end = 40						# Where the level ends and the next one starts.
#										# Determines the end value of the Intensity and triggers on_progress_complete, if it is the final level.
# 		on_enter_level = {}				# Effects when we enter this level
# 		triggered_system_modifier = {}	# Triggered modifier applying to the current system (only during this level) (scope = current system)
#									Additionally these common modifiers, are implemented triggered modifiers to fleets and planets
#									automatically depending on their owner and its relation with the aura owner
#		owner_fleet_modifier = {}		# Triggered modifier applying to fleets owned by the aura owner in the current system (only during this level) (scope = fleet)
#		rival_fleet_modifier = {}		# Triggered modifier applying to fleets owned by empires hostile to the aura owner (rivals or at war with) in the current system (only during this level) (scope = fleet)
#		neutral_fleet_modifier = {}		# Triggered modifier applying to every other fleets in the current system (only during this level) (scope = fleet)
#		owner_planet_modifier = {}		# Triggered modifier applying to planets owned by the aura owner in the current system (only during this level) (scope = planet)
#		rival_planet_modifier = {}		# Triggered modifier applying to planets owned by empires hostile to the aura owner (rivals or at war with) in the current system (only during this level) (scope = planet)
#		neutral_planet_modifier = {}	# Triggered modifier applying to every other planets in the current system (only during this level) (scope = planet)
# 		custom_tooltip = x				# this will print in the level tooltip
#		ai_weight_coefficient = value	# Coefficient used in the following function: sqrt( military_power x abs(value) ) (default: 0)
#										# Allows AIs to know if they want to go inside this aura or not. Only used by the Aura of the Exiled for now.
#										# Negative coefficients will negatively impact cached military power, vice-versa for positive coefficients
#										# Should be adapted alongside modifiers (evasion and fire rate are the modifiers affection military power the most)
# }
#
# Intensity value can exclusively tick up or down. Down ticks can be calculated daily or monthly, while up ticks are calculated monthly.
# Each scripted value is preceded by a trigger for optimization purposes. Triggers must be true before calculating scripted values.
# Intensity can't grow if its intensity is ticking down. Hence, down tick is calculated first, and if its value > 0, increase isn't calculated.
#
# daily_decrease = {
# 	base = 0							# default progress
# 	modifier = { 						# Standard weight fields, you can do everything that common/script_values/00_script_values.txt tells you about
# 		add = 2
# 		desc = federation_acceptance_reduce_fleet 	# Do not forget to add loc tooltips (the game will scream at you otherwise)
# 		<triggers>
# 	}
# }
#
# increase_trigger = {
# 	<triggers>
# }
# monthly_increase = {
# 	base = 1							# default monthly progress
# 	modifier = { 						# Standard weight fields, you can do everything that common/script_values/00_script_values.txt tells you about
# 		add = 2
# 		desc = federation_acceptance_reduce_fleet 	# Do not forget to add loc tooltips (the game will scream at you otherwise)
# 		<triggers>
# 	}
# }
#
# aura_galaxy_texture = "texture"		# Textures used for galaxy view (star and hyperlane)
# aura_hyperlane_texture = "texture"
#

eater_aura = {
	patron = the_eater_of_worlds
	background = "GFX_aura_eater_background"

	intensity_level = {
		end = 1000
		owner_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = 0.03
				ship_disengage_chance_mult = 0.15
			}
		}
		owner_planet_modifier = {
			modifier = {
				job_soldier_stability_add = 0.05
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = 0.03
			}
		}
		neutral_planet_modifier = {
			modifier = {
				job_soldier_stability_add = 0.05
			}
		}
		rival_fleet_modifier = {
			potential = {
				OR = {
					is_scope_type = no_scope # Shroud view has no scope
					is_scope_type = galactic_object # Tooltips have current system as scope
					is_ship_class = shipclass_starbase
				}
			}
			modifier = {
				custom_tooltip = eater_aura_starbase_rival_modifier_level_1_tooltip
				ship_fire_rate_mult = @eater_aura_fire_rate_rival_level_1
			}
		}
		rival_planet_modifier = {
			modifier = {
				army_damage_mult = -0.1
				army_morale_damage_mult = -0.1
			}
		}
	}
	intensity_level = {
		end = 2000
		owner_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = 0.05
				ship_disengage_chance_mult = 0.25
			}
		}
		owner_planet_modifier = {
			modifier = {
				job_soldier_stability_add = 0.08
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = 0.05
			}
		}
		neutral_planet_modifier = {
			modifier = {
				job_soldier_stability_add = 0.08
			}
		}
		rival_fleet_modifier = {
			potential = {
				OR = {
					is_scope_type = no_scope # Shroud view has no scope
					is_scope_type = galactic_object # Tooltips have current system as scope
					is_ship_class = shipclass_starbase
				}
			}
			modifier = {
				custom_tooltip = eater_aura_starbase_rival_modifier_level_2_tooltip
				ship_fire_rate_mult = @eater_aura_fire_rate_rival_level_2
			}
		}
		rival_planet_modifier = {
			modifier = {
				army_damage_mult = -0.15
				army_morale_damage_mult = -0.15
			}
		}
	}
	intensity_level = {
		end = 2500
		owner_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = 0.07
				ship_disengage_chance_mult = 0.5
			}
		}
		owner_planet_modifier = {
			modifier = {
				job_soldier_stability_add = 0.15
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = 0.07
			}
		}
		neutral_planet_modifier = {
			modifier = {
				job_soldier_stability_add = 0.15
			}
		}
		rival_fleet_modifier = {
			potential = {
				OR = {
					is_scope_type = no_scope # Shroud view has no scope
					is_scope_type = galactic_object # Tooltips have current system as scope
					is_ship_class = shipclass_starbase
				}
			}
			modifier = {
				custom_tooltip = eater_aura_starbase_rival_modifier_level_3_tooltip
				ship_fire_rate_mult = @eater_aura_fire_rate_rival_level_3
			}
		}
		rival_planet_modifier = {
			modifier = {
				army_damage_mult = -0.2
				army_morale_damage_mult = -0.2
			}
		}
	}

	inline_script = {
		script = shroud/psionic_aura_definition
		TYPE = eater_aura
	}

	aura_galaxy_texture = "gfx/map/psionic_auras/eater_aura.dds"
	aura_hyperlane_texture = "gfx/map/psionic_auras/eater_aura_hyperlane.dds"
}

souls_aura = {
	patron = the_cradle_of_souls
	background = "GFX_aura_cradle_background"

	intensity_level = {
		end = 1000
		owner_planet_modifier = {
			modifier = {
				planet_stability_add = 1
				planet_jobs_unity_produces_mult = 0.05
			}
		}
		neutral_planet_modifier = {
			modifier = {
				planet_jobs_unity_produces_mult = 0.05
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = -0.05
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_stability_add = -2
			}
		}
	}
	intensity_level = {
		end = 2000
		owner_planet_modifier = {
			modifier = {
				planet_stability_add = 3
				planet_jobs_unity_produces_mult = 0.1
			}
		}
		neutral_planet_modifier = {
			modifier = {
				planet_jobs_unity_produces_mult = 0.1
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = -0.07
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_stability_add = -4
			}
		}
	}
	intensity_level = {
		end = 2500
		owner_planet_modifier = {
			modifier = {
				planet_stability_add = 4
				planet_jobs_unity_produces_mult = 0.15
			}
		}
		neutral_planet_modifier = {
			modifier = {
				planet_jobs_unity_produces_mult = 0.15
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = -0.1
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_stability_add = -6
			}
		}
	}

	inline_script = {
		script = shroud/psionic_aura_definition
		TYPE = souls_aura
	}

	aura_galaxy_texture = "gfx/map/psionic_auras/souls_aura.dds"
	aura_hyperlane_texture = "gfx/map/psionic_auras/souls_aura_hyperlane.dds"
}

composer_aura = {
	patron = the_composer_of_strands
	background = "GFX_aura_composer_background"

	intensity_level = {
		end = 1000
		owner_fleet_modifier = {
			modifier = {
				ship_speed_mult = 0.05
			}
		}
		owner_planet_modifier = {
			modifier = {
				logistic_growth_mult = 0.03
				planet_pop_assembly_mult = 0.03
				bonus_pop_growth_mult = 0.03
				deposit_blockers_natural_unity_produces_add = 10
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_speed_mult = 0.05
			}
		}
		neutral_planet_modifier = {
			modifier = {
				logistic_growth_mult = 0.03
				planet_pop_assembly_mult = 0.03
				bonus_pop_growth_mult = 0.03
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_speed_mult = -0.05
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_building_build_speed_mult = -0.15
			}
		}
	}
	intensity_level = {
		end = 2000
		owner_fleet_modifier = {
			modifier = {
				ship_speed_mult = 0.1
			}
		}
		owner_planet_modifier = {
			modifier = {
				logistic_growth_mult = 0.05
				planet_pop_assembly_mult = 0.05
				bonus_pop_growth_mult = 0.05
				deposit_blockers_natural_unity_produces_add = 20
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_speed_mult = 0.1
			}
		}
		neutral_planet_modifier = {
			modifier = {
				logistic_growth_mult = 0.05
				planet_pop_assembly_mult = 0.05
				bonus_pop_growth_mult = 0.05
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_speed_mult = -0.1
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_building_build_speed_mult = -0.3
			}
		}
	}
	intensity_level = {
		end = 2500
		owner_fleet_modifier = {
			modifier = {
				ship_speed_mult = 0.15
			}
		}
		owner_planet_modifier = {
			modifier = {
				logistic_growth_mult = 0.07
				planet_pop_assembly_mult = 0.07
				bonus_pop_growth_mult = 0.07
				deposit_blockers_natural_unity_produces_add = 30
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_speed_mult = 0.15
			}
		}
		neutral_planet_modifier = {
			modifier = {
				logistic_growth_mult = 0.07
				planet_pop_assembly_mult = 0.07
				bonus_pop_growth_mult = 0.07
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_speed_mult = -0.15
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_building_build_speed_mult = -0.45
			}
		}
	}

	inline_script = {
		script = shroud/psionic_aura_definition
		TYPE = composer_aura
	}

	aura_galaxy_texture = "gfx/map/psionic_auras/composer_aura.dds"
	aura_hyperlane_texture = "gfx/map/psionic_auras/composer_aura_hyperlane.dds"
}

desire_aura = {
	patron = the_instrument_of_desire
	background = "GFX_aura_instrument_background"

	intensity_level = {
		end = 1000
		owner_fleet_modifier = {
			modifier = {
				ship_hull_mult = 0.1
				ship_armor_mult = 0.1
			}
		}
		owner_planet_modifier = {
			modifier = {
				custom_tooltip = desire_aura_planet_self_modifier_level_1_tooltip
				planet_buildings_volatile_motes_upkeep_mult = @desire_aura_upkeep_level_1
				planet_buildings_exotic_gases_upkeep_mult = @desire_aura_upkeep_level_1
				planet_buildings_rare_crystals_upkeep_mult = @desire_aura_upkeep_level_1
			}
		}
		owner_planet_modifier = {
			modifier = {
				planetary_ascension_cost_mult = -0.1
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_hull_mult = 0.05
				ship_armor_mult = 0.05
			}
		}
		neutral_planet_modifier = {
			modifier = {
				custom_tooltip = desire_aura_planet_neutral_modifier_level_1_tooltip
				planet_buildings_volatile_motes_upkeep_mult = @desire_aura_upkeep_neutral_level_1
				planet_buildings_exotic_gases_upkeep_mult = @desire_aura_upkeep_neutral_level_1
				planet_buildings_rare_crystals_upkeep_mult = @desire_aura_upkeep_neutral_level_1
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_hull_mult = -0.05
				ship_armor_mult = -0.05
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_pops_upkeep_mult = 0.1
			}
		}
	}
	intensity_level = {
		end = 2000
		owner_fleet_modifier = {
			modifier = {
				ship_hull_mult = 0.2
				ship_armor_mult = 0.2
			}
		}
		owner_planet_modifier = {
			modifier = {
				custom_tooltip = desire_aura_planet_self_modifier_level_2_tooltip
				planet_buildings_volatile_motes_upkeep_mult = @desire_aura_upkeep_level_2
				planet_buildings_exotic_gases_upkeep_mult = @desire_aura_upkeep_level_2
				planet_buildings_rare_crystals_upkeep_mult = @desire_aura_upkeep_level_2
			}
		}
		owner_planet_modifier = {
			modifier = {
				planetary_ascension_cost_mult = -0.2
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_hull_mult = 0.1
				ship_armor_mult = 0.1
			}
		}
		neutral_planet_modifier = {
			modifier = {
				custom_tooltip = desire_aura_planet_neutral_modifier_level_2_tooltip
				planet_buildings_volatile_motes_upkeep_mult = @desire_aura_upkeep_neutral_level_2
				planet_buildings_exotic_gases_upkeep_mult = @desire_aura_upkeep_neutral_level_2
				planet_buildings_rare_crystals_upkeep_mult = @desire_aura_upkeep_neutral_level_2
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_hull_mult = -0.1
				ship_armor_mult = -0.1
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_pops_upkeep_mult = 0.15
			}
		}
	}
	intensity_level = {
		end = 2500
		owner_fleet_modifier = {
			modifier = {
				ship_hull_mult = 0.3
				ship_armor_mult = 0.3
			}
		}
		owner_planet_modifier = {
			modifier = {
				custom_tooltip = desire_aura_planet_self_modifier_level_3_tooltip
				planet_buildings_volatile_motes_upkeep_mult = @desire_aura_upkeep_level_3
				planet_buildings_exotic_gases_upkeep_mult = @desire_aura_upkeep_level_3
				planet_buildings_rare_crystals_upkeep_mult = @desire_aura_upkeep_level_3
			}
		}
		owner_planet_modifier = {
			modifier = {
				planetary_ascension_cost_mult = -0.3
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_hull_mult = 0.15
				ship_armor_mult = 0.15
			}
		}
		neutral_planet_modifier = {
			modifier = {
				custom_tooltip = desire_aura_planet_neutral_modifier_level_3_tooltip
				planet_buildings_volatile_motes_upkeep_mult = @desire_aura_upkeep_neutral_level_3
				planet_buildings_exotic_gases_upkeep_mult = @desire_aura_upkeep_neutral_level_3
				planet_buildings_rare_crystals_upkeep_mult = @desire_aura_upkeep_neutral_level_3
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_hull_mult = -0.15
				ship_armor_mult = -0.15
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_pops_upkeep_mult = 0.2
			}
		}
	}

	inline_script = {
		script = shroud/psionic_aura_definition
		TYPE = desire_aura
	}

	aura_galaxy_texture = "gfx/map/psionic_auras/desire_aura.dds"
	aura_hyperlane_texture = "gfx/map/psionic_auras/desire_aura_hyperlane.dds"
}

whisperers_aura = {
	patron = whisperers_in_the_void
	background = "GFX_aura_whisperers_background"

	intensity_level = {
		end = 1000
		owner_fleet_modifier = {
			modifier = {
				ship_tracking_mult = 0.05
			}
		}
		owner_fleet_modifier = {
			potential = {
				has_first_contact_dlc = yes
			}
			modifier = {
				ship_cloaking_strength_add = 1
			}
		}
		owner_planet_modifier = {
			modifier = {
				planet_researchers_upkeep_mult = -0.1
				station_researchers_produces_mult = 0.2
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_tracking_mult = 0.03
			}
		}
		neutral_planet_modifier = {
			modifier = {
				station_researchers_produces_mult = 0.1
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_evasion_mult = -0.1
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_researchers_upkeep_mult = 0.1
			}
		}
	}
	intensity_level = {
		end = 2000
		owner_fleet_modifier = {
			modifier = {
				ship_tracking_mult = 0.1
			}
		}
		owner_fleet_modifier = {
			potential = {
				has_first_contact_dlc = yes
			}
			modifier = {
				ship_cloaking_strength_add = 2
			}
		}
		owner_planet_modifier = {
			modifier = {
				planet_researchers_upkeep_mult = -0.15
				station_researchers_produces_mult = 0.4
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_tracking_mult = 0.05
			}
		}
		neutral_fleet_modifier = {
			potential = {
				has_first_contact_dlc = yes
			}
			modifier = {
				ship_cloaking_strength_add = 1
			}
		}
		neutral_planet_modifier = {
			modifier = {
				station_researchers_produces_mult = 0.2
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_evasion_mult = -0.15
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_researchers_upkeep_mult = 0.15
			}
		}
	}
	intensity_level = {
		end = 2500
		owner_fleet_modifier = {
			modifier = {
				ship_tracking_mult = 0.15
			}
		}
		owner_fleet_modifier = {
			potential = {
				has_first_contact_dlc = yes
			}
			modifier = {
				ship_cloaking_strength_add = 2
			}
		}
		owner_planet_modifier = {
			modifier = {
				planet_researchers_upkeep_mult = -0.2
				station_researchers_produces_mult = 0.6
			}
		}
		neutral_fleet_modifier = {
			modifier = {
				ship_tracking_mult = 0.07
			}
		}
		neutral_fleet_modifier = {
			potential = {
				has_first_contact_dlc = yes
			}
			modifier = {
				ship_cloaking_strength_add = 1
			}
		}
		neutral_planet_modifier = {
			modifier = {
				station_researchers_produces_mult = 0.3
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_evasion_mult = -0.2
			}
		}
		rival_fleet_modifier = {
			potential = {
				has_first_contact_dlc = yes
			}
			modifier = {
				ship_cloaking_strength_add = -1
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_researchers_upkeep_mult = 0.2
			}
		}
	}

	inline_script = {
		script = shroud/psionic_aura_definition
		TYPE = whisperers_aura
	}

	aura_galaxy_texture = "gfx/map/psionic_auras/whisperers_aura.dds"
	aura_hyperlane_texture = "gfx/map/psionic_auras/whisperers_aura_hyperlane.dds"
}

exiled_aura = {
	intensity_level = {
		end = 1000
		rival_fleet_modifier = {
			modifier = {
				ship_fire_rate_mult = -1.25
				ship_shield_mult = -2
				ship_evasion_mult = -1
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_jobs_produces_mult = -0.3
				planet_pops_upkeep_mult = 1
				building_time_mult = 1
			}
		}
		ai_weight_coefficient = -3.33
	}

	on_start = {
		on_psionic_aura_spawned = {
			TYPE = end_aura
			NO_IMMUNE = yes
		}
		# Exiled Aura has only one level
		spawn_psionic_aura_object = {
			TYPE = end_aura
			LEVEL = 2
		}
		spawn_psionic_aura_object = {
			TYPE = end_aura
			LEVEL = 3
		}
		setup_aura_clashing = yes
	}
	on_monthly = {
		setup_aura_clashing_monthly = yes
	}
	on_progress_complete = {
		custom_tooltip = try_spread_aura_tt
		random_neighbor_system = {
			limit = {
				has_psionic_aura = no
				is_psionic_aura_suppressed = no
				OR = {
					AND = {
						exists = space_owner
						space_owner = { is_same_value = event_target:mindwarden_country@root.aura_owner }
					}
					has_star_flag = mindwarden_buffer_system
				}
			}
			spawn_psionic_aura = {
				owner = root.aura_owner
				type = exiled_aura
				update_type = no
			}
			if = {
				limit = {
					has_star_flag = mindwarden_buffer_system
				}
				event_target:mindwarden_country@root.aura_owner = {
					country_event = { id = shroud.6200 }
				}
			}
			else_if = {
				limit = {
					has_star_flag = mindwarden_system
				}
				event_target:mindwarden_country@root.aura_owner = {
					country_event = { id = shroud.6225 }
				}
			}
		}
	}
	on_vanish = {
		on_psionic_aura_vanishing = yes
	}

	increase_trigger = {
		OR = {
			years_passed >= 15
			AND = {
				has_psionic_aura = yes
				aura_owner = { has_country_flag = exiled_aura_should_expand }
			}
		}
	}
	monthly_increase = {
		base = 10
	}

	inline_script = "shroud/psionic_aura_daily_decrease"
	inline_script = "shroud/psionic_aura_monthly_decrease"

	aura_galaxy_texture = "gfx/map/psionic_auras/end_aura.dds"
	aura_hyperlane_texture = "gfx/map/psionic_auras/end_aura_hyperlane.dds"
}

end_aura = {
	patron = end_of_the_cycle
	background = "GFX_aura_end_background"

	intensity_level = {
		end = value:eotc_lvl1_end
		owner_fleet_modifier = {
			modifier = {
				ships_upkeep_mult = -0.1
			}
		}
		owner_fleet_modifier = {
			potential = {
				is_scope_type = fleet # We don't want that to show in tooltip
				exists = leader
				leader = { has_trait = leader_trait_disciple_of_the_end }
			}
			modifier = {
				ship_ftl_jumpdrive_range_mult = @disciple_of_the_end_jumpdrive_range
			}
		}
		owner_planet_modifier = {
			modifier = {
				station_researchers_produces_mult = 0.33
				station_gatherers_produces_mult = 0.33
				planet_jobs_produces_mult = 0.33
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_stability_add = -6
				planet_jobs_upkeep_mult = 0.12
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_monthly_hull_damage = 5
			}
		}
	}
	intensity_level = {
		end = value:eotc_lvl2_end
		owner_fleet_modifier = {
			modifier = {
				ships_upkeep_mult = -0.2
			}
		}
		owner_fleet_modifier = {
			potential = {
				is_scope_type = fleet # We don't want that to show in tooltip
				exists = leader
				leader = { has_trait = leader_trait_disciple_of_the_end }
			}
			modifier = {
				ship_ftl_jumpdrive_range_mult = @disciple_of_the_end_jumpdrive_range
			}
		}
		owner_planet_modifier = {
			modifier = {
				station_researchers_produces_mult = 0.66
				station_gatherers_produces_mult = 0.66
				planet_jobs_produces_mult = 0.66
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_stability_add = -12
				planet_jobs_upkeep_mult = 0.24
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_monthly_hull_damage = 10
			}
		}
	}
	intensity_level = {
		end = value:eotc_lvl3_end
		owner_fleet_modifier = {
			modifier = {
				ships_upkeep_mult = -0.3
			}
		}
		owner_fleet_modifier = {
			potential = {
				is_scope_type = fleet # We don't want that to show in tooltip
				exists = leader
				leader = { has_trait = leader_trait_disciple_of_the_end }
			}
			modifier = {
				ship_ftl_jumpdrive_range_mult = @disciple_of_the_end_jumpdrive_range
			}
		}
		owner_planet_modifier = {
			modifier = {
				station_researchers_produces_mult = 1.0
				station_gatherers_produces_mult = 1.0
				planet_jobs_produces_mult = 1.0
			}
		}
		rival_planet_modifier = {
			modifier = {
				planet_stability_add = -18
				planet_jobs_upkeep_mult = 0.36
			}
		}
		rival_fleet_modifier = {
			modifier = {
				ship_monthly_hull_damage = 15
			}
		}
	}

	on_start = {
		on_psionic_aura_spawned = { TYPE = end_aura }
		check_psionic_suppression_eligibility = yes
		setup_aura_clashing = yes
		# Encountering EotC aura event
		if = {
			limit = {
				exists = owner
				owner = {
					NOR = {
						is_same_value = root.aura_owner
						has_country_flag = has_encountered_end_aura
					}
				}
			}
			owner = {
				country_event = {
					id = shroud.4950
					scopes = {
						from = root
						fromfrom = root.aura_owner
					}
				}
				set_country_flag = has_encountered_psionic_auras
				set_country_flag = has_encountered_end_aura
				if = {
					limit = { is_ai = yes }
					give_technology = { tech = tech_psionic_suppression }
					if = {
						limit = {
							NOT = { has_technology = tech_mine_zro }
						}
						add_tech_option_or_research_effect = {
							TECH = tech_mine_zro
							PROGRESS = 0.1
							CATEGORY = society_research
						}
					}
					if = {
						limit = { is_nomadic = no }
						if = {
							limit = {
								NOT = {
									any_planet_within_border = {
										has_zro_deposit = yes
									}
								}
							}
							random_planet_within_border = {
								limit = {
									OR = {
										has_deposit_for = shipclass_research_station
										has_deposit = no
									}
								}
								add_deposit = d_zro_deposit_1
							}
						}
					}
					else = {
						if = {
							limit = {
								NOT = {
									any_owned_nonprimary_starbase = {
										is_waystation_starbase = yes
										solar_system = {
											any_system_planet = {
												has_zro_deposit = yes
											}
										}
									}
								}
							}
							random_owned_nonprimary_starbase = {
								limit = { is_waystation_starbase = yes }
								solar_system = {
									random_system_planet = {
										limit = {
											OR = {
												has_deposit_for = shipclass_research_station
												has_deposit = no
											}
										}
										add_deposit = d_zro_deposit_1
									}
								}
							}
						}
					}
				}
			}
		}
		every_neighbor_system = {
			limit = {
				exists = owner
				owner = {
					NOR = {
						is_same_value = root.aura_owner
						has_country_flag = has_encountered_end_aura
					}
				}
			}
			owner = {
				country_event = {
					id = shroud.4950
					scopes = {
						from = root
						fromfrom = root.aura_owner
					}
				}
				set_country_flag = has_encountered_psionic_auras
				set_country_flag = has_encountered_end_aura
				if = {
					limit = { is_ai = yes }
					give_technology = { tech = tech_psionic_suppression }
					if = {
						limit = {
							NOT = { has_technology = tech_mine_zro }
						}
						add_tech_option_or_research_effect = {
							TECH = tech_mine_zro
							PROGRESS = 0.1
							CATEGORY = society_research
						}
					}
					if = {
						limit = { is_nomadic = no }
						if = {
							limit = {
								NOT = {
									any_planet_within_border = {
										has_zro_deposit = yes
									}
								}
							}
							random_planet_within_border = {
								limit = {
									OR = {
										has_deposit_for = shipclass_research_station
										has_deposit = no
									}
								}
								add_deposit = d_zro_deposit_1
							}
						}
					}
					else = {
						if = {
							limit = {
								NOT = {
									any_owned_nonprimary_starbase = {
										is_waystation_starbase = yes
										solar_system = {
											any_system_planet = {
												has_zro_deposit = yes
											}
										}
									}
								}
							}
							random_owned_nonprimary_starbase = {
								limit = { is_waystation_starbase = yes }
								solar_system = {
									random_system_planet = {
										limit = {
											OR = {
												has_deposit_for = shipclass_research_station
												has_deposit = no
											}
										}
										add_deposit = d_zro_deposit_1
									}
								}
							}
						}
					}
				}
			}
		}
		# EotC aura coverage events
		aura_owner = {
			if = {
				if = {
					limit = {
						NOT = { has_country_flag = end_aura_coverage_second_event_triggered }
						check_variable_arithmetic = {
							which = value:num_end_cycle_galaxy_systems_percent
							value >= 0.75
						}
					}
					set_country_flag = end_aura_coverage_second_event_triggered
					every_playable_country = {
						limit = {
							NOT = { is_same_value = root.aura_owner }
						}
						country_event = {
							id = shroud.4965
							scopes = {
								from = root.aura_owner
							}
						}
					}
				}
				else_if = {
					limit = {
						NOT = { has_country_flag = end_aura_coverage_first_event_triggered }
						check_variable_arithmetic = {
							which = value:num_end_cycle_galaxy_systems_percent
							value >= 0.5
						}
					}
					set_country_flag = end_aura_coverage_first_event_triggered
					every_playable_country = {
						limit = {
							NOT = { is_same_value = root.aura_owner }
						}
						country_event = {
							id = shroud.4960
							scopes = {
								from = root.aura_owner
							}
						}
					}
				}
			}
			# Check win con
			check_end_aura_win_condition = yes
		}
	}
	on_monthly = {
		setup_aura_clashing_monthly = yes
	}
	on_gain_level = {
		spread_aura_endlessly = yes
		add_psionic_aura_level_visual = { TYPE = end_aura }
	}
	on_lose_level = {
		remove_psionic_aura_level_visual = yes
	}
	on_progress_complete = {
		spread_aura_endlessly = yes
		hidden_effect = {
			set_aura_intensity = value:eotc_lvl2_end
		}
	}
	on_type_change = {
		update_psionic_aura_visuals = { TYPE = end_aura }
	}
	on_vanish = {
		on_psionic_aura_vanishing = yes
	}

	inline_script = "shroud/psionic_aura_daily_decrease"
	monthly_decrease = {
		base = 0
		modifier = {
			subtract = @aura_clashing_loser_decrease
			any_neighbor_system = {
				has_star_flag = aura_clash_winning_against_@root
			}
			desc = BLANK_STRING
		}
	}

	increase_trigger = {
		# EotC owner has tech_aura_intensification by default
		NOT = {
			any_neighbor_system = {
				has_star_flag = aura_is_clashing_against_@root
			}
		}
	}
	monthly_increase = { # Final value must be >= 0
		base = 0
		modifier = {
			add = value:calc_psionic_aura_monthly_increase
			desc = tech_psionic_aura
		}
		modifier = {
			add = value:count_command_fleets_in_system
			any_fleet_in_system = { is_owned_by = root.aura_owner }
			desc = tech_psionic_aura
		}
		modifier = {
			add = @psionic_offices_intensity
			has_star_flag = building_psionic_offices_emitting@root.aura_owner
			desc = tech_psionic_aura
		}
		modifier = {
			add = @psionic_offices_intensity
			has_star_flag = waystation_aura_emitting@root.aura_owner
			desc = INTENSITY_FROM_AURA_EMITTERS
		}
	}

	triggered_system_modifier = {
		potential = {
			has_global_flag = shroud_seals_disabled
		}
		custom_tooltip = intensification_accord_aura_tt
	}

	triggered_system_modifier = {
		potential = {
			NOT = { is_scope_type = no_scope }
			has_psionic_aura = yes
			aura_owner = {
				check_variable = {
					which = fractalization_accord_activation
					value > 0
				}
			}
			exists = owner
			owner = { is_same_value = prev.aura_owner }
		}
		custom_tooltip = fractalization_effect_tt
		station_gatherers_produces_mult = 1.0
		station_researchers_produces_mult = 1.0
		mult = aura_owner.fractalization_accord_activation
	}

	aura_galaxy_texture = "gfx/map/psionic_auras/end_aura.dds"
	aura_hyperlane_texture = "gfx/map/psionic_auras/end_aura_hyperlane.dds"
}
