namespace = disaster_fee_division_of_the_habsburg_monarchy

# Start of Disaster
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.1
	title = disaster_fee_division_of_the_habsburg_monarchy.1.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.1.D
	picture = CIVIL_WAR_eventPicture

	major = yes
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			set_country_flag = had_fee_division_of_the_habsburg_monarchy
			set_country_flag = hab_division_1
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.1.OPT1

		add_stability = -1
		add_legitimacy_equivalent = { amount = -50 republican_tradition = -25 }
	}
}

# End of Disaster
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.2
	title = disaster_fee_division_of_the_habsburg_monarchy.2.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.2.D
	picture = GOOD_WITH_MONARCH_eventPicture

	major = yes
	is_triggered_only = yes

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.2.OPT1

		add_stability_or_adm_power_per_stab = { amount = 2 }
		change_government_reform_progress = 100
		add_adm_power = 100
		add_dip_power = 100
		if = {
			limit = {
				has_country_flag = military_reunification
			}
			if = {
				limit = {
					has_reform = feudalism_reform
				}
				remove_government_reform = feudalism_reform
			}
			add_country_modifier = {
				name = fee_division_of_the_habsburg_monarchy_new_habsburg_monarchy
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_country_flag = diplomatic_reunification
			}
			add_country_modifier = {
				name = fee_division_of_the_habsburg_monarchy_restored_habsburg_monarchy
				duration = -1
			}
		}
		hidden_effect = {
			clr_country_flag = hab_division_1
			clr_country_flag = hab_division_2
			clr_country_flag = hab_division_3
			clr_country_flag = hab_division_4
			clr_country_flag = military_reunification
			clr_country_flag = diplomatic_reunification
		}
	}
}

