################################
#
# Federations Events
# Written by Stephen Muray
#
###############################

namespace = federations

### Community: Project Cornucopia

# Project Cornucopia granted
country_event = {
	id = federations.10000
	title = "federations.10000.name"
	desc = "federations.10000.desc"
	picture = GFX_evt_engineering_research
	show_sound = event_laboratory_sound

	is_triggered_only = yes

	option = {
		name = progress.2.a.mech # Acknowledged.
	}
}

# Greater Than Ourselves
country_event = {
	id = federations.10010
	title = "federations.10010.name"

	desc = {
		trigger = {
			is_gestalt = no
		}
		text = "federations.10010.desc"
	}
	desc = {
		trigger = {
			is_gestalt = yes
			is_wilderness_empire = no
		}
		text = "federations.10010.desc_gestalt"
	}
	desc = {
		trigger = {
			is_wilderness_empire = yes
		}
		text = "federations.10010.desc_wilderness"
	}

	picture = GFX_evt_alien_propaganda
	show_sound = event_conversation

	is_triggered_only = yes

	option = {
		name = EXCELLENT

		custom_tooltip = "greater_than_ourselves_tooltip"
	}
}

# Extradimensional Experimentation
country_event = {
	id = federations.10020
	title = "federations.10020.name"

	desc = {
		trigger = {
			is_gestalt = no
		}
		text = "federations.10020.desc"
	}
	desc = {
		trigger = {
			is_gestalt = yes
		}
		text = "federations.10020.desc_gestalt"
	}

	picture = GFX_evt_clocks
	show_sound = event_laboratory_sound

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		custom_tooltip = "extradimensional_experimentation_tooltip"
		if = {
			limit = {
				NOR = {
					has_tech_option = tech_mine_zro
					has_technology = tech_mine_zro
				}
			}
			add_research_option = tech_mine_zro
		}
	}
}

# test event to change federation type
country_event = {
	id = federations.type
	is_test_event = yes
	trigger = { always = no }
	title = "Change federation type"
	desc = NAME_Fluffy
	picture = GFX_evt_zro_1

	option = {
		name = "default_federation"
		trigger = {
			has_federation = yes
			federation = {
				NOT = { has_federation_type = default_federation }
			}
		}
		federation = {
			set_federation_type = default_federation
		}
	}

	option = {
		name = "trade_federation"
		trigger = {
			has_federation = yes
			federation = {
				NOT = { has_federation_type = trade_federation }
			}
		}
		federation = {
			set_federation_type = trade_federation
		}
	}

	option = {
		name = "research_federation"
		trigger = {
			has_federation = yes
			federation = {
				NOT = { has_federation_type = research_federation }
			}
		}
		federation = {
			set_federation_type = research_federation
		}
	}

	option = {
		name = "military_federation"
		trigger = {
			has_federation = yes
			federation = {
				NOT = { has_federation_type = military_federation }
			}
		}
		federation = {
			set_federation_type = military_federation
		}
	}

	option = {
		name = "hegemony_federation"
		trigger = {
			has_federation = yes
			federation = {
				NOT = { has_federation_type = hegemony_federation }
			}
		}
		federation = {
			set_federation_type = hegemony_federation
		}
	}

	option = {
		name = graygoo.500.d
	}
}

# Events for after resolutions with breach effects pass.

