# INFLUENCE

#Note! These are base values, use loss/gain below
miniscule_influence_value = 10
minor_influence_value = 30
medium_influence_value = 60
major_influence_value = 100
massive_influence_value = 150
monumental_influence_value = 250


miniscule_influence_loss = {
	value = 0
	subtract = miniscule_influence_value
}
minor_influence_loss = {
	value = 0
	subtract = minor_influence_value
}
medium_influence_loss = {
	value = 0
	subtract = medium_influence_value
}
major_influence_loss = {
	value = 0
	subtract = major_influence_value
}
massive_influence_loss = {
	value = 0
	subtract = massive_influence_value
}
monumental_influence_loss = {
	value = 0
	subtract = monumental_influence_value
}

miniscule_influence_gain = miniscule_influence_value
minor_influence_gain = minor_influence_value
medium_influence_gain = medium_influence_value
major_influence_gain = major_influence_value
massive_influence_gain = massive_influence_value
monumental_influence_gain = monumental_influence_value

#Influence Levels
low_negative_influence_level = -1
low_influence_level = 1
medium_influence_level = 2
high_influence_level = 3
very_high_influence_level = 4
max_influence_level = 5

max_dynasty_influence_level = 10
high_dynasty_influence_level = 7
medium_dynasty_influence_level = 4
low_dynasty_influence_level = 2
min_dynasty_influence_level = 0


influence_modifier_scaling_value = {
	value = influence_level
	min = 1
	desc = MODIFIER_DEFINITION_MAIN_DESC_INFLUENCE_LEVEL
}

### Estate building cost values
# Base costs
estate_external_building_normal_base_cost_value = {
	if = {
		limit = {
			government_has_flag = government_is_celestial
		}
		value = 50
	}
	else = {
		value = 100
	}
}
estate_external_building_high_base_cost_value = {
	if = {
		limit = {
			government_has_flag = government_is_celestial
		}
		value = 75
	}
	else = {
		value = 150
	}
}
estate_internal_building_normal_base_cost_value = {
	if = {
		limit = {
			government_has_flag = government_is_celestial
		}
		value = 25
	}
	else = {
		value = 50
	}
}
estate_internal_building_high_base_cost_value = {
	if = {
		limit = {
			government_has_flag = government_is_celestial
		}
		value = 40
	}
	else = {
		value = 75
	}
}

