# Author(s): AngriestBird, Doolittle
# General EU Voting AI

# Utils for the common sections
EU_update_AI_general_voting_modifiers = {
	### modifiers for influence of ROOT on all other EU members
	if = { limit = { influence_higher_5 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 5 }
	}
	if = { limit = { influence_higher_10 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 5 }
	}
	if = { limit = { influence_higher_20 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 10 }
	}
	if = { limit = { influence_higher_30 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 10 }
	}
	if = { limit = { influence_higher_50 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 15 }
	}
	# Modifiers for Europeanism
	# The intent is that strongly pro-European members are more likely to support the EU; support scales down as europeanism falls
	if = { limit = { check_variable = { var = THIS.europeanism value = 0.801 compare = greater_than_or_equals } }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 40 }
	}
	if = { limit = { check_variable = { var = THIS.europeanism value = 0.8 compare = less_than_or_equals } }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -5 }
	}
	if = { limit = { check_variable = { var = THIS.europeanism value = 0.7 compare = less_than_or_equals } }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -10 }
	}
	if = { limit = { check_variable = { var = THIS.europeanism value = 0.6 compare = less_than_or_equals } }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -15 }
	}
	if = { limit = { check_variable = { var = THIS.europeanism value = 0.5 compare = less_than_or_equals } }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -20 }
	}
	if = { limit = { check_variable = { var = THIS.europeanism value = 0.3 compare = less_than_or_equals } }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -25 }
	}
	# if China or Russia have significant influence, AI will not support measures
	if = { limit = { EU_external_sov_chi_influence_15 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -75 }
	}
	if = { limit = { EU_external_sov_chi_influence_10 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -50 }
	}
	if = { limit = { EU_external_sov_chi_influence_5 = yes }
		add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -25 }
	}

	if = {
		limit = { is_subject = yes }
		if = { limit = { OVERLORD = { is_in_array = { global.EU_active_vote_supporters = THIS.id } } }
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 100 }
		}
		else = {
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -25 }
		}
	}

	# AI Difficulty check
	if = { limit = { has_global_flag = EUU_player_proposed_law }
		if = { limit = { difficulty > 1 }
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -10 }
		}
		if = { limit = { difficulty > 2 }
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -10 }
		}
		if = { limit = { difficulty > 3 }
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = -10 }
		}
	}
	else = {
		if = { limit = { difficulty > 1 }
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 10 }
		}
		if = { limit = { difficulty > 2 }
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 10 }
		}
		if = { limit = { difficulty > 3 }
			add_to_temp_variable = { var = EU_AI_focus_modifier_yes_vote value = 10 }
		}
	}

	# Common Law Section, this is something that can and is repeated so we will be tucking it in here with the general modifiers since that goes at the end.
	if = {
		limit = { is_ai = yes }
		if = {
			limit = {
				OR = {
					has_global_flag = EUU_all_nations_vote_yes
					check_variable = { EU_AI_focus_modifier_yes_vote > 0 }
				}
			}
			add_to_array = { global.EU_active_vote_supporters = THIS }
			add_to_variable = { global.EU_pop_ratio_yes = THIS.EU_pop_ratio }
		}
		else = {
			add_to_array = { global.EU_active_vote_rejecters = THIS }
			add_to_variable = { global.EU_pop_ratio_no = THIS.EU_pop_ratio }
		}
	}
	if = { limit = { is_debug = yes }
		log = "[GetDateText]: [THIS.GetName]: AI Voting Weight on EU Law Index: [?v], AI Weight: [?EU_AI_focus_modifier_yes_vote]"
	}
}

EU_law_party_value_weight = {
	if = {
		limit = {
			OR = {
				check_variable = { ruling_party = 1 } ### conservatism
				check_variable = { ruling_party = 6 } ### Conservative
				check_variable = { ruling_party = 14 } ### Neutral_conservatism
			}
		}
		add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = value1 }
	}
	else_if = {
		limit = {
			OR = {
				check_variable = { ruling_party = 2 } ### liberalism
				check_variable = { ruling_party = 16 } ### Neutral_Libertarian
			}
		}
		add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = value2 }
	}
	else_if = {
		limit = {
			OR = {
				check_variable = { ruling_party = 3 } ### socialism
				check_variable = { ruling_party = 18 } ### neutral_Social
			}
		}
		add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = value3 }
	}
	else_if = { limit = { check_variable = { ruling_party = 17 } } ### Neutral_green
		add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = value4 }
	}
	else_if = {
		limit = {
				OR = {
					check_variable = { ruling_party = 4 } ### communist_state
					check_variable = { ruling_party = 5 } ### anarchist_communism
					check_variable = { ruling_party = 19 } ### Neutral_Communism
				}
		}
		add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = value5 }
	}
	else_if = {
		limit = {
			OR = {
				check_variable = { ruling_party = 20 } ### Nat_Populism
				check_variable = { ruling_party = 21 } ### Nat_Fascism
				check_variable = { ruling_party = 22 } ### Nat_Autocracy
				check_variable = { ruling_party = 23 } ### Monarchist
			}
		}
		add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = value6 }
	}
}

### modifier for gov_resist
# Charter of Fundamental Rights - This one everyone supports but those stinky fascists
### Parameterized EU voting-AI focus modifiers (#1448) ###
# Replaces 47 near-identical EU_update_AI_focus_EU<NNN>_voting_modifier effects.

