﻿namespace = diplomacy_majesty
# Diplomacy (Majesty) Events:
	#0004 - 0006: The Power of Words (Compliment Someone), by Mathilda Bjarnehed
	#0016		: Kindred Spirits (Befriend someone with a similar personality), by Mathilda Bjarnehed
	#1020		: Loyaty or Fear (Keep your vassals in line), by Mathilda Bjarnehed
	#4030 - 4033: A Battle of Ideas (Use your Martial skill in conversations), by Sean Hughes
	#4070 - 4073: The Lure of Language (Learn a minority culture's language), by Sean Hughes
	#4090		: Trappings of Majesty (How will you clothe yourself?), by Sean Hughes

 # Diplomay (Majesty) Special Events:
 	#1010 - 1050: A Tedious Disagreement (Win a debate versus somebody), by Mathilda Bjarnehed

#############################
# The Power of Words		#
# 0004-0006					#
# by Mathilda Bjarnehed		#
#############################

scripted_trigger diplomacy_majesty_0004_compliment_target_trigger = {
	# Must actually be a member of our realm (no neighbors)
	is_available_ai_adult = yes
	save_temporary_scope_as = this_character

	# Must have a neutral-ish opinion of us (friends shouldn't be awkward, foes wouldn't appreciate compliments from you).
	opinion = {
		target = root
		value < 40
	}
	opinion = {
		target = root
		value > -30
	}

	# Must actually be worthy of any kind of compliment...
	can_receieve_good_available_compliment_trigger = yes
}

