#Tortuga AI 
country_event = {

	id = 17900
	
	trigger = { 
               	controls = 489 # Tortuga
		year = 1500
		NOT = { 
			has_country_flag = Disable
              		year = 1700
                	has_country_flag = buccaneers_release
			has_country_flag = buccaneers_second 
			exists = BUC
			exists = RPC
			VAR = { has_country_flag = BUC_No }
			religion_group = pagan
		}
	}

        mean_time_to_happen = {   
		months = 120

		modifier = { 
			factor = 0.9 
			revolt_percentage = 0.25	
		}
		modifier = { 
			factor = 0.9 
			has_country_flag = civil_war
		}
        	modifier = { 
			factor = 0.9 
			NOT = { stability = 0 }
		}
        	modifier = { 
			factor = 0.75 
			NOT = { ADM = 3 }
		}
        	modifier = { 
			factor = 0.9 
			has_country_flag = rebellion
		}
        }

	title = "EVTNAME17900"#	The Brethren of the Coast stir...
	desc = "EVTDESC17900"#	The gradual abandonment of Tortuga has allowed the return of both French and English pirates.
	
	option = {
	name = "EVTOPTA17900"#	The Pirates set sail!
		ai_chance = { factor = 100 }
		489 = { citysize = 1000 }
		489 = { add_building = fort1 }
		489 = { add_building = shipyard }
		489 = { add_building = regimental_camp }
		489 = { add_building = temple }
		489 = { add_building = workshop }
		489 = { add_building = constable }
		489 = { add_building = courthouse }
		489 = { add_building = marketplace }
		489 = { add_building = tax_assessor }
		489 = { add_building = customs_house }
		489 = { religion = free }
		489 = { culture = pirate }
		BUC = { badboy = 3 }
		BUC = { treasury = 500 }
                set_country_flag = buccaneers_release
	}
}

#BUC formation
country_event = {

	id = 17901
	
	trigger = {
		NOT = {
			religion_group = pagan
			has_country_flag = Disable
			has_country_flag = Player
			exists = BUC
			exists = RPC 
			year = 1700
			VAR = { has_country_flag = BUC_No }
		} 
                has_country_flag = buccaneers_release
                year = 1500
	}

	mean_time_to_happen = {
		months = 12
        }
	
	title = "EVTNAME17901"#	The Brethren take land
	desc = "EVTDESC17901"#	Buccaneers return to Tortuga in force, more and more they frequent the island and control is slipping away from the government.
	
	option = {
	name = "EVTOPTA17901"#	Avast, me hearties. Oh dear.
		release = BUC
          	set_country_flag = buccaneers_second
		clr_country_flag = buccaneers_release	
	}
}

#Jamaica (port royal) AI
country_event = {

	id = 17902
	
	trigger = { 
                controls = 487 #jamaica
		year = 1500
		NOT = {
			religion_group = pagan
			has_country_flag = Disable
			has_country_flag = Player
               		year = 1700
                	has_country_flag = buccaneers_release
			has_country_flag = buccaneers_second
			exists = BUC
			exists = RPC
			VAR = { has_country_flag = BUC_No }
		}
	}

        mean_time_to_happen = {   
		months = 120

		modifier = { 
			factor = 0.9 
			revolt_percentage = 0.25	
		}
		modifier = { 
			factor = 0.9 
			has_country_flag = civil_war
		}
        	modifier = { 
			factor = 0.9 
			NOT = { stability = 0 }
		}
        	modifier = { 
			factor = 0.75 
			NOT = { ADM = 3 }
		}
        	modifier = { 
			factor = 0.9 
			has_country_flag = rebellion
		}
        }

	
	title = "EVTNAME17902"#	The Brethren of the Coast stir...
	desc = "EVTDESC17902"#	The gradual abandonment of Port Royal has allowed the return of both French and English pirates.
	
	option = {
	name = "EVTOPTA17902"#	The Pirates set sail!
		ai_chance = { factor = 100 }
		487 = { citysize = 1000 }
		487 = { add_building = fort1 }
		487 = { add_building = shipyard }
		487 = { add_building = regimental_camp }
		487 = { add_building = temple }
		487 = { add_building = workshop }
		487 = { add_building = constable }
		487 = { add_building = courthouse }
		487 = { add_building = marketplace }
		487 = { add_building = tax_assessor }
		487 = { add_building = customs_house }
		487 = { religion = free }
		487 = { culture = pirate }
		BUC = { badboy = 3 }
		BUC = { treasury = 500 }
                set_country_flag = buccaneers_release
	}
}

