﻿#Events relating to Rivals

namespace = rivalry


# 0000-0999: Relation status changes
# 1000-1999: Rivals make life miserable for each other
# 2000-2999: General effects of Rivalry on other things
# 3000-3999: Rivalry opinion change events

# 9000-9999: Rivalry competition events


# Your rivals kinda likes you, asks to stop being rivals
# 0001 & 0002
# by Petter Vilberg and Linnéa Thimrén
rivalry.0001 = {
	type = character_event
	title = rivalry.0001.t
	desc = rivalry.0001.desc
	theme = rival_relation
	left_portrait = {
		character = root
		animation = war_over_win
	}
	right_portrait = {
		character = scope:rival
		animation = personality_compassionate
	}

	trigger = {
		any_relation = {
			type = rival
			NOT = { has_relation_nemesis = root }
			is_ai = yes
			opinion = {
				target = root
				value >= 10
			}
			is_ai = yes #The response event is not something a player should get
		}
	}

	immediate = {
		save_scope_as = rival_response
		ordered_relation = {
			type = rival
			limit = {
				NOT = { has_relation_nemesis = root }
				opinion = {
					target = root
					value >= 10
				}
				is_ai = yes
			}
			order_by = "opinion(root)"
			save_scope_as = rival
		}
	}

	option = { #Lose the rivalry
		name = rivalry.0001.a
		show_as_tooltip = {
			remove_relation_rival = scope:rival
		}
		hidden_effect = {
			scope:rival = {
				trigger_event = rivalry.0002
			}
		}
	}

	option = { #Haha, sucker! I want to keep you as a rival
		name = rivalry.0001.b
		scope:rival = {
			add_opinion = {
				target = root
				modifier = hate_opinion
				opinion = -15
			}
		}
	}
}

#Event for Rival
rivalry.0002 = {
	type = character_event
	title = rivalry.0002.t
	desc = rivalry.0002.desc
	theme = rival_relation
	right_portrait = scope:rival_response

	option = {
		name = rivalry.0002.a
		remove_relation_rival = scope:rival_response
	}
}



###Nemesis is no longer challenging###
rivalry.0003 = { #by Mathilda Bjarnehed
	type = character_event
	title = rivalry.0003.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:nemesis = { imprisoner = root } }
				desc = rivalry.0003.my_prisoner.desc
			}
			triggered_desc = {
				trigger = { scope:nemesis = { is_imprisoned = yes } }
				desc = rivalry.0003.imprisoned.desc
			}
			triggered_desc = {
				trigger = { scope:nemesis = { has_trait = incapable } }
				desc = rivalry.0003.incapable.desc
			}
		}
		desc = rivalry.0003.middle.desc
		first_valid = {
			triggered_desc = {
				trigger = { ai_compassion >= medium_positive_ai_value }
				desc = rivalry.0003.compassionate.desc
			}
			desc = rivalry.0003.uncompassionate.desc
		}
	}
		
	theme = rival_relation
	
	left_portrait = scope:nemesis
	
	trigger = {
		NOT = { has_character_flag = event_rivalry_0003_cooldown}
		any_relation = {
			type = nemesis
			is_ai = yes
			OR = {
				has_trait = incapable
				days_in_prison >= 500
				imprisoner = root
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		random_relation = {
			type = nemesis
			limit = {
				is_ai = yes
			}
			save_scope_as = nemesis
		}
		add_character_flag = {
			flag = event_rivalry_0003_cooldown
			years = 10
		}
	}

	#Let it go
	option = {
		name = rivalry.0003.a
		remove_relation_nemesis = scope:nemesis
		set_relation_rival = {
			target = scope:nemesis
			reason = rival_no_longer_nemesis
		}
		
		if = {
			limit = { faith = { trait_is_virtue = forgiving } }
			add_piety = minor_piety_gain
		}

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

		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = vengeful
 					has_trait = sadistic
 					has_trait = callous
 					has_trait = wrathful
 					has_trait = arrogant
 					has_trait = stubborn
				}
				add = -95
			}
		}
	}

	#Keep them
	option = {
		name = rivalry.0003.b
		
		hidden_effect = {
			add_opinion = {
				modifier = hate_opinion
				target = scope:nemesis
				opinion = -15
			}
		}

		reverse_add_opinion = {
			modifier = hate_opinion
			target = scope:nemesis
			opinion = -15
		}

		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 10
		}
	}
}

#Rival adds stress
#Rivalry.1001
# by Petter Vilberg
rivalry.1001 = {
	type = character_event
	title = rivalry.1001.t
	desc = {
		desc = rivalry.1001.desc.opening
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_malicious_trigger = yes
						}
					}
					desc = rivalry.1001.malicious
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_benevolent_trigger = yes
						}
					}
					desc = rivalry.1001.benevolent
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_dominant_trigger = yes
						}
					}
					desc = rivalry.1001.dominant
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_submissive_trigger = yes
						}
					}
					desc = rivalry.1001.submissive
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_extroverted_trigger = yes
						}
					}
					desc = rivalry.1001.extroverted
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_introverted_trigger = yes
						}
					}
					desc = rivalry.1001.introverted
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_emotional_trigger = yes
						}
					}
					desc = rivalry.1001.emotional
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_levelheaded_trigger = yes
						}
					}
					desc = rivalry.1001.levelheaded
				}
			}
			desc = rivalry.1001.desc.fallback
		}
	}	
	theme = rival_relation
	left_portrait = {
		character = scope:rival
		animation = schadenfreude
	}
	
	cooldown = { years = 5 }

	trigger = {
		is_available_adult = yes
		any_relation = {
			type = rival
			is_available_adult = yes
		}
	}

	immediate = {
		random_relation = {
			type = rival
			limit = { is_available_adult = yes }
			save_scope_as = rival
		}
	}

	option = {
		name = rivalry.1001.a
		stress_impact = {
			base = medium_stress_gain
		}
	}
}

##################################################
# Spiteful Acts
# by Sean Hughes
# 1010-1025
##################################################

