#######################
# AI_WILL_DO MODIFIERS

activity_option_expense_gold_low_value = { value = major_gold_value }
activity_option_expense_gold_high_value = { value = monumental_gold_value }

activity_option_likes_cheap_expense_value = {
	# AI values.
	## Greed weights us up dramatically.
	add = {
		value = ai_greed
		multiply = 2
		desc = debug_gui.activity_weight.ai_value.greed
	}
	## Sociability weights us down a bit, since activities are inherently at least somewhat social.
	add = {
		value = ai_sociability
		multiply = -0.5
		desc = debug_gui.activity_weight.ai_value.sociability
	}
	# Traits.
	## Personality traits.
	### Greedy doesn't want to spend money.
	if = {
		limit = { has_trait = greedy }
		add = {
			value = 100
			desc = debug_gui.activity_weight.trait.greedy
		}
	}
	### Generous is happy to dole out cash.
	if = {
		limit = { has_trait = generous }
		add = {
			value = -100
			desc = debug_gui.activity_weight.trait.generous
		}
	}
	## Stress traits.
	### Profligate will happily spend itself into debt.
	if = {
		limit = { has_trait = profligate }
		add = {
			value = -200
			desc = debug_gui.activity_weight.trait.profligate
		}
	}
	### Improvident will likewise, provided they consider this a form of giving to others.
	if = {
		limit = { considers_social_presence_a_gift_to_other_trigger = yes }
		add = {
			value = -200
			desc = debug_gui.activity_weight.trait.improvident.giving_circumstances
		}
	}
	# Gold.
	## If we're poor, we'll try to avoid massive expenses unnecessarily.
	if = {
		limit = {
			# Can't be a big spender.
			NOR = {
				has_trait = profligate
				considers_social_presence_a_gift_to_other_trigger = yes
			}
			# Or have more than a certain amount of negative greed.
			ai_greed >= high_negative_ai_value
			# _Then_ we check to see how your finances are.
			short_term_gold <= activity_option_expense_gold_low_value
		}
		add = {
			value = 200
			desc = debug_gui.activity_weight.gold.prefers_cheapness
		}
	}
}

activity_option_likes_middling_expense_value = {
	# AI values.
	## Rationality weights us up a bit, since we only want to spend a sensible amount.
	add = {
		value = ai_rationality
		multiply = 0.75
		desc = debug_gui.activity_weight.ai_value.rationality
	}
	## Boldness weights us down, since we're caring more what other people think of us — either because we want to spend more or we want to spend less.
	add = {
		value = ai_boldness
		multiply = -0.5
		desc = debug_gui.activity_weight.ai_value.boldness
	}
	# Traits.
	## Personality traits.
	### Generous is happy to dole out cash.
	if = {
		limit = { has_trait = generous }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.generous
		}
	}
	### Greedy doesn't want to spend money.
	if = {
		limit = { has_trait = greedy }
		add = {
			value = -50
			desc = debug_gui.activity_weight.trait.greedy
		}
	}
	## Stress traits.
	### Profligate will happily spend itself into debt.
	if = {
		limit = { has_trait = profligate }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.profligate
		}
	}
	### Improvident will likewise, provided they consider this a form of giving to others.
	if = {
		limit = { considers_social_presence_a_gift_to_other_trigger = yes }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.improvident.giving_circumstances
		}
	}
	# Gold.
	## We mostly care about gold if we fall within the bandwidths for the other two values.
	if = {
		limit = {
			short_term_gold < activity_option_expense_gold_high_value
			short_term_gold > activity_option_expense_gold_low_value
		}
		add = {
			value = 200
			desc = debug_gui.activity_weight.gold.prefers_middling
		}
	}
}

activity_option_likes_heavy_expense_value = {
	# AI values.
	## Sociability weights us up a bit, since activities are inherently at least somewhat social.
	add = {
		value = ai_sociability
		multiply = 0.5
		desc = debug_gui.activity_weight.ai_value.greed
	}
	## Greed weights us down dramatically.
	add = {
		value = ai_greed
		multiply = -2
		desc = debug_gui.activity_weight.ai_value.sociability
	}
	# Traits.
	## Personality traits.
	### Generous is happy to dole out cash.
	if = {
		limit = { has_trait = generous }
		add = {
			value = 100
			desc = debug_gui.activity_weight.trait.generous
		}
	}
	### Greedy doesn't want to spend money.
	if = {
		limit = { has_trait = greedy }
		add = {
			value = -100
			desc = debug_gui.activity_weight.trait.greedy
		}
	}
	## Stress traits.
	### Profligate will happily spend itself into debt.
	if = {
		limit = { has_trait = profligate }
		add = {
			value = 200
			desc = debug_gui.activity_weight.trait.profligate
		}
	}
	### Improvident will likewise, provided they consider this a form of giving to others.
	if = {
		limit = { considers_social_presence_a_gift_to_other_trigger = yes }
		add = {
			value = 200
			desc = debug_gui.activity_weight.trait.improvident.giving_circumstances
		}
	}
	# Gold.
	## If we're rich, we'll try to spend up a bit, since we can splash out.
	if = {
		limit = {
			# Some characters just don't want to make a whole big thing of it.
			NOR = {
				has_trait = greedy
				has_trait = shy
				has_trait = humble
			}
			# Or have more than a certain amount of positive greed.
			ai_greed <= high_positive_ai_value
			# _Then_ we check to see how your finances are.
			short_term_gold >= activity_option_expense_gold_high_value
		}
		add = {
			value = 200
			desc = debug_gui.activity_weight.gold.prefers_expense
		}
	}
}

activity_option_likes_functional_food_option_value = {
	# AI Values.
	## Boldness weights us up, since we're showing off.
	add = {
		value = ai_boldness
		multiply = 1
		desc = debug_gui.activity_weight.ai_value.boldness
	}
	## Sociability weights us up a little, as we want to put on a fancy feast.
	add = {
		value = ai_sociability
		multiply = 0.25
		desc = debug_gui.activity_weight.ai_value.sociability
	}
	# Traits.
	## Personality traits.
	### Humble hates showing off.
	if = {
		limit = { has_trait = humble }
		add = {
			value = 150
			desc = debug_gui.activity_weight.trait.humble
		}
	}
	### Shy prefers not to show off.
	if = {
		limit = { has_trait = shy }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.shy
		}
	}
	### Gregarious quite likes showing off.
	if = {
		limit = { has_trait = gregarious }
		add = {
			value = -50
			desc = debug_gui.activity_weight.trait.gregarious
		}
	}
	### Arrogant loves showing off.
	if = {
		limit = { has_trait = arrogant }
		add = {
			value = -150
			desc = debug_gui.activity_weight.trait.arrogant
		}
	}
	## Stress traits.
	### Drunkard wants fancier fare available.
	if = {
		limit = { has_trait = drunkard }
		add = {
			value = -100
			desc = debug_gui.activity_weight.trait.drunkard
		}
	}
	### Hashishiyah wants fancier fare available.
	if = {
		limit = { has_trait = hashishiyah }
		add = {
			value = -100
			desc = debug_gui.activity_weight.trait.hashishiyah
		}
	}
}

