• 🏆 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!

Random number in W3

Status
Not open for further replies.
Level 6
Joined
Dec 8, 2016
Messages
127
I am planning to make a gambling map, are the random numbers in this game functions well like how you expect the 100% randomness of dice roll or lottery ticket?

If not, how can i trigger a 100% random number?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Also make sure you are not in a cinamitc. The GUI action to start a cinematic locks the random seed to a certain value. If cinematic mode is ended, the seed is reverted.
You can change this, but you will need JASS for that.
 
I have reversed GetRandomInt partially here

Here is an implementation of GetRandomInt & SetRandomSeed in python as well.

As for the how cinematics affect the seed:

JASS:
if (cineMode) then
    // Save the UI state so that we can restore it later.
    if (not bj_cineModeAlreadyIn) then
        set bj_cineModeAlreadyIn = true
        set bj_cineModeSavedSeed = GetRandomInt(0, 1000000)
    endif

    // Use a fixed random seed, so that cinematics play consistently.
    call SetRandomSeed(0)
else
    set bj_cineModeAlreadyIn = false

    // Perform global changes
    call SetRandomSeed(bj_cineModeSavedSeed)
endif
 

Attachments

  • rand.zip
    931 bytes · Views: 39
Status
Not open for further replies.
Top