﻿grand_preceptor_court_position = {
	sort_order = 1000
	max_available_positions = 1
	minimum_rank = empire # Should only be available for emperors and hegemons
	skill = learning

	court_position_asset = {
		animation = holding_hu
		background = "gfx/interface/illustrations/event_scenes/tgp_asia_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 = 1
		add = {
			value = merit_level
			multiply = 5
			max = 50
			desc = court_position_merit_level
		}
		add = {
			value = learning
			multiply = 1.75
			max = 50
			desc = court_position_skill_learning
		}
		# Confucian Education
		if = {
			limit = {
				has_trait = confucian_education
			}
			add = {
				value = "has_trait_xp(confucian_education)"
				floor = yes
				desc = court_position_confucian_education_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 5
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 5
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 5
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 5
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = {
				has_trait = intellect_good_3
			}
			add = {
				value = 15
				desc = court_position_intellect_good_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_2
			}
			add = {
				value = 10
				desc = court_position_intellect_good_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_1
			}
			add = {
				value = 5
				desc = court_position_intellect_good_1_trait
			}
		}
		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
			}
		}
		if = {
			limit = {
				has_trait = shy
			}
			add = {
				value = -10
				desc = court_position_shy_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -10
				desc = court_position_lazy_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
			}
		}
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		is_independent_ruler = yes
		government_has_flag = government_is_celestial
		highest_held_title_tier >= tier_empire
	}

	valid_position = {
		is_independent_ruler = yes
		government_has_flag = government_is_celestial
		highest_held_title_tier >= tier_empire
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			grand_preceptor_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 = grand_preceptor
						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 = grand_preceptor_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = grand_preceptor_total_salary_value
			}
		}
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		gold = {
			value = grand_preceptor_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 = {
			monthly_influence = 0.5
			direct_vassal_opinion = 2
		}
		poor = {
			monthly_influence = 0.75
			direct_vassal_opinion = 4
		}
		average = {
			monthly_influence = 1.0
			direct_vassal_opinion = 6
		}
		good = {
			monthly_influence = 1.25
			direct_vassal_opinion = 8
		}
		excellent = {
			monthly_influence = 1.5
			direct_vassal_opinion = 10
		}
	}

	modifier = {
		monthly_influence = 3
		monthly_merit = 10
		monthly_diplomacy_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		grand_preceptor_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		grand_preceptor_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		grand_preceptor_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = grand_preceptor_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 = 500
		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 = grand_preceptor }
			}
			add = 1000
		}
	}
}

grand_mentor_court_position = {
	sort_order = 990
	max_available_positions = 1
	minimum_rank = empire # Should only be available for emperors and hegemons
	skill = learning

	court_position_asset = {
		animation = happy_teacher
		background = "gfx/interface/illustrations/event_scenes/tgp_examination_room.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 = {
			value = merit_level
			multiply = 5
			max = 50
			desc = court_position_merit_level
		}
		add = {
			value = learning
			multiply = 1.75
			max = 50
			desc = court_position_skill_learning
		}
		# Confucian Education
		if = {
			limit = {
				has_trait = confucian_education
			}
			add = {
				value = "has_trait_xp(confucian_education)"
				floor = yes
				desc = court_position_confucian_education_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 5
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 5
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 5
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 5
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = {
				has_trait = intellect_good_3
			}
			add = {
				value = 10
				desc = court_position_intellect_good_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_2
			}
			add = {
				value = 10
				desc = court_position_intellect_good_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_1
			}
			add = {
				value = 5
				desc = court_position_intellect_good_1_trait
			}
		}
		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
			}
		}
		if = {
			limit = {
				has_trait = shy
			}
			add = {
				value = -10
				desc = court_position_shy_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -10
				desc = court_position_lazy_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
			}
		}
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		is_independent_ruler = yes
		government_has_flag = government_is_celestial
		highest_held_title_tier >= tier_empire
	}

	valid_position = {
		is_independent_ruler = yes
		government_has_flag = government_is_celestial
		highest_held_title_tier >= tier_empire
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			grand_mentor_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 = grand_mentor
						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 = grand_mentor_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = grand_mentor_total_salary_value
			}
		}
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		gold = {
			value = grand_mentor_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 = {
			diplomacy = 1
			stewardship = 1
			learning = 1
		}
		poor = {
			diplomacy = 2
			stewardship = 2
			learning = 2
		}
		average = {
			diplomacy = 3
			stewardship = 3
			learning = 3
		}
		good = {
			diplomacy = 4
			stewardship = 4
			learning = 4
		}
		excellent = {
			diplomacy = 5
			stewardship = 5
			learning = 5
		}
	}

	modifier = {
		monthly_influence = 3
		monthly_merit = 10
		monthly_learning_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		grand_mentor_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		grand_mentor_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		grand_mentor_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = grand_mentor_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 = 500
		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 = grand_mentor }
			}
			add = 1000
		}
	}
}

