﻿# Events for the Hajj

namespace = hajj

################################################################################################################################
## Hajj Activity System Events
## 0500
################################
# hajj.0010 - Your capital is now Mecca and you don't have the Hajjaj trait
# hajj.0500 - Promise your dying Hajjaj relative to go on the Hajj
#
#
################################
# Hajj Destination Events
# 3001-3499
################################
# hajj.3010 - Pray at the Place of Abraham
# hajj.3020-1 - Walk between Safa and Marwah
# hajj.3030 - Drink water from the Zamzam well
# hajj.3040 - Sacrifice to Allah
# hajj.3001 - Performing the Halq


################################################################################################################################
## Hajj Activity System Events
## 0500
################################
# hajj.0010 - Your capital is now Mecca and you don't have the Hajjaj trait
# hajj.0500 - Promise your Hajjaj relative to go on the Hajj
#
#

#Hidden event to determine who has Mecca as their capital
hajj.0010 = {
	hidden = yes 
	scope = faith
	trigger = {
		has_doctrine = doctrine_pilgrimage_mandatory_hajj
		any_faith_ruler = {
			is_landed = yes
			capital_province.barony ?= title:b_makka
			NOT = { has_trait = hajjaj }
		}
	}
	immediate = {
		random_faith_ruler = {
			limit = {
				is_landed = yes
				capital_province.barony ?= title:b_makka
				NOT = { has_trait = hajjaj }
			}
			trigger_event = hajj.0011
		}
	}
}

#Your capital is now Mecca and you don't have the Hajjaj trait
hajj.0011 = {
	type = character_event
	title = hajj.0011.t
	desc = hajj.0011.desc
	theme = faith
	override_background = { reference = holy_site_mecca }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = cynical
					any_secret = { type = secret_non_believer }
				}
			}
			animation = boredom
		}
		animation = personality_content
	}
	immediate = {
		add_trait = hajjaj
		#Set up the memory in case we change capital and want to go on a second Hajj
		create_character_memory = { type = completed_hajj_memory }
		scope:new_memory ?= {
			set_variable = {
				name = first_hajj
				value = flag:completed_hajj
			}
			set_variable = {
				name = hajj_destination
				value = title:b_makka.title_province
			}
			if = {
				limit = { exists = var:hajj_destination }
				#To prevent 'unused except in loc' errors :catto:
			}
		}
	}
	#Guess that's done
	option = {
		name = {
			trigger = {
				OR = {
					has_trait = cynical
					any_secret = { type = secret_non_believer }
				}
			}
			text = hajj.0011.a_cynical
		}
		name = hajj.0011.a
		ai_chance = {
			base = 100
		}
	}
}


