#Events for authority lifestyle focus


##################################################

#AUTHORITY REGULAR EVENTS
	# 1031		- Mercenaries are being misbehaving at an inn, by Linnéa Thimrén
	# 2040-2042	- Fight between my soldiers (Diplomacy skill challenge), Sean Hughes
	# 2050-2057 - An Extra Hand: Find a right-hand (wo)man, Sean Hughes
	# 3000		- Displaying/Teaching Authority to Someone, by Milla Isaksson

#AUTHORITY SPECIAL EVENTS
	# 1100-1104	- Soldier and Officer Fighting, by Mathilda Bjarnehed
	# 1501-1504	- Deal with Deserters, by Linnéa Thimrén

##################################################

#############################
# AUTHORITY: REGULAR EVENTS #
#############################

namespace = martial_authority

##################################################
# Mercenaries are being misbehaving at an inn
	# by Linnéa Thimrén
##################################################

martial_authority.1031 = {
	type = character_event
	title = martial_authority.1031.t
	desc = martial_authority.1031.desc
	theme = martial_authority_focus
	override_background = {
		reference = tavern
	}

	left_portrait = {
		character = root
		animation = disapproval
	}

	right_portrait = {
		character = scope:scoped_mercenary
		animation = drink
	}
	
	trigger = {
		has_lifestyle = martial_lifestyle
		NOT = { has_character_flag = had_mercenary_disruption_event }
		is_ruler = yes
		is_landed = yes
		exists = capital_county
		any_independent_ruler = {
			government_has_flag = government_is_mercenary
		}
	}

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

	immediate = {
		play_music_cue = "mx_cue_meadandwine"
		add_character_flag = {
			flag = had_mercenary_disruption_event
			days = 3650
		}
		capital_county = {
			save_scope_as = county_to_save
		}
		random_independent_ruler = {
			limit = {
				government_has_flag = government_is_mercenary
				culture = root.culture
			}
			alternative_limit = {
				government_has_flag = government_is_mercenary
				faith = root.faith
			}
			alternative_limit = {
				government_has_flag = government_is_mercenary
			}
			save_scope_as = scoped_mercenary
		}
	}

	option = {
		name = martial_authority.1031.a
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= major_gold_value_check
			}
		}
		
		ai_chance = {
			base = 50
			modifier = {
				add = 20
				OR = {
					has_trait = generous
					has_trait = craven
					has_trait = shy
				}
			}
		}
		remove_short_term_gold = major_gold_value
		add_character_modifier = {
			modifier = generous_to_mercenaries
		}
		add_martial_lifestyle_xp = minor_lifestyle_xp
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
	}
	
	option = {
		name = martial_authority.1031.b
		scope:county_to_save = {
			add_county_modifier = {
				modifier = warfare_expunged_bandits_modifier
				years = 10
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 20
				OR = {
					has_trait = just
					has_trait = greedy
				}
			}
		}
		add_martial_lifestyle_xp = minor_lifestyle_xp
		stress_impact = {
			just = minor_stress_impact_gain
		}
	}
	option = {
		name = martial_authority.1031.c
		trigger = {
			prowess >= high_skill_rating
		}
		skill = prowess
		scope:county_to_save = {
			add_county_modifier = {
				modifier = warfare_expunged_bandits_modifier
				years = 10
			}
		}
		if = {
			limit = {
				OR = {
					has_trait = sadistic
					has_trait = wrathful
				}
			}
			add_dread = medium_dread_gain
		}
		else_if = {
			limit = {
				NOR = {
					has_trait = sadistic
					has_trait = wrathful
				}
			}
			add_character_modifier = {
				modifier = respected_by_mercenaries
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 30
				OR = {
					has_trait = brave
					has_trait = wrathful
					has_trait = sadistic
					has_trait = vengeful
				}
			}
		}
		add_martial_lifestyle_xp = medium_lifestyle_xp
		stress_impact = {
			calm = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
	}
}

##################################################
# Internal Dispute (Diplomacy Skill Challenge)
# by Sean Hughes
# 2040-2042
##################################################

#Find a courtier who would fight in your army.
scripted_trigger martial_authority_2040_first_trigger = {
	is_ai = yes
	is_available_healthy_adult = yes

	age <= 35
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = this }

	save_temporary_scope_as = first

	root = {
		any_knight = {
			martial_authority_2040_second_trigger = yes
		}
	}
}

#Find another courtier who is disliked by the first one.
scripted_trigger martial_authority_2040_second_trigger = {
	is_ai = yes
	is_available_healthy_adult = yes

	age <= 40

	this != scope:first
	reverse_opinion = {
		target = scope:first
		value <= neutral_opinion
	}
}

