rig_hansa_mission_slot = {
	slot = 1
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Lions of the North"
	}
	potential = {
		tag = RIG
		has_dlc = "Lions of the North"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	rig_riga_in_the_hansa = {
		icon = mission_heart_of_the_hansa
		position = 1
		required_missions = {  }
		provinces_to_highlight = {
			OR = {
				AND = {
					province_id = 45
					NOT = { has_trader = ROOT }
				}
				AND = {
					owned_by = HSA
					HSA = {
						NOT = {
							has_opinion = {
								who = ROOT
								value = 150
							}
						}
					}
				}
			}
		}
		trigger = {
			if = {
				limit = {
					exists = HSA
				}
				reverse_has_opinion = {
					who = HSA
					value = 150
				}
			}
			45 = {
				has_trader = ROOT
			}
		}
		effect = {
			add_dip_power = 50
			45 = {
				add_trade_modifier = {
					who = ROOT
					duration = 18250
					power = 20
					key = rig_riga_in_the_hansa_tt
				}
			}
		}
	}

	rig_dominate_the_baltic_trade = {
		icon = mission_seize_north_sea_trade
		position = 2
		required_missions = { rig_riga_in_the_hansa }
		provinces_to_highlight = {
			province_id = 1926
		}
		trigger = {
			1926 = {
				OR = {
					is_strongest_trade_power = ROOT
					trade_share = {
						country = ROOT
						share = 10
					}
				}
			}
			religion_group = christian
			NOT = { religion = orthodox }
		}
		effect = {
			add_years_of_income = 3
			if = {
				limit = {
					mission_completed = rig_improve_papal_relations
					mission_completed = rig_lubeck_trade
				}
				if = {
					limit = {
						religion = catholic
					}
					country_event = {
						id = flavor_rig.10
					}
				}
				else = {
					country_event = {
						id = flavor_rig.11
					}
				}
				hidden_effect = {
					set_variable = {
						which = sold_indulgences
						value = 0
					}
					set_variable = {
						which = raided_churches
						value = 0
					}
				}
			}
			else = {
				custom_tooltip = rig_dominate_the_baltic_trade_tt
			}
		}
	}

	rig_mercs_mission = {
		icon = mission_hessian_jaeger_corps
		position = 4
		required_missions = { rig_sell_indulgences }
		provinces_to_highlight = {}
		trigger = {
			num_of_mercenaries = 20
			is_in_deficit = no
		}
		effect = {
			add_country_modifier = {
				name = rig_mercenary_contracts
				duration = 9125
			}
			if = {
				limit = { has_dlc = "Cradle of Civilization" }
				fifty_percent_merc_army_professionalism_cost = yes
				add_army_professionalism = 10
			}
			else = {
				hidden_effect = {
					fifty_percent_merc_army_professionalism_cost = yes
				}
				add_army_tradition = 20
			}
		}
	}

	rig_rent_condotitieri = {
		icon = mission_among_the_great_powers
		position = 5
		required_missions = { rig_mercs_mission }
		provinces_to_highlight = {
			is_capital = yes
			owner = { 
				ROOT = { knows_country = PREV }
				religion = ROOT
				is_at_war = yes
				NOT = { is_subject_of = ROOT }
				is_free_or_tributary_trigger = yes
				NOT = { ROOT = { is_renting_condottieri_to = PREV } }
				NOT = { alliance_with = ROOT }
				NOT = { tag = ROOT }
				NOT = { subsidised_percent_amount = { value = 0.2 } }
				any_war_enemy_country = {
					NOT = { religion = ROOT }
					OR = {
						is_in_war = {
							defender_leader = THIS
						}
						is_in_war = {
							attacker_leader = THIS
						}
					}
				}
			}
		}
		trigger = {
			calc_true_if = {
				desc = liv_support_other_catholics_ct
				all_known_country = {
					religion = ROOT
					NOT = { is_subject_of = ROOT }
					is_free_or_tributary_trigger = yes
					is_at_war = yes
					OR = {
						subsidised_percent_amount = { value = 0.2 }
						ROOT = { is_renting_condottieri_to = PREV }
						AND = {
							alliance_with = ROOT
							any_war_enemy_country = {
								war_with = ROOT
								war_with = PREV
							}
						}
					}
					any_war_enemy_country = {
						NOT = { religion = ROOT }
						OR = {
							is_in_war = {
								defender_leader = THIS
							}
							is_in_war = {
								attacker_leader = THIS
							}
						}
					}
				}
				amount = 3
			}
		}
		effect = {
			add_power_projection = {
				type = mission_rewards_power_projection
				amount = 100
			}
			add_adm_power = 100
			add_dip_power = 100
			add_mil_power = 100
		}
	}
}

