########################################
# Events for Bohemia
#
# written by Johan Andersson
########################################

namespace = flavor_boh
normal_or_historical_nations = yes

#Hussites march on Prague
country_event = {
	id = flavor_boh.1
	title = flavor_boh.1.t
	desc = flavor_boh.1.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = HUSSITE_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = CIVIL_WAR_eventPicture
	}

	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		owns = 266
		is_year = 1446
		NOT = { is_year = 1500 }
		is_at_war = no
		OR = {
			religion = catholic
			religion = hussite
		}
		is_free_or_tributary_trigger = yes
	}
	
	mean_time_to_happen = {
		months = 17
	}
	immediate = {
		hidden_effect = {
			set_country_flag = first_hussite_king
			set_country_flag = no_election_of_new_ruler_event_trigger
			if = {
				limit = {
					ai = yes
					has_dlc = "Winds of Change"
				}
				country_event = { id = flavor_boh.14 }
			}
		}
	}
	after = {
		clr_country_flag = no_election_of_new_ruler_event_trigger
	}
	
	option = { # Convert to Hussite
		ai_chance = { factor = 10 }
		name = flavor_boh.1.a
		set_country_flag = hussite_regency_mission_flag
		if = {
			limit = {
				has_regency = no
			}
			tooltip = {
				kill_ruler = yes
			}
		}
		if = {
			limit = {
				has_heir = yes
			}
			remove_heir = {}
		}
		change_religion = hussite
		define_ruler = {
			name = "000"
			dynasty = "00000000"
			adm = 5
			dip = 4
			mil = 3
			religion = hussite
			culture = czech
			age = 25
		}
		hidden_effect = {
			set_ruler_flag = ruler_cant_trigger_this_event_flag
		}
		if = {
			limit = {
				has_states_general_mechanic = yes
			}
			change_statists_vs_orangists = 1
		}
		if = {
			limit = {
				has_dlc = "Rights of Man" 
			}
			hidden_effect = { add_ruler_personality_ancestor = { key = zealot } }
		}
		add_reform_desire = 0.02
	}
	
	option = { # Hussite King, Catholic nation - tolerance option
		ai_chance = { factor = 90 }
		set_country_flag = hussite_regency_mission_flag
		name = flavor_boh.1.c
		add_papal_influence = -100
		if = {
			limit = {
				has_regency = no
			}
			tooltip = {
				kill_ruler = yes
			}
		}
		if = {
			limit = {
				has_heir = yes
			}
			remove_heir = {}
		}
		define_ruler = {
			name = "000"
			dynasty = "00000000"
			adm = 5
			dip = 4
			mil = 3
			religion = hussite
			culture = czech
			age = 25
		}
		hidden_effect = {
			set_ruler_flag = ruler_cant_trigger_this_event_flag
		}
		if = {
			limit = {
				has_states_general_mechanic = yes
			}
			change_statists_vs_orangists = 1
		}
		add_reform_desire = 0.01
		add_ruler_modifier = {
			name = "boh_hussite_king"
			duration = -1
		}
		PAP = {
			country_event = { id = flavor_boh.9 }
		}
	}
	
	option = { # Fight them
		name = flavor_boh.1.b
		set_country_flag = hussite_regency_mission_flag
		266 = {
			spawn_rebels = {
				type = pretender_rebels
				size = 1
				leader = "Jir"
				leader_dynasty = "z Podebrad"
			}		
		}
		random_owned_province = {
			limit = {
				NOT = { province_id = 266 }
			}
			spawn_rebels = {
				type = pretender_rebels
				size = 1
			}
		}
		if = {
			limit = { religion = catholic }
			add_papal_influence = 10
			PAP = {
				add_opinion = {
					who = root
					modifier = boh_papal_reconciled
				}
			}
		}
	}
}