#What compliment should I use...
diplomacy_majesty.0004 = {
	type = character_event
	title = diplomacy_majesty.0004.t
	desc = diplomacy_majesty.0004.desc
	
	theme = diplomacy_majesty_focus
	left_portrait = scope:compliment_receiver
	
	trigger = {
		NOT = { has_character_flag = had_event_diplomacy_majesty_0004 }
		get_characters_of_major_interest_trigger = { LISTNAME = potential_compliment_targets }
		any_in_list = {
			list = potential_compliment_targets

			diplomacy_majesty_0004_compliment_target_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		# Equally valid in all 3 focuses, so no upscaling/downscaling of focus weights.
	}

	immediate = {
		add_character_flag = {
			flag = had_event_diplomacy_majesty_0004
			days = 1825
		}
		if = {
			limit = {
				is_ai = no
			}
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event_diplomacy
				years = ongoing_lifestyle_event_delay
			}
		}
		else = {
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event
				years = ongoing_lifestyle_event_delay
			}
		}
		hidden_effect = {
			#Find a person to compliment
			get_characters_of_major_interest_effect = { LISTNAME = potential_compliment_targets }
			random_in_list = {
				list = potential_compliment_targets

				limit = {
					diplomacy_majesty_0004_compliment_target_trigger = yes
				}

				weight = {
					base = 0

					modifier = {
						add = {
							value = diplomacy_roots_focus_based_character_relevance_weighting
							multiply = 100
						}
					}
				}

				save_scope_as = compliment_receiver
			}

			#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 = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#bold
	option = {
		trigger = { has_character_flag = available_compliment_bold }
		name = diplomacy_majesty.0004.bold
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#honorable
	option = {
		trigger = { has_character_flag = available_compliment_honorable }
		name = diplomacy_majesty.0004.honorable
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#greed
	option = {
		trigger = { has_character_flag = available_compliment_greedy }
		name = diplomacy_majesty.0004.greed
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#rational
	option = {
		trigger = { has_character_flag = available_compliment_rational }
		name = diplomacy_majesty.0004.rational
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#zealous
	option = {
		trigger = { has_character_flag = available_compliment_zealous }
		name = diplomacy_majesty.0004.zealous
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#energetic
	option = {
		trigger = { has_character_flag = available_compliment_energetic }
		name = diplomacy_majesty.0004.energetic
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#forgiving
	option = {
		trigger = { has_character_flag = available_compliment_forgiving }
		name = diplomacy_majesty.0004.forgiving
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#beautiful
	option = {
		trigger = { has_character_flag = available_compliment_beautiful }
		name = diplomacy_majesty.0004.beautiful
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#strong
	option = {
		trigger = { has_character_flag = available_compliment_strong }
		name = diplomacy_majesty.0004.strong
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#extroverted
	option = {
		trigger = { has_character_flag = available_compliment_extroverted }
		name = diplomacy_majesty.0004.extroverted
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#dominant
	option = {
		trigger = { has_character_flag = available_compliment_dominant }
		name = diplomacy_majesty.0004.dominant
		flavor = 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 } }
		}
		diplomacy_majesty_0004_outcome_effect = yes #Mus be in every options but fallback for tooltip reasons
	}

	#No thanks
	option = {
		name = diplomacy_majesty.0004.fallback				
	}

	after = {
		clear_available_compliments_effect = yes
	}

}	

#What a nice compliment!
diplomacy_majesty.0005 = {
	type = character_event
	title = diplomacy_majesty.0005.t
	desc = diplomacy_majesty.0005.desc
	theme = diplomacy_majesty_focus
	left_portrait = {
		character = scope:compliment_receiver
		animation = happiness
	}
	
	immediate = {		
		if = {
			limit = {
				scope:compliment_receiver = { is_alive = yes }
			}
			reverse_add_opinion = {
				target = scope:compliment_receiver
				modifier = kindness_opinion
				opinion = 25
			}
			progress_towards_friend_effect = {
				CHARACTER = scope:compliment_receiver
				OPINION = no
			}
		}
	}

	option = {
		name = diplomacy_majesty.0005.a
		add_diplomacy_lifestyle_xp = medium_lifestyle_xp

	}
}

#How insulting!
diplomacy_majesty.0006 = {
	type = character_event
	title = diplomacy_majesty.0006.t
	desc = diplomacy_majesty.0006.desc
	theme = diplomacy_majesty_focus
	left_portrait = {
		character = scope:compliment_receiver
		animation = disapproval
	}
	
	immediate = {
		reverse_add_opinion = {
			target = scope:compliment_receiver
			modifier = cruelty_opinion
			opinion = -25
		}
		progress_towards_rival_effect = {
				CHARACTER = scope:compliment_receiver
				OPINION = no
			}
	}

	option = {
		name = diplomacy_majesty.0006.a
	}
}


#############################
# Kindred Spririts			#
# 0016						#
# by Mathilda Bjarnehed		#
#############################

scripted_trigger diplomacy_majesty_0016_potential_friend_trigger = {
	is_available_ai_adult = yes
	NOR = {
		can_set_relation_friend_trigger = { CHARACTER = root }
		root = { has_hook = prev }
		root = { is_scheming_against = { target = prev } }
		this = root
	}
	opinion = {
		target = root
		value > low_negative_opinion
	}
	number_of_opposing_personality_traits = {
		target = root
		value = 0
	}
}

diplomacy_majesty.0016 = {
	type = character_event
	title = diplomacy_majesty.0016.t
	desc = diplomacy_majesty.0016.desc
	theme = diplomacy_majesty_focus
	left_portrait = scope:potential_friend
	
	trigger = {
		is_in_civil_war = no
		NOT = { has_character_flag = had_event_diplomacy_majesty_0016 }

		# Find an appropriate event target
		get_characters_of_major_interest_trigger = { LISTNAME = potential_friend_pool }
		get_characters_of_minor_interest_trigger = { LISTNAME = potential_friend_pool }
		any_in_list = {
			list = potential_friend_pool
			diplomacy_majesty_0016_potential_friend_trigger = yes
		}
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_diplomacy_majesty_0016
			days = 1825
		}
		if = {
			limit = {
				is_ai = no
			}
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event_diplomacy
				years = ongoing_lifestyle_event_delay
			}
		}
		else = {
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event
				years = ongoing_lifestyle_event_delay
			}
		}

		#Find a person to befriend
		get_characters_of_major_interest_effect = { LISTNAME = potential_friend_pool }
		get_characters_of_minor_interest_effect = { LISTNAME = potential_friend_pool }

		random_in_list = {
			list = potential_friend_pool

			limit = {
				diplomacy_majesty_0016_potential_friend_trigger = yes
			}

			weight = {
				base = 10

				modifier = {
					# Adds between 0 and 100 based on relevance score (e.g., if Family is picked, a distant dynatsy member will adds 5, a house member 15, and a brother 55).
					add = {
						value = diplomacy_roots_focus_based_character_relevance_weighting
						multiply = 100
					}
				}
				modifier = {
					is_landed = yes
					add = 100
				}
				opinion_modifier = {
					opinion_target = root
					multiplier = 1.5
				}
				compatibility_modifier = {
					compatibility_target = root
					multiplier = 3
				}
				modifier = {
					has_relation_potential_friend = root
					add = 200
				}
			}
			save_scope_as = potential_friend	
		}
	}

	#Yes, we should be friends!
	option = {
		name = diplomacy_majesty.0016.a

		if = {
			limit = {
				can_start_scheme = {
					target = scope:potential_friend
					type = befriend
				}
			}
			start_scheme = {
				target = scope:potential_friend
				type = befriend
			}
			custom_tooltip = diplomacy_majesty.0016.a.tt
			hidden_effect = {
				random_scheme = {
					limit = {
						scheme_type = befriend
					}
					add_scheme_modifier = {
						type = kindred_spirits_modifier
					}
				}
			}
		}
		else_if = {
			limit = {
				can_set_relation_potential_friend_trigger = { CHARACTER = scope:potential_friend }
			}
			hidden_effect = {
				set_relation_potential_friend = scope:potential_friend
			}
		}
		hidden_effect = {
			add_opinion = {
				target = scope:potential_friend
				modifier = friendliness_opinion
				opinion = 20
			}
		}
		reverse_add_opinion = {
			target = scope:potential_friend
			modifier = friendliness_opinion
			opinion = 20
		}
	}

	#I can take advantage of this...
	option = {
		name = diplomacy_majesty.0016.b

		add_hook = {
			type = manipulation_hook
			target = scope:potential_friend
		}
	}
}	

#############################
# Loyal Subjects			#
# 1020						#
# by Mathilda Bjarnehed		#
#############################

scripted_trigger diplomacy_majesty_1020_vassal_trigger = {
	basic_is_available_ai = yes
	is_adult = yes
	NOT = {
		has_trait_rank = {
			trait = wounded
			rank >= 2
		}
	}
}

diplomacy_majesty.1020 = {
	type = character_event
	title = diplomacy_majesty.1020.t
	desc = diplomacy_majesty.1020.desc
	theme = diplomacy_majesty_focus
	left_portrait = scope:wounded_vassal
	right_portrait = scope:important_ruler
	
	trigger = {
		is_available = yes
		any_vassal = {
			diplomacy_majesty_1020_vassal_trigger = yes
		}
		OR = {
			has_diplomacy_lifestyle_trait_trigger = yes
			diplomacy >= high_skill_rating
		}
		NOT = { has_character_flag = had_diplomacy_majesty_1020_event }
	}

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

	immediate = {
		hidden_effect = {
			add_character_flag = {
				flag = had_diplomacy_majesty_1020_event
				years = 5
			}
			if = {
				limit = {
					is_ai = no
				}
				add_character_flag = {
					flag = had_recent_lifestyle_ongoing_event_diplomacy
					years = ongoing_lifestyle_event_delay
				}
			}
			else = {
				add_character_flag = {
					flag = had_recent_lifestyle_ongoing_event
					years = ongoing_lifestyle_event_delay
				}
			}

			#Save some scopes
			if = {
				limit = { is_independent_ruler = yes }
				random_neighboring_top_liege_realm_owner = {
					limit = {
						is_ai = yes
						highest_held_title_tier >= root.highest_held_title_tier
					}
					alternative_limit = { is_ai = yes }
					save_scope_as = important_ruler
				}
			}
			else_if = {
				limit = {
					liege = {
						is_ai = yes
						NOT = { this = root }
					}
				}
				liege = { save_scope_as = important_ruler }
			}

			random_vassal = {
				limit = {
					diplomacy_majesty_1020_vassal_trigger = yes
				}
				weight = {
					base = 1
					modifier = {
						add = {
							value = ai_boldness
							multiply = -1
						}
					}
				}
				save_scope_as = wounded_vassal
			}
		}
	}

	#Yes, I want to be better
	option = {
		name = diplomacy_majesty.1020.a

		add_character_modifier = {
			modifier = generous_ruler
			years = 10
		}

		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100

			ai_value_modifier = {
				ai_compassion = medium_chance_impact_positive_ai_value
				ai_honor = medium_chance_impact_positive_ai_value
			}
		}
	}
	
	#I rule through fear!
	option = {
		name = diplomacy_majesty.1020.c

		add_dread = medium_dread_gain

		scope:wounded_vassal = {
			increase_wounds_no_death_effect = { REASON = beaten }

			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -20
			}
		}

		stress_impact = {
			generous = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			compassionate = medium_stress_impact_gain
			craven = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}

		ai_chance = {
			base = 75

			ai_value_modifier = {
				ai_greed = low_chance_impact_positive_ai_value
				ai_boldness = low_chance_impact_positive_ai_value
				ai_vengefulness = low_chance_impact_positive_ai_value
			}	
		}
	}

	#I care more about people above me/at my level
	option = {
		trigger = {
			exists = scope:important_ruler
		}
		name = diplomacy_majesty.1020.b
	
		reverse_add_opinion = {
			target = scope:important_ruler
			modifier = respect_opinion
			opinion = 20
		}

		ai_chance = {
			base = 50
		}
	}

	#Opt out
	option = {
		trigger = {
			NOT = { exists = scope:important_ruler }
		}
		name = diplomacy_majesty.1020.d
	
		add_stress = minor_stress_loss

		ai_chance = {
			base = 50
		}
	}
}

#########################
# A Battle of Ideas		#
# 4030 - 4033			#
# by Sean Hughes		#
#########################

scripted_trigger diplomacy_majesty_4030_valid_target = {
	is_available_adult = yes
	is_in_civil_war = no
	NOR = {
		has_character_modifier = diplomacy_majesty_4030_basic_strategy_modifier
		has_character_modifier = diplomacy_majesty_4030_advanced_strategy_modifier
	}
}

diplomacy_majesty.4030 = {
	type = character_event
	title = diplomacy_majesty.4030.t
	desc = diplomacy_majesty.4030.desc
	theme = diplomacy_majesty_focus
	left_portrait = scope:event_target
	
	trigger = {
		martial >= 8
		is_available_adult_or_is_commanding = yes
		
		NOR = {
			#Event can only happen once every 5 years.
			has_character_flag = had_event_diplomacy_majesty_4030
			has_character_modifier = diplomacy_majesty_4030_basic_strategy_modifier
			has_character_modifier = diplomacy_majesty_4030_advanced_strategy_modifier
		}

		#Ensure there is at least one valid target
		get_characters_of_major_interest_trigger = { LISTNAME = potential_important_people }
		any_in_list = {
			list = potential_important_people

			diplomacy_majesty_4030_valid_target = yes
		}

	}

	weight_multiplier = {
		base = 0.5

		compare_modifier = { #10 martial = 1.25, 20 martial = 2
			value = martial
			multiplier = 0.075
			max = 2
		}

		upweight_for_focus_modifier = { FOCUS = diplomacy_majesty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_diplomacy_majesty_4030
			days = 1825
		}
		if = {
			limit = {
				is_ai = no
			}
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event_diplomacy
				years = ongoing_lifestyle_event_delay
			}
		}
		else = {
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event
				years = ongoing_lifestyle_event_delay
			}
		}

		save_scope_as = thinker

		get_characters_of_major_interest_effect = { LISTNAME = potential_important_people }
		random_in_list = {
			list = potential_important_people

			limit = {
				diplomacy_majesty_4030_valid_target = yes
			}

			weight = {
				base = 1

				modifier = {
					# Adds between 0 and 100 based on relevance score (e.g., if Family is picked, a distant dynatsy member will adds 5, a house member 15, and a brother 55).
					add = {
						value = diplomacy_roots_focus_based_character_relevance_weighting
						multiply = 100
					}
				}
			}
			save_scope_as = event_target
		}
	}

	#Attempt to develop more advanced conversational tactics.
	option = {
		name = diplomacy_majesty.4030.a

		duel = {
			skill = martial
			value = 10
			desc = outcome_in_a_few_days
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				trigger_event = { id = diplomacy_majesty.4031 days = 5 }
				desc = diplomacy_majesty.4030.a.success
				show_as_tooltip = {
					add_character_modifier = {
						modifier = diplomacy_majesty_4030_advanced_strategy_modifier
						years = 5
					}
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				trigger_event = { id = diplomacy_majesty.4032 days = 5 }
				desc = diplomacy_majesty.4030.a.failure

				show_as_tooltip = {
					stress_impact = {
						base = minor_stress_impact_gain
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}

		stress_impact = {
			shy = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

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

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

	}

	#Share the tactics you have developed with a possible ally.
	option = {
		name = diplomacy_majesty.4030.b

		scope:event_target = {
			show_as_tooltip = {
				add_character_modifier = {
					modifier = diplomacy_majesty_4030_basic_strategy_modifier
					years = 5
				}
				add_opinion = {
					modifier = pleased_opinion
					target = root
					opinion = 25
				}
			}
			trigger_event = { id = diplomacy_majesty.4033 }
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}

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

	#Simply use the knowledge you already have.
	option = {
		name = diplomacy_majesty.4030.c

		add_character_modifier = {
			modifier = diplomacy_majesty_4030_basic_strategy_modifier
			years = 5
		}

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

#Succeed in developing advanced conversational tactics.
diplomacy_majesty.4031 = {
	type = character_event
	title = diplomacy_majesty.4031.t
	desc = diplomacy_majesty.4031.desc
	theme = diplomacy_majesty_focus
	left_portrait = {
		character = root
		animation = personality_rational
	}
	

	option = {
		name = diplomacy_majesty.4031.a

		add_character_modifier = {
			modifier = diplomacy_majesty_4030_advanced_strategy_modifier
			years = 5
		}
		add_diplomacy_lifestyle_xp = medium_lifestyle_xp
	}
}

#Fail to develop advanced conversational tactics.
diplomacy_majesty.4032 = {
	type = character_event
	title = diplomacy_majesty.4032.t
	desc = diplomacy_majesty.4032.desc
	theme = diplomacy_majesty_focus
	left_portrait = {
		character = root
		animation = stress
	}

	option = {
		name = diplomacy_majesty.4032.a
		stress_impact = {
			base = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
	}
}

#Important person is glad you shared your ideas with them.
diplomacy_majesty.4033 = {
	type = character_event
	title = diplomacy_majesty.4033.t
	desc = diplomacy_majesty.4033.desc
	theme = diplomacy_majesty_focus
	
	left_portrait = scope:thinker
	
	trigger = {
		scope:thinker = {
			is_alive = yes
		}
	}

	option = {
		name = diplomacy_majesty.4033.a

		add_character_modifier = {
			modifier = diplomacy_majesty_4030_basic_strategy_modifier
			years = 5
		}
		add_opinion = {
			modifier = pleased_opinion
			target = scope:thinker
			opinion = 25
		}
		hidden_effect = {
			if = {
				limit = { NOT = { has_relation_potential_friend = scope:thinker } }
				set_relation_potential_friend = scope:thinker
			}
		}
	}
}


#########################
# The Lure of Language	#
# 4070 - 4073			#
# by Sean Hughes		#
#########################

scripted_trigger diplomacy_majesty_4070_valid_culture = {
	NOT = { has_same_culture_group_as = root }
	culture = {
		save_temporary_scope_as = potential_culture
	}

	root = {
		OR = {
			NOT = { has_variable = statecraft_4070_learned_language }
			AND = {
				has_variable = statecraft_4070_learned_language
				NOT = {var:statecraft_4070_learned_language = scope:potential_culture}
			}
		}
	}
	
	is_adult = yes
}

diplomacy_majesty.4070 = {
	type = character_event
	title = diplomacy_majesty.4070.t
	desc = diplomacy_majesty.4070.desc
	theme = diplomacy_majesty_focus
	override_background = {
		event_background = study
	}
	left_portrait = scope:my_vassal
	
	trigger = {
		NOT = { has_character_flag = had_diplomacy_majesty_4070_event }

		any_vassal = {
			diplomacy_majesty_4070_valid_culture = yes
		}
	}

	weight_multiplier = {
		base = 0.5

		compare_modifier = { #10 learning = 1.25, 20 learning = 2.0
			value = learning
			multiplier = 0.075
			max = 2
		}
		upweight_for_focus_modifier = { FOCUS = diplomacy_majesty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_diplomacy_majesty_4070_event
			years = 5
		}
		if = {
			limit = {
				is_ai = no
			}
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event_diplomacy
				years = ongoing_lifestyle_event_delay
			}
		}
		else = {
			add_character_flag = {
				flag = had_recent_lifestyle_ongoing_event
				years = ongoing_lifestyle_event_delay
			}
		}

		random_vassal = {
			limit = {
				diplomacy_majesty_4070_valid_culture = yes

				OR = {
					# Prioritize powerful vassals, as you want to make them feel important.
					is_powerful_vassal_of = root

					# Also can prioritize cultures that make up at least 25% of our realm.
					AND = {
						liege = {
							any_vassal = {
								percent > 0.25
								culture = scope:potential_culture
							}
						}
					}
				}
			}
			alternative_limit = {
				diplomacy_majesty_4070_valid_culture = yes

				# Prioritize cultures that make up at least 10% of our realm.
				liege = {
					any_vassal = {
						percent > 0.10
						culture = scope:potential_culture
					}
				}
			}
			# Otherwise just pick any culture.
			alternative_limit = {
				diplomacy_majesty_4070_valid_culture = yes
			}

			weight = {
				base = 1
				modifier = {
					is_powerful_vassal_of = root
					add = 20
				}
				compare_modifier = {
					value = highest_held_title_tier
					multiplier = 10
				}
			}

			save_scope_as = my_vassal
		}
	}

	option = {
		name = diplomacy_majesty.4070.a

		stress_impact = {
			arrogant = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}

		duel = {
			skill = learning
			value = 10
			desc = outcome_in_a_few_weeks
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -49
				}

				desc = diplomacy_majesty.4070.success
				show_as_tooltip = {
					every_vassal = {
						limit = {
							has_same_culture_as = scope:my_vassal
						}
						add_opinion = {
							target = root
							modifier = respect_opinion
							opinion = 30
						}
					}
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
				}
				trigger_event = {
					id = diplomacy_majesty.4071
					days = { 45 75 }
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -49
				}
				desc = diplomacy_majesty.4070.failure
				show_as_tooltip = {
					add_stress = minor_stress_gain
					custom_tooltip = diplomacy_majesty.4070.failure.tt
				}
				trigger_event = {
					id = diplomacy_majesty.4072
					days = { 45 75 }
				}
			}
		}

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 500
				ai_energy = 200
			}
		}	
	}

	option = {
		name = diplomacy_majesty.4070.b
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= medium_gold_value_check
			}
		}

		remove_short_term_gold = medium_gold_value
		stress_impact = {
			greedy = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		
		duel = {
			skill = learning
			value = 10
			desc = outcome_in_a_few_weeks
			75 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -74
				}
				desc = diplomacy_majesty.4070.success
				show_as_tooltip = {
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
					every_vassal = {
						limit = {
							has_same_culture_as = scope:my_vassal
						}
						add_opinion = {
							target = root
							modifier = respect_opinion
							opinion = 30
						}
					}
				}
				trigger_event = {
					id = diplomacy_majesty.4071
					days = { 45 75 }
				}
			}
			25 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -24
				}
				desc = diplomacy_majesty.4070.failure
				show_as_tooltip = {
					add_stress = minor_stress_gain
					custom_tooltip = diplomacy_majesty.4070.failure.tt
				}
				trigger_event = {
					id = diplomacy_majesty.4072
					days = { 45 75 }
				}
			}
		}

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

	}
	
	option = {
		name = diplomacy_majesty.4070.c
		add_prestige = medium_prestige_gain

		stress_impact = {
			humble = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -0.5
			}
		}
	}
}