#I decide that my rival's aggravating behavior has gone on long enough!
rivalry.1010 = {
	type = character_event
	title = rivalry.1010.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = patient
				}
				desc = rivalry.1010.desc.patient
			}
			desc = rivalry.1010.desc
		}
		desc = rivalry.1010.desc.end
	}
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = rage
	}
	right_portrait = {
		character = scope:rival
		animation = schadenfreude
	}

	trigger = {
		is_adult = yes

		any_relation = {
			type = rival
			is_available_healthy_adult = yes
		}

		NOT = {
			has_character_flag = had_event_rivalry_1010
		}
	}

	immediate = {
		save_scope_as = from_rival
		add_character_flag = {
			flag = had_event_rivalry_1010
			years = 5
		}

		random_relation = {
			type = rival
			limit = {
				is_available_healthy_adult = yes
			}
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
			save_scope_as = rival
		}
	}

	option = {
		name = rivalry.1010.a
		duel = {
			skill = intrigue
			target = scope:rival

			15 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -14
				}
				scope:rival = {
					trigger_event = rivalry.1011 #The rumors take off.
				}
				custom_tooltip = rivalry.1010.a.success.tt
			}
			20 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.25
					min = -19
				}
				trigger_event = rivalry.1014 #The rumors are seen as unbelievable.
				custom_tooltip = rivalry.1010.a.failure.tt
			}
			10 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.75
					min = -9
				}
				add_character_flag = {
					flag = rivalry_1010_exposed
					days = 15
				}
				scope:rival = {
					trigger_event = rivalry.1012 #The rumors are seen as unbelievable, and everyone knows I made them up!
				}
				custom_tooltip = rivalry.1010.a.failure.tt
				custom_tooltip = rivalry.1010.a.badfailure.tt
			}
		}
		ai_chance = {
			base = 100

			modifier = {
				diplomacy >= intrigue
				add = 100
			}

			ai_value_modifier = {
				ai_honor = -1
				ai_boldness = 0.5
			}
		}
	}

	option = {
		name = rivalry.1010.b
		add_character_flag = {
			flag = rivalry_1010_wrote_poem
			days = 15
		}
		duel = {
			skill = diplomacy
			target = scope:rival

			13 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.25
					min = -14
				}
				scope:rival = {
					trigger_event = rivalry.1011 #The poem is a success!
				}				
				custom_tooltip = rivalry.1010.b.success.tt
			}
			20 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.25
				}
				trigger_event = rivalry.1016 #The poem is seen as drivel.
				custom_tooltip = rivalry.1010.b.failure.tt
			}
			8 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.75
					min = -7
				}
				add_character_flag = {
					flag = rivalry_1010_exposed
					days = 15
				}
				scope:rival = {
					trigger_event = rivalry.1012 #The poem is seen as drivel, and everyone knows I wrote it!
				}
				custom_tooltip = rivalry.1010.b.failure.tt
				custom_tooltip = rivalry.1010.b.badfailure.tt
			}
		}
		ai_chance = {
			base = 100

			modifier = {
				intrigue >= diplomacy
				add = 100
			}

			ai_value_modifier = {
				ai_honor = -1
				ai_boldness = 0.5
			}
		}
	}

	option = {
		name = rivalry.1010.c
		scope:rival = {
			trigger_event = rivalry.1017 #My rival reacts directly to my insult!
		}
		custom_tooltip = rivlary.1010.c.tt

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_boldness = 2
				ai_energy = 0.5
			}
		}
	}
}

#My rival learns that I am successful in defaming them!
rivalry.1011 = {
	type = character_event
	title = rivalry.1011.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:from_rival = {
						has_character_flag = rivalry_1010_wrote_poem
					}
				}
				desc = rivalry.1011.desc.poem
			}
			desc = rivalry.1011.desc.rumors
		}
	}
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = rage
	}
	right_portrait = {
		character = scope:from_rival
		animation = schadenfreude
	}

	immediate = {
		get_quirk_character_effect = yes
		add_prestige = medium_prestige_loss
	}

	option = {
		name = rivalry.1011.a
		scope:from_rival = {
			if = {
				limit = {
					has_character_flag = rivalry_1010_wrote_poem
				}
				trigger_event = { id = rivalry.1015 }
			}
			else = {
				trigger_event = { id = rivalry.1013 }
			}
		}
	}
}

#Informational event telling my rival that I have failed miserably in my attempt to defame them!
rivalry.1012 = {
	type = character_event
	title = rivalry.1012.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:from_rival = {
						has_character_flag = rivalry_1010_wrote_poem
					}
				}
				desc = rivalry.1012.desc.poem
			}
			desc = rivalry.1012.desc.rumors
		}
	}
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:from_rival
		animation = stress
	}

	immediate = {
		get_quirk_character_effect = yes
	}

	option = {
		name = rivalry.1012.a
		scope:from_rival = {
			if = {
				limit = {
					has_character_flag = rivalry_1010_wrote_poem
				}
				trigger_event = { id = rivalry.1016 }
			}
			else = {
				trigger_event = { id = rivalry.1014 }
			}

			show_as_tooltip = {
				add_prestige = medium_prestige_loss
			}

		}
	}
}

#Informational event telling me that my rival has lost prestige as a result of the scandalous rumors.
rivalry.1013 = {
	type = character_event
	title = rivalry.1013.t
	desc = rivalry.1013.desc
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = personality_vengeful
	}
	right_portrait = {
		character = scope:rival
		animation = stress
	}

	immediate = {
		scope:rival = {
			show_as_tooltip = {
				add_prestige = medium_prestige_loss
			}
		}
	}

	option = {
		name = rivalry.1013.a
	}
}

#The rumors I tried to spread are not believed by the court.
rivalry.1014 = {
	type = character_event
	title = rivalry.1014.t
	desc = {
		desc = rivalry.1014.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = rivalry_1010_exposed }
				desc = rivalry.1014.desc.exposed
			}
			desc = rivalry.1014.desc.hidden
		}
		desc = rivalry.1014.desc.end

	}
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:rival
		animation = personality_vengeful
	}

	option = {
		name = rivalry.1014.a
	}

	option = {
		name = rivalry.1014.a.exposed
		trigger = { #I've bungled my attempt to spread rumors so badly that I have lost prestige as a result!
			has_character_flag = rivalry_1010_exposed
		}
		exclusive = yes
		add_prestige = medium_prestige_loss
	}
}

