• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Created Unit Leaks?

Status
Not open for further replies.
Level 6
Joined
Jul 23, 2018
Messages
243
  • Multi MA Lvl 5
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Multiple Magic Arrows
    • Actions
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Set level of Searing Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Night Elf Priestess Of The Moon - Activate Searing Arrows
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Set level of Frost Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Special Sylvanas Windrunner - Activate Cold Arrows
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Set level of Flaming Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral Fire Lord - Activate Incinerate (Arrow)
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Set level of Poison Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral - Activate Poison Arrows
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Set level of Black Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral Dark Ranger - Activate Black Arrow
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
I made an ability based on Thunder Claps, which makes this trigger to create dummy units. The problem is, after casting it many times, the game became laggy. Does anyone know how to fix this? Thanks in advance.
 
Thunderclap causes desyncs apparently. It has to do with the terrain deformation. Try using a different ability.

You should also use "A unit starts the effect of an ability" as your Event in most cases. Begins casting can be abused (you can cancel it but the trigger still runs).

And you're leaking 5 Points. You should set Position of triggering unit as a Point variable, then create the units at this Point variable. Then at the very end of the trigger put this to remove the Point variable:
  • Custom script: call RemoveLocation (udg_PutTheNameOfYourPointHere)
 
Change ability to Locust Swarm. But still laggy after starting the effect.
  • Multi MA Lvl 5
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Locust Swarm
      • (Level of Locust Swarm for (Triggering unit)) Equal to 5
    • Actions
      • Set Location = (Position of (Triggering unit))
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Searing Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Night Elf Priestess Of The Moon - Activate Searing Arrows
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Frost Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Special Sylvanas Windrunner - Activate Cold Arrows
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Flaming Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral Fire Lord - Activate Incinerate (Arrow)
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Poison Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral - Activate Poison Arrows
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Black Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral Dark Ranger - Activate Black Arrow
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Location)
 
Thats weird. I have no idea.

Anyway, if you need an ability you can use Channel. It has a bunch of options like Instant (which is what you want), Target Unit, Target Point, and Both (Point/Unit). It can also be used for channeling effects (go figure). It serves as the go to ability for triggered spells.
 
Tried Channel, still lag. I removed all the effects. Is it because of patch? I'm using 1.29.
Update: Tried doing this way, still lag.
  • Multi MA Lvl 5
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Multiple Magic Arrows
      • (Level of Multiple Magic Arrows for (Triggering unit)) Equal to 5
    • Actions
      • Set Location = (Position of (Triggering unit))
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Searing Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Night Elf Priestess Of The Moon - Activate Searing Arrows
      • Custom script: call RemoveLocation(udg_Location)
      • Set Location = (Position of (Triggering unit))
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Frost Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Special Sylvanas Windrunner - Activate Cold Arrows
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Location)
      • Set Location = (Position of (Triggering unit))
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Flaming Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral Fire Lord - Activate Incinerate (Arrow)
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Location)
      • Set Location = (Position of (Triggering unit))
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Poison Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral - Activate Poison Arrows
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Location)
      • Set Location = (Position of (Triggering unit))
      • Unit - Create 1 Archer (Archer Dummy) for (Owner of (Triggering unit)) at Location facing Default building facing degrees
      • Unit - Set level of Black Arrows (Archer Queen) for (Last created unit) to 5
      • Unit - Order (Last created unit) to Neutral Dark Ranger - Activate Black Arrow
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Location)
 
Last edited:
You don't need to save and destroy the location many times. It's enough to save it once at the start and destroy it at the end. The cause of the lag must be different.
About how many casts does the game lag? It could be an accumulated memory leaks from the created units since removed unit's apparently doesn't free up all its memory.
Another possible cause would be if you have other triggers in your map with the same event
  • Unit - A unit Starts the effect of an ability
but runs for all spells, and maybe that's the trigger that creates leaks and not this one?
 
I have 3 more triggers with the same events but they all have conditions
  • (Level of Multiple Magic Arrows for (Triggering unit)) Equal to <integer>
so it's not the case.
 
Maybe send here the map, I'll check. Which version do you use?
It looks like you're using a pre-1.30 version... so nevermind :)

Though your problem doesn't rely on the script you posted here.
If you're eager to solve this problem, sending the map can help.
 
Last edited:
At fist, this map was 1.21b but I use 1.29 patch because of an Action that is not available in earlier patch and my collaborator use it so...
Anyway it's the trigger in Archer Queen called Multi MA Lvl
 

Attachments

