has_paragon_dlc = {
	host_has_dlc = "Galactic Paragons"
}

is_hive_species = {
	species = {
		has_trait = trait_hive_mind
	}
}

has_any_subclass = {
	OR = {
		has_council_subclass = yes
		has_non_council_subclass = yes
	}
}

has_council_subclass = {
	OR = {
		has_trait = subclass_commander_councilor
		has_trait = subclass_official_diplomacy_councilor
		has_trait = subclass_official_economy_councilor
		has_trait = subclass_scientist_councilor
	}
}

has_governor_subclass = {
	OR = {
		has_trait = subclass_commander_governor
		has_trait = subclass_official_governor
		has_trait = subclass_scientist_governor
	}
}

has_non_council_subclass = {
	OR = {
		has_trait = subclass_commander_admiral
		has_trait = subclass_commander_general
		has_trait = subclass_commander_governor
		has_trait = subclass_official_delegate
		has_trait = subclass_official_governor
		has_trait = subclass_scientist_explorer
		has_trait = subclass_scientist_scholar
		has_trait = subclass_scientist_governor
	}
}

has_any_ethic = {
	OR = {
		has_ethic = ethic_authoritarian
		has_ethic = ethic_egalitarian
		has_ethic = ethic_xenophile
		has_ethic = ethic_xenophobe
		has_ethic = ethic_materialist
		has_ethic = ethic_spiritualist
		has_ethic = ethic_militarist
		has_ethic = ethic_pacifist
	}
}

has_any_admiral_speciality = {
	OR = {
		has_trait = leader_trait_artillery_specialization
		has_trait = leader_trait_carrier_specialization
		has_trait = leader_trait_rocketry_specialization
		has_trait = leader_trait_gunship_specialization
		has_trait = leader_trait_artillery_specialization_2
		has_trait = leader_trait_carrier_specialization_2
		has_trait = leader_trait_rocketry_specialization_2
		has_trait = leader_trait_gunship_specialization_2
	}
}

has_any_governor_focus = {
	OR = {
		has_trait = leader_trait_mining_focus
		has_trait = leader_trait_mining_focus_2
		has_trait = leader_trait_mining_focus_3
		has_trait = leader_trait_generator_focus
		has_trait = leader_trait_generator_focus_2
		has_trait = leader_trait_generator_focus_3
		has_trait = leader_trait_farming_focus
		has_trait = leader_trait_farming_focus_2
		has_trait = leader_trait_farming_focus_3
		has_trait = leader_trait_industrial_focus
		has_trait = leader_trait_industrial_focus_2
		has_trait = leader_trait_industrial_focus_3
		has_trait = leader_trait_forge_focus
		has_trait = leader_trait_forge_focus_2
		has_trait = leader_trait_forge_focus_3
		has_trait = leader_trait_refinement_focus
		has_trait = leader_trait_refinement_focus_2
		has_trait = leader_trait_refinement_focus_3
	}
}

has_scientist_focus = {
	OR = {
		has_trait = leader_trait_engineering_focus
		has_trait = leader_trait_engineering_focus_2
		has_trait = leader_trait_engineering_focus_3
		has_trait = leader_trait_physics_focus
		has_trait = leader_trait_physics_focus_2
		has_trait = leader_trait_physics_focus_3
		has_trait = leader_trait_society_focus
		has_trait = leader_trait_society_focus_2
		has_trait = leader_trait_society_focus_3
	}
}

is_specialist_researcher_physics = {
	OR = {
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_computing }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_field_manipulation }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_particles }
	}
}

is_specialist_researcher_society = {
	OR = {
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_biology }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_military_theory }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_new_worlds }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_statecraft }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_archaeostudies }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_psionics }
	}
}

is_specialist_researcher_engineering = {
	OR = {
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_industry }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_materials }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_propulsion }
		has_trait_tier1or2or3 = { TRAIT = leader_trait_expertise_voidcraft }
	}
}

