﻿namespace = fp3_misc_decisions

### EVENT LIST ####################################################################
## 0005 - 0009	Request Invasion by Hugo Cortell
## 0010 - 0014	Demand Submission letter events
## 0015	- 0015	Embrace Zoroastrianism faith selection event
## 0020 - 0030	Challenge House Head Events by Hugo Cortell
## 0031 - 0040  Favor Skilled Outsiders events by Ewan Cowhig Croft
## 0041 - 0050  Extra Challenge House Head Events
###################################################################################

###################################
# Request Invasion
# By Hugo Cortell
###################################
fp3_misc_decisions.0005 = {
	hidden = yes

	immediate = {
		random_character_war = { # We need to locate the war we just created, since we can't save it on creation
			limit = {
				using_cb = fp3_turkic_invasion_cb
				primary_attacker = scope:secondary_recipient # root
				primary_defender = scope:recipient
			}
			add_attacker = scope:actor
		}
	}
}
fp3_misc_decisions.0006 = {
	hidden = yes

	immediate = {
		random_character_war = { # We need to locate the war we just created, since we can't save it on creation
			limit = {
				using_cb = fp3_turkic_invasion_cb
				primary_attacker = scope:secondary_recipient # root
				primary_defender = scope:recipient
			}
			save_scope_as = turkic_war
		}
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
			}
			spawn_army = {
				men_at_arms = {
					type = horse_archers
					stacks = fp3_request_invasion_troop_value_bonus_troops
				}
				men_at_arms = {
					type = steppe_raiders
					stacks = fp3_request_invasion_troop_value_bonus_troops
				}
				men_at_arms = {
					type = nomadic_riders
					stacks = fp3_request_invasion_troop_value_bonus_levy_nomads
				}
				location = capital_province
				uses_supply = yes
				war = scope:turkic_war
				inheritable = no
				name = turkic_tribal_event_troops
			}
		}
		else = {
			spawn_army = {
				men_at_arms = {
					type = horse_archers
					stacks = fp3_request_invasion_troop_value_bonus_troops
				}
				men_at_arms = {
					type = light_horsemen
					stacks = fp3_request_invasion_troop_value_bonus_troops
				}
				levies = fp3_request_invasion_troop_value_bonus_levy_troops
				location = capital_province
				uses_supply = yes
				war = scope:turkic_war
				inheritable = no
				name = turkic_tribal_event_troops
			}
		}
	}
}

# Demand Submission Letter Events
fp3_misc_decisions.0010 = {
	type = letter_event
	opening = fp3_misc_decisions.0010.opening
	desc = {
		desc = fp3_misc_decisions.0010.desc_intro
		# If the Persian Struggle is still ongoing, comment on that
		triggered_desc = {
			trigger = {
				exists = struggle:persian_struggle
				scope:actor ?= title:d_sunni.holder
			}
			desc = fp3_misc_decisions.0010.desc_struggle
		}
	}
	sender = scope:recipient

	immediate = {
		show_as_tooltip = {
			if = {
				limit = { scope:piety_cost_reduction ?= yes }
				add_piety = massive_piety_loss
			}
			add_hook = {
				target = scope:recipient
				type = caliphal_submission_hook
			}
			# Remove "rejected my authority" negative opinion, if valid
			if = {
				limit = {
					has_opinion_modifier = {
						modifier = fp3_rejected_my_authority_opinion
						target = scope:recipient
					}
				}
				remove_opinion = {
					modifier = fp3_rejected_my_authority_opinion
					target = scope:recipient
				}
			}
		}
	}

	option = {
		name = fp3_misc_decisions.0010.a
	}
}

fp3_misc_decisions.0011 = {
	type = letter_event
	opening = fp3_misc_decisions.0010.opening
	desc = fp3_misc_decisions.0011.desc
	sender = scope:recipient

	immediate = {
		show_as_tooltip = {
			scope:recipient = {
				add_piety = medium_piety_loss
				reverse_add_opinion = {
					target = scope:actor
					modifier = fp3_rejected_my_authority_opinion
					years = 30
				}
			}
		}
	}

	option = {
		name = fp3_misc_decisions.0011.a
	}
}

# Embrace Zoroastrianism faith selection event
fp3_misc_decisions.0015 = {
	type = character_event
	title = fp3_misc_decisions.0015.t
	desc = fp3_misc_decisions.0015.desc
	left_portrait = {
		character = root
		animation = worry
	}
	theme = faith

	immediate = {
		# Gather what faiths we can choose to convert to (Zoroastrian faiths practiced by counties in our realm)
		every_sub_realm_county = {
			faith = {
				if = {
					limit = {
						# Don't add the same faith to a list more than once
						NOT = {
							any_in_list = {
								list = realm_zoroastrian_faiths
								this = prev
							}
						}
						religion = religion:zoroastrianism_religion
					}
					add_to_list = realm_zoroastrian_faiths
				}
			}
		}
		# Save the faiths with the most, 2nd most, and 3rd most fervor
		# These are the faiths that we will be allowed to convert to
		ordered_in_list = {
			list = realm_zoroastrian_faiths
			order_by = fervor
			position = 0
			save_scope_as = zoroastrian_faith_1
		}
		if = {
			limit = {
				list_size = {
					name = realm_zoroastrian_faiths
					value > 1
				}
			}
			ordered_in_list = {
				list = realm_zoroastrian_faiths
				order_by = fervor
				position = 1
				save_scope_as = zoroastrian_faith_2
			}
		}
		if = {
			limit = {
				list_size = {
					name = realm_zoroastrian_faiths
					value > 2
				}
			}
			ordered_in_list = {
				list = realm_zoroastrian_faiths
				order_by = fervor
				position = 2
				save_scope_as = zoroastrian_faith_3
			}
		}
	}

	option = { # Zoroastrian faith option 1 (faith with the most fervor)
		name = fp3_misc_decisions.0015.a
		make_character_crypto_religionist_effect = { CRYPTO_RELIGION = scope:zoroastrian_faith_1 }
	}

	option = { # Zoroastrian faith option 2
		name = fp3_misc_decisions.0015.b
		trigger = {
			list_size = {
				name = realm_zoroastrian_faiths
				value > 1
			}
		}
		make_character_crypto_religionist_effect = { CRYPTO_RELIGION = scope:zoroastrian_faith_2 }
	}

	option = { # Zoroastrian faith option 3
		name = fp3_misc_decisions.0015.c
		trigger = {
			list_size = {
				name = realm_zoroastrian_faiths
				value > 2
			}
		}
		make_character_crypto_religionist_effect = { CRYPTO_RELIGION = scope:zoroastrian_faith_3 }
	}

	option = { # Don't switch to any secret faith
		name = false_conversion.0020.b # "No, no, the time is not yet right."
		add_piety = miniscule_piety_gain # Refund piety
	}
}

###################################
# Challenge House Head Events
# By Hugo Cortell
# 0020 - 0030 + 0041 - 0050
###################################

scripted_trigger fp3_clan_challenge_negotiate_age_health_trigger = {
	OR = {
		AND = {
			scope:recipient.health < fine_health
			scope:recipient.health < scope:actor.health
		}
		AND = {
			scope:recipient.age >= 50
			scope:recipient.age >= root.age_plus_25
		}
		OR = {
			scope:recipient.age <= scope:actor.age_minus_10
			AND = {
				scope:recipient = { is_sibling_of = scope:actor }
				scope:recipient.age < scope:actor.age
			}
		}
	}
}

scripted_effect fp3_clan_challenge_negotiate_success_effect = {
	save_scope_as = negotiate_success
	save_scope_value_as = {
		name = negotiate_reason
		value = flag:$REASON$
	}
	show_as_tooltip = {
		scope:actor = {
			add_prestige = medium_prestige_gain
			house = { set_house_head = root }
		}
	}
}

scripted_effect fp3_clan_challenge_negotiate_bargain_effect = {
	save_scope_as = negotiate_bargain
	save_scope_value_as = {
		name = negotiate_reason
		value = flag:$REASON$
	}
	custom_tooltip = fp3_misc_decisions.0027.bargain.tt
}

scripted_effect fp3_clan_challenge_negotiate_fail_effect = {
	save_scope_as = negotiate_fail
	save_scope_value_as = {
		name = negotiate_reason
		value = flag:$REASON$
	}
	show_as_tooltip = {
		scope:actor = { add_prestige = medium_prestige_loss }
		scope:recipient = {
			add_prestige = medium_piety_value
			add_hook_no_toast = {
				type = trial_by_combat_hook
				target = scope:actor
			}
		}
	}
}