In addition to what JAKEZINC said, another possible cause be this
  • More Flag Effect
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Set Effect_P = (Position of (Casting unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Effect (Agility)
        • Then - Actions
          • Special Effect - Create a special effect at Effect_P using Abilities\Spells\Items\AIam\AIamTarget.mdl
          • Wait 0.01 game-time seconds
          • Unit - Remove (Ability being cast) from (Casting unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Effect (Intelligence)
            • Then - Actions
              • Special Effect - Create a special effect at Effect_P using Abilities\Spells\Items\AIim\AIimTarget.mdl
              • Wait 0.01 game-time seconds
              • Unit - Remove (Ability being cast) from (Casting unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ability being cast) Equal to Effect (Strength)
                • Then - Actions
                  • Special Effect - Create a special effect at Effect_P using Abilities\Spells\Items\AIsm\AIsmTarget.mdl
                  • Wait 0.01 game-time seconds
                  • Unit - Remove (Ability being cast) from (Casting unit)
                • Else - Actions
Since it leaks a location saved to Effect_P and a special effect, and it also runs every time a spell is cast - or in other words, this trigger also runs every time the trigger in your original post runs.
 
For this charge ability, I believe it is leaked but I also have a question. Is it MUI? Because I have multiple heroes use it at different times, and they are pretty close, still, it works perfect. I only need to know the way to prevent these kind of leaks when they are designed with variables. This ability is based on Shockwave and the triggers are based on this video, also based on this thread. I changed some of the actions and variables to make it fit my need. I also thought about using custom value of units with unit indexer.
  • Charge
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charge (Dark Knight)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Casting unit)) Equal to Dark Knight
    • Actions
      • Set Caster = (Casting unit)
      • Set DashPoint[0] = (Position of Caster)
      • Set DashPoint[1] = (Target point of ability being cast)
      • Set Distance = (Distance between DashPoint[0] and DashPoint[1])
      • Set Increment = 50.00
      • Set Angle = (Angle from DashPoint[0] to DashPoint[1])
      • Trigger - Turn on Charge Loop <gen>
  • Charge Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Distance = (Distance - Increment)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Distance Greater than 0.00
        • Then - Actions
          • Set DashPoint[2] = (Position of Caster)
          • Set DashPoint[3] = (DashPoint[2] offset by Increment towards Angle degrees)
          • Unit - Turn collision for Caster Off
          • Unit - Pause Caster
          • Animation - Play Caster's Walk animation
          • Unit - Move Caster instantly to DashPoint[3]
          • Wait (Distance - (Distance x 0.99)) game-time seconds
          • Unit - Unpause Caster
          • Unit - Turn collision for Caster On
        • Else - Actions
 
Last edited:
Currently it is not MUI since you are using global variable together with waits and not using an indexing of any kind. If you will have two consecutive casts with the next one happening before the wait duration (+0.05 for timer interval) is over, the previous variables will be overriden.

For the leaks, there are actually many more present in your map than just your spells (just to make you aware). In this one in particular, you are leaking 2 locations per timer expiration in the charge loop.
 
So I have to destroy all the dash point?? How do I do that? They have index.
And thanks for telling me about the leaks me and my cousin made in all of the triggers, I have a lot to fix.
EDIT: I need help with this, how do I destroy variables with index?
  • Mana Flare
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mana Flare (Dummy,Sage)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Casting unit)) Equal to Sage
          • (Unit-type of (Casting unit)) Equal to Sage (AI)
    • Actions
      • Set CV = (Custom value of (Casting unit))
      • Set Loc_MA[CV] = (Target point of ability being cast)
      • Unit - Create 1 Dummy (Mana Flare) for (Owner of (Casting unit)) at Loc_MA[CV] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Loc_MA[CV])
      • Unit - Order (Last created unit) to Night Elf Faerie Dragon - Mana Flare
 
Last edited:
Really? It tells error.
EDIT: nevermind, found a way
  • Custom script: call RemoveLocation(udg_Loc_MA[udg_CV])
Does it leak if I use Last Created Unit and Add Expiration Timer? For Expiration Timer, how do I check the channel time?
 
Last edited:
I made a spell based on Channel, what it does is triggering a trigger to create a unit and make the last created unit casting a channeling spell, Mana Flare. The problem is the channel time of that channeling spell is the time plus 2 seconds to remove the unit after it is done channeling. I couldn't find it anywhere. Also, do integers leak? And is it okay to have an index inside an index, and continuously?
  • Mana Flare
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mana Flare (Dummy,Sage)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Casting unit)) Equal to Sage
          • (Unit-type of (Casting unit)) Equal to Sage (AI)
    • Actions
      • Set CV = (Custom value of (Casting unit))
      • Set Loc_MA[CV] = (Target point of ability being cast)
      • Unit - Create 1 Dummy (Mana Flare) for (Owner of (Casting unit)) at Loc_MA[CV] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Loc_MA[udg_CV])
      • Unit - Order (Last created unit) to Night Elf Faerie Dragon - Mana Flare
 
Last edited:
Instead of checking the channel time, just use the event
  • Unit - A unit stops casting an ability
. It will run when the channel finishes or is interrupted. Then to remove unit, use [Unit - Add Expiration Timer] to remove it after 2 seconds.

Also, do integers leak?
No. More info here. Pls read it, really useful info.

And is it okay to have an index inside an index, and continuously?
Yes
 
So you're saying I can have my triggers like this.
  • Charge
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charge (Dark Knight)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Casting unit)) Equal to Dark Knight
    • Actions
      • Set CV = (Custom value of (Casting unit))
      • Set Caster[CV] = (Casting unit)
      • Set DashPoint[(CV + 1)] = (Position of Caster[CV])
      • Set DashPoint[(CV + 2)] = (Target point of ability being cast)
      • Set Distance = (Distance between DashPoint[(CV + 1)] and DashPoint[(CV + 2)])
      • Set Increment = 50.00
      • Set Angle = (Angle from DashPoint[(CV + 1)] to DashPoint[(CV + 2)])
      • Trigger - Turn on Charge Loop <gen>
  • Charge Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Distance = (Distance - Increment)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Distance Greater than 0.00
        • Then - Actions
          • Set DashPoint[(CV + 3)] = (Position of Caster[CV])
          • Set DashPoint[(CV + 4)] = (DashPoint[(CV + 3)] offset by Increment towards Angle degrees)
          • Unit - Turn collision for Caster[CV] Off
          • Unit - Pause Caster[CV]
          • Unit - Move Caster[CV] instantly to DashPoint[(CV + 4)]
          • Wait (Distance - (Distance x 0.99)) game-time seconds
          • Unit - Unpause Caster[CV]
          • Unit - Turn collision for Caster[CV] On
          • Custom script: call RemoveLocation(udg_DashPoint[udg_CV+3])
          • Custom script: call RemoveLocation(udg_DashPoint[udg_CV+4])
        • Else - Actions
 
Status
Not open for further replies.
Back
Top