﻿#############
# Diarchy Scripted Values
#############

diarch_loyalty_score_standard_values_general_culture_value = {
	culture = {
		# +++ Malleable Subjects.
		if = {
			limit = { has_cultural_tradition = tradition_fp2_malleable_subjects }
			add = {
				desc = diarch_loyalty_score.regency.tradition_fp2_malleable_subjects
				value = diarch_loyalty_score_add_major_gain
			}
		}
		# +++ Recognition of Talent & lowborn.
		if = {
			limit = {
				has_cultural_tradition = tradition_talent_acquisition
				root = { is_lowborn = yes }
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_talent_acquisition
				value = diarch_loyalty_score_add_major_gain
			}
		}
		# ++/-- Astute Diplomats & they like or dislike their liege.
		if = {
			limit = { has_cultural_tradition = tradition_astute_diplomats }
			# If they like you, they work loyally.
			if = {
				limit = {
					root = {
						opinion = {
							target = liege
							value >= 1
						}
					}
				}
				add = {
					desc = diarch_loyalty_score.regency.tradition_astute_diplomats.positive
					value = diarch_loyalty_score_add_medium_gain
				}
			}
			# If they don't, they work against you.
			else_if = {
				limit = {
					root = {
						opinion = {
							target = liege
							value <= -1
						}
					}
				}
				add = {
					desc = diarch_loyalty_score.regency.tradition_astute_diplomats.negative
					value = diarch_loyalty_score_add_medium_loss
				}
			}
			# Else neutral, so they're ambivalent.
		}
		# ++ Ruling Caste & is liege.
		if = {
			limit = {
				root.liege.culture = {
					has_cultural_tradition = tradition_ruling_caste
					# But only apply it to diff-cultured characters.
					this != root.culture
				}
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_ruling_caste
				value = diarch_loyalty_score_add_medium_gain
			}
		}
		# ++ Family Business & extended family.
		if = {
			limit = {
				has_cultural_tradition = tradition_family_entrepreneurship
				root = { is_close_or_extended_family_of = liege }
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_family_entrepreneurship
				value = diarch_loyalty_score_add_medium_gain
			}
		}
		# + Hereditary Hierarchy.
		if = {
			limit = { has_cultural_tradition = tradition_hereditary_hierarchy }
			add = {
				desc = diarch_loyalty_score.regency.tradition_hereditary_hierarchy
				value = diarch_loyalty_score_add_minor_gain
			}
		}
		# + Tribal Unity & same-house.
		if = {
			limit = {
				has_cultural_tradition = tradition_tribe_unity
				exists = root.liege.house
				root.house ?= root.liege.house
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_tribe_unity
				value = diarch_loyalty_score_add_minor_gain
			}
		}
		# + Strong Kinship & same-house.
		if = {
			limit = {
				has_cultural_tradition = tradition_strong_kinship
				exists = root.liege.house
				root.house ?= root.liege.house
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_strong_kinship
				value = diarch_loyalty_score_add_minor_gain
			}
		}
		# +/- Chivalry & variable depending on "honour".
		if = {
			limit = { has_cultural_tradition = tradition_chivalry }
			# If dishonourable...
			if = {
				limit = {
					root.liege = {
						OR = {
							tyranny >= 1
							prestige_level <= 0
							has_any_shunned_or_criminal_trait_in_faith_trigger = {
								CHARACTER = liege
								FAITH = root.faith
							}
							# We avoid the actual ai_honour stat because it's a bit less exposed to the player.
						}
					}
				}
				add = {
					desc = diarch_loyalty_score.regency.tradition_chivalry.loss
					value = diarch_loyalty_score_add_minor_loss
				}
			}
			# Else, honourable enough.
			else = {
				add = {
					desc = diarch_loyalty_score.regency.tradition_chivalry.gain
					value = diarch_loyalty_score_add_minor_gain
				}
			}
		}
		# + Philosopher Culture & learning education.
		if = {
			limit = {
				has_cultural_tradition = tradition_philosopher_culture
				root = { has_trait = education_learning }
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_philosopher_culture
				value = diarch_loyalty_score_add_minor_gain
			}
		}
		# -1 (and only 1) if Vegetarian & liege isn't also vegetarian.
		## This one goes out to our dear D.M. for everything he's ever said at lunch.
		if = {
			limit = {
				has_cultural_tradition = tradition_vegetarianism
				# ^We're deliberately only checking culture rather than faith here — not wanting to mock religious convictions.
				## Just personal ones.
				root.liege = { is_vegetarian_trigger = no }
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_vegetarianism
				value = -1
			}
		}
		# -- Eye for an Eye.
		if = {
			limit = { has_cultural_tradition = tradition_eye_for_an_eye }
			add = {
				desc = diarch_loyalty_score.regency.tradition_eye_for_an_eye
				value = diarch_loyalty_score_add_medium_loss
			}
		}
		# -- Byzantine Traditions.
		if = {
			limit = { has_cultural_tradition = tradition_byzantine_succession }
			add = {
				desc = diarch_loyalty_score.regency.tradition_byzantine_succession
				value = diarch_loyalty_score_add_medium_loss
			}
		}
		# -- EP3 Byzantines
		if = {
			limit = { has_cultural_tradition = tradition_ep3_palace_politics }
			add = {
				desc = diarch_loyalty_score.regency.tradition_ep3_palace_politics
				value = diarch_loyalty_score_add_medium_loss
			}
		}
		# -- Warrior Culture & non-martially educated lieges.
		if = {
			limit = {
				has_cultural_tradition = tradition_warrior_culture
				root.liege = {
					NOR = {
						has_trait = education_martial
						has_focus = education_martial
						##### Start More Lifestyles Submod Education Modifications
						has_trait = education_nht_prowess
						has_focus = education_nht_prowess	
						##### End More Lifestyles Submod Education Modifications						
					}
				}
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_warrior_culture
				value = diarch_loyalty_score_add_medium_loss
			}
		}
		# --- Practiced Pirates.
		if = {
			limit = { has_cultural_tradition = tradition_practiced_pirates }
			add = {
				desc = diarch_loyalty_score.regency.tradition_practiced_pirates
				value = diarch_loyalty_score_add_major_loss
			}
		}
		# --- Bound by Faith & different faiths.
		if = {
			limit = {
				has_cultural_tradition = tradition_faith_bound
				root.faith != root.liege.faith
			}
			add = {
				desc = diarch_loyalty_score.regency.tradition_faith_bound
				value = diarch_loyalty_score_add_major_loss
			}
		}
	}
}


