package PreloadHandler /* * * * * * * * * PreloadHandler * * * * * * * * * * * * * * The PreloadHandler helps you to preload resources * * at mapstart, to avoid first-laggs. * * Use the corresponding function to preload the data * * you want. * * * */ boolean autoFinish = false /** use this function to preload an ability */ public function preloadAbility( int abilid ) UnitAddAbility(dum, abilid) if dum == null error("PreloadAbility: do not load abilities after map init when autoFinish = true") else if GetUnitAbilityLevel(dum, abilid) == 0 printWarning("PreloadAbility: Ability "+idInteger2IdString(abilid)+" does not exist.") public function preloadUnit( int unitId ) if dumg == null error("PreloadUnit: Group dumg does not exist") return GroupAddUnit(dumg, CreateUnit(DUMMY_PLAYER, unitId, 0, 0, 0)) group dumg unit dum public function finishPreload() RemoveUnit(dum) for u in dumg u.remove() dumg.destr() if GetExpiredTimer() != null DestroyTimer(GetExpiredTimer()) init dum = CreateUnit( Player(15), DUMMY_UNIT_ID, 0., 0., 0. ) if dum == null error("PreloadHandler : DUMMY_UNITID ("+idInteger2IdString(DUMMY_UNIT_ID)+") not added correctly to the map.") if autoFinish TimerStart( CreateTimer(), 0.0, false, function finishPreload )