grand_guardian_court_position = {
	sort_order = 995
	max_available_positions = 1
	minimum_rank = empire # Should only be available for emperors and hegemons
	skill = martial

	court_position_asset = {
		animation = relaxed_spear
		background = "gfx/interface/illustrations/event_scenes/tgp_camp_asia.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 = {
			value = merit_level
			multiply = 5
			max = 50
			desc = court_position_merit_level
		}
		add = {
			value = martial
			multiply = 1.75
			max = 50
			desc = court_position_skill_martial
		}
		# Confucian Education
		if = {
			limit = {
				has_trait = confucian_education
			}
			add = {
				value = "has_trait_xp(confucian_education)"
				floor = yes
				desc = court_position_confucian_education_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 5
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 5
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 5
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 5
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = {
				has_trait = intellect_good_3
			}
			add = {
				value = 10
				desc = court_position_intellect_good_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_2
			}
			add = {
				value = 10
				desc = court_position_intellect_good_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_1
			}
			add = {
				value = 5
				desc = court_position_intellect_good_1_trait
			}
		}
		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
			}
		}
		if = {
			limit = {
				has_trait = shy
			}
			add = {
				value = -10
				desc = court_position_shy_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -10
				desc = court_position_lazy_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
			}
		}
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		is_independent_ruler = yes
		government_has_flag = government_is_celestial
		highest_held_title_tier >= tier_empire
	}

	valid_position = {
		is_independent_ruler = yes
		government_has_flag = government_is_celestial
		highest_held_title_tier >= tier_empire
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			grand_guardian_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 = grand_guardian
						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 = grand_guardian_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = grand_guardian_total_salary_value
			}
		}
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		gold = {
			value = grand_guardian_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 = {
			army_damage_mult = 0.01
			army_toughness_mult = 0.01
		}
		poor = {
			army_damage_mult = 0.03
			army_toughness_mult = 0.03
		}
		average = {
			army_damage_mult = 0.05
			army_toughness_mult = 0.05
		}
		good = {
			army_damage_mult = 0.08
			army_toughness_mult = 0.08
		}
		excellent = {
			army_damage_mult = 0.15
			army_toughness_mult = 0.15
		}
	}

	modifier = {
		monthly_influence = 3
		monthly_merit = 10
		monthly_martial_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		grand_guardian_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		grand_guardian_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		grand_guardian_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = grand_guardian_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 = 500
		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 = grand_guardian }
			}
			add = 1000
		}
	}
}

fire_dragon_engineer_court_position = {
	sort_order = {
		value = 225
	}
	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 = 1.75
			max = 50
			desc = court_position_skill_learning
		}

		# 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_celestial
		culture = {
			has_innovation = innovation_fire_medicine
		}
		OR = {
			is_independent_ruler = yes
			vassal_contract_has_flag = celestial_military_appointment
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		highest_held_title_tier >= tier_kingdom
		government_has_flag = government_is_celestial
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}
	
	valid_character = {
		scope:employee = {
			fire_dragon_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
			# Set to 0 via obligation hook
			if = {
				limit = { 
					court_position_obligation_hook_salary_trigger = {
						POS = fire_dragon_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
					}
				}
				add = fire_dragon_engineer_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = fire_dragon_engineer_total_salary_value
			}
		}
		prestige = {
			value = minor_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		gold = {
			value = fire_dragon_engineer_total_salary_value
		}
		prestige = {
			value = minor_court_position_prestige_salary
		}
		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
		}
	}

	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 = fire_dragon_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 = {
		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 = fire_dragon_engineer }
			}
			add = 1000
		}
	}
}

