﻿###########################
# Cyrenaica and Tripolitania Events
###########################
# By Jeankedezeehond
###########################

add_namespace = libya

### Libya introduction
country_event = {
	id = libya.1
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.1" }
	title = libya.1.t
	desc = libya.1.d
	picture = GFX_OTT_Idris_Back

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.1.a
		if = {
			limit = {
				is_ai = yes # help the AI out
			}
			add_stability = 0.2
			add_war_support = 0.2
		}
	}
}

country_event = {
	id = libya.2 #[LBA.GetLeader] Incapacitated
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.2" }
	title = libya.2.t
	desc = libya.2.d
	picture = GFX_OTT_Civil_War_Jabal

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.2.a
		create_country_leader = {
			name = "Senussi Regency Council"
			picture = "gfx/leaders/LBA/Portrait_LBA_Regency_Council.png"
			ideology = pataut_islamism_subtype
		}
		create_country_leader = {
			name = "Senussi Regency Council"
			picture = "gfx/leaders/LBA/Portrait_LBA_Regency_Council.png"
			ideology = natpop_islamism_subtype
		}
		random_unit_leader = {
			limit = { has_id = 613 }
			remove_unit_leader = yes
		}
	}
}

country_event = {
	id = libya.3 # Idris Speaks at the Third Arab Congress
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.3" }
	title = libya.3.t
	desc = libya.3.d
	picture = GFX_report_event_EGY_egyptian_palace

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.3.a
		add_stability = -0.05
		hidden_effect = {
			TUR = {
				country_event = {
					id = libyanew.7 # Idris Legitimists Gather Support
					days = 1
				}
			}
			EGY = {
				country_event = {
					id = libyanew.7 # Idris Legitimists Gather Support
					days = 1
				}
			}
			TUN = {
				country_event = {
					id = libyanew.7 # Idris Legitimists Gather Support
					days = 1
				}
			}
			NFA = {
				country_event = {
					id = libyanew.7 # Idris Legitimists Gather Support
					days = 1
				}
			}
			country_event = {
				id = libya.4 # Scheming in Benghazi
				days = 189 random_days = 15
			}
			country_event = {
				id = libya.31 #Rise of Pan-Arabism in Cyrenaica
				days = 100 random_days = 7
			}
		}
	}
}

country_event = {
	id = libya.4 # Scheming in Benghazi
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.4" }
	title = libya.4.t
	desc = libya.4.d
	picture = GFX_OTT_Al_Qurnah

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.4.a # assassination succeeds
		ai_chance = {
			base = idris_support
			modifier = {
				factor = 0
				OR = {
					has_game_rule = {
						rule = LBA_politics
						option = LBA_POLITICS_UMAR_OTTOMANS
					}
					has_game_rule = {
						rule = LBA_politics
						option = LBA_POLITICS_UMAR_ISLAM
					}
				}
			}
		}
		hidden_effect = {
			country_event = {
				id = libya.5
				days = 10
			}
			TUR = {
				country_event = {
					id = libyanew.8 # al-Mukhtar Killed in [LBA.GetName]
					days = 9
				}
			}
			EGY = {
				country_event = {
					id = libyanew.8
					days = 9
				}
			}
			SUD = {
				country_event = {
					id = libyanew.8
					days = 9
				}
			}
			NFA = {
				country_event = {
					id = libyanew.8
					days = 9
				}
			}
			TUN = {
				country_event = {
					id = libyanew.8
					days = 9
				}
			}
		}
	}
	option = {
		name = libya.4.b # attemped assassination but fails
		ai_chance = {
			base = 20
			modifier = {
				factor = 0
				OR = {
					has_game_rule = {
						rule = LBA_politics
						option = LBA_POLITICS_IDRIS
					}
					has_game_rule = {
						rule = LBA_politics
						option = LBA_POLITICS_IDRIS_OTTOMAN_WAR
					}
				}
			}
		}
		hidden_effect = {
			country_event = {
				id = libya.6
				days = 10
			}
		}
	}
}

country_event = {
	id = libya.5 #Assassination of al-Mukhtar
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.5" }
	title = libya.5.t
	desc = libya.5.d
	picture = GFX_report_event_minaret

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.5.a
		add_stability = -0.05
		random_unit_leader = {
			limit = { has_id = 610 }
			remove_unit_leader = yes
		}
		set_country_flag = Umar_al_Mukhtar_dead
		hidden_effect = {
			country_event = {
				id = libya.7
				days = 10
			}
			country_event = {
				id = libya.35
				days = 700
			}
		}
	}
}

country_event = {
	id = libya.6 #Assassination Attempt on al-Mukhtar
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.6" }
	title = libya.6.t
	desc = libya.6.d
	picture = GFX_OTT_Civil_War_Jabal

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.6.a
		add_stability = -0.1
		hidden_effect = {
			country_event = {
				id = libya.8
				days = 10
			}
		}
	}
}