# External building costs - normal
estate_external_building_normal_cost_tier_1_value = {
	value = estate_external_building_normal_base_cost_value
	multiply = estate_location_cost_modifier_value
}
estate_external_building_normal_cost_tier_2_value = {
	value = {
		value = estate_external_building_normal_base_cost_value
		multiply = 2
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_normal_cost_tier_3_value = {
	value = {
		value = estate_external_building_normal_base_cost_value
		multiply = 3
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_normal_cost_tier_4_value = {
	value = {
		value = estate_external_building_normal_base_cost_value
		multiply = 4
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_normal_cost_tier_5_value = {
	value = {
		value = estate_external_building_normal_base_cost_value
		multiply = 5
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_normal_cost_tier_6_value = {
	value = {
		value = estate_external_building_normal_base_cost_value
		multiply = 6
	}
	multiply = estate_location_cost_modifier_value
}

# External building costs - high
estate_external_building_high_cost_tier_1_value = {
	value = estate_external_building_high_base_cost_value
	multiply = estate_location_cost_modifier_value
}
estate_external_building_high_cost_tier_2_value = {
	value = {
		value = estate_external_building_high_base_cost_value
		multiply = 2
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_high_cost_tier_3_value = {
	value = {
		value = estate_external_building_high_base_cost_value
		multiply = 3
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_high_cost_tier_4_value = {
	value = {
		value = estate_external_building_high_base_cost_value
		multiply = 4
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_high_cost_tier_5_value = {
	value = {
		value = estate_external_building_high_base_cost_value
		multiply = 5
	}
	multiply = estate_location_cost_modifier_value
}
estate_external_building_high_cost_tier_6_value = {
	value = {
		value = estate_external_building_high_base_cost_value
		multiply = 6
	}
	multiply = estate_location_cost_modifier_value
}

# Internal building costs - normal
estate_internal_building_normal_cost_tier_1_value = {
	value = estate_internal_building_normal_base_cost_value
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_normal_cost_tier_2_value = {
	value = {
		value = estate_internal_building_normal_base_cost_value
		multiply = 2
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_normal_cost_tier_3_value = {
	value = {
		value = estate_internal_building_normal_base_cost_value
		multiply = 3
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_normal_cost_tier_4_value = {
	value = {
		value = estate_internal_building_normal_base_cost_value
		multiply = 4
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_normal_cost_tier_5_value = {
	value = {
		value = estate_internal_building_normal_base_cost_value
		multiply = 5
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_normal_cost_tier_6_value = {
	value = {
		value = estate_internal_building_normal_base_cost_value
		multiply = 6
	}
	multiply = estate_location_cost_modifier_value
}

# Internal building costs - high
estate_internal_building_high_cost_tier_1_value = {
	value = estate_internal_building_high_base_cost_value
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_high_cost_tier_2_value = {
	value = {
		value = estate_internal_building_high_base_cost_value
		multiply = 2
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_high_cost_tier_3_value = {
	value = {
		value = estate_internal_building_high_base_cost_value
		multiply = 3
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_high_cost_tier_4_value = {
	value = {
		value = estate_internal_building_high_base_cost_value
		multiply = 4
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_high_cost_tier_5_value = {
	value = {
		value = estate_internal_building_high_base_cost_value
		multiply = 5
	}
	multiply = estate_location_cost_modifier_value
}
estate_internal_building_high_cost_tier_6_value = {
	value = {
		value = estate_internal_building_high_base_cost_value
		multiply = 6
	}
	multiply = estate_location_cost_modifier_value
}

# Estate location modifier value
estate_location_cost_modifier_value = {
	value = 1

	if = { # Everything is a bit more expensive in the capital
		limit = {
			domicile.domicile_location = top_liege.capital_province
		}
		add = 0.2
	}
	else_if = { # Everything is a bit cheaper in themes along the borders
		limit = {
			any_top_realm_border_county = {
				duchy = root.domicile.domicile_location.county.duchy
			}
		}
		add = -0.2
	}
}

### Estate building AI values
estate_building_ai_modifier_value = {
	if = {
		limit = { # Some characters should want to build in their estate before they construct buildings in holdings
			scope:owner = {
				OR = {
					has_trait = arbitrary
					has_trait = gluttonous
					has_trait = greedy
				}
			}
		}
		add = 10
	}
	if = { # Character's loyal to the realm should very slightly favor constructing buildings in holdings first
		limit = {
			scope:owner = {
				has_trait = loyal
				OR = {
					has_trait = diligent
					has_trait = just
				}
			}
		}
		add = -1 # This will generally (though not guaranteed) make the AI build estate buildings one tier later than normal
	}
}
#

granary_modifier_scaling_value = {
	value = 1
	if = {
		limit = {
			exists = root
		}
		domicile ?= {
			if = {
				limit = {
					has_domicile_building_or_higher = grain_field_01
				}
				if = {
					limit = { has_domicile_building = grain_field_06 }
					add = 6
				}
				else_if = {
					limit = { has_domicile_building = grain_field_05 }
					add = 5
				}
				else_if = {
					limit = { has_domicile_building = grain_field_04 }
					add = 4
				}
				else_if = {
					limit = { has_domicile_building = grain_field_03 }
					add = 3
				}
				else_if = {
					limit = { has_domicile_building = grain_field_02 }
					add = 2
				}
				else = {
					add = 1
				}
			}
			if = {
				limit = {
					has_domicile_building_or_higher = east_asian_estate_rice_field_01
				}
				if = {
					limit = { has_domicile_building = east_asian_estate_rice_field_06 }
					add = 6
				}
				else_if = {
					limit = { has_domicile_building = east_asian_estate_rice_field_05 }
					add = 5
				}
				else_if = {
					limit = { has_domicile_building = east_asian_estate_rice_field_04 }
					add = 4
				}
				else_if = {
					limit = { has_domicile_building = east_asian_estate_rice_field_03 }
					add = 3
				}
				else_if = {
					limit = { has_domicile_building = east_asian_estate_rice_field_02 }
					add = 2
				}
				else = {
					add = 1
				}
			}
			if = {
				limit = {
					domicile_location = {
						this = root.top_liege.capital_province
					}
				}
				add = 2
			}
			if = {
				limit = {
					domicile_location = {
						OR = {
							terrain = farmlands
							terrain = floodplains
							terrain = terraced_hills
						}
					}
				}
				add = 5
			}
			if = {
				limit = {
					domicile_location.county = {
						county_control < 100
					}
				}
				add = {
					value = 100
					subtract = domicile.domicile_location.county.county_control
					multiply = 0.1
					round = yes
					min = 1
				}
			}
			if = {
				limit = {
					domicile_location.county = {
						development_level >= estate_granary_development_bonus_2_value
					}
				}
				multiply = 3
			}
			else_if = {
				limit = {
					domicile_location.county = {
						development_level >= estate_granary_development_bonus_1_value
					}
				}
				multiply = 2
			}
			if = {
				limit = {
					domicile_location = {
						any_province_epidemic = { }
					}
				}
				multiply = 2
			}
		}
	}
	desc = MODIFIER_DEFINITION_ESTATE_SCALING_DESC
}
estate_granary_development_bonus_1_value = 30
estate_granary_development_bonus_2_value = 60

estate_construction_influence_gain_value = {
	value = 20

	# Bonus from governing with Civilian Administration
	if = {
		limit = { vassal_contract_has_flag = admin_influence_construction_bonus }
		add = 20
	}

	# Increase from Estate Building
	if = {
		limit = {
			domicile ?= { has_domicile_parameter = estate_increase_influence_on_building_construction_5 }
		}
		multiply = {
			value = 1
			add = estate_construction_influence_bonus_5_value
		}
	}
	else_if = {
		limit = {
			domicile ?= { has_domicile_parameter = estate_increase_influence_on_building_construction_4 }
		}
		multiply = {
			value = 1
			add = estate_construction_influence_bonus_4_value
		}
	}
	else_if = {
		limit = {
			domicile ?= { has_domicile_parameter = estate_increase_influence_on_building_construction_3 }
		}
		multiply = {
			value = 1
			add = estate_construction_influence_bonus_3_value
		}
	}
	else_if = {
		limit = {
			domicile ?= { has_domicile_parameter = estate_increase_influence_on_building_construction_2 }
		}
		multiply = {
			value = 1
			add = estate_construction_influence_bonus_2_value
		}
	}
	else_if = {
		limit = {
			domicile ?= { has_domicile_parameter = estate_increase_influence_on_building_construction_1 }
		}
		multiply = {
			value = 1
			add = estate_construction_influence_bonus_1_value
		}
	}
}
estate_construction_influence_bonus_1_value = 0.2
estate_construction_influence_bonus_2_value = 0.4
estate_construction_influence_bonus_3_value = 0.6
estate_construction_influence_bonus_4_value = 0.8
estate_construction_influence_bonus_5_value = 1

influence_inherit_large_bonus_value = 0.3
influence_inherit_medium_bonus_value = 0.2
influence_inherit_small_bonus_value = 0.1

appointment_score_script_value = {
	value = "appointment_candidate_score(root.primary_title)"
	min = 1
	desc = APPOINTMENT_SCORE_SCRIPT_VALUE_DESC
}

# The cost for taking command of other theme troops - ROOT is the title the requested troops belong to
admin_title_troop_command_cost_value = {
	save_temporary_scope_as = recipient_title

	# Base cost - Set in 00_defines.txt
	value = {
		value = define:NAdministrative|BASE_REASSIGN_COST
		format = "BASE_VALUE_FORMAT"
		desc = "BASE_VALUE"
	}

	if = { # Increase cost based on the total number of regiments - The first three regiments are not accounted for, we consider them a part of the base cost
		limit = {
			scope:recipient_title = {
				OR = {
					any_owned_title_maa_regiment = {
						count > 3
					}
					any_owned_title_maa_regiment = {
						maa_size > 3
					}
					AND = {
						any_owned_title_maa_regiment = {
							count > 2
						}
						any_owned_title_maa_regiment = {
							maa_size > 1
						}
					}
					AND = {
						any_owned_title_maa_regiment = {
							count > 1
						}
						any_owned_title_maa_regiment = {
							maa_size > 2
						}
					}
				}
			}
		}
		add = {
			value = define:NAdministrative|BASE_REASSIGN_COST
			multiply = {
				value = {
					scope:recipient_title = {
						every_title_maa_regiment = {
							add = maa_size
						}
					}
					subtract = 3
					divide = 20
				}
			}
			desc = ADMIN_TITLE_TROOP_COST_ARMY_SIZE_DESC
		}
	}

	# You are fighting a defensive war
	if = {
		limit = {
			scope:actor = {
				any_character_war = {
					is_war_leader = scope:actor
					is_defender = scope:actor
				}
			}
		}
		subtract = {
			value = define:NAdministrative|BASE_REASSIGN_COST
			multiply = 0.25
			desc = ADMIN_TITLE_TROOP_COST_DEFENDER_DESC
		}
	}
	# You are fighting an offensive war, and the troop owner is far away
	else_if = {
		limit = {
			scope:recipient_title.holder = { top_liege != this }
			scope:actor = {
				any_war_enemy = {
					realm_to_title_distance_squared = {
						target = scope:recipient_title
						value > 100000
					}
				}
			}
		}
		add = {
			value = define:NAdministrative|BASE_REASSIGN_COST
			multiply = 0.25
			desc = ADMIN_TITLE_TROOP_COST_ATTACKER_DESC
		}
	}

	# The Troop owner is inside the war goal
	if = {
		limit = {
			holder = {
				target_is_liege_or_above = scope:actor
				OR = {
					any_held_title = { is_contested = yes }
					any_vassal = {
						any_held_title = { is_contested = yes }
					}
				}
			}
		}
		subtract = {
			value = define:NAdministrative|BASE_REASSIGN_COST
			multiply = 0.25
			desc = ADMIN_TITLE_TROOP_COST_OWNER_IN_WAR_GOAL_DESC
		}
	}

	# If you are independent - The cost is reduced with your laws
	# Imperial Bureaucracy for admin, and Army Command Structure for celestial
	if = { # Admin
		limit = {
			scope:actor = {
				top_liege = this
				realm_law_use_imperial_bureaucracy = yes
			}
		}
		if = {
			limit = {
				scope:actor = {
					has_realm_law_flag = admin_title_troop_cost_reduction_high
				}
			}
			subtract = {
				value = define:NAdministrative|BASE_REASSIGN_COST
				multiply = admin_law_cost_reduction_high_value
				desc = ADMIN_TITLE_TROOP_COST_LAW_2_DESC
			}
		}
		else_if = {
			limit = {
				scope:actor = {
					has_realm_law_flag = admin_title_troop_cost_reduction
				}
			}
			subtract = {
				value = define:NAdministrative|BASE_REASSIGN_COST
				multiply = admin_law_cost_reduction_value
				desc = ADMIN_TITLE_TROOP_COST_LAW_1_DESC
			}
		}
	}
	else_if = { # Celestial
		limit = {
			scope:actor = {
				top_liege = this
				realm_law_use_celestial_bureaucracy = yes
			}
		}
		if = {
			limit = {
				scope:actor = {
					has_realm_law_flag = admin_title_troop_cost_reduction_very_high
				}
			}
			subtract = {
				value = define:NAdministrative|BASE_REASSIGN_COST
				multiply = admin_law_cost_reduction_very_high_value
				desc = ADMIN_TITLE_TROOP_COST_LAW_3_CELESTIAL_DESC
			}
		}
		else_if = {
			limit = {
				scope:actor = {
					has_realm_law_flag = admin_title_troop_cost_reduction_high
				}
			}
			subtract = {
				value = define:NAdministrative|BASE_REASSIGN_COST
				multiply = admin_law_cost_reduction_high_value
				desc = ADMIN_TITLE_TROOP_COST_LAW_2_CELESTIAL_DESC
			}
		}
		else_if = {
			limit = {
				scope:actor = {
					has_realm_law_flag = admin_title_troop_cost_reduction
				}
			}
			subtract = {
				value = define:NAdministrative|BASE_REASSIGN_COST
				multiply = admin_law_cost_reduction_value
				desc = ADMIN_TITLE_TROOP_COST_LAW_1_CELESTIAL_DESC
			}
		}
	}

	# In Meritocratic governments, we prefer to not let the AI borrow from players, since they can be
	# called in via 'request_military_aid_interaction' / 'send_military_aid_interaction'
	if = {
		limit = {
			scope:actor = {
				government_has_flag = government_has_merit
				is_ai = yes
			}
			scope:recipient_title = {
				holder = {
					is_ai = no
				}
			}
		}
		multiply = 100000
	}
}
admin_law_cost_reduction_value = 0.25
admin_law_cost_reduction_high_value = 0.5
admin_law_cost_reduction_very_high_value = 0.75

admin_troops_reclaim_cost_cooldown_value = 5

# Some control values that we reference in loc.
diarch_more_efficient_administrative_emperor_promotion_candidate_massive_value = 1.5
diarch_more_efficient_administrative_emperor_promotion_candidate_major_value = 1
diarch_more_efficient_administrative_emperor_promotion_candidate_medium_value = 0.75
diarch_more_efficient_administrative_emperor_promotion_candidate_mild_value = 0.5

# For use when promoting a candidate via interaction.
appointment_score_interaction_multiplier_modifiers_value = {
	value = 1
	# Co-emperors are more efficient to promote.
	if = {
		limit = {
			exists = scope:target
			exists = scope:secondary_recipient
			appointment_interactions_recipient_is_suitable_co_emperor_trigger = yes
		}
		if = {
			limit = {
				scope:actor.top_liege = { has_diarchy_active_parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_massive }
			}
			add = diarch_more_efficient_administrative_emperor_promotion_candidate_massive_value
		}
		else_if = {
			limit = {
				scope:actor.top_liege = { has_diarchy_active_parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_major }
			}
			add = diarch_more_efficient_administrative_emperor_promotion_candidate_major_value
		}
		else_if = {
			limit = {
				scope:actor.top_liege = { has_diarchy_active_parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_medium }
			}
			add = diarch_more_efficient_administrative_emperor_promotion_candidate_medium_value
		}
		else_if = {
			limit = {
				scope:actor.top_liege = { has_diarchy_active_parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_mild }
			}
			add = diarch_more_efficient_administrative_emperor_promotion_candidate_mild_value
		}
	}
}

# Eparch values
eparch_aptitude_modifier_scaling_value = {
	value = 1
	if = {
		limit = { exists = root }
		add = root.aptitude:eparch_court_position
	}
	desc = MODIFIER_DEFINITION_MAIN_DESC_EPARCH_APTITUDE
}
university_cost_reduction_value = 0.25
eparch_scheme_secrecy_bonus_value = {
	if = {
		limit = {
			scope:owner ?= { has_court_position = eparch_court_position }
			scope:target = {
				domicile ?= { domicile_location = owner.top_liege.capital_province }
			}
		}
		add = {
			value = 15
			desc = eparch_scheme_bonus_desc
		}
	}
}

# State Faith
ep3_state_faith_conversion_mult_value = 2

# Hold Triumph Decision
ep3_triumph_gold_cost = {
	value = 100
	if = {
		limit = {
			NOT = { government_allows = administrative }
		}
		add = 100
		if = {
			limit = {
				NOT = {
					has_variable = ep3_valid_triumph_victory
				}
			}
			add = 200
		}
	}
}

ep3_triumph_influence_cost = {
	value = 0
	if = {
		limit = {
			government_allows = administrative
		}
		add = 50
		if = {
			limit = {
				NOT = {
					has_variable = ep3_valid_triumph_victory
				}
			}
			add = 200
		}
	}
}

# Laamp

ep3_laamp_chance_score_value = {
	value = 0
	add = { value = sum_of_all_skills_and_prowess_value divide = 4 }
	add = { value = piety_level multiply = 2 } # Devotion
	add = { value = prestige_level multiply = 2 } # Fame
	# Age
	if = {
		limit = { age < 25 }
		add = 3
	}
	# Personality
	if = {
		limit = { has_trait = ambitious }
		add = 3
	}
	if = {
		limit = { has_trait = brave }
		add = 3
	}
	if = {
		limit = { has_trait = arrogant }
		add = 3
	}
	if = {
		limit = { has_trait = stubborn }
		add = 3
	}
	# Genetics
	if = {
		limit = { has_trait = beauty_good }
		add = 3
	}
	if = {
		limit = { has_trait = intellect_good }
		add = 3
	}
	if = {
		limit = { has_trait = physique_good }
		add = 3
	}
	# Fame/Lifestyle/Commander
	every_character_trait = {
		limit = {
			OR = {
				has_trait_category = fame
				has_trait_category = lifestyle
				has_trait_category = commander
			}
		}
		add = 3
	}
	# Education
	if = {
		limit = { has_trait = education_martial }
		add = 5
	}
	if = {
		limit = { has_trait = education_martial_prowess }
		add = 5
	}
	# Bastardry
	if = {
		limit = { has_trait = bastard }
		add = 5
	}
	if = {
		limit = { has_trait = legitimized_bastard }
		add = 3
	}
	if = {
		limit = { has_trait = wild_oat }
		add = 3
	}
	if = {
		limit = { has_trait = child_of_concubine }
		add = 3
	}
	# Cosmetics
	if = {
		limit = { has_trait = scarred }
		add = 3
	}
	if = {
		limit = { has_trait = one_eyed }
		add = 3
	}
	if = {
		limit = { has_trait = disfigured }
		add = 3
	}
	# Culture/Faith
	if = {
		limit = {
			faith = { has_doctrine_parameter = unlock_voluntary_laampdom_faith }
		}
		add = 5
	}
	if = {
		limit = {
			culture = { has_cultural_parameter = unlock_voluntary_laampdom }
		}
		add = 5
	}
	if = {
		limit = {
			has_trait = nomadic_philosophy
		}
		add = 5
	}
	if = {
		limit = {
			culture = { has_cultural_parameter = much_more_likely_to_be_laamps }
		}
		add = 50
	}
	if = {
		limit = {
			culture = { has_cultural_parameter = more_likely_to_be_laamps }
		}
		add = 25
	}
	# Too much to lose
	every_heir_title = {
		add = {
			value = 0
			subtract = tier
		}
	}
	every_held_title = {
		add = {
			value = tier
			multiply = -2
		}
	}
	# Stop streaks
	every_held_title = {
		limit = {
			previous_holder ?= {
				is_alive = yes
				government_has_flag = government_is_landless_adventurer
			}
		}
		add = -75
	}
	# Encourage potential legitimists and such to go wandering.
	if = {
		limit = { realm_size <= 0 }
		every_claim = {
			limit = { tier >= tier_kingdom }
			add = 30
		}
	}
}

request_laamp_invasion_sponsorship_gold_cost = {
	value = 300
	if = {
		limit = { scope:recipient.highest_held_title_tier >= tier_empire }
		add = 200
	}
}

## Referenced in code
ep3_hire_laamp_mercs_cost_value = {
	value = scope:recipient.current_military_strength
	divide = 10
	min = scope:actor.minor_gold_value
	multiply = {
		value = {
			scope:actor = {
				every_character_war = {
					limit = {
						is_war_leader = scope:actor
					}
					add = 1
				}
			}
			min = 1
		}
	}
	if = {
		limit = {
			scope:recipient.domicile = { has_domicile_parameter = camp_improved_mercenary_contract_rewards }
		}
		multiply = camp_improved_mercenary_contract_rewards_value
	}
	if = {
		limit = {
			scope:recipient = { has_perk = hard_rule_perk }
		}
		multiply = adventurer_hard_rule_contract_rewards_value
	}
}

ep3_hire_laamp_mercs_payment_value = {
	value = scope:war_contribution_value
	divide = 10
	min = scope:employer.medium_gold_value
	if = {
		limit = {
			scope:laamp_temp.domicile ?= { has_domicile_parameter = camp_improved_mercenary_contract_rewards }
		}
		multiply = camp_improved_mercenary_contract_rewards_value
	}
	if = {
		limit = {
			exists = scope:war_valuable_prisoners
		}
		add = {
			value = scope:war_valuable_prisoners
			multiply = 20
		}
	}
	if = {
		limit = {
			scope:laamp_temp ?= { has_perk = hard_rule_perk }
		}
		multiply = adventurer_hard_rule_contract_rewards_value
	}
	max = {
		value = scope:employer.yearly_character_income
		if = {
			limit = {
				scope:employer.gold > 0
			}
			add = scope:employer.gold
		}
	}
}

ep3_laamp_flavour_ewan_4041_regiment_damage_wildfires_min = 20
ep3_laamp_flavour_ewan_4041_regiment_damage_wildfires_max = 50

ep3_laamp_flavour_ewan_4041_regiment_damage_avalanches_min = 30
ep3_laamp_flavour_ewan_4041_regiment_damage_avalanches_max = 60

ep3_laamp_flavour_ewan_4041_regiment_damage_flash_floods_min = 20
ep3_laamp_flavour_ewan_4041_regiment_damage_flash_floods_max = 40

ep3_laamp_flavour_ewan_4041_regiment_damage_frozen_water_min = 15
ep3_laamp_flavour_ewan_4041_regiment_damage_frozen_water_max = 30

ep3_laamp_flavour_ewan_4041_regiment_damage_earthquake_min = 50
ep3_laamp_flavour_ewan_4041_regiment_damage_earthquake_max = 80

chariot_race_entrance_fee = {
	value = 50
}

chariot_race_base_cost_value = {
	value = 200
}

chariot_ordering_value = {
	value = 0
	add = aptitude:charioteer_court_position
	round = yes
}

charioteer_chance_to_win = {
	value =  1
	add = prowess
	add = aptitude:charioteer_court_position
	round = yes
}

charioteer_chance_to_place = {
	value = 1
	add = prowess
	add = aptitude:charioteer_court_position
	round = yes
}

charioteer_chance_to_show = {
	value = 1
	add = prowess
	add = aptitude:charioteer_court_position
	round = yes
}

charioteer_victory_score_value = {
	value = 0
	if = {
		limit = { is_alive = yes}
		if = {
			limit = { has_variable = chariot_race_victory_score }
			add = var:chariot_race_victory_score
		}
	}
}

charioteer_passive_phase_gui_sort_value = {
	value = 1
	if = {
		limit = { is_alive = yes }
		add = this.aptitude:charioteer_court_position
	}
}

charioteer_placement_middle = {
	value = 0
	add = {
		value = involved_activity.var:num_charioteers
		divide = 2
	}
}

following_charioteer_index = {
	value = var:current_place_in_race
	add = 1
	max = 12
}

ahead_charioteer_index = {
	value = var:current_place_in_race
	subtract = 1
	min = 1
}

2_ahead_charioteer_index = {
	value = var:current_place_in_race
	subtract = 2
	min = 1
}

bookkeeper_small_commission_value = {
	value = 0.2
	if = {
		limit = {
			scope:host.court_position:bookmaker_court_position ?= {
				has_character_flag = bookmaker_cooking_the_books
			}
		}
		multiply = 3
	}
}

bookkeeper_medium_commission_value = {
	value = 0.3
	if = {
		limit = {
			scope:host.court_position:bookmaker_court_position ?= {
				has_character_flag = bookmaker_cooking_the_books
			}
		}
		multiply = 3
	}
}

bookkeeper_large_commission_value = {
	value = 0.4
	if = {
		limit = {
			scope:host.court_position:bookmaker_court_position ?= {
				has_character_flag = bookmaker_cooking_the_books
			}
		}
		multiply = 3
	}
}

# Distance value used instead of diplo range for LAAMP interactions range
ep3_laamp_interaction_max_range = 450000 #from Byzantion to west and east edges of ERE in 1066

purchase_land_county_cost_value = 400
purchase_land_duchy_cost_value = 1000

ep3_laamp_invasion_levies_size_value = {
	value = 0
	add = scope:supporter.max_military_strength
	divide = 10
	max = {
		# Standard base max.
		value = varangian_adventurers_standard_levy_cap_value
	}
}

ep3_laamp_invasion_ai_targeting_value = {
	value = 100
	scope:attacker = {
		# Weight up claims.
		if = {
			limit = {
				scope:attacker = {
					any_claim = {
						OR = {
							holder = scope:defender
							holder.top_liege = scope:defender
						}
					}
				}
			}
			add = 100
		}
		# Weight up those who are already overwhelmed.
		if = {
			limit = {
				scope:defender = { gold < 0 }
			}
			add = 100
		}
		# Weight up those who are already overwhelmed.
		if = {
			limit = {
				scope:defender = { is_at_war = yes }
			}
			add = 100
		}
		# Weight up independent dukes.
		if = {
			limit = {
				scope:defender = { highest_held_title_tier = tier_duchy }
			}
			add = 100
		}
		# Weight up independent kings.
		if = {
			limit = {
				scope:defender = { highest_held_title_tier = tier_kingdom }
			}
			add = 50
		}
		# Weight up for coastal counties.
		every_in_list = {
			list = target_titles
			limit = {
				tier = tier_county
				is_coastal_county = yes
			}
			add = 50
		}
		# Weight down independent religious heads.
		if = {
			limit = { scope:defender = scope:defender.faith.religious_head }
			add = -1000
		}
		# Weight down independent counts.
		if = {
			limit = {
				scope:defender = { highest_held_title_tier = tier_county }
			}
			add = -200
		}
		# Weight down small players.
		if = {
			limit = {
				scope:defender = {
					is_ai = no
					realm_size <= minor_realm_size
				}
			}
			add = -1000
		}
	}
}

ep3_laamp_invasion_cb_cost = {
	add = {
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_empire
				}
			}
			add = 10000
		}
		else_if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_kingdom
				}
			}
			add = 5000
		}
		else_if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_duchy
				}
			}
			add = 2000
		}
		else = { add = 500 }
		desc = "CB_BASE_COST"
	}

	# Reduce the cost to make this more feasible for the AI.
	scope:attacker = {
		if = {
			limit = { is_ai = yes }
			multiply = 0.1
		}
	}

	#Halve cost if Lust for Land modifier
	if = {
		limit = {
			scope:attacker = {
				has_character_modifier = ep3_lust_for_land_modifier
			}
		}
		divide = {
			value = 2
			desc = "lust_for_land_modifier_tt"
		}
	}
}

ep3_laamp_invasion_base_piety_cost = {
	add = common_cb_impious_piety_cost
	if = {
		limit = {
			scope:defender.faith = scope:attacker.faith
		}
		add = {
			value = major_piety_value
			desc = CB_SAME_FAITH_COST
		}
	}
}

# Governor efficiency used in code
# root - charater that is evaluated for the governorship
# End result should be a multiplier, but we add larger values to present it better in the breakdown. E.g. we add 10, but divide it with 100 to make it 0.1.
governor_efficiency = {
	value = {
		# Everyone will calculate their Efficiency according to the following:
		# Skills
		add = {
			add = {
				desc = diplomacy_concept
				add = {
					value = diplomacy
					multiply = 1.7
				}
				round = yes
			}
			add = {
				desc = martial_concept
				add = {
					value = martial
					multiply = 1.7
				}
				round = yes
			}
			add = {
				desc = stewardship_concept
				add = {
					value = stewardship
					multiply = 1.7
				}
				round = yes
			}
			add = {
				desc = intrigue_concept
				add = {
					value = intrigue
					multiply = 1.7
				}
				round = yes
			}
			add = {
				desc = learning_concept
				add = {
					value = learning
					multiply = 1.7
				}
				round = yes
			}
			divide = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						realm_size >= 65
						realm_size < 75
					}
					liege ?= {
						realm_size >= 65
						realm_size < 75
					}
				}
			}
			add = {
				add = {
					value = -5
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
						realm_size >= 75
						realm_size < 85
					}
					liege ?= {
						realm_size >= 75
						realm_size < 85
					}
				}
			}
			add = {
				add = {
					value = -10
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
						realm_size >= 85
						realm_size < 95
					}
					liege ?= {
						realm_size >= 85
						realm_size < 95
					}
				}
			}
			add = {
				add = {
					value = -15
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
						realm_size >= 95
						realm_size < 105
					}
					liege ?= {
						realm_size >= 95
						realm_size < 105
					}
				}
			}
			add = {
				add = {
					value = -20
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 105
				realm_size < 115
					}
					liege ?= {
				realm_size >= 105
				realm_size < 115
					}
				}
			}
			add = {
				add = {
					value = -25
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 115
				realm_size < 125
					}
					liege ?= {
				realm_size >= 115
				realm_size < 125
					}
				}
			}
			add = {
				add = {
					value = -30
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 125
				realm_size < 135
					}
					liege ?= {
				realm_size >= 125
				realm_size < 135
					}
				}
			}
			add = {
				add = {
					value = -35
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 135
				realm_size < 145
					}
					liege ?= {
				realm_size >= 135
				realm_size < 145
					}
				}
			}
			add = {
				add = {
					value = -40
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 145
				realm_size < 155
					}
					liege ?= {
				realm_size >= 145
				realm_size < 155
					}
				}
			}
			add = {
				add = {
					value = -45
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 155
				realm_size < 165
					}
					liege ?= {
				realm_size >= 155
				realm_size < 165
					}
				}
			}
			add = {
				add = {
					value = -50
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 175
				realm_size < 185
					}
					liege ?= {
				realm_size >= 175
				realm_size < 185
					}
				}
			}
			add = {
				add = {
					value = -55
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 185
				realm_size < 195
					}
					liege ?= {
				realm_size >= 185
				realm_size < 195
					}
				}
			}
			add = {
				add = {
					value = -60
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 195
				realm_size < 205
					}
					liege ?= {
				realm_size >= 195
				realm_size < 205
					}
				}
			}
			add = {
				add = {
					value = -65
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
				realm_size >= 205
				realm_size < 215
					}
					liege ?= {
				realm_size >= 205
				realm_size < 215
					}
				}
			}
			add = {
				add = {
					value = -70
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
						realm_size >= 215
						realm_size < 225
					}
					liege ?= {
						realm_size >= 215
						realm_size < 225
					}
				}
			}
			add = {
				add = {
					value = -75
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
						realm_size >= 225
						realm_size < 235
					}
					liege ?= {
						realm_size >= 225
						realm_size < 235
					}
				}
			}
			add = {
				add = {
					value = -80
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
						realm_size >= 235
						realm_size < 245
					}
					liege ?= {
						realm_size >= 235
						realm_size < 245
					}
				}
			}
			add = {
				add = {
					value = -85
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				OR = {
					AND = {
						realm_size >= 245
						realm_size < 255

					}
					liege ?= {
						realm_size >= 245
						realm_size < 255

					}
				}
			}
			add = {
				add = {
					value = -90
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {

				OR = {
					AND = {
						realm_size >= 255
						realm_size < 265
					}
					liege ?= {
						realm_size >= 255
						realm_size < 265
					}
				}
			}
			add = {
				add = {
					value = -95
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				OR = {
					AND = {
						realm_size >= 265
						realm_size < 275

					}
					liege ?= {
						realm_size >= 265
						realm_size < 275

					}
				}
			}
			add = {
				add = {
					value = -100
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				OR = {
					AND = {
						realm_size >= 275
						realm_size < 285

					}
					liege ?= {
						realm_size >= 275
						realm_size < 285

					}
				}
			}
			add = {
				add = {
					value = -105
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				
				OR = {
					AND = {
						realm_size >= 285
						realm_size < 295
					}
					liege ?= {
						realm_size >= 285
						realm_size < 295
					}
				}
			}
			add = {
				add = {
					value = -110
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				
				OR = {
					AND = {
						realm_size >= 300
					}
					liege ?= {
						realm_size >= 300
					}
				}
			}
			add = {
				add = {
					value = -115
					desc = game_concept_realm_size
				}
				divide = 100
			}
		}
		else = {
		}
		# Rank 4 or 5 education trait
		if = {
			limit = {
				has_trait_with_flag = level_5_education
			}
			add = {
				add = {
					value = 4
					desc = has_rank_5_education_desc
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				has_trait_with_flag = level_4_education
			}
			add = {
				add = {
					value = 2
					desc = has_rank_4_education_desc
				}
				divide = 100
			}
		}

		# Governor trait
		if = { # You only get a small bonus since the trait also provides skills that will increase Efficiency further
			limit = {
				has_trait = governor
				has_trait_xp = {
					trait = governor
					value >= 25
				}
			}
			add = {
				add = {
					value = 0
					if = {
						limit = {
							has_trait_xp = {
								trait = governor
								value >= 100
							}
						}
						add = 12
					}
					else_if = {
						limit = {
							has_trait_xp = {
								trait = governor
								value >= 75
							}
						}
						add = 9
					}
					else_if = {
						limit = {
							has_trait_xp = {
								trait = governor
								value >= 50
							}
						}
						add = 6
					}
					else_if = {
						limit = {
							has_trait_xp = {
								trait = governor
								value >= 25
							}
						}
						add = 3
					}
					desc = governor_trait_short_desc
				}
				divide = 100
			}
		}

		# Estate
		if = {
			limit = { domicile ?= { has_domicile_parameter = estate_governor_efficiency_bonus } }
			add = {
				add = {
					value = estate_governor_efficiency_bonus_value
					multiply = 100
					desc = "[estate_buildings|E]"
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				house ?= {
					house_head ?= {
						domicile ?= { has_domicile_parameter = estate_governor_efficiency_bonus_for_house_members }
					}
				}
			}
			add = {
				add = {
					value = estate_governor_efficiency_house_bonus_value
					multiply = 100
					desc = "[domicile_buildings|E]"
				}
				divide = 100
			}
		}
		
		# Aspirations
		if = {
			limit = { # Service
				house ?= { has_house_power_parameter = service_house_governor_efficiency_bonus }
			}
			add = {
				add = {
					value = service_house_governor_efficiency_bonus_value
					multiply = 100
					desc = service_house_power
				}
				divide = 100
			}
		}
		if = {
			limit = { # Governance
				house ?= { has_house_power_parameter = governance_improved_governor_efficiency_bonus }
			}
			add = {
				add = {
					value = governance_improved_governor_efficiency_bonus_value
					multiply = 100
					desc = celestial_governor_name_desc
				}
				divide = 100
			}
		}

		# Bonuses from active Governorship Obligation/Administration
		if = {
			limit = { vassal_contract_has_flag = admin_martial_obligation_bonus }
			add = {
				add = {
					value = martial
					multiply = efficiency_skill_increase_value
					desc = admin_martial_obligation_bonus_desc
				}
				divide = 100
			}
		}
		if = {
			limit = { vassal_contract_has_flag = admin_stewardship_obligation_bonus }
			add = {
				add = {
					value = stewardship
					multiply = efficiency_skill_increase_value
					desc = admin_stewardship_obligation_bonus_desc
				}
				divide = 100
			}
		}
		if = {
			limit = { vassal_contract_has_flag = admin_prowess_obligation_bonus }
			add = {
				add = {
					value = prowess
					multiply = efficiency_skill_increase_value
					desc = admin_prowess_obligation_bonus_desc
				}
				divide = 100
			}
		}
		if = {
			limit = { vassal_contract_has_flag = admin_prestige_obligation_bonus }
			add = {
				add = {
					value = prestige_level
					multiply = efficiency_currency_level_increase_value
					desc = admin_prestige_obligation_bonus_desc
				}
				divide = 100
			}
		}
		if = {
			limit = { vassal_contract_has_flag = admin_tradeport_obligation_bonus }
			add = {
				add = {
					every_sub_realm_barony = {
						limit = {
							title_province = { has_building_or_higher = common_tradeport_01 }
						}
						add = efficiency_building_increase_value
					}
					desc = admin_tradeport_obligation_bonus_desc
				}
				divide = 100
			}
		}
		# Celestial Obligation/Administration (we split these out to have separate loc)
		if = {
			limit = { vassal_contract_has_flag = celestial_province_protectorate }
			add = {
				add = {
					value = martial
					multiply = efficiency_skill_increase_value
					desc = celestial_province_protectorate_name_desc
				}
				divide = 100
			}
		}
		if = {
			limit = { vassal_contract_has_flag = celestial_province_metropolitan }
			add = {
				add = {
					value = diplomacy
					multiply = efficiency_skill_increase_value
					desc = celestial_province_metropolitan_name_desc
				}
				divide = 100
			}
		}

		# Dynasty Legacy Perk
		if = {
			limit = {
				dynasty ?= { ep3_administrative_legacy_track_perks >= 1 }
			}
			add = {
				add = {
					value = 5
					desc = "[GetDynastyPerk('ep3_administrative_legacy_1').GetName]"
				}
				divide = 100
			}
		}

		if = {
			limit = {
				dynasty ?= { has_dynasty_perk = tgp_chinese_legacy_3 }
			}
			add = {
				add = {
					value = 5
					desc = "[GetDynastyPerk('tgp_chinese_legacy_3').GetName]"
				}
				divide = 100
			}
		}

		# Lifestyle Perks
		# Positions of Power Stewardship Perk
		if = {
			limit = { has_perk = positions_of_power_perk }
			add = {
				add = {
					value = 5
					desc = "[GetPerk('positions_of_power_perk').GetName(GetPlayer)]"
				}
				divide = 100
			}
		}
		# Strict Organization Martial Perk
		if = {
			limit = { has_perk = strict_organization_perk }
			add = {
				add = {
					value = 5
					desc = "[GetPerk('strict_organization_perk').GetName(GetPlayer)]"
				}
				divide = 100
			}
		}
		
		# Eparch court position
		if = {
			limit = {
				employs_court_position = eparch_court_position
			}
			add = {
				add = {
					value = 1
					court_position:eparch_court_position ?= {
						add = aptitude:eparch_court_position
					}
					multiply = 2
					desc = eparch_increase_efficiency_desc
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				top_liege ?= {
					employs_court_position = eparch_court_position
				}
				NOT = { has_court_position = eparch_court_position }
				domicile ?= {
					domicile_location = {
						this = county.holder.top_liege.capital_province
					}
				}
			}
			add = {
				add = {
					value = 1
					top_liege ?= {
						court_position:eparch_court_position ?= {
							add = aptitude:eparch_court_position
						}
					}
					desc = eparch_increase_efficiency_vassal_desc
				}
				divide = 100
			}
		}
		if = {
			limit = {
				employs_court_position = grand_mentor_court_position
			}
			add = {
				add = {
					value = 1
					court_position:grand_mentor_court_position ?= {
						add = aptitude:grand_mentor_court_position
					}
					multiply = 2
					desc = grand_mentor_powerfuL_family_score_desc
				}
				divide = 100
			}
		}
		if = {
			limit = {
				employs_court_position = grand_guardian_court_position
			}
			add = {
				add = {
					value = 1
					court_position:grand_guardian_court_position ?= {
						add = aptitude:grand_guardian_court_position
					}
					multiply = 2
					desc = grand_guardian_powerfuL_family_score_desc
				}
				divide = 100
			}
		}
		if = {
			limit = {
				employs_court_position = grand_preceptor_court_position
			}
			add = {
				add = {
					value = 1
					court_position:grand_preceptor_court_position ?= {
						add = aptitude:grand_preceptor_court_position
					}
					multiply = 2
					desc = grand_preceptor_powerfuL_family_score_desc
				}
				divide = 100
			}
		}

		# Events
		add = {
			add = {
				desc = gov_efficiency_events_desc
				if = {	#ep3_emperor_yearly.2150
					limit = { has_character_flag = ep3_2150_found_truth }
					add = 10
				}
				if = {	#ep3_governor_yearly.3070
					limit = {
						has_character_modifier = contented_governing_countrymen_modifier
						exists = capital_county
						culture = capital_county.culture
					}
					add = 10
				}
				if = {	#ep3_emperor_yearly.2160
					limit = { has_character_flag = ep3_2160_success }
					add = 5
				}
				if = {	#ep3_emperor_yearly.2160
					limit = { has_character_flag = ep3_2160_failure }
					add = -5
				}
				if = {	#ep3_governor_yearly.3100
					limit = { has_character_modifier = ep3_ignoring_realm_decline_modifier }
					add = -5
				}
				if = {	#ep3_governor_yearly.3080
					limit = { has_character_flag = ep3_governor_ignored_isolation }
					add = -5
				}
				if = {	#ep3_governor_yearly.3080
					limit = { has_character_modifier = ep3_anxious_for_new_assignment_modifier }
					add = -5
				}
				if = {	#ep3_emperor_yearly.2170
					limit = { has_character_flag = ep3_2170_success }
					add = 5
				}
				if = {
					limit = { has_character_modifier = restored_greek_theme_modifier }
					add = 10
				}
				if = {	#ep3_emperor_yearly.2190
					limit = { has_character_flag = ep3_2190_honest }
					add = 10
				}
				if = {	#ep3_emperor_yearly.2200
					limit = { has_character_flag = ep3_embezzling_governor }
					add = -5
				}
				if = {
					limit = { has_character_modifier = ep3_bolstered_governor_treasury_modifier }
					add = 5
				}
				if = {
					limit = { has_character_modifier = ep3_governor_yearly_8050_imperial_recruiter_modifier }
					add = 5
				}
				if = {
					limit = { has_character_flag = ep3_8060_efficiency_drop }
					add = -5
				}
				if = {
					limit = { has_character_modifier = ep3_governor_yearly_8050_imperial_resources_modifier }
					add = -5
				}
				if = {
					limit = { has_character_modifier = ep3_governor_yearly_8120_relief_rejected_modifier }
					add = -5
				}
				if = {
					limit = { has_character_modifier = ep3_governor_yearly_8130_raised_taxes_modifier }
					add = -5
				}
				if = {
					limit = { has_character_modifier = ep3_governor_yearly_8130_raised_almonage_modifier }
					add = 5
				}
				if = {
					limit = { has_character_modifier = noble_administrators_modifier }
					add = 5
				}
				if = {
					limit = { has_character_flag = ep3_governor_yearly_3050_neglect_duties }
					add = -5
				}
				if = {
					limit = { has_character_flag = ep3_governor_yearly_3002_landlord_fight }
					add = -5
				}
				if = {
					limit = { has_character_flag = ep3_governor_yearly_3002_landlord_wins }
					add = -10
				}
				if = {
					limit = { has_character_flag = ep3_governor_yearly_3002_landlord_dominates }
					add = -15
				}
				if = {
					limit = { has_character_modifier = ep3_governor_yearly_8040_domicile_development_modifier }
					add = -10
				}
			}
			divide = 100
		}

		# Interactions
		add = {
			add = {
				desc = gov_efficiency_interactions_desc
				if = {
					limit = { has_character_modifier = ep3_boost_efficiency_modifier }
					add = {
						value = {
							value = efficiency_interaction_change_value
							if = {
								limit = { exists = var:ep3_governor_efficiency_stack }
								multiply = var:ep3_governor_efficiency_stack
							}
						}
					}
				}
				if = {
					limit = { has_character_modifier = ep3_damage_efficiency_modifier }
					add = {
						value = {
							value = efficiency_interaction_change_value
							multiply = -1 # Negativise
							if = {
								limit = { exists = var:ep3_governor_efficiency_stack }
								multiply = var:ep3_governor_efficiency_stack
							}
						}
					}
				}
			}
			divide = 100
		}

		# Schemes
		add = {
			add = {
				desc = "[GetModifier('scheme_slandered_modifier').GetNameWithTooltip]"
				if = {
					limit = { has_character_modifier = scheme_slandered_modifier }
					add = efficiency_slandered_value
				}
			}
			divide = 100
		}

		# Eunuch
		if = {
			limit = {
				exists = liege
				liege.culture ?= {
					OR = {
						has_cultural_parameter = eunuch_trait_bonuses
						has_cultural_parameter = court_machinations_eunuch_trait_bonuses
					}
				}
				has_trait = eunuch_1
			}
			add = {
				add = {
					value = 10
					desc = court_position_eunuch_trait
				}
				divide = 100
			}
		}
		else_if = {
			limit = {
				exists = liege
				liege.culture ?= {
					OR = {
						has_cultural_parameter = eunuch_trait_bonuses
						has_cultural_parameter = court_machinations_eunuch_trait_bonuses
					}
				}
				has_trait = beardless_eunuch
			}
			add = {
				add = {
					value = 10
					desc = court_position_beardless_eunuch_trait
				}
				divide = 100
			}
		}

		# Non-de jure governors get a penalty
		if = {
			limit = {
				top_liege ?= { save_temporary_scope_as = top_liege_temp }
				is_governor = yes
				any_sub_realm_county = {
					NOT = {
						trigger_if = {
							limit = { scope:top_liege_temp.highest_held_title_tier > tier_empire }
							target_is_de_jure_liege_or_above = scope:top_liege_temp.primary_title
						}
						trigger_else_if = {
							limit = { scope:top_liege_temp.highest_held_title_tier = tier_empire }
							empire ?= scope:top_liege_temp.primary_title
						}
						trigger_else = { kingdom ?= scope:top_liege_temp.primary_title }
					}
				}
			}
			add = {
				add = {
					value = de_jure_governor_bonus
					desc = de_jure_governor_desc
				}
				divide = 100
			}
		}

		# TGP DYNASTIC CYCLE
		if = {
			limit = {
				top_liege ?= {
					has_title = title:h_china
					top_participant_group:dynastic_cycle ?= {
						has_participant_group_parameter = dynastic_cycle_governor_efficiency_penalty
					}
				}
			}
			add = {
				add = {
					value = {
						add = corruption_phase_governor_efficiency_penalty_value
						multiply = {
							value = top_liege.legitimacy_level
							subtract = 5
						}
					}
					desc = corruption_phase_governor_efficiency_penalty_desc
				}
				divide = 100
			}
		}
		if = { # The Forbidden City special building bonus
			limit = {
				top_liege ?= {
					capital_province = {
						has_building_or_higher = forbidden_city_01
					}
				}
			}
			add = {
				add = {
					value = forbidden_city_bonus_value
					desc = "[GetBuilding('forbidden_city_01').GetName]"
				}
				divide = 100
			}
		}
		if = { # The Great Barracks duchy building bonus (great project)
			limit = {
				OR = {
					vassal_contract_has_flag = celestial_military_appointment # Only for celestial military governors
					government_has_flag = government_is_administrative # All regular admin types are eligible
					is_independent_ruler = yes # The top liege can always use it
				}
				any_directly_owned_province ?= {
					has_building_or_higher = celestial_great_barracks_01
				}
			}
			add = {
				add = {
					value = great_barracks_bonus_value
					desc = "[GetBuilding('celestial_great_barracks_01').GetName]"
				}
				divide = 100
			}
		}
		
		# TGP TREASURY BUDGET
		if = {
			limit = {
				top_liege ?= {
					OR = {
						has_realm_law = budget_allocation_salary_0
						has_realm_law = budget_allocation_salary_5
						AND = {
							has_realm_law = budget_allocation_salary_10
							situation:dynastic_cycle ?= { situation_current_phase = situation_dynastic_cycle_phase_stability_advancement }
						}
						AND = {
							has_realm_law = budget_allocation_salary_15
							situation:dynastic_cycle ?= { situation_current_phase = situation_dynastic_cycle_phase_stability_advancement }
						}
					}
				}
			}
			add = {
				add = {
					value = -5
					if = {
						limit = {
							OR = {
								has_realm_law = budget_allocation_salary_0
								has_realm_law = budget_allocation_salary_5
							}
							situation:dynastic_cycle ?= { situation_current_phase = situation_dynastic_cycle_phase_stability_advancement }
						}
						add = -5
					}
					desc = low_salary_desc
				}
				divide = 100
			}
		}

		# TGP JAPAN DOMICILE
		if = {
			limit = {
				domicile ?= { has_domicile_parameter = japanese_archives_governor_efficiency_boost }
			}
			add = {
				value = 2.5
				domicile ?= {
					if = {
						limit = { has_domicile_building_or_higher = japanese_archive_02 }
						add = 2.5
					}
					if = {
						limit = { has_domicile_building_or_higher = japanese_archive_03 }
						add = 2.5
					}
					if = {
						limit = { has_domicile_building_or_higher = japanese_archive_04 }
						add = 2.5
					}
					if = {
						limit = { has_domicile_building_or_higher = japanese_archive_05 }
						add = 2.5
					}
				}
				desc = japanese_archives_governor_efficiency_boost_desc
			}
		}
		#HOUSE BLOC
		if = {
			limit = {
				confederation ?= { has_cohesion_level_parameter = any_member_house_governor_efficiency_boost }
			}
			multiply = {
				value = 1.1
				desc = SERVICE_BLOC_COHESION_DESC
			}
		}

		min = 0.5 # Can't go lower than -50%
		max = 1.5 # Can't go higher than +50%
	}
}

# Governor efficiency as presented in the interface.
governor_efficiency_presented = {
	value = {
		add = governor_efficiency
		multiply = 100 # Make percentile
		subtract = 100 # Shift calculation to be between -50% and 50%
	}
}

efficiency_skill_increase_value = 0.5
efficiency_currency_level_increase_value = 4
efficiency_building_increase_value = 2
efficiency_slandered_value = -5
admin_contract_cooldown_value = 5

governance_task_contract_tier_value = {
	value = 1

	if = {
		limit = {
			scope:task_contract.task_contract_tier >= define:NTaskContract|MEDIUM_TASK_CONTRACT_TIER
			scope:task_contract.task_contract_tier < define:NTaskContract|HIGH_TASK_CONTRACT_TIER
		}
		add = 0.5
	}
	else_if = {
		limit = {
			scope:task_contract.task_contract_tier >= define:NTaskContract|HIGH_TASK_CONTRACT_TIER
		}
		add = 1
	}
}

governance_modifier_scaling_tier_value = {
	value = 1
	if = {
		limit = {
			scope:task_contract.task_contract_tier >= define:NTaskContract|MEDIUM_TASK_CONTRACT_TIER
			scope:task_contract.task_contract_tier < define:NTaskContract|HIGH_TASK_CONTRACT_TIER
		}
		add = 1
	}
	else_if = {
		limit = {
			scope:task_contract.task_contract_tier >= define:NTaskContract|HIGH_TASK_CONTRACT_TIER
		}
		add = 2
	}
	desc = MODIFIER_DEFINITION_MAIN_DESC_GOVERNANCE_TIER
}

estate_governance_contract_bonus_value = 0.5

appointment_cost_multiplier_value = {
	value = 1
	if = {
		limit = {
			top_liege = { has_realm_law = male_preference_law }
			is_female = yes
		}
		add = 1
	}
	else_if = {
		limit = {
			top_liege = { has_realm_law = male_only_law }
			is_female = yes
		}
		multiply = 3
	}
	else_if = {
		limit = {
			top_liege = { has_realm_law = female_preference_law }
			is_female = no
		}
		multiply = 1
	}
	else_if = {
		limit = {
			top_liege = { has_realm_law = female_only_law }
			is_female = no
		}
		multiply = 3
	}
}

appointment_minor_influence_cost = {
	value = 50
}

appointment_medium_influence_cost = {
	value = 100
}

appointment_major_influence_cost = {
	value = 250
}

appointment_score_minor_value = {
	value = appointment_minor_influence_cost
	multiply = 0.2
}

appointment_score_medium_value = {
	value = appointment_medium_influence_cost
	multiply = 0.2
}

appointment_score_major_value = {
	value = appointment_major_influence_cost
	multiply = 0.2
}

appointment_score_minor_loss_value = {
	value = appointment_score_minor_value
	multiply = -1
}

appointment_score_medium_loss_value = {
	value = appointment_score_medium_value
	multiply = -1
}

appointment_score_major_loss_value = {
	value = appointment_score_major_value
	multiply = -1
}

appointment_score_max_tt_value = {
	value = 0
	if = {
		limit = {
			exists = scope:target
			exists = scope:secondary_recipient
			NOT = { scope:secondary_recipient = scope:target.current_heir }
		}
		add = {
			value = "scope:target.current_heir.appointment_candidate_score(scope:target)"
			multiply = 1.1
		}
		subtract = "scope:secondary_recipient.appointment_candidate_score(scope:target)"
		min = 4 # We do this to prevent cases when the default score of the candidate is already much higher than that the heir
	}
	multiply = scope:actor.appointment_score_interaction_multiplier_modifiers_value
}

appointment_score_medium_tt_value = {
	value = appointment_score_medium_value
	multiply = scope:actor.appointment_score_interaction_multiplier_modifiers_value
}

appointment_score_major_tt_value = {
	value = appointment_score_major_value
	multiply = scope:actor.appointment_score_interaction_multiplier_modifiers_value
}

appointment_score_medium_loss_tt_value = {
	value = appointment_score_medium_loss_value
	multiply = scope:actor.appointment_score_interaction_multiplier_modifiers_value
}

appointment_score_major_loss_tt_value = {
	value = appointment_score_major_loss_value
	multiply = scope:actor.appointment_score_interaction_multiplier_modifiers_value
}

appointment_non_preferred_gender_penalty_value = 0.8
appointment_opposite_gender_penalty_value = 1

admin_council_cost_value = {
	add = {
		add = {
			value = monumental_influence_value
			multiply = 2
		}
		desc = BASE
	}

	# Cost reduction from Estates
	if = {
		limit = {
			scope:actor ?= {
				domicile ?= { has_domicile_parameter = estate_reduce_council_position_cost }
			}
		}
		multiply = {
			value = {
				value = 1
				subtract = estate_reduce_council_position_cost_value
			}
			desc = market_02_domicile_building
		}
	}

	# Cost reduction from lifestyles
	if = {
		limit = {
			scope:actor ?= {
				has_perk = positions_of_power_perk
			}
		}
		multiply = {
			value = {
				value = 1
				subtract = admin_council_cost_perk_value
			}
			desc = "[GetPerk('honored_to_serve_perk').GetName(GetPlayer)]"
		}
	}

	# Being a Powerful or Dominant Family reduces the cost significantly
	if = {
		limit = {
			scope:actor.house = { is_dominant_family = yes }
		}
		multiply = {
			value = 0.25
			desc = is_dominant_family_desc
		}
	}
	else_if = {
		limit = {
			scope:actor.house = { is_powerful_family = yes }
		}
		multiply = {
			value = 0.5
			desc = is_powerful_family_desc
		}
	}
}
admin_council_loss_value = {
	value = admin_council_cost_value
	multiply = -1
}
admin_council_cost_perk_value = 0.3

admin_state_faith_cost_perk_value = 0.2

estate_move_cooldown_value = 180
estate_governor_efficiency_bonus_value = 0.1
estate_governor_efficiency_house_bonus_value = 0.05
estate_increased_governance_scheme_success_value = 10
estate_local_theme_cost_reduction_value = -0.25
estate_court_tutor_cost_reduction_low_value = 0.25
estate_court_tutor_cost_reduction_value = 0.5
estate_court_tutor_cost_reduction_high_value = 0.75
estate_increased_tutor_aptitude_value = 20
estate_increase_charioteer_aptitude_value = 20
estate_improved_wine_cellar_1_value = 0.1
estate_improved_wine_cellar_2_value = 0.25
estate_improved_wine_cellar_3_value = 0.5
estate_increase_bodyguard_aptitude_1_value = 5
estate_increase_bodyguard_aptitude_2_value = 15
estate_cheaper_feast_cost_value = 0.2
estate_reduce_council_position_cost_value = 0.2
estate_reduce_commission_artifact_cost_value = 0.5
estate_increase_antiquarian_aptitude_value = 20
estate_increase_physician_aptitude_value = 10
estate_increase_physician_aptitude_2_value = 15
estate_increase_physician_aptitude_3_value = 20
estate_increase_master_of_hunt_aptitude_value = 20
estate_increase_master_of_horse_aptitude_value = 20
estate_cheaper_hunt_cost_value = 0.2
estate_granary_gold_bonus_value = 0.5
estate_increase_powerful_famil_rating_per_dynasty_level_value = 3
estate_cheaper_funeral_cost_value = 0.2
estate_cheaper_pilgrimage_cost_value = 0.2
estate_powerful_family_rating_1_value = 10
estate_powerful_family_rating_2_value = 20
estate_powerful_family_rating_3_value = 30
estate_powerful_family_rating_4_value = 40
estate_powerful_family_rating_5_value = 50
estate_powerful_family_rating_6_value = 60

chariot_kathisma_access_difficulty_value = {
	value = medium_skill_rating
	if = {
		limit = {
			OR = {
				is_powerful_vassal = yes
				any_held_title = { is_noble_family_title = yes }
			}
		}
		divide = 2
	}
}

marshal_court_jester_contribution_value = {
	add = diplomacy
	divide = 60
}

camp_improved_court_physician_aptitude_value = 10

ep3_iconoclast_vassal_count = {
	value = 0
	every_vassal_or_below = {
		limit = { faith = faith:iconoclast }
		add = 1
	}
}

# DYNASTY LEGACY PERKS


#CONTRACTS
task_contract_tier_value = {
	value = highest_held_title_tier
}

task_contract_escort_gold_value = {
	value = minor_gold_max_value
	if = {
		limit = {
			highest_held_title_tier > 1
		}
		multiply = highest_held_title_tier
	}
}
#ratio between attacker's military strength and defender's strength
task_contract_join_war_attacker_strength_ratio_value = {
	value = scope:attacker.current_military_strength
	divide = scope:defender.current_military_strength
}

task_contract_war_duration_value = {
	value = root.war_days
}
task_contract_attacker_war_score_value = {
	value = root.attacker_war_score
}
task_contract_defender_war_score_value = {
	value = root.defender_war_score
}
task_contract_t1_value = { value = define:NTaskContract|LOW_TASK_CONTRACT_TIER }
task_contract_t2_value = { value = define:NTaskContract|MEDIUM_TASK_CONTRACT_TIER }
task_contract_t3_value = { value = define:NTaskContract|HIGH_TASK_CONTRACT_TIER }

council_task_contracts_limit_value = {
	value = 1
}

##################################################
# Contract Reward Values

# Gold values for laamps.
## Basic gold values are based on domain/income size. This isn't useful for us, so we balance on a separate scale.
## Bear in mind that these are heavily scaled by _tier_ later on.
miniscule_gold_laamps_value = {
	value = 5
	if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
		}
		multiply = 1.75
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
		multiply = 1.25
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_early_medieval }
		 }
		multiply = 1
	}
	else = { multiply = 0.75 }
}
tiny_gold_laamps_value = {
	value = 10
	if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
		}
		multiply = 1.75
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
		multiply = 1.25
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_early_medieval }
		 }
		multiply = 1
	}
	else = { multiply = 0.75 }
}
minor_gold_laamps_value = {
	value = 25
	if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
		}
		multiply = 1.75
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
		multiply = 1.25
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_early_medieval }
		 }
		multiply = 1
	}
	else = { multiply = 0.75 }
}
medium_gold_laamps_value = {
	value = 50
	if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
		}
		multiply = 1.75
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
		multiply = 1.25
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_early_medieval }
		 }
		multiply = 1
	}
	else = { multiply = 0.75 }
}
major_gold_laamps_value = {
	value = 80
	if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
		}
		multiply = 1.75
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
		multiply = 1.25
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_early_medieval }
		 }
		multiply = 1
	}
	else = { multiply = 0.75 }
}
massive_gold_laamps_value = {
	value = 120
	if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
		}
		multiply = 1.75
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
		multiply = 1.25
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_early_medieval }
		 }
		multiply = 1
	}
	else = { multiply = 0.75 }
}
monumental_gold_laamps_value = {
	value = 180
	if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
		}
		multiply = 1.75
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
		multiply = 1.25
	}
	else_if = {
		limit = {
			culture = { has_cultural_era_or_later = culture_era_early_medieval }
		 }
		multiply = 1
	}
	else = { multiply = 0.75 }
}

