﻿add_namespace = sokoto

state_event = {
	id = sokoto.1
	title = sokoto.1.t
	desc = sokoto.1.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	#mean_time_to_happen = {days = 30 }

	trigger = {
	}

	option = {
		name = sokoto.1.a
		ai_chance = { factor = 90 }
		#skt_revolt_in_state_effect = yes
	}

	option = {
		name = sokoto.1.b
		ai_chance = { factor = 10 }
		#skt_release_revolting_state_effect = yes
	}
}


country_event = {
	id = sokoto.2
	title = sokoto.2.t
	desc = sokoto.2.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.2.a
		ai_chance = { factor = 100 }
		set_country_flag = afr_jihad_repair_ribats_completed
	}
}

country_event = {
	id = sokoto.3
	title = sokoto.8.t
	desc = sokoto.8.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.2.a
		ai_chance = { factor = 100 }
		set_country_flag = afr_jihad_repair_ribats_completed
	}
}

country_event = {
	id = sokoto.4
	title = sokoto.4.t
	desc = sokoto.4.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.4.a
		ai_chance = { factor = 100 }
		trigger = {
			has_manpower > 500
		}
		add_manpower = -500
	}

	option = {
		name = sokoto.4.b
		ai_chance = { factor = 0 }
	}
}

country_event = {
	id = sokoto.5
	title = sokoto.5.t
	desc = sokoto.5.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.5.a
		ai_chance = { factor = 60 }
		trigger = {
			has_manpower > 1500
		}
		set_country_flag = afr_jihad_ribat_skilled_labor
		add_manpower = -1500
	}
	option = {
		name = sokoto.5.b
		ai_chance = { factor = 40 }
		capital_scope = { add_manpower = -500 }
	}
	option = {
		name = sokoto.5.c
		ai_chance = { factor = 0 }
		add_manpower = 250
	}
}

country_event = {
	id = sokoto.6
	title = sokoto.6.t
	desc = sokoto.6.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.6.a
		ai_chance = {
			base = 60
			modifier = {
				factor = 2
				has_manpower > 2000
			}
		}
		trigger = {
			has_manpower > 1500
		}
		add_manpower = -1500
		set_country_flag = afr_jihad_ribat_investment_1
	}
	option = {
		name = sokoto.6.b
		ai_chance = {
			base = 40
		}
	}
}

country_event = {
	id = sokoto.7
	title = sokoto.7.t
	desc = sokoto.7.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.7.a
		ai_chance = {
			base = 60
			modifier = {
				factor = 2
				has_manpower > 2500
			}
		}
		trigger = {
			has_manpower > 2000
		}
		add_manpower = -2000
		set_country_flag = afr_jihad_ribat_investment_2
	}
	option = {
		name = sokoto.7.b
		ai_chance = {
			factor = 40
		}
	}
}

country_event = {
	id = sokoto.8
	title = sokoto.8.t
	desc = sokoto.8.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.8.a
		ai_chance = { factor = 100 }
		set_country_flag = afr_jihad_repair_ribats_completed
		capital_scope = {
			#add_building_construction = {
			#	type = bunker
			#	level = 1
			#	instant_build = yes
			#	province = {
			#		all_provinces = yes
			#		limit_to_border = yes
			#	}
			#}
			set_state_flag = AFR_islamic_frontier_ribat
		}
		if = {
			limit = {
				has_country_flag = afr_jihad_ribat_investment_1
			}
			capital_scope = {
				add_building_construction  = {
					type = infrastructure
					level = 1
					instant_build = yes
				}
			}
		}
		if = {
			limit = {
				has_country_flag = afr_jihad_ribat_investment_2
			}
			capital_scope = {
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = farm
					level = 1
					instant_build = yes
				}
			}
		}
	}
}

#SKT islamic Raids
country_event = {
	id = sokoto.9
	title = sokoto.9.t
	desc = sokoto.9.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.9.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
			}
		}
	}

}

#SKT islamic Raids
country_event = {
	id = sokoto.10
	title = sokoto.10.t
	desc = sokoto.10.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.10.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
			}
		}
	}

}