#Informational event telling me that my rival has lost prestige due to the mocking poem I wrote about them.
rivalry.1015 = {
	type = character_event
	title = rivalry.1015.t
	desc = rivalry.1015.desc
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:rival
		animation = stress
	}

	immediate = {
		scope:rival = {
			show_as_tooltip = {
				add_prestige = medium_prestige_loss
			}
		}
	}

	option = {
		name = rivalry.1015.a
	}
}

#My mocking poem of my rival is poorly-written.
rivalry.1016 = {
	type = character_event
	title = rivalry.1016.t
	desc = {
		desc = rivalry.1016.desc
		triggered_desc = {
			trigger = { has_character_flag = rivalry_1010_exposed }
			desc = rivalry.1016.desc.exposed
		}
	}
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:rival
		animation = schadenfreude
	}

	option = {
		name = rivalry.1016.a
	}

	option = {
		name = rivalry.1016.a.exposed
		trigger = { #My mocking poem is so bad that I get mocked instead!
			has_character_flag = rivalry_1010_exposed
		}
		exclusive = yes
		add_prestige = medium_prestige_loss
	}
}

#I go up to my rival and tell them what I think about them to their face!
rivalry.1017 = {
	type = character_event
	title = rivalry.1017.t
	desc = rivalry.1017.desc
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:from_rival
		animation = anger
	}

	immediate = {
		get_quirk_character_effect = yes
	}

	#Rival responds with insults
	option = {
		name = rivalry.1017.a
		add_prestige = medium_prestige_loss
		add_opinion = {
			target = scope:from_rival
			modifier = angry_opinion
			opinion = -20
		}
		scope:from_rival = {
			show_as_tooltip = {
				add_prestige = medium_prestige_loss
				add_opinion = {
					target = root
					modifier = angry_opinion
					opinion = -20
				}
			}
			trigger_event = rivalry.1018
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -0.5
				ai_boldness = 0.5
				ai_vengefulness = 1
			}
		}

	}

	#Rival challenges me to a duel!
	option = {
		name = rivalry.1017.b
		scope:from_rival = {
			trigger_event = rivalry.1020
		}

		show_as_tooltip = {
			duel = {
				skill = prowess
				target = scope:from_rival

				8 = { #Triumphant victory 		
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.5
						min = -7
					}
					desc = rivalry.1021.tt
					show_as_tooltip = {
						add_prestige = major_prestige_gain
						scope:from_rival = {
							add_prestige = major_prestige_loss
							increase_wounds_effect = { REASON = fight }
						}
					}
				}
				15 = { #Narrow victory 		
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.25
						min = -14
					}
					desc = rivalry.1022.tt
					show_as_tooltip = {
						add_prestige = medium_prestige_gain
						scope:from_rival = {
							add_prestige = medium_prestige_loss
						}
					}
				}
				15 = { #Narrow defeat 		
					compare_modifier = {
						value = scope:duel_value
						multiplier = -0.25
						min = -14
					}
					desc = rivalry.1023.tt
					show_as_tooltip = {
						add_prestige = medium_prestige_loss
						scope:from_rival = {
							add_prestige = medium_prestige_gain
						}
					}
				}
				8 = { #Humiliating defeat! 		
					compare_modifier = {
						value = scope:duel_value
						multiplier = -0.5
					}
					desc = rivalry.1024.tt
					show_as_tooltip = {
						add_prestige = major_prestige_loss
						increase_wounds_effect = { REASON = fight }
						scope:from_rival = {
							add_prestige = major_prestige_gain
						}
					}
				}
			}
		}

		stress_impact = {
			craven = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 2
				ai_boldness = 2
				ai_energy = 1
				ai_vengefulness = 1
			}

			#AI shouldn't challenge me to a duel if their prowess is 0!
			modifier = {
				factor = 0
				prowess = 0
			}
		}
	}

	#Rival turns the other cheek.
	option = {
		name = rivalry.1017.c
		add_prestige = medium_prestige_loss
		add_piety = minor_piety_gain
		scope:from_rival = {
			trigger_event = rivalry.1019
		}

		show_as_tooltip = {
			add_opinion = {
					target = scope:from_rival
				modifier = insult_opinion
				opinion = -20
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
				ai_honor = -0.5

				ai_boldness = -1.5
				ai_vengefulness = -2
			}
		}
	}
}

#Rival responds with insults.
rivalry.1018 = {
	type = character_event
	title = rivalry.1018.t
	desc = rivalry.1018.desc
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:rival
		animation = anger
	}

	immediate = {
		add_prestige = medium_prestige_loss
		add_opinion = {
			target = scope:rival
			modifier = angry_opinion
			opinion = -20
		}
		scope:rival = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
			show_as_tooltip = {
				add_prestige = medium_prestige_loss
				add_opinion = {
					target = root
					modifier = angry_opinion
					opinion = -20
				}
			}	
		}
	}

	option = {
		name = rivalry.1018.a
	}
}

#Rival sits there and takes the abuse.
rivalry.1019 = {
	type = character_event
	title = rivalry.1019.t
	desc = rivalry.1019.desc
	theme = rival_relation
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:rival
		animation = dismissal
	}

	immediate = {
		scope:rival = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
			show_as_tooltip = {
				add_prestige = medium_prestige_loss
				add_opinion = {
					target = root
					modifier = insult_opinion
					opinion = -20
				}
			}	
		}
	}

	option = {
		name = rivalry.1019.a
	}
}

