lubeck_missions_1 = {
	slot = 1 
	generic = no 
	ai = yes 
	potential = {
		tag = HSA
	}
	has_country_shield = yes
	
	hsa_gateway_to_east = {
		icon = mission_develop_nevas_port
		required_missions = { hsa_young_men_lubeck }
		position = 2 
		provinces_to_highlight = { 
			province_id = 38 
		}
		trigger = {
			OR = {
				38 = { country_or_non_sovereign_subject_holds = ROOT }
				AND = {
					RIG = {
						is_in_trade_league_with = ROOT 
						has_opinion = {
							who = ROOT 
							value = 125 
						}
					}
					army_size = 4 # modified
				}
			}
		}
		effect = {
			38 = { add_base_production = 2 }
			if = {
				limit = {
					RIG = { is_in_trade_league_with = ROOT }
				}
				add_dip_power = 50 
				add_mercantilism = 1 
			}
			if = {
				limit = {
					RIG = {
						is_in_trade_league_with = ROOT 
						has_opinion = {
							who = ROOT 
							value = 125 
						}
					}
					hre_size = 1
				}
				RIG = { set_in_empire = yes }
			}
		}
	}
	
	hsa_st_peterhof_depot = {
		icon = explore_caribbean
		required_missions = { hsa_gateway_to_east }
		position = 4 
		provinces_to_highlight = { 
			province_id = 310 
		}
		trigger = {
			310 = {
				OR = {
					country_or_non_sovereign_subject_holds = ROOT 
					owner = {
						alliance_with = ROOT 
						has_opinion = {
							who = ROOT 
							value = 125 
						}
					}
					trade_share = {
						country = ROOT 
						share = 30
					}
				}
			}
		}
		effect = {
			country_event = { id = flavor_hsa.5 } #flavor_hsa.5
			custom_tooltip = hsa_every_league_member_wealth_tt
			hidden_effect = {
				every_country = {
					limit = { is_in_trade_league_with = ROOT }
					add_country_modifier = {
						name = hsa_wealth_of_the_hansa_modifier
						duration = 3650 
					}
					capital_scope = {
						random_list = {
							40 = {
								add_base_tax = 1 
							}
							50 = {
								add_base_production = 1 
							}
							10 = {
								add_base_manpower = 1 
							}
						}
					}
				}
			}
		}
	}
	
	hsa_peace_vordingborg = {
		icon = mission_alliances 
		required_missions = { hsa_expand_market_square } 
		position = 7
		provinces_to_highlight = {
			OR = {
				province_id = 6 
				province_id = 12
			}
		}
		trigger = {
			OR = {
				12 = { country_or_non_sovereign_subject_holds = ROOT }
				12 = {
					owner = {
						has_opinion = {
							who = ROOT
							value = 125
						}
						is_at_war = no
					}
				}
				45 = { #Lubeck
					trade_share = {
						country = ROOT 
						share = 50
					}
				}
			}
		}
		effect = {
			45 = {
				add_province_modifier = {
					name = free_shipping_through_the_sound
					duration = 10950 
				}
			}
			if = {
				limit = {
					12 = { country_or_non_sovereign_subject_holds = ROOT }
				}
				add_mercantilism = 2 
			}
			custom_tooltip = general_tooltip_dynamic_reward
		}
	}
	
	hsa_herring_migration = {
		icon = mission_rb_cod_wars 
		required_missions = { hsa_peace_vordingborg }
		position = 8 
		provinces_to_highlight = {
			OR = {
				province_id = 6 
				province_id = 45 
			}
		}
		trigger = {
			OR = {
				45 = { 
					higher_development_than = 6 
					OR = {
						has_building = workshop 
						has_building = counting_house 
					}
					development = 25 
				}
				6 = {
					country_or_non_sovereign_subject_holds = ROOT 
					OR = {
						has_building = workshop 
						has_building = counting_house 
					}
					num_of_times_improved = 5
				}
			}
		}
		effect = {
			if = {
				limit = {
					6 = { country_or_non_sovereign_subject_holds = ROOT }
				}
				6 = { 
					if = {
						limit = {
							NOT = { has_building = counting_house }
						}
						remove_building = workshop 
						add_building = counting_house 
					}
					else = { add_base_production = 2 }
				}
			}
			else = {
				country_event = { id = flavor_hsa.6 } #flavor_hsa.6
			}
			custom_tooltip = general_tooltip_dynamic_reward
		}
	}
	
	hsa_markets_bryggen = {
		icon = promote_urbanization 
		required_missions = { hsa_herring_migration }
		position = 9
		provinces_to_highlight = { province_id = 23 }
		trigger = {
			OR = {
				23 = { country_or_non_sovereign_subject_holds = ROOT }
				23 = {
					owner = {
						has_opinion = {
							value = 125
							who = ROOT 
						}
					}	
				}
			}
			light_ship_fraction = 0.3
		}
		effect = {
			if = {
				limit = {
					23 = {
						owner = {
							has_opinion = {
								value = 125
								who = ROOT 	
							}
						}
					}
				}
				country_event = { id = flavor_hsa.7 } #flavor_hsa.7
			}
			else = {
				23 = {
					add_center_of_trade_level = 1 
				}
			}
			custom_tooltip = general_tooltip_dynamic_reward
		}
	}
	
	hsa_organize_hanseatic_diets = {
		icon = friends_in_high_places
		required_missions = { }
		position = 10 
		provinces_to_highlight = {
			owner = { 
				NOT = { tag = ROOT }
				OR = { 
					alliance_with = ROOT 
					is_in_trade_league_with = ROOT 
				}
				NOT = { 
					has_opinion = { 
						who = ROOT 
						value = 100 
					}
				}
			}
		}
		trigger = {
			OR = {
				dip = 4 
				ruler_has_personality = charismatic_negotiator_personality
				ruler_has_personality = silver_tongue_personality
			}
			if = {
				limit = { government = republic }
				OR = {
					reform_level = 3 
					republican_tradition = 80
				}
			}
			OR = {
				diplomat = 1 
				statesman = 1 
			}
			if = {
				limit = { 
					is_in_trade_league = yes
				}
				calc_true_if = {
					all_country = {
						has_opinion = {
							who = ROOT
							value = 100
						}
						OR = {
							is_in_trade_league_with = ROOT
							is_subject_of = ROOT
						}
					}
					amount = 3
				}
			}
			else = {
				calc_true_if = {
					all_country = {
						is_subject_of = ROOT
						has_opinion = {
							who = ROOT
							value = 100
						}
					}
					amount = 2
				}
			}
		}
		effect = {
			if = {
				limit = { has_reform = frequent_elections_reform }
				add_stability_or_adm_power = yes 
				add_ruler_modifier = {
					name = hsa_fresh_administration_modifier
					duration = 10950 
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_reform = consolidation_of_power_reform 
						has_reform = consolidate_power_in_doge_reform
					}
				}
				add_country_modifier = { 
					name = hsa_longterm_admin_modifier 
					duration = 9125 
				}
				if = { 
					limit = {
						adm = 5
						NOT = { adm = 6 }
					}
					change_adm = 1 
				}
				else = { add_adm_power = 50 }
				if = { 
					limit = {
						dip = 5
						NOT = { dip = 6 }
					}
					change_dip = 1 
				}
				else = { add_dip_power = 50 }
				if = { 
					limit = {
						mil = 5
						NOT = { mil = 6 }
					}
					change_mil = 1 
				}
				else = { add_mil_power = 50 }
			}
			else_if = {
				limit = { has_reform = consolidate_power_in_cities_reform }
				custom_tooltip = hsa_every_league_member_and_subject_adm_power_and_50_opinion_tt 
				hidden_effect = {
					every_country = {
						limit = {
							OR = {
								is_in_trade_league_with = ROOT 
								is_subject_of = ROOT 
							}
						}
						add_adm_power = 100
						add_opinion = {
							who = ROOT  
							modifier = hsa_allowed_regional_admin_opinion_modifier 
						}
					}
				}
				change_government_reform_progress = 100 
			}
			else_if = {
				limit = { has_reform = lottery_reform }
				add_ruler_modifier = {
					name = hsa_diplomatic_powerhouse 
					duration = 10950 
				}
			}
			else = {
				add_country_modifier = {
					name = hsa_hanseatic_diets_modifier 
					duration = 7300 
				}
				add_republican_tradition = 5
				add_legitimacy = 10 
				add_devotion = 10 
			}
			custom_tooltip = general_tooltip_dynamic_reward 
		}
	}
	
	hsa_wards_city = {
		icon = personal_diplomacy
		required_missions = { hsa_organize_hanseatic_diets hsa_tend_towns } 
		position = 11 
		trigger = {
			mercantilism = 60 
			OR = {
				full_idea_group = trade_ideas 
				AND = {
					faction_in_power = mr_traders
					power_projection = 50 
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = hsa_altermanner_modifier
				duration = 9125 
			}
			custom_tooltip = hsa_every_league_member_gets_this_reward_tt
			hidden_effect = {
				every_country = {
					limit = { is_in_trade_league_with = ROOT }
					add_country_modifier = {
						name = hsa_altermanner_modifier
						duration = 9125 
					}
				}
			}
			change_dip = 1 
			change_adm = 1 
		}
	}
}