diplomacy_majesty.4071 = {
	type = character_event
	title = diplomacy_majesty.4071.t
	desc = diplomacy_majesty.4071.desc
	theme = diplomacy_majesty_focus
	override_background = {
		event_background = study
	}
	left_portrait = {
		character = root
		animation = happiness
	}

	option = {
		name = diplomacy_majesty.4071.a

		add_diplomacy_lifestyle_xp = medium_lifestyle_xp
		every_vassal = {
			limit = {
				has_same_culture_as = scope:my_vassal
			}
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 30
			}
		}

		set_variable = {
			name = statecraft_4070_learned_language
			value = scope:my_vassal.culture
		}

		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_rationality = 1
			}
		}
	}

	option = {
		name = diplomacy_majesty.4071.b

		add_diplomacy_lifestyle_xp = medium_lifestyle_xp
		root = {
			set_culture = scope:my_vassal.culture
		}
		every_close_family_member = {
			limit = {
				OR = {
					is_courtier_of = root
					AND = {
						is_vassal_of = root
						is_child_of = root
					}
				}
			}
			custom = diplomacy_majesty.4070.b.custom
			random = {
				chance = {
					value = root.diplomacy
					multiply = 3
					add = 30
				}
				set_culture = scope:my_vassal.culture
			}
			hidden_effect = {
				if = {
					limit = {
						this = player_heir
					}
				}
				set_culture = scope:my_vassal.culture
			}
		}
		ai_chance = {
			base = -100
			ai_value_modifier = {
				ai_rationality = -2
			}
		}
	}

}

