########################################
# Flavor Events for Timurid
#
# written by Sara Wendel-rtqvist
# Events rewritten and adapted for patch 1.22 by Henrik Lohmander
########################################

namespace = flavor_tim
normal_or_historical_nations = yes

# Muhammad Baysonqor's Rebellion
country_event = {
	id = flavor_tim.0
	title = "flavor_tim.0.t"
	desc = "flavor_tim.0.d"
	picture = OVEREXTENSION_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = TIM
		exists = QOM
		has_ruler = "Shah Rukh"
	}

	mean_time_to_happen = {
		months = 1
	}
	
	option = { 
		name = "flavor_tim.0.a" #
		custom_tooltip = flavor_tim.0.a.tt
		
		hidden_effect = {
			every_country = {
				limit = {
					NOT = { tag = ROOT }
					OR = {
						is_neighbor_of = ROOT
						dynasty = Timurid
						any_owned_province = {
							is_core = TIM
						}
						any_neighbor_country = {
							dynasty = Timurid
						}
					}
				}
				country_event = { id = flavor_tim.4 }
			}
		}
	}
}

# Death of Shah Rukh
country_event = {
	id = flavor_tim.1
	title = "flavor_tim.1.t"
	desc = "flavor_tim.1.d"
	picture = DEATH_OF_HEIR_eventPicture
	
	is_triggered_only = yes
	fire_only_once = yes
	
	trigger = {
		tag = TIM
		NOT = { has_global_flag = death_of_shah_rukh }
	}

	mean_time_to_happen = {
		days = 1
	}
	
	immediate = { set_global_flag = death_of_shah_rukh }
	
	option = { 
		name = "flavor_tim.1.a" # My time has come!
		custom_tooltip = flavor_tim.1.a.tt
		hidden_effect = {

		KHO = {
			add_opinion = { who = TIM modifier = wants_independence }
			
		}
		TRS = {
			add_opinion = { who = TIM modifier = wants_independence }
			
		}
		AFG = {
			add_opinion = { who = TIM modifier = wants_independence }
			
		}
		SIS = {
			add_opinion = { who = TIM modifier = wants_independence }
			
		}
		FRS = {
			add_opinion = { who = TIM modifier = wants_independence }
			
		}
		
			every_country = {
				limit = {
					NOT = { tag = ROOT }
					OR = {
						is_neighbor_of = ROOT
						dynasty = Timurid
						any_owned_province = {
							is_core = TIM
						}
						any_neighbor_country = {
							dynasty = Timurid
						}
					}
				}
				country_event = { id = flavor_tim.2 }
			}
		}
	}
}

# Death of Shah Rukh
country_event = {
	id = flavor_tim.2
	title = "flavor_tim.2.t"
	desc = "flavor_tim.2.d"
	picture = DEATH_OF_HEIR_eventPicture
	
	is_triggered_only = yes

	option = {
		name = "flavor_tim.2.a" # My time has come!
		trigger = { dynasty = Timurid }
		custom_tooltip = flavor_tim.2.a.tt
	}
	option = {
		name = "flavor_tim.2.b" #
		trigger = { NOT = { dynasty = Timurid } }
		custom_tooltip = flavor_tim.2.a.tt
		if = {
			limit = {
				NOT = { dynasty = "Timurid" }
				government = monarchy
				NOT = { tag = HLR }
				NOT = { tag = ROM }
				NOT = { tag = MUG }
				NOT = { tag = PER }
				OR = {
					culture_group = iranian
					primary_culture = uzbehk
					primary_culture = turkmeni
				}
				NOT = { primary_culture = azerbaijani }
				NOT = { has_reform = tribal_federation }
				religion_group = muslim
			}
		custom_tooltip = flavor_tim.2.b.tt
		}
	}
}

# Ismail's Resurrection of Persia
# Removed as the Safavids are in control of a tag in Ardabil from 1.22.
# country_event = {
	# id = flavor_tim.2
	# title = "flavor_tim.EVTNAME2"
	# desc = "flavor_tim.EVTDESC2"
	# picture = ANGRY_MOB_eventPicture
	
	# fire_only_once = yes
	
	# trigger = {
		# tag = TIM
		# any_owned_province = { is_core = PER }
		# NOT = { exists = PER }
		# NOT = { is_year = 1550 }
	# }

	# mean_time_to_happen = {
		# months = 2000
	# }
	
	# option = {
		# name = "flavor_tim.EVTOPTA2" # Crush the Shiite rebels
		# every_owned_province = {
			# limit = { is_core = PER }
			# add_province_modifier = {
				# name = add_unrest_10_modifier
				# duration = 1825
			# }
		# }
	# }
# }

# Ulugh Beg's Observatory
country_event = {
	id = flavor_tim.3
	title = "flavor_tim.EVTNAME3"
	desc = "flavor_tim.EVTDESC3"
	picture = UNIVERSITY_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			tag = TRS
			tag = TIM
		}
		has_ruler = "Ulugh Beg"
		NOT = { is_year = 1465 }
	}

	mean_time_to_happen = {
		months = 63
	}
	
	option = {
		name = "flavor_tim.EVTOPTA3" # Build it!
		add_years_of_income = -1
		add_dip_power = 50
		add_mil_power = 50
		add_adm_power = 50
		add_innovativeness_big_effect = yes
	}
	option = {
		name = "flavor_tim.EVTOPTB3" # We don't have the time or the money for such foolishness!
		add_prestige = -5
	}
}

country_event = {
	id = flavor_tim.4
	title = "flavor_tim.0.t"
	desc = "flavor_tim.0.d"
	picture = OVEREXTENSION_eventPicture
	
	is_triggered_only = yes
	
	option = { 
		name = "flavor_tim.0.a" # My time has come!
		custom_tooltip = flavor_tim.0.a.tt
	}
}