lubeck_missions_2 = { 
	slot = 2
	generic = no 
	ai = yes 
	potential = {
		tag = HSA
	}
	has_country_shield = yes		
	
	hsa_restore_visby = {
		icon = return_visby_to_the_league
		required_missions = { hsa_young_men_lubeck }
		position = 2 
		provinces_to_highlight = { 
			province_id = 25 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			OR = {
				AND = { 
					GOT = { 
						is_in_trade_league_with = ROOT 
						has_opinion = {
							who = ROOT 
							value = 150 
						}
					}
				}
				25 = { country_or_non_sovereign_subject_holds = ROOT } 
			}
			if = { 
				limit = { 
					25 = { country_or_non_sovereign_subject_holds = ROOT } 
				}
				25 = {
					OR = {
						base_production = 7 
						province_has_center_of_trade_of_level = 2 
					}
				}
			}
		}
		effect = { 
			country_event = { id = flavor_hsa.8 } #flavor_hsa.8
			east_prussia_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			west_prussia_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
		}
	}

	hsa_induct_danzig_ports = {
		icon = capture_adriatic_ports 
		required_missions = { hsa_restore_visby }
		position = 3 
		provinces_to_highlight = {
			province_id = 43
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			43 = { country_or_non_sovereign_subject_holds = ROOT }
			OR = {
				faction_influence = {
					faction = mr_traders
					influence = 75
				}
				43 = { development = 25 }
			}
		}
		effect = {
			country_event = { id = flavor_hsa.9 } #flavor_hsa.9
		}
	}
	
	hsa_royal_prussia = {
		icon = tame_brandenburg 
		required_missions = { hsa_induct_danzig_ports }
		position = 4 
		provinces_to_highlight = { 
			OR = {
				area = east_prussia_area 
				area = west_prussia_area 
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			west_prussia_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT 
			}
			east_prussia_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT 
			}
		}
		effect = {
			west_prussia_area = { add_base_production = 1 }
			east_prussia_area = { add_base_production = 1 }
			add_accepted_culture = prussian 
		}
	}

	hsa_expand_market_square = {
		icon = mission_develop_nevas_port 
		required_missions = { } 
		position = 6 
		provinces_to_highlight = {
			province_id = 45 
			NOT = {
				OR = {
					has_building = marketplace 
					has_building = trade_depot
					has_building = stock_exchange
				}
				num_of_times_improved = 4 
			}
		}
		trigger = {
			45 = {
				OR = {
					has_building = marketplace 
					has_building = trade_depot
					has_building = stock_exchange
				}
				num_of_times_improved = 4 
			}
		}
		effect = {
			add_country_modifier = {
				name = hsa_influx_of_trade_and_foreigners_modifier
				duration = 5475 
			}
		}
	}
	
	hsa_impose_lubeck_law = {
		icon = mission_rb_monopolize_the_channel
		required_missions = { hsa_herring_migration hsa_expand_market_square } 
		position = 9 
		trigger = {
			stability = 1 
			adm = 3 
			dip = 3 
			mil = 3 
			if = {
				limit = { 
					OR = {
						has_reform = merchants_reform 
						has_reform = veche_republic
					}
				}
				OR = { 
					faction_influence = {
						faction = mr_traders 
						influence = 50
					}
					faction_influence = {
						faction = mr_aristocrats
						influence = 50
					}
					faction_influence = {
						faction = mr_guilds
						influence = 50
					}
					statesman = 2 
				}
			}
			else = { statesman = 2 }			
		}
		effect = {
			if = {
				limit = {
					faction_influence = {
						faction = mr_traders 
						influence = 50
					}
				}
				capital_scope = {
					add_province_modifier = {
						name = hsa_mercantile_burgermeister_modifier
						duration = 7300 
					}
				}
				hidden_effect = {
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						capital_scope = {
							add_province_modifier = {
								name = hsa_mercantile_burgermeister_modifier
								duration = 7300 
							}
						}
					}
				}
			}
			else_if = {
				limit = {
					faction_influence = {
						faction = mr_guilds 
						influence = 50
					}
				}
				capital_scope = {
					add_province_modifier = {
						name = hsa_guild_burgermeister_modifier
						duration = 7300 
					}
				}
				hidden_effect = {
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						capital_scope = {
							add_province_modifier = {
								name = hsa_guild_burgermeister_modifier
								duration = 7300 
							}
						}
					}
				}
			}
			else_if = {
				limit = {
					faction_influence = {
						faction = mr_aristocrats 
						influence = 50
					}
				}
				capital_scope = {
					add_province_modifier = {
						name = hsa_aristocrat_burgermeister_modifier
						duration = 7300 
					}
					add_base_manpower = 1 
				}
				hidden_effect = {
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						capital_scope = {
							add_province_modifier = {
								name = hsa_aristocrat_burgermeister_modifier
								duration = 7300 
							}
							add_base_manpower = 1
						}
					}
				}
			}
			else = {
				capital_scope = {
					add_province_modifier = {
						name = hsa_mercantile_burgermeister_modifier
						duration = 7300 
					}
				}
				hidden_effect = {
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						capital_scope = {
							add_province_modifier = {
								name = hsa_mercantile_burgermeister_modifier
								duration = 7300 
							}
						}
					}
				}
			}
			custom_tooltip = general_tooltip_dynamic_reward
			custom_tooltip = hsa_every_league_member_gets_this_reward_tt
		}
	}	

	hsa_tend_towns = {
		icon = renovate_berlin
		required_missions = { hsa_impose_lubeck_law }
		position = 10 
		provinces_to_highlight = {
			owned_by = ROOT 
			OR = {	
				devastation = 1 
				unrest = 1 
				NOT = { development = 10 }
			}
		}
		trigger = { 
			share_of_starting_income = 5
			grown_by_development = 50
			all_owned_province = {
				development = 10 
				NOT = { unrest = 1 }
				NOT = { devastation = 1 }
			}
		}
		effect = {
			add_country_modifier = {
				name = hsa_strong_mercantile_union_modifier
				duration = 10950 
			}
			custom_tooltip = hsa_every_league_member_gets_prosperity_and_25_trust_towards_you_tt
			hidden_effect = {
				every_country = {
					limit = { is_in_trade_league_with = ROOT }
					capital_scope = { add_prosperity = 100 }
					add_trust = {
						who = ROOT 
						value = 25 
						mutual = yes 
					}
				}
			}
		}
	}
	
	hsa_develop_mineral_trade = {
		icon = mission_establish_mint_towns 
		required_missions = { hsa_tend_towns } 
		position = 11 
		provinces_to_highlight = {
			province_id = 4742
		}
		trigger = {
			OR = {
				adm = 6 
				full_idea_group = economic_ideas 
				has_final_tier_reforms_trigger = yes
			}
			custom_trigger_tooltip = {
				tooltip = hsa_trigger_2_tt
				OR = {
					any_ally = {
						any_owned_province = { 
							trade_goods = gold 
						}
						has_opinion = {
							who = ROOT 
							value = 150 
						}
					}
					any_owned_province = {
						trade_goods = gold 
						base_production = 5
					}
					4742 = {
						owner = {
							OR = {
								AND = {
									alliance_with = ROOT 
									has_opinion = {
										who = ROOT 
										value = 150 
									}
								}
								AND = {
									is_in_trade_league_with = ROOT 
									has_opinion = {
										who = ROOT 
										value = 150 
									}
								}
							}
						}
					}
				}
			}
		}
		effect = {
			if = {
				limit = {
					4742 = {
						owner = {
							OR = {
								AND = {
									alliance_with = ROOT 
									has_opinion = {
										who = ROOT 
										value = 150 
									}
								}
								AND = {
									is_in_trade_league_with = ROOT 
									has_opinion = {
										who = ROOT 
										value = 150 
									}
								}
							}
						}
					}
				}
				4742 = { change_trade_goods = gold }
				capital_scope = { 
					change_trade_goods = gold 
					remove_province_modifier = hsa_lubeck_herring_market_modifier2
					remove_province_modifier = hsa_lubeck_herring_market_modifier
				}
				4742 = {
					owner = {
						add_country_modifier = {
							name = hsa_valuable_mineral_deposits_modifier
							duration = 9125
						}
					}
				}
				add_country_modifier = {
					name = hsa_valuable_mineral_abundance_modifier
					duration = 9125
				}
			}
			else = {
				capital_scope = { 
					add_base_tax = 2 
					add_base_production = 2 
					add_base_manpower = 2
					change_trade_goods = gold 
					remove_province_modifier = hsa_lubeck_herring_market_modifier2
					remove_province_modifier = hsa_lubeck_herring_market_modifier
					add_province_modifier = {
						name = hsa_center_of_mineral_trade
						duration = -1 
					}
				}
			}
			random_ally = {
				limit = {
					any_owned_province = { trade_goods = gold }
				}
				random_owned_province = {
					limit = { trade_goods = gold }
					add_province_modifier = {
						name = hsa_valuable_mineral_deposits_modifier
						duration = 9125
					}
				}
			}
			add_country_modifier = {
				name = hsa_valuable_mineral_abundance_modifier
				duration = 9125
			}
			custom_tooltip = general_tooltip_dynamic_reward
		}
	}
}

