#Events caused by having Friends

namespace = friendship

# 0000-0999: Relation status changes
# 1000-1999: Friends offer each other support
# 2000-2999: Back-and-forth or other exchanges
# 3000-3999: General effects of Friendship on other things
# 4000-4999: Friendship opinion change events



#
# Friend Relation Status Changes
# 0000-0999
#


# A Friend stops being a Friend
scripted_trigger friendship_0001_losing_friend_trigger = {
	is_ai = yes
	friendship_0001_opinion_trigger = yes
}

scripted_trigger friendship_0001_opinion_trigger = {
	save_temporary_scope_as = friend_check
	#Why are they doubting the relationship?
	OR = {
		opinion = { #They simply dislike you
			target = root
			value <= -5
		}
		AND = { #You're a known murderer
			root = { has_trait = murderer }
			opinion = {
				target = root
				value <= 0
			}
			NOR = {
				has_trait = sadistic
				has_trait = callous
				has_trait = murderer
				any_secret = {
					secret_type = secret_murder
				}
			}
		}
		AND = { #They know you're a murderer
			root = {
				any_secret = {
					secret_type = secret_murder
					is_known_by = scope:friend_check
				}
			}
			opinion = {
				target = root
				value <= 0
			}
			NOR = {
				has_trait = sadistic
				has_trait = callous
				has_trait = murderer
				any_secret = {
					secret_type = secret_murder
				}
			}
		}
	}
}

friendship.0001 = {
	type = character_event
	title = friendship.0001.t
	desc = {
		desc = friendship.0001.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:friend_in_question = {
						friendship_0001_opinion_trigger = yes
					}
				}
				desc = friendship.0001.desc_murder
			}
			desc = friendship.0001.desc
		}
	}
	theme = friend_relation
	left_portrait = {
		character = scope:friend_in_question
		animation = sadness
	}

	trigger = {
		#Friends have to like each other a lot to stay together
		any_relation = {
			type = friend
			save_temporary_scope_as = friend_check
			friendship_0001_losing_friend_trigger = yes
		}
	}

	immediate = {
		save_scope_as = first_friend
		random_relation = {
			type = friend
			limit = {
				friendship_0001_losing_friend_trigger = yes
			}
			save_scope_as = friend_in_question
		}
	}

	option = { #It is the way of things
		name = friendship.0001.a
		scope:friend_in_question = {
			#Notification event to target, where the actual effect lies
			trigger_event = friendship.0002
		}
		show_as_tooltip = {
			remove_relation_friend = scope:friend_in_question
		}
	}
	option = { #No!
		name = friendship.0001.b
		custom_tooltip = friendship.0001.b.tt
		scope:friend_in_question = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 10
			}
		}
	}
}


#Event for the friend being lost
friendship.0002 = {
	type = character_event
	title = friendship.0002.t
	desc = friendship.0002.desc
	theme = friend_relation
	left_portrait = {
		character = scope:first_friend
		animation = sadness
	}

	immediate = {
		if = {
			limit = {
				has_relation_friend = scope:first_friend
			}
			remove_relation_friend = scope:first_friend
		}
	}

	option = {
		name = friendship.0002.a
		show_as_tooltip = {
			remove_relation_friend = scope:first_friend
		}
	}
}


#####
# Good friends might become lovers
# 0003 -
#####


#Really good friends might see the beginning of something more
friendship.0003 = {
	type = character_event
	title = friendship.0003.t
	desc = friendship.0003.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_as_potential_lover
		animation = love
	}

	trigger = {
		mgr_can_seduce = yes
		NOT = { has_character_flag = had_potential_lover_event_flag }
		NOT = { has_character_flag = might_develop_romance_with_friend }
		any_relation = {
			type = friend
			#Is not currently involved in another budding romance
			NOT = { has_character_flag = might_develop_romance_with_friend }
			NOT = {
				any_relation = {
					type = lover
					this = root
				}
			}
			#Friends must like each other a lot
			opinion = {
				target = root
				value > 70
			}
			reverse_opinion = {
				target = root
				value > 70
			}
			#Must have matching gender/sexualities
			save_temporary_scope_as = sexuality_check_friend
			matching_gender_and_sexuality_trigger = { CHARACTER_1 = root CHARACTER_2 = scope:sexuality_check_friend }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.1
			#Makes it way less likely if Root is already Lover with a Friend.
			any_relation = {
				type = friend
				any_relation = {
					type = lover
					this = root
				}
			}
		}
	}

	immediate = {
		save_scope_as = first_friend
		random_relation = {
			type = friend
			limit = {
					NOT = { has_character_flag = might_develop_romance_with_friend }
					NOT = {
						any_relation = {
							type = lover
							this = root
						}
					}
					opinion = {
					target = root
					value > 70
				}
				reverse_opinion = {
					target = root
					value > 70
				}
				#Must have matching gender/sexualities
				save_temporary_scope_as = sexuality_check_friend
				matching_gender_and_sexuality_trigger = { CHARACTER_1 = root CHARACTER_2 = scope:sexuality_check_friend }
			}
			save_scope_as = friend_as_potential_lover
		}
		add_character_flag = {
			flag = had_potential_lover_event_flag
			days = 5475
		}
	}

	option = { #There might be something more to this
		name = friendship.0003.a
		ai_chance = {
			base = 80
		}
		hidden_effect = {
			add_character_flag = might_develop_romance_with_friend
			scope:friend_as_potential_lover = {
				trigger_event = friendship.0004
			}
		}
		custom_tooltip = friendship.0003.goes_for_it_tooltip
	}

	option = { #No, we're just friends
		name = friendship.0003.b
		ai_chance = {
			base = 20
		}
	}
}


# Friends also experiences this interest
# NOTE: This matches 0003, which should make it unclear where the chain began in the first place.
friendship.0004 = {
	type = character_event
	title = friendship.0003.t
	desc = friendship.0004.desc
	theme = friend_relation
	left_portrait = {
		character = scope:first_friend
		animation = love
	}

	option = { #There is something more to our relationship
		name = friendship.0004.a
		ai_chance = {
			base = 70
		}
		hidden_effect = {
			add_character_flag = might_develop_romance_with_friend
			scope:first_friend = {
				trigger_event = {
					id = friendship.0006
					days = { 30 730 }
				}
			}
		}
		custom_tooltip = friendship.0004.goes_for_it_tooltip
	}

	option = { #We are just very good friends
		name = friendship.0004.b
		ai_chance = {
			base = 30
		}
		scope:first_friend = { trigger_event = friendship.0005 }
	}
}