# Release Styria
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.3
	title = disaster_fee_division_of_the_habsburg_monarchy.3.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.3.D
	picture = CIVIL_WAR_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = hab_division_1
		NOT = { exists = STY }
		inner_austria_area = {
			owned_by = ROOT
		}
	}

	mean_time_to_happen = {
		months = 6
	}

	immediate = {
		hidden_effect = {
			inner_austria_area = {
				limit = {
					owned_by = ROOT
				}
				remove_core = ROOT
				add_core = STY
				if = {
					limit = {
						units_in_province = REB
					}
					kill_units = {
						who = REB
					}
				}
			}
			every_owned_province = {
				limit = {
					NOT = { area = inner_austria_area }
					is_core = STY
				}
				set_province_flag = was_core_of_STY
				remove_core = STY
			}
			release = STY
			vassalize = STY
			every_owned_province = {
				limit = {
					has_province_flag = was_core_of_STY
				}
				clr_province_flag = was_core_of_STY
				add_core = STY
			}
			STY = {
				change_government = monarchy
				add_government_reform = feudalism_reform
				adopt_reform_progress = ROOT
				change_religion = new_variable:dominant_religion
				change_primary_culture = new_variable:dominant_culture
				define_ruler = {
					claim = 75
					dynasty = "von Habsburg"
				}
				set_prestige_to_zero = yes
				add_years_of_income = 15
				if = {
					limit = {
						NOT = { treasury = 1000 }
					}
					add_treasury = 1000
				}
				add_yearly_manpower = 15
				if = {
					limit = {
						NOT = { manpower = 5 }
					}
					add_manpower = 5
				}
				capital_scope = {
					build_to_forcelimit = {
						infantry = 0.7
						cavalry = 0.2
						artillery = 0.1
					}
				}
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.3.OPT1

		tooltip = {
			STY = {
				custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_THIS_IS_RELEASED_AS_FREE_TT
			}
		}
		hidden_effect = {
			STY = {
				grant_independence = yes
			}
			if = {
				limit = {
					hre_size = 1
					is_emperor = yes
					NOT = { hre_reform_passed = emperor_erbkaisertum }
					NOT = { hre_reform_passed = erbkaisertum }
					calc_true_if = {
						all_elector = {
							NOT = { tag = ROOT }
						}
						amount = 1
					}
				}
				set_country_flag = electors_can_decide_STY_for_emperor
				every_elector = {
					limit = {
						NOT = { tag = ROOT }
					}
					country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.4 days = 1 }
				}
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.3.OPT2

		add_stability = -1
		tooltip = {
			STY = {
				custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_THIS_IS_RELEASED_AS_VASSAL_TT
			}
		}
		STY = {
			hidden_effect = {
				add_casus_belli = {
					target = ROOT
					type = cb_independence_war
				}
			}
			declare_war_with_cb = {
				who = ROOT
				casus_belli = cb_independence_war
			}
		}
		hidden_effect = {
			if = {
				limit = {
					hre_size = 1
					is_emperor = yes
					NOT = { hre_reform_passed = emperor_erbkaisertum }
					NOT = { hre_reform_passed = erbkaisertum }
					calc_true_if = {
						all_elector = {
							NOT = { tag = ROOT }
						}
						amount = 1
					}
				}
				set_country_flag = electors_can_decide_STY_for_emperor
				every_elector = {
					limit = {
						NOT = { tag = ROOT }
					}
					country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.4 days = 1 }
				}
			}
		}
	}

	after = {
		set_country_flag = hab_division_2
	}
}

# The Return of the King
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.4
	title = disaster_fee_division_of_the_habsburg_monarchy.4.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.4.D
	picture = HRE_eventPicture

	major = yes
	major_trigger = {
		is_emperor = yes
	}
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			set_country_flag = elector_can_back_STY_for_emperor
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.4.OPT1

		ai_chance = {
			factor = 0.4
			modifier = {
				factor = 100
				is_rival = FROM
			}
			modifier = {
				factor = 2
				NOT = {
					has_opinion = {
						who = FROM
						value = 0
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					alliance_with = FROM
					AND = {
						is_subject_of = FROM
						NOT = { liberty_desire = 50 }
					}
				}
			}
			modifier = {
				factor = 2
				is_subject_of = FROM
				liberty_desire = 50
			}
			modifier = {
				factor = 3
				is_subject_of = FROM
				liberty_desire = 75
			}
			modifier = {
				factor = 5
				is_subject_of = FROM
				liberty_desire = 95
			}
		}

		if = {
			limit = {
				is_subject = no
			}
			create_alliance = STY
			if = {
				limit = {
					government = monarchy
					religion_group = STY
				}
				create_marriage = STY
			}
			if = {
				limit = {
					STY = {
						is_in_war = {
							attacker_leader = THIS
							defender_leader = FROM
							casus_belli = cb_independence_war
						}
					}
				}
				join_all_offensive_wars_of = STY
			}
		}
		custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_ELECTOR_BACKS_STY_FOR_EMPEROR_TT
		set_country_flag = elector_backs_STY_for_emperor
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.4.OPT2

		ai_chance = {
			factor = 0.6
			modifier = {
				factor = 0
				is_rival = FROM
			}
			modifier = {
				factor = 0.5
				NOT = {
					has_opinion = {
						who = FROM
						value = 0
					}
				}
			}
			modifier = {
				factor = 100
				OR = {
					alliance_with = FROM
					AND = {
						is_subject_of = FROM
						NOT = { liberty_desire = 50 }
					}
				}
			}
		}

		add_stability_or_adm_power = yes
	}

	after = {
		set_country_flag = elector_decided_about_STY_for_emperor
	}
}

# Hidden Event to trigger the Styria becomes Emperor Event
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.5
	title = disaster_fee_division_of_the_habsburg_monarchy.5.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.5.D
	picture = HRE_eventPicture

	hidden = yes
	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_country_flag = electors_can_decide_STY_for_emperor
		all_elector = {
			OR = {
				NOT = { has_country_flag = elector_can_back_STY_for_emperor }
				has_country_flag = elector_decided_about_STY_for_emperor
			}
		}
	}

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					is_emperor = yes
					calc_true_if = {
						all_elector = {
							has_country_flag = elector_backs_STY_for_emperor
						}
						amount = 4
					}
					STY = {
						religion_group = christian
						has_regency = no
						government = monarchy
					}
					OR = {
						NOT = { has_dlc = "Art of War" }
						AND = {
							has_dlc = "Art of War"
							OR = {
								STY = { religion = ROOT }
								hre_religion_treaty = yes
							}
						}
					}
				}
				country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.6 }
			}
			clr_country_flag = electors_can_decide_STY_for_emperor
			every_country = {
				clr_country_flag = elector_can_back_STY_for_emperor
				clr_country_flag = elector_decided_about_STY_for_emperor
				clr_country_flag = elector_backs_STY_for_emperor
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.5.OPT1

		ai_chance = { factor = 100 }
	}
}

