﻿je_ailing_shah = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
		
	is_shown_when_inactive = {
	this = c:PER
	}
	
	immediate = {
	random_scope_character = {
			limit = {
				has_template = per_mohammad_shah_qajar_template
			}
			save_scope_as = mohammad_qajar_scope
			}
	}
	
	scripted_button = prepare_the_crown_prince_button
	
	on_monthly_pulse = {
		random_events = {
			100 = 0
			25 = 03_persia_events.3 #Prepare the Crown Prince
			5 = 03_persia_events.10 #Treat the Shah	
			3 = 03_persia_events.2 #not getting better with traditional doctors
			4 = 03_persia_events.1 #not getting better with european doctors
			#1 = 03_persia_events.4 #Death of the Shah
					}
				}
	
	complete = {
		OR = {
		ruler = {
			NOT = {
			OR = {
			has_trait = ill
			has_trait = severly_ill
			has_trait = deathly_ill
				}
			}
		}
		has_technology_researched = pharmaceuticals
		}
	}
	
	on_complete = {	
	add_loyalists = {
	value = 0.02
	}
	if = {
		limit = {
	ruler = {
	has_trait = ill
				}
			}
		ruler = {
		remove_trait = ill
			}
		}
		if = {
		limit = {
	ruler = {
	has_trait = severly_ill
			}
		}
		ruler = {
		remove_trait = severly_ill
			}
		}
	if = {
		limit = {
	ruler = {
	has_trait = deathly_ill
				}
			}
		ruler = {
		remove_trait = deathly_ill
			}
		}	
	}
	fail = {
	scope:mohammad_qajar_scope = {
		is_character_alive = no
			}
	}
	
	#on_fail = {
	#}
	
	timeout = 4380

	on_timeout = {
		trigger_event = { id = 03_persia_events.4 popup = yes } #Death of the Shah
	
	}
	weight = 10

	should_be_pinned_by_default = yes
}

je_not_getting_better_europe = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
	
	complete = {
		ruler = {
			NOT = {
			OR = {
			has_trait = ill
			has_trait = severly_ill
			has_trait = deathly_ill
				}
			}
		}
	}

	on_complete = {		
	}


		timeout = 730

	on_timeout = {
		trigger_event = { id = 03_persia_events.1 popup = yes }
		}


	weight = 10

	should_be_pinned_by_default = yes
}

je_not_getting_better_traditional = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"
	group = je_group_historical_content
	
	complete = {
		ruler = {
			NOT = {
			OR = {
			has_trait = ill
			has_trait = severly_ill
			has_trait = deathly_ill
				}
			}
		}
	}

	on_complete = {		
	
	}


		timeout = 2190

	on_timeout = {
		trigger_event = { id = 03_persia_events.2 popup = yes }	
	}

	weight = 10

	should_be_pinned_by_default = yes
}

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

	complete = {
		has_technology_researched = central_archives
		NOT = {
		has_journal_entry = je_babism
		has_law = law_type:law_peasant_levies
		has_law = law_type:law_traditionalism
		has_law = law_type:law_no_police
		has_law = law_type:law_local_police
		}
		
		
	}

	on_complete = {	
		add_loyalists = {		
			value = 0.02
			}	
		remove_modifier = minor_vassals_modifier
		trigger_event = { id = 03_persia_events.58 }

	}
		

	weight = 1000
	
	should_be_pinned_by_default = yes

}