#Friend rejects advances
friendship.0005 = {
	type = character_event
	title = friendship.0005.t
	desc = friendship.0005.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_as_potential_lover
		animation = disbelief
	}

	immediate = {
		remove_character_flag = might_develop_romance_with_friend
	}

	option = { #Try to get over it
		name = friendship.0005.a
		stress_impact = {
			honest = medium_stress_impact_loss
		}
	}

	option = { #Lament their rejection
		name = friendship.0005.b
		add_opinion = {
			modifier = rejected_by_friend_opinion
			target = scope:friend_as_potential_lover
		}
	}

	option = { #Try to be optimistic
		name = friendship.0005.c
		add_opinion = {
			modifier = optimistic_about_friendship_opinion
			target = scope:friend_as_potential_lover
		}
	}
}



#Friend has welcomed advances, check if they are still alive
friendship.0006 = {
	type = character_event

	hidden = yes

	immediate = {
		if = {
			limit = {
				scope:friend_as_potential_lover = { is_alive = no }
			}
			trigger_event = friendship.0009
		}
		else = {
			trigger_event = friendship.0007
		}
	}
}


#Friend becomes Lover
friendship.0007 = {
	type = character_event
	title = friendship.0007.t
	desc = friendship.0007.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_as_potential_lover
		animation = love
	}

	immediate = {
		remove_character_flag = might_develop_romance_with_friend
	}

	option = {
		name = friendship.0007.a
		set_relation_lover = scope:friend_as_potential_lover
		hidden_effect = {
			scope:friend_as_potential_lover = {
				trigger_event = friendship.0008
			}
		}
	}
}


#Other side becomes Lover
friendship.0008 = {
	type = character_event
	title = friendship.0008.t
	desc = friendship.0008.desc
	theme = friend_relation
	left_portrait = {
		character = scope:first_friend
		animation = love
	}

	immediate = {
		remove_character_flag = might_develop_romance_with_friend
	}

	option = {
		name = friendship.0008.a
		show_as_tooltip = {
			set_relation_lover = scope:first_friend
		}
	}
}


#Longing for what could have been
# (Fired if target is dead)
friendship.0009 = {
	type = character_event
	title = friendship.0009.t
	desc = friendship.0009.desc
	theme = friend_relation
	left_portrait = scope:friend_as_potential_lover

	immediate = {
		remove_character_flag = might_develop_romance_with_friend
	}

	option = {
		name = friendship.0009.a
		if = {
			limit = {
				NOT = { has_trait = depressed }
			}
			random = {
				chance = 10
				add_trait = depressed_1
			}
		}
	}
}


#Best friend no longer best friend
scripted_trigger friendship_0010_losing_best_friend_trigger = {
	is_ai = yes
	opinion = {
		target = root
		value < 0
	}
}

friendship.0010 = { #by Mathilda Bjarnehed
	type = character_event
	title = friendship.0010.t
	desc = friendship.0010.desc
	theme = friend_relation
	theme = unfriendly
	left_portrait = {
		character = scope:best_friend
		animation = sadness
	}
	
	trigger = {
		NOT = { has_character_flag = event_friendship_0010_cooldown }
		any_relation = {
			type = best_friend
			friendship_0010_losing_best_friend_trigger = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = event_friendship_0010_cooldown
			years = 10
		}		
		random_relation = {
			type = best_friend
			limit = { # You're technically only supposed to have one, but who knows what can happen
				friendship_0010_losing_best_friend_trigger = yes
			}
			save_scope_as = best_friend
		}
	}

	#We must remain besties!
	option = {
		name = friendship.0010.a

		add_stress = medium_stress_gain

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

		random_list = {
			60 = {
				desc = friendship.0010.a.success
				modifier = {
					ai_values_divergence = {
		 				target = scope:best_friend
		 				value <= very_low_ai_values_divergence
		 			}
		 			factor = 1.3
				}
				modifier = {
					ai_values_divergence = {
		 				target = scope:best_friend
		 				value <= low_ai_values_divergence
		 			}
		 			factor = 1.2
				}
				modifier = {
					ai_values_divergence = {
		 				target = scope:best_friend
		 				value <= medium_ai_values_divergence
		 			}
		 			factor = 1.2
				}

				send_interface_toast = {
					title = friendship.0010.a.success
					left_icon = scope:best_friend
					reverse_add_opinion = {
						target = scope:best_friend
						modifier = friendliness_opinion
						opinion = 20
					}
					hidden_effect = {
						add_opinion = {
							target = scope:best_friend
							modifier = friendliness_opinion
							opinion = 20
						}
					}
				}
			}
			40 = {
				desc = friendship.0010.a.failure
				modifier = {
					opinion = {
						target = scope:best_friend
						value <= low_positive_opinion
					}
					factor = 1.3
				}
				modifier = {
					reverse_opinion = {
						target = scope:best_friend
						value <= low_positive_opinion
					}
					factor = 1.3
				}
				modifier = {
					ai_values_divergence = {
		 				target = scope:best_friend
		 				value >= high_ai_values_divergence
		 			}
		 			factor = 1.5
				}

				send_interface_toast = {
					title = friendship.0010.a.failure
					left_icon = scope:best_friend
					show_as_tooltip = {
						remove_relation_best_friend = scope:best_friend
						set_relation_friend = scope:best_friend
					}
				}
				hidden_effect = {
					save_scope_as = other_best_friend
					scope:best_friend = { trigger_event = friendship.0011 }
				}
			}
		}

		ai_chance = {
			factor = 65
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_energy = 0.2
			}
		}
	}

	#Let it go
	option = {
		name = friendship.0010.b

		show_as_tooltip = {
			remove_relation_best_friend = scope:best_friend
			set_relation_friend = scope:best_friend
		}
		hidden_effect = {
			save_scope_as = other_best_friend
			scope:best_friend = { trigger_event = friendship.0011 }
		}

		stress_impact = {
			gregarious = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			generous = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			factor = 35
			
		}
	}
}


friendship.0011 = { #by Mathilda Bjarnehed
	type = character_event
	title = friendship.0011.t
	desc = friendship.0011.desc
	theme = friend_relation
	theme = unfriendly
	left_portrait = {
		character = scope:other_best_friend
		animation = sadness
	}

	immediate = {
		remove_relation_best_friend = scope:other_best_friend
		set_relation_friend = scope:other_best_friend
	}

	option = {
		name = friendship.0011.a

		stress_impact = {
			gregarious = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
	}
}



#Become Rivals instead of Friends
friendship.0014 = {
	type = character_event
	title = friendship.0014.t
	desc = friendship.0014.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_to_rival
		animation = anger
	}

	trigger = {
		any_relation = {
			type = friend
			is_ai = yes
			reverse_opinion = {
				target = root
				value <= -30
			}
		}
	}

	immediate = {
		save_scope_as = original_friend
		random_relation = {
			type = friend
			limit = {
				is_ai = yes
				reverse_opinion = {
					target = root
					value <= -30
				}
			}
			save_scope_as = friend_to_rival
		}
		remove_relation_friend = scope:friend_to_rival
	}

	option = {
		name = friendship.0014.a
		show_as_tooltip = {
			set_relation_rival = scope:friend_to_rival
		}
		hidden_effect = {
			scope:friend_to_rival = {
				trigger_event = friendship.0015
			}
		}
	}
}


