# Creates a list of the ten countries with the most artifacts
#As this effect is called in an effect, it creates the list with normal variables
#Look at the customizable localizations to see how the countries are displayed.
#Basically the custom loc uses the variable to display both the countries in their order as well as the variables of those countries
ztr_liberty_gdp_ranking_effect = {
	ordered_country = {
		limit = {
			NOT = { #Hopefully keeps revolutions to appear in the ranking
				is_revolutionary = yes
			}
			ztr_is_democratic = yes
		}
		order_by = gdp
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_gdp_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_liberty_gdp_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_gdp_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_gdp_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_gdp_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_gdp_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_gdp_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_gdp_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_gdp_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_gdp_rank_5_var
					value = prev
				}
			}
		}
	}	
}

ztr_autocracy_gdp_ranking_effect = {
	ordered_country = {
		limit = {
			NOT = { #Hopefully keeps revolutions to appear in the ranking
				is_revolutionary = yes
			}
			ztr_is_not_democratic = yes
		}
		order_by = gdp
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_gdp_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_autocracy_gdp_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_gdp_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_gdp_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_gdp_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_gdp_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_gdp_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_gdp_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_gdp_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_gdp_rank_5_var
					value = prev
				}
			}
		}
	}	
}

# Order by GDP

ztr_socialist_gdp_ranking_effect = {
	ordered_country = {
		limit = {
			NOT = { #Hopefully keeps revolutions to appear in the ranking
				is_revolutionary = yes
			}
			ztr_is_socialist = yes
		}
		order_by = gdp
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_socialist_gdp_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_socialist_gdp_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_socialist_gdp_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_socialist_gdp_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_socialist_gdp_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_socialist_gdp_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_socialist_gdp_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_socialist_gdp_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_socialist_gdp_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_socialist_gdp_rank_5_var
					value = prev
				}
			}
		}
	}	
}

ztr_individualist_gdp_ranking_effect = {
	ordered_country = {
		limit = {
			NOT = { #Hopefully keeps revolutions to appear in the ranking
				is_revolutionary = yes
			}
			ztr_is_individualist = yes
		}
		order_by = gdp
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_individualist_gdp_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_individualist_gdp_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_individualist_gdp_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_individualist_gdp_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_individualist_gdp_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_individualist_gdp_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_individualist_gdp_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_individualist_gdp_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_individualist_gdp_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_individualist_gdp_rank_5_var
					value = prev
				}
			}
		}
	}	
}

# Order by Liberty Index

ztr_liberty_index_ranking_effect = {
	ordered_country = {
		limit = {
			NOT = { #Hopefully keeps revolutions to appear in the ranking
				is_revolutionary = yes
			}
			ztr_is_democratic = yes
		}
		order_by = var:liberty_index_var
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_index_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_liberty_index_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_index_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_index_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_index_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_index_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_index_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_index_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_liberty_index_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_liberty_index_rank_5_var
					value = prev
				}
			}
		}
	}	
}

ztr_autocracy_index_ranking_effect = {
	ordered_country = {
		limit = {
			NOT = { #Hopefully keeps revolutions to appear in the ranking
				is_revolutionary = yes
			}
			ztr_is_not_democratic = yes
			var:liberty_index_var >= 1
			gdp > 1000000 # Avoids very small countries
		}
		order_by = {
			value =	{
				add = var:liberty_index_var
				multiply = -1 # revert sort order so the highest penalty delta goes first
			}
		}
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_index_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_autocracy_index_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_index_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_index_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_index_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_index_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_index_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_index_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_autocracy_index_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_autocracy_index_rank_5_var
					value = prev
				}
			}
		}
	}	
}

#Removes the ranking variables
ztr_liberty_autocracy_index_ranking_variables = {
	#GDP
	remove_variable = ztr_liberty_gdp_rank_1_var
	remove_variable = ztr_liberty_gdp_rank_2_var
	remove_variable = ztr_liberty_gdp_rank_3_var
	remove_variable = ztr_liberty_gdp_rank_4_var
	remove_variable = ztr_liberty_gdp_rank_5_var
	# remove_variable = ztr_autocracy_gdp_rank_1_var
	# remove_variable = ztr_autocracy_gdp_rank_2_var
	# remove_variable = ztr_autocracy_gdp_rank_3_var
	# remove_variable = ztr_autocracy_gdp_rank_4_var
	# remove_variable = ztr_autocracy_gdp_rank_5_var
	#Liberty Index
	remove_variable = ztr_liberty_index_rank_1_var
	remove_variable = ztr_liberty_index_rank_2_var
	remove_variable = ztr_liberty_index_rank_3_var
	remove_variable = ztr_liberty_index_rank_4_var
	remove_variable = ztr_liberty_index_rank_5_var
	# remove_variable = ztr_autocracy_index_rank_1_var
	# remove_variable = ztr_autocracy_index_rank_2_var
	# remove_variable = ztr_autocracy_index_rank_3_var
	# remove_variable = ztr_autocracy_index_rank_4_var
	# remove_variable = ztr_autocracy_index_rank_5_var
}