martial_authority.2040 = {
	type = character_event
	title = martial_authority.2040.t
	desc = martial_authority.2040.desc
	theme = martial_authority_focus
	override_background = {
		reference = army_camp
	}
	
	left_portrait = {
		character = scope:first
		animation = anger
	}
	right_portrait = {
		character = scope:second
		animation = rage
	}

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

		#Only trigger if we've been at war for at least a few days.
		days_of_continuous_war >= 5
		is_available_adult_or_is_commanding = yes

		any_knight = {
			martial_authority_2040_first_trigger = yes
		}
		any_knight = {
			martial_authority_2040_second_trigger = yes
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			add = { #-1 at 5 diplomacy, 0 at 10 diplomacy, 1 at 15 diplomacy etc.
				value = diplomacy
				subtract = medium_skill_rating
				multiply = 0.2
			}
		}
		upweight_for_focus_modifier = { FOCUS = martial_authority_focus }
	}

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

		random_knight = {
			limit = {
				martial_authority_2040_first_trigger = yes
			}
			save_scope_as = first
		}
		random_knight = {
			limit = {
				martial_authority_2040_second_trigger = yes
			}
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
			save_scope_as = second
		}
	}

	#Attempt to get the men to calm down and work together
	option = {
		name = martial_authority.2040.a
		duel = {
			skill = diplomacy
			value = 10
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = martial_authority.2040.a.success
				trigger_event = martial_authority.2041 #The men calm down.
				show_as_tooltip = {
					add_prestige = medium_prestige_gain
					add_martial_lifestyle_xp = medium_lifestyle_xp
					reverse_add_opinion = {
						target = scope:first
						modifier = respect_opinion
						opinion = low_positive_opinion
					}
					reverse_add_opinion = {
						target = scope:second
						modifier = respect_opinion
						opinion = low_positive_opinion
					}
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = martial_authority.2040.a.failure
				trigger_event = martial_authority.2042 #A brawl breaks out!
				show_as_tooltip = {
					add_prestige = minor_prestige_loss
				}
				custom_tooltip = martial_authority.2040.a.failure.tt
			}
		}
		stress_impact = {
			shy = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 100
				ai_compassion = 100
			}
			# Rational characters know when they have a good chance of winning the duel
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = {
					value = diplomacy
					add = -10
				}
				multiplier = 1000 # -10,000 at 0 Stewardship, +0 at 10 Stewardship, +10,000 at 20 Stewardship
			}
		}
	}

	#Have the soldiers whipped
	option = {
		name = martial_authority.2040.b
		add_dread = medium_dread_gain
		scope:first = {
			increase_wounds_effect = { REASON = whipping }
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = low_negative_opinion
			}
		}
		scope:second = {
			increase_wounds_effect = { REASON = whipping }
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = low_negative_opinion
			}
		}
		add_martial_lifestyle_xp = minor_lifestyle_xp
			stress_impact = {
				compassionate = medium_stress_impact_gain
				calm = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -100
				ai_vengefulness = 100
				ai_compassion = -200
			}
		}
	}

	#Leave the men to their petty quarrel
	option = {
		name = {
			text = martial_authority.2040.c
			trigger = {		
				NOR = {
					has_trait = hashishiyah
					has_trait = drunkard
				}
			}
		}
		name = {
			text = martial_authority.2040.c.hashishiyah
			trigger = { has_trait = hashishiyah }
		}
		name = {
			text = martial_authority.2040.c.drunkard
			trigger = { has_trait = drunkard }
		}
		add_prestige = miniscule_prestige_loss
		
		if = {
			limit = {
				OR = {
					has_trait = hashishiyah
					has_trait = drunkard
				}
			}
			add_stress = medium_stress_impact_loss
		}
		else = {
			stress_impact = {
				diligent = minor_stress_impact_gain
				just = minor_stress_impact_gain
				reclusive = minor_stress_impact_loss
			}
		}

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

#Men calm down
martial_authority.2041 = {
	type = character_event
	title = martial_authority.2041.t
		desc = martial_authority.2041.desc
		theme = martial_authority_focus
	override_background = {
		reference = army_camp
	}
	
	left_portrait = {
		character = scope:first
		animation = shame
	}
	right_portrait = {
		character = scope:second
		animation = worry
	}

	option = {
		name = martial_authority.2041.a
		add_prestige = medium_prestige_gain
			reverse_add_opinion = {
			target = scope:first
			modifier = respect_opinion
			opinion = low_positive_opinion
		}
		reverse_add_opinion = {
			target = scope:second
			modifier = respect_opinion
			opinion = low_positive_opinion
		}
		add_martial_lifestyle_xp = medium_lifestyle_xp
	}
}

#Brawl breaks out!
martial_authority.2042 = {
	type = character_event
	title = martial_authority.2042.t
		desc = martial_authority.2042.desc
	theme = martial_authority_focus
	override_background = {
		reference = army_camp
	}
	
	left_portrait = {
		character = scope:first
		animation = anger
	}
	right_portrait = {
		character = scope:second
		animation = rage
	}

	immediate = {
		play_music_cue = "mx_cue_combat_3"
	}
	
	option = {
		name = martial_authority.2042.a
		duel = {
			skill = prowess
			value = 15
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 4
					min = -49
				}
				desc = martial_authority.2042.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_authority.2042.a.success
					left_icon = root
					add_prestige = medium_prestige_gain
					add_martial_lifestyle_xp = medium_lifestyle_xp
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -4
					min = -49
				}
				desc = martial_authority.2042.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_authority.2042.a.failure
					left_icon = root
					increase_wounds_effect = { REASON = fight }
					add_martial_lifestyle_xp = miniscule_lifestyle_xp
				}
			}
		}

		stress_impact = {
				#Rare opportunity for certain character types to 'blow off some steam' and lose stress here, at risk of wounds.
				eccentric = medium_stress_loss
				wrathful = medium_stress_loss
				vengeful = medium_stress_loss
				sadistic = medium_stress_loss

				#Most characters won't want to do this, though.
				craven = major_stress_impact_gain
				calm = medium_stress_impact_gain
				patient = minor_stress_impact_gain
				forgiving = minor_stress_impact_gain
				compassionate = minor_stress_impact_gain
		}
			
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 100
				ai_vengefulness = 100
				ai_energy = 100
				ai_rationality = -100
			}
			# Rational characters know when they have a good chance of winning the duel
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = {
					value = prowess
					add = -15
				}
				multiplier = 1500 # -22,500 at 0 Prowess, +0 at 15 Prowess, +7,500 at 20 Prowess
			}
		}
	}

	option = {
		name = martial_authority.2042.b
		add_prestige = minor_prestige_loss
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 100
				ai_rationality = 100
			}
		}
	}
}

##################################################
# An Extra Hand: Find a right-hand (wo)man
# by Sean Hughes
# 2050 - 2057
##################################################

scripted_trigger martial_authority_2050_can_be_right_hand_person_trigger = {
	is_available_ai_adult = yes
	# Must not be the kind of person to ignore/defy your will.
	NOT = {
		has_trait = greedy
		has_trait = ambitious
		has_trait = lazy
		has_trait = arbitrary
	}
	opinion = {
		target = root
		value >= -15
	}

	# Not a baron; they're too insignificant!
	NOT = {
		highest_held_title_tier = 1
	}

	# Not your marshal (since they appear elsewhere in the event).
	NOR = {
		is_councillor_of = root
		has_council_position = councillor_marshal
	}

	# Not somebody else's right-hand person.
	NOT = { has_variable = is_right_hand_person_of }
}

