• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Random number

Status
Not open for further replies.
Level 2
Joined
Jan 26, 2020
Messages
9
Hello,
I would like to generate a random number between 1 to 4 but remove certain number possibility under certain conditions.
The problem is that the number is link to a specific action. So if i generate a number between 1 to 3 because the 2 dont match the conditions, i will never have the 4.

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set VariableSet move_RNG = (Random integer number between 1 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (move_RNG Equal to 1) and (move_droite Equal to 0)
        • Then - Actions
          • Set VariableSet move_RNG = (Random integer number between 1 and 4)
        • Else - Actions
Actually, i have this, but i still have the possibility to have 2 times the same number.
Any ideas?
 
Level 27
Joined
Aug 29, 2012
Messages
1,207
Make sure you have this option unchecked in the preferences, I know it messes up with RNG

1681388097680.png
 
Level 23
Joined
Feb 27, 2019
Messages
767
You can make use of an array to store your numbers.
You can store any number in the array.
number[1] = 1
number[2] = 3
number[3] = 4
set move_RNG = number[random number between 1 and 3]


Here is an example of how to do it but its not actual code. Do you see what is happening here?

Set invalid_number[2] = true
For each integer int from 1 - 4
if invalid_number[int] = false then
set array = array +1
set random_choice[array] = int
else
set invalid_number[int] = false
endif
endloop
set udg_move_RNG = random_choice[random number between 1 and array]
set array = 0
 
Status
Not open for further replies.
Top