# Advanced Xenostudies
country_event = {
	id = federations.10100
	title = "resolution_galacticstudies_advanced_xenostudies"

	desc = {
		text = "federations.10100.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		name = FED_WE_MUST_COMPLY

		allow = {
			OR = {
				AND = {
					has_policy_flag = ai_outlawed
					can_set_policy = {
						policy = artificial_intelligence_policy
						option = ai_servitude
					}
				}
				AND = {
					has_policy_flag = interference_not_allowed
					can_set_policy = {
						policy = interference
						option = interference_active
					}
				}
			}
		}

		breach_fix_resolution_galacticstudies_advanced_xenostudies = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				has_ethic = "ethic_spiritualist"
				has_ethic = "ethic_fanatic_spiritualist"
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		if = {
			limit = {
				has_policy_flag = ai_outlawed
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		if = {
			limit = {
				has_policy_flag = interference_not_allowed
				can_set_policy = {
					policy = interference
					option = interference_active
				}
			}
			set_policy_cooldown = interference
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				has_ethic = "ethic_spiritualist"
				has_ethic = "ethic_fanatic_spiritualist"
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		if = {
			limit = {
				has_policy_flag = ai_outlawed
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		if = {
			limit = {
				has_policy_flag = interference_not_allowed
				can_set_policy = {
					policy = interference
					option = interference_active
				}
			}
			set_policy_cooldown = interference
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Ethical Guideline Refactoring
country_event = {
	id = federations.10110
	title = "resolution_galacticstudies_ethical_guideline_refactoring"

	desc = {
		text = "federations.10110.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		name = FED_WE_MUST_COMPLY

		trigger = {
			has_technology = tech_capacity_boosters
			NOT = { has_policy_flag = leader_enhancement_capacity_boosters }
		}

		allow = {
			NOR = {
				has_ethic = "ethic_egalitarian"
				has_ethic = "ethic_fanatic_egalitarian"
			}
			can_set_policy = {
				policy = leader_enhancement
				option = leader_enhancement_capacity_boosters
			}
		}

		set_policy = {
			policy = leader_enhancement
			option = leader_enhancement_capacity_boosters
			cooldown = yes
		}

		custom_tooltip = "federations.10110.capacity_boosters"

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_MUST_COMPLY

		trigger = {
			NOT = { has_technology = tech_capacity_boosters }
			has_technology = tech_selected_lineages
			has_policy_flag = leader_enhancement_natural_selection
		}

		allow = {
			NOT = { has_ethic = "ethic_fanatic_egalitarian" }
			can_set_policy = {
				policy = leader_enhancement
				option = leader_enhancement_selected_lineages
			}
		}

		set_policy = {
			policy = leader_enhancement
			option = leader_enhancement_selected_lineages
			cooldown = yes
		}

		custom_tooltip = "federations.10110.selected_lineages"

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				has_ethic = "ethic_egalitarian"
				has_ethic = "ethic_fanatic_egalitarian"
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		if = {
			limit = {
				OR = {
					AND = {
						has_technology = tech_capacity_boosters
						can_set_policy = {
							policy = leader_enhancement
							option = leader_enhancement_capacity_boosters
						}
					}
					AND = {
						NOT = { has_technology = tech_capacity_boosters }
						has_technology = tech_selected_lineages
						has_policy_flag = leader_enhancement_natural_selection
						can_set_policy = {
							policy = leader_enhancement
							option = leader_enhancement_selected_lineages
						}
					}
				}
			}
			set_policy_cooldown = leader_enhancement
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				has_ethic = "ethic_egalitarian"
				has_ethic = "ethic_fanatic_egalitarian"
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Five Year Plans
country_event = {
	id = federations.10200
	title = "resolution_greatergood_five_year_plans"

	desc = {
		text = "federations.10200.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		name = FED_WE_MUST_COMPLY

		breach_fix_resolution_greatergood_five_year_plans_normal = yes

		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				OR = {
					has_ethic = "ethic_authoritarian"
					has_ethic = "ethic_fanatic_authoritarian"
				}
			}
		}
	}

	option = {
		name = FED_THE_BAREST_MINIMUM

		trigger = {
			OR = {
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
			}
		}

		breach_fix_resolution_greatergood_five_year_plans_stratified = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Greater Than Ourselves
country_event = {
	id = federations.10210
	title = "resolution_greatergood_greater_than_ourselves"

	desc = {
		text = "federations.10210.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = { # Is militarist so can create battle thralls
		trigger = {
			is_militarist = yes
			any_owned_species = {
				has_citizenship_type = { type = citizenship_slavery country = prev }
			}
			NOT = {
				any_owned_species = {
					has_living_standard = { type = living_standard_dystopian_society country = prev }
				}
			}
		}

		name = "federations.10210.complythralls"

		breach_fix_resolution_greatergood_greater_than_ourselves_living_standards = yes
		breach_fix_resolution_greatergood_greater_than_ourselves_thralls = yes

		ai_chance = {
			factor = 5
		}
	}

	option = { # Will create domestic servants
		trigger = {
			is_gestalt = no
			any_owned_species = {
				has_citizenship_type = { type = citizenship_slavery country = prev }
			}
			NOT = {
				any_owned_species = {
					has_living_standard = { type = living_standard_dystopian_society country = prev }
				}
			}
		}

		name = "federations.10210.complyservants"

		breach_fix_resolution_greatergood_greater_than_ourselves_living_standards = yes
		breach_fix_resolution_greatergood_greater_than_ourselves_servants = yes

		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				is_militarist = yes
			}
		}
	}

	option = { # Living Standards Only
		trigger = {
			is_gestalt = no
			OR = {
				NOT = {
					any_owned_species = {
						has_citizenship_type = { type = citizenship_slavery country = prev }
					}
				}
				any_owned_species = {
					has_living_standard = { type = living_standard_dystopian_society country = prev }
				}
			}
		}

		name = "FED_WE_MUST_COMPLY"

		breach_fix_resolution_greatergood_greater_than_ourselves_living_standards = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Balance in the Middle
country_event = {
	id = federations.10220
	title = "resolution_greatergood_balance_in_the_middle"

	desc = {
		text = "federations.10220.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		trigger = {
			is_gestalt = no
			NOR = {
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
			}
		}

		name = "FED_WE_MUST_COMPLY"

		breach_fix_resolution_greatergood_balance_in_the_middle = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		trigger = {
			is_gestalt = yes
		}

		name = "federations.10210.gestalt"

		breach_fix_resolution_greatergood_balance_in_the_middle_gestalt = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
				has_valid_civic = civic_dystopian_society
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Universal Prosperity Mandate
country_event = {
	id = federations.10230
	title = "resolution_greatergood_universal_prosperity_mandate"

	desc = {
		text = "federations.10230.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		trigger = {
			is_gestalt = no
			any_owned_species = {
				is_sapient = yes
				OR = {
					has_living_standard = { type = living_standard_subsistence country = prev }
					has_living_standard = { type = living_standard_stratified country = prev }
					has_living_standard = { type = living_standard_normal country = prev }
					has_living_standard = { type = living_standard_academic_privilege country = prev }
					has_living_standard = { type = living_standard_good country = prev }
					has_living_standard = { type = living_standard_decadent country = prev }
				}
			}
		}

		allow = {
			OR = {
				has_ethic = "ethic_egalitarian"
				has_ethic = "ethic_fanatic_egalitarian"
			}
		}

		name = "federations.10230.utopian"

		breach_fix_resolution_greatergood_universal_prosperity_mandate_utopian = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		trigger = {
			is_gestalt = no
			any_owned_species = {
				is_sapient = yes
				OR = {
					has_living_standard = { type = living_standard_subsistence country = prev }
					has_living_standard = { type = living_standard_stratified country = prev }
					has_living_standard = { type = living_standard_normal country = prev }
					has_living_standard = { type = living_standard_academic_privilege country = prev }
					has_living_standard = { type = living_standard_good country = prev }
					has_living_standard = { type = living_standard_decadent country = prev }
				}
			}
		}

		allow = {
			has_technology = "tech_subdermal_stimulation"
		}

		name = "federations.10230.chemical"

		breach_fix_resolution_greatergood_universal_prosperity_mandate_chemical = yes

		ai_chance = {
			factor = 2
			modifier = {
				factor = 0
				OR = {
					has_ethic = "ethic_egalitarian"
					has_ethic = "ethic_fanatic_egalitarian"
				}
			}
		}
	}

	option = {
		trigger = {
			is_gestalt = yes
		}

		name = "federations.10210.gestalt"

		# Same fix as Balance in the Middle
		breach_fix_resolution_greatergood_balance_in_the_middle_gestalt = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_civic = "civic_machine_assimilator"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
				has_valid_civic = civic_dystopian_society
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				has_ethic = "ethic_authoritarian"
				has_ethic = "ethic_fanatic_authoritarian"
				has_valid_civic = civic_indentured_assets
				has_valid_civic = civic_slaver_guilds
				has_valid_civic = civic_dystopian_society
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}

	option = {
		name = "federations.10230.assimilator"

		trigger = {
			has_civic = "civic_machine_assimilator"
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 10
		}
	}
}

# Reverence for Life
country_event = {
	id = federations.10300
	title = "resolution_rulesofwar_reverence_for_life"

	desc = {
		text = "federations.10300.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		name = "FED_WE_MUST_COMPLY"

		breach_fix_resolution_rulesofwar_reverence_for_life = yes

		allow = {
			OR = {
				can_set_policy = {
					policy = purge
					option = purge_displacement_only
				}
				can_set_policy = {
					policy = nomad_deterrence
					option = nomad_deterrence_do_no_harm
				}
			}
		}
		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			is_xenophobe = no
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = purge
					option = purge_displacement_only
				}
			}
			set_policy_cooldown = purge
		}
		if = {
			limit = {
				has_policy_flag = arkship_raid_purge_pops
				can_set_policy = {
					policy = nomad_deterrence
					option = nomad_deterrence_do_no_harm
				}
			}
			set_policy_cooldown = nomad_deterrence
		}
		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			is_xenophobe = yes
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Independent Tribunals
country_event = {
	id = federations.10310
	title = "resolution_rulesofwar_independent_tribunals"

	desc = {
		text = "federations.10310.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		name = "FED_WE_MUST_COMPLY"

		breach_fix_resolution_rulesofwar_independent_tribunals = yes

		allow = {
			can_set_policy = {
				policy = orbital_bombardment
				option = orbital_bombardment_selective
			}
		}
		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				is_militarist = yes
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = orbital_bombardment
					option = orbital_bombardment_selective
				}
			}
			set_policy_cooldown = orbital_bombardment
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				is_militarist = yes
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = orbital_bombardment
					option = orbital_bombardment_selective
				}
			}
			set_policy_cooldown = orbital_bombardment
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Last Resort Doctrine
country_event = {
	id = federations.10320
	title = "resolution_rulesofwar_last_resort_doctrine"

	desc = {
		text = "federations.10320.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		name = "FED_WE_MUST_COMPLY"

		trigger = {
			NOT = { has_ethic = ethic_gestalt_consciousness }
		}
		allow = {
			can_set_policy = {
				policy = war_philosophy
				option = liberation_wars
			}
		}

		breach_fix_resolution_rulesofwar_last_resort_doctrine = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = "FED_WE_MUST_COMPLY"

		trigger = {
			has_ethic = ethic_gestalt_consciousness
		}
		allow = {
			can_set_policy = {
				policy = war_philosophy
				option = no_wars
			}
		}

		breach_fix_resolution_rulesofwar_last_resort_doctrine = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				is_militarist = yes
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		if = {
			limit = {
				OR = {
					AND = {
						is_gestalt = no
						can_set_policy = {
							policy = war_philosophy
							option = liberation_wars
						}
					}
					AND = {
						is_gestalt = yes
						can_set_policy = {
							policy = war_philosophy
							option = no_wars
						}
					}
				}
			}
			set_policy_cooldown = war_philosophy
		}
		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				is_militarist = yes
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = war_philosophy
					option = liberation_wars
				}
			}
			set_policy_cooldown = war_philosophy
		}
		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# Demobilization Initiative
country_event = {
	id = federations.10330
	title = "resolution_rulesofwar_demobilization_initiative"

	desc = {
		text = "federations.10330.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	option = {
		name = "FED_WE_MUST_COMPLY"

		allow = {
			can_set_policy = {
				policy = economic_policy
				option = economic_policy_balanced
			}
		}

		breach_fix_resolution_rulesofwar_demobilization_initiative = yes

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			NOR = {
				is_xenophobe = yes
				is_militarist = yes
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = economic_policy
					option = economic_policy_balanced
				}
			}
			set_policy_cooldown = economic_policy
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				is_xenophobe = yes
				is_militarist = yes
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = economic_policy
					option = economic_policy_balanced
				}
			}
			set_policy_cooldown = economic_policy
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}
}

# A Defined Purpose
country_event = {
	id = federations.10340
	title = "resolution_divinity_a_defined_purpose"

	desc = {
		text = "federations.10340.desc"
	}

	picture = GFX_evt_galactic_senate
	show_sound = event_factions

	is_triggered_only = yes

	immediate = {
		random_country = {
			limit = {
				is_country_type = default
				is_synthetic_empire = no
				is_gestalt = no
				is_galactic_community_member = yes
			}
			owner_species = { save_event_target_as = defined_purpose_random_species }
		}
	}

	option = {
		name = "FED_WE_MUST_COMPLY"

		breach_fix_resolution_divinity_a_defined_purpose_nonsynthetic = yes

		allow = {
			NOT = { has_country_flag = synthetic_empire }
			can_set_policy = {
				policy = artificial_intelligence_policy
				option = ai_servitude
			}
		}

		trigger = {
			is_machine_empire = no
		}

		ai_chance = {
			factor = 5
		}
	}

	option = {
		name = FED_WE_WILL_RETAIN

		trigger = {
			is_machine_empire = no
			NOT = { has_country_flag = synthetic_empire }
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = FED_WE_WILL_NOT_SUBMIT

		trigger = {
			OR = {
				has_country_flag = synthetic_empire
				is_xenophobe = yes
				has_ethic = "ethic_materialist"
				has_ethic = "ethic_fanatic_materialist"
			}
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"

		ai_chance = {
			factor = 2
		}
	}

	option = {
		name = "federations.10340.declinemachine"

		trigger = {
			is_machine_empire = yes
		}

		add_monthly_resource_mult = {
			resource = unity
			value = @tier2unityreward
			min = @tier2unitymin
			max = @tier2unitymax
		}

		if = {
			limit = {
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		custom_tooltip = "FED_WE_WILL_BE_IN_BREACH"
	}

	option = {
		name = "federations.10340.complybecomerogueservitor"

		trigger = {
			is_machine_empire = yes
			NOT = { has_valid_civic = civic_machine_servitor }
		}

		allow = {
			NOT = { has_valid_civic = civic_machine_assimilator }
		}

		breach_fix_resolution_divinity_a_defined_purpose_machine = yes

		ai_chance = {
			factor = 2
		}
	}
}

# FIX ALL THE THINGS (Fix everything we're in breach of) - occurs on decade pulse.
country_event = {
	id = federations.10400

	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_galactic_community_member = yes
		is_in_breach_of_any = yes
		NOT = { has_country_flag = fed_10400_ignore }
	}

	immediate = {
		country_event = { id = federations.10401 days = 30 random = 330 }
	}
}

country_event = {
	id = federations.10401
	title = federations.10400.title
	desc = federations.10400.desc
	picture = GFX_evt_signing
	show_sound = event_factions
	is_triggered_only = yes

	trigger = {
		is_galactic_community_member = yes
		is_in_breach_of_any = yes
		# Need to check if you are in breach of a pre-FTL Resolution due to Policies not event flags.
		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_equal_standing
				in_breach_of = resolution_pre_ftl_stances_equal_standing
			}
			OR = {
				has_policy_flag = interference_not_allowed
				has_policy_flag = interference_aggressive
			}
		}
		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_non_interference
				in_breach_of = resolution_pre_ftl_stances_non_interference
			}
			OR = {
				has_policy_flag = interference_active
				has_policy_flag = interference_aggressive
			}
		}
		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_exploitation
				in_breach_of = resolution_pre_ftl_stances_exploitation
			}
			has_policy_flag = interference_not_allowed
		}
		NOT = { has_country_flag = fed_10400_ignore }
	}

	immediate = {
		if = {
			limit = {
				is_active_resolution = resolution_divinity_a_defined_purpose
			}
			random_country = {
				limit = {
					is_country_type = default
					is_synthetic_empire = no
					is_gestalt = no
					is_galactic_community_member = yes
				}
				owner_species = { save_event_target_as = defined_purpose_random_species }
			}
		}

		random_relation = {
			limit = {
				any_owned_leader = {
					is_assigned_to_galcom = yes
				}
			}
			random_owned_leader = {
				limit = {
					is_assigned_to_galcom = yes
				}
				save_event_target_as = executed_envoy
			}
		}
	}

	# Refuse to comply
	option = {
		name = federations.10400.refuse
		custom_tooltip = FED_WE_WILL_BE_IN_BREACH
	}
	# Agree to comply
	option = {
		name = federations.10400.comply
		allow = {
			custom_tooltip = {
				fail_text = federations.10400.comply_fail_ethics
				NOT = {
					AND = {
						in_breach_of = resolution_galacticstudies_ethical_guideline_refactoring
						OR = {
							AND = {
								has_technology = tech_selected_lineages
								is_fanatic_egalitarian = yes
							}
							AND = {
								has_technology = tech_capacity_boosters
								is_egalitarian = yes
							}
						}
					}
				}
			}
			custom_tooltip = {
				fail_text = federations.10400.comply_fail_civics
				NOT = {
					AND = {
						has_valid_civic = civic_machine_assimilator
						OR = {
							is_active_resolution = resolution_divinity_a_defined_purpose
							is_active_resolution = resolution_greatergood_universal_prosperity_mandate
						}
					}
				}
				NOT = {
					AND = {
						OR = {
							is_active_resolution = resolution_greatergood_universal_prosperity_mandate
							is_active_resolution = resolution_greatergood_balance_in_the_middle
						}
						OR = {
							in_breach_of = resolution_greatergood_universal_prosperity_mandate
							in_breach_of = resolution_greatergood_balance_in_the_middle
						}
						OR = {
							has_valid_civic = civic_indentured_assets
							has_valid_civic = civic_slaver_guilds
						}
					}
				}
			}
			custom_tooltip = {
				fail_text = federations.10400.comply_fail_tech
				NOT = {
					AND = {
						is_active_resolution = resolution_greatergood_universal_prosperity_mandate
						is_egalitarian = no
						is_gestalt = no
						in_breach_of = resolution_greatergood_universal_prosperity_mandate
						NOT = { has_technology = tech_subdermal_stimulation }
					}
				}
			}
			custom_tooltip = {
				fail_text = federations.10400.comply_fail_ascension
				NOT = {
					AND = {
						is_synthetic_empire = yes
						is_active_resolution = resolution_divinity_a_defined_purpose
					}
				}
			}
			custom_tooltip = {
				fail_text = federations.10400.comply_fail_origin
				NAND = {
					AND = {
						has_origin = origin_scion
						exists = overlord
						overlord = { has_country_flag = scion_master }
					}
					is_active_resolution = resolution_galactic_focus_war_in_heaven_denounce_both
				}

			}
		}

		breach_fix_resolution_galacticstudies_advanced_xenostudies = yes
		breach_fix_resolution_galacticstudies_ethical_guideline_refactoring = yes

		# The Greater Good is way too complicated. We can go from the most extreme down.
		if = {
			limit = {
				is_active_resolution = resolution_greatergood_universal_prosperity_mandate
				in_breach_of = resolution_greatergood_universal_prosperity_mandate
				is_egalitarian = yes
			}
			breach_fix_resolution_greatergood_universal_prosperity_mandate_utopian = yes
		}
		else_if = {
			limit = {
				is_active_resolution = resolution_greatergood_universal_prosperity_mandate
				in_breach_of = resolution_greatergood_universal_prosperity_mandate
				has_technology = tech_subdermal_stimulation
				is_gestalt = no
			}
			breach_fix_resolution_greatergood_universal_prosperity_mandate_chemical = yes
		}
		else_if = {
			limit = {
				is_gestalt = yes
				OR = {
					AND = {
						is_active_resolution = resolution_greatergood_balance_in_the_middle
						in_breach_of = resolution_greatergood_balance_in_the_middle
					}
					AND = {
						is_active_resolution = resolution_greatergood_universal_prosperity_mandate
						in_breach_of = resolution_greatergood_universal_prosperity_mandate
						NOT = { has_civic = civic_machine_assimilator }
					}
				}
			}
			breach_fix_resolution_greatergood_balance_in_the_middle_gestalt = yes
		}
		else_if = {
			limit = {
				is_gestalt = no
				is_active_resolution = resolution_greatergood_balance_in_the_middle
				in_breach_of = resolution_greatergood_balance_in_the_middle
			}
			breach_fix_resolution_greatergood_balance_in_the_middle = yes
		}
		else_if = {
			limit = {
				is_active_resolution = resolution_greatergood_greater_than_ourselves
				in_breach_of = resolution_greatergood_greater_than_ourselves
				is_militarist = yes
			}
			breach_fix_resolution_greatergood_greater_than_ourselves_living_standards = yes
			breach_fix_resolution_greatergood_greater_than_ourselves_thralls = yes
		}
		else_if = {
			limit = {
				is_active_resolution = resolution_greatergood_greater_than_ourselves
				in_breach_of = resolution_greatergood_greater_than_ourselves
			}
			breach_fix_resolution_greatergood_greater_than_ourselves_living_standards = yes
			breach_fix_resolution_greatergood_greater_than_ourselves_servants = yes
		}
		else_if = {
			limit = {
				is_active_resolution = resolution_greatergood_five_year_plans
				in_breach_of = resolution_greatergood_five_year_plans
				is_authoritarian = yes
			}
			breach_fix_resolution_greatergood_five_year_plans_stratified = yes
		}
		else_if = {
			limit = {
				is_active_resolution = resolution_greatergood_five_year_plans
				in_breach_of = resolution_greatergood_five_year_plans
				is_authoritarian = no
			}
			breach_fix_resolution_greatergood_five_year_plans_normal = yes
		}

		breach_fix_resolution_rulesofwar_reverence_for_life = yes
		breach_fix_resolution_rulesofwar_independent_tribunals = yes
		breach_fix_resolution_rulesofwar_last_resort_doctrine = yes
		breach_fix_resolution_rulesofwar_demobilization_initiative = yes

		breach_fix_resolution_divinity_a_defined_purpose_nonsynthetic = yes
		breach_fix_resolution_divinity_a_defined_purpose_machine = yes

		breach_fix_resolution_resolution_pre_ftl_stances_equal_standing = yes
		breach_fix_resolution_resolution_pre_ftl_stances_non_interference = yes
		breach_fix_resolution_resolution_pre_ftl_stances_exploitation = yes

		ai_chance = {
			factor = 5
		}
	}
	# Discard and permanently ignore this
	option = {
		name = federations.10400.refuse_2
		custom_tooltip = FED_WE_WILL_BE_IN_BREACH
		custom_tooltip = federations.10400.refuse_2_tooltip
		hidden_effect = {
			set_country_flag = fed_10400_ignore
		}
		ai_chance = {
			factor = 0
		}
	}
	# Execute the Envoys
	option = {
		name = federations.10400.execute
		trigger = {
			OR = {
				is_imperial_authority = yes
				is_xenophobe = yes
				AND = {
					is_hive_empire = yes
					NOR = {
						NOT = { exists = event_target:executed_envoy }
						AND = {
							exists = event_target:executed_envoy
							event_target:executed_envoy = {
								NOR = {
									has_trait = trait_lithoid
									has_trait = trait_machine_unit
									has_trait = trait_mechanical
								}
							}
						}
					}
				}
			}
			is_xenophile = no
			is_pacifist = no
		}
		allow = {
			NOT = { has_valid_civic = civic_hive_empath }
		}

		custom_tooltip = FED_WE_WILL_BE_IN_BREACH
		custom_tooltip = federations.10400.refuse_2_tooltip
		custom_tooltip = federations.10400.execute_tooltip

		add_monthly_resource_mult = {
			resource = unity
			value = @tier3unityreward
			min = @tier3unitymin
			max = @tier3unitymax
		}

		if = {
			limit = {
				exists = event_target:executed_envoy
			}
			event_target:executed_envoy = {
				kill_leader = {
					show_notification = yes
				}
			}
		}

		hidden_effect = {
			set_country_flag = fed_10400_ignore
			set_country_flag = executed_galcom_envoys
			every_playable_country = {
				limit = {
					is_galactic_community_member = yes
					NOR = {
						is_same_value = root
						is_xenophobe = yes
					}
				}
				add_opinion_modifier = {
					who = root
					modifier = opinion_executed_galcom_envoys
				}
			}
		}

		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_advanced_xenostudies
				in_breach_of = resolution_galacticstudies_advanced_xenostudies
				has_policy_flag = ai_outlawed
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_advanced_xenostudies
				in_breach_of = resolution_galacticstudies_advanced_xenostudies
				has_policy_flag = interference_not_allowed
				can_set_policy = {
					policy = interference
					option = interference_active
				}
			}
			set_policy_cooldown = interference
		}

		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_ethical_guideline_refactoring
				in_breach_of = resolution_galacticstudies_ethical_guideline_refactoring
				OR = {
					AND = {
						has_technology = tech_capacity_boosters
						can_set_policy = {
							policy = leader_enhancement
							option = leader_enhancement_capacity_boosters
						}
					}
					AND = {
						NOT = { has_technology = tech_capacity_boosters }
						has_technology = tech_selected_lineages
						has_policy_flag = leader_enhancement_natural_selection
						can_set_policy = {
							policy = leader_enhancement
							option = leader_enhancement_selected_lineages
						}
					}
				}
			}
			set_policy_cooldown = leader_enhancement
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_reverence_for_life
				in_breach_of = resolution_rulesofwar_reverence_for_life
				can_set_policy = {
					policy = purge
					option = purge_displacement_only
				}
			}
			set_policy_cooldown = purge
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_independent_tribunals
				in_breach_of = resolution_rulesofwar_independent_tribunals
				can_set_policy = {
					policy = orbital_bombardment
					option = orbital_bombardment_selective
				}
			}
			set_policy_cooldown = orbital_bombardment
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_last_resort_doctrine
				in_breach_of = resolution_rulesofwar_last_resort_doctrine
				OR = {
					AND = {
						is_gestalt = no
						can_set_policy = {
							policy = war_philosophy
							option = liberation_wars
						}
					}
					AND = {
						is_gestalt = yes
						can_set_policy = {
							policy = war_philosophy
							option = no_wars
						}
					}
				}
			}
			set_policy_cooldown = war_philosophy
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_demobilization_initiative
				in_breach_of = resolution_rulesofwar_demobilization_initiative
				can_set_policy = {
					policy = economic_policy
					option = economic_policy_balanced
				}
			}
			set_policy_cooldown = economic_policy
		}

		if = {
			limit = {
				is_active_resolution = resolution_divinity_a_defined_purpose
				in_breach_of = resolution_divinity_a_defined_purpose
				is_synthetic_empire = no
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_equal_standing
				in_breach_of = resolution_pre_ftl_stances_equal_standing
				has_met_primitives = yes
				OR = {
					has_policy_flag = interference_not_allowed
					has_policy_flag = interference_aggressive
				}
				OR = {
					can_set_policy = {
						policy = interference
						option = interference_subtle
					}
					can_set_policy = {
						policy = interference
						option = interference_active
					}
				}
			}
			set_policy_cooldown = interference
		}

		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_non_interference
				in_breach_of = resolution_pre_ftl_stances_non_interference
				has_met_primitives = yes
				NOT = {
					has_policy_flag = interference_not_allowed
				}
				can_set_policy = {
					policy = interference
					option = interference_not_allowed
				}
			}
			set_policy_cooldown = interference
		}

		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_exploitation
				in_breach_of = resolution_pre_ftl_stances_exploitation
				has_met_primitives = yes
				OR = {
					has_policy_flag = interference_not_allowed
					has_policy_flag = interference_subtle
				}
				OR = {
					can_set_policy = {
						policy = interference
						option = interference_active
					}
					can_set_policy = {
						policy = interference
						option = interference_aggressive
					}
				}
			}
			set_policy_cooldown = interference
		}

		ai_chance = {
			factor = 0
		}
	}
	# Eat the Envoys
	option = {
		name = federations.10400.eat
		trigger = {
			OR = {
				is_hive_empire = yes
				has_origin = origin_necrophage
			}
			OR = {
				NOT = { exists = event_target:executed_envoy }
				AND = {
					exists = event_target:executed_envoy
					event_target:executed_envoy = {
						NOR = {
							has_trait = trait_lithoid
							has_trait = trait_machine_unit
							has_trait = trait_mechanical
						}
					}
				}
			}
		}

		allow = {
			NOT = { has_valid_civic = civic_hive_empath }
		}

		custom_tooltip = FED_WE_WILL_BE_IN_BREACH
		custom_tooltip = federations.10400.refuse_2_tooltip
		custom_tooltip = federations.10400.execute_tooltip

		add_monthly_resource_mult = {
			resource = unity
			value = @tier3unityreward
			min = @tier3unitymin
			max = @tier3unitymax
		}

		add_resource = {
			food = 1
		}

		if = {
			limit = {
				exists = event_target:executed_envoy
			}
			event_target:executed_envoy = {
				kill_leader = {
					show_notification = yes
				}
			}
		}

		hidden_effect = {
			set_country_flag = fed_10400_ignore
			set_country_flag = executed_galcom_envoys
			every_playable_country = {
				limit = {
					is_galactic_community_member = yes
					NOR = {
						is_same_value = root
						is_xenophobe = yes
					}
				}
				add_opinion_modifier = {
					who = root
					modifier = opinion_executed_galcom_envoys
				}
			}
		}

		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_advanced_xenostudies
				in_breach_of = resolution_galacticstudies_advanced_xenostudies
				has_policy_flag = ai_outlawed
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_advanced_xenostudies
				in_breach_of = resolution_galacticstudies_advanced_xenostudies
				NOR = {
					has_policy_flag = interference_not_allowed
					has_policy_flag = interference_subtle
				}
				can_set_policy = {
					policy = interference
					option = interference_active
				}
			}
			set_policy_cooldown = interference
		}

		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_ethical_guideline_refactoring
				in_breach_of = resolution_galacticstudies_ethical_guideline_refactoring
				OR = {
					AND = {
						has_technology = tech_capacity_boosters
						can_set_policy = {
							policy = leader_enhancement
							option = leader_enhancement_capacity_boosters
						}
					}
					AND = {
						NOT = { has_technology = tech_capacity_boosters }
						has_technology = tech_selected_lineages
						has_policy_flag = leader_enhancement_natural_selection
						can_set_policy = {
							policy = leader_enhancement
							option = leader_enhancement_selected_lineages
						}
					}
				}
			}
			set_policy_cooldown = leader_enhancement
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_reverence_for_life
				in_breach_of = resolution_rulesofwar_reverence_for_life
				can_set_policy = {
					policy = purge
					option = purge_displacement_only
				}
			}
			set_policy_cooldown = purge
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_independent_tribunals
				in_breach_of = resolution_rulesofwar_independent_tribunals
				can_set_policy = {
					policy = orbital_bombardment
					option = orbital_bombardment_selective
				}
			}
			set_policy_cooldown = orbital_bombardment
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_last_resort_doctrine
				in_breach_of = resolution_rulesofwar_last_resort_doctrine
				OR = {
					AND = {
						is_gestalt = no
						can_set_policy = {
							policy = war_philosophy
							option = liberation_wars
						}
					}
					AND = {
						is_gestalt = yes
						can_set_policy = {
							policy = war_philosophy
							option = no_wars
						}
					}
				}
			}
			set_policy_cooldown = war_philosophy
		}

		if = {
			limit = {
				is_active_resolution = resolution_rulesofwar_demobilization_initiative
				in_breach_of = resolution_rulesofwar_demobilization_initiative
				can_set_policy = {
					policy = economic_policy
					option = economic_policy_balanced
				}
			}
			set_policy_cooldown = economic_policy
		}

		if = {
			limit = {
				is_active_resolution = resolution_divinity_a_defined_purpose
				in_breach_of = resolution_divinity_a_defined_purpose
				is_synthetic_empire = no
				can_set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
				}
			}
			set_policy_cooldown = artificial_intelligence_policy
		}

		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_equal_standing
				in_breach_of = resolution_pre_ftl_stances_equal_standing
				has_met_primitives = yes
				OR = {
					has_policy_flag = interference_not_allowed
					has_policy_flag = interference_aggressive
				}
				OR = {
					can_set_policy = {
						policy = interference
						option = interference_subtle
					}
					can_set_policy = {
						policy = interference
						option = interference_active
					}
				}
			}
			set_policy_cooldown = interference
		}

		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_non_interference
				in_breach_of = resolution_pre_ftl_stances_non_interference
				has_met_primitives = yes
				NOT = {
					has_policy_flag = interference_not_allowed
				}
				can_set_policy = {
					policy = interference
					option = interference_not_allowed
				}
			}
			set_policy_cooldown = interference
		}

		if = {
			limit = {
				is_active_resolution = resolution_pre_ftl_stances_exploitation
				in_breach_of = resolution_pre_ftl_stances_exploitation
				has_met_primitives = yes
				OR = {
					has_policy_flag = interference_not_allowed
					has_policy_flag = interference_subtle
				}
				OR = {
					can_set_policy = {
						policy = interference
						option = interference_active
					}
					can_set_policy = {
						policy = interference
						option = interference_aggressive
					}
				}
			}
			set_policy_cooldown = interference
		}

		ai_chance = {
			factor = 0
		}
	}
}

