﻿### EK NOTE: removed vanilla references and added some of our stuff
# On actions for the Pilgrimage activity

# On-action managing possible Pilgrimage journey events
pilgrimage_journey_events = {
	trigger = {
		involved_activity ?= {
			has_activity_type = activity_pilgrimage
			#EK DISABLED no hajj
			#NOT = {
			#	has_activity_option = {
			#		category = special_type
			#		option = pilgrimage_type_hajj
			#	}
			#}
		}
		#We should only get pilgrimage events on our way TO the pilgrimage destination
		is_on_a_pilgrimage_trigger = yes
		NOR = { 
			has_character_flag = in_pilgrimage_event_chain
			has_character_flag = pilgrimage_dealing_with_invalidation
		} 
		#Barons don't need pilgrimage events - to avoid them bloating their court when getting add_courtier events
		highest_held_title_tier >= tier_county
	}

	on_actions = {
		pilgrimage_travel_events
	}
	#EK ADDITION: added guaranteed events if you cross certain poi that aren't quite holy sites
	events = {
		ek_pilgrimage.0005 # The Pilgrim's Path: Humility
		ek_pilgrimage.0011 # The Pilgrim's Path: Valor
		ek_pilgrimage.0013 # The Pilgrim's Path: Pride
	}
	#EK ADDITION END
}

# On-action managing possible Hajj journey events
hajj_journey_events = {
	trigger = {
		always = no
		#EK DISABLED no hajj
		#involved_activity ?= { 
		#	has_activity_type = activity_pilgrimage
		#	has_activity_option = {
		#		category = special_type
		#		option = pilgrimage_type_hajj
		#	}
		#}
		#We should only get pilgrimage events on our way TO the pilgrimage destination
		#is_on_a_hajj_trigger = yes
		#NOT = { has_character_flag = in_pilgrimage_event_chain }
	}

	on_actions = {
		pilgrimage_travel_events
	}
}

