﻿#court_astrologer_court_position
#boyan_court_position
#siege_engineer_court_position
#yurtchi_court_position
#cherbi_court_position
#yeke_jarquchi_court_position
#foreign_emissary_court_position
#keeper_of_the_horses_court_position


court_astrologer_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 400
		}
	}
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		animation = chaplain
		background = "gfx/interface/illustrations/event_scenes/mpo_temple_steppe.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
		# Skill
		add = {
			value = learning
			multiply = 1.75
			max = 50
			desc = court_position_skill_learning
		}
		#Spiritual ethos
		if = {
			limit = {
				culture ?= { has_cultural_pillar = ethos_spiritual }
			}
			add = 10
		}
		# Mystic
		if = {
			limit = { has_trait = lifestyle_mystic }
			add = {
				value = 15
				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
			}
		}
		# Nomad Yurt
		if = {
			limit = {
				employer.domicile ?= {
					has_domicile_building_or_higher = astrologer_yurt_01
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_astrologer_aptitude_lvl_4
						}
					}
					add = 32
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_astrologer_aptitude_lvl_3
						}
					}
					add = 16
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_astrologer_aptitude_lvl_2
						}
					}
					add = 8
				}
				else_if = {
					limit = {
						employer.domicile ?= {
							has_domicile_parameter = nomad_yurt_increased_astrologer_aptitude_lvl_1
						}
					}
					add = 4
				}
				desc = astrologer_yurt_01_domicile_building
			}
		}
		# Herbalist
		if = {
			limit = { has_trait = lifestyle_herbalist }
			add = {
				value = 10
				desc = court_position_herbalist_trait
			}
		}
		# 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
			}
		}
		
		add = kurultai_task_value
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			court_astrologer_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = court_astrologer } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = court_astrologer
						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 = {
		prestige = {
			value = court_astrologer_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		prestige = {
			value = court_astrologer_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.10
			monthly_piety_gain_mult = 0.02
		}
		poor = {
			stress_loss_mult = 0.12
			monthly_piety_gain_mult = 0.03
		}
		average = {
			stress_loss_mult = 0.15
			monthly_piety_gain_mult = 0.04
		}
		good = {
			stress_loss_mult = 0.20
			monthly_piety_gain_mult = 0.05
		}
		excellent = {
			stress_loss_mult = 0.25
			monthly_piety_gain_mult = 0.05
			learning = 1
		}
	}

	custom_employer_modifier_description = court_astrologer_employer_custom_effect_description

	modifier = {
		learning = 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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_astrologer_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 = { #Unop Added so that AI can hire this position
		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
        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_astrologer }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}

boyan_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 275
		}
	}
	max_available_positions = 1
	skill = martial

	court_position_asset = {
		trigger = {
			NOT = {
				root ?= { #Unop: We want to check the culture of the court_owner (most likely the player) not the culture of the recipient
					culture = { has_cultural_pillar = heritage_mongolic }
				}
			}
		}
		animation = personality_bold
		background = "gfx/interface/illustrations/event_scenes/mpo_camp_steppe.dds"
		localization_key = boyan_court_position_fallback
	}

	court_position_asset = {
		animation = personality_bold
		background = "gfx/interface/illustrations/event_scenes/mpo_camp_steppe.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
		# Skill
		add = {
			value = martial
			multiply = 2.5
			max = 50
			desc = court_position_skill_martial
		}
		add = {
			value = stewardship
			multiply = 0.5
			max = 50
			desc = court_position_skill_stewardship
		}
		add = {
			value = learning
			multiply = 0.5
			max = 50
			desc = court_position_skill_learning
		}
		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
			}
		}
		# Positive
		if = {
			limit = {
				has_trait = strategist
			}
			add = {
				value = 15
				desc = court_position_strategist_trait
			}
		}
		if = {
			limit = {
				has_trait = overseer
			}
			add = {
				value = 15
				desc = court_position_overseer_trait
			}
		}
		if = {
			limit = {
				has_trait = brave
			}
			add = {
				value = 15
				desc = court_position_brave_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 15
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = ambitious
			}
			add = {
				value = 15
				desc = court_position_ambitious_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 15
				desc = court_position_diligent_trait
			}
		}
		# Negative
		if = {
			limit = {
				has_trait = craven
			}
			add = {
				value = -15
				desc = court_position_craven_trait
			}
		}
		if = {
			limit = {
				has_trait = shy
			}
			add = {
				value = -15
				desc = court_position_shy_trait
			}
		}
		if = {
			limit = {
				has_trait = paranoid
			}
			add = {
				value = -15
				desc = court_position_paranoid_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -15
				desc = court_position_lazy_trait
			}
		}

		add = aptitude_commander_trait_value
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

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

	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			boyan_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = boyan } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = boyan
						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
					}
			#	court_position_inner_circle_salary_trigger = { POS = boyan } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.0
			#		desc = inner_circle_salary_mod
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			## Halved with obligation hook
			#else_if = {
			#	limit = {
			#		court_position_obligation_hook_salary_trigger = {
			#			POS = boyan
			#			LIEGE = scope:liege
			#		}
				}
				add = boyan_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
			#		court_position_halved_salary_trigger = { POS = boyan } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.5
			#		desc = court_position_halved_salary
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			##You're working with LAAMPS now
			#if = {
			#	limit = { 
			#		scope:liege ?= { government_has_flag = government_is_landless_adventurer }
			#	}
			#	multiply = {
			#		value = 0
			#		desc = court_position_laamps_free
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
				add = boyan_total_salary_value
			}
		}
		prestige = {
			value = boyan_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = boyan_total_salary_value
		}
		prestige = {
			value = boyan_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 = {
			belligerent_opinion = 1
			herd_conversion = 0.001
		}
		poor = {
			belligerent_opinion = 2
			min_combat_roll = 1
			max_combat_roll = 1
			herd_conversion = 0.002
		}
		average = {
			belligerent_opinion = 4
			min_combat_roll = 1
			max_combat_roll = 1
			herd_conversion = 0.005
		}
		good = {
			belligerent_opinion = 7
			min_combat_roll = 2
			max_combat_roll = 2
			herd_conversion = 0.015
		}
		excellent = {
			belligerent_opinion = 10
			min_combat_roll = 2
			max_combat_roll = 2
			herd_conversion = 0.025
		}
	}

	modifier = {
		monthly_martial_lifestyle_xp_gain_mult = 0.1
		herd_conversion = 0.05
	}

	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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = boyan_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 = { #Unop Added so that AI can hire this position
		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
        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 = boyan }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}