# Gain a Right-Hand Person
martial_authority.2050 = {
	type = character_event
	title = martial_authority.2050.t
	desc = {
		desc = martial_authority.2050.desc.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:right_hand_person = {
						is_vassal_of = root
						is_landed = yes
					}
				}
				desc = martial_authority.2050.desc.vassal
			}
			triggered_desc = {
				trigger = {
					scope:right_hand_person = {
						is_knight_of = root
					}
				}
				desc = martial_authority.2050.desc.knight
			}
			desc = martial_authority.2050.desc.courtier
		}
		desc = martial_authority.2050.desc.ending
	}
	theme = martial_authority_focus

	left_portrait = {
		character = root
		animation = interested_left
	}
	right_portrait = {
		character = scope:right_hand_person
		animation = personality_bold
	}
	lower_right_portrait = scope:marshal

	trigger = {
		# Restricted to Authority and Adventurer lifestyle, because it's not really sensible for Chivalry or Strategy
		OR = {
			has_focus = martial_authority_focus 
			has_focus = martial_adventurer_focus
		}
		NOT = { has_variable = right_hand_person } # Does not already have a right-hand person.
		NOT = { has_character_flag = had_event_martial_authority_2050 } #Can only happen once every 5 years.

		# A valid character to become our right-hand person must exist.
		OR = {
			any_vassal = {
				martial_authority_2050_can_be_right_hand_person_trigger = yes
			}
			any_knight = {
				martial_authority_2050_can_be_right_hand_person_trigger = yes
			}
			any_courtier = {
				martial_authority_2050_can_be_right_hand_person_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = had_event_martial_authority_2050
			years = 5
		}

		every_vassal = {
			limit = {
				martial_authority_2050_can_be_right_hand_person_trigger = yes
			}
			add_to_temporary_list = potential_right_hand_people
		}
		every_knight = {
			limit = {
				martial_authority_2050_can_be_right_hand_person_trigger = yes
			}
			add_to_temporary_list = potential_right_hand_people
		}
		every_courtier = {
			limit = {
				martial_authority_2050_can_be_right_hand_person_trigger = yes
			}
			add_to_temporary_list = potential_right_hand_people
		}

		ordered_in_list = {
			list = potential_right_hand_people

			order_by = {
				value = {

					add = 1

					# More likely to pick somebody who has some amount of standing in your realm...
					if = {
						limit = {
							is_vassal_of = root
						}
						add = 15
						add = {
							add = highest_held_title_tier
							multiply = 2
						}
					}
					else_if = {
						limit = {
							is_knight_of = root
						}
						add = 10
					}

					# ...but less likely to pick somebody who is already very important.
					if = {
						limit = {
							OR = {
								is_councillor_of = root
								is_consort_of = root
								is_player_heir_of = root
							}
						}
						add = -25
					}
					else_if = {
						limit = {
							OR = {
								is_powerful_vassal_of = root
								is_player_heir_of = root
							}
						}
						add = -10
					}

					# More likely to pick someone who has respect for the 'rule of law'
					if = {
						limit = { has_trait = just }
						add = 10
					}
					if = {
						limit = { has_trait = content }
						add = 5
					}
					if = {
						limit = { has_trait = diligent }
						add = 5
					}
					if = {
						limit = { has_trait = arrogant }
						add = -5
					}
					if = {
						limit = { has_trait = fickle }
						add = -5
					}

					# More likely to pick someone who is friendly to you.
					if = {
						limit = {
							opinion = {
								target = root
								value >= 10
							}
						}
						add = 10
					}
					if = {
						limit = {
							opinion = {
								target = root
								value >= 25
							}
						}
						add = 5
					}

					# But not too friendly, otherwise the event is kind of inconsequential.
					if = {
						limit = {
							opinion = {
								target = root
								value >= 80
							}
						}
						add = -10
					}

					# Trait compatibility has a large impact on who gets picked.
					add = {
						add = 0
						if = {
							limit = {
								trait_compatibility = {
									target = root
									value >= high_positive_trait_compatibility
								}
							}
							add = 50
						}
						else_if = {
							limit = {
								trait_compatibility = {
									target = root
									value >= medium_positive_trait_compatibility
								}
							}
							add = 35
						}
						else_if = {
							limit = {
								trait_compatibility = {
									target = root
									value >= low_positive_trait_compatibility
								}
							}
							add = 15
						}
						else_if = {
							limit = {
								trait_compatibility = {
									target = root
									value >= low_negative_trait_compatibility
								}
							}
							add = -10
						}
						else = {
							add = -30
						}

						# Attraction Multiplier
                        if = {
                            limit = {
                                root = { is_attracted_to_gender_of = prev }
                                is_attracted_to_gender_of = root
                            }
                            multiply = 1.5
                        } 
					}

					# Slightly more likely to pick someone close to you in age.
					if = {
						limit = {
							age < age_compared_to_root_plus_ten
							age > age_compared_to_root_minus_ten
						}
						add = 5
					}
				}
			}
			save_scope_as = right_hand_person
		}

		# Save variables (for localization and death events).
		set_variable = {
			name = right_hand_person
			value = scope:right_hand_person
		}
		scope:right_hand_person = {
			set_variable = {
				name = is_right_hand_person_of
				value = root
			}
		}		

		# Save other relevant scopes.
		if = {
			limit = {
				exists = cp:councillor_marshal
			}
			cp:councillor_marshal = {
				save_scope_as = marshal
			}
		}
	}

	option = {
		name = martial_authority.2050.a

		# Gain semi-permanent character modifier (until RHP is unable or unwilling to continue serving you).
		send_interface_toast = {
			title = martial_authority.2050.toast.title
			left_icon = scope:right_hand_person
			add_character_modifier = {
				modifier = martial_authority_2050_right_hand_person_modifier
			}
		}

		# Mutual Opinion Increase with RHM.
		scope:right_hand_person = {
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}
		hidden_effect = {
			add_opinion = {
				modifier = pleased_opinion
				target = scope:right_hand_person
				opinion = 10
			}
			if = {
				limit = {
					NOT = { has_relation_potential_friend = scope:right_hand_person}
				}	
				set_relation_potential_friend = scope:right_hand_person
			}
		}
		primary_title = { #Scope change here to avoid tooltip grouping.
			custom_tooltip = martial_authority.2050.a.tt
		}

		stress_impact = {
			shy = medium_stress_gain
			paranoid = medium_stress_gain
		}

		trigger_event = {
			id = martial_authority.2051
			years = { 2 3 }
		}
	}

	option = {
		name = martial_authority.2050.b
		trigger = {
			exists = scope:marshal
		}

		# Larger Mutual opinion increase with Marshal.
		scope:marshal = {
			add_opinion = {
				modifier = trust_opinion
				target = root
				opinion = 20
			}
		}
		hidden_effect = {
			add_opinion = {
				modifier = trust_opinion
				target = scope:marshal
				opinion = 20
			}
		}

		# Remove unused event variables
		remove_variable = right_hand_person
		scope:right_hand_person = {
			remove_variable = is_right_hand_person_of
		}		
	}
	
	option = {
		name = martial_authority.2050.c

		# Gain large amount of Prestige at the cost of Stress.
		add_prestige = major_prestige_gain
		stress_impact = {
			base = medium_stress_gain
			diligent = minor_stress_loss
			lazy = major_stress_gain
			humble = minor_stress_gain
		}

		# Remove unused event variables
		remove_variable = right_hand_person
		scope:right_hand_person = {
			remove_variable = is_right_hand_person_of
		}
	}
}

