HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Optimizing unit spawn lag

09-12-2003, 02:45 PM#1
Zwan
I am nearing the home stretch with my map and I'm trying to optimize my triggers as much as possible regarding lag.

One area that could use work is my unit spawns. I have been reading/searching around the last few nights and reading up on lag etc..

That said, I am currently running 3 periodic event triggers
(only 3 periodics in the map) to control my spawns, which are regulating a total of 16 spawns.

1st trig- every 45 secs, 8 spawns, 20 units total
2nd trig-every 48 secs, 4 spawns, 8 units total
3rd trig- every 60 secs, 4 spawns, 24 units total

I am seeing a slight pause as units spawn, and this is at each point pretty much. It seems to be the same no matter which one is actually spawning. It also seems to be noticeable primarily at the begining of the game(sometimes I don't even notice it) none the less it it still there and I'd like to reduce it as much as possible as I tend to fixate on things like this until they are perfect.

Anyone have any advice on reducing this type of lag? Either by a more efficient spawning method or trigger size, times etc..

Examples/links/advice welcome
09-12-2003, 03:15 PM#2
cideh
Hmm. You could remove the second periodic trigger(every 48 sec), by adding this:

Set RealVariable = ( RealVariable + 1.00 ) (Default value = 0.00)
Wait ( 3.00 * RealVariable ) seconds
Second-Periodic-Trigger-Actions

I don't know if this would increase performance or not, but it's a way of reducing # of periodic events.

EDIT: I don't think it will work if you have other wait-statements in the trigger.
09-12-2003, 03:16 PM#3
Vexorian
Instead of Unit create 8 units in point
Use
Unit create 1 units in point
wait 0.01 seconds
Unit create 1 units in point
wait 0.01 seconds
Unit create 1 units in point
wait 0.01 seconds
Unit create 1 units in point
wait 0.01 seconds
Unit create 1 units in point
wait 0.01 seconds
Unit create 1 units in point
wait 0.01 seconds
Unit create 1 units in point
wait 0.01 seconds
Unit create 1 units in point
09-12-2003, 03:44 PM#4
Ant
I Think (but not know)
Most of the lag is caused when a unit is created.
Creating Eight units intensifies the lag, but not by much.
Creating 8 units over a period of 0.1 seconds probably won't help. Maybe you can do the following (but you're already at your home stretch, so it probably won't be convenient).

At the start of the map, create a more units at storage area.
Then MOVE those units immediately to spawns.

I have no idea if moving units cause much lag, so I don't know if this works.

Also, as long as the lag isn't enough to make someone pop up that "drop player" screen, it's perfectly fine. Don't spend 3 precious editing days trying to reduce it.
09-12-2003, 03:53 PM#5
Vexorian
However I don't know what is causing the lag, I have triggers that crete 10-15 units in a map and doesn't lag .
09-12-2003, 04:03 PM#6
Ant
I'm guessing much of the lag is not just because of the units created. Maybe there are just too many units already on the map, and creating more units creates more lag.
Also, playing in long periods in a map with lots of units lags up computers. Start DOTC and it's running smoothly. Then wait one hour and you feeel the laaaggg.

I got a nice computer that lags so much I can tell everytime the enemy hero comes out for the first time cause it lags for a few seconds.
09-12-2003, 06:30 PM#7
Zwan
Well its not so much of a build up of lag per say, just that pause when they spawn.

The pause length is the same whether its popping out 24 units, or just 8, which is why I'm unsure of how to reduce it. It seems to pause from execution and not # of units on screen. Could it be the attack move-to Orders causing lag? I didn't think only 8 and 4 would cause lag but maybe it is. May have just answered my own question.



@cideh no other wait actions so I will probably add this, thanks for the suggestion
09-12-2003, 07:04 PM#8
Guest
The direct reason for the lag is the creation of the units... When each unit is created it has to put it into memory... So when you have 100 units created at same time it has to load them all into memory then display them... To prove this make a test map with the unit creation trigger to create the 100 units after 10 seconds of game time... Then have another one create 100 with the .01 waits after 20 seconds of game time... The second one won't lag or lag very little compared.
09-12-2003, 09:24 PM#9
Zwan
That seems much more reasonable, although I did go through all the spawn triggers and reduced the actions/orders by quite a bit and I am now down to nearly no delay at all.

I'll try the .01 waits. If it does increase performance I should be looking at 0 delay. Thanks for the help all.
09-13-2003, 05:50 AM#10
Grater
Is each spawn a different type of unit? (ie like in tower defense)?

If so, you might be able to improve lag by preplacing 1 of each type into the map to force WC3 to preload the unit data. I imagine you could remove all the units with a trigger just after the map starts.
09-13-2003, 11:02 AM#11
Zoizite
Quote:
Is each spawn a different type of unit? (ie like in tower defense)?

If so, you might be able to improve lag by preplacing 1 of each type into the map to force WC3 to preload the unit data. I imagine you could remove all the units with a trigger just after the map starts.

Wow, I just did that, and it completely eliminated the split second pause I got from the first wave of spawns and spawning the initial creeps. I placed one of every type of unit that spawns in my map in a region and gave them all to neutral passive. At .05 seconds I remove them all. Worked like a charm =)
09-13-2003, 01:24 PM#12
Zwan
Yes, wow. This worked exceptionally well. I took it a bit further and I believe I now have achieved seemless spawns with no pause through out the game.

Thanks you guys.
09-13-2003, 01:30 PM#13
Grater
Great :) Pleased I could help, always gives the warm fuzzy feeling. I didn't know for sure if it would work, but I'd heard about doing a simialler thing to prevent lag when players chose heros with custom abilities like in footman war games.
09-15-2003, 01:44 PM#14
Vexorian
Quote:
Originally posted by Zwan
Yes, wow. This worked exceptionally well. I took it a bit further and I believe I now have achieved seemless spawns with no pause through out the game.

Thanks you guys.


I am wondering, which one worked? the wait 0.01 seconds or preplacing the units? perhaps both?
09-15-2003, 03:03 PM#15
Zwan
Both. I shoulda been more specific. with the .01 delay it smoothes out the progessive spawning throughout the game.

And the preload trick resolved all delays during the begining of the game as well as one area in which I had one of certain unit types spawning and hero selection.

Although I did have to do a lot re-writing, it was worth it. Or.. well a lot of clicking CnPing the waits that is.