je_repeal_jizya_tax = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
	OR = {
			this = c:PER
			this = c:QAJ
			}	
		game_date >= 1854.1.1		
		has_law = law_type:law_monarchy
		has_law = law_type:law_jizya_tax
		#has_technology_researched = egalitarianism
		#has_journal_entry = je_persia_great_game
		}
		
	immediate = {
	create_character = {
					first_name = Maneckji_Limji
					last_name = Hataria
					historical = yes
					is_agitator = yes
					interest_group = ig_intelligentsia
					ig_leader = no
					birth_date = 1813.1.2
					culture = cu:persian
					religion = rel:zoroastrian
					ideology = ideology_zoroastrian_moralist					
					traits = {
						persistent												
						pious						
						inspirational_orator
				}
				on_created = {
				set_variable = {
					name = is_hataria_var					
				}				
			}		
		}
		random_scope_character = {
		limit = {
			has_variable = is_hataria_var
			}
		save_scope_as = hataria_scope
		}
	trigger_event = { id = 03_persia_events.76 popup = yes }
	}
	
	on_monthly_pulse = {
		random_events = {
			100 = 0
			04 = 03_persia_events.61 #Appeal to Repeal
					}
				}
	
	complete = {
		has_law = law_type:law_no_tax
				
	}

	on_complete = {
	trigger_event = { id = 03_persia_events.48 }	
	}
	
	fail = {
		OR = {
		scope:hataria_scope = {
					is_character_alive = no
				}
				custom_tooltip = {
				text = hataria_exiled_tt
				any_character_in_exile_pool = {
					has_variable = is_hataria_var
				}
			}
		}
	}
	on_fail = {
	add_radicals = {
		religion = rel:zoroastrian
		value = 0.25
		}
	}		
			
	invalid = {
	has_variable = not_allow_parsi_activist_var
	}
	
	on_invalid = {
	remove_variable = not_allow_parsi_activist_var
	}
	
	weight = 10

}


je_tobacco_buyout = {
	icon = "gfx/interface/icons/event_icons/event_trade.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
		OR = {
		this = c:PER
		this = c:QAJ
		}
		has_law = law_type:law_monarchy
		#has_journal_entry = je_persia_great_game
		has_technology_researched = corporate_charters
	}

	complete = {
	#has_journal_entry = je_persia_great_game
	has_law = law_type:law_monarchy
	has_company = company_type:company_imperial_tobacco
	OR = {
		AND = {
		has_technology_researched = investment_banks
		custom_tooltip = {
			text = company_imperial_tobacco_properity_tt
			any_company = {
				type = company_type:company_imperial_tobacco
				prosperity >= 100
					}
				}
			}
		game_date >= 1890
		}
	}

	on_complete = {		
		trigger_event = { id = 03_persia_events.21 }
			}
			
	invalid = {
	country_rank = rank_value:great_power
	}
	
	weight = 10
	
	should_be_pinned_by_default = yes
}

je_tobacco_protests = {
	icon = "gfx/interface/icons/event_icons/event_protest.dds"
	group = je_group_historical_content
	

	immediate = {
		set_variable = {
			name = tobacco_protests_timer_var
			value = 0
		}
	}

on_monthly_pulse = {
		effect = {
			change_variable = {
				name = tobacco_protests_timer_var
				add = 1
			}
		}
	}

	complete = {
		scope:journal_entry = { is_goal_complete = yes }
	}

	on_complete = {		
	add_radicals = {
		pop_type = farmers
			value = very_large_radicals
			}
								add_radicals = {
		pop_type = shopkeepers
			value = very_large_radicals
			}
			add_radicals = {
		pop_type = clergymen
			value = very_large_radicals
			}
	create_character = {
					first_name = hajj_mohammad
					last_name = malek_altojjar
					historical = yes
					interest_group = ig_petty_bourgeoisie
					female = no
					is_agitator = yes
					culture = cu:persian
					religion = rel:shiite
					ideology = ideology_isolationist					
					traits = {
					inspirational_orator
					}
		}
	create_character = {
					first_name = mirza 
					last_name = hasan_shirazi
					historical = yes
					interest_group = ig_devout
					female = no
					is_agitator = yes
					culture = cu:persian
					religion = rel:shiite
					ideology = ideology_isolationist					
					traits = {
					pious
					demagogue
					}
		}
		trigger_event = { id = 03_persia_events.23 }
	}

	current_value = {
		value = root.var:tobacco_protests_timer_var
	}

	goal_add_value = {
		value = 7
	}

	progressbar = yes

	weight = 10

	should_be_pinned_by_default = yes

}

