﻿#CONTENT
#Ai value values
#Trait compatibility thresholds
#Ai value divergence thresholds
#Ai value inverse
#Retired values

###################
# Ai value values #
###################

# ai_honor 45
# ai_zeal 28
# ai_greed 24
# ai_compassion 27
# ai_boldness 42
# ai_rationality 59
# ai_vengefulness 28
# ai_energy 84
# ai_sociability 43

very_low_positive_ai_value = 10
low_positive_ai_value = 20
medium_positive_ai_value = 35
high_positive_ai_value = 50
very_high_positive_ai_value = 75
dominant_positive_ai_value = 200

very_low_negative_ai_value = -10
low_negative_ai_value = -20
medium_negative_ai_value = -35
high_negative_ai_value = -50
very_high_negative_ai_value = -75
dominant_negative_ai_value = -200

#######################
# trait compatibility #
#######################

#These values are balanced based on samples taken 2018-11-13. The data is found in the spreadsheet "Ai value divergence & trait compatibility" on the drive.
#Note that they're balanced for adults only.

high_negative_trait_compatibility = -31 #About 8% of characters will have compatibility below this value for average character
medium_negative_trait_compatibility = -16 #About 21% of characters will have compatibility below this value for average character
low_negative_trait_compatibility = -1 #About 43% of characters will have compatibility below this value for average character
neutral_trait_compatibility = 0 # ~20% of chars are neutral towards average character
low_positive_trait_compatibility = 1 # ~38% of chars has compatibility over this value for average character
medium_positive_trait_compatibility = 11 # ~21% of chars has compatibility over this value for average character
high_positive_trait_compatibility = 26 # ~8% of char has compatibility over this value for average character



########################
# ai_values_divergence #
########################

#These are balanced based on samples taken the 2018-03-28. The data is found in the spreadsheet "Ai value divergence" on the drive.
#The values are only intended to be used for adults. Note that they

very_low_ai_values_divergence = 150 #About 10% (>1 to 24%) of character will be at or below this value for the average character.
low_ai_values_divergence = 200 #About 30% (3-57%) of characters will be at or below this value for the average character
medium_ai_values_divergence = 250  #About 52% (10-85%) of characters will be at or below this value for the average character
high_ai_values_divergence = 300 #About 71% (24-85%) of characters will be at or below this value for the average character
very_high_ai_values_divergence =  350 #About 85% (46-98%) of characters will be at or below this value for the average character
#Percentages in parentheses are the observed spans

####################
# Ai value inverse #
####################

high_positive_ai_value_inverse = {
	value = 1
	divide = high_positive_ai_value
}

high_negative_ai_value_inverse = {
	value = 1
	divide = high_negative_ai_value
}
















###########
# retired #
###########

######################
# ai_value_modifiers #
######################

#For a character with a "high" ai value (see above), the product of ai_value * modifier_scripted_value should be:
#High =  400
#Medium = 200
#Low = 100
#Tiny = 50

#Example: high positive ai value is 40. As high should return the product 400, the high_chance_impact_positive_ai_value should be 10.

high_chance_impact_positive_ai_value = 10
medium_chance_impact_positive_ai_value = 5
low_chance_impact_positive_ai_value = 2.5
tiny_chance_impact_positive_ai_value = 1.25

high_chance_impact_negative_ai_value = -10
medium_chance_impact_negative_ai_value = -5
low_chance_impact_negative_ai_value = -2.5
tiny_chance_impact_negative_ai_value = -1.25


#################
# old ai values #
#################
#Base:
#max: having the top 3 personality traits
#high: having the top 1 (not 100)
#medium: having the top 2nd highest (or slightly higher if traits with this ai value is common)
#low: 10/15/20 (depending on how common it is, this level should be quite common)


