# Vanilla scripted triggers from 01_scripted_triggers_refugees.txt
is_valid_refugee_pop = {
	is_non_sapient_robot = no
	NOR = {
		merg_has_hive_trait = yes
		can_think = no
		AND = {
			has_virtual_species_trait = yes
			exists = owner
			owner = {
				NOT = {
					has_active_tradition = tr_virtuality_finish
				}
			}
		}
	}
	owner = {
		any_relation = {
			merg_is_default_empire = yes
			has_communications = prev #relations include countries that have made first contact but not established comms
			NOT = { has_policy_flag = refugees_not_allowed }
			prevprev = {
				#this ensures Pop scope, as root will not always be pop scope
				OR = {
					has_citizenship_type = { type = citizenship_full country = prev }
					has_citizenship_type = { type = citizenship_organic_trophy country = prev }
					AND = {
						OR = {
							has_citizenship_type = { type = citizenship_limited country = prev }
							# SirBlackAxe's Unofficial Bug Patch
							has_citizenship_type = { type = citizenship_assimilation country = prev }
						}
						prev = { has_policy_flag = refugees_allowed }
					}
				}
			}
			OR = {
				AND = {
					has_policy_flag = robots_allowed
					prevprev = { is_robotic_species = yes }
				}
				prevprev = { is_robotic_species = no }
			}
			any_owned_planet = {
				is_under_colonization = no
				is_controlled_by = owner
				has_orbital_bombardment = no
			}
		}
	}
}
