﻿#Events for strategy lifestyle focus

#STRATEGY REGULAR EVENTS
	# 1051 		- Well-known commander, by Sean Hughes
	# 2000		- Translate old texts (Learning skill challenge), Mathilda Bjarnehed
	# 2020-2022	- Developing cunning/manipulative tactics (Intrigue skill challenge), Sean Hughes
	# 2030-2032	- Logistics and securing provisions (Stewardship skill challenge), Sean Hughes
	# 3010-3014	- Decide between two vassal's proposed strategies for a war, Sean Hughes

#STRATEGY SPECIAL EVENTS
	# 1301-1399	- Storm Your Own Castle, by Linnéa Thimrén
	# 1401-1499	- March gone awry, by Petter Vilberg


############################
# STRATEGY: REGULAR EVENTS #
############################

namespace = martial_strategy

##################################################
# General Gossip
# by Sean Hughes
# 1051
##################################################

martial_strategy.1051 = {
	type = character_event
	title = martial_strategy.1051.t
	desc = martial_strategy.1051.desc
	theme = martial_strategy_focus
	override_background = {
		event_background = armory
	}

	left_portrait = root

	trigger = {
		#Character must be experienced strategist
		OR = {
			has_trait = strategist
			has_trait = gallant
		}

		#Character needs at least two event options available to get this
		calc_true_if = {
			amount >= 2
			has_trait = brave
			has_trait = wrathful
			has_trait = sadistic
			has_trait = zealous
			OR = {
				has_trait = patient
				AND = {
					has_trait = calm
					NOT = { has_trait = impatient}
				}
			}
			OR = {
				has_trait = callous
				AND = {
					has_trait = ambitious
					NOR = {
						has_trait = impatient
						has_trait = sadistic
					}
				}
			}
		}
		#Only once per character.
		NOT = {
			has_character_flag = had_event_martial_strategy_1051
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = { #-1 at 5 martial, 0 at 10 martial, 1 at 15 martial etc.
				value = martial
				subtract = medium_skill_rating
				multiply = 0.2
			}
		}

		#More available event options make a more interesting event, so we increase the chance of this occuring.
		modifier = {
			has_trait = brave
			add = 0.2
		}
		modifier = {
			has_trait = wrathful
			add = 0.2
		}
		modifier = {
			has_trait = zealous
			add = 0.2
		}
		modifier = {
			has_trait = calm
			add = 0.2
		}
		modifier = {
			has_trait = callous
			add = 0.2
		}
		modifier = {
			has_trait = patient
			add = 0.2
		}
		modifier = {
			has_trait = ambitious
			add = 0.2
		}
		modifier = {
			has_trait = sadistic
			add = 0.5 # Sadistic modifies 2 options, so it's weighted heavier than the others.
		}

		modifier = {
			OR = {
				has_any_nickname = no
				has_bad_nickname = yes
			}
			factor = 0.2
		}
		upweight_for_focus_modifier = { FOCUS = martial_strategy_focus }
	}

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

	#Option A: Gain prestige for simply being good at what you do.
	option = {
		#Special option text if Humble.
		name = {
			trigger = { has_trait = humble }
			text = martial_strategy.1051.a.humble
		}
		name = {
			trigger = { NOT = { has_trait = humble }}
			text = martial_strategy.1051.a
		}

		#Being Humble or Arrogant is in-line with this option's flavor text.
		trait = humble
		trait = arrogant

		#Lesser effect for being Humble, since this event is all about bolstering your reputation.
		if = {
			limit = {
				has_trait = humble
			}
			add_prestige = minor_prestige_gain
		}
		else_if = {
			limit = {
				has_trait = arrogant
			}
			set_nickname_effect = { NICKNAME = nick_the_imperious }
			add_prestige = major_prestige_gain
		}
		else = {
			add_prestige = medium_prestige_gain
		}
	}

	#Option B: Gain a defensive character modifier for being Brave/Unyielding Defender.
	option = {
		#Special option text if you are Unyielding Defender.
		name = {
			trigger = {	NOT = { has_trait = unyielding_defender }}
			text = martial_strategy.1051.b.brave
		}
		name = {
			trigger = {
				has_trait = unyielding_defender
			}
			text = martial_strategy.1051.b.stalwart
		}

	 	#Must be Brave for this option to appear.
		trigger = {
			has_trait = brave
		}
		trait = brave
		trait = unyielding_defender

		if = {
			#If we're Unyielding Defender, we gain a special nickname as well as gaining the modifier for an extended duration.
			limit = {
				has_trait = unyielding_defender
			}
			set_nickname_effect = { NICKNAME = nick_the_stalwart }
			add_character_modifier = {
				modifier = warfare_unshakable_reputation_modifier
				years = 20
			}
		}
		else = {
			#Otherwise gain a normal nickname and standard duration modifier
			set_nickname_effect = { NICKNAME = nick_the_brave }
			add_character_modifier = {
				modifier = warfare_unshakable_reputation_modifier
				years = 10
			}
		}
	
	}

	#Option C: Gain an offensive character modifier for being Wrathful/Sadistic/Aggressive Attacker.
	option = {
		#If we're Sadistic, we get special event text for this choice.
		name = {
			trigger = { has_trait = sadistic }
			text = martial_strategy.1051.c.feareater
		}
		name = {
			trigger = {	NOT = { has_trait = sadistic }}
			text = martial_strategy.1051.c.wrathful
		}

		#Must be Wrathful and not Craven for this option to appear.
		trigger = {
			OR = {
				has_trait = wrathful
			}
			NOT = { has_trait = craven }
		}
		trait = wrathful
		trait = sadistic
		
		if = {
			#If we're also Sadistic, we get a special nickname and as well as gaining the modifier for an extended duration.
			limit = {
				has_trait = sadistic
			}
			set_nickname_effect = { NICKNAME = nick_feareater }

			add_character_modifier = {
				modifier = warfare_ferocious_reputation_modifier
				years = 20
			}
		}
		else = {
			#Otherwise, we get a different nickname and the modifier for a normal duration.
			set_nickname_effect = { NICKNAME = nick_the_fury }

			add_character_modifier = {
				modifier = warfare_ferocious_reputation_modifier
				years = 10
			}
		}
	}

	#Option D: Gain piety, or lose piety to gain dread for being Zealous/Sadistic
	option = {
		#Option text dependant on what comination of traits you have.
		name = {
			trigger = {
				has_trait = zealous
				NOT = { has_trait = sadistic }
			}
			text = martial_strategy.1051.d.zealous
		}
		name = {
			trigger = {
				has_trait = sadistic
				has_trait = zealous
			}
			text = martial_strategy.1051.d.zealoussadistic
		}
		name = {
			trigger = {
				has_trait = sadistic
				NOT = { has_trait = zealous }
			}
			text = martial_strategy.1051.d.sadistic
		}

		#Must have at least one of these two traits.
		trigger = {
			OR = {
				has_trait = zealous
				has_trait = sadistic
			}
		}
		trait = sadistic
		trait = zealous


		if = {
			#If both Sadistic and Zealous, we gain both Piety and Dread as well as a special nickname.
			limit = {
				has_trait = sadistic
				has_trait = zealous
			}

			set_nickname_effect = { NICKNAME = nick_the_merciless }

			add_piety = major_piety_gain
			add_dread = major_dread_gain
		}
		else_if = {
			#If Sadistic, we lose some Piety but gain Dread.
			limit = {
				has_trait = sadistic
			}

			set_nickname_effect = { NICKNAME = nick_the_merciless }

			add_piety = miniscule_piety_loss
			add_dread = major_dread_gain	
		}
		else = {
			#If only Zealous, we can some Piety.
			set_nickname_effect = { NICKNAME = nick_the_holy }
			add_piety = major_piety_gain
		}
	}

	option = {
		name = martial_strategy.1051.e.patient
		trigger = {
			OR = {
				has_trait = patient
				AND = {
					has_trait = calm
					NOT = { has_trait = impatient }
				}
			}
		}
		trait = patient
		trait = calm

		set_nickname_effect = { NICKNAME = nick_the_hawk }
		add_prestige = medium_prestige_gain
		add_stress = medium_stress_loss
	}

	option = {
		name = martial_strategy.1051.f.ambitious
		trigger = {
			OR = {
				has_trait = callous
				AND = {
					has_trait = ambitious
					NOR = {
						has_trait = sadistic
						has_trait = compassionate
					}
				}
			}
		}
		trait = callous
		trait = ambitious

		set_nickname_effect = { NICKNAME = nick_the_unrelenting }
		add_prestige = medium_prestige_gain
		add_dread = minor_dread_gain
	}
}


#Texts on old battles
	#by Mathilda Bjarnehed