#Mirror event for character being rivaled
friendship.0015 = {
	type = letter_event
	opening = {
		desc = friendship.0015.opening
	}
	desc = friendship.0015.desc
	sender = {
		character = scope:original_friend
		animation = anger
	}

	option = {
		name = friendship.0015.a
		if = {
			limit = {
				NOT = { has_relation_rival = scope:original_friend }
			}
			set_relation_rival = scope:original_friend
		}
	}
}

#More Friends than Time
friendship.0018 = {
	type = character_event
	title = friendship.0018.t
	desc = friendship.0018.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_1
		animation = idle
	}
	right_portrait = {
		character = scope:friend_2
		animation = idle
	}
	lower_center_portrait = scope:friend_3

	trigger = {
		any_relation = {
			type = friend
			opinion = {
				target = root
				value < 50
			}
			count > 2
		}
		NOT = { has_character_flag = had_too_many_friends_event }
	}

	immediate = {
		save_scope_as = first_friend
		add_character_flag = {
			flag = had_too_many_friends_event
			years = 5
		}
		random_relation = {
			type = friend
			limit = {
				opinion = {
					target = root
					value < 50
				}
			}
			save_scope_as = friend_1
		}
		random_relation = {
			type = friend
			limit = {
				opinion = {
					target = root
					value < 50
				}
				NOT = { this = scope:friend_1 }
			}
			save_scope_as = friend_2
		}
		random_relation = {
			type = friend
			limit = {
				opinion = {
					target = root
					value < 50
				}
				NOT = { this = scope:friend_1 }
				NOT = { this = scope:friend_2 }
			}
			save_scope_as = friend_3
		}
	}

	option = {
		name = friendship.0018.a
		show_as_tooltip = {
			remove_relation_friend = scope:friend_1
			scope:friend_1 = {
				add_opinion = {
					modifier = friend_abandoned_me_opinion
					target = root
				}
			}
		}
		hidden_effect = {
			scope:friend_1 = {
				trigger_event = friendship.0019
			}
		}
	}

	option = {
		name = friendship.0018.b
		show_as_tooltip = {
			remove_relation_friend = scope:friend_2
			scope:friend_2 = {
				add_opinion = {
					modifier = friend_abandoned_me_opinion
					target = root
				}
			}
		}
		hidden_effect = {
			scope:friend_2 = {
				trigger_event = friendship.0019
			}
		}
	}

	option = {
		name = friendship.0018.c
		trigger = {
			exists = scope:friend_3
		}
		show_as_tooltip = {
			remove_relation_friend = scope:friend_3
			scope:friend_3 = {
				add_opinion = {
					modifier = friend_abandoned_me_opinion
					target = root
				}
			}
		}
		hidden_effect = {
			scope:friend_3 = {
				trigger_event = friendship.0019
			}
		}
	}

	option = {
		name = friendship.0018.d
		trigger = {
			NOR = {
				has_trait = gregarious
				has_trait = diplomat
			}
		}
		stress_impact = {
			base = major_stress_gain
		}
	}

	option = {
		name = friendship.0018.e
		trigger = {
			OR = {
				has_trait = gregarious
				has_trait = diplomat
			}
			NOT = { has_character_flag = used_social_skills_to_keep_friends }
		}
		trait = gregarious
		trait = diplomat
		hidden_effect = {
			add_character_flag = {
				flag = used_social_skills_to_keep_friends
				years = 10
			}
		}
	}
}


# Notification for Friend that you have abandoned them
friendship.0019 = {
	type = character_event
	title = friendship.0019.t
	desc = friendship.0019.desc
	theme = friend_relation
	left_portrait = {
		character = scope:first_friend
		animation = sadness
	}

	immediate = {
		add_opinion = {
			modifier = friend_abandoned_me_opinion
			target = scope:first_friend
		}
	}

	option = {
		name = friendship.0019.a_1
		remove_relation_friend = scope:first_friend
		show_as_tooltip = {
			add_opinion = {
				modifier = friend_abandoned_me_opinion
				target = scope:first_friend
			}
		}
	}
}




#
# FRIENDSHIP SUPPORT EVENTS
# 1000-1999
#



#
# Send gift to Friend chain
# 1001-1004
scripted_trigger friendship_1001_friend_trigger = {
	is_ai = no
	is_available = yes
}

scripted_trigger friendship_1001_secret_trigger = {
	NOR = {
		secret_owner = root
		secret_owner = scope:friend_gift_target
		secret_target = root
		secret_target = scope:friend_gift_target
		is_known_by = scope:friend_gift_target
	}
	OR = {
		secret_owner = {
			is_of_major_or_minor_interest_trigger = { CHARACTER = scope:friend_gift_target }
		}
		AND = {
			exists = secret_target
			secret_target = {
				is_of_major_or_minor_interest_trigger = { CHARACTER = scope:friend_gift_target }
			}
		}
	}
}

#Send your friend a gift
friendship.1001 = {
	type = character_event
	hidden = yes

	trigger = {
		any_relation = {
			type = friend
			friendship_1001_friend_trigger = yes
		}
		is_ai = yes
		NOT = { has_character_flag = had_friend_gift_event_flag }
	}

	immediate = {
		save_scope_as = sender
		add_character_flag = {
			flag = had_friend_gift_event_flag
			years = 5
		}
		random_relation = {
			type = friend
			save_scope_as = friend_gift_target
		}

		#To decide what's sent
		random_list = {
			50 = { #gold
				scope:friend_gift_target = {
					trigger_event = friendship.1002
				}
				stress_impact = {
					base = minor_stress_impact_loss
					greedy = medium_stress_impact_gain
				}
			}
			50 = { #stag
				scope:friend_gift_target = {
					trigger_event = friendship.1003
				}
			}
			100 = { #secret
				trigger = {
					any_known_secret = {
						friendship_1001_secret_trigger = yes
					}
				}
				random_known_secret = {
					limit = {
						friendship_1001_secret_trigger = yes
					}
					save_scope_as = secret_to_share
				}
				scope:friend_gift_target = {
					trigger_event = friendship.1004
				}
			}
		}
	}
}