# Styria becomes Emperor
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.6
	title = disaster_fee_division_of_the_habsburg_monarchy.6.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.6.D
	picture = HRE_eventPicture

	major = yes
	is_triggered_only = yes

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.6.OPT1

		tooltip = {
			set_emperor = no
		}
		custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_STY_BECOMES_EMPEROR_TT
		hidden_effect = {
			STY = {
				set_emperor = yes
			}
		}
	}
}

# Release Tirol
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.7
	title = disaster_fee_division_of_the_habsburg_monarchy.7.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.7.D
	picture = CIVIL_WAR_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = hab_division_2
		NOT = { exists = TIR }
		tirol_area = {
			owned_by = ROOT
		}
	}

	mean_time_to_happen = {
		months = 6
	}

	immediate = {
		hidden_effect = {
			tirol_area = {
				limit = {
					owned_by = ROOT
				}
				remove_core = ROOT
				add_core = TIR
				if = {
					limit = {
						units_in_province = REB
					}
					kill_units = {
						who = REB
					}
				}
			}
			every_owned_province = {
				limit = {
					NOT = { area = tirol_area }
					is_core = TIR
				}
				set_province_flag = was_core_of_TIR
				remove_core = TIR
			}
			release = TIR
			vassalize = TIR
			every_owned_province = {
				limit = {
					has_province_flag = was_core_of_TIR
				}
				clr_province_flag = was_core_of_TIR
				add_core = TIR
			}
			TIR = {
				change_government = monarchy
				add_government_reform = feudalism_reform
				adopt_reform_progress = ROOT
				change_religion = new_variable:dominant_religion
				change_primary_culture = new_variable:dominant_culture
				define_ruler = {
					claim = 75
					dynasty = "von Habsburg"
				}
				set_prestige_to_zero = yes
				add_years_of_income = 15
				if = {
					limit = {
						NOT = { treasury = 1000 }
					}
					add_treasury = 1000
				}
				add_yearly_manpower = 15
				if = {
					limit = {
						NOT = { manpower = 5 }
					}
					add_manpower = 5
				}
				capital_scope = {
					build_to_forcelimit = {
						infantry = 0.7
						cavalry = 0.2
						artillery = 0.1
					}
				}
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.7.OPT1

		tooltip = {
			TIR = {
				custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_THIS_IS_RELEASED_AS_FREE_TT
			}
		}
		hidden_effect = {
			TIR = {
				grant_independence = yes
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.7.OPT2

		add_stability = -1
		tooltip = {
			TIR = {
				custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_THIS_IS_RELEASED_AS_VASSAL_TT
			}
		}
		TIR = {
			hidden_effect = {
				add_casus_belli = {
					target = ROOT
					type = cb_independence_war
				}
			}
			declare_war_with_cb = {
				who = ROOT
				casus_belli = cb_independence_war
			}
		}
		custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_RIVALS_MAY_JOIN_VASSAL_IN_WAR_TT
		hidden_effect = {
			if = {
				limit = {
					any_rival_country = {
						NOT = { war_with = ROOT }
					}
				}
				TIR = {
					save_event_target_as = vassal_to_support
				}
				every_rival_country = {
					limit = {
						NOT = { war_with = ROOT }
					}
					country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.26 }
				}
			}
		}
	}

	after = {
		set_country_flag = hab_division_3
	}
}

# Release Hungary (for Austria)
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.8
	title = disaster_fee_division_of_the_habsburg_monarchy.8.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.8.D
	picture = CIVIL_WAR_eventPicture

	major = yes
	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = hab_division_3
		exists = HUN
		overlord_of = HUN
		HUN = {
			OR = {
				junior_union_with = ROOT
				AND = {
					is_expanded_mod_active = { mod = subjects }
					is_subject_of_type = brother_kingdom
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 2
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.8.OPT1

		tooltip = {
			HUN = {
				grant_independence = yes
				add_truce_with = ROOT
			}
		}
		hidden_effect = {
			HUN = {
				country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.9 }
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.8.OPT2

		add_legitimacy_equivalent = { amount = -20 republican_tradition = -10 }
		HUN = {
			add_liberty_desire = 75
		}
	}
}

# Release Hungary (for Hungary)
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.9
	title = disaster_fee_division_of_the_habsburg_monarchy.9.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.9.D
	picture = DIPLOMACY_eventPicture

	is_triggered_only = yes

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.9.OPT1

		add_truce_with = FROM
		tooltip = {
			grant_independence = yes
		}
		hidden_effect = {
			if = {
				limit = {
					is_lesser_in_union = yes
				}
				break_union = yes
			}
			else = {
				overlord = {
					ROOT = {
						grant_independence = yes
					}
				}
			}
		}
		define_ruler = {
			name = "Maximilian"
			dynasty = "von Habsburg"
			age = 16
			claim = 50
			adm = 2
			dip = 4
			mil = 4
		}
		hidden_effect = {
			kill_heir = { allow_new_heir = no }
		}
	}
}

# Release Bohemia (for Austria)
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.10
	title = disaster_fee_division_of_the_habsburg_monarchy.10.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.10.D
	picture = CIVIL_WAR_eventPicture

	major = yes
	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = hab_division_3
		exists = BOH
		overlord_of = BOH
		BOH = {
			OR = {
				junior_union_with = ROOT
				AND = {
					is_expanded_mod_active = { mod = subjects }
					is_subject_of_type = brother_kingdom
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 2
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.10.OPT1

		tooltip = {
			BOH = {
				grant_independence = yes
				add_truce_with = ROOT
			}
		}
		hidden_effect = {
			BOH = {
				country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.11 }
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.10.OPT2

		add_legitimacy_equivalent = { amount = -20 republican_tradition = -10 }
		BOH = {
			add_liberty_desire = 75
		}
	}
}

# Release Bohemia (for Bohemia)
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.11
	title = disaster_fee_division_of_the_habsburg_monarchy.11.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.11.D
	picture = DIPLOMACY_eventPicture

	is_triggered_only = yes

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.11.OPT1

		add_truce_with = FROM
		tooltip = {
			grant_independence = yes
		}
		hidden_effect = {
			if = {
				limit = {
					is_lesser_in_union = yes
				}
				break_union = yes
			}
			else = {
				overlord = {
					ROOT = {
						grant_independence = yes
					}
				}
			}
		}
		define_ruler = {
			dynasty = "von Habsburg"
			claim = 100
		}
		hidden_effect = {
			kill_heir = { allow_new_heir = no }
		}
	}
}

# Release Swabia
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.12
	title = disaster_fee_division_of_the_habsburg_monarchy.12.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.12.D
	picture = CIVIL_WAR_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = hab_division_3
		NOT = { exists = SWA }
		any_owned_province = {
			culture = swabian
		}
	}

	mean_time_to_happen = {
		months = 12
	}

	immediate = {
		hidden_effect = {
			every_owned_province = {
				limit = {
					culture = swabian
				}
				remove_core = ROOT
				add_core = SWA
				if = {
					limit = {
						units_in_province = REB
					}
					kill_units = {
						who = REB
					}
				}
			}
			every_owned_province = {
				limit = {
					NOT = { culture = swabian }
					is_core = SWA
				}
				set_province_flag = was_core_of_SWA
				remove_core = SWA
			}
			release = SWA
			vassalize = SWA
			every_owned_province = {
				limit = {
					has_province_flag = was_core_of_SWA
				}
				clr_province_flag = was_core_of_SWA
				add_core = SWA
			}
			SWA = {
				change_government = monarchy
				add_government_reform = feudalism_reform
				adopt_reform_progress = ROOT
				change_religion = new_variable:dominant_religion
				change_primary_culture = new_variable:dominant_culture
				define_ruler = {
					claim = 75
					dynasty = "von Habsburg"
				}
				set_prestige_to_zero = yes
				add_years_of_income = 15
				if = {
					limit = {
						NOT = { treasury = 1000 }
					}
					add_treasury = 1000
				}
				add_yearly_manpower = 15
				if = {
					limit = {
						NOT = { manpower = 5 }
					}
					add_manpower = 5
				}
				capital_scope = {
					build_to_forcelimit = {
						infantry = 0.7
						cavalry = 0.2
						artillery = 0.1
					}
				}
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.12.OPT1

		tooltip = {
			SWA = {
				custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_THIS_IS_RELEASED_AS_FREE_TT
			}
		}
		hidden_effect = {
			SWA = {
				grant_independence = yes
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.12.OPT2

		add_stability = -1
		tooltip = {
			SWA = {
				custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_THIS_IS_RELEASED_AS_VASSAL_TT
			}
		}
		SWA = {
			hidden_effect = {
				add_casus_belli = {
					target = ROOT
					type = cb_independence_war
				}
			}
			declare_war_with_cb = {
				who = ROOT
				casus_belli = cb_independence_war
			}
		}
		custom_tooltip = FEE_DIVISION_OF_THE_HABSBURG_MONARCHY_SOUTH_GERMANS_MAY_JOIN_VASSAL_IN_WAR_TT
		hidden_effect = {
			if = {
				limit = {
					any_country = {
						is_subject = no
						NOT = { war_with = ROOT }
						NOT = { alliance_with = ROOT }
						NOT = { alliance_with = SWA }
						capital_scope = {
							region = south_german_region
						}
					}
				}
				SWA = {
					save_event_target_as = vassal_to_support
				}
				every_country = {
					limit = {
						is_subject = no
						NOT = { war_with = ROOT }
						NOT = { alliance_with = ROOT }
						NOT = { alliance_with = SWA }
						capital_scope = {
							region = south_german_region
						}
					}
					country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.26 }
				}
			}
		}
	}

	after = {
		set_country_flag = hab_division_4
	}
}

# Reunification?
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.13
	title = disaster_fee_division_of_the_habsburg_monarchy.13.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.13.D
	picture = COURT_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = hab_division_4
		is_at_war = no
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.13.OPT1

		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_diplomatic_efforts
			duration = 27375
		}
		set_country_flag = diplomatic_reunification
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.13.OPT2

		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_reunification_wars
			duration = 1825
		}
		if = {
			limit = {
				exists = STY
				NOT = { overlord_of = STY }
			}
			add_casus_belli = {
				target = STY
				type = cb_restore_personal_union
			}
		}
		if = {
			limit = {
				exists = TIR
				NOT = { overlord_of = TIR }
			}
			add_casus_belli = {
				target = TIR
				type = cb_restore_personal_union
			}
		}
		if = {
			limit = {
				exists = HUN
				NOT = { overlord_of = HUN }
			}
			add_casus_belli = {
				target = HUN
				type = cb_restore_personal_union
			}
		}
		if = {
			limit = {
				exists = BOH
				NOT = { overlord_of = BOH }
			}
			add_casus_belli = {
				target = BOH
				type = cb_restore_personal_union
			}
		}
		if = {
			limit = {
				exists = SWA
				NOT = { overlord_of = SWA }
			}
			add_casus_belli = {
				target = SWA
				type = cb_restore_personal_union
			}
		}
		set_country_flag = military_reunification
	}
}

