namespace = fp1_other_decisions

##################################################
# #Religious Events
# 0001 - 0020	Gruesome Festivals - hold a mighty sacrifice dedicated to your divinities.
# 0021 - 0040	GF Consequences - events resulting from GFs, e.g., the world freaking out at the sacrifice of a HoF.
# 0041 - 0060	Unreserved
# 0061 - 0080	GF Maintenance Events - invalidation events & Chief Sacrifice resets.
#
# 0101 - 0120	Stele Setup Events - select type & location.
##################################################

##################################################
# Gruesome Festivals
# by Ewan Cowhig Croft
# 0001 - 0020
##################################################

# Human Sacrifice will be referred to as HumSac throughout. I make no apologies for whatever you envision as a result.

# Clean up declining guest list: we track this separately, since we don't always want to fire it at the same time.
scripted_effect gruesome_sacrifices_clean_up_declining_guests_effect = {
	#Shouldn't ever need to be more complicated than this, but might be.
	clear_variable_list = gf_guests_rejecting_invite_list
}

scripted_trigger sacrifice_method_hang_n_fang_trigger = {
	scope:activity.var:gf_faith = {
		religion = religion:germanic_religion
		has_doctrine_parameter = cannibalism_legal
	}
}
scripted_trigger sacrifice_method_eat_em_trigger = {
	scope:activity.var:gf_faith = { has_doctrine_parameter = cannibalism_legal }
}
scripted_trigger sacrifice_method_hang_em_trigger = {
	scope:activity.var:gf_faith.religion = religion:germanic_religion
}

scripted_trigger gruesome_festivals_available_impressable_nobles = {
	highest_held_title_tier >= tier_county
	# Exempt priests, who have their own option.
	NOT = { government_has_flag = government_is_theocracy }
}

scripted_trigger gruesome_festivals_available_impressable_clergy = {
	highest_held_title_tier >= tier_county
	government_has_flag = government_is_theocracy
}

scripted_trigger dislikes_humsac_trigger = {
	NOR = {
		has_doctrine_parameter = flower_war_cb_active
		has_doctrine_parameter = human_sacrifice_active
		has_doctrine_parameter = gruesome_festivals_active
	}
}

scripted_effect gruesome_festivals_blotter_opinion_gain_of_guests_effect = {
	reverse_add_opinion = {
		modifier = pleased_opinion
		target = scope:blotter
		opinion = 30
	}
}