fp3_misc_decisions.0020 = { # Actor Duel Outcome(s)
	type = character_event
	title = fp3_misc_decisions.0020.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:sc_victor = scope:house_challenger
					scope:sc_loser = { is_alive = no }
				}
				desc = fp3_misc_decisions.0020.desc.a.lethal
			}
			triggered_desc = {
				trigger = { scope:sc_victor = scope:house_challenger }
				desc = fp3_misc_decisions.0020.desc.a
			}
			desc = fp3_misc_decisions.0020.desc.b
		}
	}

	theme = dynasty
	override_background = { reference = throne_room }
	left_portrait = {
		character = scope:house_challenger
		animation = war_over_loss

		triggered_animation = {
			trigger = { this = scope:sc_victor }
			animation = war_over_win
		}
	}
	right_portrait = {
		character = scope:house_head
		animation = war_over_loss

		triggered_animation = {
			trigger = { is_alive = no }
			animation = loss_1
		}
		triggered_animation = {
			trigger = { this = scope:sc_victor }
			animation = war_over_win
		}
	}

	immediate = {
	 	# Challenger lost
		if = {
			limit = { scope:sc_victor = scope:house_head }
			show_as_tooltip = { fp3_challenge_house_head_duel_challenger_loss_effect = yes } # Prestige and hooks
		}
		# Challenger won
		else = {
			show_as_tooltip = { fp3_challenge_house_head_duel_challenger_win_prestige_effect = yes } # Prestige gain
		}
	}

	# OPTIONS FOR LOSER
	option = { # Default option (goes on top, against design conventions)
		name = fp3_misc_decisions.0020.lose.a
		trigger = { scope:sc_loser = scope:house_challenger }
	}

	option = { # Slay them to take the mantle
		name = fp3_misc_decisions.0020.lose.b
		trigger = { scope:sc_loser = root }
		show_as_tooltip ={
			#Lose a ton of prestige for being so backhanded
			add_prestige = massive_prestige_loss
			add_prestige_level = -1
		}
		duel = {
			skills = { intrigue prowess }
			target = scope:house_head
			1 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 1
				show_as_tooltip = {
					known_murder_hidden_opinion_effect = { VICTIM = scope:house_head MURDERER = scope:house_challenger EXPOSER = scope:house_challenger }
					house = { set_house_head = root }
				}
				save_scope_as = challenge_murder_success
			}
			9 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				scope:house_head = {
					hidden_effect = {
						random = {
							chance = 50
							save_scope_as = challenge_wound
						}
					}
					show_as_tooltip = {
						if = {
							limit = {
								can_set_relation_rival_trigger = { CHARACTER = scope:house_challenger }
							}
							set_relation_rival = {
								target = scope:house_challenger
								reason = rival_tried_to_kill_me
							}
						}
						add_opinion = {
							target = scope:house_challenger
							modifier = attempted_murder_me_crime
						}
						imprison = {
							target = scope:house_challenger
							type = house_arrest
						}
					}
				}
			}
		}
		trigger_event = fp3_misc_decisions.0041
		stress_impact = {
			content = major_stress_impact_gain
			just = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 0
		}
	}

	option = {
		name = fp3_misc_decisions.0025.b
		trigger = {
			can_set_relation_rival_trigger = { CHARACTER = scope:recipient }
			scope:recipient = { is_alive = yes }
		}
		progress_towards_rival_effect = {
			REASON = rival_house_head_rejected_challenge
			CHARACTER = scope:recipient
			OPINION = default_rival_opinion
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_boldness = 0.25
				ai_vengefulness = 0.5
			}
		}
	}

	# OPTIONS FOR WINNER
	option = { # Default option
		name = fp3_misc_decisions.0020.win.a
		trigger = { scope:sc_victor = scope:house_challenger }
		fp3_challenge_house_head_duel_challenger_win_house_effect = yes
		ai_chance = {
			base = 25
		}
	}

	option = { # You fought well and deserve to be house head
		name = fp3_misc_decisions.0020.win.b
		trigger = {
			scope:sc_victor = scope:house_challenger
			has_trait = gallant
			scope:lethal != yes
		}
		add_prestige = massive_prestige_gain
		reverse_add_opinion = {
			target = scope:recipient
			modifier = honored_opinion
		}
		house = {
			add_clan_unity_interaction_effect = {
				CHARACTER = scope:actor
				TARGET = scope:recipient
				VALUE = miniscule_unity_gain # recover half of what was lost by challenge itself
				DESC = clan_unity_gallant_after_duel.desc
				REVERSE_NON_HOUSE_TARGET = yes
			}
		}
		stress_impact = {
			greedy = major_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = 0.5
				ai_compassion = 0.25
				ai_greed = -1
			}
			opinion_modifier = {
				opinion_target = scope:recipient
				multiplier = 0.25
			}
		}
	}
}

#	Bout has ended, inform affected parties.
fp3_misc_decisions.0021 = {
	hidden = yes

	immediate = {
		if = {
			limit = { scope:sc_victor = scope:house_challenger }
			fp3_challenge_house_head_duel_challenger_win_prestige_effect = yes
		}
		else = { fp3_challenge_house_head_duel_challenger_loss_effect = yes }
		scope:house_challenger = {
			trigger_event = {
				id = fp3_misc_decisions.0020
				days = 1
			}
		}
		scope:house_head = {
			trigger_event = {
				id = fp3_misc_decisions.0023
				days = 1
			}
			# allow challenges again
			if = {
				limit = { is_alive = yes }
				remove_character_flag = ongoing_house_head_challenge_flag
			}
		}
		# If both parties are alive, and aren't good losers/don't have good reasons to forgive each other, then we mark them as potential rivals.
		if = {
			limit = {
				scope:house_challenger = {
					is_alive = yes
					NOR = {
						has_trait = humble
						has_trait = content
						has_trait = just
						has_trait = forgiving
					}
				}
				scope:house_head = {
					is_alive = yes
					NOR = {
						has_trait = humble
						has_trait = content
						has_trait = just
						has_trait = forgiving
					}
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:house_challenger }
				}
			}
			scope:house_challenger = { set_relation_potential_rival = scope:house_head }
		}
	}
}

fp3_misc_decisions.0022 = { # Actor Duel opening
	type = character_event
	window = duel_event
	title = fp3_misc_decisions.0022.t
	desc = {
		desc = fp3_misc_decisions.0022.desc.intro
		desc = fp1_tbc.0001.desc.outro
		desc = fp3_misc_decisions.0022.desc.body
	}
	theme = dynasty
	left_portrait = {
		character = scope:actor
		animation = throne_room_one_handed_passive_1
	}
	right_portrait = {
		character = scope:recipient
		animation = war_over_win
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# If, for any reason, scope:recipient has died or been imprisoned, then the bout is cancelled.
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	on_trigger_fail = {
		# Inform both parties that the duel has invalidated.
		scope:actor = {
			send_interface_toast = {	
				title = fp3_misc_decisions.0022.trigger_failure.actor
				left_icon = scope:recipient
			}
		}
		scope:recipient = {
			send_interface_toast = {	
				title = fp3_misc_decisions.0022.trigger_failure.recipient
				left_icon = scope:actor
			}
		}
		# Reset scope:actor's cooldowns against scope:recipient.
		scope:actor = {
			remove_interaction_cooldown = challenge_to_trial_by_combat_interaction
			remove_interaction_cooldown_against = {
				interaction = fp3_challenge_house_head_interaction
				target = scope:recipient
			}
		}
		scope:recipient = {
			# allow challenges again
			remove_character_flag = ongoing_house_head_challenge_flag
		}
	}

	immediate = {
		play_music_cue = "mx_cue_combat_stinger"
		# Nab scope:champion's location for terrain.
		scope:recipient = {
			# And scope:champion's location name for loc.
			location.barony = { save_scope_as = duel_location }
		}
	}

	# Almost there.
	option = {
		name = fp3_misc_decisions.0022.a

		# Inform scope:actor that the bout will begin immediately.
		custom_tooltip = fp3_misc_decisions.0022.a.tt
		# Configure the bout.
		switch = {
			trigger = scope:lethal
			yes = {
				configure_start_single_combat_effect = {
					SC_INITIATOR = scope:actor 
					SC_ATTACKER = scope:actor
					SC_DEFENDER = scope:recipient
					FATALITY = always
					FIXED = no
					LOCALE = throne_room
					OUTPUT_EVENT = fp3_misc_decisions.0021
					INVALIDATION_EVENT = single_combat.1006
				}
			}
			no = {
				configure_start_single_combat_effect = {
					SC_INITIATOR = scope:actor 
					SC_ATTACKER = scope:actor
					SC_DEFENDER = scope:recipient
					FATALITY = no
					FIXED = no
					LOCALE = throne_room
					OUTPUT_EVENT = fp3_misc_decisions.0021
					INVALIDATION_EVENT = single_combat.1006
				}
			}
		}
		# No stress for single-option events.
		ai_chance = {
			# AI will always choose single option.
			base = 100
		}
	}
}

fp3_misc_decisions.0023 = { # Recipient Duel Outcome(s)
	type = character_event
	title = fp3_misc_decisions.0020.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:sc_loser = { is_alive = no }
					scope:sc_victor = scope:house_head
				}
				desc = fp3_misc_decisions.0023.desc.a.lethal
			}
			triggered_desc = {
				trigger = { scope:sc_victor = scope:house_head }
				desc = fp3_misc_decisions.0023.desc.a
			}
			desc = fp3_misc_decisions.0023.desc.b
		}
	}

	theme = dynasty
	override_background = { reference = throne_room }
	left_portrait = {
		character = scope:house_head
		animation = war_over_loss

		triggered_animation = {
			trigger = { this = scope:sc_victor }
			animation = war_over_win
		}
	}
	right_portrait = {
		character = scope:house_challenger
		animation = war_over_loss

		triggered_animation = {
			trigger = { is_alive = no }
			animation = loss_1
		}
		triggered_animation = {
			trigger = { this = scope:sc_victor }
			animation = war_over_win
		}
	}

	immediate = {
		if = {
			limit = { scope:sc_victor = scope:house_head }
			show_as_tooltip = { fp3_challenge_house_head_duel_challenger_loss_effect = yes } # Prestige and hooks
		}
		else = {
			show_as_tooltip = {
				fp3_challenge_house_head_duel_challenger_win_prestige_effect = yes # Prestige gain
				fp3_challenge_house_head_duel_challenger_win_house_effect = yes # House head change
			}
		}
	}

	# OPTIONS FOR WINNER
	option = { # Default option (goes on top, against design conventions)
		name = fp3_misc_decisions.0023.win.a
		trigger = { scope:sc_victor = scope:house_head }
	}

	# OPTIONS FOR LOSER
	option = { # Default option
		name = fp3_misc_decisions.0023.lose.a
		trigger = { scope:sc_victor = scope:house_challenger }
	}
}