diplomacy_majesty.4072 = {
	type = character_event
	title = diplomacy_majesty.4072.t
	desc = diplomacy_majesty.4072.desc
	theme = diplomacy_majesty_focus
	override_background = {
		event_background = study
	}
	left_portrait = {
		character = root
		animation = stress
	}

	immediate = {
		add_stress = minor_stress_gain
	}

	option = {
		name = diplomacy_majesty.4072.a

		duel = {
			skill = learning
			value = 10
			desc = outcome_in_a_few_weeks
			66 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -65
				}
				desc = diplomacy_majesty.4070.success
				show_as_tooltip = {
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
					every_vassal = {
						limit = {
							has_same_culture_as = scope:my_vassal
						}
						add_opinion = {
							target = root
							modifier = respect_opinion
							opinion = 30
						}
					}
				}
				trigger_event = {
					id = diplomacy_majesty.4071
					days = { 45 75 }
				}
			}
			33 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -32
				}
				desc = diplomacy_majesty.4070.failure
				show_as_tooltip = {
					add_stress = minor_stress_gain
				}
				trigger_event = {
					id = diplomacy_majesty.4073
					days = { 45 75 }
				}
			}
		}

		stress_impact = {
			impatient = medium_stress_impact_gain
			fickle = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
				ai_energy = 2
			}
		}

	}
	
	option = {
		name = diplomacy_majesty.4072.b

		stress_impact = {
			stubborn = medium_stress_impact_gain
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -2
			}
		}
	}	
}

diplomacy_majesty.4073 = {
	type = character_event
	title = diplomacy_majesty.4073.t
	desc = diplomacy_majesty.4073.desc
	theme = diplomacy_majesty_focus
	override_background = {
		event_background = study
	}
	left_portrait = {
		character = root
		animation = sadness
	}

	immediate = {
		add_stress = minor_stress_gain
	}

	option = {
		name = diplomacy_majesty.4073.a
	}	
}


#########################
# Trappings of Majesty	#
# 4090					#
# by Sean Hughes		#
#########################

diplomacy_majesty.4090 = {
	type = character_event
	title = diplomacy_majesty.4090.t
	desc = diplomacy_majesty.4090.desc
	theme = diplomacy_majesty_focus
	left_portrait = root
	
	trigger = {
		is_independent_ruler = yes
		highest_held_title_tier >= 4
		NOR = {
			should_be_naked_trigger = yes
			has_character_flag = had_event_diplomacy_majesty_4090
		}
	}

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

	
	immediate = {
		add_character_flag = {
			flag = had_event_diplomacy_majesty_4090
			years = 10
		}
		save_scope_as = me # We need to save our own scope for effects in the options.
	}


	#Spend gold to get luxurious clothes.
	option = {
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= major_gold_value
			}
		}

		name = diplomacy_majesty.4090.a
		remove_short_term_gold = major_gold_value
		add_character_modifier = {
			modifier = diplomacy_majesty_4090_resplendent_raiment_modifier
			years = 5
		}
		hidden_effect = { add_focus_progress = standard_lifestyle_focus_progress }

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

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 500
			}
		}
	}

	#Find a tailor to make raiment from local materials.
	option = {
		name = diplomacy_majesty.4090.b

		duel = {
			skill = stewardship
			value = 10

			desc = diplomacy_majesty.4090.b.desc
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = diplomacy_majesty.4090.b.success
				send_interface_toast = {
					title = diplomacy_majesty.4090.b.success

					add_character_modifier = {
						modifier = diplomacy_majesty_4090_traditional_raiment_modifier
						years = 5
					}
					
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
				}
				hidden_effect = { add_focus_progress = standard_lifestyle_focus_progress }
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = diplomacy_majesty.4090.b.failure
				send_interface_toast = {
					title = diplomacy_majesty.4090.b.failure

					add_prestige = minor_prestige_loss
				}
			}
		}

		ai_chance = {
			base = 100

			ai_value_modifier = {
				ai_compassion = 200
			}

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

		stress_impact = {
			greedy = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
			profligate = medium_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
	}
	
	#I'm good enough to not need nice clothes.
	option = {
		name = diplomacy_majesty.4090.c
		trigger = {
			NOR = {
				has_trait = lunatic
				AND = {
					has_trait = zealous
					faith = {
						OR = {
							trait_is_sin = greedy
							trait_is_virtue = generous
						}
					}
				}
			}
		}

		add_piety = medium_piety_gain

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -200
				ai_boldness = -100
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			profligate = medium_stress_impact_gain
		}
	}

	#I am zealous enough to not need nice clothes.
	option = {
		name = diplomacy_majesty.4090.c.zealous
		trigger = {
			has_trait = zealous
			faith = {
				OR = {
					trait_is_sin = greedy
					trait_is_virtue = generous
				}
			}
		}
		trait = zealous

		add_piety = major_piety_gain

		stress_impact = {
			greedy = minor_stress_impact_gain
			profligate = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -100
				ai_zeal = 200
			}
		}
	}

	#If lunatic just go naked.
	option = {
		trigger = {
			has_trait = lunatic
			NOT = { has_game_rule = never_nudity }
		}

		name = {
			trigger = {
				has_trait_rank = {
					trait = beauty_good
					rank > 0
				}
			}
			text = diplomacy_majesty.4090.d.lunatic_beautiful
		}
		name = {
			trigger = {
				is_male = yes
				NOT = {
					has_trait_rank = {
						trait = beauty_good
						rank > 0
					}
				}
			}
			text = diplomacy_majesty.4090.d.lunatic.male
		}
		name = {
			trigger = {
				is_female = yes
				NOT = {
					has_trait_rank = {
						trait = beauty_good
						rank > 0
					}
				}
			}
			text = diplomacy_majesty.4090.d.lunatic.female
		}
		name = {
			trigger = {
				NOT = {
					has_trait_rank = {
						trait = beauty_good
						rank > 0
					}
				}
			}
			text = diplomacy_majesty.4090.d.lunatic.neutral
		}

		trait = lunatic_1
		trait = lunatic_genetic
		trait = beauty_good_1
		trait = beauty_good_2
		trait = beauty_good_3

		stress_impact = {
			base = major_stress_impact_loss
			shy = medium_stress_impact_gain
		}
		
		add_character_modifier = {
			modifier = diplomacy_majesty_4090_no_raiment_modifier
		}

		#We want to encourage this opion if the AI is elegible, because it's funny.
		ai_chance = {
			base = 100000
		}
	}
}

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