#player set-up
country_event = {

	id = 17904
	
	trigger = {
		has_country_flag = Player
		tag = BUC
		year = 1500
		NOT = { 
			has_country_flag = Disable
			has_country_flag = player_buc
			VAR = { has_country_flag = BUC_No }
                	year = 1700
			exists = RPC 
		}
	}

        mean_time_to_happen = {   
		months = 1
        }

	
	title = "EVTNAME17904"#	Brethren of the Coast
	desc = "EVTDESC17904"#	The gradual abandonment of Tortuga has allowed the return of both French and English pirates. We are hated beyond measure but a few countries may try to buy us off.
	
	option = {
	name = "EVTOPTA17904"#	The Pirates set sail!
		ai_chance = { factor = 100 }
		489 = { citysize = 2000 }
		489 = { add_building = fort1 }
		489 = { add_building = shipyard }
		489 = { add_building = regimental_camp }
		badboy = 3
		treasury = 500
		set_country_flag = player_buc
		add_core = 487
		add_core = 489
	}
}

#Divide the Plunder
country_event = {

	id = 17905
	
	trigger = { 
                exists = BUC
		tag = BUC
		year = 1500
		NOT = {
			VAR = { has_country_flag = BUC_No }
			has_country_flag = Disable
		}
		treasury = 501
	}

        mean_time_to_happen = {   
		months = 12
        }

	
	title = "EVTNAME17905"#	Divide the Plunder
	desc = "EVTDESC17905"#	It is time to split the plunder among all the ship crews and the raiders.
	
	option = {
	name = "EVTOPTA17905"#	Shiver me timbers!
		ai_chance = { factor = 50 }
		489 = { change_manpower = -1 }
		
	}
	option = {
	name = "EVTOPTB17905"#	Aye
		ai_chance = { factor = 50 }
		treasury = -100
	}
}

# Buccaneer Raids
province_event = {

	id = 17906

	trigger = {
		controller = {
			tag = BUC
		}
		owner = {
			NOT = { tag = BUC }
		}
	}

	mean_time_to_happen = {
		months = 12 
		
		modifier = { 
			factor = 2.0 
			has_province_flag = Buc_looting
		}
	}

	title = "EVTNAME17906"#	Buccaneer Raids
	desc = "EVTDESC17906"#	The Brethren of the Coast have looted one of our provinces. This cannot be tolerated.
	
	option = {
	name = "EVTOPTA17906"#	Bloody Pirates!
		ai_chance = { factor = 100 }
		add_province_modifier = {
			name = "tax_reduction"
			duration = 600
		} 
		set_province_flag = Buc_looting
		BUC = { 
			treasury = 300 
		}	
	}
}

#AI tortuga 2
country_event = {

	id = 17907
	
	trigger = { 
               	OR = {
			controls = 489
			controls = 487
		}
		year = 1500
		has_country_flag = buccaneers_second
		NOT = {
			religion_group = pagan
			has_country_flag = Disable
              		year = 1700
                	has_country_flag = buccaneers_release
			has_country_flag = buccaneers_no
			exists = BUC
			exists = RPC
			VAR = { has_country_flag = BUC_No }
		}
	}

        mean_time_to_happen = {   
		months = 120

		modifier = { 
			factor = 0.9 
			revolt_percentage = 0.25	
		}
		modifier = { 
			factor = 0.9 
			has_country_flag = civil_war
		}
        	modifier = { 
			factor = 0.9 
			NOT = { stability = 0 }
		}
        	modifier = { 
			factor = 0.75 
			NOT = { ADM = 3 }
		}
        	modifier = { 
			factor = 0.9 
			has_country_flag = rebellion
		}
        }

	
	title = "EVTNAME17907"#	The Brethren of the Coast
	desc = "EVTDESC17907"#	The Buccaneers are getting ready to overtake Tortuga once again.
	
	option = {
	name = "EVTOPTA17907"#	Why me?
		ai_chance = { factor = 100 }
		489 = { add_building = fort2 }
		489 = { religion = free }
		489 = { culture = pirate }
		BUC = { badboy = 3 }
		BUC = { treasury = 500 }
                set_country_flag = buccaneers_release
		set_country_flag = buccaneers_no
	}
}