# Become friends with your Right-Hand Person.
martial_authority.2051 = {
	type = character_event
	title = martial_authority.2051.t
	desc = martial_authority.2051.desc
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:right_hand_person
		animation = admiration
	}
	theme = martial_authority_focus
	
	trigger = {
		exists = var:right_hand_person
		var:right_hand_person = {
			is_alive = yes
			is_imprisoned = no
			opinion = {
				target = root
				value >= 15
			}
		}
		can_set_relation_friend_trigger = { CHARACTER = var:right_hand_person }
		NOR = {
			has_relation_lover = var:right_hand_person
			has_relation_soulmate = var:right_hand_person
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		# Transition right-hand person variable into an event scope.
		var:right_hand_person = {
			save_scope_as = right_hand_person
		}
	}

	option = {
		name = martial_authority.2051.a
		set_relation_friend = { reason = friend_right_hand_man target = scope:right_hand_person }
	}

	option = {
		name = martial_authority.2051.b
		trigger = {
			can_set_relation_lover_trigger = { CHARACTER = var:right_hand_person }
		}

		set_relation_lover = { reason = lover_right_hand target = scope:right_hand_person }
	}
	
	option = {
		name = martial_authority.2051.c
		add_prestige = minor_prestige_gain
		scope:right_hand_person = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 10
			}
		}
	}
}


# Right-Hand Person Imprisoned (by you)
martial_authority.2052 = {
	hidden = yes
	
	trigger = {
		exists = var:right_hand_person
		var:right_hand_person = {
			is_alive = yes
			is_imprisoned = yes
			exists = var:is_right_hand_person_of
		}
		scope:imprisoner = var:right_hand_person.var:is_right_hand_person_of
	}

	immediate = {
		var:right_hand_person.var:is_right_hand_person_of = {
			send_interface_message = {
				type = event_prison_neutral
				title = martial_authority.2052.message
				left_icon = var:right_hand_person
				remove_character_modifier = martial_authority_2050_right_hand_person_modifier
			}
		}
	}
}

# Right-Hand Person Imprisoned (by someone else)
martial_authority.2053 = {
	hidden = yes
	
	trigger = {
		exists = var:right_hand_person
		var:right_hand_person = {
			is_alive = yes
			is_imprisoned = yes
			exists = var:is_right_hand_person_of
			var:is_right_hand_person_of = {
				is_alive = yes
			}
		}
		NOT = { scope:imprisoner = var:right_hand_person.var:is_right_hand_person_of }
	}

	immediate = {
		var:right_hand_person.var:is_right_hand_person_of = {
			send_interface_message = {
				type = event_prison_neutral
				title = martial_authority.2053.toast
				left_icon = var:right_hand_person
				remove_character_modifier = martial_authority_2050_right_hand_person_modifier
			}
		}
	}
}

# Right-Hand Person Released from Prison
martial_authority.2054 = {
	hidden = yes
	
	trigger = {
		exists = var:is_right_hand_person_of
		var:is_right_hand_person_of = {
			is_alive = yes
		}
	}

	immediate = {
		var:is_right_hand_person_of = {
			var:right_hand_person = { save_scope_as = right_hand_person }
			send_interface_message = {
				type = event_prison_neutral
				title = martial_authority.2054.toast
				left_icon = scope:right_hand_person
				add_character_modifier = {
					modifier = martial_authority_2050_right_hand_person_modifier
				}
			}
		}
	}
}

# Right-Hand Person Dies
martial_authority.2055 = {
	hidden = yes
	trigger = {
		exists = var:is_right_hand_person_of
	}

	immediate = {
		var:is_right_hand_person_of = {
			send_interface_message = {
				type = event_generic_neutral
				title = martial_authority.2056.message
				left_icon = root
				remove_character_modifier = martial_authority_2050_right_hand_person_modifier
			}	

			hidden_effect = {
				remove_variable = right_hand_person
			}
		}
	}
}

# Right-Hand Person Leaves Service
martial_authority.2056 = {
	hidden = yes
	orphan = yes
	trigger = {
		exists = var:right_hand_person
		var:right_hand_person = {
			is_alive = yes
		}
	}

	immediate = {
		remove_character_modifier =  martial_authority_2050_right_hand_person_modifier

		scope:right_hand_person = {
			remove_variable = is_right_hand_person_of
		}
		remove_variable = right_hand_person
	}
}

# I Die (Cleans up variables on Right-Hand Person)
martial_authority.2057 = {
	hidden = yes
	trigger = {
		exists = var:right_hand_person
	}
	immediate = {
		var:right_hand_person = {
			remove_variable = is_right_hand_person_of
		}
	}
}

################################################################################################################################
################################################################################################################################

#############################
# AUTHORITY: SPECIAL EVENTS #
#############################

namespace = martial_authority_special

##############################
# Soldier & Officer fighting # by Mathilda Bjarnehed
##############################

