je_afghanistan_fractured = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
		OR = {
		this = c:KAN
		this = c:HER
		this = c:MAI
		}
	}

	possible = {
		is_subject = no
	}

	scripted_button = peaceful_afghan_union_button
		
	complete = {
		custom_tooltip = {
			text = afghanistan_formed_tt
		exists = c:AFG
		this = c:AFG 
		}
	}
	
	on_complete = {

	if = {
		limit = {
		country_has_primary_culture = cu:tajik
		country_has_primary_culture = cu:hazara
		country_has_primary_culture = cu:uzbek
			}
		custom_tooltip = change_uzbek_tt
		}	
			
		add_loyalists = {
		value = 0.02
		}
		#trigger_event = { id = 01_afghanistan_events.1 }
		trigger_event = { id = 01_afghanistan_events.13 }

	}
	
	invalid = {
		has_journal_entry = je_afghanistan_fractured_kabul
	}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_afghanistan_fractured_durrani = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
		this = c:DUR
	}

	possible = {
		is_subject = no
	}
	
	scripted_button = peaceful_afghan_union_button
	
	complete = {			
		AND = {
			calc_true_if = {
				owns_entire_state_region = STATE_HERAT
				owns_entire_state_region = STATE_KANDAHAR
				owns_entire_state_region = STATE_KABUL
				owns_entire_state_region = STATE_BALKH
				amount = 4
			}
		}
	}
	
	on_complete = {
		add_loyalists = {
		value = 0.02
		}
		trigger_event = { id = 01_afghanistan_events.13 }
	}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_afghanistan_fractured_kabul = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"
	group = je_group_historical_content
		
	immediate = {		
		random_scope_character = {
			limit = {
				has_variable = is_dost_var
			}
			save_scope_as = dost_scope
			}
	}
	
	scripted_button = peaceful_afghan_union_button
	
	complete = {			
		custom_tooltip = {
			text = afghanistan_formed_tt
		exists = c:AFG
		this = c:AFG 
		}		
	}
	
	on_complete = {
		custom_tooltip = historical_tt
		
		add_loyalists = {
		value = 0.05
		}
		add_modifier = {
		name = dost_forms_afghanistan_modifier
		years = 10
		}
		trigger_event = { id = 01_afghanistan_events.13 }
	}
	
	fail = {
		scope:dost_scope = {
		is_character_alive = no
			}		
	}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_herat = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
		exists = c:KAB
		this = c:KAB
	}

	possible = {
		is_subject = no
	}
	
	immediate = {		
		random_scope_character = {
			limit = {
				has_variable = is_dost_var
			}
			save_scope_as = dost_scope
			}
	}
	
	complete = {			
				owns_entire_state_region = STATE_HERAT
	}
	
	on_complete = {
		add_loyalists = {
		value = 0.02
		}
		add_modifier = {
		name = supported_rule_modifier
		years = 2
		}
	}
	
	fail = {
		scope:dost_scope = {
		is_character_alive = no
			}		
	}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_kandahar = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
		exists = c:KAB
		this = c:KAB
	}

	possible = {
		is_subject = no
	}
	
	immediate = {		
		random_scope_character = {
			limit = {
				has_variable = is_dost_var
			}
			save_scope_as = dost_scope
			}
	}
	
	complete = {			
				owns_entire_state_region = STATE_KANDAHAR
	}
	
	on_complete = {
		add_loyalists = {
		value = 0.02
		}
		add_modifier = {
		name = supported_rule_modifier
		years = 2
		}
	}
	
	fail = {
		scope:dost_scope = {
		is_character_alive = no
			}		
	}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_balkh = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
		exists = c:KAB
		this = c:KAB
	}

	possible = {
		is_subject = no
	}
	
	immediate = {		
		random_scope_character = {
			limit = {
				has_variable = is_dost_var
			}
			save_scope_as = dost_scope
			}
	}
	
	complete = {			
				owns_entire_state_region = STATE_BALKH
	}
	
	on_complete = {
		add_loyalists = {
		value = 0.02
		}
		add_modifier = {
		name = supported_rule_modifier
		years = 2
		}
	}
	
	fail = {
		scope:dost_scope = {
		is_character_alive = no
			}		
	}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_maimana_unified_khanate = {
	icon = "gfx/interface/icons/event_icons/event_election.dds"
	group = je_group_historical_content
	
	complete = {
		ig:ig_landowners = {
							ig_approval >= 15
						}
		ig:ig_devout = {
							ig_approval >= 15
						}
		ig:ig_armed_forces = {
							ig_approval >= 15
						}
					}	
		
	
	
	on_complete = {
		add_modifier = {
		name = maimana_unified_khanate_modifier
		years = 10
		}
		trigger_event = { id = 01_afghanistan_events.27 }
	}
	
	fail = {
		ig:ig_landowners = {
							ig_approval <= 0
						}
		ig:ig_devout = {
							ig_approval <= 0
						}
		ig:ig_armed_forces = {
							ig_approval <= 0
						}							
	}
	
	on_fail = {
	add_radicals = {
	value = 0.1
		}
	}
	
	weight = 100
	
	should_be_pinned_by_default = yes
}


