﻿
# Have a look at _court_positions.info for documentation

# COURT POSITIONS
# court_physician_court_position
# cultural_emissary_court_position
# keeper_of_swans_court_position
# chief_qadi_court_position
# garuda_court_position
# court_gardener_court_position
# lady_in_waiting_court_position
# antiquarian_court_position
# travel_leader_court_position
# wet_nurse_court_position
# court_tutor_court_position
# food_taster_court_position
# master_of_horse_court_position
# master_of_hunt_court_position
# royal_architect_court_position
# high_almoner_court_position
# seneschal_court_position
# cupbearer_court_position
# chief_eunuch_court_position
# court_jester_court_position
# court_poet_court_position
# court_musician_court_position
# bodyguard_court_position
# champion_court_position
# executioner_court_position
# court_artificer_court_position
# master_assassin_court_position
# cave_hermit_court_position
# chronicler_court_position
# court_scholar_court_position
# charioteer_court_position
# bookmaker_court_position
# akolouthos_court_position
# court_astrologer_court_position

### Important Court Positions ### ( Sort order 399 - 300 )
court_physician_court_position = {
	sort_order = 399
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		trigger = {
			OR = {
				government_has_flag = government_is_tribal
				government_has_flag = government_is_nomadic
			}
		}
		animation = physician
		background = "gfx/interface/illustrations/event_scenes/fp4_physician_tribal.dds"
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = physician
		background = "gfx/interface/illustrations/event_scenes/tgp_physician_asia.dds"
		localization_key = court_physician_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = physician
		background = "gfx/interface/illustrations/event_scenes/tgp_physician_asia.dds"
		localization_key = court_physician_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		 exists = culture
	# 		 culture_has_east_asian_heritage_pillar_trigger = yes
	# 	}
	# 	animation = physician
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_physician_asia.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		exists = culture
	# 		culture_has_mena_heritage_pillar_trigger = yes
	# 	}
	# 	animation = physician
	# 	background = "gfx/interface/illustrations/event_scenes/fp4_study_physician_mena.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		exists = culture
	# 		culture_has_south_asian_heritage_pillar_trigger = yes
	# 	}
	# 	animation = physician
	# 	background = "gfx/interface/illustrations/event_scenes/fp4_study_physician_indian.dds"
	# }

	court_position_asset = {
		animation = physician
		background = "gfx/interface/illustrations/event_scenes/study_physician.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = soon_forgiven_perk
				}
			}
			add = {
				value = 10
				desc = court_position_soon_forgiven_perk
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = friend }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_friend
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = lover }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_lover
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				is_married = yes
			}
			add = {
				value = 10
				desc = court_position_positions_of_power_perk_marriage
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = likable_perk
					has_relation_best_friend = prev
				}
			}
			add = {
				value = 30
				desc = court_position_best_friend
			}
		}
		else_if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = likable_perk
					has_relation_friend = prev
				}
			}
			add = {
				value = 15
				desc = court_position_friend
			}
		}
		add = court_position_aptitude_boon_voyager_trait
		# Skill
		add = {
			value = learning
			multiply = 1.75
			max = 50
			desc = court_position_skill_learning
		}
		# Physician
		if = {
			limit = { has_trait = lifestyle_physician }
			add = {
				value = 15
				if = {
					limit = {
						has_trait_xp = { trait = lifestyle_physician value >= 50 }
					}
					add = 15
				}
				if = {
					limit = {
						has_trait_xp = { trait = lifestyle_physician value >= 100 }
					}
					add = 15
				}
				desc = court_position_physician_1_trait
			}
		}
		# Mystic
		if = {
			limit = { has_trait = lifestyle_mystic }
			add = {
				value = 5
				if = {
					limit = {
						has_trait_xp = { trait = lifestyle_mystic value >= 50 }
					}
					add = 5
				}
				if = {
					limit = {
						has_trait_xp = { trait = lifestyle_mystic value >= 100 }
					}
					add = 5
				}
				desc = court_position_mystic_1_trait
			}
		}
		# Herbalist
		if = {
			limit = { has_trait = lifestyle_herbalist }
			add = {
				value = 15
				desc = court_position_herbalist_trait
			}
		}
		if = {
			limit = { employer.domicile ?= { has_domicile_building_or_higher = japanese_medicine_house_01 } }
			add = {
				value = 0
				if = {
					limit = { employer.domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude_6 } }
					add = estate_increase_gardener_aptitude_value_6
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude_5 } }
					add = estate_increase_gardener_aptitude_value_5
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude_4 } }
					add = estate_increase_gardener_aptitude_value_4
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude_3 } }
					add = estate_increase_gardener_aptitude_value_3
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude_2 } }
					add = estate_increase_gardener_aptitude_value_2
				}
				else = { add = estate_increase_gardener_aptitude_value_1 }
				desc = estate_physician_building
			}
		}
		# Nomad Yurt
		if = {
			limit = {
				employer.domicile ?= {
					has_domicile_building_or_higher = physician_yurt_01
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_physician_aptitude_lvl_4
						}
					}
					add = 32
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_physician_aptitude_lvl_3
						}
					}
					add = 16
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_physician_aptitude_lvl_2
						}
					}
					add = 8
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_physician_aptitude_lvl_1
						}
					}
					add = 4
				}
				desc = physician_yurt_01_domicile_building
			}
		}
		# Education
		if = {
			limit = { has_trait = education_learning }
			add = {
				value = 4
				if = {
					limit = { has_trait = education_learning_2 }
					add = 4
				}
				else_if = {
					limit = { has_trait = education_learning_3 }
					add = 8
				}
				else_if = {
					limit = { has_trait = education_learning_4 }
					add = 12
				}
				else_if = {
					limit = { has_trait = education_learning_5 }
					add = 22
				}
				desc = education_learning
			}
		}
		if = {
			limit = {
				has_trait = blind
			}
			add = {
				value = -50
				desc = court_position_blind_trait
			}
		}
		if = {
			limit = {
				any_character_artifact = {
					has_artifact_modifier = artifact_physician_aptitude_1_modifier
				}
			}
			add = 20
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Camp
		if = {
			limit = {
				employer.domicile ?= { has_domicile_parameter = camp_improved_court_physician_aptitude }
			}
			add = {
				value = camp_improved_court_physician_aptitude_value
				desc = camp_improved_court_physician_aptitude_desc
			}
		}
		# Estate
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude }
				}
			}
			add = {
				value = estate_increase_physician_aptitude_value
				desc = estate_increase_physician_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude_2 }
				}
			}
			add = {
				value = estate_increase_physician_aptitude_2_value
				desc = estate_increase_physician_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_physician_aptitude_3 }
				}
			}
			add = {
				value = estate_increase_physician_aptitude_3_value
				desc = estate_increase_physician_aptitude_desc
			}
		}
		add = court_position_aptitude_eunuch_tradition_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_physician }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_barony
			}
			always = no
		}
		#AGOT Added
		OR = {
			NOR = {
				culture = {
					has_innovation = innovation_maesters
				}
				has_title = title:h_the_iron_throne
			}
			government_has_flag = government_is_custom_landless
		}
	}

	# Is this an available position for this court? (root is court owner)
	#AGOT Modified
	# valid_position = { }
	valid_position = {
		NOR = {
			culture = {
				has_innovation = innovation_maesters
			}
			has_title = title:h_the_iron_throne
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		valid_camp_officer_trigger = {
			OFFICER = court_physician
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_physician
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = court_physician } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_physician_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_physician_total_salary_value
			}
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_physician_total_salary_value
		}
		round = no
	}

	is_powerful_agent = yes

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			epidemic_resistance = 1
		}
		poor = {
			epidemic_resistance = 3
		}
		average = {
			epidemic_resistance = 5
		}
		good = {
			epidemic_resistance = 7
		}
		excellent = {
			epidemic_resistance = 10
		}
	}

	scaling_employer_court_modifiers = {
		terrible = {
			health = 0.01
		}
		poor = {
			health = 0.03
		}
		average = {
			health = 0.05
		}
		good = {
			health = 0.07
		}
		excellent = {
			health = 0.1
		}
	}

	custom_employer_modifier_description = court_physician_employer_custom_effect_description

	modifier = {
		health = 0.1
	}

	#custom_employee_modifier_description = court_physician_employee_custom_effect_description

	on_court_position_received = {
		court_physician_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_physician_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_physician_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_physician_court_position
		}
	}

	search_for_courtier = {
		send_interface_toast = {
			type = event_toast_effect_neutral
			title = hire_physician_decision
			custom_tooltip = hire_physician_decision_effect_tooltip
		}
		hidden_effect = {
			add_character_flag = {
				flag = health_3001_hire_physician_decision_text
				days = 20
			}
		}

		trigger_event = {
			id = health.3001
			days = 14
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 150

		if = {
			limit = {
				scope:liege = {
					any_held_county = {
						has_province_with_epidemic = { intensity = minor }
					}
				}
			}
			add = 50
		}
		if = {
			limit = {
				scope:liege = {
					any_held_county = {
						has_province_with_epidemic = { intensity = major }
					}
				}
			}
			add = 100
		}
		if = {
			limit = {
				scope:liege = {
					any_held_county = {
						has_province_with_epidemic = { intensity = apocalyptic }
					}
				}
			}
			add = 150
		}
	}
	ai_candidate_score = {
        value = 150
        # Always have this position if you can, regardless of monetary situation
        add = court_position_candidate_score_base_value
        add = court_position_candidate_aptitude_value

		# No debt considerations for Physicians, they are too important
        # AI is less likely to fire the court physician, unless they have a better candidate.
        if = {
            limit = {
                exists = scope:firing_court_position
            }
            add = 200
            scope:employee = {
                # Does the liege have a better candidate that they should be hiring instead?
                if = {
                    limit = {
                        scope:highest_available_aptitude > scope:employee_aptitude
                    }
                    add = -150
                }
            }
        }

        add = adjust_court_position_score_for_unity

		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_physician }
			}
			add = 1000
		}
    }
}

travel_leader_court_position = {
	sort_order = 375
	max_available_positions = 1
	is_travel_related = yes
	skill = stewardship

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = holding_staff
		background = "gfx/interface/illustrations/event_scenes/ep2_travel_mountains.dds"
		localization_key = travel_leader_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = holding_staff
		background = "gfx/interface/illustrations/event_scenes/ep2_travel_mountains.dds"
		localization_key = travel_leader_celestial
	}
	#AGOT Added
	court_position_asset = {
		trigger = {
			government_has_flag = government_is_pirate
		}
		animation = holding_staff
		background = "gfx/interface/illustrations/event_scenes/docks.dds"
		localization_key = travel_leader_pirate
	}

	court_position_asset = {
		animation = holding_staff
		background = "gfx/interface/illustrations/event_scenes/ep2_travel_mountains.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 1
			max = 50
			desc = court_position_skill_learning
		}
		add = {
			value = stewardship
			multiply = 1.3
			max = 50
			desc = court_position_skill_stewardship
		}
		if = {
			limit = {
				num_of_known_languages >= 2
			}
			add = {
				value = num_of_known_languages
				subtract = 1
				multiply = 5
				max = 50
				desc = court_position_languages
			}
		}

		# SPEED
		add = {
			value = travel_leader_speed
			multiply = 1.8
			subtract = 10
			min = 0
			desc = court_position_speed
		}

		# SAFETY
		add = {
			value = travel_leader_safety
			multiply = 1.8
			subtract = 10
			min = 0
			desc = court_position_safety
		}

		# POSITIVES
		if = {
			limit = {
				has_trait = adventurer
			}
			add = {
				value = 10
				desc = court_position_adventurer_trait
			}
		}
		if = {
			limit = {
				has_trait = brave
			}
			add = {
				value = 5
				desc = court_position_brave_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_herbalist
			}
			add = {
				value = 5
				desc = court_position_herbalist_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_hunter
			}
			add = {
				value = 5
				desc = court_position_hunter_1_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 5
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = flexible_leader
			}
			add = {
				value = 10
				desc = court_position_flexible_leader_trait
			}
		}
		if = {
			limit = {
				has_trait = forest_fighter
			}
			add = {
				value = 10
				desc = court_position_forest_fighter_trait
			}
		}
		if = {
			limit = {
				has_trait = open_terrain_expert
			}
			add = {
				value = 10
				desc = court_position_open_terrain_expert_trait
			}
		}
		if = {
			limit = {
				has_trait = rough_terrain_expert
			}
			add = {
				value = 10
				desc = court_position_rough_terrain_expert_trait
			}
		}
		if = {
			limit = {
				has_trait = desert_warrior
			}
			add = {
				value = 10
				desc = court_position_desert_warrior_trait
			}
		}
		if = {
			limit = {
				has_trait = jungle_stalker
			}
			add = {
				value = 10
				desc = court_position_jungle_stalker_trait
			}
		}
		if = {
			limit = {
				has_trait = winter_soldier
			}
			add = {
				value = 10
				desc = court_position_winter_soldier_trait
			}
		}
		if = {
			limit = {
				has_trait = administrator
			}
			add = {
				value = 5
				desc = court_position_administrator_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 5
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_physician
			}
			add = {
				value = 5
				desc = court_position_physician_1_trait
			}
		}
		if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_traveler
					track = travel
					value >= 75
				}
			}
			add = {
				value = 40
				desc = court_position_traveler_trait_experienced
			}
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_traveler
					track = danger
					value >= 75
				}
			}
			add = {
				value = 40
				desc = court_position_traveler_trait_experienced_danger
			}
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_traveler
					track = travel
					value >= 50
				}
			}
			add = {
				value = 30
				desc = court_position_traveler_trait_experienced
			}
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_traveler
					track = danger
					value >= 50
				}
			}
			add = {
				value = 30
				desc = court_position_traveler_trait_experienced_danger
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_traveler
			}
			add = {
				value = 20
				desc = court_position_traveler_trait
			}
		}
		if = {
			limit = {
				has_character_modifier = ep2_beastmaster_modifier
			}
			add = {
				value = 30
				desc = court_position_beastmaster_modifier
			}
		}

		if = {
			limit = {
				has_perk = travel_companion_perk
			}
			add = {
				value = 15
				desc = court_position_travel_companion_modifier
			}
		}
		if = {
			limit = {
				liege ?= { has_perk = travel_companion_perk }
			}
			add = {
				value = 15
				desc = court_position_travel_companion_liege_modifier
			}
		}

		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = friend }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_friend
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = lover }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_lover
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				is_married = yes
			}
			add = {
				value = 10
				desc = court_position_positions_of_power_perk_marriage
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = likable_perk
					has_relation_best_friend = prev
				}
			}
			add = {
				value = 30
				desc = court_position_best_friend
			}
		}
		else_if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = likable_perk
					has_relation_friend = prev
				}
			}
			add = {
				value = 15
				desc = court_position_friend
			}
		}

		#AGOT Added
		if = {
			limit = {
				employer ?= {
					agot_is_landless_pirate_character = yes
					has_perk = toe_the_line_perk
				}
			}
			add = {
				value = 10
				desc = court_position_positions_of_landless_pirate_toe_the_line_perk_bonus
			}
		}
		
		add = court_position_aptitude_traveling_friends_value


		# NEGATIVES
		if = {
			limit = {
				has_trait = craven
			}
			add = {
				value = -20
				desc = court_position_craven_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -10
				desc = court_position_lazy_trait
			}
		}
		if = {
			limit = {
				has_trait = clubfooted
			}
			add = {
				value = -30
				desc = court_position_clubfooted_trait
			}
		}
		if = {
			limit = {
				has_trait = blind
			}
			add = {
				value = -50
				desc = court_position_blind_trait
			}
		}
		if = {
			limit = {
				has_trait = incapable
			}
			multiply = {
				value = 0
				desc = court_position_incapable_trait
			}
		}
		if = {
			limit = {
				has_trait = infirm
			}
			add = {
				value = -50
				desc = court_position_infirm_trait
			}
		}
		if = {
			limit = {
				has_trait = maimed
			}
			add = {
				value = -30
				desc = court_position_maimed_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add = {
				value = -5
				desc = court_position_reveler_1_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:travel_leader }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		# Japan
		if = {
			limit = {
				liege.house ?= { has_house_power_parameter = improved_stewardship_court_position_efficiency }
			}
			add = {
				value = cp_bonus_aptitude_value
				desc = improved_stewardship_court_position_efficiency_desc
			}
		}
		min = 0
	}

	is_shown = {
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_barony
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = { }

	is_shown_character = {
		scope:employee = {
			is_clergy = no
			bannable_serving_diarch_trigger = no
			NOT = { has_variable = gone_adventuring }
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		valid_camp_officer_trigger = {
			OFFICER = travel_leader
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = travel_leader_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = travel_leader_total_salary_value
			}
		}
		round = no
	}

	received_salary = {
		gold = {
			value = travel_leader_total_salary_value
		}
		round = no
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige = {
			value = minor_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = travel_leader
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
		}
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			monthly_wanderer_lifestyle_xp_gain_mult = 0.025
		}
		poor = {
			monthly_wanderer_lifestyle_xp_gain_mult = 0.05
		}
		average = {
			monthly_wanderer_lifestyle_xp_gain_mult = 0.075
		}
		good = {
			monthly_wanderer_lifestyle_xp_gain_mult = 0.15
		}
		excellent = {
			monthly_wanderer_lifestyle_xp_gain_mult = 0.25
		}
	}

	custom_employer_modifier_description = travel_leader_court_position_custom_desc

	modifier = {
		diplomacy = 1
		health = 0.1
	}

	on_court_position_received = {
		court_travel_leader_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_travel_leader_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_travel_leader_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = travel_leader_court_position
		}
	}

	search_for_courtier = {
		send_interface_toast = {
			type = event_toast_effect_neutral
			title = hire_travel_leader_decision
			custom_tooltip = hire_travel_leader_decision_tooltip
		}

		trigger_event = {
			id = travel_events.1010
			days = 14
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 150
	}
	ai_candidate_score = {
        value = 150
    	# Always have this position if you can, regardless of monetary situation
    	add = court_position_candidate_score_base_value
    	add = court_position_candidate_aptitude_value

		# No debt considerations for Travel Leaders, they are too important

        if = {
            limit = {
                exists = scope:firing_court_position
            }
            add = 200
            scope:employee = {
                # Does the liege have a better candidate that they should be hiring instead?
                if = {
                    limit = {
                        scope:highest_available_aptitude > scope:employee_aptitude
                    }
                    add = -150
                }
            }
        }

        if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = travel_leader }
			}
			add = 1000
		}
    }
}

