ethic_fanatic_authoritarian = {
	cost = 2
	category = "col"
	category_value = 0

	use_for_pops = no

	regular_variant = ethic_authoritarian

	country_modifier = {
		country_ethic_influence_produces_add = 1
		pop_cat_worker_bonus_workforce_mult = 0.1
		add_attunement_the_instrument_of_desire = @ethic_attunement2
	}

	tags = {
		ETHIC_ALLOWS_STRATIFIED_SOCIETY
		ETHIC_ALLOWS_SLAVERY
		ETHIC_ONLY_AUTOCRACY
	}

	random_weight = {
		base = 150
	}
}

ethic_authoritarian = {
	cost = 1
	category = "col"
	category_value = 1

	fanatic_variant = ethic_fanatic_authoritarian

	leader_background_job_weight = {
		politician = 25
		noble = 25
		executive = 25
		bureaucrat = 25
		manager = 25
	}

	country_modifier = {
		country_ethic_influence_produces_add = 0.5
		pop_cat_worker_bonus_workforce_mult = 0.05
		add_attunement_the_instrument_of_desire = @ethic_attunement1
	}

	tags = {
		ETHIC_ALLOWS_STRATIFIED_SOCIETY
		ETHIC_ALLOWS_SLAVERY
		ETHIC_NEVER_DEMOCRACY
	}

	random_weight = {
		base = 100
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_AUTHORITARIAN_POS
		trigger = {
			is_authoritarian = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_authoritarian = no
			has_faction = totalitarian
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_SLAVERY_POS
		trigger = {
			any_enslaved_species = {
				is_same_species = root
				is_robotic = no
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_authoritarian = yes }
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENO_SLAVES_POS
		trigger = {
			any_enslaved_species = {
				not = { is_same_species = root }
				is_robotic = no
			}
			NOT = {
				any_enslaved_species = {
					is_same_species = root
					is_robotic = no
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_CONSUMER_GOODS_NEG
		trigger = {
			is_authoritarian = no
			any_owned_species = {
				OR = {
					has_living_standard = { type = living_standard_utopian country = root }
					has_living_standard = { type = living_standard_good country = root }
					has_living_standard = { type = living_standard_shared_burden country = root }
					has_living_standard = { type = living_standard_worker_ownership country = root }
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STRATIFIED_POS
		trigger = {
			any_owned_species = {
				OR = {
					has_living_standard = { type = living_standard_stratified country = root }
					has_living_standard = { type = living_standard_dystopian_society country = root }
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_BENEFIT_FROM_INEQUALITY_POS
		trigger = {
			any_owned_species = {
				is_sapient = yes
				NOR = {
					has_citizenship_type = { type = citizenship_full country = prev.owner }
					has_citizenship_type = { type = citizenship_slavery country = prev.owner }
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_AUTOCRATIC_GOV_POS
		trigger = {
			has_election_type = none
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_DEMOCRATIC_GOV_NEG
		trigger = {
			has_election_type = democratic
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_DECADENT_POS
		trigger = {
			any_owned_species = {
				OR = {
					has_trait = "trait_decadent"
					has_trait = "trait_robot_decadent"
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_AUTHORITARIAN_DIPLOMACY_POS
		trigger = {
			any_relation = {
				OR = {
					is_in_federation_with = root
					has_defensive_pact = root
				}
				is_authoritarian = yes
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_HEGEMONYFED_POS
		trigger = {
			has_federation = yes
			federation = {
				has_federation_type = hegemony_federation
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NOBLES_POS
		trigger = {
			num_assigned_jobs = {
				job = noble
				value > 0
			}
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_authoritarian
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_authoritarian }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_authoritarian
				is_faction_extorted = yes
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_authoritarian
				has_ethic = ethic_fanatic_authoritarian
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_authoritarian
								has_ethic = ethic_authoritarian
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}
		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_authoritarian }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_authoritarian }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 2
			hidden_trigger = {
				is_country_type = default
				is_authoritarian = no
			}
			has_faction = totalitarian
		}
		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|authoritarian|
			desc = FROM_OVERLORD
		}
		modifier = {
			factor = 1.5
			has_federation = yes
			federation = {
				has_federation_type = hegemony_federation
			}
			desc = FROM_FEDERATION
		}
		modifier = {
			factor = 2
			has_ethic = ethic_authoritarian
		}
		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_authoritarian
		}
		modifier = {
			factor = 1.25
			has_election_type = none
			desc = FROM_AUTHORITY
		}
		modifier = {
			factor = 0.75
			has_election_type = democratic
			desc = FROM_AUTHORITY
		}

		# Check for any leader on the Council with Faction's Ethic.
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|authoritarian|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|authoritarian|
				value != 1
			}
			desc = FROM_COUNCIL
		}

		modifier = {
			factor = value:authoritarian_ethics_from_relations
			check_variable_arithmetic = {
				which = value:authoritarian_ethics_from_relations
				value != 1
			}
			desc = FROM_RELATIONS
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = authoritarian
			ETHIC_OPPOSED = egalitarian
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = authoritarian
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 1.25
			OR = {
				has_trait = "trait_decadent"
				has_trait = "trait_robot_decadent"
			}
			desc = HAS_DECADENT_TRAIT
		}
		modifier = {
			factor = 1.5
			is_enslaved = no
			from = {
				any_enslaved_species = {
					is_same_species = root
					is_robotic = no
				}
			}
			desc = FROM_SAME_SPECIES_SLAVES
		}
		modifier = {
			factor = 1.25
			is_enslaved = no
			from = {
				any_enslaved_species = {
					NOT = { is_same_species = root }
					is_robotic = no
				}
				NOT = {
					any_enslaved_species = {
						is_same_species = root
						is_robotic = no
					}
				}
			}
			desc = FROM_OTHER_SPECIES_SLAVES
		}
		modifier = {
			factor = 1.2
			has_citizenship_rights = yes
			from = {
				any_owned_species = {
					is_sapient = yes
					NOR = {
						has_citizenship_type = { type = citizenship_full country = prev.owner }
						has_citizenship_type = { type = citizenship_slavery country = prev.owner }
					}
				}
			}
			desc = FROM_NON_CITIZENS
		}
		modifier = {
			factor = value:authoritarian_ethics_from_living_standards
			check_variable_arithmetic = {
				which = value:authoritarian_ethics_from_living_standards
				value != 1
			}
			desc = FROM_LIVING_STANDARDS
		}
	}
}

ethic_fanatic_egalitarian = {
	cost = 2
	category = "col"
	category_value = 4

	category_opposite = yes

	regular_variant = ethic_egalitarian

	use_for_pops = no

	tags = {
		ETHIC_ONLY_DEMOCRACY
		ETHIC_ALLOWS_UTOPIA
	}

	country_modifier = {
		pop_factions_produces_mult = 0.30
		pop_cat_specialist_bonus_workforce_mult = 0.1
		add_attunement_the_composer_of_strands = @ethic_attunement2
	}

	random_weight = {
		base = 150
	}
}

ethic_egalitarian = {
	cost = 1
	category = "col"
	category_value = 3

	fanatic_variant = ethic_fanatic_egalitarian

	category_opposite = yes

	tags = {
		ETHIC_NEVER_AUTOCRACY
		ETHIC_ALLOWS_UTOPIA
	}

	leader_background_job_weight = {
		colonist = 25
		culture_worker = 25
		pearl_diver = 25
		clerk = 25
		technician = 25
		miner = 25
		crystal_miner = 25
		gas_extractor = 25
		mote_harvester = 25
		farmer = 25
		scrap_miner = 25
		angler = 25
		ranger = 25
		squire = 25
		puddle_technician = 25
	}

	country_modifier = {
		pop_factions_produces_mult = 0.15
		pop_cat_specialist_bonus_workforce_mult = 0.05
		add_attunement_the_composer_of_strands = @ethic_attunement1
	}

	random_weight = {
		base = 100
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_EGALITARIAN_POS
		trigger = {
			is_egalitarian = yes
		}
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_egalitarian = no
			has_faction = progressive
		}
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_CONSUMER_GOODS_POS
		trigger = {
			is_authoritarian = no
			any_owned_species = {
				OR = {
					has_living_standard = { type = living_standard_utopian country = root }
					has_living_standard = { type = living_standard_good country = root }
					has_living_standard = { type = living_standard_shared_burden country = root }
					has_living_standard = { type = living_standard_worker_ownership country = root }
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_EGALITARIAN_DIPLOMACY_POS
		trigger = {
			any_relation = {
				OR = {
					AND = {
						is_subject = no
						has_migration_access = root
					}
					is_in_federation_with = root
					has_defensive_pact = root
					has_commercial_pact = root
				}
				is_egalitarian = yes
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_UTOPIAN_CITIZENSHIP_POS
		trigger = {
			any_owned_species = {
				is_robotic = no
				NOT = { is_same_species = root }
			}
			count_owned_species = {
				limit = {
					is_sapient = yes
					is_robotic = no
					NOT = {
						has_citizenship_type = { type = citizenship_full country = root }
					}
				}
				count = 0
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_ENSLAVED_POS
		trigger = {
			any_enslaved_species = {
				is_robotic = no
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_DEMOCRATIC_GOV_POS
		trigger = {
			has_election_type = democratic
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_AUTOCRATIC_GOV_NEG
		trigger = {
			has_election_type = none
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_egalitarian = yes }
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_DECADENT_NEG
		trigger = {
			any_owned_species = {
				OR = {
					has_trait = "trait_decadent"
					has_trait = "trait_robot_decadent"
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NOBLES_NEG
		trigger = {
			num_assigned_jobs = {
				job = noble
				value > 0
			}
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_egalitarian
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_egalitarian }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_egalitarian
				is_faction_extorted = yes
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_egalitarian
				has_ethic = ethic_fanatic_egalitarian
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_egalitarian
								has_ethic = ethic_egalitarian
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}
		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_egalitarian }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_egalitarian }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 2
			hidden_trigger = {
				is_country_type = default
				is_egalitarian = no
			}
			has_faction = progressive
		}
		modifier = {
			factor = 2
			has_ethic = ethic_egalitarian
		}
		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_egalitarian
		}
		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|egalitarian|
			desc = FROM_OVERLORD
		}
		modifier = {
			factor = 0.75
			is_country_type = default
			has_election_type = none
			desc = FROM_AUTHORITY
		}
		modifier = {
			factor = 1.25
			is_country_type = default
			has_election_type = democratic
			desc = FROM_AUTHORITY
		}
		modifier = {
			factor = 1.25
			any_owned_species = {
				is_robotic = no
				NOT = { is_same_species = root }
			}
			count_owned_species = {
				limit = {
					is_sapient = yes
					is_robotic = no
					NOT = {
						has_citizenship_type = { type = citizenship_full country = root }
					}
				}
				count = 0
			}
			desc = FROM_UTOPIAN_CITIZENSHIP
		}

		# Check for any leader on the Council with Faction's Ethic.
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|egalitarian|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|egalitarian|
				value != 1
			}
			desc = FROM_COUNCIL
		}

		modifier = {
			factor = value:egalitarian_ethics_from_relations
			check_variable_arithmetic = {
				which = value:egalitarian_ethics_from_relations
				value != 1
			}
			desc = FROM_RELATIONS
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = egalitarian
			ETHIC_OPPOSED = authoritarian
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = egalitarian
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 0.5
			OR = {
				has_trait = "trait_decadent"
				has_trait = "trait_robot_decadent"
			}
			desc = HAS_DECADENT_TRAIT
		}
		modifier = {
			factor = 1.25
			has_citizenship_rights = no
		}
		modifier = {
			factor = 1.5
			is_enslaved = yes
			is_robot_pop_group = no
			desc = FROM_SLAVERY
		}
		modifier = {
			factor = 1.25
			owner = { is_authoritarian = no }
			OR = {
				has_living_standard = { type = living_standard_utopian }
				has_living_standard = { type = living_standard_good }
				has_living_standard = { type = living_standard_shared_burden }
				has_living_standard = { type = living_standard_worker_ownership }
			}
			desc = FROM_LIVING_STANDARDS
		}
	}
}

ethic_fanatic_xenophobe = {
	cost = 2
	category = "xen"
	category_value = 0

	xenophobe = yes #used for a few hardcoded checks (mainly tooltips)

	use_for_pops = no

	regular_variant = ethic_xenophobe

	tags = {
		ETHIC_ALLOWS_PURGE
		ETHIC_ALLOWS_SLAVERY
		ETHIC_REDUCED_DIPLOMACY
		ETHIC_NEVER_ALIEN_CITIZENSHIP
		ETHIC_NEVER_ALIEN_MILITARY_SERVICE
		ETHIC_NO_REFUGEES
	}

	country_modifier = {
		founder_species_growth_mult = 0.20
		add_attunement_the_eater_of_worlds = @ethic_attunement2
		refugee_attraction = -0.30
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = no
		}
		country_starbase_influence_cost_mult = -0.4
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = yes
		}
		megastructures_arkships_influence_cost_mult = -0.1
	}

	random_weight = {
		base = 150
		modifier = {
			factor = 0.2
			blocks_disruptive_gameplay = yes
		}
	}
}

ethic_xenophobe = {
	cost = 1
	category = "xen"
	category_value = 1

	xenophobe = yes #used for a few hardcoded checks (mainly tooltips)

	fanatic_variant = ethic_fanatic_xenophobe

	tags = {
		ETHIC_ALLOWS_PURGE
		ETHIC_ALLOWS_SLAVERY
		ETHIC_REDUCED_DIPLOMACY
		ETHIC_NEVER_ALIEN_CITIZENSHIP
		ETHIC_NEVER_ALIEN_MILITARY_SERVICE
		ETHIC_NO_REFUGEES
	}

	country_modifier = {
		founder_species_growth_mult = 0.10
		add_attunement_the_eater_of_worlds = @ethic_attunement1
		refugee_attraction = -0.15
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = no
		}
		country_starbase_influence_cost_mult = -0.2
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = yes
		}
		megastructures_arkships_influence_cost_mult = -0.05
	}

	random_weight = {
		base = 100
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENOPHOBE_POS
		trigger = {
			is_xenophobe = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_xenophobe = no
			OR = {
				has_faction = supremacist
				has_faction = isolationist
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FANATIC_PURIFIERS_POS
		trigger = {
			has_valid_civic = civic_fanatic_purifiers
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_INWARDS_PERFECTION_POS
		trigger = {
			has_valid_civic = civic_inwards_perfection
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_DEFENSIVE_XENO_WAR_POS
		trigger = {
			is_at_war = yes
			any_war = {
				any_defender = {
					is_same_value = prevprev
				}
				any_attacker = {
					NOT = { is_same_species = root }
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPUGNANT_POS
		trigger = {
			any_owned_planet = {
				any_owned_species = {
					has_trait = "trait_repugnant"
				}
				any_owned_pop_group = {
					NOT = { has_trait = "trait_repugnant" }
					is_non_sapient_robot = no
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NOXIOUS_POS
		trigger = {
			any_owned_planet = {
				any_owned_species = {
					has_trait = "trait_noxious"
				}
				any_owned_pop_group = {
					NOT = { has_trait = "trait_noxious" }
					is_non_sapient_robot = no
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENO_SLAVES_POS
		trigger = {
			any_enslaved_species = {
				not = { is_same_species = root }
				is_robotic = no
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_xenophobe = yes }
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_ENSLAVEMENT_OF_SPECIES_POS
		trigger = {
			any_relation = {
				NOT = { is_same_species = root }
				any_enslaved_species = {
					is_robotic = no
					is_same_species = root
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_PURGING_POS
		trigger = {
			any_relation = {
				has_opinion_modifier = {
					who = root
					modifier = opinion_genocidal
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_PURGING_OF_SPECIES_POS
		trigger = {
			any_relation = {
				has_opinion_modifier = {
					who = root
					is_reverse = yes
					modifier = opinion_genocidal_our_species
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NEIGHBOR_HOMICIDAL_POS
		trigger = {
			any_neighbor_country = {
				is_homicidal = yes
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENO_LEADERS_NEG
		trigger = {
			allows_alien_leaders = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FREE_XENOS_NEG
		trigger = {
			any_owned_pop_group = {
				not = { is_same_species = root }
				is_enslaved = no
				is_being_purged = no
				is_sapient = yes
				is_robot_pop_group = no
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_MIGRATION_TREATIES_NEG
		trigger = {
			any_relation = {
				is_subject = no
				has_migration_access = root
				NOT = { is_same_species = root }
			}
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_xenophobe
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_xenophobe }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_xenophobe
				is_faction_extorted = yes
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_xenophobe
				has_ethic = ethic_fanatic_xenophobe
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_xenophobe
								has_ethic = ethic_xenophobe
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}
		modifier = {
			factor = 2
			is_country_type = default
			is_xenophobe = no
			OR = {
				has_faction = supremacist
				has_faction = isolationist
			}
			desc = FROM_XENOPHOBIC_FACTIONS
		}

		modifier = {
			factor = 2
			has_ethic = ethic_xenophobe
		}
		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_xenophobe
		}
		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|xenophobe|
			desc = FROM_OVERLORD
		}
		modifier = {
			factor = 1.5
			has_valid_civic = civic_inwards_perfection
		}
		modifier = {
			factor = 1.5
			has_valid_civic = civic_fanatic_purifiers
		}
		modifier = {
			factor = 0.75
			allows_alien_leaders = yes
			desc = FROM_XENO_LEADERS
		}
		modifier = {
			factor = 3.0
			any_war = {
				any_defender = {
					is_same_value = prevprev
				}
				any_attacker = {
					NOT = { is_same_species = root }
				}
			}
			desc = FROM_DEFENSIVE_XENO_WAR
		}
		modifier = {
			factor = 2.0
			species = { is_robotic = no }
			any_relation = {
				NOT = { is_same_species = root }
				any_enslaved_species = {
					is_same_species = root
				}
			}
			desc = FROM_RELATIONS_SLAVERY
		}
		modifier = {
			factor = 3.0
			any_relation = {
				has_opinion_modifier = {
					who = root
					modifier = opinion_genocidal
				}
			}
			desc = FROM_HOMICIDAL_EMPIRES
		}
		modifier = {
			factor = 4.0
			any_relation = {
				has_opinion_modifier = {
					who = root
					is_reverse = yes
					modifier = opinion_genocidal_our_species
				}
			}
			desc = FROM_XENO_PURGE
		}
		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_xenophobe }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_xenophobe }
			}
			desc = FROM_OBSERVER
		}

		# Check for any leader on the Council with Faction's Ethic.
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|xenophobe|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|xenophobe|
				value != 1
			}
			desc = FROM_COUNCIL
		}

		modifier = {
			factor = value:xenophobe_ethics_from_relations
			check_variable_arithmetic = {
				which = value:xenophobe_ethics_from_relations
				value != 1
			}
			desc = FROM_RELATIONS
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = xenophobe
			ETHIC_OPPOSED = xenophile
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = xenophobe
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 2.0
			is_enslaved = no
			is_being_purged = no
			from = {
				any_enslaved_species = {
					NOT = { is_same_species = root }
					is_robotic = no
				}
			}
			desc = FROM_OTHER_SPECIES_SLAVE
		}
		modifier = {
			factor = 0.5
			is_enslaved = no
			is_being_purged = no
			from = {
				any_owned_pop_group = {
					NOT = { is_same_species = root }
					is_enslaved = no
					is_being_purged = no
					is_sapient = yes
					is_robot_pop_group = no
				}
			}
			desc = FROM_OTHER_SPECIES_FREE
		}
		modifier = {
			factor = 1.5
			from = {
				any_owned_species = {
					NOT = { is_same_species = root }
					has_trait = "trait_repugnant"
				}
			}
			desc = FROM_OTHER_SPECIES_REPUGNANT
		}
		modifier = {
			factor = 1.5
			NOT = { has_trait = trait_noxious }
			from = {
				any_owned_species = {
					NOT = { is_same_species = root }
					has_trait = trait_noxious
				}
			}
			desc = FROM_OTHER_SPECIES_NOXIOUS
		}
	}
}

ethic_fanatic_xenophile = {
	cost = 2
	category = "xen"
	category_value = 4

	xenophile = yes #used for a few hardcoded checks (mainly tooltips)

	category_opposite = yes

	regular_variant = ethic_xenophile

	use_for_pops = no

	tags = {
		ETHIC_IMPROVED_DIPLOMACY
		ETHIC_ALWAYS_REFUGEES
		ETHIC_DISALLOWS_SLAVERY
		ETHIC_DISALLOWS_DISPLACE
	}

	country_modifier = {
		planet_jobs_trade_produces_mult = 0.20
		envoys_add = 2
		show_only_custom_tooltip = no
		custom_tooltip = fan_xenophile_insight_gain
		add_attunement_the_cradle_of_souls = @ethic_attunement2
		refugee_attraction = 0.30
	}

	random_weight = {
		base = 100
	}
}

ethic_xenophile = {
	cost = 1
	category = "xen"
	category_value = 3

	xenophile = yes #used for a few hardcoded checks (mainly tooltips)

	category_opposite = yes

	fanatic_variant = ethic_fanatic_xenophile

	tags = {
		ETHIC_IMPROVED_DIPLOMACY
		ETHIC_ALWAYS_REFUGEES
		ETHIC_DISALLOWS_SLAVERY
		ETHIC_DISALLOWS_DISPLACE
	}

	leader_background_job_weight = {
		xeno_zoo_keeper = 25
	}

	country_modifier = {
		planet_jobs_trade_produces_mult = 0.10
		envoys_add = 1
		add_attunement_the_cradle_of_souls = @ethic_attunement1
		show_only_custom_tooltip = no
		custom_tooltip = xenophile_insight_gain
		refugee_attraction = 0.15
	}

	random_weight = {
		base = 66
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENOPHILE_POS
		trigger = {
			is_xenophile = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_xenophile = no
			has_faction = xenoist
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FREE_XENOS_POS
		trigger = {
			any_owned_planet = {
				any_owned_pop_group = {
					not = { is_same_species = root }
					is_enslaved = no
					is_being_purged = no
					is_sapient = yes
					is_robot_pop_group = no
					NOT = { has_trait = trait_syncretic_proles }
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENO_DIPLOMACY_POS
		trigger = {
			any_relation = {
				NOT = { is_same_species = root }
				is_subject = no
				OR = {
					is_in_federation_with = root
					has_defensive_pact = root
					has_commercial_pact = root
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_MIGRATION_TREATIES_POS
		trigger = {
			any_relation = {
				is_subject = no
				has_migration_access = root
				NOT = { is_same_species = root }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_CHARISMATIC_POS
		trigger = {
			any_owned_planet = {
				any_owned_species = {
					has_trait = "trait_charismatic"
				}
				any_owned_pop_group = {
					NOT = { has_trait = "trait_charismatic" }
					is_non_sapient_robot = no
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FANATIC_PURIFIERS_NEG
		trigger = {
			has_valid_civic = civic_fanatic_purifiers
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_INWARDS_PERFECTION_NEG
		trigger = {
			has_valid_civic = civic_inwards_perfection
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_ENSLAVEMENT_OF_SPECIES_NEG
		trigger = {
			any_relation = {
				NOT = { is_same_species = root }
				any_enslaved_species = {
					is_robotic = no
					is_same_species = root
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_PURGING_NEG
		trigger = {
			any_relation = {
				has_opinion_modifier = {
					who = root
					modifier = opinion_genocidal
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_PURGING_OF_SPECIES_NEG
		trigger = {
			any_relation = {
				has_opinion_modifier = {
					who = root
					is_reverse = yes
					modifier = opinion_genocidal_our_species
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NECROPHAGE_NEG
		trigger = {
			has_origin = origin_necrophage
			has_trait = trait_necrophage
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENO_LEADERS_POS
		trigger = {
			allows_alien_leaders = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_xenophile = yes }
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_XENO_OUTREACH_AGENCY_POS
		trigger = {
			any_owned_planet = {
				has_branch_office = yes
				has_holding = {
					holding = building_xeno_tourism_agency
					owner = branch_office_owner
				}
			}
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_xenophile
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_xenophile }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_xenophile
				is_faction_extorted = yes
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_xenophile
				has_ethic = ethic_fanatic_xenophile
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_xenophile
								has_ethic = ethic_xenophile
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}
		modifier = {
			factor = 2
			hidden_trigger = {
				is_country_type = default
				is_xenophile = no
			}
			has_faction = xenoist
		}
		modifier = {
			factor = 2
			has_ethic = ethic_xenophile
		}
		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_xenophile
		}
		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|xenophile|
			desc = FROM_OVERLORD
		}
		modifier = {
			factor = 0.5
			has_valid_civic = civic_inwards_perfection
		}
		modifier = {
			factor = 0.33
			has_valid_civic = civic_fanatic_purifiers
		}
		modifier = {
			factor = 1.5
			is_country_type = default
			allows_alien_leaders = yes
			desc = FROM_XENO_LEADERS
		}
		modifier = {
			factor = 0.25
			any_relation = {
				has_opinion_modifier = {
					who = root
					is_reverse = yes
					modifier = opinion_genocidal_our_species
				}
			}
			desc = FROM_XENO_PURGE
		}
		modifier = {
			factor = 0.35
			any_relation = {
				has_opinion_modifier = {
					who = root
					modifier = opinion_genocidal
				}
			}
			desc = FROM_HOMICIDAL_EMPIRES
		}
		modifier = {
			factor = 0.5
			is_same_species = root
			any_relation = {
				NOT = { is_same_species = root }
				any_enslaved_species = {
					is_robotic = no
					is_same_species = root
				}
			}
			desc = FROM_OTHER_SPECIES_SLAVE
		}
		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_xenophile }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_xenophile }
			}
			desc = FROM_OBSERVER
		}
		# Check for any leader on the Council with Faction's Ethic.
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|xenophile|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|xenophile|
				value != 1
			}
			desc = FROM_COUNCIL
		}

		modifier = {
			factor = value:xenophile_ethics_from_relations
			check_variable_arithmetic = {
				which = value:xenophile_ethics_from_relations
				value != 1
			}
			desc = FROM_RELATIONS
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = xenophile
			ETHIC_OPPOSED = xenophobe
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = xenophile
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 2
			NOT = { is_same_species = from.owner }
			has_citizenship_rights = yes
			is_enslaved = no
			desc = FROM_SPECIES_RIGHTS
		}
		modifier = {
			factor = 2.0
			is_enslaved = no
			from = {
				any_owned_pop_group = {
					NOT = { is_same_species = root }
					is_enslaved = no
					is_being_purged = no
					is_sapient = yes
					is_robot_pop_group = no
					NOT = { has_trait = trait_syncretic_proles }
				}
			}
			desc = FROM_OTHER_SPECIES_FREE
		}
		modifier = {
			factor = 1.5
			from = {
				any_owned_species = {
					NOT = { is_same_species = root }
					has_trait = "trait_charismatic"
				}
			}
			desc = FROM_OTHER_SPECIES_CHARISMATIC
		}
		modifier = {
			factor = 0.5
			has_trait = trait_necrophage
		}
		modifier = {
			factor = 1.1
			from = {
				has_branch_office = yes
				has_holding = {
					holding = building_xeno_tourism_agency
					owner = branch_office_owner
				}
			}
			desc = FROM_BRANCH_OFFICES
		}
	}
}

ethic_fanatic_militarist = {
	cost = 2
	category = "mil"
	category_value = 0

	use_for_pops = no

	regular_variant = ethic_militarist

	tags = {
		ETHIC_ALLOW_NO_RETREAT
	}

	country_modifier = {
		ship_fire_rate_mult = 0.20
		add_attunement_the_eater_of_worlds = @ethic_attunement2
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = no
		}
		country_claim_influence_cost_mult = -0.2
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = yes
		}
		scavenge_debris_mult = 0.1
	}

	# more common ethic
	random_weight = {
		base = 250
	}
}

ethic_militarist = {
	cost = 1
	category = "mil"
	category_value = 1

	fanatic_variant = ethic_fanatic_militarist

	tags = {
		ETHIC_ALLOW_NO_RETREAT
	}

	leader_background_job_weight = {
		knight_commander = 25
		enforcer = 25
		duelist = 25
		knight = 25
		soldier = 25
	}

	country_modifier = {
		ship_fire_rate_mult = 0.10
		add_attunement_the_eater_of_worlds = @ethic_attunement1
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = no
		}
		country_claim_influence_cost_mult = -0.1
	}

	triggered_country_modifier = {
		potential = {
			is_nomadic = yes
		}
		scavenge_debris_mult = 0.05
	}

	# more common ethic
	random_weight = {
		base = 150
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_MILITARIST_POS
		trigger = {
			is_militarist = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_militarist = no
			has_faction = imperialist
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_AT_WAR_POS
		trigger = {
			is_at_war = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_AT_WAR_WITH_RIVAL_POS
		trigger = {
			is_at_war = yes
			any_war = {
				any_war_participant = {
					is_rival = root
					prev = { NOT = { is_war_participant = { side = root } } }
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_LOST_WAR_POS
		trigger = {
			recently_lost_war = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_LOST_PLANETS_POS
		trigger = {
			any_relation = {
				any_owned_planet = {
					is_original_owner = root
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OCCUPIED_PLANET_POS
		trigger = {
			any_owned_planet = {
				NOT = { is_controlled_by = root }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NEIGHBOR_RIVALS_POS
		trigger = {
			any_neighbor_country = {
				OR = {
					is_hostile_to = root
					is_domineering_to = root
					is_rival = root
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STRONG_POS
		trigger = {
			any_owned_species = {
				OR = {
					has_trait = "trait_strong"
					has_trait = "trait_very_strong"
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_EMPIRE_PEACEFUL_NEG
		trigger = {
			years_of_peace = {
				value > 20
				delay = 50
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_WEAK_NEG
		trigger = {
			any_owned_planet = {
				any_owned_species = {
					has_trait = "trait_weak"
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_INWARDS_PERFECTION_NEG
		trigger = {
			has_valid_civic = civic_inwards_perfection
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_WARFED_POS
		trigger = {
			has_federation = yes
			federation = {
				has_federation_type = military_federation
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_DUELIST_POS
		trigger = {
			num_assigned_jobs = {
				job = duelist
				value > 0
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_SOLDIER_POS
		trigger = {
			num_assigned_jobs = {
				job = soldier
				value > 0
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_MILITARY_SUPERIOR_RIVAL_POS
		trigger = {
			any_rival_country = {
				is_neighbor_of = root
				relative_power = {
					who = root
					category = fleet
					value >= superior
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_militarist = yes }
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NO_WARS_NEG
		trigger = {
			has_policy_flag = no_wars
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_militarist
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_militarist }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_militarist
				is_faction_extorted = yes
			}
		}
	}
	#Cybercreed War
	pop_attraction_tag = {
		desc = POP_ATTRACTION_CYBER_CREED_WAR
		trigger = {
			owner = {
				has_country_flag = cybernetic_creed_war
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_militarist
				has_ethic = ethic_fanatic_militarist
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_militarist
								has_ethic = ethic_militarist
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}

		modifier = {
			factor = 2
			hidden_trigger = {
				is_country_type = default
				is_militarist = no
			}
			has_faction = imperialist
		}

		modifier = {
			factor = 1.5
			has_federation = yes
			federation = {
				has_federation_type = military_federation
			}
			desc = FROM_FEDERATION
		}

		modifier = {
			factor = 2
			has_ethic = ethic_militarist
		}

		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_militarist
		}

		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|militarist|
			desc = FROM_OVERLORD
		}

		modifier = {
			factor = 0.33
			has_valid_civic = civic_inwards_perfection
		}

		modifier = {
			factor = value:militarist_ethics_from_peace
			is_country_type = default
			years_of_peace = {
				value > 20
				delay = 50
			}
			desc = FROM_PEACE
		}

		modifier = {
			factor = 2.0
			is_at_war = yes
			desc = FROM_WARS
		}
		modifier = {
			factor = 1.5
			is_at_war = yes
			any_war = {
				any_war_participant = {
					is_rival = root
					prev = { NOT = { is_war_participant = { side = root } } }
				}
			}
			desc = FROM_RIVAL_WARS
		}
		modifier = {
			factor = 2.0
			recently_lost_war = yes
			desc = FROM_RECENT_LOSS
		}
		modifier = {
			factor = 1.5
			any_neighbor_country = {
				OR = {
					is_hostile_to = root
					is_domineering_to = root
					is_rival = root
				}
			}
			desc = FROM_HOSTILE_NEIGHBORS
		}
		modifier = {
			factor = 1.25
			any_rival_country = {
				is_neighbor_of = root
				relative_power = {
					who = root
					category = fleet
					value >= superior
				}
			}
			desc = FROM_SUPERIOR_RIVAL_MILITARY
		}

		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_militarist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_militarist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 2 #If the empire is losing planets, militarism should increase
			any_relation = {
				any_owned_planet = {
					is_original_owner = root
				}
			}
			desc = FROM_STOLEN_PLANETS
		}
		modifier = {
			factor = 0.75
			has_policy_flag = no_wars
		}

		# Check for any leader on the Council with Faction's Ethic.
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|militarist|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|militarist|
				value != 1
			}
			desc = FROM_COUNCIL
		}

		#Cyber Creed War
		modifier = {
			factor = 1
			is_country_type = default
			has_country_flag = cybernetic_creed_war
			desc = FROM_CREED
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = militarist
			ETHIC_OPPOSED = pacifist
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = militarist
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 1.1
			has_trait = "trait_strong"
		}
		modifier = {
			factor = 1.2
			has_trait = "trait_very_strong"
		}
		modifier = {
			factor = 0.75
			has_trait = "trait_weak"
		}
		modifier = {
			factor = 3.0
			from = {
				NOT = { is_controlled_by = from.owner }
			}
			desc = FROM_OCCUPIED_PLANET
		}
	}
}

ethic_fanatic_pacifist = {
	cost = 2
	category = "mil"
	category_value = 4

	category_opposite = yes

	regular_variant = ethic_pacifist

	use_for_pops = no

	tags = {
		ETHIC_DISALLOW_OFFENSIVE_WARS
		ETHIC_DISALLOW_FULL_BOMBARDMENT
	}

	country_modifier = {
		empire_size_pops_mult = -0.20
		planet_stability_add = 10
		add_attunement_the_cradle_of_souls = @ethic_attunement2
		the_eater_of_worlds_attunement_mult = -0.35
	}

	random_weight = {
		base = 33		# rare ethic
	}
}

ethic_pacifist = {
	cost = 1
	category = "mil"
	category_value = 3

	category_opposite = yes

	fanatic_variant = ethic_fanatic_pacifist

	leader_background_job_weight = {
		healthcare = 25
		unifier = 25
		entertainer = 25
		artisan = 25
		educator = 100
	}

	country_modifier = {
		empire_size_pops_mult = -0.10
		planet_stability_add = 5
		add_attunement_the_cradle_of_souls = @ethic_attunement1
		the_eater_of_worlds_attunement_mult = -0.25
	}

	tags = {
		ETHIC_DISALLOW_CONQUEST_WARS
		ETHIC_DISALLOW_FULL_BOMBARDMENT
	}

	random_weight = {
		base = 66	# uncommon ethic
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_PACIFIST_POS
		trigger = {
			is_pacifist = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_pacifist = no
			has_faction = prosperity
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_EMPIRE_PEACEFUL_POS
		trigger = {
			years_of_peace = {
				value > 20
				delay = 50
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_INWARDS_PERFECTION_POS
		trigger = {
			has_valid_civic = civic_inwards_perfection
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_WEAK_POS
		trigger = {
			any_owned_planet = {
				any_owned_species = {
					has_trait = "trait_weak"
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NEIGHBOR_RIVALS_NEG
		trigger = {
			any_neighbor_country = {
				OR = {
					is_hostile_to = from
					is_domineering_to = from
					is_rival = from
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FANATIC_PURIFIERS_NEG
		trigger = {
			has_valid_civic = civic_fanatic_purifiers
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_DUELIST_NEG
		trigger = {
			num_assigned_jobs = {
				job = duelist
				value > 0
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_UNRESTRICTED_WARS_NEG
		trigger = {
			has_policy_flag = unrestricted_wars
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NON_AGGRESSION_PACTS_POS
		trigger = {
			num_non_aggression_pacts > 0
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_pacifist = yes }
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_pacifist
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_pacifist }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_pacifist
				is_faction_extorted = yes
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_pacifist
				has_ethic = ethic_fanatic_pacifist
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_pacifist
								has_ethic = ethic_pacifist
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}
		modifier = {
			factor = 2
			hidden_trigger = {
				is_country_type = default
				is_pacifist = no
			}
			has_faction = prosperity
		}
		modifier = {
			factor = 1.5
			has_valid_civic = civic_inwards_perfection
		}
		modifier = {
			factor = 0.5
			has_valid_civic = civic_fanatic_purifiers
		}

		modifier = {
			factor = 2
			has_ethic = ethic_pacifist
		}
		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_pacifist
		}
		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|pacifist|
			desc = FROM_OVERLORD
		}
		modifier = {
			factor = value:pacifist_ethics_from_peace
			is_country_type = default
			years_of_peace = {
				value > 20
				delay = 50
			}
			desc = FROM_PEACE
		}
		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_pacifist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_pacifist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 0.75
			has_policy_flag = unrestricted_wars
		}
		# Check for any leader on the Council with Faction's Ethic.
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|pacifist|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|pacifist|
				value != 1
			}
			desc = FROM_COUNCIL
		}
		modifier = {
			factor = value:pacifist_ethics_from_pacts
			check_variable_arithmetic = {
				which = value:pacifist_ethics_from_pacts
				value != 1
			}
			desc = FROM_EMPIRE_NON_AGGRESSION_PACTS
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = pacifist
			ETHIC_OPPOSED = militarist
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = pacifist
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 1.1
			has_trait = "trait_weak"
		}
		modifier = {
			factor = 0.5
			OR = {
				has_citizenship_rights = yes
				# can_be_military_leader = yes #
			}
			from = {
				owner = {
					any_neighbor_country = {
						from = { is_neighbor_of = prev }
						OR = {
							is_hostile_to = from.owner
							is_domineering_to = from.owner
							is_rival = from.owner
						}
					}
				}
			}
			desc = FROM_HOSTILE_NEIGHBORS
		}
	}
}

ethic_fanatic_spiritualist = {
	cost = 2
	category = "spi"
	category_value = 0

	regular_variant = ethic_spiritualist

	use_for_pops = no

	tags = {
		ETHIC_ALLOWS_TEMPLE
		ETHIC_DISALLOW_AI
	}

	country_modifier = {
		country_unity_produces_mult = 0.20
		edicts_upkeep_mult= -0.20
		edicts_cost_mult= -0.20
		add_attunement_the_composer_of_strands = @ethic_attunement2
	}

	random_weight = {
		base = 150
	}
}

ethic_spiritualist = {
	cost = 1
	category = "spi"
	category_value = 1

	fanatic_variant = ethic_fanatic_spiritualist

	tags = {
		ETHIC_ALLOWS_TEMPLE
		ETHIC_DISALLOW_AI
	}

	leader_background_job_weight = {
		high_priest = 25
		telepath = 25
		death_chronicler = 25
		necro_apprentice = 25
		preacher = 25
		mortal_initiate = 25
		haruspex = 25
		technophant = 25
		bureaucrat = 25
	}

	country_modifier = {
		country_unity_produces_mult = 0.10
		edicts_upkeep_mult = -0.10
		edicts_cost_mult = -0.10
		add_attunement_the_composer_of_strands = @ethic_attunement1
	}

	random_weight = {
		base = 100
	}

	pop_attraction_tag = {
		desc =	POP_ATTRACTION_SPIRITUALIST_POS
		trigger = {
			is_spiritualist = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_spiritualist = no
			has_faction = traditionalist
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_PSIONICS_POS
		trigger = {
			OR = {
				AND = {
					has_technology = "tech_psionic_theory"
					is_individual_machine = no
				}
				has_psionic_ascension = yes
				has_tradition = tr_psionics_psionic_assimilation
				has_tradition = tr_psionics_shroud_great_awakening
				any_owned_species = {
					has_psionic_species_trait = yes
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_SPIRITUALIST_DIPLOMACY_POS
		trigger = {
			any_relation = {
				OR = {
					is_in_federation_with = root
					has_defensive_pact = root
					has_commercial_pact = root
					AND = {
						is_subject = no
						has_migration_access = root
					}
				}
				is_spiritualist = yes
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_spiritualist = yes }
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_ROBOTS_NEG
		trigger = {
			any_owned_species = {
				is_robotic = yes
			}
			is_individual_machine = no
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_ROBOT_RIGHTS_NEG
		trigger = {
			has_policy_flag = ai_full_rights
			is_individual_machine = no
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_SPIFED_POS
		trigger = {
			has_federation = yes
			federation = {
				has_federation_type = spiritualist_federation
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_SPIFED_PERK_POS
		trigger = {
			has_federation = yes
			federation = {
				has_federation_type = spiritualist_federation
				has_federation_perk = spiritualist_envoys_1
			}
			any_owned_leader = {
				is_assigned_to_federation = yes
			}
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_spiritualist
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_spiritualist }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_spiritualist
				is_faction_extorted = yes
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_spiritualist
				has_ethic = ethic_fanatic_spiritualist
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_spiritualist
								has_ethic = ethic_spiritualist
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}
		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_spiritualist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_spiritualist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 2
			hidden_trigger = {
				is_country_type = default
				is_spiritualist = no
			}
			has_faction = traditionalist
		}
		modifier = {
			factor = 1.5
			has_federation = yes
			federation = {
				has_federation_type = spiritualist_federation
			}
			desc = FROM_FEDERATION
		}
		modifier = {
			factor = 1.2
			has_federation = yes
			federation = {
				has_federation_type = spiritualist_federation
				has_federation_perk = spiritualist_envoys_1
			}
			any_owned_leader = {
				is_assigned_to_federation = yes
			}
			desc = FROM_FEDERATION_LEADER
		}
		modifier = {
			factor = 2
			has_ethic = ethic_spiritualist
		}
		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_spiritualist
		}
		modifier = {
			factor = 1.1
			hidden_trigger = { is_country_type = default }
			has_technology = "tech_psionic_theory"
		}
		modifier = {
			factor = 1.5
			is_country_type = default
			has_psionic_ascension = yes
			desc = FROM_PSIONIC_ASCENSION
		}
		modifier = {
			factor = 1.5
			is_country_type = default
			OR = {
				has_tradition = tr_psionics_psionic_assimilation
				has_tradition = tr_psionics_shroud_great_awakening
			}
			desc = FROM_PSIONIC_TRADITIONS
		}
		modifier = {
			factor = 0.75
			hidden_trigger = { is_country_type = default }
			has_policy_flag = ai_full_rights
		}
		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|spiritualist|
			desc = FROM_OVERLORD
		}
		# Check for any leader on the Council with Faction's Ethic.
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|spiritualist|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|spiritualist|
				value != 1
			}
			desc = FROM_COUNCIL
		}

		modifier = {
			factor = value:spiritualist_ethics_from_relations
			check_variable_arithmetic = {
				which = value:spiritualist_ethics_from_relations
				value != 1
			}
			desc = FROM_RELATIONS
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = spiritualist
			ETHIC_OPPOSED = materialist
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = spiritualist
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 1.1
			is_latent_psionic_species = yes
			desc = HAS_LATENT_PSIONIC_TRAIT
		}
		modifier = {
			factor = 1.2
			is_psionic_species = yes
			desc = HAS_PSIONIC_TRAIT
		}
		modifier = {
			factor = 0.25
			is_robot_pop_group = yes
			owner = { is_individual_machine = no }
			desc = IS_ROBOTIC
		}
		modifier = {
			factor = 2
			has_cybernetic_creed_trait = yes
			desc = HAS_CYBERNETIC_CREED_TRAIT
		}
	}
}

ethic_fanatic_materialist = {
	cost = 2
	category = "spi"
	category_value = 4

	regular_variant = ethic_materialist

	category_opposite = yes

	use_for_pops = no

	tags = {
		ETHIC_ALLOWS_ACADEMIC_PRIVILEGE
		ETHIC_DISALLOW_BAN_AI
		ETHIC_DISALLOW_BAN_ROBOTS
	}

	country_modifier = {
		planet_pops_robotics_upkeep_mult = -0.2
		all_technology_research_speed = 0.10
		add_attunement_the_instrument_of_desire = @ethic_attunement2
	}

	random_weight = {
		base = 150
	}
}

ethic_materialist = {
	cost = 1
	category = "spi"
	category_value = 3

	fanatic_variant = ethic_fanatic_materialist

	category_opposite = yes

	tags = {
		ETHIC_ALLOWS_ACADEMIC_PRIVILEGE
		ETHIC_DISALLOW_BAN_AI
		ETHIC_DISALLOW_BAN_ROBOTS
	}

	leader_background_job_weight = {
		head_researcher = 25
		merchant = 25
		physicist = 25
		biologist = 25
		engineer = 25
		chemist = 25
		translucer = 25
		gas_refiner = 25
		roboticist = 25
		foundry = 25
		catalytic_technician = 25
		artificer = 25
		reassigner = 25
	}

	country_modifier = {
		planet_pops_robotics_upkeep_mult = -0.1
		all_technology_research_speed = 0.05
		add_attunement_the_instrument_of_desire = @ethic_attunement1
	}

	random_weight = {
		base = 100
	}

	pop_attraction_tag = {
		desc = POP_ATTRACTION_MATERIALIST_POS
		trigger = {
			is_materialist = yes
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_FACTION_POS
		trigger = {
			is_materialist = no
			has_faction = technologist
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_MECHANIST_POS
		trigger = {
			has_origin = origin_mechanists
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_CYBORGS_POS
		trigger = {
			NOT = {
				has_origin = origin_cybernetic_creed
			}
			any_owned_species = {
				has_trait = trait_cybernetic
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_ROBOTS_POS
		trigger = {
			any_owned_species = {
				is_robotic = yes
			}
			is_individual_machine = no
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_ROBOT_RIGHTS_POS
		trigger = {
			has_policy_flag = ai_full_rights
			is_individual_machine = no
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_OVERLORD_POS
		trigger = {
			is_subject = yes
			has_loyalty > 0
			overlord = { is_materialist = yes }
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_MATERIALIST_RESEARCH_POS
		trigger = {
			any_relation = {
				root = { has_research_agreement = prev }
				is_materialist = yes
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_MATERIALIST_DIPLOMACY_POS
		trigger = {
			any_relation = {
				OR = {
					is_in_federation_with = root
					has_defensive_pact = root
					has_commercial_pact = root
					AND = {
						is_subject = no
						has_migration_access = root
					}
				}
				is_materialist = yes
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_NATURAL_SCIENTISTS_POS
		trigger = {
			any_owned_species = {
				OR = {
					has_trait = "trait_natural_sociologists"
					has_trait = "trait_natural_engineers"
					has_trait = "trait_natural_physicists"
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_PRIESTS_NEG
		trigger = {
			is_spiritualist = yes
			num_assigned_jobs = {
				job = bureaucrat
				value > 0
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_RESEARCHFED_POS
		trigger = {
			has_federation = yes
			federation = {
				has_federation_type = research_federation
			}
		}
	}
	# Check for any leader on the Council with Faction's Ethic.
	pop_attraction_tag = {
		desc = POP_ATTRACTION_REPRESENTED_ON_COUNCIL
		trigger = {
			owner = {
				any_owned_leader = {
					OR = {
						is_ruler = yes
						is_councilor = yes
					}
					has_ethic = ethic_materialist
				}
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_GOVERNOR_POS
		trigger = {
			any_owned_planet = {
				exists = leader
				leader = { has_ethic = ethic_materialist }
			}
		}
	}
	pop_attraction_tag = {
		desc = POP_ATTRACTION_STATELY_ACCLIAM
		trigger = {
			has_edict = stately_acclaim
			any_pop_faction = {
				has_ethic = ethic_materialist
				is_faction_extorted = yes
			}
		}
	}
	#Cybercreed Research
	pop_attraction_tag = {
		desc = POP_ATTRACTION_CYBER_CREED_RESEARCH
		trigger = {
			owner = {
				has_country_flag = cybernetic_creed_research
			}
		}
	}

	# This = Country
	country_attraction = {
		base = 1
		modifier = {
			factor = 0
			NOR = {
				is_country_type = default
				has_ethic = ethic_materialist
				has_ethic = ethic_fanatic_materialist
				has_ethic = ethic_gestalt_consciousness # No governing ethic
				check_modifier_value = { # Allow foreign ethics if no governing ethics attraction
					modifier = pop_government_ethic_attraction
					value <= -1
				}
				AND = {
					is_country_type = primitive
					has_country_flag = preftl_societal_enlightenment_pact
					capital_scope = {
						has_observation_outpost = yes
						observation_outpost_owner = {
							OR = {
								has_ethic = ethic_fanatic_materialist
								has_ethic = ethic_materialist
							}
						}
					}
				}
			}
			desc = FROM_EMPIRE
		}
		# Effects of indoctrination mission
		modifier = {
			factor = 20
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_fanatic_materialist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 10
			is_country_type = primitive
			has_country_flag = preftl_societal_enlightenment_pact
			capital_scope = {
				has_observation_outpost = yes
				observation_outpost_owner = { has_ethic = ethic_materialist }
			}
			desc = FROM_OBSERVER
		}
		modifier = {
			factor = 2
			hidden_trigger = {
				is_country_type = default
				is_materialist = no
			}
			has_faction = technologist
		}

		modifier = {
			factor = 1.5
			has_federation = yes
			federation = {
				has_federation_type = research_federation
			}
			desc = FROM_FEDERATION
		}
		modifier = {
			factor = 2
			has_ethic = ethic_materialist
		}
		modifier = {
			factor = 3
			has_ethic = ethic_fanatic_materialist
		}
		modifier = {
			factor = 1.25
			has_origin = origin_mechanists
		}
		modifier = {
			factor = 1.25
			hidden_trigger = {
				is_country_type = default
				is_individual_machine = no
			}
			has_policy_flag = ai_full_rights
		}
		modifier = {
			exists = overlord
			has_loyalty > 0
			mult = value:ethics_from_overlord|ETHIC|materialist|
			desc = FROM_OVERLORD
		}
		modifier = {
			factor = value:count_councilors_with_ethic|ETHIC|materialist|
			check_variable_arithmetic = {
				which = value:count_councilors_with_ethic|ETHIC|materialist|
				value != 1
			}
			desc = FROM_COUNCIL
		}

		#Cyber Creed Research
		modifier = {
			factor = 1
			is_country_type = default
			has_country_flag = cybernetic_creed_research
			desc = FROM_CREED
		}

		modifier = {
			factor = value:materialist_ethics_from_relations
			check_variable_arithmetic = {
				which = value:materialist_ethics_from_relations
				value != 1
			}
			desc = FROM_RELATIONS
		}
	}

	# This = Pop group
	# From = Planet
	pop_attraction = {
		base = 1

		inline_script = {
			script = "ethics/governor_pop_attraction"
			ETHIC = materialist
			ETHIC_OPPOSED = spiritualist
		}

		inline_script = {
			script = "ethics/stately_acclaim_pop_attraction"
			ETHIC = materialist
		}

		modifier = {
			factor = 0
			has_trait = trait_hive_mind
		}
		modifier = {
			factor = 2.0
			is_robot_pop_group = yes
			owner = { is_individual_machine = no }
			desc = IS_ROBOTIC
		}
		modifier = {
			factor = 1.5
			has_trait = "trait_cybernetic"
		}
		modifier = {
			factor = 1.25
			is_robot_pop_group = no
			from = {
				any_owned_species = {
					is_robotic = yes
				}
			}
			owner = { is_individual_machine = no }
			desc = FROM_ROBOTS_COLONY
		}
		modifier = {
			factor = 1.25
			has_trait = "trait_natural_engineers"
		}
		modifier = {
			factor = 1.25
			has_trait = "trait_natural_sociologists"
		}
		modifier = {
			factor = 1.25
			has_trait = "trait_natural_physicists"
		}
	}
}

ethic_gestalt_consciousness = {
	cost = 3
	category = "hive"
	category_value = 0
	use_for_pops = yes

	country_modifier = {
		country_war_exhaustion_mult = -0.2
		country_ethic_influence_produces_add = 1
		intel_encryption_add = 2
		add_attunement_the_cradle_of_souls = @ethic_attunement3
	}

	tags = {
		ETHIC_GESTALT_CONSCIOUSNESS_NO_TUTORIAL
		ETHIC_GESTALT_CONSCIOUSNESS_AUTHORITY
		ETHIC_GESTALT_CONSCIOUSNESS_IMMORTAL_RULER
		ETHIC_GESTALT_CONSCIOUSNESS_NO_FACTIONS
		ETHIC_GESTALT_CONSCIOUSNESS_NO_CONSUMER_GOODS
		ETHIC_GESTALT_CONSCIOUSNESS_DOMESTIC_POP_SURVIVAL
		ETHIC_ALLOW_NO_RETREAT
	}

	random_weight = {
		base = 300 #higher weight since if it's not the first ethic chosen it will never be chosen.
		modifier = {
			factor = 0
			has_global_flag = game_started # additional traits (trait_hive_mind, trait_machine_unit) are only assigned and verified for empire designs, no effect after game start
		}
	}
}
