﻿# CHARIOT RACE ONGOING EVENTS
namespace = chariot_race

#########################################################################
###
### ONGOING EVENTS
###

##############################
### CHARIOTEER EVENTS

# Charioteer sacrifices himself for another of his team to pull ahead
# by Jason Cantalini
chariot_race.3000 = {
	type = activity_event
	title = chariot_race.3000.t
	desc = {
		desc = chariot_race.3000.intro
		#Different loc based on which racer is yours
		first_valid = {
			triggered_desc = {
				trigger = {
					var:wager_target = {
						this = scope:charioteer_sacrifice
					}
				}
				desc = chariot_race.3000.backing_sacrifice
			}
			triggered_desc = {
				trigger = {
					NOT = { var:wager_target = scope:charioteer_sacrifice }
					scope:charioteer_sacrifice = {
						has_court_position = charioteer_court_position
					}
					scope:charioteer_sacrifice = {
						is_court_position_employer = {
							court_position = charioteer_court_position
							who = root
						}
					}
				}
				desc = chariot_race.3000.not_backing_but_employs_sacrifice
			}
			desc = chariot_race.3000.not_backing_sacrifice
		}
	}
	theme = chariot_race_charioteer

	left_portrait = {
		character = scope:charioteer_leading
		animation = chariot_w_horses_neutral
		camera = camera_event_chariot_left_hippodrome
	}
	right_portrait = {
		character = scope:charioteer_sacrifice
		animation = chariot_happy
		camera = camera_event_chariot_right_hippodrome
	}

	trigger = {
		OR = {
			cares_about_charioteer_trigger = { CHARIOTEER = scope:charioteer_sacrifice }
			cares_about_charioteer_trigger = { CHARIOTEER = scope:charioteer_leading }
		}
	}

	#Pick a fight with the blocked racers' fans
	option = {
		name = chariot_race.3000.a
		flavor = chariot_race.3000.a.flavor
		trigger = {
			has_activity_intent = sow_discord_intent
		}
		if = {
			limit = {
				OR = {
					scope:host.capital_county = {
						county_control <= 80
					}
					has_character_flag = races_commoner_aiding_discord
				}
			}
			scope:host.capital_county = {
				add_county_modifier = {
					modifier = strong_sow_discord_modifier
					years = 10
				}
				change_county_control = miniscule_county_control_loss
			}
			add_dread = minor_dread_gain
			change_influence = miniscule_influence_loss
		}
		else = {
			scope:host.capital_county = {
				add_county_modifier = {
					modifier = normal_sow_discord_modifier
					years = 10
				}
				change_county_control = -2
			}
			add_dread = miniscule_dread_gain
			change_influence = miniscule_influence_loss
		}
		if = {
			limit = {
				scope:charioteer_sacrifice = {
					this = root.var:wager_target
					is_courtier_of = root
					NOT = {
						has_trait = reckless
					}
				}
			}
			random_list = {
				20 = {
					scope:charioteer_sacrifice = {
						add_trait = reckless
					}
				}
				10 = {}
			}
		}

		stress_impact = {
			compassionate = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			calm = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_compassion = -1
				ai_boldness = 1
			}
			modifier = {
				add = 100
				scope:host.capital_county = {
					county_control <= 80
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = craven
					has_trait = calm
					has_trait = humble
					influence <= minor_influence_value
				}
			}
		}
	}

	#A sensible sacrifice, I suppose
	option = {
		name = chariot_race.3000.b
		flavor = chariot_race.3000.b.flavor
		trigger = {
			OR = {
				cares_about_charioteer_trigger = { CHARIOTEER = scope:charioteer_sacrifice }
				cares_about_charioteer_trigger = { CHARIOTEER = scope:charioteer_leading }
			}
		}
		#It's nice to win!
		if = {
			limit = {
				var:wager_target = {
					this = scope:charioteer_leading
				}
			}
			stress_impact = {
				base = miniscule_stress_impact_loss
				compassionate = miniscule_stress_impact_gain
				just = miniscule_stress_impact_gain
				humble = miniscule_stress_impact_gain
			}
		}
		#Fellow Blues appreciate your support, despite your loss
		else = {
			change_influence = minor_influence_gain
			if = {
				limit = {
					NOR = {
						has_trait = generous
						has_trait = loyal
						has_trait = humble
						has_trait = content
						has_trait = forgiving
					}
				}
				if = {
					limit = {
						scope:charioteer_sacrifice = {
							is_courtier_of = root
							NOR = {
								has_trait = loyal
								has_trait = disloyal
							}
						}
					}
					random_list = {
						20 = {
							scope:charioteer_sacrifice = {
								add_trait = loyal
							}
						}
						10 = {}
					}
				}
				stress_impact = {
					base = minor_stress_impact_gain
					vengeful = minor_stress_impact_gain
					wrathful = minor_stress_impact_gain
					greedy = minor_stress_impact_gain
					arrogant = minor_stress_impact_gain
					ambitious = minor_stress_impact_gain
				}
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 50
				NOT = {
					var:wager_target ?= {
						this = scope:charioteer_sacrifice
					}
				}
				OR = {
					has_trait = arrogant
					has_trait = arbitrary
					has_trait = sadistic
					has_trait = callous
				}
			}
			modifier = {
				factor = 0
				var:wager_target ?= {
					this = scope:charioteer_sacrifice
				}
				OR = {
					has_trait = compassionate
					has_trait = just
					has_trait = humble
				}
			}
			modifier = {
				add = 50
				NOT = {
					var:wager_target ?= {
						this = scope:charioteer_sacrifice
					}
				}
				OR = {
					has_trait = forgiving
					has_trait = calm
					has_trait = generous
					has_trait = humble
					has_trait = content
				}
			}
			modifier = {
				factor = 0
				var:wager_target ?= {
					this = scope:charioteer_sacrifice
				}
				OR = {
					has_trait = vengeful
					has_trait = wrathful
					has_trait = greedy
					has_trait = arrogant
					has_trait = ambitious
				}
			}
		}
	}

	#Oof... but at what cost
	option = {
		name = chariot_race.3000.c
		flavor = chariot_race.3000.c.flavor
		trigger = {
			OR = {
				cares_about_charioteer_trigger = { CHARIOTEER = scope:charioteer_sacrifice }
				cares_about_charioteer_trigger = { CHARIOTEER = scope:charioteer_leading }
			}
		}
		#Fellow Blues appreciate your support in this sad time
		if = {
			limit = {
				var:wager_target ?= {
					this = scope:charioteer_leading
				}
			}
			change_influence = miniscule_influence_gain
			stress_impact = {
				arrogant = miniscule_stress_impact_gain
				callous = miniscule_stress_impact_gain
				sadistic = miniscule_stress_impact_gain
				stubborn = miniscule_stress_impact_gain
				disloyal = miniscule_stress_impact_gain
				greedy = miniscule_stress_impact_gain
			}
		}
		#What a time for self-pity
		else = {
			stress_impact = {
				loyal = miniscule_stress_impact_gain
				humble = miniscule_stress_impact_gain
				content = miniscule_stress_impact_gain
			}
			if = {
				limit = {
					scope:charioteer_sacrifice = {
						is_courtier_of = root
						NOT = {
							has_trait = unyielding_defender
						}
					}
				}
				random_list = {
					20 = {
						scope:charioteer_sacrifice = {
							add_trait = unyielding_defender
						}
					}
					10 = {}
				}
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 50
				NOT = {
					var:wager_target ?= {
						this = scope:charioteer_sacrifice
					}
				}
				OR = {
					has_trait = humble
					has_trait = compassionate
					has_trait = loyal
					has_trait = generous
				}
			}
			modifier = {
				factor = 0
				var:wager_target ?= {
					this = scope:charioteer_sacrifice
				}
				OR = {
					has_trait = arrogant
					has_trait = callous
					has_trait = sadistic
					has_trait = stubborn
					has_trait = disloyal
					has_trait = greedy
				}
			}
			modifier = {
				add = 50
				NOT = {
					var:wager_target ?= {
						this = scope:charioteer_sacrifice
					}
				}
				OR = {
					has_trait = disloyal
					has_trait = arrogant
					has_trait = ambitious
					has_trait = callous
				}
			}
			modifier = {
				factor = 0
				var:wager_target ?= {
					this = scope:charioteer_sacrifice
				}
				OR = {
					has_trait = loyal
					has_trait = humble
					has_trait = content
				}
			}
		}
	}

	option = { # My guy was passed up, that sucks
		name = chariot_race.3000.d
		trigger = {
			cares_about_charioteer_trigger = { CHARIOTEER = scope:charioteer_about_to_be_passed }
		}
		stress_impact = {
			base = minor_stress_impact_gain
		}
	}
}

# First Place Charioteer crashes and dies
# by Chad Uhl
chariot_race.3010 = {
	type = activity_event
	title = chariot_race.3010.t
	desc = chariot_race.3010.desc
	theme = chariot_race_charioteer
	override_background = { reference = ep3_hippodrome_track }

	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:first_place_charioteer
		animation = chariot_shocked
		camera = camera_event_chariot_right_hippodrome
	}

	immediate = {
		show_as_tooltip = {
			scope:first_place_charioteer = {
				death = { death_reason = death_crushed_in_chariot_race }
			}
		}
	}

	option = { # Give a speech to soothe the crowd
		name = chariot_race.3010.a
		trigger = {
			OR = {
				root = scope:host
				scope:host.primary_title = {
					place_in_line_of_succession = {
						target = root
						value >= 5
					}
				}
			}
		}
		# Diplomacy Challenge
		duel = {
			skill = diplomacy
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = chariot_race.3010.a.success
				if = {
					limit = { root = scope:host }
					send_interface_toast = {
						title = chariot_race.3010.a.success
						left_icon = root
						scope:activity = {
							add_activity_log_entry = {
								key = emperor_calms_mourning_crowd_log
								score = 25
								tags = { positive }
								character = root
								target = scope:first_place_charioteer

								root = { add_legitimacy = minor_legitimacy_gain }
							}
						}
					}
				}
				else = {
					send_interface_toast = {
						title = chariot_race.3010.a.success
						left_icon = root
						scope:activity = {
							add_activity_log_entry = {
								key = noble_calms_mourning_crowd_log
								score = 25
								tags = { positive }
								character = root
								target = scope:first_place_charioteer

								activity_location.county = {
									add_county_modifier = {
										modifier = calmed_after_charioteer_died_spectator
										years = 10
									}
								}
								scope:host.primary_title = {
									change_appointment_investment = {
										target = root
										value = appointment_score_minor_value
									}
								}
							}
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = chariot_race.3010.a.failure
				if = {
					limit = { root = scope:host }
					send_interface_toast = {
						title = chariot_race.3010.a.failure
						left_icon = root
						scope:activity = {
							add_activity_log_entry = {
								key = emperor_calms_mourning_crowd_fail_log
								score = 25
								tags = { negative }
								character = root
								target = scope:first_place_charioteer

								root = { add_legitimacy = miniscule_legitimacy_loss }
							}
						}
					}
				}
				else = {
					send_interface_toast = {
						title = chariot_race.3010.a.failure
						left_icon = root
						scope:activity = {
							add_activity_log_entry = {
								key = noble_calms_mourning_crowd_fail_log
								score = 25
								tags = { negative }
								character = root
								target = scope:first_place_charioteer

								root = { change_influence = minor_influence_loss }
							}
						}
					}
				}
			}
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				min = 0
				ai_honor = 0.75
				ai_boldness = 1
			}
			modifier = {
				has_trait = shy
				factor = 0
			}
		}

		stress_impact = {
			shy = medium_stress_impact_gain
		}
	}

	option = { # Commission a statue of the charioteer in the Hippodrome
		name = chariot_race.3010.b
		trigger = {
			has_activity_intent = appease_populace_intent
			this = scope:activity.activity_location.county.holder
			scope:activity.activity_location.county = {
				trigger_if = {
					limit = { scope:first_place_charioteer = { has_trait = charioteer_blue } }
					NOT = { has_county_modifier = chariot_race_blues_statue_county_modifier }
				}
				trigger_else_if = {
					limit = { scope:first_place_charioteer = { has_trait = charioteer_green } }
					NOT = { has_county_modifier = chariot_race_greens_statue_county_modifier }
				}
				trigger_else_if = {
					limit = { scope:first_place_charioteer = { has_trait = charioteer_white } }
					NOT = { has_county_modifier = chariot_race_whites_statue_county_modifier }
				}
				trigger_else_if = {
					limit = { scope:first_place_charioteer = { has_trait = charioteer_red } }
					NOT = { has_county_modifier = chariot_race_reds_statue_county_modifier }
				}
				trigger_else = { always = no }
			}
		}
		add_legitimacy = miniscule_legitimacy_gain
		remove_short_term_gold = medium_gold_value
		scope:first_place_charioteer = {
			switch = {
				trigger = has_trait
				charioteer_blue = {
					scope:activity.activity_location.county = { add_county_modifier = chariot_race_blues_statue_county_modifier }
				}
				charioteer_green = {
					scope:activity.activity_location.county = { add_county_modifier = chariot_race_greens_statue_county_modifier }
				}
				charioteer_white = {
					scope:activity.activity_location.county = { add_county_modifier = chariot_race_whites_statue_county_modifier }
				}
				charioteer_red = {
					scope:activity.activity_location.county = { add_county_modifier = chariot_race_reds_statue_county_modifier }
				}
			}
		}
		complete_activity_intent = yes

		ai_chance = {
			base = 60
			ai_value_modifier = {
				ai_honor = 1
				ai_greed = -1
				ai_compassion = 1
				min = 0
			}
			modifier = {
				short_term_gold <= medium_gold_value
				factor = 0
			}
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = callous
					has_trait = sadistic
				}
				add = -20
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
	}

	option = {
		name = chariot_race.3010.c
		add_prestige = medium_prestige_gain
		if = {
			limit = {
				is_landed = yes
				highest_held_title_tier >= tier_county
				OR = {
					this = scope:host
					NOT = {
						government_has_flag = government_is_administrative
					}
				}
			}
			add_legitimacy = miniscule_legitimacy_gain
		}

		remove_short_term_gold = minor_gold_value

		ai_chance = {
			base = 50
			ai_value_modifier = {
				min = 0
				ai_honor = 0.75
				ai_boldness = 1
			}
		}
	}
}

