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

Need advice to reduce Lag

Status
Not open for further replies.
Level 4
Joined
Nov 26, 2011
Messages
34
I'm was making a Tower Defense map, but when I test the map, its was really horrible lags, do someone have advice 4 me to reduce the lag? :bored: I was thinking that the problem is because I used a lot of trigger, but I need all of them to move my creeps, can someone Help ME? :cry: Here are my Trigger:
mytrigger-1322294749.jpg

Here are the Ex of my Map: Example TD
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
Your Wrote Lives and Ruined Village triggers both fire every 0.00 seconds, which is very frequent and they create and leak objects while doing so, making this interval even worse. You have to change the lives text tag only when lives change and there is no need for the other trigger to have a periodic event either.
 
Level 4
Joined
Nov 26, 2011
Messages
34
thank you very much 4 the advices, now i can continue making my maps :thumbs_up:
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Remove the leaks, and don't create all the creeps at the same time.

You use Periodic Triggers for things that doesn't need to be periodic at all... And have Group leaks, and Point leaks, and several triggers for things that can be done in one. Don't worry, you're learning. We've all been there. Read and learn.


Your map initialization had leaks, and could be improved a lot. Instead of creating a new floating text every 0.00 seconds, you can create one, and change the text only when the text is supossed to change.
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Group = (Units in No Villager shall leave <gen>)
      • Set Lives = (Number of units in Group)
      • Set Point = (Center of No Villager shall leave <gen>)
      • Floating Text - Create floating text that reads ((String(Lives)) + !) at Point with Z offset 0.00, using font size 28.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
      • Set FloatingText = (Last created floating text)
      • Custom script: call DestroyGroup(udg_Group)
      • Game - Display to (All players) for 5.00 seconds the text: You can see your li...
      • Cinematic - Ping minimap for (All players) at Point for 1.00 seconds, using a Simple ping of color (100.00%, 0.00%, 0.00%)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across (Playable map area)
          • Visibility - Enable (Last created visibility modifier)
      • Custom script: call RemoveLocation(udg_Point)
-> Mix Triggers, use Player Pick Loop, and reduce the parentheses as much as possible when repeating things (Picked player several times is wrong, when you can call it once in a variable, and use the variable from there on)
  • Set Resource and Music and Init Cam
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Sound - Play TragicConfrontation <gen>
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Player = (Picked player)
          • Set Point = (Player start location)
          • Camera - Pan camera for Player to Point over 0.00 seconds
          • Player - Set Player Current gold to 30
          • Custom script: call RemoveLocation(udg_Point)
-> Remove the Group Leaks and Mix Triggers
  • Count and Write Lives and Ruined Village
    • Events
      • Unit - A unit enters Village Enter <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Human Builder
    • Actions
      • Set Group = (Units in No Villager shall leave <gen>)
      • Unit - Kill (Triggering unit)
      • Unit - Kill (Random unit from Group)
      • Set Lives = (Number of units in Group)
      • Floating Text - Change text of FloatingText to ((String(Lives)) + !) using font size 28.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Group) Equal to 0
        • Then - Actions
          • Game - Display to (All players) for 30.00 seconds the text: The Village have be...
          • Wait 2.00 seconds
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Game - Defeat (Picked player) with the message: The village has bee...
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Group)


Do the same on the rest. Declare the points, use the points, and remove the points. Same with Groups: Declare, use, destroy. Integers doesn't leak, neither counting units in the group variable (as long as you destroy the group later with shown methods)

You can't imagine how "improved" and "fast" and "non-laggy" your map is by just doing your triggers like I showed in the Hidden tag. Turned 7 or 8 Triggers into 3, better made ones.

BTW; if your paths are already fixed and squared, there's no need to order the units to move region by region. Just order all of them to move to the goal, and they'll find their path. It even makes the game more interesting.

Also, there are "automatic" or "generic" or "more intuitive" ways of doing the spawning of creeps for all players, for all waves, including boss waves, with just 1 trigger... Neat huh?

The moving triggers aren't the bad ones (though they all have Point leaks, per unit.. Means at least 10 (Unit) x 30 (Move Triggers) = 300 leaks. The bad ones were the periodic triggers (Create floating text and others like those).
 
Last edited:
Status
Not open for further replies.
Top