﻿namespace = ep2_locale_events

##################################################
# #General (Reserved)
# 0001 - 0999
#
# #Tavern
# 1000 - 1499
#
# #Temple
# 1500 - 1999
#
# #Armorer
# 2000 - 2499
#
# #Tailor
# 2500 - 2999
#
# #Camp
# 3000 - 3499
#
# #Farrier
# 3500 - 3999
#
# #Bowyer
# 4000 - 4499
#
# #Weaponsmith
# 4500 - 4999
#
# #Grounds
# 5000 - 5499
#
# #Village
# 5500 - 5999
##################################################

#######################################
#######################################
### 	GENERAL - 0001 - 0999		###
#######################################
#######################################

#######################################
### 	AI EVENTS - 0001 - 0099		###
#######################################

# These events are AI-only and used to generate some randomness and dynamism to PtV
# They deliberately are hidden and have no loc

ep2_locale_events.0001 = {
	hidden = yes

	trigger = {
		is_ai = yes # Only AI
		is_landed = no
		activity_is_competing_trigger = yes
	}

	immediate = {
		random_list = {
			1 = { # Increase
				activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
			}

			1 = { # Decrease
				activity_tournament_change_contestant_score_effect = { SCORE = decrease_miniscule }
			}
		}
	}
}

ep2_locale_events.0002 = {
	hidden = yes

	trigger = {
		is_ai = yes # Only AI
		is_landed = no
		activity_is_competing_trigger = yes
	}

	immediate = {
		random_list = {
			1 = { # Increase
				activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
			}

			1 = { # Decrease
				activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
			}
		}
	}
}

ep2_locale_events.0003 = {
	hidden = yes

	trigger = {
		is_ai = yes # Only AI
		is_landed = no
		activity_is_competing_trigger = yes
	}

	immediate = {
		random_list = {
			1 = { # Increase
				activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
			}

			1 = { # Decrease
				activity_tournament_change_contestant_score_effect = { SCORE = decrease_medium }
			}
		}
	}
}



scripted_trigger tournament_intent_locale_trigger = {
	has_activity_intent = $INTENT$_intent
	exists = intent_target
	intent_target = {
		is_alive = yes
		is_participant_in_activity = root.involved_activity
		has_activity_state = passive
	}
}

#######################################
#######################################
### 	TAVERN - 1000 - 1499		###
#######################################
#######################################

scripted_trigger tournament_tavern_round_recipient_trigger = {
	activity_is_competing_trigger = yes
	age >= 18
	trigger_if = {
		limit = {
			faith = { trait_is_sin = drunkard }
		}
		NOT = { has_trait = zealous }
	}
	NOR = {
		has_trait = shy
		has_trait = diligent
		has_trait = temperate
		has_trait = inappetetic
		this = root
		any_relation = { this = root }
	}
	opinion = {
		target = root
		value >= -25
	}
}

# Another Round?
ep2_locale_events.1000 = {
	type = activity_event
	title = ep2_locale_events.1000.t
	desc = {
		first_valid = {
		    triggered_desc = {
		        trigger = { scope:drinking_leader = scope:drinking_leader.liege }
		        desc = ep2_locale_events.1000.independent
		    }
		    desc = ep2_locale_events.1000.liege
		}
		desc = ep2_locale_events.1000.alcohol
	}
	theme = tournament_locale_tavern
	left_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:drinking_leader
		animation = toast
	}
	lower_right_portrait = scope:drinker_1
	lower_center_portrait = scope:drinker_2
	lower_left_portrait = scope:drinker_3
	cooldown = { years = 1 }

	trigger = {
		activity_tournament_race_contest_trigger = no
		scope:activity = {			
			any_attending_character = {
				count >= 4
				tournament_tavern_round_recipient_trigger = yes
			}
			has_active_locale = tournament_locale_tavern
		}
	}

	immediate = {
		play_music_cue = mx_cue_tavern
		scope:activity = {
			hidden_effect = {
				while = {
					count = 4
					random_attending_character = {
						limit = {
							tournament_tavern_round_recipient_trigger = yes
							NOT = { is_in_list = tavern_round }
						}
						weight = {
							base = 1
							modifier = {
								add = 10
								has_trait = gregarious
							}
							modifier = {
								add = 10
								has_trait = lazy
							}
							modifier = {
								add = 10
								has_trait = gluttonous
							}
							modifier = {
								add = 10
								has_trait = drunkard
							}
							modifier = {
								add = -10
								has_trait = shy
							}
							modifier = {
								add = -10
								has_trait = diligent
							}
							modifier = {
								add = -10
								has_trait = temperate
							}
							modifier = {
								add = -10
								has_trait = inappetetic
							}
							modifier = {
								factor = 0.5
								has_court_position = champion_court_position
							}
							modifier = {
								factor = 2
								save_temporary_scope_as = new_list_member
								any_in_list = {
									list = tavern_round
									has_any_good_relationship_with_character_trigger = { CHARACTER = scope:new_list_member }
								}
							}
							modifier = {
								factor = 2
								save_temporary_scope_as = new_list_member
								any_in_list = {
									list = tavern_round
									liege = scope:new_list_member
								}
							}
							modifier = {
								factor = 0
								save_temporary_scope_as = new_list_member
								any_in_list = {
									list = tavern_round
									has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:new_list_member }
								}
							}
						}
						add_to_list = tavern_round
					}
				}
				ordered_in_list = {
					list = tavern_round
					limit = {
						NOR = {
							AND = {
								exists = scope:drinking_leader
								this = scope:drinking_leader
							}
							AND = {
								exists = scope:drinker_1
								this = scope:drinker_1
							}
							AND = {
								exists = scope:drinker_2
								this = scope:drinker_2
							}
						}
					}
					order_by = {
						value = 0
						if = {
							limit = { is_landed = yes }
							add = primary_title.tier
						}
						if = {
							limit = { has_court_position = champion_court_position }
							add = 3
						}
						if = {
							limit = { is_councillor = yes }
							add = 2
						}
						if = {
							limit = { has_relation_activity_recurrer = root }
							add = 10
						}
					}
					max = 4
					check_range_bounds = no
					if = {
						limit = {
							NOT = { exists = scope:drinking_leader }
						}
						save_scope_as = drinking_leader
						try_to_create_recurring_character_effect = { CHARACTER = root }
					}
					else_if = {
						limit = {
							NOT = { exists = scope:drinker_1 }
						}
						save_scope_as = drinker_1
					}
					else_if = {
						limit = {
							NOT = { exists = scope:drinker_2 }
						}
						save_scope_as = drinker_2
					}
					else = { save_scope_as = drinker_3 }	
				}
			}
		}
	}

	# A round!
	option = {
		name = ep2_locale_events.1000.a
		remove_short_term_gold = tiny_gold_value
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		}
		every_in_list = {
			list = tavern_round
			custom = drinks_round_tt
			if = {
				limit = { has_trait = drunkard }
				add_opinion = {
					target = root
					modifier = tournament_bought_round_opinion
					opinion = 10
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = tournament_bought_round_opinion
					opinion = 5
				}
			}
			random = {
				chance = 50
				activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
				add_character_modifier = {
					modifier = tournament_wicked_hangover_modifier
					months = 3
				}
			}
		}
		stress_impact = {
			temperate = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			just = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -1
				ai_greed = -1
				ai_vengefulness = 0.5
				ai_compassion = -0.5
			}
			modifier = {
				has_activity_intent = win_contest_intent
				factor = 2
			}
		}
	}

	# Open tab!
	option = {
		name = ep2_locale_events.1000.b
		remove_short_term_gold = minor_gold_value
		if = {
			limit = {
				scope:activity = {
					any_guest_subset_current_phase = { #you're participating
						name = contestant
						this = root					
					}
				}
			}
			activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		}
		every_in_list = {
			list = tavern_round
			custom = drinks_round_tt
			if = {
				limit = { has_trait = drunkard }
				add_opinion = {
					target = root
					modifier = tournament_bought_round_opinion
					opinion = 20
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = tournament_bought_round_opinion
					opinion = 10
				}
			}
			random = {
				chance = 75
				
				hidden_effect = {
					activity_tournament_change_contestant_score_effect = { SCORE = decrease_medium }
				}
				custom_tooltip = score_decreases_tt

				add_character_modifier = {
					modifier = tournament_wicked_hangover_modifier
					months = 3
				}
			}
		}
		stress_impact = {
			temperate = medium_stress_impact_gain
			honest = medium_stress_impact_gain
			just = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_honor = -1
				ai_greed = -1
				ai_vengefulness = 0.5
				ai_compassion = -0.5
			}
			modifier = {
				has_activity_intent = win_contest_intent
				factor = 2
			}
		}
	}

	# Cut off!
	option = {
		name = ep2_locale_events.1000.c
		trigger = { this = scope:host }
		if = {
			limit = {
				faith = { trait_is_virtue = temperate }
			}
			add_piety = minor_piety_gain
		}
		every_in_list = {
			list = tavern_round
			custom = drinks_round_tt
			add_opinion = {
				target = root
				modifier = tournament_cut_off_round_opinion
				opinion = -10
			}
			random = {
				chance = 50
				
				hidden_effect = {
					activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
				}
				custom_tooltip = score_increases_tt

				add_character_modifier = {
					modifier = tournament_wicked_hangover_modifier
					months = 3
				}
			}
		}
		stress_impact = {
			drunkard = minor_stress_impact_gain
			hashishiyah = minor_stress_impact_gain
			gluttonous = minor_stress_impact_gain
			deceitful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = 1
				ai_compassion = -0.5
			}
		}
	}

	# Have a good night
	option = {
		name = ep2_locale_events.1000.d
		every_in_list = {
			list = tavern_round
			custom = drinks_round_tt
			random = {
				chance = 25
				
				hidden_effect = {
					activity_tournament_change_contestant_score_effect = { SCORE = decrease_medium }
				}
				custom_tooltip = score_decreases_tt

				add_character_modifier = {
					modifier = tournament_wicked_hangover_modifier
					months = 3
				}
			}
		}
		if = {
			limit = { has_activity_intent = win_contest_intent }
			stress_impact = { base = medium_stress_impact_gain }
		}
		stress_impact = {
			sadistic = medium_stress_impact_gain
			drunkard = minor_stress_impact_gain
			hashishiyah = minor_stress_impact_gain
			gluttonous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = 0.5
				ai_greed = 0.5
				ai_vengefulness = -0.5
			}
		}
	}

	after = {
		if = {
			limit = {
				any_in_list = {
					list = tavern_round
					has_character_modifier = tournament_wicked_hangover_modifier
				}
			}
			random_in_list = {
				list = tavern_round
				limit = { has_character_modifier = tournament_wicked_hangover_modifier }
				save_scope_as = hungover_1
			}
			if = {
				limit = {
					any_in_list = {
						list = tavern_round
						has_character_modifier = tournament_wicked_hangover_modifier
						NOT = { this = scope:hungover_1 }
					}
				}
				random_in_list = {
					list = tavern_round
					limit = {
						has_character_modifier = tournament_wicked_hangover_modifier
						NOT = { this = scope:hungover_1 }
					}
					save_scope_as = hungover_2
				}
			}
			send_interface_toast = {
				title = ep2_locale_events.1000.hangover_tt
				left_icon = scope:hungover_1
				right_icon = scope:hungover_2
				show_as_tooltip = {
					every_in_list = {
						list = tavern_round
						limit = { has_character_modifier = tournament_wicked_hangover_modifier }
						add_character_modifier = tournament_wicked_hangover_modifier
					}
				}
			}
		}
	}
}

# You challenge a local drunk to a drinking contest
# by Nick Meredith
ep2_locale_events.1002 = {
	type = activity_event
	title = ep2_locale_events.1002.t
	desc = ep2_locale_events.1002.desc
	theme = tournament_locale_tavern
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:local_drunk
		animation = drink
	}
	cooldown = { years = 1 }

	trigger = {
		drinks_alcohol_trigger = yes

		scope:activity = {
			has_active_locale = tournament_locale_tavern
		}
	}

	immediate = {
		play_music_cue = mx_cue_tavern
		create_character = {
			template = generic_peasant_character
			faith = root.faith #to ensure he also drinks
			location = root.location
			save_scope_as = local_drunk
		}
	}

	# Buy them a drink
	option = {
		name = ep2_locale_events.1002.a

		trigger = {
			OR = {
				has_trait = gregarious
				has_trait = lifestyle_reveler
			}
		}

		remove_short_term_gold = tiny_gold_value

		reverse_add_opinion = {
			target = scope:local_drunk
			modifier = friendliness_opinion
			opinion = 20
		}

		add_character_modifier = {
			modifier = tournament_man_of_the_people_modifier
			years = 10
		}

		try_to_create_recurring_character_effect = { CHARACTER = scope:local_drunk }

		stress_impact = {
			base = medium_stress_impact_loss
			calm = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			wrathful = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = wrathful
					has_trait = arrogant
				}
			}
		}
	}

	# Challenge them to a drinking contest
	option = {
		name = ep2_locale_events.1002.b

		random_list = {
			35 = { # You win
				desc = ep2_locale_events.1002.b.success
				modifier = {
					has_trait = drunkard
					add = 20
				}
				modifier = {
					has_trait = lifestyle_reveler
					add = 15
				}
				modifier = {
					has_trait = gluttonous
					add = 10
				}
				modifier = { #More body weight to soak up the alcohol!
					has_trait = giant 
					add = 5
				}
				modifier = { #Fit and in good health already
					has_trait = physique_good
					add = 5
				}
				modifier = {
					health > 5
					add = 2
				}
				modifier = {
					health > 8
					add = 1
				}
				modifier = {
					has_trait = temperate
					add = -10
				}

				send_interface_toast = {
					title = ep2_locale_events.1002.b.success
					left_icon = root
					right_icon = scope:local_drunk

					add_prestige = minor_prestige_gain
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = decrease_miniscule }
					}
				}
			}
			40 = { # You lose
				desc = ep2_locale_events.1002.b.failure

				send_interface_toast = {
					title = ep2_locale_events.1002.b.failure
					left_icon = root
					right_icon = scope:local_drunk

					add_prestige = minor_prestige_loss
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = decrease_major }
					}
				}
			}
		}

		try_to_create_recurring_character_effect = { CHARACTER = scope:local_drunk }

		stress_impact = {
			base = minor_stress_impact_loss
			shy = minor_stress_impact_gain
			gluttonous = medium_stress_impact_loss
			drunkard = medium_stress_impact_loss
			arrogant = minor_stress_impact_loss
			temperate = major_stress_impact_gain
			humble = minor_stress_impact_gain
		}

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

	# Refuse
	option = {
		name = ep2_locale_events.1002.c

		add_character_modifier = {
			modifier = tournament_snob_modifier
			years = 10
		}

		reverse_add_opinion = {
			target = scope:local_drunk
			modifier = annoyed_opinion
			opinion = -20
		}

		stress_impact = {
			shy = miniscule_stress_impact_loss
			gluttonous = major_stress_impact_gain
			temperate = miniscule_stress_impact_loss
		}

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

# Fancy a game of dice?
# by Nick Meredith
ep2_locale_events.1010 = {
	type = activity_event
	title = ep2_locale_events.1010.t
	desc = ep2_locale_events.1010.desc
	theme = friendly  
	override_background = { reference = tavern }
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:gambler
		animation = ecstasy
	}
	lower_center_portrait = {
		character = scope:tournament_tavernkeeper
	}
	cooldown = { years = 1 }

	trigger = {
		scope:activity = {
			any_attending_character = {
				is_ai = yes
				is_adult = yes
				NOT = { 
					this = root 
				}
				NOR = { #Zealous monks shouldn't gamble
					has_trait = devoted
					has_trait = zealous
				}
				is_alive = yes
			}
			exists = var:tournament_tavernkeeper
			var:tournament_tavernkeeper = { is_alive = yes }
		}

		scope:activity = { # You have a tavern
			has_active_locale = tournament_locale_tavern
		}
	}

	immediate = {
		play_music_cue = mx_cue_tavern
		scope:activity = {
			var:tournament_tavernkeeper = { save_scope_as = tournament_tavernkeeper }
		}
		involved_activity = {
			random_attending_character = {
				limit = {
					is_ai = yes
					is_adult = yes
					NOT = { this = root }
					is_alive = yes
				}
				weight = {
					base = 1
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = gambler
			}
		}
	}

	## Cheat to win
	#option = {
	#	name = ep2_locale_events.1010.a
	#
	#	trigger = {
	#		OR = {
	#			has_trait = deceitful
	#			has_trait = arbitrary
	#		}
	#	}
	#
	#	flavor = ep2_locale_events.1010.a.tt
	#
	#	add_character_flag = {
	#		flag = cheating_at_dice
	#		days = 10
	#	}
	#
	#	try_to_create_recurring_character_effect = { CHARACTER = scope:gambler }
	#
	#	trigger_event = ep2_locale_events.1011
	#
	#	stress_impact = {
	#		deceitful = minor_stress_impact_loss
	#		arbitrary = minor_stress_impact_loss
	#		greedy = miniscule_stress_impact_loss
	#		content = minor_stress_impact_gain
	#		honest = massive_stress_impact_gain
	#		just = massive_stress_impact_gain
	#	}
	#
	#	ai_chance = {
	#		base = 100
	#		modifier = {
	#			factor = 0
	#			OR = {
	#				has_trait = honest
	#				has_trait = just
	#			}
	#		}
	#	}
	#}

	# Take them up on it
	option = {
		name = ep2_locale_events.1010.b

		try_to_create_recurring_character_effect = { CHARACTER = scope:gambler }

		trigger_event = ep2_locale_events.1011

		stress_impact = {
			profligate = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_zeal = -0.5
				ai_rationality = 0.5
			}
		}
	}

	# Decline
	option = {
		name = ep2_locale_events.1010.c

		reverse_add_opinion = {
			target = scope:gambler
			modifier = disappointed_opinion
			opinion = -15
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_rationality = 0.5
			}
		}
	}
}

