How would I give ChoiceScript a small number generator/dice to select a certain situation?

What I am trying to do is have ChoiceScript randomize a number between 1 and 10, with 1, 2 being [no enemies] 3, 4, and 5 being [1 enemy], 6, 7, 8 being [2 enemies] and 9, 10 being [3 enemies].
I would have a scene written out for 1/2/3 enemies, and just want CS to randomly pick one, so with my game instead of knowing how to progress through each level it’s randomized.

1 Like

*rand

Just be careful as if you have it on the same page as your fight, it’ll re-roll ever time the player checks their stat page. It’s better to have it on the page before so it doesn’t keep rolling.

ie
*temp diceroll 1

You enter a house.
*rand diceroll 1 10

*if diceroll =1
*set enemyno 1
*set enemy “enemy”

*if diceroll = 2
*set enemyno 2
*set enemy “enemies”

(etc for all the numbers)

*page_break

As you walk into the living room {enemyno} {enemy} jumps out at you looking for a fight.

Edit: If you have different scenes, instead of setting enemy numbers you could just redirect to the scene. I

ie:
*if (diceroll < 3)
*goto_scene noenemy

etc

If you are using goto (instead of goto_scene) remember to have the diceroll on a different page (separated by a page_break) or people will find the scene jumps every time they check their stat page at the start of the fight.

4 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.