scripted_trigger chariot_race_3020_biggest_fandom = {
	OR = {
		AND = {
			var:wager_team = flag:blues
			scope:activity = {
				var:characters_betting_blue > var:characters_betting_green
				var:characters_betting_blue > var:characters_betting_red
				var:characters_betting_blue > var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:greens
			scope:activity = {
				var:characters_betting_green > var:characters_betting_blue
				var:characters_betting_green > var:characters_betting_red
				var:characters_betting_green > var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:reds
			scope:activity = {
				var:characters_betting_red > var:characters_betting_green
				var:characters_betting_red > var:characters_betting_blue
				var:characters_betting_red > var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:whites
			scope:activity = {
				var:characters_betting_white > var:characters_betting_green
				var:characters_betting_white > var:characters_betting_red
				var:characters_betting_white > var:characters_betting_blue
			}
		}
	}
}

scripted_trigger chariot_race_3020_smallest_fandom = {
	OR = {
		AND = {
			var:wager_team = flag:blues
			scope:activity = {
				var:characters_betting_blue < var:characters_betting_green
				var:characters_betting_blue < var:characters_betting_red
				var:characters_betting_blue < var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:greens
			scope:activity = {
				var:characters_betting_green < var:characters_betting_blue
				var:characters_betting_green < var:characters_betting_red
				var:characters_betting_green < var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:reds
			scope:activity = {
				var:characters_betting_red < var:characters_betting_green
				var:characters_betting_red < var:characters_betting_blue
				var:characters_betting_red < var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:whites
			scope:activity = {
				var:characters_betting_white < var:characters_betting_green
				var:characters_betting_white < var:characters_betting_red
				var:characters_betting_white < var:characters_betting_blue
			}
		}
	}
}

# An update on the charioteer you placed a bet on
# by Chad Uhl
chariot_race.3020 = {
	type = activity_event
	title = chariot_race.3020.t
	desc = {
		desc = chariot_race.3020.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:wager_target.var:current_place_in_race = 1 }
				desc = chariot_race.3020.placement_first
			}
			triggered_desc = {
				trigger = {
					scope:wager_target.var:current_place_in_race >= 2
					scope:wager_target.var:current_place_in_race < root.charioteer_placement_middle
				}
				desc = chariot_race.3020.placement_good
			}
			triggered_desc = {
				trigger = {
					scope:wager_target.var:current_place_in_race >= root.charioteer_placement_middle
					scope:wager_target.var:current_place_in_race < scope:activity.var:num_charioteers
				}
				desc = chariot_race.3020.placement_bad
			}
			triggered_desc = {
				trigger = { scope:wager_target.var:current_place_in_race = scope:activity.var:num_charioteers }
				desc = chariot_race.3020.placement_last
			}
		}
	}
	theme = chariot_race_charioteer
	override_background = { reference = ep3_hippodrome_track }

	cooldown = { years = 1 }

	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:wager_target
		animation = chariot_neutral
		camera = camera_event_chariot_right_hippodrome
	}
	lower_left_portrait = scope:special_guest

	trigger = {
		has_variable = wager_target
		var:wager_target = { this != root }
	}

	immediate = {
		var:wager_target = { save_scope_as = wager_target }
		if = {
			limit = { root = scope:activity.activity_host }
			scope:activity.special_guest:chariot_race_honorary_guest ?= { save_scope_as = special_guest }
		}
	}

	option = { # start a chant in the crowd
		name = chariot_race.3020.a
		flavor = chariot_race.3020.a.flavor
		trigger = { has_activity_intent = sow_discord_intent }
		if = {
			limit = {
				OR = {
					chariot_race_3020_biggest_fandom = yes
					AND = {
						has_character_flag = races_commoner_aiding_discord
						chariot_race_3020_smallest_fandom = no
					}
				}
			}
			if = {
				limit = {
					scope:host.primary_title = {
						any_title_heir = {
							this = root
						}
					}
				}
				scope:host.primary_title = {
					change_appointment_investment = {
						target = root
						value = 20
					}
				}
			}
			else = {
				add_prestige = medium_prestige_gain
				change_influence = miniscule_influence_gain
			}
			scope:host.capital_county = {
				change_county_control = -5
			}
		}
		else_if = {
			limit = {
				chariot_race_3020_smallest_fandom = yes
				NOT = {
					has_character_flag = races_commoner_aiding_discord
				}
			}
			if = {
				limit = {
					scope:host.primary_title = {
						any_title_heir = {
							this = root
						}
					}
				}
				scope:host.primary_title = {
					change_appointment_investment = {
						target = root
						value = 10
					}
				}
			}
			else = {
				add_prestige = minor_prestige_gain
			}
			scope:host.capital_county = {
				change_county_control = -1
			}
		}
		else = {
			if = {
				limit = {
					scope:host.primary_title = {
						any_title_heir = {
							this = root
						}
					}
				}
				scope:host.primary_title = {
					change_appointment_investment = {
						target = root
						value = 15
					}
				}
			}
			else = {
				add_prestige = minor_prestige_gain
			}
			scope:host.capital_county = {
				change_county_control = -3
			}
		}
		remove_short_term_gold = minor_gold_value
		stress_impact = {
			sadistic = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
			compassionate = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
			}
			modifier = {
				add = -50
				NOT = {
					scope:host.primary_title = {
						any_title_heir = {
							this = root
						}
						place_in_line_of_succession = {
							target = root
							value >= 10
						}
					}
				}
			}
			modifier = {
				add = -100
				chariot_race_3020_smallest_fandom = yes
			}
			modifier = {
				add = 50
				chariot_race_3020_biggest_fandom = yes
			}
			modifier = {
				add = 100
				scope:host.primary_title = {
					any_title_heir = {
						this = root
					}
					place_in_line_of_succession = {
						target = root
						value >= 5
					}
				}
			}
			modifier = {
				OR = {
					has_trait = compassionate
					has_trait = humble
					has_trait = content
				}
				factor = 0
			}
		}
	}

	option = { #Try to calm the crowd
		name = chariot_race.3020.b
		trigger = { has_activity_intent = appease_populace_intent }
		if = {
			limit = {
				scope:host = {
					legitimacy_level >= 4
				}
			}
			add_legitimacy = minor_legitimacy_gain
			if = {
				limit = {
					scope:host.capital_county = {
						has_county_modifier = strong_sow_discord_modifier
					}
				}
				scope:host.capital_county = {
					remove_county_modifier = strong_sow_discord_modifier
				}
			}
			else_if = {
				limit = {
					scope:host.capital_county = {
						has_county_modifier = normal_sow_discord_modifier
					}
				}
				scope:host.capital_county = {
					remove_county_modifier = normal_sow_discord_modifier
				}
			}
			else_if = {
				limit = {
					scope:host.capital_county = {
						has_county_modifier = weak_sow_discord_modifier
					}
				}
				scope:host.capital_county = {
					remove_county_modifier = weak_sow_discord_modifier
				}
			}
			scope:host.capital_county = {
				add_county_modifier = {
					modifier = ep3_chariot_race_strong_appeasement_modifier
					years = 10
				}
			}
			scope:host.capital_county = {
				change_county_control = miniscule_county_control_gain
			}
		}
		else = {
			add_legitimacy = miniscule_legitimacy_gain
			if = {
				limit = {
					scope:host.capital_county = {
						has_county_modifier = normal_sow_discord_modifier
					}
				}
				scope:host.capital_county = {
					remove_county_modifier = normal_sow_discord_modifier
				}
			}
			else_if = {
				limit = {
					scope:host.capital_county = {
						has_county_modifier = weak_sow_discord_modifier
					}
				}
				scope:host.capital_county = {
					remove_county_modifier = weak_sow_discord_modifier
				}
			}
			scope:host.capital_county = {
				add_county_modifier = {
					modifier = ep3_chariot_race_weak_appeasement_modifier
					years = 10
				}
			}
		}
		complete_activity_intent = yes
		remove_short_term_gold = minor_gold_value
		stress_impact = {
			generous = minor_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			greedy = major_stress_impact_gain
			temperate = major_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_greed = -0.5
				ai_compassion = 0.5
			}
			modifier = {
				add = 100
				scope:host = {
					legitimacy_level >= 4
				}
			}
			modifier = {
				add = 50
				scope:host.capital_county = {
					OR = {
						county_opinion < 0
						county_control < 100
					}
				}
			}
			modifier = {
				add = 100
				scope:host.capital_county = {
					OR = {
						county_opinion <= -20
						county_control < 95
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = temperate
					short_term_gold <= minor_gold_value
				}
			}
		}

	}

	option = { # strike up conversation with your special guest
		name = chariot_race.3020.c
		trigger = {
			this = scope:activity.activity_host
			exists = scope:activity.special_guest:chariot_race_honorary_guest
		}
		change_influence = minor_influence_gain
		progress_towards_friend_effect = {
			REASON = friend_chariot_convincing_display
			CHARACTER = scope:special_guest
			OPINION = default_friend_opinion
		}
	}

	# Fallback option
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:wager_target.var:current_place_in_race = 1 }
						desc = chariot_race.3020.d.placement_first
					}
					triggered_desc = {
						trigger = {
							scope:wager_target.var:current_place_in_race >= 2
							scope:wager_target.var:current_place_in_race < root.charioteer_placement_middle
						}
						desc = chariot_race.3020.d.placement_good
					}
					triggered_desc = {
						trigger = {
							scope:wager_target.var:current_place_in_race >= root.charioteer_placement_middle
							scope:wager_target.var:current_place_in_race < scope:activity.var:num_charioteers
						}
						desc = chariot_race.3020.d.placement_bad
					}
					triggered_desc = {
						trigger = { scope:wager_target.var:current_place_in_race = scope:activity.var:num_charioteers }
						desc = chariot_race.3020.d.placement_last
					}
				}
			}
		}
	}
}

# A Charioteer pulls ahead
# by Chad Uhl & Jason Cantalini
# Event sent to any spectator who cares about these charioteers
chariot_race.3030 = {
	type = activity_event
	title = chariot_race.3030.t
	desc = {
		desc = chariot_race.3030.desc
		triggered_desc = {
			trigger = {
				trigger_if = {
					limit = {
						scope:trailing_charioteer = { has_trait = charioteer_blue }
					}
					NOT = { scope:leading_charioteer = { has_trait = charioteer_blue } }
				}
				trigger_else_if = {
					limit = {
						scope:trailing_charioteer = { has_trait = charioteer_green }
					}
					NOT = { scope:leading_charioteer = { has_trait = charioteer_green } }
				}
				trigger_else_if = {
					limit = {
						scope:trailing_charioteer = { has_trait = charioteer_white }
					}
					NOT = { scope:leading_charioteer = { has_trait = charioteer_white } }
				}
				trigger_else_if = {
					limit = {
						scope:trailing_charioteer = { has_trait = charioteer_red }
					}
					NOT = { scope:leading_charioteer = { has_trait = charioteer_red } }
				}
				trigger_else = { always = no }
			}
			desc = chariot_race.3030.desc_teams
		}
	}
	theme = chariot_race_charioteer

	cooldown = { months = 3 }

	left_portrait = {
		character = scope:trailing_charioteer
		animation = chariot_w_horses_neutral
		camera = camera_event_chariot_left_hippodrome
	}
	right_portrait = {
		character = scope:leading_charioteer
		animation = chariot_shocked
		camera = camera_event_chariot_right_hippodrome
	}

	option = {
		name = chariot_race.3030.a
		trigger = {
			employs_court_position = charioteer_court_position
			court_position:charioteer_court_position = scope:trailing_charioteer
		}
	}

	option = {
		name = chariot_race.3030.b
		trigger = {
			is_ai = no
			can_employ_court_position_type = charioteer_court_position
			scope:trailing_charioteer = { can_be_employed_as = charioteer_court_position }
		}
		change_influence = medium_influence_loss
		scope:trailing_charioteer = {
			if = {
				limit = { employer != root }
				set_employer = root
			}
		}
		appoint_court_position = {
			recipient = scope:trailing_charioteer
			court_position = charioteer_court_position
		}
	}

	option = {
		name = chariot_race.3030.c

		ai_chance = {
			base = 30
			modifier = {
				has_trait = ambitious
				factor = 0
			}
		}
	}
}

