Preloading

Curo

Why am I still playing this game...?
Reaction score
109
I made a previous thread with a question. I have now found the answer to that question, and am posting a new question (don't -rep me again, AceHart)

I have recently been experimenting with preloading; the concept of creating units and [units with certain] abilities at the start of the map to avoid small lag spikes in game when said units and abilities would first be introduced. From what I have found, there are 2 ways to preload things, both involving creating then destroying the units in question. The first way uses the map initialization event which causes the map loading time to increase significantly. The second option is to preload during an opening cinematic to "hide" the lag spike.

Now to my problem. I used the second option, preloading during a cinematic. What happens though is that I get a significant lag spike turning what should be a 4 second cinematic into a 20 second cinematic. Now what is the point of using this cinematic method if the lag spike will still be visible? Beyond that, I am curious as to why my preload trigger warrants such a massive spike. It creates 22 heroes (15 of which have 5 abilities each), then does not remove them. I see no reason for creating dummies with the abilities, then removing the dummies, just to add the heroes. Why not save a step and add the heroes directly? My point is, why is this causing such a huge lag spike, and further, how can I prevent this?

The trigger follows:
Code:
preload
    Events
        Map initialization
    Conditions
    Actions
        Set TempPoint[1] = (Center of start architect <gen>)
        Unit - Create 1 Architect for Neutral Passive at TempPoint[1] facing 70.00 degrees
        Set hero_architect = (Last created unit)
        Set TempPoint[2] = (Center of start arsonist <gen>)
        Unit - Create 1 Arsonist for Neutral Passive at TempPoint[2] facing 270.00 degrees
        Set hero_arsonist = (Last created unit)
        Set TempPoint[3] = (Center of start barge <gen>)
        Unit - Create 1 Living Machine for Neutral Passive at TempPoint[3] facing 180.00 degrees
        Set hero_barge = (Last created unit)
        Set TempPoint[4] = (Center of start carrier <gen>)
        Unit - Create 1 Protoss Battleship for Neutral Passive at TempPoint[4] facing 270.00 degrees
        Set hero_carrier = (Last created unit)
        Set TempPoint[5] = (Center of start centaur <gen>)
        Unit - Create 1 Centaur Battlelord for Neutral Passive at TempPoint[5] facing 270.00 degrees
        Set hero_centaur = (Last created unit)
        Set TempPoint[6] = (Center of start deadly <gen>)
        Unit - Create 1 Deadly Assassin for Neutral Passive at TempPoint[6] facing 0.00 degrees
        Set hero_deadly = (Last created unit)
        Set TempPoint[7] = (Center of start dragon <gen>)
        Unit - Create 1 Vengeful Dragon for Neutral Passive at TempPoint[7] facing 270.00 degrees
        Set hero_dragon = (Last created unit)
        Set TempPoint[8] = (Center of start druid <gen>)
        Unit - Create 1 Guardian Druid for Neutral Passive at TempPoint[8] facing 270.00 degrees
        Set hero_druid = (Last created unit)
        Set TempPoint[9] = (Center of start ghost <gen>)
        Unit - Create 1 Ghost Lord for Neutral Passive at TempPoint[9] facing 270.00 degrees
        Set hero_ghost = (Last created unit)
        Set TempPoint[10] = (Center of start ghoul <gen>)
        Unit - Create 1 Frenzied Ghoul for Neutral Passive at TempPoint[10] facing 135.00 degrees
        Set hero_ghoul = (Last created unit)
        Set TempPoint[11] = (Center of start master <gen>)
        Unit - Create 1 Master of the Arts for Neutral Passive at TempPoint[11] facing 0.00 degrees
        Set hero_master = (Last created unit)
        Set TempPoint[12] = (Center of start mind <gen>)
        Unit - Create 1 The Collective Mind for Neutral Passive at TempPoint[12] facing 45.00 degrees
        Set hero_mind = (Last created unit)
        Set TempPoint[13] = (Center of start phase <gen>)
        Unit - Create 1 Phase Shifter for Neutral Passive at TempPoint[13] facing 0.00 degrees
        Set hero_phase = (Last created unit)
        Set TempPoint[14] = (Center of start pitlord <gen>)
        Unit - Create 1 Pit Lord Torturist for Neutral Passive at TempPoint[14] facing 225.00 degrees
        Set hero_pitlord = (Last created unit)
        Set TempPoint[15] = (Center of start rage <gen>)
        Unit - Create 1 Embodiment of Rage for Neutral Passive at TempPoint[15] facing 315.00 degrees
        Set hero_rage = (Last created unit)
        Set TempPoint[16] = (Center of start ranger <gen>)
        Unit - Create 1 Divine Ranger for Neutral Passive at TempPoint[16] facing 90.00 degrees
        Set hero_ranger = (Last created unit)
        Set TempPoint[17] = (Center of start renegade <gen>)
        Unit - Create 1 Renegade for Neutral Passive at TempPoint[17] facing 180.00 degrees
        Set hero_renegade = (Last created unit)
        Set TempPoint[18] = (Center of start stealth <gen>)
        Unit - Create 1 Stealth Assassin for Neutral Passive at TempPoint[18] facing 0.00 degrees
        Set hero_stealth = (Last created unit)
        Set TempPoint[19] = (Center of start trapper <gen>)
        Unit - Create 1 Trapper for Neutral Passive at TempPoint[19] facing 0.00 degrees
        Set hero_trapper = (Last created unit)
        Set TempPoint[20] = (Center of start virus <gen>)
        Unit - Create 1 Rouge Virus for Neutral Passive at TempPoint[20] facing 0.00 degrees
        Set hero_virus = (Last created unit)
        Set TempPoint[21] = (Center of start water <gen>)
        Unit - Create 1 Water Diety for Neutral Passive at TempPoint[21] facing 180.00 degrees
        Set hero_water = (Last created unit)
        Set TempPoint[22] = (Center of start wraith <gen>)
        Unit - Create 1 Shadow Wraith for Neutral Passive at TempPoint[22] facing 180.00 degrees
        Set hero_wraith = (Last created unit)
        For each (Integer A) from 1 to 22, do (Custom script:   call RemoveLocation (udg_TempPoint[bj_forLoopAIndex]))
 
Reaction score
91
You can't prevent Heroes' preloading lag - it's caused because all trigger data involved with them has to be loaded. Another option could be to cut it into parts - just preload the Heroes one by one with 0.5-1 second interval. However, I think it would be a lot more worse than instant unit creation since the players with older computers could be lagging more than usual. You might want to try experimenting with that part...
 

Curo

Why am I still playing this game...?
Reaction score
109
You can't prevent Heroes' preloading lag - it's caused because all trigger data involved with them has to be loaded. Another option could be to cut it into parts - just preload the Heroes one by one with 0.5-1 second interval. However, I think it would be a lot more worse than instant unit creation since the players with older computers could be lagging more than usual. You might want to try experimenting with that part...

I considered that. Perhaps using 0.1 second intervals would be enough? I'm planning on making 50+ heroes, so the smaller the interval, the better. I believe the reason for such a long spike is that the program wants to do more than it can at an instant, so it extends that instant. If the data the program is processing at an instant is rather small, as you suggested, I believe the intervals between the instants should not matter, as long as they are separate instances.

My options as of now are the above, or an additional 15 second loading time if I move the event to map initialization. Either that or I could create a story that displays during the cinematic for people to read during the 15 seconds. Although people that play often would find this too annoying, and would probably rather cope with a longer loading time, not knowing that I created the cinematic to decrease loading time in the first place.

Any other suggestions?
 
Reaction score
91
I've heard of other methods to prevent such spikes - one of them, if "rumours" can be believed, is that DotA disables its triggers on Map Initialization and when some Heroes are created, specific triggers are enabled again one by one from time to time. I have no idea if this works and unfortunatelly I can't test it - my PC is too fast. >_>
 

Curo

Why am I still playing this game...?
Reaction score
109
I've heard of other methods to prevent such spikes - one of them, if "rumours" can be believed, is that DotA disables its triggers on Map Initialization and when some Heroes are created, specific triggers are enabled again one by one from time to time. I have no idea if this works and unfortunatelly I can't test it - my PC is too fast. >_>

That might not be a terrible idea. I have created a 5 second delay between when the hero gets picked and when it is thrown into the arena, so this would be the perfect time to enable the corresponding triggers. I didn't think about this because I wasn't aware that the triggers cause the lag. I thought is was only the units and abilities.

And I'm sorry that your PC is too fast; it must be so hard on you :p
 

Sooda

Diversity enchants
Reaction score
318
To talk in GUI, DotA has disabled all triggers with 'Run This Trigger At Map Initialization' check box, only core triggers which setup game and hero selection run on map initialization. All other triggers will be created if specific hero is selected (They got trigger which enables needed triggers.).
To avoid lag, preload things on map loading. As suggested use trigger waits between hero creation. Then there is 'Game -Preload' thingies -- Blizzard uses them to preload melee maps (that is why you never get spikes when building or casting abilities in melee games). Reign of Chaos scenario map WarChasers uses preloading actions.
 

Curo

Why am I still playing this game...?
Reaction score
109
*sigh* Thanks Sooda, too bad I didn't read your post until after I turned off all my triggers and made actions to turn them back on when the hero is picked....

I'll just use make all the heroes at different times.

Edit: As I figured, if the game wants to take 15 seconds, it will take 15 seconds. In short, it didn't work :(

I didn't want my loading time to go from 25 seconds to 40 seconds. Sad thing is I still plan on adding another 30 heroes. Map init, here I come....
 

Sooda

Diversity enchants
Reaction score
318
Hero Selection where you see hero model may be cool, but it needs better computer to handle. I remember Angel Arena having such hero selection. Your other triggers which run after map start may cause lag with hero loading adding its own slowdown.
 

Curo

Why am I still playing this game...?
Reaction score
109
Hero Selection where you see hero model may be cool, but it needs better computer to handle. I remember Angel Arena having such hero selection. Your other triggers which run after map start may cause lag with hero loading adding its own slowdown.

I agree, but it is more than just cool for me. Taking DotA as an example, all you have to go by is the icons for ~90 heroes, and for a new player (like myself), it is almost impossible to find a hero that you saw someone use and would like to try yourself. I prefer the model hero approach for this reason, and you also feel more involved when choosing your hero. That and I've been playing Arena Nexus for years, and it would feel weird to change the method of hero selection in my own map to something different.
 

PrisonLove

Hard Realist
Reaction score
78
With preloading units there is an easy solution. Place on the map in the editor, and have them removed during your cinematic. Then there will be no lag spike, as the units are already loaded in map and they're just being removed. I did this in my map and it worked wonderfully.

You can download it at: Space Orcs!

if you'd like to check it out.

[/end map plug]
 

Curo

Why am I still playing this game...?
Reaction score
109
Haha, Prison. Yeah, I'm pretty sure what you have done is the same as adding them at map initialization, except your method makes the file size larger. Either way, it increases the loading time. Instead of a 15 second lag spike, I have to wait an extra 15 seconds for it to load. I think I'll just have to deal with it.

Another idea I have though is to make model heroes like I currently have, but not to give them the abilities..."fake" model heroes if you will. This shouldn't cause a spike. Then, I can just add the real hero if someone selects a model. What do you guys think?
 

istar

New Member
Reaction score
31
Another idea I have though is to make model heroes like I currently have, but not to give them the abilities..."fake" model heroes if you will. This shouldn't cause a spike. Then, I can just add the real hero if someone selects a model. What do you guys think?
so what exactly did you preloaded for this?
you didnt avoid the hero load lag
and to preload abilities, its a troublesome way?
 

vypur85

Hibernate
Reaction score
803
> its a troublesome way?

More like double the job thing... :p Bad idea.


Well, just only preload those abilities when the specific hero is chosen. You have 50+ heroes, right, but I don't think all will be used? No point of preloading 50 useless data when only around 8 are used throughout the map. And it depends on how you select the hero. Here's an example:

Code:
Event
 A unit sells a unit
Condition
 Unit-type of (Sold unit) Equal to Someone
Actions
 Dummy Unit creation and removal.... preloading stuff...

The above preload is only useful to preload dummy abilitites used in triggering your hero abilities. A little lag while choosing hero won't hurt.
 

Curo

Why am I still playing this game...?
Reaction score
109
@istar: using the fake hero models would not create such a huge spike because they don't have the triggered abilities that seem to be causing the spike. I would only have to actually load the real heroes if/when they are chosen. So I avoid any lag associated with heroes that are never chosen.

@vypur: I'm not using taverns, I'm using the model hero selection system. As I said, the only way to just deal with the chosen heroes using this system would be to add fake heroes.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top