# Opinion.
## Default opinion reward for excelling when completing a contract.
task_contract_opinion_excelled_reward_value = 60
## Default opinion reward for successfully completing a contract.
task_contract_opinion_standard_reward_value = 30
## Default opinion reward for kinda completing a contract.
task_contract_opinion_reduced_reward_value = 20
## Default opinion penalty for goofing a contract.
task_contract_opinion_standard_failure_value = -30
## Default opinion penalty for _massively_ goofing a contract.
task_contract_opinion_critical_failure_value = -50
## Opinion penalty for successfully prosecuting a criminal contract against someone.
task_contract_opinion_crime_success_value = -60
## Opinion penalty for successfully prosecuting a criminal contract against someone.
task_contract_opinion_crime_failure_value = -30
## Opinion penalty for successfully prosecuting a criminal contract against someone.
task_contract_opinion_crime_backed_down_value = -10

# Extra rewards.
task_contract_extra_reward_multiplier_value = 1.5 # Update all relevant parameter tootlips if this is changed! e.g. improved_learning_contract_rewards

# How do we multiply the cash rewards in a task contract depending on the employer's tier?
task_contract_tier_gold_multiplier_value = {
	value = 1 # Barons and counts are neutral, so no multiplier needed here.
	if = {
		limit = { exists = scope:task_contract.task_contract_employer }
		# Kings'n'emperors.
		if = {
			limit = { scope:task_contract.task_contract_employer.highest_held_title_tier >= define:NTaskContract|HIGH_TASK_CONTRACT_TIER }
			add = 3
		}
		# Dukes.
		else_if = {
			limit = { scope:task_contract.task_contract_employer.highest_held_title_tier >= define:NTaskContract|MEDIUM_TASK_CONTRACT_TIER }
			add = 2
		}
		# Courtiers first, as we give them a bit less.
		else_if = {
			limit = { scope:task_contract.task_contract_employer.highest_held_title_tier <= 0 }
			add = 0.5
			ceiling = yes
		}
	}
}
# How do we multiply the non-cash rewards in a task contract depending on the employer's tier?
task_contract_tier_other_reward_multiplier_value = {
	value = 1 # Barons and counts are neutral, so no multiplier needed here.
	if = {
		limit = { exists = scope:task_contract.task_contract_employer }
		# Kings'n'emperors.
		if = {
			limit = { scope:task_contract.task_contract_employer.highest_held_title_tier >= define:NTaskContract|HIGH_TASK_CONTRACT_TIER }
			add = 2.5
		}
		# Dukes.
		else_if = {
			limit = { scope:task_contract.task_contract_employer.highest_held_title_tier >= define:NTaskContract|MEDIUM_TASK_CONTRACT_TIER }
			add = 1.5
		}
	}
}

