﻿#EK NOTE: applied tasks to some of our positions

### Court Tutor Tasks ###

court_tutor_improve_others = {
	court_position_types = { court_tutor_court_position loremaster_court_position } #EK EDIT: added loremaster

	# Monthly cost for the task
	cost = {
		round = no
		prestige = {
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
	}

	employee_modifier = {
		general_opinion = 5
	}

	on_start = {
		custom_tooltip = court_tutor_improve_others_fallback_tt
	}

	on_monthly = {
		random = {
			chance = {
				value = 1
				add = {
					value = "aptitude(court_tutor_court_position)"
					multiply = 4
				}
			}
			# Find target
			random_list = {
				1 = {
					liege_or_court_owner = { 
						save_scope_as = target_character 
						save_scope_as = liege_character
					}
				}
				1 = {
					liege_or_court_owner = {
						random_court_position_holder = {
							limit = {
								NOT = { this = root }
							}
							save_scope_as = target_character
						}
					}
				}
				1 = {
					liege_or_court_owner = {
						random_heir = {
							limit = { 
								liege_or_court_owner = prev 
								NOT = { this = root }
							}
							save_scope_as = target_character
							save_scope_as = heir_character
						}
					}
				}
			}
			if = {
				limit = {
					exists = scope:target_character
				}
				random_list = {
					3 = { # Martial
						trigger = {
							scope:target_character.martial < root.martial
							scope:target_character = {
								OR = {
									scope:liege_character ?= scope:target_character
									scope:heir_character ?= scope:target_character
									has_court_position = akolouthos_court_position
									has_court_position = garuda_court_position
									has_court_position = master_of_horse_court_position
									has_court_position = boyan_court_position
									has_court_position = siege_engineer_court_position
									has_court_position = cherbi_court_position
									has_court_position = keeper_of_the_horses_court_position
								}
							}
						}
						court_tutor_improve_others_skill_effect = { SKILL = martial }
					}
					3 = { # Diplomacy
						trigger = {
							scope:target_character.diplomacy < root.diplomacy
							scope:target_character = {
								OR = {
									scope:liege_character ?= scope:target_character
									scope:heir_character ?= scope:target_character
									has_court_position = cultural_emissary_court_position
									has_court_position = lady_in_waiting_court_position
									has_court_position = cupbearer_court_position
									has_court_position = chief_eunuch_court_position
									has_court_position = court_jester_court_position
									has_court_position = court_poet_court_position
									has_court_position = court_musician_court_position
									has_court_position = chronicler_court_position
									has_court_position = yeke_jarquchi_court_position
									has_court_position = foreign_emissary_court_position
								}
							}
						}
						court_tutor_improve_others_skill_effect = { SKILL = diplomacy }
					}
					3 = { # Stewardship
						trigger = {
							scope:target_character.stewardship < root.stewardship
							scope:target_character = {
								OR = {
									scope:liege_character ?= scope:target_character
									scope:heir_character ?= scope:target_character
									has_court_position = bookmaker_court_position
									has_court_position = keeper_of_swans_court_position
									has_court_position = court_gardener_court_position
									has_court_position = travel_leader_court_position
									has_court_position = royal_architect_court_position
									has_court_position = seneschal_court_position
									has_court_position = yurtchi_court_position
								}
							}
						}
						court_tutor_improve_others_skill_effect = { SKILL = stewardship }
					}
					3 = { # Learning
						trigger = {
							scope:target_character.learning < root.learning
							scope:target_character = {
								OR = {
									scope:liege_character ?= scope:target_character
									scope:heir_character ?= scope:target_character
									has_court_position = court_physician_court_position
									has_court_position = chief_qadi_court_position
									has_court_position = antiquarian_court_position
									has_court_position = wet_nurse_court_position
									has_court_position = high_almoner_court_position
									has_court_position = court_artificer_court_position
									has_court_position = cave_hermit_court_position
									has_court_position = court_brewmaster_court_position
									has_court_position = court_astrologer_court_position
								}
							}
						}
						court_tutor_improve_others_skill_effect = { SKILL = learning }
					}
					1 = { # Physician trait
						trigger = {
							OR = {
								NOT = { exists = scope:liege_character }
								NOT = { scope:liege_character = scope:target_character }
							}
							scope:target_character = {
								OR = {
									has_court_position = court_physician_court_position
									has_court_position = travel_leader_court_position
									has_court_position = court_scholar_court_position
								}
							}
						}
						if = {
							limit = {
								scope:target_character = { 
									NOT = { has_trait = lifestyle_physician }
								}
							}
							court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_physician }
						}
						else = {
							court_tutor_improve_others_trait_xp_effect = { TRAIT = lifestyle_physician }
						}
					}
					1 = { # Traveler trait
						trigger = {
							scope:target_character = {
								has_court_position = travel_leader_court_position
							}
						}
						if = {
							limit = {
								scope:target_character = { 
									NOT = { has_trait = lifestyle_traveler }
								}
							}
							court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_traveler }
						}
						else = {
							court_tutor_improve_others_trait_track_xp_effect = { 
								TRAIT = lifestyle_traveler
								TRACK = travel
							}
						}
					}
					1 = { # Gardener trait
						trigger = {
							scope:target_character = {
								OR = {
									has_court_position = court_physician_court_position
									has_court_position = travel_leader_court_position
									has_court_position = court_scholar_court_position
								}
								NOT = { has_trait = lifestyle_gardener }
							}
						}
						court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_gardener }
					}
					1 = { # Herbalist trait
						trigger = {
							scope:target_character = {
								OR = {
									has_court_position = court_physician_court_position
									has_court_position = court_gardener_court_position
									has_court_position = travel_leader_court_position
									has_court_position = food_taster_court_position
									has_court_position = cave_hermit_court_position
								}
								NOT = { has_trait = lifestyle_herbalist }
							}
						}
						court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_herbalist }
					}
					1 = { # Reveler trait
						trigger = {
							scope:target_character = {
								OR = {
									has_court_position = travel_leader_court_position
									has_court_position = court_poet_court_position
									has_court_position = court_musician_court_position
									has_court_position = court_brewmaster_court_position
								}
								NOT = { has_trait = lifestyle_reveler }
							}
						}
						court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_reveler }
					}
					1 = { # Hunter trait
						trigger = {
							scope:target_character = {
								OR = {
									has_court_position = keeper_of_swans_court_position
									has_court_position = travel_leader_court_position
									has_court_position = master_of_hunt_court_position
								}
							}
						}
						if = {
							limit = {
								scope:target_character = { 
									NOT = { has_trait = lifestyle_hunter }
								}
							}
							court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_hunter }
						}
						else = {
							court_tutor_improve_others_trait_track_xp_effect = { 
								TRAIT = lifestyle_hunter
								TRACK = hunter
							}
						}
					}
					1 = { # Blademaster trait
						trigger = {
							scope:target_character = {
								OR = {
									has_court_position = garuda_court_position
									has_court_position = bodyguard_court_position
									has_court_position = champion_court_position
									has_court_position = master_assassin_court_position
								}
							}
						}
						if = {
							limit = {
								scope:target_character = { 
									NOT = { has_trait = lifestyle_blademaster }
								}
							}
							court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_blademaster }
						}
						else = {
							court_tutor_improve_others_trait_xp_effect = { TRAIT = lifestyle_blademaster }
						}
					}
					1 = { # Mystic trait
						trigger = {
							scope:target_character = {
								OR = {
									has_court_position = court_physician_court_position
									has_court_position = cave_hermit_court_position
								}
							}
						}
						if = {
							limit = {
								scope:target_character = { 
									NOT = { has_trait = lifestyle_mystic }
								}
							}
							court_tutor_improve_others_trait_effect = { TRAIT = lifestyle_mystic }
						}
						else = {
							court_tutor_improve_others_trait_xp_effect = { TRAIT = lifestyle_mystic }
						}
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0 # Never used by AI
	}
}

court_tutor_teach_kids = {
	court_position_types = { court_tutor_court_position }

	# Monthly cost for the task
	cost = {
		round = no
		prestige = {
			add = {
				value = monthly_court_position_task_cost
				desc = COURT_POSITION_TASK_COST_BREAKDOWN_BASE
				format = "BASE_VALUE_FORMAT_DECIMALS_PLUS_NEGATIVE"
			}
		}
	}

	employee_modifier = {
		stress_gain_mult = 0.25
		child_opinion = 5
	}

	on_start = {
		set_variable = court_tutor_teach_kids
		custom_tooltip = court_tutor_teach_kids_tt
	}

	on_end = {
		remove_variable = court_tutor_teach_kids
	}

	ai_will_do = {
		value = 0 # Never used by AI
	}
}
