Be careful with floats, saving them to text in a decimal format is not possible exactly,
must either use hexadecimal float format or save the raw value somehow.
Also floats lose precision when the numbers grow larger, computer games stumble over this problem sooner or later...
Maybe better use fixed-point arithmetic, say multiplying all values by 1000?
then add(x,y) == x + y and mul(x,y) == (x*y)/1000
overflow of int32_t or int64_t is probable unlikely.
otherwise can use ((__int128_t)x * y) / 1000 or similar
to avoid overflow of the intermediate result.
I have just noticed that the gloves have absorb 1-2 themselves, so the flickering adds +- 25 3 3 to the base values 225 6 7 for the 3 quantities
I think there is a new bug in the bugfix:in src/UtilsMath.hfunction randBetweenF
the line return minVal + (static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) * maxVal;should be return minVal + (static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) * (maxVal - minVal);
i.e. (maxVal - minVal) instead of maxVal
There is a mistake in the above fix proposal.
It must be
int chance = Math::randBetween(1,100*100);
Be careful with floats, saving them to text in a decimal format is not possible exactly,
must either use hexadecimal float format or save the raw value somehow.
Also floats lose precision when the numbers grow larger, computer games stumble over this problem sooner or later...
Maybe better use fixed-point arithmetic, say multiplying all values by 1000?
then add(x,y) == x + y and mul(x,y) == (x*y)/1000
overflow of int32_t or int64_t is probable unlikely.
otherwise can use ((__int128_t)x * y) / 1000 or similar
to avoid overflow of the intermediate result.
I have just noticed that the gloves have absorb 1-2 themselves,
so the flickering adds +- 25 3 3
to the base values 225 6 7
for the 3 quantities
I think there is a new bug in the bugfix:
in src/UtilsMath.h
function randBetweenF
the line
return minVal + (static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) * maxVal;
should be
return minVal + (static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) * (maxVal - minVal);
i.e. (maxVal - minVal) instead of maxVal
There is a mistake in the above fix proposal.
It must be
int chance = Math::randBetween(1,100*100);