add_namespace = pssystem

#-1
country_event = {
	id = pssystem.10
	title = pssystem.10.t
	desc = pssystem.10.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.10"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_sank_minus_one = yes
		NOT = {
			has_idea = PS_high_ps
		}
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.10"
		#hidden_effect = {
			add_ideas = PS_opposition_rises
			set_variable = { ROOT.opposition_rises_done = 1 }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.10.a
		# log = "option:		name = pssystem.10.a"
	}
}

#-2
country_event = {
	id = pssystem.32
	title = pssystem.32.t
	desc = pssystem.32.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.32"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_sank_minus_two = yes
		has_idea = PS_opposition_rises
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.32"
		#hidden_effect = {
			add_ideas = PS_riots_in_the_streets
			set_variable = { ROOT.riots_in_the_streets_done = 1 }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.32.a
		# log = "option:		name = pssystem.32.a"
	}
}

#-3
country_event = {
	id = pssystem.1
	title = pssystem.1.t
	desc = pssystem.1.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.1"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_sank_minus_three = yes
		has_idea = PS_riots_in_the_streets
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.1"
		#hidden_effect = {
			if = {
				limit = {
					has_government = radical_democracy
				}
				add_ideas = PS_big_scale_protests_double
			}
			else_if = {
				limit = {
					has_government = ideology_radical_socialism
				}
				add_ideas = PS_big_scale_protests_single
			}
			else = {
				random_list = {
					50 = {
						modifier = {
							factor = 2
							has_global_flag = eoanb_flag_ps_no_commies_until_allowed
						}
						add_ideas = PS_big_scale_protests_single
					}
					50 = {
						modifier = {
							factor = 0
							has_global_flag = eoanb_flag_ps_no_commies_until_allowed
						}
						add_ideas = PS_big_scale_protests_double
					}
				}
			}
			set_variable = { ROOT.big_scale_protests_done = 1 }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.1.a
		# log = "option:		name = pssystem.1.a"
	}
}

#-4
country_event = {
	id = pssystem.2
	title = pssystem.2.t
	desc = pssystem.2.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.2"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_sank_minus_four = yes
		OR = {
			has_idea = PS_big_scale_protests_single
			has_idea = PS_big_scale_protests_double
		}
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.2"
		#hidden_effect = {
			random_list = {
				50 = {
					modifier = {
						factor = 0
						num_of_controlled_states < 2
					}
					if = {
						limit = {
							has_idea = PS_big_scale_protests_single
						}
						add_ideas = PS_fighting_in_the_streets_single
					}
					else_if = {
						limit = {
							has_idea = PS_big_scale_protests_double
						}
						add_ideas = PS_fighting_in_the_streets_double
					}
					set_variable = { ROOT.fighting_in_the_streets_done = 1 }
				}
				50 = {
					modifier = {
						factor = 2
						num_of_controlled_states < 2
					}
					if = {
						limit = {
							has_idea = PS_big_scale_protests_single
						}
						add_ideas = PS_fighting_in_the_streets_single
					}
					else_if = {
						limit = {
							has_idea = PS_big_scale_protests_double
						}
						add_ideas = PS_fighting_in_the_streets_double
					}
					set_variable = { ROOT.fighting_in_the_streets_done = 1 }
					add_ideas = PS_take_over_identificator
				}
			}
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.2.a
		# log = "option:		name = pssystem.2.a"
	}
}

#-5 demilitarized zone
#country_event = {
#	id = pssystem.31
#	title = pssystem.31.t
#	desc = pssystem.31.d
#	picture = GFX_report_event_wittelsbach_family

	# immediate = {
	# 	# log = "[THIS.GetTag]: firing  = pssystem.31"
	# }
#
#	mean_time_to_happen = {
#		days = 20
#	}
#
#	trigger = {
#		PS_pol_stab_sank_minus_five = yes
#		#has_idea = PS_dem_zone_identificator
#		OR = {
#			has_idea = PS_fighting_in_the_streets_single
#			has_idea = PS_fighting_in_the_streets_double
#		}
#	}
#
#	immediate = {
#		hidden_effect = {
#			random_owned_controlled_state = {
#				set_demilitarized_zone = yes
#			}
#		}
#	}
#
#	option = {
#		ai_chance = { factor = 100 }
#		name = pssystem.31.a
#	}
#}

