Lagging bad I think I may have leaks...

Aibhin23

New Member
Reaction score
0
I think I might have some memory leaks in these triggers...lags real bad after using them several times. They all work but I did have a bug with the caster of Ocean's Fury. When the caster of it would attack someone, they would keep auto attacking until they died. It didnt matter if I tried to move him away, It was like he was paused but still attacking. I am not sure if these triggers are even good or not I just started playing with the editor so if you want let me know if anything else is wrong or if there is a better way I can do it.

Trigger:
  • Drought x Rain
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Drought/Rain
    • Actions
      • Set Casting_Unit[41] = (Triggering unit)
      • Set Casting_Unit_Target[41] = (Target unit of ability being cast)
      • Set Caster_Target_Position[41] = (Position of Casting_Unit_Target[41])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Casting_Unit_Target[41] belongs to an enemy of (Owner of Casting_Unit[41])) Equal to True
        • Then - Actions
          • Special Effect - Create a special effect at Caster_Target_Position[41] using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
          • Unit - Cause Casting_Unit[41] to damage Casting_Unit_Target[41], dealing 6.00 damage of attack type Hero and damage type Normal
          • Wait 1.00 seconds
          • Unit - Cause Casting_Unit[41] to damage Casting_Unit_Target[41], dealing 6.00 damage of attack type Hero and damage type Normal
          • Wait 1.00 seconds
          • Unit - Cause Casting_Unit[41] to damage Casting_Unit_Target[41], dealing 6.00 damage of attack type Hero and damage type Normal
          • Wait 1.00 seconds
          • Unit - Cause Casting_Unit[41] to damage Casting_Unit_Target[41], dealing 6.00 damage of attack type Hero and damage type Normal
          • Wait 1.00 seconds
          • Unit - Cause Casting_Unit[41] to damage Casting_Unit_Target[41], dealing 6.00 damage of attack type Hero and damage type Normal
          • Custom script: call RemoveLocation (udg_Caster_Target_Position[41])
        • Else - Actions
          • Set Caster_Target_Health[41] = (Life of Casting_Unit_Target[41])
          • Unit - Set life of Casting_Unit_Target[41] to (Caster_Target_Health[41] + 10.00)
          • Wait 1.00 seconds
          • Set Caster_Target_Health[41] = (Life of Casting_Unit_Target[41])
          • Unit - Set life of Casting_Unit_Target[41] to (Caster_Target_Health[41] + 10.00)
          • Wait 1.00 seconds
          • Set Caster_Target_Health[41] = (Life of Casting_Unit_Target[41])
          • Unit - Set life of Casting_Unit_Target[41] to (Caster_Target_Health[41] + 10.00)
          • Wait 1.00 seconds
          • Set Caster_Target_Health[41] = (Life of Casting_Unit_Target[41])
          • Unit - Set life of Casting_Unit_Target[41] to (Caster_Target_Health[41] + 10.00)
          • Wait 1.00 seconds
          • Set Caster_Target_Health[41] = (Life of Casting_Unit_Target[41])
          • Unit - Set life of Casting_Unit_Target[41] to (Caster_Target_Health[41] + 10.00)
          • Custom script: call RemoveLocation (udg_Caster_Target_Position[41])


Trigger:
  • Riverflow
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Riverflow
    • Actions
      • Set Casting_Unit[42] = (Triggering unit)
      • Set Casting_Unit_Target[42] = (Target unit of ability being cast)
      • Set Caster_Target_Position[42] = (Position of Casting_Unit_Target[42])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Casting_Unit_Target[42] belongs to an enemy of (Owner of Casting_Unit[42])) Equal to True
        • Then - Actions
          • Unit - Set Casting_Unit_Target[42] movement speed to ((Current movement speed of Casting_Unit_Target[42]) x 0.80)
          • Wait 5.00 seconds
          • Unit - Set Casting_Unit_Target[42] movement speed to ((Current movement speed of Casting_Unit_Target[42]) / 0.80)
          • Custom script: call RemoveLocation (udg_Caster_Target_Position[42])
        • Else - Actions
          • Unit - Set Casting_Unit_Target[42] movement speed to ((Current movement speed of Casting_Unit_Target[42]) / 0.80)
          • Wait 5.00 seconds
          • Unit - Set Casting_Unit_Target[42] movement speed to ((Current movement speed of Casting_Unit_Target[42]) x 0.80)
          • Custom script: call RemoveLocation (udg_Caster_Target_Position[42])


Trigger:
  • Low Tides x High Tides
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Low Tides/High Tides
    • Actions
      • Set Casting_Unit[43] = (Triggering unit)
      • Set Casting_Unit_Target[43] = (Target unit of ability being cast)
      • Set Caster_Target_Position[43] = (Position of Casting_Unit_Target[43])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Unit-type of Casting_Unit_Target[43]) Not equal to Faerie Dragon) and ((Unit-type of Casting_Unit_Target[43]) Not equal to Faerie Dragon)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Casting_Unit_Target[43] belongs to an enemy of (Owner of Casting_Unit[43])) Equal to True
            • Then - Actions
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] - 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] - 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] - 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] - 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] - 7.00)
              • Custom script: call RemoveLocation (udg_Caster_Target_Position[43])
            • Else - Actions
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] + 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] + 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] + 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] + 7.00)
              • Wait 1.00 seconds
              • Set Caster_Target_Mana[43] = (Mana of Casting_Unit_Target[43])
              • Unit - Set mana of Casting_Unit_Target[43] to (Caster_Target_Mana[43] + 7.00)
              • Custom script: call RemoveLocation (udg_Caster_Target_Position[43])
        • Else - Actions
          • Do nothing


