# Palatine Events

namespace = FEE_Palatinate_Events

# Ernst von Mansfeld
country_event = {
	id = FEE_Palatinate_Events.1
	title = FEE_Palatinate_Events.1.T
	desc = FEE_Palatinate_Events.1.D
	picture = NOBLE_ESTATE_eventPicture

	fire_only_once = yes

	trigger = {
		tag = PAL
		NOT = {
			religion = catholic
		}
		hre_leagues_enabled = yes
	}

	mean_time_to_happen = {
		months = 12
		modifier = {
			factor = 0.0001
			is_at_war = yes
		}
	}

	option = {
		name = FEE_Palatinate_Events.1.OPT1

		ai_chance = {
			factor = 50
		}

		add_treasury = -50
		define_general = {
			name = "Ernst von Mansfeld"
			shock = 4
			fire = 4
			manuever = 6
			siege = 0
			trait = cannoneer_personality
		}
	}

	option = {
		name = FEE_Palatinate_Events.1.OPT2

		ai_chance = {
			factor = 50
		}
	}
}

#Imperial Duties and Salic Law
country_event = {
	id = FEE_Palatinate_Events.2
	title = FEE_Palatinate_Events.2.T
	desc = FEE_Palatinate_Events.2.D
	picture = REFORM_eventPicture

	#fire_only_once = yes

	trigger = {
		OR = {
			tag = PAL
			tag = SAX
		}
		NOT = {
			has_country_flag = pal_sax_imperial_duties
		}
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = FEE_Palatinate_Events.2.OPT1.PAL

		trigger = {
			tag = PAL
		}

		ai_chance = {
			factor = 33
		}

		hidden_effect = {
			set_country_flag = pal_sax_imperial_duties
		}

		franconia_area = { add_permanent_claim = ROOT }
		lower_swabia_area = { add_permanent_claim = ROOT }
		lower_rhineland_area = { add_permanent_claim = ROOT }
		palatinate_area = { add_permanent_claim = ROOT }
		upper_swabia_area = { add_permanent_claim = ROOT }
		upper_rhineland_area = { add_permanent_claim = ROOT }
	}

	option = {
		name = FEE_Palatinate_Events.2.OPT1.SAX

		trigger = {
			tag = SAX
		}

		ai_chance = {
			factor = 33
		}

		hidden_effect = {
			set_country_flag = pal_sax_imperial_duties
		}

		braunschweig_area = { add_permanent_claim = ROOT }
		northern_saxony_area = { add_permanent_claim = ROOT }
		south_saxony_area = { add_permanent_claim = ROOT }
		westphalia_area = { add_permanent_claim = ROOT }
	}

	option = {
		name = FEE_Palatinate_Events.2.OPT2
		ai_chance = {
			factor = 33
		}

		hidden_effect = {
			set_country_flag = pal_sax_imperial_duties
		}

		add_years_of_income = -0.5
		add_country_modifier = {
			name = pal_imperial_vicarship
			duration = 10950
		}
		every_neighbor_country = {
			add_opinion = {
				who = ROOT
				modifier = pal_imperial_vicarship_opinion_modifiers
			}
		}
	}

	option = {
		name = FEE_Palatinate_Events.2.OPT3

		ai_chance = {
			factor = 33
		}

		hidden_effect = {
			set_country_flag = pal_sax_imperial_duties
		}

		add_years_of_income = -1
		add_country_modifier = {
			name = pal_salic_law_established
			duration = -1
		}
		add_country_modifier = {
			name = pal_internal_reform
			duration = 7300
		}
	}
}

