Spell Lagging!

Mike889

New Member
Reaction score
15
I made a spell that picks a targeted enemy unit, spin it around with my hero and then the unit is thrown away. However, when a unit casts it the game lags heavily!
The Hero with this spell is Cairne Bloodhoof and he is on my test map (optimized).
Here is my spell trigger:

Code:
Unit Throwing
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to (==) Unit Throwing (Cairne Bloodhoof)
    Actions
        Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
        Set Caster_Cairne[PlayerNumber] = (Triggering unit)
        Set Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] = (Target unit of ability being cast)
        Unit - Pause Caster_Cairne[PlayerNumber]
        Unit - Pause Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))]
        Unit - Turn collision for Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] Off
        Set Skill_UnitPos = (Position of (Triggering unit))
        Set Temp_Point = (Skill_UnitPos offset by 100.00 towards -90.00 degrees)
        Unit - Move Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] instantly to Temp_Point
        Animation - Play Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))]'s death animation
        Point - Remove Temp_Point
        Point - Remove Skill_UnitPos
        Animation - Play Caster_Cairne[PlayerNumber]'s stand, ready animation
        Unit Group - Add Caster_Cairne[PlayerNumber] to Skill_UnitSpin
        Unit Group - Add Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] to Skill_UnitSpin
        Trigger - Turn on Units Spin <gen>

Code:
Units Spin
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Skill_UnitSpin and do (Actions)
            Loop - Actions
                Set PlayerNumber = (Player number of (Owner of (Picked unit)))
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Skill_SpinAngle[PlayerNumber] Greater than or equal to (>=) 3780.00
                    Then - Actions
                        Unit - Unpause Caster_Cairne[PlayerNumber]
                        Animation - Play Caster_Cairne[PlayerNumber]'s attack, 1 animation
                        Unit Group - Remove Caster_Cairne[PlayerNumber] from Skill_UnitSpin
                        Set Skill_SpinAngle[PlayerNumber] = 0.00
                         Do Multiple ActionsFor each (Integer A) from 0 to 16, do (Actions)
                            Loop - Actions
                                Unit - Unpause Target_Cairne[(Integer A)]
                                Unit - Turn collision for Target_Cairne[(Integer A)] On
                                Set N[(Integer A)] = 0.00
                                Unit Group - Add Target_Cairne[(Integer A)] to Skill_Knockback
                                Animation - Play Caster_Cairne[PlayerNumber]'s spell, slam animation
                                Unit Group - Remove Target_Cairne[(Integer A)] from Skill_UnitSpin
                                Special Effect - Create a special effect attached to the origin of Caster_Cairne[PlayerNumber] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
                                Special Effect - Destroy (Last created special effect)
                                Set Temp_Point = (Position of Target_Cairne[(Integer A)])
                                Unit - Create 1 Dummy for (Owner of Target_Cairne[(Integer A)]) at Temp_Point facing Default building facing (270.0) degrees
                                Set Target_Cairne[(Integer A)] = (Last created unit)
                                Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                                Point - Remove Temp_Point
                                Trigger - Turn off (This trigger)
                    Else - Actions
                        Set Temp_UnitFacing = (Facing of (Picked unit))
                        Set Temp_Angle = (Temp_UnitFacing + 20.00)
                        Set Skill_SpinAngle[PlayerNumber] = (Skill_SpinAngle[PlayerNumber] + 20.00)
                        Animation - Play Caster_Cairne[PlayerNumber]'s stand, ready animation
                        Unit - Make Caster_Cairne[PlayerNumber] face Temp_Angle over 0.00 seconds
                        Set Skill_UnitPos = (Position of Caster_Cairne[PlayerNumber])
                        Set Temp_Point = (Skill_UnitPos offset by 150.00 towards (Temp_UnitFacing - 10.00) degrees)
                         Do Multiple ActionsFor each (Integer A) from 0 to 16, do (Actions)
                            Loop - Actions
                                Special Effect - Create a special effect attached to the chest of Target_Cairne[(Integer A)] using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                                Special Effect - Destroy (Last created special effect)
                                Unit - Cause Caster_Cairne[PlayerNumber] to damage Target_Cairne[(Integer A)], dealing (0.50 x (Real((Level of Unit Throwing (Cairne Bloodhoof) for Caster_Cairne[PlayerNumber])))) damage of attack type Normal and damage type Normal
                                Unit - Move Target_Cairne[(Integer A)] instantly to Temp_Point
                                Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
                                    Loop - Actions
                                        Destructible - Kill (Picked destructible)
                        Point - Remove Skill_UnitPos
                        Point - Remove Temp_Point