#Read an old scroll or a newer tome?
martial_strategy.2000 = {
	type = character_event
	title = martial_strategy.2000.t
	desc = {
		desc = martial_strategy.2000.start.desc
		random_valid = {
			triggered_desc = {
				trigger = {
					game_start_date >= 1066.10.15
					location = { geographical_region = world_europe }
				}
				desc = martial_strategy.2000.hastings.desc
			}
			triggered_desc = {
				trigger = {
					location = {
						NOR = {
							geographical_region = world_india
							geographical_region = world_steppe
						}
					}
					NOT = { faith = { religion_tag = islam_religion } }
				}
				desc = martial_strategy.2000.tours.desc
			}
			triggered_desc = {
				trigger = {
					location = {
						NOR = {
							geographical_region = world_india
							geographical_region = world_steppe
						}
					}
					faith = { religion_tag = islam_religion }
				}
				desc = martial_strategy.2000.palaceofthemartyrs.desc #(tours but arabic name!)
			}
			triggered_desc = {
				trigger = {
					location = {
						NOR = {
							geographical_region = world_india
							geographical_region = world_steppe
						}
					}
				}
				desc = martial_strategy.2000.catalaunianplains.desc #Not India/plains
			}
			desc = martial_strategy.2000.constantinople.desc
			triggered_desc = {
				trigger = {
					location = {
						NOR = {
							geographical_region = world_europe
							geographical_region = world_africa
						}
					}
				}
				desc = martial_strategy.2000.vapati.desc
			}
		}
		desc = martial_strategy.2000.end.desc
	}
	theme = martial_strategy_focus
	override_background = {
		event_background = study
	}
	
	left_portrait = root

	trigger = {
		NOR = {
			has_character_flag = had_event_martial_strategy_2000
			has_character_modifier = studied_the_battle_of_gaixia
			has_character_modifier = studied_the_battle_of_red_cliffs
			has_character_modifier = studied_the_battle_of_thermopylae
			has_character_modifier = studied_the_battle_of_teutoburg_forest
			has_character_modifier = studied_an_old_battle
			has_character_modifier = studying_ancient_texts
		}
		NOT = { has_character_modifier = studied_an_old_battle }
	}
	

	weight_multiplier = {
		base = 1
		modifier = {
			add = { #-1 at 5 learning, 0 at 10 learning, 1 at 15 learning etc.
				value = learning
				subtract = medium_skill_rating
				multiply = 0.2
			}
		}
		modifier = { #Because the modifiers are awesome when you're commanding
			is_at_war = yes
			add = 1
		}
		upweight_for_focus_modifier = { FOCUS = martial_strategy_focus }
	}

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

	#Just read the new one
	option = {
		name = martial_strategy.2000.a

		add_character_modifier = {
			modifier = studied_an_old_battle
			years = 10
		}

			stress_impact = {
				diligent = minor_stress_impact_gain
		}

		ai_chance = {	
			base = 100
			modifier = {
				has_trait = diligent
				add = -90
			}
			modifier = {
				add = {
					value = learning
					subtract = 10
					multiply = -10
				}
			}
		}
	}

	#Try to translate the old book
	option = {
		name = martial_strategy.2000.b
		duel = {
			skill = learning
			value = medium_skill_rating
			desc = outcome_in_a_few_days
			60 = {		
				desc = martial_strategy.2000.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 5
				}
				show_as_tooltip = {
					add_martial_lifestyle_xp = medium_lifestyle_experience #Must match in 2000, 2001 and 2002
				}
				custom_tooltip = martial_strategy.2000.b.success.tt
				trigger_event = { id = martial_strategy.2001 days = 5 } #You uncover old knowledge!
				
			}
			40 = {		
				desc = martial_strategy.2000.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -5
				}
				custom_tooltip = martial_strategy.2000.b.failure.tt
				trigger_event = { id = martial_strategy.2002 days = 5 } #You fail to read the text
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}	

		ai_chance = {	
			base = 100
			modifier = {
				OR = {
					has_trait = lazy
					has_trait = impatient
				}
				add = -90
			}
			modifier = {
				add = {
					value = learning
					subtract = 10
					multiply = 10
				}
			}
		}
	}
}

#You translated the book and gained ancient knowledge!
martial_strategy.2001 = {
	type = character_event
	title = martial_strategy.2000.t
	desc = {
		desc = martial_strategy.2001.start.desc
		random_valid = {
			triggered_desc = {
				trigger = { var:ancient_battle = flag:gaixia }
				desc = martial_strategy.2001.gaixia.desc
			}
			triggered_desc = {
				trigger = { var:ancient_battle = flag:red_cliffs }
				desc = martial_strategy.2001.red_cliffs.desc
			}
			triggered_desc = {
				trigger = { var:ancient_battle = flag:thermopylae }
				desc = martial_strategy.2001.thermopylae.desc
			}
			triggered_desc = {
				trigger = { var:ancient_battle = flag:teutoburg_forest }
				desc = martial_strategy.2001.teutoburg_forest.desc
			}
			#triggered_desc = {
			#	trigger = { var:ancient_battle = flag:cannae }
			#	desc = martial_strategy.2001.cannae.desc
			#}
			#triggered_desc = {
			#	trigger = { var:ancient_battle = flag:gaugamela }
			#	desc = martial_strategy.2001.gaugamela.desc
			#}
		}
	}
	theme = martial_strategy_focus
	override_background = {
		event_background = study
	}

	left_portrait = root
	
	immediate = {
		hidden_effect = {
			#Which battle did you read about?
			random_list = {
				1 = {
					modifier = {
						factor = 0
						has_character_modifier = studied_the_battle_of_gaixia
					}
					set_variable = { name = ancient_battle value = flag:gaixia }
				}
				1 = {
					modifier = {
						factor = 0
						has_character_modifier = studied_the_battle_of_red_cliffs
					}
					set_variable = { name = ancient_battle value = flag:red_cliffs }
				}
				1 = {
					modifier = {
						factor = 0
						has_character_modifier = studied_the_battle_of_thermopylae
					}
					set_variable = { name = ancient_battle value = flag:thermopylae }
				}
				1 = {
					modifier = {
						factor = 0
						has_character_modifier = studied_the_battle_of_teutoburg_forest
					}
					set_variable = { name = ancient_battle value = flag:teutoburg_forest }
				}
				#1 = { set_variable = { name = ancient_battle value = flag:cannae } }
				#1 = { set_variable = { name = ancient_battle value = flag:gaugamela } }
			}
		}
	}

	option = { #I must try this out!
		name = martial_strategy.2001.a


			if = {
				limit = { var:ancient_battle = flag:gaixia }
				add_character_modifier = {
				modifier = studied_the_battle_of_gaixia
				years = 20
			}
			}
			if = {
				limit = { var:ancient_battle = flag:red_cliffs }
				add_character_modifier = {
				modifier = studied_the_battle_of_red_cliffs
				years = 20
			}
			}
			if = {
				limit = { var:ancient_battle = flag:thermopylae }
				add_character_modifier = {
				modifier = studied_the_battle_of_thermopylae
				years = 20
			}
			}
			if = {
				limit = { var:ancient_battle = flag:teutoburg_forest }
				add_character_modifier = {
				modifier = studied_the_battle_of_teutoburg_forest
				years = 20
			}
			}
			add_martial_lifestyle_xp = medium_lifestyle_experience #Must match in 2000, 2001 and 2002
	}

	option = { #So interesting, books are great!
		name = martial_strategy.2001.b

		add_character_modifier = {
			modifier = studying_ancient_texts
			years = 20
		}
		add_martial_lifestyle_xp = medium_lifestyle_experience #Must match in 2000, 2001 and 2002
	}

	after = {
		hidden_effect = {
			remove_variable = ancient_battle
		}
	}
}

#You failed to translate the book... bummer!
martial_strategy.2002 = {
	type = character_event
	title = martial_strategy.2000.t
	desc = martial_strategy.2002.desc
	theme = martial_strategy_focus
	override_background = {
		event_background = study
	}

	left_portrait = root

	
	#Keep going
	option = {
		name = martial_strategy.2002.a

		stress_impact = { #Should mirror the stress in the toast above
			base = medium_stress_gain
			lazy = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
		}

		duel = {
			skill = learning
			value = medium_skill_rating
			desc = outcome_in_a_few_days
			90 = {		
				desc = martial_strategy.2000.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 5
				}
				show_as_tooltip = {
					add_martial_lifestyle_xp = medium_lifestyle_experience #Must match in 2000, 2001 and 2002
				}
				custom_tooltip = martial_strategy.2000.b.success.tt
				trigger_event = { id = martial_strategy.2001 days = 5 } #You uncover old knowledge!
				
			}
			10 = {		
				desc = martial_strategy.2000.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -5
				}
				hidden_effect = {
					send_interface_toast = {
						type = event_toast_effect_bad
						title = martial_strategy.2000.b.failure
						left_icon = root
						show_as_tooltip = {
							stress_impact = {
								base = medium_stress_gain
								lazy = medium_stress_impact_gain
							} 		
						}
					}
				}
			}
		}


		ai_chance = {
			base = 0
		}
	}

	#Give up
	option = {
		name = martial_strategy.2002.b

		ai_chance = {
			base = 100
		}
	}
}


