﻿devoted = {
	score = {
		# If we are regula we add a large flat score
		if = {
			limit = {
				faith = scope:liege.faith
				is_regula_trigger = yes
			}
			add = 500
		} 
		else = {
			add = -5000
		}

		# If we are charmed we add a large score
		if = {
			limit = {
				has_trait = mulsa
			}
			add = 1000
		}

		if = {
			limit = {
				has_trait = tropaeum
			}
			add = 1500
		}
		
		if = {
			limit = {
				has_trait = paelex
			}
			add = 2500
		}
		
		if = {
			limit = {
				has_trait = familia_paelex
			}
			add = 3000
		}

		if = {
			limit = {
				has_trait = domina
			}
			add = 5000
		}

		# Add Sins and Virtues
		if = {
			limit = {
				num_virtuous_traits >= 1
			}
			add = {
				value = 100
				multiply = num_virtuous_traits
			}
		}
		if = {
			limit = {
				num_sinful_traits >= 1
			}
			add = {
				value = -200
				multiply = num_sinful_traits
			}
		}

		# No Males
		if = {
			limit = {
				is_male = yes
			}
			multiply = 0
			add = -100
		}
	}

	# How do we score player heir?
	# Bonus
		# Attributes
			# Add attributes with multipliers for each.
			# Diplomacy X 10
			# Martial X 5
			# Stewardship X 15
			# Intrigue X 5
			# Learning X 10
		# AI Values
			# Add Compassion, Honor and Zeal
		# Sins and Virtues
		# Congential Traits
	# Malus
		# Can't be female
		# Kids get 0.5 multiplier
	heir_score = {
		
		# Attributes
		add = { value = diplomacy 	multiply = 10 }
		add = { value = martial 	multiply = 5 }
		add = { value = stewardship multiply = 15 }
		add = { value = intrigue 	multiply = 5 }
		add = { value = learning 	multiply = 10 }

		# AI Values
		add = ai_compassion
		add = ai_honor
		add = ai_zeal

		# Sins and Virtues
		if = {
			limit = {
				num_virtuous_traits >= 1
			}
			add = {
				value = 100
				multiply = num_virtuous_traits
			}
		}
		if = {
			limit = {
				num_sinful_traits >= 1
			}
			add = {
				value = -200
				multiply = num_sinful_traits
			}
		}

		# Congential Traits
		if = {
			limit = { has_trait = beauty_good_1 }
			add = 100
		}
		if = {
			limit = { has_trait = beauty_good_2 }
			add = 200
		}
		if = {
			limit = { has_trait = beauty_good_3 }
			add = 300
		}

		if = {
			limit = { has_trait = intellect_good_1 }
			add = 100
		}
		if = {
			limit = { has_trait = intellect_good_2 }
			add = 200
		}
		if = {
			limit = { has_trait = intellect_good_3 }
			add = 300
		}

		if = {
			limit = { has_trait = physique_good_1 }
			add = 100
		}
		if = {
			limit = { has_trait = physique_good_2 }
			add = 200
		}
		if = {
			limit = { has_trait = physique_good_3 }
			add = 300
		}

		if = {
			limit = { has_trait = fecund }
			add = 100
		}
		if = {
			limit = { has_trait = pure_blooded }
			add = 150
		}

		# Same faith
		if = {
			limit = {
				NOR = { 
					faith = scope:liege.faith
					is_regula_trigger = yes
				}
			}
			multiply = 0
			add = -5000
		}

		# Female should be impossible
		if = {
			limit = {
				is_female = yes
			}
			multiply = 0
			add = -100
		}

		# Kids should be rare, unless they have good stats!
		if = {
			limit = {
				is_adult = no
			}
			multiply = 0.5
		}
	}

	# We have to be part of Regula religion
	is_valid = {
		faith = scope:liege.faith
		is_regula_trigger = yes
	}	
}