﻿agse_knight_with_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	num_of_relation_agot_squire > 0
}

agse_player_knight_with_squire_trigger = {
	is_ai = no
	is_playable_character = yes
	agse_knight_with_squire_trigger = yes
}

agse_ai_knight_with_squire_trigger = {
	is_ai = yes
	agse_knight_with_squire_trigger = yes
}

agse_ai_activity_can_fire_trigger = {
	OR = {
		is_ai = no
		AND = {
			is_ai = yes
			exists = scope:activity
			scope:activity = {
				NOT = { any_attending_character = { is_ai = no } }
			}
		}
	}
}

agse_squire_can_join_entourage_trigger = {
	is_alive = yes
	is_imprisoned = no
	is_available = yes
	is_commanding_army = no
	NOT = { exists = involved_activity }
	NOT = { exists = current_travel_plan }
	is_travel_entourage_character = no
}

agse_valid_travel_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	is_available_travelling = yes
	has_relation_agot_knight = root
	is_travel_entourage_character = yes
}

agse_valid_home_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	is_available = yes
	has_relation_agot_knight = root
	OR = {
		is_courtier_of = root
		location = root.location
	}
}

agse_kingsguard_aspiration_squire_trigger = {
	is_alive = yes
	is_adult = no
	age >= 10
	age < 16
	is_available = yes
	is_ruler = no
	valid_kingsguard_gender_trigger = yes
	has_trait = ambitious
	prowess >= 7
	is_married = no
	NOT = { exists = betrothed }
	has_been_promised_grand_wedding = no
	NOT = { has_character_flag = kingsguard_ambition }
	NOT = { has_character_modifier = training_for_kingsguard }
	NOT = { has_trait = refusing_marriage }
	NOR = {
		has_trait = maester
		has_trait = septon
		has_trait = nightswatch
		has_trait = devoted
		has_trait = order_member
		has_trait = clubfooted
		has_trait = physique_bad_3
		has_trait = crippled
	}
	NOT = {
		any_heir_title = {
			place_in_line_of_succession = {
				target = prev
				value == 1
			}
		}
	}
	exists = top_liege
	top_liege = { ruler_has_kingsguard_trigger = yes }
}

agse_valid_campaign_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	is_available = yes
	is_commanding_army = no
	NOT = { exists = involved_activity }
	NOT = { exists = current_travel_plan }
	has_relation_agot_knight = root
}

agse_valid_army_campaign_squire_trigger = {
	agse_valid_campaign_squire_trigger = yes
	NOT = { has_character_flag = agse_squire_campaign_event_cooldown }
}

agse_valid_tournament_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	has_relation_agot_knight = root
	location = root.location
	trigger_if = {
		limit = { exists = scope:activity }
		OR = {
			NOT = { exists = involved_activity }
			involved_activity = scope:activity
		}
	}
}

agse_valid_feast_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	has_relation_agot_knight = root
	location = root.location
	trigger_if = {
		limit = { exists = scope:activity }
		OR = {
			NOT = { exists = involved_activity }
			involved_activity = scope:activity
		}
	}
}

agse_valid_hunt_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	has_relation_agot_knight = root
	location = root.location
	trigger_if = {
		limit = { exists = scope:activity }
		OR = {
			NOT = { exists = involved_activity }
			involved_activity = scope:activity
		}
	}
}

agse_valid_funeral_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	has_relation_agot_knight = root
	location = root.location
	trigger_if = {
		limit = { exists = scope:activity }
		OR = {
			NOT = { exists = involved_activity }
			involved_activity = scope:activity
		}
	}
}

agse_valid_siege_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	is_available = yes
	is_commanding_army = no
	NOT = { exists = involved_activity }
	NOT = { exists = current_travel_plan }
	has_relation_agot_knight = root
}

agse_player_is_active_tournament_competitor_trigger = {
	activity_is_competing_trigger = yes
	exists = scope:activity
	scope:activity = {
		has_activity_type = activity_tournament
		OR = {
			has_current_phase = tournament_phase_melee
			has_current_phase = tournament_phase_archery
			has_current_phase = tournament_phase_horse_race
			has_current_phase = tournament_phase_joust
			has_current_phase = tournament_phase_wrestling
			has_current_phase = tournament_phase_duel
		}
		any_guest_subset_current_phase = {
			name = qualified
			this = root
		}
	}
}

agse_player_is_registered_tournament_competitor_trigger = {
	activity_is_valid_tournament_contestant = yes
	is_in_guest_subset = { name = contestant }
	exists = scope:activity
	scope:activity = {
		has_activity_type = activity_tournament
		OR = {
			has_current_phase = tournament_phase_melee
			has_current_phase = tournament_phase_archery
			has_current_phase = tournament_phase_horse_race
			has_current_phase = tournament_phase_joust
			has_current_phase = tournament_phase_wrestling
			has_current_phase = tournament_phase_duel
		}
	}
}

agse_player_is_mounted_tournament_competitor_trigger = {
	agse_player_is_registered_tournament_competitor_trigger = yes
	scope:activity = {
		OR = {
			has_current_phase = tournament_phase_horse_race
			has_current_phase = tournament_phase_joust
		}
	}
}

