﻿celestial_civic_governor = {
	allow_same_tier_candidates = yes

	level = merit

	candidate_score = {
		value = {
			if = {
				limit = {
					top_liege = {
						has_realm_law = candidate_score_prestige_law
					}
				}
				# Base score gained from prestige rank
				add = {
					value = 10
					multiply = prestige_level
					desc = PRESTIGE_LEVEL_CONCEPT
				} 
				if = {
					limit = {
						exists = dynasty
					}
					# Base score gained from prestige rank
					add = {
						value = 10
						multiply = dynasty.dynasty_prestige_level
						desc = DYNASTY_PRESTIGE_CONCEPT
					}
				}
			}

			# Age - With age comes experience. We provide a rather small bonus for the elderly, to exist as a potential tie-breaker.
			if = { # Too old
				limit = {
					age >= retirement_age_1_value
					tgp_is_above_retirement_age_trigger = { REALM_OWNER = root }
				}
				add = {
					value = {
						value = retirement_age_current_value
						subtract = age
						divide = 2
						round = yes
					}
					desc = is_above_retirement_age_desc
				}
			}
			else_if = { # Old and experienced
				limit = {
					age >= 40
				}
				add = {
					value = 15
					desc = old_age_desc
				}
			}
			else_if = { # Too young
				limit = {
					age < 30
				}
				add = {
					value = -10
					desc = young_age_desc
				}
			}
			
			# Skills
			add = {
				value = learning
				multiply = 0.5
				round = yes
				desc = "[learning_skill|E]"
			}
			add = {
				value = diplomacy
				multiply = 0.25
				round = yes
				desc = "[diplomacy_skill|E]"
			}
			add = {
				value = stewardship
				multiply = 0.25
				round = yes
				desc = "[stewardship_skill|E]"
			}
			
			# Education traits
			if = {
				limit = {
					OR = {
						has_trait = education_diplomacy_5
						has_trait = education_stewardship_5
						has_trait = education_learning_5
					}
				}
				add = {
					value = 10
					desc = has_rank_5_education_desc
				}
			}
			if = {
				limit = {
					has_trait = confucian_education
				}
				add = {
					value = "has_trait_xp(confucian_education)"
					divide = 4
					round = yes
					min = 5
					desc = court_position_confucian_education_trait
				}
			}
			
			# Influenced career score
			if = {
				limit = {
					exists = var:merit_civilian_career_score_bonus
				}
				add = {
					value = var:merit_civilian_career_score_bonus
					desc = merit_career_score_bonus_desc
				}
			}

			# Domicile
			if = {
				limit = {
					exists = scope:title
					root.dynasty.dynast ?= {
						has_domicile = yes
					}
					scope:title = {
						is_de_jure_liege_or_above_target = root.dynasty.dynast.domicile.domicile_location.county
					}
				}
				subtract = {
					value = 20
					desc = estate_location_in_area
				}
			}
			if = {
				limit = {
					domicile ?= {
						has_domicile_parameter = celestial_civilian_score_bonus_1
					}
				}
				add = {
					value = celestial_civilian_score_bonus_1_value
					desc = "[GetDomicileBuilding('east_asian_estate_office_01').GetName]"
				}
			}
			else_if = {
				limit = {
					domicile ?= {
						has_domicile_parameter = celestial_civilian_score_bonus_2
					}
				}
				add = {
					value = celestial_civilian_score_bonus_2_value
					desc = "[GetDomicileBuilding('east_asian_estate_office_02').GetName]"
				}
			}
			else_if = {
				limit = {
					domicile ?= {
						has_domicile_parameter = celestial_civilian_score_bonus_3
					}
				}
				add = {
					value = celestial_civilian_score_bonus_3_value
					desc = "[GetDomicileBuilding('east_asian_estate_office_03').GetName]"
				}
			}
			else_if = {
				limit = {
					domicile ?= {
						has_domicile_parameter = celestial_civilian_score_bonus_4
					}
				}
				add = {
					value = celestial_civilian_score_bonus_4_value
					desc = "[GetDomicileBuilding('east_asian_estate_office_04').GetName]"
				}
			}

			# Piety level
			if = {
				limit = {
					piety_level != 1
				}
				add = {
					value = 10
					multiply = {
						value = piety_level
						subtract = 1 # Baseline is at 1, so we want the bonus to start at 2
					}
					desc = PIETY_LEVEL_CONCEPT
				}
			}

			# Traits
			if = {
				limit = { has_trait = disinherited }
				subtract = {
					value = 200
					desc = trait_disinherited
				}
			}
			if = {
				limit = { has_trait = gallivanter }
				subtract = {
					value = 200
					desc = trait_gallivanter
				}
			}
			
			# Same dynasty as holder penalty
			if = {
				limit = {
					root.dynasty ?= scope:title.holder.dynasty
				}
				subtract = {
					value = 50
					desc = too_closely_related
				}
			}
			
			# CRIMINAL
			if = {
				limit = {
					has_trait = deviant
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "deviant_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = incestuous
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "incestuous_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = sodomite
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "sodomite_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = cannibal
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "cannibal_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = kinslayer_1
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "kinslayer_1_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = kinslayer_2
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "kinslayer_2_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = kinslayer_3
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "kinslayer_3_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = witch
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "witch_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = adulterer
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "adulterer_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = fornicator
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -50
					desc = "fornicator_and_criminal_desc"
				}
			}
			if = {
				limit = {
					OR = {
						has_trait = lunatic
						has_trait = possessed
						has_trait = incapable
						has_trait = intellect_bad_3
					}
				}
				add = {
					value = -100
					desc = "unsound_mind_desc"
				}
			}

			# FAITH HOSTILITY
			if = {
				limit = {
					scope:title.holder.primary_title.state_faith ?= {
						faith_hostility_level = {
							target = root.faith
							value = faith_astray_level
						}
					}
				} #Change to faith acceptance
				subtract = {
					value = 10
					desc = astray_faith_succession_desc
				}
			}
			if = {
				limit = {
					scope:title.holder.primary_title.state_faith ?= {
						faith_hostility_level = {
							target = root.faith
							value = faith_hostile_level
						}
					}
				} #Change to faith acceptance
				subtract = {
					value = 20
					desc = hostile_faith_succession_desc
				}
			}
			if = {
				limit = {
					scope:title.holder.primary_title.state_faith ?= {
						faith_hostility_level = {
							target = root.faith
							value >= faith_evil_level
						}
					}
				} #Change to faith acceptance
				subtract = {
					value = 30
					desc = evil_faith_sucession_desc
				}
			}

			# CLAIMS
			if = {
				limit = {
					exists = scope:title
				}
				if = {
					limit = { has_strong_claim_on = scope:title }
					add = {
						value = 20
						desc = title_claim_desc
					}
				}
				else_if = {
					limit = { has_weak_claim_on = scope:title }
					add = {
						value = 10
						desc = title_weak_claim_desc
					}
				}
			}

			# POPULAR OPINION
			if = {
				limit = { is_landed = yes }
				add = {
					value = {
						value = capital_county.county_holder_opinion
						multiply = 0.25
						round = yes
					}
					desc = county_holder_opinion_desc
				}
			}

			# PERKS
			if = {
				limit = {
					NOT = {
						government_has_flag = government_is_celestial
					}
					has_perk = ducal_conquest_perk
				}
				add = {
					value = 30
					desc = ducal_conquest_perk_name_desc
				}
			}

			# Dynasty Legacy
			if = {
				limit = {
					dynasty ?= {
						has_dynasty_perk = tgp_chinese_legacy_4
					}
				}
				add = {
					value = legacy_candidate_score_bonus
					desc = "[GetDynastyPerk('tgp_chinese_legacy_4').GetName]"
				}
			}
			
			# Aspirations
			if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_1 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					multiply = poet_trait_provides_candidate_score_1_value
					desc = celestial_governor_poet_trait_desc
				}
			}
			else_if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_2 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					multiply = poet_trait_provides_candidate_score_2_value
					desc = celestial_governor_poet_trait_desc
				}
			}
			else_if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_3 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					multiply = poet_trait_provides_candidate_score_3_value
					desc = celestial_governor_poet_trait_desc
				}
			}
			else_if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_4 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					desc = celestial_governor_poet_trait_desc
				}
			}

			# LOWBORN? EW no
			if = {
				limit = {
					is_lowborn = yes
				}
				subtract = {
					value = 25
					desc = lowborn_desc_succession
				}
			}

			# RELATIONS
			if = { # Is a friend
				limit = {
					scope:title.holder ?= { has_relation_friend = root }
				}
				add = {
					value = 15
					desc = governor_friend_desc
				}
			}
			if = { # Is a elder
				limit = {
					scope:title.holder ?= { has_relation_elder = root }
				}
				add = {
					value = 15
					desc = governor_elder_desc
				}
			}
			if = { # Is a disciple
				limit = {
					scope:title.holder ?= { has_relation_disciple = root }
				}
				add = {
					value = 10
					desc = governor_disciple_desc
				}
			}

			# REGENT OF EMPEROR
			if = {
				limit = { scope:title.holder.diarch ?= root }
				add = {
					value = scope:title.holder.diarchy_swing
					desc = governor_diarch_desc
				}
			}

			# Schemes
			if = {
				limit = { has_character_modifier = scheme_slandered_modifier }
				add = {
					value = slander_appointment_score_value
					desc = scheme_slandered_modifier
				}
			}
			if = {
				limit = { has_character_modifier = scheme_promoted_modifier }
				add = {
					value = promote_appointment_score_value	# Keep this balanced if more values are added!
					desc = scheme_promoted_modifier
				}
			}

			# Decisions
			if = {
				limit = {
					has_character_modifier = ep3_integration_promoter_modifier
					has_variable = integration_promoted_in
					var:integration_promoted_in.duchy ?= scope:title
				}
				add = {
					value = 30
					desc = ep3_integration_promoter_modifier
				}
			}

			# Conquest Dynasty has a favored culture
			if = {
				limit = {
					top_liege ?= { has_title = title:h_china }
					situation:dynastic_cycle ?= {
						has_variable = dynastic_cycle_favored_culture
						root.culture = var:dynastic_cycle_favored_culture
					}
				}
				add = {
					value = 100
					desc = dynastic_cycle_conquerer_promoted_culture
				}
			}

			# PETITION
			if = {
				limit = { scope:title.var:petition_house_rights ?= house }
				add = {
					value = 250
					desc = petition_liege_house_province_rights_value_desc
				}
			}

			# MOVEMENTS
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:expansion_movement = {
							participant_group_has_character = root
							is_movement_in_power = { MOVEMENT = expansion_movement }
						}
					}
				}
				add = {
					value = 20
					desc = expansion_movement_is_favored_appointment_desc
				}
			}
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:advancement_movement = {
							participant_group_has_character = root
							is_movement_in_power = { MOVEMENT = advancement_movement }
						}
					}
				}
				add = {
					value = 20
					desc = advancement_movement_is_favored_appointment_desc
				}
			}
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:pro_hegemon_movement = {
							participant_group_has_character = root
							#they don't have to be in power
						}
					}
				}
				add = {
					value = 20
					desc = pro_hegemon_movement_appointment_desc
				}
			}
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:conservative_movement = {
							participant_group_has_character = root
							NOT = { is_movement_in_power = { MOVEMENT = conservative_movement } }
							#they have to be in power to remove the malus
						}
					}
				}
				add = {
					value = -20
					desc = conservative_movement_appointment_value
				}
			}
			
			### EXPANDED POWER BASE
			save_temporary_value_as = temp_total
			if = {
				limit = { has_character_modifier = ep3_expanded_power_base_minor_modifier }
				add = {
					value = scope:temp_total
					multiply = 0.10
					round = yes
					min = 25
					desc = ep3_expanded_power_base_minor_modifier
				}
			}
			if = {
				limit = { has_character_modifier = ep3_expanded_power_base_medium_modifier }
				add = {
					value = scope:temp_total
					multiply = 0.20
					round = yes
					min = 50
					desc = ep3_expanded_power_base_medium_modifier
				}
			}
			if = {
				limit = { has_character_modifier = ep3_expanded_power_base_major_modifier }
				add = {
					value = scope:temp_total
					multiply = 0.30
					round = yes
					min = 75
					desc = ep3_expanded_power_base_major_modifier
				}
			}

			# ADJUST BASED ON GENDER LAW - MUST GO AT THE END
			if = {
				limit = {
					scope:title.holder.top_liege ?= { has_realm_law = male_preference_law }
					is_female = yes
				}
				multiply = {
					value = {
						value = 1
						subtract = appointment_non_preferred_gender_penalty_value
					}
					desc = appointment_male_preference_desc
				}
			}
			else_if = {
				limit = {
					scope:title.holder.top_liege ?= { has_realm_law = male_only_law }
					is_female = yes
				}
				multiply = {
					value = {
						value = 1
						subtract = appointment_opposite_gender_penalty_value
					}
					desc = appointment_male_only_desc
				}
			}
			else_if = {
				limit = {
					scope:title.holder.top_liege ?= { has_realm_law = female_preference_law }
					is_female = no
				}
				multiply = {
					value = {
						value = 1
						subtract = appointment_non_preferred_gender_penalty_value
					}
					desc = appointment_female_preference_desc
				}
			}
			else_if = {
				limit = {
					scope:title.holder.top_liege ?= { has_realm_law = female_only_law }
					is_female = no
				}
				multiply = {
					value = {
						value = 1
						subtract = appointment_opposite_gender_penalty_value
					}
					desc = appointment_female_only_desc
				}
			}

			# We remove all score from the emperor, to make sure you don't inherit governorships needlessly
			if = {
				limit = {
					is_independent_ruler = yes
				}
				multiply = {
					value = 0
					desc = appointment_is_top_liege
				}
			}
		}
	}
}

