﻿#Events for Vassal and Liege relationships

namespace = vassal

# vassal.1001 - Religious liege wants you to build temple
# vassal.1101 - Religious vassal wants you to build temple
# vassal.2001 - Vassal wants liege to educate their child
# vassal.2101 - No feast in a while, vassal requests it
# vassal.2201 - You lend money from a vassal
# vassal.2205 - Vassal reminds you of the money you owe them
# vassal.2301 - Highly skilled vassal progresses development in province
# vassal.2401 - Vassal wants gold, offers territory/better Vassal Contract
# vassal.2451 - Vassal wants better contract, offers territory/gold
# vassal.2501 - Peaceful vassal complains about ongoing war
# vassal.2601 - Warmongering vassal complains about peace
# vassal.2701 - Ask vassal to teach you CT
# vassal.2801 - Liege complains abut no province improvement
# vassal.2901 - Vassal requesting land they have claim on
# vassal.3001 - You have no heir, ask a vassal for help
# vassal.5010 - Zealous vassal wants liege to fight religious enemies
# vassal.5050 - Vassal wants liege to fight war over his claim

#by Linnéa Thimrén and Tobias Bodlund

###########################################
# Religious liege wants you to build temple
# 1001 - 1020
# by Linnéa Thimrén
###########################################

vassal.1001 = {
	type = character_event
	title = vassal.1001.t
	desc = vassal.1001.desc
	
	theme = faith
	override_background = {
		event_background = farmland
	}
	left_portrait = scope:religious_liege
	
	trigger = {
		NOR = {
			exists = var:promised_to_build_temple
			has_character_flag = had_vassal_1001_event
			has_character_flag = had_vassal_1101_event
		}
		exists = liege
		liege = {
			NOT = { liege = this }
			faith = root.faith
			is_available_ai_adult = yes
			OR = {
				has_trait = zealous
				piety >= high_piety_level
			}
			root = { NOT = { has_hook = prev } }
		}
		gold >= 600
		any_directly_owned_province = {
			has_free_building_slot = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 0.3
			liege = {
				is_available_ai_adult = yes
				has_trait = zealous
				piety >= high_piety_level
			}
		}
		modifier = {
			add = 0.5
			any_directly_owned_province = {
				NOT = { has_building_with_flag = temple }
				has_free_building_slot = yes
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_vassal_1001_event
			days = 1460
		}
		liege = {
			assign_quirk_effect = yes
			save_scope_as = religious_liege
		}
	}

	option = { # Promise to build a temple
		name = vassal.1001.a
		custom_tooltip = vassal.1001.a.tt
		set_variable = { #To check if a promise has been made
			name = promised_to_build_temple
			value = scope:religious_liege
			days = 3655
		}
		add_character_flag = {
			flag = promised_liege_temple
			days = 3655
		}
		trigger_event = {
			id = vassal.1020
			days = 3650
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
				ai_zeal = 0.75
			}
		}
	}

	option = { #Nah
		name = {
			trigger = { has_trait = zealous }
			text = vassal.1001.b_zealous
		}
		name = {
			trigger = { NOT = { has_trait = zealous } }
			text = vassal.1001.b
		}
		add_piety = minor_piety_loss
		reverse_add_opinion = {
			modifier = refusal_opinion
			target = scope:religious_liege
			opinion = low_negative_opinion
		}
		stress_impact = {
			zealous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_greed = 0.75
			}
		}
	}
}


#A promise was made and you delivered!
vassal.1010 = {
	type = character_event
	title = vassal.1001.t
	desc = vassal.1010.desc
	
	theme = faith
	left_portrait = {
		character = scope:religious_liege
		animation = happiness
	}

	immediate = {
		var:promised_to_build_temple = {
			save_scope_as = religious_liege
		}
		reverse_add_opinion = {
			modifier = respect_opinion
			target = scope:religious_liege
			opinion = medium_positive_opinion
		}
	}

	option = {
		name = vassal.1010.a
		add_piety = major_piety_gain
		if = {
			limit = {
				can_add_hook = {
					target = scope:religious_liege
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:religious_liege
				type = favor_hook
			}
		}
	}

	after = {
		remove_variable = promised_to_build_temple
		remove_character_flag = promised_liege_temple
	}
}

#A promise was made and nothing has been built
vassal.1020 = {
	type = character_event
	title = vassal.1001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_trait = zealous
						piety >= high_piety_level
					}
				}
				desc = vassal.1020.desc_religious
			}
			desc = vassal.1020.desc_not_as_religious
		}
		desc = vassal.1020.desc
	}
	
	theme = unfriendly
	left_portrait = {
		character = scope:religious_liege
		animation = anger
	}
	
	trigger = {
		exists = var:promised_to_build_temple
		scope:religious_liege = { is_alive = yes }
		NOT = { has_character_flag = had_vassal_1001_event }
	}

	immediate = {
		var:promised_to_build_temple = {
			save_scope_as = religious_liege
		}
		reverse_add_opinion = {
			modifier = respect_opinion
			target = scope:religious_liege
			opinion = low_negative_opinion
		}
	}

	option = {
		name = {
			trigger = {
				NOR = {
					has_trait = zealous
					piety >= high_piety_level
				}
			}
			text = vassal.1020.a
		}
		name = {
			trigger = {
				OR = {
					has_trait = zealous
					piety >= high_piety_level
				}
			}
			text = vassal.1020.a_religious
		}
		custom_tooltip = vassal.1020.a.tt
		add_piety = medium_piety_loss
		if = {
			limit = {
				has_trait = zealous
			}
			stress_impact = {
				zealous = medium_stress_impact_gain
			}
		}
	}

	after = {
		remove_variable = promised_to_build_temple
		remove_character_flag = promised_liege_temple
	}
}

##############################################
# Religious vassal wants you to build temple
# 1101 - 1120
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_1101_religious_vassal_trigger = {
	faith = root.faith
	is_available_ai_adult = yes
	NOT = { root = { has_hook = prev } }
	OR = {
		has_trait = zealous
		piety_level >= high_piety_level
	}	
}

vassal.1101 = {
	type = character_event
	title = vassal.1001.t
	desc = vassal.1101.desc
	
	theme = vassal
	left_portrait = {
		character = scope:religious_vassal
		animation = personality_zealous
	}
	
	trigger = {
		has_government = feudal_government
		NOR = {
			exists = var:promised_to_build_temple
			has_character_flag = had_vassal_1101_event
			has_character_flag = had_vassal_1001_event
		}
		any_vassal = {
			vassal_1101_religious_vassal_trigger = yes
		}
		gold >= 600
		any_directly_owned_province = {
			has_free_building_slot = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 0.3
			any_vassal = {
				vassal_1101_religious_vassal_trigger = yes
				has_trait = zealous
				piety_level >= high_piety_level
			}
		}
		modifier = {
			add = 0.5
			any_directly_owned_province = {
				NOT = { has_building_with_flag = temple }
				has_free_building_slot = yes
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_vassal_1101_event
			days = 1460
		}
		random_vassal = {
			limit = {
				vassal_1101_religious_vassal_trigger = yes
			}
			weight = {
				base = 100
				modifier = {
					add = 100
					is_powerful_vassal = yes
				}
				modifier = {
					add = 100
					has_trait = zealous
					piety_level >= high_piety_level
				}
			}
			save_scope_as = religious_vassal
			assign_quirk_effect = yes
		}
	}

	option = { # Promise to build a temple
		name = vassal.1001.a
		custom_tooltip = vassal.1101.a.tt
		set_variable = { #To check if a promise has been made
			name = promised_to_build_temple
			value = scope:religious_vassal
			days = 3655
		}
		add_character_flag = {
			flag = promised_vassal_temple
			days = 3655
		}
		reverse_add_opinion = {
			modifier = friendliness_opinion
			target = scope:religious_vassal
			opinion = 10
		}
		trigger_event = {
			id = vassal.1120
			days = 3650
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
				ai_zeal = 0.75
			}
		}
	}

	option = { #Nah
		name = {
			trigger = { has_trait = zealous }
			text = vassal.1001.b_zealous
		}
		name = {
			trigger = { NOT = { has_trait = zealous } }
			text = vassal.1001.b
		}
		add_piety = minor_piety_loss
		reverse_add_opinion = {
			modifier = refusal_opinion
			target = scope:religious_vassal
			opinion = low_negative_opinion
		}
		stress_impact = {
			zealous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_greed = 0.75
			}
		}
	}
}


#A promise was made and you delivered!
vassal.1110 = {
	type = character_event
	title = vassal.1001.t
	desc = vassal.1110.desc
	
	theme = faith
	left_portrait = {
		character = scope:religious_vassal
		animation = happiness
	}

	immediate = {
		var:promised_to_build_temple = {
			save_scope_as = religious_vassal
		}
	}

	option = {
		name = vassal.1010.a
		reverse_add_opinion = {
			modifier = kept_promise
			target = scope:religious_vassal
		}
		if = {
			limit = {
				can_add_hook = {
					target = scope:religious_vassal
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:religious_vassal
				type = favor_hook
			}
		}
		add_piety = major_piety_gain
	}

	after = {
		remove_variable = promised_to_build_temple
		remove_character_flag = promised_vassal_temple
	}
}


#A promise was made and nothing has been built
vassal.1120 = {
	type = character_event
	title = vassal.1001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_trait = zealous
						piety >= high_piety_level
					}
				}
				desc = vassal.1120.desc_religious
			}
			desc = vassal.1120.desc_not_as_religious
		}
		desc = vassal.1120.desc
	}
	
	theme = unfriendly
	left_portrait = {
		character = scope:religious_vassal
		animation = anger
	}
	
	trigger = {
		exists = var:promised_to_build_temple
		NOT = { has_character_flag = had_vassal_1001_event }
	}

	immediate = {
		var:promised_to_build_temple = {
			save_scope_as = religious_vassal
		}
		reverse_add_opinion = {
			modifier = respect_opinion
			target = scope:religious_vassal
			opinion = low_negative_opinion
		}
	}

	option = {
		name = vassal.1120.a
		custom_tooltip = vassal.1120.a.tt
		add_piety = medium_piety_loss
	}

	after = {
		remove_variable = promised_to_build_temple
		remove_character_flag = promised_vassal_temple
	}
}


##############################################
# Vassal wants liege to educate their child
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2001_vassal_child_trigger = {
	num_of_relation_guardian = 0
	child_not_infant_trigger = yes
	NOT = { this = root }
	is_ruler = no
	is_imprisoned = no
}

scripted_trigger vassal_2001_vassal_trigger = {
	opinion = {
		target = root
		value >= neutral_opinion
	}
	NOT = {
		has_relation_rival = root
	}
	any_child = {
		vassal_2001_vassal_child_trigger = yes
	}
	root = {
		NOT = {
			has_hook = prev
		}
	}
}

