########################################
# Events for Art of War patch
#
# written by Rufus Tronde
########################################

namespace = aow_events

# The Plight of [Province]
province_event = {
	id = aow_events.1
	title = "aow_events.1.t"
	desc = "aow_events.1.d"
	picture = FAMINE_eventPicture
	goto = root
	
	is_mtth_scaled_to_size = 1

	trigger = {
		is_looted = yes
		owner = { is_at_war = yes }
		NOT = { has_province_modifier = famine_refused_aid }
	}

	mean_time_to_happen = {
		months = 240
		modifier = {
			factor = 1.5
			owner = {
				any_owned_province = {
					has_province_modifier = famine_refused_aid
				}
			}
		}
	}

	# Send aid
	option = {
		name = "aow_events.1.a"
		owner = { add_years_of_income = -0.1 }
	}

	# Refuse aid
	option = {
		name = "aow_events.1.b"
		add_province_modifier = {
			name = "famine_refused_aid"
			duration = 3650
		}
	}
}

# Removed for now
## Skirting the Borders
#country_event = {
#	id = aow_events.2
#	title = "aow_events.2.t"
#	desc = "aow_events.2.d"
#	picture = SIEGE_eventPicture
#
#	trigger = {
#		is_at_war = yes
#		any_known_country = {
#			war_with = ROOT
#			any_owned_province = {
#				sieged_by = ROOT
#				any_neighbor_province = {
#					owner = {
#						NOT = { war_with = ROOT }
#						NOT = { tag = ROOT }
#					}
#				}
#			}
#		}
#	}
#
#	mean_time_to_happen = {
#		months = 480
#	}
#
#	# Raid neighboring province
#	option = {
#		name = "aow_events.2.a"
#		random_province = {
#			limit = {
#				sieged_by = ROOT
#				owner = { war_with = ROOT }
#				any_neighbor_province = {
#					owner = {
#						NOT = { war_with = ROOT }
#						NOT = { tag = ROOT }
#					}
#				}
#			}
#			change_siege = 2
#			random_neighbor_province = {
#				limit = {
#					owner = {
#						NOT = { war_with = ROOT }
#						NOT = { tag = ROOT }
#					}
#				}
#				province_event = {
#					id = aow_events.3
#					days = 1
#					tooltip = "aow_events.2.a.tt"
#				}
#			}
#		}
#	}
#
#	# Keep the conflicts between the warring parties
#	option = {
#		name = "aow_events.2.b"
#		random_province = {
#			limit = {
#				sieged_by = ROOT
#				owner = { war_with = ROOT }
#				any_neighbor_province = {
#					owner = {
#						NOT = { war_with = ROOT }
#					}
#				}
#			}
#			change_siege = -1
#		}
#	}
#}
#
## [From] Assaulting our Borders
#province_event = {
#	id = aow_events.3
#	title = "aow_events.3.t"
#	desc = "aow_events.3.d"
#	picture = BORDER_TENSION_eventPicture
#
#	is_triggered_only = yes
#
#	# Object to their violation of our territory
#	option = {
#		name = "aow_events.3.a"
#		add_province_modifier = {
#			name = "plundered_in_war"
#			duration = 1095
#		}
#		owner = {
#			add_opinion = {
#				who = FROM
#				modifier = violated_territory
#			}
#			add_casus_belli = {
#				target = FROM
#				type = cb_insult
#				months = 12
#			}
#		}
#	}
#
#	# Ignore it
#	option = {
#		name = "aow_events.3.b"
#		add_province_modifier = {
#			name = "plundered_in_war"
#			duration = 1095
#		}
#		owner = { add_prestige = -10 }
#	}
#}

# Resistance
#province_event = {
#	id = aow_events.4
#	title = "aow_events.4.t"
#	desc = "aow_events.4.d"
#	picture = ANGRY_MOB_eventPicture
#
#	trigger = {
#		owner = {
#			is_at_war = yes
#		}
#		culture = owner
#		NOT = { controlled_by = owner }
#		NOT = { controlled_by = REB }
#	}
#
#	mean_time_to_happen = {
#		months = 1200
#	}
#
#	# Long live the resistance!
#	option = {
#		name = "aow_events.4.a"
#		owner = { add_years_of_income = -0.4 }
#		spawn_rebels = {
#			type = nationalist_rebels
#			size = 2
#			friend = ROOT
#		}
#	}
#
#	# Join the main forces instead
#	option = {
#		name = "aow_events.4.b"
#		owner = { add_manpower = 3 }
#	}
#}

# Plague at the Siege of [Province] [Defender]
#province_event = {
#	id = aow_events.5
#	title = "aow_events.5.t"
#	desc = "aow_events.5.d"
#	picture = SIEGE_eventPicture
#
#	trigger = {
#		has_siege = yes
#		NOT = { sieged_by = ROOT }
#		NOT = { sieged_by = REB }
#		NOT = { has_province_modifier = plague_at_siege }
#	}
#
#	mean_time_to_happen = {
#		months = 480
#	}
#
#	immediate = {
#		hidden_effect = {
#			random_known_country = {
#				limit = {
#					ROOT = { sieged_by = PREV }
#				}
#				country_event = { id = aow_events.6 days = 1 }
#				# Followup events for attacker
#				country_event = { id = aow_events.7 days = 160 }
#				country_event = { id = aow_events.10 days = 160 }
#			}
#			add_province_modifier = {
#				name = "plague_at_siege"
#				duration = 170
#			}
#			# Followup events for defender
#			owner = { country_event = { id = aow_events.8 days = 160 } }
#			province_event = { id = aow_events.9 days = 160 }
#		}
#	}
#
#	# Evacuate
#	option = {
#		name = "aow_events.5.a"
#		custom_tooltip = aow_events.5.a.tt
#		add_province_modifier = {
#			name = "defender_evacuated_siege"
#			duration = 170
#			hidden = yes
#		}
#	}
#
#	# Don't evacuate
#	option = {
#		name = "aow_events.5.b"
#		custom_tooltip = "aow_events.5.b.tt"
#	}
#}