#The absolute worst
je_the_absolute_worst = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
			
	complete = {
		custom_tooltip = {
		text = kabul_gone_tt
		NOT = {
			exists = c:KAB
			}
		}
	}
	
	on_complete = {
		if = {
			limit = {
				has_modifier = afghan_guerrilla_war_modifier
				}
			remove_modifier = afghan_guerrilla_war_modifier
			}
		if = {
			limit = {
				has_modifier = encourage_revolt_modifier
				}
			remove_modifier = encourage_revolt_modifier
			}
		trigger_event = { id = 01_afghanistan_events.2 } #No Challengers
	}

	on_monthly_pulse = {
		random_events = {
			100 = 0
			2 = 01_afghanistan_events.19
			3 = 01_afghanistan_events.20
			1 = 01_afghanistan_events.21
			#10 = 01_afghanistan_events.29
		}
	}

	fail = {
		custom_tooltip = {
		text = shuja_dead_tt
		ruler = {
		NOT = {
		has_variable = is_shuja_var
				}
			}
		}
	}

	on_fail = {
		custom_tooltip = historical_tt
		
		play_as = c:KAB
		c:KAB = {
			annex = c:DUR
		}
	}

	weight = 50
	
	should_be_pinned_by_default = yes
}

je_vizier_vs_shah = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
	

	is_shown_when_inactive = {
	exists = c:HER
	this = c:HER
	any_scope_character = {			
				has_variable = yar_alive_var
			}
	}
	
	possible = {
	any_scope_character = {			
				has_variable = yar_alive_var
			}
	}
	
	immediate = {
		set_variable = {
			name = vizier_vs_shah_var
			value = 0
		}
		random_scope_character = {
			limit = {
				has_variable = yar_alive_var
			}
			save_scope_as = yazer_scope
			}
	}


	on_monthly_pulse = {
		effect = {
			if = {
				limit = {			
				ig:ig_landowners = { is_powerful = yes } 
				}
				change_variable = {
					name = vizier_vs_shah_var
					add = 1
				}
			}
			if = {
				limit = {			
				ig:ig_landowners = { is_in_government = yes } 
				}
				change_variable = {
					name = vizier_vs_shah_var
					add = 1
				}
			}
		}
		random_events = {
			100 = 0
			25 = 01_afghanistan_events.5 #Brave Warrior
			4 = 01_afghanistan_events.6 #Dispensing Justice
			20 = 01_afghanistan_events.7 #Oppose			
					}
	}
	
	complete = {
		ig:ig_landowners = {
					ig_approval < 20
				}
		scope:journal_entry = {
			is_goal_complete = yes  
			}
		}			
	

	on_complete = {
			custom_tooltip = historical_tt
		
			add_radicals = {
			pop_type = aristocrats
			value = 0.2
			}
			ig:ig_landowners = {
			add_modifier = {
				name = yaz_rebels_modifier
			years = 3
				}
			}
			trigger_event = { id = 01_afghanistan_events.16 popup = yes }
			
	}

	current_value = {
		value = var:vizier_vs_shah_var
	}

	goal_add_value = {
		add = 144
		}
		
	fail = {
		OR = {
		scope:yazer_scope = {
		is_character_alive = no
			}
		ig:ig_landowners = { is_powerful = NO }
		}		
	}
	
	on_fail = {
	add_loyalists = {
			value = 0.05
			}
	}
	
	progressbar = yes

	weight = 1000
	
	should_be_pinned_by_default = yes
}

