
# We separate out most of the guts of this cost multiplier to stop struggle CBs from double-dipping on costs and discounts.
common_cb_cost_multiplier_core = {
	value = 1
	# Bellum Justum Perk
	if = {
		limit = {
			scope:attacker = {
				has_perk = bellum_justum_perk
			}
		}
		multiply = {
			add = bellum_justum_discount_percentage
			divide = 100
			desc = CB_ATTACKER_BELLUM_JUSTUM
		}
	}
	# Dynasty Warfare Perk
	if = {
		limit = {
			scope:attacker = {
				has_dynasty = yes
				dynasty = {
					has_dynasty_perk = warfare_legacy_2
				}
			}
		}
		multiply = {
			value = warfare_legacy_2_discount
			desc = CB_ATTACKER_DYNASTY_WARFARE
		}
	}
	# Culture
	if = {
		limit = {
			scope:attacker = {
				culture = {
					has_cultural_parameter = cheaper_cbs
				}
			}
		}
		multiply = {
			value = 0.8
			desc = "CB_ATTACKER_CULTURE"
		}
	}

	if = {
		limit = {
			scope:attacker = { government_has_flag = government_is_tribal }
		}
		multiply = {
			value = 0.5
			desc = CB_TRIBAL_COST
		}
	}
	
	# Clan Unity modifiers
	if = {
		limit = {
			scope:attacker = {
				government_has_flag = government_is_clan
				exists = scope:attacker.house
			}
		}
		if = {
			limit = {
				scope:attacker.house = {
					has_house_unity_parameter = unity_antagonistic_cb_cost
				}
			}
			multiply = {
				value = unity_antagonistic_cb_cost_value
				desc = CB_UNITY_COST
			}
		}
		if = {
			limit = {
				scope:attacker.house = {
					has_house_unity_parameter = unity_competitive_cb_cost
				}
			}
			multiply = {
				value = unity_competitive_cb_cost_value
				desc = CB_UNITY_COST
			}
		}
		if = {
			limit = {
				scope:attacker.house = {
					has_house_unity_parameter = unity_friendly_cb_cost
				}
			}
			multiply = {
				value = unity_friendly_cb_cost_value
				desc = CB_UNITY_COST
			}
		}
		if = {
			limit = {
				scope:attacker.house = {
					has_house_unity_parameter = unity_harmonious_cb_cost
				}
			}
			multiply = {
				value = unity_harmonious_cb_cost_value
				desc = CB_UNITY_COST
			}
		}
	}

	# Special increase for Persia if Concession is reached
	if = {
		limit = {
			exists = global_var:fp3_struggle_ending
			global_var:fp3_struggle_ending = flag:fp3_struggle_concession_ending
			OR = {
				scope:attacker = {
					capital_province ?= {
						geographical_region = world_persian_empire
					}
				}
				scope:defender = {
					capital_province ?= {
						geographical_region = world_persian_empire
					}
				}
			}
		}
		multiply = {
			value = 1
			add = {
				if = {
					limit = {
						scope:attacker = {
							house ?= {
								OR = {
								 	has_house_modifier = fp3_house_modifier_frontier_ambitions
									has_house_modifier = fp3_house_modifier_rebuilding_efforts
								}
							}
						}
					}
					add = 0.5
				}
				if = {
					limit = {
						scope:defender = {
							house ?= {
								OR = {
								 	has_house_modifier = fp3_house_modifier_frontier_ambitions
									has_house_modifier = fp3_house_modifier_rebuilding_efforts
								}
							}
						}
					}
					add = 0.5
				}
			}
			desc = CB_STRUGGLE_CONCESSION_ENDING
		}
	}

	if = {
		limit = {
			scope:attacker = {
				house ?= { has_house_modifier = fp3_house_modifier_frontier_ambitions }
			}
			NOT = {
				scope:defender = {
					capital_province ?= {
						geographical_region = world_persian_empire
					}
				}
			}
		}
		multiply = 0.5
	}

	if = {
		limit = {
			has_game_rule = no_cost_casus_belli_costs
		}
		multiply = {
			value = 0
			desc = CB_GAME_RULE_NO_COST
		}
	}

	if = {
		limit = {
			scope:attacker = {
				ai_should_get_conqueror_bonuses = yes
			}
		}
		multiply = {
			value = 0
			desc = ai_conqueror_modifier
		}
	}
}