#Rival challenges me to a duel!
rivalry.1020 = {
	type = character_event
	title = rivalry.1020.t
	desc = rivalry.1020.desc
	theme = rival_relation
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:rival
		animation = rage
	}

	immediate = {
		scope:rival = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
	}

	#I accept the challenge!
	option = {
		name = rivalry.1020.a

		duel = {
			skill = prowess
			target = scope:rival

			8 = { #Triumphant victory 		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -7
				}
				desc = rivalry.1021.tt
				show_as_tooltip = {
					add_prestige = major_prestige_gain
					scope:rival = {
						add_prestige = major_prestige_loss
						increase_wounds_effect = { REASON = fight }
					}
				}
				trigger_event = rivalry.1021
			}
			15 = { #Narrow victory 		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.25
					min = -14
				}
				desc = rivalry.1022.tt
				show_as_tooltip = {
					add_prestige = medium_prestige_gain
					scope:rival = {
						add_prestige = medium_prestige_loss
					}
				}
				trigger_event = rivalry.1022
			}
			15 = { #Narrow defeat 		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.25
					min = -14
				}
				desc = rivalry.1023.tt
				show_as_tooltip = {
					add_prestige = medium_prestige_loss
					scope:rival = {
						add_prestige = medium_prestige_gain
					}
				}
				scope:rival = {
					trigger_event = rivalry.1022
				}
			}
			8 = { #Humiliating defeat! 		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
					min = -7
				}
				desc = rivalry.1024.tt
				show_as_tooltip = {
					add_prestige = major_prestige_loss
					increase_wounds_effect = { REASON = fight }
					scope:rival = {
						add_prestige = major_prestige_gain
					}
				}
				scope:rival = {
					trigger_event = rivalry.1021
				}
			}
		}

		stress_impact = {
			craven = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 2
				ai_boldness = 2
			}

 			#AI shouldn't accept a duel if their prowess is 0!
			modifier = {
				factor = 0
				prowess = 0
			}
		}
	}

	#I back down from my rival's challenge and lose face as a result.
	option = {
		name = rivalry.1020.b
		add_prestige = medium_prestige_loss
		scope:rival = {
			add_prestige = minor_prestige_gain
			trigger_event = rivalry.1025
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -2
				ai_boldness = -2
			}
		}

		stress_impact = {
			brave = medium_stress_impact_gain
		}

	}
}

#I win decisively over my opponent!
rivalry.1021 = {
	type = character_event
	title = rivalry.1021.t
	desc = rivalry.1021.desc
	theme = rival_relation
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:duel_loser
		animation = shock
	}

	immediate = {
		if = {
			limit = {
				root = scope:from_rival
			}
			scope:rival = {
				save_scope_as = duel_loser
			}
		}
		else = {
			scope:from_rival = {
				save_scope_as = duel_loser
			}
		}
		set_signature_weapon_effect = yes
		add_prestige = major_prestige_gain
		scope:duel_loser = {
			show_as_tooltip = {
				add_prestige = major_prestige_loss
				increase_wounds_effect = { REASON = fight }
			}
		}
	}

	option = {
		name = rivalry.1021.a
		scope:duel_loser = {
			trigger_event = {
					id = rivalry.1024
			}
		}
	}
}

#I win narrowly over my opponent.
rivalry.1022 = {
	type = character_event
	title = rivalry.1022.t
	desc = rivalry.1022.desc
	theme = rival_relation
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:duel_loser
		animation = shock
	}

	immediate = {
		if = {
			limit = {
				root = scope:from_rival
			}
			scope:rival = {
				save_scope_as = duel_loser
			}
		}
		else = {
			scope:from_rival = {
				save_scope_as = duel_loser
			}
		}
		set_signature_weapon_effect = yes
		add_prestige = medium_prestige_gain
		scope:duel_loser = {
			show_as_tooltip = {
				add_prestige = medium_prestige_loss
			}
		}
	}

	option = {
		name = rivalry.1022.a
		scope:duel_loser = {
			trigger_event = {
				id = rivalry.1023
			}
		}
	}
}

#I lose narrowly to my opponent.
rivalry.1023 = {
	type = character_event
	title = rivalry.1023.t
	desc = {
		desc = rivalry.1023.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = wounded_3
				}
				desc = rivalry.1023.desc.death
			}
			desc = rivalry.1023.desc.end

		}
	}
	theme = rival_relation
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:duel_winner
		animation = anger
	}

	immediate = {
		if = {
			limit = {
				root = scope:from_rival
			}
			scope:rival = {
				save_scope_as = duel_winner
			}
		}
		else = {
			scope:from_rival = {
				save_scope_as = duel_winner
			}
		}
		set_signature_weapon_effect = yes
		add_prestige = medium_prestige_loss
		scope:duel_winner = {
			show_as_tooltip = {
				add_prestige = medium_prestige_gain
			}
		}
	}

	option = {
		name = rivalry.1023.a
	}

	option = {
		trigger = {
			has_trait = wounded_3
		}
		exclusive = yes
		name = rivalry.1023.a.death
	}
}

#I lose decisively to my opponent!
rivalry.1024 = {
	type = character_event
	title = rivalry.1024.t
	desc = {
		desc = rivalry.1024.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = wounded_3
				}
				desc = rivalry.1024.desc.death
			}
			desc = rivalry.1024.desc.end

		}
	}
	theme = rival_relation
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:duel_winner
		animation = anger
	}

	immediate = {
		if = {
			limit = {
				root = scope:from_rival
			}
			scope:rival = {
				save_scope_as = duel_winner
			}
		}
		else = {
			scope:from_rival = {
				save_scope_as = duel_winner
			}
		}
		set_signature_weapon_effect = yes
		add_prestige = major_prestige_loss
		increase_wounds_effect = { REASON = fight }

		scope:duel_winner = {
			show_as_tooltip = {
				add_prestige = major_prestige_gain
			}
		}
	}

	option = {
		name = rivalry.1024.a
	}

	option = {
		trigger = {
			has_trait = wounded_3
		}
		exclusive = yes
		name = rivalry.1023.a.death
	}
}

#Informational event telling my rival that I refused to duel them.
rivalry.1025 = {
	type = character_event
	title = rivalry.1025.t
	desc = rivalry.1025.desc
	theme = rival_relation
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = dismissal
	}
	right_portrait = {
		character = scope:from_rival
		animation = anger
	}

	immediate = {
		show_as_tooltip = {
			add_prestige = minor_prestige_gain
			scope:from_rival = {
				add_prestige = medium_prestige_loss
			}
		}
	}

	option = {
		name = rivalry.1025.a
	}
}


##################################################
# Meddling in Marriage
# by Sean Hughes
# 1030-1028
##################################################

