﻿
namespace = feast_default_alex

# Someone reminds you of a positive memory you share
feast_default_alex.100 = {
	type = activity_event
	title = feast_default_alex.100.t
	desc = feast_default_alex.100.desc
	theme = feast_activity
	right_portrait = {
		character = scope:guest
		animation = wedding_drunk
		camera = camera_event_very_right
	}
	center_portrait = {
		character = root
		animation = interested
	}
	left_portrait = {
		character = scope:other_guest
		animation = storyteller
		camera = camera_event_very_left
	}
	cooldown = { years = 10 }
	
	trigger = {
		scope:activity = {
			any_attending_character = {
				this != root
				is_physically_able_ai_adult = yes
				NOT = { has_relation_rival = root }
				any_memory = {
					has_memory_category = positive
					NOT = {
						has_memory_category = private
					}
					any_memory_participant = {
						this = root
					}
				}
				opinion = {
					target = root
					value > 0
				}
				save_temporary_scope_as = guest_temp
			}
			#There is a third attendee in existence
			any_attending_character = {
				count >= 2
				NOT = {
					this = root
				}
				opinion = {
					target = root
					value > 0
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 3
			has_activity_intent = befriend_attendee_intent
			intent_target ?= {
				involved_activity ?= root.involved_activity
				is_physically_able_ai_adult = yes
				NOT = { has_relation_rival = root }
				any_memory = {
					has_memory_category = positive
					any_memory_participant = {
						this = root
					}
					NOT = {
						has_memory_category = private
					}
				}
				opinion = {
					target = root
					value > 0
				}
			}
		}
	}

	immediate = {
		save_scope_as = root_scope
		scope:activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = {
					this != root
					is_physically_able_ai_adult = yes
					NOT = { has_relation_rival = root }
					any_memory = {
						has_memory_category = positive
						any_memory_participant = {
							this = root
						}
						NOT = {
							has_memory_category = private
						}
					}
					opinion = {
						target = root
						value > 0
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 1000
						root = {
							has_activity_intent = befriend_attendee_intent
						}
						root.intent_target ?= this
					}
					modifier = {
						add = 50
						has_relation_potential_friend = root
					}
					modifier = {
						add = 10
						is_of_major_interest_to_root_trigger = yes
					}
					modifier = {
						add = 5
						is_of_minor_interest_to_root_trigger = yes
					}
				}
				assign_quirk_effect = yes
				save_scope_as = guest
				random_memory = {
					limit = {
						has_memory_category = positive
						any_memory_participant = {
							this = root
						}
						NOT = {
							has_memory_category = private
						}
					}
					save_scope_as = guest_memory
				}
			}
			random_attending_character = {
				limit = {
					NOR = {
						this = root
						this = scope:guest
					}
					opinion = {
						target = root
						value > 0
					}
				}
				save_scope_as = other_guest
			}
		}
	}

	option = {
		trigger = {
			OR = {
				has_trait = arrogant
				has_trait = callous
				has_trait = sadistic
				has_trait = vengeful
				has_trait = wrathful
				has_trait = arbitrary
				has_trait = fickle
			}
			scope:guest = {
				NOR = {
					is_spouse_of = root
					is_close_family_of = root
					any_vassal = {
						this = root
					}
				}
			}
		}
		name = feast_default_alex.100.aa

		add_prestige = minor_prestige_gain

		reverse_add_opinion = {
			modifier = insulted_opinion
			target = scope:guest
			opinion = -30
		}
		scope:guest = {
			add_stress = medium_stress_gain
			add_prestige = medium_prestige_loss
		}
		stress_impact = {
			gregarious = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 3
			modifier = {
				factor = 0
				OR = {
					has_trait = gregarious
					has_trait = compassionate
					has_trait = humble
					has_trait = forgiving
				}
			}
		}
	}

	option = {
		name = feast_default_alex.100.a
		progress_towards_friend_effect = {
			REASON = friend_showed_personal_interest
			CHARACTER = scope:guest
			OPINION = 20
		}
		stress_impact = {
			gregarious = medium_stress_impact_loss
		}
	}

	option = {
		name = feast_default_alex.100.b

		add_diplomacy_lifestyle_xp = miniscule_lifestyle_xp
		
		stress_impact = {
			base = minor_stress_impact_loss
		}
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				stress <= 0
				has_focus_diplomacy = no
			}
		}
	}
}

