﻿interactive_war_attacker_total_strength_value = {
	value = 0
	scope:war = {
		every_war_attacker = {
			add = max_military_strength
		}
	}
}

interactive_war_attacker_total_strength_value_times = {
	value = 0
	scope:war = {
		every_war_attacker = {
			add = max_military_strength
		}
	}
	multiply = 2
}

interactive_war_defender_total_strength_value = {
	value = 0
	scope:war = {
		every_war_defender = {
			add = max_military_strength
		}
	}
}

interactive_war_defender_total_strength_value_times = {
	value = 0
	scope:war = {
		every_war_defender = {
			add = max_military_strength
		}
	}
	multiply = 2
}

interactive_war_defender_total_strength_value_plus = {
	value = 6000
	scope:war = {
		every_war_defender = {
			add = max_military_strength
		}
	}
}

interactive_war_attacker_total_strength_value_plus = {
	value = 6000
	scope:war = {
		every_war_attacker = {
			add = max_military_strength
		}
	}
}

interactive_start_date = {
	value = game_start_date
}

interactive_tooltip_attacking_strength = {
	value = 0
	every_in_list = {
		list = interactive_attackers
		save_temporary_scope_as = vassal
		add = {
			value = scope:vassal.max_military_strength
		}
	}
}

interactive_tooltip_defending_strength = {
	value = 0
	every_in_list = {
		list = interactive_defenders
		save_temporary_scope_as = vassal
		add = {
			value = scope:vassal.max_military_strength
		}
	}
}

interactive_tooltip_vassal_strength = {
	value = 0
	add = {
		value = scope:vassal.max_military_strength
	}
}

interactive_tooltip_attacking_count = {
	value = 0
	every_in_list = {
		list = interactive_attackers
		add = 1
	}
}

interactive_admin_governor_military_strength = {
	value = 0
	scope:recipient = {
		add = max_military_strength
		divide = 5
	}
	divide = 2	# recipient gets less influence than actor spends
}

interactive_admin_governor_military_strength_negative = {
	value = 0
	scope:recipient = {
		add = max_military_strength
		divide = 5
	}
	multiply = -1
}

interactive_tooltip_attacking_bannermen_count = {
	value = 0
	every_in_list = {
		list = interactive_attackers_bannermen_refuses
		add = 1
	}
}

interactive_tooltip_defending_bannermen_count = {
	value = 0
	every_in_list = {
		list = interactive_defenders_bannermen_refuses
		add = 1
	}
}

interactive_request_vassal_support_military_strength_negative = {
	value = 0
	scope:recipient = {
		add = max_military_strength
		divide = 20
	}
	add = 100
	multiply = -1
}

stop_war_attacker_bribe_size = {
	value = medium_gold_value
	multiply = 4
}

interactive_tooltip_bannermen_mode_count = {
	value = 0
	scope:attacker = {
		every_vassal = {
			limit = {
				OR = {
					AND = {
						scope:attacker = {
							highest_held_title_tier < tier_empire
						}
						highest_held_title_tier >= tier_county
					}
					highest_held_title_tier >= tier_duchy
				}
				max_military_strength > 200
				is_landed = yes
				is_ai = yes
				is_capable_adult = yes
			}
			add = 1
		}
	}
}

interactive_tooltip_bannermen_defender_mode_count = {
	value = 0
	scope:defender = {
		every_vassal = {
			limit = {
				OR = {
					AND = {
						scope:defender = {
							highest_held_title_tier < tier_empire
						}
						highest_held_title_tier >= tier_county
					}
					highest_held_title_tier >= tier_duchy
				}
				max_military_strength > 200
				is_landed = yes
				is_ai = yes
				is_capable_adult = yes
			}
			add = 1
		}
	}
}

interactive_tooltip_admin_vassal_attacker_count = {
	value = 0
	scope:attacker = {
		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
				government_has_flag = government_has_influence
				is_landed = yes
				max_military_strength > 200
			}
			add = 1
		}
	}
}