vassal.2001 = {
	type = character_event
	title = vassal.2001.t
	desc = vassal.2001.desc
	
	theme = learning
	override_background = {
		event_background = throne_room
	}
	left_portrait = scope:vassal_proposing_education
	right_portrait = scope:child_to_educate
	
	trigger = {
		NOT = { has_character_flag = had_event_vassal_2001 }
		num_of_relation_ward < 2
		any_vassal = {
			vassal_2001_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if liege is highly skilled
			add = 0.5
			OR = {
				martial > high_skill_rating
				diplomacy > high_skill_rating
				intrigue > high_skill_rating
				learning > high_skill_rating
				stewardship > high_skill_rating
				prowess > high_skill_rating
			}
		}
		modifier = { #More likely if the vassal feels threatened
			add = 0.2
			dread > high_dread
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2001
			days = 1825
		}
		random_vassal = {
			limit = {
				vassal_2001_vassal_trigger = yes
			}
			weight = {
				base = 100
				modifier = {
					add = 100
					is_powerful_vassal = yes
				}
			}
			save_scope_as = vassal_proposing_education
			random_child = {
				limit = {
					vassal_2001_vassal_child_trigger = yes
				}
				assign_quirk_effect = yes
				save_scope_as = child_to_educate
			}
		}
	}

	option = { #Sure, I'll educate the child!
		name = vassal.2001.a
		add_hook = {
			target = scope:vassal_proposing_education
			type = favor_hook
		}
		scope:child_to_educate = {
			set_relation_guardian = root
			if = {
				limit = {
					NOT = {
						root = scope:child_to_educate.host
					}				
				}
				root = {
					add_visiting_courtier = scope:child_to_educate
				}				
			}
		}
	}

	option = { #I won't educate your kid
		name = vassal.2001.b
		reverse_add_opinion = {
			modifier = refusal_opinion
			target = scope:vassal_proposing_education
			opinion = low_negative_opinion
		}
	}
}

##############################################
# No feast in a while, vassal requests it
# 2101 - 2120
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2101_potential_vassal_trigger = {
	is_ai = yes
	NOR = {
		has_trait = shy
		has_opinion_modifier = {
			modifier = feast_hosted_successful_feast
			target = root
		}
	}
}

vassal.2101 = {
	type = character_event
	title = vassal.2101.t
	desc = vassal.2101.desc
	
	theme = vassal
	left_portrait = scope:party_vassal
	
	trigger = {
		NOT = { has_character_flag = had_event_vassal_2101 }
		is_at_war = no
		any_vassal = {
			count >= 1
			vassal_2101_potential_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 0.5
			any_vassal = {
				count >= 1
				is_ai = yes
				OR = {
					has_trait = reveler_1
					has_trait = reveler_2
					has_trait = reveler_3
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2101
			days = 3650
		}
		random_vassal = {
			limit = {
				vassal_2101_potential_vassal_trigger = yes
			}
			weight = {
				base = 100
				modifier = {
					add = 100
					is_powerful_vassal = yes
				}
				modifier = {
					add = 20
					has_trait = gregarious
				}
				modifier = {
					add = 20
					has_trait = reveler_1
				}
				modifier = {
					add = 40
					has_trait = reveler_2
				}
				modifier = {
					add = 60
					has_trait = reveler_3
				}
			}
			save_scope_as = party_vassal
			assign_quirk_effect = yes
		}
	}

	option = { #Sure, let's party!
		name = {
			trigger = {
				NOR = {
					has_trait = reveler_1
					has_trait = reveler_2
					has_trait = reveler_3
					has_trait = drunkard
				}
			}
			text = vassal.2101.a
		}
		name = {
			trigger = {
				OR = {
					has_trait = reveler_1
					has_trait = reveler_2
					has_trait = reveler_3
					has_trait = drunkard
				}
			}
			text = vassal.2101.a_hyped
		}
		custom_tooltip = vassal.2101.a.tt
		set_variable = {
			name = was_promised_a_feast
			value = scope:party_vassal
			days = 750
		}
		trigger_event = { #To check if the promise was kept
			id = vassal.2120
			days = 3650
		}
		scope:party_vassal = {
			add_opinion = {
				modifier = kindness_opinion
				target = root
				opinion = 10
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			temperate = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_boldness = 0.25
			}
		}
	}

	option = { #Refuse
		name = {
			trigger = { always = no }
			text = vassal.2101.b
		}
		name = {
			trigger = {
				has_trait = greedy
			}
			text = vassal.2101.b_greedy
		}
		name = {
			trigger = {
				has_trait = arrogant
			}
			text = vassal.2101.b_arrogant
		}
		name = {
			trigger = {
				has_trait = lazy
			}
			text = vassal.2101.b_lazy
		}
		name = {
			trigger = {
				has_trait = shy
			}
			text = vassal.2101.b_shy
		}
		trait = greedy
		trait = arrogant
		trait = lazy
		trait = shy
		scope:party_vassal = {
			add_opinion = {
				modifier = refusal_opinion
				target = root
				opinion = low_negative_opinion
			}
		}
		stress_impact = {
			reveler_1 = minor_stress_impact_gain
			reveler_2 = minor_stress_impact_gain
			reveler_3 = minor_stress_impact_gain
			drunkard = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.25
				
			}
		}
	}
}

#You delivered on your party-promise!
vassal.2110 = {
	type = character_event
	title = vassal.2101.t
	desc = vassal.2110.desc
	
	theme = vassal
	left_portrait = {
		character = scope:party_vassal
		animation = happiness
	}

	immediate = {
		var:was_promised_a_feast = {
			save_scope_as = party_vassal
		}
		remove_variable = was_promised_a_feast
		if = {
			limit = {
				scope:party_vassal = {
					OR = {
						has_trait = reveler_1
						has_trait = reveler_2
						has_trait = reveler_3
					}
				}
			}
			reverse_add_opinion = {
				modifier = kept_promise
				target = scope:party_vassal
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:party_vassal
				modifier = respect_opinion
				opinion = low_positive_opinion
			}
		}
	}

	option = {
		name = vassal.2110.a
	}
}


#You lied and never threw a party
vassal.2120 = {
	type = character_event
	title = vassal.2101.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_trait = reveler_1
						has_trait = reveler_2
						has_trait = reveler_3
					}
				}
				desc = vassal.2120.desc_party
			}
			desc = vassal.2120.desc_regular
		}
		desc = vassal.2120.desc
	}
	
	theme = unfriendly
	override_background = {
		event_background = throne_room
	}
	left_portrait = {
		character = scope:party_vassal
		animation = sadness
	}
	
	trigger = {
		exists = var:was_promised_a_feast
		var:was_promised_a_feast = {
			is_alive = yes
		}
	}

	immediate = {
		var:was_promised_a_feast = {
			save_scope_as = party_vassal
		}
		remove_variable = was_promised_a_feast
		reverse_add_opinion = {
			modifier = respect_opinion
			target = scope:party_vassal
			opinion = low_negative_opinion
		}
	}

	option = {
		name = vassal.2120.a
	}
}


##############################################
# Vassal offers loan to liege
# 2201 - 2205
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2201_potential_vassal_trigger = {
	is_adult = yes
	is_imprisoned = no
	is_ai = yes
	opinion = {
		target = root
		value >= 10
	}
	NOT = { has_trait = greedy }
	OR = {
		monthly_character_income > medium_income_multiplier_value
		gold > major_gold_value
	}
	NOT = {
		has_hook_of_type = {
			target = root
			type = favor_hook
		}
	}
}

vassal.2201 = {
	type = character_event
	title = vassal.2201.t
	desc = vassal.2201.desc
	
	theme = vassal
	left_portrait = scope:vassal_loan_holder
	
	trigger = {
		short_term_gold < medium_gold_value
		OR = {
			monthly_character_income < 0
			gold < tiny_gold_value
			is_at_war = yes
		}
		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_vassal = {
			vassal_2201_potential_vassal_trigger = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2201
			days = 3650
		}
		random_vassal = {
			limit = {
				vassal_2201_potential_vassal_trigger = yes
			}
			save_scope_as = vassal_loan_holder
			assign_quirk_effect = yes
			set_variable = {
				name = amount_to_loan
				value = major_gold_value
			}
		}
		set_variable = { #For tooltip only.
			name = amount_to_loan_root
			value = scope:vassal_loan_holder.var:amount_to_loan
		}
	}

	option = { #Accept
		name = vassal.2201.a
		set_up_loan_effect = {
			LENDER = scope:vassal_loan_holder
			AMOUNT = var:amount_to_loan_root
		}
		custom_tooltip = vassal.2201.a.money_loan_tooltip
		custom_tooltip = vassal.2201.a.repay_loan
		scope:vassal_loan_holder = {
			add_hook = {
				target = root
				type = favor_hook
			}
		}
		stress_impact = {
			paranoid = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = -80
				OR = {
					has_trait = paranoid
					opinion = {
						target = scope:vassal_loan_holder
						value <= neutral_opinion
					}
				}
			}
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_boldness = 0.25
			}
		}
	}

	option = { #I will not!
		name = vassal.2201.b
		reverse_add_opinion = {
			target = scope:vassal_loan_holder
			modifier = refusal_opinion
			opinion = -10
		}
		stress_impact = {
			base = medium_stress_impact_gain
			paranoid = medium_stress_impact_loss
			arrogant = medium_stress_impact_loss
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_greed = 0.5
				ai_honor = 0.25
			}
		}
	}
	after = {
		remove_variable = amount_to_loan_root
	}
}

