﻿################
# PERSIAN EVENTS
################
# By Sean Hughes
##
# EVENT LIST
#  yearly_persian.1001 - Persian New Year
#  yearly_persian.1101 - Persian Nationalism

namespace = yearly_persian

#########################################
# Nowruz, or Persian New Year 			#
# by Sean Hughes 						#
#########################################

# Ping event to ensure the actual Nowruz festival fires just before the vernal equinox.
yearly_persian.1001 = {
	hidden = yes

	trigger = {
		is_landed = yes
		is_available_adult = yes
		culture = { has_cultural_pillar = heritage_iranian }
		NOT = { has_character_flag = had_event_yearly_persian_1002 }
	}

	immediate = {
		random_list = {
			50 = {
				trigger_event = {
					id = yearly_persian.1002
					trigger_on_next_date = 3.20
				}
			}
			50 = {
				trigger_event = {
					id = fp3_yearly.8032
					trigger_on_next_date = 3.18
				}
			}
		}
	}
}

# Actual Nowruz festival event.
yearly_persian.1002 = {
	type = character_event
	title = yearly_persian.1002.t
	desc = yearly_persian.1002.desc
	left_portrait = root
	theme = realm

	trigger = {
		is_available_adult = yes
		culture = { has_cultural_pillar = heritage_iranian }
	}

	weight_multiplier = {
		base = 1

		modifier = {
			add = 1
			has_trait = diligent
		}
		modifier = {
			add = -0.5
			has_trait = lazy
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_yearly_persian_1002
			years = 5
		}
		culture = {
			save_scope_as = iranian # For loc
		}

		# Compile list of affected characters for Option A.
		every_vassal = {
			limit = {
				culture = { has_cultural_pillar = heritage_iranian }
			}
			add_to_list = iranian_characters
		}
		every_courtier = {
			limit = {
				culture = { has_cultural_pillar = heritage_iranian }
			}
			add_to_list = iranian_characters
		}

		# Compile list of affected characters for Option B.
		every_relation = {
			type = friend
			add_to_list = friends_and_neighbors
		}
		every_held_title = {
			limit = {
				tier = tier_county
			}
			every_neighboring_county = {
				limit = {
					holder = {
						NOR = {
							this = root
							is_in_list = friends_and_neighbors
						}
					}
				}
				holder = {
					add_to_list = friends_and_neighbors
				}
			}
		}

		# Compile list of affected characters for Option C.
		every_close_family_member = {
			add_to_list = spouses_and_family
		}
		every_spouse = {
			limit = {
				NOT = { is_in_list = spouses_and_family }
			}
			add_to_list = spouses_and_family
		}
	}

	# Option A: Spend a lot of Gold to gain a lot of Prestige, and a small opinion boost with all Persian vassals/courtiers.
	option = {
		name = yearly_persian.1002.a
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= major_gold_value
			}
		}
		remove_short_term_gold = major_gold_value

		add_prestige = major_prestige_value
		every_in_list = {
			list = iranian_characters
			custom = yearly_persian.1002.every_iranian_character

			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 10
			}
		}

		stress_impact = {
			greedy = major_stress_impact_gain
		}

		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_compassion = 0.20
				ai_greed = -0.20
			}
		}
	}

	# Option B: Gain a subsantial opinion boost with all friends and neighboring rulers.
	option = {
		name = yearly_persian.1002.b
		every_in_list = {
			list = friends_and_neighbors
			custom = yearly_persian.1002.every_friend_and_neighboring_ruler

			add_opinion = {
				modifier = friendliness_opinion
				target = root
				opinion = 25
			}
		}

		stress_impact = {
			shy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 40
			ai_value_modifier = {
				ai_sociability = 0.40
			}
		}
	}
	
	# Option C: Gain a small amount of piety and a substantial opinion boost with spouses and close family.
	option = {
		name = yearly_persian.1002.c

		add_piety = minor_piety_value
		every_close_family_member = {
			custom = yearly_persian.1002.every_spouse_and_close_family_member

			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 25
			}
		}

		ai_chance = {
			base = 40
			ai_value_modifier = {
				ai_zeal = 0.20
				ai_compassion = 0.20
			}
		}
	}

	# Option D: Eschew the festival to focus on work.
	option = {
		name = yearly_persian.1002.d

		add_character_modifier = {
			modifier = all_work_no_play_persian_modifier
			years = 5
		}

		stress_impact = {
			base = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
			diligent = minor_stress_impact_loss
		}

		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_energy = 0.20
				ai_sociability = -0.20
				ai_greed = 0.40
			}
		}
	}
}

#########################################
# Persian Nationalism/Cultural Tolerance#
# by Sean Hughes 						#
#########################################

# Shu'ubiyya, or Persian Nationalism (From the foreign side)
yearly_persian.1101 = {
	type = character_event
	title = yearly_persian.1101.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
                    OR = {
                        dynasty = dynasty:613
                        dynasty = dynasty:1000101748
						dynasty = dynasty:7327
                    }
					culture = { has_cultural_pillar = heritage_turkic }
				}
				desc = yearly_persian.1101.desc.seljuk
			}
			desc = yearly_persian.1101.desc.arabic
		}
		desc = yearly_persian.1101.desc.ending
	}
	theme = realm
	left_portrait = root
	
	trigger = {
		is_ai = no
		highest_held_title_tier >= tier_kingdom
		OR = {
			AND = {
                OR = {
                    dynasty = dynasty:613
                    dynasty = dynasty:1000101748
					dynasty = dynasty:7327
                }
				culture = { has_cultural_pillar = heritage_turkic }
			}
			culture = { has_cultural_pillar = heritage_arabic }
		}
		any_sub_realm_county = {
			percent >= 0.25
			culture = culture:persian
		}
		NOT = {
			has_global_variable = yearly_persian_1101
		}
	}

	weight_multiplier = {
		base = 1

		modifier = {
			add = 1
			any_sub_realm_county = {
				percent >= 0.5
				culture = culture:persian
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = yearly_persian_1101
			value = yes
		}
		culture:persian = {
			save_scope_as = persian # For localiation
		}
	}

	option = {
		name = yearly_persian.1101.a

		every_sub_realm_county = {
			limit = {
				culture = culture:persian
			}
			custom = yearly_persian.1101.every_county

			random = {
				chance = 33

				set_county_culture = root.culture
				add_county_modifier = {
					modifier = county_forced_assimilation_modifier
					years = 50
				}
			}
		}
	}

	option = {
		name = yearly_persian.1101.b.seljuk
		trigger = {
            OR = {
                dynasty = dynasty:613
                dynasty = dynasty:1000101748
				dynasty = dynasty:7327
            }
			culture = { has_cultural_pillar = heritage_turkic }
		}

		set_culture = culture:persian
		every_close_family_member = {
			custom = yearly_persian.1101.every_family
			set_culture = culture:persian
		}
	}
	
	option = {
		name = yearly_persian.1101.c

		root.culture = {
			get_random_innovation_from = culture:persian
		}
		culture:persian = {
			get_random_innovation_from = root.culture
		}

		every_sub_realm_county = {
			limit = {
				culture = culture:persian
			}
			custom = yearly_persian.1101.every_county

			add_county_modifier = {
				modifier = county_shuubiyya_modifier
				years = 50
			}
			custom_tooltip = yearly_persian.1101.c.warning
		}
	}
}