# Proposal from [From.Capital.GetName]
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.14
	title = disaster_fee_division_of_the_habsburg_monarchy.14.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.14.D
	picture = DIPLOMACY_eventPicture

	is_triggered_only = yes

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.14.OPT1

		ai_chance = {
			factor = 0.5
			modifier = {
				factor = 0.5
				army_strength = { who = FROM value = 2 }
			}
			modifier = {
				factor = 2
				NOT = { army_strength = { who = FROM value = 0.5 } }
			}
		}

		if = {
			limit = {
				OR = {
					is_subject_of = FROM
					tag = STY
					tag = TIR
					tag = SWA
				}
			}
			tooltip = {
				FROM = {
					inherit = ROOT
				}
			}
		}
		else = {
			tooltip = {
				FROM = {
					create_union = ROOT
				}
				add_opinion = {
					who = FROM
					modifier = fee_division_of_the_habsburg_monarchy_acceptance
				}
				reverse_add_opinion = {
					who = FROM
					modifier = fee_division_of_the_habsburg_monarchy_acceptance
				}
				add_liberty_desire = -30
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.15 days = 3 }
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.14.OPT2

		ai_chance = {
			factor = 0.5
			modifier = {
				factor = 2
				army_strength = { who = FROM value = 2 }
			}
			modifier = {
				factor = 0.5
				NOT = { army_strength = { who = FROM value = 0.5 } }
			}
		}

		tooltip = {
			FROM = {
				add_casus_belli = {
					target = ROOT
					type = cb_restore_personal_union
				}
			}
			if = {
				limit = {
					OR = {
						tag = STY
						tag = TIR
					}
				}
				every_owned_province = {
					limit = {
						OR = {
							culture = FROM
							culture = austrian
						}
					}
					add_core = FROM
				}
			}
			else = {
				FROM = {
					add_dip_power = 100
				}
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.16 days = 3 }
			}
		}
	}
}

