﻿
##################################################
# Interactions

purchase_truce_interaction_small_sum = { value = medium_gold_value }

purchase_truce_interaction_medium_sum = { value = major_gold_value }

purchase_truce_interaction_major_sum = { value = massive_gold_value }

# We only use this one for AI weighting, hence why it's a little jank.
purchase_truce_interaction_massive_sum = {
	value = monumental_gold_value
	multiply = 2
}

purchase_truce_interaction_truce_days_small_value = 3650
purchase_truce_interaction_truce_days_medium_value = 5475
purchase_truce_interaction_truce_days_large_value = 9125

purchase_truce_interaction_recipient_far_weaker_value = {
	value = max_military_strength
	multiply = 0.4
}

purchase_truce_interaction_recipient_somewhat_weaker_value = {
	value = max_military_strength
	multiply = 0.8
}

purchase_truce_interaction_recipient_somewhat_stronger_value = {
	value = max_military_strength
	multiply = 1.2
}

purchase_truce_interaction_recipient_far_stronger_value = {
	value = max_military_strength
	multiply = 1.6
}

challenge_to_chess_opinion_change_loser_value = 30

challenge_to_chess_opinion_change_loser_arrogant_value = {
	value = challenge_to_chess_opinion_change_loser_value
	multiply = -1
}

challenge_to_chess_stress_stake_value = { value = medium_stress_gain }

challenge_to_chess_gold_change_value = {
	value = 0

	#Guess you don't have a monthly income, most of the time
	if = {
		limit = {
			scope:actor = {
				monthly_character_income <= 0
				is_landless_adventurer = yes
			}
		}
		if = {
			limit = { scope:actor.gold > scope:recipient.gold }
			add = scope:recipient.monthly_character_income
			multiply = 9
		}
		else = { add = scope:actor.gold }
	}
	else = {
		# To keep this balanced, we want to use the lowest income of scope:actor & scope:recipient.
		if = {
			limit = { scope:actor.monthly_character_income >= scope:recipient.monthly_character_income }
			add = scope:recipient.monthly_character_income
		}
		else = { add = scope:actor.monthly_character_income }
		# And, because month-to-month income isn't much, we take it up to a significant fraction of a year's earnings.
		multiply = 9
	}
}

bg_stake_land_evaluate_appropriate_county_ordering_value = {
	value = 0
	# We want to get the *least* worthwhile county available.
	## Chiefly based off of development.
	add = {
		value = development_level
		multiply = -1
	}
	## But control factors in a tad too.
	add = {
		value = county_control
		multiply = -0.25
	}
	# Weight up personal claims a bit.
	if = {
		limit = {
			any_claimant = { this = scope:ordering_char_temp }
		}
		add = 50
	}
}

bg_crit_success_add_value = 7

bg_success_add_value = 4

bg_failure_add_value = 2

bg_crit_failure_add_value = 0

bg_counter_mult_value = 0.5

bg_winning_threshold_value = 10
bg_close_to_winning_threshold_value = 8

bg_relative_score_heavy_difference_threshold_value = {
	value = 0
	add = scope:bg_opponent.var:bg_current_score
	add = 4
}
bg_relative_score_light_difference_threshold_value = {
	value = 0
	add = scope:bg_opponent.var:bg_current_score
	add = 2
}

# Note: the cap is considered hit at the *end* of this round.
bg_round_cap_value = 4

bg_cumulative_skill_score_value = {
	value = 0
	# Pachisi
	if = {
		limit = { scope:bg_system = flag:pachisi }
		add = diplomacy
		add = intrigue
		add = stewardship
	}
	# Hnefatafl
	if = {
		limit = { scope:bg_system = flag:hnefatafl }
		add = intrigue
		add = martial
		add = prowess
	}
	# Tabula
	if = {
		limit = { scope:bg_system = flag:tabula }
		add = intrigue
		add = learning
		add = stewardship
	}
	# Go
	if = {
		limit = { scope:bg_system = flag:go }
		add = learning
		add = martial
		add = intrigue
	}
	# Fidchell
	if = {
		limit = { scope:bg_system = flag:fidchell }
		add = learning
		add = prowess
		add = diplomacy
	}
	# Chess
	if = {
		limit = { scope:bg_system = flag:chess }
		add = martial
		add = intrigue
		add = learning
	}
}

