########################################
# Events for Thirty Years War
#
# written by Rufus Tronde
########################################

namespace = tyw_events

# Reservatum Ecclesiasticum
country_event = {
	id = tyw_events.1
	title = "tyw_events.1.t"
	desc = "tyw_events.1.d"
	picture = PRINCE_BISHOP_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_emperor = yes
		is_at_war = no
		religion = catholic
		has_global_flag = counter_reformation
		hre_leagues_enabled = no
		hre_religion_treaty = no
		any_known_country = {
			is_part_of_hre = yes
			religion = protestant
			has_reform = leading_clergy_reform
		}
	}

	mean_time_to_happen = {
		months = 80
	}

	option = {
		name = "tyw_events.1.a"
		random_known_country = {
			limit = {
				is_part_of_hre = yes
				religion = protestant
				has_reform = leading_clergy_reform
			}
			add_opinion = {
				who = ROOT
				modifier = opinion_forceful_conversion
			}
			country_event = { id = tyw_events.2 days = 7 tooltip = "tyw_events.1.a.tt" }
		}
		every_known_country = {
			limit = {
				is_part_of_hre = yes
				religion = protestant
			}
			add_opinion = {
				who = ROOT
				modifier = enforced_reservatum_ecclesiasticum
			}
		}
	}

	option = {
		name = "tyw_events.1.b"
		add_scaled_imperial_influence = -10
	}
}

# Emperor Demands Resignation
country_event = {
	id = tyw_events.2
	title = "tyw_events.2.t"
	desc = "tyw_events.2.d"
	picture = PRINCE_BISHOP_RESIGN_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.2.a"
		kill_ruler = yes
		change_religion = catholic
		hidden_effect = {
			FROM = { country_event = { id = tyw_events.4 days = 7 } }
		}
	}

	option = {
		name = "tyw_events.2.b"
		add_prestige = 10
		FROM = {
			add_opinion = {
				who = ROOT
				modifier = refused_to_resign
			}
			tooltip = {
				add_casus_belli = {
					target = ROOT
					type = cb_religious_conformance
					months = 24
				}
			}
			hidden_effect = {
				FROM = { country_event = { id = tyw_events.3 days = 7 } }
			}
		}
	}
}

# Prince-Bishop Refuses Resignation
country_event = {
	id = tyw_events.3
	title = "tyw_events.3.t"
	desc = "tyw_events.3.d"
	picture = PRINCE_BISHOP_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.3.a"
		add_casus_belli = {
			target = FROM
			type = cb_religious_conformance
			months = 24
		}
	}
}

# Prince-Bishop Resigns
country_event = {
	id = tyw_events.4
	title = "tyw_events.4.t"
	desc = "tyw_events.4.d"
	picture = PRINCE_BISHOP_RESIGN_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.4.a"
		add_scaled_imperial_influence = 5
	}
}

# Blockade
province_event = {
	id = tyw_events.5
	title = "tyw_events.5.t"
	desc = "tyw_events.5.d"
	picture = PORT_BLOCKADED_eventPicture

	trigger = {
		has_dlc = "Art of War"
		has_port = yes
		is_blockaded = yes
		controlled_by = owner
		NOT = { has_province_modifier = unaided_during_blockade }
	}

	mean_time_to_happen = {
		months = 800
	}

	option = {
		name = "tyw_events.5.a"
		trigger = { is_island = no } #Overland help cannot really arrive in this case.
		owner = { add_adm_power = -25 }
	}

	option = {
		trigger = { owner = { has_idea = privateers } }
		name = "tyw_events.5.b"
		owner = { add_dip_power = -25 }
	}

	option = {
		name = "tyw_events.5.c"
		add_province_modifier = {
			name = "unaided_during_blockade"
			duration = 1825
		}
	}
}

# The Great Comet
country_event = {
	id = tyw_events.6
	title = "tyw_events.6.t"
	desc = "tyw_events.6.d"
	picture = ASTRONOMER_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_year = 1577
		NOT = { is_year = 1578 }
		advisor = natural_scientist
		NOT = { has_country_flag = had_great_comet }
	}

	mean_time_to_happen = {
		months = 8
	}

	option = {
		name = "tyw_events.6.a"
		add_stability_or_adm_power = yes
		set_country_flag = had_great_comet
	}
}

# Education for a [Title]
country_event = {
	id = tyw_events.7
	title = "tyw_events.7.t"
	desc = "tyw_events.7.d"
	picture = MONARCH_CHILD_WITH_REGENT_eventPicture

	trigger = {
		has_dlc = "Art of War"
		has_regency = yes
		has_consort_regency = no
		OR = {
			AND = {
				OR = {
					advisor = philosopher
					advisor = natural_scientist
					advisor = artist
					advisor = treasurer
					advisor = theologian
					advisor = master_of_mint
					advisor = inquisitor
				}
				NOT = { heir_adm = 6 }
			}
			AND = {
				OR = {
					advisor = statesman
					advisor = naval_reformer
					advisor = trader
					advisor = spymaster
					advisor = colonial_governor
					advisor = diplomat
					advisor = navigator
				}
				NOT = { heir_dip = 6 }
			}
			AND = {
				OR = {
				advisor = army_reformer
				advisor = army_organiser
				advisor = commandant
				advisor = quartermaster
				advisor = recruitmaster
				advisor = fortification_expert
				advisor = grand_captain
				}
				NOT = { heir_mil = 6 }
			}
		}
		has_heir = yes
		NOT = { 
			OR = {
				has_reform = elective_monarchy
				has_reform = polish_elective_monarchy
				has_reform = steppe_horde
			}
		}
		NOT = { has_country_flag = heir_adm_education }
		NOT = { has_country_flag = heir_dip_education }
		NOT = { has_country_flag = heir_mil_education }
		is_lesser_in_union = no
		OR = {
			NOT = { heir_adm = 6 }
			NOT = { heir_mil = 6 }
			NOT = { heir_dip = 6 }
		}
	}

	mean_time_to_happen = {
		months = 800
	}

	option = {
		name = "tyw_events.7.a"
		trigger = {
			OR = {
				advisor = philosopher
				advisor = natural_scientist
				advisor = artist
				advisor = treasurer
				advisor = theologian
				advisor = master_of_mint
				advisor = inquisitor
			}
			NOT = { heir_adm = 6 }
		}
		set_country_flag = heir_adm_education
		custom_tooltip = "tyw_events.7.a.tt"
	}

	option = {
		name = "tyw_events.7.b"
		trigger = {
			OR = {
				advisor = statesman
				advisor = naval_reformer
				advisor = trader
				advisor = spymaster
				advisor = colonial_governor
				advisor = diplomat
				advisor = navigator
			}
			NOT = { heir_dip = 6 }
		}
		set_country_flag = heir_dip_education
		custom_tooltip = "tyw_events.7.b.tt"
	}

	option = {
		name = "tyw_events.7.c"
		trigger = {
			OR = {
				advisor = army_reformer
				advisor = army_organiser
				advisor = commandant
				advisor = quartermaster
				advisor = recruitmaster
				advisor = fortification_expert
				advisor = grand_captain
			}
			NOT = { heir_mil = 6 }
		}
		set_country_flag = heir_mil_education
		custom_tooltip = "tyw_events.7.c.tt"
	}
}