#ai_boldness
max_positive_boldness = 100 #brave (50) + ambitious (25) + fickle (25)
high_positive_boldness = 50 #brave
medium_positive_boldness = 25 #ambitious etc.
low_positive_boldness = 10 #gregarious etc.
max_negative_boldness = -100 #craven (-50) + calm (-25) + content (25)
high_negative_boldness = -50 #craven
medium_negative_boldness = -25 #content etc.
low_negative_boldness = -10 #patient etc.

#ai_compassion
max_positive_compassion = 100 #compassionate (40) + generous (25) + forgiving (20)
high_positive_compassion = 40 #compassionate
medium_positive_compassion = 25 #generous
low_positive_compassion = 10 #trusting/humble
max_negative_compassion = -100 #sadistic (-100)
high_negative_compassion = -40 #callous
medium_negative_compassion = -25 #greedy (-20) + one of the 7 traits between -5 and -15
low_negative_compassion = -15 #wrathful, arrogant etc.

#ai_greed
max_positive_greed = 100 #ambitious (50) + greedy (50)
high_positive_greed = 50 #ambitious/greedy
medium_positive_greed = 20 #gluttonous
low_positive_greed = 10 #lustful/lazy
max_negative_greed = -100 #generous (-50) + content (-25) + compassionate (-25)
high_negative_greed = -50 #generous
medium_negative_greed = -25 #content/compassionate/humble
low_negative_greed = -10 #chaste or temperate (-20), all other are -25 or less

#ai_energy
max_positive_energy = 95 #diligent (50), brave (50)
high_positive_energy = 50 #diligent
medium_positive_energy = 25 #brave
low_positive_energy = 15 #there are a 7 traits adding 10 and one 5
max_negative_energy = -100 #content (-50), lazy (-50)
high_negative_energy = -50 #content
medium_negative_energy = -25 #craven
low_negative_energy = -10 #4 traits using -10

#ai_honor
max_positive_honor = 100 #just (50) + honest (25) + compassionate (25)
high_positive_honor = 50 #just
medium_positive_honor = 25 #honest/compassionate
low_positive_honor = 10 #generous, humble etc. 5 different traits
max_negative_honor = -100 #sadistic (-100)
high_negative_honor = -50 #arbitrary
medium_negative_honor = -25 #callous/deceitful
low_negative_honor = -10 #greedy/arrogant etc. 6 different traits

#ai_rationality
max_positive_rationality = 45 #cynical (20) + calm (15) + patient (10)
high_positive_rationality = 20 #cynical
medium_positive_rationality = 15 #calm (15)
low_positive_rationality = 10 #patient etc. 4 different traits
max_negative_rationality = -65 #fickle (-30) + zealous (-20) + wrathful (-15)
high_negative_rationality = -30 #fickle
medium_negative_rationality = -20 #zealous
low_negative_rationality = -10 #impatient etc. 6 different traits
#There are a lot of lifestyle/physical traits which have big impacts on rationality. Maybe throw the intellect_good_3 +30 and the intellect_bad_3 -30 into the list as the highest ranking traits? Especially important for the positive rationality, as many characters will become more rational with age (if progressing in a lifestyle)

#ai_vengefulness
max_positive_vengefulness = 90 #vengeful (50) + stubborn (30) + patient (10)
high_positive_vengefulness = 50 #vengeful
medium_positive_vengefulness = 20 #lowered to 20 so there are more ways to get above it than having vengeful or stubborn
low_positive_vengefulness = 10 #patient/paranoid
max_negative_vengefulness = -100 #forgiving (-50) + fickle (-30) + impatient (-10)
high_negative_vengefulness = -50
medium_negative_vengefulness = -30
low_negative_vengefulness = -10
#Note: there are very few traits which adjust vengefulness

#ai_zeal
max_positive_zeal = 85 #zealous (50), just (25), chaste (10)
high_positive_zeal = 50 #zealous
medium_positive_zeal = 25 #just
low_positive_zeal = 10 #ambitious
max_negative_zeal = -85 #cynical (-50), arbitrary (-25), lustful (-10)
high_negative_zeal = -50 #cynical
medium_negative_zeal = -25 #arbirary
low_negative_zeal = -10 #lustful
#There are a lot of other religious traits which have an impact, look at them?

