• 🏆 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] Why does this lag?

Status
Not open for further replies.
Level 8
Joined
Jun 1, 2008
Messages
341
Hey Ive come across a hinderance in my project, can anyone tell me why this would lag after i've played for about 10 mins, yet i can fire about a hundred missile similtaniously in the begining. Is there a leak im missing?? any help appreciated. If you need to know more please ask.

  • Intalization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- //Setup Heros and Hide Initial Dummy Units --------
      • Set TempGroup = (Units of type Dummy)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 8, do (Actions)
            • Loop - Actions
              • Set TempPoint = ((Player((Integer A))) start location)
              • Set TempPoint2 = (Position of (Picked unit))
              • Unit - Create 1 Blood Mage for (Player((Integer A))) at TempPoint facing TempPoint2
              • Set Hero[(Integer A)] = (Last created unit)
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call RemoveLocation(udg_TempPoint2)
          • Animation - Change (Picked unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 100.00% transparency
      • Custom script: call DestroyGroup(udg_TempGroup)
      • -------- //Setup AI --------
      • Set TempGroup2 = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Owner of (Matching unit)) controller) Not equal to User) or (((Owner of (Matching unit)) slot status) Equal to Is unused))))
      • Unit Group - Pick every unit in TempGroup2 and do (Actions)
        • Loop - Actions
          • Set TempGroup3 = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of (Picked unit))) Equal to True))))
          • Set TempUnit = (Random unit from TempGroup3)
          • Set TempPoint2 = (Position of TempUnit)
          • Set AIControll_Movepoint[(Player number of (Picked player))] = TempPoint2
          • Unit - Order (Picked unit) to Move To TempPoint2
          • Hero - Learn skill for (Picked unit): Blast
          • Set TempUnit = No unit
          • Custom script: call DestroyGroup(udg_TempGroup3)
          • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempGroup2)