activity_option_likes_ostentatious_food_option_value = {
	# AI Values.
	## Sociability weights us down a little, as we don't want to be the centre of attention.
	add = {
		value = ai_sociability
		multiply = -0.25
		desc = debug_gui.activity_weight.ai_value.sociability
	}
	## Boldness weights us down, since we're trying to avoid showing off.
	add = {
		value = ai_boldness
		multiply = -1
		desc = debug_gui.activity_weight.ai_value.boldness
	}
	# Traits.
	## Personality traits.
	### Arrogant loves showing off.
	if = {
		limit = { has_trait = arrogant }
		add = {
			value = 150
			desc = debug_gui.activity_weight.trait.arrogant
		}
	}
	### Gregarious quite likes showing off.
	if = {
		limit = { has_trait = gregarious }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.gregarious
		}
	}
	### Shy prefers not to show off.
	if = {
		limit = { has_trait = shy }
		add = {
			value = -50
			desc = debug_gui.activity_weight.trait.shy
		}
	}
	### Humble hates showing off.
	if = {
		limit = { has_trait = humble }
		add = {
			value = -150
			desc = debug_gui.activity_weight.trait.humble
		}
	}
	## Stress traits.
	### Drunkard wants fancier fare available.
	if = {
		limit = { has_trait = drunkard }
		add = {
			value = 100
			desc = debug_gui.activity_weight.trait.drunkard
		}
	}
	### Hashishiyah wants fancier fare available.
	if = {
		limit = { has_trait = hashishiyah }
		add = {
			value = 100
			desc = debug_gui.activity_weight.trait.hashishiyah
		}
	}
}

activity_option_food_prefers_small_volume_value = {
	# AI Values.
	## AI values here would be kinda muddled, since the relevant traits overlap heavily with greedy/generous, so we sede the section to the expense values.
	# Traits.
	## Personality traits.
	### Temperate wants the requisite amount.
	if = {
		limit = { has_trait = temperate }
		add = {
			value = 150
			desc = debug_gui.activity_weight.trait.temperate
		}
	}
	### Humble has a slight preference for smaller amounts.
	if = {
		limit = { has_trait = humble }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.humble
		}
	}
	### Arrogant has a slight preference for larger amounts.
	if = {
		limit = { has_trait = arrogant }
		add = {
			value = -50
			desc = debug_gui.activity_weight.trait.arrogant
		}
	}
	### Gluttonous wants _more_.
	if = {
		limit = { has_trait = gluttonous }
		add = {
			value = -150
			desc = debug_gui.activity_weight.trait.gluttonous
		}
	}
	## Stress traits.
	### Inappetetic prefers fewer courses.
	if = {
		limit = { has_trait = inappetetic }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.inappetetic
		}
	}
	### Comfort Eater wants more.
	if = {
		limit = { has_trait = comfort_eater }
		add = {
			value = -50
			desc = debug_gui.activity_weight.trait.comfort_eater
		}
	}
	## Other traits.
	### Reveller likes a decent revel.
	if = {
		limit = { has_trait = lifestyle_reveler }
		add = {
			value = -100
			desc = debug_gui.activity_weight.trait.lifestyle_reveler
		}
	}
	# Other.
	### Trying to lose weight, fewer courses.
	if = {
		limit = { has_character_modifier = losing_weight_modifier }
		add = {
			value = 200
			desc = debug_gui.activity_weight.modifier.losing_weight
		}
	}
	### Trying to gain weight, more courses.
	if = {
		limit = { has_character_modifier = gaining_weight_modifier }
		add = {
			value = -100
			desc = debug_gui.activity_weight.modifier.gaining_weight
		}
	}
}

activity_option_prefers_large_volume_value = {
	# AI Values.
	## AI values here would be kinda muddled, since the relevant traits overlap heavily with greedy/generous, so we sede the section to the expense values.
	# Traits.
	## Personality traits.
	### Gluttonous wants _more_.
	if = {
		limit = { has_trait = gluttonous }
		add = {
			value = 150
			desc = debug_gui.activity_weight.trait.gluttonous
		}
	}
	### Arrogant has a slight preference for larger amounts.
	if = {
		limit = { has_trait = arrogant }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.arrogant
		}
	}
	### Humble has a slight preference for smaller amounts.
	if = {
		limit = { has_trait = humble }
		add = {
			value = -50
			desc = debug_gui.activity_weight.trait.humble
		}
	}
	### Temperate wants less.
	if = {
		limit = { has_trait = temperate }
		add = {
			value = -150
			desc = debug_gui.activity_weight.trait.temperate
		}
	}
	## Stress traits.
	### Comfort Eater enjoys having plenty of food.
	if = {
		limit = { has_trait = comfort_eater }
		add = {
			value = 50
			desc = debug_gui.activity_weight.trait.comfort_eater
		}
	}
	### Inappetetic prefers fewer courses.
	if = {
		limit = { has_trait = inappetetic }
		add = {
			value = -50
			desc = debug_gui.activity_weight.trait.inappetetic
		}
	}
	## Other traits.
	### Reveller likes a decent revel.
	if = {
		limit = { has_trait = lifestyle_reveler }
		add = {
			value = 100
			desc = debug_gui.activity_weight.trait.lifestyle_reveler
		}
	}
	# Other.
	### Trying to gain weight, more courses.
	if = {
		limit = { has_character_modifier = gaining_weight_modifier }
		add = {
			value = 200
			desc = debug_gui.activity_weight.modifier.gaining_weight
		}
	}
	### Trying to lose weight, fewer courses.
	if = {
		limit = { has_character_modifier = losing_weight_modifier }
		add = {
			value = -100
			desc = debug_gui.activity_weight.modifier.losing_weight
		}
	}
}

