• 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.

Lag when creating new units

Status
Not open for further replies.
Level 5
Joined
Sep 19, 2006
Messages
152
I'm working on a dueling-style map. When I choose to play any particular hero, however, that hero enters with a 1-3 second lag, most probably because of the many upgrades and latent abilities on that unit.

I've tried adding/removing the heroes during initialization, and adding/removing the various abilities to the units placed on the map during the editing process. These little tricks may or may not have helped with the delay. Are there any other tricks to secretly "introduce" heroes into a map before the game actually is ready to be played (therefore preventing the lag-delay)?

If applicable, please provide solutions in "standard" JASS.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You can place them somewhere in the map and remove them on Map Initialization. There's no reason for those units to lag again when they're picked. Anyway, provide the map as mckill2009 said.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Check your script is fault free. You can also get temporary freezes due to infinite loops. The loop will iterate until the op limit is hit, during which time the game will hang if any demanding code is run. The simplest example is a loop block with no or a stupid exit condition running demanding code like creating and dstroying a speical effect.
 
Triggers like Create 20 units at same time will lag, you can't fix that.
But you can do something like:

Each 0.01 sec create 1 unit, set i = i + 1, when i > 20 then turn off this trigger.
This work flawlessly.

Try to group all your same like triggers and add all of them into this like trigger and lag should be reduced a lot.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
-Kobas-, creating 20 units is not the problem. The problem in that situation is the displacing 20 units. The more conjested an area is, the more time the displacement algorthim requires inorder to place a unit in a free place. The result is that creating a single unit can cause performance stutters in heavilly cojested areas.

Air units are especially prone to clump spawn related stuttering due to them using force based displacement physics (like units in SC2 to some extent do). Spawning 20 air units at the same point will result in them all smoothly flowing out the area at the same time which is performance intensive. A comon example is when a huge air fleet stops attacking as they will hapilly clump together to attack but will be forced to drift appart once they enter the stop state.

You can reduce this stuttering by creating the 20 units at free points (which are not ocupied). Even spawning randomly in an area will greatly reduce this problem. I supose the most efficient would be to spawn in a grid pattern with a spacing of atleast twice the collision radius.
 
-Kobas-, creating 20 units is not the problem. The problem in that situation is the displacing 20 units. The more conjested an area is, the more time the displacement algorthim requires inorder to place a unit in a free place. The result is that creating a single unit can cause performance stutters in heavilly cojested areas.
Well you explained it well, because usually we store center of region into variable and create 20 units at that place.

Both delayed spawn or different loc will do :)

Thanks for info btw.
 
Status
Not open for further replies.
Top