country_event = {
	id = libya.7 #al-Sanusi Invites Idris to Kufra
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.7" }
	title = libya.7.t
	desc = libya.7.d
	picture = GFX_OTT_Idris_Back

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.7.a
		hidden_effect = {
			add_popularity = {
				ideology = authoritarian_democrat
				popularity = 0.2
			}
			create_country_leader = {
				name = "Idris I"
				desc = "POLITICS_IDRIS_DESC"
				picture = "gfx/leaders/LBA/Portrait_LBA_Idris.png"
				expire = "1.1.1"
				ideology = socdem_islamism_subtype
			}
			create_country_leader = {
				name = "Idris I"
				desc = "POLITICS_IDRIS_DESC"
				picture = "gfx/leaders/LBA/Portrait_LBA_Idris.png"
				expire = "1.1.1"
				ideology = soclib_islamism_subtype
			}
			create_country_leader = {
				name = "Idris I"
				desc = "POLITICS_IDRIS_DESC"
				picture = "gfx/leaders/LBA/Portrait_LBA_Idris.png"
				expire = "1.1.1"
				ideology = marlib_islamism_subtype
			}
			create_country_leader = {
				name = "Idris I"
				desc = "POLITICS_IDRIS_DESC"
				picture = "gfx/leaders/LBA/Portrait_LBA_Idris.png"
				expire = "1.1.1"
				ideology = soccon_islamism_subtype
			}
			create_country_leader = {
				name = "Idris I"
				desc = "POLITICS_IDRIS_DESC"
				picture = "gfx/leaders/LBA/Portrait_LBA_Idris.png"
				expire = "1.1.1"
				ideology = islamism_subtype
			}
			create_country_leader = {
				name = "Idris I"
				desc = "POLITICS_IDRIS_DESC"
				picture = "gfx/leaders/LBA/Portrait_LBA_Idris.png"
				expire = "1.1.1"
				ideology = natpop_islamism_subtype
			}
		}

		create_field_marshal = {
			name = "Idris I"
			portrait_path = "gfx/leaders/LBA/Portrait_LBA_Idris.png"
			skill = 1
			attack_skill = 1
			defense_skill = 1
			planning_skill = 1
			logistics_skill = 1
			traits = {
				politically_connected
				old_guard
			}
		}

		set_politics = {
			ruling_party = authoritarian_democrat
			elections_allowed = no
		}

		if = {
			limit = {
				country_exists = TUR
				NOT = { has_global_flag = AXIS_VICTORY }
				TUR = { is_subject = no }
			}
			TUR = { country_event = ottsep.15 }
		}
		hidden_effect = {
			EGY = { country_event = libyanew.9 }
			TUN = { country_event = libyanew.9 }
			NFA = { country_event = libyanew.9 }
			SUD = { country_event = libyanew.9 }
		}
		complete_national_focus = LBA_idris_the_liberator
	}
}

country_event = {
	id = libya.8 #Civil War in Cyrenaica
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.8" }
	title = libya.8.t
	desc = libya.8.d
	picture = GFX_LBA_Senussi_Warrior

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.8.a
		add_stability = -0.25
		451 = {
			set_demilitarized_zone = yes
		}
		hidden_effect = {
			country_event = {
				id = libya.9
				days = 70
			}
		}
	}
}

country_event = {
	id = libya.9 #Defeat of the Senussi Princes
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.9" }
	title = libya.9.t
	desc = libya.9.d
	picture = GFX_OTT_Civil_War_Jabal

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = libya.9.a
		add_stability = 0.2
		hidden_effect = {
			TUR = { country_event = libyanew.10 }
			EGY = { country_event = libyanew.10 }
			TUN = { country_event = libyanew.10 }
			NFA = { country_event = libyanew.10 }
			SUD = { country_event = libyanew.10 }
		}
		451 = {
			set_demilitarized_zone = no
		}
		create_country_leader = {
			name = "Umar al-Mukhtar"
			desc = "POLITICS_MUKHTAR_DESC"
			picture = "gfx/leaders/LBA/Portrait_LBA_Omar_Mukhtar.png"
			expire = "1.1.1"
			ideology = natpop_islamism_subtype
		}
		add_popularity = {
			ideology = national_populist
			popularity = 0.35
		}
		set_politics = {
			ruling_party = national_populist
			elections_allowed = no
		}
		remove_all_minister_types = yes
		add_ideas = {
			LBA_Umar_al_Mukhtar_hog_npo
			LBA_As_Siddig_al_Mutassir_for_pau
			LBA_Yousef_Borheil_al_Massari_eco_npo
			LBA_Omar_Faiek_Shennib_sec_pau
		}
		complete_national_focus = LBA_loyalty_own_reward
		set_country_flag = LBA_idris_btfo
	}
}

country_event = { #Weltkrieg victory anniversary
	id = libya.10
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.10" }
	title = libya.10.t
	desc = libya.10.d
	picture = GFX_report_event_tunisiatown

	fire_only_once = yes

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.10.a
		add_political_power = 10
	}
}

country_event = { #The war of independence has begun!
	id = libya.11
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.11" }
	title = libya.11.t
	desc = libya.11.d
	picture = GFX_LBA_Senussi_Warrior

	fire_only_once = yes

	trigger = {
		is_in_faction_with = EGY
		has_war_with = TUR
	}

	is_triggered_only = yes

	option = {
		name = libya.11.a
		add_manpower = 13894
		add_war_support = 0.1
	}
}

country_event = { #anti-imperial rhetoric
	id = libya.12
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.12" }
	title = libya.12.t
	desc = libya.12.d
	picture = GFX_report_event_tunisiatown

	fire_only_once = yes

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.12.a
		add_political_power = 50
		add_war_support = 0.02
	}
}

country_event = { #what about the European attack on morroco?
	id = libya.13
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.13" }
	title = libya.13.t
	desc = libya.13.d
	picture = GFX_report_event_nomads

	fire_only_once = yes

	trigger = {
		tag = LBA
		is_subject = no
		MOR = {
			is_subject = no
			OR = {
				has_war_with = NFA
				has_war_with = SFA
				has_war_with = SPR
			}
		}
	}

	mean_time_to_happen = {
		days = 30
	}

	option = {
		ai_chance = {
			factor = 20
		}
		name = libya.13.a #its a system we cant afford to lose
		MOR = {
			country_event = {
				id = libya.14
				days = 5
			}
		}
		add_manpower = -1500
		add_equipment_to_stockpile = {
			type = infantry_equipment_0
			amount = -500
			producer = LBA
		}
	}

	option = {
		ai_chance = {
			factor = 80
		}
		name = libya.13.b #we cant afford
		add_political_power = 20
	}
}

country_event = { #morroco gets aid during nfa war
	id = libya.14
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.14" }
	title = libya.14.t
	desc = libya.14.d
	picture = GFX_report_event_nomads

	is_triggered_only = yes

	option = {
		name = libya.14.a
		add_manpower = 1500
		add_equipment_to_stockpile = {
			type = infantry_equipment_0
			amount = 500
			producer = LBA
		}
	}
}

country_event = { #Conflict in the Jabal
	id = libya.15
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.15" }
	title = libya.15.t
	desc = libya.15.d
	picture = GFX_LBA_Camel1

	is_triggered_only = yes

	option = {
		name = libya.15.a
		trigger = {
			tag = LBA
		}
		add_stability = 0.02
		add_manpower = -2000
	}
	option = {
		name = libya.15.b
		trigger = {
			tag = LBA
		}
		add_stability = -0.02
	}
	option = {
		name = libya.15.c
		trigger = {
			NOT = {
				tag = LBA
			}
		}
		add_political_power = -5
	}
}

