﻿#Events handling Sway ongoing

namespace = sway_ongoing




######################
#
#	FREE-STANDING EVENTS
#	1000-4999
######################


#They have different culture, talk it up a bit
	#by Linnéa Thimrén
sway_ongoing.1001 = {
	type = character_event
	title = sway_ongoing.1001.t
	desc = sway_ongoing.1001.desc
	theme = friendly
	left_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_sway_ongoing_1001 }
		}
		scope:target = {
			is_alive = yes
		}
		scope:target = {
			culture != root.culture
		}
		exists = location
	}

	immediate = {
		scope:scheme = {
			set_variable = {	
				name = had_event_sway_ongoing_1001
				value = yes
				days = 3650
			}
		}
		if = {
			limit = {
				exists = capital_province
			}
			capital_province = { save_scope_as = capital }
		}
		else = {
			location = { save_scope_as = capital }
		}
	}

	option = { #They're pretty great actually....
		name = sway_ongoing.1001.a
		scope:target = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 10
			}
		}
		random = {
			chance = 40
			add_prestige = minor_prestige_loss
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
		}
	}

	option = { #MY culture is the best!
		name = sway_ongoing.1001.b
		add_prestige = minor_prestige_gain
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				has_trait = arrogant
			}
		}
	}
}


#Write them a letter complimenting them
	#by Linnéa Thimrén