antiquarian_court_position = {
	sort_order = 350
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = throne_room_one_handed_passive_3
		background = "gfx/interface/illustrations/event_scenes/tgp_courtyard_asia.dds"
		localization_key = antiquarian_celestial
	}

	court_position_asset = {
		animation = throne_room_one_handed_passive_3
		background = "gfx/interface/illustrations/event_scenes/armory.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = soon_forgiven_perk
				}
			}
			add = {
				value = 10
				desc = court_position_soon_forgiven_perk
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = friend }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_friend
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = lover }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_lover
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				is_married = yes
			}
			add = {
				value = 10
				desc = court_position_positions_of_power_perk_marriage
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = likable_perk
					has_relation_best_friend = prev
				}
			}
			add = {
				value = 30
				desc = court_position_best_friend
			}
		}
		else_if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = likable_perk
					has_relation_friend = prev
				}
			}
			add = {
				value = 15
				desc = court_position_friend
			}
		}
		add = {
			value = learning
			multiply = 2.5
			max = 60
			desc = court_position_skill_learning
		}
		if = { # Characters with a completed inspiration are very good Antiquarians
			limit = {
				has_completed_inspiration = yes
			}
			add = {
				value = 30
				desc = court_position_completed_inspiration
			}
		}
		if = { # Shy characters are likely to spend more time with the artifacts than other people
			limit = {
				has_trait = shy
			}
			add = {
				value = 15
				desc = court_position_shy_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 15
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = administrator
			}
			add = {
				value = 15
				desc = court_position_administrator_trait
			}
		}
		if = {
			limit = { has_trait = overseer }
			add = {
				value = 15
				desc = court_position_overseer_trait
			}
		}
		if = {
			limit = {
				has_variable = fund_inspiration_6508_architect_improvement
			}
			add = {
				value = 5
				desc = court_position_architect_study_experience
			}
		}
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_antiquarian_aptitude }
				}
			}
			add = {
				value = estate_increase_antiquarian_aptitude_value
				desc = estate_increase_antiquarian_aptitude_desc
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:antiquarian }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				is_ai = yes
			}
			has_any_artifact = yes
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			antiquarian_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = antiquarian
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = antiquarian_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = antiquarian_total_salary_value
			}
		}
		round = no
	}

	received_salary = {
		gold = {
			value = antiquarian_total_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			artifact_decay_reduction_mult = -0.07
		}
		poor = {
			artifact_decay_reduction_mult = -0.11
		}
		average = {
			artifact_decay_reduction_mult = -0.17
		}
		good = {
			artifact_decay_reduction_mult = -0.25
		}
		excellent = {
			artifact_decay_reduction_mult = -0.35
		}
	}

	custom_employer_modifier_description = antiquarian_employer_custom_effect_description

	modifier = {
		stewardship = 2
		artifact_decay_reduction_mult = -0.2
	}

	on_court_position_received = {
		antiquarian_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		antiquarian_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		antiquarian_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = antiquarian_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		if = {
			limit = {
				scope:liege = {
					government_allows = administrative
				}
			}
			add = 150
		}
		if = {
			limit = {
				scope:liege = {
					highest_held_title_tier >= tier_duchy
				}
			}
			add = 50
		}
		if = {
			limit = {
				scope:liege = {
					highest_held_title_tier >= tier_kingdom
				}
			}
			add = 50
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
        if = {
            limit = {
                exists = scope:firing_court_position
            }
            add = 100
            scope:employee = {
                # Does the liege have a better candidate that they should be hiring instead?
                if = {
                    limit = {
                        scope:highest_available_aptitude > scope:employee_aptitude
                    }
                    add = -75
                }
            }
        }
        if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = antiquarian }
			}
			add = 1000
		}
	}
}

### Regular Court Positions ### ( Sort order 299 - 200 )
seneschal_court_position = {
	sort_order = 299
	max_available_positions = 1
	skill = stewardship

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = reading
		background = "gfx/interface/illustrations/event_scenes/tgp_asia_estate.dds"
		localization_key = seneschal_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = reading
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_asia_estate.dds"
	# }

	court_position_asset = {
		animation = reading
		background = "gfx/interface/illustrations/event_scenes/ep3_medi_estate.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = stewardship
			multiply = 2.5
			max = 50
			desc = court_position_skill_stewardship
		}
		if = {
			limit = {
				has_trait = administrator
			}
			add = {
				value = 20
				desc = court_position_administrator_trait
			}
		}
		if = {
			limit = {
				has_trait = overseer
			}
			add = {
				value = 20
				desc = court_position_overseer_trait
			}
		}
		if = {
			limit = {
				has_trait = organizer
			}
			add = {
				value = 20
				desc = court_position_organizer_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:seneschal }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Japan
		if = {
			limit = {
				liege.house ?= { has_house_power_parameter = improved_stewardship_court_position_efficiency }
			}
			add = {
				value = cp_bonus_aptitude_value
				desc = improved_stewardship_court_position_efficiency_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		NOR = { 
			government_has_flag = government_is_nomadic 
			government_has_flag = government_is_mandala
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			seneschal_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = seneschal
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = seneschal_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = seneschal_total_salary_value
			}
		}
		prestige = seneschal_prestige_salary_value
		round = no
	}

	received_salary = {
		gold = {
			value = seneschal_total_salary_value
		}
		prestige = {
			value = seneschal_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
		  	character_capital_county_monthly_control_add = 0.1
		  	courtier_and_guest_opinion = 1
		  	monthly_legitimacy_add = 0.1
		}
		poor = {
		  	character_capital_county_monthly_control_add = 0.15
		  	courtier_and_guest_opinion = 3
		  	monthly_legitimacy_add = 0.2
		}
		average = {
		  	character_capital_county_monthly_control_add = 0.2
		  	courtier_and_guest_opinion = 5
		  	monthly_legitimacy_add = 0.3
		}
		good = {
		  	character_capital_county_monthly_control_add = 0.25
		  	courtier_and_guest_opinion = 7
		  	monthly_legitimacy_add = 0.5
		}
		excellent = {
		  	character_capital_county_monthly_control_add = 0.3
		  	courtier_and_guest_opinion = 10
		  	monthly_legitimacy_add = 0.7
		}
	}

	modifier = {
		general_opinion = 5
		monthly_stewardship_lifestyle_xp_gain_mult = 0.2
	}

	on_court_position_received = {
		seneschal_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		seneschal_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		seneschal_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = seneschal_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
        if = { # Having a seneschal is excellent if you have legitimacy
            limit = {
				scope:liege = {
					has_legitimacy = yes
				}
            }
            add = 200
        }
		add = court_position_seneschal_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
        if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = seneschal }
			}
			add = 1000
		}
	}
}

court_tutor_court_position = {
	sort_order = 290
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = happy_teacher
		background = "gfx/interface/illustrations/event_scenes/tgp_study_asia.dds"
		localization_key = court_tutor_celestial
	}

	court_position_asset = {
		animation = happy_teacher
		background = "gfx/interface/illustrations/event_scenes/bp2_university.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 2.5
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				diplomacy >= high_skill_rating
				martial >= high_skill_rating
				stewardship >= high_skill_rating
				intrigue >= high_skill_rating
				learning >= high_skill_rating
			}
			add = {
				value = 20
				desc = court_position_high_skills_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 15
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 15
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 15
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = {
				has_trait = shy
			}
			add = {
				value = -10
				desc = court_position_shy_trait
			}
		}
		if = {
			limit = {
				has_trait = intellect_good_3
			}
			add = {
				value = 40
				desc = court_position_intellect_good_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_2
			}
			add = {
				value = 20
				desc = court_position_intellect_good_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_1
			}
			add = {
				value = 10
				desc = court_position_intellect_good_1_trait
			}
		}
		else_if = {
			limit = {
				has_trait = shrewd
			}
			add = {
				value = 10
				desc = court_position_shrewd_trait
			}
		}
		if = {
			limit = {
				has_trait = reclusive
			}
			add = {
				value = -10
				desc = court_position_reclusive_trait
			}
		}
		#AGOT Added
		if = {
			limit = {
				has_trait = inquisitive
			}
			add = {
				value = 10
				desc = court_position_inquistive_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		if = {
			limit = {
				has_character_flag = court_0107_tutor
			}
			add = {
				value = 10
				desc = court_position_liege_support
			}
		}
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increased_tutor_aptitude }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increased_tutor_aptitude_4 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_4_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increased_tutor_aptitude_3 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_3_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increased_tutor_aptitude_2 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_2_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increased_tutor_aptitude_1 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_1_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_building_or_higher = east_asian_estate_history_school_04 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_4_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_building_or_higher = east_asian_estate_history_school_03 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_3_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_building_or_higher = east_asian_estate_history_school_02 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_2_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		else_if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_building_or_higher = east_asian_estate_history_school_01 }
				}
			}
			add = {
				value = estate_increased_tutor_aptitude_1_value
				desc = estate_increased_tutor_aptitude_desc
			}
		}
		if = {
			limit = {
				has_character_flag = court_language_teacher
			}
			add = {
				value = 20
				desc = court_language_teacher_desc
			}
		}
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_tutor }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		# Nomad Yurt
		if = {
			limit = {
				employer.domicile ?= {
					has_domicile_building_or_higher = wet_nurse_yurt_01
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_court_tutor_aptitude_lvl_4
						}
					}
					add = 32
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_court_tutor_aptitude_lvl_3
						}
					}
					add = 16
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_court_tutor_aptitude_lvl_2
						}
					}
					add = 8
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_court_tutor_aptitude_lvl_1
						}
					}
					add = 4
				}
				desc = wet_nurse_yurt_01_domicile_building
			}
		}
		if = {
			limit = {
				employer.domicile ?= {
					OR = {
						has_domicile_building_or_higher = japanese_schoolhouse_01
						has_domicile_building_or_higher = east_asian_estate_library_01
					}
				}
			}
			add = {
				value = 0
				if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_tutor_aptitude_6 } }
					add = estate_increase_gardener_aptitude_value_6
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_tutor_aptitude_5 } }
					add = estate_increase_gardener_aptitude_value_5
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_tutor_aptitude_4 } }
					add = estate_increase_gardener_aptitude_value_4
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_tutor_aptitude_3 } }
					add = estate_increase_gardener_aptitude_value_3
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_tutor_aptitude_2 } }
					add = estate_increase_gardener_aptitude_value_2
				}
				else = { add = estate_increase_gardener_aptitude_value_1 }
				desc = estate_tutor_building
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			domicile ?= {
				has_domicile_parameter = nomad_unlock_court_tutor
			}
		}
		has_ep1_court_positions_dlc_trigger = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		trigger_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			domicile ?= {
				has_domicile_parameter = nomad_unlock_court_tutor
			}
		}
		trigger_else = {
			is_landed_or_landless_administrative = yes
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			court_tutor_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_tutor
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_tutor_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_tutor_total_salary_value
			}
		}
		prestige = court_tutor_prestige_salary_value
		round = no
	}

	received_salary = {
		gold = {
			value = court_tutor_total_salary_value
		}
		prestige = {
			value = court_tutor_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			learn_language_scheme_phase_duration_add = -4
		}
		poor = {
			learn_language_scheme_phase_duration_add = -8
		}
		average = {
			learn_language_scheme_phase_duration_add = -12
		}
		good = {
			learn_language_scheme_phase_duration_add = -16
		}
		excellent = {
			learn_language_scheme_phase_duration_add = -20
		}
	}

	custom_employer_modifier_description = court_tutor_employer_custom_effect_description

	base_employer_modifier = {
	}

	modifier = {
		stewardship = 1
		diplomacy = 1
		child_opinion = -10
		monthly_learning_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		court_tutor_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_tutor_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_tutor_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_tutor_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			if = {
				limit = {
					OR = {
						AND = {
							exists = primary_heir
							primary_heir = {
								is_adult = no
								is_courtier_of = scope:liege
							}
						}
						any_child = {
							count >= 3
							is_adult = no
							is_courtier_of = scope:liege
						}
					}
				}
				add = 20
			}
			if = {
				limit = {
					has_perk = pedagogy_perk
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_tutor }
			}
			add = 1000
		}
	}
}

wet_nurse_court_position = { # BP2
	sort_order = 285
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		animation = newborn
		background = "gfx/interface/illustrations/event_scenes/bp2_nursery.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		if = {
			limit = { health >= 5 }
			add = {
				value = health
				multiply = 5
				add = 10
				desc = court_position_skill_health_good
			}
		}
		else_if = {
			limit = { health < 3 }
			add = {
				value = health
				multiply = 10
				add = -30
				desc = court_position_skill_health_low
			}
		}
		else = {
			add = {
				value = health
				multiply = 2
				desc = court_position_skill_health
			}
		}
		if = {
			limit = {
				any_child = { }
			}
			add = {
				value = 15
				desc = court_position_has_child
			}
		}
		if = {
			limit = {
				has_trait = strong
			}
			add = {
				value = 15
				desc = court_position_strong_trait
			}
		}
		if = {
			limit = {
				has_trait = physique_good_3
			}
			add = {
				value = 20
				desc = court_position_physique_good_3_trait
			}
		}
		if = {
			limit = {
				has_trait = physique_good_2
			}
			add = {
				value = 15
				desc = court_position_physique_good_2_trait
			}
		}
		if = {
			limit = {
				has_trait = physique_good_1
			}
			add = {
				value = 10
				desc = court_position_physique_good_1_trait
			}
		}
		if = {
			limit = {
				has_trait = loyal
			}
			add = {
				value = 10
				desc = court_position_loyal_trait
			}
		}
		# Nomad Yurt
		if = {
			limit = {
				employer.domicile ?= {
					has_domicile_building_or_higher = wet_nurse_yurt_01
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_wet_nurse_aptitude_lvl_4
						}
					}
					add = 32
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_wet_nurse_aptitude_lvl_3
						}
					}
					add = 16
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_wet_nurse_aptitude_lvl_2
						}
					}
					add = 8
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_wet_nurse_aptitude_lvl_1
						}
					}
					add = 4
				}
				desc = wet_nurse_yurt_01_domicile_building
			}
		}
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:wet_nurse }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			domicile ?= {
				has_domicile_parameter = nomad_unlock_wet_nurse
			}
		}
		has_bp2_dlc_trigger = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		trigger_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			custom_tooltip = {
				text = has_wet_nurse_domicile_building
				domicile ?= {
					has_domicile_parameter = nomad_unlock_wet_nurse
				}
			}
		}
		trigger_else = {
			is_landed_or_landless_administrative = yes
		}
	}

	is_shown_character = {
		scope:employee = {
			NOT = { is_close_family_of = scope:liege }
			age < 46
			is_female = yes
			has_no_particular_noble_roots_trigger = yes
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			wet_nurse_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = minor_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = wet_nurse
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = wet_nurse_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = wet_nurse_total_salary_value
			}
		}
		prestige = wet_nurse_prestige_salary_value
		round = no
	}

	received_salary = {
		gold = {
			value = wet_nurse_total_salary_value
		}
		prestige = {
			value = wet_nurse_prestige_salary_value
		}
		round = no
	}

	custom_employer_modifier_description = wet_nurse_employer_custom_effect_description

	modifier = {
		diplomacy = 1
		child_opinion = 15
	}

	on_court_position_received = {
		wet_nurse_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		wet_nurse_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		wet_nurse_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_wn_effect = {
			COURT_POSITION_TYPE = wet_nurse_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		scope:liege = {
			# Opinion affects how likely they are to be hired
			if = {
				limit = {
					has_relation_lover = scope:employee
				}
				add = 100
			}
			else_if = {
				limit = {
					has_relation_friend = scope:employee
				}
				add = 75
			}
			else_if = {
				limit = {
					opinion = {
						target = scope:employee
						value >= high_positive_opinion
					}
				}
				add = 50
			}
			else_if = {
				limit = {
					opinion = {
						target = scope:employee
						value >= medium_positive_opinion
					}
				}
				add = 25
			}
			if = {
				limit = {
					has_relation_nemesis = scope:employee
				}
				add = -100
			}
			else_if = {
				limit = {
					has_relation_rival = scope:employee
				}
				add = -75
			}
			else_if = {
				limit = {
					opinion = {
						target = scope:employee
						value >= high_negative_opinion
					}
				}
				add = -50
			}
			else_if = {
				limit = {
					opinion = {
						target = scope:employee
						value >= medium_negative_opinion
					}
				}
				add = -25
			}
			if = {
				limit = {
					NOT = { scope:liege.culture ?= scope:employee.culture }
				}
				add = -25
			}
			if = {
				limit = {
					scope:liege.faith != scope:employee.faith
				}
				add = -25
			}
			if = {
				limit = {
					OR = {
						primary_heir ?= {
							is_adult = no
							is_courtier_of = scope:liege
						}
						any_child = {
							count >= 3
							is_adult = no
							is_courtier_of = scope:liege
						}
					}
				}
				add = 20
			}
		}
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = wet_nurse }
			}
			add = 1000
		}
	}
}