martial_authority_special.1100 = {
	type = character_event
	title = martial_authority_special.1100.t
	desc = {
		desc = martial_authority_special.1100.start.desc
		random_valid = {
			desc = martial_authority_special.1100.heavy_infantry.desc
			desc = martial_authority_special.1100.cavalry.desc
			desc = martial_authority_special.1100.archer.desc
			desc = martial_authority_special.1100.skirmisher.desc
			desc = martial_authority_special.1100.pikemen.desc
		}
		desc = martial_authority_special.1100.end.desc
	}
	
	theme = martial_authority_focus
	override_background = {
		reference = alley_night
	}

	left_portrait = {
		character = root
		animation = scheme
		outfit_tags = { military_outfit }
	}
	right_portrait = {
		character = scope:officer
		animation = anger
        outfit_tags = { military_outfit }
	}

	trigger = {
		NOT = {
			location = { geographical_region = world_asia_china }
		}
		OR = {
			has_focus = martial_authority_focus
			has_focus = martial_adventurer_focus
		}
		NOT = { has_character_flag = had_event_martial_authority_special_1100 }
		num_of_relation_soldier_friend = 0
		any_knight = {
			basic_is_available_ai = yes
			ai_compassion <= low_positive_ai_value
		}
		OR = {
			exists = capital_province
			exists = location
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		hidden_effect = {
			add_character_flag = {
				flag = is_in_martial_special_event
				days = 200
			}
			add_character_flag = had_event_martial_authority_special_1100
			#Pick an officer
			random_knight = {
				limit = {
					basic_is_available_ai = yes
					ai_compassion <= low_positive_ai_value
				}
				weight = {
					base = 1
					modifier = {
						add = {
							value = ai_compassion
							multiply = -2
							if = {
								limit = { ai_compassion <= medium_negative_ai_value }
								multiply = 3
							}
						}
					}
					modifier = {
						add = {
							value = ai_boldness
							multiply = 1
						}
					}
				}
				save_scope_as = officer
			}
			#Create a hidden soldier
			if = {
				limit = {
					exists = root.capital_province
				}
				create_character = {
					gender_female_chance = root_soldier_female_chance
					location = root.capital_province
					template = soldier_friend_character
					save_scope_as = soldier_friend
					dynasty = generate
				}
			}
			else = {
				create_character = {
					gender_female_chance = root_soldier_female_chance
					location = root.location
					template = soldier_friend_character
					save_scope_as = soldier_friend
					dynasty = generate
				}
			}
		}
	}
	
	#Defend the soldier (fist fight)
	option = {
		name = martial_authority_special.1100.a

		duel = {
			skill = prowess
			target = scope:officer
			7 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -14
				}
				desc = martial_authority_special.1100.a.success.tt
				
				show_as_tooltip = {
					add_martial_lifestyle_perk_points = 1
				}
				trigger_event = martial_authority_special.1101
			}
			10 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.7
					min = -9
				}
				desc = martial_authority_special.1100.a.failure.tt
				trigger_event = martial_authority_special.1102
				show_as_tooltip = {
					martial_authority_special_1100_a_failure_effect = yes
				}
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			craven = medium_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_boldness_target_modifier = { VALUE = 50 }
			ai_compassion_target_modifier = { VALUE = 50 }
			modifier = {
				factor = 0
				has_trait_rank = {
					trait = wounded
					rank >= 3
				}
			}
		}
	}

	#Inspiring speech
	option = {
		name = martial_authority_special.1100.b
		trigger = { diplomacy >= high_skill_rating }
		skill = diplomacy
		show_as_tooltip = {
			add_martial_lifestyle_perk_points = 1
		}
		reverse_add_opinion = {
			target = scope:officer
			modifier = respect_opinion
			opinion = low_positive_opinion
		}

		trigger_event = martial_authority_special.1103

		ai_chance = {
			base = 100
			ai_compassion_target_modifier = { VALUE = 50 }
		}

		stress_impact = {
			shy = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
	}
	
	#Punish them both
	option = {
		name = martial_authority_special.1100.c

		add_dread = medium_dread_gain

		scope:officer = {
			increase_wounds_no_death_effect = { REASON = beaten }

			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = low_negative_opinion
			}
		}

		hidden_effect = {
			remove_character_flag = is_in_martial_special_event
		}
		
		scope:soldier_friend = {
			silent_disappearance_ai_effect = yes
		}

		ai_chance = {
			base = 50
			ai_compassion_target_modifier = { VALUE = -100 }
		}

		stress_impact = {
			compassionate = medium_stress_impact_gain
		}
	}

	#Claim the idea as your own
	option = {
		name = martial_authority_special.1100.d

		add_character_modifier = {
			modifier = innovative_strategy_modifier
			years = 15
		}

		hidden_effect = {
			remove_character_flag = is_in_martial_special_event
		}
		
		scope:soldier_friend = {
			silent_disappearance_ai_effect = yes
		}

		stress_impact = {
			honest = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_honor_target_modifier = { VALUE = -60 }
			ai_compassion_target_modifier = { VALUE = -40 }
		}
	}
}

#You won the duel
martial_authority_special.1101 = {
	type = character_event
	title = martial_authority_special.1100.t
	desc = {
		desc = martial_authority_special.1101.desc
		desc = martial_authority_special.1101.end.desc
	}
	
	theme = martial_authority_focus
	override_background = {
		reference = alley_night
	}

	left_portrait = {
		character = root
		animation = war_over_win
        outfit_tags = { military_outfit }
	}
	right_portrait = {
		character = scope:officer
		animation = shame
        outfit_tags = { military_outfit }
	}
	lower_left_portrait = {
		character = scope:soldier_friend
        outfit_tags = { military_outfit }
	}

	immediate = {
		martial_authority_special_1100_soldier_friend_effects_effect = yes
	}

	#Use their strategy
	option = {
		name = martial_authority_special.1101.a
		add_character_modifier = {
			modifier = innovative_strategy_modifier
			years = 15
		}
		add_martial_lifestyle_xp = medium_lifestyle_xp
	}

	#Talk it over
	option = {
		name = martial_authority_special.1101.b
		add_martial_lifestyle_perk_points = 1
	}
	
	after = {
		hidden_effect = {
			remove_character_flag = is_in_martial_special_event
		}
		scope:soldier_friend = {
			silent_disappearance_ai_effect = yes
		}
	}
}

#Duel lost
martial_authority_special.1102 = {
	type = character_event
	title = martial_authority_special.1100.t
	desc = martial_authority_special.1102.desc
	
	theme = martial_authority_focus
	override_background = {
		reference = alley_night
	}

	left_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:officer
		animation = dismissal
        outfit_tags = { military_outfit }
	}

	immediate = {
		martial_authority_special_1100_a_failure_effect = yes
	}

	option = {
		name = martial_authority_special.1102.a
		add_character_modifier = {
			modifier = fought_a_seasoned_warrior
			days = 1825
		}
		add_martial_lifestyle_xp = minor_lifestyle_xp
	}

	after = {
		hidden_effect = {
			remove_character_flag = is_in_martial_special_event
		}
		scope:soldier_friend = {
			silent_disappearance_ai_effect = yes
		}
	}
}