## Plague at the Siege of [Province] [Attacker]
#country_event = {
#	id = aow_events.6
#	title = "aow_events.6.t"
#	desc = "aow_events.6.d"
#	picture = SIEGE_eventPicture
#
#	is_triggered_only = yes
#
#	# Evacuate
#	option = {
#		name = "aow_events.6.a"
#		custom_tooltip = aow_events.5.a.tt
#		FROM = {
#			add_province_modifier = {
#				name = "attacker_evacuated_siege"
#				duration = 170
#				hidden = yes
#			}
#		}
#	}
#
#	# Don't evacuate
#	option = {
#		name = "aow_events.6.b"
#		custom_tooltip = "aow_events.6.b.tt"
#	}
#}

# [Defender] Evacuate Siege
#country_event = {
#	id = aow_events.7
#	title = "aow_events.7.t"
#	desc = "aow_events.7.d"
#	picture = SIEGE_eventPicture
#
#	is_triggered_only = yes
#
#	trigger = {
#		FROM = {
#			has_province_modifier = defender_evacuated_siege
#			NOT = { has_province_modifier = attacker_evacuated_siege }
#		}
#	}
#
#	# Their walls will crumble!
#	option = {
#		name = "aow_events.7.a"
#		FROM = { change_siege = 10 }
#	}
#}

# Attackers Evacuate Siege
#country_event = {
#	id = aow_events.8
#	title = "aow_events.8.t"
#	desc = "aow_events.8.d"
#	picture = SIEGE_eventPicture
#
#	is_triggered_only = yes
#
#	trigger = {
#		FROM = {
#			has_province_modifier = attacker_evacuated_siege
#			NOT = { has_province_modifier = defender_evacuated_siege }
#		}
#	}
#
#	# Their forces will perish!
#	option = {
#		name = "aow_events.8.a"
#		FROM = { change_siege = -10 }
#	}
#}


# Plague Grows Worse [Defender]
#province_event = {
#	id = aow_events.9
#	title = "aow_events.9.t"
#	desc = "aow_events.9.d"
#	picture = PLAGUE_eventPicture
#
#	is_triggered_only = yes
#
#	trigger = {
#		NOT = { has_province_modifier = defender_evacuated_siege }
#		NOT = { has_province_modifier = attacker_evacuated_siege }
#	}
#
#	# We are both fools
#	option = {
#		name = "aow_events.9.a"
#		remove_province_modifier = plague_at_siege
#		add_province_modifier = {
#			name = "lingering_plague"
#			duration = 1095
#		}
#	}
#}

# Plague Grows Worse [Attacker]
#country_event = {
#	id = aow_events.10
#	title = "aow_events.10.t"
#	desc = "aow_events.10.d"
#	picture = PLAGUE_eventPicture
#
#	is_triggered_only = yes
#
#	trigger = {
#		FROM = {
#			NOT = { has_province_modifier = defender_evacuated_siege }
#			NOT = { has_province_modifier = attacker_evacuated_siege }
#		}
#	}
#
#	# We are both fools
#	option = {
#		name = "aow_events.9.a"
#		FROM = {
#			custom_tooltip = "aow_events.10.a.tt"
#		}
#	}
#}

# Spread of Pestilence
province_event = {
	id = aow_events.11
	title = "aow_events.11.t"
	desc = "aow_events.11.d"
	picture = PLAGUE_eventPicture
	goto = root

	trigger = {
		any_neighbor_province = {
			has_province_modifier = lingering_plague
		}
		owner = { is_at_war = yes }
	}

	mean_time_to_happen = {
		months = 100
	}

	# Curse this war...
	option = {
		name = "aow_events.11.a"
		add_province_modifier = {
			name = "lingering_plague"
			duration = 1095
		}
	}
}