charioteer_court_position = {
	sort_order = 284
	max_available_positions = 1
	skill = prowess

	court_position_asset = {
		animation = wrestling_victory
		background = "gfx/interface/illustrations/event_scenes/ep3_hippodrome_chariot_race.dds"
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep3_dlc_trigger = yes
		highest_held_title_tier > tier_county
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 10
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = prowess
			multiply = 2.5
			max = 50
			desc = court_position_skill_prowess
		}
		# Charioteer Blue Trait
		if = {
			limit = { has_trait = charioteer_blue }
			if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_blue
						value >= 90
					}
				}
				add = {
					value = 40
					desc = court_position_charioteer_blue_trait
				}
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_blue
						value >= 40
					}
				}
				add = {
					value = 20
					desc = court_position_charioteer_blue_trait
				}
			}
		}
		# Charioteer Green Trait
		if = {
			limit = { has_trait = charioteer_green }
			if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_green
						value >= 90
					}
				}
				add = {
					value = 40
					desc = court_position_charioteer_green_trait
				}
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_green
						value >= 40
					}
				}
				add = {
					value = 20
					desc = court_position_charioteer_green_trait
				}
			}
		}
		# Charioteer White Trait
		if = {
			limit = { has_trait = charioteer_white }
			if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_white
						value >= 90
					}
				}
				add = {
					value = 40
					desc = court_position_charioteer_white_trait
				}
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_white
						value >= 40
					}
				}
				add = {
					value = 20
					desc = court_position_charioteer_white_trait
				}
			}
		}
		# Charioteer Red Trait
		if = {
			limit = { has_trait = charioteer_red }
			if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_red
						value >= 90
					}
				}
				add = {
					value = 40
					desc = court_position_charioteer_red_trait
				}
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = charioteer_red
						value >= 40
					}
				}
				add = {
					value = 20
					desc = court_position_charioteer_red_trait
				}
			}
		}

		if = {
			limit = {
				OR = {
					has_trait = education_martial_1
					has_trait = education_martial_2
					has_trait = education_martial_3
					has_trait = education_martial_4
					has_trait = education_martial_5
				}
			}
			add = {
				value = 5
				if = {
					limit = { has_trait = education_martial_2 }
					add = 10
				}
				if = {
					limit = {has_trait = education_martial_3 }
					add =  15
				}
				if = {
					limit = { has_trait = education_martial_4 }
					add = 20
				}
				if = {
					limit = { has_trait = education_martial_5 }
					add = 25
				}
				desc = trait_education_martial_prowess
			}
		}
		
		# Estate - Owner bonus from stables
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_charioteer_aptitude }
				}
			}
			add = {
				value = estate_increase_charioteer_aptitude_value
				desc = estate_increase_charioteer_aptitude_desc
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:charioteer }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		#AGOT Disabled
		# if = {
		# 	limit = {
		# 		has_trait = confucian_education
		# 	}
		# 	add = {
		# 		value = 20
		# 	}
		# }

		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
		culture = { has_cultural_parameter = hosts_chariot_races }
	}

	is_shown_character = {
		scope:employee = {
			is_ai = yes
			is_landed = no
			has_no_particular_noble_roots_trigger = yes
			age >= 16
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			charioteer_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = charioteer
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = charioteer } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	custom_employer_modifier_description = charioteer_employer_custom_effect_description

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = charioteer_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = charioteer_total_salary_value
			}
		}
		prestige = charioteer_prestige_salary_value
		round = no
	}

	received_salary = {
		gold = {
			value = charioteer_total_salary_value
		}
		prestige = {
			value = charioteer_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			monthly_influence_mult = 0.04
		}
		poor = {
			monthly_influence_mult = 0.08
		}
		average = {
			monthly_influence_mult = 0.12
		}
		good = {
			monthly_influence_mult = 0.16
		}
		excellent = {
			monthly_influence_mult = 0.2
		}
	}

	modifier = {
		attraction_opinion = 10
		charioteer_blue_xp_gain_mult = 0.25
		charioteer_green_xp_gain_mult = 0.25
		charioteer_white_xp_gain_mult = 0.25
		charioteer_red_xp_gain_mult = 0.25
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes
		# Assign them to a team
		scope:employee = {
			if = {
				limit = { has_any_charioteer_trait = no }
				random_list = {
					2 = {
						add_trait = charioteer_green
					}
					2 = {
						add_trait = charioteer_blue
					}
					1 = {
						add_trait = charioteer_white
					}
					1 = {
						add_trait = charioteer_red
					}
				}
			}
		}
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_fg_effect = {
			COURT_POSITION_TYPE = charioteer_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 100
		scope:liege = {
			# More likely for very generous characters
			if = {
				limit = {
					ai_greed <= -75
				}
				add = 25
			}
			# Lots of gold to spend on inspirations!
			if = {
				limit = {
					gold >= 500
					monthly_character_income > monthly_character_expenses_plus_fourty_percent
				}
				add = 50
			}
			#AGOT Disabled
			# if = { # Emperor should always have one
			# 	limit = {
			# 		has_title = title:e_byzantium
			# 	}
			# 	add = 100
			# }
			if = { # Most governors should have them
				limit = {
					has_trait = governor
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 100
		scope:employee = {
			# Does the liege have a better candidate that they should be hiring instead?
			if = {
				limit = {
					scope:highest_available_aptitude > scope:employee_aptitude
				}
				add = -125
			}
			# More likely to pick a courtier with a high aptitude, less likely to pick one with low
			add = {
				value = scope:employee_aptitude
				multiply = 4
			}
		}

		add = scope:base_value
		add = court_position_candidate_score_base_value
	}
}

bookmaker_court_position = { # EP3
	sort_order = 283
	max_available_positions = 1
	skill = stewardship

	court_position_asset = {
		animation = throne_room_writer
		background = "gfx/interface/illustrations/event_scenes/ep3_medi_study.dds"
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep3_dlc_trigger = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 15
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = stewardship
			multiply = 2.5
			max = 50
			desc = court_position_skill_stewardship
		}
		add = {
			value = intrigue
			divide = 2
			desc = court_position_skill_intrigue
		}
		if = {
			limit = {
				OR = {
					has_trait = education_stewardship_1
					has_trait = education_stewardship_2
					has_trait = education_stewardship_3
					has_trait = education_stewardship_4
					has_trait = education_stewardship_5
				}
			}
			add = {
				value = 5
				if = {
					limit = { has_trait = education_stewardship_2 }
					add = 5
				}
				else_if = {
					limit = {has_trait = education_stewardship_3 }
					add = 10
				}
				else_if = {
					limit = { has_trait = education_stewardship_4 }
					add = 15
				}
				else_if = {
					limit = { has_trait = education_stewardship_5 }
					add = 20
				}
				desc = trait_education_stewardship
			}
		}
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:bookmaker }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		culture = { has_cultural_parameter = hosts_chariot_races }
	}

	is_shown_character = {
		scope:employee = {
			is_ai = yes
			is_adult = yes
			is_playable_character = no
			is_landed = no
			has_no_particular_noble_roots_trigger = yes
			age >= 16
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			bookmaker_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = bookmaker
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = bookmaker } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	# No gold salary. they get paid a precentage of the proceeds from gambling during chariot races
	salary = {
		prestige = {
			value = bookmaker_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		prestige = {
			value = bookmaker_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			monthly_influence_mult = 0.01
		}
		poor = {
			monthly_influence_mult = 0.02
		}
		average = {
			monthly_influence_mult = 0.03
		}
		good = {
			monthly_influence_mult = 0.04
		}
		excellent = {
			monthly_influence_mult = 0.05
		}
	}

	modifier = {
		monthly_stewardship_lifestyle_xp_gain_mult = 0.1
		monthly_income = 0.2
	}

	custom_employer_modifier_description = bookmaker_employer_custom_effect_description
	
	on_court_position_received = {
		scope:employee = { add_character_flag = was_bookmaker }
		basic_gained_court_position_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = bookmaker_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 300
		scope:liege = {
			# More likely for very generous characters
			if = {
				limit = {
					ai_greed <= -75
				}
				add = 25
			}
			#AGOT Disabled
			# if = { # Emperor should always have one
			# 	limit = {
			# 		has_title = title:e_byzantium
			# 	}
			# 	add = 100
			# }
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 300
		scope:employee = {
			# Does the liege have a better candidate that they should be hiring instead?
			if = {
				limit = {
					scope:highest_available_aptitude > scope:employee_aptitude
				}
				add = -125
			}
			# More likely to pick a courtier with a high aptitude, less likely to pick one with low
			add = {
				value = scope:employee_aptitude
				multiply = 4
			}
		}

		add = scope:base_value
		add = court_position_candidate_score_base_value
	}
}

akolouthos_court_position = { # EP1 & EP3
	sort_order = 282
	max_available_positions = 1

	skill = martial

	court_position_asset = {
		animation = marshal_axe
		background = "gfx/interface/illustrations/event_scenes/ep3_city_gate.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = martial
			multiply = 4
			max = 50
			desc = court_position_skill_martial
		}

		if = {
			limit = {
				has_trait = shieldmaiden
			}
			add = {
				value = 5
				desc = court_position_shieldmaiden_trait
			}
		}
		if = {
			limit = {
				has_trait = gallant
			}
			add = {
				value = 5
				desc = court_position_gallant_trait
			}
		}
		if = {
			limit = {
				has_trait = strong
			}
			add = {
				value = 10
				desc = court_position_strong_trait
			}
		}
		if = {
			limit = {
				has_trait = physique_good_3
			}
			add = {
				value = 15
				desc = court_position_physique_good_3_trait
			}
		}
		if = {
			limit = {
				has_trait = physique_good_2
			}
			add = {
				value = 10
				desc = court_position_physique_good_2_trait
			}
		}
		if = {
			limit = {
				has_trait = physique_good_1
			}
			add = {
				value = 5
				desc = court_position_physique_good_1_trait
			}
		}
		if = {
			limit = {
				has_trait = brave
			}
			add = {
				value = 15
				desc = court_position_brave_trait
			}
		}
		if = {
			limit = {
				has_trait = loyal
			}
			add = {
				value = 10
				desc = court_position_loyal_trait
			}
		}
		if = {
			limit = {
				has_trait = just
			}
			add = {
				value = 10
				desc = court_position_just_trait
			}
		}
		if = {
			limit = {
				has_trait = stubborn
			}
			add = {
				value = 5
				desc = court_position_stubborn_trait
			}
		}
		if = {
			limit = {
				has_trait = honest
			}
			add = {
				value = 10
				desc = court_position_honest_trait
			}
		}
		if = {
			limit = {
				has_trait = unyielding_defender
			}
			add = {
				value = 10
				desc = court_position_unyielding_defender_trait
			}
		}
		#AGOT Disabled
		# if = {
		# 	limit = {
		# 		has_trait = varangian
		# 	}
		# 	add = {
		# 		value = 10
		# 		desc = court_position_varangian_trait
		# 	}
		# }

		if = {
			limit = {
				has_trait = craven
			}
			add = {
				value = -15
				desc = court_position_craven_trait
			}
		}
		if = {
			limit = {
				has_trait = fickle
			}
			add = {
				value = -10
				desc = court_position_fickle_trait
			}
		}
		if = {
			limit = {
				has_trait = disloyal
			}
			add = {
				value = -25
				desc = court_position_disloyal_trait
			}
		}
		if = {
			limit = {
				has_character_flag = best_knight_position
			}
			add = {
				value = 20
				desc = best_knight_position_desc
			}
		}
		if = {
			limit = {
				has_character_flag = competing_knight_position
				OR = {
					any_court_position_holder = {
						type = bodyguard_court_position
						has_character_flag = competing_knight_position
					}
					any_court_position_holder = {
						type = champion_court_position
						has_character_flag = competing_knight_position
					}
				}
			}
			add = 30
			desc = competing_knight_position_desc
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:akolouthos }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		#AGOT Modified
		# is_landed_or_landless_administrative = yes
		# has_ep1_court_positions_dlc_trigger = yes
		# has_ep3_dlc_trigger = yes
		# NOT = { government_has_flag = government_is_nomadic }
		# trigger_if = {
		# 	limit = {
		# 		is_ai = yes
		# 		highest_held_title_tier <= tier_county
		# 	}
		# 	always = no
		# }
		always = no
	}

	is_shown_character = {
		scope:employee = {
			akolouthos_validity_trigger = { EMPLOYER = scope:liege }
			court_position_employee_shown_trigger = yes
		}
	}

	valid_position = {
		#AGOT Modified
		# is_landed_or_landless_administrative = yes
		# highest_held_title_tier >= tier_empire
		# save_temporary_scope_as = root_scope
		# custom_tooltip = {
		# 	text = akolouthos_founded_varangians_trigger_tt
		# 	primary_title = { has_variable = founded_varangian_guard }
		# }
		always = no
	}

	valid_character = {
		scope:employee = {
			akolouthos_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = akolouthos
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = akolouthos } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = akolouthos_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = akolouthos_total_salary_value
			}
		}
		prestige = medium_court_position_salary
		round = no
	}

	received_salary = {
		gold = {
			value = akolouthos_total_salary_value
		}
		prestige = {
			value = medium_court_position_salary
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			heavy_infantry_toughness_mult = -0.05
		}
		poor = {
			heavy_infantry_toughness_mult = 0
		}
		average = {
			heavy_infantry_toughness_mult = 0.05
		}
		good = {
			heavy_infantry_toughness_mult = 0.1
		}
		excellent = {
			heavy_infantry_toughness_mult = 0.2
		}
	}

	custom_employer_modifier_description = akolouthos_employer_custom_effect_description

	modifier = {
		prowess = 1
		intrigue = 1
		enemy_hostile_scheme_success_chance_max_add = -10
	}

	on_court_position_received = {
		akolouthos_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		akolouthos_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		akolouthos_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_fg_effect = {
			COURT_POSITION_TYPE = akolouthos_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely if you're scared all the time
			if = {
				limit = {
					has_trait = paranoid
				}
				add = 50
			}
		}
		scope:liege = {
			if = {
				limit = {
					number_maa_regiments_of_base_type = {
						type = heavy_infantry
						value >= 5
					}
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = akolouthos }
			}
			add = 1000
		}
	}
}

chief_eunuch_court_position = {
	sort_order = 281
	max_available_positions = 1
	minimum_rank = duchy # Should only be available for dukes and above
	skill = diplomacy

	court_position_asset = {
		trigger = {
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = scheme
		background = "gfx/interface/illustrations/event_scenes/tgp_asia_throne_room.dds"
		localization_key = chief_eunuch_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			highest_held_title_tier <= tier_kingdom
			government_has_flag = government_is_celestial
		}
		animation = scheme
		background = "gfx/interface/illustrations/event_scenes/throneroom_mediterranean.dds"
		localization_key = chief_eunuch_celestial
	}

	court_position_asset = {
		animation = scheme
		background = "gfx/interface/illustrations/event_scenes/throneroom_mediterranean.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = intrigue
			multiply = 2.5
			desc = court_position_skill_intrigue
		}
		if = {
			limit = {
				has_trait = blind
			}
			add = {
				value = -50
				desc = court_position_blind_trait
			}
		}
		if = {
			limit = {
				has_trait = infirm
			}
			add = {
				value = -75
				desc = court_position_infirm_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		#AGOT Added Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:chief_eunuch }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		highest_held_title_tier >= tier_duchy
		save_temporary_scope_as = root_scope
		can_employ_court_eunuchs_trigger = { CHAR = scope:root_scope }
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			liege ?= scope:liege #
			chief_eunuch_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = chief_eunuch
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = chief_eunuch } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = chief_eunuch_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = chief_eunuch_total_salary_value
			}
		}
		prestige = {
			value = chief_eunuch_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = chief_eunuch_total_salary_value
		}
		prestige = {
			value = chief_eunuch_prestige_salary_value
		}
		round = no
	}

	is_powerful_agent = yes

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			enemy_hostile_scheme_phase_duration_add = 1
			hostile_scheme_phase_duration_add = -1
		}
		poor = {
			court_grandeur_baseline_add = 1
			enemy_hostile_scheme_phase_duration_add = 2
			hostile_scheme_phase_duration_add = -2
		}
		average = {
			court_grandeur_baseline_add = 1
			enemy_hostile_scheme_phase_duration_add = 4
			hostile_scheme_phase_duration_add = -3
		}
		good = {
			court_grandeur_baseline_add = 2
			enemy_hostile_scheme_phase_duration_add = 8
			hostile_scheme_phase_duration_add = -5
		}
		excellent = {
			court_grandeur_baseline_add = 2
			enemy_hostile_scheme_phase_duration_add = 16
			hostile_scheme_phase_duration_add = -7
		}
	}

	modifier = {
		enemy_hostile_scheme_success_chance_max_add = -10
		monthly_intrigue_lifestyle_xp_gain_mult = 0.2
	}

	on_court_position_received = {
		chief_eunuch_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		chief_eunuch_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		chief_eunuch_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_eun_effect = {
			COURT_POSITION_TYPE = chief_eunuch_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 100
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 100
		add = scope:base_value
		add = court_position_candidate_score_base_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = chief_eunuch }
			}
			add = 1000
		}
	}
}

master_of_horse_court_position = {
	sort_order = 280
	max_available_positions = 1
	minimum_rank = duchy # Should only be available for dukes or higher tiers
	skill = martial

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = throne_room_two_handed_passive_1
		background = "gfx/interface/illustrations/event_scenes/tgp_courtyard_asia.dds"
		localization_key = master_of_horse_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = throne_room_two_handed_passive_1
		background = "gfx/interface/illustrations/event_scenes/tgp_courtyard_asia.dds"
		localization_key = master_of_horse_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = throne_room_two_handed_passive_1
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_courtyard_asia.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_asian_heritage_pillar_trigger = yes }
	# 	animation = throne_room_two_handed_passive_1
	# 	background = "gfx/interface/illustrations/event_scenes/bp1_courtyard_indian.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_mena_heritage_pillar_trigger = yes }
	# 	animation = throne_room_two_handed_passive_1
	# 	background = "gfx/interface/illustrations/event_scenes/bp1_courtyard_mena.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_european_heritage_pillar_trigger = yes }
	# 	animation = throne_room_two_handed_passive_1
	# 	background = "gfx/interface/illustrations/event_scenes/fp2_courtyard.dds"
	# }

	court_position_asset = {
		animation = throne_room_two_handed_passive_1
		background = "gfx/interface/illustrations/event_scenes/courtyard.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = martial
			multiply = 2.5
			max = 50
			desc = court_position_skill_martial
		}
		add = {
			value = prowess
			multiply = 2
			max = 50
			desc = court_position_skill_prowess
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 15
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = { has_trait = overseer }
			add = {
				value = 15
				desc = court_position_overseer_trait
			}
		}
		if = {
			limit = { has_trait = gallant }
			add = {
				value = 15
				desc = court_position_gallant_trait
			}
		}
		#AGOT Added
		if = {
			limit = {
				has_trait = authoritative
			}
			add = 10
			desc = court_position_authoritative_trait
		}
		# Estate - Owner bonus from stables
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_master_of_horse_aptitude }
				}
			}
			add = {
				value = estate_increase_master_of_horse_aptitude_value
				desc = estate_increase_master_of_horse_aptitude_desc
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:master_of_horse }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_duchy
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			master_of_horse_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = master_of_horse
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = master_of_horse } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = master_of_horse_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = master_of_horse_total_salary_value
			}
		}
		prestige = {
			value = master_of_horse_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = master_of_horse_total_salary_value
		}
		prestige = {
			value = master_of_horse_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			knight_effectiveness_mult = 0.01
			character_travel_speed_mult = 0.01
		}
		poor = {
			knight_effectiveness_mult = 0.02
			character_travel_speed_mult = 0.02
			knight_limit = 1
		}
		average = {
			knight_effectiveness_mult = 0.03
			character_travel_speed_mult = 0.03
			knight_limit = 2
		}
		good = {
			knight_effectiveness_mult = 0.05
			character_travel_speed_mult = 0.05
			knight_limit = 2
		}
		excellent = {
			knight_effectiveness_mult = 0.08
			character_travel_speed_mult = 0.08
			knight_limit = 3
		}
	}

	modifier = {
		monthly_martial_lifestyle_xp_gain_mult = 0.15
		knight_effectiveness_mult = 0.15
	}

	on_court_position_received = {
		master_of_horse_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		master_of_horse_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		master_of_horse_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = master_of_horse_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		if = {
			limit = {
				scope:liege = {
					ai_has_warlike_personality = yes
				}
			}
			add = 200
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = master_of_horse }
			}
			add = 1000
		}
	}
}