#############################
# A Tedious Disagreement	#
# 1010-1050					#
# by Mathilda Bjarnehed		#
#############################

scripted_trigger diplomacy_majesty_special_1010_debater = {
	is_available_healthy_adult = yes
	is_ai = yes
	ai_values_divergence = {
		target = root
		value > low_ai_values_divergence
	}
}

diplomacy_majesty_special.1010 = {
	type = character_event
	title = diplomacy_majesty_special.1010.t
	desc = {
		desc = diplomacy_majesty_special.1010.start.desc
		first_valid = { #Topic
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:divine_attributes
				}
				desc = diplomacy_majesty_special.1010.divine_attributes.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:free_will
				}
				desc = diplomacy_majesty_special.1010.free_will.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:faith_reason
				}
				desc = diplomacy_majesty_special.1010.faith_reason.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:just_war
				}
				desc = diplomacy_majesty_special.1010.just_war.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:chivalry
				}
				desc = diplomacy_majesty_special.1010.chivalry.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:seven_virtues
				}
				desc = diplomacy_majesty_special.1010.seven_virtues.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:duty_women
				}
				desc = diplomacy_majesty_special.1010.duty_women.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:mercy
				}
				desc = diplomacy_majesty_special.1010.mercy.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:ambition
				}
				desc = diplomacy_majesty_special.1010.ambition.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:inheritance
				}
				desc = diplomacy_majesty_special.1010.inheritance.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:mapped_territory
				}
				desc = diplomacy_majesty_special.1010.mapped_territory.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:heroism
				}
				desc = diplomacy_majesty_special.1010.heroism.desc
			}
		}
		desc = diplomacy_majesty_special.1010.end.desc
	}
	
	theme = diplomacy_majesty_focus
	left_portrait = scope:debater
	
	trigger = {
		# No focus restriction, because this event actually works for all focus types.
		# Standard special event triggers
		NOT = { has_character_flag = is_in_diplomacy_majesty_special_event }
		NOT = { has_character_flag = had_diplomacy_majesty_special_1010_this_lifetime }

		# Ensure there is at least one valid person we can debate.
		get_characters_of_major_interest_trigger = { LISTNAME = list_name }
		any_in_list = {
			list = list_name
			diplomacy_majesty_special_1010_debater = yes
		}
		is_in_civil_war = no
	}

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

	immediate = {
		add_character_flag = is_in_diplomacy_majesty_special_event
		add_character_flag = had_diplomacy_majesty_special_1010_this_lifetime

		# Find an interesting person for us to debate.
		get_characters_of_major_interest_effect = { LISTNAME = debater_options }

		# Since this event can only occur once per character lifetime, we will find the absolute best event target instead of using a weighted random list.
		ordered_in_list = {
			list = debater_options

			limit = {
				# Basic limitations
				diplomacy_majesty_special_1010_debater = yes
			}
		
			order_by = {
				value = 1

				#########################################
				# Lifestyle Focus Weights 				#
				# Adds 5 to 100 pts based on relevance	#
				#########################################

				add = {
					value = diplomacy_roots_focus_based_character_relevance_weighting
					multiply = 100
				}

				#########################################
				# Philosophical Disagreement Weights	#
				# Adds 5 to 50 pts based on divergence	#
				#########################################

				if = {
					limit = {
						ai_values_divergence = {
							target = root
							value >= very_high_ai_values_divergence
						}
					}
					add = 50
				}
				else_if = {
					limit = {
						ai_values_divergence = {
							target = root
							value >= high_ai_values_divergence
						}
					}
					add = 25
				}
				else_if = {
					limit = {
						ai_values_divergence = {
							target = root
							value >= medium_ai_values_divergence
						}
					}
					add = 10
				}

				#########################################
				# Interesting Character Weights			#
				# Adds 3 to 50 pts based on interest	#
				#########################################

				add = {
					value = highest_held_title_tier
					multiply = 3 # Adds 3 (Baron), 6 (Count), 9 (Duke), 12 (King) or 15 (Emperor).
				}
				if = {
					limit = {
						has_relation_nemesis = root
					}
					add = 35
				}
				else_if = {
					limit = {
						OR = {
							has_relation_rival = root
							has_relation_best_friend = root
							has_relation_soulmate = root
						}
					}
					add = 25
				}
				else_if = {
					limit = {
						OR = {
							has_relation_potential_rival = root
							has_relation_friend = root
							has_relation_lover = root
							has_relation_oaf = root
						}
					}
					add = 15
				}
				else_if = {
					limit = {
						OR = {
							has_relation_potential_friend = root
							has_relation_potential_lover = root
						}
					}
					add = 5
				}
			}
			save_scope_as = debater
		}


		#Select debate topic
		random_list = {
			10 = {
				trigger = {
					opposing_ai_values_trigger = { TARGET = scope:debater VALUE = zeal }
				}
				save_scope_value_as = {
					name = topic
					value = flag:divine_attributes # the compatibility of the divine attributes
				}
			}
			10 = {
				trigger = {
					opposing_ai_values_trigger = { TARGET = scope:debater VALUE = zeal }
					OR = {
						root.faith = {
							has_doctrine = abrahamic_hostility_doctrine
						}
						scope:debater.faith = {
							has_doctrine = abrahamic_hostility_doctrine
						}
					}
				}
				save_scope_value_as = {
					name = topic
					value = flag:free_will #the compatibility of divine foreknowledge with free will
				}
			}
			10 = {
				trigger = {
					OR = {
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = zeal }
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = rationality }
					}
				}
				save_scope_value_as = {
					name = topic
					value = flag:faith_reason # the relationship of faith and reason
				}
			}
			10 = {
				trigger = {
					OR = {
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = honor }
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = compassion }
					}
				}
				save_scope_value_as = {
					name = topic
					value = flag:just_war #the nature of just war
				}
			}
			10 = {
				trigger = {
					OR = {
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = honor }
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = compassion }
					}
				}
				save_scope_value_as = {
					name = topic
					value = flag:chivalry #the value of chivalry
				}
			}
			10 = {
				trigger = {
					AND = {
						root.faith = faith:catholic
						scope:debater.faith = faith:catholic
					}
				}
				save_scope_value_as = {
					name = topic
					value = flag:seven_virtues #the most important of the seven virtues
				}
			}
			10 = {
				trigger = { sex_opposite_of = scope:debater }
				save_scope_value_as = {
					name = topic
					value = flag:duty_women #the duties of women
				}
			}
			10 = {
				trigger = {
					OR = {
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = vengefulness }
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = compassion }
					}
				}
				save_scope_value_as = {
					name = topic
					value = flag:mercy #whether mercy is a sign of weakness
				}
			}
			10 = {
				trigger = {
					opposing_ai_values_trigger = { TARGET = scope:debater VALUE = greed }
				}
				save_scope_value_as = {
					name = topic
					value = flag:ambition #whether ambition is a sin or a strength
				}
			}
			10 = {
				trigger = {
					opposing_ai_values_trigger = { TARGET = scope:debater VALUE = greed }
				}
				save_scope_value_as = {
					name = topic
					value = flag:inheritance #matters of inheritance law
				}
			}
			10 = {
				trigger = {
					OR = {
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = honor }
						opposing_ai_values_trigger = { TARGET = scope:debater VALUE = boldness }
					}
				}
				save_scope_value_as = {
					name = topic
					value = flag:heroism #whether heroism is bravery or folly
				}
			}
			5 = {
				save_scope_value_as = {
					name = topic
					value = flag:mapped_territory #what lies beyond the edge of mapped territory
				}
			}

		}

		#If the event ended because debater died/was imprisoned, let you know nothing happened
		trigger_event = {
			id = diplomacy_majesty_special.1050
			days = 30 #The event chain would be over by then (21+5 days)
		}	
	}

	#Study the subject
	option = {
		name = diplomacy_majesty_special.1010.a

		custom_tooltip = diplomacy_majesty_special.1010.o.tt
		custom_tooltip = diplomacy_lifestyle_rank_up_indication

		duel = {
			skill = learning
			target = scope:debater
			
			80 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -79
				}

				desc = diplomacy_majesty_special.1010.a.success.desc
				send_interface_toast = {
					left_icon = scope:debater
					title = diplomacy_majesty_special.1010.a.success.desc
					custom_tooltip = diplomacy_majesty_special.1010.a.success.tt	
				}
				hidden_effect = {
					save_scope_value_as = {
						name = preparation_outcome
						value = flag:study_subject_success
					}
				}
			}
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -19
				}

				desc = diplomacy_majesty_special.1010.a.failure.desc
				send_interface_toast = {
					left_icon = scope:debater
					title = diplomacy_majesty_special.1010.a.failure.desc
					custom_tooltip = diplomacy_majesty_special.1010.a.failure.tt	
				}
				hidden_effect = {
					save_scope_value_as = {
						name = preparation_outcome
						value = flag:study_subject_failure
					}
				}
			}
		}

		stress_impact = {
			dull = medium_stress_impact_gain
			lazy = medium_stress_impact_gain
		}
	}

	#Study the opponent
	option = {
		name = diplomacy_majesty_special.1010.b

		custom_tooltip = diplomacy_majesty_special.1010.o.tt
		custom_tooltip = diplomacy_lifestyle_rank_up_indication

		duel = {
			skill = intrigue
			target = scope:debater

			70 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -69
				}

				desc = diplomacy_majesty_special.1010.b.success.desc
				send_interface_toast = {
					left_icon = scope:debater
					title = diplomacy_majesty_special.1010.b.success.desc
					custom_tooltip = diplomacy_majesty_special.1010.b.success.tt
				}
				hidden_effect = {
					save_scope_value_as = {
						name = preparation_outcome
						value = flag:study_opponent_success
					}
				}
			}
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -29
				}

				desc = diplomacy_majesty_special.1010.a.failure.desc
				send_interface_toast = {
					left_icon = scope:debater
					title = diplomacy_majesty_special.1010.a.failure.desc
					custom_tooltip = diplomacy_majesty_special.1010.a.failure.tt	
				}
				hidden_effect = {
					save_scope_value_as = {
						name = preparation_outcome
						value = flag:study_opponent_failure
					}
				}
			}
		}

		stress_impact = {
			honest = minor_stress_impact_gain
		}
	}

	#I will rest
	option = {
		name = diplomacy_majesty_special.1010.c
		custom_tooltip = diplomacy_majesty_special.1010.o.tt
		custom_tooltip = diplomacy_lifestyle_rank_up_indication

		stress_impact = {
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
	}
	
	#Shut them up
	option = {
		trigger = {
			highest_held_title_tier > scope:debater.highest_held_title_tier
			OR = {
				has_trait = arrogant
				has_trait = stubborn
				has_trait = sadistic
				has_trait = callous
				has_trait = wrathful
				has_trait = vengeful
			}
		}
		name = diplomacy_majesty_special.1010.d

		trait = arrogant
		trait = stubborn
		trait = sadistic
		trait = callous
		trait = wrathful
		trait = vengeful
		
		add_dread = medium_dread_gain
		scope:debater = {
			increase_wounds_effect = { REASON = punishment }
		}
		reverse_add_opinion = {
			modifier = cruelty_opinion
			opinion = -20
			target = scope:debater
		}
		hidden_effect = { remove_character_flag = is_in_diplomacy_majesty_special_event }

	}

	#Let them win
	option = {
		trigger = {
			OR = {
				highest_held_title_tier <= scope:debater.highest_held_title_tier
				NOR = {
					has_trait = arrogant
					has_trait = stubborn
					has_trait = sadistic
					has_trait = callous
					has_trait = wrathful
					has_trait = vengeful
				}
			}
		}
		name = diplomacy_majesty_special.1010.e

		reverse_add_opinion = {
			modifier = pleased_opinion
			opinion = 20
			target = scope:debater
		}

		hidden_effect = { remove_character_flag = is_in_diplomacy_majesty_special_event }

		stress_impact = {
			ambitious = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			zealous = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 0
		}
	}

	after = {
		hidden_effect = {

			if = {
				limit = { has_character_flag = is_in_diplomacy_majesty_special_event }

				hidden_effect = {
					trigger_event = {
						id = diplomacy_majesty_special.1011
						days = { 7 21 }
					}
				}
			}
		}
	}
}