bg_cumulative_skill_score_comparison_value = {
	value = 0
	if = {
		limit = { exists = scope:bg_myself }
		add = scope:bg_myself.bg_cumulative_skill_score_value
	}
	if = {
		limit = { exists = scope:bg_opponent }
		subtract = scope:bg_opponent.bg_cumulative_skill_score_value
	}
}

bg_bad_player_threshold_value = 24
bg_average_player_threshold_value = 36
bg_good_player_threshold_value = 48

offer_assistance_interaction_gold_value = {
	value = 0
	if = {
		limit = { exists = scope:contract_assistance_helper }
		add = scope:contract_assistance_helper.max_military_strength
	}
	divide = scope:recipient.max_military_strength
	if = {
		limit = {
			exists = scope:contract_assistance_helper
			scope:contract_assistance_helper.max_military_strength > scope:recipient.max_military_strength
		}
		multiply = 120
	}
	else = {
		multiply = 60
	}
	multiply = {
		value = 1
		if = {
			limit = { exists = scope:contract_assistance_helper }
			if = {
				limit = { scope:contract_assistance_helper = { has_trait = greedy } }
				add = 0.5
			}
			else_if = {
				limit = { scope:contract_assistance_helper = { has_trait = generous } }
				subtract = 0.5
			}
		}
	}
	if = {
		limit = {
			scope:contract_assistance_helper.domicile ?= { has_domicile_parameter = camp_improved_mercenary_contract_rewards }
		}
		multiply = camp_improved_mercenary_contract_rewards_value
	}
	if = {
		limit = {
			scope:contract_assistance_helper ?= { has_perk = hard_rule_perk }
		}
		multiply = adventurer_hard_rule_contract_rewards_value
	}
	round = yes
	max = gold
	min = 25
}

offer_assistance_interaction_gold_modifier_value = {
	value = scope:recipient.gold
	divide = 100
	floor = yes
	max = 5
}

offer_assistance_interaction_already_winning_value = 50

offer_assistance_interaction_already_losing_value = 25

offer_assistance_interaction_war_contribution_value = {
	value = 0
	if = {
		limit = { exists = scope:contract_assistance_helper }
		add = scope:contract_assistance_helper.max_military_strength
	}
	if = {
		limit = {
			scope:recipient ?= {
				any_war_ally = { #if you are the only war ally, you are the only one contributing to the war participation score, thus you cannot fulfill 
					count = 1
				}
			}
		}
		divide = 4
	}
	else_if = {
		limit = {
			scope:recipient ?= {
				any_war_ally = {
					count > 1
				}
			}
		}
		scope:recipient ?= {
			every_war_ally = {
				divide = {
					value = 4
					subtract = 1
					min = 1
				}
			}
		}	
	}
	max = 2000
	round = yes
}

saved_contribution_value = {
	value = 0
	if = {
		limit = {
			exists = scope:contract_assistance_helper
			exists = scope:contract_assistance_helper.var:owed_contract_assistance_contribution
		}
		add = scope:contract_assistance_helper.var:owed_contract_assistance_contribution
	}
	else = {
		add = offer_assistance_interaction_war_contribution_value
		if = {
			limit = {
				scope:recipient ?= {
					any_war_ally = {
						count = 0
					}
				}
			}
			divide = 4
		}
		else_if = {
			limit = {
				scope:recipient ?= {
					any_war_ally = { }
				}
			}
			scope:recipient ?= {
				every_war_ally = {
					divide = {
						value = 4
						subtract = 1
						min = 1
					}
				}
			}
		}
	}
	max = 2000
	min = 100
	if = {
		limit = {
			scope:laamp_temp ?= {
				has_character_flag = joined_as_mercenary
			}
		}
		value = 1
	}
}

##################################################
# Decisions

improve_city_province_decision_cost = 300

appoint_a_righteous_caliph_decision_same_faith_county_count = 10

appoint_a_righteous_caliph_decision_own_max_sins = 2

appoint_a_righteous_caliph_decision_hof_min_sins = 2

mozarabic_fate_county_count = 12

favour_the_countryside_basques_decision_basque_pagan_virtues_tally_value = 2