celestial_military_governor = {
	default_candidates = { direct_landed_vassal holder_close_family }
	allow_same_tier_candidates = yes

	level = merit

	candidate_score = {
		value = {
			if = {
				limit = {
					top_liege = {
						has_realm_law = candidate_score_prestige_law
					}
				}
				# Base score gained from prestige rank
				add = {
					value = 10
					multiply = prestige_level
					desc = PRESTIGE_LEVEL_CONCEPT
				} 
				if = {
					limit = {
						exists = dynasty
					}
					# Base score gained from prestige rank
					add = {
						value = 10
						multiply = dynasty.dynasty_prestige_level
						desc = DYNASTY_PRESTIGE_CONCEPT
					}
				}
			}

			# Martial skill - We use this as additional base for the overall score
			add = {
				value = martial
				multiply = 2
				desc = "[martial_skill|E]"
			}

			# Learning skill - We use this as additional base for the overall score if you have the correct cultural parameter 
			if = {
				limit = {
					culture = {
						has_cultural_parameter = military_governor_appointment_score
					}
				}
				add = {
					value = learning
					multiply = 0.5
					round = yes
					desc = "[learning_skill|E]"
				}
			}

			# Martial education provides additional score
			if = {
				limit = {
					has_trait = education_martial
				}
				if = {
					limit = {
						has_trait = education_martial_5
					}
					add = {
						value = 100
						desc = has_trait_education_martial_5
					}
				}
				else_if = {
					limit = {
						has_trait = education_martial_4
					}
					add = {
						value = 80
						desc = has_trait_education_martial_4
					}
				}
				else_if = {
					limit = {
						has_trait = education_martial_3
					}
					add = {
						value = 60
						desc = has_trait_education_martial_3
					}
				}
				else_if = {
					limit = {
						has_trait = education_martial_2
					}
					add = {
						value = 40
						desc = has_trait_education_martial_2
					}
				}
				else_if = {
					limit = {
						has_trait = education_martial_1
					}
					add = {
						value = 20
						desc = has_trait_education_martial_1
					}
				}
			}

			# Commander traits
			add = {
				value = number_of_commander_traits
				multiply = 20
				desc = number_of_commander_traits_desc
			}

			# Prowess
			add = {
				value = prowess
				desc = prowess_concept
			}
			
			# Influenced career
			if = {
				limit = {
					exists = var:merit_military_career_score_bonus
				}
				add = {
					value = var:merit_military_career_score_bonus
					desc = merit_career_score_bonus_desc
				}
			}

			# Warfare Legacy
			add = {
				value = 10
				multiply = dynasty.warfare_legacy_track_perks
				desc = has_warfare_legacy_track_desc
			}

			# Dynasty Legacy
			if = {
				limit = {
					dynasty ?= {
						has_dynasty_perk = tgp_chinese_legacy_4
					}
				}
				add = {
					value = legacy_candidate_score_bonus
					desc = "[GetDynastyPerk('tgp_chinese_legacy_4').GetName]"
				}
			}
			
			# Aspirations
			if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_1 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					multiply = poet_trait_provides_candidate_score_1_value
					desc = celestial_governor_poet_trait_desc
				}
			}
			else_if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_2 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					multiply = poet_trait_provides_candidate_score_2_value
					desc = celestial_governor_poet_trait_desc
				}
			}
			else_if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_3 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					multiply = poet_trait_provides_candidate_score_3_value
					desc = celestial_governor_poet_trait_desc
				}
			}
			else_if = {
				limit = {
					house ?= { has_house_power_parameter = poet_trait_provides_candidate_score_4 }
				}
				add = {
					value = "has_trait_xp(lifestyle_poet)"
					desc = celestial_governor_poet_trait_desc
				}
			}

			# Influence
			if = {
				limit = {
					influence_level != 1
				}
				add = {
					value = 10
					multiply = {
						value = influence_level
						subtract = 1 # Baseline is at 1, so we want the bonus to start at 2
					}
					desc = "[influence_level|E]"
				}
			}

			# Traits
			if = {
				limit = { has_trait = disinherited }
				subtract = {
					value = 200
					desc = trait_disinherited
				}
			}
			if = {
				limit = { has_trait = gallivanter }
				subtract = {
					value = 200
					desc = trait_gallivanter
				}
			}
			
			# CRIMINAL
			if = {
				limit = {
					has_trait = deviant
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "deviant_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = incestuous
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "incestuous_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = sodomite
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "sodomite_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = cannibal
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "cannibal_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = kinslayer_1
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "kinslayer_1_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = kinslayer_2
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "kinslayer_2_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = kinslayer_3
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "kinslayer_3_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = witch
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "witch_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = adulterer
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "adulterer_and_criminal_desc"
				}
			}
			if = {
				limit = {
					has_trait = fornicator
					exists = top_liege.primary_title.state_faith
					trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = top_liege.primary_title.state_faith GENDER_CHARACTER = root }
				}
				add = {
					value = -30
					desc = "fornicator_and_criminal_desc"
				}
			}

			# FAITH HOSTILITY
			if = {
				limit = {
					scope:title.holder.primary_title.state_faith ?= {
						faith_hostility_level = {
							target = root.faith
							value = faith_astray_level
						}
					}
				} #Change to faith acceptance
				subtract = {
					value = 10
					desc = astray_faith_succession_desc
				}
			}
			if = {
				limit = {
					scope:title.holder.primary_title.state_faith ?= {
						faith_hostility_level = {
							target = root.faith
							value = faith_hostile_level
						}
					}
				} #Change to faith acceptance
				subtract = {
					value = 20
					desc = hostile_faith_succession_desc
				}
			}
			if = {
				limit = {
					scope:title.holder.primary_title.state_faith ?= {
						faith_hostility_level = {
							target = root.faith
							value >= faith_evil_level
						}
					}
				} #Change to faith acceptance
				subtract = {
					value = 30
					desc = evil_faith_sucession_desc
				}
			}

			# PERKS
			if = {
				limit = { has_perk = ducal_conquest_perk }
				add = {
					value = 30
					desc = ducal_conquest_perk_name_desc
				}
			}

			# LOWBORN? EW no
			if = {
				limit = {
					is_lowborn = yes
				}
				subtract = {
					value = 25
					desc = lowborn_desc_succession
				}
			}

			# RELATIONS
			if = { # Is child of holder
				limit = {
					scope:title.holder ?= { is_parent_of = root }
				}
				add = {
					value = 30
					desc = "parent_holder_desc"
				}
			}
			else_if = { # Is family of holder
				limit = {
					scope:title.holder ?= { is_close_family_of = root }
				}
				add = {
					value = 20
					desc = "close_family_holder_desc"
				}
			}
			else_if = { # Is family of holder's spouse
				limit = {
					scope:title.holder ?= {
						any_spouse = { is_close_family_of = root }
						NOT = { is_close_family_of = root }
					}
				}
				add = {
					value = 10
					desc = "close_family_married_to_holder_desc"
				}
			}
			if = { # Is a friend
				limit = {
					scope:title.holder ?= { has_relation_friend = root }
				}
				add = {
					value = 15
					desc = governor_friend_desc
				}
			}
			if = { # Is a elder
				limit = {
					scope:title.holder ?= { has_relation_elder = root }
				}
				add = {
					value = 15
					desc = governor_elder_desc
				}
			}
			if = { # Is a disciple
				limit = {
					scope:title.holder ?= { has_relation_disciple = root }
				}
				add = {
					value = 10
					desc = governor_disciple_desc
				}
			}

			# REGENT OF EMPEROR
			if = {
				limit = { scope:title.holder.diarch ?= root }
				add = {
					value = scope:title.holder.diarchy_swing
					desc = governor_diarch_desc
				}
			}

			# Schemes
			if = {
				limit = { has_character_modifier = scheme_slandered_modifier }
				add = {
					value = slander_appointment_score_value
					desc = scheme_slandered_modifier
				}
			}
			if = {
				limit = { has_character_modifier = scheme_promoted_modifier }
				add = {
					value = promote_appointment_score_value	# Keep this balanced if more values are added!
					desc = scheme_promoted_modifier
				}
			}

			# Decisions
			if = {
				limit = {
					has_character_modifier = ep3_integration_promoter_modifier
					has_variable = integration_promoted_in
					var:integration_promoted_in.duchy ?= scope:title
				}
				add = {
					value = 30
					desc = ep3_integration_promoter_modifier
				}
			}

			# Conquest Dynasty has a favored culture
			if = {
				limit = {
					top_liege = { has_title = title:h_china }
					situation:dynastic_cycle ?= {
						has_variable = dynastic_cycle_favored_culture
						root.culture = var:dynastic_cycle_favored_culture
					}
				}
				add = {
					value = 100
					desc = dynastic_cycle_conquerer_promoted_culture
				}
			}

			# PETITION
			if = {
				limit = { scope:title.var:petition_house_rights ?= house }
				add = {
					value = 250
					desc = petition_liege_house_province_rights_value_desc
				}
			}

			# MOVEMENTS
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:expansion_movement = {
							participant_group_has_character = root
							is_movement_in_power = { MOVEMENT = expansion_movement }
						}
					}
				}
				add = {
					value = 20
					desc = expansion_movement_is_favored_appointment_desc
				}
			}
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:advancement_movement = {
							participant_group_has_character = root
							is_movement_in_power = { MOVEMENT = advancement_movement }
						}
					}
				}
				add = {
					value = 20
					desc = advancement_movement_is_favored_appointment_desc
				}
			}
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:pro_hegemon_movement = {
							participant_group_has_character = root
							#they don't have to be in power
						}
					}
				}
				add = {
					value = 20
					desc = pro_hegemon_movement_appointment_desc
				}
			}
			if = {
				limit = {
					situation:dynastic_cycle ?= {
						situation_participant_group:conservative_movement = {
							participant_group_has_character = root
							NOT = { is_movement_in_power = { MOVEMENT = conservative_movement } }
							#they have to be in power to remove the malus
						}
					}
				}
				add = {
					value = -20
					desc = conservative_movement_appointment_value
				}
			}
			
			
			
			### EXPANDED POWER BASE
			save_temporary_value_as = temp_total
			if = {
				limit = { has_character_modifier = ep3_expanded_power_base_minor_modifier }
				add = {
					value = scope:temp_total
					multiply = 0.10
					round = yes
					min = 25
					desc = ep3_expanded_power_base_minor_modifier
				}
			}
			if = {
				limit = { has_character_modifier = ep3_expanded_power_base_medium_modifier }
				add = {
					value = scope:temp_total
					multiply = 0.20
					round = yes
					min = 50
					desc = ep3_expanded_power_base_medium_modifier
				}
			}
			if = {
				limit = { has_character_modifier = ep3_expanded_power_base_major_modifier }
				add = {
					value = scope:temp_total
					multiply = 0.30
					round = yes
					min = 75
					desc = ep3_expanded_power_base_major_modifier
				}
			}

			# Must be eligible as a commander
			if = {
				limit = {
					NOT = {
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = top_liege }
					}
				}
				add = {
					value = -1000
					desc = cannot_be_commander
				}
			}

			# We remove all score from the emperor, to make sure you don't inherit governorships needlessly
			if = {
				limit = {
					is_independent_ruler = yes
				}
				multiply = {
					value = 0
					desc = appointment_is_top_liege
				}
			}
		}
	}
}
