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

Help make leakless and lagless

Status
Not open for further replies.
Level 9
Joined
Jul 20, 2009
Messages
427
How do I make this lagless and leakless?Coz the units are trained and when there are a number of them on the map it lags..Maybe its because the loop that checks the picked unit position?
  • Wander and Gather
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Group = (Units in (Playable map area) matching ((((Matching unit) has buff Wander and Gather ) Equal to True) and ((Unit-type of (Matching unit)) Equal to Gatherer)))
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Loc = (Position of (Picked unit))
          • Set Temp_Real = 9999999.00
          • Item - Pick every item in (Playable map area) and do (Actions)
            • Loop - Actions
              • Set Temp_Loc2 = (Position of (Picked item))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Temp_Loc and Temp_Loc2) Less than Temp_Real
                  • (Number of items carried by (Picked unit)) Less than 3
                • Then - Actions
                  • Set Temp_Item = (Picked item)
                  • Set Temp_Real = (Distance between Temp_Loc and Temp_Loc2)
                  • Unit - Order (Picked unit) to Right-Click (Picked item)
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Temp_Loc2)
      • Custom script: call RemoveLocation(udg_Temp_Loc)
      • Custom script: call DestroyGroup(udg_Temp_Group)
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
No, it's because you run the check for every unit x every item, which can easily get to very high numbers. You have several options:
1. don't check all units at once, create a trigger that runs every 0.01 seconds and checks 1 unit (each run a different unit)
2. pick only items in certain range of unit, if there is no, make it go random direction, it will find some item eventually
3. don't create tempgroup, use a predefined group, and manually add/remove units when they cast the "Wander and Gather" (or turn it on or whatever, i don't know how that works)
 
Status
Not open for further replies.
Top