Is there a way to set a randomizer?

Basically I want to be able to make a different assassin stumble toward you for each time you come to this scene. So the first time, it’d be the assassin 1, then the 2nd time it’d be assassin 2, then the 3rd time it’d be assassin 3. Is there a way I can do this?

"You retrieve a spare bag from our satchel and empty the iron shavings from your right pocket into the bag. After attaching the newly filled bag to your belt, you resume your journey, Beckham perching on your shoulder as you make your way to the clearing. Walking pointedly through the forest of deciduous trees, you instruct Beckham on your course of action.

“Beckham, we are going to sneak quietly to the aforementioned clearing, where I will conceal myself under cover of the trees encircling the perimeter. From there, you will take this bag of iron”, you say, patting your thigh to indicate the bag mentioned, “fly overhead, and release it onto the heads of the assassins. Once that has been achieved, I will follow through with the final attack.”

You signal Beckham with a motion of your finger and he drops silently from your shoulder and sticks his leg out. You detach the bag of shaved iron from your belt and tie the ribbon closing the opening of the bag gently onto Beckham’s leg.

“Now, when you are within range, undo the knot on the ribbon and the substance will release itself into the air and descend upon them, melting through to their flesh. Then, I will rush in, and in their confusion, strike them down.”

He winks and takes to the air with a flap of his wings. You watch him disappear above the contorted branches of the trees and await the signal. You hold your breathe for a several tentative seconds, before the chaos ensues. The contents of the bag rains down upon the assassin’s in a cloud of glinting black, and scatter though the the assailants might, the number of shavings is such that injury on their part is inevitable. The metal burns their skin down to the flesh on contact, leaving 3 degree burns scattered across their bodies akin to leprosy. They scream in agony, running around in discord in their frantic attempt to escape the acidic danger flowing in the wind around them. In the chaos, the ____________ stumbles, shrieking, directly towards you; none the wiser of your presence! How do you dispatch this foe?"

This will randomise the first assassin, but then the other will appears in order. For example, if the first assassin is number 4, the next will be 5, then 6, then 7, then 8, then 1, then 2, etc.

*create random_counter 1
*rand random_counter 1 8


*if random_counter = 1
  *set random_counter +1
  Assassin 1 appears!
*if random_counter = 2
  *set random_counter +1
  Assassin 2 appears!
*if random_counter = 3
  *set random_counter +1
  Assassin 3 appears!
*if random_counter = 4
  *set random_counter +1
  Assassin 4 appears!
*if random_counter = 5
  *set random_counter +1
  Assassin 5 appears!
*if random_counter = 6
  *set random_counter +1
  Assassin 6 appears!
*if random_counter = 7
  *set random_counter +1
  Assassin 7 appears!
*if random_counter = 8
  *set random_counter 1
  Assassin 8 appears!
1 Like

@andymwhy
So could I just set the counter to 3 instead of 8? And each time you come to this scene, you only get to ambush one assassin. After that, you rush out into the clearing and attack the other assassins. And I want to make it a different assassin for the first 3 times you come to this scene but the random counter wouldn’t take your previous game into account, would it?

If you plan to use this in several places, make it a *gosub.

STORY TEXT…
Assassin! Who is it?

*gosub assassin_role

Later… MORE STORY TEXT…
Another assassin!

*gosub assassin_role

At the end of your text file, have the line

label assassin_role

Followed by the code I printed above. (apart from the *create and *rand lines - *create obviously goes with the other variables, *rand should go ONCE at the start of this scene).

Dam my code works bad again and andy explain better than me my problem is doing this in a loop

@MaraJade
Couldn’t I also do this?


\*rand die 1-3

\*if (die 1) <br /> 
     \*set assassin1 true
\*if (die 2) <br /> 
     \*set assassin2 true
\*else 
     \*set assassin3 true
<pre/>

@andymwhy
It doesn't look like that's exactly what I'm looking for in this situation, but I'll be sure to remember it for future reference. Thanks!
1 Like

Ah, that’s right @Samuel_H_Young - this would randomise the assassin the first time you played it (you are right - reduce it to 3 from 8). However, when the player starts a new game, this would be reset and they could end up playing against the same assassin.

This code is better suited to using the same assassins at different parts of your game - as in the text in my post before this one.

Within the same playthrough, every time the player encounters an assassin, it will be a new one.

Or as MaraJade says, simply use rand.
I would reduce it from 100 to 3, unless you want a specific assassin to be rarer than the others.

*rand die 1 3
*if die =1
  You meet assassin 1