EU_init_focus_vote_weights = {
	# Per-focus AI voting weights w1..w6 + historical-focus add, indexed by agenda id.
	# One row per agenda; read by EU_update_AI_focus_voting_modifier via focus_index.
	set_variable = { global.EU_vote_w1^101 = 50 } set_variable = { global.EU_vote_w2^101 = 50 } set_variable = { global.EU_vote_w3^101 = 50 } set_variable = { global.EU_vote_w4^101 = 50 } set_variable = { global.EU_vote_w5^101 = 50 } set_variable = { global.EU_vote_w6^101 = -25 } set_variable = { global.EU_vote_hist^101 = 100 }
	set_variable = { global.EU_vote_w1^102 = 50 } set_variable = { global.EU_vote_w2^102 = 50 } set_variable = { global.EU_vote_w3^102 = 50 } set_variable = { global.EU_vote_w4^102 = 50 } set_variable = { global.EU_vote_w5^102 = 50 } set_variable = { global.EU_vote_w6^102 = -25 } set_variable = { global.EU_vote_hist^102 = 100 }
	set_variable = { global.EU_vote_w1^103 = 50 } set_variable = { global.EU_vote_w2^103 = 50 } set_variable = { global.EU_vote_w3^103 = 50 } set_variable = { global.EU_vote_w4^103 = 50 } set_variable = { global.EU_vote_w5^103 = 50 } set_variable = { global.EU_vote_w6^103 = -25 } set_variable = { global.EU_vote_hist^103 = 100 }
	set_variable = { global.EU_vote_w1^104 = 25 } set_variable = { global.EU_vote_w2^104 = 25 } set_variable = { global.EU_vote_w3^104 = 25 } set_variable = { global.EU_vote_w4^104 = 25 } set_variable = { global.EU_vote_w5^104 = 25 } set_variable = { global.EU_vote_w6^104 = 25 } set_variable = { global.EU_vote_hist^104 = 100 }
	set_variable = { global.EU_vote_w1^105 = 25 } set_variable = { global.EU_vote_w2^105 = 25 } set_variable = { global.EU_vote_w3^105 = 25 } set_variable = { global.EU_vote_w4^105 = 25 } set_variable = { global.EU_vote_w5^105 = 25 } set_variable = { global.EU_vote_w6^105 = -25 } set_variable = { global.EU_vote_hist^105 = 100 }
	set_variable = { global.EU_vote_w1^201 = -10 } set_variable = { global.EU_vote_w2^201 = -25 } set_variable = { global.EU_vote_w3^201 = 25 } set_variable = { global.EU_vote_w4^201 = 25 } set_variable = { global.EU_vote_w5^201 = 25 } set_variable = { global.EU_vote_w6^201 = -25 } set_variable = { global.EU_vote_hist^201 = 100 }
	set_variable = { global.EU_vote_w1^202 = 0 } set_variable = { global.EU_vote_w2^202 = -10 } set_variable = { global.EU_vote_w3^202 = 25 } set_variable = { global.EU_vote_w4^202 = 25 } set_variable = { global.EU_vote_w5^202 = 25 } set_variable = { global.EU_vote_w6^202 = -25 } set_variable = { global.EU_vote_hist^202 = 0 }
	set_variable = { global.EU_vote_w1^203 = -25 } set_variable = { global.EU_vote_w2^203 = -25 } set_variable = { global.EU_vote_w3^203 = 25 } set_variable = { global.EU_vote_w4^203 = 25 } set_variable = { global.EU_vote_w5^203 = 25 } set_variable = { global.EU_vote_w6^203 = -25 } set_variable = { global.EU_vote_hist^203 = 0 }
	set_variable = { global.EU_vote_w1^204 = 0 } set_variable = { global.EU_vote_w2^204 = -25 } set_variable = { global.EU_vote_w3^204 = 25 } set_variable = { global.EU_vote_w4^204 = 25 } set_variable = { global.EU_vote_w5^204 = 25 } set_variable = { global.EU_vote_w6^204 = -25 } set_variable = { global.EU_vote_hist^204 = 0 }
	set_variable = { global.EU_vote_w1^205 = 0 } set_variable = { global.EU_vote_w2^205 = -25 } set_variable = { global.EU_vote_w3^205 = 25 } set_variable = { global.EU_vote_w4^205 = 25 } set_variable = { global.EU_vote_w5^205 = 25 } set_variable = { global.EU_vote_w6^205 = -25 } set_variable = { global.EU_vote_hist^205 = 0 }
	set_variable = { global.EU_vote_w1^206 = -25 } set_variable = { global.EU_vote_w2^206 = -25 } set_variable = { global.EU_vote_w3^206 = 25 } set_variable = { global.EU_vote_w4^206 = 25 } set_variable = { global.EU_vote_w5^206 = 25 } set_variable = { global.EU_vote_w6^206 = -25 } set_variable = { global.EU_vote_hist^206 = 0 }
	set_variable = { global.EU_vote_w1^207 = -10 } set_variable = { global.EU_vote_w2^207 = 0 } set_variable = { global.EU_vote_w3^207 = 25 } set_variable = { global.EU_vote_w4^207 = 25 } set_variable = { global.EU_vote_w5^207 = 25 } set_variable = { global.EU_vote_w6^207 = -25 } set_variable = { global.EU_vote_hist^207 = 0 }
	set_variable = { global.EU_vote_w1^208 = -10 } set_variable = { global.EU_vote_w2^208 = 0 } set_variable = { global.EU_vote_w3^208 = 25 } set_variable = { global.EU_vote_w4^208 = 25 } set_variable = { global.EU_vote_w5^208 = 25 } set_variable = { global.EU_vote_w6^208 = -25 } set_variable = { global.EU_vote_hist^208 = 0 }
	set_variable = { global.EU_vote_w1^301 = 25 } set_variable = { global.EU_vote_w2^301 = 25 } set_variable = { global.EU_vote_w3^301 = 25 } set_variable = { global.EU_vote_w4^301 = 10 } set_variable = { global.EU_vote_w5^301 = -25 } set_variable = { global.EU_vote_w6^301 = 25 } set_variable = { global.EU_vote_hist^301 = 0 }
	set_variable = { global.EU_vote_w1^302 = 25 } set_variable = { global.EU_vote_w2^302 = 25 } set_variable = { global.EU_vote_w3^302 = 25 } set_variable = { global.EU_vote_w4^302 = 10 } set_variable = { global.EU_vote_w5^302 = -25 } set_variable = { global.EU_vote_w6^302 = 25 } set_variable = { global.EU_vote_hist^302 = 0 }
	set_variable = { global.EU_vote_w1^303 = 25 } set_variable = { global.EU_vote_w2^303 = 25 } set_variable = { global.EU_vote_w3^303 = 25 } set_variable = { global.EU_vote_w4^303 = 10 } set_variable = { global.EU_vote_w5^303 = -25 } set_variable = { global.EU_vote_w6^303 = 25 } set_variable = { global.EU_vote_hist^303 = 0 }
	set_variable = { global.EU_vote_w1^304 = 25 } set_variable = { global.EU_vote_w2^304 = 25 } set_variable = { global.EU_vote_w3^304 = 25 } set_variable = { global.EU_vote_w4^304 = 25 } set_variable = { global.EU_vote_w5^304 = -25 } set_variable = { global.EU_vote_w6^304 = 25 } set_variable = { global.EU_vote_hist^304 = 0 }
	set_variable = { global.EU_vote_w1^305 = 25 } set_variable = { global.EU_vote_w2^305 = 10 } set_variable = { global.EU_vote_w3^305 = 10 } set_variable = { global.EU_vote_w4^305 = -10 } set_variable = { global.EU_vote_w5^305 = -25 } set_variable = { global.EU_vote_w6^305 = -25 } set_variable = { global.EU_vote_hist^305 = 0 }
	set_variable = { global.EU_vote_w1^306 = 25 } set_variable = { global.EU_vote_w2^306 = 10 } set_variable = { global.EU_vote_w3^306 = 10 } set_variable = { global.EU_vote_w4^306 = -10 } set_variable = { global.EU_vote_w5^306 = -25 } set_variable = { global.EU_vote_w6^306 = -25 } set_variable = { global.EU_vote_hist^306 = 0 }
	set_variable = { global.EU_vote_w1^307 = 25 } set_variable = { global.EU_vote_w2^307 = 10 } set_variable = { global.EU_vote_w3^307 = 25 } set_variable = { global.EU_vote_w4^307 = 25 } set_variable = { global.EU_vote_w5^307 = 25 } set_variable = { global.EU_vote_w6^307 = -25 } set_variable = { global.EU_vote_hist^307 = 0 }
	set_variable = { global.EU_vote_w1^308 = 25 } set_variable = { global.EU_vote_w2^308 = -10 } set_variable = { global.EU_vote_w3^308 = -10 } set_variable = { global.EU_vote_w4^308 = -25 } set_variable = { global.EU_vote_w5^308 = -25 } set_variable = { global.EU_vote_w6^308 = 10 } set_variable = { global.EU_vote_hist^308 = 0 }
	set_variable = { global.EU_vote_w1^401 = 10 } set_variable = { global.EU_vote_w2^401 = -10 } set_variable = { global.EU_vote_w3^401 = 10 } set_variable = { global.EU_vote_w4^401 = 25 } set_variable = { global.EU_vote_w5^401 = 10 } set_variable = { global.EU_vote_w6^401 = -25 } set_variable = { global.EU_vote_hist^401 = 100 }
	set_variable = { global.EU_vote_w1^402 = 25 } set_variable = { global.EU_vote_w2^402 = -25 } set_variable = { global.EU_vote_w3^402 = -10 } set_variable = { global.EU_vote_w4^402 = -25 } set_variable = { global.EU_vote_w5^402 = -25 } set_variable = { global.EU_vote_w6^402 = -25 } set_variable = { global.EU_vote_hist^402 = 0 }
	set_variable = { global.EU_vote_w1^403 = 10 } set_variable = { global.EU_vote_w2^403 = 10 } set_variable = { global.EU_vote_w3^403 = 10 } set_variable = { global.EU_vote_w4^403 = 10 } set_variable = { global.EU_vote_w5^403 = 10 } set_variable = { global.EU_vote_w6^403 = -25 } set_variable = { global.EU_vote_hist^403 = 0 }
	set_variable = { global.EU_vote_w1^404 = -10 } set_variable = { global.EU_vote_w2^404 = 10 } set_variable = { global.EU_vote_w3^404 = 25 } set_variable = { global.EU_vote_w4^404 = 25 } set_variable = { global.EU_vote_w5^404 = 25 } set_variable = { global.EU_vote_w6^404 = -25 } set_variable = { global.EU_vote_hist^404 = 0 }
	set_variable = { global.EU_vote_w1^405 = 25 } set_variable = { global.EU_vote_w2^405 = -10 } set_variable = { global.EU_vote_w3^405 = 10 } set_variable = { global.EU_vote_w4^405 = -10 } set_variable = { global.EU_vote_w5^405 = -10 } set_variable = { global.EU_vote_w6^405 = 25 } set_variable = { global.EU_vote_hist^405 = 0 }
	set_variable = { global.EU_vote_w1^406 = 0 } set_variable = { global.EU_vote_w2^406 = 25 } set_variable = { global.EU_vote_w3^406 = 10 } set_variable = { global.EU_vote_w4^406 = 10 } set_variable = { global.EU_vote_w5^406 = 0 } set_variable = { global.EU_vote_w6^406 = 25 } set_variable = { global.EU_vote_hist^406 = 0 }
	set_variable = { global.EU_vote_w1^407 = 25 } set_variable = { global.EU_vote_w2^407 = 10 } set_variable = { global.EU_vote_w3^407 = 10 } set_variable = { global.EU_vote_w4^407 = -10 } set_variable = { global.EU_vote_w5^407 = -10 } set_variable = { global.EU_vote_w6^407 = 25 } set_variable = { global.EU_vote_hist^407 = 0 }
	set_variable = { global.EU_vote_w1^408 = 25 } set_variable = { global.EU_vote_w2^408 = 10 } set_variable = { global.EU_vote_w3^408 = 10 } set_variable = { global.EU_vote_w4^408 = -10 } set_variable = { global.EU_vote_w5^408 = -10 } set_variable = { global.EU_vote_w6^408 = 25 } set_variable = { global.EU_vote_hist^408 = 0 }
	set_variable = { global.EU_vote_w1^601 = 25 } set_variable = { global.EU_vote_w2^601 = 25 } set_variable = { global.EU_vote_w3^601 = 25 } set_variable = { global.EU_vote_w4^601 = 25 } set_variable = { global.EU_vote_w5^601 = 25 } set_variable = { global.EU_vote_w6^601 = -25 } set_variable = { global.EU_vote_hist^601 = 0 }
	set_variable = { global.EU_vote_w1^602 = 25 } set_variable = { global.EU_vote_w2^602 = 25 } set_variable = { global.EU_vote_w3^602 = 25 } set_variable = { global.EU_vote_w4^602 = 25 } set_variable = { global.EU_vote_w5^602 = 25 } set_variable = { global.EU_vote_w6^602 = -25 } set_variable = { global.EU_vote_hist^602 = 100 }
	set_variable = { global.EU_vote_w1^603 = 25 } set_variable = { global.EU_vote_w2^603 = 25 } set_variable = { global.EU_vote_w3^603 = 25 } set_variable = { global.EU_vote_w4^603 = 25 } set_variable = { global.EU_vote_w5^603 = 25 } set_variable = { global.EU_vote_w6^603 = -25 } set_variable = { global.EU_vote_hist^603 = 100 }
	set_variable = { global.EU_vote_w1^703 = 0 } set_variable = { global.EU_vote_w2^703 = 0 } set_variable = { global.EU_vote_w3^703 = 0 } set_variable = { global.EU_vote_w4^703 = 0 } set_variable = { global.EU_vote_w5^703 = 0 } set_variable = { global.EU_vote_w6^703 = 0 } set_variable = { global.EU_vote_hist^703 = 0 }
	set_variable = { global.EU_vote_w1^110 = 10 } set_variable = { global.EU_vote_w2^110 = 25 } set_variable = { global.EU_vote_w3^110 = 25 } set_variable = { global.EU_vote_w4^110 = 25 } set_variable = { global.EU_vote_w5^110 = 25 } set_variable = { global.EU_vote_w6^110 = -25 } set_variable = { global.EU_vote_hist^110 = 0 }
	set_variable = { global.EU_vote_w1^111 = -10 } set_variable = { global.EU_vote_w2^111 = -10 } set_variable = { global.EU_vote_w3^111 = 25 } set_variable = { global.EU_vote_w4^111 = 25 } set_variable = { global.EU_vote_w5^111 = 25 } set_variable = { global.EU_vote_w6^111 = -25 } set_variable = { global.EU_vote_hist^111 = 0 }
	set_variable = { global.EU_vote_w1^112 = 10 } set_variable = { global.EU_vote_w2^112 = 25 } set_variable = { global.EU_vote_w3^112 = 25 } set_variable = { global.EU_vote_w4^112 = 25 } set_variable = { global.EU_vote_w5^112 = 25 } set_variable = { global.EU_vote_w6^112 = -25 } set_variable = { global.EU_vote_hist^112 = 0 }
	set_variable = { global.EU_vote_w1^605 = 25 } set_variable = { global.EU_vote_w2^605 = 25 } set_variable = { global.EU_vote_w3^605 = 25 } set_variable = { global.EU_vote_w4^605 = 25 } set_variable = { global.EU_vote_w5^605 = 25 } set_variable = { global.EU_vote_w6^605 = -25 } set_variable = { global.EU_vote_hist^605 = 0 }
	set_variable = { global.EU_vote_w1^606 = -25 } set_variable = { global.EU_vote_w2^606 = 25 } set_variable = { global.EU_vote_w3^606 = 25 } set_variable = { global.EU_vote_w4^606 = 25 } set_variable = { global.EU_vote_w5^606 = 25 } set_variable = { global.EU_vote_w6^606 = -25 } set_variable = { global.EU_vote_hist^606 = 0 }
	set_variable = { global.EU_vote_w1^607 = 25 } set_variable = { global.EU_vote_w2^607 = 25 } set_variable = { global.EU_vote_w3^607 = 25 } set_variable = { global.EU_vote_w4^607 = 25 } set_variable = { global.EU_vote_w5^607 = 25 } set_variable = { global.EU_vote_w6^607 = -25 } set_variable = { global.EU_vote_hist^607 = 0 }
	set_variable = { global.EU_vote_w1^608 = 25 } set_variable = { global.EU_vote_w2^608 = 25 } set_variable = { global.EU_vote_w3^608 = 25 } set_variable = { global.EU_vote_w4^608 = 25 } set_variable = { global.EU_vote_w5^608 = 25 } set_variable = { global.EU_vote_w6^608 = -25 } set_variable = { global.EU_vote_hist^608 = 0 }
	set_variable = { global.EU_vote_w1^609 = 25 } set_variable = { global.EU_vote_w2^609 = 25 } set_variable = { global.EU_vote_w3^609 = 25 } set_variable = { global.EU_vote_w4^609 = 25 } set_variable = { global.EU_vote_w5^609 = 25 } set_variable = { global.EU_vote_w6^609 = -25 } set_variable = { global.EU_vote_hist^609 = 0 }
	set_variable = { global.EU_vote_w1^610 = 25 } set_variable = { global.EU_vote_w2^610 = 25 } set_variable = { global.EU_vote_w3^610 = 25 } set_variable = { global.EU_vote_w4^610 = 25 } set_variable = { global.EU_vote_w5^610 = 25 } set_variable = { global.EU_vote_w6^610 = -25 } set_variable = { global.EU_vote_hist^610 = 0 }
	set_variable = { global.EU_vote_w1^611 = -25 } set_variable = { global.EU_vote_w2^611 = 25 } set_variable = { global.EU_vote_w3^611 = 25 } set_variable = { global.EU_vote_w4^611 = 25 } set_variable = { global.EU_vote_w5^611 = 25 } set_variable = { global.EU_vote_w6^611 = -25 } set_variable = { global.EU_vote_hist^611 = 0 }
	set_variable = { global.EU_vote_w1^650 = -25 } set_variable = { global.EU_vote_w2^650 = 25 } set_variable = { global.EU_vote_w3^650 = 25 } set_variable = { global.EU_vote_w4^650 = 25 } set_variable = { global.EU_vote_w5^650 = 25 } set_variable = { global.EU_vote_w6^650 = -25 } set_variable = { global.EU_vote_hist^650 = 0 }
	set_variable = { global.EU_vote_w1^651 = -25 } set_variable = { global.EU_vote_w2^651 = 25 } set_variable = { global.EU_vote_w3^651 = 25 } set_variable = { global.EU_vote_w4^651 = 25 } set_variable = { global.EU_vote_w5^651 = 25 } set_variable = { global.EU_vote_w6^651 = -25 } set_variable = { global.EU_vote_hist^651 = 0 }
	set_variable = { global.EU_vote_w1^652 = -25 } set_variable = { global.EU_vote_w2^652 = 25 } set_variable = { global.EU_vote_w3^652 = 25 } set_variable = { global.EU_vote_w4^652 = 25 } set_variable = { global.EU_vote_w5^652 = 25 } set_variable = { global.EU_vote_w6^652 = -25 } set_variable = { global.EU_vote_hist^652 = 0 }
	set_variable = { global.EU_vote_w1^653 = -25 } set_variable = { global.EU_vote_w2^653 = 25 } set_variable = { global.EU_vote_w3^653 = 25 } set_variable = { global.EU_vote_w4^653 = 25 } set_variable = { global.EU_vote_w5^653 = 25 } set_variable = { global.EU_vote_w6^653 = -25 } set_variable = { global.EU_vote_hist^653 = 0 }
	set_variable = { global.EU_vote_w1^654 = -25 } set_variable = { global.EU_vote_w2^654 = 25 } set_variable = { global.EU_vote_w3^654 = 25 } set_variable = { global.EU_vote_w4^654 = 25 } set_variable = { global.EU_vote_w5^654 = 25 } set_variable = { global.EU_vote_w6^654 = -25 } set_variable = { global.EU_vote_hist^654 = 0 }
	set_variable = { global.EU_vote_w1^655 = -25 } set_variable = { global.EU_vote_w2^655 = 25 } set_variable = { global.EU_vote_w3^655 = 25 } set_variable = { global.EU_vote_w4^655 = 25 } set_variable = { global.EU_vote_w5^655 = 25 } set_variable = { global.EU_vote_w6^655 = -25 } set_variable = { global.EU_vote_hist^655 = 0 }
	set_variable = { global.EU_vote_w1^656 = -25 } set_variable = { global.EU_vote_w2^656 = 25 } set_variable = { global.EU_vote_w3^656 = 25 } set_variable = { global.EU_vote_w4^656 = 25 } set_variable = { global.EU_vote_w5^656 = 25 } set_variable = { global.EU_vote_w6^656 = -25 } set_variable = { global.EU_vote_hist^656 = 0 }
	set_variable = { global.EU_vote_w1^657 = -25 } set_variable = { global.EU_vote_w2^657 = 25 } set_variable = { global.EU_vote_w3^657 = 25 } set_variable = { global.EU_vote_w4^657 = 25 } set_variable = { global.EU_vote_w5^657 = 25 } set_variable = { global.EU_vote_w6^657 = -25 } set_variable = { global.EU_vote_hist^657 = 0 }
	set_variable = { global.EU_vote_w1^658 = -25 } set_variable = { global.EU_vote_w2^658 = 25 } set_variable = { global.EU_vote_w3^658 = 25 } set_variable = { global.EU_vote_w4^658 = 25 } set_variable = { global.EU_vote_w5^658 = 25 } set_variable = { global.EU_vote_w6^658 = -25 } set_variable = { global.EU_vote_hist^658 = 0 }
	set_variable = { global.EU_vote_w1^659 = -25 } set_variable = { global.EU_vote_w2^659 = 25 } set_variable = { global.EU_vote_w3^659 = 25 } set_variable = { global.EU_vote_w4^659 = 25 } set_variable = { global.EU_vote_w5^659 = 25 } set_variable = { global.EU_vote_w6^659 = -25 } set_variable = { global.EU_vote_hist^659 = 0 }
	set_variable = { global.EU_vote_w1^660 = -25 } set_variable = { global.EU_vote_w2^660 = 25 } set_variable = { global.EU_vote_w3^660 = 25 } set_variable = { global.EU_vote_w4^660 = 25 } set_variable = { global.EU_vote_w5^660 = 25 } set_variable = { global.EU_vote_w6^660 = -25 } set_variable = { global.EU_vote_hist^660 = 0 }
}

