﻿# Events for the Coronation activity
namespace = ach_coronation

################################################################################################################################
## Coronation Activity System Events
## 0000-0010
## by Jay Zaborowski
################################
# ach_coronation.0001 - Enter passive state - you arrived, establish the mood
# ach_coronation.0010 - The HoF arrives

######################
# Enter passive state - you arrived, establish the mood
# 0001
ach_coronation.0001 = {
	type = activity_event
	title = ach_coronation.0001.t
	desc = {
		# Opening
		first_valid = {
			triggered_desc = {
				trigger = { location = this.capital_province }
				desc = ach_coronation.0001.notravel
			}
			desc = ach_coronation.0001.travel
		}

		# Intro
		first_valid = {
			# You are the Host
			triggered_desc = {
				trigger = { this = scope:host }
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:host = { primary_title = title:e_hre }
								this = scope:host
							}
							desc = ach_coronation.0001.intro.hre_host
						}
						triggered_desc = {
							trigger = {
								scope:host = { primary_title = title:e_byzantium }
								this = scope:host
							}
							desc = ach_coronation.0001.intro.byzantine_host
						}
						triggered_desc = {
							trigger = {
								this = scope:host
								location = this.capital_province
							}
							desc = ach_coronation.0001.intro.notravel_host
						}
						desc = ach_coronation.0001.intro.host
					}
				}
			}
			# You are a Guest
			triggered_desc = {
				trigger = { this != scope:host }
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:host = { primary_title = title:e_hre }
							}
							desc = ach_coronation.0001.intro.hre
						}
						triggered_desc = {
							trigger = {
								scope:host = { primary_title = title:e_byzantium }
							}
							desc = ach_coronation.0001.intro.byzantine
						}
					}
				}
			}
		}

		# Ending
		first_valid = {
			# Host - Eccentric (so that it matches the rest of the loc)
			triggered_desc = {
				trigger = {
					this = scope:host
					has_trait = eccentric
				}
				desc = ach_coronation.0001.ending.host_eccentric
			}
			# Host
			triggered_desc = {
				trigger = { this = scope:host }
				desc = {
					random_valid = {
						triggered_desc = {
							trigger = {
								has_trait = cynical
								OR = {
									scope:priest ?= { is_important_hof_trigger = yes }
									faith = { has_doctrine_parameter = theocratic_coronation } # To give something to complain about
								}
							}
							desc = {
								first_valid = {
									triggered_desc = {
										trigger = { scope:priest ?= { is_important_hof_trigger = yes } }
										desc = ach_coronation.0001.ending.host_cynical_hof
									}
									triggered_desc = {
										trigger = { faith = { has_doctrine_parameter = theocratic_coronation } }
										desc = ach_coronation.0001.ending.host_cynical
									}
								}
							}
						}
						triggered_desc = {
							trigger = { has_trait = impatient }
							desc = ach_coronation.0001.ending.host_impatient
						}
						triggered_desc = {
							trigger = { has_trait = just }
							desc = ach_coronation.0001.ending.host_just
						}
						triggered_desc = {
							trigger = { has_trait = ambitious }
							desc = ach_coronation.0001.ending.host_ambitious
						}
						triggered_desc = {
							trigger = { has_trait = compassionate }
							desc = ach_coronation.0001.ending.host_compassionate
						}
						triggered_desc = {
							trigger = { has_trait = trusting }
							desc = ach_coronation.0001.ending.host_trusting
						}
						triggered_desc = {
							trigger = { has_trait = paranoid }
							desc = ach_coronation.0001.ending.host_paranoid
						}
						triggered_desc = {
							trigger = { has_trait = zealous }
							desc = ach_coronation.0001.ending.host_zealous
						}
						triggered_desc = {
							trigger = { has_trait = content }
							desc = ach_coronation.0001.ending.host_content
						}
						triggered_desc = {
							trigger = { has_trait = gregarious }
							desc = ach_coronation.0001.ending.host_gregarious
						}
						triggered_desc = {
							trigger = { has_trait = craven }
							desc = ach_coronation.0001.ending.host_craven
						}
						triggered_desc = {
							trigger = { has_trait = shy }
							desc = ach_coronation.0001.ending.host_shy
						}
						triggered_desc = {
							trigger = { has_trait = arrogant }
							desc = ach_coronation.0001.ending.host_arrogant
						}
						triggered_desc = {
							trigger = {
								OR = {
									has_trait = calm
									has_trait = lazy
								}
							}
							desc = ach_coronation.0001.ending.host_calm
						}
						triggered_desc = {
							trigger = { has_trait = gluttonous }
							desc = ach_coronation.0001.ending.host_gluttonous
						}
						triggered_desc = {
							trigger = { has_trait = arbitrary }
							desc = ach_coronation.0001.ending.host_arbitrary
						}
						desc = ach_coronation.0001.ending.host_neutral
					}
				}
			}
			# Guest
			triggered_desc = {
				trigger = { this != scope:host }
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = { scope:host = { has_any_bad_relationship_with_character_trigger = { CHARACTER = root } } }
							desc = ach_coronation.0001.ending.hostile_host
						}
						triggered_desc = {
							trigger = { scope:host = { has_any_good_relationship_with_character_trigger = { CHARACTER = root } } }
							desc = ach_coronation.0001.ending.friendly_host
						}
						desc = ach_coronation.0001.ending.neutral_host
					}
				}
			}
		}
	}

	center_portrait = {
		character = scope:host
		animation = idle
		camera = camera_center_large
	}

	lower_left_portrait = {
		character = root
		trigger = { this != scope:host }
	}
	lower_center_portrait = {
		character = scope:priest
		trigger = {
			this != scope:host
			scope:host.involved_activity ?= {
				has_activity_option = {
					category = special_type
					option = coronation_type_anointment
				}
			}
		}
	}

	theme = coronation_activity

	override_background = {
		reference = throne_room
	}

	immediate = {
		play_music_cue = mx_cue_majesty
		involved_activity = {
			activity_host = { save_scope_as = host }
			var:officiator ?= { save_scope_as = priest }
			if = {
				limit = {
					has_activity_option = {
						category = special_type
						option = coronation_type_anointment
					}
				}
				scope:host.faith.religious_head = { save_scope_as = priest }
			}
		}
		# Send out the papal fanfare
		if = {
			limit = {
				# Is the host's religious head
				scope:host.faith.religious_head ?= this
				# The HoF actually matters for the ceremony
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = coronation_type_anointment
					}
				}
				#HoF doesn't own or live there
				scope:activity.activity_location.county = {
					OR = {
						holder = scope:host
						holder = {
							any_liege_or_above = {
								this = scope:host
							}
						}
					}
					NOR = {
						holder = scope:priest
						holder = {
							any_liege_or_above = {
								this = scope:priest
							}
						}
					}
				}
				#tricksy patriarch
				trigger_if = {
					limit = {
						scope:priest = {
							is_landed = no
							liege ?= scope:host
						}
					}
					NOT = {
						scope:activity.activity_location.county = scope:host.capital_county
					}
				}
			}
			save_scope_as = hof
			coronation_hof_visit_effect = yes
			involved_activity = {
				every_attending_character = {
					limit = {
						OR = {
							# Only bother for player's and the Host
							is_ai = no
							this = scope:host
							# And anyone who might want to beg the pope for pardon
							has_trait = excommunicated
						}
					}
					trigger_event = ach_coronation.0010
				}
			}
		}
		scope:host = {
			if = {
				limit = {
					any_targeting_faction = {
						count > 1
					}
					any_targeting_faction = {
						OR = {
							faction_power >= 200
							discontent_per_month > 0
							trigger_if = {
								limit = {
									discontent_per_month > 0
								}
								months_until_max_discontent <= 8
							}
							AND = {
								OR = {
									faction_is_type = nation_fracturing_faction
									faction_is_type = claimant_faction
								}
								faction_power >= 100
							}
						}
					}
				}
				custom_tooltip = magnificence_badly_reduced_by_factions_tt
			}
			else_if = {
				limit = {
					any_targeting_faction = {
						count = 1
					}
					any_targeting_faction = {
						OR = {
							faction_power >= 200
							discontent_per_month > 0
							trigger_if = {
								limit = {
									discontent_per_month > 0
								}
								months_until_max_discontent <= 8
							}
							AND = {
								OR = {
									faction_is_type = nation_fracturing_faction
									faction_is_type = claimant_faction
								}
								faction_power >= 100
							}
						}
					}
				}
				custom_tooltip = magnificence_badly_reduced_by_faction_tt
			}
			else_if = {
				limit = {
					any_targeting_faction = {
						count > 1
					}
				}
				custom_tooltip = magnificence_reduced_by_factions_tt
			}
			else_if = {
				limit = {
					any_targeting_faction = {
						count = 1
					}
				}
				custom_tooltip = magnificence_reduced_by_faction_tt
			}
		}
		if = {
			limit = {
				this = scope:host
				involved_activity = { var:activity_special_type_progression >= 50 }
			}
			scope:host.dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
		}
		else_if = {
			limit = {
				this = scope:host
				involved_activity = { var:activity_special_type_progression >= 25 }
			}
			scope:host.dynasty = { add_dynasty_prestige = miniscule_dynasty_prestige_gain }
		}
	}

	option = {
		name = {
			trigger = {
				NOT = { this = scope:host }
				opinion = {
					target = scope:host
					value < 0
				}
			}
			text = ach_coronation.0001.a.bad
		}
		name = {
			trigger = {
				NOT = { this = scope:host }
				opinion = {
					target = scope:host
					value >= 0
				}
			}
			text = ach_coronation.0001.a.good
		}
		name = {
			trigger = {
				this = scope:host
				has_trait = eccentric
			}
			text = ach_coronation.0001.a.eccentric
		}
		name = {
			trigger = {
				this = scope:host
				NOT = { has_trait = eccentric }
			}
			text = ach_coronation.0001.a
		}
	}
}

######################
# The HoF Arrives
# 0010
scripted_trigger ach_coronation_0010_appropriate_hof_follower = {
	# Find a clergy member of the hof's religion
	faith.religion = scope:hof.faith.religion
	this != scope:hof
	this != scope:host
	this != scope:greeter
	# Who isn't the player
	is_physically_able_ai = yes
}

scripted_trigger ach_coronation_0010_friendly_hof_and_host = {
	scope:host = {
		OR = {
			has_any_good_relationship_with_character_trigger = { CHARACTER = scope:hof }
			reverse_opinion = {
				target = scope:hof
				value > medium_positive_opinion
			}
		}
	}
}

scripted_trigger ach_coronation_0010_hostile_hof_and_host = {
	OR = {
		scope:host = { has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:hof } }
		reverse_opinion = {
			target = scope:hof
			value < medium_negative_opinion
		}
	}
}

scripted_effect ach_coronation_0010_choose_greeters = {
	# Barons are underutilized and it is *their* city, and the Host is probably busy, so they get to meet the HoF
	if = {
		limit = { scope:coronation_site.barony.holder != scope:host }
		scope:coronation_site.barony.holder = { save_scope_as = greeter }
	}
	# If the host owns the province we still want the world to feel lively, try the local count instead
	else_if = {
		limit = { scope:coronation_site.barony.county.holder != scope:host }
		scope:coronation_site.barony.holder = { save_scope_as = greeter }
	}
	# If all else fails, the Host gets to be the greeter
	else = {
		limit = { scope:host.location = scope:coronation_site }
		scope:host = { save_scope_as = greeter }
	}

	if = {
		limit = {
			# Grab the greeter's court chaplain if they exist
			exists = scope:greeter.cp:councillor_court_chaplain
			# Make sure it isn't the player
			scope:greeter.cp:councillor_court_chaplain = { is_physically_able_ai = yes } 
		}
		scope:greeter.cp:councillor_court_chaplain = { save_scope_as = greeter_2 }
	}
	else = {
		involved_activity = {
			ordered_attending_character = {
				# Grab the most zealous priest of the hof's religion at the activity
				limit = {
					ach_coronation_0010_appropriate_hof_follower = yes
					is_clergy = yes
				}
				# Or any valid follower of their religion
				alternative_limit = {
					ach_coronation_0010_appropriate_hof_follower = yes
				}
				# Fallback
				alternative_limit = {
					this != scope:host
					this != scope:hof
					this != scope:greeter
				}
				order_by = ai_zeal
				save_scope_as = greeter_2
			}
		}
	}
}

ach_coronation.0010 = {
	type = activity_event
	title = ach_coronation.0010.t
	desc = { # Should have a lot of variety for different pope-analities
		desc = ach_coronation.0010.desc.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = { this = scope:greeter }
				desc = ach_coronation.0010.desc.desc_greeting.first_person
			}
			triggered_desc = {
				trigger = { this = scope:host }
				desc = ach_coronation.0010.desc.desc_greeting.host
			}
			desc = ach_coronation.0010.desc.desc_greeting.baron
		}
		random_valid = {
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = generous
							has_trait = profligate
							ai_greed < medium_negative_greed
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_first.generous
			}
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = greedy
							has_trait = avaricious
							ai_greed > medium_positive_greed
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_first.greedy
			}
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = compassionate
							ai_compassion > medium_positive_compassion
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_first.compassionate
			}
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = cynical
							ai_zeal < medium_negative_zeal
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_first.cynical
			}
			desc = ach_coronation.0010.desc.desc_first
		}
		random_valid = {
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = zealous
							ai_zeal > medium_positive_zeal
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_second.zealous
			}
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = wrathful
							has_trait = irritable
							has_trait = vengeful
							ai_vengefulness > medium_positive_vengefulness
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_second.wrathful
			}
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = lustful
							has_trait = rakish
							is_incestuous_trigger = yes
							is_deviant_trigger = yes
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_second.lustful
			}
			triggered_desc = {
				trigger = {
					scope:hof = { has_trait = gluttonous }
				}
				desc = ach_coronation.0010.desc.desc_second.gluttonous
			}
			triggered_desc = {
				trigger = {
					scope:hof = {
						OR = {
							has_trait = giant
							has_trait = strong
							has_trait = physique_good_3
							has_trait = physique_good_2
						}
					}
				}
				desc = ach_coronation.0010.desc.desc_second.strong
			}
			desc = ach_coronation.0010.desc.desc_second
		}
		first_valid = {
			# Universal
			triggered_desc = {
				trigger = { scope:hof.faith = { fervor <= 30 } }
				desc = ach_coronation.0010.desc.desc_ending.low_fervor
			}
			# Host
			triggered_desc = {
				trigger = { this = scope:host }
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = { has_trait = excommunicated }
							desc = ach_coronation.0010.desc.desc_ending.excommunicated_first_person
						}
						triggered_desc = {
							trigger = {
								ach_coronation_0010_friendly_hof_and_host = yes
								scope:hof = {
									opinion = {
										target = root
										value >= high_positive_opinion
									}
								}
							}
							desc = ach_coronation.0010.desc.desc_ending.opinion_very_good_first_person
						}
						triggered_desc = {
							trigger = { ach_coronation_0010_friendly_hof_and_host = yes }
							desc = ach_coronation.0010.desc.desc_ending.opinion_good_first_person
						}
						triggered_desc = {
							trigger = { ach_coronation_0010_hostile_hof_and_host = yes }
							desc = ach_coronation.0010.desc.desc_ending.opinion_bad_first_person
						}
						desc = ach_coronation.0010.desc.desc_ending.neutral_first_person
					}
				}
			}
			# Guest
			triggered_desc = {
				trigger = { this != scope:host }
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = { scope:host = { has_trait = excommunicated } }
							desc = ach_coronation.0010.desc.desc_ending.excommunicated
						}
						triggered_desc = {
							trigger = {
								ach_coronation_0010_friendly_hof_and_host = yes
								scope:hof = {
									opinion = {
										target = scope:host
										value >= high_positive_opinion
									}
								}
							}
							desc = ach_coronation.0010.desc.desc_ending.opinion_very_good
						}
						triggered_desc = {
							trigger = { ach_coronation_0010_friendly_hof_and_host = yes }
							desc = ach_coronation.0010.desc.desc_ending.opinion_good
						}
						triggered_desc = {
							trigger = { ach_coronation_0010_hostile_hof_and_host = yes }
							desc = ach_coronation.0010.desc.desc_ending.opinion_bad
						}
						desc = ach_coronation.0010.desc.desc_ending.neutral
					}
				}
			}
		}
	}

	left_portrait = {
		character = scope:greeter_2
		animation = horse_conversing_right
		camera = camera_event_horse_left_facing_left_far
	}

	center_portrait = {
		character = scope:greeter
		animation = horse_conversing_left
		camera = camera_event_horse_left_facing_left_very_far
	}

	right_portrait = {
		character = scope:hof
		# Are they the type to wave at peasants?
		triggered_animation = {
			trigger = { ai_compassion >= medium_positive_compassion }
			animation = jockey_wave
		}
		triggered_animation = {
			trigger = { always = yes }
			animation = jockey_idle
		}
		camera = camera_event_horse_right_facing_left_close
	}

	theme = coronation_activity

	override_background = {
		reference = market
	}
	override_effect_2d = {
		reference = legend_glow
	}

	# Horse and crowd noises instead of normal activity ones
	override_sound = { reference = "event:/DLC/EP3/SFX/Events/Event_Moments/ep3_evn_eventmoment_chariot_race_pivotal_moment" }

	immediate = {
		# Make it sound momentous
		play_sound_effect = "event:/DLC/EP2/SFX/Events/Grand_Activities/Tournaments/ep2_event_grand_tournament_win"
		play_sound_effect = "event:/DLC/EP3/SFX/Stingers/Byzantine_Flavor/ep3_mx_sting_byzantineflavor_hold_triumph"

		involved_activity.var:officiator ?= { save_scope_as = hof }
		scope:hof.location = { save_scope_as = coronation_site }

		hidden_effect = { ach_coronation_0010_choose_greeters = yes }
		show_as_tooltip = { coronation_hof_visit_effect = yes }
	}

	option = { # Beg him to unexcommunicate you
		name = ach_coronation.0010.a
		trigger = {
			has_trait = excommunicated
			faith.religious_head = scope:hof
			# Not getting off so easy
			this != scope:host
		}
		trait = excommunicated

		duel = {
			skill = diplomacy
			target = scope:hof
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = { # I got a soft spot and not much hate in my heart
					add = 20
					scope:hof = {
						ai_compassion >= high_positive_compassion
						opinion = {
							value >= low_negative_opinion
							target = root
						}
					}
				}
				modifier = {
					add = 5
					scope:hof = { has_trait = generous }
				}
				modifier = {
					factor = 2
					scope:hof = { has_trait = forgiving }
				}
				modifier = {
					factor = 0.5
					scope:hof = { has_trait = vengeful }
				}
				min = 5
				desc = ach_coronation.0010.a.tt.success
				send_interface_toast = {
					title = ach_coronation.0010.a.tt.success
					left_icon = scope:hof
					remove_trait = excommunicated
					stress_impact = {
						base = major_stress_loss
						arrogant = minor_stress_loss
						zealous = major_stress_loss
					}
					hidden_effect = {
						add_opinion = {
							target = scope:hof
							modifier = grateful_opinion
							opinion = 30
						}
					}
				}
				
			}
			50 = { # They ignore you
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					add = 5
					has_trait = arrogant
				}
				opinion_modifier = {
					who = scope:hof
					opinion_target = scope:host
					multiplier = 0.5
				}
				min = 5
				desc = ach_coronation.0010.a.tt.failure
				send_interface_toast = {
					title = ach_coronation.0010.a.tt.failure
					left_icon = scope:hof
					add_prestige = minor_prestige_loss
					if = {
						limit = { is_ai = yes }
					}
					stress_impact = {
						base = minor_stress_gain
						shy = minor_stress_loss # Honestly? Thank HighGod
					}
				}
			}
			20 = { # They're offended you even asked
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					add = 20
					OR = {
						has_trait = shy
						has_trait = reclusive
					}
				}
				modifier = {
					add = 5
					has_trait = impatient
				}
				opinion_modifier = {
					who = scope:hof
					opinion_target = root
					multiplier = -1
				}
				modifier = {
					factor = 1.5
					has_trait = wrathful
				}
				min = 5
				desc = ach_coronation.0010.a.tt.anger
				send_interface_toast = {
					title = ach_coronation.0010.a.tt.anger
					left_icon = scope:hof
					reverse_add_opinion = {
						target = scope:hof
						modifier = annoyed_opinion
						opinion = -30
					}
					add_prestige = minor_prestige_loss
					stress_impact = {
						base = medium_stress_gain
						arrogant = minor_stress_gain
						zealous = minor_stress_gain
						cynical = medium_stress_loss # Got one good thing out of it at least
					}
				}
			}
		}
		ai_chance = {
			base = 150
			modifier = {
				has_trait = shy
				factor = 0.5
			}
			modifier = {
				has_trait = zealous
				factor = 0.5
			}
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 2
			}
			# More likely if skilled at diplomacy
			modifier = {
				diplomacy > medium_skill_rating
				factor = 2
			}
			# Less likely if not
			modifier = {
				diplomacy <= medium_skill_rating
				factor = 0.5
			}
			# Way less likely if way not
			modifier = {
				diplomacy <= low_skill_rating
				# Unless you have zero ability to conceive your own diplomatic inferiority
				NOT = { has_trait = arrogant }
				factor = 0.5
			}
		}
	}

	option = { # "Neat"
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:hof } }
						desc = ach_coronation.0010.b.rival
					}
					triggered_desc = {
						trigger = { has_relation_lover = scope:hof }
						desc = ach_coronation.0010.b.lover
					}
					triggered_desc = {
						trigger = { has_any_good_relationship_with_character_trigger = { CHARACTER = scope:hof } }
						desc = ach_coronation.0010.b.friend
					}
					triggered_desc = {
						trigger = { faith.religion != scope:hof.faith.religion }
						desc = ach_coronation.0010.b.heathen
					}
					triggered_desc = {
						trigger = { faith != scope:hof.faith }
						desc = ach_coronation.0010.b.heretic
					}
					triggered_desc = {
						trigger = {
							OR = {
								is_witch_trigger = yes
								# Also fits if you're hiding your faith
								any_secret = {
									secret_type = secret_crypto_religionist
								}
							}
						}
						desc = ach_coronation.0010.b.witch
					}
					triggered_desc = {
						trigger = { has_trait = cynical }
						desc = ach_coronation.0010.b.cynical
					}
					triggered_desc = {
						trigger = { has_trait = zealous }
						desc = ach_coronation.0010.b.zealous
					}
					desc = ach_coronation.0010.b
				}
			}
		}
		if = {
			limit = { this = scope:host }
			custom_tooltip = ach_coronation_0010_hof_desc_host.tt
		}
		else = {
			custom_tooltip = ach_coronation_0010_hof_desc_guest.tt
		}
		ai_chance = {
			base = 100
		}
	}
}

####################################
# Random coronation events
# 0011-0499
## by Jay Zaborowski
####################################
# ach_coronation.0011 - Host: You see some potential plotters whispering
# ach_coronation.0012 - Host: Vassals squabble over coronation roles
# ach_coronation.0013 - Host: You eavesdrop on some peasants
# ach_coronation.0014 - Guest: Opportunity to cause a crowd crush
# ach_coronation.0015 - Host: There is a crowd crush
# ach_coronation.0016 - Guest: You present your host a gift
# ach_coronation.0017 - Guest: faith_warrior reacts to the coronation of a non-crusader_king
# ach_coronation.0018 - Guest: Close family member of Host sees opportunity
# ach_coronation.0020 - Host: Close family member helps manage the coronation
# ach_coronation.0022 - Guest: An ongoing plague has shaken a zealous guest
# ach_coronation.0023 - Host: An exotic foreign warrior pledges themselves to you
# ach_coronation.0025 - Open up drinks to the locals
# ach_coronation.0027 - A guest offers some hashish
# ach_coronation.0028 - Host: Drinking contest with a detractor
# ach_coronation.0029 - Host: Guests offer to help get a hunt going

######################
# Host: You see some potential plotters whispering
# 0011
scripted_trigger ach_coronation_0011_eligible_vassal_trigger = {
	is_physically_able_ai_adult = yes
	is_vassal_of = involved_activity.activity_host
	trigger_if = { # Should be someone you'd actually suspect
		limit = {
			scope:host = { # But what if they're in on it?
				NOT = { has_trait = paranoid }
			}
		}
		NOR = {
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = root }
			has_trait = loyal
		}
	}
}

scripted_trigger ach_coronation_0011_is_suitable_active_scheme_trigger = {
	is_scheme_exposed = no
	hostile_scheme_trigger = yes
	scheme_target_character = { is_participant_in_activity = involved_activity }
}

scripted_effect ach_coronation_0011_coward_setup_effect = {
	save_scope_as = coward
	if = { # If the plotter has a scheme and the coward's in on it, grab that
		limit = {
			scope:hostile_scheme ?= {
				any_scheme_agent_character = { this = scope:coward }
			}
		}
		scope:hostile_scheme = {
			save_scope_as = coward_scheme
		}
	}
	else_if = { # If the coward has a scheme of their own, grab that
		limit = {
			any_scheme = {
				ach_coronation_0011_is_suitable_active_scheme_trigger = yes
			}
		}
		random_scheme = {
			limit = { # Grab any targetting the Host
				ach_coronation_0011_is_suitable_active_scheme_trigger = yes
				scheme_target_character = scope:host
			}
			alternative_limit = { # Else just one targetting someone at the activity
				ach_coronation_0011_is_suitable_active_scheme_trigger = yes
			}
			save_scope_as = coward_scheme
		}
	}
	else = { # If there is no scheme, they will babble about whatever skeleton they have in their closet
		if = {
			limit = { # If they don't have a secret, generate one
				NOT = {
					any_secret = { NOT = { is_known_by = scope:host } }
				}
			}
			hidden_effect = { give_random_likely_secret_effect = yes }
		}
		random_secret = {
			limit = { NOT = { is_known_by = scope:host } }
			save_scope_as = uncovered_secret
		}
	}
}