sway_ongoing.1002 = {
	type = character_event
	title = sway_ongoing.1002.t
	desc = sway_ongoing.1002.desc
	theme = friendly
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:target
		animation = boredom
	}
	lower_left_portrait = scope:friend
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_sway_ongoing_1002 }
		}
		scope:target = {
			is_alive = yes
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {	
				name = had_event_sway_ongoing_1002
				value = yes
				days = 3650
			}
		}
		scope:target = {
			save_scope_as = compliment_receiver
		}

		#Do I have a friend?
		if = {
			limit = {
				any_relation = {
					type = friend
				}
			}
			random_relation = {
				type = friend
				limit = {
					diplomacy >= high_skill_rating
				}
				alternative_limit = {
					diplomacy >= medium_skill_rating
				}
				alternative_limit = {
					is_alive = yes
				}
				save_scope_as = friend
			}
		}

		if = {
			limit = { #Only give a good option if you have a friend!
				exists = scope:friend
			}
			randomize_good_available_compliment_effect = { COMPLIMENT_RECEIVER = scope:compliment_receiver }
		}
		else = {
			#Randomize 3 compliment types
			randomize_available_compliment_effect = { COMPLIMENT_RECEIVER = scope:compliment_receiver }
			randomize_available_compliment_effect = { COMPLIMENT_RECEIVER = scope:compliment_receiver }
			randomize_good_available_compliment_effect = { COMPLIMENT_RECEIVER = scope:compliment_receiver }
		}
	}

	#Compassionate
	option = {
		trigger = { has_character_flag = available_compliment_compassionate }
		name = diplomacy_majesty.0004.compassionate
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = compassionate COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#bold
	option = {
		trigger = { has_character_flag = available_compliment_bold }
		name = diplomacy_majesty.0004.bold
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = bold COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#honorable
	option = {
		trigger = { has_character_flag = available_compliment_honorable }
		name = diplomacy_majesty.0004.honorable
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = honorable COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#greed
	option = {
		trigger = { has_character_flag = available_compliment_greedy }
		name = diplomacy_majesty.0004.greed
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = greed COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#rational
	option = {
		trigger = { has_character_flag = available_compliment_rational }
		name = diplomacy_majesty.0004.rational
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = rational COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#zealous
	option = {
		trigger = { has_character_flag = available_compliment_zealous }
		name = diplomacy_majesty.0004.zealous
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = zealous COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#energetic
	option = {
		trigger = { has_character_flag = available_compliment_energetic }
		name = diplomacy_majesty.0004.energetic
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = energetic COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#forgiving
	option = {
		trigger = { has_character_flag = available_compliment_forgiving }
		name = diplomacy_majesty.0004.forgiving
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = forgiving COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#beautiful
	option = {
		trigger = { has_character_flag = available_compliment_beautiful }
		name = diplomacy_majesty.0004.beautiful
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = beautiful COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#strong
	option = {
		trigger = { has_character_flag = available_compliment_strong }
		name = diplomacy_majesty.0004.strong
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = strong COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#extroverted
	option = {
		trigger = { has_character_flag = available_compliment_extroverted }
		name = diplomacy_majesty.0004.extroverted
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = extroverted COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	#dominant
	option = {
		trigger = { has_character_flag = available_compliment_dominant }
		name = diplomacy_majesty.0004.dominant
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:friend #Available because of your friend
					}
					desc = sway_ongoing.1002.success.tt
				}
				desc = diplomacy_majesty.0004.compliment.tt #Explanation of what outcome is based on
			}
		}

		hidden_effect = {
			scope:compliment_receiver = { evaluate_compliment_effect = { COMPLIMENT_TYPE = dominant COMPLIMENT_GIVER = root } }
		}
		sway_ongoing_1002_outcome_effect = yes #Must be in every options but fallback for tooltip reasons
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = sway_ongoing.1002.b
	}

	after = {
		clear_available_compliments_effect = yes
	}
}


#For owner - It was well received!
sway_ongoing.1003 = {
	type = letter_event
	opening = {
		desc = sway_ongoing.1003.opening
	}
	desc = sway_ongoing.1003.desc
	sender = {
		character = scope:compliment_receiver
		animation = happiness
	}

	trigger = {
		exists = scope:scheme
		scope:scheme = { scheme_progress < scope:scheme.scheme_phase_duration }
		scope:target = {
			is_alive = yes
		}
	}
	
	immediate = {		
		if = {
			limit = {
				scope:compliment_receiver = { is_alive = yes }
			}
			scope:compliment_receiver = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 10
				}
			}
		}
		scope:scheme ?= {
			add_scheme_progress = scheme_progress_gain
		}
	}

	option = {
		name = sway_ongoing.1003.a
	}
}

#For owner - It was not well received
sway_ongoing.1004 = {
	type = letter_event
	opening = {
		desc = sway_ongoing.1003.opening
	}
	desc = sway_ongoing.1004.desc
	sender = {
		character = scope:compliment_receiver
		animation = dismissal
	}

	trigger = {
		exists = scope:scheme
		scope:target = {
			is_alive = yes
		}
	}
	
	immediate = {
		if = {
			limit = {
				scope:compliment_receiver = { is_alive = yes }
			}
			scope:compliment_receiver = {
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = -5
				}
			}
		}	
	}

	option = {
		name = sway_ongoing.1004.a
	}
}


#Talk them up a bit
	#by Linnéa Thimrén
#sway_ongoing.1005 = {
#	type = character_event
#	title = sway_ongoing.1005.t
#	desc = sway_ongoing.1005.desc
#	theme = friendly
#	left_portrait = scope:target
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		is_travelling = no
#		scope:target = {
#			is_alive = yes
#		}
#		scope:target = { is_landed = yes }
#		scope:scheme = {
#			NOT = { has_variable = had_event_sway_ongoing_1005 }
#		}
#	}
#
#	immediate = {
#		scope:scheme = {
#			set_variable = {	
#				name = had_event_sway_ongoing_1005
#				value = yes
#				days = 3650
#			}
#		}
#	}
#
#	option = { #They're cool!
#		name = sway_ongoing.1005.a
#		scope:target = {
#			add_opinion = {
#				target = root
#				modifier = sway_good_rumors_opinion
#			}
#		}
#		scope:scheme = {
#			add_scheme_progress = scheme_progress_gain
#		}
#		add_prestige = minor_prestige_loss
#		ai_chance = {
#			base = 50
#		}
#	}
#
#	option = { #I'M the coolest
#		name = sway_ongoing.1005.b
#		add_prestige = minor_prestige_gain
#
#		stress_impact = {
#			arrogant = minor_stress_impact_loss
#		}
#		ai_chance = {
#			base = 50
#			modifier = {
#				add = 100
#				has_trait = arrogant
#			}
#		}
#	}
#}
#
##Send people to their realm
#	#by Linnéa Thimrén
#sway_ongoing.1006 = {
#	type = character_event
#	title = sway_ongoing.1006.t
#	desc = sway_ongoing.1006.desc
#	theme = friendly
#	left_portrait = scope:target
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		scope:target = {
#			is_alive = yes
#		}
#		scope:scheme = {
#			NOT = { has_variable = had_event_sway_ongoing_1006 }
#		}
#		short_term_gold >= minor_gold_value
#		scope:target = {
#			is_landed = yes
#		}
#	}
#
#	immediate = {
#		scope:scheme = {
#			set_variable = {	
#				name = had_event_sway_ongoing_1006
#				value = yes
#				days = 3650
#			}
#		}
#		scope:target = {
#			capital_province = { save_scope_as = capital }
#		}
#	}
#
#	option = { #Send people to their capital
#		name = sway_ongoing.1006.a
#		remove_short_term_gold = minor_gold_value
#		scope:scheme = {
#			add_scheme_progress = scheme_progress_gain
#		}
#		ai_chance = {
#			base = 50
#			modifier = {
#				add = {
#					value = ai_greed
#					multiply = -1
#				}
#				ai_greed > 0
#			}
#		}
#	}
#
#	option = { #Save the money
#		name = sway_ongoing.1006.b
#		ai_chance = {
#			base = 50
#		}
#	}
#}



####################
#
#	CHAINS
#	5000-9999
####################



#scripted_trigger sway_ongoing_5001_likes_everything_trigger = {
#	scope:target = {
#		has_character_flag = diplomacy_lifestyle
#		has_character_flag = martial_lifestyle
#		has_character_flag = stewardship_lifestyle
#		has_character_flag = intrigue_lifestyle
#		has_character_flag = learning_lifestyle
#	}
#}
#
#scripted_effect sway_ongoing_5001_remove_flags_effect = {
#	remove_character_flag = option_chosen_diplomacy
#	remove_character_flag = option_chosen_martial
#	remove_character_flag = option_chosen_stewardship
#	remove_character_flag = option_chosen_intrigue
#	remove_character_flag = option_chosen_learning
#	remove_character_flag = win
#}

#################
# Talk to them about a subject that interests them
#	by Linnéa Thimrén
###################
#sway_ongoing.5001 = {
#	type = character_event
#	title = sway_ongoing.5001.t
#	desc = sway_ongoing.5001.desc
#	theme = friendly
#	left_portrait = scope:target
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		scope:target = {
#			is_alive = yes
#		}
#		scope:scheme = {
#			NOT = { has_variable = had_event_sway_ongoing_5001 }
#		}
#		scope:target = {
#			has_any_lifestyle_focus_trigger = yes
#		}
#	}
#
#	immediate = {
#		scope:scheme = {
#			set_variable = {	
#				name = had_event_sway_ongoing_5001
#				value = yes
#				days = 3650
#			}
#		}
#
#		#Event option set-up
#		if = {
#			limit = {
#				scope:target = {
#					OR = {
#						has_diplomacy_lifestyle_trait_trigger = yes
#						has_lifestyle = diplomacy_lifestyle
#						diplomacy >= high_skill_rating
#					}
#				}
#			}
#			#Set the flag for enabling this event option to be chosen in the coming random list
#			add_character_flag = diplomacy_lifestyle
#		}
#		if = {
#			limit = {
#				scope:target = {
#					OR = {
#						has_martial_lifestyle_trait_trigger = yes
#						has_lifestyle = martial_lifestyle
#						martial >= high_skill_rating
#					}
#				}
#			}
#			add_character_flag = martial_lifestyle
#		}
#		if = {
#			limit = {
#				scope:target = {
#					OR = {
#						has_stewardship_lifestyle_trait_trigger = yes
#						has_lifestyle = stewardship_lifestyle
#						stewardship >= high_skill_rating
#					}
#				}
#			}
#			add_character_flag = stewardship_lifestyle
#		}
#		if = {
#			limit = {
#				scope:target = {
#					OR = {
#						has_intrigue_lifestyle_trait_trigger = yes
#						has_lifestyle = intrigue_lifestyle
#						intrigue >= high_skill_rating
#					}
#				}
#			}
#			add_character_flag = intrigue_lifestyle
#		}
#		if = {
#			limit = {
#				scope:target = {
#					OR = {
#						has_learning_lifestyle_trait_trigger = yes
#						has_lifestyle = learning_lifestyle
#						learning >= high_skill_rating
#					}
#				}
#			}
#			add_character_flag = learning_lifestyle
#		}
#
#		#To choose the good option shown
#		random_list = {
#			10 = {
#				trigger = { has_character_flag = diplomacy_lifestyle }
#				add_character_flag = diplomacy_lifestyle_option
#				save_scope_value_as = {
#					name = good_option
#					value = flag:diplomacy
#				}
#			}
#			10 = {
#				trigger = { has_character_flag = martial_lifestyle }
#				add_character_flag = martial_lifestyle_option
#				save_scope_value_as = {
#					name = good_option
#					value = flag:martial
#				}
#			}
#			10 = {
#				trigger = { has_character_flag = stewardship_lifestyle }
#				add_character_flag = stewardship_lifestyle_option
#				save_scope_value_as = {
#					name = good_option
#					value = flag:stewardship
#				}
#			}
#			10 = {
#				trigger = { has_character_flag = intrigue_lifestyle }
#				add_character_flag = intrigue_lifestyle_option
#				save_scope_value_as = {
#					name = good_option
#					value = flag:intrigue
#				}
#			}
#			10 = {
#				trigger = { has_character_flag = learning_lifestyle }
#				add_character_flag = learning_lifestyle_option
#				save_scope_value_as = {
#					name = good_option
#					value = flag:learning
#				}
#			}
#		}
#
#		if = { #save another scope value if they're good at everything
#			limit = {
#				sway_ongoing_5001_likes_everything_trigger = yes
#			}
#			save_scope_value_as = {
#				name = good_option
#				value = flag:everything
#			}
#		}
#
#		#To choose bad option
#		random_list = {
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = diplomacy_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = diplomacy_lifestyle_option }
#				}
#				add_character_flag = diplomacy_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = martial_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = martial_lifestyle_option }
#				}
#				add_character_flag = martial_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = stewardship_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = stewardship_lifestyle_option }
#				}
#				add_character_flag = stewardship_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = intrigue_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = intrigue_lifestyle_option }
#				}
#				add_character_flag = intrigue_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = learning_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = learning_lifestyle_option }
#				}
#				add_character_flag = learning_lifestyle_option
#			}
#		}
#		#To choose another bad option
#		random_list = {
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = diplomacy_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = diplomacy_lifestyle_option }
#				}
#				add_character_flag = diplomacy_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = martial_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = martial_lifestyle_option }
#				}
#				add_character_flag = martial_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = stewardship_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = stewardship_lifestyle_option }
#				}
#				add_character_flag = stewardship_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = intrigue_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = intrigue_lifestyle_option }
#				}
#				add_character_flag = intrigue_lifestyle_option
#			}
#			10 = {
#				trigger = {
#					OR = {
#						NOT = { has_character_flag = learning_lifestyle }
#						sway_ongoing_5001_likes_everything_trigger = yes
#					}
#					NOT = { has_character_flag = learning_lifestyle_option }
#				}
#				add_character_flag = learning_lifestyle_option
#			}
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5001.diplomacy_lifestyle
#		trigger = { has_character_flag = diplomacy_lifestyle_option }
#		flavor = sway_ongoing.5001.a.tt
#		add_character_flag = option_chosen_diplomacy
#		scope:target = {
#			trigger_event = {
#				id = sway_ongoing.5002
#				days = { 7 14 }
#			}
#		}
#		ai_chance = {
#			base = 50
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5001.martial_lifestyle
#		trigger = { has_character_flag = martial_lifestyle_option }
#		flavor = sway_ongoing.5001.a.tt
#		add_character_flag = option_chosen_martial
#		scope:target = {
#			trigger_event = {
#				id = sway_ongoing.5002
#				days = { 7 14 }
#			}
#		}
#		ai_chance = {
#			base = 50
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5001.stewardship_lifestyle
#		trigger = { has_character_flag = stewardship_lifestyle_option }
#		flavor = sway_ongoing.5001.a.tt
#		add_character_flag = option_chosen_stewardship
#		scope:target = {
#			trigger_event = {
#				id = sway_ongoing.5002
#				days = { 7 14 }
#			}
#		}
#		ai_chance = {
#			base = 50
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5001.intrigue_lifestyle
#		trigger = { has_character_flag = intrigue_lifestyle_option }
#		flavor = sway_ongoing.5001.a.tt
#		add_character_flag = option_chosen_intrigue
#		scope:target = {
#			trigger_event = {
#				id = sway_ongoing.5002
#				days = { 7 14 }
#			}
#		}
#		ai_chance = {
#			base = 50
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5001.learning_lifestyle
#		trigger = { has_character_flag = learning_lifestyle_option }
#		flavor = sway_ongoing.5001.a.tt
#		add_character_flag = option_chosen_learning
#		scope:target = {
#			trigger_event = {
#				id = sway_ongoing.5002
#				days = { 7 14 }
#			}
#		}
#		ai_chance = {
#			base = 50
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5001.b
#		sway_ongoing_5001_remove_flags_effect = yes
#		ai_chance = {
#			base = 0
#		}
#	}
#
#	after = {
#		#To see if you succeeded or not
#		if = {
#			limit = {
#				has_character_flag = option_chosen_diplomacy
#				has_character_flag = diplomacy_lifestyle
#			}
#			add_character_flag = win
#		}
#		if = {
#			limit = {
#				has_character_flag = option_chosen_martial
#				has_character_flag = martial_lifestyle
#			}
#			add_character_flag = win
#		}
#		if = {
#			limit = {
#				has_character_flag = option_chosen_stewardship
#				has_character_flag = stewardship_lifestyle
#			}
#			add_character_flag = win
#		}
#		if = {
#			limit = {
#				has_character_flag = option_chosen_intrigue
#				has_character_flag = intrigue_lifestyle
#			}
#			add_character_flag = win
#		}
#		if = {
#			limit = {
#				has_character_flag = option_chosen_learning
#				has_character_flag = learning_lifestyle
#			}
#			add_character_flag = win
#		}
#
#		remove_character_flag = diplomacy_lifestyle_option
#		remove_character_flag = martial_lifestyle_option
#		remove_character_flag = stewardship_lifestyle_option
#		remove_character_flag = intrigue_lifestyle_option
#		remove_character_flag = learning_lifestyle_option
#		remove_character_flag = diplomacy_lifestyle
#		remove_character_flag = martial_lifestyle
#		remove_character_flag = stewardship_lifestyle
#		remove_character_flag = intrigue_lifestyle
#		remove_character_flag = learning_lifestyle
#	}
#}
#
##For target, response
#sway_ongoing.5002 = {
#	type = character_event
#	title = sway_ongoing.5002.t
#	desc = {
#		desc = sway_ongoing.5002.desc_opening
#		desc = {
#			first_valid = {
#				triggered_desc = {
#					trigger = {
#						scope:owner = { has_character_flag = option_chosen_diplomacy }
#					}
#					desc = sway_ongoing.5002.desc_diplomacy
#				}
#				triggered_desc = {
#					trigger = {
#						scope:owner = { has_character_flag = option_chosen_martial }
#					}
#					desc = sway_ongoing.5002.desc_martial
#				}
#				triggered_desc = {
#					trigger = {
#						scope:owner = { has_character_flag = option_chosen_stewardship }
#					}
#					desc = sway_ongoing.5002.desc_stewardship
#				}
#				triggered_desc = {
#					trigger = {
#						scope:owner = { has_character_flag = option_chosen_intrigue }
#					}
#					desc = sway_ongoing.5002.desc_intrigue
#				}
#				triggered_desc = {
#					trigger = {
#						scope:owner = { has_character_flag = option_chosen_learning }
#					}
#					desc = sway_ongoing.5002.desc_learning
#				}
#				desc = sway_ongoing.5002.desc_fallback
#			}
#		}
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					scope:owner = { has_character_flag = win }
#				}
#				desc = sway_ongoing.5002.desc_success
#			}
#			desc = sway_ongoing.5002.desc_failure
#		}
#		desc = sway_ongoing.5002.desc_ending
#	}
#	theme = friendly
#	left_portrait = scope:owner
#	
#	trigger = {
#		scope:owner = {
#			is_alive = yes
#		}
#	}
#
#	on_trigger_fail = {
#		sway_ongoing_5001_remove_flags_effect = yes
#	}
#
#	immediate = {
#		#Check if none of you knows what you're talking about
#		if = {
#			limit = {
#				scope:owner = {
#					has_character_flag = option_chosen_diplomacy
#					NOR = {
#						has_diplomacy_lifestyle_trait_trigger = yes
#						has_lifestyle = diplomacy_lifestyle
#						diplomacy >= high_skill_rating
#					}
#					NOT = { scope:good_option = flag:everything }
#				}
#			}
#			if = {
#				limit = {
#					NOT = { scope:owner = { has_character_flag = win } }
#				}
#				save_scope_value_as = {
#					name = nonsense
#					value = yes
#				}
#			}
#			else = {
#				save_scope_value_as = {
#					name = one_sided
#					value = yes
#				}
#			}
#		}
#		if = {
#			limit = {
#				scope:owner = {
#					has_character_flag = option_chosen_martial
#					NOR = {
#						has_martial_lifestyle_trait_trigger = yes
#						has_lifestyle = martial_lifestyle
#						martial >= high_skill_rating
#					}
#					NOT = { scope:good_option = flag:everything }
#				}
#			}
#			if = {
#				limit = {
#					NOT = { scope:owner = { has_character_flag = win } }
#				}
#				save_scope_value_as = {
#					name = nonsense
#					value = yes
#				}
#			}
#			else = {
#				save_scope_value_as = {
#					name = one_sided
#					value = yes
#				}
#			}
#		}
#		if = {
#			limit = {
#				scope:owner = {
#					has_character_flag = option_chosen_stewardship
#					NOR = {
#						has_stewardship_lifestyle_trait_trigger = yes
#						has_lifestyle = stewardship_lifestyle
#						stewardship >= high_skill_rating
#					}
#					NOT = { scope:good_option = flag:everything }
#				}
#			}
#			if = {
#				limit = {
#					NOT = { scope:owner = { has_character_flag = win } }
#				}
#				save_scope_value_as = {
#					name = nonsense
#					value = yes
#				}
#			}
#			else = {
#				save_scope_value_as = {
#					name = one_sided
#					value = yes
#				}
#			}
#		}
#		if = {
#			limit = {
#				scope:owner = {
#					has_character_flag = option_chosen_intrigue
#					NOR = {
#						has_intrigue_lifestyle_trait_trigger = yes
#						has_lifestyle = intrigue_lifestyle
#						intrigue >= high_skill_rating
#					}
#					NOT = { scope:good_option = flag:everything }
#				}
#			}
#			if = {
#				limit = {
#					NOT = { scope:owner = { has_character_flag = win } }
#				}
#				save_scope_value_as = {
#					name = nonsense
#					value = yes
#				}
#			}
#			else = {
#				save_scope_value_as = {
#					name = one_sided
#					value = yes
#				}
#			}
#		}
#		if = {
#			limit = {
#				scope:owner = {
#					has_character_flag = option_chosen_learning
#					NOR = {
#						has_learning_lifestyle_trait_trigger = yes
#						has_lifestyle = learning_lifestyle
#						learning >= high_skill_rating
#					}
#					NOT = { scope:good_option = flag:everything }
#				}
#			}
#			if = {
#				limit = {
#					NOT = { scope:owner = { has_character_flag = win } }
#				}
#				save_scope_value_as = {
#					name = nonsense
#					value = yes
#				}
#			}
#			else = {
#				save_scope_value_as = {
#					name = one_sided
#					value = yes
#				}
#			}
#		}
#	}
#
#	option = { #I like this subject! Let's talk
#		name = sway_ongoing.5002.a
#		trigger = {
#			scope:owner = { has_character_flag = win }
#		}
#		save_scope_value_as = {
#			name = encouraged
#			value = yes
#		}
#		scope:owner = {
#			add_opinion = {
#				target = scope:target
#				modifier = friendliness_opinion
#				opinion = 10
#			}
#		}
#		ai_chance = {
#			base = 100
#			modifier = {
#				add = 100
#				scope:owner = { has_character_flag = win }
#			}
#			modifier = {
#				add = 200
#				has_trait = gregarious
#			}
#			modifier = {
#				add = 50
#				scope:target = {
#					dread_modified_ai_boldness = { #More likely if I'm scared of the owner
#						dreaded_character = scope:owner
#						value <= 0
#					}
#				}
#			}
#			ai_value_modifier = {
#				ai_boldness = 0.75
#				ai_compassion = 0.75
#			}
#		}
#	}
#
#	option = { #What are you even talking about? Well, let's see where it leads...
#		name = sway_ongoing.5002.b
#		trigger = {
#			NOT = { scope:owner = { has_character_flag = win } }
#		}
#		flavor = sway_ongoing.5002.b.tt
#		save_scope_value_as = {
#			name = encouraged
#			value = yes
#		}
#		scope:owner = {
#			add_opinion = {
#				target = scope:target
#				modifier = friendliness_opinion
#				opinion = 10
#			}
#		}
#		ai_chance = {
#			base = 50
#			modifier = {
#				add = 100
#				scope:owner = { has_character_flag = win }
#			}
#			modifier = {
#				add = 200
#				has_trait = gregarious
#			}
#			modifier = {
#				add = 50
#				scope:target = {
#					dread_modified_ai_boldness = { #More likely if I'm scared of the owner
#						dreaded_character = scope:owner
#						value <= 0
#					}
#				}
#			}
#			ai_value_modifier = {
#				ai_boldness = 0.75
#				ai_compassion = 0.75
#			}
#		}
#	}
#
#	option = { #Tell them off
#		name = sway_ongoing.5002.c
#		ai_chance = {
#			base = 50
#			modifier = {
#				add = 100
#				NOT = {
#					scope:owner = { has_character_flag = win }
#				}
#			}
#			ai_value_modifier = {
#				ai_compassion = -0.25
#			}
#		}
#	}
#
#	after = {
#		if = {
#			limit = {
#				exists = scope:encouraged
#			}
#			scope:owner = {
#				trigger_event = sway_ongoing.5003
#			}
#		}
#		else = {
#			scope:owner = {
#				trigger_event = sway_ongoing.5004
#			}
#		}
#	}
#}
#
##Response for owner - encouraged!
#sway_ongoing.5003 = {
#	type = character_event
#	title = sway_ongoing.5001.t
#	desc = {
#		desc = sway_ongoing.5003.desc_opening
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					OR = {
#						exists = scope:nonsense
#						exists = scope:one_sided
#					}
#				}
#				desc = sway_ongoing.5003.desc_nonsense
#			}
#			desc = sway_ongoing.5003.desc
#		}
#	}
#	theme = friendly
#	left_portrait = scope:target
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		scope:target = {
#			is_alive = yes
#		}
#	}
#
#	on_trigger_fail = {
#		sway_ongoing_5001_remove_flags_effect = yes
#	}
#
#	option = { #It went well!
#		name = sway_ongoing.5003.a
#		trigger = {
#			NOT = {
#				exists = scope:nonsense
#			}
#		}
#		scope:target = {
#			add_opinion = {
#				target = scope:owner
#				modifier = friendliness_opinion
#				opinion = 10
#			}
#		}
#		ai_chance = {
#			base = 100
#		}
#	}
#
#	option = { #Keep the nonsense going
#		name = {
#			trigger = {
#				has_character_flag = option_chosen_diplomacy
#			}
#			text = sway_ongoing.5003.b_diplomacy
#		}
#		name = {
#			trigger = {
#				has_character_flag = option_chosen_martial
#			}
#			text = sway_ongoing.5003.b_martial
#		}
#		name = {
#			trigger = {
#				has_character_flag = option_chosen_stewardship
#			}
#			text = sway_ongoing.5003.b_stewardship
#		}
#		name = {
#			trigger = {
#				has_character_flag = option_chosen_intrigue
#			}
#			text = sway_ongoing.5003.b_intrigue
#		}
#		name = {
#			trigger = {
#				has_character_flag = option_chosen_learning
#			}
#			text = sway_ongoing.5003.b_learning
#		}
#		trigger = {
#			exists = scope:nonsense
#		}
#		flavor = sway_ongoing.5003.b.tt
#		scope:target = {
#			trigger_event = {
#				id = sway_ongoing.5007
#				days = { 7 14 }
#			}
#		}
#		ai_chance = {
#			base = 100
#		}
#	}
#
#	option = { #Back out
#		name = sway_ongoing.5003.c
#		trigger = {
#			exists = scope:nonsense
#		}
#		sway_ongoing_5001_remove_flags_effect = yes
#		scope:target = {
#			add_opinion = {
#				target = scope:owner
#				modifier = respect_opinion
#				opinion = -5
#			}
#			trigger_event = {
#				id = sway_ongoing.5005
#				days = { 7 14 }
#			}
#		}
#		ai_chance = {
#			base = 50
#			modifier = {
#				add = 100
#				has_trait = honest
#			}
#			ai_value_modifier = {
#				ai_honor = 0.5
#			}
#		}
#	}
#}
#
##Response for owner - shot down
#sway_ongoing.5004 = {
#	type = character_event
#	title = sway_ongoing.5001.t
#	desc = {
#		desc = sway_ongoing.5004.desc
#		triggered_desc = {
#			trigger = {
#				exists = scope:nonsense
#			}
#			desc = sway_ongoing.5004.desc_nonsense
#		}
#	}
#	theme = unfriendly
#	left_portrait = {
#		character = scope:target
#		animation = dismissal
#	}
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		scope:target = {
#			is_alive = yes
#		}
#	}
#
#	on_trigger_fail = {
#		sway_ongoing_5001_remove_flags_effect = yes
#	}
#
#	option = {
#		name = sway_ongoing.5004.a
#		sway_ongoing_5001_remove_flags_effect = yes
#		if = {
#			limit = { exists = scope:scheme }
#			scope:scheme = {
#				add_scheme_progress = scheme_progress_loss
#			}
#		}
#	}
#}
#
##Response for target - owner backed out
#sway_ongoing.5005 = {
#	type = character_event
#	title = sway_ongoing.5002.t
#	desc = sway_ongoing.5005.desc
#	theme = unfriendly
#	left_portrait = {
#		character = scope:owner
#		animation = shame
#	}
#	
#	trigger = {
#		scope:owner = {
#			is_alive = yes
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5005.a
#		scope:owner = {
#			add_opinion = {
#				target = scope:target
#				modifier = grateful_opinion
#				opinion = 5
#			}
#		}
#	}
#}
#
##Response for owner - target backed out
#sway_ongoing.5006 = {
#	type = character_event
#	title = sway_ongoing.5001.t
#	desc = sway_ongoing.5006.desc
#	theme = unfriendly
#	left_portrait = {
#		character = scope:target
#		animation = shame
#	}
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		scope:target = {
#			is_alive = yes
#		}
#	}
#
#	on_trigger_fail = {
#		sway_ongoing_5001_remove_flags_effect = yes
#	}
#
#	option = {
#		name = sway_ongoing.5005.a
#		scope:target = {
#			add_opinion = {
#				target = scope:owner
#				modifier = grateful_opinion
#				opinion = 5
#			}
#		}
#		sway_ongoing_5001_remove_flags_effect = yes
#	}
#}
#
##For target - we keep going
#sway_ongoing.5007 = {
#	type = character_event
#	title = sway_ongoing.5002.t
#	desc = sway_ongoing.5007.desc
#	theme = friendly
#	left_portrait = scope:owner
#	
#	trigger = {
#		scope:owner = {
#			is_alive = yes
#		}
#	}
#
#	option = {
#		name = {
#			trigger = {
#				scope:owner = { has_character_flag = option_chosen_diplomacy }
#			}
#			text = sway_ongoing.5003.b_diplomacy
#		}
#		name = {
#			trigger = {
#				scope:owner = { has_character_flag = option_chosen_martial }
#			}
#			text = sway_ongoing.5003.b_martial
#		}
#		name = {
#			trigger = {
#				scope:owner = { has_character_flag = option_chosen_stewardship }
#			}
#			text = sway_ongoing.5003.b_stewardship
#		}
#		name = {
#			trigger = {
#				scope:owner = { has_character_flag = option_chosen_intrigue }
#			}
#			text = sway_ongoing.5003.b_intrigue
#		}
#		name = {
#			trigger = {
#				scope:owner = { has_character_flag = option_chosen_learning }
#			}
#			text = sway_ongoing.5003.b_learning
#		}
#		flavor = sway_ongoing.5007.b.tt
#		scope:owner = {
#			trigger_event = sway_ongoing.5008
#		}
#		ai_chance = {
#			base = 100
#		}
#	}
#
#	option = { #Back out
#		name = sway_ongoing.5003.c
#		scope:owner = {
#			add_opinion = {
#				target = scope:target
#				modifier = respect_opinion
#				opinion = -5
#			}
#			trigger_event = sway_ongoing.5006
#		}
#		ai_chance = {
#			base = 50
#			modifier = {
#				add = 100
#				has_trait = honest
#			}
#			ai_value_modifier = {
#				ai_honor = 0.5
#			}
#		}
#	}
#}
#
##How will the whole thing play out?
#sway_ongoing.5008 = {
#	hidden = yes
#
#	immediate = {
#		random_list = {
#			50 = {
#				save_scope_value_as = {
#					name = it_worked
#					value = yes
#				}	
#			}
#			500 = {
#				save_scope_value_as = {
#					name = owner_discovered
#					value = yes
#				}	
#			}
#			0 = {
#				save_scope_value_as = {
#					name = target_discovered
#					value = yes
#				}	
#			}
#		}
#		scope:owner = {
#			trigger_event = sway_ongoing.5009
#		}
#		scope:target = {
#			trigger_event = sway_ongoing.5010
#		}
#	}
#}
#
#
#scripted_effect sway_ongoing_5009_success_effect = {
#	if = {
#		limit = {
#			scope:owner = { has_character_flag = option_chosen_diplomacy }
#		}
#		add_character_modifier = {
#			modifier = discussion_about_diplomacy_modifier
#			years = 5
#		}
#	}
#	if = {
#		limit = {
#			scope:owner = { has_character_flag = option_chosen_martial }
#		}
#		add_character_modifier = {
#			modifier = discussion_about_martial_modifier
#			years = 5
#		}
#	}
#	if = {
#		limit = {
#			scope:owner = { has_character_flag = option_chosen_stewardship }
#		}
#		add_character_modifier = {
#			modifier = discussion_about_stewardship_modifier
#			years = 5
#		}
#	}
#	if = {
#		limit = {
#			scope:owner = { has_character_flag = option_chosen_intrigue }
#		}
#		add_character_modifier = {
#			modifier = discussion_about_intrigue_modifier
#			years = 5
#		}
#	}
#	if = {
#		limit = {
#			scope:owner = { has_character_flag = option_chosen_learning }
#		}
#		add_character_modifier = {
#			modifier = discussion_about_learning_modifier
#			years = 5
#		}
#	}
#}
#
##For owner - what's the outcome?
#sway_ongoing.5009 = {
#	type = character_event
#	title = sway_ongoing.5001.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					exists = scope:it_worked
#				}
#				desc = sway_ongoing.5009.desc_success
#			}
#			triggered_desc = {
#				trigger = {
#					exists = scope:owner_discovered
#				}
#				desc = sway_ongoing.5009.desc_owner_discovered
#			}
#			desc = sway_ongoing.5009.desc_target_discovered
#		}
#	}
#	theme = friendly
#	override_icon = {
#		trigger = { NOT = { exists = scope:it_worked } }
#		reference = "gfx/interface/icons/event_types/type_relation_unfriendly.dds"
#	}
#	left_portrait = {
#		character = scope:target
#		triggered_animation = {
#			trigger = { exists = scope:owner_discovered }
#			animation = dismissal
#		}
#		triggered_animation = {
#			trigger = { NOT = { exists = scope:it_worked } }
#			animation = shame
#		}
#		
#		triggered_animation = {
#			trigger = { always = yes }
#			animation = idle
#		}
#	}
#	widget = {
#		gui = "event_window_widget_scheme"
#		container = "custom_widgets_container"
#	}
#	
#	trigger = {
#		scope:target = {
#			is_alive = yes
#		}
#	}
#
#	on_trigger_fail = {
#		sway_ongoing_5001_remove_flags_effect = yes
#	}
#
#	option = {
#		name = sway_ongoing.5009.a
#		trigger = {
#			exists = scope:it_worked
#		}
#		sway_ongoing_5009_success_effect = yes
#	}
#
#	option = { #owner failed
#		name = sway_ongoing.5009.b
#		trigger = {
#			exists = scope:owner_discovered
#		}
#		scope:target = {
#			add_opinion = {
#				target = scope:owner
#				modifier = respect_opinion
#				opinion = -10
#			}
#		}
#	}
#	option = { #target failed
#		name = sway_ongoing.5009.c
#		trigger = {
#			exists = scope:target_discovered
#		}
#		scope:target = {
#			add_opinion = {
#				target = scope:owner
#				modifier = grateful_opinion
#				opinion = 20
#			}
#		}
#	}
#
#	after = {
#		trigger_event = { #To remove flags
#			id = sway_ongoing.4999
#			days = 4
#		}
#	}
#}
#
##For target - what's the outcome?
#sway_ongoing.5010 = {
#	type = character_event
#	title = sway_ongoing.5002.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					exists = scope:it_worked
#				}
#				desc = sway_ongoing.5010.desc_success
#			}
#			triggered_desc = {
#				trigger = {
#					exists = scope:target_discovered
#				}
#				desc = sway_ongoing.5010.desc_target_discovered
#			}
#			desc = sway_ongoing.5010.desc_owner_discovered
#		}
#	}
#	theme = friendly
#	override_icon = {
#		trigger = { NOT = { exists = scope:it_worked } }
#		reference = "gfx/interface/icons/event_types/type_relation_unfriendly.dds"
#	}
#	left_portrait = {
#		character = scope:target
#		triggered_animation = {
#			trigger = { exists = scope:target_discovered }
#			animation = dismissal
#		}
#		triggered_animation = {
#			trigger = { NOT = { exists = scope:it_worked } }
#			animation = shame
#		}
#		
#		triggered_animation = {
#			trigger = { always = yes }
#			animation = idle
#		}
#	}
#	
#	trigger = {
#		scope:owner = {
#			is_alive = yes
#		}
#	}
#
#	option = {
#		name = sway_ongoing.5009.a
#		trigger = {
#			exists = scope:it_worked
#		}
#		sway_ongoing_5009_success_effect = yes
#	}
#
#	option = { #target failed
#		name = sway_ongoing.5009.b
#		trigger = {
#			exists = scope:target_discovered
#		}
#		scope:owner = {
#			add_opinion = {
#				target = scope:target
#				modifier = respect_opinion
#				opinion = -10
#			}
#		}
#	}
#	option = { #owner failed
#		name = sway_ongoing.5009.c
#		trigger = {
#			exists = scope:owner_discovered
#		}
#		add_prestige = medium_prestige_gain
#		scope:owner = {
#			add_opinion = {
#				target = scope:target
#				modifier = grateful_opinion
#				opinion = 20
#			}
#		}
#	}
#}
#
##To remove flags
#sway_ongoing.4999 = {
#	hidden = yes
#
#	immediate = {
#		sway_ongoing_5001_remove_flags_effect = yes
#	}
#}


################
# Visit vassal/liege
#	by Linnéa Thimrén
###############
sway_ongoing.5011 = {
	type = character_event
	title = sway_ongoing.5011.t
	desc = {
		desc = sway_ongoing.5011.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:target = {
						opinion = {
							target = root
							value >= 10
						}
					}
				}
				desc = sway_ongoing.5011.desc_friendly
			}
			triggered_desc = {
				trigger = {
					scope:target = {
						opinion = {
							target = root
							value <= -20
						}
					}
				}
				desc = sway_ongoing.5011.desc_dislike
			}
			desc = sway_ongoing.5011.desc_normal
		}
		desc = sway_ongoing.5011.desc
	}
	theme = friendly
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:target
		animation = boredom
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_sway_ongoing_5011 }
		}
		scope:target = {
			is_alive = yes
			is_ai = yes
			is_landed = yes
		}
		OR = {
			liege ?= scope:target

			AND = {
				exists = scope:target.liege
				scope:target.liege = scope:owner
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = { #Unlikely if target is diligent
			add = -0.5
			scope:target = {
				has_trait = diligent
			}
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {	
				name = had_event_sway_ongoing_5011
				value = yes
				days = 3650
			}
		}
		scope:target = {
			capital_province = { save_scope_as = capital }
		}
	}

	option = { #Stick around
		name = sway_ongoing.5011.a
		flavor = sway_ongoing.5011.a.tt
		set_variable = {
			name = rating
			value = 0
		}
		trigger_event = {
			id = sway_ongoing.5013
			days = { 7 14 }
		}
	}

	option = { #Leave as soon as possible
		name = sway_ongoing.5011.b
		flavor = sway_ongoing.5011.b.tt
		add_stress = minor_stress_loss
	}
}

#Hm, maybe I can help out around here?
sway_ongoing.5013 = {
	type = character_event
	title = sway_ongoing.5011.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOR = {
						has_character_flag = block_option_expansion
						has_character_flag = block_option_library
						has_character_flag = block_option_gold
						has_character_flag = block_option_steal
					}
				}
				desc = sway_ongoing.5013.desc_opening
			}
			desc = {
				triggered_desc = {
					trigger = {
						has_character_flag = expansion_success_first_round
					}
					desc = sway_ongoing.5013.desc_expansion_success
				}
				triggered_desc = {
					trigger = {
						has_character_flag = expansion_failure_first_round
					}
					desc = sway_ongoing.5013.desc_expansion_failure
				}
				triggered_desc = {
					trigger = {
						has_character_flag = library_success_first_round
					}
					desc = sway_ongoing.5013.desc_library_success
				}
				triggered_desc = {
					trigger = {
						has_character_flag = library_failure_first_round
					}
					desc = sway_ongoing.5013.desc_library_failure
				}
				triggered_desc = {
					trigger = {
						has_character_flag = gold_success_first_round
					}
					desc = sway_ongoing.5013.desc_gold_success
				}
				triggered_desc = {
					trigger = {
						has_character_flag = gold_failure_first_round
					}
					desc = sway_ongoing.5013.desc_gold_failure
				}
				triggered_desc = {
					trigger = {
						has_character_flag = steal_success_first_round
					}
					desc = sway_ongoing.5013.desc_steal_success
				}
				desc = {
					first_valid = {
						triggered_desc = { #Nothing more to do
							trigger = {
								AND = {
									has_character_flag = block_option_expansion
									has_character_flag = block_option_library
									has_character_flag = block_option_gold
								}
							}
							desc = {
								first_valid = {
									triggered_desc = {
										trigger = {
											OR = {
												has_character_flag = expansion_success_first_round
												has_character_flag = library_success_first_round
												has_character_flag = gold_success_first_round
												has_character_flag = steal_success_first_round
											}
										}
										desc = sway_ongoing.5013.desc_end_good
									}
									desc = sway_ongoing.5013.desc_end_bad
								}
							}
						}
						desc = { #There's something left you can do
							first_valid = {
								triggered_desc = {
									trigger = {
										OR = {
											has_character_flag = expansion_success_first_round
											has_character_flag = library_success_first_round
											has_character_flag = gold_success_first_round
											has_character_flag = steal_success_first_round
										}
									}
									desc = sway_ongoing.5013.desc_good
								}
								desc = sway_ongoing.5013.desc_bad
							}
						}
					}
				}
			}
		}
	}
	theme = friendly
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:target
		triggered_animation = {
			trigger = {
				has_character_flag = gold_success_first_round
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				has_character_flag = gold_failure_first_round
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				has_character_flag = steal_success_first_round
			}
			animation = grief
		}
		triggered_animation = {
			trigger = { always = yes }
			animation = idle
		}
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:target = { is_alive = yes }
	}

	on_trigger_fail = {
		trigger_event = sway_ongoing.5015
	}

	immediate = {
		if = {
			limit = {
				has_character_flag = steal_success_first_round
			}
			add_gold = minor_gold_value
		}
	}

	option = { #Fix the dining hall - you're an architect!
		name = sway_ongoing.5012.a_trait
		trigger = {
			has_trait = architect
			NOT = { has_character_flag = block_option_expansion }
		}
		trait = architect
		change_variable = {
			name = rating
			add = 1
		}
		add_character_flag = expansion_success
		add_character_flag = block_option_expansion

		trigger_event = {
			id = sway_ongoing.5013
			days = { 7 14 }
		}
	}

	option = { #Unfinished expansion-project
		name = sway_ongoing.5012.a
		trigger = {
			NOR = {
				has_character_flag = block_option_expansion
				has_trait = architect
			}
		}
		duel = {
			skill = stewardship
			value = 10
			20 = {
				desc = sway_ongoing.5012.a_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				change_variable = {
					name = rating
					add = 1
				}
				add_character_flag = expansion_success
				add_character_flag = block_option_expansion
			}
			10 = {
				desc = sway_ongoing.5012.a_failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				change_variable = {
					name = rating
					add = -1
				}
				add_character_flag = expansion_failure
				add_character_flag = block_option_expansion
			}
		}
		custom_tooltip = sway_ongoing.5012.a.tt
		trigger_event = {
			id = sway_ongoing.5013
			days = { 7 14 }
		}
	}

	option = { #Tidy up the library - You're a scholar!
		name = sway_ongoing.5012.b_trait
		trigger = {
			NOT = { has_character_flag = block_option_library }
			has_trait = scholar
		}
		trait = scholar

		change_variable = {
			name = rating
			add = 1
		}
		add_character_flag = library_success
		add_character_flag = block_option_library

		trigger_event = {
			id = sway_ongoing.5013
			days = { 7 14 }
		}
	}

	option = { #Library in shambles
		name = sway_ongoing.5012.b
		trigger = {
			NOR = {
				has_character_flag = block_option_library
				has_trait = scholar
			}
		}
		flavor = sway_ongoing.5012.b.tt
		duel = {
			skill = learning
			value = 10
			20 = {
				desc = sway_ongoing.5012.b_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				change_variable = {
					name = rating
					add = 1
				}
				add_character_flag = library_success
				add_character_flag = block_option_library
			}
			10 = {
				desc = sway_ongoing.5012.b_failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				change_variable = {
					name = rating
					add = -1
				}
				add_character_flag = library_failure
				add_character_flag = block_option_library
			}
		}
		custom_tooltip = sway_ongoing.5012.a.tt
		
		trigger_event = {
			id = sway_ongoing.5013
			days = { 7 14 }
		}
	}

	option = { #Unguarded gold
		name = sway_ongoing.5012.c
		trigger = {
			NOT = { has_character_flag = block_option_gold }
		}
		flavor = sway_ongoing.5012.c.tt
		duel = {
			skill = diplomacy
			value = 10
			20 = {
				desc = sway_ongoing.5012.c_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				change_variable = {
					name = rating
					add = 1
				}
				add_character_flag = gold_success
				add_character_flag = block_option_gold
			}
			10 = {
				desc = sway_ongoing.5012.c_failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				change_variable = {
					name = rating
					add = -1
				}
				add_character_flag = gold_failure
				add_character_flag = block_option_gold
			}
		}
		custom_tooltip = sway_ongoing.5012.a.tt
		trigger_event = {
			id = sway_ongoing.5013
			days = { 7 14 }
		}
	}

	option = { #Unguarded gold (I have to help them understand how dangerous it is to have it like that!)
		name = sway_ongoing.5013.c
		trigger = {
			intrigue >= decent_skill_rating
			NOT = { has_character_flag = block_option_steal }
			AND = {
				has_character_flag = block_option_gold
				has_character_flag = gold_failure_first_round
			}
		}
		skill = intrigue
		flavor = sway_ongoing.5013.c.tt_intrigue
		change_variable = {
			name = rating
			add = 2
		}
		add_character_flag = steal_success
		add_character_flag = block_option_steal
		trigger_event = {
			id = sway_ongoing.5013
			days = { 7 14 }
		}
	}

	option = { #Head off to bed after doing at least one things
		name = sway_ongoing.5013.d
		trigger = {
			OR = {
				has_character_flag = block_option_expansion
				has_character_flag = block_option_library
				has_character_flag = block_option_gold
				has_character_flag = block_option_steal
			}
		}
		flavor = sway_ongoing.5011.b.tt
		trigger_event = {
			id = sway_ongoing.5014
			days = { 7 14 }
		}
	}

	option = { #Head off to bed without doing anything
		name = sway_ongoing.5012.d
		trigger = {
			NOR = {
				has_character_flag = block_option_expansion
				has_character_flag = block_option_library
				has_character_flag = block_option_gold
				has_character_flag = block_option_steal
			}
		}
		flavor = sway_ongoing.5011.b.tt
		trigger_event = {
			id = sway_ongoing.5014
			days = { 7 14 }
		}
	}

	after = {

		if = {
			limit = {
				has_character_flag = expansion_success_first_round
			}
			remove_character_flag = expansion_success_first_round
			add_character_flag = expansion_success_outcome
		}
		if = {
			limit = {
				has_character_flag = expansion_success
			}
			add_character_flag = expansion_success_first_round
			remove_character_flag = expansion_success
		}
		if = {
			limit = {
				has_character_flag = expansion_failure_first_round
			}
			remove_character_flag = expansion_failure_first_round
			add_character_flag = expansion_failure_outcome
		}
		if = {
			limit = {
				has_character_flag = expansion_failure
			}
			add_character_flag = expansion_failure_first_round
			remove_character_flag = expansion_failure
		}

		if = {
			limit = {
				has_character_flag = library_success_first_round
			}
			remove_character_flag = library_success_first_round
			add_character_flag = library_success_outcome
		}
		if = {
			limit = {
				has_character_flag = library_success
			}
			add_character_flag = library_success_first_round
			remove_character_flag = library_success
		}
		if = {
			limit = {
				has_character_flag = library_failure_first_round
			}
			remove_character_flag = library_failure_first_round
			add_character_flag = library_failure_outcome
		}
		if = {
			limit = {
				has_character_flag = library_failure
			}
			add_character_flag = library_failure_first_round
			remove_character_flag = library_failure
		}

		if = {
			limit = {
				has_character_flag = gold_success_first_round
			}
			remove_character_flag = gold_success_first_round
			add_character_flag = gold_success_outcome
		}
		if = {
			limit = {
				has_character_flag = gold_success
			}
			add_character_flag = gold_success_first_round
			remove_character_flag = gold_success
		}
		if = {
			limit = {
				has_character_flag = gold_failure_first_round
			}
			remove_character_flag = gold_failure_first_round
			add_character_flag = gold_failure_outcome
		}
		if = {
			limit = {
				has_character_flag = steal_success_first_round
			}
			remove_character_flag = steal_success_first_round
			add_character_flag = steal_success_outcome
		}
		if = {
			limit = {
				has_character_flag = gold_failure
			}
			add_character_flag = gold_failure_first_round
			remove_character_flag = gold_failure
		}
		if = {
			limit = {
				has_character_flag = steal_success
			}
			add_character_flag = steal_success_first_round
			remove_character_flag = steal_success
		}
	}
}