#Promise your Hajjaj relative to go on the Hajj
hajj.0500 = {
	type = character_event
	title = hajj.0500.t
	desc = hajj.0500.desc
	theme = death
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:hajj_dying_relative
		animation = sick
	}
	cooldown = { years = 10 }
	trigger = {
		any_close_family_member = {
			OR = {
				has_any_good_relationship_with_character_trigger = { CHARACTER = root }
				has_any_best_good_relationship_with_character_trigger = { CHARACTER = root }
				opinion = {
					target = root
					value >= 40
				}
			}
			OR = {
				health <= death_chance_dying_health
				has_trait = incapable
				has_trait = infirm
			}
			OR = {
				AND = {
					has_trait = zealous
					NOT = {
						any_secret = { type = secret_non_believer }
					}
				}
				ai_zeal >= 50
			}
			is_adult = yes
			faith = root.faith
			has_trait = hajjaj
		}
		is_available_healthy_adult = yes
		#Needs to be a mandatory Hajj religion
		faith = { 
			has_doctrine_parameter = mandatory_hajj
			any_holy_site = { this = title:b_makka }
		}
		#This really should take care of most Hajj/Pilgrim-related trigger checks - if you don't have this trait, you really shouldn't have a Hajj cooldown etc
		NOT = { has_trait = hajjaj }
		#Don't want to be standing in the holy site already / have Mecca as our (invalid) capital
		NOR = { 
			root.location.barony = title:b_makka
			capital_province.barony ?= title:b_makka 
		}
		#Only one modifier for _you_
		NOR = {
			has_character_modifier = ghost_pilgrimage_promised_modifier
			has_character_modifier = hajj_promised_modifier
			has_character_modifier = pilgrimage_promised_modifier
		}
	}
	immediate = {
		random_close_family_member = {
			limit = {
				OR = {
					has_any_good_relationship_with_character_trigger = { CHARACTER = root }
					has_any_best_good_relationship_with_character_trigger = { CHARACTER = root }
				}
				OR = {
					health <= death_chance_dying_health
					has_trait = incapable
					has_trait = infirm
				}
				is_adult = yes
				faith = root.faith
				has_trait = hajjaj
			}
			save_scope_as = hajj_dying_relative
		}
		scope:hajj_dying_relative = {
			if = {
				limit = {
					NOT = { has_character_flag = use_sickness_clothes }
				}
				add_character_flag = use_sickness_clothes
			}
		}
	}
	#Hajj it is
	option = {
		name = hajj.0500.a
		scope:hajj_dying_relative = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 15
			}
		}
		custom_tooltip = {
			text = hajj.0500.a.tt_hajj
			add_character_modifier = hajj_promised_modifier
		}
		add_piety = minor_piety_gain
		stress_impact = {
			cynical = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = cynical
				factor = 0
			}
		}
	}
	#Erm... no.
	option = {
		name = hajj.0500.b
		scope:hajj_dying_relative = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -5
			}
		}
		stress_impact = {
			sadistic = medium_stress_impact_loss
			callous = minor_stress_impact_loss
			compassionate = major_stress_impact_gain
			zealous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = compassionate
					has_trait = zealous
				}
				factor = 0
			}
		}
	}
	after = {
		scope:hajj_dying_relative ?= {
			if = {
				limit = {
					has_character_flag = use_sickness_clothes
				}
				remove_character_flag = use_sickness_clothes
			}
		}
	}
}

################################
# Hajj Destination Events
# 3001-3499
################################
# hajj.3010 - Pray at the Place of Abraham
# hajj.3020-1 - Walk between Safa and Marwah
# hajj.3030 - Drink water from the Zamzam well
# hajj.3040 - Sacrifice to Allah
# hajj.3001 - Performing the Halq

