# Scripted Triggers Undercoat overwrites

is_playable = {
	merg_is_default_empire = yes
}
is_empire = {
	merg_is_standard_empire = yes
}
planet_gives_aquatics_bonus = {
	OR = {
		merg_is_aquatic = yes
		has_modifier = flooded_habitat
	}
}
is_endgame_crisis = {
	OR = {
		is_country_type = extradimensional
		is_country_type = extradimensional_2
		is_country_type = extradimensional_3
		is_country_type = swarm
		is_country_type = ai_empire
		is_country_type = synth_queen
		is_country_type = awakened_synth_queen
		is_country_type = synth_queen_storm
		# ACOT SBTG
		is_country_type = sbtg_stellarborne_empire
		# Gigastructural Engineering & More
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_giga_crisis_faction = yes
			"
			toggle = @has_gigastructures
		}
	}
}
has_slaver_civic = {
	merg_is_slaver = yes
}
is_planet_city = {
	merg_is_arcology = yes
}
is_city_world = {
	merg_is_arcology = yes
}
is_habitat = {
	merg_is_habitat = yes
}
is_shielded = {
	merg_is_shielded = yes
}
is_gaia_world = {
	merg_is_gaia = yes
}
is_hive_world = {
	merg_is_hive_world = yes
}
is_machine_world = {
	merg_is_machine_world = yes
}
is_relic_world = {
	merg_is_relic_world = yes
}
is_continental_world = {
	merg_is_continental = yes
}
is_tropical_world = {
	merg_is_tropical = yes
}
is_ocean_world = {
	merg_is_ocean = yes
}
is_desert_world = {
	merg_is_desert = yes
}
is_arid_world = {
	merg_is_arid = yes
}
is_savannah_world = {
	merg_is_savannah = yes
}
is_arctic_world = {
	merg_is_arctic = yes
}
is_tundra_world = {
	merg_is_tundra = yes
}
is_alpine_world = {
	merg_is_alpine = yes
}
is_gas_giant = {
	merg_is_gas_giant = yes
}
is_toxic_world = {
	merg_is_toxic = yes
}
is_frozen_world = {
	merg_is_frozen = yes
}
is_barren_dry_world = {
	merg_is_barren = yes
}
is_barren_cold_world = {
	merg_is_barren_cold = yes
}
is_barren_world = {
	merg_is_barren = yes
}
is_molten_world = {
	merg_is_molten = yes
}
planet_is_neutron_star_including_pulsar = {
	OR = {
		is_planet_class = pc_neutron_star
		is_planet_class = pc_pulsar
		# Real Space
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_planet_class_pc_collapsar = yes
				is_planet_class_pc_magnetar = yes
			"
			toggle = @rs_compatch_var
		}
	}
}
planet_is_nonstandard_star = {
	OR = {
		is_planet_class = pc_neutron_star
		is_planet_class = pc_pulsar
		is_planet_class = pc_black_hole
		# Real Space
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_planet_class_pc_collapsar = yes
				is_planet_class_pc_magnetar = yes
			"
			toggle = @rs_compatch_var
		}
		# Gigastructural Engineering & More
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				giga_is_black_hole = yes
			"
			toggle = @has_gigastructures
		}
		# TimeMod
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_tm_black_hole = yes
			"
			toggle = @timemod
		}
	}
}
planet_is_black_hole = {
	OR = {
		is_planet_class = pc_black_hole
		# Gigastructural Engineering & More
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				giga_is_black_hole = yes
			"
			toggle = @has_gigastructures
		}
		# TimeMod
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_tm_black_hole = yes
			"
			toggle = @timemod
		}
	}
}
can_have_defense_platforms = {
	is_scope_type = starbase
	OR = {
		has_starbase_size >= starbase_outpost
		has_starbase_size >= orbital_ring_tier_1
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				is_precursor_starbase = yes
			"
			toggle = @has_ancient_caches
		}
	}
}
has_unrestricted_cbs = {
	OR = {
		NOT = { has_policy_flag = liberation_wars }
		AND = {
			$target$ = { is_robot_empire = yes }
			NOR = {
				has_policy_flag = ai_full_rights
				is_robot_empire = yes
			}
		}
		AND = {
			$target$ = { is_gestalt = yes }
			OR = {
				AND = {
					is_xenophile = yes
					$target$ = { is_xenophile = no }
				}
				AND = {
					is_xenophobe = yes
					$target$ = { is_xenophobe = no }
				}
				AND = {
					is_authoritarian = yes
					$target$ = { is_authoritarian = no }
				}
				AND = {
					is_egalitarian = yes
					$target$ = { is_egalitarian = no }
				}
				AND = {
					is_spiritualist = yes
					$target$ = { is_spiritualist = no }
				}
				AND = {
					is_materialist = yes
					$target$ = { is_materialist = no }
				}
				AND = {
					is_militarist = yes
					$target$ = { is_militarist = no }
				}
				AND = {
					is_pacifist = yes
					$target$ = { is_pacifist = no }
				}
			}
			# Restrictions on which GCs the AI considerss worth making ideologically-motivated claims against
			[[check_ai_limits]
			OR = {
				is_ai = no
				# They're unworthy of autonomy, weaken them until we can subjugate them
				AND = {
					has_ai_personality_behaviour = subjugator
					from = { is_subject = no }
					relative_power = {
						who = $target$
						category = all
						value <= equivalent
					}
					# this is specifically for claims
					NAND = {
						exists = root
						exists = $target$.capital_star
						root = {
							is_scope_type = galactic_object
							is_same_value = $target$.capital_star
						}
					}
				}
				# They have subjects we need to "free"!
				$target$ = {
					any_owned_species = {
						NOR = {
							has_trait = trait_hive_mind
							has_trait = trait_machine_unit
						}
						is_sapient = yes
						can_think = yes
					}
				}
				# They have drones we need to "free"!
				AND = {
					has_tradition = tr_genetics_creation
					$target$ = { is_hive_empire = yes }
					is_hive_empire = no
					OR = {
						is_xenophile = no
						has_ethic = ethic_fanatic_egalitarian
					}
				}
			}
			]
		}
	}
}