scripted_trigger sway_ongoing_5015_two_trigger = {
	calc_true_if = {
		amount = 2
		has_character_flag = expansion_failure_outcome
		has_character_flag = library_failure_outcome
		has_character_flag = gold_failure_outcome
	}
}

scripted_trigger sway_ongoing_5015_three_trigger = {
	has_character_flag = expansion_failure_outcome
	has_character_flag = library_failure_outcome
	has_character_flag = gold_failure_outcome
}

#You leave - how did it go?
sway_ongoing.5014 = {
	type = character_event
	title = sway_ongoing.5011.t
	desc = {
		desc = sway_ongoing.5014.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					var:rating >= 3
				}
				desc = sway_ongoing.5014.desc_great
			}
			triggered_desc = {
				trigger = {
					var:rating >= 1
				}
				desc = sway_ongoing.5014.desc_good
			}
			desc = sway_ongoing.5014.desc_bad
		}
		triggered_desc = {
			trigger = {
				OR = {
					has_character_flag = expansion_failure_outcome
					has_character_flag = library_failure_outcome
					AND = {
						has_character_flag = gold_failure_outcome
						NOT = { has_character_flag = steal_success_outcome }
					}
				}
			}
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = {
							var:rating >= 1
						}
						desc = sway_ongoing.5014.desc_failed_but
					}
					desc = sway_ongoing.5014.desc_failed_dot
				}
				first_valid = {
					triggered_desc = {
						trigger = {
							sway_ongoing_5015_three_trigger = yes
						}
						desc = sway_ongoing.5014.desc_failed_three
					}
					triggered_desc = {
						trigger = {
							sway_ongoing_5015_two_trigger = yes
						}
						desc = {
							triggered_desc = {
								trigger = {
									has_character_flag = library_failure_outcome
									has_character_flag = gold_failure_outcome
									NOT = { has_character_flag = steal_success_outcome }
								}
								desc = sway_ongoing.5014.desc_failed_library_gold
							}
							triggered_desc = {
								trigger = {
									has_character_flag = expansion_failure_outcome
									has_character_flag = library_failure_outcome
								}
								desc = sway_ongoing.5014.desc_failed_expansion_library
							}
							triggered_desc = {
								trigger = {
									has_character_flag = expansion_failure_outcome
									has_character_flag = gold_failure_outcome
									NOT = { has_character_flag = steal_success_outcome }
								}
								desc = sway_ongoing.5014.desc_failed_expansion_gold
							}
						}
					}
					triggered_desc = {
						trigger = {
							has_character_flag = expansion_failure_outcome
						}
						desc = sway_ongoing.5014.desc_failed_expansion
					}
					triggered_desc = {
						trigger = {
							has_character_flag = library_failure_outcome
						}
						desc = sway_ongoing.5014.desc_failed_library
					}
					triggered_desc = {
						trigger = {
							has_character_flag = gold_failure_outcome
							NOT = { has_character_flag = steal_success_outcome }
						}
						desc = sway_ongoing.5014.desc_failed_gold
					}
				}
			}
		}
		desc = sway_ongoing.5014.desc_ending
	}
	theme = friendly
	override_icon = {
		trigger = { var:rating < 1 }
		reference = "gfx/interface/icons/event_types/type_relation_unfriendly.dds"
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				var:rating < 1
			}
			animation = shame
		}
		triggered_animation = {
			trigger = { always = yes }
			animation = love
		}
	}
	right_portrait = {
		character = scope:target
		triggered_animation = {
			trigger = {
				var:rating < 1
			}
			animation = sadness
		}
		triggered_animation = {
			trigger = { always = yes }
			animation = happiness
		}
	}

	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:target = { is_alive = yes }
	}

	on_trigger_fail = {
		trigger_event = sway_ongoing.5015
	}

	option = { #Bye bye!
		name = {
			trigger = { var:rating >= 1 }
			text = sway_ongoing.5014.a_good
		}
		name = {
			trigger = { var:rating < 1 }
			text = sway_ongoing.5014.a_bad
		}
		
		if = {
			limit = {
				var:rating >= 3
			}
			scope:target = {
				add_opinion = {
					target = root
					modifier = grateful_opinion
					opinion = 20
				}
			}
		}
		else_if = {
			limit = {
				var:rating >= 1
			}
			scope:target = {
				add_opinion = {
					target = root
					modifier = grateful_opinion
					opinion = 10
				}
			}
		}
		else = {
			scope:target = {
				add_opinion = {
					target = root
					modifier = angry_opinion
					opinion = -10
				}
			}
		}

		#Chance that there's consequences for the vassal/liege
		hidden_effect = {
			if = {
				limit = {
					has_character_flag = expansion_failure_outcome
				}
				random = {
					chance = 15
					scope:target = {
						add_character_modifier = {
							modifier = drafty_dining_hall_modifier
							years = 2
						}
					}
				}
			}
			if = {
				limit = {
					has_character_flag = library_failure_outcome
				}
				random = {
					chance = 15
					scope:target = {
						add_character_modifier = {
							modifier = messy_library_modifier
							years = 2
						}
					}
				}
			}
			if = {
				limit = {
					has_character_flag = gold_failure_outcome
				}
				random = {
					chance = 15
					scope:target = {
						add_character_modifier = {
							modifier = suspicious_of_carpet_modifier
							years = 2
						}
					}
				}
			}
		}

		#Clean up event!
		trigger_event = sway_ongoing.5015
	}
}