EU_apply_expansion_focus_weights = {
	# rule_european_union_expansion_focus = yes: bias EU AI toward enlargement agendas (605-611, 650-660).
	for_loop_effect = {
		start = 605
		end = 612
		value = code
		add_to_variable = { global.EU_vote_w1^code = 25 }
		add_to_variable = { global.EU_vote_w2^code = 25 }
		add_to_variable = { global.EU_vote_w3^code = 25 }
		add_to_variable = { global.EU_vote_w4^code = 25 }
		add_to_variable = { global.EU_vote_w5^code = 25 }
		add_to_variable = { global.EU_vote_w6^code = 25 }
	}
	for_loop_effect = {
		start = 650
		end = 661
		value = code
		add_to_variable = { global.EU_vote_w1^code = 25 }
		add_to_variable = { global.EU_vote_w2^code = 25 }
		add_to_variable = { global.EU_vote_w3^code = 25 }
		add_to_variable = { global.EU_vote_w4^code = 25 }
		add_to_variable = { global.EU_vote_w5^code = 25 }
		add_to_variable = { global.EU_vote_w6^code = 25 }
	}
}

EU_update_AI_focus_voting_modifier = {
	# focus_index (numeric agenda id) set by caller; weights from EU_init_focus_vote_weights.
	set_temp_variable = { EU_AI_focus_modifier_yes_vote = 0 }
	set_temp_variable = { value1 = global.EU_vote_w1^focus_index }
	set_temp_variable = { value2 = global.EU_vote_w2^focus_index }
	set_temp_variable = { value3 = global.EU_vote_w3^focus_index }
	set_temp_variable = { value4 = global.EU_vote_w4^focus_index }
	set_temp_variable = { value5 = global.EU_vote_w5^focus_index }
	set_temp_variable = { value6 = global.EU_vote_w6^focus_index }
	EU_law_party_value_weight = yes

	if = {
		limit = { is_historical_focus_on = yes }
		add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = global.EU_vote_hist^focus_index }
	}

	# EU202: low-stability bonus
	if = {
		limit = { check_variable = { focus_index = 202 } }
		if = { limit = { has_stability < 0.40 }
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = 10 }
		}
	}
	# EU203: interest-rate ladder
	if = {
		limit = { check_variable = { focus_index = 203 } }
		# Interest Rate Check
		if = { limit = { check_variable = { interest_rate > 10 } }
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = 10 }
		}
		if = { limit = { check_variable = { interest_rate > 12 } }
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = 10 }
		}
		if = { limit = { check_variable = { interest_rate > 14 } }
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = 10 }
		}
		if = { limit = { check_variable = { interest_rate > 16 } }
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = 10 }
		}
		if = { limit = { check_variable = { interest_rate > 18 } }
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = 10 }
		}
		if = { limit = { check_variable = { interest_rate > 20 } }
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = 10 }
		}
		if = {
			limit = {
				check_variable = { interest_rate > 5.5 }
				check_variable = { interest_rate < 7.6 }
			}
			add_to_temp_variable = { EU_AI_focus_modifier_yes_vote = -10 }
		}
	}

	EU_update_AI_general_voting_modifiers = yes
}


