﻿# Events for the Funeral activity
namespace = funeral
# 0000-0999: Maintenance events

# funeral.1000 - Share a memory about the deceased
# funeral.1010 - Grave Goods
# funeral.1020 - Title claimant: IT SHOULD'VE BEEN ME!
# funeral.1030 - Pet sadly mourning their former master
# funeral.1040 - The body is found to be incorrupt
# funeral.1050 - You are given a moment alone with the body, what do you do with that?
# funeral.1060 - I can mourn so much harder than you
# funeral.1070 - Child event, why is everyone so sad?
# funeral.1080 - Someone close is grieving the deceased, help them?
# funeral.1090 - You line up to see the body, what do you do at the front?
# funeral.1100 - The deceased truly was one of the greats
# funeral.1110 - Mourn intent event
# funeral.1120 - Offering of libations
# funeral.1130 - Stoic and bewailment funeral, a moment to mourn
# funeral.1140 - Soulmate gets quite upset about the death of their soulmate

####################################
# FUNERAL INTERRUPTION NOTIFICATIONS
# 0000-0999
####################################

#The host has died during the funeral - event for guests
# by James Beaumont
funeral.0001 = {
	type = character_event
	title = funeral.0001.t
	desc = funeral.0001.desc
	theme = funeral_activity
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_illness.dds"
	}
	left_portrait = {
		character = scope:host
	}
	
	option = {
		name = funeral.0001.a
		custom_tooltip = funeral.0001.a.tt
	}
}

# # Notif for Host Death - Player Heir
funeral.0002 = {
	type = character_event
	title = funeral.0002.t
	desc = funeral.0002.desc
	theme = realm

	left_portrait = {
		character = root
		animation = worry
	}

	option = { 
		name = funeral.0002.a
		custom_tooltip = funeral.0002.a.tt
	}
}

# Enter passive state - you arrived
funeral.0010 = {
	type = activity_event
	title = funeral.0010.t
	desc = {
		desc = funeral.0010.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					this = scope:host
				}
				desc = funeral.0010.self
			}
			triggered_desc = {
				trigger = {
					this != scope:host 
					OR = {
						has_relation_rival = scope:activity.activity_host
						reverse_opinion = {
							target = scope:activity.activity_host
							value < 0
						}
					}
				}
				desc = funeral.0010.dislikes_host
			}
			triggered_desc = {
				trigger = {
					this != scope:host 
					OR = {
						has_relation_rival = scope:activity.activity_host
						reverse_opinion = {
							target = scope:activity.activity_host
							value >= 40
						}
					}
				}
				desc = funeral.0010.likes_host
			}
			desc = funeral.0010.neutral
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					intent_target.location ?= root.location
				}
				desc = funeral.0010.intent_arrived
			}
			triggered_desc = {
				trigger = { exists = intent_target }
				desc = funeral.0010.intent
			}
		}
	}
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = sadness
	}
	center_portrait = {
		character = scope:deceased
		animation = dead
	}
	right_portrait = {
		trigger = {
			this != scope:host
		}
		character = scope:host
		animation = sadness
	}
	cooldown = { years = 1 }

	immediate = {
		play_music_cue = mx_cue_touching_moment
		if = {
			limit = {
				exists = scope:activity.var:body_to_bury
			}
			scope:activity.var:body_to_bury = { save_scope_as = deceased }
		}
	}

	option = {
		name = {
			trigger = {
				opinion = {
					target = scope:activity.activity_host
					value < 0
				}
			}
			text = funeral.0010.a.bad
		}
		name = {
			trigger = {
				opinion = {
					target = scope:activity.activity_host
					value >= 0
				}
			}
			text = funeral.0010.a.good
		}
		add_prestige = miniscule_piety_gain
	}
}

scripted_effect funeral_ending_rewards = {
	# Activity option legitimacy reward
	add_legitimacy_effect = { LEGITIMACY = funeral_end_legitimacy_gain }
	# Dish out le piety
	add_piety = funeral_end_piety_gain
	# Dish out le stress loss
	add_stress = funeral_end_stress_loss
}