je_vizier_coup = {
	icon = "gfx/interface/icons/event_icons/event_protest.dds"
	group = je_group_historical_content
	
	immediate = {
		random_interest_group = {
			limit = {
				has_variable = coup_ig_var
			}
			save_scope_as = coup_ig
			remove_variable = coup_ig_var
		}
		random_scope_character = {
			limit = {
				has_variable = yar_alive_var
			}
			save_scope_as = yazer_scope
			}
	}

	on_weekly_pulse = {
		effect = {
			if = {
				limit = {
					scope:coup_ig = {
						OR = {
							is_powerful = no
							ig_approval >= 0
						}
					}
				}
				change_variable = {
					name = coup_var
					add = -1
				}
			}
			if = {
				limit = {
					scope:coup_ig = {
						is_powerful = yes
						ig_approval < 0
					}
				}
				change_variable = {
					name = coup_var
					add = 1
				}
			}
		}
	}

	on_monthly_pulse = {
		random_events = {
			150 = 0
			10 = coup_pulse_events.1
			10 = coup_pulse_events.2
			10 = coup_pulse_events.3 
			10 = coup_pulse_events.4
			10 = coup_pulse_events.5
			10 = coup_pulse_events.6
			10 = coup_pulse_events.7
			10 = coup_pulse_events.8
			10 = coup_pulse_events.9
			10 = coup_pulse_events.10
			25 = coup_pulse_events.11
			25 = coup_pulse_events.12
			25 = coup_pulse_events.13
			25 = coup_pulse_events.14
			25 = coup_pulse_events.15
			25 = coup_pulse_events.16
			25 = coup_pulse_events.17
			25 = coup_pulse_events.18
		}
	}

	complete = {
		scope:coup_ig = {
			is_powerful = yes
			ig_approval < 0
		}
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}

	on_complete = {
		remove_variable = coup_var
		#custom_tooltip = coup_success_tt
		trigger_event = { id = 01_afghanistan_events.17 popup = yes }
			ig:ig_landowners = {
			remove_modifier = yaz_rebels_modifier	
			}
	}

	fail = {
		OR = {
			# fail if the coup has run out of steam
			custom_tooltip = {
				text = coup_no_progress
				root.var:coup_var <= 0
			}
			# fail if the IG is kicked out of government
			scope:coup_ig = {
				is_in_government = no
			}
		}
	}

	on_fail = {
		custom_tooltip = historical_yazer_tt
		custom_tooltip = coup_remove_ig
		# IG is angry that they were removed from government
		if = {
			limit = {
				scope:coup_ig = {
					is_in_government = no
					NOT = {
						has_variable = resigned_from_gov_coup
					}
				}
			}
			trigger_event = { id = coup.3 popup = yes }
		}
		else_if = {
			limit = {
				scope:coup_ig = {
					is_in_government = no
					has_variable = resigned_from_gov_coup
				}
			}
			trigger_event = { id = coup.5 popup = yes }
			remove_variable = resigned_from_gov_coup
		}
		# coup runs out of steam or IG changes law stances
		else_if = {
			limit = {
					root.var:coup_var <= 0

			}
			trigger_event = { id = coup.4 popup = yes }
		}
		remove_variable = coup_var
		add_journal_entry = { type = je_impending_civil_war }
	}

	invalid = {
		scope:yazer_scope = {
		is_character_alive = no
		}
	}

	on_invalid = {
		remove_variable = coup_var
	}

	status_desc = {
		first_valid = {
			triggered_desc = {
				desc = coup_advancing
				trigger = {
					scope:coup_ig = {
						is_powerful = yes
						ig_approval < 0
					}
				}
			}
			triggered_desc = {
				desc = coup_declining
				trigger = {
					scope:coup_ig = {
						OR = {
							is_powerful = no
							ig_approval >= 0
						}
					}
				}
			}
		}
	}

	current_value = {
		value = root.var:coup_var
	}

	goal_add_value = {
		add = 100
	}

	progressbar = yes

	should_be_pinned_by_default = yes

	weight = 100
}

je_impending_civil_war = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
		
	immediate = {
		
		random_scope_character = {
			limit = {
				has_variable = yar_alive_var
			}
			save_scope_as = yazer_scope
			}
	}
	
	complete = {
		custom_tooltip = {
		text = icw_complete_tt
		ruler = {
		has_variable = durrani_alive_var
		}
		
		scope:yazer_scope = {
		is_character_alive = no
			}
		}
	}

	on_complete = {
	add_loyalists = {
	value = 0.1
		}
	}

	fail = {	
	custom_tooltip = {
	text = icw_fail_tt
		
		ruler = {
		NOT = {
		has_variable = durrani_alive_var
				}
			}

		}	
	}

	on_fail = {
	custom_tooltip = historical_tt
		ig:ig_landowners = {
			remove_modifier = yaz_rebels_modifier	
			}
			
		custom_tooltip = {
		text = icw_on_fail_tt
		if = {
			limit = {
			NOT = {
		ruler = {
		has_variable = yar_alive_var
			}
		}
		ig:ig_landowners = {
		leader = {
		has_variable = yar_alive_var
				}
			}
		}
	
		heir = {
						kill_character = yes
					}
					ruler = {
						kill_character = yes
					}	
			ig:ig_landowners = {
				leader = {
					set_character_as_ruler = yes
					}
			
				}	
			}
		if = {
			limit = {
			NOT = {
		ruler = {
		has_variable = yar_alive_var
			}
		}
		ig:ig_landowners = {
		leader = {
		NOT = {
		has_variable = yar_alive_var
					}
				}
			}
		}
	
		heir = {
						kill_character = yes
					}
					ruler = {
						kill_character = yes
					}	
			create_character = {
			first_name = "Yar_Mohammad"
			last_name = "Alakozai"
			historical = yes
			birth_date = 1790.1.9
			culture = pashtun
			ruler = yes
			is_general = yes
			interest_group = ig_landowners
			ideology = ideology_traditionalist
			traits = {
				ambitious
			}
			on_created = {
				set_variable = {
					name = yar_alive_var
						}				
					}
			
				}
			}
		}
	}
	should_be_pinned_by_default = yes

	weight = 100
}