# Receive gold gift!
friendship.1002 = {
	type = letter_event
	opening = {
		desc = friendship.1002.opening
	}
	desc = friendship.1002.desc
	sender = {
		character = scope:sender
		animation = happiness
	}

	option = {
		name = friendship.1002.a
		add_gold = scope:sender.medium_gold_value
		add_stress = minor_stress_impact_loss
		hidden_effect = {
			add_opinion = {
				modifier = friend_gave_good_gift_opinion
				target = scope:sender
			}
		}
	}
}


# Receive a stag as a gift!
friendship.1003 = {
	type = letter_event
	opening = friendship.1002.opening
	desc = friendship.1003.desc
	sender = {
		character = scope:sender
		animation = happiness
	}

	option = {
		name = friendship.1003.a
		add_character_modifier = {
			modifier = garden_stag_modifier
			years = 10
		}
		add_stress = minor_stress_impact_loss
		hidden_effect = {
			add_opinion = {
				modifier = friend_gave_good_gift_opinion
				target = scope:sender
			}
		}
	}

	option = {
		name = friendship.1003.b
		add_character_modifier = {
			modifier = impromptu_venison_feast_modifier
			years = 5
		}
		add_stress = minor_stress_impact_loss
		hidden_effect = {
			add_opinion = {
				modifier = friend_gave_good_gift_opinion
				target = scope:sender
			}
		}
	}
}


# Receive a secret from a Friend
friendship.1004 = {
	type = letter_event
	opening = friendship.1002.opening
	desc = friendship.1004.desc
	sender = {
		character = scope:sender
		animation = schadenfreude
	}

	option = {
		name = friendship.1004.a
		scope:secret_to_share = {
			reveal_to = root
		}
		hidden_effect = {
			add_opinion = {
				modifier = friend_gave_good_gift_opinion
				target = scope:sender
			}
		}
	}
}


################################
# Get War Support from Friend
# by Petter Vilberg
################################

scripted_trigger friendship_1006_friend_trigger = {
	is_available_ai = yes
	is_at_war = no
}

friendship.1006 = {
	type = character_event
	title = friendship.1006.t
	desc = friendship.1006.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend
		animation = happiness
	}

	trigger = {
		is_at_war = yes
		any_relation = {
			type = friend
			friendship_1006_friend_trigger = yes
		}
	}

	immediate = {
		random_relation = {
			type = friend
			limit = { friendship_1006_friend_trigger = yes }
			save_scope_as = friend
		}
	}

	option = {
		name = friendship.1006.a
		add_gold = scope:friend.major_gold_value
		add_stress = minor_stress_impact_loss
		hidden_effect = {
			add_opinion = {
				modifier = supported_my_war_opinion
				target = scope:friend
			}
		}
	}
}


################################
# Send a Courtier to a Friend
# by Petter Vilberg
################################
scripted_trigger friendship_1008_friend_trigger = {
	is_ai = no
	is_available = yes
	is_landed = yes
}

scripted_trigger friendship_1008_courtier_trigger = {
	is_ruler = no
	NOR = {
		any_close_family_member = { this = root }
		any_consort = { this = root }
	}
	OR = {
		diplomacy >= very_high_skill_rating
		AND = {
			martial >= very_high_skill_rating
			can_be_commander_now_trigger = { ARMY_OWNER = scope:friend_receiving_gift }
		}
		stewardship >= very_high_skill_rating
		learning >= very_high_skill_rating
		intrigue >= very_high_skill_rating
		any_claim = {
			exists = this
			tier >= scope:friend_receiving_gift.highest_held_title_tier_minus_one
		}
	}
}

friendship.1008 = {
	type = character_event
	hidden = yes

	trigger = {
		is_ai = yes
		NOT = { has_character_flag = had_courtier_envoy_event }
		any_relation = {
			type = friend
			friendship_1008_friend_trigger = yes
			save_temporary_scope_as = friend_receiving_gift
		}
		any_courtier_or_guest = {
			friendship_1008_courtier_trigger = yes
		}
	}

	immediate = {
		save_scope_as = first_friend
		add_character_flag = {
			flag = had_courtier_envoy_event
			years = 5
		}
		random_relation = {
			type = friend
			limit = {
				friendship_1008_friend_trigger = yes
			}
			save_scope_as = friend_receiving_gift
		}
		random_courtier_or_guest = {
			limit = {
				friendship_1008_courtier_trigger = yes
			}
			save_scope_as = courtier_on_offer
		}
	}

	option = {
		name = friendship.1008.a
		scope:friend_receiving_gift = {
			trigger_event = friendship.1009
		}
	}
}


#Offer from Friend
friendship.1009 = {
	type = character_event
	title = friendship.1009.t
	desc = friendship.1009.desc
	theme = friend_relation
	left_portrait = {
		character = scope:first_friend
		animation = happiness
	}
	right_portrait = {
		character = scope:courtier_on_offer
		animation = idle
	}

	option = {
		name = friendship.1009.a
		add_courtier = scope:courtier_on_offer
		hidden_effect = {
			add_opinion = {
				modifier = sent_great_courtier_opinion
				target = scope:first_friend
			}
		}
	}

	option = {
		name = friendship.1009.b
		custom_tooltip = friendship.1009.rejection_tooltip
		scope:first_friend = {
			add_opinion = {
				modifier = rejected_gift_opinion
				target = root
			}
		}
	}
}




# Friend Interaction/Exchange Events
# 2000-2999

###
#Confess a Minor Secret - Chain
# by Petter Vilberg
###
scripted_trigger friendship_2001_friend_trigger = {
	save_temporary_scope_as = friend_receiving_confession
	root = {
		any_secret = {
			friendship_2001_secret_trigger = yes
		}
	}
}

scripted_trigger friendship_2001_secret_trigger = {
	is_shunned_for = secret_owner
	NOT = { is_known_by = scope:friend_receiving_confession }
	trigger_if = {
		limit = { exists = secret_target }
		NOT = { secret_target = scope:friend_receiving_confession }
	}
}