Code:
Knockback
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Skill_Knockback and do (Actions)
            Loop - Actions
                Set PlayerNumber = (Player number of (Owner of (Picked unit)))
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        N[PlayerNumber] Greater than or equal to (>=) 400.00
                    Then - Actions
                        Unit Group - Remove (Picked unit) from Skill_Knockback
                        Set N[PlayerNumber] = 0.00
                    Else - Actions
                        Set N[PlayerNumber] = (N[PlayerNumber] + 5.00)
                        Set Skill_UnitPos = (Position of (Picked unit))
                        Set Temp_Point = (Skill_UnitPos offset by 5.00 towards ((Facing of (Picked unit)) - 180.00) degrees)
                        Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
                        Special Effect - Destroy (Last created special effect)
                        Unit - Move (Picked unit) instantly to Temp_Point
                        Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
                            Loop - Actions
                                Destructible - Kill (Picked destructible)
                        Point - Remove Skill_UnitPos
                        Point - Remove Temp_Point

After the unit is thrown the lag dissipates.
 

ZeratuelX

New Member
Reaction score
6
What part of the spell? I noticed you have 2 triggers, one for the spin and one for the throw. Does it lag immediately? I'm going to try the map soon, but I don't have enough time right now. You might want to look for code that isn't quite doing what it's supposed to.
 

Mike889

New Member
Reaction score
15
It lags on the spin, making you see the unit just on two positions. When the throw is done, the game pauses for about 1 second, until the throwing is done. An interesting thing I noticed is that it just lags when you use the skill on another player. When you use it on creeps the spell plays smoothly.
 

ZeratuelX

New Member
Reaction score
6
Is the game physically lagging or are the units teleporting somehow? I'll go look at the map since it seems I have more time than I planned to have.

Edit-----

Dang, nice map. It looks great!

I don't seem to be getting this lag, but that's because I got a nice new desktop. Upon looking at your code I do see a major possible lag problem though.

Code:
Units Spin
    Events
        Time - Every 0.01 seconds of game time
    Conditions
--->  IF var_UnitThrowSpellisCast = 1 // I code in JASS now so i forogt what the GUI translation of this is..
    Actions
--->  SET var_UnitThrowSpellisCast = 0
        Unit Group - Pick every unit in Skill_UnitSpin and do (Actions)
            Loop - Actions
                Set PlayerNumber = (Player number of (Owner of (Picked unit)))
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Skill_SpinAngle[PlayerNumber] Greater than or equal to (>=) 3780.00
                    Then - Actions
                        Unit - Unpause Ca...
Your problem was this: The Entire code was running every 0.01 seconds that the spell was still being cast. This code ensures it is only run once. This may solve your lag problem. Suppose the spell is running for 2 seconds. Your entire script runs 200 times during the spell causing MASSIVE lag during the spell, but not after or before. You may want to change this with all similar scripts. This is a fairly common mistake that can lead to lots of lag not only during the spell, but after about 30 mins of gameplay or so.


A suggestion: I did notice that it does do a bit of teleporting when it's near enemies. Try turning off collision, pausing the unit, making it invuln, and giving it locust temporarily?
 

Mike889

New Member
Reaction score
15
Hmm ok, i'll try that, thanks ^^
I still need to work on the terrain, but it's very nice to hear it is cool =D
Someday i'll become able to help other people too ^^
 

ZeratuelX

New Member
Reaction score
6
Just keep up the good work! Battle.net needs good map-makers like you :)

Also, make sure you add "SET var_UnitThrowSpellisCast = 1" at the end of your Unit Throwing Trigger to activate the second one.

