﻿#Events related to the Spouse Councillor's stewardship task

namespace = councillor_spouse_stewardship

# Notifications events (1001-1999)
	#1001 - A temporary cost reduction for MaA regiments.
	#1002 - A build time boon modifier is added to a directly owned province
	#1003 - Cheaper buildings in a directly owned barony
	#1004 - They've organized your household better - get money!
	#1005 - They've handled your household well - prestige boost
	#1006 - They've handled your household well - courtier opinion boost
	#1007 - They keep you healthy - gain health modifier
	#1008 - They keep someone you care about healthy - they gain health modifier
	#1009 - Increase development growth for a county in need
	#1010 - Gain a favor hook on a courtier since your spouse helped them out


# Events (2001-4999)
	#2001 - What should your spouse invest money on?
	#2002 - Opportunity to borrow money from a courtier
	#2003 - Neighboring ruler as a trade-partner. Both get gold and opinion bonus.
	#2004 - Gain favor hook since your spouse helped a vassal out
	#2005 - Risky business opportunity!



#######################
# NOTIFICATION EVENTS
# 1001 - 1999
# by Linnéa Thimrén
#######################

#A temporary cost reduction for MaA regiments.
councillor_spouse_stewardship.1001 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1001
		}
	}

	weight_multiplier = {
		base = 0.25
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
		modifier = {
			add = 0.75
			is_at_war = yes
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1001
			days = 1825
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1001.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			
			add_character_modifier = {
				modifier = cheaper_men_at_arms_modifier
				days = 1825
			}
		}
	}
}

#A build time boon modifier is added to a directly owned barony
councillor_spouse_stewardship.1002 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1002
		}
		any_directly_owned_province = {
			has_free_building_slot = yes
			NOR = {
				has_holding_type = nomad_holding
				has_holding_type = herder_holding
			}
		}
	}

	weight_multiplier = {
		base = 0.75
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
		modifier = {
			add = 0.5
			scope:councillor = {
				has_trait = diligent
			}
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1002
			days = 1825
		}
		random_directly_owned_province = {
			limit = {
				has_free_building_slot = yes
				NOR = {
					has_holding_type = nomad_holding
					has_holding_type = herder_holding
				}
			}
			save_scope_as = province
			county = { save_scope_as = county_in_province }
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1002.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			right_icon = scope:county_in_province
			
			scope:province = {
				add_province_modifier = {
					modifier = less_building_time_modifier
					days = 3650
				}
			}
		}
	}
}


#Cheaper buildings in a directly owned barony
councillor_spouse_stewardship.1003 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1003
		}
		any_directly_owned_province = {
			has_free_building_slot = yes
			NOR = {
				has_holding_type = nomad_holding
				has_holding_type = herder_holding
			}
		}
	}

	weight_multiplier = {
		base = 0.75
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
		modifier = {
			add = 0.5
			scope:councillor = {
				has_trait = greedy
			}
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1003
			days = 1825
		}
		random_directly_owned_province = {
			limit = {
				has_free_building_slot = yes
				NOR = {
					has_holding_type = nomad_holding
					has_holding_type = herder_holding
				}
			}
			save_scope_as = province
			county = { save_scope_as = county_in_province }
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1003.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			left_icon = scope:councillor
			right_icon = scope:county_in_province
			scope:province = {
				add_province_modifier = {
					modifier = less_building_cost_modifier
					days = 3650
				}
			}
		}
	}
}


#They've organized your household better - get money!
councillor_spouse_stewardship.1004 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1004
		}
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1004
			days = 1825
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1004.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			
			add_gold = medium_gold_value
		}
	}
}


#They've handled your household well - prestige boost
councillor_spouse_stewardship.1005 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1005
		}
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1005
			days = 1825
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1005.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			
			add_prestige = medium_prestige_gain
		}
	}
}