##################################################
# Manipulative Tactics (Intrigue Skill Challenge)
# by Sean Hughes
# 2020-2022
##################################################

martial_strategy.2020 = {
	type = character_event
	title = martial_strategy.2020.t
	desc = {
		desc = martial_strategy.2020.opening
		first_valid = {
				triggered_desc = { #Text for characters who have the Deceitful trait.
				trigger = { has_trait = deceitful }
				desc = martial_strategy.2020.desc.deceitful
			}
			triggered_desc = { #Text for characters who already have a good martial education.
				trigger = {
					OR = {
						has_trait = education_martial_3
						has_trait = education_martial_4
					}
				}
				desc = martial_strategy.2020.desc.martial
			}
			triggered_desc = { #Text for characters who have the Ambitious trait.
				trigger = { has_trait = ambitious }
				desc = martial_strategy.2020.desc.ambitious
			}
			desc = martial_strategy.2020.desc #Generic text lines for characters who don't meet any special conditions.
		}
	}
	theme = martial_strategy_focus
	
	left_portrait = root

	trigger = {
		OR = {
			is_ai = no
			is_adult = yes
			has_lifestyle = martial_lifestyle
		}

		NOR = {
			#Event can only happen once every 5 years.
			has_character_flag = had_event_martial_strategy_2020
			has_character_modifier = warfare_cunning_gambit_succeeded_modifier
			has_character_modifier = warfare_hit_and_run_tactics_modifier
			has_character_modifier = warfare_terrain_advantage_modifier
		}
	}
	

	weight_multiplier = {
		base = 1
		modifier = {
			add = { #-1 at 5 intrigue, 0 at 10 intrigue, 1 at 15 intrigue etc.
				value = intrigue
				subtract = medium_skill_rating
				multiply = 0.2
			}
		}
		upweight_for_focus_modifier = { FOCUS = martial_strategy_focus }
	}

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

	#Attempt a cunning maneuver. High risk, high reward option.
	option = {
		name = martial_strategy.2020.a
		
		duel = {
			skill = intrigue
			value = 10

			desc = outcome_in_a_few_days

			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				trigger_event = { id = martial_strategy.2021 days = 5 } #Your soldiers pull off the maneuver.
				desc = martial_strategy.2020.a.success
				show_as_tooltip = {
					add_martial_lifestyle_xp = medium_lifestyle_experience
					add_character_modifier = {
						modifier = warfare_cunning_gambit_succeeded_modifier
						years = 5
					}	
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				trigger_event = { id = martial_strategy.2022 days = 5 } #Your soldiers' line collapses.
				desc = martial_strategy.2020.a.failure
				show_as_tooltip = {
					add_prestige = minor_prestige_loss
					set_nickname_effect = { NICKNAME = nick_the_foolish }
				}
				
			}
		}

		stress_impact = {
			honest = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -200
				ai_boldness = 100
				ai_energy = 50
			}

			# Rational characters know when they have a good chance of winning the duel
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = {
					value = intrigue
					add = -10
				}
				multiplier = 1000 # -10,000 at 0 Stewardship, +0 at 10 Stewardship, +10,000 at 20 Stewardship
			}
		}
	}

	#Focus on hit-and-run tactics. Guaranteed low-impact modifier reward.
	option = {
		name = martial_strategy.2020.b

		add_character_modifier = {
			modifier = warfare_hit_and_run_tactics_modifier
			years = 5
		}

			stress_impact = {
				honest = minor_stress_impact_gain
				brave = medium_stress_impact_gain
		}

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

	#Reject these dirty tactics. No benefit apart from avoiding stress.
	option = {
		name = {
			text = martial_strategy.2020.d
		}
		name = {
			trigger = { has_trait = brave }
			text = martial_strategy.2020.d.brave
		}
		flavor = martial_strategy.2020.d.flavor

			stress_impact = {
				base = minor_stress_impact_loss
				schemer = medium_stress_impact_gain
				deceitful = medium_stress_impact_gain
				ambitious = medium_stress_impact_gain
				brave = minor_stress_impact_loss
				just = minor_stress_impact_loss
				honest = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 300
			}
		}


	}
}

#Cunning maneuver succeeds.
martial_strategy.2021 = {
	type = character_event
	title = martial_strategy.2021.t
		desc = {
			desc = martial_strategy.2020.desc.opening
			desc = martial_strategy.2021.desc
		}
		theme = martial_strategy_focus
	
	left_portrait = root
	
	option = {
		name = martial_strategy.2021.a

		add_martial_lifestyle_xp = medium_lifestyle_experience
		add_character_modifier = { #Bonus hard casualties in combat
			modifier = warfare_cunning_gambit_succeeded_modifier
			years = 5
		}
	}
}

#Cunning maneuver fails.
martial_strategy.2022 = {
	type = character_event
	title = martial_strategy.2022.t
		desc = {
			desc = martial_strategy.2020.desc.opening
			desc = martial_strategy.2022.desc
		}
		theme = martial_strategy_focus
	
	left_portrait = root

	option = { #Return to using more conventional tactics
		name = martial_strategy.2022.b
		add_prestige = minor_prestige_loss
		set_nickname_effect = { NICKNAME = nick_the_foolish }
	}
}


##################################################
# Support The Troops (Stewardship Skill Challenge)
# by Sean Hughes
# 2030-2032
##################################################


martial_strategy.2030 = {
	type = character_event
	title = martial_strategy.2030.t
	desc = {
		first_valid = {
				triggered_desc = { #Text for characters who have the Diligent trait.
				trigger = { has_trait = diligent }
				desc = martial_strategy.2030.desc.diligent
			}
			triggered_desc = { #Text for characters who have the Ambitious trait.
				trigger = {	has_trait = ambitious }
				desc = martial_strategy.2030.desc.ambitious
			}
			desc = martial_strategy.2030.desc.fallback #Text lines for characters who don't meet any special conditions.
		}
		desc = martial_strategy.2030.desc.end
	}
	theme = martial_strategy_focus
	override_background = {
		event_background = armory
	}
	
	left_portrait = root

	trigger = {
		OR = {
			is_ai = no
			is_adult = yes
			has_lifestyle = martial_lifestyle
		}

		NOR = {
			#Event can only happen once every 5 years.
			has_character_flag = had_event_martial_strategy_2030
			has_character_modifier = warfare_well_provisioned_troops_modifier
			has_character_modifier = warfare_troops_lacking_provisions_modifier
		}
	}
	

	weight_multiplier = {
		base = 1
		modifier = {
			add = { #-1 at 5 stewardship, 0 at 10 stewardship, 1 at 15 stewardship etc.
				value = stewardship
				subtract = medium_skill_rating
				multiply = 0.2
			}
		}
		upweight_for_focus_modifier = { FOCUS = martial_strategy_focus }
	}

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

	#Work on creating a network of merchants to supply your men.
	option = {
		name = martial_strategy.2030.a
		

		duel = {
			skill = stewardship
			value = 10

			desc = outcome_in_a_few_days

			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = martial_strategy.2030.a.success.tt
				trigger_event = { id = martial_strategy.2031 days = 5 } #Your soldiers pull off the maneuver.
				show_as_tooltip = {
					add_character_modifier = {
						modifier = warfare_well_provisioned_troops_modifier
						years = 5
					}
					add_martial_lifestyle_xp = medium_lifestyle_experience
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = martial_strategy.2030.a.failure.tt
				trigger_event = { id = martial_strategy.2032 days = 5 } #Your soldiers' line collapses.
				show_as_tooltip = {
					add_character_modifier = {
						modifier = warfare_troops_lacking_provisions_modifier
						years = 5
					}
				}
			}
		}

		stress_impact = {
			lazy = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
			shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 100
				ai_greed = 100
				ai_energy = 50
			}

			# Rational characters know when they have a good chance of winning the duel
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = {
					value = stewardship
					add = -10
				}
				multiplier = 1000 # -10,000 at 0 Stewardship, +0 at 10 Stewardship, +10,000 at 20 Stewardship
			}
		}
	}

	#Pay a bunch of money for the supplies.
	option = {
		name = martial_strategy.2030.b

		trigger = {
			OR = {
				short_term_gold >= medium_gold_value_check
				is_ai = no
			}
		}

			remove_short_term_gold = medium_gold_value
		add_character_modifier = {
			modifier = warfare_well_provisioned_troops_modifier
			years = 5
		}

			stress_impact = {
				greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -50
				ai_greed = -150
			}
		}
	}


	#Just let your men loot and pillage for their supplies.
	option = {
		name = martial_strategy.2030.c

		add_character_modifier = {
			modifier = warfare_accustomed_to_foraging_modifier
			years = 5
		}

			stress_impact = {
				generous = medium_stress_impact_gain
				diligent = medium_stress_impact_gain
				compassionate = minor_stress_impact_gain
				just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -100
				ai_compassion = -100
				ai_greed = 100
				ai_energy = -50
			}
		}
	}
}

