Explain/find out why this spell lags after a while.

minikrampan

Ultra Cool Member
Reaction score
28
Hey, I am just building a spell for fun. But it starts to lagg after a while and i don't know why. Help me find the leak or whatever it is.
I was thinking it is the unit group but woulnt destroying it cause the spell to malfunction?

Trigger:
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spell
    • Actions
      • Set Target = (Target point of ability being cast)
      • Set Castingunit = (Casting unit)
      • Set Timer = 0.00
      • Set Timer2 = 0.03
      • Environment - Create a 0.01 second Permanent crater deformation at Target with radius 400.00 and depth -500.00


Trigger:
  • Timer
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Timer = (Timer + Timer2)
      • If (Timer2 Less than 3.00) then do (Set Timer2 = (Timer2 + 0.01)) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Timer Greater than or equal to 200.00
        • Then - Actions
          • For each (Integer A) from 1 to 45, do (Actions)
            • Loop - Actions
              • If (anglecounter Equal to 360) then do (Set anglecounter = 0) else do (Set anglecounter = (anglecounter + 8))
              • Unit - Create 1 dummy Fire for (Owner of Castingunit) at Target facing Default building facing (270.0) degrees
              • Unit - Set the custom value of (Last created unit) to anglecounter
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit Group - Add (Last created unit) to unit_group
          • Set Timer = 0.00
        • Else - Actions
      • Unit Group - Pick every unit in unit_group and do (Actions)
        • Loop - Actions
          • Set temp_point2 = (Position of (Picked unit))
          • Set temp_point = (temp_point2 offset by 5.00 towards (Real((Custom value of (Picked unit)))) degrees)
          • Unit - Move (Picked unit) instantly to temp_point
          • Custom script: call RemoveLocation(udg_temp_point)
          • Custom script: call RemoveLocation(udg_temp_point2)


I know the Target-point is not being removed but the spell isnt finished yet.
and it shouldnt leak if i don't move the point right?
And it isnt the nova spawn either because if i change so it spawns every 5 seconds it works fine but after something like 10 pulses it starts lagging.

Or is it just to much stuff going on at the same time?
 

I_RULE_YOU

New Member
Reaction score
34
Your not destroying the unit group.

EDIT: CURSE YOUR LIGHTNING FAST RESPONSES TRIGGERHAPPY!
 

SerraAvenger

Cuz I can
Reaction score
234
Your never removing target, which causes an extra leak every cast. you also never destroy unit_group.

These aren't the problems. He only casts it once.

I guess it's the number of things you do every 0.03 seconds; Try to take out the "pick every unit and do" and check if it still laggs that much.

EDIT: If he'd really destroy the unitgroup, the spell would mess up. He's radialsymetrically sliding the units in a plane, so removing the group would prevent the units from being slided.
 

minikrampan

Ultra Cool Member
Reaction score
28
But if i remove the target point the units have nowhere to spawn and it shouldnt leak much because im not moving the point, If i cast the spell once again without removing the point then theres a leak.

and how should i destroy the unit group? Woulnt the spell malfunction? because i need the unit_group all the time.

These aren't the problems. He only casts it once.

I guess it's the number of things you do every 0.03 seconds; Try to take out the "pick every unit and do" and check if it still laggs that much.

EDIT: If he'd really destroy the unitgroup, the spell would mess up. He's radialsymetrically sliding the units in a plane, so removing the group would prevent the units from being slided.

Thank you, Thats what i thought And you where right removing the "pick every unit" worked, no lagg so i guess theres a leak or something?
 

Nerfpl

New Member
Reaction score
53
you should remove group at end of spell. make some event while it ends (1 timer or something like that)
 

minikrampan

Ultra Cool Member
Reaction score
28
That sucks, I want my spell to be longer then a couple of seconds and I can't remove the unit group while the spell is running.
I think i found the problem
Trigger:
  • Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to (Number of units in unit_group)


made a leaderboard.. The units in the unitgroup is never removed so the unit count goes friggin high.
How would i remove the "expiring units" From the unit group?
 
Reaction score
341
Trigger:
  • Custom script: call DestroyGroup(udg_unit_group)


Add that to the end of your trigger and it should be fine.
 

minikrampan

Ultra Cool Member
Reaction score
28
Trigger:
  • Timer
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Timer = (Timer + Timer2)
      • If (Timer2 Less than 3.00) then do (Set Timer2 = (Timer2 + 0.01)) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Timer Greater than or equal to 200.00
        • Then - Actions
          • For each (Integer A) from 1 to 45, do (Actions)
            • Loop - Actions
              • If (anglecounter Equal to 360) then do (Set anglecounter = 0) else do (Set anglecounter = (anglecounter + 8))
              • Unit - Create 1 dummy Fire for (Owner of Castingunit) at Target facing Default building facing (270.0) degrees
              • Unit - Set the custom value of (Last created unit) to anglecounter
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit Group - Add (Last created unit) to unit_group
          • Set Timer = 0.00
        • Else - Actions
      • Unit Group - Pick every unit in unit_group and do (Actions)
        • Loop - Actions
          • Set temp_point2 = (Position of (Picked unit))
          • Set temp_point = (temp_point2 offset by 5.00 towards (Real((Custom value of (Picked unit)))) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
              • Unit Group - Remove (Picked unit) from unit_group
              • Unit - Remove (Picked unit) from the game
            • Else - Actions
          • Unit - Move (Picked unit) instantly to temp_point
          • Custom script: call RemoveLocation(udg_temp_point)
          • Custom script: call RemoveLocation(udg_temp_point2)
      • Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to (Number of units in unit_group)


Works like a charm now =)


Trigger:
  • Custom script: call DestroyGroup(udg_unit_group)


Add that to the end of your trigger and it should be fine.

and yes i know how to remove leaks.

Thanks for help everyone
 

SerraAvenger

Cuz I can
Reaction score
234
Obviously not.

Obviously, you don't see the problem.
Killing the unit group at the end of the trigger won't help. He has to kill the unit group at the end of the whole spell. And no, when the spell is cast only once there is no leak at all.

EDIT: GJ on fixing the spell : ) Lagg does mostly come from bad algorithms, not so much from a leak here and there. And yes, leaking memory every 0.03 seconds is considerably a bad algorithm.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top