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

[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.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
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)
 
Level 6
Joined
Jul 23, 2018
Messages
243
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)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
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.
 
Level 6
Joined
Jul 23, 2018
Messages
243
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:

AGD

AGD

Level 16
Joined
Mar 29, 2016
Messages
688
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?
 
Level 6
Joined
Jul 23, 2018
Messages
243
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.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
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:
Level 6
Joined
Jul 23, 2018
Messages
243
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

  • Two-Kingdoms-Edited-1.24.w3x
    1.3 MB · Views: 33

AGD

AGD

Level 16
Joined
Mar 29, 2016
Messages
688
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.
 
Level 6
Joined
Jul 23, 2018
Messages
243
I disabled the 2 mentioned triggers above and the game gets less laggy, but it still gets laggy around 2 hundred times of casting.
 
Level 6
Joined
Jul 23, 2018
Messages
243
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:

AGD

AGD

Level 16
Joined
Mar 29, 2016
Messages
688
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.
 
Level 6
Joined
Jul 23, 2018
Messages
243
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:
Level 6
Joined
Jul 23, 2018
Messages
243
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:
Level 6
Joined
Jul 23, 2018
Messages
243
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:

AGD

AGD

Level 16
Joined
Mar 29, 2016
Messages
688
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
 
Level 6
Joined
Jul 23, 2018
Messages
243
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.
Top