﻿namespace = legend_spread_events
namespace = legend_debug

############################
## Legend Events
## 0001-1000
## by Veronica Pazos
############################

# legend_spread_events.0001 - Are you the true descendant of x?
# legend_spread_events.0010 - Did you really kill that monster?
# legend_spread_events.0020 - Someone in your court doubts you! Oh no!
# legend_spread_events.0030 - Grab a recent memory - add that to your legend
# legend_spread_events.0040 - Did you do this because of a begging peasant?
# legend_spread_events.0050 - Did you do this to honor a lady/lord?
# legend_spread_events.0060 - Rumours about a powerful vassal mocking your legend
# legend_spread_events.0070 - Someone arrives at your court impressed by your legend
# legend_spread_events.0080 - People are going on a pilgrimage to the location of your legend

##### DEBUG ######
legend_debug.0001 = {
	orphan = yes
	type = character_event
	theme = legend
	desc = legend_debug.0001.desc
	
	option = {
		create_legend_seed = {
			type = heroic
			quality = famed
			chronicle = debug_legend
			properties = {
				beast = flag:bear
				location = root.location
				ancestor = character:159835
				ancestor_flag = flag:ramses
				antagonist = flag:vercingetorix
				culture = root.culture
				title = title:k_england
				god = flag:germanic_high_god_name
				original_region = geographical_region:world_middle_east_jerusalem
			}
		}
	}
	
	option = {
		add_character_modifier = legend_spread_debug_modifier
	}
}

# Do you wanna send children to praise your legend?
legend_spread_events.0001 = {
	
	type = character_event
	title = legend_spread_events.0001.t
	desc = legend_spread_events.0001.desc
	theme = legend
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:chronicler
		animation = chancellor
	}
	lower_center_portrait = {
		character = scope:ancestor
	}
	lower_left_portrait = {
		trigger = {
			exists = scope:my_child
			primary_title.tier = tier_county
		}
		character = scope:my_child
	}
	cooldown = { years = 5 }
	override_background = { reference = study } 
	
	trigger = {
		is_available_adult = yes
		promoted_legend ?= {
			legend_owner = root
			exists = legend_property:ancestor
		}
		any_courtier = { #there's someone to tell you about this
			this != root
			is_available_ai_adult = yes
		}
	}
	
	immediate = {
		grab_appropriate_chronicler_effect = yes
		save_scope_as = root_scope #save scope for loc
		promoted_legend = {
			save_scope_as = legend
			legend_property:ancestor = { save_scope_as = ancestor }
		}
		if = {
			limit = {
				any_child = {
					is_alive = yes
					age <= 12
					NOT = { is_primary_heir_of = root }
				}
			}
			random_child = {
				limit = {
					is_alive = yes
					age <= 12
					NOT = { is_primary_heir_of = root }
				}
				save_scope_as = my_child
			}
		}
	}
	
	option = { #I am indeed
		name = legend_spread_events.0001.a
		duel = {
			skills = { diplomacy intrigue }
			value = high_skill_rating
			50 = { #you convince people
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = legend_spread_events.0001.a.tt.success
				send_interface_toast = {
					title = legend_spread_events.0001.a.tt.success
					left_icon = root
					promoted_legend = {
						change_legend_quality_effect = {
							VALUE = medium_legend_quality_increase
						}
					}
				}
			}
			# no one believes you
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = legend_spread_events.0001.a.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0001.a.tt.failure
					left_icon = root
					promoted_legend = {
						change_legend_quality_effect = {
							VALUE = medium_legend_quality_decrease
						}
					}
				}
			}
		}

		stress_impact = {
			content = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = content
					has_trait = humble
				}
			}
		}
	}
	
	option = { #Let's keep it down
		name = legend_spread_events.0001.b
		every_vassal = {
			custom = every_parochial_vassal
			add_opinion = {
				modifier = trust_opinion
				opinion = 20
				target = root
			}
		}
		stress_impact = {
			arrogant = major_stress_impact_gain
			deceitful = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = deceitful
					has_trait = ambitious
				}
			}
		}
	}
	
	option = { #Send your own child
		name = legend_spread_events.0001.c
		trigger = {
			exists = scope:my_child
			primary_title.tier = tier_county
		}
		promoted_legend = {
			change_legend_quality_effect = {
				VALUE = minor_legend_quality_increase
			}
		}
		every_vassal = {
			custom = every_parochial_vassal
			add_opinion = {
				modifier = trust_opinion
				opinion = 20
				target = root
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			content = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain #it's weird to have your child in the market
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = content
					has_trait = arrogant
				}
			}
		}
	}
	
	option = { #I am my own legend
		name = legend_spread_events.0001.d
		trigger = {
			has_trait = arrogant
		}
		add_character_modifier = {
			modifier = legend_my_own_ancestor_modifier
			years = 25
		}
		stress_impact = {
			humble = major_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = content
				}
			}
			modifier = {
				factor = 2
				has_trait = arrogant
			}
		}
	}
}