fp3_misc_decisions.0025 = { # Interaction declined
	type = letter_event
	sender = scope:recipient
	opening = fp3_misc_decisions.0025.t
	desc = fp3_misc_decisions.0025.desc

	immediate = {
		show_as_tooltip = {  scope:recipient = { add_prestige = major_prestige_loss } }
	}

	option = {
		name = fp3_misc_decisions.0025.a
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_honor = 0.25
			}
		}
	}

	option = {
		name = fp3_misc_decisions.0025.b
		trigger = {
			can_set_relation_rival_trigger = { CHARACTER = scope:recipient }
		}
		progress_towards_rival_effect = {
			REASON = rival_house_head_rejected_challenge
			CHARACTER = scope:recipient
			OPINION = default_rival_opinion
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_boldness = 0.25
				ai_vengefulness = 0.5
			}
		}
	}
}

fp3_misc_decisions.0026 = { # Actor Diplomacy opening
	type = character_event
	title = fp3_misc_decisions.0022.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						is_governor = yes
						tgp_realm_has_ceremonial_liege_trigger = yes
					}
				}
				desc = fp3_misc_decisions.0026.desc.no_court
			}
			desc = fp3_misc_decisions.0026.desc
		}
	}
	theme = dynasty
	left_portrait = {
		character = scope:actor
		animation = worry
	}
	right_portrait = {
		character = scope:recipient
		animation = war_over_win
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# If, for any reason, scope:recipient has died or been imprisoned, then the bout is cancelled.
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	on_trigger_fail = {
		# Inform both parties that the duel has invalidated.
		scope:actor = {
			send_interface_toast = {	
				title = fp3_misc_decisions.0022.trigger_failure.actor
				left_icon = scope:recipient
			}
		}
		scope:recipient = {
			send_interface_toast = {	
				title = fp3_misc_decisions.0022.trigger_failure.recipient
				left_icon = scope:actor
			}
		}
		# Reset scope:actor's cooldowns against scope:recipient.
		scope:actor = {
			remove_interaction_cooldown = challenge_to_trial_by_combat_interaction
			remove_interaction_cooldown_against = {
				interaction = fp3_challenge_house_head_interaction
				target = scope:recipient
			}
		}
		scope:recipient = {
			# allow challenges again
			remove_character_flag = ongoing_house_head_challenge_flag
		}
	}

	immediate = {
		play_music_cue = "mx_cue_combat_stinger"
		# Nab scope:champion's location for terrain.
		scope:recipient = {
			# And scope:champion's location name for loc.
			location.barony = { save_scope_as = duel_location }
		}
	}

	# Almost there.
	option = {
		name = fp3_misc_decisions.0026.a
		custom_tooltip = fp3_misc_decisions.0026.a.tt
		trigger_event = {
			id = fp3_misc_decisions.0027
			days = 1
		}
		# No stress for single-option events.
		ai_chance = {
			# AI will always choose single option.
			base = 100
		}
	}
}