#They've handled your household well - courtier opinion boost
councillor_spouse_stewardship.1006 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1006
		}
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1006
			days = 1825
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1006.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			
			every_courtier = {
				custom = councillor_spouse_stewardship_1006_every_courtier
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 10
				}
				hidden_effect = {
					if = {
						limit = {
							this != scope:councillor
						}
						add_opinion = {
							target = scope:councillor
							modifier = respect_opinion
							opinion = 10
						}
					}
				}
			}
		}
	}
}


#They keep you healthy - gain health modifier
councillor_spouse_stewardship.1007 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		spouse_stewardship_tier_2_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1007
		}
	}

	weight_multiplier = {
		base = 0.75
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
		modifier = {
			add = 1
			health <= poor_health
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1007
			days = 1825
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1007.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor

			add_character_modifier = {
				modifier = spouse_health_modifier
				days = 1825
			}
		}
	}
}

scripted_trigger councillor_spouse_stewardship_1008_courtier_trigger = {
	this != scope:councillor
	health <= poor_health
	is_adult = yes
	is_ai = yes
	OR = {
		is_close_or_extended_family_of = root
		has_relation_friend = root
	}
}

#They keep someone you care about healthy - they gain health modifier
councillor_spouse_stewardship.1008 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		spouse_stewardship_tier_2_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1008
		}
		any_courtier = {
			councillor_spouse_stewardship_1008_courtier_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_2
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1008
			days = 1825
		}
		random_courtier = {
			limit = {
				councillor_spouse_stewardship_1008_courtier_trigger = yes
			}
			save_scope_as = courtier_to_heal
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1008.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			right_icon = scope:courtier_to_heal
			
			scope:courtier_to_heal = {
				add_character_modifier = {
					modifier = spouse_health_modifier
					days = 1825
				}
			}
		}
	}
}

#Increase development growth for a county in need
councillor_spouse_stewardship.1009 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		spouse_stewardship_tier_2_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1009
		}
		any_directly_owned_province = {
			county = { development_level < medium_development_level }
			NOR = {
				has_holding_type = nomad_holding
				has_holding_type = herder_holding
			}
		}
	}

	weight_multiplier = {
		base = 0.75
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_2
		}
		modifier = {
			add = 0.25
			any_directly_owned_province = {
				county = { development_level <= bad_development_level }
			}
		}
		modifier = {
			add = 0.5
			any_directly_owned_province = {
				county = { development_level <= terrible_development_level }
			}
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1009
			days = 1825
		}
		if = {
			limit = {
				capital_county = {
					development_level < medium_development_level
					title_province = {
						NOR = {
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
				}
			}
			capital_county = {
				save_scope_as = county_to_develop
			}
		}
		else = {
			random_directly_owned_province = {
				limit = {
					county = { development_level < terrible_development_level }
					NOR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				alternative_limit = {
					county = { development_level < bad_development_level }
					NOR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				alternative_limit = {
					county = { development_level < medium_development_level }
					NOR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				county = { save_scope_as = county_to_develop }
			}
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1009.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			right_icon = scope:county_to_develop
			
			scope:county_to_develop = {
				add_county_modifier = {
					modifier = spouse_encouraged_growth_modifier
					days = 3650
				}
			}
		}
	}
}

scripted_trigger councillor_spouse_stewardship_1010_courtier_trigger = {
	this != scope:councillor
	is_adult = yes
	is_ai = yes
	root = {
		can_add_hook = {
			target = prev
			type = favor_hook
		}
	}
}

#Gain a favor hook on a courtier since your spouse helped them out
councillor_spouse_stewardship.1010 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		spouse_stewardship_tier_3_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1010
		}
		any_courtier = {
			councillor_spouse_stewardship_1010_courtier_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_3
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1010
			days = 1825
		}
		random_courtier = {
			limit = {
				councillor_spouse_stewardship_1010_courtier_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 2
					is_of_major_interest_to_root_trigger = yes
				}
			}
			save_scope_as = courtier_to_hook
		}
		send_interface_message = {
			type = msg_spouse_task_good
			title = councillor_spouse_stewardship.1010.desc
			desc = {
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship < average_skill_level }
					}
					desc = spouse_task_stewardship_good_unskilled_notification_tooltip
				}
				triggered_desc = {
					trigger = {
						scope:councillor = { stewardship >= average_skill_level }
					}
					desc = spouse_task_stewardship_good_skilled_notification_tooltip
				}
			}
			
			left_icon = scope:councillor
			right_icon = scope:courtier_to_hook
			
			add_hook = {
				target = scope:courtier_to_hook
				type = favor_hook
			}
		}
	}
}