#ai_boldness:
high_chance_impact_positive_boldness = 8
medium_chance_impact_positive_boldness = 4
low_chance_impact_positive_boldness = 2
high_chance_impact_negative_boldness = -8
medium_chance_impact_negative_boldness = -4
low_chance_impact_negative_boldness = -2
#ai_compassion:
high_chance_impact_positive_compassion = 8
medium_chance_impact_positive_compassion = 4
low_chance_impact_positive_compassion = 2
high_chance_impact_negative_compassion = -8
medium_chance_impact_negative_compassion = -4
low_chance_impact_negative_compassion = -2
#ai_greed:
high_chance_impact_positive_greed = 8
medium_chance_impact_positive_greed = 4
low_chance_impact_positive_greed = 2
high_chance_impact_negative_greed = -8
medium_chance_impact_negative_greed = -4
low_chance_impact_negative_greed = -2
#ai_energy:
high_chance_impact_positive_energy = 8
medium_chance_impact_positive_energy = 4
low_chance_impact_positive_energy = 2
high_chance_impact_negative_energy = -8
medium_chance_impact_negative_energy = -4
low_chance_impact_negative_energy = -2
#ai_honor:
high_chance_impact_positive_honor = 8
medium_chance_impact_positive_honor = 4
low_chance_impact_positive_honor = 2
high_chance_impact_negative_honor = -8
medium_chance_impact_negative_honor = -4
low_chance_impact_negative_honor = -2
#ai_rationality:
high_chance_impact_positive_rationality = 8
medium_chance_impact_positive_rationality = 4
low_chance_impact_positive_rationality = 2
high_chance_impact_negative_rationality = -8
medium_chance_impact_negative_rationality = -4
low_chance_impact_negative_rationality = -2
#ai_vengefulness:
high_chance_impact_positive_vengefulness = 8
medium_chance_impact_positive_vengefulness = 4
low_chance_impact_positive_vengefulness = 2
high_chance_impact_negative_vengefulness = -8
medium_chance_impact_negative_vengefulness = -4
low_chance_impact_negative_vengefulness = -2
#ai_zeal:
high_chance_impact_positive_zeal = 8
medium_chance_impact_positive_zeal = 4
low_chance_impact_positive_zeal = 2
high_chance_impact_negative_zeal = -8
medium_chance_impact_negative_zeal = -4
low_chance_impact_negative_zeal = -2

halved_faction_power_threshold = {
	value = faction_power_threshold
	multiply = 0.5
}

# Budgets

ai_war_chest_gold_minus_100 = {
	value = war_chest_gold
	add = -100
	min = 1
}

halved_ai_war_chest_gold = {
	value = war_chest_gold
	multiply = 0.5
}

excess_over_halved_ai_war_chest_gold = {
	value = war_chest_gold
	subtract = halved_ai_war_chest_gold_maximum
}

halved_ai_war_chest_gold_maximum = {
	value = war_chest_gold_maximum
	multiply = 0.5
}

quarter_ai_war_chest_gold = {
	value = war_chest_gold
	multiply = 0.25
}

excess_over_a_quarter_ai_war_chest_gold = {
	value = war_chest_gold
	subtract = quarter_ai_war_chest_gold_maximum
}

quarter_ai_war_chest_gold_maximum = {
	value = war_chest_gold_maximum
	multiply = 0.25
}

cautious_ai_minimum_war_chest_gold = {
	value = 50
	if = {
		limit = {
			highest_held_title_tier = tier_duchy
		}
		add = 100
	}
	else_if = {
		limit = {
			highest_held_title_tier = tier_kingdom
		}
		add = 200
	}
	else_if = {
		limit = {
			highest_held_title_tier = tier_empire
		}
		add = 300
	}
	max = war_chest_gold_maximum
}

excess_over_cautious_ai_minimum_war_chest_gold = {
	value = war_chest_gold
	subtract = cautious_ai_minimum_war_chest_gold
}