################################
#
# Federations Events
# Written by Douglas Furen
#
###############################

# Federation Events
namespace = fedev

### Archaeology: Tribute to Lost Moments

# Stage 1 - Beacon in the Depth
fleet_event = {
	id = fedev.9430
	title = "fedev.9430.name"
	desc = "fedev.9430.desc"
	picture = GFX_evt_cold_barren
	show_sound = event_ghost_town

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Running out of time
fleet_event = {
	id = fedev.9435
	title = "fedev.9435.name"
	desc = "fedev.9435.desc"
	picture = GFX_evt_unspeakable_horror
	show_sound = event_mystic_reveal

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - So very, very brightly
fleet_event = {
	id = fedev.9440
	title = "fedev.9440.name"
	desc = "fedev.9440.desc"
	picture = GFX_evt_ancient_records
	show_sound = event_collapsing_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = FASCINATING
		owner = {
			add_modifier = {
				modifier = lost_moment_memento
				days = -1
			}
		}
	}
}

### Archaeology: The Lesser Messenger

# Stage 1 - Since Long Gone
fleet_event = {
	id = fedev.9445
	title = "fedev.9445.name"
	desc = "fedev.9445.desc"
	picture = GFX_evt_cold_barren
	show_sound = event_wind_ruins

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 2 - Beasts of Space
fleet_event = {
	id = fedev.9450
	title = "fedev.9450.name"
	desc = "fedev.9450.desc"
	picture = GFX_evt_satellite_in_orbit
	show_sound = event_bad_omen

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 3 - Garden of Prototypes
fleet_event = {
	id = fedev.9455
	title = "fedev.9455.name"
	desc = "fedev.9455.desc"
	picture = GFX_evt_archaeological_dig
	show_sound = event_finding_loot

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 4 - What are they building...
fleet_event = {
	id = fedev.9460
	title = "fedev.9460.name"
	desc = "fedev.9460.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_machinery

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	after = {
		from = { set_site_progress_locked = no }
	}

	option = {
		name = DIG
		small_artifact_reward = yes
	}
}

# Stage 5 - Random Outcome
fleet_event = {
	id = fedev.9461
	hide_window = yes

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		random_list = {
			33 = {
				fleet_event = { id = fedev.9465 }
			}
			33 = {
				fleet_event = { id = fedev.9470 }
			}
			33 = {
				fleet_event = { id = fedev.9475 }
			}
		}
	}

	after = {
		from = { expire_site_event = fedev.9461 }
	}
}

# Stage 5 - Alt. 1 - And the winner is...
fleet_event = {
	id = fedev.9465
	title = "fedev.9465.name"
	desc = "fedev.9465.desc"
	picture = GFX_evt_unidentified_ship
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = SPLENDID
		small_artifact_reward = yes
		create_lesser_messenger = yes
	}
}

# Stage 5 - Alt. 2 - Go forth and conquer!
fleet_event = {
	id = fedev.9470
	title = "fedev.9470.name"
	desc = "fedev.9470.desc"
	picture = GFX_evt_unidentified_ship
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = SPLENDID
		small_artifact_reward = yes
		create_lesser_messenger = yes
	}
}

# Stage 5 - Alt. 3 - Don't shoot the Messenger
fleet_event = {
	id = fedev.9475
	title = "fedev.9475.name"
	desc = "fedev.9475.desc"
	picture = GFX_evt_unidentified_ship
	show_sound = event_energy_field

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		fromfrom = { set_site_progress_locked = yes }
	}

	after = {
		fromfrom = { set_site_progress_locked = no }
	}

	option = {
		name = SPLENDID
		small_artifact_reward = yes
		create_lesser_messenger = yes
	}
}

