﻿#Events for statecraft lifestyle rank up

namespace = stewardship_wealth

# Normal Events
	#1001	 	- I'm Bankrupt?, by Stephen Arthur and Sean Hughes
	#1011		- Mint New Coins!, by Stephen Arthur and Sean Hughes
	#1021		- Paying for War, by Sean Hughes
	#1051		- Freeman's Fortune, by Sean Hughes
	#1061		- New Acquisitions, by Sean Hughes
	#5001 		- Purchase Livestock, by Linnéa Thimrén
	#5002		- Investment advice (wealth friend), by Mathilda Bjarnehed

# As it is currently, this event only exists to stop the game from throwing an error.
stewardship_wealth.0001 = {
	hidden = yes
	immediate = { add_character_flag = is_in_stewardship_wealth_special_event }
}

##########################################
# Im am Bankrupt!?
# by Stephen Arthur and Sean Hughes
# 1001
##########################################

scripted_trigger stewardship_wealth_1001_wealthy_vassal = {
	is_available_ai = yes
	short_term_gold >= root.medium_gold_value

	NOT = {
		has_hook_of_type = {
			target = root
			type = favor_hook
		}
	}
}

#Pick from several options of alleviating your debts.
stewardship_wealth.1001 = {
	type = character_event
	title = stewardship_wealth.1001.t
	desc = stewardship_wealth.1001.desc
	
	theme = stewardship_wealth_focus
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:wealthy_vassal
		animation = schadenfreude
	}
	
	trigger = {
		gold < 0

		is_available_adult_or_is_commanding = yes
		NOT = { has_character_flag = had_event_stewardship_wealth_1001 }
	}

	weight_multiplier = {
		base = 1

		#Higher chance of occuring the more in-debt you are.
		modifier = {
			gold < -100
			add = 5
		}
		modifier = {
			gold < -200
			add = 15
		}

		#Additional chance of occuring if you're actively bleeding money.
		modifier = {
			monthly_character_income <= monthly_character_expenses
			factor = 10
		}

		upweight_for_focus_modifier = { FOCUS = stewardship_wealth_focus }
	}

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

		#Find a vassal who could help us out of this problem.
		random_vassal = {
			#Prioritize vassals who already owe us a favor which we can call in.
			limit = {
				stewardship_wealth_1001_wealthy_vassal = yes
				save_temporary_scope_as = wealthy_vassal
				root = {
					has_hook_of_type = {
						target = scope:wealthy_vassal
						type = favor_hook
					}	
				}
			}
			#Otherwise prioritize vassals who are at least Counts or above.
			alternative_limit = {
				stewardship_wealth_1001_wealthy_vassal = yes
				highest_held_title_tier >= 2
			}
			#Else just find anyone who we don't already owe a favor to.
			alternative_limit = {
				stewardship_wealth_1001_wealthy_vassal = yes
			}

			#Prefer vassals with whom owing(or being owed) a favor would be consequential.
			weight = {
				base = 100

				modifier = {
					highest_held_title_tier >= 3
					add = 100
				}
				modifier = {
					highest_held_title_tier >= 4
					add = 200
				}
				modifier = {
					is_powerful_vassal_of = root
					add = 300
				}
			}

			save_scope_as = wealthy_vassal
		}
	}

	#Option 1: Stewardship challenge to find some old debts in your ledgers you had forgotten about.
	option = {
		name = stewardship_wealth.1001.a

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		duel = {
			skill = stewardship
			value = 10

			10 = {
				compare_modifier = {
					value = scope:duel_value
				}
				desc = stewardship_wealth.1001.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_wealth.1001.a.success
					left_icon = root

					add_gold = medium_gold_value
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = stewardship_wealth.1001.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_wealth.1001.a.failure
					left_icon = root
					
					add_stress = minor_stress_gain
				}
			}
		}


		stress_impact = {
			lazy = minor_stress_impact_gain
			dull = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1.0
			}

			modifier = {
				add = 100
				stewardship >= 12
			}
		}			
	}

	#Option 2: Exchange a favor with a wealth vassal to get some gold from them.
	option = {
		trigger = {
			exists = scope:wealthy_vassal
		}
		name = {
			text = stewardship_wealth.1001.b.givehook
		}
		name = {
			trigger = {
				has_hook_of_type = {
					target = scope:wealthy_vassal
					type = favor_hook
				}
			}
			text = stewardship_wealth.1001.b.havehook
		}

		scope:wealthy_vassal = {
			if = {
				limit = {
					has_hook_of_type = {
						target = scope:wealthy_vassal
						type = favor_hook
					}	
				}

				use_hook = scope:wealthy_Vassal
			}
			else = {
				scope:wealthy_vassal = {
					add_hook = {
						target = root
						type = favor_hook
					}
				}
			}

			scope:wealthy_vassal = {
				pay_short_term_gold = {
					target = root
					gold = root.medium_gold_value
				}
			}
		}

		stress_impact = {
			ambitious = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1.0
				ai_boldness = -1.0
				ai_greed = -1.0
			}
		}	
	}
	
	#Option 3: A tyrannical ruler can spend Dread to receive gold from their vassals, though the move makes them seem weak.
	option = {
		name = stewardship_wealth.1001.c

		trigger = {
			dread >= 40
		}

		add_dread = medium_dread_loss

		every_vassal = {
			custom = stewardship_wealth.1001.c.tt
			add_opinion = {
				modifier = weak_opinion
				target = root
				opinion = -10
			}
		}

		add_gold = medium_gold_value

		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -2.0
				ai_boldness = 1.0
				ai_greed = 2.0
				ai_vengefulness = 1.0
			}
		}
	}

	#Option 4: Confiscate church property to pay for your debts.
	option = {
		name = stewardship_wealth.1001.d

		add_piety = medium_piety_loss
		add_gold = medium_gold_value

		stress_impact = {
			zealous = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = -3.0
				ai_greed = 2.0
			}
		}
	}

	#Option 5: Tighten your belt. Earn a small amount of gold for stress
	option = {
		name = stewardship_wealth.1001.e
		add_gold = minor_gold_value

		stress_impact = {
			base = minor_stress_impact_gain
			gluttonous = medium_stress_impact_gain
			arrogant = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -3.0
				ai_boldness = -2.0
			}
		}
	}

}