conqueror_safe_spending_gold = { # Conquerors generally want to keep more gold than their war chest maximum around, so they can wage more & longer wars
	value = war_chest_gold_maximum
	multiply = 2
}

# Calc rough opinion values.
calc_rough_liege_opinion_value = {
	if = {
		limit = {
			opinion = {
				target = liege
				value >= 95
			}
		}
		add = 100
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 90
			}
		}
		add = 95
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 85
			}
		}
		add = 90
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 80
			}
		}
		add = 85
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 75
			}
		}
		add = 80
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 70
			}
		}
		add = 75
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 65
			}
		}
		add = 70
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 60
			}
		}
		add = 65
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 55
			}
		}
		add = 60
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 50
			}
		}
		add = 55
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 45
			}
		}
		add = 50
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 40
			}
		}
		add = 45
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 35
			}
		}
		add = 40
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 30
			}
		}
		add = 35
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 25
			}
		}
		add = 30
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 20
			}
		}
		add = 25
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 15
			}
		}
		add = 20
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 10
			}
		}
		add = 15
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 5
			}
		}
		add = 10
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= 0
			}
		}
		add = 5
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -4
			}
		}
		add = 0
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -5
			}
		}
		add = -5
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -10
			}
		}
		add = -10
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -15
			}
		}
		add = -15
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -20
			}
		}
		add = -20
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -25
			}
		}
		add = -25
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -30
			}
		}
		add = -30
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -35
			}
		}
		add = -35
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -40
			}
		}
		add = -40
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -45
			}
		}
		add = -45
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -50
			}
		}
		add = -50
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -55
			}
		}
		add = -55
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -60
			}
		}
		add = -60
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -65
			}
		}
		add = -65
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -70
			}
		}
		add = -70
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -75
			}
		}
		add = -75
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -80
			}
		}
		add = -80
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -85
			}
		}
		add = -85
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -90
			}
		}
		add = -90
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -95
			}
		}
		add = -95
	}
	else_if = {
		limit = {
			opinion = {
				target = liege
				value >= -100
			}
		}
		add = -100
	}
}
calc_rough_root_opinion_value = {
	if = {
		limit = {
			opinion = {
				target = root
				value >= 95
			}
		}
		add = 100
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 90
			}
		}
		add = 95
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 85
			}
		}
		add = 90
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 80
			}
		}
		add = 85
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 75
			}
		}
		add = 80
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 70
			}
		}
		add = 75
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 65
			}
		}
		add = 70
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 60
			}
		}
		add = 65
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 55
			}
		}
		add = 60
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 50
			}
		}
		add = 55
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 45
			}
		}
		add = 50
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 40
			}
		}
		add = 45
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 35
			}
		}
		add = 40
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 30
			}
		}
		add = 35
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 25
			}
		}
		add = 30
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 20
			}
		}
		add = 25
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 15
			}
		}
		add = 20
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 10
			}
		}
		add = 15
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 5
			}
		}
		add = 10
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= 0
			}
		}
		add = 5
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -4
			}
		}
		add = 0
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -5
			}
		}
		add = -5
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -10
			}
		}
		add = -10
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -15
			}
		}
		add = -15
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -20
			}
		}
		add = -20
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -25
			}
		}
		add = -25
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -30
			}
		}
		add = -30
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -35
			}
		}
		add = -35
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -40
			}
		}
		add = -40
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -45
			}
		}
		add = -45
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -50
			}
		}
		add = -50
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -55
			}
		}
		add = -55
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -60
			}
		}
		add = -60
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -65
			}
		}
		add = -65
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -70
			}
		}
		add = -70
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -75
			}
		}
		add = -75
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -80
			}
		}
		add = -80
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -85
			}
		}
		add = -85
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -90
			}
		}
		add = -90
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -95
			}
		}
		add = -95
	}
	else_if = {
		limit = {
			opinion = {
				target = root
				value >= -100
			}
		}
		add = -100
	}
}
calc_rough_opcalc_char_opinion_value = {
	if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 95
			}
		}
		add = 100
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 90
			}
		}
		add = 95
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 85
			}
		}
		add = 90
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 80
			}
		}
		add = 85
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 75
			}
		}
		add = 80
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 70
			}
		}
		add = 75
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 65
			}
		}
		add = 70
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 60
			}
		}
		add = 65
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 55
			}
		}
		add = 60
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 50
			}
		}
		add = 55
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 45
			}
		}
		add = 50
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 40
			}
		}
		add = 45
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 35
			}
		}
		add = 40
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 30
			}
		}
		add = 35
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 25
			}
		}
		add = 30
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 20
			}
		}
		add = 25
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 15
			}
		}
		add = 20
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 10
			}
		}
		add = 15
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 5
			}
		}
		add = 10
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= 0
			}
		}
		add = 5
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -4
			}
		}
		add = 0
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -5
			}
		}
		add = -5
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -10
			}
		}
		add = -10
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -15
			}
		}
		add = -15
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -20
			}
		}
		add = -20
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -25
			}
		}
		add = -25
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -30
			}
		}
		add = -30
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -35
			}
		}
		add = -35
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -40
			}
		}
		add = -40
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -45
			}
		}
		add = -45
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -50
			}
		}
		add = -50
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -55
			}
		}
		add = -55
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -60
			}
		}
		add = -60
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -65
			}
		}
		add = -65
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -70
			}
		}
		add = -70
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -75
			}
		}
		add = -75
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -80
			}
		}
		add = -80
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -85
			}
		}
		add = -85
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -90
			}
		}
		add = -90
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -95
			}
		}
		add = -95
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:opcalc_char
				value >= -100
			}
		}
		add = -100
	}
}