#	Let the sacrifice begin!
fp1_other_decisions.0003 = {
	type = activity_event
	title = fp1_other_decisions.0003.t
	desc = {
		# How big is the whole affair?
		first_valid = {
			triggered_desc = {
				trigger = { scope:activity.var:blot_scale = flag:small }
				desc = fp1_other_decisions.0003.desc.intro.small
			}
			triggered_desc = {
				trigger = { scope:activity.var:blot_scale = flag:medium }
				desc = fp1_other_decisions.0003.desc.intro.medium
			}
			triggered_desc = {
				trigger = { scope:activity.var:blot_scale = flag:large }
				desc = fp1_other_decisions.0003.desc.intro.large
			}
		}
		# What's on the menu?
		first_valid = {
			# Adequate animal sacrifice.
			triggered_desc = {
				trigger = { scope:activity.var:blot_sacrifice = flag:animals_regular }
				desc = fp1_other_decisions.0003.desc.animals.regular
			}
			# Magnificent animal sacrifice.
			triggered_desc = {
				trigger = { scope:activity.var:blot_sacrifice = flag:animals_magnificent }
				desc = fp1_other_decisions.0003.desc.animals.magnificent
			}
			# Adequate HumSac, sans chief sacrifice.
			triggered_desc = {
				trigger = {
					scope:activity.var:blot_sacrifice = flag:humans_regular
					NOT = { exists = scope:unlucky_guest }
				}
				desc = fp1_other_decisions.0003.desc.humans.regular.sans_chief
			}
			# Magnificent HumSac, sans chief sacrifice.
			triggered_desc = {
				trigger = {
					scope:activity.var:blot_sacrifice = flag:humans_magnificent
					NOT = { exists = scope:unlucky_guest }
				}
				desc = fp1_other_decisions.0003.desc.humans.magnificent.sans_chief
			}
			# Adequate HumSac, plus chief sacrifice.
			triggered_desc = {
				trigger = {
					scope:activity.var:blot_sacrifice = flag:humans_regular
					exists = scope:unlucky_guest
				}
				desc = fp1_other_decisions.0003.desc.humans.regular.plus_chief
			}
			# Magnificent HumSac, plus chief sacrifice.
			triggered_desc = {
				trigger = {
					scope:activity.var:blot_sacrifice = flag:humans_magnificent
					exists = scope:unlucky_guest
				}
				desc = fp1_other_decisions.0003.desc.humans.magnificent.plus_chief
			}
		}
		# How is it getting to the menu?
		## Named sacrifice is present.
		triggered_desc = {
			trigger = { exists = scope:unlucky_guest }
			desc = {
				first_valid = {
					# Norse pagans cannibals hang their sacrifices, *then* eat them.
					triggered_desc = {
						trigger = { sacrifice_method_hang_n_fang_trigger = yes }
						desc = fp1_other_decisions.0003.desc.sacrifice.named.norse_cannibals
					}
					# Cannibals execute them, then eat them them.
					triggered_desc = {
						trigger = { sacrifice_method_eat_em_trigger = yes }
						desc = fp1_other_decisions.0003.desc.sacrifice.named.cannibals
					}
					# Norse pagans hang their sacrifices.
					triggered_desc = {
						trigger = { sacrifice_method_hang_em_trigger = yes }
						desc = fp1_other_decisions.0003.desc.sacrifice.named.norse
					}
					# Fallback: disembowl the sacrifice.
					desc = fp1_other_decisions.0003.desc.sacrifice.named.fallback
				}
			}
		}
		## Humans are present.
		triggered_desc = {
			trigger = {
				NOT = { exists = scope:unlucky_guest }
				OR = {
					scope:activity.var:blot_sacrifice = flag:humans_regular
					scope:activity.var:blot_sacrifice = flag:humans_magnificent
				}
			}
			desc = {
				first_valid = {
					# Norse pagans cannibals hang their sacrifices, *then* eat them.
					triggered_desc = {
						trigger = { sacrifice_method_hang_n_fang_trigger = yes }
						desc = fp1_other_decisions.0003.desc.sacrifice.unnamed.norse_cannibals
					}
					# Cannibals execute them, then eat them them.
					triggered_desc = {
						trigger = { sacrifice_method_eat_em_trigger = yes }
						desc = fp1_other_decisions.0003.desc.sacrifice.unnamed.cannibals
					}
					# Norse pagans hang their sacrifices.
					triggered_desc = {
						trigger = { sacrifice_method_hang_em_trigger = yes }
						desc = fp1_other_decisions.0003.desc.sacrifice.unnamed.norse
					}
					# Fallback: disembowl the sacrifice.
					desc = fp1_other_decisions.0003.desc.sacrifice.unnamed.fallback
				}
			}
		}
		## Only animal sacrifices.
		triggered_desc = {
			trigger = {
				OR = {
					scope:activity.var:blot_sacrifice = flag:animals_regular
					scope:activity.var:blot_sacrifice = flag:animals_magnificent
				}
			}
			desc = {
				first_valid = {
					# No special Norse-cannibal or cannibal variants for animals, as they're just animals.
					# Norse pagans hang their sacrifices.
					triggered_desc = {
						trigger = { sacrifice_method_hang_em_trigger = yes }
						desc = fp1_other_decisions.0003.desc.sacrifice.animal.norse
					}
					# Fallback: disembowl the sacrifice.
					desc = fp1_other_decisions.0003.desc.sacrifice.animal.fallback
				}
			}
		}
		# And what's your basic take on affairs?
		first_valid = {
			# If you don't share the faith, then this is a political ceremony.
			triggered_desc = {
				trigger = {
					faith != scope:gf_faith
				}
				desc = fp1_other_decisions.0003.desc.outro.political
			}
			# Otherwise, you're faithful, and it's not.
			desc = fp1_other_decisions.0003.desc.outro.faithful
		}
	}
	theme = party
	left_portrait = {
		character = scope:blotter
		animation = personality_rational
	}
	right_portrait = {
		character = scope:unlucky_guest
		animation = fear
	}
	override_background = { reference = temple }

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
		# Generic can-continue check.
		#gruesome_sacrifices_grand_blot_can_continue_trigger = yes
		# Already-started can-continue check.
		#gruesome_sacrifices_grand_blot_in_progress_trigger = yes
	}

	on_trigger_fail = {
	#	# If you have a prisoner marked for sacrifice, relieve them.
	#	every_prisoner = {
	#		limit = { has_character_modifier = gruesome_festivals_designated_sacrifice_fp1_modifier }
	#		designate_gruesome_festivals_sacrifice_modifier_removed_effect = { DESIGNATOR = scope:blotter }
	#	}
	}

	immediate = {
		involved_activity = { save_scope_as = activity }
		# Get the party (audibly) started.
		play_music_cue = "mx_cue_banquet"

		# Is it somebody specific's death day?
		if = {
			limit = {
				# We don't actually need to check these scopes, but it's a convenient early out if your dungeon is huge for some reason.
				OR = {
					scope:activity.var:blot_sacrifice = flag:humans_regular
					scope:activity.var:blot_sacrifice = flag:humans_magnificent
				}
				any_prisoner = { has_character_modifier = gruesome_festivals_designated_sacrifice_fp1_modifier }
			}
			# Ahhh, it is! Nab 'em for the murderising & calculate piety to be gained.
			random_prisoner = {
				limit = { has_character_modifier = gruesome_festivals_designated_sacrifice_fp1_modifier }
				# Once for the portrait.
				save_scope_as = unlucky_guest
				# And once for loc.
				save_scope_as = sacrifice
				#To give accurate death notifications
				add_character_flag = {
					flag = is_currently_being_sacrificed
					days = 1
				}
			}
		}
		# If someone is dying but we don't care who, generate a dummy sacrifice.
		else_if = {
			limit = {
				NOT = { exists = scope:unlucky_guest }
				OR = {
					scope:activity.var:blot_sacrifice = flag:humans_regular
					scope:activity.var:blot_sacrifice = flag:humans_magnificent
				}
			}
			random_dummy_gender_soldier_effect = { SCOPE_NAME = sacrifice }
		}
		# Take care of happy subjects.
		## Build a list of affected happy subjects.
		### Small first.
		if = {
			limit = { scope:activity.var:blot_scale = flag:small }
			# Nab all courtiers & guests.
			every_courtier_or_guest = {
				limit = { faith = scope:gf_faith }
				add_to_list = happified_character_subjects_list
			}
		}
		### Then try a medium list.
		else_if = {
			limit = { scope:activity.var:blot_scale = flag:medium }
			# Nab all courtiers & guests.
			every_courtier_or_guest = {
				limit = { faith = scope:gf_faith }
				add_to_list = happified_character_subjects_list
			}
			# Also nab all barons in your domain.
			every_vassal = {
				limit = {
					highest_held_title_tier = tier_barony
					faith = scope:gf_faith
				}
				add_to_list = happified_character_subjects_list
			}
			# Nab your domain titles.
			every_held_title = {
				title_tier = county
				limit = {
					is_landless_type_title = no
					faith = scope:gf_faith
				}
				add_to_list = happified_title_subjects_list
			}
		}
		### Finally, try a large list.
		else_if = {
			limit = { scope:activity.var:blot_scale = flag:large }
			# Nab all courtiers & guests.
			every_courtier_or_guest = {
				limit = { faith = scope:gf_faith }
				add_to_list = happified_character_subjects_list
			}
			# Also nab all vassals and sub-vassals.
			every_vassal_or_below = {
				limit = { faith = scope:gf_faith }
				add_to_list = happified_character_subjects_list
			}
			# Nab all sub-realm titles.
			every_sub_realm_county = {
				limit = { faith = scope:gf_faith }
				add_to_list = happified_title_subjects_list
			}
		}
		### Aaaand remove anyone who spurned the invitation explicitly.
		if = {
			limit = {
				has_variable_list = gf_guests_rejecting_invite_list
				any_in_list = {
					variable = gf_guests_rejecting_invite_list
					count >= 1
					# Account for people who might have converted in the meanwhilst.
					faith = scope:gf_faith
				}
			}
			every_in_list = {
				variable = gf_guests_rejecting_invite_list
				# TIT-25457
				remove_from_list = happified_title_subjects_list
			}
		}
		# Set up var:gf_faith for custom loc to work; not used in strictly every permutation, but doesn't really need an if gate on it.
		set_variable = {
			name = gf_faith
			value = scope:gf_faith
		}

		scope:activity = {
			add_activity_log_entry = {
				key = gruesome_festival_immediate_log
				score = 1000
				show_in_conclusion = yes
				character = root
				# Piety based on value calculated from the selected activity option
				activity_host = {
					if = {
						limit = { exists = var:gf_piety_value }
						add_piety = var:gf_piety_value
						remove_variable = gf_piety_value
					}
				}
				## Big RIP, scope:unlucky_guest.
				if = {
					limit = { exists = scope:unlucky_guest }
					# Sort opinions and kinslaying.
					add_kinslayer_trait_or_nothing_effect = { VICTIM = scope:unlucky_guest}
					execute_opinion_effect = {
						VICTIM = scope:unlucky_guest
						EXECUTIONER = scope:blotter
					}
					# Are you HumSac'ing the HoF of a faith that doesn't practice HumSac?
					## We hide this, since it's too late for you to do anything about now and it's more fun/terrifying to find out about it *after* the sacrifice.
					hidden_effect = {
						humsacd_a_hof_effect = {
							SACRIFICER = scope:blotter
							SACRIFICED_HOF = scope:unlucky_guest
						}
					}
					## And are you actually humsac'ing your *OWN* HoF?
					if = {
						limit = { scope:blotter.faith.religious_head = scope:unlucky_guest }
						# Inform players that they're an abysmal, abysmal faith adherent.
						every_player = {
							limit = {
								this != scope:blotter
								faith = scope:unlucky_guest.faith
							}
							trigger_event = fp1_other_decisions.0023
						}
						# Update scope:blotter's HumSac'd HoFs kill tally manually, since we're not going through the usual effect.
						add_to_variable_list = {
							name = humsacd_hofs
							target = scope:unlucky_guest.faith
						}
						# And tell scope:blotter they dun goofed.
						trigger_event = {
							id = fp1_other_decisions.0024
							# We give it a day's delay, since they _might_ have taken a conversion option in the event itself, in which case the follow-up event is invalid.
							days = 1
						}
					}
					# How exactly do they die?
					scope:unlucky_guest = {
						# Cannibalist Germanic pagans will hang them, then eat them.
						trigger_event = fp1_other_decisions.1000
						if = {
							limit = { sacrifice_method_hang_n_fang_trigger = yes }
							death = {
								killer = scope:blotter
								death_reason = death_ritually_hung_then_eaten
							}
						}
						# All other Germanic pagans will hang them.
						else_if = {
							limit = { sacrifice_method_eat_em_trigger = yes }
							death = {
								killer = scope:blotter
								death_reason = death_ritually_eaten
							}
						}
						# All other cannibals will just eat them.
						else_if = {
							limit = { sacrifice_method_hang_em_trigger = yes }
							death = {
								killer = scope:blotter
								death_reason = death_ritually_hung
							}
						}
						# Fallback deaths go here; variants should be added above this point.
						else = {
							death = {
								killer = scope:blotter
								death_reason = death_sacrificed_to_gods
							}
						}
					}
				}
				## Naturally, if appropriate, you become a cannibal.
				activity_host = {
					if = {
						limit = {
							OR = {
								scope:activity.var:blot_sacrifice = flag:humans_regular
								scope:activity.var:blot_sacrifice = flag:humans_magnificent
							}
							scope:gf_faith = { has_doctrine_parameter = cannibalism_legal }
							NOT = { has_trait = cannibal }
						}
						add_trait = cannibal
					}
				}
				## Happify them appropriately.
				### First we do characters.
				if = {
					limit = {
						any_in_list = {
							list = happified_character_subjects_list
							count >= 1
						}
					}
					every_in_list = {
						list = happified_character_subjects_list
						custom = fp1_other_decisions.0003.happy_characters_list
						add_opinion = {
							target = scope:blotter
							modifier = fp1_held_grand_sacrifice_opinion
						}
						# And gain some opinion back from scope:blotter for turning up.
						hidden_effect = { gruesome_festivals_blotter_opinion_gain_of_guests_effect = yes }
					}
				}
				### Then we do titles.
				if = {
					limit = {
						any_in_list = {
							list = happified_title_subjects_list
							count >= 1
						}
					}
					every_in_list = {
						list = happified_title_subjects_list
						custom = fp1_other_decisions.0003.happy_titles_list
						add_county_modifier = {
							modifier = held_grand_sacrifice_fp1_modifier
							years = 7
						}
					}
				}
				# Take care of unhappy subjects.
				## Is building a list of unhappy subjects necessary?
				activity_host = {
					if = {
						limit = {
							OR = {
								scope:activity.var:blot_sacrifice = flag:humans_regular
								scope:activity.var:blot_sacrifice = flag:humans_magnificent
							}
						}
						# If so, then we build one.
						## Grabbing all sub-realm characters who dislike HumSac.
						every_courtier_or_guest = {
							limit = {
								faith = { dislikes_humsac_trigger = yes }
							}
							add_to_list = unhappified_character_subjects_list
						}
						every_vassal_or_below = {
							limit = {
								faith = { dislikes_humsac_trigger = yes }
							}
							add_to_list = unhappified_character_subjects_list
						}
						## Then all sub-realm counties.
						every_sub_realm_county = {
							limit = {
								faith = { dislikes_humsac_trigger = yes }
							}
							add_to_list = unhappified_title_subjects_list
						}
						# Before unhappifying them to taste.
						## Again, first characters.
						if = {
							limit = {
								any_in_list = {
									list = unhappified_character_subjects_list
									count >= 1
								}
							}
							every_in_list = {
								list = unhappified_character_subjects_list
								custom = fp1_other_decisions.0003.unhappy_characters_list
								add_opinion = {
									target = scope:blotter
									modifier = fp1_held_human_sacrifice_opinion
								}
							}
						}
						## Then counties.
						if = {
							limit = {
								any_in_list = {
									list = unhappified_title_subjects_list
									count >= 1
								}
							}
							every_in_list = {
								list = unhappified_title_subjects_list
								custom = fp1_other_decisions.0003.unhappy_titles_list
								add_county_modifier = {
									modifier = held_human_sacrifice_fp1_modifier
									years = 7
								}
							}
							# Flag this character as having upset people.
							set_variable = {
								name = offended_counties_with_humsac
								value = yes
								years = 7
							}
						}
					}
				}
			}
		}
		# Cannibalism cleanup.
		## Specifically, we want every ranking guest who might have gotten some human meat reserved to become a cannibal. We do this later in the block so that we've already built a solid list of invited vassals.
		if = {
			limit = {
				OR = {
					scope:activity.var:blot_sacrifice = flag:humans_regular
					scope:activity.var:blot_sacrifice = flag:humans_magnificent
				}
				scope:gf_faith = { has_doctrine_parameter = cannibalism_legal }
			}
			hidden_effect = {
				every_in_list = {
					list = happified_title_subjects_list
					limit = {
						# Filter out lowborns.
						exists = dynasty
						NOT = { has_trait = cannibal }
					}
					send_interface_toast = {
						title = fp1_other_decisions.0003.attendee_became_cannibal
						left_icon = scope:blotter
						add_trait = cannibal
					}
				}
			}
		}
	}

	# Faithful: focus on the faith.
	option = {
		name = fp1_other_decisions.0003.a
		# Only available if you follow the scope:gf_faith & have priests to impress at all.
		trigger = {
			faith = {
				this = scope:gf_faith
				has_doctrine = doctrine_theocracy_temporal
			}
		}

		scope:activity = {
			add_activity_log_entry = {
				key = gruesome_festival_faithful_faith_option_log
				score = 900
				show_in_conclusion = yes
				character = root
				activity_host = {
					# Your commitment to ritual earns you opinion with the priestly classes.
					if = {
						limit = {
							any_learning_councillor = { exists = this }
						}
						every_learning_councillor = {
							add_opinion = {
								target = scope:blotter
								modifier = pleased_opinion
								opinion = 50
							}
						}
					}
					if = {
						limit = {
							any_in_list = {
								list = happified_character_subjects_list
								gruesome_festivals_available_impressable_clergy = yes
							}
						}
						every_in_list = {
							list = happified_character_subjects_list
							custom = fp1_other_decisions.0003.b.clergy_list
							limit = { gruesome_festivals_available_impressable_clergy = yes }
							add_opinion = {
								target = scope:blotter
								modifier = pleased_opinion
								opinion = 40
							}
						}
					}
				}
			}
		}

		stress_impact = {
			zealous = major_stress_impact_loss
			cynical = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 0.5
				ai_sociability = -0.25
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = zealous
			}
			modifier = {	# Weight down for stress.
				add = 10
				has_trait = cynical
			}
		}
	}

	# Faithful: focus on the nobility.
	option = {
		name = fp1_other_decisions.0003.b
		# Must have actually got some other landed nobility coming, and be of the faith and able to take part fully.
		trigger = {
			faith = scope:gf_faith
			any_in_list = {
				list = happified_character_subjects_list
				gruesome_festivals_available_impressable_nobles = yes
			}
		}

		scope:activity = {
			add_activity_log_entry = {
				key = gruesome_festival_faithful_nobility_option_log
				score = 900
				show_in_conclusion = yes
				character = root
				# The nobles appreciate the extra attention you grace them with.
				every_in_list = {
					list = happified_character_subjects_list
					custom = fp1_other_decisions.0003.b.nobility_list
					limit = { gruesome_festivals_available_impressable_nobles = yes }
					add_opinion = {
						target = scope:blotter
						modifier = pleased_opinion
						opinion = 20
					}
				}
			}
		}

		stress_impact = {
			arrogant = medium_stress_impact_loss
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_energy = -0.25	# Just because there's a lot fewer nobles than peasants.
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = arrogant
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = humble
			}
		}
	}

	# Faithful: focus on the commoners.
	option = {
		name = fp1_other_decisions.0003.c
		# Must be of the faith and able to take part fully.
		trigger = { faith = scope:gf_faith }

		scope:activity = {
			add_activity_log_entry = {
				key = gruesome_festival_faithful_commoners_option_log
				score = 900
				show_in_conclusion = yes
				character = root
				# The commoners appreciate the extra attention.
				every_in_list = {
					list = happified_title_subjects_list
					custom = fp1_other_decisions.0003.happy_titles_list
					remove_county_modifier = held_grand_sacrifice_fp1_modifier
					add_county_modifier = {
						modifier = commoners_grand_sacrifice_fp1_modifier
						years = 7
					}
				}
			}
		}

		stress_impact = {
			humble = major_stress_impact_loss
			arrogant = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_energy = 0.25	# Just because there's a lot fewer nobles than peasants.
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = humble
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = arrogant
			}
		}
	}

	# Political: engage no more than is necessary.
	option = {
		name = fp1_other_decisions.0003.d
		# Must be an outsider.
		trigger = {
			faith != scope:gf_faith
		}

		scope:activity = {
			add_activity_log_entry = {
				key = gruesome_festival_faithful_nobility_option_log
				score = 900
				show_in_conclusion = yes
				character = root
				activity_host = {
					# You console yourself with a minor moral victory.
					add_stress = medium_stress_loss
				}
			}
		}


		stress_impact = {
			arrogant = major_stress_impact_loss
			humble = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 0.5
				ai_sociability = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = arrogant
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = humble
			}
		}
	}

	# Political: engage wholeheartedly.
	option = {
		name = fp1_other_decisions.0003.e
		# Must be an outsider.
		trigger = {
			faith != scope:gf_faith
		}

		scope:activity = {
			add_activity_log_entry = {
				key = gruesome_festival_faithful_nobility_option_log
				score = 900
				show_in_conclusion = yes
				character = root
				# The commoners appreciate the extra attention.
				every_in_list = {
					list = happified_title_subjects_list
					custom = fp1_other_decisions.0003.happy_titles_list
					remove_county_modifier = held_grand_sacrifice_fp1_modifier
					add_county_modifier = {
						modifier = commoners_grand_sacrifice_fp1_modifier
						years = 10
					}
				}
			}
		}

		stress_impact = {
			humble = major_stress_impact_loss
			arrogant = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_zeal = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = humble
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = arrogant
			}
		}
	}

	# Political: you know, they make some good points...
	option = {
		name = fp1_other_decisions.0003.f
		# Must be an outsider.
		trigger = {
			faith != scope:gf_faith
			# We only allow this under certain circumstances.
			OR = {
				# The vast majority of your sub-realm follows their faith.
				any_sub_realm_county = {
					percent >= 0.75
					faith = scope:gf_faith
				}
				# Their fervour is high, your fervour is low.
				## Normal people require a very stark difference.
				AND = {
					faith = { fervor <= 10 }
					scope:gf_faith = { fervor >= 90 }
				}
				## Cynics are a bit less fussed.
				AND = {
					faith = { fervor <= 25 }
					scope:gf_faith = { fervor >= 75}
				}
			}
		}

		# First, we save your old faith for reference.
		faith = { save_scope_as = old_faith }
		# Next, we convert your faith.
		set_character_faith_with_conversion = scope:gf_faith

		scope:activity = {
			add_activity_log_entry = {
				key = gruesome_festival_faithful_nobility_option_log
				score = 900
				show_in_conclusion = yes
				character = root
				activity_host = {
					# Then charge piety for the transition.
					## A sensible fee if they're reformed or you're both unreformed.
					if = {
						limit = {
							OR = {
								NOT = {
									scope:gf_faith = { has_doctrine_parameter = unreformed }
								}
								AND = {
									scope:old_faith = { has_doctrine_parameter = unreformed }
									scope:gf_faith = { has_doctrine_parameter = unreformed }
								}
							}
						}
						add_piety = -500
					}
					## A reasonable, though still extremely high, fee otherwise, as then you're reformed & they're unreformed.
					else = { add_piety = -2000 }
					# Finally, you get a nickname.
					if = {
						limit = {
							OR = {
								has_bad_nickname = yes
								has_any_nickname = no
							}
						}
						# Converting within your religion, you're a heretic.
						if = {
							limit = { scope:old_faith.religion = scope:gf_faith.religion }
							give_nickname = nick_the_heretic
						}
						# Converting outside of your religious family, you're a heathen.
						else_if = {
							limit = {
								OR = {
									AND = {
										scope:old_faith.religion = { is_in_family = rf_eastern }
										NOT = {
											scope:gf_faith.religion = { is_in_family = rf_eastern }
										}
									}
									AND = {
										scope:old_faith.religion = { is_in_family = rf_pagan }
										NOT = {
											scope:gf_faith.religion = { is_in_family = rf_pagan }
										}
									}
									AND = {
										scope:old_faith.religion = { is_in_family = rf_abrahamic }
										NOT = {
											scope:gf_faith.religion = { is_in_family = rf_abrahamic }
										}
									}
								}
							}
							give_nickname = nick_the_heathen
						}
						# And otherwise, you're an apostate.
						else = { give_nickname = nick_the_apostate }
					}
				}
			}
		}

		stress_impact = {
			trusting = medium_stress_impact_loss
			cynical = major_stress_impact_loss
			paranoid = medium_stress_impact_gain
			arrogant = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.25
				ai_zeal = -1
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = trusting
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = cynical
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = paranoid
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = arrogant
			}
		}
	}

	after = {
		# Take care of anyone who insulted you by not showing up.
		trigger_event = {
			id = fp1_other_decisions.0012
			months = 3
		}
	}
}

