Help with Making Spells MUI/Cleaning Up leaks

trigger_newb

Active Member
Reaction score
3
Hi all, I've been having headaches trying to understand how to make a spell MUI/Leakless in GUI

This is just for fun so I know these spells wont lag me, but I want to know just for good practice and learning - how I can make these spells MUI. I've read lots of tutorials on them, but I still don't understand how to do so... Can someone walk me through on this one?
Code:
Spell 1
Surge Step Go
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Surge Step
    Actions
        Custom script:  local unit u
        Custom script:  local effect p
        Set ShadeEnd = ((Position of (Triggering unit)) offset by 500.00 towards (Facing of (Triggering unit)) degrees)
        Set ShadeTransparency = 25.00
        Set ShadeCaster = (Triggering unit)
        Set ShadePoint = ((Position of ShadeCaster) offset by 250.00 towards (Facing of ShadeCaster) degrees)
        Set ShadeLoc[0] = (Position of ShadeCaster)
        Unit - Create 1 Shade for (Owner of (Triggering unit)) at ShadePoint facing (Facing of ShadeCaster) degrees
        Set ShadeDummy = (Last created unit)
        Custom script:  set u = udg_ShadeDummy
        Custom script:  set udg_ShadeDummy = u
        Special Effect - Create a special effect attached to the weapon of ShadeDummy using Abilities\Spells\Other\HealingSpray\HealBottleMissile.mdl
        Set ShadeEffects[0] = (Last created special effect)
        Custom script:  set p = udg_ShadeEffects[0]
        Custom script:  set udg_ShadeEffects[0] = p
        Special Effect - Create a special effect at ShadeLoc[0] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Animation - Play ShadeDummy's attack animation
        Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency
        Set ShadeGroup[0] = (Units within 300.00 of (Position of ShadeDummy) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
        Unit Group - Pick every unit in ShadeGroup[0] and do (Actions)
            Loop - Actions
                Unit - Cause ShadeDummy to damage (Picked unit), dealing 250.00 damage of attack type Spells and damage type Normal
                Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Other\Transmute\PileofGold.mdl
                Special Effect - Destroy (Last created special effect)
        Set ShadeGroup[1] = (Units within 250.00 of (Position of ShadeCaster) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
        Unit Group - Pick every unit in ShadeGroup[1] and do (Actions)
            Loop - Actions
                Unit - Cause ShadeDummy to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
                Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Other\Transmute\PileofGold.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:  call SetUnitX( udg_ShadeCaster, GetLocationX(udg_ShadeEnd) )
        Custom script:  call SetUnitY( udg_ShadeCaster, GetLocationY(udg_ShadeEnd) )
        Countdown Timer - Start ShadeTimer[0] as a Repeating timer that will expire in 0.02 seconds
        Wait 1.50 seconds
        Custom script:  call PauseTimer(udg_ShadeTimer[0])
        Custom script:  call RemoveLocation(udg_ShadeLoc[0])
        Custom script:  call RemoveLocation(udg_ShadePoint)
        Custom script:  call RemoveLocation(udg_ShadeEnd)
        Custom script:  call DestroyGroup (udg_ShadeGroup[0])
        Custom script:  call DestroyGroup (udg_ShadeGroup[1])
        Custom script:  call DestroyEffect (p)
        Custom script:  call RemoveUnit (u)
        Custom script:  set u = null
        Custom script:  set p = null
 
Surge Step Clean
    Events
        Time - ShadeTimer[0] expires
    Conditions
    Actions
        Set ShadeTransparency = (ShadeTransparency + 1.00)
        Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency

This first spell basically blinks your caster a distance forward and creates an effect inbetween.



Code:
Spell 2
Spin Go
Events - Specific Unit takes damage,
Conditions
(Level of Assault Strike for (Damage source)) Greater than 0
Actions
Set SpinNer = (Damage source)
Set SpinTarget = (Triggering unit)
Set SpinPoint[0] = (Position of SpinNer)
Set SpinPoint[1] = ((Position of SpinTarget) offset by 100.00 towards (Random real number between 0.00 and 360.00) degrees)
Set SpinAOE = (Units within 225.00 of (Position of SpinTarget) matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of SpinNer)) Equal to True) and ((Matching unit) Not equal to SpinTarget))))
Unit Group - Pick every unit in SpinAOE and do (Actions)
Loop - Actions
Set SpinAOEPicked = (Picked unit)
Unit - Cause SpinDummy to damage SpinAOEPicked, dealing (0.15 x (Damage taken)) damage of attack type Chaos and damage type Normal
Special Effect - Create a special effect attached to the chest of SpinAOEPicked using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
Set SpinEffects[0] = (Last created special effect)
Special Effect - Create a special effect at SpinPoint[0] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
Special Effect - Destroy (Last created special effect)
Special Effect - Create a special effect attached to the chest of SpinTarget using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
Set SpinEffects[1] = (Last created special effect)
Custom script: call SetUnitX( udg_SpinNer, GetLocationX(udg_SpinPoint[1]) )
Custom script: call SetUnitY( udg_SpinNer, GetLocationY(udg_SpinPoint[1]) )
Custom script: call RemoveLocation(udg_SpinPoint[0])
Custom script: call RemoveLocation(udg_SpinPoint[1])
Custom script: call DestroyGroup(udg_SpinAOE)
Unit - Set life of SpinNer to ((Life of SpinNer) + 0.00)
Special Effect - Create a special effect attached to the head of SpinNer using Abilities\Spells\Undead\VampiricAura\VampiricAuraTarget.mdl
Special Effect - Destroy (Last created special effect)
Wait 0.70 seconds
Special Effect - Destroy SpinEffects[0]
Special Effect - Destroy SpinEffects[1]