######################
# FEAST STUFF
######################
standard_feast_cooldown_time = {
	value = 5
	if = {
		limit = {
			root.culture = {
				has_cultural_parameter = more_frequent_feasts
			}
		}
		multiply = 0.5
	}
}

min_feast_event_spacing = 10
max_feast_event_spacing = 15

feast_activity_cost = {
	value = 0
	add = standard_activity_base_cost
	if = {
		limit = {
			culture = {
				has_cultural_parameter = more_expensive_feasts
			}
		}
		multiply = 2
	}
	if = {
		limit = {
			exists = var:protected_alcohol_stores
			var:protected_alcohol_stores > 0
		}
		multiply = 0.5
	}
}

feast_normal_option_cost = {
	value = 10
	multiply = activity_cost_scale_by_tier
	multiply = activity_cost_scale_by_era
}

feast_good_option_cost = {
	value = 35
	multiply = activity_cost_scale_by_tier
	multiply = activity_cost_scale_by_era
}

feast_activity_cost_discount_max = {
	value = 0.5
}
feast_activity_cost_discount_max_value = {
	value = feast_activity_cost_discount_max
	subtract = 1
}
feast_activity_cost_discount_medium = {
	value = 0.7
}
feast_activity_cost_discount_medium_value = {
	value = feast_activity_cost_discount_medium
	subtract = 1
}
feast_activity_cost_discount_min = {
	value = 0.9
}
feast_activity_cost_discount_min_value = {
	value = feast_activity_cost_discount_min
	subtract = 1
}

feast_opinion_max_food_value = {
	value = 15

	if = {
		limit = {
			is_vassal_of = scope:host
			has_vassal_stance = courtly
			is_participant_in_activity = scope:activity
		}
		add = 10
	}

	scope:host = {
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = { type = court_food_quality value >= 5 }
			}
			add = 10
		}
		multiply = court_brewmaster_multiplier
	}
}

feast_opinion_medium_food_value = {
	value = 10

	if = {
		limit = {
			is_vassal_of = scope:host
			has_vassal_stance = courtly
			is_participant_in_activity = scope:activity
		}
		add = 5
	}

	scope:host = {
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = { type = court_food_quality value >= 5 }
			}
			add = 5
		}
		multiply = court_brewmaster_multiplier
	}
}

feast_opinion_mediocre_food_value = {
	value = 5

	if = {
		limit = {
			is_vassal_of = scope:host
			has_vassal_stance = courtly
			is_participant_in_activity = scope:activity
		}
		subtract = 3
	}

	scope:host = {
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = { type = court_food_quality value >= 5 }
			}
			add = 5
		}
		else_if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = { type = court_food_quality value >= 5 }
			}
			add = 2
		}
		multiply = court_brewmaster_multiplier
	}
}

### END FEASTS

pilgrimage_base_cost = {
	value = 0 
	add = standard_activity_base_cost
}

standard_activity_base_cost = {
	value = 30
	multiply = {
		value = root.primary_title.tier
		subtract = 1
		min = 1
	}
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.primary_title.tier > tier_duchy
		}
		add = 50
	}
}

# Deprecated
standard_activity_cost = {
	value = 50
	multiply = {
		value = root.primary_title.tier
		subtract = 1
		min = 1
	}
	if = {
		limit = {
			root.primary_title.tier > tier_duchy
		}
		add = 50
	}
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
}

law_legacy_cost_reduction_mult = 0.3

feast_events_ewan_0001_murder_scheme_bonus_time_to_use_value = 20
feast_events_ewan_0001_murder_scheme_bonus_added_base_success_value = 10

######################
# PLAYDATE STUFF
######################
standard_playdate_cooldown_time = 1095

playdate_participants = 10
min_default_playdate_events = 3
min_playdate_event_spacing = 5
max_playdate_event_spacing = 10
playdate_initial_event_delay = 3

max_playdate_duration = {
	value = max_playdate_event_spacing
	multiply = {
		value = min_default_playdate_events
		subtract = 1
	}
	add = playdate_initial_event_delay
	add = 1 # To be sure no values get set on the last tick
}

standard_playdate_activity_cost = {
	value = 10
	multiply = {
		value = root.primary_title.tier
		subtract = 1
		min = 1
	}
	if = {
		limit = {
			root.primary_title.tier > tier_duchy
		}
		add = 25
	}
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
}


activity_medium_gold_value = {
	value = medium_gold_value
}

activity_minor_gold_value = {
	value = minor_gold_value
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
}

######################
# HOLD COURT STUFF
######################
standard_hold_court_cooldown_time = 1825

######################
# GRAND RITE STUFF
######################
standard_witch_ritual_cooldown_time = 1825

######################
# ADVENTURE STUFF
######################
# Using the same measure of distances as pilgrimage
long_adventure_max_length = 5000000 # 5M Over this distance, it will be an exceptionally long pilgrimage 
medium_adventure_max_length = 1000000 # 1M, slightly larger than 1 'holy roman empire' away 
short_adventure_max_length = 100000 # 100K, slightly larger than 1 'ireland' away. 

very_long_adventure_var = 5
long_adventure_var = 4
medium_adventure_var = 3
short_adventure_var = 2

######################
# PETITION STUFF
######################

standard_petition_liege_cooldown_time = 1825
petition_liege_refusal_tyranny_value = 2

### Council

# For checking if petitioner is significantly better than current councillor
councillor_diplomacy_threshold_value = { # Petitioner's diplomacy - 3
	value = scope:petition_vassal.diplomacy
	subtract = 3
}

councillor_martial_threshold_value = { # Petitioner's martial - 3
	value = scope:petition_vassal.martial
	subtract = 3
}

councillor_stewardship_threshold_value = { # Petitioner's stewardship - 3
	value = scope:petition_vassal.stewardship
	subtract = 3
}

councillor_intrigue_threshold_value = { # Petitioner's intrigue - 3
	value = scope:petition_vassal.intrigue
	subtract = 3
}

councillor_learning_threshold_value = { # Petitioner's learning - 3
	value = scope:petition_vassal.learning
	subtract = 3
}

### Debt

# Amount liege needs to pay to get petioner out of debt
petitioner_debt_positivization_value = { 
	value = 0
	add = scope:petition_vassal.gold
	multiply = -1
}

petitioner_debt_positivization_root_value = { 
	value = 0
	add = root.gold
	multiply = -1
}

### War Aid