lubeck_missions_3 = { 
	slot = 3 
	generic = no 
	ai = yes 
	potential = { tag = HSA }
	has_country_shield = yes	
	
	hsa_young_men_lubeck = {
		icon = league_of_the_public_weal 
		required_missions = { } 
		position = 1 
		trigger = {
			army_size_percentage = 0.9
			manpower_percentage = 0.6
		}
		effect = {
			if = {
				limit = {
					is_trade_league_leader = yes 
				}
				custom_tooltip = hsa_reward_scales_with_number_of_members_tt
			}
			if = {
				limit = { 
					calc_true_if = {
						all_country = {
							is_in_trade_league_with = ROOT
						}
						amount = 6
					}
				}
				add_country_modifier = {
					name = hsa_recruiting_from_league_modifier3
					duration = 7300 
				}
			}
			else_if = {
				limit = { 
					calc_true_if = {
						all_country = {
							is_in_trade_league_with = ROOT
						}
						amount = 5
					}
				}
				add_country_modifier = {
					name = hsa_recruiting_from_league_modifier2
					duration = 5475 
				}
			}
			else_if = {
				limit = {
					calc_true_if = {
						all_country = {
							is_in_trade_league_with = ROOT
						}
						amount = 1
					}
				}
				add_country_modifier = {
					name = hsa_recruiting_from_league_modifier
					duration = 3650 
				}
			}
			else = { add_army_tradition = 20 }
			lower_saxony_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			mecklenburg_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			25 = {
				if = {
					limit = {
						NOT = { is_core = ROOT }
						NOT = { is_permanent_claim = ROOT }
					}
					add_permanent_claim = ROOT
				}
			}
			38 = {
				if = {
					limit = {
						NOT = { is_core = ROOT }
						NOT = { is_permanent_claim = ROOT }
					}
					add_permanent_claim = ROOT
				}
			}
			43 = {
				if = {
					limit = {
						NOT = { is_core = ROOT }
						NOT = { is_permanent_claim = ROOT }
					}
					add_permanent_claim = ROOT
				}
			}
		}
	}
	
	hsa_grinning_steers_head = {
		icon = protect_against_austria 
		required_missions = { hsa_young_men_lubeck }
		position = 2 
		provinces_to_highlight = {
			area = mecklenburg_area 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			OR = {
				AND = {
					development_in_provinces = {
						value = 35 
						area = mecklenburg_area 
					}
					2996 = { country_or_non_sovereign_subject_holds = ROOT }
					46 = { country_or_non_sovereign_subject_holds = ROOT }
				}
				mecklenburg_area = {
					type = all 
					country_or_non_sovereign_subject_holds = ROOT 
				}
			}
		}
		effect = {
			create_general = { tradition = 50 }
			hinter_pommern_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			vorpommern_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			if = {
				limit = {
					NOT = { mission_completed = hsa_impose_lubeck_law }
				}
				custom_tooltip = hsa_if_lubeck_law_complete_tt
			}
			if = {
				limit = { mission_completed = hsa_impose_lubeck_law }
				mecklenburg_area = {
					limit = { country_or_non_sovereign_subject_holds = ROOT }
					add_province_modifier = {
						name = hsa_lubeck_law_modifier
						duration = 5475
					}
					add_devastation = -20
				}
			}
		}
	}
	
	hsa_along_sea = {
		icon = mission_hanseatic_city 
		required_missions = { hsa_grinning_steers_head }
		position = 3
		provinces_to_highlight = {
			OR = {
				area = hinter_pommern_area
				area = vorpommern_area 
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			OR = {
				AND = {
					hinter_pommern_area = {
						type = all 
						country_or_non_sovereign_subject_holds = ROOT 
					}
					vorpommern_area = {
						type = all 
						country_or_non_sovereign_subject_holds = ROOT 
					}
				}
				AND = { 
					47 = {
						country_or_non_sovereign_subject_holds = ROOT 
						num_of_times_improved = 4 
						province_has_center_of_trade_of_level = 2
					}
					1858 = {
						country_or_non_sovereign_subject_holds = ROOT 
						num_of_times_improved = 4 
					}
				}
			}
		}
		effect = {
			custom_tooltip = hsa_permanent_mod_if_50_trade_in_lubeck
			if = {
				limit = {
					NOT = {
						45 = { #Lubeck
							trade_share = {
								country = ROOT
								share = 50
							}
						}
					}
				}
				add_country_modifier = {
					name = hsa_secured_pomeranian_coast_modifier
					duration = 7300
				}
			}
			else = {
				add_country_modifier = {
					name = hsa_secured_pomeranian_coast_modifier
					duration = -1
				}
			}
			add_mercantilism = 3 
		}
	}
	
	hsa_double_entry_bookkeeping = {
		icon = medici_bank_ledgers
		required_missions = { hsa_expand_market_square }
		position = 7
		trigger = {
			OR = {
				custom_trigger_tooltip = {
					tooltip = hsa_trigger_4_tt
					any_ally = { 
						culture_group = latin
						has_institution = renaissance 
						has_opinion = {
							who = ROOT 
							value = 125 
						}
					}
				}
				capital_scope = {
					renaissance = 100 
					development = 30 
				}
				has_idea = the_hansa_bank
			}
		}
		effect = {
			define_advisor = {
				type = treasurer
				skill = 3 
				culture = tuscan
				cost_multiplier = 0.3
				name = "Luca Pacioli" 
			}
			add_adm_power = 100 
		}
	}
	
	hsa_queens_hall = {
		icon = powerhouse_of_the_north
		required_missions = { hsa_double_entry_bookkeeping }
		position = 8 
		provinces_to_highlight = { province_id = 45 }
		trigger = {
			OR = {
				45 = { num_of_times_improved = 10 }
				monthly_adm = 10 
			}
			45 = { 
				OR = {
					has_building = courthouse
					has_building = town_hall
				}
			}
		}
		effect = {
			country_event = { id = flavor_hsa.10 } #flavor_hsa.10
			45 = {
				add_province_modifier = {
					name = hsa_expand_the_hansehalle_modifier
					duration = 7300 
				}
			}
		}
	}
	
	hsa_construct_holstentor = {
		icon = defend_the_city 
		required_missions = { hsa_queens_hall }
		position = 9 
		provinces_to_highlight = { province_id = 45 }
		trigger = {
			fortification_expert = 3
			45 = {
				OR = {
					has_fort_building_trigger = yes 
					has_building = ramparts 
				}
			}
		}
		effect = { 
			country_event = { id = flavor_hsa.11 } #flavor_hsa.11
		}
	}
	
	hsa_new_system_trade = {
		icon = mission_dominate_home_trade_node
		required_missions = { hsa_construct_holstentor }
		position = 10 
		trigger = {
			mercantilism = 40 
			trader = 3
			45 = {
				OR = {
					province_has_center_of_trade_of_level = 3 
					OR = {
						has_building = trade_depot 
						has_building = stock_exchange 
					}
				}
			}
			45 = { #Lubeck
				trade_share = {
					country = ROOT 
					share = 50
				}
			}
		}
		effect = {
			country_event = { id = flavor_hsa.12 } #flavor_hsa.12
		}
	}
	
	hsa_queen_of_the_hansa = {
		icon = unite_the_league
		required_missions = { hsa_wards_city hsa_develop_mineral_trade hsa_new_system_trade hsa_eagle_of_lubeck } 
		position = 12 
		provinces_to_highlight = { #untested
			OR = {
				province_id = 45
				province_id = 1975
				province_id = 1926
				province_id = 33
			}
			NOT = { is_strongest_trade_power = ROOT }
		}
		trigger = {
			mercantilism = 75 
			OR = {
				is_great_power = yes 
				total_development = 400 
				AND = {
					monthly_dip = 12
					grown_by_development = 200
					power_projection = 50 
					republican_tradition = 85
				}
			}
			45 = { is_strongest_trade_power = ROOT }
			1975 = { is_strongest_trade_power = ROOT }
			1926 = { is_strongest_trade_power = ROOT }
			33 = { is_strongest_trade_power = ROOT }
			custom_trigger_tooltip = {
				tooltip = largest_trade_fleet_in_europe_ttt
				NOT = {
					any_country = {
						capital_scope = {
							continent = europe 
						}
						num_of_light_ship = ROOT
					}
				}
			}
		}
		effect = {
			if = {
				limit = {
					is_trade_league_leader = yes 
				}
				custom_tooltip = hsa_vassalize_lib_desire_trade_league_tt
				hidden_effect = {
					every_country = {
						limit = {
							is_in_trade_league_with = ROOT 
						}
						ROOT = { vassalize = PREV }
						add_liberty_desire = -50
					}
				}
			}
			capital_scope = {
				add_scaled_local_adm_power = 10 
				add_scaled_local_dip_power = 10 
				add_scaled_local_mil_power = 10
			}
			custom_tooltip = hsa_based_on_the_development_of_our_capital_tt
			country_event = { id = flavor_hsa.26 } #flavor_hsa.26
			custom_tooltip = hsa_diplomatic_upkeep_boost_tt
			hidden_effect = {
				if = { 
					limit = { num_of_non_tributary_subjects = 6 }
					add_country_modifier = {
						name = hsa_northern_alliance_of_trade_cities6_modifier
						duration = 10950 
					}
				}
				else_if = {
					limit = { num_of_non_tributary_subjects = 5 }
					add_country_modifier = {
						name = hsa_northern_alliance_of_trade_cities5_modifier
						duration = 10950 
					}
				}
				else_if = {
					limit = { num_of_non_tributary_subjects = 4 }
					add_country_modifier = {
						name = hsa_northern_alliance_of_trade_cities4_modifier
						duration = 10950 
					}
				}	
				else_if = {
					limit = { num_of_non_tributary_subjects = 3 }
					add_country_modifier = {
						name = hsa_northern_alliance_of_trade_cities3_modifier
						duration = 10950 
					}
				}
				else_if = {
					limit = { num_of_non_tributary_subjects = 2 }
					add_country_modifier = {
						name = hsa_northern_alliance_of_trade_cities2_modifier
						duration = 10950 
					}
				}
				else = {
					add_country_modifier = {
						name = hsa_northern_alliance_of_trade_cities1_modifier
						duration = 10950 
					}
				}
			}
		}
	}
}


lubeck_missions_4 = {
	slot = 4 
	generic = no 
	ai = yes 
	potential = { tag = HSA }
	has_country_shield = yes
	
	hsa_secure_salt_road = {
		icon = claim_the_borderlands
		required_missions = { hsa_young_men_lubeck }
		position = 2 
		provinces_to_highlight = {
			OR = {
				province_id = 1857
				province_id = 53 
				province_id = 4772
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			1857 = { country_or_non_sovereign_subject_holds = ROOT }
			53 = { country_or_non_sovereign_subject_holds = ROOT }
			4772 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			weser_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			add_country_modifier = {
				name = hsa_lower_saxon_drittel_modifier 
				duration = 5475
			}
			custom_tooltip = hsa_hamburg_dev_per_member
			hidden_effect = {
				if = {
					limit = {
						HAM = { 
							is_in_trade_league_with = ROOT 
								has_opinion = {
								who = ROOT 
								value = 160 
							}
						}
						calc_true_if = {
							all_country = {
								is_in_trade_league_with = ROOT
							}
							amount = 6
						}
					}
					add_country_modifier = {
						name = hsa_development_works_of_the_hansa_modifier6
						duration = 5475 
					}
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						add_country_modifier = {
							name = hsa_development_works_of_the_hansa_modifier6
							duration = 5475 
						}
					}
				}
				else_if = {
					limit = {
						HAM = { 
							is_in_trade_league_with = ROOT 
								has_opinion = {
								who = ROOT 
								value = 160 
							}
						}
						calc_true_if = {
							all_country = {
								is_in_trade_league_with = ROOT
							}
							amount = 5
						}
					}
					add_country_modifier = {
						name = hsa_development_works_of_the_hansa_modifier5
						duration = 5475 
					}
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						add_country_modifier = {
							name = hsa_development_works_of_the_hansa_modifier5
							duration = 5475 
						}
					}
				}
				else_if = {
					limit = {
						HAM = { 
							is_in_trade_league_with = ROOT 
								has_opinion = {
								who = ROOT 
								value = 160 
							}
						}
						calc_true_if = {
							all_country = {
								is_in_trade_league_with = ROOT
							}
							amount = 4
						}
					}
					add_country_modifier = {
						name = hsa_development_works_of_the_hansa_modifier4
						duration = 5475 
					}
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						add_country_modifier = {
							name = hsa_development_works_of_the_hansa_modifier4
							duration = 5475 
						}
					}
				}
				else_if = {
					limit = {
						HAM = { 
							is_in_trade_league_with = ROOT 
								has_opinion = {
								who = ROOT 
								value = 160 
							}
						}
						calc_true_if = {
							all_country = {
								is_in_trade_league_with = ROOT
							}
							amount = 3
						}
					}
					add_country_modifier = {
						name = hsa_development_works_of_the_hansa_modifier3
						duration = 5475 
					}
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						add_country_modifier = {
							name = hsa_development_works_of_the_hansa_modifier3
							duration = 5475 
						}
					}
				}
				else_if = {
					limit = {
						HAM = { 
							is_in_trade_league_with = ROOT 
								has_opinion = {
								who = ROOT 
								value = 160 
							}
						}
						calc_true_if = {
							all_country = {
								is_in_trade_league_with = ROOT
							}
							amount = 2
						}
					}
					add_country_modifier = {
						name = hsa_development_works_of_the_hansa_modifier2
						duration = 5475 
					}
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						add_country_modifier = {
							name = hsa_development_works_of_the_hansa_modifier2
							duration = 5475 
						}
					}
				}
				else = {
					add_country_modifier = {
						name = hsa_development_works_of_the_hansa_modifier1
						duration = 5475 
					}
					every_country = {
						limit = { is_in_trade_league_with = ROOT }
						add_country_modifier = {
							name = hsa_development_works_of_the_hansa_modifier1
							duration = 5475 
						}
					}
				}
				if = {
					limit = {
						HAM = {
							is_in_trade_league_with = ROOT 
							owns = 44 
						}
					}
					44 = { change_trade_goods = salt }
				}
			}
		}
	}
	
	hsa_flow_trade = {
		icon = sources_of_trade 
		required_missions = { hsa_secure_salt_road }
		position = 3
		provinces_to_highlight = {
			area = weser_area 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			OR = {
				weser_area = { country_or_non_sovereign_subject_holds = ROOT }
				AND = { 
					OLD = { is_in_trade_league_with = ROOT }
					BRE = { is_in_trade_league_with = ROOT }
					54 = { country_or_non_sovereign_subject_holds = ROOT }
					4771 = { country_or_non_sovereign_subject_holds = ROOT }
				}
			}
		}
		effect = {
			
			1876 = { #Rhineland
				add_trade_modifier = {
					who = ROOT
					duration = 7300
					power = 30
					key = hsa_secured_inland_trade
				}
			}
			add_years_of_income = 0.5 
			if = {
				limit =  {
					BRE = {
						is_in_trade_league_with = ROOT 
						owns = 1874 
					}
				}
				1874 = { add_center_of_trade_level = 1 }
				BRE = { add_mercantilism = 1 }
			}
			if = {
				limit = {
					FRN = {
						is_in_trade_league_with = ROOT 
						owns = 1876 
					}
				}
				1876 = {
					add_province_modifier = {
						name = hsa_mercantile_stronghold_of_the_hansa_modifier
						duration = 9125
					}
				}
			}
		}
	}
	
	hsa_appoint_war_minister = {
		icon = military_self_reliance
		required_missions = { hsa_royal_prussia hsa_flow_trade hsa_bypass_sound_toll }
		position = 5 
		trigger = {
			has_mil_advisor_3 = yes
			OR = {
				army_professionalism = 0.6
				army_tradition = 80
			}
			total_development = 350 
			OR = {
				full_idea_group = quality_ideas 
				full_idea_group = offensive_ideas 
				full_idea_group = quantity_ideas 
			}
		}
		effect = {
			custom_tooltip = hsa_army_reformer_tt
			tooltip = {
				add_country_modifier = {
					name = hsa_general_army_reform_modifier
					duration = -1 
				}
			}
			custom_tooltip = hsa_army_organiser_tt
			tooltip = {
				add_country_modifier = {
					name = hsa_general_army_organization_modifier
					duration = -1 
				}
			}
			custom_tooltip = hsa_commandant_tt
			tooltip = {
				add_country_modifier = {
					name = hsa_military_excellence_modifier
					duration = -1 
				}
			}
			custom_tooltip = hsa_quartermaster_tt
			tooltip = {
				add_country_modifier = {
					name = hsa_modernized_supply_lines_modifier
					duration = -1 
				}
			}
			custom_tooltip = hsa_recruitmaster_tt
			tooltip = {
				add_country_modifier = {
					name = hsa_zealous_recruitment_modifier
					duration = -1 
				}
			}
			custom_tooltip = hsa_grandcaptain_tt
			tooltip = {
				add_country_modifier = {
					name = hsa_improved_military_administration_modifier
					duration = -1 
				}
			}
			custom_tooltip = hsa_fortification_expert_tt
			tooltip = {
				add_country_modifier = {
					name = hsa_fortification_efforts_modifier
					duration = -1 
				}
			}
			hidden_effect = {#
				if = {
					limit = { army_reformer = 3 }
					add_country_modifier = {
						name = hsa_general_army_reform_modifier
						duration = -1 
					}
				}
				else_if = {#
					limit = { army_organiser = 3 }
					add_country_modifier = {
						name = hsa_general_army_organization_modifier
						duration = -1 
					}
				}
				else_if = {#
					limit = { commandant = 3 }
					add_country_modifier = {
						name = hsa_military_excellence_modifier
						duration = -1 
					}
				}
				else_if = {#
					limit = { quartermaster = 3 }
					add_country_modifier = {
						name = hsa_modernized_supply_lines_modifier
						duration = -1 
					}
				}
				else_if = {#
					limit = { recruitmaster = 3 }
					add_country_modifier = {
						name = hsa_zealous_recruitment_modifier
						duration = -1 
					}
				}
				else_if = {#
					limit = { grand_captain = 3 }
					add_country_modifier = {
						name = hsa_improved_military_administration_modifier
						duration = -1 
					}
				}
				else_if = {
					limit = { fortification_expert = 3 }
					add_country_modifier = {
						name = hsa_fortification_efforts_modifier
						duration = -1 
					}
				}
			}
		}
	}
	
	hsa_finance_guilds = {
		icon = mission_state_manufactories 
		required_missions = { hsa_expand_market_square }
		position = 7
		trigger = {
			capital_scope = {
				OR = {
					has_building = workshop
					has_building = counting_house
				}
			}
			OR = {
				economic_ideas = 2 
				trade_ideas = 2 
				capital_scope = { base_production = 10 }
			}
		}
		effect = {
			add_country_modifier = {
				name = hsa_shipwrights_naval_expansion_modifier 
				duration = 7300 
			}
			if = {
				limit = {
					capital_scope = { 
						has_port = yes
						has_building = shipyard 
						NOT = { has_building = grand_shipyard }
					}
				}
				capital_scope = {
					remove_building = shipyard 
					add_building = grand_shipyard 
				}
			}
			else_if = {
				limit = {
					capital_scope = { 
						has_port = yes
						NOT = { has_building = shipyard }
						NOT = { has_building = grand_shipyard }
					}
				}
				capital_scope = { add_building = shipyard }
			}
			custom_tooltip = hsa_every_league_member_gets_this_reward_tt
			hidden_effect = {
				every_country = {
					limit = {
						is_in_trade_league_with = ROOT 
						capital_scope = { 
							has_port = yes
							NOT = { has_building = grand_shipyard }
							NOT = { has_building = shipyard }
						}
					}
					capital_scope = { add_building = shipyard }
				}
				every_country = {
					limit = {
						any_owned_province = { has_port = yes }
						is_in_trade_league_with = ROOT 
					}
					add_country_modifier = {
						name = hsa_shipwrights_naval_expansion_modifier 
						duration = 7300 
					}
				}
			}
		}
	}

	hsa_develop_handsflotte = {
		icon = mission_corsairs_of_the_north_sea
		required_missions = { hsa_queens_hall hsa_finance_guilds hsa_schiffbauer_gilde } 
		position = 9
		trigger = {
			navy_size_percentage = 1 
			num_of_admirals = 1
			num_of_light_ship = 10 
		}
		effect = {
			add_navy_tradition = 15 
			add_country_modifier = {
				name = hsa_hanseatic_trade_fleet_modifier
				duration = 10950
			}
		}
	}
	
	hsa_charter_north_america = {
		icon = mission_caribbean_cn
		required_missions = { hsa_new_system_trade hsa_develop_handsflotte }
		position = 11
		provinces_to_highlight = {
			area = newfoundland_area 
		}
		trigger = {
			exploration_ideas = 1
			navy_size = 26 # modified
		}
		effect = {
			add_country_modifier = { 
				name = hsa_new_world_ambitions_modifier
				duration = 10950 
			}
			create_explorer = { tradition = 80 }
		}
	}
}
	