#Remove a negative county modifier from the stewardship lifestyle. By Sean Hughes
scripted_trigger councillor_spouse_stewardship_1011_has_negative_modifier = {
	OR = {
		has_county_modifier = governance_1041_quarreling_guilds_modifier
		has_county_modifier = governance_1042_domineering_guild_modifier
		has_county_modifier = governance_1052_resentful_serfs_modifier
		has_county_modifier = governance_1053_corrupt_tax_collectors_modifier
	}
}

councillor_spouse_stewardship.1011 = {
	hidden = yes
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_1011
		}

		any_sub_realm_county = {
			councillor_spouse_stewardship_1011_has_negative_modifier = yes
		}
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
	}

	immediate = {
		cp:councillor_spouse = {
			save_scope_as = councillor
		}
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_1011
			days = 1825
		}

		random_sub_realm_county = {
			limit = {
				councillor_spouse_stewardship_1011_has_negative_modifier = yes
			}
			save_scope_as = target_county
		}

		if = {
			# Remove an uncooperative guild modifier.
			limit = {
				scope:target_county = {
					OR = {
						has_county_modifier = governance_1041_quarreling_guilds_modifier
						has_county_modifier = governance_1042_domineering_guild_modifier
					}
				}
			}
			send_interface_message = {
				type = msg_spouse_task_good
				title = councillor_spouse_stewardship.1011.desc.guilds
				desc = {
					triggered_desc = {
						trigger = {
							scope:councillor = { stewardship < average_skill_level }
						}
						desc = spouse_task_stewardship_good_unskilled_notification_tooltip
					}
					triggered_desc = {
						trigger = {
							scope:councillor = { stewardship >= average_skill_level }
						}
						desc = spouse_task_stewardship_good_skilled_notification_tooltip
					}
				}
				
				left_icon = scope:councillor
				right_icon = scope:target_county

				scope:target_county = {
					if = {
						limit = {
							scope:target_county = { has_county_modifier = governance_1041_quarreling_guilds_modifier}
						}
						remove_county_modifier = governance_1041_quarreling_guilds_modifier
					}
					else = {
						remove_county_modifier = governance_1042_domineering_guild_modifier
					}
				}
			}
		}
		else_if = {
			# Remove resentful serfs modifier
			limit = {
				scope:target_county = {
					has_county_modifier = governance_1052_resentful_serfs_modifier
				}
			}
			send_interface_message = {
				type = msg_spouse_task_good
				title = councillor_spouse_stewardship.1011.desc.serfs
				desc = {
					triggered_desc = {
						trigger = {
							scope:councillor = { stewardship < average_skill_level }
						}
						desc = spouse_task_stewardship_good_unskilled_notification_tooltip
					}
					triggered_desc = {
						trigger = {
							scope:councillor = { stewardship >= average_skill_level }
						}
						desc = spouse_task_stewardship_good_skilled_notification_tooltip
					}
				}
			
				left_icon = scope:councillor
				right_icon = scope:target_county

				scope:target_county = {
					remove_county_modifier = governance_1052_resentful_serfs_modifier
				}
			}
		}
		else_if = {
			# Remove corrupt tax collectors modifier
			limit = {
				scope:target_county = {
					has_county_modifier = governance_1053_corrupt_tax_collectors_modifier
				}
			}
			send_interface_message = {
				type = msg_spouse_task_good
				title = councillor_spouse_stewardship.1011.desc.corruption
				desc = {
					triggered_desc = {
						trigger = {
							scope:councillor = { stewardship < average_skill_level }
						}
						desc = spouse_task_stewardship_good_unskilled_notification_tooltip
					}
					triggered_desc = {
						trigger = {
							scope:councillor = { stewardship >= average_skill_level }
						}
						desc = spouse_task_stewardship_good_skilled_notification_tooltip
					}
				}
				
				left_icon = scope:councillor
				right_icon = scope:target_county

				scope:target_county = {
					remove_county_modifier = governance_1053_corrupt_tax_collectors_modifier
				}
			}
		}
	}
}


