﻿elector_self_voting_pattern_feudal_elective_modifier = {
	##########################	Elector voting himself	##########################
	modifier = {
		add = 15
		desc = tooltip_feudal_elector_vote_myself
		this = scope:candidate
		NOR = {
			has_trait = humble
			has_trait = content
			has_trait = craven
			has_trait = lazy
			has_trait = depressed
			has_trait = ambitious
		}
		NOT = {
			scope:holder = {
				is_parent_of = root
			}
		}
	}
	modifier = {
		add = -25
		desc = tooltip_feudal_elector_vote_not_myself
		this = scope:candidate
		NOT = { has_trait = ambitious }
		OR = {
			has_trait = humble
			has_trait = content
			has_trait = craven
			has_trait = lazy
			has_trait = depressed
		}
	}
	modifier = {
		add = {
			add = 40
			if = {
				limit = {
					ai_boldness > 0
				}
				add = this.ai_boldness
			}
			if = {
				limit = {
					ai_greed > 0
				}
				add = this.ai_greed
			}
		}
		desc = tooltip_feudal_elector_vote_myself_heir
		this = scope:candidate
		NOR = {
			has_trait = humble
			has_trait = content
			has_trait = craven
			has_trait = lazy
			has_trait = depressed
			has_trait = ambitious
		}
		scope:holder = {
			is_parent_of = root
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_myself_ambitious
		this = scope:candidate
		has_trait = ambitious
		is_adult = yes
		add = {
			add = 40
			if = {
				limit = {
					ai_boldness > 0
				}
				add = this.ai_boldness
			}
			if = {
				limit = {
					ai_greed > 0
				}
				add = this.ai_greed
			}
		}
	}
	modifier = {
		add = 100
		desc = tooltip_feudal_elector_vote_myself_ruler_choice
		this = scope:candidate
		this = scope:holder_candidate
		is_adult = yes
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_myself_ruling_dynasty
		this = scope:candidate
		exists = this.dynasty
		exists = scope:holder.dynasty
		this.dynasty = scope:holder.dynasty
		is_adult = yes
		add = {
			value = 40
			if = {
				limit = {
					scope:candidate.dynasty = { dynasty_prestige_level >= 10 }
				}
				add = 20
			}
			if = {
				limit = {
					scope:candidate.dynasty = { dynasty_prestige_level >= 7 }
				}
				add = 20
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_myself_sick
		this = scope:candidate
		is_healthy = no
		add = {
			subtract = 20
			if = {
				limit = {
					has_trait = pneumonic
				}
				subtract = 10
			}
			if = {
				limit = {
					has_trait = leper
				}
				subtract = 50
			}
			if = {
				limit = {
					has_trait = bubonic_plague
				}
				subtract = 50
			}
			if = {
				limit = {
					has_trait = wounded_3
				}
				subtract = 25
			}
		}
		is_adult = yes
	}
	#Claims
	modifier = {
		add = {
			value = 30
			if = {
				limit = {
					has_strong_claim_on = scope:title
				}
				add = 30
			}
		}
		desc = tooltip_feudal_elector_vote_myself_claimant
		this = scope:candidate
		scope:candidate = {
			OR = {
				has_strong_claim_on = scope:title
				has_weak_claim_on = scope:title
			}
		}
	}
	# Political Circumstances
	## Disloyal regents vote for themselves.
	modifier = {
		add = 50
		desc = tooltip_feudal_elector_vote_myself_diarch
		this = scope:candidate
		is_diarch_of_target = scope:holder
		# Loyal diarchs won't try to usurp the throne.
		diarch_loyalty < diarch_loyalty_visibly_loyal_threshold
	}
	## Loyal regents vote for their liege's candidate.
	modifier = {
		add = 50
		desc = tooltip_feudal_elector_vote_liege_candidate_diarch
		is_diarch_of_target = scope:holder
		scope:candidate = scope:holder_candidate
		diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold
	}
}

holder_voting_pattern_feudal_elective_modifier = {
	##########################	Holder voting pattern	##########################
	modifier = { #Current ruler will always try to elect his player heir before everybody else.
		add = 50
		desc = tooltip_feudal_holder_elector_vote_player_heir
		player_heir = scope:candidate
		NOT = { player_heir = root }
		scope:holder = {
			this = root
			NOT = {
				has_relation_rival = scope:candidate #Unless is rival.
			}
		}
	}
	modifier = { #Current ruler should prefer his own children.
		desc = tooltip_feudal_holder_elector_vote_not_child
		add = {
			subtract = 50
			if = { #Even less so if not same House.
				limit = {
					exists = root.house
					exists = scope:candidate.house
					NOT = {
						root.house = scope:candidate.house
					}
				}
				subtract = 50
			}
			if = { #Even less so if not same Dynasty.
				limit = {
					exists = root.dynasty
					exists = scope:candidate.dynasty
					NOT = {
						root.dynasty = scope:candidate.dynasty
					}
				}
				subtract = 150
			}
		}
		scope:holder = {
			this = root
			NOT = {
				scope:candidate = {
					is_child_of = scope:holder
				}
			}
		}
	}
	modifier = { #Heir is unable to sire another heir.
		add = -50
		desc = tooltip_feudal_holder_elector_vote_infertile
		scope:holder = root
		scope:candidate = {
			NOT = {
				any_child = {
					is_alive = yes
				}
			}
			OR = {
				has_trait = celibate
				is_eunuch_trigger = yes
				has_trait = infertile
				has_trait = incapable
			}
		}
	}
}

elector_voting_pattern_circumstances_feudal_elective_modifier = {
	##########################	Elector voting patterns (circumstances)	##########################
	#Sexism
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_agnatic_woman
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = male_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = male_preference_law }
				scope:title = {
					NOR = {
						has_title_law = female_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_male_dominated }
		}
		scope:candidate = { is_female = yes }
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = male_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = male_preference_law }
							scope:title = {
								NOR = {
									has_title_law = female_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_male_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_enatic_man
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = female_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = female_preference_law }
				scope:title = {
					NOR = {
						has_title_law = male_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_female_dominated }
		}
		scope:candidate = {
			is_female = no
		}
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = female_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = female_preference_law }
							scope:title = {
								NOR = {
									has_title_law = male_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_female_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	#Ageism
	modifier = {
		add = -30
		desc = tooltip_feudal_elector_vote_baby
		NOT = { this = scope:candidate }
		scope:candidate = {
			age < 5
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_child
		NOT = { this = scope:candidate }
		scope:candidate = {
			age > 5
			age < 16
		}
		add = {
			subtract = 10
			if = {
				limit = {
					age < 10
				}
				subtract = 15
			}
		}
	}
	modifier = { #Still too young for older rulers
		add = -10
		desc = tooltip_feudal_elector_vote_youngster
		NOT = { this = scope:candidate }
		age > 40
		scope:candidate = {
			age > 16
			age < 25
		}
	}
	modifier = { #Or too old for younger rulers.
		add = -10
		desc = tooltip_feudal_elector_vote_oldtimer
		NOT = { this = scope:candidate }
		age < 30
		scope:candidate = {
			age > 40
			age < 50
		}
	}
	modifier = { #Or simply too old overall.
		add = -15
		desc = tooltip_feudal_elector_vote_decrepit
		NOT = { this = scope:candidate }
		scope:candidate = { age > 50 }
	}
	#Culturism
	modifier = {
		desc = tooltip_feudal_elector_vote_fellow_culture
		NOT = { this = scope:candidate }
		root.culture = scope:candidate.culture
		add = {
			add = 10
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				add = 10
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_stranger
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { root.culture = scope:candidate.culture }
		culture = { has_same_culture_heritage = scope:candidate.culture }
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 15
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 15
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_foreigner
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { culture = { has_same_culture_heritage = scope:candidate.culture } }
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 30
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 30
			}
		}
	}
	modifier = { #Candidate is a foreigner's pet
		desc = tooltip_feudal_elector_vote_strangers_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { this.culture = root.culture }
			culture = { has_same_culture_heritage = root.culture }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 10
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 10
			}
		}
	}
	modifier = { #Candidate is a foreigner's pet
		desc = tooltip_feudal_elector_vote_foreigners_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { culture = { has_same_culture_heritage = root.culture } }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 15
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 15
			}
		}
	}
	modifier = { #If candidate is elected, he will rule from a capital outside this de jure.
		desc = tooltip_feudal_elector_vote_political_concerns
		is_playable_character = yes
		exists = capital_county
		capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } }

		OR = { # If the current holder is reigning from within the title, there is no reason to believe a lower tier candidate would not.
			scope:holder = { 
				capital_county = {
					scope:title = {
						NOT = { is_de_jure_liege_or_above_target = prev }
					}
				}
			}
			scope:candidate = {
				highest_held_title_tier >= scope:title.tier
			}
		}

		scope:candidate = {
			is_ruler = yes
			#is_vassal_of = scope:holder
			exists = capital_county
			NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
		}
		add = {
			subtract = 15
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 15
			}
		}
	}
	modifier = { #Candidate is a foreign ruler.
		desc = tooltip_feudal_elector_vote_encroaching_foreigner
		is_playable_character = yes
		exists = capital_county
		scope:candidate = {
			is_ruler = yes
			NOT = { target_is_liege_or_above = scope:holder }
		}
		add = {
			subtract = 30
			if = { #Candidate is a foreign non-dejure ruler.
				limit = {
					NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
				}
				subtract = 470
			}
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 50
			}
		}
	}
	#Faithism
	modifier = { #Accepted but different faith. (Buddhism vs Hinduism)
		desc = tooltip_feudal_elector_vote_different_faith
		NOT = { root.faith = scope:candidate.faith }
		ai_zeal >= 0 #Does not care otherwise.
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_fully_accepted_level
			}
		}
		add = {
			subtract = 25
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 25
			}
		}
	}
	modifier = { #Astray (Catholic vs Orthodox)
		desc = tooltip_feudal_elector_vote_astray
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_astray_level
			}
		}
		add = {
			subtract = 50
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 50
			}
		}
	}
	modifier = { #Heretic (Catholic vs Cathar)
		desc = tooltip_feudal_elector_vote_heretic
		add = {
			subtract = 100
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 100
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_hostile_level
			}
		}
	}
	modifier = { #Infidel (Catholic vs Ashari)
		desc = tooltip_feudal_elector_vote_evil_heathen
		add = {
			subtract = 200
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 75
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 75
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 75
			}
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 150
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_evil_level
			}
		}
	}

	#Barbarism
	modifier = {
		add = -15
		desc = tooltip_feudal_elector_vote_uncivilized
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_republic
		}
		scope:candidate = {
			OR = {
				government_has_flag = government_is_clan
				government_has_flag = government_is_tribal
			}
		}
	}
	modifier = {
		add = -15
		desc = tooltip_feudal_elector_vote_settled
		government_has_flag = government_is_clan
		scope:candidate = {
			NOT = { government_has_flag = government_is_clan }
		}
	}
	#Nepotism
	modifier = {
		add = 10
		desc = tooltip_feudal_elector_vote_dynasty
		NOT = { this = scope:candidate }
		exists = root.dynasty
		exists = scope:candidate.dynasty
		root.dynasty = scope:candidate.dynasty
		scope:candidate = {
			NOT = { is_close_family_of = root }
		}
	}
	modifier = {
		add = 20
		desc = tooltip_feudal_elector_vote_relative
		NOT = { this = scope:candidate }
		scope:candidate = {
			is_close_family_of = root
			NOT = { is_child_of = root }
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_parent
		NOT = { this = scope:candidate }
		scope:candidate = { is_child_of = root }
		add = {
			value = 30
			if = { #Current Ruler should tend to often pick one of his own children as potential heirs.
				limit = { this = scope:holder }
				add = 30
			}
		}
	}
	modifier = { #Elector AI should not pick current ruler's distant relatives
		add = -75
		desc = tooltip_feudal_elector_vote_distant_relative
		NOR = {
			this = scope:candidate
			is_close_family_of = root
			scope:candidate = scope:holder_candidate #Avoid if he's being specifically picked by the current ruler.
		}
		exists = scope:candidate.dynasty
		exists = scope:holder.dynasty
		scope:candidate = { #Candidate in question must not be of the same house as the Elector.
			dynasty = scope:holder.dynasty
			NOT = {
				house = root.house
			}
		}
	}
	#Educational preferences
	modifier = { # Warrior society prefers warriors
		desc = tooltip_feudal_elector_vote_martial_education
		NOT = { this = scope:candidate }
		this_is_martial_society_trigger = yes
		scope:candidate = {
			martial >= 10
			OR = {
				has_trait = education_martial
				has_lifestyle = martial_lifestyle
				has_trait = lifestyle_blademaster
				has_martial_lifestyle_trait_trigger = yes
			}
		}
		add = {
			add = 15
			if = {
				limit = { # Scandinavian elective boost
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = { # Diplomatic society prefers stewards and diplomats
		add = 15
		desc = tooltip_feudal_elector_vote_diplomatic_education
		NOT = { this = scope:candidate }
		this_is_diplomatic_society_trigger = yes
		scope:candidate = {
			OR = {
				AND = {
					diplomacy >= 10
					OR = {
						has_trait = education_diplomacy
						has_lifestyle = diplomacy_lifestyle
						has_diplomacy_lifestyle_trait_trigger = yes
						has_trait = lifestyle_reveler
						has_trait = gallant
					}
				}
				AND = {
					stewardship >= 10
					OR = {
						has_trait = education_stewardship
						has_lifestyle = stewardship_lifestyle
						has_stewardship_lifestyle_trait_trigger = yes
					}
				}
			}
		}
	}
	modifier = { # Spiritual society prefers scholars
		add = 15
		desc = tooltip_feudal_elector_vote_spiritual_education
		NOT = { this = scope:candidate }
		this_is_spiritual_society_trigger = yes
		scope:candidate = {
			learning >= 10
			OR = {
				has_trait = education_learning
				has_lifestyle = learning_lifestyle
				has_learning_lifestyle_trait_trigger = yes
				has_trait = lifestyle_mystic
				has_trait = lifestyle_physician
			}
		}
	}
	#Claims
	modifier = {
		add = 30
		desc = tooltip_feudal_elector_vote_strong_claimant
		NOT = { this = scope:candidate }
		scope:candidate = {
			OR = {
				has_strong_claim_on = scope:title
				AND = {
					NOT = { has_trait = bastard }
					is_child_of = scope:holder
				}
			}
		}
	}
	modifier = {
		add = 15
		desc = tooltip_feudal_elector_vote_weak_claimant
		NOT = { this = scope:candidate }
		scope:candidate = { has_weak_claim_on = scope:title }
	}
	# Political Circumstances
	modifier = {
		add = {
			if = {
				limit = {
					scope:holder = { has_diarchy_parameter = diarchy_type_is_temporary_regency }
				}
				add = 20
			}
			else = { add = 40 }
		}
		desc = tooltip_feudal_elector_vote_regent_already_governs
		NOT = { this = scope:candidate }
		scope:candidate = { is_diarch_of_target = scope:holder }
	}
}

elector_voting_pattern_prestige_piety_feudal_elective_modifier = {
	##########################	Elector voting patterns (prestige/piety)	##########################
	#Prestige
	modifier = {
		desc = tooltip_feudal_elector_vote_prestige_negative
		add = -10
		NOT = { this = scope:candidate }
		scope:candidate = { prestige_level < 1 }
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_prestige_positive
		add = {
			value = scope:candidate.prestige_level
			subtract = 1
			multiply = 5
		}
		NOT = { this = scope:candidate }
		scope:candidate = { prestige_level >= 2 }
	}
	#Dynasty Prestige
	modifier = {
		desc = tooltip_feudal_elector_vote_dynasty_prestige
		add = {
			value = 20
			if = {
				limit = {
					scope:candidate.dynasty = { dynasty_prestige_level >= 10 }
				}
				add = 20
			}
			if = {
				limit = {
					scope:candidate.dynasty = { dynasty_prestige_level >= 7 }
				}
				add = 20
			}
		}
		NOT = { this = scope:candidate }
		exists = scope:candidate.dynasty
		scope:candidate.dynasty = {
			dynasty_prestige_level >= 4
		}
	}
	#Piety
	modifier = {
		desc = tooltip_feudal_elector_vote_piety_negative
		NOT = { scope:title = { has_title_law = princely_elective_succession_law } }
		add = -10
		NOT = { this = scope:candidate }
		ai_zeal > 0
		scope:candidate = { piety_level < 1 }
	}
	modifier = { #More extreme for Princely Elective
		desc = tooltip_feudal_elector_vote_piety_negative
		scope:title = { has_title_law = princely_elective_succession_law }
		NOT = { this = scope:candidate }
		ai_zeal > -30
		scope:candidate = { piety_level < 1 }
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_piety_positive
		NOT = { scope:title = { has_title_law = princely_elective_succession_law } }
		add = {
			value = scope:candidate.piety_level
			subtract = 1
			multiply = 5
		}
		NOT = { this = scope:candidate }
		faith = scope:candidate.faith
		ai_zeal > 0
		scope:candidate = { piety_level >= 2 }
	}
	modifier = { #More extreme for Princely Elective
		desc = tooltip_feudal_elector_vote_piety_positive
		scope:title = { has_title_law = princely_elective_succession_law }
		add = {
			value = scope:candidate.piety_level
			subtract = 1
			multiply = 10
		}
		NOT = { this = scope:candidate }
		faith = scope:candidate.faith
		ai_zeal > -30
		scope:candidate = { piety_level >= 2 }
	}
}

elector_voting_pattern_traits_feudal_elective_modifier = {
	##########################	Elector voting patterns (traits)	##########################
	#Personality Traits compatibility
	#Sins vs Virtues
	#Crime traits
	#Attraction
	#Special cases (ex. deformities, disfigured for Byzantines)

	#Trait compatibility between elector and candidate
	compatibility_modifier = {
		who = root
		compatibility_target = scope:candidate
		min = -50
		max = 50
		trigger = {
			NOT = { root = scope:candidate }
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_sinful
		NOT = { this = scope:candidate } #Do not judge yourself.
		NOT = { has_trait = cynical }
		ai_zeal > 0
		scope:candidate = { num_sinful_traits >= 1 }
		add = {
			subtract = 5
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_sinful_traits >= 2 }
				}
				subtract = 5
			}
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_sinful_traits >= 3 }
				}
				subtract = 5
			}
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_sinful_traits >= 4 }
				}
				subtract = 5
			}
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_sinful_traits >= 5 }
				}
				subtract = 5
			}
			if = { #Princely elective more unforgiving.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				multiply = 2
			}
			multiply = ai_zeal #...Multiply by Elector Zeal.
			multiply = 0.1 #Reduce overall to avoid extreme numbers.
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_virtuous
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			has_trait = cynical
		}
		ai_zeal > 0
		scope:candidate = { num_virtuous_traits >= 1 }
		add = {
			add = 5
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_virtuous_traits >= 2 }
				}
				add = 5
			}
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_virtuous_traits >= 3 }
				}
				add = 5
			}
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_virtuous_traits >= 4 }
				}
				add = 5
			}
			if = { #Check specific number...
				limit = {
					scope:candidate = { num_virtuous_traits >= 5 }
				}
				add = 5
			}
			if = { #Princely elective more unforgiving.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				multiply = 2
			}
			multiply = ai_zeal #...Multiply by Elector Zeal.
			multiply = 0.05 #Reduce overall to avoid extreme numbers.
		}
	}
	#Excommunication
	modifier = {
		desc = tooltip_feudal_elector_vote_excommunication
		NOT = { this = scope:candidate } #Do not judge yourself.
		faith = { has_doctrine_parameter = excommunication_active }
		faith = scope:candidate.faith
		root.faith.religious_head = scope:candidate.faith.religious_head #Must have been excommunicated by the same Pope.
		OR = {
			NOT = { has_trait = excommunicated }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = { has_trait = excommunicated }
		add = {
			subtract = 25
			if = { #Religious gradients.
				limit = { ai_zeal > 0 }
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
			if = { #Princely Elective doubles.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	#Illegitimate children (excepting the children of consorts, which filter separately)
	modifier = {
		desc = tooltip_feudal_elector_vote_out_of_wedlock
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine = doctrine_bastardry_none }
		}
		OR = {
			NOR = {
				has_trait = bastard
				has_trait = legitimized_bastard
				has_trait = wild_oat
			}
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = {
			OR = {
				has_trait = bastard
				has_trait = legitimized_bastard
				has_trait = wild_oat
			}
		}
		add = {
			subtract = 15
			if = { #Religious gradients.
				limit = {
					faith = { has_doctrine = doctrine_bastardry_legitimization }
				}
				subtract = 10
			}
			if = { #Religious gradients.
				limit = {
					faith = { has_doctrine = doctrine_bastardry_all }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = {
					ai_zeal > 10
				}
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Children of Consorts
	modifier = {
		desc = tooltip_feudal_elector_vote_out_of_wedlock
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			allowed_concubines = yes
			faith = { has_doctrine = doctrine_bastardry_none } #Unlikely to be fussed about such kids
		}
		OR = {
			NOT = { has_trait = child_of_concubine }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = { has_trait = child_of_concubine }
		add = {
			subtract = 15
			if = { #Religious gradients.
				limit = {
					faith = { has_doctrine = doctrine_bastardry_legitimization }
				}
				subtract = 10
			}
			if = { #Religious gradients.
				limit = {
					faith = { has_doctrine = doctrine_bastardry_all }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = {
					ai_zeal > 10
				}
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Sodomy Crime
	modifier = {
		desc = tooltip_feudal_elector_vote_sodomite
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine = doctrine_homosexuality_accepted }
		}
		ai_zeal > 0
		OR = {
			NOT = { has_trait = sodomite }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = { has_trait = sodomite }
		add = {
			subtract = 15
			if = { #Religious gradients.
				limit = {
					faith = { has_doctrine = doctrine_homosexuality_shunned }
				}
				subtract = 10
			}
			else_if = { #Religious gradients.
				limit = {
					faith = { has_doctrine = doctrine_homosexuality_crime }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = {
					ai_zeal > 10
				}
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Kinslayer Crime
	modifier = {
		desc = tooltip_feudal_elector_vote_kinslayer
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine = doctrine_kinslaying_accepted }
		}
		OR = {
			NOT = { has_trait = kinslayer }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = { has_trait = kinslayer }
		add = {
			value = 0
			if = { #Check specific trait, multiply depending on religious doctrine.
				limit = {
					scope:candidate = { has_trait = kinslayer_1 }
				}
				subtract = 10
				if = {
					limit = {
						faith = { has_doctrine = doctrine_kinslaying_any_dynasty_member_crime }
					}
					multiply = 2
				}
			}
			else_if = {
				limit = {
					scope:candidate = { has_trait = kinslayer_2 }
				}
				subtract = 15
				if = {
					limit = {
						faith = {
							OR = {
								has_doctrine = doctrine_kinslaying_any_dynasty_member_crime
								has_doctrine = doctrine_kinslaying_extended_family_crime
							}
						}
					}
					multiply = 2
				}
			}
			else_if = {
				limit = {
					scope:candidate = { has_trait = kinslayer_3 }
				}
				subtract = 20
				if = {
					limit = {
						faith = {
							OR = {
								has_doctrine = doctrine_kinslaying_any_dynasty_member_crime
								has_doctrine = doctrine_kinslaying_extended_family_crime
								has_doctrine = doctrine_kinslaying_close_kin_crime
							}
						}
					}
					multiply = 2
				}
			}
			#And further add malus depending on Elector's relation to the Kinslaying candidate.
			if = {
				limit = {
					exists = scope:candidate.dynasty
					NOT = { dynasty = scope:candidate.dynasty }
				}
				subtract = 10
			}
			else_if = {
				limit = {
					exists = scope:candidate.dynasty
					dynasty = scope:candidate.dynasty
					NOT = { is_close_family_of = scope:candidate }
				}
				subtract = 20
			}
			else_if = {
				limit = {
					exists = scope:candidate.dynasty
					dynasty = scope:candidate.dynasty
					is_close_family_of = scope:candidate
				}
				subtract = 30
			}
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 1.5
			}
		}
	}

	#Deviancy
	modifier = {
		desc = tooltip_feudal_elector_vote_deviant
		NOT = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine_parameter = deviancy_accepted }
		}
		OR = {
			NOT = { has_trait = deviant }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = { has_trait = deviant }
		add = {
			subtract = 15
			if = {
				limit = {
					faith = { has_doctrine_parameter = deviancy_shunned }
				}
				subtract = 10
			}
			if = {
				limit = {
					faith = { has_doctrine_parameter = deviancy_illegal }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = { ai_zeal > 10 }
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Cannibalism
	modifier = {
		desc = tooltip_feudal_elector_vote_cannibal
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine_parameter = cannibalism_legal }
		}
		OR = {
			NOT = { has_trait = cannibal }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = { has_trait = cannibal }
		add = {
			subtract = 30
			if = { #Religious gradients.
				limit = { ai_zeal > 10 }
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Incest
	modifier = {
		desc = tooltip_feudal_elector_vote_incestuous
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine = doctrine_consanguinity_unrestricted }
		}
		OR = {
			NOT = { has_trait = incestuous }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = { has_trait = incestuous }
		add = {
			subtract = 25
			if = { #Religious gradients.
				limit = { ai_zeal > 10 }
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Adultery - males
	modifier = {
		desc = tooltip_feudal_elector_vote_adulterous_man
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine = doctrine_adultery_men_accepted }
		}
		OR = {
			NOT = { has_trait = adulterer }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = {
			has_trait = adulterer
			is_female = no
		}
		add = {
			subtract = 15
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_men_shunned }
				}
				subtract = 10
			}
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_men_crime }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = { ai_zeal > 10 }
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Adultery - females
	modifier = {
		desc = tooltip_feudal_elector_vote_adulterous_woman
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine = doctrine_adultery_women_accepted }
		}
		OR = {
			NOT = { has_trait = adulterer }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = {
			has_trait = adulterer
			is_female = yes
		}
		add = {
			subtract = 15
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_women_shunned }
				}
				subtract = 10
			}
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_women_crime }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = { ai_zeal > 10 }
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Fornication - males
	modifier = {
		desc = tooltip_feudal_elector_vote_fornicating_man
		NOT = { this = scope:candidate } #Do not judge yourself.
		faith = { has_doctrine = doctrine_adultery_men_accepted }
		OR = {
			NOT = { has_trait = fornicator }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = {
			has_trait = fornicator
			is_female = no
		}
		add = {
			subtract = 15
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_men_shunned }
				}
				subtract = 10
			}
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_men_crime }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = {
					ai_zeal > 10
				}
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Fornication - females
	modifier = {
		desc = tooltip_feudal_elector_vote_fornicating_woman
		NOT = { this = scope:candidate } #Do not judge yourself.
		faith = { has_doctrine = doctrine_adultery_women_accepted }
		OR = {
			NOT = { has_trait = fornicator }
			has_trait = arbitrary #No need for consistency
		}
		scope:candidate = {
			has_trait = fornicator
			is_female = yes
		}
		add = {
			subtract = 15
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_women_shunned }
				}
				subtract = 10
			}
			if = {
				limit = {
					faith = { has_doctrine = doctrine_adultery_women_crime }
				}
				subtract = 15
			}
			if = { #Religious gradients.
				limit = {
					ai_zeal > 10
				}
				subtract = {
					value = ai_zeal
					multiply = 0.5
				}
			}
		}
	}
	#Attraction
	modifier = {
		desc = tooltip_feudal_elector_vote_attractive
		NOT = { this = scope:candidate } #Do not judge yourself, you dirty AI.
		is_adult = yes
		scope:candidate = {
			is_adult = yes
			attraction >= 25
		}
		add = {
			value = 1
			multiply = scope:candidate.attraction
			multiply = 0.1
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_ugly
		NOT = { this = scope:candidate } #Do not judge yourself.
		is_adult = yes
		scope:candidate = {
			is_adult = yes
			attraction <= -25
		}
		add = {
			value = 0
			multiply = scope:candidate.attraction
			multiply = 0.1
		}
	}

	#Special cases (ex. deformities, disfigured for Byzantines)
	modifier = {
		add = -35
		desc = tooltip_feudal_elector_vote_incapable
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = { has_trait = incapable }
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_incapable_warrior
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = incapable }
		add = {
			subtract = 50
			if = { #Scandinavian elective more unforgiving.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = {
		add = -15
		desc = tooltip_feudal_elector_vote_infirm
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_diplomatic_society_trigger = no
		scope:candidate = { has_trait = infirm }
	}
	modifier = {
		add = -30
		desc = tooltip_feudal_elector_vote_infirm_diplomat
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_diplomatic_society_trigger = yes
		scope:candidate = { has_trait = infirm }
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_disfigured
		this_is_martial_society_trigger = no
		NOT = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
		scope:candidate = { has_trait = disfigured }
		add = -15
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_disfigured_byzantine
		culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance }
		scope:candidate = { has_trait = disfigured }
		add = -100
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_disfigured_warrior
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = disfigured }
		add = {
			subtract = 5
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 45
			}
			if = { #Scandinavian elective more unforgiving.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = {
		add = -10
		desc = tooltip_feudal_elector_vote_maimed
		this_is_martial_society_trigger = no
		scope:candidate = { has_trait = maimed }
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_maimed_warrior
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = maimed }
		add = {
			subtract = 15
			if = { #Scandinavian elective more unforgiving.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_born_in_the_purple
		NOT = { this = scope:candidate } #Do not judge yourself.
		culture = { has_cultural_parameter = children_can_be_born_in_the_purple }
		scope:candidate = { has_trait = born_in_the_purple }
		add = 50
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_genius_diplomat
		NOT = { this = scope:candidate } #Do not judge yourself.
		OR = {
			this_is_diplomatic_society_trigger = yes
			this_is_spiritual_society_trigger = yes
		}
		scope:candidate = {
			OR = {
				has_trait = intellect_good
				has_trait = shrewd
			}
		}
		add = {
			value = 10
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_good_1 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = {
						OR = {
							has_trait = intellect_good_2
							has_trait = shrewd
						}
					}
				}
				add = 10
			}
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_good_3 }
				}
				add = 15
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_genius
		NOT = { this = scope:candidate } #Do not judge yourself.
		NOR = {
			this_is_diplomatic_society_trigger = yes
			this_is_spiritual_society_trigger = yes
		}
		scope:candidate = {
			OR = {
				has_trait = intellect_good
				has_trait = shrewd
			}
		}
		add = {
			value = 0
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_good_1 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = {
						OR = {
							has_trait = intellect_good_2
							has_trait = shrewd
						}
					}
				}
				add = 10
			}
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_good_3 }
				}
				add = 15
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_strong
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = {
			OR = {
				has_trait = physique_good
				has_trait = strong
			}
		}
		add = {
			value = 0
			if = {
				limit = {
					scope:candidate = { has_trait = physique_good_1 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = {
						OR = {
							has_trait = strong
							has_trait = physique_good_2
						}
					}
				}
				add = 10
			}
			if = {
				limit = {
					scope:candidate = { has_trait = physique_good_3 }
				}
				add = 15
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_strong_warrior
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = {
			OR = {
				has_trait = physique_good
				has_trait = strong
			}
		}
		add = {
			value = 10
			if = {
				limit = {
					scope:candidate = { has_trait = physique_good_1 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = {
						OR = {
							has_trait = strong
							has_trait = physique_good_2
						}
					}
				}
				add = 10
			}
			if = {
				limit = {
					scope:candidate = { has_trait = physique_good_3 }
				}
				add = 15
			}
			if = { #Scandinavian elective more unforgiving.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_imbecile
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_diplomatic_society_trigger = no
		scope:candidate = {
			OR = {
				has_trait = intellect_bad
				has_trait = dull
			}
		}
		add = {
			value = 0
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_bad_1 }
				}
				subtract = 5
			}
			if = {
				limit = {
					scope:candidate = {
						OR = {
							has_trait = intellect_bad_2
							has_trait = dull
						}
					}
				}
				subtract = 10
			}
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_bad_3 }
				}
				subtract = 15
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_imbecile_diplomat
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_diplomatic_society_trigger = yes
		scope:candidate = {
			OR = {
				has_trait = intellect_bad
				has_trait = dull
			}
		}
		add = {
			subtract = 10
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_bad_1 }
				}
				subtract = 5
			}
			if = {
				limit = {
					scope:candidate = {
						OR = {
							has_trait = intellect_bad_2
							has_trait = dull
						}
					}
				}
				subtract = 10
			}
			if = {
				limit = {
					scope:candidate = { has_trait = intellect_bad_3 }
				}
				subtract = 15
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_clubfooted
		NOT = { this = scope:candidate } #Do not judge yourself.
		scope:candidate = { has_trait = clubfooted }
		add = {
			subtract = 5
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 10
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_dwarf
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = { has_trait = dwarf }
		add = {
			subtract = 15
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 20
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_dwarf_warrior
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = dwarf }
		add = {
			subtract = 30
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 30
			}
			if = { #Scandinavian elective more unforgiving.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_hunchback
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = {has_trait = hunchbacked }
		add = {
			subtract = 15
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 30
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_hunchback_warrior
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = hunchbacked }
		add = {
			subtract = 30
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 30
			}
			if = { #Scandinavian elective more unforgiving.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_inbred
		NOT = { this = scope:candidate } #Do not judge yourself.
		scope:candidate = {
			OR = {
				has_trait = inbred
				has_trait = spindly
				has_trait = scaly
				has_trait = albino
				has_trait = wheezing
				has_trait = bleeder
			}
		}
		add = {
			subtract = 15
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 60
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_lisping
		NOT = { this = scope:candidate } #Do not judge yourself.
		scope:candidate = { has_trait = lisping }
		add = {
			subtract = 5
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 10
			}
		}
	}
	modifier = {
		add = -5
		desc = tooltip_feudal_elector_vote_stuttering
		NOT = { this = scope:candidate } #Do not judge yourself.
		scope:candidate = { has_trait = stuttering }
	}
	modifier = { #Shunned for being Evil
		add = -25
		desc = tooltip_feudal_elector_vote_evil_negative
		NOT = { this = scope:candidate } #Do not judge yourself.
		OR = {
			has_trait = arbitrary #No need for consistency
			NOT = { has_personality_malicious_trigger = yes }
		}
		scope:candidate = { has_personality_malicious_trigger = yes }
	}
	modifier = { #Shunned for being a lunatic
		add = -15
		desc = tooltip_feudal_elector_vote_lunatic_negative
		NOT = { this = scope:candidate } #Do not judge yourself.
		OR = {
			has_trait = arbitrary #No need for consistency
			NOR = {
				has_trait = lunatic
				has_trait = possessed
			}
		}
		scope:candidate = { has_trait = lunatic }
	}
	modifier = { #Shunned for being possessed
		add = -15
		desc = tooltip_feudal_elector_vote_possessed_negative
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = { has_doctrine_parameter = spirit_possession_active }
		}
		OR = {
			has_trait = arbitrary #No need for consistency
			NOR = {
				has_trait = lunatic
				has_trait = possessed
			}
		}
		scope:candidate = { has_trait = possessed }
	}
	modifier = { #Praised for being possessed
		add = 35
		desc = tooltip_feudal_elector_vote_possessed_positive
		NOT = { this = scope:candidate } #Do not judge yourself.
		faith = { has_doctrine_parameter = spirit_possession_active }
		ai_zeal > 10
		scope:candidate = { has_trait = possessed }
	}
	modifier = { #Praised for being Pilgrim
		add = 10
		desc = tooltip_feudal_elector_vote_pilgrim_positive
		NOT = { this = scope:candidate } #Do not judge yourself.
		faith = scope:candidate.faith
		ai_zeal > 10
		scope:candidate = { has_trait = pilgrim }
	}
	modifier = { #Praised for being Crusader
		add = 10
		desc = tooltip_feudal_elector_vote_crusader_positive
		NOT = { this = scope:candidate } #Do not judge yourself.
		faith = scope:candidate.faith
		ai_zeal > 10
		scope:candidate = { has_trait = faith_warrior }
	}
	modifier = { #Shunned for being Crusader
		add = -15
		desc = tooltip_feudal_elector_vote_crusader_negative
		NOR = {
			this = scope:candidate	#Do not judge yourself.
			faith = scope:candidate.faith
		}
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value >= faith_hostile_level
			}
		}
		ai_zeal > 10
		scope:candidate = { has_trait = faith_warrior }
	}
	modifier = { #Praised for being a saoshyant_descendant
		add = 10
		desc = tooltip_feudal_elector_vote_saoshyant_descendant_positive
		NOT = { this = scope:candidate } #Do not judge yourself.
		faith = { religion_tag = zoroastrianism_religion }
		scope:candidate = { has_trait = saoshyant_descendant }
	}
	modifier = { #Praised for being Adventurer
		add = 10
		desc = tooltip_feudal_elector_vote_adventurer_positive
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = adventurer }
	}
	modifier = { #Shunned for being Adventurer
		add = -10
		desc = tooltip_feudal_elector_vote_adventurer_negative
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = { has_trait = adventurer }
	}
	modifier = { #Praised for being Berserker
		add = 5
		desc = tooltip_feudal_elector_vote_berserker_positive
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = berserker }
	}
	modifier = { #Shunned for being Berserker
		add = -20
		desc = tooltip_feudal_elector_vote_berserker_negative
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = { has_trait = berserker }
	}
	modifier = { #Shunned for being blind
		desc = tooltip_feudal_elector_vote_blinded_negative
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = { has_trait = blind }
		add = {
			subtract = 10
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 140
			}
		}
	}
	modifier = { #Shunned for being blind
		desc = tooltip_feudal_elector_vote_blinded_negative_warrior
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = blind }
		add = {
			subtract = 20
			if = {
				limit = { culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance } }
				subtract = 130
			}
			if = { #Scandinavian elective more unforgiving.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = { #Shunned for being eunuch
		desc = tooltip_feudal_elector_vote_eunuch_negative
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		NOR = {
			culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance }
			faith = { religion_tag = islam_religion }
		}
		scope:candidate = { is_eunuch_trigger = yes }
		add = -25
	}
	modifier = { #Shunned for being eunuch
		desc = tooltip_feudal_elector_vote_eunuch_negative_warrior
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		NOR = {
			culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance }
			faith = { religion_tag = islam_religion }
		}
		scope:candidate = { is_eunuch_trigger = yes }
		add = -50
	}
	modifier = { #Shunned for being eunuch
		desc = tooltip_feudal_elector_vote_eunuch_negative_byzantine
		NOT = { this = scope:candidate } #Do not judge yourself.
		OR = {
			culture = { has_cultural_parameter = physical_disfigurement_blocks_inheritance }
			faith = { religion_tag = islam_religion }
		}
		scope:candidate = { is_eunuch_trigger = yes }
		add = -150
	}
	modifier = { #Praised for being Giant
		add = 10
		desc = tooltip_feudal_elector_vote_giant_positive
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = yes
		scope:candidate = { has_trait = giant }
	}
	modifier = { #Shunned for being Giant
		add = -10
		desc = tooltip_feudal_elector_vote_giant_negative
		NOT = { this = scope:candidate } #Do not judge yourself.
		this_is_martial_society_trigger = no
		scope:candidate = { has_trait = giant }
	}
	modifier = { #Shunned for being unproved courtier in the shadow of the ruler.
		add = -10
		desc = tooltip_feudal_elector_vote_spoiled_courtier
		scope:candidate = { this = scope:holder_candidate }
		NOT = { this = scope:candidate } #Do not judge yourself.
		scope:candidate = {
			NOR = {
				is_ruler = yes
				has_council_position = councillor_marshal
				has_council_position = councillor_chancellor
				has_council_position = councillor_steward
				has_council_position = councillor_spymaster
				has_council_position = councillor_court_chaplain
			}
			OR = {
				has_trait = deviant
				has_trait = lazy
				has_trait = lifestyle_reveler
				has_trait = seducer
				has_trait = drunkard
				has_trait = shy
			}
		}
	}
}

elector_voting_pattern_opinion_feudal_elective_modifier = {
	##########################	Elector voting patterns (opinion)	##########################
	#Ruler is lunatic, vote against his pick
	modifier = {
		add = -10
		desc = tooltip_feudal_elector_anti_vote_ruler_lunatic
		scope:candidate = { this = scope:holder_candidate }
		NOR = {
			this = scope:candidate	#But not if it's me.
			has_trait = lunatic #Don't care
			has_trait = possessed #Don't care
			has_trait = arbitrary #Don't care
			has_trait = zealous #Might be the gods speaking
			faith = { has_doctrine_parameter = spirit_possession_active } #Actually blessed
		}
		scope:holder = {
			has_trait = lunatic
		}
	}
	#Ruler is possessed, vote against his pick
	modifier = {
		add = -10
		desc = tooltip_feudal_elector_anti_vote_ruler_possessed
		scope:candidate = { this = scope:holder_candidate }
		ai_zeal > 0
		NOR = {
			this = scope:candidate	#But not if it's me.
			has_trait = lunatic #Don't care
			has_trait = possessed #Don't care
			has_trait = arbitrary #Don't care
			faith = { has_doctrine_parameter = spirit_possession_active } #Actually blessed
		}
		scope:holder = {
			has_trait = possessed
		}
	}
	#Unless adorcism is a thing
	modifier = {
		add = 25
		desc = tooltip_feudal_elector_anti_vote_ruler_possessed_positive
		scope:candidate = { this = scope:holder_candidate }
		faith = { has_doctrine_parameter = spirit_possession_active } #Actually blessed
		ai_zeal > 0
		scope:holder = {
			has_trait = possessed
		}
	}
	#Ruler is just, trust his pick
	modifier = {
		desc = tooltip_feudal_elector_pro_vote_ruler_just
		scope:candidate = { this = scope:holder_candidate }
		NOR = {
			this = scope:holder  #But not if it's me.
			this = scope:candidate  #But not if it's me.
		}
		NOR = {
			has_trait = lunatic #Don't care
			has_trait = possessed #Don't care
			has_trait = arbitrary #Don't like it
			has_trait = sadistic #Don't care
			faith = { trait_is_sin = just } #Not a positive.
		}
		scope:holder = { has_trait = just }
		add = {
			value = 25
			if = {
				limit = {
					faith = { has_doctrine_parameter = legalism_trust_just_leader_active }
				}
				add = 15
			}
		}
	}
	#Ruler is a Tyrant, vote against his pick
	modifier = {
		desc = tooltip_feudal_elector_anti_vote_ruler_tyrant
		scope:candidate = { this = scope:holder_candidate }
		NOR = {
			this = scope:holder  #But not if it's me.
			this = scope:candidate  #But not if it's me.
		}
		NOR = {
			has_trait = lunatic #Don't care
			has_trait = possessed #Don't care
			has_trait = arbitrary #Don't care
			has_trait = sadistic #Don't care
			has_trait = callous #Don't care
		}
		scope:holder = {
			tyranny >= low_tyranny
		}
		add = {
			subtract = 25
			if = {
				limit = {
					tyranny >= medium_tyranny
				}
				subtract = 25
			}
			if = {
				limit = {
					tyranny >= high_tyranny
				}
				subtract = 50
			}
		}
	}
	#Ruler is Dreaded, vote for his pick
	modifier = {
		desc = tooltip_feudal_elector_anti_vote_ruler_dreaded
		scope:candidate = { this = scope:holder_candidate }
		NOR = {
			this = scope:holder  #But not if it's me.
			this = scope:candidate  #But not if it's me.
		}
		NOR = {
			has_trait = lunatic #Don't care
			has_trait = arbitrary #Don't care
		}
		scope:holder = { dread >= low_dread	}
		dread_modified_ai_boldness = {
			dreaded_character = scope:holder
			value <= -25
		}
		add = {
			value = 10
			if = {
				limit = {
					dread_modified_ai_boldness = {
						dreaded_character = scope:holder
						value <= -50
					}
				}
				add = 15
			}
			if = {
				limit = {
					dread_modified_ai_boldness = {
						dreaded_character = scope:holder
						value <= -75
					}
				}
				add = 20
			}
			if = {
				limit = {
					dread_modified_ai_boldness = {
						dreaded_character = scope:holder
						value <= -95
					}
				}
				add = 25
			}
		}
	}
	##########################	Raw Opinion bonus towards Candidate	##########################
	modifier = { #Raw Opinion bonus (negative)
		desc = tooltip_feudal_elector_vote_opinion_negative
		NOT = { this = scope:candidate } #Not on yourself.
		save_temporary_opinion_value_as = {
			name = opinion_of_candidate
			target = scope:candidate
		}
		scope:opinion_of_candidate <= low_negative_opinion
		add = {
			subtract = 15
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_candidate <= medium_negative_opinion
				}
				subtract = 15 #-30 total
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_candidate <= high_negative_opinion
				}
				subtract = 20 #-50 total
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_candidate <= very_high_negative_opinion
				}
				subtract = 50 #-100 total
			}
			if = { #Even less so if rival.
				limit = {
					has_relation_rival = scope:candidate
				}
				subtract = 50 #-150 total
			}
			if = { #Further increased for Tanistry.
				limit = {
					scope:title = { has_title_law = gaelic_elective_succession_law }
				}
				multiply = 1.5
			}
		}
	}
	modifier = { #Raw Opinion bonus (positive)
		desc = tooltip_feudal_elector_vote_opinion_positive
		NOT = {
			has_relation_rival = scope:candidate #Completely removed for rivals.
		}
		NOT = { this = scope:candidate } #Not on yourself.
		save_temporary_opinion_value_as = {
			name = opinion_of_candidate
			target = scope:candidate
		}
		scope:opinion_of_candidate >= low_positive_opinion
		add = {
			value = 15
			if = { #Even more so if higher opinion.
				limit = {
					scope:opinion_of_candidate >= medium_positive_opinion
				}
				add = 15 #30 total
			}
			if = { #Even more so if higher opinion.
				limit = {
					scope:opinion_of_candidate >= high_positive_opinion
				}
				add = 20 #50 total
			}
			if = { #Even more so if higher opinion.
				limit = {
					scope:opinion_of_candidate >= very_high_positive_opinion
				}
				add = 20 #70 total
			}
			if = { #Even more so if friend/lover.
				limit = {
					OR = {
						has_relation_friend = scope:candidate
						has_relation_lover = scope:candidate
					}
				}
				add = 30 #100 total
			}
			if = { #Further increased for Tanistry.
				limit = {
					scope:title = { has_title_law = gaelic_elective_succession_law }
				}
				multiply = 1.5
			}
		}
	}
	##########################	Raw Opinion bonus towards Ruler	##########################
	modifier = { #Vassal hates ruler, therefore votes against the ruler's candidate (scope:holder_candidate)
		desc = tooltip_feudal_elector_anti_vote_ruler_opinion_negative
		scope:candidate = scope:holder_candidate
		NOR = {
			this = scope:holder  #But not if it's me.
			this = scope:candidate  #But not if it's me.
		}
		save_temporary_opinion_value_as = {
			name = opinion_of_holder
			target = scope:holder
		}
		scope:opinion_of_holder <= low_negative_opinion
		add = {
			subtract = 10
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_holder <= medium_negative_opinion
				}
				subtract = 15 #-25 total
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_holder <= high_negative_opinion
				}
				subtract = 25 #-50 total
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_holder <= very_high_negative_opinion
				}
				subtract = 50 #-100 total
			}
			if = { #Even less so if rival.
				limit = {
					has_relation_rival = scope:holder
				}
				subtract = 50 #-150 total
			}
		}
	}
	modifier = { #Vassal loves ruler, therefore votes for the ruler's candidate (scope:holder_candidate)
		desc = tooltip_feudal_elector_pro_vote_ruler_opinion_positive
		scope:candidate = scope:holder_candidate
		NOR = {
			this = scope:holder  #But not if it's me.
			this = scope:candidate  #But not if it's me.
		}
		save_temporary_opinion_value_as = {
			name = opinion_of_holder
			target = scope:holder
		}
		scope:opinion_of_holder >= low_positive_opinion
		add = {
			value = 10
			if = { #Even more so if higher opinion.
				limit = {
					opinion = {
						target = scope:holder
						value >= medium_positive_opinion
					}
				}
				add = 15 #25 total
			}
			if = { #Even more so if higher opinion.
				limit = {
					opinion = {
						target = scope:holder
						value >= high_positive_opinion
					}
				}
				add = 25 #50 total
			}
			if = { #Even more so if higher opinion.
				limit = {
					opinion = {
						target = scope:holder
						value >= very_high_positive_opinion
					}
				}
				add = 50 #100 total
			}
			if = { #Even more so if friend/lover.
				limit = {
					OR = {
						has_relation_friend = scope:holder
						has_relation_lover = scope:holder
					}
				}
				add = 50 #150 total
			}
		}
	}
}