favour_the_countryside_basques_decision_counties_to_control_value = 9

council_of_toledo_decision_decision_cooldown_value = 25

council_of_toledo_piety_cost_value = 250

council_of_toledo_gold_cost_value = 100

council_of_toledo_realm_size_value = 20

council_toledo_conversion_modifier_value = 1.5

council_toledo_culture_acceptance_value = 10

council_toledo_modifier_duration_value = 10

council_toledo_success_guest_value = 3

council_of_toledo_counter_value = {
	value = 0
	if = {
		limit = { exists = global_var:council_of_toledo_counter }
		add = global_var:council_of_toledo_counter
	}
}

council_of_toledo_counter_less_one_value = {
	value = council_of_toledo_counter_value
	subtract = 1
}

council_toledo_divided_svalue = {
	value = council_of_toledo_counter_value
	divide = 10
}

council_toledo_divided_floor_svalue = {
	value = council_of_toledo_counter_value
	divide = 10
	floor = yes
}

council_toledo_divided_1_svalue = {
	value = council_of_toledo_counter_value
	subtract = 1
	divide = 10
}

council_toledo_divided_2_svalue = {
	value = council_of_toledo_counter_value
	subtract = 2
	divide = 10
}

council_toledo_divided_3_svalue = {
	value = council_of_toledo_counter_value
	subtract = 3
	divide = 10
}

council_toledo_divided_4_svalue = {
	value = council_of_toledo_counter_value
	subtract = 4
	divide = 10
}

council_toledo_divided_5_svalue = {
	value = council_of_toledo_counter_value
	subtract = 5
	divide = 10
}

council_toledo_divided_6_svalue = {
	value = council_of_toledo_counter_value
	subtract = 6
	divide = 10
}

council_toledo_divided_7_svalue = {
	value = council_of_toledo_counter_value
	subtract = 7
	divide = 10
}

council_toledo_divided_8_svalue = {
	value = council_of_toledo_counter_value
	subtract = 8
	divide = 10
}

council_toledo_divided_9_svalue = {
	value = council_of_toledo_counter_value
	subtract = 9
	divide = 10
}

##################################################
# Council Tasks

court_chaplain_fabricate_claim_cheaper_for_involved_parties_in_struggle_region_value = {
	value = 0
	add = court_chaplain_fabricate_claim_base_total
	multiply = 0.50
}

##################################################
# Casus Belli

fp2_border_raid_control_change_value = -25

fp2_border_raid_development_change_value = -1

fp2_border_raid_gold_change_value = {
	value = prev.development_level
	multiply = 5
	if = {
		limit = { exists = scope:raid_province }
		add = fp2_border_raid_building_gold_value
	}
}

fp2_border_raid_building_gold_value = {
	value = 25
}

fp2_border_raid_ai_targeting_value = {
	value = 0.5
	scope:attacker = {
		# Weight up religious enemies.
		if = {
			limit = {
				faith = {
					faith_hostility_level = {
						target = scope:defender.faith
						value > faith_astray_level
					}
				}
			}
			add = 0.5
		}
		# Weight up developed realms.
		every_in_list = {
			list = target_titles
			limit = { development_level >= 8 }
			add = 0.25
		}
		every_in_list = {
			list = target_titles
			limit = {
				any_county_province = { num_buildings >= 3 }
			}
			add = 0.25
		}
		if = {
			limit = {
				scope:defender = { is_at_war = yes }
			}
			add = 0.25
		}
		if = {
			limit = {
				NOT = {
					scope:attacker.ai_greed = 0
				}
			}
			add = {
				value = scope:attacker.ai_greed
				divide = 100
			}
		}
	}
}

siege_occupier_county_soldier_value = {
	value = 0
	if = {
		limit = { exists = scope:war }
		scope:war = {
			every_war_attacker = {
				limit = {
					any_army = {
						location = { is_in_list = occupied_baronies }
					}
				}
				every_army = {
					limit = {
						location = { is_in_list = occupied_baronies }
					}
					add = army_size
				}
			}
		}
	}
}

destroy_building_soldier_multiplier_value = {
	value = siege_occupier_county_soldier_value # 5000
	divide = 100000 # 0.5
	add = 1 # 1.5
}