master_of_hunt_court_position = {
	sort_order = {
		value = 275
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 100
		}
	}
	max_available_positions = 1
	minimum_rank = county
	skill = prowess

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_nomadic
		}
		animation = hunting_falcon
		background = "gfx/interface/illustrations/event_scenes/ep2_hunt_poachers_camp.dds"
		localization_key = master_of_hunt_court_position_nomadic
	}
	
	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = hunting_shortbow_aim_arrow_default
		background = "gfx/interface/illustrations/event_scenes/tgp_hunt_generic_asia.dds"
		localization_key = master_of_hunt_celestial
	}
	
	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = hunting_shortbow_aim_arrow_default
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_hunt_generic_asia.dds"
	# }

	court_position_asset = {
		animation = hunting_shortbow_aim_arrow_default
		background = "gfx/interface/illustrations/event_scenes/ep2_hunt_poachers_camp.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = prowess
			multiply = 2
			max = 50
			desc = court_position_skill_prowess
		}
		add = {
			value = learning
			multiply = 1.5
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 100 }
			}
			add = {
				value = 40
				desc = court_position_hunter_3_trait
			}
		}
		else_if = {
			limit = {
				hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 50 }
			}
			add = {
				value = 30
				desc = court_position_hunter_2_trait
			}
		}
		else_if = {
			limit = { has_trait = lifestyle_hunter }
			add = {
				value = 20
				desc = court_position_hunter_1_trait
			}
		}
		if = {
			limit = { has_trait = brave }
			add = {
				value = 5
				desc = court_position_brave_trait
			}
		}
		if = {
			limit = { has_trait = craven }
			add = {
				value = -10
				desc = court_position_craven_trait
			}
		}
		# Events
		if = {
			limit = {
				has_character_modifier = ep2_beastmaster_modifier
			}
			add = {
				value = 10
				desc = court_position_beastmaster_modifier
			}
		}
		if = {
			limit = {
				has_character_flag = 7600_taking_child_to_hunt
			}
			add = {
				value = 10
				desc = 7600_taking_child_to_hunt
			}
		}
		# Estate - Owner bonus from stables
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_master_of_hunt_aptitude }
				}
			}
			add = {
				value = estate_increase_master_of_hunt_aptitude_value
				desc = estate_increase_master_of_hunt_aptitude_desc
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:master_of_hunt }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			master_of_hunt_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = master_of_hunt
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = master_of_hunt } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = master_of_hunt_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = master_of_hunt_total_salary_value
			}
		}
		prestige = {
			value = master_of_hunt_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = master_of_hunt_total_salary_value
		}
		prestige = {
			value = master_of_hunt_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			lifestyle_hunter_xp_gain_mult = 0.02
		}
		poor = {
			lifestyle_hunter_xp_gain_mult = 0.05
		}
		average = {
			lifestyle_hunter_xp_gain_mult = 0.08
		}
		good = {
			lifestyle_hunter_xp_gain_mult = 0.14
		}
		excellent = {
			lifestyle_hunter_xp_gain_mult = 0.2
		}
	}

	custom_employer_modifier_description = master_of_hunt_employer_custom_effect_description

	modifier = {
		monthly_martial_lifestyle_xp_gain_mult = 0.1
		lifestyle_hunter_xp_gain_mult = 0.25
	}

	custom_employee_modifier_description = master_of_hunt_employee_custom_effect_description

	on_court_position_received = {
		master_of_hunt_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		master_of_hunt_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		master_of_hunt_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = master_of_hunt_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely to hire if you're a hunter
			if = {
				limit = {
					has_trait = lifestyle_hunter
				}
				add = 25
			}
			if = {
				limit = {
					has_character_flag = hunts_a_lot
				}
				add = 1000
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = master_of_hunt }
			}
			add = 1000
		}
	}
}

master_assassin_court_position = {
	sort_order = 250
	max_available_positions = 1
	minimum_rank = county

	court_position_asset = {
		animation = assassin
		background = "gfx/interface/illustrations/event_scenes/fp2_corridor_night.dds"
	}


	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = intrigue
			multiply = 1.25
			max = 50
			desc = court_position_skill_intrigue
		}
		add = {
			value = prowess
			multiply = 2
			max = 50
			desc = court_position_skill_prowess
		}
		if = {
			limit = {
				dynasty ?= { has_dynasty_perk = fp3_khvarenah_legacy_1 }
			}
			add = {
				value = 10
				desc =  court_position_khvarenah_legacy_1
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 100
				}
			}
			add = {
				value = 15
				desc = court_position_blademaster_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 50
				}
			}
			add = {
				value = 10
				desc = court_position_blademaster_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
			}
			add = {
				value = 5
				desc = court_position_blademaster_1_trait
			}
		}
		if = {
			limit = {
				has_trait = deceitful
			}
			add = {
				value = 10
				desc = court_position_deceitful_trait
			}
		}
		if = {
			limit = {
				has_trait = murderer
			}
			add = {
				value = 20
				desc = court_position_murderer_trait
			}
		}
		if = {
			limit = {
				has_trait = order_member
			}
			add = {
				value = 25
				desc = court_position_order_member_trait
			}
		}
		if = {
			limit = {
				has_trait = faith_warrior
			}
			add = {
				value = 25
				desc = court_position_faith_warrior_trait
			}
		}
		if = {
			limit = {
				has_trait = zealous
			}
			add = {
				value = 25
				desc = court_position_zealous_trait
			}
		}
		if = {
			limit = {
				has_trait = brave
			}
			add = {
				value = 25
				desc = court_position_brave_trait
			}
		}
		if = {
			limit = {
				has_trait = compassionate
			}
			add = {
				value = -50
				desc = court_position_compassionate_trait
			}
		}
		if = {
			limit = {
				has_trait = just
			}
			add = {
				value = -20
				desc = court_position_just_trait
			}
		}
		if = {
			limit = {
				has_trait = honest
			}
			add = {
				value = -20
				desc = court_position_honest_trait
			}
		}
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_traveling_friends_value

		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:master_assassin }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		faith = {
			has_doctrine = tenet_fp3_fedayeen
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			master_assassin_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = master_assassin
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = master_assassin } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = master_assassin_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = master_assassin_total_salary_value
			}
		}
		prestige = {
			value = master_assassin_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = master_assassin_total_salary_value
		}
		prestige = {
			value = master_assassin_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			hostile_scheme_phase_duration_add = -3
			enemy_hostile_scheme_success_chance_add = -2
		}
		poor = {
			hostile_scheme_phase_duration_add = -6
			enemy_hostile_scheme_success_chance_add = -4
		}
		average = {
			hostile_scheme_phase_duration_add = -9
			enemy_hostile_scheme_success_chance_add = -6
		}
		good = {
			hostile_scheme_phase_duration_add = -12
			enemy_hostile_scheme_success_chance_add = -8
		}
		excellent = {
			hostile_scheme_phase_duration_add = -15
			enemy_hostile_scheme_success_chance_add = -10
		}
	}

	modifier = {
		monthly_intrigue_lifestyle_xp_gain_mult = 0.2
		owned_hostile_scheme_success_chance_add = 10
		max_hostile_schemes_add = 1
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
		scope:employee = {
			# Moves to pool after 1 day
			# Moving them directly here would invalidate the court position too early
			trigger_event = {
				id = courtier_guest_management.0999
				days = 1
			}
		}
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_fg_effect = {
			COURT_POSITION_TYPE = master_assassin_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely to hire one if you have high dread
			if = {
				limit = {
					dread > medium_dread
				}
				add = 25
			}
			# More likely if you have dread-traits
			if = {
				limit = {
					OR = {
						has_trait = sadistic
						has_trait = callous
						has_trait = arbitrary
					}
				}
				add = 25
			}
			# More likely if you are a zealous jihadist
			if = {
				limit = {
					has_trait = zealous
				}
				add = 25
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = master_assassin }
			}
			add = 1000
		}
	}
}

cultural_emissary_court_position = {
	sort_order = {
		value = 249
		if = { # Prio'd down for landless
			limit = {
				is_landed_or_landless_administrative = no
			}
			subtract = 240
		}
	}
	max_available_positions = 1
	minimum_rank = county
	skill = diplomacy

	court_position_asset = {
		animation = personality_compassionate
		background = "gfx/interface/illustrations/event_scenes/fp3_docks.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = num_of_known_languages
			subtract = 1
			multiply = 10
			max = 100
			desc = court_position_languages
		}
		if = {
			limit = {
				has_trait = just
			}
			add = {
				value = 15
				desc = court_position_just_trait
			}
		}
		if = {
			limit = {
				has_trait = gregarious
			}
			add = {
				value = 15
				desc = court_position_gregarious_trait
			}
		}
		if = {
			limit = {
				has_trait = diplomat
			}
			add = {
				value = 30
				desc = court_position_diplomat_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:cultural_emissary }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		dynasty ?= {
			has_dynasty_perk = ep1_culture_legacy_4
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}
	# Is this a valid position for this character? Also checks the scripted rule "is_eligible_for_court_positions" in code. (root is potential position holder)
	valid_character = {
		valid_camp_officer_trigger = {
			OFFICER = cultural_emissary
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 with obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = cultural_emissary
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = cultural_emissary } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = cultural_emissary_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = cultural_emissary_total_salary_value
			}
		}
		prestige = {
			value = cultural_emissary_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = cultural_emissary_total_salary_value
		}
		prestige = {
			value = cultural_emissary_prestige_salary_value
		}
		round = no
	}

	scaling_employer_modifiers = {
		terrible = {
			different_culture_opinion = 2
			different_faith_opinion = 2
			different_faith_county_opinion_mult = -0.05
		}
		poor = {
			different_culture_opinion = 5
			different_faith_opinion = 5
			different_faith_county_opinion_mult = -0.1
		}
		average = {
			different_culture_opinion = 10
			different_faith_opinion = 10
			different_faith_county_opinion_mult = -0.15
		}
		good = {
			different_culture_opinion = 15
			different_faith_opinion = 15
			different_faith_county_opinion_mult = -0.2
		}
		excellent = {
			different_culture_opinion = 20
			different_faith_opinion = 20
			different_faith_county_opinion_mult = -0.25
		}
	}

	modifier = {
		different_culture_opinion = 10
		different_faith_opinion = 10
		different_faith_county_opinion_mult = -0.2
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = cultural_emissary_court_position
		}
	}
	ai_position_score = {
		value = 100
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 100
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = cultural_emissary }
			}
			add = 1000
		}
	}
}

cave_hermit_court_position = {
	sort_order = 248
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = lantern
		background = "gfx/interface/illustrations/event_scenes/ep2_hunt_cave_entrance.dds"
		localization_key = cave_hermit_celestial
	}

	court_position_asset = {
		animation = lantern
		background = "gfx/interface/illustrations/event_scenes/ep2_hunt_cave_entrance.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 2.5
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				has_trait = lifestyle_mystic
				has_trait_xp = {
					trait = lifestyle_mystic
					value >= 100
				}
			}
			add = {
				value = 20
				desc = court_position_mystic_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_mystic
				has_trait_xp = {
					trait = lifestyle_mystic
					value >= 50
				}
			}
			add = {
				value = 10
				desc = court_position_mystic_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_mystic
			}
			add = {
				value = 5
				desc = court_position_mystic_1_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_herbalist
			}
			add = {
				value = 10
				desc = court_position_herbalist_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_gardener
			}
			add = {
				value = 10
				desc = court_position_gardener_trait
			}
		}
		#Events
		if = {
			limit = {
				has_character_modifier = possessed_prophetic_visions
			}
			add = {
				value = 30
				desc = possessed_prophetic_visions
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:cave_hermit }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		custom_tooltip = {
			text = cave_hermit_court_position_tt
			has_variable = encountered_recruitable_hermit
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			cave_hermit_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = cave_hermit
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = cave_hermit } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = cave_hermit_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = cave_hermit_total_salary_value
			}
		}
		round = no
	}

	received_salary = {
		gold = {
			value = cave_hermit_total_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			lifestyle_mystic_xp_gain_mult = 0.02
		}
		poor = {
			monthly_prestige = 0.05
			lifestyle_mystic_xp_gain_mult = 0.05
			monthly_learning_lifestyle_xp_gain_mult = 0.02
		}
		average = {
			monthly_prestige = 0.1
			lifestyle_mystic_xp_gain_mult = 0.08
			monthly_learning_lifestyle_xp_gain_mult = 0.04
		}
		good = {
			monthly_prestige = 0.15
			lifestyle_mystic_xp_gain_mult = 0.14
			monthly_learning_lifestyle_xp_gain_mult = 0.06
		}
		excellent = {
			monthly_prestige = 0.2
			lifestyle_mystic_xp_gain_mult = 0.2
			monthly_learning_lifestyle_xp_gain_mult = 0.1
		}
	}

	modifier = {
		general_opinion = 5
		lifestyle_mystic_xp_gain_mult = 0.25
		monthly_learning_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = cave_hermit_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely for very generous characters
			if = {
				limit = {
					ai_greed <= -75
				}
				add = 25
			}
			# Lots of gold to spend on inspirations!
			if = {
				limit = {
					gold >= 500
					monthly_character_income > monthly_character_expenses_plus_fourty_percent
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		scope:employee = {
			# Does the liege have a better candidate that they should be hiring instead?
			if = {
				limit = {
					scope:highest_available_aptitude > scope:employee_aptitude
				}
				add = -125
			}
			# More likely to pick a courtier with a high aptitude, less likely to pick one with low
			add = {
				value = scope:employee_aptitude
				multiply = 4
			}
		}

		add = scope:base_value
		add = court_position_candidate_score_base_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = cave_hermit }
			}
			add = 1000
		}
	}
}

chief_qadi_court_position = {
	sort_order = 233
	max_available_positions = 1
	minimum_rank = kingdom # Should only be available for kings and emperors
	skill = learning

	court_position_asset = {
		animation = personality_zealous
		background = "gfx/interface/illustrations/event_scenes/bp2_university_mena.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 2.5
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				exists = dynasty
				dynasty = { has_dynasty_perk = fp3_khvarenah_legacy_1 }
			}
			add = {
				value = 10
				desc =  court_position_khvarenah_legacy_1
			}
		}
		if = {
			limit = {
				has_trait = generous
			}
			add = {
				value = 15
				desc = court_position_generous_trait
			}
		}
		if = {
			limit = {
				has_trait = just
			}
			add = {
				value = 15
				desc = court_position_just_trait
			}
		}
		if = {
			limit = {
				has_trait = temperate
			}
			add = {
				value = 15
				desc = court_position_temperate_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 15
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = greedy
			}
			add = {
				value = -10
				desc = court_position_greedy_trait
			}
		}
		if = {
			limit = {
				has_trait = arbitrary
			}
			add = {
				value = -10
				desc = court_position_arbitrary_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:chief_qadi }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		#AGOT Modified
		# is_landed_or_landless_administrative = yes
		# NOT = { government_has_flag = government_is_nomadic }
		# trigger_if = {
		# 	limit = {
		# 		is_ai = yes
		# 		highest_held_title_tier <= tier_county
		# 	}
		# 	always = no
		# }
		always = no
	}

	valid_position = {
		#AGOT Modified
		# is_landed_or_landless_administrative = yes
		# has_religion = religion:islam_religion
		# highest_held_title_tier >= tier_kingdom
		always = no
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			chief_qadi_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = chief_qadi
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = chief_qadi } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = chief_qadi_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = chief_qadi_total_salary_value
			}
		}
		prestige = {
			value = chief_qadi_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = chief_qadi_total_salary_value
		}
		prestige = {
			value = chief_qadi_prestige_salary_value
		}
		round = no
	}

	base_employer_modifier = {
	}

	scaling_employer_modifiers = {
		terrible = {
			monthly_piety_gain_mult = 0.02
		}
		poor = {
			monthly_piety_gain_mult = 0.04
		}
		average = {
			monthly_piety_gain_mult = 0.06
			stewardship = 1
		}
		good = {
			monthly_piety_gain_mult = 0.08
			stewardship = 2
		}
		excellent = {
			monthly_piety_gain_mult = 0.1
			stewardship = 3
		}
	}

	modifier = {
		monthly_learning_lifestyle_xp_gain_mult = 0.1
		stewardship = 1
		monthly_piety_gain_mult = 0.1
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes #chief_qadi_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes #chief_qadi_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes #chief_qadi_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = chief_qadi_court_position
		}
	}
	ai_position_score = {
		value = 50
		scope:liege = {
			if = {
				limit = {
					ai_zeal >= -25
				}
				add = 150
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = chief_qadi }
			}
			add = 1000
		}
	}
}