lubeck_missions_5 = {
	slot = 5 
	generic = no 
	ai = yes 
	potential = { tag = HSA }
	has_country_shield = yes	
	
	hsa_imperial_allegience = {
		icon = lead_the_empire 
		required_missions = { } 
		position = 1 
		trigger = {
			if = {
				limit = { hre_size = 1 }
				OR = {
					emperor = {
						has_opinion = {
							who = ROOT 
							value = 100 
						}
					}
					is_emperor = yes 
				}
			}
			OR = {
				statesman = 1 
				diplomat = 1 
			}
			num_of_allies = 2 
		}
		effect = {
			add_casus_belli = {
				target = DTT
				type = cb_vassalize_mission
				months = 180
			}
			holstein_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			if = {
				limit = { hre_size = 1 }
				emperor = {
					add_trust = {
						who = ROOT 
						value = 25 
						mutual = yes 
					}
				}
			}
			else = { add_dip_power = 50 }
		}
	}
	
	hsa_pen_sword = {
		icon = unite_the_realm
		required_missions = { hsa_secure_salt_road hsa_imperial_allegience }
		position = 3 
		provinces_to_highlight = {
			area = holstein_area 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			holstein_area = {
				type = all 
				OR = {
					country_or_non_sovereign_subject_holds = ROOT 
					owner = { is_in_trade_league_with = ROOT }
				}
			}
		}
		effect = {
			custom_tooltip = hsa_imperial_favor_tt
			hidden_effect = {
				if = {
					limit = {
						emperor = {
							has_opinion = {
								who = ROOT 
								value = 100 
							}
						}
					}
					1775 = { add_core = ROOT }
				}
			}
			add_country_modifier = {
				name = hsa_victory_in_holstein_modifier
				duration = 7300
			}
			if = {
				limit = {	
					DAN = {
						NOT = {
							has_opinion = {
								who = ROOT 
								value = 0 
							}
						}
					}
				}
				custom_tooltip = hsa_reduce_denmark_trade_tt 
				hidden_effect = {
					45 = { #Lubeck
						add_trade_modifier = {
							who = DAN
							duration = 3650
							power = -50
							key = hsa_submission_to_the_hansa
						}
					}
				}
			}
		}
	}
	
	hsa_bypass_sound_toll = {
		icon = mission_trade_with_cathay
		required_missions = { hsa_pen_sword }
		position = 4 
		provinces_to_highlight = {
			province_id = 12 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			OR = {
				12 = { country_or_non_sovereign_subject_holds = ROOT }
				AND = {
					45 = {
						NOT = {
							trade_share = {
								country = DAN 
								share = 20
							}
						}
						is_strongest_trade_power = ROOT 
					}
					army_strength = { 
						who = DAN 
						value = 1.5 
					}
				}
			}
		}
		effect = {
			custom_tooltip = general_tooltip_dynamic_reward
			if = {
				limit = {
					12 = { owned_by = ROOT }
				}
				12 = { change_culture = ROOT }
			}
			if = {
				limit = {
					12 = { country_or_non_sovereign_subject_holds = ROOT }
				}
				12 = { add_center_of_trade_level = 1 }
			}
			else = {
				12 = { remove_province_modifier = sound_toll }
				45 = { 
					add_province_modifier = {
						name = sound_toll
						duration = -1
					}
				}
			}
			4163 = { add_permanent_claim = ROOT }
			17 = { add_permanent_claim = ROOT }
		}
	}
	
	hsa_tame_north_sea = {
		icon = imperial_navy 
		required_missions = { hsa_bypass_sound_toll }
		position = 5
		provinces_to_highlight = { province_id = 1975 }
		trigger = {
			1975 = {
				trade_share = {
					country = ROOT 
					share = 50
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = hsa_high_seas_navy_modifier
				duration = 9125 
			}
			45 = { add_trade_node_income = 10 }
			add_mercantilism = 5
		}
	}
	
	hsa_expand_admiralty = {
		icon = imperial_navy
		required_missions = { }
		position = 6 
		trigger = {
			navy_size_percentage = 1 
			naval_maintenance = 1 
			num_of_galley = 5
			OR = {
				naval_reformer = 1 
				45 = {
					owned_by = ROOT 
					OR = {
						has_building = dock 
						has_building = drydock 
					}
				}
			}
		}
		effect = {
			create_admiral = {
				tradition = 50 
				add_fire = 1 
				add_shock = 1 
			}
		}
	}
	
	hsa_schiffbauer_gilde = {
		icon = renaissance_city
		required_missions = { hsa_expand_admiralty }
		position = 8 
		provinces_to_highlight = { province_id = 45 }
		trigger = {
			45 = {
				OR = {
					has_building = shipyard 
					has_building = grand_shipyard 
				}
			}
			if = {
				limit = {
					45 = { trade_goods = naval_supplies }
				}
				45 = {
					OR = {
						has_manufactory_trigger = yes 
						has_building = workshop 
						has_building = counting_house 
					}
				}
			}
			else = { 
				OR = {
					faction_influence = {
						faction = mr_guilds 
						influence = 50
					}
					years_of_income = 1 
				}
			}
		}
		effect = {
			country_event = { id = flavor_hsa.13 } #flavor_hsa.13
		}
	}
	
	hsa_marine_pilots = {
		icon = overshadow_venice
		required_missions = { hsa_schiffbauer_gilde }
		position = 10
		trigger = {
			naval_forcelimit = 25
			has_leader_with = { 
				manuever = 4 
				admiral = yes 
			}
			NOT = {
				any_country = {
					45 = { 
						has_privateer_share_in_trade_node = {
							who = PREV
							share = 0.01
						}
					}
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = hsa_safe_seaways_modifier 
				duration = 7300 
			}	
			define_advisor = {
				type = naval_reformer 
				cost_multiplier = 0.5 
				skill = 3 
			}
		}
	}
	
	hsa_eagle_of_lubeck = {
		icon = mission_launch_a_flagship 
		required_missions = { hsa_marine_pilots }
		position = 11
		trigger = {
			if = { 
				limit = { has_dlc = "Golden Century" }
				has_flagship = yes 
			}
			else = { navy_tradition = 60 }
			custom_trigger_tooltip = {
				tooltip = hsa_enacted_adler_von_lubeck_decision_tt
				has_country_flag = adler_built
			}
			num_of_heavy_ship = 25
			custom_trigger_tooltip = {
				tooltip = hsa_largest_fleet_from_rivals_or_naval_ideas_tt
				OR = {
					any_country = {
						is_rival = ROOT
						NOT = { navy_size = ROOT }
					}
					full_idea_group = naval_ideas
				}
			}
		}
		effect = {
			country_event = { id = flavor_hsa.14 } #flavor_hsa.14
		}
	}
}
	
	
	