#Vassal reminds you that you owe them money
vassal.2205 = {
	type = character_event
	title = vassal.2201.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					var:has_reminded_about_loan = 1
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								exists = scope:original_lender
								NOT = { exists = scope:original_loaner }
							}
							desc = vassal.2205.desc_inherited
						}
						triggered_desc = {
							trigger = {
								exists = scope:original_loaner
								NOT = { exists = scope:original_lender }
							}
							desc = vassal.2205.desc_inherited_loan
						}
						triggered_desc = {
							trigger = {
								exists = scope:original_loaner
								exists = scope:original_lender
							}
							desc = vassal.2205.desc_all_new_char
						}
						desc = vassal.2205.desc_first_time
					}
				}
			}
			triggered_desc = {
				trigger = {
					var:has_reminded_about_loan = 2
				}
				desc = vassal.2205.desc_second_time
			}
			triggered_desc = {
				trigger = {
					var:has_reminded_about_loan = 3
				}
				desc = vassal.2205.desc_three_times
			}
			triggered_desc = {
				trigger = {
					var:has_reminded_about_loan = 4
				}
				desc = vassal.2205.desc_more_times
			}
		}
	}
	
	theme = vassal
	left_portrait = {
		character = scope:vassal_loan_holder
		animation = personality_greedy
	}
	lower_left_portrait = scope:original_lender
	right_portrait = scope:original_loaner
	
	trigger = {
		exists = var:loan_holder
		var:loan_holder = {
			is_alive = yes
			NOT = { this = root }
		}
		NOT = {
			has_character_flag = had_event_vassal_2205
		}
	}

	weight_multiplier = {
		base = 0
		modifier = { #Possible to trigger even if you don't have enough money
			add = 0.5
			OR = {
				has_trait = greedy
				has_trait = impatient
			}
		}
		modifier = {
			add = 1
			gold > var:loan_amount_owed
		}
		modifier = {
			add = 0.2
			exists = var:has_reminded_about_loan
			var:has_reminded_about_loan = 1
		}
		modifier = {
			add = 0.5
			exists = var:has_reminded_about_loan
			var:has_reminded_about_loan = 2
		}
		modifier = {
			add = 1
			exists = var:has_reminded_about_loan
			var:has_reminded_about_loan = 3
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = var:has_reminded_about_loan }
			}
			set_variable = {
				name = has_reminded_about_loan
				value = 1
			}
		}
		else = {
			change_variable = {
				name = has_reminded_about_loan
				add = 1
			}
		}
		add_character_flag = {
			flag = had_event_vassal_2205
			days = 365
		}
		var:loan_holder = {
			save_scope_as = vassal_loan_holder
			assign_quirk_effect = yes
		}

		if = { #has the loan holder changed?
			limit = {
				scope:vassal_loan_holder = {
					exists = var:original_lender
				}
			}
			scope:vassal_loan_holder.var:original_lender = {
				save_scope_as = original_lender
			}
		}
		if = { #has the one owing money changed?
			limit = {
				exists = var:original_loan_holder
			}
			var:original_loan_holder = {
				save_scope_as = original_loaner
			}
		}
		if = { #Did you lie about repaying them?
			limit = {
				has_character_flag = promised_repayment
			}
			scope:vassal_loan_holder = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = low_negative_opinion
				}
			}
		}
	}

	option = { #Give money
		name = vassal.2205.z
		trigger = {
			gold >= var:loan_amount_owed
		}
		root = {
			pay_short_term_gold = {
				gold = var:loan_amount_owed
				target = var:loan_holder
			}
			remove_variable = loan_amount_owed
			remove_variable = loan_holder
			if = {
				limit = {
					has_character_flag = promised_repayment
				}
				remove_character_flag = promised_repayment
			}
			if = {
				limit = {
					exists = var:has_reminded_about_loan
				}
				remove_variable = has_reminded_about_loan
			}
			if = {
				limit = {
					exists = var:original_loan_holder
				}
				remove_variable = original_loan_holder
			}
		}
		scope:vassal_loan_holder = {
			remove_variable = owes_me_money
			if = {
				limit = {
					exists = var:original_lender
				}
				remove_variable = original_lender
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.25
			}
		}
	}
	option = { #Yes, yes, you'll get your money
		name = vassal.2205.a
		trigger = {
			var:has_reminded_about_loan <= 3
		}
		custom_tooltip = vassal.2205.a.tt
		if = {
				limit = {
					NOT = { has_character_flag = promised_repayment }
				}
			add_character_flag = promised_repayment
			}
		if = {
			limit = {
				var:has_reminded_about_loan = 2
			}
			scope:vassal_loan_holder = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = low_negative_opinion
				}
			}
			add_prestige = medium_prestige_loss
		}
		if = {
			limit = {
				var:has_reminded_about_loan = 2
			}
			scope:vassal_loan_holder = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = medium_negative_opinion
				}
			}
			add_prestige = major_prestige_loss
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.25
			}
		}
	}

	option = { #Stop bothering me about this
		name = vassal.2205.b
		trigger = {
			var:has_reminded_about_loan <= 3
		}
		if = {
			limit = {
				has_character_flag = promised_repayment
			}
			remove_character_flag = promised_repayment
		}
		if = {
			limit = {
				var:has_reminded_about_loan = 1
			}
			scope:vassal_loan_holder = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = low_negative_opinion
				}
			}
			add_prestige = minor_prestige_loss
		}
		else_if = {
			limit = {
				var:has_reminded_about_loan = 2
			}
			scope:vassal_loan_holder = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = medium_negative_opinion
				}
			}
			add_prestige = medium_prestige_loss
		}
		else_if = {
			limit = {
				var:has_reminded_about_loan = 3
			}
			progress_towards_rival_effect = {
				CHARACTER = scope:vassal_loan_holder
				OPINION = no
			}
			scope:vassal_loan_holder = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = medium_negative_opinion
				}
			}
			add_prestige = high_negative_opinion
		}
		stress_impact = {
			base = medium_stress_gain
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			arrogant = minor_stress_impact_loss
			greedy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				opinion = {
					target = scope:vassal_loan_holder
					value <= 0
				}
			}
			ai_value_modifier = {
				ai_vengefulness = 0.75
				ai_boldness = 0.25
				ai_compassion = -0.25
			}
		}
	}

	option = { #Last warning!!
		name = {
			trigger = { has_trait = greedy }
			text = vassal.2205.c_greedy
		}
		name = vassal.2205.c
		trigger = {
			var:has_reminded_about_loan >= 4
		}
		scope:vassal_loan_holder = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = medium_negative_opinion
			}
		}
		add_prestige = medium_prestige_loss
		progress_towards_rival_effect = {
			CHARACTER = scope:vassal_loan_holder
			OPINION = no
		}
		remove_variable = has_reminded_about_loan
		remove_variable = loan_amount_owed
		remove_variable = loan_holder
		scope:vassal_loan_holder = {
			remove_variable = owes_me_money
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

##############################################
# Highly skilled vassal progresses development in province
# by Linnéa Thimrén
##############################################
scripted_trigger vassal_2301_vassal_trigger = {
	is_available_ai_adult = yes
	holds_landed_title = yes
	OR = {
		diplomacy > high_skill_rating
		martial > high_skill_rating
		stewardship > high_skill_rating
		intrigue > high_skill_rating
		learning > high_skill_rating
	}
	capital_county = {
		NOT = { has_county_modifier = encouraged_improvement_modifier }
	}
}

vassal.2301 = {
	type = character_event
	title = vassal.2301.t
	desc = {
		desc = vassal.2301.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:skilled_vassal = { has_character_flag = high_diplomacy }
				}
				desc = vassal.2301.desc_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:skilled_vassal = { has_character_flag = high_martial }
				}
				desc = vassal.2301.desc_martial
			}
			triggered_desc = {
				trigger = {
					scope:skilled_vassal = { has_character_flag = high_stewardship }
				}
				desc = vassal.2301.desc_stewardship
			}
			triggered_desc = {
				trigger = {
					scope:skilled_vassal = { has_character_flag = high_intrigue }
				}
				desc = vassal.2301.desc_intrigue
			}
			triggered_desc = {
				trigger = {
					scope:skilled_vassal = { has_character_flag = high_learning }
				}
				desc = vassal.2301.desc_learning
			}
		}
		desc = vassal.2301.desc_ending
	}
	
	theme = vassal
	left_portrait = scope:skilled_vassal
	
	trigger = {
		NOT = { has_character_flag = had_event_vassal_2301 }
		any_vassal = {
			vassal_2301_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0
		modifier = {
			add = 1
			any_vassal = {
				vassal_2301_vassal_trigger = yes
				capital_county = {
					development_level <= bad_development_level
				}
			}
		}
		modifier = {
			add = 1
			any_vassal = {
				vassal_2301_vassal_trigger = yes
				is_powerful_vassal = yes
			}
		}
		modifier = {
			add = 0.5
			any_vassal = {
				vassal_2301_vassal_trigger = yes
				OR = {
					diplomacy > extremely_high_skill_rating
					martial > extremely_high_skill_rating
					stewardship > extremely_high_skill_rating
					intrigue > extremely_high_skill_rating
					learning > extremely_high_skill_rating
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2301
			days = 1825
		}
		random_vassal = {
			limit = {
				is_powerful_vassal = yes
				vassal_2301_vassal_trigger = yes
			}
			alternative_limit = {
				vassal_2301_vassal_trigger = yes
			}
			save_scope_as = skilled_vassal
			capital_county = {
				save_scope_as = develop_county
			}
			random_list = {
				10 = {
					trigger = {
						diplomacy > high_skill_rating
					}
					add_character_flag = {
						flag = high_diplomacy
						days = 50
					}
				}
				10 = {
					trigger = {
						martial > high_skill_rating
					}
					add_character_flag = {
						flag = high_martial
						days = 50
					}
				}
				10 = {
					trigger = {
						stewardship > high_skill_rating
					}
					add_character_flag = {
						flag = high_stewardship
						days = 50
					}
				}
				10 = {
					trigger = {
						intrigue > high_skill_rating
					}
					add_character_flag = {
						flag = high_intrigue
						days = 50
					}
				}
				10 = {
					trigger = {
						learning > high_skill_rating
					}
					add_character_flag = {
						flag = high_learning
						days = 50
					}
				}
			}
		}
	}

	option = { #I know this better than you
		name = {
			trigger = {
				scope:skilled_vassal = { has_character_flag = high_diplomacy }
			}
			text = vassal.2301.b_diplomacy
		}
		name = {
			trigger = {
				scope:skilled_vassal = { has_character_flag = high_martial }
			}
			text = vassal.2301.b_martial
		}
		name = {
			trigger = {
				scope:skilled_vassal = { has_character_flag = high_stewardship }
			}
			text = vassal.2301.b_stewardship
		}
		name = {
			trigger = {
				scope:skilled_vassal = { has_character_flag = high_intrigue }
			}
			text = vassal.2301.b_intrigue
		}
		name = {
			trigger = {
				scope:skilled_vassal = { has_character_flag = high_learning }
			}
			text = vassal.2301.b_learning
		}
		trigger = {
			OR = {
				AND = {
					scope:skilled_vassal = { has_character_flag = high_diplomacy }
					diplomacy > scope:skilled_vassal.diplomacy
				}
				AND = {
					scope:skilled_vassal = { has_character_flag = high_martial }
					martial > scope:skilled_vassal.martial
				}
				AND = {
					scope:skilled_vassal = { has_character_flag = high_stewardship }
					stewardship > scope:skilled_vassal.stewardship
				}
				AND = {
					scope:skilled_vassal = { has_character_flag = high_intrigue }
					intrigue > scope:skilled_vassal.intrigue
				}
				AND = {
					scope:skilled_vassal = { has_character_flag = high_learning }
					learning > scope:skilled_vassal.learning
				}
			}
		}
		scope:develop_county = {
			add_county_modifier = {
				modifier = encouraged_improvement_modifier
				days = 1825
			}
		}
		add_prestige = medium_prestige_gain
		stress_impact = {
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = -50
				opinion = {
					target = scope:skilled_vassal
					value >= 30
				}
			}
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_greed = 0.25
				ai_boldness = 0.25
				ai_vengefulness = 0.25
			}
		}
	}
	
	option = { #Encourage them
		name = vassal.2301.a
		scope:develop_county = {
			add_county_modifier = {
				modifier = encouraged_improvement_modifier
				days = 1825
			}
		}
		scope:skilled_vassal = {
			add_opinion = {
				target = root
				modifier = kindness_opinion
				opinion = low_positive_opinion
			}
		}
		add_prestige = minor_prestige_loss
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_rationality = 0.25
				ai_honor = 0.25
			}
		}
	}

	option = { #Nah
		name = vassal.2301.c
		scope:skilled_vassal = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -10
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				opinion = {
					target = scope:skilled_vassal
					value <= neutral_opinion
				}
			}
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_vengefulness = 0.25
			}
		}
	}
}