rivalry.1030 = {
	type = character_event
	title = rivalry.1030.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:rival = {
						opinion = {
							target = scope:rival_spouse
							value >= 20
						}
						reverse_opinion = {
							target = scope:rival_spouse
							value >= 20
						}
					}
				}
				desc = rivalry.1030.desc.happy
			}
			triggered_desc = {
				trigger = {
					scope:rival = {
						OR = {
							opinion = {
								target = scope:rival_spouse
								value <= -20
							}
							reverse_opinion = {
								target = scope:rival_spouse
								value <= -20
							}
						}
					}
				}
				desc = rivalry.1030.desc.unhappy
			}
			desc = rivalry.1030.desc.neutral
		}
	}
	theme = rival_relation
	
	left_portrait = {
		character = scope:rival
		triggered_animation = {
			trigger = {
				scope:rival = {
					opinion = {
						target = scope:rival_spouse
						value >= 20
					}
					reverse_opinion = {
						target = scope:rival_spouse
						value >= 20
					}
				}
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				scope:rival = {
					OR = {
						opinion = {
							target = scope:rival_spouse
							value <= -20
						}
						reverse_opinion = {
							target = scope:rival_spouse
							value <= -20
						}
					}
				}
			}
			animation = dismissal
		}
		triggered_animation = {
			trigger = {
				scope:rival = {
					NOR = {
						OR = {
							opinion = {
								target = scope:rival_spouse
								value <= -20
							}
							reverse_opinion = {
								target = scope:rival_spouse
								value <= -20
							}
						}
						AND = {
							opinion = {
								target = scope:rival_spouse
								value >= 20
							}
							reverse_opinion = {
								target = scope:rival_spouse
								value >= 20
							}
						}
					}
				}
			}
			animation = personality_dishonorable
		}
	}
	
	right_portrait = {
		character = scope:rival_spouse
		triggered_animation = {
			trigger = {
				scope:rival = {
					opinion = {
						target = scope:rival_spouse
						value >= 20
					}
					reverse_opinion = {
						target = scope:rival_spouse
						value >= 20
					}
				}
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				scope:rival = {
					OR = {
						opinion = {
							target = scope:rival_spouse
							value <= -20
						}
						reverse_opinion = {
							target = scope:rival_spouse
							value <= -20
						}
					}
				}
			}
			animation = boredom
		}
		triggered_animation = {
			trigger = {
				scope:rival = {
					NOR = {
						OR = {
							opinion = {
								target = scope:rival_spouse
								value <= -20
							}
							reverse_opinion = {
								target = scope:rival_spouse
								value <= -20
							}
						}
						AND = {
							opinion = {
								target = scope:rival_spouse
								value >= 20
							}
							reverse_opinion = {
								target = scope:rival_spouse
								value >= 20
							}
						}
					}
				}
			}
			animation = disapproval
		}
	}

	trigger = {
		any_relation = {
			type = rival
			is_available_healthy_adult = yes
			is_married = yes
			any_spouse = {
				is_available_healthy_adult = yes
				this != root
			}
		}

		NOT = {
			has_character_flag = had_event_rivalry_1030
		}
	}

	immediate = {
		root = {
			save_scope_as = instigator
			add_character_flag = {
				flag = had_event_rivalry_1030
				years = 5
			}
		}

		random_relation = {
			type = rival
			limit = {
				is_available_healthy_adult = yes
				is_married = yes
			}
			save_scope_as = rival
			scope:rival = {
				random_spouse = {
					limit = {
						is_available_healthy_adult = yes
						this != root
					}
					save_scope_as = rival_spouse
				}
			}
		}
	}

	#Frame your rival's spouse as the adulterer!
	option = {
		name = rivalry.1030.a

		flavor = rivalry.1030.a.tt
		duel = {
			skill = intrigue
			target = scope:rival


			13 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -12
				}
				custom_tooltip = rivalry.1030.a_success
				scope:rival = {
					add_character_flag = rivalry_1030_suspicious
				}
			}
			18 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
					min = -17
				}
				custom_tooltip = rivalry.1030.a_failure
			}
		}
		scope:rival = {
			trigger_event = rivalry.1031
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -2
				ai_vengefulness = 1
				ai_boldness = 0.5
			}
		}

		stress_impact = {
			just = medium_stress_gain
			honest = minor_stress_gain
		}
	}

	#Frame your rival as the adulterer!
	option = {
		name = rivalry.1030.b

		flavor = rivalry.1030.b.tt
		duel = {
			skill = intrigue
			target = scope:rival_spouse

			13 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -12
				}
				custom_tooltip = rivalry.1030.a_success
				scope:rival_spouse = {
					add_character_flag = rivalry_1030_suspicious
				}
			}
			18 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
					min = -17
				}
				custom_tooltip = rivalry.1030.a_failure
				#No effect
			}
		}
		scope:rival_spouse = {
			trigger_event = rivalry.1031
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -2
				ai_vengefulness = 1
				ai_boldness = 0.5
			}
		}

		stress_impact = {
			just = medium_stress_gain
			honest = minor_stress_gain
		}

	}

	#Decide not to interfere with your rival's marriage.
	option = {
		name = rivalry.1030.c
		flavor = rivalry.1030.c.tt

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_zeal = 1
				ai_vengefulness = -1
				ai_boldness = -0.5
			}
		}

		stress_impact = {
			deceitful = medium_stress_gain
		}
	}
}