# QMV Results Section

# Dispatches the council QMV outcome to the agenda-specific focus_EU<n>_QMV_result handler.
apply_EU_QMV_result = {
	# EU111 (form United States of Europe) applies on QMV regardless of the result trigger.
	if = {
		limit = { check_variable = { global.EUXXX_council_agenda = 111 } }
		focus_EU111_QMV_result = yes
	}
	else = {
		if = {
			limit = { EU_voting_decision_result_trigger = yes }
			# agenda-specific reward; agendas without a reward fall through to cleanup
			if = { limit = { check_variable = { global.EUXXX_council_agenda = 101 } } focus_EU101_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 102 } } focus_EU102_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 103 } } focus_EU103_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 104 } } focus_EU104_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 105 } } focus_EU105_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 201 } } focus_EU201_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 202 } } focus_EU202_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 203 } } focus_EU203_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 204 } } focus_EU204_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 205 } } focus_EU205_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 206 } } focus_EU206_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 207 } } focus_EU207_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 208 } } focus_EU208_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 301 } } focus_EU301_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 302 } } focus_EU302_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 303 } } focus_EU303_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 304 } } focus_EU304_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 305 } } focus_EU305_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 306 } } focus_EU306_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 307 } } focus_EU307_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 308 } } focus_EU308_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 401 } } focus_EU401_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 402 } } focus_EU402_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 403 } } focus_EU403_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 404 } } focus_EU404_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 405 } } focus_EU405_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 406 } } focus_EU406_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 407 } } focus_EU407_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 408 } } focus_EU408_QMV_result = yes }
			# Enlargement agendas: grant EU_candidate to the cohort so non-members can apply for entry.
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 601 } } focus_EU601_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 602 } } focus_EU602_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 603 } } focus_EU603_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 605 } } focus_EU605_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 606 } } focus_EU606_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 607 } } focus_EU607_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 608 } } focus_EU608_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 609 } } focus_EU609_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 610 } } focus_EU610_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 611 } } focus_EU611_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 653 } } focus_EU653_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 654 } } focus_EU654_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 655 } } focus_EU655_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 656 } } focus_EU656_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 657 } } focus_EU657_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 658 } } focus_EU658_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 659 } } focus_EU659_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 660 } } focus_EU660_QMV_result = yes }
			else_if = { limit = { check_variable = { global.EUXXX_council_agenda = 112 } } focus_EU112_QMV_result = yes }
			set_temp_variable = { vote_passed = 1 }
			cleanup_european_union_voting = yes
		}
		else = {
			set_temp_variable = { vote_passed = 0 }
			cleanup_european_union_voting = yes
		}
	}
}

