﻿namespace = ep2_locale_events

# Ask local blacksmith to remove a spell from you
# by Veronica Pazos
ep2_locale_events.4530 = {
	type = activity_event
	title = ep2_locale_events.4530.t
	desc = ep2_locale_events.4530.desc
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:tournament_weaponsmith
		animation = personality_bold
	}
	artifact = {
		trigger = { exists = scope:improved_weapon }
		target = scope:improved_weapon
		position = lower_center_portrait
	}
	cooldown = { years = 1 }

	trigger = {
		scope:activity = { # You have a weaponsmith
			has_active_locale = tournament_locale_artisans
			OR = {
				AND = {
					exists = var:tournament_weaponsmith
					var:tournament_weaponsmith = { is_alive = yes }
				}
				AND = {
					exists = var:tournament_armorer
					var:tournament_armorer = { is_alive = yes }
				}
			}
		}
		activity_tournament_prowess_contest_trigger = yes
	}

	immediate = {
		if = {
			limit = {
				scope:activity = {
					exists = var:tournament_weaponsmith
				}
			}
			scope:activity = {
				var:tournament_weaponsmith = { save_scope_as = tournament_weaponsmith }
			}
		}
		else = {
			scope:activity = {
				var:tournament_armorer = { save_scope_as = tournament_weaponsmith } #WAD
			}
		}
		if = {
			limit = {
				any_character_artifact = {
					artifact_slot_type = primary_armament
				}
			}
			random_character_artifact = {
				limit = { artifact_slot_type = primary_armament }
				weight = {
					base = 1
					modifier = {
						add = 2
						is_equipped = yes
					}
					modifier = {
						add = 1
						OR = {
							rarity = illustrious
							rarity = famed
							rarity = masterwork
						}
					}
				}
				save_scope_as = improved_weapon
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_trait = paranoid
		}
		modifier = {
			factor = 2
			has_trait = wounded
		}
		modifier = {
			factor = 2
			has_activity_intent = win_contest_intent
		}
	}

	# Please break this spell and make me win
	option = {
		name = ep2_locale_events.4530.a
		trigger = {
			culture = {
				NOT = { has_cultural_era_or_later = culture_era_late_medieval } #I'm sorry, but I'm gonna have to time gate this; this is based on real beliefs that didn't make it past the high MAs
			}
			activity_is_competing_trigger = yes
		}
		random = {
			chance = 50
			activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		}
		if = {
			limit = { NOT = { has_character_modifier = bp1_superstition_modifier } }
			random = {
				chance = 25
				send_interface_toast = {
					title = ep2_locale_events.4530.a.tt
					left_icon = root
					add_character_modifier = {
						modifier = bp1_superstition_modifier
					}
				}
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
			brave = medium_stress_impact_gain
			zealous = major_stress_impact_gain #this would imply acknowledging magic is a thing
			cynical = major_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_trait = paranoid
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = zealous
					has_trait = brave
					has_trait = cynical
					has_trait = witch #you know better
				}
			}
		}
	}

	# Can you teach me how to use this weapon?
	option = {
		name = ep2_locale_events.4530.b
		stress_impact = {
			calm = medium_stress_impact_gain
			craven = medium_stress_impact_gain
			paranoid = major_stress_impact_gain
		}
		if = {
			limit = { activity_is_competing_trigger = yes }
			random = {
				chance = 50
				activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
			}
		}
		scope:tournament_weaponsmith = {
			duel = {
				skill = martial
				value = average_skill_rating
				5 = {
					desc = ep2_locale_events.4530.b.crit_success
					modifier = {
						add = -50
						root = {
							is_ai = yes #to prevent the AI from abusing it
						}
					}
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4530.b.crit_success
							left_icon = root
							add_prowess_skill = 2
						}
					}
				}
				65 = {
					desc = ep2_locale_events.4530.b.success
					modifier = {
						add = 20
						scope:tournament_weaponsmith = {
							OR = {
								prowess >= high_skill_rating
								martial >= high_skill_rating
							}
						}	
					}
					modifier = {
						add = -50
						root = {
							is_ai = yes #to prevent the AI from abusing it
						}
					}
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4530.b.success
							left_icon = root
							add_prowess_skill = 1
						}
					}
				}
				30 = {
					desc = ep2_locale_events.4530.b.failure
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4530.b.failure
							left_icon = root
							increase_wounds_effect = {
								REASON = accident
							}
						}
					}
				}
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = craven
					has_trait = paranoid
				}
			}
		}
	}
	
	# I have this really cool weapon, improve?
	option = {
		name = ep2_locale_events.4530.c
		trigger = {
			exists = scope:improved_weapon
		}
		scope:improved_weapon = {
			add_durability = 10
			custom_tooltip = {
				text = ep2_locale_events.4530.c.tt
				add_artifact_modifier = artifact_prowess_1_modifier
			}
			set_artifact_description = improved_artifact_desc
		}
		create_character_memory = {
			type = tournament_improved_blade_memory
		}
		stress_impact = {
			paranoid = major_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = paranoid
			}
		}
	}
	
	# If you're wounded pls fix me
	option = {
		name = ep2_locale_events.4530.d
		trigger = {
			has_trait = wounded
		}
		scope:tournament_weaponsmith = {
			duel = {
				skill = learning
				value = average_skill_rating
				75 = {
					desc = ep2_locale_events.4530.d.success
					modifier = {
						add = 20
						scope:tournament_weaponsmith = {
							OR = {
								has_trait = whole_of_body
								has_trait = lifestyle_physician
							}
						}
					}
					modifier = {
						add = 20
						scope:tournament_weaponsmith = {
							learning >= high_skill_rating
						}
					}
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4530.d.success
							left_icon = root
							change_trait_rank = {
								trait = wounded
								rank = -1
								max = 1
							}
						}
					}
				}
				25 = {
					desc = ep2_locale_events.4530.d.nothing
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4530.d.nothing
							left_icon = root
						}
					}
				}
				25 = {
					desc = ep2_locale_events.4530.b.failure
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4530.b.failure
							left_icon = root
							increase_wounds_effect = {
								REASON = accident
							}
						}
					}
				}
			}
		}
		stress_impact = {
			cynical = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			patient = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = cynical
					has_trait = callous
					has_trait = patient
				}
			}
		}
	}
	
	# Opt out in case you can only choose one option of the above
	option = {
		name = ep2_locale_events.4530.e
		trigger = {
			NOT = { exists = scope:improved_weapon }
		}
		stress_impact = {
			paranoid = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = paranoid
			}
		}
	}
}