rivalry.1031 = {
	type = character_event
	title = rivalry.1031.t
	desc = {
		desc = rivalry.1031.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = rivalry_1030_suspicious
				}
				desc = rivalry.1031.desc.suspicious
			}
			desc = rivalry.1031.desc.fooled
		}
	}
	theme = rival_relation
	left_portrait = scope:my_spouse

	trigger = {
		scope:rival_spouse = { is_alive = yes }
		scope:rival = { is_alive = yes }
	}

	immediate = {
		if = {
			limit = {
				root = scope:rival
			}
			scope:rival_spouse = {
				save_scope_as = my_spouse
			}
			scope:rival = {
				save_scope_as = suspicious_spouse
			}
		}
		else = {
			scope:rival = {
				save_scope_as = my_spouse
			}
			scope:rival_spouse = {
				save_scope_as = suspicious_spouse
			}
		}
	}

	#Rival investigates the love letter's origins.
	option = {
		name = {
			text = rivalry.1031.a.fooled
		}
		name = {
			trigger = {
				has_character_flag = rivalry_1030_suspicious
			}
			text = rivalry.1031.a.suspicious
		}
		add_opinion = {
			target = scope:my_spouse
			modifier = suspicion_opinion
			opinion = -10
		}

		#Rival also attempts to learn who sent the letter.
		hidden_effect = {
			duel = {
				skill = intrigue
				target = scope:instigator

				#Rival learns where the letter actually came from.
				15 = {		
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.5
						min = -14
					}
					trigger_event = rivalry.1035
				}
				#Rival fails to discover where the letter came from.
				15 = {		
					compare_modifier = {
						value = scope:duel_value
						multiplier = -0.5
						min = -14
					}
					trigger_event = rivalry.1036
				}

			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
				ai_compassion = -1
				ai_vengefulness = 0.5
			}
		}

		stress_impact = {
			eccentric = medium_stress_gain
			trusting = medium_stress_gain
		}
	}

	#Rival confronts their spouse about the letter.
	option = {
		name = {
			text = rivalry.1031.b.fooled
		}
		name = {
			trigger = {
				has_character_flag = rivalry_1030_suspicious
			}
			text = rivalry.1031.b.suspicious
		}

		add_opinion = {
			target = scope:my_spouse
			modifier = suspicion_opinion
			opinion = -10
		}
		custom_tooltip = rivalry.1031.b.tt

		scope:my_spouse = {
			trigger_event = rivalry.1032
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -1
				ai_compassion = -1
				ai_vengefulness = 0.5
				ai_boldness = 1
			}
		}

		stress_impact = {
			trusting = medium_stress_gain
		}

	}

	#Rival believes their spouse is innocent.
	option = {
		name = rivalry.1031.c

		custom_tooltip = rivalry.1031.c.tt

		scope:instigator = {
			#Instigator is informed that their plan failed, but that there were no consequences.
			trigger_event = rivalry.1038
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
				ai_compassion = 1
				ai_vengefulness = -0.5
			}
		}

		stress_impact = {
			paranoid = medium_stress_gain
			eccentric = medium_stress_gain
		}
	}

	#This flag is only used for altering this specific event's text, so we can remove it now.
	after = {
		hidden_effect = {
			remove_character_flag = rivalry_1030_suspicious
		}
	}
}

#Rival's spouse is confronted by them about the letter.
rivalry.1032 = {
	type = character_event
	title = rivalry.1032.t
	desc = rivalry.1032.desc
	theme = rival_relation
	left_portrait = {
		character = scope:suspicious_spouse
		animation = anger
	}
	right_portrait = scope:spouse_lover

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

	immediate = {
		#Check if spouse actually has a secret lover which their spouse doesn't already know about.
		#If they do, save the secret and secret target for their possible confession.
		if = {
			limit = {
				any_secret = {
					type = secret_lover
					NOT = {
						any_secret_knower = {
							this = scope:suspicious_spouse
						}
					}
				}
			}
			random_secret = {
				type = secret_lover
				limit = {
					NOT = {
						any_secret_knower = {
							this = scope:suspicious_spouse
						}
					}
				}
				save_scope_as = affair
			}

			scope:affair = {
				secret_target = {
					save_scope_as = spouse_lover
				}
			}
		}
	}

	#Deny having an affair.
	option = {
		name = rivalry.1032.a

		custom_tooltip = rivalry.1032.a.tt

		#Tells partner they're innocent!
		scope:suspicious_spouse = {
			trigger_event = rivalry.1033
		}

		add_opinion = {
			target = scope:suspicious_spouse
			modifier = angry_opinion
			opinion = -10
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -2
				ai_compassion = -1
			}
		}

	}

	#Spouse confesses to having a secret lover.
	option = {
		name = rivalry.1032.b

		trigger = {
			any_secret = {
				type = secret_lover
				NOT = {
					any_secret_knower = {
						this = scope:suspicious_spouse
					}
				}
			}
		}

		scope:suspicious_spouse = {
			trigger_event = rivalry.1034
			scope:affair = {
				show_as_tooltip = {
					reveal_to = scope:suspicious_spouse
				}
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 2
				ai_compassion = 1
			}
		}
	}
}

#Rival hears that their spouse maintains that they are innocent!
rivalry.1033 = {
	type = character_event
	title = rivalry.1033.t
	desc = rivalry.1033.desc
	theme = rival_relation
	left_portrait = {
		character = scope:my_spouse
		animation = shock
	}

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

	#Rival trusts that their spouse is telling the truth.
	option = {
		name = rivalry.1033.a

		custom_tooltip = rivalry.1033.a.tt

		#Rival accepts that their initial suspicions were misguided.
		remove_opinion = {
			target = scope:my_spouse
			modifier = suspicion_opinion
			single = yes
		}

		#Instigator is informed that their plans failed, but they don't suffer any ill effects.
		scope:instigator = {
			trigger_event = rivalry.1038
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 2
				ai_vengefulness = -2
			}
		}

		stress_impact = {
			paranoid = medium_stress_gain
		}

	}

	#Rival still believes their spouse is cheating on them, will investigate.
	option = {
		name = rivalry.1033.b

		#Spouses' denial makes rival even more suspicious.
		add_opinion = {
			target = scope:my_spouse
			modifier = suspicion_opinion
			opinion = -10
		}

		#Rival attempts to learn who sent the letter.
		hidden_effect = {
			duel = {
				skill = intrigue
				target = scope:instigator

				#Rival learns where the letter actually came from.
				15 = {		
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.5
						min = -14
					}
					trigger_event = rivalry.1035
				}
				#Rival fails to discover where the letter came from.
				15 = {		
					compare_modifier = {
						value = scope:duel_value
						multiplier = -0.5
						min = -14
					}
					trigger_event = rivalry.1036
				}

			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -2
				ai_vengefulness = 2
			}
		}

		stress_impact = {
			trusting = medium_stress_gain
		}

	}
}

#Rival hears that their spouse confesses to adultery!
rivalry.1034 = {
	type = character_event
	title = rivalry.1034.t
	desc = rivalry.1034.desc
	theme = rival_relation
	left_portrait = {
		character = scope:my_spouse
		animation = stress
	}
	right_portrait = scope:secret_lover

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

	immediate = {
		#Reveal spouses' secret lover to the accuser.
		scope:affair = {
			reveal_to = scope:my_spouse
		}
	}

	option = {
		name = rivalry.1034.a

		hidden_effect = {
			#Relationship penalty for learning their spouse cheated.
			add_opinion = {
				target = scope:my_spouse
				modifier = trust_opinion
				opinion = -30
			}
		}

		#Instigator is informed that their plans succeeded!
		scope:instigator = {
			trigger_event = rivalry.1039
		}

	}
}