# Did you kill that monster?
legend_spread_events.0010 = {
	
	type = character_event
	title = legend_spread_events.0010.t
	desc = legend_spread_events.0010.desc
	theme = legend
	override_background = { reference = feast }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					has_trait = brave
					has_trait = strong
					has_trait = ambitious
				}
			}
			animation = hero_flex
		}
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:bard
		animation = instrument_active
	}
	cooldown = { years = 5 }
	
	trigger = {
		is_available_adult = yes
		promoted_legend ?= {
			legend_owner = root
			exists = legend_property:beast #any legend featuring a beast
			NOT = { has_variable = had_legends_0010 }
		}
		any_courtier = { #there's someone to tell you about this
			this != root
			is_available_ai_adult = yes
		}
	}
	
	immediate = {
		save_scope_as = root_scope #loc reasons
		promoted_legend = {
			set_variable = had_legends_0010
			save_scope_as = legend
		}
		grab_appropriate_bard_effect = yes
	}
	
	option = { #Actually... I killed a dragon
		name = legend_spread_events.0010.a
		trigger = {
			promoted_legend = {
				NOT = {
					legend_property:beast ?= flag:dragon
				}
			}
		}
		duel = {
			skills = { diplomacy prowess } #would people believe you _can_ kill a dragon?
			value = high_skill_rating
			40 = { #you convince people
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = lifestyle_hunter
					add = 5
				}
				modifier = {
					has_trait = deceitful
					add = 5
				}
				desc = legend_spread_events.0010.a.tt.success
				send_interface_toast = {
					title = legend_spread_events.0010.a.tt.success
					left_icon = root
					promoted_legend = {
						set_legend_property = { name = beast target = flag:dragon }
					}
					add_character_modifier = {
						modifier = legends_dragon_slayer
						years = 25
					}
					if = {
						limit = {
							is_ai = yes
						}
						random = {
							chance = 5
							give_nickname = nick_the_dragonslayer
						}
					}
					else = {
						random = {
							chance = 50
							give_nickname = nick_the_dragonslayer
						}
					}
					add_prestige = minor_prestige_gain
				}
			}
			# no one believes you
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					has_trait = craven
					add = 25
				}
				desc = legend_spread_events.0010.a.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0010.a.tt.failure
					left_icon = root
					add_prestige = major_prestige_loss
				}
			}
		}

		stress_impact = {
			honest = major_stress_impact_gain
			humble = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = honest
					has_trait = humble
				}
			}
			modifier = {
				factor = 2
				has_trait = arrogant
			}
		}
	}
	
	option = { #I did but it was a GIGANTIC one
		name = legend_spread_events.0010.b
		trigger = {
			promoted_legend = {
				NOT = {
					legend_property:beast ?= flag:huge_beast
				}
			}
		}
		duel = {
			skills = { diplomacy prowess } #would people believe you _can_ kill a dragon?
			value = medium_skill_rating
			50 = { #you convince people
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = lifestyle_hunter
					add = 25
				}
				modifier = {
					has_trait = strong
					add = 5
				}
				modifier = {
					has_trait = brave
					add = 5
				}
				desc = legend_spread_events.0010.b.tt.success
				send_interface_toast = {
					title = legend_spread_events.0010.b.tt.success
					left_icon = root
					promoted_legend = {
						set_legend_property = { name = beast target = flag:huge_beast } 
					}
					add_prestige = minor_prestige_gain
				}
			}
			# no one believes you
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					has_trait = craven
					add = 10
				}
				desc = legend_spread_events.0010.a.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0010.a.tt.failure
					left_icon = root
					add_prestige = medium_prestige_loss
				}
			}
		}
		
		stress_impact = {
			humble = medium_stress_impact_gain
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = honest
				}
			}
		}
	}
	
	option = { #Let's keep it down
		name = legend_spread_events.0010.c
		every_vassal = {
			custom = every_parochial_vassal
			add_opinion = {
				modifier = trust_opinion
				opinion = 20
				target = root
			}
		}
		stress_impact = {
			arrogant = major_stress_impact_gain
			deceitful = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = deceitful
					has_trait = ambitious
				}
			}
		}
	}
}

# Someone in your court doubts you
legend_spread_events.0020 = {
	
	type = character_event
	title = legend_spread_events.0020.t
	desc = {
		desc = legend_spread_events.0020.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					promoted_legend.legend_protagonist = root
				}
				desc = legend_spread_events.0020.desc.you_protag
			}
			desc = legend_spread_events.0020.desc.other_protag
		}
		desc = legend_spread_events.0020.desc.outro
	}
	theme = legend
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					has_trait = wrathful
				}
			}
			animation = anger
		}
		animation = eavesdrop
	}
	right_portrait = {
		character = scope:courtier
		animation = scheme
	}
	cooldown = { years = 5 }
	
	trigger = {
		is_available = yes
		is_landed = yes
		promoted_legend ?= {
			legend_owner = root
		}
		any_courtier = { #there's someone gossipping
			is_standard_legend_spreading_courtier = yes
		}
	}
	
	immediate = {
		promoted_legend = {
			legend_protagonist = { save_scope_as = protagonist }
		}
		random_courtier = {
			limit = {
				is_standard_legend_spreading_courtier = yes
			}
			save_scope_as = courtier
		}
	}
	
	option = { #Punish them
		name = legend_spread_events.0020.a
		trigger = {
			OR = {
				has_trait = arrogant
				has_trait = wrathful
				has_trait = callous
				has_trait = sadistic
			}
		}
		add_dread = major_dread_gain		
		rightfully_imprison_character_less_verbose_effect = { 
			TARGET = scope:courtier 
			IMPRISONER = root
		}
		every_courtier_or_guest = {
			custom = all_courtiers_and_guests
			add_opinion = {
				opinion = -10
				target = root
				modifier = cruelty_opinion
			}
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			calm = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = calm
				}
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = wrathful
					has_trait = sadistic
				}
			}
		}
	}
	
	option = { #Call them out
		name = legend_spread_events.0020.b
		duel = {
			skill = diplomacy
			target = scope:courtier
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = legend_spread_events.0020.b.tt.success
				send_interface_toast = {
					title = legend_spread_events.0020.b.tt.success
					left_icon = scope:courtier
					add_character_modifier = {
						modifier = legend_put_out_rumors_modifier
						years = 5
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = legend_spread_events.0020.b.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0020.b.tt.failure
					left_icon = scope:courtier
					scope:courtier = {
						add_opinion = {
							opinion = -30
							target = root
							modifier = dismissive_opinion
						}
					}
				}
			}
		}
		
		stress_impact = {
			humble = medium_stress_impact_gain
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = honest
				}
			}
		}
	}
	
	option = { #Ignore them
		name = legend_spread_events.0020.c
		add_character_modifier = {
			modifier = legend_sus_rumors_modifier
			years = 2
		}
		stress_impact = {
			base = medium_stress_impact_loss
			arrogant = medium_stress_impact_gain
			wrathful = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = wrathful
					has_trait = callous
					has_trait = sadistic
				}
			}
		}
	}
}

# Do you wanna add this recent memory to your chronicle?

scripted_trigger is_legend_worthy_memory = {
	has_memory_category = positive 
	OR = {
		has_memory_category = war
		has_memory_category = travel
		has_memory_category = martial
		has_memory_category = battle
		has_memory_category = tournament
		has_memory_category = nemesis
	}
}