##############################################
# Vassal in need of gold, offers territory or improved Vassal Contract in exchange
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2401_potential_vassal_trigger = {
	is_ai = yes
	is_adult = yes
	is_imprisoned = no
	domain_size > 1 #Must not become landless.	
	vassal_contract_obligation_level_can_be_increased = feudal_government_taxes
	NOR = {
		has_government = theocracy_government
		has_government = republic_government
		has_government = holy_order_government
	}
	OR = {
		monthly_character_income < 0
		gold < tiny_gold_value
		is_at_war = yes
	}
	OR = {
		domain_size >= domain_limit
		vassal_contract_obligation_level:feudal_government_taxes <= feudal_tax_normal_level
	}
	any_directly_owned_province = {
		NOT = { is_county_capital = yes }
		exists = county
	}
}

vassal.2401 = {
	type = character_event
	title = vassal.2401.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					is_close_or_extended_family_of = scope:vassal_needs_gold
				}
				desc = vassal.2401.desc_family
			}
			desc = vassal.2401.desc_other
		}
		desc = vassal.2401.desc
	}
	
	theme = vassal
	left_portrait = {
		character = scope:vassal_needs_gold
		animation = beg
	}
	
	trigger = {
		any_vassal = {
			vassal_2401_potential_vassal_trigger = yes
		}
		NOT = { has_character_flag = had_event_vassal_2401 }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			domain_size >= domain_limit
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2401
			days = 3650
		}
		random_vassal = {
			limit = {
				vassal_2401_potential_vassal_trigger = yes
				is_powerful_vassal = yes
			}
			alternative_limit = {
				vassal_2401_potential_vassal_trigger = yes
			}
			assign_quirk_effect = yes
			save_scope_as = vassal_needs_gold
			random_directly_owned_province = {
				limit = {
					NOT = {
						is_county_capital = yes
					}
				}
				county = {
					save_scope_as = possible_county
				}
			}
		}
	}

	option = { #I'll take territory thx
		name = vassal.2401.a
		pay_short_term_gold = {
			target = scope:vassal_needs_gold
			gold = major_gold_value
		}
		create_title_and_vassal_change = change
		scope:change = {
			set_title_and_vassal_change_type = created
		}
		scope:possible_county = {
			change_title_holder = {
				holder = root
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -50
				domain_size >= domain_limit
			}
		}
	}

	option = { #We'll renegotiate your contract
		name = vassal.2401.b
		pay_short_term_gold = {
			target = scope:vassal_needs_gold
			gold = major_gold_value
		}
		scope:vassal_needs_gold = {
			vassal_contract_increase_obligation_level = feudal_government_taxes
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
		}
	}
	
	option = { #You can't have my gold!
		name = vassal.2401.c
		reverse_add_opinion = {
			modifier = refusal_opinion
			target = scope:vassal_needs_gold
			opinion = low_negative_opinion
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_zeal = 0.2
			}
		}
	}
}

##############################################
# Vassal wants better contract, offers territory or gold in exchange
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2451_potential_vassal_trigger = {
	has_government = feudal_government
	is_ai = yes
	is_adult = yes
	is_imprisoned = no
	domain_size > 1 #Must not become landless.
	highest_held_title_tier >= 2 #No Barons
	any_directly_owned_province = {
		is_county_capital = no
		exists = county
	}
}

vassal.2451 = {
	type = character_event
	title = vassal.2451.t
	desc = vassal.2451.desc
	
	theme = vassal
	left_portrait = scope:negotiating_vassal
	
	trigger = {
		any_vassal = {
			vassal_2451_potential_vassal_trigger = yes
			OR = { 
				vassal_contract_obligation_level_can_be_increased = feudal_government_taxes
				domain_size >= domain_limit
				gold >= major_gold_value
				is_powerful_vassal = yes
			}
		}
		NOT = { has_character_flag = had_event_vassal_2451 }
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #more likely to need gold
			add = 0.4
			is_at_war = yes
		}
		modifier = {
			add = 0.4
			domain_size < domain_limit
		}
		modifier = {
			add = 0.4
			gold <= minor_gold_value
		}
		modifier = {
			add = 0.4
			monthly_character_income < 0
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2451
			days = 3650
		}
		random_vassal = {
			limit = {
				vassal_2451_potential_vassal_trigger = yes
			}
			weight = {
				base = 100
				modifier = {
					add = 100
					is_powerful_vassal = yes
				}
				modifier = {
					add = 100
					domain_size >= domain_limit
				}
				modifier = {
					add = 100
					gold >= major_gold_value
				}
				modifier = {
					add = 100
					vassal_contract_obligation_level:feudal_government_taxes <= feudal_tax_normal_level
				}
			}
			assign_quirk_effect = yes
			save_scope_as = negotiating_vassal
			random_directly_owned_province = {
				limit = {
					is_county_capital = no
				}
				county = {
					save_scope_as = possible_county
				}
			}
		}
	}

	option = { #I'll take territory thx
		name = vassal.2451.a
		scope:negotiating_vassal = { vassal_contract_decrease_obligation_level = feudal_government_taxes }
		create_title_and_vassal_change = change
		scope:change = {
			set_title_and_vassal_change_type = created
		}
		scope:possible_county = {
			change_title_holder = {
				holder = root
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		ai_chance = {
			base = 50
			modifier = {
				add = -100
				domain_size >= domain_limit
			}
		}
	}

	option = { #Did you mention gold?
		name = vassal.2451.b
		scope:negotiating_vassal = { 
			vassal_contract_decrease_obligation_level = feudal_government_taxes
			pay_short_term_gold = {
				gold = medium_gold_value
				target = root
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 100
				gold <= minor_gold_value
			}
		}
	}
	
	option = { #You can't have a new contract!
		name = vassal.2451.c
		reverse_add_opinion = {
			modifier = refusal_opinion
			target = scope:negotiating_vassal
			opinion = low_negative_opinion
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 20
				opinion = {
					target = scope:negotiating_vassal
					value <= 0
				}
			}
			modifier = {
				add = 50
				opinion = {
					target = scope:negotiating_vassal
					value <= -10
				}
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_zeal = 0.2
			}
		}
	}
}

##############################################
# Peaceful vassal complains about ongoing war
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2501_potential_vassal_trigger = {
	is_ai = yes
	is_adult = yes
	is_imprisoned = no
	has_raised_armies = yes
	NOR = {
		has_trait = wrathful
		has_trait = vengeful
		has_trait = brave
		has_trait = sadistic
		has_trait = callous
	}
	opinion = {
		target = root
		value <= low_negative_opinion
	}
}

vassal.2501 = {
	type = character_event
	title = vassal.2501.t
	desc = vassal.2501.desc
	
	theme = vassal
	left_portrait = {
		character = scope:peaceful_vassal
		animation = sadness
	}
	
	trigger = {
		days_of_continuous_war > 730
		is_at_war = yes
		NOT = { has_character_flag = had_event_vassal_2501 }
		any_vassal = {
			vassal_2501_potential_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 0.5
			any_vassal = {
				is_ai = yes
				is_adult = yes
				is_imprisoned = no
				OR = {
					has_trait = craven
					has_trait = content
					has_trait = calm
					has_trait = forgiving
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2501
			days = 3650
		}
		random_vassal = {
			limit = {
				vassal_2501_potential_vassal_trigger = yes
			}
			weight = {
				base = 100
				modifier = {
					add = 100
					is_powerful_vassal = yes
				}
				modifier = {
					add = 100
					calc_true_if = {
						amount >= 2
						has_trait = craven
						has_trait = content
						has_trait = calm
						has_trait = forgiving
					}
				}
			}
			save_scope_as = peaceful_vassal
		}
	}

	option = { #Change vassal contract to make them like you
		name = vassal.2501.a
		trigger = {
			scope:peaceful_vassal = { vassal_contract_obligation_level_can_be_decreased = feudal_government_taxes }
		}
		scope:peaceful_vassal = {
			vassal_contract_decrease_obligation_level = feudal_government_taxes
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = medium_positive_opinion
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			vengeful = medium_stress_impact_gain
			wrathful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.75
			}
		}
	}

	option = { #Increase their obligations!
		name = vassal.2501.b
		trigger = {
			scope:peaceful_vassal = { vassal_contract_obligation_level_can_be_increased = feudal_government_taxes }
			dread >= medium_dread
		}
		scope:peaceful_vassal = {
			vassal_contract_increase_obligation_level = feudal_government_taxes
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = low_negative_opinion
			}
		}
		add_dread = minor_dread_gain
		stress_impact = {
			base = medium_stress_gain
			sadistic = medium_stress_impact_loss
			wrathful = medium_stress_impact_loss
			callous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = 0.75
			}
		}
	}

	option = { #Nah
		name = vassal.2501.c
		scope:peaceful_vassal = {
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = low_negative_opinion
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			calm = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.75
			}
		}
	}
}


##############################################
# Warmongering vassal complains about peace
# 2601 - 2620
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2601_potential_vassal_trigger = {
	is_ai = yes
	is_adult = yes
	is_imprisoned = no
	NOR = {
		has_trait = compassionate
		has_trait = craven
		has_trait = content
		has_trait = calm
		opinion = {
			target = scope:holder_of_claim
			value >= low_positive_opinion
		}
	}
}

scripted_trigger vassal_2601_holder_trigger = {
	any_neighboring_top_liege_realm_owner = { this = root }
	max_military_strength < root.max_military_strength
}

