Repair cost based on % of health

How could I create a formula to come up with a number (cost) to repair an item, based on the % of health the item has left.

EG:

Armor has 10% of health remaining out of 400.
Cost to repair the armor should be 90% of 400

1 Like
local remainingHealthProportion = health / maxHealth
local toRepairProportion = 1 - remainingHealthProportion
local cost = fullRepairCost * toRepairProportion
3 Likes

Thanks works great

30-characters

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.