#The Heretic King
country_event = {
	id = flavor_boh.2
	title = flavor_boh.2.t
	desc = flavor_boh.2.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = HUSSITE_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = COURT_eventPicture
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		OR = {
			AND = {
				religion = catholic
				ruler_religion = hussite
			}
			religion = hussite
		}
		has_regency = no
		NOT = { has_ruler_flag = hussite_king }
		NOT = { is_religion_enabled = protestant }
		NOT = {
			check_variable = {
				which = hussite_changes_to_repent
				value = 3
			}
		}
		had_country_flag = {
			flag = first_hussite_king
			days = 182
		}
	}
	
	immediate = {
		hidden_effect = {
			set_ruler_flag = hussite_king
			if = {
				limit = {
					NOT = {
						check_variable = {
							which = hussite_changes_to_repent
							value = 1
						}
					}
				}
				set_variable = {
					which = hussite_changes_to_repent
					value = 1
				}					
			}
			else_if = {
				limit = {
					check_variable = {
						which = hussite_changes_to_repent
						value = 1
					}
				}
				change_variable = {
					which = hussite_changes_to_repent
					value = 1
				}
			}
		}
	}
	
	option = { # reconciliation
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0.1
				is_year = 1470
			}
		}
		name = flavor_boh.2.a
		if = {
			limit = { exists = PAP }
			add_papal_influence = 5
			PAP = {
				add_opinion = {
					who = root
					modifier = boh_papal_reconciled
				}
			}
		}
		add_reform_desire = -0.01
		if = {
			limit = {
				religion = hussite
			}
			change_religion = catholic
			every_owned_province = {
				limit = {
					religion = hussite
				}
				change_religion = catholic
			}
		}
		if = {
			limit = {
				ruler_religion = hussite
			}
			set_ruler_religion = catholic
		}
		if = {
			limit = {
				heir_religion = hussite
			}
			set_heir_religion = catholic
		}
	}
	option = {
		name = flavor_boh.2.b
		ai_chance = {
			factor = 10
		}
		add_ruler_modifier = {
			name = "boh_hussite_king"
			duration = -1
		}
		add_reform_desire = 0.005
		if = {
			limit = {
				religion = catholic
			}
			excommunicate = ROOT
		}
		else_if = {
			limit = {
				religion = hussite
			}
			custom_tooltip = rejected_reconciliation_tt
			set_ruler_flag = hussite_heretic # catholics can cleanse heresy against you for 15 years
		}
		if = {
			limit = {
				exists = PAP
			}
			PAP = { country_event = { id = flavor_boh.9 } }
		}
	}
}

# Confederacy of Zelena Hora
country_event = {
	id = flavor_boh.3
	title = flavor_boh.3.t
	desc = flavor_boh.3.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = HUSSITE_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = BAD_WITH_MONARCH_eventPicture
	}
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_year = 1465
		owns = 265
		owns = 2970
		OR = {
			religion = hussite
			ruler_religion = hussite
		}
	}
	
	immediate = {
		hidden_effect = {
			set_country_flag = confederacy_of_zelena_hora
		}
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	option = {
		name = flavor_boh.3.a
		add_prestige = -5
		tooltip = {
			265 = {
				spawn_rebels = {
					type = religious_rebels
					size = 1
				}
			}
			2970 = {
				spawn_rebels = {
					type = religious_rebels
					size = 1
				}
			}
		}
		if = {
			limit = {
				is_neighbor_of = HUN
				HUN = {
					religion = catholic
					has_regency = no
				}
			}
			HUN = {
				country_event = { id = flavor_hun.13 }
			}
			else = {
				hidden_effect = {
					265 = {
						spawn_rebels = {
							type = religious_rebels
							size = 1
						}
					}
					2970 = {
						spawn_rebels = {
							type = religious_rebels
							size = 1
						}
					}
				}
			}
		}
	}
}

# The Vladislav Hall
country_event = {
	id = flavor_boh.4
	title = flavor_boh.4.t
	desc = flavor_boh.4.d
	picture = FORT_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		owns = 266
		is_year = 1493
	}
	
	mean_time_to_happen = {
		months = 32
	}
	
	option = {
		name = flavor_boh.4.a
		add_prestige = 50
	}
}

# Municipal Constitution
country_event = {
	id = flavor_boh.5
	title = flavor_boh.5.t
	desc = flavor_boh.5.d
	picture = DEBATE_REPUBLICAN_eventPicture
	
	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_year = 1500
		NOT = { is_year = 1550 }
		NOT = { ADM = 3 }
	}
	
	mean_time_to_happen = {
		months = 12
	}
	
	option = {
		name = flavor_boh.5.a
		ai_chance = { factor = 90 }
		change_estate_land_share = {
			estate = estate_nobles
			share = 3
		}
	}
	option = {
		name = flavor_boh.5.b
		add_stability = -1
		random_owned_province = {
			spawn_rebels = {
				type = noble_rebels
				size = 1
			}
		}
	}
}

