﻿# Guru
# Court Brahmin
# Khlon Glan

# Guru
court_guru_court_position = {
	sort_order = 380
	max_available_positions = 1
	skill = learning

	court_position_asset = {
		trigger = { culture_has_east_asian_heritage_pillar_trigger = yes }
		animation = happy_teacher
		background = "gfx/interface/illustrations/event_scenes/tgp_holysite_asia.dds"
	}

	court_position_asset = {
		animation = happy_teacher
		background = "gfx/interface/illustrations/event_scenes/bp2_indian_garden.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 = 25
		add = {
			value = learning
			multiply = 2
			max = 50
			desc = court_position_skill_learning
		}
		add = {
			value = diplomacy
			max = 50
			desc = court_position_skill_diplomacy
		}
		add = {
			value = intrigue
			max = 50
			desc = court_position_skill_intrigue
		}
		if = {
			limit = {
				diplomacy >= high_skill_rating
				martial >= high_skill_rating
				stewardship >= high_skill_rating
				intrigue >= high_skill_rating
				learning >= high_skill_rating
			}
			add = {
				value = 20
				desc = court_position_high_skills_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 15
				desc = court_position_scholar_trait
			}
		}
		if = {
			limit = {
				has_trait = theologian
			}
			add = {
				value = 20
				desc = court_position_theologian_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 15
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = calm
			}
			add = {
				value = 15
				desc = court_position_calm_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
			}
		}
		else_if = {
			limit = {
				has_trait = shrewd
			}
			add = {
				value = 10
				desc = court_position_shrewd_trait
			}
		}
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		has_tgp_dlc_trigger = yes
		OR = {
			government_has_flag = government_is_mandala
			government_has_flag = government_is_wanua
			religion = { is_in_family = rf_eastern }
			religion = religion:taoism_religion
		}
		is_landed_or_landless_administrative = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

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

	revoke_cost = { # root is the liege, no other scopes are passed here!
		piety =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_guru #Unop Use correct position
						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
			}
			#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 = {
		prestige = very_high_court_position_prestige_salary
		round = no
	}

	received_salary = {
		prestige = very_high_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 = {
			stress_loss_mult = 0.02
			monthly_piety_gain_mult = 0.02
		}
		poor = {
			stress_loss_mult = 0.04
			monthly_piety_gain_mult = 0.05
		}
		average = {
			stress_loss_mult = 0.06
			monthly_piety_gain_mult = 0.10
		}
		good = {
			stress_loss_mult = 0.08
			monthly_piety_gain_mult = 0.15
		}
		excellent = {
			stress_loss_mult = 0.1
			monthly_piety_gain_mult = 0.2
		}
	}

	base_employer_modifier = {
	}

	modifier = {
		general_opinion = 20
	}

	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_guru_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 = 5000
	}
	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 = court_guru }
			}
			add = 1000
		}
	}
}

# Court Brahmin
court_brahmin_court_position = {
	sort_order = 379
	max_available_positions = 1
	minimum_rank = duchy
	skill = learning

	court_position_asset = {
		animation = wedding_priest
		background = "gfx/interface/illustrations/event_scenes/ep2_holysite_indian.dds"
	}

	opinion = {
		value = ceremonial_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 = learning
			multiply = 2.5
			max = 50
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				is_clergy = yes
			}
			add = {
				value = 20
				desc = court_position_clergy_trait
			}
		}
		if = {
			limit = {
				has_trait = generous
			}
			add = {
				value = 20
				desc = court_position_generous_trait
			}
		}
		if = {
			limit = {
				has_trait = theologian
			}
			add = {
				value = 20
				desc = court_position_theologian_trait
			}
		}
		if = {
			limit = {
				has_trait = compassionate
			}
			add = {
				value = 20
				desc = court_position_compassionate_trait
			}
		}
		if = {
			limit = {
				has_trait = greedy
			}
			add = {
				value = -10
				desc = court_position_greedy_trait
			}
		}
		if = {
			limit = {
				has_trait = profligate
			}
			add = {
				value = -10
				desc = court_position_profligate_trait
			}
		}
		if = {
			limit = {
				has_trait = avaricious
			}
			add = {
				value = -10
				desc = court_position_avaricious_trait
			}
		}
		if = {
			limit = {
				has_trait = devoted
				culture = { has_cultural_parameter = devoted_trait_bonuses }
			}
			add = {
				value = 20
				desc = tradition_monastic_communities_name
			}
		}
		if = {
			limit = {
				has_character_flag = plenty_to_donate_almoner
			}
			add = {
				value = 30
				desc = plenty_to_donate_almoner_desc
			}
		}
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus
	}

	is_shown = {
		has_tgp_dlc_trigger = yes
		is_landed_or_landless_administrative = yes
		government_has_flag = government_is_mandala
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_duchy
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			court_brahmin_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 = court_brahmin #Unop Use correct position
						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
			}
			#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 = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = court_brahmin_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = court_brahmin_total_salary_value
			}
		}
		prestige = {
			value = major_court_position_prestige_salary
		}
		round = no
	}

	received_salary = {
		gold = {
			value = court_brahmin_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 = {
			monthly_piety = 0.1
		  	monthly_legitimacy_add = 0.1
		}
		poor = {
			monthly_piety = 0.2
		  	monthly_legitimacy_add = 0.2
		}
		average = {
			monthly_piety = 0.3
		  	monthly_legitimacy_add = 0.3
		}
		good = {
			monthly_piety = 0.5
		  	monthly_legitimacy_add = 0.5
		}
		excellent = {
			monthly_piety = 0.7
		  	monthly_legitimacy_add = 0.7
		}
	}

	modifier = {
		monthly_piety = 0.1
		monthly_piety_gain_mult = 0.1
		monthly_learning_lifestyle_xp_gain_mult = 0.1
	}

	on_court_position_received = {
		high_almoner_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		high_almoner_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		high_almoner_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_brahmin_court_position #Unop Use correct 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 = 100
		scope:liege = {
			# Zealous AI's like this
			if = {
				limit = {
					ai_zeal > 75
				}
				add = 50
			}
		}
        if = { # Having a Court Brahmin is excellent if you have legitimacy
            limit = {
				scope:liege = {
					has_legitimacy = 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 = court_brahmin }
			}
			add = 1000
		}
	}
}