friendship.2001 = {
	type = character_event
	title = friendship.2001.t
	desc = friendship.2001.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_receiving_confession
		animation = idle
	}

	trigger = {
		NOT = { has_character_flag = had_friendship_secret_reveal_event }
		any_relation = {
			type = friend
			friendship_2001_friend_trigger = yes
		}
		any_secret = {
			friendship_2001_secret_trigger = yes
		}
	}

	immediate = {
		save_scope_as = confessor
		add_character_flag = {
			flag = had_friendship_secret_reveal_event
			years = 10
		}
		random_relation = {
			type = friend
			limit = {
				friendship_2001_friend_trigger = yes
			}
			save_scope_as = friend_receiving_confession
		}
		random_secret = {
			limit = {
				is_shunned_for = secret_owner
			}
			save_scope_as = secret_being_confessed
		}
	}

	option = {
		name = friendship.2001.a
		add_stress = medium_stress_loss
		show_as_tooltip = {
			scope:secret_being_confessed = {
				reveal_to = scope:friend_receiving_confession
			}
			scope:friend_receiving_confession = {
				add_opinion = {
					modifier = confided_in_me_opinion
					target = scope:confessor
				}
			}
		}
		hidden_effect = {
			scope:friend_receiving_confession = {
				trigger_event = friendship.2002
			}
		}
	}
}


#A Friend confesses a minor secret
friendship.2002 = {
	type = character_event
	title = friendship.2002.t
	desc = friendship.2002.desc
	theme = friend_relation
	left_portrait = {
		character = scope:confessor
		animation = worry
	}

	immediate = {
		if = {
			limit = {
				any_secret = {				
					same_secret_type_as = scope:secret_being_confessed
					NOT = { is_known_by = scope:confessor }
				}
			}
			random_secret = {
				limit = {				
					same_secret_type_as = scope:secret_being_confessed
					NOT = { is_known_by = scope:confessor }
				}
				save_scope_as = return_secret_to_confess
			}
		}
	}

	option = {
		name = friendship.2002.a
		scope:secret_being_confessed = {
			reveal_to = root
		}
		hidden_effect = {
			add_opinion = {
				modifier = confided_in_me_opinion
				target = scope:confessor
			}
		}
	}

	option = {
		name = friendship.2002.b
		trigger = {
			exists = scope:return_secret_to_confess
		}
		exclusive = yes
		scope:secret_being_confessed = {
			reveal_to = root
		}
		hidden_effect = {
			add_opinion = {
				modifier = confided_in_me_opinion
				target = scope:confessor
			}
		}
		add_stress = medium_stress_loss
		show_as_tooltip = {
			scope:return_secret_to_confess = {
				reveal_to = scope:confessor
			}
			scope:confessor = {
				add_opinion = {
					modifier = confided_in_me_opinion
					target = root
				}
			}
		}
		hidden_effect = {
			scope:confessor = {
				trigger_event = friendship.2003
			}
		}
	}
}


# The Friend had the exact same secret!
friendship.2003 = {
	type = character_event
	title = friendship.2003.t
	desc = friendship.2003.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_receiving_confession
		animation = happiness
	}

	option = {
		name = friendship.2003.a
		scope:return_secret_to_confess = {
			reveal_to = root
		}
		hidden_effect = {
			add_opinion = {
				modifier = confided_in_me_opinion
				target = scope:friend_receiving_confession
			}
		}
	}
}
#END Confess a Minor Secret Chain


###
#Confess a Major Secret - Chain
# by Petter Vilberg
###
scripted_trigger friendship_2004_friend_trigger = {
	save_temporary_scope_as = friend_receiving_confession
	root = {
		any_secret = {
			friendship_2004_secret_trigger = yes
		}
	}
}

scripted_trigger friendship_2004_secret_trigger = {
	is_criminal_for = secret_owner
	NOT = { is_known_by = scope:friend_receiving_confession }
	trigger_if = {
		limit = { exists = secret_target }
		NOT = { secret_target = scope:friend_receiving_confession }
	}
}

#Confess a Major Secret
friendship.2004 = {
	type = character_event
	title = friendship.2004.t
	desc = friendship.2004.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_receiving_confession
		animation = idle
	}

	trigger = {
		NOT = { has_character_flag = had_friendship_secret_reveal_event }
		any_relation = {
			type = friend
			friendship_2004_friend_trigger = yes
		}
		any_secret = {
			friendship_2004_secret_trigger = yes
		}
		stress >= 40
	}

	immediate = {
		save_scope_as = confessor
		add_character_flag = {
			flag = had_friendship_secret_reveal_event
			years = 10
		}
		random_relation = {
			type = friend
			limit = {
				friendship_2004_friend_trigger = yes
			}
			save_scope_as = friend_receiving_confession
		}
		random_secret = {
			limit = {
				friendship_2004_secret_trigger = yes
			}
			save_scope_as = secret_being_confessed
		}
	}

	option = {
		name = friendship.2004.a
		show_as_tooltip = {
			scope:secret_being_confessed = {
				reveal_to = scope:friend_receiving_confession
			}
		}
		add_stress = medium_stress_loss
		hidden_effect = {
			scope:friend_receiving_confession = {
				trigger_event = friendship.2005
			}
		}
	}
}


#A Friend confesses a major secret
friendship.2005 = {
	type = character_event
	title = friendship.2005.t
	desc = friendship.2005.desc
	theme = friend_relation
	left_portrait = {
		character = scope:confessor
		animation = worry
	}

	immediate = {
		if = {
			limit = {
				any_secret = {				
					same_secret_type_as = scope:secret_being_confessed
					NOT = { is_known_by = scope:confessor }
				}
			}
			random_secret = {
				limit = {				
					same_secret_type_as = scope:secret_being_confessed
					NOT = { is_known_by = scope:confessor }
				}
				save_scope_as = return_secret_to_confess
			}
		}
	}

	option = {
		name = friendship.2005.a
		scope:secret_being_confessed = {
			reveal_to = root
		}
		add_opinion = {
			modifier = confided_in_me_opinion
			target = scope:confessor
		}
	}

	option = {
		name = friendship.2005.b
		trigger = {
			exists = scope:return_secret_to_confess
		}
		exclusive = yes
		scope:secret_being_confessed = {
			reveal_to = root
		}
		hidden_effect = {
			add_opinion = {
				modifier = confided_in_me_opinion
				target = scope:confessor
			}
		}
		add_stress = medium_stress_loss
		show_as_tooltip = {
			scope:return_secret_to_confess = {
				reveal_to = scope:confessor
			}
			scope:confessor = {
				add_opinion = {
					modifier = confided_in_me_opinion
					target = scope:friend_receiving_confession
				}
			}
		}
		hidden_effect = {
			scope:confessor = {
				trigger_event = friendship.2006
			}
		}
	}
}


# The Friend had the exact same secret!
friendship.2006 = {
	type = character_event
	title = friendship.2006.t
	desc = friendship.2006.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_receiving_confession
		animation = happiness
	}

	option = {
		name = friendship.2006.a
		scope:return_secret_to_confess = {
			reveal_to = root
		}
		hidden_effect = {
			add_opinion = {
				modifier = confided_in_me_opinion
				target = scope:friend_receiving_confession
			}
		}
	}
}