### Brief: ai_men_at_arms_expense_gold_min
# The AI will quickly try to spend this much of its gold income on MAA 
# maintenance. This is referenced in code, so do not rename or remove this 
# without talking with a programmer about it. 
# 
# Value between 0 and 1, where 1 eqivalents using 100% of its income on maa 
# maintenance.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_expense_gold_min = {
	value = {
		value = 0.15
		desc = "default value"
	}
	if = {
		limit = {
			ai_has_warlike_personality = yes
		}
		add = {
			desc = ai_warlike_personality
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_has_conqueror_personality = yes
		}
		add = {
			desc = ai_conqueror_personality
			value = 0.2
		}
	}
	if = {
		limit = {
			ai_has_cautious_personality = yes
		}
		add = {
			desc = ai_cautious_personality
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_has_economical_boom_personality = yes
		}
		add = {
			desc = ai_economical_boom_personality
			value = -0.1
		}
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 0.5
		}
	}

	min = 0
	max = 0.9
}

### Brief: ai_men_at_arms_expense_ideal
# The AI will try to spend this much of its gold income on MAA maintenance. It won't
# buy beyond this, but might end up higher due to reduced income. This is 
# referenced in code, so do not rename or remove this without talking with a 
# programmer about it. 
#
# Value between 0 and 1, where 1 eqivalents using 100% of its income on maa 
# maintenance.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_expense_gold_ideal = {
	value = {
		value = 0.4
		desc = "default value"
	}
	if = {
		limit = {
			ai_has_warlike_personality = yes
		}
		add = {
			desc = ai_warlike_personality
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_has_conqueror_personality = yes
		}
		add = {
			desc = ai_conqueror_personality
			value = 0.2
		}
	}
	if = {
		limit = {
			ai_has_economical_boom_personality = yes
		}
		add = {
			desc = ai_economical_boom_personality
			value = -0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
			monthly_character_income >= 20
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
			monthly_character_income >= 40
		}
		add = {
			desc = "significant ruler, late medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
			monthly_character_income >= 30
		}
		add = {
			desc = "lesser ruler, high medieval"
			value = 0.1
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
			monthly_character_income >= 60
		}
		add = {
			desc = "lesser ruler, late medieval"
			value = 0.1
		}
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 0.5
		}
	}

	min = 0
	max = 0.9
}