# Khlon Glan
khlon_glan_court_position = {
	sort_order = 378
	max_available_positions = 1
	skill = stewardship

	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 = 25
		add = {
			value = stewardship
			multiply = 2
			max = 50
			desc = court_position_skill_stewardship
		}
		add = {
			value = martial
			multiply = 2
			max = 50
			desc = court_position_skill_martial
		}
		if = {
			limit = {
				has_trait = administrator
			}
			add = {
				value = 20
				desc = court_position_administrator_trait
			}
		}
		if = {
			limit = {
				has_trait = overseer
			}
			add = {
				value = 20
				desc = court_position_overseer_trait
			}
		}
		if = {
			limit = {
				has_trait = organizer
			}
			add = {
				value = 20
				desc = court_position_organizer_trait
			}
		}
		add = court_position_aptitude_low_penalty_value
		add = general_aptitude_bonus_exclude_other_court_position #Unop: They cannot improve themselves (will crash the game if general_aptitude_bonus is used)
		# Bonus from court.8311
		#if = { #Unop Not possible
		#	limit = { var:bonus_aptitude_role ?= flag:seneschal }
		#	add = {
		#		value = cp_bonus_aptitude_value
		#		desc = cp_bonus_aptitude
		#	}
		#}
	}

	is_shown = {
		has_tgp_dlc_trigger = yes
		is_landed_or_landless_administrative = yes
		government_has_flag = government_is_mandala
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
	}
	
	is_shown_character = {
		scope:employee = {
			court_position_employee_shown_trigger = yes
		}
	}

	valid_character = {
		scope:employee = {
			khlon_glan_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 = khlon_glan #Unop Use correct position
						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
			}
			#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 = {
		gold = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = no
					}
				}
				add = khlon_glan_total_salary_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					scope:liege = {
						has_treasury = yes
					}
				}
				add = khlon_glan_total_salary_value
			}
		}
		prestige = khlon_glan_prestige_salary_value
		round = no
	}

	received_salary = {
		gold = {
			value = khlon_glan_total_salary_value
		}
		prestige = {
			value = khlon_glan_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 = {
		  	monthly_county_control_growth_add = 0.1
			great_project_build_speed = -0.05
			character_travel_safety = 2
		}
		poor = {
		  	monthly_county_control_growth_add = 0.15
			great_project_build_speed = -0.1
			character_travel_safety = 4
		}
		average = {
		  	monthly_county_control_growth_add = 0.2
			great_project_build_speed = -0.15
			character_travel_safety = 6
		}
		good = {
		  	monthly_county_control_growth_add = 0.25
			great_project_build_speed = -0.2
			character_travel_safety = 8
		}
		excellent = {
		  	monthly_county_control_growth_add = 0.3
			great_project_build_speed = -0.25
			character_travel_safety = 10
		}
	}

	modifier = {
		general_opinion = 5
		monthly_stewardship_lifestyle_xp_gain_mult = 0.2
	}

	on_court_position_received = {
		seneschal_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		seneschal_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		seneschal_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = khlon_glan_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 = 100
		add = court_position_seneschal_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 = khlon_glan }
			}
			add = 1000
		}
	}
}