# Round One
ep2_locale_events.1011 = {
	type = activity_event
	title = ep2_locale_events.1011.t
	desc = {
		desc = ep2_locale_events.1011.opening
		first_valid = {
			triggered_desc = { #If you're smort and they have a high roll
				trigger = {
					intrigue >= 14
					var:gambler_dice_1 > 11
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1011.tell.good
			}
			triggered_desc = { #If you're smort and they have a low roll
				trigger = {
					intrigue >= 14
					var:gambler_dice_1 < 10
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1011.tell.bad
			}
			triggered_desc = {  #If you're an idiot and they have a high roll
				trigger = {
					intrigue <= 6
					var:gambler_dice_1 > 11
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1011.tell.bad
			}
			triggered_desc = {  #If you're an idiot and they have a low roll
				trigger = {
					intrigue <= 6
					var:gambler_dice_1 < 10
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1011.tell.good
			}
			triggered_desc = {  #If you're average
				trigger = {
					intrigue >= 7
					intrigue <= 13
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1011.average
			}
			triggered_desc = {  #If they're deceitful you get nothing
				trigger = {
					scope:gambler = {
						has_trait = deceitful
					}
				}
				desc = ep2_locale_events.1011.deceitful
			}
		}
	}
	theme = friendly  
	override_background = { reference = tavern }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:gambler
		animation = ecstasy
	}
	cooldown = { years = 1 }

	immediate = {
		play_music_cue = mx_cue_tavern
		set_variable = {
			name = root_dice_1
			value = {
				integer_range = {
					min = 3
					max = 18
				}
			}
		}
		set_variable = {
			name = gambler_dice_1
			value = {
				integer_range = {
					min = 3
					max = 18
				}
			}
		}
		set_variable = {
			name = root_wins
			value = 0
		}
		set_variable = {
			name = gambler_wins
			value = 0
		}
	}

	# Guess higher
	option = {
		name = ep2_locale_events.1011.a

		if = {
			limit = {
				var:root_dice_1 > var:gambler_dice_1
			}
			change_variable = {
				name = root_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1012
		}

		else_if = {
			limit = {
				var:root_dice_1 < var:gambler_dice_1
			}
			change_variable = {
				name = gambler_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1012
		}

		else = {
			limit = {
				var:gambler_dice_1 = var:root_dice_1
			}
			trigger_event = ep2_locale_events.1012
		}

		ai_chance = {
			base = 100
		}
	}

	# Guess lower
	option = {
		name = ep2_locale_events.1011.b

		if = {
			limit = {
				var:root_dice_1 < var:gambler_dice_1
			}
			change_variable = {
				name = gambler_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1012
		}

		else_if = {
			limit = {
				var:root_dice_1 > var:gambler_dice_1
			}
			change_variable = {
				name = root_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1012
		}

		else = {
			limit = {
				var:gambler_dice_1 = var:root_dice_1
			}
			trigger_event = ep2_locale_events.1012
		}

		ai_chance = {
			base = 100
		}
	}
}

# Round Two
ep2_locale_events.1012 = {
	type = activity_event
	title = ep2_locale_events.1012.t
	desc = {
		first_valid = { 
			triggered_desc = { #You won the last round
				trigger = {
					var:root_wins = 1
				}
				desc = ep2_locale_events.1012.opening.win
			}
			triggered_desc = { #You lost the last round
				trigger = {
					var:gambler_wins = 1
				}
				desc = ep2_locale_events.1012.opening.win
			}
			triggered_desc = {  #You drew the last round
				trigger = {
					var:gambler_wins = var:root_wins
				}
				desc = ep2_locale_events.1012.opening.draw
			}
		}
		desc = ep2_locale_events.1012.dice_reveal
		first_valid = {
			triggered_desc = { #If you're smort and they have a high roll
				trigger = {
					intrigue >= 14
					var:gambler_dice_1 > 11
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1012.tell.good
			}
			triggered_desc = { #If you're smort and they have a low roll
				trigger = {
					intrigue >= 14
					var:gambler_dice_1 < 10
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1012.tell.bad
			}
			triggered_desc = {  #If you're an idiot and they have a high roll
				trigger = {
					intrigue <= 6
					var:gambler_dice_1 > 11
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1012.tell.bad
			}
			triggered_desc = {  #If you're an idiot and they have a low roll
				trigger = {
					intrigue <= 6
					var:gambler_dice_1 < 10
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1012.tell.good
			}
			triggered_desc = {  #If you're average
				trigger = {
					intrigue >= 7
					intrigue <= 13
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1012.average
			}
			triggered_desc = {  #If they're deceitful you get nothing
				trigger = {
					scope:gambler = {
						has_trait = deceitful
					}
				}
				desc = ep2_locale_events.1012.deceitful
			}
		}
	}
	theme = friendly  
	override_background = { reference = tavern }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:gambler
		animation = worry
	}
	cooldown = { years = 1 }

	immediate = {
		play_music_cue = mx_cue_tavern
		set_variable = {
			name = root_dice_2
			value = {
				integer_range = {
					min = 3
					max = 18
				}
			}
		}
		set_variable = {
			name = gambler_dice_2
			value = {
				integer_range = {
					min = 3
					max = 18
				}
			}
		}
	}

	# Guess higher
	option = {
		name = ep2_locale_events.1012.a

		if = {
			limit = {
				var:gambler_dice_2 < var:root_dice_2
			}
			change_variable = {
				name = root_wins
				add = 1
			}
			if = {
				limit = {
					OR = {
						var:root_wins >= 2
						var:gambler_wins >= 2
					}
				}
				trigger_event = ep2_locale_events.1014
			}
			else = {
				trigger_event = ep2_locale_events.1013
			}
		}

		else_if = {
			limit = {
				var:root_dice_2 < var:gambler_dice_2
			}
			change_variable = {
				name = gambler_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1013
		}

		else = {
			limit = {
				var:gambler_dice_2 = var:root_dice_2
			}
			trigger_event = ep2_locale_events.1013
		}

		ai_chance = {
			base = 100
		}
	}

	# Guess lower
	option = {
		name = ep2_locale_events.1012.b

		if = {
			limit = {
				var:gambler_dice_2 > var:root_dice_2
			}
			change_variable = {
				name = root_wins
				add = 1
			}

			if = {
				limit = {
					OR = {
						var:root_wins >= 2
						var:gambler_wins >= 2
					}
				}
				trigger_event = ep2_locale_events.1014
			}
			else = {
				trigger_event = ep2_locale_events.1013
			}
		}

		else_if = {
			limit = {
				var:root_dice_2 > var:gambler_dice_2
			}
			change_variable = {
				name = gambler_wins
				add = 1
			}
			if = {
				limit = {
					OR = {
						var:root_wins >= 2
						var:gambler_wins >= 2
					}
				}
				trigger_event = ep2_locale_events.1014
			}
			else = {
				trigger_event = ep2_locale_events.1013
			}
		}

		else = {
			limit = {
				var:gambler_dice_2 = var:root_dice_2
			}
			trigger_event = ep2_locale_events.1013
		}

		ai_chance = {
			base = 100
		}
	}
}

# Round Three
ep2_locale_events.1013 = {
	type = activity_event
	title = ep2_locale_events.1013.t
	desc = {
		desc = ep2_locale_events.1013.opening
		desc = ep2_locale_events.1013.dice_reveal
		first_valid = {
			triggered_desc = { #If you're smort and they have a high roll
				trigger = {
					intrigue <= 6
					var:gambler_dice_1 > 11
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1013.tell.good
			}
			triggered_desc = { #If you're smort and they have a low roll
				trigger = {
					intrigue >= 14
					var:gambler_dice_1 < 10
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1013.tell.bad
			}
			triggered_desc = {  #If you're an idiot and they have a high roll
				trigger = {
					intrigue <= 6
					var:gambler_dice_1 > 11
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1013.tell.bad
			}
			triggered_desc = {  #If you're an idiot and they have a low roll
				trigger = {
					intrigue <= 6
					var:gambler_dice_1 < 10
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1013.tell.good
			}
			triggered_desc = {  #If you're average
				trigger = {
					intrigue >= 7
					intrigue <= 13
					scope:gambler = {
						NOT = {
							has_trait = deceitful
						}
					}
				}
				desc = ep2_locale_events.1013.average
			}
			triggered_desc = {  #If they're deceitful you get nothing
				trigger = {
					scope:gambler = {
						has_trait = deceitful
					}
				}
				desc = ep2_locale_events.1013.deceitful
			}
		}
	}
	theme = friendly  
	override_background = { reference = tavern }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:gambler
		animation = worry
	}
	cooldown = { years = 1 }

	immediate = {
		play_music_cue = mx_cue_tavern
		set_variable = {
			name = root_dice_3
			value = {
				integer_range = {
					min = 3
					max = 18
				}
			}
		}
		set_variable = {
			name = gambler_dice_3
			value = {
				integer_range = {
					min = 3
					max = 18
				}
			}
		}
	}

	# Guess higher
	option = {
		name = ep2_locale_events.1013.a

		if = {
			limit = {
				var:gambler_dice_3 < var:root_dice_3
			}
			change_variable = {
				name = root_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1014
		}

		else_if = {
			limit = {
				var:root_dice_3 < var:gambler_dice_3
			}
			change_variable = {
				name = gambler_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1014
		}

		else = {
			limit = {
				var:gambler_dice_3 = var:root_dice_3
			}
			trigger_event = ep2_locale_events.1014
		}

		ai_chance = {
			base = 100
		}
	}

	# Guess lower
	option = {
		name = ep2_locale_events.1013.b

		if = {
			limit = {
				var:gambler_dice_3 > var:root_dice_3
			}
			change_variable = {
				name = root_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1014
		}

		else_if = {
			limit = {
				var:root_dice_3 > var:gambler_dice_3
			}
			change_variable = {
				name = gambler_wins
				add = 1
			}
			trigger_event = ep2_locale_events.1014
		}

		else = {
			limit = {
				var:gambler_dice_3 = var:root_dice_3
			}
			trigger_event = ep2_locale_events.1014
		}

		ai_chance = {
			base = 100
		}
	}
}

# Dice Results
ep2_locale_events.1014 = {
	type = activity_event
	title = ep2_locale_events.1014.t
	desc = {
		desc = ep2_locale_events.1014.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					var:root_wins > var:gambler_wins
				}
				desc = ep2_locale_events.1014.win
			}
			triggered_desc = {
				trigger = {
					var:gambler_wins > var:root_wins
				}
				desc = ep2_locale_events.1014.lose
			}
			triggered_desc = {
				desc = ep2_locale_events.1014.draw
			}
		}
	}
	theme = tournament_locale_tavern
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				var:root_wins > var:gambler_wins
			}
			animation = throne_room_cheer_1
		}
		animation = shock
	}
	right_portrait = {
		character = scope:gambler
		triggered_animation = {
			trigger = {
				var:root_wins > var:gambler_wins
			}
			animation = shock
		}
		animation = throne_room_cheer_1
	}
	cooldown = { years = 1 }

	immediate = {
		play_music_cue = mx_cue_tavern
		
		add_character_modifier = {
			modifier = tournament_dice_player_modifier
			years = 20
		}

		if = {
			limit = {
				var:root_wins > var:gambler_wins
			}
			
			scope:gambler = {
				pay_short_term_gold = {
					target = root
					gold = medium_gold_value
				}
			}

			add_stress = minor_stress_loss
		}

		else_if = {
			limit = {
				var:root_wins < var:gambler_wins
			}
			
			scope:gambler = {
				pay_short_term_gold = {
					target = root
					gold = medium_gold_value
				}
			}

			add_stress = minor_stress_gain
		}

		else = {
			limit = {
				var:gambler_dice_1 = var:root_dice_1
			}

			#Deliberately empty
		}
	}

	# Win: buy a round of drinks
	option = {
		name = ep2_locale_events.1014.a

		trigger = {
			var:root_wins > var:gambler_wins
		}

		remove_short_term_gold = minor_gold_value


		#AGOT Modified
		# if = {
		# 	limit = { 
		# 		is_landed = yes 
		# 		is_ai = yes
		# 	}
		# 	hidden_effect = {
		# 		random = {
		# 			chance = 50
		# 			give_nickname = nick_monarch_of_dice
		# 		}
		# 	}
		# }
		if = {
			limit = {
				is_landed = yes
				has_any_nickname = no
			}
			random = {
				chance = 1
				give_nickname = nick_monarch_of_dice
			}
		}

		scope:activity = {
			every_attending_character = {
				limit = { 
					has_trait = lifestyle_reveler
					NOT = { 
						this = root 
					} 
				}

				add_opinion = {
					target = root
					modifier = tournament_bought_round_opinion
					opinion = 10
				}
			}
		}

		stress_impact = {
			gluttonous = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			greedy = medium_stress_impact_gain
			temperate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = temperate
				}
			}
		}
	}

	# Win: do nothing
	option = {
		name = ep2_locale_events.1014.b

		trigger = {
			var:root_wins > var:gambler_wins
		}

		stress_impact = {
			base = minor_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			temperate = miniscule_stress_impact_loss
			gregarious = medium_stress_impact_gain
			gluttonous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = gregarious
					has_trait = gluttonous
				}
			}
		}
	}

	# Lose: buy yourself a drink
	option = {
		name = ep2_locale_events.1014.c

		trigger = {
			var:root_wins < var:gambler_wins
		}

		remove_short_term_gold = minor_gold_value

		stress_impact = {
			base = miniscule_stress_impact_loss
			gluttonous = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			greedy = medium_stress_impact_gain
			temperate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = temperate
				}
			}
		}
	}

	# Lose: do nothing
	option = {
		name = ep2_locale_events.1014.d

		trigger = {
			var:root_wins < var:gambler_wins
		}

		stress_impact = {
			base = minor_stress_impact_gain
			greedy = miniscule_stress_impact_loss
			temperate = miniscule_stress_impact_loss
			gregarious = medium_stress_impact_gain
			gluttonous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = gluttonous
					has_trait = gregarious
				}
			}
		}
	}

	# Draw: buy yourself a drink
	option = {
		name = ep2_locale_events.1014.e

		trigger = {
			var:root_wins = var:gambler_wins
		}

		remove_short_term_gold = minor_gold_value

		stress_impact = {
			base = miniscule_stress_impact_loss
			gluttonous = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			greedy = medium_stress_impact_gain
			temperate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = temperate
				}
			}
		}
	}

	# Draw: do nothing
	option = {
		name = ep2_locale_events.1014.f

		trigger = {
			var:root_wins = var:gambler_wins
		}

		stress_impact = {
			base = minor_stress_impact_gain
			greedy = miniscule_stress_impact_loss
			temperate = miniscule_stress_impact_loss
			gregarious = medium_stress_impact_gain
			gluttonous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = gluttonous
					has_trait = gregarious
				}
			}
		}
	}

	after = {
		remove_variable = gambler_wins
		remove_variable = root_wins
		remove_variable = root_dice_1
		remove_variable = root_dice_2
		remove_variable = root_dice_3
		remove_variable = gambler_dice_1
		remove_variable = gambler_dice_2
		remove_variable = gambler_dice_3
	}
}

# Wealthy gambler offers you money to go helmetless
# by Nick Meredith
ep2_locale_events.1050 = {
	type = activity_event
	title = ep2_locale_events.1050.t
	desc = ep2_locale_events.1050.desc
	theme = physical_health  
	# override_background = { reference = market }  
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:wealthy_gambler
		animation = scheme
	}
	cooldown = { years = 1 }

	trigger = {
		is_participant_in_activity = scope:activity

		activity_is_valid_tournament_contestant = yes

		#AGOT Disabled
		# NOT = { #Muslims shouldn't be gambling if they're zealous
		# 	AND = {
		# 		faith = { religion_tag = islam_religion }
		# 		has_trait = zealous
		# 	}
		# }
		NOT = { #You could conceivably be accused of cowardice
			has_trait = brave
		}

		scope:activity = { #Ensure the upcoming Contest is actually dangerous and requires armour
			OR = {
				has_current_phase = tournament_phase_melee
				has_current_phase = tournament_phase_joust
				has_current_phase = tournament_phase_duel
			}
		}
	}

	immediate = {
		play_music_cue = mx_cue_tavern
		if = {
			limit = {
				any_pool_character = {
					province = scope:activity.activity_location
					is_available_ai_adult = yes
					has_no_particular_noble_roots_trigger = yes
					gold > 50
				}
			}
			random_pool_character = {
				province = scope:activity.activity_location
				limit = {
					is_available_ai_adult = yes
					has_no_particular_noble_roots_trigger = yes
					gold > 50
				}
				weight = {
					base = 1
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = wealthy_gambler
			}
		}
		else = {
			create_character = {
				template = wealthy_gambler_template
				dynasty = none
				location = scope:activity.activity_location
				gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
				save_scope_as = wealthy_gambler
			}
		}
		try_to_create_recurring_character_effect = { CHARACTER = scope:wealthy_gambler }
	}

	# Threaten to expose them to their gambling partners unless they pay you
	option = {
		name = ep2_locale_events.1050.a

		trigger = {
			has_trait = deceitful
		}

		scope:wealthy_gambler = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}

		reverse_add_opinion = {
			target = scope:wealthy_gambler
			modifier = angry_opinion
			opinion = -45
		}

		stress_impact = {
			base = minor_stress_impact_loss
			compassionate = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
			wrathful = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
		}

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

	# Offended, you compete without a helmet or gloves
	option = {
		name = ep2_locale_events.1050.b

		trigger = {
			has_trait = arrogant
		}
		
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = decrease_medium }
		}

		scope:wealthy_gambler = {
			pay_short_term_gold = {
				target = root
				gold = minor_gold_value
			}
		}

		add_character_flag = {
			flag = no_headgear
			months = 3
		}

		reverse_add_opinion = {
			target = scope:wealthy_gambler
			modifier = impressed_opinion
			opinion = 35
		}

		stress_impact = {
			base = minor_stress_impact_loss
			wrathful = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			paranoid = medium_stress_impact_gain
		}

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

	# Accept
	option = {
		name = ep2_locale_events.1050.c

		trigger = {
			NOR = {
				has_trait = arrogant
				has_trait = deceitful
			}
		}
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
		}

		add_character_flag = {
			flag = no_headgear
			months = 3
		}

		reverse_add_opinion = {
			target = scope:wealthy_gambler
			modifier = pleased_opinion
			opinion = 25
		}		

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			stubborn = medium_stress_impact_gain
			arrogant = miniscule_stress_impact_loss
			humble = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_greed = 1
			}
		}
	}

	# Decline
	option = {
		name = ep2_locale_events.1050.d
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
		}

		reverse_add_opinion = {
			target = scope:wealthy_gambler
			modifier = disappointed_opinion
			opinion = -15
		}		

		stress_impact = {
			greedy = medium_stress_impact_gain
			stubborn = miniscule_stress_impact_loss
			arrogant = medium_stress_impact_gain
			humble = miniscule_stress_impact_loss
			deceitful = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -0.5
				ai_greed = -1
			}
		}
	}
}

#######################################
#######################################
### 	TEMPLE - 1500-1999			###
#######################################
#######################################

##################################################
# God's Favors
# by Joe Parkin
# 1500
##################################################

scripted_trigger tournament_prayer_target_trigger = {
	is_participant_in_activity = scope:activity
	activity_is_valid_tournament_contestant = yes
	NAND = {
		exists = root.var:tournament_wager_target
		this = root.var:tournament_wager_target
	}
}

