• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to reduce your map's lag

Level 10
Joined
Jun 16, 2007
Messages
415
Tutorial on how to reduce lag:

This is a different way to reduce your map's lag. We all know about using programs like wc3optimizer and removing leaks, but I am going to talk about a different source of lag, which I reckon is much greater.

Events

Events.
-Basically an event is something that always checks whether something is happening. Thus the event "A unit starts the effect of a spell" will run every single time a unit casts something. "A unit is attacked" will also run every single time. Now, this is a fair bitch of processing if you ask me.

The problem with events is that unneeded events will run all the time. In most maps, 90% of the triggers and events will be not needed. They will be there even though no one needs them.

The probably biggest bitch is triggered spells. Imagine a hero map like dota with 90 heroes, and each hero has an average of 2 triggered spells. This adds up to 180 events of the type "A unit starts the effect..." which is a huge shitload. But let's face it, out of those 90 heroes only 10 will be picked. Thus only 20 of those triggers with their events are actually needed. This would be 89% less events being triggered upon spell cast. HOLY SHIT!

So, solution A is:
Remove the Garbage. Once repick is over and everyone has their heroes, remove all the garbage triggers that no one needs any more. Just use DestroyTrigger(gg_trg_Garbage) and boom, you just reduced lag.
Furthermore you can use this to remove triggers when players don't exist or leave the game. Why would I care whether player red types -arem when he isn't even in the game?

Solution B is:
Growing Triggers as I like to call them. The idea is to create triggers without events. This way the trigger takes no memory at all, since it doesn't actually trigger. The idea is to add the event to the trigger once it is needed.
Example: Once the hero Juggernaught learns Omnislash, we do: Trigger - Add Event: "Last Created Unit casts a spell" to Omnislash.
The advantage of this solution is that you can still repick classes and that the trigger only exists if the unit decides to learn the spell.
I am using this system in my new map, and I tell you, if you use this smartly, it will wipe out your lag! It will seriously fucking improve your maps performance so much, it is unbelievable.

To prove my point:
My map uses this, and it literally never lags. In a 30 minute game, not one person ever lags. (People get disconnected somtimes, but that's their shitty dial-up's fault) This is not an just boasting, it seriously never ever lags.
Furthermore, I always play 6v6, with big hero brawls, and furthermore I use a system that tracks all the damage done, another one that tracks all the hero's health and mana and displays them on a multiboard as bars and several triggered spells with complex timed triggers. This would normally result in heavy fucking lag, but thanks to this system, I can use any kind of triggers without having to worry about lag.
 
Level 9
Joined
Apr 5, 2008
Messages
529
I have good news. You don't even remove everything.
Destroying a trigger helps alot but it leaks. The conditions are still there. Destroying the trigger doesn't remove the boolexpr/condition (i'm not sure what exactly it is). You can easily do this manually by using DestroyTrigger. This should definately be added to the tutorial.
 
Level 10
Joined
Jun 16, 2007
Messages
415
Destroying the trigger doesn't remove the boolexpr/condition (i'm not sure what exactly it is). You can easily do this manually by using DestroyTrigger. This should definately be added to the tutorial.

Not destroying the trigger leaves everything there, so that is besides the point, also what do you mean by "Destroying the trigger doesn't remove the boolexpr/condition, You can easily do this manually by using DestroyTrigger."? You do realize that DestroyTrigger() does destroy the trigger, and besides that, I included that already in my tutorial.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
furthermore I doubt that the condition is even run at any point if the trigger is destroyed.

That doesn't matter, they are still saved in the memory.

That is beside the fact that your map doesn't sound heavy... at all.
And, please remove the curse words if you want this to be a tutorial.

As to how useful it is - meh. You could put all your abilities in one trigger (this will be a very long and crappy trigger if you use GUI though, since you can break it down to nice little function calls in Jass) and kaboom, no more problems.
 
Level 10
Joined
Jun 16, 2007
Messages
415
The idea is that a trigger using the event A Unit...Does X will run every time any unit does X. That is a fair high number of times it can run. You might have noted that in many maps like DotA you often get spikes or lag in big battles, where all players of the two teams are nuking and attacking each other.