hunt_entourage_extras_set_weighting_value = {
	value = 0
	if = {
		limit = {
			is_available_healthy_adult = yes
			is_designated_diarch = no
			OR = {
				is_knight_of = scope:host
				has_trait = education_martial
				has_trait = education_martial_prowess
				##### Start More Lifestyles Submod Education Modifications				
				has_trait = education_nht_prowess				
				has_trait = lazy
				prowess >= decent_skill_rating
			}
			trigger_if = {
				limit = {
					NOT = { scope:special_option ?= flag:hunt_type_falconry }
				}
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:host }
			}
			trigger_else = { always = yes }
		}
		# Base
		add = 150
	}
}

# 	The end result of this number MUST be between 0 and 5, otherwise the game
# 	will crash due to being used in the UI to allocate a segmented progress bar
contest_type_aptitude_horse = {
	value = 0
	# Score
	if = {
		limit = {
			involved_activity ?= {
				OR = {
					has_current_phase = tournament_phase_horse_race
					has_current_phase = tournament_phase_joust
				}
			}
			exists = var:progress_to_victory_score
			var:progress_to_victory_score >= contest_progress_increase_medium_value
		}
		add = {
			value = 1
			if = {
				limit = { var:progress_to_victory_score >= contest_progress_increase_massive_value }
				add = 1
			}
			desc = tournament_aptitude.events
		}
	}
	else_if = {
		limit = {
			involved_activity ?= { has_current_phase = tournament_phase_melee }
			exists = var:progress_to_victory_score
			var:progress_to_victory_score >= contest_progress_increase_medium_value
		}
		add = {
			value = 0.5
			if = {
				limit = { var:progress_to_victory_score >= contest_progress_increase_massive_value }
				add = 0.5
			}
			desc = tournament_aptitude.events
		}
	}
	# Trait
	if = {
		limit = {
			has_trait_xp = {
				trait = tourney_participant
				track = horse
				value >= 25
			}
		}
		add = {
			value = 1
			if = {
				limit = {
					has_trait_xp = {
						trait = tourney_participant
						track = horse
						value >= 50
					}
				}
				add = 1
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = tourney_participant
						track = horse
						value >= 75
					}
				}
				add = 1
			}
			desc = tourney_participant_foot
		}
	}
	if = { # Prowess
		limit = {
			NOT = {
				has_trait_xp = {
					trait = tourney_participant
					track = foot
					value >= 25
				}
			}
			prowess >= medium_skill_rating
		}
		add = {
			value = 1
			if = {
				limit = { prowess >= high_skill_rating }
				add = 1
			}
			desc = prowess_concept
		}
	}
	if = { # Martial
		limit = {
			NOT = {
				has_trait_xp = {
					trait = tourney_participant
					track = foot
					value >= 25
				}
			}
			martial >= medium_skill_rating
		}
		add = {
			value = 1
			if = {
				limit = { martial >= high_skill_rating }
				add = 1
			}
			desc = martial_concept
		}
	}
	# Lifestyle & Genetic
	if = {
		limit = { has_trait = adventurer } #Bit of a stretch, I know
		add = {
			value = 1
			desc = trait_adventurer
		}
	}
	if = {
		limit = {
			OR = {
				has_trait = education_martial_prowess_1
				has_trait = education_martial_prowess_2
				has_trait = education_martial_prowess_3
				has_trait = education_martial_prowess_4
			}
		}
		add = {
			value = 1
			if = {
				limit = { has_trait = education_martial_prowess_2 }
				add = 1
			}
			else_if = {
				limit = { has_trait = education_martial_prowess_3 }
				add =  1
			}
			else_if = {
				limit = { has_trait = education_martial_prowess_4 }
				add = 1
			}
			desc = trait_education_martial_prowess
		}
	}
	##### Start More Lifestyles Submod Education Modifications
	if = {
		limit = {
			OR = {
				has_trait = education_nht_prowess_1
				has_trait = education_nht_prowess_2
				has_trait = education_nht_prowess_3
				has_trait = education_nht_prowess_4
			}
		}
		add = {
			value = 1
			if = {
				limit = { has_trait = education_nht_prowess_2 }
				add = 1
			}
			else_if = {
				limit = { has_trait = education_nht_prowess_3 }
				add =  1
			}
			else = {
				limit = { has_trait = education_nht_prowess_4 }
				add = 1
			}
			desc = trait_education_martial_prowess
		}
	}
	##### End More Lifestyles Submod Education Modifications
	# Disability & Misc.
	if = {
		limit = { has_trait = dwarf }
		add = {
			value = 1
			desc = trait_dwarf
		}
	}
	if = {
		limit = { has_trait = giant }
		add = {
			value = -1
			desc = trait_giant
		}
	}

	max = 5
	min = 0
}