legend_spread_events.0030 = {
	
	type = character_event
	title = legend_spread_events.0030.t
	desc = {
		desc = legend_spread_events.0030.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					promoted_legend.legend_protagonist = root
				}
				desc = legend_spread_events.0030.desc.you_protag
			}
			desc = legend_spread_events.0030.desc.other_protag
		}
	}
	theme = legend
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:chronicler
		animation = page_flipping
	}
	cooldown = { years = 5 }
	
	trigger = {
		is_available = yes
		promoted_legend ?= {
			legend_owner = root
			has_legend_chapter = {
				name = extra_deed
			}
			NOT = { has_variable = had_legends_0030 }
		}
		any_memory = {
			is_legend_worthy_memory = yes
		}
		any_courtier = { #chronicler backup
			this != root
			is_available_ai_adult = yes
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			any_memory = {
				is_legend_worthy_memory = yes
			}
		}
	}
	
	immediate = {
		grab_appropriate_chronicler_effect = yes
		promoted_legend = {
			set_variable = {
				name = had_legends_0030
				years = 10
			}
			legend_protagonist = { save_scope_as = protagonist }
		}
		random_memory = {
			limit = { is_legend_worthy_memory = yes }
			weight = {
				base = 1
				modifier = {
					add = 10
					has_memory_category = major
				}
				modifier = {
					add = 2
					has_memory_category = battle
				}
				modifier = {
					add = 2
					has_memory_category = war
				}
				modifier = {
					add = 1
					has_memory_category = martial
				}
			}
			save_scope_as = legend_memory
		}
	}
	
	option = { #I already told you my legend once, didn't I?
		name = legend_spread_events.0030.a
		flavor = legend_spread_events.0030.a.flavor
		trigger = {
			OR = {
				has_trait = stubborn
				has_trait = lazy
			}
		}
		add_character_modifier = {
			modifier = legend_lazy_modifier
			years = 5
		}
		stress_impact = {
			lazy = major_stress_impact_loss
			stubborn = major_stress_impact_loss
			calm = medium_stress_impact_gain
			ambitious = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = ambitious
					has_trait = calm
				}
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = lazy
					has_trait = stubborn
				}
			}
		}
	}
	
	option = { #Sure, replace it
		name = legend_spread_events.0030.b
		duel = {
			skill = diplomacy
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = legend_spread_events.0030.b.tt.success
				send_interface_toast = {
					title = legend_spread_events.0030.b.tt.success
					left_icon = root
					promoted_legend = {
						if = {
							limit = {
								NOT = {
									exists = var:extra_deed_memory
								}
							}
							set_variable = {
								name = extra_deed_memory
								value = scope:legend_memory
							}
						}
						set_legend_chapter = { name = extra_deed localization_key = legend_chapter_extra_deed_memory }
					}
					if = {
						limit = { #people remember you actually did this
							promoted_legend.legend_protagonist = root
						}
						add_character_modifier = {
							modifier = legend_memory_deed_modifier
							years = 5
						}
					}
					else = {
						add_prestige = minor_prestige_gain
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = legend_spread_events.0030.b.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0030.b.tt.failure
					left_icon = root
					add_prestige = medium_prestige_loss
				}
			}
		}
		
		stress_impact = {
			lazy = medium_stress_impact_gain
			stubborn = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = stubborn
				}
			}
		}
	}
	
	option = { #Leave it as it is
		name = legend_spread_events.0030.c
		every_courtier_or_guest = {
			limit = {
				OR = { 
					has_trait = humble
					has_trait = content
				}
			}
			custom = humble_content_courtiers_and_guests
			add_opinion = {
				opinion = 20
				target = root
				modifier = pleased_opinion
			}
		}
		stress_impact = {
			humble = medium_stress_impact_loss
			content = medium_stress_impact_loss
			shy = major_stress_impact_loss
			arrogant = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = content
					has_trait = shy
				}
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = arrogant
					has_trait = ambitious
				}
			}
		}
	}
}

# Did you do this because a peasant begged you to?
legend_spread_events.0040 = {
	
	type = character_event
	title = legend_spread_events.0040.t
	desc = {
		desc = legend_spread_events.0040.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					promoted_legend.legend_protagonist = root
				}
				desc = legend_spread_events.0040.desc.you_protag
			}
			desc = legend_spread_events.0040.desc.other_protag
		}
		desc = legend_spread_events.0040.desc.outro
	}
	theme = legend
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			animation = dismissal
		}
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:chronicler
		animation = page_flipping
	}
	lower_center_portrait = {
		trigger = {
			exists = scope:chaplain
			scope:chaplain != scope:chronicler
		}
		character = scope:chaplain
	}
	cooldown = { years = 5 }
	
	trigger = {		
		is_available = yes
		promoted_legend ?= {
			legend_owner = root
			OR = {
				legend_type = legend_type:heroic
				legend_type = legend_type:holy
			}
			has_legend_chapter = motivation
			NOT = {
				has_legend_chapter = {
					name = motivation 
					localization_key = legend_chapter_motivation_peasant
				}
			}
			NOT = { has_variable = had_legends_0040 }
		}
		any_courtier = { #chronicler backup
			this != root
			is_available_ai_adult = yes
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			promoted_legend ?= {
				legend_owner = root
				legend_type = legend_type:holy
			}
		}
	}
	
	immediate = {
		grab_appropriate_chronicler_effect = yes
		promoted_legend = {
			set_variable = had_legends_0040
			legend_protagonist = { save_scope_as = protagonist }
		}
		save_scope_as = root_scope
		cp:councillor_court_chaplain ?= { save_scope_as = chaplain }
	}
	
	option = { #I would _never_ let a peasant tell me what to do
		name = legend_spread_events.0040.a
		trigger = {
			OR = {
				has_trait = callous
				has_trait = sadistic
			}
		}
		promoted_legend = {
			set_legend_chapter = { name = motivation localization_key = legend_chapter_motivation_evil }
		}
		stress_impact = {
			callous = major_stress_impact_loss
			sadistic = major_stress_impact_loss
			calm = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = compassionate
				}
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
		}
	}
	
	option = { #I sure did!
		name = legend_spread_events.0040.b
		duel = {
			skill = diplomacy
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = legend_spread_events.0040.b.tt.success
				send_interface_toast = {
					title = legend_spread_events.0040.b.tt.success
					left_icon = root
					promoted_legend = {
						set_legend_chapter = { name = motivation localization_key = legend_chapter_motivation_peasant }
					}
					add_piety = medium_piety_gain
					every_vassal_or_below = {
						vassal_stance = courtly
						custom = every_courtly_vassal
						add_opinion = {
							target = root
							opinion = -10
							modifier = disappointed_opinion
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = legend_spread_events.0040.b.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0040.b.tt.failure
					left_icon = root
					if = {
						limit = {
							exists = cp:councillor_court_chaplain
						}
						cp:councillor_court_chaplain = {
							add_opinion = {
								target = root
								opinion = -10
								modifier = impious_opinion
							}
						}
					}
					else_if = { 
						limit = { promoted_legend.legend_type = legend_type:holy }
						add_piety = medium_piety_loss
					}
					else = { add_piety = minor_piety_loss }
				}
			} 
		}
		
		stress_impact = {
			compassionate = major_stress_impact_loss
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				promoted_legend.legend_type = legend_type:holy
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = compassionate
					has_trait = zealous
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
		}
	}
	
	option = { #Leave it as it is
		name = legend_spread_events.0040.c
		if = {
			limit = {
				promoted_legend.legend_type = legend_type:holy
			}
			add_piety = minor_piety_loss
		}
		else = {
			add_piety = miniscule_piety_loss
		}
		stress_impact = {
			zealous = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = zealous
					has_trait = compassionate
				}
			}
		}
	}
}
	