rig_empire_mission_slot = {
	slot = 2
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Lions of the North"
	}
	potential = {
		tag = RIG
		has_dlc = "Lions of the North"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	rig_ally_the_emperor = {
		icon = mission_alliances
		position = 1
		required_missions = {  }
		provinces_to_highlight = {
			owned_by = emperor
		}
		trigger = {
			if = {
				limit = {
					hre_size = 1
				}
				reverse_has_opinion = {
					who = emperor
					value = 75
				}
			}
			else = {
				total_development = 100
			}
		}
		effect = {
			if = {
				limit = {
					hre_size = 1
					is_part_of_hre = no
				}
				country_event = {
					id = flavor_rig.9
				}
			}
			else = {
				add_adm_power = 75
				add_dip_power = 75
				add_mil_power = 75
			}
		}
	}

	rig_lubeck_trade = {
		icon = mission_hanseatic_city
		position = 2
		required_missions = { 
			rig_riga_in_the_hansa
			rig_ally_the_emperor
		}
		provinces_to_highlight = {
			province_id = 45
		}
		trigger = {
			45 = {
				OR = {
					is_strongest_trade_power = ROOT
					trade_share = {
						country = ROOT
						share = 3
					}
				}
			}
			mercantilism = 12
			religion_group = christian
			NOT = { religion = orthodox }
		}
		effect = {
			define_advisor = {
				type = trader
				skill = 1
				cost_multiplier = 0.25
			}
			add_mercantilism = 3
			if = {
				limit = {
					mission_completed = rig_dominate_the_baltic_trade
					mission_completed = rig_improve_papal_relations
				}
				if = {
					limit = {
						religion = catholic
					}
					country_event = {
						id = flavor_rig.10
					}
				}
				else = {
					country_event = {
						id = flavor_rig.11
					}
				}
				hidden_effect = {
					set_variable = {
						which = sold_indulgences
						value = 0
					}
					set_variable = {
						which = raided_churches
						value = 0
					}
				}
			}
			else = {
				custom_tooltip = rig_lubeck_trade_tt
			}
		}
	}

	rig_sell_indulgences = {
		icon = mission_sell_indulgences
		position = 3
		required_missions = { 
			rig_dominate_the_baltic_trade
			rig_lubeck_trade
			rig_improve_papal_relations
		}
		provinces_to_highlight = {}
		trigger = {
			if = {
				limit = {
					religion = catholic
				}
				has_reform = merchant_theocracy_reform
				custom_trigger_tooltip = {
					tooltip = rig_sell_indulgences_at
					check_variable = {
						which = sold_indulgences
						value = 5
					}
				}
			}
			else_if = {
				limit = {
					OR = {
						religion = hussite
						religion = protestant
						religion = reformed
						religion = anglican
					}
				}
				has_reform = reformer_state_reform
				custom_trigger_tooltip = {
					tooltip = rig_sell_indulgences_bt
					check_variable = {
						which = raided_churches
						value = 5
					}
				}
			}
			else = {
				OR = {
					calc_true_if = {
						custom_trigger_tooltip = {
							tooltip = swe_catholic_defender_of_faith_ct
							all_known_country = {
								force_converted_by = ROOT
								religion = ROOT
							}
						}
						amount = 5
					}
					custom_trigger_tooltip = {
						tooltip = nor_spread_the_reformation_tt
						check_variable = { which = num_converted_religion value = 15 }
					}
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = rig_influential_religious_power
				duration = -1
			}
		}
	}

	rig_the_baltic_bank = {
		icon = mission_entrepot_of_india
		position = 4
		required_missions = { rig_sell_indulgences }
		provinces_to_highlight = {}
		trigger = {
			trade_income_percentage = 0.5
			monthly_income = 10
		}
		effect = {
			add_mercantilism = 5
			add_country_modifier = {
				name = rig_commerce_master
				duration = 9125
			}
		}
	}

	rig_finance_great_powers = {
		icon = dominant_economy
		position = 5
		required_missions = { rig_the_baltic_bank }
		provinces_to_highlight = {
			has_discovered = ROOT
			owner = {
				NOT = { tag = ROOT }
				NOT = { is_subject_of = ROOT }
				OR = {
					is_great_power = yes
					total_development = 300
				}
			}
		}
		trigger = {
			if = {
				limit = {
					OR = {
						has_dlc = "Emperor"
						has_dlc = "Rights of Man"
					}
				}
				calc_true_if = {
					desc = rig_finance_great_powers_ct
					all_known_country = {
						is_great_power = yes
						subsidised_percent_amount = {
							value = 0.1
						}
					}
					amount = 4
				}
			}
			else = {
				calc_true_if = {
					desc = rig_finance_great_powers_dt
					all_known_country = {
						total_development = 300
						subsidised_percent_amount = {
							value = 0.1
						}
					}
					amount = 4
				}
			}
			is_in_deficit = no
			NOT = { num_of_loans = 1 }
			NOT = { corruption = 1 }
		}
		effect = {
			add_mercantilism = 3
			custom_tooltip = rig_finance_great_powers_tt
			hidden_effect = {
				every_known_country = {
					limit = {
						knows_country = ROOT
						subsidised_percent_amount = {
							value = 0.1
						}
					}
					add_opinion = {
						who = ROOT
						modifier = rig_rigan_investment
					}
				}
			}
		}
	}
}

rig_religion_mission_slot = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Lions of the North"
	}
	potential = {
		tag = RIG
		has_dlc = "Lions of the North"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	rig_improve_papal_relations = {
		icon = influence_the_church
		position = 2
		required_missions = { 
		}
		provinces_to_highlight = {
			OR = {
				AND = {
					province_id = 38
					OR = {
						NOT = { is_capital_of = ROOT }
						NOT = { has_tax_building_trigger = yes }
					}
				}
				AND = {
					owned_by = PAP
					NOT = {
						PAP = {
							has_opinion = {
								who = ROOT
								value = 100
							}
						}
					}
				}
			}
		}
		trigger = {
			38 = {
				is_capital_of = ROOT
				has_tax_building_trigger = yes
			}
			if = {
				limit = {
					religion = catholic
				}
				reverse_has_opinion = {
					who = PAP
					value = 100
				}
				papal_influence = 25
			}
			else = {
				religion_group = christian
				NOT = { religion = orthodox }
				stability = 1
			}
		}
		effect = {
			if = {
				limit = {
					religion = catholic
				}
				capital_scope = {
					add_cardinal = yes
				}
			}
			else = {
				add_adm_power = 100
			}
			if = {
				limit = {
					mission_completed = rig_dominate_the_baltic_trade
					mission_completed = rig_lubeck_trade
				}
				if = {
					limit = {
						religion = catholic
					}
					country_event = {
						id = flavor_rig.10
					}
				}
				else = {
					country_event = {
						id = flavor_rig.11
					}
				}
				hidden_effect = {
					set_variable = {
						which = sold_indulgences
						value = 0
					}
					set_variable = {
						which = raided_churches
						value = 0
					}
				}
			}
			else = {
				custom_tooltip = rig_improve_papal_relations_tt
			}
			custom_tooltip = rig_establish_religious_dominance_ct
			set_country_flag = war_against_heresy_flag
		}
	}

	rig_establish_religious_dominance = {
		icon = catholic_confraternity
		position = 4
		required_missions = { 
			rig_sell_indulgences
		}
		provinces_to_highlight = {
			OR = {
				AND = {
					owned_by = ROOT
					NOT = { religion = ROOT }
				}
				AND = {
					is_capital = yes
					has_discovered = ROOT
					is_part_of_hre = yes
					owner = {
						NOT = { tag = ROOT }
						NOT = { religion = ROOT }
						NOT = { force_converted_by = ROOT }
					}
				}
			}
		}
		trigger = {
			is_religion_enabled = protestant
			OR = {
				AND = {
					religion_group = christian
					NOT = { religion = catholic }
				}
				AND = {
					religion = catholic
					has_country_modifier = counter_reformation
				}
				current_age = age_of_absolutism
				current_age = age_of_revolutions
			}
			religious_unity = 1
			OR = {
				calc_true_if = {
					desc = rig_establish_religious_dominance_bt
					all_known_country = {
						is_part_of_hre = yes
						religion = ROOT
						force_converted_by = ROOT
					}
					amount = 4
				}
				NOT = { hre_size = 1 }
			}
		}
		effect = {
			if = {
				limit = {
					has_dlc = "Cradle of Civilization"
					has_reform = reformer_state_reform
				}
				custom_tooltip = rig_establish_religious_dominance_tt
			}
			set_country_flag = 15_trade_power_for_propogate_religion
			add_devotion = 50
			add_prestige = 25
			add_papal_influence = 100
			add_church_power = 100
			add_fervor = 50
		}
	}

	rig_defend_the_catholic_league = {
		icon = mission_spread_the_reformation
		position = 5
		required_missions = { rig_establish_religious_dominance }
		provinces_to_highlight = {
			OR = {
				region = baltic_region
				region = north_german_region
				region = south_german_region
				region = poland_region
			}
			OR = {
				NOT = { religion = root }
				NOT = { owner = { religion = root } }
			}
			NOT = {
				root = {
					calc_true_if = {
						amount = 50
						all_province = {
							OR = {
								region = baltic_region
								region = north_german_region
								region = south_german_region
								region = poland_region
							}
							religion = root
						}
					}
				}
			}
			NOT = {
				root = {
					calc_true_if = {
						amount = 150
						all_province = {
							OR = {
								region = baltic_region
								region = north_german_region
								region = south_german_region
								region = poland_region
							}
							owner = { religion = root }
						}
					}
				}
			}
		}

		trigger = {
			custom_trigger_tooltip = {
				tooltip = emp_bav_center_of_counter_reformation_tooltip2
				had_global_flag = {
					flag = reformation_started
					days = 18250
				}
			}
			calc_true_if = {
				desc = rig_defend_the_catholic_league_ct
				amount = 50
				all_province = {
					OR = {
						region = baltic_region
						region = north_german_region
						region = south_german_region
						region = poland_region
					}
					religion = root
				}
			}
			calc_true_if = {
				desc = rig_defend_the_catholic_league_bt
				amount = 150
				all_province = {
					OR = {
						region = baltic_region
						region = north_german_region
						region = south_german_region
						region = poland_region
					}
					owner = { religion = root }
				}
			}
		}
		effect = {
			custom_tooltip = rig_defend_the_catholic_league_at
			set_country_flag = improved_expansionist_zealotry
		}
	}
}

