#######################
# SPECIALIST SUBJECTS #
#######################

has_specialist_subject = {
	is_overlord = yes
	any_agreement = { has_active_specialization = any }
}

has_specialist_subject_type = {
	is_overlord = yes
	any_agreement = { has_active_specialization = specialist_$TYPE$ }
}

has_specialist_subject_tier = {
	is_overlord = yes
	any_agreement = {
		has_active_specialization = specialist_$TYPE$
		specialist_tier >= $TIER$
	}
}

is_subject_with_preset = {
	is_subject = yes
	any_agreement = { agreement_preset = $PRESET$ }
}

is_specialist_subject = {
	is_subject = yes
	any_agreement = { has_active_specialization = any }
}

is_specialist_subject_type = {
	is_subject = yes
	any_agreement = { has_active_specialization = specialist_$TYPE$ }
}

is_specialist_subject_tier = {
	is_subject = yes
	any_agreement = {
		has_active_specialization = specialist_$TYPE$
		specialist_tier >= $TIER$
	}
}

is_near_specialist_subject = {
	exists = owner
	solar_system = {
		closest_system = {
			max_steps = 2
			limit = {
				exists = owner
				owner = {
					has_overlord = ROOT.owner
					is_specialist_subject_type = { TYPE = $TYPE$ }
				}
			}
		}
	}
}

overlord_has_num_armies_on_planet = {
	count_planet_army = {
		count = $NUM$
		limit = {
			exists = owner
			exists = ROOT.owner
			ROOT.owner = { has_overlord = PREV.owner }
		}
	}
}

overlord_has_more_than_num_armies_on_planet = {
	count_planet_army = {
		count > $NUM$
		limit = {
			exists = owner
			exists = ROOT.owner
			ROOT.owner = { has_overlord = PREV.owner }
		}
	}
}

valid_for_scholarium_sensors = {
	is_colony = no
	is_preventing_anomaly = no
	can_have_sensory_readings = yes
}

valid_for_prospectorium_discovery = {
	has_deposit = no
	has_anomaly = no
	is_preventing_anomaly = no
	NOT = { has_planet_flag = resource_discovery_flag }
	can_have_resource_discovery = yes
}

federation_check_for_subject_trigger = {
	custom_tooltip = {
		fail_text = same_federation_as_overlord
		OR = {
			has_federation = no
			is_subject = no
			AND = {
				is_subject = yes
				is_in_federation_with = overlord
			}
		}
	}
}

#fleet scope
is_merc_enclave_founding_allowed = {
	owner = {
		NOR = {
			has_origin = origin_mindwardens
			AND = {
				has_ethic = ethic_gestalt_consciousness
				NOT = { has_valid_civic = civic_machine_tactical_algorithms }
			}
			has_civic = civic_fanatic_purifiers
		}
	}
	is_enclave_founding_allowed = {
		FLEET_SIZE = 100
		STARBASE_SHIP_SIZE = enclave_mercenary_station
	}
}

#################
# Hyper Relays  #
#################

has_hyper_relay = {
	OR = {
		has_megastructure = hyper_relay
		has_megastructure = hyper_relay_restored
	}
}

has_any_hyper_relay = {
	OR = {
		has_megastructure = hyper_relay
		has_megastructure = hyper_relay_ruined
		has_megastructure = hyper_relay_restored
	}
}

#####################
# Quantum Catapult #
#####################

# Scope: megastructure
is_quantum_catapult_megastructure = {
	OR = {
		is_megastructure_type = quantum_catapult_0
		is_megastructure_type = quantum_catapult_1
		is_megastructure_type = quantum_catapult_2
		is_megastructure_type = quantum_catapult_3
		is_megastructure_type = quantum_catapult_ruined
		is_megastructure_type = quantum_catapult_restored
		is_megastructure_type = quantum_catapult_ruined_slingshot
		is_megastructure_type = quantum_catapult_restored_slingshot
		is_megastructure_type = quantum_catapult_improved_slingshot
	}
}

# Scope: megastructure
# Excludes construction platform (_0) and ruined variants
is_functional_quantum_catapult_megastructure = {
	OR = {
		is_megastructure_type = quantum_catapult_1
		is_megastructure_type = quantum_catapult_2
		is_megastructure_type = quantum_catapult_3
		is_megastructure_type = quantum_catapult_restored
		is_megastructure_type = quantum_catapult_restored_slingshot
		is_megastructure_type = quantum_catapult_improved_slingshot
	}
}

######################
# More Shroudwalking #
######################
shroudwalker_insight_purchasing_trigger = {
	custom_tooltip = {
		fail_text = shroudwalker_insight_cooldown_tt
		NOT = { has_country_flag = shroudwalker_insight_cooldown }
	}
	resource_stockpile_compare = {
		resource = influence
		value >= 50
	}
	resource_stockpile_compare = {
		resource = energy
		value >= 10
		mult = $TARGET$.trigger:empire_size
	}
}

shroudwalker_insight_save_spynetwork_trigger = {
	OR = {
		NOT = { exists = event_target:$EVENT_TARGET$ }
		target = { is_same_value = event_target:$EVENT_TARGET$ }
		root = {
			NOT = {
				any_spynetwork = {
					owner = { is_same_value = root }
					target = {
						is_country_type = default
						is_same_value = event_target:$EVENT_TARGET$
					}
					exists = leader
				}
			}
		}
	}
}

##########
# Galcom #
##########
not_allowed_for_galcom_resolution_trigger = {
	OR = {
		NOT = { owner = { is_galactic_community_member = yes } }
		NOT = { target = { is_galactic_community_member = yes } }
		NOT = { is_active_resolution = $RESOLUTION$ }
	}
}