# The funeral ceremony
funeral.0100 = {
	type = activity_event
	title = funeral.0100.t
	desc = {
		desc = funeral.0100.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = burial_funeral }
				}
				desc = funeral.0100.desc.intro2.burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = sky_burials_active }
				}
				desc = funeral.0100.desc.intro2.sky_burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = mummification_funeral }
				}
				desc = funeral.0100.desc.intro2.mummification
			}
			# Cremation used as fallback
			desc = funeral.0100.desc.intro2.cremation
		}
		# Triggered desc based on how we feel about the deceased
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						any_memory = {
							memory_type = rival_died
							memory_participant:dead_relation = scope:deceased
						}
						scope:deceased.killer ?= root
					}
				}
				desc = funeral.0100.desc.mid.hate
			}
			triggered_desc = {
				trigger = {
					any_memory = {
						OR = {
							has_memory_type = friend_died
							has_memory_type = lover_died
							has_memory_type = soulmate_died
						}
						memory_participant:dead_relation = scope:deceased
					}
				}
				desc = funeral.0100.desc.mid.love
			}
			triggered_desc = {
				trigger = {
					any_former_spouse = {
						this = scope:deceased
					}
				}
				desc = funeral.0100.desc.mid.spouse
			}
			triggered_desc = {
				trigger = {
					any_child = {
						even_if_dead = yes
						this = scope:deceased
					}
				}
				desc = funeral.0100.desc.mid.child
			}
			triggered_desc = {
				trigger = {
					primary_title = {
						any_past_holder = {
							this = scope:deceased
						}
					}
				}
				desc = funeral.0100.desc.mid.predecessor
			}
			triggered_desc = {
				trigger = {
					scope:deceased.age <= 25
				}
				desc = funeral.0100.desc.mid.young
			}
			triggered_desc = {
				trigger = {
					scope:deceased.age >= 60 # Pretty young to die nowadays but we're in the middle ages
				}
				desc = funeral.0100.desc.mid.old
			}
			desc = funeral.0100.desc.mid.fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = burial_funeral }
				}
				desc = funeral.0100.desc.outro.burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = sky_burials_active }
				}
				desc = funeral.0100.desc.outro.sky_burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = mummification_funeral }
				}
				desc = funeral.0100.desc.outro.mummification
			}
			# Cremation used as fallback
			desc = funeral.0100.desc.outro.cremation
		}
	}
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				always = yes
			}
			animation = sadness
		}
	}
	center_portrait = {
		character = scope:deceased
		animation = dead
	}
	right_portrait = {
		character = scope:priest
		animation = personality_zealous
	}
	cooldown = { years = 1 }

	immediate = {
		play_music_cue = mx_cue_personal_negative
		if = {
			limit = {
				exists = involved_activity.var:body_to_bury
			}
			involved_activity.var:body_to_bury = { save_scope_as = deceased }
		}
	}

	option = {
		name = funeral.0100.a
		trigger = {
			NOT = {
				faith = { has_doctrine_parameter = mummification_funeral }
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = funeral_conclusion_log
				show_in_conclusion = yes
				character = root 
				root = {
					funeral_ending_rewards = yes
				}
			}
		}
		hidden_effect = {
			scope:activity = {
				every_attending_character = {
					limit = {
						is_ai = no # This is a flavour event, no need to run it on AI
						this != scope:host
					}
					trigger_event = funeral.0101
				}
			}
		}
	}

	option = { # Get yourself a mummy :)
		name = funeral.0100.b
		trigger = {
			faith = { has_doctrine_parameter = mummification_funeral }
			has_dlc_feature = royal_court
		}
		scope:activity = {
			add_activity_log_entry = {
				key = funeral_conclusion_log
				show_in_conclusion = yes
				character = root 
				root = {
					funeral_ending_rewards = yes
					# Get your mummy!
					if = {
						limit = {
							scope:deceased.mummy_quality <= very_low_mummy_quality
						}
						create_artifact = {
							name = mummy_artifact
							description = mummy_artifact_desc
							rarity = common
							type = sculpture # Grandma is furniture now, sorry
							modifier = mummy_modifier_tier_1
							decaying = yes
							template = ce1_mummy_template
							visuals = statue
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < low_mummy_quality
						}
						create_artifact = {
							name = mummy_artifact
							description = mummy_artifact_desc
							rarity = masterwork
							type = sculpture
							modifier = mummy_modifier_tier_2
							decaying = yes
							template = ce1_mummy_template
							visuals = statue
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < medium_mummy_quality
						}
						create_artifact = {
							name = mummy_artifact
							description = mummy_artifact_desc
							rarity = masterwork
							type = sculpture
							modifier = mummy_modifier_tier_3
							decaying = yes
							template = ce1_mummy_template
							visuals = statue
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < high_mummy_quality
						}
						create_artifact = {
							name = mummy_artifact
							description = mummy_artifact_desc
							rarity = masterwork
							type = sculpture
							modifier = mummy_modifier_tier_4
							decaying = yes
							template = ce1_mummy_template
							visuals = statue
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < very_high_mummy_quality
						}
						create_artifact = {
							name = mummy_artifact
							description = mummy_artifact_desc
							rarity = famed
							type = sculpture
							modifier = mummy_modifier_tier_5
							decaying = yes
							template = ce1_mummy_template
							visuals = statue
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else = {
						create_artifact = {
							name = mummy_artifact
							description = mummy_artifact_desc
							rarity = illustrious
							type = sculpture
							modifier = mummy_modifier_tier_6
							decaying = yes
							template = ce1_mummy_template
							visuals = statue
							creator = root
							save_scope_as = mummy_artifact
						}
					}
				}
			}
		}
		hidden_effect = {
			scope:activity = {
				every_attending_character = {
					limit = {
						is_ai = no # This is a flavour event, no need to run it on AI
						this != scope:host
					}
					trigger_event = funeral.0101
				}
			}
		}
	}

	option = { # Get yourself some organs in jars
		name = funeral.0100.c
		trigger = {
			faith = { has_doctrine_parameter = mummification_funeral }
		}
		scope:activity = {
			add_activity_log_entry = {
				key = funeral_conclusion_log
				show_in_conclusion = yes
				character = root 
				root = {
					funeral_ending_rewards = yes
					# Get your mummy heart!
					if = {
						limit = {
							scope:deceased.mummy_quality <= very_low_mummy_quality
						}
						create_artifact = {
							name = mummy_jar_artifact
							description = mummy_jar_artifact_desc
							rarity = common
							type = miscellaneous
							modifier = mummy_jar_modifier_tier_1
							decaying = yes
							template = ce1_mummy_template
							visuals = glazed_jar
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < low_mummy_quality
						}
						create_artifact = {
							name = mummy_jar_artifact
							description = mummy_jar_artifact_desc
							rarity = masterwork
							type = sculpture
							modifier = mummy_jar_modifier_tier_2
							decaying = yes
							template = ce1_mummy_template
							visuals = glazed_jar
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < medium_mummy_quality
						}
						create_artifact = {
							name = mummy_jar_artifact
							description = mummy_jar_artifact_desc
							rarity = masterwork
							type = sculpture
							modifier = mummy_jar_modifier_tier_3
							decaying = yes
							template = ce1_mummy_template
							visuals = glazed_jar
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < high_mummy_quality
						}
						create_artifact = {
							name = mummy_jar_artifact
							description = mummy_jar_artifact_desc
							rarity = masterwork
							type = sculpture
							modifier = mummy_jar_modifier_tier_4
							decaying = yes
							template = ce1_mummy_template
							visuals = glazed_jar
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else_if = {
						limit = {
							scope:deceased.mummy_quality < very_high_mummy_quality
						}
						create_artifact = {
							name = mummy_jar_artifact
							description = mummy_jar_artifact_desc
							rarity = famed
							type = sculpture
							modifier = mummy_jar_modifier_tier_5
							decaying = yes
							template = ce1_mummy_template
							visuals = glazed_jar
							creator = root
							save_scope_as = mummy_artifact
						}
					}
					else = {
						create_artifact = {
							name = mummy_jar_artifact
							description = mummy_jar_artifact_desc
							rarity = illustrious
							type = sculpture
							modifier = mummy_jar_modifier_tier_6
							decaying = yes
							template = ce1_mummy_template
							visuals = glazed_jar
							creator = root
							save_scope_as = mummy_artifact
						}
					}
				}
			}
		}
		hidden_effect = {
			scope:activity = {
				every_attending_character = {
					limit = {
						is_ai = no # This is a flavour event, no need to run it on AI
						this != scope:host
					}
					trigger_event = funeral.0101
				}
			}
		}
	}

	option = { # I don't want a mummy
		name = funeral.0100.d
		trigger = {
			faith = { has_doctrine_parameter = mummification_funeral }
		}
		scope:activity = {
			add_activity_log_entry = {
				key = funeral_conclusion_log
				show_in_conclusion = yes
				character = root 
				root = {
					add_piety = major_piety_gain
					funeral_ending_rewards = yes
				}
			}
		}
		hidden_effect = {
			scope:activity = {
				every_attending_character = {
					limit = {
						is_ai = no # This is a flavour event, no need to run it on AI
						this != scope:host
					}
					trigger_event = funeral.0101
				}
			}
		}
	}
}

# The funeral ceremony (guests)
funeral.0101 = {
	type = activity_event
	title = funeral.0101.t
	desc = {
		desc = funeral.0101.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = burial_funeral }
				}
				desc = funeral.0101.desc.intro2.burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = sky_burials_active }
				}
				desc = funeral.0101.desc.intro2.sky_burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = mummification_funeral }
				}
				desc = funeral.0101.desc.intro2.mummification
			}
			# Cremation used as fallback
			desc = funeral.0101.desc.intro2.cremation
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = burial_funeral }
				}
				desc = funeral.0101.desc.outro.burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = sky_burials_active }
				}
				desc = funeral.0101.desc.outro.sky_burial
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = mummification_funeral }
				}
				desc = funeral.0101.desc.outro.mummification
			}
			# Cremation used as fallback
			desc = funeral.0101.desc.outro.cremation
		}
	}
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = sadness
	}
	center_portrait = {
		character = scope:deceased
		animation = dead
	}
	right_portrait = {
		character = scope:priest
		animation = personality_zealous
	}
	cooldown = { years = 1 }

	immediate = {
		play_music_cue = mx_cue_personal_negative
		if = {
			limit = {
				exists = involved_activity.var:body_to_bury
			}
			involved_activity.var:body_to_bury = { save_scope_as = deceased }
		}
	}

	option = {
		name = funeral.0101.a
	}
}