#-5 take over
country_event = {
	id = pssystem.25
	title = pssystem.25.t
	desc = pssystem.25.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.25"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_sank_minus_five = yes
		has_idea = PS_take_over_identificator
		OR = {
			has_idea = PS_fighting_in_the_streets_single
			has_idea = PS_fighting_in_the_streets_double
		}
		NOT = { has_country_flag = PS_pol_disable_coups }
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.25"
		#hidden_effect = {
			add_ideas = PS_call_for_take_over
			set_variable = { ROOT.call_for_civil_war_done = 1 }

			country_event = { id = pssystem.27 days = 70 }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.25.a
		# log = "option:		name = pssystem.25.a"
	}
}

#takeover proxy
country_event = {
	id = pssystem.27
	title = pssystem.27.t
	desc = pssystem.27.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.27"
	}

	is_triggered_only = yes

	hidden = yes

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.27"
		#hidden_effect = {
			if = {
				limit = {
					has_idea = PS_call_for_take_over
				}
				if = {
					limit = {
						has_idea = PS_fighting_in_the_streets_double
					}
					country_event = { id = pssystem.28 }
				}
				else_if = {
					limit = {
						has_idea = PS_fighting_in_the_streets_single
					}
					country_event = { id = pssystem.29 }
				}
			}
			else = {
				country_event = { id = pssystem.30 }
			}
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.27.a
		# log = "option:		name = pssystem.27.a"
	}
}

#takeover succeed colsoc
country_event = {
	id = pssystem.28
	title = pssystem.28.t
	desc = pssystem.28.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.28"
	}

	is_triggered_only = yes

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.28"
		#hidden_effect = {
			set_politics = {
				ruling_party = ideology_radical_socialism
			}
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.28.a
		# log = "option:		name = pssystem.28.a"
	}
}

#takeover succeed raddem
country_event = {
	id = pssystem.29
	title = pssystem.29.t
	desc = pssystem.29.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.29"
	}

	is_triggered_only = yes

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.29"
		#hidden_effect = {
			set_politics = {
				ruling_party = radical_democracy
			}
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.29.a
		# log = "option:		name = pssystem.29.a"
	}
}

#takeover avoided
country_event = {
	id = pssystem.30
	title = pssystem.30.t
	desc = pssystem.30.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.30"
	}

	is_triggered_only = yes

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.30.a
		# log = "option:		name = pssystem.30.a"
	}
}

#-5 civil war
country_event = {
	id = pssystem.3
	title = pssystem.3.t
	desc = pssystem.3.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.3"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_sank_minus_five = yes
		NOT = {
			has_idea = PS_take_over_identificator
		}
		OR = {
			has_idea = PS_fighting_in_the_streets_single
			has_idea = PS_fighting_in_the_streets_double
		}
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.3"
		#hidden_effect = {
			add_ideas = PS_call_for_civil_war
			set_variable = { ROOT.call_for_civil_war_done = 1 }

			if = {
				limit = {
					has_idea = PS_big_scale_protests_single
				}
				start_civil_war = {
					ideology = radical_democracy
					size = 0.2
				}
			}
			else_if = {
				limit = {
					has_idea = PS_big_scale_protests_double
				}
				start_civil_war = {
					ideology = ideology_radical_socialism
					size = 0.2
				}
				#start_civil_war = {
				#	ideology = radical_democracy
				#	size = 0.2
				#	only_own_territory = no
				#}
			}
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.3.a
		# log = "option:		name = pssystem.3.a"
	}
}

#reverse
#-5 reverse takeover
country_event = {
	id = pssystem.26
	title = pssystem.26.t
	desc = pssystem.26.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.26"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_minus_five = yes
		has_idea = PS_call_for_take_over
		has_idea = PS_take_over_identificator
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.26"
		#hidden_effect = {
			set_variable = { ROOT.call_for_civil_war_done = 0 }
			remove_ideas = { PS_call_for_take_over }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.26.a
		# log = "option:		name = pssystem.26.a"
	}
}

