# from = country
# this = species
#triggered_pop_group_modifier = {
#	potential = { is_pop_category = ruler }
#	pop_happiness = 0.15
#}

living_standard_organic_trophy = {
	triggered_pop_group_modifier = {
		potential = {
			owner? = { NOT = { has_deficit = consumer_goods } }
			OR = {
				is_pop_category = bio_trophy
				is_pop_category = cruise_passenger
			}
		}
		pop_happiness = 0.4
	}

	triggered_pop_group_modifier = {
		potential = {
			OR = {
				owner? = { has_deficit = consumer_goods }
				NOR = {
					is_pop_category = bio_trophy
					is_pop_category = cruise_passenger
				}
			}
		}
		pop_happiness = -0.4
	}

	pop_group_modifier = {
		pop_category_bio_trophy_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
	}

	# Forever Cruise Bio-Trophy Passengers also add the luxury upkeep of First-Class Passengers.
	triggered_pop_group_modifier = {
		potential = {
			owner? = { is_hospitality_servitor_empire = yes }
		}
		pop_category_cruise_passenger_consumer_goods_upkeep_add = @living_standard_luxuries_very_high_passenger
	}

	potential = {
		exists = from
		from = {
			is_machine_empire = yes
			has_valid_civic = civic_machine_servitor
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = species_is_not_trophy
			has_citizenship_type = {
				type = citizenship_organic_trophy
				country = from
			}
		}
	}

	ai_will_do = {
		factor = 100
	}
}
living_standard_chemical_bliss = {
	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_happiness = 0.4
	}

	pop_group_modifier = {
		pop_bonus_workforce_mult = -0.6
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_low
	}

	potential = {
		from = {
			has_technology = tech_subdermal_stimulation
			NOT = { has_valid_civic = civic_dystopian_society }
		}
		NOR = {
			has_trait = trait_hive_mind
			has_trait = trait_mechanical
			has_trait = trait_machine_unit
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = is_slaves_chattel_or_domestic
			if = {
				limit = {
					has_citizenship_type = { country = from type = citizenship_slavery }
				}
				NOR = {
					has_slavery_type = { country = from type = slavery_normal }
					has_slavery_type = { country = from type = slavery_domestic }
				}
			}
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}

	ai_will_do = {
		factor = 0
	}
}

living_standard_shared_burden = {
	potential = {
		exists = from
		from = { has_valid_civic = civic_shared_burden }
		is_cruise_passenger = no
	}

	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_happiness = 0.05
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_shared_burden
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_shared_burden
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_shared_burden
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_shared_burden
		pop_cat_ruler_political_power = 3
		pop_cat_specialist_political_power = 3
		pop_cat_worker_political_power = 3
		pop_cat_civilian_political_power = 3
		pop_civilian_bonus_workforce_mult = 0.15
	}

	triggered_pop_group_modifier = {
		potential = {
			is_pop_category = civilian
		}
		pop_category_civilians_unity_produces_add = 1
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = is_slaves_tooltip
			NOT = { has_citizenship_type = { country = from type = citizenship_slavery } }
		}
		custom_tooltip = {
			fail_text = is_servitude_tooltip
			NOT = { has_citizenship_type = { country = from type = citizenship_robot_servitude } }
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}

	ai_will_do = {
		factor = 1
	}
}

