What affect the loading speed of a map?

Level 10
Joined
Aug 12, 2008
Messages
349
I've been working on a map and I found out that my map load quite slow although the file size is small (400kb+).
Does the loading speed depends on the triggers that I used? Or it depends on how many triggers that I used?

Besides that, I used the below trigger in setup like map initialization and Multiboard initialization. Does the below trigger actually helps in reducing the lag during the game?
  • Custom script: call DestroyTrigger( GetTriggeringTrigger() )
 
Well, let's say I want a trigger created specifically for the target unit of a spell. Instead of bloating a global trigger with multiple events, I can use a local one.
JASS:
function A takes nothing returns nothing
    local unit u = GetTriggerUnit()
    //Actions Here
    call DestroyTrigger (GetTriggeringTrigger())
    set u = null
endfunction

function Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local trigger tri = CreateTrigger()
    call TriggerRegisterUnitEvent (tri, u, EVENT_UNIT_DAMAGED)
    call TriggerAddAction (tri, function A)
    set u = null
    set tri = null
endfunction
This example creates a local trigger for the target unit, with the event of "Unit takes damage". Once the unit takes damage, the trigger is not needed (if we wanted the unit to be damaged only once and trigger the effects), so we destroy it.

As for the variables, if you declare loads of them under the "Map Initialization" events, it will become slow indeed. Distribute them with the event of "Elapsed time game is 0.00 seconds".
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,141
Since there was ton of threads like this, I'll just recommend reading that - it will help you reducing/optimizing the map (enter both 'this' links).

Loading time can be lowered by replacing event 'Map initialization' with Time - Elapsed time is 1.00 (it doesn't have to be exactly 1.00 second, you can enter any other value here too, but let it be small enought so triggers will be loaded 'at the begining of the game').
 
Top