How to fix this?

Status
Not open for further replies.
Level 11
Joined
Jan 23, 2015
Messages
788
I have a custom spell that creates a unit group, picks it's units and damages them. The problem is, when I use the spell, the game freezes for over 0.2 sec at the time where it's supposed to damage the units. However this occurs only the first time I use the spell, the second time, it works properly.

So, everything else connected with the spell works perfectly, the only problem is this freezing...

So, why does this occur, and how do I fix it? This happens with most of my spells that pick up units..
I don't have leaks btw..
 
Level 15
Joined
Aug 14, 2007
Messages
936
For your information, to do preloading, you can place units from the editor onto the map itself, use trigger to hide them from the game, pause them, make them invulnerable. I suggest you remove them only when you are certain that certain things will never be used, for example when every player already picked their hero but that's the next level. What I am trying to say is that you don't need to remove them, it might make warcraft remove the abilities too (Needs to be checked).
 
Level 12
Joined
May 22, 2015
Messages
1,051
Wait wait wait wait wait, what does preload actually do?

Basically, abilities and unit data don't get loaded until they are put into the game. This means that abilities and unit data have to load the moment you spawn them (create a unit, create a unit with an ability, add an ability to a unit), but not afterwards. This is most likely a performance helping function implemented by Blizzard.

If something is lagging only the first time you do something, it is very possible for it to be due to this loading happening (could also be an obscure bug in your code, though) - this is likely to happen if your ability spawns units or adds abilities to units. A way to avoid this is to "preload" the unit / ability data. All you have to do is spawn the units and abilities that you know will cause lag when created by a spell or during gameplay at the start of your map (place them in the editor and use a trigger to remove them, or just have a trigger do both parts at some other specific time). By loading those units and abilities at the start of your map / during map load, you will not see the lag spike while playing. This is preferred in most cases.
 
Status
Not open for further replies.
Top