• 🏆 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!

Issues with random generator.

Status
Not open for further replies.
Level 5
Joined
Mar 24, 2020
Messages
80
Hi guys,

The game I've made relies quite heavily on a variety of factors that randomize within the first few seconds of game time. These include:

- Doodad & destructible locations.
- Region locations (for spawning).

The issue is, even when hosting online with real players, that the game doesn't randomize, it generates the same locations each times. An example of the trigger below.

  • Spawn Domain Gates
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set VariableSet ZombieRandomSpawn[1] = (Random point in Main Map Cropped <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Centre <gen> contains ZombieRandomSpawn[1]) Equal to False
        • Then - Actions
        • Else - Actions
          • Set VariableSet ZombieRandomSpawn[1] = (Random point in Main Map <gen>)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Centre <gen> contains ZombieRandomSpawn[1]) Equal to False
            • Then - Actions
            • Else - Actions
              • Set VariableSet ZombieRandomSpawn[1] = (Random point in Main Map <gen>)
      • Region - Center Zombie Spawn 1 <gen> on ZombieRandomSpawn[1]
      • Set VariableSet DomainGateRegions[0] = Zombie Spawn 1 <gen>
      • Destructible - Pick every destructible within 2000.00 of ZombieRandomSpawn[1] and do (Destructible - Remove (Picked destructible))
      • Set VariableSet SpawnLocation = (Random point in Zombie Spawn 1 <gen>)
      • Unit - Create 1 Domain Gate for Player 12 (Brown) at SpawnLocation facing (Position of (Triggering unit))
      • Set VariableSet DomainGate[1] = (Last created unit)
      • Unit - Make (Last created unit) Invulnerable
      • Custom script: call RemoveLocation(udg_SpawnLocation)
      • Environment - Create Blight for Player 11 (Dark Green) from ZombieRandomSpawn[1] to a radius of 1500.00.
Are there any techniques I could use to make sure that these factors do randomize? The locations only ever really change if I have made quite big changes to any triggers.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
It might be the fixed random seed setting in the editor.

upload_2020-10-3_12-48-17.png


Make sure the "Use Fixed Random Seed" is unchecked
 
Level 20
Joined
Feb 27, 2019
Messages
593
  • Spawn Domain Gates
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set VariableSet ZombieRandomSpawn[1] = (Random point in Main Map Cropped <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Centre <gen> contains ZombieRandomSpawn[1]) Equal to True
        • Then - Actions
          • Custom script: call RemoveLocation(udg_ZombieRandomSpawn[1])
          • Trigger - Run (This trigger) (ignoring conditions)
          • Skip remaining actions
        • Else - Actions
Would this work?

I dont see why the zombiespawn isnt random though...
 
Level 5
Joined
Mar 24, 2020
Messages
80
  • Spawn Domain Gates
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set VariableSet ZombieRandomSpawn[1] = (Random point in Main Map Cropped <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Centre <gen> contains ZombieRandomSpawn[1]) Equal to True
        • Then - Actions
          • Custom script: call RemoveLocation(udg_ZombieRandomSpawn[1])
          • Trigger - Run (This trigger) (ignoring conditions)
          • Skip remaining actions
        • Else - Actions
Would this work?