siege_engineer_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 125
		}
	}
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		animation = reading
		background = "gfx/interface/illustrations/event_scenes/mpo_rural_village_asian.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
		# Skill
		add = {
			value = learning
			multiply = 2
			max = 50
			desc = court_position_skill_learning
		}
		add = {
			value = martial
			multiply = 1.5
			max = 50
			desc = court_position_skill_martial
		}
		add = {
			value = stewardship
			max = 50
			desc = court_position_skill_stewardship
		}

		# Positive
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 15
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = architect
			}
			add = {
				value = 15
				desc = court_position_architect_trait
			}
		}
		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
			}
		}
		# Negative
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -15
				desc = court_position_lazy_trait
			}
		}
		if = {
			limit = {
				has_trait = impatient
			}
			add = {
				value = -15
				desc = court_position_impatient_trait
			}
		}
		
		add = {
			value = aptitude_military_engineer_value
			multiply = 2
			desc = court_position_military_engineer_trait
		}
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			siege_engineer_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = siege_engineer } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = siege_engineer
						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
					}
			#		court_position_inner_circle_salary_trigger = { POS = siege_engineer } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.0
			#		desc = inner_circle_salary_mod
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			## Halved with obligation hook
			#else_if = {
			#	limit = {
			#		court_position_obligation_hook_salary_trigger = {
			#			POS = siege_engineer
			#			LIEGE = scope:liege
			#		}
				}
				add = siege_engineer_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
			#		court_position_halved_salary_trigger = { POS = siege_engineer } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.5
			#		desc = court_position_halved_salary
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			##You're working with LAAMPS now
			#if = {
			#	limit = { 
			#		scope:liege ?= { government_has_flag = government_is_landless_adventurer }
			#	}
			#	multiply = {
			#		value = 0
			#		desc = court_position_laamps_free
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
				add = siege_engineer_total_salary_value
			}
		}
		prestige = {
			value = siege_engineer_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = siege_engineer_total_salary_value
		}
		prestige = {
			value = siege_engineer_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 = {
			siege_phase_time = -0.05
		}
		poor = {
			siege_phase_time = -0.1
		}
		average = {
			siege_phase_time = -0.15
		}
		good = {
			siege_phase_time = -0.2
		}
		excellent = {
			siege_phase_time = -0.25
		}
	}

	modifier = {
		military_engineer_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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = siege_engineer_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 = { #Unop Added so that AI can hire this position
		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
        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 = siege_engineer }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}