#Your speech worked
martial_authority_special.1103 = {
	type = character_event
	title = martial_authority_special.1100.t
	desc = {
		desc = martial_authority_special.1103.desc
		desc = martial_authority_special.1101.end.desc
	}
	theme = martial_authority_focus
	override_background = {
		reference = alley_night
	}

	left_portrait = {
		character = root
		animation = toast
	}
	right_portrait = {
		character = scope:soldier_friend
		animation = happiness
        outfit_tags = { military_outfit }
	}
	lower_right_portrait = {
		character = scope:officer
        outfit_tags = { military_outfit }
	}

	immediate = {
		martial_authority_special_1100_soldier_friend_effects_effect = yes
	}

	#Use their strategy
	option = {
		name = martial_authority_special.1101.a
		add_character_modifier = {
			modifier = innovative_strategy_modifier
			years = 15
		}
		add_martial_lifestyle_xp = medium_lifestyle_xp
	}

	#Talk it over
	option = {
		name = martial_authority_special.1101.b
		add_martial_lifestyle_perk_points = 1
	}
	
	after = {
		hidden_effect = {
			remove_character_flag = is_in_martial_special_event
		}
		scope:soldier_friend = {
			silent_disappearance_ai_effect = yes
		}
	}
}

######################
# Deserting Soldier  # by Linnéa Thimrén, rewritten by Arkadiusz Majewski
######################

#Your knight wants to desert because of a PTSD
martial_authority_special.1501 = {
	type = character_event
	title = martial_authority_special.1501.t
	desc = {
		desc = martial_authority_special.1501.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:desertion_reason = flag:raid }
				desc = martial_authority_special.1501.desc_raid
			}
			desc = martial_authority_special.1501.desc_battle
		}
		desc = martial_authority_special.1501.desc_outro
	}
	
	theme = martial_authority_focus
	override_background = {
		reference = ce1_funeral_pyre
	}
	
	cooldown = { years = 10 }

	left_portrait = {
		character = root
		animation = worry
		outfit_tags = { military_outfit }
	}
	right_portrait = {
		character = scope:deserting_soldier
		animation = delirium
		outfit_tags = { military_outfit }
	}
	
	trigger = {
		NOT = { has_character_flag = is_in_martial_special_event }
		OR = {
			has_focus = martial_authority_focus
			has_focus = martial_adventurer_focus
		}
		OR = {
			any_relation = {
				type = soldier_friend
				save_temporary_scope_as = deserting_soldier_temp
			}
			any_courtier_or_guest = {
				NOT = { this = root }
				is_ai = yes
				is_adult = yes
				is_knight_of = root
				save_temporary_scope_as = deserting_soldier_temp
			}
		}
		OR = {
			location = {
				has_province_modifier = recently_looted_modifier
			}
			any_memory = {
				has_memory_type = battle_lost_memory
				var:battle_location = root.location
				memory_age_years < 1
			}
			scope:deserting_soldier_temp = {
				any_memory = {
					has_memory_type = battle_lost_memory
					var:battle_location = root.location
					memory_age_years < 1
				}
			}
		}
	}

	immediate = {
		location = {
			save_scope_as = ravaged_place
		}
		if = {
			limit = {
				location = {
					has_province_modifier = recently_looted_modifier
				}
			}
			save_scope_value_as = {
				name = desertion_reason
				value = flag:raid
			}
		}
		else = {
			save_scope_value_as = {
				name = desertion_reason
				value = flag:battle
			}
		}
		if = {
			limit = {
				any_relation = {
					type = soldier_friend
					is_councillor = no
				}
			}
			hidden_effect = {
				random = {
					chance = 25
					random_relation = {
						type = soldier_friend
						save_scope_as = deserting_soldier # Oh no, your soldier_friend is among the deserters!
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:deserting_soldier }
			}
			ordered_courtier_or_guest = {
				order_by = ai_honor
				limit = {
					trigger_if = {
						limit = {
							scope:desertion_reason = flag:battle
						}
						any_memory = {
							has_memory_type = battle_lost_memory
							var:battle_location = location
							memory_age_years < 1
						}
					}
					this != root
					is_ai = yes
					is_adult = yes
					is_knight_of = root
				}
				save_scope_as = deserting_soldier
			}
		}
	}

	option = {
		name = martial_authority_special.1501.a
		flavor = martial_authority_special.1501.a_tt
		duel = {
			skill = martial
			target = scope:deserting_soldier
			20 = {
				desc = martial_authority_special.1501.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = 1
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_authority_special.1501.a.success
					left_icon = scope:deserting_soldier
					right_icon = root
					add_martial_lifestyle_perk_points = 1
					scope:deserting_soldier = {
						add_opinion = {
							modifier = comforted_opinion
							opinion = 15
							target = root
							years = 5
						}
					}
				}
			}
			20 = {
				desc = martial_authority_special.1501.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.25
					min = -4
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_authority_special.1501.a.failure
					left_icon = scope:deserting_soldier
					right_icon = root
					add_character_modifier = {
						modifier = decreased_levies_modifier
						days = 1825
					}
					scope:deserting_soldier = {
						add_opinion = {
							modifier = doubted_me
							opinion = -30
							target = root
						}
					}
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}

	#I allievate you from responsibilites
	option = {
		name = martial_authority_special.1501.b
		scope:deserting_soldier = {
			set_knight_status = forbid
			add_opinion = {
				modifier = helped_me_in_time_of_need
				opinion = 30
				target = root
				years = 5
			}
			hidden_effect = { # removes soldier_friend and adds them as a friend so that they will not be used in future warfare events
				remove_relation_soldier_friend = root
				if = {
					limit = {
						can_set_relation_friend_trigger = { CHARACTER = root }
					}
					set_relation_friend = { reason = friend_spared target = root }
				}
			}
		}
		if = {
			limit = {
				can_add_hook = {
					type = obligation_hook
					target = scope:deserting_soldier
				}
			}
			add_hook = {
				type = obligation_hook
				target = scope:deserting_soldier
			}
			add_stress = minor_stress_loss
		}
		else = {
			add_stress = medium_stress_loss
		}
		stress_impact = {
			compassionate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 100
				has_trait = compassionate
			}
		}
	}

	#snap out of it
	option = {
		name = martial_authority_special.1501.c
		add_martial_lifestyle_xp = minor_lifestyle_xp
		scope:deserting_soldier = {
			add_opinion = {
				modifier = let_me_down_opinion
				opinion = -15
				target = root
			}
			hidden_effect = { # removes soldier_friend and adds them as a friend so that they will not be used in future warfare events
				remove_relation_soldier_friend = root
				if = {
					limit = {
						can_set_relation_friend_trigger = { CHARACTER = root }
					}
					set_relation_friend = { reason = friend_spared target = root }
				}
			}
		}
		ai_chance = {
			base = 10
		}
	}
}