#######################
# EVENTS
# 2001 - 4999
# by Linnéa Thimrén
#######################

#What should your spouse focus on?
councillor_spouse_stewardship.2001 = {
	type = character_event
	title = councillor_spouse_stewardship.2001.t
	desc = councillor_spouse_stewardship.2001.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:councillor
		animation = steward
	}
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		spouse_stewardship_tier_2_trigger = yes
		is_available_adult = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_2001
		}
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_2
		}
	}

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

	option = { #Dinner party (courtier op boost)
		name = councillor_spouse_stewardship.2001.a
		every_vassal = {
			limit = {
				is_powerful_vassal_of = root
			}
			custom = councillor_spouse_stewardship_2001_every_powerful_vassal
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = low_positive_opinion
			}
			hidden_effect = {
				add_opinion = {
					target = scope:councillor
					modifier = friendliness_opinion
					opinion = low_positive_opinion
				}
			}
		}
		every_courtier = {
			custom = councillor_spouse_stewardship_1006_every_courtier
			limit = {
				this != scope:councillor
			}
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = low_positive_opinion
			}
			hidden_effect = {
				add_opinion = {
					target = scope:councillor
					modifier = friendliness_opinion
					opinion = low_positive_opinion
				}
			}
		}
		stress_impact = {
			gregarious = minor_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_energy = 1
			}
		}
	}
	option = { #Help the local area ( county modifier )
		name = councillor_spouse_stewardship.2001.b
		capital_county = {
			change_county_control = minor_county_control_gain
			add_county_modifier = {
				modifier = spouse_encouraged_growth_modifier
				days = 3650
			}
		}
		stress_impact = {
			generous = minor_stress_impact_loss
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 1
			}
		}
	}
	option = { #Intrigue defense
		name = councillor_spouse_stewardship.2001.c
		add_character_modifier = {
			modifier = spouse_increased_defenses_modifier
			years = 15
		}
		stress_impact = {
			deceitful = minor_stress_impact_loss
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			modifier = {
				add = 50
				has_trait = paranoid
			}
		}
	}
	option = { #Save the money
		name = councillor_spouse_stewardship.2001.d
		add_treasury_or_gold = medium_treasury_or_gold_value
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}
}

#Opportunity to borrow money from a courtier
scripted_trigger councillor_spouse_stewardship_2002_courtier_trigger = {
	NOR = {
		this = scope:councillor
		has_trait = greedy
		has_trait = gregarious
	}
	is_adult = yes
	is_ai = yes
	ai_boldness <= medium_positive_boldness
	opinion = {
		target = root
		value >= 10
	}
}