elector_voting_pattern_theocracy_modifier = {
	### Theocracy voting pattern ###
	
	modifier = { # Learning
		add = {
			add = scope:candidate.learning
			multiply = 5
		}
		desc = tooltip_feudal_elector_vote_spiritual_education
		scope:candidate = {
			learning >= 10
		}
	}
	modifier = { # Age
		add = {
			add = 25
			subtract = scope:candidate.age
		}
		desc = geriatric_candidate_desc
		scope:candidate = {
			age >= 50
		}
	}
	modifier = { # Sinner
		subtract = 25
		desc = piety_level_0
		scope:candidate = {
			piety_level = 0
		}
	}
	modifier = { # Pious
		add = 25
		desc = piety_level_2
		scope:candidate = {
			piety_level = 2
		}
	}
	modifier = { # Paragon
		add = 50
		desc = piety_level_3
		scope:candidate = {
			piety_level = 3
		}
	}
	modifier = { # Icon
		add = 75
		desc = piety_level_4
		scope:candidate = {
			piety_level = 4
		}
	}
	modifier = {
		add = 25
		desc = trait_zealous_character_desc
		scope:candidate = {
			has_trait = zealous
		}
	}
	modifier = {
		add = 25
		desc = devoted_interesting_desc
		scope:candidate = {
			has_trait = devoted
		}
	}
	modifier = {
		add = 25
		desc = pious_theologian_interesting_desc
		scope:candidate = {
			has_trait = theologian
		}
	}
	modifier = {
		add = 25
		desc = scholar
		scope:candidate = {
			has_trait = scholar
		}
	}
	modifier = {
		add = {
			add = 25
			multiply = scope:candidate.num_virtuous_traits
		}
		desc = virtuous_traits_difficulty
		scope:candidate = {
			num_virtuous_traits >= 1
		}
	}
	modifier = {
		add = {
			add = 25
			multiply = scope:candidate.num_sinful_traits
		}
		desc = sinful_traits_difficulty
		scope:candidate = {
			num_sinful_traits >= 1
		}
	}
	modifier = {
		subtract = 25
		desc = lowborn_desc_succession
		scope:candidate = {
			is_lowborn = yes
		}
	}
	modifier = {
		subtract = 25
		desc = trait_intellect_bad_1_desc
		scope:candidate = {
			has_trait = intellect_bad_1
		}
	}
	modifier = {
		subtract = 50
		desc = trait_intellect_bad_2_desc
		scope:candidate = {
			has_trait = intellect_bad_2
		}
	}
	modifier = {
		subtract = 75
		desc = trait_intellect_bad_3_desc
		scope:candidate = {
			has_trait = intellect_bad_3
		}
	}
	modifier = {
		add = 50
		desc = trait_intellect_good_2_desc
		scope:candidate = {
			has_trait = intellect_good_2
		}
	}
	modifier = {
		add = 75
		desc = trait_intellect_good_3_desc
		scope:candidate = {
			has_trait = intellect_good_3
		}
	}
	modifier = {
		add = 25
		desc = trait_intellect_good_1_desc
		scope:candidate = {
			has_trait = intellect_good_1
		}
	}
	modifier = {
		add = 50
		desc = trait_intellect_good_2_desc
		scope:candidate = {
			has_trait = intellect_good_2
		}
	}
	modifier = {
		add = 75
		desc = trait_intellect_good_3_desc
		scope:candidate = {
			has_trait = intellect_good_3
		}
	}

	# Someone who is familiar with the local culture
	modifier = {
		add = 100
		desc = of_local_culture_succession_desc
		scope:candidate = {
			culture ?= root.capital_county.culture
		} 
	}
	# Currently serving as religious leader preferred
	modifier = {
		add = 100
		scope:candidate = {
			has_council_position = councillor_court_chaplain
		}
	}
}

