HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Preload natives

10-27-2006, 02:00 PM#1
iNfraNe
I've been unable to find what they do, and how to exactly use them.

Collapse JASS:
native Preload takes string filename returns nothing 
native PreloadEnd takes real timeout returns nothing 

native PreloadStart takes nothing returns nothing 
native PreloadRefresh takes nothing returns nothing 
native PreloadEndEx takes nothing returns nothing 

native PreloadGenClear takes nothing returns nothing 
native PreloadGenStart takes nothing returns nothing 
native PreloadGenEnd takes string filename returns nothing 
native Preloader takes string filename returns nothing
What do they all do...
10-27-2006, 03:10 PM#2
aidan_124
They are used for preloading effects to prevent lag..at least the preload is. Some i imagine are used for Campaign map loading etc...dunno all of them though.
10-27-2006, 03:35 PM#3
moyack
I only know the native Preload, you put for example the file path you want to preload in order avoid the famous first use lag. Here's a good example:

Collapse JASS:
constant function Kraken_SummonEffect takes nothing returns string
    //Let you edit the summon effect model path
    return "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl" 
endfunction

constant function Kraken_SoundFile takes nothing returns string
    //Let you edit the sound effect path
    return "Sound\\Ambient\\DoodadEffects\\SargerasRoar.wav" 
endfunction

...


//***************************************************************************************************************
//* Add sound to the tentacle. Script made by iNfraNe
//*
function Kraken_AddSound takes unit u, string file returns sound
  local sound s = CreateSound(file, false, true, false, 10, 10, "")
  call SetSoundPitch(s,GetRandomReal(0.75,1.25))
  call SetSoundVolume(s,128)
  call SetSoundDistances(s,600,10000)
  call SetSoundDistanceCutoff(s,3000)
  call AttachSoundToUnit(s,u)
  call StartSound(s)
  call KillSoundWhenDone(s)
  return s
endfunction

....

function InitTrig_Kraken takes nothing returns nothing // Trigger Initialization. DO NOT MODIFY
    local trigger Kraken = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( Kraken, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( Kraken, Condition( function Kraken_Cast_Conditions ) )
    call TriggerAddAction( Kraken, function Kraken_Cast_Actions )
    call Preload(Kraken_SummonEffect())
    call Preload(Kraken_SoundFile())
    set Kraken = null
endfunction

In theory (i have to test it someday), it can be useful to preload models too, so heroes don't lag when they're summoned the first time.

With this, you can ensure that you won't any first lag in your map. About the others fucntions, I don't know what they do, you should ask to master Vex.
10-27-2006, 03:37 PM#4
iNfraNe
Ah, so the preload native works without calling some PreloadStart or something.. good to know. Still curious about all the others.
10-27-2006, 05:47 PM#5
PipeDream
I think the extension is .pld. Take a look at the scripts in the warcraft mpqs.
10-28-2006, 07:46 AM#6
blu_da_noob
I think Pipe is referring to batch preloading, where you basically have a list of all the files you want to preload inside a (apparently .pld) file and you just call Preload once on that file to load them all.
10-28-2006, 08:05 AM#7
PipeDream
Well I think you can find example uses of the preload natives in them
10-28-2006, 08:47 AM#8
AceHart
Indeed.

Melee games use them for example.
The "create starting units for night elves" has the line:
call Preloader( "scripts\\NightElfMelee.pld" )

That file looks something like this:
Collapse JASS:
function PreloadFiles takes nothing returns nothing

    call Preload( "units\\nightelf\\Wisp\\Wisp.mdx" )
    call Preload( "Textures\\star2_32.blp" )
    call Preload( "Textures\\Shockwave10.blp" )
    call Preload( "Textures\\Dust3.blp" )
    call Preload( "ReplaceableTextures\\Weather\\CloudSingleFlat.blp" )
    call Preload( "Textures\\Dust5.blp" )
    call Preload( "Textures\\GenericGlow2c.blp" )
    call Preload( "ReplaceableTextures\\CommandButtons\\BTNNightElfBUild.blp" )
    call Preload( "ReplaceableTextures\\CommandButtonsDisabled\\DISBTNNightElfBUild.blp" )
    call Preload( "ReplaceableTextures\\CommandButtons\\BTNTreeOfLife.blp" )
    // ... lots more lines...
    call PreloadEnd( 2.5 )
endfunction

There's just about anything in them, including the "cancel" button...