#Merchant network successfully established.
martial_strategy.2031 = {
	type = character_event
	title = martial_strategy.2031.t
		desc = martial_strategy.2031.desc
		theme = martial_strategy_focus
	override_background = {
		event_background = armory
	}
	
	left_portrait = root

	immediate = {
		add_martial_lifestyle_xp = medium_lifestyle_experience
	}
	
	option = { #Bonus to supply limit/reduced maintence costs.
		name = martial_strategy.2031.a

		add_character_modifier = {
			modifier = warfare_well_provisioned_troops_modifier
			years = 5
		}
		

		stress_impact = {
				greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
			}
		}
	}

	option = { #Benefit via raw cash.
		name = martial_strategy.2031.b
		add_gold = medium_gold_value

		stress_impact = {
				generous = minor_stress_impact_gain
				honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_honor = -0.5
			}
		}
	}
}

#Scammed by untrustworthy merchants
martial_strategy.2032 = {
	type = character_event
	title = martial_strategy.2032.t
		desc = martial_strategy.2032.desc
		theme = martial_strategy_focus
	override_background = {
		event_background = armory
	}
	
	left_portrait = root

	immediate = {
		add_character_modifier = {
			modifier = warfare_troops_lacking_provisions_modifier
			years = 5
		}
	}
	
	option = {
		name = {
			text = martial_strategy.2032.a
		}
		name = {
			trigger = {
				OR = {
					has_trait = forgiving
					has_trait = compassionate
					has_trait = humble
				}
			}
			text = martial_strategy.2032.a.forgiving
		}
	}
}

##################################################
# Discussion of Strategy
# by Sean Hughes
# 3010-3014
##################################################

#Triggers for determining which strategy each commander wants to use.
scripted_trigger martial_strategy_3010_wrathful_trigger = {
	OR = { #Favors direct attacks
		has_trait = wrathful
		has_trait = impatient
		has_trait = vengeful
		has_trait = sadistic
		has_trait = aggressive_attacker
	}
}

scripted_trigger martial_strategy_3010_greedy_trigger = {
	OR = {#Favors pillaging
		has_trait = greedy
		has_trait = gluttonous
		has_trait = reaver
	}
}

scripted_trigger martial_strategy_3010_patient_trigger = {
	OR = {#Favors fighting defensively
		has_trait = patient
		has_trait = humble
		has_trait = calm
		has_trait = military_engineer
		has_trait = unyielding_defender
	}
}

scripted_trigger martial_strategy_3010_craven_trigger = {
	#Wants to avoid fighting as much as possible.
	OR = {
		has_trait = craven
		has_trait = shy
	}
}

scripted_trigger martial_strategy_3010_flexible_trigger = {
	OR = {#Favors a more flexible strategy
		has_trait = fickle
		has_trait = logistician
		has_trait = flexible_leader
	}
}

scripted_trigger martial_strategy_patient_commander_trigger = {
	OR = {
		martial_strategy_3010_patient_trigger = yes #Basic personality check requirement
		martial_strategy_3010_craven_trigger = yes #Special personality option
		martial_strategy_3010_flexible_trigger = yes #Special personality option
	}
	NOR = {
		has_trait = wrathful
		has_trait = impatient
	}

	martial_strategy_3010_valid_commander = yes
}

scripted_trigger martial_strategy_impatient_commander_trigger = {
	OR = {
		martial_strategy_3010_wrathful_trigger = yes #Basic personality check requirement
		martial_strategy_3010_greedy_trigger = yes #Special personality option
	}
	NOR = {
		has_trait = patient
		has_trait = calm
	}
	martial_strategy_3010_valid_commander = yes
}

scripted_trigger martial_strategy_3010_valid_commander = {
	can_be_combatant_based_on_gender_trigger = {ARMY_OWNER = root}
	is_alive = yes
	is_imprisoned = no
	NOT = { is_at_war_with = root }
	has_contagious_deadly_disease_trigger = no
}