country_event = {
	id = fedev.9480
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		owner = { remove_lessenger_damage = yes }
	}
}

### JUGGERNAUT CONSTRUCTED - BUILDER EVENT
ship_event = {
	id = fedev.9500
	title = "fedev.9500.name"
	desc = "fedev.9500.desc"
	picture = GFX_evt_juggernaut
	show_sound = event_default

	is_triggered_only = yes

	trigger = {
		is_ship_size = juggernaut
		owner = {
			NOT = { has_country_flag = juggernaut_constructed }
		}
	}

	immediate = {
		owner = {
			set_country_flag = juggernaut_constructed
		}
		every_playable_country = {
			limit = {
				has_communications = root.owner
				NOT = { is_same_value = root.owner }
				has_intel_level = {
					who = root.owner
					category = military
					level >= 2
				}
			}
			country_event = { id = fedev.9505 }
		}
	}

	after = {
	}

	option = {
		name = fedev.9500.a
	}
}

### JUGGERNAUT CONSTRUCTED - OTHER EMPIRES EVENT
country_event = {
	id = fedev.9505
	title = "fedev.9505.name"
	desc = "fedev.9505.desc"
	picture = GFX_evt_juggernaut
	show_sound = event_default

	is_triggered_only = yes

	immediate = {
	}

	after = {
	}

	option = {
		name = fedev.9505.a
	}
}