#-5 reverse civil war
country_event = {
	id = pssystem.4
	title = pssystem.4.t
	desc = pssystem.4.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.4"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_minus_five = yes
		has_idea = PS_call_for_civil_war
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.4"
		#hidden_effect = {
			set_variable = { ROOT.call_for_civil_war_done = 0 }
			remove_ideas = { PS_call_for_civil_war }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.4.a
		# log = "option:		name = pssystem.4.a"
	}
}

#-4 reverse
country_event = {
	id = pssystem.5
	title = pssystem.5.t
	desc = pssystem.5.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.5"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_minus_four = yes
		check_variable = { ROOT.call_for_civil_war_done = 0 }
		OR = {
			has_idea = PS_fighting_in_the_streets_single
			has_idea = PS_fighting_in_the_streets_double
		}
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.5"
		#hidden_effect = {
			set_variable = { ROOT.fighting_in_the_streets_done = 0 }
			remove_ideas = { PS_fighting_in_the_streets_single PS_fighting_in_the_streets_double }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.5.a
		# log = "option:		name = pssystem.5.a"
	}
}

#-3 reverse
country_event = {
	id = pssystem.6
	title = pssystem.6.t
	desc = pssystem.6.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.6"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_minus_three = yes
		check_variable = { ROOT.fighting_in_the_streets_done = 0 }
		OR = {
			has_idea = PS_big_scale_protests_single
			has_idea = PS_big_scale_protests_double
		}
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.6"
		#hidden_effect = {
			set_variable = { ROOT.big_scale_protests_done = 0 }
			remove_ideas = { PS_big_scale_protests_single PS_big_scale_protests_double }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.6.a
		# log = "option:		name = pssystem.6.a"
	}
}

#-2 reverse
country_event = {
	id = pssystem.7
	title = pssystem.7.t
	desc = pssystem.7.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.7"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_minus_two = yes
		check_variable = { ROOT.big_scale_protests_done = 0 }
		has_idea = PS_riots_in_the_streets
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.7"
		#hidden_effect = {
			set_variable = { ROOT.riots_in_the_streets_done = 0 }
			remove_ideas = { PS_riots_in_the_streets }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.7.a
		# log = "option:		name = pssystem.7.a"
	}
}

#-1 reverse
country_event = {
	id = pssystem.11
	title = pssystem.11.t
	desc = pssystem.11.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.11"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_minus_one = yes
		check_variable = { ROOT.riots_in_the_streets_done = 0 }
		has_idea = PS_opposition_rises
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.11"
		#hidden_effect = {
			set_variable = { ROOT.opposition_rises_done = 0 }
			remove_ideas = PS_opposition_rises
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.11.a
		# log = "option:		name = pssystem.11.a"
	}
}

#+1
country_event = {
	id = pssystem.8
	title = pssystem.8.t
	desc = pssystem.8.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.8"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_rose_one = yes
		NOT = {
			has_idea = PS_opposition_rises
		}
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.8"
		#hidden_effect = {
			set_variable = { ROOT.ps_high_done = 1 }
			add_ideas = PS_high_ps
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.8.a
		# log = "option:		name = pssystem.8.a"
	}
}

#+2
country_event = {
	id = pssystem.12
	title = pssystem.12.t
	desc = pssystem.12.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.12"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_rose_two = yes
		has_idea = PS_high_ps
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.12"
		#hidden_effect = {
			set_variable = { ROOT.overwhelming_ps_done = 1 }
			add_ideas = PS_overwhelming_ps
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.12.a
		# log = "option:		name = pssystem.12.a"
	}
}

#+3
country_event = {
	id = pssystem.13
	title = pssystem.13.t
	desc = pssystem.13.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.13"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_rose_three = yes
		has_idea = PS_overwhelming_ps
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.13"
		#hidden_effect = {
			set_variable = { ROOT.no_opposition_left_done = 1 }
			add_ideas = PS_no_opposition_left
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.13.a
		# log = "option:		name = pssystem.13.a"
	}
}

#+1 reverse
country_event = {
	id = pssystem.9
	title = pssystem.9.t
	desc = pssystem.9.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.9"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_one = yes
		check_variable = { ROOT.overwhelming_ps_done = 0 }
		has_idea = PS_high_ps
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.9"
		#hidden_effect = {
			set_variable = { ROOT.ps_high_done = 0 }
			remove_ideas = { PS_high_ps }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.9.a
		# log = "option:		name = pssystem.9.a"
	}
}

