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

Count the Number of Items in Map

Status
Not open for further replies.
Level 5
Joined
Jul 8, 2007
Messages
146
How can I make a trigger like this but so that it counts the number of items placed on the map.

  • Random Lumber
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
      • "Number of Items on Map < 200"
    • Actions
      • Item - Create Lumber Stack at (Random point in (Playable map area))
There is no condition like the one used in the pseudo-code above. Anyone have any ideas?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
Deifine placed.... If you mean items lose on the ground (not owned), then you simply enum through all items in the playable map area and use a global integer to count them. (this will need jass as you have better condition control then and can do actions in them which is neat)

If you have to include items in inventory, then the method is insanly slow and complex as ontop of the above you have to enum through all units with inventories and count how many each has of that item and add them to the counter.

I advise keeping track of change of item number rather than counting them (via a global). When ever one is ues, you remove one from the counter. When you create one you add one to the counter. Then you simply use the counter in an integer comparision as the condition. This is the most efficent way and the way I recommend as you do not count them each time, but have a count of how many at every time.
 
Status
Not open for further replies.
Top