##########################################
# Mint new coins
# by Stephen Arthur and Sean Hughes
# 1011
##########################################

#Decide what methodology you want to use for minting coins.
stewardship_wealth.1011 = {
	type = character_event
	title = stewardship_wealth.1011.t
	desc = stewardship_wealth.1011.desc
	
	theme = stewardship_wealth_focus
	left_portrait = {
		character = root
		animation = personality_rational
	}

	trigger = {
		is_independent_ruler = yes
		NOT = { has_character_flag = had_event_stewardship_wealth_1011 }	
	}

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

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


	#Option 1: Mint new silver coins to encourage commerce.
	option = {
		name = stewardship_wealth.1011.a

		#Add silver coins modifier to realm.
		every_sub_realm_county = {
			custom = stewardship_wealth.1011.custom
			add_county_modifier = {
				modifier = governance_newly_minted_silver_coins_modifier
				days = 1825
			}		
		}

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

	#Option 2: Mint new gold coins to gain prestige.
	option = {
		name = stewardship_wealth.1011.b

		if = {
			limit = {
				highest_held_title_tier >= 3
			}
			add_prestige = major_prestige_gain
		}
		else_if = {
			limit = {
				highest_held_title_tier = 2
			}
			add_prestige = medium_prestige_gain
		}
		else = {
			add_prestige = minor_prestige_gain
		}
		

		stress_impact = {
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 2
			}

			modifier = {
				add = 100
				OR = {
					has_culture = culture:butr
					has_culture = culture:baranis
					has_culture = culture:bedouin
					has_culture = culture:levantine
					has_culture = culture:egyptian
					has_culture = culture:andalusian
					has_culture = culture:persian
					has_culture = culture:sogdian
					has_culture = culture:tocharian
					has_culture = culture:kurdish
					has_culture = culture:afghan
					has_culture = culture:baloch
					has_culture = culture:turkish
				}
			}	
		}
	}

	#Option 3: Debase the coins to earn a quick buck.
	option = {
		name = stewardship_wealth.1011.c

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		duel = {
			skill = stewardship
			value = 10

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = stewardship_wealth.1011.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_wealth.1011.c.success
					left_icon = root

					#Add silver coins modifier to realm.
					every_sub_realm_county = {
						custom = stewardship_wealth.1011.custom
						add_county_modifier = {
							modifier = governance_newly_minted_silver_coins_modifier
							days = 1825
						}		
					}

					#Adds gold to the character's treasury.
					add_gold = medium_gold_value
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = stewardship_wealth.1011.c.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_wealth.1011.c.failure
					left_icon = root
					
					add_prestige = medium_prestige_loss
				}
			}
		}		


		stress_impact = {
			generous = medium_stress_impact_gain
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 3
				ai_honor = -1
			}
		}			
	}
}