ach_coronation.0011 = {
	type = activity_event
	title = ach_coronation.0011.t
	desc = ach_coronation.0011.desc

	left_portrait = {
		character = root
		animation = eavesdrop
		camera = camera_event_very_left
	}

	right_portrait = {
		character = scope:plotter
		animation = dismissal
		camera = camera_event_center_pointing_left
	}

	center_portrait = {
		character = scope:coward
		animation = worry
	}

	cooldown = { years = 1 }

	theme = coronation_activity

	override_background = { reference = throne_room }

	trigger = {
		involved_activity = {
			any_attending_character = {
				ach_coronation_0011_eligible_vassal_trigger = yes
				count >= 2
			}
		}
	}

	immediate = {
		involved_activity = {
			activity_host = { save_scope_as = host }
			# Grab a likely ringleader
			random_attending_character = {
				limit = {
					is_powerful_vassal = yes
					ach_coronation_0011_eligible_vassal_trigger = yes
					any_scheme = { ach_coronation_0011_is_suitable_active_scheme_trigger = yes }
				}
				alternative_limit = {
					is_powerful_vassal = yes
					ach_coronation_0011_eligible_vassal_trigger = yes
				}
				alternative_limit = {
					ach_coronation_0011_eligible_vassal_trigger = yes
				}
				weight = {
					base = 1
					
					ach_likely_plotter_modifier = yes

					modifier = { # Weighted up if there is actually a scheme against a guest
						any_targeting_scheme = { ach_coronation_0011_is_suitable_active_scheme_trigger = yes }
						factor = {
							value = 2
							if = { # And ofc if that guest is you
								limit = { any_targeting_scheme = { scheme_target_character = scope:host } }
								add = 1
							}
						}
					}
				}
				if = {
					limit = {
						any_scheme = {
							ach_coronation_0011_is_suitable_active_scheme_trigger = yes
						}
					}
					random_scheme = {
						limit = {
							ach_coronation_0011_is_suitable_active_scheme_trigger = yes
							scheme_target_character = scope:host
						}
						alternative_limit = {
							ach_coronation_0011_is_suitable_active_scheme_trigger = yes
						}
						save_scope_as = hostile_scheme
					}
				}
				save_scope_as = plotter
			}
			# Grab a likely weak-link
			random_attending_character = {
				limit = {
					NOT = { this = scope:plotter }
					ach_coronation_0011_eligible_vassal_trigger = yes
					OR = {
						any_scheme = { ach_coronation_0011_is_suitable_active_scheme_trigger = yes }
						has_any_secrets = yes # Grab someone with secrets if possible
					}
				}
				alternative_limit = {
					NOT = { this = scope:plotter }
					ach_coronation_0011_eligible_vassal_trigger = yes
				}
				weight = {
					base = 1

					ach_unlikely_plotter_modifier = yes

					modifier = { # Grab them if they are actually an agent against you
						scope:hostile_scheme ?= {
							any_scheme_agent_character = { this = root }
						}
						factor = 4
					}
				}
				ach_coronation_0011_coward_setup_effect = yes
			}
		}
	}

	option = { # Break the coward
		name = ach_coronation.0011.b
		skill = intrigue
		flavor = ach_coronation.0011.b.flavor
		custom_tooltip = ach_coronation.0011.b.tt
		trigger = {
			intrigue >= very_high_skill_rating
		}
		
		hidden_effect = {
			if = {
				limit = { exists = scope:coward_scheme }
				send_interface_toast = {
					type = event_toast_effect_good
					title = ach_coronation.0011.coward.success
					left_icon = root
					right_icon = scope:coward
					scope:coward_scheme = {
						expose_scheme = yes
					}
				}
			}
			else = {
				send_interface_toast = {
					type = event_toast_effect_good
					title = ach_coronation.0011.coward.success
					left_icon = root
					right_icon = scope:coward
					scope:uncovered_secret = {
						reveal_to = root
					}
				}
			}
		}

		if = {
			limit = {
				can_add_hook = {
					target = scope:host
					type = manipulation_hook
				}
			}
			add_hook = {
				type = manipulation_hook
				target = scope:host
			}
		}
		scope:coward = {
			add_opinion = { 
				target = root
				modifier = scared_opinion
				opinion = -20
			}
			add_stress = major_stress_gain
			add_prestige = minor_prestige_loss
		}

		stress_impact = {
			sadistic = medium_stress_loss
			trusting = medium_stress_gain
			compassionate = medium_stress_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				add = {
					value = 0
					add = intrigue
					multiply = 5
				}
			}
			opinion_modifier = {
				opinion_target = scope:coward
				multiplier = -1
			}
			modifier = {
				OR = {
					has_trait = compassionate
					has_any_good_relationship_with_character_trigger = { CHARACTER = scope:coward }
				}
				factor = 0
			}
			modifier = {
				has_trait = sadistic
				factor = 2.5
			}
			modifier = {
				has_trait = callous
				factor = 2
			}
			modifier = {
				has_trait = schemer
				factor = 2
			}
			modifier = {
				has_trait = trusting
				factor = 0.5
			}
			modifier = {
				has_trait = compassionate
				factor = 0.5
			}
		}
	}
	
	option = { # Arrest the traitors!
		name = {
			trigger = { has_trait = paranoid }
			text = ach_coronation.0011.c.paranoid
		}
		name = {
			trigger = { has_trait = wrathful }
			text = ach_coronation.0011.c.wrathful
		}
		name = ach_coronation.0011.c
		trait = paranoid
		trait = arbitrary

		trigger = {
			OR = {
				has_trait = paranoid
				has_trait = arbitrary
				has_activity_intent = coronation_weaken_detractors
			}
		}

		imprison_character_effect = {
			IMPRISONER = root
			TARGET = scope:plotter
		}
		imprison_character_effect = {
			IMPRISONER = root
			TARGET = scope:coward
		}

		add_dread = medium_dread_gain
		if = {
			limit = {
				scope:activity = {
					any_attending_character = {
						is_vassal_of = root
						has_vassal_stance = belligerent
						NOT = { is_in_guest_subset = { name = detractor } }
						NOR = {
							this = scope:plotter
							this = scope:coward
						}
					}
				}
			}
			coronation_weaken_detractors_opinion_effect = yes
		}

		stress_impact = {
			wrathful = medium_stress_loss
			arbitrary = medium_stress_loss
			paranoid = major_stress_loss
			just = major_stress_gain
			calm = major_stress_gain
		}

		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = 0
					add = intrigue
					multiply = 5
				}
			}
			opinion_modifier = {
				opinion_target = scope:plotter
				multiplier = -1
			}
			modifier = {
				has_trait = irritable
				add = 25
			}
			modifier = {
				has_trait = wrathful
				add = 25
			}
			modifier = {
				has_trait = arbitrary
				add = 25
			}
			modifier = {
				has_trait = paranoid
				add = 50
			}
			modifier = {
				has_trait = calm
				factor = 0.5
			}
			modifier = {
				OR = {
					has_trait = just
					has_trait = compassionate
					has_any_good_relationship_with_character_trigger = { CHARACTER = scope:plotter }
				}
				factor = 0
			}
		}
	}
	
	option = { # Catch HerHim in a lie!
		name = ach_coronation.0011.a
		skill = intrigue

		reverse_add_opinion = {
			target = scope:plotter
			modifier = insult_opinion
			opinion = -20
		}

		duel = {
			skill = intrigue
			target = scope:plotter
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -19
				}
				desc = ach_coronation.0011.a.success
				custom_tooltip = ach_coronation.0011.a.success.tt
				hidden_effect = {
					if = {
						limit = { exists = scope:hostile_scheme }
						send_interface_toast = {
							type = event_toast_effect_good
							title = ach_coronation.0011.scheme.plotter.toast
							left_icon = root
							right_icon = scope:plotter

							scope:hostile_scheme = { expose_scheme = yes }
						}
					}
					else = {
						send_interface_toast = {
							type = event_toast_effect_good
							title = ach_coronation.0011.false.toast
							left_icon = root
							right_icon = scope:plotter

							add_prestige = minor_prestige_loss
						}
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -9
				}
				desc = ach_coronation.0011.a.failure
				send_interface_toast = {
					type = event_toast_effect_good
					title = ach_coronation.0011.false.toast
					left_icon = root
					right_icon = scope:plotter

					add_prestige = minor_prestige_loss
				}
			}
		}

		stress_impact = {
			trusting = medium_stress_gain
			paranoid = medium_stress_loss
		}

		ai_chance = {
			base = 150
			modifier = { 
				intrigue <= mediocre_skill_rating
				add = -50
			}
			modifier = {
				has_trait = paranoid
				factor = 2
			}
			# Don't weight up by a crazy amount - it's already high
			modifier = {
				has_trait = schemer
				factor = 1.25
			}
			modifier = {
				has_trait = diligent
				factor = 1.25
			}
			modifier = {
				OR = {
					intrigue <= low_skill_rating
					has_trait = trusting
				}
				factor = 0
			}
		}
	}

	option = { # Move on
		name = ach_coronation.0011.d

		if = {
			limit = { has_trait = paranoid }
			add_character_modifier = {
				modifier = ach_coronation_trusts_nobody_modifier
				years = 10
			}
		}
		else_if = {
			limit = { has_trait = trusting }
			add_character_modifier = {
				modifier = ach_coronation_blissful_ignorance_modifier
				years = 10
			}
		}

		reverse_add_opinion = {
			target = scope:plotter
			modifier = relieved_opinion
			opinion = 10
		}
		reverse_add_opinion = {
			target = scope:coward
			modifier = relieved_opinion
			opinion = 10
		}

		stress_impact = {
			# This is somewhat worrying
			base = minor_stress_gain
			# Doesn't actually care
			lazy = minor_stress_loss
			trusting = minor_stress_loss
			# Really really cares
			paranoid = major_stress_gain
		}

		ai_chance = {
			base = 75
			opinion_modifier = {
				opinion_target = scope:plotter
			}
			modifier = {
				OR = {
					has_trait = paranoid
					has_trait = deceitful
					has_intrigue_lifestyle_trait_trigger = yes
				}
				factor = 0.1
			}
			modifier = {
				has_trait = trusting
				factor = 2
			}
			modifier = {
				has_trait = lazy
				factor = 2
			}
			modifier = {
				has_trait = schemer
				factor = 0.5
			}
		}
	}
}

######################
# Host: Vassals squabble over coronation roles
# 0012
scripted_effect get_random_coronation_object = {
	# Decided here so the loc is consistent between the description and the options
	random_list = {
		# Cultural objects - weighted higher since they're more interesting
		10 = {
			trigger = {
				OR = {
					has_culture = culture:irish
					has_title = title:k_ireland
				}
			}
			set_variable = {
				name = random_coronation_object
				value = flag:white_rod
			}
		}
		10 = {
			trigger = { has_title = title:e_hre }
			set_variable = {
				name = random_coronation_object
				value = flag:coronation_cloak
			}
		}
		10 = {
			trigger = { any_equipped_character_artifact = { artifact_slot_type = regalia } }
			set_variable = {
				name = random_coronation_object
				value = flag:equipped_regalia
			}
		}
		1 = {
			trigger = { OR = { faith.religion = religion:eastern_orthodox_religion faith.religion = religion:catholic_religion faith.religion = religion:protestant_religion } }
			set_variable = {
				name = random_coronation_object
				value = flag:apostolic_cross
			}
		}
		1 = {
			trigger = {
				faith = {
					NOR = {
						has_doctrine_parameter = unreformed_syncretic_actor_opinion_active
						has_doctrine_parameter = unreformed
					}
				}
			}
			set_variable = {
				name = random_coronation_object
				value = flag:royal_religioustext
			}
		}
		1 = {
			set_variable = {
				name = random_coronation_object
				value = flag:sceptre_and_orb
			}
		}
		1 = {
			set_variable = {
				name = random_coronation_object
				value = flag:coronation_spoon
			}
		}
		1 = {
			set_variable = {
				name = random_coronation_object
				value = flag:coronation_sword
			}
		}
		1 = {
			set_variable = {
				name = random_coronation_object
				value = flag:coronation_rings
			}
		}
	}
}

scripted_trigger is_eligible_random_squabbler = {
	location = root.location
	is_physically_able_ai_adult = yes
	NOR = {
		this = root
		involved_activity.var:officiator ?= this
	}
	OR = {
		AND = {
			is_vassal_of = root
			highest_held_title_tier >= tier_county
		}
		is_close_family_of = root
		is_councillor_of = root
		AND = {
			is_allied_to = root
			highest_held_title_tier >= tier_county
		}
	}
}

scripted_trigger ach_coronation_0012_mutual_enmity = {
	save_temporary_scope_as = squabbler_temp
	scope:activity = {
		any_attending_character = {
			NOT = {
				this = scope:squabbler_temp
			}
			is_eligible_random_squabbler = yes
			#Check that they don't love each other
			opinion = {
				target = scope:squabbler_temp
				value <= 20
			}
			reverse_opinion = {
				target = scope:squabbler_temp
				value <= 20
			}
		}
	}
}

ach_coronation.0012 = {
	type = activity_event
	title = ach_coronation.0012.t
	desc = ach_coronation.0012.desc

	left_portrait = {
		character = root
		animation = disapproval
	}

	center_portrait = {
		character = scope:first
		animation = debating
	}

	right_portrait = {
		character = scope:second
		animation = rage
	}

	cooldown = { years = 1 }

	theme = coronation_activity

	override_background = { reference = study }

	trigger = {
		involved_activity = {
			has_current_phase = coronation_phase_preparations
			any_attending_character = {
				is_eligible_random_squabbler = yes
				count >= 1
				ach_coronation_0012_mutual_enmity = yes
			}
		}
	}

	immediate = {
		get_random_coronation_object = yes
		involved_activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = { # Grab two random attendees to be used in loc
				limit = {
					is_eligible_random_squabbler = yes
					highest_held_title_tier >= tier_duchy
					ach_coronation_0012_mutual_enmity = yes
				}
				alternative_limit = {
					is_eligible_random_squabbler = yes
					save_temporary_scope_as = squabbler_temp
					ach_coronation_0012_mutual_enmity = yes
				}
				weight = {
					base = 1

					ach_squabbler_modifier = yes

					# Try to get someone who has a rivalry with another vassal already if possible
					modifier = {
						factor = 4
						any_relation = {
							type = rival
							is_participant_in_activity = scope:activity
							is_eligible_random_squabbler = yes
							is_vassal_of = scope:host
						}
					}
				}
				save_scope_as = first
			}
			random_attending_character = {
				limit = { 
					is_eligible_random_squabbler = yes
					this != scope:first
					# Try and get the rival of the first character
					has_relation_rival = scope:first
					highest_held_title_tier >= tier_duchy
					ach_coronation_0012_mutual_enmity = yes
				}
				alternative_limit = { 
					is_eligible_random_squabbler = yes
					this != scope:first
					# Try and get the rival of the first character
					has_relation_rival = scope:first
					ach_coronation_0012_mutual_enmity = yes
				}
				alternative_limit = {
					is_eligible_random_squabbler = yes
					this != scope:first
					highest_held_title_tier >= tier_duchy
					ach_coronation_0012_mutual_enmity = yes
				}
				alternative_limit = {
					is_eligible_random_squabbler = yes
					this != scope:first
					ach_coronation_0012_mutual_enmity = yes
				}
				weight = {
					base = 1

					ach_squabbler_modifier = yes

					# Prefer those who hate the first vassal
					opinion_modifier = {
						opinion_target = scope:first
						multiplier = -0.01
					}
					# And those likewise hated by
					opinion_modifier = {
						who = scope:first
						opinion_target = this
						multiplier = -0.01
					}
					# And a final boost if they have any sort of negative relationship, just in case
					modifier = {
						factor = 2
						has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:first }
					}
				}
				save_scope_as = second
			}
		}
	}

	option = { # Vassal 1 is my favorite!
		name = ach_coronation.0012.a

		coronation_move_towards_supporter_effect = { CHARACTER = scope:first }
		coronation_move_towards_detractor_effect = { CHARACTER = scope:second }
		scope:first = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 40
			}
			add_prestige = medium_prestige_gain
		}
		scope:second = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -20
			}
			add_prestige = medium_prestige_loss
			hidden_effect = {
				if = {
					limit = {
						is_ai = yes
						scope:first = {
							is_ai = yes
						}
					}
					progress_towards_rival_effect = {
						REASON = rival_stole_coronation_role
						CHARACTER = scope:first
						OPINION = -40
					}
				}
			}
		}

		stress_impact = {
			fickle = minor_stress_gain
		}

		ai_chance = {
			base = 0
			opinion_modifier = {
				opinion_target = scope:first
			}
			opinion_modifier = {
				opinion_target = scope:second
				multiplier = -1
			}
			modifier = {
				has_trait = fickle
				factor = 0.5
			}
		}
	}

	option = { # Vassal 2 so 2 deserves my support!
		name = ach_coronation.0012.b
		coronation_move_towards_supporter_effect = { CHARACTER = scope:second }
		coronation_move_towards_detractor_effect = { CHARACTER = scope:first }
		scope:second = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 40
			}
			add_prestige = medium_prestige_gain
		}
		scope:first = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -20
			}
			add_prestige = medium_prestige_loss

			hidden_effect = {
				if = {
					limit = {
						is_ai = yes
						scope:second = {
							is_ai = yes
						}
					}
					progress_towards_rival_effect = {
						REASON = rival_stole_coronation_role
						CHARACTER = scope:second
						OPINION = -40
					}
				}
			}
		}

		stress_impact = {
			fickle = minor_stress_gain
		}

		ai_chance = {
			base = 0
			opinion_modifier = {
				opinion_target = scope:second
			}
			opinion_modifier = {
				opinion_target = scope:first
				multiplier = -1
			}
			modifier = {
				has_trait = fickle
				factor = 0.5
			}
		}
	}

	option = { # You can both do it together!
		name = ach_coronation.0012.c
		flavor = ach_coronation.0012.c.flavor
		trigger = {
			NOR = {
				has_trait = diplomatic_court
				trigger_if = {
					limit = { has_royal_court = yes }
					court_grandeur_current_level >= 8
				}
			}
		}

		duel = {
			skill = diplomacy
			value = 10
			50 = {
				desc = ach_coronation.0012.c.tt.success
				compare_modifier = {
					 value = scope:duel_value
					 multiplier = 1.5
					 min = -49
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ach_coronation.0012.c.tt.success
					left_icon = root
					custom_tooltip = coronation_tt_positive_tiny
					scope:activity = { activity_special_type_progression_tiny = yes }
					add_diplomacy_lifestyle_xp = medium_lifestyle_experience
				}
				coronation_add_magnificence_log_effect = {
        		    VALUE = flag:positive_tiny
        		    CHAR = root
        		}
			}
			50 = {
				desc = ach_coronation.0012.c.tt.failure
				compare_modifier = {
					 value = scope:duel_value
					 multiplier = -1.5
					 min = -49
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ach_coronation.0012.c.tt.failure
					left_icon = root
					add_prestige = minor_prestige_loss
				}
				scope:first = {
					if = {
						limit = {
							can_set_relation_rival_trigger = { CHARACTER = scope:second }
							is_ai = yes
							scope:second = { is_ai = yes }
						}
						set_relation_rival = {
							target = scope:second
							reason = rival_ruined_coronation_role
						}
					}
				}
			}
		}

		stress_impact = {
			craven = minor_stress_loss
			fickle = minor_stress_loss
		}

		ai_chance = {
			base = 0
			modifier = {
				add = 25
				OR = {
					has_trait = craven
					has_trait = fickle
				}
			}
			modifier = {
				add = 50
				AND = {
					opinion = {
						target = scope:first
						value >= low_positive_opinion
					}
					opinion = {
						target = scope:second
						value >= low_positive_opinion
					}
				}
			}
			opinion_modifier = {
				opinion_target = scope:first
				multiplier = 0.5
			}
			opinion_modifier = {
				opinion_target = scope:second
				multiplier = 0.5
			}
			modifier = {
				factor = 0
				diplomacy < low_skill_rating
			}
		}
	}

	option = { # I have the perfect idea!
		name = ach_coronation.0012.d
		flavor = ach_coronation.0012.d.flavor
		trigger = {
			OR = {
				has_trait = diplomatic_court
				trigger_if = { # This ain't your first rodeo
					limit = { has_royal_court = yes }
					court_grandeur_current_level >= 8
				}
			}
		}
		trait = diplomatic_court_1
		# Legitimacy gets a lil bump
		add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
		# And the activity gets a small bump as well
		custom_tooltip = coronation_tt_positive_medium
		scope:activity = {
			activity_special_type_progression_medium = yes
			add_activity_log_entry = {
				key = coronation_elaborate_ceremony_log
				score = 25
				tags = { positive }
				character = scope:first
				target = scope:second
			}
		}

		scope:first = {
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 20
			}
		}
		scope:second = {
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 20
			}
		}

		stress_impact = {
			arrogant = medium_stress_loss
		}

		ai_chance = {
			base = 150
			modifier = {
				AND = {
					opinion = {
						target = scope:first
						value <= low_negative_opinion
					}
					opinion = {
						target = scope:second
						value <= low_negative_opinion
					}
				}
				add = -50
			}
			modifier = {
				has_trait = arrogant
				factor = 1.5
			}
			modifier = {
				AND = {
					opinion = {
						target = scope:first
						value < medium_negative_opinion
					}
					opinion = {
						target = scope:second
						value < medium_negative_opinion
					}
				}
				factor = 0.5
			}
		}
	}

	option = { # Neither of you are worthy of touching my random_coronation_object!
		name = ach_coronation.0012.e

		scope:first = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -10
			}
		}
		scope:second = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -10
			}
		}
		
		add_character_modifier = {
			modifier = ach_imperious_modifier
			years = 5
		}
		add_prestige = minor_prestige_gain

		stress_impact = {
			impatient = minor_stress_loss
			lazy = minor_stress_loss
			arrogant = minor_stress_loss
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 50
				AND = {
					opinion = {
						target = scope:first
						value >= low_positive_opinion
					}
					opinion = {
						target = scope:second
						value >= low_positive_opinion
					}
				}
			}
			modifier = {
				add = -50
				AND = {
					opinion = {
						target = scope:first
						value <= low_positive_opinion
					}
					opinion = {
						target = scope:second
						value <= low_positive_opinion
					}
				}
			}
			modifier = {
				OR = {
					has_trait = impatient
					has_trait = lazy
					has_trait = callous
					has_trait = arrogant
					has_trait = wrathful
				}
				factor = 1.5
			}
			opinion_modifier = {
				opinion_target = scope:first
				multiplier = 0.5
			}
			opinion_modifier = {
				opinion_target = scope:second
				multiplier = 0.5
			}
		}
	}
}

######################
# Host: You eavesdrop on some peasants
# 0013
scripted_trigger ach_coronation_0013_claimant_trigger = {
	# Shouldn't be friendly
	has_any_good_relationship_with_root_trigger = no
	is_alive = yes
	is_adult = yes
	NOT = { is_courtier_of = scope:host }
	# Don't include your kids (unless you hate the little bastards)
	trigger_if = {
		limit = { has_any_bad_relationship_with_root_trigger = no }
		NOT = { is_child_of = scope:host }
	}
}

scripted_effect ach_coronation_0013_get_eligible_pretender_effect = {
	scope:host = {
		if = {
			limit = {
				any_held_title = {
					any_claimant = { ach_coronation_0013_claimant_trigger = yes }
				}
			}
			random_held_title = {
				# Prefer strong claimants (Who you're thus more likely to also hate)
				limit = {
					any_claimant = {
						has_strong_claim_on = prev
						ach_coronation_0013_claimant_trigger = yes
					}
				}
				alternative_limit = {
					any_claimant = { ach_coronation_0013_claimant_trigger = yes }
				}
				weight = {
					# Prefer primary title
					modifier = {
						this = scope:host.primary_title
						factor = 4
					}
					# Prefer higher tier titles
					modifier = { factor = tier }
				}
				random_claimant = {
					limit = { ach_coronation_0013_claimant_trigger = yes }
					save_scope_as = claimant
				}
			}
		}
	}
}

scripted_effect ach_coronation_0013_get_gossip_type_effect = {
	random_list = {
		# More likely to get nice modifiers
		200 = {
			save_scope_value_as = {
				name = gossip_type
				value = flag:nice
			}
			# Unless you're a tyrant (but some people still like tyrants)
			modifier = {
				add = {
					value = tyranny
					multiply = -1
				}
			}
		}
		100 = {
			save_scope_value_as = {
				name = gossip_type
				value = flag:mean
			}
			modifier = {
				add = {
					value = tyranny
				}
			}
		}
	}
}

