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

Leak variables...

Status
Not open for further replies.
Level 3
Joined
Jan 23, 2014
Messages
32
Hi friends, i need help. Why do i have Leaks when i activate these variables? Try putting the same variable for all and even Array does not work, provided that the active and start playing, begins to unplayable Leaks. How do i get those active variables without Leaks?

Divine Shield:

  • Divine Shield Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Shield (Custom; Bandit Lord)
    • Actions
      • Set DivineShield_Caster = (Triggering unit)
      • Trigger - Turn on Divine Shield Loop <gen>
  • Divine Shield Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set DivineShield_Group = (Units in (Playable map area)) ---> (DEACTIVATED)
      • Set Spell_Group = (Units in (Playable map area)) ---> (TESTING)
      • Unit Group - Pick every unit in Spell_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Divine Shield) Equal to True
            • Then - Actions
              • Unit - Add Divine Shield (Spellbook; Magic Resistance) to (Picked unit)
            • Else - Actions
              • Unit - Remove Divine Shield (Spellbook; Magic Resistance) from (Picked unit)
      • Custom script: call DestroyGroup(udg_DivineShield_Group) ---> (DEACTIVATED)
      • Custom script: call DestroyGroup(udg_Spell_Group) ---> (TESTING)
Thorns Aura:

  • Thorns Aura New
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set ThornsAura_Group = (Units in (Playable map area)) ---> (DEACTIVATED)
      • Set Spell_Group = (Units in (Playable map area)) ---> (TESTING)
      • Unit Group - Pick every unit in Spell_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Thorns Aura) Equal to True
            • Then - Actions
              • Unit - Add Thorns Aura (Spellbook) to (Picked unit)
            • Else - Actions
              • Unit - Remove Thorns Aura (Spellbook) from (Picked unit)
      • Custom script: call DestroyGroup(udg_ThornsAura_Group) ---> (DEACTIVATED)
      • Custom script: call DestroyGroup(udg_Spell_Group) ---> (TESTING)
  • Inner Fire Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Inner Fire (Custom; Blood Knight)
          • (Ability being cast) Equal to Inner Fire (Custom; Forest Troll High Priest)
    • Actions
      • Set InnerFire_Caster = (Triggering unit)
      • Trigger - Turn on Inner Fire Loop <gen>
  • Inner Fire Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set InnerFire_Group = (Units in (Playable map area)) ---> (DEACTIVATED)
      • Set Spell_Group = (Units in (Playable map area)) ---> (TESTING)
      • Unit Group - Pick every unit in Spell_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Inner Fire) Equal to True
            • Then - Actions
              • Unit - Add Inner Fire (Spellbook) to (Picked unit)
              • Unit - Set level of Inner Fire (Dummy) for (Picked unit) to (Level of Inner Fire (Custom; Forest Troll High Priest) for InnerFire_Caster)
              • Unit - Set level of Inner Fire (Dummy) for (Picked unit) to (Level of Inner Fire (Custom; Blood Knight) for InnerFire_Caster)
            • Else - Actions
              • Unit - Remove Inner Fire (Spellbook) from (Picked unit)
      • Custom script: call DestroyGroup(udg_InnerFire_Group) ---> (DEACTIVATED)
      • Custom script: call DestroyGroup(udg_Spell_Group) ---> (TESTING)
And another 10 Triggers with the same function.

Spell_Group is the test variable Iput to them.
 
What makes you think that it leaks?
That's the proper way to destroy a unit group, like you're doing already:

Set myGroup = ..
PickAllUnitsIn myGroup..
call DestroyGroup(udg_myGroup)

Enumerating all units in map is quite a heavy operation.
I can imagine doing it that often like each 0.1 seconds might cause lags.

Indexing is by far much more efficient than group enumerations. It might help you.
Also I don't see you ever turn off the periodic triggers.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Ah lol I missed the part of All units in playable map area :D

When a unit is gaining the buff (inner fire for example), you add it to the group "InnerFireGroup".
If InnerFireGroup has one unit at that moment, you turn on the loop trigger of that spell.

