﻿#Events for chivalry lifestyle focus

#CHIVALRY REGULAR EVENTS
	# 0001 		- A practice duel gone terribly wrong, Peter Vilberg
	# 0002-0007 - Horse Riding Accident, by Petter Vilberg
	# 0010 		- Train with your signature weapon, by Linnéa Thimrén
	# 1011-1012 - Find an old castle, by Linnéa Thimrén
	# 1021 		- Stress triggers bad battle practice
	# 2010 		- Practice duel (Prowess skill challenge), Petter Vilberg
	# 3000-3005	- Vassal struggling to train new recruits, Sean Hughes

#CHIVALRY SPECIAL EVENTS
	# 1201-1204	- Mounted Warrior Practice, by Petter Vilberg
	# 1601-1699	- Train a warhorse, by Linnéa Thimrén


############################
# CHIVALRY: REGULAR EVENTS #
############################

namespace = martial_chivalry

#A practice duel gone terribly wrong
	#by Petter Vilberg
martial_chivalry.0001 = {
	type = character_event
	title = martial_chivalry.0001.t
	desc = {
		desc = martial_chivalry.0001.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					prowess < scope:duel_opponent.prowess
				}
				desc = martial_chivalry.0001.hard_fight
			}
			triggered_desc = {
				desc = martial_chivalry.0001.easy_fight
			}
		}
		desc = martial_chivalry.0001.conclusion
	}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	
	left_portrait = scope:duel_opponent
	
	trigger = {
		NOT = { has_character_flag = had_duel_gone_wrong_event }
		is_landed = yes
	}

	weight_multiplier = {
		base = 1
		modifier = { #More likely to occur if the character has a little Dread
			add = 1
			dread > 10
		}
		modifier = { #More likely if you are into duels
			add = 2
			has_trait_rank = {
				trait = lifestyle_blademaster
				rank > 0
			}
		}
		upweight_for_focus_modifier = { FOCUS = martial_chivalry_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_duel_gone_wrong_event
			days = 3650
		}
		hidden_effect = {
			create_character = {
				location = root.capital_province
				save_scope_as = duel_opponent
				trait = brave
				culture = root.culture
				faith = root.faith
				gender_female_chance = root_soldier_female_chance
				prowess = 15
			}
		}
	}

	option = { #This person could serve me well!
		name = martial_chivalry.0001.a
		add_courtier = scope:duel_opponent
		reverse_add_opinion = {
			modifier = duel_mutual_respect_opinion
			target = scope:duel_opponent
		}
		add_opinion = {
			modifier = duel_mutual_respect_opinion
			target = scope:duel_opponent
		}	
		stress_impact = {
			sadistic = minor_stress_impact_gain
			paranoid = major_stress_impact_gain
			vengeful = medium_stress_impact_gain
			wrathful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.25
				ai_vengefulness = -1
				ai_rationality = 0.5
			}
		}
	}

	option = { #Lecture them on honor
		name = martial_chivalry.0001.b
		add_prestige = medium_prestige_gain
		add_piety = medium_piety_gain
		stress_impact = {
			sadistic = medium_stress_impact_gain
			vengeful = medium_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 2
				ai_compassion = 1
				ai_energy = -0.25
				ai_boldness = -0.25
			}
		}
	}	
	
	option = { #Kill them
		name = martial_chivalry.0001.c
		scope:duel_opponent = {
			death = {
				death_reason = death_duel
				killer = root
			}
		}
		add_dread = medium_dread_gain
		stress_impact = {
			forgiving = major_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_rationality = -0.25
				ai_zeal = 0.25
				ai_energy = 0.25
			}
		}
	}

	after = {
		hidden_effect = { add_focus_progress = standard_lifestyle_focus_progress }
	}
}


#Horse Riding Accident
	#by Petter Vilberg
martial_chivalry.0002 = {
	type = character_event
	title = martial_chivalry.0002.t
	desc = martial_chivalry.0002.desc

	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	
	
	trigger = {
		NOT = { has_character_flag = had_horseriding_accident_event }
	}

	weight_multiplier = {
		base = 1
		#Less and less likely the more hurt you already are.
		modifier = {
			add = -0.5
			has_trait_rank = {
				trait = wounded
				rank = 1
			}
		}
		modifier = {
			add = -0.8
			has_trait_rank = {
				trait = wounded
				rank = 1
			}
		}
		modifier = {
			add = -1
			has_trait_rank = {
				trait = wounded
				rank = 3
			}
		}
		modifier = { #You really shouldn't go riding if you're wounded, but if you insist, my lord.
			add = 0.5
			has_trait = wounded
			has_trait = stubborn
		}
		upweight_for_focus_modifier = { FOCUS = martial_chivalry_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_horseriding_accident_event
			days = 3650
		}
	}

	option = { #Try to stay on the horse!
		name = martial_chivalry.0002.a
		duel = {
			skill = prowess
			value = high_skill_rating
			20 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -19
				}
				show_as_tooltip = {
					add_martial_lifestyle_xp = medium_lifestyle_experience
					add_character_modifier = {
						modifier = improved_horse_mastery_modifier
						days = 3650
					}
				}
				hidden_effect = {
					trigger_event = martial_chivalry.0003 #Gain an improved horse mastery modifier
				}
			}
			20 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -19
				}
				show_as_tooltip = {
					increase_wounds_effect = {
						REASON = horse_riding_accident
					}
				}
				hidden_effect = {
					trigger_event = { #Things don't go well
						on_action = horse_riding_accident_outcome
					}
				}
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
	}

	option = { #Make for a safe - if humble - landing
		name = martial_chivalry.0002.b
		add_prestige = miniscule_prestige_loss
		stress_impact = {
			arrogant = minor_stress_impact_gain
			brave = medium_stress_impact_gain
		}
	}
}