ep2_locale_events.1500 = {
	type = activity_event
	title = ep2_locale_events.1500.t
	desc = {
		first_valid = {
		    triggered_desc = {
		        trigger = { faith = scope:activity.activity_location.faith }
		        desc = ep2_locale_events.1500.host_faith
		    }
		    desc = ep2_locale_events.1500.other_faith
		}
		desc = ep2_locale_events.1500.desc
	}
	theme = tournament_locale_temple
	left_portrait = {
		character = root
		animation = throne_room_bow_1
	}
	right_portrait = {
		character = scope:tournament_priest
		animation = personality_zealous
	}
	lower_left_portrait = scope:bad_prayer_target
	lower_center_portrait = scope:good_prayer_target
	lower_right_portrait = {
		trigger = { exists = scope:backup_prayer_target }
		character = scope:backup_prayer_target
	}
	cooldown = { years = 1 }

	trigger = {
		OR = {
			activity_is_valid_tournament_contestant = yes
			any_relation = { tournament_prayer_target_trigger = yes }
			any_child = { tournament_prayer_target_trigger = yes }
			any_consort = { tournament_prayer_target_trigger = yes }
			AND = {
				exists = intent_target
				intent_target = { tournament_prayer_target_trigger = yes }
			}
		}
		scope:activity = {
			has_active_locale = tournament_locale_religious_building
			exists = var:tournament_priest
			var:tournament_priest = { is_alive = yes }
		}
	}

	immediate = {
		play_music_cue = mx_cue_temple
		every_child = {
			limit = { tournament_prayer_target_trigger = yes }
			add_to_list = good_prayer_targets
		}
		every_consort = {
			limit = { tournament_prayer_target_trigger = yes }
			add_to_list = good_prayer_targets
		}
		every_relation = {
			type = friend
			type = lover
			limit = { tournament_prayer_target_trigger = yes }
			add_to_list = good_prayer_targets
		}
		every_relation = {
			type = rival
			limit = { tournament_prayer_target_trigger = yes }
			add_to_list = bad_prayer_targets
		}
		if = {
			limit = { exists = intent_target }
			if = {
				limit = { has_activity_intent = murder_attendee_intent }
				intent_target = { add_to_list = bad_prayer_targets }
			}
			else = {
				intent_target = { add_to_list = good_prayer_targets }
			}
		}
		if = {
			limit = {
				employs_court_position = champion_court_position
				court_position:champion_court_position = { tournament_prayer_target_trigger = yes }
			}
			court_position:champion_court_position = { add_to_list = good_prayer_targets }
		}
		set_variable = { name = prayer_options_count value = 1 }
		if = {
			limit = { activity_is_valid_tournament_contestant = yes }
			change_variable = { name = prayer_options_count add = 1 }
		}
		if = {
			limit = {
				exists = var:tournament_wager_target
				NOT = { var:tournament_wager_target = root }
			}
			var:tournament_wager_target = { save_scope_as = wager_prayer_target }
			change_variable = { name = prayer_options_count add = 1 }
		}
		if = {
			limit = {
				any_in_list = { list = good_prayer_targets }
			}
			random_in_list = {
				list = good_prayer_targets
				limit = { has_relation_soulmate = root }
				alternative_limit = { has_relation_best_friend = root }
				alternative_limit = { is_child_of = root }
				alternative_limit = {
					exists = root.primary_spouse
					this = root.primary_spouse
				}
				alternative_limit = { always = yes }
				save_scope_as = good_prayer_target
				remove_from_list = good_prayer_targets
			}
			change_variable = { name = prayer_options_count add = 1 }
		}
		if = {
			limit = {
				any_in_list = { list = bad_prayer_targets }
			}
			random_in_list = {
				list = bad_prayer_targets
				limit = { has_relation_nemesis = root }
				alternative_limit = { has_relation_rival = root }
				alternative_limit = { always = yes }
				save_scope_as = bad_prayer_target
				remove_from_list = bad_prayer_targets
			}
			change_variable = { name = prayer_options_count add = 1 }
		}
		if = {
			limit = {
				exists = var:prayer_options_count
				var:prayer_options_count < 4
			}
			random_list = {
				50 = {
					trigger = {
						any_in_list = { list = good_prayer_targets }
					}
					random_in_list = {
						list = good_prayer_targets
						limit = { has_relation_soulmate = root }
						alternative_limit = { has_relation_best_friend = root }
						alternative_limit = { is_child_of = root }
						alternative_limit = {
							exists = root.primary_spouse
							this = root.primary_spouse
						}
						alternative_limit = { always = yes }
						save_scope_as = backup_prayer_target
					}
				}
				50 = {
					trigger = {
						any_in_list = { list = bad_prayer_targets }
					}
					random_in_list = {
						list = bad_prayer_targets
						limit = { has_relation_nemesis = root }
						alternative_limit = { has_relation_rival = root }
						alternative_limit = { always = yes }
						save_scope_as = backup_prayer_target
					}
				}
			}
		}
		scope:activity = {
			var:tournament_priest = { save_scope_as = tournament_priest }
		}
	}

	weight_multiplier = {
		base = 100
		modifier = {
			factor = 0.5
			has_trait = cynical
		}
	}

	# Victory
	option = {
		name = ep2_locale_events.1500.a
		trigger = { activity_is_competing_trigger = yes }
		random = {
			chance = 50
			activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		}
		if = {
			limit = {
				NOT = { has_activity_intent = win_contest_intent }
			}
			stress_impact = {
				humble = minor_stress_impact_gain
				content = minor_stress_impact_gain
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 0.5
			}
		}
	}

	# Wish harm
	option = {
		name = ep2_locale_events.1500.b
		trigger = { exists = scope:bad_prayer_target }
		scope:bad_prayer_target = { 
			if = {
				limit = { activity_is_competing_trigger = yes }
				random = {
					chance = 50
					activity_tournament_change_contestant_score_effect = { SCORE = decrease_medium }
				}
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = -0.5
			}
		}
	}

	# Wish well
	option = {
		name = ep2_locale_events.1500.c
		trigger = { exists = scope:good_prayer_target }
		scope:good_prayer_target = { 
			if = {
				limit = { activity_is_competing_trigger = yes }
				random = {
					chance = 50
					activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
				}
			}
		}
		progress_towards_friend_effect = {
			CHARACTER = scope:good_prayer_target
			REASON = friend_prayed_for_me
			OPINION = default_friend_opinion
		}
		add_piety = minor_piety_gain
		stress_impact = {
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		if = {
			limit = { has_activity_intent = win_contest_intent }
			stress_impact = { base = medium_stress_impact_gain }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_compassion = 1
			}
		}
	}

	# Wish harm 2
	option = {
		name = ep2_locale_events.1500.d
		trigger = {
			exists = scope:backup_prayer_target
			scope:backup_prayer_target = { is_in_list = bad_prayer_targets }
		}
		scope:backup_prayer_target = { 
			if = {
				limit = { activity_is_competing_trigger = yes }
				random = {
					chance = 50
					activity_tournament_change_contestant_score_effect = { SCORE = decrease_medium }
				}
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = -0.5
			}
		}
	}

	# Wish well 2
	option = {
		name = ep2_locale_events.1500.e
		trigger = {
			exists = scope:backup_prayer_target
			scope:backup_prayer_target = { is_in_list = good_prayer_targets }
		}
		scope:backup_prayer_target = {
			if = {
				limit = { activity_is_competing_trigger = yes }
				random = {
					chance = 50
					activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
				}
			}
		}
		progress_towards_friend_effect = {
			CHARACTER = scope:good_prayer_target
			REASON = friend_prayed_for_me
			OPINION = default_friend_opinion
		}
		add_piety = minor_piety_gain
		stress_impact = {
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		if = {
			limit = { has_activity_intent = win_contest_intent }
			stress_impact = { base = medium_stress_impact_gain }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_compassion = 1
			}
		}
	}

	# Win big
	option = {
		name = ep2_locale_events.1500.f
		trigger = { exists = scope:wager_prayer_target }
		scope:wager_prayer_target = {
			if = {
				limit = { activity_is_competing_trigger = yes }
				random = {
					chance = 50
					activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
				}
			}
		}
		stress_impact = {
			generous = minor_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		if = {
			limit = { has_activity_intent = win_contest_intent }
			stress_impact = { base = medium_stress_impact_gain }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_greed = 1
			}
		}
	}

	# Inner peace
	option = {
		name = ep2_locale_events.1500.g
		add_piety = medium_piety_gain
		stress_impact = {
			base = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
			calm = minor_stress_impact_loss
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_energy = -1
			}
		}
	}

	after = { remove_variable = prayer_options_count }
}

# Make a pious showing for a seduce target
# by Nick Meredith
ep2_locale_events.1501 = {
	type = activity_event
	title = ep2_locale_events.1501.t
	desc = ep2_locale_events.1501.desc
	theme = friendly  
	override_background = { reference = temple_scope }
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:seduce_target
		animation = personality_zealous
	}
	cooldown = { years = 1 }

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = {
		tournament_intent_locale_trigger = { INTENT = woo_attendee }
		root.faith = root.location.faith
		intent_target.faith = root.faith
		scope:activity = { 
			has_active_locale = tournament_locale_religious_building
		}
	}

	immediate = {
		play_music_cue = mx_cue_temple
		intent_target = { save_scope_as = seduce_target }
	}

	# Pray very performatively
	option = {
		name = ep2_locale_events.1501.a

		flavor = ep2_locale_events.1501.a.tt

		add_piety = minor_piety_gain

		random_list = {
			10 = {
				desc = ep2_locale_events.1501.a.success
				show_chance = no

				modifier = { #They love zealous people
					scope:seduce_target = {
						has_trait = zealous
					}
					add = 100
				}

				modifier = { #They hate cynics
					scope:seduce_target = {
						has_trait = cynical
					}
					add = -100
				}

				modifier = { #They trust your display of faith
					scope:seduce_target = {
						has_trait = trusting
					}
					add = 10
				}

				modifier = { #They doubt your display of faith
					scope:seduce_target = {
						has_trait = paranoid
					}
					add = -10
				}

				modifier = { #They think you're being honest
					scope:seduce_target = {
						has_trait = honest
					}
					add = 5
				}

				modifier = { #They reckon you're lying like they would
					scope:seduce_target = {
						has_trait = deceitful
					}
					add = -5
				}

				send_interface_toast = {
					title = ep2_locale_events.1501.a.success
					left_icon = root
					right_icon = scope:seduce_target
				
					progress_towards_lover_effect = {
						CHARACTER = scope:seduce_target
						OPINION = default_lover_opinion
						REASON = lover_tournament_praying
					}	
				}
			}
			10 = {
				desc = ep2_locale_events.1501.a.failure
				show_chance = no

				send_interface_toast = {
					title = ep2_locale_events.1501.a.failure
					left_icon = root
					right_icon = scope:seduce_target
				
					reverse_add_opinion = {
						target = scope:seduce_target
						modifier = disappointed_opinion
						opinion = -15
					}
				}
			}
		}

		stress_impact = {
			zealous = miniscule_stress_impact_loss
			cynical = major_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_zeal = 1
				ai_rationality = -1
			}
		}
	}

	# Pray cynically
	option = {
		name = ep2_locale_events.1501.b

		random_list = {
			10 = {
				desc = ep2_locale_events.1501.b.success
				show_chance = no

				modifier = { #They aren't keen on zealots
					scope:seduce_target = {
						has_trait = zealous
					}
					add = -100
				}

				modifier = { #But they love cynics
					scope:seduce_target = {
						has_trait = cynical
					}
					add = 100
				}

				modifier = { #They trust your display of cynicism
					scope:seduce_target = {
						has_trait = trusting
					}
					add = 10
				}

				modifier = { #They doubt you don't actually believe
					scope:seduce_target = {
						has_trait = paranoid
					}
					add = -10
				}

				modifier = { #They think you're being honest
					scope:seduce_target = {
						has_trait = honest
					}
					add = 5
				}

				modifier = { #They reckon you're lying like they would
					scope:seduce_target = {
						has_trait = deceitful
					}
					add = -5
				}

				send_interface_toast = {
					title = ep2_locale_events.1501.b.success
					left_icon = root
					right_icon = scope:seduce_target
				
					progress_towards_lover_effect = {
						CHARACTER = scope:seduce_target
						OPINION = default_lover_opinion
						REASON = lover_tournament_cynical_prayer
					}
				}
			}
			10 = {
				desc = ep2_locale_events.1501.b.failure
				show_chance = no

				send_interface_toast = {
					title = ep2_locale_events.1501.b.failure
					left_icon = root
					right_icon = scope:seduce_target
				
					reverse_add_opinion = {
						target = scope:seduce_target
						modifier = disappointed_opinion
						opinion = -15
					}
				}
			}
		}

		stress_impact = {
			cynical = miniscule_stress_impact_loss
			zealous = major_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_zeal = 1
				ai_rationality = -1
			}
		}
	}

	# Leave the church entirely
	option = {
		name = ep2_locale_events.1501.c

		reverse_add_opinion = {
			target = scope:seduce_target
			modifier = disappointed_opinion
			opinion = -15
		}		

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_rationality = 0.5
			}
		}
	}
}

##################################################
# Sacrilegious Spree
# by Joe Parkin
# 1510
##################################################

ep2_locale_events.1510 = {
	type = activity_event
	title = ep2_locale_events.1510.t
	desc = {
		desc = ep2_locale_events.1510.desc
		first_valid = {
		    triggered_desc = {
		        trigger = {
					scope:instigator_scope = {
						OR = {
							faith = {
								NOT = { trait_is_sin = drunkard }
							}
							has_trait = drunkard
						}
					}
		        }
		        desc = ep2_locale_events.1510.alcohol
		    }
		    triggered_desc = {
		        trigger = {
					scope:instigator_scope = {
						OR = {
							faith = {
								NOT = { trait_is_sin = hashishiyah }
							}
							has_trait = hashishiyah
						}
					}
		        }
		        desc = ep2_locale_events.1510.hashish
		    }
		}
		desc = ep2_locale_events.1510.closing
	}
	theme = faith  
	# override_background = { reference = market }  
	cooldown = { years = 1 }

	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:instigator_scope
		triggered_animation = {
			trigger = {
				OR = {
					faith = {
						NOT = { trait_is_sin = drunkard }
					}
					has_trait = drunkard
				}
			}
			animation = drink
		}
		triggered_animation = {
			trigger = {
				NOR = {
					faith = {
						NOT = { trait_is_sin = drunkard }
					}
					has_trait = drunkard
				}
			}
			animation = happiness
		}
	}
	lower_right_portrait = scope:tournament_priest

	trigger = {
		this = scope:host
		scope:activity = {
			any_attending_character = {
				NOT = { this = root }
				activity_is_valid_tournament_contestant = yes
				is_landed = no
				NOR = {
					is_close_family_of = root
					is_consort_of = root
					has_trait = temperate
					has_trait = zealous
					has_trait = shy
				}
			}
			has_active_locale = tournament_locale_religious_building
			exists = var:tournament_priest
			var:tournament_priest = { is_alive = yes }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			has_trait = cynical
		}
	}

	immediate = {
		play_music_cue = mx_cue_temple
		scope:activity = {
			random_attending_character = {
				limit = {
					NOT = { this = root }
					activity_is_valid_tournament_contestant = yes
					is_landed = no
					NOR = {
						is_close_family_of = root
						is_consort_of = root
						has_trait = temperate
						has_trait = zealous
						has_trait = shy
					}
					NAND = {
						exists = root.cp:councillor_court_chaplain
						this = root.cp:councillor_court_chaplain
					}
				}
				weight = {
					modifier = {
						factor = 10
						has_trait = drunkard
					}
					modifier = {
						factor = 10
						has_trait = hashishiyah
					}
					modifier = {
						factor = 10
						has_trait = gluttonous
					}
					modifier = {
						factor = 10
						has_trait = gregarious
					}
					modifier = {
						factor = 10
						NOT = { faith = scope:host.faith }
					}					
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = instigator_scope
			}
			var:tournament_priest = {
				save_scope_as = tournament_priest
			}
		}
	}

	weight_multiplier = {
		base = 100
		modifier = {
			factor = 0.5
			has_trait = cynical
		}
	}

	option = { # Imprison
		name = ep2_locale_events.1510.a
		add_piety = medium_piety_gain
		rightfully_imprison_character_effect = { TARGET = scope:instigator_scope IMPRISONER = root }
		if = {
			limit = { exists = scope:tournament_priest }
			reverse_add_opinion = {
				target = scope:tournament_priest
				modifier = tournament_arrested_revelers_opinion
				opinion = 15
			}
		}
		reverse_add_opinion = {
			target = scope:instigator_scope
			modifier = tournament_arrested_revelers_opinion
			opinion = -10
		}
		try_to_create_recurring_character_effect = { CHARACTER = scope:tournament_priest }
		stress_impact = {
			gluttonous = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:tournament_priest
				multiplier = 0.5
			}
			ai_value_modifier = {
				ai_zeal = 0.5
				ai_vengefulness = 0.5
				ai_boldness = 1
			}
		}
	}

	# Party? Where's the party?
	option = {
		name = ep2_locale_events.1510.b
		progress_towards_friend_effect = {
			CHARACTER = scope:instigator_scope
			OPINION = default_friend_opinion
			REASON = friend_tournament_church_party
		}
		if = {
			limit = { exists = scope:tournament_priest }
			reverse_add_opinion = {
				target = scope:tournament_priest
				modifier = tournament_favored_revelers_opinion
				opinion = -10
			}
		}
		try_to_create_recurring_character_effect = { CHARACTER = scope:instigator_scope }
		stress_impact = {
			temperate = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			opinion_modifier = {
				opinion_target = scope:instigator_scope
				multiplier = 0.5
			}
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_boldness = 0.5
				ai_zeal = -1
			}
		}
	}

	# Foul heathens
	option = {
		name = ep2_locale_events.1510.c
		trigger = {
			NOT = { scope:instigator_scope.faith = root.faith }
		}
		add_prestige = medium_prestige_gain
		scope:activity = {
			every_attending_character = {
				limit = { faith = scope:instigator_scope.faith }
				custom = every_faith_attending_character_tt
				add_opinion = {
					target = root
					modifier = tournament_religious_tension_opinion
					opinion = -15
				}
			}
		}
		if = {
			limit = { exists = scope:tournament_priest }
			reverse_add_opinion = {
				target = scope:tournament_priest
				modifier = tournament_religious_tension_opinion
				opinion = 10
			}
		}
		try_to_create_recurring_character_effect = { CHARACTER = scope:instigator_scope }
		stress_impact = {
			theologian = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 0.5
				ai_zeal = 1
			}
		}
	}

	# Harmless
	option = {
		name = ep2_locale_events.1510.d
		if = {
			limit = { exists = scope:tournament_priest }
			reverse_add_opinion = {
				target = scope:tournament_priest
				modifier = tournament_arrested_revelers_opinion
				opinion = -10
			}
		}
		reverse_add_opinion = {
			target = scope:instigator_scope
			modifier = tournament_arrested_revelers_opinion
			opinion = 5
		}
		try_to_create_recurring_character_effect = { CHARACTER = scope:tournament_priest }
		stress_impact = {
			vengeful = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
				ai_zeal = -0.5
			}
		}
	}
}

#######################################
#######################################
### 	ARMORER - 2000-2499			###
#######################################
#######################################

# Improve some armour
# by Nick Meredith
ep2_locale_events.2001 = {
	type = activity_event
	title = ep2_locale_events.2001.t
	desc = ep2_locale_events.2001.desc
	theme = physical_health  
	# override_background = { reference = market }  
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:tournament_armorer
		animation = personality_honorable
	}
	artifact = {
		target = scope:improve_armour
		position = lower_center_portrait
	}

	trigger = {
		any_character_artifact = {
			#AGOT MODIFIED 
			#is_equipped = yes
			#artifact_slot_type = armor
			AND = {
				is_equipped = yes
				artifact_slot_type = armor
				NOT = { has_variable = ep2_locale_events_2001_improved }
			}
		}
		scope:activity = {
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_armorer
			var:tournament_armorer = { is_alive = yes }
		}
		activity_tournament_armor_contest_trigger = yes
	}

	immediate = {
		play_music_cue = mx_cue_armorer
		scope:activity = {
			var:tournament_armorer = {
				save_scope_as = tournament_armorer
				try_to_create_recurring_character_effect = { CHARACTER = root }
			}
		}

		random_character_artifact = {
			limit = {
				#AGOT MODIFIED 
				#is_equipped = yes
				#artifact_slot_type = armor
				AND = {
					is_equipped = yes
					artifact_slot_type = armor
					NOT = { has_variable = ep2_locale_events_2001_improved }
				}
			}
			save_scope_as = improve_armour
		}
	}

	# Burnish armour
	option = {
		name = ep2_locale_events.2001.a
		remove_short_term_gold = medium_gold_value
		scope:improve_armour = {
			custom_tooltip = ep2_locale_events.2001.a.tt
		}
		hidden_effect = {
			scope:improve_armour = {
				add_artifact_modifier = artifact_monthly_minor_prestige_1_modifier
				#AGOT ADDED
				set_variable = { 
					name = ep2_locale_events_2001_improved
					value = yes
				}
			}
		}
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_loss
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -1
				ai_boldness = 1
			}
		}
	}

	# Oil armour
	option = {
		name = ep2_locale_events.2001.b

		remove_short_term_gold = medium_gold_value

		scope:improve_armour = {
			custom_tooltip = ep2_locale_events.2001.b.tt
		}

		hidden_effect = {
			scope:improve_armour = {
				add_artifact_modifier = artifact_prowess_1_modifier
				#AGOT ADDED
				set_variable = { 
					name = ep2_locale_events_2001_improved
					value = yes
				}
			}
		}
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = miniscule_stress_impact_loss
			diligent = minor_stress_impact_loss
			lazy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -1
				ai_honor = 1
			}
		}
	}

	# Never mind
	option = {
		name = ep2_locale_events.2001.c

		reverse_add_opinion = {
			target = scope:tournament_armorer
			modifier = disappointed_opinion
			opinion = -15
		}

		stress_impact = {
			greedy = minor_stress_impact_loss
			generous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 1
				ai_energy = -1
			}
		}
	}
}