je_darcy_oil_survey = {
	icon = "gfx/interface/icons/event_icons/event_industry.dds"
	group = je_group_historical_content
		
	immediate = {
				
			random_state = {
			limit = {
				state_region = s:STATE_LURISTAN
			}
			save_scope_as = oil_luristan_scope
		}
		random_state = {
			limit = {
				state_region = s:STATE_LARISTAN
			}
			save_scope_as = oil_laristan_scope
		}
		random_state = {
			limit = {
				state_region = s:STATE_KHUZESTAN
			}
			save_scope_as = oil_khuzestan_scope
		}
		random_state = {
			limit = {
				state_region = s:STATE_FARS
			}
			save_scope_as = oil_fars_scope
		}
		random_state = {
			limit = {
				state_region = s:STATE_KHORASAN
			}
			save_scope_as = oil_khorasan_scope
		}
		random_state = {
			limit = {
				state_region = s:STATE_MAZANDARAN
			}
			save_scope_as = oil_mazandaran_scope
		}
		
	}
	
	modifiers_while_active = {
		uf_oil_drilling_modifier
	}

	complete = {
	OR = {
	scope:oil_luristan_scope = { 
			any_scope_building = {
				is_building_type = building_oil_rig
				is_under_construction = yes
				}
			}
	scope:oil_laristan_scope = { 
			any_scope_building = {
				is_building_type = building_oil_rig
				is_under_construction = yes
				}
			}
	scope:oil_khuzestan_scope = { 
			any_scope_building = {
				is_building_type = building_oil_rig
				is_under_construction = yes
				}
			}
	scope:oil_fars_scope = { 
			any_scope_building = {
				is_building_type = building_oil_rig
				is_under_construction = yes
				}
			}
	scope:oil_khorasan_scope = { 
			any_scope_building = {
				is_building_type = building_oil_rig
				is_under_construction = yes
				}
			}
	scope:oil_mazandaran_scope = { 
			any_scope_building = {
				is_building_type = building_oil_rig
				is_under_construction = yes
				}
			}
		}
	}

	on_complete = {			
	trigger_event = { id = 03_persia_events.28 }
	}
	
	

	weight = 1000

}

je_anglo_persian_oil_company = {
	icon = "gfx/interface/icons/event_icons/event_industry.dds"
	group = je_group_historical_content
		
	#modifiers_while_active = {
		#apoc_oil_modifier
	#}

	complete = {
	custom_tooltip = {
	text = never_ending_oil_tt
		has_variable = iranian_oil_nationalised_var
		}
	}

	on_complete = {			
	remove_modifier = darcy_concession_modifier
	}
	
	fail = {
	custom_tooltip = {
	text = persia_cancel_oil_tt
	NOT = {
	any_market = {		
			owner = c:GBR			
			any_trade_route = {
				exporter.owner = root				
				goods = g:oil
					}
				}
			}
		}
	}
	on_fail = {
	remove_modifier = darcy_concession_modifier
	change_relations = { 
				country = c:GBR 
				value = -120 
			}
	
	s:STATE_FARS = { 
			add_claim = c:GBR
			}
	s:STATE_KHUZESTAN = { 
			add_claim = c:GBR
			}
	s:STATE_LURISTAN = { 
			add_claim = c:GBR
			}
	s:STATE_LARISTAN = { 
			add_claim = c:GBR
			}
		}

	weight = 1000

}