#Amount of levies liege will grant
petitioner_war_aid_levies_value = { 
	value = 0
	add = scope:petition_vassal.petition_war_aid_strongest_enemy_strength_value
	subtract = scope:petition_vassal.petition_war_aid_vassal_strength_value
	multiply = 2
	min = 500
	max = scope:petition_liege.max_military_strength
}

petitioner_war_aid_levies_cost_value = { 
	value = petitioner_war_aid_levies_value
	divide = 20

}

petitioner_war_aid_levies_cost_threshold_value = { 
	value = petitioner_war_aid_levies_cost_value
	multiply = 2
}

### Control

county_control_scaling_cost_value = {
	value = 0
	scope:petition_vassal = {
		every_held_title = {
			limit = {
				tier = tier_county
				county_control < medium_county_control
			}
			add = 25
		}
	}
	min = 50
	max = 150
}

petition_liege_county_control_count_value = {
	value = 0
	every_in_list = {
		list = petition_liege_county_control_list
		add = 1
	}
}

petition_liege_county_control_modifier_value = {
	value = 0
	add = marshal_increase_control_base_total
	multiply = 0.1
}

### Convert

petition_liege_county_convert_count_value = {
	value = 0
	every_in_list = {
		list = petition_liege_county_convert_list
		add = 1
	}
}

petition_liege_county_convert_modifier_value = {
	value = 0
	add = court_chaplain_conversion_base_total
	multiply = 0.1
}

### Opinion

petition_liege_county_opinion_count_value = {
	value = 0
	every_in_list = {
		list = petition_liege_county_opinion_list
		add = 1
	}
}

### Fortify

petition_liege_fortify_border_count_value = {
	value = 0
	every_in_list = {
		list = petition_liege_fortify_border_list
		add = 1
	}
}

### Development

# Amount of development difference of liege's capital
petitioner_development_difference_decision_value = { 
	value = 0
	if = {
		limit = { exists = capital_province }
		add = capital_province.county.development_level
	}
	multiply = 1.5
}

# Amount of development difference of liege's capital
petitioner_development_difference_value = { 
	value = 0
	add = scope:petition_vassal.capital_province.county.development_level
	multiply = 1.5
}

### Petition Parameters

# War Aid War Score
petition_war_aid_score_value = {
	value = 25
}

petition_liege_defender_strength_value = {
	value = 0
	every_war_defender = {
		add = max_military_strength
		every_hired_mercenary = { add = max_military_strength }
	}
}

petition_liege_attacker_strength_value = {
	value = 0
	every_war_attacker = {
		add = max_military_strength
		every_hired_mercenary = { add = max_military_strength }
	}
}

# War Aid Liege Strength Min
petition_war_aid_strongest_enemy_strength_value = {
	value = 0
	if = {
		limit = {
			any_character_war = {
				root = { is_leader_in_war = prev }
				root = { is_attacker_in_war = prev }
				defender_war_score >= petition_war_aid_score_value
			}
		}
		ordered_character_war = {
			limit = {
				root = { is_leader_in_war = prev }
				root = { is_attacker_in_war = prev }
				defender_war_score >= petition_war_aid_score_value
			}
			order_by = petition_liege_defender_strength_value
			add = petition_liege_defender_strength_value
		}
	}
	else_if = {
		limit = {
			any_character_war = {
				root = { is_leader_in_war = prev }
				root = { is_defender_in_war = prev }
				attacker_war_score >= petition_war_aid_score_value
			}
		}
		ordered_character_war = {
			limit = {
				root = { is_leader_in_war = prev }
				root = { is_defender_in_war = prev }
				attacker_war_score >= petition_war_aid_score_value
			}
			order_by = petition_liege_attacker_strength_value
			add = petition_liege_attacker_strength_value
		}
	}
}

petition_war_aid_vassal_strength_value = {
	value = 0
	if = {
		limit = {
			any_character_war = {
				root = { is_leader_in_war = prev }
				root = { is_attacker_in_war = prev }
				defender_war_score >= petition_war_aid_score_value
			}
		}
		ordered_character_war = {
			limit = {
				root = { is_leader_in_war = prev }
				root = { is_attacker_in_war = prev }
				defender_war_score >= petition_war_aid_score_value
			}
			order_by = petition_liege_defender_strength_value
			add = petition_liege_attacker_strength_value
		}
	}
	else_if = {
		limit = {
			any_character_war = {
				root = { is_leader_in_war = prev }
				root = { is_defender_in_war = prev }
				attacker_war_score >= petition_war_aid_score_value
			}
		}
		ordered_character_war = {
			limit = {
				root = { is_leader_in_war = prev }
				root = { is_defender_in_war = prev }
				attacker_war_score >= petition_war_aid_score_value
			}
			order_by = petition_liege_attacker_strength_value
			add = petition_liege_defender_strength_value
		}
	}
}

petition_war_aid_vassal_liege_combined_value = {
	value = petition_war_aid_vassal_strength_value
	add = petition_war_aid_liege_merc_value
}

petition_war_aid_difference_value = {
	value = petition_war_aid_strongest_enemy_strength_value
	subtract = petition_war_aid_vassal_liege_combined_value
}

petition_county_opinion_value = {
	value = -25
}

petition_war_aid_liege_ally_value = {
	value = 0
	root.liege = {
		add = max_military_strength
		if = {
			limit = {
				any_ally = {
					NOT = { is_vassal_of = root.liege }
				}
			}
			every_ally = {
				limit = {
					NOT = { is_vassal_of = root.liege }
				}
				add = max_military_strength
			}
		}
		every_hired_mercenary = { add = max_military_strength }
	}
}

petition_war_aid_liege_merc_value = {
	value = 0
	scope:petition_liege = {
		add = max_military_strength
		every_hired_mercenary = { add = max_military_strength }
	}
}

petition_war_aid_liege_ally_advantage_value = {
	value = petition_war_aid_liege_ally_value
	multiply = 2
}

petition_war_aid_rebels_value = {
	value = 0
	liege = {
		if = {
			limit = {
				any_character_war = {
					primary_defender = root.liege
					OR = {
						using_cb = peasant_war
						using_cb = independence_faction_war
						using_cb = liberty_faction_war
						using_cb = populist_war
						using_cb = claimant_faction_war
						using_cb = depose_war
						using_cb = refused_liege_demand_war
						using_cb = independence_war
					}
				}
			}
			every_character_war = {
				limit = {
					primary_defender = root.liege
					OR = {
						using_cb = peasant_war
						using_cb = independence_faction_war
						using_cb = liberty_faction_war
						using_cb = populist_war
						using_cb = claimant_faction_war
						using_cb = depose_war
						using_cb = refused_liege_demand_war
						using_cb = independence_war
					}
				}
				add = petition_liege_attacker_strength_value
			}
		}
	}
	multiply = 2
}