Then you use the InnerFireGroup and do the actions only on those units.
In that action, you check if the unit has the buff and if true, you do the actions and if false, you remove the unit from the group. Also when you remove the unit from the group, you check if the number of units in InnerFireGroup is equal to 0 and turn the loop off if that is true.

You could also use a buff system... cough* signature cough* and make that system do all the work for you.
 
Level 3
Joined
Jan 23, 2014
Messages
32
What makes you think that it leaks?
That's the proper way to destroy a unit group, like you're doing already:

Set myGroup = ..
PickAllUnitsIn myGroup..
call DestroyGroup(udg_myGroup)

Enumerating all units in map is quite a heavy operation.
I can imagine doing it that often like each 0.1 seconds might cause lags.

Indexing is by far much more efficient than group enumerations. It might help you.
Also I don't see you ever turn off the periodic triggers.

I know it's the right way but... every time active variables and start the game, it triggers an unbearable Leak... the point is paralyzed. I think by the periodic time, proves deactivating it and doing what you say, adding the Index and turn off the periodic trigger... but i have a couple of questions, i was reading the Indexer and so little i could understand is that works for skills temporary. Will it work with auras? if i add turn off the periodic trigger. Do not disable auras them permanently?

Ah lol I missed the part of All units in playable map area :D

When a unit is gaining the buff (inner fire for example), you add it to the group "InnerFireGroup".
If InnerFireGroup has one unit at that moment, you turn on the loop trigger of that spell.

Then you use the InnerFireGroup and do the actions only on those units.
In that action, you check if the unit has the buff and if true, you do the actions and if false, you remove the unit from the group. Also when you remove the unit from the group, you check if the number of units in InnerFireGroup is equal to 0 and turn the loop off if that is true.

You could also use a buff system... cough* signature cough* and make that system do all the work for you.

I had not thought, proves what you say and see if it works but... again, i doubt it will work with auras.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,195
Why do i have Leaks when i activate these variables?
Nothing you said there makes any sense. Variables cannot be "activated" as far as I am aware as they act as persistent storage locations for data.

Variables also cannot be deactivated as a result. You can assign a value to a variable if it is non-constant. You can also pre-allocate arrays due to their underlying dynamic array implementation.

I do not see any obvious leaks. The performance problems you are reporting is likely a result of the complexity of the script you are running. Instead of enumerating all units on the map it might be a good idea to reduce the set size by only searching for units nearby aura providers. Additionally you may want to remove abilities from units which actually have the ability as the remove ability behaviour might not be well defined on units without the specified ability.

Unless you pre-load the abilities you add, you can expect frame drops the first time the triggers run. This is due to a resource stall as it fetches and loads the resources needed for the ability. If your computer has a very slow hard disk that can last for several seconds however it should be once off per session.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You are not experiencing leak lagg but operation lagg.
You pick every unit in map every 0.1 seconds. (10X per second)
Then you do that action for every spell and you mentioned that you do that in 14 spells. (140X per second)
Now you pick every unit 140 times per second... that is hell for your game.

When a unit is gaining the buff (inner fire for example), you add it to the group "InnerFireGroup".
If InnerFireGroup has one unit at that moment, you turn on the loop trigger of that spell.

Then you use the InnerFireGroup and do the actions only on those units.
In that action, you check if the unit has the buff and if true, you do the actions and if false, you remove the unit from the group. Also when you remove the unit from the group, you check if the number of units in InnerFireGroup is equal to 0 and turn the loop off if that is true.
 
Basically, as stated before by others, it's operation lag, enumeration is heavy as said before.

Wietlol solution is very good, and used widely in many spells. Else if you want you can also choose IcemanBo's suggestion, but it's kinda complex for this case.
Dr Super Good also states an important thing about Preload, if this already lags whenever used, this will double (or worse, triples) lag itself when first time used, solution is to preload them early in game.

I recall creating similar spell which involves aura. Maybe I'll check my folders later.
 
Level 3
Joined
Jan 23, 2014
Messages
32
Problem solved, i had to remove the "Initially On" to Triggers. Thanks anyway for helping me guys. xD
 
Status
Not open for further replies.
Top