je_power_of_the_people = {
	icon = "gfx/interface/icons/event_icons/event_protest.dds"
	group = je_group_historical_content
	
	complete = {
	custom_tooltip = historical_if_russia_tt		
			#OR = {
		#has_modifier = british_repayment_modifier
		#has_modifier = russian_repayment_modifier
			#}
		custom_tooltip = {
		text = nasir_is_alive_tt
		ruler = {
			NOT = {
			has_template = per_nasir_al_din_qajar_template
				}
			}
		}
	}

	on_complete = {			
		trigger_event = { id = 03_persia_events.29 }
	}
	
	fail = {
	NOT = {
	has_law = law_type:law_monarchy
		}
	}
	
	on_fail = {
	}
	
	weight = 100
	
	should_be_pinned_by_default = yes

}

je_not_backing_down = {
	icon = "gfx/interface/icons/event_icons/event_protest.dds"
	group = je_group_historical_content
	
	timeout = 30

	on_timeout = {
		trigger_event = { id = 03_persia_events.30 }
	}

	weight = 10

	should_be_pinned_by_default = yes
}

je_no_justice = {
	icon = "gfx/interface/icons/event_icons/event_protest.dds"
	group = je_group_historical_content
	
	immediate = {
		set_variable = {
			name = no_justice_var
			value = 0
		}
	}
	
		on_monthly_pulse = {
		effect = {
			if = {
				limit = {			
					has_law = law_type:law_monarchy
					NOT = {
					is_enacting_law = law_type:law_parliamentary_republic
					}
				}
				change_variable = {
					name = no_justice_var
					add = 1
				}
			}
		}
	}


	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
			}			
	}

	on_complete = {
	custom_tooltip = historical_tt
		trigger_event = { id = 03_persia_events.31 }

		set_variable = {
		name = no_justice_complete_var
		value = yes
		}
	}

	current_value = {
		value = var:no_justice_var
	}

	goal_add_value = {
		add = 5
		}

	progressbar = yes
	

	weight = 10

	should_be_pinned_by_default = yes
}

je_persian_constitution = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"
	group = je_group_historical_content
	
	immediate = {
		set_variable = {
			name = persian_constitution_var
			value = 0
		}
	}
	
		on_monthly_pulse = {
		effect = {
			if = {
				limit = {			
					NOT = {
					is_enacting_law = law_type:law_monarchy
					}
				}
				change_variable = {
					name = persian_constitution_var
					add = 1
				}
			}
		}
	}


	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
			}			
	}

	on_complete = {
	custom_tooltip = historical_tt
		trigger_event = { id = 03_persia_events.32 }
	}

	current_value = {
		value = var:persian_constitution_var
	}

	goal_add_value = {
		add = 7
		}

	progressbar = yes
	

	weight = 10

	should_be_pinned_by_default = yes
}

je_tabriz_warnings = {
	icon = "gfx/interface/icons/event_icons/event_default.dds"
	group = je_group_historical_content
	
	immediate = {
		set_variable = {
			name = tabriz_warnings_var
			value = 0
		}
	}
	
		on_monthly_pulse = {
		effect = {
			if = {
				limit = {			
					NOT = {
					is_enacting_law = law_type:law_monarchy
					}
				}
				change_variable = {
					name = tabriz_warnings_var
					add = 1
				}
			}
		}
	}


	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
			}			
	}

	on_complete = {
	custom_tooltip = historical_tt
		trigger_event = { id = 03_persia_events.33 }
	}

	current_value = {
		value = var:tabriz_warnings_var
	}

	goal_add_value = {
		add = 7
		}

	progressbar = yes
	

	weight = 10

	should_be_pinned_by_default = yes
}