court_gardener_court_position = {
	sort_order = 232
	max_available_positions = 1
	minimum_rank = county
	skill = stewardship

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = admiration
		background = "gfx/interface/illustrations/event_scenes/tgp_garden_asia.dds"
		localization_key = court_gardener_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = admiration
		background = "gfx/interface/illustrations/event_scenes/tgp_garden_asia.dds"
		localization_key = court_gardener_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = admiration
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_garden_asia.dds"
	# }

	court_position_asset = {
		animation = admiration
		background = "gfx/interface/illustrations/event_scenes/garden.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	aptitude_level_breakpoints = { 20 40 60 80 }

	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = stewardship
			multiply = 2.5
			max = 60
			desc = court_position_skill_stewardship
		}
		if = {
			limit = {
				has_trait = lifestyle_gardener
			}
			add = {
				value = 20
				desc = court_position_gardener_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_herbalist
			}
			add = {
				value = 10
				desc = court_position_herbalist_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 10
				desc = court_position_patient_trait
			}
		}
		if = { # Architect gives a tiny bonus, since building stuff is also a part of gardening
			limit = {
				has_trait = architect
			}
			add = {
				value = 5
				desc = court_position_architect_trait
			}
		}
		if = {
			limit = { employer.domicile ?= { has_domicile_parameter = increased_gardener_aptitude_1 } }
			add = {
				value = 0
				if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_gardener_aptitude_6 } }
					add = estate_increase_gardener_aptitude_value_6
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_gardener_aptitude_5 } }
					add = estate_increase_gardener_aptitude_value_5
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_gardener_aptitude_4 } }
					add = estate_increase_gardener_aptitude_value_4
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_gardener_aptitude_3 } }
					add = estate_increase_gardener_aptitude_value_3
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_gardener_aptitude_2 } }
					add = estate_increase_gardener_aptitude_value_2
				}
				else = { add = estate_increase_gardener_aptitude_value_1 }
				desc = estate_garden_building
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		# Japan
		if = {
			limit = {
				liege.house ?= { has_house_power_parameter = improved_stewardship_court_position_efficiency }
			}
			add = {
				value = cp_bonus_aptitude_value
				desc = improved_stewardship_court_position_efficiency_desc
			}
		}
		#AGOT Added Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_gardener }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		is_landed_or_landless_administrative = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		culture = { has_cultural_parameter = can_appoint_court_gardener }
	}

	valid_character = {
		scope:employee = {
			court_gardener_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_gardener
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_gardener_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_gardener_total_salary_value
			}
		}
		prestige = {
			value = court_gardener_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_gardener_total_salary_value
		}
		prestige = {
			value = court_gardener_prestige_salary_value
		}
		round = no
	}

	base_employer_modifier = {
		courtier_and_guest_opinion = 10
	}

	scaling_employer_modifiers = {
		terrible = {
			#AGOT Modified, development rebalance
			# character_capital_county_monthly_development_growth_add = 0.05
			monthly_prestige = 0.25
		}
		poor = {
			#AGOT Modified, development rebalance
			# character_capital_county_monthly_development_growth_add = 0.1
			monthly_prestige = 0.5
		}
		average = {
			#AGOT Modified, development rebalance
			# character_capital_county_monthly_development_growth_add = 0.2
			monthly_prestige = 1
		}
		good = {
			#AGOT Modified, development rebalance
			# character_capital_county_monthly_development_growth_add = 0.35
			monthly_prestige = 1.5
		}
		excellent = {
			#AGOT Modified, development rebalance
			# character_capital_county_monthly_development_growth_add = 0.5
			monthly_prestige = 2
		}
	}

	modifier = {
		monthly_stewardship_lifestyle_xp_gain_mult = 0.1
		#AGOT Disabled, development rebalance
		# character_capital_county_monthly_development_growth_add = 0.02
		stress_gain_mult = -0.25
	}

	on_court_position_received = {
		court_gardener_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_gardener_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_gardener_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_gardener_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 100
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 100
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_gardener }
			}
			add = 1000
		}
	}
}

court_scholar_court_position = { # FP3
	sort_order = 231
	max_available_positions = 1
	minimum_rank = kingdom

	court_position_asset = {
		animation = page_flipping
		background = "gfx/interface/illustrations/event_scenes/tgp_relaxing_room_asia.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 0
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 4
			desc = court_position_skill_learning
			max = 65
		}
		if = {
			limit = {
				#AGOT Modified Check employer instead of scope:liege (Unop)
				# scope:liege.dynasty ?= { has_dynasty_perk = fp3_khvarenah_legacy_1 }
				employer ?= {
					dynasty ?= { has_dynasty_perk = fp3_khvarenah_legacy_1 }
				}
			}
			add = {
				value = 10
				desc =  court_position_khvarenah_legacy_1
			}
		}
		if = {
			limit = { has_trait = theologian }
			add = {
				value = 15
				desc = court_position_theologian_trait
			}
		}
		if = {
			limit = { has_trait = scholar }
			add = {
				value = 15
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_physician
				has_trait_xp = {
					trait = lifestyle_physician
					value >= 100
				}
			}
			add = {
				value = 15
				desc = court_position_physician_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_physician
				has_trait_xp = {
					trait = lifestyle_physician
					value >= 50
				}
			}
			add = {
				value = 10
				desc = court_position_physician_2_trait
			}
		}
		else_if = {
			limit = { has_trait = lifestyle_physician }
			add = {
				value = 5
				desc = court_position_physician_1_trait
			}
		}
		if = {
			limit = {
				has_trait = intellect_good_3
			}
			add = {
				value = 20
				desc = court_position_intellect_good_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_2
			}
			add = {
				value = 15
				desc = court_position_intellect_good_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_1
			}
			add = {
				value = 10
				desc = court_position_intellect_good_1_trait
			}
		}
		else_if = {
			limit = {
				has_trait = shrewd
			}
			add = {
				value = 10
				desc = court_position_shrewd_trait
			}
		}
		if = {
			limit = {
				scope:liege.culture ?= {
					has_innovation = fp3_innovation_mural_sextant
				}
			}
			add = {
				value = 10
				desc = court_position_innovation_mural_sextant
			}
		}
		#AGOT Added
		if = {
			limit = {
				has_trait = inquisitive
			}
			add = {
				value = 10
				desc = court_position_inquistive_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_scholar }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_fp3_dlc_trigger = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Only Kingdoms+ can attract prominent enough scholars
	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_kingdom
		culture = { has_cultural_tradition = tradition_fp3_beacon_of_learning }
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			court_scholar_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_scholar
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_scholar_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_scholar_total_salary_value
			}
		}
		prestige = {
			value = court_scholar_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_scholar_total_salary_value
		}
		prestige = {
			value = court_scholar_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			cultural_head_fascination_mult = 0.02
		}
		poor = {
			cultural_head_fascination_mult = 0.04
		}
		average = {
			learning = 1
			cultural_head_fascination_mult = 0.06
		}
		good = {
			learning = 2
			cultural_head_fascination_mult = 0.08
		}
		excellent = {
			learning = 3
			cultural_head_fascination_mult = 0.10
		}
	}

	# custom_employer_modifier_description = court_scholar_employer_custom_effect_description

	base_employer_modifier = {
	}

	modifier = {
		general_opinion = 5
		monthly_learning_lifestyle_xp_gain_mult = 0.2
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_scholar_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			if = {
				limit = { has_trait = scholar }
				add = 25
			}
			if = {
				limit = { has_education_learning_trigger = yes }
				add = 50
			}
			if = {
				limit = {
					has_lifestyle = learning_lifestyle
				}
				add = 100
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = {
			limit = {
				exists = scope:firing_court_position
			}
			add = 100
			scope:employee = {
				# Does the liege have a better candidate that they should be hiring instead?
				if = {
					limit = {
						scope:highest_available_aptitude > scope:employee_aptitude
					}
					add = -75
 				}
			}
		}
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_scholar }
			}
			add = 1000
		}
	}
}

chronicler_court_position = { # CE1
	sort_order = 230
	max_available_positions = 1
	skill = diplomacy

	court_position_asset = {
		trigger = {
			OR = {
				government_has_flag = government_is_nomadic
				government_has_flag = government_is_tribal
			}
		}
		animation = storyteller
		background = "gfx/interface/illustrations/event_scenes/throneroom_tribal.dds"
		localization_key = chronicler_court_position_nomadic_tribal
	}
	
	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = writing
		background = "gfx/interface/illustrations/event_scenes/tgp_asia_throne_room.dds"
		localization_key = chronicler_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = writing
		background = "gfx/interface/illustrations/event_scenes/tgp_asia_throne_room.dds"
		localization_key = chronicler_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = writing
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_asia_throne_room.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		is_roman_emperor_trigger = yes
	# 	}
	# 	animation = writing
	# 	background = "gfx/interface/illustrations/event_scenes/ep3_byzantine_throne_room.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_mena_heritage_pillar_trigger = yes }
	# 	animation = writing
	# 	background = "gfx/interface/illustrations/event_scenes/throneroom_east.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_asian_heritage_pillar_trigger = yes }
	# 	animation = writing
	# 	background = "gfx/interface/illustrations/event_scenes/throneroom_india.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_european_heritage_pillar_trigger = yes }
	# 	animation = writing
	# 	background = "gfx/interface/illustrations/event_scenes/throneroom_mediterranean.dds"
	# }

	court_position_asset = {
		animation = writing
		background = "gfx/interface/illustrations/event_scenes/throneroom_west.dds"
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			domicile ?= {
				has_domicile_building_or_higher = court_yurt_01
			}
		}
		has_dlc_feature = legends
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = learning
			multiply = 1
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				has_trait = lifestyle_poet
			}
			add = {
				value = 15
				desc = court_position_poet_trait
			}
		}
		if = {
			limit = {
				has_trait = gregarious
			}
			add = {
				value = 15
				desc = court_position_gregarious_trait
			}
		}
		if = {
			limit = {
				has_trait = diplomat
			}
			add = {
				value = 30
				desc = court_position_diplomat_trait
			}
		}
		#Events
		if = {
			limit = {
				has_character_modifier = possessed_prophetic_visions
			}
			add = {
				value = 30
				desc = possessed_prophetic_visions
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:chronicler }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	valid_position = {
		trigger_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			domicile ?= {
				has_domicile_building_or_higher = court_yurt_01
			}
		}
		trigger_else = {
			is_landed_or_landless_administrative = yes
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			chronicler_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = chronicler
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = chronicler } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = chronicler_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = chronicler_total_salary_value
			}
		}
		prestige = {
			value = chronicler_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = chronicler_total_salary_value
		}
		prestige = {
			value = chronicler_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			legitimacy_loss_mult = -0.05
			monthly_dynasty_prestige = 0.01
		}
		poor = {
			legitimacy_loss_mult = -0.10
			monthly_dynasty_prestige = 0.02
		}
		average = {
			legitimacy_loss_mult = -0.15
			monthly_dynasty_prestige = 0.04
		}
		good = {
			legitimacy_loss_mult = -0.20
			monthly_dynasty_prestige = 0.07
		}
		excellent = {
			legitimacy_loss_mult = -0.25
			monthly_dynasty_prestige = 0.1
		}
	}


	modifier = {
		monthly_diplomacy_lifestyle_xp_gain_mult = 0.1
		monthly_prestige = 0.25
		general_opinion = 5
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = chronicler_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely for very generous characters
			if = {
				limit = {
					ai_greed <= -75
				}
				add = 25
			}
			# Lots of gold to spend on inspirations!
			if = {
				limit = {
					gold >= 500
					monthly_character_income > monthly_character_expenses_plus_fourty_percent
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		scope:employee = {
			# Does the liege have a better candidate that they should be hiring instead?
			if = {
				limit = {
					scope:highest_available_aptitude > scope:employee_aptitude
				}
				add = -125
			}
			# More likely to pick a courtier with a high aptitude, less likely to pick one with low
			add = {
				value = scope:employee_aptitude
				multiply = 4
			}
		}

		add = scope:base_value
		add = court_position_candidate_score_base_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = chronicler }
			}
			add = 1000
		}
	}
}

champion_court_position = { # EP1
	sort_order = {
		value = 215
		if = {
			limit = {
				house = { has_house_power_parameter = aspect_of_destruction }
				is_house_head = yes
			}
			add = 136
		}
	}
	max_available_positions = 1
	skill = prowess

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = throne_room_two_handed_passive_1
		background = "gfx/interface/illustrations/event_scenes/tgp_camp_asia.dds"
		localization_key = champion_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = throne_room_two_handed_passive_1
		background = "gfx/interface/illustrations/event_scenes/tgp_camp_asia.dds"
		localization_key = champion_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = throne_room_two_handed_passive_1
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_camp_asia.dds"
	# }

	court_position_asset = {
		animation = marshal_shield
		background = "gfx/interface/illustrations/event_scenes/ep2_tournament_western.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = prowess
			multiply = 4
			max = 50
			desc = court_position_skill_prowess
		}
		if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 100
				}
			}
			add = {
				value = 30
				desc = court_position_blademaster_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 50
				}
			}
			add = {
				value = 15
				desc = court_position_blademaster_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
			}
			add = {
				value = 5
				desc = court_position_blademaster_1_trait
			}
		}
		if = {
			limit = {
				has_trait = shieldmaiden
			}
			add = {
				value = 20
				desc = court_position_shieldmaiden_trait
			}
		}
		if = {
			limit = {
				has_trait = brave
			}
			add = {
				value = 20
				desc = court_position_brave_trait
			}
		}
		if = {
			limit = {
				has_trait = craven
			}
			add = {
				value = -10
				desc = court_position_craven_trait
			}
		}
		if = {
			limit = {
				has_trait = maimed
			}
			add = {
				value = -50
				desc = court_position_maimed_trait
			}
		}
		if = {
			limit = {
				has_trait = wounded_3
			}
			add = {
				value = -50
				desc = court_position_wounded_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = wounded_2
			}
			add = {
				value = -25
				desc = court_position_wounded_2_trait
			}
		}
		#Wounded_1 is ok since it's not a serious injury... yet
		if = {
			limit = {
				has_trait = blind
			}
			add = {
				value = -50
				desc = court_position_blind_trait
			}
		}
		if = {
			limit = {
				has_trait = infirm
			}
			add = {
				value = -75
				desc = court_position_infirm_trait
			}
		}
		if = {
			limit = {
				has_character_flag = best_knight_position
			}
			add = {
				value = 20
				desc = best_knight_position_desc
			}
		}
		if = {
			limit = {
				has_character_flag = competing_knight_position
				OR = {
					any_court_position_holder = {
						type = bodyguard_court_position
						has_character_flag = competing_knight_position
					}
					any_court_position_holder = {
						type = akolouthos_court_position
						has_character_flag = competing_knight_position
					}
				}
			}
			add = 30
			desc = competing_knight_position_desc
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		#AGOT Added Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:champion }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep1_court_positions_dlc_trigger = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added, KG serve this purpose
		NOT = {
			ruler_primary_title_has_kingsguard_trigger = yes
		}
		#AGOT Added - Bloodriders have their own version of Champion
		NOT = { faith = { has_doctrine_parameter = can_make_bloodriders } }
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			champion_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = champion
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = champion } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = champion_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = champion_total_salary_value
			}
		}
		round = no
	}

	received_salary = {
		gold = {
			value = champion_total_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			monthly_prestige = 0.02
			dread_decay_mult = -0.02
		}
		poor = {
			monthly_prestige = 0.05
			dread_decay_mult = -0.05
		}
		average = {
			monthly_prestige = 0.1
			dread_decay_mult = -0.1
		}
		good = {
			monthly_prestige = 0.2
			dread_decay_mult = -0.2
		}
		excellent = {
			monthly_prestige = 0.3
			dread_decay_mult = -0.3
		}
	}

	custom_employer_modifier_description = champion_employer_custom_effect_description

	modifier = {
		monthly_prestige = 0.25
		attraction_opinion = 10
		tourney_participant_xp_gain_mult = 0.25
		lifestyle_blademaster_xp_gain_mult = 0.25
	}

	on_court_position_received = {
		champion_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		champion_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		champion_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_fg_effect = {
			COURT_POSITION_TYPE = champion_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 25

		scope:liege = {
			# More likely to hire one if you can't fight yourself
			if = {
				limit = {
					NOT = { can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:liege } }
				}
				add = 50
			}
			# Less likely to hire one if you have high prowess
			if = {
				limit = {
					prowess >= high_skill_rating
				}
				add = -25
			}
			else_if = {
				limit = {
					prowess >= medium_skill_rating
				}
				add = -10
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 25
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = champion }
			}
			add = 1000
		}
	}
}

court_brewmaster_court_position = {
	sort_order = 210
	max_available_positions = 1
	minimum_rank = county
	skill = learning

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = wedding_drunk
		background = "gfx/interface/illustrations/event_scenes/tgp_tavern_asia.dds"
		localization_key = court_brewmaster_celestial
	}

	court_position_asset = {
		animation = wedding_drunk
		background = "gfx/interface/illustrations/event_scenes/bp1_wine_cellar.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 2.5
			max = 50
			desc = court_position_skill_learning
		}

		# Positive Traits
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 15
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 15
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = humble
			}
			add = {
				value = 15
				desc = court_position_humble_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add = {
				value = 15
				desc = court_position_reveler_trait
			}
		}
		# Negative Traits
		if = {
			limit = {
				has_trait = impatient
			}
			add = {
				value = -10
				desc = court_position_impatient_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -10
				desc = court_position_lazy_trait
			}
		}

		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_brewmaster }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		custom_tooltip = {
			text = court_brewmaster_requirement_tt
			any_sub_realm_barony = {
				county.holder = root
				title_province = { has_building_or_higher = breweries_01 }
			}
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			court_brewmaster_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_brewmaster
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = court_brewmaster } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_brewmaster_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_brewmaster_total_salary_value
			}
		}
		prestige = {
			value = court_brewmaster_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_brewmaster_total_salary_value
		}
		prestige = {
			value = court_brewmaster_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			county_opinion_add = 1
		}
		poor = {
			county_opinion_add = 2
		}
		average = {
			county_opinion_add = 3
		}
		good = {
			county_opinion_add = 6
		}
		excellent = {
			county_opinion_add = 10
		}
	}

	custom_employer_modifier_description = court_brewmaster_employer_custom_effect_description

	modifier = {
		general_opinion = 5
		monthly_prestige = 0.25
		learning = 1
	}

	on_court_position_received = {
		court_brewmaster_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_brewmaster_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_brewmaster_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_brewmaster_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_brewmaster }
			}
			add = 1000
		}
	}
}