#Pray at the Place of Abraham
hajj.3010 = {
	type = activity_event
	title = hajj.3010.t
	desc = hajj.3010.desc
	theme = pilgrimage_destination
	left_portrait = {
		character = root
		animation = thinking
	}
	trigger = {
		exists = scope:activity
	}
	#I should ask for something more substantial...
	option = {
		name = hajj.3010.a
		trigger = {
			#Unnecessary option if we already have the modifiers
			NOT = {
				has_character_modifier = hajj_prayer_wealth_modifier
				has_character_modifier = hajj_prayer_prestige_modifier
				has_character_modifier = hajj_prayer_opinion_modifier
				has_character_modifier = bp1_superstition_modifier
			}
		}
		random_list = {
			10 = {
				trigger = {
					NOT = { has_character_modifier = hajj_prayer_wealth_modifier }
				}
				desc = hajj.3010.a.wealth.desc
				send_interface_toast = {
					title = hajj.3010.a.wealth.t
					left_icon = root
					scope:activity = {
						add_activity_log_entry = {
							key = hajj_destination_prayed_at_abraham_wealth_log
							tags = { destination_event abraham }
							score = 50
							character = scope:host
							#Effects
							root = {
								add_character_modifier = {
									modifier = hajj_prayer_wealth_modifier
									years = 3
								}
							}
						}
					}
				}
			}
			10 = {
				trigger = {
					NOT = { has_character_modifier = hajj_prayer_prestige_modifier }
				}
				desc = hajj.3010.a.prestige.desc
				send_interface_toast = {
					title = hajj.3010.a.prestige.t
					left_icon = root
					scope:activity = {
						add_activity_log_entry = {
							key = hajj_destination_prayed_at_abraham_prestige_log
							tags = { destination_event abraham }
							score = 50
							character = scope:host
							#Effects
							root = {
								add_character_modifier = {
									modifier = hajj_prayer_prestige_modifier
									years = 5
								}
							}
						}
					}
				}
			}
			10 = {
				trigger = {
					NOT = { has_character_modifier = hajj_prayer_opinion_modifier }
				}
				desc = hajj.3010.a.opinion.desc
				send_interface_toast = {
					title = hajj.3010.a.opinion.t
					left_icon = root
					scope:activity = {
						add_activity_log_entry = {
							key = hajj_destination_prayed_at_abraham_opinion_log
							tags = { destination_event abraham }
							score = 50
							character = scope:host
							show_in_conclusion = yes
							#Effects
							root = {
								add_character_modifier = {
									modifier = hajj_prayer_opinion_modifier
									years = 10
								}
							}
						}
					}
				}
			}
			10 = {
				modifier = {
					has_trait = callous
					factor = 0.5
				}
				desc = hajj.3010.a.bad.desc
				send_interface_toast = {
					title = hajj.3010.a.bad.t
					left_icon = root
					if = {
						limit = { has_character_modifier = bp1_superstition_modifier }
						#Get stress
						scope:activity = {
							add_activity_log_entry = {
								key = hajj_destination_prayed_at_abraham_stress_log
								tags = { destination_event abraham }
								score = 50
								character = scope:host
								show_in_conclusion = yes
								#Effects
								root = {
									stress_impact = {
										base = medium_stress_impact_gain
										cynical = medium_stress_impact_loss #To weigh it up
									}
								}
							}
						}
					}
					else = {
						#Get superstition modifier
						scope:activity = {
							add_activity_log_entry = {
								key = hajj_destination_prayed_at_abraham_superstition_log
								tags = { destination_event abraham }
								score = 50
								character = scope:host
								show_in_conclusion = yes
								#Effects
								root = {
									add_character_modifier = {
										modifier = bp1_superstition_modifier
										years = 10
									}
								}
							}
						}
					}
				}
			}
		}
		stress_impact = {
			zealous = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = zealous
					has_trait = humble
				}
				factor = 0
			}
		}
	}
	#One standard prayer, coming up
	option = {
		name = hajj.3010.b
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { has_trait = cynical }
					desc = hajj.3010.b.flavor_cynical
				}
			}
		}
		pious_type_option_effect = yes
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_prayed_at_abraham_log
				tags = { destination_event abraham }
				score = 50
				character = scope:host
				show_in_conclusion = yes
				#Effects
				root = {
					add_piety = minor_piety_gain
				}
			}
		}
		ai_chance = {
			base = 100
		}
	}
	after = {
		trigger_event = {
			#Walk between Safa and Marwah
			id = hajj.3020
			days = 15
		}
	}
}

scripted_effect 3020_hajj_penalization_effect = {
	add_piety = minor_piety_loss
	add_character_modifier = {
		modifier = hajj_caught_on_safa_modifier
		years = 1
	}
}

#Walk between Safa and Marwah
hajj.3020 = {
	type = activity_event
	title = hajj.3020.t
	desc = hajj.3020.desc
	theme = pilgrimage_destination
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = athletic }
			animation = ecstasy
		}
		triggered_animation = {
			trigger = { has_trait = lazy }
			animation = boredom
		}
		animation = personality_forgiving
	}
	trigger = {
		exists = scope:activity
	}
	#PUSH IT TO THE LIMIT
	option = {
		name = hajj.3020.a
		trigger = { has_trait = athletic }
		pious_type_option_effect = yes
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_safa_marwah_athletic_log
				tags = { destination_event safa }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = {
					add_character_modifier = {
						modifier = hajj_pushed_the_marwah_modifier
						years = 1
					}
					add_piety = medium_piety_gain
				}
			}
		}
		stress_impact = {
			athletic = medium_stress_impact_loss
			lazy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
		}
	}
	#7 times, coming up
	option = {
		name = hajj.3020.b
		pious_type_option_effect = yes
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_safa_marwah_log
				tags = { destination_event safa }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = {
					add_piety = minor_piety_gain
				}
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_loss #To weigh up the lazy gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = athletic
					has_trait = lazy
				}
				factor = 0
			}
		}
	}
	#Will anyone notice if I just do 4?
	option = {
		name = hajj.3020.c
		trigger = { has_trait = lazy }
		duel = {
			skill = intrigue
			value = medium_skill_rating
			#Skimping success
			60 = {
				desc = hajj.3020.c.success.desc
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 5
				}
				send_interface_toast = {
					title = hajj.3020.c.success.t
					left_icon = root
					scope:activity = {
						add_activity_log_entry = {
							key = hajj_destination_safa_marwah_lazy_log
							tags = { destination_event safa }
							score = 50
							character = root
							show_in_conclusion = yes
							#Effects
							root = {
								add_character_modifier = {
									modifier = hajj_skimp_on_safa_modifier
									years = 1
								}
								add_piety = miniscule_piety_loss
							}
						}
					}
				}
			}
			#Skimping caught!
			40 = {
				desc = hajj.3020.c.failure.desc
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 5
				}
				show_as_tooltip = { 3020_hajj_penalization_effect = yes }
				#Penalty event
				trigger_event = hajj.3021
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_gain
			athletic = medium_stress_impact_gain
			lazy = medium_stress_impact_loss
		}
		ai_chance = {
			base = 50
		}
	}
	after = {
		trigger_event = {
			#Drink water from the Zamzam well
			id = hajj.3030
			days = 15
		}
	}
}