### First Federation Formed Events
country_event = {
	id = fedev.499
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		federation = {
			any_member = {
				is_ai = no
				NOR = {
					has_origin = origin_common_ground
					has_origin = origin_hegemon
				}
			}
			count_member = {
				count = 2
			}
		}
	}

	immediate = {
		save_event_target_as = fed_founder_1
		from = { save_event_target_as = fed_founder_2 }
		federation = {
			every_member = {
				limit = {
					is_ai = no
					NOR = {
						has_origin = origin_legendary_leader_dictatorial
						has_origin = origin_legendary_leader_imperial
					}
				}
				country_event = { id = fedev.500 }
			}
			every_member = {
				limit = {
					OR = {
						has_origin = origin_legendary_leader_dictatorial
						has_origin = origin_legendary_leader_imperial
					}
				}
				country_event = { id = paragon.5023 }
			}
		}
	}
}

### First Federation Formed Event
country_event = {
	id = fedev.500
	title = "fedev.500.name"
	desc = {
		trigger = {
			federation = { has_federation_type = default_federation }
		}
		text = "fedev.500.a.desc"
	}
	desc = {
		trigger = {
			federation = { has_federation_type = trade_federation }
		}
		text = "fedev.500.b.desc"
	}
	desc = {
		trigger = {
			federation = { has_federation_type = research_federation }
		}
		text = "fedev.500.c.desc"
	}
	desc = {
		trigger = {
			federation = { has_federation_type = military_federation }
		}
		text = "fedev.500.d.desc"
	}
	desc = {
		trigger = {
			federation = { has_federation_type = hegemony_federation }
		}
		text = "fedev.500.e.desc"
	}
	picture = GFX_evt_signing
	show_sound = event_celebration

	is_triggered_only = yes

	trigger = {
		NOT = {
			has_country_flag = first_federation_event
		}
		NAND = {
			has_origin = origin_broken_shackles
			federation = {
				any_member = {
					OR = {
						has_origin = origin_slavers
						allows_slavery = yes
					}
				}
			}
		}
		federation = {
			any_member = {
				NOR = {
					is_galactic_emperor = yes
					has_country_flag = empire_rebel
					has_country_flag = empire_loyalist
				}
			}
		}
	}

	immediate = {
		set_country_flag = first_federation_event
	}

	option = {
		name = fedev.500.a
		if = {
			limit = {
				has_ascension_perk = ap_defender_of_the_galaxy_nomads
				has_nomads_dlc = yes
			}
			add_resource = { integrity = 50 }
		}
	}
}

