﻿# Triggers related to knights and accolades

ep2_can_be_accolade_successor_base_trigger = {
	is_acclaimed = no
	prowess >= 8
	is_available_quick = {
		alive = yes
		adult = yes
	}
	highest_held_title_tier <= tier_barony
	NOT = {
		any_heir_title = {
			exists = holder
			tier >= tier_county
		}
	}
}

valid_squire_for_accolade_trigger = {
	save_temporary_scope_as = squire_temp
	is_courtier_of = $KNIGHT$.accolade.accolade_owner
	exists = liege
	$KNIGHT$.liege ?= liege
	age >= 10
	age <= 20
	#If in an accolade's squire pool...
	trigger_if = {
		limit = {
			$KNIGHT$.accolade.accolade_owner = {
				any_accolade = {
					has_variable_list = accolade_squire_chars
					any_in_list = {
						variable = accolade_squire_chars
						this = scope:squire_temp
					}
				}
			}
		}
		#...must be this accolade's squire pool
		$KNIGHT$.accolade = {
			has_variable_list = accolade_squire_chars
			any_in_list = {
				variable = accolade_squire_chars
				this = scope:squire_temp
			}
		}
	}
	NOR = {
		#Already has bonus commensurate with level
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					accolade_squires_quality_value < accolade_squires_capable_minimum_value
				}
			}
			has_variable = acclaimed_sq_inexperienced
		}
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					accolade_squires_quality_value < accolade_squires_accomplished_minimum_value
				}
			}
			has_variable = acclaimed_sq_capable
		}
		#Accomplished-tier training
		has_variable = acclaimed_sq_maxed
		
		#Don't want to make it impossible to be trained by guardian
		any_relation = {
			type = guardian
			is_acclaimed = yes
			NOT = {
				this = $KNIGHT$
			}
		}
	}
	#Must be knight's ward if player, implying that you intentionally signed up to be trained by them
	OR = {
		is_ai = yes
		has_relation_guardian = $KNIGHT$
	}
	OR = {
		NOT = {
			any_heir_title = {
				exists = holder
				tier >= tier_county
			}
		}
		has_relation_guardian = $KNIGHT$
	}
	OR = {
		can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = liege }
		#Player can ignore gender triggers
		is_ai = no
		AND = {
			any_close_family_member = {
				is_ai = no
			}
			has_relation_guardian = $KNIGHT$
		}
	}
	is_imprisoned = no
	is_incapable = no
	NOR = {
		has_trait = infirm
		has_trait = physique_bad_3
		has_trait = blind
		has_trait = maimed
	}
	NOT = {
		this = $KNIGHT$
	}
	#fanatic accolade requires same faith
	trigger_if = {
		limit = {
			$KNIGHT$.accolade = {
				has_accolade_type = fanatic_attribute 
			}
		}
		faith = $KNIGHT$.accolade.accolade_owner.faith
	}
	#Limit random unrelated children who can be pulled in as squires
	trigger_if = {
		limit = {
			NOR = {
				has_relation_guardian = $KNIGHT$
				is_close_family_of = $KNIGHT$
			}
		}
		#Consider blocking personality trait accolades picking up kids with wrong personality/childhood traits
		#revels accolade can't get temperate kid
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					has_accolade_type = master_of_revels_attribute
				}
			}
			NOR = {
				has_trait = temperate
				has_trait = shy
			}
		}
		#charmer accolade can't get chaste kid
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					has_accolade_type = charmer_attribute
				}
			}
			NOR = {
				has_trait = chaste
				has_trait = celibate
				has_sexuality = asexual
			}
		}
		#skill type accolade should only get skill-educated kids
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					has_accolade_type = politicker_attribute
				}
			}
			OR = {
				has_focus = education_diplomacy
				has_trait = education_diplomacy
				has_lifestyle = diplomacy_lifestyle
				diplomacy > average_skill_rating
			}
		}
		#skill type accolade should only get skill-educated kids
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					has_accolade_type = reeve_attribute
				}
			}
			OR = {
				has_focus = education_stewardship
				has_trait = education_stewardship
				has_lifestyle = stewardship_lifestyle
				stewardship > average_skill_rating
			}
		}
		#skill type accolade should only get skill-educated kids
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					has_accolade_type = manipulator_attribute
				}
			}
			OR = {
				has_focus = education_intrigue
				has_trait = education_intrigue
				has_lifestyle = intrigue_lifestyle
				intrigue > average_skill_rating
			}
		}
		#skill type accolade should only get skill-educated kids
		trigger_if = {
			limit = {
				$KNIGHT$.accolade = {
					has_accolade_type = mentor_attribute
				}
			}
			OR = {
				has_focus = education_learning
				has_trait = education_learning
				has_lifestyle = learning_lifestyle
				learning > average_skill_rating
			}
		}
	}
}