petition_war_aid_external_value = {
	value = 0
	liege = {
		if = {
			limit = {
				any_character_war = {
					root.liege = { is_leader_in_war = prev }
					trigger_if = {
						limit = {
							root.liege = { is_defender_in_war = prev }
						}
						OR = {
							primary_attacker.primary_title.tier = root.liege.primary_title.tier
							petition_liege_attacker_strength_value > petition_war_aid_liege_ally_value
						}
					}
					trigger_else = {
						limit = {
							root.liege = { is_defender_in_war = prev }
						}
						OR = {
							primary_attacker.primary_title.tier = root.liege.primary_title.tier
							petition_liege_attacker_strength_value > petition_war_aid_liege_ally_value
						}
					}
				}
			}
			ordered_character_war = {
				limit = {
					root.liege = { is_leader_in_war = prev }
					trigger_if = {
						limit = {
							root.liege = { is_defender_in_war = prev }
						}
						OR = {
							primary_attacker.primary_title.tier = root.liege.primary_title.tier
							petition_liege_attacker_strength_value > petition_war_aid_liege_ally_value
						}
					}
					trigger_else = {
						limit = {
							root.liege = { is_defender_in_war = prev }
						}
						OR = {
							primary_attacker.primary_title.tier = root.liege.primary_title.tier
							petition_liege_defender_strength_value > petition_war_aid_liege_ally_value
						}
					}
				}
				add = petition_liege_attacker_strength_value
			}
		}
	}
	multiply = 2
}

petition_liege_war_aid_ongoing_count_trigger = {
	value = 0
	every_character_war = { subtract = 25 }
}

#Adventurers:

adventure_progress_chance_svalue = {
	value = 30
	if = {
		limit = {
			exists = scope:inspiration_owner.involved_activity.var:adventure_distance
			scope:inspiration_owner.involved_activity.var:adventure_distance = short_adventure_var
		}
		subtract = 5
	}
	else_if = {
		limit = {
			exists = scope:inspiration_owner.involved_activity.var:adventure_distance
			scope:inspiration_owner.involved_activity.var:adventure_distance = medium_adventure_var
		}
		subtract = 10
	}
	else_if = {
		limit = {
			exists = scope:inspiration_owner.involved_activity.var:adventure_distance
			scope:inspiration_owner.involved_activity.var:adventure_distance = long_adventure_var
		}
		subtract = 15
	}
	else_if = {
		limit = {
			exists = scope:inspiration_owner.involved_activity.var:adventure_distance
			scope:inspiration_owner.involved_activity.var:adventure_distance = very_long_adventure_var
		}
		subtract = 20
	}
	multiply = {
		value = scope:inspiration_owner.adventure_inspiration_average_skill_value
		divide = 10
		min = 1
	}
}

#TOUR Values

activity_tour_maximum_stop_value = 10
activity_tour_high_stop_value = 8
activity_tour_low_stop_value = 5
activity_tour_minimum_stop_value = 3

tour_level_5_prestige_reward = {
	value = 1000
	if = {
		limit = {
			involved_activity = {
				has_activity_option = {
					category = special_type
					option = tour_type_taxation
				}
			}
		}
		multiply = 0.5
	}
}
tour_level_4_prestige_reward = {
	value = 700
	if = {
		limit = {
			involved_activity = {
				has_activity_option = {
					category = special_type
					option = tour_type_taxation
				}
			}
		}
		multiply = 0.5
	}
}
tour_level_3_prestige_reward = {
	value = 500
	if = {
		limit = {
			involved_activity = {
				has_activity_option = {
					category = special_type
					option = tour_type_taxation
				}
			}
		}
		multiply = 0.5
	}
}
tour_level_2_prestige_reward = {
	value = 300
	if = {
		limit = {
			involved_activity = {
				has_activity_option = {
					category = special_type
					option = tour_type_taxation
				}
			}
		}
		multiply = 0.5
	}
}
tour_level_1_prestige_reward = {
	value = 100
	if = {
		limit = {
			involved_activity = {
				has_activity_option = {
					category = special_type
					option = tour_type_taxation
				}
			}
		}
		multiply = 0.5
	}
}

achievement_imperial_march_achievement_powerful_vassal_tally_value = {
	value = 0
	scope:host = {
		every_powerful_vassal = {
			limit = { highest_held_title_tier >= tier_county }
			add = 1
		}
	}
	min = 1
}

# To be used in activity script files where we weight which characters from your court get added to your entourage
standard_travel_entourage_additions = {
	value = 0
	if = {
		limit = { is_available = no }
		add = -1000
	}
	if = {
		limit = {
			scope:owner = { employs_court_position = bodyguard_court_position }
			has_court_position = bodyguard_court_position
		}
		add = 500
	}
	if = {
		limit = {
			scope:owner = { employs_court_position = akolouthos_court_position }
			has_court_position = akolouthos_court_position
		}
		add = 500
	}
	if = {
		limit = {
			scope:owner = { employs_court_position = court_physician_court_position }
			has_court_position = court_physician_court_position
		}
		add = 500
	}
	if = {
		limit = {
			bannable_serving_diarch_trigger = yes
		}
		subtract = 10000
	}
}

# Activity Cost Scaling Multipliers 
# use as multiply = activity_cost_scale_by_XXX
activity_cost_scale_by_era = {
	value = 0
	if = {
		limit = {
			exists = culture
		}
		culture = {
			if = {
				limit = {
					has_cultural_era_or_later = culture_era_late_medieval
				}
				add = 3
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_high_medieval
				}
				add = 1.5
			}
			else_if = {
				limit = {
					has_cultural_era_or_later = culture_era_early_medieval
				}
				add = 1
			}
			else = {
				add = 0.75
			}
		}
	}
}

activity_cost_scale_by_tier = {
	value = 0
	if = {
		limit = { exists = root.primary_title }
		add = {
			value = root.primary_title.tier
			subtract = 1
		}
	}
	min = 1
}

university_visit_activity_cost_scale_by_tier = {
	value = 0
	if = {
		limit = { exists = root.primary_title }
		add = {
			value = root.primary_title.tier
			subtract = 1
			multiply = 0.5
		}
	}
	min = 1
}