destroy_building_development_multiplier_value = {
	value = barony.county.development_level # 11
	divide = 20 # 0.5
	add = 1
}

fp2_expel_interloper_ai_targeting_value = {
	value = 100
	scope:attacker = {
		# Weight up religious enemies.
		if = {
			limit = {
				faith = {
					faith_hostility_level = {
						target = scope:defender.faith
						value > faith_astray_level
					}
				}
			}
			add = 100
		}
		# Weight up culture enemies.
		if = {
			limit = {
				culture = {
					cultural_acceptance = {
						target = scope:defender.culture
						value < -25
					}
				}
			}
			add = 100
		}
	}
	# Weight up with interloper land
	scope:defender = {
		every_realm_county = {
			limit = { target_is_de_jure_liege_or_above = title:e_spain }
			add = fp2_expel_interloper_county_cost_value
		}
	}
}

fp2_expel_interloper_county_cost_value = 25

##################################################
# Dynasty Legacies

fp2_urbanism_legacy_1_bonus_value = 0.1

fp2_urbanism_legacy_1_bonus_value_percentage = {
	value = fp2_urbanism_legacy_1_bonus_value
	multiply = 100
}

##################################################
# Decisions

##### Struggle Ending Decisions #####

### Common

# Counts every county in region, to check against
struggle_iberia_ending_ending_decision_region_total_value = {
	value = 0
	every_county_in_region = {
		region = world_europe_west_iberia
		add = 1
	}
}

# Counts independent involved realms in Iberia, to compare
struggle_iberia_ending_ending_decision_foreign_realm_total_value = {
	value = 0
	struggle:iberian_struggle = {
		every_involved_ruler = {
			limit = {
				this != root
				top_liege = this
				is_landless_adventurer = no
				primary_title = { is_holy_order = no }
				primary_title = { is_mercenary_company = no }
			}
			add = 1
		}
	}
}

# Counts completely controlled de jure kingdoms of Hispania
fp2_struggle_ending_kingdom_counter_value = {
	every_held_title = {
		title_tier = kingdom
		limit = {
			de_jure_liege = title:e_spain
			root = { completely_controls = prev }
		}
		add = 1
	}
}

### Hostility

# Parameter for conversion speed multiplier
fp2_struggle_hostility_conversion_value = 1.5

# Parameter for culture and faith opinion loss
fp2_struggle_hostility_opinion_value = 15

fp2_struggle_hostility_opinion_negative_value = -5

# Parameter for cultural acceptance loss
fp2_struggle_hostility_culture_acceptance_value = -50

fp2_struggle_hostility_culture_acceptance_large_value = -75

# Counter for de jure capital kingdom's total counties
fp2_struggle_hostility_county_total_value = {
	value = 0
	capital_county.kingdom = {
		every_de_jure_county = { add = 1 }
	}
}

fp2_struggle_hostility_county_total_light_value = {
	value = fp2_struggle_hostility_county_total_value
	multiply = 0.75
	ceiling = yes
}

# Counter for de jure capital kingdom's same culture and faith counties
fp2_struggle_hostility_county_counter_value = {
	value = 0
	capital_county.kingdom = {
		every_de_jure_county = {
			limit = {
				culture = root.culture
				faith = root.faith
			}
			add = 1
		}
	}
}

# Counter for other rulers who own too much of Iberia
fp2_struggle_hostility_region_counter_value = {
	struggle:iberian_struggle = {
		every_involved_ruler = {
			limit = {
				this != root
				top_liege = this
				primary_title = { is_holy_order = no }
				primary_title = { is_mercenary_company = no }
				any_county_in_region = {
					region = world_europe_west_iberia
					percent > fp2_struggle_hostility_region_percent_decimal_value # set by fp2_struggle_hostility_region_percent_value
					holder.top_liege = prev
				}
			}
			add = 1
		}
	}
}

# Paramater for de jure kingdoms required
fp2_struggle_hostility_kingdom_total_value = 2

# Paramameter for percentage of Iberia that no other ruler can control
fp2_struggle_hostility_region_percent_value = 20

# Uses above to plug in to script as a decimal
fp2_struggle_hostility_region_percent_decimal_value = {
	value = fp2_struggle_hostility_region_percent_value
	divide = 100
	max = 1
}