je_in_a_pickle = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
	exists = c:KAN
	this = c:KAN
	any_scope_character = {			
				has_variable = is_kohan
			}
	}
	
	possible = {
	any_scope_character = {			
				has_variable = is_kohan
			}
	}
		
	immediate = {
	random_scope_character = {
			limit = {
				has_variable = is_kohan
			}
			save_scope_as = kohan_scope
			}
		set_variable = {
			name = in_a_pickle_progress_var
			value = 0
		}
	}

	complete = {		
		scope:kohan_scope = {
		is_character_alive = no
			}
		scope:journal_entry = {
						is_goal_complete = yes
					}
	}


	on_complete = {	
	
		if = {
			limit = {
					has_variable = supporting_land_owners_var
					any_interest_group = {
						leader = { has_variable = rahim_dil_alive_var }
						is_in_government = yes
					}
			}
			heir = {
						kill_character = yes
					}
					hideen_effect = {
					ruler = {
						kill_character = yes
					}
				}
			ig:ig_landowners = {
				leader = {
					set_character_as_ruler = yes
					}
			
				}
		}
		if = {
			limit = {
					has_variable = supporting_armed_forces_var
					any_interest_group = {
						leader = { has_variable = mir_dil_alive_var }
						is_in_government = yes
					}
			}
			heir = {
						kill_character = yes
					}
					hideen_effect = {
					ruler = {
						kill_character = yes
					}
				}	
			ig:ig_armed_forces = {
				leader = {
					set_character_as_ruler = yes
					}
			
				}
		}
	}
	fail = {	
		scope:kohan_scope = {
		is_character_alive = no
			}
		hidden_effect = {
		scope:journal_entry = {
						is_goal_complete = no
					}
				}
	}

	on_fail = {
	custom_tooltip = historical_tt
	ig:ig_landowners = {
			remove_modifier = brotherly_love_modifier
		}
		ig:ig_armed_forces = {
			remove_modifier = brotherly_love_modifier
		}
		if = {
			limit = {
					any_interest_group = {
						leader = { has_variable = rahim_dil_alive_var }
					}
			}
		ig:ig_landowners = {	
			add_modifier = {
		name = brotherly_hatred_modifier
		years = 10
		decaying = yes
			}
		}
	}
		if = {
			limit = {
					any_interest_group = {
						leader = { has_variable = mir_dil_alive_var }
					}
			}
		ig:ig_armed_forces = {	
			add_modifier = {
		name = brotherly_hatred_modifier
		years = 10
		decaying = yes
				}
			}
		}
	}

	scripted_button = in_a_pickle_landowners_button
	scripted_button = in_a_pickle_armed_forces_button

	status_desc = {
		first_valid = {
			
			triggered_desc = { 
				desc = status_land_owners_in_a_pickle
				trigger = {
					has_variable = supporting_land_owners_var
				}
			}
			triggered_desc = { 
				desc = status_armed_forces_in_a_pickle
				trigger = {
					has_variable = supporting_armed_forces_var
				}
			}
			triggered_desc = { # Bar not moving, either no supported or not in government
				desc = status_afg_no_dynasty
				trigger = {
					always = yes
				}
			}
		}
	}

	on_weekly_pulse = {
		events = {
			01_afghanistan_events.18
		}
	}

	on_monthly_pulse = {
		effect = {
			if = {
				limit = {
					scope:journal_entry = {
						is_goal_complete = no
					}
					has_variable = in_a_pickle_progress_var
					OR = {
						AND = {
							trigger_if = {
								has_variable = supporting_land_owners_var
							}							
							any_interest_group = {
								leader = { has_variable = rahim_dil_alive_var }
								is_in_government = yes
								OR = {
								is_powerful = yes
								ig_approval >= 20
								}
							}
						}
						AND = {
							trigger_if = {
								has_variable = supporting_armed_forces_var
							}
							any_interest_group = {
								leader = { has_variable = mir_dil_alive_var }
								is_in_government = yes
								OR = {
								is_powerful = yes
								ig_approval >= 20
								}
							}
						}
					}
				}
				change_variable = {
					name = in_a_pickle_progress_var
					add = 1
				}
			}
			if = {
				limit = {
					scope:journal_entry = {
						is_goal_complete = no
					}
					has_variable = in_a_pickle_progress_var
					OR = {
						AND = {
							trigger_if = {
								has_variable = supporting_land_owners_var
							}
							var:in_a_pickle_progress_var >= 1
							any_interest_group = {
								leader = { has_variable = rahim_dil_alive_var }
								OR = {
								is_in_government = no
								AND = {
								is_powerful = no
								ig_approval < 20
									}
								}
							}
						}
						AND = {
							trigger_if = {
								has_variable = supporting_armed_forces_var
							}
							var:in_a_pickle_progress_var >= 1
							any_interest_group = {
								leader = { has_variable = mir_dil_alive_var }
								OR = {
								is_in_government = no
								AND = {
								is_powerful = no
								ig_approval < 20
									}
								}
							}
						}
					}
				}
				change_variable = {
					name = in_a_pickle_progress_var
					add = -1
				}
			}
		}
		#random_events = {
		#	50 = 0
		#	10 = french_pretenders_pulse.2
		#	10 = french_pretenders_pulse.3
		#}
	}
	on_yearly_pulse = {
		random_events = {
		}
	}

	current_value = {
		value = root.var:in_a_pickle_progress_var
	}

	goal_add_value = {
		value = 60
	}

	progressbar = yes

	weight = 100

	should_be_pinned_by_default = yes
}