# Brahe & Kepler
country_event = {
	id = flavor_boh.6
	title = flavor_boh.6.t
	desc = flavor_boh.6.d
	picture = INVENTION_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_year = 1599
		owns = 266
	}
	
	mean_time_to_happen = {
		months = 12
	}
	
	option = {
		name = flavor_boh.6.a
		trigger = {
			num_of_ports = 1
		}
		ai_chance = { factor = 90 }	
		add_navy_tradition = 10
	}
	option = {
		name = flavor_boh.6.b
		add_army_tradition = 10
	}	
}

# Hussite Traditions
country_event = {
	id = flavor_boh.7
	title = flavor_boh.7.t
	desc = flavor_boh.7.d

	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ADULT_BAPTISME_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = POPE_PREACHING_eventPicture
	}
	
	is_triggered_only = yes # initially triggered by Protestant event and then by itself
	
	trigger = {
		OR = {
			OR = {
				tag = BOH
				was_tag = BOH
			}
			any_owned_province = {
				religion = hussite
			}
		}
	}
	
	option = { # Remain Hussite
		ai_chance = {
			factor = 20
		}
		trigger = {
			religion = hussite
		}
		name = "flavor_boh.7.a"
		if = {
			limit = {
				has_dlc = "Art of War"
			}
			custom_tooltip = remain_hussite_tt # warning that you won't get a side for the league war
		}
		add_prestige = 10
		add_church_power = 10
	}
	
	option = { # Switch to Protestant
		ai_chance = {
			factor = 80
		}
		trigger = {
			religion = hussite
		}
		name = "flavor_boh.7.b"
		change_religion = protestant
		every_owned_province = {
			limit = {
				religion = hussite
			}
			change_religion = protestant
		}
		if = {
			limit = {
				tag = BOH
			}
			every_country = {
				limit = {
					NOT = { tag = BOH }
					OR = {
						religion = hussite
						any_owned_province = {
							religion = hussite
						}
					}
				}
				country_event = {
					id = flavor_boh.7
					days = 3
				}
			}
		}
	}
	
	option = { # Hussite provinces convert
		trigger = {
			NOT = { 
				religion = hussite 
			}
		}
		name = "flavor_boh.7.b"
		every_owned_province = {
			limit = {
				religion = hussite
			}
			change_religion = protestant
		}
	}
}

# Winter King in Prague
country_event = {
	id = flavor_boh.8
	title = flavor_boh.8.t
	desc = flavor_boh.8.d
	picture = COURT_eventPicture
	
	fire_only_once = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_emperor = no
		religion = catholic
		any_owned_province = {
			religion = protestant
			OR = {
				culture = czech
				culture = czech_new
			}
		}
		is_year = 1580
	}
	
	
	option = {
		name = flavor_boh.8.a
		ai_chance = { factor = 90 }	
		change_religion = protestant
		if = {
			limit = {
				emperor = { religion = catholic }
			}
			emperor = {
				add_casus_belli = {	
					target = BOH
					type = cb_religious_conformance
					months = 1200
				}
				add_opinion = {
					who = root
					modifier = boh_protestant_king
				}										
			}
		}

		every_neighbor_country = {
			limit = {
				is_emperor = no
				religion = catholic
				num_of_cities = 5
			}
			add_casus_belli = {	
				target = BOH
				type = cb_religious_conformance
				months = 1200
			}	
			add_opinion = {
				who = root
				modifier = boh_protestant_king
			}							
		}
	}
}


# The Hussites of Bohemia (Papal reaction)
country_event = {
	id = flavor_boh.9
	title = flavor_boh.9.t
	desc = flavor_boh.9.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ADULT_BAPTISME_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = POPE_PREACHING_eventPicture
	}
	
	is_triggered_only = yes

	option = {
		name = flavor_boh.9.a #Condemn the [From.Monarch.GetTitle]
		ai_chance = { factor = 90 }
		add_devotion = 10
		add_reform_desire = -0.01
		FROM = {
			country_event = { id = flavor_boh.10 }
			add_opinion = {
				who = root
				modifier = boh_heretic_hussite
			}
		}
	}
	option = {
		name = flavor_boh.9.b #We must seek Reconciliation
		ai_chance = { factor = 10 }
		add_reform_desire = 0.005
		add_devotion = -10
		FROM = {
			country_event = { id = flavor_boh.11 }
			add_opinion = {
				who = root
				modifier = boh_papal_reconciled
			}
		}
	}
}