### Compromise

# Counter for controlled counties in Iberia
struggle_iberia_ending_compromise_decision_region_owned_value = {
	value = 0
	every_county_in_region = {
		region = world_europe_west_iberia
		limit = { holder.top_liege = root }
		add = 1
	}
}

# Percentage of Iberian counties owned
struggle_iberia_ending_compromise_decision_region_owned_percent_value = {
	value = struggle_iberia_ending_compromise_decision_region_owned_value
	divide = struggle_iberia_ending_ending_decision_region_total_value
	multiply = 100
}

# Parameter for mininmum opinion
struggle_iberia_ending_compromise_decision_opinion_value = {
	value = 60
}

# Counter for hooked and friendly rulers
struggle_iberia_ending_compromise_decision_opinion_counter_value = {
	value = 0
	struggle:iberian_struggle = {
		every_involved_ruler = {
			limit = {
				this != root
				top_liege = this
				primary_title = { is_holy_order = no }
				primary_title = { is_mercenary_company = no }
				is_landless_adventurer = no
				save_temporary_scope_as = this_character
				OR = {
					root = { has_strong_hook = scope:this_character }
					opinion = {
						target = root
						value >= struggle_iberia_ending_compromise_decision_opinion_value
					}
				}
			}
			add = 1
		}
	}
}

# Counter for Iberian counties owned by non-Involved
struggle_iberia_ending_compromise_decision_region_interloper_value = {
	value = 0
	every_county_in_region = {
		region = world_europe_west_iberia
		limit = {
			holder.top_liege = { fp2_character_involved_in_struggle_trigger = no }
		}
		add = 1
	}
}

# Percentage of Iberian counties owned by non-Involved
struggle_iberia_ending_compromise_decision_region_interloper_percent_value = {
	value = struggle_iberia_ending_compromise_decision_region_interloper_value
	divide = struggle_iberia_ending_ending_decision_region_total_value
	multiply = 100
}

# Counter for independent king or higher Involved rulers
struggle_iberia_ending_compromise_decision_independent_counter_value = {
	value = 0
	struggle:iberian_struggle = {
		every_involved_ruler = {
			limit = {
				this != root
				top_liege = this
				primary_title = {
					is_mercenary_company = no
					is_holy_order = no
					tier >= tier_kingdom
				}
			}
			add = 1
		}
	}
}

# Counter for inter-Involved character wars
struggle_iberia_ending_compromise_decision_war_counter_value = {
	struggle:iberian_struggle = {
		every_involved_ruler = {
			limit = {
				top_liege = this
				primary_title = { is_mercenary_company = no }
				primary_title = { is_holy_order = no }
				any_primary_war_enemy = {
					top_liege = this
					any_character_struggle = {
						involvement = involved
						is_struggle_type = iberian_struggle
					}
					primary_title = { is_holy_order = no }
					primary_title = { is_mercenary_company = no }
				}
			}
			add =  {
				value = 0
				if = {
					 limit = {
					 	any_character_war = {
							OR = {
								AND = {
									primary_attacker = prev
									primary_defender = {
										any_character_struggle = {
											involvement = involved
											is_struggle_type = iberian_struggle
										}
										top_liege = this
										primary_title = { is_mercenary_company = no }
									}
								}
								AND = {
									primary_defender = prev
									primary_attacker = {
										any_character_struggle = {
											involvement = involved
											is_struggle_type = iberian_struggle
										}
										top_liege = this
										primary_title = { is_mercenary_company = no }
									}
								}
							}
						}
					 }
					add = 0.5 # they are both primary participant so they will add 0.5 each
				}
				else = {
					add = 1 # only one of them is primary participant, so we need to add 1
				}
			}
		}
	}
}

# Paramameter for percentage of Iberia that you cannot control
fp2_struggle_compromise_owned_percent_value = 50

# Uses above to plug in to script as a decimal
fp2_struggle_compromise_owned_percent_decimal_value = {
	value = fp2_struggle_compromise_owned_percent_value
	divide = 100
	max = 1
}

# Paramameter for percentage of Iberia that no other Involved ruler can control
fp2_struggle_compromise_involved_percent_value = 50