#AI Port Royal 2
country_event = {

	id = 17908
	
	trigger = { 
               	OR = {
			controls = 489
			controls = 487
		}
		year = 1500
		has_country_flag = buccaneers_second
		NOT = {
			religion_group = pagan
			has_country_flag = Disable
              		year = 1700
                	has_country_flag = buccaneers_release
			has_country_flag = buccaneers_no
			exists = BUC
			exists = RPC
			VAR = { has_country_flag = BUC_No }
		}
	}

        mean_time_to_happen = {   
		months = 120

		modifier = { 
			factor = 0.9 
			revolt_percentage = 0.25	
		}
		modifier = { 
			factor = 0.9 
			has_country_flag = civil_war
		}
        	modifier = { 
			factor = 0.9 
			NOT = { stability = 0 }
		}
        	modifier = { 
			factor = 0.75 
			NOT = { ADM = 3 }
		}
        	modifier = { 
			factor = 0.9 
			has_country_flag = rebellion
		}
        }

	
	title = "EVTNAME17908"#	The Brethren of the Coast
	desc = "EVTDESC17908"#	The Buccaneers are getting ready to overtake Port Royal once again.
	
	option = {
	name = "EVTOPTA17908"#	Why me?
		ai_chance = { factor = 100 }
		487 = { add_building = fort2 }
		487 = { religion = free }
		487 = { culture = pirate }
		BUC = { badboy = 3 }
		BUC = { treasury = 500 }
                set_country_flag = buccaneers_release
		set_country_flag = buccaneers_no
	}
}

#Privateer commonwealth
country_event = {

	id = 17903
	
	trigger = { 
		num_of_cities = 8
               	tag = BUC
		exists = BUC
		year = 1500
		NOT = { 
			has_country_flag = Disable
                	government = privateer_commonwealth
			VAR = { has_country_flag = BUC_No }
			exists = RPC
		}
	}

        mean_time_to_happen = {   
		months = 12
        }

	
	title = "EVTNAME17903"#	Time for change
	desc = "EVTDESC17903"#	With the increase in controlled land, we must now create a government in order to bring in taxes and maintain order.
	
	option = {
	name = "EVTOPTA17903"#	Where's my grog?
		ai_chance = { factor = 100 }
		government = privateer_commonwealth
		badboy = -1
		government_tech = 20000
	}
}

#agnostic
country_event = {

	id = 17909
	
	trigger = { 
		num_of_cities = 10
               	tag = BUC
		exists = BUC
		year = 1500
		NOT = { 
			has_country_flag = Disable
                	religion = agnostic
			VAR = { has_country_flag = BUC_No }
			exists = RPC
		}
	}

        mean_time_to_happen = {   
		months = 12
        }

	
	title = "EVTNAME17909"#	State religion
	desc = "EVTDESC17909"#	It is now time to establish a 'most popular', or prefered religion for our country. This is just one more step of bringing our state to a more legitimate status.
	
	option = {
	name = "EVTOPTA17909"#	Do we even need churches?
		ai_chance = { factor = 100 }
		religion = agnostic
		badboy = -1
		489 = { religion = agnostic }
	}
}