lady_in_waiting_court_position = { # EP1
	sort_order = 205
	max_available_positions = 2
	minimum_rank = duchy # Should only be available for dukes or higher tiers
	skill = diplomacy

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = throne_room_conversation_1
		background = "gfx/interface/illustrations/event_scenes/tgp_wedding_bedroom_asia.dds"
		localization_key = lady_in_waiting_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = throne_room_conversation_1
		background = "gfx/interface/illustrations/event_scenes/tgp_wedding_bedroom_asia.dds"
		localization_key = lady_in_waiting_celestial
	}

	court_position_asset = {
		animation = throne_room_conversation_1
		background = "gfx/interface/illustrations/event_scenes/bedchamber.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		if = {
			limit = {
				exists = dynasty
				dynasty = { has_dynasty_perk = fp3_khvarenah_legacy_1 }
			}
			add = {
				value = 10
				desc =  court_position_khvarenah_legacy_1
			}
		}
		if = {
			limit = {
				has_trait = gregarious
			}
			add = {
				value = 40
				desc = court_position_gregarious_trait
			}
		}
		if = {
			limit = {
				has_trait = honest
			}
			add = {
				value = 10
				desc = court_position_honest_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:lady_in_waiting }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep1_court_positions_dlc_trigger = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_duchy
		#AGOT Modified, spouses/daughters can have ladies in waiting
		#is_female = yes
		OR = {
			any_child = {
				is_female = yes
				is_married = no
			}
			is_married = yes
			is_female = yes
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			lady_in_waiting_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = lady_in_waiting
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = lady_in_waiting } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = lady_in_waiting_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = lady_in_waiting_total_salary_value
			}
		}
		prestige = {
			value = lady_in_waiting_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = lady_in_waiting_total_salary_value
		}
		prestige = {
			value = lady_in_waiting_prestige_salary_value
		}
		round = no
	}

	is_powerful_agent = yes

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			stress_loss_mult = 0.10
			enemy_hostile_scheme_phase_duration_add = 1
		}
		poor = {
			stress_loss_mult = 0.15
			enemy_hostile_scheme_phase_duration_add = 2
		}
		average = {
			stress_loss_mult = 0.15
			enemy_hostile_scheme_phase_duration_add = 5
		}
		good = {
			stress_loss_mult = 0.15
			enemy_hostile_scheme_phase_duration_add = 7
		}
		excellent = {
			stress_loss_mult = 0.20
			enemy_hostile_scheme_phase_duration_add = 10
		}
	}

	modifier = {
		monthly_diplomacy_lifestyle_xp_gain_mult = 0.1
		liege_opinion = 25
		enemy_hostile_scheme_success_chance_max_add = -10
	}

	on_court_position_received = {
		lady_in_waiting_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		lady_in_waiting_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		lady_in_waiting_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_lin_effect = {
			COURT_POSITION_TYPE = lady_in_waiting_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		add = court_position_debt_considerations_value
		scope:liege = {
			# Less likely to hire an additional one if you're already employing one
			if = {
				limit = {
					employs_court_position = lady_in_waiting_court_position
				}
				add = -50
			}
		}
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		scope:liege = {
			# Opinion affects how likely they are to be hired
			if = {
				limit = {
					has_relation_lover = scope:employee
				}
				add = 100
			}
			else_if = {
				limit = {
					has_relation_friend = scope:employee
				}
				add = 75
			}
			else_if = {
				limit = {
					opinion = {
						target = scope:employee
						value >= high_positive_opinion
					}
				}
				add = 50
			}
			else_if = {
				limit = {
					opinion = {
						target = scope:employee
						value >= medium_positive_opinion
					}
				}
				add = 25
			}
		}
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = lady_in_waiting }
			}
			add = 1000
		}
	}
}

### Kingdom Tier Court Positions ### ( Sort order 199 - 100 )
royal_architect_court_position = { # EP1
	sort_order = 199
	max_available_positions = 1
	minimum_rank = kingdom # Should only be available for kings and emperors
	skill = stewardship

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = survey
		background = "gfx/interface/illustrations/event_scenes/tgp_chinese_city.dds"
		localization_key = royal_architect_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		culture = { has_cultural_pillar = heritage_japonic }
	# 	}
	# 	animation = survey
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_japanese_city.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = survey
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_market_asia.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		OR = {
	# 			culture_has_mena_heritage_pillar_trigger = yes
	# 			culture_has_south_asian_heritage_pillar_trigger = yes
	# 		}
	# 	}
	# 	animation = survey
	# 	background = "gfx/interface/illustrations/event_scenes/market_east.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_european_heritage_pillar_trigger = yes }
	# 	animation = survey
	# 	background = "gfx/interface/illustrations/event_scenes/ep3_medi_market.dds"
	# }

	court_position_asset = {
		animation = survey
		background = "gfx/interface/illustrations/event_scenes/market_west.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = stewardship
			multiply = 2.5
			max = 50
			desc = court_position_skill_stewardship
		}
		if = {
			limit = {
				exists = dynasty
				dynasty = { has_dynasty_perk = fp3_khvarenah_legacy_1 }
			}
			add = {
				value = 10
				desc =  court_position_khvarenah_legacy_1
			}
		}
		if = {
			limit = {
				has_trait = architect
			}
			add = {
				value = 40
				desc = court_position_architect_trait
			}
		}
		if = { #Hard to design building if you can't see them
			limit = {
				has_trait = blind
			}
			add = {
				value = -50
				desc = court_position_blind_trait
			}
		}
		#AGOT Added
		if = {
			limit = {
				has_trait = authoritative
			}
			add = {
				value = 15
				desc = court_position_authoritative_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:royal_architect }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		# Japan
		if = {
			limit = {
				liege.house ?= { has_house_power_parameter = improved_stewardship_court_position_efficiency }
			}
			add = {
				value = cp_bonus_aptitude_value
				desc = improved_stewardship_court_position_efficiency_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep1_court_positions_dlc_trigger = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_kingdom
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			royal_architect_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = royal_architect
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = royal_architect } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = royal_architect_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = royal_architect_total_salary_value
			}
		}
		prestige = {
			value = royal_architect_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = royal_architect_total_salary_value
		}
		prestige = {
			value = royal_architect_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			build_speed = -0.05
			domicile_build_speed = -0.05
			holding_build_speed = -0.02
		}
		poor = {
			build_speed = -0.1
			domicile_build_speed = -0.1
			holding_build_speed = -0.04
		}
		average = {
			build_speed = -0.15
			domicile_build_speed = -0.15
			holding_build_speed = -0.08
		}
		good = {
			build_speed = -0.2
			domicile_build_speed = -0.2
			holding_build_speed = -0.12
		}
		excellent = {
			build_speed = -0.3
			domicile_build_speed = -0.3
			holding_build_speed = -0.2
		}
	}

	modifier = {
		build_speed = -0.15
		build_gold_cost = -0.15
		monthly_stewardship_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		royal_architect_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		royal_architect_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		royal_architect_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = royal_architect_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# Unless you have lots of gold to spend on buildings, there's no point
			if = {
				limit = {
					short_term_gold < 500
					monthly_character_income < monthly_character_expenses_plus_fourty_percent
				}
				add = -100
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = royal_architect }
			}
			add = 1000
		}
	}
}

high_almoner_court_position = {
	sort_order = 190
	max_available_positions = 1
	minimum_rank = kingdom # Should only be available for kings and emperors
	skill = learning

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = prayer
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_temple_asia.dds"
	# }

	court_position_asset = {
		animation = prayer
		background = "gfx/interface/illustrations/event_scenes/temple.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 2.5
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				is_clergy = yes
			}
			add = {
				value = 20
				desc = court_position_clergy_trait
			}
		}
		if = {
			limit = {
				has_trait = generous
			}
			add = {
				value = 20
				desc = court_position_generous_trait
			}
		}
		if = {
			limit = {
				has_trait = theologian
			}
			add = {
				value = 20
				desc = court_position_theologian_trait
			}
		}
		if = {
			limit = {
				has_trait = compassionate
			}
			add = {
				value = 20
				desc = court_position_compassionate_trait
			}
		}
		if = {
			limit = {
				has_trait = greedy
			}
			add = {
				value = -10
				desc = court_position_greedy_trait
			}
		}
		if = {
			limit = {
				has_trait = profligate
			}
			add = {
				value = -10
				desc = court_position_profligate_trait
			}
		}
		if = {
			limit = {
				has_trait = avaricious
			}
			add = {
				value = -10
				desc = court_position_avaricious_trait
			}
		}
		if = {
			limit = {
				has_trait = devoted
				culture = { has_cultural_parameter = devoted_trait_bonuses }
			}
			add = {
				value = 20
				desc = tradition_monastic_communities_name
			}
		}
		if = {
			limit = {
				has_character_flag = plenty_to_donate_almoner
			}
			add = {
				value = 30
				desc = plenty_to_donate_almoner_desc
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:high_almoner }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_celestial
			government_has_flag = government_is_mandala
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_kingdom
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			high_almoner_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = high_almoner
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = high_almoner } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = high_almoner_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = high_almoner_total_salary_value
			}
		}
		round = no
	}

	received_salary = {
		gold = {
			value = high_almoner_total_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			monthly_piety_gain_mult = 0.02
		}
		poor = {
			monthly_piety_gain_mult = 0.05
		}
		average = {
			monthly_piety_gain_mult = 0.10
		}
		good = {
			monthly_piety_gain_mult = 0.15
		}
		excellent = {
			monthly_piety_gain_mult = 0.2
		}
	}

	modifier = {
		monthly_piety = 0.1
		monthly_piety_gain_mult = 0.1
		monthly_learning_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		high_almoner_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		high_almoner_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		high_almoner_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = high_almoner_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# Zealous AI's like this
			if = {
				limit = {
					ai_zeal > 75
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = high_almoner }
			}
			add = 1000
		}
	}
}

court_poet_court_position = { # EP1
	sort_order = 180
	max_available_positions = 1
	minimum_rank = county # Usually available only to kings++, but at times available to dukes - in Japan for Counts
	skill = diplomacy

	court_position_asset = {
		trigger = {
			government_has_flag = government_is_celestial
		}
		animation = storyteller
		background = "gfx/interface/illustrations/event_scenes/tgp_tavern_asia.dds"
		localization_key = court_poet_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = storyteller
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_tavern_asia.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_mena_heritage_pillar_trigger = yes }
	# 	animation = storyteller
	# 	background = "gfx/interface/illustrations/event_scenes/bp2_tavern_mena.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		root.culture ?= {
	# 			has_cultural_pillar = heritage_north_germanic
	# 		}
	# 	}
	# 	animation = storyteller
	# 	background = "gfx/interface/illustrations/event_scenes/tavern.dds"
	# 	localization_key = court_poet_skald
	# }

	court_position_asset = {
		animation = storyteller
		background = "gfx/interface/illustrations/event_scenes/tavern.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = learning
			multiply = 1
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				has_trait = gregarious
			}
			add = {
				value = 15
				desc = court_position_gregarious_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add = {
				value = 15
				desc = court_position_reveler_1_trait
			}
		}
		if = {
			limit = {
				has_trait = diplomat
			}
			add = {
				value = 15
				desc = court_position_diplomat_trait
			}
		}
		if = { #Cultural Tradition that improves the aptitude of characters of that culture
			limit = {
				NOT = {
					has_trait = lifestyle_poet
				}
			}
			add = {
				value = -20
				desc = court_position_no_poet_trait
			}
		}
		if = { #Cultural Tradition that improves the aptitude of characters of that culture
			limit = {
				culture = { has_cultural_parameter = characters_are_better_court_poets }
			}
			add = {
				value = 20
				desc = court_position_tradition_poetry
			}
		}
		#AGOT Disabled
		# if = { #Advancement movement
		# 	limit = {
		# 		top_participant_group:dynastic_cycle ?= {
		# 			participant_group_type = advancement_movement
		# 		}
		# 	}
		# 	add = {
		# 		value = 10
		# 		desc = court_position_poet_is_advancement
		# 	}
		# }
		#AGOT Disabled
		# if = { #Advancement movement
		# 	limit = {
		# 		liege ?= {
		# 			top_participant_group:dynastic_cycle ?= {
		# 				participant_group_type = advancement_movement
		# 			}
		# 		}
		# 	}
		# 	add = {
		# 		value = 10
		# 		desc = court_position_liege_is_advancement
		# 	}
		# }
		#Events
		if = {
			limit = {
				has_character_modifier = possessed_prophetic_visions
			}
			add = {
				value = 30
				desc = possessed_prophetic_visions
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_poet }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		if = {
			limit = { employer.domicile ?= { has_domicile_parameter = increased_poet_aptitude_1 } }
			add = {
				value = 0
				if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_poet_aptitude_6 } }
					add = estate_increase_gardener_aptitude_value_6
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_poet_aptitude_5 } }
					add = estate_increase_gardener_aptitude_value_5
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_poet_aptitude_4 } }
					add = estate_increase_gardener_aptitude_value_4
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_poet_aptitude_3 } }
					add = estate_increase_gardener_aptitude_value_3
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_poet_aptitude_2 } }
					add = estate_increase_gardener_aptitude_value_2
				}
				else = { add = estate_increase_gardener_aptitude_value_1 }
				desc = estate_poet_building
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		#ep1 or ep4 unlocks this
		OR = {
			has_ep1_court_positions_dlc_trigger = yes
			has_tgp_dlc_trigger = yes
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				government_has_flag = government_is_nomadic
				root.culture ?= {
					has_cultural_parameter = better_court_poets
				}
			}
			OR = {
				has_realm_law = nomadic_authority_5
				has_realm_law = nomadic_authority_4
				has_realm_law = nomadic_authority_3
				has_realm_law = nomadic_authority_2
			}
		}
		trigger_else_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			OR = {
				has_realm_law = nomadic_authority_5
				has_realm_law = nomadic_authority_4
				has_realm_law = nomadic_authority_3
			}
		}
		trigger_else_if = {
			limit = {
				root.culture ?= {
					has_cultural_parameter = better_court_poets
				}
			}
			highest_held_title_tier >= tier_duchy
		}
		trigger_else_if = {
			limit = {
				dynasty ?= { has_dynasty_perk = tgp_japan_legacy_2 }
			}
			highest_held_title_tier >= tier_county
		}
		trigger_else = {
			highest_held_title_tier >= tier_kingdom
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			court_poet_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_poet
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = court_poet } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_poet_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_poet_total_salary_value
			}
		}
		prestige = {
			value = court_poet_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_poet_total_salary_value
		}
		prestige = {
			value = court_poet_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			stress_loss_mult = 0.01
			court_grandeur_baseline_add = 1
		}
		poor = {
			stress_loss_mult = 0.025
			court_grandeur_baseline_add = 1
		}
		average = {
			stress_loss_mult = 0.05
			court_grandeur_baseline_add = 2
		}
		good = {
			stress_loss_mult = 0.075
			court_grandeur_baseline_add = 2
		}
		excellent = {
			stress_loss_mult = 0.1
			court_grandeur_baseline_add = 3
		}
	}

	custom_employer_modifier_description = court_poet_employer_custom_effect_description

	modifier = {
		stress_gain_mult = -0.25
		monthly_diplomacy_lifestyle_xp_gain_mult = 0.1
		general_opinion = 5
	}

	culture_modifier = {
		parameter = better_court_poets
		monthly_prestige = 0.25
	}

	on_court_position_received = {
		court_poet_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_poet_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_poet_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_poet_court_position
		}
	}

	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely for very generous characters
			if = {
				limit = {
					ai_greed <= -75
				}
				add = 25
			}
			# Lots of gold to spend on inspirations!
			if = {
				limit = {
					gold >= 500
					monthly_character_income > monthly_character_expenses_plus_fourty_percent
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		scope:employee = {
			# Does the liege have a better candidate that they should be hiring instead?
			if = {
				limit = {
					scope:highest_available_aptitude > scope:employee_aptitude
				}
				add = -125
			}
			# More likely to pick a courtier with a high aptitude, less likely to pick one with low
			add = {
				value = scope:employee_aptitude
				multiply = 4
			}
		}

		add = scope:base_value
		add = court_position_candidate_score_base_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_poet }
			}
			add = 1000
		}
	}
}