#You successfully rein in the horse and stay atop!
martial_chivalry.0003 = {
	type = character_event
	title = martial_chivalry.0003.t
	desc = martial_chivalry.0003.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	
	
	immediate = {
		add_character_modifier = {
			modifier = improved_horse_mastery_modifier
			days = 3650
		}
	}

	option = {
		name = martial_chivalry.0003.a
		add_martial_lifestyle_xp = medium_lifestyle_experience
	}
}

#You fall to the ground, hurting yourself a little
martial_chivalry.0004 = {
	type = character_event
	title = martial_chivalry.0004.t
	desc = martial_chivalry.0004.desc

	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root

	trigger = {
		NOT = {
			has_trait_rank = {
				trait = wounded
				rank > 0
			}
		}
	}
	
	immediate = {
		increase_wounds_effect = {
			REASON = horse_riding_accident
		}
	}

	option = { #Damn horse!
		name = martial_chivalry.0004.a
	}
}

#You fall to the ground, hurting yourself severely
martial_chivalry.0005 = {
	type = character_event
	title = martial_chivalry.0005.t
	desc = martial_chivalry.0005.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	

	trigger = {
		has_trait_rank = {
			trait = wounded
			rank = 1
		}
	}
	
	immediate = {
		increase_wounds_effect = {
			REASON = horse_riding_accident
		}
	}

	option = { #Damn horse!
		name = martial_chivalry.0005.a
	}
}

#You fall to the ground, nearly killing yourself
martial_chivalry.0006 = {
	type = character_event
	title = martial_chivalry.0006.t
	desc = martial_chivalry.0006.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	

	trigger = {
		has_trait_rank = {
			trait = wounded
			rank = 2
		}
	}
	
	immediate = {
		increase_wounds_effect = {
			REASON = horse_riding_accident
		}
	}

	option = { #Damn horse!
		name = martial_chivalry.0006.a
	}
}

#You fall to the ground, dying
martial_chivalry.0007 = {
	type = character_event
	title = martial_chivalry.0007.t
	desc = martial_chivalry.0007.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	
	trigger = {
		has_trait_rank = {
			trait = wounded
			rank = 3
		}
	}

	option = { #Damn horse, for real this time!!
		name = martial_chivalry.0007.a
		increase_wounds_effect = {
			REASON = horse_riding_accident
		}
	}
}


#Train with your signature weapon
	#by Linnéa Thimrén
martial_chivalry.0010 = {
	type = character_event
	title = martial_chivalry.0010.t
	desc = martial_chivalry.0010.desc

	theme = martial_chivalry_focus
	override_background = {
		event_background = armory
	}	
	left_portrait = root
	
	trigger = {
		NOT = { has_character_flag = had_event_martial_chivalry_0010 }
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = martial_chivalry_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_martial_chivalry_0010
			days = 3650
		}
		set_signature_weapon_effect = yes
	}

	option = {
		name = martial_chivalry.0010.a
		hidden_effect = { add_focus_progress = standard_lifestyle_focus_progress }
		add_character_modifier = {
			modifier = respected_expertise
		}
	}

	option = {
		name = martial_chivalry.0010.b
		hidden_effect = { add_focus_progress = standard_lifestyle_focus_progress }
		random_list = {
			70 = {
				desc = martial_chivalry.0010.b.tt1
				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_chivalry.0010.b.tt1
					left_icon = root
					add_prestige = minor_prestige_gain
					add_martial_lifestyle_xp = medium_lifestyle_experience
				}
			}
			30 = {
				desc = martial_chivalry.0010.b.tt2
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_chivalry.0010.b.tt2
					left_icon = root
					increase_wounds_effect = { REASON = training_accident }
					add_martial_lifestyle_xp = minor_lifestyle_experience
				}
			}
		}
	}
}


#Find an old castle, rt craven/at brave/prowess/gold or stress
	#by Linnéa Thimrén

martial_chivalry.1011 = {
	type = character_event
	title = martial_chivalry.1011.t
	desc = martial_chivalry.1011.desc

	theme = martial_chivalry_focus
	override_background = {
		event_background = terrain
	}	
	left_portrait = root
	
	trigger = {
		NOT = { has_character_flag = had_haunted_castle_event }

	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = martial_chivalry_focus }
	}

	immediate = {
		hidden_effect = {
			get_quirk_character_effect = yes
		}
		add_character_flag = {
			flag = had_haunted_castle_event
			days = 3650
		}
	}

	option = {
		name = martial_chivalry.1011.a
		stress_impact = {
			craven = minor_stress_impact_gain
		}
		custom_tooltip = martial_chivalry.1011.a.tt
		trigger_event = {
			id = martial_chivalry.1012
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_trait = brave
			}
		}
	}

	option = {
		name = martial_chivalry.1011.b
		add_character_modifier = {
			modifier = hightened_troop_morale_modifier
			days = 3650
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_trait = craven
			}
		}
	}
}

#You went inside, search cellar or upper floors?
martial_chivalry.1012 = {
	type = character_event
	title = martial_chivalry.1012.t
	desc = martial_chivalry.1012.desc

	theme = martial_chivalry_focus
	override_background = {
		event_background = corridor_night
	}	
	left_portrait = root
	
	option = {
		name = martial_chivalry.1012.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_trait = greedy
			}
		}
		duel = {
			skill = stewardship
			value = average_skill_rating

			50 = {
				desc = martial_chivalry.1012.a.success

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

				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_chivalry.1012.a.success
					left_icon = root
					add_gold = major_gold_value
				}
			}
			50 = {
				desc = martial_chivalry.1012.a.failure

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

				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_chivalry.1012.a.failure
					left_icon = root
					add_gold = minor_gold_value
				}
			}
		}
	}

	option = {
		name = martial_chivalry.1012.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_trait = brave
			}
		}
		random_list = {
			50 = {
				desc = martial_chivalry.1012.b.success

				compare_modifier = {
					value = ai_boldness
					multiplier = 0.5
					min = -49
				}

				if = {
					limit = {
						AND = {
							is_ai = no #no ai should be able to gain brave- to keep the type of characters in the game diverse
							stress <= 25
							NOT = { has_trait = brave }
							number_of_personality_traits <= 3
						}
					}
					send_interface_toast = {
						type = event_toast_effect_good
						title = martial_chivalry.1012.b.success
						left_icon = root
						add_trait_force_tooltip = brave
					}
				}
				else_if = {
					limit = {
						OR = {
							number_of_personality_traits = 4
							is_ai = yes
							stress > 25
							has_trait = brave
						}
					}
					send_interface_toast = {
						type = event_toast_effect_good
						title = martial_chivalry.1012.b.success
						left_icon = root
						add_character_modifier = {
							modifier = faced_my_fears
							years = 10
						}
					}
				}
			}
			50 = {
				desc = martial_chivalry.1012.b.tt1

				compare_modifier = {
					value = ai_boldness
					multiplier = -0.5
					min = -49
				}

				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_chivalry.1012.b.failure
					left_icon = root
					add_dread = medium_dread_loss
					stress_impact = {
						base = medium_stress_gain
					}
				}
			}
		}
		stress_impact = {
			craven = medium_stress_impact_gain
		}
	}
}