living_standard_dystopian_society = {
	potential = {
		exists = from
		NOT = { has_resource_slavery_type = yes }
		from = { has_valid_civic = civic_dystopian_society }
		is_cruise_passenger = no
	}

	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_cat_ruler_happiness = 0.25
	}

	triggered_pop_group_modifier = {
		potential = {
			is_pop_category = ruler
		}
		pop_amenities_usage_mult = 0.45
	}

	triggered_pop_group_modifier = {
		potential = {
			NOR = {
				is_pop_category = ruler
			}
		}
		pop_happiness = -2
	}

	triggered_pop_group_modifier = {
		potential = {
			OR = {
				is_pop_category = specialist
				is_pop_category = worker
				is_pop_category = civilian
				is_pop_category = criminal
				is_enslaved = yes
			}
		}
		pop_amenities_usage_base = -1
		pop_entertainer_bonus_workforce_mult = -1
		pop_maintenance_drone_bonus_workforce_mult = -1
	}

	triggered_pop_group_modifier = {
		potential = {
			OR = {
				AND = {
					is_unemployed = yes
					is_pop_category = ruler
				}
				AND = {
					exists = owner
					owner = { has_deficit = consumer_goods }
				}
			}
		}
		pop_happiness = -0.25
	}


	in_breach_of = {
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_greater_than_ourselves
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_balance_in_the_middle
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_universal_prosperity_mandate
		}
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high_decadent
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_low_decadent
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_low
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_low
		planet_pops_enslaved_consumer_goods_upkeep_mult = -0.50
		pop_cat_ruler_political_power = 10
		pop_cat_specialist_political_power = -0.25
		pop_cat_worker_political_power = -0.75
		pop_cat_civilian_political_power = -1
		pop_civilian_bonus_workforce_mult = -0.1
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = empire_is_dystopian_society
			from = { has_valid_civic = civic_dystopian_society }
		}
		custom_tooltip = {
			fail_text = is_undesirables_tooltip
			NOR = {
				has_citizenship_type = { country = from type = citizenship_purge_machine }
				has_citizenship_type = { country = from type = citizenship_purge }
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}

	ai_will_do = {
		factor = 1
	}
}

living_standard_worker_ownership = {
	potential = {
		exists = from
		from = { is_worker_coop_empire = yes }
		is_cruise_passenger = no
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_cat_ruler_political_power = 3
		pop_cat_specialist_political_power = 3
		pop_cat_worker_political_power = 3
		pop_cat_civilian_political_power = 3
	}

	triggered_pop_group_modifier = {
		potential = {
			exists = owner
			owner = {
				has_active_tradition = tr_mercantile_worker_coop_improved_ownership
			}
		}
		pop_happiness = 0.05
		pop_bonus_workforce_mult = 0.05
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = is_slaves_tooltip
			NOT = { has_citizenship_type = { country = from type = citizenship_slavery } }
		}
		custom_tooltip = {
			fail_text = is_servitude_tooltip
			NOR = { has_citizenship_type = { country = from type = citizenship_robot_servitude } }
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}

	ai_will_do = {
		factor = 1
	}
}

living_standard_utopian = {
	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_happiness = 0.20
	}

	triggered_pop_group_modifier = {
		potential = {
			is_pop_category = civilian
		}
		pop_category_civilians_society_research_produces_add = 0.50
		pop_category_civilians_physics_research_produces_add = 0.50
		pop_category_civilians_engineering_research_produces_add = 0.50
		pop_category_civilians_unity_produces_add = 0.50
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_cat_ruler_political_power = 4
		pop_cat_specialist_political_power = 4
		pop_cat_worker_political_power = 4
		pop_cat_civilian_political_power = 4
	}

	potential = {
		exists = from
		from = {
			is_gestalt = no
			NOT = { has_valid_civic = civic_dystopian_society }
		}
		NOR = {
			has_trait = trait_hive_mind
			AND = {
				from = { is_individual_machine = no }
				has_trait = trait_machine_unit
			}
			is_shackled_robot_species_rights = yes
			is_cruise_passenger = yes
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = empire_not_egalitarian
			from = {
				is_egalitarian = yes
			}
		}
		custom_tooltip = {
			fail_text = is_slaves_tooltip
			NOT = { has_citizenship_type = { country = from type = citizenship_slavery } }
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}

	ai_will_do = {
		factor = 15
		modifier = {
			factor = 0
			NOT = { has_citizenship_type = { country = from type = citizenship_full } }
		}
		modifier = {
			factor = 0
			NOT = { has_living_standard = { country = from type = living_standard_utopian } }
			NOT = {
				from = {
					has_monthly_income = {
						resource = minerals
						value > 300
					}
				}
			}
		}
		modifier = {
			factor = 0
			has_living_standard = { country = from type = living_standard_utopian }
			NOT = {
				from = {
					has_monthly_income = {
						resource = minerals
						value > 200
					}
				}
			}
		}
	}
}