Tell me how it turns out!
 

Mike889

New Member
Reaction score
15
The spell still lags. I used Booleans instead of 1/0.
Code:
Units Spin
    Events
        Time - Every 0.01 seconds of game time
    Conditions
        [B]Spell_runing Equal to (==) False[/B]
    Actions
        [B]Set Spell_runing = True[/B]
        Unit Group - Pick every unit in Skill_UnitSpin and do (Actions)
            Loop - Actions
                Set PlayerNumber = (Player number of (Owner of (Picked unit)))
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Skill_SpinAngle[PlayerNumber] Greater than or equal to (>=) 3780.00
                    Then - Actions
                        Unit - Unpause Caster_Cairne[PlayerNumber]
                        Animation - Play Caster_Cairne[PlayerNumber]'s attack, 1 animation
                        Unit Group - Remove Caster_Cairne[PlayerNumber] from Skill_UnitSpin
                        Set Skill_SpinAngle[PlayerNumber] = 0.00
                         Do Multiple ActionsFor each (Integer A) from 0 to 16, do (Actions)
                            Loop - Actions
                                Unit - Unpause Target_Cairne[(Integer A)]
                                Unit - Turn collision for Target_Cairne[(Integer A)] On
                                Set N[(Integer A)] = 0.00
                                Unit Group - Add Target_Cairne[(Integer A)] to Skill_Knockback
                                Animation - Play Caster_Cairne[PlayerNumber]'s spell, slam animation
                                Unit Group - Remove Target_Cairne[(Integer A)] from Skill_UnitSpin
                                Special Effect - Create a special effect attached to the origin of Caster_Cairne[PlayerNumber] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
                                Special Effect - Destroy (Last created special effect)
                                Set Temp_Point = (Position of Target_Cairne[(Integer A)])
                                Unit - Create 1 Dummy for (Owner of Target_Cairne[(Integer A)]) at Temp_Point facing Default building facing (270.0) degrees
                                Set Target_Cairne[(Integer A)] = (Last created unit)
                                Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                                Point - Remove Temp_Point
                                Trigger - Turn off (This trigger)
                    Else - Actions
                        Set Temp_UnitFacing = (Facing of (Picked unit))
                        Set Temp_Angle = (Temp_UnitFacing + 20.00)
                        Set Skill_SpinAngle[PlayerNumber] = (Skill_SpinAngle[PlayerNumber] + 20.00)
                        Animation - Play Caster_Cairne[PlayerNumber]'s stand, ready animation
                        Unit - Make Caster_Cairne[PlayerNumber] face Temp_Angle over 0.00 seconds
                        Set Skill_UnitPos = (Position of Caster_Cairne[PlayerNumber])
                        Set Temp_Point = (Skill_UnitPos offset by 150.00 towards (Temp_UnitFacing - 10.00) degrees)
                         Do Multiple ActionsFor each (Integer A) from 0 to 16, do (Actions)
                            Loop - Actions
                                Special Effect - Create a special effect attached to the chest of Target_Cairne[(Integer A)] using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                                Special Effect - Destroy (Last created special effect)
                                Unit - Cause Caster_Cairne[PlayerNumber] to damage Target_Cairne[(Integer A)], dealing (0.50 x (Real((Level of Unit Throwing (Cairne Bloodhoof) for Caster_Cairne[PlayerNumber])))) damage of attack type Normal and damage type Normal
                                Unit - Move Target_Cairne[(Integer A)] instantly to Temp_Point
                                Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
                                    Loop - Actions
                                        Destructible - Kill (Picked destructible)
                        [B]Set Spell_runing = False[/B]
                        Point - Remove Skill_UnitPos
                        Point - Remove Temp_Point

