﻿brus_elector_voting_pattern_circumstances_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
		}
	}
	#Culturism
	modifier = {
		desc = tooltip_feudal_elector_vote_fellow_culture
		NOT = { this = scope:candidate }
		root.culture = scope:candidate.culture
		add = {
			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
		}
	}
	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
		}
	}
	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
		}
	}
	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
		}
	}
	#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 }
		}
	}
	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 = { has_strong_claim_on = scope:title }
	}
	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 }
	}
	### Holder voting patterns ###
	modifier = { #Current ruler will always try to elect his player heir before everybody else.
		add = 75
		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 = 30
		}
		scope:holder = {
			this = root
			NOT = {
				scope:candidate = {
					is_child_of = scope:holder
				}
			}
		}
	}
}

brus_elector_voting_pattern_prestige_piety_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 }
	}
	#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 = {
		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 }
	}
}

brus_elector_voting_pattern_opinion_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 = 5
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_holder <= medium_negative_opinion
				}
				subtract = 10 
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_holder <= high_negative_opinion
				}
				subtract = 15 
			}
			if = { #Even less so if lower opinion.
				limit = {
					scope:opinion_of_holder <= very_high_negative_opinion
				}
				subtract = 20 
			}
		}
	}
	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 = 10 
			}
			if = { #Even more so if higher opinion.
				limit = {
					opinion = {
						target = scope:holder
						value >= high_positive_opinion
					}
				}
				add = 15 
			}
			if = { #Even more so if higher opinion.
				limit = {
					opinion = {
						target = scope:holder
						value >= very_high_positive_opinion
					}
				}
				add = 30 
			}
			if = { #Even more so if friend/lover.
				limit = {
					OR = {
						has_relation_friend = scope:holder
						has_relation_lover = scope:holder
					}
				}
				add = 30 
			}
		}
	}
}