gruesome_festival_option_small = {
	value = 15
	add = {
		value = 15
		multiply = activity_cost_scale_by_era
		subtract = 15
		desc = activity_cost_scale_by_era_desc 
	}
	add = {
		value = 15
		multiply = activity_cost_scale_by_tier
		subtract = 15
		desc = activity_cost_scale_by_tier_desc 
	}
}

gruesome_festival_option_medium = {
	value = 40
	add = {
		value = 40
		multiply = activity_cost_scale_by_era
		subtract = 40
		desc = activity_cost_scale_by_era_desc 
	}
	add = {
		value = 40
		multiply = activity_cost_scale_by_tier
		subtract = 40
		desc = activity_cost_scale_by_tier_desc 
	}
}

gruesome_festival_option_large = {
	value = 120
	add = {
		value = 120
		multiply = activity_cost_scale_by_era
		subtract = 120
		desc = activity_cost_scale_by_era_desc 
	}
	add = {
		value = 120
		multiply = activity_cost_scale_by_tier
		subtract = 120
		desc = activity_cost_scale_by_tier_desc 
	}
}

### UNIVERSITY VISIT STUFF

adult_education_activity_cost = {
	value = root.major_gold_value_static_max
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
}

######################
# FUNERAL STUFF
######################
standard_funeral_cooldown_time = {
	value = 5
}

min_funeral_event_spacing = 10
max_funeral_event_spacing = 15

funeral_activity_cost = {
	value = 0
	add = standard_activity_base_cost
}

funeral_normal_option_cost = {
	value = 10
	multiply = activity_cost_scale_by_tier
	multiply = activity_cost_scale_by_era
}

funeral_good_option_cost = {
	value = 35
	multiply = activity_cost_scale_by_tier
	multiply = activity_cost_scale_by_era
}

funeral_activity_cost_discount_max = {
	value = 0.5
}
funeral_activity_cost_increase_max = {
	value = 1.5
}
funeral_activity_cost_discount_max_value = {
	value = funeral_activity_cost_discount_max
	subtract = 1
}
funeral_activity_cost_discount_medium = {
	value = 0.7
}
funeral_activity_cost_discount_medium_value = {
	value = funeral_activity_cost_discount_medium
	subtract = 1
}
funeral_activity_cost_discount_min = {
	value = 0.9
}
funeral_activity_cost_discount_min_value = {
	value = funeral_activity_cost_discount_min
	subtract = 1
}

funeral_end_piety_gain = {
	value = 150
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_bad
				}
			}
		}
		add = 50
	}
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_normal
				}
			}
		}
		add = 100
	}
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_good
				}
			}
		}
		add = 200
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					barony = {
						is_holy_site_of = scope:host.faith
					}
					has_holy_building = yes
				}
			}
		}
		add = 50
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					barony = {
						is_holy_site_of = scope:host.faith
					}
				}
			}
		}
		add = 50
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					has_building_or_higher = tower_of_silence_01
				}
			}
		}
		add = 50
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					scope:host.faith = { has_doctrine_parameter = sky_burials_active }
					is_mountainous_trigger = yes
				}
			}
		}
		add = 50
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					has_building_or_higher = temple_01
					faith.religion = scope:host.faith.religion
				}
			}
		}
		add = 50
	}
	multiply = funeral_end_piety_multiplier
}

funeral_end_piety_multiplier = {
	value = 1
	if = {
		limit = {
			scope:host.faith = {
				has_doctrine_parameter = mummification_funeral
			}
		}
		value = 0.1
	}
	if = {
		limit = {
			scope:host.faith = {
				has_doctrine_parameter = stoic_funeral
			}
		}
		value = 1.25
	}
}

funeral_end_stress_loss = {
	value = -10
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_bad
				}
			}
		}
		add = -10
	}
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_normal
				}
			}
		}
		add = -25
	}
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_good
				}
			}
		}
		add = -50
	}
	multiply = funeral_end_stress_multiplier
}

funeral_end_stress_multiplier = {
	value = 1
	if = {
		limit = {
			scope:host.faith = {
				has_doctrine_parameter = stoic_funeral
			}
		}
		value = 0.5
	}
	if = {
		limit = {
			scope:host.faith = {
				has_doctrine_parameter = bewailment_funeral
			}
		}
		value = 2
	}
}

funeral_end_legitimacy_gain = {
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_bad
				}
			}
		}
		value = miniscule_legitimacy_gain
	}
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_normal
				}
			}
		}
		value = minor_legitimacy_gain
	}
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = funeral_option_ceremony
					option = funeral_ceremony_good
				}
			}
		}
		value = medium_legitimacy_gain
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					barony = {
						is_holy_site_of = scope:host.faith
					}
					has_holy_building = yes
				}
			}
		}
		add = 10
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					barony = {
						is_holy_site_of = scope:host.faith
					}
				}
			}
		}
		add = 10
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					has_building_or_higher = tower_of_silence_01
				}
			}
		}
		add = 10
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					scope:host.faith = { has_doctrine_parameter = sky_burials_active }
					is_mountainous_trigger = yes
				}
			}
		}
		add = 10
	}
	if = {
		limit = {
			scope:activity = {
				activity_location = {
					has_building_or_higher = temple_01
					faith.religion = scope:host.faith.religion
				}
			}
		}
		add = 10
	}
}

### CAMP PARTY STUFF
standard_camp_party_cooldown_time = {
	value = 2
	if = {
		limit = {
			root.culture = {
				has_cultural_parameter = more_frequent_feasts
			}
		}
		multiply = 0.5
	}
}
standard_camp_party_activity_cost = {
	value = 15
}

###########
# ROAMING #
###########
standard_roaming_activity_cost = {
	value = 25
	multiply = {
		value = root.primary_title.tier
		subtract = 1
		min = 1
	}
	if = {
		limit = {
			root.primary_title.tier > tier_duchy
		}
		add = 25
	}
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
}

roaming_province_reference_value = {
	value = 0
	if = {
		limit = {
			has_province_modifier = wayfarer_astronomical_phenomenon
		}
		add = 45
	}
	# TERRAIN
	if = {
		limit = {
			OR = {
				terrain = desert_mountains
				terrain = mountains
			}
		}
		add = 30
	}
	if = {
		limit = {
			OR = {
				terrain = desert
				terrain = oasis
				terrain = hills
				terrain = taiga
				terrain = forest
				terrain = jungle
			}
		}
		add = 15
	}
	# POPULATION
	if = {
		limit = { has_holding = no }
		add = 15
	}
}