##########################################
# War Taxes
# by Sean Hughes
# 1021
##########################################

#Gain several options to help you pay for your war.
stewardship_wealth.1021 = {
	type = character_event
	title = stewardship_wealth.1021.t
	desc = stewardship_wealth.1021.desc
	left_portrait = {
		character = root
		animation = idle
	}
	theme = stewardship_wealth_focus
	
	trigger = {
		#Must be at war and losing money.
		is_at_war = yes
		is_available_adult_or_is_commanding = yes
		monthly_character_income < monthly_character_expenses
		NOT = { has_character_flag = had_event_stewardship_wealth_1021 }
	}

	weight_multiplier = {
		base = 1

		#More likely to occur the less money you have in your treasury.
		modifier = {
			gold < major_gold_value
			add = 0.5
		}
		modifier = {
			gold < medium_gold_value
			add = 1.0
		}
		modifier = {
			gold < minor_gold_value
			add = 2.0
		}

		upweight_for_focus_modifier = { FOCUS = stewardship_wealth_focus }
	}

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

	#Option 1: Raise war taxes, gaining a large boost to income but raising unrest in your provinces.
	option = {
		name = stewardship_wealth.1021.a
		every_sub_realm_county = {
			custom = stewardship_wealth.1021.a.custom
			add_county_modifier = {
				modifier = governance_1021_war_taxes_modifier
				years = 3
			}	
		}

		stress_impact = {
			compassionate = minor_stress_impact_gain
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 2
				ai_compassion = -1
				ai_honor = 2
			}
		}	
	}

	#Option 2: Reduce the maintenance cost of your armies; Martial challenge to avoid getting a combat penalty.
	option = {
		name = stewardship_wealth.1021.b

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		duel = {
			skill = martial
			value = 12

			10 = {
				compare_modifier = {
					value = scope:duel_value
				}
				desc = stewardship_wealth.1021.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_wealth.1021.b.success
					left_icon = root

					#Add maintenance reduction modifier to this character's armies.
					add_character_modifier = {
						modifier = governance_1021_efficiently_supplied_armies_modifer
						years = 3
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = stewardship_wealth.1021.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_wealth.1021.b.failure
					left_icon = root
					
					#Add maintenance reduction modifier + combat penalty to this character's armies.
					add_character_modifier = {
						modifier = governance_1021_undersupplied_armies_modifier
						years = 3
					}
				}
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 2
				ai_boldness = 1
			}

			#AI is more likely to pick this if they have a good chance of succeeding.
			modifier = {
				martial >= 12
				add = 100
			}
		}		

	}
	
	#Option 3: Gain a bonus to looting enemy lands.
	option = {
		name = stewardship_wealth.1021.c

		stress_impact = {
			base = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			diligent = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_compassion = -2
				ai_honor = -2
			}
		}	
	}
}


##########################################
# Freeman's Fortune
# by Sean Hughes
# 1051
##########################################