##########################################################################
# Displaying/Teaching Authority to Someone (Find a way to impress someone)
##########################################################################
# by Milla Isaksson
#####################

scripted_trigger martial_authority_special_friend_trigger = {	
	OR = {
		AND = {
			OR = {
				has_trait = overseer
				AND = {
					exists = root.var:right_hand_person
					this = root.var:right_hand_person
				}
			}
			is_available_ai_adult = yes
		}
		AND = {
			is_child_of = root
			age >= 10
			is_available_ai = yes
		}
	}
}

martial_authority_special.3000 = {
	type = character_event
	title = martial_authority_special.3000.t
	desc = martial_authority_special.3000.desc

	left_portrait = {
		character = root
		animation = interested_left
	}
	right_portrait = {
		character = scope:martial_authority_friend
		animation = inspect_weapon
	}
	theme = martial_authority_focus

	trigger = {
		NOT = { has_character_flag = had_event_martial_authority_3000 } #Can only happen once every 5 years
		OR = {
			any_vassal = {
				martial_authority_special_friend_trigger = yes
			}
			any_knight = {
				martial_authority_special_friend_trigger = yes
			}
			any_courtier_or_guest = {
				martial_authority_special_friend_trigger = yes
			}
		}

		exists = capital_province
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_martial_authority_3000
			days = 1825
		}

		if = {
			limit = {
				NOT = {
					any_relation = {
						type = friend
						is_available = yes
						lifestyle_friend_trigger = { CHARACTER = root FOCUS = martial_authority_focus }
					}
				}
			}
			potential_lifestyle_friend_saving_effect = { FOCUS = martial_authority_focus SCOPE_NAME = martial_authority_friend }

		}
		else = {
			random_relation = {
				type = friend
				limit = {
					is_available = yes
					lifestyle_friend_trigger = { CHARACTER = root FOCUS = martial_authority_focus }
					exists = root.var:right_hand_person
					this = root.var:right_hand_person
				}
				alternative_limit = {
					is_available = yes
					lifestyle_friend_trigger = { CHARACTER = root FOCUS = martial_authority_focus }
				}
				save_scope_as = martial_authority_friend
			}
		}
	}

	option = { # Talk about the importance of communication
		name = martial_authority_special.3000.a
		
		add_martial_lifestyle_xp = minor_lifestyle_xp
		
		reverse_add_opinion = {
			target = scope:martial_authority_friend
			modifier = respect_opinion
			opinion = low_positive_opinion
		}		

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
			}
			modifier = {
				factor = 1.5
				has_trait_extroverted_trigger = yes
			}
		}
	}

	option = { # Take a walk among your soldiers
		name = martial_authority_special.3000.b

		add_martial_lifestyle_xp = minor_lifestyle_xp
		
		if = {
			limit = {
				has_government = landless_adventurer_government
			}
			add_character_modifier = {
				modifier = ep3_loyal_troops_raid_modifier
				years = 2
			}
		}
		else = {
			capital_province = {
				add_province_modifier = { modifier = respected_figurehead years = 2 }
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 1.5
				has_trait_benevolent_trigger = yes
			}
		}
	}
	
	after = {
		scope:martial_authority_friend = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}



###     Innovate with weaponry    ###
### martial_authority 4000 - 4005 ###
###       by Nick Meredith        ###