je_russia_flood_of_opium = {
	icon = "gfx/interface/icons/event_icons/event_trade.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
	OR = {
	exists = c:AFG
	exists = c:DUR
	exists = c:KHO
	}
	OR = {
	this = c:AFG
	this = c:DUR
	this = c:KHO
		}
	}

	possible = {
		any_market = {		
			owner = c:RUS			
			any_trade_route = {
				exporter.owner = root				
				goods = g:opium
					}
				}
			}
				
	complete = {
			c:RUS = {
			any_primary_culture = {
				has_cultural_obsession = opium
			}
		}		
	}
			
	on_complete = {		
		c:RUS = {
		add_modifier = {
		name = opium_wars_addiction_modifier
		years = 5
			}
		}

	}

	weight = 10
}

je_britain_flood_of_opium = {
	icon = "gfx/interface/icons/event_icons/event_trade.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
	OR = {
	exists = c:AFG
	exists = c:DUR
	exists = c:KHO
	}
	OR = {
	this = c:AFG
	this = c:DUR
	this = c:KHO
		}
	}
	
	possible = {
		any_market = {		
			owner = c:GBR			
			any_trade_route = {
				exporter.owner = root				
				goods = g:opium
					}
				}
			}

	complete = {
			c:GBR = {
			any_primary_culture = {
				has_cultural_obsession = opium
				
			}
		}
	}

	on_complete = {		
		c:GBR = {
		add_modifier = {
		name = opium_wars_addiction_modifier
		years = 5
			}
		}
	}

	weight = 10
}

je_pharmaceutical_giant = {
	icon = "gfx/interface/icons/event_icons/event_industry.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
	OR = {
	exists = c:AFG
	exists = c:DUR
	exists = c:KHO
	}
	OR = {
	this = c:AFG
	this = c:DUR
	this = c:KHO
	}
	has_technology_researched = medical_degrees
	}

	complete = {
		has_technology_researched = pharmaceuticals
		has_technology_researched = modern_nursing
		any_scope_building = {
			is_building_type = building_opium_plantation
			cash_reserves_ratio > 0.5
			weekly_profit > 0
			occupancy >= 0.75
			level >= 50
			}
		}

	on_complete = {		
		add_modifier = world_class_hospitals_modifier
			}

	weight = 100
}

