I’m planning to write a text based zombie survival game. It would be ideal if certain choices didn’t always result in the same outcome, to increase replay value and the bad luck you sometimes get in real life. For example, sometimes there is a zombie behind that door and sometimes there isn’t, sometimes you find food/water and sometimes you find bullets instead. How would i go about coding the game to roll for a random variable and then coding it so that depending if it’s more or less than a certain variable, it leads to a different outcome?
You mean something like this?
Perfect!
Just a warning how choicescript works is it re-rolls everytime the page is read. So if you got a 5 and check your stat screen when you go back the number gets re-rolled and you can get a different number. So it is possible to game the system. The best way around it is to do the actual *rand command the page before you need it.
I second this in a big way. My last story had randomly selected scenes and it took a while to fix them so they wouldn’t reroll if someone went to the stat screen or whatever.
Thank you so, so much for this. I’ve been scratching my head over it for a while and couldn’t figure out how to stop it from rerolling.
I don’t exactly understand, how do you do it the page before you need it? Do you just insert the random variable code but not add any text and then do the *if command on the next page?
*rand die 1 6
*page_break
You roll a die and score ${die}
By doing it the way @Nocturnal_Stillness mentions, they are still rerolling the results when they go to stat or achievement screens and come back, but because they won’t see those results until they advance past the page break it does not matter.
Separate the randomizing code and the scene with a *page_break
Bit off topic, but I very much plan to read your story if it involves zombies, so I cant wait till that journey to start up