interactive_tooltip_admin_vassal_defender_count = {
	value = 0
	scope:defender = {
		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
				government_has_flag = government_has_influence
				is_landed = yes
				max_military_strength > 200
			}
			add = 1
		}
	}
}

# uses current strength to see losses on tooltip
interactive_tooltip_bannermen_strength = {
	value = 0
	every_in_list = {
		list = interactive_bannermen
		save_temporary_scope_as = vassal
		add = {
			value = scope:vassal.current_military_strength
		}
	}
}

interactive_tooltip_bannermen_oathbreaker_strength = {
	value = 0
	every_in_list = {
		list = interactive_bannermen_oathbreaker
		save_temporary_scope_as = vassal
		add = 1
	}
}

interactive_tooltip_bannermen_count = {
	value = 0
	every_in_list = {
		list = interactive_bannermen
		add = 1
	}
}

# MIV: reduced CB prestige costs for AI if challenging AI is enabled (0 against players, 0.5 against other AI)
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
		}
	}
	# MIV added
	if = {
		limit = {
			has_game_rule = challenging_ai_enabled
			scope:attacker = {
				is_ai = yes
				prestige > 0
				prestige_level > 0
			}
			scope:defender = {
				is_ai = no
			}
		}
		multiply = {
			value = 0
			desc = hard_difficulty
		}
	}
	else_if = {
		limit = {
			has_game_rule = challenging_ai_enabled
			scope:attacker = {
				is_ai = yes
				prestige > 0
				prestige_level > 0
			}
		}
		multiply = {
			value = 0.5
			desc = hard_difficulty
		}
	}
}

# MIV: reduced CB piety costs for AI if challenging AI is enabled (0 against players, 0.5 against other AI)
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
	# MIV added
	if = {
		limit = {
			has_game_rule = challenging_ai_enabled
			scope:attacker = {
				is_ai = yes
				piety > 0
				piety_level > 0
			}
			scope:defender = {
				is_ai = no
			}
		}
		multiply = {
			value = 0
			desc = hard_difficulty
		}
	}
	else_if = {
		limit = {
			has_game_rule = challenging_ai_enabled
			scope:attacker = {
				is_ai = yes
				piety > 0
				piety_level > 0
			}
		}
		multiply = {
			value = 0.5
			desc = hard_difficulty
		}
	}
}

