HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Comprimize Function

05-09-2006, 08:02 PM#1
Thunder_Eye
Anyway to make this function not freeze the game for 4 seconds?
Collapse JASS:
function FixHero takes unit hero returns nothing
    local integer a = 1
    loop
        exitwhen a > udg_int
        call UnitAddAbility( hero, udg_AAAbilities[a] )
        call UnitRemoveAbility( hero, udg_AAAbilities[a] )
        call UnitAddAbility( hero, udg_h[a] )
        set a = a + 1
    endloop
    call UnitAddAbility( hero, 'A000' )
    call UnitAddAbility( hero, 'A00O' )
    call UnitAddAbility( hero, 'A00P' )
    call UnitAddAbility( hero, 'A00S' )
    call UnitAddAbility( hero, 'A00T' ) 
endfunction

the size of udg_int is 12 so the loop runs 12 times. And this is supposed to be greatly increased :/
05-09-2006, 08:05 PM#2
karukef
It may be that it freezes the game for 4 seconds if the abilities you are adding are loaded for the first time during that code.

If you somehow preload the abilities, that tiny function should run in a heartbeat.
05-09-2006, 08:05 PM#3
Blade.dk
I think it is because it is first time that you use the abilities, makes it lag a bit when they are added to a unit the first time.

Eventually try to add them to some dummy units at map init, that should help.

Edit: Karukef is fast.
05-09-2006, 08:06 PM#4
Thunder_Eye
So how do I preload them? I know Vex did this in some spell map, I'll see if I can find it.
EDIT: Ok I found a way, will test if it works now.
EDIT2: Ok it works, though It was a little tricky to get the preloading the right way, the first way I did it screwed my system up, but now I got it working :)