# Did you do this to honor a fair lady/lord?
scripted_trigger 0050_valid_courtier = {
	is_available_ai_adult = yes
	is_close_family_or_spouse_of_root_trigger = no
	is_attracted_to_gender_of = root
	root = { is_attracted_to_gender_of = prev }
}

legend_spread_events.0050 = {
	type = character_event
	title = legend_spread_events.0050.t
	desc = legend_spread_events.0050.desc
	theme = legend
	override_background = { reference = garden }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = rakish
					has_trait = lustful
					has_trait = seducer
					has_trait = deviant
				}
			}
			animation = flirtation_left
		}
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = dismissal
		}
		animation = laugh
	}
	right_portrait = {
		character = scope:bard
		animation = instrument_active
	}
	lower_left_portrait = {
		trigger = { exists = scope:my_spouse }
		character = scope:my_spouse 
	}
	lower_right_portrait = scope:honored_lady
	cooldown = { years = 5 }
	
	trigger = {
		is_available_adult = yes
		promoted_legend ?= {
			legend_owner = root
			NOT = { has_variable = had_legends_0050 }
			NOR = {
				has_legend_chapter = {
					name = motivation 
					localization_key = legend_chapter_motivation_spouse
				}
				has_legend_chapter = {
					name = motivation 
					localization_key = legend_chapter_motivation_honor_lady
				}
			}
			has_legend_chapter = motivation
			legend_protagonist = root
		}
		any_courtier_or_guest = { #we have a lady
			0050_valid_courtier = yes
			count >= 2 #to make sure we also have a bard
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			OR = {
				is_married = yes
				has_trait = lustful
				has_trait = seducer
				has_trait = rakish
			}
		}
	}
	
	immediate = {
		grab_appropriate_bard_effect = yes
		promoted_legend = {
			set_variable = had_legends_0050
		}
		if = {
			limit = { is_married = yes }
			random_spouse = {
				weight = {
					base = 1
					modifier = {
						add = 5
						has_relation_soulmate = root
					}
					modifier = {
						add = 3
						primary_spouse = this
					}
					modifier = {
						add = 1
						has_relation_lover = root
					}
				}
				save_scope_as = my_spouse
			}
		}
		random_courtier_or_guest = {
			limit = { 
				0050_valid_courtier = yes
				this != scope:bard
			}
			weight = {
				base = 1
				modifier = {
					add = 20
					has_relation_soulmate = root
				}
				modifier = {
					add = 10
					has_relation_lover = root
				}
				modifier = {
					add = 5
					is_married = no
					age >= root.age_minus_10
					age <= root.age_plus_10
				}
			}
			save_scope_as = honored_lady
		}
	}
	
	option = { #Of course! To honor my spouse!
		name = legend_spread_events.0050.a
		trigger = {
			is_married = yes
		}
		promoted_legend = {
			set_legend_chapter = { 
				name = motivation 
				localization_key = legend_chapter_motivation_spouse 
			}
		}
		if = {
			limit = {
				can_set_relation_soulmate_trigger = { CHARACTER = scope:my_spouse }
				scope:my_spouse = { #do they like you
					opinion = {
						target = root
						value >= 50
					}
				}
			}
			set_relation_soulmate = {
				reason = soulmate_legend_motivation
				copy_reason = lover
				target = scope:my_spouse
			}
		}
		else = {
			progress_towards_lover_effect = {
				CHARACTER = scope:my_spouse
				REASON = soulmate_legend_motivation
				OPINION = default_lover_opinion
			}
		}
		stress_impact = {
			rakish = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = rakish
			}
			modifier = {
				factor = 0
				might_cheat_on_every_partner_trigger = no
			}
		}
	}
	
	option = { #That fair woman/man...
		name = legend_spread_events.0050.b
		duel = {
			skill = intrigue
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = seducer
					add = 10
				}
				modifier = {
					scope:honored_lady = {
						has_trait = lustful
					}
					add = 5
				}
				desc = legend_spread_events.0050.b.tt.success
				send_interface_toast = {
					title = legend_spread_events.0050.b.tt.success
					left_icon = scope:honored_lady
					promoted_legend = {
						set_legend_chapter = { name = motivation localization_key = legend_chapter_motivation_honor_lady }
					}
					if = {
						limit = { has_focus_or_focus_trait_trigger = { FOCUS = intrigue_temptation_focus } }
						add_intrigue_lifestyle_xp = major_lifestyle_xp
					}
					else = {
						add_intrigue_lifestyle_xp = medium_lifestyle_xp
					}
					progress_towards_lover_effect = {
						CHARACTER = scope:honored_lady
						REASON = soulmate_legend_motivation
						OPINION = default_lover_opinion
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					scope:honored_lady = {
						OR = {
							has_trait = chaste
							has_trait = celibate
						}
					}
					add = 10
				}
				desc = legend_spread_events.0050.b.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0050.b.tt.failure
					left_icon = scope:honored_lady

					reverse_add_opinion = {
						modifier = insulted_opinion
						target = scope:honored_lady
						opinion = -10
					}
				}
			} 
		}
		scope:my_spouse ?= {
			add_opinion = {
				target = root
				modifier = disrespect_opinion
				opinion = -25
			}
		}
		stress_impact = {
			seducer = major_stress_impact_loss
			lustful = medium_stress_impact_loss
			honest = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = honest
					has_trait = compassionate
					trigger_if = {
						limit = { exists = scope:my_spouse }
						NOT = {
							might_cheat_on_partner_trigger = { PARTNER = scope:my_spouse }
						}
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = lustful
					has_trait = seducer
				}
			}
		}
	}
	
	option = { #Leave it as it is
		name = legend_spread_events.0050.c
		add_prestige = minor_prestige_gain
		scope:my_spouse ?= {
			add_opinion = {
				modifier = pleased_opinion
				opinion = 5
				target = root
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
			lustful = major_stress_impact_gain
			seducer = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lustful
					has_trait = seducer
				}
			}
		}
	}
}