ztr_socialist_individualist_index_ranking_variables = {
    remove_variable = ztr_socialist_gdp_rank_1_var
	remove_variable = ztr_socialist_gdp_rank_2_var
	remove_variable = ztr_socialist_gdp_rank_3_var
	remove_variable = ztr_socialist_gdp_rank_4_var
	remove_variable = ztr_socialist_gdp_rank_5_var
	remove_variable = ztr_individualist_gdp_rank_1_var
	remove_variable = ztr_individualist_gdp_rank_2_var
	remove_variable = ztr_individualist_gdp_rank_3_var
	remove_variable = ztr_individualist_gdp_rank_4_var
	remove_variable = ztr_individualist_gdp_rank_5_var
}

# Nuclear Offense

ztr_nuclear_strength_ranking_effect = {
	ordered_country = {
		limit = {
			has_modifier = nuclear_capability
		}
		order_by = var:nuclear_strike_power_display
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_power_display_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_nuclear_strike_power_display_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_power_display_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_power_display_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_power_display_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_power_display_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_power_display_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_power_display_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_power_display_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_power_display_rank_5_var
					value = prev
				}
			}
		}
	}	
}

# Nuclear Defense

ztr_nuclear_defence_ranking_effect = {
	ordered_country = {
		limit = {
			has_modifier = nuclear_capability
		}
		order_by = var:nuclear_strike_defence_display
		max = 5 #Limits the list to the ten top countires
		check_range_bounds = no #prevents errors

		#This part checks one after another whether the the first, second, etc. ranked countries are saved already.
		#Luckily the ordered_country effect iterates through the countries one after another.
		#So the first country gets saved to the first variable but as that variable now is set,
		# the second country gets saved to the second variable and so on.
		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_defence_display_rank_1_var
					}
				}
			}
			root = { #The countries are actually saved to the country that uses the effect in the event window
				set_variable = {
					name = ztr_nuclear_strike_defence_display_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_defence_display_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_defence_display_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_defence_display_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_defence_display_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_defence_display_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_defence_display_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_nuclear_strike_defence_display_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_nuclear_strike_defence_display_rank_5_var
					value = prev
				}
			}
		}
	}	
}

#Removes the nuclear ranking variables
ztr_nuclear_ranking_variables = {
	# Offense
	remove_variable = ztr_nuclear_strike_power_display_rank_1_var
	remove_variable = ztr_nuclear_strike_power_display_rank_2_var
	remove_variable = ztr_nuclear_strike_power_display_rank_3_var
	remove_variable = ztr_nuclear_strike_power_display_rank_4_var
	remove_variable = ztr_nuclear_strike_power_display_rank_5_var
	# Defense
	remove_variable = ztr_nuclear_strike_defence_display_rank_1_var
	remove_variable = ztr_nuclear_strike_defence_display_rank_2_var
	remove_variable = ztr_nuclear_strike_defence_display_rank_3_var
	remove_variable = ztr_nuclear_strike_defence_display_rank_4_var
	remove_variable = ztr_nuclear_strike_defence_display_rank_5_var
}

ztr_un_permanent_member_ranking_effect = {
	ordered_country = {
		limit = {
			has_modifier = ztr_onu_permanent_member
		}
		order_by = prestige
		max = 10
		check_range_bounds = no

		if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_1_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_1_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_2_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_2_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_3_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_3_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_4_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_4_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_5_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_5_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_6_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_6_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_7_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_7_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_8_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_8_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_9_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_9_var
					value = prev
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					root = {
						has_variable = ztr_un_permanent_member_display_rank_10_var
					}
				}
			}
			root = {
				set_variable = {
					name = ztr_un_permanent_member_display_rank_10_var
					value = prev
				}
			}
		}
	}
}

