Spell Trigger Makes Lag

eric92

New Member
Reaction score
3
This spell trigger is making my game lag. After I cast it a few times it starts to get laggy, can anyone help me figure out why? I have tried multiple things. If I cast the spell like 20 times then it will get really really really laggy.

Just so you know what the trigger does, it just makes 6 dummy units in a straight line in whatever direction you are facing, then they all cast thunderclap. Its a beam spell.

Trigger:
  • Energy Beam
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Beam1
    • Actions
      • -------- Setting Variables --------
      • Set ThunderCaster = (Casting unit)
      • Set ThunderPoint = (Position of ThunderCaster)
      • Set EffectPoint = 0.00
      • -------- Finished Setting --------
      • -------- ----------- --------
      • -------- Pause Caster --------
      • Wait 0.15 seconds
      • Unit - Pause ThunderCaster
      • -------- ----------- --------
      • -------- Increase the "6" to make more and longer effects --------
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • -------- Setting Point Again --------
          • -------- Increasing the "150" with make large spaces between effects and visa versa --------
          • Set EffectPoint = (EffectPoint + 150.00)
          • -------- ----------- --------
          • -------- Special Effects --------
          • Special Effect - Create a special effect at (ThunderPoint offset by EffectPoint towards (Facing of ThunderCaster) degrees) using Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
          • Special Effect - Destroy (Last created special effect)
          • -------- ----------- --------
          • -------- Creating Dummy and Setting Ability --------
          • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by EffectPoint towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
          • -------- ----------- --------
          • -------- Unpausing Caster --------
      • Unit - Unpause ThunderCaster
      • -------- ----------- --------
      • -------- Clearing Leak --------
      • Custom script: call RemoveLocation(udg_ThunderPoint)
      • Set ThunderCaster = No unit
      • -------- ----------- --------
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Every time you use a point with an offset, that creates another point, which will leak. Use this scheme:

Set Point1
Set Point2 = Point 1 with offset...
<Do stuff>
Clear Point2
Clear Point1
 

Corleone

New Member
Reaction score
44
Points offset in one direction also leak. You should create a seperate location variable for the offset point and delete it at the end.

After all, casting the spell 20 times will create 120 memory leaks.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
You have some point called ThunderPoint, right? So you set it and then use it a few times, then destroy it to stop the leak that would otherwise occur.
That's all well and good, but you have more work to do.

Any action that uses a Point with Polar Offset (or any kind of offset, really) will leak TWICE. It leaks once for the first point, and once for the new point after the offset is applied. So you need to have two variables in order to clean up the leak. First you set the original point. In your case, that is the ThunderPoint, so you have that done already. Then you need to set a point to use as the new offset point. So you set some new variable (we'll call it ThunderPoint2) to the offset that you want. Something like this:

Set ThunderPoint2 = ThunderPoint offset by X towards Y degrees

Then in your action where you use that offset point, you would do something like this:

Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees

Then after this:

Unit - Order (Last created unit) to Human Mountain King - Thunder Clap

you need to destroy ThunderPoint2 so you can set it again during the next loop. This will properly clean all the leaks.
 

N582114

New Member
Reaction score
2
They're saying that

Trigger:
  • ThunderPoint offset by EffectPoint towards


is causing your leaks.

Create a variable to set Thunderpoint's offset onto it.

Use RemoveLocation (udg_Point1) to remove these leaks.

Point1 = Thunderpoint's offset
 

eric92

New Member
Reaction score
3
Ok this is what I have now, do i also delete the effect point? like delete it out of the trigger i mean? I took the comments out so it would be easier to see. It is still lagging on me.


Trigger:
  • Energy Beam
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Beam1
    • Actions
      • Set ThunderCaster = (Casting unit)
      • Set ThunderPoint = (Position of ThunderCaster)
      • Set ThunderPoint2 = (ThunderPoint offset by 0.00 towards 0.00 degrees)
      • Set EffectPoint = 0.00
      • Wait 0.15 seconds
      • Unit - Pause ThunderCaster
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set EffectPoint = (EffectPoint + 150.00)
          • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint2 offset by EffectPoint towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Unpause ThunderCaster
      • Custom script: call RemoveLocation(udg_ThunderPoint)
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
 

Corleone

New Member
Reaction score
44
This something like this:

Trigger:
  • Energy Beam
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Beam1
    • Actions
      • Set ThunderCaster = (Casting unit)
      • Set ThunderPoint = (Position of ThunderCaster)
      • Set EffectPoint = 0.00
      • Wait 0.15 seconds
      • Unit - Pause ThunderCaster
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set EffectPoint = (EffectPoint + 150.00)
          • Set ThunderPoint2 = (ThunderPoint offset by EffectPoint towards (Facing of ThunderCaster))
          • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint2) facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Unpause ThunderCaster
      • Custom script: call RemoveLocation(udg_ThunderPoint)
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Custom script: set ThunderPoint = null
      • Custom script: set ThunderPoint2 = null
 

eric92

New Member
Reaction score
3
Ok everything functions properly in your trigger except for the null part, that made it so the game wouldn't start. But it still lags. I think the lag is coming from EffectPoint and I don't know how to fix that.
 

Corleone

New Member
Reaction score
44
EffectPoint is a real variable. Real variables don't cause memory leaks.

I know what's causing the null part to fail. I forgot that you're using global variables.

Hence, it should say:

Trigger:
  • Custom script: set udg_ThunderPoint = null
    • Custom script: set udg_ThunderPoint2 = null


My mistake.
 

eric92

New Member
Reaction score
3
EffectPoint is a real variable. Real variables don't cause memory leaks.
My mistake.