# You visit the town and notice ANCIENT LANGUAGE inscriptions in some buildings
# by Veronica Pazos
ep2_locale_events.5500 = {
	type = activity_event
	title = ep2_locale_events.5500.t
	desc = ep2_locale_events.5500.desc
	theme = tournament_locale_village
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = { exists = scope:impressed_target }
		character = scope:impressed_target
		animation = flirtation
	}
	artifact = {
		target = scope:ancient_plaque
		position = lower_center_portrait
	}

	cooldown = { years = 1 }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_settlement
		}
	}

	immediate = {
		if = {
			limit = {
				OR = {
					has_activity_intent = woo_attendee_intent
					has_activity_intent = befriend_attendee_intent
				}
				intent_target ?= { is_alive = yes }
			}
			intent_target = { save_scope_as = impressed_target }
		}
		hidden_effect = {
			create_artifact = {
				name = ancient_stone_artifact
				description = ancient_stone_artifact_desc
				type = miscellaneous
				visuals = rock
				modifier = artifact_monthly_prestige_1_modifier
				save_scope_as = ancient_plaque
			}
			scope:ancient_plaque = {
				flag_as_trash_artifact = yes
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			scope:activity = {
				OR = {
					has_current_phase = tournament_phase_recital
					has_current_phase = tournament_phase_board_game
				}
			}
		}
		modifier = {
			factor = 2
			OR = {
				has_activity_intent = win_contest_intent
				has_activity_intent = woo_attendee_intent
				has_activity_intent = befriend_attendee_intent
			}
		}
	}

	# flex the language
	option = {
		name = {
			trigger = {
				location = {
					geographical_region = custom_roman_full_borders
				}
			}
			text = ep2_locale_events.5500.a.rome
		}
		name = {
			trigger = {
				location = {
					NOT = { geographical_region = custom_roman_full_borders }
				}
			}
			text = ep2_locale_events.5500.a.fallback
		}
		trigger = {
			learning >= average_skill_rating 
		}
		show_as_unavailable = {
			learning < average_skill_rating
		}
		if = {
			limit = {
				scope:activity = { #mind contests
					OR = {
						has_current_phase = tournament_phase_recital
						has_current_phase = tournament_phase_board_game
					}
				}
				activity_is_competing_trigger = yes
			}
			activity_tournament_change_contestant_score_effect = { SCORE = increase_major }
		}
		add_prestige = medium_prestige_gain
		if = {
			limit = {
				exists = scope:impressed_target
				has_activity_intent = woo_attendee_intent 
				can_set_relation_lover_trigger = { CHARACTER = scope:impressed_target }
			}
			progress_towards_lover_effect = {
				CHARACTER = scope:impressed_target
				REASON = friend_impressed_stones
				OPINION = default_lover_opinion
			}
		}
		else_if = {
			limit = {
				exists = scope:impressed_target
				has_activity_intent = befriend_attendee_intent 
				can_set_relation_friend_trigger = { CHARACTER = scope:impressed_target }
			}
			set_relation_friend = {
				reason = friend_impressed_stones
				target = scope:impressed_target
			}
		}
		else_if = {
			limit = { exists = scope:impressed_target }
			scope:impressed_target = {
				add_opinion = {
					target = root
					modifier = admiration_opinion
					opinion = 20
				}
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = humble
			}
		}
	}

	# take the stone back home lol
	option = {
		name = ep2_locale_events.5500.b
		scope:ancient_plaque = { set_owner = root }
		stress_impact = {
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
				ai_rationality = -1
			}
		}
	}
	
	# leave it be
	option = {
		name = ep2_locale_events.5500.c
		capital_county = { change_development_progress = minor_development_progress_gain }
		stress_impact = {
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			eccentric = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
				ai_rationality = -1
			}
		}
	}
}

# Your child wants to become a knight
# by Veronica Pazos

scripted_trigger ep2_locale_events_5000_child_trigger = {
	is_participant_in_activity = scope:activity
	age < 15
	is_ai = yes
	is_physically_able = yes
	NOT = { has_trait = pensive }
	NOT = { has_trait = craven }
}

scripted_effect ep2_locale_events_5000_martial_effect = {
	scope:my_child = {
		if = {
			limit = {
				has_focus_martial = yes
			}
			add_martial_skill = 2
		}
		else = {
			set_focus = education_martial
			add_martial_skill = 1
		}
	}
	add_prestige = minor_prestige_gain
	every_vassal = {
		vassal_stance = glory_hound
		limit = {
			is_participant_in_activity = scope:activity
		}
		custom = every_glory_hound_vassal
		add_opinion = {
			target = root
			modifier = pleased_opinion
			opinion = 10
		}
	}
}

scripted_effect ep2_locale_events_5000_guardian_effect = {
	if = {
		limit = {
			scope:my_child = {
				any_relation = { type = guardian }
			}
		}
		scope:my_child = {
			every_relation = {
				type = guardian
				remove_guardian_effect = {
					GUARDIAN = this
					WARD = scope:my_child
					RETURN_WARD = no
					HIDE_OPINION = no
				}
			}
		}
	}
}