Trigger:
  • Oceans Fury
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ocean's Fury
    • Actions
      • Set Casting_Unit[44] = (Triggering unit)
      • Set Caster_Position[44] = (Position of Casting_Unit[44])
      • Set Unit_Group[44] = (Units in (Entire map))
      • Unit Group - Pick every unit in Unit_Group[44] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of Casting_Unit[44])) Equal to False) and (((Picked unit) has buff Riverflow ) Equal to True)
            • Then - Actions
              • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Move (Picked unit) instantly to Caster_Position[44]
              • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of Casting_Unit[44])) Equal to True) and (((Picked unit) has buff Riverflow ) Equal to True)
            • Then - Actions
              • Set Caster_Target_Position[44] = (Position of (Picked unit))
              • Special Effect - Create a special effect at Caster_Target_Position[44] using Abilities\Spells\Items\AIta\CrystalBallCaster.mdl
              • Set Special_Effect[44] = (Last created special effect)
              • Unit - Pause (Picked unit)
              • Wait 5.00 seconds
              • Special Effect - Destroy Special_Effect[44]
              • Unit - Unpause (Picked unit)
              • Custom script: call RemoveLocation (udg_Caster_Target_Position[44])
            • Else - Actions
              • Do nothing
          • -------- ----------------------------------------------------------------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of Casting_Unit[44])) Equal to False) and (((Picked unit) has buff Drought/Rain ) Equal to True)
            • Then - Actions
              • Set Caster_Target_Health[44] = (Life of (Picked unit))
              • Unit - Set life of (Picked unit) to (Caster_Target_Health[44] + 100.00)
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of Casting_Unit[44])) Equal to True) and (((Picked unit) has buff Drought/Rain ) Equal to True)
            • Then - Actions
              • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Objects\Spawnmodels\Orc\Orcblood\BattrollBlood.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Cause Casting_Unit[44] to damage (Picked unit), dealing 100.00 damage of attack type Hero and damage type Normal
            • Else - Actions
              • Do nothing
          • -------- ----------------------------------------------------------------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of Casting_Unit[44])) Equal to False) and (((Picked unit) has buff Low/High Tides ) Equal to True)
            • Then - Actions
              • Set Caster_Target_Mana[44] = (Mana of (Picked unit))
              • Unit - Set mana of (Picked unit) to (Caster_Target_Mana[44] + 50.00)
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of Casting_Unit[44])) Equal to True) and (((Picked unit) has buff Low/High Tides ) Equal to True)
            • Then - Actions
              • Set Caster_Target_Mana[44] = (Mana of (Picked unit))
              • Unit - Set mana of (Picked unit) to (Caster_Target_Mana[44] - 50.00)
            • Else - Actions
              • Do nothing
 

tommerbob

Minecraft. :D
Reaction score
110
You are also leaking a Unit Group in the last trigger.

And do not use "Do Nothing." It calls a function that...does nothing. Instead just leave the space blank.

Instead of using Waits, you can use a Repeating timer. If you don't know what that is, here is an example of how to use one:

Trigger:
  • Events
    • Unit - A unit starts the effects of an ability
    • Conditions
      • (Ability being cast) equal to [your ability]
    • Actions
      • Countdown Timer - Start Timer[1] as a Repeating Timer than will expire in 1.00 seconds
      • Set Max_Ticks[1] = 10
      • Set Casting_Unit[1] = (Triggering unit)


Trigger:
  • Events
    • Countdown Timer - Timer[1] Expires
    • Conditions
    • Actions
      • Unit - Set Casting_Unit[1]'s current mana to (Current mana of Casting_Unit[1] - 7.00)
      • Set Ticks[1] = Ticks[1] + 1
      • If (all conditions are true) then do (then actions) else do (else actions)
        • If - Conditions
          • Ticks[1] is equal to or greater than Max_Ticks[1]
        • Then - Actions
          • Countdown Timer - Pause Timer[1]
        • Else - Actions


That was freehand so it might not be exact, but hopefully you get the idea. Using timers is much better than using waits if the time period is less than a few seconds. Besides, it makes it a lot easier to code and it makes your code look better. :thup:
 

Aibhin23

New Member
Reaction score
0
Ok, I'll fix those, thanks for showing me that repeating timer. I'm going to be added those instead now that I know of them.
 

B0ndo

New Member
Reaction score
4
Hmm wouldn't the timers require shitloads of triggers just for 1 spell? Since he has like 10 waits in 1 trigger.
 

vypur85

Hibernate
Reaction score
803
> bug with the caster of Ocean's Fury

Waits strictly do not work within a Unit Group block. If you wanna stun the unit, create a hidden dummy unit and order it to cast Storm Bolt that lasts for 5 seconds to the pick units.

Same goes to the others. Create dummy units to cast Slow (for movement speed reduction), Rejuvenation (for health/mana increment/decrement), and Unholy Frenzy (for damage over time) to the affected units. It's better and efficient than using waits or timers.


Edit:
Not too wise to use arrays with high values. Creating too many arrayed variables may lag the game badly, depending on how much you've set in the variable editor. So far, it seems fine to me in your triggers now, but I'm still unsure of what value you used in your variable editor.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top