court_musician_court_position = {
	sort_order = 175
	max_available_positions = 1
	minimum_rank = duchy # Usually available only to kings++, but at times available to dukes
	skill = diplomacy

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = guqin_active
		background = "gfx/interface/illustrations/event_scenes/tgp_relaxing_room_asia.dds"
		localization_key = court_musician_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = guqin_active
		background = "gfx/interface/illustrations/event_scenes/tgp_relaxing_room_asia.dds"
		localization_key = court_musician_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = guqin_active
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_relaxing_room_asia.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_mena_heritage_pillar_trigger = yes }
	# 	animation = qanun_active
	# 	background = "gfx/interface/illustrations/event_scenes/bp1_relaxing_room_mena.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_european_heritage_pillar_trigger = yes }
	# 	animation = qanun_active
	# 	background = "gfx/interface/illustrations/event_scenes/ep3_relaxing_room.dds"
	# }

	court_position_asset = {
		animation = lute_active
		background = "gfx/interface/illustrations/event_scenes/bp1_relaxing_room_western.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		if = {
			limit = {
				has_trait = gregarious
			}
			add = {
				value = 30
				desc = court_position_gregarious_trait
			}
		}
		if = { #Being a poet helps a little bit
			limit = {
				has_trait = lifestyle_poet
			}
			add = {
				value = 10
				desc = court_position_poet_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add = {
				value = 15
				desc = court_position_reveler_1_trait
			}
		}
		if = {
			limit = {
				has_trait = shy
			}
			add = {
				value = -10
				desc = court_position_shy_trait
			}
		}
		if = { #Cultural Tradition that improves the aptitude of characters of that culture
			limit = {
				culture = { has_cultural_parameter = characters_are_better_court_musicians }
			}
			add = {
				value = 20
				desc = court_position_tradition_music_theory
			}
		}
		#Events
		if = {
			limit = {
				has_character_modifier = possessed_prophetic_visions
			}
			add = {
				value = 30
				desc = possessed_prophetic_visions
			}
		}
		if = {
			limit = {
				has_trait = beardless_eunuch
			}
			add = {
				value = 10
				desc = court_position_eunuch_falsetto
			}
		}
		if = {
			limit = { employer.domicile ?= { has_domicile_parameter = increased_musician_aptitude_1 } }
			add = {
				value = 0
				if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_musician_aptitude_6 } }
					add = estate_increase_gardener_aptitude_value_6
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_musician_aptitude_5 } }
					add = estate_increase_gardener_aptitude_value_5
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_musician_aptitude_4 } }
					add = estate_increase_gardener_aptitude_value_4
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_musician_aptitude_3 } }
					add = estate_increase_gardener_aptitude_value_3
				}
				else_if = {
					limit = { employer.domicile ?= { has_domicile_parameter = increased_musician_aptitude_2 } }
					add = estate_increase_gardener_aptitude_value_2
				}
				else = { add = estate_increase_gardener_aptitude_value_1 }
				desc = estate_musician_building
			}
		}
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_traveling_friends_value

		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_musician }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		OR = {
			is_landed_or_landless_administrative = yes
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				government_has_flag = government_is_nomadic
				root.culture ?= {
					has_cultural_parameter = better_court_musicians
				}
			}
			OR = {
				has_realm_law = nomadic_authority_5
				has_realm_law = nomadic_authority_4
				has_realm_law = nomadic_authority_3
				has_realm_law = nomadic_authority_2
			}
		}
		trigger_else_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			OR = {
				has_realm_law = nomadic_authority_5
				has_realm_law = nomadic_authority_4
				has_realm_law = nomadic_authority_3
			}
		}
		trigger_else_if = {
			limit = {
				root.culture ?= {
					has_cultural_parameter = better_court_musicians
				}
			}
			highest_held_title_tier >= tier_duchy
		}
		trigger_else = {
			highest_held_title_tier >= tier_kingdom
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			court_musician_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_musician
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = court_musician } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_musician_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_musician_total_salary_value
			}
		}
		prestige = {
			value = court_musician_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_musician_total_salary_value
		}
		prestige = {
			value = court_musician_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			stress_loss_mult = 0.01
			court_grandeur_baseline_add = 1
		}
		poor = {
			stress_loss_mult = 0.025
			court_grandeur_baseline_add = 1
		}
		average = {
			stress_loss_mult = 0.05
			court_grandeur_baseline_add = 2
		}
		good = {
			stress_loss_mult = 0.075
			court_grandeur_baseline_add = 2
		}
		excellent = {
			stress_loss_mult = 0.1
			court_grandeur_baseline_add = 3
		}
	}

	custom_employer_modifier_description = court_musician_employer_custom_effect_description

	modifier = {
		stress_gain_mult = -0.25
		monthly_diplomacy_lifestyle_xp_gain_mult = 0.1
		general_opinion = 5
	}

	culture_modifier = {
		parameter = better_court_musicians
		monthly_prestige = 0.25
	}

	on_court_position_received = {
		court_musician_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_musician_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_musician_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_musician_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 100
		 if = { # Having a musician is good if you have legitimacy
            limit = {
				scope:liege = {
					has_legitimacy = yes
				}
            }
            add = 50
        }
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		scope:employee = {
			# Does the liege have a better candidate that they should be hiring instead?
			if = {
				limit = {
					scope:highest_available_aptitude > scope:employee_aptitude
				}
				add = -125
			}
			# More likely to pick a courtier with a high aptitude, less likely to pick one with low
			add = {
				value = scope:employee_aptitude
				multiply = 4
			}
		}

		add = scope:base_value
		add = court_position_candidate_score_base_value

		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_musician }
			}
			add = 1000
		}
	}
}

cupbearer_court_position = {
	sort_order = 170
	max_available_positions = 1
	minimum_rank = kingdom # Should only be available for kings and emperors
	skill = diplomacy

	court_position_asset = {
		animation = toast_goblet
		background = "gfx/interface/illustrations/event_scenes/councilchamber.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		if = {
			limit = {
				has_trait = honest
			}
			add = {
				value = 15
				desc = court_position_honest_trait
			}
		}
		if = {
			limit = {
				has_trait = trusting
			}
			add = {
				value = 15
				desc = court_position_trusting_trait
			}
		}
		if = {
			limit = {
				has_trait = loyal
			}
			add = {
				value = 15
				desc = court_position_loyal_trait
			}
		}
		if = {
			limit = {
				has_trait = deceitful
			}
			add = {
				value = -10
				desc = court_position_deceitful_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:cupbearer }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_kingdom
		is_landed_or_landless_administrative = yes
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			cupbearer_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = cupbearer
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}

	salary = {
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	is_powerful_agent = yes

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			court_grandeur_baseline_add = 1
		}
		poor = {
			court_grandeur_baseline_add = 2
		}
		average = {
			court_grandeur_baseline_add = 2
		}
		good = {
			court_grandeur_baseline_add = 3
		}
		excellent = {
			court_grandeur_baseline_add = 3
		}
	}

	custom_employer_modifier_description = cupbearer_employer_custom_effect_description

	modifier = {
		monthly_diplomacy_lifestyle_xp_gain_mult = 0.1
		monthly_prestige = 0.25
	}

	on_court_position_received = {
		cupbearer_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		cupbearer_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		cupbearer_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_musician_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = cupbearer }
			}
			add = 1000
		}
	}
}

food_taster_court_position = { # EP1
	sort_order = 165
	max_available_positions = 1
	minimum_rank = duchy # Usually available only to kings++, but at times available to dukes
	skill = intrigue

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = drink
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_kitchen_asia.dds"
	# }

	court_position_asset = {
		animation = drink
		background = "gfx/interface/illustrations/event_scenes/bp1_kitchen_western.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 10
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = intrigue
			multiply = 3
			max = 50
			desc = court_position_skill_intrigue
		}
		if = {
			limit = {
				has_trait = gluttonous
			}
			add = {
				value = 25
				desc = court_position_gluttonous_trait
			}
		}
		if = {
			limit = {
				has_trait = comfort_eater
			}
			add = {
				value = 15
				desc = court_position_comfort_eater_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_herbalist
			}
			add = {
				value = 25
				desc = court_position_herbalist_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_gardener
			}
			add = {
				value = 15
				desc = court_position_gardener_trait
			}
		}
		if = {
			limit = {
				has_trait = trusting
			}
			add = {
				value = 15
				desc = court_position_trusting_trait
			}
		}
		if = {
			limit = {
				has_trait = loyal
			}
			add = {
				value = 15
				desc = court_position_loyal_trait
			}
		}
		if = {
			limit = {
				has_trait = inappetetic
			}
			add = {
				value = -50
				desc = court_position_inappetetic_trait
			}
		}
		if = {
			limit = {
				culture = { has_cultural_parameter = characters_are_better_food_tasters }
			}
			add = {
				value = 20
				desc = court_position_tradition_culinary_art
			}
		}
		if = {
			limit = {
				has_character_flag = food_taster_mettle_tested
			}
			add = {
				value = 30
				desc = food_taster_mettle_tested_desc
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:food_taster }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep1_court_positions_dlc_trigger = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		trigger_if = {
			limit = {
				root.culture ?= {
					has_cultural_parameter = better_food_tasters
				}
			}
			highest_held_title_tier >= tier_duchy
		}
		trigger_else = {
			highest_held_title_tier >= tier_kingdom
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:liege }
		}
	}

	valid_character = {
		scope:employee = {
			food_taster_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = food_taster
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = food_taster } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = food_taster_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = food_taster_total_salary_value
			}
		}
		prestige = {
			value = food_taster_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = food_taster_total_salary_value
		}
		prestige = {
			value = food_taster_prestige_salary_value
		}
		round = no
	}

	is_powerful_agent = yes

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			court_grandeur_baseline_add = 1
		}
		poor = {
			enemy_hostile_scheme_success_chance_add = -2
			court_grandeur_baseline_add = 1
		}
		average = {
			enemy_hostile_scheme_success_chance_add = -4
			court_grandeur_baseline_add = 2
		}
		good = {
			enemy_hostile_scheme_success_chance_add = -6
			court_grandeur_baseline_add = 2
		}
		excellent = {
			enemy_hostile_scheme_success_chance_add = -10
			court_grandeur_baseline_add = 3
		}
	}

	custom_employer_modifier_description = food_taster_employer_custom_effect_description

	base_employer_modifier = {
	}

	modifier = {
		diplomacy = 1
		enemy_hostile_scheme_success_chance_max_add = 10
	}

	culture_modifier = {
		parameter = better_food_tasters
		monthly_prestige = 0.25
	}

	on_court_position_received = {
		food_taster_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		food_taster_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		food_taster_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = food_taster_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = food_taster }
			}
			add = 1000
		}
	}
}

keeper_of_swans_court_position = {
	sort_order = 164
	max_available_positions = 1
	#AGOT Disabled
	# minimum_rank = kingdom # Should only be available for kings and emperors
	skill = stewardship

	court_position_asset = {
		animation = personality_compassionate
		background = "gfx/interface/illustrations/event_scenes/bp2_courtyard.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 40
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = stewardship
			multiply = 4
			max = 50
			desc = court_position_skill_stewardship
		}
		if = {
			limit = {
				hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 100 }
			}
			add = {
				value = 20
				desc = court_position_hunter_3_trait
			}
		}
		else_if = {
			limit = {
				hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 50 }
			}
			add = {
				value = 10
				desc = court_position_hunter_2_trait
			}
		}
		else_if = {
			limit = { has_trait = lifestyle_hunter }
			add = {
				value = 5
				desc = court_position_hunter_1_trait
			}
		}
		if = {
			limit = {
				has_trait = blind # Can't see the damn birds
			}
			add = {
				value = -20
				desc = court_position_blind_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:keeper_of_swans }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		# Japan
		if = {
			limit = {
				liege.house ?= { has_house_power_parameter = improved_stewardship_court_position_efficiency }
			}
			add = {
				value = cp_bonus_aptitude_value
				desc = improved_stewardship_court_position_efficiency_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_celestial
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		# AGOT Modified
		# highest_held_title_tier >= tier_kingdom
		# culture = {
		# 	has_cultural_pillar = heritage_west_germanic
		# }
		dynasty = dynasty:dynn_Swann
		NOT = { has_government = nights_watch_government }
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			keeper_of_swans_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = keeper_of_swans
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = keeper_of_swans } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = keeper_of_swans_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = keeper_of_swans_total_salary_value
			}
		}
		prestige = {
			value = keeper_of_swans_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = keeper_of_swans_total_salary_value
		}
		prestige = {
			value = keeper_of_swans_prestige_salary_value
		}
		round = no
	}

	base_employer_modifier = {
		diplomacy_per_prestige_level = 1
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
		}
		poor = {
			court_grandeur_baseline_add = 1
		}
		average = {
			court_grandeur_baseline_add = 1
		}
		good = {
			court_grandeur_baseline_add = 2
		}
		excellent = {
			court_grandeur_baseline_add = 2
		}
	}

	modifier = {
		diplomacy = 2
		general_opinion = 5
	}

	on_court_position_received = {
		keeper_of_swans_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		keeper_of_swans_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		keeper_of_swans_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = keeper_of_swans_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 25
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 25
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = keeper_of_swans }
			}
			add = 1000
		}
	}
}

court_jester_court_position = {
	sort_order = 150
	max_available_positions = 1
	minimum_rank = duchy
	skill = diplomacy

	court_position_asset = {
		trigger = { government_has_flag = government_is_nomadic }
		animation = dancing
		background = "gfx/interface/illustrations/event_scenes/ep2_feast_steppe.dds"
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = dancing
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_feast_asia.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_african_heritage_pillar_trigger = yes }
	# 	animation = dancing
	# 	background = "gfx/interface/illustrations/event_scenes/ep2_feast_sub_saharan.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_mena_heritage_pillar_trigger = yes }
	# 	animation = dancing
	# 	background = "gfx/interface/illustrations/event_scenes/ep2_feast_mena.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_asian_heritage_pillar_trigger = yes }
	# 	animation = dancing
	# 	background = "gfx/interface/illustrations/event_scenes/ep2_feast_indian.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_european_heritage_pillar_trigger = yes }
	# 	animation = dancing
	# 	background = "gfx/interface/illustrations/event_scenes/ep3_feast_byzantine.dds"
	# }

	court_position_asset = {
		animation = dancing
		background = "gfx/interface/illustrations/event_scenes/feast.dds"
	}

	opinion = {
		value = court_jester_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		if = {
			limit = {
				has_trait = gregarious
			}
			add = {
				value = 20
				desc = court_position_gregarious_trait
			}
		}
		if = {
			limit = {
				has_trait = stubborn
			}
			add = {
				value = 20
				desc = court_position_stubborn_trait
			}
		}
		if = {
			limit = {
				has_trait = shrewd
			}
			add = {
				value = 20
				desc = court_position_shrewd_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_poet
			}
			add = {
				value = 10
				desc = court_position_poet_trait
			}
		}
		if = { # An acrobatic jester is a good jester
			limit = {
				has_trait = athletic
			}
			add = {
				value = 10
				desc = court_position_athletic_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		#AGOT Disabled
		# if = { # ep3_emperor_yearly.2090
		# 	limit = {
		# 		has_character_flag = famous_mime_court
		# 	}
		# 	add = {
		# 		value = 30
		# 		desc = court_position_famous_mime
		# 	}
		# }
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_jester }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_celestial
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_duchy
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			court_jester_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_jester
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = court_jester } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_jester_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_jester_total_salary_value
			}
		}
		prestige = {
			value = court_jester_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_jester_total_salary_value
		}
		prestige = {
			value = court_jester_prestige_salary_value
		}
		round = no
	}

	custom_employer_modifier_description = court_jester_employer_custom_effect_description

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			stress_gain_mult = -0.01
		}
		poor = {
			stress_gain_mult = -0.02
		}
		average = {
			stress_gain_mult = -0.03
		}
		good = {
			stress_gain_mult = -0.05
		}
		excellent = {
			stress_gain_mult = -0.08
		}
	}

	modifier = {
		monthly_prestige = -0.5
		hostile_scheme_phase_duration_add = -3
		owned_hostile_scheme_success_chance_add = -10
	}

	on_court_position_received = {
		court_jester_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_jester_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_jester_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_jester_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely for very stressed characters
			if = {
				limit = {
					stress_level >= 1
				}
				add = 20
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		scope:employee = {
			if = {
				limit = {
					OR = {
						is_close_family_of = scope:liege
						is_consort_of = scope:liege
						is_ruler = yes
						AND = {
							exists = dynasty
							dynasty = {
								any_dynasty_member = {
									count <= 2
								}
							}
						}
						is_clergy = yes
						is_theocratic_lessee = yes
					}
					NOR = {
						has_relation_potential_rival = scope:liege
						has_relation_rival = scope:liege
					}
				}
				add = -1000
			}
		}
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_jester }
			}
			add = 1000
		}
	}
}

executioner_court_position = { # EP1
	sort_order = {
		value = 140
		if = {
			limit = {
				house = { has_house_power_parameter = aspect_of_destruction }
				is_house_head = yes
			}
			add = 220
		}
	}
	max_available_positions = 1
	minimum_rank = kingdom # Should only be available for kings and emperors
	skill = intrigue

	court_position_asset = {
		trigger = {
			OR = {
				government_has_flag = government_is_tribal
				government_has_flag = government_is_nomadic
			}
		}
		animation = marshal_axe
		background = "gfx/interface/illustrations/event_scenes/fp1_tribal_prison.dds"
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_mena_heritage_pillar_trigger = yes }
	# 	animation = marshal_axe
	# 	background = "gfx/interface/illustrations/event_scenes/fp2_prison.dds"
	# }

	court_position_asset = {
		animation = marshal_axe
		background = "gfx/interface/illustrations/event_scenes/gallows.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = intrigue
			multiply = 2.5
			max = 50
			desc = court_position_skill_intrigue
		}
		add = {
			value = prowess
			multiply = 2
			max = 50
			desc = court_position_skill_prowess
		}
		if = {
			limit = {
				has_trait = torturer
			}
			add = {
				value = 25
				desc = court_position_torturer_trait
			}
		}
		if = {
			limit = {
				has_trait = sadistic
			}
			add = {
				value = 20
				desc = court_position_sadistic_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:executioner }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep1_court_positions_dlc_trigger = yes
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_celestial
		}
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_kingdom
		#AGOT Added
		NAND = {
			culture = { has_cultural_pillar = heritage_first_man }
			NOR = {
				has_trait = lazy
				has_trait = craven
				has_trait = arbitrary
			}
		}
	}

	is_shown_character = {
		scope:employee = {
			tgp_is_ceremonial_liege_trigger = no
		}
	}

	valid_character = {
		scope:employee = {
			executioner_validity_trigger = { EMPLOYER = scope:liege }
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = executioner
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = executioner } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		prestige = {
			value = executioner_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		prestige = {
			value = executioner_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			dread_gain_mult = 0.05
			dread_decay_mult = -0.05
		}
		poor = {
			dread_gain_mult = 0.1
			dread_decay_mult = -0.1
		}
		average = {
			dread_gain_mult = 0.15
			dread_decay_mult = -0.15
		}
		good = {
			dread_gain_mult = 0.20
			dread_decay_mult = -0.20
		}
		excellent = {
			dread_gain_mult = 0.25
			dread_decay_mult = -0.25
		}
	}

	custom_employer_modifier_description = executioner_employer_custom_effect_description

	modifier = {
		dread_baseline_add = 25
		general_opinion = -15
		dread_gain_mult = 0.5
	}

	on_court_position_received = {
		# Consume hook if that is what is being used to assign them as Executioner
		scope:liege = {
			if = {
				limit = {
					NOR = {
						has_imprisonment_reason = scope:employee
						scope:employee = { is_imprisoned_by = scope:liege }
					}
					has_usable_hook = scope:employee
				}
				use_hook = scope:employee
			}
		}
		executioner_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		executioner_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		executioner_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = executioner_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely to hire one if you have high dread
			if = {
				limit = {
					dread > medium_dread
				}
				add = 25
			}
			# More likely if you have dread-traits
			if = {
				limit = {
					OR = {
						has_trait = sadistic
						has_trait = callous
						has_trait = arbitrary
					}
				}
				add = 25
			}
		}
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = executioner }
			}
			add = 1000
		}
	}
}

