jk2pach Invité
|
Posté le: 18/03/10 19:24 Sujet du message: Library: AbilityPreload |
|
|
Jass: | library AbilityPreload initializer Init
// Information:
//==============
//
// Preloading removes the noticeable delay the first time an ability is
// loaded in a game. It is suggested that you preload every ability that
// is not already on a unit that is placed on the map or created at init.
//
// How to install PreloadAbility:
//================================
//
// Just copy the script into your map, no further tweaking needed.
//
// How to use PreloadAbility:
//============================
//
// Just call PreloadAbility(abilityid) during an init function. There is no
// point calling it after init, since it will do nothing, and it would not
// be "pre"-loading anyway.
//
//===========================================================================
globals
private boolean InitDone = false
private unit PreloadUnit
endglobals
function AbilityPreload takes integer abilityid returns nothing
if not InitDone then
call BJDebugMsg("AbilityPreload error: Library has not been initialized yet")
return
elseif GetUnitTypeId(PreloadUnit) == 0 then
call BJDebugMsg("AbilityPreload error: Can't preload an ability after initialization")
return
endif
call UnitAddAbility(PreloadUnit, abilityid)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
set PreloadUnit = CreateUnit(Player(15), 'zsmc', 0., 0., 0.)
call UnitApplyTimedLife(PreloadUnit, 0, .001)
call ShowUnit(PreloadUnit, false)
call UnitAddAbility(PreloadUnit, 'Aloc')
set InitDone = true
endfunction
endlibrary
|
_________________
|
|