#The Clevian Succession
country_event = {
	id = FEE_Palatinate_Events.3
	title = FEE_Palatinate_Events.3.T
	desc = FEE_Palatinate_Events.3.D
	picture = DIPLOMACY_eventPicture

	fire_only_once = yes

	trigger = {
		tag = PAL
		exists = KLE
		is_year = 1490
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = FEE_Palatinate_Events.3.OPT1

		ai_chance = {
			factor = 50
		}

		add_casus_belli = {
			type = cb_vassalize_mission
			target = KLE
			months = 240
		}
		if = {
			limit = {
				exists = BRA
			}
			BRA = {
				add_opinion = {
					who = ROOT
					modifier = pal_war_cleves_yes
				}
			}
		}
	}

	option = {
		name = FEE_Palatinate_Events.3.OPT2

		ai_chance = {
			factor = 50
		}

		if = {
			limit = {
				exists = BRA
			}
			BRA = {
				add_opinion = {
					who = ROOT
					modifier = pal_war_cleves_no
				}
			}
		}
	}
}

#Elector's Renovations
country_event = {
	id = FEE_Palatinate_Events.4
	title = FEE_Palatinate_Events.4.T
	desc = FEE_Palatinate_Events.4.D
	picture = CITY_DEVELOPMENT_eventPicture

	fire_only_once = yes

	trigger = {
		tag = PAL
		is_year = 1500
		adm = 3
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = FEE_Palatinate_Events.4.OPT1

		ai_chance = {
			factor = 33
		}

		add_years_of_income = -1
		add_prestige_or_monarch_power = { amount = 25 }
		add_country_modifier = {
			name = pal_hortus_palatinus
			duration = -1
		}
		capital_scope = {
			if = {
				limit = {
					OR = {
						has_building = fort_15th
						has_building = fort_16th
						has_building = fort_17th
						has_building = fort_18th
					}
				}
				owner = {
					add_adm_power = 100
				}
			}
			else = {
				add_building_construction = {
					building = fort_15th
					speed = 0
					cost = 0
				}
			}
			if = {
				limit = {
					has_building = cathedral
				}
				add_base_tax = 1
			}
			else_if = {
				limit = {
					has_building = temple
				}
				add_building_construction = {
					building = cathedral
					speed = 0
					cost = 0
				}
			}
			else = {
				add_building_construction = {
					building = temple
					speed = 0
					cost = 0
				}
			}
		}
		every_owned_province = {
			limit = {
				any_province_in_state = {
					is_capital = yes
				}
			}
			add_base_tax = 1
		}

	}

	option = {
		name = FEE_Palatinate_Events.4.OPT2

		ai_chance = {
			factor = 33
		}

		add_years_of_income = -1
		add_stability_or_adm_power = yes
		add_prestige_or_monarch_power = { amount = 10 }
	}

	option = {
		name = FEE_Palatinate_Events.4.OPT3

		ai_chance = {
			factor = 33
		}

		add_years_of_income = 1
		add_prestige = -10
	}
}

# Development of Amberg
country_event = {
	id = FEE_Palatinate_Events.5
	title = FEE_Palatinate_Events.5.T
	desc = FEE_Palatinate_Events.5.D
	picture = CITY_DEVELOPMENT_eventPicture

	fire_only_once = yes

	trigger = {
		tag = PAL
		owns = 1757
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = FEE_Palatinate_Events.5.OPT1

		ai_chance = {
			factor = 50
		}
		add_years_of_income = -2
		fee_add_estate_burghers_loyalty_effect_big = yes
		1757 = {
			add_permanent_province_modifier = {
				name = pal_amberg_mines
				duration = -1
			}
		}
	}

	option = {
		name = FEE_Palatinate_Events.5.OPT2

		ai_chance = {
			factor = 50
		}

		add_years_of_income = 0.5
		add_stability_or_adm_power = yes
	}
}