stewardship_wealth.1051 = {
	type = character_event
	title = stewardship_wealth.1051.t
	desc = stewardship_wealth.1051.desc
	
	theme = stewardship_wealth_focus
	override_background = {
		event_background = throne_room
	}
	left_portrait = {
		character = scope:freeman
		animation = idle
	}
	
	trigger = {
		NOT = { has_character_flag = had_stewardship_wealth_1051_event }

		#Only feudal governments have serfs and freemen.
		has_government = feudal_government

		#Must hold a county title.
		any_held_title = {
			tier = tier_county
		}
	}

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

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

		#Find one of our owned counties.
		random_held_title = {
			limit = {
				tier = tier_county
			}

			#Save the scope.
			save_scope_as = target_county
			
			#Generate a high stewardship peasant to be our successful farmer.
			root = { random_dummy_gender_landholder_effect = yes }
			create_character = {
				age = { 20 30 }
				location = root.capital_province
				gender = scope:dummy_gender
				trait = education_stewardship_2
				trait = intellect_good_2
				trait = diligent
				faith = this.faith
				culture = this.culture
				dynasty = none
				stewardship = { 10 12 }
				save_scope_as = freeman
			}
		}
	}

	#Recruit the peasant farmer to our court.
	option = {
		name = {
			trigger = {
				NOT = { has_trait = arrogant }
			}
			text = stewardship_wealth.1051.a
		}
		name = {
			trigger = {
				has_trait = arrogant
			}
			text = stewardship_wealth.1051.a.arrogant
		}
		trait = arrogant

		add_courtier = scope:freeman

		if = {
			limit = {
				NOT = { has_trait = arrogant }
			}
			scope:freeman = {
				add_opinion = {
					modifier = grateful_opinion
					target = root
					opinion = 25
				}
			}
		}
		else = {
			scope:freeman = {
				add_opinion = {
					modifier = insult_opinion
					target = root
					opinion = -10
				}
			}
		}

		stress_impact = {
			shy = minor_stress_gain
		}

		ai_chance = {
			base = 0
		}
	}

	#Allow the peasant farmer to buy your lands, gaining a lot of gold but suffering heavy county authority penalties.
	option = {
		name = stewardship_wealth.1051.b
		add_gold = medium_gold_value
		scope:target_county = {
			change_county_control = -20
			add_county_modifier = {
				modifier = governance_1051_independent_farmlands_modifier
				days = 1825
			}
		}
		hidden_effect = {
			scope:freeman = {
				death = {
					death_reason = death_disappearance
				}
			}
		}

		stress_impact = {
			paranoid = minor_stress_impact_gain
		}

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

	#Refuse to allow the farmer more land, solidifying your grip on the province.
	option = {
		name = stewardship_wealth.1051.d
		scope:target_county = {
			change_county_control = 10
		}
		hidden_effect = {
			scope:freeman = {
				death = {
					death_reason = death_disappearance
				}
			}
		}

		stress_impact = {
			generous = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100

			ai_value_modifier = {
				ai_compassion = -200
				ai_boldness = 100
				ai_vengefulness = 100
			}

			#If county authority is already so high this would have no benefit, the AI will avoid it.
			modifier = {
				factor = 0.2

				AND = {
					ai_rationality >= 10
					scope:target_county = {
						county_control >= 90
					}
				}
			}			
		}
	}
}


##################################
# New Acquisitions
# 1061
# by Sean Hughes
##################################

scripted_trigger stewardship_wealth_1061_valid_vassal = {

	# Must not be a Baron.
	highest_held_title_tier > 1

	# Must be available for events.
	is_available_ai_adult = yes

	# Must not hate me.
	opinion = {
		target = root
		value >= -10
	}

	save_temporary_scope_as = vassal
	
	# Must not be me.
	NOT = { root = scope:vassal }
	
	# Neither of us can have a hook on the other.
	NOR = {
		has_hook = root
		root = {
			has_hook = scope:vassal
		}
	}
}