councillor_spouse_stewardship.2002 = {
	type = character_event
	title = councillor_spouse_stewardship.2002.t
	desc = councillor_spouse_stewardship.2002.desc
	theme = stewardship
	left_portrait = {
		character = scope:councillor
		animation = personality_greedy
	}
	right_portrait = {
		character = scope:courtier_lender
		animation = personality_content
	}
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		OR = {
			monthly_character_income < 0
			gold < tiny_gold_value
		}
		NOR = {
			exists = var:loan_holder #You can't already have a loan
			has_character_flag = had_event_vassal_2201
			has_character_flag = had_event_councillor_spouse_stewardship_2002
		}
		any_courtier = {
			councillor_spouse_stewardship_2002_courtier_trigger = yes
		}
		is_available_adult = yes
	}

	weight_multiplier = {
		base = 0.5
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_1
		}
		modifier = {
			add = 0.5
			monthly_character_income < 0
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_2002
			days = 3650
		}
		random_courtier = {
			limit = {
				councillor_spouse_stewardship_2002_courtier_trigger = yes
				gold >= tiny_gold_value
			}
			alternative_limit = {
				councillor_spouse_stewardship_2002_courtier_trigger = yes
			}
			weight = {
				base = 1
				modifier = { #If they already have the required gold that's awesome!
					add = 100
					short_term_gold >= root.medium_gold_value
				}
				modifier = {
					add = 2
					has_trait = generous
				}
				modifier = {
					add = 2
					has_trait = shy
				}
				modifier = {
					add = 1
					ai_boldness <= low_positive_boldness
				}
				modifier = {
					add = 1.5
					ai_boldness <= low_negative_boldness
				}
			}
			save_scope_as = courtier_lender
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
			root = {
				set_variable = {
					name = amount_to_loan
					value = 0
				}
				change_variable = {
					name = amount_to_loan
					add = medium_gold_value
				}
			}
		}
	}

	option = { #Loan money
		name = councillor_spouse_stewardship.2002.a
		hidden_effect = {
			scope:courtier_lender = {
				if = {
					limit = {
						short_term_gold < root.medium_gold_value
					}
					add_gold = root.medium_gold_value
				}
				pay_short_term_gold = {
					target = root
					gold = root.medium_gold_value
				}
			}
		}
		set_up_loan_effect = {
			LENDER = scope:courtier_lender
			AMOUNT = var:amount_to_loan
		}
		custom_tooltip = councillor_spouse_stewardship.2002.money_loan_tooltip
		custom_tooltip = vassal.2201.a.repay_loan
		remove_variable = amount_to_loan
		every_courtier = {
			limit = {
				NOT = {
					this = scope:councillor
					this = scope:courtier_lender
				}
			}
			custom = councillor_spouse_stewardship_1006_every_courtier
			add_opinion = {
				target = scope:courtier_lender
				modifier = reputation_opinion
				opinion = low_positive_opinion
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			just = minor_stress_impact_loss
		}
		ai_chance = {
			base = 80
			ai_value_modifier = {
				ai_greed = 2
			}
		}
	}

	option = { # Nah - give to the church
		name = councillor_spouse_stewardship.2002.b
		add_piety = medium_piety_gain
		if = {
			limit = {
				exists = root.faith.religious_head
				root.faith.religious_head != root
			}
			root.faith.religious_head = {
				add_opinion = {
					target = root
					modifier = donated_to_church_opinion
				}
			}
		}
		stress_impact = {
			cynical = medium_stress_impact_gain
			zealous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_zeal = 2
			}
		}
	}

	option = { # Nah - give to the poor
		name = councillor_spouse_stewardship.2002.c
		add_prestige = medium_prestige_gain
		stress_impact = {
			callous = medium_stress_impact_gain
			compassionate = medium_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 2
			}
		}
	}

	option = { #Take the money
		name = councillor_spouse_stewardship.2002.d
		trigger = { has_trait = greedy }
		trait = greedy
		hidden_effect = {
			scope:courtier_lender = {
				if = {
					limit = {
						short_term_gold < root.medium_gold_value
					}
					add_gold = root.medium_gold_value
				}
			}
		}
		scope:courtier_lender = {
			add_opinion = {
				target = root
				modifier = spouse_coerced_gift_opinion
			}
			pay_short_term_gold = {
				target = root
				gold = root.medium_gold_value
			}
		}
		add_dread = medium_dread_gain
		stress_impact = {
			just = minor_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		ai_chance = {
				base = 2
			ai_value_modifier = {
				dread_modified_ai_boldness = {
					dreaded_character = scope:courtier_lender
					value = 0.5
				}
				ai_greed = 2
			}
		}
	}
}