This is the Blast Intilisation

  • Blast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Level of Blast for (Casting unit)) Not equal to 0
    • Actions
      • Set TempUnit = (Casting unit)
      • Set TempPoint = (Position of TempUnit)
      • Set TempPoint2 = (Target point of ability being cast)
      • Set TempReal = (Angle from TempPoint to TempPoint2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Blast for TempUnit) Equal to 1
        • Then - Actions
          • Unit - Create 1 Dummy for (Owner of TempUnit) at TempPoint facing TempReal degrees
          • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
          • Unit Group - Add (Last created unit) to Blast_Spell
          • Unit - Order TempUnit to Stop
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blast for TempUnit) Equal to 2
            • Then - Actions
              • For each (Integer A) from -1 to 1, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer A) Not equal to 0
                    • Then - Actions
                      • Set TempReal2 = (TempReal + (5.00 x (Real((Integer A)))))
                      • Unit - Create 1 Dummy for (Owner of TempUnit) at TempPoint facing TempReal2 degrees
                      • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                      • Unit Group - Add (Last created unit) to Blast_Spell
                      • Unit - Order TempUnit to Stop
                    • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Blast for TempUnit) Equal to 3
                • Then - Actions
                  • For each (Integer A) from -1 to 1, do (Actions)
                    • Loop - Actions
                      • Set TempReal2 = (TempReal + (5.00 x (Real((Integer A)))))
                      • Unit - Create 1 Dummy for (Owner of TempUnit) at TempPoint facing TempReal2 degrees
                      • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                      • Unit Group - Add (Last created unit) to Blast_Spell
                      • Unit - Order TempUnit to Stop
                • Else - Actions
      • Set TempUnit = No unit
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)
This is the Blast System

  • System
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Blast_Spell) Not equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in Blast_Spell and do (Actions)
            • Loop - Actions
              • Set TempUnit = (Picked unit)
              • Animation - Change TempUnit flying height to 50.00 at 100.00
              • Set TempPoint = (Position of TempUnit)
              • Set TempPoint2 = (TempPoint offset by 12.00 towards (Facing of TempUnit) degrees)
              • Set TempPoint3 = (Position of Hero[(Player number of (Owner of TempUnit))])
              • Set TempInteger = ((((Level of Hero[(Player number of (Owner of TempUnit))]) x (Random integer number between 2 and 5)) + ((Level of Blast for Hero[(Player number of (Owner of TempUnit))]) x (Random integer number between 5 and 10))) + (Random integer number between 5 and 15)
              • Set TempGroup2 = (Units in (Region centered at TempPoint with size (120.00, 120.00)) matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of TempUnit)) Equal to True)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit is dead) Equal to True
                • Then - Actions
                  • Unit - Remove TempUnit from the game
                  • Special Effect - Create a special effect at TempPoint2 using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Skip remaining actions
                • Else - Actions
              • Unit - Move TempUnit instantly to TempPoint2
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Number of units in TempGroup2) Not equal to 0
                      • (Terrain pathing at TempPoint2 of type Walkability is off) Equal to True
                • Then - Actions
                  • Unit Group - Pick every unit in TempGroup2 and do (Actions)
                    • Loop - Actions
                      • Set TempUnit2 = (Picked unit)
                      • Unit - Cause Hero[(Player number of (Owner of TempUnit))] to damage TempUnit2, dealing (Real(TempInteger)) damage of attack type Hero and damage type Force
                  • Unit - Remove TempUnit from the game
                  • Special Effect - Create a special effect at TempPoint2 using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in TempGroup2) Not equal to 0
                    • Then - Actions
                      • Floating Text - Create floating text that reads (String(TempInteger)) above TempUnit2 with Z offset 0.00, using font size 8.00, color (55.00%, 20.00%, 20.00%), and 25.00% transparency
                      • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
                      • Floating Text - Change the fading age of (Last created floating text) to 1.50 seconds
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • TempInteger Greater than or equal to ((((Hero level of Hero[(Player number of (Owner of TempUnit))]) x 5) + 13) + ((Level of Blast for Hero[(Player number of (Owner of TempUnit))]) x 10))
                        • Then - Actions
                          • Floating Text - Create floating text that reads Critical Hit above TempUnit2 with Z offset 0.00, using font size 10.00, color (55.00%, 20.00%, 20.00%), and 0.00% transparency
                          • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                          • Floating Text - Change (Last created floating text): Disable permanence
                          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                          • Floating Text - Change the fading age of (Last created floating text) to 2.50 seconds
                        • Else - Actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: call RemoveLocation(udg_TempPoint3)
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call DestroyGroup(udg_TempGroup2)
The Rest might not be needed to know.

  • AI Controll Settings
    • Events
      • Time - Every 0.80 seconds of game time
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Owner of (Matching unit)) controller) Not equal to User) or (((Owner of (Matching unit)) slot status) Equal to Is unused))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Not equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Melee AI of (Owner of (Picked unit))) Equal to Easy AI
                • Then - Actions
                  • Set TempUnit = (Picked unit)
                  • Set TempPoint = (Position of TempUnit)
                  • Set TempGroup2 = (Units within (Current acquisition range of TempUnit) of TempPoint matching (((((Matching unit) is alive) Equal to True) and (((Matching unit) is Magic Immune) Equal to False)) and (((Owner of (Matching unit)) is an enemy of (Owner of TempUnit)) Equal to True
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in TempGroup2) Greater than 0
                    • Then - Actions
                      • Set TempUnit2 = (Random unit from TempGroup)
                      • Set TempPoint2 = (Position of TempUnit2)
                      • Set TempUnit2 = No unit
                      • Unit - Order TempUnit to Orc Tauren Chieftain - Shockwave TempPoint2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Region centered at TempPoint with size (150.00, 150.00)) contains AIControll_Movepoint[(Player number of (Owner of TempUnit))]) Equal to True
                        • Then - Actions
                          • Custom script: call RemoveLocation(udg_TempPoint)
                          • Set TempPoint = (Random point in (Playable map area))
                          • Set AIControll_Movepoint[(Player number of (Owner of TempUnit))] = TempPoint
                          • Unit - Order TempUnit to Move To AIControll_Movepoint[(Player number of (Owner of TempUnit))]
                        • Else - Actions
                          • Unit - Order TempUnit to Move To AIControll_Movepoint[(Player number of (Owner of TempUnit))]
                • Else - Actions
          • Set TempUnit = No unit
          • Custom script: call DestroyGroup(udg_TempGroup2)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
          • Custom script: call RemoveLocation(udg_TempPoint3)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
  • AI Controll Settings Normal
    • Events
      • Time - Every 0.60 seconds of game time
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Owner of (Matching unit)) controller) Not equal to User) or (((Owner of (Matching unit)) slot status) Equal to Is unused))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Not equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Melee AI of (Owner of (Picked unit))) Equal to Normal AI
                • Then - Actions
                  • Set TempUnit = (Picked unit)
                  • Set TempPoint = (Position of TempUnit)
                  • Set TempGroup2 = (Units within 1000.00 of TempPoint matching (((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A Hero) Equal to True) or ((Owner of (Matching unit)) Equal to Player 12 (Brown)))) and (((Owner of (Matching unit)) is an enemy of (Owner of Te
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in TempGroup2) Greater than 0
                    • Then - Actions
                      • Set TempUnit2 = (Random unit from TempGroup)
                      • Set TempPoint2 = (Position of TempUnit2)
                      • Set TempUnit2 = No unit
                      • Unit - Order TempUnit to Orc Tauren Chieftain - Shockwave TempPoint2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Region centered at TempPoint with size (150.00, 150.00)) contains AIControll_Movepoint[(Player number of (Owner of TempUnit))]) Equal to True
                        • Then - Actions
                          • Custom script: call RemoveLocation(udg_TempPoint)
                          • Set TempPoint = (Random point in (Playable map area))
                          • Set AIControll_Movepoint[(Player number of (Owner of TempUnit))] = TempPoint
                          • Unit - Order TempUnit to Move To AIControll_Movepoint[(Player number of (Owner of TempUnit))]
                        • Else - Actions
                          • Unit - Order TempUnit to Move To AIControll_Movepoint[(Player number of (Owner of TempUnit))]
                • Else - Actions
          • Set TempUnit = No unit
          • Custom script: call DestroyGroup(udg_TempGroup2)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
          • Custom script: call RemoveLocation(udg_TempPoint3)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
  • AI Controll Settings Insane
    • Events
      • Time - Every 0.40 seconds of game time
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Owner of (Matching unit)) controller) Not equal to User) or (((Owner of (Matching unit)) slot status) Equal to Is unused))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Not equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Melee AI of (Owner of (Picked unit))) Equal to Insane AI
                • Then - Actions
                  • Set TempUnit = (Picked unit)
                  • Set TempPoint = (Position of TempUnit)
                  • Set TempGroup2 = (Units within (Current acquisition range of TempUnit) of TempPoint matching (((((Matching unit) is alive) Equal to True) and (((Matching unit) is Magic Immune) Equal to False)) and (((Owner of (Matching unit)) is an enemy of (Owner of TempUnit)) Equal to True
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in TempGroup2) Greater than 0
                    • Then - Actions
                      • Set TempUnit2 = (Random unit from TempGroup)
                      • Set TempPoint2 = (Position of TempUnit2)
                      • Set TempUnit2 = No unit
                      • Unit - Order TempUnit to Orc Tauren Chieftain - Shockwave TempPoint2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Region centered at TempPoint with size (150.00, 150.00)) contains AIControll_Movepoint[(Player number of (Owner of TempUnit))]) Equal to True
                        • Then - Actions
                          • Custom script: call RemoveLocation(udg_TempPoint)
                          • Set TempPoint = (Random point in (Playable map area))
                          • Set AIControll_Movepoint[(Player number of (Owner of TempUnit))] = TempPoint
                          • Unit - Order TempUnit to Move To AIControll_Movepoint[(Player number of (Owner of TempUnit))]
                        • Else - Actions
                          • Unit - Order TempUnit to Move To AIControll_Movepoint[(Player number of (Owner of TempUnit))]
                • Else - Actions
          • Set TempUnit = No unit
          • Custom script: call DestroyGroup(udg_TempGroup2)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
          • Custom script: call RemoveLocation(udg_TempPoint3)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