keeper_of_the_harem_court_position = {
	sort_order = 1018
	max_available_positions = 1
	minimum_rank = empire # Should only be available for emperors and hegemons
	skill = diplomacy

	court_position_asset = {
		animation = fanning_coyly
		background = "gfx/interface/illustrations/event_scenes/tgp_wedding_bedroom_asia.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 = {
			value = diplomacy
			multiply = 1.75
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = intrigue
			multiply = 1.75
			max = 50
			desc = court_position_skill_intrigue
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 5
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 5
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 5
				desc = court_position_calm_trait
			}
		}
		if = {
			limit = {
				has_trait = intellect_good_3
			}
			add = {
				value = 15
				desc = court_position_intellect_good_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_2
			}
			add = {
				value = 10
				desc = court_position_intellect_good_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_1
			}
			add = {
				value = 5
				desc = court_position_intellect_good_1_trait
			}
		}
		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
			}
		}
		if = {
			limit = {
				has_trait = shy
			}
			add = {
				value = -10
				desc = court_position_shy_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -10
				desc = court_position_lazy_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
			}
		}

		#add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		is_adult = yes
		highest_held_title_tier = tier_hegemony
		government_has_flag = government_is_celestial
	}

	valid_position = {
		highest_held_title_tier = tier_hegemony
		government_has_flag = government_is_celestial
		save_temporary_scope_as = root_scope
		can_employ_court_eunuchs_trigger = { CHAR = scope:root_scope }
	}

	is_shown_character = {
		scope:employee = {
			OR = {
				is_eunuch_trigger = yes
				is_female = yes
			}
			NOT = {
				is_consort_of = scope:liege
			}
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			keeper_of_the_harem_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_the_harem
						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 = keeper_of_the_harem_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = keeper_of_the_harem_total_salary_value
			}
		}
		prestige = {
			value = minor_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		gold = {
			value = keeper_of_the_harem_total_salary_value
		}
		prestige = {
			value = minor_court_position_prestige_salary
		}
		round = no
	}

	base_employer_modifier = {
	}

	modifier = {
	}

	is_powerful_agent = yes

	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			spouse_opinion = 5
		}
		poor = {
			spouse_opinion = 10
		}
		average = {
			spouse_opinion = 15
		}
		good = {
			spouse_opinion = 25
		}
		excellent = {
			spouse_opinion = 40
		}
	}

	on_court_position_received = {
		keeper_of_the_harem_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		keeper_of_the_harem_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		keeper_of_the_harem_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = keeper_of_the_harem_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 = 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 = fire_dragon_engineer }
			}
			add = 1000
		}
	}
}