# Scottish Mercenaries - Scotland
country_event = {
	id = tyw_events.8
	title = "tyw_events.8.t"
	desc = "tyw_events.8.d"
	picture = SCOTTISH_MERCENARIES_eventPicture

	trigger = {
		has_dlc = "Art of War"
		tag = SCO
		is_at_war = no
		any_known_country = {
			is_in_league_war = yes
		}
		manpower_percentage = 0.2
		NOT = {
			any_known_country = {
				has_country_modifier = scottish_mercenaries
			}
		}
	}

	mean_time_to_happen = {
		months = 120
	}

	option = {
		name = "tyw_events.8.a"
		add_years_of_income = 0.5
		add_yearly_manpower = -2
		every_known_country = {
			limit = { in_league = protestant }
			hidden_effect = {
				country_event = { id = tyw_events.9 days = 7}
			}
			tooltip = {
				add_country_modifier = {
					name = "scottish_mercenaries"
					duration = 10950
				}
			}
			add_opinion = {
				who = ROOT
				modifier = sent_mercenaries
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				in_league = catholic
			}
			modifier = {
				factor = 4
				OR = {
					religion = protestant
					religion = reformed
				}
			}
		}
	}

	option = {
		name = "tyw_events.8.b"
		add_years_of_income = 0.5
		add_yearly_manpower = -2
		every_known_country = {
			limit = { in_league = catholic }
			hidden_effect = {
				country_event = { id = tyw_events.9 days = 7}
			}
			tooltip = {
				add_country_modifier = {
					name = "scottish_mercenaries"
					duration = 10950
				}
			}
			add_opinion = {
				who = ROOT
				modifier = sent_mercenaries
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				in_league = protestant
			}
			modifier = {
				factor = 4
				religion = catholic
			}
		}
	}

	option = {
		name = "tyw_events.8.c"
		add_yearly_manpower = 2
		ai_chance = {
			factor = 0
		}
	}
}

# Scottish Mercenaries - Employers
country_event = {
	id = tyw_events.9
	title = "tyw_events.9.t"
	desc = "tyw_events.9.d"
	picture = SCOTTISH_MERCENARIES_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.9.a"
		if = {
			limit = {
				NOT = { has_country_modifier = swedish_mercenary_core }
				OR = {
					current_age = age_of_discovery
					current_age = age_of_reformation
				}
			}
			custom_tooltip = tyw_events.9.tt1
		}
		if = {
			limit = {
				NOT = { has_country_modifier = swedish_mercenary_core }
				OR = {
					current_age = age_of_absolutism
					current_age = age_of_revolutions
				}
			}
			custom_tooltip = tyw_events.9.tt2
		}
		add_country_modifier = {
			name = "scottish_mercenaries"
			duration = 10950
		}
	}
}

# Hungarians Revolt Against Habsburg Rule
province_event = {
	id = tyw_events.10
	title = "tyw_events.10.t"
	desc = "tyw_events.10.d"
	picture = REVOLT_HUNGARIAN_eventPicture

	trigger = {
		has_dlc = "Art of War"
		culture = hungarian
		OR = {
			religion = protestant
			religion = reformed
		}
		owner = {
			dynasty = "0000000000"
			religion = catholic
			is_in_league_war = yes
		}
	}

	mean_time_to_happen = {
		months = 1000
	}

	option = {
		name = "tyw_events.10.a"
		create_revolt = 2
	}
}

# Huguenots Gather in La Rochelle
country_event = {
	id = tyw_events.11
	title = "tyw_events.11.t"
	desc = "tyw_events.11.d"
	picture = REVOLT_HUGUENOTS_eventPicture

	trigger = {
		has_dlc = "Art of War"
		tag = FRA
		has_country_flag = FRA_wars_of_religion_ended
		NOT = { has_country_flag = huguenots_la_rochelle }
		NOT = { has_country_flag = FRA_had_event_3128 }
		NOT = { religious_unity = 1.0 }
		religion = catholic
		owns = 4111
	}

	mean_time_to_happen = {
		months = 300
	}

	option = {
		name = "tyw_events.11.a"
		set_country_flag = huguenots_la_rochelle
		4111 = {
			change_religion = reformed
			add_province_modifier = {
				name = "huguenot_stronghold"
				duration = 3650
			}
		}
	}
}