rig_livonia_and_trade_mission_slot = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Lions of the North"
	}
	potential = {
		tag = RIG
		has_dlc = "Lions of the North"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	rig_establish_bishop_authority = {
		icon = the_great_school
		position = 1
		required_missions = { 
		}
		provinces_to_highlight = {
			province_id = 38
			OR = {
				NOT = { is_capital_of = ROOT }
				NOT = { is_core = ROOT }
				NOT = { development = 15 }
			}
		}
		trigger = {
			38 = {
				is_capital_of = ROOT
				is_core = ROOT
				development = 15
			}
			if = {
				limit = {
					has_estate = estate_burghers
				}
				NOT = {
					estate_influence = {
						estate = estate_burghers
						influence = 50
					}
				}
			}
			else = {
				NOT = { has_estate = estate_burghers }
			}
			crown_land_share = 30
			stability = 1
		}
		effect = {
			38 = {
				add_building = cathedral
				add_province_triggered_modifier = seat_of_the_rigan_archbishopric
			}
			add_legitimacy = 20
			add_devotion = 20
			set_country_flag = rig_has_completed_authority_mission
		}
	}

	rig_vassalize_livonia = {
		icon = mission_livonian_knights
		position = 2
		required_missions = { rig_the_rigan_defense }
		provinces_to_highlight = {
			OR = {
				province_id = 36
				province_id = 37
				owned_by = LIV
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			if = {
				limit = {
					exists = LIV
				}
				LIV = {
					is_subject_of = ROOT
				}
			}
			owns_or_non_sovereign_subject_of = 36
			owns_or_non_sovereign_subject_of = 37
		}
		effect = {
			if = {
				limit = { LIV = { NOT = { historical_friend_with = ROOT } } }
				add_historical_friend = LIV
				LIV = { add_historical_friend = ROOT }
			}
			add_stability_or_adm_power = yes
			custom_tooltip = rig_vassalize_livonia_ct
			set_country_flag = rig_can_end_confederacy_flag
		}
	}

	rig_livonian_confederacy = {
		icon = mission_livonian_castle
		position = 3
		required_missions = { rig_vassalize_livonia }
		provinces_to_highlight = {
			OR = {
				owned_by = LIV
				province_id = 36
				province_id = 35
				province_id = 39
				province_id = 1834
				province_id = 37
				province_id = 4241
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			owns_or_non_sovereign_subject_of = 36
			owns_or_non_sovereign_subject_of = 35
			owns_or_non_sovereign_subject_of = 39
			owns_or_non_sovereign_subject_of = 1834
			owns_or_non_sovereign_subject_of = 37
			owns_or_non_sovereign_subject_of = 4241
			if = {
				limit = {
					exists = LIV
				}
				LIV = { 
					is_subject_of = ROOT
					NOT = { has_estate_privilege = estate_church_bishopric_of_dorpat }
					NOT = { has_estate_privilege = estate_church_bishopric_of_osel_wiek }
					NOT = { has_estate_privilege = estate_church_bishopric_of_courland }
					NOT = { has_estate_privilege = estate_church_bishopric_of_reval }
				}
			}
		}
		effect = {
			capital_scope = {
				add_base_tax = 4
				add_base_production = 3
				add_base_manpower = 3
			}
			add_country_modifier = {
				name = rig_integrated_the_livonian_confederacy
				duration = 9125
			}
		}
	}

	rig_control_the_trade_league = {
		icon = mission_bane_of_the_hansa
		position = 4
		required_missions = { 
			rig_sell_indulgences
		}
		provinces_to_highlight = {
			if = {
				limit = {
					has_dlc = "Mare Nostrum"
				}
				owner = {
					is_in_trade_league_with = HSA
					NOT = {
						has_opinion = {
							who = ROOT
							value = 75
						}
					}
				}
			}
			else = {
				OR = {
					province_id = 45
					owned_by = HSA
				}
			}
		}
		trigger = {
			if = {
				limit = {
					has_dlc = "Mare Nostrum"
				}
				OR = {
					HSA = {
						OR = {
							exists = no
							is_trade_league_leader = no
						}
					}
					custom_trigger_tooltip = {
						tooltip = rig_control_the_trade_league_tt
						all_known_country = {
							OR = {
								tag = ROOT
								NOT = { is_in_trade_league_with = HSA }
								AND = {
									is_in_trade_league_with = HSA
									has_opinion = {
										who = ROOT
										value = 75
									}
								}
							}
						}
					}
				}
				is_trade_league_leader = yes
			}
			else = {
				OR = {
					owns_or_non_sovereign_subject_of = 45
					NOT = { exists = HSA }
					45 = { 
						NOT = { is_strongest_trade_power = HSA } 
						trade_share = {
							country = ROOT
							share = 30
						}
					}
				}
			}
		}
		effect = {
			if = {
				limit = {
					has_dlc = "Mare Nostrum"
				}
				if = {
					limit = {
						HSA = {
							OR = {
								exists = no
								is_trade_league_leader = no
							}
						}
					}
					add_mercantilism = 5
				}
				else_if = {
					limit = {
						all_known_country = {
							OR = {
								tag = ROOT
								NOT = { is_in_trade_league_with = HSA }
								AND = {
									is_in_trade_league_with = HSA
									has_opinion = {
										who = ROOT
										value = 75
									}
								}
							}
						}
					}
					HSA = {
						country_event = {
							id = flavor_rig.12
						}
					}
					add_country_modifier = {
						name = rig_founder_of_a_new_trade_league
						duration = 9125
					}
				}
				else = {
					custom_tooltip = rig_control_the_trade_league_ct
				}
			}
			else = {
				45 = {
					add_trade_modifier = {
						who = ROOT
						duration = -1
						power = 15
						key = rig_control_the_trade_league_at
					}
				}
				add_mercantilism = 3
			}
			add_dip_power = 100
		}
	}

	rig_rigan_hansa = {
		icon = unite_the_league
		position = 5
		required_missions = { 
			rig_control_the_trade_league
		}
		provinces_to_highlight = {}
		trigger = {
			if = {
				limit = {
					has_dlc = "Mare Nostrum"
				}
				OR = {
					has_reform = reformer_state_reform
					has_reform = merchant_theocracy_reform
					has_reform = plutocratic_reform
					has_reform = venetian_merchant_republic
					has_reform = merchants_reform
				}
				is_trade_league_leader = yes
				calc_true_if = {
					all_known_country = {
						is_in_trade_league_with = ROOT
					}
					amount = 6
				}
			}
			else = {
				45 = {
					trade_share = {
						country = ROOT
						share = 75
					}
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = rig_the_rigan_trade_league
				duration = -1
			}
		}
	}
}

rig_develop_and_teuton_mission_slot = {
	slot = 5
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Lions of the North"
	}
	potential = {
		tag = RIG
		has_dlc = "Lions of the North"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	rig_the_rigan_defense = {
		icon = mission_castle_construction
		position = 1
		required_missions = { 
		}
		provinces_to_highlight = {
			province_id = 38
			OR = {
				NOT = { province_has_current_tech_fort_trigger = yes }
				NOT = { owned_by = ROOT }
			}
		}
		trigger = {
			army_size_percentage = 1
			num_of_generals = 1
			38 = {
				province_has_current_tech_fort_trigger = yes
				owned_by = ROOT
			}
		}
		effect = {
			add_country_modifier = {
				name = rig_tower_defenders
				duration = 9125
			}
			add_manpower = 6
			if = {
				limit = {
					exists = LIV
				}
				add_casus_belli = {
					type = cb_vassalize_mission
					target = LIV
					months = 300
				}
			}
			else = {
				custom_tooltip = rig_add_cores_to_livonia_tt
				hidden_effect = {
					livonia_area = {
						limit = { is_core = LIV }
						add_core = ROOT
					}
					curonia_area = {
						limit = { is_core = LIV }
						add_core = ROOT
					}
					estonia_ingria_area = {
						limit = { is_core = LIV }
						add_core = ROOT
					}
					livonia_area = {
						limit = {
							NOT = { is_core = ROOT }
							NOT = { is_permanent_claim = ROOT }
						}
						if = {
							limit = { NOT = { is_core = LIV } }
							add_core = LIV
						}
						add_permanent_claim = ROOT
					}
					curonia_area = {
						limit = {
							NOT = { is_core = ROOT }
							NOT = { is_permanent_claim = ROOT }
						}
						if = {
							limit = { NOT = { is_core = LIV } }
							add_core = LIV
						}
						add_permanent_claim = ROOT
					}
					estonia_ingria_area = {
						limit = {
							NOT = { is_core = ROOT }
							NOT = { is_permanent_claim = ROOT }
						}
						if = {
							limit = { NOT = { is_core = LIV } }
							add_core = LIV
						}
						add_permanent_claim = ROOT
					}
				}
			}
			if = {
				limit = {
					exists = TEU
				}
				add_casus_belli = {
					type = cb_vassalize_mission
					target = TEU
					months = 300
				}
			}
			else = {
				custom_tooltip = rig_add_cores_to_prussia_tt
				hidden_effect = {
					west_prussia_area = {
						limit = { is_core = TEU }
						add_core = ROOT
					}
					east_prussia_area = {
						limit = { is_core = TEU }
						add_core = ROOT
					}
					west_prussia_area = {
						limit = {
							NOT = { is_core = ROOT }
							NOT = { is_permanent_claim = ROOT }
						}
						if = {
							limit = { NOT = { is_core = TEU } }
							add_core = TEU
						}
						add_permanent_claim = ROOT
					}
					east_prussia_area = {
						limit = {
							NOT = { is_core = ROOT }
							NOT = { is_permanent_claim = ROOT }
						}
						if = {
							limit = { NOT = { is_core = TEU } }
							add_core = TEU
						}
						add_permanent_claim = ROOT
					}
				}
			}
		}
	}

	rig_subjugate_the_teutonic_order = {
		icon = mission_knight
		position = 2
		required_missions = { 
			rig_the_rigan_defense
		}
		provinces_to_highlight = {
			OR = {
				province_id = 41
				province_id = 43
				owned_by = TEU
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			if = {
				limit = {
					exists = TEU
				}
				TEU = {
					is_subject_of = ROOT
				}
			}
			owns_or_non_sovereign_subject_of = 41
			owns_or_non_sovereign_subject_of = 43
		}
		effect = {
			if = {
				limit = {
					exists = TEU
					TEU = { is_subject_of = ROOT }
				}
				country_event = {
					id = flavor_rig.1
				}
			}
			else = {
				custom_tooltip = rig_subjugate_the_teutonic_order_tt
			}
			add_army_tradition = 25
			add_mil_power = 75
		}
	}

	rig_rule_over_the_knights = {
		icon = mission_united_knight_order
		position = 4
		required_missions = { 
			rig_livonian_confederacy
			rig_subjugate_the_teutonic_order
		}
		provinces_to_highlight = {
			OR = {
				owned_by = TEU
				owned_by = LIV
				region = baltic_region
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			if = {
				limit = { exists = LIV }
				LIV = {
					is_subject_of = ROOT
					NOT = { liberty_desire = 10 }
				}
			}
			if = {
				limit = { exists = TEU }
				TEU = {
					is_subject_of = ROOT
					NOT = { liberty_desire = 10 }
				}
			}
			baltic_region = {
				country_or_non_sovereign_subject_holds = ROOT
				type = all
			}
		}
		effect = {
			add_country_modifier = {
				name = rig_the_rigan_orders
				duration = -1
			}
			if = {
				limit = { exists = LIV }
				if = {
					limit = {
						LIV = { is_subject_of = ROOT }
					}
					add_country_modifier = {
						name = rig_livonian_overlord
						duration = -1
					}
					LIV = {
						add_country_modifier = {
							name = rig_order_of_riga
							duration = -1
						}
					}
					custom_tooltip = rig_rule_over_the_knights_et
				}
				else = { custom_tooltip = rig_rule_over_the_knights_at }
			}
			else_if = {
				limit = {
					baltic_region = {
						country_or_non_sovereign_subject_holds = ROOT
						type = all
					}
				}
				add_dip_power = 100
			}
			else = { custom_tooltip = rig_rule_over_the_knights_bt }
			if = {
				limit = { exists = TEU }
				if = {
					limit = {
						TEU = { is_subject_of = ROOT }
					}
					add_country_modifier = {
						name = rig_teutonic_overlord
						duration = -1
					}
					TEU = {
						add_country_modifier = {
							name = rig_order_of_riga
							duration = -1
						}
					}
					custom_tooltip = rig_rule_over_the_knights_ft
				}
				else = { custom_tooltip = rig_rule_over_the_knights_ct }
			}
			else_if = {
				limit = {
					baltic_region = {
						country_or_non_sovereign_subject_holds = ROOT
						type = all
					}
				}
				add_mil_power = 100
			}
			else = { custom_tooltip = rig_rule_over_the_knights_dt }
		}
	}

	rig_develop_riga = {
		icon = mission_conquer_riga
		position = 5
		required_missions = { 
		}
		provinces_to_highlight = {
			province_id = 38
			OR = {
				NOT = { is_capital_of = ROOT }
				NOT = { is_core = ROOT }
				NOT = { province_has_current_tech_fort_trigger = yes }
				NOT = { has_tax_building_trigger = yes }
				NOT = { has_trade_building_trigger = yes }
				NOT = { has_production_building_trigger = yes }
				NOT = { has_manpower_building_trigger = yes }
			}
		}
		trigger = {
			custom_trigger_tooltip = {
				tooltip = rig_develop_riga_ct
				NOT = {
					num_of_owned_provinces_with = {
						continent = europe
						value = 6
					}
				}
			}
			38 = {
				is_capital_of = ROOT
				is_core = ROOT
				province_has_current_tech_fort_trigger = yes
				has_tax_building_trigger = yes
				has_trade_building_trigger = yes
				has_production_building_trigger = yes
				has_manpower_building_trigger = yes
			}
			stability = 3
		}
		effect = {
			38 = {
				add_base_tax = 4
				add_base_production = 4
				add_base_manpower = 3
				add_province_triggered_modifier = cathedral_of_riga
				add_province_triggered_modifier = market_of_riga
				add_province_triggered_modifier = fortification_of_riga
			}
			custom_tooltip = rig_develop_riga_tt
			set_country_flag = tall_riga_mission_flag
		}
	}
}