#################################################
#	FEDERATION JOINT OPERATION - TRADE LEAGUE	#
#################################################

### SETUP EVENT (HIDDEN)
event = {
	id = fedev.600
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		mid_game_years_passed >= 1
		any_playable_country = {
			exists = federation
			has_federation = yes
			any_owned_colony = {
				planet_resource_compare = {
					resource = trade
					value >= 100
					type = produces
				}
			}
			is_at_war = no
			federation = {
				has_federation_type = trade_federation
				NOR = {
					has_federation_flag = logistic_remodel_complete
					has_federation_flag = logistic_remodel_ongoing
				}
			}
		}
	}

	immediate = {
		every_playable_country = {
			limit = {
				exists = federation
				has_federation = yes
				is_federation_leader = yes
				federation = {
					has_federation_type = trade_federation
					NOR = {
						has_federation_flag = logistic_remodel_complete
						has_federation_flag = logistic_remodel_ongoing
					}
					any_member = {
						is_at_war = no
						any_owned_colony = {
							planet_resource_compare = {
								resource = trade
								value >= 100
								type = produces
							}
						}
					}
				}
			}
			federation = {
				set_variable = {
					which = number_of_empires_in_federation		### <-- Used to establish how many empires participated in the end
					value = 0
				}
				set_variable = {
					which = remodel_projects_completed		### <-- Used to establish how many empires has completed the project
					value = 0
				}
			}
			federation = {
				set_federation_flag = logistic_remodel_ongoing
				save_event_target_as = logistic_remodelling_federation
				every_member = {
					country_event = { id = fedev.605 }		### <-- Fires introduction message to everyone in the federation
				}
			}
		}
	}

	after = {
		every_playable_country = {
			limit = {
				exists = federation
				has_federation = yes
				is_federation_leader = yes
				federation = {
					has_federation_type = trade_federation
					NOR = {
						has_federation_flag = logistic_remodel_complete
						has_federation_flag = logistic_remodel_ongoing
					}
					any_member = {
						is_at_war = no
						any_owned_colony = {
							planet_resource_compare = {
								resource = trade
								value >= 100
								type = produces
							}
						}
					}
				}
			}
			country_event = { id = fedev.630 days = 5400 }
		}
	}
}