#Stress triggers bad battle practice
	#by Linnéa Thimrén
martial_chivalry.1021 = {
	type = character_event
	title = martial_chivalry.1021.t
	desc = martial_chivalry.1021.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	
	trigger = {
		stress > 60
		NOT = { has_character_flag = had_stressful_battle_event }
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			target = root
			value = stress
			multiplier = 0.01 # 1.4 total @ 100 Stress, 3.4 total @ 300 Stress.
			offset = -60
		}
		modifier = {
			factor = 0.5
			has_trait_rank = {
				trait = wounded
				rank = 1
			}
		}
		modifier = {
			factor = 0.2
			has_trait_rank = {
				trait = wounded
				rank = 2
			}
		}
		modifier = {
			factor = 0
			has_trait_rank = {
				trait = wounded
				rank = 3
			}
		}
		modifier = {
			add = 0.5
			has_trait = wounded
			has_trait = stubborn
		}
		upweight_for_focus_modifier = { FOCUS = martial_chivalry_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_stressful_battle_event
			days = 3650
		}
	}

	option = {
		name = martial_chivalry.1021.b
		add_martial_lifestyle_xp = medium_lifestyle_experience
		stress_impact = {
			craven = minor_stress_impact_gain
		}

		duel = {
			skill = prowess
			value = average_skill_rating

			50 = {
				desc = martial_chivalry.1021.b.success

				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -19
				}

				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_chivalry.1021.b.success
					left_icon = root
					add_character_modifier = {
						modifier = respected_vigor
						years = 5
					}
				}
			}
			20 = {
				desc = martial_chivalry.1021.b.failure

				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -19
				}
				compare_modifier = {
					value = stress
					multiplier = 0.5 # +30 at 60 Stress; +150 at 300 Stress
				}

				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_chivalry.1021.b.failure
					left_icon = root
					increase_wounds_effect = { REASON = training_accident }
				}
			}
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 20
				OR = {
					has_trait = brave
					has_trait = aggressive_attacker
				}
			}
		}
	}

	option = {
		name = martial_chivalry.1021.a
		stress_impact = {
			base = medium_stress_impact_loss
			craven = minor_stress_impact_loss
			brave = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
		}
	}

}

#Practice duel
	#by Petter Vilberg
#Someone challenges you
martial_chivalry.2010 = {
	type = character_event
	title = martial_chivalry.2010.t
	desc = {
		desc = martial_chivalry.2010.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					reverse_opinion = {
						target = scope:challenger
						value >= 0
					}
				}
				desc = martial_chivalry.2010.like.desc
			}
			desc = martial_chivalry.2010.dislike.desc
		}
	}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = scope:challenger
	
	trigger = {
		NOT = { has_character_flag = had_event_martial_chivalry_2010 }
		NOT = {
			has_trait_rank = {
				trait = wounded
				rank > 1
			}
		}
		OR = {
			any_relation = {
				type = soldier_friend
				is_available_healthy_ai_adult = yes
			}
			any_knight = {
				is_available_healthy_ai_adult = yes
			}
			any_relation = { type = rival
				target_is_liege_or_above = root
				is_available_healthy_ai_adult = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_trait_rank = {
				trait = wounded
				rank = 1
			}
		}
		upweight_for_focus_modifier = { FOCUS = martial_chivalry_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_martial_chivalry_2010
			years = 5
		}
		hidden_effect = {
			random_list = {
				40 = {
					trigger = {
						any_relation = {
							type = soldier_friend
							is_available_healthy_ai_adult = yes
						}
					}
					random_relation = { type = soldier_friend
						limit = {
							is_available_healthy_ai_adult = yes
						}
						save_scope_as = challenger
					}
				}
				30 = {
					trigger = {
						any_knight = {
							is_available_healthy_ai_adult = yes
						}
					}
					random_knight = {
						limit = {
							is_available_healthy_ai_adult = yes
						}
						save_scope_as = challenger
					}
				}
				30 = {
					trigger = {
						any_relation = { type = rival
							is_available_healthy_ai_adult = yes
							OR = {
								is_knight_of = root
								is_knight_of = root.liege
								target_is_liege_or_above = root
							}
						}
					}
					random_relation = {
						type = rival
						limit = {
							is_available_healthy_ai_adult = yes
							OR = {
								is_knight_of = root
								is_knight_of = root.liege
								target_is_liege_or_above = root
							}
						}
						save_scope_as = challenger
					}
				}
			}

			scope:challenger = { set_signature_weapon_effect = yes }
			set_signature_weapon_effect = yes
		}
	}

	option = { #Accept challenge
		name = martial_chivalry.2010.a
		
		duel = {
			skill = prowess
			target = scope:challenger
			20 = { #You have the advantage 		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -19
				}
				desc = martial_chivalry.2010.a.success.tt
				trigger_event = martial_chivalry.2011
				show_as_tooltip = {
					add_martial_lifestyle_xp = medium_lifestyle_experience
					add_character_modifier = {
						modifier = won_practice_duel
						years = 5
					}
				}
			}
			20 = {  #They have the advantage (they are nice), mutually exclusive with other failure
				trigger = {
					reverse_opinion = {
						target = scope:challenger
						value >= 0
					}
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -19
				}
				show_as_tooltip = {
					add_martial_lifestyle_xp = minor_lifestyle_experience
				}
				trigger_event = martial_chivalry.2012 #They're nice about their advantage
				desc = martial_chivalry.2010.a.failure1.tt
			}
			20 = { #They have the advantage (they are an ass), mutually exclusive with other failure
				trigger = {
					reverse_opinion = {
						target = scope:challenger
						value < 0
					}
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -19
				}
				desc = martial_chivalry.2010.a.failure2.tt
				trigger_event = martial_chivalry.2013  #They're an ass about their advantage
				show_as_tooltip = {
					increase_wounds_effect = { REASON = training_accident }
					add_prestige = medium_prestige_loss
				}
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			craven = medium_stress_impact_gain
		}

		ai_chance = {
			base = 75

			modifier = {
				has_trait = brave
				add = 75
			}
		}
	}

	option = { #Decline challenge
		name = martial_chivalry.2010.b
		
		if = {
			limit = {
				reverse_opinion = {
					target = scope:challenger
					value < 0
				}
			}
			add_prestige = minor_prestige_loss
			stress_impact = {
				arrogant = medium_stress_impact_gain
				brave = medium_stress_impact_gain
			}
		}
		else = {
			add_prestige = miniscule_prestige_loss
			stress_impact = {
				brave = medium_stress_impact_gain
			}
		}


		ai_chance = {
			base = 25

			modifier = {
				has_trait = lazy
				add = 50
			}
			modifier = {
				has_trait = craven
				add = 100
			}
			modifier = {
				has_trait = wounded
				add = 200
			}
		}
	}
}	

