﻿loaa_task_contract_success_gold_gain_full_max_tt_value = {
	# Base value + multiplier.
	value = 50
	if = {
		limit = {
			scope:actor = { highest_held_title_tier >= tier_kingdom }
		}
		multiply = 3
	}
	else_if = {
		limit = {
			scope:actor = { highest_held_title_tier >= tier_duchy }
		}
		multiply = 2
	}
	# Lifestyle perks.
	if = {
		limit = {
			scope:recipient = { has_perk = at_any_cost_perk }
		}
		multiply = 1.25
	}
	# Stuff that NEEDS to stay at the bottom.
	## Vary our final tally up a bit.
	if = {
		limit = {
			scope:actor.ai_greed != 0
		}
		add = {
			value = scope:actor.ai_greed
			multiply = -0.2
		}
	}
	## Plus change the last digit around slightly so the values look a little less robotic.
	if = {
		limit = { exists = scope:gold_fuzz }
		add = scope:gold_fuzz
	}
	## And boost a bit further for exceptional rewards, so that they're never beneath the common rewards.
	add = 10
	## Shouldn't happen but just in case someone is really, really, _really_ stingy: never pay less than at least a truly pathetic amount.
	min = 25
	multiply = task_contract_extra_reward_multiplier_value
	max = {
		value = scope:actor.yearly_character_income
		if = {
			limit = {
				scope:actor.gold > 0
			}
			add = scope:actor.gold
		}
	}
	round = yes
}

loaa_task_contract_success_gold_gain_crime_max_tt_value = {
	# Base value + multiplier.
	value = 100
	if = {
		limit = {
			scope:actor = { highest_held_title_tier >= tier_kingdom }
		}
		multiply = 3
	}
	else_if = {
		limit = {
			scope:actor = { highest_held_title_tier >= tier_duchy }
		}
		multiply = 2
	}
	# Lifestyle perks.
	if = {
		limit = {
			scope:recipient = { has_perk = at_any_cost_perk }
		}
		multiply = 1.25
	}
	if = {
		limit = {
			scope:recipient = { has_perk = malice_implicit_perk }
		}
		multiply = 2
	}
	# Stuff that NEEDS to stay at the bottom.
	## Vary our final tally up a bit.
	if = {
		limit = { scope:actor.ai_greed > 1 }
		add = {
			value = scope:actor.ai_greed
			multiply = 0.1
		}
	}
	### Take it down only a marginal amount for generous chars, as we still want criminal contracts to almost always pay more.
	else_if = {
		limit = { scope:actor.ai_greed < -1 }
		add = {
			value = scope:actor.ai_greed
			multiply = -0.05
		}
	}
	## Plus change the last digit around slightly so the values look a little less robotic.
	if = {
		limit = { exists = scope:gold_fuzz }
		add = scope:gold_fuzz
	}
	## And boost a bit further for exceptional rewards, so that they're never beneath the common rewards.
	# if = {
	# 	limit = {
	# 		exists = scope:gold_safety_margin
	# 		scope:gold_safety_margin = flag:yes
	# 	}
	# 	add = 10
	# }
	add = 10
	## Shouldn't happen but just in case someone is really, really, _really_ stingy: never pay less than at least a truly pathetic amount.
	min = 60
	multiply = task_contract_extra_reward_multiplier_value
	max = {
		value = scope:actor.yearly_character_income
		if = {
			limit = {
				scope:actor.gold > 0
			}
			add = scope:actor.gold
		}
	}
	round = yes
}

loaa_task_contract_success_gold_gain_full_value = {
	value = task_contract_success_gold_gain_full_value
	max = {
		value = scope:task_contract.task_contract_employer.yearly_character_income
		if = {
			limit = {
				scope:task_contract.task_contract_employer.gold > 0
			}
			add = scope:task_contract.task_contract_employer.gold
		}
	}
}

loaa_task_contract_success_gold_gain_crime_value = {
	value = task_contract_success_gold_gain_crime_value
	max = {
		value = scope:task_contract.task_contract_employer.yearly_character_income
		if = {
			limit = {
				scope:task_contract.task_contract_employer.gold > 0
			}
			add = scope:task_contract.task_contract_employer.gold
		}
	}
}

loaa_task_contract_invalidation_penalty_value = {
	value = {
		value = scope:task_contract.var:months_spent
		divide = 6
		floor = yes
		multiply = 250
	}
	min = 250
}