fp3_misc_decisions.0027 = { # Actor reason choice
	type = character_event
	title = fp3_misc_decisions.0022.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:recipient.house.house_founder = scope:recipient }
				desc = fp3_misc_decisions.0027.desc.founder
			}
			desc = fp3_misc_decisions.0027.desc
		}
	}
	theme = dynasty
	left_portrait = {
		character = scope:actor
		animation = admiration
	}
	right_portrait = {
		character = scope:recipient
		animation = thinking
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# Both parties alive and well
		scope:actor = {
			is_alive = yes
			is_imprisoned = no
		}
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		save_scope_value_as = {
			name = recipient_skill_sum_75
			value = {
				value = scope:recipient.sum_of_all_skills_value
				multiply = 0.75
				round = yes 
			}
		}
	}

	# Age/health, a rational option
	option = {
		name = {
			trigger = {
				scope:recipient.health < fine_health
				scope:recipient.health < scope:actor.health
			}
			text = fp3_misc_decisions.0027.a.sick
		}
		name = {
			trigger = {
				scope:recipient.age >= 50
				scope:recipient.age >= root.age_plus_25
			}
			text = fp3_misc_decisions.0027.a.old
		}
		name = {
			trigger = {
				NOR = {
					scope:recipient.age > scope:actor.age
					AND = {
						scope:recipient.health < fine_health
						scope:recipient.health < scope:actor.health
					}
					AND = {
						scope:recipient.age >= 50
						scope:recipient.age >= root.age_plus_25
					}
				}
			}
			text = fp3_misc_decisions.0027.a.young
		}
		trigger = {
			custom_tooltip = {
				text = fp3_misc_decisions.0027.a.trigger
				fp3_clan_challenge_negotiate_age_health_trigger = yes
			}
		}
		show_as_unavailable = { always = yes }
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:recipient.health < fine_health
						scope:recipient.health < scope:actor.health
					}
					desc = fp3_misc_decisions.0027.a.sick.tt
				}
				triggered_desc = {
					trigger = { scope:recipient.age > scope:recipient.age }
					desc = fp3_misc_decisions.0027.a.old.tt
				}
				triggered_desc = {
					trigger = { scope:recipient.age < scope:actor.age }
					desc = fp3_misc_decisions.0027.a.young.tt
				}
			}
		}
		duel = {
			skills = { learning }
			target = scope:recipient
			1 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.accept
				fp3_clan_challenge_negotiate_success_effect = { REASON = age }
			}
			5 = {
				# Personality
				fp3_challenge_house_head_negotiation_bargain_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.bargain
				fp3_clan_challenge_negotiate_bargain_effect = { REASON = age }
			}
			20 = {
				# Personality
				fp3_challenge_house_head_negotiation_reject_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				# Age
				modifier = {
					scope:recipient.age <= scope:actor.age_minus_10
					scope:recipient = { has_trait = arrogant }
					add = 10
				}
				# Health
				modifier = {
					add = {
						value = scope:recipient.health
						multiply = 2
					}
				}
				min = 15
				desc = fp3_misc_decisions.0027.reject
				fp3_clan_challenge_negotiate_fail_effect = { REASON = age }
			}
		}
		ai_chance = {
			base = 100
		}
	}

	# Strength, might makes right
	option = {
		name = {
			trigger = {
				scope:recipient = { is_vassal_or_below_of = scope:actor }
			}
			text = fp3_misc_decisions.0027.b.vassal
		}
		name = {
			trigger = { scope:recipient.highest_held_title_tier < scope:actor.highest_held_title_tier }
			text = fp3_misc_decisions.0027.b.tier
		}
		name = {
			trigger = { scope:recipient.current_military_strength < scope:actor.current_strength_seventy_five_percent_value }
			text = fp3_misc_decisions.0027.b.military
		}
		name = {
			trigger = {
				NOR = {
					scope:recipient = { is_vassal_or_below_of = scope:actor }
					scope:recipient.highest_held_title_tier < scope:actor.highest_held_title_tier
					scope:recipient.current_military_strength < scope:actor.current_strength_seventy_five_percent_value
				}
			}
			text = fp3_misc_decisions.0027.b.dread
		}
		trigger = {
			custom_tooltip = {
				text = fp3_misc_decisions.0027.b.trigger
				OR = {
					scope:recipient = { is_vassal_or_below_of = scope:actor }
					scope:recipient.highest_held_title_tier < scope:actor.highest_held_title_tier
					scope:recipient.current_military_strength < scope:actor.current_strength_seventy_five_percent_value
					scope:recipient = {
						has_dread_level_towards = {
							target = scope:actor
							level >= 1
						}
					}
				}
			}
		}
		show_as_unavailable = { always = yes }
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:recipient = { is_vassal_or_below_of = scope:actor }
					}
					desc = fp3_misc_decisions.0027.b.vassal.tt
				}
				triggered_desc = {
					trigger = { scope:recipient.highest_held_title_tier < scope:actor.highest_held_title_tier }
					desc = fp3_misc_decisions.0027.b.tier.tt
				}
				triggered_desc = {
					trigger = { scope:recipient.current_military_strength < scope:actor.current_strength_seventy_five_percent_value }
					desc = fp3_misc_decisions.0027.b.military.tt
				}
				desc = fp3_misc_decisions.0027.b.dread.tt
			}
		}
		duel = {
			skills = { martial }
			target = scope:recipient
			1 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.accept
				fp3_clan_challenge_negotiate_success_effect = { REASON = strength }
			}
			5 = {
				# Personality
				fp3_challenge_house_head_negotiation_bargain_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.bargain
				fp3_clan_challenge_negotiate_bargain_effect = { REASON = strength }
			}
			20 = {
				fp3_challenge_house_head_negotiation_reject_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 15
				desc = fp3_misc_decisions.0027.reject
				fp3_clan_challenge_negotiate_fail_effect = { REASON = strength }
			}
		}
		ai_chance = {
			base = 100
		}
	}

	# Skill, just more qualified
	option = {
		name = fp3_misc_decisions.0027.c
		trigger = {
			custom_tooltip = {
				text = fp3_misc_decisions.0027.c.trigger
				scope:actor.sum_of_all_skills_value >= scope:recipient.sum_of_all_skills_value
			}
		}
		show_as_unavailable = { always = yes }
		flavor = fp3_misc_decisions.0027.c.tt
		duel = {
			skills = { diplomacy martial stewardship intrigue learning }
			target = scope:recipient
			1 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.accept
				fp3_clan_challenge_negotiate_success_effect = { REASON = strength }
			}
			5 = {
				# Personality
				fp3_challenge_house_head_negotiation_bargain_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.bargain
				fp3_clan_challenge_negotiate_bargain_effect = { REASON = strength }
			}
			20 = {
				fp3_challenge_house_head_negotiation_reject_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 15
				desc = fp3_misc_decisions.0027.reject
				fp3_clan_challenge_negotiate_fail_effect = { REASON = strength }
			}
		}
		ai_chance = {
			base = 100
		}
	}

	# Fallback, pure charisma
	option = {
		name = fp3_misc_decisions.0027.d
		duel = {
			skills = { diplomacy intrigue }
			target = scope:recipient
			1 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.accept
				fp3_clan_challenge_negotiate_success_effect = { REASON = fallback }
			}
			5 = {
				fp3_challenge_house_head_negotiation_bargain_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				min = 2
				desc = fp3_misc_decisions.0027.bargain
				fp3_clan_challenge_negotiate_bargain_effect = { REASON = fallback }
			}
			20 = {
				fp3_challenge_house_head_negotiation_reject_modifier = yes
				compare_modifier = {
					value = scope:duel_value
					multiplier = -5
					min = -49
				}
				min = 15
				desc = fp3_misc_decisions.0027.reject
				fp3_clan_challenge_negotiate_fail_effect = { REASON = fallback }
			}
		}
		ai_chance = {
			base = 25
		}
	}

	after = {
		scope:recipient = {
			trigger_event = {
				id = fp3_misc_decisions.0028
				days = 1
			}
		}
	}
}

fp3_misc_decisions.0028 = { # Recipient response
	type = character_event
	title = fp3_misc_decisions.0022.t
	desc = {
		desc = fp3_misc_decisions.0028.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:recipient.house.house_head = scope:recipient }
				desc = fp3_misc_decisions.0028.desc.founder
			}
			desc = fp3_misc_decisions.0028.desc
		}
		first_valid = {
			# Age
			triggered_desc = { # Sick
				trigger = {
					scope:negotiate_reason = flag:age
					scope:recipient.health < fine_health
					scope:recipient.health < scope:actor.health
				}
				desc = fp3_misc_decisions.0028.sick
			}
			triggered_desc = { # Old
				trigger = {
					scope:negotiate_reason = flag:age
					scope:recipient.age > scope:recipient.age
				}
				desc = fp3_misc_decisions.0028.old
			}
			triggered_desc = { # Young
				trigger = { scope:negotiate_reason = flag:age }
				desc = fp3_misc_decisions.0028.young
			}
			# Strength
			triggered_desc = {
				trigger = {
					scope:negotiate_reason = flag:strength
					scope:recipient = { is_vassal_or_below_of = scope:actor }
				}
				desc = fp3_misc_decisions.0028.vassal
			}
			triggered_desc = {
				trigger = {
					scope:negotiate_reason = flag:strength
					scope:recipient.highest_held_title_tier < scope:actor.highest_held_title_tier
				}
				desc = fp3_misc_decisions.0028.tier
			}
			triggered_desc = {
				trigger = {
					scope:negotiate_reason = flag:strength
					scope:recipient.current_military_strength < scope:actor.current_strength_seventy_five_percent_value
				}
				desc = fp3_misc_decisions.0028.military
			}
			triggered_desc = {
				trigger = { scope:negotiate_reason = flag:strength }
				desc = fp3_misc_decisions.0028.dread
			}
			# Skill
			triggered_desc = {
				trigger = { scope:negotiate_reason = flag:skill }
				desc = fp3_misc_decisions.0028.skill
			}
			# Fallback
			triggered_desc = {
				trigger = { scope:negotiate_reason = flag:fallback }
				desc = fp3_misc_decisions.0028.fallback
			}
		}
	}
	theme = dynasty
	left_portrait = {
		character = scope:recipient
		animation = thinking
	}
	right_portrait = {
		character = scope:actor
		animation = admiration
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# Both parties alive and well
		scope:actor = {
			is_alive = yes
			is_imprisoned = no
		}
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	# Accept
	option = {
		name = fp3_misc_decisions.0028.a
		save_scope_as = negotiate_accept
		show_as_tooltip = {
			house = { set_house_head = scope:actor }
		}
		add_character_flag = {
			flag = accepted_house_head_challenge_flag
			years = 10
		}
		ai_chance = {
			base = 0
			modifier = {
				exists = scope:negotiate_success
				add = 100
			}
			modifier = {
				exists = scope:negotiate_fail
				factor = 0
			}
		}
	}

	# Bargain gold
	option = {
		name = fp3_misc_decisions.0028.c
		save_scope_as = negotiate_gold
		custom_tooltip = fp3_misc_decisions.0028.bargain.tt
		show_as_tooltip = {
			scope:actor = {
				pay_short_term_gold = {
					gold = scope:actor.medium_gold_value
					target = scope:recipient
				}
			}
			house = { set_house_head = scope:actor }
		}
		ai_chance = {
			base = 0
			modifier = {
				exists = scope:negotiate_bargain
				add = 100
			}
			modifier = {
				exists = scope:negotiate_fail
				factor = 0
			}
		}
	}

	# Bargain hook
	option = {
		name = fp3_misc_decisions.0028.d
		save_scope_as = negotiate_hook
		custom_tooltip = fp3_misc_decisions.0028.bargain.tt
		show_as_tooltip = {
			scope:recipient = {
				add_hook_no_toast = {
					target = scope:actor
					type = predecessor_loyalty_hook
				}
			}
			house = { set_house_head = scope:actor }
		}
		ai_chance = {
			base = 0
			modifier = {
				exists = scope:negotiate_bargain
				add = 100
			}
			modifier = {
				exists = scope:negotiate_fail
				factor = 0
			}
		}
	}

	# Reject
	option = {
		name = fp3_misc_decisions.0028.e
		reverse_add_opinion = {
			target = scope:actor
			modifier = annoyed_opinion
			opinion = -20
		}
		ai_chance = {
			base = 0
			modifier = {
				exists = scope:negotiate_fail
				add = 100
			}
		}
	}

	after = {
		scope:actor = {
			trigger_event = {
				id = fp3_misc_decisions.0029
				days = 1
			}
		}
	}
}