je_hostile_takeover = {
	icon = "gfx/interface/icons/event_icons/event_industry.dds"
	group = je_group_historical_content
	
	immediate = {
	c:BIC = { 
			save_scope_as = bic_sec_scope
			}
		}
		
	complete = {
					OR = {
					c:BIC = {
					is_subject_of = ROOT
						}
					AND = {
					owns_entire_state_region = STATE_SOUTH_BENGAL
					owns_entire_state_region = STATE_NORTH_BENGAL
					owns_entire_state_region = STATE_ASSAM
						}
					}
					scope:bic_sec_scope = { country_rank < root.country_rank }
				}				

	on_complete = {		
		trigger_event = { id = 01_afghanistan_events.15 }
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_graveyard_of_empires = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
	OR = {
	exists = c:AFG
	exists = c:DUR
	exists = c:KHO
	}
	OR = {
	this = c:AFG
	this = c:DUR
	this = c:KHO
		}
	}
	possible = {
	is_subject = yes
	}
	
	immediate = {
	if = {
		limit = {
			is_subject_of = c:GBR
				}
			set_variable = british_subject_var		
			}
	if = {
		limit = {
			is_subject_of = c:RUS
				}
			set_variable = russian_subject_var		
			}
	}
	
		on_monthly_pulse = {		
		random_events = {
			100 = 0
			5 = 01_afghanistan_events.8 #Resistance
			5 = 01_afghanistan_events.9 #Recruit Population
			5 = 01_afghanistan_events.10 #Mountain strongholds
			5 = 01_afghanistan_events.11 #Arms from foreign nations			
					}
				}
					
	complete = {
		is_subject = no
		#has_modifier = gravedigger_modifier
		is_at_war = no
	}

	on_complete = {
		remove_variable = gravedigger_var
		remove_modifier = gravedigger_modifier
		add_modifier = {
		name = another_tombstone_modifier
		years = 10
		decaying = yes
			}
		if = {
			limit = {
				has_variable = british_subject_var
				}
		trigger_event = { id = 01_afghanistan_events.4 }
			}
		if = {
			limit = {
				has_variable = russian_subject_var
				}
		trigger_event = { id = 01_afghanistan_events.12 }
			}
		}
	weight = 10
	
	should_be_pinned_by_default = yes
}