# PRESTIGE — NORMAL CONTRACTS
## Default scaling reward.
task_contract_success_prestige_gain_full_value = {
	value = 150
	multiply = task_contract_tier_other_reward_multiplier_value
	if = {
		limit = {
			scope:taker ?= {
				has_perk = firm_hand_perk
			}
		}
		multiply = 1.2
	}
	if = {
		limit = {
			scope:taker ?= {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		multiply = 1.15
	}
}
## Boosted scaling reward.
task_contract_success_prestige_gain_critical_value = {
	value = task_contract_success_prestige_gain_full_value
	multiply = 1.5
}
## Half default scaling reward.
task_contract_success_prestige_gain_half_value = {
	value = task_contract_success_prestige_gain_full_value
	multiply = 0.5
	min = 25
}
## Default scaling loss on failure.
task_contract_failure_prestige_loss_full_value = {
	value = -25
	multiply = task_contract_tier_other_reward_multiplier_value
}
## Doubled prestige loss
task_contract_failure_prestige_loss_double_value = {
	value = task_contract_failure_prestige_loss_full_value
	multiply = 2
}

# PRESTIGE — CRIMINAL CONTRACTS
## Criminal scaling loss on failure.
### A little higher, for obvious reasons.
task_contract_failure_prestige_loss_crime_value = {
	value = task_contract_failure_prestige_loss_full_value
	multiply = task_contract_tier_other_reward_multiplier_value
}
task_contract_failure_prestige_loss_crime_half_value = {
	value = task_contract_failure_prestige_loss_crime_value
	multiply = 0.5
}
## Default award on invalidation.
task_contract_invalidated_prestige_gain_value = {
	value = task_contract_success_prestige_gain_full_value
	multiply = 0.5
}

# PIETY
## Default scaling reward.
task_contract_success_piety_gain_full_value = {
	value = 100
	multiply = task_contract_tier_other_reward_multiplier_value
}
##Critical scaling reward
task_contract_success_piety_gain_critical_value = {
	value = task_contract_success_piety_gain_full_value
	multiply = 2
}
## Half default scaling reward.
task_contract_success_piety_gain_half_value = {
	value = task_contract_success_piety_gain_full_value
	multiply = 0.5
	min = 25
}
## Default scaling loss on failure.
task_contract_failure_piety_loss_full_value = {
	value = -50
	multiply = task_contract_tier_other_reward_multiplier_value
}

# GOLD — NORMAL CONTRACTS
## Default scaling reward.
task_contract_success_gold_gain_full_value = {
	# Base value + multiplier.
	value = 50
	multiply = task_contract_tier_gold_multiplier_value
	# Lifestyle perks.
	if = {
		limit = {
			exists = scope:task_contract.task_contract_taker
			scope:task_contract.task_contract_taker = { has_perk = at_any_cost_perk }
		}
		multiply = 1.25
	}
	# Stuff that NEEDS to stay at the bottom.
	## Vary our final tally up a bit.
	if = {
		limit = {
			exists = scope:task_contract.task_contract_taker
			scope:task_contract.task_contract_employer.ai_greed != 0
		}
		add = {
			value = scope:task_contract.task_contract_employer.ai_greed
			multiply = -0.2
		}
	}
	## Plus change the last digit around slightly so the values look a little less robotic.
	if = {
		limit = { exists = scope:gold_fuzz }
		add = scope:gold_fuzz
	}
	## And boost a bit further for exceptional rewards, so that they're never beneath the common rewards.
	if = {
		limit = {
			exists = scope:gold_safety_margin
			scope:gold_safety_margin = flag:yes
		}
		add = 10
	}
	## Shouldn't happen but just in case someone is really, really, _really_ stingy: never pay less than at least a truly pathetic amount.
	min = 25
}
## Critical scaling reward.
task_contract_success_gold_gain_critical_value = {
	value = task_contract_success_gold_gain_full_value
	if = {
		limit = { exists = scope:task_contract_tier }
		if = {
			limit = { scope:task_contract_tier >= 3 }
			multiply = 1.25
		}
		else_if = {
			limit = { scope:task_contract_tier >= 2 }
			multiply = 1.5
		}
		else = { multiply = 1.75 }
	}
	else = {
		if = {
			limit = { scope:task_contract.task_contract_tier >= 3 }
			multiply = 1.25
		}
		else_if = {
			limit = { scope:task_contract.task_contract_tier >= 2 }
			multiply = 1.5
		}
		else = { multiply = 1.75 }
	}
}
## Half default scaling reward.
task_contract_success_gold_gain_half_value = {
	value = task_contract_success_gold_gain_full_value
	multiply = 0.5
}
## One third default scaling reward.
task_contract_success_gold_gain_third_value = {
	value = task_contract_success_gold_gain_full_value
	multiply = 0.33
}
## Default award on invalidation.
task_contract_invalidated_gold_gain_value = {
	value = task_contract_success_gold_gain_full_value
	multiply = 0.1
}

# GOLD — TRAVEL CONTRACTS
## Travel scaling reward.
task_contract_success_gold_gain_travel_value = {
	# Base value + multiplier.
	value = 75
	multiply = task_contract_tier_gold_multiplier_value
	# Lifestyle perks.
	if = {
		limit = { exists = scope:task_contract.task_contract_taker }
		if = {
			limit = {
				scope:task_contract.task_contract_taker = { has_perk = at_any_cost_perk }
			}
			multiply = 1.25
		}
		if = {
			limit = {
				scope:task_contract.task_contract_taker = { has_perk = malice_implicit_perk }
			}
			multiply = 2
		}
	}
	# Stuff that NEEDS to stay at the bottom.
	## Vary our final tally up a bit.
	if = {
		limit = {
			exists = scope:task_contract.task_contract_employer
			scope:task_contract.task_contract_employer.ai_greed != 0
		}
		add = {
			value = scope:task_contract.task_contract_employer.ai_greed
			multiply = -0.2
		}
	}
	## Plus change the last digit around slightly so the values look a little less robotic.
	if = {
		limit = { exists = scope:gold_fuzz }
		add = scope:gold_fuzz
	}
	## And boost a bit further for exceptional rewards, so that they're never beneath the common rewards.
	if = {
		limit = {
			exists = scope:gold_safety_margin
			scope:gold_safety_margin ?= flag:yes
		}
		add = 10
	}
	## Shouldn't happen but just in case someone is really, really, _really_ stingy: never pay less than at least a truly pathetic amount.
	min = 25
}
## Travel critical scaling reward.
task_contract_success_gold_gain_critical_travel_value = {
	value = task_contract_success_gold_gain_travel_value
	if = {
		limit = { exists = scope:task_contract_tier }
		if = {
			limit = { scope:task_contract_tier >= 3 }
			multiply = 1.25
		}
		else_if = {
			limit = { scope:task_contract_tier >= 2 }
			multiply = 1.5
		}
		else = { multiply = 1.75 }
	}
	else = {
		if = {
			limit = { scope:task_contract.task_contract_tier >= 3 }
			multiply = 1.25
		}
		else_if = {
			limit = { scope:task_contract.task_contract_tier >= 2 }
			multiply = 1.5
		}
		else = { multiply = 1.75 }
	}
}
## Half travel scaling reward.
task_contract_success_gold_gain_half_travel_value = {
	value = task_contract_success_gold_gain_travel_value
	multiply = 0.5
}

# GOLD — CRIMINAL CONTRACTS
## Criminal scaling reward.
task_contract_success_gold_gain_crime_value = {
	# Base value + multiplier.
	value = 100
	multiply = task_contract_tier_gold_multiplier_value
	# Lifestyle perks.
	if = {
		limit = { exists = scope:task_contract.task_contract_taker }
		if = {
			limit = {
				scope:task_contract.task_contract_taker = { has_perk = at_any_cost_perk }
			}
			multiply = 1.25
		}
		if = {
			limit = {
				scope:task_contract.task_contract_taker = { has_perk = malice_implicit_perk }
			}
			multiply = 2
		}
	}
	# Stuff that NEEDS to stay at the bottom.
	## Vary our final tally up a bit.
	### This time, we add _more_ gold the greedier the employer is — it's a criminal reward, so the greedier they are, the more gold they have available (albeit not to the same degree as the inverse in normal contracts).
	if = {
		limit = { exists = scope:task_contract.task_contract_employer }
		if = {
			limit = { scope:task_contract.task_contract_employer.ai_greed > 1 }
			add = {
				value = scope:task_contract.task_contract_employer.ai_greed
				multiply = 0.1
			}
		}
		### Take it down only a marginal amount for generous chars, as we still want criminal contracts to almost always pay more.
		else_if = {
			limit = { scope:task_contract.task_contract_employer.ai_greed < -1 }
			add = {
				value = scope:task_contract.task_contract_employer.ai_greed
				multiply = -0.05
			}
		}
	}
	## Plus change the last digit around slightly so the values look a little less robotic.
	if = {
		limit = { exists = scope:gold_fuzz }
		add = scope:gold_fuzz
	}
	## And boost a bit further for exceptional rewards, so that they're never beneath the common rewards.
	if = {
		limit = {
			exists = scope:gold_safety_margin
			scope:gold_safety_margin = flag:yes
		}
		add = 10
	}
	## Shouldn't happen but just in case someone is really, really, _really_ stingy: never pay less than at least a truly pathetic amount.
	min = 60
}
## Criminal critical scaling reward.
task_contract_success_gold_gain_critical_crime_value = {
	value = task_contract_success_gold_gain_crime_value
	if = {
		limit = { exists = scope:task_contract_tier }
		if = {
			limit = { scope:task_contract_tier >= 3 }
			multiply = 1.25
		}
		else_if = {
			limit = { scope:task_contract_tier >= 2 }
			multiply = 1.5
		}
		else = { multiply = 1.75 }
	}
	else = {
		if = {
			limit = { scope:task_contract.task_contract_tier >= 3 }
			multiply = 1.25
		}
		else_if = {
			limit = { scope:task_contract.task_contract_tier >= 2 }
			multiply = 1.5
		}
		else = { multiply = 1.75 }
	}
}
## Half criminal scaling reward.
task_contract_success_gold_gain_half_crime_value = {
	value = task_contract_success_gold_gain_crime_value
	multiply = 0.5
}

# Provisions.
## We don't scale these by tier.
task_contract_success_provisions_gain_minor_value = 250
task_contract_success_provisions_gain_medium_value = 500
task_contract_success_provisions_gain_major_value = 1000
task_contract_success_provisions_gain_massive_value = 1500
task_contract_failure_provisions_gain_minor_value = 0

adventurer_siege_replenish_amount = {
	value = 0
	add = scope:barony.title_province.available_loot
	multiply = {
		value = 2
		if = {
			limit = {
				root = { has_perk = a_mans_home_perk }
			}
			add = 2
		}
	}
}

adventurer_siege_provisions_amount = {
	value = 0
	add = scope:barony.title_province.available_loot
	multiply = 20
}

human_provision_value = {
	value = 100
	add = scope:recipient.current_weight
	multiply = 3
}

# Gallowsbait XP
reduced_criminal_contract_xp_gain_value = 0.75
reduced_criminal_contract_xp_gain_loc_value = {
	value = 1
	subtract = reduced_criminal_contract_xp_gain_value
}
gallowsbait_xp_minor_gain = small_lifestyle_random_xp_low
gallowsbait_xp_medium_gain = {
	value = gallowsbait_xp_minor_gain
	multiply = 2 # Between low and mid
}
gallowsbait_xp_major_gain = small_lifestyle_random_xp_mid
gallowsbait_xp_massive_gain = small_lifestyle_random_xp_high

# Knight Errant XP
knight_errant_xp_minor_gain = small_lifestyle_random_xp_low
knight_errant_xp_medium_gain = {
	value = knight_errant_xp_minor_gain
	multiply = 2 # Between low and mid
}
knight_errant_xp_major_gain = small_lifestyle_random_xp_mid
knight_errant_xp_massive_gain = small_lifestyle_random_xp_high

laamp_base_0011_num_removable_potential_rivals_value = {
	every_relation = {
		type = potential_rival
		limit = { laamp_base_0011_valid_potential_rival_trigger = yes }
		add = 1
	}
}

laamp_base_2041_num_counties_to_rob_sans_capital_value = {
	value = laamp_base_2041_num_counties_to_rob_value
	add = -1
}

laamp_base_2041_num_counties_to_rob_value = {
	add = highest_held_title_tier
	add = 2
}

laamp_base_2011_desired_surveyable_holdings_per_tier_value = {
	value = highest_held_title_tier
	add = -1
	multiply = 3
}
laamp_base_2011_actual_surveyable_holdings_per_tier_value = {
	value = sub_realm_size
	every_sub_realm_barony = {
		limit = {
			holder.highest_held_title_tier = tier_barony
			title_province != root.domicile.domicile_location
		}
		add = 1
	}
}

laamp_base_contract_schemes_1301_min_troops_value = 750
laamp_base_contract_schemes_2661_other_skill_threshold_value = very_high_skill_rating
laamp_base_contract_schemes_2661_sacrifice_loan_length_min_value = 4
laamp_base_contract_schemes_2661_sacrifice_loan_length_max_value = 8

##################################################
# Camp Values

adventurer_hard_rule_contract_rewards_value = 1.25

# How much bonus gold do we get from warfare contracts for having the lockwagon upgrade?
## Applied within a script value, not as an extra modifier.
camp_improved_mercenary_contract_rewards_value = 1.5
## Shift the value around a bit for loc.
camp_improved_mercenary_contract_rewards_loc_value = {
	value = camp_improved_mercenary_contract_rewards_value
	add = -1
}

# How much a proportion of a camp building's cost do we get back on demolishing it?
camp_refund_mult_value = 0.5

# Camp additional buildings standard costs.
camp_building_upgrade_cost_t1_value = 60
camp_building_upgrade_cost_t2_value = 120
camp_building_upgrade_cost_t3_value = 180
camp_building_upgrade_cost_t4_value = 240
camp_building_upgrade_cost_t5_value = 300
camp_building_upgrade_cost_t6_value = 360

# Assorted gold costs for camp buildings.
camp_main_02_domicile_building_gold_cost_value = 200
camp_main_03_domicile_building_gold_cost_value = 350
camp_main_04_domicile_building_gold_cost_value = 500
supply_tent_01_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
supply_tent_02_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
supply_tent_03_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
supply_tent_04_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
supply_tent_05_domicile_building_gold_cost_value = camp_building_upgrade_cost_t5_value
supply_tent_06_domicile_building_gold_cost_value = camp_building_upgrade_cost_t6_value
supply_tent_sutler_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
supply_tent_mender_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
supply_tent_smithy_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
supply_tent_arsenal_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
supply_tent_reserve_provisions_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
supply_tent_reserve_water_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
supply_tent_climbing_gear_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
supply_tent_subdued_gear_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
barber_tent_01_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
barber_tent_02_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
barber_tent_03_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
barber_tent_04_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
barber_tent_05_domicile_building_gold_cost_value = camp_building_upgrade_cost_t5_value
barber_tent_06_domicile_building_gold_cost_value = camp_building_upgrade_cost_t6_value
barber_tent_surgeons_tools_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
barber_tent_dentists_tools_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
barber_tent_torturers_tools_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
barber_tent_reference_corpus_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
barber_tent_morticians_tools_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
baggage_train_01_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
baggage_train_02_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
baggage_train_03_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
baggage_train_04_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
baggage_train_05_domicile_building_gold_cost_value = camp_building_upgrade_cost_t5_value
baggage_train_06_domicile_building_gold_cost_value = camp_building_upgrade_cost_t6_value
baggage_train_ample_steeds_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
baggage_train_porters_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
baggage_train_trackers_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
baggage_train_kennel_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
baggage_train_siege_engineers_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
baggage_train_shrine_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
baggage_train_scribes_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
baggage_train_bartering_grounds_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
baggage_train_proof_of_claims_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
baggage_train_ransom_cages_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
baggage_train_negotiators_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
baggage_train_ascetics_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
baggage_train_pleasure_tents_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
mess_tent_01_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
mess_tent_02_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
mess_tent_03_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
mess_tent_04_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
mess_tent_05_domicile_building_gold_cost_value = camp_building_upgrade_cost_t5_value
mess_tent_06_domicile_building_gold_cost_value = camp_building_upgrade_cost_t6_value
mess_tent_herbalists_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
mess_tent_brewers_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
mess_tent_curers_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
mess_tent_bakers_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
mess_tent_cooks_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
camp_fire_01_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_fire_02_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
camp_fire_03_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
camp_fire_04_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
camp_fire_05_domicile_building_gold_cost_value = camp_building_upgrade_cost_t5_value
camp_fire_06_domicile_building_gold_cost_value = camp_building_upgrade_cost_t6_value
camp_fire_trailing_musicians_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
camp_fire_wandering_poets_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
camp_fire_capering_fools_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_fire_libations_for_the_lost_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_fire_local_hangers_on_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_fire_future_dreams_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
camp_fire_nightly_debates_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
camp_fire_juicy_rumors_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
proving_grounds_01_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
proving_grounds_02_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
proving_grounds_03_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
proving_grounds_04_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
proving_grounds_05_domicile_building_gold_cost_value = camp_building_upgrade_cost_t5_value
proving_grounds_06_domicile_building_gold_cost_value = camp_building_upgrade_cost_t6_value
proving_grounds_horse_run_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
proving_grounds_camel_run_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
proving_grounds_elephantry_reserve_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
proving_grounds_nightly_barding_drills_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
proving_grounds_life_in_the_saddle_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
proving_grounds_the_stump_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
proving_grounds_personal_bouts_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
proving_grounds_training_circle_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
proving_grounds_mock_battle_drills_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
proving_grounds_lockwagon_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
proving_grounds_martial_study_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
proving_grounds_the_stick_game_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
proving_grounds_bodyguard_drills_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
camp_perimeter_01_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_perimeter_02_domicile_building_gold_cost_value = camp_building_upgrade_cost_t2_value
camp_perimeter_03_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
camp_perimeter_04_domicile_building_gold_cost_value = camp_building_upgrade_cost_t4_value
camp_perimeter_05_domicile_building_gold_cost_value = camp_building_upgrade_cost_t5_value
camp_perimeter_06_domicile_building_gold_cost_value = camp_building_upgrade_cost_t6_value
camp_perimeter_good_siting_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_perimeter_fixed_layout_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_perimeter_extra_watch_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_perimeter_palisade_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value
camp_perimeter_ditch_domicile_building_gold_cost_value = camp_building_upgrade_cost_t3_value
camp_perimeter_camp_hygiene_domicile_building_gold_cost_value = camp_building_upgrade_cost_t1_value

# Control weights for camp ai_will_do buildings.
## Base value.
camp_building_ai_base_t1 = 70
camp_building_ai_base_t2 = 80
camp_building_ai_base_t3 = 90
camp_building_ai_base_t4 = 100
### We use this for both highly useful buildings & for unique unlocks, so that camps prioritise stuff specific to their purpose.
camp_building_ai_base_t5 = 100
## Flavour bonuses.
camp_building_ai_bonus_t1 = 10
camp_building_ai_bonus_t2 = 20
camp_building_ai_bonus_t3 = 30
## Flavour penalties.
camp_building_ai_malus_t1 = -20
camp_building_ai_malus_t2 = -40
camp_building_ai_malus_t3 = -60
## Camp Purpose-specific bonuses.
camp_building_ai_camp_purpose_t1 = 20
camp_building_ai_camp_purpose_t2 = 40
camp_building_ai_camp_purpose_t3 = 60
## Try to pick matching upgrades depending on our lifestyle.
camp_building_ai_lifestyle_bias_value = 75

# Various camp ai_will_do building values.
camp_main_main_path_value = {
	value = camp_building_ai_base_t3
	# Traits.
	## ++ Arrogant.
	if = {
		limit = {
			owner = { has_trait = arrogant }
		}
		add = camp_building_ai_bonus_t2
	}
	## ++ Ambitious.
	if = {
		limit = {
			owner = { has_trait = ambitious }
		}
		add = camp_building_ai_bonus_t2
	}
	## - Content.
	if = {
		limit = {
			owner = { has_trait = content }
		}
		add = camp_building_ai_malus_t1
	}
	## -- Humble.
	if = {
		limit = {
			owner = { has_trait = humble }
		}
		add = camp_building_ai_malus_t2
	}
}
supply_tent_main_path_value = {
	value = camp_building_ai_base_t4
	# Traits.
	## +++ Logistician.
	if = {
		limit = {
			owner = { has_trait = logistician }
		}
		add = camp_building_ai_bonus_t3
	}
	## +++ Organiser.
	if = {
		limit = {
			owner = { has_trait = organizer }
		}
		add = camp_building_ai_bonus_t3
	}
	## + Patient
	if = {
		limit = {
			owner = { has_trait = patient }
		}
		add = camp_building_ai_bonus_t1
	}
	## + Diligent.
	if = {
		limit = {
			owner = { has_trait = diligent }
		}
		add = camp_building_ai_bonus_t1
	}
	## - Lazy.
	if = {
		limit = {
			owner = { has_trait = lazy }
		}
		add = camp_building_ai_malus_t1
	}
	# Camp Purpose.
	if = {
		limit = {
			owner = {
				OR = {
					has_realm_law_flag = unlocks_supply_tent_reserve_provisions
					has_realm_law_flag = unlocks_supply_tent_reserve_water
					has_realm_law_flag = unlocks_supply_tent_climbing_gear
					has_realm_law_flag = unlocks_supply_tent_subdued_gear
				}
			}
		}
		add = camp_building_ai_camp_purpose_t2
	}
}
barber_tent_main_path_value = {
	value = camp_building_ai_base_t2
	# Traits.
	## +++ Lifestyle Physician.
	if = {
		limit = {
			owner = { has_trait = lifestyle_physician }
		}
		add = camp_building_ai_bonus_t3
	}
	## ++ Whole of Body.
	if = {
		limit = {
			owner = { has_trait = whole_of_body }
		}
		add = camp_building_ai_bonus_t2
	}
	## + Gregarious.
	if = {
		limit = {
			owner = { has_trait = gregarious }
		}
		add = camp_building_ai_bonus_t1
	}
	## + Eccentric.
	if = {
		limit = {
			owner = { has_trait = eccentric }
		}
		add = camp_building_ai_bonus_t1
	}
	# Camp Purpose.
	if = {
		limit = {
			owner = {
				OR = {
					has_realm_law_flag = unlocks_barber_tent_reference_corpus
					has_realm_law_flag = unlocks_barber_tent_morticians_tools
				}
			}
		}
		add = camp_building_ai_camp_purpose_t1
	}
}
baggage_train_main_path_value = {
	value = camp_building_ai_base_t4
	# Traits.
	## +++ Logistician.
	if = {
		limit = {
			owner = { has_trait = logistician }
		}
		add = camp_building_ai_bonus_t3
	}
	## +++ Organiser.
	if = {
		limit = {
			owner = { has_trait = organizer }
		}
		add = camp_building_ai_bonus_t3
	}
	## ++ Gregarious.
	if = {
		limit = {
			owner = { has_trait = gregarious }
		}
		add = camp_building_ai_bonus_t2
	}
	## ++ Diligent.
	if = {
		limit = {
			owner = { has_trait = diligent }
		}
		add = camp_building_ai_bonus_t2
	}
	## - Lazy.
	if = {
		limit = {
			owner = { has_trait = lazy }
		}
		add = camp_building_ai_malus_t1
	}
	## -- Shy.
	if = {
		limit = {
			owner = { has_trait = shy }
		}
		add = camp_building_ai_malus_t2
	}
	# Camp Purpose.
	if = {
		limit = {
			owner = {
				OR = {
					has_realm_law_flag = unlocks_baggage_train_siege_engineers
					has_realm_law_flag = unlocks_baggage_train_scribes
					has_realm_law_flag = unlocks_baggage_train_proof_of_claims
					has_realm_law_flag = unlocks_baggage_train_ransom_cages
					has_realm_law_flag = unlocks_baggage_train_negotiators
					has_realm_law_flag = unlocks_baggage_train_ascetics
				}
			}
		}
		add = camp_building_ai_camp_purpose_t3
	}
}
mess_tent_main_path_value = {
	value = camp_building_ai_base_t2
	# Traits.
	## +++ Gluttonous.
	if = {
		limit = {
			owner = { has_trait = gluttonous }
		}
		add = camp_building_ai_bonus_t3
	}
	## + Greedy.
	if = {
		limit = {
			owner = { has_trait = greedy }
		}
		add = camp_building_ai_bonus_t1
	}
	## --- Temperate.
	if = {
		limit = {
			owner = { has_trait = temperate }
		}
		add = camp_building_ai_malus_t3
	}
}
camp_fire_main_path_value = {
	value = camp_building_ai_base_t3
	# Traits.
	## +++ Gregarious.
	if = {
		limit = {
			owner = { has_trait = gregarious }
		}
		add = camp_building_ai_bonus_t3
	}
	## ++ Humble.
	if = {
		limit = {
			owner = { has_trait = humble }
		}
		add = camp_building_ai_bonus_t2
	}
	## --- Arrogant.
	if = {
		limit = {
			owner = { has_trait = arrogant }
		}
		add = camp_building_ai_malus_t3
	}
	## --- Shy.
	if = {
		limit = {
			owner = { has_trait = shy }
		}
		add = camp_building_ai_malus_t3
	}
	# Camp Purpose.
	if = {
		limit = {
			owner = {
				OR = {
					has_realm_law_flag = unlocks_camp_fire_local_hangers_on
					has_realm_law_flag = unlocks_camp_fire_future_dreams
					has_realm_law_flag = unlocks_camp_fire_nightly_debates
					has_realm_law_flag = unlocks_camp_fire_juicy_rumors
				}
			}
		}
		add = camp_building_ai_camp_purpose_t3
	}
}
proving_grounds_main_path_value = {
	value = camp_building_ai_base_t3
	# Traits.
	## +++ Wrathful.
	if = {
		limit = {
			owner = { has_trait = wrathful }
		}
		add = camp_building_ai_bonus_t3
	}
	## +++ Athletic.
	if = {
		limit = {
			owner = { has_trait = athletic }
		}
		add = camp_building_ai_bonus_t3
	}
	## - Calm.
	if = {
		limit = {
			owner = { has_trait = calm }
		}
		add = camp_building_ai_malus_t1
	}
	# Camp Purpose.
	if = {
		limit = {
			owner = {
				OR = {
					has_realm_law_flag = unlocks_proving_grounds_lockwagon
					has_realm_law_flag = unlocks_proving_grounds_martial_study
					has_realm_law_flag = unlocks_proving_grounds_the_stick_game
					has_realm_law_flag = unlocks_proving_grounds_bodyguard_drills
				}
			}
		}
		add = camp_building_ai_camp_purpose_t3
	}
}
camp_perimeter_main_path_value = {
	value = camp_building_ai_base_t1
	# Traits.
	## +++ Paranoid.
	if = {
		limit = {
			owner = { has_trait = paranoid }
		}
		add = camp_building_ai_bonus_t3
	}
	## ++ Deceitful.
	if = {
		limit = {
			owner = { has_trait = deceitful }
		}
		add = camp_building_ai_bonus_t2
	}
	## - Honest.
	if = {
		limit = {
			owner = { has_trait = honest }
		}
		add = camp_building_ai_malus_t1
	}
	## --- Trusting.
	if = {
		limit = {
			owner = { has_trait = trusting }
		}
		add = camp_building_ai_malus_t3
	}
	# Camp Purpose.
	if = {
		limit = {
			owner = {
				OR = {
					has_realm_law_flag = unlocks_camp_perimeter_extra_watch
					has_realm_law_flag = unlocks_camp_perimeter_palisade
					has_realm_law_flag = unlocks_camp_perimeter_ditch
				}
			}
		}
		add = camp_building_ai_camp_purpose_t1
	}
}

##################################################
# Misc Values

prison_break_value = {
	value = 1
	if = {
		limit = {
			is_primary_heir_of = prev
		}
		add = 10
	}
	if = {
		limit = {
			this = prev.primary_spouse
		}
		add = 10
	}
}

# Powerful Family Rating
# House power score is used in code to enable bonuses from powerful houses
# root - house under evaluation
house_power_score = {
	value = {
		value = 0

		save_temporary_scope_as = target_house
		# Add a small amount of score for each house member within the realm (less for Japan)
		if = {
			limit = {
				exists = house_head
			}
			if = {
				limit = {
					house_head = { government_is_japanese_trigger = yes }
				}
				add = {
					every_house_member = {
						limit = { top_liege = scope:target_house.house_head.top_liege }
						add = 1.5
					}
					desc = members_in_realm_desc
				}
			}
			else = {
				add = {
					every_house_member = {
						limit = { top_liege = scope:target_house.house_head.top_liege }
						add = 3
					}
					desc = members_in_realm_desc
				}
			}

			# Add scoring based on the House Head's Level of Influence
			if = {
				limit = {
					house_head = {
						NOT = { government_has_flag = government_has_merit }
						influence_level >= 1
					}
				}
				add = {
					value = house_head.influence_level
					multiply = 5
					desc = house_head_influence_level_desc
				}
			}
			
			# Add scoring based on the House head's Merit Rank
			if = {
				limit = {
					house_head = {
						government_has_flag = government_has_merit
						merit_level >= 1
					}
				}
				add = {
					value = house_head.merit_level
					multiply = 5
					desc = house_head_merit_level_desc
				}
			}
			
			# House head is a movement leader
			if = {
				limit = {
					house_head = {
						any_character_situation = { situation_type = dynastic_cycle }
						is_any_movement_leader = yes
					}
				}
				add = {
					value = 10
					desc = house_head_is_movement_leader_desc
				}
			}

			# Add scoring for every house member on top liege's council - Higher for ministers
			if = {
				limit = {
					exists = house_head.top_liege
					house_head.top_liege = {
						any_councillor = {
							exists = house
							scope:target_house ?= house
						}
					}
				}
				add = {
					house_head.top_liege = {
						every_councillor = {
							limit = {
								exists = house
								scope:target_house ?= house
							}
							add = 15
						}
						if = {
							limit = {
								tgp_has_access_to_ministry_trigger = yes
							}
							multiply = 2
						}
					}
					desc = house_members_on_council_desc
				}
			}
			
			# A house member is the favored ministers
			if = {
				limit = {
					house_head.top_liege ?= {
						employs_court_position = favored_minister_court_position
						court_position:favored_minister_court_position = {
							house ?= scope:target_house
						}
					}
				}
				add = {
					value = 10
					desc = house_member_is_favored_minister_desc
				}
			}

			# Malus for not practicing the state faith
			if = {
				limit = {
					house_head.top_liege ?= { government_allows = state_faith }
					NOT = { house_head.top_liege.primary_title.state_faith ?= scope:target_house.house_head.faith }
				}
				add = {
					value = -25
					desc = house_head_different_faith_powerful_family_rating
				}
			}

			# Estate building bonuses
			if = { # Market
				limit = {
					house_head.domicile ?= { has_domicile_parameter = estate_increase_powerful_family_rating_6 }
				}
				add = {
					value = estate_powerful_family_rating_6_value
					desc = estate_buildings_desc
				}
			}
			else_if = {
				limit = {
					house_head.domicile ?= { has_domicile_parameter = estate_increase_powerful_family_rating_5 }
				}
				add = {
					value = estate_powerful_family_rating_5_value
					desc = estate_buildings_desc
				}
			}
			else_if = {
				limit = {
					house_head.domicile ?= { has_domicile_parameter = estate_increase_powerful_family_rating_4 }
				}
				add = {
					value = estate_powerful_family_rating_4_value
					desc = estate_buildings_desc
				}
			}
			else_if = {
				limit = {
					house_head.domicile ?= { has_domicile_parameter = estate_increase_powerful_family_rating_3 }
				}
				add = {
					value = estate_powerful_family_rating_3_value
					desc = estate_buildings_desc
				}
			}
			else_if = {
				limit = {
					house_head.domicile ?= { has_domicile_parameter = estate_increase_powerful_family_rating_2 }
				}
				add = {
					value = estate_powerful_family_rating_2_value
					desc = estate_buildings_desc
				}
			}
			else_if = {
				limit = {
					house_head.domicile ?= { has_domicile_parameter = estate_increase_powerful_family_rating }
				}
				add = {
					value = estate_powerful_family_rating_1_value
					desc = estate_buildings_desc
				}
			}
			if = { # Catacombs
				limit = {
					exists = house_head.dynasty
					house_head.domicile ?= { has_domicile_parameter = estate_powerful_family_rating_per_dynasty_level }
				}
				add = {
					value = estate_increase_powerful_famil_rating_per_dynasty_level_value
					multiply = house_head.dynasty.dynasty_prestige_level
					desc = estate_buildings_desc
				}
			}

			# When your estate is located in the realm's capital
			if = {
				limit = {
					house_head = {
						exists = top_liege.capital_province
						domicile ?= {
							is_domicile_type = estate
							domicile_location = prev.top_liege.capital_province
						}
					}
				}
				add = {
					value = 10
					desc = estate_in_capital_desc
				}
			}

			# Obligation/Theme Administration bonus
			if = {
				limit = {
					house_head = { vassal_contract_has_flag = admin_prestige_obligation_bonus }
				}
				add = {
					value = 10
					desc = imperial_theme_type_desc
				}
			}

			# Heart of the Family Diplomacy Lifestyle Perk
			if = {
				limit = { house_head = { has_perk = familial_familiar_perk } }
				add = {
					value = 10
					desc = familial_familiar_perk_name
				}
			}

			# Base score increase from Power is a Ladder dynasty legacy perk
			if = {
				limit = {
					house_head.dynasty ?= { ep3_administrative_legacy_track_perks >= 3 }
				}
				add = {
					value = 15
					desc = house_power_ep3_administrative_legacy_3
				}
			}

			# Merit Dynasty Legacy Perk
			if = {
				limit = {
					house_head.dynasty ?= { has_dynasty_perk = tgp_chinese_legacy_4 }
				}
				add = {
					value = 15
					desc = movement_power_chinese_legacy_4
				}
			}

			# From Mass Arrests Decision
			if = {
				limit = { house_head = { has_character_flag = mass_arrests_house_power_malus } }
				add = {
					value = -15
					desc = ep3_mass_arrests_house_power_malus
				}
			}

			if = {
				limit = { house_head.confederation ?= { leading_house ?= scope:target_house } }
				add = {
					value = 0
					house_head.confederation = {
						every_confederation_member_house = { add = 10 }
					}
					desc = led_bloc_size_desc
				}
			}

			# The number of governorships the house holds
			multiply = {
				value = 1
				every_house_member = {
					limit = {
						# Using the triggers of is_governor directly to save performance
						is_landed = yes
						government_allows = administrative
						top_liege != this
						highest_held_title_tier >= main_administrative_tier
						house.house_head.top_liege ?= top_liege
					}
					add = 0.4 # Let's add a multiplier to the overall score for each governorship
				}
				desc = held_governoships_desc
			}

			# Bonus for being the Ceremonial house
			if = {
				limit = { house_head = { tgp_is_in_ceremonial_house_trigger = yes } }
				add = {
					value = 100
					desc = tgp_ceremonial_house_desc
				}
			}

			# Bonus for being the imperial house (we deliberately but this at the end, behind the governorship multiplier, as an added bonus on top of everything else)
			if = {
				limit = {
					any_house_member = {
						top_liege = this
						#primary_title.tier >= tier_empire (this is commented out because the house in power should always get this big boost)
						house.house_head.top_liege ?= top_liege
					}
				}
				add = {
					value = 100
					if = {
						limit = {
							any_house_member = {
								top_liege = this
								primary_title.tier < tier_empire
								house.house_head.top_liege ?= top_liege
							}
						}
						subtract = 50 #For Kings and below the bonus is not quite as high - they are not a far ahead of everyone else as an emperor
					}
					desc = imperial_house_desc
				}
			}

			# Status Challenged
			if = {
				limit = { has_variable_list = status_challenged_by }
				save_temporary_value_as = temp_total
				subtract = {
					value = scope:temp_total
					multiply = {
						value = 0.05
						multiply = {
							value = 0
							every_in_list = {
								variable = status_challenged_by
								add = 1
							}
						}
					}
					desc = challenge_status_powerful_family_rating_modifier
				}
			}
		}
		else = {
			add = {
				value = -100
				desc = house_is_lowborn_desc
			}
		}
	}

	round = yes
}

# Maximum investment a character can make to support a candidate for a title appointment
# root - investor
appointment_investment_cap = {
	value = {
		add = {
			value = 50 # Base
			desc = BASE_VALUE
		}
		##### FAMILY RATING
		if = {
			limit = { house.house_head ?= this }
			add = {
				value = house.house_power_score
				desc = appointment_investment_cap_family_rating
			}
		}
		##### AGE
		if = { # ADULT - scaling bonus
			limit = { is_adult = yes }
			add = {
				value = {
					add = age
					subtract = 16
					divide = 2
					ceiling = yes
				}
				desc = appointment_investment_cap_age
			}
		}
		else = { # CHILD - scaling malus
			add = {
				value = {
					add = age
					subtract = 16
					divide = 2
					floor = yes
				}
				desc = appointment_investment_cap_age
			}
		}
		##### INFLUENCE LEVEL
		if = { # NEGATIVE
			limit = { influence_level < 1 }
			add = {
				value = -20
				desc = appointment_investment_cap_influence_level
			}
		}
		else_if = { # POSITIVE
			limit = { influence_level > 1 }
			add = {
				value = {
					add = influence_level
					multiply = 10
				}
				desc = appointment_investment_cap_influence_level
			}
		}
		##### ESTATE BUILDINGS
		if = {
			limit = { exists = house.house_head.domicile }
			house.house_head.domicile = {
				add = {
					value = 0
					if = {
						limit = { has_domicile_building = estate_main_02 }
						add = 10
					}
					else_if = {
						limit = { has_domicile_building = estate_main_03 }
						add = 20
					}
					else_if = {
						limit = { has_domicile_building = estate_main_04 }
						add = 30
					}
					else_if = {
						limit = { has_domicile_building = estate_main_05 }
						add = 40
					}
					if = {
						limit = { has_domicile_building = reception_hall_02 }
						add = 10
					}
					else_if = {
						limit = { has_domicile_building = reception_hall_03 }
						add = 20
					}
					else_if = {
						limit = { has_domicile_building = reception_hall_04 }
						add = 30
					}
					else_if = {
						limit = { has_domicile_building = reception_hall_05 }
						add = 40
					}
					if = {
						limit = { has_domicile_building = japanese_manor_office_01 }
						add = 5
					}
					else_if = {
						limit = { has_domicile_building = japanese_manor_office_02 }
						add = 10
					}
					else_if = {
						limit = { has_domicile_building = japanese_manor_office_03 }
						add = 15
					}
					else_if = {
						limit = { has_domicile_building = japanese_manor_office_04 }
						add = 20
					}
					else_if = {
						limit = { has_domicile_building = japanese_manor_office_05 }
						add = 25
					}
					else_if = {
						limit = { has_domicile_building = japanese_manor_office_06 }
						add = 30
					}
					desc = appointment_investment_cap_estate_buildings
				}
			}
		}
		##### FAMILY ATTRIBUTES
		house ?= {
			add = {
				value = 0
				if = {
					limit = { has_house_power_parameter = increased_investment_cap_bonus_3 }
					add = increased_investment_cap_bonus_3_value
				}
				else_if = {
					limit = { has_house_power_parameter = increased_investment_cap_bonus_2 }
					add = increased_investment_cap_bonus_2_value
				}
				else_if = {
					limit = { has_house_power_parameter = increased_investment_cap_bonus_1 }
					add = increased_investment_cap_bonus_1_value
				}
				desc = political_meddlers_attribute_name_desc
			}
		}
		##### EXPANDED POWER BASE
		save_temporary_value_as = temp_total
		if = {
			limit = { has_character_modifier = ep3_expanded_power_base_minor_modifier }
			add = {
				value = scope:temp_total
				multiply = 0.10
				round = yes
				min = 25
				desc = ep3_expanded_power_base_minor_modifier
			}
		}
		if = {
			limit = { has_character_modifier = ep3_expanded_power_base_medium_modifier }
			add = {
				value = scope:temp_total
				multiply = 0.20
				round = yes
				min = 50
				desc = ep3_expanded_power_base_medium_modifier
			}
		}
		if = {
			limit = { has_character_modifier = ep3_expanded_power_base_major_modifier }
			add = {
				value = scope:temp_total
				multiply = 0.30
				round = yes
				min = 75
				desc = ep3_expanded_power_base_major_modifier
			}
		}
		##### MERIT
		if = {
			limit = { merit_level >= 1 }
			add = {
				value = {
					add = merit_level
					multiply = 5
				}
				desc = "[merit_level|E]"
			}
		}
		##### CELESTIAL MINISTER
		if = {
			limit = {
				is_councillor = yes
				liege ?= {
					tgp_has_access_to_ministry_trigger = yes
				}
			}
			add = {
				value = 10
				desc = is_a_minister_desc
			}
		}
		min = 0
	}
}

dominant_family_threshold_value = 0.25

ep3_governor_yearly_8150_total_count_value = {
	value = 0
	every_in_list = {
		list = rebel_counties
		add = 1
	}
	every_in_list = {
		list = potential_rebel_counties
		add = 1
	}
}

#special bonus to traveling friends from a court event
court_position_aptitude_traveling_friends_value = {
	if = {
		limit = {
			has_character_flag = travelling_friend
			liege ?= {
				any_court_position_holder = {
					OR = {
						has_relation_best_friend = root
						has_relation_friend = root
					}
					has_character_flag = travelling_friend
				}
			}
		}
		add = {
			value = 20
			desc = court_position_traveling_friend
		}
	}
}

ep3_foreign_ruler_interest_in_coup_value = {
	value = 0
	every_claim = {
		limit = {
			any_de_jure_top_liege = {
				this = scope:target_char
			}
		}
		add = 1
	}
	if = {
		limit = { has_relation_nemesis = scope:target_char }
		add = 2
	}
	else_if = {
		limit = { has_relation_rival = scope:target_char }
		add = 1
	}
}

ep3_distance_to_comparator_claim = {
	value = 0
	add = "title_capital_county.squared_distance(scope:comparator.capital_county)"
	abs = yes
	multiply = -1
}

ep3_distance_to_comparator_capital_county = {
	value = 0
	add = "squared_distance(scope:comparator.capital_county)"
	abs = yes
	multiply = -1
}

number_of_granaries_in_egypt_value = {
	value = 0
	every_county_in_region = {
		region = custom_roman_aegyptus
		limit = {
			any_county_province = {
				has_building_or_higher = cereal_fields_05
			}
		}
		add = 1
		max = 10
	}
	min = 1
	desc = MODIFIER_DEFINITION_MAIN_DESC_PER_EGYPT_GRANARY
}

grain_dole_cost = {
	value = 1500
}

pay_off_crusaders_value = {
	value = 0
	every_in_list = {
		list = paying_off_crusaders
		add = 1
	}
	multiply = 150
}

ep3_byz_regiments_gained_value = {
	value = 1
	if = {
		limit = {
			exists = scope:regiment_1
			highest_held_title_tier >= tier_kingdom
		}
		add = 1
	}
	if = {
		limit = {
			exists = scope:regiment_2
			OR = {
				highest_held_title_tier >= tier_duchy
				this = scope:attacker
			}
		}
		add = 1
	}
}

ep3_byz_regiments_ck_value = {
	value = 0
	if = {
		limit = {
			exists = scope:regiment_1
		}
		add = 2
	}
	if = {
		limit = {
			exists = scope:regiment_2
		}
		add = 3
	}
}

ep3_byz_reward_levy_size_value = {
	value = 100
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 5
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 10
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 15
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 20
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 25
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 30
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 35
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 40
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 50
			}
		}
		add = 150
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 65
			}
		}
		add = 200
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 80
			}
		}
		add = 250
	}
	if = {
		limit = {
			highest_held_title_tier = tier_duchy
		}
		multiply = 1.33
	}
	if = {
		limit = {
			highest_held_title_tier >= tier_kingdom
		}
		multiply = 1.66
	}
}