fp3_misc_decisions.0029 = { # Actor response
	type = character_event
	title = {
		desc = {
			first_valid = {
				triggered_desc = {
					trigger = {
						calc_true_if = {
							amount >= 1
							exists = scope:negotiate_gold
							exists = scope:negotiate_hook
						}
					}
					desc = fp3_misc_decisions.0022.t
				}
				desc = fp3_misc_decisions.0020.t
			}
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						is_governor = yes
						tgp_realm_has_ceremonial_liege_trigger = yes
					}
				}
				desc = fp3_misc_decisions.0029.desc.no_court
			}
			desc = fp3_misc_decisions.0029.desc
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:negotiate_accept }
				desc = fp3_misc_decisions.0029.accept
			}
			triggered_desc = {
				trigger = { exists = scope:negotiate_gold }
				desc = fp3_misc_decisions.0029.gold
			}
			triggered_desc = {
				trigger = { exists = scope:negotiate_hook }
				desc = fp3_misc_decisions.0029.hook
			}
			desc = fp3_misc_decisions.0029.fail
		}
	}
	theme = dynasty
	left_portrait = {
		character = scope:actor
		animation = war_over_loss
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:negotiate_gold
					exists = scope:negotiate_hook
				}
			}
			animation = war_over_tie
		}
		triggered_animation = {
			trigger = { exists = scope:negotiate_accept }
			animation = war_over_win
		}
		animation = war_over_loss
	}
	right_portrait = {
		character = scope:recipient
		animation = thinking
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# Both parties alive and well
		scope:actor = {
			is_alive = yes
			is_imprisoned = no
		}
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		if = {
			limit = {
				calc_true_if = {
					amount = 0
					exists = scope:negotiate_gold
					exists = scope:negotiate_hook
				}
			}
			play_music_cue = "mx_cue_negative"
		}
		else_if = {
			limit = { exists = scope:negotiate_accept }
			play_music_cue = "mx_cue_positive_effect"
		}
	}

	# Accepted
	option = {
		name = fp3_misc_decisions.0029.a
		trigger = { exists = scope:negotiate_accept }
		save_scope_as = negotiate_accept
		set_house_head_effect = {
			NEW_HEAD = scope:actor
			OLD_HEAD = scope:recipient
		}
	}

	# Accept bargain
	option = {
		name = fp3_misc_decisions.0029.b
		trigger = {
			calc_true_if = {
				amount >= 1
				exists = scope:negotiate_gold
				exists = scope:negotiate_hook
			}
		}
		show_as_tooltip = {
			switch = {
				trigger = exists
				scope:negotiate_gold = {
					scope:actor = {
						pay_short_term_gold = {
							gold = scope:recipient.medium_gold_value
							target = scope:recipient
						}
					}
				}
				scope:negotiate_hook = {
					scope:recipient = {
						add_hook_no_toast = {
							target = scope:actor
							type = predecessor_loyalty_hook
						}
					}
				}
			}
			house = { set_house_head = scope:actor }
		}
		save_scope_as = negotiate_bargain_accept
		scope:recipient = { trigger_event = fp3_misc_decisions.0030 }
		stress_impact = {
			greedy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
	}

	# Reject bargain
	option = {
		name = fp3_misc_decisions.0029.c
		trigger = {
			calc_true_if = {
				amount >= 1
				exists = scope:negotiate_gold
				exists = scope:negotiate_hook
			}
		}
		save_scope_as = negotiate_bargain_reject
		scope:recipient = { trigger_event = fp3_misc_decisions.0030 }
		stress_impact = {
			generous = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
	}

	# Reject
	option = {
		name = fp3_misc_decisions.0029.d
		trigger = {
			calc_true_if = {
				amount = 0
				exists = scope:negotiate_gold
				exists = scope:negotiate_hook
				exists = scope:negotiate_accept
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				exists = scope:negotiate_fail
				add = 100
			}
		}
	}
}

fp3_misc_decisions.0030 = { # Actor response
	type = character_event
	title = fp3_misc_decisions.0022.t
	desc = {
		desc = fp3_misc_decisions.0030.desc
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:negotiate_bargain_accept }
				desc = fp3_misc_decisions.0030.accept
			}
			desc = fp3_misc_decisions.0030.reject
		}
	}
	theme = dynasty
	left_portrait = {
		character = scope:recipient
		animation = war_over_win
	}
	right_portrait = {
		character = scope:actor
		animation = dismissal
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# Both parties alive and well
		scope:actor = {
			is_alive = yes
			is_imprisoned = no
		}
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		if = {
			limit = { exists = scope:negotiate_bargain_accept }
			switch = {
				trigger = exists
				scope:negotiate_gold = {
					scope:actor = {
						pay_short_term_gold = {
							gold = scope:recipient.medium_gold_value
							target = scope:recipient
						}
					}
				}
				scope:negotiate_hook = {
					scope:recipient = {
						add_hook_no_toast = {
							target = scope:actor
							type = predecessor_loyalty_hook
						}
					}
				}
			}
			set_house_head_effect = {
				NEW_HEAD = scope:actor
				OLD_HEAD = scope:recipient
			}
		}
	}

	# Accepted
	option = {
		name = fp3_misc_decisions.0030.a
		trigger = { exists = scope:negotiate_bargain_accept }
	}

	# Rejected
	option = {
		name = fp3_misc_decisions.0030.b
		trigger = { exists = scope:negotiate_bargain_reject }
	}
}

fp3_misc_decisions.0041 = { # Murder attempt outcome
	type = character_event
	title = fp3_misc_decisions.0020.t
	desc = {
		desc = fp3_misc_decisions.0041.intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:challenge_murder_success }
				desc = fp3_misc_decisions.0041.desc.success
			}
			desc = fp3_misc_decisions.0041.desc.failure
		}
	}
	theme = dynasty
	left_portrait = {
		character = scope:house_challenger
		animation = loss_1
		triggered_animation = {
			trigger = { exists = scope:challenge_murder_success }
			animation = assassin
		}
	}
	right_portrait = {
		character = scope:house_head
		animation = anger
		triggered_animation = {
			trigger = { exists = scope:challenge_murder_success }
			animation = fear
		}
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# Both parties alive and well
		scope:actor = {
			is_alive = yes
			is_imprisoned = no
		}
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		add_prestige = massive_prestige_loss
		add_prestige_level = -1
		if = {
			limit = { exists = scope:challenge_murder_success }
			set_house_head_effect = {
				NEW_HEAD = scope:house_challenger
				OLD_HEAD = scope:house_head
			}
			show_as_tooltip = {
				known_murder_effect = { VICTIM = scope:house_head MURDERER = scope:house_challenger EXPOSER = scope:house_challenger }
			}
			scope:house_head = { trigger_event = fp3_misc_decisions.0043 }
		}
		else = {
			scope:house_head = {
				show_as_tooltip = {
					if = {
						limit = {
							can_set_relation_rival_trigger = { CHARACTER = scope:house_challenger }
						}
						set_relation_rival = {
							target = scope:house_challenger
							reason = rival_tried_to_kill_me
						}
					}
				}
				if = {
					limit = { exists = scope:challenge_wound }
					show_as_tooltip = {
						increase_wounds_no_death_effect = { REASON = murder }
					}
				}
			}
			show_as_tooltip = {
				attempted_murder_opinion_effect = {
					VICTIM = scope:house_head
					MURDERER = scope:house_challenger
				}
			}
			show_as_tooltip = {
				scope:house_head = {
					imprison = {
						target = scope:house_challenger
						type = house_arrest
					}
				}
			}
			scope:house_head = { trigger_event = fp3_misc_decisions.0042 }
		}
	}

	# Yay
	option = {
		name = fp3_misc_decisions.0041.a
		trigger = { exists = scope:challenge_murder_success }
	}

	# Curses
	option = {
		name = fp3_misc_decisions.0041.b
		trigger = {
			NOT = { exists = scope:challenge_murder_success }
		}
	}
}

