1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  4. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Why Does This Trigger Lag Me?

Discussion in 'Triggers & Scripts' started by Daedin, Jun 10, 2009.

  1. Daedin

    Daedin

    Joined:
    Dec 4, 2007
    Messages:
    76
    Resources:
    0
    Resources:
    0
    So I made this trigger for a spell, and I wish to know why it lags me when I cast the spell..I can't seem to find any way it would leak, but then again, I suck at leak fixing...So can someone tell me whether it's a leak, or if this just lags because my computer sucks?

    • Aqua Crush 1
      • Events
        • Unit - A unit Begins casting an ability
      • Conditions
        • (Ability being cast) Equal to Aqua Crush
      • Actions
        • Set CastPoint = (Target point of ability being cast)
        • Set TempInt = 0.00
        • Unit Group - Pick every unit in (Units within 500.00 of (Target point of ability being cast) matching ((Owner of (Matching unit)) Equal to Neutral Hostile)) and do (Actions)
          • Loop - Actions
            • Unit Group - Add (Picked unit) to TempDmgGroup
        • For each (Integer A) from 1 to 8, do (Actions)
          • Loop - Actions
            • Set TempPoint = (CastPoint offset by 500.00 towards TempInt degrees)
            • Unit - Create 1 Dummy1 for (Owner of (Casting unit)) at TempPoint facing CastPoint
            • Custom script: call RemoveLocation(udg_TempPoint)
            • Unit - Add a 1.80 second Generic expiration timer to (Last created unit)
            • Unit Group - Add (Last created unit) to TempGroup
            • Set TempInt = (TempInt + 45.00)
            • Wait 0.02 seconds
        • Unit Group - Pick every unit in TempGroup and do (Actions)
          • Loop - Actions
            • Unit - Order (Picked unit) to Move To CastPoint
            • Wait 1.00 seconds
            • Custom script: call RemoveLocation(udg_CastPoint)
            • Unit Group - Remove all units of TempGroup from TempGroup
        • Unit Group - Pick every unit in TempDmgGroup and do (Actions)
          • Loop - Actions
            • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 250.00)
            • Unit Group - Remove all units of TempDmgGroup from TempDmgGroup


    :confused:
     
  2. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Well, first of all you're leaking a group here:

    • Unit Group - Pick every unit in (Units within 500.00 of (Target point of ability being cast) matching ((Owner of (Matching unit)) Equal to Neutral Hostile)) and do (Actions)


    And secondly:

    • Wait 0.02 seconds


    This isn't possible. The game will in reality wait somewhere between 0.1-0.5 seconds, since this is the minimum wait time for Wait (TriggerSleepAction())

    Thirdly:

    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • Unit - Order (Picked unit) to Move To CastPoint
        • Wait 1.00 seconds
        • Custom script: call RemoveLocation(udg_CastPoint)
        • Unit Group - Remove all units of TempGroup from TempGroup


    Wtf? I really hope blizz handles concurrent modification for unit groups cuz if not this will majorly screw up.
     
  3. Daedin

    Daedin

    Joined:
    Dec 4, 2007
    Messages:
    76
    Resources:
    0
    Resources:
    0
    @ Azn:
    1) Ty for the group leak. (How would i fix it though?)
    2) I just put a random wait time so it wouldn't create all the dummy unit's at once.
    3) I'm not sure what you meant with the last thing though, but it works, as far moving the units is concerned.
     
  4. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Put the action:

    • Custom script: "set bj_wantDestroyGroup = true"


    Immediately before the Unit Group action.

    And about the third thing: did something screw up when copy-pasting the trigger and put the two lines:

    • Custom script: call RemoveLocation(udg_CastPoint)
    • Unit Group - Remove all units of TempGroup from TempGroup


    inside the unit group loop when they're supposed to be outside? Cuz that would explain a lot.
     
  5. Daedin

    Daedin

    Joined:
    Dec 4, 2007
    Messages:
    76
    Resources:
    0
    Resources:
    0
    Alright, I removed the group leak and I put those two actions outside the Unit Group loop. It helped a tiny bit, but it still lags. I'm beginning to wonder if it's just my computer...
     
  6. Lord_BoNes

    Lord_BoNes

    Joined:
    Sep 5, 2007
    Messages:
    264
    Resources:
    0
    Resources:
    0
    You should use GroupClear() to blank out that group. :thumbs_up:
    • Custom script: call GroupClear(udg_TempGroup)
     
  7. maskedpoptart

    maskedpoptart

    Joined:
    Aug 4, 2006
    Messages:
    351
    Resources:
    1
    Spells:
    1
    Resources:
    1
    change the trigger to:
    • Aqua Crush 1
      • Events
        • Unit - A unit Begins casting an ability
      • Conditions
        • (Ability being cast) Equal to Aqua Crush
      • Actions
        • Set CastPoint = (Target point of ability being cast)
        • Set TempInt = 0.00
        • Set TempDmgGroup = (Units within 500.00 of CastPoint matching ((Owner of (Matching unit)) Equal to Neutral Hostile))
        • For each (Integer A) from 1 to 8, do (Actions)
          • Loop - Actions
            • Set TempPoint = (CastPoint offset by 500.00 towards TempInt degrees)
            • Unit - Create 1 Dummy1 for (Owner of (Casting unit)) at TempPoint facing CastPoint
            • Custom script: call RemoveLocation(udg_TempPoint)
            • Unit - Add a 1.80 second Generic expiration timer to (Last created unit)
            • Unit Group - Add (Last created unit) to TempGroup
            • Set TempInt = (TempInt + 45.00)
            • Wait 0.02 seconds
        • Unit Group - Pick every unit in TempGroup and do (Actions)
          • Loop - Actions
            • Unit - Order (Picked unit) to Move To CastPoint
        • Wait 1.00 seconds
        • Custom script: call RemoveLocation(udg_CastPoint)
        • Unit Group - Remove all units from TempGroup
        • Unit Group - Pick every unit in TempDmgGroup and do (Actions)
          • Loop - Actions
            • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 250.00)
        • Unit Group - Remove all units from TempDmgGroup

    i think this fixes all the leaks. the reason it was lagging is because the "Wait 1.00 seconds" was inside the unit group loop. why does this cause "lag"? suppose your TempGroup has 8 units in it. all of the actions in the loop will be executed for each unit in TempGroup. basically, you were waiting 1 second 8 times (8 seconds) before the units were damaged.