• 🏆 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 cause massive lags

Status
Not open for further replies.
Level 31
Joined
Jun 27, 2008
Messages
2,557
Hello.

There is a simple spell that cause extreme lags and with every use bigger ones until I can't even cast it. Game is singleplayer. Spell consist of two triggers. Dummies are Locust with SFX model that has negative life regeneration rate and dies after 1 second of summon. SFX do not cause lag. I am not really good at coding etc, so I suppose there is something to do with triggers. Help would be appreciated.

  • Crystalic Impale
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Crystalic Impale
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Mana of Hero) - ((Max mana of Hero) x 0.23)) Less than or equal to 0.00
        • Then - Actions
          • Unit - Set mana of Hero to 0.00%
          • Skip remaining actions
        • Else - Actions
          • Unit - Set mana of Hero to ((Mana of Hero) - ((Max mana of Hero) x 0.23))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Crystalic Impale
        • Then - Actions
          • Set HeroFaceCrystal = (Facing of Hero)
          • Set HeroLocationCrystal = (Position of Hero)
          • Set HeroPathCrystal = 30.00
          • Set CrystalOffset = (HeroLocationCrystal offset by HeroPathCrystal towards HeroFaceCrystal degrees)
          • Sound - Play BlizzardLoop1 <gen>
          • Trigger - Turn on Crystalic Impale Loop <gen>
        • Else - Actions
  • Crystalic Impale Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Sound - Stop IceBreak <gen> Immediately
      • Sound - Play IceBreak <gen>
      • Set HeroLocationCrystal = (Position of Hero)
      • Set CrystalOffset = (HeroLocationCrystal offset by HeroPathCrystal towards HeroFaceCrystal degrees)
      • Unit - Create 1 Conjured Crystal for Player 1 (Red) at CrystalOffset facing (Random real number between 0.00 and 360.00) degrees
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 175.00 of CrystalOffset) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to Hero
            • Then - Actions
              • Set CrystalTarget = (Position of (Picked unit))
              • Unit - Create 1 Dummy1 for Player 1 (Red) at CrystalTarget facing Default building facing degrees
              • Unit - Order (Last created unit) to Human Sorceress - Slow (Picked unit)
              • Unit - Cause Hero to damage (Picked unit), dealing ((Mana of Hero) x 0.20) damage of attack type Spells and damage type Normal
              • Sound - Stop IceCrack <gen> Immediately
              • Sound - Play IceCrack <gen>
            • Else - Actions
      • Set HeroPathCrystal = (HeroPathCrystal + 100.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroPathCrystal Greater than or equal to 1000.00
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Sound - Stop BlizzardLoop1 <gen> After fading
        • Else - Actions
      • Custom script: call RemoveLocation(udg_HeroLocationCrystal)
      • Custom script: call RemoveLocation(udg_CrystalOffset)
      • Custom script: call RemoveLocation(udg_CrystalTarget)
 
Last edited:
Level 13
Joined
Jan 30, 2012
Messages
1,298
you should use this
  • Conditions
    • (Ability being cast) Equal to Crystalic Impale
instead of
  • Or - Any (Conditions) are true
    • Conditions
      • (Ability being cast) Equal to Crystalic Impale
if you want this in MUI you have to learn about indexing..
your spell can only casted by one unit, if more than one unit cast this spell.. you'll get a bug.. to fix this you have to use array index.. you can learn it in here
Things a GUI User Should Know by deathismyfriend
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
It was designed to be for one unit as it is singleplayer map. Changed conditions, still lags massively. Other spells with leaks doesn't cause lag at all, yet this certain spell after few uses almost freezes computer.

I don't have the will go to through all these tutorials and spend lots of time and effort trying to adapt to this specific situation and finally fail to fix. That is the reason why I posted here, I can find tutorials by myself. I just need someone to point out specifically what is wrong, what to change here if there is something that may cause massive lag.

I went through object editor of dummies, nothing exceptional there, tried changing models, same results. I could add map here, but its size is 62 MB at the moment.

Do not take this offensively, I'm glad you are willing to help.
 

Ralle

Owner
Level 77
Joined
Oct 6, 2004
Messages
10,100
This leaks
(HeroLocationCrystal offset by HeroPathCrystal towards HeroFaceCrystal degrees)
The offset creats a new location which you have to store in an additional location variable

You have to create another location variable and set it to the value of "HeroLocationCrystal offset by HeroPathCrystal towards HeroFaceCrystal degrees"

This also leaks a location:
Pick every unit in (Units within 175.00 of (HeroLocationCrystal offset by HeroPathCrystal towards HeroFaceCrystal degrees))
You can use the same variable for this location as the last one.
 
Level 13
Joined
Jan 30, 2012
Messages
1,298
it supposed like this
  • Set HeroLocationCrystal = (Position of Hero)
  • Set HeroLocationCrystal2 = HeroLocationCrystal with offset by HeroPathCrystal towards HeroFaceCrystal degrees)
  • Unit - Create 1 Conjured Crystal for Player 1 (Red) at HeroLocationCrystal2 facing (Random real number between 0.00 and 360.00) degrees
then destroy it when you're done
 
Last edited:
Level 13
Joined
Jan 30, 2012
Messages
1,298
wait a minute i'll fix this

Edited: I found your leaks, you create a dummy but you don't kill nor remove it from game
use this function below your dummy
  • Unit - Create 1 Conjured Crystal for Player 1 (Red) at CrystalOffset facing (Random real number between 0.00 and 360.00) degrees
  • Unit - Add a 1.00 generic expiration Timer to (Last Created Unit)
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
Dummies have their life regeneration rate negative, so they die after 1 second automatically, but I added expiration timer, no use of it. I also tried removing trigger action to create dummies and then casted spell, lag is still being caused. Perhaps it has something to do with a base spell I am using, it is shockwave with all stats set to zero.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Creating units is a costly process. Create only one dummy and order it to cast the ability on all units.