# Tattered Straps
# by Nick Meredith
ep2_locale_events.2002 = {
	type = activity_event
	title = ep2_locale_events.2002.t
	desc = ep2_locale_events.2002.desc
	theme = physical_health  
	# override_background = { reference = market }  
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:tournament_armorer
		animation = personality_honorable
	}
	artifact = {
		target = scope:armour
		position = lower_center_portrait
	}

	trigger = {
		any_character_artifact = {
			#AGOT MODIFIED 
			#is_equipped = yes
			#artifact_slot_type = armor
			AND = {
				is_equipped = yes
				artifact_slot_type = armor
				NOT = { has_variable = ep2_locale_events_2002_improved }
			}
		}
		scope:activity = {
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_armorer
			var:tournament_armorer = { is_alive = yes }
		}
		activity_tournament_armor_contest_trigger = yes
	}

	immediate = {
		play_music_cue = mx_cue_armorer
		scope:activity = {
			var:tournament_armorer = {
				save_scope_as = tournament_armorer
				try_to_create_recurring_character_effect = { CHARACTER = root }
			}
		}

		random_character_artifact = {
			limit = {
				#AGOT MODIFIED
				#is_equipped = yes
				#artifact_slot_type = armor
				AND = {
					is_equipped = yes
					artifact_slot_type = armor
					NOT = { has_variable = ep2_locale_events_2002_improved }
				}
			}
			save_scope_as = armour
			save_scope_as = improve_armour
		}

		create_character = {
			age = { 16 21 }
			dynasty = none
			random_traits = yes
			gender_female_chance = 50
			culture = scope:tournament_armorer.culture
			faith = scope:tournament_armorer.faith
			location = scope:tournament_armorer.location
			save_scope_as = apprentice
		}
	}

	# Threaten them
	option = {
		name = ep2_locale_events.2002.a

		trigger = {
			dread >= 40
		}

		add_opinion = {
			target = scope:tournament_armorer
			modifier = scared_opinion
			opinion = -15
		}
		custom_tooltip = ep2_locale_events.2001.a.tt
		hidden_effect = {
			scope:armour = {
				add_artifact_modifier = artifact_monthly_minor_prestige_1_modifier
				#AGOT ADDED
				set_variable = { 
					name = ep2_locale_events_2002_improved
					value = yes
				}
			}
		}
		
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
		}

		stress_impact = {
			wrathful = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			calm = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = forgiving
					has_trait = compassionate
				}
			}
		}
	}

	# Challenge them directly
	option = {
		name = ep2_locale_events.2002.b
		trigger = { activity_is_competing_trigger = yes }
		duel = {
			skill = diplomacy
			target = scope:tournament_armorer

			# They grudgingly agree to fix it
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				opinion_modifier = {
					who = scope:tournament_armorer
					opinion_target = root
					multiplier = 0.5
				}
				desc = ep2_locale_events.2002.b.success
				send_interface_toast = {
					title = ep2_locale_events.2002.b.success
					left_icon = root
					right_icon = scope:tournament_armorer

					activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
				}
			}

			# They worm their way out of it
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				#AGOT Modified, vanilla bug
				#desc = ep2_locale_events.4001.a.failure
				desc = ep2_locale_events.2002.b.failure
				send_interface_toast = {
					#AGOT Modified, vanilla bug
					#title = ep2_locale_events.4001.a.failure
					title = ep2_locale_events.2002.b.failure
					left_icon = root
					right_icon = scope:tournament_armorer

					activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
				}
			}
		}

		stress_impact = {
			shy = minor_stress_impact_gain
			trusting = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			vengeful = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = trusting
					has_trait = forgiving
				}
			}
		}
	}

	# Take it back and do it properly
	option = {
		name = ep2_locale_events.2002.c
		trigger = { activity_is_competing_trigger = yes }

		remove_short_term_gold = minor_gold_value

		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }

		reverse_add_opinion = {
			target = scope:tournament_armorer
			modifier = annoyed_opinion
			opinion = -10
		}

		stress_impact = {
			wrathful = medium_stress_impact_gain
			vengeful = medium_stress_impact_gain
			calm = miniscule_stress_impact_loss
			forgiving = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = wrathful
					has_trait = vengeful
				}
			}
		}
	}

	# I don't have time for this
	option = {
		name = ep2_locale_events.2002.d
		
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = decrease_medium }
		}

		stress_impact = {
			diligent = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
			lazy = miniscule_stress_impact_loss
			greedy = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = diligent
					has_trait = trusting
				}
			}
		}
	}
}

##################################################
# Defensive Gifts
# by Joe Parkin
# 2010-2012
##################################################

scripted_effect tournament_gift_relationship_effect = {
	scope:befriend_actor = {
		if = {
			limit = { has_activity_intent = befriend_attendee_intent }
			progress_towards_friend_effect = {
				CHARACTER = scope:befriend_target
				OPINION = default_friend_opinion
				REASON =  friend_tournament_shop_gift
			}
		}
		else = {
			progress_towards_lover_effect = {
				CHARACTER = scope:befriend_target
				OPINION = default_lover_opinion
				REASON =  friend_tournament_shop_gift
			}
		}
	}
}

scripted_effect tournament_gift_outcome_effect = {
	show_as_tooltip = {
		scope:befriend_actor = {
			random_list = {
				10 = {
					desc = ep2_locale_events_gift_success
					show_chance = no
					tournament_gift_relationship_effect = yes
				}
				10 = {
					desc = ep2_locale_events_gift_failure
					show_chance = no
					reverse_add_opinion = {
						target = scope:befriend_target
						modifier = tournament_failed_gift_opinion
						opinion = -5
					}
				}
			}
		}
	}
}

# Decision
ep2_locale_events.2010 = {
	type = activity_event
	title = ep2_locale_events.2010.t
	desc = ep2_locale_events.2010.desc
	theme = friendly  
	override_background = { reference = armory }
	left_portrait = {
		character = root
		animation = worry
	}
	lower_right_portrait = scope:befriend_target
	cooldown = { years = 1 }

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = {
		OR = {
			tournament_intent_locale_trigger = { INTENT = befriend_attendee }
			tournament_intent_locale_trigger = { INTENT = woo_attendee }
		}
		intent_target = {
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root.intent_target }
		}
		scope:activity = {
			has_active_locale = tournament_locale_artisans
		}
	}

	immediate = {
		play_music_cue = mx_cue_armorer
		save_scope_as = befriend_actor
		intent_target = { save_scope_as = befriend_target }
	}

	# Buy armor
	option = {
		name = ep2_locale_events.2010.a
		remove_short_term_gold =  minor_gold_value
		custom_tooltip = ep2_locale_events.2010.a.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:armor
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
				ai_greed = -0.5
			}
		}
	}

	# Buy shield
	option = {
		name = ep2_locale_events.2010.b
		remove_short_term_gold =  medium_gold_value
		custom_tooltip = ep2_locale_events.2010.b.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:shield
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -1
				ai_boldness = -0.5
				ai_greed = -1
			}
		}
	}

	# Buy tournament helmet
	option = {
		name = ep2_locale_events.2010.c
		remove_short_term_gold =  tiny_gold_value
		custom_tooltip = ep2_locale_events.2010.c.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:tournament
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.5
				ai_boldness = 0.5
				ai_greed = -0.5
			}
		}
	}

	# No buy
	option = {
		name = ep2_locale_events.2010.d
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_boldness = -0.5
				ai_greed = 1
			}
		}
	}

	after = {
		if = {
			limit = { exists = scope:befriend_approach }
			hidden_effect = {
				#Evaluate what makes for a "right" choice
				if = {
					limit = {
						OR = {
							AND = {
								has_trait = craven
								exists = scope:befriend_approach
								scope:befriend_approach = flag:armor
							}
							AND = {
								has_trait = arrogant
								exists = scope:befriend_approach
								scope:befriend_approach = flag:shield
							}
							AND = {
								OR = {
									has_activity_intent = win_contest_intent
									has_trait = diligent
									has_trait = lifestyle_blademaster
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:tournament
							}
						}
					}
					save_scope_value_as = {
						name = made_great_choice
						value = yes
					}
				}
				random_list = {
					50 = {
						modifier = {
							add = 100
							exists = scope:made_great_choice
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:armor
							has_trait = craven
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:shield
							has_trait = arrogant
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:tournament
							has_trait = diligent
						}						
						save_scope_as = befriend_success
					}
					50 = {
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:armor
							has_trait = brave
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:shield
							has_trait = humble
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:tournament
							has_trait = lazy
						}
						save_scope_as = befriend_failure
					}
				}
				scope:befriend_target = {
					trigger_event = {
						id = ep2_locale_events.2011
						days = { 1 2 }
					}
				}			
			}
		}
	}
}

scripted_effect tournament_armorer_tooltip_effect = {
	show_as_tooltip = {
		if = {
			limit = { exists = scope:newly_created_artifact }
			show_as_tooltip = {
				scope:newly_created_artifact = { set_owner = scope:befriend_target }
			}
		}
		else_if = {
			limit = { has_character_modifier = tournament_armorer_shield_modifier }
			add_character_modifier = { modifier = tournament_armorer_shield_modifier years = 20 }
		}
		else_if = {
			limit = { has_character_modifier = tournament_armorer_tournament_modifier }
			add_character_modifier = { modifier = tournament_armorer_tournament_modifier years = 20 }
		}
	}
}

#Target
ep2_locale_events.2011 = {
	type = activity_event
	title = ep2_locale_events.2010.t
	desc = {
		desc = ep2_locale_events.2011.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:armor
				}
				desc = ep2_locale_events.2011.success_armor
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:armor }
				desc = ep2_locale_events.2011.armor
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:shield
				}
				desc = ep2_locale_events.2011.success_shield
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:shield }
				desc = ep2_locale_events.2011.shield
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:tournament
				}
				desc = ep2_locale_events.2011.success_tournament
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:tournament }
				desc = ep2_locale_events.2011.tournament
			}
		}
	}
	left_portrait = {
		character = scope:befriend_actor
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:befriend_success }
			}
			animation = sadness
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = friendly  
	override_background = { reference = armory }

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_armorer
		scope:befriend_actor = {
			save_scope_as = owner 
			get_artifact_quality_effect = yes
			get_artifact_wealth_effect = yes
		}
		hidden_effect = {
			switch = {
				trigger = scope:befriend_approach
				flag:armor = {
					create_artifact_armor_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_ARMOR_TYPE = flag:no } 
				}
				flag:shield = {
					if = {
						limit = { has_royal_court = yes }
						create_artifact_wall_shield_effect = {
							OWNER = scope:befriend_target
							CREATOR = scope:befriend_actor
							TARGET = scope:befriend_target.house						
						}
					}
					else = {
						add_character_modifier = { modifier = tournament_armorer_shield_modifier years = 20 }
					}
				}
				flag:tournament = {
					add_character_modifier = { modifier = tournament_armorer_tournament_modifier years = 20 }
				}
			}
		}
		tournament_armorer_tooltip_effect = yes
		scope:befriend_actor = {
			trigger_event = {
				id = ep2_locale_events.2012
				days = { 1 2 }
			}
		}
	}

	option = {
		name = ep2_locale_events.2011.a
		trigger = { exists = scope:befriend_success }
		add_stress = minor_stress_loss
		show_as_tooltip = { tournament_gift_relationship_effect = yes }
	}

	option = {
		name = ep2_locale_events.2011.b
		trigger = { exists = scope:befriend_failure }
	}
}

#Actor
ep2_locale_events.2012 = {
	type = activity_event
	title = ep2_locale_events.2010.t
	desc = {
		desc = ep2_locale_events.2012.opening
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.2012.success_reply
			}
			desc = ep2_locale_events.2012.reply
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:armor
				}
				desc = ep2_locale_events.2012.success_armor
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:armor }
				desc = ep2_locale_events.2012.armor
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:shield
				}
				desc = ep2_locale_events.2012.success_shield
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:shield }
				desc = ep2_locale_events.2012.shield
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:tournament
				}
				desc = ep2_locale_events.2012.success_tournament
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:tournament }
				desc = ep2_locale_events.2012.tournament
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.2012.success
			}
			desc = ep2_locale_events.2012.failure
		}
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = worry
		}
	}
	right_portrait = {
		character = scope:befriend_target
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = happiness
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = disapproval
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = friendly  
	override_background = { reference = army_camp }

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_armorer
		scope:befriend_target = { tournament_armorer_tooltip_effect = yes }
	}

	option = {
		name = ep2_locale_events.2012.a
		trigger = { exists = scope:befriend_success }
		tournament_gift_relationship_effect = yes
	}

	option = {
		name = ep2_locale_events.2012.b
		trigger = { exists = scope:befriend_failure }
		reverse_add_opinion = {
			target = scope:befriend_target
			modifier = tournament_failed_gift_opinion
			opinion = -5
		}
	}
}

# Gleaming Panoply
# by Nick Meredith
ep2_locale_events.2050 = {
	type = activity_event
	title = ep2_locale_events.2050.t
	desc = ep2_locale_events.2050.desc
	theme = friendly
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:tournament_armorer
		animation = scheme
	}
	artifact = {
		target = scope:upgrade_armour
		position = lower_right_portrait
	}
	override_background = { reference = armory }
	cooldown = { years = 1 }

	trigger = {
		any_equipped_character_artifact = {
			#AGOT MODIFIED
			#artifact_slot_type = armor
			AND = {
				artifact_slot_type = armor
				NOT = { has_variable = ep2_locale_events_2050_improved }
			}
		}
		scope:activity = { 
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_armorer
			var:tournament_armorer = { is_alive = yes }
		}
		activity_tournament_armor_contest_trigger = yes
	}

	immediate = {
		play_music_cue = mx_cue_armorer
		random_equipped_character_artifact = {
			limit = {
				#AGOT MODIFIED 
				#artifact_slot_type = armor
				AND = { 
					artifact_slot_type = armor
					NOT = { has_variable = ep2_locale_events_2050_improved }
				}
			}
			save_scope_as = upgrade_armour
		}
		scope:activity = {
			var:tournament_armorer = {
				save_scope_as = tournament_armorer
			}
		}
	}

	# Go on then
	option = {
		name = ep2_locale_events.2050.a

		remove_short_term_gold = medium_gold_value

		random_list = {
			5 = { # They succeed
				desc = ep2_locale_events.2050.a.success

				hidden_effect = { #Hiding these effects because the toast doesn't like it
					scope:upgrade_armour = {
						add_durability = 5
						add_artifact_modifier = artifact_prowess_1_modifier
						#AGOT ADDED
						set_variable = { 
							name = ep2_locale_events_2050_improved
							value = yes 
						}
					}
				}

				send_interface_toast = {
					title = ep2_locale_events.2050.a.success
					
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
					}

					custom_tooltip = ep2_locale_events.2050.a.armour1
					custom_tooltip = ep2_locale_events.2050.a.durability1
				}
			}

			1 = { # They really succeed
				desc = ep2_locale_events.2050.a.critsuccess

				hidden_effect = {
					scope:upgrade_armour = {
						add_durability = 10
						add_artifact_modifier = artifact_prowess_2_modifier
						add_artifact_modifier = artifact_monthly_minor_prestige_2_modifier
						#AGOT ADDED
						set_variable = { 
							name = ep2_locale_events_2050_improved
							value = yes 
						}
					}
				}

				send_interface_toast = {
					title = ep2_locale_events.2050.a.criticalsuccess
					
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }
					}

					custom_tooltip = ep2_locale_events.2050.a.armour2
					custom_tooltip = ep2_locale_events.2050.a.prestige2
					custom_tooltip = ep2_locale_events.2050.a.durability2
				}
			}

			2 = { # They fail
				desc = ep2_locale_events.2050.a.failure

				hidden_effect = {
					scope:upgrade_armour = {
						add_durability = -5
					}
				}

				send_interface_toast = {
					title = ep2_locale_events.2050.a.failure
					
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
					}

					custom_tooltip = ep2_locale_events.2050.a.durability3
				}
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			paranoid = minor_stress_impact_gain #I don't want to let this armour out of my sight!
			craven = miniscule_stress_impact_loss #Anything to protect me!
			ambitious = miniscule_stress_impact_loss #Only the best for me
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = paranoid
				}
			}
		}
	}
	
	# No thanks
	option = {
		name = ep2_locale_events.2050.b

		reverse_add_opinion = {
			modifier = disappointed_opinion
			target = scope:tournament_armorer
			opinion = -10
		}

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			paranoid = miniscule_stress_impact_loss
			craven = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = ambitious
				}
			}
		}
	}
}

#######################################
#######################################
### 	TAILOR - 2500-2999			###
#######################################
#######################################

scripted_trigger tournament_tailor_rivalry_trigger = {
	OR = {
		AND = {
			exists = house.house_head
			house.house_head = {
				any_owned_story = {
					story_type = story_cycle_house_feud
					exists = var:house_feud_house
					var:house_feud_house = scope:tailor_mixup.house
				}
			}
		}
		scope:tailor_mixup.house = {
			any_house_member = { has_relation_rival = root }
		}
	}
}

# Erroneous Escutcheon
ep2_locale_events.2500 = {
	type = activity_event
	title = ep2_locale_events.2500.t
	desc = ep2_locale_events.2500.desc
	theme = tournament_locale_artisans
	left_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:tournament_tailor
		animation = happiness
	}
	lower_center_portrait = scope:tailor_mixup
	cooldown = { years = 1 }

	trigger = {
		exists = house
		scope:activity = {
			any_attending_character = {
				is_lowborn = no
				NOR = {
					this = root
					AND = {
						exists = house
						house = root.house
					}
					is_close_family_of = root
					is_consort_of = root
				}
			}
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_tailor
			var:tournament_tailor = { is_alive = yes }
		}
	}

	immediate = {
		play_music_cue = mx_cue_tailor
		scope:activity = {
			var:tournament_tailor = { save_scope_as = tournament_tailor }
		}
		scope:activity = {
			random_attending_character = {
				limit = {
					is_lowborn = no
					NOR = {
						this = root
						AND = {
							exists = house
							house = root.house
						}
						is_close_family_of = root
						is_consort_of = root
					}
				}
				weight = {
					base = 10
					modifier = {
						add = 2
						is_landed = yes
					}
					modifier = {
						add = 10
						has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
					}
					modifier = {
						add = 10
						this.house = { save_temporary_scope_as = tailor_mixup_house_temp }
						any_owned_story = {
							story_type = story_cycle_house_feud
							exists = var:house_feud_house
							var:house_feud_house = scope:tailor_mixup_house_temp
						}
					}
					modifier = {
						exists = dynasty
						factor = dynasty.dynasty_prestige_level
					}
					modifier = {
						factor = 2
						culture = root.culture
					}
					modifier = {
						factor = 0.1
						NOT = { culture = root.culture }
					}
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = tailor_mixup
				try_to_create_recurring_character_effect = { CHARACTER = root }
			}
		}
	}

	# Destroy
	option = {
		name = {
			trigger = {	tournament_tailor_rivalry_trigger = yes }
			text = ep2_locale_events.2500.a.rival
		}
		name = {
			trigger = {	tournament_tailor_rivalry_trigger = no }
			text = ep2_locale_events.2500.a
		}
		scope:tailor_mixup = {
			stress_impact = { base = medium_stress_impact_gain }
		}
		if = {
			limit = { tournament_tailor_rivalry_trigger = yes }
			stress_impact = {
				base = medium_stress_impact_loss
			}
		}
		else = {
			progress_towards_rival_effect = {
				REASON = rival_tournament_burned_crest
				CHARACTER = scope:tailor_mixup
				OPINION = default_rival_opinion
			}
		}
		stress_impact = {
			just = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			opinion_modifier = {
				opinion_target = scope:tailor_mixup
				multiplier = -0.5
			}
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_honor = -0.5
				ai_compassion = -0.5
			}
		}
	}

	# Buy
	option = {
		name = ep2_locale_events.2500.b
		remove_short_term_gold = minor_gold_value
		add_character_modifier = {
			modifier = tournament_tailor_mixup_scheme_modifier
			years = 10
		}
		set_variable = {
			name = tailor_mixup_house
			value = scope:tailor_mixup.house
			years = 10
		}
		custom_tooltip = ep2_locale_events.2500.b.tt
		stress_impact = {
			honest = minor_stress_impact_gain
			brave = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_honor = -1
				ai_boldness = 0.5
				ai_rationality = 0.5
				ai_greed = -0.5
			}
		}
	}

	# I want one!
	option = {
		name = ep2_locale_events.2500.c
		remove_short_term_gold = minor_gold_value
		add_character_modifier = {
			modifier = tournament_tailor_fancy_crest_modifier
			years = 5
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
				ai_honor = 1
				ai_boldness = 1
			}
		}
	}

	# Nevermind
	option = {
		name = ep2_locale_events.2500.d
		stress_impact = {
			deceitful = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 1
				ai_boldness = -1
				ai_energy = -1
				ai_honor = 0.5
			}
		}
	}
}

# You larp as the Pope
# by Nick Meredith
#AGOT Disabled
# ep2_locale_events.2501 = {
# 	type = activity_event
# 	title = ep2_locale_events.2501.t
# 	desc = ep2_locale_events.2501.desc
# 	theme = tournament_locale_artisans
# 	left_portrait = {
# 		character = root
# 		animation = personality_rational
# 	}
# 	right_portrait = {
# 		character = scope:random_knight
# 		animation = ecstasy
# 	}
# 	lower_center_portrait = {
# 		character = scope:tournament_tailor
# 	}
# 	cooldown = { years = 50 }

# 	trigger = {
# 		is_ai = no
# 		root.faith = faith:catholic
# 		scope:activity = {
# 			has_active_locale = tournament_locale_artisans
# 			exists = var:tournament_tailor
# 			var:tournament_tailor = { is_alive = yes }
# 		}
# 		exists = cp:councillor_court_chaplain
# 		cp:councillor_court_chaplain = {
# 			is_physically_able_ai_adult = yes
# 			faith = root.faith
# 		}
# 		any_knight = {
# 			location = root.location
# 			is_adult = yes
# 			is_healthy = yes
# 		}
# 	}

# 	immediate = {
# 		play_music_cue = mx_cue_tailor
# 		random_knight = {
# 			limit = {
# 				location = root.location
# 				is_adult = yes
# 				is_healthy = yes
# 			}
# 			save_scope_as = random_knight
# 		}
# 		cp:councillor_court_chaplain = {
# 			save_scope_as = realm_priest
# 		}
# 		scope:activity = {
# 			var:tournament_tailor = { save_scope_as = tournament_tailor }
# 		}
# 	}

# 	# SOLD!
# 	option = {
# 		name = ep2_locale_events.2501.a

