add_namespace = Swedish_african_events

country_event = {
	id = Swedish_african_events.1
	title = Swedish_african_events.1.t
	desc = Swedish_african_events.1.d

	is_triggered_only = yes
	
	option = { 
	    name = Swedish_african_events.1.a
		trigger = {
			NOT = { has_country_flag = afr_traditional_tree }
			NOT = { has_country_flag = afr_jihadist_tree }
			NOT = {
				has_country_flag = afr_rrp_british_company_port
				has_country_flag = afr_rrp_french_company_port
				has_country_flag = afr_rrp_german_company_port
				has_country_flag = afr_rrp_bremen_company_port
				has_country_flag = afr_rrp_portugal_company_port
			}
		}
		ai_chance = {
			factor = 100
		}
		set_country_flag = SWE_negotiation_with_afr_kingdom_success_flag
		hidden_effect = {
			if = {
				limit = { SWE = { NOT = { has_country_flag = SWE_swedish_african_company_established_flag } } }
				SWE = { set_country_flag = SWE_swedish_african_company_established_flag }
			}
			ROOT = { country_event = { id = Swedish_african_events.5 days = 1 } }
			random_list = {
				25 = { FROM = { country_event = { id = Swedish_african_events.2 days = 10 random = 2 } } }
				25 = { FROM = { country_event = { id = Swedish_african_events.2 days = 14 random = 2 } } }
				25 = { FROM = { country_event = { id = Swedish_african_events.2 days = 18 random = 2 } } }
				25 = { FROM = { country_event = { id = Swedish_african_events.2 days = 22 random = 2 } } }
			}
		}
	}
	option = { 
	    name = Swedish_african_events.1.b
		trigger = {
			NOT = {
				has_country_flag = afr_rrp_british_company_port
				has_country_flag = afr_rrp_french_company_port
				has_country_flag = afr_rrp_german_company_port
				has_country_flag = afr_rrp_bremen_company_port
				has_country_flag = afr_rrp_portugal_company_port
			}
		}
		ai_chance = {
			factor = 100
		}
		hidden_effect = {
			random_list = {
				25 = { FROM = { country_event = { id = Swedish_african_events.3 days = 10 random = 2 } } }
				25 = { FROM = { country_event = { id = Swedish_african_events.3 days = 14 random = 2 } } }
				25 = { FROM = { country_event = { id = Swedish_african_events.3 days = 18 random = 2 } } }
				25 = { FROM = { country_event = { id = Swedish_african_events.3 days = 22 random = 2 } } }
			}
		}
	}
	option = { 
	    name = Swedish_african_events.1.c
		trigger={
			OR = {
				has_country_flag = afr_rrp_british_company_port
				has_country_flag = afr_rrp_french_company_port
				has_country_flag = afr_rrp_german_company_port
				has_country_flag = afr_rrp_bremen_company_port
				has_country_flag = afr_rrp_portugal_company_port
			}
		}
		ai_chance = {
			factor = 100
		}
		FROM = { country_event = { id = Swedish_african_events.4 days = 5 random = 5 } }
	}
}

country_event = {
	id = Swedish_african_events.2
	title = Swedish_african_events.2.t
	desc = Swedish_african_events.2.d

	is_triggered_only = yes
	
	option = { 
	    name = Swedish_african_events.2.a
		ai_chance = {
			factor = 100
		}
		if = {
			limit = { NOT = { has_idea = SWE_Colonial_Purchases } }
			add_timed_idea = { idea = SWE_Colonial_Purchases days = 365 }
		}
		FROM = { add_ideas = SWE_swedish_african_company_idea }
		FROM = { give_military_access = SWE }
	}
}

country_event = {
	id = Swedish_african_events.3
	title = Swedish_african_events.3.t
	desc = Swedish_african_events.3.d

	is_triggered_only = yes
	
	option = { 
	    name = Swedish_african_events.3.a
		ai_chance = {
			factor = 100
		}
	}
}

country_event = {
	id = Swedish_african_events.4
	title = Swedish_african_events.4.t
	desc = Swedish_african_events.4.d

	is_triggered_only = yes
	
	option = { 
	    name = Swedish_african_events.4.a
		ai_chance = {
			factor = 100
		}
	}
}