vassal.2601 = {
	type = character_event
	title = vassal.2601.t
	desc = vassal.2601.desc
	
	theme = vassal
	left_portrait = {
		character = scope:warmongering_vassal
		animation = personality_callous
	}
	right_portrait = scope:holder_of_claim
	
	trigger = {
		NOT = { has_character_flag = had_event_vassal_2601 }
		days_of_continuous_peace > 730
		any_claim = {
			exists = holder
			holder = {
				vassal_2601_holder_trigger = yes
				save_temporary_scope_as = holder_of_claim
			}
		}
		any_vassal = {
			vassal_2601_potential_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 0.3
			any_vassal = {
				is_ai = yes
				is_adult = yes
				is_imprisoned = no
				OR = {
					has_trait = wrathful
					has_trait = vengeful
					has_trait = impatient
					has_trait = brave
				}
			}
		}
		modifier = {
			add = 0.3
			any_vassal = {
				is_ai = yes
				is_adult = yes
				is_imprisoned = no
				OR = {
					number_of_commander_traits >= 1
					ai_boldness = medium_positive_boldness
					ai_vengefulness = medium_positive_vengefulness
					ai_zeal = medium_positive_zeal
					martial >= medium_skill_rating
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2601
			days = 3650
		}
		random_claim = {
			limit = {
				holder = {
					vassal_2601_holder_trigger = yes
				}
			}
			weight = {
				base = 100
		  	  	modifier = {
			  	  	add = {
						value = 1
						subtract = {
							value = this.holder.max_military_strength
							divide = { value = root.max_military_strength min = 1 }
						}
						multiply = 20
					}
				}
			}
			save_scope_as = claim_to_fight_for
			holder = { save_scope_as = holder_of_claim }
		}
		random_vassal = {
			limit = {
				vassal_2601_potential_vassal_trigger = yes
			}
			weight = {
				base = 100
				modifier = {
					add = 30
					culture = root.culture
				}
				modifier = {
					add = 30
					faith = root.faith
				}
				modifier = {
					add = 30
					dynasty = root.dynasty
				}
				modifier = {
					add = 70
					is_powerful_vassal = yes
				}
				modifier = {
					add = 100
					calc_true_if = {
						amount >= 2
						has_trait = wrathful
						has_trait = vengeful
						has_trait = impatient
						has_trait = brave
					}
				}
				modifier = {
					add = 100
					OR = {
						number_of_commander_traits >= 1
						ai_boldness = medium_positive_boldness
						ai_vengefulness = medium_positive_vengefulness
						ai_zeal = medium_positive_zeal
						martial >= medium_skill_rating
					}
				}
			}
			save_scope_as = warmongering_vassal
			assign_quirk_effect = yes
		}
	}

	option = { #Yeah sure, let's go to war
		name = vassal.2601.a
		custom_tooltip = vassal.2601.a.tt
		scope:warmongering_vassal = {
			add_character_modifier = {
				modifier = increased_levies_modifier
				days = 1825
			}
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = medium_positive_opinion
			}
		}
		set_variable = {
			name = promised_war
			value = scope:warmongering_vassal
			days = 1850
		}
		set_variable = {
			name = promised_to_claim
			value = scope:claim_to_fight_for
			days = 1850
		}
		trigger_event = {
			id = vassal.2620
			days = 1830
		}
		stress_impact = {
			craven = medium_stress_impact_gain
			content = medium_stress_impact_gain
			calm = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_boldness = 0.5
				ai_zeal = 0.5
			}
		}
	}
	
	option = { #Nah
		name = vassal.2601.b
		scope:warmongering_vassal = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = low_negative_opinion
			}
		}
		add_prestige = medium_prestige_loss
		stress_impact = {
			wrathful = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_rationality = 0.5
			}
		}
	}
}

#You declared war and your warmongering vassal is happy
vassal.2610 = {
	type = character_event
	title = vassal.2601.t
	desc = vassal.2610.desc
	
	theme = vassal
	left_portrait = {
		character = scope:warmongering_vassal
		animation = ecstasy
	}

	immediate = {
		var:promised_war = {
			save_scope_as = warmongering_vassal
		}
		var:promised_to_claim = {
			save_scope_as = claim_to_fight_for
		}
		scope:warmongering_vassal = {
			add_opinion = {
				modifier = kept_promise
				target = root
			}
		}
	}

	option = {
		name = vassal.2610.a
	}

	after = {
		remove_variable = promised_war
		remove_variable = promised_to_claim
	}
}

#You promised vassal a war, but never declared one
vassal.2620 = {
	type = character_event
	title = vassal.2601.t
	desc = vassal.2620.desc
	
	theme = unfriendly
	left_portrait = {
		character = scope:warmongering_vassal
		animation = anger
	}
	
	trigger = {
		exists = var:promised_war
		var:promised_war = {
			is_alive = yes
			is_vassal_of = root
		}
	}

	immediate = {
		scope:claim_to_fight_for.holder = { save_scope_as = holder_of_claim }
		var:promised_war = {
			save_scope_as = warmongering_vassal
		}
		scope:warmongering_vassal = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = low_negative_opinion
			}
		}
		add_prestige = medium_prestige_loss
		remove_variable = promised_war
	}

	option = {
		name = vassal.2620.a
	}
}

##############################################
# Demand commander training from vassal
# 2701 - 2702
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2701_potential_vassal_trigger = {
	is_available_healthy_ai_adult = yes
	number_of_commander_traits >= 1
	root = { character_has_commander_trait_scope_does_not = prev }
}

vassal.2701 = {
	type = character_event
	title = vassal.2701.t
	desc = vassal.2701.desc
	
	theme = vassal
	left_portrait = scope:teacher
	
	trigger = {
		is_available_adult = yes
		NOT = {
			has_character_flag = had_event_vassal_2701
		}
		has_lifestyle = martial_lifestyle
		any_vassal = {
			vassal_2701_potential_vassal_trigger = yes
		}
		number_of_commander_traits < 3
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			factor = martial
			multiplier = 0.1
			max = 2
		}
		modifier = {
			add = -0.8
			number_of_commander_traits = 1
		}
		modifier = {
			add = -0.1
			number_of_commander_traits = 2
		}
		modifier = {
			add = 0.3
			any_vassal = {
				vassal_2701_potential_vassal_trigger = yes
				opinion = {
					target = root
					value >= low_positive_opinion
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2701
			days = 3650
		}
		add_character_flag = {
			flag = being_taught_commander_trait
			days = 1825
		}
		random_vassal = {
			limit = {
				vassal_2701_potential_vassal_trigger = yes
			}
			save_scope_as = teacher
		}
		randomize_commander_trait_to_be_taught_effect = yes
	}

	option = {
		name = vassal.2701.a
		pay_short_term_gold = {
			gold = minor_gold_value
			target = scope:teacher
		}
		scope:teacher = {
			add_prestige = medium_prestige_gain
		}
		show_as_tooltip = {
			random_list = {
				50 = {
					desc = vassal.2701.a.random_list.success
					compare_modifier = {
						target = scope:teacher
						factor = learning
						multiplier = 0.2
						max = 2
					}
					compare_modifier = {
						factor = martial
						multiplier = 0.2
						max = 2
					}
					compare_modifier = {
						factor = prowess
						multiplier = 0.2
						step = 0.1
						max = 2
					}
					modifier = {
						factor = 1.3
						reverse_opinion = {
							target = scope:teacher
							value >= 10
						}
					}
					modifier = {
						add = 20
						has_education_martial_trigger = yes
					}
					modifier = {
						factor = 0.6
						reverse_opinion = {
							target = scope:teacher
							value <= neutral_opinion
						}
					}
					add_character_flag = {
						flag = will_learn_ct
						days = 50
					}
					learn_commander_trait_success_effect = yes
				}
				50 = {
					desc = vassal.2701.a.random_list.failure
					custom_tooltip = vassal.2701.a.tt
				}
			}
		}
		trigger_event = {
			id = vassal.2702
			days = { 30 50 }
		}
		stress_impact = {
			wrathful = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = -100
				OR = {
					tyranny >= medium_tyranny
					dread >= medium_dread
					has_trait = wrathful
					has_trait = arrogant
				}
			}
		}
	}

	option = { #Nah
		name = vassal.2701.c
		custom_tooltip = learn_commander_trait.11.b.tt
		add_prestige = minor_prestige_loss
		ai_chance = {
			base = 0
		}
	}
}

#Did you learn a commander trait?
vassal.2702 = {
	type = character_event
	title = vassal.2701.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = will_learn_ct
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									has_education_martial_trigger = yes
									has_lifestyle = martial_lifestyle
								}
							}
							desc = vassal.2702.desc_success_inclination
						}
						desc = vassal.2702.desc_success_no_inclination
					}
				}
			}
			desc = vassal.2702.desc_failure
		}
	}
	
	theme = vassal
	override_background = {
		event_background = courtyard
	}
	left_portrait = {
		character = scope:teacher
		triggered_animation = {
			trigger = { has_character_flag = will_learn_ct }
			animation = happiness
		}
		triggered_animation = {
			trigger = { always = yes }
			animation = idle
		}
	}

	immediate = {
		hidden_effect = {
			random_list = {
				50 = {
					compare_modifier = {
						target = scope:teacher
						factor = learning
						multiplier = 0.2
						max = 2
					}
					compare_modifier = {
						factor = martial
						multiplier = 0.2
						max = 2
					}
					compare_modifier = {
						factor = prowess
						multiplier = 0.2
						step = 0.1
						max = 2
					}
					modifier = {
						factor = 1.3
						reverse_opinion = {
							target = scope:teacher
							value >= 10
						}
					}
					modifier = {
						add = 20
						has_education_martial_trigger = yes
					}
					modifier = {
						factor = 0.6
						reverse_opinion = {
							target = scope:teacher
							value <= neutral_opinion
						}
					}
					add_character_flag = {
						flag = will_learn_ct
						days = 50
					}
					learn_commander_trait_success_effect = yes
				}
				50 = { }
			}
		}
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:logistician
		}
		trait = logistician
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:military_engineer
		}
		trait = military_engineer
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:aggressive_attacker
		}
		trait = aggressive_attacker
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:unyielding_defender
		}
		trait = unyielding_defender
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:forder
		}
		trait = forder
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:flexible_leader
		}
		trait = flexible_leader
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:desert_warrior
		}
		trait = desert_warrior
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:jungle_stalker
		}
		trait = jungle_stalker
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:reaver
		}
		trait = reaver
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:reckless
		}
		trait = reckless
	}

	option = {
		name = vassal.2702.a
		trigger = {
			has_character_flag = will_learn_ct
			var:commander_trait_being_taught = flag:holy_warrior
		}
		trait = holy_warrior
	}

	option = {
		name = vassal.2702.b
		trigger = {
			NOT = {
				has_character_flag = will_learn_ct
			}
		}
	}

	after = {
		if = {
			limit = {
				exists = var:commander_trait_being_taught
			}
			remove_variable = commander_trait_being_taught
		}
		if = {
			limit = {
				has_character_flag = will_learn_ct
			}
			remove_character_flag = will_learn_ct
		}
		if = {
			limit = {
				has_character_flag = being_taught_commander_trait
			}
			remove_character_flag = being_taught_commander_trait
		}
	}
}