#You gained the upper hand in the mock duel
martial_chivalry.2011 = {
	type = character_event
	title = martial_chivalry.2011.t
	desc = {
		desc = martial_chivalry.2011.start.desc
		desc = martial_chivalry.2011.end.desc
	}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = scope:challenger

	immediate = {
		show_as_tooltip = {
			add_martial_lifestyle_xp = medium_lifestyle_experience
			add_character_modifier = {
				modifier = won_practice_duel
				years = 5
			}
		}
	}
	
	option = { #You end the duel gracefully
		name = martial_chivalry.2011.a

		add_prestige = minor_prestige_gain
		reverse_add_opinion = {
			target = scope:challenger
			modifier = honorable_duelist
		}
	}

	option = { #You humiliate them
		name = martial_chivalry.2011.b

		add_dread = minor_dread_gain

		scope:challenger = {
			increase_wounds_effect = { REASON = training_accident }
			add_opinion = {
				target = root
				modifier = dishonorable_duelist
			}
			add_prestige = medium_prestige_loss
		}
	}
}	

#The challenger gains the upper hand in the mock duel
martial_chivalry.2012 = {
	type = character_event
	title = martial_chivalry.2012.t
	desc = {
		desc = martial_chivalry.2011.start.desc
		desc = martial_chivalry.2012.end.desc
	}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = scope:challenger

	immediate = {
		add_martial_lifestyle_xp = minor_lifestyle_experience
	}
	
	option = { #Yield
		name = martial_chivalry.2012.a

		reverse_add_opinion = {
			target = scope:challenger
			modifier = honorable_duelist
		}

		stress_impact = {
			brave = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
		}

		ai_chance = {
			base = 75
		}
	}

	option = { #Keep fighting
		name = martial_chivalry.2012.b

		duel = {
			skill = prowess
			target = scope:challenger
			10 = { #You win	
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -9
				}
				desc = martial_chivalry.2010.a.success.tt
				trigger_event = martial_chivalry.2014
				show_as_tooltip = {
					add_martial_lifestyle_xp = medium_lifestyle_experience
					add_prestige = minor_prestige_gain
					add_character_modifier = {
						modifier = won_practice_duel
						years = 5
					}
				}
			}
			20 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -19
				}
				desc = martial_chivalry.2010.a.failure2.tt
				trigger_event = martial_chivalry.2015
				show_as_tooltip = {
					increase_wounds_effect = { REASON = training_accident }
					add_prestige = medium_prestige_loss
				}
			}
		}

		stress_impact = {
			craven = medium_stress_impact_gain
		}

		ai_chance = {
			base = 25
		}
	}
}

#The challenger gains the upper hand in the practise duel and they're being an ass about it!
martial_chivalry.2013 = {
	type = character_event
	title = martial_chivalry.2013.t
	desc = {
		desc = martial_chivalry.2011.start.desc
		desc = martial_chivalry.2013.end.desc
	}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = scope:challenger
	
	option = {
		name = martial_chivalry.2013.a

		increase_wounds_effect = { REASON = training_accident }
		add_prestige = medium_prestige_loss
		add_opinion = {
			target = scope:challenger
			modifier = dishonorable_duelist
		}
	}
}

#You won the duel, what a miracle!
martial_chivalry.2014 = {
	type = character_event
	title = martial_chivalry.2014.t
	desc = martial_chivalry.2014.desc
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = scope:challenger
	
	option = {
		name = martial_chivalry.2014.a

		add_martial_lifestyle_xp = medium_lifestyle_experience
		add_prestige = minor_prestige_gain
		add_character_modifier = {
			modifier = won_practice_duel
			years = 5
		}
		
	}
}

#You make a fool of yourself...
martial_chivalry.2015 = {
	type = character_event
	title = martial_chivalry.2015.t
	desc = martial_chivalry.2015.desc
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = scope:challenger
	
	option = {
		name = martial_chivalry.2015.a

		increase_wounds_effect = { REASON = training_accident }
		add_prestige = medium_prestige_loss
	}
}