### INTRODUCTION TO UPCOMING TRIAL - FOR ALL MEMBERS
country_event = {
	id = fedev.605
	title = "fedev.605.name"
	desc = "fedev.605.desc"
	picture = GFX_evt_ship_offloading_cargo
	show_sound = event_default

	is_triggered_only = yes

	immediate = {
		country_event = { id = fedev.611 days = 540 random = 180 }
	}

	option = {
		name = fedev.605.a
		hidden_effect = {
			federation = {
				change_variable = {
					which = number_of_empires_in_federation
					value = 1
				}
			}
		}
	}
}

### TRIAL START PREPARATIONS - INDIVIDUAL (HIDDEN)
country_event = {
	id = fedev.611
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				any_owned_starbase = {
					has_starbase_module = trading_hub
					solar_system = {
						#has_system_trade_value >= 50
					}
				}
			}
			random_owned_starbase = {
				limit = {
					has_starbase_module = trading_hub
					solar_system = {
						#has_system_trade_value >= 50
					}
				}
				save_event_target_as = trial_trade_hub
			}
			set_country_flag = is_trial_participant
		}
	}

	after = {
		if = {
			limit = {
				has_country_flag = is_trial_participant
			}
			country_event = { id = fedev.615 }	### <-- Only fires for empires who have a valid Trade Hub
		}
		else = {
			country_event = { id = fedev.620 }	### <-- Fires for empires who do not have a valid Trade Hub
		}
	}
}

