Code:
<Post-Damage Eval>
var bonusStateRate = 0.20 + (user.luk / 300);
if (Math.random() < bonusStateRate && target.elementRate(1) > 1) user.addState(7);
</Post-Damage Eval>
In my project, I'm using this post damage evaluation to award a bonus state if you hit an enemy's weakness and if a random chance passes. But I would like to use the luck stat of said actor in the evaluation so that the luck stat has a bit more use in the game. The actor's luck gets taken and divided by a large number so it's added as a minor modifier to the bonus state rate. This code works, but I'm wondering if there's any issues with floating numbers?
As an example, if var bonusStateRate was 0.20 + (user.luk / 300), where the users luck was 44, google says the answer to 44 / 300 is 0.14666666666.
Is that still a smaller number than 0.80? Will a floating number give a pass when it shouldn't have been a pass?
Additionally:
I'm also curious how to have it add the bonus state if the hit was critical? Would that be it's own "if" line?