• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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?
 
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