# BUC conquest
province_event = {

	id = 17910

	trigger = {
		controller = {
			tag = BUC
		}
		owner = {
			NOT = { tag = BUC }
			num_of_cities = 2
		}
	}

	mean_time_to_happen = {
		months = 50 
		
		modifier = { 
			factor = 0.5 
			has_province_flag = Buc_looting
		}
	}

	title = "EVTNAME17910"#	Buccaneer conquest
	desc = "EVTDESC17910"#	The Brethren of the Coast have taken one of our provinces. This cannot be tolerated.
	
	option = {
	name = "EVTOPTA17910"#	They shall pay!
		ai_chance = { factor = 100 }
		secede_province = BUC
		BUC = {
			badboy = 1
		}	
	}
}

#RPC
country_event = {

	id = 17911
	
	trigger = { 
		num_of_cities = 12
               	tag = BUC
		exists = BUC
		year = 1500
		government = privateer_commonwealth
		religion = agnostic
		NOT = { 
			has_country_flag = Disable
			exists = RPC
			VAR = { has_country_flag = BUC_No }
		}
	}

        mean_time_to_happen = {   
		months = 12
        }

	
	title = "EVTNAME17911"#	Buccaneer Reformation
	desc = "EVTDESC17911"#	It is now time to establish a new national identity. This is just one more step of bringing our state to a more legitimate status.
	
	option = {
	name = "EVTOPTA17911"#	So no more plundering?
		ai_chance = { factor = 100 }
		government = republican_dictatorship
		badboy = -3
		prestige = 0.25
		change_tag = RPC
	}
}

# RPC cores
province_event = {

	id = 17912

	trigger = {
		owner = {
			tag = RPC
		}
		NOT = { 
			owner = {
				has_country_flag = Disable
			}
			is_core = THIS
		}
	}

	mean_time_to_happen = {
		months = 50 
		
	}

	title = "EVTNAME17912"#	PRC claims
	desc = "EVTDESC17912"#	We have declared this land as being our offical territory.
	
	option = {
	name = "EVTOPTA17912"#	Where be the tavern?
		ai_chance = { factor = 100 }
		owner = {
			badboy = 1
		}
		add_core = THIS	
	}
}

# RPC religion
province_event = {

	id = 17913

	trigger = {
		exists = RPC #fuzzbug
		owner = {
			tag = RPC
		}
		is_core = THIS
		NOT = { 
			owner = {
				has_country_flag = Disable
			}
			religion = agnostic
		}
	}

	mean_time_to_happen = {
		months = 50
		
	}

	title = "EVTNAME17913"#	Agnostic Views
	desc = "EVTDESC17913"#	Most of our nation's population is slowly sharing our national religious views.
	
	option = {
	name = "EVTOPTA17913"#	If we must!
		ai_chance = { factor = 100 }
		owner = {
			prestige = 0.05
		}
		religion = agnostic	
	}
}

#ai set-up first time tortuga
country_event = {

	id = 17914
	
	trigger = { 
                exists = BUC
		tag = BUC
		year = 1500
		NOT = { 
			has_country_flag = Disable
			has_country_flag = player_buc
			has_country_flag = Player
			has_country_flag = buccaneers_release
			has_country_flag = buccaneers_second
                	year = 1700
			exists = RPC
			VAR = { has_country_flag = BUC_No }
		}
	}

        mean_time_to_happen = {   
		months = 1
        }

	
	title = "EVTNAME17914"#	Brethren of the Coast
	desc = "EVTDESC17914"#	The gradual abandonment of Tortuga has allowed the return of both French and English pirates. We are hated beyond measure but a few countries may try to buy us off.
	
	option = {
	name = "EVTOPTA17914"#	The Pirates set sail!
		ai_chance = { factor = 100 }
		489 = { citysize = 2000 }
		489 = { add_building = fort1 }
		489 = { add_building = shipyard }
		489 = { add_building = regimental_camp }
		489 = { add_building = temple }
		489 = { add_building = workshop }
		489 = { add_building = constable }
		489 = { add_building = courthouse }
		489 = { add_building = marketplace }
		489 = { add_building = tax_assessor }
		489 = { add_building = customs_house }
		489 = { religion = free }
		489 = { culture = pirate }
		government = anarchy
		religion = free
		badboy = 3
		treasury = 500
		set_country_flag = player_buc
	}
}