country_event = { #Border Friction in Western Egypt
	id = libya.16
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.16" }
	title = libya.16.t
	desc = libya.16.d
	picture = GFX_LBA_Camel3

	is_triggered_only = yes

	option = {
		name = libya.16.a
		ai_chance = {
			factor = 80
		}
		trigger = {
			tag = LBA
		}
		add_political_power = -100
	}
	option = {
		name = libya.16.b
		ai_chance = {
			factor = 10
		}
		trigger = {
			tag = LBA
		}
		add_stability = -0.05
		452 = {
			custom_effect_tooltip = lba_blocked_tt
			set_state_flag = blocked_caravan
		}
		lba_recalculate_caravan_total = yes
	}
	option = {
		name = libya.16.c
		ai_chance = {
			factor = 10
		}
		trigger = {
			tag = LBA
		}
		452 = {
			custom_effect_tooltip = lba_blocked_destroyed_tt
			clr_state_flag = lba_zawiya_1
			clr_state_flag = lba_zawiya_2
			set_state_flag = blocked_caravan
		}
		lba_recalculate_caravan_total = yes
	}
	option = {
		name = libya.16.e
		ai_chance = {
			factor = 10
		}
		trigger = {
			NOT = {
				tag = LBA
			}
		}
		add_stability = -0.01
	}
}

country_event = { #Slavery on the Central African Route
	id = libya.17
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.17" }
	title = libya.17.t
	desc = libya.17.d
	picture = GFX_LBA_Camel1

	is_triggered_only = yes
	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.17.a
		add_political_power = -10
	}
}

country_event = { #The Ottoman Economic Recession
	id = libya.18
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.18" }
	title = libya.18.t
	desc = libya.18.d
	picture = GFX_OTT_Palace_Seaside

	is_triggered_only = yes
	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.18.a
		add_stability = -0.05
		add_political_power = -50
	}
}

country_event = { #Great Summit of the Cyrenaican Tribes
	id = libya.19
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.19" }
	title = libya.19.t
	desc = libya.19.d
	picture = GFX_OTT_Senussi_Army

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.19.a
		add_stability = -0.05
		increase_ruling_party_popularity_by_10 = yes
	}
}

country_event = { #French Attack Zawiya
	id = libya.20
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.20" }
	title = libya.20.t
	desc = libya.20.d
	picture = GFX_report_event_oasis

	is_triggered_only = yes

	option = {
		name = libya.20.a
		add_manpower = -100
		custom_effect_tooltip = lba_blocked_destroyed_tt
		every_state = {
			limit = {
				has_state_flag = zawiya_destroyed
			}
			clr_state_flag = zawiya_destroyed
			clr_state_flag = lba_zawiya_1
			clr_state_flag = lba_zawiya_2
			set_state_flag = blocked_caravan
			if = {
				limit = { has_active_resistance = yes }
				add_resistance = -0.1
			}
		}
		LBA = {
			lba_evaluate_volunteers = yes
			lba_recalculate_caravan_total = yes
		}
	}
}

country_event = { #Caravan Lost
	id = libya.21
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.21" }
	title = libya.21.t
	desc = libya.21.d
	picture = GFX_LBA_Camel2

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.21.a
		add_political_power = -30
	}
	option = {
		name = libya.21.b
		add_stability = -0.02
	}
}

country_event = { #Caravan Plundered
	id = libya.22
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.22" }
	title = libya.22.t
	desc = libya.22.d
	picture = GFX_LBA_Camel1

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.22.a
		add_stability = -0.02
	}
}

country_event = { #France Closes Down Operations in Timbuktu
	id = libya.23
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.23" }
	title = libya.23.t
	desc = {
		text = libya.23.d.lba #Libya side
		trigger = { tag = LBA }
	}
	desc = {
		text = libya.23.d.nfa #NFA side
		trigger = { tag = NFA }
	}
	picture = GFX_LBA_Timbuktu

	is_triggered_only = yes

	option = {
		trigger = {
			tag = LBA
		}
		name = libya.23.a
		556 = {
			custom_effect_tooltip = lba_blocked_destroyed_tt
			clr_state_flag = lba_zawiya_1
			clr_state_flag = lba_zawiya_2
			set_state_flag = blocked_caravan
		}
		LBA = {
			lba_evaluate_volunteers = yes
			lba_recalculate_caravan_total = yes
		}
	}

	option = {
		trigger = {
			tag = NFA
		}
		556 = {
			add_resistance = -3
		}
		name = libya.23.b
	}
}

country_event = { #The Search for Zerzura
	id = libya.24
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.24" }
	title = libya.24.t
	desc = libya.24.d
	picture = GFX_LBA_Expedition

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.24.a
		hidden_effect = {
			country_event = {
				id = libya.30
				days = 241
			}
		}
	}
}

country_event = { #Fall of Misratah
	id = libya.25
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.25" }
	title = libya.25.t
	desc = libya.25.d	picture = GFX_OTT_Hagia_Sophia

	is_triggered_only = yes

	trigger = {
		owns_state = 448
	}

	immediate = {
		if = {
			limit = {
				is_in_faction = no
				EGY = { is_faction_leader = yes }
			}
			EGY = { add_to_faction = ROOT }
		}
	}

	option = {
		name = libya.25.a
		ai_chance = {
			factor = 60
			modifier = {
				factor = 20
				has_government = national_populist
			}
		}
		add_stability = -0.3
		set_country_flag = TRP_CONQ
		complete_national_focus = LBA_Unification_Libya
		country_event = {
			id = libya.26
			days = 3
		}
	}
	option = {
		name = libya.25.b
		trigger = {
			NOT = {
				has_completed_focus = LBA_Unification_Libya
			}
		}
		ai_chance = {
			factor = 40
		}
		TRP = {
			transfer_state = 448
			transfer_state = 273
		}
		hidden_effect = {
			448 = {
				if = {
					limit = { has_resistance = yes }
					cancel_resistance = yes
				}
				force_disable_resistance = { clear = yes }
			}
			273 = {
				if = {
					limit = { has_resistance = yes }
					cancel_resistance = yes
				}
				force_disable_resistance = { clear = yes }
			}
		}
		if = {
			limit = {
				LBA = {
					is_in_faction_with = EGY
				}
			}
			EGY = {
				add_to_faction = TRP
			}
		}
	}
	option = {
		name = libya.25.c
		trigger = {
			is_ai = no
			NOT = {
				has_completed_focus = LBA_Unification_Libya
			}
		}
		TRP = {
			transfer_state = 448
			transfer_state = 273
		}
		hidden_effect = {
			448 = {
				if = {
					limit = { has_resistance = yes }
					cancel_resistance = yes
				}
				force_disable_resistance = { clear = yes }
			}
			273 = {
				if = {
					limit = { has_resistance = yes }
					cancel_resistance = yes
				}
				force_disable_resistance = { clear = yes }
			}
		}
		TRP = { change_tag_from = ROOT }
	}
}