##############################################
# Liege complains abut no province improvement
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2801_potential_province_trigger = {
	has_free_building_slot = yes
	NOR = {
		has_construction_with_flag = temple
		has_construction_with_flag = castle
		has_construction_with_flag = city
	}
}

vassal.2801 = {
	type = character_event
	title = vassal.2801.t
	desc = vassal.2801.desc
	
	theme = vassal
	left_portrait = {
		character = scope:industrious_liege
		animation = personality_callous
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_vassal_2801 }
		is_independent_ruler = no
		exists = liege
		liege = {
			is_available_ai_adult = yes
		}
		any_directly_owned_province = {
			vassal_2801_potential_province_trigger = yes
		}
		gold >= 600
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 0.2
			liege = {
				has_trait = diligent
			}
		}
		modifier = {
			add = 0.2
			gold >= 1200
		}
		modifier = {
			add = 0.2
			gold >= 1800
		}
		modifier = {
			add = 0.2
			gold >= 2400
		}
		modifier = {
			add = 0.7
			any_directly_owned_province = {
				has_free_building_slot = yes
				count >= 3
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2801
			days = 3650
		}
		liege = {
			save_scope_as = industrious_liege
		}
		random_directly_owned_province = {
			limit = {
				vassal_2801_potential_province_trigger = yes
				county = {
					development_level <= bad_development_level
				}
			}
			alternative_limit = {
				vassal_2801_potential_province_trigger = yes
			}
			county = {
				save_scope_as = develop_county
			}
		}
	}

	option = { #I'll get right on it!
		name = vassal.2801.a
		scope:develop_county = {
			add_county_modifier = {
				modifier = less_building_time_modifier
				days = 3650
			}
		}
		stress_impact = {
			lazy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 40
				OR = {
					has_trait = diligent
					has_trait = ambitious
				}
			}
			compare_modifier = {
				target = scope:industrious_liege
				factor = dread
				multiplier = 0.2
				max = 2
			}
		}
	}

	option = { #Only if you decrease obligations.
		name = vassal.2801.b
		trigger = { vassal_contract_obligation_level_can_be_decreased = feudal_government_taxes }
		vassal_contract_decrease_obligation_level = feudal_government_taxes
		scope:industrious_liege = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = low_negative_opinion
			}
		}
		stress_impact = {
			diligent = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 30
				OR = {
					has_trait = lazy
					has_trait = content
					has_trait = wrathful
				}
			}
			modifier = {
				add = 20
				opinion = {
					target = scope:industrious_liege
					value <= neutral_opinion
				}
			}
		}
	}
}

##############################################
# Vassal requesting land they have claim on that you're the holder of
# 2901 - 2910
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_2901_claim_vassal_trigger = {
	is_available_ai_adult = yes
	highest_held_title_tier > 1 #No Barons
	NOR = {
		has_government = theocracy_government
		has_government = republic_government
		has_government = holy_order_government
	}
	any_claim = {
		pressed = no
		holder = root
		NOT = { this = root.primary_title }
	}
	NOT = { root = { has_hook = prev } }
}

vassal.2901 = {
	type = character_event
	title = vassal.2901.t
	desc = vassal.2901.desc
	
	theme = vassal
	left_portrait = {
		character = scope:claim_vassal
		animation = personality_callous
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_vassal_2901 }
		highest_held_title_tier > 2 #Dukes or above.
		any_vassal = {
			vassal_2901_claim_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0.8
		modifier = {
			add = 0.2
			any_vassal = {
				vassal_2901_claim_vassal_trigger = yes
				has_trait = ambitious
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_vassal_2901
			days = 7200
		}
		random_vassal = {
			limit = {
				vassal_2901_claim_vassal_trigger = yes
				is_powerful_vassal = yes
			}
			alternative_limit = {
				vassal_2901_claim_vassal_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					has_trait = ambitious
					add = 2
				}
			}
			save_scope_as = claim_vassal
		}
		scope:claim_vassal = {
			random_claim = {
				pressed = no
				limit = {
					save_temporary_scope_as = this_claim
					holder = {
						NOT = { scope:this_claim = this.primary_title }
						this = root
					}
				}
				save_scope_as = claim_to_propose
			}
		}
	}

	option = { #Take it now then.
		name = vassal.2901.z
		create_title_and_vassal_change = change
		scope:change = {
			set_title_and_vassal_change_type = created
		}
		scope:claim_to_propose = {
			change_title_holder = {
				holder = scope:claim_vassal
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		if = {
			limit = {
				can_add_hook = {
					target = scope:claim_vassal
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:claim_vassal
				type = favor_hook
			}
		}
		else = {
			add_prestige = major_prestige_gain
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = medium_positive_opinion
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
			just = medium_stress_impact_loss
			generous = medium_stress_impact_loss
		}
	}

	option = { #I'll make it happen!
		name = vassal.2901.a
		custom_tooltip = vassal.2901.a.tt
		scope:claim_vassal = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = low_positive_opinion
			}
			set_variable = {
				name = promised_title
				value = scope:claim_to_propose
			}
		}
		set_variable = {
			name = was_promised_title
			value = scope:claim_vassal
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}
		trigger_event = {
			id = vassal.2911
			days = 3650
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.25
			}
			modifier = {
				add = 20
				opinion = {
					target = scope:claim_vassal
					value >= low_positive_opinion
				}
			}
		}
	}
	
	option = { #nah
		name = vassal.2901.b
		scope:claim_vassal = {
			add_opinion = {
				modifier = refusal_opinion
				target = root
				opinion = low_negative_opinion
			}
		}
		stress_impact = {
			generous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.75
				ai_vengefulness = 0.5
				ai_rationality = 0.25
			}
		}
	}
}

#You granted the vassal the desired title
vassal.2910 = {
	type = character_event
	title = vassal.2901.t
	desc = vassal.2910.desc
	
	theme = vassal
	left_portrait = {
		character = scope:recipient
		animation = happiness
	}

	immediate = {
		scope:recipient = {
			var:promised_title = {
				save_scope_as = claim_to_propose
			}
		}
	}

	option = {
		name = vassal.2910.a
		if = {
			limit = {
				can_add_hook = {
					target = scope:recipient
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:recipient
				type = favor_hook
			}
		}
		else = {
			add_prestige = major_prestige_gain
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = medium_positive_opinion
			}
		}
	}

	after = {
		remove_variable = was_promised_title
		scope:recipient = {
			remove_variable = promised_title
		}
	}
}


#You did not grant the vassal the desired title
vassal.2911 = {
	type = character_event
	title = vassal.2901.t
	desc = vassal.2911.desc
	
	theme = unfriendly
	override_background = {
		event_background = throne_room
	}
	left_portrait = {
		character = scope:claim_vassal
		animation = rage
	}

	trigger = {
		scope:claim_vassal = { is_alive = yes }
		exists = var:was_promised_title
	}

	immediate = {
		scope:claim_vassal = {
			var:promised_title = {
				save_scope_as = claim_to_propose
			}
		}
	}

	option = {
		name = vassal.2911.a
		reverse_add_opinion = {
			modifier = respect_opinion
			target = scope:claim_vassal
			opinion = medium_negative_opinion
		}
		add_prestige = medium_prestige_loss
		remove_variable = was_promised_title
		scope:claim_vassal = {
			remove_variable = promised_title
		}
	}
}

##############################################
# You have no heir, ask a vassal with a lot of children for help
# 3001 - 3004
# by Linnéa Thimrén
##############################################

scripted_trigger vassal_3001_potential_child_trigger = {
	is_alive = yes
	OR = {
		reverse_opinion = {
			target = root
			value <= neutral_opinion
		}
		has_trait = incapable
		has_trait_rank = {
			trait = intellect_bad
			rank > 1
		}
	}
}

scripted_trigger vassal_3001_potential_vassal_trigger = {
	any_child = {
		count >= 5
		is_alive = yes
	}
	reverse_opinion = {
		target = root
		value >= 10
	}
}

vassal.3001 = {
	type = character_event
	title = vassal.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:child
				}
				desc = vassal.3001.desc_child
			}
			desc = vassal.3001.desc_no_child
		}
		desc = vassal.3001.desc
	}
	
	theme = vassal
	left_portrait = scope:vassal_to_ask
	right_portrait = scope:spouse
	lower_right_portrait = scope:child
	
	trigger = {
		OR = {
			any_child = {
				count >= 1
				vassal_3001_potential_child_trigger = yes
			}
			NOT = {
				any_child = {
					count >= 1
					is_alive = yes
				}
			}
		}
		any_spouse = {
			count >= 1
			is_alive = yes
		}
		NOR = {
			has_character_flag = had_event_vassal_3001
			any_spouse = {
				is_pregnant = yes
			}
			is_pregnant = yes
			has_trait = eunuch
			has_trait = celibate
			has_trait = infertile
		}
		any_vassal = {
			vassal_3001_potential_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 0.5
			any_vassal = {
				vassal_3001_potential_vassal_trigger = yes
				OR = {
					any_child = {
						count >= 7
					}
					has_trait = lustful
					fertility >= high_fertility
				}
			}
		}
		modifier = {
			add = -0.5
			any_spouse = {
				count = 1
				OR = {
					has_trait = eunuch
					has_trait = celibate
					has_trait = infertile
				}
			}
		}
	}

	immediate = {
		save_scope_as = liege_with_trouble
		add_character_flag = {
			flag = had_event_vassal_3001
			days = 3650
		}
		random_spouse = {
			limit = {
				is_alive = yes
				is_pregnant = no
				this = root.primary_spouse
			}
			alternative_limit = {
				is_pregnant = no
			}
			save_scope_as = spouse
		}
		random_child = {
			limit = {
				vassal_3001_potential_child_trigger = yes
			}
			save_scope_as = child
		}
		random_vassal = {
			limit = {
				vassal_3001_potential_vassal_trigger = yes
			}
			weight = {
				base = 100
				modifier = {
					add = 100
					is_powerful_vassal = yes
				}
				modifier = {
					add = 20
					fertility >= high_fertility
				}
				modifier = {
					add = 50
					any_child = {
						count >= 7
					}
				}
				modifier = {
					add = 20
					has_trait = lustful
				}
			}
			save_scope_as = vassal_to_ask
		}
	}

	option = { #I will ask them!
		name = vassal.3001.a
		scope:vassal_to_ask = {
			trigger_event = {
				id = vassal.3002
				days = { 7 14 }
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			chaste = medium_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 80
			modifier = {
				add = 20
				has_trait = lustful
			}
			ai_value_modifier = {
				ai_energy = 0.5
				ai_boldness = 0.5
				ai_compassion = 0.25
			}
		}
	}

	option = { #This is none of their business!
		name = vassal.3001.b
		add_prestige = minor_prestige_gain
		stress_impact = {
			base = medium_stress_gain
			lustful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 20
				OR = {
					has_trait = chaste
					has_trait = arrogant
					has_trait = paranoid
				}
			}
			ai_value_modifier = {
				ai_zeal = 0.5
				ai_rationality = 0.25
			}
		}
	}
}

