﻿#Original file from Catholic Trinity by Uber
### Configuration parameters

# General character stat parameters
# If these are set to zero, then the corresponding contribution will never show up in the breakdown.
emperor_score_per_prestige 								= 0.1
emperor_score_per_piety 								= 0.05
emperor_score_per_gold 									= 0.2

# The following don't get disabled by setting them to 0
emperor_score_per_age 									= 2
emperor_score_italy 									= 500
emperor_score_culture 									= -400
emperor_score_per_popinion_positive						= 2
emperor_score_per_popinion_negative						= 3.5
dynasty_prestige_per_emperor_score	 					= 40

# Secular power parameters
emperor_secular_power_multiplier 						= 0.5
emperor_county_bonus  									= 10
emperor_duchy_bonus   									= 30
emperor_kingdom_bonus 									= 100

#Scripted Modifier Score
#emperor_has_modifier_good 								= 250
#emperor_has_modifier_bad 								= -100

emperor_too_old 										= -300
emperor_is_child										= -300

emperor_score_pweakhook									= 100
emperor_score_pstronghook								= 200
emperor_score_karling									= 100
emperor_score_imperial_dynasty							= 100
emperor_score_territory									= 2
emperor_score_military									= 0.05
emperor_score_is_heir									= 200
emperor_score_has_heir									= 50
emperor_score_wrong_faith								= -150
emperor_has_serious_disease								= -300
emperor_is_criminal										= -200

# Summary values
HRT_imperator_score = {
	value = 0
	if = {
		limit = {
			any_HRT_candidati = {
				count > 0
			}
			#exists = this # To not log errors when iterating through members of an empty list
			#is_alive = yes
		}
		if = {
			limit = {
				NOT = { has_variable = HRT_prince_var } # Primary Heir gets partial score from current Emperor
			}
			add = emperor_prestige_bonus
			add = emperor_piety_bonus
			add = emperor_gold_bonus
			add = emperor_age_bonus
			add = emperor_dynasty_bonus
			add = emperor_location_bonus
			add = emperor_popinion_bonus
			add = emperor_secular_power_bonus
			#add = emperor_recent_event_modifier
			add = emperor_too_old_malus
			add = emperor_is_child_malus
			add = emperor_culture_malus
			add = emperor_karling_dynasty_bonus
			add = emperor_is_imperial_dynasty_bonus
			add = emperor_phook_bonus
			add = emperor_territory_bonus
			add = emperor_military_bonus
			add = emperor_is_heir_bonus
			add = emperor_has_heir_bonus
			add = emperor_has_no_heir_malus
			add = emperor_has_wrong_faith_malus
			add = emperor_has_serious_disease_malus
			add = emperor_is_criminal_malus
		}
		else_if = {
			limit = {
				has_variable = HRT_prince_var
			}
			add = emperor_prestige_bonus
			add = emperor_piety_bonus
			add = emperor_gold_bonus
			add = emperor_age_bonus
			add = father.emperor_dynasty_bonus
			add = father.emperor_location_bonus
			add = emperor_popinion_bonus
			add = father.emperor_secular_power_bonus
			#add = emperor_recent_event_modifier
			add = emperor_too_old_malus
			add = emperor_is_child_malus
			add = emperor_culture_malus
			add = emperor_karling_dynasty_bonus
			add = emperor_is_imperial_dynasty_bonus
			add = emperor_phook_bonus
			add = father.emperor_territory_bonus
			add = father.emperor_military_bonus
			add = emperor_is_heir_bonus
			add = emperor_has_heir_bonus
			add = emperor_has_no_heir_malus
			add = emperor_has_wrong_faith_malus
			add = emperor_has_serious_disease_malus
			add = emperor_is_criminal_malus
		}
	}
}

HRT_imperator_score_prince = {
	value = 0
	if = {
		limit = {
			exists = this # To not log errors when iterating through members of an empty list
			is_alive = yes
		}
		add = emperor_prestige_bonus
		add = emperor_piety_bonus
		add = emperor_gold_bonus
		add = emperor_age_bonus
		add = emperor_dynasty_bonus
		add = emperor_location_bonus
		add = emperor_popinion_bonus
		add = emperor_secular_power_bonus
		#add = emperor_recent_event_modifier
		add = emperor_too_old_malus
		add = emperor_culture_malus
		add = emperor_karling_dynasty_bonus
		add = emperor_is_imperial_dynasty_bonus
		add = emperor_phook_bonus
		add = emperor_territory_bonus
		add = emperor_military_bonus
		add = emperor_is_heir_bonus
		add = emperor_has_heir_bonus
		add = emperor_has_no_heir_malus
		add = emperor_has_wrong_faith_malus
		add = emperor_has_serious_disease_malus
		add = emperor_is_criminal_malus
	}
}

