﻿namespace = feast_events_flavor

#######################################
# By Veronica Pazos and Jay Zaborowski
# feast_events_flavor.0001 - Dynasty member of someone you have a relation with approaches you
# feast_events_flavor.0002 - A former rival reminisces with you

# Dynasty member of someone you have a relation with approaches you
# by Veronica Pazos
scripted_trigger feast_events_flavor_0001_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	NOR = {
		has_any_good_relationship_with_character_trigger = { CHARACTER = root }
		has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
		dynasty = root.dynasty
		is_courtier_of = root
		overlord ?= root
	}
	save_temporary_scope_as = guest_temp
	dynasty ?= {
		any_dynasty_member = {
			NOT = { this = scope:guest_temp }
			NOT = { is_spouse_of = scope:guest_temp } # We exclude their spouses to avoid weirdness
			OR = {
				AND = {
					has_any_good_relationship_with_character_trigger = { CHARACTER = root }
					NOT = { has_any_bad_relationship_with_character_trigger = { CHARACTER = root } }
				}
				AND = {
					has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
					NOT = { has_any_good_relationship_with_character_trigger = { CHARACTER = root } }
				}
			}
		}
	}
}				

feast_events_flavor.0001 = {
	type = activity_event
	title = feast_events_flavor.0001.t
	desc = {
		desc = feast_events_flavor.0001.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					has_any_good_relationship_with_character_trigger = { CHARACTER = scope:relation_target }
				}
				desc = feast_events_flavor.0001.desc.good
			}
			desc = feast_events_flavor.0001.desc.bad
		}
	}
	theme = feast_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_any_good_relationship_with_character_trigger = { CHARACTER = scope:relation_target } }
			animation = happiness
		}
		animation = dismissal
	}
	right_portrait = {
		character = scope:guest
		triggered_animation = {
			trigger = {
				root = { has_any_good_relationship_with_character_trigger = { CHARACTER = scope:relation_target } }
			}
			animation = toast_goblet
		}
		animation = schadenfreude
	}
	lower_left_portrait = scope:relation_target
	
	cooldown = { years = 10 }
	
	trigger = {
		involved_activity = {
			any_attending_character = { 
				feast_events_flavor_0001_appropriate_guest = yes
			}
		}
	}

	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					feast_events_flavor_0001_appropriate_guest = yes
				}
				save_scope_as = guest
				dynasty = {
					random_dynasty_member = {
						limit = {
							is_ai = yes
							NOT = { this = scope:guest }
							NOT = { is_spouse_of = scope:guest } # We exclude their spouses to avoid weirdness
							OR = {
								AND = {
									has_any_good_relationship_with_character_trigger = { CHARACTER = root }
									NOT = { has_any_bad_relationship_with_character_trigger = { CHARACTER = root } }
								}
								AND = {
									has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
									NOT = { has_any_good_relationship_with_character_trigger = { CHARACTER = root } }
								}
							}
						}
						save_scope_as = relation_target
					}
				}
			}
		}
	}
	
	option = { # Special diplo option
		name = feast_events_flavor.0001.aa
		trigger = {
			has_any_good_relationship_with_character_trigger = { CHARACTER = scope:relation_target }
			has_trait = family_first
			NOT = { is_allied_to = scope:guest }
		}
		custom_tooltip = feast_alliance_effect_tooltip
		create_alliance = {
			target = scope:guest
			allied_through_owner = root
			allied_through_target = scope:guest
		}
		stress_impact = {
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}

	option = { # If it's a good relationship, extend it
		name = feast_events_flavor.0001.a
		trigger = {
			has_any_good_relationship_with_character_trigger = { CHARACTER = scope:relation_target }
			NOT = { has_relation_friend = scope:guest }
		}
		if = {
			limit = {
				has_activity_intent = befriend_attendee_intent
				intent_target ?= scope:guest 
			}
			complete_activity_intent = yes
		}
		set_relation_friend = {
			target = scope:guest
			reason = friend_feast_bonding
		}
		stress_impact = {
			gregarious = major_stress_impact_loss
			shy = medium_stress_impact_gain
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = shy
					has_trait = callous
				}
				factor = 0
			}
		}
	}
	
	option = { # If it's a good relationship, sing their praises
		name = feast_events_flavor.0001.b
		trigger = {
			has_any_good_relationship_with_character_trigger = { CHARACTER = scope:relation_target }
		}
		add_prestige = minor_prestige_gain
		every_vassal_or_below = {
			limit = {
				this != scope:guest
				is_ai = yes
				has_vassal_stance = courtly 
				is_vassal_of = root
			}
			custom = every_participating_courtly_vassal
			add_opinion = {
				modifier = feast_had_good_talk
				target = root
				opinion = 10
			}
		}
		stress_impact = {
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
	
	option = { # If it's bad, double down
		name = feast_events_flavor.0001.c
		trigger = {
			has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:relation_target }
		}
		add_dread = minor_dread_gain
		set_relation_rival = {
			target = scope:guest
			reason = rival_insulted_dynasty
		}
		stress_impact = {
			callous = major_stress_impact_loss
			vengeful = major_stress_impact_loss
			wrathful = major_stress_impact_loss
			compassionate = major_stress_impact_gain
			craven = major_stress_impact_gain
			calm = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = wrathful
					has_trait = vengeful
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = compassionate
					has_trait = craven
					has_trait = calm
				}
				factor = 0
			}
		}
	}
	
	option = { # If it's bad, apologise
		name = feast_events_flavor.0001.d
		show_as_unavailable = {
			has_trait = callous # We show it but we don't even let you click it kekw
		}
		trigger = {
			has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:relation_target }
			NOT = { has_trait = callous }
		}
		if = {
			limit = { has_relation_rival = scope:relation_target }
			remove_relation_rival = scope:relation_target
		}
		else_if = {
			limit = { has_relation_nemesis = scope:relation_target }
			remove_relation_nemesis = scope:relation_target
		}
		else = {
			scope:relation_target = {
				add_opinion = {
					target = root
					modifier = apologized_opinion
					opinion = 25
				}
			}
		}
		stress_impact = {
			craven = major_stress_impact_loss
			vengeful = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = forgiving
				factor = 2
			}
			modifier = {
				has_trait = vengeful
				factor = 0
			}
		}
	}
	
	option = { # Enough talking about them
		name = feast_events_flavor.0001.e
		if = {
			limit = {
				has_any_good_relationship_with_character_trigger = { CHARACTER = scope:relation_target }
			}
			scope:guest = {
				add_opinion = {
					target = root
					modifier = feast_had_good_talk
					opinion = 10
				}
			}
		}
		else = {
			every_vassal_or_below = {
				limit = {
					this != scope:guest
					is_ai = yes
					has_vassal_stance = courtly 
					is_participant_in_activity = root.involved_activity
				}
				custom = every_participating_courtly_vassal
				add_opinion = {
					modifier = impressed_opinion
					target = root
					opinion = 10
				}
			}
		}
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
}