ep2_locale_events.5000 = {
	type = activity_event
	title = ep2_locale_events.5000.t
	desc = { 
		desc = ep2_locale_events.5000.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:my_child = {
						OR = {
							has_education_martial_trigger = yes
							has_focus_martial = yes
						}
					}
				}
				desc = ep2_locale_events.5000.desc.martial
			}
			triggered_desc = {
				trigger = {
					scope:my_child = {
						NOR = {
							has_education_martial_trigger = yes
							has_focus_martial = yes
						}
					}
				}
				desc = ep2_locale_events.5000.desc.non_martial
			}
		}
	}
	theme = tournament_grounds
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:my_child
		animation = admiration
	}
	lower_center_portrait = {
		character = scope:my_knight
	}
	cooldown = { years = 1 }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_tournament_grounds
			NOR = {
				has_current_phase = tournament_phase_recital
				has_current_phase = tournament_phase_board_game
			}
		}
		any_child = {
			ep2_locale_events_5000_child_trigger = yes
		}
		any_knight = {
			is_participant_in_activity = scope:activity
		}
	}

	immediate = {
		save_scope_as = root_scope
		random_child = {
			limit = { ep2_locale_events_5000_child_trigger = yes }
			weight = {
				base = 1
				modifier = {
					add = 2
					has_trait = bossy
				}
				modifier = {
					add = 1
					has_trait = rowdy
				}
			}
			save_scope_as = my_child
		}
		random_knight = {
			limit = {
				is_participant_in_activity = scope:activity
			}
			weight = {
				base = 1
				modifier = {
					add = 2
					martial >= high_skill_rating
				}
				modifier = {
					add = 1
					prowess >= high_skill_rating
				}
			}
			save_scope_as = my_knight
		}
		scope:my_knight = {
			add_character_flag = wear_armor
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			scope:activity = {	
				OR = {
					has_current_phase = tournament_phase_duel
					has_current_phase = tournament_phase_joust
				}
			}
		}
		modifier = {
			factor = 2
			OR = {
				has_activity_intent = woo_attendee_intent
				has_activity_intent = befriend_attendee_intent
			}
		}
	}

	# sure
	option = {
		name = ep2_locale_events.5000.a
		ep2_locale_events_5000_martial_effect = yes
		if = { #if you can train them you do
			limit = { 
				has_lifestyle = martial_lifestyle
			}
			ep2_locale_events_5000_guardian_effect = yes
			scope:my_child = {
				set_relation_guardian = root
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			calm = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = callous
					has_trait = calm
				}
			}
		}
	}

	# sure and YOU are gonna be their ward
	option = {
		name = ep2_locale_events.5000.b
		ep2_locale_events_5000_martial_effect = yes
		ep2_locale_events_5000_guardian_effect = yes
		scope:my_child = {
			set_relation_guardian = scope:my_knight
		}
		scope:my_knight = {
			accolade_minor_glory_gain_with_checks_effect = yes
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			calm = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = callous
					has_trait = calm
				}
			}
		}
	}
	
	# no way
	option = {
		name = ep2_locale_events.5000.c
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		}
		education_point_acquisition_effect = yes
		scope:my_child = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		if = {
			limit = {
				scope:my_child = { NOT = { has_trait = rowdy } }
			}
			random = {
				chance = 30
				scope:my_child = {
					remove_childhoood_traits_effect = yes
					add_trait = rowdy
				}
			}
		}			
		stress_impact = {
			compassionate = medium_stress_impact_gain
			brave = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = brave
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					has_trait = gallant
					has_trait = wrathful
				}
			}
		}
	}
	after = {
		scope:my_knight = {
			remove_character_flag = wear_armor
		}
	}
}

# You visit the tourney grounds and are filled with DETERMINATION / Repeatable
# by Veronica Pazos
ep2_locale_events.5010 = {
	type = activity_event
	title = ep2_locale_events.5010.t
	desc = {
		desc = ep2_locale_events.5010.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { activity_tournament_prowess_contest_trigger = yes }
				desc = ep2_locale_events.5010.desc.prowess
			}
			triggered_desc = {
				trigger = { activity_tournament_mind_contest_trigger = yes }
				desc = ep2_locale_events.5010.desc.mind
			}
			desc = ep2_locale_events.5010.desc.fallback
		}
		desc = ep2_locale_events.5010.desc.outro
	}
	theme = tournament_grounds
	left_portrait = {
		character = root
		animation = personality_honorable
	}

	trigger = {
		activity_is_competing_trigger = yes
		scope:activity = { 
			has_active_locale = tournament_locale_tournament_grounds
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_activity_intent = win_contest_intent
		}
		modifier = {
			factor = 2
			any_memory = {
				has_memory_category = tournament
				memory_age_years > 1
			}
		}
	}

	# I can feel the power - practice
	option = {
		name = ep2_locale_events.5010.a 
		if = {
			limit = { activity_tournament_prowess_contest_trigger = yes }
			duel = {
				skills = { martial prowess }
				value = average_skill_rating
				50 = {
					desc = ep2_locale_events.5010.a.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
					}
					send_interface_toast = {
						title = ep2_locale_events.5010.a.success
						left_icon = root
						activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
					}
				}
				50 = {
					desc = ep2_locale_events.5010.a.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
					}
					send_interface_toast = {
						title = ep2_locale_events.5010.a.failure
						left_icon = root
						every_vassal = {
							vassal_stance = glory_hound
							limit = {
								is_participant_in_activity = scope:activity
							}
							add_opinion = {
								target = root
								modifier = weak_opinion
								opinion = -5
							}
						}
					}
				}
			}
		}
		else = {
			duel = {
				skills = { learning diplomacy }
				value = average_skill_rating
				50 = {
					desc = ep2_locale_events.5010.a.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
					}
					send_interface_toast = {
						title = ep2_locale_events.5010.a.success
						left_icon = root
						activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
					}
				}
				50 = {
					desc = ep2_locale_events.5010.a.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
					}
					send_interface_toast = {
						title = ep2_locale_events.5010.a.failure
						left_icon = root
						every_vassal = {
							vassal_stance = courtly
							limit = {
								is_participant_in_activity = scope:activity
							}
							add_opinion = {
								target = root
								modifier = weak_opinion
								opinion = -5
							}
						}
					}
				}
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_energy = 1
				ai_boldness = 1
			}
		}
	}

	# I remember when I was in another tournament
	option = {
		name = {
			trigger = { 
				any_memory = {
					has_memory_category = tournament
					has_memory_category = positive
					memory_age_years >= 1
				}
			}
			text = ep2_locale_events.5010.b.good
		}
		name = {
			trigger = {
				any_memory = {
					has_memory_category = tournament
					has_memory_category = negative
					memory_age_years >= 1
				}
			}
			text = ep2_locale_events.5010.b.bad
		}
		trigger = {
			any_memory = {
				has_memory_category = tournament
				memory_age_years >= 1
			}
		}
		flavor = ep2_locale_events.5010.b.flavor
		add_prestige = medium_prestige_gain
		stress_impact = {
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_rationality = 1
				ai_vengefulness = 0.5
			}
		}
	}
	
	# What are you looking at??
	option = {
		name = ep2_locale_events.5010.c 
		trigger = {
			NOR = { 
				has_trait = calm
				has_trait = humble
				has_trait = compassionate
			}
		}
		show_as_unavailable = {
			OR = {
				has_trait = calm
				has_trait = humble
				has_trait = compassionate
			}
		}
		duel = { #intimidation roll
			skills = { prowess intrigue }
			value = average_skill_rating
			50 = {
				desc = ep2_locale_events.5010.c.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				send_interface_toast = {
					title = ep2_locale_events.5010.c.success
					left_icon = root
					activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
					add_dread = medium_dread_gain
				}
			}
			50 = {
				desc = ep2_locale_events.5010.c.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				send_interface_toast = {
					title = ep2_locale_events.5010.c.failure
					left_icon = root
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			calm = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				OR = {
					has_trait = vengeful
					has_trait = wrathful
					has_trait = callous
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = calm
					has_trait = craven
					has_trait = gregarious
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					has_trait = arrogant
					has_trait = brave
				}
			}
		}
	}
	
	# Leave
	option = {
		name = ep2_locale_events.5010.d
		trigger = {
			NOT = {
				any_memory = { 
					has_memory_category = tournament
				}
			}
		}
		add_prestige = miniscule_prestige_loss
		stress_impact = {
			arrogant = medium_stress_impact_gain
			brave = medium_stress_impact_gain
			vengeful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = brave
					has_trait = vengeful
				}
			}
		}
	}
}