yurtchi_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 270
		}
	}
	max_available_positions = 1
	skill = stewardship

	court_position_asset = {
		trigger = {
			NOT = {
				root ?= { #Unop: We want to check the culture of the court_owner (most likely the player) not the culture of the recipient
					culture = { has_cultural_pillar = heritage_mongolic } 
				}
			}
		}
		animation = steward
		background = "gfx/interface/illustrations/event_scenes/mpo_tent_interior_mongol.dds"
		localization_key = yurtchi_court_position_fallback
	}

	court_position_asset = {
		animation = steward
		background = "gfx/interface/illustrations/event_scenes/mpo_tent_interior_mongol.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
		# Skill
		add = {
			value = stewardship
			multiply = 2.5
			max = 50
			desc = court_position_skill_stewardship
		}
		add = {
			value = learning
			max = 50
			desc = court_position_skill_learning
		}
		# Positive
		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_trait = diligent
			}
			add = {
				value = 15
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = greedy
			}
			add = {
				value = 15
				desc = court_position_diligent_trait
			}
		}
		# Negative
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -15
				desc = court_position_lazy_trait
			}
		}
		if = {
			limit = {
				has_trait = generous
			}
			add = {
				value = -15
				desc = court_position_generous_trait
			}
		}
		
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			government_has_flag = government_is_nomadic
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			yurtchi_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = yurtchi } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = yurtchi
						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
					}
			#		court_position_inner_circle_salary_trigger = { POS = yurtchi }#Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.0
			#		desc = inner_circle_salary_mod
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			## Halved with obligation hook
			#else_if = {
			#	limit = {
			#		court_position_obligation_hook_salary_trigger = {
			#			POS = yurtchi
			#			LIEGE = scope:liege
			#		}
				}
				add = yurtchi_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
			#		court_position_halved_salary_trigger = { POS = yurtchi } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.5
			#		desc = court_position_halved_salary
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			##You're working with LAAMPS now
			#if = {
			#	limit = { 
			#		scope:liege ?= { government_has_flag = government_is_landless_adventurer }
			#	}
			#	multiply = {
			#		value = 0
			#		desc = court_position_laamps_free
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
				add = yurtchi_total_salary_value
			}
		}
		prestige = {
			value = yurtchi_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = yurtchi_total_salary_value
		}
		prestige = {
			value = yurtchi_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 = {
			domicile_build_gold_cost = -0.02
			domicile_build_speed = -0.02
			men_at_arms_maintenance = -0.01
		}
		poor = {
			domicile_build_gold_cost = -0.05
			domicile_build_speed = -0.05
			men_at_arms_maintenance = -0.02
		}
		average = {
			domicile_build_gold_cost = -0.08
			domicile_build_speed = -0.08
			men_at_arms_maintenance = -0.04
		}
		good = {
			domicile_build_gold_cost = -0.14
			domicile_build_speed = -0.14
			men_at_arms_maintenance = -0.07
		}
		excellent = {
			domicile_build_gold_cost = -0.2
			domicile_build_speed = -0.2
			men_at_arms_maintenance = -0.1
		}
	}

	modifier = {
		domicile_build_gold_cost = -0.1
		domicile_build_speed = -0.1
		monthly_stewardship_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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = yurtchi_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 = { #Unop Added so that AI can hire this position
		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
        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 = yurtchi }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}

