on_unification_candidate_added = {
	
	# Takes effect each time a unification candidate is added. You may need to wait a few ticks for this to take effect
	on_actions = {
		WB_setup_on_actions
	}
}

# Some redundancies to guarantee these variables gets added
on_start_supporting_unification = {
	on_actions = {
		WB_setup_on_actions
	}
}
on_country_released_as_independent = {
	on_actions = {
		WB_setup_on_actions
	}
}
on_country_released_as_own_subject = {
	on_actions = {
		WB_setup_on_actions
	}
}
on_country_released_as_overlord_subject = {
	on_actions = {
		WB_setup_on_actions
	}
}

WB_setup_on_actions = {

effect = {
	
## Italian Unifiers variables
			
	every_country = {
	
		limit = {
			exists = c:SAR
			this = c:SAR
		}
		set_variable = {
			name = WB_is_Sardinia_Piedmont_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:SIC
			this = c:SIC
		}
		set_variable = {
			name = WB_is_Two_Sicilies_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:PAP
			this = c:PAP
		}
		set_variable = {
			name = WB_is_Papal_States_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:TUS
			this = c:TUS
		}
		set_variable = {
			name = WB_is_Tuscany_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:MOD
			this = c:MOD
		}
		set_variable = {
			name = WB_is_Modena_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:LUC
			this = c:LUC
		}
		set_variable = {
			name = WB_is_Lucca_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:PAR
			this = c:PAR
		}
		set_variable = {
			name = WB_is_Parma_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:LOM
			this = c:LOM
		}
		set_variable = {
			name = WB_is_Lombardia_var
			value = 0
		}
	}
	
	every_country = {
	# For Kikko's Formable and Releasable Nations' Lombardy-Venezia
		limit = {
			exists = c:LMV
			this = c:LMV
		}
		set_variable = {
			name = WB_is_Lombardia_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:VEN
			this = c:VEN
		}
		set_variable = {
			name = WB_is_Venice_var
			value = 0
		}
	}
			
	every_country = {
		limit = {
			exists = c:TRE
			this = c:TRE
		}
		set_variable = {
			name = WB_is_Trieste_var
			value = 0
		}
	}
			
			
## German Unifiers variables
			
	every_country = {

		limit = {
			exists = c:PRU
			this = c:PRU
		}
		set_variable = {
			name = WB_is_Prussia_var
			value = 0
		}
	}

	every_country = {
		limit = {
			exists = c:AUS
			this = c:AUS
		}
		set_variable = {
			name = WB_is_Austria_var
			value = 0
		}
	}

	every_country = {
		limit = {
			exists = c:BAV
			this = c:BAV
		}
		set_variable = {
			name = WB_is_Bavaria_var
			value = 0
		}
	}

	every_country = {
		limit = {
			exists = c:SCH
			this = c:SCH
		}
		set_variable = {
			name = WB_is_Schleswig_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:WES
			this = c:WES
		}
		set_variable = {
			name = WB_is_Westphalia_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:HAN
			this = c:HAN
		}
		set_variable = {
			name = WB_is_Hanover_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:POM
			this = c:POM
		}
		set_variable = {
			name = WB_is_Pommerania_var
			value = 0
		}
	}
	
	# The Mecklenburgs
	every_country = {
		limit = {
			exists = c:MEC
			this = c:MEC
		}
		set_variable = {
			name = WB_is_Mecklenburg_var
			value = 0
		}
	}
	every_country = { # Mecklenburg-Strelitz
		limit = {
			exists = c:MST
			this = c:MST
		}
		set_variable = {
			name = WB_is_Mecklenburg_var
			value = 0
		}
	}
	
	#The Saxonies
	
	every_country = {
		limit = {
			exists = c:WEI
			this = c:WEI
		}
		set_variable = {
			name = WB_is_Saxe_Weimar_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:SAX
			this = c:SAX
		}
		set_variable = {
			name = WB_is_Saxony_var
			value = 0
		}
	}
	
	every_country = { # Saxe-Coburg-Gotha
		limit = {
			exists = c:COB
			this = c:COB
		}
		set_variable = {
			name = WB_is_Saxony_var
			value = 0
		}
	}
	
	every_country = { # Saxe-Meiningen
		limit = {
			exists = c:MEI
			this = c:MEI
		}
		set_variable = {
			name = WB_is_Saxony_var
			value = 0
		}
	}
	
	every_country = { # Schwarzburg
		limit = {
			exists = c:SCW
			this = c:SCW
		}
		set_variable = {
			name = WB_is_Saxony_var
			value = 0
		}
	}
	
	## Canadian and Australian unifiers ##

	every_country = {
		limit = {
			exists = c:ONT
			this = c:ONT
		}
		set_variable = {
			name = WB_is_WU_Canada_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:QUE
			this = c:QUE
		}
		set_variable = {
			name = WB_is_Quebec_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:NEW
			this = c:NEW
		}
		set_variable = {
			name = WB_is_Newfoundland_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:NVS
			this = c:NVS
		}
		set_variable = {
			name = WB_is_Nova_Scotia_var
			value = 0
		}
	}

	every_country = {
		limit = {
			exists = c:NBS
			this = c:NBS
		}
		set_variable = {
			name = WB_is_New_Brunswick_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:HBC
			this = c:HBC
		}
		set_variable = {
			name = WB_is_HBC_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:ORG
			this = c:ORG
		}
		set_variable = {
			name = WB_is_Cascadia_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:NSW
			this = c:NSW
		}
		set_variable = {
			name = WB_is_WU_Australia_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:NZL
			this = c:NZL
		}
		set_variable = {
			name = WB_is_New_Zealand_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:WAS
			this = c:WAS
		}
		set_variable = {
			name = WB_is_Western_Australia_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:SAS
			this = c:SAS
		}
		set_variable = {
			name = WB_is_South_Australia_var
			value = 0
		}
	}

	every_country = {
		limit = {
			exists = c:TAS
			this = c:TAS
		}
		set_variable = {
			name = WB_is_Tasmania_var
			value = 0
		}
	}
	
## USA unifiers ##
	
	# Texas
	every_country = {
		limit = {
			OR = {
				AND = {
					exists = c:TEX
					this = c:TEX
				}
				
				AND = {
					exists = c:USA
					this = c:USA
					c:USA = {
						was_formed_from = TEX
					}
				}
			}
		}
		set_variable = {
			name = WB_is_Texas_var
			value = 0
		}
	}
	
	# CSA
	every_country = {
		limit = {
			exists = c:CSA
			this = c:CSA
		}
		set_variable = {
			name = WB_is_CSA_var
			value = 0
		}
	}
	
	# FSA
	every_country = {
		limit = {
			exists = c:FSA
			this = c:FSA
		}
		set_variable = {
			name = WB_is_FSA_var
			value = 0
		}
	}
	
	# California
	every_country = {
		limit = {
			exists = c:CAL
			this = c:CAL
		}
		set_variable = {
			name = WB_is_California_var
			value = 0
		}
	}
	
	# New England
	every_country = {
		limit = {
			exists = c:NEN
			this = c:NEN
		}
		set_variable = {
			name = WB_is_New_England_var
			value = 0
		}
	}
	
	# Michigan
	every_country = {
		limit = {
			exists = c:UOM
			this = c:UOM
		}
		set_variable = {
			name = WB_is_Michigan_var
			value = 0
		}
	}
	
	# Deseret
	every_country = {
		limit = {
			exists = c:DES
			this = c:DES
		}
		set_variable = {
			name = WB_is_Deseret_var
			value = 0
		}
	}
	
## Yugoslav unifiers ##
	
	# Serbia
	every_country = {
		limit = {
			exists = c:SER
			this = c:SER
		}
		set_variable = {
			name = WB_is_Serbia_var
			value = 0
		}
	}
	
	# Montenegro
	every_country = {
		limit = {
			exists = c:MON
			this = c:MON
		}
		set_variable = {
			name = WB_is_Montenegro_var
			value = 0
		}
	}

## Byzantine unifiers ##
	
	# Greece
	every_country = {
		limit = {
			exists = c:GRE
			this = c:GRE
		}
		set_variable = {
			name = WB_is_Greece_var
			value = 0
		}
	}
	
	# Ionian Islands
	every_country = {
		limit = {
			exists = c:ION
			this = c:ION
		}
		set_variable = {
			name = WB_is_Corfu_var
			value = 0
		}
	}
	
## Scandinavian unifiers
	
	every_country = {
		limit = {
			exists = c:SWE
			this = c:SWE
		}
		set_variable = {
			name = WB_is_Sweden_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:NOR
			this = c:NOR
		}
		set_variable = {
			name = WB_is_Norway_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:DEN
			this = c:DEN
		}
		set_variable = {
			name = WB_is_Denmark_var
			value = 0
		}
	}

## Misc

	every_country = {
		limit = {
			exists = c:EGY
			this = c:EGY
		}
		set_variable = {
			name = WB_is_Egypt_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:JOH
			this = c:JOH
		}
		set_variable = {
			name = WB_is_Johor_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:WAL
			this = c:WAL
		}
		set_variable = {
			name = WB_is_Wallachia_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:MOL
			this = c:MOL
		}
		set_variable = {
			name = WB_is_Moldavia_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:HUN
			this = c:HUN
		}
		set_variable = {
			name = WB_is_Hungary_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:TUG
			this = c:TUG
		}
		set_variable = {
			name = WB_is_Touggourt_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:AIT
			this = c:AIT
		}
		set_variable = {
			name = algeria_ait_abbas_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:CON
			this = c:CON
		}
		set_variable = {
			name = algeria_constantine_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:GBR
			this = c:GBR
		}
		set_variable = {
			name = WB_is_Britain_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:FRA
			this = c:FRA
		}
		set_variable = {
			name = WB_is_France_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:SPA
			this = c:SPA
		}
		set_variable = {
			name = WB_is_Spain_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:POR
			this = c:POR
		}
		set_variable = {
			name = WB_is_Portugal_var
			value = 0
		}
	}

	every_country = {
		limit = {
			exists = c:ARG
			this = c:ARG
		}
		set_variable = {
			name = WB_is_Argie_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:NET
			this = c:NET
		}
		set_variable = {
			name = WB_is_Netherlands_var
			value = 0
		}
	}
	
	every_country = {
		limit = {
			exists = c:BEL
			this = c:BEL
		}
		set_variable = {
			name = WB_is_Belgium_var
			value = 0
		}
	}
}

}

## Monthly pulse ##

on_monthly_pulse_country = {

	effect = {
	
		# To detect if Austria-Hungary has been formed
		if = {
			limit = {
				exists = c:AUS
				THIS = c:AUS
				
				cu:hungarian = {
					NOT = { culture_is_discriminated_in = c:AUS }
				}
				
				c:AUS = {
					NOT = { has_journal_entry = je_dual_monarchy }
				}
				
				NOT = { has_global_variable = WB_Austria_Hungary_is_formed_var }
			}
			
			c:AUS = {
				set_variable = {
				name = WB_is_Austria_Hungary_var
				value = 0
				}
			}
			
			set_global_variable = WB_Austria_Hungary_is_formed_var
		}
		
		# So that Haiti doesn't lose its flag with its national emblem if Greece no longer exists
		if = {
			limit = {
				exists = c:GRE
				THIS = c:GRE
				
				c:GRE ?= { has_variable = revive_olympics_decision_taken }
				
				NOT = { has_global_variable = WB_Greece_started_Olympics_var }
			}
			
			set_global_variable = WB_Greece_started_Olympics_var
		}
		
	}
}