scripted_trigger gruesome_festivals_will_gain_cannibal_trait_trigger = {
	# Is human flesh potentially on the menu?
	scope:activity.var:gf_faith = { has_doctrine_parameter = cannibalism_legal }
	# Are you already a cannibal?
	NOT = { has_trait = cannibal }
	# Is HumSac taking place to give meat to serve?
	OR = {
		scope:activity.var:blot_sacrifice = flag:humans_regular
		scope:activity.var:blot_sacrifice = flag:humans_magnificent
	}
}

scripted_effect gruesome_festivals_turn_down_invitation_effect = {
	# Add this character to scope:blotter's list of non-attendees.
	save_temporary_scope_as = current_rejecter
	scope:blotter = {
		add_to_variable_list = {
			name = gf_guests_rejecting_invite_list
			target = scope:current_rejecter
		}
	}
	#This removes the character from the activity and reroutes them homeward
	root.current_travel_plan = { 
		if = {
			limit = { can_cancel = yes }
			cancel_travel_plan = yes
		}
	}
}

#	Vassal: chance to decline invitation.
fp1_other_decisions.0011 = {
	type = character_event
	title = fp1_other_decisions.0011.t
	desc = {
		desc = fp1_other_decisions.0011.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity.var:gf_faith = { has_doctrine_parameter = cannibalism_legal }
				}
				desc = fp1_other_decisions.0011.desc.cannibal_blot
			}
			desc = fp1_other_decisions.0011.desc.fallback
		}
		desc = fp1_other_decisions.0011.desc.outro
	}
	theme = party
	left_portrait = {
		character = scope:blotter
		animation = personality_honorable
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
	}

	# We divide our options between gaining the cannibal trait and not gaining the cannibal trait.
	## If gaining the cannibal trait, we make a bigger deal about attending, since we don't want the player to accidentally become a cannibal because they weren't paying attention.
	## If not gaining the cannibal trait (because no human flesh is being served or because you're already a cannibal), our options are a bit more varied.

	# Non-Cannibal Gain: go graciously.
	option = {
		name = fp1_other_decisions.0011.a
		trigger = { gruesome_festivals_will_gain_cannibal_trait_trigger = no }

		# Get some opinion with scope:blotter for turning up.
		show_as_tooltip = { gruesome_festivals_blotter_opinion_gain_of_guests_effect = yes }

		stress_impact = {
			forgiving = minor_stress_impact_loss
			gregarious = medium_stress_impact_loss
			vengeful = minor_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_vengefulness = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 10
				has_trait = forgiving
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = gregarious
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = vengeful
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = shy
			}
		}
	}

	# Non-Cannibal Gain: tell 'em to get stuffed.
	option = {
		name = fp1_other_decisions.0011.b
		trigger = { gruesome_festivals_will_gain_cannibal_trait_trigger = no }

		# Scope:blotter will doubtless notice you failed to turn up.
		custom_tooltip = fp1_other_decisions.0011.b.tt
		gruesome_festivals_turn_down_invitation_effect = yes

		stress_impact = {
			vengeful = minor_stress_impact_loss
			shy = medium_stress_impact_loss
			forgiving = minor_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_sociability = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 10
				has_trait = vengeful
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = shy
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = forgiving
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = gregarious
			}
		}
	}

	# Will Become Cannibal: go, and enjoy the HumSac to the fullest.
	option = {
		name = fp1_other_decisions.0011.c
		trigger = { gruesome_festivals_will_gain_cannibal_trait_trigger = yes }

		# You'll eventually gain the cannibal trait, too.
		show_as_tooltip = { add_trait = cannibal }
		# Get some opinion with scope:blotter for turning up.
		show_as_tooltip = { gruesome_festivals_blotter_opinion_gain_of_guests_effect = yes }

		stress_impact = {
			forgiving = minor_stress_impact_loss
			gregarious = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
			vengeful = minor_stress_impact_gain
			shy = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_vengefulness = -0.5
				ai_compassion = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 10
				has_trait = forgiving
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = gregarious
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = sadistic
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = vengeful
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = shy
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = compassionate
			}
		}
	}

	# Will Become Cannibal: go, but refuse to partake in human flesh.
	option = {
		name = fp1_other_decisions.0011.d
		trigger = { gruesome_festivals_will_gain_cannibal_trait_trigger = yes }

		# Costs you a bit of extra piety, but you do opt out of the cannibal option.
		add_piety = medium_piety_loss
		# Get some opinion with scope:blotter for turning up.
		show_as_tooltip = { gruesome_festivals_blotter_opinion_gain_of_guests_effect = yes }

		stress_impact = {
			forgiving = minor_stress_impact_loss
			gregarious = medium_stress_impact_loss
			compassionate = medium_stress_impact_loss
			vengeful = minor_stress_impact_gain
			shy = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_compassion = 0.5
				ai_vengefulness = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 10
				has_trait = forgiving
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = gregarious
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = compassionate
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = vengeful
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = shy
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = sadistic
			}
		}
	}

	# Will Become Cannibal: not a chance in GetFaith.GetNegativeAfterLife!
	option = {
		name = fp1_other_decisions.0011.e
		trigger = { gruesome_festivals_will_gain_cannibal_trait_trigger = yes }

		# Costs you a bit of extra piety, but you do opt out of the cannibal option.
		add_piety = medium_piety_loss
		# Scope:blotter will doubtless notice you failed to turn up.
		custom_tooltip = fp1_other_decisions.0011.e.tt
		gruesome_festivals_turn_down_invitation_effect = yes

		stress_impact = {
			vengeful = minor_stress_impact_loss
			shy = medium_stress_impact_loss
			forgiving = minor_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_sociability = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 10
				has_trait = vengeful
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = shy
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = forgiving
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = gregarious
			}
		}
	}
}

