# Dependencies:
#	_basic_values.txt

# When their health drop too low and they're slated for death, a character will die within 15-50 days (based on DEATH_MAXIMUM_DELAY , DEATH_MINIMUM_DELAY and DEATH_CHECK_INTERVAL in defines)

######################
# Diseases
######################

#### TREATMENT PROCESS SPEED ###
#The speed should most likely be under the minimum delay between health check and death DEATH_MINIMUM_DELAY (15)

court_physician_search_min = 7
court_physician_search_max = 10

physician_treatment_delay_ruler_min = 2
physician_treatment_delay_ruler_max = 4
physician_treatment_delay_subject_min = 6 #Subject span should be after ruler span so ruler's own treatment is always first
physician_treatment_delay_subject_max = 15


### RECOVERY TIMES ###
minimum_recovery_time = 51 #Needs to be higher than 50 (the longest amount of days between health change and death, so that a character can't recover before they're slated to be checked for death)

ill_recovery_min = minimum_recovery_time
ill_recovery_max = 365

pneumonic_recovery_min = minimum_recovery_time
pneumonic_recovery_max = 250

gout_ridden_recovery_min = { #1 year
	value = minimum_recovery_time
	add = 314
}
gout_ridden_recovery_max = 10950 #30 years

smallpox_min_recovery_time = minimum_recovery_time
smallpox_max_recovery_time = 150

bubonic_plague_min_recovery_time = minimum_recovery_time
bubonic_plague_max_recovery_time = 150

measles_min_recovery_time = minimum_recovery_time
measles_max_recovery_time = 100

dysentery_min_recovery_time = minimum_recovery_time
dysentery_max_recovery_time = 100

ergotism_min_recovery_time = minimum_recovery_time
ergotism_max_recovery_time = 150

### CONTAGION ###
smallpox_contagion_min = 15 #If there is a physician, the character should be likely to meet them before first spread
smallpox_contagion_max = 65

bubonic_plague_contagion_min = 15 #If there is a physician, the character should be likely to meet them before first spread
bubonic_plague_contagion_max = 45 #Shorter than smallpox because you die faster



physician_contagion_prevention_value = {
	add = physician_base_skill_factor #Between 1 for average skill and 3 for high skill
	if = {
		limit = {
			AND = {
				has_trait = lifestyle_physician
				has_trait_xp = {
					trait = lifestyle_physician
					value >= 100
				}
			}
		}
		multiply = 2
	}
	else_if = {
		limit = {
			OR = {
				AND = {
					has_trait = lifestyle_physician
					has_trait_xp = {
						trait = lifestyle_physician
						value >= 50
					}
				}
				AND = {
					has_trait = lifestyle_mystic
					has_trait_xp = {
						trait = lifestyle_mystic
						value >= 100
					}
				}
			}
		}
		multiply = 1.5
	}
	else_if = {
		limit = {
			OR = {
				has_trait = lifestyle_physician
				AND = {
					has_trait = lifestyle_mystic
					has_trait_xp = {
						trait = lifestyle_mystic
						value >= 50
					}
				}
				has_trait = lifestyle_herbalist
			}
		}
		multiply = 1.3
	}
	else_if = {
		limit = {
			has_trait = lifestyle_mystic
		}
		multiply = 1.1
	}
	max = 7.5
}



#####################
# Treatments
#####################




######################
# Court Physician
######################

high_skill_court_physician_cost = {
	value = medium_gold_value
	if = {
		limit = {
			has_perk = anatomical_studies_perk
		}
		multiply = 0.5
	}
}

low_skill_court_physician_cost = {
	value = minor_gold_value
	if = {
		limit = {
			has_perk = anatomical_studies_perk
		}
		multiply = 0.5
	}
}

physician_base_skill_factor = {
	# 1 for an average learning skill character without traits
	# 0.2 min for low learning
	# ~3 for high skill character without traits
	add = learning
	divide = average_skill_rating #At average skill rating, we have a factor of 1
	if = {
		limit = { learning >= high_skill_rating } #At high skill rating, they become 30% better
		multiply = 1.3
	}
	min = 0.2
}