ach_coronation.0013 = {
	type = activity_event
	title = ach_coronation.0013.t
	desc = {
		desc = ach_coronation.0013.intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:rain_day }
				desc = ach_coronation.0013.desc_opening.rainy_day
			}
			desc = ach_coronation.0013.desc_opening.dry_day
		}
		desc = ach_coronation.0013.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = { scope:gossip_type = flag:mean }
				desc = {
					random_valid = {
						desc = ach_coronation.0013.desc_conversation.mean.1
						desc = ach_coronation.0013.desc_conversation.mean.2
						desc = ach_coronation.0013.desc_conversation.mean.3
						desc = {
							desc = ach_coronation.0013.desc_conversation.mean.4
							first_valid = {
								triggered_desc = {
									trigger = { has_trait = lustful }
									desc = ach_coronation.0013.desc_conversation.mean.4.lustful.host
								}
								triggered_desc = {
									trigger = { has_trait = chaste }
									desc = ach_coronation.0013.desc_conversation.mean.4.chaste
								}
								desc = ach_coronation.0013.desc_conversation.mean.4.not_lustful
							}
						}
						desc = ach_coronation.0013.desc_conversation.mean.5
					}
				}
			}
			triggered_desc = {
				trigger = { scope:gossip_type = flag:nice }
				desc = {
					random_valid = {
						desc = ach_coronation.0013.desc_conversation.nice.1
						desc = ach_coronation.0013.desc_conversation.nice.2
						desc = ach_coronation.0013.desc_conversation.nice.3
						desc = ach_coronation.0013.desc_conversation.nice.4
						triggered_desc = {
							trigger = { exists = scope:claimant }
							desc = ach_coronation.0013.desc_conversation.nice.5
						}
					}
				}
			}
		}
	}

	left_portrait = {
		character = root
		animation = interested
		camera = camera_event_table_center_background

		triggered_animation = {
			trigger = { scope:gossip_type = flag:mean }
			animation = shock
		}
		triggered_animation = {
			trigger = { scope:gossip_type = flag:nice }
			animation = happiness
		}
	}

	center_portrait = {
		character = scope:peasant
		animation = wedding_drunk
		camera = camera_event_table_left_2
		hide_info = yes
	}

	right_portrait = {
		character = scope:peasant_2
		animation = drink
		camera = camera_event_table_right_far_2
		hide_info = yes
	}

	cooldown = { years = 1 }

	theme = coronation_activity

	override_background = { reference = alley_day }

	override_effect_2d = {
		trigger = { exists = scope:rain_day }
		reference = rain	
	}
	
	trigger = {
		OR = {
			involved_activity.var:activity_special_type_progression < 25
			location.county = { county_control < 25 }
		}
		#V Serious roots
		NOR = {
			coronation_host_east_asian_trigger = yes
			highest_held_title_tier > tier_empire
		}
	}

	# Peasants are less likely to spread rumors about rulers they fear
	weight_multiplier = {
		base = 1
		compare_modifier = {
			value = dread
			multiplier = -0.01
			# But sometimes you drink a bit too much with the lads and get y'allselves killed. Opsec, people!
			min = -0.9
		}
	}

	immediate = {
		save_scope_as = host
		involved_activity = {
			activity_location.barony.holder = {
				save_scope_as = baron
			}
		}

		# Generate some gossipy peasants
		create_character = {
			location = root.location
			template = drunken_peasant_character
			culture = root.location.county.culture
			faith = root.location.county.faith
			save_scope_as = peasant
			after_creation = { # To make sure they fit the event window
				if = {
					limit = { has_trait = giant }
					remove_trait = giant
				}
				if = {
					limit = { has_trait = dwarf }
					remove_trait = dwarf
				}
			}
		}
		create_character = {
			location = root.location
			template = drunken_peasant_character
			culture = root.location.county.culture
			faith = root.location.county.faith
			save_scope_as = peasant_2
			after_creation = {
				if = {
					limit = { has_trait = giant }
					remove_trait = giant
				}
				if = {
					limit = { has_trait = dwarf }
					remove_trait = dwarf
				}
			}
		}

		# And stuff for loc
		random_dummy_gender_effect = yes
		random_rain_snow_chance_effect = yes
		ach_coronation_0013_get_eligible_pretender_effect = yes
		ach_coronation_0013_get_gossip_type_effect = yes
	}

	option = { # Weaken Detractors: Focus them on your opponents
		name = ach_coronation.0013.a.weaken_detractors
		reason = activity_intent
		flavor = ach_coronation.0013.a.weaken_detractors.flavor
		add_internal_flag = special

		trigger = {
			has_activity_intent = coronation_weaken_detractors
			involved_activity = {
				any_guest_subset = { # There are actually enough people to do this to
					name = detractor
					count >= 2
				}
			}
		}

		custom_tooltip = two_detractors_get_negative_rumors_tt

		hidden_effect = {
			involved_activity = {
				random_guest_subset = {
					name = detractor
					weight = {
						base = 1
						is_of_major_interest_to_weight_up_modifier = { CHARACTER = root }
						is_of_minor_interest_to_weight_up_modifier = { CHARACTER = root }

						# Less likely to get rumors to stick on proper political operators
						modifier = {
							add = {
								value = intrigue
								multiply = -5
							}
							add = {
								value = diplomacy
								multiply = -5
							}
						}
					}
					add_character_modifier = {
						modifier = ach_negative_rumors_modifier
						years = 5
					}
					save_scope_as = detractor_1
				}
				random_guest_subset = {
					name = detractor
					weight = {
						base = 1
						is_of_major_interest_to_weight_up_modifier = { CHARACTER = root }
						is_of_minor_interest_to_weight_up_modifier = { CHARACTER = root }
						
						# Less likely to get rumors to stick on proper political operators
						modifier = {
							add = {
								value = intrigue
								multiply = -5
							}
							add = {
								value = diplomacy
								multiply = -5
							}
						}
					}
					add_character_modifier = {
						modifier = ach_negative_rumors_modifier
						years = 5
					}
					save_scope_as = detractor_2
				}
			}
			send_interface_toast = {
				title = ach_coronation.0013.a.weaken_detractors.tt
				left_icon = scope:detractor_1
				right_icon = scope:detractor_2
				
				scope:detractor_1 = {
					add_character_modifier = {
						modifier = ach_negative_rumors_modifier
						years = 5
					}
				}
				scope:detractor_2 = {
					add_character_modifier = {
						modifier = ach_negative_rumors_modifier
						years = 5
					}
				}
			}
		}

		remove_short_term_gold = minor_gold_value

		highlight_portrait = scope:peasant
		highlight_portrait = scope:peasant_2

		coronation_weaken_detractors_opinion_effect = yes

		stress_impact = {
			arrogant = minor_stress_gain # Talking to peasants
			shy = minor_stress_gain # Talking to anyone
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
			modifier = {
				has_trait = arrogant
				add = -25
			}
			modifier = {
				has_trait = shy
				add = -25
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				has_trait = profligate
				add = 25
			}
			modifier = {
				has_trait = generous
				add = 25
			}
			modifier = {
				has_trait = lifestyle_reveler
				add = 25
			}
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = schemer
				factor = 2
			}
			modifier = {
				has_trait = honest
				factor = 0.5
			}
		}
	}

	option = { # Host: Do they have any idea who you are!?
		name = ach_coronation.0013.c
		trigger = {
			scope:gossip_type = flag:mean
		}
		skill = diplomacy

		duel = {
			skills = { diplomacy prowess }
			value = medium_skill_rating
			# you manage to win them over
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ach_coronation.0013.c.tt.success
				send_interface_toast = {
					title = ach_coronation.0013.c.tt.success
					left_icon = root
					add_prestige = medium_prestige_gain
					custom_tooltip = coronation_tt_positive_tiny
					scope:activity = { activity_special_type_progression_tiny = yes }
				}
				coronation_add_magnificence_log_effect = {
					VALUE = flag:positive_tiny
					CHAR = root
				}
			}
			# The rumors spread further
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ach_coronation.0013.c.tt.failure
				send_interface_toast = {	
					title = ach_coronation.0013.c.tt.failure
					left_icon = root
					add_prestige = minor_prestige_loss
					add_dread = minor_dread_loss
					add_character_modifier = {
						modifier = ach_negative_rumors_modifier
						years = 5
					}
				}
			}
		}

		stress_impact = {
			forgiving = minor_stress_gain
			just = minor_stress_loss
			wrathful = minor_stress_loss
			vengeful = minor_stress_loss
		}

		ai_chance = {
			base = 10
			modifier = {
				has_trait = wrathful
				add = 25
			}
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_sociability = 0.5
			}
		}
	}

	option = { # Set the guards on them
		name = ach_coronation.0013.b
		trigger = { scope:gossip_type = flag:mean }

		add_character_modifier = {
			modifier = ach_negative_rumors_modifier
			years = 5
		}

		rightfully_imprison_character_less_verbose_effect = {
			TARGET = scope:peasant
			IMPRISONER = root
		}
		rightfully_imprison_character_less_verbose_effect = {
			TARGET = scope:peasant_2
			IMPRISONER = root
		}

		add_tyranny = minor_tyranny_gain
		add_dread = minor_dread_gain
		root.location = {
			add_province_modifier = {
				modifier = ach_arrested_rumormongers_modifier
				years = 5
			}
		}
		add_character_modifier = {
			modifier = ach_arrested_rumormongers_character_modifier
			years = 5
		}

		highlight_portrait = scope:peasant

		stress_impact = {
			forgiving = medium_stress_gain
			compassionate = minor_stress_gain
			calm = miniscule_stress_gain
			irritable = minor_stress_loss
			wrathful = medium_stress_loss
			vengeful = medium_stress_loss
		}

		ai_chance = {
			base = 20
			modifier = {
				has_trait = wrathful
				add = 25
			}
			modifier = {
				has_trait = vengeful
				add = 50
			}
			ai_value_modifier = {
				ai_boldness = 1
				ai_energy = 1
				ai_compassion = -1
			}
		}
	}

	option = { # Join them
		name = ach_coronation.0013.d
		trigger = { scope:gossip_type = flag:nice }

		add_character_modifier = {
			modifier = ach_positive_rumors_modifier
			years = 10
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
				has_trait_xp = {
					trait = lifestyle_reveler
					value < 100
				}
			}
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 10
			}
		}
		else = {
			random = {
				chance = 25
				if = {
					limit = {
						NOT = { has_trait = lifestyle_reveler }
					}
					add_trait = lifestyle_reveler
				}
			}
		}

		add_prestige = minor_prestige_loss

		highlight_portrait = scope:peasant
		highlight_portrait = scope:peasant_2

		stress_impact = {
			base = medium_stress_loss
			gregarious = minor_stress_loss
			lifestyle_reveler = minor_stress_loss
			shy = major_stress_gain
			arrogant = major_stress_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	option = { # Who cares?
		name = ach_coronation.0013.e
		name = {
			trigger = { scope:gossip_type = flag:mean }
			text = ach_coronation.0013.e.disagrees
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:gossip_type = flag:mean
					}
					desc = ach_coronation.0013.e.flavor.mean
				}
				desc = ach_coronation.0013.e.flavor.nice
			}
		}

		if = {
			limit = { scope:gossip_type = flag:nice }
			add_character_modifier = {
				modifier = ach_positive_rumors_modifier
				years = 5
			}
			stress_impact = {
				base = minor_stress_loss
			}
		}
		else = {
			add_character_modifier = {
				modifier = ach_negative_rumors_modifier
				years = 5
			}
			stress_impact = {
				base = minor_stress_loss
				vengeful = medium_stress_gain
				wrathful = minor_stress_gain
				forgiving = medium_stress_loss
			}
		}

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_sociability = -0.5
				ai_energy = -0.5
			}
		}
	}

	after = {
		if = {
			limit = {
				scope:peasant = { is_imprisoned = no }
			}
			hidden_effect = {
				scope:peasant = { silent_disappearance_effect = yes }
				scope:peasant_2 = { silent_disappearance_effect = yes }
			}
		}
	}
}

######################
# Guest: Yell fire
# 0014
scripted_trigger ach_coronation_0014_random_attendee_trigger = {
	NOR = {
		this = scope:host
		this = scope:crush_initiator
		involved_activity.var:officiator ?= this
	}
	is_available_in_activity_trigger = yes
}

scripted_effect ach_coronation_0015_crushed_guest_effect = {
	involved_activity = {
		# Wound X characters and kill Y %
		while = {
			count = $COUNT$
			random_attending_character = {
				limit = {
					ach_coronation_0014_random_attendee_trigger = yes
					NOT = { is_in_list = in_crowd_crush }
				}
				add_to_list = in_crowd_crush
				increase_wounds_effect = { REASON = crowd_stampede }
				create_character_memory = {
					type = injured_in_crowd_crush_at_coronation_memory
					participants = {
						coronation_host = scope:host
					}
				}

				random = {
					chance = $DEATH_CHANCE$
					death = { death_reason = death_crowd_stampede }
				}
			}
		}
		# Add the stampede modifier
		root.location = {
			if = {
				limit = {
					NOT = { has_province_modifier = ach_coronation_stampede_modifier }
				}
				add_province_modifier = { modifier = ach_coronation_stampede_modifier years = 5 }
				county = { change_county_control = minor_county_control_loss }
			}
		}
	}
}

# Crowd crush effects used in tooltips in 0014 and the effects of 0015
scripted_effect ach_coronation_0015_minor_crush_effect = {
	custom_tooltip = few_guests_wounded
	hidden_effect = { ach_coronation_0015_crushed_guest_effect = { COUNT = 2 DEATH_CHANCE = 0 } }
}
scripted_effect ach_coronation_0015_medium_crush_effect = {
	custom_tooltip = many_guests_wounded
	hidden_effect = { ach_coronation_0015_crushed_guest_effect = { COUNT = 8 DEATH_CHANCE = 0 } }
}
scripted_effect ach_coronation_0015_major_crush_effect = {
	custom_tooltip = many_guests_wounded_or_killed
	hidden_effect = { ach_coronation_0015_crushed_guest_effect = { COUNT = 12 DEATH_CHANCE = 4 } }
}

ach_coronation.0014 = {
	type = activity_event
	title = ach_coronation.0014.t
	desc = {
		desc = ach_coronation.0014.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:rain }
				desc = ach_coronation.0014.desc.weather.rain
			}
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:generic_indoors }
				desc = ach_coronation.0014.desc.weather.indoors
			}
			desc = ach_coronation.0014.desc.weather.clear
		}
		first_valid = {
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:rain }
				desc = ach_coronation.0014.desc.reason.rain
			}
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:local_discontent }
				desc = ach_coronation.0014.desc.reason.local_discontent
			}
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:low_control }
				desc = ach_coronation.0014.desc.reason.low_control
			}
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:generic_indoors }
				desc = ach_coronation.0014.desc.reason.generic_indoors
			}
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:generic_outdoors }
				desc = ach_coronation.0014.desc.reason.generic_outdoors
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					culture = { has_cultural_pillar = language_greek }
					OR = {
						has_title = title:e_byzantium
						top_liege = {
							has_title = title:e_byzantium
						}
					}
				}
				desc = ach_coronation.0014.desc.ending.byzantine
			}
			triggered_desc = {
				desc = ach_coronation.0014.desc.ending
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { scope:crush_scenario = flag:generic_indoors }
				desc = ach_coronation.0014.desc.ending.indoors
			}
			desc = ach_coronation.0014.desc.ending.outdoors
		}
	}

	left_portrait = {
		character = root
		animation = thinking
	}

	center_portrait = {
		character = scope:peasant
		animation = rage
		camera = camera_event_center_pointing_right
		hide_info = yes
	}

	right_portrait = {
		character = scope:guard
		animation = threatening
		camera = camera_event_right_pointing_right
		hide_info = yes
	}

	lower_left_portrait = {
		character = scope:first
	}

	cooldown = { years = 10 }

	theme = coronation_activity

	override_background = {
		trigger = { scope:crush_scenario = flag:generic_indoors }
		reference = throne_room
	}
	override_background = { reference = alley_day }

	override_effect_2d = {
		trigger = {
			exists = scope:rain_day
			NOT = { scope:crush_scenario = flag:generic_indoors }
		}
		reference = rain	
	}

	trigger = {
		involved_activity = {
			activity_host != root
			# Coronation Splendor is low
			var:activity_special_type_progression < 25
			OR = {
				# County has low control
				activity_location.county = { county_control < low_county_control_limit }
				# County is part of a faction
				activity_host = {
					any_targeting_faction = {
						any_faction_county_member = {
							this = scope:activity.activity_location.county
						}
					}
				}
				# There are many powerful detractors
				any_guest_subset = {
					name = detractor
					OR = { # Is a threat to the host
						AND = {
							liege = involved_activity.activity_host
							is_powerful_vassal = yes
						}
						highest_held_title_tier >= involved_activity.activity_host.highest_held_title_tier
						current_military_strength > involved_activity.activity_host.current_military_strength
					}
					count >= 4
				}
			}
		}

		# You have a reason to do this, or at least consider it
		coronation_hostile_to_host_trigger = yes

		involved_activity = {
			# There are enough people to be impacted by a crush
			any_attending_character = {
				is_physically_able_ai = yes
				this != root
				count >= 12
			}
			# There is a character we can use for the arrival
			any_attending_character = {
				is_landed = yes
				location = involved_activity.activity_location
				NOR = {
					this = involved_activity.activity_host
					this = root
					involved_activity.var:officiator ?= this
				}
				is_available_in_activity_trigger = yes
			}
			# Once per activity
			NOT = { has_variable = crowd_crush_happened }
		}
	}

	weight_multiplier = {
		base = 1
		# More likely if the coronation isn't going great
		modifier = {
			involved_activity = {
				any_guest_subset = {
					name = detractor
					OR = {
						# Is a powerful vassal
						AND = {
							liege = scope:host
							is_powerful_vassal = yes
						}
						# Or a threat to the host
						highest_held_title_tier >= scope:host.highest_held_title_tier
					}
					count >= 3
				}
			}
			add = 1
		}
		modifier = {
			involved_activity = {
				any_guest_subset = {
					name = detractor
					OR = {
						# Is a powerful vassal
						AND = {
							liege = scope:host
							is_powerful_vassal = yes
						}
						# Or a threat to the host
						highest_held_title_tier >= scope:host.highest_held_title_tier
					}
					count >= 5
				}
			}
			add = 1
		}
		modifier = {
			involved_activity = {
				any_guest_subset = {
					name = detractor
					OR = {
						# Is a powerful vassal
						AND = {
							liege = scope:host
							is_powerful_vassal = yes
						}
						# Or a threat to the host
						highest_held_title_tier >= scope:host.highest_held_title_tier
					}
					count >= 7
				}
			}
			add = 1
		}
	}

	immediate = {
		save_scope_as = crush_initiator

		involved_activity = {
			activity_host = { save_scope_as = host }

			# Grab a random landed attendee to be used in loc
			random_attending_character = {
				limit = {
					ach_coronation_0014_random_attendee_trigger = yes
					is_landed = yes
				}
				weight = {
					base = 1
					modifier = { factor = highest_held_title_tier } # Grab someone important
				}
				save_scope_as = first
			}
		}

		# Generate a bodyguard
		create_character = {
			location = root.location
			template = soldier_friend_character
			culture = scope:first.culture
			faith = scope:first.faith
			save_scope_as = guard
		}
		create_character = {
			location = root.location
			template = servant_character
			culture = root.location.county.culture
			faith = root.location.county.faith
			save_scope_as = peasant
		}

		random_rain_snow_chance_effect = yes

		# Choose a scenario
		random_list = {
			1 = {
				trigger = { exists = scope:rain_day }
				save_scope_value_as = {
					name = crush_scenario
					value = flag:rain
				}
			}
			1 = {
				save_scope_value_as = {
					name = crush_scenario
					value = flag:generic_indoors
				}
			}
			1 = {
				save_scope_value_as = {
					name = crush_scenario
					value = flag:generic_outdoors
				}
			}
			# Prefer non-generic ones
			4 = {
				trigger = {
					scope:host = {
						any_targeting_faction = {
							any_faction_county_member = {
								this = scope:activity.activity_location.county
							}
						}
					}
				}
				save_scope_value_as = {
					name = crush_scenario
					value = flag:local_discontent
				}
			}
			4 = {
				trigger = {
					location.county = { county_control < low_county_control_limit }
				}
				save_scope_value_as = {
					name = crush_scenario
					value = flag:low_control
				}
			}
		}
	}

	option = { # Yell fire
		name = {
			trigger = { scope:crush_scenario = flag:generic_indoors }
			text = ach_coronation.0014.a.indoors
		}
		name = ach_coronation.0014.a.outdoors
		add_internal_flag = dangerous

		duel = {
			skill = intrigue
			value = very_high_skill_rating
			# You spark a riot.
			35 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = ach_coronation.0014.a.tt.success

				if = {
					limit = {
						scope:crush_scenario != flag:generic_indoors
					}
					custom_tooltip = ach_coronation.0014.a.rock
					hidden_effect = {
						scope:first = { increase_wounds_effect = { REASON = fight } }
					}
				}
				else = {
					scope:first = { increase_wounds_effect = { REASON = fight } }
				}

				# Effect is fired from the host event
				hidden_effect = {
					scope:host = {
						trigger_event = ach_coronation.0015
					}
					involved_activity = {
						set_variable = {
							name = crowd_crush_happened
						}
					}
				}

				custom_description_no_bullet = {
					text = if_host_calms_crowd_desc
					object = scope:host
				}
				show_as_tooltip = { ach_coronation_0015_minor_crush_effect = yes }
				custom_tooltip = ach_coronation.0014.a.tt.host.success
				
				custom_description_no_bullet = {
					text = if_crush_happens_desc
					object = scope:host
				}
				custom_tooltip = many_guests_may_be_wounded_or_killed
				custom_tooltip = ach_coronation.0014.a.tt.host.failure.magnificence
				custom_tooltip = ach_coronation.0014.a.tt.host.failure.host
				custom_tooltip = ach_coronation.0014.a.tt.host.failure.crackdown
			}
			# Nobody notices
			65 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ach_coronation.0014.a.tt.failure
				send_interface_toast = {
					title = ach_coronation.0014.a.tt.failure
					desc = {
						desc = ach_coronation.0014.a.tt.failure
						triggered_desc = {
							trigger = { scope:crush_scenario = flag:generic_indoors }
							desc = ach_coronation.0014.a.tt.failure.indoors
						}
					}
				}
			}
		}

		ai_chance = {
			base = 25
			# More likely if you actually have a chance
			modifier = {
				intrigue > high_skill_rating
				add = 25
			}
			modifier = {
				intrigue > very_high_skill_rating
				add = 50
			}
			modifier = {
				has_trait = schemer
				add = 25
			}
			modifier = {
				has_trait = callous
				add = 25
			}
			modifier = {
				has_trait = sadistic
				factor = 2
			}
		}
		stress_impact = {
			sadistic = medium_stress_impact_loss
			callous = minor_stress_impact_loss
			honest = minor_stress_impact_gain
			content = minor_stress_impact_gain
			just = medium_stress_impact_gain
			compassionate = massive_stress_gain
		}
	}
	
	option = { # These crowds could be useful...
		name = ach_coronation.0014.b
		trigger = {
			custom_tooltip = {
				text = ach_coronation.0014.b.tt
				OR = {
					intrigue >= very_high_skill_rating
					has_trait = deceitful
					has_trait = schemer
				}
			}
		}
		show_as_unavailable = { always = yes }
		skill = intrigue
		trait = schemer
		trait = deceitful

		add_character_modifier = {
			modifier = ach_useful_crowds_modifier
			years = 5
		}

		ai_chance = {
			base = 150
		}
	}
	
	option = { # Go schmooze with the oncoming lord instead
		name = ach_coronation.0014.c
		reverse_add_opinion = {
			modifier = charmed_opinion
			opinion = 10
			target = scope:first
		}

		ai_chance = {
			base = 100
		}
	}

	after = {
		hidden_effect = {
			scope:guard = { silent_disappearance_effect = yes }
			scope:peasant = { silent_disappearance_effect = yes }
		}
	}
}