# A Shipwreck
# by Luke Bean
chariot_race.3040 = {
	type = activity_event
	title = chariot_race.3040.t
	desc = chariot_race.3040.desc
	theme = chariot_race_charioteer

	left_portrait = {
		character = scope:charioteer_1
		animation = chariot_neutral
		camera = camera_event_chariot_left
	}
	right_portrait = {
		character = scope:charioteer_2
		animation = chariot_shocked
		camera = camera_event_chariot_right
	}

	option = { # These brave souls will have a lavish funeral
		name = chariot_race.3040.a
		trigger = { has_activity_intent = appease_populace_intent }
		scope:charioteer_1 = {
			death = { death_reason = death_crushed_in_chariot_race }
			remove_dead_charioteer_from_race = yes
		}
		scope:charioteer_2 = {
			death = { death_reason = death_crushed_in_chariot_race }
			remove_dead_charioteer_from_race = yes
		}
		if = {
			limit = { exists = scope:activity.special_guest:chariot_race_honorary_guest }
			reverse_add_opinion = {
				modifier = impressed_opinion
				opinion = 20
				target = scope:activity.special_guest:chariot_race_honorary_guest
			}
		}
		capital_county = {
			add_county_modifier = {
				modifier = ep3_chariot_race_strong_appeasement_modifier
				years = 10
			}
			change_county_control = minor_county_control_gain

		}
		complete_activity_intent = yes
		remove_short_term_gold = medium_gold_value
		add_prestige = medium_prestige_gain

		stress_impact = {
			greedy = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
	}

	option = { # Pause the race! They could still be alive!
		name = chariot_race.3040.b
		add_prestige = medium_prestige_loss # Inappropriate behavior
		custom_tooltip = chariot_race.3040.b
		random_list = {
			4 = { # Everyone survives
				show_chance = no
				desc = chariot_race.3040.b.both_survive
				scope:charioteer_1 = {
					increase_wounds_no_death_effect = { REASON = death_crushed_in_chariot_race }
				}
				scope:charioteer_2 = {
					increase_wounds_no_death_effect = { REASON = death_crushed_in_chariot_race }
				}
			}
			16 = { # Charioteer 2 survives
				show_chance = no
				desc = chariot_race.3040.b.chariot_two_survives
				scope:charioteer_1 = {
					death = { death_reason = death_crushed_in_chariot_race }
					remove_dead_charioteer_from_race = yes
				}
				scope:charioteer_2 = {
					increase_wounds_no_death_effect = { REASON = death_crushed_in_chariot_race }
				}
			}
			16 = { # Charioteer 1 survives
				desc = chariot_race.3040.b.chariot_one_survives
				show_chance = no
				scope:charioteer_1 = {
					increase_wounds_no_death_effect = { REASON = death_crushed_in_chariot_race }
				}
				scope:charioteer_2 = {
					death = { death_reason = death_crushed_in_chariot_race }
					remove_dead_charioteer_from_race = yes
				}
			}
			64 = { # No survivors
				show_chance = no
				desc = chariot_race.3040.b.no_survivors
				scope:charioteer_1 = {
					death = { death_reason = death_crushed_in_chariot_race }
					remove_dead_charioteer_from_race = yes
				}
				scope:charioteer_2 = {
					death = { death_reason = death_crushed_in_chariot_race }
					remove_dead_charioteer_from_race = yes
				}
			}
		}
		stress_impact = {
			sadistic = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			compassionate = medium_stress_impact_loss
			arbitrary = minor_stress_impact_loss
		}
	}
	option = { # What a show! THAT'S a chariot race!
		name = chariot_race.3040.c
		if = {
			limit = { root = scope:host } # so that EVERYONE isn't telling the charioteers to die
			scope:charioteer_1 = {
				death = { death_reason = death_crushed_in_chariot_race }
				remove_dead_charioteer_from_race = yes
			}
			scope:charioteer_2 = {
				death = { death_reason = death_crushed_in_chariot_race }
				remove_dead_charioteer_from_race = yes
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			brave = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			compassionate = major_stress_impact_gain
		}
	}

	after = {
		update_chariot_race_standings_effect = yes
	}
}

# A Charioteer gets an Aristeia and goes from last to first place
# by Chad Uhl
chariot_race.3050 = {
	type = activity_event
	title = chariot_race.3050.t
	desc = chariot_race.3050.desc
	theme = chariot_race_charioteer

	left_portrait = {
		character = scope:last_place_charioteer
		animation = chariot_w_horses_happy
		camera = camera_event_chariot_left_hippodrome
	}
	right_portrait = {
		character = scope:first_place_charioteer
		animation = chariot_shocked
		camera = camera_event_chariot_right_hippodrome
	}

	# You root for him/have wagered on him, so you're thrilled
	option = {
		name = chariot_race.3050.a
		# Check that root has wagered on the charioteer or cares about their team at the very least
		trigger = {
			trigger_if = {
				limit = { scope:last_place_charioteer = { has_trait = charioteer_blue } }
				supports_chariot_team_trigger = { TEAM = flag:blues }
			}
			trigger_else_if = {
				limit = { scope:last_place_charioteer = { has_trait = charioteer_green } }
				supports_chariot_team_trigger = { TEAM = flag:greens }
			}
			trigger_else_if = {
				limit = { scope:last_place_charioteer = { has_trait = charioteer_white } }
				supports_chariot_team_trigger = { TEAM = flag:whites }
			}
			trigger_else_if = {
				limit = { scope:last_place_charioteer = { has_trait = charioteer_red } }
				supports_chariot_team_trigger = { TEAM = flag:reds }
			}
			trigger_else = {
				var:wager_target ?= scope:last_place_charioteer
			}
		}

		change_influence = minor_influence_gain

		ai_chance = {
			base = 60
		}
	}

	# Hire him
	option = {
		name = chariot_race.3050.b
		trigger = {
			can_appoint_char_to_court_position = {
				CHAR = scope:last_place_charioteer
				COURT_POS = charioteer_court_position
			}
		}
		scope:last_place_charioteer = { set_employer = root }
		appoint_court_position = {
			recipient = scope:last_place_charioteer
			court_position = charioteer_court_position
		}

		ai_chance = {
			base = 50
		}
	}

	# Generic Cheer
	option = {
		name = chariot_race.2050.c
		trigger = { cares_about_charioteer_trigger = { CHARIOTEER = scope:last_place_charioteer } }

		ai_chance = {
			base = 40
		}
		stress_impact = {
			base = minor_stress_impact_loss
		}
	}

	option = {
		name = chariot_race.2050.d
		ai_chance = {
			base = 40
		}
		stress_impact = {
			base = minor_stress_impact_gain
		}
	}
}

##############################
### SPECTATOR EVENTS

# You have a run-in with a fellow governor
# by Chad Uhl
chariot_race.4000 = {
	type = activity_event
	title = chariot_race.4000.t
	desc = chariot_race.4000.desc
	theme = chariot_race

	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:target_governor
		animation = admiration
	}
	lower_center_portrait = scope:activity.var:first_place

	cooldown = { years = 1 }

	trigger = {
		is_governor = yes
		scope:activity = {
			any_guest_subset = {
				name = spectators
				is_governor = yes
				top_liege = root.top_liege
				is_ai = yes
				this != root
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			has_activity_intent = increase_influence_intent
		}
		modifier = {
			add = 1
			has_activity_intent = befriend_attendee_intent
			intent_target ?= {
				is_alive = yes
				is_governor = yes
				NOR = {
					has_relation_friend = root
					this = root
				}
			}
		}
	}

	immediate = {
		# Pick out a target governor to chat with
		scope:activity = {
			if = {
				limit = {
					root = {
						has_activity_intent = befriend_attendee_intent
						intent_target ?= {
							is_alive = yes
							is_governor = yes
							NOR = {
								has_relation_friend = root
								this = root
							}
						}
					}
				}
				root.intent_target = { save_scope_as = target_governor }
			}
			else = {
				random_guest_subset = {
					name = spectators
					limit = {
						is_governor = yes
						top_liege = root.top_liege
						is_ai = yes
						this != root
					}
					save_scope_as = target_governor
				}
			}
			# Get the guy in last place for loc
			ordered_guest_subset = {
				name = charioteers
				order_by = {
					value = charioteer_victory_score_value
					multiply = -1
				}
				save_scope_as = last_place
			}
		}
		top_liege.primary_title = { save_scope_as = target_title }
	}

	option = { # Increase/decrease your candidate score
		name = chariot_race.4000.a
		trigger = {
			top_liege = {
				has_realm_law = acclamation_succession_law
			}
		}
		duel = {
			skill = diplomacy
			target = scope:target_governor
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = chariot_race.4000.a.critical_success
				send_interface_toast = {
					title = chariot_race.4000.a.critical_success
					left_icon = root

					scope:target_title = {
						change_appointment_investment = {
							target = root
							value = medium_influence_gain
						}
					}
					custom_tooltip = change_appointment_investment_medium_gain
					progress_towards_friend_effect = {
						CHARACTER = scope:target_governor
						OPINION = 30
						REASON = friend_chariot_convincing_display
					}
				}
			}
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = chariot_race.4000.a.success
				send_interface_toast = {
					title = chariot_race.4000.a.success
					left_icon = root

					scope:target_title = {
						change_appointment_investment = {
							target = root
							value = appointment_score_minor_value
						}
					}
					custom_tooltip = change_appointment_investment_minor_gain
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = chariot_race.4000.a.failure
				send_interface_toast = {
					title = chariot_race.4000.a.failure
					left_icon = root

					scope:target_title = {
						change_appointment_investment = {
							target = root
							value = {
								value = appointment_score_minor_value
								multiply = -1
							}
						}
					}
					custom_tooltip = change_appointment_investment_minor_loss
				}
			}
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = chariot_race.4000.a.critical_failure
				send_interface_toast = {
					title = chariot_race.4000.a.critical_failure
					left_icon = root

					scope:target_title = {
						change_appointment_investment = {
							target = root
							value = {
								value = appointment_score_medium_value
								multiply = -1
							}
						}
					}
					custom_tooltip = change_appointment_investment_medium_loss
					progress_towards_rival_effect = {
						CHARACTER = scope:target_governor
						OPINION = -30
						REASON = rival_chariot_race
					}
				}
			}
		}

		stress_impact = {
			ambitious = medium_stress_impact_loss
			gregarious = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
			shy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_boldness = 1.5
				ai_sociability = 1.5
				ai_honor = 1.1
			}
		}
	}

	option = { # Sow Discord
		name = chariot_race.4000.b
		trigger = { has_activity_intent = sow_discord_intent }
		if = {
			limit = {
				NOT = {
					has_character_modifier = united_political_agents_modifier
				}
				is_vassal_of = scope:host
			}
			custom_tooltip = ep3_united_agents_tooltip
			add_character_modifier = {
				modifier = united_political_agents_modifier
				years = 10
				desc = united_political_agents_modifier_tt
			}
			scope:host.capital_county = {
				add_county_modifier = {
					modifier = weak_sow_discord_modifier
					years = 10
				}
			}
		}
		else = {
			scope:host.capital_county = {
				add_county_modifier = {
					modifier = weak_sow_discord_modifier
					years = 10
				}
			}
			change_influence = minor_influence_gain
			add_intrigue_lifestyle_xp = minor_lifestyle_xp
		}
		if = {
			limit = {
				has_character_flag = races_commoner_aiding_discord
			}
			scope:host.capital_county = {
				change_county_control = -2
			}
		}
		stress_impact = {
			content = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_greed = 0.5
				ai_sociability = 0.5
			}
			modifier = {
				add = 100
				opinion = {
					target = scope:host
					value <= -75
				}
			}
			modifier = {
				add = -100
				opinion = {
					target = scope:host
					value >= 75
				}
			}
			modifier = {
				add = -50
				opinion = {
					target = scope:host
					value >= 25
				}
			}
			modifier = {
				add = 50
				opinion = {
					target = scope:host
					value <= -75
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = content
					has_trait = paranoid
					has_trait = just
				}
			}
		}
	}

	option = { # Spread Legend
		name = chariot_race.4000.c
		trigger = { has_activity_intent = spread_legend_intent }
		duel = {
			skill = diplomacy
			target = scope:target_governor
			50 = {
				desc = chariot_race.4000.c.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				send_interface_toast = {
					title = chariot_race.4000.c.success
					left_icon = root
					right_icon = scope:target_governor
					change_influence = minor_influence_gain
					scope:target_governor = {
						set_promoted_legend = root.promoted_legend
					}
				}
				complete_activity_intent = yes
			}
			50 = {
				desc = chariot_race.4000.c.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				send_interface_toast = {
					title = chariot_race.4000.c.failure
					left_icon = root
					right_icon = scope:target_governor
					add_prestige = medium_prestige_loss
				}
			}
		}

		stress_impact = {
			humble = medium_stress_impact_gain
			honest = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 1.2
				ai_sociability = 1.5
				ai_honor = 1.5
			}
		}
	}

	option = { # Increase Influence
		name = chariot_race.4000.d
		trigger = { has_activity_intent = increase_influence_intent }
		duel = {
			skill = intrigue
			target = scope:target_governor
			50 = {
				desc = chariot_race.4000.d.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				send_interface_toast = {
					title = chariot_race.4000.d.success
					left_icon = root
					right_icon = scope:target_governor
					change_influence = major_influence_gain
				}
				complete_activity_intent = yes
			}
			50 = {
				desc = chariot_race.4000.d.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				send_interface_toast = {
					title = chariot_race.4000.d.failure
					left_icon = root
					right_icon = scope:target_governor
					add_prestige = medium_prestige_loss
				}
			}
		}

		stress_impact = {
			arrogant = minor_stress_impact_loss
			deceitful = minor_stress_impact_loss
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 1.5
				ai_sociability = 1
				ai_honor = -0.5
			}
		}
	}

	option = { # Befriend Attendee
		name = chariot_race.4000.f
		trigger = {
			has_activity_intent = befriend_attendee_intent
			scope:target_governor = root.intent_target
		}
		progress_towards_friend_effect = {
			REASON = friend_chariot_convincing_display
			CHARACTER = scope:target_governor
			OPINION = default_friend_opinion
		}

		stress_impact = {
			gregarious = medium_stress_impact_loss
		}

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

	option = { # Fallback
		name = chariot_race.4000.g
		flavor = chariot_race.4000.g.flavor
		change_influence = medium_influence_loss
		scope:target_title = {
			change_appointment_investment = {
				target = root
				value = {
					value = appointment_score_medium_value
					multiply = -1
				}
			}
		}
		custom_tooltip = target_governor_change_appointment_investment_medium_loss

		stress_impact = {
			arrogant = medium_stress_impact_loss
			content = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 2
				ai_sociability = -1
				ai_honor = -2
			}
			modifier = {
				OR = {
					has_trait = content
					has_trait = compassionate
				}
				factor = 0
			}
		}
	}
}

