Why does this lagg?

feelingparty

New Member
Reaction score
3
So something's wrong with my map because whenever there are more units on the screen there is a major drop-down in fps. There are some leaks that need clearing but that (i think) is not the case as the laggs are there from the beginning itself. For example I have this spell that shoots an arrow and a fiery dummy unit that i use for the effect. And everything works fine except that when I cast it my fps goes down from 63 to 18 until the arrow and the effect are dead then it goes up again. Any thoughts? Here is the movement trigger :
Trigger:
  • Move Proj
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Arrows and do (Actions)
        • Loop - Actions
          • Set Temp_Point = (Position of (Picked unit))
          • Set Temp_Point2 = (Temp_Point offset by (Load 3 of (Key (Picked unit)) from hasharrows) towards (Load 4 of (Key (Picked unit)) from hasharrows) degrees)
          • Set Temp_Group = (Units within 70.00 of Temp_Point)
          • Unit Group - Pick every unit in Temp_Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Not equal to FieldDummy
                  • (Unit-type of (Picked unit)) Not equal to FlamingArrow
                  • ((Picked unit) is dead) Equal to False
                • Then - Actions
                  • Set unit = (Picked unit)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 2 of (Key (Picked unit)) from hasharrows) Greater than or equal to 0.00
              • ((Picked unit) is alive) Equal to True
              • unit Equal to No unit
            • Then - Actions
              • Unit - Move (Picked unit) instantly to Temp_Point2
              • Hashtable - Save ((Load 2 of (Key (Picked unit)) from hasharrows) - (Load 3 of (Key (Picked unit)) from hasharrows)) as 2 of (Key (Picked unit)) in hasharrows
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to FieldDummy
                      • (Unit-type of (Picked unit)) Equal to FlamingArrow
                • Then - Actions
                  • Unit - Cause (Picked unit) to damage unit, dealing (Load 5 of (Key (Picked unit)) from hasharrows) damage of attack type Spells and damage type Normal
                  • Unit - Remove (Picked unit) from the game
                • Else - Actions
                  • Unit - Remove (Picked unit) from the game
          • Set unit = No unit
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Custom script: call RemoveLocation (udg_Temp_Point2)
          • Custom script: call DestroyGroup (udg_Temp_Group)


And here is the other trigger (even though i think the problem is in the upper)
Trigger:
  • Arrow Fire
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Shoot Flaming Arrow
          • (Ability being cast) Equal to Fletch Arrow
          • (Ability being cast) Equal to Shoot Flaming Arrow 2
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Shoot Flaming Arrow 2
        • Then - Actions
          • Unit - Create 1 FlamingArrow for (Triggering player) at ((Position of (Triggering unit)) offset by 100.00 towards (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees) facing (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees
          • Special Effect - Create a special effect attached to the overhead of (Last created unit) using Abilities\Spells\Other\BreathOfFire\BreathOfFireDamage.mdl
          • Hashtable - Save (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) as 4 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBspeed[(Player number of (Triggering player))] as 3 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBdistance[(Player number of (Triggering player))] as 2 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save (ATRIBattack[(Player number of (Triggering player))] x ATRIBattMultip[(Player number of (Triggering player))]) as 5 of (Key (Last created unit)) in hasharrows
          • Unit Group - Add (Last created unit) to Arrows
          • Unit - Create 1 FlamingArrowFX for (Triggering player) at ((Position of (Triggering unit)) offset by 100.00 towards (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees) facing (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) degrees
          • Hashtable - Save (Angle from (Position of (Triggering unit)) to (Target point of ability being cast)) as 4 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBspeed[(Player number of (Triggering player))] as 3 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save ATRIBdistance[(Player number of (Triggering player))] as 2 of (Key (Last created unit)) in hasharrows
          • Hashtable - Save (ATRIBattack[(Player number of (Triggering player))] x ATRIBattMultip[(Player number of (Triggering player))]) as 5 of (Key (Last created unit)) in hasharrows
          • Unit Group - Add (Last created unit) to Arrows
        • Else - Actions
      • Sound - Play ArrowAttack1 <gen> at 100.00% volume, attached to (Triggering unit)
 

Ashlebede

New Member
Reaction score
43
You have to flush child hashtables, first of all.

Trigger:
  • Hashtable - Clear all child hashtables of child (Key unit) in H

Use this when you don't need it anymore. It will remove all the stored values for that unit in the Hashtable. This can cause leaks if you don't do it.

Making that action happen every .02 second can also alter performance. I usually use .04 or .03 delay.

Can't find anything else wrong, but from my experience, not clearing child Hashtables is verrry laggy. That should help at least a little.
 

feelingparty

New Member
Reaction score
3
thank you for your help. I changed the periodic to 0.04 (rescaled speed), added a clearing for the child hashtable. And the fps drop-down got halved. However if the ability is cast 2 or 3 times the fps goes to about 8 witch is insane considering my CPU is pretty good. Is there any way to completely remove it so it is possible to cast the spell multiple times?(The spell must be MUI after all.)
 

Ashlebede

New Member
Reaction score
43
There's always UserData which can be used instead of one of the Hashtable values and is quicker. However it can only store a single integer.

Trigger:
  • Actions
    • Unit - Set the custom value of (Triggering unit) to 10
    • Set int = (Custom value of (Triggering unit))

That could be a little less computer-hungry, but only for one value. Probably won't make a difference. Of course, you would have to convert the reals to integers...

You can also reduce lag from first run by calling this line at map init in a custom script:

JASS:
call Preload("My Special Effect's path")

Having the path to your special effect between the double-quotes, doubling all the backslashes. For instance, "Blah\Blahblah\Blah.mdl" would become "Blah\\Blahblah\\Blah.mdl".

This will pre-load the model file for your special effect, making some lag at map startup, but reducing the spikes caused by using abilities for the first time. (it would often make some 2-second spikes on Lagginator if I didn't preload)

Really can't find any leaks, though. I'm rather bad at analyzing others' code, too. :p
 

feelingparty

New Member
Reaction score
3
So I tried reworking everything. And I think the problem doesn't come from the hashtables nor from the models as i didn't use any of them (I used Custom Values when possible and preloaded all dummy models). I think that my Group-in-Group (for each unit in X pick each unit in Y and do actions) method doesn't work though. Any ideas how to bypass this?
 

Ashlebede

New Member
Reaction score
43
Trigger:
  • Set Temp_Group = Units within 70.00 of (Position of(Picked Unit)) matching {Condition}


Condition should use "Matching Unit" to refer to the unit for which you want to verify the condition. It then won't overlap with the units of the first loop... in theory...

Then, to check if there is a unit in the group, you have to verify like this :

Trigger:
  • (Number of units in Temp_Group) Equal to 0


That should do it, um... maybe....
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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