######################
# Host: There is a crowd crush
# 0015
ach_coronation.0015 = {
	type = activity_event
	title = ach_coronation.0015.t
	desc = ach_coronation.0015.desc

	left_portrait = {
		character = root
		animation = fear
	}

	center_portrait = {
		character = scope:peasant
		animation = rage
		camera = camera_event_crowd
		hide_info = yes
	}

	right_portrait = {
		character = scope:filthy_peasant
		animation = beg
		camera = camera_event_ground
		hide_info = yes
	}

	cooldown = { years = 10 }

	theme = coronation_activity

	override_background = {
		trigger = {
			location.county.holder = {
				government_has_flag = government_is_tribal
			}
		}
		reference = market_tribal
	}
	override_background = { reference = alley_day }

	override_effect_2d = {
		trigger = { exists = scope:rain_day }
		reference = rain	
	}

	trigger = {
		involved_activity = {
			# Once per activity
			NOT = { has_variable = crowd_crush_happened }
		}
	}

	immediate = {
		create_character = {
			location = root.location
			template = diseased_peasant_character
			culture = root.location.county.culture
			faith = root.location.county.faith
			save_scope_as = filthy_peasant
		}
		create_character = {
			location = root.location
			template = servant_character
			culture = root.location.county.culture
			faith = root.location.county.faith
			save_scope_as = peasant
		}
		
		ach_coronation_0015_minor_crush_effect = yes

		custom_tooltip = ach_coronation.0015.has_happened
	}

	option = { # Diplomacy Challenge - Talk them down
		name = {
			trigger = { has_trait = august }
			text = ach_coronation.0015.a.august
		}
		name = ach_coronation.0015.a
		trigger = { diplomacy >= low_skill_rating }
		show_as_unavailable = { always = yes }
		skill = diplomacy
		trait = august

		duel = {
			skill = diplomacy
			value = medium_skill_rating
			# Your speech stuns the crowd to awed silence
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				modifier = {
					diplomacy >= high_skill_rating
					add = 10
				}
				modifier = {
					has_trait = diplomat
					add = 20
				}

				desc = ach_coronation.0015.a.tt.critical_success

				custom_tooltip = coronation_tt_positive_major
				scope:activity = { activity_special_type_progression_major = yes }
				coronation_add_magnificence_log_effect = {
					VALUE = flag:positive_major
					CHAR = root
				}

				# The commoners will remember this
				add_character_modifier = { modifier = ach_awed_peasantry_modifier years = 10 }

				# You'll also remember this
				create_character_memory = { type = calmed_the_crowd_memory }

				show_as_tooltip = {
					add_diplomacy_lifestyle_perk_points = 1
				}

				hidden_effect = {
					send_interface_toast = {
						title = ach_coronation.0015.a.tt.critical_success
						custom_tooltip = ach_coronation.0015.a.tt.critical_success.desc
						left_icon = root
						type = event_toast_effect_good

						# Everyone is very impressed
						add_diplomacy_lifestyle_perk_points = 1
						custom_tooltip = {
							text = coronation_tt_positive_major
							scope:activity = { activity_special_type_progression_major = yes }
						}
						scope:activity = {
							every_attending_character = {
								limit = {
									this != root
									this != scope:crush_initiator
								}
								add_opinion = {
									target = root
									modifier = impressed_opinion
									opinion = 10
								}
								custom = custom.every_activity_guest
							}
						}
					}

					# Remove the stampede modifier early
					root.location.county = {
						remove_county_modifier = ach_coronation_stampede_modifier
					}
					# Inform the initiator they failed in a critical persuasian
					scope:crush_initiator = {
						send_interface_toast = {
							title = ach_coronation.0015.a.tt.initiator.critical_failure
							custom_tooltip = ach_coronation.0015.a.tt.initiator.critical_failure.desc
							left_icon = root
							right_icon = scope:host

							stress_impact = {
								base = medium_stress_impact_gain
								irritable = medium_stress_impact_gain
							}

							show_as_tooltip = {
								scope:host = {
									custom_tooltip = {
										text = coronation_tt_positive_major
										scope:activity = { activity_special_type_progression_major = yes }
									}
									add_diplomacy_lifestyle_perk_points = 1
								}
								scope:activity = {
									every_attending_character = {
										limit = {
											this != scope:host
											this != scope:crush_initiator
										}
										add_opinion = {
											target = scope:host
											modifier = impressed_opinion
											opinion = 10
										}
										custom = custom.every_activity_guest
									}
								}
							}
						}
					}
				}
			}
			# Your speech calms the people
			40 = {
				# If you have the August trait (and higher than low_skill_rating), critical success is free
				trigger = { NOT = { has_trait = august } }
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = diplomat
					add = 30
				}

				desc = ach_coronation.0015.a.tt.success

				ach_coronation_0015_minor_crush_effect = yes

				# You'll remember this
				create_character_memory = { type = calmed_the_crowd_memory }

				custom_tooltip = coronation_tt_positive_medium
				scope:activity = { activity_special_type_progression_medium = yes }
				coronation_add_magnificence_log_effect = {
					VALUE = flag:positive_medium
					CHAR = root
				}

				hidden_effect = {
					send_interface_toast = {
						title = ach_coronation.0015.a.tt.success
						custom_tooltip = ach_coronation.0015.a.tt.success.desc
						left_icon = root
						type = event_toast_effect_good

						# Everyone is impressed
						custom_tooltip = coronation_tt_positive_medium
						scope:activity = {
							activity_special_type_progression_medium = yes
						}
					}

					# Inform the initiator they failed
					scope:crush_initiator = {
						send_interface_toast = {
							title = ach_coronation.0015.a.tt.initiator.failure
							custom_tooltip = ach_coronation.0015.a.tt.initiator.failure.desc
							left_icon = root
							right_icon = scope:host

							scope:host = {
								custom_tooltip = coronation_tt_positive_medium
							}
						}
					}
				}
			}
			# The fools do not listen
			40 = {
				# If you have the August trait (and higher than low_skill_rating), critical success is free
				trigger = { NOT = { has_trait = august } }
				compare_modifier = {
					value = scope:duel_value
					multiplier = -4
					min = -49
				}
				modifier = { # Hard to ignore
					has_trait = august
					add = -20
				}
				modifier = { # Hard to get people to listen
					OR = {
						has_trait = stuttering
						has_trait = lisping
					}
					add = 10
				}

				desc = ach_coronation.0015.a.tt.failure

				ach_coronation_0015_medium_crush_effect = yes

				custom_tooltip = coronation_tt_negative
				scope:activity = { activity_special_type_progression_negative = yes }
				coronation_add_magnificence_log_effect = {
					VALUE = flag:negative
					CHAR = root
				}

				hidden_effect = {
					send_interface_toast = {
						title = ach_coronation.0015.a.tt.failure.title
						desc = ach_coronation.0015.a.tt.failure
						left_icon = root
						type = event_toast_effect_bad

						stress_impact = {
							base = medium_stress_impact_gain
							irritable = medium_stress_impact_gain
						}

						custom_tooltip = coronation_tt_negative
					}

					# Inform the initiator they succeeded
					scope:crush_initiator = {
						send_interface_toast = {
							title = ach_coronation.0015.a.tt.initiator.success
							desc = ach_coronation.0015.a.tt.initiator.success.desc
							left_icon = root
							right_icon = scope:host

							show_as_tooltip = {
								scope:host = {
									stress_impact = {
										base = medium_stress_impact_gain
										irritable = medium_stress_impact_gain
									}

									custom_tooltip = coronation_tt_negative
								}
							}
						}
					}
				}
			}
		}
		if = {
			limit = { exists = scope:new_memory }
			scope:new_memory = {
				set_variable = {
					name = memory_location
					value = root.location
				}
			}
		}

		stress_impact = {
			callous = minor_stress_impact_gain # Doesn't care
			shy = minor_stress_impact_gain # Talk to people!?
		}

		ai_chance = {
			base = 200
			modifier = {
				add = -25
				has_trait = callous
			}
			modifier = {
				add = -25
				has_trait = shy
			}
			modifier = {
				add = -50
				has_trait = sadistic
			}
			modifier = {
				add = 25
				has_trait = calm
			}
			modifier = {
				add = 50
				has_trait = compassionate
			}
			modifier = {
				add = 50
				has_trait = gregarious
			}
		}
	}

	option = { # Physician / Learning - Tend to the wounded
		name = ach_coronation.0015.b
		flavor = ach_coronation.0015.b.flavor
		trigger = {
			OR = {
				learning >= high_skill_rating
				has_trait = lifestyle_physician
			}
		}
		skill = learning
		trait = lifestyle_physician

		random = {
			chance = 25
			custom_tooltip = coronation_tt_negative
			scope:activity = { activity_special_type_progression_negative = yes }
			coronation_add_magnificence_log_effect = {
				VALUE = flag:negative
				CHAR = root
			}
		}

		add_piety = major_piety_gain
		add_learning_lifestyle_xp = medium_lifestyle_experience

		show_as_tooltip = {
			scope:activity = {
				every_attending_character = {
					limit =  { is_ai = yes }
					custom = every_wounded_guest_in_crowd_scope_tt
					show_as_tooltip = {
						add_character_modifier = {
							modifier = ach_coronation_treated_wound_modifier
							years = 5
						}
						add_opinion = {
							target = root
							modifier = thankful_opinion
							opinion = 20
						}
					}
				}
			}
		}

		hidden_effect = {
			every_in_list = {
				list = in_crowd_crush
				add_opinion = {
					target = root
					modifier = thankful_opinion
					opinion = 20
				}
				add_character_modifier = {
					modifier = ach_coronation_treated_wound_modifier
					years = 5
				}
			}
			# Inform the initiator they failed
			scope:crush_initiator = {
				send_interface_toast = {
					title = ach_coronation.0015.a.tt.initiator.failure
					custom_tooltip = ach_coronation.0015.a.tt.initiator.failure.physician.desc
					left_icon = root
					right_icon = scope:host

					show_as_tooltip = {
						scope:host = {
							custom_tooltip = coronation_tt_positive_medium

							add_piety = major_piety_gain
						}
					}
				}
			}
		}

		stress_impact = {
			arrogant = medium_stress_impact_gain # "Peasant blood? On *my* hands?"
			sadistic = medium_stress_impact_gain # "No wait this is great let's just watch"
			compassionate = major_stress_impact_loss # "Mass casualty events are bad :(((" ~ local buzzkill
		}

		ai_chance = {
			base = 300
			modifier = {
				add = 100
				has_trait = compassionate
			}
			modifier = {
				add = -100
				has_trait = sadistic
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
		}
	}

	option = { # Set the guards on them!
		name = {
			trigger = { primary_title = { has_variable = founded_varangian_guard } }
			text = ach_coronation.0015.d.byzantines
		}
		name = ach_coronation.0015.d
		trait = overseer
		add_internal_flag = dangerous

		add_dread = miniscule_dread_gain

		random_list = {
			1 = { # The soldiers go too far
				ach_coronation_0015_major_crush_effect = yes
				add_tyranny = medium_tyranny_gain

				hidden_effect = {
					# Inform the initiator they succeeded
					scope:crush_initiator = {
						send_interface_toast = {
							title = ach_coronation.0015.a.tt.initiator.critical_success
							custom_tooltip = ach_coronation.0015.a.tt.initiator.critical_success.desc
							left_icon = root
							right_icon = scope:host

							show_as_tooltip = {
								scope:host = {
									ach_coronation_0015_major_crush_effect = yes
									add_tyranny = medium_tyranny_gain
									add_dread = miniscule_dread_gain
								}
							}
						}
					}
				}
			}
			2 = { # The soldiers kill a bunch of people but restore order
				ach_coronation_0015_medium_crush_effect = yes
				add_tyranny = minor_tyranny_gain

				hidden_effect = {
					# Inform the initiator they failed
					scope:crush_initiator = {
						send_interface_toast = {
							title = ach_coronation.0015.a.tt.initiator.failure
							custom_tooltip = ach_coronation.0015.a.tt.initiator.failure.crackdown.desc
							left_icon = root
							right_icon = scope:host

							show_as_tooltip = {
								scope:host = {
									ach_coronation_0015_medium_crush_effect = yes
									add_dread = miniscule_dread_gain
									add_character_modifier = {
										modifier = ach_coronation_crackdown_character_modifier
										years = 5
									}
								}
							}
						}
					}
				}
			}
			3 = { # The crowds disperse before many are killed
				ach_coronation_0015_minor_crush_effect = yes

				hidden_effect = {
					# Inform the initiator they failed
					scope:crush_initiator = {
						send_interface_toast = {
							title = ach_coronation.0015.a.tt.initiator.failure
							custom_tooltip = ach_coronation.0015.a.tt.initiator.failure.crackdown.desc
							left_icon = root
							right_icon = scope:host

							show_as_tooltip = {
								scope:host = {
									ach_coronation_0015_minor_crush_effect = yes
									add_character_modifier = {
										modifier = ach_coronation_crackdown_character_modifier
										years = 5
									}
									add_dread = miniscule_dread_gain
								}
							}
						}
					}
				}
			}
		}

		if = {
			limit = {
				NOT = { has_trait = overseer }
			}
			custom_tooltip = coronation_tt_negative
			scope:activity = { activity_special_type_progression_negative = yes }
			coronation_add_magnificence_log_effect = {
				VALUE = flag:negative
				CHAR = root
			}
		}
		else = {
			custom_tooltip = because_you_have_overseer_tt
		}

		add_character_modifier = {
			modifier = ach_coronation_crackdown_character_modifier
			years = 5
		}
		root.location = {
			add_province_modifier = {
				modifier = ach_coronation_crackdown_modifier
				years = 5
			}
			county = {
				change_development_progress = medium_development_progress_loss
			}
		}

		stress_impact = {
			compassionate = medium_stress_impact_gain
			arrogant = minor_stress_impact_loss # Loves calling guards on the commons
			# Loves seeing guards beat people
			callous = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
			overseer = minor_stress_impact_loss
		}
		
		ai_chance = {
			base = 100
			modifier = {
				add = -50
				has_trait = compassionate
			}
			modifier = {
				add = 25
				has_trait = arbitrary
			}
			modifier = {
				add = 25
				has_trait = arrogant
			}
			modifier = {
				add = 50
				has_trait = sadistic
			}
			modifier = {
				add = 50
				has_trait = callous
			}
			modifier = {
				add = 50
				has_trait = overseer
			}
		}
	}

	option = { # Getting coronated - Who cares
		name = ach_coronation.0015.e

		random = {
			chance = 50
			custom_tooltip = coronation_tt_negative
			scope:activity = { activity_special_type_progression_negative = yes }
			coronation_add_magnificence_log_effect = {
				VALUE = flag:negative
				CHAR = root
			}
		}

		ach_coronation_0015_medium_crush_effect = yes
		add_prestige = minor_prestige_loss

		hidden_effect = {
			# Inform the initiator they succeeded
			scope:crush_initiator = {
				send_interface_toast = {
					title = ach_coronation.0015.a.tt.initiator.success
					custom_tooltip = ach_coronation.0015.a.tt.initiator.success.desc
					left_icon = root
					right_icon = scope:host

					show_as_tooltip = {
						scope:host = {
							stress_impact = {
								base = medium_stress_impact_gain
								irritable = medium_stress_impact_gain
							}

							add_prestige = minor_prestige_loss
							add_piety = minor_piety_loss

							custom_tooltip = coronation_tt_negative
						}
					}
				}
			}
		}

		stress_impact = {
			arrogant = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			sadistic = medium_stress_impact_loss
			craven = medium_stress_impact_loss
			brave = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				add = -50
				has_trait = compassionate
			}
			modifier = {
				add = -50
				has_trait = brave
			}
			modifier = {
				add = 25
				has_trait = craven
			}
			modifier = {
				add = 25
				has_trait = sadistic
			}
			modifier = {
				add = 25
				has_trait = callous
			}
			modifier = {
				add = 25
				has_trait = arrogant
			}
		}
	}

	after = {
		hidden_effect = {
			scope:peasant = { silent_disappearance_effect = yes }
			scope:filthy_peasant = { silent_disappearance_effect = yes }
		}
	}
}

######################
# Guest: You present your host a gift
# 0016
scripted_trigger ach_coronation_0016_eligible_artifact = {
	NOR = {
		artifact_slot_type = helmet
		artifact_slot_type = regalia
		has_variable = banner_house
		has_variable = banner_dynasty
		has_variable = 1025_treasure_map
	}
	artifact_durability > 10
}

scripted_trigger ach_coronation_0016_can_be_swayed_trigger = {
	NOR = {
		is_in_guest_subset = { name = detractor }
		is_in_guest_subset = { name = supporter }
	}
	is_ai = yes
	is_vassal_of = involved_activity.activity_host
	NOR = {
		has_trait = disloyal
		has_trait = loyal
	}
}

scripted_effect liege_reward_effect = {
	switch = {
		trigger = has_activity_intent
		coronation_bear_witness = {
			if = {
				limit = {
					has_legitimacy = yes
				}
				add_legitimacy = minor_legitimacy_gain
			}
			else_if = {
				limit = {
					government_allows = administrative
					top_liege = involved_activity.activity_host
				}
				change_influence = medium_influence_gain
			}
			else = {
				add_prestige = medium_prestige_gain
			}
		}
		coronation_offer_support = {
			reverse_add_opinion = {
				target = scope:host
				modifier = thankful_opinion
				opinion = 30
				years = 10
			}
			custom_tooltip = {
				text = coronation_tt_positive_medium
				scope:activity = { activity_special_type_progression_medium = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive
        	    CHAR = root
        	}
		}
		coronation_advocate_domain = {
			capital_county = {
				add_county_modifier = {
					modifier = ach_liege_subsidies_modifier
					years = 10
				}
			}
		}
		coronation_profess_rights = {
			if = {
				limit = {
					can_add_hook = {
						target = scope:host
						type = favor_hook
					}
				}
				random = {
					chance = 33
					add_hook = {
						target = scope:host
						type = favor_hook
					}
				}
			}
			else = {
				reverse_add_opinion = {
					target = scope:host
					modifier = thankful_opinion
					opinion = 10
					years = 10
				}
				if = {
					limit = {
						has_lifestyle = stewardship_lifestyle
					}
					add_stewardship_lifestyle_xp = minor_lifestyle_xp
				}
				else = {
					add_diplomacy_lifestyle_xp = minor_lifestyle_xp
				}
			}
		}
		coronation_seize_advantages = {
			if = {
				limit = {
					government_allows = administrative
					top_liege = involved_activity.activity_host
				}
				change_influence = medium_influence_gain
			}
			else = {
				add_prestige = medium_prestige_gain
			}
		}
	}
	if = {
		limit = {
			NOT = {
				has_activity_intent = coronation_offer_support
			}
		}
		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:host
			opinion = 15
		}
	}
	
	custom_tooltip = ach_coronation.0016.reward.tt
}

ach_coronation.0016 = {
	type = activity_event
	title = ach_coronation.0016.t
	desc = ach_coronation.0016.desc
	theme = coronation_activity

	left_portrait = {
		character = root
		animation = obsequious_bow
	}

	right_portrait = {
		character = scope:host
		animation = interested
	}

	artifact = {
		trigger = { exists = scope:gifted_artifact }
		target = scope:gifted_artifact
		position = lower_center_portrait
	}

	cooldown = { years = 1 }

	override_background = { reference = throne_room }

	trigger = {
		is_physically_able = yes
		involved_activity = {
			activity_host = {
				this != root
				is_ai = yes
			}
			any_attending_character = {
				ach_coronation_0016_can_be_swayed_trigger = yes
				this != root
			}
		}

		NOR = {
			trigger_if = {
				limit = {
					is_ai = yes
				}
				is_in_guest_subset = { name = detractor }
			}
			trigger_else = {
				involved_activity = {
					is_target_in_variable_list = {
						name = major_detractor
						target = root 
					}
				}
			}
			has_activity_intent = coronation_disrupt_loyalists
		}
	}

	immediate = {
		involved_activity = {
			activity_host = { save_scope_as = host }
			ordered_attending_character = {
				limit = {
					ach_coronation_0016_can_be_swayed_trigger = yes
					this != root
				}
				order_by = {
					value = 0
					add = "opinion(root)"
					subtract = "opinion(scope:host)"
					if = { # Prefer powerful vassals
						limit = { is_powerful_vassal = no }
						multiply = 0.75
					}
				}
				save_scope_as = detractor
			}
		}

		if = {
			limit = {
				any_character_artifact = {
					ach_coronation_0016_eligible_artifact = yes
				}
			}
			ordered_character_artifact = { # Try and give away the worst one first
				order_by = {
					value = 1
					if = {
						limit = {
							is_equipped = no
						}
						add = 100
					}
					if = {
						limit = {
							rarity = common
						}
						add = 15
					}
					if = {
						limit = {
							rarity = masterwork
						}
						add = 10
					}
					if = {
						limit = {
							rarity = famed
						}
						add = 5
					}
					if = {
						limit = {
							NOT = { creator = root }
						}
						add = 10
					}
				}
				save_scope_as = gifted_artifact
			}
		}
	}
	
	option = { # A: Martial - Promise Troops
		name = ach_coronation.0016.a.martial
		trigger = {
			highest_skill = martial
			martial >= good_skill_level
		}

		scope:host = {
			if = {
				limit = {
					root = { government_has_flag = government_is_nomadic }
				}
				spawn_army = {
					name = event_troop_default_name
					location = capital_province
					inheritable = no
					men_at_arms = {
						type = nomadic_riders
						stacks = {
							value = gok_nomadic_riders_small_value
							divide = 6
						}
					}
					men_at_arms = {
						type = steppe_raiders
						stacks = 2
					}
				}
			}
			else = {
				spawn_army = {
					name = event_troop_default_name
					location = capital_province
					inheritable = no
					levies = {
						add = max_military_strength
						multiply = 0.20
					}
					men_at_arms = {
						type = pikemen_unit
						stacks = 2
					}
				}
			}
		}
		if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			add_character_modifier = {
				modifier = ach_coronation_expended_resources_martial_nomad_modifier
				years = 5
			}
		}
		else = {
			add_character_modifier = {
				modifier = ach_coronation_expended_resources_martial_modifier
				years = 5
			}
		}
		add_martial_lifestyle_xp = minor_lifestyle_xp
		
		liege_reward_effect = yes

		ai_chance = {
			base = 100
		}
	}
	
	option = { # A: Stewardship - Organize Donations
		name = ach_coronation.0016.a.stewardship
		trigger = {
			highest_skill = stewardship
			stewardship >= good_skill_level
		}
		
		if = {
			limit = { has_trait = greedy }
			# Custom tooltip since flavor text isn't triggerable
			custom_tooltip = ach_coronation.0016.a.stewardship.greedy.tt
		}
		else = {
			pay_short_term_gold = {
				target = scope:host
				gold = tiny_gold_value
			}
		}
		involved_activity = {
			every_attending_character = {
				limit = {
					is_ai = yes
					this != root
					is_vassal_or_below_of = scope:host
					NOT = { has_trait = disloyal }
				}
				custom = every_non_disloyal_vassal_attendee_tt
				pay_short_term_gold = {
					target = scope:host
					gold = tiny_gold_value
				}
				add_opinion = {
					target = root
					modifier = annoyed_opinion
					opinion = -10
				}
			}
		}
		liege_reward_effect = yes

		ai_chance = {
			base = 100
		}
	}

	option = { # A: Diplomacy - Turn a Detractor
		name = ach_coronation.0016.a.diplomacy
		trigger = {
			highest_skill = diplomacy
			diplomacy >= good_skill_level
			exists = scope:detractor
		}

		involved_activity = {
			every_attending_character = {
				custom = every_detractor_tt
				limit = { is_in_guest_subset = { name = detractor } }
				add_opinion = {
					target = root
					modifier = annoyed_opinion
					opinion = -15
				}
			}
		}
		coronation_move_towards_supporter_effect = { CHARACTER = scope:detractor }
		scope:detractor = {
			add_opinion = {
				target = scope:host
				modifier = impressed_opinion
				opinion = 20
			}
		}
		liege_reward_effect = yes
	}
	
	option = { # A: Intrigue - Offer Spies
		name = ach_coronation.0016.a.intrigue
		trigger = {
			highest_skill = intrigue
			intrigue >= good_skill_level
		}

		scope:host = {
			add_character_modifier = {
				modifier = ach_coronation_little_birds_modifier
				years = 5
			}
			if = {
				limit = { has_trait = paranoid }
				add_stress = medium_stress_loss
			}
		}
		add_character_modifier = {
			modifier = ach_coronation_expended_resources_intrigue_modifier
			years = 5
		}
		liege_reward_effect = yes
		add_intrigue_lifestyle_xp = minor_lifestyle_xp

		ai_chance = {
			base = 100
			modifier = {
				has_trait = schemer
				add = 25
			}
		}
	}
	
	option = { # A: Learning - Appeal to Church
		name = ach_coronation.0016.a.learning
		trigger = {
			highest_skill = learning
			learning >= good_skill_level
		}

		scope:host = {
			add_character_modifier = {
				modifier = ach_coronation_theocratic_allies_modifier
				years = 5
			}
		}
		liege_reward_effect = yes
		add_piety = medium_piety_loss

		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				add = 50
			}
		}
	}
	
	option = { # A: Fallback - Become Loyal and give a hook
		name = ach_coronation.0016.a.loyal

		trigger = {
			NOR = {
				martial >= good_skill_level
				stewardship >= good_skill_level
				diplomacy >= good_skill_level
				intrigue >= good_skill_level
				learning >= good_skill_level
			}
			NOR = {
				has_trait = loyal
				has_trait = disloyal
			}
		}

		add_trait = loyal
		scope:host = {	
			add_hook = {
				type = loyalty_hook
				target = root
			}
		}
		liege_reward_effect = yes

		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				add = 75
			}
			modifier = {
				has_trait = content
				add = 75
			}
			modifier = {
				has_trait = lazy
				add = 50
			}
		}
		stress_impact = {
			base = minor_stress_impact_gain
			ambitious = medium_stress_impact_gain
			content = medium_stress_impact_loss
			lazy = medium_stress_impact_loss
		}
	}
	option = { # B: Host has Impress Attendees
		name = ach_coronation.0016.b.impress_attendees
		name = {
			trigger = {
				OR = {
					has_trait = lifestyle_poet
					has_court_position = court_musician_court_position
					has_court_position = court_poet_court_position
				}
			}
			text = ach_coronation.0016.b.impress_attendees.writer
		}
		trigger = {
			scope:host = { has_activity_intent = coronation_impress_attendees }
			prestige_level >= high_prestige_level
		}
		involved_activity = {
			every_attending_character = {
				custom = activity_every_attendee_tt
				add_opinion = {
					target = scope:host
					modifier = impressed_opinion
					opinion = 10
				}
			}
		}
		reason = prestige_level
		reason = host_activity_intent

		liege_reward_effect = yes
		if = {
			limit = {
				NOT = {
					has_activity_intent = coronation_seize_advantages
				}
			}
			add_prestige = medium_prestige_loss
		}
		else = {
			add_stress = minor_stress_gain
		}
	}
	
	option = { # B: Host has Embrace Supporters
		name = ach_coronation.0016.b.bonds
		trigger = {
			scope:host = { has_activity_intent = coronation_embrace_supporters }
			OR = {
				diplomacy > medium_skill_rating
				has_trait = gregarious
			}
			is_in_guest_subset = { name = supporter }
		}
		reason = host_activity_intent
		scope:host = {
			add_prestige = minor_prestige_gain
		}
		liege_reward_effect = yes
		involved_activity = {
			every_attending_character = {
				custom =  every_supporter_activity
				limit = { is_in_guest_subset = { name = supporter } }
				add_prestige = minor_prestige_gain
			}
		}
		if = {
			limit = {
				NOT = {
					has_activity_intent = coronation_seize_advantages
				}
			}
			add_prestige = medium_prestige_loss
		}
		else = {
			add_stress = minor_stress_gain
		}
	}
	
	option = { # C: Give artifact
		name = ach_coronation.0016.c.artifact
		trigger = { exists = scope:gifted_artifact }

		scope:gifted_artifact = {
			set_variable = {
				name = suppress_artifact_notifications
				value = yes
				days = 1
			}
			set_variable = { 
				name = gifted_artifact 
				value = yes
				days = 1825
			}
			set_owner = {
				target = scope:host
				history = {
					location = root.location
					actor = root
					recipient = scope:host
					type = given
				}
			}
		}
		liege_reward_effect = yes
		if = {
			limit = {
				scope:gifted_artifact = {
					OR = {
						rarity = illustrious
						rarity = famed
					}
				}
			}
			dynasty ?= {
				add_dynasty_prestige = minor_dynasty_prestige_gain
			}
		}
		else_if = {
			limit = {
				scope:gifted_artifact = {
					rarity = masterwork
				}
			}
			dynasty ?= {
				add_dynasty_prestige = miniscule_dynasty_prestige_gain
			}
		}
		

		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				has_trait = avaricious
				add = -25
			}
			modifier = {
				has_trait = disloyal
				add = -50
			}
			modifier = {
				has_trait = loyal
				add = 50
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			avaricious = minor_stress_impact_gain
			disloyal = medium_stress_impact_gain
			loyal = medium_stress_impact_loss
		}
	}
	
	option = { # C: Fallback: Give gold
		name = ach_coronation.0016.c.gold

		trigger = {
			NOT = { exists = scope:gifted_artifact }
		}

		pay_short_term_gold = {
			gold = medium_gold_value
			target = scope:host
		}
		liege_reward_effect = yes

		ai_chance = {
			base = 100
			# More likely if you actually have a chance
			modifier = {
				has_trait = avaricious
				add = -50
			}
			modifier = {
				has_trait = generous
				add = 25
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				has_trait = loyal
				add = 50
			}
			modifier = {
				has_trait = disloyal
				add = -50
			}
			modifier = {
				has_trait = improvident
				add = 50
			}
		}
		stress_impact = {
			generous = minor_stress_impact_loss
			greedy = minor_stress_impact_gain
			avaricious = minor_stress_impact_gain
			improvident = medium_stress_impact_loss
			loyal = medium_stress_impact_loss
			disloyal = medium_stress_impact_gain
		}
	}
	
	option = { # D: I'm good, thanks
		name = {
			trigger = { has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:host } }
			text = ach_coronation.0016.d.hate
		}
		name = ach_coronation.0016.d

		if = {
			limit = {
				has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:host }
			}
			reverse_add_opinion = {
				target = scope:host
				modifier = insulted_opinion 
				opinion = -5
			}
		}

		ai_chance = {
			base = 100
			# More likely if you actually have a chance
			modifier = {
				has_trait = greedy
				add = 25
			}
			modifier = {
				has_trait = disloyal
				add = 25
			}
			modifier = {
				has_trait = loyal
				add = -25
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_loss
			disloyal = minor_stress_impact_loss
			loyal = minor_stress_impact_gain
		}
	}
}