agse_valid_rival_tournament_squire_trigger = {
	is_alive = yes
	is_imprisoned = no
	location = root.location
	NOT = { has_relation_agot_knight = root }
	num_of_relation_agot_knight > 0
	trigger_if = {
		limit = { exists = scope:activity }
		involved_activity = scope:activity
		any_relation = {
			type = agot_knight
			is_alive = yes
			involved_activity = scope:activity
		}
	}
}

agse_player_lost_recorded_tournament_contest_trigger = {
	OR = {
		AND = {
			var:agse_squire_tournament_contest = flag:melee
			NOT = { scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_melee this = root } } }
		}
		AND = {
			var:agse_squire_tournament_contest = flag:archery
			NOT = { scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_archery this = root } } }
		}
		AND = {
			var:agse_squire_tournament_contest = flag:horse_race
			NOT = { scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_horse_race this = root } } }
		}
		AND = {
			var:agse_squire_tournament_contest = flag:joust
			NOT = { scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_joust this = root } } }
		}
		AND = {
			var:agse_squire_tournament_contest = flag:wrestling
			NOT = { scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_wrestling this = root } } }
		}
		AND = {
			var:agse_squire_tournament_contest = flag:duel
			NOT = { scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_duel this = root } } }
		}
	}
}

agse_player_won_recorded_tournament_wager_trigger = {
	OR = {
		AND = {
			var:agse_squire_tournament_wager_contest = flag:melee
			scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_melee this = root } }
		}
		AND = {
			var:agse_squire_tournament_wager_contest = flag:archery
			scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_archery this = root } }
		}
		AND = {
			var:agse_squire_tournament_wager_contest = flag:horse_race
			scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_horse_race this = root } }
		}
		AND = {
			var:agse_squire_tournament_wager_contest = flag:joust
			scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_joust this = root } }
		}
		AND = {
			var:agse_squire_tournament_wager_contest = flag:wrestling
			scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_wrestling this = root } }
		}
		AND = {
			var:agse_squire_tournament_wager_contest = flag:duel
			scope:activity = { any_guest_subset = { name = winner phase = tournament_phase_duel this = root } }
		}
	}
}

agse_squire_has_opposite_personality_trait_trigger = {
	OR = {
		AND = { flag:$TRAIT$ = flag:lustful has_trait = chaste }
		AND = { flag:$TRAIT$ = flag:chaste has_trait = lustful }
		AND = { flag:$TRAIT$ = flag:gluttonous has_trait = temperate }
		AND = { flag:$TRAIT$ = flag:temperate has_trait = gluttonous }
		AND = { flag:$TRAIT$ = flag:greedy has_trait = generous }
		AND = { flag:$TRAIT$ = flag:generous has_trait = greedy }
		AND = { flag:$TRAIT$ = flag:lazy has_trait = diligent }
		AND = { flag:$TRAIT$ = flag:diligent has_trait = lazy }
		AND = { flag:$TRAIT$ = flag:wrathful has_trait = calm }
		AND = { flag:$TRAIT$ = flag:calm has_trait = wrathful }
		AND = { flag:$TRAIT$ = flag:patient has_trait = impatient }
		AND = { flag:$TRAIT$ = flag:impatient has_trait = patient }
		AND = { flag:$TRAIT$ = flag:arrogant has_trait = humble }
		AND = { flag:$TRAIT$ = flag:humble has_trait = arrogant }
		AND = { flag:$TRAIT$ = flag:deceitful has_trait = honest }
		AND = { flag:$TRAIT$ = flag:honest has_trait = deceitful }
		AND = { flag:$TRAIT$ = flag:craven has_trait = brave }
		AND = { flag:$TRAIT$ = flag:brave has_trait = craven }
		AND = { flag:$TRAIT$ = flag:shy has_trait = gregarious }
		AND = { flag:$TRAIT$ = flag:gregarious has_trait = shy }
		AND = { flag:$TRAIT$ = flag:ambitious has_trait = content }
		AND = { flag:$TRAIT$ = flag:content has_trait = ambitious }
		AND = { flag:$TRAIT$ = flag:arbitrary has_trait = just }
		AND = { flag:$TRAIT$ = flag:just has_trait = arbitrary }
		AND = { flag:$TRAIT$ = flag:cynical has_trait = zealous }
		AND = { flag:$TRAIT$ = flag:zealous has_trait = cynical }
		AND = { flag:$TRAIT$ = flag:paranoid has_trait = trusting }
		AND = { flag:$TRAIT$ = flag:trusting has_trait = paranoid }
		AND = {
			flag:$TRAIT$ = flag:compassionate
			OR = {
				has_trait = callous
				has_trait = sadistic
			}
		}
		AND = { flag:$TRAIT$ = flag:callous has_trait = compassionate }
		AND = { flag:$TRAIT$ = flag:sadistic has_trait = compassionate }
		AND = { flag:$TRAIT$ = flag:stubborn has_trait = fickle }
		AND = { flag:$TRAIT$ = flag:fickle has_trait = stubborn }
		AND = { flag:$TRAIT$ = flag:vengeful has_trait = forgiving }
		AND = { flag:$TRAIT$ = flag:forgiving has_trait = vengeful }
	}
}