# Uses above to plug in to script as a decimal
fp2_struggle_compromise_involved_percent_decimal_value = {
	value = fp2_struggle_compromise_involved_percent_value
	divide = 100
	max = 1
}

# Paramameter for percentage of Iberia that no Uninvolved ruler can control
fp2_struggle_compromise_uninvolved_percent_value = 25

# Uses above to plug in to script as a decimal
fp2_struggle_compromise_uninvolved_percent_decimal_value = {
	value = fp2_struggle_compromise_uninvolved_percent_value
	divide = 100
	max = 1
}

### Conciliation

# Counter for allied Involved rulers
struggle_iberia_ending_conciliation_decision_alliance_counter_value = {
	value = 0
	struggle:iberian_struggle = {
		every_involved_ruler = {
			limit = {
				this != root
				top_liege = this
				is_landless_adventurer = no
				primary_title = { is_holy_order = no }
				primary_title = { is_mercenary_company = no }
				is_allied_to = root
			}
			add = 1
		}
	}
}

# Parameter for num de jure kingdoms of Iberia must be owned
fp2_struggle_conciliation_kingdom_total_value = 1

# Parameter for cultural acceptance gain
fp2_struggle_conciliation_culture_acceptance_value = 50

fp2_struggle_secure_iberian_foothold_years_value = 15

fp2_struggle_secure_iberian_foothold_faith_target_percent_value = 50

fp2_struggle_secure_iberian_foothold_faith_total_value = {
	if = {
		limit = { exists = scope:iberian_kingdom_temp }
		scope:iberian_kingdom_temp = {
			every_de_jure_county = { add = 1 }
		}
	}
	min = 1
}

fp2_struggle_secure_iberian_foothold_faith_value = {
	value = 0
	if = {
		limit = { exists = scope:iberian_kingdom_temp }
		scope:iberian_kingdom_temp = {
			every_de_jure_county = {
				limit = { faith = holder.top_liege.faith }
				add = 1
			}
		}
	}
	min = 1
}

fp2_struggle_secure_iberian_foothold_faith_percent_value = {
	value = fp2_struggle_secure_iberian_foothold_faith_value
	divide = fp2_struggle_secure_iberian_foothold_faith_total_value
	multiply = 100
}

##### Religion values #####

# Total Iberian counties of my Religion
fp2_struggle_secure_iberian_foothold_religion_total_value = {
	value = 0
	every_county_in_region = {
		region = world_europe_west_iberia
		limit = { religion = root.religion }
		add = 1
	}
}

# Held Iberian counties of my Religion
fp2_struggle_secure_iberian_foothold_religion_owned_value = {
	value = 0
	every_county_in_region = {
		region = world_europe_west_iberia
		limit = {
			religion = root.religion
			holder.top_liege = root
		}
		add = 1
	}
}

# Percentage owned Iberian counties of my Religion
fp2_struggle_secure_iberian_foothold_religion_percent_value = {
	value = fp2_struggle_secure_iberian_foothold_religion_owned_value
	divide = fp2_struggle_secure_iberian_foothold_religion_total_value
	multiply = 100
	min = 1
}

# Target percentage owned Iberia counties of my Religion
fp2_struggle_secure_iberian_foothold_religion_target_percent_value = 50

fp2_struggle_secure_iberian_foothold_religion_target_percent_decimal_value = {
	value = fp2_struggle_secure_iberian_foothold_religion_target_percent_value
	divide = 100
}

##### Outsider values #####

# Target percentage owned counties of Iberia
fp2_struggle_secure_iberian_foothold_outsider_target_percent_value = 33

fp2_struggle_secure_iberian_foothold_outsider_target_percent_decimal_value = {
	value = fp2_struggle_secure_iberian_foothold_outsider_target_percent_value
	divide = 100
}

# Decimal target percentage owned counties of Iberia
fp2_struggle_secure_iberian_foothold_outsider_percent_decimal_value = {
	value = fp2_struggle_secure_iberian_foothold_outsider_percent_value
	divide = 100
	max = 1
}

# Percentage owned counties of Iberia
fp2_struggle_secure_iberian_foothold_outsider_percent_value = {
	value = fp2_struggle_secure_iberian_foothold_outsider_value
	divide = fp2_struggle_secure_iberian_foothold_outsider_total_value
	multiply = 100
}

