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

Lag issues in triggers

Status
Not open for further replies.
Level 2
Joined
Jul 28, 2009
Messages
24
Okay, I have multiple triggers of this similar type, and I will show an example of three of them. I have fixed any leaks I can see, and yet they cause immense lag spikes and lag to the point of un-playability after only a few minutes in-game. I need help from other Hive members to find out what exactly the problem is.

This is used to order any units that come into the region:
  • Enclave Bot Attack
    • Events
      • Unit - A unit enters Enclave bot <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set Enclave_Bot = (Units in Enclave bot <gen>)
      • Set Castle_Temp = (Center of Castle <gen>)
      • Unit Group - Pick every unit in Enclave_Bot and do (Actions)
        • Loop - Actions
          • If ((Owner of (Entering unit)) Equal to Player 12 (Brown)) then do (Unit Group - Order Enclave_Bot to Attack-Move To Castle_Temp) else do (Wait 1.00 seconds)
      • Custom script: call DestroyGroup (udg_Enclave_Bot)
      • Custom script: call RemoveLocation (udg_Castle_Temp)

This is what I use to create units:
  • Enclave bot
    • Events
      • Time - Every 35.00 seconds of game time
    • Conditions
    • Actions
      • Set EB_Spawn = (Center of Enclave bot <gen>)
      • Unit - Create 6 Footman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
      • Custom script: call RemoveLocation (udg_EB_Spawn)
      • Wait until ((In-game time of day) Greater than or equal to 2.30), checking every 1.00 seconds
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())

This is when spiking becomes so bad, the map is unplayable:

  • Enclave bot 2
    • Events
      • Game - The in-game time of day becomes Equal to 5.00
      • Time - Every 35.00 seconds of game time
    • Conditions
      • (In-game time of day) Greater than or equal to 5.00
    • Actions
      • Set EB_Spawn = (Center of Enclave bot <gen>)
      • Unit - Create 6 Footman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
      • Unit - Create 3 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
      • Unit - Create 3 Knight for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
      • Custom script: call RemoveLocation (udg_EB_Spawn)
      • Wait until ((In-game time of day) Greater than or equal to 7.30), checking every 1.00 seconds
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
It keeps making units like that until 3 more other units spawn.... what am I doing wrong? Why is it spiking and lagging so badly? I'm including the map so that you guys can take a look at it if you'd like (or if you can, please).



Edit: Pharaoh, I tried it your way, the spikes seemed to have gotten worse after editing it your way... I'm not sure what else to try... -- in fact, it was nearly unplayable spikes whenever the units spawned during the 2nd group of units consisting of footmen and riflemen.

Edit2: I've tried and played around with multiple ways between krisserz's and Destiny.Knight's suggestions, but none worked. I want to make it clear that I have 4 of these triggers active at the same time doing similar things, just at different regions.
 

Attachments

  • HERO SIEGE MIDNIGHT v1.1b.w3x
    340.2 KB · Views: 42
Last edited:
In the last trigger, you don't need the event "Game - The in-game time of the day becomes Equal to 5.00", cause you already have a condition that checks the day-time. Remove that event and just leave the periodic one. Also, remove the wait action and the destroy trigger custom script and do this instead:
  • Enclave bot 2
  • Events
    • Time - Every 35.00 seconds of game time
  • Conditions
    • (In-game time of day) Greater than or equal to 5.00
    • (In-game time of day) Less than or Equal to 7.30
  • Actions
    • Set EB_Spawn = (Center of Enclave bot <gen>)
    • Unit - Create 6 Footman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
    • Unit - Create 3 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
    • Unit - Create 3 Knight for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
    • Custom script: call RemoveLocation (udg_EB_Spawn)
 
Level 2
Joined
Jul 28, 2009
Messages
24
I tried it, and it didn't work out so well.. :(

I did the exact same, and it did the spikes earlier and were hitting harder.
In the last trigger, you don't need the event "Game - The in-game time of the day becomes Equal to 5.00", cause you already have a condition that checks the day-time. Remove that event and just leave the periodic one. Also, remove the wait action and the destroy trigger custom script and do this instead:
  • Enclave bot 2
  • Events
    • Time - Every 35.00 seconds of game time
  • Conditions
    • (In-game time of day) Greater than or equal to 5.00
    • (In-game time of day) Less than or Equal to 7.30
  • Actions
    • Set EB_Spawn = (Center of Enclave bot <gen>)
    • Unit - Create 6 Footman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
    • Unit - Create 3 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
    • Unit - Create 3 Knight for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
    • Custom script: call RemoveLocation (udg_EB_Spawn)
 