# MIV: game rule to disable dejure title creation
create_title_counties_percentage = {
	scope:title = {
		if = {
			limit = {
				has_game_rule = miv_title_creation_miv_enabled_empires
				tier = tier_empire
			}
			add = {
				value = 10
				desc = interactive_title_creation_desc
			}
		}
		if = {
			limit = {
				has_game_rule = miv_title_creation_miv_enabled_kingdoms
				OR = {
					tier = tier_empire
					tier = tier_kingdom
				}
			}
			add = {
				value = 10
				desc = interactive_title_creation_desc
			}
		}
		if = {
			limit = {
				OR = {
					tier = tier_duchy
					tier = tier_kingdom
				}
			}
			add = {
				value = 0.5
				desc = CREATE_TITLE_PERCENTAGE_BASE_DUCHY_KINGDOM
			}
			if = {
				limit = {
					# Do you have Legitimacy?
					root ?= {
						has_legitimacy = yes
					}
				}
				if = {
					limit = {
						root = {
							has_legitimacy_flag = extra_reduced_title_creation_cost
						}
					}
					add = {
						value = -0.25						#25%
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_EXTRA_REDUCED
					}
				}
				else_if = {
					limit = {
						root = {
							has_legitimacy_flag = very_reduced_title_creation_cost
						}
					}
					add = {
						value = -0.2						#30%
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_VERY_REDUCED
					}
				}
				else_if = {
					limit = {
						root = {
							has_legitimacy_flag = reduced_title_creation_cost
						}
					}
					add = {
						value = -0.15						#35%
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_REDUCED
					}
				}
				else = {
					#If you're level 2/1/0 or don't have Legitimacy you get no discounts
					add = {
						value = 0
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_NONE
					}
				}
			}
			else = {
				#If you're level 2/1/0 or don't have Legitimacy you get no discounts
				add = {
					# We add 0 with a 'desc', so we show up in the GUI and people understand legitimacy is a way to improve this
					value = 0
					desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_NONE
				}
			}
		}
		else_if = {
			#Smaller discounts for Empires
			limit = {
				tier = tier_empire
			}
			add = {
				value = 0.8
				desc = CREATE_TITLE_PERCENTAGE_BASE_EMPIRE
			}
			if = {
				limit = {
					# Do you have Legitimacy?
					root ?= {
						# MIV: added ? vanilla bug fix
						has_legitimacy = yes
					}
				}
				if = {
					limit = {
						root = {
							has_legitimacy_flag = extra_reduced_title_creation_cost
						}
					}
					add = {
						value = -0.15						#65%
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_EXTRA_REDUCED
					}
				}
				else_if = {
					limit = {
						root = {
							has_legitimacy_flag = very_reduced_title_creation_cost
						}
					}
					add = {
						value = -0.1						#70%
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_VERY_REDUCED
					}
				}
				else_if = {
					limit = {
						root = {
							has_legitimacy_flag = reduced_title_creation_cost
						}
					}
					add = {
						value = -0.05						#75%
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_REDUCED
					}
				}
				else = {
					#If you're level 1/0 or don't have Legitimacy you get no discounts
					add = {
						value = 0
						desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_NONE
					}
				}
			}
			else = {
				#If you're level 1/0 or don't have Legitimacy you get no discounts
				add = {
					# We add 0 with a 'desc', so we show up in the GUI and people understand legitimacy is a way to improve this
					value = 0
					desc = CREATE_TITLE_PERCENTAGE_LEGITIMACY_DISCOUNT_NONE
				}
			}
		}
	}
}

# MIV: reduce peasant levy size based on levy reduction rule
total_county_levies = {
	value = 0
	# Get the base levies from each province.
	every_in_de_jure_hierarchy = {
		limit = {
			tier = tier_barony
		}
		title_province = {
			add = building_levies
		}
	}
	# Levy size multipliers (excluding ruler-specific modifiers, such as Martial skill).
	multiply = {
		# 100% Levy Base
		value = 1
		# MIV: levy reduction settings
		if = {
			limit = {
				has_game_rule = less_levies_10
			}
			add = {
				add = 0.1
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_20
			}
			add = {
				add = 0.2
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_30
			}
			add = {
				add = 0.3
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_40
			}
			add = {
				add = 0.4
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_50
			}
			add = {
				add = 0.5
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_60
			}
			add = {
				add = 0.6
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_70
			}
			add = {
				add = 0.7
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_80
			}
			add = {
				add = 0.8
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_90
			}
			add = {
				add = 0.9
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_100
			}
			add = {
				add = 0.95
				multiply = -1
			}
		}
		if = {
			limit = {
				has_game_rule = less_levies_110
			}
			add = {
				add = 0.99
				multiply = -1
			}
		}
		# Adds bonus levies from Development (at base 20 development, +20% levies).
		add = {
			add = development_level
			multiply = 0.01
		}
		# Adds bonus levies from cultural innovations.
		if = {
			limit = {
				culture = {
					has_innovation = innovation_bannus
				}
			}
			add = 0.1
		}
	}
}

county_levies_to_raise = {
	value = total_county_levies
	# Will summon between 75% and 175% of total county levy strength, depending on how much they hate you (most commonly will be 95-110% though, scores between -20 and -35 are the most common)
	multiply = {
		value = county_opinion
		multiply = -0.01
		add = 0.5
	}
	min = {
		value = building_max_garrison
		multiply = 0.5		# 1.2
	}
}