martial_strategy.3010 = {
	type = character_event
	title = martial_strategy.3010.t
	desc = {
		desc = martial_strategy.3010.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:impatient_commander = { martial_strategy_3010_greedy_trigger = yes} }
				desc = martial_strategy.3010.desc.greedy
			}
			desc = martial_strategy.3010.desc.wrathful
		}
		desc = martial_strategy.3010.desc.middle
		first_valid = {
			triggered_desc = {
				trigger = { scope:patient_commander = { martial_strategy_3010_craven_trigger = yes } }
				desc = martial_strategy.3010.desc.craven
			}
			triggered_desc = {
				trigger = { scope:patient_commander = { martial_strategy_3010_flexible_trigger = yes } }
				desc = martial_strategy.3010.desc.flexible
			}
			desc = martial_strategy.3010.desc.patient
		}
		desc = martial_strategy.3010.desc.end
		}
		theme = martial_strategy_focus
	
	left_portrait = scope:impatient_commander
	right_portrait = scope:patient_commander

	trigger = {
		is_at_war = yes
		is_available_adult_or_is_commanding = yes
		
		NOT = { has_character_flag = had_event_martial_strategy_3010 } #Can only happen once every 5 years.

		any_vassal = {
			martial_strategy_patient_commander_trigger = yes
			save_temporary_scope_as = vassal_1
		}
		any_vassal = {
			martial_strategy_impatient_commander_trigger = yes
			NOT = { this = scope:vassal_1 }
		}
	}

	weight_multiplier = {
		base = 2 #Because this is only available while at war, but it's nice to get it then
		upweight_for_focus_modifier = { FOCUS = martial_strategy_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_martial_strategy_3010
			years = 10
		}


		random_character_war =	{
			#Used only for localization, any war will do.
			save_scope_as = my_war
		}

		#Get our first vassal for the meeting.
		random_vassal = {
			limit = {
				#We want to get two commanders with relatively opposed viewpoints.
				martial_strategy_impatient_commander_trigger = yes
				save_temporary_scope_as = impatient_commander
				root = {
					any_vassal = {
						martial_strategy_patient_commander_trigger = yes
						NOT = { this = scope:impatient_commander }
					}
				}
			}
			weight = {
				base = 1
				#Higher-tier vassals are more likely to be part of the strategy meeting, due to their power and/or assumed stake in the war.
				compare_modifier = {
					value = highest_held_title_tier
					multiplier = 5
				}

				#High martial chatacters are much more likely to sit in on the meeting.
				compare_modifier = {
					value = martial
					multiplier = 30
				}

				#Your powerful vassals get their own stacking modifier on top of everything else.
				modifier = {
					is_powerful_vassal = yes
					factor = 10
				}

				# If they're actually commanding your army, they're much, much more likely to be chosen!
				modifier = {
					is_commanding_army = yes
					factor = 50
				}
			}
			save_scope_as = impatient_commander

		}

		#Get our second vassal for the meeting.
		random_vassal = {
			limit = {
				#We want to get two commanders with relatively opposed viewpoints.
				martial_strategy_patient_commander_trigger = yes
				NOT = { this = scope:impatient_commander }
			}

			weight = {
				base = 1
				#Higher-tier vassals are more likely to be part of the strategy meeting, due to their power and/or assumed stake in the war.
				compare_modifier = {
					value = highest_held_title_tier
					multiplier = 5
				}

				#High martial chatacters are more likely to sit in on the meeting.
				compare_modifier = {
					value = martial
					multiplier = 30
				}

				#Your powerful vassals get their own stacking modifier on top of everything else.
				modifier = {
					is_powerful_vassal = yes
					factor = 10
				}

				# If they're actually commanding your army, they're much, much more likely to be chosen!
				modifier = {
					is_commanding_army = yes
					factor = 50
				}				
			}
			save_scope_as = patient_commander
		}
	}

	#High martial skill lets you fuse the two strategies together.
	option = {
		name = martial_strategy.3010.o_martial
		trigger = {
			martial >= 18
		}

		skill = martial

		#Everyone gets both strategies!
		add_impatient_commanders_modifier_effect = yes
		add_patient_commanders_modifier_effect = yes

		scope:impatient_commander = {
			add_impatient_commanders_modifier_effect = yes
			add_patient_commanders_modifier_effect = yes
			trigger_event = martial_strategy.3014
		}

		scope:patient_commander = {
			add_impatient_commanders_modifier_effect = yes
			add_patient_commanders_modifier_effect = yes
			trigger_event = martial_strategy.3014
		}

		ai_chance = {
			base = 1000
			ai_value_modifier = {
				ai_rationality = 200
				ai_energy = 100
			}
		}
	}

	#Pick the more aggressive option.
	option = {
		name = martial_strategy.3010.a

		# Share impatient strategy with commander.
		scope:impatient_commander = {
			add_impatient_commanders_modifier_effect = yes
			trigger_event = martial_strategy.3011

			#Impatient commander is happy you picked him.
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		add_impatient_commanders_modifier_effect = yes
		scope:patient_commander = {
			trigger_event = martial_strategy.3012

			#Patient commander is upset you dismissed his plan..
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -50
				ai_greed = 100
			}
		}

	}

	#Pick the more defensive option.
	option = {
		name = martial_strategy.3010.b

		# Share patient strategy with commander.
		scope:patient_commander = {
			add_patient_commanders_modifier_effect = yes
			trigger_event = martial_strategy.3011

			#Patient commander is happy you picked him.
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		add_patient_commanders_modifier_effect = yes
		scope:impatient_commander = {
			trigger_event = martial_strategy.3012

			#Impatient commander is upset you dismissed his plan..
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}


		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 50
				ai_greed = -100
			}
		}
	}

	#Each commander gets to employ their own strategy.
	option = {
		name = martial_strategy.3010.c

		#Impatient commander gets their own strategy as a modifier.
		scope:impatient_commander = {
			add_impatient_commanders_modifier_effect = yes
			trigger_event = martial_strategy.3013

			#Pleased that you let them do their own thing.
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
		}

		#Patient commander gets their own strategy as a modifer.
		scope:patient_commander = {
			add_patient_commanders_modifier_effect = yes
			trigger_event = martial_strategy.3013

			#Pleased that you let them do their own thing.
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
		}

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

#The commander whose strategy got picked is informed of their liege's decision.
martial_strategy.3011 = {
	type = character_event
	title = martial_strategy.3011.t
	desc = {
 		desc = martial_strategy.3010.desc.response.start
		desc = martial_strategy.3011.desc
	}
	theme = martial_strategy_focus
	
	left_portrait = scope:my_liege
	right_portrait = scope:other_commander

	immediate = {

		liege = {
			save_scope_as = my_liege
		}

		scope:impatient_commander = {
			if = {
				limit = {
					this = root
				}
				scope:patient_commander = {
					save_scope_as = other_commander
				}

				show_as_tooltip = {
					scope:impatient_commander = {
						add_impatient_commanders_modifier_effect = yes
						add_opinion = {
							target = scope:my_liege
							modifier = pleased_opinion
							opinion = 20
						}
					}
					scope:patient_commander = {
						add_impatient_commanders_modifier_effect = yes
						save_scope_as = other_commander
					}
					scope:my_liege = {
						add_impatient_commanders_modifier_effect = yes
					}
				}
			}
			else = {
				scope:impatient_commander = {
					save_scope_as = other_commander
				}

				show_as_tooltip = {
					scope:patient_commander = {
						add_patient_commanders_modifier_effect = yes
						add_opinion = {
							target = scope:my_liege
							modifier = pleased_opinion
							opinion = 20
						}
					}
					scope:impatient_commander = {
						add_patient_commanders_modifier_effect = yes
					}
					scope:my_liege = {
						add_patient_commanders_modifier_effect = yes
					}
				}
			}
		}
	}

	option = {
		name = {
			text = martial_strategy.3011.a
		}
		name = {
			trigger = {
				opinion = {
					target = scope:my_liege
					value <= -10
				}
			}
			text = martial_strategy.3011.a.disapprove
		}
	}
}

#The commander whose strategy got rejected is informed of their liege's decision.
martial_strategy.3012 = {
	type = character_event
	title = martial_strategy.3012.t
	desc = {
 		desc = martial_strategy.3010.desc.response.start
		desc = martial_strategy.3012.desc
	}
	theme = martial_strategy_focus
	
	left_portrait = scope:my_liege
	right_portrait = scope:other_commander

	immediate = {

		liege = {
			save_scope_as = my_liege
		}

		scope:impatient_commander = {
			if = {
				limit = {
					this = root
				}
				scope:patient_commander = {
					save_scope_as = other_commander
				}

				show_as_tooltip = {
					scope:impatient_commander = {
						add_patient_commanders_modifier_effect = yes
					}
					scope:patient_commander = {
						add_patient_commanders_modifier_effect = yes
					}
					scope:my_liege = {
						add_patient_commanders_modifier_effect = yes
					}
				}
			}
			else = {
				scope:impatient_commander = {
					save_scope_as = other_commander
				}
				show_as_tooltip = {
					scope:patient_commander = {
						add_impatient_commanders_modifier_effect = yes
					}
					scope:impatient_commander = {
						add_impatient_commanders_modifier_effect = yes
					}
					scope:my_liege = {
						add_impatient_commanders_modifier_effect = yes
					}
				}
			}
		}
	}

	option = {
		name = {
			text = martial_strategy.3012.a
		}
		name = {
			trigger = {
				opinion = {
					target = scope:my_liege
					value <= -10
				}
			}
			text = martial_strategy.3012.a.disapprove
		}
	}
}

#The commanders are both informed that their liege is letting them do what they want.
martial_strategy.3013 = {
	type = character_event
	title = martial_strategy.3013.t
	desc = {
 		desc = martial_strategy.3010.desc.response.start
		desc = martial_strategy.3013.desc
	}
	theme = martial_strategy_focus
	
	left_portrait = scope:my_liege
	right_portrait = scope:other_commander

	immediate = {

		liege = {
			save_scope_as = my_liege
		}

		scope:impatient_commander = {
			if = {
				limit = {
					this = root
				}
				scope:patient_commander = {
					save_scope_as = other_commander
				}

				show_as_tooltip = {
					scope:impatient_commander = {
						add_impatient_commanders_modifier_effect = yes
					}
					scope:patient_commander = {
						add_patient_commanders_modifier_effect = yes
					}
				}
			}
			else = {
				scope:impatient_commander = {
					save_scope_as = other_commander
				}
				show_as_tooltip = {
					scope:patient_commander = {
						add_patient_commanders_modifier_effect = yes
					}
					scope:impatient_commander = {
						add_impatient_commanders_modifier_effect = yes
					}
				}
			}
		}
	}

	option = {
		name = martial_strategy.3013.a
	}
}

#The commanders are both informed that their liege took each of their strategies and fused them together!
martial_strategy.3014 = {
	type = character_event
	title = martial_strategy.3014.t
	desc = {
 		desc = martial_strategy.3010.desc.response.start
		desc = martial_strategy.3014.desc
	}
	theme = martial_strategy_focus
	
	left_portrait = scope:my_liege
	right_portrait = scope:other_commander

	immediate = {

		liege = {
			save_scope_as = my_liege
		}

		scope:impatient_commander = {
			if = {
				limit = {
					this = root
				}
				scope:patient_commander = {
					save_scope_as = other_commander
				}

				show_as_tooltip = {
					scope:impatient_commander = {
						add_impatient_commanders_modifier_effect = yes
						add_patient_commanders_modifier_effect = yes
					}
					scope:patient_commander = {
						add_impatient_commanders_modifier_effect = yes
						add_patient_commanders_modifier_effect = yes
					}
					scope:my_liege = {
						add_impatient_commanders_modifier_effect = yes
						add_patient_commanders_modifier_effect = yes
					}
				}
			}
			else = {
				scope:impatient_commander = {
					save_scope_as = other_commander
				}
				show_as_tooltip = {
					scope:patient_commander = {
						add_impatient_commanders_modifier_effect = yes
						add_patient_commanders_modifier_effect = yes
					}
					scope:impatient_commander = {
						add_impatient_commanders_modifier_effect = yes
						add_patient_commanders_modifier_effect = yes
					}
					scope:my_liege = {
						add_impatient_commanders_modifier_effect = yes
						add_patient_commanders_modifier_effect = yes
					}
				}
			}
		}
	}

	option = {
		name = {
			text = martial_strategy.3014.a
		}
		name = {
			trigger = {
				opinion = {
					target = scope:my_liege
					value <= -10
				}
			}
			text = martial_strategy.3014.a.disapprove
		}
	}
}


############################
# STRATEGY: SPECIAL EVENTS #
############################

namespace = martial_strategy_special

#########################
# Storm Your Own Castle # by Linnéa Thimrén
#########################

scripted_trigger martial_strategy_special_1301_defender_trigger = {
	is_available_healthy_ai_adult = yes
	NOT = { this = root }
	OR = {
		has_lifestyle = martial_lifestyle
		is_knight = yes
		has_council_position = councillor_marshal
	}
}

#Will you practice castle-taking or look at defenses?
martial_strategy_special.1301 = {
	type = character_event
	title = martial_strategy_special.1301.t
	desc = martial_strategy_special.1301.desc
	
	left_portrait = root
	right_portrait = scope:siege_proposer
	theme = martial_strategy_focus
	override_background = {
		event_background = courtyard
	}
	
	trigger = {
		has_focus = martial_strategy_focus
		exists = capital_county
		NOT = { has_character_flag = had_event_martial_strategy_special_1301 }
		OR = {
			AND = {
				exists = cp:councillor_marshal
				cp:councillor_marshal = { martial_strategy_special_1301_defender_trigger = yes }
			}
			any_knight = {
				martial_strategy_special_1301_defender_trigger = yes
			}
			any_relation = {
				type = friend
				martial_strategy_special_1301_defender_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		
		hidden_effect = {
			add_character_flag = had_event_martial_strategy_special_1301
			add_character_flag = {
				flag = is_in_martial_special_event
				days = 200
			}
			
			#Save defender
			if = {
				limit = {
					exists = cp:councillor_marshal
					cp:councillor_marshal = { martial_strategy_special_1301_defender_trigger = yes }	
				}
				cp:councillor_marshal = { add_to_list = possible_defenders }
			}
			every_knight = {
				limit = { martial_strategy_special_1301_defender_trigger = yes }
				add_to_list = possible_defenders
			}
			every_relation = {
				type = friend
				limit = { martial_strategy_special_1301_defender_trigger = yes }
				add_to_list = possible_defenders
			}
			random_in_list = {
				list = possible_defenders
				weight = {
					base = 1
					modifier = {
						has_relation_friend = root
						add = 4
					}
					modifier = {
						has_council_position = councillor_marshal
						add = 3
					}
				}
				save_scope_as = siege_proposer
				if = {
					limit = {
						root = { is_ai = no }
					}
					get_quirk_character_effect = yes
				}
			}
		}
	}

	#let's go
	option = {
		name = martial_strategy_special.1301.b
		custom_tooltip = martial_lifestyle_perk_indication
		trigger_event = {
			id = martial_strategy_special.1302
			days = { 3 7 }
		}
		reverse_add_opinion = {
			target = scope:siege_proposer
			modifier = pleased_opinion
			opinion = 10
		}
	}

	#nah thanks
	option = {
		name = martial_strategy_special.1301.a
		capital_county.title_province = {
			add_province_modifier = {
				modifier = increased_castle_defense
				days = 3650
			}
		}
	}

}

#Let the game begin! Storm the gate or climb the walls?
martial_strategy_special.1302 = {
	type = character_event
	title = martial_strategy_special.1302.t
	desc = martial_strategy_special.1302.desc
	left_portrait = root
	theme = martial_strategy_focus
	override_background = {
		event_background = courtyard
	}
	
	immediate = {
		set_variable = {
			name = storm_castle_points #to keep track of how you're doing
			value = 0
			days = 800
		}
		set_variable = {
			name = storm_castle_step
			value = 1
			days = 800
		}

		#Setting a commander trait option
		random_list = {
			1 = {
				trigger = { has_trait = military_engineer }
				save_scope_value_as = {
					name = special_commander_option
					value = flag:military_engineer
				}
			}
			1 = {
				trigger = { has_trait = flexible_leader }
				save_scope_value_as = {
					name = special_commander_option
					value = flag:flexible_leader
				}
			}
		}
	}

	option = { #Special option! militarty_engineer <- LÅT STÅ
		trigger = {
			exists = scope:special_commander_option
			scope:special_commander_option = flag:military_engineer
		}
		trait = military_engineer
		name = martial_strategy_special.1302.c

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		trigger_event = {
			id = martial_strategy_special.1303
			days = { 3 7 }
		}
		
		ai_chance = {
			base = 1000
		}
	}

	option = { #Special option! flexible_leader
		trigger = {
			exists = scope:special_commander_option
			scope:special_commander_option = flag:flexible_leader
		}
		trait = flexible_leader
		name = martial_strategy_special.1302.d

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		trigger_event = {
			id = martial_strategy_special.1303
			days = { 3 7 }
		}

		ai_chance = {
			base = 1000
		}
	}

	option = { #A riskier option that gives a higher reward
		name = martial_strategy_special.1302.a
		flavor = martial_strategy_special.13.a.tt

		add_martial_lifestyle_xp = minor_lifestyle_experience

		duel = {
			skill = prowess
			value = average_skill_level
			60 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -59
				}
				desc = martial_strategy_special.1302.a.tt1

				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_strategy_special.1302.a.tt1
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.very_well
					change_variable = {
						name = storm_castle_points
						add = 2
					}
				}
			}
			40 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -39
				}
				desc = martial_strategy_special.1302.a.tt2
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_strategy_special.1302.a.tt2
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.poorly
					change_variable = {
						name = storm_castle_points
						add = -1
					}
				}
			}
		}
		stress_impact = {
			patient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = brave
					has_trait = impatient
					has_trait = aggressive_attacker
					has_trait = reckless
				}
			}
		}
		trigger_event = {
			id = martial_strategy_special.1303
			days = { 3 7 }
		}
	}

	option = { #A safer option that doesn't pay off as well
		name = martial_strategy_special.1302.b
		flavor = martial_strategy_special.13.b.tt
		custom_tooltip = martial_strategy_special.storm_castle.well
		change_variable = {
			name = storm_castle_points
			add = 1
		}
		stress_impact = {
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = craven
					has_trait = patient
				}
			}
		}
		trigger_event = {
			id = martial_strategy_special.1304
			days = { 3 7 }
		}
	}
}