# ELECTOR converts to Reformed
country_event = {
	id = FEE_Palatinate_Events.6
	title = FEE_Palatinate_Events.6.T
	desc = FEE_Palatinate_Events.6.D
	picture = RELIGIOUS_CONVERSION_eventPicture

	fire_only_once = yes

	trigger = {
		tag = PAL
		is_subject = no
		is_religion_enabled = protestant
		is_religion_enabled = reformed
		NOT = {
			religion = reformed
		}
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = FEE_Palatinate_Events.6.OPT1

		ai_chance = {
			factor = 33
		}
		tooltip = {
			kill_ruler = yes
			if = {
				limit = {
					has_heir = yes
				}
				kill_heir = {}
			}
		}
		define_ruler = {
			name = "Frederick"
			dynasty = ROOT
			adm = 4
			dip = 6
			mil = 3
			age = 40
			claim = 100
			religion = reformed
			culture = hessian
		}
		if = {
			limit = {
				has_dlc = "Rights of Man"
			}
			add_ruler_personality = scholar_personality
			add_ruler_personality = zealot_personality
			add_ruler_personality = silver_tongue_personality
		}
		if = {
			limit = {
				NOT = {
					religion = reformed
				}
			}
			change_religion = reformed
		}
		else = {
			add_ruler_modifier = {
				name = pal_heidelberg_catechism
				duration = -1
			}
		}
		add_adm_power = 100
	}

	option = {
		name = FEE_Palatinate_Events.6.OPT2

		ai_chance = {
			factor = 33
		}

		add_adm_power = 100
		if = {
			limit = {
				has_dlc = "Rights of Man"
			}
			add_ruler_personality = scholar_personality
		}
		add_country_modifier = {
			name = pal_hidden_reformation
			duration = -1
		}
	}

	option = {
		name = FEE_Palatinate_Events.6.OPT3

		ai_chance = {
			factor = 33
		}

		add_adm_power = 100
		if = {
			limit = {
				religion = reformed
			}
			kill_ruler = yes
			change_religion = catholic
		}
		capital_scope = {
			spawn_rebels = {
				type = reformed_rebels
				size = 1
			}
		}
		add_country_modifier = {
			name = pal_heretic_suppressed
			duration = 9125
		}
	}
}

country_event = {
	id = FEE_Palatinate_Events.7
	title = FEE_Palatinate_Events.7.T
	desc = FEE_Palatinate_Events.7.D
	picture = DIPLOMACY_eventPicture

	fire_only_once = yes

	mean_time_to_happen = {
		months = 12
	}

	trigger = {
		tag = PAL
		is_year = 1550
		exists = SAX
		NOT = {
			is_rival = SAX
		}
		AND = {
			SAX = {
				was_player = no
				OR = {
					religion = reformed
					religion = protestant
				}
			}
			OR = {
				religion = reformed
				religion = protestant
			}
		}
	}

	option = {
		name = FEE_Palatinate_Events.7.OPT1

		ai_chance = {
			factor = 50
		}

		add_mil_power = 100
		SAX = {
			add_opinion = {
				who = ROOT
				modifier = pal_sax_alliance
			}
			reverse_add_opinion = {
				who = ROOT
				modifier = pal_sax_alliance
			}
			add_historical_friend = ROOT
		}
		add_historical_friend = SAX
	}

	option = {
		name = FEE_Palatinate_Events.7.OPT2

		ai_chance = {
			factor = 50
		}

		add_dip_power = 100
		SAX = {
			add_opinion = {
				who = ROOT
				modifier = pal_sax_rivalry
			}
		}
	}
}

#The Winter King
country_event = {
	id = FEE_Palatinate_Events.8
	title = FEE_Palatinate_Events.8.T
	desc = FEE_Palatinate_Events.8.D
	picture = SIEGE_eventPicture

	fire_only_once = yes

	mean_time_to_happen = {
		months = 12
	}

	trigger = {
		tag = PAL
		BOH = {
			is_in_war = {
				attacker_leader = PAL
				casus_belli = cb_restore_personal_union
			}
			owns = 267
		}
		267 = {
			OR = {
				has_building = fort_15th
				has_building = fort_16th
				has_building = fort_17th
				has_building = fort_18th
			}
		}
	}

	option = {
		name = FEE_Palatinate_Events.8.OPT1

		ai_chance = {
			factor = 100
		}

		add_country_modifier = {
			name = pal_winter_blitzkrieg
			duration = 1825
		}
		if = {
			limit = {
				has_dlc = "Rights of Man"
			}
			add_ruler_personality = bold_fighter_personality
		}
		267 = {
			add_province_modifier = {
				name = pal_palatine_collaboration
				duration = 365
			}
		}
	}
}