# 		custom_tooltip = ep2_locale_events.2501.a.tt
		
# 		if = {
# 			limit = { activity_is_competing_trigger = yes }
# 			activity_tournament_change_contestant_score_effect = { SCORE = decrease_miniscule }
# 		}

# 		add_character_flag = {
# 			flag = pope_larper_flag
# 			months = 5
# 		}

# 		every_knight = {
# 			add_character_flag = {
# 				flag = cardinal_larper_flag
# 				months = 5
# 			}
# 		}

# 		create_artifact = {	
# 			name = fake_papal_tiara_name
# 			description = fake_papal_tiara_description
# 			type = helmet
# 			visuals = pope_tiara
# 			modifier = artifact_fake_papal_tiara_modifier
# 			save_scope_as = newly_created_artifact
# 		}

# 		scope:newly_created_artifact = {
# 			equip_artifact_to_owner = yes
# 		}

# 		remove_short_term_gold = medium_gold_value

# 		add_piety = minor_piety_loss

# 		reverse_add_opinion = {
# 			modifier = impious_opinion
# 			target = scope:realm_priest
# 			opinion = -50
# 		}

# 		reverse_add_opinion = {
# 			modifier = pleased_opinion
# 			target = scope:random_knight
# 			opinion = 10
# 		}

# 		stress_impact = {
# 			zealous = major_stress_impact_gain
# 			greedy = medium_stress_impact_gain
# 			gregarious = miniscule_stress_impact_loss
# 			cynical = miniscule_stress_impact_loss
# 		}

# 		ai_chance = {
# 			base = 100
# 			modifier = {
# 				factor = 0

# 				OR = {
# 					has_trait = greedy
# 					has_trait = zealous
# 				}
# 			}
# 		}
# 	}

# 	# Blasphemy!
# 	option = {
# 		name = ep2_locale_events.2501.b

# 		add_piety = medium_piety_gain
		
# 		if = {
# 			limit = { activity_is_competing_trigger = yes }
# 			activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
# 		}

# 		reverse_add_opinion = {
# 			modifier = pious_opinion
# 			target = scope:realm_priest
# 			opinion = 50
# 		}

# 		reverse_add_opinion = {
# 			modifier = disappointed_opinion
# 			target = scope:random_knight
# 			opinion = -20
# 		}

# 		stress_impact = {
# 			zealous = minor_stress_impact_loss
# 			greedy = miniscule_stress_impact_loss
# 			gregarious = medium_stress_impact_gain
# 			cynical = medium_stress_impact_gain
# 		}

# 		ai_chance = {
# 			base = 100
# 			modifier = {
# 				factor = 0

# 				OR = {
# 					has_trait = gregarious
# 					has_trait = cynical
# 				}
# 			}
# 		}
# 	}
# }

# You purchase a duellist's cloak
# by Nick Meredith
ep2_locale_events.2502 = {
	type = activity_event
	title = ep2_locale_events.2502.t
	desc = ep2_locale_events.2502.desc
	theme = tournament_locale_artisans
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:tournament_tailor
		animation = happiness
	}

	cooldown = { years = 1 }

	trigger = {
		scope:activity = {
			has_active_locale = tournament_locale_tailor
			has_current_phase = tournament_phase_duel
			exists = var:tournament_tailor
			var:tournament_tailor = { is_alive = yes }
		}
		activity_is_competing_trigger = yes
	}

	immediate = {
		play_music_cue = mx_cue_tailor
		scope:activity = {
			var:tournament_tailor = { 
				save_scope_as = tournament_tailor
			}
		}
	}

	# I'll take it!
	option = {
		name = ep2_locale_events.2502.a

		add_character_flag = {
			flag = cloak_duelist_flag
			years = 1
		}

		add_prestige = 100

		remove_short_term_gold = minor_gold_value

		stress_impact = {
			greedy = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			generous = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.5
				ai_greed = -1
			}
		}
	}

	# A duelling cloak?! Don't be ridiculous!
	option = {
		name = ep2_locale_events.2502.b

		flavor = ep2_locale_events.2502.b.tt

		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }	

		stress_impact = {
			generous = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			greedy = miniscule_stress_impact_loss
			humble = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_energy = -0.5
				ai_greed = 1
			}
		}
	}
}

##################################################
# Threaded Gifts
# by Joe Parkin
# 2510-2512
##################################################

# Decision
ep2_locale_events.2510 = {
	type = activity_event
	title = ep2_locale_events.2510.t
	desc = ep2_locale_events.2510.desc
	theme = tournament_locale_artisans
	left_portrait = {
		character = root
		animation = worry
	}
	lower_right_portrait = scope:befriend_target
	cooldown = { years = 1 }

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = {
		OR = {
			tournament_intent_locale_trigger = { INTENT = befriend_attendee }
			tournament_intent_locale_trigger = { INTENT = woo_attendee }
		}
		intent_target = {
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root.intent_target }
		}
		scope:activity = {
			has_active_locale = tournament_locale_artisans
		}
	}

	immediate = {
		play_music_cue = mx_cue_tailor
		save_scope_as = befriend_actor
		intent_target = { save_scope_as = befriend_target }
	}

	# Buy banner
	option = {
		name = ep2_locale_events.2510.a
		remove_short_term_gold =  minor_gold_value
		custom_tooltip = ep2_locale_events.2510.a.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:banner
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
				ai_greed = -0.5
			}
		}
	}

	# Buy gambeson
	option = {
		name = ep2_locale_events.2510.b
		remove_short_term_gold =  medium_gold_value
		custom_tooltip = ep2_locale_events.2510.b.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:gambeson
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -1
				ai_boldness = -0.5
				ai_greed = -1
			}
		}
	}

	# Buy gloves
	option = {
		name = ep2_locale_events.2510.c
		remove_short_term_gold =  minor_gold_value
		custom_tooltip = ep2_locale_events.2510.c.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:glove
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.5
				ai_boldness = 0.5
				ai_greed = -0.5
			}
		}
	}

	# No buy
	option = {
		name = ep2_locale_events.2510.d
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_boldness = -0.5
				ai_greed = 1
			}
		}
	}

	after = {
		if = {
			limit = { exists = scope:befriend_approach }
			hidden_effect = {
				#Evaluate what makes for a "right" choice
				if = {
					limit = {
						OR = {
							AND = {
								has_trait = education_stewardship
								exists = scope:befriend_approach
								scope:befriend_approach = flag:banner
							}
							AND = {
								OR = {
									has_trait = education_martial
									has_trait = education_martial_prowess
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:gambeson
							}
							AND = {
								has_trait = education_diplomacy
								exists = scope:befriend_approach
								scope:befriend_approach = flag:glove
							}
						}
					}
					save_scope_value_as = {
						name = made_great_choice
						value = yes
					}
				}
				random_list = {
					50 = {
						modifier = {
							add = 100
							exists = scope:made_great_choice
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:banner
							has_trait = arrogant
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:gambeson
							has_trait = brave
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:glove
							has_trait = compassionate
						}						
						save_scope_as = befriend_success
					}
					50 = {
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:banner
							has_trait = humble
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:gambeson
							has_trait = craven
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:glove
							has_trait = callous
						}
						save_scope_as = befriend_failure
					}
				}
				scope:befriend_target = {
					trigger_event = {
						id = ep2_locale_events.2511
						days = { 1 2 }
					}
				}			
			}
		}
	}
}

scripted_effect tournament_tailor_tooltip_effect = {
	show_as_tooltip = {
		if = {
			limit = { exists = scope:newly_created_artifact }
			show_as_tooltip = {
				scope:newly_created_artifact = { set_owner = scope:befriend_target }
			}
		}
		else_if = {
			limit = { has_character_modifier = tournament_tailor_banner_modifier }
			add_character_modifier = { modifier = tournament_tailor_banner_modifier years = 20 }
		}
		else_if = {
			limit = { has_character_modifier = tournament_tailor_gambeson_modifier }
			add_character_modifier = { modifier = tournament_tailor_gambeson_modifier years = 20 }
		}
		else_if = {
			limit = { has_character_modifier = tournament_tailor_glove_modifier }
			add_character_modifier = { modifier = tournament_tailor_glove_modifier years = 20 }
		}
	}
}

#Target
ep2_locale_events.2511 = {
	type = activity_event
	title = ep2_locale_events.2510.t
	desc = {
		desc = ep2_locale_events.2511.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:banner
				}
				desc = ep2_locale_events.2511.success_banner
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:banner }
				desc = ep2_locale_events.2511.banner
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:gambeson
				}
				desc = ep2_locale_events.2511.success_gambeson
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:gambeson }
				desc = ep2_locale_events.2511.gambeson
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:glove
				}
				desc = ep2_locale_events.2511.success_glove
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:glove }
				desc = ep2_locale_events.2511.glove
			}
		}
	}
	left_portrait = {
		character = scope:befriend_actor
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:befriend_success }
			}
			animation = sadness
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = tournament_locale_artisans

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_tailor
		scope:befriend_actor = {
			save_scope_as = owner 
			get_artifact_quality_effect = yes
			get_artifact_wealth_effect = yes
		}
		hidden_effect = {
			switch = {
				trigger = scope:befriend_approach
				flag:banner = {
					if = {
						limit = { has_royal_court = yes }
						set_variable = banner_from_house
						create_artifact_wall_banner_effect = {
							OWNER = scope:befriend_target
							CREATOR = scope:befriend_actor
							TARGET = scope:befriend_target.house
						}
					}
					else = {
						add_character_modifier = { modifier = tournament_tailor_banner_modifier years = 20 }
					}
				}
				flag:gambeson = {
					add_character_modifier = { modifier = tournament_tailor_gambeson_modifier years = 20 }
				}
				flag:glove = {
					add_character_modifier = { modifier = tournament_tailor_glove_modifier years = 20 }
				}
			}
		}
		tournament_tailor_tooltip_effect = yes
		scope:befriend_actor = {
			trigger_event = {
				id = ep2_locale_events.2512
				days = { 1 2 }
			}
		}
	}

	option = {
		name = ep2_locale_events.2511.a
		trigger = { exists = scope:befriend_success }
		add_stress = minor_stress_loss
		show_as_tooltip = { tournament_gift_relationship_effect = yes }
	}

	option = {
		name = ep2_locale_events.2511.b
		trigger = { exists = scope:befriend_failure }
	}
}

#Actor
ep2_locale_events.2512 = {
	type = activity_event
	title = ep2_locale_events.2510.t
	desc = {
		desc = ep2_locale_events.2512.opening
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.2012.success_reply
			}
			desc = ep2_locale_events.2512.reply
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:banner
				}
				desc = ep2_locale_events.2512.success_banner
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:banner }
				desc = ep2_locale_events.2512.banner
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:gambeson
				}
				desc = ep2_locale_events.2512.success_gambeson
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:gambeson }
				desc = ep2_locale_events.2512.gambeson
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:glove
				}
				desc = ep2_locale_events.2512.success_glove
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:glove }
				desc = ep2_locale_events.2512.glove
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.2512.success
			}
			desc = ep2_locale_events.2512.failure
		}
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = worry
		}
	}
	right_portrait = {
		character = scope:befriend_target
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = happiness
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = disapproval
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = tournament_locale_artisans

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_tailor
		scope:befriend_target = { tournament_tailor_tooltip_effect = yes }
	}

	option = {
		name = ep2_locale_events.2512.a
		trigger = { exists = scope:befriend_success }
		tournament_gift_relationship_effect = yes
	}

	option = {
		name = ep2_locale_events.2512.b
		trigger = { exists = scope:befriend_failure }
		reverse_add_opinion = {
			target = scope:befriend_target
			modifier = tournament_failed_gift_opinion
			opinion = -5
		}
	}
}

#######################################
#######################################
### 	CAMP - 3000-3499			###
#######################################
#######################################

# Stealing a moment
# by Nick Meredith
ep2_locale_events.3001 = {
	type = activity_event
	title = ep2_locale_events.3001.t
	desc = ep2_locale_events.3001.desc
	theme = tournament_locale_camp
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:lover
		animation = love
	}

	trigger = {
		activity_is_valid_tournament_contestant = yes
		scope:activity = {
			any_attending_character = {
				NOT = { this = root }
				basic_is_available_ai = yes
				is_adult = yes
				has_relation_lover = root
				opinion = {
					target = root
					value >= 15
				}
			}
		}
		scope:activity = {
			has_active_locale = tournament_locale_visitor_camp
		}
	}

	immediate = {
		play_music_cue = mx_cue_visitor_camp
		scope:activity = {
			random_attending_character = {
				limit = {
					NOT = { this = root }
					basic_is_available_ai = yes
					is_adult = yes
					has_relation_lover = root
					opinion = {
						target = root
						value >= 15
					}
				}
				weight = {
					base = 1
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = lover
				try_to_create_recurring_character_effect = { CHARACTER = root }
			}
		}
	}

	# Tumble
	option = {
		name = ep2_locale_events.3001.a

		trigger = {
			has_trait = lustful
		}

		had_sex_with_effect = {
			CHARACTER = scope:lover
			PREGNANCY_CHANCE = pregnancy_chance
		}

        stress_impact = {
			chaste = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
			lustful = minor_stress_impact_loss
			content = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0

				OR = {
					has_trait = chaste
					has_trait = ambitious
				}
			}
		}
	}

	# Take a moment to rest
	option = {
		name = ep2_locale_events.3001.b
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
		}

		reverse_add_opinion = {
			target = scope:lover
			modifier = love_opinion
			opinion = 30
		}

		stress_impact = {
			base = minor_stress_impact_loss
			chaste = miniscule_stress_impact_loss
			ambitious = medium_stress_impact_gain
			lustful = medium_stress_impact_gain
			content = miniscule_stress_impact_loss
			calm = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			shy = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0

				OR = {
					has_trait = lustful
					has_trait = ambitious
				}
			}
		}
	}

	# Say you don't have time for this
	option = {
		name = ep2_locale_events.3001.c
		
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		}

		reverse_add_opinion = {
			target = scope:lover
			modifier = disappointed_opinion
			opinion = -15
		}

		stress_impact = {
			ambitious = minor_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			lustful = medium_stress_impact_gain
			content = minor_stress_impact_gain
			lazy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0

				OR = {
					has_trait = lustful
					has_trait = lazy
				}
			}
		}
	}
}

scripted_effect ep2_locale_events_3002_recurring_character_tumbola_effect = {
	hidden_effect = {
		random_list = {
			1 = {
				try_to_create_recurring_character_effect = { CHARACTER = scope:lech1 }
			}
			1 = {
				try_to_create_recurring_character_effect = { CHARACTER = scope:lech2 }
			}
			1 = {
				try_to_create_recurring_character_effect = { CHARACTER = scope:lech3 }
			}
		}
	}
}

# Lecherous knight party
# by Nick Meredith
scripted_trigger willing_lecherous_knight_trigger = {
	is_ai = yes
	is_knight = yes
	is_adult = yes
	NOR = {
		has_trait = chaste
		has_trait = celibate
		this = root
	}
	might_cheat_on_every_partner_trigger = yes
	OR = {
		# Ur horny
		has_trait = lustful
		has_trait = rakish
		is_deviant_trigger = yes
		# You are gay
		attracted_to_same_gender_trigger = yes
		# You are a man and there are lady knights at the tournament
		AND = {
			is_male = yes
			scope:activity = {
				any_attending_character = {
					is_adult = yes
					is_female = yes
					is_knight = yes
					is_attracted_to_men = yes
				}
			}
		}
		# You are a woman and there are men knights at the tournament
		AND = {
			is_female = yes
			scope:activity = {
				any_attending_character = {
					is_adult = yes
					is_male = yes
					is_knight = yes
					is_attracted_to_women = yes
				}
			}
		}
	}
}

ep2_locale_events.3002 = {
	type = activity_event
	title = ep2_locale_events.3002.t
	desc = ep2_locale_events.3002.desc
	theme = tournament_locale_camp
	cooldown = { years = 1 }
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:lech1
		animation = shock
		triggered_outfit = {
			remove_default_outfit = no
			outfit_tags = { no_clothes }
		}
	}
	lower_right_portrait = {
		character = scope:lech2
		triggered_outfit = {
			remove_default_outfit = no
			outfit_tags = { no_clothes }
		}
	}
	lower_center_portrait = {
		character = scope:lech3
		triggered_outfit = {
			remove_default_outfit = no
			outfit_tags = { no_clothes }
		}
	}

	trigger = {
		activity_is_valid_tournament_contestant = yes
		scope:activity = {
			any_attending_character = {
				is_adult = yes
				is_knight_of = root
				willing_lecherous_knight_trigger = yes
				save_temporary_scope_as = lech1_temporary
			}
			any_attending_character = {
				count >= 2
				is_adult = yes
				NOT = { this = scope:lech1_temporary }
				willing_lecherous_knight_trigger = yes
			}
		}
		scope:activity = {
			has_active_locale = tournament_locale_visitor_camp
		}
	}

	immediate = {
		play_music_cue = mx_cue_visitor_camp
		scope:activity = {
			random_attending_character = {
				limit = {
					is_knight_of = root
					willing_lecherous_knight_trigger = yes
				}
				weight = {
					base = 1
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = lech1
				add_to_list = lecherous_knights
			}
			random_attending_character = {
				limit = {
					willing_lecherous_knight_trigger = yes
					OR = {
						has_trait = lustful
						has_trait = rakish
						is_deviant_trigger = yes
						trigger_if = {
							limit = { exists = scope:lech1 }
							is_attracted_to_gender_of = scope:lech1
						}
					}
					NOT = { scope:lech1 ?= this }
				}
				weight = {
					base = 1
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = lech2
				add_to_list = lecherous_knights
			}
			random_attending_character = {
				limit = {
					willing_lecherous_knight_trigger = yes
					OR = {
						has_trait = lustful
						has_trait = rakish
						is_deviant_trigger = yes
						trigger_if = {
							limit = { exists = scope:lech1 }
							is_attracted_to_gender_of = scope:lech1
						}
						trigger_if = {
							limit = { exists = scope:lech2 }
							is_attracted_to_gender_of = scope:lech2
						}
					}
					NOR = {
						scope:lech1 ?= this
						scope:lech2 ?= this 
					}
				}
				weight = {
					base = 1
					activity_recurring_character_weight_modifier = { VALUE = 100 }
				}
				save_scope_as = lech3
				add_to_list = lecherous_knights
			}
		}
		scope:lech1 = {
			hidden_effect = {
				had_sex_with_effect = {
					CHARACTER = scope:lech2
					PREGNANCY_CHANCE = 50
				}
				had_sex_with_effect = {
					CHARACTER = scope:lech3
					PREGNANCY_CHANCE = 50
				}
			}
			random_secret = {
				limit = {
					secret_type = secret_homosexual
				}
				reveal_to = root
			}
		}
		scope:lech2 = {
			hidden_effect = {
				had_sex_with_effect = {
					CHARACTER = scope:lech3
					PREGNANCY_CHANCE = 50
				}
			}
			random_secret = {
				limit = {
					secret_type = secret_homosexual
				}
				reveal_to = root
			}
		}
		scope:lech3 = {
			random_secret = {
				limit = {
					secret_type = secret_homosexual
				}
				reveal_to = root
			}
		}
	}

	# Join in
	option = {
		name = ep2_locale_events.3002.a

		trigger = {
			OR = {
				has_trait = lustful
				has_trait = seducer
				has_trait = rakish
				is_deviant_trigger = yes
			}
			NOT = {
				has_trait = celibate
			}
			might_cheat_on_every_partner_trigger = yes
		}

		if = { #You're a man and your faith says no to male adultery
			limit = {
				is_female = no 
				root.faith = {
					OR = {
						has_doctrine_parameter = adultery_male_crime
						has_doctrine_parameter = adultery_male_shunned
					}
				}
			}
			add_character_modifier = tournament_lecherous_knight_modifier
		}

		else_if = { #You're a man and your faith says yes to male adultery
			limit = {
				is_female = no 
				root.faith = {
					has_doctrine_parameter = adultery_male_accepted
				}
			}
			add_character_modifier = tournament_lecherous_knight_positive_modifier
		}

		else_if = { #You're a woman and your faith says no to female adultery
			limit = {
				is_female = yes
				root.faith = {
					OR = {
						has_doctrine_parameter = adultery_female_crime
						has_doctrine_parameter = adultery_female_shunned
					}
				}
			}
			add_character_modifier = tournament_lecherous_knight_modifier
		}

		else = { #You're a woman and your faith says yes to female adultery
			limit = {
				is_female = yes
				root.faith = {
					has_doctrine_parameter = adultery_female_accepted
				}
			}
			add_character_modifier = tournament_lecherous_knight_positive_modifier
		}

		had_sex_with_effect = {
			CHARACTER = scope:lech1
			PREGNANCY_CHANCE = 50
		}
		had_sex_with_effect = {
			CHARACTER = scope:lech2
			PREGNANCY_CHANCE = 50
		}
		had_sex_with_effect = {
			CHARACTER = scope:lech3
			PREGNANCY_CHANCE = 50
		}

		ep2_locale_events_3002_recurring_character_tumbola_effect = yes

        stress_impact = {
			base = major_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			lustful = minor_stress_impact_loss
			chaste = major_stress_impact_gain
			shy = minor_stress_impact_gain
			ambitious = medium_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0

				OR = {
					has_trait = chaste
					has_trait = ambitious
				}
			}
		}
	}

	# Break it up and chastise them
	option = {
		name = ep2_locale_events.3002.b
		
		add_piety = minor_piety_gain

		every_in_list = {
			list = lecherous_knights
			add_opinion = {
				target = root
				modifier = annoyed_opinion
				opinion = -30
			}
		}

		hidden_effect = { ep2_locale_events_3002_recurring_character_tumbola_effect = yes }

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			lustful = major_stress_impact_gain
			gregarious = minor_stress_impact_gain
			lazy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0

				OR = {
					has_trait = lustful
					has_trait = lazy
				}
			}
		}
	}

	# Leave them to it
	option = {
		name = ep2_locale_events.3002.c

		flavor = ep2_locale_events.3002.c.tt

		every_in_list = {
			list = lecherous_knights
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 30
			}
		}

		if = { #You're a man and your faith says no to male adultery
			limit = {
				is_female = no 
				root.faith = {
					OR = {
						has_doctrine_parameter = adultery_male_crime
						has_doctrine_parameter = adultery_male_shunned
					}
				}
			}
			add_piety = medium_piety_loss
		}

		else_if = { #You're a man and your faith says yes to male adultery
			limit = {
				is_female = no 
				root.faith = {
					has_doctrine_parameter = adultery_male_accepted
				}
			}
			add_piety = minor_piety_gain
		}

		else_if = { #You're a woman and your faith says no to female adultery
			limit = {
				is_female = yes
				root.faith = {
					OR = {
						has_doctrine_parameter = adultery_female_crime
						has_doctrine_parameter = adultery_female_shunned
					}
				}
			}
			add_piety = medium_piety_loss
		}

		else = { #You're a woman and your faith says yes to female adultery
			limit = {
				is_female = yes
				root.faith = {
					has_doctrine_parameter = adultery_female_accepted
				}
			}
			add_piety = minor_piety_gain
		}

		stress_impact = {
			ambitious = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			content = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}
}