# You see a street fight
# by Veronica Pazos

scripted_trigger ep2_locale_events_5510_valid_fighter = {
	is_physically_able_ai_adult = yes
	prowess >= medium_skill_rating
}

ep2_locale_events.5510 = {
	type = activity_event
	title = ep2_locale_events.5510.t
	desc = ep2_locale_events.5510.desc
	theme = tournament_locale_village
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:village_thug
		animation = rage
	}
	cooldown = { years = 1 }
	override_background = { reference = alley_day }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_settlement
			any_attending_character = {
				count < 240 #Max is 250 but attendence is open so leaving some space.
			}
		}
		activity_tournament_prowess_contest_trigger = yes #it wouldn't make sense to get this for board games etc
	}

	immediate = {
		if = {
			limit = {
				any_pool_character = {
					province = root.location
					ep2_locale_events_5510_valid_fighter = yes
				}
			}
			random_pool_character = {
				province = root.location
				limit = { ep2_locale_events_5510_valid_fighter = yes }
				save_scope_as = village_thug
			}
		}
		else = {
			create_character = {
				template = bandit_character
				location = root.location
				dynasty = none
				culture = root.location.county.culture
				faith = root.location.county.faith
				save_scope_as = village_thug
				after_creation = {
					add_character_flag = created
				}
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			OR = {
				has_activity_intent = win_contest_intent
				has_activity_intent = recruit_knights_intent
			}
		}
	}

	# Hire the guy 
	option = {
		name = ep2_locale_events.5510.a 
		duel = {
			skill = diplomacy
			value = average_skill_rating
			50 = {
				desc = ep2_locale_events.5510.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				send_interface_toast = {
					title = ep2_locale_events.5510.a.success
					left_icon = root
					right_icon = scope:village_thug
					add_courtier = scope:village_thug
					scope:village_thug = {
						hidden_effect = {
							if = {
								limit = {
									NOT = { is_participant_in_activity = scope:activity }
									can_join_activity = scope:activity
								}
								add_to_activity = scope:activity
							}
						}
						root = {
							custom_tooltip = obligation_hook_tt
							add_hook = {
								type = obligation_hook
								target = scope:village_thug
							}
						}
					}
				}
			}
			50 = {
				desc = ep2_locale_events.5510.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				send_interface_toast = {
					title = ep2_locale_events.5510.a.failure
					left_icon = root
					right_icon = scope:village_thug
				}
			}
		}
		add_prestige = minor_prestige_loss #you're asking a lowborn to join your court
		stress_impact = {
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_energy = 1
				ai_boldness = 1
			}
		}
	}

	# Take notes
	option = {
		name = ep2_locale_events.5510.b
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		}
		else_if = {
			limit = { has_lifestyle = martial_lifestyle }
			add_martial_lifestyle_xp = medium_lifestyle_xp
		}
		else = {
			random_list = {
				20 = {
					trigger = { NOT = { has_trait = reckless } }
					add_trait = reckless
				}
				80 = {
					trigger = { is_ai = no }
					add_prowess_skill = 1
				}
			}
		}
		scope:village_thug = {
			accolade_minimal_glory_gain_with_checks_effect = yes
		}
		
		stress_impact = {
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_rationality = 1
				ai_vengefulness = 0.5
			}
		}
	}
	
	# Stop right now!
	option = {
		name = ep2_locale_events.5010.c 
		location.county = { #county control
			add_county_modifier = {
				modifier = tournament_stopped_peasant_fight
				years = 15
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			calm = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = calm
					has_trait = craven
					has_trait = gregarious
				}
			}
		}
	}
	after = {
		scope:village_thug = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

# You hear some women weaving and gossiping
# by Veronica Pazos

scripted_trigger ep2_locale_events_5520_valid_weaver = { #non martial gender etc
	is_physically_able_ai_adult = yes
	trigger_if = {
		limit = { faith = { has_doctrine = doctrine_gender_female_dominated } }
		is_male = yes 
	}
	trigger_else = { 
		is_female = yes
	}
}

scripted_trigger ep2_locale_events_5520_valid_contestant = {
	this != root
	is_physically_able_ai_adult = yes
	NOT = {
		has_any_good_relationship_with_character_trigger = { CHARACTER = root }
	}
	any_secret = { #and they have a secret
		NOT = { any_secret_knower = { this = root } }
	}
	save_temporary_scope_as = valid_contestant_temp
	scope:activity = {
		any_guest_subset_current_phase = { #they're participating
			name = contestant
			this = scope:valid_contestant_temp
		}
	}
}

ep2_locale_events.5520 = {
	type = activity_event
	title = ep2_locale_events.5520.t
	desc = ep2_locale_events.5520.desc
	theme = tournament_locale_village
	left_portrait = {
		character = scope:village_woman
		animation = scheme
	}
	right_portrait = {
		character = root
		animation = eavesdrop
	}
	lower_center_portrait = scope:gossip_knight
	cooldown = { years = 1 }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_settlement
		}
		scope:activity = {
			any_attending_character = {
				ep2_locale_events_5520_valid_contestant = yes
			}
		}
	}

	immediate = {
		if = {
			limit = {
				any_pool_character = {
					province = root.location
					ep2_locale_events_5520_valid_weaver = yes
				}
			}
			random_pool_character = {
				province = root.location
				limit = { ep2_locale_events_5520_valid_weaver = yes }
				save_scope_as = village_woman
			}
		}
		else = { #non martial gender etc
			create_character = {
				template = generic_peasant_character
				location = root.location
				dynasty = none
				culture = root.location.county.culture
				faith = root.location.county.faith
				gender_female_chance = {
					if = {
						limit = { root.faith = { has_doctrine = doctrine_gender_male_dominated } }
						add = 100
					}
					else_if = {
						limit = { root.faith = { has_doctrine = doctrine_gender_female_dominated } }
						add = 0
					}
					else = {
						add = 50
					}
				}
				save_scope_as = village_woman
				after_creation = {
					add_character_flag = created
				}
			}
		}
		scope:activity = {
			random_attending_character = {
				limit = {
					ep2_locale_events_5520_valid_contestant = yes
				}
				save_scope_as = gossip_knight
				random_secret = {
					limit = {
						NOT = { any_secret_knower = { this = root } }
					}
					save_scope_as = gossip_secret
				}
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			OR = {
				has_activity_intent = win_contest_intent
				has_activity_intent = recruit_knights_intent
			}
		}
	}

	# What are you saying about that guy?
	option = {
		name = ep2_locale_events.5520.a 
		duel = {
			skill = diplomacy
			value = average_skill_rating
			50 = {
				desc = ep2_locale_events.5520.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				custom_tooltip = ep2_locale_events.5520.a.success.tt
				hidden_effect = { #to hide the secret from the tt
					send_interface_toast = {
						title = ep2_locale_events.5520.a.success
						left_icon = scope:village_woman
						right_icon = scope:gossip_knight
						scope:gossip_secret = { reveal_to = root }
					}
				}
			}
			50 = {
				desc = ep2_locale_events.5520.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				send_interface_toast = {
					title = ep2_locale_events.5520.a.failure
					left_icon = root
					right_icon = scope:village_woman
					scope:village_woman = {
						add_opinion = {
							target = root
							modifier = annoyed_opinion
							opinion = -10
						}
					}
				}
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_energy = 1
				ai_boldness = 1
			}
		}
	}

	# Learn from them
	option = {
		name = ep2_locale_events.5520.b
		if = {
			limit = {
				activity_is_competing_trigger = yes
				activity_tournament_mind_contest_trigger = yes
			}
			activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		}
		else_if = {
			limit = {
				location.county = {
					holder ?= { this = root }
				}
			}
			location.county = { #popular opinion
				add_county_modifier = {
					modifier = tournament_supported_weavers
					years = 20
				}
			}
		}
		else_if = {
			limit = { has_lifestyle = learning_lifestyle }
			add_learning_lifestyle_xp = major_lifestyle_xp
		}
		else = { add_learning_lifestyle_xp = medium_lifestyle_xp }
		stress_impact = {
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_rationality = 1
				ai_vengefulness = 0.5
			}
		}
	}
	
	# Great industry, can you pay more taxes, pls?
	option = {
		name = ep2_locale_events.5520.c 
		trigger = {
			location.county = {
				NOT = { has_county_modifier = tournament_weaving_taxes_modifier }
				holder ?= { this = root }
			}
		}
		location.county = {
			add_county_modifier = {
				modifier = tournament_weaving_taxes_modifier
				years = 10
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			calm = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = calm
					has_trait = craven
					has_trait = gregarious
				}
			}
		}
	}
	
	# None of my business
	option = {
		name = ep2_locale_events.5520.d
		stress_impact = {
			compassionate = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			calm = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = calm
					has_trait = craven
					has_trait = gregarious
				}
			}
		}
	}
	after = {
		scope:village_woman = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

# You try to poach a counselor
# by Veronica Pazos

scripted_trigger ep2_locale_events_5030_valid_counselor = {
	is_physically_able_ai_adult = yes
	is_councillor = yes
	has_any_high_skill_rating = yes
	is_ruler = no
	NOT = { has_council_position = councillor_court_chaplain } #let's not poach bishops
	liege ?= { is_ai = yes } #we don't want to steal councillors from the players
	liege = { save_temporary_scope_as = temporary_liege }
	liege != root
	NOT = { is_spouse_of = scope:temporary_liege } #we don't wanna steal their spouse
	NOT = { is_heir_of = scope:temporary_liege } #or their heirs
}

scripted_effect ep2_locale_events_5030_employ_effect = {
	scope:councillor_employer = {
		add_opinion = {
			target = root
			modifier = angry_opinion
			opinion = -25
		}
	}
	add_courtier = scope:poached_councillor
}

ep2_locale_events.5030 = {
	type = activity_event
	title = ep2_locale_events.5030.t
	desc = {
		desc = ep2_locale_events.5030.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity = {
						any_guest_subset_current_phase = { #they're participating
							name = contestant
							this = scope:poached_councillor					
						}
					}
				}
				desc = ep2_locale_events.5030.desc.contestant
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						NOT = {
							any_guest_subset_current_phase = { #they're not participating
								name = contestant
								this = scope:poached_councillor					
							}
						}
					}
				}
				desc = ep2_locale_events.5030.desc.fallback
			}
		}
		desc = ep2_locale_events.5030.desc.outro
	}
	theme = tournament_grounds
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = just
					has_trait = loyal
				}
			}
			animation = personality_honorable
		}
		animation = scheme
	}
	right_portrait = {
		character = scope:poached_councillor
		animation = personality_content
	}
	lower_center_portrait = scope:councillor_employer
	cooldown = { years = 1 }
	override_background = { reference = army_camp }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_tournament_grounds
			any_attending_character = {
				ep2_locale_events_5030_valid_counselor = yes
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = { ep2_locale_events_5030_valid_counselor = yes }
				weight = {
					base = 1
					modifier = {
						add = 10
						liege = scope:host
					}
					modifier = {
						add = 7
						liege = { is_powerful_vassal_of = root }
					}
					modifier = {
						add = 4
						liege = { is_vassal_of = root }
					}
				}
				save_scope_as = poached_councillor
				liege = { save_scope_as = councillor_employer }
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			scope:activity = { 
				any_attending_character = {
					ep2_locale_events_5030_valid_counselor = yes
					employer = scope:host
				}
			}
		}
	}

	# Offer them money
	option = {
		name = ep2_locale_events.5030.a 
		pay_short_term_gold = {
			target = scope:poached_councillor
			gold = {
				value = medium_gold_value
				max = 30
			}
		}
		custom_tooltip = obligation_hook_tt
		add_hook = {
			type = obligation_hook
			target = scope:poached_councillor
		}
		ep2_locale_events_5030_employ_effect = yes
		stress_impact = {
			greedy = medium_stress_impact_gain
			just = medium_stress_impact_gain
			loyal = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = just
					has_trait = loyal
				}
			}
		}
	}

	# Intimidate them
	option = {
		name = ep2_locale_events.5030.b
		duel = {
			skills = { prowess intrigue }
			target = scope:poached_councillor
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep2_locale_events.5030.b.success
				send_interface_toast = {
					title = ep2_locale_events.5030.b.success
					left_icon = scope:poached_councillor
					add_courtier = scope:poached_councillor
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.5030.b.failure
				send_interface_toast = {
					title = ep2_locale_events.5030.b.failure
					left_icon = scope:poached_councillor
					scope:poached_councillor = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -20
						}
					}
				}
			}
		}
		scope:councillor_employer = { #they dislike you for trying
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -25
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			loyal = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = just
					has_trait = loyal
				}
			}
		}
	}
	
	# Offer them prestige
	option = {
		name = ep2_locale_events.5030.c 
		trigger = {
			prestige >= scope:councillor_employer.prestige
		}
		duel = {
			skill = diplomacy
			target = scope:poached_councillor
			70 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep2_locale_events.5030.b.success
				send_interface_toast = {
					title = ep2_locale_events.5030.b.success
					left_icon = scope:poached_councillor
					add_courtier = scope:poached_councillor
				}
			}
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.5030.b.failure
				send_interface_toast = {
					title = ep2_locale_events.5030.b.failure
					left_icon = scope:poached_councillor
					scope:poached_councillor = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -20
						}
					}
				}
			}
		}
		scope:councillor_employer = { #they dislike you for trying
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -25
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			just = medium_stress_impact_gain
			loyal = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = just
					has_trait = loyal
				}
			}
		}
	}
	
	# Appeal to your good relation
	option = {
		name = ep2_locale_events.5030.d
		trigger = {
			has_any_good_relationship_with_character_trigger = { CHARACTER = scope:poached_councillor }	
		}
		ep2_locale_events_5030_employ_effect = yes
		stress_impact = {
			callous = medium_stress_impact_gain
			just = medium_stress_impact_gain
			loyal = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = just
					has_trait = loyal
				}
			}
		}
	}
	
	# I don't wanna offend their liege
	option = {
		name = ep2_locale_events.5030.e
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		}
		scope:councillor_employer = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 25
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_gain
			disloyal = major_stress_impact_gain
			loyal = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = ambitious
					has_trait = disloyal
				}
			}
		}
	}
}