#+2 reverse
country_event = {
	id = pssystem.14
	title = pssystem.14.t
	desc = pssystem.14.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.14"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_two = yes
		check_variable = { ROOT.no_opposition_left_done = 0 }
		has_idea = PS_overwhelming_ps
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.14"
		#hidden_effect = {
			set_variable = { ROOT.overwhelming_ps_done = 0 }
			remove_ideas = { PS_overwhelming_ps }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.14.a
		# log = "option:		name = pssystem.14.a"
	}
}

#+3 reverse
country_event = {
	id = pssystem.15
	title = pssystem.15.t
	desc = pssystem.15.d
	picture = GFX_report_event_wittelsbach_family

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.15"
	}

	mean_time_to_happen = {
		days = 20
	}

	trigger = {
		PS_pol_stab_was_three = yes
		has_idea = PS_no_opposition_left
	}

	immediate = {
		# log = "[THIS.GetTag]: firing = pssystem.15"
		#hidden_effect = {
			set_variable = { ROOT.no_opposition_left_done = 0 }
			remove_ideas = { PS_no_opposition_left }
		#}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.15.a
		# log = "option:		name = pssystem.15.a"
	}
}

### YEARLY CHANGE ###
#event that calculates how much PS should be added or subtracted
country_event = {
	id = pssystem.16
	title = pssystem.16.t
	desc = pssystem.16.d
	is_triggered_only = yes
	hidden = yes

	immediate = {
		# Initialize stability factor
		set_variable = {
			var = ROOT.pol_stability_yearly_factor
			value = 0
		}

		# AI Historical Focus Balancing
		if = {
			limit = {
				is_ai = yes
				is_historical_focus_on = yes
			}
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 5 
			}
		}
		else_if = {
			limit = { 
				is_ai = yes 
			}
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 3 
			}
		}

		# Border War
		if = {
			limit = {
				has_border_war = yes
			}
			subtract_from_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 1
			}
		}
		else = {
			add_to_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 1
			}
		}
		
		# General War
		if = {
			limit = {
				has_war = yes
			}
			subtract_from_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 1
			}
		}
		else = {
			add_to_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 2
			}
		}
		
		# Civil War
		if = {
			limit = {
				has_civil_war = yes
			}
			subtract_from_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 1
			}
		}
		else = {
			add_to_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 2
			}
		}
		
		# Coup Target
		if = {
			limit = {
				is_target_of_coup = yes
			}
			subtract_from_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 1
			}
		}
		else = {
			add_to_variable = {
				var = ROOT.pol_stability_yearly_factor
				value = 1
			}
		}

		# Popular Stability
		if = {
			limit = { 
				has_stability > 0.8 
			}
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 2 
			}
		}
		else_if = {
			limit = { 
				has_stability > 0.6 
			}
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else_if = {
			limit = { 
				has_stability > 0.4 
			}
			# Between 0.4-0.6 stability doesn't affect factor
		}
		else_if = {
			limit = { 
				has_stability > 0.2 
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else = {
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 2 
			}
		}

		# Party Popularity
		if = {
			limit = { 
				check_variable = { ROOT.party_popularity@ruling_party > 0.8 } 
			}
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 2 
			}
		}
		else_if = {
			limit = { 
				check_variable = { ROOT.party_popularity@ruling_party > 0.6 } 
			}
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else_if = {
			limit = { 
				check_variable = { ROOT.party_popularity@ruling_party > 0.4 } 
			}
			# Party popularity between 0.4-0.6 doesn't affect factor
		}
		else_if = {
			limit = { 
				check_variable = { ROOT.party_popularity@ruling_party > 0.3 } 
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else_if = {
			limit = { 
				check_variable = { ROOT.party_popularity@ruling_party > 0.2 } 
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 2 
			}
		}
		else = {
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 3 
			}
		}

		# Puppet Status
		if = {
			limit = { 
				is_puppet = yes 
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else = {
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		
		# Subject Status
		if = {
			limit = { 
				is_subject = yes 
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else = {
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}

		# Faction Membership
		if = {
			limit = { 
				is_in_faction = yes 
			}
			add_to_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}

		# Accident Count
		if = {
			limit = {
				PS_accident_factor_zero = yes
			}
			# No effect
		}
		else_if = {
			limit = {
				PS_accident_factor_one = yes
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else_if = {
			limit = {
				PS_accident_factor_two = yes
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 1 
			}
		}
		else_if = {
			limit = {
				PS_accident_factor_three = yes
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 2 
			}
		}
		else_if = {
			limit = {
				PS_accident_factor_four = yes
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 2 
			}
		}
		else_if = {
			limit = {
				PS_accident_factor_over_four = yes
			}
			subtract_from_variable = { 
				var = ROOT.pol_stability_yearly_factor 
				value = 3 
			}
		}

		# Military Junta
		if = {
			limit = {
				OR = {
					has_country_flag = MHC_military_junta_army
					has_country_flag = MHC_military_junta_airforce
					has_country_flag = MHC_military_junta_navy
				}
			}
			country_event = { id = pssystem.99 days = 1 }
		}
		# Factor-based event triggering - consolidated into fewer blocks
		else_if = {
			limit = {
				check_variable = { ROOT.pol_stability_yearly_factor > 8 }
			}
			country_event = { id = pssystem.17 days = 1 }
		}
		else_if = {
			limit = {
				check_variable = { ROOT.pol_stability_yearly_factor > 5 }
			}
			country_event = { id = pssystem.18 days = 1 }
		}
		else_if = {
			limit = {
				check_variable = { ROOT.pol_stability_yearly_factor > 2 }
			}
			country_event = { id = pssystem.19 days = 1 }
		}
		else_if = {
			limit = {
				check_variable = { ROOT.pol_stability_yearly_factor > -2 }
			}
			country_event = { id = pssystem.20 days = 1 }
		}
		else_if = {
			limit = {
				check_variable = { ROOT.pol_stability_yearly_factor > -5 }
			}
			country_event = { id = pssystem.21 days = 1 }
		}
		else_if = {
			limit = {
				check_variable = { ROOT.pol_stability_yearly_factor > -8 }
			}
			country_event = { id = pssystem.22 days = 1 }
		}
		else_if = {
			limit = {
				check_variable = { ROOT.pol_stability_yearly_factor > -11 }
			}
			country_event = { id = pssystem.23 days = 1 }
		}
		else = {
			country_event = { id = pssystem.24 days = 1 }
		}
	}

	option = {
		ai_chance = { factor = 100 }
		name = pssystem.16.a
		clear_variable = ROOT.pol_stability_yearly_factor
	}
}

#endpoint nr 1
country_event = {
	id = pssystem.17
	title = pssystem.17.t
	desc = pssystem.17.d
	picture = GFX_report_event_generic_parliament

	is_triggered_only = yes

	#neutral
	option = {
		ai_chance = { factor = 100 }
		name = pssystem.17.a
		# log = "option:		name = pssystem.17.a"

		#hidden_effect = {
			increase_ps_by_two = yes
		#}
	}
}

#endpoint nr 2
country_event = {
	id = pssystem.18
	title = pssystem.17.t
	desc = pssystem.18.d
	picture = GFX_report_event_generic_parliament

	is_triggered_only = yes

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				OR = {
					PS_ideology_neutral = yes
					PS_ideology_offensive = yes
				}
			}
		}
		name = pssystem.18.a
		# log = "option:		name = pssystem.18.a"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				#no effect
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}

	#careful
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				OR = {
					PS_ideology_neutral = yes
					PS_ideology_careful = yes
				}
			}
		}
		name = pssystem.18.b
		# log = "option:		name = pssystem.18.b"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				#no effect
			}
		#}
	}
}

#endpoint nr 3
country_event = {
	id = pssystem.19
	title = pssystem.17.t
	desc = pssystem.19.d
	picture = GFX_report_event_generic_parliament

	is_triggered_only = yes

	#careful
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_careful = yes
			}
		}
		name = pssystem.19.a
		# log = "option:		name = pssystem.19.a"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				OR = {
					PS_ideology_neutral = yes
					PS_ideology_careful = yes
				}
			}
		}
		name = pssystem.19.b
		# log = "option:		name = pssystem.19.b"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}
}