cherbi_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 100
		}
	}
	max_available_positions = 1
	skill = prowess

	court_position_asset = {
		trigger = {
			NOT = { 
				root ?= { #Unop: We want to check the culture of the court_owner (most likely the player) not the culture of the recipient
					culture = { has_cultural_pillar = heritage_mongolic } 
				}
			}
		}
		animation = personality_bold
		background = "gfx/interface/illustrations/event_scenes/mpo_hunt_steppe.dds"
		localization_key = cherbi_court_position_fallback
	}

	court_position_asset = {
		animation = personality_bold
		background = "gfx/interface/illustrations/event_scenes/mpo_hunt_steppe.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
		# Skill
		add = {
			value = prowess
			multiply = 2.5
			max = 50
			desc = court_position_skill_prowess
		}
		add = {
			value = martial
			multiply = 0.5
			max = 50
			desc = court_position_skill_martial
		}
		add = {
			value = intrigue
			multiply = 0.5
			max = 50
			desc = court_position_skill_intrigue
		}
		# Positive
		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 = {
			limit = {
				has_trait = gallant
			}
			add = {
				value = 15
				desc = court_position_gallant_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 = loyal
			}
			add = {
				value = 15
				desc = court_position_loyal_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 15
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = brave
			}
			add = {
				value = 15
				desc = court_position_brave_trait
			}
		}

		# Negative
		if = {
			limit = {
				has_trait = disloyal
			}
			add = {
				value = -15
				desc = court_position_disloyal_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -15
				desc = court_position_lazy_trait
			}
		}
		if = {
			limit = {
				has_trait = craven
			}
			add = {
				value = -15
				desc = court_position_craven_trait
			}
		}
		
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			government_has_flag = government_is_nomadic
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			cherbi_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = cherbi } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = cherbi
						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
					}
			#		court_position_inner_circle_salary_trigger = { POS = cherbi } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.0
			#		desc = inner_circle_salary_mod
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			## Halved with obligation hook
			#else_if = {
			#	limit = {
			#		court_position_obligation_hook_salary_trigger = {
			#			POS = cherbi
			#			LIEGE = scope:liege
			#		}
				}
				add = cherbi_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
			#		court_position_halved_salary_trigger = { POS = cherbi } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.5
			#		desc = court_position_halved_salary
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			##You're working with LAAMPS now
			#if = {
			#	limit = { 
			#		scope:liege ?= { government_has_flag = government_is_landless_adventurer }
			#	}
			#	multiply = {
			#		value = 0
			#		desc = court_position_laamps_free
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
				add = cherbi_total_salary_value
			}
		}
		prestige = {
			value = cherbi_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = cherbi_total_salary_value
		}
		prestige = {
			value = cherbi_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 = {
			archer_cavalry_toughness_add = 1
		}
		poor = {
			knight_limit = 1
			archer_cavalry_toughness_add = 1
		}
		average = {
			knight_limit = 2
			archer_cavalry_toughness_add = 2
		}
		good = {
			knight_limit = 2
			archer_cavalry_toughness_add = 2
		}
		excellent = {
			knight_limit = 3
			archer_cavalry_toughness_add = 3
		}
	}

	custom_scaling_employer_modifier_description = {
		terrible = cherbi_custom_modifier_terrible
		poor = cherbi_custom_modifier_poor
		average = cherbi_custom_modifier_average
		good = cherbi_custom_modifier_good
		excellent = cherbi_custom_modifier_excellent
		range = cherbi_custom_modifier_range
	}

	modifier = {
		monthly_prestige = 1
		dread_baseline_add = 15
		enemy_hostile_scheme_success_chance_max_add = -15
	}

	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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = cherbi_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 = { #Unop Added so that AI can hire this position
		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
        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 = cherbi }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}