je_a_new_game_britain = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"
	group = je_group_historical_content
		
	immediate = {
	s:STATE_HOME_COUNTIES = { 
			if = {
				limit = {
					any_scope_state = {
						 NOT = {
							owner = ROOT
						}
					}
				}
				add_claim = ROOT 
			}
		}	
	}
					
	complete = {
				owns_entire_state_region = STATE_HOME_COUNTIES
						
	}

	on_complete = {
		add_modifier = checkmate_afgan_modifier

		c:GBR = {
		add_modifier = checkmate_gp_modifier
		}
		trigger_event = { id = 01_afghanistan_events.14 }
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_a_new_game_russia = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"
	group = je_group_historical_content
		
	immediate = {

	s:STATE_MOSCOW = { 
			if = {
				limit = {
					any_scope_state = {
						 NOT = {
							owner = ROOT
						}
					}
				}
				add_claim = ROOT 
			}
		}	
	}
					
	complete = {
				owns_entire_state_region = STATE_MOSCOW
						
	}

	on_complete = {
		add_modifier = checkmate_afgan_modifier
		c:RUS = {
		add_modifier = checkmate_gp_modifier
		}
		trigger_event = { id = 01_afghanistan_events.14 }
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_the_great_players = {
	icon = "gfx/interface/icons/event_icons/waving_flag.dds"
	group = je_group_historical_content
	
	complete = {
		custom_tooltip = {
		text = complete_great_players_tt
		NOT = {
	has_journal_entry = je_the_great_northern_players
	has_journal_entry = je_the_great_western_player
	has_journal_entry = je_the_great_eastern_player
	has_journal_entry = je_the_great_southern_players
			}
		}
	}

	on_complete = {
		
		trigger_event = { id = 01_afghanistan_events.23 }
		custom_tooltip = {
		text = grand_alliance_tt
		set_global_variable = grand_alliance_var
				}
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_the_great_northern_players = {
	icon = "gfx/interface/icons/event_icons/waving_flag.dds"
	group = je_group_historical_content
		
	
	immediate = {
	random_state = {
			limit = {
				state_region = s:STATE_BALKH
			}
			save_scope_as = balkh_state
		}
	}
	
	scripted_button = cede_balkh_button
	scripted_button = remove_bukharas_claim_button
	
	complete = {
					custom_tooltip = {
					text = bukhara_claims_tt		
					scope:balkh_state = {
					NOT = {
						has_claim_by = c:BUK
						}
					}
				}
				
	ROOT = {
			is_in_same_power_bloc = c:KOK
			is_in_same_power_bloc = c:BUK
			is_in_same_power_bloc = c:KHI
		}
				
	}

	on_complete = {
	c:KHI = {
		add_modifier = a_great_player_modifier

		}
				
	c:BUK = {
		add_modifier = a_great_player_modifier
		}
				
	c:KOK = {
		add_modifier = a_great_player_modifier
		}
				
			
		#trigger_event = { id = 01_afghanistan_events.??? }
			}

	weight = 1000
	
	#should_be_pinned_by_default = yes
}

je_the_great_western_player = {
	icon = "gfx/interface/icons/event_icons/waving_flag.dds"
	group = je_group_historical_content
		
	
	immediate = {
	random_state = {
			limit = {
				state_region = s:STATE_HERAT
			}
			save_scope_as = herat_state
		}
	}
	
	scripted_button = cede_herat_button
	scripted_button = remove_persias_claim_button
	
	complete = {
					custom_tooltip = {
					text = herat_claims_tt		
					scope:herat_state = {
					NOT = {
						has_claim_by = c:PER
						}
					}
				}

				
	ROOT = {
			is_in_same_power_bloc = c:PER
		}				
	}

	on_complete = {
	c:PER = {
		add_modifier = a_great_player_modifier
				}
		
		#trigger_event = { id = 01_afghanistan_events.??? }
			}

	weight = 1000
	
	#should_be_pinned_by_default = yes
}

je_the_great_eastern_player = {
	icon = "gfx/interface/icons/event_icons/waving_flag.dds"
	group = je_group_historical_content
						
	immediate = {
	random_state = {
			limit = {
				state_region = s:STATE_PASHTUNISTAN
			}
			save_scope_as = pashtunistan_state
		}
	}
	
	scripted_button = cede_pashtunistan_claim_button
	
	complete = {
					custom_tooltip = {
					text = pashtunistan_claims_tt		
					scope:pashtunistan_state = {
					NOT = {
						has_claim_by = root
						}
					}
				}
				
	ROOT = {
			is_in_same_power_bloc = c:PAN
		}				
	}

	on_complete = {
	c:PAN = {
		add_modifier = a_great_player_modifier

		}
				
	ROOT = {
			create_diplomatic_pact = {
            country = c:PAN
            type = the_great_players
			}	
		}
			
		#trigger_event = { id = 01_afghanistan_events.??? }
			}

	weight = 1000
	
	#should_be_pinned_by_default = yes
}

je_the_great_southern_players = {
	icon = "gfx/interface/icons/event_icons/waving_flag.dds"
	group = je_group_historical_content
						
	immediate = {
	random_state = {
			limit = {
				state_region = s:STATE_BALUCHISTAN
			}
			save_scope_as = kalat_state
		}
	}
	
	scripted_button = cede_kalat_claim_button
	
	complete = {
					custom_tooltip = {
					text = kalat_claims_tt		
					scope:kalat_state = {
					NOT = {
						has_claim_by = root
						}
					}
				}
	
	ROOT = {
			OR = {
			is_in_same_power_bloc = c:BLH
			AND = {
			is_in_same_power_bloc = c:KAL
			is_in_same_power_bloc = c:MAK
				}
			}
		}
				
	}

	on_complete = {
	c:KAL = {
		add_modifier = a_great_player_modifier
				}
	c:MAK = {
		add_modifier = a_great_player_modifier
				}
	c:BLH = {
		add_modifier = a_great_player_modifier
				}
			
		#trigger_event = { id = 01_afghanistan_events.??? }
			}

	weight = 1000
	
	#should_be_pinned_by_default = yes
}

je_khorasan_ascendant = {
	icon = "gfx/interface/icons/event_icons/waving_flag.dds"
	group = je_group_historical_content
	
	#	is_shown_when_inactive = {
	#has_journal_entry = je_the_great_game_afghanistan
	#}
	
	complete = {
		custom_tooltip = {
		text = complete_is_khorasan_tt
		exists = c:KHO
		this = c:KHO
		}
		custom_tooltip = {
		text = complete_khorasan_ascendant_tt
		NOT = {
	has_journal_entry = je_the_impenetrable_coast
	has_journal_entry = je_whats_ours_is_ours
	has_journal_entry = je_the_northern_wall
			}
		}
	}

	on_complete = {	
		trigger_event = { id = 01_afghanistan_events.23 }
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_the_impenetrable_coast = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"
	group = je_group_historical_content
	
		#is_shown_when_inactive = {
	#has_journal_entry = je_the_great_game_afghanistan
	#}
	
	complete = {
		any_scope_state = {
			any_scope_building = {
				is_building_type = building_port
				level >= 5
					}
			any_scope_building = {
				is_building_type = building_naval_base
				level >= 20
					}
		}
	}

	on_complete = {
		add_modifier = impenetrable_coast_modifier
		
		#trigger_event = { id = 01_afghanistan_events.??? }
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_whats_ours_is_ours = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"
	group = je_group_historical_content
	
		#is_shown_when_inactive = {
	#has_journal_entry = je_the_great_game_afghanistan
	#}
	
	immediate = {
	random_state = {
			limit = {
				state_region = s:STATE_BALKH
			}
			save_scope_as = balkh_state
		}
	random_state = {
			limit = {
				state_region = s:STATE_HERAT
			}
			save_scope_as = herat_state
		}
	}
	
	complete = {
		custom_tooltip = {
		text = bukhara_claims_tt
		OR = {
		NOT = {
		exists = c:BUK
			}				
					scope:balkh_state = {
					NOT = {
						has_claim_by = c:BUK
						}
					}
				}
			}
		custom_tooltip = {
					text = herat_claims_tt		
					scope:herat_state = {
					NOT = {
						has_claim_by = c:PER
						}
					}
				}
		owns_entire_state_region = STATE_PASHTUNISTAN
		owns_entire_state_region = STATE_BALUCHISTAN
		owns_entire_state_region = STATE_HERAT
		owns_entire_state_region = STATE_BALKH
		owns_entire_state_region = STATE_KABUL
		owns_entire_state_region = STATE_KANDAHAR
	}

	on_complete = {
	add_modifier = ours_forever_modifier	
		
		}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_the_northern_wall = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"
	group = je_group_historical_content
	
		#is_shown_when_inactive = {
	#has_journal_entry = je_the_great_game_afghanistan
	#}
	
	complete = {
		
			OR = {
			owns_entire_state_region = STATE_MERZ
			c:BUK = {
					owns_entire_state_region = STATE_MERZ
					is_subject_of = root
						}
			}
			OR = {
			owns_entire_state_region = STATE_UZBEKIA
			c:BUK = {
					owns_entire_state_region = STATE_UZBEKIA
					is_subject_of = root
						}
			}
			OR = {
			owns_entire_state_region = STATE_TAJIKISTAN
			AND = {
			c:KOK = {
					owns_entire_state_region = STATE_TAJIKISTAN
					is_subject_of = root
						}
			}
		}

	}

	on_complete = {
		
		add_modifier = nomadic_conscripts_modifier
		
		#trigger_event = { id = 01_afghanistan_events.??? }
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_overthrow_shuja = {
	icon = "gfx/interface/icons/event_icons/event_protest.dds"
	group = je_group_historical_content
		
	scripted_button = guerrilla_war_button
	scripted_button = encourage_revolt_button
	
	complete = {	
			custom_tooltip = {
			text = durrani_gone_tt
			NOT = { exists = c:DUR }
			}
	}
	
	on_complete = {
		custom_tooltip = historical_tt
		if = {
			limit = {
				has_modifier = cost_guerrilla_war_modifier
				}
			remove_modifier = cost_guerrilla_war_modifier
			}
		if = {
			limit = {
				has_modifier = cost_encourage_revolt_modifier
				}
			remove_modifier = cost_encourage_revolt_modifier
			}
		trigger_event = { id = 01_afghanistan_events.3 }
			}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_british_garrison = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
		
	immediate = {
		set_variable = {
			name = afghan_uprising_var
			value = 0
		}
		random_scope_character = {
			limit = {
				has_variable = is_elphinstone_var
			}
			save_scope_as = elphinstone_scope
			}
	}


	on_monthly_pulse = {
		effect = {
			if = {
				limit = {			
				ig:ig_landowners = {
							ig_approval <= -5
						} 
				}
				change_variable = {
					name = afghan_uprising_var
					add = 1
				}
			}
			if = {
				limit = {			
				ig:ig_rural_folk = {
							ig_approval <= -5
						} 
				}
				change_variable = {
					name = afghan_uprising_var
					add = 1
				}
			}
			if = {
				limit = {			
				ig:ig_devout = {
							ig_approval <= -5
						} 
				}
				change_variable = {
					name = afghan_uprising_var
					add = 1
				}
			}
			if = {
				limit = {			
				ig:ig_armed_forces = {
							ig_approval <= -5
						} 
				}
				change_variable = {
					name = afghan_uprising_var
					add = 1
				}
			}
		}
	}
	
	complete = {
		custom_tooltip = historical_tt
		scope:journal_entry = {
			is_goal_complete = yes  
			}
		}			
	

	on_complete = {			
			trigger_event = { id = 01_afghanistan_events.29 popup = yes }
			
	}

	current_value = {
		value = var:afghan_uprising_var
	}

	goal_add_value = {
		add = 13
		}
		
	fail = {
		OR = {
		scope:elphinstone_scope = {
		is_character_alive = no
			}
		custom_tooltip = {
			text = elphinstone_gone_tt
		ig:ig_armed_forces = {
		NOT = {
		leader = {				
				has_variable = is_elphinstone_var
						}
					}
				}
			}
		}		
	}
	
	on_fail = {
	add_loyalists = {
			value = 0.02
			}
			remove_modifier = british_garrison_modifier
			if = {
			limit = {
				has_modifier = tribal_bribes_modifier
				}
			remove_modifier = tribal_bribes_modifier
			}
	}
	
	timeout = 730
	
	on_timeout = {
		add_loyalists = {
			value = 0.02
			}				 
	}
	
	progressbar = yes

	weight = 1000
	
	should_be_pinned_by_default = yes
}