ep3_sacking_byz_capital_payoff_value = {
	value = 220

	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 5
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 10
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 15
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 20
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 25
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 30
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 35
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 40
			}
		}
		add = 100
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 50
			}
		}
		add = 150
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 65
			}
		}
		add = 200
	}
	if = {
		limit = {
			title:e_byzantium.holder.capital_county = {
				development_level >= 80
			}
		}
		add = 250
	}
}

number_vassals_converting_to_new_state_faith = {
	value = 0
	every_vassal = {
		limit = {
			opinion = {
				target = root
				value >= 30
			}
			faith != root.faith
			NOT = { has_vassal_stance = zealot }
			is_ai = yes
		}
		add = 1
	}
}

# Hasan Sabbah event troops

hasan_sabbah_max_levies_value = 20000

hasan_sabbah_event_troops_value = {
	value = 0

	# Add troops for each appropriate county.
	root.location.county.holder.top_liege = {
		every_sub_realm_county = {
			limit = {
				faith = root.faith
			}
			add = 500
		}
	}

	max = {
		# Standard base max.
		value = hasan_sabbah_max_levies_value
	}
	divide = 5
}

maa_regiments_cost_more_to_reinforce_per_soldier_trigger_mult = 4

provision_refill_value = {
	value = 0.125
	if = {
		limit = {
			trigger_if = {
				limit = { exists = scope:laamp_temp }
				scope:laamp_temp = { has_perk = prepared_conscription_perk }
			}
			trigger_else = { always = no }
		}
		multiply = 1.25
	}
	if = {
		limit = {
			scope:laamp_temp ?= {
				has_perk = personal_touch_perk
				landless_inspector_king_of_the_wilds = yes
			}
		}
		multiply = 1.25
	}
	if = {
		limit = {
			scope:laamp_temp ?= {
				is_ai = no
				has_game_rule = hard_difficulty
			}
		}
		multiply = 0.5
	}
	else_if = {
		limit = {
			scope:laamp_temp ?= {
				is_ai = no
				has_game_rule = very_hard_difficulty
			}
		}
		multiply = 0.2
	}
}