# Cruelty of Mercenaries
country_event = {
	id = aow_events.12
	title = "aow_events.12.t"
	desc = "aow_events.12.d"
	picture = BORDER_TENSION_eventPicture
	goto = war_province

	trigger = {
		is_at_war = yes
		NOT = { has_country_flag = disable_cruelty_of_mercs }
		num_of_hired_mercenary_companies = 1
		NOT = { has_country_modifier = curtailed_mercenaries }
		any_hired_mercenary_company = {
			location = {
				NOT = { owned_by = root }
				owner = {
					war_with = ROOT
				}
				area_for_scope_province = {
					owned_by = prev
					controlled_by = root
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 240
	}

	immediate = {
		hidden_effect = {
			random_hired_mercenary_company = {
				limit = {
					location = {
						NOT = { owned_by = root }
						owner = {
							war_with = ROOT
						}
						area_for_scope_province = {
							owned_by = prev
							controlled_by = root
						}
					}
				}
				save_event_target_as = hired_mercenary_band
				location = {
					save_event_target_as = war_province
				}
			}
		}
	}

	# Rein them in
	option = {
		name = "aow_events.12.a"
		PA_random_army_exp_between_2_and_10_effect = yes    #PA: replaced flat gain with random dynamic gain. -- 200e200w
		add_country_modifier = {
			name = "curtailed_mercenaries"
			duration = 1825
		}
	}

	# Bellum se ipsum alet
	option = {
		name = "aow_events.12.b"
		add_prestige = -10
		event_target:war_province = {
			hidden_effect = {
				random = {
					chance = 25
					province_event = { id = aow_events.13 days = 30 }
				}
			}
			area = {
				limit = {
					controlled_by = ROOT
					NOT = { owned_by = ROOT }
				}
				add_province_modifier = {
					name = "terrorized_by_mercenaries"
					duration = 1095
				}
			}
		}
	}
}

# Mercenary Bands Raid [Province]
province_event = {
	id = aow_events.13
	title = "aow_events.13.t"
	desc = "aow_events.13.d"
	picture = BORDER_TENSION_eventPicture
	goto = root

	trigger = {
		area_for_scope_province = {
			owned_by = root
			controlled_by = from
			has_province_modifier = terrorized_by_mercenaries
			NOT = { has_province_modifier = plundered_in_war }
		}
	}

	is_triggered_only = yes

	# Greed corrupts men's hearts...
	option = {
		name = "aow_events.13.a"
		area = {
			limit = {
				NOT = { controlled_by = ROOT }
				owned_by = ROOT
			}
			add_province_modifier = {
				name = "plundered_in_war"
				duration = 1095
			}
		}
	}
}

# Displaced Refugees from [Province]
province_event = {
	id = aow_events.14
	title = "aow_events.14.t"
	desc = "aow_events.14.d"
	picture = FAMINE_eventPicture
	goto = root

	trigger = {
		OR = {
			has_province_modifier = lingering_plague
			has_province_modifier = plundered_in_war
			has_province_modifier = famine_refused_aid
		}
		base_tax = 2
		owner = {
			is_at_war = no
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	# The war may be over, but our troubles are not.
	option = {
		name = "aow_events.14.a"
		add_base_tax = -1
		random_neighbor_province = {
			limit = { owned_by = ROOT }
			add_base_tax = 1
		}
	}
}

# The Families Left Behind
country_event = {
	id = aow_events.15
	title = "aow_events.15.t"
	desc = "aow_events.15.d"
	picture = FARMING_eventPicture

	trigger = {
		NOT = { manpower_percentage = 0.1 }
		had_recent_war = 3
		is_at_war = no
		NOT = { has_country_modifier = post_war_tax_relief }
		NOT = { has_country_modifier = decreased_drafting }
		NOT = { has_country_modifier = suffering_bereaved }
	}

	mean_time_to_happen = {
		months = 240
	}

	# We can ease the tax burden on the bereaved.
	option = {
		name = "aow_events.15.a"
		add_country_modifier = {
			name = "post_war_tax_relief"
			duration = 1825
		}
	}

	# Let us be more lenient drafting for the army in the future.
	option = {
		name = "aow_events.15.b"
		add_country_modifier = {
			name = "decreased_drafting"
			duration = 1825
		}
	}

	# This is the price that must be paid for our glorious nation.
	option = {
		name = "aow_events.15.c"
		add_country_modifier = {
			name = "suffering_bereaved"
			duration = 1825
		}
	}
}

# Witchcraft
province_event = {
	id = aow_events.16
	title = "aow_events.16.t"
	desc = "aow_events.16.d"
	picture = ANGRY_MOB_eventPicture
	goto = root

	trigger = {
		OR = {
			has_province_modifier = lingering_plague
			has_province_modifier = plundered_in_war
			has_province_modifier = famine_refused_aid
		}
		NOT = { has_province_modifier = local_witch_hunts }
		owner = {
			is_at_war = no
			religion_group = christian
			NOT = { has_country_modifier = forbade_witch_hunts }
			NOT = { has_country_modifier = nationwide_witch_hunts }
		}
	}

	mean_time_to_happen = {
		months = 480
		modifier = {
			factor = 0.75
			owner = {
				government = theocracy
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				current_age = age_of_discovery
				current_age = age_of_reformation
			}
		}
		modifier = {
			factor = 2
			current_age = age_of_revolutions
		}
	}

	# Allow them to proceed with the local trials.
	option = {
		name = "aow_events.16.a"
		add_province_modifier = {
			name = "local_witch_hunts"
			duration = 3650
		}
		hidden_effect = {
			province_event = { id = aow_events.17 days = 1080 random = 4800 }
			province_event = { id = aow_events.18 days = 1080 random = 4800 }
		}
	}

	# [Inquisitor] can see to these matters in a more organized fashion.
	option = {
		name = "aow_events.16.b"
		trigger = {
			owner = { advisor = inquisitor }
		}
		owner = {
			add_country_modifier = {
				name = "nationwide_witch_hunts"
				duration = 3650
			}
		}
	}

	# Such foolish superstitions have no place in [Country]!
	option = {
		name = "aow_events.16.c"
		owner = {
			add_country_modifier = {
				name = "forbade_witch_hunts"
				duration = 3650
			}
		}
	}
}

# Witch-hunt
province_event = {
	id = aow_events.17
	title = "aow_events.17.t"
	desc = "aow_events.17.d"
	picture = ANGRY_MOB_eventPicture
	goto = root

	trigger = {
		has_province_modifier = local_witch_hunts
		owner = {
			is_at_war = no
		}
	}

	is_triggered_only = yes

	# Cease this madness!
	option = {
		name = "aow_events.17.a"
		owner = { add_adm_power = -80 }
		remove_province_modifier = local_witch_hunts
	}

	# Intervene on behalf of the nobles.
	option = {
		name = "aow_events.17.b"
		spawn_rebels = {
			type = anti_tax_rebels
			size = 1
		}
	}

	# Intervene on behalf of the commoners.
	option = {
		name = "aow_events.17.c"
		spawn_rebels = {
			type = noble_rebels
			size = 1
		}
	}

	# Let them exact justice as they see fit.
	option = {
		name = "aow_events.17.e"
		trigger = {
			is_capital = no
			NOT = { local_autonomy = 80 }
		}
		add_local_autonomy = 25
	}
}

# A Witch from Foreign Lands
province_event = {
	id = aow_events.18
	title = "aow_events.18.t"
	desc = "aow_events.18.d"
	picture = ANGRY_MOB_eventPicture
	goto = root

	trigger = {
		has_province_modifier = local_witch_hunts
		owner = {
			is_at_war = no
			any_neighbor_country = {
				any_owned_province = {
					NOT = {
						province_distance = {
							who = root
							distance = 150
						}
					}
				}
			}
		}
	}

	immediate = {
		hidden_effect = {
			owner = {
				random_neighbor_country = {
					limit = {
						any_owned_province = {
							NOT = {
								province_distance = {
									who = root
									distance = 120
								}
							}
						}
					}
					save_event_target_as = they_send_us_witches
				}
			}
		}
	}

	is_triggered_only = yes

	# This fear of the unfamiliar must be stopped.
	option = {
		name = "aow_events.18.a"
		owner = { add_adm_power = -50 }
	}

	# Witches, spies, who know what they're up to?
	option = {
		name = "aow_events.18.b"
		event_target:they_send_us_witches = {
			add_opinion = {
				who = PREV
				modifier = accused_compatriot_of_witchcraft
			}
		}
	}
}

# A Highly Troubling Accusation
country_event = {
	id = aow_events.19
	title = "aow_events.19.t"
	desc = "aow_events.19.d"
	picture = ACCUSATION_eventPicture

	trigger = {
		has_country_modifier = nationwide_witch_hunts
		advisor = inquisitor
		OR = {
			advisor = statesman
			advisor = trader
			advisor = spymaster
			advisor = diplomat
		}
	}

	mean_time_to_happen = {
		months = 240
	}

	# Thou shalt not suffer a witch to live.
	option = {
		name = "aow_events.19.a"
		kill_advisor = statesman
		kill_advisor = trader
		kill_advisor = spymaster
		kill_advisor = diplomat
	}

	# Thou shalt not bear false witness against thy neighbor.
	option = {
		name = "aow_events.19.b"
		kill_advisor = inquisitor
		remove_country_modifier = nationwide_witch_hunts
	}
}

# The Fires of Hell
country_event = {
	id = aow_events.20
	title = "aow_events.20.t"
	desc = "aow_events.20.d"
	picture = RELIGIOUS_TURMOIL_eventPicture

	trigger = {
		has_country_modifier = nationwide_witch_hunts
		advisor = inquisitor
		heir_age = 6
		NOT = { heir_age = 16 }
	}

	mean_time_to_happen = {
		months = 240
	}

	# The child is right. We have been blinded by our zeal.
	option = {
		name = "aow_events.20.a"
		remove_advisor = inquisitor
		remove_country_modifier = nationwide_witch_hunts
		add_dip_power = 100
	}

	# Hush child, and hope no one heard that...
	option = {
		name = "aow_events.20.b"
		add_adm_power = 100
		add_heir_claim = -10
	}
}

# Unknown Shooter
country_event = {
	id = aow_events.21
	title = "aow_events.21.t"
	desc = "aow_events.21.d"
	picture = ASSASSINATION_eventPicture

	trigger = {
		war_exhaustion = 10
		war_score = 10
		is_lesser_in_union = no
		is_monarch_leader = yes
		any_army = {
			is_ruler_commanding_unit = yes
		}
		is_at_war = yes
		any_known_country = {
			defensive_war_with = ROOT
		}
		# Check that the nation has infantry guns at all
		mil_tech = 9
	}

	mean_time_to_happen = {
		months = 240
		modifier = {
			factor = 0.75
			war_exhaustion = 15
		}
	}

	# We may never know.
	option = {
		name = "aow_events.21.a"
		kill_ruler = yes
		add_war_exhaustion = -5
	}
}

# A Change of Character
country_event = {
	id = aow_events.22
	title = "aow_events.22.t"
	desc = "aow_events.22.d"
	picture = DIPLOMACY_eventPicture

	trigger = {
		war_exhaustion = 8
		is_at_war = no
		mil = 2
		NOT = { dip = 6 }
		advisor = diplomat
	}

	mean_time_to_happen = {
		months = 240
		modifier = {
			factor = 0.75
			war_exhaustion = 15
		}
	}

	# You are right, [Country] needs peace.
	option = {
		name = "aow_events.22.a"
		change_dip = 1
		change_mil = -1
	}

	# Forsake the spirit that called me to war? Ridiculous.
	option = {
		name = "aow_events.22.b"
		remove_advisor = diplomat
		add_dip_power = -50
	}
}

# The Faithful in Enemy Lands
country_event = {
	id = aow_events.23
	title = "aow_events.23.t"
	desc = "aow_events.23.d"
	picture = SIEGE_eventPicture
	goto = war_province

	trigger = {
		is_at_war = yes
		any_known_country = {
			war_with = ROOT
			any_owned_province = {
				sieged_by = ROOT
				religion = ROOT
				NOT = { religion = owner }
				religion_group = owner
				NOT = { is_religious_center_province = yes }
				NOT = { has_province_modifier = religious_center}
			}
		}
	}
	immediate = {
		hidden_effect = {
			random_province = {
				limit = {
					sieged_by = ROOT
					religion = ROOT
					NOT = { religion = owner }
					religion_group = owner
					NOT = { is_religious_center_province = yes }
					NOT = { has_province_modifier = religious_center}
				}
				save_event_target_as = war_province
			}
		}
	}

	mean_time_to_happen = {
		months = 400
	}

	# Spare the faithful
	option = {
		name = "aow_events.23.a"
		event_target:war_province = {
			change_siege = -2
		}
	}

	# No mercy for enemies of [Country]!
	option = {
		name = "aow_events.23.b"
		event_target:war_province = {
			tooltip = {
				change_religion = owner
			}
			province_event = {
				id = aow_events.24
				days = 1
			}
		}
	}
}

# [Province] Betrayed by Brothers in Faith
province_event = {
	id = aow_events.24
	title = "aow_events.24.t"
	desc = "aow_events.24.d"
	picture = BORDER_TENSION_eventPicture
	goto = root

	is_triggered_only = yes

	# We will show them the [Religion] faith has more integrity than that.
	option = {
		name = "aow_events.24.a"
		change_religion = owner
	}
}


# Unbelievers in [Province] Waver
province_event = {
	id = aow_events.25
	title = "aow_events.25.t"
	desc = "aow_events.25.d"
	picture = RELIGIOUS_TURMOIL_eventPicture
	goto = root

	trigger = {
		owner = {
			is_at_war = yes
		}
		NOT = { controlled_by = owner }
		NOT = { controlled_by = REB }
		NOT = { religion = owner }
		NOT = { is_core = controller }
		religion = controller
	}

	mean_time_to_happen = {
		months = 640
		modifier = {
			factor = 1.5
			tolerance_to_this = 0
		}
		modifier = {
			factor = 2.0
			tolerance_to_this = 1
		}
	}

	# We will reward loyalty with respect.
	option = {
		name = "aow_events.25.a"
		trigger = { is_capital = no }
		add_local_autonomy = 30
	}

	# We will not accept disloyalty.
	option = {
		name = "aow_events.25.b"
		tooltip = { add_core = controller }
		controller = {
			country_event = {
				id = aow_events.26
				days = 1
			}
		}
	}
}

# [Religion] Defectors
country_event = {
	id = aow_events.26
	title = "aow_events.26.t"
	desc = "aow_events.26.d"
	picture = RELIGIOUS_CONVERSION_eventPicture
	goto = from

	is_triggered_only = yes

	# We may be able to accommodate them...
	option = {
		name = "aow_events.26.a"
		FROM = { add_core = controller }
	}
}

# [Religion] of [Province] Betray Us!
province_event = {
	id = aow_events.27
	title = "aow_events.27.t"
	desc = "aow_events.27.d"
	picture = RELIGIOUS_TURMOIL_eventPicture
	goto = root
	
	is_mtth_scaled_to_size = 1

	trigger = {
		NOT = { religion = owner }
		controlled_by = owner
		NOT = { tolerance_to_this = 0 }
		owner = {
			is_at_war = yes
			any_known_country = {
				war_with = PREV
				religion = ROOT
			}
		}
		
	}

	mean_time_to_happen = {
		months = 800
	}

	# Faith determines the path of all, even the wicked.
	option = {
		name = "aow_events.27.a"
		spawn_rebels = {
			type = religious_rebels
			size = 2
		}
	}
}

# Struggle Without, Struggle Within
province_event = {
	id = aow_events.28
	title = "aow_events.28.t"
	desc = "aow_events.28.d"
	picture = RELIGIOUS_TURMOIL_eventPicture
	goto = root
	
	is_mtth_scaled_to_size = 1

	trigger = {
		NOT = { religion = owner }
		controlled_by = owner
		owner = {
			is_at_war = yes
			any_known_country = {
				war_with = PREV
				religion = ROOT
			}
		}
		
		NOT = { is_religious_center_province = yes }
		NOT = { has_province_modifier = religious_center }
		any_neighbor_province = {
			owned_by = ROOT
			religion = owner
			is_reformation_center = no
			NOT = { is_religious_center_province = yes }
			NOT = { has_province_modifier = religious_center }
		}
	}

	mean_time_to_happen = {
		months = 800
	}

	immediate = {
		hidden_effect = {
			random_neighbor_province = {
				limit = {
					owned_by = ROOT
					religion = owner
					is_reformation_center = no
					NOT = { is_religious_center_province = yes }
					NOT = { has_province_modifier = religious_center }
				}
				save_event_target_as = neighbour_province
			}
		}
	}

	# Like the war, this conflict must take its course.
	option = {
		name = "aow_events.28.a"
		goto = neighbour_province
		owner = { add_manpower = -4 }
		random_list = {
			75 = { change_religion = owner }
			25 = {
				event_target:neighbour_province = {
					change_religion = ROOT
				}
			}
		}
	}

	# Unite against the true enemy! You are all [subject nationality here]!
	option = {
		name = "aow_events.28.b"
		owner = { add_dip_power = -50 }
	}
}

# Country Before Faith
province_event = {
	id = aow_events.29
	title = "aow_events.29.t"
	desc = "aow_events.29.d"
	picture = SPY_eventPicture
	
	is_mtth_scaled_to_size = 1

	trigger = {
		owner = {
			any_rival_country = {
				religion = ROOT
			}
			NOT = { has_country_modifier = loyal_unbelievers }
			NOT = { has_country_modifier = disloyal_unbelievers }
		}
		NOT = { religion = owner }
	}

	mean_time_to_happen = {
		months = 1600
	}

	# We will trust them to remain loyal to us.
	option = {
		name = "aow_events.29.a"
		random_list = {
			75 = {
				owner = {
					add_country_modifier = {
						name = "loyal_unbelievers"
						duration = 1825
					}
				}
			}
			25 = {
				owner = {
					add_country_modifier = {
						name = "disloyal_unbelievers"
						duration = 1825
					}
				}
			}
		}
	}

	# There is no need for such underhanded tactics... or risks.
	option = {
		name = "aow_events.29.b"
		owner = { add_prestige = 10 }
	}
}

# Warriors of the [Religion] Faith
province_event = {
	id = aow_events.30
	title = "aow_events.30.t"
	desc = "aow_events.30.d"
	picture = ANGRY_MOB_eventPicture
	goto = root
	
	is_mtth_scaled_to_size = 1

	trigger = {
		religion = owner
		NOT = { religion = confucianism }
		NOT = { religion = buddhism }
		NOT = { religion = mahayana }
		has_siege = no
		controlled_by = owner
		any_neighbor_province = {
			owner = {
				offensive_war_with = ROOT
				NOT = { religion = ROOT }
			}
			religion = owner
			controlled_by = owner
		}
	}

	mean_time_to_happen = {
		months = 1000
	}

	# Forward, sentinels of the truth!
	option = {
		name = "aow_events.30.a"
		infantry = ROOT
		infantry = ROOT
		infantry = ROOT
		infantry = ROOT
	}
}

# Early Reformers
country_event = {
	id = aow_events.31
	title = "aow_events.31.t"
	desc = "aow_events.31.d"
	picture = RELIGIOUS_CONVERSION_eventPicture

	trigger = {
		any_owned_province = {
			is_reformation_center = yes
		}
		religion_group = christian
		any_neighbor_country = {
			NOT = {
				has_opinion_modifier = {
					who = ROOT
					modifier = reformation_pioneers
				}
			}
			religion = ROOT
			any_owned_province = {
				is_reformation_center = yes
				religion = ROOT
			}
		}
		NOT = { religion_years = { protestant = 50 } }
	}

	mean_time_to_happen = {
		months = 300
	}

	# Together we will spread God's true message!
	option = {
		name = "aow_events.31.a"
		random_neighbor_country = {
			limit = {
				NOT = {
					has_opinion_modifier = {
						who = ROOT
						modifier = reformation_pioneers
					}
				}
				religion = ROOT
				any_owned_province = {
					is_reformation_center = yes
					religion = ROOT
				}
			}
			add_opinion = {
				who = ROOT
				modifier = reformation_pioneers
			}
		}
	}

	# The [Country] Church stands alone.
	option = {
		name = "aow_events.31.b"
		add_prestige = 15
	}
}

# Neither [Religion] nor Catholic
country_event = {
	id = aow_events.32
	title = "aow_events.32.t"
	desc = "aow_events.32.d"
	picture = RELIGIOUS_CONVERSION_eventPicture

	trigger = {
		OR = {
			religion = protestant
			religion = reformed
			religion = anglican
			religion = hussite
		}
		any_owned_province = {
			is_reformation_center = yes
		}
		any_neighbor_country = {
			OR = {
				religion = protestant
				religion = reformed
				religion = anglican
				religion = hussite
			}
			NOT = { religion = ROOT }
			any_owned_province = {
				is_reformation_center = yes
				NOT = { religion = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 240
	}

	# We will stand with them against the Pope, if they stand with us.
	option = {
		name = "aow_events.32.a"
		random_neighbor_country = {
			limit = {
				OR = {
					religion = protestant
					religion = reformed
					religion = anglican
					religion = hussite
				}
				NOT = { religion = ROOT }
				any_owned_province = {
					is_reformation_center = yes
					NOT = { religion = ROOT }
				}
			}
			country_event = { id = aow_events.33 days = 30 }
		}
	}

	# They spread lies, merely different lies.
	option = {
		name = "aow_events.32.b"
		random_neighbor_country = {
			limit = {
				OR = {
					religion = protestant
					religion = reformed
					religion = anglican
					religion = hussite
				}
				NOT = { religion = ROOT }
				any_owned_province = {
					is_reformation_center = yes
					NOT = { religion = ROOT }
				}
			}
			add_opinion = {
				who = ROOT
				modifier = renounced_as_heretics
			}
		}
	}
}


# [From.Religion] Neighbors Reach Out
country_event = {
	id = aow_events.33
	title = "aow_events.33.t"
	desc = "aow_events.33.d"
	picture = RELIGION_eventPicture

	is_triggered_only = yes

	# Together, we can return Christianity to what it was meant to be.
	option = {
		name = "aow_events.33.a"
		add_prestige = 10
		add_opinion = {
			who = FROM
			modifier = reformation_pioneers
		}
		FROM = {
			country_event = { id = aow_events.34 days = 30 }
		}
	}

	# The last thing we need is theological confusion in our own ranks.
	option = {
		name = "aow_events.33.b"
		add_adm_power = 20
		add_opinion = {
			who = FROM
			modifier = renounced_as_heretics
		}
		FROM = {
			country_event = { id = aow_events.35 days = 30 }
		}
	}
}

# [From.Religion] Neighbors Accept
country_event = {
	id = aow_events.34
	title = "aow_events.34.t"
	desc = "aow_events.34.d"
	picture = RELIGION_eventPicture

	is_triggered_only = yes

	# The pious of [Root.GetName] and [From.GetName] will remember this day.
	option = {
		name = "aow_events.34.a"
		add_prestige = 10
		add_opinion = {
			who = FROM
			modifier = reformation_pioneers
		}
	}
}

# [From.Religion] Neighbors Reject Our Charity
country_event = {
	id = aow_events.35
	title = "aow_events.35.t"
	desc = "aow_events.35.d"
	picture = RELIGION_eventPicture

	is_triggered_only = yes

	# Do they not know to love their neighbor as themselves?
	option = {
		name = "aow_events.35.a"
		add_prestige = -15
	}
}

# Heretics Encroach On Our Land
country_event = {
	id = aow_events.36
	title = "aow_events.36.t"
	desc = "aow_events.36.d"
	picture = RELIGION_eventPicture

	trigger = {
		has_country_modifier = counter_reformation
		religion = catholic
		any_neighbor_country = {
			OR = {
				religion = protestant
				religion = reformed
				religion = anglican
				religion = hussite
			}
			any_owned_province = {
				is_reformation_center = yes
			}
		}
		any_owned_province = {
			OR = {
				religion = protestant
				religion = reformed
				religion = anglican
				religion = hussite
			}
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	# No, we can see all too well what must be done.
	option = {
		name = "aow_events.36.a"
		random_neighbor_country = {
			limit = {
				OR = {
					religion = protestant
					religion = reformed
					religion = anglican
				}
				any_owned_province = {
					is_reformation_center = yes
				}
			}
			reverse_add_casus_belli = {
				target = ROOT
				type = cb_border_war
				months = 24
			}
		}
	}

	# We can certainly pretend to.
	option = {
		name = "aow_events.36.b"
		add_prestige = -10
		add_dip_power = 50
	}
}

# The Cause of the Protestant Plague
country_event = {
	id = aow_events.37
	title = "aow_events.37.t"
	desc = "aow_events.37.d"
	picture = RELIGIOUS_TURMOIL_eventPicture

	trigger = {
		has_spawned_rebels = protestant_rebels
		religion = catholic
		any_neighbor_country = {
			religion = protestant
			any_owned_province = {
				is_reformation_center = yes
			}
		}
	}

	mean_time_to_happen = {
		months = 240
	}

	# They better have an answer for us!
	option = {
		name = "aow_events.37.a"
		random_neighbor_country = {
			limit = {
				religion = protestant
				any_owned_province = {
					is_reformation_center = yes
				}
			}
			country_event = { id = aow_events.39 days = 30 }
		}
	}

	# Let us not stir up more trouble over this.
	option = {
		name = "aow_events.37.b"
		add_prestige = -10
	}
}

# The Cause of the Calvinist Plague
country_event = {
	id = aow_events.38
	title = "aow_events.38.t"
	desc = "aow_events.38.d"
	picture = RELIGIOUS_TURMOIL_eventPicture

	trigger = {
		has_spawned_rebels = reformed_rebels
		religion = catholic
		any_neighbor_country = {
			religion = reformed
			any_owned_province = {
				is_reformation_center = yes
			}
		}
	}

	mean_time_to_happen = {
		months = 240
	}

	# They better have an answer for us!
	option = {
		name = "aow_events.38.a"
		random_neighbor_country = {
			limit = {
				religion = reformed
				any_owned_province = {
					is_reformation_center = yes
				}
			}
			country_event = { id = aow_events.39 days = 30 }
		}
	}

	# Let us not stir up more trouble over this.
	option = {
		name = "aow_events.38.b"
		add_prestige = -10
	}
}

# [From.GetName] Confronts Us About Rebels
country_event = {
	id = aow_events.39
	title = "aow_events.39.t"
	desc = "aow_events.39.d"
	picture = DIPLOMACY_eventPicture

	is_triggered_only = yes

	# Cuius regio, eius religio. They should respect the will of their rulers.
	option = {
		name = "aow_events.39.a"
		add_opinion = {
			who = FROM
			modifier = renounced_heretic_rebels
		}
		add_country_modifier = {
			name = "abadoned_religious_rebels"
			duration = 1825
		}
		FROM = {
			country_event = { id = aow_events.40 days = 30 }
		}
	}

	# We demand that you cease your oppression of these poor [Root.Religion.GetName] subjects!
	option = {
		name = "aow_events.39.b"
		add_prestige = 15
		add_opinion = {
			who = FROM
			modifier = defended_heretic_rebels
		}
		FROM = {
			country_event = { id = aow_events.41 days = 30 }
		}
	}

	# We will support the faithful against you, openly and gladly!
	option = {
		name = "aow_events.39.c"
		add_years_of_income = -0.2
		add_opinion = {
			who = FROM
			modifier = roused_heretic_rebels
		}
		FROM = {
			country_event = { id = aow_events.42 days = 30 }
		}
	}
}

# [From.GetName] Renounce [From.Religion.GetName] Rebels
country_event = {
	id = aow_events.40
	title = "aow_events.40.t"
	desc = "aow_events.40.d"
	picture = RELIGIOUS_CONVERSION_eventPicture

	is_triggered_only = yes

	# Let us hope this is not duplicitous talk.
	option = {
		name = "aow_events.40.a"
		add_prestige = 15
	}
}

# [From.GetName] Defend [From.Religion.GetName] Rebels
country_event = {
	id = aow_events.41
	title = "aow_events.41.t"
	desc = "aow_events.41.d"
	picture = RELIGIOUS_TURMOIL_eventPicture

	is_triggered_only = yes

	# 
	option = {
		name = "aow_events.41.a"
		add_prestige = -10
	}
}

# [From.GetName] Fund [From.Religion.GetName] Rebels!
country_event = {
	id = aow_events.42
	title = "aow_events.42.t"
	desc = "aow_events.42.d"
	picture = RELIGIOUS_TURMOIL_eventPicture

	is_triggered_only = yes

	# There can be no absolution for those who persist in sin.
	option = {
		name = "aow_events.42.a"
		if = {
			limit = {
				FROM = { religion = protestant }
			}
			random_owned_province = {
				limit = { likely_rebels = protestant_rebels }
				create_revolt = 2
			}
		}
		if = {
			limit = {
				FROM = { religion = reformed }
			}
			random_owned_province = {
				limit = { likely_rebels = reformed_rebels }
				create_revolt = 2
			}
		}
		add_casus_belli = {
			target = FROM
			type = cb_insult
			months = 12
		}
	}
}

# Cardinal Events

# Cardinal Across the Border
country_event = {
	id = aow_events.43
	title = "aow_events.43.t"
	desc = "aow_events.43.d"
	picture = RELIGION_eventPicture
	goto = receive_cardinal_province

	trigger = {
		papacy_active = yes
		religion = catholic
		NOT = { tag = PAP }
		NOT = { num_of_cardinals = 7 }
		any_owned_province = {
			development = 10
			has_cardinal = no
			religion = catholic
			any_neighbor_province = {
				has_cardinal = yes
				NOT = { owned_by = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 480
		modifier = {
			factor = 1.2
			num_of_cardinals = 5
		}
	}

	immediate = {
		check_if_non_state_advisor_effect = { #Hidden, must be followed by erase_advisor_flags_effect
			chance_of_primary = 75 #Not percentages!
			chance_of_tertiary = 5
			chance_of_secondary = 25
		}
		hidden_effect = {
			random_owned_province = {
				limit = {
					has_cardinal = no
					religion = catholic
					development = 10
					any_neighbor_province = {
						has_cardinal = yes
						NOT = { owned_by = ROOT }
					}
				}
				save_event_target_as = receive_cardinal_province
				random_neighbor_province = {
					limit = {
						has_cardinal = yes
						NOT = { owned_by = ROOT }
					}
					save_event_target_as = send_cardinal_province
				}
			}
		}
	}
	
	# 
	option = {
		name = "aow_events.43.a"
		add_years_of_income = -0.05
		add_corruption = 0.5
		event_target:receive_cardinal_province = {
			add_cardinal = yes
		}
		event_target:send_cardinal_province = {
			remove_cardinal = yes
			random = {
				chance = 50
				hidden_effect = {
					province_event = {
						id = aow_events.44
						days = 7
					}
				}
				owner = {
					tooltip = {
						add_casus_belli = {
							target = ROOT
							type = cb_insult
							months = 32
						}
						add_opinion = {
							who = ROOT
							modifier = bribed_cardinal
						}
					}
				}
			}
		}
	}

	option = {
		name = "aow_events.43.b"
		generate_advisor_of_type_and_semi_random_religion_effect = {
			advisor_type=spymaster
			advisor_type_if_not_state=spymaster
			scaled_skill = yes
			discount=yes
		}
	}
	after = {
		erase_advisor_flags_effect = yes
	}
}

# Cardinal Bribed to Move
province_event = {
	id = aow_events.44
	title = "aow_events.44.t"
	desc = "aow_events.44.d"
	picture = CORRUPTION_eventPicture
	goto = root

	is_triggered_only = yes

	# 
	option = {
		name = "aow_events.44.a"
		owner = {
			add_casus_belli = {
				target = FROM
				type = cb_insult
				months = 32
			}
			add_corruption = 1
			add_opinion = {
				who = FROM
				modifier = bribed_cardinal
			}
		}
	}
}

# Thoughts of Heresy
province_event = {
	id = aow_events.45
	title = "aow_events.45.t"
	desc = "aow_events.45.d"
	picture = PRAYING_eventPicture
	goto = root

	trigger = {
		has_cardinal = yes
		any_neighbor_province = {
			NOT = { religion = catholic }
			religion_group = christian
		}
	}

	is_mtth_scaled_to_size = 1
	
	mean_time_to_happen = {
		months = 480
	}

	# 
	option = {
		name = "aow_events.45.a"
		owner = {
			add_years_of_income = -0.1
		}
			random = {
				chance = 40
				province_event = {
					id = aow_events.46
					days = 180
					tooltip = "aow_events.45.a.tt"
				}
			}

	}

	option = {
		name = "aow_events.45.b"
		remove_cardinal = yes
	}
}

# Pope Discovers Duplicity
province_event = {
	id = aow_events.46
	title = "aow_events.46.t"
	desc = "aow_events.46.d"
	picture = POPE_PREACHING_eventPicture
	goto = root

	is_triggered_only = yes

	trigger = {
		exists = PAP
	}

	# 
	option = {
		name = "aow_events.46.a"
		PAP = {
			add_opinion = {
				who = ROOT
				modifier = bribed_cardinal
			}
		}
	}
}

# Cardinal Distrusts Heathens
province_event = {
	id = aow_events.47
	title = "aow_events.47.t"
	desc = "aow_events.47.d"
	picture = RELIGIOUS_TURMOIL_eventPicture
	goto = root

	trigger = {
		has_cardinal = yes
		any_neighbor_province = {
			NOT = { religion_group = christian }
			owned_by = root
		}
		NOT = { owner = { has_country_modifier = distrusts_heathens } }
	}

	mean_time_to_happen = {
		months = 480
	}

	# 
	option = {
		name = "aow_events.47.a"
		owner = {
			add_country_modifier = {
				name = "distrusts_heathens"
				duration = 1825
			}
		}
	}

	option = {
		name = "aow_events.47.b"
		remove_cardinal = yes
	}
}

# Contacts in the Holy See
country_event = {
	id = aow_events.48
	title = "aow_events.48.t"
	desc = "aow_events.48.d"
	picture = RELIGION_eventPicture

	trigger = {
		papacy_active = yes
		religion = catholic
		NOT = { tag = PAP }
		OR = {
			employed_advisor = {
				type = theologian
				religion = catholic
			}
			employed_advisor = {
				type = inquisitor
				religion = catholic
			}
		}
		NOT = { num_of_cardinals = 7 }
		NOT = { total_number_of_cardinals = 49 }
		any_owned_province = {
			development = 10
			continent = europe
			has_cardinal = no
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	# 
	option = {
		name = "aow_events.48.a"
		add_adm_power = -100
		random_owned_province = {
			limit = {
				development = 10
				continent = europe
				religion = catholic
				has_cardinal = no
			}
			add_cardinal = yes
		}
	}

	option = {
		name = "aow_events.48.b"
		add_adm_power = 100
	}
}

# Cardinal Minister
country_event = {
	id = aow_events.49
	title = "aow_events.49.t"
	desc = "aow_events.49.d"
	picture = ADVISOR_eventPicture

	trigger = {
		NOT = { has_country_modifier = cardinal_in_administration }
		num_of_cardinals = 1
	}

	mean_time_to_happen = {
		months = 480
	}

	# 
	option = {
		name = "aow_events.49.a"
		if = {
			limit = {
				has_estate = estate_church
				NOT = {
					has_estate_influence_modifier = {
						estate = estate_church
						modifier = EST_VAL_CARDINAL_IN_ADMINISTRATION
					}
				}
			}
			add_estate_influence_modifier = {
				estate = estate_church
				desc = EST_VAL_CARDINAL_IN_ADMINISTRATION
				influence = 5
				duration = 7300
			}
		}
		add_country_modifier = {
			name = "cardinal_in_administration"
			duration = 7300
		}
	}

	option = {
		name = "aow_events.49.b"
		add_prestige = 10
	}
}

# Cardinal's Policies Upset Nobles
country_event = {
	id = aow_events.50
	title = "aow_events.50.t"
	desc = "aow_events.50.d"
	picture = REFORM_eventPicture

	trigger = {
		has_country_modifier = cardinal_in_administration
		NOT = { has_country_modifier = centralization_modifier }
		num_of_cardinals = 1
		capital_scope = {
			any_neighbor_province = {
				owned_by = ROOT
			}
		}
	}

	mean_time_to_happen = {
		months = 1200
	}

	immediate = {
		hidden_effect = {
			random_owned_province = {
				limit = {
					any_neighbor_province = {
						is_capital = yes
						owned_by = ROOT
					}
				}
				save_event_target_as = rebel_province
			}
			random_owned_province = {
				limit = { has_cardinal = yes }
				save_event_target_as = cardinal_province
			}
		}
	}

	# 
	option = {
		name = "aow_events.50.a"
		goto = rebel_province
		add_country_modifier = {
			name = "centralization_modifier"
			duration = 3650
		}
		event_target:rebel_province = {
			spawn_rebels = {
				type = noble_rebels
				size = 2
			}
		}
	}

	#
	option = {
		name = "aow_events.50.b"
		goto = cardinal_province
		remove_country_modifier = cardinal_in_administration
		event_target:cardinal_province = {
			remove_cardinal = yes
		}
	}
}

# Cardinal Sins
country_event = {
	id = aow_events.51
	title = "aow_events.51.t"
	desc = "aow_events.51.d"
	picture = SPY_eventPicture

	trigger = {
		has_idea_group = spy_ideas
		religion = catholic
		any_neighbor_country = {
			num_of_cardinals = 1
		}
		NOT = { has_country_modifier = blackmailing_cardinal }
	}

	mean_time_to_happen = {
		months = 1200
	}

	# 
	option = {
		name = "aow_events.51.a"
		random_neighbor_country = {
			limit = { num_of_cardinals = 1 }
			random_owned_province = {
				limit = { has_cardinal = yes }
				hidden_effect = {
					province_event = {
						id = aow_events.52
						days = 1
					}
				}
				tooltip = {
					remove_cardinal = yes
				}
			}
			add_opinion = {
				who = ROOT
				modifier = exposed_cardinal
			}
		}
	}

	#
	option = {
		name = "aow_events.51.b"
		add_corruption = 0.5
		add_country_modifier = {
			name = "blackmailing_cardinal"
			duration = 1825
		}
	}
}

# Cardinal Exposed
province_event = {
	id = aow_events.52
	title = "aow_events.52.t"
	desc = "aow_events.52.d"
	picture = ACCUSATION_eventPicture
	goto = root

	is_triggered_only = yes

	option = {
		name = "aow_events.52.a"
		remove_cardinal = yes
	}
}