# Subterms
emperor_prestige_bonus = {
	value = prestige
	multiply = emperor_score_per_prestige
	max = 200
}
emperor_piety_bonus = {
	value = piety
	multiply = emperor_score_per_piety
	max = 200
}
emperor_gold_bonus = {
	value = gold
	multiply = emperor_score_per_gold
	max = 200
}
emperor_age_bonus = {
	value 	 = age
	multiply = emperor_score_per_age
	if =		{limit = {age < 16} multiply = 0}
	if =		{limit = {age >= 61} multiply = 0}
	max = 100
}
emperor_dynasty_bonus = {
	value = 0
	if = 		{limit = {exists = this exists = dynasty}} add = {value = dynasty.dynasty_prestige divide = dynasty_prestige_per_emperor_score}
}
emperor_karling_dynasty_bonus = {
	value = 0
	if =		{limit = {exists = this exists = dynasty dynasty = dynasty:25061} add = emperor_score_karling}
}
emperor_is_imperial_dynasty_bonus = {
	value = 0
	if =		{limit = {exists = this exists = dynasty exists = title:c_aachen.var:HRT_emperor dynasty = title:c_aachen.var:HRT_emperor.dynasty} add = emperor_score_imperial_dynasty}
}
emperor_location_bonus = {
	value = 0
	if = 		{limit = {any_held_title = {this = title:k_italy}} add = emperor_score_italy}
}
emperor_culture_malus = {
	value = 0
	if 		= {limit = {NOR  = {
	culture = {has_cultural_pillar = heritage_central_germanic}
	culture = {has_cultural_pillar = heritage_frankish}
	culture = {has_cultural_pillar = heritage_latin}}}
	add = emperor_score_culture}
}
emperor_popinion_bonus = {
	value = 0
	if = {
		limit = {
			has_variable = HRT_popinion
			var:HRT_popinion >= 0
		}
		add = var:HRT_popinion
		multiply = emperor_score_per_popinion_positive
	}
	else_if = {
		limit = {
			has_variable = HRT_popinion
			var:HRT_popinion < 0
		}
		add = var:HRT_popinion
		multiply = emperor_score_per_popinion_negative
	}
}
emperor_phook_bonus = {
	value = 0
	if = {
		limit = {
			has_strong_usable_hook = faith:catholic.religious_head
		}
		add = emperor_score_pstronghook
	}
	else_if = {
		limit = {
			has_weak_hook = faith:catholic.religious_head
		}
		add = emperor_score_pweakhook
	}
}
emperor_secular_power_bonus = {
	value = 0
	if = {
		limit = {is_landed = yes}
		every_held_title = {limit = {tier = tier_county} add = emperor_county_bonus}
		every_held_title = {limit = {tier = tier_duchy} add = emperor_duchy_bonus}
		every_held_title = {limit = {tier = tier_kingdom} add = emperor_kingdom_bonus}
	}
	multiply = emperor_secular_power_multiplier
}
emperor_territory_bonus = {
	value = 0
	every_sub_realm_county = {
		add = emperor_score_territory
	}
}
emperor_military_bonus = {
	value = current_military_strength
	multiply = emperor_score_military
}
emperor_is_heir_bonus = {
	value = 0
	if = {
		limit = {
			father ?= {
				HRT_is_emperor_trigger = yes
				primary_title = root.primary_title
			}
		}
		add = emperor_score_is_heir
	}
}
emperor_has_heir_bonus = {
	value = 0
	if = {
		limit = {
			any_child = {
				is_male = yes
				NOR = {
					has_trait = bastard
					has_trait = denounced
					has_trait = disinherited
					has_trait = excommunicated
				}
			}
		}
		add = emperor_score_has_heir
	}
}
emperor_has_no_heir_malus = {
	value = 0
	if = {
		limit = {
			NOT = {
				any_child = {
					is_male = yes
					NOR = {
						has_trait = bastard
						has_trait = denounced
						has_trait = disinherited
						has_trait = excommunicated
					}
				}
			}
		}
		subtract = emperor_score_has_heir
	}
}
emperor_has_wrong_faith_malus = {
	value = 0
	if = {
		limit = {
			NOT = {
				faith = faith:catholic
			}
		}
		subtract = emperor_score_wrong_faith
	}
}
#emperor_recent_event_modifier = {
#	value = 0 
#	if = { limit = { has_character_flag = emperor_boost } add = emperor_has_modifier_good }
#	if = { limit = { has_character_flag = emperor_debuff } add = emperor_has_modifier_bad }
#}
emperor_too_old_malus = {
	value = 0 
	if = { limit = { age >= 61 } add = emperor_too_old } #Henry IV was the oldest to get crowned with this age 
}
emperor_is_child_malus = {
	value = 0 
	if = { limit = { age < 16 } add = emperor_is_child } 
}
emperor_has_serious_disease_malus = {
	value = 0
	if = {
		limit = {
			OR = {
				has_serious_disease_trigger = yes
				has_contagious_deadly_disease_trigger = yes
				has_epidemic_disease_trigger = yes
				has_trait = infirm
				has_trait = incapable
			}
		}
		add = emperor_has_serious_disease
	}
}

emperor_is_criminal_malus = {
	value = 0
	if = {
		limit = {
			OR = {
				has_trait = murderer
				has_trait = incestuous
				has_trait = sodomite
				has_trait = cannibal
				has_trait = kinslayer
			}
		}
		add = emperor_is_criminal
	}
	else_if = {
		limit = {
			OR = {
				has_trait = deviant
				has_trait = adulterer
				has_trait = fornicator
			}
		}
		add = emperor_is_criminal
		multiply = 0.5
	}
}