# Down With Unpopular Official!
# by Luke Bean
chariot_race.4010 = {
	type = activity_event
	title = chariot_race.4010.t
	desc = chariot_race.4010.desc
	theme = chariot_race

	cooldown = { years = 1 }

	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:unpopular_official
		animation = shock
	}

	trigger = {
		root = root.involved_activity.activity_host
		OR = { # Need at least one official to exist
			any_councillor = {
				count > 0
				can_be_fired_from_council_trigger = { COURT_OWNER = root }
			}
			any_vassal = {
				count > 0
				root = { has_revoke_title_reason = prev }
			}
		}
	}

	immediate = {
		root.involved_activity = { save_scope_as = activity }
		every_councillor = {
			limit = { can_be_fired_from_council_trigger = { COURT_OWNER = root } }
			add_to_list = potential_unpopular_official
		}
		every_vassal = {
			limit = { root = { has_revoke_title_reason = prev } }
			add_to_list = potential_unpopular_official
		}
		ordered_in_list = {
			list = potential_unpopular_official
			limit = {
				NOR = {
					this = root.cp:councillor_court_chaplain
					has_court_position = charioteer_court_position
					has_court_position = bookmaker_court_position
				}
			}
			order_by = {
				value = ai_greed
				if = {
					limit = { num_sinful_traits = { value = 1 target = root.faith } }
					add = 10
				}
				else_if = {
					limit = { num_sinful_traits = { value = 2 target = root.faith } }
					add = 30
				}
				else_if = {
					limit = { num_sinful_traits = { value > 2 target = root.faith } }
					add = 60
				}
				if = {
					limit = { num_virtuous_traits = { value = 1 target = root.faith } }
					add = -5
				}
				else_if = {
					limit = { num_virtuous_traits = { value = 2 target = root.faith } }
					add = -15
				}
				else_if = {
					limit = { num_virtuous_traits = { value > 2 target = root.faith } }
					add = -30
				}
				if = {
					limit = { has_trait = sadistic }
					add = 100
				}
				if = {
					limit = { has_trait = greedy }
					add = 60
				}
				if = {
					limit = { has_trait = arbitrary }
					add = 30
				}
				if = {
					limit = { has_trait = compassionate }
					add = -30
				}
				if = {
					limit = { has_trait = generous }
					add = -30
				}
				if = {
					limit = { has_trait = just }
					add = -30
				}
				if = {
					limit = { # More likely to happen to a skilled councillor
						save_temporary_scope_as = councillor_check_temp
						root = { any_councillor = { this = scope:councillor_check_temp } }
						councillor_is_skilled_trigger = { EMPLOYER = root }
					}
					multiply = 2
				}
				if = {
					limit = { # More likely to happen to someone who is physically present
						save_temporary_scope_as = spectator_check_temp
						scope:activity = {
							any_guest_subset = {
								name = spectators
								this = scope:spectator_check_temp
							}
						}
					}
					multiply = 2
				}
			}
			save_scope_as = unpopular_official
		}
	}

	option = { # Tell the crowd that Unpopular Official will be stripped of their position
		name = chariot_race.4010.a
		if = {
			limit = {
				scope:unpopular_official = {
					is_councillor = yes
					can_be_fired_from_council_trigger = { COURT_OWNER = root }
				}
			}
			fire_councillor = scope:unpopular_official
		}
		else_if = {
			limit = {
				has_revoke_title_reason = scope:unpopular_official
				scope:unpopular_official = {
					is_vassal_of = root

				}
			}
			scope:unpopular_official = {
				ordered_heir = {
					order_by = appointment_score_script_value
					save_scope_as = new_governor
				}
				create_title_and_vassal_change = {
					type = granted
					save_scope_as = change
					add_claim_on_loss = yes
				}
				# If you have admin counts below you, they move to the new governor
				every_vassal = {
					limit = {
						primary_title = {
							any_this_title_or_de_jure_above = {
								is_in_list = transfer_titles
							}
						}
					}
					change_liege = {
						liege = scope:new_governor
						change = scope:change
					}
				}
				# Move all titles under you governorship to the new governor
				every_in_list = {
					list = transfer_titles
					change_title_holder = {
						holder = scope:new_governor
						change = scope:change
					}
				}
				# It shouldn't happen, but if by any chance you remain landed in the area, you also move below the new governor
				if = {
					limit = {
						is_landed = yes
						any_held_title = {
							any_this_title_or_de_jure_above = {
								is_in_list = transfer_titles
							}
						}
						NOT = {
							any_held_title = {
								is_noble_family_title = no
								tier >= scope:new_governor.primary_title.tier
							}
						}
					}
					change_liege = {
						liege = scope:new_governor
						change = scope:change
					}
				}

				resolve_title_and_vassal_change = scope:change
			}
		}
		progress_towards_rival_effect = {
			REASON = rival_fired_at_chariot_race
			CHARACTER = scope:unpopular_official
			OPINION = 0
		}
		stress_impact = {
			base = minor_stress_impact_gain
			just = minor_stress_impact_gain
			stubborn = major_stress_impact_gain # Bowing to the crowd drives Stubborn crazy
			fickle = minor_stress_impact_loss # Fickle and Arbitrary don't find this stressful
			arbitrary = minor_stress_impact_loss
		}
		ai_chance = {
			base = 30
			modifier = {
				factor = 0
				scope:unpopular_official = { is_ai = no }
			}
		}
	}

	option = { # Placate the crowd. Send servants to throw them prizes!
		name = chariot_race.4010.b
		trigger = { has_activity_intent = appease_populace_intent }
		remove_short_term_gold = medium_gold_value
		duel = {
			value = decent_skill_rating
			skill = diplomacy
			70 = {
				desc = chariot_race.4010.b.tt.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				send_interface_toast = {
					left_icon = root
					title = chariot_race.4010.b.tt.success
					add_legitimacy = minor_legitimacy_gain
					capital_county = {
						add_county_modifier = {
							modifier = ep3_chariot_race_weak_appeasement_modifier
							years = 10
						}
						change_county_control = miniscule_county_control_gain
					}
					complete_activity_intent = yes
				}
			}
			30 = {
				desc = chariot_race.4010.b.tt.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				send_interface_toast = {
					left_icon = root
					title = chariot_race.4010.b.tt.failure
					capital_county = {
						add_county_modifier = {
							modifier = normal_sow_discord_modifier
							years = 10
						}
					}
				}
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -1
			}
			modifier = {
				factor = 0
				short_term_gold <= medium_gold_value
			}
		}
	}

	option = { # Unacceptable. I need Unpopular Official's skills.
		name = chariot_race.4010.c
		reverse_add_opinion = {
			target = scope:unpopular_official
			modifier = grateful_opinion
			opinion = 30
		}
		stress_impact = {
			fickle = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

scripted_trigger chariot_race_4020_house_head_trigger = {
	top_liege = root.top_liege
	NOR = {
		this = scope:host
		this = root
	}
	NOT = { has_character_flag = had_chariot_race_4020 }
	is_lowborn = no
	is_ai = yes
	opinion = {
		target = root
		value >= 0
	}
	has_domicile = yes
	save_temporary_scope_as = notable_temp
	
	scope:notable_temp.domicile.domicile_location != root.capital_province
}

# House Head is considering moving their estate
#By Jason Cantalini
chariot_race.4020 = {
	type = activity_event
	title = chariot_race.4020.t
	desc = {
		desc = chariot_race.4020.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:current_estate = top_liege.capital_province
				}
				desc = chariot_race.4020.desc_capital_estate
			}
			desc = chariot_race.4020.desc_provincial_estate
		}
	}

	theme = chariot_race

	left_portrait = {
		character = root
		animation = throne_room_conversation_2
	}
	center_portrait = {
		character = scope:notable
		animation = eavesdrop
	}

	trigger = {
		this != scope:host
		is_governor = yes
		scope:activity = {
			any_guest_subset = {
				name = spectators
				OR = {
					is_landless_administrative = yes
					is_governor = yes
				}
				chariot_race_4020_house_head_trigger = yes
			}
		}
		governor_efficiency >= 1
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 3
			OR = {
				AND = {
					has_activity_intent = befriend_attendee_intent
					root.intent_target = {
						is_landless_administrative = yes
						chariot_race_4020_house_head_trigger = yes
					}
				}
				has_activity_intent = increase_influence_intent
			}
		}
	}

	immediate = {
		#start with a friend target that fits the bill
		if = {
			limit = {
				has_activity_intent = befriend_attendee_intent
				NOR = {
					has_relation_friend = root.intent_target
					has_relation_best_friend = root.intent_target
				}
				scope:activity = {
					any_guest_subset = {
						name = spectators
						is_landless_administrative = yes
						chariot_race_4020_house_head_trigger = yes
						this = root.intent_target
					}
				}
			}
			scope:activity = {
				random_guest_subset = {
					name = spectators
					limit = {
						is_landless_administrative = yes
						chariot_race_4020_house_head_trigger = yes
						this = root.intent_target
					}
					save_scope_as = notable
				}
			}
		}
		#same, but governor instead of unlanded admin
		else_if = {
			limit = {
				has_activity_intent = befriend_attendee_intent
				NOR = {
					has_relation_friend = root.intent_target
					has_relation_best_friend = root.intent_target
				}
				scope:activity = {
					any_guest_subset = {
						name = spectators
						is_governor = yes
						chariot_race_4020_house_head_trigger = yes
						this = root.intent_target
					}
				}
			}
			scope:activity = {
				random_guest_subset = {
					name = spectators
					limit = {
						is_governor = yes
						chariot_race_4020_house_head_trigger = yes
						this = root.intent_target
					}
					save_scope_as = notable
				}
			}
		}
		#save unlanded house head scope
		else_if = {
			limit = {
				scope:activity = {
					any_guest_subset = {
						name = spectators
						is_landless_administrative = yes
						chariot_race_4020_house_head_trigger = yes
					}
				}
			}
			scope:activity = {
				random_guest_subset = {
					name = spectators
					limit = {
						is_landless_administrative = yes
						chariot_race_4020_house_head_trigger = yes
					}
					save_scope_as = notable
				}
			}
		}
		else = {
			scope:activity = {
				random_guest_subset = {
					name = spectators
					limit = {
						is_governor = yes
						chariot_race_4020_house_head_trigger = yes
					}
					save_scope_as = notable
				}
			}
		}

		scope:notable.domicile.domicile_location = {
			save_scope_as = current_estate
		}

		scope:notable = {
			add_character_flag = {
				flag = had_chariot_race_4020
				days = 600
			}
		}
	}

	option = { # Yes, then we can hang more!
		name = chariot_race.4020.a
		flavor = chariot_race.4020.a.flavor
		trigger = {
			has_activity_intent = befriend_attendee_intent
			scope:notable = {
				this = root.intent_target
			}
		}
		duel = {
			skill = diplomacy
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = 20
					reverse_opinion = {
						target = scope:notable
						value > 50
					}
				}
				desc = chariot_race.4020.a.success
				send_interface_toast = {
					title = chariot_race.4020.a.success
					left_icon = root
					right_icon = scope:notable
					scope:activity = {
						add_activity_log_entry = {
							key = moved_estate_log
							score = 25
							tags = { positive }
							character = root
							target = scope:notable

							#Effect
							root = {
								set_relation_friend = {
									reason = friend_moved_estate
									target = scope:notable
								}
								if = {
									limit = {
										root = {
											this = house.house_head
										}
									}
									dynasty = {
										add_dynasty_prestige = minor_dynasty_prestige_gain
									}
								}
							}

						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					add = 20
					reverse_opinion = {
						target = scope:notable
						value <= 20
					}
				}
				desc = chariot_race.4020.a.failure
				send_interface_toast = {
					title = chariot_race.4020.a.failure
					left_icon = root
					right_icon = scope:notable
					scope:activity = {
						add_activity_log_entry = {
							key = moved_estate_log
							score = 25
							tags = { positive }
							character = root
							target = scope:notable

							#Effect
							root = {
								progress_towards_friend_effect = {
									CHARACTER = scope:notable
									OPINION = 30
									REASON = friend_moved_estate
								}
								if = {
									limit = {
										root = {
											this = house.house_head
										}
									}
									dynasty = {
										add_dynasty_prestige = miniscule_dynasty_prestige_gain
									}
								}
							}
						}
					}
				}
			}
		}
		scope:notable.domicile = {
			move_domicile = root.capital_province
		}
		scope:notable = {
			set_location = scope:host.capital_province
		}
		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			trusting = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_sociability = 1
			}
			modifier = {
				add = 100
				OR = {
					has_trait = gregarious
					has_trait = trusting
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = shy
					has_trait = callous
					has_trait = paranoid
				}
			}
		}
	}

	option = { # Come work for my administration
		name = chariot_race.4020.b
		trigger = {
			has_activity_intent = increase_influence_intent
		}
		scope:activity = {
			add_activity_log_entry = {
				key = moved_estate_log
				score = 25
				tags = { positive }
				character = root
				target = scope:notable

				root = {
					change_influence = medium_influence_gain
					add_character_modifier = {
						modifier = noble_administrators_modifier
						desc = 5_percent_governor_efficiency_tooltip
						years = 20
					}
					reverse_add_opinion = {
						modifier = grateful_opinion
						target = scope:notable
						opinion = 10
					}
				}

				scope:notable.domicile = {
					move_domicile = root.capital_province
				}
				scope:notable = {
					set_location = scope:activity.activity_location
				}
			}
		}
		stress_impact = {
			diligent = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_gain
			content = minor_stress_impact_gain
			paranoid = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_energy = 0.5
				ai_sociability = 0.5
			}
			modifier = {
				add = 100
				has_trait = diligent
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = content
					has_trait = paranoid
				}
			}
		}
	}

	option = { # I'll build a country residence for you... for free
		name = chariot_race.4020.c
		flavor = chariot_race.4020.c.flavor
		add_hook = {
			type = favor_hook
			target = scope:notable
		}
		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:notable
			opinion = 20
		}
		change_influence = minor_influence_gain
		remove_short_term_gold = medium_gold_value

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			greedy = minor_stress_impact_gain
			honest = miniscule_stress_impact_gain
			just = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.5
				ai_honor = -0.5
			}
			modifier = {
				add = 50
				has_trait = ambitious
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = honest
					has_trait = just
					short_term_gold <= major_gold_value
				}
			}
		}
	}

	option = { # I hear your family has certain business interests...
		name = chariot_race.4020.d
		flavor = chariot_race.4020.d.flavor
		root.capital_county = {
			change_development_progress = minor_development_progress_gain
			add_county_modifier = {
				modifier = mercantile_contacts_modifier
				years = 10
			}
		}
		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
			compassionate = miniscule_stress_impact_gain
			impatient = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 0.5
				ai_rationality = 0.5
			}
			modifier = {
				add = 50
				has_trait = greedy
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = generous
					has_trait = impatient
				}
			}
		}
	}
}

