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

[Solved] Why does this Leak?

Status
Not open for further replies.
Level 4
Joined
Sep 25, 2015
Messages
56
1708459603571.png

AFAIK item groups don't leak but testing in-game I start lagging within less than a minute
 
Last edited:

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
I thought it shouldn't too, but when I tested in-game it lagged like hell and didn't without the trigger
That's probably because you are looping through all the units on the map every 0.10 seconds, applying conditions, and ordering them to target an item - all of them (that match). So it would not surprise me if it lagged.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
For every unit owned by Coal, you loop over every item in the map and order that one single unit to interact with every item that is Meat.

Every unit owned by Coal is each ordered to pick up every Meat (however many times that is). Every 0.10 seconds.

Does that sound like a proper solution to you? What exactly are you trying to achieve?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
Oh, you're right nvm. I knew it was bad but not that bad. Theres no lag with 1s timer event
Remember, you can manually manage your Unit Groups. It's far easier for the game to process this in multiple steps spread over time:
  • Events
    • Unit - A unit Enters playable map area
  • Conditions
    • (Owner of (Triggering unit)) Equal to Player 21 (Coal)
  • Actions
    • Unit Group - Add (Triggering unit) to Player_Units[21]
^ Or better yet use an Event that's more specific to your situation -> "A unit is Trained/Summoned" or Add them after you Create them with triggers.
  • Events
    • Unit - A unit Dies
  • Conditions
    • (Owner of (Triggering unit)) Equal to Player 21 (Coal)
  • Actions
    • Unit Group - Removes (Triggering unit) from Player_Units[21]
^ We're now doing things in a way that is Event based which is great since it removes the random time element from it. You now know PRECISELY when Player 21 has run out of units which is quite useful. You could even throw in an Integer variable to track the number of these Units so you can display them in a Multiboard or whatever -> "Number of enemies remaining".

Constantly rebuilding the Unit Group over and over again is often unnecessary, inefficient, and just bad triggering practice.

Plus, you can probably narrow it down even further like Pyro suggested. I doubt that you actually need to order ALL of those Units to get the Meat. How about just certain types? Or how about just ordering X amount of them from the Unit Group where X is the number of Meat. There's always optimizations that can be made.
 
Last edited:
Status
Not open for further replies.
Top