#Rival learns the instigator forged the letter, and hates them for it!
rivalry.1035 = {
	type = character_event
	title = rivalry.1035.t
	desc = rivalry.1035.desc
	theme = rival_relation
	left_portrait = {
		character = scope:my_spouse
		animation = stress
	}
	right_portrait = {
		character = scope:instigator
		animation = schadenfreude
	}

	option = {
		name = rivalry.1035.a

		if = {
			limit = {
				scope:instigator = { is_alive = yes }
			}
			#Rival and their spouse hate the instigator for attempting to sabotage their marriage.
			add_opinion = {
				target = scope:instigator
				modifier = hate_opinion
				opinion = -30
			}
			scope:my_spouse = {
				add_opinion = {
					target = scope:instigator
					modifier = hate_opinion
					opinion = -30
				}
			}

			#Instigator is informed that their plans failed and that their rival knows they were responsible for it.
			scope:instigator = {
				add_character_flag = rivalry_1030_exposed

				trigger_event = rivalry.1038
			}
		}
	}
}

#Rival cannot determine where the letter came from.
rivalry.1036 = {
	type = character_event
	title = rivalry.1036.t
	desc = rivalry.1036.desc
	theme = rival_relation
	left_portrait = {
		character = scope:my_spouse
		animation = worry
	}

	#Rival still believes their spouse is cheating on them.
	option = {
		name = rivalry.1036.a

		if = {
			limit = {
				scope:my_spouse = { is_alive = yes }
			}
			#Spouses' denial makes rival even more suspicious.
			add_opinion = {
				target = scope:my_spouse
				modifier = suspicion_opinion
				opinion = -10
			}
		}
		if = {
			limit = {
				scope:instigator = { is_alive = yes }
			}
			#Instigator is informed that their plans succeeded!
			scope:instigator = {
				trigger_event = rivalry.1037
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -2
				ai_vengefulness = 2
			}
		}
	}

	#Rival comes to the conclusion that the letter was a forgery.
	option = {
		name = rivalry.1036.b

		custom_tooltip = rivalry.1031.c.tt

		if = {
			limit = {
				scope:my_spouse = { is_alive = yes }
			}
			#Rival accepts that their initial suspicions were misguided.
			remove_opinion = {
				target = scope:my_spouse
				modifier = suspicion_opinion
				single = yes
			}
		}
		if = {
			limit = {
				scope:instigator = { is_alive = yes }
			}
			#Instigator is informed that their plans failed, but they don't suffer any ill effects.
			scope:instigator = {
				trigger_event = rivalry.1038
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 2
				ai_vengefulness = -2
			}
		}
	}
}

#Instigator's plans succeeded! Gain benefit
rivalry.1037 = {
	type = character_event
	title = rivalry.1037.t
	desc = rivalry.1037.desc
	theme = rival_relation
	
	left_portrait = {
		character = scope:rival
		animation = rage
	}
	
	right_portrait = {
		character = scope:rival_spouse
		animation = worry
	}

	trigger = {
		scope:rival = { is_alive = yes }
		scope:rival_spouse = { is_alive = yes }
	}

	option = {
		name = rivalry.1037.a
		add_prestige = medium_prestige_gain
		add_stress = medium_stress_loss
	}
}

#Instigator's plans failed! possible opinion consequences.
rivalry.1038 = {
	type = character_event
	title = rivalry.1038.t
	desc = rivalry.1038.desc
	theme = rival_relation
	left_portrait = {
		character = scope:rival
		animation = worry
	}
	
	right_portrait = {
		character = scope:rival_spouse
		animation = paranoia
	}

	trigger = {
		scope:rival = { is_alive = yes }
		scope:rival_spouse = { is_alive = yes }
	}

	immediate = {
		if = {
			limit = {
				has_character_flag = rivalry_1030_exposed
			}
			remove_character_flag = rivalry_1030_exposed
			show_as_tooltip = {
				reverse_add_opinion = {
					target = scope:rival
					modifier = hate_opinion
					opinion = -30
				}
				reverse_add_opinion = {
					target = scope:rival_spouse
					modifier = hate_opinion
					opinion = -30
				}
			}
		}
	}

	option = {
		name = rivalry.1038.a
	}
}

#Instigator's plans succeeded! Learn secret
rivalry.1039 = {
	type = character_event
	title = rivalry.1039.t
	desc = rivalry.1039.desc
	theme = rival_relation
	left_portrait = scope:rival
	right_portrait = scope:rival_spouse

	trigger = {
		scope:rival = { is_alive = yes }
		scope:rival_spouse = { is_alive = yes }
	}

	immediate = {
		if = {
			limit = {
				exists = scope:affair
				scope:affair = {
					NOT = {
						any_secret_knower = {
							this = root
						}
					}
				}
			}
			scope:affair = {
				reveal_to = root
			}
		}
	}

	option = {
		name = rivalry.1039.a
		add_prestige = medium_prestige_gain
		add_stress = medium_stress_loss
	}
}


#Hinder the progress of rival's Befriend scheme
#Rivalry.2001, 2002
# by Petter Vilberg

scripted_trigger rivalry_2001_scheme_trigger = {
	scheme_type = befriend
	scheme_target_character = {
		this != root
	}
}

rivalry.2001 = {
	type = character_event
	title = rivalry.2001.t
	desc = rivalry.2001.desc
	theme = rival_relation
	override_background = { reference = corridor_day }
	left_portrait = {
		character = scope:rival
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:target_in_question
		animation = personality_rational
	}
	
	cooldown = { years = 3 }

	trigger = {
		any_relation = {
			type = rival
			any_scheme = {
				rivalry_2001_scheme_trigger = yes
			}
		}
	}

	immediate = {
		save_scope_as = first_rival
		random_relation = {
			type = rival
			limit = {
				any_scheme = {
					rivalry_2001_scheme_trigger = yes
				}
			}
			save_scope_as = rival
		}
		scope:rival = {
			random_scheme = {
				limit = {
					rivalry_2001_scheme_trigger = yes
				}
				save_scope_as = scheme
				scheme_target_character = {
					save_scope_as = target_in_question
				}
			}
		}
	}

	option = {
		name = rivalry.2001.a
		show_as_tooltip = {
			scope:scheme = {
				add_scheme_progress = scheme_progress_loss
			}
			scope:rival = {
				hidden_effect = {
					add_opinion = {
						modifier = hate_opinion
						target = scope:first_rival
						opinion = -20
					}
				}
			}
		}
		hidden_effect = {
			scope:rival = {
				trigger_event = rivalry.2002
			}
		}
		stress_impact = {
			compassionate = miniscule_stress_impact_gain
			honest = miniscule_stress_impact_gain
			forgiving = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = honest
					has_trait = forgiving
				}
			}
		}
	}

	option = {
		name = rivalry.2001.b
		stress_impact = {
			vengeful = medium_stress_impact_gain
			sadistic = miniscule_stress_impact_gain
			callous = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = vengeful
					has_trait = sadistic
					has_trait = callous
				}
			}
		}
	}
}