country_event = { #Formation of Political Parties
	id = libya.26
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.26" }
	title = libya.26.t
	desc = libya.26.d
	picture = GFX_OTT_Fezzan

	is_triggered_only = yes

	option = {
		name = libya.26.a
		hidden_effect = {
			if = {
				limit = {
					has_country_leader = {
						name = "Idris I"
						ruling_only = yes
					}
				}
				set_popularities = {
					totalist = 0
					radical_socialist = 0
					syndicalist = 0
					social_democrat = 18
					social_liberal = 16
					market_liberal = 4
					social_conservative = 14
					authoritarian_democrat = 38
					paternal_autocrat = 10
					national_populist = 0
				}
			}
			else = {
				set_popularities = {
					totalist = 0
					radical_socialist = 0
					syndicalist = 0
					social_democrat = 18
					social_liberal = 16
					market_liberal = 4
					social_conservative = 14
					authoritarian_democrat = 0
					paternal_autocrat = 10
					national_populist = 38
				}
			}
		}
		set_party_name = {
			ideology = social_democrat
			long_name = "al-Kutlat al-wataniat al-hura (Free National Bloc)"
			name = "HQ"
		}
		set_party_name = {
			ideology = social_conservative
			long_name = "al-Jabha al-wataniyya al-muttahida (United National Front)"
			name = "JWM"
		}
		set_party_name = {
			ideology = social_liberal
			long_name = "al-Mutamar al-wataniu al-liybiu (Libyan National Congress)"
			name = "MWL"
		}
		set_party_name = {
			ideology = market_liberal
			long_name = "Hizb al-Ahrar (Liberal Party)"
			name = "HA"
		}
		set_party_name = {
			ideology = radical_socialist
			long_name = "Hizb al-'umma (Labour Party)"
			name = "HU"
		}
		set_party_name = {
			ideology = syndicalist
			long_name = "Hizb al-'umma (Labour Party)"
			name = "HU"
		}
		set_party_name = {
			ideology = totalist
			long_name = "Hizb al-'umma (Labour Party)"
			name = "HU"
		}
	}
}

country_event = { #Local Authorities Raise Taxes
	id = libya.27
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.27" }
	title = libya.27.t
	desc = libya.27.d
	picture = GFX_LBA_Camel3

	is_triggered_only = yes

	option = {
		name = libya.27.a
		add_political_power = -10
	}
	option = {
		name = libya.27.b
		add_equipment_to_stockpile = {
			type = infantry_equipment_0
			amount = -35
		}
	}
}

country_event = { #Local Mufti Closes Zawiya
	id = libya.28
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.28" }
	title = libya.28.t
	desc = libya.28.d
	picture = GFX_OTT_Arabs_Angry

	is_triggered_only = yes

	option = {
		name = libya.28.a
		every_state = {
			limit = {
				has_state_flag = zawiya_destroyed
			}
			clr_state_flag = zawiya_destroyed
			clr_state_flag = lba_zawiya_1
			clr_state_flag = lba_zawiya_2
			set_state_flag = blocked_caravan
			# if = {
			# 	limit = {
			# 		NOT = {
			# 			AND = {
			# 				state = 273
			# 				is_owned_by = TUR
			# 			}
			# 			AND = {
			# 				state = 448
			# 				is_owned_by = TUR
			# 			}
			# 		}
			# 	}
			# 	force_disable_resistance = yes
			# 	cancel_resistance = yes
			# }
		}
		LBA = {
			lba_evaluate_volunteers = yes
			lba_recalculate_caravan_total = yes
		}
	}
}

country_event = { #An Unexpected Encounter
	id = libya.29
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.29" }
	title = libya.29.t
	desc = libya.29.d
	picture = GFX_LBA_petit_prince

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.29.a
	}
}

country_event = { #The Second Almásy Expedition
	id = libya.30
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.30" }
	title = libya.30.t
	desc = libya.30.d
	picture = GFX_LBA_Expedition

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = libya.30.a
		add_political_power = 5
	}
}

country_event = { #Rise of Pan-Arabism in Cyrenaica
	id = libya.31
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.31" }
	title = libya.31.t
	desc = libya.31.d
	picture = GFX_OTT_Arab_Protest_Indoors

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	is_triggered_only = yes

	option = {
		name = libya.31.a
		if = {
			limit = {
				tag = LBA
			}
			add_stability = -0.01
		}
	}
}

country_event = { #Desert Glass Exports Boom in North Africa
	id = libya.32
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.32" }
	title = libya.32.t
	desc = libya.32.d
	picture = GFX_LBA_Expedition

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	is_triggered_only = yes

	option = {
		name = libya.32.a
		add_political_power = 20
	}
}

country_event = { #Crossroads of Destiny
	id = libya.33
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.33" }
	title = libya.33.t
	desc = libya.33.d
	picture = GFX_OTT_Senussi_Army

	trigger = {
		tag = LBA
		has_government = national_populist
		is_subject_of = TUR
		TUR = {
			has_war_with = EGY
		}
	}

	mean_time_to_happen = {
		days = 30
	}

	option = {
		name = libya.33.a
		ai_chance = {
			factor = 40
		}
		trigger = {
			NOT = {
				has_completed_focus = LBA_Cooperate_Caliph
			}
		}
		complete_national_focus = LBA_Unite_Libya
	}
	option = {
		name = libya.33.b
		ai_chance = {
			factor = 15
			modifier = {
				factor = 10
				TUR = {
					OR = {
						has_government = social_conservative
						has_government = paternal_autocrat
					}
				}
			}
		}
		complete_national_focus = LBA_Cooperate_Caliph
	}
	option = {
		name = libya.33.c
		ai_chance = {
			factor = 45
		}
		overlord = {
			set_autonomy = {
				target = ROOT
				autonomy_state = autonomy_free
			}
		}
		if = {
			limit = {
				has_cosmetic_tag = LBA_OTT
			}
			drop_cosmetic_tag = yes
		}
		leave_faction = yes
		TUR = { country_event = libya.34 } #"Cyrenaica Remains Neutral
		every_enemy_country = {
			limit = {
				is_valid_peace_target = yes
				NOT = { tag = TUR }
			}
			white_peace_with_ROOT = yes
		}
	}
}

