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

[Spell] Need Help about Leak

Status
Not open for further replies.
Level 3
Joined
Jan 1, 2013
Messages
43
I have download the spell here, i want to edit it, my problem is when i spam the spell it will make game delay
this is the trigger
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Dissipate Arrow [T]
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • ID2 Equal to 0
      • Then - Actions
        • Trigger - Turn on Dissipate Arrow Loop <gen>
      • Else - Actions
    • Set SBArray = (SBArray + 1)
    • Set ID2 = (ID2 + 1)
    • Set SBYesOrNo[SBArray] = True
    • Set SBCaster[SBArray] = (Triggering unit)
    • Set SBCasterPos[SBArray] = (Position of SBCaster[SBArray])
    • Set SBLevel[SBArray] = (Level of Dissipate Arrow [T] for SBCaster[SBArray])
    • Set SBPoint[SBArray] = (Target point of ability being cast)
    • Set SBAngle[SBArray] = (Angle from SBCasterPos[SBArray] to SBPoint[SBArray])
    • Set SBDistance[SBArray] = 0
    • Set SBTransparency[SBArray] = 0
    • Sound - Play PossessionMissileLaunch1 <gen> at 100.00% volume, located at SBCasterPos[SBArray] with Z offset 0.00
    • Set SBMaxDistance[SBArray] = 1500
    • Set SBBladeSpeed = 40.00
    • Set SBRadius = 150.00
    • Set SBDamage = (((Real(SBLevel[SBArray])) x 55.00) + 60.00)
    • Set SBTransparencyRate = 10
    • Unit - Create 1 Dissipate Arrow for (Owner of SBCaster[SBArray]) at SBCasterPos[SBArray] facing SBAngle[SBArray] degrees
    • Set SBBlade[SBArray] = (Last created unit)
    • Custom script: set udg_SBUnitGroupDamaged[udg_SBArray] = CreateGroup()
    • Animation - Change SBBlade[SBArray] flying height to 40.00 at 0.00
    • Custom script: call RemoveLocation(udg_SBCasterPos[udg_SBArray])
    • Custom script: call RemoveLocation(udg_SBPoint[udg_SBArray])
second trigger
  • Events
    • Time - Every 0.04 seconds of game time
  • Conditions
  • Actions
    • For each (Integer SB) from 1 to SBArray, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • SBYesOrNo[SB] Equal to True
          • Then - Actions
            • Set SBBladePos[SB] = (Position of SBBlade[SB])
            • Set SBBladePos_second = (SBBladePos[SB] offset by SBBladeSpeed towards SBAngle[SB] degrees)
            • Set SBDistance[SB] = (SBDistance[SB] + (Integer(SBBladeSpeed)))
            • Set SBUnitGroup[SB] = (Units within SBRadius of SBBladePos[SB])
            • Unit - Move SBBlade[SB] instantly to SBBladePos_second
            • Custom script: call RemoveLocation(udg_SBBladePos[udg_SB])
            • Custom script: call RemoveLocation(udg_SBBladePos_second)
            • Unit Group - Pick every unit in SBUnitGroup[SB] and do (Actions)
              • Loop - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • ((Picked unit) is alive) Equal to True
                    • ((Picked unit) is in SBUnitGroupDamaged[SB]) Equal to False
                    • ((Picked unit) belongs to an enemy of (Owner of SBBlade[SB])) Equal to True
                  • Then - Actions
                    • Set Diss_P = (Position of (Picked unit))
                    • Unit - Create 1 Dummy Support 1 for (Owner of SBCaster[SB]) at Diss_P facing SBAngle[SB] degrees
                    • Unit - Add a 0.03 second Generic expiration timer to (Last created unit)
                    • Unit - Add Inventory (Hero) to (Last created unit)
                    • Hero - Create Dissipate Arrow Illusion and give it to (Last created unit)
                    • Hero - Order (Last created unit) to use (Last created item) on (Picked unit)
                    • Sound - Play PossessionMissileHit1 <gen> at 100.00% volume, located at Diss_P with Z offset 0.00
                    • Unit - Cause SBBlade[SB] to damage (Picked unit), dealing SBDamage damage of attack type Spells and damage type Magic
                    • Unit Group - Add (Picked unit) to SBUnitGroupDamaged[SB]
                    • Custom script: call RemoveLocation(udg_Diss_P)
                  • Else - Actions
            • Custom script: call DestroyGroup(udg_SBUnitGroup[udg_SB])
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • SBDistance[SB] Greater than or equal to SBMaxDistance[SB]
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • SBTransparency[SB] Greater than or equal to 100
                  • Then - Actions
                    • Unit - Remove SBBlade[SB] from the game
                    • Custom script: call DestroyGroup(udg_SBUnitGroupDamaged[udg_SB])
                    • Set SBYesOrNo[SB] = False
                    • Set ID2 = (ID2 - 1)
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • SBArray Equal to 0
                      • Then - Actions
                        • Trigger - Turn off (This trigger)
                      • Else - Actions
                  • Else - Actions
                    • Animation - Change SBBlade[SB]'s vertex coloring to (100.00%, 100.00%, 100.00%) with (Real(SBTransparency[SB]))% transparency
                    • Set SBTransparency[SB] = (SBTransparency[SB] + SBTransparencyRate)
              • Else - Actions
          • Else - Actions