elector_voting_pattern_circumstances_gaelic_elective_modifier = {
	##########################	Elector voting patterns (circumstances)	##########################
	#Sexism
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_agnatic_woman
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = male_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = male_preference_law }
				scope:title = {
					NOR = {
						has_title_law = female_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_male_dominated }
		}
		scope:candidate = { is_female = yes }
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = male_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = male_preference_law }
							scope:title = {
								NOR = {
									has_title_law = female_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_male_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_enatic_man
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = female_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = female_preference_law }
				scope:title = {
					NOR = {
						has_title_law = male_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_female_dominated }
		}
		scope:candidate = {
			is_female = no
		}
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = female_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = female_preference_law }
							scope:title = {
								NOR = {
									has_title_law = male_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_female_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	#Ageism
	modifier = {
		add = -50
		desc = tooltip_feudal_elector_vote_baby
		NOT = { this = scope:candidate }
		scope:candidate = {
			age < 5
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_child
		NOT = { this = scope:candidate }
		scope:candidate = {
			age > 5
			age < 16
		}
		add = {
			subtract = 20
			if = {
				limit = {
					age < 10
				}
				subtract = 15
			}
		}
	}
	modifier = { #Still too young for older rulers
		add = -15
		desc = tooltip_feudal_elector_vote_youngster
		NOT = { this = scope:candidate }
		age > 40
		scope:candidate = {
			age > 16
			age < 25
		}
	}
	modifier = { #Or too old for younger rulers.
		add = -5
		desc = tooltip_feudal_elector_vote_oldtimer
		NOT = { this = scope:candidate }
		age < 30
		scope:candidate = {
			age > 40
			age < 50
		}
	}
	#Culturism
	modifier = {
		add = 30
		desc = tooltip_feudal_elector_vote_fellow_culture
		NOT = { this = scope:candidate }
		root.culture = scope:candidate.culture
	}
	modifier = {
		add = -30
		desc = tooltip_feudal_elector_vote_stranger
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { root.culture = scope:candidate.culture }
		culture = { has_same_culture_heritage = scope:candidate.culture }
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = {
		add = -60
		desc = tooltip_feudal_elector_vote_foreigner
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { culture = { has_same_culture_heritage = scope:candidate.culture } }
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = { #Candidate is a foreigner's pet
		add = -25
		desc = tooltip_feudal_elector_vote_strangers_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { this.culture = root.culture }
			culture = { has_same_culture_heritage = root.culture }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = { #Candidate is a foreigner's pet
		add = -30
		desc = tooltip_feudal_elector_vote_foreigners_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { culture = { has_same_culture_heritage = root.culture } }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = { #If candidate is elected, he will rule from a capital outside this de jure.
		add = -30
		desc = tooltip_feudal_elector_vote_political_concerns
		is_playable_character = yes
		exists = capital_county
		capital_county = {
			scope:title = {
				is_de_jure_liege_or_above_target = prev
			}
		}

		OR = { # If the current holder is reigning from within the title, there is no reason to believe a lower tier candidate would not.
			scope:holder = { 
				capital_county = {
					scope:title = {
						NOT = { is_de_jure_liege_or_above_target = prev }
					}
				}
			}
			scope:candidate = {
				highest_held_title_tier >= scope:title.tier
			}
		}

		scope:candidate = {
			is_ruler = yes
			#is_vassal_of = scope:holder
			exists = capital_county
			NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
		}
	}
	modifier = { #Candidate is a foreign ruler.
		desc = tooltip_feudal_elector_vote_encroaching_foreigner
		is_playable_character = yes
		exists = capital_county
		scope:candidate = {
			is_ruler = yes
			NOT = { target_is_liege_or_above = scope:holder }
		}
		add = {
			subtract = 100
			if = { #Candidate is a foreign non-dejure ruler.
				limit = {
					NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
				}
				subtract = 500
			}
		}
	}
	#Faithism
	modifier = { #Accepted but different faith. (Buddhism vs Hinduism)
		add = -10
		desc = tooltip_feudal_elector_vote_different_faith
		NOT = { root.faith = scope:candidate.faith }
		ai_zeal >= 0 #Does not care otherwise.
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_fully_accepted_level
			}
		}
	}
	modifier = { #Astray (Catholic vs Orthodox)
		add = -25
		desc = tooltip_feudal_elector_vote_astray
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_astray_level
			}
		}
	}
	modifier = { #Heretic (Catholic vs Cathar)
		desc = tooltip_feudal_elector_vote_heretic
		add = {
			subtract = 50
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 25
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 25
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 25
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_hostile_level
			}
		}
	}
	modifier = { #Infidel (Catholic vs Ashari)
		desc = tooltip_feudal_elector_vote_evil_heathen
		add = {
			subtract = 100
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 50
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_evil_level
			}
		}
	}
	#Nepotism
	modifier = {
		add = 5
		desc = tooltip_feudal_elector_vote_dynasty
		NOT = { this = scope:candidate }
		exists = root.dynasty
		exists = scope:candidate.dynasty
		root.dynasty = scope:candidate.dynasty
		scope:candidate = {
			NOT = { is_close_family_of = root }
		}
	}
	modifier = {
		add = 10
		desc = tooltip_feudal_elector_vote_relative
		NOT = { this = scope:candidate }
		scope:candidate = {
			is_close_family_of = root
			NOT = { is_child_of = root }
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_parent
		NOT = { this = scope:candidate }
		scope:candidate = { is_child_of = root }
		add = {
			value = 10
			if = { #Current Ruler should tend to often pick one of his own children as potential heirs.
				limit = { this = scope:holder }
				add = 30
			}
		}
	}
	#Educational preferences
	modifier = { # Warrior society prefers warriors
		add = 15
		desc = tooltip_feudal_elector_vote_martial_education
		NOT = { this = scope:candidate }
		this_is_martial_society_trigger = yes
		scope:candidate = {
			martial >= 10
			OR = {
				has_trait = education_martial
				has_lifestyle = martial_lifestyle
				has_trait = lifestyle_blademaster
				has_martial_lifestyle_trait_trigger = yes
			}
		}
	}
	modifier = { # Diplomatic society prefers stewards and diplomats
		add = 15
		desc = tooltip_feudal_elector_vote_diplomatic_education
		NOT = { this = scope:candidate }
		this_is_diplomatic_society_trigger = yes
		scope:candidate = {
			OR = {
				AND = {
					diplomacy >= 10
					OR = {
						has_trait = education_diplomacy
						has_lifestyle = diplomacy_lifestyle
						has_diplomacy_lifestyle_trait_trigger = yes
						has_trait = lifestyle_reveler
						has_trait = gallant
					}
				}
				AND = {
					stewardship >= 10
					OR = {
						has_trait = education_stewardship
						has_lifestyle = stewardship_lifestyle
						has_stewardship_lifestyle_trait_trigger = yes
					}
				}
			}
		}
	}
	modifier = { # Spiritual society prefers scholars
		add = 15
		desc = tooltip_feudal_elector_vote_spiritual_education
		NOT = { this = scope:candidate }
		this_is_spiritual_society_trigger = yes
		scope:candidate = {
			learning >= 10
			OR = {
				has_trait = education_learning
				has_lifestyle = learning_lifestyle
				has_learning_lifestyle_trait_trigger = yes
				has_trait = lifestyle_mystic
				has_trait = lifestyle_physician
			}
		}
	}
	#Claims
	modifier = {
		add = 15
		desc = tooltip_feudal_elector_vote_strong_claimant
		NOT = { this = scope:candidate }
		scope:candidate = { has_strong_claim_on = scope:title }
	}
	modifier = {
		add = 5
		desc = tooltip_feudal_elector_vote_weak_claimant
		NOT = { this = scope:candidate }
		scope:candidate = { has_weak_claim_on = scope:title }
	}
	# Political Circumstances
	modifier = {
		add = 30
		desc = tooltip_feudal_elector_vote_regent_already_governs
		scope:candidate = { is_diarch_of_target = scope:holder }
	}
	## Vassals will tend to pick heirs that are not the current ruler's children/close relatives when under Tanistry.
	modifier = {
		add = -50
		desc = tooltip_feudal_elector_vote_anti_tanist
		NOT = { this = scope:candidate }
		scope:holder = {
			NOT = { this = root }
			is_parent_of = scope:candidate
		}
	}
	## Vassals will tend to pick heirs that are not the current ruler's close relaitves when under Tanistry.
	modifier = {
		add = -30
		desc = tooltip_feudal_elector_vote_anti_tanist
		NOT = { this = scope:candidate }
		scope:holder = {
			is_close_family_of = scope:candidate
			NOT = { this = root }
			NOT = { is_parent_of = scope:candidate }
		}
	}
}

elector_voting_pattern_circumstances_saxon_elective_modifier = {
	##########################	Additional patterns for the Witenagemot	##########################
	#Stewardship
	#Military might

	modifier = {	# Candidate's Stewardship
		desc = tooltip_saxon_elector_vote_stewardship
		NOT = { this = scope:candidate } #Not on yourself.
		scope:candidate = { stewardship >= 10 }
		add = {
			value = 5
			if = {
				limit = {
					scope:candidate = { stewardship > 12 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { stewardship > 16 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { stewardship > 18 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { stewardship > 20 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { stewardship > 25 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { stewardship > 30 }
				}
				add = 5
			}
		}
	}
	
	modifier = {	# Witengamot will challenge the ruler's pick if they can't enforce it.
		add = -30
		desc = tooltip_saxon_elector_vote_military_strength
		scope:candidate = { this = scope:holder_candidate }
		NOT = { this = scope:holder }	#But not if it's me.
		this.max_military_strength > scope:holder.max_military_strength
	}

	modifier = {	# Witengamot prefers magnates of the land.
		add = -60
		desc = tooltip_saxon_elector_vote_candidate_unlanded
		#But not if it's me.
		NOT = { this = scope:candidate }
		scope:candidate = { is_landed_or_landless_administrative = no }
	}

	modifier = {	# Witengamot prefers actual magnates, not low-tier counts.
		add = -30
		desc = tooltip_saxon_elector_vote_candidate_count_magnate
		#But not if it's me.
		NOT = { this = scope:candidate }
		scope:candidate = {
			is_landed_or_landless_administrative = yes
			highest_held_title_tier = tier_county
		}
	}

	modifier = {	#Witengamot likes powerful lords of the realm.
		desc = tooltip_saxon_elector_vote_candidate_king_magnate
		#But not if it's me.
		NOT = { this = scope:candidate }
		scope:candidate = {
			is_landed_or_landless_administrative = yes
			highest_held_title_tier = tier_kingdom
		}
		add = {
			if = {
				limit = {
					NOT = { this.top_liege = scope:candidate.top_liege }
				}
				subtract = -30
			}
		}
	}
}

elector_voting_pattern_circumstances_scandinavian_elective_modifier = {
	##########################	Additional patterns for the Thing	##########################
	modifier = { #Martial score
		desc = tooltip_scandinavian_elector_vote_prowess
		NOR = {
			this = scope:holder
			this = scope:candidate
		}
		scope:candidate = { prowess >= 10 }
		add = {
			value = 5
			if = {
				limit = {
					scope:candidate = { prowess > 12 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { prowess > 16 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { prowess > 18 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { prowess > 20 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { prowess > 25 }
				}
				add = 5
			}
			if = {
				limit = {
					scope:candidate = { prowess > 30 }
				}
				add = 5
			}
		}
	}
}

elector_voting_pattern_circumstances_tribal_elective_modifier = {
	##########################	Elector voting patterns (circumstances)	##########################
	#Sexism
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_agnatic_woman
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = male_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = male_preference_law }
				scope:title = {
					NOR = {
						has_title_law = female_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_male_dominated }
		}
		scope:candidate = { is_female = yes }
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = male_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = male_preference_law }
							scope:title = {
								NOR = {
									has_title_law = female_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_male_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_enatic_man
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = female_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = female_preference_law }
				scope:title = {
					NOR = {
						has_title_law = male_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_female_dominated }
		}
		scope:candidate = {
			is_female = no
		}
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = female_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = female_preference_law }
							scope:title = {
								NOR = {
									has_title_law = male_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_female_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	#Ageism
	modifier = {
		add = -50
		desc = tooltip_feudal_elector_vote_baby
		NOT = { this = scope:candidate }
		scope:candidate = {
			age < 5
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_child
		NOT = { this = scope:candidate }
		scope:candidate = {
			age > 5
			age < 16
		}
		add = {
			subtract = 20
			if = {
				limit = {
					age < 10
				}
				subtract = 15
			}
		}
	}
	modifier = { #Still too young for older rulers
		add = -15
		desc = tooltip_feudal_elector_vote_youngster
		NOT = { this = scope:candidate }
		age > 40
		scope:candidate = {
			age > 16
			age < 25
		}
	}
	modifier = { #but you cannot be too old! 
		add = 5
		desc = tooltip_tribal_elector_vote_elder
		NOT = { this = scope:candidate }
		scope:candidate = {
			age > 50
		}
	}
	#Culturism
	modifier = {
		add = 30
		desc = tooltip_feudal_elector_vote_fellow_culture
		NOT = { this = scope:candidate }
		root.culture = scope:candidate.culture
	}
	modifier = {
		add = -30
		desc = tooltip_tribal_elector_vote_stranger #belongs to a different tribe! 
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { root.culture = scope:candidate.culture }
		culture = { has_same_culture_heritage = scope:candidate.culture }
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = {
		add = -60
		desc = tooltip_feudal_elector_vote_foreigner
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { culture = { has_same_culture_heritage = scope:candidate.culture } }
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = { #Candidate is a foreigner's pet
		add = -25
		desc = tooltip_feudal_elector_vote_strangers_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { this.culture = root.culture }
			culture = { has_same_culture_heritage = root.culture }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = { #Candidate is a foreigner's pet
		add = -30
		desc = tooltip_feudal_elector_vote_foreigners_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { culture = { has_same_culture_heritage = root.culture } }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
	}
	modifier = { #If candidate is elected, he will rule from a capital outside this de jure.
		add = -30
		desc = tooltip_feudal_elector_vote_political_concerns
		is_playable_character = yes
		exists = capital_county
		capital_county = {
			scope:title = {
				is_de_jure_liege_or_above_target = prev
			}
		}

		OR = { # If the current holder is reigning from within the title, there is no reason to believe a lower tier candidate would not.
			scope:holder = { 
				capital_county = {
					scope:title = {
						NOT = { is_de_jure_liege_or_above_target = prev }
					}
				}
			}
			scope:candidate = {
				highest_held_title_tier >= scope:title.tier
			}
		}

		scope:candidate = {
			is_ruler = yes
			#is_vassal_of = scope:holder
			exists = capital_county
			NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
		}
	}
	modifier = { #Candidate is a foreign ruler.
		desc = tooltip_feudal_elector_vote_encroaching_foreigner
		is_playable_character = yes
		exists = capital_county
		scope:candidate = {
			is_ruler = yes
			NOT = { target_is_liege_or_above = scope:holder }
		}
		add = {
			subtract = 100
			if = { #Candidate is a foreign non-dejure ruler.
				limit = {
					NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
				}
				subtract = 500
			}
		}
	}
	#Faithism
	modifier = { #Accepted but different faith. (Buddhism vs Hinduism)
		add = -10
		desc = tooltip_feudal_elector_vote_different_faith
		NOT = { root.faith = scope:candidate.faith }
		ai_zeal >= 0 #Does not care otherwise.
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_fully_accepted_level
			}
		}
	}
	modifier = { #Astray (Catholic vs Orthodox)
		add = -25
		desc = tooltip_feudal_elector_vote_astray
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_astray_level
			}
		}
	}
	modifier = { #Heretic (Catholic vs Cathar)
		desc = tooltip_feudal_elector_vote_heretic
		add = {
			subtract = 50
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 25
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 25
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 25
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_hostile_level
			}
		}
	}
	modifier = { #Infidel (Catholic vs Ashari)
		desc = tooltip_feudal_elector_vote_evil_heathen
		add = {
			subtract = 100
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 50
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_evil_level
			}
		}
	}
	#Nepotism
	modifier = {
		add = 5
		desc = tooltip_feudal_elector_vote_dynasty
		NOT = { this = scope:candidate }
		exists = root.dynasty
		exists = scope:candidate.dynasty
		root.dynasty = scope:candidate.dynasty
		scope:candidate = {
			NOT = { is_close_family_of = root }
		}
	}
	modifier = {
		add = 10
		desc = tooltip_tribal_elector_vote_relative
		NOT = { this = scope:candidate }
		scope:candidate = {
			is_close_family_of = root
			NOT = { is_child_of = root }
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_parent
		NOT = { this = scope:candidate }
		scope:candidate = { is_child_of = root }
		add = {
			value = 10
			if = { #Current Ruler should tend to often pick one of his own children as potential heirs.
				limit = { this = scope:holder }
				add = 30
			}
		}
	}
	#Educational preferences
	modifier = { # Warrior society prefers warriors
		add = 15
		desc = tooltip_feudal_elector_vote_martial_education
		NOT = { this = scope:candidate }
		this_is_martial_society_trigger = yes
		scope:candidate = {
			martial >= 10
			OR = {
				has_trait = education_martial
				has_lifestyle = martial_lifestyle
				has_trait = lifestyle_blademaster
				has_martial_lifestyle_trait_trigger = yes
				has_trait = faith_warrior #This is particular to tribal elective - they really like 'em ghazis
			}
		}
	}
	modifier = { # Diplomatic society prefers stewards and diplomats
		add = 15
		desc = tooltip_feudal_elector_vote_diplomatic_education
		NOT = { this = scope:candidate }
		this_is_diplomatic_society_trigger = yes
		scope:candidate = {
			OR = {
				AND = {
					diplomacy >= 10
					OR = {
						has_trait = education_diplomacy
						has_lifestyle = diplomacy_lifestyle
						has_diplomacy_lifestyle_trait_trigger = yes
						has_trait = lifestyle_reveler
						has_trait = gallant
					}
				}
				AND = {
					stewardship >= 10
					OR = {
						has_trait = education_stewardship
						has_lifestyle = stewardship_lifestyle
						has_stewardship_lifestyle_trait_trigger = yes
					}
				}
			}
		}
	}
	modifier = { # Spiritual society prefers scholars
		add = 15
		desc = tooltip_feudal_elector_vote_spiritual_education
		NOT = { this = scope:candidate }
		this_is_spiritual_society_trigger = yes
		scope:candidate = {
			learning >= 10
			OR = {
				has_trait = education_learning
				has_lifestyle = learning_lifestyle
				has_learning_lifestyle_trait_trigger = yes
				has_trait = lifestyle_mystic
				has_trait = lifestyle_physician
			}
		}
	}
	#Claims
	modifier = {
		add = 15
		desc = tooltip_feudal_elector_vote_strong_claimant
		NOT = { this = scope:candidate }
		scope:candidate = { has_strong_claim_on = scope:title }
	}
	modifier = {
		add = 5
		desc = tooltip_feudal_elector_vote_weak_claimant
		NOT = { this = scope:candidate }
		scope:candidate = { has_weak_claim_on = scope:title }
	}	
}

elector_voting_pattern_circumstances_misc_elective_modifier = {
	# Players can say that they don't want to get elected.
	first_valid = {
		# If they constitute the majority of the empire, then they'll mostly get voted for.
		modifier = {
			add = 1
			desc = tooltip_feudal_elector_player_opt_out_50_percent
			scope:candidate ?= {
				# Because our candidate might die in the meanwhilst.
				is_alive = yes
				# And _then_ we check size, etc.
				has_variable = rejects_electioneering
				sub_realm_size >= scope:holder.50_percent_realm_size_value
			}
		}
		# If they're a third or less, they get a reduced amount.
		modifier = {
			add = -100
			desc = tooltip_feudal_elector_player_opt_out_33_percent
			scope:candidate ?= {
				# Because our candidate might die in the meanwhilst.
				is_alive = yes
				# And _then_ we check size, etc.
				has_variable = rejects_electioneering
				sub_realm_size >= scope:holder.33_percent_realm_size_value
			}
		}
		# A bit more of a malus for one quarter.
		modifier = {
			add = -200
			desc = tooltip_feudal_elector_player_opt_out_25_percent
			scope:candidate ?= {
				# Because our candidate might die in the meanwhilst.
				is_alive = yes
				# And _then_ we check size, etc.
				has_variable = rejects_electioneering
				sub_realm_size >= scope:holder.25_percent_realm_size_value
			}
		}
		# Full amount below that.
		modifier = {
			add = -300
			desc = tooltip_feudal_elector_player_opt_out_minor_realm
			scope:candidate ?= {
				# Because our candidate might die in the meanwhilst.
				is_alive = yes
				# And _then_ we check for our variable.
				has_variable = rejects_electioneering
			}
		}
	}
}

#scope:actor (ruler taking the action)
#scope:recipient (elector being forced)
#scope:target (potential candidate being voted)
hook_for_vote_interaction_ai_modifier = {
	modifier = {
		add = -250
		NOT = {
			scope:target = {
				is_child_of = scope:actor
			}
		}
	}
	modifier = { #Raw Opinion bonus (negative)
		scope:actor = {
			opinion = {
				target = scope:target
				value <= low_negative_opinion
			}
		}
		add = {
			subtract = 15
			if = { #Even less so if lower opinion.
				limit = {
					scope:actor = {
						opinion = {
							target = scope:target
							value <= medium_negative_opinion
						}
					}
				}
				subtract = 15 #-30 total
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:actor = {
						opinion = {
							target = scope:target
							value <= high_negative_opinion
						}
					}
				}
				subtract = 20 #-50 total
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:actor = {
						opinion = {
							target = scope:target
							value <= very_high_negative_opinion
						}
					}
				}
				subtract = 50 #-100 total
			}
			if = { #Even less so if rival.
				limit = {
					has_relation_rival = scope:candidate
				}
				subtract = 50 #-150 total
			}
			if = { #Further increased for Tanistry.
				limit = {
					scope:title = { has_title_law = gaelic_elective_succession_law }
				}
				multiply = 1.5
			}
		}
	}
	modifier = { #Raw Opinion bonus (positive)
		scope:actor = {
			has_relation_rival = scope:target #Completely removed for rivals.
		}
		scope:actor = {
			opinion = {
				target = scope:target
				value >= low_positive_opinion
			}
		}
		add = {
			value = 15
			if = { #Even more so if higher opinion.
				limit = {
					scope:actor = {
						opinion = {
							target = scope:target
							value >= medium_positive_opinion
						}
					}
				}
				add = 15 #30 total
			}
			if = { #Even more so if higher opinion.
				limit = {
					scope:actor = {
						opinion = {
							target = scope:target
							value >= high_positive_opinion
						}
					}
				}
				add = 20 #50 total
			}
			if = { #Even more so if higher opinion.
				limit = {
					scope:actor = {
						opinion = {
							target = scope:target
							value >= very_high_positive_opinion
						}
					}
				}
				add = 20 #70 total
			}
			if = { #Even more so if friend/lover.
				limit = {
					OR = {
						has_relation_friend = scope:candidate
						has_relation_lover = scope:candidate
					}
				}
				add = 30 #100 total
			}
		}
	}
}
