Clever uses of *rand

Hello folks!

Thought I’d pick a less controversial topic on this one. I’m currently using *rand to create variable weather in my game. Very simple use of the command. Lots of excruciating writing; but, I’m having fun with it. What are some clever/creative uses of *rand that you all use? I’d love to learn more.

7 Likes

I love *rand. It’s all over The Parenting Simulator, from the option to randomize the story scenes you encounter to results for the SAT, television auditions and other things. Ideally you need to make sure people are able to influence the results significantly with their choices (one game that was less than ideal about this was Fielder’s Choice; it was already too reliant on luck and your stats had way too little impact on skewing probability one way or the other), but overall it’s a fun mechanic. Provided you remember to have a page break before the results show, of course. I imagine anyone who wrote with *rand encountered that stat page causing a reroll issue a time or two.

As for my most creative use of it, probably allowing for the random option of success for a surgery on your old and ailing pet in TPS, which is influenced by its age at purchase and whether you sprung for the emergency vet as opposed to waiting until they opened. Success isn’t very likely in any case, but I like to think that makes it more meaningful for those who do manage to buck the odds since they get to join the rare few who have a living pet in the endgame.

4 Likes

Heart of the House has a chapter in which (I believe) it’s used to determine the sequence of scenes that take place, meaning that one playthrough can be very different to another. I don’t know if it’s a particularly unusual use of *rand but I’ve used it to simulate a cartomancy reading in Royal Affairs which I enjoyed doing!

9 Likes

I coded a fully randomized, extensive character creation scene, using *rand, back when I was bored one weekend. (Including a half-done, species-specific name generator.)

I’ve also used it for the framework I did for having random encounters, and randomizing the flavour text for when you enter repeatable locations.

And for talking with companions/RO, when there’s no new special scene available.

5 Likes

Thats amazing! I love it! Oh my lord I would be riveted. After working as emergency technician for years I still love that you did that. Thank-you for your response. Yes make me feel!

3 Likes

Very cool thanks for your response! My use is very simple but some players get a storm, some don’t, of course with choices to react. I want to people talking about the game going what! That never happened on my play through! I can only hope

2 Likes

I used it in my WIP to randomize airship race results in a minigame. Probably a pretty typical usage, but I needed to program some looping code to do it, which I had never done with choicescript before, so that was challenging.

Weather randomization sounds really interesting, that’s a very cool use of the *rand function :eyes:

3 Likes

Don’t forget to use the command well before you call the variable (i.e. at least one page break or choice separating the randomisation and when the variable appears in the game). Choicescript has a bug where opening and closing the stats screen rerolls all random variables on the page.

6 Likes

Yep I like some uses of *rand as well. It can add some game play uncertainty into what would otherwise be linear straightforward games. In Dragon Challenges I’m using weighted RNG’s depending mainly on your stats and prior choices to give some randomisaton to events including weather, battles, resources, theft and scene selection to try and give it more replayability. I’ve added in the ability to go around the RNG for scene selection, and also put in a difficulty slider so hopefully it’s customisable enough for people’s tastes.

Haha yeah. I found it interesting trying to get it to work without bugs when you start juggling multiple rand variables, especially when some continue to affect the game after they’re triggered.

Yes, discovered this the hard way :slight_smile:

5 Likes

Everyone finds out about the stat page thing sooner or later.

7 Likes

I had this idea a day or so ago to use rand to create a handful of scenarios where you would run into different background characters as you’re going about your week. You would have a full conversation with them dialouge choices and all and learn something about characters you wouldn’t necessarily go out of your way to talk to ordinarily. My only concern is people missing a background character they actually do want to talk to.

4 Likes

Been using *rand commands for skill checks, which made a game more RNG based.

So that even if you have the highest stat possible for Strength, for example, you can still fail, however unlikely, and the same can happen the other way too, where your weakest stat can work out despite the odds.

2 Likes

I used *rand to generate a cheap version of AI for an opponent in a game of blackjack, to determine what the opponent will do next. Each opponent move is determined by a hidden dice roll, but the closer their hand is to 21, the less likely it becomes that they will take another card (unless the player already has 21 in their hand, in which case the opponent will always take another card).

3 Likes

Your code here is at risk of this bug! Put the *rand command last so that it’s actually rolling for the next hit instead of the current one (and put a single *rand at the beginning of the game before you need it). It’s the best way to avoid the issue.

3 Likes

There are several choices between that code and where my variable shows up, so I have ensured the bug won’t happen, but I agree there are probably better ways to do it.

3 Likes

As will is saying, I’d roll the rand well before you need it. Ideally set up the first roll at the very start of the game so it’s ready to go (don’t use temp). If you need to reroll the stats for the next use, do it as soon as possible where it will not interfere with the game being played. I could be wrong, but I think with that code, if someone goes to the stats page it will reroll and may flip from success to fail (or vice versa) which will probably confuse players. The roll needs to be at least on the other side of a choice or page_break to not keep rolling. (Or do you mean the player can’t see the result of the roll until a choice or two later in which case it doesn’t really matter if it keeps flipping as long as it doesn’t mess up your stat checks.)

2 Likes

If the player goes to the stat page when they first go to that page, they will reroll the result; however, since the result/variable isn’t displayed at the start of the page where the code is (it’s displayed later on after a few choices and page breaks), they won’t know that’s happening nor what the variable result is.

And I definitely should be using permanent variables instead of temps. (Doing temps you basically have to rewrite that every single page you do a stat check on and be careful how you arrange things to avoid that glitch/bug.)

4 Likes

I’m writing a cat breeding game for the IF Comp this year (PM me if you wanna help beta read it), and I use *rand to determine how many kittens each cat has (ranging from 1-5 kittens but with only two options for each cat as there are six possible mother cats and I wanted photos of very young kittens with each option). So the total number of kittens for the PC’s two mother cats ranges from 3 to 10.

This game has way more boolean variables than the norm, which is a pain in the neck. But worth it, because kittens.

gratuitous cuteness

4 Likes

Hey, DrewWolf

You picked a topic I enjoy perhaps a bit too much. I have a project I’m working on, that’s in the background, where *rand is used extensively. I use it for scenes with the antagonist that’s hunting the Player Character, using it to randomly choose if the “bad guy” is coming after the PC or going after someone else. It’s crazy, but very enjoyable.

I also have another side project I’m working on, for learning purposes, where *rand is used to determine if certain actions succeed or not. Should the scene “fail,” it automatically draws up a response scene where more choices are presented.

So…I suppose I use *rand as my own version of a Literature AI.

Takes a lot of coding, doing it the way I do, but it’s something that gets my brain working.

2 Likes