# Court Positions Expanded - Court Herbalist
# Adapted for CK3 1.19 framework
# court_herbalist_court_position

### Common Court Positions ###

court_herbalist_court_position = {
	sort_order = 286 
	skill = learning
	max_available_positions = 1

	court_position_asset = {
		trigger = {
			culture_has_mena_heritage_pillar_trigger = yes
		}
		animation = physician
		background = "gfx/interface/illustrations/event_scenes/fp4_study_physician_mena.dds"
	}

	court_position_asset = {
		trigger = {
			culture_has_south_asian_heritage_pillar_trigger = yes
		}
		animation = physician
		background = "gfx/interface/illustrations/event_scenes/fp4_study_physician_indian.dds"
	}

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

	opinion = {
		value = regular_court_position_opinion
	}

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

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 20
		add = {
			value = learning
			multiply = 1.5
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				has_trait = lifestyle_herbalist
			}
			add = {
				value = 20
				desc = court_position_herbalist_trait
			}
		}
		if = {
			limit = {
				is_witch_trigger = yes
			}
			add = {
				value = 20
				desc = court_position_witch_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_physician
			}
			add = {
				value = 10
				desc = court_position_physician_trait
			}
		}
		if = {
			limit = {
				has_trait = curious
			}
			add = {
				value = 5
				desc = court_position_curious_trait
			}
		}
		add = court_position_aptitude_family_business_value
		add = general_aptitude_bonus
	}

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

	valid_position = {
		is_landed_or_landless_administrative = yes
	}

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

	valid_character = {
		scope:employee = {
			is_imprisoned = no
			OR = {
				has_trait = lifestyle_herbalist
				is_witch_trigger = yes
			}
		}
	}

	revoke_cost = {
		prestige = {
			value = major_court_position_prestige_revoke_cost
			if = {
				limit = {
					exists = dynasty
					dynasty = { has_dynasty_perk = fp2_coterie_legacy_1 }
					employs_court_position = court_herbalist_court_position
					any_court_position_holder = {
						type = court_herbalist_court_position
						exists = dynasty
						house = prev.house
					}
				}
				multiply = 0
			}
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
		}
	}

	salary = {
		round = no
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = {
					value = minor_court_position_salary
					if = {
						limit = {
							scope:liege = {
								exists = dynasty
								dynasty = { has_dynasty_perk = fp2_coterie_legacy_1 }
								employs_court_position = court_herbalist_court_position
								any_court_position_holder = {
									type = court_herbalist_court_position
									exists = dynasty
									house = prev.house
								}
							}
						}
						multiply = {
							value = 0.0
							desc = inner_circle_salary_mod
							format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
						}
					}
					if = {
						limit = {
							scope:liege = {
								employs_court_position = court_herbalist_court_position
								any_court_position_holder = {
									type = court_herbalist_court_position
									scope:liege = {
										has_hook_of_type = {
											type = obligation_hook
											target = prev
										}
									}
								}
							}
						}
						multiply = {
							value = 0.5
							desc = obligation_hook_salary
						}
					}
				}
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = {
					value = minor_court_position_salary
					if = {
						limit = {
							scope:liege = {
								exists = dynasty
								dynasty = { has_dynasty_perk = fp2_coterie_legacy_1 }
								employs_court_position = court_herbalist_court_position
								any_court_position_holder = {
									type = court_herbalist_court_position
									exists = dynasty
									house = prev.house
								}
							}
						}
						multiply = {
							value = 0.0
							desc = inner_circle_salary_mod
							format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
						}
					}
					if = {
						limit = {
							scope:liege = {
								employs_court_position = court_herbalist_court_position
								any_court_position_holder = {
									type = court_herbalist_court_position
									scope:liege = {
										has_hook_of_type = {
											type = obligation_hook
											target = prev
										}
									}
								}
							}
						}
						multiply = {
							value = 0.5
							desc = obligation_hook_salary
						}
					}
				}
			}
		}
		prestige = {
			value = minor_court_position_prestige_salary
		}
	}

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

	# Scaling modifiers based on herbalist aptitude
	scaling_employer_modifiers = {
		terrible = {
			negate_health_penalty_add = 0.05
		}
		poor = {
			learning = 1
			negate_health_penalty_add = 0.10
		}
		average = {
			learning = 2
			negate_health_penalty_add = 0.15
		}
		good = {
			learning = 2
			negate_health_penalty_add = 0.25
		}
		excellent = {
			learning = 2
			negate_health_penalty_add = 0.50
		}
	}

	# Modifiers always applied to the Herbalist themselves
	modifier = {
		monthly_prestige = minor_court_position_prestige_salary
		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 = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_herbalist_court_position
		}
	}

	ai_position_score = {
		value = 1
		scope:liege = {
			# More likely if ruler has poor health
			if = {
				limit = {
					health <= 4
				}
				add = 30
			}
			if = {
				limit = {
					health <= 2
				}
				add = 30
			}
			# More likely for rulers interested in learning
			if = {
				limit = {
					has_lifestyle = learning_lifestyle
				}
				add = 20
			}
		}
		add = court_position_debt_considerations_value
	}
	ai_candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		add = court_position_debt_considerations_value
	}
}