common_cb_cost_multiplier = {
	value = common_cb_cost_multiplier_core
	# Struggle Multipliers
	if = {
		limit = {
			scope:attacker = {
				OR = {
					any_character_struggle = {
						involvement = involved
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_wars_in_struggle_region_cheaper_costs }
					}
					any_character_struggle = {
						involvement = interloper
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_wars_in_struggle_region_cheaper_costs }
					}
				}
			}
		}
		multiply = {
			value = 0.5
			desc = CB_STRUGGLE_PHASE_DISCOUNT
		}
	}
}


##### Piety Costs

# Multipliers

# We separate out most of the guts of this cost multiplier to stop struggle CBs from double-dipping on costs and discounts.
common_cb_piety_cost_multiplier_core = {
	value = 1
	# Faith Doctrine Piety Discounts
	if = {
		limit = {
			scope:attacker.faith = {
				has_doctrine_parameter = divine_destiny_holy_war_cost_reduction
			}
		}
		multiply = {
			value = 0.5
			desc = CB_DIVINE_DESTINY_COST
		}
	}
	# Innovation Piety Discounts
	if = {
		limit = {
			scope:attacker = {
				culture = {
					has_innovation = innovation_reconquista
				}
			}
		}
		multiply = {
			value = 0.9
			desc = CB_RECONQUISTA_COST
		}
	}
	# Vassal contract in-realm cost reduction
	if = {
		limit = {
			scope:attacker = {
				is_independent_ruler = no
				vassal_contract_has_flag = vassal_contract_war_override
				liege = scope:defender.liege
			}
		}
		multiply = {
			value = war_declaration_rights_allowed_cost_reduction
			desc = "CB_ATTACKER_VASSAL_CONTRACT"
		}
	}
	# Someone in the target region sacrificed your HoF.
	if = {
		limit = {
			scope:defender = {
				has_variable_list = humsacd_hofs
				is_target_in_variable_list = {
					name = humsacd_hofs
					target = scope:attacker.faith
				}
			}
		}
		multiply = {
			value = religious_cb_piety_discount_against_hof_humsac
			desc = "CB_ATTACKER_HOF_HUMSACD"
		}
	}
}

common_cb_piety_cost_multiplier_sans_struggles = {
	value = common_cb_piety_cost_multiplier_core
	# Common multiplier
	multiply = common_cb_cost_multiplier_core
}

common_cb_piety_cost_multiplier = {
	value = common_cb_piety_cost_multiplier_core
	# Struggle Multipliers
	## Generic modifiers.
	if = {
		limit = {
			scope:attacker = {
				OR = {
					any_character_struggle = {
						involvement = involved
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_wars_in_struggle_region_cheaper_piety_costs }
					}
					any_character_struggle = {
						involvement = interloper
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_wars_in_struggle_region_cheaper_piety_costs }
					}
				}
			}
		}
		multiply = {
			value = 0.5
			desc = CB_STRUGGLE_PHASE_DISCOUNT
		}
	}

	# Common multiplier
	multiply = common_cb_cost_multiplier_core
}

holy_war_cb_piety_cost_multiplier = {
	value = 1

	if = {
		limit = {
			scope:attacker = {
				faith = { has_doctrine_parameter = cheaper_holy_wars_active }
			}
		}
		multiply = {
			value = 0.8
			desc = CB_REDUCED_HOLY_WAR_COST
		}
	}

	# Ghazi reduction
	if = {
		limit = {
			scope:attacker = {
				is_independent_ruler = no
				vassal_contract_has_flag = vassal_contract_cheaper_religious_war
			}
		}
		multiply = {
			value = ghazi_religious_war_cost_reduction
			desc = "CB_ATTACKER_VASSAL_CONTRACT"
		}
	}
}