# Huguenots Rebels Need Our Help
country_event = {
	id = tyw_events.12
	title = "tyw_events.12.t"
	desc = "tyw_events.12.d"
	picture = REVOLT_HUGUENOTS_eventPicture

	trigger = {
		has_dlc = "Art of War"
		OR = {
			tag = ENG
			tag = GBR
		}
		OR = {
			religion = protestant
			religion = reformed
		}
		NOT = { has_country_flag = support_huguenots_decision }
		FRA = {
			NOT = { has_country_flag = FRA_had_event_3128 }
			owns = 4111
		}
		4111 = {
			religion = reformed
			has_province_modifier = huguenot_stronghold
		}
	}

	mean_time_to_happen = {
		months = 80
	}

	immediate = {
		hidden_effect = {
			set_country_flag = support_huguenots_decision
		}
	}
	
	option = {
		name = "tyw_events.12.a"
		tooltip = {
			4111 = {
				spawn_rebels = {
					type = religious_rebels
					size = 2
					friend = ROOT
				}
				add_claim = ROOT
			}
		}
		FRA = {
			add_opinion = {
				who = ROOT
				modifier = supported_huguenots
			}
			tooltip = {
				add_casus_belli = {
					target = ROOT
					type = cb_insult
					months = 24
				}
			}
			hidden_effect = {
				country_event = { id = tyw_events.13 days = 7 }
			}
		}
	}

	option = {
		name = "tyw_events.12.b"
		add_prestige = -10
	}
}

# English Intervention Rouses Huguenots
country_event = {
	id = tyw_events.13
	title = "tyw_events.13.t"
	desc = "tyw_events.13.d"
	picture = REVOLT_HUGUENOTS_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.13.a"
		4111 = {
			spawn_rebels = {
				type = religious_rebels
				size = 2
				friend = FROM
			}
		}
		add_casus_belli = {
			target = FROM
			type = cb_insult
			months = 24
		}
	}
}

# Fall of Prague
country_event = {
	id = tyw_events.14
	title = "tyw_events.14.t"
	desc = "tyw_events.14.d"
	picture = SIEGE_PRAGUE_CASTLE_eventPicture

	trigger = {
		has_dlc = "Art of War"
		FROM = {
			province_id = 266 # Prague
			owner = { is_in_league_war = yes }
			NOT = { has_province_modifier = plundered_in_war }
		}
		is_in_league_war = yes
		NOT = { has_country_flag = plundered_prague_in_war }
	}

	is_triggered_only = yes

	option = {
		name = "tyw_events.14.a"
		add_treasury = 100
		add_prestige = 10
		266 = {
			add_province_modifier = {
				name = "plundered_in_war"
				duration = 1825
			}
			owner = {
				add_opinion = {
					who = ROOT
					modifier = "plundered_prague"
				}
			}
		}
		set_country_flag = plundered_prague_in_war
	}

	option = {
		name = "tyw_events.14.b"
		add_dip_power = 20
	}
}

# Albrecht von Wallenstein
country_event = {
	id = tyw_events.15
	title = "tyw_events.15.t"
	desc = "tyw_events.15.d"
	picture = WALLENSTEIN_eventPicture

	fire_only_once = yes

	trigger = {
		has_dlc = "Art of War"
		is_emperor = yes
		is_in_league_war = yes
		NOT = { has_leader = "000000000" }
		is_year = 1604
		NOT = { is_year = 1650 }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = "tyw_events.15.a"
		define_general = {
			name = "000000000"
			shock = 4
			fire = 4
			manuever = 4
			siege = 1
		}
		add_mil_power = 50
	}
}

# Wallenstein's Loyalties Doubted
country_event = {
	id = tyw_events.16
	title = "tyw_events.16.t"
	desc = "tyw_events.16.d"
	picture = WALLENSTEIN_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_emperor = yes
		is_in_league_war = yes
		has_leader = "000000000"
		war_exhaustion = 8
		NOT = { war_score = 0 }
		NOT = { has_country_flag = wallenstein_suspected }
	}

	mean_time_to_happen = {
		months = 80
	}

	option = {
		name = "tyw_events.16.a"
		kill_leader = {
			type = "Wallenstein"
		}
	}

	option = {
		name = "tyw_events.16.b"
		add_mil_power = 20
		set_country_flag = wallenstein_suspected
	}
}

# Wallenstein Betrays Us
country_event = {
	id = tyw_events.17
	title = "tyw_events.17.t"
	desc = "tyw_events.17.d"
	picture = WALLENSTEIN_eventPicture

	trigger = {
		has_dlc = "Art of War"
		has_country_flag = wallenstein_suspected
		is_emperor = yes
		is_in_league_war = yes
		has_leader = "000000000"
		war_exhaustion = 8
		NOT = { war_score = 0 }
	}

	mean_time_to_happen = {
		months = 50
	}

	option = {
		name = "tyw_events.17.a"
		hidden_effect = {
			kill_leader = {
				type = "Wallenstein"
			}
		}
		random_known_country = {
			limit = {
				is_league_enemy = ROOT
				war_with = ROOT
			}
			country_event = {
				id = tyw_events.18
				days = 7
				tooltip = "tyw_events.17.a.tt"
			}
		}
	}
}

# General Wallenstein Defects from [Emperor]
country_event = {
	id = tyw_events.18
	title = "tyw_events.18.t"
	desc = "tyw_events.18.d"
	picture = WALLENSTEIN_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.18.a"
		define_general = {
			name = "000000000"
			shock = 4
			fire = 4
			manuever = 4
			siege = 1
		}
	}
}

# Winter Siege
country_event = {
	id = tyw_events.19
	title = "tyw_events.19.t"
	desc = "tyw_events.19.d"
	picture = SOLDIERS_FREEZING_eventPicture
	goto = siege_province

	trigger = {
		has_dlc = "Art of War"
		manpower = 4
		any_known_country = {
			war_with = ROOT
			any_owned_province = {
				sieged_by = ROOT
				fort_level = 1
				OR = {
					has_winter = normal_winter
					has_winter = severe_winter
				}
			}
		}
		OR = {
			is_month = 10
			AND = {
				is_month = 0
				NOT = { is_month = 3 }
			}
		}
	}

	mean_time_to_happen = {
		months = 600
	}
	
	immediate = {
		hidden_effect = {			
			random_province = {
				limit = {
					sieged_by = ROOT
					fort_level = 1
					NOT = { owned_by = ROOT }
					OR = {
						has_winter = normal_winter
						has_winter = severe_winter
					}
				}
				save_event_target_as = siege_province
			}
		}
	}

	option = {
		name = "tyw_events.19.a"
		add_manpower = -2
	}
	option = {
		name = "tyw_events.19.b"
		add_prestige = -5
		event_target:siege_province = {
			change_siege = -2
		}
	}
}