####################################
# FUNERAL RANDOM EVENTS
# 0000-0999
####################################

####################################
# Random funeral events
# by James Beaumont
# 1000-1999
####################################

# Share a memory of the deceased
funeral.1000 = {
	type = activity_event
	title = funeral.1000.t
	desc = funeral.1000.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = sadness
	}
	center_portrait = {
		character = scope:deceased
		animation = dead
	}
	right_portrait = {
		character = scope:random_attendee
		animation = personality_rational
	}
	cooldown = { years = 10 }

	trigger = {
		scope:activity = {
			any_attending_character = {
				is_adult = yes
				this != root
				any_memory = {
					NOR = {
						has_memory_category = murder
						has_memory_category = negative
					}
					any_memory_participant = {
						this = scope:deceased
					}
				}
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = {
					is_adult = yes
					this != root
					any_memory = {
						NOR = {
							has_memory_category = murder
							has_memory_category = negative
						}
						any_memory_participant = {
							this = scope:deceased
						}
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						any_memory = {
							any_memory_participant = {
								this = scope:deceased
							}
							has_memory_category = positive
						}
					}
				}
				random_memory = {
					limit = {
						NOR = {
							has_memory_category = murder
							has_memory_category = negative
						}
						any_memory_participant = {
							this = scope:deceased
						}
					}
					weight = {
						base = 1
						modifier = {
							add = 10
							any_memory_participant = {
								this = scope:deceased
							}
							has_memory_category = positive
						}
					}
					save_scope_as = attendee_memory
				}
				save_scope_as = random_attendee
			}
		}
		add_character_flag = busy_in_banquet_event
	}

	option = { # Let us focus on mourning instead
		name = funeral.1000.a
		trigger = {
			has_activity_intent = mourn_intent
		}
		add_piety = medium_piety_gain
		stress_impact = {
			base = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_zeal = 0.5
				ai_rationality = 1
			}
		}
	}

	option = { # Lie and say you knew them well
		name = funeral.1000.b
		trigger = {
			NOT = {
				any_memory = {
					any_memory_participant = {
						this = scope:deceased
					}
					has_memory_category = positive
				}
			}
		}
		duel = {
			skill = intrigue
			target = scope:random_attendee
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1000.b.success
					left_icon = root
					right_icon = scope:random_attendee
					add_piety = major_piety_gain
					scope:activity = {
						every_attending_character = {
							limit = { this != root }
							custom = every_funeral_participant
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = 10
							}
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1000.b.failure
					left_icon = root
					right_icon = scope:random_attendee
					scope:activity = {
						every_attending_character = {
							limit = { this != root }
							custom = every_funeral_participant
							add_opinion = {
								target = root
								modifier = insult_opinion
								opinion = -15
							}
						}
					}
				}
			}
		}
		stress_impact = {
			honest = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -0.5
				ai_zeal = 0.5
			}
		}
	}

	option = { # Admit you have nothing
		name = funeral.1000.c
		trigger = {
			NOT = {
				any_memory = {
					any_memory_participant = {
						this = scope:deceased
					}
					has_memory_category = positive
				}
			}
		}
		stress_impact = {
			deceitful = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -0.5
				ai_zeal = 0.5
			}
		}
	}

	option = { # I'll never forget the good times
		name = funeral.1000.d
		trigger = {
			any_memory = {
				any_memory_participant = {
					this = scope:deceased
				}
				has_memory_category = positive
			}
		}
		duel = {
			skill = diplomacy
			target = scope:random_attendee
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1000.d.success
					left_icon = root
					right_icon = scope:random_attendee
					add_piety = major_piety_gain
					scope:activity = {
						every_attending_character = {
							limit = { this != root }
							custom = every_funeral_participant
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = 10
							}
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1000.d.failure
					left_icon = root
					right_icon = scope:random_attendee
					scope:activity = {
						every_attending_character = {
							limit = { this != root }
							custom = every_funeral_participant
							add_opinion = {
								target = root
								modifier = insult_opinion
								opinion = -5
							}
						}
					}
				}
			}
		}
		
		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_zeal = -0.5
			}
		}
	}

	option = { # This is not a competition
		name = funeral.1000.e
		trigger = {
			any_memory = {
				any_memory_participant = {
					this = scope:deceased
				}
				has_memory_category = positive
			}
		}
		add_piety = minor_piety_gain
		stress_impact = {
			arrogant = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# Grave Goods
# by James Beaumont
# 1010
####################################
funeral.1010 = {
	type = activity_event
	title = funeral.1010.t
	desc = funeral.1010.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:deceased
		animation = dead
	}
	artifact = {
		target = scope:masterwork_grave_good
		position = lower_left_portrait
	}
	artifact = {
		target = scope:famed_grave_good
		position = lower_center_portrait
	}
	artifact = {
		target = scope:illustrious_grave_good
		position = lower_right_portrait
	}
	cooldown = { years = 10 }

	trigger = {
		any_character_artifact = {
			any_recent_previous_owner = { OWNER = scope:deceased }
		}
	}

	immediate = {
		add_character_flag = busy_in_banquet_event
		if = {
			limit = {
				any_character_artifact = {
					rarity = common
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
			}
			random_character_artifact = {
				limit = {
					rarity = common
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
				save_scope_as = common_grave_good
			}
		}
		if = {
			limit = {
				any_character_artifact = {
					rarity = masterwork
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
			}
			random_character_artifact = {
				limit = {
					rarity = masterwork
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
				save_scope_as = masterwork_grave_good
			}
		}
		if = {
			limit = {
				any_character_artifact = {
					rarity = famed
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
			}
			random_character_artifact = {
				limit = {
					rarity = famed
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
				save_scope_as = famed_grave_good
			}
		}
		if = {
			limit = {
				any_character_artifact = {
					rarity = illustrious
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
			}
			random_character_artifact = {
				limit = {
					rarity = illustrious
					any_recent_previous_owner = { OWNER = scope:deceased }
				}
				save_scope_as = illustrious_grave_good
			}
		}
	}

	option = { # Bury him with your common artifact
		name = funeral.1010.a
		trigger = {
			exists = scope:common_grave_good
		}
		destroy_artifact_aniconist_effect = {
			ARTIFACT = scope:common_grave_good
			DESTROYER = root
			GIVE_GOLD = no
			PIETY_BY_DEFAULT = yes
		}
		if = {
			limit = {
				faith = { has_doctrine_parameter = family_rites }
				age < scope:deceased.age
			}
			add_merit_if_relevant_effect = {
				MERIT = miniscule_merit_value
			}
		}
		stress_impact = {
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_sociability = 0.5
				ai_zeal = 1
				ai_rationality = 1
			}
		}
	}

	option = { # Bury him with your masterwork artifact
		name = funeral.1010.b
		trigger = {
			exists = scope:masterwork_grave_good
		}
		destroy_artifact_aniconist_effect = {
			ARTIFACT = scope:masterwork_grave_good
			DESTROYER = root
			GIVE_GOLD = no
			PIETY_BY_DEFAULT = yes
		}
		if = {
			limit = {
				faith = { has_doctrine_parameter = family_rites }
				age < scope:deceased.age
			}
			add_merit_if_relevant_effect = {
				MERIT = minor_merit_value
			}
		}
		stress_impact = {
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_sociability = 0.5
				ai_zeal = 1
				ai_rationality = 1
			}
		}
	}

	option = { # Bury him with your famed artifact
		name = funeral.1010.c
		trigger = {
			exists = scope:famed_grave_good
		}
		destroy_artifact_aniconist_effect = {
			ARTIFACT = scope:famed_grave_good
			DESTROYER = root
			GIVE_GOLD = no
			PIETY_BY_DEFAULT = yes
		}
		if = {
			limit = {
				faith = { has_doctrine_parameter = family_rites }
				age < scope:deceased.age
			}
			add_merit_if_relevant_effect = {
				MERIT = medium_merit_value
			}
		}
		stress_impact = {
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			greedy = medium_stress_impact_gain
			generous = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_sociability = 0.5
				ai_zeal = 1
				ai_rationality = -2.5
			}
		}
	}

	option = { # Bury him with your illustrious artifact
		name = funeral.1010.d
		trigger = {
			exists = scope:illustrious_grave_good
		}
		destroy_artifact_aniconist_effect = {
			ARTIFACT = scope:illustrious_grave_good
			DESTROYER = root
			GIVE_GOLD = no
			PIETY_BY_DEFAULT = yes
		}

		if = {
			limit = {
				faith = { has_doctrine_parameter = family_rites }
				age < scope:deceased.age
			}
			add_merit_if_relevant_effect = {
				MERIT = major_merit_value
			}
		}

		stress_impact = {
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			greedy = medium_stress_impact_gain
			generous = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_sociability = 0.5
				ai_zeal = 1
				ai_rationality = -5
			}
		}
	}

	option = { # I will not bury shit.
		name = funeral.1010.e

		# Not offering goods to the young is the correct thing
		if = {
			limit = {
				faith = { has_doctrine_parameter = family_rites }
				age >= scope:deceased.age
			}
			add_merit_if_relevant_effect = {
				MERIT = miniscule_merit_value
			}
		}

		stress_impact = {
			generous = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -0.5
				ai_sociability = -0.5
				ai_zeal = -1
				ai_rationality = 1
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# Title claimant: IT SHOULD'VE BEEN ME!
# by James Beaumont
# 1020
####################################
funeral.1020 = {
	type = activity_event
	title = funeral.1020.t
	desc = funeral.1020.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:deceased
		animation = dead
	}
	cooldown = { years = 10 }

	trigger = {
		this != scope:host
		is_adult = yes
		scope:host.primary_title = {
			any_past_holder = { this = scope:deceased }
		}
		scope:host = {
			is_adult = yes
		}
		has_claim_on = scope:host.primary_title
	}

	immediate = {
		add_character_flag = busy_in_banquet_event
	}

	option = { # Now would be a good time to renounce my claim actually
		name = funeral.1020.c
		trigger = {
			has_trait = content
		}
		remove_claim = scope:host.primary_title
		add_piety = massive_piety_gain
		upgrade_to_friend_effect = {
			CHARACTER = scope:host
			REASON = friend_renounced_claim
		}
		add_legitimacy_effect = { LEGITIMACY = medium_legitimacy_gain }
		remove_character_flag = busy_in_banquet_event
		stress_impact = {
			ambitious = major_stress_impact_gain
			vengeful = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			content = massive_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
				ai_rationality = -2.5
				ai_vengefulness = -2.5
			}
		}
	}

	option = { # It shoulda been me!
		name = funeral.1020.a
		custom_tooltip = {
			text = unforseen_consequences_tt
			save_scope_as = claimant
			scope:host = {
				trigger_event = {
					id = funeral.1021
					days = { 1 3 }
				}
			}
		}
		stress_impact = {
			shy = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
			calm = minor_stress_impact_gain
			just = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			content = massive_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
				ai_rationality = -0.5
				ai_vengefulness = 2.5
			}
		}
	}

	option = { # I think this is not the right time or place
		name = funeral.1020.b
		remove_character_flag = busy_in_banquet_event
		stress_impact = {
			ambitious = major_stress_impact_gain
			vengeful = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
				ai_rationality = -0.5
				ai_vengefulness = 2.5
			}
		}
	}
}

# Host response event
funeral.1021 = {
	type = activity_event
	title = funeral.1021.t
	desc = funeral.1021.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:claimant
		animation = anger
	}
	cooldown = { years = 10 }

	immediate = {
		add_character_flag = busy_in_banquet_event
	}

	option = { # Ban them from the funeral
		name = funeral.1021.a
		scope:claimant = {
			send_interface_toast = {
				title = funeral.1021.a.toast
				left_icon = scope:host
				right_icon = scope:claimant
				downgrade_to_rival_effect = {
					CHARACTER = scope:host
					REASON = rival_pushed_claim_at_funeral
				}
				if = {
					limit = {
						has_weak_claim_on = scope:host.primary_title
					}
					add_pressed_claim = scope:host.primary_title
				}
				remove_from_activity = scope:activity
			}
		}
		stress_impact = {
			shy = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
			calm = minor_stress_impact_gain
			just = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			content = minor_stress_impact_gain
			vengeful = major_stress_impact_loss
			arrogant = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
				ai_rationality = -2.5
				ai_vengefulness = -2.5
			}
		}
	}

	option = { # Just ignore them
		name = funeral.1021.b
		scope:claimant = {
			send_interface_toast = {
				title = funeral.1021.b.toast
				left_icon = scope:host
				right_icon = scope:claimant
				add_prestige = medium_prestige_loss
				add_piety = medium_piety_loss
			}
		}
		stress_impact = {
			ambitious = major_stress_impact_gain
			vengeful = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
				ai_rationality = -0.5
				ai_vengefulness = 2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
		scope:claimant = { remove_character_flag = busy_in_banquet_event }
	}
}

####################################
# Pet sadly mourning their former master
# by James Beaumont
# 1030
####################################
funeral.1030 = {
	type = activity_event
	title = funeral.1030.t
	desc = funeral.1030.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	right_portrait = {
		character = scope:deceased
		animation = dead
	}
	cooldown = { years = 10 }

	trigger = {
		exists = var:dead_dog_owner
		var:dead_dog_owner = scope:deceased
	}

	immediate = {
		add_character_flag = busy_in_banquet_event
	}

	option = { # Adopt the pupper
		name = funeral.1030.a
		custom_tooltip = {
			text = funeral_1030_adopt_tt
			create_story = story_cycle_pet_dog
			set_variable = {
				name = story_cycle_dog_name
				value = var:parent_dog_name
			}
			set_variable = {
				name = dog_age_variable
				value = var:parent_dog_age
			}
			set_variable = {
				name = dog_fur_color
				value = var:parent_dog_fur_color
			}
			set_variable = {
				name = dog_eye_color
				value = var:parent_dog_eye_color
			}
			set_variable = {
				name = dog_gender
				value = var:parent_dog_gender
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			content = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
				ai_rationality = 1
				ai_vengefulness = -2.5
			}
		}
	}

	option = { # Shoo it away
		name = funeral.1030.b
		
		stress_impact = {
			base = minor_stress_impact_gain
			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
				ai_rationality = -2.5
				ai_vengefulness = 1
			}
		}
	}

	option = { # Kick it
		name = funeral.1030.c
		trigger = {
			has_trait = sadistic
		}
		scope:activity = {
			every_attending_character = {
				limit = {
					NOT = {
						this = root
						has_trait = sadistic
					}
				}
				custom = every_funeral_participant
				add_opinion = {
					target = root
					modifier = disgusted_opinion
					opinion = -10
				}
			}
		}
		stress_impact = {
			callous = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
			compassionate = massive_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -5
				ai_compassion = -10
				ai_rationality = -2.5
				ai_vengefulness = 5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
		remove_variable = dead_dog_owner
		remove_variable = parent_dog_name
		remove_variable = parent_dog_age
		remove_variable = parent_dog_fur_color
		remove_variable = parent_dog_eye_color
		remove_variable = parent_dog_gender
	}
}

####################################
# The body is found to be incorrupt
# by James Beaumont
# 1040
####################################
funeral.1040 = {
	type = activity_event
	title = funeral.1040.t
	desc = funeral.1040.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:deceased
		animation = dead
	}
	cooldown = { years = 10 }

	trigger = {
		scope:activity = {
			exists = var:incorrupt_body # Determined when the funeral starts
		}
	}

	option = { # Of course! A miracle!
		name = funeral.1040.a
		add_piety = minor_piety_gain
		scope:deceased = {
			add_trait = saint
		}
		stress_impact = {
			cynical = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			content = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = 1
				ai_rationality = 1
				ai_zeal = -2.5
			}
		}
	}

	option = { # I shall play the Devil's advocate
		name = funeral.1040.b
		duel = {
			skill = learning
			value = decent_skill_rating
			# Success.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1040.b.success
					left_icon = root
					right_icon = scope:deceased
					add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
					add_piety = medium_piety_gain
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1040.b.failure
					left_icon = root
					right_icon = scope:deceased
					add_legitimacy_effect = { LEGITIMACY = miniscule_legitimacy_loss }
					add_piety = minor_piety_loss
					scope:deceased = {
						add_trait = saint
					}
				}
			}
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			paranoid = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = -1
				ai_rationality = -1
				ai_zeal = 2.5
			}
		}
	}

	option = { # Indeed, and I am just like him!
		name = funeral.1040.c
		trigger = {
			has_trait = theologian
		}
		add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
		add_piety = medium_piety_gain
		scope:deceased = {
			add_trait = saint
		}
		random = {
			chance = 5
			add_trait = saint
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			paranoid = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = -1
				ai_rationality = -1
				ai_zeal = 2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# You are given a moment alone with the body, what do you do with that?
# by James Beaumont
# 1050
####################################
funeral.1050 = {
	type = activity_event
	title = funeral.1050.t
	desc = funeral.1050.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = stoic_funeral }
				}
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = stoic_funeral }
			}
			animation = grief
		}
	}
	right_portrait = {
		character = scope:deceased
		animation = dead
	}
	cooldown = { years = 10 }

	option = { # Take a lock of hair
		name = funeral.1050.witch
		trigger = {
			is_witch_trigger = yes
		}
		trait = witch
		create_artifact = {
			name = dead_hair
			description = dead_hair_desc
			template = witchy_artifact_template
			rarity = common
			type = miscellaneous
			modifier = artifact_monthly_minor_prestige_5_modifier
			modifier = artifact_monthly_learning_lifestyle_xp_1_modifier
			decaying = yes
			visuals = pocket_pouch
			creator = root
		}
		random = {
			chance = 50
			add_piety = minor_piety_loss
		}
		stress_impact = {
			base = minor_stress_impact_loss
			cynical = minor_stress_impact_gain
			just = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_sociability = -1
				ai_rationality = 1
				ai_zeal = 2.5
			}
		}
	}

	option = { # Say a quiet prayer
		name = funeral.1050.a
		add_piety = medium_piety_gain
		stress_impact = {
			base = minor_stress_impact_gain # It's difficult to quietly do anything at a funeral if you ask me
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_sociability = -1
				ai_rationality = 1
				ai_zeal = 2.5
			}
		}
	}

	option = { # Sob gently
		name = funeral.1050.b
		trigger = {
			NOT = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
		}
		if = {
			limit = {
				faith = { has_doctrine_parameter = stoic_funeral }
			}
			add_piety = minor_piety_gain
		}
		stress_impact = {
			base = minor_stress_impact_loss
			compassionate = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = -1
				ai_zeal = -2.5
			}
		}
	}

	option = { # Sob ungently
		name = funeral.1050.c
		trigger = {
			OR = {
				faith = { has_doctrine_parameter = bewailment_funeral }
				# Sob for an elder
				AND = {
					faith = { has_doctrine_parameter = family_rites }
					age < scope:deceased.age
				}
			}
		}
		add_piety = minor_piety_gain
		if = {
			limit = {
				faith = { has_doctrine_parameter = family_rites }
				age < scope:deceased.age
			}
			add_merit_if_relevant_effect = {
				MERIT = minor_merit_value
			}
		}
		stress_impact = {
			base = major_stress_impact_loss
			compassionate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
				ai_rationality = 1
				ai_zeal = 2.5
			}
		}
	}

	option = { # Promise to be a better ruler
		name = funeral.1050.d
		add_character_modifier = {
			modifier = funeral_unrelenting_devotion
			years = 15
		}
		stress_impact = {
			base = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = -1
				ai_rationality = -1
				ai_zeal = 2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# I can mourn so much harder than you
# by James Beaumont
# 1060
####################################
funeral.1060 = {
	type = activity_event
	title = funeral.1060.t
	desc = funeral.1060.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = grief
	}
	right_portrait = {
		character = scope:other_mourner
		animation = wailing
	}
	cooldown = { years = 10 }

	trigger = {
		scope:activity = {
			any_attending_character = {
				this != root
				is_ai = yes
				is_adult = yes
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = {
					this != root
					is_ai = yes
					is_adult = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 100
						OR = {
							is_close_family_of = scope:deceased
							any_former_spouse = {
								this = scope:deceased
							}
						}
					}
					modifier = {
						add = 100
						any_memory = {
							OR = {
								has_memory_type = friend_died
								has_memory_type = lover_died
								has_memory_type = soulmate_died
							}
							memory_participant:dead_relation ?= scope:deceased
						}
					}
					modifier = {
						add = 10
						any_memory = {
							has_memory_participant = scope:deceased
							has_memory_category = positive
						}
					}
				}
				save_scope_as = other_mourner
			}
		}
	}

	option = { # Out-wail them!
		name = funeral.1060.a
		duel = {
			skills = { learning prowess }
			target = scope:other_mourner
			# Success.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1060.a.success
					left_icon = root
					right_icon = scope:other_mourner
					add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
					add_piety = medium_piety_gain
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1060.a.failure
					left_icon = root
					right_icon = scope:other_mourner
					add_legitimacy_effect = { LEGITIMACY = miniscule_legitimacy_loss }
					add_piety = minor_piety_loss
				}
			}
		}
		random = {
			chance = 50
			progress_towards_rival_effect = {
				REASON = rival_competitive_mourning
				CHARACTER = scope:other_mourner
				OPINION = default_rival_opinion
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			cynical = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_sociability = -1
				ai_zeal = 2.5
				ai_vengefulness = 2.5
			}
		}
	}

	option = { # Sob gently
		name = funeral.1060.b
		add_piety = medium_piety_gain
		stress_impact = {
			base = medium_stress_impact_loss
			compassionate = minor_stress_impact_loss
			vengeful = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = -1
				ai_zeal = -2.5
			}
		}
	}

	option = { # I miss them too...
		name = funeral.1060.c
		progress_towards_intent_effect = {
			REASON = friend_bonded_over_grief
			CHARACTER = scope:other_mourner
			FRIEND_FALLBACK = yes
		}
		stress_impact = {
			base = medium_stress_impact_loss
			compassionate = minor_stress_impact_loss
			vengeful = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = -1
				ai_zeal = -2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# Child, why is everyone so sad?
# by James Beaumont
# 1070
####################################
funeral.1070 = {
	type = activity_event
	title = funeral.1070.t
	desc = funeral.1070.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:other_mourner
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = stoic_funeral }
				}
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = stoic_funeral }
			}
			animation = grief
		}
	}
	cooldown = { years = 10 }

	trigger = {
		child_not_infant_trigger = yes
		child_not_teen_trigger = yes
		involved_activity = {
			any_attending_character = {
				NOT = {
					has_character_flag = funeral_1071
					this = root
				}
				is_adult = yes
			}
		}
	}

	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					NOT = {
						has_character_flag = funeral_1071
						this = root
					}
					is_adult = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 100
						OR = {
							is_close_or_extended_family_of = root
							is_vassal_or_below_of = root
						}
					}
					modifier = {
						factor = 2
						is_ai = no
					}
				}
				save_scope_as = other_mourner
			}
		}
		save_scope_as = confused_child
	}

	option = { # Why is everyone so sad?
		name = funeral.1070.a
		custom_tooltip = {
			text = mourner_gives_advice_tt
			scope:other_mourner = {
				trigger_event = funeral.1071
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			cynical = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
				ai_sociability = 1
			}
		}
	}

	option = { # Just quietly try to go along with it
		name = funeral.1070.b
		add_piety = minor_piety_gain
		stress_impact = {
			base = minor_stress_impact_gain
			curious = minor_stress_impact_gain
			bossy = minor_stress_impact_gain
			charming = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_compassion = 1
				ai_rationality = -1
				ai_zeal = 2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

# Adult follow-up
funeral.1071 = {
	type = activity_event
	title = funeral.1071.t
	desc = funeral.1071.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = stoic_funeral }
				}
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = stoic_funeral }
			}
			animation = grief
		}
	}
	right_portrait = {
		character = scope:confused_child
		animation = thinking
	}

	immediate = {
		add_character_flag = {
			flag = funeral_1071
			years = 10
		}
		add_character_flag = busy_in_banquet_event
	}

	option = { # It's nothing you need worry yourself about, child
		name = funeral.1071.a
		scope:confused_child = {
			send_interface_toast = {
				title = funeral.1071.a.tt
				left_icon = scope:confused_child
				right_icon = scope:other_mourner
				add_stress = minor_stress_impact_loss
			}
		}
		stress_impact = {
			cynical = minor_stress_impact_loss
			deceitful = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = 1
				ai_sociability = -1
				ai_zeal = -1
			}
		}
	}

	option = { # Deceased has gone to PositiveAfterLife, child
		name = {
			text = funeral.1071.b
		}
		name = {
			trigger = {
				faith = {
					has_doctrine_parameter = reincarnation_events_active
				}
			}
			text = funeral.1071.b.reincarnation
		}
		name = {
			trigger = {
				religion = religion:taoism_religion
			}
			text = funeral.1071.b.taoism
		}
		duel = {
			skill = learning
			target = scope:confused_child
			# Success.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1071.a.success
					left_icon = scope:other_mourner
					right_icon = scope:confused_child
					add_piety = medium_piety_gain
					scope:confused_child = {
						send_interface_toast = {
							title = funeral.1071.a.success.child
							left_icon = scope:confused_child
							right_icon = scope:other_mourner
							add_stress = minor_stress_loss
							add_character_modifier = {
								modifier = funeral_comfort
								years = 15
							}
							scope:other_mourner = {
								progress_towards_friend_effect = {
									REASON = friend_comforted_at_funeral
									CHARACTER = scope:confused_child
									OPINION = default_friend_opinion
								}
							}
						}
					}
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1071.a.failure
					left_icon = scope:other_mourner
					right_icon = scope:confused_child
					add_piety = minor_piety_loss
					scope:confused_child = {
						send_interface_toast = {
							title = funeral.1071.a.failure.child
							left_icon = scope:confused_child
							right_icon = scope:other_mourner
							add_stress = minor_stress_gain
							add_character_modifier = {
								modifier = funeral_existential_dread
								years = 15
							}
						}
					}
				}
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = 1
				ai_zeal = 2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# Someone close is grieving the deceased, help them?
# by James Beaumont
# 1080
####################################
funeral.1080 = {
	type = activity_event
	title = funeral.1080.t
	desc = funeral.1080.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:other_mourner
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	cooldown = { years = 10 }

	trigger = {
		scope:activity = {
			any_attending_character = {
				this != root
				is_ai = yes
				is_adult = yes
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = {
					this != root
					is_ai = yes
					is_adult = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 100
						is_close_or_extended_family_of = scope:deceased
					}
				}
				save_scope_as = other_mourner
			}
		}
	}

	option = { # I share in your grief
		name = funeral.1080.a
		trigger = {
			scope:host.faith = {
				has_doctrine_parameter = bewailment_funeral
			}
		}
		reason = faith
		progress_towards_friend_effect = {
			REASON = friend_cried_at_funeral_together
			CHARACTER = scope:other_mourner
			OPINION = default_friend_opinion
		}
		stress_impact = {
			base = medium_stress_impact_loss
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = 1
				ai_sociability = -1
				ai_zeal = -1
			}
		}
	}

	option = { # Now now, we must remain stonefaced
		name = funeral.1080.b
		trigger = {
			scope:host.faith = {
				has_doctrine_parameter = stoic_funeral
			}
		}
		reason = faith
		add_piety = medium_piety_gain
		reverse_add_opinion = {
			modifier = disrespect_opinion
			target = scope:other_mourner
			opinion = -25
		}
		stress_impact = {
			base = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_compassion = -1
				ai_rationality = 1
				ai_zeal = 2.5
			}
		}
	}

	option = { # A tear, Sarah Jane?
		name = funeral.1080.c
		duel = {
			skills = { learning diplomacy }
			target = scope:other_mourner
			# Success.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1080.c.success
					left_icon = root
					right_icon = scope:other_mourner
					add_piety = medium_piety_gain
					progress_towards_friend_effect = {
						REASON = friend_comforted_at_funeral
						CHARACTER = scope:other_mourner
						OPINION = default_friend_opinion
					}
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1080.c.failure
					left_icon = root
					right_icon = scope:other_mourner
					add_piety = minor_piety_loss
					reverse_add_opinion = {
						modifier = insulted_opinion
						target = scope:other_mourner
						opinion = -25
					}
				}
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = 1
				ai_zeal = -2.5
			}
		}
	}

	option = { # I had best do my own grieving
		name = funeral.1080.d
		stress_impact = {
			base = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_compassion = -1
				ai_rationality = -1
				ai_zeal = 1
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# You line up to see the body, what do you do at the front?
# by James Beaumont
# 1090
####################################
funeral.1090 = {
	type = activity_event
	title = funeral.1090.t
	desc = funeral.1090.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	right_portrait = {
		character = scope:deceased
		animation = dead
	}
	cooldown = { years = 10 }

	option = { # Wail like I've never wailed before
		name = funeral.1090.a
		trigger = {
			OR = {
				scope:host.faith = {
					has_doctrine_parameter = bewailment_funeral
				}
				AND = {
					scope:host.faith = { has_doctrine_parameter = family_rites }
					age < scope:deceased.age
				}
			}
		}
		reason = faith
		stress_impact = {
			base = medium_stress_impact_loss
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = 1
				ai_sociability = -1
				ai_zeal = -1
			}
		}
	}

	option = { # Quietly bow and move on
		name = funeral.1090.b
		trigger = {
			OR = {
				scope:host.faith = {
					has_doctrine_parameter = stoic_funeral
				}
				AND = {
					scope:host.faith = { has_doctrine_parameter = family_rites }
					age >= scope:deceased.age
				}
			}
		}
		add_piety = medium_piety_gain
		stress_impact = {
			base = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_compassion = -1
				ai_rationality = 1
				ai_zeal = 2.5
			}
		}
	}

	option = { # Whisper how glad you are that they're dead
		name = funeral.1090.c
		trigger = {
			OR = {
				any_memory = {
					memory_type = rival_died
					memory_participant:dead_relation = scope:deceased
				}
				scope:deceased.killer ?= root
			}
		}
		random = {
			chance = 25
			add_piety = minor_piety_loss
		}
		stress_impact = {
			base = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_compassion = -1
				ai_rationality = 1
				ai_zeal = 2.5
			}
		}
	}

	option = { # I will rule in their honor!
		name = funeral.1090.d
		duel = {
			skill = diplomacy
			value = decent_skill_rating
			# Success.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1090.d.success
					left_icon = root
					right_icon = scope:deceased
					add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1090.d.failure
					left_icon = root
					right_icon = scope:deceased
					add_legitimacy_effect = { LEGITIMACY = miniscule_legitimacy_loss }
					add_piety = minor_piety_loss
					scope:activity = {
						every_attending_character = {
							limit = { this != root }
							custom = every_funeral_participant
							add_opinion = {
								target = root
								modifier = insulted_opinion
								opinion = -10
							}
						}
					}
				}
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_loss
			shy = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = -1
				ai_rationality = 1
				ai_zeal = -2.5
			}
		}
	}

	option = { # They truly were great ;_;
		name = funeral.1090.e
		scope:activity = {
			every_attending_character = {
				limit = { this != root }
				custom = every_funeral_participant
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 15
				}
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = 1
				ai_zeal = 1
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# The deceased truly was one of the greats
# by James Beaumont
# 1100
####################################
funeral.1100 = {
	type = activity_event
	title = funeral.1100.t
	desc = funeral.1100.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:other_mourner
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	cooldown = { years = 10 }

	trigger = {
		scope:activity = {
			any_attending_character = {
				this != root
				is_ai = yes
				is_adult = yes
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = {
					this != root
					is_ai = yes
					is_adult = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 50
						is_close_or_extended_family_of = scope:deceased
					}
					modifier = {
						add = 100
						is_ruler = yes
					}
					modifier = {
						add = 1000
						exists = root.intent_target
						NOT = { root = { has_activity_intent = murder_attendee_intent } }
						this = root.intent_target
					}
				}
				save_scope_as = other_mourner
			}
		}
	}

	option = { # Truly one of the greats, but I will be greater still
		name = funeral.1100.a
		duel = {
			skill = diplomacy
			value = decent_skill_rating
			# Success.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1100.a.success
					left_icon = root
					right_icon = scope:deceased
					add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1100.a.failure
					left_icon = root
					right_icon = scope:other_mourner
					add_legitimacy_effect = { LEGITIMACY = miniscule_legitimacy_loss }
					add_piety = minor_piety_loss
					progress_towards_rival_effect = {
						REASON = rival_insulted_at_funeral
						CHARACTER = scope:other_mourner
						OPINION = default_rival_opinion
					}
				}
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_loss
			shy = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = -1
				ai_rationality = 1
				ai_zeal = -2.5
			}
		}
	}

	option = { # A fine person indeed
		name = funeral.1100.b
		add_piety = minor_piety_gain
		stress_impact = {
			arrogant = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = 1
				ai_zeal = 1
			}
		}
	}

	option = { # What did they mean to you?
		name = funeral.1100.c
		progress_towards_intent_effect = {
			REASON = friend_bonded_over_grief
			CHARACTER = scope:other_mourner
			FRIEND_FALLBACK = no
		}
		stress_impact = {
			gregarious = minor_stress_impact_loss
			arrogant = minor_stress_impact_gain
			shy = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 1
				ai_rationality = 1
				ai_zeal = -1
			}
		}
	}

	option = { # Please, I just wish to mourn quietly
		name = funeral.1100.d
		trigger = {
			has_activity_intent = mourn_intent
		}
		add_piety = minor_piety_gain
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_compassion = -1
				ai_rationality = 1
				ai_zeal = 1
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# Generico mourn intent
# by James Beaumont
# 1110
####################################
funeral.1110 = {
	type = activity_event
	title = funeral.1110.t
	desc = funeral.1110.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	cooldown = { years = 10 }

	trigger = {
		has_activity_intent = mourn_intent
	}

	option = { # It feels good to let it out
		name = funeral.1110.a
		reason = activity_intent
		if = {
			limit = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			add_stress = major_stress_loss
		}
		else = {
			add_stress = medium_stress_loss
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# The Offering of Libations
# by James Beaumont
# 1120
####################################
funeral.1120 = {
	type = activity_event
	title = funeral.1120.t
	desc = funeral.1120.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:other_mourner
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	cooldown = { years = 10 }

	trigger = {
		scope:activity = {
			any_attending_character = {
				this != root
				is_ai = yes
				is_adult = yes
				OR = { # They're likely to pour one out for ya boi
					has_trait = lifestyle_reveler
					has_trait = drunkard
					has_trait = gluttonous
					has_trait = hashishiyah
				}
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = {
					this != root
					is_ai = yes
					is_adult = yes
					OR = {
						has_trait = lifestyle_reveler
						has_trait = drunkard
						has_trait = gluttonous
						has_trait = hashishiyah
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 50
						is_close_or_extended_family_of = scope:deceased
					}
					modifier = {
						add = 100
						is_ruler = yes
					}
					modifier = {
						add = 1000
						exists = root.intent_target
						NOT = { root = { has_activity_intent = murder_attendee_intent } }
						this = root.intent_target
					}
				}
				save_scope_as = other_mourner
			}
		}
	}

	option = { # Wait, this is idolatry!
		name = funeral.1120.aniconist
		trigger = {
			OR = {
				religion = religion:islam_religion
				faith = { has_doctrine_parameter = destroying_artifacts_is_pious }
			}
			scope:host = {
				OR = {
					religion = religion:islam_religion
					faith = { has_doctrine_parameter = destroying_artifacts_is_pious }
				}
			}
		}
		reason = faith
		add_legitimacy_effect = { LEGITIMACY = miniscule_legitimacy_gain }
		add_piety = minor_piety_gain
		reverse_add_opinion = {
			target = scope:other_mourner
			modifier = humiliated_opinion
			opinion = -15
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -2.5
				ai_compassion = -2.5
				ai_greed = 2.5
				ai_zeal = 2.5
			}
		}
	}

	option = { # Pour one out for my guy
		name = funeral.1120.a
		add_legitimacy_effect = { LEGITIMACY = miniscule_legitimacy_gain }
		stress_impact = {
			arrogant = minor_stress_impact_gain
			gluttonous = minor_stress_impact_gain
			drunkard = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = -1
				ai_greed = -1
			}
		}
	}

	option = { # Buy a round for everyone to pour out!
		name = funeral.1120.b
		add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
		remove_short_term_gold = minor_gold_value
		scope:activity = {
			every_attending_character = {
				limit = { this != root }
				custom = every_funeral_participant
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 10
				}
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			gluttonous = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 2.5
				ai_compassion = 2.5
				ai_greed = -2.5
				ai_zeal = 1
			}
			modifier = {
				factor = 0
				short_term_gold <= minor_gold_value
			}
		}
	}

	option = { # Quietly sip on your drink
		name = funeral.1120.c
		add_piety = minor_piety_value
		scope:activity = {
			every_attending_character = {
				limit = { this != root }
				custom = every_funeral_participant
				add_opinion = {
					target = root
					modifier = disgusted_opinion
					opinion = -5
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			gluttonous = minor_stress_impact_loss
			drunkard = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -2.5
				ai_compassion = -2.5
				ai_greed = 2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# Stoic + bewailment, take a moment to mourn
# by James Beaumont
# 1130
####################################
funeral.1130 = {
	type = activity_event
	title = funeral.1130.t
	desc = {
		desc = funeral.1130.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
				desc = funeral.1130.desc.bewailment
			}
			desc = funeral.1130.desc.stoic
		}
		desc = funeral.1130.desc.outro
	}
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	cooldown = { years = 10 }

	trigger = {
		OR = {
			faith = { has_doctrine_parameter = bewailment_funeral }
			faith = { has_doctrine_parameter = stoic_funeral }
		}
	}

	option = { # Wail
		name = funeral.1130.a
		trigger = {
			faith = { has_doctrine_parameter = bewailment_funeral }
		}
		reason = faith
		add_piety = minor_piety_gain
		add_stress = medium_stress_loss
	}

	option = { # Be a bit sad but not too sad
		name = funeral.1130.b
		trigger = {
			faith = { has_doctrine_parameter = stoic_funeral }
		}
		reason = faith
		add_piety = medium_piety_gain
		add_stress = minor_stress_loss
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}

####################################
# Soulmate tries to poison themselves
# by James Beaumont
# 1140
####################################
funeral.1140 = {
	type = activity_event
	title = funeral.1140.t
	desc = funeral.1140.desc
	theme = funeral_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				faith = { has_doctrine_parameter = bewailment_funeral }
			}
			animation = wailing
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { has_doctrine_parameter = bewailment_funeral }
				}
			}
			animation = grief
		}
	}
	right_portrait = {
		character = scope:soulmate
		animation = wailing
	}
	cooldown = { years = 10 }

	trigger = {
		OR = { # Give the player the opportunity to prevent this
			is_ai = no
			scope:host = { is_ai = yes }
		}
		involved_activity = {
			any_attending_character = {
				this != root
				is_ai = yes
				is_adult = yes
				OR = {
					any_memory = {
						memory_type = soulmate_died
						memory_participant:dead_relation = scope:deceased
					}
					any_memory = {
						memory_type = became_soulmates
						memory_participant:new_soulmate = scope:deceased
					}
				}
				NOR = {
					# Don't care
					has_trait = callous
					has_trait = sadistic
					# Unlikely to do something like this
					has_trait = zealous
				}
			}
		}
	}

	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					this != root
					is_ai = yes
					is_adult = yes
					OR = {
						any_memory = {
							memory_type = soulmate_died
							memory_participant:dead_relation = scope:deceased
						}
						any_memory = {
							memory_type = became_soulmates
							memory_participant:new_soulmate = scope:deceased
						}
					}
					NOR = {
						# Don't care
						has_trait = callous
						has_trait = sadistic
						# Unlikely to do something like this
						has_trait = zealous
					}
				}
				save_scope_as = soulmate
			}
		}
	}

	option = { # Let me help
		name = funeral.1140.a
		duel = {
			skill = diplomacy
			target = scope:random_attendee
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1140.a.success
					left_icon = root
					right_icon = scope:random_attendee
					add_piety = major_piety_gain
					upgrade_to_friend_effect = {
						CHARACTER = scope:soulmate
						REASON = friend_saved_life
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = funeral.1140.a.failure
					left_icon = root
					right_icon = scope:soulmate
					scope:soulmate = {
						death = { death_reason = death_suicide }
					}
				}
			}
		}
		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 2.5
				ai_compassion = 10
				ai_zeal = 2.5
			}
		}
	}

	option = { # Stop them by force
		name = funeral.1140.b
		reverse_add_opinion = {
			modifier = hate_opinion
			target = scope:soulmate
			opinion = -50
		}
		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 2.5
				ai_compassion = 5
				ai_zeal = 1
			}
		}
	}

	option = { # Do a flip
		name = funeral.1140.c
		scope:soulmate = {
			death = { death_reason = death_suicide }
		}
		stress_impact = {
			base = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			just = medium_stress_impact_gain
			brave = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			content = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
			callous = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -2.5
				ai_compassion = -10
				ai_energy = -2.5
				ai_zeal = -2.5
			}
		}
	}

	after = {
		remove_character_flag = busy_in_banquet_event
	}
}