roaming_outro_stress_loss_value = {
	value = 0
	if = {
		limit = {
			has_character_flag = roaming_weak_stress_loss
		}
		add = -15
	}
	if = {
		limit = {
			has_character_flag = roaming_medium_stress_loss
		}
		add = -20
	}
	if = {
		limit = {
			has_character_flag = roaming_strong_stress_loss
		}
		add = -25
	}
	if = {
		limit = {
			has_character_flag = roaming_very_strong_stress_loss
		}
		add = -30
	}
}

roaming_reward_multiplier_value = {
	value = 1
	if = {
		limit = {
			exists = scope:activity
			scope:activity = { has_activity_type = activity_roaming }
		}
		scope:activity.activity_location = {
			if = {
				limit = {
					has_holding = no
				}
				add = 0.1
			}
			if = {
				limit = {
					OR = {
						terrain = desert_mountains
						terrain = mountains
					}
				}
				add = 0.3
			}
			else_if = {
				limit = {
					OR = {
						terrain = desert
						terrain = oasis
						terrain = hills
						terrain = taiga
						terrain = forest
						terrain = jungle
					}
				}
				add = 0.2
			}
			if = {
				limit = {
					OR = {
						has_province_modifier = inspection_hidden_hinterlands_recruit_modifier
						has_province_modifier = inspection_hidden_hinterlands_hunters_modifier
					}
				}
				multiply = 1.25
			}
		}
	}
}

roaming_reward_fame_multiplier_value = {
	value = 1
	if = {
		limit = {
			has_activity_intent = roaming_storyteller_intent
		}
		add = 0.2
	}
}

roaming_reward_fame_very_small = {
	value = 20
	multiply = roaming_reward_multiplier_value
	multiply = roaming_reward_fame_multiplier_value
}

roaming_reward_fame_small = {
	value = 40
	multiply = roaming_reward_multiplier_value
	multiply = roaming_reward_fame_multiplier_value
}

roaming_reward_fame_medium = {
	value = 60
	multiply = roaming_reward_multiplier_value
	multiply = roaming_reward_fame_multiplier_value
}

roaming_reward_fame_high = {
	value = 80
	multiply = roaming_reward_multiplier_value
	multiply = roaming_reward_fame_multiplier_value
}

roaming_reward_fame_very_high = {
	value = 125
	multiply = roaming_reward_multiplier_value
	multiply = roaming_reward_fame_multiplier_value
}

roaming_reward_fame_legendary = {
	value = 200
	multiply = roaming_reward_multiplier_value
	multiply = roaming_reward_fame_multiplier_value
}

roaming_apa_fame_chance_value = {
	value = 25
	scope:host = {
		if = {
			limit = {
				has_activity_intent = roaming_storyteller_intent
			}
			multiply = 1.5
		}
	}
}
roaming_apa_stress_chance_value = {
	value = 10
	scope:host = {
		if = {
			limit = {
				has_activity_intent = reduce_stress_intent
			}
			multiply = 1.5
		}
	}
}
roaming_apa_gold_chance_value = 15
roaming_apa_rare_chance_value = 2

roaming_mystic_chance_value = {
	value = 25
	if = {
		limit = {
			OR = {
				has_trait = lifestyle_mystic
				has_activity_intent = roaming_mystic_intent
			}
		}
		value = 50
	}
}

roaming_test_value = {
	value = scope:fame_value
}

###########
# JOURNEY #
###########
standard_journey_activity_cost = {
	value = 10
	multiply = {
		value = root.primary_title.tier
		subtract = 1
		min = 1
	}
	if = {
		limit = {
			root.primary_title.tier > tier_duchy
		}
		add = 25
	}
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
}

journey_province_reference_value = {
	value = 0
	if = {
		limit = {
			exists = county.holder
			scope:host = { in_diplomatic_range = root.county.holder }
			trigger_if = {
				limit = {
					exists = county.holder.liege
				}
				scope:host = { in_diplomatic_range = root.county.holder.liege }
			}
		}
		add = {
			value = county.development_level
			divide = 2
		}
		if = {
			limit = {
				"scope:host.capital_province.squared_distance(root)" <= squared_distance_small
			}
			add = 50
		}
		if = {
			limit = {
				"scope:host.capital_province.squared_distance(root)" > squared_distance_small
				"scope:host.capital_province.squared_distance(root)" <= squared_distance_medium
			}
			add = 40
		}
		if = {
			limit = {
				"scope:host.capital_province.squared_distance(root)" > squared_distance_medium
				"scope:host.capital_province.squared_distance(root)" <= squared_distance_large
			}
			add = 30
		}
		if = {
			limit = {
				"scope:host.capital_province.squared_distance(root)" > squared_distance_large
				"scope:host.capital_province.squared_distance(root)" <= squared_distance_huge
			}
			add = 20
		}
		if = {
			limit = {
				"scope:host.capital_province.squared_distance(root)" > squared_distance_huge
				"scope:host.capital_province.squared_distance(root)" <= squared_distance_almost_massive
			}
			add = 10
		}
		if = {
			limit = {
				"scope:host.capital_province.squared_distance(root)" > squared_distance_almost_massive
			}
			add = -10
		}
		if = {
			limit = {
				has_travel_point_of_interest = poi_special_buildings_wonder
			}
			add = 40
		}
		if = {
			limit = {
				has_travel_point_of_interest = poi_special_buildings_martial
			}
			add = 25
		}
		if = {
			limit = {
				has_travel_point_of_interest = poi_special_buildings_learning
			}
			add = 25
		}
		if = {
			limit = {
				has_travel_point_of_interest = poi_special_buildings_religious
			}
			add = 25
		}
		if = {
			limit = {
				has_travel_point_of_interest = poi_special_buildings_diplomatic
			}
			add = 25
		}
		if = {
			limit = {
				has_travel_point_of_interest = poi_special_buildings_economic
			}
			add = 25
		}
	}
	if = {
		limit = {
			scope:host = { 
				has_variable_list = extra_journey_target 
				is_target_in_variable_list = {
					name = extra_journey_target
					target = root
				}
			}
		}
		add = 100
	}
	if = {
		limit = {
			OR = {
				has_province_modifier = inspection_proteted_poi_levy_modifier
				has_province_modifier = inspection_protected_holy_poi_levy_modifier
				has_province_modifier = inspection_protected_poi_gold_modifier
				has_province_modifier = inspection_protected_holy_poi_gold_modifier
			}
		}
		add = 25
	}
	if = {
		limit = {
			OR = {
				NOT = { scope:host = { has_variable_list = extra_journey_target } }
				AND = {
					scope:host = { has_variable_list = extra_journey_target }
					NOT = {
						scope:host = {
							is_target_in_variable_list = {
								name = extra_journey_target
								target = root
							}
						}
					}
				}
			}
			OR = {
				NOT = { exists = root.county.holder }
				NOT = {
					scope:host = { in_diplomatic_range = root.county.holder }
				}
				AND = {
					exists = root.county.holder.liege
					NOT = {
						scope:host = {
							in_diplomatic_range = root.county.holder.liege
						}
					}
				}
			}
		}
		multiply = 0
	}
	if = {
		limit = {
			scope:host = { 
				has_variable_list = visited_monument_exploration 
				is_target_in_variable_list = {
					name = visited_monument_exploration
					target = root
				}
			}
		}
		multiply = 0
	}
}

