﻿# EK NOTE: added our own guest trigger, removed gruesome festivals if only a vasall faith has access to it

##################################
## Gruesome Festivals 			##
## by Ewan Cowhig Croft			##
## modified by Chad Uhl			##
##################################

activity_gruesome_festival = {
	is_shown = {
		highest_held_title_tier > tier_barony
		is_landed_or_landless_administrative = yes
		trigger_if = {
			limit = {
				is_ai = yes
			}
			is_at_war = no
			ai_has_conqueror_personality = no
		}
		# DLC check.
		has_fp1_dlc_trigger = yes
		# Following a valid faith, or simply has an appropriate county.
		OR = {
			faith = { has_doctrine_parameter = gruesome_festivals_active }
			# Early-out for people who couldn't take the decision anyway.
			# EK DISABLED: commented this section out, so only the root faith doctrines are checked
			#AND = {
			#	highest_held_title_tier >= tier_duchy
			#	any_sub_realm_county = {
			#		count >= 1
			#		faith = { has_doctrine_parameter = gruesome_festivals_active }
			#	}
			#}
			# EK DISABLED END
		}
	}

	can_start_showing_failures_only = {
		is_available_adult = yes
		# Must have at least some peasants who are into the idea.
		custom_tooltip = {
			text = gf_valid_county_faith
			any_sub_realm_county = {
				faith = { has_doctrine_parameter = gruesome_festivals_active }
			}
		}
		# Suitable rank required.
		trigger_if = {
			limit = {
				faith = { has_doctrine_parameter = gruesome_festivals_active }
			}
			custom_tooltip = {
				text = gf_suitable_rank_valid
				OR = {
					is_independent_ruler = yes
					highest_held_title_tier >= tier_kingdom
				}
			}
		}
		trigger_else = {
			highest_held_title_tier >= tier_duchy
			# Technically, we could make this just mega-stressful, but since you'd have no easy way out, that feels like a newb trap.
			NOT = { has_trait = zealous }
		}
	}

	is_valid = {
		# Generic can-continue check.
		scope:host = {
			is_imprisoned = no
			is_landed_or_landless_administrative = yes
			NOT = { is_incapable = yes }
		}
		# If no one shows up
		trigger_if = {
			limit = {
				is_current_phase_active = yes
			}
			has_attending_activity_guests = yes
		}
	}

	on_invalidated = {
		set_variable = {
			name = gf_gold_recoup_value
			value = {
				value = 0
				# For a base, add the total pot spent.
				add = scope:activity.var:gf_refund_pot
				# Then revise it down a little to account for some costs being irredeemable.
				multiply = 0.75
			}
		}
		if = {
			limit = {
				scope:host = { is_incapable = yes  }
			}
			scope:activity = {
				activity_type = { save_scope_as = activity_type }
			}
			scope:host = {
				trigger_event = activity_system.0330
			}
			every_attending_character = {
				limit = { NOT = { this = scope:host } }
				trigger_event = activity_system.0331
			}
		}

		if = {
			limit = {
				scope:host = { is_imprisoned = yes }
			}
			#Host has been imprisoned
			every_attending_character = {
				limit = {
					NOT = { this  = scope:host }
				}
				trigger_event = feast.5005
			}
			scope:host = {
				# Send refund
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = fp1_other_decisions.0002.blot_invalidation.tt
					left_icon = scope:host
					custom_tooltip = fp1_other_decisions.0002.blot_invalidation.costs_recouped.tt
					hidden_effect = {
						# Regain *most* of any gold spent.
						add_gold = scope:activity.var:gf_gold_recoup_value
						# Regain all prestige.
						add_prestige_no_experience = gruesome_festival_prestige_cost_value
					}
				}
				trigger_event = feast.5004
			}
		}
		# Host becomes unlanded
		else_if = {
			limit = {
				scope:host = {
					is_landed_or_landless_administrative = no
				}
			}
			scope:activity = {
				activity_type = { save_scope_as = activity_type }
			}
			every_attending_character = {
				trigger_event = activity_system.0320
			}
		}
		else = {
			every_attending_character = {
				limit = {
					NOT = { this  = scope:host }
				}
				add_to_list = attendees_not_coming #Saved for tooltip in feast.2002
			}
			activity_host = {
				# For loc.
				save_scope_as = blotter
				# Send refund
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = fp1_other_decisions.0002.blot_invalidation.tt
					left_icon = scope:host
					custom_tooltip = fp1_other_decisions.0002.blot_invalidation.costs_recouped.tt
					hidden_effect = {
						# Regain *most* of any gold spent.
						add_gold = scope:activity.var:gf_gold_recoup_value
						# Regain all prestige.
						add_prestige_no_experience = gruesome_festival_prestige_cost_value
					}
				}
				trigger_event = activity_system.0100 
			}
		}
	}

	on_host_death = {
		every_attending_character = {
			limit = { is_alive = yes }
			trigger_event = {
				id = feast.5003
				days = 2 # So you don't get spammed
			}
		}
	}

	province_filter = domicile_domain
	ai_province_filter = domicile_domain

	max_province_icons = 5

	is_location_valid = {
		faith = { has_doctrine_parameter = gruesome_festivals_active }
	}

	cost = {
		prestige = {
			add = {
				value = gruesome_festival_prestige_cost_value
				desc = hunt_base_cost
			}
		}
	}

	ui_predicted_cost = {
		prestige = {
			# Base cost in Prestige
			value = gruesome_festival_prestige_cost_value

			# Make it a multiple of 5 (rounded up)
			divide = 5 
			ceiling = yes 
			multiply = 5
		}
		gold = {
			# Blot only has a base prestige cost
			value = 0 
			add = { # Blot Size
				value = 0
				add = gruesome_festival_option_small # Small Blot
				add = gruesome_festival_option_medium # Mid-sized Blot
				add = gruesome_festival_option_large # Large Blot
				# Divide by 3 to get the average option cost
				divide = 3
			}
			add = { # Sacrifices Option
				value = 0 
				add = gruesome_festival_option_medium # Magnificent Animal Sacrifices
				add = gruesome_festival_option_medium # Magnificent Human Sacrifices
				# Divide by 4 to get the average option cost (2 levels of the option, the non magnificent ones, do not have a cost)
				divide = 4
			}

			# Make it a multiple of 5 (rounded up)
			divide = 5 
			ceiling = yes 
			multiply = 5
		}
	}

	cooldown = { years = hold_gruesome_festival_decision_value }

	is_single_location = yes

	###################
	# AI VALUES 
	###################
	ai_will_do = {
		value = 100
		
		# Different Faith Block
		## If not of the faith, you don't want to do it at all outside of extenuating circumstances.
		if = {
			limit = {
				faith = { has_doctrine_parameter = gruesome_festivals_active }
			}
			add = -100
		}
		## No need to account for zealots, as they cannae take the decision.
		## Cynical.
		if = {
			limit = {
				NOT = {
					faith = { has_doctrine_parameter = gruesome_festivals_active }
				}
				has_trait = sadistic
			}
			add = 10
		}
		## Otherwise, we only want to do it if basically the whole realm is of some kind of gf-practicing faith.
		if = {
			limit = {
				NOT = {
					faith = { has_doctrine_parameter = gruesome_festivals_active }
				}
				any_sub_realm_county = {
					percent >= 0.75
					faith = { has_doctrine_parameter = gruesome_festivals_active }
				}
			}
			add = 25
		}
		# Same Faith Block
		# Zealous.
		if = {
			limit = {
				faith = { has_doctrine_parameter = gruesome_festivals_active }
				has_trait = zealous
			}
			add = 100
		}
		# Cynical.
		if = {
			limit = {
				faith = { has_doctrine_parameter = gruesome_festivals_active }
				has_trait = cynical
			}
			add = -25
		}
		# You're richer.
		if = {
			limit = {
				faith = { has_doctrine_parameter = gruesome_festivals_active }
				short_term_gold >= massive_gold_value
			}
			add = 50
		}
		if = {
			limit = {
				faith = { has_doctrine_parameter = gruesome_festivals_active }
				short_term_gold >= monumental_gold_value
			}
			add = 50
		}
		# Plague
		if = {
        	limit = {
        	    any_held_title = {
					tier = tier_county
        	        any_county_province = {
        	            any_province_epidemic = {
        	                count >= 1
        	                outbreak_intensity < apocalyptic
        	            }
        	        }
        	    }
        	    would_follow_social_distancing_value >= -1
        	}
        	add = {
        	    value = -60
        	    desc = "Plague in Domain"
        	}
    	}
    	else_if = {
    	    limit = {
    	        any_realm_county = {
    	            any_county_province = {
    	                any_province_epidemic = {
    	                    count >= 1
    	                    outbreak_intensity < apocalyptic
    	                }
    	            }
    	        }
    	        would_follow_social_distancing_value >= -1
    	    }
    	    add = {
    	        value = -20
    	        desc = "Plague in Top Realm"
    	    }
    	}
    	if = {
    	    limit = {
    	        any_held_title = {
					tier = tier_county
    	            any_county_province = {
    	                any_province_epidemic = {
    	                    count >= 1
    	                    outbreak_intensity = apocalyptic
    	                }
    	            }
    	        }
    	    }
    	    add = {
    	        value = -200
    	        desc = "Apocalyptic Plague in Domain"
    	    }
    	}
    	else_if = {
    	    limit = {
    	        any_held_title = {
					tier = tier_county
    	            any_county_province = {
    	                any_province_epidemic = {
    	                    count >= 1
    	                    outbreak_intensity = apocalyptic
    	                }
    	            }
    	        }
    	    }
    	    add = {
    	        value = -40
    	        desc = "Apocalyptic Plague in Top Realm"
    	    }
    	}
	}

	ai_check_interval = 60

	ai_will_select_province = {
		value = 10
		if = {
			limit = {
				this = scope:host.capital_province
			}
			add = {
				value = 30
				desc = "Capital Province preferred"
			}
		}
	}

	###################
	# OPTIONS
	###################

	options = {
		gruesome_festival_option_size = {
			gruesome_festival_size_small = {
				default = yes
				cost = {
					gold = {
						add = {
							value = gruesome_festival_option_small
							desc = gruesome_festival_size_small
						}
						if = {
							limit = {
								has_perk = journey_planner_perk
							}
							multiply = {
								value = voyager_journey_planner_value
								desc = journey_planner_perk_name
							}
						}
					}
				}

				on_start = {
					change_variable = {
						name = gf_refund_pot
						add = scope:host.gruesome_festival_option_small
					}
				}

				ai_will_do = {
					value = 10
					add = {
						value = 40
						desc = "Base test value"
					}
				}
			}
			gruesome_festival_size_medium = {
				is_valid = {
					custom_tooltip = {
						text = gf_medium_option_valid
						any_held_title = {
							count >= 2
							tier = tier_county
							#faith = scope:gf_faith
						}
					}
				}
				cost = {
					gold = {
						add = {
							value = gruesome_festival_option_medium
							desc = gruesome_festival_size_medium
						}
						if = {
							limit = {
								has_perk = journey_planner_perk
							}
							multiply = {
								value = voyager_journey_planner_value
								desc = journey_planner_perk_name
							}
						}
					}
				}

				on_start = {
					change_variable = {
						name = gf_refund_pot
						add = scope:host.gruesome_festival_option_medium
					}
				}

				ai_will_do = {
					value = 20
					if = {
						limit = { has_trait = greedy }
						subtract = {
							value = 20
							desc = "Greedy"
						}
					}
				}
			}
			gruesome_festival_size_large = {
				is_valid = {
					highest_held_title_tier >= tier_duchy
				}
				cost = {
					gold = {
						add = {
							value = gruesome_festival_option_large
							desc = gruesome_festival_size_large
						}
						if = {
							limit = {
								has_perk = journey_planner_perk
							}
							multiply = {
								value = voyager_journey_planner_value
								desc = journey_planner_perk_name
							}
						}
					}
				}

				on_start = {
					change_variable = {
						name = gf_refund_pot
						add = scope:host.gruesome_festival_option_large
					}
				}

				ai_will_do = {
					value = 30
					if = {
						limit = { has_trait = greedy }
						subtract = {
							value = 30
							desc = "Greedy"
						}
					}
				}
			}
		}

		gruesome_festival_option_sacrifice = {
			gruesome_festival_sacrifice_animals_genuine = {
				default = yes
				is_shown = {
					faith = { has_doctrine_parameter = gruesome_festivals_active }
				}

				on_start = {
					scope:host = {
						set_variable = {
							name = gf_piety_value
							value = minor_piety_gain
							# If not of the faith, invert this & reduce it a little.
						}
						
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
				}
			}
			gruesome_festival_sacrifice_animals_magnificent_genuine = {
				is_shown = {
					OR = {
						is_ai = no 
						short_term_gold >= gruesome_festival_option_medium
					}
					faith = { has_doctrine_parameter = gruesome_festivals_active }
				}
				cost = {
					gold = {
						add = {
							value = gruesome_festival_option_medium
							desc = gruesome_festival_sacrifice_animals_magnificent_genuine
						}
						if = {
							limit = {
								has_perk = journey_planner_perk
							}
							multiply = {
								value = voyager_journey_planner_value
								desc = journey_planner_perk_name
							}
						}
					}
				}

				on_start = {
					change_variable = {
						name = gf_refund_pot
						add = scope:host.gruesome_festival_option_medium
					}
					scope:host = {
						set_variable = {
							name = gf_piety_value
							value = medium_piety_gain
						}

						# If not of the faith, invert this & reduce it a little.
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value 
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
				}
			}
			gruesome_festival_sacrifice_humans_genuine = {
				is_shown = {
					faith = { has_doctrine_parameter = gruesome_festivals_active }
				}

				on_start = {
					scope:host = {
						set_variable = {
							name = gf_piety_value 
							value = medium_piety_gain
						}
						add_character_flag = gruesome_festivals_can_pick_human_sacrifice

						# If not of the faith, invert this & reduce it a little.
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value 
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
					if = {
						limit = { has_trait = cannibal }
						add = {
							value = 50 
							desc = "Cannibal"
						}
					}
				}
			}
			gruesome_festival_sacrifice_humans_magnificent_genuine = {
				is_shown = {
					OR = {
						is_ai = no 
						short_term_gold >= gruesome_festival_option_medium
					}
					faith = { has_doctrine_parameter = gruesome_festivals_active }
				}
				cost = {
					gold = {
						add = {
							value = gruesome_festival_option_medium
							desc = gruesome_festival_sacrifice_humans_magnificent_genuine
						}
						if = {
							limit = {
								has_perk = journey_planner_perk
							}
							multiply = {
								value = voyager_journey_planner_value
								desc = journey_planner_perk_name
							}
						}
					}
				}

				on_start = {
					change_variable = {
						name = gf_refund_pot
						add = scope:host.gruesome_festival_option_medium
					}
					scope:host = {
						set_variable = {
							name = gf_piety_value
							value = major_piety_gain
						}
						add_character_flag = gruesome_festivals_can_pick_human_sacrifice

						# If not of the faith, invert this & reduce it a little.
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
					if = {
						limit = { has_trait = cannibal }
						add = {
							value = 50 
							desc = "Cannibal"
						}
					}
				}
			}

			gruesome_festival_sacrifice_animals_poser = {
				is_shown = {
					faith = { 
						NOT = { 
							has_doctrine_parameter = gruesome_festivals_active
						}
					}
				}
				default = yes
		

				on_start = {
					scope:host = {
						set_variable = {
							name = gf_piety_value
							value = minor_piety_gain
							# If not of the faith, invert this & reduce it a little.
						}
						
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
				}
			}
			gruesome_festival_sacrifice_animals_magnificent_poser = {
				is_shown = {
					OR = {
						is_ai = no 
						short_term_gold >= major_gold_value
					}
					faith = { 
						NOT = { 
							has_doctrine_parameter = gruesome_festivals_active 
						}
					}
				}
		
				cost = { 
					gold = {
						add = gruesome_festival_option_medium 
						if = {
							limit = {
								has_perk = journey_planner_perk
							}
							multiply = {
								value = voyager_journey_planner_value
								desc = journey_planner_perk_name
							}
						}
					}
				}
				is_valid = {
					gold > gruesome_festival_option_medium
				}

				on_start = {
					change_variable = {
						name = gf_refund_pot
						add = scope:host.major_gold_value
					}
					scope:host = {
						set_variable = {
							name = gf_piety_value
							value = medium_piety_gain
						}

						# If not of the faith, invert this & reduce it a little.
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value 
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
				}
			}
			gruesome_festival_sacrifice_humans_poser = {
				is_shown = {
					any_vassal_or_below = { highest_held_title_tier >= tier_county }
					faith = { 
						NOT = { 
							has_doctrine_parameter = gruesome_festivals_active 
						}
					}
				}
		

				on_start = {
					scope:host = {
						set_variable = {
							name = gf_piety_value 
							value = medium_piety_gain
						}
						add_character_flag = gruesome_festivals_can_pick_human_sacrifice

						# If not of the faith, invert this & reduce it a little.
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value 
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
				}
			}
			gruesome_festival_sacrifice_humans_magnificent_poser = {
				is_shown = {
					OR = {
						is_ai = no 
						short_term_gold >= gruesome_festival_option_medium
					}
					faith = { 
						NOT = { 
							has_doctrine_parameter = gruesome_festivals_active
						}
					}
				}
		
				cost = { 
					gold = {
						add = gruesome_festival_option_medium 
						if = {
							limit = {
								has_perk = journey_planner_perk
							}
							multiply = {
								value = voyager_journey_planner_value
								desc = journey_planner_perk_name
							}
						}
					}
				}
				is_valid = {
					gold > gruesome_festival_option_medium
				}

				on_start = {
					change_variable = {
						name = gf_refund_pot
						add = scope:host.gruesome_festival_option_medium
					}
					scope:host = {
						set_variable = {
							name = gf_piety_value
							value = major_piety_gain
						}
						add_character_flag = gruesome_festivals_can_pick_human_sacrifice

						# If not of the faith, invert this & reduce it a little.
						if = {
							limit = {
								NOT = { faith = involved_activity.activity_location.faith }
							}
							# HumSac faiths still aren't happy.
							if = {
								limit = {
									faith = {
										OR = {
											has_doctrine_parameter = flower_war_cb_active
											has_doctrine_parameter = human_sacrifice_active
											has_doctrine_parameter = gruesome_festivals_active
										}
									}
								}
								change_variable = {
									name = gf_piety_value
									multiply = -0.25
								}
							}
							# Non-HumSac faiths are horrified.
							else = {
								change_variable = {
									name = gf_piety_value
									multiply = -0.75
								}
							}
						}
					}
				}

				ai_will_do = {
					value = 0
					add = {
						value = 40
						desc = "Base value"
					}
				}
			}
		}
	}

	###################
	# PHASES
	###################

	phases = {
		gruesome_festival_phase = {
			is_predefined = yes
			order = 1

			on_phase_active = {
				if = {
					limit = { this = scope:host }
					scope:activity = { progress_activity_phase_after = { weeks = 1 } }
					save_scope_as = blotter
					scope:activity.var:gf_faith = { save_scope_as = gf_faith }
					trigger_event = fp1_other_decisions.0003 
				}
			}
		}
	}

	max_guest_arrival_delay_time = { months = 8 }

	###################
	# GUEST HANDLING
	###################

	max_guests = 50

	guest_invite_rules = {
		defaults = {
			1 = activity_invite_rule_courtiers
			1 = activity_invite_rule_vassals
			2 = activity_invite_rule_guests
		}
		rules = {
			# MP 
			6 = activity_invite_mp
		}
	}

	can_be_activity_guest = {
		is_adult = yes
		in_diplomatic_range = scope:host
		# EK ADDITION: added our own trigger
		ek_is_valid_activity_guest = yes
	}

	host_intents = {
		intents = { reduce_stress_intent }
		default = reduce_stress_intent
	}

	guest_intents = {
		intents = { reduce_stress_intent }
		default = reduce_stress_intent
	}

	guest_join_chance = {
		base = 10
		base_activity_modifier = yes

		# Scripted Modifiers
		activity_guest_shared_ai_accept_modifier = yes 
	}

	###################
	# ACTIVITY-SPECIFIC PULSES
	###################
	
	pulse_actions = {
		entries = {
			sacrifed_small_animal mournful_music spouse_gives_hook hook_trusting_guest guest_brawl host_gains_diplo_xp host_gains_steward_xp host_gains_intrigue_xp good_kitty good_puppy antiquarian_admires_artifact apa_executioner
		}
		chance_of_no_event = 5
	}

	on_start = {
		set_variable = {
			name = gf_faith 
			value = activity_location.faith
		}
		set_variable = {
			name = gf_refund_pot
			value = 0
		}

		# Turn activity options into scopes so all the events work
		# scope:blot_scale
		if = {
			limit = {
				has_activity_option = {
					category = gruesome_festival_option_size
					option = gruesome_festival_size_small
				}
			}
			set_variable = {
				name = blot_scale 
				value = flag:small
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = gruesome_festival_option_size
					option = gruesome_festival_size_medium
				}
			}
			set_variable = {
				name = blot_scale 
				value = flag:medium
			}
		}
		else_if = {
			limit = { 
				has_activity_option = {
					category = gruesome_festival_option_size
					option = gruesome_festival_size_large
				} 
			}
			set_variable = {
				name = blot_scale 
				value = flag:large
			}
		}

		#var:blot_sacrifice
		if = {
			limit = {
				OR = {
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_animals_genuine
					}
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_animals_poser
					}
				}
			}
			set_variable = {
				name = blot_sacrifice 
				value = flag:animals_regular
			}
		}
		else_if = {
			limit = { 
				OR = {
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_animals_magnificent_genuine
					}
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_animals_magnificent_poser
					}
				}
			}
			set_variable = {
				name = blot_sacrifice 
				value = flag:animals_magnificent
			}
		}
		else_if = {
			limit = { 
				OR = {
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_humans_genuine
					}
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_humans_poser
					}
				}
			}
			set_variable = {
				name = blot_sacrifice 
				value = flag:humans_regular
			}
		}
		else_if = {
			limit = { 
				OR = {
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_humans_magnificent_genuine
					}
					has_activity_option = {
						category = gruesome_festival_option_sacrifice
						option = gruesome_festival_sacrifice_humans_magnificent_poser
					}
				}
			}
			set_variable = {
				name = blot_sacrifice 
				value = flag:humans_magnificent
			}
		}
	}

	on_enter_active_state = {
		surveyor_no_stone_unturned_perk_effect = yes
	}

	on_enter_travel_state = {
		if = {
			limit = {
				NOT = { this = scope:host }
				current_travel_plan.travel_plan_owner = this
			}	
			# saving the scope again so that it gets passed onto the following event
			scope:activity.var:gf_faith = {
				save_scope_as = gf_faith
			}
			scope:host = { save_scope_as = blotter }
			trigger_event = fp1_other_decisions.0011
		}
		
	}

	# Entourage Selection

	travel_entourage_selection = {
		weight = {
			value = standard_travel_entourage_additions
			if = {
				limit = {
					has_trait = zealous
				}
				add = 10
			}
		}
		max = 3
		invite_rule_order = 1
	}

	### Graphics
	map_entity = {
		trigger = {
			activity_location.culture = {
				OR = {
					has_graphical_iranian_culture_group_trigger = yes
					has_graphical_mena_culture_group_trigger = yes
					has_graphical_steppe_culture_group_trigger = yes
					has_graphical_african_culture_group_trigger = yes
				}
			}
		}
		reference = "building_mena_feast_01_entity"
	}

	map_entity = {
		trigger = {
			activity_location.culture = {
				has_graphical_india_culture_group_trigger = yes
			}
		}
		reference = "building_indian_feast_01_entity"
	}
	
	map_entity = "building_western_feast_01_entity"

	# Travel
	background = { # Bridge
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				is_riverside_province = yes
				# EK EDIT: Swapped europe with our own regions
				geographical_region = ek_graphical_europe_like
				# EK EDIT END
				OR = {
					terrain = farmlands
					terrain = plains
					terrain = mountains
					terrain = hills
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_bridge.dds"
		environment = "environment_travel_bridge"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}
	
	background = { # Farmland, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				terrain = farmlands
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_farm.dds"
		environment = "environment_travel_farmlands"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { # Farmland, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				terrain = farmlands
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/farms.dds"
		environment = "environment_event_farms"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #Desert, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_desert_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_desert.dds"
		environment = "environment_travel_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}
	background = { #Desert, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_desert_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/desert.dds"
		environment = "environment_event_bp1_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}

	background = { #forest snowy
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location ?= { hunt_snowy_forest_trigger = yes }
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_hunt_snowy_forest.dds"
		environment = "environment_hunt_snowy_forest"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	background = { #forest_pine
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_forest_pine_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/forest_pine.dds"
		environment = "environment_event_forest_pine"
		ambience = "event:/SFX/Events/Backgrounds/coniferous_forest_day"
	}

	background = { #forest
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_forest_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/forest.dds"
		environment = "environment_event_forest"
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #mountains, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_mountains_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_mountains.dds"
		environment = "environment_travel_mountain_settlement"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}
	background = { #mountains, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_mountains_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/mountains.dds"
		environment = "environment_event_mountains"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	background = { #steppe, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_steppe_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_steppe.dds"
		environment = "environment_travel_steppe_settlement"
		ambience = "event:/SFX/Events/Backgrounds/steppe_day"
	}
	background = { #steppe, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_steppe_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/steppe.dds"
		environment = "environment_event_steppe"
		ambience = "event:/SFX/Events/Backgrounds/steppe_day"
	}

	background = { #drylands (formerly desert)
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_drylands_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/drylands.dds"
		environment = "environment_event_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}

	background = { #wetlands
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_wetlands_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_wetlands.dds"
		environment = "environment_event_bp1_wetlands" 
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #jungle
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_wilderness_jungle_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_jungle.dds"
		environment = "environment_event_bp1_jungle"
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #plains, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_plains_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_hills.dds"
		environment = "environment_travel_hills_settlement"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { #plains, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_plains_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_plains.dds"
		environment = "environment_event_bp1_plains"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #hills, settled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_hills_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_hills.dds"
		environment = "environment_travel_hills_settlement"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { #hills, unsettled
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				graphical_hills_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_hills.dds"
		environment = "environment_event_bp1_hills"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #sea
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				is_sea_province = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp1_ocean.dds"
		environment = "environment_event_fp1_ocean"
		ambience = "event:/DLC/FP1/SFX/Events/event_ocean_longship"
	}
	# End Travel
	background = {
		texture = "gfx/interface/illustrations/activity_backgrounds/activity_gruesome_festival.dds"
		environment = "environment_event_bp1_bonfire" 
		ambience = "event:/SFX/Events/Backgrounds/burning_building"
	}

	window_characters = {

		guest = {
			camera = camera_event_center
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = zealous }
					}
					animation = personality_zealous
				}
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = cynical }
					}
					animation = { boredom personality_cynical }
				}
				#Fallback
				animation = personality_compassionate
			}
		}

		guest = {
			camera = camera_event_center
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = zealous }
					}
					animation = personality_zealous
				}
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = cynical }
					}
					animation = { boredom personality_cynical }
				}
				#Fallback
				animation = personality_compassionate
			}
		}
		
		host = {
			camera = camera_event_center
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character.location = { is_sea_province = yes }
					}
					animation = { survey }
				}
				animation = idle
			}
		}
		
		travel_host = {
			camera = camera_event_horse_left
			
			effect = {
				if = {
					limit = {
						NOR = {
							scope:host.location = scope:activity.activity_location
							scope:host.location = { is_sea_province = yes }
						}
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = { scope:character = { has_trait = impatient } }
					animation = { jockey_gallop }
				}
				animation = jockey_walk
			}
		}

		guest = {
			camera = camera_event_center
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = zealous }
					}
					animation = personality_zealous
				}
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = cynical }
					}
					animation = { boredom personality_cynical }
				}
				#Fallback
				animation = personality_compassionate
			}
		}

		guest = {
			camera = camera_event_center
			
			effect = {
				every_attending_character = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = zealous }
					}
					animation = personality_zealous
				}
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = cynical }
					}
					animation = { boredom personality_cynical }
				}
				#Fallback
				animation = personality_compassionate
			}
		}
	}
}