#Neighboring ruler as a trade-partner. Both get gold and opinion bonus.
scripted_trigger councillor_spouse_stewardship_2003_ruler_trigger = {
	exists = this
	this != scope:councillor
	NOT = { government_has_flag = government_is_theocracy }
	is_available_ai_adult = yes
	opinion = {
		target = root
		value >= low_negative_opinion
	}
}

councillor_spouse_stewardship.2003 = {
	type = character_event
	title = councillor_spouse_stewardship.2003.t
	desc = councillor_spouse_stewardship.2003.desc
	theme = stewardship
	left_portrait = {
		character = scope:councillor
		animation = chancellor
	}
	lower_left_portrait = scope:ruler_1
	lower_center_portrait = scope:ruler_2
	lower_right_portrait = scope:ruler_3
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		OR = { # Expensive, so we restrict the AI use of this
			is_ai = no
			highest_held_title_tier > tier_county
		}
		spouse_stewardship_tier_2_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_2003
		}
		trigger_if = {
			limit = {
				any_neighboring_realm_same_rank_owner = {
					councillor_spouse_stewardship_2003_ruler_trigger = yes
				}
			}
			any_neighboring_realm_same_rank_owner = {
				councillor_spouse_stewardship_2003_ruler_trigger = yes
				count = all
				add_to_temporary_list = neighbors
			}
		}
		trigger_if = {
			limit = {
				any_neighboring_top_liege_realm_owner = {
					councillor_spouse_stewardship_2003_ruler_trigger = yes
				}
			}			
			any_neighboring_top_liege_realm_owner = {
				councillor_spouse_stewardship_2003_ruler_trigger = yes
				count = all
				add_to_temporary_list = neighbors
			}
		}
		any_in_list = {
			list = neighbors
			councillor_spouse_stewardship_2003_ruler_trigger = yes
			count >= 3
		}
		is_available_adult = yes
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_2
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_2003
			days = 3650
		}
		every_neighboring_realm_same_rank_owner = {
			limit = {
				councillor_spouse_stewardship_2003_ruler_trigger = yes
			}
			add_to_list = neighboring_rulers
		}
		if = {
			limit = {
				any_in_list = {
					list = neighboring_rulers
					count < 3
				}
			}
			while = {
				limit = {
					any_in_list = {
						list = neighboring_rulers
						count < 3
					}
				}
				random_neighboring_top_liege_realm_owner = {
					limit = {
						councillor_spouse_stewardship_2003_ruler_trigger = yes
						NOT = { is_in_list = neighboring_rulers }
					}
					add_to_list = neighboring_rulers
				}
			}
		}
		random_in_list = {
			list = neighboring_rulers
			weight = {
				base = 1
				opinion_modifier = {
					opinion_target = root
					multiplier = 1
				}
				modifier = {
					add = 2
					number_of_personality_traits_in_common = {
						target = root
						value >= 2
					}
				}
			}
			save_scope_as = ruler_1
		}
		random_in_list = {
			list = neighboring_rulers
			limit = {
				this != scope:ruler_1
			}
			weight = {
				base = 1
				opinion_modifier = {
					opinion_target = root
					multiplier = 1
				}
				modifier = {
					add = 2
					number_of_personality_traits_in_common = {
						target = root
						value >= 2
					}
				}
			}
			save_scope_as = ruler_2
		}
		random_in_list = {
			list = neighboring_rulers
			limit = {
				NOR = {
					this = scope:ruler_1
					this = scope:ruler_2
				}
			}
			weight = {
				base = 1
				opinion_modifier = {
					opinion_target = root
					multiplier = 1
				}
				modifier = {
					add = 2
					number_of_personality_traits_in_common = {
						target = root
						value >= 2
					}
				}
			}
			save_scope_as = ruler_3
		}
	}

	option = { # ruler_1 seems the most reasonable!
		name = councillor_spouse_stewardship.2003.a
		scope:ruler_1 = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = opinion_boost_neighboring_ruler_value
			}
			add_treasury_or_gold = minor_treasury_or_gold_value
		}
		add_treasury_or_gold = scope:ruler_1.minor_treasury_or_gold_value
		add_opinion = {
			target = scope:ruler_1
			modifier = friendliness_opinion
			opinion = low_positive_opinion
		}
		ai_chance = {
			base = 50
			opinion_modifier = {
				opinion_target = scope:ruler_1
				multiplier = 0.5
			}
		}
	}
	option = { # I'll talk to ruler_2!
		name = councillor_spouse_stewardship.2003.b
		scope:ruler_2 = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = opinion_boost_neighboring_ruler_value
			}
			add_treasury_or_gold = minor_treasury_or_gold_value
		}
		add_treasury_or_gold = scope:ruler_2.minor_treasury_or_gold_value
		add_opinion = {
			target = scope:ruler_2
			modifier = friendliness_opinion
			opinion = low_positive_opinion
		}
		ai_chance = {
			base = 50
			opinion_modifier = {
				opinion_target = scope:ruler_2
				multiplier = 0.5
			}
		}
	}
	option = { # ruler_3 is my friend!
		name = councillor_spouse_stewardship.2003.c
		scope:ruler_3 = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = opinion_boost_neighboring_ruler_value
			}
			add_treasury_or_gold = minor_treasury_or_gold_value
		}
		add_treasury_or_gold = scope:ruler_3.minor_treasury_or_gold_value
		add_opinion = {
			target = scope:ruler_3
			modifier = friendliness_opinion
			opinion = low_positive_opinion
		}
		ai_chance = {
			base = 50
			opinion_modifier = {
				opinion_target = scope:ruler_3
				multiplier = 0.5
			}
		}
	}
	option = { # Nah
		name = {
			trigger = {
				has_trait = greedy
			}
			text = councillor_spouse_stewardship.2003.d_greedy
		}
		name = {
			trigger = {
				has_trait = arrogant
			}
			text = councillor_spouse_stewardship.2003.d_arrogant
		}
		name = {
			trigger = {
				always = yes
			}
			text = councillor_spouse_stewardship.2003.d
		}
		ai_chance = {
			base = 0
		}
	}
}