# People are doing a group dance in the middle of the square
# by Veronica Pazos

ep2_locale_events.5530 = {
	type = activity_event
	title = ep2_locale_events.5530.t
	desc = ep2_locale_events.5530.desc
	theme = tournament_locale_village
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			animation = boredom
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = drunkard
					has_trait = gregarious
					has_trait = gluttonous
				}
			}
			animation = toast_goblet
		}
		animation = admiration
	}
	right_portrait = {
		character = scope:random_peasant
		animation = dancing
	}
	cooldown = { years = 1 }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_settlement
		}
	}

	immediate = {
		play_music_cue = "mx_cue_in_taberna_instrumental"
		if = {
			limit = {
				any_pool_character = {
					province = root.location
					is_lowborn = yes
				}
			}
			random_pool_character = {
				province = root.location
				limit = { is_lowborn = yes }
				save_scope_as = random_peasant
			}
		}
		else = {
			create_character = {
				location = root.location
				culture = root.location.culture
				faith = root.location.faith
				template = peasant_character
				gender_female_chance = 50
				save_scope_as = random_peasant
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_activity_intent = reduce_stress_intent
		}
	}

	# Join
	option = {
		name = ep2_locale_events.5530.a 
		trigger = {
			location = {
				county = { holder = root }
			}
		}
		location.county = {
			add_county_modifier = {
				modifier = tournament_village_dance_modifier #popular opinion
				years = 20
			}
		}
		add_prestige = medium_prestige_loss
		stress_impact = {
			base = medium_stress_impact_loss
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = shy
				}
			}
		}
	}
	
	# Join and I'll show you how it's done 
	option = {
		name = ep2_locale_events.5530.b
		trigger = {
			location = {
				county = { holder != root }
			}
		}
		duel = {
			skill = diplomacy
			value = average_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep2_locale_events.5530.b.success
				send_interface_toast = {
					title = ep2_locale_events.5530.b.success
					left_icon = root
					add_prestige = medium_prestige_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.5530.b.failure
				send_interface_toast = {
					title = ep2_locale_events.5530.b.failure
					left_icon = root
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = shy
				}
			}
		}
	}

	# These moves remind me of the dance of BATTLE
	option = {
		name = ep2_locale_events.5530.c
		flavor = ep2_locale_events.5530.c.flavor
		trigger = {
			activity_tournament_prowess_contest_trigger = yes
			has_focus_or_focus_trait_trigger = { FOCUS = martial_chivalry_focus } #includes gallant
			activity_is_competing_trigger = yes
		}
		activity_tournament_change_contestant_score_effect = { SCORE = increase_major }
		stress_impact = {
			base = minor_stress_impact_loss
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = shy
				}
			}
		}
	}
	
	# If it's a recital get inspired
	option = {
		name = ep2_locale_events.5530.d
		trigger = {
			scope:activity = {
				has_current_phase = tournament_phase_recital
			}
			activity_is_competing_trigger = yes
		}
		activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		stress_impact = {
			lazy = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = callous
				}
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = ambitious
					has_activity_intent = win_contest_intent
				}
			}
		}
	}
	
	# I have more important things to focus on
	option = {
		name = ep2_locale_events.5530.e
		trigger = {
			NOT = {
				scope:activity = {
					has_current_phase = tournament_phase_recital
				}
			}
			activity_is_competing_trigger = yes
		}
		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		stress_impact = {
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = gregarious
			}
		}
	}
}

