1
Coding / Formula for TU penalty
« on: December 04, 2012, 06:22:37 am »
I mentioned here an alternative method of calculating the TU penalty. Currently it adds 0 penalty if you are under 20% weight, 30% penalty if under 50% weight, and 60% penalty if over 50% weight. This is simple, but it doesn't allow changes in inventory to matter unless it puts you over the threshold.
I found the code and figured out the formulas to use linear scales between 0%, the light weight penalty point, the heavy penalty point, and 100%. Using this formula, every change in weight will likely change your total TUs by a little bit.
from src\game\q_shared.h
I also modified the penalties a bit because as they were they gave basically a straight line graph. I changed it from 30% @ 20% to 20% @ 30%, and from 60% @ 50% to 70& @ 60%. That puts a little bend in the graph, giving more bonus at light weights and more penalty at higher weights. The linear method also carries the penalty right up to 100% @ 100%, so you can't do much if you are power lifting. The numbers can be adjusted, obviously.
Attached is an ODS spreadsheet with the linear and threshold numbers if you want to play with it.
I found the code and figured out the formulas to use linear scales between 0%, the light weight penalty point, the heavy penalty point, and 100%. Using this formula, every change in weight will likely change your total TUs by a little bit.
from src\game\q_shared.h
Code: [Select]
#define GET_ENCUMBRANCE_PENALTY(weight, max) (1.0f - ((weight) > (max) * WEIGHT_HEAVY ? (((weight / (2.0f * max)) - WEIGHT_HEAVY) / (1.0f - WEIGHT_HEAVY) * (1.0f - WEIGHT_HEAVY_PENALTY)) + WEIGHT_HEAVY_PENALTY : (weight) > (max) * WEIGHT_LIGHT ? (((weight / (2.0f * max)) - WEIGHT_LIGHT) / (WEIGHT_HEAVY - WEIGHT_LIGHT) * (WEIGHT_HEAVY_PENALTY - WEIGHT_NORMAL_PENALTY)) + WEIGHT_NORMAL_PENALTY : (weight * WEIGHT_LIGHT) / (2.0f * max * WEIGHT_LIGHT)))
I also modified the penalties a bit because as they were they gave basically a straight line graph. I changed it from 30% @ 20% to 20% @ 30%, and from 60% @ 50% to 70& @ 60%. That puts a little bend in the graph, giving more bonus at light weights and more penalty at higher weights. The linear method also carries the penalty right up to 100% @ 100%, so you can't do much if you are power lifting. The numbers can be adjusted, obviously.
Attached is an ODS spreadsheet with the linear and threshold numbers if you want to play with it.