ROOT_add_political_power = {
	add_political_power = 500
}

VAT_create_array_with_catholic_states = {
	ITA = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	IRE = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	POR = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	SPR = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	FRA = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	BEL = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	AUS = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	SWI = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	POL = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	LIT = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	CZE = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	SLO = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	SLV = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	CRO = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	HUN = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	MEX = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	GUA = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	ELS = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	HON = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	NIC = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	COS = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	PAN = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	COL = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	VEN = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	ECU = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	PRU = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	BOL = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	CHL = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	ARG = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	PAR = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	URG = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	BRA = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	GYA = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	SUR = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	CAY = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	CUB = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	HAI = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	JAM = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	DOM = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	PUE = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	GDL = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	BAS = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	TRI = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	CRC = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	PHI = { every_core_state = { add_to_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	add_to_array = { array = vat_catholic_states value = 978 }
	add_to_array = { array = vat_catholic_states value = 50 }
	add_to_array = { array = vat_catholic_states value = 52 }
	add_to_array = { array = vat_catholic_states value = 53 }
	add_to_array = { array = vat_catholic_states value = 54 }
	add_to_array = { array = vat_catholic_states value = 35 }
	BLR = { every_core_state = { remove_from_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	UKR = { every_core_state = { remove_from_array = { array = PREV.PREV.vat_catholic_states value = THIS } } }
	add_to_array = { array = vat_catholic_states value = 97 }
	add_to_array = { array = vat_catholic_states value = 89 }
	add_to_array = { array = vat_catholic_states value = 91 }
	add_to_array = { array = vat_catholic_states value = 73 }
}

VAT_give_opinion_modifier_hates_communism = {
	every_other_country = {
		limit = {
			has_government = communism
			NOT = {
				has_opinion_modifier = vat_hates_communism
			}
		}
		ROOT = {
			add_opinion_modifier = {
				target = PREV
				modifier = vat_hates_communism
			}
		}
	}
}

VAT_oob_for_north_italia = {
	division_template = {
		name = "Divisione della Guardia Interna"
		division_names_group = ITA_INF_01 
	
		regiments = {
			militia = { x = 0 y = 0 }
			militia = { x = 0 y = 1 }
			militia = { x = 1 y = 0 }
			militia = { x = 1 y = 1 }
			militia = { x = 2 y = 0 }
		}
	}
	division_template = { 
		name = "Divisione di Fanteria" 
		division_names_group = ITA_INF_01 
	
		regiments = { 
			infantry = { x = 0 y = 0 }
			infantry = { x = 0 y = 1 }
			infantry = { x = 0 y = 2 }
			infantry = { x = 1 y = 0 }
			infantry = { x = 1 y = 1 }
		}
		support = { 
			artillery = { x = 0 y = 0 }
		}
	}
	if = {
		limit = { original_tag = LBV }
		capital_scope = {
			create_unit = {
				division = "name = \"Divisione della Guardia Interna\" division_template = \"Divisione della Guardia Interna\" start_manpower_factor = 1"
				owner = owner
				count = 5
			}
			create_unit = {
				division = "name = \"Divisione di Fanteria\" division_template = \"Divisione di Fanteria\" start_manpower_factor = 1"
				owner = owner
				count = 3
			}
		}
	}
	else = {
		capital_scope = {
			create_unit = {
				division = "name = \"Divisione della Guardia Interna\" division_template = \"Divisione della Guardia Interna\" start_manpower_factor = 1"
				owner = owner
				count = 3
			}
			create_unit = {
				division = "name = \"Divisione di Fanteria\" division_template = \"Divisione di Fanteria\" start_manpower_factor = 1"
				owner = owner
				count = 5
			}
		}
	}
}

VAT_party_names_for_italian_cw_factions = {
	set_party_name = {
		ideology = democratic
		name = ITA_democratic_party
		long_name = ITA_democratic_party
	}
	set_party_name = {
		ideology = neutrality
		name = ITA_neutrality_party
		long_name = ITA_neutrality_party_long
	}
	set_party_name = {
		ideology = communism
		name = ITA_communism_party
		long_name = ITA_communism_party_long
	}
	set_party_name = {
		ideology = fascism
		name = ITA_fascism_party
		long_name = ITA_fascism_party_long
	}
}

VAT_mafia_swap_idea = {
	clamp_variable = {
		var = mafia_power
		min = 0
		max = 100
	}
	if = {
		limit={ 
			check_variable = { mafia_power > 74 }
		}
		swap_ideas = {
			remove_idea = VAT_active_mafia
			add_idea = VAT_ruling_mafia
		}
	}
	if = {
		limit={ 
			check_variable = { mafia_power < 75 }
			check_variable = { mafia_power > 49 }
		}
		swap_ideas = {
			remove_idea = VAT_medium_mafia
			add_idea = VAT_active_mafia
		}
		swap_ideas = {
			remove_idea = VAT_ruling_mafia
			add_idea = VAT_active_mafia
		}
	}
	if = {
		limit={ 
			check_variable = { mafia_power < 50 }
			check_variable = { mafia_power > 24 }
		}
		swap_ideas = {
			remove_idea = VAT_low_mafia
			add_idea = VAT_medium_mafia
		}
		swap_ideas = {
			remove_idea = VAT_active_mafia
			add_idea = VAT_medium_mafia
		}
	}
	if = {
		limit={ 
			check_variable = { mafia_power < 25 }
		}
		swap_ideas = {
			remove_idea = VAT_medium_mafia
			add_idea = VAT_low_mafia
		}
	}
}


VAT_left_opposition_swap_idea = {
	clamp_variable = {
		var = left_opposition_power
		min = 0
		max = 100
	}
	if = {
		limit={ 
			check_variable = { left_opposition_power > 74 }
		}
		swap_ideas = {
			remove_idea = VAT_active_left_opposition
			add_idea = VAT_ruling_left_opposition
		}
	}
	if = {
		limit={ 
			check_variable = { left_opposition_power < 75 }
			check_variable = { left_opposition_power > 49 }
		}
		swap_ideas = {
			remove_idea = VAT_medium_left_opposition
			add_idea = VAT_active_left_opposition
		}
		swap_ideas = {
			remove_idea = VAT_ruling_left_opposition
			add_idea = VAT_active_left_opposition
		}
	}
	if = {
		limit={ 
			check_variable = { left_opposition_power < 50 }
			check_variable = { left_opposition_power > 24 }
		}
		swap_ideas = {
			remove_idea = VAT_low_left_opposition
			add_idea = VAT_medium_left_opposition
		}
		swap_ideas = {
			remove_idea = VAT_active_left_opposition
			add_idea = VAT_medium_left_opposition
		}
	}
	if = {
		limit={ 
			check_variable = { left_opposition_power < 25 }
		}
		swap_ideas = {
			remove_idea = VAT_medium_left_opposition
			add_idea = VAT_low_left_opposition
		}
	}
}

VAT_right_opposition_swap_idea = {
	clamp_variable = {
		var = right_opposition_power
		min = 0
		max = 100
	}
	if = {
		limit={ 
			check_variable = { right_opposition_power > 74 }
		}
		swap_ideas = {
			remove_idea = VAT_active_right_opposition
			add_idea = VAT_ruling_right_opposition
		}
	}
	if = {
		limit={ 
			check_variable = { right_opposition_power < 75 }
			check_variable = { right_opposition_power > 49 }
		}
		swap_ideas = {
			remove_idea = VAT_medium_right_opposition
			add_idea = VAT_active_right_opposition
		}
		swap_ideas = {
			remove_idea = VAT_ruling_right_opposition
			add_idea = VAT_active_right_opposition
		}
	}
	if = {
		limit={ 
			check_variable = { right_opposition_power < 50 }
			check_variable = { right_opposition_power > 24 }
		}
		swap_ideas = {
			remove_idea = VAT_low_mafia
			add_idea = VAT_medium_right_opposition
		}
		swap_ideas = {
			remove_idea = VAT_active_right_opposition
			add_idea = VAT_medium_right_opposition
		}
	}
	if = {
		limit={ 
			check_variable = { right_opposition_power < 25 }
		}
		swap_ideas = {
			remove_idea = VAT_medium_right_opposition
			add_idea = VAT_low_right_opposition
		}
	}
}
VAT_update_curia_law_gui = {
	clamp_variable = {
		var = curia_law_vote_value
		min = 0
		max = 70
	}
	#vote semicircle calculations
	set_variable = {
		curia_law_vote_value_oposite = 70
	}
	subtract_from_variable = {
		curia_law_vote_value_oposite = curia_law_vote_value
	}
	set_temp_variable = {
		iterator = vat_curia_law_vote_frames^num
	}
	set_temp_variable = {
		iterator_shift = 1
	}
	subtract_from_temp_variable = {
		iterator = iterator_shift
	}
	#maybe can be optimised, but it`s too complicated (maybe votes have to be swapped)
	for_loop_effect = {
		end = vat_curia_law_vote_frames^num
		value = i
		set_variable = {
			vat_curia_law_vote_frames^i = 1
		}
	}
	for_loop_effect = {
		end = curia_law_vote_value_oposite
		if = {
			limit = {
				check_variable = {
					iterator < 0
				}
			}
			set_temp_variable = {
				iterator = vat_curia_law_vote_frames^num
			}
			add_to_temp_variable = {
				iterator_shift = 1
			}
			subtract_from_temp_variable = {
				iterator = iterator_shift
			}
		}
		set_variable = {
			vat_curia_law_vote_frames^iterator = 2
		}
		subtract_from_temp_variable = {
			iterator = 14
		}
	}
}


d_vla = {
	for_loop_effect = {
		end = suspended_laws^num
		value = i
		set_variable = {
			suspended_laws^i = 0
		}
	}
	set_variable = {
		suspended_laws^3 = 3
	}
	set_variable = {
		suspended_laws^8 = 2
	}
	set_variable = {
		suspended_laws^9 = 1
	}
	VAT_validate_law_array = yes
}
VAT_validate_law_array = {
	set_temp_variable = {
		i = 0
	}
	set_temp_variable = {
		k = 0
	}
	while_loop_effect = {
		limit = {
			check_variable = {
				k < suspended_laws^num
			}
		}
		if = {
			limit = {
				check_variable = {
					suspended_laws^i = 0
				}
			}
			remove_from_array = {
				array = suspended_laws
				index = i
			}
			add_to_array = {
				suspended_laws = 0
			}
			remove_from_array = {
				array = suspended_law_start_votes
				index = i
			}
			add_to_array = {
				suspended_law_start_votes = 0
			}
			remove_from_array = {
				array = suspended_law_pope_vote
				index = i
			}
			add_to_array = {
				suspended_law_pope_vote = 0
			}
			remove_from_array = {
				array = suspended_law_secretary_vote
				index = i
			}
			add_to_array = {
				suspended_law_secretary_vote = 0
			}
		}
		else = {
			add_to_temp_variable = {
				i = 1
			}
		}
		add_to_temp_variable = {
			k = 1
		}
	}
}

VAT_curia_add_support_law_5 = { ### Use this when adding 1-5 support
	custom_effect_tooltip = VAT_curia_add_support_law_5_tt
	set_variable_to_random = {
		var = vat_random_support_of_law
		min = 1
		max = 5
		integer = yes
	}
	add_to_variable = {
		curia_law_vote_value = vat_random_support_of_law
	}
	VAT_update_curia_law_gui = yes
}
VAT_curia_add_support_law_6 = { ### Use this when adding 3-6 support
	custom_effect_tooltip = VAT_curia_add_support_law_6_tt
	set_variable_to_random = {
		var = vat_random_support_of_law
		min = 3
		max = 6
		integer = yes
	}
	add_to_variable = {
		curia_law_vote_value = vat_random_support_of_law
	}
	VAT_update_curia_law_gui = yes
}
VAT_curia_add_support_law_remove_7 = { ### Use this when removing 1-7 support
	custom_effect_tooltip = VAT_curia_remove_support_law_7_tt ### Custom tooltip
	set_variable_to_random = {
		var = vat_random_support_of_law
		min = 1
		max = 7
		integer = yes
	}
	subtract_from_variable = {
		curia_law_vote_value = vat_random_support_of_law
	}
	VAT_update_curia_law_gui = yes
}

VAT_curia_add_support_law_remove_5 = { ### Use this when removing 1-5 support
	custom_effect_tooltip = VAT_curia_remove_support_law_5_tt ### Custom tooltip
	set_variable_to_random = {
		var = vat_random_support_of_law
		min = 1
		max = 5
		integer = yes
	}
	subtract_from_variable = {
		curia_law_vote_value = vat_random_support_of_law
	}
	VAT_update_curia_law_gui = yes
}

VAT_curia_add_support_law_remove_3 = { ### Use this when removing 1-5 support
	custom_effect_tooltip = VAT_curia_remove_support_law_3_tt ### Custom tooltip
	set_variable_to_random = {
		var = vat_random_support_of_law
		min = 1
		max = 3
		integer = yes
	}
	subtract_from_variable = {
		curia_law_vote_value = vat_random_support_of_law
	}
	VAT_update_curia_law_gui = yes
}

VAT_init_protestantism_power = {
	add_to_array = { #0
		protestantism_power_modifier_value = 0
	}
	add_to_array = { #1-10
		protestantism_power_modifier_value = -0.05
	}
	add_to_array = { #16-30
		protestantism_power_modifier_value = -0.07
	}
	add_to_array = { #31-45
		protestantism_power_modifier_value = -0.12
	}
	add_to_array = { #46-60
		protestantism_power_modifier_value = -0.15
	}
	add_to_array = { #61-75
		protestantism_power_modifier_value = -0.2
	}
	add_to_array = { #76-90
		protestantism_power_modifier_value = -0.25
	}
	add_to_array = { #90-100
		protestantism_power_modifier_value = -0.3
	}
	VAT_update_protestantism_power_modifier = yes
	add_dynamic_modifier = {
		modifier = VAT_protestantism_resistance
	}
}
VAT_update_protestantism_power_modifier = {
	clamp_variable = {
		var = protestantism_power
		min = 0
		max = 100
	}
	if = {
		limit = {
			check_variable = {
				protestantism_power > 90
			}
		}
		set_variable = {
			cs_i_prot = 6
		}
	}
	else_if = {
		limit = {
			check_variable = {
				protestantism_power > 75
			}
		}
		set_variable = {
			cs_i_prot = 5
		}
	}
	else_if = {
		limit = {
			check_variable = {
				protestantism_power > 60
			}
		}
		set_variable = {
			cs_i_prot = 4
		}
	}
	else_if = {
		limit = {
			check_variable = {
				protestantism_power > 45
			}
		}
		set_variable = {
			cs_i_prot = 3
		}
	}
	else_if = {
		limit = {
			check_variable = {
				protestantism_power > 30
			}
		}
		set_variable = {
			cs_i_prot = 2
		}
	}
	else_if = {
		limit = {
			check_variable = {
				protestantism_power > 10
			}
		}
		set_variable = {
			cs_i_prot = 1
		}
	}
	else = {
		set_variable = {
			cs_i_prot = 0
		}
	}
}

VAT_init_curia = {
	#ATTENTION!
	#curia_vote_value is number votes for LEFT SIDE!!!
	#curia_vote_value_oposite - for RIGHT SIDE!!!
	set_variable = {
		curia_vote_value = 35
	}
	resize_array = {
		array = vat_curia_vote_frames
		size = 70
	}
	resize_array = {
		array = vat_curia_law_vote_frames
		size = 70
	}
	log = "curia_vote_value before update: [?curia_vote_value]"
	VAT_update_curia_gui = yes
	VAT_update_curia_law_gui = yes
	log = "curia_vote_value after update: [?curia_vote_value]"
}

VAT_update_curia_gui = {
	if = {
		limit = { 
			has_power_balance = {
				id = VAT_curia_bop
			}
		}
		if = {
			limit = {
				power_balance_value = {
					id = VAT_curia_bop
					value < 0
				}	
			}
			set_variable = {
				var = curia_vote_value
				value = power_balance_value
			}
			multiply_variable = {
				var = curia_vote_value
				value = 35
			}
			round_variable = curia_vote_value
			add_to_variable = {
				curia_vote_value = 35
			}
		}
		else = {
			set_variable = {
				var = curia_vote_value_oposite
				value = power_balance_value
			}
			multiply_variable = {
				var = curia_vote_value_oposite
				value = 35
			}
			round_variable = curia_vote_value_oposite
			set_variable = {
				curia_vote_value = 35
			}
			subtract_from_variable = {
				curia_vote_value = curia_vote_value_oposite
			}
		}
	}

	log = "curia_vote_value after if about power_balance: [?curia_vote_value]"
	
	#bop frame calculations
	set_variable = {
		vat_curia_bop_frames = curia_vote_value
	}
	divide_variable = {
		vat_curia_bop_frames = 0.7
	}
	round_variable = vat_curia_bop_frames
	#vote semicircle calculations
	set_variable = {
		curia_vote_value_oposite = 70
	}
	subtract_from_variable = {
		curia_vote_value_oposite = curia_vote_value
	}
	set_temp_variable = {
		iterator = vat_curia_vote_frames^num
	}
	set_temp_variable = {
		iterator_shift = 1
	}
	subtract_from_temp_variable = {
		iterator = iterator_shift
	}
	#maybe can be optimised, but it`s too complicated (maybe votes have to be swapped)
	for_loop_effect = {
		end = vat_curia_vote_frames^num
		value = i
		set_variable = {
			vat_curia_vote_frames^i = 1
		}
	}
	for_loop_effect = {
		end = curia_vote_value_oposite
		if = {
			limit = {
				check_variable = {
					iterator < 0
				}
			}
			set_temp_variable = {
				iterator = vat_curia_vote_frames^num
			}
			add_to_temp_variable = {
				iterator_shift = 1
			}
			subtract_from_temp_variable = {
				iterator = iterator_shift
			}
		}
		set_variable = {
			vat_curia_vote_frames^iterator = 2
		}
		subtract_from_temp_variable = {
			iterator = 14
		}
	}
}

VAT_add_votes_for_law = {
	custom_effect_tooltip = vat_bill_law_additional_support_from_the_start_tt
	add_to_variable = {
		var = curia_law_vote_value
		value = vat_random_additional_support_of_law
	}
}
VAT_subtract_votes_for_law = {
	custom_effect_tooltip = vat_bill_law_additional_support_from_the_start_remove_tt
	subtract_from_variable = {
		var = curia_law_vote_value
		value = vat_random_additional_support_of_law
	}
}
VAT_law_add_additional_law_votes_at_the_start = {
	set_variable = {
		var = max_additional_law_vote
		value = power_balance_value
	}
	if = {
		limit = {
			check_variable = { max_additional_law_vote < 0 }
		}
		multiply_variable = { max_additional_law_vote = -1 }
	}
	multiply_variable = {
		var = max_additional_law_vote
		value = 35
	}
	round_variable = max_additional_law_vote
	set_variable_to_random = {
		var = vat_random_additional_support_of_law
		min = 1
		max = max_additional_law_vote
		integer = yes
	}

	if = {
		limit = { VAT_traditionalists_dominate = yes }
		if = {
			limit = { VAT_is_law_by_traditionalists = yes }
			VAT_add_votes_for_law = yes
			log = "current law: [?current_law], traditionalists dominate, votes added"
		}
		else_if = {
			limit = { VAT_is_law_by_reformists = yes }
			VAT_subtract_votes_for_law = yes
			log = "current law: [?current_law], traditionalists dominate, votes subtracted"
		}
	}
	else_if = {
		limit = { VAT_reformists_dominate = yes }
		if = {
			limit = { VAT_is_law_by_reformists = yes }
			VAT_add_votes_for_law = yes
			log = "current law: [?current_law], reformists dominate, votes added"
		}
		else_if = {
			limit = { VAT_is_law_by_traditionalists = yes }
			VAT_subtract_votes_for_law = yes
			log = "current law: [?current_law], reformists dominate, votes subtracted"
		}
	}
	set_variable = { max_additional_law_vote = 0 }
}

VAT_law_initialization = {
	VAT_law_add_additional_law_votes_at_the_start = yes
	hidden_effect = {
		VAT_update_curia_law_gui = yes
		activate_mission = VAT_curia_law_voting_mission
		random_list = {
			40 = {
				country_event = {
					id = vat_random.21
					days = 5
					random_days = 15
				}
			}
			40 = {
				country_event = {
					id = vat_random.22
					days = 5
					random_days = 15
				}
			}
			20 = {
				country_event = {
					id = vat_random.23
					days = 5
					random_days = 15
				}
			}
		}
	}
}

VAT_veto_by_traditionalists = {
	if = {
		limit = {
			OR = {
				var:current_pope = { is_character = VAT_Pius_XI }
				var:current_pope = { is_character = VAT_Pius_XII }
				var:current_pope = { is_character = VAT_Adrian_VII }
			}
		}
		set_variable = {
			current_law_pope_vote = 0
		}
		set_variable = {                
			current_law_secretary_vote = 1
		}
		custom_effect_tooltip = vat_papal_veto_tt
	}
	else = {
		set_variable = {
			current_law_pope_vote = 1
		}
		set_variable = {                
			current_law_secretary_vote = 0
		}
		custom_effect_tooltip = vat_secretary_veto_tt
	}
}
VAT_veto_by_reformists = {
	if = {
		limit = {
			OR = {
				var:current_pope = { is_character = VAT_Stefan_X }
				var:current_pope = { is_character = VAT_Benedict_XVI }
			}
		}
		set_variable = {
			current_law_pope_vote = 0
		}
		set_variable = {                
			current_law_secretary_vote = 1
		}
		custom_effect_tooltip = vat_papal_veto_tt
	}
	else = {
		set_variable = {
			current_law_pope_vote = 1
		}
		set_variable = {                
			current_law_secretary_vote = 0
		}
		custom_effect_tooltip = vat_secretary_veto_tt
	}
}

VAT_init_catholic_uprising = {
	set_party_name = {
		ideology = democratic
		long_name = diocese_administration_long
		name = diocese_administration
	}
	set_party_name = {
		ideology = neutrality
		long_name = diocese_administration_long
		name = diocese_administration
	}
	add_equipment_to_stockpile = {
		type = infantry_equipment_1
		amount = 2000
		producer = VAT
	}
	add_equipment_to_stockpile = {
		type = support_equipment
		amount = 100
		producer = VAT
	}
	
	meta_effect = {
		text = {
			set_cosmetic_tag = [TAG]_VAT_uprising
		}
		TAG = "[FROM.GetTag]"
	}
}
VAT_init_catholic_coup = {
	set_party_name = {
		ideology = democratic
		long_name = diocese_administration_long
		name = diocese_administration
	}
	set_party_name = {
		ideology = neutrality
		long_name = diocese_administration_long
		name = diocese_administration
	}
	if = {
		limit = {
			VAT = { has_government = fascism }
		}
		set_politics = {
			ruling_party = neutrality
		}
		add_popularity = {
			ideology = neutrality
			popularity = 0.5
		}
	}
	
	meta_effect = {
		text = {
			set_cosmetic_tag = [TAG]_VAT_diocese
		}
		TAG = "[FROM.GetTag]"
	}
}
VAT_create_diocese_in_country = {
	set_party_name = {
		ideology = democratic
		long_name = diocese_administration_long
		name = diocese_administration
	}
	set_party_name = {
		ideology = neutrality
		long_name = diocese_administration_long
		name = diocese_administration
	}
	
	meta_effect = {
		text = {
			set_cosmetic_tag = [TAG]_VAT_diocese
		}
		TAG = "[?vat_TAG_var.GetTag]"
	}
}

VAT_swap_ruling_party_if_master_fascist = {
	if = {
		limit = {
			VAT = { has_government = fascism }
		}
		set_politics = {
			ruling_party = neutrality
		}
		add_popularity = {
			ideology = neutrality
			popularity = 0.5
		}
	}
}

VAT_update_german_relations_var = {
	clamp_variable = {
		var = vat_german_relations
		min = 0
		max = 100
	}
}
VAT_update_german_influence_var = {
	clamp_variable = {
		var = vat_german_influence
		min = 0
		max = 100
	}
}