Code:
Knockback
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Skill_Knockback and do (Actions)
            Loop - Actions
                Set PlayerNumber = (Player number of (Owner of (Picked unit)))
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        N[PlayerNumber] Greater than or equal to (>=) 400.00
                    Then - Actions
                        [B]Set Spell_runing = False[/B]
                        Unit Group - Remove (Picked unit) from Skill_Knockback
                        Set N[PlayerNumber] = 0.00
                    Else - Actions
                        Set N[PlayerNumber] = (N[PlayerNumber] + 5.00)
                        Set Skill_UnitPos = (Position of (Picked unit))
                        Set Temp_Point = (Skill_UnitPos offset by 5.00 towards ((Facing of (Picked unit)) - 180.00) degrees)
                        Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
                        Special Effect - Destroy (Last created special effect)
                        Unit - Move (Picked unit) instantly to Temp_Point
                        Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
                            Loop - Actions
                                Destructible - Kill (Picked destructible)
                        Point - Remove Skill_UnitPos
                        Point - Remove Temp_Point

I'll remove the special effects and see if it still lags.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
lol? i have just tested your map and it doesnt lagg for me. the game is running smooth as possible...

used your skill about 3 times, once with and 2 times without whosyourdaddy and it worked very fine.
 

Mike889

New Member
Reaction score
15
Well, on creeps it dosen't lag, don't know why. But when you use on another hero it lags. Try going to where DotA's Roshan is. It's the big red neutral creep. He will spin you and will lag.
 

Mike889

New Member
Reaction score
15
Found some new bugs xD.
I'll put arrays into the booleans, this way the spell can be MUI.
Also I found it's a bit too unbalanced for my map, so i'll reduce the damage and increase the cooldown a little bit ^^

Anyway, if you want to test the spells of my map, type -mikemode.
It will level your hero up and reset the cooldowns. But don't worry, on the final version this will be removed =P




--------------


Suspects of the lag source: Loop Integer A functions. I'm trying to get rid of them with player number.
 

Libra

New Member
Reaction score
3
idea

=|

At the end of the trigger, MAY, after activating the second trigger, it takes a little run to get o.o1 sec. I suggest o.2 or o.3 (test with the least) the second part of skill is very large and computer you use should not hold resolve 17/20 parameters in 0.01seg.
 

ZeratuelX

New Member
Reaction score
6
Hmm, I didn't try it on a hero, I'll go do that now.

I agree, change 0.01 to 0.02. It doesn't affect the game play, but lightens to load of the computer. I also agree as far as changing Integer A to player numbers.

These do not seem to be the problem though, if it is a hero only problem, then the problem most likely resides in where the code only affects heroes and not units, I'll look around and see if I can find anything.
 

Mike889

New Member
Reaction score
15
I made some optimizations, and now it dosen't lag anymore! =D
I'll +rep you all, but that can't express my gratitude =D
The spell still has some bugs, but there won't be a same hero command on my map, so that is a minor leak.