living_standard_good = {

	in_breach_of = {
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_universal_prosperity_mandate
		}
	}

	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_happiness = 0.05
	}

	triggered_pop_group_modifier = {
		potential = {
			is_pop_category = civilian
		}
		pop_category_civilians_unity_produces_add = 0.5
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_cat_ruler_political_power = 4
		pop_cat_specialist_political_power = 3
		pop_cat_worker_political_power = 2
		pop_cat_civilian_political_power = 2
	}

	potential = {
		exists = from
		from = {
			is_gestalt = no
			NOR = {
				has_valid_civic = civic_shared_burden
				is_worker_coop_empire = yes
				has_valid_civic = civic_dystopian_society
			}
		}
		NOR = {
			has_trait = trait_hive_mind
			is_cruise_passenger = yes
		}
		OR = {
			AND = {
				is_robotic_species = yes
				OR = {
					species_rights_robot_full_rights_check = yes
					from = { is_individual_machine = yes }
				}
			}
			is_robotic_species = no
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = is_slaves_chattel_or_domestic
			if = {
				limit = {
					has_citizenship_type = { country = from type = citizenship_slavery }
				}
				NOR = {
					has_slavery_type = { country = from type = slavery_normal }
					has_slavery_type = { country = from type = slavery_domestic }
				}
			}
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
		custom_tooltip = {
			fail_text = "SCORCHED_HERALDS_ONLY_INF"
			if = {
				limit = { from = { is_genocidal_infernal = yes } }
				has_trait = trait_infernal
			}
		}
	}
	ai_will_do = {
		factor = 5
		modifier = {
			factor = 0
			NOT = { has_citizenship_type = { country = from type = citizenship_full } }
		}
		modifier = {
			factor = 0
			from = {
				NOR = {
					is_pacifist = yes
					is_egalitarian = yes
				}
			}
		}
		modifier = {
			factor = 0
			NOT = { has_living_standard = { country = from type = living_standard_good } }
			NOT = {
				from = {
					has_monthly_income = {
						resource = minerals
						value > 150
					}
				}
			}
		}
		modifier = {
			factor = 0
			has_living_standard = { country = from type = living_standard_good }
			NOT = {
				from = {
					has_monthly_income = {
						resource = minerals
						value > 100
					}
				}
			}
		}
		modifier = {
			factor = 0.25
			from = {
				is_galactic_community_member = yes
			}
			OR = {
				is_active_resolution = "resolution_greatergood_universal_prosperity_mandate"
			}
		}
	}
}

living_standard_academic_privilege = {
	in_breach_of = {
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_balance_in_the_middle
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_universal_prosperity_mandate
		}
	}

	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		researcher_jobs_bonus_workforce_mult = 0.1
		pop_cat_ruler_happiness = 0.15
		pop_cat_specialist_happiness = 0.15
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_normal
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_normal
		pop_cat_ruler_political_power = 6
		pop_cat_specialist_political_power = 2.5
		pop_cat_worker_political_power = 0.5
		pop_cat_civilian_political_power = 0.5
	}

	potential = {
		exists = from
		from = {
			is_gestalt = no
			NOR = {
				has_valid_civic = civic_shared_burden
				is_worker_coop_empire = yes
				has_valid_civic = civic_dystopian_society
			}
		}
		NOR = {
			has_trait = trait_hive_mind
			AND = {
				from = { is_individual_machine = no }
				has_trait = trait_machine_unit
			}
			is_shackled_robot_species_rights = yes
			is_cruise_passenger = yes
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = empire_not_materialist
			from = {
				is_materialist = yes
			}
		}
		custom_tooltip = {
			fail_text = is_slaves_tooltip
			NOT = { has_citizenship_type = { country = from type = citizenship_slavery } }
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
		custom_tooltip = {
			fail_text = "SCORCHED_HERALDS_ONLY_INF"
			if = {
				limit = { from = { is_genocidal_infernal = yes } }
				has_trait = trait_infernal
			}
		}
	}

	ai_will_do = {
		factor = 10
		modifier = {
			factor = 0
			NOT = { has_citizenship_type = { country = from type = citizenship_full } }
		}
		modifier = {
			factor = 0
			NOT = { has_living_standard = { country = from type = living_standard_academic_privilege } }
			NOT = {
				from = {
					has_monthly_income = {
						resource = minerals
						value > 300
					}
				}
			}
		}
		modifier = {
			factor = 0
			has_living_standard = { country = from type = living_standard_academic_privilege }
			NOT = {
				from = {
					has_monthly_income = {
						resource = minerals
						value > 200
					}
				}
			}
		}

		modifier = {
			factor = 0.25
			from = {
				is_galactic_community_member = yes
			}
			OR = {
				is_active_resolution = "resolution_greatergood_balance_in_the_middle"
				is_active_resolution = "resolution_greatergood_universal_prosperity_mandate"
			}
		}
	}
}