#Outcome of preparations and choice of tactics
diplomacy_majesty_special.1011 = {
	type = character_event
	title = diplomacy_majesty_special.1010.t
	desc = {
		desc = diplomacy_majesty_special.1011.start.desc
		first_valid = { #Topic
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:divine_attributes
				}
				desc = diplomacy_majesty_special.1010.divine_attributes.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:free_will
				}
				desc = diplomacy_majesty_special.1010.free_will.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:faith_reason
				}
				desc = diplomacy_majesty_special.1010.faith_reason.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:just_war
				}
				desc = diplomacy_majesty_special.1010.just_war.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:chivalry
				}
				desc = diplomacy_majesty_special.1010.chivalry.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:seven_virtues
				}
				desc = diplomacy_majesty_special.1010.seven_virtues.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:duty_women
				}
				desc = diplomacy_majesty_special.1010.duty_women.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:mercy
				}
				desc = diplomacy_majesty_special.1010.mercy.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:ambition
				}
				desc = diplomacy_majesty_special.1010.ambition.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:inheritance
				}
				desc = diplomacy_majesty_special.1010.inheritance.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:mapped_territory
				}
				desc = diplomacy_majesty_special.1010.mapped_territory.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:topic
					scope:topic = flag:heroism
				}
				desc = diplomacy_majesty_special.1010.heroism.desc
			}
		}
		#Outcome of preparations
		triggered_desc = {
			trigger = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_subject_success
			}
			desc = diplomacy_majesty_special.1011.study_subject_success.desc
		}
		triggered_desc = {
			trigger = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			desc = diplomacy_majesty_special.1011.study_opponent_success.desc
		}
		triggered_desc = {
			trigger = {
				exists = scope:preparation_outcome
				OR = {
					scope:preparation_outcome = flag:study_subject_failure
					scope:preparation_outcome = flag:study_opponent_failure
				}
			}
			desc = diplomacy_majesty_special.1011.failure.desc
		}
		desc = diplomacy_majesty_special.1011.end.desc
	}
	
	theme = diplomacy_majesty_focus
	left_portrait = scope:debater

	trigger = {
		scope:debater = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		scope:debater = { strongest_ai_value_effect = yes }
	}
	
	#Win them over
	option = {
		name = diplomacy_majesty_special.1011.a
		flavor = diplomacy_majesty_special.1011.a.flavor

		stress_impact = {
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}

		#tooltip for possible outcomes of this path
		show_as_tooltip = {
			random_list = {
				desc = diplomacy_majesty_special.1011.a.desc
				1 = {
					desc = diplomacy_majesty_special.1011.a.success.desc
					show_chance = no
					add_diplomacy_lifestyle_perk_points = 1
					reverse_add_opinion = {
						modifier = respect_opinion
						opinion = 20
						target = scope:debater
					}
				}
				1 = {
					desc = diplomacy_majesty_special.1011.a.failure.desc
					show_chance = no
					add_prestige = medium_prestige_loss
				}
			}
		}


		
		hidden_effect = {
			trigger_event = {
				id = diplomacy_majesty_special.1012
			}
		}
	}

	#Humiliate them
	option = {
		name = diplomacy_majesty_special.1011.b
		flavor = diplomacy_majesty_special.1011.b.flavor

		#tooltip for possible outcomes of this path
		show_as_tooltip = {
			random_list = {
				desc = diplomacy_majesty_special.1011.a.desc
				1 = {
					desc = diplomacy_majesty_special.1011.a.success.desc
					show_chance = no
					add_diplomacy_lifestyle_perk_points = 1
					add_prestige = medium_prestige_gain
					scope:debater = {
						add_opinion = {
							modifier = cruelty_opinion
							opinion = -20
							target = root
						}
						custom_tooltip = diplomacy_majesty_special.1011.b.rival
					}
					
				}
				1 = {
					desc = diplomacy_majesty_special.1011.a.failure.desc
					show_chance = no
					add_prestige = medium_prestige_loss
				}
			}
		}

		stress_impact = {
			humble = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		
		hidden_effect = {
			trigger_event = {
				id = diplomacy_majesty_special.1014
			}
		}
	}

	after = {
		hidden_effect = { scope:debater = { remove_variable = strongest_ai_value} }
	}
}	

