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

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 63
Joined
Jan 18, 2005
Messages
27,197
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