#SKT islamic Raids
country_event = {
	id = sokoto.11
	title = sokoto.11.t
	desc = sokoto.11.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.11.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
			}
		}
	}

}

#SKT islamic Raids
country_event = {
	id = sokoto.12
	title = sokoto.12.t
	desc = sokoto.12.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.12.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
			}
		}
	}

}

#SKT islamic Raids
country_event = {
	id = sokoto.13
	title = sokoto.13.t
	desc = sokoto.13.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.13.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
			}
		}
	}

}

#SKT islamic Raids
country_event = {
	id = sokoto.14
	title = sokoto.14.t
	desc = sokoto.14.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.14.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
			}
		}
	}

}

#SKT islamic Raids
country_event = {
	id = sokoto.15
	title = sokoto.15.t
	desc = sokoto.15.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.15.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
			}
		}
	}

}
#Win
country_event = {
	id = sokoto.16
	title = sokoto.16.t
	desc = sokoto.16.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.16.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
				custom_effect_tooltip= EDC_add_100_to_tribal_army
				add_to_variable = {Tribal_army_num = 100}
				hidden_effect = {
					clr_country_flag = raiding_neighbour
					add_stability = 0.01
				}
				custom_effect_tooltip = SKT_raid_stolen_treasures
			}
		}
	}

}
#Loss
country_event = {
	id = sokoto.17
	title = sokoto.17.t
	desc = sokoto.17.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.17.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
				hidden_effect = {
					clr_country_flag = raiding_neighbour
				}

			}
		}
	}

}
#Stalemate
country_event = {
	id = sokoto.18
	title = sokoto.18.t
	desc = sokoto.18.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.18.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				tag = SKT
			}
			SKT = {
				hidden_effect = {
					clr_country_flag = raiding_neighbour
				}
			}
		}
	}

}
#Win
country_event = {
	id = sokoto.19
	title = sokoto.19.t
	desc = sokoto.19.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.19.a
		ai_chance = { factor = 100 }

	}

}
#Win
country_event = {
	id = sokoto.20
	title = sokoto.20.t
	desc = sokoto.20.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.20.a
		ai_chance = { factor = 100 }

	}

}
#Loss
country_event = {
	id = sokoto.21
	title = sokoto.21.t
	desc = sokoto.21.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.21.a
		ai_chance = { factor = 100 }

	}

}
#Stalemate
country_event = {
	id = sokoto.22
	title = sokoto.22.t
	desc = sokoto.22.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = sokoto.22.a
		ai_chance = { factor = 100 }

	}
}

	country_event = {
		id = sokoto.23
		title = sokoto.23.t
		desc = sokoto.23.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.23.a
			ai_chance = { factor = 30 }
			hidden_effect = { ROOT = { store_current_ideologies = yes } }
			FROM = {
				set_autonomy = {
					target = ROOT
					autonomy_state = autonomy_puppet
					freedom_level = 0.5
				}
			}
			hidden_effect = { ROOT = { load_prevous_ideologies = yes } }
			if = {
				limit = { 
					FROM = {  } #OVERLORD
					ROOT = {  } #SUBJECT
					ROOT = { NOT = { has_variable = afr_empire_subject_loyalty_var } } 
				}
				ROOT = { 
					set_variable = { var = afr_empire_subject_overlord value = FROM.id }
					set_variable = { var = ROOT.afr_empire_subject_loyalty_var value = 6 }
					clamp_variable = { var = ROOT.afr_empire_subject_loyalty_var min = -1 max = 10 }
				}
			}
		}


		option = {
			name = sokoto.23.b
			ai_chance = { factor = 70 }
			custom_effect_tooltip = SKT_sunni_integration_tooltip
			hidden_effect = {
				FROM = { country_event = { id = sokoto.24 days = 3 } }
				ROOT = {
					add_ai_strategy = {
						type = prepare_for_war
						id = FROM
						value = 200
					}
				}
				FROM = {
					add_ai_strategy = {
						type = prepare_for_war
						id = ROOT
						value = 200
					}
				}
			}
		}

	}

	country_event = {
		id = sokoto.24
		title = sokoto.24.t
		desc = sokoto.24.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.24.a
			ai_chance = { factor = 90 }
			ROOT = {
				declare_war_on = {
					target = FROM
					type = annex_everything
				}
			}
			FROM = { every_owned_state = { add_claim_by = ROOT } }
			if = {
				limit = {
					TAG = SKT
				}
				custom_effect_tooltip = afr_war_exhaustion_value_add_5
				add_to_variable = {
					var = afr_war_exhaustion_value
					value = 5
				}
			}
		}

		option = {
			name = sokoto.24.b
			ai_chance = { factor = 10 }
			hidden_effect = {
				ROOT = {
					add_ai_strategy = {
						type = prepare_for_war
						id = FROM
						value = -200
					}
				}
				FROM = {
					add_ai_strategy = {
						type = prepare_for_war
						id = ROOT
						value = -200
					}
				}
			}
		}

	}

	country_event = {
		id = sokoto.25
		title = sokoto.23.t
		desc = sokoto.23.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.23.a
			ai_chance = {
				factor = 10
			}
			hidden_effect = {
				ROOT = {
					add_ai_strategy = {
						type = prepare_for_war
						id = FROM
						value = -200
					}
				}
				FROM = {
					add_ai_strategy = {
						type = prepare_for_war
						id = ROOT
						value = -200
					}
				}
			}
			hidden_effect = { ROOT = { store_current_ideologies = yes } }
			FROM = {
				set_autonomy = {
					target = ROOT
					autonomy_state = autonomy_puppet
					freedom_level = 0.3
				}
			}
			hidden_effect = { ROOT = { load_prevous_ideologies = yes } }
			if = {
				limit = { 
					FROM = {  } #OVERLORD
					ROOT = {  } #SUBJECT
					ROOT = { NOT = { has_variable = afr_empire_subject_loyalty_var } } 
				}
				ROOT = { 
					set_variable = { var = afr_empire_subject_overlord value = FROM.id }
					set_variable = { var = ROOT.afr_empire_subject_loyalty_var value = 6 }
					clamp_variable = { var = ROOT.afr_empire_subject_loyalty_var min = -1 max = 10 }
				}
			}

		}


		option = {
			name = sokoto.23.b
			ai_chance = {
				factor = 90
				modifier = {
					factor = 0
					AND = {
						ROOT = { has_army_size = { size < 10 } }
						ROOT = { check_variable = { Tribal_army_num < 9999 } }
					}
				}
			}
			custom_effect_tooltip = SKT_sunni_integration_tooltip
			hidden_effect = {
				FROM = { country_event = { id = sokoto.26 days = 3 } }
			}
		}

	}

	country_event = {
		id = sokoto.26
		title = sokoto.24.t
		desc = sokoto.24.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.24.a
			ai_chance = { factor = 90 }
			ROOT = {
				declare_war_on = {
					target = FROM
					type = puppet_wargoal_focus
				}
			}
			FROM = { every_owned_state = { add_claim_by = ROOT } }
			if = {
				limit = {
					TAG = SKT
				}
				custom_effect_tooltip = afr_war_exhaustion_value_add_10
				add_to_variable = {
					var = afr_war_exhaustion_value
					value = 10
				}
			}
		}

		option = {
			name = sokoto.24.b
			ai_chance = { factor = 10 }
			hidden_effect = {
				ROOT = {
					add_ai_strategy = {
						type = prepare_for_war
						id = FROM
						value = -200
					}
				}
				FROM = {
					add_ai_strategy = {
						type = prepare_for_war
						id = ROOT
						value = -200
					}
				}
			}
		}

	}

	country_event = {
		id = sokoto.27
		title = sokoto.27.t
		desc = sokoto.27.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.27.a
			ai_chance = { factor = 100 }
			if = {
				limit = {
						tag = ROOT
				}
				hidden_effect = {
					SKT = {
						diplomatic_relation = {
							country = ROOT
							relation = military_access
							active = yes
						}
						diplomatic_relation = {
							country = ROOT
							relation = guarantee
							active = yes
						}
					}
					ROOT = {
						diplomatic_relation = {
							country = SKT
							relation = military_access
							active = yes
						}
						diplomatic_relation = {
							country = SKT
							relation = guarantee
							active = yes
						}
					}
				}
				custom_effect_tooltip = SKT_jihad_member
				set_country_flag = SKT_jihad
				add_popularity = {
					ideology = fundamentalism
					popularity = 0.17
				}
				add_political_power = -15
				add_stability = 0.075
				add_war_support = 0.1
			}

		}


		option = {
			name = sokoto.27.b
			ai_chance = { factor = 0 }
			if = {
				limit = {
						tag = ROOT
				}
				diplomatic_relation = {
					country = SKT
					relation = non_aggression_pact
					active = yes
				}
				add_popularity = {
					ideology = fundamentalism
					popularity = 0.17
				}
				add_political_power = 25
			}
		}

	}




	country_event = {
		id = sokoto.28
		title = sokoto.28.t
		desc = sokoto.28.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.28.a
			ai_chance = { factor = 100 }
			if = {
				limit = { KBO = { owns_state = 838 } }
				838 = { add_claim_by = WDD }
			}
			if = {
				limit = { KBO = { owns_state = 1042 } }
				1042 = { add_claim_by = WDD }
			}
			add_war_support = 0.15
			give_military_access = SKT
			SKT = { country_event = { id = sokoto.29 } }
			declare_war_on = {
				target = KBO
				type = annex_everything
			}
			diplomatic_relation = {
				country = SKT
				relation = non_aggression_pact
				active = yes
			}
			set_country_flag = SKT_WDD_Joint_War_BAG
			set_country_flag = SKT_WDD_Joint_War_Buffer
		}


		option = {
			name = sokoto.27.b
			ai_chance = { factor = 0 }
			SKT = { country_event = { days = 10 id = sokoto.31 } }
			WDD = {
				add_ai_strategy = {
					type = prepare_for_war
					id = KBO
					value = -200
				}
			}
			KBO = {
				add_ai_strategy = {
					type = prepare_for_war
					id = WDD
					value = -200
				}
			}
			BAG = {
				add_ai_strategy = {
					type = prepare_for_war
					id = WDD
					value = -200
				}
			}
		}

	}

	country_event = {
		id = sokoto.29
		title = sokoto.29.t
		desc = sokoto.29.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.29.a
			ai_chance = { factor = 100 }
			give_military_access = WDD
			add_to_war = {
				targeted_alliance = WDD
				enemy = KBO
				hostility_reason = asked_to_join
			}
			declare_war_on = {
				target = BAG
				type = annex_everything
			}
			hidden_effect = { KBO = { every_owned_state = { add_claim_by = SKT } } }
			hidden_effect = { BAG = { every_owned_state = { add_claim_by = SKT } } }
			hidden_effect = { SKT = { country_event = { id = sokoto.30 } } }
			set_country_flag = SKT_WDD_Joint_War_KAN
			set_country_flag = SKT_WDD_Joint_War_BAG_Buffer
			custom_effect_tooltip = afr_war_exhaustion_value_add_5
			add_to_variable = {
				var = afr_war_exhaustion_value
				value = 5
			}
		}

	}

	country_event = {
		id = sokoto.30
		hidden = yes

		is_triggered_only = yes

		immediate = {
			hidden_effect = {
				if = {
					limit = {
						AND = {
							KBO = { owns_state = 838 }
							838 = { is_claimed_by = SKT }
						}
					}
					838 = { remove_claim_by = SKT }
				}
				if = {
					limit = {
						AND = {
							KBO = { owns_state = 1042 }
							1042 = { is_claimed_by = SKT }
						}
					}
					1042 = { remove_claim_by = SKT }
				}
			}
		}
	}

	country_event = {
		id = sokoto.31
		title = sokoto.31.t
		desc = sokoto.31.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.31.a
			ai_chance = { factor = 100 }
			add_war_support = -0.5
			declare_war_on = {
				target = BAG
				type = annex_everything
			}
			KBO = {
				add_to_war = {
					targeted_alliance = BAG
					enemy = SKT
					hostility_reason = asked_to_join
				}
			}
			hidden_effect = { KBO = { every_owned_state = { add_claim_by = SKT } } }
			hidden_effect = { BAG = { every_owned_state = { add_claim_by = SKT } } }
			custom_effect_tooltip = afr_war_exhaustion_value_add_15
			add_to_variable = {
				var = afr_war_exhaustion_value
				value = 15
			}
		}


		option = {
			name = SKT_sunni_influence.3.b
			ai_chance = { factor = 0 }
			add_war_support = -0.30
			1219 = {
				remove_claim_by = ROOT
			}
			KBO = {
				add_ai_strategy = {
					type = prepare_for_war
					id = SKT
					value = -200
				}
			}
			KBO = {
				add_ai_strategy = {
					type = protect
					id = BAG
					value = -200
				}
			}
			BAG = {
				add_ai_strategy = {
					type = prepare_for_war
					id = SKT
					value = -200
				}
			}
			SKT = {
				add_ai_strategy = {
					type = prepare_for_war
					id = BAG
					value = -200
				}
			}
			SKT = {
				add_ai_strategy = {
					type = prepare_for_war
					id = KBO
					value = -200
				}
			}
		}

	}

	country_event = {
		id = sokoto.32
		title = sokoto.32.t
		desc = sokoto.32.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.32.a
			ai_chance = { factor = 100 }
			if = {
				limit = { 
					any_country = {
						OR = {
							TAG = WDD
							TAG = SKT
							is_subject_of = WDD
							is_subject_of = SKT
						}
						owns_state = 1339
					}
					WDD = { NOT = { owns_state = 1339 } }
				}
				WDD = { transfer_state = 1339 }
			}
			if = {
				limit = { 1339 = { is_claimed_by = SKT } }
				SKT = { remove_state_claim = 1339 }
			}
		}
	}

	country_event = {
		id = sokoto.33
		title = sokoto.33.t
		desc = sokoto.33.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.33.a
			ai_chance = { factor = 100 }
			if = {
				limit = { 
					any_country = {
						OR = {
							TAG = WDD
							TAG = SKT
							is_subject_of = WDD
							is_subject_of = SKT
						}
						owns_state = 1219
					}
					SKT = { NOT = { owns_state = 1219 } }
				}
				SKT = { transfer_state = 1219 }
			}
			if = {
				limit = { 1219 = { is_claimed_by = WDD } }
				WDD = { remove_state_claim = 1219 }
			}
		}
	}

	#Buffer Zone Lands Distributed
	country_event = {
		id = sokoto.34
		title = sokoto.34.t
		desc = sokoto.34.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes
		
		immediate = { 
			if = {
				limit = { NOT = { has_global_flag = SKT_joint_invasion_bagirmi_6_flag } }
				hidden_effect = {
					set_global_flag = SKT_joint_invasion_bagirmi_6_flag
					WDD = { country_event = { id = sokoto.35 days = 20 } }
					SKT = { country_event = { id = sokoto.35 days = 20 } }
					789 = { set_demilitarized_zone = yes }
					860 = { set_demilitarized_zone = yes }
					1340 = { set_demilitarized_zone = yes }
				}
			}
		}

		option = {
			name = sokoto.34.a
			trigger = { TAG = SKT }
			ai_chance = { factor = 100 }
			WDD = {
				if = {
					limit = { 
						any_country = {
							OR = {
								TAG = WDD
								TAG = SKT
								is_subject_of = WDD
								is_subject_of = SKT
							}
							owns_state = 789
						}
						WDD = { NOT = { owns_state = 789 } }
					}
					transfer_state = 789
				}
				if = {
					limit = { 
						any_country = {
							OR = {
								TAG = WDD
								TAG = SKT
								is_subject_of = WDD
								is_subject_of = SKT
							}
							owns_state = 860
						}
						WDD = { NOT = { owns_state = 860 } }
					}
					transfer_state = 860
				}
			}
			if = {
				limit = { 789 = { is_claimed_by = SKT } }
				SKT = { remove_state_claim = 789 }
			}
			if = {
				limit = { 860 = { is_claimed_by = SKT } }
				SKT = { remove_state_claim = 860 }
			}
		}
		
		option = {
			name = sokoto.34.b
			trigger = { TAG = WDD }
			ai_chance = { factor = 100 }
			SKT = {
				if = {
					limit = { 
						any_country = {
							OR = {
								TAG = WDD
								TAG = SKT
								is_subject_of = WDD
								is_subject_of = SKT
							}
							owns_state = 805
						}
						SKT = { NOT = { owns_state = 805 } }
						ADM = { NOT = { owns_state = 805 } }
					}
					transfer_state = 805
				}
				if = {
					limit = { 
						any_country = {
							OR = {
								TAG = WDD
								TAG = SKT
								is_subject_of = WDD
								is_subject_of = SKT
							}
							owns_state = 1340
						}
						SKT = { NOT = { owns_state = 1340 } }
					}
					transfer_state = 1340
				}
			}
			if = {
				limit = { 805 = { is_claimed_by = WDD } }
				WDD = { remove_state_claim = 805 }
			}
			if = {
				limit = { 1340 = { is_claimed_by = WDD } }
				WDD = { remove_state_claim = 1340 }
			}
		}
	}

	#BAG Becomes Buffer State
	country_event = {
		id = sokoto.35
		title = sokoto.35.t
		desc = {
			text = sokoto.35.c
			trigger = { ADM = { is_subject_of = SKT } }
		}
		desc = {
			text = sokoto.35.d
			trigger = { ADM = { NOT = { is_subject_of = SKT } } }
		}
		picture = GFX_report_event_chinese_army_training
		
		immediate = { 
			if = {
				limit = { NOT = { has_global_flag = SKT_joint_invasion_bagirmi_7_flag } }
				hidden_effect = {
					set_global_flag = SKT_joint_invasion_bagirmi_7_flag
					789 = { set_demilitarized_zone = no }
					860 = { set_demilitarized_zone = no }
					1340 = { set_demilitarized_zone = no }
				} 
			}
		}
		is_triggered_only = yes

		option = {
			name = sokoto.35.a
			trigger = { TAG = WDD }
			ai_chance = { factor = 100 }
			if = {
				limit = { 
					OR = {
						BAG = { NOT = { is_subject_of = WDD } } 
						BAG = { exists = no }
					}
				}
				BAG = {
					transfer_state = 789
					transfer_state = 860
				}				
				WDD = {
					hidden_effect = { BAG = { store_current_ideologies = yes } }
					puppet = BAG
					hidden_effect = { BAG = { load_prevous_ideologies = yes } }
				}
			}
			if = {
				limit = { 789 = { is_claimed_by = WDD } }
				WDD = { remove_state_claim = 789 }
			}
			if = {
				limit = { 860 = { is_claimed_by = WDD } }
				WDD = { remove_state_claim = 860 }
			}
			if = {
				limit = { 1340 = { is_claimed_by = WDD } }
				WDD = { remove_state_claim = 1340 }
			}
			if = {
				limit = { 
					805 = { is_claimed_by = WDD }
					ADM = { 
						exists = yes 
						is_subject_of = SKT
					}
				}
				WDD = { remove_state_claim = 805 }
			}
			set_autonomy = { target = BAG autonomy_state = autonomy_dominion }
			BAG = { country_event = { id = sokoto.36 days = 1 } }
			clr_country_flag = SKT_WDD_Joint_War_BAG
			BAG = { set_variable = { most_favoured_country = WDD.id } }
			hidden_effect = {
				clear_variable = rival_country
			}
		}
		
		option = {
			name = sokoto.35.b
			trigger = { TAG = SKT }
			ai_chance = { factor = 100 }
			if = {
				limit = { 789 = { is_claimed_by = SKT } }
				SKT = { remove_state_claim = 789 }
			}
			if = {
				limit = { 860 = { is_claimed_by = SKT } }
				SKT = { remove_state_claim = 860 }
			}
			if = {
				limit = { 1340 = { is_claimed_by = SKT } }
				SKT = { remove_state_claim = 1340 }
			}
			if = {
				limit = { 
					805 = { is_claimed_by = SKT }
					ADM = { 
						exists = yes 
						is_subject_of = SKT
					}
				}
				SKT = { remove_state_claim = 805 }
			}
			if = {
				limit = { 
					ADM = { 
						exists = yes 
						is_subject_of = SKT
					}
				}
				1340 = { add_claim_by = ADM }
				ADM = {
					transfer_state = 1340
					country_event = { id = sokoto.39 days = 1 }
					set_variable = { most_favoured_country = SKT.id }
				}
			}
			clr_country_flag = SKT_WDD_Joint_War_KAN
		}
	}

	#BAG Understands Situation
	country_event = {
		id = sokoto.36
		title = sokoto.36.t
		desc = sokoto.36.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.36.a
			ai_chance = { factor = 100 }
			every_state = {
				limit = { 
					OR = { 
						is_owned_by = SKT
						is_owned_by = WDD
						is_owned_by = ADM
					}
					is_claimed_by = ROOT
				}
				remove_claim_by = ROOT
			}
			WDD = { country_event = { id = sokoto.37 days = 1 } }
			SKT = { country_event = { id = sokoto.38 days = 1 } }
			hidden_effect = {
				clear_variable = rival_country
			}
		}
	}
	
	#ADM Understands Situation
	country_event = {
		id = sokoto.39
		title = sokoto.39.t
		desc = sokoto.39.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.39.a
			ai_chance = { factor = 100 }
			every_state = {
				limit = { 
					OR = { 
						is_owned_by = SKT
						is_owned_by = WDD
						is_owned_by = BAG
					}
					is_claimed_by = ROOT
				}
				remove_claim_by = ROOT
			}
			hidden_effect = {
				clear_variable = rival_country
			}
		}
	}

	#Confirms BAG Buffer
	country_event = {
		id = sokoto.37
		title = sokoto.37.t
		desc = sokoto.37.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.37.a
			ai_chance = { factor = 100 }
			add_political_power = 25
			hidden_effect = {
				WDD = {
					diplomatic_relation = {
						country = SKT
						relation = military_access
						active = no
					}
					if = {
						limit = { WDD = { has_non_aggression_pact_with = SKT } }
						diplomatic_relation = {
							country = SKT
							relation = non_aggression_pact
							active = no
						}
					}
					if = {
						limit = { has_wargoal_against = SKT }
						remove_wargoal = {
							type = all
							target = SKT
						}
					}
					if = {
						limit = { has_wargoal_against = BAG }
						remove_wargoal = {
							type = all
							target = BAG
						}
					}
					if = {
						limit = { has_wargoal_against = KBO }
						remove_wargoal = {
							type = all
							target = KBO
						}
					}
				}
			}
			clr_country_flag = SKT_WDD_Joint_War_BAG
		}
	}

	country_event = {
		id = sokoto.38 
		title = sokoto.38.t
		desc = sokoto.38.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.38.a
			ai_chance = { factor = 100 }
			add_political_power = 50
			hidden_effect = {
				SKT = {
					diplomatic_relation = {
						country = WDD
						relation = military_access
						active = no
					}
					if = {
						limit = { SKT = { has_non_aggression_pact_with = WDD } }
						diplomatic_relation = {
							country = WDD
							relation = non_aggression_pact
							active = no
						}
					}
					if = {
						limit = { has_wargoal_against = WDD }
						remove_wargoal = {
							type = all
							target = WDD
						}
					}
					if = {
						limit = { has_wargoal_against = BAG }
						remove_wargoal = {
							type = all
							target = BAG
						}
					}
					if = {
						limit = { has_wargoal_against = KBO }
						remove_wargoal = {
							type = all
							target = KBO
						}
					}
				}
			}
		}
	}

	country_event = {
		id = sokoto.40
		title = sokoto.40.t
		desc = sokoto.40.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.40.a
			ai_chance = { factor = 100 }
			declare_war_on = {
				target = EPD
				type = annex_everything
			}
			hidden_effect = {
				set_province_controller = 7132
				set_province_controller = 4150
				set_province_controller = 11923
			}
		}

	}

	country_event = {
		id = sokoto.41
		title = sokoto.41.t
		desc = sokoto.41.d
		picture = GFX_report_event_chinese_army_training

		is_triggered_only = yes

		option = {
			name = sokoto.41.a
			ai_chance = { factor = 100 }
			SKT = { add_to_faction = ROOT }
		}

		option = {
			name = sokoto.41.b
			ai_chance = { factor = 0 }
		}

	}