#Fighting up stairs
martial_strategy_special.1303 = {
	type = character_event
	title = martial_strategy_special.1303.t
	desc = {
		desc = martial_strategy_special.1303.desc
		triggered_desc = {
			trigger = { var:storm_castle_step = 3 } #This is the last points event
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { var:storm_castle_points >= 3 }
						desc = martial_strategy_1303.winning
					}
					desc = martial_strategy_1303.losing
				}
			}
		}
	}
	left_portrait = root
	theme = martial_strategy_focus
	override_background = {
		event_background = corridor_day
	}
	

	trigger = {
		exists = var:storm_castle_points #If it runs out in MP, kill the event
	}

	immediate = {
		change_variable = {
			name = storm_castle_step
			add = 1
		}

		#Setting a commander trait option
		random_list = {
			1 = {
				trigger = { has_trait = organizer }
				save_scope_value_as = {
					name = special_commander_option
					value = flag:organizer
				}
			}
			1 = {
				trigger = { has_trait = cautious_leader }
				save_scope_value_as = {
					name = special_commander_option
					value = flag:cautious_leader
				}
			}
			1 = {
				trigger = { has_trait = reckless }
				save_scope_value_as = {
					name = special_commander_option
					value = flag:reckless
				}
			}
		}
	}

	option = { #Special option! organizer
		trigger = {
			exists = scope:special_commander_option
			scope:special_commander_option = flag:organizer
		}
		trait = organizer
		name = martial_strategy_special.1303.c

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		ai_chance = {
			base = 1000
		}
	}

	option = { #Special option! cautious_leader
		trigger = {
			exists = scope:special_commander_option
			scope:special_commander_option = flag:cautious_leader
		}
		trait = cautious_leader
		name = martial_strategy_special.1303.d

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		ai_chance = {
			base = 1000
		}
	}

	option = { #Special option! reckless
		trigger = {
			exists = scope:special_commander_option
			scope:special_commander_option = flag:reckless
		}
		trait = reckless
		name = martial_strategy_special.1303.e

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		ai_chance = {
			base = 1000
		}
	}

	option = {
		name = martial_strategy_special.1303.a
		flavor = martial_strategy_special.13.a.tt
		add_martial_lifestyle_xp = minor_lifestyle_experience
		random_list = {
			60 = {		
				desc = martial_strategy_special.1303.a.tt1
				compare_modifier = {
					value = ai_boldness
					multiplier = 0.25
					min = -59
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_strategy_special.1303.a.tt1
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.very_well
					change_variable = {
						name = storm_castle_points
						add = 2
					}
				}
			}
			40 = {
				desc = martial_strategy_special.1303.a.tt2
				compare_modifier = {
					value = ai_boldness
					multiplier = -0.25
					min = -39
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_strategy_special.1303.a.tt2
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.poorly
					change_variable = {
						name = storm_castle_points
						add = -1
					}
				}
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = brave
					has_trait = impatient
					has_trait = aggressive_attacker
					has_trait = reckless
				}
			}
		}
	}

	option = {
		name = martial_strategy_special.1303.b
		flavor = martial_strategy_special.13.b.tt
		random_list = {
			90 = {
				modifier = {
					add = 30
					OR = {
						has_trait = diligent
						has_trait = patient
					}
				}
				desc = martial_strategy_special.1303.b.tt1
				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_strategy_special.1303.b.tt1
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.well
					change_variable = {
						name = storm_castle_points
						add = 1
					}
				}
			}
			10 = {
				modifier = {
					add = 5
					has_trait = impatient
				}
				desc = martial_strategy_special.1303.b.tt2
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_strategy_special.1303.b.tt2
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.poorly
					change_variable = {
						name = storm_castle_points
						add = -1
					}
				}
			}
		}
		stress_impact = {
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = diligent
					has_trait = patient
					has_trait = flexible_leader
				}
			}
		}
	}

	#Protect them with your body
	option = {
		trigger = { #I don't have any of the cool commander options
			trigger_if = {
				limit = {
					exists = scope:special_commander_option
				}
				NOR = {
					scope:special_commander_option = flag:organizer
					scope:special_commander_option = flag:cautious_leader
					scope:special_commander_option = flag:reckless
				}
			}
		}
		name = martial_strategy_special.1303.f

		stress_impact = {
			base = medium_stress_impact_gain
			brave = minor_stress_impact_loss
			craven = medium_stress_impact_gain
		}

		random = {
			chance = 20
			increase_wounds_no_death_effect = { REASON = fight }
		}

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}
	}

	after = {
		if = {
			limit = { var:storm_castle_step = 2 }
			trigger_event = {
				id = martial_strategy_special.1304
				days = { 3 7 }
			}
		}
		else = {
			trigger_event = {
				id = martial_strategy_special.1399
				days = { 3 7 }
			}
		}
	}
}