#Response event for vassal: Liege wants some pointers in the bedchamber
vassal.3002 = {
	type = character_event
	title = vassal.3001.t
	desc = vassal.3002.desc
	
	theme = vassal
	left_portrait = {
		character = scope:liege_with_trouble
		animation = personality_coward
	}
	lower_left_portrait = scope:spouse

	option = { #I'll help!
		name = vassal.3002.a
		random_list = {
			20 = {
				desc = vassal.3002.a.critical_success
				send_interface_toast = {
					left_icon = scope:liege_with_trouble
					title = vassal.3002.a.critical_success
					scope:liege_with_trouble = {
						add_character_modifier = {
							modifier = modifier_amazing_fertility_counsel
							days = 1825
						}
						add_opinion = {
							target = root
							modifier = friendliness_opinion
							opinion = 30
						}
					}
				}
			}
			20 = {
				desc = vassal.3002.a.success
				send_interface_toast = {
					left_icon = scope:liege_with_trouble
					title = vassal.3002.a.success
					scope:liege_with_trouble = {
						add_character_modifier = {
							modifier = modifier_great_fertility_counsel
							days = 1825
						}
						add_opinion = {
							target = root
							modifier = friendliness_opinion
							opinion = low_positive_opinion
						}
					}
				}
			}
			20 = {
				desc = vassal.3002.a.failure
				send_interface_toast = {
					left_icon = scope:liege_with_trouble
					title = vassal.3002.a.failure
					scope:liege_with_trouble = {
						add_character_modifier = {
							modifier = modifier_bad_fertility_counsel
							days = 1825
						}
						add_opinion = {
							target = root
							modifier = respect_opinion
							opinion = low_negative_opinion
						}
					}
				}
			}
		}
		if = {
			limit = {
				scope:liege_with_trouble = { is_ai = yes } #Because it's not visible in the option leading here, not fair to player
				can_add_hook = {
					target = scope:liege_with_trouble
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:liege_with_trouble
				type = favor_hook
			}
		}
		if = {
			limit = {
				is_heir_of = scope:liege_with_trouble
			}
			stress_impact = {
				base = major_stress_gain
				chaste = medium_stress_impact_gain
				zealous = medium_stress_impact_gain
				shy = medium_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				chaste = medium_stress_impact_gain
				zealous = medium_stress_impact_gain
				shy = medium_stress_impact_gain
			}
		}
		ai_chance = {
			base = 80
			modifier = {
				add = 40
				opinion = {
					target = scope:liege_with_trouble
					value >= medium_positive_opinion
				}
			}
			modifier = {
				add = 20
				opinion = {
					target = scope:liege_with_trouble
					value >= low_positive_opinion
				}
			}
			ai_value_modifier = {
				ai_compassion = 0.75
				ai_honor = 0.5
			}
		}
	}

	option = { #I want nothing to do with this!
		name = vassal.3002.b
		scope:liege_with_trouble = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -10
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 40
				opinion = {
					target = scope:liege_with_trouble
					value <= neutral_opinion
				}
			}
			ai_value_modifier = {
				ai_vengefulness = 0.75
				ai_rationality = 0.25
				ai_zeal = 0.25
			}
		}
	}
	
	option = { #Oh, I'll help alright...
		name = vassal.3002.c
		trigger = {
			mgr_can_seduce = yes
			scope:spouse = {
				is_attracted_to_gender_of = root
				is_ai = yes
			}
			has_trait = lustful #this was incorrectly put outside the trigger...
		}
		show_as_tooltip = {
			random_list = {
				10 = {
					show_chance = no
					desc = vassal.3002.c.tt_success
					progress_towards_lover_effect = {
						CHARACTER = scope:spouse
						OPINION = yes
					}
					had_sex_with_effect = {
						CHARACTER = scope:spouse
						PREGNANCY_CHANCE = pregnancy_chance
					}
				}
				10 = {
					show_chance = no
					desc = vassal.3002.c.tt_failure
					reverse_add_opinion = {
						target = scope:liege_with_trouble
						modifier = insult_opinion
						opinion = low_negative_opinion
					}
				}
			}
		}
		add_character_flag = {
			flag = is_making_a_move_on_spouse
			days = 100
		}
		stress_impact = {
			sadistic = medium_stress_impact_loss
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			honest = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = -70
				opinion = {
					target = scope:liege_with_trouble
					value >= low_positive_opinion
				}
			}
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_rationality = -0.25
				ai_honor = -0.25
			}
		}
	}

	option = { #I will give some... personal directions
		name = vassal.3002.d
		trigger = {
			mgr_can_seduce = yes
			scope:liege_with_trouble = {
				is_attracted_to_gender_of = root
			}
			has_trait = lustful
		}
		show_as_tooltip = {
			random_list = {
				10 = {
					show_chance = no
					desc = vassal.3002.d.tt_success
					progress_towards_lover_effect = {
						CHARACTER = scope:liege_with_trouble
						OPINION = yes
					}
					had_sex_with_effect = {
						CHARACTER = scope:liege_with_trouble
						PREGNANCY_CHANCE = pregnancy_chance
					}
				}
				10 = {
					show_chance = no
					desc = vassal.3002.d.tt_failure
					reverse_add_opinion = {
						target = scope:liege_with_trouble
						modifier = insult_opinion
						opinion = low_negative_opinion
					}
				}
			}
		}
		add_character_flag = {
			flag = is_making_a_move
			days = 100
		}
		stress_impact = {
			base = medium_stress_loss
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			honest = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = -70
				opinion = {
					target = scope:liege_with_trouble
					value <= neutral_opinion
				}
			}
			ai_value_modifier = {
				ai_greed = 0.5
				ai_honor = -0.5
			}
		}
	}

	after = {
		scope:liege_with_trouble = {
			trigger_event = {
				id = vassal.3003
				days = { 7 10 }
			}
		}
	}
}

#Did the vassal help or not?
vassal.3003 = {
	type = character_event
	title = vassal.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_character_modifier = modifier_amazing_fertility_counsel
						has_character_modifier = modifier_great_fertility_counsel
					}
				}
				desc = vassal.3003.desc_good_counsel
			}
			triggered_desc = {
				trigger = {
					has_character_modifier = modifier_bad_fertility_counsel
				}
				desc = vassal.3003.desc_bad_counsel
			}
			triggered_desc = {
				trigger = {
					scope:vassal_to_ask = {
						has_character_flag = is_making_a_move_on_spouse
					}
				}
				desc = vassal.3003.desc_making_a_move_on_spouse
			}
			triggered_desc = {
				trigger = {
					scope:vassal_to_ask = {
						has_character_flag = is_making_a_move
					}
				}
				desc = vassal.3003.desc_making_a_move
			}
			desc = vassal.3003.desc_refusal
		}
	}
	
	theme = vassal
	left_portrait = scope:vassal_to_ask
	right_portrait = scope:spouse

	immediate = {
		if = {
			limit = {
				has_character_modifier = modifier_amazing_fertility_counsel
			}
			show_as_tooltip = {
				add_character_modifier = {
					modifier = modifier_amazing_fertility_counsel
					days = 1825
				}
				add_opinion = {
					target = scope:vassal_to_ask
					modifier = friendliness_opinion
					opinion = 30
				}
			}
		}
		else_if = {
			limit = {
				has_character_modifier = modifier_great_fertility_counsel
			}
			show_as_tooltip = {
				add_character_modifier = {
					modifier = modifier_great_fertility_counsel
					days = 1825
				}
				add_opinion = {
					target = scope:vassal_to_ask
					modifier = friendliness_opinion
					opinion = low_positive_opinion
				}
			}
		}
		else_if = {
			limit = {
				has_character_modifier = modifier_bad_fertility_counsel
			}
			show_as_tooltip = {
				add_character_modifier = {
					modifier = modifier_bad_fertility_counsel
					days = 1825
				}
				add_opinion = {
					target = scope:vassal_to_ask
					modifier = respect_opinion
					opinion = low_negative_opinion
				}
			}
		}
		else_if = {
			limit = {
				scope:vassal_to_ask = {
					NOR = {
						has_character_flag = is_making_a_move
						has_character_flag = is_making_a_move_on_spouse
					}
				}
			}
			scope:vassal_to_ask = {
				add_opinion = {
					target = root
					modifier = insult_opinion
					opinion = -10
				}
			}
		}
	}

	option = { #Call for my spouse!
		name = vassal.3003.a
		trigger = {
			OR = {
				has_character_modifier = modifier_amazing_fertility_counsel
				has_character_modifier = modifier_great_fertility_counsel
			}
		}
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
		stress_impact = {
			base = major_stress_loss
			chaste = medium_stress_impact_gain
		}
	}

	option = { #Bummer
		name = vassal.3003.b
		trigger = {
			NOR = {
				has_character_modifier = modifier_amazing_fertility_counsel
				has_character_modifier = modifier_great_fertility_counsel
				scope:vassal_to_ask = { has_character_flag = is_making_a_move }
				scope:vassal_to_ask = { has_character_flag = is_making_a_move_on_spouse }
			}
		}
	}

	option = { #Yes please instruct my spouse!
		name = vassal.3003.spouse
		random = {
			chance = 80
			send_interface_toast = {
				left_icon = scope:spouse
				title = vassal.3003.spouse.tt
				add_character_modifier = {
					modifier = modifier_great_fertility_counsel
					years = 5
				}
			}
		}
		trigger = {
			scope:vassal_to_ask = {
				has_character_flag = is_making_a_move_on_spouse
			}
		}
		hidden_effect = {
			scope:vassal_to_ask = {
				progress_towards_lover_effect = {
					CHARACTER = scope:spouse
					OPINION = yes
				}
				had_sex_with_effect = {
					CHARACTER = scope:spouse
					PREGNANCY_CHANCE = pregnancy_chance
				}
			}
		}
		scope:vassal_to_ask = {
			trigger_event = vassal.3004
		}
		stress_impact = {
			base = medium_stress_loss
			chaste = major_stress_impact_gain
			zealous = medium_stress_impact_gain
		}
	}
	
	option = { #Why yes, I do believe I want to commit adultery!
		name = vassal.3003.c
		trigger = {
			scope:vassal_to_ask = {
				has_character_flag = is_making_a_move
			}
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:vassal_to_ask
			OPINION = yes
		}
		had_sex_with_effect = {
			CHARACTER = scope:vassal_to_ask
			PREGNANCY_CHANCE = pregnancy_chance
		}
		scope:vassal_to_ask = {
			trigger_event = vassal.3004
			hidden_effect = {
				reverse_add_opinion = {
					target = root
					modifier = love_opinion
					opinion = low_positive_opinion
				}
			}
		}
		stress_impact = {
			base = medium_stress_loss
			chaste = major_stress_impact_gain
			zealous = medium_stress_impact_gain
		}
	}

	option = { #The audacity!
		name = vassal.3003.d
		trigger = {
			scope:vassal_to_ask = {
				OR = {
					has_character_flag = is_making_a_move
					has_character_flag = is_making_a_move_on_spouse
				}
			}
		}
		scope:vassal_to_ask = {
			remove_character_flag = is_making_a_move
			trigger_event = vassal.3004
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = low_negative_opinion
			}
		}
		stress_impact = {
			base = medium_stress_loss
			lustful = medium_stress_impact_gain
		}
	}
}