scripted_trigger chariot_race_4030_john_trigger = {
	OR = {
		is_landless_administrative = yes
		is_governor = yes
		highest_held_title_tier >= tier_duchy
	}
	NOT = { has_character_flag = chariot_race_john }
	is_ai = yes
	is_adult = yes
	is_healthy = yes
	NOR = {
		has_trait = chaste
		has_trait = celibate
	}
	possibly_interested_in_character_trigger = { CHARACTER = scope:prostitute }
	this != scope:host
	NOT = {
		faith = {
			trait_is_virtue = lustful
		}
	}
}

# You might do some sex during the race
#By Jason Cantalini
chariot_race.4030 = {
	type = activity_event
	title = chariot_race.4030.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_activity_intent = woo_attendee_intent
					exists = scope:seduce_interest
				}
				desc = chariot_race.4030.desc
			}
			desc = chariot_race.4030.desc_no_seduction
		}
	}
	theme = chariot_race

	left_portrait = {
		character = root
		animation = personality_dishonorable
		camera = camera_event_very_left
	}
	center_portrait = {
		character = scope:seduce_interest
		animation = eavesdrop
	}
	right_portrait = {
		character = scope:prostitute
		animation = scheme
	}

	lower_center_portrait = {
		character = scope:john
	}

	cooldown = { years = 9 }

	trigger = {
		is_adult = yes
		NOR = {
			has_trait = celibate
			has_sexuality = asexual
		}
		#This event would feel weird if it were firing for subordinated gender more than is necessary
		OR = {
			AND = {
				is_female = yes
				faith = { has_doctrine = doctrine_gender_female_dominated }
			}
			AND = {
				is_female = no
				NOT = { faith = { has_doctrine = doctrine_gender_female_dominated } }
			}
			#We need the seduce outcome regardless of gender
			AND = {
				has_activity_intent = woo_attendee_intent
				root.intent_target = {
					is_healthy = yes
					location = root.location
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 3
			OR = {
				AND = {
					has_activity_intent = woo_attendee_intent
					root.intent_target = {
						is_healthy = yes
						location = root.location
					}
				}
				has_activity_intent = increase_influence_intent
			}
		}
	}

	immediate = {
		involved_activity.activity_host = { save_scope_as = host }
		hidden_effect_new_object = {
			#Make a prostitute
			create_character = {
				location = scope:host.capital_province
				template = ep3_prostitute_character
				gender_female_chance = root_attraction_based_female_chance
				faith = scope:host.capital_county.faith
				culture = scope:host.capital_county.culture
				save_scope_as = prostitute
			}
			scope:prostitute = {
				random_list = {
					10 = {
						set_sexuality = bisexual
					}
					5 = {
						trigger = {
							OR = {
								AND = {
									is_female = yes
									root = { is_female = yes }
								}
								AND = {
									is_male = yes
									root = { is_male = yes }
								}
							}
						}
						set_sexuality = homosexual
					}
					10 = {
						trigger = {
							OR = {
								AND = {
									is_female = no
									root = { is_female = yes }
								}
								AND = {
									is_male = no
									root = { is_male = yes }
								}
							}
						}
						set_sexuality = heterosexual
					}
				}
			}
		}
		#Get the seduce intent target
		if = {
			limit = {
				has_activity_intent = woo_attendee_intent
				intent_target = {
					is_healthy = yes
					location = root.location
				}
			}
			intent_target = {
				save_scope_as = seduce_interest
			}
		}
		#Get an eager prostitute-sexer
		if = {
			limit = {
				has_activity_intent = increase_influence_intent
				scope:activity = {
					any_guest_subset = {
						name = spectators
						chariot_race_4030_john_trigger = yes
						OR = {
							has_trait = lustful
							has_trait = rakish
							has_trait = lifestyle_reveler
							has_trait = seducer
							has_trait = deviant
							has_trait = disloyal
						}
						might_cheat_on_every_partner_trigger = yes
					}
				}
			}
			scope:activity = {
				random_guest_subset = {
					name = spectators
					limit = {
						chariot_race_4030_john_trigger = yes
						OR = {
							has_trait = lustful
							has_trait = rakish
							has_trait = lifestyle_reveler
							has_trait = seducer
							has_trait = deviant
							has_trait = disloyal
						}
						might_cheat_on_every_partner_trigger = yes
					}
					save_scope_as = john
				}
			}
		}
		#Get a willing prostitute-sexer
		else_if = {
			limit = {
				has_activity_intent = increase_influence_intent
				scope:activity = {
					any_guest_subset = {
						name = spectators
						chariot_race_4030_john_trigger = yes
						OR = {
							might_cheat_on_every_partner_trigger = yes
							has_trait = rakish
						}
					}
				}
			}
			scope:activity = {
				random_guest_subset = {
					name = spectators
					limit = {
						chariot_race_4030_john_trigger = yes
						OR = {
							might_cheat_on_every_partner_trigger = yes
							has_trait = rakish
						}
					}
					save_scope_as = john
				}
			}
		}
		scope:john ?= {
			add_character_flag = {
				flag = chariot_race_john
				years = 1
			}
		}
	}

	#Influence option - I know who might enjoy that prostitute... and give me a juicy secret
	option = {
		name = chariot_race.4030.a
		flavor = chariot_race.4030.a.flavor
		trigger = {
			has_activity_intent = increase_influence_intent
			exists = scope:john
		}
		duel = {
			skill = intrigue
			target = scope:john
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -59
				}
				modifier = {
					factor = 2
					scope:john = {
						OR = {
							has_trait = rakish
							has_trait = lustful
						}
					}
				}
				modifier = {
					add = 20
					scope:john = {
						attraction <= 0
					}
				}
				modifier = {
					add = 20
					scope:john = {
						OR = {
							has_trait = deviant
							has_trait = seducer
							has_trait = lifestyle_reveler
							has_trait = disloyal
						}
					}
				}
				desc = chariot_race.4030.a.success
				send_interface_toast = {
					title = chariot_race.4030.a.success
					left_icon = root
					right_icon = scope:john

					#ADD STRONG FAVOR HOOK IF IT IS ILLEGAL ADULTERY/FORNICATION
					if = {
						limit = {
							scope:john = {
								OR = {
									AND = {
										faith = {
											has_doctrine = doctrine_adultery_women_crime
										}
										is_female = yes
									}
									AND = {
										faith = {
											has_doctrine = doctrine_adultery_men_crime
										}
										is_female = no
									}
								}
							}
							can_add_hook = {
								target = scope:john
								type = strong_prostitute_blackmail_hook
							}
						}
						change_influence = medium_influence_gain
						add_hook = {
							target = scope:john
							type = strong_prostitute_blackmail_hook
						}
					}
					#ADD WEAK IF IT IS LEGAL
					else_if = {
						limit = {
							can_add_hook = {
								target = scope:john
								type = weak_prostitute_blackmail_hook
							}
						}
						change_influence = minor_influence_gain
						add_hook = {
							target = scope:john
							type = weak_prostitute_blackmail_hook
						}
					}
					else = {
						change_influence = major_influence_gain
					}

					scope:prostitute = { save_scope_as = besexed }
					scope:john = {
						#To prevent errors firing when rakes sleep with prostitutes
						if = {
							limit = {
								has_trait = rakish
								might_cheat_on_every_partner_trigger = no
							}
							save_scope_as = ignore_cheating_error_check
						}
						had_sex_with_effect = {
							CHARACTER = scope:prostitute
							PREGNANCY_CHANCE = pregnancy_chance
						}
						trigger_event = chariot_race.4031
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -39
				}
				modifier = {
					add = 30
					scope:john = {
						highest_held_title_tier >= tier_kingdom
					}
				}
				modifier = {
					add = 20
					scope:john = {
						has_activity_intent = woo_attendee_intent
					}
				}
				desc = chariot_race.4030.a.failure
				send_interface_toast = {
					title = chariot_race.4030.a.failure
					left_icon = root
					right_icon = scope:john

					reverse_add_opinion = {
						modifier = disgusted_opinion
						target = scope:john
						opinion = -20
					}
					change_influence = minor_influence_loss
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			honest = major_stress_impact_gain
			just = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_honor = -1
				ai_greed = 1
			}
			modifier = {
				add = 50
				OR = {
					has_trait = ambitious
					has_trait = deceitful
				}
			}
			modifier = {
				add = 100
				intrigue >= high_skill_rating
				scope:john = { intrigue < mediocre_skill_rating }
			}
			modifier = {
				add = -100
				intrigue < decent_skill_rating
				scope:john = { intrigue < mediocre_skill_rating }
			}
			modifier = {
				add = -100
				NOT = {
					can_add_hook = {
						target = scope:john
						type = weak_prostitute_blackmail_hook
					}
				}
			}
			modifier = {
				add = -100
				intrigue < decent_skill_rating
				scope:john = { intrigue < mediocre_skill_rating }
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = honest
					has_trait = just
					has_trait = compassionate
					has_trait = forgiving
					intrigue < medium_skill_rating
					NOT = { prestige <= 0 }
				}
			}
		}
	}

	#Seduce option - try to fornicate with target
	option = {
		name = chariot_race.4030.b
		flavor = chariot_race.4030.b.flavor
		trigger = {
			has_activity_intent = woo_attendee_intent
			exists = scope:seduce_interest
			OR = {
				scope:seduce_interest = {
					is_consort_of = root
				}
				might_cheat_on_every_partner_trigger = yes
			}
		}
		duel = {
			skill = intrigue
			value = medium_skill_rating
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -59
				}
				modifier = {
					add = 30
					attraction >= 10
				}
				modifier = {
					add = 30
					attraction >= 20
				}
				modifier = {
					add = 30
					reverse_opinion = {
						target = scope:seduce_interest
						value > 50
					}
				}
				modifier = {
					add = 30
					reverse_opinion = {
						target = scope:seduce_interest
						value > 0
					}
				}
				modifier = {
					factor = 2
					scope:seduce_interest = {
						OR = {
							has_trait = seducer
							has_trait = lustful
						}
					}
				}
				modifier = {
					add = 30
					has_trait = seducer
				}
				modifier = {
					add = 20
					OR = {
						has_trait = lustful
						has_trait = lifestyle_poet
						has_trait = adventurer
						has_trait = rakish
						has_trait = lifestyle_reveler
					}
				}
				modifier = {
					add = 20
					highest_held_title_tier >= tier_kingdom
				}
				modifier = {
					factor = 2
					scope:seduce_interest.faith = {
						trait_is_virtue = lustful
					}
				}
				desc = chariot_race.4030.b.success
				send_interface_toast = {
					type = event_generic_good_text
					title = chariot_race.4030.b.success
					left_icon = root
					right_icon = scope:john

					complete_activity_intent = yes
					scope:seduce_interest = { save_scope_as = besexed }
					had_sex_with_effect = {
						CHARACTER = scope:seduce_interest
						PREGNANCY_CHANCE = pregnancy_chance
					}
					trigger_event = chariot_race.4031
					add_intrigue_lifestyle_xp = minor_lifestyle_xp
					stress_impact = {
						base = minor_stress_impact_loss
						lustful = minor_stress_impact_loss
						deviant = miniscule_stress_impact_loss
						lifestyle_reveler = minor_stress_impact_loss
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2
					min = -39
				}
				modifier = {
					add = 50
					scope:seduce_interest = {
						OR = {
							might_cheat_on_every_partner_trigger = no
							scope:seduce_interest = {
								is_consort_of = root
							}
						}
					}
				}
				modifier = {
					add = 75
					scope:seduce_interest = {
						NOT = { is_attracted_to_gender_of = root }
					}
				}
				modifier = {
					add = 30
					reverse_opinion = {
						target = scope:seduce_interest
						value < -50
					}
				}
				modifier = {
					add = 30
					reverse_opinion = {
						target = scope:seduce_interest
						value <= 0
					}
				}
				modifier = {
					add = 30
					scope:seduce_interest = {
						any_spouse = {
							highest_held_title_tier >= tier_empire
						}
					}
				}
				modifier = {
					add = 30
					scope:seduce_interest = {
						highest_held_title_tier >= tier_duchy
					}
				}
				desc = chariot_race.4030.b.failure
				send_interface_toast = {
					type = event_generic_bad_text
					title = chariot_race.4030.b.failure
					left_icon = root
					right_icon = scope:john

					reverse_add_opinion = {
						modifier = disgusted_opinion
						target = scope:seduce_interest
						opinion = -30
					}
					if = {
						limit = {
							NOT = {
								faith = {
									trait_is_virtue = lustful
								}
							}
							OR = {
								#adultery is a sin
								AND = {
									OR = {
										is_married = yes
										scope:seduce_interest = { is_married = yes }
									}
									OR = {
										AND = {
											OR = {
												is_female = yes
												scope:seduce_interest = {
													is_female = yes
												}

											}
											NOT = {
												faith = { has_doctrine = doctrine_adultery_women_accepted }
											}
										}
										AND = {
											OR = {
												is_female = no
												scope:seduce_interest = {
													is_female = no
												}
											}
											NOT = {
												faith = { has_doctrine = doctrine_adultery_men_accepted }
											}
										}
									}
								}
								#homosexuality is a sin
								AND = {
									OR = {
										AND = {
											is_female = yes
											scope:seduce_interest = {
												is_female = yes
											}
										}
										AND = {
											is_female = no
											scope:seduce_interest = {
												is_female =no
											}
										}
									}
									NOT = {
										faith = { has_doctrine = doctrine_homosexuality_accepted }
									}
								}
							}
						}
						add_piety = medium_piety_loss
					}
					stress_impact = {
						base = minor_stress_impact_gain
					}
				}
			}
		}
		stress_impact = {
			chaste = major_stress_impact_gain
			honest = miniscule_stress_impact_gain
			calm = miniscule_stress_impact_gain
			paranoid = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			just = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_boldness = 1
				ai_sociability = 0.5
				ai_honor = -0.5
			}
			modifier = {
				add = 50
				OR = {
					has_trait = lustful
					has_trait = deviant
					has_trait = lifestyle_reveler
				}
			}
			modifier = {
				add = 50
				OR = {
					has_trait = seducer
					has_trait = beauty_good_2
					has_trait = beauty_good_3
				}
			}
			modifier = {
				add = 50
				intrigue > high_skill_rating
			}
			modifier = {
				add = 50
				reverse_opinion = {
					target = scope:seduce_interest
					value > 50
				}
			}
			modifier = {
				add = 100
				scope:seduce_interest = {
					OR = {
						has_trait = seducer
						has_trait = lustful
					}
				}
			}
			modifier = {
				add = 100
				scope:seduce_interest.faith = {
					trait_is_virtue = lustful
				}
			}
			modifier = {
				add = -50
				OR = {
					has_trait = honest
					has_trait = calm
					has_trait = just
				}
			}
			modifier = {
				add = -50
				intrigue <= medium_skill_rating
			}
			modifier = {
				add = -50
				reverse_opinion = {
					target = scope:seduce_interest
					value <= 0
				}
			}
			modifier = {
				add = -50
				scope:seduce_interest = {
					might_cheat_on_every_partner_trigger = no
					scope:seduce_interest = {
						is_consort_of = root
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = chaste
					has_trait = paranoid
					has_trait = craven
					has_trait = shy
					intrigue <= low_skill_rating
					scope:seduce_interest = {
						NOT = { is_attracted_to_gender_of = root }
					}
				}
			}
		}
	}

	#Sex with a prostitute? Absolutely
	option = {
		trigger = {
			OR = {
				has_trait = rakish
				might_cheat_on_every_partner_trigger = yes
			}
		}
		name = chariot_race.4030.c
		flavor = chariot_race.4030.c.flavor

		#To prevent errors firing when rakes sleep with prostitutes
		if = {
			limit = {
				has_trait = rakish
				might_cheat_on_every_partner_trigger = no
			}
			save_scope_as = ignore_cheating_error_check
		}
		scope:prostitute = { save_scope_as = besexed }
		had_sex_with_effect = {
			CHARACTER = scope:prostitute
			PREGNANCY_CHANCE = pregnancy_chance
		}
		pay_short_term_gold = {
			target = scope:prostitute
			gold = minor_gold_value
		}
		random_list = {
			90 = {}
			5 = {
				modifier = {
					factor = 0
					learning > decent_skill_rating
				}
				add_trait = lovers_pox
				add_character_flag = lovers_pox_gained
			}
			5 = {
				modifier = {
					factor = 0
					intrigue > decent_skill_rating
				}
				modifier = {
					factor = 2
					intrigue <= low_skill_rating
				}
				add_trait = rakish
				add_character_flag = rakish_gained
			}
		}

		trigger_event = chariot_race.4031

		stress_impact = {
			base = minor_stress_impact_loss
			rakish = minor_stress_impact_loss
			deviant = miniscule_stress_impact_loss
			lifestyle_reveler = miniscule_stress_impact_loss
			chaste = major_stress_impact_gain
			just = miniscule_stress_impact_gain
			compassionate = miniscule_stress_impact_gain
			calm = miniscule_stress_impact_gain
			paranoid = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			temperate = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_sociability = 1
				ai_rationality = -1
			}
			modifier = {
				add = 25
				OR = {
					has_trait = lustful
					has_trait = rakish
					has_trait = deviant
					has_trait = lifestyle_reveler
				}
			}
			modifier = {
				add = -25
				OR = {
					has_trait = just
					has_trait = compassionate
					has_trait = calm
					has_trait = temperate
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = chaste
					has_trait = paranoid
					has_trait = craven
					NOT = { short_term_gold < medium_gold_value }
				}
			}
		}
	}

	#Yeah... I'm good
	option = {
		name = chariot_race.4030.d
		stress_impact = {
			chaste = minor_stress_impact_loss
			paranoid = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
			shy = miniscule_stress_impact_loss
			lustful = medium_stress_impact_gain
			fickle = miniscule_stress_impact_gain
			rakish = medium_stress_impact_gain
			seducer = miniscule_stress_impact_gain
			deviant = minor_stress_impact_gain
			lifestyle_reveler = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_rationality = 1
			}
			modifier = {
				add = 50
				OR = {
					has_trait = chaste
					has_trait = paranoid
					has_trait = shy
				}
			}
			modifier = {
				add = -50
				OR = {
					has_trait = seducer
					has_trait = fickle
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = lustful
					has_trait = rakish
					has_trait = deviant
					has_trait = lifestyle_reveler
				}
			}
		}
	}
	after = {
		if = {
			limit = {
				is_ai = yes
			}
			if = {
				limit = {
					highest_held_title_tier >= tier_kingdom
					exists = scope:besexed
					scope:prostitute = {
						this = scope:besexed
					}
				}
			}
			else = {
				scope:prostitute = {
					silent_disappearance_effect = yes
				}
			}
		}
	}
}