rivalry.2002 = {
	type = character_event
	title = rivalry.2002.t
	desc = rivalry.2002.desc
	theme = rival_relation
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:first_rival
		animation = schadenfreude
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	option = {
		name = rivalry.2002.a
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}
		hidden_effect = {
			add_opinion = {
				modifier = hate_opinion
				target = scope:first_rival
				opinion = -20
			}
		}
	}
}



#Rival insults you
#Rivalry.3001
# by Petter Vilberg
scripted_trigger rivalry_3001_rival_trigger = {
	is_available = yes
	NOT = {
		reverse_has_opinion_modifier = {
			target = prev
			modifier = rival_insult_opinion
		}
	}
}

rivalry.3001 = {
	type = character_event
	title = rivalry.3001.t
	desc = {
		desc = rivalry.3001.desc.opening
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_malicious_trigger = yes
						}
					}
					desc = rivalry.3001.malicious
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_benevolent_trigger = yes
						}
					}
					desc = rivalry.3001.benevolent
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_dominant_trigger = yes
						}
					}
					desc = rivalry.3001.dominant
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							OR = {
								has_personality_introverted_trigger = yes
								has_personality_submissive_trigger = yes
							}
						}
					}
					desc = rivalry.3001.submissive
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_extroverted_trigger = yes
						}
					}
					desc = rivalry.3001.extroverted
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_emotional_trigger = yes
						}
					}
					desc = rivalry.3001.emotional
				}
				triggered_desc = {
					trigger = {
						scope:rival = {
							has_personality_levelheaded_trigger = yes
						}
					}
					desc = rivalry.3001.levelheaded
				}
			}
			desc = rivalry.3001.desc.fallback
		}
		desc = rivalry.3001.desc.end
	}
	theme = rival_relation
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:rival
		animation = schadenfreude
	}

	trigger = {
		any_relation = {
			type = rival
			rivalry_3001_rival_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.8
			is_ai = no
		}
	}

	immediate = {
		random_relation = {
			type = rival
			limit = {
				rivalry_3001_rival_trigger = yes
			}
			save_scope_as = rival
		}
	}

	option = {
		name = rivalry.3001.a
		add_stress = medium_stress_impact_gain
		hidden_effect = {
			add_opinion = {
				target = scope:rival
				modifier = rival_insult_opinion
			}
		}
	}
}



#You like the Rival of a Friend less
# by Petter Vilberg
scripted_trigger rivalry_3002_rival_trigger = {
	root = {
		NOT = {
			has_opinion_modifier = {
				target = prev
				modifier = rival_of_friend_opinion
			}
		}
	}
}

#Rivalry.3002
rivalry.3002 = {
	type = character_event
	title = rivalry.3002.t
	desc = rivalry.3002.desc
	theme = rival_relation
	left_portrait = scope:rival
	right_portrait = scope:friend

	trigger = {
		is_available_ai_adult = yes
		any_relation = {
			type = friend
			any_relation = {
				type = rival
				rivalry_3002_rival_trigger = yes
				save_temporary_scope_as = rival_check
			}
		}
		NOT = {
			has_opinion_modifier = {
				target = scope:rival_check
				modifier = rival_of_friend_opinion
			}
		}
	}

	immediate = {
		save_scope_as = first_friend
		random_relation = {
			type = friend
			limit = {
				any_relation = {
					type = rival
					rivalry_3002_rival_trigger = yes
				}
			}
			random_relation = {
				type = rival
				limit = {
					rivalry_3002_rival_trigger = yes
				}
				save_scope_as = rival
			}
			save_scope_as = friend
		}
	}

	option = {
		name = rivalry.3002.a
		add_opinion = {
			target = scope:rival
			modifier = rival_of_friend_opinion
		}
		hidden_effect = {
			scope:rival = {
				trigger_event = rivalry.3003
			}
		}
	}
}


rivalry.3003 = {
	type = character_event
	title = rivalry.3003.t
	desc = rivalry.3003.desc
	theme = rival_relation
	left_portrait = {
		character = scope:friend
		animation = admiration
	}
	right_portrait = {
		character = scope:first_friend
		animation = anger
	}

	option = {
		name = rivalry.3003.a
		show_as_tooltip = {
			scope:first_friend = {
				add_opinion = {
					target = scope:rival
					modifier = rival_of_friend_opinion
					opinion = -30
					years = 20
				}
			}
		}
		hidden_effect = {
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:rival }
				}
				set_relation_potential_rival = scope:rival
			}
			add_opinion = {
				target = scope:first_friend
				modifier = friend_of_rival_opinion
			}
		}
	}
}


# Decrease opinion of rival because of opposing personality trait
rivalry.3004 = {
	type = character_event
	title = rivalry.3004.t
	desc = {
		desc = rivalry.3004.opening
		random_valid = {
			desc = rivalry.3004.fallback
		}
	}
	theme = rival_relation

	trigger = {
		is_ai = yes
		any_relation = {
			type = rival
			has_a_personality_trait_opposite_to_root_trigger = yes
			root = {
				NOT = {
					has_opinion_modifier = {
						target = prev
						modifier = rival_differing_personalities_opinion
					}
				}
			}
		}
	}

	immediate = {
		random_relation = {
			type = rival
			limit = {
				has_a_personality_trait_opposite_to_root_trigger = yes
				NOT = {
					root = {
						has_opinion_modifier = {
							target = prev
							modifier = rival_differing_personalities_opinion
						}
					}
				}
			}
			save_scope_as = rival
		}
	}

	option = {
		name = rivalry.3004.a
		add_opinion = {
			target = scope:rival
			modifier = rival_differing_personalities_opinion
		}
	}
}