#Rumors about a powerful vassal mocking you
legend_spread_events.0060 = {
	
	type = character_event
	title = legend_spread_events.0060.t
	desc = {
		desc = legend_spread_events.0060.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					promoted_legend.legend_protagonist = root
				}
				desc = legend_spread_events.0060.desc.you_protag
			}
			desc = legend_spread_events.0060.desc.other_protag
		}
		desc = legend_spread_events.0060.desc.outro
	}
	theme = legend
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = wrathful
					has_trait = arrogant
					has_trait = deceitful
					has_trait = stubborn
				}
			}
			animation = anger
		}
		animation = dismissal
	}
	right_portrait = {
		character = scope:courtier
		animation = worry
	}
	lower_center_portrait = scope:bad_vassal
	cooldown = { years = 5 }
	
	trigger = {
		is_available_adult = yes
		promoted_legend ?= {
			legend_owner = root
		}
		any_courtier_or_guest = {
			is_standard_legend_spreading_courtier = yes
		}
		any_powerful_vassal = {
			is_available_ai_adult = yes
			opinion = {
				target = root
				value <= -20
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_powerful_vassal = {
				is_available_ai_adult = yes
				opinion = {
					target = root
					value <= -75
				}
			}
		}
	}
	
	immediate = {
		random_courtier_or_guest = {
			limit = { is_standard_legend_spreading_courtier = yes }
			weight = {
				base = 1
				modifier = {
					add = 2
					has_any_good_relationship_with_root_trigger = yes
				}
			}
			save_scope_as = courtier
		}
		random_powerful_vassal = {
			limit = {
				is_available_ai_adult = yes
				opinion = {
					target = root
					value <= -20
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					has_relation_nemesis = root
				}
				modifier = {
					add = 5
					has_relation_rival = root
				}
				modifier = {
					add = 2
					opinion = {
						target = root
						value <= -50
					}
				}
			}
			save_scope_as = bad_vassal
		}
	}
	
	option = { #Seethe
		name = legend_spread_events.0060.a
		progress_towards_rival_effect = {
			CHARACTER = scope:bad_vassal
			REASON = rival_mocked_legend
			OPINION = -20
		}
		stress_impact = {
			base = medium_stress_impact_loss
			wrathful = massive_stress_impact_loss
			calm = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = wrathful
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = forgiving
				}
			}
		}
	}
	
	option = { #Try to put out the rumors
		name = legend_spread_events.0060.b
		duel = {
			skills = { diplomacy intrigue }
			target = scope:bad_vassal
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = legend_spread_events.0060.b.tt.success
				send_interface_toast = {
					title = legend_spread_events.0060.b.tt.success
					left_icon = scope:bad_vassal
					add_character_modifier = {
						modifier = legend_no_mocking_modifier
						years = 5
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = legend_spread_events.0060.b.tt.failure
				send_interface_toast = {
					title = legend_spread_events.0060.b.tt.failure
					left_icon = scope:bad_vassal
					add_character_modifier = {
						modifier = legend_extra_mocking_modifier
						years = 5
					}
				}
			} 
		}
		stress_impact = {
			wrathful = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = wrathful
					has_trait = arrogant
				}
			}
		}
	}
	
	option = { #Turn it back on them
		name = legend_spread_events.0060.c
		trigger = {
			intrigue >= high_skill_rating
		}
		scope:bad_vassal = {
			add_character_modifier = {
				modifier = not_believable_modifier
				years = 10
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			deceitful = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = deceitful
				}
			}
		}
	}
	
	option = { #Didn't hear anything
		name = legend_spread_events.0060.d
		
		stress_impact = {
			base = minor_stress_impact_loss
			calm = medium_stress_impact_loss
			forgiving = medium_stress_impact_loss
			wrathful = major_stress_impact_gain
			arrogant = major_stress_impact_gain
			vengeful = major_stress_impact_gain
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				OR = {
					has_trait = calm
					has_trait = forgiving
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = wrathful
					has_trait = arrogant
					has_trait = callous
					has_trait = vengeful
				}
			}
		}
	}
}


#Someone sings your legend at a party - doubts
#Start of event chain

scripted_effect trigger_appropriate_breakdown_effect = {
	if = {
		limit = {
			promoted_legend.legend_type = legend_type:holy
		}
		trigger_event = { 
			id = legend_spread_events.0072
			days = { 10 20 }
		}
	}
	else_if = {
		limit = {
			promoted_legend.legend_type = legend_type:heroic
		}
		trigger_event = { 
			id = legend_spread_events.0073
			days = { 10 20 }
		}
	}
	else = { #Legitimizing
		trigger_event = { 
			id = legend_spread_events.0074
			days = { 10 20 }
		}
	}
}