is_specialist_researcher = {
	OR = {
		is_specialist_researcher_physics = yes
		is_specialist_researcher_society = yes
		is_specialist_researcher_engineering = yes
	}
}

is_head_of_research = {
	OR = {
		is_councilor_type = councilor_research
		is_councilor_type = councilor_gestalt_cognitive
	}
}

is_pool_leader = {
	exists = owner
	owner = {
		any_pool_leader = {
			is_same_value = PREVPREV
		}
	}
}

leader_has_empire_ethic = {
	OR = {
		AND = {
			has_ethic = ethic_pacifist
			owner = { is_pacifist = yes }
		}
		AND = {
			has_ethic = ethic_militarist
			owner = { is_militarist = yes }
		}
		AND = {
			has_ethic = ethic_xenophile
			owner = { is_xenophile = yes }
		}
		AND = {
			has_ethic = ethic_xenophobe
			owner = { is_xenophobe = yes }
		}
		AND = {
			has_ethic = ethic_egalitarian
			owner = { is_egalitarian = yes }
		}
		AND = {
			has_ethic = ethic_authoritarian
			owner = { is_authoritarian = yes }
		}
		AND = {
			has_ethic = ethic_spiritualist
			owner = { is_spiritualist = yes }
		}
		AND = {
			has_ethic = ethic_materialist
			owner = { is_materialist = yes }
		}
	}
}

suitable_for_chosen = {
	has_psionic_leader_trait = yes
	NOR = {
		has_any_chosen_one_leader_trait = yes # Current Chosen leader isn't suitable for new Chosen unless explicitely specified
		is_exploring_astral_rift = yes
		is_gestalt_node = yes
	}
}

suitable_for_chosen_covenant = {
	suitable_for_chosen = yes
	OR = {
		owner = { has_country_flag = composer_covenant_rank_3 }
		owner = { has_country_flag = eater_covenant_rank_3 }
		owner = { has_country_flag = instrument_covenant_rank_3 }
		owner = { has_country_flag = cradle_covenant_rank_3 }
		owner = { has_country_flag = whisperers_covenant_rank_3 }
		owner = { has_country_flag = forging_our_own_path }
	}
}

has_trait_in_council = {
	any_owned_leader = {
		is_councilor = yes
		has_trait = $TRAIT$
	}
}

has_tier1or2or3_in_council = {
	any_owned_leader = {
		is_councilor = yes
		has_trait_tier1or2or3 = {
			TRAIT = $TRAIT$
		}
	}
}

has_trait_tier1or2 = {
	OR = {
		has_trait = $TRAIT$
		has_trait = $TRAIT$_2
	}
}

has_trait_tier1or2or3 = {
	OR = {
		has_trait = $TRAIT$
		has_trait = $TRAIT$_2
		has_trait = $TRAIT$_3
	}
}

local_or_sector_governor_has_trait = {
	exists = planet
	planet = {
		OR = {
			AND = {
				exists = leader
				leader = {
					has_trait = $TRAIT$
				}
			}
			AND = {
				is_sector_capital = no
				NOT = { exists = leader }
				exists = sector
				sector.sector_capital = {
					exists = leader
					leader = {
						has_trait = $TRAIT$
					}
				}
			}
		}
	}
}

# leader scope
can_have_health_issues = {
	NOR = {
		has_trait = leader_trait_synthetic
		species = {
			OR = {
				has_trait = trait_machine_unit
				has_trait = trait_mechanical
				is_species_class = ROBOT
				is_species_class = MACHINE
			}
		}
	}
}

country_has_extra_council_position = {
	civics_count >= 3
	is_gestalt = no
}

# planet scope
has_azaryn_in_orbit = {
	exists = event_target:azaryn_ship
	any_fleet_in_orbit = {
		any_owned_ship = {
			is_same_value = event_target:azaryn_ship
		}
	}
}

