• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Trigger - Region Array Assistance

Status
Not open for further replies.
Level 4
Joined
Aug 12, 2014
Messages
48
Have an idea for a map that I need some help with. Appreciate any ideas / help creating a trigger.

The map is like a chessboard. Each square is a region and the game is played from square to square. There are 100 squares and each one contains a resource (gold, lumber, food) or nothing. I have a test map (included) where I created the array and can trigger the creation of a unit in a random region. More or less working... but with a few critical flaws.

I need a trigger that creates a random resource inside of each square without the trigger creating more than one resource in each. So either I need some additional variables / arrays or I am going to have to trigger each and every single region. Right now, I have it set so that it picks a random region (to reduce the amount of triggers needed) but that really adds to the duplicating issue.

Surely there is an easier way?

Step by step example:
1: Game is loaded
2: 100 regions load / variables attached
3: trigger to create resources runs
4: trigger picks region 1 - creates tree
5: trigger picks region 2 - creates mine
6: trigger picks region 3 - creates nothing
7: trigger picks region 4 - creates food
8: trigger repeats until every region has had a chance at creating a resource
9: trigger ends, moves on to other map functions...
 

Attachments

  • testing array.w3x
    17.2 KB · Views: 63
Level 13
Joined
May 10, 2009
Messages
868
Use a Loop. With it, you won't run into a region more than once. Then, generate a random number in order to create a certain resource. I suggest using more variables so that you know which resource has been created for a region. It will be easier to handle them later.
 

Attachments

  • testing array.w3x
    18.4 KB · Views: 33
Level 4
Joined
Aug 12, 2014
Messages
48
Dude!!! You're awesome. I greatly appreciate you providing the triggers too, that is exactly what I was hoping for. I will go ahead and tinker with that and implement it into the full map.
 
Status
Not open for further replies.
Top