### END Confess Major Secret Chain



###
#Intercede on Behalf of Friend
# by Petter Vilberg
###

scripted_trigger friendship_2007_liege_trigger = {
	is_available_ai = yes
	AND = {
		exists = this.liege
		reverse_opinion = {
			target = this.liege
			value < 10
		}
		this.liege = {
			NOT = { this = prev }
			NOT = { this = root }
		}
	}
}

scripted_trigger friendship_2007_vassal_trigger = {
	is_available_ai = yes
	is_powerful_vassal = yes
	NOT = { this = root }
	opinion = {
		target = prev
		value < 10
	}
}

scripted_trigger friendship_2007_friend_trigger = {
	OR = {
		friendship_2007_liege_trigger = yes
		any_vassal = {
			friendship_2007_vassal_trigger = yes
		}
	}
}

#Should I Intercede?
friendship.2007 = {
	type = character_event
	title = friendship.2007.t
	desc = friendship.2007.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_interceded_for
		animation = idle
	}
	right_portrait = {
		character = scope:talking_target
		animation = disapproval
	}

	trigger = {
		NOT = { has_character_flag = had_friend_intercession_event }
		any_relation = {
			type = friend
			friendship_2007_friend_trigger = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_friend_intercession_event
			years = 10
		}
		save_scope_as = friend_doing_interceding
		random_relation = {
			type = friend
			limit = {
				friendship_2007_friend_trigger = yes
			}
			save_scope_as = friend_interceded_for
		}
		random_list = {
			50 = {
				trigger = {
					scope:friend_interceded_for = {
						friendship_2007_liege_trigger = yes
					}
				}
				scope:friend_interceded_for = {
					liege = {
						save_scope_as = talking_target
					}
				}
			}
			50 = {
				trigger = {
					scope:friend_interceded_for = {
						any_vassal = {
							friendship_2007_vassal_trigger = yes
						}
					}
				}
				scope:friend_interceded_for = {
					random_vassal = {
						limit = {
							friendship_2007_vassal_trigger = yes
						}
						save_scope_as = talking_target
					}
				}
			}
		}
	}

	option = { #Speak on behalf of your friend
		name = friendship.2007.a
		duel = {
			skill = diplomacy
			target = scope:talking_target
			20 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -19
				}
				custom_tooltip = friendship.2007.success_tt
				hidden_effect = {
					scope:talking_target = {
						trigger_event = {
							id = friendship.2013
							days = { 3 5 }
						}
					}
				}
			}
			10 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.1
					min = -9
				}
				custom_tooltip = friendship.2007.failure_tt
				hidden_effect = {
					scope:talking_target = {
						trigger_event = {
							id = friendship.2011
							days = { 3 5 }
						}
					}
				}
			}
			5 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
					min = -4
				}
				custom_tooltip = friendship.2007.utter_failure_tt
				hidden_effect = {
					scope:talking_target = {
						trigger_event = {
							id = friendship.2008
							days = { 3 5 }
						}
					}
				}
			}
		}
	}

	option = { #No
		name = friendship.2007.b
		add_stress = minor_stress_loss
	}
}


#A Diplomatic Disaster
friendship.2008 = {
	hidden = yes

	immediate = {
		add_opinion = {
			modifier = bad_friend_reputation_opinion
			target = scope:friend_interceded_for
		}
		scope:friend_doing_interceding = {
			trigger_event = friendship.2009
		}
		scope:friend_interceded_for = {
			trigger_event = friendship.2010
		}
	}
}


#What Have I Done
friendship.2009 = {
	type = character_event
	title = friendship.2009.t
	desc = friendship.2009.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_interceded_for
		animation = shock
	}
	right_portrait = {
		character = scope:talking_target
		animation = disgust
	}

	option = {
		name = friendship.2009.a
		show_as_tooltip = {
			scope:talking_target = {
				add_opinion = {
					modifier = bad_friend_reputation_opinion
					target = scope:friend_interceded_for
				}
			}
			scope:friend_interceded_for = {
				add_opinion = {
					modifier = bad_intervention_my_behalf_opinion
					target = root
				}
			}
		}
	}
}


#What Has Friend Done?
friendship.2010 = {
	type = character_event
	title = friendship.2010.t
	desc = friendship.2010.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_doing_interceding
		animation = shock
	}
	right_portrait = {
		character = scope:talking_target
		animation = disgust
	}

	immediate = {
		show_as_tooltip = {
			scope:talking_target = {
				add_opinion = {
					modifier = bad_friend_reputation_opinion
					target = scope:friend_interceded_for
				}
			}
		}
	}

	option = {
		name = friendship.2010.a
		add_stress = medium_stress_gain
		add_opinion = {
			modifier = bad_intervention_my_behalf_opinion
			target = scope:friend_doing_interceding
		}
	}
}


#A Bother
friendship.2011 = {
	hidden = yes

	immediate = {
		add_opinion = {
			modifier = keeps_bothering_me_opinion
			target = scope:friend_doing_interceding
		}
		scope:friend_doing_interceding = {
			trigger_event = friendship.2012
		}
	}
}


#Didn't Work
friendship.2012 = {
	type = character_event
	title = friendship.2012.t
	desc = friendship.2012.desc
	theme = friend_relation
	left_portrait = {
		character = scope:talking_target
		animation = boredom
	}

	immediate = {
		show_as_tooltip = {
			scope:talking_target = {
				add_opinion = {
					modifier = keeps_bothering_me_opinion
					target = scope:friend_doing_interceding
				}
			}
		}
	}

	option = {
		name = friendship.2012.a
		add_stress = minor_stress_gain
	}
}



#I've Been Giving Them a Short Shrift
friendship.2013 = {
	hidden = yes

	immediate = {
		add_opinion = {
			modifier = successfull_intercession_opinion
			target = scope:friend_interceded_for
		}
		scope:friend_interceded_for = {
			trigger_event = friendship.2014
		}
		scope:friend_doing_interceding = {
			trigger_event = friendship.2015
		}
	}
}


#Friend Successfully Interceded for Me!
friendship.2014 = {
	type = character_event
	title = friendship.2014.t
	desc = friendship.2014.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_doing_interceding
		animation = happiness
	}
	right_portrait = {
		character = scope:talking_target
		animation = admiration
	}

	option = {
		name = friendship.2014.a
		scope:talking_target = {
			add_opinion = {
				modifier = successfull_intercession_opinion
				target = scope:friend_interceded_for
			}
		}
		add_stress = minor_stress_loss
		hidden_effect = {
			add_opinion = {
				modifier = friend_interceded_for_me_opinion
				target = scope:friend_doing_interceding
			}
		}
	}
}

