﻿# AI-vs-AI balance values.

bdp_ai_vs_ai_career_score_value = {
	value = prowess
	add = {
		value = martial
		divide = 4
	}
}

# Prowess and Martial still lead. A little reputation helps careers gather steam.
bdp_ai_vs_ai_candidate_weight_value = {
	value = 100
	add = {
		value = prowess
		subtract = 10
		multiply = 2
	}
	add = {
		value = martial
		divide = 2
	}

	if = {
		limit = { has_variable = bdp_battlefield_reputation var:bdp_battlefield_reputation >= 60 }
		multiply = 3.5
	}
	else_if = {
		limit = { has_variable = bdp_battlefield_reputation var:bdp_battlefield_reputation >= 45 }
		multiply = 3
	}
	else_if = {
		limit = { has_variable = bdp_battlefield_reputation var:bdp_battlefield_reputation >= 30 }
		multiply = 2.5
	}
	else_if = {
		limit = { has_variable = bdp_battlefield_reputation var:bdp_battlefield_reputation >= 10 }
		multiply = 2
	}
	else_if = {
		limit = { has_variable = bdp_battlefield_reputation var:bdp_battlefield_reputation >= 1 }
		multiply = 1.5
	}

	if = {
		limit = { is_landed = yes highest_held_title_tier = tier_county }
		multiply = 0.70
	}
	else_if = {
		limit = { is_landed = yes highest_held_title_tier = tier_barony }
		multiply = 0.85
	}
	min = 1
}

# Soft cap only. Fighters stay eligible at one-quarter weight.
bdp_ai_vs_ai_soft_capped_candidate_weight_value = {
	value = bdp_ai_vs_ai_candidate_weight_value
	if = {
		limit = {
			has_variable = bdp_ai_vs_ai_lifetime_duels
			has_variable = bdp_ai_vs_ai_career_ceiling
			var:bdp_ai_vs_ai_lifetime_duels >= var:bdp_ai_vs_ai_career_ceiling
		}
		multiply = 0.25
	}
	min = 1
}

# Save the player's most hated targets before the AI starts picking.
bdp_ai_vs_ai_manual_reservation_value = {
	value = bdp_ai_vs_ai_candidate_weight_value
	if = {
		limit = { has_relation_nemesis = scope:bdp_ai_vs_ai_player_commander }
		add = 20000
	}
	else_if = {
		limit = { has_relation_rival = scope:bdp_ai_vs_ai_player_commander }
		add = 10000
	}
}

# Prowess shifts the odds, but both fighters always keep a 5% chance.
bdp_ai_vs_ai_side_a_victory_weight_value = {
	value = 50
	add = {
		value = scope:bdp_ai_vs_ai_actual_a.prowess
		subtract = scope:bdp_ai_vs_ai_actual_b.prowess
		multiply = 2
	}
	min = 5
	max = 95
}

bdp_ai_vs_ai_side_b_victory_weight_value = {
	value = 50
	add = {
		value = scope:bdp_ai_vs_ai_actual_b.prowess
		subtract = scope:bdp_ai_vs_ai_actual_a.prowess
		multiply = 2
	}
	min = 5
	max = 95
}

# Base: defeat 34 / mercy 25 / capture 30 / maim 5 / death 6. Personality and grudges move it from there.
bdp_ai_vs_ai_outcome_defeat_weight_value = {
	value = 34
	if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:peaceful } add = -3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:pragmatic } add = -5 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:arbitrary } add = -3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:callous } add = -3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:wrathful } add = -2 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:vengeful } add = -2 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:sadistic } add = -3 }
	if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_nemesis = scope:bdp_ai_vs_ai_loser } } add = -3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_rival = scope:bdp_ai_vs_ai_loser } } add = -2 }
	if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier >= tier_duchy } } add = -4 }
	else_if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier = tier_county } } add = -3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier = tier_barony } } add = -2 }
	min = 1
}

bdp_ai_vs_ai_outcome_mercy_weight_value = {
	value = 25
	if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:peaceful } add = 12 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:pragmatic } add = -5 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:arbitrary } add = -4 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:callous } add = -8 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:wrathful } add = -8 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:vengeful } add = -7 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:sadistic } add = -10 }
	if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_nemesis = scope:bdp_ai_vs_ai_loser } } add = -7 }
	else_if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_rival = scope:bdp_ai_vs_ai_loser } } add = -4 }
	if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier >= tier_duchy } } add = -4 }
	else_if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier = tier_county } } add = -3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier = tier_barony } } add = -1 }
	min = 1
}

bdp_ai_vs_ai_outcome_capture_weight_value = {
	value = 30
	if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:peaceful } add = -4 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:pragmatic } add = 12 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:callous } add = 3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:wrathful } add = -1 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:vengeful } add = -1 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:sadistic } add = -3 }
	if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier >= tier_duchy } } add = 8 }
	else_if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier = tier_county } } add = 6 }
	else_if = { limit = { scope:bdp_ai_vs_ai_loser = { is_landed = yes highest_held_title_tier = tier_barony } } add = 3 }
	min = 1
}

bdp_ai_vs_ai_outcome_maim_weight_value = {
	value = 5
	if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:peaceful } add = -3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:pragmatic } add = -1 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:arbitrary } add = 5 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:callous } add = 5 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:wrathful } add = 7 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:vengeful } add = 6 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:sadistic } add = 13 }
	if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_nemesis = scope:bdp_ai_vs_ai_loser } } add = 6 }
	else_if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_rival = scope:bdp_ai_vs_ai_loser } } add = 4 }
	min = 1
}

bdp_ai_vs_ai_outcome_death_weight_value = {
	value = 6
	if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:peaceful } add = -2 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:pragmatic } add = -1 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:arbitrary } add = 2 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:callous } add = 3 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:wrathful } add = 4 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:vengeful } add = 4 }
	else_if = { limit = { scope:bdp_ai_vs_ai_outcome_profile = flag:sadistic } add = 3 }
	if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_nemesis = scope:bdp_ai_vs_ai_loser } } add = 4 }
	else_if = { limit = { scope:bdp_ai_vs_ai_winner = { has_relation_rival = scope:bdp_ai_vs_ai_loser } } add = 2 }
	min = 1
}
