
palatinate_conquest_group = {
	slot = 1
	generic = no
	ai = yes
	potential = {
		tag = PAL
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes
	
	pal_expand_a_bit = {
		icon = mission_have_two_subjects
		required_missions = { }

		completed_by = 1618.05.20
		
		trigger = {
			num_of_cities = 7
			army_size = 5 # modified
		}
		
		effect = {
			franconia_area = {
				limit = {
					NOT = { is_permanent_claim = root }
					NOT = { is_core = root }
				}
				add_permanent_claim = root
			}
			upper_franconia_area = {
				limit = {
					NOT = { is_permanent_claim = root }
					NOT = { is_core = root }
				}
				add_permanent_claim = root
			}
			70 = {
				if = {
					limit = {
						NOT = { is_claim = root }
						NOT = { is_core = root }
					}
					add_claim = root
				}
			}
			2955 = {
				if = {
					limit = {
						NOT = { is_claim = root }
						NOT = { is_core = root }
					}
					add_claim = root
				}
			}
			4711 = {
				if = {
					limit = {
						NOT = { is_claim = root }
						NOT = { is_core = root }
					}
					add_claim = root
				}
			}
		}
	}
	pal_connect_oberpfalz = {
		icon = mission_build_up_to_force_limit
		required_missions = { pal_expand_a_bit }

		provinces_to_highlight = {
			OR = {
				province_id = 77
				province_id = 1757
			}
			OR = {
				NOT = { owned_by = root }
				is_in_capital_area = no
			}
		}
		
		trigger = {
			77 = {
				owned_by = root
				is_in_capital_area = yes
			}
			1757 = {
				owned_by = root
				is_in_capital_area = yes
			}
		}
		
		effect = {
			if = {
				limit = {
					valid_for_personal_unions_trigger = yes
					exists = BAV
					BAV = {
						valid_for_personal_unions_trigger = yes
					}
				}
				add_casus_belli = {
					type = cb_restore_personal_union
					months = 300
					target = BAV
				}
			}
			else_if = {
				limit = {
					valid_for_personal_unions_trigger = yes
					OR = {
						AND = {
							exists = ING
							ING = {
								valid_for_personal_unions_trigger = yes
							}
						}
						AND = {
							exists = UBV
							UBV = {
								valid_for_personal_unions_trigger = yes
							}
						}
						AND = {
							exists = LBV
							LBV = {
								valid_for_personal_unions_trigger = yes
							}
						}
					}
				}
				if = {
					limit = {
						valid_for_personal_unions_trigger = yes
						exists = UBV
						UBV = {
							valid_for_personal_unions_trigger = yes
						}
					}
					add_casus_belli = {
						type = cb_restore_personal_union
						months = 300
						target = UBV
					}
				}
				if = {
					limit = {
						valid_for_personal_unions_trigger = yes
						exists = LBV
						LBV = {
							valid_for_personal_unions_trigger = yes
						}
					}
					add_casus_belli = {
						type = cb_restore_personal_union
						months = 300
						target = LBV
					}
				}
				if = {
					limit = {
						valid_for_personal_unions_trigger = yes
						exists = ING
						ING = {
							valid_for_personal_unions_trigger = yes
						}
					}
					add_casus_belli = {
						type = cb_restore_personal_union
						months = 300
						target = ING
					}
				}
			}
			else = {
				upper_bavaria_area = {
					limit = {
						NOT = { is_permanent_claim = root }
						NOT = { is_core = root }
					}
					add_permanent_claim = root
				}
				lower_bavaria_area = {
					limit = {
						NOT = { is_permanent_claim = root }
						NOT = { is_core = root }
					}
					add_permanent_claim = root
				}
				east_bavaria_area = {
					limit = {
						NOT = { is_permanent_claim = root }
						NOT = { is_core = root }
					}
					add_permanent_claim = root
				}
			}
		}
	}
	pal_one_true_wittelsbach = {
		icon = mission_unite_home_region
		required_missions = { pal_connect_oberpfalz }

		provinces_to_highlight = {
			OR = {
				area = upper_bavaria_area
				area = lower_bavaria_area
				area = east_bavaria_area
			}
			ROOT = {
				NOT = {
					num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
						value = 8
						OR = {
							area = upper_bavaria_area
							area = lower_bavaria_area
							area = east_bavaria_area
						}
					}
				}
			}
			NOT = { country_or_non_sovereign_subject_holds = root }
		}

		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				value = 8
				OR = {
					area = upper_bavaria_area
					area = lower_bavaria_area
					area = east_bavaria_area
				}
			}
			if = {
				limit = {
					exists = BAV
				}
				BAV = {
					OR = {
						is_subject_of = root
						exists = no
					}
				}
			}
			if = {
				limit = {
					exists = UBV
				}
				UBV = {
					OR = {
						is_subject_of = root
						exists = no
					}
				}
			}
			if = {
				limit = {
					exists = LBV
				}
				LBV = {
					OR = {
						is_subject_of = root
						exists = no
					}
				}
			}
			if = {
				limit = {
					exists = ING
				}
				ING = {
					OR = {
						is_subject_of = root
						exists = no
					}
				}
			}
		}
		
		effect = {
			north_rhine_area = {
				limit = {
					NOT = { is_permanent_claim = root }
					NOT = { is_core = root }
				}
				add_permanent_claim = root
			}
			lower_rhineland_area = {
				limit = {
					NOT = { is_permanent_claim = root }
					NOT = { is_core = root }
				}
				add_permanent_claim = root
			}
			upper_rhineland_area = {
				limit = {
					NOT = { is_permanent_claim = root }
					NOT = { is_core = root }
				}
				add_permanent_claim = root
			}
			alsace_area = {
				limit = {
					NOT = { is_permanent_claim = root }
					NOT = { is_core = root }
				}
				add_permanent_claim = root
			}
		}
	}
	
	pal_kingdom_of_the_rhine = {
		icon = mission_empire
		position = 5
		required_missions = { pal_one_true_wittelsbach }
		
		provinces_to_highlight = {
			OR = {
				area = north_rhine_area
				area = lower_rhineland_area
				area = upper_rhineland_area
				area = alsace_area
			}
			ROOT = {
				NOT = {
					num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
						value = 11 #out of 14
						OR = {
							area = north_rhine_area
							area = lower_rhineland_area
							area = upper_rhineland_area
							area = alsace_area
						}
					}
				}
			}
			NOT = { country_or_non_sovereign_subject_holds = root }
		}

		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				value = 11 #out of 14
				OR = {
					area = north_rhine_area
					area = lower_rhineland_area
					area = upper_rhineland_area
					area = alsace_area
				}
			}
		}
		
		effect = {
			if = {
				limit = {
					NOT = { government_rank = 3 }
					OR = {
						is_elector = yes
						is_part_of_hre = no
					}
				}
				set_government_rank = 3
			}
			add_country_modifier = {
				name = pal_kingdom_of_the_rhine_mod
				duration = -1
			}
		}
	}
}