### EK EDIT: Disabled the religion specific events
### EK TODO: Add our own
pilgrimage_travel_events = {
	random_events = {
		chance_of_no_event = {
			value = 50
		}
		100 = 0
		# Generic Pilgrimage Events
		50 = pilgrimage.1110 # Heathen Raiders
		150 = pilgrimage.1120 # Tour Church
		100 = pilgrimage.1130 # Roadside Shrine
		50 = pilgrimage.1140 # Strength in Numbers
		100 = pilgrimage.2002 # Heathen-hating adherent challenges you
		100 = pilgrimage.2003 # Companions are running low
		100 = pilgrimage.2004 # Run into a potential friend
		100 = pilgrimage.2005 # A peasant inadvertedly insults you
		100 = pilgrimage.2006 # You have gotten lost
		25 = pilgrimage.2010 # Meet a Mystic (chain)
		50 = pilgrimage.2020 # Pilgrimage thieves
		# Sea Generic Pilgrimage Events Events
		50 = pilgrimage.1100 # Saint Elmo's Fire
		50 = pilgrimage.2030 # Massive rainbow
		50 = pilgrimage.2040 # Go fish
		50 = pilgrimage.2050 # Shipwrecked pilgrims
		# BP1 Events 
		50 = pilgrimage.6001 #Sneaking off to a tavern with your pal
		#EK ADDITION: ek events
		100 = ek_pilgrimage.1019 # Spirited Away
		500 = ek_pilgrimage.1022 # On the Matter of Mountains
		
		#Intent Events
		50 = pilgrimage_intent.1110 #Sea: Sea legs
		#Altruism
		50 = tour_travel.1004 # You decide to wash the feet of locals
		50 = devaraja.0001	  # Mandala equivalent of royal touch
		50 = tour_travel.1005 # Locals beg for your royal touch
		50 = tour_travel.1006 # Distribute alms in front of a temple
		#Zealot
		50 = pilgrimage_intent.1000 # Console a local
		50 = pilgrimage_intent.1001 # Convert a child
		50 = pilgrimage_intent.1010 # Local courtier is passing by, convert them and bring them on your pilgrimage!
		50 = pilgrimage_intent.1020 # Fellow pilgrims of a different faith are on your path
		100 = pilgrimage_intent.9000 # A local heathen is smitten with one of your entourage members and asks to marry them
		#Reflection
		50 = pilgrimage_intent.1030 # You see a particularly calm clearing along your way and stop to meditate
		50 = pilgrimage_intent.1040 # You spot an animal, follow it for an omen?
		50 = pilgrimage_intent.1050 # You contemplate the brevity of life
		50 = pilgrimage_intent.1060 # You contemplate old empires
		100 = pilgrimage_intent.1100 # Personal reflections
		
		# 'Temptation' Events
		50 = pilgrimage.2101 # Rakish or Lustful character considers making a pit stop, or perhaps, a detour to the local brothels
		50 = pilgrimage.2501 # Persistent Beggar
		50 = pilgrimage.2511 # Cocky Lordling
		
		#EK DISABLED: disabled vanilla specific events
		# Christian-specific Pilgrimage Events
		#100 = pilgrimage.3001 # Zealous priest giving sermon in freezing rains
		#5 = pilgrimage.3002  # Naked preacher claims to have recovered Adam & Eve's innocence
		#100 = pilgrimage.3004 # Doomsayer promises the end is nigh!

		# Muslim-specific Pilgrimage Events
		#100 = pilgrimage.3102 # Ziyarat - Why am I taking this pilgrimage?

		### EK NOTE: 3202 can also use Sanctity of Nature, and can also serve with other terrain-related tenets
		# Hindu-specific Pilgrimage Events
		#100 = pilgrimage.3201 # Ritual purification in a river
		100 = pilgrimage.3202 # Contemplating the universe

		# Buddhist-specific Pilgrimage Events
		#100 = pilgrimage.3301 # Critical Wanderer
		#100 = pilgrimage.3302 # The Wisdom of Goats
		#100 = pilgrimage.3303 # Kalama Sutta

		#Dharmic-specific Pilgrimage Events
		#100 = pilgrimage.3401 # Brahmacharya Challenged
		
		#EK DISABLED: removed all but one event
		# South-East Asia
		# Ocean Events
		#100 = pilgrimage_seasia.100 # The Pearl Diver
		#100 = pilgrimage_seasia.200 # Mangrove Spirits
		600 = pilgrimage_seasia.300 # Good Omen - Calm Oceans
		#100 = pilgrimage_seasia.400 # Floating Shrine
		#100 = pilgrimage_seasia.500 # The Great Raja!
		#100 = pilgrimage_seasia.600 # An Offering of Rice
		#100 = pilgrimage_seasia.700 # The Naga's Victim
		#100 = pilgrimage_seasia.800 # Shadows in the Water
		#100 = pilgrimage_seasia.900 # Sampan Pirates
		#100 = pilgrimage_seasia.1000 # Traders of Tanah Makkah
		# Land Events
		#100 = pilgrimage_seasia.1100 # Rattan Snare
		#100 = pilgrimage_seasia.1200 # A Wanderer from Nalanda
		#100 = pilgrimage_seasia.1300 # The Croaking Pool
		#100 = pilgrimage_seasia.1400 # Face of a God
		#100 = pilgrimage_seasia.1500 # The Pawang
		
		###EK ADDITION:: new pilgrimage events
		# Tribunal-specific Pilgrimage Events
		100 = ek_pilgrimage.0001 # Sermon Reading
		100 = ek_pilgrimage.0003 # The Bloodstone Shrine
		100 = ek_pilgrimage.0014 # Rilms' Grace
		100 = ek_pilgrimage.0015 # Aralor's Intervention
		100 = ek_pilgrimage.0016 # Felm's Glory
		100 = ek_pilgrimage.0017 # Rock of Llothis
		100 = ek_pilgrimage.0022 # The Immolation of Anequina

		# Divines-specific Pilgrimage Events
		100 = ek_pilgrimage.0002 # Wisdom of the Ages
		100 = ek_pilgrimage.1018 # The Sword of the Crusader
		
		# Aedra-specific Pilgrimage Events
		100 = ek_pilgrimage.1025 # The Apprentices' God
	}
}

# On-action managing possible destination arrival events
pilgrimage_arrival_events = {
	first_valid_on_action = {
		db_specific_arrival_events #DB ADDITION: added our own
		ek_specific_arrival_events #EK ADDITION: added our own
		burial_arrival_events
		#EK TODO: check if these can be repurposed, disabled some for now
		#hajj_arrival_events
		#christian_arrival_events
		#jewish_arrival_events
		#muslim_arrival_events
		#hindu_arrival_events
		#buddhist_arrival_events
		#jain_arrival_events
		#zoroastrian_arrival_events
		#norse_arrival_events
		#tengri_arrival_events
		pagan_arrival_events
		pilgrimage_generic_arrival_events
	}
	effect = {
		if = {
			limit = { has_character_flag = pilgrim_group_joined }
			send_interface_toast = {
				type = event_toast_effect_good
				title = grateful_pilgrims_title
				left_icon = scope:group_leader
				current_travel_plan = {
					remove_travel_plan_modifier = pilgrim_group_joined_modifier
					if = {
						limit = {
							any_entourage_character = { has_character_flag = peasant_pilgrim_leader }
						}
						every_entourage_character = {
							limit = { has_character_flag = peasant_pilgrim_leader }
							remove_character_flag = peasant_pilgrim_leader
							add_trait = pilgrim
							save_scope_as = group_leader
						}
						remove_character = scope:group_leader
					}
				}
			}
		}
	}
}

