Hi, I’m making my first ChoiceScript game right now and I’m planning to toss in random skill checks into my game. I’ve been checking out the online guide and forums and I’ve got a two questions.
Is it possible to have degrees of success? E.g. Dexterity > 80 gets result A, Dexterity > 50 but < 80 gets result B and Dexterity < 50 gets result C?
Is it possible to have a random skill check that is like this: D20 + Dexterity + 1/2 Strength? How would I type it out in ChoiceScript if that were possible?
Note that it’s generally a good idea to have any *rand command separated by a *page_break from the *if line where the value it produces (‘diceroll’) is actually used. This is because if the player hits the Stats button on that particular page, when they return to the story page it will run the *rand command again, so generating a new random value.
Okay. I now ran into the Stats button that Vendetta is talking after. How do I work out this problem? Where is the *page_break supposed to be located at?
I guess it depends entirely on where & how you’re using the *rand command. For example, if there’s an earlier story scene leading up to that part, you’ve likely got a *page_break somewhere there. Just stick the *rand command at the end of that text, before the actual *page_break. That way the random value will already have been determined in advance, and will not be changed by the Stats page thing once the player hits the ‘Next’ button to go past that *page_break.
Just a thought; you can also stick a *rand command just before (e.g.) an earlier *choice command, since that also essentially results in a “new page” (so far as returning from the Stats page is concerned). The key to avoiding an unwanted re-roll is simply to not have the *rand command running on the same “page” as the *if command where you actually use the numeric value it generates . . . if that makes sense.
Edit: I should qualify that by saying that if you’re using *rand dieroll on two or more entirely separate routes, then yes, each will need its own *temp (or one at the very start of that file, so it applies to all following branches / routes).
In short, the program must always hit a *temp (variable name) line before it reads any other command using that particular (variable name), otherwise the (variable name) has not yet been created and it will error when you try to use it.
The other option is simply to define ‘dieroll’ in mygame.js with a starting value of 0, then you don’t have to worry about *temp-ing it anywhere, in any scene file.
Bump for the edit . . . it sounds like you intend to use ‘dieroll’ quite a lot, so my final paragraph above is well worth consideration before you make too many more changes sticking *temps everywhere!