#	Blotter: at least one vassal declined your invitation.
fp1_other_decisions.0012 = {
	type = character_event
	title = fp1_other_decisions.0012.t
	desc = {
		desc = fp1_other_decisions.0012.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { exists= scope:decliner_2 }
				desc = fp1_other_decisions.0012.desc.multiple_decliners
			}
			desc = fp1_other_decisions.0012.desc.single_decliner
		}
		desc = fp1_other_decisions.0012.desc.outro
	}
	theme = party
	left_portrait = {
		character = scope:decliner_1
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:decliner_2
		animation = personality_honorable
	}
	lower_left_portrait = { character = scope:decliner_3 }
	lower_center_portrait = { character = scope:decliner_4 }
	lower_right_portrait = { character = scope:decliner_5 }
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
		# Do you have the appropriate variable list, and is there anyone actually in it?
		has_variable_list = gf_guests_rejecting_invite_list
		any_in_list = {
			variable = gf_guests_rejecting_invite_list
			is_alive = yes
			is_imprisoned = no
			count >= 1
		}
	}

	immediate = {
		# Work out which of our decliners is the worst and why.
		ordered_in_list = {
			variable = gf_guests_rejecting_invite_list
			max = gruesome_festival_gf_guests_rejecting_invite_list_max_value
			order_by = {
				value = 0

				# Weight up players a little.
				if = {
					limit = { is_ai = no }
					add = 10
				}
				# Then weight up by rank.
				## Kings.
				if = {
					limit = { highest_held_title_tier >= tier_kingdom }
					add = 25
				}
				## Dukes.
				if = {
					limit = { highest_held_title_tier = tier_duchy }
					add = 10
				}
				# And add a little for every held county.
				every_held_title = {
					title_tier = county
					add = 1
				}
				#If they somehow die or are imprisoned before this event
				if = {
					limit = {
						OR = {
							is_alive = no
							is_imprisoned = yes
						}
					}
					multiply = 0
				}
			}
			if = {
				limit = {
					NOT = { exists = scope:decliner_1 }
				}
				save_scope_as = decliner_1
			}
			else_if = {
				limit = {
					NOT = {
						this = scope:decliner_1
						exists = scope:decliner_2
					}
				}
				save_scope_as = decliner_2
			}
			else_if = {
				limit = {
					NOT = {
						this = scope:decliner_1
						this = scope:decliner_2
						exists = scope:decliner_3
					}
				}
				save_scope_as = decliner_3
			}
			else_if = {
				limit = {
					NOT = {
						this = scope:decliner_1
						this = scope:decliner_2
						this = scope:decliner_3
						exists = scope:decliner_4
					}
				}
				save_scope_as = decliner_4
			}
			else_if = {
				limit = {
					NOT = {
						this = scope:decliner_1
						this = scope:decliner_2
						this = scope:decliner_3
						this = scope:decliner_4
						exists = scope:decliner_5
					}
				}
				save_scope_as = decliner_5
			}
		}
		# Add them to a list for easy general management if there's more than one.
		scope:decliner_1 = { add_to_list = decliners_list }
		if = {
			limit = { exists = scope:decliner_2 }
			add_to_list = decliners_list
		}
		if = {
			limit = { exists = scope:decliner_3 }
			add_to_list = decliners_list
		}
		if = {
			limit = { exists = scope:decliner_4 }
			add_to_list = decliners_list
		}
		if = {
			limit = { exists = scope:decliner_5 }
			add_to_list = decliners_list
		}
		# Clean up the variable list.
		gruesome_sacrifices_clean_up_declining_guests_effect = yes
	}

	# Only the arch-offender annoys me!
	option = {
		name = fp1_other_decisions.0012.a

		# Inform scope:decliner_1.
		hidden_effect = {
			scope:decliner_1 = {
				send_interface_toast = {
					title = fp1_other_decisions.0012.a.decliner_toast.t
					left_icon = scope:blotter
					show_as_tooltip = {
						progress_towards_rival_effect = {
							REASON = rival_blotter_declined
							CHARACTER = scope:blotter
							OPINION = -30
						}
					}
				}
			}
		}
		# Then actual rivalry/opinion loss.
		progress_towards_rival_effect = {
			REASON = rival_blotter_declined
			CHARACTER = scope:decliner_1
			OPINION = -30
		}

		stress_impact = {
			forgiving = minor_stress_impact_loss
			vengeful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_rationality = -0.25
			}
			modifier = {	# Weight up for stress.
				add = 10
				has_trait = forgiving
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = vengeful
			}
		}
	}

	# Damn and blast the whole lot of them!
	option = {
		name = fp1_other_decisions.0012.b
		# Only available if more than one of them turned you down.
		trigger = { exists = scope:decliner_2 }

		# Inform the decliners.
		hidden_effect = {
			every_in_list = {
				list = decliners_list
				send_interface_toast = {
					title = fp1_other_decisions.0012.a.decliner_toast.t
					left_icon = scope:blotter
					show_as_tooltip = {
						progress_towards_rival_effect = {
							REASON = rival_blotter_declined
							CHARACTER = scope:blotter
							OPINION = -30
						}
					}
				}
			}
		}
		# Then actual rivalry/opinion loss.
		every_in_list = {
			list = decliners_list
			limit = {
				this != scope:blotter
			}
			custom = fp1_other_decisions.0012.b.all_decliners_list
			progress_towards_rival_effect = {
				REASON = rival_blotter_declined
				CHARACTER = scope:blotter
				OPINION = -30
			}
		}

		stress_impact = {
			forgiving = major_stress_impact_loss
			vengeful = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.75
				ai_rationality = -0.50
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = forgiving
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = vengeful
			}
		}
	}

	# Bah, who cares about a bunch of no-shows?
	option = {
		name = {
			trigger = {
				NOT = { exists = scope:decliner_2 }
			}
			text = fp1_other_decisions.0012.c.singular
		}
		name = {
			trigger = { exists = scope:decliner_2 }
			text = fp1_other_decisions.0012.c.plural
		}

		# Carefreeeeeeee!
		add_stress = medium_stress_loss
		# But it was still a slight.
		add_prestige = minor_prestige_loss

		stress_impact = {
			forgiving = medium_stress_impact_loss
			vengeful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_vengefulness = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = forgiving
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = vengeful
			}
		}
	}
}