journey_inspired_journey_costs_value = {
	value = 1
	if = {
		limit = {
			inspired_journey_value_trigger = yes
		}
		multiply = 0.5
	}
}

##########
# SURVEY #
##########
standard_survey_activity_cost = {
	value = 50
	if = {
		limit = {
			root.primary_title.tier > tier_duchy
		}
		add = 25
	}
	multiply = {
		value = root.primary_title.tier
		subtract = 1
		min = 1
		divide = 2
		min = 1
	}
	if = {
		limit = {
			root = {
				government_has_flag = government_is_tribal
			}
		}
		multiply = 0.5
	}
}

survey_province_reference_value = {
	value = 0
	if = {
		limit = {
			county = {
				any_neighboring_county = {
					exists = holder
					NOT = { holder.top_liege = root.county.holder.top_liege }
				}
			}
		}
		add = 50
	}
	else_if = {
		limit = {
			scope:host = { is_independent_ruler = no }
			county = {
				any_neighboring_county = {
					exists = holder
					holder.top_liege = root.county.holder.top_liege
					NOT = {
						holder = { 
							OR = {
								is_vassal_of = scope:host 
								this = scope:host
							}
						}
					}
				}
			}
		}
		add = 25
	}
	add = {
		value = 100
		subtract = county.county_control
	}
	if = {
		limit = {
			OR = {
				this = scope:host.capital_province
				is_county_capital = no
			}
		}
		multiply = 0
	}
}

inspection_success_chance_value = {
	if = {
		limit = {
			activity_host = { is_ai = no }
			activity_location = { has_province_modifier = inspection_second_try_modifier }
		}
		add = {
			value = 10
			desc = inspection_success_chance.second_try_modifier
		}
	}
	activity_host = {
		if = {
			limit = {
				has_activity_intent = survey_overseer_intent
			}
			add = {
				value = 10
				desc = survey_overseer_intent
			}
		}
		add = {
			value = stewardship
			divide = 3
			ceiling = yes
			max = 10
			desc = stewardship_modifier
		}
		add = {
			value = learning
			divide = 3
			ceiling = yes
			max = 10
			desc = learning_modifier
		}
		add = {
			value = diplomacy
			divide = 3
			ceiling = yes
			max = 10
			desc = diplomacy_modifier
		}
		add = {
			value = intrigue
			divide = 3
			ceiling = yes
			max = 10
			desc = intrigue_modifier
		}
		if = {
			limit = {
				has_trait = overseer
			}
			add = {
				value = 4
				desc = trait_overseer
			}
		}
		if = {
			limit = {
				has_trait = administrator
			}
			add = {
				value = 4
				desc = trait_administrator
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_surveyor
			}
			add = {
				value = 4
				desc = trait_lifestyle_surveyor
			}
		}
	}
	activity_location = {
		add = {
			value = 100
			subtract = {
				value = county.county_control
				max = 100 # In-case they have 'Absolute Control', which seems to be more than 100
			}
			divide = 5
			desc = county_control_modifier
		}
		if = {
			limit = {
				county = {
					any_neighboring_county = {
						exists = holder
						NOT = { holder.top_liege = prev.holder.top_liege }
					}
				}
			}
			add = {
				value = 10
				desc = borderlands_modifier
			}
		}
	}
	# EVENTS
	if = {
		limit = { exists = var:inspection_success_chance_event }
		add = {
			value = var:inspection_success_chance_event
			desc = inspection_success_chance.events
		}
	}
	min = 5
	max = 95
}

survey_province_development_info_value = { value = root.location.county.development_level }
survey_province_control_info_value = { value = root.location.county.county_control }
survey_province_tax_info_value = { value = root.location.monthly_income }
survey_province_levy_info_value = { value = root.location.building_levies }
survey_province_popular_opinion_info_value = { value = root.location.county.county_opinion }

inspection_activity_success_increase_medium_value = 10
inspection_activity_success_increase_minor_value = 5
inspection_activity_success_increase_miniscule_value = 2
inspection_activity_success_decrease_miniscule_value = -2
inspection_activity_success_decrease_minor_value = -5
inspection_activity_success_decrease_medium_value = -10

inspection_value_old_roads_scale = {
	value = 30
	subtract = development_level
	divide = 3
	floor = yes

	min = 0
	max = 10
	desc = MODIFIER_DEFINITION_OLD_ROADS_DESC
}

inspection_expanding_walls_new_scale = {
	add = free_building_slots

	min = 1
	max = 5
	DESC = MODIFIER_DEFINITION_EXPANDING_WALLS_NEW_DESC
}

inspection_expanding_walls_old_scale = {
	add = num_buildings
	if = {
		limit = {
			has_special_building = yes
		}
		add = 1
	}

	min = 1
	max = 10
	DESC = MODIFIER_DEFINITION_EXPANDING_WALLS_OLD_DESC
}

inspection_minor_gold = {
	value = minor_gold_value
	multiply = inspection_activity_option_multiplier
}

inspection_medium_gold = {
	value = medium_gold_value
	multiply = inspection_activity_option_multiplier
}

inspection_activity_option_multiplier = {
	value = 1
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = inspection_option_allocated_funds
					option = inspection_large_fund
				}
			}
		}
		multiply = 0.6
	}
	else_if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = inspection_option_allocated_funds
					option = inspection_small_fund
				}
			}
		}
		multiply = 0.8
	}
}


