| 09-11-2002, 02:10 AM | #1 |
The other day, I ran into a strange bug. In my map, random numbers always appeared in the same order after the map was started. Not in WE's map testing mode, either, but in the full blown game. Pretty weird to say the least. After a huuuuge amount of going through my triggers, I isolated the problem to a trigger that ran upon initialization which turned cinematic mode on. When this trigger was run, subsequent random numbers always were created from the same seed (before this, the seed varied, since the names of the heroes were random, as they should have been). At this point, Nihilist made the key observation that buried deep in the bowels of blizzard.j lies the problem. Apparently, the function CinematicModeBJ calls SetRandomSeed(0) "so that cinematics play consistantly." The effect of this is to nix all subsequent randomness in the map, since turning off cinematic mode doesn't restore the random seed. Nihilist's advice is to add the line SetRandomSeed (MAP_LOCK_RANDOM_SEED); or SetRandomSeed (32728); - which should have the same effect after a cinematic is used. I haven't tested this, but hopefully this will restore randomness to susequent random calls. I'm posting this not so much because I have a problem (anymore), but to alert other people to this "feature." |
| 09-11-2002, 01:37 PM | #2 |
thats interesting and useful, thx man I discovered an issue too yesterday, when you cast blizzard on a paused unit, only the first waves causes damage (very frustrating coz i made a timestop spell using pause unit, and the same hero that has time stop also has blizzard which is his main damage-causing spell) I can probably fix this with a trigger, tho I need to know the radius of Blizzard, anyone know? |
| 09-11-2002, 02:16 PM | #3 |
Guest | Are you sure about this? I use some basic camera work within letterbox mode when my map begins, then have some random functions later on - and they seem to work "properly". I have two timers that will fire at a random time between 20 and 30 seconds, and they don't fire concurrently - which I assume they would do if the random seed was set at 0. |
| 09-11-2002, 04:17 PM | #4 | |
Quote:
I've designed a simple map that has a single random function call for a real between 0 and 5 when esc is pressed and a cinematic mode on/off trigger that works upon initialization. Play the map once and you get 4.563....1.432....0.897, etc. Play the map a second time and you get the same numbers. Nihilist hypothesized that the seed is only a factor in making the random numbers based on the system time, and not the *only* factor, so randomness wouldn't disappear even with a seed of 0. As for your map, if you're merely using letterbox mode and not cinematic mode, it wouldn't apply. I checked out blizzard.j myself last night and can confrim that that is how cinematic mode is designed to run. |
| 09-11-2002, 06:18 PM | #5 | |
Guest | Quote:
Got it. Good thing to know :) |
