• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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 20
Joined
Aug 29, 2012
Messages
826
Make sure you have this option unchecked in the preferences, I know it messes up with RNG

1681388097680.png
 
Level 19
Joined
Feb 27, 2019
Messages
590
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