country_event = { #Cyrenaica Declares Independence
	id = libya.34
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.34" }
	title = libya.34.t
	desc = libya.34.d
	picture = GFX_OTT_Senussi_Army

	is_triggered_only = yes

	option = {
		name = libya.34.a
		declare_war_on = {
			target = "LBA"
			type = annex_everything
		}
		"LBA" = {
			set_capital = { state = 663 }
			activate_mission = LBA_White_Peace_Cyrenaican_Revolt
			complete_national_focus = LBA_Unite_Libya
		}
	}
	option = {
		name = libya.34.b
		if = {
			limit = {
				has_government = authoritarian_democrat
			}
			add_popularity = {
				ideology = authoritarian_democrat
				popularity = -0.02
			}
		}
		else = {
			### Return Arab Nationalist votes to opposition
			custom_effect_tooltip = 10_nat_ara_opp_tt
			add_to_variable = { nat_ara_opp_deputies = 10 }
			subtract_from_variable = { nat_ara_sup_deputies = 10 }
			clamp_variable = {
				var = nat_ara_sup_deputies
				min = 0
				max = nat_ara_deputies
			}
			clamp_variable = {
				var = nat_ara_opp_deputies
				min = 0
				max = nat_ara_deputies
			}

			### Calculate coalition strength
			OTT_calc_coalition_strength = yes
		}
	}
}

country_event = { #Death of al-Mukhtar
	id = libya.35
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.35" }
	title = libya.35.t
	desc = libya.35.d
	picture = GFX_LBA_Senussi_Warrior

	trigger = {
		has_government = national_populist
	}

	is_triggered_only = yes

	option = {
		name = libya.35.a
		add_stability = -0.10
		random_unit_leader = {
			limit = { has_id = 610 }
			remove_unit_leader = yes
		}
		set_country_flag = Umar_al_Mukhtar_dead
		create_country_leader = {
			name = "Yousaf Borahil Al-Msmare"
			picture = "gfx/leaders/LBA/Portrait_LBA_Yousaf_Borahil_Al_Msmare.png"
			ideology = natpop_islamism_subtype
		}
	}
}

country_event = { #End of the Libyan Revolt
	id = libya.37
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.37" }
	title = libya.37.t
	desc = libya.37.d
	picture = GFX_LBA_Senussi_Warrior

	is_triggered_only = yes

	fire_only_once = yes

	option = {
		name = libya.37.a
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.01
				EGY = {
					is_ai = no
				}
			}
			modifier = {
				factor = 0.5
				TUR = {
					surrender_progress > 0.4
				}
			}
			modifier = {
				factor = 3
				controls_state = 448
			}
		}
		### Give LBA controlled states
		every_state = {
			limit = {
				is_owned_by = TUR
				is_fully_controlled_by = LBA
				OR = {
					state = 451
					state = 663
					state = 1009
				}
			}
			LBA = {
				transfer_state = PREV
			}
		}
		### Remove LBA from Cairo Pact and peace out Turks
		if = {
			limit = {
				is_in_faction_with = EGY
			}
			EGY = {
				remove_from_faction = LBA
			}
			TUR = {
				white_peace_with_ROOT = yes
			}
		}
		### If Turks succesfully held Tripoli, give Fezzan back to them
		if = {
			limit = {
				TUR = {
					controls_state = 448
				}
			}
			TUR = {
				transfer_state = 273
			}
		}
	}
	option = {
		name = libya.37.b
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				is_in_faction = no
			}
		}
		### Give LBA controlled states
		every_state = {
			limit = {
				is_owned_by = TUR
				is_fully_controlled_by = LBA
				OR = {
					state = 451
					state = 663
					state = 1009
				}
			}
			LBA = {
				transfer_state = PREV
			}
		}
	}
}