# You do sex
# by Jason Cantalini
chariot_race.4031 = {
	type = activity_event
	title = chariot_race.4031.t
	desc = {
		desc = chariot_race.4031.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:seduce_interest
					scope:besexed = {
						this = scope:seduce_interest
					}
				}
				desc = chariot_race.4031.desc_seduced
			}
			desc = chariot_race.4031.desc_prostitute
		}
	}
	theme = chariot_race
	override_background = {
		reference = ep2_hunt_falconry_mews
	}

	left_portrait = {
		character = root
		animation = personality_irrational
		camera = camera_event_right_pointing_left
	}
	center_portrait = {
		character = scope:besexed
		animation = reception_bride_right
		camera = camera_event_right
	}

	immediate = {
		add_character_flag = {
			flag = is_naked
			days = 30
		}
		scope:besexed = {
			add_character_flag = {
				flag = is_naked
				days = 30
			}
		}
		show_as_tooltip = {
			if = {
				limit = {
					scope:besexed = { this = scope:seduce_interest }
				}
				had_sex_with_effect = {
					CHARACTER = scope:seduce_interest
					PREGNANCY_CHANCE = pregnancy_chance
				}
				add_intrigue_lifestyle_xp = minor_lifestyle_xp
			}
			else = {
				had_sex_with_effect = {
					CHARACTER = scope:prostitute
					PREGNANCY_CHANCE = pregnancy_chance
				}
				pay_short_term_gold = {
					target = scope:prostitute
					gold = minor_gold_value
				}
				if = {
					limit = {
						has_character_flag = lovers_pox_gained
					}
					add_trait = lovers_pox
				}
				else_if = {
					limit = {
						has_character_flag = rakish_gained
					}
					add_trait = rakish
				}
			}
		}
	}

	#We're lovers now
	option = {
		name = chariot_race.4031.a
		flavor = chariot_race.4031.a.flavor
		trigger = {
			can_set_relation_lover_trigger = { CHARACTER = scope:besexed }
		}
		set_relation_lover = {
			target = scope:besexed
			reason = lover_chariot_races_rendezvous
		}
		#adds prostitute as courtier
		if = {
			limit = {
				scope:besexed = {
					this = scope:prostitute
				}
				OR = {
					is_landed = yes
					is_landless_ruler = yes
				}
			}
			add_courtier = scope:besexed
			pay_short_term_gold = {
				target = scope:prostitute
				gold = minor_gold_value
			}
		}
		stress_impact = {
			loyal = miniscule_stress_impact_loss
			lustful = miniscule_stress_impact_loss
			chaste = minor_stress_impact_gain
			fickle = minor_stress_impact_gain
			paranoid = miniscule_stress_impact_gain
			honest = minor_stress_impact_gain
		}
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_sociability = 0.5
			}
			modifier = {
				add = 50
				OR = {
					has_trait = loyal
					has_trait = lustful
				}
			}
			modifier = {
				add = -50
				has_trait = paranoid
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = honest
					has_trait = fickle
					has_trait = chaste
					AND = {
						NOT = { short_term_gold < medium_gold_value }
						scope:besexed = { this = scope:prostitute }
					}
				}
			}
		}
	}

	#Just the once is fine
	option = {
		name = chariot_race.4031.b
		flavor = chariot_race.4031.b.flavor

		stress_impact = {
			content = miniscule_stress_impact_loss
			callous = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			fickle = miniscule_stress_impact_loss
			compassionate = minor_stress_impact_gain
			loyal = minor_stress_impact_gain
			trusting = miniscule_stress_impact_gain
			generous = minor_stress_impact_gain
			stubborn = miniscule_stress_impact_gain
			lustful = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_sociability = -0.5
			}
			modifier = {
				add = 50
				OR = {
					has_trait = content
					has_trait = callous
					has_trait = sadistic
					has_trait = fickle
				}
			}
			modifier = {
				add = -50
				OR = {
					has_trait = lustful
					has_trait = stubborn
					has_trait = trusting
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = loyal
					has_trait = generous
				}
			}
		}
	}
	after = {
		if = {
			limit = {
				has_character_flag = lovers_pox_gained
			}
			remove_character_flag = lovers_pox_gained
		}
		if = {
			limit = {
				has_character_flag = rakish_gained
			}
			remove_character_flag = rakish_gained
		}
		if = {
			limit = {
				is_ai = yes
				scope:prostitute = {
					NOT = { is_courtier_of = root }
				}
			}
			scope:prostitute = {
				silent_disappearance_effect = yes
			}
		}
		if = {
			limit = { has_character_flag = is_naked }
			remove_character_flag = is_naked
		}
		scope:besexed = {
			if = {
				limit = {
					is_alive = yes
					has_character_flag = is_naked
				}
				remove_character_flag = is_naked
			}
		}
	}
}

scripted_trigger chariot_race_4040_noble_fan_trigger = {
	has_variable = wager_team
	OR = {
		AND = {
			var:wager_team = flag:blues
			root = { var:wager_team = flag:blues }
		}
		AND = {
			var:wager_team = flag:greens
			root = { var:wager_team = flag:greens }
		}
		AND = {
			var:wager_team = flag:reds
			root = { var:wager_team = flag:reds }
		}
		AND = {
			var:wager_team = flag:whites
			root = { var:wager_team = flag:whites }
		}
	}
	NOR = {
		this = scope:host
		this = root
	}
	is_adult = yes
	OR = {
		is_landless_administrative = yes
		is_governor = yes
		highest_held_title_tier >= tier_duchy
	}
}