#Fallback to clean out flags if target dies and at the end of the chain
sway_ongoing.5015 = {
	hidden = yes

	immediate = {
		remove_variable = rating
		remove_character_flag = expansion_success
		remove_character_flag = block_option_expansion
		remove_character_flag = expansion_failure
		remove_character_flag = block_option_expansion
		remove_character_flag = library_success
		remove_character_flag = block_option_library
		remove_character_flag = library_failure
		remove_character_flag = block_option_library
		remove_character_flag = gold_success
		remove_character_flag = block_option_gold
		remove_character_flag = gold_failure
		remove_character_flag = block_option_gold
		remove_character_flag = steal_success
		remove_character_flag = block_option_steal
		remove_character_flag = expansion_success_first_round
		remove_character_flag = expansion_failure_first_round
		remove_character_flag = library_success_first_round
		remove_character_flag = library_failure_first_round
		remove_character_flag = gold_success_first_round
		remove_character_flag = gold_failure_first_round
		remove_character_flag = steal_success_first_round

		remove_character_flag = expansion_success_outcome
		remove_character_flag = expansion_failure_outcome
		remove_character_flag = library_success_outcome
		remove_character_flag = library_failure_outcome
		remove_character_flag = gold_success_outcome
		remove_character_flag = gold_failure_outcome
		remove_character_flag = steal_success_outcome
	}
}