# Base Costs
common_cb_impious_piety_cost = {
	if = { # Attacking your HoF is impious
		limit = {
			exists = scope:attacker.faith.religious_head
			scope:attacker.faith.religious_head = scope:defender
		}
		if = {
			limit = {
				scope:attacker.faith = {
					has_doctrine = doctrine_spiritual_head
				}
			}
			add = {
				value = massive_piety_value
				desc = CB_ATTACKER_HOF
			}
		}
		else = {
			add = {
				value = medium_piety_value
				desc = CB_ATTACKER_HOF
			}
		}
	}
	if = {
		limit = {
			scope:attacker.faith = scope:defender.faith
			scope:defender = {
				government_has_flag = government_is_theocracy
			}
		}
		add = {
			value = medium_piety_value
			desc = CB_ATTACKER_THEOCRACY
		}
	}
}

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

##### Prestige Costs

# Multipliers
# We separate out most of the guts of this cost multiplier to stop struggle CBs from double-dipping on costs and discounts.
common_cb_prestige_cost_multiplier_core = {
	value = 1
	# Innovation Prestige Discounts
	multiply = {
		value = {
			value = 1
			if = {
				limit = {
					scope:attacker = {
						culture = {
							has_innovation = innovation_chronicle_writing
						}
					}
				}
				add = -0.1
			}
			if = {
				limit = {
					scope:attacker = {
						culture = {
							has_innovation = innovation_land_grants
						}
					}
				}
				add = -0.1
			}
			if = {
				limit = {
					scope:attacker = {
						culture = {
							has_innovation = innovation_rightful_ownership
						}
					}
				}
				add = -0.1
			}
		}
		desc = CB_ATTACKER_INNOVATIONS
	}

	# Vassal contract in-realm cost reduction
	if = {
		limit = {
			scope:attacker = {
				is_independent_ruler = no
				vassal_contract_has_flag = vassal_contract_war_override
				liege = scope:defender.liege
			}
		}
		multiply = {
			value = war_declaration_rights_allowed_cost_reduction
			desc = "CB_ATTACKER_VASSAL_CONTRACT"
		}
	}

	# Ghazi extra cost
	if = {
		limit = {
			scope:attacker = {
				is_independent_ruler = no
				vassal_contract_has_flag = vassal_contract_increase_prestige_cb_cost
			}
		}
		multiply = {
			value = 1
			add = ghazi_prestige_cost_increments
			desc = "CB_ATTACKER_VASSAL_CONTRACT"
		}
	}
}

common_cb_prestige_cost_multiplier_sans_struggles = {
	value = common_cb_prestige_cost_multiplier_core
	# Common modifier
	multiply = common_cb_cost_multiplier_core
}

common_cb_prestige_cost_multiplier = {
	value = common_cb_prestige_cost_multiplier_core
	# Struggle Multipliers
	## Discounts
	if = {
		limit = {
			# Pre-filter struggle CB types, as we don't want to double-modify their costs. Makes for weird balancing.
			# And then the main event.
			scope:attacker = {
				OR = {
					any_character_struggle = {
						involvement = involved
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_wars_in_struggle_region_cheaper_prestige_costs }
					}
					any_character_struggle = {
						involvement = interloper
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_wars_in_struggle_region_cheaper_prestige_costs }
					}
				}
			}
		}
		multiply = {
			value = 0.5
			desc = CB_STRUGGLE_PHASE_DISCOUNT
		}
	}
	## Surcharges
	if = {
		limit = {
			# Pre-filter struggle CB types, as we don't want to double-modify their costs. Makes for weird balancing.
			# And then the main event.
			scope:attacker = {
				OR = {
					any_character_struggle = {
						involvement = involved
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_diff_faith_wars_in_struggle_region_more_expensive_prestige_costs }
					}
					any_character_struggle = {
						involvement = interloper
						is_struggle_parameter_active_variable_cb_target_secondary_county_trigger = { PARAMETER = involved_or_interloper_diff_faith_wars_in_struggle_region_more_expensive_prestige_costs }
					}
				}
			}
		}
		multiply = {
			value = 1.5
			desc = CB_STRUGGLE_PHASE_SURCHARGE
		}
	}

	# Common modifier
	multiply = common_cb_cost_multiplier
}