legend_spread_events.0070 = {
	type = character_event
	title = legend_spread_events.0070.t
	desc = legend_spread_events.0070.desc
	theme = legend
	override_background = { reference = feast }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					has_trait = callous
					has_trait = ambitious
				}
			}
			animation = personality_honorable
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = humble
					has_trait = depressed_genetic
					has_trait = depressed_1
				}
			}
			animation = grief
		}
		animation = worry
	}
	right_portrait = {
		character = scope:bard
		animation = instrument_active
	}
	cooldown = { years = 25 }
	
	trigger = {
		is_available_adult = yes
		promoted_legend ?= {
			legend_owner = root
		}
		any_courtier_or_guest = {
			is_standard_legend_spreading_courtier = yes
		}
	}
	
	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		grab_appropriate_bard_effect = yes
	}
	
	option = { #I am the very best like no one ever was
		name = legend_spread_events.0070.a
		trigger = {
			OR = {
				has_trait = arrogant
				has_trait = callous
				has_trait = ambitious
			}
		}
		set_variable = legend_chain_arrogant_var
		custom_tooltip = legend_spread_events.0070.a.tt
		add_prestige = minor_prestige_gain
		trigger_event = { 
			id = legend_spread_events.0071
			days = { 10 20 }
		}
		
		stress_impact = {
			base = medium_stress_impact_loss
			depressed_1 = major_stress_impact_gain
			depressed_genetic = major_stress_impact_gain
			humble = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				OR = {
					has_trait = arrogant
					has_trait = ambitious
					has_trait = callous
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = depressed_1
					has_trait = depressed_genetic
					has_trait = humble
				}
			}
		}
	}
	
	option = { #I'm having a mental breakdown help
		name = legend_spread_events.0070.b
		trigger = {
			NOR = {
				has_trait = humble
				has_trait = depressed_genetic
				has_trait = depressed_1
			}
		}
		trigger_appropriate_breakdown_effect = yes
		custom_tooltip = legend_spread_events.0070.a.tt
		add_piety = minor_piety_gain
		
		stress_impact = {
			arrogant = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = ambitious
					has_trait = callous
				}
			}
		}
	}
	
	option = { #Im having a _really_ bad mental breakdown help 
		name = legend_spread_events.0070.c
		trigger = {
			OR = {
				has_trait = humble
				has_trait = depressed_genetic
				has_trait = depressed_1
			}
		}
		custom_tooltip = legend_spread_events.0070.a.tt
		set_variable = legend_chain_depressed_var
		trigger_appropriate_breakdown_effect = yes
		
		stress_impact = {
			base = medium_stress_impact_loss
			arrogant = major_stress_impact_gain
			ambitious = major_stress_impact_gain
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = ambitious
					has_trait = callous
				}
			}
		}
	}
	
	option = { #It's not that bad
		name = legend_spread_events.0070.d
		custom_tooltip = legend_spread_events.0070.a.tt
		add_prestige = minor_prestige_gain
		trigger_event = { 
			id = legend_spread_events.0071
			days = { 10 20 }
		}
		
		stress_impact = {
			base = medium_stress_impact_gain
			depressed_1 = major_stress_impact_gain
			depressed_genetic = major_stress_impact_gain
			humble = major_stress_impact_gain
			arrogant = medium_stress_impact_loss
			ambitious = medium_stress_impact_loss
			callous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				OR = {
					has_trait = depressed_1
					has_trait = depressed_genetic
					has_trait = humble
				}
			}
		}
	}
}

scripted_trigger legend_spread_events_0071_promoter_trigger = {
	is_physically_able_adult = yes
	number_of_personality_traits_in_common = {
		target = root
		value >= 1
	}
	NOT = { exists = promoted_legend }
}

# You're feeling pretty good about your legend
legend_spread_events.0071 = {
	type = character_event
	title = legend_spread_events.0071.t
	desc = {
		desc = legend_spread_events.0071.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { has_variable = legend_chain_arrogant_var }
				desc = legend_spread_events.0071.desc.mid.arrogant
			}
			desc = legend_spread_events.0071.desc.mid
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:promoter 
				}
				desc = legend_spread_events.0071.desc.promoter
			}
			desc = legend_spread_events.0071.desc.fallback
		}
	}
	theme = legend_terrain
	left_portrait = {
		character = root
		animation = hero_flex
		camera = camera_event_very_left
	}
	right_portrait = {
		trigger = { exists = scope:promoter }
		character = scope:promoter
		animation = admiration
		camera = camera_event_right
	}
	lower_right_portrait = {
		trigger = { exists = scope:other_promoter }
		character = scope:other_promoter
	}
	
	immediate = {
		save_scope_as = root_scope
		random_neighboring_and_across_water_top_liege_realm_owner = {
			limit = { legend_spread_events_0071_promoter_trigger = yes }
			weight = {
				base = 1
				modifier = {
					add = 10
					has_any_good_relationship_with_root_trigger = yes
				}
				modifier = {
					add = -5
					primary_title = { is_head_of_faith = yes }
				}
			}
			save_scope_as = promoter
		}
		if = {
			limit = { NOT = { exists = scope:promoter } }
			random_vassal = {
				limit = { legend_spread_events_0071_promoter_trigger = yes }
				weight = {
					base = 1
					modifier = {
						add = 10
						has_any_good_relationship_with_root_trigger = yes
					}
					modifier = {
						add = 5
						is_powerful_vassal_of = root
					}
				}
				save_scope_as = promoter
			}
		}
		if = {
			limit = { NOT = { exists = scope:promoter } }
			random_courtier = {
				limit = { legend_spread_events_0071_promoter_trigger = yes }
				weight = {
					base = 1
					modifier = {
						add = 10
						has_any_good_relationship_with_root_trigger = yes
					}
				}
				save_scope_as = promoter
			}
		}
		random_neighboring_and_across_water_top_liege_realm_owner = {
			limit = {
				legend_spread_events_0071_promoter_trigger = yes
				this != scope:promoter
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					has_any_good_relationship_with_root_trigger = yes
				}
				modifier = {
					add = -5
					primary_title = { is_head_of_faith = yes }
				}
			}
			save_scope_as = other_promoter
		}
		if = {
			limit = { NOT = { exists = scope:other_promoter } }
			random_vassal = {
				limit = {
					legend_spread_events_0071_promoter_trigger = yes
					this != scope:promoter
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						has_any_good_relationship_with_root_trigger = yes
					}
					modifier = {
						add = 5
						is_powerful_vassal_of = root
					}
				}
				save_scope_as = other_promoter
			}
		}
		if = {
			limit = { NOT = { exists = scope:other_promoter } }
			random_courtier = {
				limit = {
					legend_spread_events_0071_promoter_trigger = yes
					this != scope:promoter
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						has_any_good_relationship_with_root_trigger = yes
					}
				}
				save_scope_as = other_promoter
			}
		}
	}
	
	option = { #Convince this guy to be a promoter
		name = legend_spread_events.0071.a
		trigger = {
			exists = scope:promoter
		}			
		scope:promoter = {
			set_promoted_legend = root.promoted_legend
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 25
			}
		}
		
		stress_impact = {
			gregarious = medium_stress_impact_loss
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = gregarious
			}
			modifier = {
				factor = 0
				has_trait = ambitious
			}
		}
	}
	
	option = { #Convince this other guy
		name = legend_spread_events.0071.b
		trigger = { exists = scope:other_promoter }
		scope:other_promoter = {
			set_promoted_legend = root.promoted_legend
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 25
			}
		}
		
		stress_impact = {
			gregarious = medium_stress_impact_loss
			ambitious = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = gregarious
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
			}
		}
	}
	
	option = { #Try to convince your vassals you're cool instead
		name = legend_spread_events.0071.c
		every_vassal = {
			vassal_stance = parochial
			custom = every_parochial_vassal
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 50
			}
		}
		
		stress_impact = {
			humble = medium_stress_impact_gain
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = humble
			}
			modifier = {
				factor = 2
				has_trait = ambitious
			}
		}
	}
	
	option = { #I don't care about anyone's opinion but MY OWN
		name = legend_spread_events.0071.d
		if = {
			limit = {
				has_variable = legend_chain_arrogant_var
			}
			promoted_legend = { 
				add_legend_owner_modifier = {
					modifier = legend_chain_arrogant_modifier
				}
			}
		}
		else = {
			promoted_legend = {
				add_legend_owner_modifier = {
					modifier = legend_chain_kinda_arrogant_modifier
				}
			}
		}
		
		stress_impact = {
			arrogant = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			deceitful = medium_stress_impact_loss
			humble = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = gregarious
				}
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = callous
					has_trait = deceitful
					has_trait = arrogant
				}
			}
		}
	}
}

