Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Scripts (http://www.wc3c.net/forumdisplay.php?f=737)
-   -   AbilityPreload (http://www.wc3c.net/showthread.php?t=105279)

Toadcop 04-03-2009 06:40 PM

zomg... SLK > all the only thing what needed to be preloaded are some fx. BUT your trick will not preload them also (for example on cast effect etc.)

well 95% of "lags/preloads" solves the SLK optimization. so i personaly don't see the sense for this.

grim001 04-03-2009 07:20 PM

There is also the Preload native if you want to preload models and spell effects.

Vexorian 04-03-2009 08:36 PM

AFAIK slk only solves loading time and not that short freeze after adding an ability...

Toadcop 04-03-2009 11:06 PM

Quote:

AFAIK slk only solves loading time and not that short freeze after adding an ability...
hmmm imo it's art what frezzes and not the abilitys self. cause i have bonus mod in slk and it's not mentionable than adding abilitys etc. maybe i don't mention this cause i don't use hero spells =\

and about only loading time is 100% incorrect. well i am not interested in this all stuff etc. but someone could make a comparision...

grim001 04-03-2009 11:12 PM

The lag is usually about 1 frame when a new ability enters the game without preloading. It doesn't get in the way of gameplay, but it is a noticeable aesthetic problem.

Karawasa 04-04-2009 02:24 PM

Not sure I see the point in this system. What is wrong with loading up a pre-placed dummy unit with all the guilty (guilty of causing entering lag) abilities and then removing that dummy at the start of the game? If nothing, then...

akolyt0r 04-04-2009 03:24 PM

Quote:

Originally Posted by Karawasa
Not sure I see the point in this system. What is wrong with loading up a pre-placed dummy unit with all the guilty (guilty of causing entering lag) abilities and then removing that dummy at the start of the game? If nothing, then...

i dont think anything is wrong with that ..
typing a line of code is usually faster than:
opening object editor ..searching ur dummy unit ....search the ability ...

Karawasa 04-05-2009 09:38 AM

Don't see how using this thing would be any faster for the map maker. I can easily add the custom ability to the dummy unit in the time it takes to look up the ability id and add the line of code. Also, I fail to see how calling a bunch of code is better than simply annihilating the dummy unit in-game.

@Litany: I really fail to see where you are coming from. How is it any less modular than this system? In practice, both end up giving you a list (either a wall of code, or an object editor list of abilities) of abilities to be preloaded.

akolyt0r 04-05-2009 04:48 PM

Litany is right...
when you want to add your custom ablity to another map, with your method you have setup that dummy unit once again... +add those abilities...(can be quite many..)
When using this, you just have to add this script.

grim001 04-05-2009 06:17 PM

An important use is that systems which require this script can preload their own abilities, especially stuff generated by the Object Merger.

Rising_Dusk 04-05-2009 08:40 PM

Quote:

Originally Posted by grim001
An important use is that systems which require this script can preload their own abilities, especially stuff generated by the Object Merger.

Bingo.

You misspelled initialized and initialization in your debug messages. Whatever, though, I'll just go ahead and fix the typos myself and approve this.

Anitarf 04-06-2009 12:40 AM

What happens if I want to preload an engineering upgrade based ability?

grim001 10-17-2009 02:48 AM

Raising this thread from the dead, I have decided to do some maintenance on my old submissions.
  • Improved documentation.
  • It is no longer possible to attempt to preload an ability when the PreloadUnit doesn't exist yet. If you can call the function, it exists.
  • AbilityPreload now inlines if debug mode is off, and displays error messages if debug mode is on.
  • The preload unit rawcode is now configurable, although it should probably be left alone. Sammy! makes a good preloading unit.
  • Added AbilityRangePreload, which lets you preload an entire range of abilities in one function call.

Also, this script is way more useful now with optional requirements. You can preload stuff if it's in the map, and skip it if it's not in the map.

Archmage Owenalacaster 02-25-2010 06:56 AM

I think the error messages ought to display the rawcode of the offending value, as it is more helpful for tracking down the problem. I do it with this minor modification to your code.
Collapse JASS:
    private function Id2Char takes integer i returns string
        local string abc = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

        if i >= 97 then
            return SubString(abc,i - 97 + 36,i - 96 + 36)
        elseif i >= 65 then
            return SubString(abc,i - 65 + 10,i - 64 + 10)
        endif
        return SubString(abc,i - 48,i - 47)
    endfunction

    private function Id2String takes integer id returns string
        local integer t = id / 256
        local string r = Id2Char(id - 256 * t)
        set id = t / 256
        set r = Id2Char(t - 256 * id) + r
        set t = id / 256
        return Id2Char(t) + Id2Char(id - 256 * t) + r
    endfunction
    
function AbilityPreload takes integer abilityid returns nothing
    static if DEBUG_MODE then
        if GetUnitTypeId(PreloadUnit) == 0 then
            call BJDebugMsg("AbilityPreload error: Can't preload an ability ("+Id2String(abilityid)+") after initialization")
            return
        endif
    endif
    call UnitAddAbility(PreloadUnit, abilityid)
    static if DEBUG_MODE then
        if GetUnitAbilityLevel(PreloadUnit, abilityid) == 0 then
            call BJDebugMsg("AbilityPreload error: Attempted to preload a non-existent ability ("+Id2String(abilityid)+")")
        endif
    endif
endfunction

Anitarf 08-21-2010 09:31 PM

Module onInit methods were recently added to vJass and they get executed before struct onInits, so preloading stuff from module onInit methods currently doesn't work.


All times are GMT. The time now is 02:02 AM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services