#enpoint nr 4
country_event = {
	id = pssystem.20
	title = pssystem.17.t
	desc = pssystem.20.d

	is_triggered_only = yes

	#neutral
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_neutral = yes
			}
		}
		name = pssystem.20.a
		# log = "option:		name = pssystem.20.a"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#careful
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_careful = yes
			}
		}
		name = pssystem.20.b
		# log = "option:		name = pssystem.20.b"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_offensive = yes
			}
		}
		name = pssystem.20.c
		# log = "option:		name = pssystem.20.c"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}
}

#enpoint nr 5
country_event = {
	id = pssystem.21
	title = pssystem.17.t
	desc = pssystem.21.d

	is_triggered_only = yes

	#neutral
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_neutral = yes
			}
		}
		name = pssystem.21.a
		# log = "option:		name = pssystem.21.a"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_offensive = yes
			}
		}
		name = pssystem.21.b
		# log = "option:		name = pssystem.21.b"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}

	#careful
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_careful = yes
			}
		}
		name = pssystem.21.c
		# log = "option:		name = pssystem.21.c"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}
}

#enpoint nr 6
country_event = {
	id = pssystem.22
	title = pssystem.17.t
	desc = pssystem.22.d

	is_triggered_only = yes

	#neutral
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_neutral = yes
			}
		}
		name = pssystem.22.a
		# log = "option:		name = pssystem.22.a"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#careful
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_careful = yes
			}
		}
		name = pssystem.22.b
		# log = "option:		name = pssystem.22.b"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_offensive = yes
			}
		}
		name = pssystem.22.c
		# log = "option:		name = pssystem.22.c"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}
}