palatinate_other_group = {
	slot = 2
	generic = no
	ai = yes
	potential = {
		tag = PAL
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes
	
	pal_religious_leadership = {
		icon = mission_religious
		position = 2
		required_missions = { pal_expand_a_bit }

		completed_by = 1618.08.26

		provinces_to_highlight = {
			ROOT = {
				OR = {
					NOT = { has_dlc = "Art of War" }
					is_part_of_hre = no
					hre_religion_treaty = yes
				}
			}
			owner = {
				is_neighbor_of = root
				NOT = { religion = root }
			}
		}
		
		trigger = {
			OR = {
				AND = {
					any_owned_province = {
						is_reformation_center = yes
					}
					religious_unity = 1
				}
				if = {
					limit  = {
						has_dlc = "Art of War"
						is_part_of_hre = yes
						hre_religion_treaty = no
					}
					OR = {
						is_league_leader = yes
						AND = {
							hre_religion_locked = yes
							custom_trigger_tooltip = {
								tooltip = hre_religion_is_root_tooltip
								hre_religion = root
							}
						}
					}
				}
				else = {
					custom_trigger_tooltip = {
						tooltip = emp_bav_center_of_counter_reformation_tooltip2
						had_global_flag = {
							flag = reformation_started
							days = 18250
						}
					}
					calc_true_if = {
						desc = pal_religious_leadership_trigger_tooltip
						amount = 5
						all_neighbor_country = {
							religion = root
						}
					}
				}
			}
		}
		
		effect = {
			if = {
				limit = {
					valid_for_personal_unions_trigger = yes
					exists = BOH
					BOH = {
						valid_for_personal_unions_trigger = yes
					}
				}
				add_casus_belli = {
					type = cb_restore_personal_union
					months = 300
					target = BOH
				}
			}
			else = {
				bohemia_area = {
					limit = {
						NOT = { is_permanent_claim = root }
						NOT = { is_core = root }
					}
					add_permanent_claim = root
				}
				moravia_area = {
					limit = {
						NOT = { is_permanent_claim = root }
						NOT = { is_core = root }
					}
					add_permanent_claim = root
				}
				erzgebirge_area = {
					limit = {
						NOT = { is_permanent_claim = root }
						NOT = { is_core = root }
					}
					add_permanent_claim = root
				}
			}
		}
	}
	
	pal_kingdom_of_bohemia = {
		icon = mission_monarch_in_throne_room
		required_missions = { pal_religious_leadership }
		
		provinces_to_highlight = {
			OR = {
				area = bohemia_area
				area = moravia_area
				area = erzgebirge_area
			}
		}

		trigger = {
			bohemia_area = {
				type = all
				country_or_non_sovereign_subject_holds = root
			}
			moravia_area = {
				type = all
				country_or_non_sovereign_subject_holds = root
			}
			erzgebirge_area = {
				type = all
				country_or_non_sovereign_subject_holds = root
			}
		}
		
		effect = {
			add_country_modifier = {
				name = pal_great_king
				duration = 10950
			}
		}
	}
	
	pal_protect_from_france = {
		icon = mission_assemble_an_army
		required_missions = { pal_kingdom_of_bohemia }

		provinces_to_highlight = {
			owner = {
				NOT = { tag = root }
				capital_scope = {
					region = france_region
				}
				army_size = root
			}
		}
		
		trigger = {
			OR = {
				custom_trigger_tooltip = {
					tooltip = pal_protect_from_france_trigger_tooltip
					NOT = {
						any_country = {
							capital_scope = {
								region = france_region
							}
							NOT = { ROOT = { army_size = prev } }
						}
					}
				}
				FRA = {
					religion = root
					OR = {
						alliance_with = root
						is_subject_of = root
					}
					has_opinion = {
						who = root
						value = 150
					}
				}
			}
		}
		
		effect = {
			if = {
				limit = { #has completed the mission objectives
					OR = {
						custom_trigger_tooltip = {
							tooltip = pal_protect_from_france_trigger_tooltip
							NOT = {
								any_country = {
									capital_scope = {
										region = france_region
									}
									NOT = { ROOT = { army_size = prev } }
								}
							}
						}
						FRA = {
							religion = root
							OR = {
								alliance_with = root
								is_subject_of = root
							}
							has_opinion = {
								who = root
								value = 150
							}
						}
					}
				}
				if = {
					limit = {
						NOT = {
							FRA = {
								religion = root
								OR = {
									alliance_with = root
									is_subject_of = root
								}
								has_opinion = {
									who = root
									value = 150
								}
							}
						}
					}
					wallonia_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					lorraine_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					bourgogne_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					champagne_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					if = {
						limit = {
							any_owned_province = {
								any_neighbor_province = {
									region = france_region
									NOT = { area = wallonia_area }
									NOT = { area = lorraine_area }
									NOT = { area = bourgogne_area }
									NOT = { area = champagne_area }
									NOT = { is_permanent_claim = root }
									NOT = { is_core = root }
								}
							}
						}
						every_province = {
							limit = {
								region = france_region
								NOT = { area = wallonia_area }
								NOT = { area = lorraine_area }
								NOT = { area = bourgogne_area }
								NOT = { area = champagne_area }
								NOT = { is_permanent_claim = root }
								NOT = { is_core = root }
								any_neighbor_province = {
									owned_by = root
								}
							}
							add_permanent_claim = root
						}
					}
				}
				else = {
					add_dip_power = 200
					add_historical_friend = FRA
				}
			}
			else = {
				custom_tooltip = pal_protect_from_france_effect_tooltip1
				tooltip = {
					add_dip_power = 200
					add_historical_friend = FRA
				}
				custom_tooltip = pal_protect_from_france_effect_tooltip2
				tooltip = {
					wallonia_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					lorraine_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					bourgogne_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					champagne_area = {
						limit = {
							NOT = { is_permanent_claim = root }
							NOT = { is_core = root }
						}
						add_permanent_claim = root
					}
					if = {
						limit = {
							any_owned_province = {
								any_neighbor_province = {
									region = france_region
									NOT = { area = wallonia_area }
									NOT = { area = lorraine_area }
									NOT = { area = bourgogne_area }
									NOT = { area = champagne_area }
									NOT = { is_permanent_claim = root }
									NOT = { is_core = root }
								}
							}
						}
						every_province = {
							limit = {
								region = france_region
								NOT = { area = wallonia_area }
								NOT = { area = lorraine_area }
								NOT = { area = bourgogne_area }
								NOT = { area = champagne_area }
								NOT = { is_permanent_claim = root }
								NOT = { is_core = root }
								any_neighbor_province = {
									owned_by = root
								}
							}
							add_permanent_claim = root
						}
					}
				}
			}
		}
	}

	pal_glorious_palatine = {
		icon = mission_early_modern_university
		position = 5
		required_missions = { pal_protect_from_france }
		
		trigger = {
			prestige = 75
			capital_scope = {
				development = 30
			}
			has_adm_advisor_3 = yes
			has_dip_advisor_3 = yes
			has_mil_advisor_3 = yes
			is_in_deficit = no
		}
		
		effect = {
			add_prestige = 25
			add_country_modifier = {
				name = pal_glorious_palatine_mod
				duration = -1
			}
		}
	}
}