Random skill checks

#1

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.

1. 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?

2. 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?

Thanks.

Edit: Found the answer to question 1.

#2
1. Here’s how you do that:
``````
*if dexterity > 80
*set condition_a true
*goto Next
*elseif dexterity > 50
*set condition_b true
*goto Next
*else
*set condition_c true
*goto Next
*label Next

``````
1. What’s the “D20” supposed to mean? Anyways, here’s how you could do that:
``````
*set d20 + dexterity
*set strength_2 strength
*set strength_2 / 2
*set d20 + strength_2

``````

This way, the variables “Dexterity” and “Strength” won’t be altered, and “d20” will be the final value of your calculation above.

I hope this helped

EDIT: I posted before you edited your post, so disregard my answer to the first one.

#3

20 Sided die?

#4

Yeah. Twenty sided die. Sorry about that. Hrmmm…I’ll give that one a quick test and see if it works.

#5

You can create a random number between any two given values and assign that number it to a variable name (I’ll call this ‘diceroll’) as follows:

``````
*temp diceroll
*rand diceroll 0 20

``````

You can then use the value of ‘diceroll’ as you would any other numeric variable, e.g.

``````
*if ((diceroll + dexterity) + (strength / 2)) > 50

``````

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.

#6

Ooooh…so many advice. Thanks for all the advice and yes, I’ve got it 1/2 stat to work ^-^

#7

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?

#8

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.

#9

Thanks. The *rand command and skill checks work like a charm now. Hopefully I can get the prologue bit of my game done in a day or two now.

#10

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.

#11

Quick question: do I need to keep on using *temp dieroll each time I want the game to make a random skill check?

#12

Not generally within the same scene file, no.

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.

#13

Danke schon.

#14

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!

#15

Heh. Yeah I’m planning to do that. Thanks for the quick heads up.

#16

Also note that it’s incredibly hard to balance and playtest games which make use of a large number of random factors, just be aware of that.