EU_drop_rival_endgame = {
	remove_from_array = { array = global.EU_council_votes value = rival_endgame_id }
	remove_from_array = { array = global.EU_potential_votes value = rival_endgame_id }
	if = {
		limit = { check_variable = { global.current_active_agenda_disp = rival_endgame_id } }
		clr_global_flag = EU_active_EP_agenda_holder
		set_variable = { global.current_active_agenda_disp = 0 }
		set_variable = { global.active_MEP_Support = 0 }
		set_variable = { global.pass_vote_mission_ender = 0 }
		for_each_scope_loop = {
			array = global.EU_member
			if = {
				limit = { has_active_mission = EU_parliament_focus_EUXXX_approve }
				remove_mission = EU_parliament_focus_EUXXX_approve
			}
		}
	}
	update_eu_dirty_variable = yes
}

### EU111 - United States of Europe ###
focus_EU111_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_active_vote_rejecters
		remove_ideas = EU_member
	}

	hidden_effect = {
		# Record the vote before annexations — on_annex resets current_active_vote_disp to 0
		add_to_array = { array = global.EU_passed_votes value = 111 }
		remove_from_array = { array = global.EU_council_votes value = 111 }
		set_temp_variable = { rival_endgame_id = 112 }
		EU_drop_rival_endgame = yes
		set_variable = { global.current_active_vote_disp = 0 }

		# Snapshot members before annexing: annex_country fires on_annex, which removes each
		# annexed member from global.EU_member. Looping global.EU_member live would mutate it
		# mid-iteration and skip most members, leaving them independent instead of forming USoE.
		clear_array = global.USoE_formation_members
		for_each_scope_loop = {
			array = global.EU_member
			add_to_array = { global.USoE_formation_members = THIS }
		}

		for_each_scope_loop = {
			array = global.USoE_formation_members
			EUU = { inherit_technology = THIS }
			set_country_flag = USoE_member
			set_country_flag = USoE
			every_unit_leader = {
				set_unit_leader_flag = USoE_unit_leader
				set_nationality = ROOT
				add_unit_leader_trait = military_reorganization
			}
			every_owned_state = {
				limit = {
					OR = {
						is_on_continent = europe
						is_core_of = GEO
						is_core_of = ARM
						is_core_of = AZE
						is_core_of = TUR
						is_core_of = POR
						is_core_of = SPR
					}
					NOT = { is_core_of = ROOT }
				}
				add_core_of = ROOT
			}
			if = { limit = { NOT = { original_tag = ROOT } }
				ROOT = {
					add_to_variable = { treasury = PREV.treasury }
					add_to_variable = { debt = PREV.debt }
					add_to_variable = { int_investments = PREV.int_investments }
					set_variable = { tag_to_grab = PREV.id }
					update_missile_satellite_inventory = yes
					annex_country = {
						target = PREV
						transfer_troops = yes
					}
				}
			}
		}
		clear_array = global.USoE_formation_members
		apply_USoE_technologies = yes
	}
	ROOT = {
		set_cosmetic_tag = USoE
		set_temp_variable = { special_formable_id = 101 }
		commit_special_formable = yes
		clr_country_flag = dynamic_flag
		set_country_flag = USoE
		set_variable = { global.united_states_of_europe = THIS.id }
		clr_country_flag = GER_Final_settlement
		if = {
			limit = { original_tag = GER }
			set_country_flag = GER_bavaria_gone
			clr_country_flag = GER_war_on_terror_started
			remove_ideas = GER_idea_carbon_neutral
		}
		if = {
			limit = { original_tag = ENG }
			# The USoE annexes the whole union, so the UK dissolution path no longer applies
			set_country_flag = ENG_devolution_purged
			remove_mission = ENG_scottish_referendum
			remove_mission = ENG_irish_referendum
			remove_mission = ENG_welsh_referendum
			remove_mission = ENG_scottish_union_settlement_referendum
			remove_mission = ENG_north_irish_union_settlement_referendum
			remove_mission = ENG_welsh_union_settlement_referendum
			remove_mission = ENG_scottish_referendum_pressure
			remove_mission = ENG_north_irish_referendum_pressure
			remove_mission = ENG_welsh_referendum_pressure
		}
		add_ideas = multi_ethnic_state_idea
	}
	custom_effect_tooltip = form_USoE_tt
	set_temp_variable = { vote_passed = 1 }
	cleanup_european_union_voting = yes
}