##################################################
# Poor Commander
# by Sean Hughes
# 3000-3005
##################################################

scripted_trigger martial_chivalry_3000_is_valid_commander_trigger = {
	can_be_combatant_based_on_gender_trigger = {ARMY_OWNER = root}
	is_available_healthy_adult = yes
	is_landed = yes
	martial <= 9
	any_liege_or_above = {
		this = root
	}
}

martial_chivalry.3000 = {
	type = character_event
	title = martial_chivalry.3000.t
	desc = {
		desc = martial_chivalry.3000.desc #Standard introduction text for all characters
		first_valid = {
				triggered_desc = { #Conclusion flavor text for Compassionate characters.
				trigger = { has_trait = compassionate }
				desc = martial_chivalry.3000.desc.compassionate
			}
			triggered_desc = { #Conclusion flavor text for Callous characters.
				trigger = { has_trait = callous }
				desc = martial_chivalry.3000.desc.callous
			}
			desc = martial_chivalry.3000.desc.fallback #Standard conclusion text for other characters.
		}
	}

	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}	
	left_portrait = {
		character = scope:bad_commander
		animation = stress
	}

	trigger = {
		NOT = { has_character_flag = had_event_martial_chivalry_3000 } #Can only happen once every 5 years.

		OR = {
			any_vassal = {
				martial_chivalry_3000_is_valid_commander_trigger = yes
			}
			AND = {
				exists = player_heir
				player_heir = {
					martial_chivalry_3000_is_valid_commander_trigger = yes
				}
			}
			any_child = {
				martial_chivalry_3000_is_valid_commander_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1

		modifier = {
			add = 0.5
			exists = player_heir
			player_heir = {
				martial_chivalry_3000_is_valid_commander_trigger = yes
			}
		}

		modifier = {
			add = 0.3
			any_vassal = {
				is_powerful_vassal_of = root
				martial_chivalry_3000_is_valid_commander_trigger = yes
			}
		}
		upweight_for_focus_modifier = { FOCUS = martial_chivalry_focus }
	}	

	immediate = {
		add_character_flag = {
			flag = had_event_martial_chivalry_3000
			days = 1825
		}

		save_scope_as = my_liege

		every_child = {
			limit = {
				martial_chivalry_3000_is_valid_commander_trigger = yes
			}
			add_to_list = potential_important_people
		}
		every_heir = {
			limit = {
				martial_chivalry_3000_is_valid_commander_trigger = yes
			}
			add_to_list = potential_important_people
		}
		every_vassal = {
			limit = {
				martial_chivalry_3000_is_valid_commander_trigger = yes
			}
			add_to_list = potential_important_people
		}

		random_in_list = {
			list = potential_important_people

			weight = {
				#Because the event can only fire on bad commanders, we need to make sure the event prefers firing on characters the player actually cares about.
				base = 10
				modifier = {
					is_player_heir_of_trigger = { CHARACTER = root }
					factor = 10
				}
				modifier = {
					is_child_of = root
					factor = 10
				}
				modifier = {
					is_powerful_vassal = yes
					factor = 5
				}
				compare_modifier = {
					value = highest_held_title_tier
					multiplier = 2
				}
			
				#Even if the commander is bad, it would be nice if they weren't completely terrible.
				compare_modifier = {
					value = martial
					multiplier = 5
				}
			}
			save_scope_as = bad_commander
		}
	}



	#Give advice(wanted or not) to the poor commander.
	option = {
		name = martial_chivalry.3000.b

		add_martial_lifestyle_xp = medium_lifestyle_experience

		#This list is purely to create an informational tooltip for the player; all the actual effects happen in the follow-up events.
		random_list = {
			desc = martial_chivalry.3000.b.attempt
			1 = {
				desc = martial_chivalry.3000.b.tt.s
				show_chance = no
				show_as_tooltip = {
					scope:bad_commander = {
						if = {
							limit = {martial <= 4}
							add_martial_skill = 3
						}
						else_if = {
							limit = {martial <= 7}
							add_martial_skill = 2
						}
						else = {
							add_martial_skill = 1
						}
						add_opinion = {
							target = root
							modifier = grateful_opinion
							opinion = 20
						}	
					}
				}
			}
			1 = {
				desc = martial_chivalry.3000.b.tt.f
				show_chance = no
				show_as_tooltip = {
					scope:bad_commander = {
						add_opinion = {
							target = root
								modifier = angry_opinion
								opinion = -10
						}
					}
				}
			}
		}

		#Commander responds to advice given.
		scope:bad_commander = {
		  	trigger_event = { id = martial_chivalry.3002 days = 3 }
		}

		stress_impact = {
				shy = medium_stress_impact_gain
				wrathful = medium_stress_impact_gain
				humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
				ai_boldness = 0.5
			}
		}
	}
	
	#Ignore the poor commander's mediocrity, befriend him instead.
	option = {
		name = martial_chivalry.3000.c

		show_as_tooltip = {
			progress_towards_friend_effect = {
				CHARACTER = scope:bad_commander
				OPINION = 20
			}
		}

		scope:bad_commander = {
			hidden_effect = { root = { save_scope_as = my_liege } }
			trigger_event = { id = martial_chivalry.3005 days = 3 }
		}

		stress_impact = {
				shy = medium_stress_impact_gain
				wrathful = medium_stress_impact_gain
				impatient = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_compassion = 1
			}
		}
	}

	#Berate the poor commander for his failure.
	option = {
		name = martial_chivalry.3000.a

		add_dread = minor_dread_gain

		#Only add opinion of other character if we are an AI(As player opinion has no effect).
		if = {
			limit = {
				is_ai = yes
			}
			add_opinion = {
				target = scope:bad_commander
				modifier = disappointed_opinion
				opinion = -20
			}	
		}
		reverse_add_opinion = {
			target = scope:bad_commander
			modifier = angry_opinion
			opinion = -20
		}

		scope:bad_commander = {
			show_as_tooltip = {
				add_prestige = medium_prestige_loss
			}

			trigger_event = { id = martial_chivalry.3001 days = 3 }
		}

		stress_impact = {
				forgiving = medium_stress_impact_gain
				compassionate = medium_stress_impact_gain
				calm = minor_stress_impact_gain
				shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = -1
			}
		}
	}
}

