namespace = peasants_war

# Peasants' War
country_event = {
	id = peasants_war.1
	title = "EVTNAME3021"
	desc = "EVTDESC3021"
	picture = ANGRY_MOB_eventPicture
	
	major = yes

	trigger = {
		num_of_cities = 5
		NOT = { has_country_flag = religious_turmoil } 
		NOT = { has_country_flag = peasant_war }
		NOT = { has_country_flag = internal_conflicts }
		NOT = { has_country_flag = FRA_french_revolution }
		NOT = { has_country_flag = revolution }
		NOT = { has_country_flag = liberalism }
		NOT = { has_country_flag = civil_war } 
		NOT = { has_country_flag = total_war_series } 
		government = monarchy
		NOT = { manpower_percentage = 0.25 }
		NOT = { is_year = 1600 }
		is_at_war = no
		OR = {
			war_exhaustion = 10
			overextension_percentage = 0.25
			NOT = { legitimacy = 75 }
			num_of_loans = 10
		}
		OR = {
			NOT = { has_country_flag = had_peasant_war }
			had_country_flag = { flag = had_peasant_war days = 3650 }
		}
	}

	mean_time_to_happen = {
		months = 640
		modifier = {
			factor = 10
			luck = yes
		}
		modifier = {
			factor = 0.85
			religion = catholic
			NOT = { has_opinion = { who = PAP value = 0 } }
		}
		modifier = {
			factor = 0.75
			religion = catholic
			NOT = { has_opinion = { who = PAP value = -100 } }
		}
		modifier = {
			factor = 1.15
			religion = catholic
			has_opinion = { who = PAP value = 0 }
		}
		modifier = {
			factor = 1.25
			religion = catholic
			has_opinion = { who = PAP value = 100 }
		}
		modifier = {
			factor = 0.9
			NOT = { stability = 0 }
		}
		modifier = {
			factor = 0.9
			NOT = { stability = -1 }
		}
		modifier = {
			factor = 0.9
			NOT = { stability = -2 }
		}
		modifier = {
			factor = 1.1
			stability = 1
		}
		modifier = {
			factor = 1.1
			stability = 2
		}
		modifier = {
			factor = 1.1
			stability = 3
		}
	}

	immediate = {
		set_country_flag = peasant_war
		clr_country_flag = had_peasant_war
	}
	
	option = {
		name = "EVTOPTA3021"			# Dire times are ahead of us
		add_stability = -6
		add_prestige = -10
	}
}

# Peasant protests
country_event = {
	id = peasants_war.2
	title = "EVTNAME3022"
	desc = "EVTDESC3022"
	picture = ANGRY_MOB_eventPicture

	trigger = {
		has_country_flag = peasant_war
		NOT = { has_country_flag = peasant_protests }
	}

	mean_time_to_happen = {
		months = 28
		modifier = {
			factor = 0.95
			revolt_percentage = 0.1
		}
		modifier = {
			factor = 0.85
			revolt_percentage = 0.3
		}
		modifier = {
			factor = 0.75
			revolt_percentage = 0.5
		}
		modifier = {
			factor = 1.05
			stability = 1
		}
		modifier = {
			factor = 1.05
			stability = 2
		}
		modifier = {
			factor = 1.05
			stability = 3
		}
		modifier = {
			factor = 0.95
			NOT = { stability = 0 }
		}
		modifier = {
			factor = 0.95
			NOT = { stability = -1 }
		}
		modifier = {
			factor = 0.95
			NOT = { stability = -2 }
		}
	}

	immediate = {
		set_country_flag = peasant_protests
	}

	option = {
		name = "EVTOPTA3022"			# Enforce serfdom
		ai_chance = { factor = 65 }
		random_owned_province = { 
			anti_tax_rebels = 1 
		}
		capital_scope = { 
			anti_tax_rebels = 2
		}		
		add_country_modifier = {
			name = "enforce_serfdom"
			duration = -1
			desc = "END_OF_PEASANTS_WAR"
		}
	}
	option = {
		name = "EVTOPTB3022"			# Restrict serfdom
		ai_chance = { factor = 35 }
		add_legitimacy = -15
		add_country_modifier = {
			name = "restrict_serfdom"
			duration = -1
			desc = "END_OF_PEASANTS_WAR"
		}
	}
}

# Religious revolt
country_event = {
	id = peasants_war.3
	title = "EVTNAME3023"
	desc = "EVTDESC3023"
	picture = ANGRY_MOB_eventPicture

	trigger = {
		has_country_flag = peasant_war
		NOT = { has_country_flag = religious_revolt }
		religion = catholic
		is_religion_enabled = protestant		
		NOT = { religious_unity = 1.0 }
	}

	mean_time_to_happen = {
		months = 32
		modifier = {
			factor = 0.9
			has_opinion = { who = PAP value = 100 }
		}
		modifier = {
			factor = 0.8
			has_opinion = { who = PAP value = 150 }
		}
		modifier = {
			factor = 1.1
			NOT = { has_opinion = { who = PAP value = -100 } }		
		}
		modifier = {
			factor = 1.2
			NOT = { has_opinion = { who = PAP value = -150 } }		
		}
	}
	
	immediate = {
		set_country_flag = religious_revolt
	}

	option = {
		name = "EVTOPTA3023" # Crush the rebels!
		ai_chance = { factor = 60 }		
		random_owned_province = { 
			spawn_rebels = {
				type = religious_rebels
				size = 1
			}
		}
		add_mil_power = -50
		add_country_modifier = {
			name = "religious_intolerance"
			duration = -1
			desc = "END_OF_PEASANTS_WAR"
		}
	}
	option = {
		name = "EVTOPTB3023" # Let them chose their own faith
		ai_chance = { factor = 40 }
		add_dip_power = -50
		reverse_add_opinion = { who = PAP modifier = opinion_pope_religious_tolerance }
		add_papal_influence = -10
		add_country_modifier = {
			name = "religious_tolerance"
			duration = -1
			desc = "END_OF_PEASANTS_WAR"
		}
	}
}

