﻿# Court Alchemist Position
# This file adds the Court Alchemist position to the game..
# It focuses primarily on the Learning ability and provides various bonuses.

court_alchemist_court_position = { 
	sort_order = 250
	max_available_positions = 1
	skill = learning

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

	opinion = {
		value = regular_court_position_opinion
	}

	is_powerful_agent = yes

	aptitude_level_breakpoints = { 20 40 60 80 }

	aptitude = {
		value = 0
		add = court_position_aptitude_boon_voyager_trait
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
		add = {
			value = learning
			multiply = 2
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = { has_trait = scholar }
			add = { value = 15 desc = court_position_scholar_trait }
		}
		if = {
			limit = { has_trait = shrewd }
			add = { value = 10 desc = court_position_shrewd_trait }
		}
		# Mystic
		if = {
			limit = { has_trait = lifestyle_mystic }
			add = {
				value = 5
				if = {
					limit = {
						has_trait_xp = { trait = lifestyle_mystic value >= 50 }
					}
					add = 5
				}
				if = {
					limit = {
						has_trait_xp = { trait = lifestyle_mystic value >= 100 }
					}
					add = 5
				}
				desc = court_position_mystic_1_trait
			}
		}
		if = {
            limit = { has_trait = cynical }
            add = { value = 5 desc = court_position_cynical_trait }
		}
		if = {
			limit = { has_trait = patient }
			add = { value = 5 desc = court_position_patient_trait }
		}
		if = {
			limit = { has_trait = intellect_good_3 }
			add = { value = 40 desc = court_position_intellect_good_3_trait }
		}
		else_if = {
			limit = { has_trait = intellect_good_2 }
			add = { value = 20 desc = court_position_intellect_good_2_trait }
		}
		else_if = {
			limit = { has_trait = intellect_good_1 }
			add = { value = 10 desc = court_position_intellect_good_1_trait }
		}
		if = { # witch gives a tiny bonus
			limit = {
				has_trait = witch
			}
			add = {
				value = 5
				desc = court_position_witch_trait
			}
		}
		if = { # whole_of_body gives a tiny bonus
			limit = {
				has_trait = whole_of_body
			}
			add = {
				value = 5
				desc = court_position_whole_of_body_trait
			}
		}
		if = { # diligent gives a tiny bonus
			limit = {
				has_trait = diligent
			}
			add = {
				value = 5
				desc = court_position_diligent_trait
			}
		}
		if = { # gardener gives a tiny bonus, since gardening is also a part of herbalism
			limit = {
				has_trait = lifestyle_gardener
			}
			add = {
				value = 5
				desc = court_position_gardener_trait
			}
		}
		if = { # hashishiyah gives a tiny bonus, duhh
			limit = {
				has_trait = hashishiyah
			}
			add = {
				value = 5
				desc = court_position_hashishiyah_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
			}
		}
		if = {
			limit = {
				has_trait = blind
			}
			add = {
				value = -50
				desc = court_position_blind_trait
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
		if = {
			limit = { has_trait = lazy }
			add = { value = -20 desc = court_position_lazy_trait }
		}
		if = {
			limit = { has_trait = impatient }
			add = { value = -15 desc = court_position_impatient_trait }
		}
	}

	is_shown = {
		has_ep1_court_positions_dlc_trigger = yes
		culture = { has_cultural_parameter = can_appoint_court_alchemist }
	}

	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= 3
		has_trait = witch
	}

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


	revoke_cost = {
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_alchemist
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					government_has_flag = government_is_landless_adventurer
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}

	salary = {
		round = no
		gold = {
			value = medium_court_position_salary # Update X_salary_tooltip if script_value is changed
			# Set to 0 with Dynasty Perk Inner Circle
			if = {
				limit = { court_position_inner_circle_salary_trigger = { POS = court_alchemist } }
				multiply = {
					value = 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 = court_alchemist
						LIEGE = scope:liege
					}
				}
				multiply = {
					value = 0.5
					desc = obligation_hook_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Halved salary
			if = {
				limit = {
					court_position_halved_salary_trigger = { POS = court_alchemist }
				}
				multiply = {
					value = 0.5
					desc = court_position_halved_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Increased salary
			if = {
				limit = {
					court_position_increased_salary_trigger = { POS = court_alchemist }
				}
				multiply = {
					value = 1.5
					desc = court_position_increased_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"
				}
			}
		}
		prestige = {
			value = medium_court_position_prestige_salary # Update X_salary_tooltip if script_value is changed
			# Set to 0 with Dynasty Perk Inner Circle
			if = {
				limit = { court_position_inner_circle_salary_trigger = { POS = court_alchemist } }
				multiply = {
					value = 0
					desc = inner_circle_salary_mod
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Halved via obligation hook
			else_if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_alchemist
						LIEGE = scope:liege
					}
				}
				multiply = {
					value = 0.5
					desc = obligation_hook_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Halved salary
			if = {
				limit = {
					court_position_halved_salary_trigger = { POS = court_alchemist }
				}
				multiply = {
					value = 0.5
					desc = court_position_halved_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Increased salary
			if = {
				limit = {
					court_position_increased_salary_trigger = { POS = court_alchemist }
				}
				multiply = {
					value = 1.5
					desc = court_position_increased_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"
				}
			}
		}
	}

	scaling_employer_modifiers = {
		terrible = {
			epidemic_resistance = 1
			health = 0.01
		}
		poor = {
			epidemic_resistance = 3
			health = 0.03
		}
		average = {
			epidemic_resistance = 5
			health = 0.05
		}
		good = {
			epidemic_resistance = 7
			health = 0.07
		}
		excellent = {
			epidemic_resistance = 10
			health = 0.1
		}
	}

	scaling_employer_court_modifiers = {
		terrible = {
			negate_prowess_penalty_add = 1
			negate_fertility_penalty_add = 0.01
		}
		poor = {
			negate_prowess_penalty_add = 2
			negate_fertility_penalty_add = 0.03
		}
		average = {
			negate_prowess_penalty_add = 3
			negate_fertility_penalty_add = 0.05
		}
		good = {
			negate_prowess_penalty_add = 4
			negate_fertility_penalty_add = 0.07
		}
		excellent = {
			negate_prowess_penalty_add = 5
			negate_fertility_penalty_add = 0.1
		}
	}

	#custom_employer_modifier_description = court_alchemist_employer_custom_effect_description

	modifier = {
		health = 0.1
		monthly_learning_lifestyle_xp_gain_mult = 0.1
		monthly_intrigue_lifestyle_xp_gain_mult = 0.05
		monthly_prestige = 0.2
	}

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

	ai_candidate_score = {
		value = 100
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_alchemist }
			}
			add = 1000
		}
		add = court_position_debt_considerations_value
	}
}