how to do random script?

Long John
30 Nov 2016, 18:06

i want to do a script that goes like this.
input: look at X
output: random 1
input: look at X
outpit: random 3

and so on.


Deckrect
30 Nov 2016, 19:22

Ok. So, in short, you want a random text or feedback for a "Look at" verb placed on an Object, right?

If i recall correctly, if you place in description: {text1:text2} Quest will randomize between options. You may place as much different options you want.


Anonynn
30 Nov 2016, 19:28

Hmm....well there are a couple of ways to do this.

The first is the text processor which can be done in a regular message or message/expression. For example...

{random:Text 1:Text 2:Text 3:Text 4}  

^--- and it'll randomly choose one of those every time the script is accessed. It can be as large as you need it to be. You can even do this with it.

 {random:{random:Text 1:Text1a:Text1b}:{random:Text 2:Text2a:Text2b}:Text 3:Text 4}  

So you can make that as complicated as you like.

OR if scripts

if (RandomChance(25)) {
msg ("")
}
else if (RandomChance(25)) {
msg ("")
}
else {
msg ("")
}

And so on. Do those help?


hegemonkhan
01 Dec 2016, 07:38

there's 4 built-in Randomization Functions:

(see the quest doc site - too lazy to post the links to these 4 Randomization Functions right now)

DiceRoll
GetRandomInt
GetRandomDouble
RandomChance

using 'RandomChance' and 'GetRandomInt' work well for 'item drop selection / treasure chest item selection' implementation. The 'GetRandomInt' selects the item (via list's indexing), and the 'RandomChance' determines whether you actually get that item or not.

'GetRandomDouble' works well for a percentage or as a modifier-multiplier