# [From.GetName] Accepts!
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.15
	title = disaster_fee_division_of_the_habsburg_monarchy.15.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.15.D
	picture = GOOD_WITH_MONARCH_eventPicture

	is_triggered_only = yes

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.15.OPT1

		if = {
			limit = {
				FROM = {
					OR = {
						is_subject_of = ROOT
						tag = STY
						tag = TIR
						tag = SWA
					}
				}
			}
			inherit = FROM
		}
		else = {
			hidden_effect = {
				FROM = {
					if = {
						limit = {
							is_subject = yes
						}
						overlord = {
							PREV = { grant_independence = yes }
						}
					}
				}
			}
			create_union = FROM
			add_opinion = {
				who = FROM
				modifier = fee_division_of_the_habsburg_monarchy_acceptance
			}
			reverse_add_opinion = {
				who = FROM
				modifier = fee_division_of_the_habsburg_monarchy_acceptance
			}
			FROM = {
				add_liberty_desire = -30
			}
		}
	}
}

# [From.GetName] Refuses!
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.16
	title = disaster_fee_division_of_the_habsburg_monarchy.16.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.16.D
	picture = BAD_WITH_MONARCH_eventPicture

	is_triggered_only = yes

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.16.OPT1

		add_casus_belli = {
			target = FROM
			type = cb_restore_personal_union
		}
		if = {
			limit = {
				FROM = {
					OR = {
						tag = STY
						tag = TIR
					}
				}
			}
			FROM = {
				every_owned_province = {
					limit = {
						OR = {
							culture = ROOT
							culture = austrian
						}
					}
					add_core = ROOT
				}
			}
		}
		else = {
			add_dip_power = 100
		}
	}
}