# EU101 - Charter of Fundamental Rights of the European Union
focus_EU101_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.02 }
	EU_europeanism_change = yes
	newline = yes
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = EUU_cfr_eu
	}
}

# EU102 - European Convention
focus_EU102_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_europeanism_change = yes
	newline = yes
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		if = { limit = { has_idea = european_spirit }
			modify_timed_idea = { idea = european_spirit days = 600 }
		}
		else = {
			add_timed_idea = { idea = european_spirit days = 600 }
		}
	}
}

# EU103 - European Constitution
focus_EU103_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_europeanism_change = yes
	newline = yes
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		if = { limit = { has_idea = european_spirit }
			modify_timed_idea = { idea = european_spirit days = 600 }
		}
		else = {
			add_timed_idea = { idea = european_spirit days = 600 }
		}
	}
}

# EU104 - Treaty of Lisbon
focus_EU104_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN

		if = { limit = { has_idea = european_spirit }
			modify_timed_idea = { idea = european_spirit days = 600 }
		}
		else = {
			add_timed_idea = { idea = european_spirit days = 600 }
		}
	}
	set_global_flag = treaty_of_lisbon
}

# EU105 - European External Action Service
focus_EU105_QMV_result = {
	set_global_flag = EU_foreign_minister
}

# EU201 - ECB Intervention
focus_EU201_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN

		add_ideas = ECB_zero_interest_rate_policy
	}
}

# EU202 - European Banking Union
focus_EU202_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN

		add_stability = 0.05
		remove_ideas = european_debt_crisis
	}
}

# EU203 - Eurobonds
focus_EU203_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		remove_ideas = european_debt_crisis
		add_ideas = euro_bonds
	}

	set_temp_variable = { eurobonds_debt_total = 0 }
	clear_temp_array = debt_consumers
	set_temp_variable = { debt_consumer_counter = 0 }

	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		if = {
			limit = {
				check_variable = { interest_rate > 7.5 }
				check_variable = { debt_ratio > 0.75 }
			}

			set_temp_variable = {
				current_debt = {
					value = debt
					multiply = 0.075
				}
			}
			add_to_temp_variable = { eurobonds_debt_total = current_debt }

			subtract_from_variable = { debt = current_debt }
		}
		if = {
			limit = {
				NOT = { check_variable = { interest_rate > 7.5 } }
				check_variable = { debt_ratio < 1.0 }
				check_variable = { EU_ratio_of_total_eu_gdp > 0.1 }
			}
			add_to_temp_array = { debt_consumers = THIS }
			add_to_temp_variable = { debt_consumer_counter = 1 }
		}
	}

	set_temp_variable = { var = debt_number value = { value = eurobonds_debt_total multiply = 0.8 } }
	clamp_temp_variable = { var = debt_consumer_counter min = 1 }
	divide_temp_variable = { debt_number = debt_consumer_counter }

	for_each_scope_loop = {
		array = debt_consumers

		add_to_variable = { debt = debt_number }
	}

	for_each_scope_loop = {
		array = global.EU_member
		if = {
			limit = {
				has_idea = EUU_national_dept_crisis_eu
			}
			remove_ideas = EUU_national_dept_crisis_eu
		}
	}
}

# EU204 - European Financial Stability Facility
focus_EU204_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_stability = 0.10
	}
	POR = { activate_mission = troika_reforms }
	ITA = { activate_mission = troika_reforms }
	IRE = { activate_mission = troika_reforms }
	GRE = { activate_mission = troika_reforms }
	SPR = { activate_mission = troika_reforms }
	CYP = { activate_mission = troika_reforms }
}

# EU205 - European Stability Mechanism (ESM)
focus_EU205_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		remove_ideas = european_debt_crisis
		add_ideas = euro_rescue_package
	}
}

# EU206 - Fiscal Union
focus_EU206_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = fiscal_union
	}
}

# EU207 - European Economic Government
focus_EU207_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = European_Economic_Government
	}
}

# EU208 - European Minister of Economy and Finance
focus_EU208_QMV_result = {
	set_global_flag = EU_finance_minister
}

# EU301 - European Defence Agency
focus_EU301_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_to_tech_sharing_group = EU_Tech_Share
	}
}

# EU302 - Permanent Structured Cooperation (PESCO)
focus_EU302_QMV_result = {
	modify_tech_sharing_bonus = { id = EU_Tech_Share bonus = 0.08 } hidden_effect = { rq_ms_34e3b731b6 = yes }
}

# EU303 - European Defence Fund
focus_EU303_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = European_Defence_Fund
	}
}

# EU304 - European Security Council
focus_EU304_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = European_Security_Council
	}
}

# EU305 - EuroArmy
focus_EU305_QMV_result = {
	set_global_flag = euro_army
}

# EU306 - EuroNavy
focus_EU306_QMV_result = {
	set_global_flag = euro_navy
}

# EU307 - EU Permanent Member of the UNSC
focus_EU307_QMV_result = {
	set_global_flag = EU_UNSC
}

# EU308 - EU Nuclear Power
focus_EU308_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = nuclear_power_def
	}
}

# EU401 - General Data Protection Regulation
focus_EU401_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		if = {
			limit = { has_idea = foreign_data_kraken }
			swap_ideas = {
				remove_idea = foreign_data_kraken
				add_idea = EUU_idea_gdpr
			}
		}
		else = {
			add_ideas = EUU_idea_gdpr
		}
	}
}

# EU402 - Directive on Copyright in the Digital Single Market
focus_EU402_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = EU_copyright
		set_temp_variable = { party_index = 1 }
		set_temp_variable = { party_popularity_increase = -0.03 }
		set_temp_variable = { temp_outlook_increase = -0.03 }
		change_relative_party_popularity = yes
		set_temp_variable = { party_index = 6 }
		change_relative_party_popularity = yes
		set_temp_variable = { party_index = 14 }
		change_relative_party_popularity = yes
	}
}