bodyguard_court_position = { # EP1
	sort_order = {
		value = 131
		if = { # Lower for landless
			limit = {
				is_landed_or_landless_administrative = no
			}
			subtract = 101
		}
		if = {
			limit = {
				#AGOT Modified
				#house = { has_house_power_parameter = aspect_of_destruction }
				house ?= { has_house_power_parameter = aspect_of_destruction }
				is_house_head = yes
			}
			add = 220
		}
	}
	max_available_positions = 2

	skill = prowess

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		culture = { has_cultural_pillar = heritage_mongolic }
	# 	}
	# 	animation = menacing
	# 	background = "gfx/interface/illustrations/event_scenes/corridor.dds"
	# 	localization_key = bodyguard_court_position_nomadic
	# }
	
	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = menacing
		background = "gfx/interface/illustrations/event_scenes/tgp_chinese_corridor_day.dds"
		localization_key = bodyguard_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = menacing
		background = "gfx/interface/illustrations/event_scenes/tgp_chinese_corridor_day.dds"
		localization_key = bodyguard_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = menacing
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_chinese_corridor_day.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_asian_heritage_pillar_trigger = yes }
	# 	animation = menacing
	# 	background = "gfx/interface/illustrations/event_scenes/bp1_corridor_indian_day.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		OR = {
	# 			culture_has_mena_heritage_pillar_trigger = yes
	# 			culture_has_south_european_heritage_pillar_trigger = yes
	# 		}
	# 	}
	# 	animation = menacing
	# 	background = "gfx/interface/illustrations/event_scenes/fp2_corridor_day.dds"
	# }

	court_position_asset = {
		animation = menacing
		background = "gfx/interface/illustrations/event_scenes/corridor.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = soon_forgiven_perk
				}
			}
			add = {
				value = 10
				desc = court_position_soon_forgiven_perk
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = friend }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_friend
			}
		}
		# Nomad Yurt
		if = {
			limit = {
				employer.domicile ?= {
					has_domicile_building_or_higher = bodyguard_yurt_01
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_bodyguard_aptitude_lvl_3
						}
					}
					add = 30
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_bodyguard_aptitude_lvl_2
						}
					}
					add = 20
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_bodyguard_aptitude_lvl_1
						}
					}
					add = 10
				}
				desc = bodyguard_yurt_01_domicile_building
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				any_relation = { type = lover }
			}
			add = {
				value = 5
				desc = court_position_positions_of_power_perk_lover
			}
		}
		if = {
			limit = {
				employer ?= {
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
					has_perk = positions_of_power_perk
				}
				is_married = yes
			}
			add = {
				value = 10
				desc = court_position_positions_of_power_perk_marriage
			}
		}
		add = {
			value = prowess
			multiply = 4
			max = 50
			desc = court_position_skill_prowess
		}
		if = {
			limit = {
				has_trait = shieldmaiden
			}
			add = {
				value = 20
				desc = court_position_shieldmaiden_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 100
				}
			}
			add = {
				value = 15
				desc = court_position_blademaster_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 50
				}
			}
			add = {
				value = 10
				desc = court_position_blademaster_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
			}
			add = {
				value = 5
				desc = court_position_blademaster_1_trait
			}
		}
		if = {
			limit = {
				has_trait = gallant
			}
			add = {
				value = 5
				desc = court_position_gallant_trait
			}
		}
		if = {
			limit = {
				has_trait = brave
			}
			add = {
				value = 20
				desc = court_position_brave_trait
			}
		}
		if = {
			limit = {
				has_trait = paranoid
			}
			add = {
				value = 10
				desc = court_position_paranoid_trait
			}
		}
		if = {
			limit = {
				has_trait = craven
			}
			add = {
				value = -15
				desc = court_position_craven_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		#AGOT Disabled
		# if = {
		# 	limit = {
		# 		has_trait = varangian
		# 		employer ?= {
		# 			has_title = title:e_byzantium
		# 			employs_court_position = akolouthos_court_position
		# 		}
		# 	}
		# 	add = {
		# 		value = 5
		# 		multiply = employer.court_position:akolouthos_court_position.aptitude:akolouthos_court_position
		# 		desc = court_position_akolouthos_bonus
		# 	}
		# }
		if = {
			limit = {
				employer ?= {
					culture = {
						has_cultural_parameter = reduced_bodyguard_aptitude
					}
				}
			}
			add = {
				value = -10
				desc = court_position_palace_politics
			}
		}
		#Pick _one_
		if = {
			limit = {
				employer ?= { has_relation_soulmate = prev } #The considered character
			}
			add = {
				value = 40
				desc = court_position_soulmate
			}
		}
		else_if = {
			limit = {
				employer ?= { has_relation_best_friend = prev } #The considered character
			}
			add = {
				value = 30
				desc = court_position_best_friend
			}
		}
		else_if = {
			limit = {
				employer ?= { has_relation_friend = prev } #The considered character
			}
			add = {
				value = 15
				desc = court_position_friend
			}
		}
		if = {
			limit = {
				has_character_flag = best_knight_position
			}
			add = {
				value = 20
				desc = best_knight_position_desc
			}
		}
		if = {
			limit = {
				has_character_flag = competing_knight_position
				OR = {
					any_court_position_holder = {
						type = bodyguard_court_position
						has_character_flag = competing_knight_position
						NOT = { this = prev }
					}
					any_court_position_holder = {
						type = champion_court_position
						has_character_flag = competing_knight_position
					}
					any_court_position_holder = {
						type = akolouthos_court_position
						has_character_flag = competing_knight_position
					}
				}
			}
			add = 30
			desc = competing_knight_position_desc
		}
		# Estate bonus
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_bodyguard_aptitude_1 }
				}
			}
			add = {
				value = estate_increase_bodyguard_aptitude_1_value
				desc = estate_increase_bodyguard_aptitude_desc
			}
		}
		if = {
			limit = {
				liege ?= {
					domicile ?= { has_domicile_parameter = estate_increase_bodyguard_aptitude_2 }
				}
			}
			add = {
				value = estate_increase_bodyguard_aptitude_2_value
				desc = estate_increase_bodyguard_aptitude_desc
			}
		}

		if = {
			limit = {
				has_perk = praetorian_guard_perk
			}
			add = {
				value = 15
				desc = court_position_bodyguard_modifier
			}
		}
		if = {
			limit = {
				liege ?= { has_perk = praetorian_guard_perk }
			}
			add = {
				value = 15
				desc = court_position_bodyguard_liege_modifier
			}
		}
		
		if = { # Cherbi / Chief Bodyguard bonus
			limit = {
				exists = liege.court_position:cherbi_court_position
			}
			switch = {
				trigger = "liege.court_position:cherbi_court_position.aptitude(cherbi_court_position)"
				1 = { 
					add = {
						value = 1 
						desc = court_position_bodyguard_cherbi_modifier
					}
				}
				2 = {
					add = {
						value = 4
						desc = court_position_bodyguard_cherbi_modifier
					}
				}
				3 = { 
					add = {
						value = 7
						desc = court_position_bodyguard_cherbi_modifier
					}
				}
				4 = {
					add = {
						value = 10
						desc = court_position_bodyguard_cherbi_modifier
					}
				}
				5 = {
					add = {
						value = 15
						desc = court_position_bodyguard_cherbi_modifier
					}
				}
			}
		}
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:bodyguard }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
		#AGOT Added
		if = {
			limit = {
				employer ?= {
					agot_is_landless_pirate_character = yes
					has_perk = toe_the_line_perk
				}
			}
			add = {
				value = 10
				desc = court_position_positions_of_landless_pirate_toe_the_line_perk_bonus
			}
		}
	}

	is_shown = {
		has_ep1_court_positions_dlc_trigger = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added, KG serve this purpose
		NOT = { ruler_primary_title_has_kingsguard_trigger = yes }
		#Bloodriders have their own version of Bodyguard
		NOT = { faith = { has_doctrine_parameter = can_make_bloodriders } }
		agot_is_landless_nw_character = no
		NOT = { government_has_flag = government_is_custom_landless }
	}

	valid_position = {
		trigger_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			domicile ?= {
				has_domicile_building_or_higher = character_warfare_yurt_01
			}
		}
	}

	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
			#AGOT Added - Bloodriders have their own version of Bodyguard
			NOT = { faith = { has_doctrine_parameter = can_make_bloodriders } }
		}
	}

	valid_character = {
		valid_camp_officer_trigger = {
			OFFICER = bodyguard
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = bodyguard
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = bodyguard } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = bodyguard_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = bodyguard_total_salary_value
			}
		}
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		gold = {
			value = bodyguard_total_salary_value
		}
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	is_powerful_agent = yes

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			enemy_hostile_scheme_success_chance_max_add = -1
		}
		poor = {
			enemy_hostile_scheme_success_chance_max_add = -2
		}
		average = {
			enemy_hostile_scheme_success_chance_max_add = -5
		}
		good = {
			enemy_hostile_scheme_success_chance_max_add = -7
		}
		excellent = {
			enemy_hostile_scheme_success_chance_max_add = -10
		}
	}

	custom_employer_modifier_description = bodyguard_employer_custom_effect_description

	modifier = {
		dread_baseline_add = 10
		intrigue = 1
		enemy_hostile_scheme_success_chance_max_add = -10
	}

	on_court_position_received = {
		bodyguard_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		bodyguard_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		bodyguard_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_fg_effect = {
			COURT_POSITION_TYPE = bodyguard_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# More likely if you're scared all the time
			if = {
				limit = {
					has_trait = paranoid
				}
				add = 50
			}

			# Less likely to hire an additional one if you're already employing one
			if = {
				limit = {
					employs_court_position = bodyguard_court_position
				}
				add = -50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		#counter the base_value for landless adventurers, as it assumes you would have a monthly income, don't worry court position don't have salary when hired by landless adventurers
    	if = {
    		limit = {
    			scope:liege = {
    				#AGOT Modified
    				# government_has_flag = government_is_landless_adventurer
    				OR = {
    					government_has_flag = government_is_landless_adventurer
    					agot_is_landless_character = yes
    				}
    			}
    		}
    		add = {
    			value = scope:base_value
    			multiply = -1
    		}
    	}
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = bodyguard }
			}
			add = 1000
		}
	}
}

court_artificer_court_position = { # EP1
	sort_order = 130
	max_available_positions = 3
	minimum_rank = kingdom
	skill = learning

	court_position_asset = {
		trigger = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = page_flipping
		background = "gfx/interface/illustrations/event_scenes/tgp_study_asia.dds"
		localization_key = court_artificer_celestial_imperial
	}

	court_position_asset = {
		trigger = {
			is_independent_ruler = no
			highest_held_title_tier <= tier_empire
			government_has_flag = government_is_celestial
		}
		animation = page_flipping
		background = "gfx/interface/illustrations/event_scenes/tgp_study_asia.dds"
		localization_key = court_artificer_celestial
	}

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		culture = { has_cultural_pillar = heritage_japonic }
	# 	}
	# 	animation = page_flipping
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_study_japan.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
	# 	animation = page_flipping
	# 	background = "gfx/interface/illustrations/event_scenes/tgp_study_asia.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = {
	# 		OR = {
	# 			culture_has_south_asian_heritage_pillar_trigger = yes
	# 			culture_has_mena_heritage_pillar_trigger = yes
	# 		}
	# 	}
	# 	animation = page_flipping
	# 	background = "gfx/interface/illustrations/event_scenes/bp2_study_indian.dds"
	# }

	#AGOT Disabled
	# court_position_asset = {
	# 	trigger = { culture_has_south_european_heritage_pillar_trigger = yes }
	# 	animation = page_flipping
	# 	background = "gfx/interface/illustrations/event_scenes/ep3_medi_study.dds"
	# }

	court_position_asset = {
		animation = page_flipping
		background = "gfx/interface/illustrations/event_scenes/study.dds"
	}

	opinion = {
		value = ceremonial_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = prowess
			#AGOT Modified, vanilla bug
			#desc = court_position_skill_intrigue
			desc = court_position_skill_prowess
		}
		add = {
			value = diplomacy
			desc = court_position_skill_diplomacy
		}
		add = {
			value = intrigue
			desc = court_position_skill_intrigue
		}
		add = {
			value = learning
			desc = court_position_skill_learning
		}
		add = {
			value = martial
			desc = court_position_skill_martial
		}
		add = {
			value = stewardship
			desc = court_position_skill_stewardship
		}
		if = {
			limit = {
				has_character_modifier = local_artisan_modifier
			}
			add = {
				value = -20
				desc = local_artisan_modifier
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		#add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_artificer }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	is_shown = {
		is_landed_or_landless_administrative = yes
		has_ep1_court_positions_dlc_trigger = yes
		NOT = { government_has_flag = government_is_nomadic }
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
		#AGOT Added
		NOT = { has_government = nights_watch_government }
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		has_royal_court = yes
	}

	is_shown_character = {
		scope:employee = {
			OR = {
				has_completed_inspiration = yes
				custom_tooltip = {
					text = has_an_inspiration
					exists = inspiration
				}
			}
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		valid_camp_officer_trigger = {
			OFFICER = court_artificer
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_artificer
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = court_artificer } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_artificer_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_artificer_total_salary_value
			}
		}
		prestige = {
			value = court_artificer_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_artificer_total_salary_value
		}
		prestige = {
			value = court_artificer_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			court_grandeur_baseline_add = 0
		}
		poor = {
			court_grandeur_baseline_add = 1
		}
		average = {
			court_grandeur_baseline_add = 1
		}
		good = {
			court_grandeur_baseline_add = 2
		}
		excellent = {
			court_grandeur_baseline_add = 2
		}
	}

	custom_employer_modifier_description = court_artificer_employer_custom_effect_description

	modifier = {
		monthly_learning_lifestyle_xp_gain_mult = 0.1
		artifact_decay_reduction_mult = -0.2
	}

	on_court_position_received = {
		basic_gained_court_position_effect = yes
	}
	on_court_position_revoked = {
		basic_revoked_court_position_effect = yes
		scope:employee = {
			# Moves to pool after 1 day
			# Moving them directly here would invalidate the court position too early
			trigger_event = {
				id = courtier_guest_management.0999
				days = 1
			}
		}
	}
	on_court_position_invalidated = {
		basic_invalidated_court_position_effect = yes
	}
	on_court_position_vacated = {
		# CPAGOT changed
		court_position_vacated_event_art_effect = {
			COURT_POSITION_TYPE = court_artificer_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 50
		scope:liege = {
			# Unless you have lots of gold to spend, there's no point
			if = {
				limit = {
					short_term_gold < 500
					monthly_character_income < monthly_character_expenses_plus_fourty_percent
				}
				add = -100
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_artificer }
			}
			add = 1000
		}
	}
}

### Special Court Positions ### ( Sort order 99 - 50 )

garuda_court_position = {
	sort_order = 65
	max_available_positions = 2
	minimum_rank = kingdom # Should only be available for kings and emperors
	skill = martial

	court_position_asset = {
		animation = marshal_shield
		background = "gfx/interface/illustrations/event_scenes/bp1_courtyard_indian.dds"
	}

	opinion = {
		value = regular_court_position_opinion
	}

	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 1
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = martial
			multiply = 2.5
			max = 50
			desc = court_position_skill_martial
		}
		add = {
			value = prowess
			multiply = 2
			max = 50
			desc = court_position_skill_prowess
		}
		if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 100
				}
			}
			add = {
				value = 30
				desc = court_position_blademaster_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
				has_trait_xp = {
					trait = lifestyle_blademaster
					value >= 50
				}
			}
			add = {
				value = 15
			}
		}
		else_if = {
			limit = {
				has_trait = lifestyle_blademaster
			}
			add = {
				value = 5
				desc = court_position_blademaster_1_trait
			}
		}
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:garuda }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		# Yeke Jarquchi
		if = {
			limit = {
				liege.court_position:yeke_jarquchi_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:yeke_jarquchi_court_position.yeke_jarquchi_improve_court_value
				desc = yeke_jarquchi_improve_court_aptitude_desc
			}
		}
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		#AGOT Modified
		# is_landed_or_landless_administrative = yes
		# trigger_if = {
		# 	limit = {
		# 		is_ai = yes
		# 		highest_held_title_tier <= tier_county
		# 	}
		# 	always = no
		# }
		always = no
	}

	valid_position = {
		#AGOT Modified
		# OR = {
		# 	is_landed_or_landless_administrative = yes
		# 	government_has_flag = government_is_nomadic
		# }
		# highest_held_title_tier >= tier_kingdom
		# culture = { has_cultural_tradition = tradition_garuda_warriors }
		always = no
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		valid_camp_officer_trigger = {
			OFFICER = garuda
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = garuda
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = { 
					exists = this
					#AGOT Modified
					#government_has_flag = government_is_landless_adventurer
					OR = {
						government_has_flag = government_is_landless_adventurer
						agot_is_landless_character = yes
					}
				}
				value = minor_court_position_prestige_revoke_cost
			}
			#AGOT Added Inner circle legacy allows revoking without cost
			if = {
				limit = { agot_court_position_inner_circle_revoke_trigger = { LIEGE = root POS = garuda } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = garuda_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = garuda_total_salary_value
			}
		}
		prestige = {
			value = garuda_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = garuda_total_salary_value
		}
		prestige = {
			value = garuda_prestige_salary_value
		}
		round = no
	}

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			dread_baseline_add = 1
		}
		poor = {
			dread_gain_mult = 0.05
			dread_decay_mult = -0.05
			dread_baseline_add = 2
		}
		average = {
			dread_gain_mult = 0.1
			dread_decay_mult = -0.1
			dread_baseline_add = 4
		}
		good = {
			dread_gain_mult = 0.2
			dread_decay_mult = -0.2
			dread_baseline_add = 7
		}
		excellent = {
			dread_gain_mult = 0.3
			dread_decay_mult = -0.3
			dread_baseline_add = 10
		}
	}

	custom_employer_modifier_description = garuda_employer_custom_effect_description

	modifier = {
		dread_baseline_add = 15
		dread_decay_mult = -0.25
	}

	on_court_position_received = {
		garuda_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		garuda_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		garuda_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = garuda_court_position
		}
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	ai_position_score = {
		value = 100
		scope:liege = {
			# Less likely to hire an additional one if you're already employing one
			if = {
				limit = {
					employs_court_position = garuda_court_position
				}
				add = -50
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 100
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = garuda }
			}
			add = 1000
		}
	}
}