Set Art - animation - cast point to 0, cast backswing to 0, and mana cost and cooldown of the ability to 0.

Also use this after creating the dummy.
Custom script : call UnitRemoveAbility(bj_lastCreatedUnit, 'Amov')

Another thing is to test if the sounds cause the lag.

Make sure the death type of the dummies is set to Can't raise, does not decay so the dummies are removed right after they die.
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
Map is big so I'll put a link to dropbox. Cant upload here as an attachment bigger file than 20 MB. Here it is. Just run the game, use given item to acquire an ability and use it towards anything several times, or you can use footman to your right as targets. After few uses lag becomes unbearable. It is also global, it is not like pulling away camera gets rid of the lag, it stays even if camera is far away from that place where spell was casted.

Dummies are set like that, I tried adding the script, but lag stays.

Oh, I also tried copying the spell to a completely empty map, it won't cause global lag there. Terrains got nothing to do with it though.
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
So could it be doodads that cause the lag? If I drag hero far away from doodads to another corner of map and start casting spell, lag still occurs. What could possibly fight with doodads / imported material with that coding when other spells don't cause lag at all. Perhaps I'll try to remake entire spell slightly differently and test every step.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You are leaking units? For every unit the ability hits you are creating a dummy unit which you never remove.

Use 1 dummy unit for all dummy ability casting by settings its cast backwards swing and point to 0 and then use this dummy for all casts again and again.

Units leak due to a Warcraft III game bug even if you do remove them. Not removing them makes the problem a lot worse.
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
But it has negative life regeneration rate so it dies after 1 second, doesn't rise, doesn't decay, swing and point to zero etc. If I add expiration timer, result is the same. I also tried creating one unit to cast spell on every unit hit, but it still cause lag. Doodads got something to do with it even though it hardly makes any sense.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
DSG means that every unit that is created permanently reserves some memory even if the unit is removed from the game. The amount is about 44 bytes per unit based on tests I ran if I remember correctly.

The amount of memory leaked is very small so generally there is no need to worry about it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The amount of memory leaked is very small so generally there is no need to worry about it.
Is it only memory that is leaked? It could also be internal structures that will slow parts of the game down.

In any case I think the cause is...
Set CrystalTarget = (Position of (Picked unit))
Unit - Create 1 Dummy1 for Player 1 (Red) at CrystalTarget facing Default building facing degrees
Not only does he leak that location, but also he creates a unit under a unit. Even with no collision it is a very bad idea to make units inside other units as that can cause a lot of displacement overhead. Using 1 unit that is flying, locust with virtually no collision size is the best for that reason.
 
Level 6
Joined
Feb 5, 2012
Messages
1,685
your pc maybe..

i have a problem with lags too.. i have a map after playing 20 - 30 minutes it starts lagging and the lagging is very bad.. i check my map for leaks but there isn't so i tried on other computers and the map don't lag at all..

How about try some other base spell like Channel?...
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
This is my version of it, try it, (i didn't download the map)

  • Crystalic Impale
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Crystalic Impale
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Mana of Hero) - ((Max mana of Hero) x 0.23)) Less than or equal to 0.00
        • Then - Actions
          • Unit - Set mana of Hero to 0.00%
        • Else - Actions
          • Unit - Set mana of Hero to ((Mana of Hero) - ((Max mana of Hero) x 0.23))
          • Set HeroFaceCrystal = (Facing of Hero)
          • Set HeroPathCrystal = 30.00
          • Sound - Stop IceCrack <gen> Immediately
          • Sound - Play IceCrack <gen>
          • Trigger - Turn on (Crystalic Impale Loop)
  • Crystalic Impale Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Sound - Stop IceBreak <gen> Immediately
      • Sound - Play IceBreak <gen>
      • Set HeroLocationCrystal = (Position of Hero)
      • Set CrystalOffset = (HeroLocationCrystal offset by HeroPathCrystal towards HeroFaceCrystal degrees)
      • Unit - Create 1 Conjured Crystal for Player 1 (Red) at CrystalOffset facing (Random real number between 0.00 and 360.00) degrees
      • Unit - Create 1 Dummy1 for Player 1 (Red) at CrystalOffset facing Default building facing degrees
      • Set UnitGroup = (Units within 175.00 of CrystalOffset matching (((Matching unit) Not equal to Hero) and ((Matching Unit) is Alive equal to True))
      • Unit Group - Pick every unit in (UnitGroup) and do (Actions)
        • Loop - Actions
          • Unit - Order (Last created unit) to Human Sorceress - Slow (Picked unit)
          • Unit - Cause Hero to damage (Picked unit), dealing ((Mana of Hero) x 0.20) damage of attack type Spells and damage type Normal
      • Unit - Kill (Last Created Unit)
      • Custom script: call DestroyGroup(udg_UnitGroup)
      • Set HeroPathCrystal = (HeroPathCrystal + 100.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroPathCrystal Greater than or equal to 1000.00
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Sound - Stop BlizzardLoop1 <gen> After fading
        • Else - Actions
      • Custom script: call RemoveLocation(udg_HeroLocationCrystal)
      • Custom script: call RemoveLocation(udg_CrystalOffset)
      • Custom script: call RemoveLocation(udg_CrystalTarget)
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
It is not really low. More then enough for warcraft. Intel Core i5 - 3210M, 2.5 GHz, 6 GB of ram. There must be something wrong with Editor itself, I'll try reinstalling operating system someday, this would renew entire PC, because the last time I did it was a year ago, but it runs fine wihout any problems though.
 
Status
Not open for further replies.
Top