#######################################
#######################################
### 	FARRIER - 3500-3999			###
#######################################
#######################################

# A Little Prick
ep2_locale_events.3500 = {
	type = activity_event
	title = ep2_locale_events.3500.t
	desc = {
		desc = ep2_locale_events.3500.desc
		first_valid = {
			triggered_desc = {
		        trigger = {
		        	any_owned_story = {
						story_type = story_cycle_martial_lifestyle_warhorse
						exists = var:horse_gender
					}
					NOT = {
						scope:activity = { has_current_phase = tournament_phase_horse_race }
					}
		        }
		        desc = ep2_locale_events.3500.war
		    }
		    triggered_desc = {
		        trigger = { exists = var:contest_horse_race_name }
		        desc = ep2_locale_events.3500.race
		    }
		    desc = ep2_locale_events.3500.other
		}
	}
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:tournament_farrier
		animation = worry
	}
	cooldown = { years = 1 }

	trigger = {
		activity_tournament_horse_contest_trigger = yes
		activity_is_competing_trigger = yes
		scope:activity = {
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_farrier
			var:tournament_farrier = { is_alive = yes }
		}
	}

	immediate = {
		play_music_cue = mx_cue_farrier
		activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
		add_character_modifier = {
			modifier = tournament_farrier_mistake_modifier
			years = 1
		}
		remove_short_term_gold = tiny_gold_value
		scope:activity = {
			var:tournament_farrier = { save_scope_as = tournament_farrier }
		}
	}

	# Ream out
	option = {
		name = {
			trigger = {
				any_owned_story = {
					story_type = story_cycle_martial_lifestyle_warhorse
					exists = var:horse_gender
				}
				NOT = {
					scope:activity = { has_current_phase = tournament_phase_horse_race }
				}
			}
			text = ep2_locale_events.3500.a.war_horse
		}
		name = {
			trigger = {
				NAND = {
					any_owned_story = {
						story_type = story_cycle_martial_lifestyle_warhorse
						exists = var:horse_gender
					}
					NOT = {
						scope:activity = { has_current_phase = tournament_phase_horse_race }
					}
				}
			}
			text = ep2_locale_events.3500.a
		}

		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }

		reverse_add_opinion = {
			target = scope:tournament_farrier
			modifier = scared_opinion
			opinion = -15
		}

		add_prestige = minor_prestige_gain
        stress_impact = {
			irritable = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			calm = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_energy = -0.5
			}
		}
	}

	# Banish
	option = {
		name = ep2_locale_events.3500.b
		add_dread = miniscule_dread_gain
		scope:activity = {
			every_attending_character = {
				custom = custom.every_attending_character
				limit = {
					NOT = { this = root }
				}
				add_opinion = {
					target = root
					modifier = tournament_banished_farrier_opinion
					opinion = -5
				}
			}
		}
		reverse_add_opinion = {
			target = scope:tournament_farrier
			modifier = hate_opinion
			opinion = -40
		}
		stress_impact = {
			irritable = medium_stress_impact_loss
			wrathful = medium_stress_impact_loss
			calm = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_energy = -0.5
			}
		}
	}

	# Demand refund
	option = {
		name = ep2_locale_events.3500.c
		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }		
		add_gold = tiny_gold_value
		reverse_add_opinion = {
			target = scope:tournament_farrier
			modifier = disappointed_opinion
			opinion = -30
		}
		stress_impact = {
			irritable = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			calm = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			calm = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_energy = -0.5
			}
		}
	}

	# Laugh it off
	option = {
		name = ep2_locale_events.3500.d
		add_dread = miniscule_dread_loss
		stress_impact = {
			wrathful = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}
		if = {
			limit = { has_activity_intent = win_contest_intent }
			stress_impact = { base = medium_stress_impact_gain }
		}
		reverse_add_opinion = {
			target = scope:tournament_farrier
			modifier = relieved_opinion
			opinion = 30
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_energy = -0.5
			}
		}
	}
}

#######################################
#######################################
### 	BOWYER - 4000-4499			###
#######################################
#######################################

# Bowyer snaps your bow in half
# Have you had your bow broken by a local bowyer?
# You may be eligible for a claim!
# Our team of lawgivers and scribes are on hand to help you get the settlement you deserve.
# We operate on a strict no-win, no-fee basis.
# That's right, no win, no fee!
# Call 0800-BROKEN-BOW now!
# by Nick Meredith
ep2_locale_events.4001 = {
	type = activity_event
	title = ep2_locale_events.4001.t
	desc = ep2_locale_events.4001.desc
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:tournament_bowyer
		animation = worry
	}

	trigger = {
		activity_is_competing_trigger = yes
		scope:activity = {
			has_active_locale = tournament_locale_artisans
			has_current_phase = tournament_phase_archery
			exists = var:tournament_bowyer
			var:tournament_bowyer = { is_alive = yes }
		}
	}

	immediate = {
		play_music_cue = mx_cue_fletcher
		scope:activity = {
			var:tournament_bowyer = { save_scope_as = tournament_bowyer }
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			scope:activity = { has_current_phase = tournament_phase_archery }
		}
	}

	# Demand a replacement for free
	option = {
		name = ep2_locale_events.4001.a

		duel = {
			skill = diplomacy
			target = scope:tournament_bowyer

			# They replace your bow for free
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				opinion_modifier = {
					who = scope:tournament_bowyer
					opinion_target = root
					multiplier = 0.5
				}
				desc = ep2_locale_events.4001.a.success
				send_interface_toast = {
					title = ep2_locale_events.4001.a.success
					left_icon = root
					right_icon = scope:tournament_bowyer

					activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
				}
			}

			# They refuse
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.4001.a.failure
				send_interface_toast = {
					title = ep2_locale_events.4001.a.failure
					left_icon = root
					right_icon = scope:tournament_bowyer

					activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
				}
			}
		}

		reverse_add_opinion = {
			target = scope:tournament_bowyer
			modifier = angry_opinion
			opinion = -15
		}

		stress_impact = {
			wrathful = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
			diligent = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
				ai_greed = 1
			}
		}
	}

	# Buy a new bow
	option = {
		name = ep2_locale_events.4001.b

		remove_short_term_gold = minor_gold_value

		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }

		reverse_add_opinion = {
			target = scope:tournament_bowyer
			modifier = relieved_opinion
			opinion = 10
		}

		stress_impact = {
			wrathful = medium_stress_impact_gain
			forgiving = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			greedy = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.5
				ai_boldness = 1
				ai_greed = -1
			}
		}
	}

	# Harangue them
	option = {
		name = ep2_locale_events.4001.c

		activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }

		reverse_add_opinion = {
			target = scope:tournament_bowyer
			modifier = angry_opinion
			opinion = -40
		}

		stress_impact = {
			wrathful = miniscule_stress_impact_loss
			forgiving = medium_stress_impact_gain
			lazy = medium_stress_impact_gain
			greedy = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
				ai_greed = 1
			}
		}
	}
}

##################################################
# Ballistic Gifts
# by Joe Parkin
# 4010-4012
##################################################

# Decision
ep2_locale_events.4010 = {
	type = activity_event
	title = ep2_locale_events.4010.t
	desc = ep2_locale_events.4010.desc
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = worry
	}
	lower_right_portrait = scope:befriend_target

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = {
		OR = {
			tournament_intent_locale_trigger = { INTENT = befriend_attendee }
			tournament_intent_locale_trigger = { INTENT = woo_attendee }
		}
		intent_target = {
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root.intent_target }
		}
		scope:activity = {
			has_active_locale = tournament_locale_artisans
			has_current_phase = tournament_phase_archery
		}
	}

	immediate = {
		play_music_cue = mx_cue_fletcher
		save_scope_as = befriend_actor
		intent_target = {
			save_scope_as = befriend_target
			set_signature_weapon_effect = yes
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			scope:activity = { has_current_phase = tournament_phase_archery }
		}
	}

	# Buy weapon
	option = {
		name = ep2_locale_events.4010.a
		remove_short_term_gold =  minor_gold_value
		custom_tooltip = ep2_locale_events.4010.a.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:bow
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
				ai_greed = -0.5
			}
		}
	}

	# Buy display weapon
	option = {
		name = ep2_locale_events.4010.b
		remove_short_term_gold =  medium_gold_value
		custom_tooltip = ep2_locale_events.4010.b.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:quiver
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -1
				ai_boldness = -0.5
				ai_greed = -1
			}
		}
	}

	# Buy dagger
	option = {
		name = ep2_locale_events.4010.c
		remove_short_term_gold =  tiny_gold_value
		custom_tooltip = ep2_locale_events.4010.c.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:hunt
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.5
				ai_boldness = 0.5
				ai_greed = -0.5
			}
		}
	}

	# No buy
	option = {
		name = ep2_locale_events.4010.d
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_boldness = -0.5
				ai_greed = 1
			}
		}
	}

	after = {
		if = {
			limit = { exists = scope:befriend_approach }
			hidden_effect = {
				#Evaluate what makes for a "right" choice
				if = {
					limit = {
						OR = {
							AND = {
								OR = {
									has_lifestyle = martial_lifestyle
									has_trait = education_martial_prowess
									has_trait = education_martial
									has_trait = brave
									has_trait = lifestyle_blademaster
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:bow
							}
							AND = {
								OR = {
									NOR = {
										has_lifestyle = martial_lifestyle
										has_trait = education_martial
										has_lifestyle = intrigue_lifestyle
										has_trait = education_intrigue
										has_trait = schemer
									}
									has_trait = craven
									has_trait = greedy
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:quiver
							}
							AND = {
								OR = {
									has_lifestyle = intrigue_lifestyle
									has_trait = education_intrigue
									has_trait = schemer
									has_trait = deceitful
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:hunt
							}
						}
					}
					save_scope_value_as = {
						name = made_great_choice
						value = yes
					}
				}
				random_list = {
					50 = {
						modifier = {
							add = 100
							exists = scope:made_great_choice
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:bow
							has_trait = tourney_participant
							has_trait_xp = {
								trait = tourney_participant
								track = bow
								value >= 25
							}
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:quiver
							has_trait = paranoid
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:hunt
							has_trait = lifestyle_hunter
						}					
						save_scope_as = befriend_success
					}
					50 = {
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:bow
							has_trait = lifestyle_blademaster
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:quiver
							has_trait = trusting
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:hunt
							has_trait = lazy
						}
						save_scope_as = befriend_failure
					}
				}
				scope:befriend_target = {
					trigger_event = {
						id = ep2_locale_events.4011
						days = { 1 2 }
					}
				}			
			}
		}
	}
}

scripted_effect tournament_bowyer_befriend_tooltip_effect = {
	show_as_tooltip = {
		if = {
			limit = { exists = scope:newly_created_artifact }
			show_as_tooltip = {
				scope:newly_created_artifact = { set_owner = scope:befriend_target }
			}
		}
		else_if = {
			limit = { has_character_modifier = tournament_bowyer_quiver_modifier }
			add_character_modifier = { modifier = tournament_bowyer_quiver_modifier years = 20 }
		}
		else_if = {
			limit = { has_character_modifier = tournament_bowyer_hunt_modifier }
			add_character_modifier = { modifier = tournament_bowyer_hunt_modifier years = 20 }
		}
	}
}

#Target
ep2_locale_events.4011 = {
	type = activity_event
	title = ep2_locale_events.4010.t
	desc = {
		desc = ep2_locale_events.4011.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:bow
				}
				desc = ep2_locale_events.4011.success_bow
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:bow }
				desc = ep2_locale_events.4011.bow
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:quiver
				}
				desc = ep2_locale_events.4011.success_quiver
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:quiver }
				desc = ep2_locale_events.4011.quiver
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:hunt
				}
				desc = ep2_locale_events.4011.success_hunt
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:hunt }
				desc = ep2_locale_events.4011.hunt
			}
		}
	}
	left_portrait = {
		character = scope:befriend_actor
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:befriend_success }
			}
			animation = sadness
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = tournament_locale_camp
	cooldown = { years = 1 }

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_fletcher
		scope:befriend_actor = {
			save_scope_as = owner 
			get_artifact_quality_effect = yes
			get_artifact_wealth_effect = yes
		}
		hidden_effect = {
			switch = {
				trigger = scope:befriend_approach
				flag:bow = {
					create_artifact_bow_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_BOW_TYPE = flag:no }
				}
				flag:quiver = {
					add_character_modifier = { modifier = tournament_bowyer_quiver_modifier years = 20 }
				}
				flag:hunt = {
					add_character_modifier = { modifier = tournament_bowyer_hunt_modifier years = 20 }
				}
			}
		}
		tournament_bowyer_befriend_tooltip_effect = yes
		scope:befriend_actor = {
			trigger_event = {
				id = ep2_locale_events.4012
				days = { 1 2 }
			}
		}
	}

	option = {
		name = ep2_locale_events.4011.a
		trigger = { exists = scope:befriend_success }
		add_stress = minor_stress_loss
		show_as_tooltip = { tournament_gift_relationship_effect = yes }
	}

	option = {
		name = ep2_locale_events.4011.b
		trigger = { exists = scope:befriend_failure }
	}
}

#Actor
ep2_locale_events.4012 = {
	type = activity_event
	title = ep2_locale_events.4010.t
	desc = {
		desc = ep2_locale_events.4012.opening
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.4012.success_reply
			}
			desc = ep2_locale_events.4012.reply
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:bow
				}
				desc = ep2_locale_events.4012.success_bow
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:bow }
				desc = ep2_locale_events.4012.bow
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:quiver
				}
				desc = ep2_locale_events.4012.success_quiver
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:quiver }
				desc = ep2_locale_events.4012.quiver
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:hunt
				}
				desc = ep2_locale_events.4012.success_hunt
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:hunt }
				desc = ep2_locale_events.4012.hunt
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.4012.success
			}
			desc = ep2_locale_events.4012.failure
		}
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = worry
		}
	}
	right_portrait = {
		character = scope:befriend_target
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = happiness
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = disapproval
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = tournament_locale_camp

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_fletcher
		scope:befriend_target = { tournament_bowyer_befriend_tooltip_effect = yes }
	}

	option = {
		name = ep2_locale_events.4012.a
		trigger = { exists = scope:befriend_success }
		tournament_gift_relationship_effect = yes
	}

	option = {
		name = ep2_locale_events.4012.b
		trigger = { exists = scope:befriend_failure }
		reverse_add_opinion = {
			target = scope:befriend_target
			modifier = tournament_failed_gift_opinion
			opinion = -5
		}
	}
}

# You purchase a bracer
# by Nick Meredith
ep2_locale_events.4050 = {
	type = activity_event
	title = ep2_locale_events.4050.t
	desc = ep2_locale_events.4050.desc
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:tournament_bowyer
		animation = personality_bold
	}
	override_background = { reference = armory }

	trigger = {
		scope:activity = { 
			has_active_locale = tournament_locale_artisans
			has_current_phase = tournament_phase_archery
			exists = var:tournament_bowyer
			var:tournament_bowyer = { is_alive = yes }
		}
	}

	immediate = {
		play_music_cue = mx_cue_fletcher
		scope:activity = {
			var:tournament_bowyer = { save_scope_as = tournament_bowyer }
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			scope:activity = { has_current_phase = tournament_phase_archery }
		}
	}

	# Haggle
	option = {
		name = ep2_locale_events.4050.a

		trigger = {
			OR = {
				has_trait = education_stewardship_3
				has_trait = education_stewardship_4
				has_trait = education_stewardship_5
				has_trait = education_diplomacy_3
				has_trait = education_diplomacy_4
				has_trait = education_diplomacy_5
			}
		}

		duel = {
			skills = { diplomacy stewardship }
			target = scope:tournament_bowyer

			# Success; cost reduction
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep2_locale_events.4050.a.success
				send_interface_toast = {
					title = ep2_locale_events.4050.a.success
					left_icon = root
					right_icon = scope:tournament_bowyer
					remove_short_term_gold = minor_gold_value
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
					}
					add_character_modifier = tournament_bracer_modifier
				}
			}
			# Failure; no cost reduction
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.4050.a.failure
				send_interface_toast = {
					title = ep2_locale_events.4050.a.failure
					left_icon = root
					right_icon = scope:tournament_bowyer
					remove_short_term_gold = medium_gold_value
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
					}

					add_character_modifier = tournament_bracer_modifier
				}
			}
			# Crit Failure; he refuses to sell to you at all
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep2_locale_events.4050.a.critfailure
				send_interface_toast = {
					title = ep2_locale_events.4050.a.critfailure
					left_icon = root
					right_icon = scope:tournament_bowyer
					if = {
						limit = { activity_is_competing_trigger = yes }
						activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
					}

					reverse_add_opinion = {
						target = scope:tournament_bowyer
						modifier = angry_opinion
						opinion = -10
					}
				}
			}
		}

		stress_impact = {
			avaricious = minor_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			generous = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
		}

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

	# I'll take two!
	option = {
		name = ep2_locale_events.4050.b
		trigger = {
			has_trait = profligate
		}
		remove_short_term_gold = major_gold_value
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		}
		add_character_modifier = tournament_two_bracers_modifier
		reverse_add_opinion = {
			target = scope:tournament_bowyer
			modifier = pleased_opinion
			opinion = 20
		}		
		
		stress_impact = {
			greedy = major_stress_impact_gain
			generous = minor_stress_impact_loss
		}

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

	# I'll take it
	option = {
		name = ep2_locale_events.4050.c

		remove_short_term_gold = medium_gold_value
		if = {
			limit = { activity_is_competing_trigger = yes }
			activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
		}

		add_character_modifier = tournament_bracer_modifier

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			content = minor_stress_impact_gain
			generous = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}
	
	# No thanks
	option = {
		name = ep2_locale_events.4050.d

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = generous
				}
			}
		}
	}
}

#######################################
#######################################
### 	WEAPONSMITH - 4500-4999		###
#######################################
#######################################

