I’m considering adding skill checks (via the use of “dice”) to one of my WIPs.
Is there a way that this can be done? I believe the rand command had an issue related to this with avoiding numbers that it had chosen previously but it’s been so long I cannot remember the command in its entirety.
Also…
If it IS possible to make something like this, how would the code be written? In a way that is elegant and doesn’t rely on dozens of lines of code for a single command, that is. I understand the basics of CScript but making elegant code is not my forte.
The main issue is the game re-rolls if you go to the stats page and back, so you need a *page_break between when the roll is made and when you actually tell the player what the dice says. If you’re rerolling dice one after the other, you might even need two dice stats to get around this problem. ie dice_a and dice_b
Here is the chociescript wiki page on *rand which explains how to use it pretty well. It doesn’t mention the issue you talked about with avoid numbers.
I’m not sure how complicated the code would be? I’m pretty sure it would just be
*rand dice 1 20
*if (dice >= DC)
SUCCESS TEXT HERE
*else
FAIL TEXT HERE
where DC refers to the minimum number you need to roll to succeed the skill check.
If you want an example of d20 rolls in a choicescript game, Breach: the Archangel Job uses them to hilarious results.
I’m not sure what you’re trying to do here? gosub needs to go to another place, so if you’re going to use gosub to roll, it needs to point to a *label and that section of text needs to end with a return. Also as I said, don’t use it right before a goto, or if the player checks the stat menu and comes back, the text they see with flick from one to the other causing them to think it is bugged.
Example
*gosub CombatSkillCheck
Text here talking about whatever.
*page_break
More text about the combat and then the result kicks in with…
I was just trying to see if I could use a gosub to reduce the overall amount of code necessary for it is all. I didn’t realize that a gosub would also cause this issue.
You can use it to reduce code, I updated the comment above, but gosub doesn’t avoid the reroll thing. There needs to be a page break. It’s no big deal, just set the roll before you need it.
Edit- Also I think you’re getting errors because you’re mixing up your variables in the checks and need to set not temp some of the variables. TBH I’d make you’re life easier and just create them as variables in the start file so you don’t need to temp them unless it’s something you’re only going to use once to reduce confusion like this.