##################################################
# GF Consequences
# by Ewan Cowhig Croft
# 0021 - 0040
##################################################

scripted_effect gruesome_festivals_martyred_a_hof_effect = {
	# We only show this here, actual effects are applied in the humsacd_a_hof_effect.
	show_as_tooltip = {
		$SACRIFICED_HOF$ = {
			faith = {
				change_fervor = {
					value = hof_humsacd_fervour_gain
					desc = fervor_gain_sacrficed_head_of_faith
				}
			}
			# Since the nickname is assigned elsewhere, if they've already gotten it, it's safe to show it again.
			if = {
				limit = { has_nickname = nick_the_martyr }
				give_nickname = nick_the_martyr
			}
		}
	}
}

# Your HoF was sacrificed.
fp1_other_decisions.0021 = {
	type = character_event
	title = fp1_other_decisions.0021.t
	desc = {
		desc = fp1_other_decisions.0021.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = holy_wars_forbidden }
				}
				desc = fp1_other_decisions.0021.desc.disallows_holy_wars
			}
			desc = fp1_other_decisions.0021.desc.allows_holy_wars
		}
	}
	theme = skull
	left_portrait = {
		character = scope:sacrificer
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:sacrificed_hof
		animation = fear
	}
	override_background = { reference = throne_room }

	immediate = {
		play_music_cue = "mx_cue_murder"
		gruesome_festivals_martyred_a_hof_effect = { SACRIFICED_HOF = scope:sacrificed_hof }
	}

	# What blasphemy is this?!
	option = {
		name = {
			trigger = { has_trait = zealous }
			text = fp1_other_decisions.0021.a.zealous
		}
		name = {
			trigger = { has_trait = cynical }
			text = fp1_other_decisions.0021.a.cynical
		}
		name = {
			trigger = {
				NOR = {
					has_trait = zealous
					has_trait = cynical
				}
			}
			text = fp1_other_decisions.0021.a.fallback
		}

		# Scope:hof_sacrificer has become immensely cheaper to holy war.
		if = {
			limit = {
				NOT = {
					scope:sacrificed_hof.faith = { has_doctrine_parameter = holy_wars_forbidden }
				}
			}
			custom_tooltip = fp1_other_decisions.0021.cheaper_holy_wars.tt
			custom_tooltip = fp1_other_decisions.0021.easier_holy_wars.tt
			custom_tooltip = fp1_other_decisions.0021.ghw_target_preference.tt
		}

		ai_chance = {
			# Only one option, so it doesn't much matter.
			base = 100
		}
	}
}