I dont see why the zombiespawn isnt random though...
Definitely a way to smooth out my trigger (which i've actually implemented - cheers!). Unfortunately doesn't randomize though. D:
 
Level 20
Joined
Feb 27, 2019
Messages
593
I noticed have an issue with random seed :/ ticking off use random seed doesnt work. It has worked before.

EDIT:
This is a bug that should be fixed in the latest PTR patch: Warcraft III: Reforged PTR Patch Notes - Version 1.32.9
Oh... I thought it had already been updated but now I get it! So its a known bug that is going to be fixed.

But that still shouldnt affect custom games or games on the battle.net
 
Last edited:
Level 5
Joined
Mar 24, 2020
Messages
80
I noticed have an issue with random seed :/ ticking off use random seed doesnt work. It has worked before.

EDIT:

Oh... I thought it had already been updated but now I get it! So its a known bug that is going to be fixed.

But that still shouldnt affect custom games or games on the battle.net

I did another test on battle.net and it actually did work this time. But, it's odd i did like 3/4 tests yesterday and the map didnt randomize. Unless the spawns were identical out of chance haha!
 
Level 24
Joined
Jun 26, 2020
Messages
1,853
I did another test on battle.net and it actually did work this time. But, it's odd i did like 3/4 tests yesterday and the map didnt randomize. Unless the spawns were identical out of chance haha!
You can try make the generation start depends on something that you know will be different every match, like time to choose, the path of unit at the begging, some selections, etc.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
One way to force even more randomness is to have some aspect depend on user input. For example having a user press "start" and only then generating the map with some input based on the time it took to press. This really should not be required but still is technically sound and how many older games did randomness.
 
Level 5
Joined
Mar 24, 2020
Messages
80
One way to force even more randomness is to have some aspect depend on user input. For example having a user press "start" and only then generating the map with some input based on the time it took to press. This really should not be required but still is technically sound and how many older games did randomness.

You can try make the generation start depends on something that you know will be different every match, like time to choose, the path of unit at the begging, some selections, etc.

Right I see, I've been thinking about including an option to select the difficulty of the game so that could be the trigger to these events. That should make it randomize properly.

Thanks both.
 
Level 5
Joined
Mar 24, 2020
Messages
80
One way to force even more randomness is to have some aspect depend on user input. For example having a user press "start" and only then generating the map with some input based on the time it took to press. This really should not be required but still is technically sound and how many older games did randomness.

Sorry for the bump.

I created a dialogue option that is shown 1 second in that basically allows the host to decide on a difficulty. When a dialogue button is pressed it runs the trigger that randomly spawns the gates somewhere in the map.
Unfortunately still not randomizing. Even however long the host takes to press the button. So time doesn't seem to have an effect on it.

The conditions don't even work really either. Still gets spawned within regions it isn't supposed to.

Any other ideas on how I can try to make it work?

  • Spawn Domain Gate 1
    • Events
    • Conditions
    • Actions
      • Set VariableSet ZombieRandomSpawn[1] = (Random point in MapNorth <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (LargeCentre <gen> contains ZombieRandomSpawn[1]) Equal to True
              • (DenyGate1 <gen> contains ZombieRandomSpawn[1]) Equal to True
              • (DenyGate2 <gen> contains ZombieRandomSpawn[1]) Equal to True
              • (DenyGate3 <gen> contains ZombieRandomSpawn[1]) Equal to True
        • Then - Actions
          • Custom script: call RemoveLocation(udg_ZombieRandomSpawn[1])
          • Trigger - Run (This trigger) (checking conditions)
          • Skip remaining actions
        • Else - Actions
          • Set VariableSet ZombieRandomSpawn[1] = (Random point in MapNorth <gen>)
          • Region - Center Zombie Spawn 1 <gen> on ZombieRandomSpawn[1]
          • Set VariableSet DomainGateRegions[0] = Zombie Spawn 1 <gen>
          • Destructible - Pick every destructible within 2000.00 of ZombieRandomSpawn[1] and do (Destructible - Remove (Picked destructible))
          • Set VariableSet SpawnLocation = (Random point in Zombie Spawn 1 <gen>)
          • Unit - Create 1 Domain Gate for Player 12 (Brown) at SpawnLocation facing (Position of (Triggering unit))
          • Set VariableSet DomainGate[1] = (Last created unit)
          • Unit - Make (Last created unit) Invulnerable
          • Environment - Create Blight for Player 11 (Dark Green) from ZombieRandomSpawn[1] to a radius of 1500.00.
          • Custom script: call RemoveLocation(udg_ZombieRandomSpawn[1])
 
Level 20
Joined
Feb 27, 2019
Messages
593
There is an error in which you set the ZombieRandomSpawn[1] AGAIN after already setting it. This causes it to spawn in locations it shouldnt and the entire first part becomes useless. The error lies in Else - Actions Set VariableSet ZombieRandomSpawn[1] = (Random point in Mapnorth <gen>) which should be entirely removed from Else - Actions.

The randomization should work but if it doesnt there is nothing in the randomization that cares about how long time it takes for a player to pick an option. I believe it has to be triggered to have an effect. Perheaps changing some values every 0.02 seconds would theoretically change the randomization but I havnt tried that.

So how that could work is every 0.02 seconds of game time set ZombieRandomSpawn[1] = Random point in MapNorth <gen> then when a player clicks the dialog button turn off the trigger and use that location as the point for the rest of the trigger. This way there will be ~50 possible locations every second and the chance to get the same location two games in a row is very slim. Although at 10 seconds there would ONLY be ~5000 different locations which in a way is a bit few, but better than only 1 ofcourse. We also know that one often presses the button as quickly as possible which would leave even fewer locations. So its not a good option...

Another thing to have in mind is that when the game doesnt know a location it may default to the center of the map. So if your spawn always appears in the center of the map then that probably means there is a location that is set wrong.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Any other ideas on how I can try to make it work?
Although it really should not be necessary, the idea is you generate random numbers in a loop where loop count depends on time taken. The random numbers are not used, just generated as the act of generation will advance the random number generator internal seed. Another approach is to have a separate trigger that generates a random number every 0.02 seconds to force RNG to change with time.

Be aware that cinematic mode uses a constant seed. If you enable cinematic mode before any of these triggers run the results will always be the same. If this is not desired then cinematic mode must not be enabled until after the generation completes.
 
Level 5
Joined
Mar 24, 2020
Messages
80
There is an error in which you set the ZombieRandomSpawn[1] AGAIN after already setting it. This causes it to spawn in locations it shouldnt and the entire first part becomes useless. The error lies in Else - Actions Set VariableSet ZombieRandomSpawn[1] = (Random point in Mapnorth <gen>) which should be entirely removed from Else - Actions.

Thank you for spotting that! I think I had looked at that trigger too many times and completely missed that mistake!

I added a trigger that every 0.02 seconds repositioned the points up to the point the player decides on the difficulty. This worked! So thanks a lot guys for helping me get to this point.

Be aware that cinematic mode uses a constant seed. If you enable cinematic mode before any of these triggers run the results will always be the same. If this is not desired then cinematic mode must not be enabled until after the generation completes.

Thanks a lot for pointing that out! I did have cinematic mode on during this so that would've caused issues!

Case closed! Cheers guys.
 
Status
Not open for further replies.
Top