yeke_jarquchi_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 300
		}
	}
	max_available_positions = 1
	skill = diplomacy

	court_position_asset = {
		trigger = {
			NOR = {
				root ?= { #Unop: We want to check the culture of the court_owner (most likely the player) not the culture of the recipient
					culture = { has_cultural_pillar = heritage_mongolic }
					culture = { has_cultural_pillar = heritage_turkic }
				}
			}
		}
		animation = debating
		background = "gfx/interface/illustrations/event_scenes/mpo_hunt_steppe.dds"
		localization_key = yeke_jarquchi_court_position_fallback
	}
	
	court_position_asset = {
		trigger = {
			root ?= { #Unop: We want to check the culture of the court_owner (most likely the player) not the culture of the recipient
				culture = { has_cultural_pillar = heritage_turkic }
			}
		}
		animation = debating
		background = "gfx/interface/illustrations/event_scenes/mpo_hunt_steppe.dds"
		localization_key = yeke_jarquchi_court_position_turkic
	}

	court_position_asset = {
		animation = debating
		background = "gfx/interface/illustrations/event_scenes/mpo_hunt_steppe.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
		# Skill
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = learning
			max = 50
			desc = court_position_skill_learning
		}

		# Positive
		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_trait = stubborn
			}
			add = {
				value = 15
				desc = court_position_stubborn_trait
			}
		}
		if = {
			limit = {
				has_trait = just
			}
			add = {
				value = 15
				desc = court_position_just_trait
			}
		}
		if = {
			limit = {
				has_trait = honest
			}
			add = {
				value = 15
				desc = court_position_honest_trait
			}
		}

		# Negative
		if = {
			limit = {
				has_trait = fickle
			}
			add = {
				value = -15
				desc = court_position_fickle_trait
			}
		}
		if = {
			limit = {
				has_trait = callous
			}
			add = {
				value = -15
				desc = court_position_callous_trait
			}
		}
		if = {
			limit = {
				has_trait = sadistic
			}
			add = {
				value = -15
				desc = court_position_sadistic_trait
			}
		}
		if = {
			limit = {
				has_trait = deceitful
			}
			add = {
				value = -15
				desc = court_position_deceitful_trait
			}
		}
		
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus_exclude_other_court_position
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			government_has_flag = government_is_nomadic
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			yeke_jarquchi_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = yeke_jarquchi } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = yeke_jarquchi
						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
					}
			#		court_position_inner_circle_salary_trigger = { POS = yeke_jarquchi } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.0
			#		desc = inner_circle_salary_mod
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			## Halved with obligation hook
			#else_if = {
			#	limit = {
			#		court_position_obligation_hook_salary_trigger = {
			#			POS = yeke_jarquchi
			#			LIEGE = scope:liege
			#		}
				}
				add = yeke_jarquchi_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
			#		court_position_halved_salary_trigger = { POS = yeke_jarquchi } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.5
			#		desc = court_position_halved_salary
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			##You're working with LAAMPS now
			#if = {
			#	limit = { 
			#		scope:liege ?= { government_has_flag = government_is_landless_adventurer }
			#	}
			#	multiply = {
			#		value = 0
			#		desc = court_position_laamps_free
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
				add = yeke_jarquchi_total_salary_value
			}
		}
		prestige = {
			value = yeke_jarquchi_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = yeke_jarquchi_total_salary_value
		}
		prestige = {
			value = yeke_jarquchi_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
			monthly_legitimacy_add = 0.1
		}
		poor = {
			character_capital_county_monthly_control_add = 0.2
			monthly_legitimacy_add = 0.2
		}
		average = {
			character_capital_county_monthly_control_add = 0.3
			monthly_legitimacy_add = 0.3
		}
		good = {
			character_capital_county_monthly_control_add = 0.4
			monthly_legitimacy_add = 0.5
		}
		excellent = {
			character_capital_county_monthly_control_add = 0.5
			monthly_legitimacy_add = 0.7
		}
	}

	modifier = {
		monthly_county_control_growth_factor = 0.2
		monthly_diplomacy_lifestyle_xp_gain_mult = 0.1
	}

	custom_scaling_employer_modifier_description = {
		terrible = yeke_jarquchi_custom_modifier_terrible
		poor = yeke_jarquchi_custom_modifier_poor
		average = yeke_jarquchi_custom_modifier_average
		good = yeke_jarquchi_custom_modifier_good
		excellent = yeke_jarquchi_custom_modifier_excellent
		range = yeke_jarquchi_custom_modifier_range
	}

	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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = yeke_jarquchi_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 = { #Unop Added so that AI can hire this position
		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
        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 = yeke_jarquchi }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}