# Proposal to Styria [deleted]
#	country_event = {
#		id = disaster_fee_division_of_the_habsburg_monarchy.17
#		title = disaster_fee_division_of_the_habsburg_monarchy.17.T
#		desc = disaster_fee_division_of_the_habsburg_monarchy.17.D
#		picture = DIPLOMACY_eventPicture
#
#		fire_only_once = yes
#
#		trigger = {
#			OR = {
#				tag = HAB
#				was_tag = HAB
#			}
#			has_disaster = fee_division_of_the_habsburg_monarchy
#			has_country_flag = diplomatic_reunification
#			has_country_flag = hab_division_3
#			exists = STY
#			STY = {
#				OR = {
#					is_free_or_tributary_trigger = yes
#					AND = {
#						is_subject_of = ROOT
#						years_in_vassalage_under = {
#							who = ROOT
#							years = 5
#							all_subject_country = yes
#						}
#						NOT = { liberty_desire = 50 }
#					}
#				}
#			}
#			NOT = { war_with = STY }
#		}
#
#		mean_time_to_happen = {
#			months = 12
#		}
#
#		option = {
#			name = disaster_fee_division_of_the_habsburg_monarchy.17.OPT1
#
#			STY = {
#				country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.14 days = 3 }
#			}
#		}
#
#		option = {
#			name = disaster_fee_division_of_the_habsburg_monarchy.17.OPT2
#
#			add_legitimacy_equivalent = { amount = 10 republican_tradition = 5 }
#		}
#	}

# Proposal to Tirol
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.18
	title = disaster_fee_division_of_the_habsburg_monarchy.18.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.18.D
	picture = DIPLOMACY_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = diplomatic_reunification
		has_country_flag = hab_division_3
		exists = TIR
		TIR = {
			OR = {
				is_free_or_tributary_trigger = yes
				AND = {
					is_subject_of = ROOT
					years_in_vassalage_under = {
						who = ROOT
						years = 5
						all_subject_country = yes
					}
					NOT = { liberty_desire = 50 }
				}
			}
		}
		NOT = { war_with = TIR }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.18.OPT1

		TIR = {
			country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.14 days = 3 }
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.18.OPT2

		add_legitimacy_equivalent = { amount = 10 republican_tradition = 5 }
	}
}

# Proposal to Swabia
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.19
	title = disaster_fee_division_of_the_habsburg_monarchy.19.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.19.D
	picture = DIPLOMACY_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = diplomatic_reunification
		has_country_flag = hab_division_4
		exists = SWA
		SWA = {
			OR = {
				is_free_or_tributary_trigger = yes
				AND = {
					is_subject_of = ROOT
					years_in_vassalage_under = {
						who = ROOT
						years = 5
						all_subject_country = yes
					}
					NOT = { liberty_desire = 50 }
				}
			}
		}
		NOT = { war_with = SWA }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.19.OPT1

		SWA = {
			country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.14 days = 3 }
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.19.OPT2

		add_legitimacy_equivalent = { amount = 10 republican_tradition = 5 }
	}
}