Please help me...
 
Level 7
Joined
Nov 15, 2009
Messages
225
Leaks are nothing to fear about.
Let me get you a little bit into it.

Imagine a variable is a memo.
You write the value down. Now you put that memo on your table.

To check what you wrote, you pick that memo and read.
Now you want to write down another thing.
To make sure you don't confuse yourself you strike anything before writing something else down.

Now here comes the problem.
If you repeat this step (writing more and more down) your memo is getting more and more unreadable (because you have no free space to write something down).
You still see that you already wrote something down, but you can't read it any longer.
How should you solve that problem?

Right! Take a new memo. And what do you do with the old?
You throw it in your bin (remove / destroy / 'null' it).
Now you always have a new and clean memo for your stuff you want to write down.

The striked values are the leak.



That could be an explaining what leaks are.
The only thing you need to know now is what leaks and how to get rid of it.

If you don't know it by heart, check this page and take a look at it.
Anything is listed there.


I hope I could make it understandable for you. :)
 
Level 3
Joined
Jan 1, 2013
Messages
43
Your triggers do not leak, except when you don't null the destroyed locations and groups.

You don't need to use arrays for the locations and groups. Only SBUnitGroupDamaged needs to be an array.

i think so...

But if i spam the spell, the game become slowly fps...

i'm so streess to make it fix...

please help me bos...
 
i think so...

But if i spam the spell, the game become slowly fps...

i'm so streess to make it fix...

please help me bos...
This is because your spell is creating a shitload of units and items on a 0.04 second timer. This spell is not something you should spam.

Besides, I'm pretty sure this spell can be done with only one global dummy.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Unit - Move SBBlade[SB] instantly to SBBladePos_second
->
  • Custom script : call SetUnitX(udg_SBBlade[udg_SB], GetLocationX(udg_SBBladePos_second)
  • Custom script : call SetUnitY(udg_SBBlade[udg_SB], GetLocationY(udg_SBBladePos_second)
That SetUnitX/Y is much faster operation than moving unit instantly.

Another optimization is not to create dummies to cast the item ability. Order the arrow dummy to cast the ability on all units. Set the dummy's death type to can't raise, does not decay. Art - cast point and art - cast backswing to 0. Movement speed to 0 and ofcourse the item ability cooldown to 0.
 
  • Unit - Move SBBlade[SB] instantly to SBBladePos_second
->
  • Custom script : call SetUnitX(udg_SBBlade[udg_SB], GetLocationX(udg_SBBladePos_second)
  • Custom script : call SetUnitY(udg_SBBlade[udg_SB], GetLocationY(udg_SBBladePos_second)
That SetUnitX/Y is much faster operation than moving unit instantly.

Another optimization is not to create dummies to cast the item ability. Order the arrow dummy to cast the ability on all units. Set the dummy's death type to can't raise, does not decay. Art - cast point and art - cast backswing to 0. Movement speed to 0 and ofcourse the item ability cooldown to 0.
I don't even see why it has to be an item ability.
Create ONE normal dummy (non hero!) unit and apply the item ability directly to the dummy, instead of creating an item and adding it.
Then use the above to make it cast instantly and simply move it around.
 
Status
Not open for further replies.
Top