#Fighting on battlement
martial_strategy_special.1304 = {
	type = character_event
	title = martial_strategy_special.1304.t
	desc = {
		desc = martial_strategy_special.1304.desc
		triggered_desc = {
			trigger = { var:storm_castle_step = 3 } #This is the last points event
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { var:storm_castle_points >= 3 }
						desc = martial_strategy_1303.winning
					}
					desc = martial_strategy_1303.losing
				}
			}
		}
	}
	left_portrait = root
	theme = martial_strategy_focus
	override_background = {
		event_background = courtyard
	}

	trigger = {
		exists = var:storm_castle_points #If it runs out in MP, kill the event
	}

	immediate = {
		change_variable = {
			name = storm_castle_step
			add = 1
		}

		#Setting a commander trait option
		random_list = {
			1 = {
				trigger = { has_trait = aggressive_attacker }
				save_scope_value_as = {
					name = special_commander_option
					value = flag:aggressive_attacker
				}
			}
			1 = {
				trigger = { has_trait = unyielding_defender }
				save_scope_value_as = {
					name = special_commander_option
					value = flag:unyielding_defender
				}
			}
		}
	}

	option = { #Special option! aggressive_attacker
		trigger = {
			exists = scope:special_commander_option
			scope:special_commander_option = flag:aggressive_attacker
		}
		trait = aggressive_attacker
		name = martial_strategy_special.1304.c

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		ai_chance = {
			base = 1000
		}
	}

	option = { #Special option! unyielding_defender
		trigger = {
			exists = scope:special_commander_option
			scope:special_commander_option = flag:unyielding_defender
		}
		trait = unyielding_defender
		name = martial_strategy_special.1304.d

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		ai_chance = {
			base = 1000
		}
	}

	option = { #Risky
		name = martial_strategy_special.1304.a
		flavor = martial_strategy_special.13.a.tt
		add_martial_lifestyle_xp = minor_lifestyle_experience
		random_list = {
			50 = {		
				desc = martial_strategy_special.1304.a.tt1
				compare_modifier = {
					value = ai_boldness
					multiplier = 0.25
					min = -49
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_strategy_special.1304.a.tt1
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.very_well
					change_variable = {
						name = storm_castle_points
						add = 2
					}
				}
			}
			50 = {		
				desc = martial_strategy_special.1304.a.tt2
				compare_modifier = {
					value = ai_boldness
					multiplier = -0.25
					min = -49
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_strategy_special.1304.a.tt2
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.poorly
					change_variable = {
						name = storm_castle_points
						add = -1
					}
				}
			}
		}
		stress_impact = {
			patient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = brave
					has_trait = impatient
					has_trait = aggressive_attacker
					has_trait = reckless
				}
			}
		}
	}

	option = { #Safe
		name = martial_strategy_special.1304.b
		flavor = martial_strategy_special.13.b.tt
		random_list = {
			90 = {
				desc = martial_strategy_special.1304.b.tt1
				send_interface_toast = {
					type = event_toast_effect_good
					title = martial_strategy_special.1304.b.tt1
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.well
					change_variable = {
						name = storm_castle_points
						add = 1
					}
				}
			}
			10 = {
				modifier = {
					add = 20
					has_trait = impatient
				}
				desc = martial_strategy_special.1304.b.tt2
				send_interface_toast = {
					type = event_toast_effect_bad
					title = martial_strategy_special.1304.b.tt2
					left_icon = root
					custom_tooltip = martial_strategy_special.storm_castle.poorly
					change_variable = {
						name = storm_castle_points
						add = -1
					}
				}
			}
		}
		stress_impact = {
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = patient
					has_trait = diligent
					has_trait = unyielding_defender
				}
			}
		}
	}


	#Hurt them for reals!
	option = {
		trigger = { #I don't have any of the cool commander options
			trigger_if = {
				limit = {
					exists = scope:special_commander_option
				}
				NOR = {
					scope:special_commander_option = flag:unyielding_defender
					scope:special_commander_option = flag:aggressive_attacker
				}
			}
		}
		name = martial_strategy_special.1304.f

		add_tyranny = minor_tyranny_gain
		add_dread = minor_dread_gain

		custom_tooltip = martial_strategy_special.storm_castle.very_well
		change_variable = {
			name = storm_castle_points
			add = 2
		}

		random_knight = {
			increase_wounds_no_death_effect = { REASON = fight }
		}

		ai_chance = {
			base = 0
		}
	}

	after = {
		if = {
			limit = { var:storm_castle_step = 2 }
			trigger_event = {
				id = martial_strategy_special.1303
				days = { 3 7 }
			}
		}
		else = {
				trigger_event = {
				id = martial_strategy_special.1399
				days = { 3 7 }
			}
		}
	}
}

#END
martial_strategy_special.1399 = {
	type = character_event
	title = martial_strategy_special.1399.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					var:storm_castle_points >= 3
				}
				desc = martial_strategy_special.1399.desc_win
			}
			desc = martial_strategy_special.1399.desc_loose
		}
		desc = martial_strategy_special.1399.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					var:storm_castle_points >= 3
				}
				desc = martial_strategy_special.1399.desc_win2
			}
			triggered_desc = {
				desc = martial_strategy_special.1399.desc_loose2
			}
		}
	}
	left_portrait = root
	right_portrait = scope:siege_proposer
	theme = martial_strategy_focus
	override_background = {
		event_background = courtyard
	}

	trigger = {
		exists = var:storm_castle_points #If it runs out in MP, kill the event
	}

	option = {
		name = martial_strategy_special.1399.a
		trigger = {
			var:storm_castle_points >= 3
		}
		add_martial_lifestyle_perk_points = 1
		if = {
			limit = {
				exists = capital_county
			}
			capital_county.title_province = {	
				add_province_modifier = {
					modifier = minor_increased_castle_defense
					days = 3650
				}
			}
		}
	}

	option = {
		name = martial_strategy_special.1399.b
		trigger = {
			var:storm_castle_points < 3
		}
		capital_county = {	
			add_county_modifier = {
				modifier = minor_increased_castle_defense
				days = 3650
			}
		}
	}
	after = {
		remove_character_flag = is_in_martial_special_event
		remove_variable = storm_castle_points
		remove_variable = storm_castle_step
	}
}



#################################
# MARCH GONE AWRY, by Petter Vilberg
# 1400 - 1499
#################################
#Structure explanation:
# 1401 sets up the loop
# Every successive event needs to:
# 		The immediate must mark the event as having been used, and block itself from happening again in this cycle
# 		An option with a cost must fire the search_for_troops_event_selection event selection
# 		Giving up should route the player to the failure event (1499)
# Eventually, an increasing random weight will send the character to the success event (1498)
#Each event should have a "free" option that continues the chain, unlocked by traits or other conditions


#Setup
martial_strategy_special.1401 = {
	type = character_event
	title = martial_strategy_special.1401.t
	desc = {
		desc = martial_strategy_special.1401.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:commander
				}
				desc = martial_strategy_special.1401.commander
			}
			desc = martial_strategy_special.1401.officer_fallback
		}
		desc = martial_strategy_special.1401.end
	}
	theme = martial_strategy_focus
	left_portrait = {
		character = root
		animation = boredom
	}
	right_portrait = scope:commander
	
	trigger = {
		has_focus = martial_strategy_focus
		is_landed = yes
		NOT = { has_character_flag = had_event_martial_strategy_special_1401 }
		any_knight = { basic_is_available_ai = yes }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = is_in_martial_special_event
			days = 100
		}
		add_character_flag = had_event_martial_strategy_special_1401
		random_knight = {
			limit = { basic_is_available_ai = yes }
			save_scope_as = commander
		} #Done here to guarantee it is applied, no matter the outcome
		capital_barony = {
			save_scope_as = capital
		}
	}

	option = { #Start looping towards ranking up
		name = martial_strategy_special.1401.a
		hidden_effect = {
			set_variable = {
				name = search_for_troops_event_count
				value = 0
				days = 365
			}
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		custom_tooltip = martial_lifestyle_perk_indication
		ai_chance = {
			base = 100
		}
	}

	option = { #No thanks.
		name = martial_strategy_special.1401.b
		hidden_effect = {
			trigger_event = {
				id = martial_strategy_special.1499
				days = { 7 20 }
			}
		}
		show_as_tooltip = {
			add_character_modifier = {
				modifier = self_sufficient_troops_modifier
				days = 1825
			}
		}
		ai_chance = {
			base = 0
		}
	}
}