# Obsolete forces
country_event = {
	id = peasants_war.4
	title = "EVTNAME3024"
	desc = "EVTDESC3024"
	picture = BATTLE_eventPicture

	trigger = {
		has_country_flag = peasant_war
		NOT = { has_country_flag = obsolete_forces }
	}

	mean_time_to_happen = {
		months = 34
		modifier = {
			factor = 0.9
			revolt_percentage = 0.2
		}
		modifier = {
			factor = 0.9
			revolt_percentage = 0.3
		}
		modifier = {
			factor = 0.9
			revolt_percentage = 0.4
		}
		modifier = {
			factor = 0.9
			NOT = { stability = -1 }
		}
		modifier = {
			factor = 0.9
			NOT = { stability = -2 }
		}
		modifier = {
			factor = 1.1
			adm = 4
		}
		modifier = {
			factor = 1.1
			adm = 5
		}
	}
	
	immediate = {
		set_country_flag = obsolete_forces
	}

	option = {
		name = "EVTOPTA3024"			# They have no place in our society
		ai_chance = { factor = 50 }
		add_country_modifier = {
			name = "obsolete_forces"
			duration = -1
			desc = "END_OF_PEASANTS_WAR"
		}
	}
	option = {
		name = "EVTOPTB3024"			# They may still be of some use
		ai_chance = { factor = 50 }
		add_years_of_income = -1.0
		add_country_modifier = {
			name = "support_troops"
			duration = -1
			desc = "END_OF_PEASANTS_WAR"
		}
	}
}

# National decentralisation
country_event = {
	id = peasants_war.5
	title = "EVTNAME3025"
	desc = "EVTDESC3025"
	picture = ANGRY_MOB_eventPicture

	trigger = {
		has_country_flag = peasant_war
		NOT = { has_country_modifier = isolate_rebels }
	}

	mean_time_to_happen = {
		months = 12
		modifier = {
			factor = 0.9
			NOT = { economic_ideas = 1 }
		}
		modifier = {
			factor = 0.9
			NOT = { stability = 0 }
		}
		modifier = {
			factor = 0.9
			NOT = { stability = -1 }
		}
		modifier = {
			factor = 0.9
			NOT = { stability = -2 }
		}
		modifier = {
			factor = 1.1
			stability = 1
		}
		modifier = {
			factor = 1.1
			stability = 2
		}
		modifier = {
			factor = 1.1
			stability = 3
		}
	}

	option = {
		name = "EVTOPTA3025"			# Crush the rebels
		ai_chance = { factor = 55 }
		random_owned_province = {
			limit = { is_core = ROOT }
			anti_tax_rebels = 3
		}
		add_country_modifier = {
			name = "isolate_rebels"
			duration = 720
		}
	}
	option = {
		name = "EVTOPTB3025"			# We have to negotiate a solution
		trigger = {
			stability = 0
		}
		ai_chance = { factor = 40 }	
		add_years_of_income = -1.0
		add_prestige = -50
		set_country_flag = peasants_war_can_end
		country_event = { id = peasants_war.6 days = 1 }
	}
}

# Order is returning
country_event = {
	id = peasants_war.6
	title = "EVTNAME3026"
	desc = "EVTDESC3026"
	picture = ANGRY_MOB_eventPicture
	
	major = yes

	trigger = {
		has_country_flag = peasant_war
		OR = {
			AND = {
				had_country_flag = { flag = peasant_war days = 1000 }
				NOT = { num_of_revolts = 1 }
				stability = 1
			}
			has_country_flag = peasants_war_can_end
		}
	}

	mean_time_to_happen = {
		months = 72
		modifier = {
			factor = 0.9
			mil = 2
		}
		modifier = {
			factor = 0.8
			mil = 3
		}
		modifier = {
			factor = 0.9
			adm = 2
		}	
		modifier = {
			factor = 0.8
			adm = 3
		}
		modifier = {
			factor = 0.5
			stability = 1
		}
		modifier = {
			factor = 0.5
			stability = 2
		}
		modifier = {
			factor = 0.5
			stability = 3
		}
		modifier = {
			factor = 1.1
			NOT = { stability = 0 }
		}
		modifier = {
			factor = 1.1
			NOT = { stability = -1 }
		}
		modifier = {
			factor = 1.1
			NOT = { stability = -2 }
		}
		modifier = {
			factor = 0.8
			had_country_flag = { flag = peasant_war days = 1825 } # 5 years
		}
		modifier = {
			factor = 0.8
			had_country_flag = { flag = peasant_war days = 3650 } # 10 years
		}
		modifier = {
			factor = 0.8
			had_country_flag = { flag = peasant_war days = 5475 } # 15 years
		}
	}

	option = {
		name = "EVTOPTA3026"			# Restore order
		add_legitimacy = 10
		add_prestige = 20
		
		clr_country_flag = peasant_war
		clr_country_flag = peasant_protests
		clr_country_flag = religious_revolt
		clr_country_flag = obsolete_forces
		clr_country_flag = peasants_war_can_end
		
		remove_country_modifier = enforce_serfdom	
		remove_country_modifier = restrict_serfdom
		remove_country_modifier = religious_intolerance
		remove_country_modifier = religious_tolerance
		remove_country_modifier = support_troops
		remove_country_modifier = obsolete_forces
		remove_country_modifier = isolate_rebels
		
		set_country_flag = had_peasant_war
	}
}