# You reminisce about a past memory
# by Veronica Pazos

scripted_trigger ep2_locale_events_1060_valid_target = {
	this != root
	is_physically_able_ai_adult = yes 
	has_any_good_relationship_with_root_trigger = no #they're not already your friend
}

ep2_locale_events.1070 = {
	type = activity_event
	title = ep2_locale_events.1070.t
	desc = {
		desc = ep2_locale_events.1070.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { drinks_alcohol_trigger = yes }
				desc = ep2_locale_events.1070.desc.alcohol
			}
			triggered_desc = {
				trigger = { drinks_alcohol_trigger = no }
				desc = ep2_locale_events.1070.desc.no_alcohol
			}
		}
		desc = ep2_locale_events.1070.desc.outro
	}
		
	theme = tournament_locale_tavern
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = arrogant
				}
			}
			animation = personality_bold
		}
		animation = drink_goblet
	}
	right_portrait = {
		character = scope:impressed_target
		animation = throne_room_conversation_3
	}
	cooldown = { years = 1 }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_tavern
		}
		any_memory = {
			has_memory_category = positive 
			memory_age_years >= 1 #so it's not something that's happened in this tournament
		}
		OR = {
			AND = {
				has_activity_intent = woo_attendee_intent
				intent_target = { is_alive = yes }
			}
			AND = {
				has_activity_intent = befriend_attendee_intent
				intent_target = { is_alive = yes }
			}
			scope:activity = {
				any_attending_character = { ep2_locale_events_1060_valid_target = yes }
			}
		}
	}

	immediate = {
		if = {
			limit = {
				has_activity_intent = woo_attendee_intent
				intent_target = { is_alive = yes }
			}
			intent_target = {
				save_scope_as = impressed_target
			}
		}
		else_if = {
			limit = {
				has_activity_intent = befriend_attendee_intent
				intent_target = { is_alive = yes }
			}
			intent_target = {
				save_scope_as = impressed_target
			}
		}
		else = {
			scope:activity = {
				random_attending_character = {
					limit = { ep2_locale_events_1060_valid_target = yes }
					weight = {
						base = 1
						modifier = {
							add = 10
							this = scope:host
						}
						modifier = {
							add = 7
							is_powerful_vassal_of = root
						}
						modifier = {
							add = 4
							is_vassal_of = root
						}
					}
					save_scope_as = impressed_target 
				}
			}
		}
		if = {
			limit = {
				any_memory = {
					has_memory_category = major
					has_memory_category = positive 
					memory_age_years >= 1
				}
			}
			random_memory = {
				limit = {
					has_memory_category = major
					has_memory_category = positive 
					memory_age_years >= 1
				}
				save_scope_as = my_memory
			}
		}
		else = {
			random_memory = {
				limit = {
					has_memory_category = positive 
					memory_age_years >= 1
				}
				save_scope_as = my_memory
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_activity_intent = reduce_stress_intent
		}
	}

	# Be uplifting!
	option = {
		name = ep2_locale_events.1070.a 
		if = {
			limit = { has_activity_intent = woo_attendee_intent }
			progress_towards_lover_effect = {
				CHARACTER = scope:impressed_target
				REASON = lover_tavern_memory
				OPINION = default_lover_opinion
			}
		}
		else = {
			progress_towards_friend_effect = {
				CHARACTER = scope:impressed_target
				REASON = lover_tavern_memory
				OPINION = default_friend_opinion
			}
		}
		stress_impact = {
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = ambitious
					has_trait = arrogant
				}
			}
		}
	}
	
	# Brag about it
	option = {
		name = ep2_locale_events.1070.b
		trigger = { activity_is_competing_trigger = yes }
		activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		stress_impact = {
			humble = medium_stress_impact_gain
			content = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = content
					has_trait = shy
				}
			}
		}
	}
	
	# If you have the relax intent you lose massive stress
	option = {
		name = ep2_locale_events.1070.c
		trigger = {
			has_activity_intent = reduce_stress_intent
		}
		custom_tooltip = available_because_intent_tt
		stress_impact = {
			base = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = temperate
			}
			modifier = {
				factor = 0.5
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
			}
		}
	}
}