######################
# Guest: faith_warrior reacts to the coronation of a non-crusader_king
# by Jay Zaborowski
# 0017
scripted_trigger ach_coronation_0017_crusader_trigger = {
	OR = {
		has_trait = faith_warrior
		has_trait = crusader_king
	}
}

ach_coronation.0017 = {
	type = activity_event
	title = ach_coronation.0017.t
	desc = {
		desc = ach_coronation.0017.desc
		first_valid = {
			triggered_desc = { # You're the host and not in immediate danger
				trigger = {
					scope:guest = { ach_coronation_0017_crusader_trigger = yes }
				}
				desc = ach_coronation.0017.ending.crusader
			}
			desc = ach_coronation.0017.ending.civilian
		}
	}

	left_portrait = {
		character = root
		animation = dismissal
		camera = camera_event_group_talking_left_left
	}

	center_portrait = {
		character = scope:guest
		animation = interested_left
		camera = camera_event_group_talking_left_center
	}

	right_portrait = {
		character = scope:host
		animation = prayer
		camera = camera_event_kneeling
	}

	theme = coronation_activity

	cooldown = { years = 1 }

	override_background = {
		reference = temple
	}

	trigger = {
		# Crusades are a thing
		religion = {
			exists = var:variable_ghw_unlocked
		}
		# You're some brand of crusader
		ach_coronation_0017_crusader_trigger = yes
		involved_activity = {
			# This beta-ruler dork is not
			activity_host = {
				is_ai = yes
				religion = root.religion
				# Can be a Faith Warrior but isn't
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = this }
				ach_coronation_0017_crusader_trigger = no
				# And is of fighting age
				is_adult = yes
				is_old_character = no
			}
			# Make sure there's actually someone to talk to
			any_attending_character = {
				is_available_in_activity_trigger = yes
				this != root
				this != involved_activity.activity_host
			}
		}
	}

	immediate = {
		involved_activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = {
					is_available_in_activity_trigger = yes
					this != root
					this != scope:host
				}
				weight = {
					base = 1
					# Prefer interesting characters
					modifier = {
						add = 10
						is_of_major_interest_to_root_trigger = yes
					}
					modifier = {
						add = 5
						is_of_minor_interest_to_root_trigger = yes
					}
					# Prefer pot-stirrers
					modifier = {
						OR = {
							has_trait = deceitful
							has_trait = education_intrigue
							has_trait = schemer
							has_activity_intent = coronation_disrupt_loyalists
							AND = {
								is_ai = yes
								is_in_guest_subset = { name = detractor }
							}
						}
						add = 10
					}
					# And someone who's willing to talk to you
					opinion_modifier = {
						opinion_target = root
						multiplier = 0.5
					}
					# And who's willing to talk trash about the Host
					opinion_modifier = {
						opinion_target = scope:host
						multiplier = -1
					}
					# And who isn't also a crusader
					modifier = {
						factor = 0.5
						ach_coronation_0017_crusader_trigger = yes
					}
				}
				save_scope_as = guest
			}
		}
	}

	option = { # Offer Support - You give an endorsement
		name = {
			trigger = { OR = { faith.religion = religion:eastern_orthodox_religion faith.religion = religion:catholic_religion faith.religion = religion:protestant_religion } }
			text = ach_coronation.0017.a.christian
		}
		name = ach_coronation.0017.a

		trigger = {
			has_activity_intent = coronation_offer_support
			prestige_level >= 3
		}
		show_as_unavailable = { has_activity_intent = coronation_offer_support }
		reason = activity_intent
		add_internal_flag = special

		add_prestige = medium_prestige_gain # Good publicity
		add_piety = medium_piety_loss

		scope:host = {
			add_opinion = {
				target = root
				modifier = appreciation_opinion
				opinion = 20
			}
			if = {
				limit = {
					opinion = {
						target = root
						value > 20
					}
					OR = {
						is_ai = yes
						AND = {
							root = { is_ai = no }
							is_ai = no
						}
					}
				}
				progress_towards_friend_effect = {
					REASON = friend_crusader_endorsement
					CHARACTER = root
					OPINION = 0
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = friendliness_opinion
					opinion = 20
				}
			}
			add_prestige = major_prestige_gain
			add_piety = medium_piety_gain
		}

		involved_activity = {
			every_attending_character = {
				limit = {
					is_vassal_of = scope:host
					has_vassal_stance = zealot
					# They don't know what it's really like out there, man
					ach_coronation_0017_crusader_trigger = no
				}
				custom = every_zealot_vassal_guest_tt
				add_opinion = {
					target = scope:host
					modifier = crusader_endorsement_opinion
				}
			}
			every_attending_character = {
				limit = {
					# Thinks this is sort of denigrating
					ach_coronation_0017_crusader_trigger = yes
					this != root
				}
				custom = every_faith_warrior_guest_tt
				add_opinion = {
					target = root
					modifier = crusader_sellout_opinion
				}
			}
		}

		ai_chance = {
			base = 200 # Offer Support means they probably want to do this
			opinion_modifier = {
				opinion_target = scope:host
			}
			# Cynical character's are less likely to do this
			modifier = {
				has_trait = cynical
				factor = {
					value = 0.5 # But hey, politics
					# But some still won't misrepresent themselves
					if = {
						limit = { has_trait = honest }
						add = -0.5
					}
					# "What do you mean I was in it for the money? Me?"
					if = {
						limit = {
							OR = {
								has_trait = deceitful
								has_trait = schemer
							}
						}
						add = 0.5
					}
				}
			}
		}
	}

	option = { # Disrupt Loyalists - You publicly shame HerHim
		name = ach_coronation.0017.b

		trigger = {
			piety_level >= scope:host.piety_level
			has_activity_intent = coronation_disrupt_loyalists
		}
		show_as_unavailable = { has_activity_intent = coronation_disrupt_loyalists }
		reason = activity_intent
		custom_tooltip = available_because_piety_vs_host_tt

		add_prestige = medium_prestige_gain
		add_piety = major_piety_gain

		involved_activity = {
			every_attending_character = {
				limit = {
					is_vassal_of = scope:host
					has_vassal_stance = zealot
				}
				custom = every_zealot_vassal_guest_tt
				add_opinion = {
					target = scope:host
					modifier = impious_opinion 
					opinion = -15
				}
			}
		}
		scope:host = {
			add_opinion = {
				target = root
				modifier = shamed_me_opinion 
				opinion = -25
			}
			add_prestige = medium_prestige_loss
			add_piety = medium_piety_loss
		}

		ai_chance = {
			base = 0
			opinion_modifier = {
				opinion_target = scope:host
				multiplier = -1
			}
			# Far more likely if Arrogant or Wrathful and they dislike the person
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = wrathful
				}
				opinion = {
					target = root
					value < 0
				}
				factor = 2
			}
			# Opinion matters more than these but might tip the scales
			modifier = {
				has_trait = zealous
				add = 15
			}
			# Far less likely in general
			modifier = {
				has_trait = shy
				factor = 0.5
			}
			modifier = {
				has_trait = humble
				factor = 0.5
			}
			modifier = {
				has_trait = calm
				factor = 0.5
			}
			modifier = {
				has_trait = compassionate
				factor = 0.5
			}
			# Cynical characters might just refuse to even think of it
			modifier = {
				has_trait = cynical
				factor = {
					value = 0 # Would never
					# Would consider lying for clout
					if = {
						limit = {
							intrigue >= low_skill_rating
							NOT = { has_trait = honest }
						}
						add = 0.5
					}
					# Would actually *looove* to lie about, like, anything really
					if = {
						limit = {
							OR = {
								has_trait = deceitful
								has_trait = schemer
							}
							# But probably won't if they're chill
							opinion = {
								target = root
								value > low_positive_opinion
							}
						}
						multiply = 4
					}
				}
			}
		}
		stress_impact = {
			# Doesn't care that much, but can be doing this cynically
			cynical = minor_stress_impact_gain
			# Doesn't like the attention
			shy = minor_stress_impact_gain
			humble = medium_stress_impact_gain
			# Conflict-averse
			calm = minor_stress_impact_gain
			compassionate = medium_stress_impact_gain
			# Not so much
			arrogant = medium_stress_impact_loss
			wrathful = medium_stress_impact_loss
			zealous = minor_stress_impact_loss
		}
	}

	option = { # Bah, I shall focus on prayer
		name = ach_coronation.0017.c

		add_piety = medium_piety_gain
		add_character_modifier = {
			modifier = ach_focusing_on_prayer_modifier
			years = 5
		}
		stress_impact = {
			# Is annoyed by it
			base = medium_stress_impact_gain
			# Does *not* want to pray, actually
			cynical = major_stress_impact_gain
			# Is *very* annoyed by it
			arrogant = minor_stress_impact_gain
			# But it's not all bad
			humble = minor_stress_impact_loss # Because I don't care *that* much
			zealous = minor_stress_impact_loss # Because I love prayer
			shy = minor_stress_impact_loss # Because if I pray you'll shut up
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 0.5
			}
			modifier = {
				has_trait = humble
				factor = 2
			}
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = shy
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}
		}
	}

	option = { # It's not a competition, fool!
		name = ach_coronation.0017.d
		name = {
			trigger = {
				OR = {
					has_trait = cynical
					has_trait = humble
					has_trait = shy
				}
				NOT = { has_trait = arrogant }
			}
			text = ach_coronation.0017.d.cynical # Literally who cares
		}

		# Not making a big deal of it is respected
		add_prestige = minor_prestige_gain
		add_piety = minor_piety_gain
		scope:guest = {
			add_opinion = {
				target = root
				modifier = respect_opinion 
				opinion = 10
			}
		}

		stress_impact = {
			# No Zealot impact because the player can interpret this either way
			arrogant = medium_stress_impact_gain # You *do* deserve it more
			humble = medium_stress_impact_loss
			shy = medium_stress_impact_loss # Actually it's sort of nice
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 0.5
			}
			modifier = {
				has_trait = humble
				factor = 2
			}
			modifier = {
				has_trait = shy
				factor = 2
			}
		}
	}
}

######################
# Guest: Close family member of Host sees opportunity
# 0018
scripted_trigger ach_coronation_0018_eligible_family_member_trigger = {
	#You can't just give stress and stuff to players
	is_ai = yes
	is_available_in_activity_trigger = yes
	this != scope:host
	is_close_or_extended_family_of = scope:host
	NOT = { has_trait = disloyal }
	trigger_if = { # For ach_coronation.0020
		limit = { is_ai = yes }
		opinion = {
			target = scope:host
			value >= low_positive_opinion
		}
	}
}

scripted_trigger ach_coronation_0018_grantable_title_trigger = {
	tier = tier_county
	this != scope:host.capital_county
}

scripted_effect ach_coronation_0018_choose_title_effect = {
	scope:host = {
		random_held_title = {
			limit = { ach_coronation_0018_grantable_title_trigger = yes }
			weight = {
				base = 100
				# Prefer worse titles
				modifier = {
					add = {
						value = development_level
						multiply = -1
					}
				}
				# Even more if it's some backwards other-language hellhole
				modifier = {
					culture != scope:host.culture
					factor = 2
				}
				modifier = {
					faith != scope:host.faith
					factor = 2
				}
			}
			save_scope_as = grantable_title
		}
	}
}

ach_coronation.0018 = {
	type = activity_event
	title = ach_coronation.0018.t
	desc = {
		desc = ach_coronation.0018.desc
		first_valid = {
			triggered_desc = { # There's a Seneschal
				trigger = {
					scope:servant_boss = { has_court_position = seneschal_court_position }
				}
				desc = ach_coronation.0018.desc.seneschal
			}
			triggered_desc = { # There's a Steward
				trigger = {
					scope:servant_boss = { has_council_position = councillor_steward }
				}
				desc = ach_coronation.0018.desc.steward
			}
			triggered_desc = { # There is no Seneschal or Steward
				trigger = { NOT = { exists = scope:servant_boss } }
				desc = ach_coronation.0018.desc.fallback
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:servant_boss }
				desc = ach_coronation.0018.desc.ending.servant_boss
			}
			desc = ach_coronation.0018.desc.ending.no_servant_boss
		}
	}

	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_left
	}

	center_portrait = {
		character = scope:servant
		triggered_animation = {
			trigger = { exists = scope:servant_boss }
			animation = throne_room_messenger_3
		}
		animation = stress
		camera = camera_event_right_pointing_left_fov50
		hide_info = yes
	}

	right_portrait = {
		character = scope:servant_boss
		animation = stress
		camera = camera_event_very_right_fov50
	}

	lower_left_portrait = {
		character = scope:host
	}

	weight_multiplier = {
		base = 1
		# Far more likely if there is no Seneschal
		modifier = {
			NOT = { exists = court_position:seneschal_court_position }
			factor = 3
		}
		# If there is a Seneschal than low Aptitude raises likeliness
		activity_court_position_aptitude_negative_modifier = { LIEGE = root POS = seneschal }
	}
	
	theme = coronation_activity

	cooldown = { years = 1 }
	override_background = {
		trigger = {
			#Do not want generic courtyard calling up Constantinople for this one
			location.county = title:c_byzantion
		}
		reference = bp2_courtyard
	}
	override_background = {
		reference = courtyard
	}

	override_effect_2d = {
		trigger = { exists = scope:rain_day }
		reference = rain
	}

	trigger = {
		ach_coronation_0018_eligible_family_member_trigger = yes
		coronation_hostile_to_host_trigger = no
		involved_activity = {
			activity_host = {
				# Don't potentially screw over a player Seneschal
				trigger_if = {
					limit = { exists = court_position:seneschal_court_position }
					court_position:seneschal_court_position = { is_ai = yes }
				}
				# If we need a Steward but they're absent, make sure they're not a player so we can teleport them
				trigger_else = {
					cp:councillor_steward ?= { is_ai = yes }
				}
			}
		}
	}

	immediate = {
		# For the event art
		create_character = {
			save_scope_as = servant
			employer = involved_activity.activity_host
			template = servant_character
			gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
		}
		random_rain_snow_chance_effect = yes

		involved_activity = {
			hidden_effect = {
				if = { # Grab a secret for the opt-out option
					limit = {
						any_attending_character = {
							this != root
							is_available_in_activity_trigger = yes
							any_secret = {
								NOT = { is_known_by = root }
							}
						}
					}
					random_attending_character = {
						limit = {
							this != root
							is_available_in_activity_trigger = yes
							any_secret = {
								NOT = { is_known_by = root }
							}
						}
						save_scope_as = secret_holder
						random_secret = {
							limit = { NOT = { is_known_by = root } }
							save_scope_as = secret_to_reveal
						}
					}
				}
				else = { # Create one if you can't find one
					random_attending_character = {
						limit = {
							this != root
							is_available_in_activity_trigger = yes
						}

						weight = {
							base = 1
							# Prefer interesting characters (but not by too much)
							modifier = {
								add = 4
								is_of_major_interest_to_root_trigger = yes
							}
							modifier = {
								add = 2
								is_of_minor_interest_to_root_trigger = yes
							}
						}

						give_random_likely_secret_effect = yes
						save_scope_as = secret_holder
						random_secret = {
							limit = { NOT = { is_known_by = root } }
							save_scope_as = secret_to_reveal
						}
					}
				}
				activity_host = {
					save_scope_as = host
					if = { # If the Seneschal exists and isn't AI then they're the Servant Boss
						limit = {
							court_position:seneschal_court_position ?= { is_ai = yes }
						}
						court_position:seneschal_court_position = { save_scope_as = servant_boss }
					}
					else = { # Else it's the Steward
						cp:councillor_steward = {
							save_scope_as = servant_boss
						}
					}
				}
				scope:servant_boss = {
					if = { # Teleport them if they're not at the coronation
						limit = { location != scope:host.involved_activity.activity_location }
						set_location = { location = scope:host.involved_activity.activity_location }
					}
					if = { # And add them to the activity if they're not in it
						limit = { can_join_activity = scope:host.involved_activity }
						add_to_activity_without_travel = scope:host.involved_activity
					}
				}
			}
		}
	}

	option = { # A: Seize Advantages | Offer Support: Take charge of the servants
		name = ach_coronation.0018.a.intent
		reason = activity_intent
		add_internal_flag = special

		trigger = {
			OR = {
				has_activity_intent = coronation_seize_advantages
				has_activity_intent = coronation_offer_support
			}
		}

		if = {
			limit = { has_trait = diligent }
			custom_tooltip = because_you_have_diligent_tt
		}
		else = {
			add_character_modifier = {
				modifier = exhausted_modifier
				years = 10
			}
		}

		duel = {
			skill = stewardship
			value = average_skill_rating
			8 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
				}
				desc = ach_coronation.0018.a.tt_success
				
				custom_tooltip = ach_can_refuse_reward

				if = { # Offer a title
					limit = { # Host has a title to give
						scope:host = {
							any_held_title = { ach_coronation_0018_grantable_title_trigger = yes }
							# And doesn't hate you
							NOR = {
								opinion = {
									target = scope:host
									value <= medium_negative_opinion
								}
								has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
							}
						}
						# Host can actually give you the title
						can_be_granted_titles_by = { RULER = scope:host }
						# Host isn't giving a vassal more land just for being mildly helpful
						is_landed = no
					}

					custom_tooltip = ach_coronation.0018.a.tt.vassal

					hidden_effect = {
						save_scope_value_as = {
							name = reward_type
							value = flag:title
						}
					}
				}
				else_if = { # Offer the Seneschal spot
					limit = {
						scope:host = {
							can_appoint_char_to_court_position = {
								CHAR = scope:host
								COURT_POS = seneschal_court_position
							}
						}
					}

					show_as_tooltip = {
						court_position_grant_effect = {
							POS = seneschal
							EMPLOYER = scope:host
							CANDIDATE = root
						}
					}

					hidden_effect = {
						save_scope_value_as = {
							name = reward_type
							value = flag:court_position
						}
					}
				}
				else = { # Give public praise
					show_as_tooltip = {
						add_prestige = medium_prestige_gain
						
						involved_activity = {
							every_attending_character = {
								limit = {
									this != root
									this != scope:host
								}
								custom = every_guest_scope_tt
								add_opinion = {
									target = root
									modifier = impressed_opinion
									opinion = 10
								}
							}
						}
					}

					hidden_effect = {
						save_scope_value_as = {
							name = reward_type
							value = flag:praise
						}
					}
				}

				send_interface_toast = {
					title = ach_coronation.0018.a.tt_success
					reverse_add_opinion = {
						modifier = helpful_opinion
						target = scope:host
						opinion = 15
					}
					hidden_effect = {
						# Player gets a chance to refuse the reward
						trigger_event = ach_coronation.0019
					}
				}
			}
			12 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2
					min = -9
				}
				desc = ach_coronation.0018.a.tt_failure
				send_interface_toast = {
					title = ach_coronation.0018.a.tt_failure
					stress_impact = {   
						base = medium_stress_impact_gain
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		stress_impact = {
			base = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			lazy = medium_stress_impact_gain
			diligent = medium_stress_impact_loss
		}

		ai_chance = {
			base = 150
			modifier = {
				has_trait = diligent
				add = 100
			}
			modifier = {
				has_trait = lazy
				add = -50
			}
			modifier = {
				has_trait = arrogant
				add = -25
			}
		}
	}

	option = { # A: Try to help with preparations
		name = ach_coronation.0018.a
		skill = stewardship

		highlight_portrait = scope:servant_boss

		trigger = {
			NOR = {
				has_activity_intent = coronation_seize_advantages
				has_activity_intent = coronation_offer_support
			}
		}

		if = {
			limit = {
				NOT = { has_trait = diligent }
			}
			add_character_modifier = {
				modifier = exhausted_modifier
				years = 10
			}
		}

		# Does servant_boss	feel like you did them a solid or tried to steal their job?
		if = {
			limit = {
				exists = scope:servant_boss
			}
			if = {
				limit = { # You're diplomatic and smooth things over
					OR = {
						has_trait = gregarious
						has_trait = diplomat
					}
				}
				custom_tooltip = ach_coronation.0018.diplomacy_trait.tt
				send_interface_toast = {
					title = ach_coronation.0018.d.pleased_servant_boss
					left_icon = scope:servant_boss
					reverse_add_opinion = {
						modifier = thankful_opinion
						target = scope:servant_boss
						opinion = 25
					}
				}
			}
			else_if = {
				limit = { # They're not the type of person to perceive this as a slight
					scope:servant_boss = {
						NOR = {
							has_trait = arrogant
							has_trait = ambitious
							has_trait = diligent
							has_trait = vengeful
						}
					}
				}
				send_interface_toast = {
					title = ach_coronation.0018.d.pleased_servant_boss
					left_icon = scope:servant_boss
					reverse_add_opinion = {
						modifier = thankful_opinion
						target = scope:servant_boss
						opinion = 20
					}
				}
			}
			else = { # Else they get annoyed
				custom_tooltip = ach_coronation.0018.d.annoyed_servant_boss
				send_interface_toast = {
					title = ach_coronation.0018.d.annoyed_servant_boss
					left_icon = scope:servant_boss
					reverse_add_opinion = {
						modifier = annoyed_opinion
						target = scope:servant_boss
						opinion = -20
					}
				}
			}
		}

		duel = {
			skill = stewardship
			value = average_skill_rating
			8 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
				}
				desc = ach_coronation.0018.a.tt_success
				send_interface_toast = {
					title = ach_coronation.0018.a.tt_success
					scope:host = {
						add_opinion = {
							modifier = helpful_opinion
							target = root
							opinion = 15
						}
					}
				}
			}
			12 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2
					min = -9
				}
				desc = ach_coronation.0018.a.tt_failure
				send_interface_toast = {
					title = ach_coronation.0018.a.tt_failure
					stress_impact = {
						base = minor_stress_impact_gain
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}

		stress_impact = {
			# Work is hard
			base = minor_stress_impact_gain
			# But not for some
			diligent = medium_stress_impact_loss
			# And for others it's worth it
			ambitious = minor_stress_impact_loss
			# Doesn't want the clout
			content = minor_stress_impact_gain
			# This sounds a lot like labor
			arrogant = minor_stress_impact_gain
			lazy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				add = 25
			}
			modifier = {
				has_trait = ambitious
				add = 25
			}
			modifier = {
				has_trait = content
				add = -25
			}
			modifier = {
				has_trait = arrogant
				add = -25
			}
			modifier = {
				has_trait = lazy
				add = -50
			}
		}
	}

	option = { # B: Gossip with the servants instead
		name = ach_coronation.0018.b
		skill = intrigue

		highlight_portrait = scope:servant

		duel = {
			skill = intrigue
			value = average_skill_rating
			75 = {
				desc = ach_coronation.0018.b.tt.gossip_with_servants
				compare_modifier = {
					value = scope:duel_value
					multiplier = 5
				}
				show_chance = no
				send_interface_toast = {
					title = ach_coronation.0018.b.tt.gossip_with_servants
					left_icon = root
					add_character_modifier = {
						modifier = ach_coronation_gossips_with_servants_modifier
						years = 5
					}
				}
			}
			25 = {	
				compare_modifier = {
					value = scope:duel_value
					multiplier = -5
				}
				min = 10
				show_chance = no
				desc = ach_coronation.0018.b.tt.secret_unknown_desc
				custom_tooltip = ach_coronation.0018.b.tt.secret_unknown
				hidden_effect = {
					send_interface_toast = {
						title = ach_coronation.0018.b.tt.secret
						left_icon = root
						scope:secret_to_reveal = {
							expose_secret = root
						}
					}
				}
			}
		}
		stress_impact = {
			gregarious = minor_stress_impact_loss
			# Sitting around and talking sucks, actually
			impatient = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			# Doesn't want to talk to poors
			arrogant = medium_stress_impact_gain
			# Looooves gossip
			schemer = medium_stress_impact_loss
			deceitful = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = lazy
				add = 25
			}
			modifier = {
				has_trait = gregarious
				add = 25
			}
			modifier = {
				has_trait = impatient
				factor = 0.5
			}
			modifier = {
				has_trait = diligent
				NOR = { # Only wasting time if gossiping isn't your whole deal
					has_trait = education_intrigue
					has_trait = deceitful
					has_trait = schemer
				}
				factor = 0.5
			}
			modifier = {
				has_trait = shy
				factor = 0.5
			}
			modifier = {
				has_trait = arrogant
				factor = 0.5
			}
			modifier = {
				OR = {
					has_trait = education_intrigue
					has_trait = deceitful
					has_trait = schemer
				}
				factor = 2
			}
		}
	}

	option = { # C: Stewardship Lifestyle: Study the ceremony
		name = ach_coronation.0018.c
		trigger = {
			has_lifestyle = stewardship_lifestyle
		}
		skill = stewardship
		reason = lifestyle

		highlight_portrait = scope:servant
		highlight_portrait = scope:servant_boss

		add_stewardship_lifestyle_xp = minor_lifestyle_xp
		add_character_modifier = {
			modifier = ach_coronation_studying_ceremony_modifier
			years = 5
		}

		stress_impact = {
			diligent = minor_stress_impact_loss
			# Super down for not talking
			shy = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				add = 25
			}
			modifier = {
				has_trait = shy
				add = 25
			}
		}
	}

	option = { # D: Just chill
		name = ach_coronation.0018.d

		highlight_portrait = root

		stress_impact = {
			base = medium_stress_impact_loss
			# Wants to do something
			diligent = minor_stress_impact_gain
			# Who really wants Host's approval?
			content = minor_stress_impact_loss
			# Super down for not talking
			shy = minor_stress_impact_loss
			# Doing *absolutely* nothing is based
			lazy = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = content
				add = 25
			}
			modifier = {
				has_trait = shy
				add = 25
			}
			modifier = {
				has_trait = lazy
				add = 50
			}
			modifier = {
				has_trait = diligent
				factor = 0.5
			}
		}
	}

	after = {
		hidden_effect = {
			scope:servant = { silent_disappearance_effect = yes }
		}
	}
}