# End of the House of Griffins - Pomerania
country_event = {
	id = tyw_events.20
	title = "tyw_events.20.t"
	desc = "tyw_events.20.d"
	picture = POMERANIA_eventPicture

	trigger = {
		has_dlc = "Art of War"
		tag = POM
		dynasty = "000"
		has_heir = no
		hre_leagues_enabled = yes
		is_part_of_hre = yes
		NOT = { num_of_cities = 6 }
	}

	mean_time_to_happen = {
		months = 360
		modifier = {
			factor = 0.5
			ai = yes
		}
	}

	option = {
		name = "tyw_events.20.a"
		kill_ruler = yes
		every_neighbor_country = {
			country_event = {
				id = tyw_events.21
				days = 1
				tooltip = "tyw_events.20.a.tt"
			}
		}
	}
}

# End of the House of Griffins - Neighbors
country_event = {
	id = tyw_events.21
	title = "tyw_events.21.t"
	desc = "tyw_events.21.d"
	picture = POMERANIA_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.21.a"
		FROM = {
			every_owned_province = {
				add_claim = ROOT
			}
		}
	}
}

# Battle of [Capital]
province_event = {
	id = tyw_events.22
	title = "tyw_events.22.t"
	desc = "tyw_events.22.d"
	picture = WHITE_MOUNTAIN_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_capital = yes
		owner = {
			is_in_league_war = yes
			NOT = { has_country_flag = lost_capital_battle }
		}
		FROM = {
			NOT = { has_country_flag = won_capital_battle }
			is_league_enemy = ROOT
		}
	}

	is_triggered_only = yes

	option = {
		name = "tyw_events.22.a"
		owner = {
			add_prestige = -20
			set_country_flag = lost_capital_battle
		}
		FROM = {
			country_event = { id = tyw_events.46 days = 1 }
		}
	}
}