burial_arrival_events = {
	trigger = { has_variable = pilgrimage_death_bury_there }
	random_events = {
		100 = pilgrimage.4020
	}
}
#EK DISABLED: commented out vanilla references
# hajj_arrival_events = {
# 	trigger = {
# 		involved_activity = {
# 			has_activity_option = {
# 				category = special_type
# 				option = pilgrimage_type_hajj
# 			}
# 		}
# 		involved_activity.activity_location.county = title:c_mecca
# 	}
# 	random_events = {
# 		100 = hajj.3001
# 		20 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# christian_arrival_events = {
# 	trigger = {
# 		religion = religion:christianity_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_roma # Rome
# 				county = title:c_jerusalem # Jerusalem
# 				county = title:c_byzantion # Constantinople
# 				county = title:c_alexandria # Alexandria
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5001 # Rome
# 		100 = pilgrimage.5011 # Jerusalem
# 		100 = pilgrimage.5021 # Constantinople
# 		100 = pilgrimage.5031 # Alexandria
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# jewish_arrival_events = {
# 	trigger = {
# 		religion = religion:judaism_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_sinai # Mt. Sinai
# 				county = title:c_jerusalem # Jerusalem
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5011 # Jerusalem
# 		100 = pilgrimage.5101 # Mt. Sinai
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# muslim_arrival_events = {
# 	trigger = {
# 		religion = religion:islam_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_medina # Medina
# 				county = title:c_sinai # Mt. Sinai
# 				county = title:c_jerusalem # Jerusalem
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5011 # Jerusalem
# 		100 = pilgrimage.5101 # Mt. Sinai
# 		100 = pilgrimage.5201 # Medina
# 		# Mecca is handled separately as part of the Hajj
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# hindu_arrival_events = {
# 	trigger = {
# 		religion = religion:hinduism_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_varanasi # Varanasi
# 				county = title:c_ayodhya # Ayodhya
# 				county = title:c_mathura # Mathura
# 				county = title:c_sthanisvara # Haridwar
# 				county = title:c_kanchipuram # Kanchipuram
# 				county = title:c_ujjayini # Ujjayini
# 				county = title:c_dvaraka # Dwarka
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5301 # Varanasi
# 		100 = pilgrimage.5311 # Ayodhya
# 		100 = pilgrimage.5321 # Mathura
# 		100 = pilgrimage.5331 # Haridwar
# 		100 = pilgrimage.5341 # Kanchipuram
# 		100 = pilgrimage.5351 # Ujjayini
# 		100 = pilgrimage.5361 # Dwarka
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# buddhist_arrival_events = {
# 	trigger = {
# 		religion = religion:buddhism_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_gaya # Bodh Gaya
# 				county = title:c_kusinagara # Kusinagara
# 				county = title:c_varanasi # Sarnath
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5401 # Bodh Gaya
# 		100 = pilgrimage.5411 # Kusinagara
# 		100 = pilgrimage.5421 # Sarnath
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# jain_arrival_events = {
# 	trigger = {
# 		religion = religion:jainism_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_radha # Shikharj
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5501 # Shikharj
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# zoroastrian_arrival_events = {
# 	trigger = {
# 		religion = religion:zoroastrianism_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_baduspan # Ushi-darena
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5601 # Ushi-darena
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# norse_arrival_events = {
# 	trigger = {
# 		religion = religion:germanic_religion
# 		involved_activity.activity_location = {
# 			OR = {
# 				county = title:c_brunswick # Paderborn
# 			}
# 		}
# 	}

# 	random_events = {
# 		100 = pilgrimage.5901 # Paderborn
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

# tengri_arrival_events = {
# 	trigger = {
# 		religion = religion:tengrism_religion
# 	}

# 	random_events = {
# 		100 = pilgrimage.5911 # Blue Open Skies
# 		100 = pilgrimage.4002 # Meet the Mystic again
# 	}
# }