country_event = { #Caliphate?
	id = libya.38
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.38" }
	title = libya.38.t
	desc = libya.38.d
	picture = GFX_LBA_Senussi_Warrior

	trigger = {
		tag = LBA
		has_completed_focus = LBA_Unification_Libya
		OR = {
			has_government = paternal_autocrat
			has_government = national_populist
		}
		is_subject = no
		is_in_faction = no
		TUR = {
			NOT = {
				OR = {
					has_country_leader = {
						ruling_only = yes
						name = "Abdülmecid II"
					}
					has_country_leader = {
						ruling_only = yes
						name = "Ahmed IV"
					}
					has_country_leader = {
						ruling_only = yes
						name = "Osman IV"
					}
					has_country_leader = {
						ruling_only = yes
						name = "Ömer I"
					}
				}
			}
		}
	}

	fire_only_once = yes

	mean_time_to_happen = {
		days = 90
	}

	option = {
		name = libya.38.a
		ai_chance = {
			factor = 99
		}
		add_stability = 0.02
	}
	
	option = {
		name = libya.38.b
		ai_chance = {
			factor = 1
		}
		set_cosmetic_tag = LBA_SENUSSY
		every_state = {
				limit = { is_core_of = OMA }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = OMA }
		every_state = {
				limit = { is_core_of = JBS }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = JBS }
		every_state = {
				limit = { is_core_of = SAU }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = SAU }
		every_state = {
				limit = { is_core_of = YEM }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = YEM }
		every_state = {
				limit = { is_core_of = PER }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = PER }
		every_state = {
				limit = { is_core_of = AFG }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = AFG }
		every_state = {
				limit = { is_core_of = SUD }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = SUD }
		every_state = {
				limit = { is_core_of = AZE }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = AZE }
		every_state = {
				limit = { is_core_of = EGY }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = EGY }
		every_state = {
				limit = { is_core_of = LBA }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = LBA }
		every_state = {
				limit = { is_core_of = TRP }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = TRP }
		every_state = {
				limit = { is_core_of = TUN }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = TUN }
		every_state = {
				limit = { is_core_of = ALG }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = ALG }
		every_state = {
				limit = { is_core_of = MOR }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = MOR }
		every_state = {
				limit = { is_core_of = MRT }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = MRT }
		create_wargoal = { type = annex_everything target = NFA }
		every_state = {
				limit = { is_core_of = ERI }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = ERI }
		every_state = {
				limit = { is_core_of = DJI }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = DJI }
		every_state = {
				limit = { is_core_of = UZB }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = UZB }
		every_state = {
				limit = { is_core_of = LEB }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = LEB }
		every_state = {
				limit = { is_core_of = TRK }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = TRK }
		every_state = {
				limit = { is_core_of = KYR }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = KYR }
		every_state = {
				limit = { is_core_of = NER }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = NER }
		every_state = {
				limit = { is_core_of = MAL }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = MAL }
		every_state = {
				limit = { is_core_of = WAD }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = WAD }
		every_state = {
				limit = { is_core_of = BFA }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = BFA }
		every_state = {
				limit = { is_core_of = SEN }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = SEN }
		every_state = {
				limit = { is_core_of = GNA }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = GNA }
		every_state = {
				limit = { is_core_of = CVG }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = CVG }
		every_state = {
				limit = { is_core_of = SIE }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = SIE }
		every_state = {
				limit = { is_core_of = IRQ }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = IRQ }
		every_state = {
				limit = { is_core_of = SYR }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = SYR }
		every_state = {
				limit = { is_core_of = ALB }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = ALB }
		every_state = {
				limit = { is_core_of = HEJ }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = HEJ }
		every_state = {
				limit = { is_core_of = TRU }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = TRU }
		every_state = {
				limit = { is_core_of = HAU }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = HAU }
		every_state = {
				limit = { is_core_of = KBR }
				add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = KBR }
		every_state = {
			limit = {
				OR = {
					is_core_of = SOM
					is_claimed_by = SOM
				}
			}
			add_core_of = LBA
		}
		create_wargoal = { type = annex_everything target = SOM }
		
		hidden_effect = {
			819 = {	add_core_of = LBA }
			352 = {	add_core_of = LBA }
			350 = {	add_core_of = LBA }
			450 = {	add_core_of = LBA }
			905 = { add_core_of = LBA }
		}
	}
}

country_event = { #The Triumph of King Idris
	id = libya.39
	immediate = { log = "[GetDateText]: [Root.GetName]: event libya.39" }
	title = libya.39.t
	desc = libya.39.d
	picture = GFX_OTT_Idris_Back

	fire_only_once = yes
	is_triggered_only = yes

	option = {
		name = libya.39.a
		ai_chance = {
			factor = 0
		}
		set_country_flag = LBA_Maghreb_Unity
		add_political_power = -100
		add_war_support = 0.10
		EGY = { add_opinion_modifier = { target = LBA modifier = medium_decrease } }
		every_state = {
				limit = {
				OR = {
				is_core_of = ALG
				is_core_of = MRT
				is_core_of = MOR
					}
				}
				add_claim_by = LBA
		}
	}
	
	option = {
		name = libya.39.b
		ai_chance = {
			factor = 100
		}
		add_political_power = 100
		add_stability = 0.10
		EGY = { add_opinion_modifier = { target = LBA modifier = medium_increase } }
	}
}


#############################
# Hidden Events for Caravan #
#############################
add_namespace = libcav

country_event = { #Hidden event for West African Route
	id = libcav.1
	immediate = { log = "[GetDateText]: [Root.GetName]: event libcav.1" }

	hidden = yes

	is_triggered_only = yes

	option = {
		if = {
			limit = {
				556 = { #Timbuktu
					has_state_flag = blocked_caravan
				}
				910 = { #Bilma
					has_state_flag = blocked_caravan
				}
				273 = { #Murzuq
					has_state_flag = blocked_caravan
				}
			}
			country_event = {
				id = libcav.1
				days = 45
			}
		}
		else_if = {
			limit = {
				556 = { #Timbuktu
					has_state_flag = blocked_caravan
				}
				910 = { #Bilma
					has_state_flag = blocked_caravan
				}
			}
			activate_mission = LBA_waf_Murzuq_Kufra_Caravan
		}
		else_if = {
			limit = {
				556 = { #Timbuktu
					has_state_flag = blocked_caravan
				}
			}
			activate_mission = LBA_waf_Bilma_Murzuq_Caravan
		}
		else = {
			activate_mission = LBA_waf_Timbuktu_Bilma_Caravan
		}
	}
}

country_event = { #Hidden event for Algerian Route
	id = libcav.2
	immediate = { log = "[GetDateText]: [Root.GetName]: event libcav.2" }

	hidden = yes

	is_triggered_only = yes

	option = {
		if = {
			limit = {
				514 = { #Tuat
					has_state_flag = blocked_caravan
				}
				273 = { #Murzuq
					has_state_flag = blocked_caravan
				}
			}
			country_event = {
				id = libcav.2
				days = 45
			}
		}
		else_if = {
			limit = {
				514 = { #Tuat
					has_state_flag = blocked_caravan
				}
			}
			activate_mission = LBA_alg_Murzuq_Kufra_Caravan
		}
		#else = {
		#	activate_mission = LBA_alg_Tuat_Murzuq_Caravan
		#}
	}
}

country_event = { #Hidden event for Congo Route
	id = libcav.3
	immediate = { log = "[GetDateText]: [Root.GetName]: event libcav.3" }

	hidden = yes

	is_triggered_only = yes

	option = {
		if = {
			limit = {
				1025 = { #Congo
					has_state_flag = blocked_caravan
				}
				515 = { #Wadai
					has_state_flag = blocked_caravan
				}
			}
			country_event = {
				id = libcav.3
				days = 45
			}
		}
		else_if = {
			limit = {
				1025 = { #Congo
					has_state_flag = blocked_caravan
				}
			}
			activate_mission = LBA_con_Wadai_Kufra_Caravan
		}
		else = {
			activate_mission = LBA_con_Congo_Wadai_Caravan
		}
	}
}