#Character receives 3 different opportunities, they pick one to follow up on.
stewardship_wealth.1061 = {
	type = character_event
	title = stewardship_wealth.1061.t
	desc = stewardship_wealth.1061.desc
	
	theme = stewardship_wealth_focus
	left_portrait = {
		character = scope:vassal
		animation = idle
	}
	
	trigger = {
		any_vassal = {
			stewardship_wealth_1061_valid_vassal = yes
		}
		NOT = { has_character_flag = had_stewardship_wealth_1061_event }
	}

	weight_multiplier = {
		base = 1

		#More likely to occur if the character has high Diplomacy or Learning (or both).
		compare_modifier = {
			factor = diplomacy
			multiplier = 0.1
		}
		compare_modifier = {
			factor = learning
			multiplier = 0.1
		}

		downweight_for_focus_modifier = { FOCUS = stewardship_domain_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_stewardship_wealth_1061_event
			days = 3650
		}
		liege = {
			random_vassal_or_below = {
				limit = {
					stewardship < root.stewardship
					stewardship_wealth_1061_valid_vassal = yes
				}
				alternative_limit = {
					stewardship_wealth_1061_valid_vassal = yes
				}

				weight = {
					base = 1

					# Much higher chance to pick low-stewardship vassals.
					modifier = {
						stewardship <= low_skill_rating
						add = 100000
					}
					modifier = {
						stewardship <= mediocre_skill_rating
						add = 10000
					}
					modifier = {
						stewardship <= medium_skill_rating
						add = 1000
					}
					modifier = {
						stewardship <= decent_skill_rating
						add = 100
					}
					modifier = {
						stewardship <= high_skill_rating
						add = 10
					}
					modifier = {
						stewardship <= very_high_skill_rating
						add = 1
					}		

					# But a higher chance to pick higher-tier vassals (with more responsibility).
					compare_modifier = {
						factor = highest_held_title_tier
					}

				}
				save_scope_as = vassal
			}
		}
	}

	# Option A: Learning challenge to gain a powerful Stewardship modifier.
	option = {
		name = stewardship_wealth.1061.a

		duel = {
			skill = learning
			value = 10

			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = stewardship_wealth.1061.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_wealth.1061.a.success
					left_icon = root

					# Add large knowledge bonus
					add_character_modifier = {
						modifier = governance_1061_lost_knowledge_modifier
						years = 5
					}
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = stewardship_wealth.1061.a.failure
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_wealth.1061.a.failure
					left_icon = root
					
					# Add smaller knowledge bonus
					add_character_modifier = {
						modifier = governance_1061_old_ledger_modifier
						years = 5
					}
				}
			}
		}

		stress_impact = {
			dull = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50

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

			ai_value_modifier = {
				ai_rationality = 100
			}
		}
	}

	# Option B: Gain a Favor on a random vassal.
	option = {
		name = stewardship_wealth.1061.b

		#Gain a hook on the vassal
		add_hook = {
			target = scope:vassal
			type = favor_hook
		}

		stress_impact = {
			shy = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 200
				ai_greed = -100
			}
		}
	}
	
	# Option C: Just give me some gold.
	option = {
		name = stewardship_wealth.1061.c

		add_gold = major_gold_value

		stress_impact = {
			compassionate = minor_stress_impact_gain
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 200
				ai_compassion = -100
				ai_rationality = -100
			}
		}
	}
}

##################################
# Purchase Livestock
# 5001
# by Linnéa Thimrén
##################################