#enpoint nr 7
country_event = {
	id = pssystem.23
	title = pssystem.17.t
	desc = pssystem.23.d

	is_triggered_only = yes

	#neutral
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_neutral = yes
			}
		}
		name = pssystem.23.a
		# log = "option:		name = pssystem.23.a"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#careful
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_careful = yes
			}
		}
		name = pssystem.23.b
		# log = "option:		name = pssystem.23.b"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_offensive = yes
			}
		}
		name = pssystem.23.c
		# log = "option:		name = pssystem.23.c"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_offensive = yes
			}
		}
		name = pssystem.23.e
		# log = "option:		name = pssystem.23.e"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}
}

#enpoint nr 8
country_event = {
	id = pssystem.24
	title = pssystem.17.t
	desc = pssystem.24.d

	is_triggered_only = yes

	#neutral
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_neutral = yes
			}
		}
		name = pssystem.24.a
		# log = "option:		name = pssystem.24.a"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#offensive
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_offensive = yes
			}
		}
		name = pssystem.24.b
		# log = "option:		name = pssystem.24.b"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_two = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
		#}
	}

	#neutral
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_neutral = yes
			}
		}
		name = pssystem.24.c
		# log = "option:		name = pssystem.24.c"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}

	#careful
	option = {
		ai_chance = {
			factor = 40
			modifier = {
				factor = 5
				#is_historical_focus_on = yes
				PS_ideology_careful = yes
			}
		}
		name = pssystem.24.e
		# log = "option:		name = pssystem.24.e"

		custom_effect_tooltip = eoanb_tt_pswarning

		#hidden_effect = {
			#careful ideologies
			if = {
				limit = {
					PS_ideology_careful = yes
				}
				random_list = {
					8 = {
						increase_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 0 }
						}
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability > 1 }
						}
					}
				}
			}
			#neutral ideologies
			else_if = {
				limit = {
					PS_ideology_neutral = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
			#offensive ideologies
			else_if = {
				limit = {
					PS_ideology_offensive = yes
				}
				random_list = {
					8 = {
						modifier = {
							add = -8
							check_variable = { THIS.pol_stability < -3 }
						}
						decrease_ps_by_one = yes
					}
					0 = {
						modifier = {
							add = 1
							check_variable = { THIS.pol_stability < -1 }
						}
						modifier = {
							add = 2
							check_variable = { THIS.pol_stability < -2 }
						}
					}
				}
			}
		#}
	}
}

#junta endpoint
country_event = {
	id = pssystem.99
	title = pssystem.99.t
	desc = pssystem.99.d

	is_triggered_only = yes

	#doesn't matter
	option = {
		ai_chance = {
			factor = 40
		}
		name = pssystem.99.a
		# log = "option:		name = pssystem.99.a"
	}
}