provision_refill_value_tt = {
	value = 0.125
	if = {
		limit = { has_perk = prepared_conscription_perk }
		multiply = 1.25
	}
	if = {
		limit = {
			has_perk = personal_touch_perk
			landless_inspector_king_of_the_wilds = yes
		}
		multiply = 1.25
	}
	if = {
		limit = {
			is_ai = no
			has_game_rule = hard_difficulty
		}
		multiply = 0.5
	}
	else_if = {
		limit = {
			is_ai = no
			has_game_rule = very_hard_difficulty
		}
		multiply = 0.2
	}
}

gold_refill_value = {
	value = 3
	if = {
		limit = {
			scope:laamp_temp = { has_perk = cutting_corners_perk }
		}
		multiply = 1.25
	}
	if = {
		limit = {
			scope:laamp_temp ?= {
				has_perk = personal_touch_perk
				landless_inspector_king_of_the_wilds = yes
			}
		}
		multiply = 1.25
	}
	if = {
		limit = {
			scope:laamp_temp ?= {
				government_has_flag = government_is_nomadic
			}
		}
		multiply = 1.5
	}
	if = {
		limit = {
			scope:laamp_temp ?= {
				is_ai = no
				has_game_rule = hard_difficulty
			}
		}
		multiply = 0.5
	}
	else_if = {
		limit = {
			scope:laamp_temp ?= {
				is_ai = no
				has_game_rule = very_hard_difficulty
			}
		}
		multiply = 0.2
	}
	if = {
		limit = {
			trigger_if = {
				limit = { exists = scope:laamp_temp }
				scope:laamp_temp = { government_has_flag = government_is_nomadic }
			}
			trigger_else = { always = no }
		}
		multiply = {
			add = scope:laamp_temp.martial
			subtract = 8
			divide = 100
			add = 1
		}
	}
}