# Proposal to Hungary
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.20
	title = disaster_fee_division_of_the_habsburg_monarchy.20.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.20.D
	picture = DIPLOMACY_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = diplomatic_reunification
		has_country_flag = hab_division_3
		exists = HUN
		HUN = {
			is_free_or_tributary_trigger = yes
			dynasty = "von Habsburg"
		}
		NOT = { war_with = HUN }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.20.OPT1

		HUN = {
			country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.14 days = 3 }
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.20.OPT2

		add_legitimacy_equivalent = { amount = 10 republican_tradition = 5 }
	}
}

# Proposal to Bohemia
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.21
	title = disaster_fee_division_of_the_habsburg_monarchy.21.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.21.D
	picture = DIPLOMACY_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = diplomatic_reunification
		has_country_flag = hab_division_3
		exists = BOH
		BOH = {
			is_free_or_tributary_trigger = yes
			dynasty = "von Habsburg"
		}
		NOT = { war_with = BOH }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.21.OPT1

		BOH = {
			country_event = { id = disaster_fee_division_of_the_habsburg_monarchy.14 days = 3 }
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.21.OPT2

		add_legitimacy_equivalent = { amount = 10 republican_tradition = 5 }
	}
}

# Nobility Protest
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.22
	title = disaster_fee_division_of_the_habsburg_monarchy.22.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.22.D
	picture = DIPLOMACY_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = military_reunification
	}

	mean_time_to_happen = {
		months = 24
	}

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					any_owned_province = {
						is_island = no
						is_capital = no
					}
				}
				random_owned_province = {
					limit = {
						is_island = no
						is_capital = no
					}
					save_event_target_as = target_province_1
				}
			}
			else_if = {
				limit = {
					any_owned_province = {
						is_island = no
					}
				}
				random_owned_province = {
					limit = {
						is_island = no
					}
					save_event_target_as = target_province_1
				}
			}
			else = {
				random_owned_province = {
					save_event_target_as = target_province_1
				}
			}
			if = {
				limit = {
					any_owned_province = {
						is_island = no
						is_capital = no
						NOT = { province_id = event_target:target_province_1 }
					}
				}
				random_owned_province = {
					limit = {
						is_island = no
						is_capital = no
						NOT = { province_id = event_target:target_province_1 }
					}
					save_event_target_as = target_province_2
				}
			}
			else_if = {
				limit = {
					any_owned_province = {
						is_island = no
						NOT = { province_id = event_target:target_province_1 }
					}
				}
				random_owned_province = {
					limit = {
						is_island = no
						NOT = { province_id = event_target:target_province_1 }
					}
					save_event_target_as = target_province_2
				}
			}
			else_if = {
				limit = {
					any_owned_province = {
						NOT = { province_id = event_target:target_province_1 }
					}
				}
				random_owned_province = {
					limit = {
						NOT = { province_id = event_target:target_province_1 }
					}
					save_event_target_as = target_province_2
				}
			}
			else = {
				random_owned_province = {
					save_event_target_as = target_province_2
				}
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.22.OPT1

		event_target:target_province_1 = {
			noble_rebels = 3
		}
		event_target:target_province_2 = {
			noble_rebels = 3
		}
	}
}

# Order Restored in Styria
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.23
	title = disaster_fee_division_of_the_habsburg_monarchy.23.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.23.D
	picture = COURT_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = military_reunification
		has_country_flag = hab_division_2
		exists = STY
		overlord_of = STY
		STY = {
			is_subject_other_than_tributary_trigger = yes
		}
	}

	mean_time_to_happen = {
		months = 6
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.23.OPT1

		ai_chance = {
			factor = 0.5
			modifier = {
				factor = 0
				STY = { ai = no }
			}
		}

		inherit = STY
		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_forcible_annexation
			duration = 5475
		}
		every_subject_country = {
			limit = {
				NOT = { tag = STY }
			}
			add_liberty_desire = 20
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.23.OPT2

		ai_chance = {
			factor = 0.5
		}

		add_stability_or_adm_power = yes
		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_generous_peace
			duration = 5475
		}
		every_subject_country = {
			add_liberty_desire = -10
		}
	}
}