favored_minister_court_position = {
	sort_order = 1200
	max_available_positions = 1
	minimum_rank = hegemony
	skill = diplomacy

	court_position_asset = {
		animation = holding_scrolls
		background = "gfx/interface/illustrations/event_scenes/tgp_chinese_city.dds"
	}

	opinion = {
		value = 10
	}

	# 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
		# Merit
		add = {
			value = merit_level
			multiply = 5
			max = 50
			desc = court_position_merit_level
		}
		# Use the skill of your current minister position
		if = {
			limit = {
				OR = {
					has_council_position = councillor_chancellor
					has_council_position = minister_personnel
				}
			}
			add = {
				value = diplomacy
				multiply = 1.75
				max = 50
				desc = court_position_skill_diplomacy
			}
		}
		else_if = {
			limit = {
				OR = {
					has_council_position = councillor_marshal
					has_council_position = minister_grand_marshal
				}
			}
			add = {
				value = martial
				multiply = 1.75
				max = 50
				desc = court_position_skill_martial
			}
		}
		else_if = {
			limit = {
				OR = {
					has_council_position = councillor_steward
					has_council_position = minister_works
				}
			}
			add = {
				value = stewardship
				multiply = 1.75
				max = 50
				desc = court_position_skill_stewardship
			}
		}
		else_if = {
			limit = {
				has_council_position = councillor_spymaster
			}
			add = {
				value = intrigue
				multiply = 1.75
				max = 50
				desc = court_position_skill_intrigue
			}
		}
		else_if = {
			limit = {
				OR = {
					has_council_position = councillor_court_chaplain
					has_council_position = minister_justice
				}
			}
			add = {
				value = learning
				multiply = 1.75
				max = 50
				desc = court_position_skill_learning
			}
		}
		
		# Disciples
		if = {
			limit = {
				number_of_disciples > 0
			}
			add = {
				value = 2
				multiply = number_of_disciples
				max = 50
				desc = court_position_disciples
			}
		}
		
		# Confucian Education
		if = {
			limit = {
				has_trait = confucian_education
			}
			add = {
				value = "has_trait_xp(confucian_education)"
				floor = yes
				desc = court_position_confucian_education_trait
			}
		}
		
		# Influence
		if = {
			limit = {
				government_allows = administrative
			}
			add = {
				value = influence_level
				subtract = 1
				multiply = 4
				desc = "[influence_level|E]"
			}
		}
		
		#add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	# Is this an available position for this court? (root is court owner)
	is_shown = {
		highest_held_title_tier = tier_hegemony
		government_has_flag = government_is_celestial
	}

	valid_position = {
		highest_held_title_tier = tier_hegemony
		government_has_flag = government_is_celestial
	}

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

	valid_character = {
		scope:employee = {
			is_councillor_of = scope:liege
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		# No revoke cost for this position
	}

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

	received_salary = {
		prestige = {
			value = major_court_position_prestige_salary
			multiply = 2
		}
		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 = {
			monthly_influence_mult = 0.05
		}
		poor = {
			monthly_influence_mult = 0.1
		}
		average = {
			monthly_influence_mult = 0.15
		}
		good = {
			monthly_influence_mult = 0.2
		}
		excellent = {
			monthly_influence_mult = 0.25
		}
	}

	modifier = {
		monthly_influence_mult = 0.25
		monthly_merit = 3
		monthly_treasury_from_ministry_budget_base = 0.5
	}
	
	custom_employee_modifier_description = favored_minister_employee_custom_desc

	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 = favored_minister_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 = 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 = grand_preceptor }
			}
			add = 1000
		}
	}
}