living_standard_normal = {
	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_cat_ruler_happiness = 0.10
		pop_cat_specialist_happiness = 0.05
	}

	in_breach_of = {
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_balance_in_the_middle
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_universal_prosperity_mandate
		}
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_normal
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_normal
		pop_cat_ruler_political_power = 5.0
		pop_cat_specialist_political_power = 2.5
		pop_cat_worker_political_power = 1.5
		pop_cat_civilian_political_power = 1.5
	}

	potential = {
		exists = from
		NOT = { has_resource_slavery_type = yes }
		from = {
			is_gestalt = no
			NOR = {
				has_valid_civic = civic_shared_burden
				is_worker_coop_empire = yes
				has_valid_civic = civic_dystopian_society
			}
		}
		NOR = {
			has_trait = trait_hive_mind
			AND = {
				from = { is_individual_machine = no }
				has_trait = trait_machine_unit
			}
			is_shackled_robot_species_rights = yes
			is_cruise_passenger = yes
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = "SCORCHED_HERALDS_ONLY_INF"
			if = {
				limit = { from = { is_genocidal_infernal = yes } }
				has_trait = trait_infernal
			}
		}
	}
	ai_will_do = {
		factor = 1
		modifier = {
			factor = 0.5
			from = {
				is_galactic_community_member = yes
			}
			OR = {
				is_active_resolution = "resolution_greatergood_balance_in_the_middle"
				is_active_resolution = "resolution_greatergood_universal_prosperity_mandate"
			}
		}
	}
}

living_standard_stratified = {

	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_cat_ruler_happiness = 0.15
		pop_cat_specialist_happiness = 0.05
	}

	in_breach_of = {
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_greater_than_ourselves
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_balance_in_the_middle
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_universal_prosperity_mandate
		}
	}

	# Triggered so the auto-generated modifier is hidden.
	triggered_pop_group_modifier = {
		potential = {
			always = yes
		}
		pop_cat_worker_happiness = -0.10
		pop_cat_civilian_happiness = -0.10
		pop_slave_happiness = -0.10
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_low
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_low
		pop_cat_ruler_political_power = 8
		pop_cat_specialist_political_power = 1.25
		pop_cat_worker_political_power = -0.25
		pop_cat_civilian_political_power = -0.25
	}

	potential = {
		exists = from
		from = {
			is_gestalt = no
			NOR = {
				has_valid_civic = civic_shared_burden
				is_worker_coop_empire = yes
				has_valid_civic = civic_dystopian_society
			}
		}
		NOR = {
			has_trait = trait_hive_mind
			AND = {
				from = { is_individual_machine = no }
				has_trait = trait_machine_unit
			}
			is_shackled_robot_species_rights = yes
			is_cruise_passenger = yes
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = empire_not_authoritarian
			from = { is_authoritarian = yes }
		}
		custom_tooltip = {
			fail_text = is_slaves_not_battle_thralls
			if = {
				limit = {
					has_citizenship_type = { country = from type = citizenship_slavery }
				}
				has_slavery_type = { country = from type = slavery_military }
			}
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}
	ai_will_do = {
		factor = 5
		modifier = {
			factor = 0.2
			from = {
				is_galactic_community_member = yes
			}
			OR = {
				is_active_resolution = "resolution_greatergood_greater_than_ourselves"
				is_active_resolution = "resolution_greatergood_balance_in_the_middle"
				is_active_resolution = "resolution_greatergood_universal_prosperity_mandate"
			}
		}
	}
}