je_baskerville_siege_of_tabriz = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"
	group = je_group_historical_content
	
	immediate = {
		set_variable = {
			name = march_on_the_shah_var
			value = 0
		}
	}
	
		on_monthly_pulse = {
		effect = {
			if = {
				limit = {			
					NOT = {
					is_enacting_law = law_type:law_monarchy
					}
				}
				change_variable = {
					name = march_on_the_shah_var
					add = 1
				}
			}			
		}
		random_events = {
			6 = 0
			1 = 03_persia_events.46 #baskerville arrives
			1 = 03_persia_events.47 #baskerville tries to break the siege
					}
	}


	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
			}			
	}

	on_complete = {
	custom_tooltip = historical_tt
	remove_modifier = majlis_dissolved_modifier
		trigger_event = { id = 03_persia_events.34 days = 30 popup = yes }
	}

	current_value = {
		value = var:march_on_the_shah_var
	}

	goal_add_value = {
		add = 24
		}

	progressbar = yes
	
	fail = {
	OR = {
	has_law = law_type:law_autocracy
	has_law = law_type:law_oligarchy
	has_law = law_type:law_landed_voting
		}
	}
	
		on_fail = {
		change_relations = { 
				country = c:RUS 
				value = 15 
			}	
	}

	weight = 10

	should_be_pinned_by_default = yes
}

je_shuster_refinancing = {
	icon = "gfx/interface/icons/event_icons/event_portrait.dds"
	group = je_group_historical_content
	

	immediate = {
		set_variable = {
			name = shuster_refinancing_var
			value = 0
		}
	}
	
		on_monthly_pulse = {
		effect = {
			
				change_variable = {
					name = shuster_refinancing_var
					add = 1
				}
			}
		}
	
	
	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
			}			
	}

	on_complete = {
	custom_tooltip = historical_tt
		trigger_event = { id = 03_persia_events.36 }
	}

	current_value = {
		value = var:shuster_refinancing_var
	}

	goal_add_value = {
		add = 7
		}

	progressbar = yes
	

	weight = 10

}

je_weak_shah = {
	icon = "gfx/interface/icons/event_icons/event_portrait.dds"
	group = je_group_historical_content
		
	
	complete = {
	has_modifier = cossack_brigade_modifier
	any_scope_war = {
		    has_war_support = {
		        target = ROOT
		        value < 60
		    }
		}
		government_legitimacy <= 25
		
			}
	

	on_complete = {			
		remove_modifier = majlis_dissolved_modifier
		trigger_event = { id = 03_persia_events.38 }
	}
	
	weight = 100
	
	should_be_pinned_by_default = yes

}

je_rezas_ambition = {
	icon = "gfx/interface/icons/event_icons/event_portrait.dds"
	group = je_group_historical_content
	

	immediate = {
		set_variable = {
			name = reza_faction_var
			value = 0
		}
	}
	
		on_monthly_pulse = {
		effect = {
			if = {
				limit = {			
					ig:ig_armed_forces = { is_powerful = yes }
				}
				change_variable = {
					name = reza_faction_var
					add = 1
				}
			}
			if = {
				limit = {			
					ig:ig_armed_forces = { is_in_government = yes }
				}
				change_variable = {
					name = reza_faction_var
					add = 1
				}
			}
		}
	}


	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
			}			
	}

	on_complete = {		
		trigger_event = { id = 03_persia_events.39 }
	}

	current_value = {
		value = var:reza_faction_var
	}

	goal_add_value = {
		add = 60
		}
		
	timeout = 3650
	
	on_timeout = {					 
	}
	
	progressbar = yes

	weight = 1000
	
	should_be_pinned_by_default = yes
}

je_friends_with_germany = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"	
	group = je_group_historical_content
		
	is_shown_when_inactive = {
		OR = {
		this = c:PER
		this = c:QAJ
		}
		has_variable = reza_khan_is_shah_var
	}
	
	scripted_button = iran_button
		
	on_monthly_pulse = {
		effect = {
			if = {
				limit = {
					NOT = {
					has_variable = check_friends_with_germany_var
					}
				}
				set_variable = check_friends_with_germany_var				
			}
		}
	}

	complete = {
			OR = {
			c:GER = {
				relations:root >= relations_threshold:cordial
			}
						c:PRU = {
				relations:root >= relations_threshold:amicable
			}
		}
		custom_tooltip = {
			text = is_true_tt
			has_variable = check_friends_with_germany_var
			}
	}

	on_complete = {
		trigger_event = { id = 03_persia_events.40 }		
		
		change_relations = { 
				country = c:GBR 
				value = -25 
			}
					change_relations = { 
				country = c:RUS 
				value = -25 
			}						
		}


	weight = 100

	should_be_pinned_by_default = yes
}


