limit = {
	exists = $ENEMY$
	$NOMAD$ = {
		is_at_war_with = $ENEMY$
		any_war = {
			any_$ENEMY_SIDE$ = {
				is_same_value = $ENEMY$
			}
			any_$NOMAD_SIDE$ = {
				is_same_value = prevprev
			}
			any_$NOMAD_SIDE$ = {
				is_nomadic = no #Nomads shouldn't be able to have claims but adding this just in case
			}
		}
	}
}
$NOMAD$ = {
	random_war = {
		limit = {
			any_$ENEMY_SIDE$ = {
				is_same_value = $ENEMY$
			}
			any_$NOMAD_SIDE$ = {
				is_same_value = prevprev
			}
			any_$NOMAD_SIDE$ = {
				is_nomadic = no #Nomads shouldn't be able to have claims but adding this just in case
			}
		}
		ordered_$NOMAD_SIDE$ = {
			limit = {
				is_nomadic = no
			}
			position = 0
			order_by = capital_scope.solar_system.value:distance_to_target|TARGET|$TARGET_SYSTEM$| #If we have no claims we go to the ally whose border is the closest to the system
			$TARGET_SYSTEM$.starbase = {
				set_owner = prev
			}
		}
	}
}