# EU403 - Dublin II Regulation
focus_EU403_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		remove_ideas = asylum_shopping
		set_temp_variable = { party_index = 20 }
		set_temp_variable = { party_popularity_increase = 0.03 }
		set_temp_variable = { temp_outlook_increase = 0.03 }
		change_relative_party_popularity = yes
	}
}

# EU404 - Relocation and Resettlement of Asylum Seekers
focus_EU404_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		if = {
			limit = { has_global_flag = EUU_migrant_crisis_triggered }
			remove_ideas = Migrant_Crisis_Europe
		}
		add_ideas = relocation_asylum_seekers
		set_temp_variable = { party_index = 20 }
		set_temp_variable = { party_popularity_increase = 0.05 }
		set_temp_variable = { temp_outlook_increase = 0.05 }
		change_relative_party_popularity = yes
	}
}

# EU405 - EU-Turkey Deal
focus_EU405_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		if = {
			limit = { has_global_flag = EUU_migrant_crisis_triggered }
			remove_ideas = Migrant_Crisis_Europe
		}
		add_ideas = EU_Turkey_deal

		set_temp_variable = { treasury_change = THIS.EU_pop_ratio }
		multiply_temp_variable = { treasury_change = -3 }
		newline = yes
		modify_treasury_effect = yes
	}
	TUR = {
		set_temp_variable = { treasury_change = 3 }
		modify_treasury_effect = yes
	}
}

# EU406 - European Asylum Agency
focus_EU406_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		remove_ideas = relocation_asylum_seekers
		remove_ideas = EU_Turkey_deal
		add_ideas = European_Asylum_Agency
	}
}

# EU407 - Frontex
focus_EU407_QMV_result = {
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		add_ideas = Frontex
	}
}

# EU408 - European Border and Coast Guard Agency
focus_EU408_QMV_result = {
	set_global_flag = frontex_ExDir
}

### EU112 ###
focus_EU112_QMV_result = {
	set_global_flag = european_federation
	hidden_effect = {
		set_temp_variable = { rival_endgame_id = 111 }
		EU_drop_rival_endgame = yes
	}
}

# Enlargement QMV handlers — passing the vote makes each cohort an EU candidate,
# which is the gate that lets a non-member apply for entry (existing members rejoin
# via the EU_former_member cooldown path instead).
# EU601 - 2003 EU Enlargement
focus_EU601_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	CYP = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	CZE = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	EST = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	HUN = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	LAT = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	LIT = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	MLT = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	POL = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SLO = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SLV = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU602 - 2007 EU Enlargement
focus_EU602_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	BUL = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	ROM = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU603 - 2013 EU Enlargement
focus_EU603_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	CRO = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU605 - Western Balkans
focus_EU605_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	ALB = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SER = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	MNT = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	FYR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	BOS = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	RSK = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	HZG = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	KOS = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU606 - Turkey
focus_EU606_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	TUR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU607 - Eastern Partnership
focus_EU607_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	MLV = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	UKR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU608 - Caucasus
focus_EU608_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	ARM = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	AZE = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	GEO = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU609 - EFTA and Microstates
focus_EU609_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	SWI = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	NRY = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	ICE = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	HLS = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SMA = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	MNC = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	ADO = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	LIC = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU610 - Belarus
focus_EU610_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	BLR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU611 - Regional Aspirants
focus_EU611_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	CAT = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	CRE = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SCL = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SCO = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	WAS = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	IOM = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	GAL = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SIL = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SPA = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	CNR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	NAV = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	BAY = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	GRN = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	FAO = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	RUS = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU653 - EU-Russia Treaty
focus_EU653_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	SOV = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU654 - Barents Sea Enlargement
focus_EU654_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	KAE = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	KOM = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	NEE = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU655 - Volga Enlargement
focus_EU655_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	BSH = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	CHU = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	MEL = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	MOV = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	TAT = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	UDM = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU656 - Don-Kuban Enlargement
focus_EU656_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	ADY = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	DON = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	KLM = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	KUB = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU657 - Northern Caucasus Enlargement
focus_EU657_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	ABK = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	CHE = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	DAG = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	ING = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	KBK = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	KCC = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	SOO = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU658 - Ruthenia Enlargement
focus_EU658_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	OPR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU659 - Donets Enlargement
focus_EU659_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	DPR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	HPR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	LPR = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# EU660 - Dnieper Enlargement
focus_EU660_QMV_result = {
	set_temp_variable = { modify_europeanism = 0.03 }
	EU_potential_europeanism_change = yes
	newline = yes
	CRM = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
	DRP = { set_country_flag = EU_candidate set_eu_candidate_europeanism_floor = yes }
}

# Shared finalize for a passed EP agenda (mission complete + timeout-success branch).
EU_finalize_passed_agenda = {
	custom_effect_tooltip = EU_parliament_approve_agenda_tt
	hidden_effect = {
		log = "[GetDateText]: [ROOT.GetName]: mission complete_effect EU_parliament_focus_EU[?global.current_active_agenda_disp]_approve"
		clr_global_flag = EU_active_EP_agenda_holder
		clr_global_flag_PG_X_support = yes
		if = {
			limit = { is_in_array = { array = global.EU_potential_votes value = global.current_active_agenda_disp } }
			remove_from_array = {
				array = global.EU_potential_votes
				value = global.current_active_agenda_disp
			}
		}
		if = {
			limit = {
				NOT = {
					OR = {
						check_variable = { global.current_active_agenda_disp = 0 }
						check_variable = { global.current_active_agenda_disp = 998 }
						check_variable = { global.current_active_agenda_disp = 999 }
					}
				}
			}
			add_to_array = { global.EU_council_votes = global.current_active_agenda_disp }
		}
		set_variable = { global.current_active_agenda_disp = 0 }
		if = {
			limit = {
				has_global_flag = EU_budget_EP_block
				NOT = { has_active_mission = EU_budget_draft_ongoing }
				NOT = { has_active_mission = EU_budget_draft_preparations }
			}
			clr_global_flag = EU_budget_EP_block
		}
		if = {
			limit = {
				has_global_flag = EU_mff_EP_block
				NOT = { has_active_mission = EU_mff_draft_ongoing }
				NOT = { has_active_mission = EU_mff_draft_preparations }
			}
			clr_global_flag = EU_mff_EP_block
		}
		set_variable = { global.active_MEP_Support = 0 }
		set_variable = { global.pass_vote_mission_ender = 0 }
		# THIS IS A FAILGATE ###########################
		if = { limit = { is_in_array = { array = global.EU_council_votes value = 999 } }
			remove_from_array = { array = global.EU_council_votes value = 999 }
		}
		if = { limit = { is_in_array = { array = global.EU_council_votes value = 998 } }
			remove_from_array = { array = global.EU_council_votes value = 998 }
		}
		#################################################
	}
	for_each_scope_loop = {
		array = global.EU_member
		if = {
			limit = { has_active_mission = EU_parliament_focus_EUXXX_approve }
			remove_mission = EU_parliament_focus_EUXXX_approve
		}
	}
}