country_event = { #Hidden event for Cameroon Route
	id = libcav.4
	immediate = { log = "[GetDateText]: [Root.GetName]: event libcav.4" }

	hidden = yes

	is_triggered_only = yes

	option = {
		if = {
			limit = {
				927 = { #Cameroon
					has_state_flag = blocked_caravan
				}
				515 = { #Wadai
					has_state_flag = blocked_caravan
				}
			}
			country_event = {
				id = libcav.4
				days = 45
			}
		}
		else_if = {
			limit = {
				927 = { #Cameroon
					has_state_flag = blocked_caravan
				}
			}
			activate_mission = LBA_cam_Wadai_Kufra_Caravan
		}
		else = {
			activate_mission = LBA_cam_Cameroon_Wadai_Caravan
		}
	}
}

country_event = { #Hidden event for Nigeria Route
	id = libcav.5
	immediate = { log = "[GetDateText]: [Root.GetName]: event libcav.5" }

	hidden = yes

	is_triggered_only = yes

	option = {
		if = {
			limit = {
				558 = { #Nigeria
					has_state_flag = blocked_caravan
				}
				515 = { #Wadai
					has_state_flag = blocked_caravan
				}
			}
			country_event = {
				id = libcav.5
				days = 45
			}
		}
		else_if = {
			limit = {
				558 = { #Nigeria
					has_state_flag = blocked_caravan
				}
			}
			activate_mission = LBA_nig_Wadai_Kufra_Caravan
		}
		else = {
			activate_mission = LBA_nig_Nigeria_Wadai_Caravan
		}
	}
}

########################
# Libyan Revolt Events #
########################

add_namespace = librev

country_event = { #General Revolt in Fezzan
	id = librev.1
	immediate = { log = "[GetDateText]: [Root.GetName]: event librev.1" }
	title = librev.1.t
	desc = librev.1.d
	picture = GFX_OTT_Fezzan

	fire_only_once = yes

	is_triggered_only = yes

	trigger = {
		owns_state = 273
		controls_state = 273
		OR = {
			has_war_with = LBA
			has_war_with = TRP
		}
	}

	immediate = {
		if = {
			limit = {
				TRP = { exists = no }
				has_war_with = LBA
			}
			448 = {
				force_disable_resistance = { clear = yes }
			}
			LBA = {
				set_province_controller = 10037
				set_province_controller = 4117
			}
			448 = {
				create_unit = {
					division = "name = \"al-Mushati\" division_template = \"Cavalry Division\"  start_experience_factor = 0.1"
					owner = "LBA"
					prioritize_location = 10037
				}
				create_unit = {
					division = "name = \"al-Mushati\" division_template = \"Cavalry Division\"  start_experience_factor = 0.1"
					owner = "LBA"
					prioritize_location = 4117
				}
			}
		}
		else = {
			TRP = { 
				transfer_state = 273 
			}
		}
	}

	option = {
		name = librev.1.a
	}
}

country_event = { #Civil War in the Jabal
	id = librev.2
	immediate = { log = "[GetDateText]: [Root.GetName]: event librev.2" }
	title = librev.2.t
	desc = librev.2.d
	picture = GFX_OTT_Civil_War_Jabal

	fire_only_once = yes

	is_triggered_only = yes

	trigger = {
		has_war_with = EGY
		owns_state = 448
		controls_state = 448
	}

	immediate = {
		hidden_effect = {
			448 = {
				force_disable_resistance = { clear = yes }
			}
			TRP = {
				transfer_state = 448
				transfer_state = 273
				load_oob = TRP
				declare_war_on = {
					target = TUR
					type = annex_everything
				}
			}
		}
	}

	option = {
		name = librev.2.a
		add_political_power = -10
	}
}

country_event = { #Fall of Benghazi
	id = librev.3
	immediate = { log = "[GetDateText]: [Root.GetName]: event librev.3" }
	title = librev.3.t
	desc = librev.3.d
	picture = GFX_OTT_Benghazi_Ablaze

	fire_only_once = yes

	trigger = {
		has_war_with = "LBA"
		owns_state = 450
		controls_state = 450
	}

	is_triggered_only = yes

	immediate = {
		450 = {
			force_disable_resistance = { clear = yes }
		}
		LBA = {
			transfer_state = 450
		}
		450 = {
			create_unit = {
				division = "name = \"al-Mushati\" division_template = \"Cavalry Division\"  start_experience_factor = 0.1"
				owner = "LBA"
			}
		}
	}

	option = {
		name = librev.3.a
		add_war_support = -0.01
	}
}

country_event = { #Return of the Cyrenaican Emirate
	id = librev.4
	immediate = { log = "[GetDateText]: [Root.GetName]: event librev.4" }
	title = librev.4.t
	desc = librev.4.d
	picture = GFX_OTT_Benghazi_Ablaze

	fire_only_once = yes

	trigger = {
		has_war_with = EGY
		451 = { has_active_resistance = yes }
		663 = { has_active_resistance = yes }
		1009 = { has_active_resistance = yes }
	}

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				LBA = {
					has_cosmetic_tag = LBA_OTT
				}
			}
			LBA = { drop_cosmetic_tag = yes }
		}
		451 = {
			force_disable_resistance = { clear = yes }
		}
		663 = {
			force_disable_resistance = { clear = yes }
		}
		1009 = {
			force_disable_resistance = { clear = yes }
		}
		hidden_effect = {
			LBA = {
				transfer_state = 451
				transfer_state = 663
				transfer_state = 1009
				declare_war_on = {
					target = TUR
					type = annex_everything
				}
				load_oob = LBA
				set_capital = { state = 663 }
				activate_mission = LBA_White_Peace_Cyrenaican_Revolt
				complete_national_focus = LBA_idris_the_liberator
			}
			EGY = {
				add_to_faction = LBA
			}
		}
	}

	option = {
		name = librev.4.a
		effect_tooltip = {
			LBA = {
				transfer_state = 451
				transfer_state = 663
				transfer_state = 1009
				activate_mission = LBA_White_Peace_Cyrenaican_Revolt
			}
			EGY = {
				add_to_faction = LBA
			}
		}
	}
}

