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

[Solved] FPS drops with loop in MUI spells

Status
Not open for further replies.
Level 10
Joined
Sep 16, 2016
Messages
269
Up until now, I have always done MUI spells with array method and periodic timer (0.03125s). A friend told me it is make w3 run multiple loops O(n) by running integer loop, creating+destroying groups, which greatly causes Fps drop. I tested it with a simple CUSTOM spell and it went down from 55 to 29 fps with 10 casts (no cd).

I wonder if this is true then? (I believe it more than 70%). And if it were, what kind of method can I use then? This is totally in GUI so I hope you wouldn't answer things like GroupUtils or TimerUtils

  • Reset
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set loc = (Position of Paladin 0001 <gen>)
      • Set SW_Count = (SW_Count + 1)
      • Set SW_Travel_Count[SW_Count] = 40
      • Set SW_Angle[SW_Count] = (Random real number between 0.00 and 360.00)
      • Memory Leak - Destroy SW_DamageGroup[SW_Count]
      • Set SW_DamageGroup[SW_Count] = (Create Unit Group)
      • Unit - Create 1 Dummy Caster for Neutral Passive at loc facing SW_Angle[SW_Count] degrees
      • Set SW_Missile[SW_Count] = (Last created unit)
      • Set SW_Caster[SW_Count] = Paladin 0001 <gen>
      • Memory Leak - Remove loc
      • Trigger - Turn on Untitled Trigger 001 <gen>
  • Untitled Trigger 001
    • Events
      • Time - Every (1.00 / 32.00) seconds of game time
    • Conditions
    • Actions
      • For each (Integer Int) from 1 to SW_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SW_Travel_Count[Int] Greater than 0
            • Then - Actions
              • Set SW_Travel_Count[Int] = (SW_Travel_Count[Int] - 1)
              • Set loc = (Position of SW_Missile[Int])
              • Set loc_1 = (loc offset by 31.25 towards SW_Angle[Int] degrees)
              • Unit - Move SW_Missile[Int] instantly to loc_1
              • Set TempUnitGroup = (Units within 165.00 of loc_1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) is in SW_DamageGroup[Int]) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of
              • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
                • Loop - Actions
                  • Unit - Cause SW_Caster[Int] to damage (Picked unit), dealing 200.00 damage of attack type Spells and damage type Magic
                  • Unit Group - Add (Picked unit) to SW_DamageGroup[Int]
              • Memory Leak - Remove loc
              • Memory Leak - Remove loc_1
              • Memory Leak - Destroy TempUnitGroup
            • Else - Actions
              • Unit - Kill SW_Missile[Int]
              • Set SW_Angle[Int] = SW_Angle[SW_Count]
              • Set SW_Caster[Int] = SW_Caster[SW_Count]
              • Set SW_Missile[Int] = SW_Missile[SW_Count]
              • Set SW_Travel_Count[Int] = SW_Travel_Count[SW_Count]
              • Unit Group - Remove all units from SW_DamageGroup[Int]
              • Unit Group - Pick every unit in SW_DamageGroup[SW_Count] and do (Unit Group - Add (Picked unit) to SW_DamageGroup[Int])
              • Set Int = (Int - 1)
              • Set SW_Count = (SW_Count - 1)
      • If (SW_Count Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
Edit: remove spoiler
Edit 2: add full triggers
 
Last edited:
Level 11
Joined
May 16, 2016
Messages
730
Up until now, I have always done MUI spells with array method and periodic timer (0.03125s). A friend told me it is make w3 run multiple loops O(n) by running integer loop, creating+destroying groups, which greatly causes Fps drop. I tested it with a simple shockwave spell and it went down from 55 to 29 fps with 10 casts (no cd).
Shockwave causes large FPS problem just like War Stomp or Thunder Clap
 
Level 8
Joined
Jan 28, 2016
Messages
486
You're not removing the group and location leaks properly (unless what you wrote above is pseudo-code).

  • Removing Leaks
    • Events
    • Conditions
    • Actions
      • Custom script: call RemoveLocation( udg_loc )
      • Custom script: call RemoveLocation( udg_loc_1 )
      • Custom script: call DestroyGroup( udg_TempUnitGroup )
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Unit - Move SW_Missile[Int] instantly to loc_1
This is computationally very intensive. It checks unit on unit collisions, pathing collisions as well as performs displacement.

Use SetUnitX and SetUnitY, both do not test for any collision or perform any displacement so are much faster. Since missiles generally do not collide with units these fewer tests are beneficial on top of being faster.

Shockwave causes large FPS problem just like War Stomp or Thunder Clap
Thunder Clap causes FPS problems? I did not think it created deformations.
 
As DSG said, if you use SetUnitX/Y it will perform better.
It will work correct and perform better, if you create the SW_DamageGroup[INt] before firing a missle, you have to clear/Destory, depends on the whole design, the Groups on expire, too.

With what starting Size you create the Array SW_DamageGroup this is important, cause only the amount of preseted Groups are created by World editor automatically, others have to be created by your Missle starting, else you will do all unit actions upto 32 times a second for each Unit affected cause the SW_DamageGroup[2->8xxx] are not existing and can't contain the Targets.

If you want to check out by yourself do following:
  • Create a Group-Array Variable with Size 1.
  • Switch to WE Main Screen.
  • Select Menu "File - Export Script"
  • Save it.
  • Open it with Notepad/Editor
  • Scroll down to/Search "function InitGlobals takes nothing returns nothing"
  • Search your Group-Variable Array
Will look like this:
JASS:
function InitGlobals takes nothing returns nothing
"Other Code"

    local integer i = 0
    set i = 0
    loop
        exitwhen (i > 1)
        set udg_SW_DamageGroup[i] = CreateGroup()
        set i = i + 1
    endloop

"Other Code"
endfunction
 
Level 10
Joined
Sep 16, 2016
Messages
269
Thx Dr.Good for your advice and Tasyen for your information.

The performance also depends on how I chose the dummy model. I was stupid to pick Fire Lord model as missile to take a fps performance test, it consumed a lot of frame. I just don't want to go too much with custom script when using GUI triggers.
 
Status
Not open for further replies.
Top