add_namespace = erevents

#Elections: Voting Tour 1.
country_event = {
	id = erevents.1
	title = erevents.1.t
	desc = erevents.1.desc

	picture = elections_voting_tour_1-618
	is_triggered_only = yes
	trigger = {
		NOT = {
			AND = {
				tag = USA
				date < 1949.1.1
				
			}
		}
		OR = { NOT = { original_tag = SPR } NOT = { date < 1937.1.1 } }
	}
	option = {
		name = erevents.1.a
		trigger = {
			NOT = {
				has_government = democratic
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = communism
				party_popularity@fascism > 0.15
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = neutrality
				add = 1
			}
			#compare influence
			modifier = {
				has_government = communism
				check_variable = { ROOT.Fas_inf > ROOT.Dem_inf }
				add = -2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Dem_inf }
				add = -2
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = 2
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = fascism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 3
			}
			#has acceptance?
			modifier = {
				democratic_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = democratic
			popularity = 0.05
		}
		add_to_variable = { ROOT.Dem_inf = 5 }
		hidden_effect = {
			set_variable = { ROOT.d_lose = 0 }
			country_event = { id = erevents.2 days = 3 }
		}
		if = {
			limit = {
				NOT = {
					has_country_flag = ROOT.on_going_elections
				}
			}
			set_country_flag = ROOT.on_going_elections
		}
	}
	option = {
		name = erevents.1.b
		trigger = {
			NOT = {
				has_government = communism
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = neutrality
				party_popularity@democratic > 0.15
				add = -2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = 2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = fascism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 3
			}
			#has acceptance?
			modifier = {
				communism_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = communism
			popularity = 0.05
		}
		add_to_variable = { ROOT.Com_inf = 5 }
		hidden_effect = {
			set_variable = { ROOT.c_lose = 0 }
			country_event = { id = erevents.2 days = 3 }
		}
		if = {
			limit = {
				NOT = {
					has_country_flag = ROOT.on_going_elections
				}
			}
			set_country_flag = ROOT.on_going_elections
		}
	}
	option = {
		name = erevents.1.c
		trigger = {
			NOT = {
				has_government = fascism
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = communism
				add = 2
			}
			modifier = {
				has_government = neutrality
				party_popularity@democratic > 0.15
				add = -2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = communism
				add = 1
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = -2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = -1
			}
			#has acceptance?
			modifier = {
				fascism_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = fascism
			popularity = 0.05
		}
		add_to_variable = { ROOT.Fas_inf = 5 }
		hidden_effect = {
			set_variable = { ROOT.f_lose = 0 }
			country_event = { id = erevents.2 days = 3 }
		}
		if = {
			limit = {
				NOT = {
					has_country_flag = ROOT.on_going_elections
				}
			}
			set_country_flag = ROOT.on_going_elections
		}
	}
	option = {
		name = erevents.1.d
		trigger = {
			NOT = {
				has_government = neutrality
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				add = 2
			}
			modifier = {
				has_government = communism
				party_popularity@fascism > 0.20
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@communism < 0.25
				add = 2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Fas_inf }
				add = 2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = 2
			}
			modifier = {
				has_government = communism
				check_variable = { ROOT.Neu_inf < Fas_inf }
				add = 2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 1
			}
			#has acceptance?
			modifier = {
				neutrality_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = neutrality
			popularity = 0.05
		}
		add_to_variable = { ROOT.Neu_inf = 5 }
		hidden_effect = {
			set_variable = { ROOT.n_lose = 0 }
			country_event = { id = erevents.2 days = 3 }
		}
		if = {
			limit = {
				NOT = {
					has_country_flag = ROOT.on_going_elections
				}
			}
			set_country_flag = ROOT.on_going_elections
		}
	}
	option = {
		name = erevents.1.f
		
		hidden_effect = {
			country_event = { id = erevents.2 days = 3 }
		}
		
	}
}

#Elections: Voting Tour 2.
country_event = {
	id = erevents.2
	title = erevents.2.t
	desc = erevents.2.desc

	picture = elections_voting_tour_2-605
	is_triggered_only = yes
	option = {
		name = erevents.2.a
		trigger = {
			NOT = {
				has_government = democratic
				AND = {
					check_variable = { party_popularity@democratic < party_popularity@fascism }
					check_variable = { party_popularity@democratic < party_popularity@communism }
					check_variable = { party_popularity@democratic < party_popularity@neutrality }
				}
			}
			OR = {
				check_variable = { party_popularity@democratic > party_popularity@fascism }
				check_variable = { party_popularity@democratic > party_popularity@communism }
				check_variable = { party_popularity@democratic > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = communism
				party_popularity@fascism > 0.15
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = neutrality
				add = 1
			}
			#compare influence
			modifier = {
				has_government = communism
				check_variable = { ROOT.Fas_inf > ROOT.Dem_inf }
				add = -2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Dem_inf }
				add = -2
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = 2
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = fascism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 3
			}
			#has acceptance?
			modifier = {
				democratic_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = democratic
			popularity = 0.05
		}
		add_to_variable = { ROOT.Dem_inf = 5 }
		hidden_effect = {
			if = {
				limit = {
					check_variable = { party_popularity@democratic < party_popularity@fascism }
					check_variable = { party_popularity@democratic < party_popularity@communism }
					check_variable = { party_popularity@democratic < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.d_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@communism < party_popularity@democratic }
					check_variable = { party_popularity@communism < party_popularity@fascism }
					check_variable = { party_popularity@communism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.c_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@fascism < party_popularity@democratic }
					check_variable = { party_popularity@fascism < party_popularity@communism }
					check_variable = { party_popularity@fascism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.f_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@neutrality < party_popularity@democratic }
					check_variable = { party_popularity@neutrality < party_popularity@communism }
					check_variable = { party_popularity@neutrality < party_popularity@fascism }
				}
				add_to_variable = { ROOT.n_lose = 1 }
			}
			country_event = { id = erevents.3 days = 3 }
		}
	}
	option = {
		name = erevents.2.b
		trigger = {
			NOT = {
				has_government = communism
				AND = {
					check_variable = { party_popularity@communism < party_popularity@fascism }
					check_variable = { party_popularity@communism < party_popularity@democratic }
					check_variable = { party_popularity@communism < party_popularity@neutrality }
				}
			}
			OR = {
				check_variable = { party_popularity@communism > party_popularity@fascism }
				check_variable = { party_popularity@communism > party_popularity@democratic }
				check_variable = { party_popularity@communism > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = neutrality
				party_popularity@democratic > 0.15
				add = -2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = 2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = fascism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 3
			}
			#has acceptance?
			modifier = {
				communism_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = communism
			popularity = 0.05
		}
		add_to_variable = { ROOT.Com_inf = 5 }
		hidden_effect = {
			if = {
				limit = {
					check_variable = { party_popularity@democratic < party_popularity@fascism }
					check_variable = { party_popularity@democratic < party_popularity@communism }
					check_variable = { party_popularity@democratic < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.d_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@communism < party_popularity@democratic }
					check_variable = { party_popularity@communism < party_popularity@fascism }
					check_variable = { party_popularity@communism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.c_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@fascism < party_popularity@democratic }
					check_variable = { party_popularity@fascism < party_popularity@communism }
					check_variable = { party_popularity@fascism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.f_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@neutrality < party_popularity@democratic }
					check_variable = { party_popularity@neutrality < party_popularity@communism }
					check_variable = { party_popularity@neutrality < party_popularity@fascism }
				}
				add_to_variable = { ROOT.n_lose = 1 }
			}
			country_event = { id = erevents.3 days = 3 }
		}
	}
	option = {
		name = erevents.2.c
		trigger = {
			NOT = {
				has_government = fascism
				AND = {
					check_variable = { party_popularity@fascism < party_popularity@communism }
					check_variable = { party_popularity@fascism < party_popularity@democratic }
					check_variable = { party_popularity@fascism < party_popularity@neutrality }
				}
			}
			OR = {
				check_variable = { party_popularity@fascism > party_popularity@communism }
				check_variable = { party_popularity@fascism > party_popularity@democratic }
				check_variable = { party_popularity@fascism > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = communism
				add = 2
			}
			modifier = {
				has_government = neutrality
				party_popularity@democratic > 0.15
				add = -2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = communism
				add = 1
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = -2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = -1
			}
			#has acceptance?
			modifier = {
				fascism_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = fascism
			popularity = 0.05
		}
		add_to_variable = { ROOT.Fas_inf = 5 }
		hidden_effect = {
			if = {
				limit = {
					check_variable = { party_popularity@democratic < party_popularity@fascism }
					check_variable = { party_popularity@democratic < party_popularity@communism }
					check_variable = { party_popularity@democratic < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.d_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@communism < party_popularity@democratic }
					check_variable = { party_popularity@communism < party_popularity@fascism }
					check_variable = { party_popularity@communism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.c_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@fascism < party_popularity@democratic }
					check_variable = { party_popularity@fascism < party_popularity@communism }
					check_variable = { party_popularity@fascism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.f_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@neutrality < party_popularity@democratic }
					check_variable = { party_popularity@neutrality < party_popularity@communism }
					check_variable = { party_popularity@neutrality < party_popularity@fascism }
				}
				add_to_variable = { ROOT.n_lose = 1 }
			}
			country_event = { id = erevents.3 days = 3 }
		}
	}
	option = {
		name = erevents.2.d
		trigger = {
			NOT = {
				has_government = neutrality
				AND = {
					check_variable = { party_popularity@neutrality < party_popularity@communism }
					check_variable = { party_popularity@neutrality < party_popularity@democratic }
					check_variable = { party_popularity@neutrality < party_popularity@fascism }
				}
			}
			OR = {
				check_variable = { party_popularity@neutrality > party_popularity@communism }
				check_variable = { party_popularity@neutrality > party_popularity@democratic }
				check_variable = { party_popularity@neutrality > party_popularity@fascism }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				add = 2
			}
			modifier = {
				has_government = communism
				party_popularity@fascism > 0.20
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@communism < 0.25
				add = 2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Fas_inf }
				add = 2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = 2
			}
			modifier = {
				has_government = communism
				check_variable = { ROOT.Neu_inf < Fas_inf }
				add = 2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 1
			}
			#has acceptance?
			modifier = {
				neutrality_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = neutrality
			popularity = 0.05
		}
		add_to_variable = { ROOT.Neu_inf = 5 }
		hidden_effect = {
			if = {
				limit = {
					check_variable = { party_popularity@democratic < party_popularity@fascism }
					check_variable = { party_popularity@democratic < party_popularity@communism }
					check_variable = { party_popularity@democratic < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.d_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@communism < party_popularity@democratic }
					check_variable = { party_popularity@communism < party_popularity@fascism }
					check_variable = { party_popularity@communism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.c_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@fascism < party_popularity@democratic }
					check_variable = { party_popularity@fascism < party_popularity@communism }
					check_variable = { party_popularity@fascism < party_popularity@neutrality }
				}
				add_to_variable = { ROOT.f_lose = 1 }
			}
			if = {
				limit = {
					check_variable = { party_popularity@neutrality < party_popularity@democratic }
					check_variable = { party_popularity@neutrality < party_popularity@communism }
					check_variable = { party_popularity@neutrality < party_popularity@fascism }
				}
				add_to_variable = { ROOT.n_lose = 1 }
			}
			country_event = { id = erevents.3 days = 3 }
		}
	}
	option = {
		name = erevents.2.f
		
		hidden_effect = {
			
			country_event = { id = erevents.3 days = 3 }
		}
		
	}
}

#Elections: Voting Tour 3.
country_event = {
	id = erevents.3
	title = erevents.3.t
	desc = erevents.3.desc

	picture = elections_voting_tour_3-750
	is_triggered_only = yes
	option = {
		name = erevents.3.a
		trigger = {
			NOT = {
				has_government = democratic
				AND = {
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.f_lose < 1}
								check_variable = { ROOT.f_lose = 0}
							}
						}
						check_variable = { party_popularity@democratic < party_popularity@fascism }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.c_lose < 1}
								check_variable = { ROOT.c_lose = 0}
							}
						}
						check_variable = { party_popularity@democratic < party_popularity@communism }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.n_lose < 1}
								check_variable = { ROOT.n_lose = 0}
							}
						}
						check_variable = { party_popularity@democratic < party_popularity@neutrality }
					}
				}
				OR = {
					check_variable = { ROOT.d_lose = 1 }
					check_variable = { ROOT.d_lose > 1 }
				}
			}
			OR = {
				check_variable = { party_popularity@democratic > party_popularity@fascism }
				check_variable = { party_popularity@democratic > party_popularity@communism }
				check_variable = { party_popularity@democratic > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = communism
				party_popularity@fascism > 0.15
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = neutrality
				add = 1
			}
			#compare influence
			modifier = {
				has_government = communism
				check_variable = { ROOT.Fas_inf > ROOT.Dem_inf }
				add = -2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Dem_inf }
				add = -2
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = 2
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = fascism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 3
			}
			#has acceptance?
			modifier = {
				democratic_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = democratic
			popularity = 0.05
		}
		add_to_variable = { ROOT.Dem_inf = 5 }
		hidden_effect = {
			country_event = { id = erevents.4 days = 3 }
		}
	}
	option = {
		name = erevents.3.b
		trigger = {
			NOT = {
				has_government = communism
				AND = {
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.f_lose < 1}
								check_variable = { ROOT.f_lose = 0}
							}
						}
						check_variable = { party_popularity@communism < party_popularity@fascism }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.d_lose < 1}
								check_variable = { ROOT.d_lose = 0}
							}
						}
						check_variable = { party_popularity@communism < party_popularity@democratic }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.n_lose < 1}
								check_variable = { ROOT.n_lose = 0}
							}
						}
						check_variable = { party_popularity@communism < party_popularity@neutrality }
					}
				}
				OR = {
					check_variable = { ROOT.c_lose = 1 }
					check_variable = { ROOT.c_lose > 1 }
				}
			}
			OR = {
				check_variable = { party_popularity@communism > party_popularity@fascism }
				check_variable = { party_popularity@communism > party_popularity@democratic }
				check_variable = { party_popularity@communism > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = neutrality
				party_popularity@democratic > 0.15
				add = -2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = 2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = fascism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 3
			}
			#has acceptance?
			modifier = {
				communism_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = communism
			popularity = 0.05
		}
		add_to_variable = { ROOT.Com_inf = 5 }
		hidden_effect = {
			country_event = { id = erevents.4 days = 3 }
		}
	}
	option = {
		name = erevents.3.c
		trigger = {
			NOT = {
				has_government = fascism
				AND = {
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.c_lose < 1}
								check_variable = { ROOT.c_lose = 0}
							}
						}
						check_variable = { party_popularity@fascism < party_popularity@communism }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.d_lose < 1}
								check_variable = { ROOT.d_lose = 0}
							}
						}
						check_variable = { party_popularity@fascism < party_popularity@democratic }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.n_lose < 1}
								check_variable = { ROOT.n_lose = 0}
							}
						}
						check_variable = { party_popularity@fascism < party_popularity@neutrality }
					}
				}
				OR = {
					check_variable = { ROOT.f_lose = 1 }
					check_variable = { ROOT.f_lose > 2 }
				}
			}
			OR = {
				check_variable = { party_popularity@fascism > party_popularity@communism }
				check_variable = { party_popularity@fascism > party_popularity@democratic }
				check_variable = { party_popularity@fascism > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				party_popularity@neutrality > 0.15
				add = -2
			}
			modifier = {
				has_government = communism
				add = 2
			}
			modifier = {
				has_government = neutrality
				party_popularity@democratic > 0.15
				add = -2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = -2
			}
			modifier = {
				has_government = communism
				add = 1
			}
			modifier = {
				has_government = neutrality
				check_variable = { ROOT.Dem_inf > 25 }
				add = -2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = -1
			}
			#has acceptance?
			modifier = {
				fascism_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = fascism
			popularity = 0.05
		}
		add_to_variable = { ROOT.Fas_inf = 5 }
		hidden_effect = {
			country_event = { id = erevents.4 days = 3 }
		}
	}
	option = {
		name = erevents.3.d
		trigger = {
			NOT = {
				has_government = neutrality
				AND = {
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.c_lose < 1}
								check_variable = { ROOT.c_lose = 0}
							}
						}
						check_variable = { party_popularity@neutrality < party_popularity@communism }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.d_lose < 1}
								check_variable = { ROOT.d_lose = 0}
							}
						}
						check_variable = { party_popularity@neutrality < party_popularity@democratic }
					}
					if = {
						limit = {
							OR = {
								check_variable = { ROOT.f_lose < 1}
								check_variable = { ROOT.f_lose = 0}
							}
						}
						check_variable = { party_popularity@neutrality < party_popularity@fascism }
					}
				}
				OR = {
					check_variable = { ROOT.n_lose = 1 }
					check_variable = { ROOT.n_lose > 2 }
				}
			}
			OR = {
				check_variable = { party_popularity@neutrality > party_popularity@communism }
				check_variable = { party_popularity@neutrality > party_popularity@democratic }
				check_variable = { party_popularity@neutrality > party_popularity@fascism }
			}
		}
		ai_chance = {
			base = 1
			#compare parties
			modifier = {
				has_government = democratic
				add = 2
			}
			modifier = {
				has_government = communism
				party_popularity@fascism > 0.20
				add = -2
			}
			modifier = {
				has_government = fascism
				party_popularity@communism < 0.25
				add = 2
			}
			#compare influence
			modifier = {
				has_government = democratic
				check_variable = { ROOT.Neu_inf > ROOT.Fas_inf }
				add = 2
			}
			modifier = {
				has_government = fascism
				check_variable = { ROOT.Neu_inf > ROOT.Com_inf }
				add = 2
			}
			modifier = {
				has_government = communism
				check_variable = { ROOT.Neu_inf < Fas_inf }
				add = 2
			}
			#check stability
			modifier = {
				has_government = democratic
				has_stability < 0.45
				add = -1
			}
			modifier = {
				has_government = communism
				has_stability < 0.45
				add = 1
			}
			modifier = {
				has_government = neutrality
				has_stability < 0.45
				add = 1
			}
			#has acceptance?
			modifier = {
				neutrality_acceptance > 20
				add = 2
			}
		}
		add_popularity = {
			ideology = neutrality
			popularity = 0.05
		}
		add_to_variable = { ROOT.Neu_inf = 5 }
		hidden_effect = {
			country_event = { id = erevents.4 days = 3 }
		}
	}
	option = {
		name = erevents.3.f
		
		hidden_effect = {
			country_event = { id = erevents.4 days = 3 }
		}
		
	}
}