EDIT:
Code:
Units Spin
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Skill_UnitSpin and do (Actions)
            Loop - Actions
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Spell_runing[(Player number of (Owner of (Picked unit)))] Equal to (==) False
                    Then - Actions
                        Set Spell_runing[(Player number of (Owner of (Picked unit)))] = True
                        Set PlayerNumber = (Player number of (Owner of (Picked unit)))
                         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Skill_SpinAngle[PlayerNumber] Greater than or equal to (>=) 3780.00
                            Then - Actions
                                Unit - Unpause Caster_Cairne[PlayerNumber]
                                Animation - Play Caster_Cairne[PlayerNumber]'s attack, 1 animation
                                Unit Group - Remove Caster_Cairne[PlayerNumber] from Skill_UnitSpin
                                Set Skill_SpinAngle[PlayerNumber] = 0.00
                                Special Effect - Create a special effect attached to the origin of Caster_Cairne[PlayerNumber] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
                                Special Effect - Destroy (Last created special effect)
                                 Do Multiple ActionsFor each (Integer A) from 1 to 16, do (Actions)
                                    Loop - Actions
                                        Unit - Unpause Target_Cairne[(Integer A)]
                                        Unit - Turn collision for Target_Cairne[(Integer A)] On
                                        Set N[(Integer A)] = 0.00
                                        Unit Group - Add Target_Cairne[(Integer A)] to Skill_Knockback
                                        Animation - Play Caster_Cairne[PlayerNumber]'s spell, slam animation
                                        Unit Group - Remove Target_Cairne[(Integer A)] from Skill_UnitSpin
                                        Set Temp_Point = (Position of Target_Cairne[(Integer A)])
                                        Unit - Create 1 Dummy for (Owner of Target_Cairne[(Integer A)]) at Temp_Point facing Default building facing (270.0) degrees
                                        Set Target_Cairne[(Integer A)] = (Last created unit)
                                        Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                                        Set Spell_runing[PlayerNumber] = False
                                        Unit - Create 1 Dummy for (Owner of Caster_Cairne[(Integer A)]) at Temp_Point facing Default building facing (270.0) degrees
                                        Set Caster_Cairne[(Integer A)] = (Last created unit)
                                        Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                                        Point - Remove Temp_Point
                                        Trigger - Turn off (This trigger)
                            Else - Actions
                                Set Temp_UnitFacing = (Facing of (Picked unit))
                                Set Temp_Angle = (Temp_UnitFacing + 20.00)
                                Set Skill_SpinAngle[PlayerNumber] = (Skill_SpinAngle[PlayerNumber] + 20.00)
                                Unit - Make Caster_Cairne[PlayerNumber] face Temp_Angle over 0.00 seconds
                                Set Skill_UnitPos = (Position of Caster_Cairne[PlayerNumber])
                                Set Temp_Point = (Skill_UnitPos offset by 150.00 towards (Temp_UnitFacing - 10.00) degrees)
                                Special Effect - Create a special effect at Temp_Point using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                                Special Effect - Destroy (Last created special effect)
                                Set Temp_Angle = (Facing of Caster_Cairne[PlayerNumber])
                                 Do Multiple ActionsFor each (Integer A) from 1 to 16, do (Actions)
                                    Loop - Actions
                                        Unit - Cause Caster_Cairne[PlayerNumber] to damage Target_Cairne[(Integer A)], dealing (0.50 x (Real((Level of Unit Throwing (Cairne Bloodhoof) for Caster_Cairne[PlayerNumber])))) damage of attack type Normal and damage type Normal
                                        Unit - Move Target_Cairne[(Integer A)] instantly to Temp_Point
                                        Unit - Make Target_Cairne[(Integer A)] face Temp_Angle over 0.00 seconds
                                Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
                                    Loop - Actions
                                        Destructible - Kill (Picked destructible)
                                Set Spell_runing[PlayerNumber] = False
                                Point - Remove Skill_UnitPos
                                Point - Remove Temp_Point
                    Else - Actions

Code:
Knockback
    Events
        Time - Every 0.02 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Skill_Knockback and do (Actions)
            Loop - Actions
                Set PlayerNumber = (Player number of (Owner of (Picked unit)))
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        N[PlayerNumber] Greater than or equal to (>=) 400.00
                    Then - Actions
                        Unit Group - Remove (Picked unit) from Skill_Knockback
                        Set N[PlayerNumber] = 0.00
                    Else - Actions
                        Set N[PlayerNumber] = (N[PlayerNumber] + 5.00)
                        Set Skill_UnitPos = (Position of (Picked unit))
                        Set Temp_Point = (Skill_UnitPos offset by 5.00 towards ((Facing of (Picked unit)) - 180.00) degrees)
                        Unit - Move (Picked unit) instantly to Temp_Point
                        Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
                            Loop - Actions
                                Destructible - Kill (Picked destructible)
                        Point - Remove Skill_UnitPos
                        Point - Remove Temp_Point

The main lag source where the special effects inside Integer A loops. There were being made 200x16 instances of each effect! The bugs happening now happens only when two units casts the spell at the same time.
 

Attachments

  • WoLK_TESTMODE.w3x
    228.2 KB · Views: 112

ZeratuelX

New Member
Reaction score
6
What code did you change?

Edit-----

A nice, I wouldn't have checked for that kind of problem until later. Make sure this hero can only be gotten once per game, the spell will be only be single instance-able until you make arrays and such for every player.
 
General chit-chat
Help Users

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top