# You sacrificed a HoF & people are pissed.
fp1_other_decisions.0022 = {
	type = character_event
	title = fp1_other_decisions.0022.t
	desc = {
		desc = fp1_other_decisions.0022.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:sacrificed_hof.faith = { has_doctrine_parameter = holy_wars_forbidden }
				}
				desc = fp1_other_decisions.0022.desc.disallows_holy_wars
			}
			desc = fp1_other_decisions.0022.desc.allows_holy_wars
		}
	}
	theme = skull
	left_portrait = {
		character = scope:sacrificer
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:sacrificed_hof
		animation = fear
	}
	override_background = { reference = throne_room }

	trigger = {
		# We only want to get this event once per faith, since the effects don't really stack (except for fervour).
		NAND = {
			has_variable_list = humsacd_hofs_notified
			is_target_in_variable_list = {
				name = humsacd_hofs_notified
				target = scope:sacrificed_hof.faith
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_murder"
		gruesome_festivals_martyred_a_hof_effect = { SACRIFICED_HOF = scope:sacrificed_hof }
		# Stop repeats of the same event per person per faith.
		add_to_variable_list = {
			name = humsacd_hofs_notified
			target = scope:sacrificed_hof.faith
		}
		scope:sacrificed_hof = {
			save_scope_as = unlucky_guest
		}
	}

	# Oops and/or meh.
	option = {
		name = {
			trigger = {
				scope:sacrificed_hof.faith = { has_doctrine_parameter = holy_wars_forbidden }
			}
			text = fp1_other_decisions.0022.a.pacifists
		}
		name = {
			trigger = {
				NOT = {
					scope:sacrificed_hof.faith = { has_doctrine_parameter = holy_wars_forbidden }
				}
				has_trait = craven
			}
			text = fp1_other_decisions.0022.a.craven
		}
		name = {
			trigger = {
				NOR = {
					scope:sacrificed_hof.faith = { has_doctrine_parameter = holy_wars_forbidden }
					has_trait = craven
				}
			}
			text = fp1_other_decisions.0022.a.fallback
		}

		# Scope:hof_sacrificer has become immensely cheaper to holy war.
		if = {
			limit = {
				NOT = {
					scope:sacrificed_hof.faith = { has_doctrine_parameter = holy_wars_forbidden }
				}
			}
			custom_tooltip = fp1_other_decisions.0021.cheaper_holy_wars.tt
			custom_tooltip = fp1_other_decisions.0021.easier_holy_wars.tt
			custom_tooltip = fp1_other_decisions.0021.ghw_target_preference.tt
		}

		ai_chance = {
			# Only one option, so it doesn't much matter.
			base = 100
		}
	}
}

scripted_effect gruesome_festivals_own_faith_martyred_own_hof_effect = {
	add_piety_level = -5
	add_character_modifier = { modifier = ultimate_blasphemer_modifier }
	if = {
		limit = {
			faith = { has_doctrine_parameter = excommunication_active }
		}
		# Add excommunication directly, since no one specific requested this.
		add_excommunication_actual_effect = yes
	}
}

# Your HoF was sacrificed by someone sharing your faith for the sake of someone else's faith.
fp1_other_decisions.0023 = {
	type = character_event
	title = fp1_other_decisions.0023.t
	desc = {
		desc = fp1_other_decisions.0023.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:unlucky_guest.faith = { has_doctrine_parameter = excommunication_active }
				}
				desc = fp1_other_decisions.0023.desc.has_excommunication
			}
			desc = fp1_other_decisions.0023.desc.does_not_have_excommunication
		}
		desc = fp1_other_decisions.0023.desc.outro
	}
	theme = skull
	left_portrait = {
		character = scope:blotter
		animation = paranoia
	}
	right_portrait = {
		character = scope:unlucky_guest
		animation = fear
	}
	override_background = { reference = throne_room }

	immediate = {
		gruesome_festivals_martyred_a_hof_effect = { SACRIFICED_HOF = scope:unlucky_guest }
	}

	# This is unforgiveable!
	option = {
		name = fp1_other_decisions.0023.a
		trigger = {
			NOT = { has_trait = cynical }
		}

		# Indicate that scope:blotter is about to get the slap-down.
		scope:blotter = {
			show_as_tooltip = { gruesome_festivals_own_faith_martyred_own_hof_effect = yes }
		}

		ai_chance = {
			# Only one option, so it doesn't much matter.
			base = 100
		}
	}

	# What kind of a person are they?
	option = {
		name = fp1_other_decisions.0023.b
		trigger = { has_trait = cynical }

		# Indicate that scope:blotter is about to get the slap-down.
		scope:blotter = {
			show_as_tooltip = { gruesome_festivals_own_faith_martyred_own_hof_effect = yes }
		}

		ai_chance = {
			# Only one option, so it doesn't much matter.
			base = 100
		}
	}
}

# You sacrificed your OWN HoF, despite not even believing in the HumSac faith.
fp1_other_decisions.0024 = {
	type = character_event
	title = fp1_other_decisions.0024.t
	desc = {
		desc = fp1_other_decisions.0024.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:unlucky_guest.faith = { has_doctrine_parameter = excommunication_active }
				}
				desc = fp1_other_decisions.0024.desc.has_excommunication
			}
			desc = fp1_other_decisions.0024.desc.does_not_have_excommunication
		}
		desc = fp1_other_decisions.0024.desc.outro
	}
	theme = skull
	left_portrait = {
		character = scope:blotter
		animation = paranoia
	}
	right_portrait = {
		character = scope:unlucky_guest
		animation = fear
	}
	override_background = { reference = throne_room }

	trigger = {
		# If you converted away, you're golden.
		scope:blotter.faith = scope:unlucky_guest.faith
	}

	immediate = {
		gruesome_festivals_martyred_a_hof_effect = { SACRIFICED_HOF = scope:unlucky_guest }
		gruesome_festivals_own_faith_martyred_own_hof_effect = yes
	}

	# _What have I done?!_
	option = {
		name = fp1_other_decisions.0024.a
		trigger = { has_trait = zealous }

		# Naturally, this will cause a lot of stress.
		add_stress = monumental_stress_gain

		ai_chance = {
			# Only one option, so it doesn't much matter.
			base = 100
		}
	}

	# They're only a human, not divinity itself!
	option = {
		name = fp1_other_decisions.0024.b
		trigger = { has_trait = cynical }

		# Naturally, this will cause a lot of stress.
		add_stress = major_stress_gain

		ai_chance = {
			# Only one option, so it doesn't much matter.
			base = 100
		}
	}

	# It was my subjects, not me!
	option = {
		name = fp1_other_decisions.0024.c
		trigger = {
			NOR = {
				has_trait = zealous
				has_trait = cynical
			}
		}

		# Naturally, this will cause a lot of stress.
		add_stress = massive_stress_gain

		ai_chance = {
			# Only one option, so it doesn't much matter.
			base = 100
		}
	}
}

fp1_other_decisions.1000 = {
	type = character_event
	title = fp1_other_decisions.1000.t
	desc = fp1_other_decisions.1000.desc
	theme = skull
	left_portrait = {
		character = scope:blotter
		animation = personality_zealous
	}
	override_background = {
		trigger = {
			scope:blotter = {
				religion = religion:germanic_religion
			}
		}
		reference = fp1_tribal_temple
	}
	override_background = {
		trigger = {
			scope:blotter = {
				NOT = {
					religion = religion:germanic_religion
				}
			}
		}
		reference = temple_scope
	}

	option = {
		name = fp1_other_decisions.1000.a

		show_as_tooltip = {
			death = {
				killer = scope:blotter
				death_reason = death_sacrificed_to_gods
			}
		}
	}
}

##################################################
# GF Maintenance Events
# by Ewan Cowhig Croft
# 0061 - 0080
##################################################

#	Someone intending to sacrifice you has died
fp1_other_decisions.0062 = {
	hidden = yes

	immediate = {
		# If preparing a grand sacrifice, make sure your prisoners are relieved.
		if = {
			limit = { has_character_flag = gruesome_festivals_can_pick_human_sacrifice }
			every_prisoner = {
				limit = { has_character_modifier = gruesome_festivals_designated_sacrifice_fp1_modifier }
				designate_gruesome_festivals_sacrifice_modifier_removed_effect = { DESIGNATOR = root }
			}
		}
	}
}