ach_coronation.0019 = {
	type = letter_event
	opening = {
		desc = ach_coronation.0019.opening
	}
	desc = {
		# Opening
		desc = ach_coronation.0019.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:reward_type = flag:title }
				desc = ach_coronation.0019.desc.title
			}
			triggered_desc = {
				trigger = { scope:reward_type = flag:court_position }
				desc = ach_coronation.0019.desc.court_position
			}
			desc = ach_coronation.0019.desc.praise
		}
	}

	sender = scope:host

	immediate = { ach_coronation_0018_choose_title_effect = yes }

	option = { # Accept
		name = ach_coronation.0019.a

		switch = {
			trigger = scope:reward_type
			flag:title = {
				create_title_and_vassal_change = {
					type = granted
					save_scope_as = change
					add_claim_on_loss = no
				}
				scope:grantable_title = {
					change_title_holder = {
						holder = root
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change

				custom_tooltip = {
					text = your_title_cannot_be_revoked_10_tt
					root = {
						add_character_flag = {
							flag = titles_protected
							years = 10
						}
					}
				}
			}
			flag:court_position = {
				court_position_grant_effect = {
					POS = seneschal
					EMPLOYER = scope:host
					CANDIDATE = root
				}
				if = {
					limit = {
						scope:servant_boss = { has_court_position = seneschal_court_position }
						OR = {
							scope:servant_boss = { is_ai = yes }
							AND = {
								scope:servant_boss = {
									is_ai = no
								}
								is_ai = no
							}
						}
					}
					scope:servant_boss = {
						progress_towards_rival_effect = {
							REASON = rival_jealousy_at_court
							CHARACTER = root
							OPINION = -30
						}
					}
				}
			}
			flag:praise = {
				add_prestige = medium_prestige_gain
				
				involved_activity = {
					every_attending_character = {
						limit = {
							this != root
							this != scope:host
						}
						custom = every_guest_scope_tt
						add_opinion = {
							target = root
							modifier = impressed_opinion
							opinion = 10
						}
					}
				}
			}
		}

		ai_chance = {
			base = 150
			modifier = {
				add = -50
				scope:reward_type = flag:title
				has_trait = content
			}
			modifier = {
				add = -50
				scope:reward_type = flag:court_position
				has_trait = lazy
			}
			modifier = {
				add = -50
				scope:reward_type = flag:praise
				has_trait = shy
			}
		}
	}

	option = { # Ask for gold instead
		name = ach_coronation.0019.b
		trigger = {
			scope:host = { is_ai = yes } # The player doesn't need a multi-event back and forth over this
		}
		scope:host = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
			pay_short_term_gold = {
				gold = minor_gold_value
				target = root
			}
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 50
				scope:reward_type = flag:praise
				has_trait = greedy # No money in praise
			}
			modifier = {
				add = 50
				scope:reward_type = flag:praise
				has_activity_intent = coronation_seize_advantages
			}
		}
	}

	option = { # Their friendship is enough
		name = ach_coronation.0019.c
		if = {
			limit = {
				reverse_opinion = {
					target = scope:host
					value > 20
				}
				OR = {
					scope:host = { is_ai = yes }
					AND = {
						scope:host = { is_ai = no }
						is_ai = no
					}
				}
			}
			progress_towards_friend_effect = {
				CHARACTER = scope:host
				REASON = friend_supported_host_during_coronation
				OPINION = default_friend_opinion
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:host
				modifier = friendliness_opinion
				opinion = 25
			}
		}

		ai_chance = {
			base = 0
			modifier = {
				add = 100
				has_trait = humble
			}
			modifier = {
				add = 50
				scope:reward_type = flag:praise
				has_trait = shy
			}
			modifier = {
				add = 50
				has_activity_intent = coronation_offer_support
			}
		}
	}
}

######################
# Host: Close family member helps manage the coronation
# by Jay Zaborowski
# 0020
ach_coronation.0020 = {
	type = activity_event
	title = ach_coronation.0020.t
	desc = ach_coronation.0020.desc

	left_portrait = {
		character = scope:annoying_servant
		animation = stunned
		camera = camera_event_very_right_pointing_very_left
		hide_info = yes
	}

	center_portrait = {
		character = scope:helpful_family
		animation = stayback
		camera = camera_event_right_pointing_very_right
	}

	right_portrait = {
		character = scope:host
		triggered_animation = {
			trigger = { OR = { scope:host.religion = religion:eastern_orthodox_religion scope:host.religion = religion:catholic_religion scope:host.religion = religion:protestant_religion } }
			animation = emotion_thinking_scepter
		}
		triggered_animation = {
			trigger = { NOT = { OR = { scope:host.religion = religion:eastern_orthodox_religion scope:host.religion = religion:catholic_religion scope:host.religion = religion:protestant_religion } } }
			animation = thinking
		}	
		camera = camera_event_very_left_pointing_right
	}

	theme = coronation_activity

	cooldown = { years = 1 }

	override_background = {
		reference = corridor_day
	}

	trigger = {
		involved_activity = {
			any_attending_character = {
				ach_coronation_0018_eligible_family_member_trigger = yes
			}
		}
	}

	immediate = {
		involved_activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = {
					ach_coronation_0018_eligible_family_member_trigger = yes
				}
				weight = {
					base = 1
					opinion_modifier = {
						opinion_target = scope:host
						multiplier = 0.25
					}
					modifier = {
						add = sum_of_all_skills_value
					}
					modifier = { # Prefer close family
						is_close_family_of = root
						add = 20
					}
					modifier = {
						has_trait = ambitious
						add = 10
					}
					modifier = {
						has_trait = diligent
						add = 10
					}
					# If making them a vassal is on the table, try and get someone who is eligible
					modifier = {
						trigger_if = {
							limit = {
								root = {
									has_activity_intent = coronation_embrace_supporters
									any_held_title = { ach_coronation_0018_grantable_title_trigger = yes }
								}
								NOT = { can_be_granted_titles_by = { RULER = root } }
							}
						}
						factor = 0.1
					}
				}
				save_scope_as = helpful_family
				add_character_modifier = {
					modifier = exhausted_modifier
					years = 10
				}
				if = {
					limit = {
						has_trait = diligent
					}
					add_stress = minor_stress_gain
				}
				else = {
					add_stress = major_stress_gain
				}
			}
		}

		ach_coronation_0018_choose_title_effect = yes

		if = { # Grab a courtier for the background
			limit = {
				any_courtier_or_guest = {
					this != scope:helpful_family
					this != root
					is_available_in_activity_trigger = yes
				}
			}
			random_courtier_or_guest = {
				limit = {
					this != scope:helpful_family
					this != root
					is_available_in_activity_trigger = yes
				}
				save_scope_as = annoying_servant
			}
		}
		else_if = { # If there wasn't one grab a pool char
			limit = {
				any_pool_character = {
					province = involved_activity.activity_location
					this != scope:helpful_family
					this != root
					is_available_in_activity_trigger = yes
				}
			}
			random_pool_character = {
				province = involved_activity.activity_location
				limit = {
					this != scope:helpful_family
					this != root
					is_available_in_activity_trigger = yes
				}
				save_scope_as = annoying_servant
			}
		}
		else = { # Else, make one
			create_character = {
				save_scope_as = annoying_servant
				employer = root
				template = servant_character
				gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
			}
			add_character_flag = created_character_ach_coronation_0020
		}
	}

	option = { # A: Embrace Supporters: They would be a loyal vassal!
		name = ach_coronation.0020.a
		reason = activity_intent
		add_internal_flag = special

		trigger = {
			has_activity_intent = coronation_embrace_supporters
			exists = scope:grantable_title
			scope:helpful_family = {
				can_be_granted_titles_by = { RULER = root }
			}
		}
		show_as_unavailable = {
			AND = {
				has_activity_intent = coronation_embrace_supporters
				exists = scope:grantable_title
			}
		}

		create_title_and_vassal_change = {
			type = granted
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:grantable_title = {
			change_title_holder = {
				holder = scope:helpful_family
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change

		coronation_move_towards_supporter_effect = { CHARACTER = scope:helpful_family }

		custom_tooltip = {
			text = character_title_cannot_be_revoked_tt
			scope:helpful_family = {
				add_character_flag = {
					flag = titles_protected
					years = 10
				}
			}
		}

		scope:helpful_family = {
			add_trait = loyal
			add_opinion = {
				modifier = loyalty_opinion
				target = scope:host
				opinion = 25
			}
		}
		add_hook = {
			target = scope:helpful_family
			type = loyalty_hook
		}

		coronation_embrace_supporters_opinion_effect = yes
	}

	option = { # B: Family First: This is how we do things in my dynasty!
		name = ach_coronation.0020.b
		trait = family_first

		trigger = { has_trait = family_first }
		show_as_unavailable = { always = yes }

		every_close_family_member = {
			custom = every_family_member_tt
			limit = {
				NOT = { this = root }
			}
			add_opinion = {
				target = root
				modifier = love_opinion
				opinion = 20
			}
		}
		dynasty ?= {
			add_dynasty_modifier = {
				modifier = ach_familial_support_modifier
				years = 10
			}
		}
	}
	
	option = { # C: They truly are a great GetRelationToMe
		name = ach_coronation.0020.c
		if = {
			limit = {
				can_set_relation_potential_friend_trigger = { CHARACTER = scope:helpful_family }
				reverse_opinion = {
					target = scope:helpful_family
					value > 20
				}
				OR = {
					scope:helpful_family = { is_ai = yes }
					AND = {
						scope:helpful_family = { is_ai = no }
						is_ai = no
					}
				}
			}
			set_relation_potential_friend = scope:helpful_family
		}
		coronation_move_towards_supporter_effect = { CHARACTER = scope:helpful_family }
		scope:helpful_family = {
			add_opinion = {
				target = root
				modifier = love_opinion
				opinion = 20
			}
		}
	}
	
	option = { # D: They're a model for all my subjects
		name = ach_coronation.0020.d
		add_prestige = minor_prestige_gain
	}

	after = {
		add_stress = medium_stress_loss
		if = {
			limit = { has_character_flag = created_character_ach_coronation_0020 }
			hidden_effect = {
				scope:annoying_servant = { silent_disappearance_effect = yes }
				remove_character_flag = created_character_ach_coronation_0020
			}
		}
	}
}

######################
# Guest: An ongoing plague has shaken a zealous guest
# by Jay Zaborowski
# 0022
scripted_trigger ach_coronation_0022_valid_zealot_trigger = {
	is_ai = yes
	faith = scope:host.faith
	highest_held_title_tier >= tier_county
	OR = {
		has_trait = zealous
		trigger_if = {
			limit = { is_vassal_or_below_of = scope:host }
			has_vassal_stance = zealot
		}
	}
	NOR = {
		this = scope:host
		this = root
		has_trait = cynical
		has_trait = loyal
		# Don't want anyone who wouldn't listen to you
		has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
	}
}

scripted_trigger ach_coronation_0022_loose_zealot_trigger = {
	is_ai = yes
	faith = involved_activity.activity_host.faith
	highest_held_title_tier >= tier_county
	OR = {
		ai_zeal >= low_positive_ai_value
		has_trait = zealous
		trigger_if = {
			limit = { is_vassal_or_below_of = involved_activity.activity_host }
			has_vassal_stance = zealot
		}
		has_trait = lifestyle_mystic
		has_trait = paranoid
		has_trait = craven
		has_trait = devoted
	}
	NOR = {
		this = involved_activity.activity_host
		this = root
		has_trait = cynical
		# Don't want anyone who wouldn't listen to you
		has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
	}
}

ach_coronation.0022 = {
	type = activity_event
	title = ach_coronation.0022.t
	desc = {
		desc = ach_coronation.0022.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:host = { primary_title = title:e_byzantium } }
				desc = ach_coronation.0022.desc.whisper.byzantine
			}
			triggered_desc = {
				trigger = { scope:host = { primary_title = title:e_hre } }
				desc = ach_coronation.0022.desc.whisper.hre
			}
			triggered_desc = {
				trigger = { scope:host = { num_sinful_traits >= 2 } }
				desc = ach_coronation.0022.desc.whisper.sinner
			}
			triggered_desc = {
				trigger = { scope:host.culture = { has_innovation = innovation_divine_right } }
				desc = ach_coronation.0022.desc.whisper.divine_right
			}
			desc = ach_coronation.0022.desc.whisper.fallback
		}
		desc = ach_coronation.0022.desc.ending
	}
	theme = coronation_activity

	override_background = {
		reference = temple
	}

	cooldown = { years = 1 }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_activity_intent = coronation_disrupt_loyalists }
			animation = interested
		}
		animation = thinking
	}
	right_portrait = {
		character = scope:zealot
		animation = prayer
		camera = camera_event_very_right_close
	}

	trigger = {
		involved_activity = {
			activity_host = {
				save_temporary_scope_as = host_temp
				is_ai = yes
				# Ongoing plague
				any_sub_realm_county = {
					count >= 3
					any_county_province = {
						any_province_epidemic = {
							count >= 1
							outbreak_intensity > minor
						}
					}
				}
			}
			any_attending_character = {
				ach_coronation_0022_loose_zealot_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			has_activity_intent = coronation_disrupt_loyalists
			factor = 2
		}
		modifier = {
			has_activity_intent = coronation_offer_support
			factor = 2
		}
		modifier = {
			involved_activity = {
				activity_host = {
					# Ongoing plague
					any_sub_realm_county = {
						count >= 10
						any_county_province = {
							any_province_epidemic = {
								count >= 1
								outbreak_intensity > minor
							}
						}
					}
				}
			}
			factor = 2
		}
		modifier = {
			involved_activity = {
				activity_host = {
					# Ongoing plague
					any_sub_realm_county = {
						count >= 3
						any_county_province = {
							any_province_epidemic = {
								count >= 1
								outbreak_intensity > major
							}
						}
					}
				}
			}
			factor = 2
		}
		modifier = {
			involved_activity = {
				activity_location = {
					any_province_epidemic = {
						count >= 1
						outbreak_intensity > minor
					}
				}
			}
			factor = 2
		}
	}

	immediate = {
		involved_activity = {
			activity_host = {
				save_scope_as = host
				# Get the ongoing plague
				if = {
					limit = {
						any_sub_realm_county = {
							count >= 4
							any_county_province = {
								any_province_epidemic = {
									count >= 1
									outbreak_intensity = apocalyptic
								}
							}
						}
					}
					get_random_realm_epidemic = { INTENSITY = apocalyptic }
				}
				else = {
					get_random_realm_epidemic = { INTENSITY = major }
				}
				# Get the Faction if that's part of it
				if = {
					limit = {
						root = { has_activity_intent = coronation_disrupt_loyalists }
					}
					random_targeting_faction = {
						limit = {
							any_faction_member = { this = root }
							#Won't join a bunch of heretics
							trigger_if = {
								limit = { faction_is_type = claimant_faction }
								special_character.faith ?= scope:host.faith
							}
							trigger_if = {
								limit = { faction_is_type = populist_faction }
								var:faction_faith ?= scope:host.faith
							}
						}
						save_scope_as = faction
					}
				}
			}

			# Grab yer zealot
			random_attending_character = {
				# Try and get someone who can join the faction if that's relevant
				limit = {
					exists = scope:faction
					can_join_faction = scope:faction
					ach_coronation_0022_valid_zealot_trigger = yes
				}
				alternative_limit = {
					ach_coronation_0022_valid_zealot_trigger = yes
				}
				alternative_limit = {
					ach_coronation_0022_loose_zealot_trigger = yes
				}
				weight = {
					base = 1
					# Prefer vassals
					modifier = {
						add = {
							value = 5
							if = {
								limit = { is_powerful_vassal_of = scope:host }
								add = 10
							}
						}
						is_vassal_of = scope:host
					}
					# Prefer interesting characters
					modifier = {
						add = 10
						is_of_major_interest_to_root_trigger = yes
					}
					modifier = {
						add = 5
						is_of_minor_interest_to_root_trigger = yes
					}
					# Who would also likely be afeared
					modifier = {
						add = 5
						has_trait = craven
					}
					# And not those who wouldn't be
					modifier = {
						add = -15
						has_trait = brave
					}
					# Clergy members are also nice
					modifier = {
						add = 5
						is_clergy = yes
					}
					# As are Zealot Vassal Stancers
					modifier = {
						add = 5
						is_vassal_of = scope:host
						has_vassal_stance = zealot
					}
					# Weightings for zealotry
					modifier = {
						add = {
							value = ai_zeal
							multiply = 0.2 # Don't want it to overwhelm other factors
						}
					}
					# Prefer rulers who already dislike the host
					opinion_modifier = {
						opinion_target = scope:host
						multiplier = -0.2 # Don't want it to overwhelm other factors
					}
				}
				save_scope_as = zealot
				assign_quirk_effect = yes
			}
		}
	}

	option = { # This is that bastard host's fault!
		name = ach_coronation.0022.a.coronation_disrupt_loyalists
		trigger = {
			has_activity_intent = coronation_disrupt_loyalists
			exists = scope:faction
			scope:zealot = {
				can_join_faction = scope:faction
				opinion = {
					target = scope:host
					value <= 60
				}
			}
		}
		custom_tooltip = available_because_intent_tt
		flavor = ach_coronation.0022.a.coronation_disrupt_loyalists.flavor
		reason = activity_intent
		skill = diplomacy

		add_piety = medium_piety_loss
		reverse_add_opinion = {
			target = scope:host
			modifier = opposition_opinion
			opinion = -20
		}

		duel = {
			skills = { diplomacy learning }
			target = scope:zealot
			50 = { # You convert them!
				desc = ach_coronation.0022.a.coronation_disrupt_loyalists.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				modifier = {
					has_perk = theologian_perk
					add = 25
				}
				modifier = {
					has_trait = zealous
					add = 25
				}
				modifier = {
					scope:zealot = {
						opinion = {
							target = scope:host
							value < -50
						}
					}
					add = 25
				}
				modifier = {
					scope:zealot = {
						opinion = {
							target = scope:host
							value < 0
						}
					}
					add = 15
				}
				send_interface_toast = {
					title = ach_coronation.0022.a.coronation_disrupt_loyalists.success
					left_icon = root
					right_icon = scope:zealot

					scope:zealot = { join_faction = scope:faction }
					coronation_move_towards_detractor_effect = { CHARACTER = scope:zealot }
				}
			}
			50 = { # You fail
				desc = ach_coronation.0022.a.coronation_disrupt_loyalists.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				modifier = {
					scope:zealot = {
						opinion = {
							target = scope:host
							value > 0
						}
					}
					add = 25
				}
				modifier = {
					scope:zealot = {
						opinion = {
							target = scope:host
							value > 30
						}
					}
					add = 25
				}
				send_interface_toast = {
					title = ach_coronation.0022.a.coronation_disrupt_loyalists.failure
					left_icon = root
					right_icon = scope:zealot

					reverse_add_opinion = {
						target = scope:zealot
						modifier = outraged_opinion
						opinion = -20
					}
				}
			}
		}

		ai_chance = {
			base = 150
			modifier = {
				has_trait = disloyal
				add = 50
			}
			modifier = {
				has_trait = schemer
				add = 50
			}
		}
	}
	option = { # It's not our goodly Host's fault!
		name = ach_coronation.0022.a.offer_support
		trigger = { has_activity_intent = coronation_offer_support }
		custom_tooltip = available_because_intent_tt
		flavor = ach_coronation.0022.a.offer_support.flavor

		add_piety = medium_piety_loss

		duel = {
			skills = { diplomacy learning }
			target = scope:zealot
			50 = { # They are more loyal than ever
				desc = ach_coronation.0022.a.offer_support.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				modifier = {
					has_perk = theologian_perk
					add = 25
				}
				modifier = {
					has_trait = zealous
					add = 25
				}
				send_interface_toast = {
					title = ach_coronation.0022.a.offer_support.success
					left_icon = root
					right_icon = scope:zealot

					random = {
						chance = 20
						scope:zealot = {
							add_trait = loyal
						}
					}

					reverse_add_opinion = {
						target = scope:zealot
						modifier = comforted_opinion
						opinion = 10
					}
					reverse_add_opinion = {
						target = scope:host
						modifier = helpful_opinion
						opinion = 20
					}
					scope:zealot = {
						add_opinion = {
							target = scope:host
							modifier = loyalty_opinion
							opinion = 30
						}
					}
					coronation_move_towards_supporter_effect = { CHARACTER = scope:zealot }
				}
			}
			50 = { # You fail
				desc = ach_coronation.0022.a.offer_support.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				send_interface_toast = {
					title = ach_coronation.0022.a.offer_support.failure
					left_icon = root
					right_icon = scope:zealot

					reverse_add_opinion = {
						target = scope:zealot
						modifier = annoyed_opinion
						opinion = -20
					}
					coronation_move_towards_detractor_effect = { CHARACTER = scope:zealot }
				}
			}
		}
		stress_impact = {
			fickle = minor_stress_impact_gain
		}
		ai_chance = {
			base = 150
			modifier = {
				has_trait = loyal
				add = 50
			}
		}
	}
	option = { # Pray with HerHim
		name = ach_coronation.0022.b
		trigger = {
			root.faith.religion ?= scope:zealot.faith.religion
		}
		show_as_unavailable = { always = yes }
		reason = faith
		trait = zealous

		custom_tooltip = available_because_of_shared_religion_tt

		add_piety = medium_piety_gain
		if = {
			limit = {
				scope:zealot = {
					opinion = {
						target = root
						value > 0
					}
				}
				OR = {
					scope:zealot = { is_ai = yes }
					AND = {
						scope:zealot = { is_ai = no }
						is_ai = no
					}
				}
			}
			progress_towards_friend_effect = {
				CHARACTER = scope:zealot
				OPINION = 20
				REASON = friend_religious_comfort
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:zealot
				modifier = kindness_opinion
				opinion = 20
			}
		}
		

		stress_impact = {
			cynical = medium_stress_impact_gain
			zealous = medium_stress_impact_loss
			compassionate = minor_stress_impact_loss
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				add = 100
			}
			modifier = {
				has_trait = compassionate
				add = 50
			}
			modifier = {
				has_trait = sadistic
				add = -25
			}
			modifier = {
				has_trait = callous
				add = -100
			}
			modifier = {
				OR = {
					has_trait = cynical
					has_trait = callous
					has_trait = sadistic
				}
				factor = 0
			}
		}
	}
	option = { # I'm not getting near anyone rn, thanks
		name = ach_coronation.0022.d
		flavor = ach_coronation.0022.d.flavor

		add_character_modifier = {
			modifier = ach_social_distancing_modifier
			years = 4
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = cynical
				add = 25
			}
			modifier = {
				has_trait = shy
				add = 25
			}
			modifier = {
				has_trait = paranoid
				add = 25
			}
			modifier = {
				has_trait = trusting
				add = -25
			}
			modifier = {
				has_trait = callous
				add = -25
			}
			modifier = {
				has_trait = gregarious
				add = -25
			}
		}
	}
}