# A former rival reminisces with you
# By Jay Zaborowski
feast_events_flavor.0002 = {
	type = activity_event
	title = feast_events_flavor.0002.t
	desc = feast_events_flavor.0002.desc
	theme = feast_activity
	right_portrait = {
		character = root
		animation = laugh
	}
	left_portrait = {
		character = scope:former_rival
		animation = drink_goblet
	}
	cooldown = { years = 10 }
	
	trigger = {
		involved_activity = {
			any_attending_character = {
				NOT = { this = root }
				is_physically_able_ai_adult = yes
				any_memory = {
					OR = {
						has_memory_type = stopped_being_rivals
						has_memory_type = let_go_of_rivalry
					}
					memory_participant:rival = root
				}
			}
		}
	}

	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					NOT = { this = root }
					is_physically_able_ai_adult = yes
					any_memory = {
						OR = {
							has_memory_type = stopped_being_rivals
							has_memory_type = let_go_of_rivalry
						}
						memory_participant:rival = root
					}
				}
				save_scope_as = former_rival
				get_quirk_character_effect = yes
			}
		}
	}

	option = { # Seduce
		name = feast_events_flavor.0002.a
		trigger = {
			trigger_if = {
				limit = { is_married = yes }
				OR = {
					might_cheat_on_every_partner_trigger = yes
					is_ai = no # Players can do as they like
				}
			}
			OR = {
				has_trait = lustful
				has_trait = rakish
				has_trait = seducer
				has_trait = deviant
			}
			is_attracted_to_gender_of = scope:former_rival
			scope:former_rival = { is_attracted_to_gender_of = root }
		}
		trait = lustful
		trait = rakish
		trait = seducer
		trait = deviant
		had_sex_with_effect = { 
			CHARACTER = scope:former_rival 
			PREGNANCY_CHANCE = pregnancy_chance 
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:former_rival
			REASON = lover_distracting_sex
			OPINION = default_lover_opinion
		}
		stress_impact = {
			chaste = medium_stress_impact_gain
			celibate = major_stress_impact_gain
			vengeful = major_stress_impact_gain
			forgiving = medium_stress_impact_loss
		}
		ai_chance = {
			base = 200
		}
	}
	option = { # Become friends
		name = feast_events_flavor.0002.b
		trigger = { can_set_relation_friend_trigger = { CHARACTER = scope:former_rival } }
		set_relation_friend = { reason = friend_feast_recounted_rivalry target = scope:former_rival }
		stress_impact = {
			gregarious = major_stress_impact_loss
			forgiving = major_stress_impact_loss
			vengeful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = shy
					opinion = {
						value <= medium_negative_opinion
						target = scope:former_rival
					}
				}
			}
			modifier = {
				factor = 2
				has_trait = gregarious
			}
		}
	}
	option = { # Time to go back to old times - give prestige
		name = feast_events_flavor.0002.c
		trigger = { can_set_relation_rival_trigger = { CHARACTER = scope:former_rival } }
		set_relation_rival = { reason = rival_bad_chemistry target = scope:former_rival }
		add_prestige = medium_prestige_gain
		if = {
			limit = {
				OR = {
					faith = { trait_is_virtue = forgiving }
					faith = { trait_is_sin = vengeful }
				}
			}
			custom_tooltip = feast_events_flavor.0002.c.vengeful_sinful.tt #This will lose you piety because Forgiving is Virtuous or Vengeful is Sinful
			add_piety = major_piety_loss
		}
		if = {
			limit = {
				OR = {
					faith = { trait_is_sin = forgiving }
					faith = { trait_is_virtue = vengeful }
				}
			}
			custom_tooltip = feast_events_flavor.0002.c.forgiving_sinful.tt #This will lose you piety because Forgiving is Virtuous or Vengeful is Sinful
			add_piety = major_piety_gain
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
			vengeful = major_stress_impact_loss
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 10 # Not enough on its own to be Vengeful
				has_trait = vengeful
			}
			modifier = {
				add = 100
				opinion = {
					value <= medium_negative_opinion
					target = scope:former_rival
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = forgiving
					has_trait = craven # Isn't about to start a fight
				}
			}
		}
	}
	option = { # It feels good to turn the other cheek!
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							OR = {
								faith = { trait_is_virtue = forgiving }
								faith = { trait_is_sin = vengeful }
							}
						}
						desc = feast_events_flavor.0002.d.virtuous
					}
					desc = feast_events_flavor.0002.d
				}
			}
		}
		if = {
			limit = {
				OR = {
					faith = { trait_is_virtue = forgiving }
					faith = { trait_is_sin = vengeful }
				}
			}
			custom_tooltip = feast_events_flavor.0002.d.virtuous.tt # This option is available because Forgiving is Virtuous or Vengeful is Sinful
			add_piety = major_piety_gain
			add_character_modifier = { modifier = feast_turning_the_other_cheek_modifier years = 10 }
		}
		else_if = {
			limit = {
				NOR = {
					faith = { trait_is_sin = forgiving }
					faith = { trait_is_virtue = vengeful }
				}
			}
			add_piety = medium_piety_gain
		}
		reverse_add_opinion = {
			target = scope:former_rival
			modifier = friendliness_opinion
			opinion = 10
		}
		stress_impact = {
			base = minor_stress_impact_loss
			forgiving = medium_stress_impact_loss
		}
		ai_chance = {
			base = 150
		}
	}
}