# Weaponsmith's apprentice chips your sword
# by Nick Meredith
ep2_locale_events.4500 = {
	type = activity_event
	title = ep2_locale_events.4500.t
	desc = {
		desc = ep2_locale_events.4500.start
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:chipped_sword
				}
				desc = ep2_locale_events.4500.artifact
			}
			triggered_desc = {
				trigger = {
					NOT = {
						exists = scope:chipped_sword
					}
				}
				desc = ep2_locale_events.4500.noartifact
			}
		}
		desc = ep2_locale_events.4500.end
	}
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:apprentice
		animation = shame
	}
	lower_right_portrait = scope:tournament_weaponsmith
	artifact = {
		trigger = {
			scope:chipped_sword = {
				is_equipped = yes
			}
		}
		target = scope:chipped_sword
		position = lower_left_portrait
	}

	trigger = {
		activity_is_competing_trigger = yes 
		scope:activity = { # You have a weaponsmith
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_weaponsmith
			var:tournament_weaponsmith = { is_alive = yes }
		}
		activity_tournament_armor_contest_trigger = yes
		any_equipped_character_artifact = {
			artifact_slot_type = primary_armament
		}
	}

	immediate = {
		play_music_cue = mx_cue_weaponsmith
		scope:activity.var:tournament_weaponsmith = { save_scope_as = tournament_weaponsmith }
		create_character = {
			age = { 16 21 }
			dynasty = none
			random_traits = yes
			gender_female_chance = 50
			culture = scope:tournament_weaponsmith.culture
			faith = scope:tournament_weaponsmith.faith
			location = scope:tournament_weaponsmith.location
			save_scope_as = apprentice
		}
		random_equipped_character_artifact = {
			limit = {
				artifact_slot_type = primary_armament
			}
			save_scope_as = chipped_sword
		}
		activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
		add_character_flag = event_4500_happening
		scope:tournament_weaponsmith = {
			hidden_effect = {
				create_artifact_weapon_effect = {
					OWNER = scope:tournament_weaponsmith
					CREATOR = scope:tournament_weaponsmith
					SET_WEAPON_TYPE = flag:artifact_weapon_type_sword
				}

				scope:newly_created_artifact = {
					set_artifact_description = tournament_sword_description
					set_artifact_name = tournament_sword_name
					random_list = { #Add a grab bag of potentially either very good or quite bad modifiers
						50 = {
							add_artifact_modifier = artifact_monthly_martial_lifestyle_xp_3_modifier
							set_artifact_description = tournament_sword.martiallifestyle
							set_artifact_rarity = masterwork
						}
						50 = {
							add_artifact_modifier = artifact_controlled_province_advantage_3_modifier
							set_artifact_description = tournament_sword.controlledadv
							set_artifact_rarity = masterwork
						}
						50 = {
							add_artifact_modifier = artifact_same_faith_opinion_negative_1_modifier
							add_artifact_modifier = artifact_different_faith_opinion_2_modifier
							set_artifact_description = tournament_sword.foreignfaith
						}
					}
					save_scope_as = tournament_sword
				}
			}
		}
	}

	# Demand it be fixed
	option = {
		name = ep2_locale_events.4500.a

		flavor = ep2_locale_events.4500.a.tt

		pay_short_term_gold = {
			target = scope:tournament_weaponsmith
			gold = 20
		}

		scope:chipped_sword = {
			add_durability = {
				value = artifact_durability
				multiply = -0.10
			}
		}

		activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }

		stress_impact = {
			calm = medium_stress_impact_gain
			wrathful = miniscule_stress_impact_loss
			lazy = medium_stress_impact_gain
			diligent = miniscule_stress_impact_loss
			compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = lazy
					has_trait = compassionate
				}
			}
		}
	}

	# Buy a new sword for the tournament
	option = {
		name = ep2_locale_events.4500.b

		pay_short_term_gold = {
			target = scope:tournament_weaponsmith
			gold = 45
		}

		activity_tournament_change_contestant_score_effect = { SCORE = increase_medium }

		scope:tournament_sword = {
			set_owner = root
		}
		hidden_effect = {
			scope:newly_created_artifact = {
				equip_artifact_to_owner_replace = yes
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			generous = miniscule_stress_impact_loss
			paranoid = medium_stress_impact_gain
			trusting = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = paranoid
				}
			}
		}
	}

	# Leave it be
	option = {
		name = ep2_locale_events.4500.c

		activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
		
		scope:chipped_sword = {
			add_durability = {
				value = artifact_durability
				multiply = -0.05
			}
		}

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = medium_stress_impact_gain
			vengeful = medium_stress_impact_gain
			forgiving = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = vengeful
					has_trait = generous
				}
			}
		}
	}

	after = {
		remove_character_flag = event_4500_happening
		hidden_effect = {
			if = {
				limit = {
					scope:tournament_sword = {
						NOT = {
							artifact_owner = root
						}
					}
				}
				destroy_artifact = scope:tournament_sword
			}
		}
	}
}

# Your spouse fancies the weaponsmith
# by Nick Meredith
ep2_locale_events.4501 = {
	type = activity_event
	title = ep2_locale_events.4501.t
	desc = ep2_locale_events.4501.desc
	theme = tournament_locale_forge
	cooldown = { years = 1 }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:spying_spouse
		animation = flirtation
	}
	lower_center_portrait = scope:tournament_weaponsmith
	trigger = {
		scope:activity = {
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_weaponsmith
			var:tournament_weaponsmith = {
				is_alive = yes
				save_temporary_scope_as = tournament_weaponsmith_temporary
			}
		}
		activity_tournament_armor_contest_trigger = yes
		any_spouse = {
			location = scope:activity.activity_location
			is_ai = yes
			is_adult = yes
			is_attracted_to_gender_of = scope:tournament_weaponsmith_temporary 
			is_attracted_to_gender_of = root
		}
	}

	immediate = {
		play_music_cue = mx_cue_weaponsmith
		scope:activity = {
			var:tournament_weaponsmith = { save_scope_as = tournament_weaponsmith }
		}
		random_spouse = {
			limit = {
				location = root.location
				is_ai = yes
				is_adult = yes
				is_attracted_to_gender_of = scope:tournament_weaponsmith
				is_attracted_to_gender_of = root
			}
			save_scope_as = spying_spouse
		}
	}

	# You have a quick tumble
	option = {
		name = ep2_locale_events.4501.a

		trigger = {
			is_attracted_to_gender_of = scope:tournament_weaponsmith
			NOR = {
				has_trait = chaste
				has_trait = celibate
			}
			scope:tournament_weaponsmith = {
				is_attracted_to_gender_of = root
				is_attracted_to_gender_of = scope:spying_spouse
				OR = {
					has_trait = lustful
					has_trait = seducer
				}
				NOT = {
					has_trait = chaste
					has_trait = celibate
				}
			}
			scope:spying_spouse = {
				NOT = {
					has_trait = chaste
					has_trait = celibate
				}
			}
		}

		flavor = ep2_locale_events.4501.a.tt

		scope:spying_spouse = {
			had_sex_with_effect = {
				CHARACTER = scope:tournament_weaponsmith
				PREGNANCY_CHANCE = pregnancy_chance
			}
		}

		# Consensual threesome despite the monogamy, so we ignore cheating errors here.
		save_scope_as = ignore_cheating_error_check
		had_sex_with_effect = {
			CHARACTER = scope:tournament_weaponsmith
			PREGNANCY_CHANCE = pregnancy_chance
		}
		# We fire this twice because the sex effect auto-clears it.
		save_scope_as = ignore_cheating_error_check
		had_sex_with_effect = {
			CHARACTER = scope:spying_spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}

		stress_impact = {
			seducer = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			shy = medium_stress_impact_loss
			paranoid = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = shy
					has_trait = paranoid
				}
			}
		}
	}

	# You join the ogling
	option = {
		name = ep2_locale_events.4501.b

		trigger = {
			is_attracted_to_gender_of = scope:tournament_weaponsmith
		}

		flavor = ep2_locale_events.4501.b.tt

		reverse_add_opinion = {
			target = scope:spying_spouse
			modifier = pleased_opinion
			opinion = 30
		}

		stress_impact = {
			shy = minor_stress_impact_loss
			seducer = medium_stress_impact_gain
			lustful = minor_stress_impact_gain
			chaste = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}		
	}

	# Oi! We're leaving!
	option = {
		name = ep2_locale_events.4501.c

		reverse_add_opinion = {
			target = scope:spying_spouse
			modifier = disappointed_opinion
			opinion = -15
		}

		stress_impact = {
			calm = medium_stress_impact_gain
			content = medium_stress_impact_gain
			lustful = minor_stress_impact_gain
			chaste = minor_stress_impact_gain
			wrathful = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
		}

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

	# Looking hurts nobody
	option = {
		name = ep2_locale_events.4501.d

		reverse_add_opinion = {
			target = scope:spying_spouse
			modifier = relieved_opinion
			opinion = 15
		}

		stress_impact = {
			calm = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
			wrathful = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = wrathful
					has_trait = content
				}
			}
		}	
	}
}

# The weaponsmith has a special sword for you
# by Nick Meredith
ep2_locale_events.4505 = {
	type = activity_event
	title = ep2_locale_events.4505.t
	desc = ep2_locale_events.4505.desc
	theme = friendly
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:tournament_weaponsmith
		animation = ecstasy
	}
	artifact = {
		target = scope:artisanal_sword
		position = lower_center_portrait
	}
	override_background = { reference = armory }

	trigger = {
		exists = var:tournament_weaponsmith
		var:tournament_weaponsmith = { is_alive = yes }
		scope:activity = { 
			has_active_locale = tournament_locale_artisans
		}
		has_trait = tourney_participant
		has_trait_xp = { #Make sure you are a famed soldier
			trait = tourney_participant
			track = foot
			value > 90
		}
	}

	immediate = {
		hidden_effect = {
			create_artifact = {
				name = artisanal_sword
				description = artisanal_sword_description
				type = sword
				visuals = sword
				modifier = artifact_prowess_2_modifier
				creator = scope:tournament_weaponsmith
				wealth = scope:wealth
				quality = scope:quality
				save_scope_as = artisanal_sword
			}

			random_courtier_or_guest = {
				save_scope_as = tournament_weaponsmith
			}

			#Personalise your sword
			generate_personalised_sword_effect = yes
			generate_personalised_sword_effect = yes
			generate_personalised_sword_effect = yes

			scope:artisanal_sword = {
				set_artifact_rarity = famed

				#General ones to make it nice
				add_scaled_artifact_modifier_combat_effect = yes
				add_scaled_artifact_modifier_prestige_effect = yes
			}
		}
	}

	# Yes please!
	option = {
		name = ep2_locale_events.4505.a

		trigger = {
			OR = {
				has_trait = greedy
				has_trait = avaricious
			}
		}

		flavor = ep2_locale_events.4505.a.tt

		scope:artisanal_sword = {
			#Give it to you
			set_owner = root
		}

		hidden_effect = {
			scope:artisanal_sword = {
				#And equip it
				equip_artifact_to_owner = yes
			}
		}

		trigger_event = ep2_locale_events.4506

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			content = minor_stress_impact_gain
			generous = medium_stress_impact_gain
			ambitious = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = content
				}
			}
		}
	}

	# Let me pay you
	option = {
		name = ep2_locale_events.4505.b

		pay_short_term_gold = {
			target = scope:tournament_weaponsmith
			gold = 150
		}

		scope:artisanal_sword = {
			#Give it to you
			set_owner = root
		}

		hidden_effect = {
			scope:artisanal_sword = {
				#And equip it
				equip_artifact_to_owner = yes
			}
		}

		trigger_event = ep2_locale_events.4506

		stress_impact = {
			greedy = medium_stress_impact_gain
			content = minor_stress_impact_gain
			generous = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = content
					gold < 150 #Just to ensure they don't put themselves into debt for this
				}
			}
		}
	}
	
	# No thanks
	option = {
		name = ep2_locale_events.4505.c

		destroy_artifact = scope:artisanal_sword

		reverse_add_opinion = {
			modifier = disappointed_opinion
			target = scope:tournament_weaponsmith
			opinion = -60
		}

		stress_impact = {
			generous = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
			greedy = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -1
				ai_greed = 1
			}
		}
	}
}

# Weaponsmith asks you to name the sword
ep2_locale_events.4506 = {
	type = character_event
	title = ep2_locale_events.4506.t
	desc = ep2_locale_events.4506.desc
	theme = friendly
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:tournament_weaponsmith
		animation = ecstasy
	}
	artifact = {
		target = scope:artisanal_sword
		position = lower_center_portrait
	}
	override_background = { reference = armory }

	immediate = {
		#To give some options to show
		assign_sword_names_effect = yes
		assign_sword_names_effect = yes
		assign_sword_names_effect = yes

		if = {
			limit = {
				any_equipped_character_artifact = {
					artifact_slot_type = primary_armament 
				}
			}
			random_equipped_character_artifact = { save_scope_as = rename_artifact }
		}
	}

	widget = { 
		gui = "event_window_widget_enter_text"
		container = "dynamic_birth_name"
		controller = { #This is going to get long, sorry readers!
			type = text
			data = {
				key = new_artifact_name
				default = {
					localization_key = sword_name_widowmaker
					trigger = {
						has_character_flag = sword_name_widowmaker
					}
				}
				default = {
					localization_key = sword_name_widowermaker
					trigger = {
						has_character_flag = sword_name_widowermaker
					}
				}
				default = {
					localization_key = sword_name_slicer
					trigger = {
						has_character_flag = sword_name_slicer
					}
				}
				default = {
					localization_key = sword_name_dicer
					trigger = {
						has_character_flag = sword_name_dicer
					}
				}
				#AGOT Disabled
				# default = {
				# 	localization_key = sword_name_almace
				# 	trigger = {
				# 		has_character_flag = sword_name_almace
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_hauteclere
				# 	trigger = {
				# 		has_character_flag = sword_name_hauteclere
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_murgleis
				# 	trigger = {
				# 		has_character_flag = sword_name_murgleis
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_flamberge
				# 	trigger = {
				# 		has_character_flag = sword_name_flamberge
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_arondight
				# 	trigger = {
				# 		has_character_flag = sword_name_arondight
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_clarent
				# 	trigger = {
				# 		has_character_flag = sword_name_clarent
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_coreiseuse
				# 	trigger = {
				# 		has_character_flag = sword_name_coreiseuse
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_galatine
				# 	trigger = {
				# 		has_character_flag = sword_name_galatine
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_gramr
				# 	trigger = {
				# 		has_character_flag = sword_name_gramr
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_tyrfing
				# 	trigger = {
				# 		has_character_flag = sword_name_tyrfing
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_zulfiqar
				# 	trigger = {
				# 		has_character_flag = sword_name_zulfiqar
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_harpe
				# 	trigger = {
				# 		has_character_flag = sword_name_harpe
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_ascalon
				# 	trigger = {
				# 		has_character_flag = sword_name_ascalon
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_asi
				# 	trigger = {
				# 		has_character_flag = sword_name_asi
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_caladgolg
				# 	trigger = {
				# 		has_character_flag = sword_name_caladgolg
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_blutgang
				# 	trigger = {
				# 		has_character_flag = sword_name_blutgang
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_fragarach
				# 	trigger = {
				# 		has_character_flag = sword_name_fragarach
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_chandrahas
				# 	trigger = {
				# 		has_character_flag = sword_name_chandrahas
				# 	}
				# }
				# default = {
				# 	localization_key = sword_name_nandaka
				# 	trigger = {
				# 		has_character_flag = sword_name_nandaka
				# 	}
				# }
				default = {
					localization_key = sword_name_old_pokey
					trigger = {
						has_character_flag = sword_name_old_pokey
					}
				}
				default = {
					localization_key = sword_name_needle
					trigger = {
						has_character_flag = sword_name_needle
					}
				}
				default = {
					localization_key = sword_name_stabitha
					trigger = {
						has_character_flag = sword_name_stabitha
					}
				}
				default = {
					localization_key = sword_name_marsil
					trigger = {
						has_character_flag = sword_name_marsil
					}
				}
				default = {
					localization_key = sword_name_kingsbane
					trigger = {
						has_character_flag = sword_name_kingsbane
					}
				}
				default = {
					localization_key = sword_name_queensbane
					trigger = {
						has_character_flag = sword_name_queensbane
					}
				}
				default = {
					localization_key = sword_name_triumph
					trigger = {
						has_character_flag = sword_name_triumph
					}
				}
				default = {
					localization_key = sword_name_fears_bane
					trigger = {
						has_character_flag = sword_name_fears_bane
					}
				}
				default = {
					localization_key = sword_name_tranquility
					trigger = {
						has_character_flag = sword_name_tranquility
					}
				}
				default = {
					localization_key = sword_name_reaper
					trigger = {
						has_character_flag = sword_name_reaper
					}
				}
				default = {
					localization_key = sword_name_purity
					trigger = {
						has_character_flag = sword_name_purity
					}
				}
				default = {
					localization_key = sword_name_beguiler
					trigger = {
						has_character_flag = sword_name_beguiler
					}
				}
				default = {
					localization_key = sword_name_assurance
					trigger = {
						has_character_flag = sword_name_assurance
					}
				}
				default = {
					localization_key = sword_name_fate
					trigger = {
						has_character_flag = sword_name_fate
					}
				}
				default = {
					localization_key = sword_name_grinder
					trigger = {
						has_character_flag = sword_name_grinder
					}
				}
				default = {
					localization_key = sword_name_indolence
					trigger = {
						has_character_flag = sword_name_indolence
					}
				}
				default = {
					localization_key = sword_name_quicksilver
					trigger = {
						has_character_flag = sword_name_quicksilver
					}
				}
				default = {
					localization_key = sword_name_obstinate
					trigger = {
						has_character_flag = sword_name_obstinate
					}
				}
				default = {
					localization_key = sword_name_mercy
					trigger = {
						has_character_flag = sword_name_mercy
					}
				}
				default = {
					localization_key = sword_name_vengeance
					trigger = {
						has_character_flag = sword_name_vengeance
					}
				}
				default = {
					localization_key = sword_name_charity
					trigger = {
						has_character_flag = sword_name_charity
					}
				}
				default = {
					localization_key = sword_name_opulence
					trigger = {
						has_character_flag = sword_name_opulence
					}
				}
				default = {
					localization_key = sword_name_amity
					trigger = {
						has_character_flag = sword_name_amity
					}
				}
				default = {
					localization_key = sword_name_solitude
					trigger = {
						has_character_flag = sword_name_solitude
					}
				}
				default = {
					localization_key = sword_name_candour
					trigger = {
						has_character_flag = sword_name_candour
					}
				}
				default = {
					localization_key = sword_name_deceiver
					trigger = {
						has_character_flag = sword_name_deceiver
					}
				}
				default = {
					localization_key = sword_name_humility
					trigger = {
						has_character_flag = sword_name_humility
					}
				}
				default = {
					localization_key = sword_name_glory
					trigger = {
						has_character_flag = sword_name_glory
					}
				}
				default = {
					localization_key = sword_name_justice
					trigger = {
						has_character_flag = sword_name_justice
					}
				}
				default = {
					localization_key = sword_name_whimsy
					trigger = {
						has_character_flag = sword_name_whimsy
					}
				}
				default = {
					localization_key = sword_name_serenity
					trigger = {
						has_character_flag = sword_name_serenity
					}
				}
				default = {
					localization_key = sword_name_ardent
					trigger = {
						has_character_flag = sword_name_ardent
					}
				}
				default = {
					localization_key = sword_name_prudence
					trigger = {
						has_character_flag = sword_name_prudence
					}
				}
				default = {
					localization_key = sword_name_devourer
					trigger = {
						has_character_flag = sword_name_devourer
					}
				}
				default = {
					localization_key = sword_name_steadfast
					trigger = {
						has_character_flag = sword_name_steadfast
					}
				}
				default = {
					localization_key = sword_name_safeguard
					trigger = {
						has_character_flag = sword_name_safeguard
					}
				}
				default = {
					localization_key = sword_name_faith
					trigger = {
						has_character_flag = sword_name_faith
					}
				}
				default = {
					localization_key = sword_name_doubt
					trigger = {
						has_character_flag = sword_name_doubt
					}
				}
				default = {
					localization_key = sword_name_clemency
					trigger = {
						has_character_flag = sword_name_clemency
					}
				}
				default = {
					localization_key = sword_name_malice
					trigger = {
						has_character_flag = sword_name_malice
					}
				}
				default = {
					localization_key = sword_name_desolation
					trigger = {
						has_character_flag = sword_name_desolation
					}
				}
				default = {
					localization_key = sword_name_bloodletter
					trigger = {
						has_character_flag = sword_name_bloodletter
					}
				}
				default = {
					localization_key = sword_name_fealty
					trigger = {
						has_character_flag = sword_name_fealty
					}
				}
				default = {
					localization_key = sword_name_oathbreaker
					trigger = {
						has_character_flag = sword_name_oathbreaker
					}
				}
				default = {
					localization_key = sword_name_raconteur
					trigger = {
						has_character_flag = sword_name_raconteur
					}
				}
			}
		}
		setup_scope = {
			root = { save_scope_as = text_target }
		}
	}

	option = { 
		name = ep2_locale_events.4506.a

		custom_tooltip = ep2_locale_events.4506.a.tt

		if = {
			limit = { has_variable = new_artifact_name }
			scope:rename_artifact = {
				set_artifact_name = rename_artifact_default_key
			}
		}
		else = {
			scope:rename_artifact = {
				set_artifact_name = rename_artifact_entered_text
			}
		}

		stress_impact = {
			humble = minor_stress_impact_gain
			arrogant = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = ep2_locale_events.4506.b

		add_prestige = 200

		stress_impact = {
			base = miniscule_stress_impact_loss
			humble = minor_stress_impact_loss
			arrogant = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -1
				ai_boldness = -1
			}
		}
	}

	after = {
		remove_sword_flags_effect = yes

		if = {
			limit = { has_variable = new_artifact_name }
			remove_variable = new_artifact_name
		}
	}
}