########################
# Tripolitanian Events #
########################

add_namespace = trp

country_event = { #Tripolitania pursues closer ties (TUR)
	id = trp.1
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.1" }
	title = trp.1.t
	desc = trp.1.d
	picture = GFX_report_event_tunisiatown

	fire_only_once = yes

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = trp.1.a
		add_political_power = 10
	}
}

country_event = { #Creation of the Turkish Tripolitanian Economic Union
	id = trp.2
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.2" }
	title = trp.2.t
	desc = trp.2.d
	picture = GFX_report_event_tunisiatown

	fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = trp.2.a
		add_political_power = 10
	}
}

country_event = { #Cooperation with the Tripolitanian Free National Bloc (FRA)
	id = trp.3
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.3" }
	title = trp.3.t
	desc = trp.3.d
	picture = GFX_OTT_Civil_War_Jabal

	is_triggered_only = yes

	option = {
		name = trp.3.a
		add_war_support = 0.01
		TRP = {
			add_opinion_modifier = {
				target = ROOT
				modifier = small_increase
			}
		}
	}
}

country_event = { #Tripolitania Applies for the Phalanstere
	id = trp.4
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.4" }
	title = trp.4.t
	desc = trp.4.d

	fire_only_once = yes

	is_triggered_only = yes
	picture = GFX_OTT_Fezzan

	option = {
		name = trp.4.a
		ai_chance = {
			factor = 100
		}
		add_political_power = -20
		TRP = {
			add_popularity = {
				ideology = social_democrat
				popularity = 0.05
			}
			add_ideas = TRP_Communard_Mission
		}
	}
	option = {
		name = trp.4.b
		ai_chance = {
			factor = 0
		}
	}
}

country_event = { #Tripolitania Applies for the Internationale
	id = trp.5
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.5" }
	title = trp.5.t
	desc = trp.5.d

	fire_only_once = yes

	is_triggered_only = yes
	picture = GFX_OTT_Al_Qurnah

	option = {
		name = trp.5.a
		ai_chance = {
			factor = 100
		}
		add_to_faction = TRP
	}
	option = {
		name = trp.5.b
		ai_chance = {
			factor = 0
		}
		TRP = {
			country_event = trp.6
		}
	}
}

country_event = { #Internationale says no
	id = trp.6
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.6" }
	title = trp.6.t
	desc = trp.6.d
	picture = GFX_report_event_tunisiatown

	fire_only_once = yes

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = trp.6.a
		add_stability = -0.10
	}
}

country_event = { #Tripolitania Applies for the Cairo pact
	id = trp.7
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.7" }
	title = trp.7.t
	desc = trp.7.d

	fire_only_once = yes

	is_triggered_only = yes
	picture = GFX_OTT_Al_Qurnah

	option = {
		name = trp.7.a
		ai_chance = {
			factor = 100
		}
		add_to_faction = TRP
	}
	option = {
		name = trp.7.b
		ai_chance = {
			factor = 0
		}
		add_stability = -0.08
		TRP = {
			country_event = trp.8
		}
	}
}

country_event = { #Cairo says no
	id = trp.8
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.8" }
	title = trp.8.t
	desc = trp.8.d
	picture = GFX_report_event_tunisiatown

	fire_only_once = yes

	is_triggered_only = yes

	trigger = {
		is_ai = no
		NOT = { has_global_flag = player_dislikes_colonial_flavour_flag }
	}
	#minor_flavor = yes

	option = {
		name = trp.8.a
		add_stability = -0.10
	}
}

country_event = { #Tripoli Proposes Unification
	id = trp.9
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.9" }
	title = trp.9.t
	desc = trp.9.d

	fire_only_once = yes

	is_triggered_only = yes
	picture = GFX_OTT_Al_Qurnah

	option = {
		name = trp.9.a
		ai_chance = {
			factor = 100
		}
		if = {
			limit = {
				TRP = {
					is_ai = no
				}
			}
			change_tag_from = TRP
		}
		annex_country = {
			target = TRP
			transfer_troops = yes
		}
	}
	option = {
		name = trp.9.b
		ai_chance = {
			factor = 0
		}
		add_stability = -0.08
	}
}

country_event = { #The Future of the Tripolitanian Republic
	id = trp.10
	immediate = { log = "[GetDateText]: [Root.GetName]: event trp.10" }
	title = trp.10.t
	desc = trp.10.d

	fire_only_once = yes

	is_triggered_only = yes
	picture = GFX_OTT_Al_Qurnah

	option = {
		name = trp.10.a
		ai_chance = {
			factor = 65
			modifier = {
				factor = 0
				OR = {
					has_game_rule = {
						rule = TRP_politic
						option = TRP_POLITICS_SOCCON
					}
					has_game_rule = {
						rule = TRP_politic
						option = TRP_POLITICS_AUTDEM
					}
				}
			}
		}
		set_politics = {
			ruling_party = social_democrat
			elections_allowed = yes
			election_frequency = 60
		}
		set_country_flag = soc_dems_are_socialists
		hidden_effect = {
			set_cosmetic_tag = TRP_SOC
		}
	}
	option = {
		name = trp.10.b
		ai_chance = {
			factor = 25
			modifier = {
				factor = 0
				OR = {
					has_game_rule = {
						rule = TRP_politic
						option = TRP_POLITICS_AUTDEM
					}
					has_game_rule = {
						rule = TRP_politic
						option = TRP_POLITICS_SOCDEM
					}
				}
			}
		}
		set_politics = {
			ruling_party = social_conservative
			elections_allowed = yes
			election_frequency = 60
		}
		hidden_effect = {
			set_cosmetic_tag = TRP_REP
		}
	}
	option = {
		name = trp.10.c
		ai_chance = {
			factor = 20
			base = 20
			modifier = {
				factor = 0
				OR = {
					has_game_rule = {
						rule = TRP_politic
						option = TRP_POLITICS_SOCCON
					}
					has_game_rule = {
						rule = TRP_politic
						option = TRP_POLITICS_SOCDEM
					}
				}
			}
		}
		set_politics = {
			ruling_party = authoritarian_democrat
			elections_allowed = no
		}
		hidden_effect = {
			set_cosmetic_tag = TRP_REP
		}
	}
}