This second spell is basically an built in blink, cleave attack, lifesteal into a regular units attack.

I've done what i can to try and cover up the leaks, but i still need help - on top of that I have no idea how to make them Multi Unit Instanceable. T-T can someone help me please?
 

afisakov

You can change this now in User CP.
Reaction score
37
I am not a master of MUI but I think I can help you out with some leaks.
First a couple tips for good practice:
1) destroy/remove any possible source of leaks once your done with it. For instance destroy the unit groups as soon as done using them. Remove locations once finished with them.
2) The game will always calculate a location if referencing a spot not already saved as one, major source of point leaks: eg. Position of (Triggering unit) is a location and leaks unless assigned to a temp point earlier and then removed after.
3) Waits can contribute to alot of accidental leaks, be sure to clean up before the wait unless a variable is essential to leave intance
I will focus on spell 1, bold some likely leaks or other mistakes I happen to find.
Code:
Spell 1
Surge Step Go
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Surge Step
    Actions
        Custom script:  local unit u
        Custom script:  local effect p
        Set ShadeEnd = ([B](Position of (Triggering unit)[/B]) offset by 500.00 towards (Facing of (Triggering unit)) degrees)   -leaked point
        Set ShadeTransparency = 25.00
        Set ShadeCaster = (Triggering unit)
        Set ShadePoint = (([B]Position of ShadeCaster) offset[/B] by 250.00 towards (Facing of ShadeCaster) degrees) -position of shade caster and that position offset are [B]2 [/B]points, you only fixed 1/2 leaks here
        Set ShadeLoc[0] = (Position of ShadeCaster)
        Unit - Create 1 Shade for (Owner of (Triggering unit)) at ShadePoint facing (Facing of ShadeCaster) degrees
        Set ShadeDummy = (Last created unit)
        Custom script:  set u = udg_ShadeDummy
        Custom script:  set udg_ShadeDummy = u     -this accomplishes nothing
        Special Effect - Create a special effect attached to the weapon of ShadeDummy using Abilities\Spells\Other\HealingSpray\HealBottleMissile.mdl
        Set ShadeEffects[0] = (Last created special effect)  -why not just set p directly
        Custom script:  set p = udg_ShadeEffects[0]
        Custom script:  set udg_ShadeEffects[0] = p    -pointless
        Special Effect - Create a special effect at ShadeLoc[0] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Animation - Play ShadeDummy's attack animation
        Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency
        Set ShadeGroup[0] = (Units within 300.00 of ([B]Position of ShadeDummy[/B]) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
        Unit Group - Pick every unit in ShadeGroup[0] and do (Actions)
            Loop - Actions
                Unit - Cause ShadeDummy to damage (Picked unit), dealing 250.00 damage of attack type Spells and damage type Normal
                Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Other\Transmute\PileofGold.mdl
                Special Effect - Destroy (Last created special effect)
        Set ShadeGroup[1] = (Units within 250.00 of ([B]Position of ShadeCaster[/B]) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
        Unit Group - Pick every unit in ShadeGroup[1] and do (Actions)
            Loop - Actions
                Unit - Cause ShadeDummy to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
                Special Effect - Create a special effect at ([B]Position of (Picked unit[/B])) using Abilities\Spells\Other\Transmute\PileofGold.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:  call SetUnitX( udg_ShadeCaster, GetLocationX(udg_ShadeEnd) )
        Custom script:  call SetUnitY( udg_ShadeCaster, GetLocationY(udg_ShadeEnd) )
        Countdown Timer - Start ShadeTimer[0] as a Repeating timer that will expire in 0.02 seconds
        Wait 1.50 seconds  -better to remove most of these before wait
        Custom script:  call PauseTimer(udg_ShadeTimer[0])
        Custom script:  call RemoveLocation(udg_ShadeLoc[0])
        Custom script:  call RemoveLocation(udg_ShadePoint)
        Custom script:  call RemoveLocation(udg_ShadeEnd)
        Custom script:  call DestroyGroup (udg_ShadeGroup[0])  -leak not really fixed because if anyone casts during wait group will overwrite and only second would get cleaned up
        Custom script:  call DestroyGroup (udg_ShadeGroup[1])
        Custom script:  call DestroyEffect (p)
        Custom script:  call RemoveUnit (u)
        Custom script:  set u = null
        Custom script:  set p = null
 
Surge Step Clean
    Events
        Time - ShadeTimer[0] expires   -why does this need to be every 0.2 seconds?
    Conditions
    Actions
        Set ShadeTransparency = (ShadeTransparency + 1.00)
        Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency
No guarantee I found all the mistakes,imperfections but I tried to advise on what I do know.
An improved version:
Code:
Spell 1
Surge Step Go
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Surge Step
    Actions
        Custom script:  local unit u
        Custom script:  local effect p
        Set ShadeCaster = (Triggering unit)
        Set ShadeLoc[0] = (Position of ShadeCaster)
        Set ShadeEnd = (ShadeLoc[0]) offset by 500.00 towards (Facing of (Triggering unit)) degrees)
        Set ShadeTransparency = 25.0
        Set ShadePoint = ((ShadeLoc[0]) offset by 250.00 towards (Facing of ShadeCaster) degrees) 
        Unit - Create 1 Shade for (Owner of (Triggering unit)) at ShadePoint facing (Facing of ShadeCaster) degrees
        Set ShadeDummy = (Last created unit)
        Custom script:  set u = udg_ShadeDummy
        Special Effect - Create a special effect attached to the weapon of ShadeDummy using Abilities\Spells\Other\HealingSpray\HealBottleMissile.mdl
        Custom script:  set p = bj_lastCreatedEffect
        Special Effect - Create a special effect at ShadeLoc[0] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Animation - Play ShadeDummy's attack animation
        Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency
        Set ShadeGroup[0] = (Units within 300.00 of (ShadePoint) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
        Unit Group - Pick every unit in ShadeGroup[0] and do (Actions)
            Loop - Actions
                Unit - Cause ShadeDummy to damage (Picked unit), dealing 250.00 damage of attack type Spells and damage type Normal
                set temp_point=Position of (Picked unit)
                 Special Effect - Create a special effect at (temp_point) using Abilities\Spells\Other\Transmute\PileofGold.mdl
                Special Effect - Destroy (Last created special effect)
                call RemoveLocation (udg_temp_point)
        Custom script:  call DestroyGroup (udg_ShadeGroup[0])        Set ShadeGroup[1] = (Units within 250.00 of (ShadeLoc[0]) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
        Unit Group - Pick every unit in ShadeGroup[1] and do (Actions)
            Loop - Actions
                Unit - Cause ShadeDummy to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
                set temp_point=Position of (Picked unit)
                Special Effect - Create a special effect at (temp_point) using Abilities\Spells\Other\Transmute\PileofGold.mdl
                Special Effect - Destroy (Last created special effect)
                call RemoveLocation (udg_temp_point)
        Custom script:  call DestroyGroup (udg_ShadeGroup[1])
        Custom script:  call SetUnitX( udg_ShadeCaster, GetLocationX(udg_ShadeEnd) )
        Custom script:  call SetUnitY( udg_ShadeCaster, GetLocationY(udg_ShadeEnd) )
        Custom script:  call RemoveLocation(udg_ShadeLoc[0])
        Custom script:  call RemoveLocation(udg_ShadePoint)
        Custom script:  call RemoveLocation(udg_ShadeEnd)
 Countdown Timer - Start ShadeTimer[0] as a Repeating timer that will expire in 0.02 seconds
        Wait 1.50 seconds  
        Custom script:  call PauseTimer(udg_ShadeTimer[0])
        Custom script:  call DestroyEffect (p)
        Custom script:  call RemoveUnit (u)
        Custom script:  set u = null
        Custom script:  set p = null
 
Surge Step Clean
    Events
        Time - ShadeTimer[0] expires   -why does this need to be every 0.2 seconds? not entirely sure what it accomplishes
    Conditions
    Actions
        Set ShadeTransparency = (ShadeTransparency + 1.00)
        Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency
I really doubt my version is perfect but I know I removed a couple leaks at least and you can learn from what I changed and use the tips I wrote in to understand why I made some of the changes.
 
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