stewardship_wealth.5001 = {
	type = character_event
	title = stewardship_wealth.5001.t
	desc = stewardship_wealth.5001.desc
	
	theme = stewardship_wealth_focus
	left_portrait = {
		character = root
		animation = idle
	}
	
	trigger = {
		OR = {
			is_ai = no
			is_adult = yes
			has_lifestyle = stewardship_lifestyle
		}
		NOT = { has_character_flag = had_purchase_livestock_event }
		exists = capital_county
		capital_county = {
			NOR = {
				has_county_modifier = governance_cattle_herd_county_modifier
				has_county_modifier = governance_large_cattle_herd_county_modifier
			}
		}
	}

	weight_multiplier = {
		base = 1
		downweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}	

	immediate = {
		add_character_flag = {
			flag = had_purchase_livestock_event
			days = 3650
		}
		capital_county = {
			save_scope_as = capital
		}
	}

	option = { #give them to the county
		name = stewardship_wealth.5001.a
		scope:capital = {
			add_county_modifier = {
				modifier = governance_cattle_herd_county_modifier
				years = 15
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { #try to breed them
		name = stewardship_wealth.5001.b
		duel = {
			skill = stewardship
			value = medium_skill_rating
			30 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
				}
				desc = stewardship_wealth.5001.b.message_1
				send_interface_toast = {
					type = event_toast_effect_good
					left_icon = scope:capital
					title = stewardship_wealth.5001.b.message_1
					scope:capital = {
						add_county_modifier = {
							modifier = governance_large_cattle_herd_county_modifier
							years = 15
						}
					}
				}
			}
			10 = {
				desc = stewardship_wealth.5001.b.message_2
				send_interface_toast = {
					type = event_toast_effect_bad
					left_icon = scope:capital
					title = stewardship_wealth.5001.b.message_2
					add_prestige = miniscule_prestige_loss
				}
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}
	
	option = { #slaughter and sell
		name = stewardship_wealth.5001.c
		add_gold = medium_gold_value
		stress_impact = {
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
			}
		}
	}
}


##################################
# Investment advice (wealth friend)
# by Mathilda Bjarnehed
##################################

stewardship_wealth.5002 = { #by Mathilda Bjarnehed
	type = character_event
	title = stewardship_wealth.5002.t
	desc = {
		desc = stewardship_wealth.5002.start.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:safe_investment = flag:smithy }
				desc = stewardship_wealth.5002.safe_smithy.desc
			}
			triggered_desc = {
				trigger = { scope:safe_investment = flag:mason }
				desc = stewardship_wealth.5002.safe_mason.desc
			}
			triggered_desc = {
				trigger = { scope:safe_investment = flag:religious_sculptor }
				desc = stewardship_wealth.5002.safe_religious_sculptor.desc
			}
			triggered_desc = {
				trigger = { scope:safe_investment = flag:jeweler }
				desc = stewardship_wealth.5002.safe_jeweler.desc
			}
		}
		desc = stewardship_wealth.5002.middle.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:risky_investment = flag:smithy }
				desc = stewardship_wealth.5002.risky_smithy.desc
			}
			triggered_desc = {
				trigger = { scope:risky_investment = flag:mason }
				desc = stewardship_wealth.5002.risky_mason.desc
			}
			triggered_desc = {
				trigger = { scope:risky_investment = flag:religious_sculptor }
				desc = stewardship_wealth.5002.risky_religious_sculptor.desc
			}
			triggered_desc = {
				trigger = { scope:risky_investment = flag:jeweler }
				desc = stewardship_wealth.5002.risky_jeweler.desc
			}
		}
		desc = stewardship_wealth.5002.end.desc
	}
	
	theme = stewardship_wealth_focus
	override_background = {
		event_background = market
	}
	left_portrait = {
		character = scope:investor
		animation = personality_rational
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_stewardship_wealth_5002 }
		exists = capital_province
		capital_province.monthly_income >= 0.5
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_stewardship_wealth_5002
			years = stewardship_wealth_5002_investment_duration
		}
		random_relation = {
			type = friend
			limit = { lifestyle_friend_trigger = { CHARACTER = root FOCUS = stewardship_wealth_focus } }
			save_scope_as = investor
		}
		if = {
			limit = { NOT = { exists = scope:investor } }
			potential_lifestyle_friend_saving_effect = { FOCUS = stewardship_wealth_focus SCOPE_NAME = investor }
		}

		capital_province = { save_scope_as = capital }

		#Pick safe investment
		random_list = {
			1 = {
				save_scope_value_as = {
					name = safe_investment
					value = flag:smithy
				}
			}
			1 = {
				save_scope_value_as = {
					name = safe_investment
					value = flag:mason
				}
			}
			1 = {
				save_scope_value_as = {
					name = safe_investment
					value = flag:religious_sculptor
				}
			}
			1 = {
				save_scope_value_as = {
					name = safe_investment
					value = flag:jeweler
				}
			}
		}

		#Pick potential friend suggested option
		random_list = {
			1 = {
				trigger = { NOT = { scope:safe_investment = flag:smithy } }
				save_scope_value_as = {
					name = risky_investment
					value = flag:smithy
				}
			}
			1 = {
				trigger = { NOT = { scope:safe_investment = flag:mason } }
				save_scope_value_as = {
					name = risky_investment
					value = flag:mason
				}
			}
			1 = {
				trigger = { NOT = { scope:safe_investment = flag:religious_sculptor } }
				save_scope_value_as = {
					name = risky_investment
					value = flag:religious_sculptor
				}
			}
			1 = {
				trigger = { NOT = { scope:safe_investment = flag:jeweler } }
				save_scope_value_as = {
					name = risky_investment
					value = flag:jeweler
				}
			}
		}
	}

	#Safe investment
	option = {
		name = {
			trigger = { scope:safe_investment = flag:smithy }
			text = stewardship_wealth.5002.a.smithy
		}
		name = {
			trigger = { scope:safe_investment = flag:mason }
			text = stewardship_wealth.5002.a.mason
		}
		name = {
			trigger = { scope:safe_investment = flag:religious_sculptor }
			text = stewardship_wealth.5002.a.religious_sculptor
		}
		name = {
			trigger = { scope:safe_investment = flag:jeweler }
			text = stewardship_wealth.5002.a.jeweler
		}

		remove_short_term_gold = stewardship_wealth_5002_payment
		
		capital_province = {
			switch = {
				trigger = scope:safe_investment
				flag:smithy = {
					add_province_modifier = {
						modifier = smithy_investment_modifier
						years = stewardship_wealth_5002_investment_duration
					}
				}
				flag:mason = {
					add_province_modifier = {
						modifier = mason_investment_modifier
						years = stewardship_wealth_5002_investment_duration
					}
				}
				flag:religious_sculptor = {
					add_province_modifier = {
						modifier = religious_sculptor_investment_modifier
						years = stewardship_wealth_5002_investment_duration
					}
				}
				flag:jeweler = {
					add_province_modifier = {
						modifier = jeweler_investment_modifier
						years = stewardship_wealth_5002_investment_duration
					}
				}
			}
		}
	}

	#Risky investment
	option = {
		name = {
			trigger = { scope:risky_investment = flag:smithy }
			text = stewardship_wealth.5002.a.smithy
		}
		name = {
			trigger = { scope:risky_investment = flag:mason }
			text = stewardship_wealth.5002.a.mason
		}
		name = {
			trigger = { scope:risky_investment = flag:religious_sculptor }
			text = stewardship_wealth.5002.a.religious_sculptor
		}
		name = {
			trigger = { scope:risky_investment = flag:jeweler }
			text = stewardship_wealth.5002.a.jeweler
		}

		remove_short_term_gold = stewardship_wealth_5002_payment

		if = {
			limit = { has_relation_friend = scope:investor }
			capital_province = {
				switch = {
					trigger = scope:risky_investment
					flag:smithy = {
						add_province_modifier = {
							modifier = great_smithy_investment_modifier
							years = stewardship_wealth_5002_investment_duration
						}
					}
					flag:mason = {
						add_province_modifier = {
							modifier = great_mason_investment_modifier
							years = stewardship_wealth_5002_investment_duration
						}
					}
					flag:religious_sculptor = {
						add_province_modifier = {
							modifier = great_religious_sculptor_investment_modifier
							years = stewardship_wealth_5002_investment_duration
						}
					}
					flag:jeweler = {
						add_province_modifier = {
							modifier = great_jeweler_investment_modifier
							years = stewardship_wealth_5002_investment_duration
						}
					}
				}
			}
		}
		else = {
			random_list = {
				75 = {
					desc = stewardship_wealth.5002.b.success
					send_interface_toast = {
						type = event_toast_effect_good
						title = stewardship_wealth.5002.b.success
						left_icon = scope:investor
						
						set_relation_friend = scope:investor
						capital_province = {
							switch = {
								trigger = scope:risky_investment
								flag:smithy = {
									add_province_modifier = {
										modifier = great_smithy_investment_modifier
										years = stewardship_wealth_5002_investment_duration
									}
								}
								flag:mason = {
									add_province_modifier = {
										modifier = great_mason_investment_modifier
										years = stewardship_wealth_5002_investment_duration
									}
								}
								flag:religious_sculptor = {
									add_province_modifier = {
										modifier = great_religious_sculptor_investment_modifier
										years = stewardship_wealth_5002_investment_duration
									}
								}
								flag:jeweler = {
									add_province_modifier = {
										modifier = great_jeweler_investment_modifier
										years = stewardship_wealth_5002_investment_duration
									}
								}
							}
						}
					}
				}
				25 = {
					desc = stewardship_wealth.5002.b.failure
					send_interface_toast = {
						type = event_toast_effect_bad
						title = stewardship_wealth.5002.b.failure
						left_icon = scope:investor

						custom_tooltip = stewardship_wealth.5002.b.failure.tt
					}
				}
			}
		}
	}
	
	#Just trade at the market
	option = {
		name = stewardship_wealth.5002.c
		
		add_gold = stewardship_wealth_5002_one_time_gain
	}
}



###########################################################
# Events converted from the old Progress Event system.
# These events are all challenging event chains which should reward a perk point or some other significant benefit for successfully completing them.

namespace = stewardship_wealth_special
