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

Why Does This Trigger Lag Me?

Status
Not open for further replies.
Level 4
Joined
Dec 4, 2007
Messages
76
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:
 
Level 11
Joined
Feb 22, 2006
Messages
752
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.
 
Level 4
Joined
Dec 4, 2007
Messages
76
@ 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.
 
Level 11
Joined
Feb 22, 2006
Messages
752
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.
 
Level 8
Joined
Aug 4, 2006
Messages
357
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.
 
Status
Not open for further replies.
Top