living_standard_subsistence = {
	# Triggered so the auto-generated modifier is hidden.
	triggered_pop_group_modifier = {
		potential = {
			always = yes
		}
		pop_happiness = -0.20
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_high
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_normal
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_very_low
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_very_low
		pop_cat_ruler_political_power = 9.5
		pop_cat_worker_political_power = -0.5
		pop_cat_civilian_political_power = -1
	}

	in_breach_of = {
		{
			key = resolution_greatergood_five_year_plans
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_greater_than_ourselves
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_balance_in_the_middle
		}
		{
			trigger = {
				is_gestalt = no
			}
			key = resolution_greatergood_universal_prosperity_mandate
		}
	}


	potential = {
		exists = from
		NOT = { has_resource_slavery_type = yes }
		from = {
			NOR = {
				has_valid_civic = civic_shared_burden
				is_worker_coop_empire = yes
				has_valid_civic = civic_dystopian_society
			}
		}
		OR = {
			from = { is_gestalt = no }
			has_citizenship_type = { type = citizenship_slavery country = from }
		}
		NOR = {
			has_trait = trait_hive_mind
			AND = {
				from = { is_individual_machine = no }
				has_trait = trait_machine_unit
			}
			is_shackled_robot_species_rights = yes
			is_cruise_passenger = yes
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = MUST_BE_SLAVES_LIMITED_OR_DISPLACEMENT
			OR = {
				has_citizenship_type = { country = from type = citizenship_slavery }
				has_citizenship_type = { type = citizenship_limited country = from }
				AND = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
					has_purge_type = { country = from type = purge_displacement }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}
	ai_will_do = {
		factor = 10
		modifier = {
			factor = 0
			from = {
				is_xenophobe = no
				is_gestalt = no
			}
		}
		modifier = {
			factor = 0.1
			from = {
				is_galactic_community_member = yes
			}
			OR = {
				is_active_resolution = "resolution_greatergood_five_year_plans"
				is_active_resolution = "resolution_greatergood_greater_than_ourselves"
				is_active_resolution = "resolution_greatergood_balance_in_the_middle"
				is_active_resolution = "resolution_greatergood_universal_prosperity_mandate"
			}
		}
	}
}

living_standard_livestock = {
	potential = {
		exists = from
		has_citizenship_type = { country = from type = citizenship_slavery }
		has_slavery_type = {
			country = from
			type = slavery_livestock
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = species_is_not_livestock
			has_slavery_type = {
				country = from
				type = slavery_livestock
			}
		}
	}

	ai_will_do = {
		factor = 100
	}
}

living_standard_matrix = {
	potential = {
		exists = from
		has_citizenship_type = { country = from type = citizenship_slavery }
		has_slavery_type = {
			country = from
			type = slavery_matrix
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = species_is_not_matrix
			has_slavery_type = {
				country = from
				type = slavery_matrix
			}
		}
	}

	ai_will_do = {
		factor = 100
	}
}

living_standard_matrix_guided_sapience = {
	potential = {
		exists = from
		has_citizenship_type = { country = from type = citizenship_slavery }
		has_slavery_type = {
			country = from
			type = slavery_matrix_guided_sapience
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = species_is_not_matrix_guided_sapience
			has_slavery_type = {
				country = from
				type = slavery_matrix_guided_sapience
			}
		}
	}

	ai_will_do = {
		factor = 100
	}
}

living_standard_servitude = {

	potential = {
		exists = from
		from = { is_gestalt = no }
		OR = {
			has_trait = trait_mechanical
			has_trait = trait_machine_unit
		}
		is_cruise_passenger = no
	}

	allow = {
		custom_tooltip = {
			fail_text = requires_servitude
			has_citizenship_type = { type = citizenship_robot_servitude country = from }
		}
	}

	ai_will_do = {
		factor = 0
	}
}

# Used for pops that have no happiness
living_standard_hive_mind = {
	potential = {
		exists = from
		from = { has_ethic = ethic_gestalt_consciousness }
		OR = {
			NOT = { has_trait = trait_mechanical }
			NOT = { from = { has_origin = origin_shroud_forged } }
		}
		is_cruise_passenger = no
	}

	allow = {
		if = {
			limit = {
				from = { is_hive_empire = yes }
			}
			custom_tooltip = {
				fail_text = species_is_not_hive
				has_trait = trait_hive_mind
			}
		}
		else_if = {
			limit = { from = { is_machine_empire = yes } }
			custom_tooltip = {
				fail_text = species_is_not_machine
				OR = {
					has_trait = trait_machine_unit
					has_trait = trait_mechanical
					AND = {
						from = {
							OR = {
								has_civic = civic_machine_assimilator
								has_ascension_perk = ap_mechromancy
							}
						}
						has_trait = trait_cybernetic
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}

	ai_will_do = {
		factor = 1
	}
}

living_standard_decadent = {
	potential = {
		exists = from
		from = { is_pleasure_seeker_empire = yes }
		from = {
			NOR = {
				has_valid_civic = civic_shared_burden
				is_worker_coop_empire = yes
				has_valid_civic = civic_dystopian_society
			}
		}
		OR = {
			from = { is_gestalt = no }
			has_citizenship_type = { type = citizenship_slavery country = from }
		}
		NOR = {
			has_trait = trait_hive_mind
			AND = {
				from = { is_individual_machine = no }
				has_trait = trait_machine_unit
			}
			is_shackled_robot_species_rights = yes
			is_cruise_passenger = yes
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = is_slaves_tooltip
			NOT = { has_citizenship_type = { country = from type = citizenship_slavery } }
		}
		custom_tooltip = {
			fail_text = is_purged_not_neutered
			if = {
				limit = {
					OR = {
						has_citizenship_type = { country = from type = citizenship_purge_machine }
						has_citizenship_type = { country = from type = citizenship_purge }
					}
				}
				OR = {
					has_purge_type = { country = from type = purge_neutering }
					has_purge_type = { country = from type = purge_cosmogenesis_lathe_resettle }
				}
			}
		}
		custom_tooltip = {
			fail_text = SPECIES_MUST_NOT_BE_ASSIMILATING
			NOT = {
				has_citizenship_type = {
					type = citizenship_assimilation
					country = from
				}
			}
		}
	}

	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
			is_pop_category = civilian
		}
		key = job_fe_hedonist_plural
		pop_amenities_usage_base = 1
	}

	triggered_pop_group_modifier = {
		potential = {
			NAND = {
				exists = owner
				owner = { has_deficit = consumer_goods }
			}
		}
		pop_cat_ruler_happiness = 0.20
		pop_cat_specialist_happiness = 0.20
		pop_cat_worker_happiness = 0.20
		pop_cat_civilian_happiness = 0.20
	}

	triggered_pop_group_modifier = {
		# Triggered to hide from the auto-generated tooltip
		potential = {
			always = yes
		}
	}

	pop_group_modifier = {
		pop_category_rulers_consumer_goods_upkeep_add = @living_standard_luxuries_very_high_decadent
		pop_category_specialists_consumer_goods_upkeep_add = @living_standard_luxuries_high_decadent
		pop_category_workers_consumer_goods_upkeep_add = @living_standard_luxuries_normal_decadent
		pop_category_civilians_consumer_goods_upkeep_add = @living_standard_luxuries_very_high_decadent
		pop_amenities_usage_base = 0.5
		pop_cat_ruler_political_power = 7
		pop_cat_specialist_political_power = 2
	}

	ai_will_do = {
		factor = 10
	}
}

living_standard_protected = {
	potential = {
		exists = from
		from = {
			has_authority = auth_machine_intelligence
			has_origin = origin_shroud_forged
		}
		exists = this
		has_citizenship_type = { country = from type = citizenship_shroud_touched }
		is_cruise_passenger = no
	}

	allow = {
	}

	pop_group_modifier = {
		pop_category_drones_consumer_goods_upkeep_add = @living_standard_luxuries_high
	}

	triggered_pop_group_modifier = {
		potential = {
			exists = owner
			owner = {
				OR = {
					any_situation = {
						is_situation_type = situation_shroud_forged
						situation_progress >= @ShroudForgedAcceptanceThreshold
					}
					has_country_flag = finish_shroud_forged_liberation_flag
				}
			}
		}
		pop_category_drones_consumer_goods_upkeep_add = @living_standard_luxuries_high
	}

	ai_will_do = {
		factor = 10
	}
}

# only for purge, so no happiness effect
living_standard_none = {
	potential = {
		is_cruise_crew = no
		is_cruise_passenger = no
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			fail_text = species_is_neutered_displaced
			OR = {
				has_citizenship_type = { country = from type = citizenship_purge_machine }
				has_citizenship_type = { country = from type = citizenship_purge }
			}
		}
	}

	ai_will_do = {
		factor = 10
	}
}