#	Designated sacrifice has died
fp1_other_decisions.0063 = {
	hidden = yes

	immediate = {
		if = {
			limit = {
				has_character_modifier = gruesome_festivals_designated_sacrifice_fp1_modifier
				NOT = { has_character_flag = is_currently_being_sacrificed }
			}
			save_scope_as = designated_sacrifice
			if = {
				# Should always have an imprisoner, but just in case.
				limit = { exists = imprisoner }
				imprisoner = {
					send_interface_message = {
						type = event_religious_bad_with_text
						title = fp1_other_decisions.0063.t
						desc = fp1_other_decisions.0063.desc
						right_icon = scope:designated_sacrifice
					}
				}
			}
		}
	}
}

#	Someone with offended counties has lost them (via death or independence).
fp1_other_decisions.0064 = {
	hidden = yes

	trigger = { has_variable = offended_counties_with_humsac }

	immediate = { fp1_remove_humsac_offended_counties_effect = yes }
}

##################################################
# Stele Setup Events
# by Ewan Cowhig Croft & Linnéa Thimrén
# 0101 - 0120
##################################################

#	Select which type of stele you'll be raising.
fp1_other_decisions.0101 = {
	type = character_event
	title = fp1_other_decisions.0101.t
	desc = fp1_other_decisions.0101.desc
	theme = faith
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:ancestor
		animation = personality_zealous
	}
	lower_right_portrait = scope:foe
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
	}

	immediate = {
		# Save some variables as scopes for easy loc.
		if = {
			limit = { exists = var:ancestor_to_bury }
			var:ancestor_to_bury = { save_scope_as = ancestor }
		}
		if = {
			limit = { exists = var:recent_conquest_victory }
			var:recent_conquest_victory = { save_scope_as = foe }
		}
		if = {
			limit = { exists = var:recent_rank_increase }
			var:recent_rank_increase = { save_scope_as = new_title }
		}
	}

	# Bury an ancestor.
	option = {
		name = fp1_other_decisions.0101.a
		# For family.
		trigger = { has_variable = ancestor_to_bury }

		# Note the type going forwards.
		save_scope_value_as = {
			name = stele_type
			value = flag:ancestor
		}
		# Inform root & proceed.
		custom_tooltip = fp1_other_decisions.0101.a.tt
		trigger_event = fp1_other_decisions.0111

		stress_impact = {
			humble = medium_stress_impact_loss
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.25
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = humble
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = arrogant
			}
		}
	}

	# Commemorate a conquest.
	option = {
		name = fp1_other_decisions.0101.b
		# Won a war that gained them territory.
		trigger = { has_variable = recent_conquest_victory }

		# Note the type going forwards.
		save_scope_value_as = {
			name = stele_type
			value = flag:conquest
		}
		# Inform root & proceed.
		custom_tooltip = fp1_other_decisions.0101.b.tt
		trigger_event = fp1_other_decisions.0111

		stress_impact = {
			arrogant = minor_stress_impact_loss
			vengeful = medium_stress_impact_loss
			humble = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_honor = 0.25
			}
			modifier = {	# Weight up for stress.
				add = 10
				has_trait = arrogant
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = vengeful
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = humble
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = forgiving
			}
		}
	}

	# Memorialise an increase in rank.
	option = {
		name = fp1_other_decisions.0101.c
		# Marking going up a rank.
		trigger = { has_variable = recent_rank_increase }

		# Note the type going forwards.
		save_scope_value_as = {
			name = stele_type
			value = flag:promotion
		}
		# Inform root & proceed.
		custom_tooltip = fp1_other_decisions.0101.c.tt
		trigger_event = fp1_other_decisions.0111

		stress_impact = {
			arrogant = major_stress_impact_loss
			humble = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_greed = 0.25
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = arrogant
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = humble
			}
		}
	}

	# Actually, nahhhhhh.
	option = {
		name = fp1_other_decisions.0101.d

		# Give 'em their deposit back.
		add_gold = var:raise_stele_refund
		# Clear the cooldown.
		remove_decision_cooldown = raise_stele_decision

		# No stress impact for opting out.
		ai_chance = {
			# If the AI has opened the interface, it should pick an option.
			base = 0
		}
	}

	# Run some mild clean-up.
	after = {
		# Clean-up the refund value.
		remove_variable = raise_stele_refund
	}
}

scripted_effect fp1_apply_stele_effects = {
	# Apply content-specific effects.
	# Save ancillary characters.
	## Save the commissioning character.
	$LOCATION$ = {
		save_temporary_scope_as = stele_location
		set_variable = {
			name = stele_commissioner
			value = root
			years = fp1_stele_duration_value
		}
	}
	## Create a hidden dummy character from the local area to ascribe the carvings to.
	hidden_effect = {
		# Make the character.
		create_character = {
			age = 25
			random_traits = yes
			gender_female_chance = 50
			dynasty = none
			faith = $LOCATION$.faith
			culture = $LOCATION$.culture
			location = $LOCATION$.title_province
			save_scope_as = carver
		}
		# Save them in the designated county.
		$LOCATION$ = {
			set_variable = {
				name = stele_carver
				value = scope:carver
				years = fp1_stele_duration_value
			}
		}
		# Kill them off.
		scope:carver = {
			death = { death_reason = death_vanished }
		}
	}
	## Ancestor effects.
	if = {
		limit = { scope:stele_type = flag:ancestor }
		$LOCATION$ = {
			# Set up the container for loc.
			set_variable = {
				name = stele_container
				value = root.var:ancestor_to_bury
				years = fp1_stele_duration_value
			}
			# Plus we want to remember the _type_ of stele we've got, so we can check if it's a character or title in there later.
			set_variable = {
				name = stele_scope_type
				value = flag:character
				years = fp1_stele_duration_value
			}
			# Add the actual modifier.
			## Stronger version for counties with stele-liking cultures.
			if = {
				limit = { fp1_can_raise_stele_title_scope_trigger = yes }
				add_county_modifier = {
					modifier = fp1_stele_ancestors_strong
					years = fp1_stele_duration_value
					desc = fp1_stele_ancestors_strong_custom_desc
				}
			}
			## Weaker version for counties with cultures that don't.
			else = {
				add_county_modifier = {
					modifier = fp1_stele_ancestors_weak
					years = fp1_stele_duration_value
					desc = fp1_stele_ancestors_strong_custom_desc
				}
			}
			# Add a generic flag for easy value adjustments elsewhere.
			set_variable = {
				name = stele_slot_occupied
				value = yes
				years = fp1_stele_duration_value
			}
		}
	}
	## Conquest effects.
	if = {
		limit = { scope:stele_type = flag:conquest }
		$LOCATION$ = {
			# Set up the container for loc.
			set_variable = {
				name = stele_container
				value = root.var:recent_conquest_victory
				years = fp1_stele_duration_value
			}
			# Plus we want to remember the _type_ of stele we've got, so we can check if it's a character or title in there later.
			set_variable = {
				name = stele_scope_type
				value = flag:character
				years = fp1_stele_duration_value
			}
			# Add the actual modifier.
			## Stronger version for counties with stele-liking cultures.
			if = {
				limit = { fp1_can_raise_stele_title_scope_trigger = yes }
				add_county_modifier = {
					modifier = fp1_stele_conquest_strong
					years = fp1_stele_duration_value
					desc = fp1_stele_conquest_strong_custom_desc
				}
			}
			## Weaker version for counties with cultures that don't.
			else = {
				add_county_modifier = {
					modifier = fp1_stele_conquest_weak
					years = fp1_stele_duration_value
					desc = fp1_stele_conquest_strong_custom_desc
				}
			}
			# Add a generic flag for easy value adjustments elsewhere.
			set_variable = {
				name = stele_slot_occupied
				value = yes
				years = fp1_stele_duration_value
			}
		}
	}
	## Promotion effects.
	if = {
		limit = { scope:stele_type = flag:promotion }
		$LOCATION$ = {
			# Set up the container for loc.
			set_variable = {
				name = stele_container
				value = root.var:recent_rank_increase
				years = fp1_stele_duration_value
			}
			# Plus we want to remember the _type_ of stele we've got, so we can check if it's a character or title in there later.
			set_variable = {
				name = stele_scope_type
				value = flag:title
				years = fp1_stele_duration_value
			}
			# Add the actual modifier.
			## Stronger version for counties with stele-liking cultures.
			if = {
				limit = { fp1_can_raise_stele_title_scope_trigger = yes }
				add_county_modifier = {
					modifier = fp1_stele_promotion_strong
					years = fp1_stele_duration_value
					desc = fp1_stele_promotion_strong_custom_desc
				}
			}
			## Weaker version for counties with cultures that don't.
			else = {
				add_county_modifier = {
					modifier = fp1_stele_promotion_weak
					years = fp1_stele_duration_value
					desc = fp1_stele_promotion_strong_custom_desc
				}
			}
			# Add a generic flag for easy value adjustments elsewhere.
			set_variable = {
				name = stele_slot_occupied
				value = yes
				years = fp1_stele_duration_value
			}
		}
	}
}