# There's a terrible plague in a nearby realm
feast_default_alex.200 = {
	type = activity_event
	title = feast_default_alex.200.t
	desc = feast_default_alex.200.desc
	theme = feast_activity
	center_portrait = {
		character = root
		animation = drink_goblet
	}
	right_portrait = {
		character = scope:guest
		animation = worry
	}
	cooldown = { years = 10 }
	
	trigger = {
		scope:activity = {
			any_attending_character = {
				this != root
				is_physically_able_ai_adult = yes
				NOT = { has_relation_rival = root }
				top_liege = root.top_liege
				OR = {
					has_personality_emotional_trigger = yes
					has_personality_submissive_trigger = yes
				}
			}
		}
		any_epidemic = {
			save_temporary_scope_as = the_epidemic
			any_infected_province = {
				squared_distance = {
					target = root.location
					value <= squared_distance_large
				}
				exists = barony.holder.top_liege
			}
			NOT = {
				any_infected_province = {
					barony.holder.top_liege ?= root.involved_activity.activity_host.top_liege
				}
			}
		}
	}

	immediate = {
		save_scope_as = root_scope
		scope:activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = {
					this != root
					is_physically_able_ai_adult = yes
					NOT = { has_relation_rival = root }
					top_liege = root.top_liege
					OR = {
						has_personality_emotional_trigger = yes
						has_personality_submissive_trigger = yes
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 1000
						root = {
							has_activity_intent = befriend_attendee_intent
						}
						root.intent_target ?= this
					}
					modifier = {
						add = 50
						has_relation_potential_friend = root
					}
					modifier = {
						add = 10
						is_of_major_interest_to_root_trigger = yes
					}
					modifier = {
						add = 5
						is_of_minor_interest_to_root_trigger = yes
					}
				}
				assign_quirk_effect = yes
				save_scope_as = guest
			}
		}
		random_epidemic = {
			limit = {
				save_temporary_scope_as = the_epidemic
				any_infected_province = {
					squared_distance = {
						target = root.location
						value <= squared_distance_large
					}
					exists = barony.holder.top_liege
				}
				NOT = {
					any_infected_province = {
						barony.holder.top_liege ?= root.involved_activity.activity_host.top_liege
					}
				}
			}
			save_scope_as = epidemic
			random_infected_province = {
				limit = {
					squared_distance = {
						target = root.location
						value <= squared_distance_large
					}
					exists = barony.holder.top_liege
				}
				barony.holder.top_liege = { save_scope_as = afflicted_top_liege }
			}
		}
		hidden_effect = {
			create_character = {
				template = peasant_character
				dynasty = none
				location = root.location
				culture = root.location.culture
				faith = root.location.faith
				gender_female_chance = 50
				save_scope_as = sick_peasant
			}
			scope:sick_peasant = {
				add_trait = scope:epidemic.epidemic_type.epidemic_trait
			}
		}
	}

	option = {
		name = feast_default_alex.200.a
		trigger = {
			this = scope:activity.activity_host
			scope:activity.activity_location.county = {
				holder = scope:activity.activity_host
				NOT = {
					has_county_modifier = plague_preparations_modifier
				}
			}
		}
		remove_short_term_gold = miniscule_gold_value
		add_prestige = minor_prestige_gain
		scope:activity.activity_location.county = {
			add_county_modifier = {
				modifier = plague_preparations_modifier
				years = 10
			}
		}
		scope:guest = {
			add_opinion = {
				target = root
				modifier = thankful_opinion
				opinion = 20
			}
			stress_impact = {
				base = medium_stress_impact_loss
			}
		}
		stress_impact = {
			craven = medium_stress_impact_loss
			compassionate = medium_stress_impact_loss
			generous = medium_stress_impact_loss
		}
	}

	option = {
		name = feast_default_alex.200.b
		trigger = {
			has_activity_intent = befriend_attendee_intent
			intent_target ?= scope:guest
		}
		add_internal_flag = special
		progress_towards_friend_effect = {
			REASON = friend_supported_at_feast
			CHARACTER = scope:guest
			OPINION = 20
		}
		scope:guest = {
			stress_impact = {
				base = minor_stress_impact_loss
			}
		}
		stress_impact = {
			sadistic = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
			compassionate = medium_stress_impact_loss
		}
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				OR = {
					has_trait = sadistic
					has_trait = arbitrary
				}
			}
		}
	}

	option = {
		name = feast_default_alex.200.c
		add_piety = minor_piety_gain
		stress_impact = {
			zealous = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
			cynical = medium_stress_impact_gain
		}
		scope:guest = {
			stress_impact = {
				base = minor_stress_impact_loss
				cynical = minor_stress_impact_gain
			}
		}
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				has_trait = cynical
			}
		}
	}

	option = {
		name = feast_default_alex.200.d
		stress_impact = {
			base = minor_stress_impact_loss
		}
		scope:guest = {
			stress_impact = {
				base = minor_stress_impact_gain
			}
		}
	}
	
	after = {
		scope:sick_peasant = { silent_disappearance_effect = yes }
	}
}
