HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Not random enough?

04-06-2007, 11:18 AM#1
Beelzebub
I need a fairly reliable way to get a random integer for use in a race selection trigger. Right now I've a temporary integer variable which I set to a random value using the "Math - Random.." thing. But I always get the same race when I test.

How do I make it more random? ;)
04-06-2007, 11:26 AM#2
Krysho
File->preferences->Test Map tab->uncheck "Use Fixed Random Seed"
04-06-2007, 11:35 AM#3
Beelzebub
It is already unchecked :/
04-06-2007, 11:58 AM#4
Blackroot
If it's already unchecked, it's probably a problem with the trigger rather than the random number. Just use BJDebugMsg to display the random number, and if it's the same repeatedly, then you'll know if the random number is actually at fault.
04-06-2007, 12:35 PM#5
blu_da_noob
Try testing from within WC3 itself anyway. Also be warned that if there is some cinematic mode thing that will set your random seed to a constant value, so this might be an issue if you use any cinematic stuff.
04-06-2007, 03:25 PM#6
Beelzebub
The trigger:

Trigger:
Race choosed
Collapse Events
Dialog - A dialog button is clicked for RaceChoose
Conditions
Collapse Actions
If ((Clicked dialog button) Equal to DialogButton[1]) then do (Melee Game - Create Human starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If ((Clicked dialog button) Equal to DialogButton[2]) then do (Melee Game - Create Orc starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If ((Clicked dialog button) Equal to DialogButton[3]) then do (Melee Game - Create Undead starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If ((Clicked dialog button) Equal to DialogButton[4]) then do (Melee Game - Create Night Elf starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[5]
Collapse Then - Actions
Set TempInteger = (Random integer number between 1 and 4)
If (TempInteger Equal to 1) then do (Melee Game - Create Human starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If (TempInteger Equal to 2) then do (Melee Game - Create Orc starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If (TempInteger Equal to 3) then do (Melee Game - Create Human starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If (TempInteger Equal to 4) then do (Melee Game - Create Human starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
Else - Actions
Dialog - Hide RaceChoose for (Triggering player)
If ((Triggering player) Equal to Player 1 (Red)) then do (Trigger - Run Food Limit <gen> (ignoring conditions)) else do (Do nothing)
04-06-2007, 03:32 PM#7
akolyt0r
Trigger:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to DialogButton[5]
Then - Actions
Set TempInteger = (Random integer number between 1 and 4)
If (TempInteger Equal to 1) then do (Melee Game - Create Human starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If (TempInteger Equal to 2) then do (Melee Game - Create Orc starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If (TempInteger Equal to 3) then do (Melee Game - Create Human starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
If (TempInteger Equal to 4) then do (Melee Game - Create Human starting units for (Triggering player) at ((Triggering player) start location) (Include Heroes)) else do (Do nothing)
Else - Actions

u have Human three times in there....shouldnt be there all 4 races ?!
04-06-2007, 03:41 PM#8
Beelzebub
Oh god, I'm off to kill myself.
04-06-2007, 04:47 PM#9
Zwan
hah, sometimes it's the simple things that are overlooked first. Dont worry, it has happened to everyone =P
04-06-2007, 08:09 PM#10
Mezzer
Also, hitting the test button in WE will usually give me the same starting random value. Just FYI.