My map is just like any other hero map, it has custom made heroes with 6 custom made spells and also includes a lot of fighting, because of the small arenas. I don't see why it should be any less "heavy" than any other arena or AoS.
 
Level 9
Joined
Apr 5, 2008
Messages
529
It depends. If you use solution B, then using DestroyCondition() won't be needed, furthermore I doubt that the condition is even run at any point if the trigger is destroyed.

Conditions are like leaks. They're like handles: If you nullify an effect variable but don't destroy the effect it'll cause lag (a little..). If you really want this tutorial to be useful to anyone, then you should definately mention that DestroyTrigger doesn't remove all garbage.

And i won't recommend solution B. Cleaning everything is far better.
 
Level 12
Joined
Mar 23, 2008
Messages
942
And about initialy disabled triggers?
I'm using it on my map, all triggers are initialy disabled and when they are enabled depending of the heroes on the map.

I never tried destroying them since someone said it can cause errors o.o
 
Level 9
Joined
Apr 5, 2008
Messages
529
And about initialy disabled triggers?
I'm using it on my map, all triggers are initialy disabled and when they are enabled depending of the heroes on the map.

I never tried destroying them since someone said it can cause errors o.o

The trigger still exists, so it will still use some memory, which can cause lag.
And it shouln't cause errors if you use it correctly.

Aeroblyctos said:
Does "DestroyTrigger(gg_trg_Garbage)" this reduce lag? And how much?

It does reduce lag since it removes the actions and events. Dunno how much though.
 
Level 10
Joined
Jun 16, 2007
Messages
415
Well logically an event called:
Event - A unit starts the effect of an ability

will start every time a unit uses an ability, no matter if it is the one you mean or not. but it will then check conditions and continue execution depending on true/false return value.

so, it basically gets rid of a lot of events that would run on several occasions.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Well logically an event called:
Event - A unit starts the effect of an ability

will start every time a unit uses an ability, no matter if it is the one you mean or not

Which is exactly why you should put everything that needs that event in the same trigger.
This way you have exactly the amount of triggers you need and you won't need to destroy anything and risk the problems that come with DestroyTrigger, plus, it won't fire multiple times (for each trigger that has the same event).

It is a shity thing for GUI users though, as they will have huuuuuuuuuuuuuuuuuge triggers which will lag like hell.
Shit on you, GUI users, Jass > You.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
You don't NEED to use DestroyCondition!!!!

In fact, when destroying a trigger, the triggercondition is also destroyed. The triggeraction is not, though, which is why you must use TriggerRemoveAction to clean that. You do not need to use DestroyCondition (I believe you meant TriggerRemoveCondition) or any of that.

Besides, this is lame. You really think that this will help clean your map more than any effort given by Vex's map optimizer? I highly doubt that. Also, if you're so keen on making your map's code clean and efficient, swap to Jass and you won't even have to worry about this GUI voodoo.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Or you could just use GameCache+ExecuteFunc (or if or otherwise) and a single event if you're that concerned.

EDIT: The reason you aren't understanding HINDY's point is because you are apparently confused as to what the optimizer actually does. It decreases file size, rather than reducing map lag ingame.

Either way, trigger lag is negligible.
 
Level 10
Joined
Jun 16, 2007
Messages
415
All I can say is, that I use this system in my map, and in 50 test games, with 12 players, it never lags. People do sometimes get disconnected though, but this is an issue with their internet connection and not the map^^

Also, my map is just as loaded as any other arena. If anyone has any idea on a way to actually test the increase in performance, then tell me.
 
Level 12
Joined
Mar 23, 2008
Messages
942
All I can say is, that I use this system in my map, and in 50 test games, with 12 players, it never lags. People do sometimes get disconnected though, but this is an issue with their internet connection and not the map^^

Also, my map is just as loaded as any other arena. If anyone has any idea on a way to actually test the increase in performance, then tell me.

Oh, so my map is perfect, because with 12 people it dosen't lag too!!! And I did fucking nothing!

Omgszz shiftone11!...

lame ¬¬


It is not lagging because you made this.
 
Top