• 🏆 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 is only random in some cases

Status
Not open for further replies.
I have a lot of things in my map that rely on random numbers, but only some of these things will change from map start to map start.

For instance.
Random generated gold mines seem to be placed the exact same places over and over again.

But a spawned Town Hall will be different from map start to map start.

This also seem to be the case when the map is started from WC3 and not through the editor.
 
There's a world editor setting called "random seed" or something, try changing that.

I have tried with it checked and unchecked. From what I can tell it's the same story.
And should this have any effect when the map is played from within WC3?


By the way.
The Town Hall I mentioned in post #1. It seem to only randomize between 3 points.


What I do is having a trigger which runs at 0.10 seconds in game time.
This trigger will run a series of other triggers. It's in these triggers the magic is happening (you should be happening). All that random stuff.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Did you check with Debug messages, whether the random numbers are what you expected? This will tell you, whether the calculation method of the random factor is not good enough or whether there is a simple bug somewhere.
You should also post the function, that is rolling the random numbers.
 
Did you check with Debug messages, whether the random numbers are what you expected? This will tell you, whether the calculation method of the random factor is not good enough or whether there is a simple bug somewhere.
You should also post the function, that is rolling the random numbers.

There are SO many randoms being generated in my map that I didn't bother.
Often I use the inherit "Random number between" in the function instead of using an integer set with "Random number between".

Edit:
Here is an example of the types pf triggers I use.

  • ...
The terrain will chance at the exact same spot using the exact same randoms every time I launch the map. Be it from the editor or from WC3.

Edit:
Alright so I think I have found what caused the problem.
In my map initialization I turned on Cinematic. It turns out that turning on Cinematic the random seed will be set to 0. I'm referring to this thread: http://www.hiveworkshop.com/forums/graveyard-418/snippet-random-seed-210426/ post #9 by Bribe.
 
Last edited:
Edit:
Alright so I think I have found what caused the problem.
In my map initialization I turned on Cinematic. It turns out that turning on Cinematic the random seed will be set to 0. I'm referring to this thread: http://www.hiveworkshop.com/forums/graveyard-418/snippet-random-seed-210426/ post #9 by Bribe.

Yep, this is the problem. They fix the seed because usually you want cinematics to be deterministic.

To change that, simply run this after turning cinematic mode on:
  • Cinematic - Turn Cinematic Mode On...
  • Custom script: call SetRandomSeed(bj_cineModeSavedSeed)
 
Yep, this is the problem. They fix the seed because usually you want cinematics to be deterministic.

To change that, simply run this after turning cinematic mode on:
  • Cinematic - Turn Cinematic Mode On...
  • Custom script: call SetRandomSeed(bj_cineModeSavedSeed)

Legend!

A couple of questions.
I'm curious. Is says "SavedSeed". How is that to be understood? Does it save the seed from before the cinematic is turned on or how does it work?

And

Turning cinematic mode off again won't affect the seed?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
I'm curious. Is says "SavedSeed". How is that to be understood? Does it save the seed from before the cinematic is turned on or how does it work?
As far as I can recall there is no native to get the actual RNG seed. Instead a random number in maximum range is fetched from the RNG and used as the seed since that number in some way reflects the seed but could be different from the seed. This distinction is important because it means after restoring seed the random results may be different than if they occurred without saving/loading the seed, basically a RNG sequence discontinuity.
 
It saves a random variable from 0 to 1,000,000 into the variable bj_cineModeSavedSeed when you turn cinematic mode on. Then it sets the seed to 0 for the cinematic.

When you turn cinematic mode off, it sets the seed to the stored value, as I showed in post #7.

So it doesn't actually store the seed itself, but rather just a random number. But it doesn't matter much, because that random number was already based on the seed you had at the time. As long as it isn't just some fixed seed (e.g. 0), you'll get the randomness you want. ;)

EDIT: DSG beat me to the post.
 
Status
Not open for further replies.
Top