#Gain favor hook since your spouse helped a vassal out
scripted_trigger councillor_spouse_stewardship_2004_vassal_to_hook_trigger = {
	is_ai = yes
	this != scope:councillor
	root = {
		can_add_hook = {
			target = prev
			type = favor_hook
		}
	}
}

councillor_spouse_stewardship.2004 = {
	type = character_event
	title = councillor_spouse_stewardship.2004.t
	desc = councillor_spouse_stewardship.2004.desc
	theme = stewardship
	left_portrait = {
		character = scope:councillor
		animation = scheme
	}
	right_portrait = {
		character = scope:on_my_hook
		animation = personality_forgiving
	}
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		spouse_stewardship_tier_3_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_2004
		}
		any_vassal = {
			councillor_spouse_stewardship_2004_vassal_to_hook_trigger = yes
		}
		is_available_adult = yes
	}

	weight_multiplier = {
		base = 1
		councillor_spouse_limited_skill_rating_modifier = {
			SKILL = stewardship
			SCALE = 1
			SKILL_RATING = spouse_skill_rating_3
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_2004
			days = 3650
		}
		if = {
			limit = { root = { is_ai = no }	}
			scope:councillor = {
				assign_quirk_effect = yes
			}
		}
		random_vassal = {
			limit = {
				councillor_spouse_stewardship_2004_vassal_to_hook_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 3
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 1
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = on_my_hook
		}
	}

	option = { # Get that hook yo
		name = councillor_spouse_stewardship.2004.a
		add_hook = {
			target = scope:on_my_hook
			type = favor_hook
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	option = { # Nah
		name = councillor_spouse_stewardship.2004.b
		add_piety = minor_piety_gain
		scope:on_my_hook = {
			add_opinion = {
				target = root
				modifier = helped_me_in_time_of_need
				opinion = 10
				days = 1750
			}
		}
		stress_impact = {
			vengeful = medium_stress_impact_gain
			forgiving = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
		}
	}
}

#Risky business opportunity!
councillor_spouse_stewardship.2005 = {
	type = character_event
	title = councillor_spouse_stewardship.2005.t
	desc = councillor_spouse_stewardship.2005.desc
	theme = stewardship
	left_portrait = {
		character = scope:councillor
		animation = personality_greedy
	}
	
	trigger = {
		valid_spouse_councillor_trigger = yes
		spouse_stewardship_tier_1_trigger = yes
		NOT = {
			has_character_flag = had_event_councillor_spouse_stewardship_2005
		}
		any_directly_owned_province = {
			county = { development_level < good_development_level }
		}
		is_available_adult = yes
	}

	weight_multiplier = { #More likely the more development is needed
		base = 0.5
		modifier = {
			add = 0.25
			any_directly_owned_province = {
				county = { development_level < medium_development_level }
			}
		}
		modifier = {
			add = 0.25
			any_directly_owned_province = {
				county = { development_level < bad_development_level }
			}
		}
		modifier = {
			add = 0.25
			any_directly_owned_province = {
				county = { development_level < terrible_development_level }
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_councillor_spouse_stewardship_2005
			days = 3650
		}
		random_directly_owned_province = {
			limit = {
				county = { development_level < terrible_development_level }
			}
			alternative_limit = {
				county = { development_level < bad_development_level }
			}
			alternative_limit = {
				county = { development_level < medium_development_level }
			}
			alternative_limit = {
				county = { development_level < good_development_level }
			}
			county = { save_scope_as = county_to_boost }
		}
	}

	option = { # Go for risky opportunity!
		name = councillor_spouse_stewardship.2005.a
		random_list = {
			75 = {
				desc = councillor_spouse_stewardship.2005.a_1
				send_interface_toast = {
					left_icon = scope:county_to_boost
					title = councillor_spouse_stewardship.2005.a_1
					scope:county_to_boost = {
						add_county_modifier = {
							modifier = spouse_successful_business_modifier
							days = 3650
						}
					}
				}
			}
			25 = {
				desc = councillor_spouse_stewardship.2005.a_2
				send_interface_toast = {
					left_icon = scope:county_to_boost
					title = councillor_spouse_stewardship.2005.a_2
					scope:county_to_boost = {
						add_county_modifier = {
							modifier = spouse_failed_business_modifier
							days = 3650
						}
					}
				}
			}
		}
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_boldness = 0.75
			}
		}
	}
	option = { # I'll leave it to them
		name = councillor_spouse_stewardship.2005.b
		trigger = {
			gold >= minor_gold_value_check
		}
		scope:county_to_boost = {
			change_county_control = 15
		}
		remove_treasury_or_gold = minor_treasury_or_gold_value
		ai_chance = {
			base = 50
			modifier = {
				add = -50
				has_trait = greedy
			}
			modifier = {
				factor = 0
				short_term_treasury_or_gold <= minor_treasury_or_gold_value
			}
		}
	}

	option = {
		name = councillor_spouse_stewardship.2005.c
		add_prestige = medium_prestige_gain
		ai_chance = {
			base = 0
			modifier = { #Are things already going ok for the county?
				add = 25
				scope:county_to_boost = {
					development_rate > 1
				}
			}
			modifier = { #Are things already going ok for the county?
				add = 25
				scope:county_to_boost = {
					county_control > full_county_control
				}
			}
			modifier = { #Are things already going great for the county?
				add = 75
				scope:county_to_boost = {
					development_rate > 1
					county_control > full_county_control
				}
			}
		}
	}
}