# Base Costs
claim_cb_prestige_cost = {
	if = {
		# Prestige cost can vary significantly for personal claims, based on the situation(s) the claimant/defender are in.
		limit = { scope:claimant = scope:attacker }

		add = {
			every_in_list = {
				list = target_titles
				limit = { tier = tier_county }
				add = {
					value = 100
					if = {
						# 25% cheaper to take Pressed claims.
						limit = { scope:attacker = { has_strong_claim_on = prev } }
						add = -25
					}
				}
			}
			every_in_list = {
				list = target_titles
				limit = { tier = tier_duchy }
				add = {
					value = 200
					if = {
						# 25% cheaper to take Pressed claims.
						limit = { scope:attacker = { has_strong_claim_on = prev } }
						add = -50
					}
				}
			}
			every_in_list = {
				list = target_titles
				limit = { tier = tier_kingdom }
				add = {
					value = 400
					if = {
						# 25% cheaper to take Pressed claims.
						limit = { scope:attacker = { has_strong_claim_on = prev } }
						add = -100
					}
				}
			}
			every_in_list = {
				list = target_titles
				limit = { tier = tier_empire }
				add = {
					value = 800
					if = {
						# 25% cheaper to take Pressed claims.
						limit = { scope:attacker = { has_strong_claim_on = prev } }
						add = -200
					}
				}
			}

			# Player adventurers pay much more.
			if = {
				limit = {
					scope:attacker = {
						is_landless_adventurer = yes
						is_ai = no
					}
				}
				multiply = 10
			}

			desc = "CB_CLAIM_COST_TARGET_TITLES"
		}
		if = { # 50% cheaper for adults to take titles from child rulers.
			limit = {
				scope:attacker = { is_adult = yes }
				scope:defender = { is_adult = no }
			}
			multiply = {
				value = 0.5
				desc = "CB_COST_DEFENDER_IS_CHILD"
			}
		}
		else_if = { # 50% more expensive for children to take titles from adult rulers.
			limit = {
				scope:attacker = { is_adult = no }
				scope:defender = { is_adult = yes }
			}
			multiply = {
				value = 1.5
				desc = "CB_COST_ATTACKER_IS_CHILD"
			}
		}
		if = { # 50% cheaper to take titles from a dynasty member.
			limit = {
				scope:attacker.dynasty = scope:defender.dynasty
			}
			multiply = {
				value = 0.5
				desc = "CB_COST_SAME_DYNASTY"
			}
		}

		if = {
			limit = { # If claimant & target share a faith, cost is modified by gender preferences.
				scope:attacker.faith = scope:defender.faith
				scope:attacker = {
					sex_opposite_of = scope:defender
				}
				OR = {
					scope:attacker.faith = { has_doctrine = doctrine_gender_male_dominated }
					scope:attacker.faith = { has_doctrine = doctrine_gender_female_dominated }
				}
			}
			multiply = {
				if = {
					limit = {
						scope:attacker.faith = { has_doctrine = doctrine_gender_male_dominated }
					}
					if = {
						limit = { # 25% cheaper for men to press claims on female rulers in male-dominated societies.
							scope:attacker = { is_male = yes }
							scope:defender = { is_male = no }
						}
						value = 0.75
					}
					else_if = {
						limit = { # 25% more expensive for women to press claims on male rulers in male-dominated societies.
							scope:attacker = { is_male = no }
							scope:defender = { is_male = yes }
						}
						value = 1.25
					}
					else = {
						value = 1
					}
				}
				else_if = {
					limit = {
						scope:attacker.faith = { has_doctrine = doctrine_gender_female_dominated }
					}
					if = {
						limit = { # 25% cheaper for women to press claims on male rulers in female-dominated societies.
							scope:attacker = { is_male = no }
							scope:defender = { is_male = yes }
						}
						value = 0.75
					}
					else_if = {
						limit = { # 25% more expensive for men to press claims on female rulers in female-dominated societies.
							scope:attacker = { is_male = yes }
							scope:defender = { is_male = no }
						}
						value = 1.25
					}
					else = {
						value = 1
					}
				}
				else = {
					value = 1
				}
				desc = "CB_CLAIM_COST_GENDER_PREFERENCES"
			}
		}
		else_if = {
			# Taking titles from someone of another faith costs 25% more, regardless of gender preferences.
			limit = {
				NOT = {
					scope:attacker.faith = scope:defender.faith
				}
			}
			multiply = {
				value = 1.25
				desc = "CB_COST_DIFFERENT_FAITH"
			}
		}

		if = { # 25% more expensive to take titles from lower-tier rulers (pick on someone your own size!)
			limit = {
				scope:attacker.primary_title.tier > scope:defender.primary_title.tier
			}
			multiply = {
				value = 1.25
				desc = "CB_DEFNDER_LOWER_TIER"
			}
		}
	}
	else = {
		# When pressing a 3rd party's claims, the cost is mostly static.
		add = {
			every_in_list = {
				list = target_titles
				limit = { tier = tier_county }
				add = 250
			}
			every_in_list = {
				list = target_titles
				limit = { tier = tier_duchy }
				add = 500
			}
			every_in_list = {
				list = target_titles
				limit = { tier = tier_kingdom }
				add = 1000
			}
			every_in_list = {
				list = target_titles
				limit = { tier = tier_empire }
				add = 3000
			}
			desc = "CB_CLAIM_COST_TARGET_TITLES"
		}
		if = {
			limit = { # 100% more expensive to press claims for someone not of your Religion
				NOT = { scope:attacker.faith.religion = scope:claimant.faith.religion }
			}
			multiply = {
				value = 2
				desc = "CB_CLAIM_COST_CLAIMANT_DIFFERENT_RELIGION"
			}
		}
		if = {
			limit = { # 50% more expensive to press claims for someone not in your Dynasty
				NOT = { scope:attacker.dynasty = scope:claimant.dynasty }
			}
			multiply = {
				value = 1.5
				desc = "CB_CLAIM_COST_CLAIMANT_DIFFERENT_DYNASTY"
			}
		}
		else_if = {
			limit = { # 25% more expensive to press claims for someone not in your House
				NOT = { scope:attacker.house = scope:claimant.house }
			}
			multiply = {
				value = 1.25
				desc = "CB_CLAIM_COST_CLAIMANT_DIFFERENT_HOUSE"
			}
		}
	}
}