*if die =2
  You meet assassin 2
*if die = 3
  You meet assassin 3
1 Like

yeah that I was trying but my code jump lines again. I do that for my games its more comfortable to me

There are two ways I can think of to have it so that the next time the player plays the game the random role stays intact, although both are a little tricky…

One, when the player completes the game, don’t *finish the game, but instead reset all the stats manually - except for the randomised stat. The problem with this method is that the player isn’t guaranteed to start a new game straight away - if they come out of the game after completing it, then return later they would likely click ‘start a new game’ which would reset all stats completely.

Two, the same as above but have the player save the game upon completion.

For both of these, you would need some cleverly worded text to persuade / encourage the player to continue from their previous game rather than starting completely from the start again. This can be achieved with ‘unlockables’ - things they can only access on a second playthrough.

@andymwhy
Yeah that’s an alternative.

@MaraJade
Alright:P

so in the end, the code would look like this?


\*set assassin-Hestia false
\*set assassin-Venefira false
\*set assassin-Illusia false

\*rand die 1-3

\*if (die 1) 
 
     \*set assassin1 true
\*if (die 2) 
 
     \*set assassin2 true
\*else 
     \*set assassin3 true

\*if (die 1)
     bla bla bla bla

\*if (die 2)
     bla bla bla bla

\*else

     bla bla bla bla
<pre/>
1 Like

no you have to write
assassin-Hestia true not assasin 1

@MaraJade
Oh that’s right. I knew that:P
Well thanks, guys

you could reroll inside each one to determine if assassin has exit in his attack or not


*rand die 1 3
*if (die  =1)
    *set assassin1 true

*if (die 1)
    bla bla
    *rand hit 1 2
    *if (hit =1)
        she miss
    *else
        she strike

1 Like

@MaraJade
I’m not fond of randomness

Rather than randomizing why not make it a result of a choice which Assassin gets to you first.

For example…


The Clocktower explodes in the distance. Cursing loudly you rush to intercept the attackers.
*choice
  #I should cut through the courtyard, there is no cover but I'll get there faster.
    *goto courtyard_assassin

  #I'll go through the back alleys and hit them from behind.
    *goto alley_assassin

  #I'll rush along the roof and strike from above.
    *goto roof_assassin

*label courtyard_assassin

You dart through the courtyard focused on getting to the clocktower that you almost miss the shadowy figure throwing the knife. You throw yourself to the ground dodging it at the last minute and get up weapon drawn as the cloaked man steps towards you.

[Fight]

*label alley_assassin

You dart through the alley as quick as you can. You turn the corner not skipping a beat and almost run straight into the spear the large troll thrusts at you. You shift slightly and the deadly tip just tears through your jacket not your flesh. The spear is pulled free and you step back drawing your weapon.

[Fight]

*label roof_assassin

You leap from roof to roof as silent as a cat. You're quite proud of your plan and can't wait to surprise the enemy. As you near the clocktower you spot someone ahead of you. Coming to a halt when you find your way blocked by a woman in armor black as shadows. She flexs her twin whips and you watch them tear through the rooftiles. You draw your weapon and prepare yourself.

[Fight]


This way it encourages replays and stops people from reloading the game just to get the assassin they want to fight (which will happen if they are random)

@Nocturnal_Stillness
You’ll end up fighting them all anyways, but I think that’s a really good idea. I’ll definitely do that

I preffer random but both methods are compatible. If you put a page_break after the rand choice people can’t change the result

@MaraJade brings up something to remember: *rand should never be run on the page where it randomizes what you’re looking at. If you go to to the stats page and back, it will re-randomize the stat (and potentially change the page you’re on). Always put the *rand at least one page back from where you’re calling up the stat that was randomized.

I am about to attempt an rpg game using CoS engine. Problem is, I am going to need to use *rand a lot for damage player and monster do, I can’t just set static damage or else it will be too predictable and rpg element will be just window dress and no actually important, yet from what I heard about *rand it should be use last.

So I am here to ask about any alternative?

First, you might reconsider using ChoiceScript. It’s not really built for lots of randomness.

Second, you don’t need to reveal how many HP a monster has or how much damage has been done to it; so you could probably fake randomness fairly effectively for the damage the player does (except for players who peek at code).

Third: use *rand a lot. But make sure that (as Reaperoa said 2 years ago) you use it earlier than the page where it randomizes what you’re looking at, or your readers will be (in effect) able to re-roll until they get the outcome they like by going to the stats page and back.

1 Like