# The Pope Condemns [Root.Monarch.GetName]
country_event = {
	id = flavor_boh.10
	title = flavor_boh.10.t
	desc = flavor_boh.10.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ADULT_BAPTISME_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = POPE_PREACHING_eventPicture
	}
	
	fire_only_once = yes
	is_triggered_only = yes

	
	option = {
		name = flavor_boh.10.a
		add_prestige = -5 #Real effects are in the modifier you already got.
	}
}

# Papacy remains 
country_event = {
	id = flavor_boh.11
	title = flavor_boh.11.t
	desc = flavor_boh.11.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ADULT_BAPTISME_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = POPE_PREACHING_eventPicture
	}
	
	fire_only_once = yes
	is_triggered_only = yes

	
	option = {
		name = flavor_boh.11.a
		PAP = {
			add_opinion = {
				who = ROOT
				modifier = boh_papal_reconciled
			}
		}
	}
}

# New Events for Bohemia by Daniel Tolman

# Compacts of Basel
country_event = {
	id = flavor_boh.12
	title = flavor_boh.12.t
	desc = flavor_boh.12.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ADULT_BAPTISME_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = POPE_PREACHING_eventPicture
	}
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_subject = no
		NOT = { is_year = 1450 }
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = { # religious toleration
		name = flavor_boh.12.a
		custom_tooltip = first_hussite_tt
		add_country_modifier = { # tolerance heretics
			name = "religious_peace_hussites"
			duration = 3650
		}
	}
	
	option = { # abandon religious peace
		name = flavor_boh.12.b
		add_country_modifier = {
			name = "hussite_persecution"
			duration = 3650
		}
	}
}

province_event = {
	id = flavor_boh.13
	title = none
	desc = none
	picture = none
	hidden = yes	
	fire_only_once = yes
	is_triggered_only = yes
	
	immediate = {
		remove_reform_center = hussite
	}
	
	option = { }
}

########################################
# 1.37 Bohemia by Parmelion
########################################

country_event = {
    id = flavor_boh.14
    title = none
    desc = none
    picture = none
    hidden = yes
    is_triggered_only = yes
    option = {
		ai_chance = { 
			factor = 50
			modifier = {
				factor = 0
				NOT = { religion = catholic }
			}
		}
        set_country_flag = boh_catholic_missions
        clr_country_flag = boh_hussite_missions
        swap_non_generic_missions = yes
    }
    option = {
		ai_chance = { 
			factor = 50
			modifier = {
				factor = 0
				NOT = { religion = hussite }
			}
		}
        set_country_flag = boh_hussite_missions
        clr_country_flag = boh_catholic_missions
        swap_non_generic_missions = yes
    }
}

#The Aftermath of the Hussite Wars
country_event = {
	id = flavor_boh.15
	title = flavor_boh.15.t
	desc = flavor_boh.15.d
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = HUSSITE_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = BATTLE_eventPicture
	}
	
	immediate = {
		hidden_effect = {
			bohemia_area = {
				add_devastation = 50
			}
			erzgebirge_area = {
				add_devastation = 20
			}
			moravia_area = {
				add_devastation = 20
			}
			if = {
				limit = {
					has_dlc = "Winds of Change"
				}
				add_country_modifier = {
					name = boh_hussite_destruction
					duration = 10950
				}
			}
		}
	}

	is_triggered_only = yes

	option = {
		name = flavor_boh.15.a
		custom_tooltip = boh_starting_event_devastation
		if = {
			limit = {
				has_dlc = "Winds of Change"
			}
			tooltip = {
				add_country_modifier = {
					name = boh_hussite_destruction
					duration = 10950
					desc = boh_complete_mission
				}
			}
		}
	}
}
	