fp2_struggle_secure_iberian_foothold_outsider_total_value = {
	value = 0
	every_county_in_region = {
		region = world_europe_west_iberia
		add = 1
	}
}

fp2_struggle_secure_iberian_foothold_outsider_value = {
	value = 0
	every_county_in_region = {
		region = world_europe_west_iberia
		limit = { holder.top_liege = root }
		add = 1
	}
}

fp2_enforce_truce_war_score_value = 25

fp2_enforce_truce_duration_value = 5

fp2_bargain_fealty_interaction_already_losing_value = 25

fp2_bargain_fealty_half_realm_size_value = {
	value = scope:recipient.realm_size
	divide = 2
}

fp2_bargain_fealty_half_max_strength_value = {
	value = scope:actor.max_military_strength
	divide = 2
}

##################################################
# Miscellaneous

# We want them to always be born in 795 or so.
fp2_lyonese_monk_age_value = {
	value = current_year
	add = -795
}

fp2_lyonese_monk_conclave_cost_value = major_piety_value

fp2_lyonese_monk_conversion_bonus_root_value = 0.5

fp2_lyonese_monk_conversion_bonus_actual_value = {
	value = court_chaplain_conversion_base_total
	multiply = fp2_lyonese_monk_conversion_bonus_root_value
}


floored_development_value = {
	value = development_level
	floor = yes
}

floored_current_development_value = {
	value = var:current_development_level
	floor = yes
}

pt_sum_small_value = {
	value = 0
	add = {
		# If scope:actor makes more money, we use them as a base.
		if = {
			limit = { scope:actor.yearly_character_income > scope:recipient.yearly_character_income }
			add = scope:actor.purchase_truce_interaction_small_sum
		}
		# Otherwise, we take scope:recipient.
		else = { add = scope:recipient.purchase_truce_interaction_small_sum }
	}
	# Struggle Reduction
	if = {
		limit = {
			any_character_struggle = {
				involvement = involved
				has_struggle_phase_parameter = struggle_cheaper_buy_truce
				is_secondary_character_involvement_involved_trigger = {
					CHAR = scope:recipient
				}
			}
		}
		multiply = 0.5
	}
	if = { # double the cost if you're just buying off a nomad without any prerequisites
		limit = { fp2_purchase_truce_interaction_soft_requirements_trigger = no }
		multiply = 2
	}
}

pt_sum_medium_value = {
	value = 0
	# If scope:actor makes more money, we use them as a base.
	if = {
		limit = { scope:actor.yearly_character_income > scope:recipient.yearly_character_income }
		add = scope:actor.purchase_truce_interaction_medium_sum
	}
	# Otherwise, we take scope:recipient.
	else = { add = scope:recipient.purchase_truce_interaction_medium_sum }

	# Struggle Reduction
	if = {
		limit = {
			any_character_struggle = {
				involvement = involved
				has_struggle_phase_parameter = struggle_cheaper_buy_truce
				is_secondary_character_involvement_involved_trigger = {
					CHAR = scope:recipient
				}
			}
		}
		multiply = 0.5
	}
	if = { # double the cost if you're just buying off a nomad without any prerequisites
		limit = { fp2_purchase_truce_interaction_soft_requirements_trigger = no }
		multiply = 2
	}
}

pt_sum_large_value = {
	value = 0
	# If scope:actor makes more money, we use them as a base.
	if = {
		limit = { scope:actor.yearly_character_income > scope:recipient.yearly_character_income }
		add = scope:actor.purchase_truce_interaction_major_sum
	}
	# Otherwise, we take scope:recipient.
	else = { add = scope:recipient.purchase_truce_interaction_major_sum }

	# Struggle Reduction
	if = {
		limit = {
			any_character_struggle = {
				involvement = involved
				has_struggle_phase_parameter = struggle_cheaper_buy_truce
				is_secondary_character_involvement_involved_trigger = {
					CHAR = scope:recipient
				}
			}
		}
		multiply = 0.5
	}
	if = { # double the cost if you're just buying off a nomad without any prerequisites
		limit = { fp2_purchase_truce_interaction_soft_requirements_trigger = no }
		multiply = 2
	}
}