### TRIAL START MESSAGE - PARTICIPANTS ONLY
country_event = {
	id = fedev.615
	title = fedev.615.name
	desc = {
		trigger = {
			event_target:trial_trade_hub = {
				has_starbase_building = offworld_trading_company
			}
		}
		text = fedev.615.desc.a
	}
	desc = {
		trigger = {
			NOT = {
				event_target:trial_trade_hub = {
					has_starbase_building = offworld_trading_company
				}
			}
		}
		text = fedev.615.desc.b
	}
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_space_hangar
		BIOSHIP_PICTURE = GFX_evt_bioship_hangar
	}
	show_sound = event_construction

	is_triggered_only = yes

	immediate = {
		event_target:trial_trade_hub = {
			if = {
				limit = {
					has_starbase_building = offworld_trading_company
				}
				enable_special_project = {
					name = LOGISTIC_REMODEL_OFFWORLD
					location = this
					owner = root
				}
				owner = {
					add_modifier = {
						modifier = process_sharing
						days = -1
					}
				}
			}
			else = {
				enable_special_project = {
					name = LOGISTIC_REMODEL
					location = this
					owner = root
				}
				owner = {
					add_modifier = {
						modifier = cost_of_progress
						days = -1
					}
				}
			}
		}
	}

	option = {
		name = fedev.615.a
	}
}

### TRIAL START MESSAGE - FOR THOSE WHO DO NOT PARTICIPATE
country_event = {
	id = fedev.620
	title = fedev.620.name
	desc = fedev.620.desc
	picture = GFX_evt_alien_segregation
	show_sound = event_default

	is_triggered_only = yes

	option = {
		name = fedev.620.a
		owner = {
			add_modifier = {
				modifier = encumbrance_tax
				days = -1
			}
		}
	}
}

### ON SPECIAL PROJECT COMPLETE
country_event = {
	id = fedev.625
	title = fedev.625.name
	desc = fedev.625.desc
	picture = GFX_evt_cargoship_caravan
	show_sound = event_celebration

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				has_modifier = cost_of_progress
			}
			remove_modifier = cost_of_progress
			add_modifier = {
				modifier = process_sharing
				days = -1
			}
		}
		federation = {
			change_variable = {
				which = remodel_projects_completed
				value = 1
			}
		}
	}

	option = {
		name = EXCELLENT
	}
}

### TRIAL PERIOD ENDS (HIDDEN)
country_event = {
	id = fedev.630
	hide_window = yes

	trigger = {
		exists = federation
		NOT = {
			has_country_flag = trade_league_result
		}
	}

	is_triggered_only = yes

	immediate = {
		set_timed_country_flag = {
			flag = trade_league_result
			days = 7200
		}
		federation = {
			save_event_target_as = logistic_remodelling_federation
		}
		if = {
			limit = {
				federation = {
					check_variable = {
						which = remodel_projects_completed
						value = number_of_empires_in_federation
					}
				}
			}
			country_event = { id = fedev.635 days = 5 }		### PERFECT PARTICIPATION
		}
		else_if = {
			limit = {
				federation = {
					check_variable = {
						which = remodel_projects_completed
						value > 0
					}
				}
			}
			country_event = { id = fedev.640 days = 5 }		### GOOD PARTICIPATION
		}
		else_if = {
			limit = {
				federation = {
					check_variable = {
						which = remodel_projects_completed
						value = 0
					}
				}
			}
			country_event = { id = fedev.645 days = 5 }		### NO PARTICIPATION - FOR SHAME!
		}
		else = {
			country_event = { id = fedev.645 days = 5 }		### NO PARTICIPATION - FOR SHAME!
		}
	}

	after = {
		country_event = { id = fedev.650 days = 120 }	### HIDDEN CLEAN-UP EVENT
	}
}

### PERFECT TRIAL RESULT
country_event = {
	id = fedev.635
	title = fedev.635.name
	desc = fedev.635.desc
	picture = GFX_evt_treasure_pile
	show_sound = event_celebration

	is_triggered_only = yes

	option = {
		name = fedev.635.a
		owner = {
			remove_modifier = encumbrance_tax
			remove_modifier = cost_of_progress
			remove_modifier = process_sharing
			add_modifier = {
				modifier = fully_streamlined_logistics
				days = -1
			}
		}
	}
}

### GOOD TRIAL RESULT
country_event = {
	id = fedev.640
	title = fedev.640.name
	desc = fedev.640.desc
	picture = GFX_evt_resource_cache
	show_sound = event_default

	is_triggered_only = yes

	option = {
		name = fedev.640.a
		owner = {
			remove_modifier = encumbrance_tax
			remove_modifier = cost_of_progress
			remove_modifier = process_sharing
			add_modifier = {
				modifier = streamlined_logistics
				days = -1
			}
		}
	}
}

### NO TRIAL RESULT
country_event = {
	id = fedev.645
	title = fedev.645.name
	desc = fedev.645.desc
	picture = GFX_evt_civil_action
	show_sound = event_default

	is_triggered_only = yes

	option = {
		name = fedev.645.a
		hidden_effect = {
			owner = {
				remove_modifier = encumbrance_tax
				remove_modifier = cost_of_progress
				remove_modifier = process_sharing
			}
			federation = {
				add_cohesion = -50
			}
		}
	}
}

### CLEAN-UP EVENT (HIDDEN)
country_event = {
	id = fedev.650
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		federation = {
			set_federation_flag = logistic_remodel_complete
			remove_federation_flag = logistic_remodel_ongoing
			every_member = {
				remove_country_flag = is_trial_participant
			}
		}
	}
}