### Brief: ai_men_at_arms_expense_gold_max
# The AI will disband MAA if it ends up spending more than this amount of its 
# income on maintenance. This is referenced in code, so do not rename or remove
# this without talking with a programmer about it. 
#
# Value between 0 and 1, where 1 eqivalents using 100% of its income on maa 
# maintenance.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_expense_gold_max = {
	value = {
		value = 0.6
		desc = "default value"
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, late medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, high medieval"
			value = 0.05
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, late medieval"
			value = 0.1
		}
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 0.1
		}
	}
	if = {
		limit = {
			government_allows = administrative
			NOT = { vassal_contract_has_flag = admin_theme_civilian }
		}
		add = {
			desc = ai_admin_vassal
			value = 0.3
		}
	}

	min = 0
	max = 0.9
	
	if = {
		limit = {
			government_allows = administrative
			debt_level <= 2
		}
		value = 3
	}
}

### Brief: ai_men_at_arms_expense_prestige_min
# The AI will quickly try to spend this much of its prestige income on MAA 
# maintenance. This is referenced in code, so do not rename or remove this 
# without talking with a programmer about it. 
# 
# Value between 0 and 1, where 1 equivalents to using 100% of its income on maa 
# maintenance.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_expense_prestige_min = {
	value = {
		value = 0.25
		desc = "default value"
	}
	if = {
		limit = {
			ai_has_warlike_personality = yes
		}
		add = {
			desc = ai_warlike_personality
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_has_conqueror_personality = yes
		}
		add = {
			desc = ai_conqueror_personality
			value = 0.2
		}
	}
	if = {
		limit = {
			ai_has_cautious_personality = yes
		}
		add = {
			desc = ai_cautious_personality
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_has_economical_boom_personality = yes
		}
		add = {
			desc = ai_economical_boom_personality
			value = -0.1
		}
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 0.5
		}
	}

	min = 0
	max = 0.9
}

### Brief: ai_men_at_arms_expense_prestige_ideal
# The AI will try to spend this much of its income on MAA maintenance. It won't
# buy beyond this, but might end up higher due to reduced income. This is 
# referenced in code, so do not rename or remove this without talking with a 
# programmer about it. 
#
# Value between 0 and 1, where 1 equivalents to using 100% of its income on maa 
# maintenance.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_expense_prestige_ideal = {
	value = {
		value = 0.4
		desc = "default value"
	}
	if = {
		limit = {
			ai_has_warlike_personality = yes
		}
		add = {
			desc = ai_warlike_personality
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_has_conqueror_personality = yes
		}
		add = {
			desc = ai_conqueror_personality
			value = 0.2
		}
	}
	if = {
		limit = {
			ai_has_economical_boom_personality = yes
		}
		add = {
			desc = ai_economical_boom_personality
			value = -0.1
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, high medieval"
			value = 0.1
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, late medieval"
			value = 0.1
		}
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 0.1
		}
	}

	min = 0
	max = 0.9
}

### Brief: ai_men_at_arms_expense_prestige_max
# The AI will disband MAA if it ends up spending more than this amount of its 
# income on maintenance. This is referenced in code, so do not rename or remove
# this without talking with a programmer about it. 
#
# Value between 0 and 1, where 1 equivalents to using 100% of its income on maa 
# maintenance.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_expense_prestige_max = {
	value = {
		value = 0.6
		desc = "default value"
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, high medieval"
			value = 0.05
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, late medieval"
			value = 0.1
		}
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 0.1
		}
	}

	min = 0
	max = 0.9
}

