###### DHE's to spawn pirate republics ######
###### by Daniel Tolman ######

namespace = pirates
normal_or_historical_nations = yes

# The Pirates of New Providence
country_event = {
	id = pirates.2
	title = "pirates.2.t"
	picture = CARIBBEAN_PIRATE_FORT_eventPicture
	desc = "pirates.2.d"

	fire_only_once = yes

	trigger = {
		has_dlc = "Golden Century"
		NOT = { exists = NSS }
		has_global_flag = golden_age_of_piracy
		NOT = { has_reform = pirate_republic_reform }
		OR = {
			AND = {
				owns_core_province = 482
				is_subject = no
				num_of_cities = 2
			}
			any_subject_country = {
				owns_core_province = 482
				num_of_cities = 2
			}
		}
		OR = {
			482 = {
				recent_treasure_ship_passage = yes
			}
			482 = {
				privateer_power = { share = 5 }
			}
			any_country = {
				capital_scope = {
					region = carribeans_region
				}
				war_exhaustion = 5
			}
		}
	}

	immediate = {
		hidden_effect = {
			482 = {
				discover_country = NSS
				add_core = NSS
			}
		}
	}

	mean_time_to_happen = {
		months = 12
	}

	option = { # play as the pirates
		name = "pirates.2.a"
		# play as NSS
		trigger = {
			ai = no
		}
		482 = {
			owner = {
				release = NSS
			}
		}
		NSS = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = ROOT
			discover_provinces = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "000000"
				dynasty = "Hornigold"
				adm = 3
				dip = 3
				mil = 5
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
			swap_non_generic_missions = yes
		}
		switch_tag = NSS
	}
	option = { # pirates get released
		name = "pirates.2.b"
		482 = {
			owner = {
				release = NSS
			}
		}
		NSS = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "000000"
				dynasty = "Hornigold"
				adm = 3
				dip = 3
				mil = 5
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
			swap_non_generic_missions = yes
		}
	}
}

# Libertatia
country_event = {
	id = pirates.3
	title = "pirates.3.t"
	picture = BUCCANEERS_eventPicture
	desc = "pirates.3.d"

	fire_only_once = yes

	trigger = {
		has_dlc = "Golden Century"
		not = { exists = LIB }
		capital_scope = {
			continent = africa
		}
		NOT = { has_reform = pirate_republic_reform }
		kongo_region = {
			owner = {
				capital_scope = {
					continent = europe
				}
			}
		}
		OR = {
			india_superregion = {
				owner = {
					capital_scope = {
						continent = europe
					}
				}
			}
			east_indies_superregion = {
				owner = {
					capital_scope = {
						continent = europe
					}
				}
			}
		}
		has_global_flag = golden_age_of_piracy
		owns_core_province = 4024
		num_of_cities = 2
		OR = {
			4024 = {
				recent_treasure_ship_passage = yes
			}
			4024 = {
				privateer_power = { share = 5 }
			}
		}
	}

	immediate = {
		hidden_effect = {
			4024 = {
				discover_country = LIB
				add_core = LIB
			}
		}
	}

	mean_time_to_happen = {
		months = 12
	}

	option = { # play as the pirates
		name = "pirates.3.a"
		trigger = {
			ai = no
		}
		release = LIB
		LIB = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = ROOT
			discover_provinces = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "00000"
				dynasty = "Mission"
				adm = 4
				dip = 2
				mil = 3
			}
			define_advisor = {
				type = theologian
				skill = 3
				name = "Signor Caraccioli"
				cost_multiplier = 0.25
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
		switch_tag = LIB
	}
	option = { # pirates get released
		name = "pirates.3.b"
		release = LIB
		LIB = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "00000"
				dynasty = "Mission"
				adm = 4
				dip = 2
				mil = 3
			}
			define_advisor = {
				type = theologian
				skill = 3
				name = "Signor Caraccioli"
				cost_multiplier = 0.25
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
		create_march = LIB
	}
}