##################################################
# Offensive Gifts
# by Joe Parkin
# 4510-4512
##################################################

# Decision
ep2_locale_events.4510 = {
	type = activity_event
	title = ep2_locale_events.4510.t
	desc = ep2_locale_events.4510.desc
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = worry
	}
	lower_right_portrait = scope:befriend_target
	cooldown = { years = 1 }

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = {
		OR = {
			tournament_intent_locale_trigger = { INTENT = befriend_attendee }
			tournament_intent_locale_trigger = { INTENT = woo_attendee }
		}
		intent_target = {
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root.intent_target }
		}
		scope:activity = {
			has_active_locale = tournament_locale_artisans
		}
		activity_tournament_armor_contest_trigger = yes
	}

	immediate = {
		play_music_cue = mx_cue_weaponsmith
		save_scope_as = befriend_actor
		intent_target = {
			save_scope_as = befriend_target
			set_signature_weapon_effect = yes
		}
	}

	# Buy weapon
	option = {
		name = ep2_locale_events.4510.a
		remove_short_term_gold =  minor_gold_value
		custom_tooltip = ep2_locale_events.4510.a.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:weapon
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
				ai_greed = -0.5
			}
		}
	}

	# Buy display weapon
	option = {
		name = ep2_locale_events.4510.b
		remove_short_term_gold =  medium_gold_value
		custom_tooltip = ep2_locale_events.4510.b.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:ornament
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -1
				ai_boldness = -0.5
				ai_greed = -1
			}
		}
	}

	# Buy dagger
	option = {
		name = ep2_locale_events.4510.c
		remove_short_term_gold =  tiny_gold_value
		custom_tooltip = ep2_locale_events.4510.c.tt
		save_scope_value_as = {
			name = befriend_approach
			value = flag:dagger
		}
		tournament_gift_outcome_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.5
				ai_boldness = 0.5
				ai_greed = -0.5
			}
		}
	}

	# No buy
	option = {
		name = ep2_locale_events.4510.d
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_boldness = -0.5
				ai_greed = 1
			}
		}
	}

	after = {
		if = {
			limit = { exists = scope:befriend_approach }
			hidden_effect = {
				#Evaluate what makes for a "right" choice
				if = {
					limit = {
						OR = {
							AND = {
								OR = {
									has_lifestyle = martial_lifestyle
									has_trait = education_martial_prowess
									has_trait = education_martial
									has_trait = brave
									has_trait = lifestyle_blademaster
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:weapon
							}
							AND = {
								OR = {
									NOR = {
										has_lifestyle = martial_lifestyle
										has_trait = education_martial
										has_lifestyle = intrigue_lifestyle
										has_trait = education_intrigue
										has_trait = schemer
									}
									has_trait = craven
									has_trait = greedy
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:ornament
							}
							AND = {
								OR = {
									has_lifestyle = intrigue_lifestyle
									has_trait = education_intrigue
									has_trait = schemer
									has_trait = deceitful
								}
								exists = scope:befriend_approach
								scope:befriend_approach = flag:dagger
							}
						}
					}
					save_scope_value_as = {
						name = made_great_choice
						value = yes
					}
				}
				random_list = {
					50 = {
						modifier = {
							add = 100
							exists = scope:made_great_choice
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:weapon
							has_trait = brave
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:ornament
							has_trait = arrogant
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:ornament
							has_trait = greedy
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:dagger
							has_trait = deceitful
						}						
						save_scope_as = befriend_success
					}
					50 = {
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:weapon
							has_trait = craven
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:ornament
							has_trait = humble
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:ornament
							has_trait = content
						}
						modifier = {
							add = 25
							exists = scope:befriend_approach
							scope:befriend_approach = flag:dagger
							has_trait = honest
						}
						save_scope_as = befriend_failure
					}
				}
				scope:befriend_target = {
					trigger_event = {
						id = ep2_locale_events.4511
						days = { 1 2 }
					}
				}			
			}
		}
	}
}

scripted_effect tournament_weaponsmith_befriend_tooltip_effect = {
	show_as_tooltip = {
		if = {
			limit = { exists = scope:newly_created_artifact }
			show_as_tooltip = {
				scope:newly_created_artifact = { set_owner = scope:befriend_target }
			}
		}
		else_if = {
			limit = { has_character_modifier = tournament_weaponsmith_ornament_modifier }
			add_character_modifier = { modifier = tournament_weaponsmith_ornament_modifier years = 20 }
		}
	}
}

#Target
ep2_locale_events.4511 = {
	type = activity_event
	title = ep2_locale_events.4510.t
	desc = {
		desc = ep2_locale_events.4511.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:weapon
				}
				desc = ep2_locale_events.4511.success_weapon
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:weapon }
				desc = ep2_locale_events.4511.weapon
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:ornament
				}
				desc = ep2_locale_events.4511.success_ornament
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:ornament }
				desc = ep2_locale_events.4511.ornament
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:dagger
				}
				desc = ep2_locale_events.4511.success_dagger
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:dagger }
				desc = ep2_locale_events.4511.dagger
			}
		}
	}
	left_portrait = {
		character = scope:befriend_actor
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:befriend_success }
			}
			animation = sadness
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = tournament_locale_camp

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_weaponsmith
		scope:befriend_actor = {
			save_scope_as = owner 
			get_artifact_quality_effect = yes
			get_artifact_wealth_effect = yes
		}
		hidden_effect = {
			switch = {
				trigger = scope:befriend_approach
				flag:weapon = {
					if = {
						limit = { scope:befriend_target.var:signature_weapon = flag:axe }
						create_artifact_weapon_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_WEAPON_TYPE = flag:artifact_weapon_type_axe }
					}
					else_if = {
						limit = { scope:befriend_target.var:signature_weapon = flag:hammer }
						create_artifact_weapon_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_WEAPON_TYPE = flag:artifact_weapon_type_hammer }
					}
					else_if = {
						limit = { scope:befriend_target.var:signature_weapon = flag:mace }
						create_artifact_weapon_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_WEAPON_TYPE = flag:artifact_weapon_type_mace }
					}
					else = {
						create_artifact_weapon_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_WEAPON_TYPE = flag:artifact_weapon_type_sword }
					}
				}
				flag:ornament = {
					if = {
						limit = { has_royal_court = yes }
						create_artifact_weapon_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_WEAPON_TYPE = flag:no }
						scope:newly_created_artifact = {
							reforge_artifact = { type = pedestal }
						}
					}
					else = {
						add_character_modifier = {
							modifier = tournament_weaponsmith_ornament_modifier
							years = 20
						}
					}
				}
				flag:dagger = {
					create_artifact_weapon_effect = { OWNER = scope:befriend_target CREATOR = scope:befriend_actor SET_WEAPON_TYPE = flag:artifact_weapon_type_dagger }
				}
			}
		}
		tournament_weaponsmith_befriend_tooltip_effect = yes
		scope:befriend_actor = {
			trigger_event = {
				id = ep2_locale_events.4512
				days = { 1 2 }
			}
		}
	}

	option = {
		name = ep2_locale_events.4511.a
		trigger = { exists = scope:befriend_success }
		add_stress = minor_stress_loss
		show_as_tooltip = { tournament_gift_relationship_effect = yes }
	}

	option = {
		name = ep2_locale_events.4511.b
		trigger = { exists = scope:befriend_failure }
	}
}

#Actor
ep2_locale_events.4512 = {
	type = activity_event
	title = ep2_locale_events.4510.t
	desc = {
		desc = ep2_locale_events.4512.opening
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.4512.success_reply
			}
			desc = ep2_locale_events.4512.reply
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:weapon
				}
				desc = ep2_locale_events.4512.success_weapon
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:weapon }
				desc = ep2_locale_events.4512.weapon
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:ornament
				}
				desc = ep2_locale_events.4512.success_ornament
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:ornament }
				desc = ep2_locale_events.4512.ornament
			}
			triggered_desc = {
				trigger = {
					exists = scope:befriend_success
					scope:befriend_approach = flag:dagger
				}
				desc = ep2_locale_events.4512.success_dagger
			}
			triggered_desc = {
				trigger = { scope:befriend_approach = flag:dagger }
				desc = ep2_locale_events.4512.dagger
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:befriend_success }
				desc = ep2_locale_events.4512.success
			}
			desc = ep2_locale_events.4512.failure
		}
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = admiration
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = worry
		}
	}
	right_portrait = {
		character = scope:befriend_target
		triggered_animation = {
			trigger = { exists = scope:befriend_success }
			animation = happiness
		}
		triggered_animation = {
			trigger = { exists = scope:befriend_failure }
			animation = disapproval
		}
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	theme = tournament_locale_camp

	widget = {
		gui = "event_window_widget_activity_intent"
		container = "custom_widgets_container"
	}

	trigger = { exists = scope:befriend_approach }

	immediate = {
		play_music_cue = mx_cue_weaponsmith
		scope:befriend_target = { tournament_weaponsmith_befriend_tooltip_effect = yes }
	}

	option = {
		name = ep2_locale_events.4512.a
		trigger = { exists = scope:befriend_success }
		tournament_gift_relationship_effect = yes
	}

	option = {
		name = ep2_locale_events.4512.b
		trigger = { exists = scope:befriend_failure }
		reverse_add_opinion = {
			target = scope:befriend_target
			modifier = tournament_failed_gift_opinion
			opinion = -5
		}
	}
}

#Weaponsmith wants to quench a blade in your blood
#by Nick Meredith
ep2_locale_events.4520 = {
	type = activity_event
	title = ep2_locale_events.4520.t
	desc = ep2_locale_events.4520.desc
	theme = tournament_locale_forge
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:tournament_weaponsmith
		animation = spymaster
	}
	cooldown = { years = 1 }
	
	trigger = {
		scope:activity = { # You have a weaponsmith
			has_active_locale = tournament_locale_artisans
			exists = var:tournament_weaponsmith
			var:tournament_weaponsmith = { is_alive = yes }
		}
		activity_tournament_armor_contest_trigger = yes
	}

	immediate = {
		play_music_cue = mx_cue_weaponsmith
		scope:activity = {
			var:tournament_weaponsmith = { save_scope_as = tournament_weaponsmith }
		}
	}

	# Agree, for glory
	option = {
		name = ep2_locale_events.4520.a

		trigger = {
			has_trait = ambitious
		}

		increase_wounds_no_death_effect = { REASON = wounds }

		add_prestige = medium_prestige_value

		scope:tournament_weaponsmith = {
			duel = {
				skills = { martial learning }
				value = decent_skill_rating

				# The created sword is impressive
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = ep2_locale_events.4520.a.success
					send_interface_toast = {
						title = ep2_locale_events.4520.a.success
						left_icon = root
						right_icon = scope:tournament_weaponsmith

						create_artifact = {
							name = blooded_blade
							description = blooded_blade_description
							type = sword
							visuals = sword
							creator = scope:tournament_weaponsmith
							modifier = artifact_monthly_prestige_3_modifier
							modifier = artifact_dread_gain_mult_2_modifier
							modifier = artifact_prowess_1_negative_modifier
							wealth = 70
							quality = 70
							save_scope_as = blooded_blade
						}
					}
					add_character_flag = blooded_blade
				}

				# The created sword is unimpressive
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = ep2_locale_events.4520.a.failure
					send_interface_toast = {
						title = ep2_locale_events.4520.a.failure
						left_icon = root
						right_icon = scope:tournament_weaponsmith

						create_artifact = {
							name = sullied_blooded_blade
							description = sullied_blooded_blade_description
							type = sword
							visuals = sword
							creator = scope:tournament_weaponsmith
							modifier = artifact_monthly_prestige_2_modifier
							modifier = artifact_prowess_2_negative_modifier
							wealth = 40
							quality = 40
							save_scope_as = blooded_blade
						}
						scope:blooded_blade = {
							flag_as_unwanted_artifact = yes
						}
					}
					add_character_flag = sullied_blooded_blade
				}
			}
		}

		trigger_event = ep2_locale_events.4521

		stress_impact = {
			ambitious = minor_stress_impact_loss
			craven = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			arrogant = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = paranoid
				}
			}
		}
	}

	# Agree, so long as you have your salves to hand
	option = {
		name = ep2_locale_events.4520.b

		trigger = {
			OR = {
				has_trait = lifestyle_herbalist
				has_trait = lifestyle_physician
			}
		}

		scope:tournament_weaponsmith = {
			duel = {
				skills = { martial learning }
				value = decent_skill_rating

				# The created sword is impressive
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = ep2_locale_events.4520.a.success
					send_interface_toast = {
						title = ep2_locale_events.4520.a.success
						left_icon = root
						right_icon = scope:tournament_weaponsmith
						if = {
							limit = { activity_is_competing_trigger = yes }
							activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
						}
						create_artifact = {
							name = blooded_blade
							description = blooded_blade_description
							type = sword
							visuals = sword
							creator = scope:tournament_weaponsmith
							modifier = artifact_monthly_prestige_3_modifier
							modifier = artifact_dread_gain_mult_2_modifier
							modifier = artifact_prowess_1_negative_modifier
							wealth = 70
							quality = 70
							save_scope_as = blooded_blade
						}
						add_character_flag = blooded_blade
					}
				}

				# The created sword is unimpressive
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = ep2_locale_events.4520.a.failure
					send_interface_toast = {
						title = ep2_locale_events.4520.a.failure
						left_icon = root
						right_icon = scope:tournament_weaponsmith
						if = {
							limit = { activity_is_competing_trigger = yes }
							activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
						}
						create_artifact = {
							name = sullied_blooded_blade
							description = sullied_blooded_blade_description
							type = sword
							visuals = sword
							creator = scope:tournament_weaponsmith
							modifier = artifact_monthly_prestige_2_modifier
							modifier = artifact_prowess_2_negative_modifier
							wealth = 40
							quality = 40
							save_scope_as = blooded_blade
						}
						scope:blooded_blade = {
							flag_as_unwanted_artifact = yes
						}
						add_character_flag = sullied_blooded_blade
					}
				}
			}
		}

		trigger_event = ep2_locale_events.4521

		stress_impact = {
			base = miniscule_stress_impact_loss
			content = medium_stress_impact_gain
			craven = minor_stress_impact_gain
			paranoid = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			arrogant = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = paranoid
					has_trait = content
				}
			}
		}
	}

	# Agree tentatively
	option = {
		name = ep2_locale_events.4520.c

		trigger = {
			NOT = {
				has_trait = ambitious
			}
		}

		increase_wounds_no_death_effect = { REASON = wounds }

		scope:tournament_weaponsmith = {
			duel = {
				skills = { martial learning }
				value = high_skill_rating #higher to inherently reward trait option

				# The created sword is impressive
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					opinion_modifier = {
						who = scope:tournament_weaponsmith
						opinion_target = root
						multiplier = 0.5
					}
					desc = ep2_locale_events.4520.a.success
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4520.a.success
							left_icon = root
							right_icon = scope:tournament_weaponsmith
							if = {
								limit = { activity_is_competing_trigger = yes }
								activity_tournament_change_contestant_score_effect = { SCORE = increase_minor }
							}
							create_artifact = {
								name = blooded_blade
								description = blooded_blade_description
								type = sword
								visuals = sword
								creator = scope:tournament_weaponsmith
								modifier = artifact_monthly_prestige_3_modifier
								modifier = artifact_dread_gain_mult_2_modifier
								modifier = artifact_prowess_1_negative_modifier
								wealth = 70
								quality = 70
								save_scope_as = blooded_blade
							}
						}
						add_character_flag = blooded_blade
					}
				}

				# The created sword is unimpressive
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = ep2_locale_events.4520.a.failure
					root = {
						send_interface_toast = {
							title = ep2_locale_events.4520.a.failure
							left_icon = root
							right_icon = scope:tournament_weaponsmith
							if = {
								limit = { activity_is_competing_trigger = yes }
								activity_tournament_change_contestant_score_effect = { SCORE = increase_miniscule }
							}
							create_artifact = {
								name = sullied_blooded_blade
								description = sullied_blooded_blade_description
								type = sword
								visuals = sword
								creator = scope:tournament_weaponsmith
								modifier = artifact_monthly_prestige_2_modifier
								modifier = artifact_prowess_2_negative_modifier
								wealth = 40
								quality = 40
								save_scope_as = blooded_blade
							}
							scope:blooded_blade = {
								flag_as_unwanted_artifact = yes
							}
						}
						add_character_flag = sullied_blooded_blade
					}
				}
			}
		}

		trigger_event = ep2_locale_events.4521

		stress_impact = {
			content = medium_stress_impact_gain
			craven = minor_stress_impact_gain
			paranoid = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			arrogant = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = paranoid
					has_trait = content
				}
			}
		}
	}

	# Dismiss the idea
	option = {
		name = ep2_locale_events.4520.d

		add_martial_lifestyle_xp = 5

		reverse_add_opinion = {
			target = scope:tournament_weaponsmith
			modifier = disappointed_opinion
			opinion = -30
		}

		stress_impact = {
			content = miniscule_stress_impact_loss
			craven = minor_stress_impact_loss
			paranoid = miniscule_stress_impact_loss
			humble = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -0.5
			}
		}
	}
}

ep2_locale_events.4521 = {
	type = activity_event
	title = ep2_locale_events.4521.t
	desc = {
		desc = ep2_locale_events.4521.start
		first_valid = {
		    triggered_desc = {
		        trigger = { has_character_flag = blooded_blade }
		        desc = ep2_locale_events.4521.success
		    }
		    triggered_desc = {
		        trigger = { has_character_flag = sullied_blooded_blade }
		        desc = ep2_locale_events.4521.failure
		    }
		}
		desc = ep2_locale_events.4521.ending
	}
	theme = physical_health  
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:tournament_weaponsmith
		animation = ecstasy
	}
	artifact = {
		target = scope:blooded_blade
		position = lower_center_portrait
	}

	immediate = {
		play_music_cue = mx_cue_weaponsmith
	}

	# Take the blade
	option = {
		name = ep2_locale_events.4521.a

		scope:blooded_blade = {
			set_owner = root
		}

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			generous = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -0.5
				ai_greed = 1
			}
		}
	}

	# ...on second thoughts, you can buy it off me
	option = {
		name = ep2_locale_events.4521.b

		scope:tournament_weaponsmith = {
			pay_short_term_gold = {
				target = root
				gold = 35
			}
		}

		if = {
			limit = { activity_is_competing_trigger = yes }
			if = {
				limit = { has_character_flag = sullied_blooded_blade }
				activity_tournament_change_contestant_score_effect = { SCORE = decrease_miniscule }
			}
			else = {
				activity_tournament_change_contestant_score_effect = { SCORE = decrease_minor }
			}
		}		

		reverse_add_opinion = {
			target = scope:tournament_weaponsmith
			modifier = pleased_opinion
			opinion = 20
		}

		stress_impact = {
			ambitious = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
			generous = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
				ai_greed = -0.5
			}
		}
	}

	after = {
		remove_character_flag = blooded_blade
		remove_character_flag = sullied_blooded_blade
	}
}

#######################################
#######################################
### 	GROUNDS - 5000-5499			###
#######################################
#######################################

#######################################
#######################################
### 	VILLAGE - 5500-5999			###
#######################################
#######################################