country_event = {
	id = Swedish_african_events.5
	is_triggered_only = yes
	hidden = yes
	immediate = {
		FROM = {
			if = {
			}
		}
	}
}

country_event = {
	id = Swedish_african_events.6
	title = Swedish_african_events.6.t
	desc = Swedish_african_events.6.d

	is_triggered_only = yes
	
	option = { 
	    name = Swedish_african_events.6.a
		ai_chance = {
			factor = 100
		}
		if = {
			limit = {
				OR = {
					owns_state = 871
					owns_state = 874
					owns_state = 558
					owns_state = 796
					owns_state = 798
					owns_state = 800
				}
			}
			random_owned_state = {
				limit = {
					OR = {
						state = 871
						state = 874
						state = 558
						state = 796
						state = 798
						state = 800
					}
				}
				if = {
					limit = {
						state = 871
						has_state_flag = afr_rrp_sweden_company_headquarters
					}
					add_building_construction = {
						type = infrastructure
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = bunker
						level = 1
						instant_build = yes
						province = 2050
					}
					add_building_construction = {
						type = naval_base
						level = 1
						instant_build = yes
						province = 2050
					}
					SWE = {
						diplomatic_relation = {
							country = ROOT
							relation = docking_rights
							active = yes
						}
					}
				}
				else_if = {
					limit = {
						state = 874
						has_state_flag = afr_rrp_sweden_company_headquarters
					}
					add_building_construction = {
						type = infrastructure
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = bunker
						level = 1
						instant_build = yes
						province = 4952
					}
					add_building_construction = {
						type = naval_base
						level = 1
						instant_build = yes
						province = 4952
					}
					SWE = {
						diplomatic_relation = {
							country = ROOT
							relation = docking_rights
							active = yes
						}
					}
				}
				else_if = {
					limit = {
						state = 558
						has_state_flag = afr_rrp_sweden_company_headquarters
					}
					add_building_construction = {
						type = infrastructure
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = bunker
						level = 1
						instant_build = yes
						province = 10831
					}
					add_building_construction = {
						type = naval_base
						level = 1
						instant_build = yes
						province = 10831
					}
					SWE = {
						diplomatic_relation = {
							country = ROOT
							relation = docking_rights
							active = yes
						}
					}
				}
				else_if = {
					limit = {
						state = 796
						has_state_flag = afr_rrp_sweden_company_headquarters
					}
					add_building_construction = {
						type = infrastructure
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = bunker
						level = 1
						instant_build = yes
						province = 13330
					}
					add_building_construction = {
						type = naval_base
						level = 1
						instant_build = yes
						province = 13330
					}
					SWE = {
						diplomatic_relation = {
							country = ROOT
							relation = docking_rights
							active = yes
						}
					}
				}
				else_if = {
					limit = {
						state = 798
						has_state_flag = afr_rrp_sweden_company_headquarters
					}
					add_building_construction = {
						type = infrastructure
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = bunker
						level = 1
						instant_build = yes
						province = 13332
					}
					add_building_construction = {
						type = naval_base
						level = 1
						instant_build = yes
						province = 13332
					}
					SWE = {
						diplomatic_relation = {
							country = ROOT
							relation = docking_rights
							active = yes
						}
					}
				}
				else_if = {
					limit = {
						state = 800
						has_state_flag = afr_rrp_sweden_company_headquarters
					}
					add_building_construction = {
						type = infrastructure
						level = 1
						instant_build = yes
					}
					add_building_construction = {
						type = bunker
						level = 1
						instant_build = yes
						province = 13334
					}
					add_building_construction = {
						type = naval_base
						level = 1
						instant_build = yes
						province = 13334
					}
					SWE = {
						diplomatic_relation = {
							country = ROOT
							relation = docking_rights
							active = yes
						}
					}
				}
				
			}
		}
		else_if = {
			random_owned_state = {
				limit = { has_state_flag = afr_rrp_sweden_company_headquarters }
				add_building_construction = {
					type = infrastructure
					level = 1
					instant_build = yes
				}
				
			}
		}
		else = {
			capital_scope = {
				add_building_construction = {
					type = infrastructure
					level = 1
					instant_build = yes
				}
				
			}
		}
	}
}