minister_bureaucrat_court_position = {
	sort_order = 1200
	max_available_positions = 2
	minimum_rank = empire
	skill = diplomacy

	court_position_asset = {
		animation = chancellor
		background = "gfx/interface/illustrations/event_scenes/tgp_study_asia.dds"
	}

	opinion = {
		value = 10
	}

	# 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
		# Merit
		add = {
			value = merit_level
			multiply = 2
			max = 50
			desc = court_position_merit_level
		}
		# Primary skill of the minister
		if = {
			limit = {
				liege = {
					OR = {
						has_council_position = councillor_chancellor
						has_council_position = minister_personnel
					}
				}
			}
			add = {
				value = diplomacy
				multiply = 1.75
				max = 50
				desc = court_position_skill_diplomacy
			}
		}
		else_if = {
			limit = {
				liege = {
					OR = {
						has_council_position = councillor_marshal
						has_council_position = minister_grand_marshal
					}
				}
			}
			add = {
				value = martial
				multiply = 1.75
				max = 50
				desc = court_position_skill_martial
			}
		}
		else_if = {
			limit = {
				liege = {
					OR = {
						has_council_position = councillor_steward
						has_council_position = minister_works
					}
				}
			}
			add = {
				value = stewardship
				multiply = 1.75
				max = 50
				desc = court_position_skill_stewardship
			}
		}
		else_if = {
			limit = {
				liege = { has_council_position = councillor_spymaster }
			}
			add = {
				value = intrigue
				multiply = 1.75
				max = 50
				desc = court_position_skill_intrigue
			}
		}
		else_if = {
			limit = {
				liege = {
					OR = {
						has_council_position = councillor_court_chaplain
						has_council_position = minister_justice
					}
				}
			}
			add = {
				value = learning
				multiply = 1.75
				max = 50
				desc = court_position_skill_learning
			}
		}
		
		# Disciple
		if = {
			limit = {
				has_relation_elder = liege
			}
			add = {
				value = 10
				desc = court_position_your_disciple
			}
		}

		# Dynasty Legacy
		# Dynasty Members Have better aptitude both when employing and employed
		if = {
			limit = {
				OR = {
					dynasty ?= {
						has_dynasty_perk = tgp_chinese_legacy_5
					}
					liege.dynasty ?= {
						has_dynasty_perk = tgp_chinese_legacy_5
					}
				}
			}
			add = {
				value = court_position_tgp_dynasty_legacy_aptitude_bonus
				desc = court_position_tgp_dynasty_legacy
			}
		}
		
		# Traits
		if = {
			limit = {
				has_trait = confucian_education
			}
			add = {
				value = "has_trait_xp(confucian_education)"
				desc = court_position_confucian_education_trait
			}
		}
		if = {
			limit = {
				has_trait = administrator
			}
			add = {
				value = 10
				desc = court_position_administrator_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 10
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = diplomat
			}
			add = {
				value = 10
				desc = court_position_diplomat_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_surveyor
			}
			add = {
				value = 10
				desc = court_position_surveyor_trait
			}
		}
		if = {
			limit = {
				has_trait = shrewd
			}
			add = {
				value = 10
				desc = court_position_shrewd_trait
			}
		}
		
		# Personality traits
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 5
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 5
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = just
			}
			add = {
				value = 5
				desc = court_position_just_trait
			}
		}
		if = {
			limit = {
				has_trait = stubborn
			}
			add = {
				value = 5
				desc = court_position_stubborn_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -5
				desc = court_position_lazy_trait
			}
		}
		if = {
			limit = {
				has_trait = impatient
			}
			add = {
				value = -5
				desc = court_position_impatient_trait
			}
		}
		
		# Influence
		if = {
			limit = {
				government_allows = administrative
			}
			add = {
				value = influence_level
				subtract = 1
				multiply = 4
				desc = "[influence_level|E]"
			}
		}
		
		# Domicile buildings
		if = {
			limit = {
				liege ?= {
					domicile ?= {
						OR = {
							has_domicile_parameter = estate_minister_bureaucrat_aptitude_1
							has_domicile_parameter = estate_minister_bureaucrat_aptitude_2
							has_domicile_parameter = estate_minister_bureaucrat_aptitude_3
							has_domicile_parameter = estate_minister_bureaucrat_aptitude_4
						}
					}
				}
			}
			add = {
				value = 0
				liege ?= {
					domicile ?= {
						if = {
							limit = {
								has_domicile_parameter = estate_minister_bureaucrat_aptitude_4
							}
							add = estate_minister_bureaucrat_aptitude_4_value
						}
						else_if = {
							limit = {
								has_domicile_parameter = estate_minister_bureaucrat_aptitude_3
							}
							add = estate_minister_bureaucrat_aptitude_3_value
						}
						else_if = {
							limit = {
								has_domicile_parameter = estate_minister_bureaucrat_aptitude_2
							}
							add = estate_minister_bureaucrat_aptitude_2_value
						}
						else = {
							add = estate_minister_bureaucrat_aptitude_1_value
						}
					}
				}
				desc = estate_minister_bureaucrat_aptitude_desc
			}
		}
		
		#add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

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

	valid_position = {
		tgp_has_minister_title = yes
	}

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

	valid_character = {
		scope:employee = {
			OR = {
				is_landed = no
				custom_tooltip = {
					text = they_are_your_disciple_desc
					has_relation_elder = scope:liege
				}
			}
		}
	}

	revoke_cost = { # root is the liege, no other scopes are passed here!
		# No revoke cost for this position
	}

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

	received_salary = {
		gold = {
			value = minister_bureaucrat_total_salary_value
		}
		prestige = {
			value = major_court_position_prestige_salary
		}
	}

	is_powerful_agent = yes

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

	modifier = {
		monthly_merit = 1
		monthly_influence = 3
		monthly_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 = minister_bureaucrat_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 = 500
		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
	}
}