fp3_misc_decisions.0042 = { # Failed Murder ping
	type = character_event
	title = fp3_misc_decisions.0020.t
	desc = fp3_misc_decisions.0042.desc
	theme = dynasty
	left_portrait = {
		character = scope:house_head
		animation = anger
	}
	right_portrait = {
		character = scope:house_challenger
		animation = fear
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# Both parties alive and well
		scope:actor = {
			is_alive = yes
			is_imprisoned = no
		}
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		if = {
			limit = { exists = scope:challenge_wound }
			increase_wounds_no_death_effect = { REASON = murder }
		}
		show_as_tooltip = {
			scope:house_challenger = {
				add_prestige = massive_prestige_loss
				add_prestige_level = -1
			}
			attempted_murder_opinion_effect = {
				VICTIM = scope:house_head
				MURDERER = scope:house_challenger
			}
		}
		rightfully_imprison_character_effect = {
			TARGET = scope:house_challenger
			IMPRISONER = scope:house_head
		}
	}

	# Yay
	option = {
		name = fp3_misc_decisions.0042.a
		trigger = { exists = scope:challenge_murder_success }
	}
}

fp3_misc_decisions.0043 = { # Succesful Murder ping
	type = character_event
	title = fp3_misc_decisions.0020.t
	desc = fp3_misc_decisions.0043.desc
	theme = dynasty
	left_portrait = {
		character = scope:house_head
		animation = loss_1
	}
	right_portrait = {
		character = scope:house_challenger
		animation = assassin
	}
	override_background = { reference = throne_room }

	trigger = {
		# DLC check.
		has_fp3_dlc_trigger = yes
		# Both parties alive and well
		scope:actor = {
			is_alive = yes
			is_imprisoned = no
		}
		scope:recipient = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		show_as_tooltip = {
			scope:house_challenger = {
				add_prestige = massive_prestige_loss
				add_prestige_level = -1
			}
		}
		known_murder_effect = { VICTIM = scope:house_head MURDERER = scope:house_challenger EXPOSER = scope:house_challenger }
	}

	# Curses
	option = {
		name = fp3_misc_decisions.0043.a
	}
}

##################################################
# Favour Skilled Outsiders
# by Ewan Cowhig Croft
# 0031 - 0040
##################################################

scripted_trigger fp3_misc_decisions_0031_preferred_ethoses_trigger = {
	# Eloquent Captains
	trigger_if = {
		limit = { scope:outsider_diplomacy_martial = yes }
		# Cultures more likely to send people to this type of position.
		culture = {
			OR = {
				has_cultural_pillar = ethos_bellicose
				has_cultural_pillar = ethos_courtly
			}
		}
	}
	# Career Soldiers
	trigger_if = {
		limit = { scope:outsider_martial_prowess = yes }
		# Cultures more likely to send people to this type of position.
		culture = {
			OR = {
				has_cultural_pillar = ethos_bellicose
				has_cultural_pillar = ethos_stoic
			}
		}
	}
	# Fringe Nobility
	trigger_if = {
		limit = { scope:outsider_prowess_learning = yes }
		# Cultures more likely to send people to this type of position.
		culture = {
			OR = {
				has_cultural_pillar = ethos_stoic
				has_cultural_pillar = ethos_communal
			}
		}
	}
	# Dedicated Functionaries
	trigger_if = {
		limit = { scope:outsider_learning_intrigue = yes }
		# Cultures more likely to send people to this type of position.
		culture = {
			OR = {
				has_cultural_pillar = ethos_bureaucratic
				has_cultural_pillar = ethos_spiritual
			}
		}
	}
	# Cunning Officials
	trigger_if = {
		limit = { scope:outsider_intrigue_stewardship = yes }
		# Cultures more likely to send people to this type of position.
		culture = {
			OR = {
				has_cultural_pillar = ethos_courtly
				has_cultural_pillar = ethos_egalitarian
			}
		}
	}
	# Skilled Administrators
	trigger_if = {
		limit = { scope:outsider_stewardship_diplomacy = yes }
		# Cultures more likely to send people to this type of position.
		culture = {
			OR = {
				has_cultural_pillar = ethos_bureaucratic
				has_cultural_pillar = ethos_spiritual
			}
		}
	}
}