#Response for vassal if liege was up for a romp
vassal.3004 = {
	type = character_event
	title = vassal.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = is_making_a_move_on_spouse
				}
				desc = vassal.3004.desc_spouse
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = is_making_a_move }
				}
				desc = vassal.3004.desc_refused
			}
			desc = vassal.3004.desc
		}
	}
	
	theme = seduction
	left_portrait = scope:target

	immediate = {
		if = {
			limit = {
				has_character_flag = is_making_a_move
			}
			progress_towards_lover_effect = {
				CHARACTER = scope:liege_with_trouble
				OPINION = yes
			}
			had_sex_with_effect = {
				CHARACTER = scope:liege_with_trouble
				PREGNANCY_CHANCE = pregnancy_chance
			}
		}
		else_if = {
			limit = {
				has_character_flag = is_making_a_move_on_spouse
			}
			progress_towards_lover_effect = {
				CHARACTER = scope:spouse
				OPINION = yes
			}
			had_sex_with_effect = {
				CHARACTER = scope:spouse
				PREGNANCY_CHANCE = pregnancy_chance
			}
		}
		else = {
			reverse_add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = low_negative_opinion
			}
		}
	}

	option = {
		name = vassal.3004.a
		trigger = {
			NOR = {
				has_character_flag = is_making_a_move
				has_character_flag = is_making_a_move_on_spouse
			}
		}
	}

	option = {
		name = vassal.3004.b
		trigger = {
			has_character_flag = is_making_a_move
		}
	}

	option = {
		name = vassal.3004.c
		trigger = {
			has_character_flag = is_making_a_move_on_spouse
		}
	}

	after = {
		if = {
			limit = {
				has_character_flag = is_making_a_move
			}
			remove_character_flag = is_making_a_move
		}
		if = {
			limit = {
				has_character_flag = is_making_a_move_on_spouse
			}
			remove_character_flag = is_making_a_move_on_spouse
		}
	}
}


##############################################
# Zealous vassal wants you to fight religious enemies
# 5010 - 5020
# by Tobias Bodlund
##############################################

scripted_trigger vassal_5010_potential_trigger = {
	is_capable_adult_ai = yes
	has_trait = zealous
	is_at_war = no
	faith = root.faith
}

vassal.5010 = {
	type = letter_event
	opening = {
		desc = vassal.5010.opening
	}
	desc = vassal.5010.desc
	sender = scope:vassal

	trigger = {
		NOT = { has_character_flag = 5010_vassal_asked_for_holy_war }  # Cooldown check
		is_ai = no
		any_vassal = { # Vassal is same faith and zealous
			vassal_5010_potential_trigger = yes
		}
		# Must currently have a religious cb
		any_independent_ruler = {
			NOT = { is_allied_to = root }
			root = {
				has_cb_on = {
					target = prev
					cb = religious_war
				}
			}
			faith = {
				faith_hostility_level = {
					target = root.faith
					value >= faith_hostile_level
				}
			}
		}
		# Must be either at peace or only at war with coreligionists
		OR = {
			is_at_war = no
			at_war_only_with_coreligionists_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = { # Higher chance if at war with coreligionists
			factor = 2
			at_war_with_any_coreligionist_trigger = yes
		}
		modifier = {
			factor = 2
			has_trait = impatient
		}
		modifier = {
			factor = 0.5
			has_trait = patient
		}
	}

	immediate = {
		add_character_flag = {
			flag = 5010_vassal_asked_for_holy_war # Cooldown
			years = 5
		}
		random_vassal = {
			limit = {
				vassal_5010_potential_trigger = yes
			}
			save_scope_as = vassal
		}
	}

	option = {
		name = vassal.5010.a	# Promise holy war within six months
		custom_tooltip = vassal.5010.a.tt
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = promised_vassal_holy_war_opinion
			}
		}
		trigger_event = {
			id = vassal.5020	# Check if promise is fulfilled
			days = 180
		}
	}

	option = {
		name = vassal.5010.b	#  Decline with good diplomacy skill
		trigger = {
			diplomacy >= high_skill_rating
		}
		add_piety = miniscule_piety_loss
		skill = diplomacy
		custom_tooltip = vassal.5010.b.tt
	}

	option = {
		name = vassal.5010.c	# Decline - vassal is angered
		trigger = {
			NOT = { diplomacy >= high_skill_rating }
		}
		add_piety = miniscule_piety_loss
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = impious_opinion
				opinion = -15
			}
		}
	}
}

# Promise not fulfilled
vassal.5020 = {
	type = character_event
	title = vassal.5020.t
	desc = vassal.5020.desc
	
	theme = vassal
	left_portrait = scope:vassal

	trigger = { # Check war - must be at war with any non-coreligionist
		scope:vassal = {
			is_alive = yes
			NOT = { has_trait = incapable }
			liege = root
			NOT = { is_at_war_with = root }
			faith = root.faith
		}
		at_war_with_any_non_coreligionist_trigger = no
	}

	option = {
		name = {
			trigger = {
				untrustworthy_trigger = no
			}
			text = vassal.5020.a
		}
		name = {
			trigger = {
				untrustworthy_trigger = yes
			}
			text = vassal.5020.b
		}
		trait = arbitrary
		trait = deceitful
		add_piety = minor_piety_loss
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = impious_opinion
				opinion = -15
			}
			add_opinion = {
				target = root
				modifier = suspicion_opinion
				opinion = -15
			}
		}
	}
}


##############################################
# Vassal has a claim in a foreign realm and nags the liege about going to war over it
# 5050 - 5060
# by Tobias Bodlund
##############################################

scripted_trigger vassal_5050_potential_vassal_trigger = {
	is_capable_adult_ai = yes
	is_at_war = no
	NOT = { has_trait = content }
	any_claim = {
		holder = {
			NOT = { is_allied_to = root }
			NOT = { any_liege_or_above = { this = root } }
			root = {
				has_cb_on = {
					target = prev
					cb = claim_cb
				}
			}
		}
	}
}

vassal.5050 = {
	type = letter_event
	opening = {
		desc = vassal.5010.opening
	}
	desc = vassal.5050.desc
	sender = scope:vassal

	trigger = {
		NOT = { has_character_flag = 5050_vassal_asked_for_war_over_claim } # Cooldown check
		is_ai = no
		is_at_war = no
		any_vassal = {
			vassal_5050_potential_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			has_trait = greedy
		}
		modifier = {
			factor = 2
			has_trait = ambitious
		}
		modifier = {
			factor = 2
			has_trait = impatient
		}
		modifier = {
			factor = 0.5
			has_trait = patient
		}
		modifier = {
			factor = 2
			is_powerful_vassal = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = 5050_vassal_asked_for_war_over_claim # Cooldown
			years = 5
		}
		random_vassal = {
			limit = {
				vassal_5050_potential_vassal_trigger = yes
			}
			save_scope_as = vassal
			# find relevant claim and save the scope (for text)
			random_claim = {
				limit = {
					holder = {
						NOT = { any_liege_or_above = { this = root } }
						root = {
							has_cb_on = {
								target = prev
								cb = claim_cb
							}
						}
					}
				}
				save_scope_as = claim
				holder = {
					save_scope_as = claimed_title_holder
				}
			}
		}
	}

	option = {
		name = vassal.5050.b	#  Decline with good diplomacy skill
		trigger = {
			diplomacy >= high_skill_rating
		}
		skill = diplomacy
		custom_tooltip = vassal.5050.b.tt
	}

	option = {
		name = vassal.5050.a	# Promise war within twelve months
		custom_tooltip = vassal.5050.a.tt
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = promised_vassal_claim_war_opinion
			}
		}
		trigger_event = {
			id = vassal.5060	# Check if promise is fulfilled
			days = 365
		}
	}

	option = {
		name = vassal.5050.c	# Decline - vassal is disappointed
		trigger = {
			NOT = { diplomacy >= high_skill_rating }
		}
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
	}
}

# Promise not fulfilled
vassal.5060 = {
	type = character_event
	title = vassal.5060.t
	desc = vassal.5060.desc
	
	theme = vassal
	left_portrait = scope:vassal

	trigger = {
		scope:vassal = {
			is_alive = yes
			NOT = { has_trait = incapable }
			liege = root
			NOT = { is_at_war_with = root }
		}
		# must be in an offensive war over that claim or in a defensive war OR the vassal holds that claim
		NOR = {
			scope:claim = { holder = scope:vassal }
			any_character_war = {
				using_cb = claim_cb
				casus_belli = {
					any_target_title = { this = scope:claim }
				}
			}
			any_character_war = {
				casus_belli = { primary_defender = root }
			}
		}
	}

	option = {
		name = {
			trigger = {
				untrustworthy_trigger = no
			}
			text = vassal.5060.a
		}
		name = {
			trigger = {
				untrustworthy_trigger = yes
			}
			text = vassal.5060.b
		}
		trait = arbitrary
		trait = deceitful
		add_prestige = minor_prestige_loss
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
			add_opinion = {
				target = root
				modifier = suspicion_opinion
				opinion = -10
			}
		}
	}
}