tribal_subjugation_cb_prestige_cost = {
	value = 0
	if = {
		limit = {
			NAND = {
				scope:attacker.faith.religious_head = scope:attacker
				scope:defender.faith = scope:attacker.faith
			}
		}
		add = {
			value = 1000
			desc = CB_BASE_COST
		}
	}
	if = {
		limit = {
			exists = scope:attacker.primary_title
			scope:attacker.primary_title = {
				tier = tier_kingdom
			}
		}
		multiply = {
			value = 1.5
			desc = CB_COST_RULES_KINGDOM
		}
	}
	else_if = {
		limit = {
			exists = scope:attacker.primary_title
			scope:attacker.primary_title = {
				tier = tier_empire
			}
		}
		multiply = {
			value = 2.5
			desc = CB_COST_RULES_EMPIRE
		}
	}

	multiply = common_cb_prestige_cost_multiplier
}

# Ancestor war base cost
ancestor_cb_prestige_cost = {
	add = {
		every_in_list = {
			list = target_titles
			limit = { tier = tier_county }
			add = {
				value = 100
			}
		}
		every_in_list = {
			list = target_titles
			limit = { tier = tier_duchy }
			add = {
				value = 200
			}
		}
		every_in_list = {
			list = target_titles
			limit = { tier = tier_kingdom }
			add = {
				value = 400
			}
		}
		every_in_list = {
			list = target_titles
			limit = { tier = tier_empire }
			add = {
				value = 800
			}
		}
		desc = "CB_CLAIM_COST_TARGET_TITLES"
	}
	if = { # 50% cheaper for adults to take titles from child rulers.
		limit = {
			scope:attacker = { is_adult = yes }
			scope:defender = { is_adult = no }
		}
		multiply = {
			value = 0.5
			desc = "CB_COST_DEFENDER_IS_CHILD"
		}
	}
	else_if = { # 50% more expensive for children to take titles from adult rulers.
		limit = {
			scope:attacker = { is_adult = no }
			scope:defender = { is_adult = yes }
		}
		multiply = {
			value = 1.5
			desc = "CB_COST_ATTACKER_IS_CHILD"
		}
	}
	if = { # 50% cheaper to take titles from a dynasty member.
		limit = {
			scope:attacker.dynasty = scope:defender.dynasty
		}
		multiply = {
			value = 0.5
			desc = "CB_COST_SAME_DYNASTY"
		}
	}

	if = {
		limit = { # If claimant & target share a faith, cost is modified by gender preferences.
			scope:attacker.faith = scope:defender.faith
			scope:attacker = {
				sex_opposite_of = scope:defender
			}
			OR = {
				scope:attacker.faith = { has_doctrine = doctrine_gender_male_dominated }
				scope:attacker.faith = { has_doctrine = doctrine_gender_female_dominated }
			}
		}
		multiply = {
			if = {
				limit = {
					scope:attacker.faith = { has_doctrine = doctrine_gender_male_dominated }
				}
				if = {
					limit = { # 25% cheaper for men to press claims on female rulers in male-dominated societies.
						scope:attacker = { is_male = yes }
						scope:defender = { is_male = no }
					}
					value = 0.75
				}
				else_if = {
					limit = { # 25% more expensive for women to press claims on male rulers in male-dominated societies.
						scope:attacker = { is_male = no }
						scope:defender = { is_male = yes }
					}
					value = 1.25
				}
				else = {
					value = 1
				}
			}
			else_if = {
				limit = {
					scope:attacker.faith = { has_doctrine = doctrine_gender_female_dominated }
				}
				if = {
					limit = { # 25% cheaper for women to press claims on male rulers in female-dominated societies.
						scope:attacker = { is_male = no }
						scope:defender = { is_male = yes }
					}
					value = 0.75
				}
				else_if = {
					limit = { # 25% more expensive for men to press claims on female rulers in female-dominated societies.
						scope:attacker = { is_male = yes }
						scope:defender = { is_male = no }
					}
					value = 1.25
				}
				else = {
					value = 1
				}
			}
			else = {
				value = 1
			}
			desc = "CB_CLAIM_COST_GENDER_PREFERENCES"
		}
	}
	else_if = {
		# Taking titles from someone of another faith costs 25% more, regardless of gender preferences.
		limit = {
			NOT = {
				scope:attacker.faith = scope:defender.faith
			}
		}
		multiply = {
			value = 1.25
			desc = "CB_COST_DIFFERENT_FAITH"
		}
	}

	if = { # 25% more expensive to take titles from lower-tier rulers (pick on someone your own size!)
		limit = {
			scope:attacker.primary_title.tier > scope:defender.primary_title.tier
		}
		multiply = {
			value = 1.25
			desc = "CB_DEFNDER_LOWER_TIER"
		}
	}
}

