• 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.

[Trigger] Making a random point in region TRUE random

Status
Not open for further replies.
Level 4
Joined
Aug 17, 2008
Messages
81
I'm using a massive trigger cluster at the beginning of the game to create thousands of units. Works great, the only problem is that the location of all the randomly generated units is always the same! This is bad since the whole point of it is to make the unit's location random.

  • Resources Spawn
    • Events
    • Conditions
    • Actions
      • Custom script: loop
      • Custom script: exitwhen 0 == udg_Resource_Integer
      • Set RandomPoint = (Random point in Relevant_Region)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at RandomPoint of type Walkability is off) Equal to False
        • Then - Actions
          • Unit - Create 1 Relevant_Unit for Player 9 (Gray) at RandomPoint facing Default building facing degrees
          • Set Resource_Integer = (Resource_Integer - 1)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_RandomPoint)
      • Custom script: endloop
This is the trigger that is being called thousands of time at once when the game starts. How do I make my trigger's random locations different every game in the most efficient way possible?
 
Level 4
Joined
Aug 17, 2008
Messages
81
Disabled Fixed Seed, Tested as Test map and Regular Map.

v3k6C.jpg

9NLjy.jpg


Both were screenshots taken from different games. It still isn't randomizing properly.
 
TRUE random doesn't exist on a computer (and anywhere too). The random function is just more and more calculs and the result depend of more and more parameters. So if the rocks are created at the map initialisation, the random function's parameters will be only the same.

Like in your brain. If i tell you to choice a random number, this random number will depend of your minds, what you lived, etc...
As if I told you to count in your head and to stop when I say stop, the "random number" will depend of many parameters (your reaction time for start counting, if you count fast or slow, how many time i wait before say stop, etc...)

The random and the luck are just imaginary thing.
 
Level 4
Joined
Aug 17, 2008
Messages
81
Still, there must be a way to make it generate differently each game instead of always being the same.
I tried having it function after random delays, and after random integer additions/checksums. Nothing I've tried is giving me a random result unless I base it off of a players action, which is inadequate since it's supposed to function before players have unit control. If I have to base it off of a unit being selected or moving or something first; to make the roll an uncontrollable variable; the pause will make it will look very bad. I'd like to avoid that at all costs.

A delay before based off of all player name string checks might work for a decent random roll. But I don't know the best way to go about that. Frankly I think it will probably fail too.
 
Level 7
Joined
Sep 5, 2006
Messages
333
spawn when the first order is issued,

e.g spawn the ores when you detect the first move order any player, then use the order's target position to make the random number (normal random * order X coord / order Y coord)
 
Level 9
Joined
Jul 10, 2011
Messages
562
how big is the region you put the resources in? because if its small the points are nearly the same everytime if it bigger than the chance of being the same spot everytime is smaller...
 
Level 8
Joined
Dec 9, 2009
Messages
397
You could try a different method using math random number if you got the coordinates within your region

Then x = random number, and y = random number

  • Set TempLoc = ((Center of Rect 000 <gen>) offset by ((Random real number between -5000.00 and 5000.00), (Random real number between -5000.00 and 5000.00)))
then just check if your loc is in Rect

The more times it's not in the more random it'll be I'd assume
 
Level 4
Joined
Aug 17, 2008
Messages
81
how big is the region you put the resources in? because if its small the points are nearly the same everytime if it bigger than the chance of being the same spot everytime is smaller...

The resource trigger is being called thousands of times at once in 37 regions, one of which is the entire playable map area.

Each region is relatively large, the one I'm testing is always the first in order to be called, and is approximately 5500 x 5500 in size.
 
Level 4
Joined
Aug 17, 2008
Messages
81
You could try a different method using math random number if you got the coordinates within your region

Then x = random number, and y = random number

  • Set TempLoc = ((Center of Rect 000 <gen>) offset by ((Random real number between -5000.00 and 5000.00), (Random real number between -5000.00 and 5000.00)))
then just check if your loc is in Rect

The more times it's not in the more random it'll be I'd assume

Is your suggestion to calculate delay before the triggers are called, or changing the call function itself?
 
Level 8
Joined
Dec 9, 2009
Messages
397
I suggest using the random number function to get a location on your map, then check if that location is within the region you want, and if not it'll just recalculate.

Using the center of the region as the starting point, as more of a chance to be in it.

You could also save the number of times it's not in the region in a variable just so you know if you should make the numbers larger or smaller.
 
Level 4
Joined
Aug 17, 2008
Messages
81
I tried as you suggested, Ultimatony, but in a broader sense as to not waste time configuring it for each region. -16000/16000 covers the entire size of the map. By doing this it took longer to run all the triggers, but I was able to verify something; It doesn't work. The resources are still being created at the same locations every game. Here is what the updated trigger looked like:

  • Resources Spawn Ultimatony
    • Events
    • Conditions
    • Actions
      • Custom script: loop
      • Custom script: exitwhen 0 == udg_Resource_Integer
      • Set RandomPoint = (Point((Random real number between -16000.00 and 16000.00), (Random real number between -16000.00 and 16000.00)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at RandomPoint of type Walkability is off) Equal to False
          • (Relevant_Region contains RandomPoint) Equal to True
        • Then - Actions
          • Unit - Create 1 Relevant_Unit for Player 9 (Gray) at RandomPoint facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Resources
          • Unit - Hide (Last created unit)
          • Set Resource_Integer = (Resource_Integer - 1)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_RandomPoint)
      • Custom script: endloop
I really need help on this, the functioning random factor is a crucial requirement for my map. Nothing I've tried so far is working. Does anyone have any other ideas for me to try? Perhaps it's something to do with the trigger being cluster called thousands of times at once? Anything? :/
 
Level 8
Joined
Dec 9, 2009
Messages
397
Try setting that up to trigger off first time someone moves.

Other than that, we would have to find out how often the game changes it's random factors.
 
Level 4
Joined
Aug 17, 2008
Messages
81
Try setting that up to trigger off first time someone moves.

Other than that, we would have to find out how often the game changes it's random factors.

Start the trigger calls with:
  • Unit - A unit Is issued an order targeting a point
I just tried this previously failed method combined with your previous suggested trigger changes.

Fail + Fail = Double Fail. It's still not working. The same resources every game! :goblin_cry:
 
Level 4
Joined
Aug 17, 2008
Messages
81
did you take the target point of order issued into consideration?

I tried that before, and it did not work either. I don't think combining two failures together will result in it working, so I won't try that again. There must be a relatively simple solution to this. =..=..

Anyone know what it is? -plays around with triggers more trying to fix it-
 
Level 4
Joined
Aug 17, 2008
Messages
81
ShadowHunter291 said:
SOLUTION: After several hours of gazing at my triggers, baffled at what could possibly be causing this. At long last, all that was left that I hadn't tried was turning off the map's starting cinematic mode. I did this... and finally the number outcomes were random. HOW THIS IS SO I HAVE NO IDEA, but cinematic mode seems to stop the randomization process.

Several tests have confirmed this.
Man I would have never guessed.

Found this via google searching "Random Seeds WC3 Trigger" in hopes to find someone who had a similar problem. I found this solution, thank goodness he posted his solution, I would have never guessed!

I removed my cinematic mode at the beginning of the game, and BOOM! Random seeds are working!

SOLVED.
 
Status
Not open for further replies.
Top