is_azaryn_terraformable_pc = {
	OR = {
		habitable_planet_not_urban = yes
		is_azaryn_preferred_terraform_pc = yes
	}
	planet_size >= 10
	NOT = { has_planet_flag = terraform_nucleus_transfixed }
}

is_azaryn_preferred_terraform_pc = {
	OR = {
		is_planet_class = pc_barren
		is_planet_class = pc_barren_cold
	}
	planet_size >= 10
	NOT = { has_planet_flag = terraform_nucleus_transfixed }
}

has_miltary_background_job = {
	OR = {
		has_background_job = noble
		has_background_job = knight_commander
		has_background_job = duelist
		has_background_job = knight
		has_background_job = ranger
		has_background_job = squire
	}
}

trait_is_gestalt_check = {
	OR = {
		owner? = { is_gestalt = yes }
		from? = {
			is_scope_type = country
			is_gestalt = yes
		}
	}
}

trait_is_hive_check = {
	OR = {
		owner? = { is_hive_empire = yes }
		from? = {
			is_scope_type = country
			is_hive_empire = yes
		}
	}
}

trait_is_nomad_check = {
	OR = {
		owner? = { is_nomadic = yes }
		from? = {
			is_scope_type = country
			is_nomadic = yes
		}
	}
}

trait_is_wilderness_check = {
	OR = {
		owner? = { is_wilderness_empire = yes }
		from? = {
			is_scope_type = country
			is_wilderness_empire = yes
		}
	}
}

trait_is_machine_check = {
	OR = {
		owner? = { is_machine_empire = yes }
		from? = {
			is_scope_type = country
			is_machine_empire = yes
		}
	}
}

trait_is_individual_machine_check = {
	OR = {
		owner? = { is_individual_machine = yes }
		from? = {
			is_scope_type = country
			is_individual_machine = yes
		}
	}
}

trait_is_crisis_faction_check = {
	OR = {
		owner? = { is_crisis_faction = yes }
		from? = {
			is_scope_type = country
			is_crisis_faction = yes
		}
	}
}

has_psionic_leader_trait = {
	OR = {
		has_trait = leader_trait_psionic
		has_trait = leader_trait_shroudwalker
		has_trait = leader_trait_admiral_warform
		has_any_chosen_one_leader_trait = yes
	}
}

has_chosen_one_leader_trait = {
	OR = {
		has_trait = leader_trait_chosen
		has_trait = leader_trait_shroudshaper
		has_trait = leader_trait_the_psionic_luminary
	}
}

has_patron_chosen_one_leader_trait = {
	OR = {
		has_trait = leader_trait_composer_chosen
		has_trait = leader_trait_instrument_chosen
		has_trait = leader_trait_eater_chosen
		has_trait = leader_trait_cradle_chosen
		has_trait = leader_trait_whisperers_chosen
	}
}

has_any_chosen_one_leader_trait = {
	OR = {
		has_chosen_one_leader_trait = yes
		has_patron_chosen_one_leader_trait = yes
	}
}