#Elections: The Winner.
country_event = {
	id = erevents.4
	title = erevents.4.t
	desc = erevents.4.desc

	picture = elections_the_winner-766
	is_triggered_only = yes
	option = {
		name = erevents.4.a
		trigger = {
			AND = {
				check_variable = { party_popularity@democratic > party_popularity@fascism }
				check_variable = { party_popularity@democratic > party_popularity@communism }
				check_variable = { party_popularity@democratic > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 5
		}
		set_politics = { ruling_party = democratic elections_allowed = no }
		add_ideas = spirit_of_democracy
		if = {
			limit = { has_idea = communism_empowered }
			remove_ideas = communism_empowered
		}
		if = {
			limit = { has_idea = fascism_will }
			remove_ideas = fascism_will
		}
		if = {
			limit = { has_idea = authoritarian_spirit }
			remove_ideas = authoritarian_spirit
		}
		
		clr_country_flag = ROOT.on_going_elections
		hidden_effect = {
			clear_variable = ROOT.d_lose
			clear_variable = ROOT.c_lose
			clear_variable = ROOT.f_lose
			clear_variable = ROOT.n_lose
		}
	}
	option = {
		name = erevents.4.b
		trigger = {
			AND = {
				check_variable = { party_popularity@communism > party_popularity@fascism }
				check_variable = { party_popularity@communism > party_popularity@democratic }
				check_variable = { party_popularity@communism > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 5
		}
		set_politics = { ruling_party = communism elections_allowed = no }
		add_ideas = communism_empowered
		if = {
			limit = { has_idea = spirit_of_democracy }
			remove_ideas = spirit_of_democracy
		}
		if = {
			limit = { has_idea = fascism_will }
			remove_ideas = fascism_will
		}
		if = {
			limit = { has_idea = authoritarian_spirit }
			remove_ideas = authoritarian_spirit
		}
		
		clr_country_flag = ROOT.on_going_elections
		hidden_effect = {
			clear_variable = ROOT.d_lose
			clear_variable = ROOT.c_lose
			clear_variable = ROOT.f_lose
			clear_variable = ROOT.n_lose
		}
	}
	option = {
		name = erevents.4.c
		trigger = {
			AND = {
				check_variable = { party_popularity@fascism > party_popularity@communism }
				check_variable = { party_popularity@fascism > party_popularity@democratic }
				check_variable = { party_popularity@fascism > party_popularity@neutrality }
			}
		}
		ai_chance = {
			base = 5
		}
		set_politics = { ruling_party = fascism elections_allowed = no }
		add_ideas = fascism_will
		if = {
			limit = { has_idea = spirit_of_democracy }
			remove_ideas = spirit_of_democracy
		}
		if = {
			limit = { has_idea = communism_empowered }
			remove_ideas = communism_empowered
		}
		if = {
			limit = { has_idea = authoritarian_spirit }
			remove_ideas = authoritarian_spirit
		}
		
		clr_country_flag = ROOT.on_going_elections
		hidden_effect = {
			clear_variable = ROOT.d_lose
			clear_variable = ROOT.c_lose
			clear_variable = ROOT.f_lose
			clear_variable = ROOT.n_lose
		}
	}
	option = {
		name = erevents.4.d
		trigger = {
			AND = {
				check_variable = { party_popularity@neutrality > party_popularity@communism }
				check_variable = { party_popularity@neutrality > party_popularity@democratic }
				check_variable = { party_popularity@neutrality > party_popularity@fascism }
			}
		}
		ai_chance = {
			base = 5
		}
		set_politics = { ruling_party = neutrality elections_allowed = no }
		add_ideas = authoritarian_spirit
		if = {
			limit = { has_idea = spirit_of_democracy }
			remove_ideas = spirit_of_democracy
		}
		if = {
			limit = { has_idea = communism_empowered }
			remove_ideas = communism_empowered
		}
		if = {
			limit = { has_idea = fascism_will }
			remove_ideas = fascism_will
		}
		
		clr_country_flag = ROOT.on_going_elections
		hidden_effect = {
			clear_variable = ROOT.d_lose
			clear_variable = ROOT.c_lose
			clear_variable = ROOT.f_lose
			clear_variable = ROOT.n_lose
		}
	}
	option = {
		name = erevents.4.e
		trigger = {
			always = yes
			#OR = {
			#	AND = {
			#		has_government = democratic
			#		OR = {
			#			party_popularity@democratic < party_popularity@communism
			#			party_popularity@democratic < party_popularity@fascism
			#			party_popularity@democratic < party_popularity@neutrality
			#		}
			#	}
			#	AND = {
			#		has_government = communism
			#		OR = {
			#			party_popularity@communism < party_popularity@democratic
			#			party_popularity@communism < party_popularity@fascism
			#			party_popularity@communism < party_popularity@neutrality
			#		}
			#	}
			#	AND = {
			#		has_government = fascism
			#		OR = {
			#			party_popularity@fascism < party_popularity@communism
			#			party_popularity@fascism < party_popularity@democratic
			#			party_popularity@fascism < party_popularity@neutrality
			#		}
			#	}
			#	AND = {
			#		has_government = neutrality
			#		OR = {
			#			party_popularity@neutrality < party_popularity@communism
			#			party_popularity@neutrality < party_popularity@fascism
			#			party_popularity@neutrality < party_popularity@democratic
			#		}
			#	}
			#}
		}
		ai_chance = {
			base = 2
			modifier = {
				has_government = democratic
				add = -4
			}
			modifier = {
				has_stability > 0.6
				add = 2
			}
			modifier = {
				has_stability < 0.6
				add = -2
			}
			modifier = {
				party_popularity@ruling_party > 0.5
				add = 2
			}
			modifier = {
				party_popularity@ruling_party < 0.5
				add = -2
			}
		}
		
		clr_country_flag = ROOT.on_going_elections
		add_stability = -0.1
		
		custom_effect_tooltip = tt_cheat_election
		
		hidden_effect = {
		
		random_list = {
			25 = { }
			75 = {
				country_event = { id = erevents.8 days = 1 }
			}
		}
	  }
	}
	#option = {
	#	name = erevents.4.f
	#	trigger = {
	#		OR = {
	#			AND = {
	#				has_government = democratic
	#				OR = {
	#					party_popularity@democratic > party_popularity@communism
	#					party_popularity@democratic > party_popularity@fascism
	#					party_popularity@democratic > party_popularity@neutrality
	#				}
	#			}
	#			AND = {
	#				has_government = communism
	#				OR = {
	#					party_popularity@communism > party_popularity@democratic
	#					party_popularity@communism > party_popularity@fascism
	#					party_popularity@communism > party_popularity@neutrality
	#				}
	#			}
	#			AND = {
	#				has_government = fascism
	#				OR = {
	#					party_popularity@fascism > party_popularity@communism
	#					party_popularity@fascism > party_popularity@democratic
	#					party_popularity@fascism > party_popularity@neutrality
	#				}
	#			}
	#			AND = {
	#				has_government = neutrality
	#				OR = {
	#					party_popularity@neutrality > party_popularity@communism
	#					party_popularity@neutrality > party_popularity@fascism
	#					party_popularity@neutrality > party_popularity@democratic
	#				}
	#			}
	#		}
	#	}
	#	ai_chance = {
	#		base = -1
	#	}
	#}
}

#Elections: We are at war!
country_event = {
	id = erevents.5
	title = erevents.5.t
	desc = erevents.5.desc

	picture = elections_we_are_at_war-730
	is_triggered_only = yes
	timeout_days = 7
	option = {
		name = erevents.5.a
		trigger = {
			
		}
		ai_chance = {
			base = 1
			#check stability
			modifier = {
				has_stability < 0.40
				add = -2
			}
			#check party popularity
			modifier = {
				party_popularity@ruling_party > 0.45
				add = 1
			}
		}
		
		add_stability = -0.05
		country_event = { id = erevents.1 days = 1 }
		
		hidden_effect = {
			
		}
	}
	option = {
		name = erevents.5.b
		trigger = {
			
		}
		ai_chance = {
			base = 1
			#check stability
			modifier = {
				has_stability < 0.40
				add = 1
			}
			#check party popularity
			modifier = {
				party_popularity@ruling_party > 0.45
				add = -1
			}
		}
		
		add_stability = 0.05
		add_political_power = 20
		add_popularity = {
			ideology = communism
			popularity = 0.05
		}
		add_popularity = {
			ideology = fascism
			popularity = 0.05
		}
		
		hidden_effect = {
			
		}
	}
}

#Elections: Government contested
country_event = {
	id = erevents.6
	title = erevents.6.t
	desc = erevents.6.desc

	picture = elections_government_contested-572
	is_triggered_only = yes
	option = {
		name = erevents.6.a
		trigger = {
			
		}
		ai_chance = {
			base = 1
			#check stability
			modifier = {
				has_stability < 0.45
				add = 2
			}
			#check party popularity
			modifier = {
				party_popularity@ruling_party > 0.45
				add = 0
			}
			#check political power
			modifier = {
				political_power < 30
				add = 0
			}
		}
		
		add_political_power = -50
		add_stability = -0.05
		
		hidden_effect = {
			
		}
	}
	option = {
		name = erevents.6.b
		trigger = {
			
		}
		ai_chance = {
			base = 2
			#check stability
			modifier = {
				has_stability < 0.45
				add = 2
			}
			#check party popularity
			modifier = {
				party_popularity@ruling_party > 0.45
				add = 2
			}
			#check political power
			modifier = {
				political_power < 30
				add = 2
			}
		}
		
		add_political_power = 25
		add_stability = 0.05
		add_popularity = {
			ideology = communism
			popularity = 0.07
		}
		add_popularity = {
			ideology = fascism
			popularity = 0.07
		}
		add_popularity = {
			ideology = neutrality
			popularity = 0.07
		}
		country_event = { id = erevents.1 days = 1 }
		
		hidden_effect = {
			
		}
	}
}

#Elections - Cheating on results
country_event = {
	id = erevents.8
	title = erevents.8.t
	desc = erevents.8.desc

	picture = electionscheatingonresults-529
	is_triggered_only = yes
	option = {
		name = erevents.8.a
		trigger = {
			
		}
		ai_chance = {
			base = 0
			modifier = {
				has_government = democratic
				add = 4
			}
			modifier = {
				has_stability > 0.6
				add = 2
			}
		}
		
		if = {
			limit = {
				AND = {
					check_variable = { party_popularity@communism > party_popularity@democratic }
					check_variable = { party_popularity@communism > party_popularity@fascism }
					check_variable = { party_popularity@communism > party_popularity@neutrality }
				}
			}
			set_politics = {
				ruling_party = communism
				elections_allowed = no
			}
		}
		if = {
			limit = {
				AND = {
					check_variable = { party_popularity@democratic > party_popularity@communism }
					check_variable = { party_popularity@democratic > party_popularity@fascism }
					check_variable = { party_popularity@democratic > party_popularity@neutrality }
				}
			}
			set_politics = {
				ruling_party = democratic
				elections_allowed = no
			}
		}
		if = {
			limit = {
				AND = {
					check_variable = { party_popularity@neutrality > party_popularity@democratic }
					check_variable = { party_popularity@neutrality > party_popularity@fascism }
					check_variable = { party_popularity@neutrality > party_popularity@communism }
				}
			}
			set_politics = {
				ruling_party = neutrality
				elections_allowed = no
			}
		}
		if = {
			limit = {
				AND = {
					check_variable = { party_popularity@fascism > party_popularity@democratic }
					check_variable = { party_popularity@fascism > party_popularity@communism }
					check_variable = { party_popularity@fascism > party_popularity@neutrality }
				}
			}
			set_politics = {
				ruling_party = fascism
				elections_allowed = no
			}
		}
		
		hidden_effect = {
			
		}
	}
	option = {
		name = erevents.8.b
		trigger = {
			
		}
		ai_chance = {
			base = 2
			modifier = {
				has_government = democratic
				add = -4
			}
			modifier = {
				has_stability < 0.55
				add = -2
			}
			modifier = {
				check_variable = { party_popularity@ruling_party > 0.55 }
				add = 1
			}
		}
		
		random_list = {
			20 = { }
			40 = {
				country_event = { id = partiesinfluence.12 }
			}
			40 = {
				country_event = { id = partiesinfluence.13 }
			}
		}
		
		hidden_effect = {
			
		}
	}
}

#Allow mod be only on player's country
country_event = {
	id = erevents.7
	title = erevents.7.t
	desc = erevents.7.desc
	is_triggered_only = yes
	option = {
		name = erevents.7.a
		trigger = {
			
		}
		
		set_global_flag = mod_global
		
		hidden_effect = {
			
		}
	}
	option = {
		name = erevents.7.b
		trigger = {
			
		}
		
		set_global_flag = mod_local
		
		hidden_effect = {
			
		}
	}
}