Your right because I just made this trigger and it is still Lagging!!! :banghead:

Trigger:
  • Energy Beam Copy 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Beam1
    • Actions
      • Set ThunderCaster = (Casting unit)
      • Set ThunderPoint = (Position of (Casting unit))
      • Wait 0.15 seconds
      • Unit - Pause ThunderCaster
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 150.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 300.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 450.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 600.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 750.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 900.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Unpause ThunderCaster
      • Custom script: call RemoveLocation(udg_ThunderPoint)
      • Set ThunderCaster = No unit



I see nothing wrong with this trigger!! but it laggs after a few uses.
I also added the null thing to the end of this and it didnt help.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Note the bold part:

Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 150.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees

Every time that runs, you have a leak. That part is why you need a second variable to hold the offset point. Like so:

Set ThunderPoint = <Some Point>
Set ThunderPoint2 = ThunderPoint offset by 150.00 towards (Facing of TunderCaster)
Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degress
 

tooltiperror

Super Moderator
Reaction score
231
Note the bold part:

Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by 150.00 towards (Facing of ThunderCaster) degrees) facing Default building facing degrees

Every time that runs, you have a leak. That part is why you need a second variable to hold the offset point. Like so:

Set ThunderPoint = <Some Point>
Set ThunderPoint2 = ThunderPoint offset by 150.00 towards (Facing of TunderCaster)
Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degress

Or.

Set Thunderpoint = Some Point
Set Thunderpoint = Thunderpoint offset by 150.00.

You can reuse.
 

eric92

New Member
Reaction score
3
Ok this is what I have done now, but I am still getting big lag.


Trigger:
  • Energy Beam Copy 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Beam1
    • Actions
      • Set ThunderCaster = (Casting unit)
      • Set ThunderPoint = (Position of (Casting unit))
      • Set ThunderPoint2 = (ThunderPoint offset by 150.00 towards (Facing of ThunderCaster) degrees)
      • Wait 0.15 seconds
      • Unit - Pause ThunderCaster
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Set ThunderPoint2 = (ThunderPoint offset by 300.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Set ThunderPoint2 = (ThunderPoint offset by 450.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Set ThunderPoint2 = (ThunderPoint offset by 600.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Set ThunderPoint2 = (ThunderPoint offset by 750.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Set ThunderPoint2 = (ThunderPoint offset by 900.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Unpause ThunderCaster
      • Custom script: call RemoveLocation(udg_ThunderPoint)
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Set ThunderCaster = No unit
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Each time you are going to set ThunderPoint2 again, you need to destroy it first, then set it.
 

eric92

New Member
Reaction score
3
This is what I have and it is starting to lag even sooner.

Trigger:
  • Energy Beam Copy 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Beam1
    • Actions
      • Set ThunderCaster = (Casting unit)
      • Set ThunderPoint = (Position of (Casting unit))
      • Set ThunderPoint2 = (ThunderPoint offset by 150.00 towards (Facing of ThunderCaster) degrees)
      • Wait 0.15 seconds
      • Unit - Pause ThunderCaster
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Set ThunderPoint2 = (ThunderPoint offset by 300.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Set ThunderPoint2 = (ThunderPoint offset by 450.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Set ThunderPoint2 = (ThunderPoint offset by 600.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Set ThunderPoint2 = (ThunderPoint offset by 750.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Set ThunderPoint2 = (ThunderPoint offset by 900.00 towards (Facing of ThunderCaster) degrees)
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at ThunderPoint2 facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Unpause ThunderCaster
      • Custom script: call RemoveLocation(udg_ThunderPoint)
      • Custom script: call RemoveLocation(udg_ThunderPoint2)
      • Set ThunderCaster = No unit




*FIRST POST*
Did you stole my spell?

Nvm, mine works; and doesnt lag. ;)

Chaos, yes yours does lag!! Lower the cooldowns to 1 or 2 seconds and just cast the spell like 20 - 30 times and you will start to see the lag!!! I did this in your map that i got from you. Also I think it takes more casts for it to start lagging in your map than mine because yours is much smaller than my map.


- If anyone knows of a beam spell that works, please tell me I would like to use it in my map. I have see spells like these in peoples games and i would like to put one in my map...
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
I would probably need to see the map now. It looks like all the leaks have been cleaned, so the lag is probably attributed to something else at this point.
 

eric92

New Member
Reaction score
3
ok do you want me to send you my whole map because its to big to put on here and I would have to give you it over b.net, or I can put up Chaos's map which is where I got the spell from.
 

HeX.16

Isn't Trollin You Right Now
Reaction score
131
Actually that was my spell xD i made it for him i had no idea you need to destroy each point like that rather just the main one. Wouldnt putting it in the loop fix it.
Trigger:
  • For each (Integer A) from 1 to 6, do (Actions)
    • Loop - Actions
      • -------- Setting Point Again --------
      • -------- Increasing the &quot;150&quot; with make large spaces between effects and visa versa --------
      • Set EffectPoint[Integer A] = (EffectPoint[Integer A - 1] + 150.00)
      • -------- ----------- --------
      • -------- Special Effects --------
      • Special Effect - Create a special effect at (ThunderPoint offset by EffectPoint towards (Facing of ThunderCaster) degrees) using Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- ----------- --------
      • -------- Creating Dummy and Setting Ability --------
      • Unit - Create 1 Dummy (Ice Beam) for (Owner of ThunderCaster) at (ThunderPoint offset by EffectPoint towards (Facing of ThunderCaster) degrees) facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation(udg_ThunderPoint[Integer A])
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      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