gold_refill_value_tt = {
	value = 2
	if = {
		limit = {
			has_perk = cutting_corners_perk
		}
		multiply = 1.25
	}
	if = {
		limit = {
			has_perk = personal_touch_perk
			landless_inspector_king_of_the_wilds = yes
		}
		multiply = 1.25
	}
	if = {
		limit = {
			government_has_flag = government_is_nomadic
		}
		multiply = 1.5
	}
	if = {
		limit = {
			is_ai = no
			has_game_rule = hard_difficulty
		}
		multiply = 0.5
	}
	else_if = {
		limit = {
			is_ai = no
			has_game_rule = very_hard_difficulty
		}
		multiply = 0.2
	}
	if = {
		limit = {
			government_has_flag = government_is_nomadic
		}
		multiply = {
			add = martial
			subtract = 8
			divide = 100
			add = 1
		}
	}
}

replenishable_troops_value = {
	value = maa_max_troops_count
	subtract = maa_current_troops_count
	if = {
		limit = { maa_regiments_cost_more_to_reinforce_per_soldier_trigger = yes }
		multiply = maa_regiments_cost_more_to_reinforce_per_soldier_trigger_mult
	}
}

replenishable_troops_with_provisions_value = {
	value = replenishable_troops_value
	max = {
		add = scope:current_provisions_max_value_scope
		multiply = provision_refill_value
	}
}

replenishable_troops_with_gold_value = {
	value = replenishable_troops_value
	max = {
		add = scope:current_gold_max_value_scope
		multiply = gold_refill_value
	}
}

replenishable_troops_max_provisions_value = {
	value = 0
	scope:actor = {
		every_maa_regiment = {
			add = {
				add = maa_max_troops_count
				subtract = maa_current_troops_count
				if = {
					limit = { maa_regiments_cost_more_to_reinforce_per_soldier_trigger = yes }
					multiply = maa_regiments_cost_more_to_reinforce_per_soldier_trigger_mult
				}
			}
		}
	}
	max = scope:actor.domicile.provisions
	divide = provision_refill_value
	multiply = -1
}

replenishable_troops_payed_provisions_tt_value = {
	value = 0
	every_maa_regiment = {
		add = {
			add = maa_max_troops_count
			subtract = maa_current_troops_count
			if = {
				limit = { maa_regiments_cost_more_to_reinforce_per_soldier_trigger = yes }
				multiply = maa_regiments_cost_more_to_reinforce_per_soldier_trigger_mult
			}
		}
	}
	divide = provision_refill_value_tt
	max = domicile.provisions
}

replenishable_troops_max_provisions_tt_value = {
	value = 0
	every_maa_regiment = {
		add = {
			add = maa_max_troops_count
			subtract = maa_current_troops_count
		}
	}
	max = {
		value = domicile.provisions
		multiply = provision_refill_value_tt
	}
}

replenishable_troops_payed_gold_tt_value = {
	value = 0
	every_maa_regiment = {
		add = {
			add = maa_max_troops_count
			subtract = maa_current_troops_count
			if = {
				limit = { maa_regiments_cost_more_to_reinforce_per_soldier_trigger = yes }
				multiply = maa_regiments_cost_more_to_reinforce_per_soldier_trigger_mult
			}
		}
	}
	divide = gold_refill_value_tt
	max = gold
}

replenishable_troops_max_gold_tt_value = {
	value = 0
	every_maa_regiment = {
		add = {
			add = maa_max_troops_count
			subtract = maa_current_troops_count
			if = {
				limit = { maa_regiments_cost_more_to_reinforce_per_soldier_trigger = yes }
				multiply = maa_regiments_cost_more_to_reinforce_per_soldier_trigger_mult
			}
		}
	}
	max = {
		value = gold
		multiply = gold_refill_value_tt
	}
}

replenishable_troops_provision_cost_value = {
	value = scope:actor.replenishable_troops_value
	max = scope:actor.domicile.max_provisions
	multiply = -1
}

reinforce_soldiers_regiment_soldiers_value = {
	value = reinforce_soldiers_regiment_max_value
	min = 1
	max = reinforce_soldiers_max_value
}

reinforce_soldiers_regiment_max_value = {
	value = 25
	if = {
		limit = {
			scope:actor = { has_perk = soldiers_of_lesser_fortune_perk }
		}
		multiply = 4
	}
}

reinforce_soldiers_regiment_max_value_tooltip = {
	value = 25
	if = {
		limit = {
			has_perk = soldiers_of_lesser_fortune_perk
		}
		multiply = 4
	}
}

reinforce_soldiers_max_value = {
	value = maa_max_troops_count
	subtract = maa_current_troops_count
}

reinforce_soldiers_reinforcable_regiments_value = {
	value = 0
	every_maa_regiment = {
		limit = { maa_current_troops_count < maa_max_troops_count }
		# Cheaper cavalry
		if = {
			limit = {
				OR = {
					is_unit_type = light_cavalry
					is_unit_type = heavy_cavalry
				}
				regiment_owner.domicile ?= { has_domicile_parameter = camp_cheaper_cavalry_reinforcement }
			}
			add = 0.5
		}
		else = { add = 1 }
	}
	min = 0.5
}

reinforce_soldiers_reinforcable_regiments_undiscounted_value = {
	value = 0
	every_maa_regiment = {
		limit = { maa_current_troops_count < maa_max_troops_count }
		add = 1
	}
	min = 1
}

reinforce_soldiers_gold_value = {
	value = minor_gold_value
	if = {
		limit = {
			domicile ?= { has_domicile_parameter = camp_improved_reinforcement_from_gold }
		}
		multiply = 0.5
	}
	multiply = reinforce_soldiers_reinforcable_regiments_value
}

reinforce_soldiers_dread_cost_value = {
	value = 5
	if = {
		limit = {
			scope:actor.domicile = { has_domicile_parameter = camp_improved_entice_local_mercenaries }
		}
		add = -2.5
	}
	multiply = reinforce_soldiers_reinforcable_regiments_value
}

small_empire_size_value = 75
large_empire_size_value = 125

current_size_empire_value = { add = root.realm_size }

laamp_improved_learning_contract_success_value = 20 # Update parameter tooltip if this is changed!

laamp_improved_tracker_contract_success_value = 20 # Update parameter tooltip if this is changed!

# Currently this define is set to 100, so adjust with that in mind.
provisions_privation_threshold_start = { value = define:NCharacter|PROVISIONS_LOW_WARNING }
provisions_privation_threshold_low = 66
provisions_privation_threshold_very_low = 33
provisions_privation_threshold_empty = 0

gather_provisions_forage_base_value = {
	# TERRAIN
	if = {
		limit = {
			OR = {
				terrain = desert
				terrain = desert_mountains
				terrain = taiga
			}
		}
		add = 100
	}
	else_if = {
		limit = {
			NOT = {
				root = { has_perk = golden_aplomb_perk }
			}
			OR = {
				terrain = drylands
				terrain = jungle
				terrain = mountains
				terrain = wetlands
				terrain = steppe
			}
		}
		add = 250
	}
	else = { add = 500 }
	# BUILDINGS
	if = {
		limit = { has_building_or_higher = pastures_01 }
		add = 25
	}
	if = {
		limit = { has_building_or_higher = orchards_01 }
		add = 25
	}
	if = {
		limit = { has_building_or_higher = farm_estates_01 }
		add = 25
	}
	if = {
		limit = { has_building_or_higher = cereal_fields_01 }
		add = 25
	}
	if = {
		limit = { has_building_or_higher = plantations_01 }
		add = 25
	}
	if = {
		limit = { has_building_or_higher = hill_farms_01 }
		add = 25
	}
	# WINTER
	if = {
		limit = { has_province_modifier = winter_mild_modifier }
		add = -50
	}
	else_if = {
		limit = { has_province_modifier = winter_normal_modifier }
		add = -100
	}
	else_if = {
		limit = { has_province_modifier = winter_harsh_modifier }
		add = -150
	}
	min = 50
	# We deliberately apply this after the min, since it's a global boost.
	if = {
		limit = {
			root.domicile = { has_domicile_parameter = camp_improves_gather_provisions_hunting }
		}
		multiply = camp_improves_gather_provisions_hunting_value
	}
	if = {
		limit = {
			root = { has_perk = it_is_my_domain_perk }
		}
		multiply = 1.25
	}
	if = { # Inspector Lifestyle Perk
		limit = {
			landless_inspector_terrain_knowing_the_land_trigger = yes
			root = { has_perk = know_your_land_know_your_people_perk }
		}
		multiply = 1.5
	}
}
# Parameter improvements from camp buildings.
camp_improves_gather_provisions_hunting_value = 1.5
camp_improves_gather_provisions_hunting_loc_value = {
	value = camp_improves_gather_provisions_hunting_value
	add = -1
}

gather_provisions_hunt_base_value = {
	value = 50
	# TERRAIN
	if = {
		limit = {
			OR = {
				terrain = farmlands
				terrain = floodplains
				terrain = wetlands
			}
		}
		add = 100
	}
	else_if = {
		limit = {
			NOT = {
				root = { has_perk = golden_aplomb_perk }
			}
			OR = {
				terrain = desert
				terrain = desert_mountains
				terrain = mountains
				terrain = taiga
				terrain = steppe
			}
		}
		add = 250
	}
	else = { add = 500 }
	# HOLDING
	if = {
		limit = { has_holding = no }
		add = 50
	}
	# BUILDINGS
	if = {
		limit = { has_building_or_higher = hunting_grounds_01 }
		add = 50
	}
	if = {
		limit = { has_building_or_higher = royal_forest_01 }
		add = 100
	}
	min = 5
	# We deliberately apply this after the min, since it's a global boost.
	if = {
		limit = {
			root.domicile = { has_domicile_parameter = camp_improves_gather_provisions_foraging }
		}
		multiply = camp_improves_gather_provisions_foraging_value
	}
	if = {
		limit = {
			root = { has_perk = it_is_my_domain_perk }
		}
		multiply = 1.25
	}
}
# Parameter improvements from camp buildings.
camp_improves_gather_provisions_foraging_value = 1.5
camp_improves_gather_provisions_foraging_loc_value = {
	value = camp_improves_gather_provisions_foraging_value
	add = -1
}

provisions_low_value = 10

adventurers_make_local_deals_option_value = {
	value = 0
	if = {
		limit = { root.current_travel_plan.current_location.available_loot > 0 }
		add = root.current_travel_plan.current_location.available_loot
		divide = 4
	}
}

strong_governor_military_value = {
	value = 0
	add = scope:emperor.max_military_strength
	multiply = 0.2
}

ep3_emperors_war_strength_value = {
	value = 0
	if = {
		limit = {
			scope:emperor = {
				is_defender_in_war = scope:war
			}
		}
		scope:war = {
			every_war_defender = {
				add = current_military_strength
			}
		}
	}
	else = {
		scope:war = {
			every_war_attacker = {
				add = current_military_strength
			}
		}
	}
}

ep3_emperors_war_strength_double_value = {
	value = 0
	if = {
		limit = {
			scope:emperor = {
				is_defender_in_war = scope:war
			}
		}
		scope:war = {
			every_war_defender = {
				add = current_military_strength
			}
		}
	}
	else = {
		scope:war = {
			every_war_attacker = {
				add = current_military_strength
			}
		}
	}
	multiply = 2
}

ep3_emperors_foe_war_strength_value = {
	value = 0
	if = {
		limit = {
			scope:emperor = {
				is_defender_in_war = scope:war
			}
		}
		scope:war = {
			every_war_attacker = {
				add = current_military_strength
			}
		}
	}
	else = {
		scope:war = {
			every_war_defender = {
				add = current_military_strength
			}
		}
	}
}

ep3_emperors_foe_war_strength_double_value = {
	value = 0
	if = {
		limit = {
			scope:emperor = {
				is_defender_in_war = scope:war
			}
		}
		scope:war = {
			every_war_attacker = {
				add = current_military_strength
			}
		}
	}
	else = {
		scope:war = {
			every_war_defender = {
				add = current_military_strength
			}
		}
	}
	multiply = 2
}

ep3_governor_yearly_3050_regiment_size_value = {
	value = 0
	scope:regiment = {
		add = maa_size
	}
}

provisions_threshold_critical_low_value = { value = define:NCharacter|PROVISIONS_LOW_WARNING } #Will literally throw a warning in the UI if provisions go beneath this

provisions_threshold_low_value = {
	value = max_provisions
	multiply = 0.2
}
provisions_threshold_mid_value = {
	value = max_provisions
	multiply = 0.5
}
provisions_threshold_good_value = {
	value = max_provisions
	multiply = 0.8
}

ep3_legacy_domicile_artifact_counter_illustrious_score = {
	value = var:ep3_legacy_domicile_artifact_counter_illustrious
	multiply = 4
}
ep3_legacy_domicile_artifact_counter_famed_score = {
	value = var:ep3_legacy_domicile_artifact_counter_famed
	multiply = 3
}
ep3_legacy_domicile_artifact_counter_masterwork_score = {
	value = var:ep3_legacy_domicile_artifact_counter_masterwork
	multiply = 2
}
ep3_legacy_domicile_artifact_counter_common_score = {
	value = var:ep3_legacy_domicile_artifact_counter_common
	multiply = 1
}
cabinet_of_curiosities_artifact_score = {
	value = 0
	if = {
		limit = { has_variable = ep3_legacy_domicile_artifact_counter_illustrious }
		add = ep3_legacy_domicile_artifact_counter_illustrious_score
	}
	if = {
		limit = { has_variable = ep3_legacy_domicile_artifact_counter_famed }
		add = ep3_legacy_domicile_artifact_counter_famed_score
	}
	if = {
		limit = { has_variable = ep3_legacy_domicile_artifact_counter_masterwork }
		add = ep3_legacy_domicile_artifact_counter_masterwork_score
	}
	if = {
		limit = { has_variable = ep3_legacy_domicile_artifact_counter_common }
		add = ep3_legacy_domicile_artifact_counter_common_score
	}
}

latin_emp_army_levies_value = {
	value = 100
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_early_medieval
			}
		}
		add = 100
	}
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_high_medieval
			}
		}
		add = 200
	}
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_late_medieval
			}
		}
		add = 200
	}
}

latin_emp_army_maa_value = {
	value = 1
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_early_medieval
			}
		}
		add = 1
	}
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_high_medieval
			}
		}
		add = 1
	}
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_late_medieval
			}
		}
		add = 1
	}
}

boost_efficiency_maximum_value = 40
damage_efficiency_minimum_value = -40
efficiency_interaction_cooldown_years_value = 5
efficiency_interaction_change_value = 4

ep3_governor_yearly_3070_governorship_value = {
	value = 0
	every_sub_realm_county = {
		add = 1
	}
}

ep3_found_despotate_control_total_value = {
	value = 0
	primary_title.kingdom = {
		every_de_jure_county = { add = 1 }
	}
}

ep3_found_despotate_control_held_value = {
	value = 0
	save_temporary_scope_as = holder_temp
	primary_title.kingdom = {
		every_de_jure_county = {
			limit = {
				county_held_or_vassal_to_target_trigger = { TARGET = scope:holder_temp }
			}
			add = 1
		}
	}
}

ep3_found_despotate_control_percent_value = {
	value = ep3_found_despotate_control_held_value
	divide = ep3_found_despotate_control_total_value
	multiply = 100
}

military_strength_25_percent_value = {
	value = current_military_strength
	multiply = 0.25
}

military_strength_75_percent_value = {
	value = current_military_strength
	multiply = 0.75
}

number_of_counties_with_heresy_1 = {
	value = 0
	top_liege = {
		every_realm_county = {
			limit = {
				faith = scope:heresy_1
			}
			add = 1
		}
	}
}

number_of_counties_with_heresy_2 = {
	value = 0
	top_liege = {
		every_realm_county = {
			limit = {
				faith = scope:heresy_2
			}
			add = 1
		}
	}
}

number_of_counties_with_heresy_3 = {
	value = 0
	top_liege = {
		every_realm_county = {
			limit = {
				faith = scope:heresy_3
			}
			add = 1
		}
	}
}

number_of_counties_with_heresy_acceptance = {
	value = 0
	every_realm_county = {
		limit = {
			faith = scope:heresy
		}
		add = 10
	}
}

number_of_vassals_with_heresy_acceptance = {
	value = 0
	every_vassal = {
		limit = {
			faith = scope:heresy
		}
		add = 5
	}
}

influence_difference_value = {
	value = scope:heretic.influence
	subtract = root.influence
	multiply = 0.1
}

architect_aptitude_scale_value = {
	value = 1
	multiply = root.court_position:royal_architect_court_position.aptitude:royal_architect_court_position
}

ep3_actor_governor_trait_level_value = {
	value = -1
	scope:actor ?= {
		if = {
			limit = { has_trait = governor }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 25 } }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 50 } }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 75 } }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 100 } }
			add = 1
		}
	}
}

ep3_recipient_governor_trait_level_value = {
	value = -1
	scope:recipient ?= {
		if = {
			limit = { has_trait = governor }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 25 } }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 50 } }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 75 } }
			add = 1
		}
		if = {
			limit = { has_trait_xp = { trait = governor value >= 100 } }
			add = 1
		}
	}
}

ep3_actor_recipient_governor_trait_level_diff_value = {
	value = ep3_actor_governor_trait_level_value
	subtract = ep3_recipient_governor_trait_level_value
}

event_troops_ep3_separatist_scale_value = {
	value = 100
	multiply = {
		value = root.location.duchy.holder.primary_title.tier
	}
}

hostile_scheme_variable_list_value = {
	value = 0
	scope:owner = {
		every_in_list = {
			variable = supporting_hostile_schemes
			add = 5
		}
	}
}



personal_scheme_variable_list_value = {
	value = 0
	scope:owner = {
		every_in_list = {
			variable = supporting_personal_schemes
			add = 5
		}
	}
}

political_scheme_variable_list_value = {
	value = 0
	scope:owner = {
		every_in_list = {
			variable = supporting_political_schemes
			add = 5
		}
	}
}