#	With type chosen, select a specific location.
fp1_other_decisions.0111 = {
	type = character_event
	title = fp1_other_decisions.0111.t
	desc = {
		desc = fp1_other_decisions.0111.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:stele_type = flag:ancestor }
				desc = fp1_other_decisions.0111.desc.ancestor
			}
			triggered_desc = {
				trigger = { scope:stele_type = flag:conquest }
				desc = fp1_other_decisions.0111.desc.conquest
			}
			triggered_desc = {
				trigger = { scope:stele_type = flag:promotion }
				desc = fp1_other_decisions.0111.desc.promotion
			}
		}
		desc = fp1_other_decisions.0111.desc.outro
	}
	theme = faith
	left_portrait = {
		character = root
		# We grieve ancestors.
		triggered_animation = {
			trigger = { scope:stele_type = flag:ancestor }
			animation = grief
		}
		# And celebrate successes.
		triggered_animation = {
			trigger = {
				NOT = { scope:stele_type = flag:ancestor }
			}
			animation = personality_bold
		}
	}
	right_portrait = {
		character = scope:secondary_portrait
		# Ancestors show piety.
		triggered_animation = {
			trigger = { scope:stele_type = flag:ancestor }
			animation = personality_zealous
		}
		# Foes show disgust.
		triggered_animation = {
			trigger = { scope:stele_type = flag:conquest }
			animation = disgust
		}
	}
	override_background = { reference = fp1_runestone }

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
	}

	immediate = {
		# First, we need to grab all of root's personally held counties.
		every_held_title = {
			title_tier = county
			limit = {
				is_landless_type_title = no
			}
			add_to_list = personally_held_counties_list
		}
		# Then we sort them out according to the effectiveness of the modifiers.
		## Ancestor stelae want stele-valid areas with low popular opinion.
		if = {
			limit = { scope:stele_type = flag:ancestor }
			ordered_in_list = {
				list = personally_held_counties_list
				max = raise_stele_county_preference_cap_value
				order_by = raise_stele_variant_ancestor_value
				# Grab three options.
				if = {
					limit = {
						NOT = { exists = scope:location_a }
					}
					save_scope_as = location_a
				}
				else_if = {
					limit = {
						NOR = {
							this = scope:location_a
							exists = scope:location_b
						}
					}
					save_scope_as = location_b
				}
				else_if = {
					limit = {
						NOR = {
							this = scope:location_a
							this = scope:location_b
							exists = scope:location_c
						}
					}
					save_scope_as = location_c
				}
			}
		}
		## Conquest stelae want stele-valid areas with low control.
		else_if = {
			limit = { scope:stele_type = flag:conquest }
			ordered_in_list = {
				list = personally_held_counties_list
				max = raise_stele_county_preference_cap_value
				order_by = raise_stele_variant_conquest_value
				# Grab three options.
				if = {
					limit = {
						NOT = { exists = scope:location_a }
					}
					save_scope_as = location_a
				}
				else_if = {
					limit = {
						NOR = {
							this = scope:location_a
							exists = scope:location_b
						}
					}
					save_scope_as = location_b
				}
				else_if = {
					limit = {
						NOR = {
							this = scope:location_a
							this = scope:location_b
							exists = scope:location_c
						}
					}
					save_scope_as = location_c
				}
			}
		}
		## Promotion stelae want stele-valid areas with high development.
		else_if = {
			limit = { scope:stele_type = flag:promotion }
			ordered_in_list = {
				list = personally_held_counties_list
				max = raise_stele_county_preference_cap_value
				order_by = raise_stele_variant_promotion_value
				# Grab three options.
				if = {
					limit = {
						NOT = { exists = scope:location_a }
					}
					save_scope_as = location_a
				}
				else_if = {
					limit = {
						NOR = {
							this = scope:location_a
							exists = scope:location_b
						}
					}
					save_scope_as = location_b
				}
				else_if = {
					limit = {
						NOR = {
							this = scope:location_a
							this = scope:location_b
							exists = scope:location_c
						}
					}
					save_scope_as = location_c
				}
			}
		}
		# If, for some reason, we have no designated county, just pick their capital.
		else_if = {
			limit = {
				NOT = { exists = scope:location_a }
			}
			capital_county = { save_scope_as = location_a }
		}
		# Next, try to set up a secondary portrait.
		## Ancestors can be shown.
		if = {
			limit = { scope:stele_type = flag:ancestor }
			var:ancestor_to_bury = { save_scope_as = secondary_portrait }
		}
		## As can beaten foes.
		else_if = {
			limit = { scope:stele_type = flag:conquest }
			var:recent_conquest_victory = { save_scope_as = secondary_portrait }
		}
		## But there's no secondary character available for promotion steles.
		# Finally, take care of generic stele effects.
		fp1_apply_generic_stele_bonuses_effect = yes
	}

	# Scope:location_a sounds good.
	option = {
		name = fp1_other_decisions.0111.a

		# Sort the local stele.
		fp1_apply_stele_effects = { LOCATION = scope:location_a }

		# No stress impact for arbitrary choice.
		ai_chance = {
			# AI should always pick the best option.
			base = 100
		}
	}

	# Scope:location_b is a decent spot.
	option = {
		name = fp1_other_decisions.0111.b
		trigger = { exists = scope:location_b }

		# Sort the local stele.
		fp1_apply_stele_effects = { LOCATION = scope:location_b }

		# No stress impact for arbitrary choice.
		ai_chance = {
			# AI should always pick the best option; the first one.
			base = 0
		}
	}

	# Scope:location_c makes a fine choice.
	option = {
		name = fp1_other_decisions.0111.c
		trigger = { exists = scope:location_c }

		# Sort the local stele.
		fp1_apply_stele_effects = { LOCATION = scope:location_c }

		# No stress impact for arbitrary choice.
		ai_chance = {
			# AI should always pick the best option; the first one.
			base = 0
		}
	}

	# Run some mild clean-up.
	after = {
		# Remove used variables.
		if = {
			limit = { scope:stele_type = flag:ancestor }
			remove_variable = ancestor_to_bury
		}
		else_if = {
			limit = { scope:stele_type = flag:conquest }
			remove_variable = recent_conquest_victory
		}
		else_if = {
			limit = { scope:stele_type = flag:promotion }
			remove_variable = recent_rank_increase
		}
	}
}

#	Error suppression.
fp1_other_decisions.0112 = {
	hidden = yes
	orphan = yes

	immediate = {
		if = {
			limit = {
				exists = var:stele_scope_type
				exists = var:stele_container
				exists = var:stele_commissioner
				exists = var:stele_carver
			}
			# TIT-23473
			# No effect needed.
		}
	}
}

#	New holder for a county with a stele.
fp1_other_decisions.0113 = {
	hidden = yes
	orphan = yes

	trigger = {
		# Use expanded version if we have FP1.
		has_fp1_dlc_trigger = yes
		# Using a scripted effect here so we can look at the same trigger in the grant title interaction
		fp1_remove_stele_new_holder_trigger = {
			TITLE = scope:title
			PREVIOUS_HOLDER = scope:previous_holder
			NEW_HOLDER = root
		}
	}

	immediate = {
		# Blanket remove all types.
		scope:title = {
			remove_variable = stele_scope_type
			remove_variable = stele_container
			remove_variable = stele_carver
			remove_variable = stele_commissioner
			remove_variable = stele_slot_occupied
			remove_county_modifier = fp1_stele_ancestors_strong
			remove_county_modifier = fp1_stele_ancestors_weak
			remove_county_modifier = fp1_stele_conquest_strong
			remove_county_modifier = fp1_stele_conquest_weak
			remove_county_modifier = fp1_stele_promotion_strong
			remove_county_modifier = fp1_stele_promotion_weak
		}
	}
}
