﻿# Returns the skill level of the contubernalis supervisor on a scale from
# 0 (min skill) to 1 (most skill). In terms of prowess level
# this translates to (15, 60).
# scope:councillor = councillor_contubernalis_supervisor
contubernalis_supervisor_skill_factor = {
	scope:councillor = {
		value = prowess
		subtract = 15
		divide = 45
		min = 0
		max = 1
	}
}

# The number of contubernalis in the magister's court who are available to act
# on the councillor_contubernalis_supervisor's orders.
#
# Specifically, includes all contubernalis courtiers of the liege who are
# available adults and not serving as knights.
#
# scope:councillor_liege = the lige of the councillor_contubernalis_supervisor
contubernalis_supervisor_available_contubernalis = {
	value = 0
	scope:councillor_liege = {
		every_courtier = {
			limit = {
				is_contubernalis_available_for_supervisor_use = yes
			}
			add = 1
		}
	}
}

# Monthly chance that a side effect will occur for
# councillor_contubernalis_supervisor tasks.
contubernalis_supervisor_monthly_side_effect_chance = 5

# Chance that any side effects from task_sparring_partners will be positive.
#
# Relaxed Range: [70, 100]
# Strict Range: [30, 100]
contubernalis_supervisor_positive_side_effect_chance = {
	if = {
		limit = {
			scope:councillor_liege = {
				regula_contubernalis_supervisor_in_strict_mode_trigger = yes
			}
		}
		value = 30
		add = {
			value = 70
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	else = {
		value = 70
		add = {
			value = 30
			multiply = contubernalis_supervisor_skill_factor
		}
	}
}

# Amount of time after a selected 'participant' (character, county, etc) has
# experienced side effects from councillor_contubernalis_supervisor tasks that
# they will be less likely to be selected for side effects again in years.
contubernalis_supervisor_side_effect_reduce_chance_years = 5

# Duration of side effect modifiers from task_sparring_partners in years.
task_sparring_partners_side_effect_modifier_years = 5

# The number of available contubernalis at which task_sparring_partners reaches
# maximum effectiveness.
task_sparring_partners_max_effectiveness_scaling = {
	value = 0
	scope:councillor_liege = {
		every_knight = {
			limit = {
				NOT = { has_trait = contubernalis }
			}
			add = 1
		}
	}
}

# Effectiveness value gained from using contubernalis as sparring partners for
# the Magister's knights. Simply a ratio of the number of available contubernalis
# to the number of knights the liege has.
#
# Range: [0, 1]
task_sparring_partners_effectiveness = {
	value = contubernalis_supervisor_available_contubernalis
	divide = {
		value = task_sparring_partners_max_effectiveness_scaling
		min = 1
	}
	min = 0
	max = 1
}

# task_sparring_partners_effectiveness as a percentage for descriptions.
task_sparring_partners_effectiveness_percentage = {
	value = task_sparring_partners_effectiveness
	multiply = 100
}

# The increase to the magister's prowess granted by task_sparring_partners.
# Range: [2, 10]
task_sparring_partners_magister_prowess = {
	value = 2
	add = {
		value = 8
		multiply = contubernalis_supervisor_skill_factor
	}
	floor = yes
}

# The increase in the knight effectiveness of the liege's knights for
# task_sparring_partners.
# Relaxed Range: [0.1, 0.5]
# Strict Range: [0.2, 0.75]
task_sparring_partners_knight_effectiveness = {
	if = {
		limit = {
			scope:councillor_liege = {
				regula_contubernalis_supervisor_in_strict_mode_trigger = yes
			}
		}
		value = 0.2
		add = {
			value = 0.55
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	else = {
		value = 0.1
		add = {
			value = 0.4
			multiply = contubernalis_supervisor_skill_factor
		}
	}

	multiply = task_sparring_partners_effectiveness
}

# task_sparring_partners_knight_effectiveness as a percentage for descriptions.
task_sparring_partners_knight_effectiveness_percentage = {
	value = task_sparring_partners_knight_effectiveness
	multiply = 100
}

# Duration of side effect modifiers from task_beasts_of_burden in years.
task_beasts_of_burden_side_effect_modifier_years = 5

# The number of available contubernalis at which task_beasts_of_burden reaches
# maximum effectiveness. This is based on the size of the liege's realm.
task_beasts_of_burden_max_effectiveness_scaling = {
	value = 0
	scope:councillor_liege = {
		add = domain_size
	}
}

# Effectiveness value gained from using contubernalis as manual labor for
# the liege's realm.
#
# Range: [0, 1]
task_beasts_of_burden_effectiveness = {
	value = contubernalis_supervisor_available_contubernalis
	divide = {
		value = task_beasts_of_burden_max_effectiveness_scaling
		min = 1
	}
	min = 0
	max = 1
}

# task_beasts_of_burden_effectiveness as a percentage for descriptions.
task_beasts_of_burden_effectiveness_percentage = {
	value = task_beasts_of_burden_effectiveness
	multiply = 100
}

# The monthly increase in capital development granted by
# task_beasts_of_burden.
#
# Relaxed Range: [0.1, 0.8]
# Strict Range: [0.2, 1.2]
task_beasts_of_burden_capital_development = {
	if = {
		limit = {
			scope:councillor_liege = {
				regula_contubernalis_supervisor_in_strict_mode_trigger = yes
			}
		}
		value = 0.2
		add = {
			value = 1
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	else = {
		value = 0.1
		add = {
			value = 0.7
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	multiply = task_beasts_of_burden_effectiveness
}

# The domain tax multiplier granted by task_beasts_of_burden.
#
# Relaxed Range: [0.05, 0.20]
# Strict Range: [0.1, 0.30]
task_beasts_of_burden_domain_tax_mult = {
	if = {
		limit = {
			scope:councillor_liege = {
				regula_contubernalis_supervisor_in_strict_mode_trigger = yes
			}
		}
		value = 0.1
		add = {
			value = 0.2
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	else = {
		value = 0.05
		add = {
			value = 0.15
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	multiply = task_beasts_of_burden_effectiveness
}

# The build_speed granted by task_beasts_of_burden.
#
# Relaxed Range: [-0.05, -0.4]
# Strict Range: [-0.1, -0.6]
task_beasts_of_burden_build_speed = {
	if = {
		limit = {
			scope:councillor_liege = {
				regula_contubernalis_supervisor_in_strict_mode_trigger = yes
			}
		}
		value = -0.1
		add = {
			value = -0.5
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	else = {
		value = -0.05
		add = {
			value = -0.35
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	multiply = task_beasts_of_burden_effectiveness
}

# The holding_build_speed granted by task_beasts_of_burden.
#
# Relaxed Range: [-0.05, -0.4]
# Strict Range: [-0.1, -0.6]
task_beasts_of_burden_holding_build_speed = {
	if = {
		limit = {
			scope:councillor_liege = {
				regula_contubernalis_supervisor_in_strict_mode_trigger = yes
			}
		}
		value = -0.1
		add = {
			value = -0.5
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	else = {
		value = -0.05
		add = {
			value = -0.35
			multiply = contubernalis_supervisor_skill_factor
		}
	}
	multiply = task_beasts_of_burden_effectiveness
}
