[FEATURE] Use S-Spline as `Max Item Decay Percent`
Chaos02 opened this issue · 2 comments
View on item decay:
This mod is very nice but I've thought that your take on item decay could have a change:
When I think about ancient things (an old sword for example) I think that already heavily decayed (damaged) things start to decay slower
because there isn't much to decay left.
However I also think that brand new things mostly have some kind of surface seal, which will
make it harder at the beginning for decay to affect them.
Solution:
My solution to implement such a thing consists of not having a linear Max Item Decay Percent.
Instead, the max Item decay percent should be calculated through an S-spline! This will achieve the highest decay at 50% of the items' lifespan but also respect the surface seal and the fact that the particles/material that haven't decayed yet probably are much more resistant to decay than the rest of the object.
I am envisioning this:
Math.easeInOutExpo = function(t, b, c, d) {
t /= d/2;
if (t < 1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b;
t--;
return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
};where t=MaxDecayPercent, b=100=ItemHealthPercent, c=changeInDecayPercent and d=decayStates.
(Source)
In this case The decay should be a random of this returnvalue ±X
(randrange(return-x, return+x))
however this would also be okay:
Notice that The graph doesn't go to 0 because of the two D-Statements at the beginning.
In this case the MaxDecayPercent should be 100-<DecayValue>
This would (in my opinion) make for a much better, more realistic approach on this very cool feature!
It took a while (two years later 🤣) but I finally got around to implementing something like this. Thank you for the suggestion!