# You ask a knight to lose on purpose
# by Veronica Pazos

ep2_locale_events.3020 = {
	type = activity_event
	title = ep2_locale_events.3020.t
	desc = ep2_locale_events.3020.desc		
	theme = tournament_locale_village
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = humble
					has_trait = just
					has_trait = loyal
				}
			}
			animation = personality_bold
		}
		animation = scheme
	}
	right_portrait = {
		character = scope:enemy_knight
		animation = disapproval
	}
	cooldown = { years = 1 }
	override_background = { reference = army_camp }

	trigger = {
		activity_is_competing_trigger = yes
		scope:activity = { 
			has_active_locale = tournament_locale_visitor_camp
			any_guest_subset_current_phase = { #there's someone else participating that's not you
				name = contestant
				exists = var:progress_to_victory
				this != root
			}
		}
	}

	immediate = {
		scope:activity = { #we grab the higher contestant
			ordered_guest_subset_current_phase = {
				name = contestant
				limit = {
					is_physically_able_ai_adult = yes
					exists = var:progress_to_victory
					this != root
				}
				order_by = var:progress_to_victory
				save_scope_as = enemy_knight
			}
		}
		scope:enemy_knight = {
			get_quirk_character_effect = yes
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_activity_intent = win_contest_intent
		}
	}

	# Ask them to lose
	option = {
		name = ep2_locale_events.3020.a 
		trigger = {
			scope:enemy_knight = { NOT = { is_vassal_of = root } }
		}
		duel = {
			skill = diplomacy
			target = scope:enemy_knight
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep2_locale_events.3020.a.success
				send_interface_toast = {
					title = ep2_locale_events.3020.a.success
					left_icon = root
					right_icon = scope:enemy_knight
					activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
					scope:enemy_knight = {
						activity_tournament_change_contestant_score_effect = { SCORE = decrease_major }
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.3020.a.failure
				root = {
					send_interface_toast = {
						title = ep2_locale_events.3020.a.failure
						left_icon = root
						right_icon = scope:enemy_knight
						scope:enemy_knight = {
							add_opinion = {
								target = root
								modifier = insulted_opinion
								opinion = -20
							}
							accolade_minimal_glory_gain_with_checks_effect = yes
						}
						add_prestige = minor_prestige_loss
					}
				}
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			content = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = content
					has_trait = compassionate
				}
			}
		}
	}
	
	# Force them to lose
	option = {
		name = ep2_locale_events.3020.b
		trigger = {
			scope:enemy_knight = { is_vassal_of = root }
		}
		activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		scope:enemy_knight = {
			activity_tournament_change_contestant_score_effect = { SCORE = decrease_major }
			add_hook = {
				type = favor_hook
				target = root
			}
		}
		scope:enemy_knight = {
			accolade_minor_glory_loss_with_checks_effect = yes
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			content = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = content
					has_trait = compassionate
				}
			}
		}
	}
	
	# Drop it
	option = {
		name = ep2_locale_events.3020.c
		add_prestige = minor_prestige_gain
		stress_impact = {
			arrogant = major_stress_impact_gain
			ambitious = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = ambitious
				}
			}
		}
	}
}

