• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

Weird World Editor: Random Function Behavior

Status
Not open for further replies.
Level 9
Joined
May 21, 2014
Messages
580
Greetings Hive!

This is not much of a problem, but I recently noticed something weird about random (both integer and real) number function. This also only happens when you use TEST MAP on world editor. Restarting the world editor AND my laptop doesn't change this fact. Here is a list of triggers that I used to generate random numbers:

1. Music Selection
I have 3 musics in my map, and when a mode is chosen (created via triggers as well) a random song is played from the musics I have.
  • Start Music
    • Events
      • Dialog - A dialog button is clicked for ChooseMode
    • Conditions
    • Actions
      • Sound - Stop music Immediately
      • Set MusicListCustom = (Random integer number between 0 and 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MusicListCustom Equal to 0
        • Then - Actions
          • Sound - Play Song1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MusicListCustom Equal to 1
            • Then - Actions
              • Sound - Play Song2
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MusicListCustom Equal to 2
                • Then - Actions
                  • Sound - Play Song3
                • Else - Actions
Apparently, after countless tests, the random integer chosen is 2. Always. Song3 is always played when I test the map using TEST MAP in world editor. Of course, this case alone doesn't prove the point that the random number function is acting weird, but I have more cases to show.

2. Random Point Usage
I have a trigger that spawns a number of Trees at a random point in a
specified region.
  • Start Here
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 125, do (Actions)
        • Loop - Actions
          • Set TreeSpawnPoint = (Random point in Limiter <gen>)
          • Destructible - Create a Ashenvale Tree Wall at TreeSpawnPoint facing (Random angle) with scale 1.00 and variation (Random integer number between 0 and 4)
          • Custom script: call RemoveLocation(udg_TreeSpawnPoint)
          • Custom script: set udg_TreeSpawnPoint = null
      • For each (Integer A) from 1 to 25, do (Actions)
        • Loop - Actions
          • Set TreeSpawnPoint = (Random point in Limiter <gen>)
          • Destructible - Create a Ashenvale Canopy Tree at TreeSpawnPoint facing (Random angle) with scale 2.00 and variation (Random integer number between 0 and 2)
          • Custom script: call RemoveLocation(udg_TreeSpawnPoint)
          • Custom script: set udg_TreeSpawnPoint = null
In the trigger above, a random point is used to spawn a tree. Again, with so many tests, the trees seem to be spawning on the same spot. Always, when I use TEST MAP on world editor.

3. Random Integer for Variation Selection
Notice that in the trigger above (Tree Spawn Trigger), I also used a random integer function to randomly select each tree's variation. It is a funny thing that their variation always stay the same when I TEST MAP using world editor. It can't be a coincidence to have the trees spawning on the same place with the same variation even if I used random number generation functions with it!

What's the deal with this? Playing the map without using TEST MAP works fine though, but why is it acting like this? There must be some explanation behind this. I don't know if the problem is in my map itself or... I don't know...

:goblin_boom:
 
Level 3
Joined
Jan 24, 2015
Messages
26
I see! Thanks for that information.

Why would they put that option though?

It's to help reliably test stuff like critical strikes and such, which should roll many times over the course of a test. Though that obviously doesn't really apply to what you're using random for.
 
Status
Not open for further replies.
Top