# Order Restored in Tirol
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.24
	title = disaster_fee_division_of_the_habsburg_monarchy.24.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.24.D
	picture = COURT_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = military_reunification
		has_country_flag = hab_division_3
		exists = TIR
		overlord_of = TIR
		TIR = {
			is_subject_other_than_tributary_trigger = yes
		}
	}

	mean_time_to_happen = {
		months = 6
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.24.OPT1

		add_years_of_income = 0.5
		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_accelerated_reintegration
			duration = 9125
		}
		every_subject_country = {
			add_liberty_desire = 10
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.24.OPT2

		add_stability_or_adm_power = yes
		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_fair_treatment
			duration = 5475
		}
		every_subject_country = {
			add_liberty_desire = -5
		}
	}
}

# Order Restored in Bohemia
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.25
	title = disaster_fee_division_of_the_habsburg_monarchy.25.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.25.D
	picture = COURT_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			tag = HAB
			was_tag = HAB
		}
		has_disaster = fee_division_of_the_habsburg_monarchy
		has_country_flag = military_reunification
		has_country_flag = hab_division_3
		exists = BOH
		senior_union_with = BOH
	}

	mean_time_to_happen = {
		months = 6
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.25.OPT1

		add_stability = -1
		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_bohemian_crown_hab
			duration = 9125
		}
		BOH = {
			add_country_modifier = {
				name = fee_division_of_the_habsburg_monarchy_bohemian_crown_boh
				duration = 9125
			}
			random_owned_province = {
				pretender_rebels = 2
			}
			random_owned_province = {
				pretender_rebels = 2
			}
		}
		every_subject_country = {
			add_liberty_desire = 10
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.25.OPT2

		add_stability_or_adm_power = yes
		add_country_modifier = {
			name = fee_division_of_the_habsburg_monarchy_benevolent_rulership
			duration = 5475
		}
		BOH = {
			add_liberty_desire = -20
		}
	}
}

# [vassal_to_support.GetName] in Trouble!
country_event = {
	id = disaster_fee_division_of_the_habsburg_monarchy.26
	title = disaster_fee_division_of_the_habsburg_monarchy.26.T
	desc = disaster_fee_division_of_the_habsburg_monarchy.26.D
	picture = DIPLOMACY_eventPicture

	is_triggered_only = yes

	trigger = {
		has_saved_event_target = vassal_to_support
		event_target:vassal_to_support = {
			is_at_war = yes
			is_in_war ={
				defender_leader = THIS
				attacker_leader = FROM
			}
		}
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.26.OPT1

		ai_chance = {
			factor = 0.33
			modifier = {
				factor = 10
				is_rival = FROM
			}
			modifier = {
				factor = 5
				is_enemy = FROM
			}
			modifier = {
				factor = 2
				NOT = {
					has_opinion = {
						who = FROM
						value = 0
					}
				}
			}
			modifier = {
				factor = 3
				NOT = {
					has_opinion = {
						who = FROM
						value = -50
					}
				}
			}
			modifier = {
				factor = 5
				NOT = {
					has_opinion = {
						who = FROM
						value = -100
					}
				}
			}
			modifier = {
				factor = 2
				has_opinion = {
					who = event_target:vassal_to_support
					value = 100
				}
			}
		}

		join_all_defensive_wars_of = event_target:vassal_to_support
	}

	option = {
		name = disaster_fee_division_of_the_habsburg_monarchy.26.OPT2

		ai_chance = {
			factor = 0.66
			modifier = {
				factor = 0
				is_rival = FROM
			}
			modifier = {
				factor = 0.25
				is_enemy = FROM
			}
			modifier = {
				factor = 2
				is_at_war = yes
			}
			modifier = {
				factor = 1.5
				NOT = { army_size = FROM }
			}
			modifier = {
				factor = 3
				NOT = { army_size = 10 }
				FROM = {
					army_size = 20
				}
			}
			modifier = {
				factor = 1.1
				has_opinion = {
					who = FROM
					value = 50
				}
			}
			modifier = {
				factor = 1.25
				has_opinion = {
					who = FROM
					value = 100
				}
			}
			modifier = {
				factor = 1.5
				has_opinion = {
					who = FROM
					value = 150
				}
			}
			modifier = {
				factor = 2
				has_opinion = {
					who = FROM
					value = 200
				}
			}
		}

		add_prestige = -5
	}
}