# Repeatable Tailor event for the Artisan Quarters - buy a trinket of sorts
# by Veronica Pazos

ep2_locale_events.2560 = {
	type = activity_event
	title = ep2_locale_events.2560.t
	desc = {
		desc = ep2_locale_events.2560.desc.intro
		random_valid = {
			triggered_desc = {
				trigger = { exists = scope:previous_artifact }
				desc = ep2_locale_events.2560.desc.previous_artifact
			}
			desc = ep2_locale_events.2560.desc.new_artifact
			desc = ep2_locale_events.2560.desc.new_artifact_2
		}
	}
	theme = friendly
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:tailor
		animation = steward
	}
	artifact = {
		target = scope:previous_artifact
		position = lower_left_portrait
		trigger = { exists = scope:previous_artifact }
	}
	artifact = {
		target = scope:purchasable_trinket_event
		position = lower_right_portrait
	}

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_tailor
			var:tournament_tailor = { is_alive = yes }
		}
	}

	immediate = {
		scope:activity = {
			var:tournament_tailor = { save_scope_as = tailor }
		}
		scope:tailor = {
			get_quirk_character_effect = yes
		}
		capital_barony = { save_scope_as = capital_barony }
		if = {
			limit = {
				any_character_artifact = { }
			}
			random_character_artifact = {
				limit = {
					is_equipped = yes
				}
				alternative_limit = {
					rarity = illustrious
				}
				alternative_limit = {
					rarity = famed
				}
				alternative_limit = {
					rarity = masterwork
				}
				alternative_limit = {
					rarity = common
				}
				save_scope_as = previous_artifact
			}
		}
		hidden_effect = {
			scope:tailor = {
				generate_tournament_trinket_effect = {
					TRINKET_RECEIVER = scope:tailor
					TRINKET_GIVER = scope:tailor
				}
				if = {
					# Checks required for error suppression
					limit = { exists = scope:purchasable_trinket }
					scope:purchasable_trinket = {
						flag_as_trash_artifact = yes
						save_scope_as = purchasable_trinket_event
					}
				}
			}
		}
	}
	
	weight_multiplier = {
		base = 1
	}

	# Improve
	option = {
		name = ep2_locale_events.2560.a 
		trigger = { exists = scope:previous_artifact }
		pay_short_term_gold = {
			target = scope:tailor
			gold = {
				value = minor_gold_value
				max = 15
			}
		}
		scope:previous_artifact = {
			set_artifact_description = ep2_locale_events_artifact_decoration_desc
			add_artifact_modifier = artifact_monthly_prestige_3_modifier
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			avaricious = medium_stress_impact_gain
		}
		hidden_effect = { destroy_artifact = scope:purchasable_trinket } # Destroy the trinket if its not bought
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = avaricious
					gold <= minor_gold_value
				}
			}
		}
	}
	
	# Buy
	option = {
		name = ep2_locale_events.2560.b
		trigger = {
			NAND = { 
				exists = scope:previous_artifact
				OR = {
					has_trait = callous
					has_trait = sadistic
					dread >= medium_dread
				}
				has_activity_intent = win_contest_intent
			}
		}
		pay_short_term_gold = {
			target = scope:tailor
			gold = {
				value = minor_gold_value
				max = 15
			}
		}
		scope:purchasable_trinket_event = { set_owner = root }
		stress_impact = {
			greedy = medium_stress_impact_gain
			avaricious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = avaricious
					gold <= minor_gold_value
				}
			}
		}
	}
	
	# Intimidate to get for free
	option = {
		name = ep2_locale_events.2560.c
		trigger = {
			OR = {
				has_trait = callous
				has_trait = sadistic
				dread >= medium_dread
			}
		}
		duel = {
			skills = { prowess intrigue }
			target = scope:tailor
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep2_locale_events.2560.c.success
				send_interface_toast = {
					title = ep2_locale_events.2560.c.success
					right_icon = scope:tailor
					scope:purchasable_trinket_event = { set_owner = root }
					scope:tailor = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -10
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.2560.c.failure
				send_interface_toast = {
					title = ep2_locale_events.2560.c.failure
					right_icon = scope:tailor
					scope:tailor = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -50
						}
					}
				}
				hidden_effect = { destroy_artifact = scope:purchasable_trinket } # Destroy the trinket if its not bought
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			calm = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = calm
					has_trait = compassionate
				}
			}
		}
	}
	
	# Buy banners to increase your PtV
	option = {
		name = ep2_locale_events.2560.d
		custom_tooltip = available_because_intent_tt
		trigger = {
			has_activity_intent = win_contest_intent
			activity_is_competing_trigger = yes
		}
		pay_short_term_gold = {
			target = scope:tailor
			gold = {
				value = tiny_gold_value
				max = 10
			}
		}
		add_character_modifier = {
			modifier = tournament_banners_modifier
			years = 10
		}
		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		stress_impact = {
			humble = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
			avaricious = medium_stress_impact_gain
		}
		hidden_effect = { destroy_artifact = scope:purchasable_trinket } # Destroy the trinket if its not bought
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = avaricious
					has_trait = humble
					gold <= minor_gold_value
				}
			}
		}
	}
	
	# Not interested
	option = {
		name = ep2_locale_events.2560.e
		add_prestige = miniscule_prestige_gain
		pay_short_term_gold = {
			target = scope:tailor
			gold = {
				value = tiny_gold_value
				max = 1
			}
		}
		stress_impact = {
			profligate = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		hidden_effect = { destroy_artifact = scope:purchasable_trinket } # Destroy the trinket if its not bought
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = profligate
					has_trait = arrogant
				}
			}
		}
	}
}