#Win them over tactic
diplomacy_majesty_special.1012 = {
	type = character_event
	title = diplomacy_majesty_special.1010.t
	desc = diplomacy_majesty_special.1012.desc
	
	theme = diplomacy_majesty_focus
	left_portrait = scope:debater

	trigger = {
		scope:debater = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	#Use logic
	option = {
		name = diplomacy_majesty_special.1012.a
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1012.a.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1012.generic.tt
		}

		stress_impact = {
			zealous = minor_stress_impact_gain
			fickle = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			intellect_bad_1 = minor_stress_impact_gain
			intellect_bad_2 = minor_stress_impact_gain
			intellect_bad_3 = minor_stress_impact_gain
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:logic
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_rationality > 0 }
							scope:debater = { ai_greed > 0 }
							scope:debater = { ai_zeal < 0 }
							scope:debater = { ai_compassion < 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_rationality >= medium_positive_rationality }
							scope:debater = { ai_greed >= medium_positive_greed }
							scope:debater = { ai_zeal <= medium_negative_zeal }
							scope:debater = { ai_compassion <= medium_negative_compassion }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_rationality >= high_positive_rationality }
							scope:debater = { ai_greed >= high_positive_greed }
							scope:debater = { ai_zeal <= high_negative_zeal }
							scope:debater = { ai_compassion <= high_negative_compassion }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}

	#Stay calm
	option = {
		name = diplomacy_majesty_special.1012.b
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1012.b.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1012.generic.tt
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:calm
			}

			stress_impact = {
				wrathful = minor_stress_impact_gain
				stubborn = minor_stress_impact_gain
				vengeful = minor_stress_impact_gain
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_boldness > 0 }
							scope:debater = { ai_energy > 0 }
							scope:debater = { ai_vengefulness > 0 }
							scope:debater = { ai_honor < 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_boldness >= medium_positive_boldness }
							scope:debater = { ai_energy >= medium_positive_energy }
							scope:debater = { ai_vengefulness >= medium_positive_vengefulness }
							scope:debater = { ai_honor <= medium_negative_honor }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_boldness >= high_positive_boldness }
							scope:debater = { ai_energy >= high_positive_energy }
							scope:debater = { ai_vengefulness >= high_positive_vengefulness }
							scope:debater = { ai_honor <= high_negative_honor }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}
	
	#Appeal to higher values
	option = {
		name = diplomacy_majesty_special.1012.c
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1012.c.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1012.generic.tt
		}

		stress_impact = {
			deceitful = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:higher_values
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_honor > 0 }
							scope:debater = { ai_compassion > 0 }
							scope:debater = { ai_vengefulness < 0 }
							scope:debater = { ai_zeal > 0 }
							scope:debater = { ai_greed < 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_honor >= medium_positive_honor }
							scope:debater = { ai_compassion >= medium_positive_compassion }
							scope:debater = { ai_vengefulness <= medium_positive_vengefulness }
							scope:debater = { ai_zeal >= medium_positive_zeal }
							scope:debater = { ai_greed <= medium_negative_greed }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_honor >= high_positive_honor }
							scope:debater = { ai_compassion >= high_positive_compassion }
							scope:debater = { ai_vengefulness <= high_positive_vengefulness }
							scope:debater = { ai_zeal >= high_positive_zeal }
							scope:debater = { ai_greed <= high_negative_greed }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}

	#Let them speak and listen attentively
	option = {
		name = diplomacy_majesty_special.1012.d
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1012.d.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1012.generic.tt
		}

		stress_impact = {
			intellect_good_3 = minor_stress_impact_gain
			intellect_good_2 = minor_stress_impact_gain
			intellect_good_1 = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:listen
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_boldness < 0 }
							scope:debater = { ai_energy < 0 }
							scope:debater = { ai_rationality < 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_boldness <= medium_negative_boldness }
							scope:debater = { ai_energy <= medium_negative_energy }
							scope:debater = { ai_rationality <= medium_negative_rationality }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_boldness <= high_negative_boldness }
							scope:debater = { ai_energy <= high_negative_energy }
							scope:debater = { ai_rationality <= high_negative_rationality }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}

	after = {
		hidden_effect = {
			#Trigger win or lose event
			if = {
				limit = {
					exists = scope:debate_outcome
					scope:debate_outcome = flag:success
				}
				trigger_event = {
					id = diplomacy_majesty_special.1013
					days = 5
				}
			}
			else = {
				trigger_event = {
					id = diplomacy_majesty_special.1016
					days = 5
				}
			}
		}
	}
}	

#Win them over success
diplomacy_majesty_special.1013 = {
	type = character_event
	title = diplomacy_majesty_special.1010.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:logic
				}
				desc = diplomacy_majesty_special.1013.logic.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:calm
				}
				desc = diplomacy_majesty_special.1013.calm.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:higher_values
				}
				desc = diplomacy_majesty_special.1013.higher_values.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:listen
				}
				desc = diplomacy_majesty_special.1013.listen.desc
			}
		}
	}
	
	theme = diplomacy_majesty_focus
	left_portrait = scope:debater

	trigger = {
		scope:debater = {
			is_alive = yes
			is_imprisoned = no
		}
	}
	
	option = {
		name = {
			trigger = { ai_compassion < 0 }
			text = diplomacy_majesty_special.1013.a.cruel
		}
		name = {
			trigger = { ai_compassion >= 0 }
			text = diplomacy_majesty_special.1013.a.compassionate
		}
			
		add_diplomacy_lifestyle_perk_points = 1

		reverse_add_opinion = {
			modifier = respect_opinion
			opinion = 20
			target = scope:debater
		}

		hidden_effect = { remove_character_flag = is_in_diplomacy_majesty_special_event }
	}
}