### Brief: ai_men_at_arms_chance_expense_below_min
# Chance the AI will prefer MaA to buildings when spending less than the ideal 
# on MaA.
# 
# Value between 0 and 1, where 1 equivalents to a 100% chance of recruiting MaA
# instead of a building.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_chance_expense_below_min = {
	value = {
		value = 0.4
		desc = "default value"
	}
	if = {
		limit = {
			ai_has_warlike_personality = yes
		}
		add = {
			desc = ai_warlike_personality
			value = 0.4
		}
	}
	if = {
		limit = {
			ai_has_conqueror_personality = yes
		}
		add = {
			desc = ai_conqueror_personality
			value = 0.6
		}
	}
	if = {
		limit = {
			ai_has_cautious_personality = yes
		}
		add = {
			desc = ai_cautious_personality
			value = 0.2
		}
	}
	if = {
		limit = {
			ai_has_economical_boom_personality = yes
		}
		add = {
			desc = ai_economical_boom_personality
			value = -0.3
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.4
		}
	}
	if = {
		limit = {
			ai_should_focus_on_building_in_their_capital = yes
		}
		multiply = 0
		add = 0.1
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 1
		}
	}

	min = 0
	max = 0.9
}

### Brief: ai_men_at_arms_chance_expense_below_ideal
# Chance the AI will prefer MaA to buildings when spending less than the ideal 
# on MaA.
# 
# Value between 0 and 1, where 1 equivalents to a 100% chance of recruiting MaA
# instead of a building.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_chance_expense_below_ideal = {
	value = {
		value = 0.1
		desc = "default value"
	}
	if = {
		limit = {
			ai_has_warlike_personality = yes
		}
		add = {
			desc = ai_warlike_personality
			value = 0.4
		}
	}
	if = {
		limit = {
			ai_has_conqueror_personality = yes
		}
		add = {
			desc = ai_conqueror_personality
			value = 0.6
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier >= tier_kingdom
			}
		}
		add = {
			desc = "significant ruler, high medieval"
			value = 0.2
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_high_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, high medieval"
			value = 0.05
		}
	}
	if = {
		limit = {
			culture ?= {
				has_cultural_era_or_later = culture_era_late_medieval
			}
			primary_title ?= {
				tier < tier_kingdom
			}
		}
		add = {
			desc = "lesser ruler, high medieval"
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_has_economical_boom_personality = yes
		}
		multiply = {
			desc = ai_economical_boom_personality
			value = 0.1
		}
	}
	if = {
		limit = {
			ai_should_focus_on_building_in_their_capital = yes
		}
		multiply = 0
		add = 0.1
	}
	if = {
		limit = {
			has_character_flag = vassal_directive_build_maa
			vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
		}
		add = {
			desc = ai_directive
			value = 1
		}
	}

	min = 0
	max = 0.9
}

### Brief: ai_men_at_arms_chance_landless_ruler
# Chance the AI will prefer MaA to buildings when they are a landless ruler.
# Is used exclusively when the character fulfils the requirement: 
#	- they are a ruler (they hold a title, which also means adventurers)
#	- they are not landed
# 
# Value between 0 and 1, where 1 equivalents to a 100% chance of recruiting MaA
# instead of a building.
# 
# Scopes:
#	root - character
#		AI character evaluating the ideal percentile. 
#
ai_men_at_arms_chance_landless_ruler = {
	value = {
		value = 0.5
		desc = "default value"
		if = {
			limit = {
				OR = {
					has_realm_law = camp_purpose_mercenaries
					has_realm_law = camp_purpose_brigands
				}
			}
			add = 0.25
		}
		if = {
			limit = {
				has_realm_law = camp_purpose_scholars
			}
			add = -0.25
		}
		if = { # Landless admin focus mostly on Buildings
			limit = {
				government_allows = administrative
			}
			add = -0.3
		}
		if = { # Adventurers want a minimum set of buildings
			limit = {
				is_landless_adventurer = yes
				max_military_strength >= 100
				domicile.num_domicile_buildings <= 4
			}
			add = -0.4
		}
		if = { # To avoid Adventurer travels becoming super-costly provision-wise, they should focus on buildings over MaA at certain ratios
			limit = {
				is_landless_adventurer = yes
				max_military_strength >= 500
				domicile.max_provisions <= 4000
			}
			multiply = 0
		}
	}
}