physician_safe_treatment_skill_factor = {
	# 1 for an average learning skill character without traits
	# 0.2 min for low learning
	# ~3 for high skill character without traits
	# ~12 for high skill character with best trait (physician_3)

	value = physician_base_skill_factor

	if = {
		limit = {
			AND = {
				has_trait = lifestyle_physician
				has_trait_xp = {
					trait = lifestyle_physician
					value >= 100
				}
			}
		}
		multiply = 4
	}
	else_if = {
		limit = {
			OR = {
				AND = {
					has_trait = lifestyle_physician
					has_trait_xp = {
						trait = lifestyle_physician
						value >= 50
					}
				}
				AND = {
					has_trait = lifestyle_mystic
					has_trait_xp = {
						trait = lifestyle_mystic
						value >= 100
					}
				}
			}
		}
		multiply = 2
	}
	else_if = {
		limit = {
			OR = {
				has_trait = lifestyle_physician
				AND = {
					has_trait = lifestyle_mystic
					has_trait_xp = {
						trait = lifestyle_mystic
						value >= 50
					}
				}
				has_trait = lifestyle_herbalist
			}
		}
		multiply = 1.5
	}
	else_if = {
		limit = {
			has_trait = lifestyle_mystic
		}
		multiply = 1.2
	}
	if = {
		limit = {
			liege ?= {
				domicile ?= {
					has_domicile_building_or_higher = bath_04
				}
			}
		}
		multiply = 1.4
	}
	else_if = {
		limit = {
			liege ?= {
				domicile ?= {
					has_domicile_building_or_higher = bath_01
				}
			}
		}
		multiply = 1.2
	}
	if = {
		limit = {
			exists = liege
			liege = { has_perk = anatomical_studies_perk }
		}
		multiply = 2
	}
}




#################
#	Weight
################
#These values are used to calculate the target weight that characters will trend towards once every three years

underweight_threshold = 0
overweight_threshold = 0

feast_weight_modifier_value = {
	add = 5
	# You have a lot of very desirable food
	if = {
		limit = {
			scope:activity.activity_host = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = {
					type = court_food_quality
					value >= 5
				}
			}
		}
		add = 3
	}
	# You have a lot of food in general
	else_if = {
		limit = {
			scope:activity.activity_host = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = {
					type = court_food_quality
					value >= 3
				}
			}
		}
		add = 2
	}
	# It's a smaller amount of food, but it's still a feast
	else_if = {
		limit = {
			scope:activity.activity_host = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = {
					type = court_food_quality
					value <= 1
				}
			}
		}
		add = -1
	}
}
hunt_weight_modifier_value = -4
cake_shaft_modifier_value = 4

