![]() | |
| | #1 |
![]() Join Date: Sep 2006 Location: Your Mom
Posts: 2,241
![]() | Reducing Lag Reducing Lag How to kill the anti-map, GUI version. Introduction The non-important, nice way to start a tutorial. Lag, the anti-map. If you want to make a cool map, a ‘new’ map, something that makes the players go ‘wow’, your going to have to have a lot of nice triggers. However, there’s more to nice triggers then what they do, there’s rules, and if you don’t follow them, your going to get swamped with lag.Disclaimer: The quality of this tutorial may not be as great as my others since I made it a long time ago(in 2005), and it was unfinished. Reducing lag is a big topic, and I didn’t know as nearly as much as I do now on the subject when I made this. I figured it could still help someone though, so I restored it some and re-released it. Getting Started Time to set out on your quest against the lag. The 5 Rules of the Anti-Lag Association: -If you’re not using it, throw it away. -If you do something once, then don’t do it again unless you have to. -Take the shortest route possible, while still keeping your triggers lag less. -Streaming is better then shipping. It’s better to do things little by little then in big loads. -If you have found what your looking for, stop looking. If you’re not using it, throw it away What this means is that, if you have something in your map that you will not need again, then why keep it? This goes from extra abilities/units you have saved to the floating text you created in game. See Memory Leaks, Quality over Quantity, , and . If you do something once, then don’t do it again unless you have to. Say you have the game go fetch a unit group, and you have a lot of actions for this same unit group. Why have the game fetch the unit group again, and again for each action, when you can just temporarily save it. See Using Variables. Code: Pick Every Unit in (All Units in (Playable Map Area)) and do stuff Pick Every Unit in (All Units in (Playable Map Area)) and do stuff Pick Every Unit in (All Units in (Playable Map Area)) and do stuff Code: set UnitGroupVariable = (All Units in (Playable Map Area)) Pick Every Unit in UnitGroupVariable and do stuff Pick Every Unit in UnitGroupVariable and do stuff Pick Every Unit in UnitGroupVariable and do stuff If you can do something the same way in faster time, then do it that way. Picking every player in Players that are Playing, will always be better then picking All Players, just because there is a much better chance that there will be less players playing, then there are in all. But, sometimes the way that seems shorter, isn’t the fastest way in the long run. Code: Display Game Message to (All Players) : Welcome! Display Game Message to (All Players) : I’m bob, your game guide. Code: Display Game Message to (All Players matching ((Matching Player)’s slot status = (Is Playing))) : Welcome! Display Game Message to (All Players matching ((Matching Player)’s slot status = (Is Playing))) : I’m bob, your game guide. Streaming is better then shipping. It’s better to do things little by little then in big loads. It’s true. If you can do little by little more often, instead of big loads not so often, then there’s a better chance that the player will not notice it. Remember that this is about making it smooth for the player. Creating 10 units every 20 seconds is better then creating 20 units, every 40 seconds, and they do the same thing. Code: Every 100 Seconds Actions Create 100 Units at SomePoint Code: Every 10 Seconds Actions Create 10 Units at SomePoint Code: Every 1 Second Actions Give 5 gold to Player 1 (Red) Code: Every 10 Seconds Actions Give 50 gold to Player 1 (Red) Basics All the big and small simple things. Using Variables One important thing to learn on the quest of making your map lag less is that variables are your friend. Variables are not going to hurt you, they are here to help. If you do not know what a variable is then read my tutorial on variables. Ok, with anything in game from Triggers to Units, if you’re not using it, you might as well destroy it. By using it means you will use it in the future also. With any Trigger, if you’re not going to use to again, destroy it by putting this action at the very end Custom Script: call DestroyTrigger( GetTriggeringTrigger() ) With Units if you do not use Resurrected units and etc, edit the lasting time of the corpse in Advanced - Game Constants. Leave enough time for a Dying Animation (2 Seconds). Corpses are units too. If you do use Resurrected Units, then use conditions to check if it’s a unit that cannot be resurrected. Code: Anti Lag
Events
Unit - A unit Decays
Conditions
Or- Multiple Conditions
((Dying unit) is A structure) Equal to True
((Dying unit) is A flying unit) Equal to True
((Dying unit) is Mechanical) Equal to True
((Dying unit) is An Ancient) Equal to True
((Dying unit) is Summoned) Equal to True
Actions
Unit - Remove (Dying unit) from the game Efficent Triggering Remember the less lines there are in a trigger, the better most likely. If there’s a way to make a trigger shorter that does the same thing then do it, sometimes taking the harder way in triggering instead of the easy way has many rewards. Avoid using periodicals and triggers that run very often. If there’s a way to do the same thing without running as much then do that. Avoid Periodicals at all costs (If necessary). This means Every # Second(s) Do This. If this unnecessary for the trigger to run that many times then don't do it! When do things such as Creating mass quantities of Units, try to stream the units by making less more often instead of more less often. (TIP: With Creating Units it is effective to have all units used in your game pre placed and then removed at Map Initiation. This gets rid of some initial lag.) Fewer Doodads Sometimes using a lot of those Doodads are a bad thing. Avoid using Doodads with excessive animation such as lightning, can really lag up the game. 3rd Party Tools Using such tools as Vexorian’s Map Optimizer (the shortest variables names action) Can also help your map. Get it at ().com! Memory Leaks They’re overrated. Just kidding! What They Are The King of Lag, Tyrant of Troubles, the Memory Leaks. Memory Leaks are things that cause lag, can even put your map to the point of freezing. How do they happen? Whenever you use Groups, Points, and other Dynamically Created Stuff, they are saved in memory, so the game can access them quicker, and the game does not know on its own when to get rid of them. Just to Clarify, Groups mean any Unit Group, Player Group, etc you use. Points are Locations like Center of Region, or Position of Unit. Dynamically Created Stuff can be special effects, regions(non premade), and even units can be considered such. Targeting Them Enough of what they are, I bet your wondering how to kill them, well I'll tell you how! The way to kill them for Groups and Points is instead of using the Groups and Points in the actions; you set them to a Variable, and then use the Variable in the action. You first will need to create a variable for each. -Create a Point Variable, name it TempPoint -Create a Unit Group Variable, name it TempGroup -Create a Player group Variable, name it TempForce Then set the Group/Point in question, and use the Variable in the Action instead. Example Before Code: Pick Every Player in All Players Matching (Matching Player) is Playing = True
Loop Actions
Pick Every Unit in Units Owned by Picked Player
Loop Actions
Order Picked Unit to Move to Position of Juice Box
Order Picked Unit to Dance Code: Set TempForce = All Players Matching (Matching Player) is Playing = True
Pick Every Player in TempForce
Loop Actions
Set TempGroup = Units Owned by Picked Player
Pick Every Unit in TempGroup
Loop Actions
Set TempPoint = Postion of JuiceBox
Order Picked Unit to Move to TempPoint
Order Picked Unit to Dance Destroying Them Ok, you have those Memory Leaks locked on Target, but you’re not done yet. You still have to destroy them. You Destroy the Memory Leaks by adding some Custom Script. CustomScript: call FUNCTION(udg_VARIABLE) (((TIP: Custom Script (JASS) is Case Sensitive))) You change the VARIABLE Part to whatever is the name of the Variable you want to kill. What you change the COMMAND Part to depends on what you are destroying. Replace DESTROY with whatever command suits your variable. [code=Functions] Main Memory Leaks Destroy Functions Point- RemoveLocation Player Group- DestroyForce Unit Group- DestroyGroup Other Memory Leaks Destroy Functions [b]Region- RemoveRect Floating Text- DestroyTextTag Timer- DestroyTimer Lightning - DestroyLightning [/quote] So now the Actions above should now look like: Code: Set TempForce = All Players Matching (Matching Player) is Playing = True
Pick Every Player in TempForce
Loop Actions
Set TempGroup = Units Owned by Picked Player
Pick Every Unit in TempGroup
Loop Actions
Set TempPoint = Postion of JuiceBox
Order Picked Unit to Move to TempPoint
Order Picked Unit to Dance
Custom Script: call RemoveLocation (udg_TempPoint) Custom Script: call DestroyGroup (udg_TempGroup) Custom Script: call DestroyForce (udg_TempForce) Yay, now its memory leak free! For Dynamically Created Stuff (Anything you create in-game, Units, Regions, etc. the only way to get rid of the leak is to destroy them. Use Action- Add a Generic Expiration Timer on Unit. (((TIP: Conditions leak too, so in order to set a variable for a condition you must use If/Then/Else Action instead of the Conditions part.))) Now you know how to make your map less laggy, yay! [b]Please comment on how this tutorial can be improved, if you find anything that you find confusing, or may be confusing to others, please let me know![b][/code] |
| | |
| | #2 |
![]() Join Date: Dec 2006
Posts: 2,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: Reducing Lag The only thing you should try to fix is the code tags. Color codes don't work in code tags here. And it really makes it hard to see. |
| | |
![]() |
| Tags |
| None |
| Thread Tools | |
| Rate This Thread | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Download Footmen Frenzy XV | ShadowDestroyer | Footmen Frenzy XV | 0 | 01-21-2008 12:14 AM |
| Leak Check V2(reducing lag in you maps) | tylord | Tools | 5 | 08-22-2007 05:26 PM |
| Terms of super smash bros meele | luigi_fan64 | Super Smash Brothers | 1 | 07-19-2007 09:47 PM |
| [HERO] Skeletal Mage | Killzor2 | New Feature Requests | 2 | 05-15-2007 08:08 PM |
| [Tutorial] Reducing Lag | MrApples | World Editor Help | 5 | 04-27-2007 03:34 AM |