scripted_trigger chariot_race_4040_biggest_fandom = {
	OR = {
		AND = {
			var:wager_team = flag:blues
			scope:activity = {
				var:characters_betting_blue > var:characters_betting_green
				var:characters_betting_blue > var:characters_betting_red
				var:characters_betting_blue > var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:greens
			scope:activity = {
				var:characters_betting_green > var:characters_betting_blue
				var:characters_betting_green > var:characters_betting_red
				var:characters_betting_green > var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:reds
			scope:activity = {
				var:characters_betting_red > var:characters_betting_green
				var:characters_betting_red > var:characters_betting_blue
				var:characters_betting_red > var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:whites
			scope:activity = {
				var:characters_betting_white > var:characters_betting_green
				var:characters_betting_white > var:characters_betting_red
				var:characters_betting_white > var:characters_betting_blue
			}
		}
	}
}

scripted_trigger chariot_race_4040_smallest_fandom = {
	OR = {
		AND = {
			var:wager_team = flag:blues
			scope:activity = {
				var:characters_betting_blue < var:characters_betting_green
				var:characters_betting_blue < var:characters_betting_red
				var:characters_betting_blue < var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:greens
			scope:activity = {
				var:characters_betting_green < var:characters_betting_blue
				var:characters_betting_green < var:characters_betting_red
				var:characters_betting_green < var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:reds
			scope:activity = {
				var:characters_betting_red < var:characters_betting_green
				var:characters_betting_red < var:characters_betting_blue
				var:characters_betting_red < var:characters_betting_white
			}
		}
		AND = {
			var:wager_team = flag:whites
			scope:activity = {
				var:characters_betting_white < var:characters_betting_green
				var:characters_betting_white < var:characters_betting_red
				var:characters_betting_white < var:characters_betting_blue
			}
		}
	}
}

# You're broing down with your fellow faction members
#By Jason Cantalini
chariot_race.4040 = {
	type = activity_event
	title = chariot_race.4040.t
	desc = chariot_race.4040.desc
	theme = chariot_race

	left_portrait = {
		character = root
		animation = toast_goblet
	}
	center_portrait = {
		character = scope:noble_fan
		animation = wedding_drunk
		camera = camera_event_left
	}
	right_portrait = {
		character = scope:common_fan
		animation = obsequious_bow
	}

	cooldown = { years = 1 }

	trigger = {
		is_adult = yes
		#needs to support a team
		has_variable = wager_team
		#Any noble attendee needs to support the same team as you
		scope:activity = {
			any_guest_subset = {
				name = spectators
				chariot_race_4040_noble_fan_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			this = scope:host
		}
	}

	immediate = {
		#Find a noble who supports the same team
		scope:activity = {
			random_guest_subset = {
				name = spectators
				limit = {
					chariot_race_4040_noble_fan_trigger = yes
				}
				save_scope_as = noble_fan
			}
		}
		#create a peasant
		create_character = {
			location = scope:host.capital_province
			template = ep3_common_fan_character
			gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
			faith = scope:host.capital_county.faith
			culture = scope:host.capital_county.culture
			save_scope_as = common_fan
		}
	}

	#Maybe you guys could help me get rid of someone...
	option = {
		name = chariot_race.4040.a
		flavor = chariot_race.4040.a.flavor
		trigger = {
			OR = {
				AND = {
					has_activity_intent = sow_discord_intent
					NOT = { has_character_flag = races_commoner_aiding_discord }
				}
				AND = {
					has_activity_intent = murder_attendee_intent
					NOT = { has_character_flag = races_commoner_aiding_murder }
					intent_target ?= {
						is_alive = yes
						#Can't support the same team as root
						trigger_if = {
							limit = {
								has_variable = wager_team
								root = { has_variable = wager_team }
							}
							NOR = {
								AND = {
									var:wager_team = flag:blues
									root = { var:wager_team = flag:blues }
								}
								AND = {
									var:wager_team = flag:greens
									root = { var:wager_team = flag:greens }
								}
								AND = {
									var:wager_team = flag:reds
									root = { var:wager_team = flag:reds }
								}
								AND = {
									var:wager_team = flag:whites
									root = { var:wager_team = flag:whites }
								}
							}
						}
					}
				}
			}
		}
		if = {
			limit = {
				has_activity_intent = murder_attendee_intent
			}
			custom_tooltip = chariot_race.4040.thugs_tt
			add_character_flag = {
				flag = races_commoner_aiding_murder
				years = 1
			}
			scope:common_fan = {
				add_character_flag = {
					flag = chariot_race_lackey
					years = 1
				}
			}
		}
		else = {
			custom_tooltip = chariot_race.4040.discord_tt
			add_character_flag = {
				flag = races_commoner_aiding_discord
				years = 1
			}
		}

		show_as_tooltip = {
			scope:common_fan = { add_to_court_and_entourage_only_effect = yes }
		}
		hidden_effect = {
			add_to_entourage_court_and_activity_effect = {
				CHAR_TO_ADD = scope:common_fan
				NEW_COURT_OWNER = root
			}
		}
		pay_short_term_gold = {
			target = scope:common_fan
			gold = minor_gold_value
		}
		stress_impact = {
			paranoid = minor_stress_impact_gain
			greedy = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_boldness = 1
				ai_compassion = -1
			}
			modifier = {
				add = -50
				has_trait = greedy
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = paranoid
					NOT = { short_term_gold < medium_gold_value }
				}
			}
		}
	}

	#My team members are always welcome in my capital...
	option = {
		name = chariot_race.4040.b
		flavor = chariot_race.4040.b.flavor
		trigger = {
			is_landed = yes
			exists = capital_county
			top_liege = scope:host
			this != scope:host
		}

		capital_county  = {
			add_county_modifier = {
				modifier = flourishing_local_deme_modifier
				years = 10
			}
		}

		stress_impact = {
			impatient = minor_stress_impact_gain
			lazy = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
			modifier = {
				add = -50
				has_trait = lazy
			}
			modifier = {
				factor = 0
				has_trait = impatient
			}
		}
	}

	#I want to hang with the masses and get recognized as a leader
	option = {
		name = chariot_race.4040.c
		flavor = chariot_race.4040.c.flavor
		trigger = {
			OR = {
				this = scope:host
				scope:host.primary_title = {
					any_title_heir = {
						this = root
					}
				}
			}
		}
		duel = {
			skills = { diplomacy martial }
			value = medium_skill_rating
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -59
				}
				modifier = {
					add = 40
					chariot_race_4040_smallest_fandom = yes
				}
				desc = chariot_race.4040.b.success
				send_interface_toast = {
					title = chariot_race.4040.b.success
					left_icon = root
					scope:activity = {
						add_activity_log_entry = {
							key = faction_rally_log
							score = 25
							tags = { positive }
							character = root

							#Effect
							root = {
								if = {
									limit = {
										this != scope:host
									}
									if = {
										limit = {
											chariot_race_4040_biggest_fandom = yes
										}
										scope:host.primary_title = {
											change_appointment_investment = {
												target = root
												value = major_influence_value
											}
										}
										add_prestige = minor_prestige_gain
									}
									else_if = {
										limit = {
											chariot_race_4040_smallest_fandom = yes
										}
										scope:host.primary_title = {
											change_appointment_investment = {
												target = root
												value = minor_influence_value
											}
										}
									}
									else = {
										scope:host.primary_title = {
											change_appointment_investment = {
												target = root
												value = medium_influence_value
											}
										}
										add_prestige = miniscule_prestige_gain
									}
								}
								else = {
									if = {
										limit = {
											chariot_race_4040_biggest_fandom = yes
										}
										add_legitimacy = medium_legitimacy_gain
										capital_county = {
											add_county_modifier = {
												modifier = powerful_loyal_deme_modifier
												years = 10
											}
										}
										if = {
											limit = { has_activity_intent = appease_populace_intent }
											complete_activity_intent = yes
										}
									}
									else_if = {
										limit = {
											chariot_race_4040_smallest_fandom = yes
										}
										add_legitimacy = miniscule_legitimacy_gain
									}
									else = {
										add_legitimacy = minor_legitimacy_gain
										capital_county = {
											add_county_modifier = {
												modifier = sizable_loyal_deme_modifier
												years = 10
											}
										}
									}
								}
							}
						}
						custom_tooltip = chariot_race.4040.team_popularity_rally_tt
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -39
				}
				modifier = {
					add = 40
					chariot_race_4040_biggest_fandom = yes
				}
				desc = chariot_race.4040.b.failure
				send_interface_toast = {
					title = chariot_race.4040.b.failure
					left_icon = root

					change_influence = minor_influence_loss
				}
			}
		}

		stress_impact = {
			shy = medium_stress_impact_gain
			arrogant = miniscule_stress_impact_gain
			content = medium_stress_impact_gain
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_sociability = 0.5
			}
			modifier = {
				add = 50
				chariot_race_4040_biggest_fandom = yes
			}
			modifier = {
				add = 50
				OR = {
					martial >= very_high_skill_rating
					diplomacy >= very_high_skill_rating
				}
			}
			modifier = {
				add = -50
				OR = {
					chariot_race_4040_smallest_fandom = yes
					has_trait = arrogant
				}
			}
			modifier = {
				add = -50
				NOR = {
					martial > medium_skill_rating
					diplomacy > medium_skill_rating
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = shy
					has_trait = content
					has_trait = craven
					NOR = {
						martial >= mediocre_skill_rating
						diplomacy >= mediocre_skill_rating
					}
				}
			}
		}
	}

	#I want to shmooze the bigshots for influence
	option = {
		name = chariot_race.4040.d

		#More influence if your team is popular with the nobility
		if = {
			limit = {
				chariot_race_4040_biggest_fandom = yes
			}
			change_influence = medium_influence_gain
		}
		else_if = {
			limit = {
				chariot_race_4040_smallest_fandom = yes
			}
			change_influence = miniscule_influence_gain
		}
		else = {
			change_influence = minor_influence_gain
		}
		custom_tooltip = chariot_race.4040.team_popularity_tt

		stress_impact = {
			humble = medium_stress_impact_gain
			gregarious = miniscule_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -0.5
				ai_sociability = -0.5
			}
			modifier = {
				add = 100
				chariot_race_4040_biggest_fandom = yes
			}
			modifier = {
				add = -50
				OR = {
					chariot_race_4040_smallest_fandom = yes
					has_trait = arrogant
				}
			}
			modifier = {
				add = -50
				has_trait = gregarious
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = trusting
				}
			}
		}
	}
	after = {
		if = {
			limit = {
				is_ai = yes
				scope:common_fan = {
					NOT = { has_character_flag = chariot_race_lackey }
				}
			}
			scope:common_fan = {
				silent_disappearance_effect = yes
			}
		}
	}
}

scripted_trigger chariot_race_4050_welcome_in_kathisma_trigger = {
	OR = {
		AND = {
			exists = scope:activity.special_guest:chariot_race_honorary_guest
			this = scope:activity.special_guest:chariot_race_honorary_guest
		}
		is_close_family_of = scope:host
		is_consort_of = scope:host
		highest_held_title_tier >= tier_duchy
		has_any_good_relationship_with_character_trigger = { CHARACTER = scope:host }
	}
}

# You throw a guy off the stands in order to murder him
#By Jason Cantalini
chariot_race.4050 = {
	type = activity_event
	title = chariot_race.4050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					religion_has_angels_trigger = no
				}
				desc = chariot_race.4050.desc.non_abrahamic
			}
			desc = chariot_race.4050.desc
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:victim = {
						chariot_race_0201_sitting_in_kathisma_trigger = yes
					}
				}
				desc = chariot_race.4050.desc.kathisma
			}
			desc = chariot_race.4050.desc.track
		}
		desc = chariot_race.4050.desc.outro
		triggered_desc = {
			trigger = {
				exists = scope:lackey
			}
			desc = chariot_race.4050.desc.lackey
		}
	}
	#different desc for emp
	theme = chariot_race

	left_portrait = {
		character = root
		animation = war_defender
	}
	right_portrait = {
		character = scope:victim
		animation = reception_groom_left
	}
	lower_right_portrait = scope:lackey

	cooldown = { years = 1 }

	trigger = {
		is_adult = yes
		has_activity_intent = murder_attendee_intent
		#Any noble attendee needs to support the same team as you
		scope:activity = {
			any_guest_subset = {
				name = spectators
				this = root.intent_target
			}
		}
	}

	immediate = {
		root.intent_target = { save_scope_as = victim }
		if = {
			limit = {
				any_courtier = {
					has_character_flag = chariot_race_lackey
				}
				has_character_flag = races_commoner_aiding_murder
			}
			random_courtier = {
				limit = {
					has_character_flag = chariot_race_lackey
				}
				save_scope_as = lackey
			}
		}
	}

	#I'll have someone throw them off the stands...
	option = {
		name = chariot_race.4050.a
		flavor = chariot_race.4050.a.flavor
		add_character_flag = agents_shove_target

		show_as_tooltip = {
			duel = {
				skill = intrigue
				target = scope:victim
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					chariot_race_4050_agents_positive_modifiers = yes

					desc = chariot_race.4050.a.success

					random_list = {
						30 = {
							modifier = {
								add = 25
								health <= poor_health
							}
							if = {
								limit = {
									scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
								}
								unknown_murder_effect = {
									VICTIM = scope:victim
									MURDERER = root
									REASON = death_thrown_off_kathisma
								}
							}
							else = {
								unknown_murder_effect = {
									VICTIM = scope:victim
									MURDERER = root
									REASON = death_thrown_onto_chariot_track
								}
							}
						}
						10 = {
							trigger = {
								NOT = { scope:victim = { has_trait = infirm } }
							}
							add_secret = {
								type = secret_murder_attempt
								target = scope:victim
							}
							scope:victim = {
								add_trait = infirm
								hidden_effect = {
									remove_from_activity = involved_activity
								}
							}
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					chariot_race_4050_agents_negative_modifiers = yes
					desc = chariot_race.4050.a.failure
					random_list = {
						33 = {
							attempted_murder_opinion_effect = {
								VICTIM = scope:victim
								MURDERER = root
							}
						}
						66 = {
							add_secret = {
								type = secret_murder_attempt
								target = scope:victim
							}
						}
					}
				}
			}
		}

		trigger_event = chariot_race.4051

		stress_impact = {
			compassionate = major_stress_impact_gain
			just = major_stress_impact_gain
			forgiving = major_stress_impact_gain
			honest = major_stress_impact_gain
			wrathful = medium_stress_impact_gain
			brave = medium_stress_impact_gain
			trusting = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_honor = -1
			}
			modifier = {
				add = 50
				OR = {
					intrigue >= high_skill_rating
					scope:victim = { intrigue < mediocre_skill_rating }
				}
			}
			modifier = {
				add = -50
				scope:victim = { employs_court_position = bodyguard_court_position }
				scope:victim = {
					any_court_position_holder = {
						type = bodyguard_court_position
						location = scope:victim.location
						aptitude = {
							court_position = bodyguard_court_position
							value >= 4
						}
					}
				}
			}
			modifier = {
				add = 40
				scope:victim = {
					age < 14
				}
			}
			modifier = {
				add = 30
				exists = scope:lackey
			}
			modifier = {
				add = -25
				scope:victim = { employs_court_position = bodyguard_court_position }
				scope:victim = {
					any_court_position_holder = {
						type = bodyguard_court_position
						location = scope:victim.location
						aptitude = {
							court_position = bodyguard_court_position
							value >= 2
						}
					}
				}
			}
			modifier = {
				add = -40
				scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
			}
			modifier = {
				add = -50
				OR = {
					intrigue <= medium_skill_rating
					scope:victim = { intrigue > decent_skill_rating }
				}
			}
			modifier = {
				add = -50
				OR = {
					has_trait = trusting
					has_trait = stubborn
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = just
					has_trait = forgiving
					has_trait = honest
					has_trait = wrathful
					has_trait = brave
				}
			}
		}
	}

	#I CAN ONLY TRUST MYSELF TO HURL THIS VICTIM TO THEIR DOOM
	option = {
		name = chariot_race.4050.b
		flavor = chariot_race.4050.b.flavor
		trigger = {
			is_healthy = yes
			is_adult = yes
			OR = {
				has_trait = sadistic
				has_trait = wrathful
				has_trait = vengeful
				has_trait = brave
				has_trait = impatient
				has_trait = stubborn
				has_trait = eccentric
			}
			OR = {
				NOT = { scope:victim = { this = scope:host } }
				chariot_race_4050_welcome_in_kathisma_trigger = yes
			}
		}

		show_as_tooltip = {
			if = {
				limit = {
					scope:victim = {
						OR = {
							top_liege ?= root
							liege ?= root
						}
					}
				}
				add_tyranny = major_tyranny_gain
			}
			duel = {
				skill = prowess
				target = scope:victim
				55 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -54
					}
					chariot_race_4050_self_positive_modifiers = yes

					desc = chariot_race.4050.b.success
					add_dread = major_dread_gain
					#Target is either killed or crippled
					random_list = {
						30 = {
							modifier = {
								add = 25
								health <= poor_health
							}
							known_murder_effect = {
								VICTIM = scope:victim
								MURDERER = root
								EXPOSER = root
							}
						}
						10 = {
							trigger = {
								NOT = { scope:victim = { has_trait = infirm } }
							}
							scope:victim = {
								add_trait = wounded_3
								hidden_effect = {
									remove_from_activity = involved_activity
								}
							}
							attempted_murder_opinion_effect = { VICTIM = scope:victim MURDERER = root }
						}
					}
				}
				45 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -44
					}
					chariot_race_4050_self_negative_modifiers = yes

					desc = chariot_race.4050.b.failure

					random_list = {
						60 = {
							attempted_murder_opinion_effect = {
								VICTIM = scope:victim
								MURDERER = root
							}
							if = {
								limit = {
									scope:victim = {
										chariot_race_0201_sitting_in_kathisma_trigger = yes
									}
									this != scope:host
								}
								rightfully_imprison_character_less_verbose_effect = {
									TARGET = root
									IMPRISONER = scope:host
								}
							}
						}
						20 = {
							modifier = {
								add = -10
								this = scope:host
							}
							death = {
								death_reason = death_killed_while_attempting_murder
								killer = scope:victim
							}
						}
					}
				}
			}
		}

		trigger_event = chariot_race.4051

		stress_impact = {
			craven = massive_stress_impact_gain
			compassionate = major_stress_impact_gain
			forgiving = major_stress_impact_gain
			patient = major_stress_impact_gain
			just = medium_stress_impact_gain
			calm = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			content = minor_stress_impact_gain
			deceitful = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 1
				ai_rationality = -1
				ai_energy = 1
			}
			modifier = {
				add = 50
				OR = {
					prowess >= high_skill_rating
					scope:victim = { prowess <= low_skill_rating }
				}
			}
			modifier = {
				add = 50
				scope:victim = {
					age < 14
				}
			}
			modifier = {
				add = 25
				scope:victim = {
					OR = {
						has_trait = infirm
						has_trait = incapable
					}
				}
			}
			modifier = {
				add = 50
				scope:victim = { intrigue >= high_skill_rating }
			}
			modifier = {
				add = -50
				scope:victim = { employs_court_position = bodyguard_court_position }
				scope:victim = {
					any_court_position_holder = {
						type = bodyguard_court_position
						location = scope:victim.location
						aptitude = {
							court_position = bodyguard_court_position
							value >= 4
						}
					}
				}
			}
			modifier = {
				add = -50
				OR = {
					prowess <= decent_skill_rating
					scope:victim = { prowess > decent_skill_rating }
				}
			}
			modifier = {
				add = -50
				OR = {
					intrigue >= decent_skill_rating
					scope:victim = { intrigue < mediocre_skill_rating }
				}
			}
			modifier = {
				add = -50
				OR = {
					has_trait = content
					has_trait = deceitful
					has_trait = humble
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = compassionate
					has_trait = forgiving
					has_trait = patient
					has_trait = calm
					has_trait = paranoid
					has_trait = just
				}
			}
		}
	}

	#These are terrible ideas...
	option = {
		name = chariot_race.4050.c

		stress_impact = {
			wrathful = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			callous = miniscule_stress_impact_gain
			sadistic = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			ambitious = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1
				ai_compassion = 1
			}
			modifier = {
				add = -25
				OR = {
					has_trait = callous
					has_trait = ambitious
				}
			}
			modifier = {
				add = -50
				OR = {
					has_trait = wrathful
					has_trait = vengeful
					has_trait = sadistic
					has_trait = stubborn
				}
			}
		}
	}
}