# You're feeling pretty bad about your legend - Holy
legend_spread_events.0072 = {
	type = character_event
	title = legend_spread_events.0072.t
	desc = {
		desc = legend_spread_events.0072.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { has_variable = legend_chain_depressed_var }
				desc = legend_spread_events.0072.desc.mid.depressed
			}
			desc = legend_spread_events.0072.desc.mid.fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:praying_vassal
				}
				desc = legend_spread_events.0072.desc.vassal
			}
			desc = legend_spread_events.0072.desc.fallback
		}
	}
	theme = legend
	override_background = { reference = temple }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = humble
					has_trait = depressed_genetic
					has_trait = depressed_1
				}
			}
			animation = worry
		}
		animation = prayer
	}
	right_portrait = {
		trigger = { exists = scope:praying_vassal }
		character = scope:praying_vassal
		animation = personality_zealous
	}
	lower_center_portrait = {
		trigger = { exists = scope:bishop }
		character = scope:bishop
	}
	
	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		save_scope_as = root_scope
		if = {
			limit = {
				any_vassal = {
					is_physically_able_adult = yes
					ai_zeal > 0
					NOT = { exists = promoted_legend }
					NOT = { has_council_position = councillor_court_chaplain }
				}
			}
			random_vassal = {
				limit = {
					is_physically_able_adult = yes
					ai_zeal > 0
					NOT = { exists = promoted_legend }
					NOT = { has_council_position = councillor_court_chaplain }
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						is_powerful_vassal_of = root
					}
					modifier = {
						add = 5
						has_any_good_relationship_with_root_trigger = yes
					}
					modifier = {
						add = 5
						has_trait = zealous
					}
				}
				save_scope_as = praying_vassal
			}
		}
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
			}
			cp:councillor_court_chaplain = { save_scope_as = bishop }
		}
	}
	
	option = { #Think about god
		name = legend_spread_events.0072.a
		promoted_legend = {
			add_legend_owner_modifier = {
				modifier = legend_chain_zealous_modifier
			}
		}
		
		stress_impact = {
			zealous = major_stress_impact_loss
			cynical = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = zealous
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = gregarious
					has_trait = ambitious
					has_trait = cynical
				}
			}
		}
	}
	
	option = { #Convince this guy that's also praying here
		name = legend_spread_events.0072.b
		trigger = {
			exists = scope:praying_vassal
		}
		scope:praying_vassal = {
			set_promoted_legend = root.promoted_legend
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 25
			}
		}
		
		stress_impact = {
			gregarious = medium_stress_impact_loss
			ambitious = medium_stress_impact_gain
			zealous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = gregarious
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = ambitious
					has_trait = zealous
				}
			}
		}
	}
	
	option = { #Try to convince your vassals you're cool instead
		name = legend_spread_events.0072.c
		every_vassal = {
			vassal_stance = zealot
			custom = every_zealot_vassal
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 50
			}
		}
		
		if = { #if you don't have another option we give you a bit of extra piety
			limit = {
				NOT = { exists = scope:praying_vassal }
			}
			add_piety = minor_piety_gain
		}
		
		stress_impact = {
			humble = medium_stress_impact_gain
			zealous = medium_stress_impact_gain
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = zealous
				}
			}
			modifier = {
				factor = 2
				has_trait = ambitious
			}
		}
	}
	
	option = { #I don't care about anyone's opinion but my chaplain's
		name = legend_spread_events.0072.d
		trigger = {
			exists = scope:bishop
		}
		scope:bishop = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 50
			}
		}				
		
		stress_impact = {
			zealous = medium_stress_impact_loss
			callous = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = arrogant
					has_trait = ambitious
				}
			}
		}
	}
}

# You're feeling pretty bad about your legend - Heroic
legend_spread_events.0073 = {
	type = character_event
	title = legend_spread_events.0073.t
	desc = {	
		desc = legend_spread_events.0073.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { has_variable = legend_chain_depressed_var }
				desc = legend_spread_events.0073.desc.mid.depressed
			}
			desc = legend_spread_events.0073.desc.mid.fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:fighting_vassal
				}
				desc = legend_spread_events.0073.desc.vassal
			}
			desc = legend_spread_events.0073.desc.fallback
		}
	}
	theme = legend_terrain
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = humble
					has_trait = depressed_genetic
					has_trait = depressed_1
				}
			}
			animation = grief
		}
		animation = worry
	}
	right_portrait = {
		trigger = { exists = scope:fighting_vassal }
		character = scope:fighting_vassal
		animation = marshal
	}
	lower_center_portrait = {
		trigger = { exists = scope:marshal }
		character = scope:marshal
	}
	
	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		save_scope_as = root_scope
		if = {
			limit = {
				any_vassal = {
					is_physically_able_adult = yes
					OR = {
						ai_boldness > 0
						ai_energy > 0
					}
					NOT = { exists = promoted_legend }
					NOT = { has_council_position = councillor_marshal }
				}
			}
			random_vassal = {
				limit = {
					is_physically_able_adult = yes
					OR = {
						ai_boldness > 0
						ai_energy > 0
					}
					NOT = { exists = promoted_legend }
					NOT = { has_council_position = councillor_marshal }
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						is_powerful_vassal_of = root
					}
					modifier = {
						add = 5
						has_any_good_relationship_with_root_trigger = yes
					}
					modifier = {
						add = 5
						has_trait = brave
					}
				}
				save_scope_as = fighting_vassal
			}
		}
		if = {
			limit = {
				exists = cp:councillor_marshal
			}
			cp:councillor_marshal = { save_scope_as = marshal }
		}
	}
	
	option = { #Think about heroic battles
		name = legend_spread_events.0073.a
		promoted_legend = {
			add_legend_owner_modifier = {
				modifier = legend_chain_army_modifier
			}
		}
		
		stress_impact = {
			calm = medium_stress_impact_gain
			wrathful = medium_stress_impact_loss
			brave = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				OR = {
					has_trait = wrathful
					has_trait = brave
				}
			}
			modifier = {
				factor = 0
				has_trait = calm
			}
		}
	}
	
	option = { #Convince this guy that's also hanging out here
		name = legend_spread_events.0073.b
		trigger = {
			exists = scope:fighting_vassal
		}
		scope:fighting_vassal = {
			set_promoted_legend = root.promoted_legend
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 25
			}
		}
		
		stress_impact = {
			gregarious = medium_stress_impact_loss
			ambitious = medium_stress_impact_gain
			zealous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = gregarious
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = ambitious
					has_trait = zealous
				}
			}
		}
	}
	
	option = { #Try to convince your vassals you're cool instead
		name = legend_spread_events.0073.c
		every_vassal = {
			vassal_stance = glory_hound
			custom = every_glory_hound_vassal
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 50
			}
		}
		
		if = { #if you don't have another option we give you a bit of extra prestige
			limit = {
				NOT = { exists = scope:fighting_vassal }
			}
			add_prestige = minor_prestige_gain
		}
		
		stress_impact = {
			ambitious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = ambitious
			}
		}
	}
	
	option = { #I don't care about anyone's opinion but my marshal's
		name = legend_spread_events.0073.d
		trigger = {
			exists = scope:marshal
		}
		promoted_legend = {
			add_legend_owner_modifier = {
				modifier = legend_chain_marshal_modifier
			}
		}
		scope:marshal = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 50
			}
		}
		
		stress_impact = {
			callous = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = arrogant
					has_trait = ambitious
				}
			}
		}
	}
}

