﻿namespace = cpa
cpa.1 = {
	#Bunch of triggers checking if position require filling and firing events
	hidden = yes
	trigger = {
		is_ai = no
		is_landed_or_landless_administrative = yes
	}
	immediate = {
		# #Court Physician
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = court_physician_court_position
		# 		has_global_variable = court_physician_auto
		# 	}
		# 	trigger_event = cpa_physician.1
		# }
		# #Chief Eunuch
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = chief_eunuch_court_position
		# 		has_global_variable = chief_eunuch_auto
		# 	}
		# 	trigger_event = cpa_eunuch.1
		# }
		# #Keeper of Swans
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = keeper_of_swans_court_position
		# 		has_global_variable = keeper_of_swans_auto
		# 	}
		# 	trigger_event = cpa_keeper_of_swans.1
		# }
		# #Master of Horse
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = master_of_horse_court_position
		# 		has_global_variable = master_of_horse_auto
		# 	}
		# 	trigger_event = cpa_master_of_horse.1
		# }
		# #Court Jester
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = court_jester_court_position
		# 		has_global_variable = court_jester_auto
		# 	}
		# 	trigger_event = cpa_court_jester.1
		# }
		# #Master of Hunt
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = master_of_hunt_court_position
		# 		has_global_variable = master_of_hunt_auto
		# 	}
		# 	trigger_event = cpa_master_of_hunt.1
		# }
		# #High Almoner
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = high_almoner_court_position
		# 		has_global_variable = high_almoner_auto
		# 	}
		# 	trigger_event = cpa_high_almoner.1
		# }
		# #Cup-Bearer
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = cupbearer_court_position
		# 		has_global_variable = cupbearer_auto
		# 	}
		# 	trigger_event = cpa_cupbearer.1
		# }
		# #Seneschal
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = seneschal_court_position
		# 		has_global_variable = seneschal_auto
		# 	}
		# 	trigger_event = cpa_seneschal.1
		# }
		# #Antiquarian
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = antiquarian_court_position
		# 		has_global_variable = antiquarian_auto
		# 	}
		# 	trigger_event = cpa_antiquarian.1
			
		# }
		# #Court Tutor
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = court_tutor_court_position
		# 		has_global_variable = court_tutor_auto
		# 	}
		# 	trigger_event = cpa_court_tutor.1
			
		# }
		# #Royal Architect
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = royal_architect_court_position
		# 		has_global_variable = royal_architect_auto
		# 	}
		# 	trigger_event = cpa_royal_architect.1
			
		# }
		# #Court Poet
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = court_poet_court_position
		# 		has_global_variable = court_poet_auto
		# 	}
		# 	trigger_event = cpa_court_poet.1
			
		# }
		# #Bodyguard (who fights like a crow)
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = bodyguard_court_position
		# 		has_global_variable = bodyguard_auto
		# 	}
		# 	trigger_event = cpa_bodyguard.1
			
		# }
		# #Personal Champion
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = champion_court_position
		# 		has_global_variable = champion_auto
		# 	}
		# 	trigger_event = cpa_champion.1
			
		# }
		# #Court Musician
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = court_musician_court_position
		# 		has_global_variable = court_musician_auto
		# 	}
		# 	trigger_event = cpa_court_musician.1
			
		# }
		# #Food Taster
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = food_taster_court_position
		# 		has_global_variable = food_taster_auto
		# 	}
		# 	trigger_event = cpa_food_taster.1
			
		# }
		# #Lady-in-waiting
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = lady_in_waiting_court_position
		# 		has_global_variable = lady_in_waiting_auto
		# 	}
		# 	trigger_event = cpa_lady_in_waiting.1
			
		# }
		# #Executioner
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = executioner_court_position
		# 		has_global_variable = executioner_auto
		# 	}
		# 	trigger_event = cpa_executioner.1
			
		# }
		# #Garuda
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = garuda_court_position
		# 		has_global_variable = garuda_auto
		# 	}
		# 	trigger_event = cpa_garuda.1
			
		# }
		# #Court Gardener
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = court_gardener_court_position
		# 		has_global_variable = court_gardener_auto
		# 	}
		# 	trigger_event = cpa_court_gardener.1
			
		# }
		# #Travel Leader
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = travel_leader_court_position
		# 		has_global_variable = travel_leader_auto
		# 	}
		# 	trigger_event = cpa_travel_leader.1
			
		# }
		# #Chief Qadi
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = chief_qadi_court_position
		# 		has_global_variable = chief_qadi_auto
		# 	}
		# 	trigger_event = cpa_chief_qadi.1
			
		# }
		# #Cultural Emissary
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = cultural_emissary_court_position
		# 		has_global_variable = cultural_emissary_auto
		# 	}
		# 	trigger_event = cpa_cultural_emissary.1
			
		# }
		# #Wet Nurse
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = wet_nurse_court_position
		# 		has_global_variable = wet_nurse_auto
		# 	}
		# 	trigger_event = cpa_wet_nurse.1
			
		# }
		# #Court Artificer
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = court_artificer_court_position
		# 		has_global_variable = court_artificer_auto
		# 	}
		# 	trigger_event = cpa_court_artificer.1
		# }
		# #Court Cave Hermit
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = court_cave_hermit_position
		# 		has_global_variable = court_cave_hermit_auto
		# 	}
		# 	trigger_event = cpa_court_cave_hermit.1
			
		# }
		# #Master Assassin
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = master_assassin_court_position
		# 		has_global_variable = master_assassin_auto
		# 	}
		# 	trigger_event = cpa_master_assassin.1
			
		# }
		# #Court Scholar
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = court_scholar_court_position
		# 		has_global_variable = court_scholar_auto
		# 	}
		# 	trigger_event = cpa_court_scholar.1
			
		# }
		# #Chronicler
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = chronicler_court_position
		# 		has_global_variable = chronicler_auto
		# 	}
		# 	trigger_event = cpa_chronicler.1
			
		# }
		# #Goldcloaks
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = goldcloaks_court_position
		# 		has_global_variable = goldcloaks_auto
		# 	}
		# 	trigger_event = cpa_goldcloaks.1
			
		# }
		# #Maester
		# if = {
		# 	limit = {
				
		# 		can_employ_court_position_type = maester_court_position
		# 		has_global_variable = maester_auto
		# 	}
		# 	trigger_event = cpa_maester.1
			
		# }
		# #Household Guard
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = household_guard_court_position
		# 		has_global_variable = household_guard_auto
		# 	}
		# 	trigger_event = cpa_household_guard.1
		# }
		# #Septon
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = septon_court_position
		# 		has_global_variable = septon_auto
		# 	}
		# 	trigger_event = cpa_septon.1
		# }
		# #Septa
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = septa_court_position
		# 		has_global_variable = septa_auto
		# 	}
		# 	trigger_event = cpa_septa.1
		# }
		# #Gaoler - Keeper of Cells
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = gaoler_court_position
		# 		has_global_variable = gaoler_auto
		# 	}
		# 	trigger_event = cpa_gaoler.1
		# }
		# #Harbormaster
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = harbormaster_court_position
		# 		has_global_variable = harbormaster_auto
		# 	}
		# 	trigger_event = cpa_harbormaster.1
		# }
		# #warden_of_the_north
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = warden_of_the_north_court_position
		# 		has_global_variable = warden_of_the_north_auto
		# 	}
		# 	trigger_event = cpa_warden.1
		# }
		# #warden_of_the_east
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = warden_of_the_east_court_position
		# 		has_global_variable = warden_of_the_east_auto
		# 	}
		# 	trigger_event = cpa_warden.2
		# }
		# #warden_of_the_west
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = warden_of_the_west_court_position
		# 		has_global_variable = warden_of_the_west_auto
		# 	}
		# 	trigger_event = cpa_warden.3
		# }
		# #warden_of_the_south
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = warden_of_the_south_court_position
		# 		has_global_variable = warden_of_the_south_auto
		# 	}
		# 	trigger_event = cpa_warden.4
		# }
		# #Master at Arms
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = master_at_arms_court_position
		# 		has_global_variable = master_at_arms_auto
		# 	}
		# 	trigger_event = cpa_master_at_arms.1
		# }
		# #Court Smith
		# if = {
		# 	limit = {
		# 		can_employ_court_position_type = court_smith_court_position
		# 		has_global_variable = court_smith_auto
		# 	}
		# 	trigger_event = cpa_court_smith.1
		# }
		#Knights
		ordered_knight = {
			order_by = prowess
			limit = {
				prowess < 12
				is_in_army = no
				is_acclaimed = no
				NOT = {
					has_variable = marshal_task_0304_forced_knighthood #Nepo-knight given by the vassal (forced by default, opinion penalty if removed)
					has_trait = dragonrider #Look at those Strong dragons!
				}
			}
			save_scope_as = weak_knight
		}
		if = {
			limit = {
				NOT = {
					has_global_variable = knight_auto_disabled
				}
				OR = {
					max_number_of_knights > root.number_of_knights
					exists = scope:weak_knight
				}
			}
			trigger_event = cpa_knights.1
		}
	}
}