#End of Organized Piracy
country_event = {

	id = 17915
	
	trigger = { 
                exists = BUC
		year = 1700
		knows_country = BUC
		war = no
		BUC = { ai = yes }
		NOT = { 
			has_country_flag = Disable
			exists = RPC
			tag = BUC
			technology_group = african
			technology_group = new_world 
		}
	}

        mean_time_to_happen = {   
		months = 240

		modifier = {
			factor = 0.5
			has_country_flag = Anti_Piracy
		}
		modifier = {
			factor = 0.5
			idea = quest_for_the_new_world
		}
		modifier = {
			factor = 5.0
			has_country_flag = Piracy
		}
		modifier = {
			factor = 3.0
			overlord = {
				has_country_flag = Player
			}
		}
		modifier = {
			factor = 1.5
			has_country_flag = Player
		}
		modifier = {
			factor = 0.7
			idea = vice_roys
		}
        }

	
	title = "EVTNAME17915"#	Anti-Piracy Policies
	desc = "EVTDESC17915"#	Most of the Latin World has started to realize that organized piracy must come to a end.
	
	option = {
	name = "EVTOPTA17915"#	Let us end this problem
		ai_chance = {
			factor = 50
			days = 1
			modifier = {
				factor = 0.2 	#10
				has_country_flag = Piracy
			}
			modifier = {
				factor = 1.8	#90%
				has_country_flag = Anti_Piracy
			}
		}
		relation = { who = BUC value = -100 }
		prestige = 0.05
		war = BUC
		BUC = { 
			treasury = -500
			stability = -5
			badboy = 5
		}
	}
	option = {
	name = "EVTOPTB17915"#	This is not our problem
		ai_chance = {
			factor = 50
			days = 1
			modifier = {
				factor = 1.8	#90% 
				has_country_flag = Piracy
			}
			modifier = {
				factor = 0.2 	#10
				has_country_flag = Anti_Piracy
			}
		}
		prestige = -0.05
	}
}

#BUC Cores
country_event = {

	id = 17916
	
	trigger = {
		NOT = {
			VAR = { 
				has_country_flag = BUC_No
				has_country_flag = Custom_Set 
				has_country_flag = Custom_Comp
			}
			BUC = { is_core = 489 }
			year = 1699
			exists = RPC
		}
		OR = { 
			AND = {
				any_neighbor_country = {
					has_country_flag = Player
				}
				ai = yes
				NOT = { exists = BUC }
			}
			tag = BUC
			ai = yes
		}
	}
	
	mean_time_to_happen = {
		months = 24

		modifier = {
			factor = 0.1
			tag = BUC
		}
		modifier = {
			factor = 0.01
			AND = {
				has_country_flag = Player
				tag = BUC
			}
		}
		modifier = {
			factor = 0.1
			any_neighbor_country = {
				has_country_flag = Player
			}
		}
	}
	
	title = "EVTNAME17916"#	Buccaneer Cores
	desc = "EVTDESC17916"#	This places the cores for the Buccaneer so that they can appear.
	
	option = {
	name = "EVTOPTA17916"#	OK
		BUC = {
			add_core = 487
			add_core = 489
		}
	}
}

#End of BUC
country_event = {

	id = 17917
	
	trigger = { 
		year = 1700
		NOT = { 
			has_country_flag = Disable
			exists = RPC
			exists = BUC 
		}
		owns = 489
		BUC = {
			OR = {
				is_core = 489
				is_core = 487
			}
		}
	}

        mean_time_to_happen = {   
		months = 6
        }

	
	title = "EVTNAME17917"#	End of the Buccaneer
	desc = "EVTDESC17917"#	Finaly, Organized piracy is near its end. We no longer have to wory as much about our Navy being attacked by Pirates.
	
	option = {
	name = "EVTOPTA17917"#	Let us end this problem
		ai_chance = { factor = 100 }
		prestige = 0.05
		489 = { religion = reformed }
		487 = { religion = reformed }
		BUC = {
			remove_core = 487
			remove_core = 489
		}
	}
}