#Bad commander responds to being berrated.
martial_chivalry.3001 = {
	type = character_event
	title = martial_chivalry.3001.t
	desc = {
		desc = martial_chivalry.3000.response.desc
			desc = martial_chivalry.3001.desc
		}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}	
	left_portrait = {
		character = scope:my_liege
		animation = angry
	}

	immediate = {
		show_as_tooltip = {
			#Only add opinion of other character if we are an AI(As player opinion has no effect).
			scope:my_liege = {
				if = {
					limit = {
						is_ai = yes
					}
					add_opinion = {
					  	target = root
						modifier = disappointed_opinion
						opinion = -20
					}
				}
			}

			if = {
				limit = {
					is_ai = yes
				}
				add_opinion = {
				  	target = scope:my_liege
					modifier = angry_opinion
					opinion = -20
				}
			}

		}
		#Prestige loss always happens(your liege watched you fail).
		add_prestige = medium_prestige_loss
	}

	#Punish own troops for Dread.
	option = {
		name = martial_chivalry.3001.a
		add_dread = minor_dread_gain

		stress_impact = {
				compassionate = medium_stress_impact_gain
				forgiving = medium_stress_impact_gain
				patient = medium_stress_impact_gain
				just = medium_stress_impact_gain
				ambitious = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 100
				ai_compassion = -100
				ai_honor = -100
			}
		}
	}

	#Use failure as reason to work harder.
	option = {
		name = martial_chivalry.3001.b
		add_character_modifier = {
			modifier = warfare_motivated_instructor_modifier
			days = 365
		}

		stress_impact = {
				arrogant = medium_stress_impact_gain
				lazy = medium_stress_impact_gain
				content = medium_stress_impact_gain
				wrathful = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 100
				ai_boldness = 100
				ai_greed = 100
				ai_honor = 200
			}
		}
	}

	#Accept that you are just a bad commander.
	option = {
		name = martial_chivalry.3001.c

		stress_impact = {
			base = minor_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -100
				ai_boldness = -100
			}
		}
	}
}

#Bad commander responds to advice given.
martial_chivalry.3002 = {
	type = character_event
	title = martial_chivalry.3002.t
	desc = {
		desc = martial_chivalry.3000.response.desc
			desc = martial_chivalry.3002.desc
		}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}	
	left_portrait = scope:my_liege

	trigger = {
		scope:my_liege = {
			is_alive = yes
		}
	}

	#Accept advice gratefully.
	option = {
		name = martial_chivalry.3002.a
		if = {
			limit = { martial <= 4 }
			add_martial_skill = 3
			save_scope_value_as = {
				name = martial_increase
				value = 3
			}
		}
		else_if = {
			limit = { martial <= 7 }
			add_martial_skill = 2
			save_scope_value_as = {
				name = martial_increase
				value = 2
			}
		}
		else = {
			add_martial_skill = 1
			save_scope_value_as = {
				name = martial_increase
				value = 1
			}
		}

		#Only add opinion of other character if we are an AI(As player opinion has no effect).
		if = {
			limit = {
				is_ai = yes
			}
			add_opinion = {
				target = scope:my_liege
				modifier = grateful_opinion
				opinion = low_positive_opinion
			}	
		}
		reverse_add_opinion = {
			target = scope:my_liege
			modifier = pleased_opinion
			opinion = low_positive_opinion
		}

		scope:my_liege = {
			trigger_event = { id = martial_chivalry.3003 days = 1 }
		}

		stress_impact = {
				arrogant = medium_stress_impact_gain
				stubborn = medium_stress_impact_gain
				vengeful = medium_stress_impact_gain
				lazy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 100
				ai_rationality = 200
				ai_vengefulness = -100
				ai_energy = 100
			}
		}
	}

	#Rudly reject advice!
	option = {
		name = martial_chivalry.3002.b
		add_dread = minor_dread_gain

		#Only add opinion of other character if we are an AI(As player opinion has no effect).
		if = {
			limit = {
				is_ai = yes
			}
			add_opinion = {
				target = scope:my_liege
				modifier = angry_opinion
				opinion = -10
			}
		}
		reverse_add_opinion = {
			target = scope:my_liege
			modifier = disappointed_opinion
			opinion = -10
		}

		scope:my_liege = {
			trigger_event = { id = martial_chivalry.3004 days = 1 }
		}

		stress_impact = {
			diligent = medium_stress_impact_gain
				ambitious = medium_stress_impact_gain
				humble = medium_stress_impact_gain
				compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -200
				ai_vengefulness = 200
				ai_energy = -100
			}
		}
	}
}

#Original character hears about the bad commander accepting his advice.
martial_chivalry.3003 = {
	type = character_event
	title = martial_chivalry.3003.t
	desc = {
		desc = martial_chivalry.3003.desc.1
			desc = martial_chivalry.3003.desc.2
		}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}	
	left_portrait = scope:bad_commander

	immediate = {
		show_as_tooltip = {
			scope:bad_commander = {
				if = {
					limit = {
						scope:martial_increase = 3
					}
					add_martial_skill = 3
				}
				else_if = {
					limit = {
						scope:martial_increase = 2
					}
					add_martial_skill = 2
				}
				else = {
					add_martial_skill = 1
				}
			}
			reverse_add_opinion = {
			  	target = scope:bad_commander
				modifier = pleased_opinion
				opinion = 20
			}
		}
	}

	option = {
		name = martial_chivalry.3003.a
	}
}