Level 18
Joined
Feb 28, 2009
Messages
1,970
Sometimes it`s hard to remove lags, but try to spawn units in lesser numbers, like spawn 1 rifleman, and copy that 3 times, so you`ll have
  • Unit - Create 1 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
  • Unit - Create 1 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
  • Unit - Create 1 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
 
Level 2
Joined
Jul 28, 2009
Messages
24
for Loop 1 to 100
Set EB_Spawn = (Center of Enclave bot <gen>)
Unit - Create 1 Footman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
Custom script: call RemoveLocation (udg_EB_Spawn)
end loop

hope this helps

I'm not exactly sure how to do that....could you show me in trigger format, please? [I can't find the "for Loop 1 to 100"]
 
Level 2
Joined
Jul 28, 2009
Messages
24
Sometimes it`s hard to remove lags, but try to spawn units in lesser numbers, like spawn 1 rifleman, and copy that 3 times, so you`ll have
  • Unit - Create 1 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
  • Unit - Create 1 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees
  • Unit - Create 1 Rifleman for Player 12 (Brown) at EB_Spawn facing 180.00 degrees

I've tried your way, and it didn't have much effect on reducing the spikes or the lag.. any other suggestions?
 
Level 2
Joined
Jul 28, 2009
Messages
24
Okay, I tried the looping and it caused warcraft 3 to freeze over entirely on the first spawn. So, yeah...that didn't work out, lol.

Any other things I should try out?
I Should keep an open note that there are 4~6 of these triggers (that are doing similar things) are all going off at once, which is why i believe the lag and spikes are present.
 
Level 8
Joined
Dec 8, 2007
Messages
312
Your problem is not leaks but this lines in your first reigger
  • Unit Group - Pick every unit in Enclave_Bot and do (Actions)
  • Loop - Actions
  • If ((Owner of (Entering unit)) Equal to Player 12 (Brown)) then do (Unit Group - Order Enclave_Bot to Attack-Move To Castle_Temp) else do (Wait 1.00 seconds)
problem is that for every unit in that region it runs a loop equally to unit there.
Enclave bot 2 makes lagg because you place the 12 units and for each unit your trigger runs a pointless loop 12 times. that would be 144 action just for placing your units there.

your trigger should be more simple like this
  • Enclave Bot Attack
    • Events
      • Unit - A unit enters Enclave bot <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set Castle_Temp = (Center of Castle <gen>)
      • If ((Owner of (Entering unit)) Equal to Player 12 (Brown)) then do (Unit - Order (Entering unit) to Attack-Move To Castle_Temp) else do (Wait 1.00 seconds)
      • Custom script: call RemoveLocation (udg_Castle_Temp)
Edit:
Actually it can be more simple. I just noticed that conditions already check if unit belongs to player 12 so no need for if/then/else in action. just order entering unit to move
 
Level 2
Joined
Jul 28, 2009
Messages
24
Your problem is not leaks but this lines in your first reigger
  • Unit Group - Pick every unit in Enclave_Bot and do (Actions)
  • Loop - Actions
  • If ((Owner of (Entering unit)) Equal to Player 12 (Brown)) then do (Unit Group - Order Enclave_Bot to Attack-Move To Castle_Temp) else do (Wait 1.00 seconds)
problem is that for every unit in that region it runs a loop equally to unit there.
Enclave bot 2 makes lagg because you place the 12 units and for each unit your trigger runs a pointless loop 12 times. that would be 144 action just for placing your units there.

your trigger should be more simple like this
  • Enclave Bot Attack
    • Events
      • Unit - A unit enters Enclave bot <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set Castle_Temp = (Center of Castle <gen>)
      • If ((Owner of (Entering unit)) Equal to Player 12 (Brown)) then do (Unit - Order (Entering unit) to Attack-Move To Castle_Temp) else do (Wait 1.00 seconds)
      • Custom script: call RemoveLocation (udg_Castle_Temp)
Edit:
Actually it can be more simple. I just noticed that conditions already check if unit belongs to player 12 so no need for if/then/else in action. just order entering unit to move

Thank you sooo much, that was a big help. The spikes and the lag disappeared almost altogether, but I do not know if it will come back. Thank you for this information however...!! +Reputation
 
Status
Not open for further replies.
Top