#Humiliate them tactic
diplomacy_majesty_special.1014 = {
	type = character_event
	title = diplomacy_majesty_special.1010.t
	desc = diplomacy_majesty_special.1014.desc
	
	theme = diplomacy_majesty_focus
	left_portrait = scope:debater

	trigger = {
		scope:debater = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	#Scare
	option = {
		name = diplomacy_majesty_special.1014.a
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1014.a.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1014.generic.tt
		}

		stress_impact = {
			craven = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:scare
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_boldness < 0 }
							scope:debater = { ai_compassion > 0 }
							scope:debater = { ai_vengefulness < 0 }
							scope:debater = { ai_energy < 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_boldness <= medium_negative_boldness }
							scope:debater = { ai_compassion >= medium_positive_compassion }
							scope:debater = { ai_vengefulness <= medium_negative_vengefulness }
							scope:debater = { ai_energy <= medium_negative_energy }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_boldness <= high_negative_boldness }
							scope:debater = { ai_compassion >= high_positive_compassion }
							scope:debater = { ai_vengefulness <= high_negative_vengefulness }
							scope:debater = { ai_energy <= high_negative_energy }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}

	#Provoke
	option = {
		name = diplomacy_majesty_special.1014.b
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1014.b.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1014.generic.tt
		}

		stress_impact = {
			wrathful = minor_stress_impact_gain
			just = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:provoke
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_boldness > 0 }
							scope:debater = { ai_energy > 0 }
							scope:debater = { ai_vengefulness > 0 }
							scope:debater = { ai_honor > 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_boldness >= medium_positive_boldness }
							scope:debater = { ai_energy >= medium_positive_energy }
							scope:debater = { ai_vengefulness >= medium_positive_vengefulness }
							scope:debater = { ai_honor >= medium_positive_zeal }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_boldness >= high_positive_boldness }
							scope:debater = { ai_energy >= high_positive_energy }
							scope:debater = { ai_vengefulness >= high_positive_vengefulness }
							scope:debater = { ai_honor >= high_positive_zeal }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}
	
	#Make them look bad
	option = {
		name = diplomacy_majesty_special.1014.c
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1014.c.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1014.generic.tt
		}

		stress_impact = {
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			deceitful = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:low_character
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_honor < 0 }
							scope:debater = { ai_compassion < 0 }
							scope:debater = { ai_greed > 0 }
							scope:debater = { ai_zeal < 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_honor <= medium_negative_honor }
							scope:debater = { ai_compassion <= medium_negative_compassion }
							scope:debater = { ai_greed >= medium_positive_greed }
							scope:debater = { ai_zeal <= medium_negative_zeal }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_honor <= high_negative_honor }
							scope:debater = { ai_compassion <= high_negative_compassion }
							scope:debater = { ai_greed >= high_positive_greed }
							scope:debater = { ai_zeal <= high_negative_zeal }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}

	#Exaggerate position
	option = {
		name = diplomacy_majesty_special.1014.d
		if = {
			limit = {
				exists = scope:preparation_outcome
				scope:preparation_outcome = flag:study_opponent_success
			}
			custom_tooltip = diplomacy_majesty_special.1014.d.tt #More specific tooltip as reward
		}
		else = {
			custom_tooltip = diplomacy_majesty_special.1014.generic.tt
		}

		stress_impact = {
			zealous = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		hidden_effect = {
			save_scope_value_as = {
				name = tactic
				value = flag:exaggerate
			}

			random_list = {
				3 = { #Success
					trigger = {
						OR = {
							scope:debater = { ai_rationality < 0 }
							scope:debater = { ai_greed < 0 }
							scope:debater = { ai_zeal > 0 }
						}
					}
					modifier = {
						factor = 1.5
						OR = {
							scope:debater = { ai_rationality <= medium_negative_rationality }
							scope:debater = { ai_greed <= medium_negative_greed }
							scope:debater = { ai_zeal >= medium_positive_zeal }
						}
					}
					modifier = {
						factor = 5
						OR = {
							scope:debater = { ai_rationality <= high_negative_rationality }
							scope:debater = { ai_greed <= high_negative_greed }
							scope:debater = { ai_zeal >= high_positive_zeal }
						}
					}
					modifier = {
						factor = 1.2
						exists = scope:preparation_outcome
						scope:preparation_outcome = flag:study_subject_success
					}
					modifier = {
						factor = 0.8
						exists = scope:preparation_outcome
						OR = {
							scope:preparation_outcome = flag:study_subject_failure
							scope:preparation_outcome = flag:study_opponent_failure
						}
					}
					save_scope_value_as = {
						name = debate_outcome
						value = flag:success
					}
				}
				1 = { #Failure
					save_scope_value_as = {
						name = debate_outcome
						value = flag:failure
					}
				}
			}
		}
	}

	after = {
		hidden_effect = {
			#Trigger win or lose event
			if = {
				limit = {
					exists = scope:debate_outcome
					scope:debate_outcome = flag:success
				}
				trigger_event = {
					id = diplomacy_majesty_special.1015
					days = 5
				}
			}
			else = {
				trigger_event = {
					id = diplomacy_majesty_special.1016
					days = 5
				}
			}
		}
	}
}

#Humiliate success
diplomacy_majesty_special.1015 = {
	type = character_event
	title = diplomacy_majesty_special.1010.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:scare
				}
				desc = diplomacy_majesty_special.1015.scare.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:provoke
				}
				desc = diplomacy_majesty_special.1015.provoke.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:exaggerate
				}
				desc = diplomacy_majesty_special.1015.exaggerate.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:low_character
				}
				desc = diplomacy_majesty_special.1015.low_character.desc
			}
		}
	}
	
	theme = diplomacy_majesty_focus
	left_portrait = {
		character = scope:debater
		triggered_animation = {
			trigger = {
				exists = scope:tactic
				scope:tactic = flag:scare
			}
			animation = fear
		}
		triggered_animation = {
			trigger = {
				exists = scope:tactic
				scope:tactic = flag:provoke
			}
			animation = anger
		}
		triggered_animation = {
			trigger = { always = yes }
			animation = idle
		}
	}

	trigger = {
		scope:debater = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		hidden_effect = {
			random = {
				chance = 20
				modifier = {
					reverse_opinion = {
						target = scope:debater
						value < 14 #Because the option deducts 15
					}
					add = 15
				}
				modifier = {
					reverse_opinion = {
						target = scope:debater
						value < 0
					}
					add = 15
				}
				modifier = {
					has_relation_rival = scope:debater
					factor = 0
				}
				add_character_flag = make_enemy
			}
		}
		
	}
	
	option = {
		name = {
			trigger = { ai_compassion < low_positive_compassion }
			text = diplomacy_majesty_special.1015.a.cruel
		}
		name = {
			trigger = { ai_compassion >= low_positive_compassion }
			text = diplomacy_majesty_special.1015.a.compassionate
		}

		add_diplomacy_lifestyle_perk_points = 1
		add_prestige = medium_prestige_gain

		if = {
			limit = {
				exists = scope:tactic
				scope:tactic = flag:scare
			}
			add_dread = minor_dread_gain
		}

		reverse_add_opinion = {
			modifier = cruelty_opinion
			opinion = -20
			target = scope:debater
		}
		if = {
			limit = { has_character_flag = make_enemy }
			scope:debater = {
				set_relation_rival = root
			}
			hidden_effect = { remove_character_flag = make_enemy }
		}

		hidden_effect = { remove_character_flag = is_in_diplomacy_majesty_special_event }
	}
}

#Failure
diplomacy_majesty_special.1016 = {
	type = character_event
	title = diplomacy_majesty_special.1010.t
	desc = {
		desc = diplomacy_majesty_special.1016.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:logic
				}
				desc = diplomacy_majesty_special.1016.logic.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:calm
				}
				desc = diplomacy_majesty_special.1016.calm.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:higher_values
				}
				desc = diplomacy_majesty_special.1016.higher_values.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:listen
				}
				desc = diplomacy_majesty_special.1016.listen.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:scare
				}
				desc = diplomacy_majesty_special.1016.scare.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:provoke
				}
				desc = diplomacy_majesty_special.1016.provoke.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:exaggerate
				}
				desc = diplomacy_majesty_special.1016.exaggerate.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:tactic
					scope:tactic = flag:low_character
				}
				desc = diplomacy_majesty_special.1016.low_character.desc
			}
			desc = diplomacy_majesty_special.1016.end.desc
		}
	}
	
	theme = diplomacy_majesty_focus
	left_portrait = scope:debater

	trigger = {
		scope:debater = {
			is_alive = yes
			is_imprisoned = no
		}
	}
	
	option = {
		name = diplomacy_majesty_special.1016.a

		add_prestige = medium_prestige_loss
		
		hidden_effect = { remove_character_flag = is_in_diplomacy_majesty_special_event }
	}
}

diplomacy_majesty_special.1050 = {
	hidden = yes
	trigger = { has_character_flag = is_in_diplomacy_majesty_special_event } #The event ended for some reason
	immediate = {
		send_interface_message = {
			type = event_diplomacy_neutral
			title = diplomacy_majesty_special.1050.title
			desc = diplomacy_majesty_special.1050.message
			
			left_icon = scope:debater

			hidden_effect = {
				remove_character_flag = is_in_diplomacy_majesty_special_event
			}
		}
	}
}