######################
# Host: An exotic foreign warrior pledges themselves to you
# by Jay Zaborowski
# 0023
scripted_trigger ach_coronation_0023_foreign_holder_trigger = {
	NOR = {
		# Make sure they're from afar
		in_diplomatic_range = prev
		# And suitably foreign
		faith = prev.faith
		culture = prev.culture
	}
	save_temporary_scope_as = foreign_ruler_temp
	prev = {
		# They're not that exotic if you already rule a bunch of them
		any_realm_county = {
			NOR = {
				faith = scope:foreign_ruler_temp.faith
				culture = scope:foreign_ruler_temp.culture
			}
		}
	}
}

scripted_trigger ach_coronation_0023_eligible_clergy_trigger = {
	is_available_in_activity_trigger = yes
	faith = involved_activity.activity_host.faith
}

scripted_effect ach_coronation_0023_generic_acceptance_effect = {
	if = {
		limit = {
			faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
		}
		# Fundamentalists won't be happy about this
		every_vassal = {
			limit = {
				faith = root.faith
				has_vassal_stance = zealot
			}
			custom = every_zealot_vassal
			add_opinion = {
				target = root
				modifier = fp1_honoured_heathen_opinion
				opinion = -10
			}
		}
		add_piety = medium_piety_loss
		if = {
			limit = { has_trait = zealous }
			stress_impact = {
				zealous = medium_stress_impact_gain
			}
		}
	}
	culture = {
		change_cultural_acceptance = {
			target = scope:foreign_warrior.culture
			value = low_positive_culture_acceptance
			desc = cultural_acceptance_gain_accepted_foreign_warrior
		}
	}

	stress_impact = {
		trusting = medium_stress_loss # Trusts this strange foreigner implicitly
		paranoid = medium_stress_loss # Is very happy to have less incompetent guards
	}
}

ach_coronation.0023 = {
	type = activity_event
	title = ach_coronation.0023.t
	desc = {
		desc = ach_coronation.0023.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:clergy
					scope:clergy.faith = {
						NOT = { has_doctrine = doctrine_pluralism_pluralistic }
					}
				}
				desc = ach_coronation.0023.desc.clergy.angry
			}
			triggered_desc = {
				trigger = {
					exists = scope:clergy
				}
				desc = ach_coronation.0023.desc.clergy
			}
		}
	}

	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}

	center_portrait = {
		character = scope:foreign_warrior
		animation = obsequious_bow
		camera = camera_event_center_pointing_left
	}

	right_portrait = {
		trigger = { exists = scope:clergy }
		triggered_animation = {
			trigger = {
				scope:clergy.faith = {
					NOT = { has_doctrine = doctrine_pluralism_pluralistic }
				}
			}
			animation = disapproval
		}
		animation = interested
		character = scope:clergy
	}

	cooldown = { years = 1 }
	
	theme = coronation_activity

	override_background = {
		reference = throne_room
	}

	trigger = {
		has_activity_intent = coronation_embrace_supporters
		any_independent_ruler = { ach_coronation_0023_foreign_holder_trigger = yes }
		involved_activity = {
			any_attending_character = {
				ach_coronation_0023_eligible_clergy_trigger = yes
				is_vassal_or_below_of = root
				OR = {
					is_clergy = yes
					has_trait = devoted
					is_theocratic_lessee = yes
					government_has_flag = government_is_theocracy
				}
			}
		}
	}

	# Exotic warriors won't be attracted by lords who aren't some level of famous
	weight_multiplier = {
		base = 0
		# Court Grandeur attracts adventurers
		modifier = {
			has_royal_court = yes
			court_grandeur_current_level > 2
			add = {
				value = court_grandeur_current_level
				divide = 4
			}
		}
		modifier = {
			prestige_level > 2
			add = {
				value = prestige_level
				divide = 2
			}
		}
	}

	immediate = {
		# Get a foreign court for the warrior to arrive from
		random_independent_ruler = {
			# Make sure they're from afar
			limit = { ach_coronation_0023_foreign_holder_trigger = yes }
			weight = {
				base = 1
				# Like, really afar
				modifier = {
					add = 1000
					capital_province = {
						squared_distance = {
							target = root.capital_province
							value >= squared_distance_massive
						}
					}
				}
				# More militaristic cultures with cool warrior folks are preferred
				modifier = {
					add = 500
					culture = {
						OR = {
							has_cultural_pillar = ethos_stoic
							has_cultural_pillar = ethos_bellicose
							has_cultural_parameter = wanderers_gain_extra_combat_skills
							has_cultural_parameter = high_prowess_ignores_knight_restrictions
							has_cultural_parameter = prowess_from_martial_education
							has_cultural_parameter = martial_education_more_valued
							has_cultural_parameter = strong_traits_more_valued
						}
					}
				}
				# Cultures that don't tend to like foreigners are not
				modifier = {
					add = -500
					culture = {
						OR = {
							has_cultural_parameter = courtiers_less_likely_to_leave_same_culture_court
							has_cultural_parameter = dislikes_marrying_outside_of_culture
						}
					}
				}
			}
			save_scope_as = foreign_ruler
		}

		# Create your new BFF
		create_character = {
			template = bp1_yearly_2021_martial_person_template
			location = root.location
			faith = scope:foreign_ruler.faith
			culture = scope:foreign_ruler.culture
			trait = loyal
			save_scope_as = foreign_warrior
		}
		scope:foreign_warrior = {
			hidden_effect = {
				# Give them an opinion bump so they don't hate you
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 30
				}
				# And make sure they speak your language
				learn_language_of_culture = root.culture
				# Add them now so the can_appoint triggers work
				add_courtier = scope:foreign_warrior
			}
		}

		# Grab a clergy person to be angry (or curious)
		involved_activity = {
			random_attending_character = {
				limit = { # Grab the Court Chaplain if they're attending
					ach_coronation_0023_eligible_clergy_trigger = yes
					has_council_position = councillor_court_chaplain
					is_councillor_of = root
				}
				alternative_limit = { # Any Zealot vassal if not
					ach_coronation_0023_eligible_clergy_trigger = yes
					is_vassal_of = root
					has_vassal_stance = zealot
				}
				alternative_limit = { # Find any sort of clergy-type as a fallback
					ach_coronation_0023_eligible_clergy_trigger = yes
					is_vassal_or_below_of = root
					OR = {
						is_clergy = yes
						has_trait = devoted
						is_theocratic_lessee = yes
						government_has_flag = government_is_theocracy
					}
				}
				save_scope_as = clergy
			}
		}

		ordered_court_position_holder = {
			type = bodyguard_court_position
			order_by = { # Get the worst bodyguard you have
				value = 0
				subtract = "aptitude(bodyguard_court_position)"
			}
			save_scope_as = worst_bodyguard
		}
	}

	option = { # Make them your bodyguard
		name = ach_coronation.0023.a

		trigger = {
			can_employ_court_position_type = bodyguard_court_position
			any_court_position_holder = {
				type = bodyguard_court_position
				has_court_position = bodyguard_court_position
				count < 2
			}
		}

		court_position_grant_effect = { POS = bodyguard CANDIDATE = scope:foreign_warrior EMPLOYER = root }

		scope:foreign_warrior = {
			add_opinion = {
				modifier = hired_me_opinion
				target = root
				opinion = 30
			}
			hidden_effect = {
				add_prestige = medium_prestige_gain
			}
		}

		ach_coronation_0023_generic_acceptance_effect = yes

		ai_chance = {
			base = 100
			opinion_modifier = {
				trigger = { exists = scope:worst_bodyguard }
				who = scope:worst_bodyguard
				opinion_target = root
				multiplier = -1
			}
			# Faith modifiers
			modifier = { 
				faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
				NOT = { has_trait = cynical }
				add = -50
			}
			modifier = { 
				faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
				has_trait = zealous
				factor = 0
			}
			# If you have a Champion slot then make them that instead of replacing
			modifier = {
				employs_court_position = bodyguard_court_position
				NOT = { employs_court_position = champion_court_position }
				factor = 0
			}
		}
	}

	option = { # Make them your Champion
		name = ach_coronation.0023.b

		trigger = {
			can_employ_court_position_type = champion_court_position
			NOT = { employs_court_position = champion_court_position }
		}

		if = {
			limit = {
				can_employ_court_position_type = champion_court_position
				NOT = { employs_court_position = champion_court_position }
			}
			court_position_grant_effect = { POS = champion CANDIDATE = scope:foreign_warrior EMPLOYER = root }
		}

		scope:foreign_warrior = { # Grant the position
			add_opinion = {
				modifier = hired_me_opinion
				target = root
				opinion = 30
			}
			hidden_effect = {
				add_prestige = medium_prestige_gain
			}
		}

		ach_coronation_0023_generic_acceptance_effect = yes

		ai_chance = {
			base = 100
			opinion_modifier = {
				trigger = {
					employs_court_position = champion_court_position
				}
				who = court_position:champion_court_position
				opinion_target = root
				multiplier = -1
			}
			# Faith modifiers
			modifier = { 
				faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
				NOT = { has_trait = cynical }
				add = -50
			}
			modifier = { 
				faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
				has_trait = zealous
				factor = 0
			}
		}
	}

	option = { # Courtier fallback
		name = ach_coronation.0023.c

		trigger = {
			NOR = {
				can_employ_court_position_type = bodyguard_court_position
				can_employ_court_position_type = champion_court_position
			}
		}

		ach_coronation_0023_generic_acceptance_effect = yes

		add_courtier = scope:foreign_warrior

		ai_chance = {
			base = 100
			# Faith modifiers
			modifier = { 
				faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
				NOT = { has_trait = cynical }
				add = -50
			}
			modifier = { 
				faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
				has_trait = zealous
				factor = 0
			}
		}
	}

	option = { # Reject them
		name = ach_coronation.0023.d

		if = {
			limit = {
				faith = { NOT = { has_doctrine = doctrine_pluralism_pluralistic } }
			}
			every_vassal = {
				limit = {
					faith = root.faith
					has_vassal_stance = zealot
				}
				custom = every_zealot_vassal
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 10
				}
			}
			if = {
				limit = {
					exists = scope:clergy
				}
				reverse_add_opinion = {
					target = scope:clergy
					modifier = grateful_opinion
					opinion = 20
				}
			}
		}

		hidden_effect = {
			scope:foreign_warrior = { silent_disappearance_effect = yes }
		}

		ai_chance = {
			base = 100
		}
	}
}

######################
# Open up drinks to the locals 
# by Jay Zaborowski
# 0025
ach_coronation.0025 = {
	type = activity_event
	title = ach_coronation.0025.t
	desc = {
		desc = ach_coronation.0025.desc
		first_valid = {
			triggered_desc = {
				trigger = { root = scope:host }
				desc = ach_coronation.0025.desc.host
			}
			desc = ach_coronation.0025.desc.guest
		}
	}

	left_portrait = {
		character = root
		animation = thinking
	}

	center_portrait = {
		trigger = {
			root != scope:host
		}
		character = scope:host
		animation = scepter
	}

	right_portrait = {
		trigger = {
			scope:baron != scope:host
			root != scope:baron
		}
		character = scope:baron
		animation = thinking
	}

	theme = feast_activity

	cooldown = { years = 1 }

	override_background = {
		reference = garden
	}

	trigger = {
		OR = {
			has_activity_intent = coronation_offer_support
			has_activity_intent = coronation_impress_attendees
		}
		involved_activity = {
			activity_location = {
				# Has a settlement
				has_holding = yes
				# Has locals
				NOR = {
					has_holding_type = nomad_holding
					has_holding_type = herder_holding
				}
				# The barony has willing drinkers
				barony.holder = {
					faith_forbids_alcohol_trigger = no
					faith = prev.county.faith
					trigger_if = {
						limit = { is_ai = no }
						this = root
					}
				}
			}
			# And a willing host
			activity_host = { faith_forbids_alcohol_trigger = no }
		}
		# And a willing you
		faith_forbids_alcohol_trigger = no
	}

	immediate = {
		involved_activity = {
			activity_host = { save_scope_as = host }
			activity_location = {
				save_scope_as = feast_location
				barony.holder = { save_scope_as = baron }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				has_trait = drunkard
				has_trait = lifestyle_reveler
			}
			add = 2
		}
		modifier = {
			involved_activity.activity_host = {
				OR = {
					has_trait = drunkard
					has_trait = lifestyle_reveler
				}
			}
			add = 2
		}
	}

	option = { # You'll pay for it
		name = ach_coronation.0025.a
		trigger = {
			short_term_gold >= medium_gold_value
		}
		show_as_unavailable = { always = yes }

		remove_short_term_gold = medium_gold_value

		involved_activity.activity_location = {
			add_province_modifier = { modifier = ach_drunk_province_1_modifier years = 1 }
		}

		if = {
			limit = {
				this != scope:host
			}
			reverse_add_opinion = {
				target = scope:host
				modifier = grateful_opinion
				opinion = 20
			}
		}

		scope:host = {
			every_vassal = {
				limit = {
					has_vassal_stance = courtly
					NOT = {
						this = root
					}
				}
				custom = every_courtly_vassal
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 5
				}
			}
		}

		custom_tooltip = coronation_tt_positive_medium
		involved_activity = { activity_special_type_progression_medium = yes }
		coronation_add_magnificence_log_effect = {
            VALUE = flag:positive_medium
            CHAR = root
        }

		stress_impact = {
			base = medium_stress_impact_loss
			temperate = medium_stress_impact_gain # Doesn't partake
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = temperate
				factor = 0.5
			}
		}
	}

	option = { # Drunkard / Reveler: We should *both* pay for it!
		name = ach_coronation.0025.b
		flavor = ach_coronation.0025.b.flavor
		trigger = {
			custom_tooltip = {
				text = ach_coronation.0025.b.tt
				short_term_gold >= minor_gold_value
				OR = {
					has_trait = drunkard
					has_trait = lifestyle_reveler
				}
				scope:baron != root # Only available if there's a local baron to go splitsies
				scope:baron != scope:host # And if they're not the Host
			}
		}
		show_as_unavailable = {
			scope:baron != root
			scope:baron != scope:host
		}
		trait = drunkard
		trait = lifestyle_reveler

		duel = {
			skill = diplomacy
			target = scope:baron
			40 = { # The Baron agrees to pay
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = ach_coronation.0025.b.tt.success

				involved_activity.activity_location = {
					add_province_modifier = { modifier = ach_drunk_province_2_modifier years = 1 }
				}

				scope:baron = {
					remove_short_term_gold = root.minor_gold_value
					hidden_effect = { add_prestige = medium_prestige_gain }
				}
				remove_short_term_gold = minor_gold_value

				if = {
					limit = { this != scope:host }
					scope:host = {
						add_opinion = {
							target = root
							modifier = grateful_opinion
							opinion = 10
						}
						add_opinion = {
							target = scope:baron
							modifier = grateful_opinion
							opinion = 10
						}
						hidden_effect = {
							add_prestige = medium_prestige_gain
						}
					}
				}

				send_interface_toast = {
					title = ach_coronation.0025.b.tt.success
					left_icon = scope:baron

					if = {
						limit = {
							has_trait = lifestyle_reveler
						}
						add_trait_xp = {
							trait = lifestyle_reveler
							value = {
								integer_range = {
									min = small_lifestyle_random_xp_low
									max = small_lifestyle_random_xp_high
								}
							}
						}
					}

					add_prestige = medium_prestige_gain
					if = {
						limit = {
							OR = {
								root = { is_ai = no }
							}
							scope:activity = {
								is_target_in_variable_list = {
									name = major_supporter
									target = root
								}
							}
						}
						scope:host = {
							custom_tooltip = coronation_tt_positive_medium
							involved_activity = { activity_special_type_progression_medium = yes }
						}
						coronation_add_magnificence_log_effect = {
        				    VALUE = flag:positive_medium
        				    CHAR = root
        				}
					}

					stress_impact = {
						base = medium_stress_impact_loss
						temperate = medium_stress_impact_gain # Doesn't partake
					}
				}

				create_character_memory = {
					type = got_the_city_drunk_memory
					participants = {
						coronation_host = scope:host
						baron = scope:baron
					}
				}
				# Used in loc
				scope:new_memory = {
					save_scope_as = drunk_city_memory
				}
				scope:drunk_city_memory = {
					#set_variable = {
						#name = drunk_city_location
						#value = scope:feast_location
					#}
					set_variable = {
						name = drunk_city_location
						value = scope:feast_location
					}
					if = { #startup error suppression
						limit = { has_variable = drunk_city_location }
					}
				}
			}
			60 = { # The Baron refuses your *extremely* awesome idea
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ach_coronation.0025.b.tt.failure
				send_interface_toast = {	
					title = ach_coronation.0025.b.tt.failure
					left_icon = scope:baron

					scope:baron = { # Very lame of them
						add_prestige = minor_prestige_loss
					}
					hidden_effect = {
						add_opinion = {
							target = scope:baron
							modifier = disappointed_opinion
							opinion = -10
						}
					}

					stress_impact = { # Disappointment
						drunkard = minor_stress_impact_gain
						lifestyle_reveler = minor_stress_impact_gain
					}
				}
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = drunkard
				add = 50
			}
			modifier = {
				has_trait = lifestyle_reveler
				add = 50
			}
		}
	}

	option = { # Just focus on having fun
		name = ach_coronation.0025.c
		name = {
			trigger = {
				has_trait = temperate
			}
			text = ach_coronation.0025.c.temperate
		}
		flavor = ach_coronation.0025.c.flavor

		# Stress loss
		stress_impact = {
			base = minor_stress_impact_loss
			drunkard = minor_stress_impact_gain
			lifestyle_reveler = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = temperate
				factor = 2
			}
		}
	}
}

######################
# Host: Struggle to hide a cold so that your tribal vassals don't take it as an omen
# by Jay Zaborowski
# 0026
ach_coronation.0026 = {
	type = activity_event
	title = ach_coronation.0026.t
	desc = ach_coronation.0026.desc

	left_portrait = {
		character = scope:second
		animation = dancing
		camera = camera_event_very_left_fov35
	}

	center_portrait = { 
		character = root
		animation = stress
		camera = camera_event_center_very_large
	}

	right_portrait = {
		character = scope:vassal
		animation = toast_goblet
		camera = camera_event_very_right_fov35
	}

	theme = feast_activity

	cooldown = { years = 1 }

	trigger = {
		can_contract_disease_trigger = { DISEASE = ill }
		government_has_flag = government_is_tribal
		involved_activity = {
			any_attending_character = {
				government_has_flag = government_is_tribal
				coronation_hostile_to_host_trigger = no
				can_add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
	}

	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					government_has_flag = government_is_tribal
					coronation_hostile_to_host_trigger = no
					can_add_hook = {
						target = root
						type = favor_hook
					}
				}
				weight = {
					base = 1
					# Prefer vassals
					modifier = {
						add = {
							value = 5
							if = {
								limit = { is_powerful_vassal_of = root }
								add = 10
							}
						}
						is_vassal_of = root
					}
					# Prefer interesting characters
					modifier = {
						add = 10
						is_of_major_interest_to_root_trigger = yes
					}
					modifier = {
						add = 5
						is_of_minor_interest_to_root_trigger = yes
					}
					# Try and get someone who'd be willing to help you out
					opinion_modifier = {
						opinion_target = root
						multiplier = 0.25
					}
				}
				save_scope_as = vassal
			}
			random_attending_character = {
				limit = {
					NOR = {
						this = root
						this = scope:vassal
					}
				}
				save_scope_as = second
			}
		}
	}

	option = { # Hold it in hold it in hold it in
		name = ach_coronation.0026.a

		custom_tooltip = ach_coronation.0026.a.tt

		random_list = {
			40 = { # Your vassals notice you're sick
				desc = ach_coronation.0026.a.tt.sick.failure
				send_interface_toast = {
					title = ach_coronation.0026.a.tt.sick.failure
					left_icon = root

					add_prestige = minor_prestige_loss

					contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }

					custom_tooltip = coronation_tt_negative
					involved_activity = { activity_special_type_progression_negative = yes }
					coronation_add_magnificence_log_effect = {
						VALUE = flag:negative
						CHAR = root
					}
				}
			}
			40 = { # Nobody notices
				desc = ach_coronation.0026.a.tt.sick.success
				send_interface_toast = {
					title = ach_coronation.0026.a.tt.sick.success
					left_icon = root

					reverse_add_opinion = {
						target = scope:vassal
						modifier = feast_had_good_time_together_opinion
						opinion = 15
					}

					contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
				}
			}
			20 = { # The feeling's pass
				desc = ach_coronation.0026.a.tt.critical_success
				send_interface_toast = {
					title = ach_coronation.0026.a.tt.critical_success

					reverse_add_opinion = {
						target = scope:vassal
						modifier = feast_had_good_time_together_opinion
						opinion = 15
					}

					stress_impact = {
						base = minor_stress_loss
					}
				}
			}
		}
	}

	option = { # Vassal, help me!
		name = ach_coronation.0026.b

		custom_tooltip = ach_coronation.0026.b.tt

		random = {
			chance = 50
			contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
		}

		hidden_effect = {
			add_opinion = {
				target = scope:vassal
				modifier = grateful_opinion
				opinion = 15
			}
		}
		scope:vassal = {
			add_hook = {
				target = root
				type = favor_hook
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 0.5
			}
			modifier = {
				has_trait = shy
				factor = 0.5
			}
		}
	}

	option = { # Bail on the feast
		name = ach_coronation.0026.c

		flavor = ach_coronation.0026.c.flavor

		random = {
			chance = 25
			contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
		}

		every_vassal = {
			limit = {
				OR = {
					government_has_flag = government_is_tribal
					government_has_flag = government_is_nomadic
				}
			}
			custom = custom.every_tribal_nomadic_vassal
			add_opinion = {
				target = root
				modifier = opinion_acting_strange
				opinion = -10
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 0.5
			}
			modifier = {
				has_trait = stubborn
				factor = 0.5
			}
		}
	}
}

######################
# An attendee brings some hashish
# by Jay Zaborowski
# 0027
scripted_trigger can_be_hashishiyah_ignoring_region_trigger = {
	# You meet all the Hashishiyah triggers besides geographic_region
	is_adult = yes
	NOR = {
		has_trait = drunkard
		has_trait = hashishiyah
		has_trait = temperate
	}
	NAND = {
		faith = { trait_is_sin = hashishiyah }
		has_trait = zealous
	}
}

scripted_trigger eligible_to_join_stoner_trigger = {
	is_available_in_activity_trigger = yes
	OR = {
		has_trait = hashishiyah
		can_be_hashishiyah_ignoring_region_trigger = yes
	}
}