foreign_emissary_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 100
		}
	}
	max_available_positions = 1
	skill = diplomacy

	court_position_asset = {
		animation = toast
		background = "gfx/interface/illustrations/event_scenes/mpo_campfire_steppe.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
		# Skill
		add = {
			value = diplomacy
			multiply = 2.5
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = stewardship
			max = 50
			desc = court_position_skill_stewardship
		}

		# Positive
		if = {
			limit = {
				has_trait = diplomat
			}
			add = {
				value = 25
				desc = court_position_diplomat_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add = {
				value = 25
				desc = court_position_reveler_trait
			}
		}
		if = {
			limit = {
				has_trait = humble
			}
			add = {
				value = 15
				desc = court_position_humble_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 15
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = {
				has_trait = stubborn
			}
			add = {
				value = 15
				desc = court_position_stubborn_trait
			}
		}

		# Negative
		if = {
			limit = {
				has_trait = arrogant
			}
			add = {
				value = -15
				desc = court_position_arrogant_trait
			}
		}
		if = {
			limit = {
				has_trait = impatient
			}
			add = {
				value = -15
				desc = court_position_impatient_trait
			}
		}
		if = {
			limit = {
				has_trait = fickle
			}
			add = {
				value = -15
				desc = court_position_fickle_trait
			}
		}
		
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			government_has_flag = government_is_nomadic
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			foreign_emissary_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = foreign_emissary } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = foreign_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
			}
		}
	}

	salary = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
			#		court_position_inner_circle_salary_trigger = { POS = foreign_emissary } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.0
			#		desc = inner_circle_salary_mod
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			## Halved with obligation hook
			#else_if = {
			#	limit = {
			#		court_position_obligation_hook_salary_trigger = {
			#			POS = foreign_emissary
			#			LIEGE = scope:liege
			#		}
				}
				add = foreign_emissary_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
			#		court_position_halved_salary_trigger = { POS = foreign_emissary } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.5
			#		desc = court_position_halved_salary
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			##You're working with LAAMPS now
			#if = {
			#	limit = { 
			#		scope:liege ?= { government_has_flag = government_is_landless_adventurer }
			#	}
			#	multiply = {
			#		value = 0
			#		desc = court_position_laamps_free
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
				add = foreign_emissary_total_salary_value
			}
		}
		round = no
	}

	received_salary = {
		gold = {
			value = foreign_emissary_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 = {
			tributary_tax_mult = 0.04
			courtier_and_guest_opinion = 1
			monthly_prestige_gain_mult = 0.01
		}
		poor = {
			tributary_tax_mult = 0.08
			courtier_and_guest_opinion = 2
			monthly_prestige_gain_mult = 0.02
		}
		average = {
			tributary_tax_mult = 0.12
			courtier_and_guest_opinion = 4
			monthly_prestige_gain_mult = 0.03
		}
		good = {
			tributary_tax_mult = 0.16
			courtier_and_guest_opinion = 7
			monthly_prestige_gain_mult = 0.04
		}
		excellent = {
			tributary_tax_mult = 0.2
			courtier_and_guest_opinion = 10
			monthly_prestige_gain_mult = 0.05
		}
	}

	modifier = {
		general_opinion = 5
		monthly_diplomacy_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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = foreign_emissary_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 = { #Unop Added so that AI can hire this position
		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
        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 = foreign_emissary }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}

keeper_of_the_horses_court_position = { ### MPO
	sort_order = {
		value = 100
		if = {
			limit = {
				has_mpo_dlc_trigger = yes
				government_has_flag = government_is_nomadic
			}
			add = 220
		}
	}
	max_available_positions = 1
	skill = martial

	court_position_asset = {
		animation = personality_compassionate
		background = "gfx/interface/illustrations/event_scenes/steppe.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
		# Skill
		add = {
			value = martial
			multiply = 2.5
			max = 50
			desc = court_position_skill_martial
		}
		add = {
			value = diplomacy
			max = 50
			desc = court_position_skill_diplomacy
		}

		# Positive
		if = {
			limit = {
				has_trait = administrator
			}
			add = {
				value = 15
				desc = court_position_administrator_trait
			}
		}
		if = {
			limit = {
				has_trait = family_first
			}
			add = {
				value = 15
				desc = court_position_family_first_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 15
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 15
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = compassionate
			}
			add = {
				value = 15
				desc = court_position_compassionate_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_traveler
			}
			add = {
				value = 15
				desc = court_position_traveler_trait
			}
		}

		# Negative
		if = {
			limit = {
				has_trait = wrathful
			}
			add = {
				value = -15
				desc = court_position_wrathful_trait
			}
		}
		if = {
			limit = {
				has_trait = impatient
			}
			add = {
				value = -15
				desc = court_position_impatient_trait
			}
		}
		if = {
			limit = {
				has_trait = callous
			}
			add = {
				value = -15
				desc = court_position_callous_trait
			}
		}
		if = {
			limit = {
				has_trait = sadistic
			}
			add = {
				value = -15
				desc = court_position_sadistic_trait
			}
		}
		
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		government_has_flag = government_is_nomadic
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_county
		government_has_flag = government_is_nomadic
	}

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			keeper_of_the_horses_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
			if = { #Unop: Inner circle legacy allows revoking without cost
				limit = { unop_court_position_inner_circle_revoke_trigger = { LIEGE = root  POS = keeper_of_the_horses } }
				desc = inner_circle_salary_mod
				multiply = 0
			}
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = keeper_of_the_horses
						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
					}
			#		court_position_inner_circle_salary_trigger = { POS = keeper_of_the_horses } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.0
			#		desc = inner_circle_salary_mod
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			## Halved with obligation hook
			#else_if = {
			#	limit = {
			#		court_position_obligation_hook_salary_trigger = {
			#			POS = keeper_of_the_horses
			#			LIEGE = scope:liege
			#		}
				}
				add = keeper_of_the_horses_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
			#		court_position_halved_salary_trigger = { POS = keeper_of_the_horses } #Unop Remove obsolete lines
			#	}
			#	multiply = {
			#		value = 0.5
			#		desc = court_position_halved_salary
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
			#	}
			#}
			##You're working with LAAMPS now
			#if = {
			#	limit = { 
			#		scope:liege ?= { government_has_flag = government_is_landless_adventurer }
			#	}
			#	multiply = {
			#		value = 0
			#		desc = court_position_laamps_free
			#		format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
				add = keeper_of_the_horses_total_salary_value
			}
		}
		prestige = {
			value = keeper_of_the_horses_prestige_salary_value
		}
		round = no
	}

	received_salary = {
		gold = {
			value = keeper_of_the_horses_total_salary_value
		}
		prestige = {
			value = keeper_of_the_horses_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_travel_speed_mult = 0.01
			herd_gain_mult = 0.01
			herd_capacity_mult = 0.01
		}
		poor = {
			character_travel_speed_mult = 0.02
			herd_gain_mult = 0.02
			herd_capacity_mult = 0.02
		}
		average = {
			character_travel_speed_mult = 0.03
			herd_gain_mult = 0.03
			herd_capacity_mult = 0.04
		}
		good = {
			character_travel_speed_mult = 0.05
			herd_gain_mult = 0.04
			herd_capacity_mult = 0.07
		}
		excellent = {
			character_travel_speed_mult = 0.08
			herd_gain_mult = 0.05
			herd_capacity_mult = 0.1
		}
	}

	modifier = {
		herd_capacity_mult = 0.1
		monthly_martial_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 = { #Unop: Missing block that is needed for automation to work properly
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = keeper_of_the_horses_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 = { #Unop Added so that AI can hire this position
		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
        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 = keeper_of_the_horses }
			}
			add = 1000
		}
		
		#add = court_position_debt_considerations_value #Unop Moved above
    }
}
