Those this leaks?

ccsdude

New Member
Reaction score
2
Hi, I just wanted to know if this spell I made leak, cause not sure and I am planing on use spells like this. Thx

Code:
Spell
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spell 
    Actions
        Set Caster = (Triggering unit)
        Set Caster_Pos = (Position of Caster)
        Set Offset = 0.00
        Set Degrees = 0.00
        For each (Integer A) from 1 to 20, do (Actions)
            Loop - Actions
                Unit - Create 1 Dummy for (Owner of Caster) at Caster_Pos facing Caster_Pos
                Set Dummy[(Integer A)] = (Last created unit)
                Unit - Move Dummy[(Integer A)] instantly to (Caster_Pos offset by 20.00 towards Degrees degrees), facing Caster_Pos
                Set Degrees = (Degrees + 18.00)
                Set Around[(Integer A)] = (Angle from Caster_Pos to (Position of Dummy[(Integer A)]))
                Unit - Add a 6.00 second Generic expiration timer to Dummy[(Integer A)]
        Trigger - Turn on Move Up <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Up <gen>
        Unit Group - Pick every unit in (Units within 600.00 of Caster_Pos matching (((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is dead) Equal to False))) and ((((Matching unit) belongs to an ally of (Owner of Caster)) E and do (Actions)
            Loop - Actions
                Unit Group - Add (Picked unit) to Unit_Coming
                Unit - Cause Caster to damage (Picked unit), dealing ((Distance between Caster_Pos and (Position of (Picked unit))) x (0.10 x (Real((Level of Spell  for Caster))))) damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                Special Effect - Destroy (Last created special effect)
        Trigger - Turn on Move Down <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Down <gen>
Code:
Move Up
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 20, do (Actions)
            Loop - Actions
                Unit - Move Dummy[(Integer A)] instantly to (Caster_Pos offset by Offset towards Around[(Integer A)] degrees)
                Set Offset = (Offset + 0.10)
                Set Around[(Integer A)] = (Around[(Integer A)] + 1.00)

Code:
Move Down
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 20, do (Actions)
            Loop - Actions
                Unit - Move Dummy[(Integer A)] instantly to (Caster_Pos offset by Offset towards Around[(Integer A)] degrees)
                Set Offset = (Offset - 0.10)
                Set Around[(Integer A)] = (Around[(Integer A)] - 1.00)
        Unit Group - Pick every unit in Unit_Coming and do (Actions)
            Loop - Actions
                Unit - Move (Picked unit) instantly to (Caster_Pos offset by Offset towards (Angle from Caster_Pos to (Position of (Picked unit))) degrees)
 

FireBladesX

Eating my wings!
Reaction score
123
It leaks.

Every time you reference a point, that point must be a variable.

For example, for this:
Unit - Move (Picked unit) instantly to (Caster_Pos offset by Offset towards (Angle from Caster_Pos to (Position of (Picked unit))) degrees)

you need to first do:
Set Caster Pos2 = Position of (Picked unit)
Set Caster_Pos3 = Caster_Pos offset by Offset towards (Angle from Caster_Pos to (Position of (Picked Unit))) degrees)

so, that ultimately means
Unit - Move (Picked unit) instantly to Caster_Pos3

Aaand, you have to clean up all that other stuff, of course.
Oh, I didn't even notice, you don't remove any leaks at all... you need to do "Custom Script: call RemoveLocation(udg_{insert variable name here})


Read some literature on leaks, ...Link!


Welcome to The Helper, btw.
 

ccsdude

New Member
Reaction score
2
Ok doing what you said and what I saw on the link you gave I change some stuff...

I will put in BOLD and BLUE the stuff that change or was added.

Code:
Spell
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spell 
    Actions
        Set Caster = (Triggering unit)
        Set Caster_Pos = (Position of Caster)
        Set Offset = 0.00
        Set Degrees = 0.00
        For each (Integer A) from 1 to 20, do (Actions)
            Loop - Actions
                Unit - Create 1 Dummy for (Owner of Caster) at Caster_Pos facing Caster_Pos
                Set Dummy[(Integer A)] = (Last created unit)
                Unit - Move Dummy[(Integer A)] instantly to (Caster_Pos offset by 20.00 towards Degrees degrees), facing Caster_Pos
                Set Degrees = (Degrees + 18.00)
                Set Around[(Integer A)] = (Angle from Caster_Pos to (Position of Dummy[(Integer A)]))
                Unit - Add a 6.00 second Generic expiration timer to Dummy[(Integer A)]
        Trigger - Turn on Move Up <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Up <gen>
        Unit Group - Pick every unit in (Units within 600.00 of Caster_Pos matching (((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is dead) Equal to False))) and ((((Matching unit) belongs to an ally of (Owner of Caster)) E and do (Actions)
            Loop - Actions
                [B][COLOR="blue"]Set Target_Pos = (Position of (Picked unit))[/COLOR][/B]
                Unit Group - Add (Picked unit) to Unit_Coming
                Unit - Cause Caster to damage (Picked unit), dealing (([B][COLOR="blue"]Distance between Caster_Pos and Target_Pos)[/COLOR][/B] x (0.10 x (Real((Level of Spell  for Caster))))) damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect at [B][COLOR="blue"]Target_Pos[/COLOR][/B] using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                Special Effect - Destroy (Last created special effect)
        Trigger - Turn on Move Down <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Down <gen>
        [B][COLOR="blue"]Custom script:   call RemoveLocation(udg_Caster_Pos)
        Custom script:   call RemoveLocation(udg_Target_Pos)
        Custom script:   call RemoveLocation(udg_Pos)[/COLOR][/B]

Code:
Move Down
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 20, do (Actions)
            Loop - Actions
                Unit - Move Dummy[(Integer A)] instantly to (Caster_Pos offset by Offset towards Around[(Integer A)] degrees)
                Set Offset = (Offset - 0.10)
                Set Around[(Integer A)] = (Around[(Integer A)] - 1.00)
        Unit Group - Pick every unit in Unit_Coming and do (Actions)
            Loop - Actions
                [B][COLOR="blue"]Set Target_Pos = (Position of (Picked unit))
                Set Pos = (Caster_Pos offset by Offset towards (Angle from Caster_Pos to Target_Pos) degrees)[/COLOR][/B]
                Unit - Move (Picked unit) instantly to [B][COLOR="blue"]Pos[/COLOR][/B]

Are there any more leaks, cause I tried putting the DestroyGroup but it just made my spell stop working after the first time it was cast. Thx
 

FireBladesX

Eating my wings!
Reaction score
123
It cleans some, but not all. I don't see the destroy group anywhere, either.
Colored it in green.
It would look like:

Set G = Units in (Playable Map Area)
Unit Group - Pick every unit in G and do (Actions):
Custom Script: call DestroyGroup(udg_G)

Code:
Spell
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spell 
    Actions
        Set Caster = (Triggering unit)
        Set Caster_Pos = (Position of Caster)
        Set Offset = 0.00
        Set Degrees = 0.00
        For each (Integer A) from 1 to 20, do (Actions)
            Loop - Actions
                Unit - Create 1 Dummy for (Owner of Caster) at Caster_Pos facing Caster_Pos
                Set Dummy[(Integer A)] = (Last created unit)
                Unit - Move Dummy[(Integer A)] instantly to [COLOR="Green"](Caster_Pos offset by 20.00 towards Degrees degrees)[/COLOR], facing Caster_Pos
                Set Degrees = (Degrees + 18.00)
                Set Around[(Integer A)] = (Angle from Caster_Pos to [COLOR="Green"](Position of Dummy[(Integer A)])[/COLOR])
                Unit - Add a 6.00 second Generic expiration timer to Dummy[(Integer A)]
        Trigger - Turn on Move Up <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Up <gen>
        [COLOR="Green"]Unit Group - Pick every unit in (Units within 600.00 of Caster_Pos matching (((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is dead) Equal to False))) and ((((Matching unit) belongs to an ally of (Owner of Caster)) E and do (Actions)[/COLOR]
            Loop - Actions
                Set Target_Pos = (Position of (Picked unit))
                Unit Group - Add (Picked unit) to Unit_Coming
                Unit - Cause Caster to damage (Picked unit), dealing ((Distance between Caster_Pos and Target_Pos) x (0.10 x (Real((Level of Spell  for Caster))))) damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect at Target_Pos using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                Special Effect - Destroy (Last created special effect)
        Trigger - Turn on Move Down <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Down <gen>
        Custom script:   call RemoveLocation(udg_Caster_Pos)
        Custom script:   call RemoveLocation(udg_Target_Pos)
        Custom script:   call RemoveLocation(udg_Pos)

Additional points:
-Waits don't mix well with leaks.
-Where do you set the group Unit_Coming?
-Every .01 seconds is pretty quick, and can lag if too much stuff happens. Every .02 seconds is half the lag, and to almost the same effect. Just double your numbers.
 

ccsdude

New Member
Reaction score
2
I did what you said and this is what I got now...

Code:
Spell
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spell 
    Actions
        Set Caster = (Triggering unit)
        Set Caster_Pos = (Position of Caster)
        Set Offset = 0.00
        Set Degrees = 0.00
        For each (Integer A) from 1 to 20, do (Actions)
            Loop - Actions
                Unit - Create 1 Dummy for (Owner of Caster) at Caster_Pos facing Caster_Pos
                Set Dummy[(Integer A)] = (Last created unit)
                [COLOR="lime"]Set Pos_Dummy = (Caster_Pos offset by 20.00 towards Degrees degrees)[/COLOR]                Unit - Move Dummy[(Integer A)] instantly to Pos_Dummy, facing Caster_Pos
                Unit - Move Dummy[(Integer A)] instantly to [COLOR="Lime"]Pos_Dummy[/COLOR], facing Caster_Pos
                Set Degrees = (Degrees + 18.00)
                Set Around[(Integer A)] = (Angle from Caster_Pos to (Position of Dummy[(Integer A)]))
                Unit - Add a 6.00 second Generic expiration timer to Dummy[(Integer A)]
        Trigger - Turn on Move Up <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Up <gen>
        [COLOR="lime"]Set Unit_Coming = (Units within 600.00 of Caster_Pos matching (((((Matching unit) is alive) Equal to True) and (((Matching unit) is dead) Equal to False)) and ((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of Caster)) Eq[/COLOR]
        [COLOR="lime"]Unit Group - Pick every unit in Unit_Coming and do (Actions)[/COLOR]
            Loop - Actions
                Set Target_Pos = (Position of (Picked unit))
                Unit - Cause Caster to damage (Picked unit), dealing ((Distance between Caster_Pos and Target_Pos) x (0.10 x (Real((Level of Spell  for Caster))))) damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect at Target_Pos using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                Special Effect - Destroy (Last created special effect)
        Trigger - Turn on Move Down <gen>
        Wait 3.00 seconds
        Trigger - Turn off Move Down <gen>
        Custom script:   call RemoveLocation(udg_Caster_Pos)
        Custom script:   call RemoveLocation(udg_Target_Pos)
        [COLOR="Lime"]Custom script:   call RemoveLocation(udg_Pos_Dummy)
        Custom script:   call RemoveLocation(udg_Pos_Unit)
        Custom script:   call DestroyGroup(udg_Unit_Coming)[/COLOR]

By the way, the part that says...
Set Around[(Integer A)] = (Angle from Caster_Pos to (Position of Dummy[(Integer A)]))

Do I have to make a variable for Position of Dummy[(Integer A)] or can it stay like that?
 

denmax

You can change this now in User CP.
Reaction score
155
Set Pos_Dummy = (Caster_Pos offset by 20.00 towards Degrees degrees)

-This really hurts..
Make it like this

Set Pos_Dummy[Integer A] = ...
<triggers>
Custom script: call RemoveLocation(udg_Pos_Dummy[bj_forLoopIndexA])

Every time you set a global variable without deleting it's previous data would create a leak.
 

ccsdude

New Member
Reaction score
2
Would it be ok to put like this instead of using an array...

Set Pos_Dummy = ...
<triggers>
Custom script: call RemoveLocation(udg_Pos_Dummy)

and should I do that on every loop that uses a point variable?like...

Code:
Unit Group - Pick every unit in Unit_Coming and do (Actions)
    Loop - Actions
        Set Target_Pos = (Position of (Picked unit))
        Unit - Cause Caster to damage (Picked unit), dealing ((Distance between Caster_Pos and Target_Pos) x (0.10 x (Real((Level of Spell  for Caster))))) damage of attack type Spells and damage type Magic
        Special Effect - Create a special effect at Target_Pos using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
        Special Effect - Destroy (Last created special effect)
        [COLOR="Blue"]Custom script:   call RemoveLocation(udg_Target_Pos)[/COLOR]

Code:
Unit Group - Pick every unit in Unit_Coming and do (Actions)
    Loop - Actions
        Set Target_Pos = (Position of (Picked unit))
        Set Pos_Unit = (Caster_Pos offset by Offset towards (Angle from Caster_Pos to Target_Pos) degrees)
        Unit - Move (Picked unit) instantly to Pos_Unit
        [COLOR="blue"]Custom script:   call RemoveLocation(udg_Target_Pos)
        Custom script:   call RemoveLocation(udg_Pos_Unit)[/COLOR]

Thx for the help... not very good at cleaning leaks... xD
 
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