• 🏆 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] Frame Drop

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
Hello everyone,

So I am busy with this Nexus Wars style map but I stumbled into a problem.
After a couple of unit waves the game starts to lag and my frames drop. Perhaps there is a leak somewhere in my spawning triggers.

Please tell me if you see a leak, or a possible reason that could cause this problem.

Code:

  • Farm
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set Spawn_Building = Farm
      • Set Spawn_Unit = Footman
      • Set Spawn_Integer = 10
      • -------- -------------------- --------
      • Unit Group - Pick every unit in (Units in Map) and do (Actions)
        • Loop - Actions
          • Set Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of Unit) Equal to Spawn_Building
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer((Mana of Unit))) Equal to Spawn_Integer
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of Unit) is in (All allies of Player 11 (Dark Green))) Equal to True
                    • Then - Actions
                      • Unit - Create 1 Spawn_Unit for Player 11 (Dark Green) at (Position of Unit) facing Default building facing degrees
                      • Set Spawn = (Last created unit)
                      • Unit - Order Spawn to Attack-Move To (Center of Team 2 Base <gen>)
                      • Custom script: set udg_Spawn = null
                    • Else - Actions
                      • Unit - Create 1 Spawn_Unit for Player 12 (Brown) at (Position of Unit) facing Default building facing degrees
                      • Set Spawn = (Last created unit)
                      • Unit - Order Spawn to Attack-Move To (Center of Team 1 Base <gen>)
                      • Custom script: set udg_Spawn = null
                  • Unit - Set mana of Unit to 0.00
                • Else - Actions
            • Else - Actions
          • Custom script: set udg_Unit = null
      • Custom script: call DestroyGroup( bj_lastCreatedGroup )
Thanks in advance.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Lets see.. you create 2 Point Leaks every 0.01 seconds of the game. That's 200 point leaks per second.

· Use a point variable to do the position where you want to create/attack, use the variable in the creation/order functions, and then use "Custom script: call RemoveLocation(udg_YourPointVariableName)" to clean the leak.

· There's no need to null global variables as udg_Unit and udg_Spawn

· Reduce the loop speed to 0.03~0.05.

· Why do you destroy the last created group if you're picking units in a Group already? I would rather suggest adding the Spawn_Building to a unit group, and pick every unit in that group, without creating/destroying generic groups every 0.03 seconds.
 
Status
Not open for further replies.
Top