# You behold the ruin you have caused
#By Jason Cantalini
chariot_race.4051 = {
	type = activity_event
	title = chariot_race.4051.t
	desc = {
	#Whether you did it yourself and where
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
					has_character_flag = agents_shove_target
				}
				desc = chariot_race.4051.kathisma_attempt
			}
			triggered_desc = {
				trigger = {
					has_character_flag = agents_shove_target
				}
				desc = chariot_race.4051.stands_attempt
			}
			desc = chariot_race.4051.self_attempt
		}
		#The outcome
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_character_flag = agents_succeeded_death
						has_character_flag = agents_succeeded_infirm
						has_character_flag = self_succeeded_death
						has_character_flag = self_succeeded_infirm
					}
				}
				desc = chariot_race.4051.agents_success
			}
			triggered_desc = {
				trigger = {
					has_character_flag = agents_failed_secret
				}
				desc = chariot_race.4051.agents_fail_secret
			}
			triggered_desc = {
				trigger = {
					has_character_flag = agents_failed_snitch
				}
				desc = chariot_race.4051.agents_fail_snitch
			}
			triggered_desc = {
				trigger = {
					has_character_flag = self_failed_survive
					scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
					this != scope:host
				}
				desc = chariot_race.4051.self_failed_survive_kathisma
			}
			triggered_desc = {
				trigger = {
					has_character_flag = self_failed_survive
				}
				desc = chariot_race.4051.self_failed_survive
			}
			triggered_desc = {
				trigger = {
					has_character_flag = self_failed_death
				}
				desc = chariot_race.4051.self_failed_death
			}
		}
		#Whether victim is dead
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_character_flag = agents_succeeded_death
						has_character_flag = self_succeeded_death
					}
					scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
				}
				desc = chariot_race.4051.success_death_stands
			}
			triggered_desc = {
				trigger = {
					OR = {
						has_character_flag = agents_succeeded_death
						has_character_flag = self_succeeded_death
					}
				}
				desc = chariot_race.4051.success_death_track
			}
			triggered_desc = {
				trigger = {
					OR = {
						has_character_flag = agents_succeeded_infirm
						has_character_flag = self_succeeded_infirm
					}
					scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
				}
				desc = chariot_race.4051.success_infirm_stands
			}
			triggered_desc = {
				trigger = {
					OR = {
						has_character_flag = agents_succeeded_infirm
						has_character_flag = self_succeeded_infirm
					}
				}
				desc = chariot_race.4051.success_infirm_track
			}
		}
	}
	#Outcomes
	theme = chariot_race

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				#when root died in the attempt
				root = { has_character_flag = self_failed_death }
			}
			animation = dead
		}
		triggered_animation = {
			trigger = {
				has_character_flag = self_failed_survive
				scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
				this != scope:host
			}
			animation = prisonhouse
		}
		triggered_animation = {
			trigger = {
				has_character_flag = self_failed_survive
			}
			animation = war_attacker
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_character_flag = self_succeeded_death
					has_character_flag = self_succeeded_infirm
				}
			}
			animation = manic
		}
		triggered_animation = {
			trigger = {
				has_character_flag = agents_failed_snitch
			}
			animation = dismissal
		}
		triggered_animation = {
			trigger = {
				has_character_flag = agents_failed_secret
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				NOR = {
					has_character_flag = self_failed_survive
					has_character_flag = self_succeeded_death
					has_character_flag = self_succeeded_infirm
					has_character_flag = agents_failed_snitch
					has_character_flag = agents_failed_secret
					has_character_flag = self_failed_death
				}
			}
			animation = scheme
		}
	}
	right_portrait = {
		character = scope:victim
		triggered_animation = {
			trigger = {
				#when root died in the attempt
				root = { has_character_flag = self_failed_death }
			}
			animation = celebrate_dagger
		}
		triggered_animation = {
			trigger = {
				root = { has_character_flag = self_failed_survive }
				NOR = {
					scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
					this = scope:host
				}
			}
			animation = stayback
		}
		triggered_animation = {
			trigger = {
				root = {
					OR = {
						has_character_flag = self_succeeded_infirm
						has_character_flag = agents_succeeded_infirm
					}
				}
			}
			animation = sick_stomach
		}
		triggered_animation = {
			trigger = {
				root = {
					OR = {
						has_character_flag = self_succeeded_death
						has_character_flag = agents_succeeded_death
					}
				}
			}
			animation = dead
		}
		triggered_animation = {
			trigger = {
				root = {
					NOR = {
						has_character_flag = self_succeeded_infirm
						has_character_flag = agents_succeeded_infirm
						has_character_flag = self_failed_death
					}
				}
			}
			animation = rage
		}
	}

	immediate = {
		if = {
			limit = {
				has_character_flag = agents_shove_target
			}
			duel = {
				skill = intrigue
				target = scope:victim
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					chariot_race_4050_agents_positive_modifiers = yes

					desc = chariot_race.4050.a.success

					random_list = {
						30 = {
							modifier = {
								add = 25
								health <= poor_health
							}
							add_character_flag = agents_succeeded_death
						}
						10 = {
							trigger = {
								NOT = { scope:victim = { has_trait = infirm } }
							}
							add_character_flag = agents_succeeded_infirm
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					chariot_race_4050_agents_negative_modifiers = yes

					desc = chariot_race.4050.a.failure
					random_list = {
						33 = {
							add_character_flag = agents_failed_snitch
						}
						66 = {
							add_character_flag = agents_failed_secret
						}
					}
				}
			}
		}
		else = {
			if = {
				limit = {
					scope:victim = {
						OR = {
							top_liege ?= root
							liege ?= root
						}
					}
				}
				add_tyranny = major_tyranny_gain
			}

			duel = {
				skill = prowess
				target = scope:victim
				55 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -54
					}
					chariot_race_4050_self_positive_modifiers = yes

					desc = chariot_race.4050.b.success
					#Target is either killed or crippled
					random_list = {
						30 = {
							modifier = {
								add = 25
								health <= poor_health
							}
							add_character_flag = self_succeeded_death
						}
						10 = {
							trigger = {
								NOT = { scope:victim = { has_trait = infirm } }
							}
							add_character_flag = self_succeeded_infirm
						}
					}
				}
				45 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -44
					}
					chariot_race_4050_self_negative_modifiers = yes

					desc = chariot_race.4050.b.failure

					random_list = {
						60 = {
							add_character_flag = self_failed_survive
						}
						20 = {
							modifier = {
								add = -10
								this = scope:host
							}
							add_character_flag = self_failed_death
						}
					}
				}
			}
		}
	}

	option = {
		name = {
			trigger = {
				OR = {
					has_character_flag = agents_succeeded_infirm
					has_character_flag = self_succeeded_infirm
					has_character_flag = self_succeeded_death
					has_character_flag = agents_succeeded_death
				}
			}
			text = chariot_race.4051.a_triumph
		}
		name = {
			trigger = {
				NOR = {
					has_character_flag = agents_succeeded_infirm
					has_character_flag = self_succeeded_infirm
					has_character_flag = self_succeeded_death
					has_character_flag = agents_succeeded_death
				}
			}
			text = chariot_race.4051.a
		}

		if = {
			limit = {
				has_character_flag = agents_succeeded_death
			}
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_falls_off_stands_log
					score = 25
					tags = { negative }
					character = scope:victim
					#target is either killed or crippled
					root = {
						if = {
							limit = {
								scope:victim = { chariot_race_0201_sitting_in_kathisma_trigger = yes }
							}
							unknown_murder_effect = {
								VICTIM = scope:victim
								MURDERER = root
								REASON = death_thrown_off_kathisma
							}
						}
						else = {
							unknown_murder_effect = {
								VICTIM = scope:victim
								MURDERER = root
								REASON = death_thrown_onto_chariot_track
							}
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_character_flag = agents_succeeded_infirm
			}
			add_secret = {
				type = secret_murder_attempt
				target = scope:victim
			}
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_falls_off_stands_log
					score = 25
					tags = { negative }
					character = scope:victim

					scope:victim = {
						add_trait = infirm
						hidden_effect = {
							remove_from_activity = involved_activity
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_character_flag = agents_failed_secret
			}
			add_secret = {
				type = secret_murder_attempt
				target = scope:victim
			}
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_hurled_off_stands_fail_secret_log
					score = 25
					tags = { negative }
					character = scope:victim
				}
			}
		}
		else_if = {
			limit = {
				has_character_flag = agents_failed_snitch
			}
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_hurled_off_stands_fail_log
					score = 25
					tags = { negative }
					character = root
					target = scope:victim
					root = {
						attempted_murder_opinion_effect = {
							VICTIM = scope:victim
							MURDERER = root
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_character_flag = self_succeeded_death
			}
			add_dread = major_dread_gain
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_hurled_attendee_off_stands_log
					score = 25
					tags = { negative }
					character = root
					target = scope:victim
					root = {
						known_murder_effect = {
							VICTIM = scope:victim
							MURDERER = root
							EXPOSER = root
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_character_flag = self_succeeded_infirm
			}
			add_dread = major_dread_gain
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_hurled_attendee_off_stands_log
					score = 25
					tags = { negative }
					character = root
					target = scope:victim
					scope:victim = {
						add_trait = infirm
						hidden_effect = {
							remove_from_activity = involved_activity
						}
					}
					attempted_murder_opinion_effect = { VICTIM = scope:victim MURDERER = root }
				}
			}
		}
		else_if = {
			limit = {
				has_character_flag = self_failed_survive
			}
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_hurled_attendee_off_stands_fail_log
					score = 25
					tags = { negative }
					character = root
					target = scope:victim

					root = {
						attempted_murder_opinion_effect = {
							VICTIM = scope:victim
							MURDERER = root
						}
						if = {
							limit = {
								scope:victim = {
									chariot_race_0201_sitting_in_kathisma_trigger = yes
								}
								this != scope:host
							}
							rightfully_imprison_character_less_verbose_effect = {
								TARGET = root
								IMPRISONER = scope:host
							}
						}
					}
				}
			}
		}
		else = {
			scope:activity = {
				add_activity_log_entry = {
					key = attendee_hurled_attendee_off_stands_fail_log
					score = 25
					tags = { negative }
					character = root
					target = scope:victim
					root = {
						death = {
							death_reason = death_killed_while_attempting_murder
							killer = scope:victim
						}
					}
				}
			}
		}

		ai_chance = {
			base = 100
		}
	}
	after = {
		if = {
			limit = {
				has_character_flag = agents_shove_target
			}
			remove_character_flag = agents_shove_target
		}
		if = {
			limit = {
				has_character_flag = agents_succeeded_death
			}
			remove_character_flag = agents_succeeded_death
		}
		if = {
			limit = {
				has_character_flag = agents_succeeded_infirm
			}
			remove_character_flag = agents_succeeded_infirm
		}
		if = {
			limit = {
				has_character_flag = agents_failed_secret
			}
			remove_character_flag = agents_failed_secret
		}
		if = {
			limit = {
				has_character_flag = agents_failed_snitch
			}
			remove_character_flag = agents_failed_snitch
		}
		if = {
			limit = {
				has_character_flag = self_succeeded_death
			}
			remove_character_flag = self_succeeded_death
		}
		if = {
			limit = {
				has_character_flag = self_succeeded_infirm
			}
			remove_character_flag = self_succeeded_infirm
		}
		if = {
			limit = {
				has_character_flag = self_failed_survive
			}
			remove_character_flag = self_failed_survive
		}
		if = {
			limit = {
				has_character_flag = self_failed_death
			}
			remove_character_flag = self_failed_death
		}
	}
}