#Legacy of Great Moravia
country_event = {
	id = flavor_boh.16
	title = flavor_boh.16.t
	desc = flavor_boh.16.d
	picture = GOOD_WITH_MONARCH_eventPicture

	is_triggered_only = yes

	option = {
		name = flavor_boh.16.a
		set_country_flag = boh_unlocked_great_moravia
		custom_tooltip = boh_unlock_great_moravia_tt
		change_ruler_stat = {
			type = mil
			amount = 2
		}
		add_ruler_modifier = {
			name = boh_svatopluks_heir
			duration = -1
		}
	}
}

#Reformatio Sigismundi
country_event = {
	id = flavor_boh.17
	title = flavor_boh.17.t
	desc = flavor_boh.17.d
	picture = HRE_eventPicture

	is_triggered_only = yes

	option = {
		name = flavor_boh.17.a
		add_imperial_influence = 20
		add_country_modifier = {
			name = "boh_reformatio_sigismundi_hre"
			duration = -1
		}
	}
	
	option = {
		name = flavor_boh.17.b
		unlock_estate_privilege = { estate_privilege = estate_nobles_reformatio_sigismundi }
	}
	
	option = {
		name = flavor_boh.17.c
		change_ruler_stat = {
			type = dip
			amount = 3
		}
	}
}

#Jan Rokycana
country_event = {
	id = flavor_boh.18
	title = flavor_boh.18.t
	desc = flavor_boh.18.d
	picture = CHURCH_ESTATE_1_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_year = 1450
		religion = hussite
		NOT = { is_year = 1460 }
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
    option = {
	    name = flavor_boh.18.a
		ai_chance = { factor = 40 }
		define_advisor = {
			type = theologian
			name = "Jan Rokycana"
			culture = czech
			religion = hussite
			discount = yes
			skill = 3
		}
	}
	
    option = {
	    name = flavor_boh.18.b
		ai_chance = { factor = 40 }
		define_advisor = {
			type = inquisitor
			name = "Jan Rokycana"
			culture = czech
			religion = hussite
			discount = yes
			skill = 3
		}
	}
	
    option = {
	    name = flavor_boh.18.c
		ai_chance = { factor = 10 }
		add_dip_power = 50
	}
}

#Kilian Ignaz Dientzenhofer
country_event = {
	id = flavor_boh.19
	title = flavor_boh.19.t
	desc = flavor_boh.19.d
	picture = ADVISOR_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_year = 1720
		NOT = { is_year = 1740 }
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
    option = {
	    name = flavor_boh.19.a
		ai_chance = { factor = 40 }
		add_country_modifier = {
			name = "boh_dientzenhofer"
			duration = 3650
		}
	}
	
    option = {
	    name = flavor_boh.19.b
		ai_chance = { factor = 10 }
		add_adm_power = 50
	}
}

#Jan Amos Komensky
country_event = {
	id = flavor_boh.20
	title = flavor_boh.20.t
	desc = flavor_boh.20.d
	picture = UNIVERSITY_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		is_year = 1640
		NOT = { is_year = 1660 }
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
    option = {
	    name = flavor_boh.20.a
		ai_chance = { factor = 50 }
		define_advisor = {
			type = philosopher
			name = "Jan Amos Komensk"
			culture = czech
			religion = hussite
			discount = yes
			skill = 3
		}
	}
	
    option = {
	    name = flavor_boh.20.b
		ai_chance = { factor = 50 }
		if = {
			limit = {
				has_dlc = "Rule Britannia"
			}
			change_innovativeness = 3
		}
		else = {
			change_government_reform_progress = 50
		}
	}
}

#Ji Melantrich z Aventina
country_event = {
	id = flavor_boh.21
	title = flavor_boh.21.t
	desc = flavor_boh.21.d
	picture = ADVISOR_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = BOH
			was_tag = BOH
		}
		has_unembraced_institution = printing_press
		is_year = 1550
		NOT = { is_year = 1570 }
	}
	
	mean_time_to_happen = {
		months = 40
	}
	
    option = {
	    name = flavor_boh.21.a
		ai_chance = { factor = 10 }
		define_advisor = {
			type = philosopher
			name = "Jir Melantrich z Aventina"
			culture = czech
			religion = hussite
			discount = yes
			skill = 3
		}
	}
	
    option = {
	    name = flavor_boh.21.b
		ai_chance = { factor = 90 }
		capital_scope = {
			add_institution_embracement = {
				which = printing_press
				value = 25
			}
		}
	}
}