# Sale
country_event = {
	id = pirates.4
	title = "pirates.4.t"
	picture = BARBARY_PIRATES_eventPicture
	desc = "pirates.4.d"

	fire_only_once = yes

	trigger = {
		has_dlc = "Golden Century"
		not = { exists = SLE }
		NOT = { has_reform = pirate_republic_reform }
		218 = {
			owner = {
				culture_group = iberian
				religion_group = christian
			}
		}
		223 = {
			owner = {
				culture_group = iberian
				religion_group = christian
			}
		}
		owns_core_province = 4563
		num_of_cities = 2
		is_subject = no
		religion_group = muslim
		4563 = {
			privateer_power = { share = 5 }
		}
	}

	immediate = {
		hidden_effect = {
			4563 = {
				discover_country = SLE
				add_core = SLE
			}
			218 = {
				owner = {
					save_event_target_as = spain_country
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 12
		# modifiers
	}

	option = { # play as the pirates
		name = "pirates.4.a"
		trigger = {
			ai = no
		}
		# play as SLE
		4563 = {
			add_base_tax = 2
			add_base_manpower = 2
		}
		release = SLE
		create_guarantee = SLE
		SLE = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = ROOT
			discover_provinces = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "Murat" # Jan Janszoon
				dynasty = "Reis"
				adm = 3
				dip = 3
				mil = 4
			}
			if = {
				limit = {
					NOT = { has_idea_group = barbary_pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
		switch_tag = SLE
	}
	option = { # pirates get released as a march
		name = "pirates.4.b"
		4563 = {
			add_base_tax = 2
			add_base_manpower = 2
		}
		release = SLE
		create_march = SLE
		SLE = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "Murat" # Jan Janszoon
				dynasty = "Reis"
				adm = 3
				dip = 3
				mil = 4
			}
			if = {
				limit = {
					NOT = { has_idea_group = barbary_pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
	}
	option = { # No, go away
		name = "pirates.4.c"
		4563 = {
			add_base_tax = 2
			add_base_manpower = 2
		}
		ai_chance = {
			factor = 0
		}
	}
}

# Tetouan
country_event = {
	id = pirates.5
	title = "pirates.5.t"
	picture = BARBARY_PIRATES_eventPicture
	desc = "women_history_events.56.d"

	fire_only_once = yes

	trigger = {
		has_dlc = "Golden Century"
		is_year = 1515
		NOT = { is_year = 1542 }
		NOT = { has_reform = pirate_republic_reform }
		NOT = { exists = TET }
		NOT = { exists = GRA }
		NOT = { exists = ADU }
		owns_core_province = 4561
		num_of_cities = 2
		is_subject = no
		religion_group = muslim
		4561 = {
			privateer_power = { share = 5 }
		}
		223 = {
			owner = {
				culture_group = iberian
				religion_group = christian
			}
		}
	}

	immediate = {
		hidden_effect = {
			4561 = {
				discover_country = TET
				add_core = TET
			}
		}
	}

	mean_time_to_happen = {
		months = 12
		# modifiers
	}

	option = { # play as the pirates
		name = "pirates.5.a"
		trigger = {
			ai = no
		}
		4561 = {
			add_base_tax = 2
			add_base_manpower = 2
		}
		release = TET
		create_guarantee = TET
		TET = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = andalucian
			discover_provinces = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "Sayyida"
				dynasty = "al Hurra"
				culture = andalucian
				adm = 4
				dip = 4
				mil = 5
				female = yes
			}
			if = {
				limit = {
					NOT = { has_idea_group = barbary_pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
		switch_tag = TET
	}
	option = { # pirates get released as a march
		name = "pirates.5.b"
		4561 = {
			add_base_tax = 2
			add_base_manpower = 2
		}
		release = TET
		create_march = TET
		TET = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = andalucian
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "Sayyida"
				dynasty = "al Hurra"
				culture = andalucian
				adm = 4
				dip = 4
				mil = 5
				female = yes
			}
			if = {
				limit = {
					NOT = { has_idea_group = barbary_pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
	}
	option = { # Go away
		name = "pirates.4.c"
		4561 = {
			add_base_tax = 2
			add_base_manpower = 2
		}
		ai_chance = {
			factor = 0
		}
	}
}

# Port Royal
country_event = {
	id = pirates.6
	title = "pirates.6.t"
	picture = PIRATE_CAPTAINS_eventPicture
	desc = "pirates.6.d"

	fire_only_once = yes

	trigger = {
		has_dlc = "Golden Century"
		NOT = { exists = PRY }
		has_global_flag = golden_age_of_piracy
		NOT = { has_reform = pirate_republic_reform }
		OR = {
			AND = {
				owns_core_province = 487
				is_subject = no
				num_of_cities = 2
			}
			any_subject_country = {
				owns_core_province = 487
				num_of_cities = 2
			}
		}
		487 = { # must be privateering in node
			privateer_power = {
				country = ROOT
				share = 5
			}
		}
		OR = {
			487 = {
				recent_treasure_ship_passage = yes
			}
			487 = {
				trade_share = {
					country = ROOT
					share = 10
				}
			}
			any_country = {
				capital_scope = {
					region = carribeans_region
				}
				war_exhaustion = 5
			}
		}
	}

	immediate = {
		hidden_effect = {
			487 = {
				discover_country = PRY
				add_core = PRY
			}
			random_country = {
				limit = {
					is_rival = ROOT
					any_subject_country = {
						any_owned_province = {
							OR = {
								region = mexico_region
								region = colombia_region
							}
						}
					}
				}
				save_event_target_as = spanish_main_country
			}
		}
	}

	mean_time_to_happen = {
		months = 12
		# modifiers
	}

	option = { # play as the pirates
		name = "pirates.6.a"
		trigger = {
			ai = no
		}
		487 = {
			owner = {
				release = PRY
			}
		}
		PRY = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			change_religion = ROOT
			change_primary_culture = ROOT
			discover_provinces = ROOT
			add_republican_tradition = 50
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "000000000"
				adm = 2
				dip = 2
				mil = 5
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
		switch_tag = PRY
	}
	option = { # pirates get released
		name = "pirates.6.b"
		487 = {
			owner = {
				release = PRY
			}
		}
		PRY = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			adopt_reform_progress = ROOT
			change_religion = ROOT
			change_primary_culture = ROOT
			add_republican_tradition = 50
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "000000000"
				adm = 2
				dip = 2
				mil = 5
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
	}
}

# Tortuga - Brethren of the Coast
country_event = {
	id = pirates.7
	title = "pirates.7.t"
	picture = PIRATE_CAPTAINS_eventPicture
	desc = "pirates.7.d"

	fire_only_once = yes

	trigger = {
		has_dlc = "Golden Century"
		NOT = { exists = TOR }
		NOT = { has_reform = pirate_republic_reform }
		489 = {
			OR = {
				religion = protestant
				religion = anglican
				religion = reformed
				religion = hussite
			}
		}
		has_global_flag = golden_age_of_piracy
		OR = {
			AND = {
				owns_core_province = 489
				is_subject = no
				num_of_cities = 2
			}
			any_subject_country = {
				owns_core_province = 489
				num_of_cities = 2
			}
		}
		OR = {
			489 = {
				recent_treasure_ship_passage = yes
			}
			489 = {
				privateer_power = { share = 1 }
			}
			any_country = {
				capital_scope = {
					region = carribeans_region
				}
				war_exhaustion = 5
			}
		}
	}

	immediate = {
		hidden_effect = {
			489 = {
				discover_country = TOR
				add_core = TOR
			}
		}
	}

	mean_time_to_happen = {
		months = 12
	}

	option = { # play as the pirates
		name = "pirates.7.a"
		# play as TOR
		trigger = {
			ai = no
		}
		489 = {
			owner = {
				release = TOR
			}
		}
		TOR = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			change_religion = ROOT
			change_primary_culture = ROOT
			discover_provinces = ROOT
			adopt_reform_progress = ROOT
			add_republican_tradition = 50
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "Henry Morgan"
				adm = 3
				dip = 5
				mil = 4
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
		switch_tag = TOR
	}
	option = { # pirates get released
		name = "pirates.7.b"
		489 = {
			owner = {
				release = TOR
			}
		}
		TOR = {
			change_government = republic
			add_government_reform = pirate_republic_reform
			add_republican_tradition = 50
			change_religion = ROOT
			change_primary_culture = ROOT
			adopt_reform_progress = ROOT
			capital_scope = {
				build_to_forcelimit = {
					infantry = 0.8
					artillery = 0.2
					heavy_ship = 0.3
					light_ship = 0.3
					transport = 0.3
				}
			}
			define_ruler = {
				name = "Henry Morgan"
				adm = 3
				dip = 5
				mil = 4
			}
			if = {
				limit = {
					NOT = { has_idea_group = pirate_ideas }
				}
				swap_free_idea_group = yes
			}
			swap_non_generic_missions = yes
			set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		}
	}
}

# Palembang - Return of Piracy
country_event = {
	id = pirates.8
	title = "pirates.8.t"
	picture = {
		trigger = { has_dlc = "Leviathan" }
		picture = MALAYAN_PORT_eventPicture
	}
	picture = {
		trigger = { NOT = { has_dlc = "Leviathan" } }
		picture = SMUGGLERS_eventPicture
	}
	desc = "pirates.8.d"

	fire_only_once = yes

	trigger = {
		tag = PLB
		NOT = { is_year = 1446 }
		has_dlc = "Golden Century"
		NOT = { has_reform = pirate_republic_reform }
	}

	mean_time_to_happen = {
		months = 1
	}

	option = {
		name = "pirates.8.a"
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				MAJ = {
					ai = no
				}
			}
		}
		grant_independence = yes
		change_government = republic
		add_government_reform = pirate_republic_reform
		define_ruler = {
			force_republican_names = yes
			culture = wu
		}
		add_republican_tradition = 50
		swap_non_generic_missions = yes
	}

	option = {
		name = "pirates.8.b"
		ai_chance = {
			factor = 1
		}
		add_stability = 1
	}
}

# Pattani - The Lin Daoqian Band
country_event = {
	id = pirates.9
	title = "pirates.9.t"
	picture = {
		trigger = { has_dlc = "Leviathan" }
		picture = MALAYAN_PORT_eventPicture
	}
	picture = {
		trigger = { NOT = { has_dlc = "Leviathan" } }
		picture = SMUGGLERS_eventPicture
	}
	desc = "pirates.9.d"

	fire_only_once = yes

	trigger = {
		tag = PAT
		has_dlc = "Golden Century"
		is_year = 1563
		NOT = { is_year = 1590 }
		NOT = { has_reform = pirate_republic_reform }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = "pirates.9.a"
		change_government = republic
		add_government_reform = pirate_republic_reform
		define_ruler = {
			name = "Lin Daoqian"
			culture = wu
			adm = 2
			dip = 2
			mil = 5
		}
		add_republican_tradition = 50
		set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		swap_non_generic_missions = yes
	}

	option = {
		name = "pirates.9.b"
		add_stability = -1
	}
}

# The Golden Age of Piracy
country_event = {
	id = pirates.20
	title = "pirates.20.t"
	picture = PIRATE_CAPTAINS_eventPicture
	desc = "pirates.20.d"

	major = yes

	fire_only_once = yes

	trigger = {
		has_dlc = "Golden Century"
		OR = {
			any_subject_country = {
				capital_scope = {
					region = carribeans_region
				}
			}
			1516 = {
				privateer_power = { country = ROOT share = 5 }
			}
		}
		OR = {
			any_country = {
				truce_with = ROOT
				OR = {
					any_subject_country = {
						capital_scope = {
							region = carribeans_region
						}
					}
					1516 = {
						privateer_power = { country = PREV share = 5 }
					}
				}
			}
			1516 = { # or just have a whole lot of privateers
				privateer_power = { country = ROOT share = 25 }
			}
		}
		has_privateers = yes
	}
	mean_time_to_happen = {
		months = 3
	}
	option = {
		name = "pirates.20.a"
		set_global_flag = golden_age_of_piracy
		custom_tooltip = golden_age_of_piracy_tooltip
	}
}

# Wokou Pirates in So
country_event = {
	id = pirates.21
	title = "pirates.21.t"
	picture = SMUGGLERS_eventPicture
	desc = "pirates.21.d"

	fire_only_once = yes
	major = yes

	trigger = {
		tag = SOO
		has_dlc = "Golden Century"
		any_country = {
			OR = {
				is_incident_happened = incident_wokou
				is_incident_active = incident_wokou
				has_country_flag = jap_wokou
			}
		}
		NOT = { has_reform = pirate_republic_reform }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = "pirates.21.a"
		change_government = republic
		add_government_reform = pirate_republic_reform
		define_ruler = {
			name = "Akibatsu Matsura"
			culture = kyushuan
			adm = 2
			dip = 2
			mil = 5
		}
		add_republican_tradition = 50
		set_ruler_flag = historical_pirate
			add_ruler_personality = legendary_pirate_personality
		swap_non_generic_missions = yes
	}

	option = {
		name = "pirates.21.b"
		add_stability = -1
	}
}



# Pirates of Rugen
country_event = {
	id = pirates.22
	title = "pirates.22.name"
	picture = SMUGGLERS_eventPicture
	desc = "pirates.22.desc"

	fire_only_once = yes

	trigger = {
		tag = RUG
		OR = {
			has_dlc = "Golden Century"
			has_dlc = "Lions of the North"	#Rgen is a special case as it is in the Baltic Sea too
		}
		owns_core_province = 4745
		NOT = { num_of_cities = 2 } #must be an OPM
		OR = {
			ai = no
			is_subject = no
		}
		NOT = { has_reform = pirate_republic_reform }
	}

	mean_time_to_happen = {
		months = 6
	}

	option = {
		name = "pirates.22.a"
		change_government = republic
		add_government_reform = pirate_republic_reform
		define_ruler = {
			force_republican_names = yes
			dynasty = "Strtebeker"
			culture = pommeranian
		}
		add_republican_tradition = 50
		swap_non_generic_missions = yes

		capital_scope = {
			galley = root
			galley = root
			galley = root
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = "pirates.22.b"
		add_stability = 1

		ai_chance = {
			factor = 0
		}
	}
}

# Pirates of Penzance (by James Beaumont)
country_event = {
	id = pirates.23
	title = "pirates.23.t"
	picture = SMUGGLERS_eventPicture
	desc = "pirates.23.d"

	fire_only_once = yes

	trigger = {
		tag = CRN
		has_dlc = "Golden Century"
		num_ships_privateering = 3
		NOT = { has_reform = pirate_republic_reform }
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = "pirates.23.a"
		ai_chance = {
			factor = 1
		}
		change_government = republic
		add_government_reform = pirate_republic_reform
		define_ruler = {
			force_republican_names = yes
			dynasty = "Carter"
		}
		233 = { rename_capital = "Penzance" }
		add_republican_tradition = 50
		set_ruler_flag = historical_pirate
		add_ruler_personality = legendary_pirate_personality
		swap_non_generic_missions = yes
	}

	option = {
		name = "pirates.23.b"
		ai_chance = {
			factor = 1
		}
		233 = {
			spawn_rebels = {
				size = 1
				type = particularist_rebels
			}
		}
	}
}

# Gilbert and Sulivan references to appease Daniel (by James Beaumont)
country_event = {
	id = pirates.24
	title = "pirates.24.t"
	picture = SMUGGLERS_eventPicture
	desc = "pirates.24.d"

	fire_only_once = yes

	trigger = {
		OR = {
			tag = CRN
			was_tag = CRN
		}
		has_dlc = "Golden Century"
		has_reform = pirate_republic_reform
		is_year = 1500
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = "pirates.24.a"
		ai_chance = {
			factor = 1
		}
		define_advisor = {
			type = naval_reformer
			skill = 3
			name = "Gilbert Patter"
			cost_multiplier = 0.25
		}
	}

	option = {
		name = "pirates.24.b"
		ai_chance = {
			factor = 1
		}
		define_ruler = {
			name = "00000"
			dynasty = "Patter"
			adm = 2
			dip = 2
			mil = 2
		}
	}
}


# [Root.Monarch.GetName] is now a legendary pirate!
country_event = {
	id = pirates.25
	title = pirates.25.t
	desc = pirates.25.desc
	picture = SMUGGLERS_eventPicture
	is_triggered_only = yes

	option = {
		name = pirates.25.a
		make_ruler_to_legendary_pirate = yes
		ai_chance = {
			factor = 1
		}
	}
}