• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

What affect the loading speed of a map?

Status
Not open for further replies.
Level 12
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,140
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').
 
Status
Not open for further replies.
Top