je_mossadeq_for_prime_minister = {
	icon = "gfx/interface/icons/event_icons/event_election.dds"
	group = je_group_historical_content
				

	complete = {
					ig:ig_intelligentsia = {
					is_marginal = no
					}
					in_election_campaign = yes
				}
				

	on_complete = {		
			py:liberal_party = { add_momentum = 1 }
			add_journal_entry = {
        	type = je_so_close
			}			
		}


	weight = 100

	should_be_pinned_by_default = yes
}

je_so_close = {
	icon = "gfx/interface/icons/event_icons/event_election.dds"
	group = je_group_historical_content
				

	complete = {
					ig:ig_intelligentsia = {
					is_powerful = yes
					is_in_government = yes
					}
					in_election_campaign = no
				}				

	on_complete = {		
		trigger_event = { id = 03_persia_events.42 }
		set_variable = {
		name = mossadeq_wins_var
		value = yes
			}
		}


	weight = 100

	should_be_pinned_by_default = yes
}

je_british_seek_american_help = {
	icon = "gfx/interface/icons/event_icons/event_fire.dds"
	group = je_group_historical_content
	

	complete = {
		has_law = law_type:law_public_schools
		has_law = law_type:law_public_health_insurance
		OR = {
		has_law = law_type:law_proportional_taxation
		has_law = law_type:law_graduated_taxation
		}
		OR = {
		has_law = law_type:law_wage_subsidies
		has_law = law_type:law_old_age_pension
		}
		OR = {
		has_law = law_type:law_census_voting
		has_law = law_type:law_universal_suffrage
		}		
		OR = {
		has_law = law_type:law_right_of_assembly
		has_law = law_type:law_protected_speech
		}
		
	}

	on_complete = {							
	}
	
	timeout = 330
	
	on_timeout = {
		trigger_event = { id = 03_persia_events.44 }					 
	}

	weight = 100
	
	should_be_pinned_by_default = yes
}

je_babism = {
	icon = "gfx/interface/icons/event_icons/event_protest.dds"
	group = je_group_historical_content
	
	is_shown_when_inactive = {
	exists = c:PER
	this = c:PER
	}
	
	possible = {
	game_date >= 1844.5.22
	}
	
	modifiers_while_active = {
		the_bab_modifier
	}
	
	immediate = {
	trigger_event = { id = 03_persia_events.71 popup = yes }
	random_scope_character = {
		limit = {
			has_template = the_bab_character_template
		}
		save_scope_as = the_bab_scope
		}
		
	}
	
	scripted_button = execute_the_bab_button
	
	on_monthly_pulse = {
		random_events = {
			10 = 0
			2 = 03_persia_events.72 #More Babis
				}
			}
	
	complete = {
	scope:the_bab_scope = {
					is_character_alive = no
				}
	}
	
	on_complete = {	
	
		every_scope_state = {
				limit = {
					any_scope_pop = {
						religion = rel:babism
					}
				}
				add_religion_standard_of_living_modifier = {
					religion = rel:babism
					multiplier = -2
					years = 10
				}
			}
	}
	
	fail = {
	any_scope_state = {
			custom_tooltip = {
				text = is_a_babi_tt
			any_scope_pop = {
				religion = rel:babism
				}
			}
				count >= 10
			
		}	
	}
	
	
	
	on_fail = {	
	trigger_event = { id = 03_persia_events.75 popup = yes } #Babism established
	
	
	#every_scope_state = {
	#convert_population = {
			#	target = rel:babism
			#	value = 0.1
		#	}
		#}
		
		
		
	}
	

	weight = 100
	
	should_be_pinned_by_default = yes
}