# Enemies of the Leauge
country_event = {
	id = tyw_events.23
	title = "tyw_events.23.t"
	desc = "tyw_events.23.d"
	picture = PROTESTANT_CATHOLIC_DEBATE_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_in_league_war = yes
		NOT = { religious_unity = 1.0 }
		OR = {
			AND = {
				in_league = catholic
				any_owned_province = {
					OR = {
						religion = protestant
						religion = reformed
					}
				}
			}
			AND = {
				in_league = protestant
				any_owned_province = {
					religion = catholic
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	option = {
		name = "tyw_events.23.a"
		if = {
			limit = { in_league = catholic }
			random_owned_province = {
				limit = {
					OR = {
						religion = protestant
						religion = reformed
					}
				}
				spawn_rebels = {
					type = religious_rebels
					size = 2
				}
			}
		}
		if = {
			limit = { in_league = protestant }
			random_owned_province = {
				limit = { religion = catholic }
				spawn_rebels = {
					type = religious_rebels
					size = 2
				}
			}
		}
	}
}

# [Advisor] Questions Our Faith
country_event = {
	id = tyw_events.24
	title = "tyw_events.24.t"
	desc = "tyw_events.24.d"
	picture = PROTESTANT_CATHOLIC_DEBATE_eventPicture

	trigger = {
		has_dlc = "Art of War"
		OR = {
			AND = {
				in_league = catholic
				OR = {
					religion = protestant
					religion = reformed
				}
			}
			AND = {
				in_league = protestant
				religion = catholic
			}
		}
		OR = {
			advisor = theologian
			advisor = inquisitor
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	option = {
		name = "tyw_events.24.a"
		reduce_meritocracy_effect = yes
		if = {
			limit = { advisor = theologian }
			remove_advisor = theologian
		}
		if = {
			limit = { advisor = inquisitor }
			remove_advisor = inquisitor
		}
		add_adm_power = -20
	}

	option = {
		name = "tyw_events.24.b"
		every_known_country = {
			limit = { is_league_friend = ROOT }
			add_opinion = {
				who = ROOT
				modifier = questioned_league
			}
		}
	}
}

# [Religion] [Culture] Question our Rule
province_event = {
	id = tyw_events.25
	title = "tyw_events.25.t"
	desc = "tyw_events.25.d"
	picture = PROTESTANT_CATHOLIC_DEBATE_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_capital = no
		owner = {
			NOT = { religion = ROOT }
			NOT = { accepted_culture = ROOT }
			NOT = { tolerance_to_this = 0 }
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	is_mtth_scaled_to_size = 1

	option = {
		name = "tyw_events.25.a"
		spawn_rebels = {
			type = nationalist_rebels
			size = 2
		}
	}

	option = {
		name = "tyw_events.25.b"
		spawn_rebels = {
			type = religious_rebels
			size = 2
		}
	}

	option = {
		name = "tyw_events.25.c"
		add_local_autonomy = 20
	}
}

# Jesuit Education for [Heir]
country_event = {
	id = tyw_events.26
	title = "tyw_events.26.t"
	desc = "tyw_events.26.d"
	picture = JESUIT_eventPicture

	trigger = {
		has_dlc = "Art of War"
		religion = catholic
		has_regency = yes
		has_consort_regency = no
		is_year = 1540
		is_lesser_in_union = no
	}

	mean_time_to_happen = {
		months = 1000
	}

	option = {
		name = "tyw_events.26.a"
		set_country_flag = jesuit_education
		custom_tooltip = "tyw_events.26.a.tt"
		every_neighbor_country = {
			limit = {
				OR = {
					religion = protestant
					religion = reformed
				}
			}
			add_opinion = {
				who = ROOT
				modifier = jesuit_heir
			}
		}
	}

	option = {
		name = "tyw_events.26.b"
		add_adm_power = 25
	}
}

# Jesuit Ascends to the Throne
country_event = {
	id = tyw_events.27
	title = "tyw_events.27.t"
	desc = "tyw_events.27.d"
	picture = JESUIT_eventPicture

	trigger = {
		has_dlc = "Art of War"
		has_country_flag = jesuit_education
		has_regency = no
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		name = "tyw_events.27.a"
		change_mil = 1
		clr_country_flag = jesuit_education
		add_ruler_modifier = {
			name = jesuit_ruler
		}
	}
}

# [Culture] Nobles Flee Abroad
country_event = {
	id = tyw_events.28
	title = "tyw_events.28.t"
	desc = "tyw_events.28.d"
	picture = CZECH_NOBLES_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_in_league_war = yes
		NOT = { war_score = 0 }
		capital_scope = {
			NOT = { controlled_by = ROOT }
			NOT = { controlled_by = REB }
		}
		any_neighbor_country = {
			religion = ROOT
			NOT = { is_league_enemy = ROOT }
		}
	}

	mean_time_to_happen = {
		months = 120
	}

	option = {
		name = "tyw_events.28.a"
		add_country_modifier = {
			name = "nobles_fled"
			duration = 3650
		}
		every_neighbor_country = {
			limit = {
				religion = ROOT
				NOT = { is_league_enemy = ROOT }
			}
			country_event = { id = tyw_events.29 days = 7 }
		}
	}

	option = {
		name = "tyw_events.28.b"
		add_adm_power = -20
		add_dip_power = -20
	}
}

# [Culture] Nobles Seek Refuge
country_event = {
	id = tyw_events.29
	title = "tyw_events.29.t"
	desc = "tyw_events.29.d"
	picture = CZECH_NOBLES_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.29.a"
		FROM = {
			add_opinion = {
				who = ROOT
				modifier = rejected_noble_refugees
			}
		}
	}

	option = {
		name = "tyw_events.29.b"
		add_prestige = 20
		every_known_country = {
			limit = {
				war_with = FROM
				is_in_league_war = yes
			}
			add_opinion = {
				who = ROOT
				modifier = sheltered_enemy_nobles
			}
		}
	}
}

# igo Vlez de Guevara
country_event = {
	id = tyw_events.30
	title = "tyw_events.30.t"
	desc = "tyw_events.30.d"
	picture = INIGO_GUEVARA_eventPicture

	trigger = {
		has_dlc = "Art of War"
		OR = {
			tag = CAS
			tag = SPA
		}
		is_year = 1588
		NOT = { is_year = 1644 }
		hre_leagues_enabled = yes
		OR = {
			in_league = catholic
			in_league = protestant
		}
		any_known_country = {
			is_part_of_hre = yes
			is_league_enemy = ROOT
			any_neighbor_country = {
				is_part_of_hre = yes
				NOT = { is_league_enemy = ROOT }
				NOT = { alliance_with = PREV }
			}
		}
	}

	mean_time_to_happen = {
		months = 240
	}

	option = {
		name = "tyw_events.30.a"
		random_known_country = {
			limit = {
				is_part_of_hre = yes
				NOT = { is_league_enemy = ROOT }
				any_neighbor_country = {
					is_part_of_hre = yes
					is_league_enemy = ROOT
					NOT = { alliance_with = PREV }
				}
			}
			country_event = {
				id = tyw_events.31
				days = 7
				tooltip = "tyw_events.30.a.tt"
			}
		}
	}

	option = {
		name = "tyw_events.30.b"
		add_dip_power = 10
	}
}

# [From] Offers League Enemy
country_event = {
	id = tyw_events.31
	title = "tyw_events.31.t"
	desc = "tyw_events.31.d"
	picture = INIGO_GUEVARA_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.31.a"
		random_neighbor_country = {
			limit = {
				is_part_of_hre = yes
				is_league_enemy = FROM
				NOT = { alliance_with = ROOT }
			}
			random_owned_province = {
				limit = {
					any_neighbor_province = { owned_by = ROOT }
					NOT = { is_claim = ROOT }
				}
				add_claim = ROOT
			}
		}
		FROM = {
			add_opinion = {
				who = ROOT
				modifier = accepted_claim_on_neighbor
			}
		}
	}

	option = {
		name = "tyw_events.31.b"
		every_neighbor_country = {
			limit = { is_league_enemy = FROM }
			add_opinion = {
				who = ROOT
				modifier = rejected_claim_on_neighbor
			}
		}
	}
}

# Enforce Sound Toll for Sweden
country_event = {
	id = tyw_events.32
	title = "tyw_events.32.t"
	desc = "tyw_events.32.d"
	picture = TOLLS_SHIP_CARGO_eventPicture

	trigger = {
		has_dlc = "Art of War"
		tag = DAN
		exists = SWE
		owns = 12
		is_free_or_tributary_trigger = yes
		SWE = {
			is_free_or_tributary_trigger = yes
			NOT = { war_with = ROOT }
		}
	}

	mean_time_to_happen = {
		months = 600
	}

	option = {
		name = "tyw_events.32.a"
		hidden_effect = {
			SWE = {
				country_event = { id = tyw_events.33 days = 7 }
			}
		}
		tooltip = {
			SWE = {
				12 = {
					add_trade_modifier = {
						who = prev
						duration = 3650
						power = -10
						key = enforced_sound_toll
					}
				}
				add_casus_belli = {
					target = ROOT
					type = cb_trade_war_triggered
					months = 60
				}
			}
		}
		SWE = {
			add_opinion = {
				who = ROOT
				modifier = opinion_enforced_sound_toll
			}
		}
	}

	option = {
		name = "tyw_events.32.b"
		add_dip_power = 20
	}
}

# Denmark Enforces Sound Toll
country_event = {
	id = tyw_events.33
	title = "tyw_events.33.t"
	desc = "tyw_events.33.d"
	picture = TOLLS_SHIP_CARGO_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.33.a"
		12 = {
			add_trade_modifier = {
				who = root
				duration = 3650
				power = -10
				key = enforced_sound_toll
			}
		}
		add_casus_belli = {
			target = FROM
			type = cb_trade_war_triggered
			months = 60
		}
	}
}

# Request Ottoman Backing to Claim Poland
country_event = {
	id = tyw_events.34
	title = "tyw_events.34.t"
	desc = "tyw_events.34.d"
	picture = TRANSYLVANIAN_OTTOMAN_eventPicture

	fire_only_once = yes

	trigger = {
		has_dlc = "Art of War"
		tag = TRA
		TUR = {
			has_opinion = {
				who = ROOT
				value = 50
			}
		}
		OR = {
			POL = {
				is_neighbor_of = ROOT
				NOT = { alliance_with = ROOT }
				NOT = { alliance_with = TUR }
				is_free_or_tributary_trigger = yes
			}
			PLC = {
				is_neighbor_of = ROOT
				NOT = { alliance_with = ROOT }
				NOT = { alliance_with = TUR }
				is_free_or_tributary_trigger = yes
			}
		}
	}

	mean_time_to_happen = {
		months = 360
	}

	option = {
		name = "tyw_events.34.a"
		TUR = {
			country_event = {
				id = tyw_events.35
				days = 7
				tooltip = "tyw_events.34.a.tt"
			}
		}
		if = {
			limit = { exists = PLC }
			PLC = {
				add_opinion = {
					who = ROOT
					modifier = conspired_with_ottomans
				}
			}
		}
		if = {
			limit = { exists = POL }
			POL = {
				add_opinion = {
					who = ROOT
					modifier = conspired_with_ottomans
				}
			}
		}
	}

	option = {
		name = "tyw_events.34.b"
		add_dip_power = 20
	}
}

# Transylvania Requests Backing to Claim Poland
country_event = {
	id = tyw_events.35
	title = "tyw_events.35.t"
	desc = "tyw_events.35.d"
	picture = TRANSYLVANIAN_OTTOMAN_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.35.a"
		if = {
			limit = { exists = POL }
			POL = {
				every_owned_province = {
					limit = {
						any_neighbor_province = { owned_by = FROM}
					}
					add_claim = FROM
				}
			}
		}
		if = {
			limit = { exists = PLC }
			PLC = {
				every_owned_province = {
					limit = {
						any_neighbor_province = { owned_by = FROM}
					}
					add_claim = FROM
				}
			}
		}
		ai_chance = {
			factor = 50
		}
	}

	option = {
		name = "tyw_events.35.b"
		add_dip_power = 20
		FROM = {
			add_opinion = {
				who = ROOT
				modifier = refused_backing_claims
			}
		}
		ai_chance = {
			factor = 10
			modifier = {
				factor = 5
				OR = {
					has_opinion = {
						who = POL
						value = 0
					}
					has_opinion = {
						who = PLC
						value = 0
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					has_opinion = {
						who = POL
						value = 100
					}
					has_opinion = {
						who = PLC
						value = 100
					}
				}
			}
		}
	}
}

# Free Hungary from Religious Oppression
country_event = {
	id = tyw_events.36
	title = "tyw_events.36.t"
	desc = "tyw_events.36.d"
	picture = TRANSYLVANIA_BETHLEN_INVASION_eventPicture

	trigger = {
		has_dlc = "Art of War"
		tag = TRA
		hre_leagues_enabled = yes
		any_neighbor_country = {
			NOT = { tag = HUN }
			any_owned_province = {
				culture = hungarian
				religion = ROOT
				any_neighbor_province = { owned_by = ROOT }
				NOT = { is_claim = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 240
	}

	option = {
		name = "tyw_events.36.a"
		every_owned_province = {
			every_neighbor_province = {
				limit = {
					NOT = { owned_by = ROOT }
					NOT = { owned_by = HUN }
					culture = hungarian
					religion = ROOT
					NOT = { is_claim = ROOT }
				}
				add_claim = ROOT
			}
		}
	}
}

# Golden Age of Transylvania
country_event = {
	id = tyw_events.37
	title = "tyw_events.37.t"
	desc = "tyw_events.37.d"
	picture = PRINCELY_PALACE_TRANSYLVANIA_eventPicture

	fire_only_once = yes

	trigger = {
		has_dlc = "Art of War"
		tag = TRA
		is_year = 1600
		adm = 3
		dip = 3
		mil = 3
		OR = {
			adm = 5
			dip = 5
			mil = 5
		}
		is_at_war = no
		stability = 0
	}

	mean_time_to_happen = {
		months = 240
	}

	option = {
		name = "tyw_events.37.a"
		add_country_modifier = {
			name = "golden_age_transylvania"
			duration = 5475
		}
	}
}

# United in Prayer
country_event = {
	id = tyw_events.38
	title = "tyw_events.38.t"
	desc = "tyw_events.38.d"
	picture = CATHOLIC_RULERS_PRAYING_eventPicture

	trigger = {
		has_dlc = "Art of War"
		OR = {
			has_idea_group = religious_ideas
			has_ruler_modifier = jesuit_ruler
		}
		religion_group = christian
		any_known_country = {
			religion = ROOT
			has_opinion = {
				who = ROOT
				value = 10
			}
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	option = {
		name = "tyw_events.38.a"
		random_known_country = {
			limit = {
				religion = ROOT
				has_opinion = {
					who = ROOT
					value = 10
				}
			}
			random = {
				chance = 75
				add_opinion = {
					who = ROOT
					modifier = rulers_united_in_prayer
				}
			}
		}
	}

	option = {
		name = "tyw_events.38.b"
		add_dip_power = 15
	}
}

# God is Spanish
country_event = {
	id = tyw_events.39
	title = "tyw_events.39.t"
	desc = "tyw_events.39.d"
	picture = GASPAR_DE_GUZMAN_eventPicture

	fire_only_once = yes

	trigger = {
		has_dlc = "Art of War"
		tag = SPA
		is_in_league_war = yes
		war_score = 30
	}

	mean_time_to_happen = {
		months = 360
	}

	option = {
		name = "tyw_events.39.a"
		add_country_modifier = {
			name = "god_is_spanish"
			duration = 3650
		}
	}
}

# God Wants Peace
country_event = {
	id = tyw_events.40
	title = "tyw_events.40.t"
	desc = "tyw_events.40.d"
	picture = GASPAR_DE_GUZMAN_eventPicture

	fire_only_once = yes

	trigger = {
		has_dlc = "Art of War"
		tag = SPA
		is_in_league_war = yes
		NOT = { war_score = -30 }
	}

	mean_time_to_happen = {
		months = 360
		modifier = {
			factor = 0.1
			has_country_modifier = god_is_spanish
		}
	}

	option = {
		name = "tyw_events.40.a"
		if = {
			limit = { has_country_modifier = god_is_spanish }
			remove_country_modifier = god_is_spanish
		}
		add_country_modifier = {
			name = "god_wants_peace"
			duration = 3650
		}
	}
}

# Bartering Increases
country_event = {
	id = tyw_events.41
	title = "tyw_events.41.t"
	desc = "tyw_events.41.d"
	picture = PEASANTS_BARTERING_eventPicture

	trigger = {
		has_dlc = "Art of War"
		inflation = 6
		num_of_cities = 5
	}

	mean_time_to_happen = {
		months = 600
		modifier = {
			factor = 0.8
			inflation = 8
		}
		modifier = {
			factor = 0.8
			inflation = 10
		}
	}

	option = {
		name = "tyw_events.41.a"
		random_owned_province = {
			limit = {
				is_capital = no
			}
			add_local_autonomy = 15
		}
		random_owned_province = {
			limit = {
				is_capital = no
			}
			add_local_autonomy = 15
		}
		random_owned_province = {
			limit = {
				is_capital = no
			}
			add_local_autonomy = 15
		}
		random_owned_province = {
			limit = {
				is_capital = no
			}
			add_local_autonomy = 15
		}
	}

	option = {
		name = "tyw_events.41.b"
		add_adm_power = -100
		add_inflation = -2
	}
}

# Capturing the Spanish Treasure Fleet
country_event = {
	id = tyw_events.42
	title = "tyw_events.42.t"
	desc = "tyw_events.42.d"
	picture = DUTCH_SHIPS_PLUNDERING_eventPicture

	fire_only_once = yes

	trigger = {
		has_dlc = "Art of War"
		tag = NED
		has_privateers = yes
		NOT = { alliance_with = SPA }
		SPA = {
			any_active_trade_node = {
				has_merchant = PREV
				is_overseas = yes
				any_privateering_country = { tag = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 600
	}

	option = {
		name = "tyw_events.42.a"
		SPA = {
			add_opinion = {
				who = ROOT
				modifier = attacked_treasure_fleet
			}
		}
		random = {
			chance = 60
			country_event = {
				id = tyw_events.43
				days = 14
			}
			tooltip = {
				add_treasury = 300
				SPA = {
					add_treasury = -300
					add_casus_belli = {
						target = ROOT
						type = cb_trade_war_triggered
						months = 60
					}
				}
			}
		}
	}

	option = {
		name = "tyw_events.42.b"
		add_prestige = -10
	}
}

# Spanish Treasure Fleet Captured!
country_event = {
	id = tyw_events.43
	title = "tyw_events.43.t"
	desc = "tyw_events.43.d"
	picture = DUTCH_SHIPS_PLUNDERING_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.43.a"
		add_treasury = 300
		SPA = {
			country_event = { id = tyw_events.44 days = 7 }
		}
	}
}

# Treasure Fleet Captured by the Dutch
country_event = {
	id = tyw_events.44
	title = "tyw_events.44.t"
	desc = "tyw_events.44.d"
	picture = DUTCH_SHIPS_PLUNDERING_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.44.a"
		add_treasury = -300
		add_casus_belli = {
			target = FROM
			type = cb_trade_war_triggered
			months = 60
		}
	}
}

# An Educated [Ruler]
country_event = {
	id = tyw_events.45
	title = "tyw_events.45.t"
	desc = "tyw_events.45.d"
	picture = BIG_BOOK_eventPicture

	trigger = {
		has_dlc = "Art of War"
		OR = {
			has_country_flag = heir_adm_education
			has_country_flag = heir_dip_education
			has_country_flag = heir_mil_education
		}
		has_regency = no
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		name = "tyw_events.45.a"
		# ADM EDUCATION
		if = {
			limit = {
				has_country_flag = heir_adm_education
				adm = 6
			}
			add_adm_power = 50
		}
		if = {
			limit = {
				has_country_flag = heir_adm_education
				adm = 5
				NOT = { adm = 6 }
			}
			change_adm = 1
		}
		if = {
			limit = {
				has_country_flag = heir_adm_education
				NOT = { adm = 5 }
			}
			change_adm = 2
		}
		
		# DIP EDUCATION
		if = {
			limit = {
				has_country_flag = heir_dip_education
				dip = 6
			}
			add_dip_power = 50
		}
		if = {
			limit = {
				has_country_flag = heir_dip_education
				dip = 5
				NOT = { dip = 6 }
			}
			change_dip = 1
		}
		if = {
			limit = {
				has_country_flag = heir_dip_education
				NOT = { dip = 5 }
			}
			change_dip = 2
		}
		
		# MIL EDUCATION
		if = {
			limit = {
				has_country_flag = heir_mil_education
				mil = 6
			}
			add_mil_power = 50
		}
		if = {
			limit = {
				has_country_flag = heir_mil_education
				mil = 5
				NOT = { mil = 6 }
			}
			change_mil = 1
		}
		if = {
			limit = {
				has_country_flag = heir_mil_education
				NOT = { mil = 5 }
			}
			change_mil = 2
		}
		clr_country_flag = heir_adm_education
		clr_country_flag = heir_dip_education
		clr_country_flag = heir_mil_education
	}
}

# Victory at [Enemy Capital]!
country_event = {
	id = tyw_events.46
	title = "tyw_events.46.t"
	desc = "tyw_events.46.d"
	picture = WHITE_MOUNTAIN_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.46.a"
		create_general = { tradition = 50 }
		set_country_flag = won_capital_battle
	}
}

# Preparing our Defenses
country_event = {
	id = tyw_events.47
	title = "tyw_events.47.t"
	desc = "tyw_events.47.d"
	picture = GENERALS_DISCUSSING_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_at_war = yes
		num_of_cities = 6
		NOT = { num_of_cities = 40 }
		any_known_country = {
			offensive_war_with = ROOT
		}
		any_owned_province = {
			fort_level = 1
			any_neighbor_province = {
				owned_by = ROOT
				is_capital = yes
			}
		}
		any_owned_province = {
			fort_level = 1
			NOT = { has_province_modifier = improved_fortifications }
			any_neighbor_province = {
				NOT = { controlled_by = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 480
	}

	immediate = {
		hidden_effect = {
			capital_scope = {
				set_province_flag = fortifications_event_home
			}
			random_owned_province = {
				limit = {
					fort_level = 1
					any_neighbor_province = {
						owned_by = ROOT
						is_capital = yes
					}
				}
				set_province_flag = fortifications_event_home
			}
			random_owned_province = {
				limit = {
					fort_level = 1
					any_neighbor_province = {
						owned_by = ROOT
						is_capital = yes
					}
					NOT = { has_province_flag = fortifications_event_home }
				}
				set_province_flag = fortifications_event_home
			}
			random_owned_province = {
				limit = {
					fort_level = 1
					any_neighbor_province = {
						NOT = { owned_by = ROOT }
					}
					NOT = { has_province_flag = fortifications_event_home }
				}
				set_province_flag = fortifications_event_border
			}
			random_owned_province = {
				limit = {
					fort_level = 1
					any_neighbor_province = {
						NOT = { owned_by = ROOT }
					}
					NOT = { has_province_flag = fortifications_event_home }
					NOT = { has_province_flag = fortifications_event_border }
				}
				set_province_flag = fortifications_event_border
			}
			random_owned_province = {
				limit = {
					fort_level = 1
					any_neighbor_province = {
						NOT = { owned_by = ROOT }
					}
					NOT = { has_province_flag = fortifications_event_home }
					NOT = { has_province_flag = fortifications_event_border }
				}
				set_province_flag = fortifications_event_border
			}
		}
	}

	option = {
		name = "tyw_events.47.a"
		every_owned_province = {
			limit = { has_province_flag = fortifications_event_home }
			add_province_modifier = {
				name = "improved_fortifications"
				duration = 3650
			}
		}
		hidden_effect = {
			every_owned_province = {
				clr_province_flag = fortifications_event_home
				clr_province_flag = fortifications_event_border
			}
		}
	}

	option = {
		name = "tyw_events.47.b"
		every_owned_province = {
			limit = { has_province_flag = fortifications_event_border }
			add_province_modifier = {
				name = "improved_fortifications"
				duration = 3650
			}
		}
		hidden_effect = {
			every_owned_province = {
				clr_province_flag = fortifications_event_home
				clr_province_flag = fortifications_event_border
			}
		}
	}
}

# True Intentions
country_event = {
	id = tyw_events.48
	title = "tyw_events.48.t"
	desc = "tyw_events.48.d"
	picture = GENERALS_DISCUSSING_eventPicture

	trigger = {
		has_dlc = "Art of War"
		is_in_league_war = yes
		is_league_leader = no
		OR = {
			AND = {
				in_league = catholic
				religion = catholic
			}
			AND = {
				in_league = protestant
				OR = {
					religion = protestant
					religion = reformed
				}
			}
		}
		any_known_country = {
			is_league_leader = yes
		}
		NOT = { has_country_modifier = in_league_for_faith }
		NOT = { has_country_modifier = in_league_for_land }
	}

	mean_time_to_happen = {
		months = 600
	}

	option = {
		name = "tyw_events.48.a"
		add_country_modifier = {
			name = "in_league_for_land"
			duration = 3650
		}
		random_known_country = {
			limit = {
				is_league_leader = yes
				is_league_friend = ROOT
			}
			add_opinion = {
				who = ROOT
				modifier = "joined_league_for_land"
			}
			country_event = { id = tyw_events.49 days = 7 }
		}
	}

	option = {
		name = "tyw_events.48.b"
		add_country_modifier = {
			name = "in_league_for_faith"
			duration = 3650
		}
		random_known_country = {
			limit = {
				is_league_leader = yes
				is_league_friend = ROOT
			}
			add_opinion = {
				who = ROOT
				modifier = "joined_league_for_faith"
			}
			country_event = { id = tyw_events.50 days = 7 }
		}
	}
}

# [From] Claims to Fight for Land
country_event = {
	id = tyw_events.49
	title = "tyw_events.49.t"
	desc = "tyw_events.49.d"
	picture = GENERALS_DISCUSSING_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.49.a"
		add_prestige = -10
		add_dip_power = -20
	}
}

# [From] Claims to Fight for Faith
country_event = {
	id = tyw_events.50
	title = "tyw_events.50.t"
	desc = "tyw_events.50.d"
	picture = CATHOLIC_RULERS_PRAYING_eventPicture

	is_triggered_only = yes

	option = {
		name = "tyw_events.50.a"
		add_prestige = 10
		add_dip_power = 20
	}
}