#Original character hears about the bad commander rejecting his advice.
martial_chivalry.3004 = {
	type = character_event
	title = martial_chivalry.3004.t
	desc = martial_chivalry.3004.desc
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}	
	left_portrait = {
		character = scope:bad_commander
		animation = anger
	}

	immediate = {
		show_as_tooltip = {
			#Only add opinion of other character if we are an AI(As player opinion has no effect).
			if = {
				limit = {
					is_ai = yes
				}
				add_opinion = {
				  	target = scope:bad_commander
					modifier = angry_opinion
					opinion = -10
				}
			}
			reverse_add_opinion = {
			  	target = scope:bad_commander
				modifier = angry_opinion
				opinion = -10
			}
		}
	}

	option = {
		name = martial_chivalry.3004.a
	}
}

#Bad commander hears about how nice his liege was to ignore his failure.
martial_chivalry.3005 = {
	type = character_event
	title = martial_chivalry.3005.t
	desc = {
		desc = martial_chivalry.3000.response.desc
			desc = martial_chivalry.3005.desc
		}
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}	
	left_portrait = scope:my_liege

	immediate = {
		progress_towards_friend_effect = {
			CHARACTER = scope:my_liege
			OPINION = 20
		}
	}

	option = {
		name = martial_chivalry.3005.a
		
		add_opinion = {
			target = scope:my_liege
			modifier = friendliness_opinion
			opinion = 20
		}
		add_stress = minor_stress_loss
	}
}

############################
# CHIVALRY: SPECIAL EVENTS #
############################

namespace = martial_chivalry_special


###################################
# Mounted Warrior Practice Battle # by Petter Vilberg
###################################

#Watch your knights in mock battle before the stablemaster brings out the horses
martial_chivalry_special.1201 = {
	type = character_event
	title = martial_chivalry_special.1201.t
	desc = martial_chivalry_special.1201.desc

	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	
	trigger = {
		OR = {
			has_focus = martial_chivalry_focus
			is_ai = no
		}
		NOT = { has_character_flag = had_event_martial_chivalry_special_1201 }
		NOT = { has_character_flag = is_in_martial_special_event }
		any_knight = {
			is_available_adult = yes
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = is_in_martial_special_event
			days = 200
		}
		add_character_flag = had_event_martial_chivalry_special_1201
		random_courtier = {
			limit = { martial > 9 }
			save_scope_as = soldier
		}
		random_knight = {
			limit = {
				is_available_adult = yes
			}

			weight = {
				base = 0
				compare_modifier = {
					value = martial
				}
				compare_modifier = {
					factor = martial
				}
			}
			save_scope_as = soldier
		}
	}

	option = { #Head out for a ride
		name = martial_chivalry_special.1201.a
		custom_tooltip = martial_lifestyle_perk_indication
		hidden_effect = {
			trigger_event = {
				id = martial_chivalry_special.1202
				days = { 1 5 }
			}
		}
	}

	option = { #Run the quintain
		name = martial_chivalry_special.1201.b
		add_character_modifier = {
			modifier = mounted_warrior_practice_modifier
			days = 1825
		}
		remove_character_flag = is_in_martial_special_event
	}
}


#Planning a charge with your cavalry
martial_chivalry_special.1202 = {
	type = character_event
	title = martial_chivalry_special.1202.t
	desc = martial_chivalry_special.1202.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = wilderness
	}
	left_portrait = root
	right_portrait = scope:soldier

	option = {
		name = martial_chivalry_special.1202.a
		hidden_effect = {
			trigger_event = martial_chivalry_special.1203
		}
		show_as_tooltip = {
			add_martial_lifestyle_perk_points = 1
		}
	}

	option = {
		name = martial_chivalry_special.1202.b
		hidden_effect = {
			trigger_event = martial_chivalry_special.1204
		}
		show_as_tooltip = {
			if = {
				limit = {
					NOT = { has_trait = aggressive_attacker }
					number_of_commander_traits < commander_trait_limit
				}
				add_trait = aggressive_attacker
			}
			else = {
				add_character_modifier = {
					modifier = cavalry_charge_exercise_modifier
					days = 3650
				}
			}
		}
		#custom_tooltip = martial_chivalry_special.1202.b.tt
	}	
}



#Deft maneuvering - you rank up
martial_chivalry_special.1203 = {
	type = character_event
	title = martial_chivalry_special.1203.t
	desc = martial_chivalry_special.1203.desc

	theme = martial_chivalry_focus
	override_background = {
		event_background = wilderness
	}
	left_portrait = scope:soldier
	
	immediate = {
		add_martial_lifestyle_perk_points = 1
	}

	option = {
		name = martial_chivalry_special.1203.a
	}

	after = {
		remove_character_flag = is_in_martial_special_event
	}
}


#Vicious charge - You improve your cavalry's attack ability
martial_chivalry_special.1204 = {
	type = character_event
	title = martial_chivalry_special.1204.t
	desc = martial_chivalry_special.1204.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = wilderness
	}
	left_portrait = scope:soldier
	
	immediate = {
		set_signature_weapon_effect = yes
		if = {
			limit = {
				NOT = { has_trait = aggressive_attacker }
				number_of_commander_traits < commander_trait_limit
			}
			add_trait = aggressive_attacker
		}
		else = {
			add_character_modifier = {
				modifier = cavalry_charge_exercise_modifier
				days = 3650
			}
		}
	}

	option = {
		name = martial_chivalry_special.1204.a
	}

	after = {
		remove_character_flag = is_in_martial_special_event
	}
}