#King of Bohemia
country_event = {
	id = FEE_Palatinate_Events.9
	title = FEE_Palatinate_Events.9.T
	desc = FEE_Palatinate_Events.9.D
	picture = HRE_eventPicture

	fire_only_once = yes

	mean_time_to_happen = {
		months = 12
	}

	trigger = {
		tag = PAL
		senior_union_with = BOH
		hre_leagues_enabled = yes
	}

	option = {
		name = FEE_Palatinate_Events.9.OPT1

		ai_chance = {
			factor = 33
		}
		BOH = {
			add_opinion = {
				who = ROOT
				modifier = pal_stay_united
			}
			add_liberty_desire = -50
		}
		emperor = {
			add_casus_belli = {
				type = cb_restore_personal_union
				target = BOH
			}
		}
		random_country = {
			limit = {
				in_league = protestant
				is_league_leader = yes
			}
			add_casus_belli = {
				type = cb_liberation
				target = ROOT
			}
		}
		every_country = {
			limit = {
				is_part_of_hre = yes
				in_league = protestant
			}
			add_opinion = {
				who = ROOT
				modifier = pal_union_crowns_opinion
			}
		}
		add_country_modifier = {
			name = pal_union_crowns
			duration = 9125
		}
	}

	option = {
		name = FEE_Palatinate_Events.9.OPT2

		ai_chance = {
			factor = 33
			modifier = {
				factor = 0
				was_player = no
			}
		}

		add_stability = -1
		break_union = BOH
		every_country = {
			limit = {
				is_part_of_hre = yes
				in_league = protestant
			}
			add_opinion = {
				modifier = pal_appeased_league_opinion
				who = ROOT
			}
		}
		emperor = {
			add_casus_belli = {
				type = cb_restore_personal_union
				target = BOH
			}
		}
		add_country_modifier = {
			name = pal_appeased_league
			duration = 9125
		}
	}

	option = {
		name = FEE_Palatinate_Events.9.OPT3

		ai_chance = {
			factor = 33
			modifier = {
				factor = 0
				was_player = no
			}
		}

		add_stability = -1
		random = {
			chance = 50
			break_union = BOH
			if = {
				limit = {
					emperor = { valid_for_personal_unions_trigger = yes }
					BOH = { valid_for_personal_unions_trigger = yes }
				}
				emperor = { create_union = BOH }
			}
		}
		emperor = {
			add_opinion = {
				who = ROOT
				modifier = pal_faitfhful
			}
		}
		add_country_modifier = {
			name = pal_faitfhful_imperial_laws
			duration = 9125
		}
	}
}

# Johann Wilhelm II, Elector Palatine
country_event = {
	id = FEE_Palatinate_Events.10
	title = FEE_Palatinate_Events.10.T
	desc = FEE_Palatinate_Events.10.D
	picture = ADVISOR_eventPicture

	fire_only_once = yes

	trigger = {
		tag = PAL
		is_year = 1680
		NOT = { is_year = 1715 }
	}

	mean_time_to_happen = {
		months = 300
		modifier = {
			factor = 0.9
			has_idea_group = innovativeness_ideas
		}
		modifier = {
			factor = 0.9
			has_idea_group = humanist_ideas
		}
	}

	option = {
		name = FEE_Palatinate_Events.10.OPT1

		add_stability_or_adm_power = yes
		add_adm_power = 50
	}
}