# You're feeling pretty bad about your legend - Legitimizing
legend_spread_events.0074 = {
	type = character_event
	title = legend_spread_events.0074.t
	desc = {
		desc = legend_spread_events.0074.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { has_variable = legend_chain_depressed_var }
				desc = legend_spread_events.0074.desc.mid.depressed
			}
			desc = legend_spread_events.0074.desc.mid.fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:wise_vassal
				}
				desc = legend_spread_events.0074.desc.vassal
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:spouse
				}
				desc = legend_spread_events.0074.desc.spouse
			}
			desc = legend_spread_events.0074.desc.fallback
		}
	}
	theme = legend
	override_background = { reference = ce1_catacombs }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = humble
					has_trait = depressed_genetic
					has_trait = depressed_1
				}
			}
			animation = grief
		}
		animation = worry
	}
	right_portrait = {
		trigger = { exists = scope:wise_vassal }
		character = scope:wise_vassal
		animation = personality_honorable
	}
	lower_left_portrait = {
		trigger = { exists = scope:spouse }
		character = scope:spouse
	}
	lower_right_portrait = {
		trigger = { exists = scope:chancellor }
		character = scope:chancellor
	}
	
	immediate = {
		save_scope_as = root_scope
		if = {
			limit = {
				any_vassal = {
					is_physically_able_adult = yes
					OR = {
						ai_sociability > 0
						ai_compassion > 0
					}
					NOT = { exists = promoted_legend }
					NOT = { has_council_position = councillor_chancellor }
				}
			}
			random_vassal = {
				limit = {
					is_physically_able_adult = yes
					OR = {
						ai_sociability > 0
						ai_compassion > 0
					}
					NOT = { exists = promoted_legend }
					NOT = { has_council_position = councillor_chancellor }
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						is_powerful_vassal_of = root
					}
					modifier = {
						add = 5
						has_any_good_relationship_with_root_trigger = yes
					}
					modifier = {
						add = 5
						OR = {
							has_trait = shrewd
							has_trait = intellect_good
						}
					}
				}
				save_scope_as = wise_vassal
			}
		}
		if = {
			limit = {
				exists = cp:councillor_chancellor
			}
			cp:councillor_chancellor = { save_scope_as = chancellor }
		}
		if = {
			limit = {
				any_spouse = { }
			}
			random_spouse = {
				weight = {
					base = 1
					modifier = {
						add = 10
						OR = {
							has_relation_lover = root
							has_relation_soulmate = root
						}
					}
					modifier = {
						add = 5
						this = root.primary_spouse
					}
				}
				save_scope_as = spouse
			}
		}
	}
	
	option = { #Think about your spouse
		name = legend_spread_events.0074.a
		trigger = { exists = scope:spouse }
		add_character_modifier = {
			modifier = legend_chain_spouse_modifier
			years = 25
		}
		
		stress_impact = {
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			compassionate = medium_stress_impact_loss
			lustful = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				OR = {
					has_trait = lustful
					has_trait = compassionate
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
		}
	}
	
	option = { #Convince this guy that's also hanging out here
		name = legend_spread_events.0074.b
		trigger = {
			exists = scope:wise_vassal
		}
		scope:wise_vassal = {
			set_promoted_legend = root.promoted_legend
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 25
			}
		}
		
		stress_impact = {
			gregarious = medium_stress_impact_loss
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = gregarious
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = ambitious
					has_trait = compassionate
					has_trait = lustful
				}
			}
		}
	}
	
	option = { #Try to convince your vassals you're cool instead
		name = legend_spread_events.0074.c
		trigger = {
			any_vassal = { }
		}
		every_vassal = {
			vassal_stance = courtly
			custom = every_courtly_vassal
			add_opinion = {
				modifier = impressed_opinion
				target = root
				opinion = 50
			}
		}
		
		if = { #if you don't have another option we give you a bit of extra prestige
			limit = {
				NOR = {
					exists = scope:wise_vassal
					exists = scope:spouse
				}
			}
			add_prestige = minor_prestige_gain
		}
		
		stress_impact = {
			
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = deceitful
				}
			}
		}
	}
	
	option = { #I don't care about anyone's opinion but my chancellor's
		name = legend_spread_events.0074.d
		trigger = {
			exists = scope:chancellor
		}
		promoted_legend = {
			add_legend_owner_modifier = {
				modifier = legend_chain_chancellor_modifier
			}
		}
		scope:chancellor = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 50
			}
		}
		
		stress_impact = {
			callous = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = arrogant
					has_trait = ambitious
				}
			}
		}
	}
}