#I Successfully Interceded!
friendship.2015 = {
	type = character_event
	title = friendship.2015.t
	desc = friendship.2015.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_interceded_for
		animation = happiness
	}
	right_portrait = {
		character = scope:talking_target
		animation = admiration
	}

	option = {
		name = friendship.2015.a
		show_as_tooltip = {
			scope:talking_target = {
				add_opinion = {
					modifier = successfull_intercession_opinion
					target = scope:friend_interceded_for
				}
			}
			scope:friend_interceded_for = {
				add_opinion = {
					modifier = friend_interceded_for_me_opinion
					target = root
				}
			}
		}
		add_stress = minor_stress_loss
	}
}




#
# General Having Friend Events
# 3000-3999
#

################################
# Approve of Spouse's Friend
# by Petter Vilberg
################################
scripted_trigger friendship_3001_friend_trigger = {
	NOT = { this = root }
	OR = {
		number_of_traits_in_common = {
			target = root
			value > 1
		}
		opinion = {
			target = root
			value >= high_positive_opinion
		}
	}
}

scripted_trigger friendship_3001_spouse_trigger = {
	is_ruler = yes
	is_available = yes
	any_relation = {
		type = friend
		friendship_3001_friend_trigger = yes
	}
}

friendship.3001 = {
	type = character_event
	title = friendship.3001.t
	desc = friendship.3001.desc
	theme = friend_relation
	left_portrait = {
		character = scope:spouse_benefitting
		animation = idle
	}
	right_portrait = {
		character = scope:friend_being_approved
		animation = idle
	}

	trigger = {
		is_available = yes
		NOT = { has_character_flag = had_spouse_friend_opinion_event }
		any_spouse = {
			friendship_3001_spouse_trigger = yes
		}
	}

	immediate = {
		save_scope_as = first_spouse
		add_character_flag = {
			flag = had_spouse_friend_opinion_event
			years = 10
		}
		random_spouse = {
			limit = {
				friendship_3001_spouse_trigger = yes
			}
			random_relation = {
				type = friend
				limit = {
					friendship_3001_friend_trigger = yes
				}
				save_scope_as = friend_being_approved
			}
			save_scope_as = spouse_benefitting
		}
	}

	option = {
		name = friendship.3001.a
		add_stress = medium_stress_loss
		show_as_tooltip = {
			add_opinion = {
				modifier = spouse_approves_of_friend_opinion
				target = scope:spouse_benefitting
			}
			add_opinion = {
				modifier = spouse_likes_friend_opinion
				target = scope:friend_being_approved
			}
		}
		hidden_effect = {
			scope:spouse_benefitting = {
				trigger_event = friendship.3002
			}
		}
	}
}


#My Spouse Approves of Friendship
friendship.3002 = {
	type = character_event
	title = friendship.3002.t
	desc = friendship.3002.desc
	theme = friend_relation
	left_portrait = {
		character = scope:first_spouse
		animation = admiration
	}
	right_portrait = {
		character = scope:friend_being_approved
		animation = idle
	}

	option = {
		name = friendship.3002.a
		add_stress = medium_stress_loss
		scope:first_spouse = {
			add_opinion = {
				modifier = spouse_approves_of_friend_opinion
				target = root
			}
			hidden_effect = {
				add_opinion = {
					modifier = spouse_likes_friend_opinion
					target = scope:friend_being_approved
				}
			}
		}
	}
}


################################
# Disapprove of Spouse's Friend
# by Petter Vilberg
################################
scripted_trigger friendship_3003_friend_trigger = {
	NOT = { this = root }
	OR = {
		number_of_opposing_traits = {
			target = root
			value > 1
		}
		opinion = {
			target = root
			value <= medium_negative_opinion
		}
	}
}

scripted_trigger friendship_3003_spouse_trigger = {
	is_ruler = yes
	is_available = yes
	any_relation = {
		type = friend
		friendship_3001_friend_trigger = yes
	}
}

friendship.3003 = {
	type = character_event
	title = friendship.3003.t
	desc = friendship.3003.desc
	theme = friend_relation
	left_portrait = {
		character = scope:spouse_suffering
		animation = idle
	}
	right_portrait = {
		character = scope:friend_being_disapproved
		animation = idle
	}

	trigger = {
		is_available_ai = yes
		NOT = { has_character_flag = had_spouse_friend_opinion_event }
		any_spouse = {
			friendship_3003_spouse_trigger = yes
		}
	}

	immediate = {
		save_scope_as = spouse
		add_character_flag = {
			flag = had_spouse_friend_opinion_event
			years = 10
		}
		random_spouse = {
			limit = {
				friendship_3003_spouse_trigger = yes
			}
			random_relation = {
				type = friend
				limit = {
					friendship_3003_friend_trigger = yes
				}
				save_scope_as = friend_being_disapproved
			}
			save_scope_as = spouse_suffering
		}
	}

	option = {
		name = friendship.3003.a
		custom_tooltip = spouse_responds_tt
		hidden_effect = {
			scope:spouse_suffering = {
				trigger_event = friendship.3004
			}
		}
	}
}


#My Spouse Disapproves of Friendship
friendship.3004 = {
	type = character_event
	title = friendship.3004.t
	desc = friendship.3004.desc
	theme = friend_relation
	left_portrait = {
		character = scope:spouse
		animation = disapproval
	}
	right_portrait = {
		character = scope:friend_being_disapproved
		animation = idle
	}

	option = {
		name = friendship.3004.a
		ai_chance = {
			base = 70
		}
		scope:spouse = {
			add_opinion = {
				modifier = spouse_disapproves_of_friend_opinion
				target = scope:spouse_suffering
			}
			add_opinion = {
				modifier = spouse_dislikes_friend_opinion
				target = scope:friend_being_disapproved
			}
		}
	}

	option = {
		name = friendship.3004.b
		show_as_tooltip = {
			remove_relation_friend = scope:friend_being_disapproved
		}
		scope:spouse = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 30
			}
		}
		hidden_effect = {
			scope:friend_being_disapproved = {
				trigger_event = friendship.3005
			}
		}
		ai_chance = {
			base = 30
			modifier = {
				factor = 0.2 # Make it extremely rare for this to happen to a player, but not impossible
				scope:friend_being_disapproved = {
					is_ai = no
				}
			}
		}
	}
}