character_weight_base_value = {
	add = 0
	#Any modifiers that will affect weight?
	if = {
		limit = {
			is_ai = yes # Players gaining weight is handled through health.5004
			has_character_modifier = gaining_weight_modifier
		}
		add = 35
	}
	if = {
		limit = {
			is_ai = yes # Players losing weight is handled through health.5005
			has_character_modifier = losing_weight_modifier
		}
		add = -35
	}
	if = {
		limit = {
			has_character_modifier = fasting_bad_modifier
		}
		add = -10
	}

	#Do you have a food taster? For some reason your plate is always weirdly empty since you employed them...
	if = {
		limit = {
			employs_court_position = food_taster_court_position
		}
		add = -5
	}

	#Any activities attended/other things that will affect weight?
	if = {
		limit = {
			has_variable = character_weight_variable
		}
		add = var:character_weight_variable
	}

	# PRISON/STARVATION
	if = {
		limit = {
			is_imprisoned = yes
		}
		if = {
			limit = {
				is_in_prison_type = dungeon
			}
			add = -75
		}
		else = {
			add = -30
		}
	}

	# DISEASE
	if = {
		limit = {
			has_trait = consumption
		}
		add = -75
	}
	if = {
		limit = {
			has_trait = cancer
		}
		add = -50
	}
	if = {
		limit = {
			has_trait = great_pox
		}
		add = -35
	}
	if = {
		limit = {
			has_trait = leper
		}
		add = -15
	}

	# Court amenities, weight gain from court_food_quality
	if = {
		limit = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner =  {
				amenity_level = { type = court_food_quality value = 3 }
			} 
		}
		add = 3
	}
	else_if = {
		limit = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner =  {
				amenity_level = { type = court_food_quality value = 4 }
			} 
		}
		add = 5
	}
	else_if = {
		limit = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner =  {
				amenity_level = { type = court_food_quality value = 5 }
			} 
		}
		add = 7
	}

	########
	#Trait check
	########
	#ADD
	if = {
		limit = { has_trait = gluttonous }
		add = 50
	}
	if = {
		limit = { has_trait = comfort_eater }
		add = 25
	}
	if = {
		limit = { has_trait = drunkard }
		add = 20
	}
	if = {
		limit = { has_trait = hashishiyah }
		add = 20
	}
	if = {
		limit = { has_trait = lazy }
		add = 10
	}
	if = {
		limit = { has_trait = greedy }
		add = 10
	}
	if = {
		limit = { has_trait = calm }
		add = 10
	}
	if = {
		limit = { has_trait = trusting }
		add = 10
	}
	if = {
		limit = { has_trait = gregarious }
		add = 10
	}
	if = {
		limit = { has_trait = patient }
		add = 5
	}
	if = {
		limit = { has_trait = arrogant }
		add = 5
	}
	if = {
		limit = { has_trait = ambitious	}
		add = 5
	}

	if = {
		limit = {
			has_trait = lifestyle_reveler
		}
		add = 5
		if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_reveler
					value >= 100
				}
			}
			add = 15
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_reveler
					value >= 50
				}
			}
			add = 10
		}
	}

	#SUBTRACT
	if = {
		limit = { has_trait = shy }
		add = -5
	}	
	if = {
		limit = { has_trait = zealous }
		add = -5
	}
	if = {
		limit = { has_trait = craven }
		add = -5
	}
	if = {
		limit = { has_trait = impatient }
		add = -10
	}
	if = {
		limit = { has_trait = fickle}
		add = -10
	}
	if = {
		limit = { has_trait = vengeful }
		add = -10
	}
	if = {
		limit = { has_trait = wrathful }
		add = -10
	}
	if = {
		limit = { has_trait = humble }
		add = -10
	}
	if = {
		limit = { has_trait = content }
		add = -15
	}
	if = {
		limit = { has_trait = generous }
		add = -15
	}
	if = {
		limit = { has_trait = diligent }
		add = -15 # Further 'moderation' impact below.
	}
	if = {
		limit = { has_trait = temperate }
		add = -20 # Further 'moderation' impact below.
	}
	if = {
		limit = { has_trait = reclusive }
		add = -20
	}
	if = {
		limit = { has_trait = paranoid }
		add = -25
	}
	if = {
		limit = { has_trait = inappetetic }
		add = -50
	}

	# MODERATION - reduces weight if overweight, and increases it if underweight
	if = {
		limit = {
			has_trait = athletic
		}
		multiply = 0.8
	}
	if = {
		limit = {
			has_trait = whole_of_body
		}
		multiply = 0.75
	}	
	if = {
		limit = { is_very_young_character = yes }
		multiply = 0.33
	}
	if = {
		limit = { is_young_character = yes }
		multiply = 0.66
	}	
	if = {
		limit = { is_aging_character = yes }
		multiply = 1.5
	}	
	if = {
		limit = {
			has_trait = physique_good_1
		}
		multiply = 0.9
	}
	if = {
		limit = {
			has_trait = physique_good_2
		}
		multiply = 0.8
	}
	if = {
		limit = {
			has_trait = physique_good_3
		}
		multiply = 0.7
	}
	if = {
		limit = {
			has_trait = temperate
		}
		multiply = 0.9
	}
	if = {
		limit = {
			has_trait = diligent
		}
		multiply = 0.9
	}

	#Bad physique has the opposite effect, making you skew even further towards extremes
	if = {
		limit = {
			has_trait = physique_bad_1
		}
		multiply = 1.1
	}
	if = {
		limit = {
			has_trait = physique_bad_2
		}
		multiply = 1.2
	}
	if = {
		limit = {
			has_trait = physique_bad_3
		}
		multiply = 1.3
	}
}

base_weight_plus = {
	add = base_weight
	add = 10
}

base_weight_minus = {
	add = base_weight
	add = -10
}

#The actual value that will be looked at
character_weight_target_value = {
	add = character_weight_base_value

	#To even the numbers out some if you have "good" and/or active traits
	if = {
		limit = {
			OR = {
				character_weight_base_value < base_weight_minus
				character_weight_base_value > base_weight_plus
			}
		}
		if = {
			limit = { #You weigh too little
				character_weight_base_value < base_weight_minus
			}
			if = {
				limit = { has_trait = lifestyle_hunter }
				add = 2
				if = {
					limit = {
						hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 50 }
					}
					add = 2
				}				
				if = {
					limit = {
						hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 100 }
					}
					add = 2
				}
			}
			if = {
				limit = {
					has_lifestyle = martial_lifestyle
				}
				add = 10
			}
		}
		else = { #You weigh too much
			if = {
				limit = { has_trait = lifestyle_hunter }
				if = {
					limit = {
						hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 50 }
					}
					add = -2
				}
				if = {
					limit = {
						hunt_lifestyle_track_greater_equal_trigger = { TRACK = hunter GREATER_EQUAL = 100 }
					}
					add = -2
				}
				else = {
					add = -2
				}
			}
			if = {
				limit = {
					has_lifestyle = martial_lifestyle
				}
				add = -10
			}
		}
	}
}

# Pregnancy
pregnancy_month = {
	value = pregnancy_days
	divide = 30
	floor = yes
	min = 1
}










vigorous_sex_age_difference_value = {
	value = age
	subtract = 25
}

harm_event_random_list_low_odd_success_value = 40
harm_event_random_list_low_odd_failure_value = 60
harm_event_random_list_medium_odd_success_value = 60
harm_event_random_list_medium_odd_failure_value = 40
harm_event_random_list_high_odd_success_value = 70
harm_event_random_list_high_odd_failure_value = 30