ach_coronation.0027 = {
	type = activity_event
	title = ach_coronation.0027.t
	desc = {
		desc = ach_coronation.0027.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:stoner = {
						OR = {
							has_trait = faith_warrior
							has_trait = crusader_king
						}
					}
				}
				desc = ach_coronation.0027.desc.char.crusader
			}
			triggered_desc = {
				trigger = {
					scope:stoner = {
						has_trait = varangian
						exists = title:e_byzantium.holder
					}
				}
				desc = ach_coronation.0027.desc.char.varangian
			}
			desc = ach_coronation.0027.desc.char.other
		}
	}

	left_portrait = { 
		character = root
		animation = interested
	}

	center_portrait = { 
		character = scope:partaker
		animation = interested_left
	}

	right_portrait = { 
		character = scope:stoner
		animation = wedding_drunk
	}

	cooldown = { years = 1 }
	
	theme = feast_activity

	trigger = {
		OR = { # If you can't normally be a Hashishiyah, look for some exceptions
			can_be_hashishiyah = yes
			AND = { # If a European Christian, the crusades are going on
				location = { geographical_region = world_europe }
				religion = {
					this = religion:christianity_religion
					exists = var:variable_ghw_unlocked
				}
			}
			AND = { # If in Scandinavia, you have access to Varangians and they still exist
				location = { geographical_region = world_europe_north }
				title:e_byzantium ?= { has_variable = founded_varangian_guard }
				OR = {
					culture = { has_cultural_pillar = heritage_north_germanic }
					dynasty ?= { has_dynasty_perk = fp1_adventure_legacy_1 }
				}
			}
		}
		involved_activity = {
			any_attending_character = {
				eligible_to_join_stoner_trigger = yes
				this != root
				count > 1 # In case the Stoner also meets the trigger
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			OR = {
				can_be_hashishiyah_ignoring_region_trigger = yes
				has_trait = hashishiyah
			}
		}
		modifier = {
			factor = 2
			involved_activity = {
				any_attending_character = {
					has_trait = hashishiyah
				}
			}
		}
		modifier = {
			factor = 3
			faith = {
				has_variable = variable_ghw_cooldown # There was a recent crusade
				religion = { this = religion:christianity_religion }
			}
		}
	}

	immediate = {
		play_music_cue = "middleeasterncourt_cue"
		involved_activity = {
			random_attending_character = {
				limit = {
					this != root
					this != prev.activity_host
					is_ai = yes
					is_available_in_activity_trigger = yes
					has_trait = hashishiyah
				}
				alternative_limit = {
					this != root
					this != prev.activity_host
					is_ai = yes
					is_available_in_activity_trigger = yes
					can_be_hashishiyah_ignoring_region_trigger = yes
					OR = {
						can_be_hashishiyah = yes
						can_be_hashishiyah_ignoring_region_trigger = yes
					}
					OR = {
						has_trait = faith_warrior
						has_trait = crusader_king
						has_trait = varangian
					}
				}
				save_scope_as = stoner
			}

			root = {
				if = { # If the stoner does not exist, generate a...
					limit = { NOT = { exists = scope:stoner } }
					if = { # Varangian (if you're Scandinavian)
						limit = {
							location = { geographical_region = world_europe_north }
							title:e_byzantium ?= { has_variable = founded_varangian_guard }
							OR = {
								culture = { has_cultural_pillar = heritage_north_germanic } 
								dynasty = { has_dynasty_perk = fp1_adventure_legacy_1 }
							}
						}
						create_character = {
							save_scope_as = stoner
							culture = root.culture
							faith = root.faith
							location = root.location
							template = varangian_template
							trait = hashishiyah
						}
						title:e_byzantium.holder.culture = { save_scope_as = emperor_culture }
					}
					else_if = { # Crusader (if you're Christian)
						limit = {
							location = { geographical_region = world_europe }
							faith = { has_variable = variable_ghw_cooldown }
							OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion }
						}
						create_character = {
							save_scope_as = stoner
							culture = root.culture
							faith = root.faith
							location = root.location
							template = knight
							trait = hashishiyah
							trait = faith_warrior
						}
					}
					else = { # Some Reveler type of person
						create_character = {
							save_scope_as = stoner
							culture = root.culture
							faith = root.faith
							location = root.location
							template = diplomacy_court_position_holder_template
							trait = hashishiyah
							trait = lifestyle_traveler
						}
					}
					scope:stoner = {
						add_to_activity = root.involved_activity
					}
					add_character_flag = created_character_ach_coronation_0027
				}
			}

			random_attending_character = {
				limit = {
					eligible_to_join_stoner_trigger = yes
					has_trait = hashishiyah
					this != scope:stoner
					this != root
				}
				alternative_limit = {
					eligible_to_join_stoner_trigger = yes
					this != scope:stoner
					this != root
				}
				save_scope_as = partaker
			}
		}
	}

	option = { # If Hashish is not available, purchase a supply
		name = ach_coronation.0027.a
		trigger = {
			NOT = { has_trait = hashishiyah } # You aren't already a Hashishiyah
			can_be_hashishiyah = no # You can't be a Hashishiyah
			can_be_hashishiyah_ignoring_region_trigger = yes # But only because of your region
		}

		reverse_add_opinion = {
			target = scope:stoner
			modifier = purchased_hashish_opinion
			opinion = 20
		}

		pay_short_term_gold = {
			target = scope:stoner
			gold = medium_gold_value
		}

		add_character_modifier = {
			modifier = ach_secret_stash_modifier
			years = 4
		}

		random = {
			chance = 20
			add_trait = hashishiyah
		}

		if = {
			limit = {
				faith = { trait_is_sin = hashishiyah }
			}
			add_piety = major_piety_loss
			stress_impact = {
				zealous = major_stress_impact_gain
				cynical = minor_stress_impact_loss
			}
		}
		else_if = {
			limit = {
				faith = { trait_is_virtue = hashishiyah }
			}
			add_piety = minor_piety_gain
			stress_impact = {
				cynical = medium_stress_impact_gain
				zealous = minor_stress_impact_loss
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			avaricious = minor_stress_impact_gain
			temperate = medium_stress_impact_gain
		}
		
		ai_chance = {
			modifier = {
				OR = {
					has_trait = lifestyle_reveler
					has_trait = gluttonous
					has_trait = gregarious
				}
				factor = 2
			}
			base = 100
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = avaricious
				}
				factor = 0.5
			}
			modifier = {
				has_trait = temperate
				factor = 0
			}
		}
	}

	option = { # Join in
		name = ach_coronation.0027.b
		name = {
			trigger = { has_trait = hashishiyah }
			text = ach_coronation.0027.b.hashishiyah
		}
		trait = hashishiyah

		reverse_add_opinion = {
			target = scope:stoner
			modifier = camp_party_reveled_opinion
			opinion = 10
		}
		reverse_add_opinion = {
			target = scope:partaker
			modifier = camp_party_reveled_opinion
			opinion = 10
		}

		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 5
			}
		}

		if = { # You already love hashish - let's be smoke buddies!
			limit = { has_trait = hashishiyah }
			if = {
				limit = {
					reverse_opinion = {
						target = scope:stoner
						value > 0
					}
					OR = {
						scope:stoner = { is_ai = yes }
						AND = {
							scope:stoner = { is_ai = no }
							is_ai = no
						}
					}
				}
				set_relation_friend = {
					target = scope:stoner
					reason = friend_got_high_together
				}
			}
			else = {
				reverse_add_opinion = {
					target = scope:stoner
					modifier = pleased_opinion
					opinion = 30
				}
			}
		}
		else_if = { # Else, if Hashish is available, chance to become a Hashiyah
			limit = {
				can_be_hashishiyah = yes # You can be a Hahishiyah
			}
			random = {
				chance = 20
				add_trait = hashishiyah
			}
		}

		add_character_modifier = {
			modifier = stress_hashish_stupor
			years = 1
		}

		if = {
			limit = {
				faith = { trait_is_sin = hashishiyah }
			}
			add_piety = minor_piety_loss
			stress_impact = {
				zealous = medium_stress_impact_gain
				cynical = minor_stress_impact_loss
			}
		}
		else_if = {
			limit = {
				faith = { trait_is_virtue = hashishiyah }
			}
			add_piety = minor_piety_gain
			stress_impact = {
				cynical = medium_stress_impact_gain
				zealous = minor_stress_impact_loss
			}
		}

		stress_impact = {
			base = medium_stress_impact_loss
			temperate = medium_stress_impact_gain
			shy = minor_stress_impact_gain
			hashishiyah = minor_stress_impact_loss # Bonus stress loss if you're already a fan
		}
		
		ai_chance = {
			base = 100
			modifier = {
				NOT = { has_trait = cynical }
				faith = { trait_is_virtue = hashishiyah }
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = lifestyle_reveler
					has_trait = gluttonous
					has_trait = gregarious
				}
				factor = 2
			}
			modifier = {
				has_trait = shy
				factor = 0.5
			}
		}
	}

	option = { # Host: Get this person out of here - drugs are bad!!!
		name = ach_coronation.0027.c

		trigger = {
			this = involved_activity.activity_host
		}

		add_prestige = medium_prestige_gain

		reverse_add_opinion = {
			target = scope:stoner
			modifier = angry_opinion
			opinion = -25
		}
		reverse_add_opinion = {
			target = scope:partaker
			modifier = disappointed_opinion
			opinion = -10
		}

		scope:stoner = { remove_from_activity = involved_activity }

		if = {
			limit = {
				faith = { trait_is_sin = hashishiyah }
			}
			add_piety = medium_piety_gain
			stress_impact = {
				cynical = minor_stress_impact_gain
				zealous = medium_stress_impact_loss
			}
		}
		else_if = {
			limit = {
				faith = { trait_is_virtue = hashishiyah }
			}
			add_piety = medium_piety_loss
			stress_impact = {
				zealous = minor_stress_impact_gain
				cynical = medium_stress_impact_loss
			}
		}

		stress_impact = {
			gregarious = minor_stress_impact_gain
			lifestyle_reveler = minor_stress_impact_gain
			hashishiyah = major_stress_impact_gain
		}
		
		ai_chance = {
			base = 50
			modifier = {
				has_trait = zealous
				faith = { trait_is_sin = hashishiyah }
				factor = 4
			}
			modifier = {
				has_trait = cynical
				faith = { trait_is_virtue = hashishiyah }
				factor = 4
			}
		}
	}

	option = { # I'm good
		name = ach_coronation.0027.d
		flavor = {
			triggered_desc = {
				trigger = { this = involved_activity.activity_host }
				desc = ach_coronation.0027.d.host
			}
		}

		if = {
			limit = { this = involved_activity.activity_host }
			custom_tooltip = coronation_tt_positive_tiny
			involved_activity = { activity_special_type_progression_miniscule = yes }
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_miniscule
        	    CHAR = root
        	}
		}
		else = {
			add_prestige = minor_prestige_gain
		}

		if = {
			limit = {
				faith = { trait_is_sin = hashishiyah }
			}
			add_piety = minor_piety_gain
		}
		else_if = {
			limit = {
				faith = { trait_is_virtue = hashishiyah }
			}
			add_piety = minor_piety_loss
		}

		stress_impact = {
			lifestyle_reveler = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
			temperate = minor_stress_impact_loss
			hashishiyah = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 100
			modifier = {
				has_trait = temperate
				NOT = { has_trait = hashishiyah }
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = lifestyle_reveler
					has_trait = gluttonous
				}
				factor = 0.5
			}
			modifier = {
				has_trait = hashishiyah
				factor = 0.25
			}
		}
	}

	after = {
		if = {
			limit = {
				has_character_flag = created_character_ach_coronation_0027
				scope:stoner = { NOT = { has_relation_friend = root } }
			}
			hidden_effect = {
				scope:stoner = { silent_disappearance_effect = yes }
			}
		}
	}
}


######################
# Host: Drinking contest with a detractor
# by Jay Zaborowski
# 0028
scripted_effect ach_coronation_0028_success_effect = {
	add_prestige = minor_prestige_gain

	custom_tooltip = coronation_tt_positive_medium
	involved_activity = { activity_special_type_progression_medium = yes }
	coronation_add_magnificence_log_effect = {
        VALUE = flag:positive_medium
        CHAR = root
    }

	if = {
		limit = { has_activity_intent = coronation_impress_attendees }
		every_vassal = {
			limit = {
				OR = {
					government_has_flag = government_is_tribal
					government_has_flag = government_is_nomadic
				}
			}

			custom = custom.every_tribal_nomadic_vassal

			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 10
			}
		}
	}
	else_if = {
		limit = { has_activity_intent = coronation_weaken_detractors }
		every_vassal = {
			limit = {
				OR = {
					government_has_flag = government_is_tribal
					government_has_flag = government_is_nomadic
				}
			}

			custom = custom.every_tribal_nomadic_vassal

			add_opinion = {
				target = scope:drinker
				modifier = failure_opinion
				opinion = -15
			}
		}
	}

	create_character_memory = {
		type = defeated_detractor_in_drinking_contest_memory
		participants = {
			detractor = scope:drinker
		}
	}
}

ach_coronation.0028 = {
	type = activity_event
	title = ach_coronation.0028.t
	desc = ach_coronation.0028.desc

	left_portrait = { 
		character = root
		animation = disapproval
		camera = camera_event_left_pointing_back_fov20
	}

	center_portrait = { 
		character = scope:drinker
		animation = rage
		camera = camera_event_center_pointing_forward_fov35
	}

	right_portrait = { 
		character = scope:onlooker
		animation = interested
		camera = camera_event_very_right_forward_fov30
	}
	
	theme = feast_activity

	cooldown = { years = 1 }

	trigger = {
		OR = {
			has_activity_intent = coronation_impress_attendees
			has_activity_intent = coronation_weaken_detractors
		}
		government_has_flag = government_is_tribal
		faith_forbids_alcohol_trigger = no
		involved_activity = {
			any_guest_subset = {
				name = detractor
				is_available_in_activity_trigger = yes
				faith_forbids_alcohol_trigger = no
			}
		}
	}

	immediate = {
		# Grab the highest prowess Detractor
		involved_activity = {
			random_guest_subset = {
				name = detractor
				limit = {
					is_available_in_activity_trigger = yes
					faith_forbids_alcohol_trigger = no
				}
				weight = {
					base = 1
					is_of_major_interest_to_weight_up_modifier = { CHARACTER = root }
					is_of_minor_interest_to_weight_up_modifier = { CHARACTER = root }

					modifier = {
						add = {
							value = prowess
							multiply = 5
						}
					}
					modifier = {
						has_trait = temperate
						factor = 0.5
					}
					modifier = {
						has_trait = drunkard
						factor = 1.5
					}
				}
				save_scope_as = drinker
			}
			random_attending_character = {
				limit = {
					this != root
					this != scope:drinker
					is_available_in_activity_trigger = yes
					faith_forbids_alcohol_trigger = no
				}
				save_scope_as = onlooker
			}
		}
	}

	option = { # I'll outdrink them all!
		name = ach_coronation.0028.a
		skill = prowess

		duel = {
			skills = { prowess }
			target = scope:drinker
			50 = { # Drink them under the table
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				modifier = {
					add = 10
					has_trait = drunkard
				}
				modifier = {
					factor = 1.5
					health > scope:drinker.health
				}
				modifier = { # Chonky people can take their alcohol better
					factor = 1.5
					current_weight > scope:drinker.current_weight
				}

				desc = ach_coronation.0028.a.win

				scope:drinker = {
					if = {
						limit = { has_activity_intent = coronation_weaken_detractors }
						add_prestige = major_prestige_loss
					}
					else = {
						add_prestige = medium_prestige_loss
					}
				}

				send_interface_toast = {
					title = ach_coronation.0028.a.win
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:drinker

					ach_coronation_0028_success_effect = yes
				}
			}
			50 = { # You fail
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				modifier = {
					add = 10
					scope:drinker = { has_trait = drunkard }
				}
				modifier = {
					factor = 1.5
					health < scope:drinker.health
				}
				modifier = {
					factor = 1.5
					current_weight < scope:drinker.current_weight
				}

				desc = ach_coronation.0028.a.lose

				scope:drinker = { add_prestige = minor_prestige_gain }

				send_interface_toast = {
					title = ach_coronation.0028.a.lose
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:drinker

					add_prestige = medium_prestige_loss

					every_vassal = {
						limit = {
							OR = {
								government_has_flag = government_is_tribal
								government_has_flag = government_is_nomadic
							}
						}
						custom = custom.every_tribal_nomadic_vassal
						add_opinion = {
							target = root
							modifier = unimpressed_opinion
							opinion = -10
						}
					}
				}
			}
		}

		random = {
			chance = 5
			add_trait = drunkard
		}
		
		stress_impact = {
			drunkard = medium_stress_impact_loss
			lifestyle_reveler = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
			temperate = minor_stress_impact_gain
		}

		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_sociability = 1
			}
			modifier = {
				factor = 1.5
				OR = {
					has_trait = gregarious
					has_trait = drunkard
					has_trait = gluttonous
				}
			}
			modifier = {
				factor = 0.5
				has_trait = temperate
			}
		}
	}

	option = { # Maybe if I slipped something into HerHis drink...
		name = ach_coronation.0028.b
		skill = intrigue

		duel = {
			skill = intrigue
			value = 12
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = ach_coronation.0028.b.win

				scope:drinker = {
					if = {
						limit = { has_activity_intent = coronation_weaken_detractors }
						add_prestige = major_prestige_loss
					}
					else = {
						add_prestige = medium_prestige_loss
					}
				}

				send_interface_toast = {
					title = ach_coronation.0028.b.win
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:drinker

					ach_coronation_0028_success_effect = yes
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				scope:drinker = {
					add_opinion = {
						target = root
						modifier = tried_to_poison_me_opinion
						opinion = -40
					}
					if = {
						limit = {
							OR = {
								is_ai = yes
								AND = {
									root = {
										is_ai = no
									}
									is_ai = no
								}
							}
						}
						progress_towards_rival_effect = {
							REASON = rival_tried_to_poison
							CHARACTER = root
							OPINION = 0
						}
					}
				}
				coronation_move_towards_detractor_effect = { CHARACTER = scope:drinker }

				desc = ach_coronation.0028.b.lose

				send_interface_toast = {
					title = ach_coronation.0028.b.lose
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:drinker

					custom_tooltip = coronation_tt_negative
					involved_activity = { activity_special_type_progression_negative = yes }
					coronation_add_magnificence_log_effect = {
						VALUE = flag:negative
						CHAR = root
					}

					every_vassal = {
						limit = {
							OR = {
								government_has_flag = government_is_tribal
								government_has_flag = government_is_nomadic
							}
						}
						custom = custom.every_tribal_nomadic_vassal
						add_opinion = {
							target = root
							modifier = dishonorable_liege_opinion
							opinion = -20
						}
					}
				}
				create_character_memory = {
					type = was_caught_cheating_in_drinking_contest_memory
					participants = {
						detractor = scope:drinker
					}
				}
			}
		}

		scope:drinker = {
			if = {
				limit = {
					can_contract_disease_trigger = { DISEASE = ill }
				}
				random = {
					chance = {
						value = 50
						add = {
							value = prowess
							multiply = -1
						}
					}
					contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
				}
			}
		}
		
		stress_impact = {
			honest = massive_stress_impact_gain
			just = medium_stress_impact_gain
			temperate = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -1
			}

			opinion_modifier = { opinion_target = scope:drinker }

			modifier = {
				factor = 0
				OR = {
					intrigue <= 8
					ai_honor >= low_positive_ai_value
				}
			}
		}
	}

	option = { # I'll be fine
		name = ach_coronation.0028.c

		scope:drinker = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}

		add_legitimacy = minor_legitimacy_loss

		stress_impact = {
			temperate = minor_stress_impact_loss
			drunkard = medium_stress_impact_gain
			lifestyle_reveler = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_sociability = -1
			}
			modifier = {
				factor = 2
				has_trait = temperate
			}
		}
	}
}

######################
# Host: Guests offer to help get a hunt going
# by Jay Zaborowski
# 0029
scripted_trigger ach_coronation_0029_friend_trigger = {
	this != involved_activity.activity_host
	is_available_in_activity_trigger = yes
	can_hunt_trigger = yes
	is_vegetarian_trigger = no
	likes_character_trigger = { CHARACTER = involved_activity.activity_host }
}

ach_coronation.0029 = {
	type = activity_event
	title = ach_coronation.0029.t
	desc = ach_coronation.0029.desc

	left_portrait = { 
		character = root
		animation = thinking
		camera = camera_event_table_left
	}

	center_portrait = { 
		character = scope:second
		triggered_animation = {
			trigger = { use_goblet_in_tavern_trigger = yes }
			animation = drink_goblet
		}
		triggered_animation = {
			trigger = { use_goblet_in_tavern_trigger = no }
			animation = drink
		}
		camera = camera_event_table_center
	}

	right_portrait = { 
		character = scope:first
		triggered_animation = {
			trigger = { use_goblet_in_tavern_trigger = yes }
			animation = toast_goblet
		}
		triggered_animation = {
			trigger = { use_goblet_in_tavern_trigger = no }
			animation = toast
		}
		camera = camera_event_table_right_far
	}
	
	theme = feast_activity

	cooldown = { years = 1 }

	trigger = {
		OR = {
			has_activity_intent = coronation_impress_attendees
			has_activity_intent = coronation_embrace_supporters
			has_activity_intent = coronation_exalt_crown
		}
		has_trait = lifestyle_hunter
		is_vegetarian_trigger = no
		involved_activity = {
			any_attending_character = {
				ach_coronation_0029_friend_trigger = yes
				count >= 2
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			has_trait = lifestyle_hunter
			has_trait_xp = {
				trait = lifestyle_hunter
				track = hunter
				value >= 50
			}
			add = 1
		}
		modifier = {
			has_trait = lifestyle_hunter
			has_trait_xp = {
				trait = lifestyle_hunter
				track = hunter
				value = 100
			}
			add = 1
		}
	}

	immediate = {
		involved_activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = { # Is your buddy and a hunter
					ach_coronation_0029_friend_trigger = yes
					has_trait = lifestyle_hunter
					has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
				}
				alternative_limit = { # Or one of those, at least
					ach_coronation_0029_friend_trigger = yes
					OR = {
						has_trait = lifestyle_hunter
						has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
					}
				}
				alternative_limit = { # Or exists, at least
					ach_coronation_0029_friend_trigger = yes
				}
				weight = {
					base = 1

					modifier = {
						has_trait = lifestyle_hunter
						add = 4
					}
					modifier = {
						add = 1
						reverse_opinion = {
							target = root
							value > 0
						}
					}
					modifier = {
						add = 2
						reverse_opinion = {
							target = root
							value > 20
						}
					}
					modifier = {
						add = 3
						reverse_opinion = {
							target = root
							value > 40
						}
					}
					modifier = {
						add = 5
						reverse_opinion = {
							target = root
							value > 60
						}
					}
					modifier = {
						add = 8
						reverse_opinion = {
							target = root
							value > 80
						}
					}
				}
				save_scope_as = first
			}
			random_attending_character = {
				limit = {
					ach_coronation_0029_friend_trigger = yes
					this != scope:first
					has_trait = lifestyle_hunter
					has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
				}
				alternative_limit = {
					ach_coronation_0029_friend_trigger = yes
					this != scope:first
					OR = {
						has_trait = lifestyle_hunter
						has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
					}
				}
				alternative_limit = {
					ach_coronation_0029_friend_trigger = yes
					this != scope:first
				}
				weight = {
					base = 1

					modifier = {
						has_trait = lifestyle_hunter
						add = 4
					}
					modifier = {
						add = 1
						reverse_opinion = {
							target = root
							value > 0
						}
					}
					modifier = {
						add = 2
						reverse_opinion = {
							target = root
							value > 20
						}
					}
					modifier = {
						add = 3
						reverse_opinion = {
							target = root
							value > 40
						}
					}
					modifier = {
						add = 5
						reverse_opinion = {
							target = root
							value > 60
						}
					}
					modifier = {
						add = 8
						reverse_opinion = {
							target = root
							value > 80
						}
					}
				}
				save_scope_as = second
			}
		}
	}

	option = { # Let's get a Hunt ready
		name = ach_coronation.0029.a

		reason = activity_intent

		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { has_activity_intent = coronation_impress_attendees }
					desc = ach_coronation.0029.a.flavor.impress_attendees
				}
				triggered_desc = {
					trigger = { has_activity_intent = coronation_embrace_supporters }
					desc = ach_coronation.0029.a.flavor.embrace_supporters
				}
				triggered_desc = {
					trigger = { has_activity_intent = coronation_exalt_crown }
					desc = ach_coronation.0029.a.flavor.exalt_crown
				}
			}
		}
		
		switch = {
			trigger = has_activity_intent
			coronation_impress_attendees = {
				custom_tooltip = ach_coronation.0029.a.impressive_hunt
				add_character_flag = impressive_hunt
			}
			coronation_embrace_supporters = {
				custom_tooltip = ach_coronation.0029.a.personal_hunt
				add_character_flag = personal_hunt
			}
			coronation_exalt_crown = {
				custom_tooltip = ach_coronation.0029.a.glorious_hunt
				add_character_flag = glorious_hunt
			}
		}
	}

	option = { # Want to try falconry?
		name = ach_coronation.0029.b
		trigger = { has_dlc_feature = tours_and_tournaments }
		
		flavor = ach_coronation.0029.b.flavor

		custom_tooltip = ach_coronation.0029.b.free_falconry
		add_character_flag = free_falconry
	}

	option = { # Is Temperance not a virtue?
		name = {
			trigger = {
				faith = { trait_is_virtue = temperate }
				NOR = {
					has_trait = gluttonous
					has_trait = cynical
				}
			}
			text = ach_coronation.0029.c.virtuous
		}
		name = ach_coronation.0029.c

		if = {
			limit = {
				faith = { trait_is_virtue = temperate }
				NOR = {
					has_trait = gluttonous
					has_trait = cynical
				}
			}
			custom_tooltip = ach_coronation.0029.c.virtuous.tt
			
			add_piety = medium_piety_gain

			every_vassal = {
				limit = {
					has_vassal_stance = zealot
				}
				custom = every_zealot_vassal
				add_opinion = {
					modifier = pious_opinion
					target = root
					opinion = 5
				}
			}
		}
		else = {
			add_prestige = minor_prestige_gain
		}

		ai_chance = {
			base = 150
		}
	}
}