#Find a tool in an armoury
martial_authority.4000 = {
	type = character_event
	title = martial_authority.4000.t
	desc = martial_authority.4000.desc
	theme = martial_authority_focus
	
	cooldown = { years = 10 }
	
	override_background = {
		reference = armory
	}

	left_portrait = {
		character = root
		animation = boredom
	}
		
	trigger = {
		has_lifestyle = martial_lifestyle
		is_ruler = yes
		is_landed = yes
		has_dlc_feature = royal_court
		any_held_title = {
			title_tier = county
			title_province = {
				OR = {
					terrain = farmlands
					terrain = plains
					terrain = floodplains
					terrain = oasis
				}
			}
		}
	}

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

	#Take a look at the weapon
	option = {
		name = martial_authority.4000.a

		custom_tooltip = {
			text = martial_authority.4000.a.tt
		}

		trigger_event = {
			id = martial_authority.4001
			days = { 3 10 }
		}
	}

	#Discard option
	option = {
		name = martial_authority.4000.b

		custom_tooltip = {
			text = martial_authority.4000.b.tt
		}

		stress_impact = {
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}
}


#Choose what you want to turn the tool into
martial_authority.4001 = {
	type = character_event
	title = martial_authority.4001.t
	desc = martial_authority.4001.desc
	theme = martial_authority_focus
	override_background = {
		reference = armory
	}

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	immediate = { #Make a blacksmith for the next event in the chain
		create_character = {
			gender_female_chance = root_faith_dominant_gender_female_chance
			culture = root.culture
			faith = root.faith
			trait = diligent #it has a blacksmith's hammer!
			random_traits = yes
			dynasty = none
			employer = root
			save_scope_as = blacksmith
		}
	}

	#Repurpose into a dagger
	option = {
		name = martial_authority.4001.a
		flavor = martial_authority.4001.a.tt

		random_list = {
			75 = {
				trigger_event = {
					id = martial_authority.4002
					days = { 7 21 }
				}

				modifier = {
					add = -2
					has_trait = lazy
				}

				modifier = {
					add = 2
					has_trait = diligent
				}

				modifier = {
					add = 5
					learning > 10
				}

				modifier = {
					add = 5
					martial > 10
				}

				modifier = {
					add = 10
					has_trait = intellect_good
				}

				modifier = {
					add = 30
					prowess > 15
				}

				modifier = {
					add = 50
					has_trait = lifestyle_blademaster
				}

				custom_tooltip = {
					text = martial_authority_4001.dagger.tt
				}
			}

			25 = {
				send_interface_toast = {
					title = martial_authority.4001.b.failure
					left_icon = root
				}

				custom_tooltip = {
					text = martial_authority_4001.fail.tt
				}			
			}
		}

		ai_chance = {
			base = 100
		}
	}

	#Repurpose into a halberd
	option = {
		name = martial_authority.4001.b
		flavor = martial_authority.4001.b.tt

		random_list = {
			50 = {
				trigger_event = {
					id = martial_authority.4003
					days = { 7 21 }
				}

				modifier = {
					add = -2
					has_trait = lazy
				}

				modifier = {
					add = 2
					has_trait = diligent
				}

				modifier = {
					add = 2
					learning > 10
				}

				modifier = {
					add = 2
					martial > 10
				}

				modifier = {
					add = 5
					has_trait = intellect_good
				}

				modifier = {
					add = 20
					prowess > 15
				}

				modifier = {
					add = 40
					has_trait = lifestyle_blademaster
				}

				custom_tooltip = martial_authority_4001.halberd.tt
			}

			50 = {
				send_interface_toast = {
					title = martial_authority.4001.b.failure
					left_icon = root
					custom_tooltip = martial_authority_4001.fail.tt
				}
			}
		}

		ai_chance = {
			base = 100
		}
	}

	#Keep it as-is
	option = {
		name = martial_authority.4001.c
		flavor = martial_authority.4001.c.tt

		custom_tooltip = martial_authority_4001.billhook.tt

		trigger_event = {
			id = martial_authority.4004
			days = { 7 21 }
		}
		
		ai_chance = {
			base = 100
		}
	}
}

#You've made an improvised dagger!
martial_authority.4002 = {
	type = character_event
	title = martial_authority.4002.t
	desc = martial_authority.4002.desc
	theme = martial_authority_focus
	override_background = {
		reference = armory
	}

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	right_portrait = {
		character = scope:blacksmith
		animation = personality_content
	}

	#Collect artifact
	option = {
		name = martial_authority.4002.a

		trigger = {
			NOT = {
				has_character_flag = improvised_dagger
			}
		}

		create_artifact = {
			name = improvised_dagger
			description = improvised_dagger_desc
			type = dagger
			visuals = dagger
			modifier = artifact_prowess_1_modifier
			save_scope_as = improvised_dagger
		}

		add_martial_lifestyle_xp = medium_lifestyle_xp

		hidden_effect = {
			scope:improvised_dagger = {
				set_max_durability = 25
				set_artifact_rarity_common = yes
				flag_as_trash_artifact = yes
			}
		}

		add_character_flag = {
			flag = improvised_dagger
			years = 5
		}

		ai_chance = {
			base = 100
		}
	}

	#Second option if you've already had this event
	option = {
		name = martial_authority.4002.b

	add_martial_lifestyle_xp = medium_lifestyle_xp

		add_character_modifier = {
			modifier = repurposed_billhook_dagger
			years = 5
		}

		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:blacksmith = {
		silent_disappearance_effect = yes
		}
	}
}

#You've made an improvised halberd!
martial_authority.4003 = {
		type = character_event
		title = martial_authority.4003.t
		desc = martial_authority.4003.desc
		theme = martial_authority_focus
		override_background = {
			reference = armory
		}

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	right_portrait = {
		character = scope:blacksmith
		animation = personality_content
	}

	#Collect rewards
	option = {
		name = martial_authority.4003.a

		trigger = {
			NOT = {
				has_character_flag = improvised_halberd
			}
		}

		create_artifact = {
			name = improvised_halberd
			description = improvised_halberd_desc
			type = spear
			visuals = spear
			modifier = artifact_prowess_1_modifier
			save_scope_as = improvised_halberd 
		}

		add_martial_lifestyle_xp = medium_lifestyle_xp

		hidden_effect = {
			scope:improvised_halberd = {
				set_max_durability = 25
				set_artifact_rarity_common = yes
				flag_as_trash_artifact = yes
			}
		}

		add_character_flag = {
			flag = improvised_halberd
			years = 5
		}

		ai_chance = {
			base = 100
		}
	}

	#Second option if you've already had this event
	option = {
		name = martial_authority.4003.b

		add_martial_lifestyle_xp = medium_lifestyle_xp

		add_character_modifier = {
			modifier = repurposed_billhook_halberd
			years = 5
		}

		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:blacksmith = {
			silent_disappearance_effect = yes
		}
	}
}

#You've 'made' a billhook!
martial_authority.4004 = {
		type = character_event
		title = martial_authority.4004.t
		desc = martial_authority.4004.desc
		theme = martial_authority_focus
		override_background = {
			reference = armory
		}

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	right_portrait = {
		character = scope:blacksmith
		animation = personality_content
	}

	#Collect rewards
	option = {
		name = martial_authority.4004.a

		trigger = {
			NOT = {
				has_character_flag = improvised_billhook
			}
		}

		add_martial_lifestyle_xp = medium_lifestyle_xp

		create_artifact = {
			name = improvised_billhook
			description = improvised_billhook_desc
			type = dagger
			visuals = dagger
			modifier = artifact_prowess_1_modifier
			modifier = artifact_levy_reinforcement_rate_1_modifier
			modifier = artifact_monthly_prestige_penalty_modifier
			save_scope_as = improvised_billhook
		}

		hidden_effect = {			
			scope:improvised_billhook = {
				set_max_durability = 25
				set_artifact_rarity_common = yes
				flag_as_trash_artifact = yes
			}
		}

		add_character_flag = {
			flag = improvised_billhook
			years = 5
		}

		ai_chance = {
			base = 100
		}
	}

	#Second option if you've already had this event
	option = {
		name = martial_authority.4004.b

		add_martial_lifestyle_xp = medium_lifestyle_xp

		add_character_modifier = {
			modifier = repurposed_billhook_billhook
			years = 5
		}

		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:blacksmith = {
			silent_disappearance_effect = yes
		}
	}
}