has_narratively_great_councilor_trait = {
	OR = {
		# Any class
		has_trait = leader_trait_master_bureaucrat
		has_trait = leader_trait_educator
		has_trait = leader_trait_politician
		has_trait = trait_ruler_charismatic
		has_trait = trait_ruler_charismatic_2
		has_trait = leader_trait_gifted
		has_trait = leader_trait_gifted_2

		# Scientist
		has_trait = leader_trait_collaborator
		has_trait = leader_trait_collaborator_2
		has_trait = leader_trait_collaborator_3
		has_trait = leader_trait_spark_of_genius
		has_trait = leader_trait_spark_of_genius_2
		has_trait = leader_trait_society_focus
		has_trait = leader_trait_society_focus_2
		has_trait = leader_trait_society_focus_3
		has_trait = leader_trait_expertise_statecraft
		has_trait = leader_trait_expertise_statecraft_2
		has_trait = leader_trait_expertise_statecraft_3
		has_trait = leader_trait_knowledge_for_the_masses

		# Official
		has_trait = leader_trait_bureaucrat
		has_trait = leader_trait_principled
		has_trait = leader_trait_principled_2
		has_trait = leader_trait_righteous
		has_trait = leader_trait_righteous_2
		has_trait = trait_ruler_deep_connections
		has_trait = trait_ruler_deep_connections_2
		has_trait = trait_ruler_deep_connections_3
		has_trait = leader_trait_reformer
		has_trait = leader_trait_reformer_2
		has_trait = leader_trait_reformer_3
		has_trait = leader_trait_utopian_idealist
		has_trait = leader_trait_mediator
		has_trait = leader_trait_master_diplomat
		has_trait = leader_trait_galvanizer
		has_trait = leader_trait_zealot

		# Admiral
		has_trait = leader_trait_peacekeeper
		has_trait = leader_trait_fleet_organizer
		has_trait = leader_trait_fleet_organizer_2
		has_trait = leader_trait_commanding_presence
		has_trait = leader_trait_commanding_presence_2
		has_trait = leader_trait_military_overseer

		# General
		has_trait = leader_trait_overseer
		has_trait = leader_trait_overseer_2
		has_trait = leader_trait_consul_general
		has_trait = leader_trait_consul_general_2
		has_trait = leader_trait_shadow_broker
		has_trait = leader_trait_spycraft
		has_trait = leader_trait_spycraft_2
		has_trait = leader_trait_honored_warmaster
		has_trait = leader_trait_spymaster
	}
}

has_narratively_great_speaker_trait = {
	OR = {
		# Any class
		has_trait = leader_trait_educator
		has_trait = leader_trait_politician
		has_trait = trait_ruler_charismatic
		has_trait = trait_ruler_charismatic_2

		# Scientist
		has_trait = leader_trait_spark_of_genius
		has_trait = leader_trait_collective_wisdom
		has_trait = leader_trait_society_focus
		has_trait = leader_trait_society_focus_2
		has_trait = leader_trait_society_focus_3
		has_trait = leader_trait_expertise_statecraft
		has_trait = leader_trait_expertise_statecraft_2
		has_trait = leader_trait_expertise_statecraft_3
		has_trait = leader_trait_knowledge_for_the_masses
		has_trait = leader_trait_frontier_adventurer

		# Official
		has_trait = leader_trait_bureaucrat
		has_trait = leader_trait_righteous
		has_trait = leader_trait_righteous_2
		has_trait = leader_trait_enlister
		has_trait = trait_ruler_deep_connections
		has_trait = trait_ruler_deep_connections_2
		has_trait = trait_ruler_deep_connections_3
		has_trait = leader_trait_reformer
		has_trait = leader_trait_reformer_2
		has_trait = leader_trait_reformer_3
		has_trait = leader_trait_courtroom_training
		has_trait = leader_trait_mediator
		has_trait = leader_trait_master_diplomat
		has_trait = leader_trait_galvanizer
		has_trait = leader_trait_zealot

		# Admiral
		has_trait = leader_trait_peacekeeper
		has_trait = leader_trait_commanding_presence
		has_trait = leader_trait_commanding_presence_2
		has_trait = leader_trait_military_overseer

		# General
		has_trait = leader_trait_overseer
		has_trait = leader_trait_overseer_2
		has_trait = leader_trait_consul_general
		has_trait = leader_trait_consul_general_2
		has_trait = leader_trait_honored_warmaster
	}
}

ruler_or_councilor_has_ethic = {
	OR = {
		any_owned_leader = {
			is_ruler = yes
			has_ethic = ethic_$ETHIC$
		}
		is_ethic_represented_on_council = ethic_$ETHIC$
	}
}

is_currently_excavating_site = {
	any_archaeological_site = {
		is_site_locked = no
		exists = excavator_fleet
		excavator_fleet = {
			exists = leader
			leader = {
				is_same_value = root
			}
		}
	}
}