scripted_effect fp3_misc_decisions_0031_create_char_no_dynasty_effect = {
	create_character = {
		template = fp3_skilled_outsider_template
		location = scope:batch_$BATCH$_county.title_province
		dynasty = none
		culture = scope:batch_$BATCH$_county.culture
		faith = scope:batch_$BATCH$_county.faith
		after_creation = {
			add_to_list = batch_$BATCH$_characters_list
			# Set an employer if there's a valid one available.
			if = {
				limit = {
					scope:outsider_diplomacy_martial = yes
					root.cp:councillor_chancellor ?= {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_chancellor
			}
			else_if = {
				limit = {
					scope:outsider_martial_prowess = yes
					root.cp:councillor_steward ?= {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_steward
			}
			else_if = {
				limit = {
					scope:outsider_stewardship_diplomacy = yes
					root.cp:councillor_marshal ?= {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_marshal
			}
			else_if = {
				limit = {
					scope:outsider_intrigue_stewardship = yes
					root.cp:councillor_spymaster ?= {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_spymaster
			}
			else_if = {
				limit = {
					scope:outsider_learning_intrigue = yes
					root.cp:councillor_court_chaplain ?= {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_court_chaplain
			}
		}
	}
}

scripted_effect fp3_misc_decisions_0031_create_char_with_dynasty_effect = {
	create_character = {
		template = fp3_skilled_outsider_template
		location = scope:batch_$BATCH$_county.title_province
		culture = scope:batch_$BATCH$_county.culture
		faith = scope:batch_$BATCH$_county.faith
		after_creation = {
			add_to_list = batch_$BATCH$_characters_list
			# Set an employer if there's a valid one available.
			if = {
				limit = {
					scope:outsider_diplomacy_martial = yes
					root.cp:councillor_chancellor = {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_chancellor
			}
			else_if = {
				limit = {
					scope:outsider_martial_prowess = yes
					root.cp:councillor_steward = {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_steward
			}
			else_if = {
				limit = {
					scope:outsider_stewardship_diplomacy = yes
					root.cp:councillor_marshal = {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_marshal
			}
			else_if = {
				limit = {
					scope:outsider_intrigue_stewardship = yes
					root.cp:councillor_spymaster = {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_spymaster
			}
			else_if = {
				limit = {
					scope:outsider_learning_intrigue = yes
					root.cp:councillor_court_chaplain = {
						is_ruler = yes
						is_ai = yes
					}
				}
				set_employer = root.cp:councillor_court_chaplain
			}
		}
	}
}

scripted_effect fp3_misc_decisions_0031_pick_best_appropriate_char_effect = {
	ordered_in_list = {
		list = batch_$BATCH$_characters_list
		order_by = {
			if = {
				limit = { scope:outsider_diplomacy_martial = yes }
				add = diplomacy
			}
			if = {
				limit = { scope:outsider_martial_prowess = yes }
				add = martial
			}
			if = {
				limit = { scope:outsider_prowess_learning = yes }
				add = prowess
			}
			if = {
				limit = { scope:outsider_learning_intrigue = yes }
				add = learning
			}
			if = {
				limit = { scope:outsider_intrigue_stewardship = yes }
				add = intrigue
			}
			if = {
				limit = { scope:outsider_stewardship_diplomacy = yes }
				add = stewardship
			}
		}
		save_scope_as = batch_$BATCH$_char1
	}
}

scripted_effect fp3_misc_decisions_0031_apply_opinion_to_batch_effect = {
	every_in_list = {
		list = batch_$BATCH$_characters_list
		custom = fp3_misc_decisions.0031.tt.all_outsiders
		add_opinion = {
			target = root
			modifier = grateful_opinion
			opinion = 80
		}
		# Since we're giving you a loyalty hook, we don't bother to take up option space with separate options for requesting their conversion - if you want it, you can always make 'em.
		custom_tooltip = {
			text = fp3_misc_decisions.0031.tt.all_outsiders.you_gain_hook
			root = {
				add_hook = {
					type = loyalty_hook
					target = prev
				}
			}
		}
	}
}

#	Recruit skilled outsiders from the lower ranks of your administration.
fp3_misc_decisions.0031 = {
	type = character_event
	title = favour_skilled_outsiders_decision
	desc = {
		desc = fp3_misc_decisions.0031.desc.intro
		# How many cultures are we drawing from?
		first_valid = {
			# Are we taking all our guys from the same county?
			triggered_desc = {
				trigger = { scope:batch_a_county = scope:batch_b_county }
				desc = fp3_misc_decisions.0031.desc.cultures.single
			}
			# Otherwise, use the multi-county loc.
			desc = fp3_misc_decisions.0031.desc.cultures.fallback
		}
	}
	theme = realm
	left_portrait = {
		character = scope:batch_a_char1
		animation = ecstasy
	}
	right_portrait = {
		character = scope:batch_b_char1
		animation = personality_compassionate
	}
	lower_left_portrait = scope:batch_a_char2
	lower_center_portrait = scope:batch_a_char3
	lower_right_portrait = scope:batch_b_char2

	immediate = {
		# Finally, as we sorted ordered rankings out in the previous event, make sure that batch B is always higher quality.
		hidden_effect = {
			# Does scope:batch_b_char1 need elevating?
			scope:batch_b_char1 = {
				if = {
					limit = {
						scope:outsider_diplomacy_martial = yes
						diplomacy < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
					}
					add_diplomacy_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
						subtract = diplomacy
					}
				}
				if = {
					limit = {
						scope:outsider_martial_prowess = yes
						martial < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
					}
					add_martial_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
						subtract = martial
					}
				}
				if = {
					limit = {
						scope:outsider_prowess_learning = yes
						prowess < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
					}
					add_prowess_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
						subtract = prowess
					}
				}
				if = {
					limit = {
						scope:outsider_learning_intrigue = yes
						learning < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
					}
					add_learning_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
						subtract = learning
					}
				}
				if = {
					limit = {
						scope:outsider_intrigue_stewardship = yes
						intrigue < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
					}
					add_intrigue_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
						subtract = intrigue
					}
				}
				if = {
					limit = {
						scope:outsider_stewardship_diplomacy = yes
						stewardship < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
					}
					add_stewardship_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char1_value
						subtract = stewardship
					}
				}
			}
			# Does scope:batch_b_char2 need a lil boost also?
			scope:batch_b_char2 = {
				if = {
					limit = {
						scope:outsider_diplomacy_martial = yes
						diplomacy < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
					}
					add_diplomacy_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
						subtract = diplomacy
					}
				}
				if = {
					limit = {
						scope:outsider_martial_prowess = yes
						martial < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
					}
					add_martial_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
						subtract = martial
					}
				}
				if = {
					limit = {
						scope:outsider_prowess_learning = yes
						prowess < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
					}
					add_prowess_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
						subtract = prowess
					}
				}
				if = {
					limit = {
						scope:outsider_learning_intrigue = yes
						learning < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
					}
					add_learning_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
						subtract = learning
					}
				}
				if = {
					limit = {
						scope:outsider_intrigue_stewardship = yes
						intrigue < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
					}
					add_intrigue_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
						subtract = intrigue
					}
				}
				if = {
					limit = {
						scope:outsider_stewardship_diplomacy = yes
						stewardship < scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
					}
					add_stewardship_skill = {
						value = scope:batch_a_char1.fp3_skilled_outsider_minimum_main_skill_batch_b_char2_value
						subtract = stewardship
					}
				}
			}
			# If we have a player, force a second skill recalc so that they can accurately see what they're getting.
			if = {
				limit = {
					root = { is_ai = no }
				}
				scope:batch_b_char1 = { force_character_skill_recalculation = yes }
				scope:batch_b_char2 = { force_character_skill_recalculation = yes }
			}
		}
	}

	# Select batch A.
	option = {
		name = fp3_misc_decisions.0031.a

		# Gain the courtiers.
		## Added individually rather than through the same effect as opinion so you can easily see exactly who you get.
		add_courtier = scope:batch_a_char1
		add_courtier = scope:batch_a_char2
		add_courtier = scope:batch_a_char3
		fp3_misc_decisions_0031_apply_opinion_to_batch_effect = { BATCH = a }
		# Apply opinion maluses.
		scope:batch_a_char1 = { save_scope_as = outsider_select }
		favour_skilled_outsiders_decision_apply_opinions_effect = yes

		# No stress gain here.
		ai_chance = {
			base = 1
			# No AI value modifier - this is really just a pick you gut-feel as either a player or the AI.
			# Though the AI is more likely to pick cultures you get on with better.
			modifier = {
				add = 75
				culture = {
					cultural_acceptance = {
						target = scope:batch_a_char1.culture
						value >= 75
					}
				}
			}
			modifier = {
				add = 50
				culture = {
					cultural_acceptance = {
						target = scope:batch_a_char1.culture
						value >= 50
					}
				}
			}
			modifier = {
				add = 25
				culture = {
					cultural_acceptance = {
						target = scope:batch_a_char1.culture
						value >= 25
					}
				}
			}
		}
	}
	
	# Select batch B.
	option = {
		name = fp3_misc_decisions.0031.b

		# Gain the courtiers.
		## Added individually rather than through the same effect as opinion so you can easily see exactly who you get.
		add_courtier = scope:batch_b_char1
		add_courtier = scope:batch_b_char2
		fp3_misc_decisions_0031_apply_opinion_to_batch_effect = { BATCH = b }
		# Apply opinion maluses.
		scope:batch_b_char1 = { save_scope_as = outsider_select }
		favour_skilled_outsiders_decision_apply_opinions_effect = yes

		# No stress gain here.
		ai_chance = {
			base = 1
			# No AI value modifier - this is really just a pick you gut-feel as either a player or the AI.
			# Though the AI is more likely to pick cultures you get on with better.
			modifier = {
				add = 75
				culture = {
					cultural_acceptance = {
						target = scope:batch_b_char1.culture
						value >= 75
					}
				}
			}
			modifier = {
				add = 50
				culture = {
					cultural_acceptance = {
						target = scope:batch_b_char1.culture
						value >= 50
					}
				}
			}
			modifier = {
				add = 25
				culture = {
					cultural_acceptance = {
						target = scope:batch_b_char1.culture
						value >= 25
					}
				}
			}
		}
	}

	# Change your mind.
	option = {
		name = fp3_misc_decisions.0031.c
		trigger = { is_ai = no }

		# RIP.
		## Job interviews suck.
		custom_tooltip = fp3_misc_decisions.0031.c.tt
		# Your prestige is refunded.
		hidden_effect = { add_prestige_no_experience = scope:prestige_cost }
		# We leave the decision on cooldown, though — otherwise you could just cycle through it repeatedly till you get the best conceivable recruits.
		
		# No stress gain here.
		# No ai_chance; this is for the player to change their mind. If the AI gets this far, it should roll with it.
	}

	after = {
		# Remove the batch we didn't recruit.
		hidden_effect = {
			if = {
				limit = {
					NOT = { scope:batch_a_char1.liege ?= root }
				}
				every_in_list = {
					list = batch_a_characters_list
					silent_disappearance_effect = yes
				}
			}
			if = {
				limit = {
					NOT = { scope:batch_b_char1.liege ?= root }
				}
				every_in_list = {
					list = batch_b_characters_list
					silent_disappearance_effect = yes
				}
			}
		}
	}
}

# Laundering event to spawn the characters so that we can do some skill updating magic which'd otherwise error.
fp3_misc_decisions.0032 = {
	hidden = yes

	immediate = {
		# Alright, let's generate some characters!
		## First, we need to compile a list of valid cultures.
		### Sort our total possible candidates.
		every_sub_realm_county = {
			limit = { favour_skilled_outsiders_decision_valid_county_to_generate_trigger = yes }
			# So we nab every valid county.
			add_to_list = sub_realm_minority_cultures_county_pre_filter_list
			# And every valid _culture_: we're gonna need to use these as a limit against the above list in a sec.
			culture = { add_to_list = sub_realm_minority_cultures_tally_list }
		}
		### Grab the tally of how many possible cultures we need for the final list.
		#### This'll tell us how many times to iterate over the counties list total so that we end up with one county per valid culture instead of every county for every valid culture.
		save_scope_value_as = {
			name = while_count_value
			value = {
				every_in_list = {
					list = sub_realm_minority_cultures_tally_list
					add = 1
				}
			}
		}
		### Then we loop through and pick our finalists.
		#### Hide the effect, because the while loop's tally will show even if nothing in it is visible to the player.
		hidden_effect = {
			while = {
				count = scope:while_count_value
				# First, nab a random culture we haven't used yet from the list of cultures to account for.
				random_in_list = {
					list = sub_realm_minority_cultures_tally_list
					save_scope_as = current_culture
					# We remove from the list so that we don't roll this culture again - effectively marking it as used.
					remove_from_list = sub_realm_minority_cultures_tally_list
				}
				# Now, process through the complete list of counties to find the best possible fit that matches the valid culture.
				ordered_in_list = {
					list = sub_realm_minority_cultures_county_pre_filter_list
					limit = { culture = scope:current_culture }
					order_by = {
						value = development_level
						# Weight down for places that don't follow the same HoF.
						if = {
							limit = {
								exists = root.faith.religious_head
								faith.religious_head ?= root.faith.religious_head
							}
							add = {
								value = development_level
								multiply = -0.1
							}
						}
						# Weight down by root's hostility.
						## Righteous is perfect.
						## Astray, lose a little.
						if = {
							limit = {
								root.faith = {
									faith_hostility_level = {
										target = prev.faith
										value = faith_astray_level
									}
								}
							}
							add = {
								value = development_level
								multiply = -0.1
							}
						}
						## Hostile, lose a little more.
						if = {
							limit = {
								root.faith = {
									faith_hostility_level = {
										target = prev.faith
										value = faith_hostile_level
									}
								}
							}
							add = {
								value = development_level
								multiply = -0.25
							}
						}
						## Evil, lose a lottle more.
						if = {
							limit = {
								root.faith = {
									faith_hostility_level = {
										target = prev.faith
										value = faith_evil_level
									}
								}
							}
							add = {
								value = development_level
								multiply = -0.4
							}
						}
					}
					add_to_list = sub_realm_minority_cultures_final_counties_list
				}
			}
		}
		### For debug purposes: here so you can de-clog the tooltip if you need it to stop displaying _every_ valid county and just show you some selected appropriate scopes.
		if = {
			limit = { always = no }
			every_in_list = {
				list = sub_realm_minority_cultures_county_pre_filter_list
				remove_from_list = sub_realm_minority_cultures_county_pre_filter_list
			}
		}
		## Sweet, now let's try to pick two from the list.
		### 
		if = {
			limit = {
				list_size = {
					name = sub_realm_minority_cultures_final_counties_list
					value >= 2
				}
			}
			# Try to grab a culture for batch A that matches our needs.
			random_in_list = {
				list = sub_realm_minority_cultures_final_counties_list
				limit = { fp3_misc_decisions_0031_preferred_ethoses_trigger = yes }
				alternative_limit = { always = yes }
				weight = { fp3_misc_decisions_0031_preferred_cultrads_modifier = yes }
				save_scope_as = batch_a_county
			}
			# And try to grab one for batch B that does the same whilst not being batch A.
			random_in_list = {
				list = sub_realm_minority_cultures_final_counties_list
				limit = {
					fp3_misc_decisions_0031_preferred_ethoses_trigger = yes
					this != scope:batch_a_county
				}
				alternative_limit = {
					this != scope:batch_a_county
				}
				weight = { fp3_misc_decisions_0031_preferred_cultrads_modifier = yes }
				save_scope_as = batch_b_county
			}
		}
		### Otherwise, we've only got one item in the list, so just grab it twice.
		else = {
			random_in_list = {
				list = sub_realm_minority_cultures_final_counties_list
				save_scope_as = batch_a_county
			}
			scope:batch_a_county = { save_scope_as = batch_b_county }
		}
		## Right, now let's generate batch A.
		### Slightly different parameters if we're using the fallback option.
		if = {
			limit = { scope:outsider_prowess_learning = yes }
			fp3_misc_decisions_0031_create_char_with_dynasty_effect = { BATCH = a }
			fp3_misc_decisions_0031_create_char_with_dynasty_effect = { BATCH = a }
			fp3_misc_decisions_0031_create_char_with_dynasty_effect = { BATCH = a }
		}
		### Otherwise, they're not nobles in any capacity, so remove their dynasties.
		else = {
			fp3_misc_decisions_0031_create_char_no_dynasty_effect = { BATCH = a }
			fp3_misc_decisions_0031_create_char_no_dynasty_effect = { BATCH = a }
			fp3_misc_decisions_0031_create_char_no_dynasty_effect = { BATCH = a }
		}
		## Aaaaand batch B.
		### Slightly different parameters if we're using the fallback option.
		if = {
			limit = { scope:outsider_prowess_learning = yes }
			fp3_misc_decisions_0031_create_char_with_dynasty_effect = { BATCH = b }
			fp3_misc_decisions_0031_create_char_with_dynasty_effect = { BATCH = b }
		}
		### Otherwise, they're not nobles in any capacity, so remove their dynasties.
		else = {
			fp3_misc_decisions_0031_create_char_no_dynasty_effect = { BATCH = b }
			fp3_misc_decisions_0031_create_char_no_dynasty_effect = { BATCH = b }
		}
		### Plus go over batch B & upgrade their education traits by +2.
		every_in_list = {
			list = batch_b_characters_list
			hidden_effect = {
				# Which education track are they on?
				## Diplomacy
				if = {
					limit = { has_trait = education_diplomacy_1 }
					remove_trait = education_diplomacy_1
					add_trait = education_diplomacy_3
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				else_if = {
					limit = { has_trait = education_diplomacy_2 }
					remove_trait = education_diplomacy_2
					add_trait = education_diplomacy_4
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				## Martial
				if = {
					limit = { has_trait = education_martial_1 }
					remove_trait = education_martial_1
					add_trait = education_martial_3
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				else_if = {
					limit = { has_trait = education_martial_2 }
					remove_trait = education_martial_2
					add_trait = education_martial_4
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				## Stewardship
				if = {
					limit = { has_trait = education_stewardship_1 }
					remove_trait = education_stewardship_1
					add_trait = education_stewardship_3
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				else_if = {
					limit = { has_trait = education_stewardship_2 }
					remove_trait = education_stewardship_2
					add_trait = education_stewardship_4
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				## Intrigue
				if = {
					limit = { has_trait = education_intrigue_1 }
					remove_trait = education_intrigue_1
					add_trait = education_intrigue_3
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				else_if = {
					limit = { has_trait = education_intrigue_2 }
					remove_trait = education_intrigue_2
					add_trait = education_intrigue_4
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				## Learning
				if = {
					limit = { has_trait = education_learning_1 }
					remove_trait = education_learning_1
					add_trait = education_learning_3
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
				else_if = {
					limit = { has_trait = education_learning_2 }
					remove_trait = education_learning_2
					add_trait = education_learning_4
					# Force a skill recalc so that we can evaluate who's in the lead later.
					## Remember that only two of these'll ever be applied in total, so it's not too bad to be using them like this.
					force_character_skill_recalculation = yes
				}
			}
		}
		## Select our representatives.
		fp3_misc_decisions_0031_pick_best_appropriate_char_effect = { BATCH = a }
		fp3_misc_decisions_0031_pick_best_appropriate_char_effect = { BATCH = b }
		## And fill out our fodder.
		random_in_list ={
			list = batch_a_characters_list
			limit = {
				this != scope:batch_a_char1
			}
			save_scope_as = batch_a_char2
			# Plus we make the characters within each group get on, as they're sorta local allies.
			hidden_effect = { set_relation_friend = scope:batch_a_char1 }
		}
		random_in_list = {
			list = batch_a_characters_list
			limit = {
				NOR = {
					this = scope:batch_a_char1
					this = scope:batch_a_char2
				}
			}
			save_scope_as = batch_a_char3
			# Plus we make the characters within each group get on, as they're sorta local allies.
			hidden_effect = {
				set_relation_friend = scope:batch_a_char1
				set_relation_friend = scope:batch_a_char2
			}
		}
		random_in_list = {
			list = batch_b_characters_list
			limit = {
				this != scope:batch_b_char1
			}
			save_scope_as = batch_b_char2
			# Plus we make the characters within each group get on, as they're sorta local allies.
			hidden_effect = { set_relation_best_friend = scope:batch_b_char1 }
		}
		# Now fire the actual event!
		trigger_event = fp3_misc_decisions.0031
	}
}

##################################################
# Adopt Clan Government
# by Joe Parkin
# 0051-0060
##################################################

fp3_misc_decisions.0051 = { # Adopt Clan Government through House
	type = character_event
	title = fp3_misc_decisions.0051.t
	desc = fp3_misc_decisions.0051.desc
	theme = dynasty
	left_portrait = {
		character = root
		animation = personality_rational
	}
	lower_right_portrait = house.house_head

	immediate = {
		change_government = clan_government
		# Increase unity, uses this effect since both chars are not clan when script is evaluated
		house.house_head = {
			apply_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = root.house.house_head
				DESC = clan_unity_adopt_clan.desc
				VALUE = medium_unity_gain
				VALUE_REVERSED = no
			}
		}
		hidden_effect = {
			house.house_head = {
				send_interface_toast = {
					title = fp3_become_clan_government_decision_toast
					left_icon = root
					right_icon = house.house_head
					show_as_tooltip = {
						root = {
							# Change government type
							change_government = clan_government
							# Increase unity, uses this effect since both chars are not clan when script is evaluated
							house.house_head = {
								apply_clan_unity_interaction_effect = {
									CHARACTER = root
									TARGET = root.house.house_head
									DESC = clan_unity_adopt_clan.desc
									VALUE = medium_unity_gain
									VALUE_REVERSED = no
								}
							}
						}
					}
				}
			}
		}
	}

	option = {
		name = fp3_misc_decisions.0051.a
	}
}
