I'm trying to make an editable chance of separate scripts activating after the player uses a verb, e.g the player attacks a slime and that slime has a chance of either dodging the attack or getting killed, i have been struggling with it for a while and i really can't solve it. Anyone can help me :(

Ths in advance <3

RandomChance in the attack code would work.

(Using DiceRoll in the example, but I heard that DiceRoll is not the best choice... But I know it better off the top of my head.)

IE:

You attack the slime...

H=DiceRoll(1d20)

if (H>slime.AC) {

msg("You missed.")

}

else{

M=DiceRoll(1d4)

switch (M)

case 1 {

msg("The slime squished down and avoided your swing.")

}

case 2 {

msg("The slime parted so that your swing passed between the two halves.")

}

case 3 {

msg("The slime moved back avoiding your swing.")

}

case 4 {

msg("Your swing passed through the slime, but it seems unharmed!")

}

}

there's 4 built-in Randomization Functions/Scripts:

- integer_variable = DiceRoll ("NUMBER_OF_DICEdNUMBER_OF_SIDES") // note the 'd' between the number of dice and number of sides

example of a normal dice roll (1 dice with 6 sides): integer_variable = DiceRoll ("1d6")

the sides' Values count up by 1, first side starting with 1, this can't be changed

https://docs.textadventures.co.uk/quest/functions/corelibrary/diceroll.html

- integer_variable = GetRandomInt (MIN,MAX)

example: integer_variable = GetRandomInt (0,100)

https://docs.textadventures.co.uk/quest/functions/getrandomint.html

- double_variable = GetRandomDouble ()

randomly selects a Value in the range/bounds of: 0.0 to 1.0 (I presume exclusively)

https://docs.textadventures.co.uk/quest/functions/getrandomdouble.html

- boolean_variable = RandomChance (INTEGER_VALUE) // the INTEGER_VALUE must be: 0 to 100

https://docs.textadventures.co.uk/quest/functions/corelibrary/randomchance.html

example of something happening 50% of the time (50% of being TRUE and 50% of being FALSE):

boolean_variable = RandomChance (50)

```
boolean_variable = RandomChance (50)
// 50% chance that: boolean_variable = true
// 50% chance that: boolean_variable = false
if (boolean_variable) {
// if boolean_variable = true
// whatever scripting
} else {
// if boolean_variable = false
// whatever scripting
}
----------
boolean_variable = RandomChance (75)
// 75% chance that: boolean_variable = true
// 25% chance that: boolean_variable = false
if (boolean_variable) {
// if boolean_variable = true
// whatever scripting
} else {
// if boolean_variable = false
// whatever scripting
}
---------
boolean_variable = RandomChance (25)
// 25% chance that: boolean_variable = true
// 75% chance that: boolean_variable = false
if (boolean_variable) {
// if boolean_variable = true
// whatever scripting
} else {
// if boolean_variable = false
// whatever scripting
}
-----
there's more combinations of logic manipulation with the 'if' Script, that you can do too, of course, but not going to show various samples of them, too lazy
-------
// using 'GetRandomInt' with 'RandomChance', which can be really useful, lot's of applications of using it (such as a item drop system in RPGs, but this is a bit more complicated as you're using lists, than the simple example below):
viable_random_integer_variable = GetRandomInt (0,100)
boolean_variable = RandomChance (viable_random_integer_variable)
if (boolean_variable) {
// if boolean_variable = true
// whatever scripting
} else {
// if boolean_variable = false
// whatever scripting
}
```

Log in to post a reply.