ztr_un_permanent_member_ranking_variables = {
	remove_variable = ztr_un_permanent_member_display_rank_1_var
	remove_variable = ztr_un_permanent_member_display_rank_2_var
	remove_variable = ztr_un_permanent_member_display_rank_3_var
	remove_variable = ztr_un_permanent_member_display_rank_4_var
	remove_variable = ztr_un_permanent_member_display_rank_5_var
	remove_variable = ztr_un_permanent_member_display_rank_6_var
	remove_variable = ztr_un_permanent_member_display_rank_7_var
	remove_variable = ztr_un_permanent_member_display_rank_8_var
	remove_variable = ztr_un_permanent_member_display_rank_9_var
	remove_variable = ztr_un_permanent_member_display_rank_10_var
}

ztr_un_major_power_support_vote_display_effect = {
	ordered_scope_je_involved = {
		limit = {
			country_rank >= rank_value:major_power
			has_variable = ztr_un_vote_choice_support
		}
		order_by = prestige
		max = 10
		check_range_bounds = no

		if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_1_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_1_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_2_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_2_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_3_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_3_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_4_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_4_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_5_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_5_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_6_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_6_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_7_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_7_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_8_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_8_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_9_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_9_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_display_rank_10_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_display_rank_10_var
				value = this
			}
		}
	}
}

ztr_un_major_power_neutral_vote_display_effect = {
	ordered_scope_je_involved = {
		limit = {
			country_rank >= rank_value:major_power
			has_variable = ztr_un_vote_choice_neutral
		}
		order_by = prestige
		max = 10
		check_range_bounds = no

		if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_1_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_1_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_2_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_2_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_3_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_3_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_4_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_4_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_5_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_5_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_6_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_6_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_7_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_7_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_8_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_8_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_9_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_9_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_neutral_vote_display_rank_10_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_neutral_vote_display_rank_10_var
				value = this
			}
		}
	}
}

ztr_un_major_power_against_vote_display_effect = {
	ordered_scope_je_involved = {
		limit = {
			country_rank >= rank_value:major_power
			has_variable = ztr_un_vote_choice_against
		}
		order_by = prestige
		max = 10
		check_range_bounds = no

		if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_1_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_1_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_2_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_2_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_3_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_3_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_4_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_4_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_5_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_5_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_6_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_6_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_7_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_7_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_8_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_8_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_9_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_9_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_against_vote_display_rank_10_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_against_vote_display_rank_10_var
				value = this
			}
		}
	}
}

ztr_un_major_power_vote_display_variables = {
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_1_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_2_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_3_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_4_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_5_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_6_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_7_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_8_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_9_var
	remove_global_variable = ztr_un_major_power_support_vote_display_rank_10_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_1_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_2_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_3_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_4_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_5_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_6_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_7_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_8_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_9_var
	remove_global_variable = ztr_un_major_power_neutral_vote_display_rank_10_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_1_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_2_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_3_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_4_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_5_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_6_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_7_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_8_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_9_var
	remove_global_variable = ztr_un_major_power_against_vote_display_rank_10_var
}

ztr_un_major_power_support_vote_display_global_effect = {
	ordered_scope_je_involved = {
		limit = {
			country_rank >= rank_value:major_power
			has_variable = ztr_un_vote_choice_support
		}
		order_by = prestige
		max = 2
		check_range_bounds = no

		if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_global_display_rank_1_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_global_display_rank_1_var
				value = this
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_un_major_power_support_vote_global_display_rank_2_var
				}
			}
			set_global_variable = {
				name = ztr_un_major_power_support_vote_global_display_rank_2_var
				value = this
			}
		}
	}
}

# Polluters Ranking

ztr_global_warming_rank_polluters = {
	ordered_country = {
		limit = {
			NOT = {
				is_country_type = decentralized
			}
			has_variable = ztr_country_total_pollution_current_var
			var:ztr_country_total_pollution_current_var > 0
		}
		order_by = var:ztr_country_total_pollution_current_var
		max = 10
		check_range_bounds = no
		if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_1_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_1_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_1_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_1_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_2_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_2_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_2_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_2_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_3_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_3_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_3_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_3_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_4_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_4_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_4_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_4_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_5_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_5_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_5_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_5_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_6_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_6_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_6_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_6_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_7_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_7_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_7_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_7_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_8_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_8_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_8_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_8_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_9_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_9_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_9_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_9_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_global_variable = ztr_global_warming_polluter_rank_10_var
				}
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_10_var
				value = this
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_10_pollution_var
				value = var:ztr_country_total_pollution_current_var
			}
			set_global_variable = {
				name = ztr_global_warming_polluter_rank_10_change_var
				value = var:ztr_country_total_pollution_change_var
			}
		}
	}
}