#Safa and Marwah penalization
hajj.3021 = {
	type = activity_event
	title = hajj.3021.t
	desc = hajj.3021.desc
	theme = pilgrimage_destination
	left_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:penalizer
		animation = disapproval
	}
	immediate = {
		create_character = {
			template = priest_character_template
			dynasty = none
			location = root.location
			culture = root.location.culture
			faith = root.faith
			save_scope_as = penalizer
		}
		3020_hajj_penalization_effect = yes
	}
	trigger = {
		exists = scope:activity
	}
	#Damm... I guess
	option = {
		name = hajj.3021.a
		flavor = hajj.3021.a.flavor
		remove_short_term_gold = minor_gold_value
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_damm_log
				tags = { destination_event penalized damm }
				score = 50
				character = root

				#Effects
				root = {
					add_piety = medium_piety_gain
				}
			}
		}
		stress_impact = {
			zealous = medium_stress_impact_loss
			compassionate = minor_stress_impact_gain
			sadistic = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = compassionate
				factor = 0
			}
		}
	}
	#Sadaqah al-Fitr, hm
	option = {
		name = hajj.3021.b
		flavor = hajj.3021.b.flavor
		remove_short_term_gold = tiny_gold_value
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_sadaqah_alfitr_log
				tags = { destination_event penalized sadaqah }
				score = 50
				character = root

				#Effects
				root = {
					add_piety = minor_piety_gain
				}
			}
		}
		stress_impact = {
			zealous = medium_stress_impact_loss
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#Just do the laps properly
	option = {
		name = hajj.3021.c
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { has_trait = zealous }
					desc = hajj.3021.c.flavor_zealous
				}
				desc = hajj.3021.c.flavor
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_safa_marwah_log
				tags = { destination_event safa }
				score = 50
				character = root

				#No effects, you had your chance
			}
		}
		stress_impact = {
			humble = minor_stress_impact_loss
			zealous = minor_stress_impact_loss #To weigh up the lazy gain
			lazy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	after = {
		scope:penalizer = { silent_disappearance_effect = yes }
	}
}

