Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[General] Lag Spikes in Map

Discussion in 'World Editor Help Zone' started by Freyky, Dec 31, 2016.

  1. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Why do maps have lag spikes and how do they get them?

    For example, In Fortress Survival I have almost no lag spikes, now in my map (228 x 228 or w/e) I get quite some lag spikes every 2 secs and it's a little bit annoying. How can I avoid them? Why do they appear anyways?

    Haven't got that much in my map yet, only thing in overdose I've got are 2x ~35 Waterfalls in almost 1 spot. But I've noticed those lags in my maps even without these massive waterfalls.

    PC Info:
    i5 Dual Core 3.30 GHz
    Geforce 750 GTX
    16 GB Ram
    Some very good screen idk the stats.

    Map info:
    ~1k Doodads
    ~60 Units
    15-20 Triggers

    Map:
    Imgur: The most awesome images on the Internet
     
  2. Usually caused by triggers. You say it lags periodically so can you post your periodic triggers here in [trigger]...[/trigger] tags, ... being CnP of trigger:
    upload_2016-12-31_23-12-0.png
     
  3. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    • sec check
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Triggering unit)) Equal to Grand Assasin
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • ((Picked unit) has buff Stealth ) Equal to True
                  • Then - Actions
                    • Set stealth[(Player number of (Picked player))] = 1
                  • Else - Actions
                    • Set stealth[(Player number of (Owner of (Picked unit)))] = 0
              • Else - Actions
        • Destructible - Pick every destructible in (Entire map) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Or - Any (Conditions) are true
                  • Conditions
                    • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
                    • (Destructible-type of (Picked destructible)) Equal to Snowy Tree Wall
                    • (Destructible-type of (Picked destructible)) Equal to Northrend Tree Wall
                    • (Destructible-type of (Picked destructible)) Equal to Winter Tree Wall
              • Then - Actions
              • Else - Actions
        • Set nmbr = 1
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant1 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 2
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant2 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 3
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant3 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 4
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant4 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 5
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant5 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions


    • treants move
      • Events
        • Time - Every 8.00 seconds of game time
      • Conditions
      • Actions
        • Unit - Order treant1 to Move To (Random point in treant 1 <gen>)
        • Unit - Order treant2 to Move To (Random point in treant 2 <gen>)
        • Unit - Order treant3 to Move To (Random point in treant 3 <gen>)
        • Unit - Order treant4 to Move To (Random point in treant 4 <gen>)
        • Unit - Order treant5 to Move To (Random point in treant 5 <gen>)



    Edit:

    Am I stupid or slow?
    I just found a way to calculate when a projectile hits a target... I've asked earlier for it in hive and ppl only said guess the time and insert it..
    But now I've got it tho:
    Formula:
    Distance (in units) / Projectile Speed (in units) = time when it'll hit.
    • Wait ((Distance between (Position of (Casting unit)) and (Position of (Target unit of ability being cast))) / 700.00) seconds
     
    Last edited: Dec 31, 2016
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Projectile launch and impact locations on both source & target models will slightly alter the time. If the target is moving parallel to the direction of travel of the projectile it will take longer or shorter (significantly so if the projectile is slow). Also Waits are not particularly accurate and can't go below a minimum threshold (~0.27s). So you're not wrong, but it's not really a 'good' method.
     
    Last edited: Dec 31, 2016
  5. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    But there's no perfect solution for this, so it's quite a good solution I guess :p, right? :p

    Edit: Oh and I've tested it from like ~70 units distance and 700 unit projectile speed, the timing with the projectile & damage was almost perfect.
     
  6. DarkBlueLacky

    DarkBlueLacky

    Joined:
    Nov 18, 2015
    Messages:
    41
    Resources:
    0
    Resources:
    0
    Does the map lag while you're playing it in custom games / Test map function from the WE?
    Potential culprits could be massive leaks.

    I get lag spikes on some maps but often it depends on the host of the game, as my internet connection is trash where I live and can't handle much.
     
  7. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,128
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Wait does not work well in multiplayer, possibly because it generates net traffic. It also varies with game speed. Hence it is not a real solution and certainly one I would recommend against using.

    Does your map use AI players of sorts? If they are running an AI script, eg melee AI, and cannot find a victim they will cause what people often think of as a lag spike. Basically their target or pathing search consumes a huge amount of time, as there are no reachable targets, causing one or more frames to be dropped. This is not real lag but more a performance problem.
     
  8. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Wait:
    Is there a better solution for the wait then? Because it looks quite weird if you cast a spell with the projectile animation taking 1 second to arrive but damage is already dealt upon casting the spell.

    AI:
    Yeah haven't removed AI init yet due to testing stuff, thanks :p I'll check it.
     
  9. Athur12A2

    Athur12A2

    Joined:
    Sep 16, 2016
    Messages:
    269
    Resources:
    6
    Models:
    6
    Resources:
    6
    • sec check
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Triggering unit)) Equal to Grand Assasin
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • ((Picked unit) has buff Stealth ) Equal to True
                  • Then - Actions
                    • Set stealth[(Player number of (Picked player))] = 1
                  • Else - Actions
                    • Set stealth[(Player number of (Owner of (Picked unit)))] = 0
              • Else - Actions
        • Destructible - Pick every destructible in (Entire map) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Or - Any (Conditions) are true
                  • Conditions
                    • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
                    • (Destructible-type of (Picked destructible)) Equal to Snowy Tree Wall
                    • (Destructible-type of (Picked destructible)) Equal to Northrend Tree Wall
                    • (Destructible-type of (Picked destructible)) Equal to Winter Tree Wall
              • Then - Actions
              • Else - Actions
        • Set nmbr = 1
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant1 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 2
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant2 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 3
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant3 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 4
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant4 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
        • Set nmbr = 5
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • treantsSec[nmbr] Greater than 0
          • Then - Actions
            • Set treantsSec[nmbr] = (treantsSec[nmbr] - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • treantsSec[nmbr] Less than or equal to 0
              • Then - Actions
                • Unit - Change ownership of treant5 to Neutral Passive and Retain color
              • Else - Actions
          • Else - Actions
    This leak unit group.
    The 1st part of this trigger does not do anything because (triggering unit) returns null in periodic event. The picking destructible part also the same, especially when you pick all of them, and do nothing. The more unit and destructible, the more this 2 run, making your wc3 run O(n). Save the "assassin" unit into a group variable and pick them specifically.
    You can just use a unit array and make all those 5 if-then-else a lot shorter with loop because... it really is one

    • treants move
      • Events
        • Time - Every 8.00 seconds of game time
      • Conditions
      • Actions
        • Unit - Order treant1 to Move To (Random point in treant 1 <gen>)
        • Unit - Order treant2 to Move To (Random point in treant 2 <gen>)
        • Unit - Order treant3 to Move To (Random point in treant 3 <gen>)
        • Unit - Order treant4 to Move To (Random point in treant 4 <gen>)
        • Unit - Order treant5 to Move To (Random point in treant 5 <gen>)

    This one leak, every 8s.

    Wait is a bad move, base the spell on Acid Bomb, detect unit takes damage and has the buff (DDS is recommended, actually for any map), remove the buff and make the spell work. (Or a custom missile system)
     
  10. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,128
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Trigger the entire spell (projectile and all) or at least use a timer as timers are much more accurate.
     
  11. Dehua_Darbuya

    Dehua_Darbuya

    Joined:
    Jan 28, 2016
    Messages:
    483
    Resources:
    0
    Resources:
    0
    Aside from the 5 simultaneous location leaks every 8 seconds, there are a few other things that could improve the performance of your map and make it easier to keep your triggers neat and tidy.

    Instead of picking every unit in the map, you can add all Assassin-type units into a global group when they enter play, are trained, sold, summoned, etc. This way when you get to your periodic trigger, it won't be so taxing.
    • Group Assassin
      • Events
        • Unit - A unit enters (Playable map area)
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Grand Assassin
      • Actions
        • Unit Group - Add (Triggering unit) to GroupAssassin



    We'll leave out your destructable loop for the moment since it doesn't do anything. As for your five If-Then-Else statements at the end, you could use a loop with the 'nmbr' variable and only one ITE statement instead. See below.
    • Periodic Check
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in GroupAssassin and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) has buff Stealth) Equal to True
              • Then - Actions
                • Set Stealth[(Player number of (Owner of (Picked unit)))] = 1
              • Else - Actions
                • Set Stealth[(Player number of (Owner of (Picked unit)))] = 0
        • For each (Integer Nmbr) from 1 to 5, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • TreantSec[Nmbr] Greater than 0
              • Then - Actions
                • Set TreantSec[Nmbr] = (TreantSec[Nmbr] - 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • TreantSec[Nmbr] Less than or equal to 0
                  • Then - Actions
                    • Unit - Change ownership of Treant[Nmbr] to Neutral Passive and Retain color
                  • Else - Actions
              • Else - Actions



    Same as the above trigger, you can use a loop to order the treants to move in their respective regions using both a unit array and a region array. Also, you need to set the point to a variable to clear the leak afterwards.
    • Treant Move
      • Events
        • Time - Every 8.00 seconds of game time
      • Conditions
      • Actions
        • For each (Integer Nmbr) from 1 to 5, do (Actions)
          • Loop - Actions
            • Set TempLoc = (Random point in TreantRegion[Nmbr])
            • Unit - Order Treant[Nmbr] to Move To TempLocation
            • Custom script: call RemoveLocation( udg_TempLoc )



    This is just setting the treants and their regions into arrays so that they can be used in the loops above.
    • Treant Store
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Set Treant[1] = Treant 0001 <gen>
        • Set Treant[2] = Treant 0002 <gen>
        • Set Treant[3] = Treant 0003 <gen>
        • Set Treant[4] = Treant 0004 <gen>
        • Set Treant[5] = Treant 0005 <gen>
        • Set TreantRegion[1] = Treant 1 <gen>
        • Set TreantRegion[2] = Treant 2 <gen>
        • Set TreantRegion[3] = Treant 3 <gen>
        • Set TreantRegion[4] = Treant 4 <gen>
        • Set TreantRegion[5] = Treant 5 <gen>
     
  12. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Thanks Dehua_Darbuya I'll try that out :p

    And how exactly would that look like, the way I'd do it, it'd prolly leak a lot as well xD

    Are there actually advanced tutorials for spell triggering? Only ones I found on google are the average ones adding special effects to a cast spell or hero attribute damage bonus, but those are basics everyone understands in one try
     
  13. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    All of the spells in the resource section can be picked apart to see how they work. As a general rule of thumb: if it's been approved then it meets a certain level of quality in its methodology.
     
  14. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    There are some specific languages or at least one in scripting I know good too, and I know it sounds logically for someone who is experienced in such stuff, but when u're a newb to it and there's a whole mess of functions u don't know and not quite understand, you'll just get lost. So learning from other scripts with almost no good experience in the subject is really not a good way. That's why tutorials are still good and worth to read.