hostile_scheme_base_bonus_per_character = 5
personal_scheme_base_bonus_per_character = 5
political_scheme_base_bonus_per_character = 5

# Laamps above this count must be exceptional characters or of interest to the player.
## This is because there are various things they do that are _fairly_ unperformant, so it's important that we put a good soft-cap on their numbers to stop them growing out of control and tanking performance.
### Code decisions were made assuming that there would be _maybe_ 200 on the map in the late game, give or take ~50.
#### More than that will work mechanically but prepare for substantial frame rate drops.
max_desired_laamps_value = {
	value = 200
	switch = {
		trigger = has_game_rule
		ai_laamp_numbers_25 = { value = 25 }
		ai_laamp_numbers_50 = { value = 50 }
		ai_laamp_numbers_100 = { value = 100 }
		ai_laamp_numbers_150 = { value = 150 }
		ai_laamp_numbers_200 = { value = 200 }
	}
}

seventyfive_percent_of_max_desired_laamps_value = {
	value = max_desired_laamps_value
	multiply = 0.75
}

too_many_laamps_value = {
	value = max_desired_laamps_value
	switch = {
		trigger = has_game_rule
		ai_laamp_numbers_25 = { add = 2 }
		ai_laamp_numbers_50 = { add = 5 }
		ai_laamp_numbers_100 = { add = 10 }
		ai_laamp_numbers_150 = { add = 15 }
		ai_laamp_numbers_200 = { add = 20 }
	}
}

wipe_slate_min_xp_to_remove_trait_value = 5
crusader_absolution_min_xp_to_remove_trait_value = 25
crusader_absolution_xp_removed_per_track_value = {
	value = 100
	subtract = crusader_absolution_min_xp_to_remove_trait_value
	multiply = -1
}

camp_party_province_reference_value = {
	value = 15
}

amount_of_followers_value = {
	value = 0
	every_courtier = {
		add = 1
	}
}

current_camp_temperament_average_value = {
	value = 0
	every_courtier = {
		add = "opinion(root)"
	}
	divide = amount_of_followers_value
}

low_camp_temperament_value = define:NDomicile|TEMPERAMENT_THRESHOLD_LOW
high_camp_temperament_value = define:NDomicile|TEMPERAMENT_THRESHOLD_HIGH

default_temperament_high_value_scale = {
	value = prestige_level
	if = {
		limit = {
			has_perk = absolute_control_perk
		}
		add = {
			value = dread
			divide = 20
		}
	}
	if = {
		limit = {
			has_perk = honored_to_serve_perk
		}
		add = {
			every_courtier = {
				add = 1
			}
			divide = 5
			min = 0
		}
	}
	if = {
		limit = {
			has_perk = scientific_perk
		}
		add = {
			every_courtier = {
				limit = {
					learning >= 15
				}
				add = 1
			}
			min = 0
		}
	}
	if = {
		limit = {
			has_perk = gracious_host_impeccable_guest_perk
		}
		add = num_of_known_languages
	}
}

default_temperament_low_value_scale = {
	value = prestige_level
}

estate_increase_gardener_aptitude_value_1 = 5
estate_increase_gardener_aptitude_value_2 = 10
estate_increase_gardener_aptitude_value_3 = 15
estate_increase_gardener_aptitude_value_4 = 20
estate_increase_gardener_aptitude_value_5 = 25
estate_increase_gardener_aptitude_value_6 = 30

estate_increased_personal_scheme_success_1_value = 5
estate_increased_personal_scheme_success_2_value = 15
estate_increased_personal_scheme_success_3_value = 25

kennels_more_successful_hunts_1_value = 10
kennels_more_successful_hunts_2_value = 15

cultivated_sophistication_development_gain = minor_development_progress_gain

slander_appointment_score_value = -25
slander_acclamation_score_value = -50

promote_appointment_score_value = 30
promote_acclamation_score_value = 50

ep3_requested_faith_support_0_value = {
	value = major_influence_gain
}
ep3_requested_faith_support_1_value = {
	value = ep3_requested_faith_support_0_value
	multiply = 1.5
}
ep3_requested_faith_support_2_value = {
	value = ep3_requested_faith_support_0_value
	multiply = 2
}
ep3_requested_faith_support_3_value = {
	value = ep3_requested_faith_support_0_value
	multiply = 2.5
}
ep3_requested_faith_support_4_value = {
	value = ep3_requested_faith_support_0_value
	multiply = 3
}
ep3_requested_faith_support_5_value = {
	value = ep3_requested_faith_support_0_value
	multiply = 3.5
}
ep3_requested_faith_support_6_value = {
	value = ep3_requested_faith_support_0_value
	multiply = 4
}

chancellor_integrate_title_admin_top_liege_bonus = 1
chancellor_integrate_title_admin_target_bonus = 0.5

de_jure_governor_bonus = -20

greek_anarchy_army_levy_value = {
	value = 50
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_high_medieval
			}
		}
		add = 100
	}
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_late_medieval
			}
		}
		add = 100
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_duchy
			}
		}
		add = 150
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_kingdom
			}
		}
		add = 200
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_empire
			}
		}
		add = 200
	}
}

greek_anarchy_army_weak_maa_value = {
	value = 1
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_high_medieval
			}
		}
		add = 1
	}
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_late_medieval
			}
		}
		add = 2
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_duchy
			}
		}
		add = 1
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_kingdom
			}
		}
		add = 2
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_empire
			}
		}
		add = 1
	}
}

greek_anarchy_army_maa_value = {
	value = 1
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_late_medieval
			}
		}
		add = 2
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_duchy
			}
		}
		add = 1
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_kingdom
			}
		}
		add = 1
	}
}

greek_anarchy_army_heavy_cav_value = {
	value = 0
	if = {
		limit = {
			culture = {
				has_cultural_era_or_later = culture_era_late_medieval
			}
		}
		add = 1
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_duchy
			}
		}
		add = 1
	}
	if = {
		limit = {
			scope:defender = {
				highest_held_title_tier >= tier_empire
			}
		}
		add = 1
	}
}

greek_anarchy_development_value = -50

faction_power_existing_threshold_value = {
	value = faction_power
	multiply = 2
}

ep3_invite_to_faction_war_strength_compare_defender_value = {
	value = 0
	every_war_defender = { add = current_military_strength }
}

ep3_invite_to_faction_war_strength_compare_attacker_value = {
	value = 0
	every_war_attacker = { add = current_military_strength }
}

admin_convert_influence_value = {
	value = 0
	if = {
		limit = {
			has_character_flag = latin_emp_force_admin_flag
		}
		add = major_influence_gain
	}
	else = {
		add = monumental_influence_gain
	}
}

admin_convert_legitimacy_value = {
	value = 0
	if = {
		limit = {
			has_character_flag = latin_emp_force_admin_flag
		}
		add = minor_legitimacy_gain
	}
	else = {
		add = medium_legitimacy_gain
	}
}

chance_to_be_educated_while_educating_value = {
	value = 2.5
	if = {
		limit = { has_perk = learn_on_the_job_perk }
		multiply = 2
	}
}

learning_task_contract_qualified_score_value = 1
learning_task_contract_medium_score_value = 2
learning_task_contract_major_score_value = 3

laamp_base_contract_schemes_2661_modifier_duration_value = {
	value = 5
	if = {
		limit = {
			root = { is_ai = no }
		}
		add = 20
	}
}

rebuke_roman_revanchism_sicily_requirements_no_ere_county_value = 10
rebuke_roman_revanchism_sicily_requirements_some_ere_county_value = 13
rebuke_roman_revanchism_sicily_requirements_no_ere_in_italy_county_value = 5
rebuke_roman_revanchism_sicily_fame_reward_value = 1000

# How many provisions do we give out per modifier removed?
butcher_animals_decision_cat_provision_value = 50
butcher_animals_decision_dog_provision_value = 75
butcher_animals_decision_dog_building_provision_value = 750
butcher_animals_decision_horse_provision_value = 150
butcher_animals_decision_horse_building_provision_value = 1250
butcher_animals_decision_elephant_building_provision = 2500

# How long before you can rebuild buildings/sacrifice the animals again?
butcher_animals_decision_regular_cooldown_value = 25
butcher_animals_decision_elephant_cooldown_value = 50

add_camp_officer_aptitude_value = {
	if = {
		limit = { has_court_position = second_camp_officer }
		add = "aptitude(second_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = quartermaster_camp_officer }
		add = "aptitude(quartermaster_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = armorer_camp_officer }
		add = "aptitude(armorer_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = chief_forager_camp_officer }
		add = "aptitude(chief_forager_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = master_thief_camp_officer }
		add = "aptitude(master_thief_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = head_porter_camp_officer }
		add = "aptitude(head_porter_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = head_groom_camp_officer }
		add = "aptitude(head_groom_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = huntperson_camp_officer }
		add = "aptitude(huntperson_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = kennelperson_camp_officer }
		add = "aptitude(kennelperson_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = chief_engineer_camp_officer }
		add = "aptitude(chief_engineer_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = witness_camp_officer }
		add = "aptitude(witness_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = person_haggler_camp_officer }
		add = "aptitude(person_haggler_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = camp_cook_camp_officer }
		add = "aptitude(camp_cook_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = master_bard_camp_officer }
		add = "aptitude(master_bard_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = stooge_camp_officer }
		add = "aptitude(stooge_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = master_of_arms_camp_officer }
		add = "aptitude(master_of_arms_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = light_cavalry_captain_camp_officer }
		add = "aptitude(light_cavalry_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = camelry_captain_camp_officer }
		add = "aptitude(camelry_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = elephantry_captain_camp_officer }
		add = "aptitude(elephantry_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = heavy_cavalry_captain_camp_officer }
		add = "aptitude(heavy_cavalry_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = horse_archer_captain_camp_officer }
		add = "aptitude(horse_archer_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = archer_captain_camp_officer }
		add = "aptitude(archer_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = heavy_infantry_captain_camp_officer }
		add = "aptitude(heavy_infantry_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = light_infantry_captain_camp_officer }
		add = "aptitude(light_infantry_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = pike_captain_camp_officer }
		add = "aptitude(pike_captain_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = master_of_spoils_camp_officer }
		add = "aptitude(master_of_spoils_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = laureate_camp_officer }
		add = "aptitude(laureate_camp_officer)"
	}
	else_if = {
		limit = { has_court_position = camp_priest_camp_officer }
		add = "aptitude(camp_priest_camp_officer)"
	}
}

laamp_base_contract_schemes_1301_maa_damage_catastrophic_value = -0.6
laamp_base_contract_schemes_1301_maa_damage_heavy_value = -0.45
laamp_base_contract_schemes_1301_maa_damage_moderate_value = -0.3
laamp_base_contract_schemes_1301_maa_damage_light_value = -0.2

# Thomas Aquinas was born in 1225, more or less
ep3_thomas_aquinas_age_value = {
	value = current_year
	add = -1225
}

ep3_interactions_events_0500_troops_count_value = 100

ep3_adventurer_ai_contracts_per_employer_max_value = 3
ep3_adventurer_ai_contracts_per_employer_min_value = 1
ep3_adventurer_ai_employers_per_kingdom_max_value = 8
ep3_adventurer_ai_employers_per_kingdom_min_value = 4

procure_estate_interaction_cost_base_gold = 1000
procure_estate_interaction_cost_base_prestige = 2000
procure_estate_interaction_cost_base_piety = 1000

request_co_emperor_interaction_gold_cost_value = { value = monumental_gold_value }
request_co_emperor_interaction_influence_cost_value = {
	value = monumental_influence_value
	multiply = 2
}

see_how_its_done_gold_reward_value = {
	value = 20
	multiply = been_there_done_that_check_multiplier_value
}

visit_settlement_paid_training_value = {
	value = 0
	if = {
		limit = { prowess < low_skill_rating }
		value = tiny_gold_laamps_value
	}
	else_if = {
		limit = { prowess < mediocre_skill_rating }
		value = minor_gold_laamps_value
	}
	else_if = {
		limit = { prowess < decent_skill_rating }
		value = medium_gold_laamps_value
	}
	else_if = {
		limit = { prowess < high_skill_rating }
		value = major_gold_laamps_value
	}
	else_if = {
		limit = { prowess < extremely_high_skill_rating }
		value = massive_gold_laamps_value
		divide = 2
	}
	else = {
		value = massive_gold_laamps_value
	}
}

harrying_miniscule_increase_value = 0.3
harrying_minor_increase_value = 0.5
harrying_medium_increase_value = 1

laamp_marriable_women_value = {
	if = {
		limit = { laamp_request_likely_marriable_woman_trigger = yes }
		add = 1
	}
	every_courtier = {
		limit = { laamp_request_likely_marriable_woman_trigger = yes }
		add = 1
	}
}

laamp_marriable_women_realistic_value = {
	every_courtier = {
		limit = {
			laamp_request_likely_marriable_woman_trigger = yes
			NOR = {
				is_close_family_of = root
				has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
				is_councillor_of = root
				is_concubine_of = root
			}
		}
		add = 1
	}
}

laamp_marriable_men_value = {
	if = {
		limit = { laamp_request_likely_marriable_man_trigger = yes }
		add = 1
	}
	every_courtier = {
		limit = { laamp_request_likely_marriable_man_trigger = yes }
		add = 1
	}
}

laamp_marriable_men_realistic_value = {
	every_courtier = {
		limit = {
			laamp_request_likely_marriable_man_trigger = yes
			NOR = {
				is_close_family_of = root
				has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
				is_councillor_of = root
				is_concubine_of = root
			}
		}
		add = 1
	}
}

laamp_city_construction_year_value = {
	value = scope:year_of_construction
	add = 100
}

estate_increase_tutor_aptitude_value_1 = 5
estate_increase_tutor_aptitude_value_2 = 10
estate_increase_tutor_aptitude_value_3 = 15
estate_increase_tutor_aptitude_value_4 = 20
estate_increase_tutor_aptitude_value_5 = 25
estate_increase_tutor_aptitude_value_6 = 30

force_step_down_interaction_gold_cost_value = {
	value = 0
	scope:recipient = {
		if = {
			limit = { highest_held_title_tier = tier_empire }
			add = scope:actor.monumental_gold_value
			multiply = 3
		}
		else_if = {
			limit = { highest_held_title_tier = tier_kingdom }
			add = scope:actor.monumental_gold_value
		}
		else_if = {
			limit = { highest_held_title_tier = tier_duchy }
			add = scope:actor.massive_gold_value
		}
		else_if = {
			limit = { highest_held_title_tier = tier_county }
			add = scope:actor.major_gold_value
		}
	}
	multiply = scope:recipient.number_of_held_governorships
}

force_step_down_interaction_influence_cost_value = {
	value = 0
	scope:recipient = {
		if = {
			limit = { highest_held_title_tier = tier_empire }
			add = scope:actor.monumental_influence_value
			multiply = 3
		}
		else_if = {
			limit = { highest_held_title_tier = tier_kingdom }
			add = scope:actor.monumental_influence_value
		}
		else_if = {
			limit = { highest_held_title_tier = tier_duchy }
			add = scope:actor.massive_influence_value
		}
		else_if = {
			limit = { highest_held_title_tier = tier_county }
			add = scope:actor.major_influence_value
		}
	}
	multiply = 2
	multiply = scope:recipient.number_of_held_governorships
	multiply = -1
}

number_of_held_governorships = {
	value = 0
	save_temporary_scope_as = governor_temp
	every_held_title = {
		limit = {
			tier = scope:governor_temp.highest_held_title_tier
			is_landless_type_title = no
			is_noble_family_title = no
		}
		add = 1
	}
}

# Family attribute values
increased_investment_cap_bonus_1_value = 10
increased_investment_cap_bonus_2_value = 20
increased_investment_cap_bonus_3_value = 40

improved_siphon_treasury_scheme_1_value = 4
improved_siphon_treasury_scheme_2_value = 8
improved_siphon_treasury_scheme_3_value = 12

gain_dynasty_prestige_on_building_construction_1_value = 10
gain_dynasty_prestige_on_building_construction_2_value = 20
gain_dynasty_prestige_on_building_construction_3_value = 30

building_construction_dynasty_prestige_gain_value = {
	value = 0
	scope:character.house ?= {
		if = {
			limit = { has_house_power_parameter = gain_dynasty_prestige_on_building_construction_3 }
			add = gain_dynasty_prestige_on_building_construction_3_value
		}
		else_if = {
			limit = { has_house_power_parameter = gain_dynasty_prestige_on_building_construction_2 }
			add = gain_dynasty_prestige_on_building_construction_2_value
		}
		else_if = {
			limit = { has_house_power_parameter = gain_dynasty_prestige_on_building_construction_1 }
			add = gain_dynasty_prestige_on_building_construction_1_value
		}
	}
}

increased_request_troops_acceptance_1_value = 10
increased_request_troops_acceptance_2_value = 20
increased_request_troops_acceptance_3_value = 30

swing_scales_cost_reduction_1_value = -0.1
swing_scales_cost_reduction_2_value = -0.15
swing_scales_cost_reduction_3_value = -0.2

swing_scales_cost_multipler_value = {
	value = 1
	house ?= {
		if = {
			limit = { has_house_power_parameter = respected_despots }
			if = {
				limit = { has_house_power_parameter = swing_scales_cost_reduction_3 }
				add = swing_scales_cost_reduction_3_value
			}
			else_if = {
				limit = { has_house_power_parameter = swing_scales_cost_reduction_2 }
				add = swing_scales_cost_reduction_2_value
			}
			else_if = {
				limit = { has_house_power_parameter = swing_scales_cost_reduction_1 }
				add = swing_scales_cost_reduction_1_value
			}
		}
	}
}

improved_raid_estate_scheme_1_value = 5
improved_raid_estate_scheme_2_value = 10
improved_raid_estate_scheme_3_value = 15

increased_request_appointment_acceptance_1_value = 10
increased_request_appointment_acceptance_2_value = 25
increased_request_appointment_acceptance_3_value = 50

occupations_give_bonuses_1_value = 20
occupations_give_bonuses_2_value = 40
occupations_give_bonuses_3_value = 60

increased_marriage_acceptance_1_value = 10
increased_marriage_acceptance_2_value = 20
increased_marriage_acceptance_3_value = 40

increased_clerical_influence_acceptance_1_value = 10
increased_clerical_influence_acceptance_2_value = 25
increased_clerical_influence_acceptance_3_value = 40

candidate_score_per_piety_level_1_value = 4
candidate_score_per_piety_level_2_value = 8
candidate_score_per_piety_level_3_value = 12

liquidate_camp_main_value_1 = 25
liquidate_camp_main_value_2 = 50
liquidate_camp_main_value_3 = 75
liquidate_camp_main_value_4 = 100
liquidate_camp_external_value_1 = 10
liquidate_camp_external_value_2 = 20
liquidate_camp_external_value_3 = 30
liquidate_camp_external_value_4 = 40
liquidate_camp_external_value_5 = 50
liquidate_camp_external_value_6 = 60
liquidate_camp_internal_value = 10