can_leader_get_council_trait_trigger = {
	OR = {
		NAND = {
			exists = owner
			owner = { is_gestalt = yes }
			is_councilor = no
		}
		has_leader_flag = restored_node
		has_leader_flag = renowned_leader
	}
	if = {
		limit = {
			exists = owner
		}
		owner = {
			is_crisis_faction = no
		}
	}
}

can_leader_get_normal_trait_trigger = {
	NOR = {
		AND = {
			owner? = { is_gestalt = yes }
			OR = {
				is_councilor = yes
				has_leader_flag = restored_node
			}
		}
		AND = {
			NOT = { has_leader_flag = ignore_autocracy_ruler_trait_restriction }
			OR = {
				AND = {
					has_global_flag = game_started
					is_ruler = yes
					owner? = {
						is_autocracy = yes
					}
				}
				is_heir = yes
			}
		}
	}
}

government_prefers_commanders = {
	OR = {
		has_government = gov_star_empire
		has_government = gov_military_dictatorship
		has_government = gov_military_junta
		has_government = gov_military_commissariat
		has_government = gov_martial_empire
		has_government = gov_martial_dictatorship
		has_government = gov_war_council
		has_government = gov_assembly_of_clans
		has_government = gov_citizen_stratocracy
		has_government = gov_citizen_republic
		has_government = gov_bandit_kingdom
		has_government = gov_bandit_commune
		has_government = gov_band_blood
		has_government = gov_defensive_union
		has_government = gov_cyber_dictatorial_individualist
		has_government = gov_cyber_dictatorial_collectivist
		has_government = gov_synth_democracy_virtual
		has_government = gov_synth_imperial_physical
		has_government = gov_synth_imperial_virtual
	}
}

government_prefers_officials = {
	OR = {
		has_government = gov_theocratic_monarchy
		has_government = gov_theocratic_dictatorship
		has_government = gov_theocratic_oligarchy
		has_government = gov_theocratic_republic
		has_government = gov_divine_empire
		has_government = gov_holy_tribunal
		has_government = gov_megachurch
		has_government = gov_military_commissariat
		has_government = gov_citizen_republic
		has_government = gov_irenic_dictatorship
		has_government = gov_irenic_bureaucracy
		has_government = gov_moral_democracy
		has_government = gov_celestial_empire
		has_government = gov_megacorporation
		has_government = gov_worker_coop
		has_government = gov_trade_league
		has_government = gov_criminal_syndicate
		has_government = gov_pirate_haven
		has_government = gov_subversive_cult
		has_government = gov_mortal_empire
		has_government = gov_grim_council
		has_government = gov_band_blood
		has_government = gov_sacrificial_megachurch
		has_government = gov_cyber_democracy_individualist
		has_government = gov_cyber_democracy_collectivist
		has_government = gov_cyber_oligarchy_collectivist
		has_government = gov_cyber_imperial_individualist
		has_government = gov_cyber_imperial_collectivist
		has_government = gov_cyber_corporate_individualist
		has_government = gov_synth_democracy_physical
		has_government = gov_synth_oligarchy_physical
		has_government = gov_synth_oligarchy_virtual
		has_government = gov_synth_dictatorship_physical
		has_government = gov_synth_dictatorship_virtual
		has_government = gov_synth_corporate_virtual
	}
}

government_prefers_scientists = {
	OR = {
		has_government = gov_irenic_monarchy
		has_government = gov_irenic_dictatorship
		has_government = gov_irenic_bureaucracy
		has_government = gov_moral_democracy
		has_government = gov_illuminated_autocracy
		has_government = gov_technocratic_dictatorship
		has_government = gov_science_directorate
		has_government = gov_rational_consensus
		has_government = gov_dimensional_covenant
		has_government = gov_cyber_oligarchy_individualist
		has_government = gov_cyber_corporate_collectivist
		has_government = gov_synth_corporate_physical
	}
}
