I would caution against using any random values to determine the outcome of a fight.
The powers that be don’t seem to like that sort of thing.
However, if it’s a predictable mathematical equation that will work the same way every time (of course, this concept allows for the variables and values to be different, they just have to be consistent and not rely on randomization to achieve success), then I think it should be fine.
Are you testing your code as you go, by the way?
In your ChoiceScript folder --> web --> mygame, there’s an index.html file that opens up in Firefox.
You can use that to test as you go to see if the system will give you any specific errors, like for example, if you’ve got too many or too few parentheses in an equation.
To directly address the problem you’re bringing up about hit chance, I would also think about the opponent’s defense chance. This way we eliminate “chance” altogether and use specific values.
Let’s say your “chance” to hit turns out to be a value of 18 based on choices you made earlier such as preparedness, situational awareness, etc. So 18 is your hit value.
Normally, the defense value of an opponent is 15, but they caught you off guard (plot reasons) so their defense value gets bumped up to 19.
Their defense is higher than your attack, so you miss.
If their defense is the same as your attack, perhaps they get hit for partial damage?
It’s just a matter of figuring out the design.