pagan_arrival_events = {
	trigger = {
		faith = {
			has_doctrine = tenet_sanctity_of_nature
		}
	}

	random_events = {
		100 = pilgrimage.5921 # Sacred Grove
		100 = pilgrimage.4002 # Meet the Mystic again
	}
}

pilgrimage_generic_arrival_events = {
	random_events = {
		100 = pilgrimage.4001
		100 = pilgrimage.4002
	}
}

db_specific_arrival_events = {
	trigger = {
 		scope:activity.activity_location.county = title:c_ivarstead
 	}
	random_events = {
		100 = db_pilgrimage.1001
	}
}

#Events that happen while remaining on-site
pilgrimage_destination_events = {
	trigger = {
		location = scope:activity.activity_location
	}

	random_events = {
		100 = 0
		120 = pilgrimage.6500 #Appreciation
		100 = pilgrimage.6510 #Lost in Translation
		100 = pilgrimage.6520 #Time To Go Home Soon?
		50 = pilgrimage.6530 #Fishy local guide?
		100 = pilgrimage.6540 #Find some exotic wares
		150 = pilgrimage.6750 #Repentance - remove secret/coping trait
		120 = pilgrimage.6760 #The Disputation of GetCurrentLocation
		100 = pilgrimage.6770 #Buy a relic
		100 = pilgrimage.6780 #Recruit local expert
		120 = pilgrimage.6790 #Spiritual mentor changes your ways
		100 = pilgrimage.6800 #An entourage member feels a religious calling
		100 = pilgrimage.6810 #Do you wanna buy an indulgence?
		120 = pilgrimage.6820 #Buy a pilgrims' guide
		150 = pilgrimage.6830 #Reflect on an empty temple
		100 = pilgrimage.6840 #Ask local priest to bless your artifact
		100 = pilgrimage.6850 #A Master Thief
		#100 = pilgrimage.5445 #Dharmic Parikrama (circumambulation)
		
		#EK ADDITIONS
		1000 = ek_pilgrimage.0006 # The Pilgrim's Path: Daring
		1000 = ek_pilgrimage.0007 # The Pilgrim's Path: Generosity
		1000 = ek_pilgrimage.0008 # The Pilgrim's Path: Courtesy
		1000 = ek_pilgrimage.0010 # The Pilgrim's Path: Justice
		1000 = ek_pilgrimage.0018 # meet vivec?
		1000 = ek_pilgrimage.0023 # Take My Breath Away
		100 = ek_pilgrimage.1020 # Cleansing of the Temple
		100 = ek_pilgrimage.1021 # Of Dubious Value
		100 = ek_pilgrimage.1023 # Precepts of Stendarr
		1000 = ek_pilgrimage.1024 # Blessed, Blessed Satakalaam
		100 = ek_pilgrimage.1026 # The Sounding Horn
		1000 = ek_pilgrimage.1027 # Kyne's Sacred Trials
		100 = ek_pilgrimage.1036 # On Those Who Know Baan Dar
	}
}

#DB Events that happen if your destination is Ivarstead
db_pilgrimage_destination_events = {
	trigger = {
		scope:activity.activity_location.county = title:c_ivarstead
	}
	
	random_events = {
		9000 = db_pilgrimage.0001
		100 = db_pilgrimage.0002
		100 = db_pilgrimage.0003
		100 = db_pilgrimage.0004
		100 = db_pilgrimage.0005
		100 = db_pilgrimage.0006
		100 = db_pilgrimage.0007
		100 = db_pilgrimage.0008
		100 = db_pilgrimage.0009
		100 = db_pilgrimage.2009
		100 = db_pilgrimage.0010
		40 = db_pilgrimage.0011
		40 = db_pilgrimage.0012
		40 = db_pilgrimage.0014
		40 = db_pilgrimage.0015
		40 = db_pilgrimage.0016
		40 = db_pilgrimage.0017
		40 = db_pilgrimage.0018
		40 = db_pilgrimage.0019
	}
}

#Events that happen once you've returned home
pilgrimage_return_events = {
	effect = {
		if = {
			limit = { exists = var:visited_cultures_list }
			remove_variable = visited_cultures_list
		}
		if = {
			limit = {
				has_variable = db_high_hrothgar_tablets
			}
			remove_variable = db_high_hrothgar_tablets
		}
	}
	random_events = {
		100 = pilgrimage.9001
	}
}

#EK ADDITION: added our own arrival events
ek_specific_arrival_events = {
	random_events = {
		# EK TODO: Throwing errors, we can try to fix this once the mod runs again
		#100 = pilgrimage.5001 # Sancre Tor
	}
	fallback = pilgrimage_generic_arrival_events
}
#EK ADDITION END