#Soldiers are hanging out in a local tavern
martial_strategy_special.1402 = {
	type = character_event
	title = martial_strategy_special.1402.t
	desc = martial_strategy_special.1402.desc
	theme = martial_strategy_focus
	override_background = {
		event_background = tavern
	}
	left_portrait = {
		character = root
		animation = stress
	}
	
	trigger = {
		NOT = {
			has_character_flag = had_event_1402
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = had_event_1402
			days = 365
		}
		change_variable = {
			name = search_for_troops_event_count
			add = 1
		}
	}

	option = { #Pay for the tavern to throw them out
		name = martial_strategy_special.1402.a
		remove_short_term_gold = minor_gold_value
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.5
			}
			modifier = {
				add = 30
				has_trait = generous
			}
			modifier = {
				add = -80
				short_term_gold < minor_gold_value_check
			}
		}
	}

	option = { #Have a drink with them, and feast until they come with!
		name = martial_strategy_special.1402.b
		add_prestige = minor_prestige_loss
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			temperate = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -0.75
			}
		}
	}

	option = { #Give up
		name = martial_strategy_special.1402.c
		custom_tooltip = martial_strategy_special.1401.delay_tt
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 20 30 }
			}
		}
		stress_impact = {
			stubborn = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
		}
	}

	option = { #I can convince them!
		name = martial_strategy_special.1402.d
		trigger = {
			OR = {
				has_trait = gregarious
				has_diplomacy_lifestyle_trait_trigger = yes
			}
		}
		trait = gregarious
		trait = diplomat
		trait = family_first
		trait = august
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
	}
}


#Soldiers have run out of water and are camped by a lake
martial_strategy_special.1403 = {
	type = character_event
	title = martial_strategy_special.1403.t
	desc = martial_strategy_special.1403.desc
	theme = martial_strategy_focus
	left_portrait = root

	
	trigger = {
		NOT = {
			has_character_flag = had_event_1403
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = had_event_1403
			days = 365
		}
		change_variable = {
			name = search_for_troops_event_count
			add = 1
		}
	}

	option = { #Have your knights carry water
		name = martial_strategy_special.1403.a
		add_prestige = minor_prestige_loss
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
			}
			modifier = {
				add = -100
				has_trait = arrogant
			}
		}
	}

	option = { #Have them march home
		name = martial_strategy_special.1403.b
		if = {
			limit = { exists = capital_county }
			capital_county = {
				add_county_modifier = {
					modifier = martial_strategy_reduced_capital_levy_modifier
					years = 5
				}
			}
		}
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -1
				ai_vengefulness = 1
				ai_rationality = -0.5
			}
		}
	}

	option = { #Give up
		name = martial_strategy_special.1403.c
		custom_tooltip = martial_strategy_special.1401.delay_tt
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 20 30 }
			}
		}
		stress_impact = {
			stubborn = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
		}
	}

	option = { #I think I can come up with a solution for this...
		name = martial_strategy_special.1403.d
		trigger = {
			OR = {
				has_trait = logistician
				has_trait = military_engineer
			}
		}
		trait = logistician
		trait = military_engineer
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 1000
		}
	}
}


#A sergeant has taken it upon themselves to continue training
martial_strategy_special.1404 = {
	type = character_event
	title = martial_strategy_special.1404.t
	desc = martial_strategy_special.1404.desc
	theme = martial_strategy_focus
	left_portrait = root
	right_portrait = scope:knight
	lower_right_portrait = scope:soldier_friend

	trigger = {
		NOT = {
			has_character_flag = had_event_1404
		}
		any_knight = {
			is_available_ai = yes
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = had_event_1404
			days = 365
		}
		change_variable = {
			name = search_for_troops_event_count
			add = 1
		}
		if = {
			limit = { num_of_relation_soldier_friend > 0 }
			random_relation = {
				type = soldier_friend
				save_scope_as = soldier_friend
			}
		}
		random_knight = {
			limit = {
				is_available_ai = yes
			}
			save_scope_as = knight
		}
	}

	option = { #I am the real commander here!
		name = martial_strategy_special.1404.a
		
		scope:knight = {
			add_opinion = {
				modifier = insult_opinion
				target = root
				opinion = -20
			}
		}
		add_dread = minor_dread_gain
		

		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			humble = minor_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_compassion = -0.25
				ai_rationality = 0.25
			}
		}
	}

	option = { #Challenges to my authority will be punished!
		name = martial_strategy_special.1404.b
 		add_character_modifier = {
			modifier = upset_troops_modifier
			days = 1825
		}
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -0.25
				ai_vengefulness = 1
			}
		}
	}

	option = { #Give up
		name = martial_strategy_special.1404.c
		custom_tooltip = martial_strategy_special.1401.delay_tt
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 20 30 }
			}
		}
		ai_chance = {
			base = 1
		}
	}

	option = { #My soldier friend can handle this instead of the sergeant
		name = martial_strategy_special.1404.d
		trigger = {
			num_of_relation_soldier_friend > 0
		}
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 1000
		}
	}
}


#The troops have started listening to a local preacher
martial_strategy_special.1405 = {
	type = character_event
	title = martial_strategy_special.1405.t
	desc = martial_strategy_special.1405.desc
	left_portrait = root
	right_portrait = {
		character = scope:zealot
		animation = personality_zealous
	}
	theme = martial_strategy_focus
	
	trigger = {
		NOT = {
			has_character_flag = had_event_1405
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = had_event_1405
			days = 365
		}
		change_variable = {
			name = search_for_troops_event_count
			add = 1
		}
		create_character = {
			location = scope:capital.title_province
			gender_female_chance = root_faith_clergy_gender_female_chance
			age = { 16 60 }
			culture = root.culture
			faith = root.faith
			trait = zealous
			random_traits_list = {
				count = 2
				calm = {}
				brave = {}
				gregarious = {}
				ambitious = {}
				stubborn = {}
				arrogant = {}
			}
			save_scope_as = zealot
		}
	}

	option = { #Emphasise that I am the ruler chosen by HIGH GOD
		name = martial_strategy_special.1405.a
		add_prestige = medium_prestige_gain
		add_character_modifier = {
			modifier = martial_strategy_claimed_divine_right_modifier
			years = 5
		}
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			cynical = medium_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
			}
		}
	}

	option = { #Have the preacher sent away
		name = martial_strategy_special.1405.b
		add_piety = minor_piety_loss
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_boldness = 0.5
			}
		}
	}

	option = { #Give up
		name = martial_strategy_special.1405.c
		custom_tooltip = martial_strategy_special.1401.delay_tt
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 20 30 }
			}
		}
		ai_chance = {
			base = 1
		}
	}

	option = { #Convince the preacher to side with you
		name = martial_strategy_special.1405.d
		trigger = {
			OR = {
				has_trait = zealous
				has_trait = holy_warrior
			}
		}
		trait = holy_warrior
		trait = zealous
		hidden_effect = {
			trigger_event = {
				on_action = search_for_troops_event_selection
				days = { 5 15 }
			}
		}
		custom_tooltip = martial_strategy_special.1401.continue_search_tooltip
		ai_chance = {
			base = 1000
		}
	}
}


#Successful Conclusion!
martial_strategy_special.1498 = {
	type = character_event
	title = martial_strategy_special.1498.t
	desc = martial_strategy_special.1498.desc
	
	theme = martial_strategy_focus
	left_portrait = root
	
	trigger = {
		var:search_for_troops_event_count > 1
	}

	weight_multiplier = { #Increase the likelihood of succeeding for every event that has fired.
		base = 1
		modifier = {
			add = 1
			var:search_for_troops_event_count > 2
		}
		modifier = {
			add = 1
			var:search_for_troops_event_count > 3
		}
	}

	immediate = {
		hidden_effect = {
			remove_character_flag = had_event_1402
			remove_character_flag = had_event_1403
			remove_character_flag = had_event_1404
			remove_character_flag = had_event_1405
		}
	}

	option = {
		name = martial_strategy_special.1498.a
		add_martial_lifestyle_perk_points = 1
	}

	after = {
		hidden_effect = {
			remove_variable = search_for_troops_event_count
		}
	}
}

#Failed Conclusion
martial_strategy_special.1499 = {
	type = character_event
	title = martial_strategy_special.1499.t
	desc = martial_strategy_special.1499.desc
	theme = martial_strategy_focus
	left_portrait = root
	

	immediate = {
		hidden_effect = {
			remove_character_flag = had_event_1402
			remove_character_flag = had_event_1403
			remove_character_flag = had_event_1404
			remove_character_flag = had_event_1405
		}
	}

	option = {
		name = martial_strategy_special.1499.a
		add_character_modifier = {
			modifier = self_sufficient_troops_modifier
			days = 1825
		}
	}

	after = {
		hidden_effect = {
			remove_variable = search_for_troops_event_count
		}
	}
}