#Drink water from the Zamzam well
hajj.3030 = {
	type = activity_event
	title = hajj.3030.t
	desc = hajj.3030.desc #Quenching the Soul
	theme = pilgrimage_destination
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_perk = wash_your_hands_perk
				NOT = { has_perk = healthy_perk }
				learning >= medium_skill_rating
			}
			animation = worry
		}
		animation = personality_honorable
	}
	trigger = {
		exists = scope:activity
	}
	#Let the feeble go first
	option = {
		name = hajj.3030.a
		trigger = {
			OR = {
				has_trait = calm
				has_trait = patient
				has_trait = compassionate
			}
		}
		pious_type_option_effect = yes
		flavor = hajj.3030.a.flavor
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_zamzam_well_compassionate_log
				tags = { destination_event zamzam }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = { 
					add_piety = medium_piety_gain 
					add_prestige = miniscule_prestige_loss
				}
			}
		}
		stress_impact = {
			impatient = minor_stress_impact_gain
			arrogant = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = impatient
				}
				factor = 0
			}
		}
	}
	#One standard drink, coming up
	option = {
		name = hajj.3030.b
		flavor = hajj.3030.b.flavor
		pious_type_option_effect = yes
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_zamzam_well_log
				tags = { destination_event zamzam }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = { add_piety = minor_piety_gain }
			}
		}
		if = {
			limit = { 
				has_perk = wash_your_hands_perk
				NOT = { has_perk = healthy_perk }
				learning >= medium_skill_rating 
			}
			stress_impact = {
				craven = minor_stress_impact_gain
				paranoid = medium_stress_impact_gain
			}
		}
		else = {
			#Ignorance is bliss
		}
		ai_chance = {
			base = 100
		}
	}
	#This... hardly seems hygienic
	option = {
		name = hajj.3030.c
		trigger = {
			has_perk = wash_your_hands_perk
			NOT = { has_perk = healthy_perk }
			learning >= medium_skill_rating
		}
		flavor = hajj.3030.c.flavor
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_zamzam_well_abstained_log
				tags = { destination_event zamzam }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = {
					add_piety = minor_piety_loss
					if = {
						limit = { 
							has_character_modifier = hajj_hygienic_modifier
							has_lifestyle = learning_lifestyle
						}
						add_learning_lifestyle_xp = medium_lifestyle_xp
					}
					#If you for some reason went on a Hajj again within the 5 years since getting the Hygienic modifier and don't have the learning lifestyle, let's throw them a bone
					else_if = {
						limit = {
							has_character_modifier = hajj_hygienic_modifier
							NOT = { 
								has_lifestyle = learning_lifestyle
								has_perk = iron_constitution_perk
							}
						}
						random = {
							chance = {
								value = 5
								add = {
									value = health
									multiply = -2.5
								}
							}
							add_perk = iron_constitution_perk
						}
					}
					#... and if you _seriously_ went on Hajj again the next year...
					else_if = {
						limit = {
							has_character_modifier = hajj_hygienic_modifier
							has_perk = iron_constitution_perk
							NOT = { 
								has_lifestyle = learning_lifestyle
								has_perk = healthy_perk
							}
						}
						random = {
							chance = {
								value = 5
								add = {
									value = health
									multiply = -2.5
								}
							}
							add_perk = healthy_perk
						}
					}
					else = {
						add_character_modifier = {
							modifier = hajj_hygienic_modifier
							years = 5
						}
					}
				}
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_gain
			craven = minor_stress_impact_loss
			paranoid = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}
	after = {
		trigger_event = {
			#Sacrifice to Allah
			id = hajj.3040
			days = 15
		}
	}
}

#Sacrifice to Allah
hajj.3040 = {
	type = activity_event
	title = hajj.3040.t
	desc = hajj.3040.desc
	theme = pilgrimage_destination
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = { 
					has_trait = cynical
					any_secret = { type = secret_non_believer }
				}
			}
			animation = personality_callous
		}
		animation = personality_compassionate
	}
	trigger = {
		exists = scope:activity
	}
	immediate = { save_scope_as = root_scope }
	#Sacrifice 63 camels (like Prophet Muhammad)
	option = {
		name = hajj.3040.a
		trigger = {
			#Once in a lifetime
			NOT = { has_character_modifier = hajj_prophet_like_modifier }
		}
		flavor = hajj.3040.a.flavor
		#This is _massive_
		very_pious_type_option_effect = yes
		remove_short_term_gold = massive_gold_value
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_prophet_like_sacrifice_log
				tags = { destination_event sacrifice }
				score = 75
				character = root
				show_in_conclusion = yes
				#Effects
				root = {
					add_piety = major_piety_gain
					add_prestige = major_prestige_gain
					dynasty = { add_dynasty_prestige = medium_dynasty_prestige_gain }
					add_character_modifier = hajj_prophet_like_modifier
				}
			}
		}
		#This also deserves a memory
		create_character_memory = {
			type = hajj_prophet_like_sacrifice_memory
		}
		if = {
			limit = { exists = scope:new_memory }
			scope:new_memory = {
				set_variable = {
					name = memory_location
					value = scope:activity.activity_location
				}
				if = {
					limit = { exists = var:memory_location }
					#To prevent 'unused except in loc' errors :catto:
				}
			}
		}
		stress_impact = {
			zealous = major_stress_impact_loss
			greedy = medium_stress_impact_gain
			sadistic = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				NAND = {
					has_trait = zealous
					short_term_gold > massive_gold_value
				}
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#Sacrifice a camel
	option = {
		name = hajj.3040.b
		flavor = hajj.3040.b.flavor
		pious_type_option_effect = yes
		remove_short_term_gold = medium_gold_value
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_sacrifice_camel_log
				tags = { destination_event sacrifice }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = {
					add_piety = medium_piety_gain
					add_prestige = minor_prestige_gain
					if = {
						limit = { has_character_modifier = hajj_camel_knowledge_modifier }
						every_vassal_or_below = {
							vassal_stance = zealot
							custom = every_zealot_vassal
							add_opinion = {
								modifier = humored_opinion
								target = root
								opinion = 15
							}
						}
					}
					else = {
						add_character_modifier = {
							modifier = hajj_camel_knowledge_modifier
							years = 10
						}
					}
				}
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_loss
			greedy = minor_stress_impact_gain
			sadistic = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				NAND = {
					has_trait = zealous
					short_term_gold > medium_gold_value
				}
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#Sacrifice a sheep
	option = {
		name = hajj.3040.c
		flavor = hajj.3040.c.flavor
		pious_type_option_effect = yes
		remove_short_term_gold = minor_gold_value
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_sacrifice_to_allah_log
				tags = { destination_event sacrifice }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = {
					add_piety = minor_piety_gain
				}
			}
		}
		stress_impact = {
			greedy = miniscule_stress_impact_gain
			sadistic = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < minor_gold_value
				factor = 0
			}
		}
	}
	#Partake in someone else's cow sacrifice
	option = {
		name = hajj.3040.d
		flavor = hajj.3040.d.flavor
		remove_short_term_gold = tiny_gold_value
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_destination_sacrifice_cow_log
				tags = { destination_event sacrifice }
				score = 50
				character = root
				show_in_conclusion = yes
				#Effects
				root = {
					add_piety = miniscule_piety_gain
					add_prestige = miniscule_prestige_loss
				}
			}
		}
		stress_impact = {
			zealous = miniscule_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}
	after = {
		trigger_event = {
			#Perform the Halq
			id = hajj.3001
			days = 10
		}
	}
}