#Friend is broken up with
friendship.3005 = {
	type = character_event
	title = friendship.3005.t
	desc = friendship.3005.desc
	theme = friend_relation
	left_portrait = {
		character = scope:spouse_suffering
		animation = sadness
	}
	right_portrait = {
		character = scope:spouse
		animation = happiness
	}

	option = {
		name = friendship.3005.a
		remove_relation_friend = scope:spouse_suffering
	}
}



################################
# A Friend on Your Council
# by Petter Vilberg
################################
scripted_trigger friendship_3006_council_member_trigger = {
	NOT = { this = scope:friend_on_council }
	scope:friend_on_council = {
		has_hook = prev
	}
	NOT = { has_hook = root }
}

scripted_trigger friendship_3006_friend_trigger = {	
	is_councillor_of = root
	is_available_ai = yes
	save_temporary_scope_as = friend_on_council
	root = {
		any_councillor = {
			friendship_3006_council_member_trigger = yes
		}
	}
}

friendship.3006 = {
	type = character_event
	title = friendship.3006.t
	desc = friendship.3006.desc
	theme = friend_relation
	left_portrait = {
		character = scope:friend_on_council
		animation = idle
	}
	right_portrait = {
		character = scope:hooked_councillor
		animation = idle
	}

	trigger = {
		any_relation = {
			type = friend
			friendship_3006_friend_trigger = yes
		}
		any_councillor = {
			friendship_3006_council_member_trigger = yes	
		}
	}

	immediate = {
		random_relation = {
			type = friend
			limit = {
				friendship_3006_friend_trigger = yes
			}
			save_scope_as = friend_on_council
		}
		random_councillor = {
			limit = {
				friendship_3006_council_member_trigger = yes
			}
			save_scope_as = hooked_councillor
		}
	}

	option = {
		name = friendship.3006.a
		scope:friend_on_council = {
			use_hook = scope:hooked_councillor
		}
		add_hook = {
			target = scope:hooked_councillor
			type = favor_hook
		}
		hidden_effect = {
			add_opinion = {
				modifier = passed_favor_opinion
				target = scope:friend_on_council
			}
		}
		ai_chance = {
			base = 80
			modifier = {
				factor = 0
				scope:friend_on_council = {
					is_ai = no
				}
			}
		}
	}

	option = {
		name = friendship.3006.b
		add_stress = medium_stress_loss
		scope:friend_on_council = {
			add_opinion = {
				modifier = trusted_judgement_opinion
				target = root
			}
		}
		ai_chance = {
			base = 20
		}
	}
}



################################
# Spending Time with Friend Reduces Stress
# by Petter Vilberg
################################
scripted_trigger friendship_3007_friend_trigger = {
	is_available_adult = yes
}

friendship.3007 = {
	type = character_event
	title = friendship.3007.t
	desc = {
		desc = friendship.3007.opening
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						NOT = { has_trait_benevolent_trigger = yes }
						scope:friend = {
							has_trait_malicious_trigger = yes
						}
					}
					desc = friendship.3007.malicious
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_malicious_trigger = yes }
						scope:friend = {
							has_trait_benevolent_trigger = yes
						}
					}
					desc = friendship.3007.benevolent
				}
				triggered_desc = {
					trigger = {
						Not = { has_trait_submissive_trigger = yes }
						scope:friend = {
							has_trait_dominant_trigger = yes
						}
					}
					desc = friendship.3007.dominant
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_dominant_trigger = yes }
						scope:friend = {
							has_trait_submissive_trigger = yes
						}
					}
					desc = friendship.3007.submissive
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_introverted_trigger = yes }
						scope:friend = {
							has_trait_extroverted_trigger = yes
						}
					}
					desc = friendship.3007.extroverted
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_extroverted_trigger = yes }
						scope:friend = {
							has_trait_introverted_trigger = yes
						}
					}
					desc = friendship.3007.introverted
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_levelheaded_trigger = yes }
						scope:friend = {
							has_trait_emotional_trigger = yes
						}
					}
					desc = friendship.3007.emotional
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_emotional_trigger = yes }
						scope:friend = {
							has_trait_levelheaded_trigger = yes
						}
					}
					desc = friendship.3007.levelheaded
				}
			}
			desc = friendship.3007.fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
					has_character_flag = minor_stress_reduction_flag
					has_character_flag = medium_stress_reduction_flag
					}
				}
				desc = friendship.3007.end_chill
			}
			triggered_desc = {
				trigger = {
					OR = {
					has_character_flag = major_stress_reduction_flag
					has_character_flag = massive_stress_reduction_flag
					}
				}			
				desc = friendship.3007.end_severe
			}	
		}
		
	}
	theme = friend_relation
	left_portrait = {
		character = scope:friend
		animation = idle
	}

	trigger = {
		NOT = { has_character_flag = had_friend_stress_reduction_event }
		is_available_adult = yes
		stress >= 30
		any_relation = {
			type = friend
			friendship_3007_friend_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			#Make it more likely to fire the higher your Stress
			value = stress
			multiplier = 0.2
		}
	}

	immediate = {
		random_relation = {
			type = friend
			limit = {
				friendship_3007_friend_trigger = yes
			}
			save_scope_as = friend
		}
		hidden_effect = {
			random_list = {
				25 = {
					add_character_flag = major_stress_reduction_flag
				}
				25 = {
					add_character_flag = medium_stress_reduction_flag
				}
				25 = {
					add_character_flag = minor_stress_reduction_flag
				}
				25 = {
					trigger = {
						scope:friend = {
							has_a_personality_trait_in_common_with_root_trigger = yes
						}
					}
					add_character_flag = massive_stress_reduction_flag
				}
			}
		}
		add_character_flag = {
			flag = had_friend_stress_reduction_event
			years = 5
		}
	}

	option = {
		name = friendship.3007.a
		trigger = {
			has_character_flag = major_stress_reduction_flag
		}
		stress_impact = {
			base = major_stress_loss
		}
		remove_character_flag = major_stress_reduction_flag
	}

	option = {
		name = friendship.3007.b
		trigger = {
			has_character_flag = medium_stress_reduction_flag
		}
		stress_impact = {
			base = medium_stress_loss
		}
		remove_character_flag = medium_stress_reduction_flag
	}

	option = {
		name = friendship.3007.c
		trigger = {
			has_character_flag = minor_stress_reduction_flag
		}
		fallback = yes
		stress_impact = {
			base = minor_stress_loss
		}
		remove_character_flag = minor_stress_reduction_flag
	}

	option = {
		name = friendship.3007.d
		trigger = {
			has_character_flag = massive_stress_reduction_flag
		}
		stress_impact = {
			base = massive_stress_loss
		}
		remove_character_flag = massive_stress_reduction_flag
	}
}