##### Multi-Currency Costs

struggle_cb_phase_modifier_cost = {
	# Phase modifiers.
	## Note that these aren't hooked up to the actual _parameters_ for tooltip reasons: we'd have to check what the phase is anyway, so we just check off of the phase to begin with and save ourselves a worthless parameter check.
	add = {
		value = 0
		# Cheap.
		if = {
			limit = {
				scope:attacker = {
					any_character_struggle = {
						involvement = involved
						is_struggle_type = iberian_struggle
						is_struggle_phase = struggle_iberia_phase_hostility
						is_secondary_character_involvement_either_trigger = { CHAR = scope:defender }
					}
				}
			}
			add = {
				every_in_list = {
					list = target_titles
					limit = { tier = tier_county }
					add = {
						value = minor_prestige_value
					}
				}
				multiply = {
					value = 0.9
					every_in_list = {
						list = target_titles
						limit = { tier = tier_county }
						add = {
							value = 0.1
						}
					}
					max = 2
				}
				desc = CB_COST_STRUGGLE_PHASE_HOSTILITY
			}
		}
		# Standard.
		if = {
			limit = {
				scope:attacker = {
					any_character_struggle = {
						involvement = involved
						is_struggle_type = iberian_struggle
						is_struggle_phase = struggle_iberia_phase_opportunity
						is_secondary_character_involvement_either_trigger = { CHAR = scope:defender }
					}
				}
			}
			add = {
				every_in_list = {
					list = target_titles
					limit = { tier = tier_county }
					add = {
						value = medium_prestige_value
					}
				}
				multiply = {
					value = 0.9
					every_in_list = {
						list = target_titles
						limit = { tier = tier_county }
						add = {
							value = 0.1
						}
					}
					max = 2
				}
				desc = CB_COST_STRUGGLE_PHASE_OPPORTUNITY
			}
		}
		# Expensive.
		if = {
			limit = {
				scope:attacker = {
					any_character_struggle = {
						involvement = involved
						is_struggle_type = iberian_struggle
						is_struggle_phase = struggle_iberia_phase_compromise
						is_secondary_character_involvement_either_trigger = { CHAR = scope:defender }
					}
				}
			}
			add = {
				every_in_list = {
					list = target_titles
					limit = { tier = tier_county }
					add = {
						value = major_prestige_value
					}
				}
				multiply = {
					value = 0.9
					every_in_list = {
						list = target_titles
						limit = { tier = tier_county }
						add = {
							value = 0.1
						}
					}
					max = 2
				}
				desc = CB_COST_STRUGGLE_PHASE_COMPROMISE
			}
		}
		if = {
			limit = {
				scope:attacker = {
					any_character_struggle = {
						involvement = involved
						is_struggle_type = iberian_struggle
						is_struggle_phase = struggle_iberia_phase_conciliation
						is_secondary_character_involvement_either_trigger = { CHAR = scope:defender }
					}
				}
			}
			add = {
				every_in_list = {
					list = target_titles
					limit = { tier = tier_county }
					add = {
						value = major_prestige_value
					}
				}
				multiply = {
					value = 0.9
					every_in_list = {
						list = target_titles
						limit = { tier = tier_county }
						add = {
							value = 0.1
						}
					}
					max = 2
				}
				desc = CB_COST_STRUGGLE_PHASE_CONCILIATION
			}
		}
		if = { # Post Struggle cost
			limit = {
				scope:attacker = {
					exists = scope:attacker.house
					scope:attacker.house = {
						OR ={
							has_house_modifier = fp2_struggle_hostility_house_combined_modifier
							has_house_modifier = fp2_struggle_hostility_house_faith_modifier
							has_house_modifier = fp2_struggle_hostility_house_culture_modifier
						}
					}
				}
			}
			add = {
				every_in_list = {
					list = target_titles
					limit = { tier = tier_county }
					add = {
						value = major_prestige_value
					}
				}
				multiply = {
					value = 0.9
					every_in_list = {
						list = target_titles
						limit = { tier = tier_county }
						add = {
							value = 0.1
						}
					}
					max = 2
				}
				desc = CB_BASE_COST
			}
		}
	}
}

common_claim_reduction_cost_multiplier_core = {
	value = 1
	# Claim discounts
	scope:attacker = {
		if = {
			limit = {
				any_claim = {
					is_in_list = target_titles
				}
			}
			multiply = {
				value = 1
				every_claim = {
					limit = { is_in_list = target_titles }
					multiply = 0.75
				}
				min = 0.2
				desc = CLAIMED_TITLES_DESC
			}
		}
		if = {
			limit = {
				any_claim = {
					de_jure_liege = { is_in_list = target_titles }
				}
			}
			multiply = {
				value = 1
				every_claim = {
					limit = { 
						de_jure_liege = { is_in_list = target_titles }
					}
					multiply = 0.9
				}
				min = 0.2
				desc = CLAIMED_DE_JURE_TITLES_DESC
			}
		}
	}
}