#################################
# Train a warhorse, by Linnéa Thimrén
#################################
martial_chivalry_special.1601 = {
	type = character_event
	title = martial_chivalry_special.1601.t
	desc = martial_chivalry_special.1601.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root
	
	trigger = {
		OR = {
			has_focus = martial_chivalry_focus
			is_ai = no
		}
		NOR = {
			has_character_flag = had_event_martial_chivalry_special_1601
			has_character_flag = had_warhorse_story
		}
	}

	immediate = {
		add_character_flag = {
			flag = is_in_martial_special_event
			days = 200
		}
		add_character_flag = had_event_martial_chivalry_special_1601
		random_dummy_gender_effect = yes #for horse gender
	}

	option = { #I'll do my best!
		name = martial_chivalry_special.1601.a
		custom_tooltip = martial_lifestyle_perk_indication
		custom_tooltip = martial_chivalry_special.1601.a.tt
		trigger_event = {
			id = martial_chivalry_special.1603
			days = { 7 10 }
		}
		ai_chance = {
			base = 100
		}
	}

	option = { #Opt out gold
		name = martial_chivalry_special.1601.b
		add_gold = medium_gold_value
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_greed = 0.75
			}
		}
	}

	option = { #Opt out modifier
		name = martial_chivalry_special.1601.c

		add_character_modifier = {
			modifier = warfare_stablemaster_tamed_wild_horse_modifier
			years = 15
		}

		ai_chance = {
			base = 20
			ai_energy_target_modifier = { VALUE = -50 }
		}
	}
}




#How will you try to tame the horse?
martial_chivalry_special.1603 = {
	type = character_event
	title = martial_chivalry_special.1601.t
	desc = martial_chivalry_special.1603.desc
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root

	option = { #Direct approach - prowess/boldness
		name = martial_chivalry_special.1603.a
		flavor = martial_chivalry_special.1603.a.tt

		hidden_effect = {
			random_list = {
				10 = {
					#"Guaranteed" success
					modifier = {
						OR = {
							prowess >= very_high_skill_rating
							has_trait = brave
						}
						add = 100
					}
					#Success increase
					modifier = {
						add = {
							value = prowess
							subtract = average_skill_rating
							multiply = 2 #10 at high skill
						}
					}
					modifier = {
						add = {
							value = ai_boldness
							divide = high_positive_ai_value
							multiply = 10 #10 at high positive value
						}
					}
					save_scope_value_as = {
						name = success
						value = yes
					}
				}
				5 = { }
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.75
			}
			compare_modifier = {
				target = root
				value = martial
				multiplier = 1.5
			}
		}
	}

	option = { #Get it to trust you - diplomacy/compassion
		name = martial_chivalry_special.1603.b
		flavor = martial_chivalry_special.1603.b.tt
		hidden_effect = {
			random_list = {
				10 = {
					#"Guaranteed" success
					modifier = {
						OR = {
							diplomacy >= very_high_skill_rating
							has_trait = compassionate
						}
						add = 100
					}
					#Success increase
					modifier = {
						add = {
							value = diplomacy
							subtract = average_skill_rating
							multiply = 2 #10 at high skill
						}
					}
					modifier = {
						add = {
							value = ai_compassion
							divide = high_positive_ai_value
							multiply = 10 #10 at high positive value
						}
					}
					save_scope_value_as = {
						name = success
						value = yes
					}
				}
				5 = { }
			}
		}
		ai_chance = {
			base = 50
			compare_modifier = {
				target = root
				value = diplomacy
				multiplier = 2
			}
			compare_modifier = {
				target = root
				value = intrigue
				multiplier = 1
			}
		}
	}
	
	option = { #Bribe it - intrigue/generosity
		name = martial_chivalry_special.1603.c
		flavor = martial_chivalry_special.1603.c.tt
		hidden_effect = {
			random_list = {
				10 = {
					#"Guaranteed" success
					modifier = {
						OR = {
							intrigue >= very_high_skill_rating
							has_trait = generous
						}
						add = 1000
					}
					#Success increase
					modifier = {
						add = {
							value = intrigue
							subtract = average_skill_rating
							multiply = 2 #10 at high skill
						}
					}
					modifier = {
						add = {
							value = ai_greed
							divide = high_negative_ai_value
							multiply = 10 #10 at high negative value
						}
					}
					save_scope_value_as = {
						name = success
						value = yes
					}
				}
				5 = { }
			}
		}
		ai_chance = {
			base = 50
			compare_modifier = {
				target = root
				value = stewardship
				multiplier = 2
			}
			compare_modifier = {
				target = root
				value = intrigue
				multiplier = 1
			}
		}
	}

	after = {
		trigger_event = {
			id = martial_chivalry_special.1604
			days = { 3 5 }
		}
	}
}

#How did it go? Opportunity to start the warhorse story if you did well!
martial_chivalry_special.1604 = {
	type = character_event
	title = martial_chivalry_special.1601.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:success
				}
				desc = martial_chivalry_special.1604.desc_success
			}
			desc = martial_chivalry_special.1604.desc_failure
		}
	}
	
	theme = martial_chivalry_focus
	override_background = {
		event_background = courtyard
	}
	left_portrait = root

	option = {
		name = martial_chivalry_special.1604.a
		trigger = {
			exists = scope:success
		}

		start_warhorse_story_cycle_effect = yes
		random_owned_story = {
			limit = { story_type = story_cycle_martial_lifestyle_warhorse }
			if = {
				limit = { scope:dummy_gender = { is_female = yes } }
				assign_horse_gender_effect = { GENDER = female }
			}
			else = {
				assign_horse_gender_effect = { GENDER = male }
			}
		}
		add_martial_lifestyle_perk_points = 1

		ai_chance = {
			base = 100
		}
	}

	option = {
		name = martial_chivalry_special.1604.a_2
		trigger = {
			exists = scope:success
		}

		add_character_modifier = {
			modifier = warfare_tamer_of_horses_modifier
			years = 10
		}

		add_martial_lifestyle_perk_points = 1

		ai_chance = {
			base = 0
		}
	}

	option = {
		name = martial_chivalry_special.1604.b
		trigger = {
			NOT = { exists = scope:success }
		}
		add_character_modifier = {
			modifier = warfare_almost_tamed_wild_horse_modifier
			years = 5
		}

		add_stress = minor_stress_gain

		ai_chance = {
			base = 100
		}
	}

	after = {
		remove_character_flag = is_in_martial_special_event
	}
}