#Performing the Halq
hajj.3001 = {
	type = activity_event
	title = hajj.3001.t
	desc = { 
		desc = hajj.3001.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine = doctrine_gender_male_dominated }
				}
				desc = hajj.3001.desc.male_dominated
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine = doctrine_gender_female_dominated }
				}
				desc = hajj.3001.desc.female_dominated
			}
			#Equality fallback, though the text works generically too.
			desc = hajj.3001.desc.equal
		}
	}
	trigger = {
		exists = scope:activity
	}
	theme = pilgrimage_destination
	left_portrait = {
		character = root
		animation = ecstasy
	}
	#Shave it all off!
	option = {
		name = hajj.3001.a
		#Must be equal or dominant gendered
		trigger = {
			OR = {
				AND = {
					faith = { has_doctrine = doctrine_gender_male_dominated }
					is_male = yes
				}
				AND = {
					faith = { has_doctrine = doctrine_gender_female_dominated }
					is_female = yes
				}
				faith = { has_doctrine = doctrine_gender_equal }
			}
		}
		pious_type_option_effect = yes
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_arrived_shaved_log
				tags = { arrived halq }
				score = 50
				character = root
				scope:host = {
					add_character_modifier = {
						modifier = hajj_halq_modifier
						months = 6
					}
				}
				show_in_conclusion = yes
			}
		}
		stress_impact = {
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			beauty_good_1 = minor_stress_impact_gain
			beauty_good_2 = minor_stress_impact_gain
			beauty_good_3 = minor_stress_impact_gain

			humble = minor_stress_impact_loss #Yes, we actually do want loss here.
		}
		ai_chance = {
			base = 100
		}
	}
	#Cut just a lock of hair
	option = {
		name = hajj.3001.b
		scope:activity = {
			add_activity_log_entry = {
				key = hajj_arrived_not_shaved_log
				tags = { arrived halq }
				score = 50
				character = root
				scope:host = {
					if = {
						limit = {
							faith = { has_doctrine = doctrine_gender_male_dominated }
							is_female = yes
						}
						add_piety = miniscule_piety_gain
					}
					else_if = {
						limit = {
							faith = { has_doctrine = doctrine_gender_female_dominated }
							is_male = yes
						}
						add_piety = miniscule_piety_gain
					}
					else = {
						add_piety = minor_piety_loss
					}
				}
				show_in_conclusion = yes
			}
		}
		stress_impact = {
			zealous = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}
	after = {
		scope:activity = { progress_activity_phase_after = { weeks = 1 } }
	}
}