# Caller sets vote_passed = 1 for a passing vote, 0 for a failed one.
cleanup_european_union_voting = {
	if = {
		limit = { check_variable = { vote_passed = 1 } }
		add_to_array = { array = global.EU_passed_votes value = global.current_active_vote_disp }
		remove_from_array = { array = global.EU_council_votes value = global.current_active_vote_disp }
		set_variable = { global.EUU_recently_failed_vote = -1 }
	}
	else = {
		set_variable = { global.EUU_recently_failed_vote = global.current_active_vote_disp }
	}
	set_variable = { global.current_active_vote_disp = 0 }
	set_variable = { global.EU_pop_ratio_no = 0 }
	set_variable = { global.EU_pop_ratio_yes = 0 }
	clear_array = global.EU_active_vote_supporters
	clear_array = global.EU_active_vote_rejecters
	for_each_scope_loop = {
		array = global.EU_member
		tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
		set_the_eu_council_delay = yes
		if = {
			limit = { has_country_flag = current_vote_influenced }
			clr_country_flag = current_vote_influenced
		}
	}
}

EU_show_display_effects_for_law = {
	custom_effect_tooltip = EU_show_display_effects_for_law_tt
	effect_tooltip = {
		if = {
			limit = { check_variable = { v = 101 } }
			add_ideas = EUU_cfr_eu
		}
		else_if = {
			limit = {
				OR = {
					check_variable = { v = 102 }
					check_variable = { v = 103 }
				}
			}
			if = {
				limit = { has_idea = european_spirit }
				modify_timed_idea = { idea = european_spirit days = 600 }
			}
			else = {
				add_timed_idea = { idea = european_spirit days = 600 }
			}
			set_temp_variable = { modify_europeanism = 0.03 }
			EU_europeanism_change = yes
		}
		else_if = {
			limit = { check_variable = { v = 104 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU104_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 105 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU105_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 201 } }
			add_ideas = ECB_zero_interest_rate_policy
		}
		else_if = {
			limit = { check_variable = { v = 202 } }
			add_stability = 0.05
		}
		else_if = {
			limit = { check_variable = { v = 203 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU203_EP_agenda_additional
			add_ideas = euro_bonds
			if = {
				limit = { has_global_flag = EUU_european_debt_crisis }
				for_each_scope_loop = {
					array = global.EU_member
					tooltip = TT_ALL_EU_MEMBER_NATIONS_GAIN
					if = {
						limit = { has_idea = european_debt_crisis }
						remove_ideas = european_debt_crisis
						remove_ideas = EUU_national_dept_crisis_eu
					}
				}
			}
		}
		else_if = {
			limit = { check_variable = { v = 204 } }
			add_stability = 0.10
			if = {
				limit = { has_global_flag = EUU_european_debt_crisis }
				remove_ideas = european_debt_crisis
				for_each_scope_loop = {
					array = global.EU_member
					if = {
						limit = {
							has_idea = EUU_national_dept_crisis_eu
						}
						activate_mission = troika_reforms
					}
				}
			}
		}
		else_if = {
			limit = { check_variable = { v = 205 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU205_EP_agenda_additional
			add_ideas = euro_rescue_package
			if = {
				limit = { has_global_flag = EUU_european_debt_crisis }
				remove_ideas = european_debt_crisis
			}
		}
		else_if = {
			limit = { check_variable = { v = 206 } }
			add_ideas = fiscal_union
		}
		else_if = {
			limit = { check_variable = { v = 207 } }
			add_ideas = European_Economic_Government
		}
		else_if = {
			limit = { check_variable = { v = 208 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU208_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 301 } }
			add_to_tech_sharing_group = EU_Tech_Share
		}
		else_if = {
			limit = { check_variable = { v = 302 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU302_EP_agenda_additional
			modify_tech_sharing_bonus = { id = EU_Tech_Share bonus = 0.08 } hidden_effect = { rq_ms_34e3b731b6 = yes }
		}
		else_if = {
			limit = { check_variable = { v = 303 } }
			add_ideas = European_Defence_Fund
		}
		else_if = {
			limit = { check_variable = { v = 304 } }
			add_ideas = European_Security_Council
		}
		else_if = {
			limit = { check_variable = { v = 305 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU305_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 306 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU306_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 307 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU307_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 308 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU308_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 401 } }
			add_ideas = EUU_idea_gdpr
			remove_ideas = foreign_data_kraken
		}
		else_if = {
			limit = { check_variable = { v = 402 } }
			add_ideas = EU_copyright
			set_temp_variable = { party_index = 1 }
			set_temp_variable = { party_popularity_increase = -0.03 }
			set_temp_variable = { temp_outlook_increase = -0.03 }
			change_relative_party_popularity = yes
			set_temp_variable = { party_index = 6 }
			change_relative_party_popularity = yes
			set_temp_variable = { party_index = 14 }
			change_relative_party_popularity = yes
		}
		else_if = {
			limit = { check_variable = { v = 403 } }
			remove_ideas = asylum_shopping
			set_temp_variable = { party_index = 20 }
			set_temp_variable = { party_popularity_increase = 0.03 }
			set_temp_variable = { temp_outlook_increase = 0.03 }
			change_relative_party_popularity = yes
		}
		else_if = {
			limit = { check_variable = { v = 404 } }
			if = {
				limit = { has_global_flag = EUU_migrant_crisis_triggered }
				remove_ideas = Migrant_Crisis_Europe
			}
			add_ideas = relocation_asylum_seekers
			set_temp_variable = { party_index = 20 }
			set_temp_variable = { party_popularity_increase = 0.05 }
			set_temp_variable = { temp_outlook_increase = 0.05 }
			change_relative_party_popularity = yes
		}
		else_if = {
			limit = { check_variable = { v = 405 } }
			if = {
				limit = { has_global_flag = EUU_migrant_crisis_triggered }
				remove_ideas = Migrant_Crisis_Europe
			}
			add_ideas = EU_Turkey_deal
		}
		else_if = {
			limit = { check_variable = { v = 406 } }
			remove_ideas = relocation_asylum_seekers
			remove_ideas = EU_Turkey_deal
			add_ideas = European_Asylum_Agency
		}
		else_if = {
			limit = { check_variable = { v = 407 } }
			add_ideas = Frontex
		}
		else_if = {
			limit = { check_variable = { v = 408 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU408_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 601 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU601_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 602 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU602_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 603 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU603_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 605 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU605_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 606 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU606_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 607 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU607_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 608 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU608_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 609 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU609_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 610 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU610_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 611 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU611_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 650 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU650_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 651 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU651_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 652 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU652_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 653 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU653_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 654 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU654_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 655 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU655_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 656 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU656_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 657 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU657_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 658 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU658_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 659 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU659_EP_agenda_additional
		}
		else_if = {
			limit = { check_variable = { v = 660 } }
			custom_effect_tooltip = tooltip_EU_parliament_focus_EU660_EP_agenda_additional
		}
		else = {
			custom_effect_tooltip = EU_show_display_effects_for_law_no_effect_tt
		}
	}
}

EU_emergency_vote_clear = {
	set_variable = { global.EUU_recently_failed_vote = global.current_active_vote_disp }
	set_variable = { global.current_active_vote_disp = 0 }
	set_variable = { global.EU_pop_ratio_no = 0 }
	set_variable = { global.EU_pop_ratio_yes = 0 }
	clear_array = global.EU_active_vote_supporters
	clear_array = global.EU_active_vote_rejecters
}
