• 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] Not-so-random numbers.

Status
Not open for further replies.
Level 2
Joined
Apr 16, 2008
Messages
15
I'm attempting to create a trigger than has a chance to put an item in a random region. The items are already on the map, and the trigger is supposed to have a random chance to move a random item to a random region. I've got it semi-working, however I've noticed a few bugs.

Bug #1: The numbers (and the locations items end up) don't appear to be very random after all. I've restarted the map numerous times only to find that the same items end up in the same places.

Bug #2: Not so much a bug as a hole in my triggering ability. But with my current trigger the region that is decided on first has the greatest chance of getting an item, the 2nd less, the 3rd even less and so on. Is there a way to get every region to have the exact same chance to have an item moved there?

  • ArtifactSpawn
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 13, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • ((Random item in ArtifactSpawnRegions[(Integer A)]) is in ArtifactSpawnRegions[(Integer A)]) Equal to False
                  • (Random integer number between 1 and 4) Equal to (1)
            • Then - Actions
              • Item - Move (Random item in ItemPick <gen>) to (Center of ArtifactSpawnRegions[(Integer A)])
            • Else - Actions
              • Do nothing
      • Wait 0.50 seconds
      • Item - Pick every item in ItemPick <gen> and do (Item - Remove(Picked item))
Thanks in advance.
 
Level 6
Joined
Feb 2, 2005
Messages
205
The First Bug you noted, isn't really one. If you use the Test Map button in the World Editor it will use the same "random values" by default. You can change that in the option of the WE, just uncheck the box.

I would do the Trigger like this:
  • ArtifactSpawn
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Could Add a loop here --------
      • Set RandomRegion = (Random integer number between 1 and 13)
      • -------- RandomRegion is a Integer Variable --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • ((Random item in ArtifactSpawnRegions[RandomRegion]) is in ArtifactSpawnRegions[RandomRegion]) Equal to False
              • (Random integer number between 1 and 4) Equal to (1)
            • Then - Actions
              • Item - Move (Random item in ItemPick <gen>) to (Center of ArtifactSpawnRegions[RandomRegion])
            • Else - Actions
      • -------- End Loop here -------
      • Wait 0.50 seconds
      • Item - Pick every item in ItemPick <gen> and do (Item - Remove(Picked item))
If you want a loop to move more than one item, just loop it. There is also another way to create random items in random region. For that you would need an item array. It would look like this:

[Trigger=Array Solution]
ArtifactSpawn
Events
Map initialization
Conditions
Actions
-------- Declare the Item Array --------
Set Item[0] = RareItem1
Set Item[1] = RareItem2
Set Item[2] = RareItem3
Set Item[3] = RareItem4
Set Item[4] = RareItem5
-------- Could Add a loop here --------
Set RandomRegion = (Random integer number between 1 and 13)
Set ItemNumber = (Random integer number between 0 and 4)
-------- RandomRegion is a Integer Variable --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
Item[ItemNumber] is in ArtifactSpawnRegions[RandomRegion]) Equal to False
(Random integer number between 1 and 4) Equal to (1)
Then - Actions
Item - Create 1 Item[ItemNumber] at (Center of ArtifactSpawnRegions[RandomRegion])
Else - Actions
-------- End Loop here -------
[/Trigger]

Also Note both Triggers leak one location, to prevent leaks have a look at this thread.
 
Status
Not open for further replies.
Top