Any help appreciated.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
0.01 does not lag, its purly the rate at which stuff is executed. It is the actual code which causes the lag. If you have complicated demanding code, lowering the rate at which it is executed will reduce lag. Eg, you can easilly add 1 to a counter 100 times a second without any lag what so ever occuring whoever runinng physics for 100 objects 100 times per second will almost garuntee you getting unplayable frame rate.
 
Level 8
Joined
Jun 1, 2008
Messages
341
I understand this but what i can't understand is why it works fine for the first 5-10 minuets while firing loads of missiles 100 in a row +... However after about 10 mins you can only fire about 10 missiles before the lag builds up. My first conclusion was that it had a leak (a small one) which built up until it lagged the game. Could this be right?

By reducing the speed its done should it then stop lagging or will it just temporarily stall it?


Already Have
 
Level 4
Joined
Jun 1, 2009
Messages
87
where exactly does ur 0.01 second trigger gets turned off? as a matter of fact where does any of ur period triggers gets turned off
 
Level 8
Joined
Jun 1, 2008
Messages
341
Think I've found the problem;
The Removing variables was executed EVERY 0.01 seconds coz it wasn't in the else part. (Silly me)
Also thanks dark reapers. I forgot to set conditional trigger removification. (my word)
Now it looks like this Yay.

  • Else - Actions
  • Custom script: call RemoveLocation(udg_TempPoint)
  • Custom script: call RemoveLocation(udg_TempPoint2)
  • Custom script: call RemoveLocation(udg_TempPoint3)
  • Custom script: call DestroyGroup(udg_TempGroup)
  • Custom script: call DestroyGroup(udg_TempGroup2)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in Blast_Spell) Equal to 0
    • Then - Actions
      • Trigger - Turn on System <gen>
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in Blast_Spell) Not equal to 0
    • Then - Actions
  • Do Somthing...
    • Else - Actions
      • Trigger - Turn off (This trigger)
 
Status
Not open for further replies.
Top