Preload script

Yizzy

New Member
Reaction score
20
Would anyone like to make me a trigger that preload my abilities..

I'm not that experianced with JAZZ..
My thought was to add a unit at init, add and remove all abilities and then remove the unit.. the problem is that the abilities are listed as a hex number and I only know how to make a loop with an integer..
Code:
function Trig_Preloading_Test_Actions takes nothing returns nothing
    set udg_TempPoint = GetRectCenter(GetPlayableMapRect())
    call CreateNUnitsAtLoc( 1, 'H01K', Player(PLAYER_NEUTRAL_PASSIVE), udg_TempPoint, bj_UNIT_FACING )
    set udg_TempUnit = GetLastCreatedUnit()
    set bj_forLoopAIndex = 0
    set bj_forLoopAIndexEnd = 149
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call UnitAddAbilityBJ( 'A000+bj_forLoopAIndex', udg_TempUnit )
        call UnitRemoveAbilityBJ( 'A000+bj_forLoopAIndex', udg_TempUnit )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveUnit( GetTriggerUnit() )
endfunction

//===========================================================================
function InitTrig_Preloading_Test takes nothing returns nothing
    set gg_trg_Preloading_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Preloading_Test, function Trig_Preloading_Test_Actions )
endfunction

Thx
 

Exide

I am amazingly focused right now!
Reaction score
448
Try this trigger:
Not sure if it works, didn't test it:

JASS:

function Trig_Preloading_Test_Actions takes nothing returns nothing
    local location temppoint = GetRectCenter(GetPlayableMapRect())
    local integer abilitynr = 'A000'
    local integer loopnr = 0
    local unit preloadunit

    call CreateNUnitsAtLoc( 1, 'H01K', Player(PLAYER_NEUTRAL_PASSIVE), temppoint, 270 )
    set preloadunit = GetLastCreatedUnit()

    loop
        exitwhen loopnr > 149
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = (abilitynr + loopnr)
    endloop

    call RemoveUnit( preloadunit )
    call RemoveLocation(temppoint)
    set preloadunit = null
    set temppoint = null
endfunction

//===========================================================================
function InitTrig_Preloading_Test takes nothing returns nothing
    set gg_trg_Preloading_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Preloading_Test, function Trig_Preloading_Test_Actions )
endfunction
 

Yizzy

New Member
Reaction score
20
@Darthfett: As far as I can tell, the function responds to calls by ability_id, getting that was my issue. Meybe I'm wrong, thanks anyway, +rep

@Exide: Doesn't seem to work, +rep for trying ;). I realized that the ability id isen't a hex number as the name go up to 'z', instead of 'f', which would make it have the base 36 instead of 16 as in hexadecimal.. that would however make A000 = 466560, (A000 = 40960 in hex)

i tried this function just to test:
Code:
function Trig_Preloading_UI_Actions takes nothing returns nothing
    set udg_TempInt = 'A000'
    call DisplayTextToForce( GetPlayersAll(), I2S(udg_TempInt) )
    set udg_TempInt = 466560
    call DisplayTextToForce( GetPlayersAll(), I2S(udg_TempInt) )
endfunction

//===========================================================================
function InitTrig_Preloading_UI takes nothing returns nothing
    set gg_trg_Preloading_UI = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Preloading_UI, function Trig_Preloading_UI_Actions )
endfunction
my game says that A000 >> 466560. :banghead:

As I have 332 custom abilities (maybe not all neded to be preloaded, but atleast ~100), I would greatly appreciate if it is possible to make a loop in some way..


Donno if it's the best idea, for my search in this forum the only solution seems to be: create a unit and load each ability by hand..

Is that easier than what I'm proposing? Is that what experianced mappers do when the have a lot of abilities to preload, or are they just smart enough to use a smaller number of abilities..?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Ahh, you're having trouble getting the ability ID's ?

Go into the object editor, find your ability and press "Ctrl + D"

The first four characters are the ability id.

If it's a custom object, it will have 4 more characters after it, which is the ability id the custom ability is based off of.
 

Yizzy

New Member
Reaction score
20
@Darthfett:I'm too lazy to do that with 332 abilties.. :p

Hoped that you knew a better way..

Thanks anyway, I guess I have to do that..
 

Exide

I am amazingly focused right now!
Reaction score
448

Yizzy

New Member
Reaction score
20
@AceHart: They aren't on any units, I've based it off Baka_ranger's custom hero system. Do you know how he does it?

Still don't get why 'A000' would be 1093677104 ..?

BTW can I change the typo in the title of this topic..? I tried but it didn't work..
EDIT: Hmm, now it seem fixed.. :S
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Hm... come to think of it, are you really sure you actually need this?
300+ abilities will take some time to load.
And it does not really make sense to preload them all if only some 20+ are used every game.
 

Yizzy

New Member
Reaction score
20
Good point, though it will cause lagg if players repick.. guess I'm gonna have to live with that.. Thx a lot anyway.. ;)
 

SFilip

Gone but not forgotten
Reaction score
634
> Still don't get why 'A000' would be 1093677104
It's base 256.
Think: ('A'*256^3)+('0'*256^2)+('0'*256^1)+('0'*256^0) where 'A' and '0' are corresponding ASCII values (65 and 48 respectively).

Anyway, I believe what AceHart actually suggested is that you preplace all your heroes in some region and remove them when the game starts (0.01 elapsed game time event or so). That's the same as preloading and therefore it would increase loading time, as already said.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Well, "Custom Hero", along with that link, suggests that the Heroes do not have any abilities to start with.
As such, putting them on the map only helps with the models, not the spells.
 

Cohadar

master of fugue
Reaction score
209
> Still don't get why 'A000' would be 1093677104
It's base 256.
Think: ('A'*256^3)+('0'*256^2)+('0'*256^1)+('0'*256^0) where 'A' and '0' are corresponding ASCII values (65 and 48 respectively).

I confirm this as true, furthermore you do not know to need the ascii table to use this since jass supports using one digit ascii numbers:
JASS:

    local integer i = 0

    // one ascii digit (8-bit byte)
    set i = 'A' // OK
    set i = '0' // OK
    set i = 'x' // OK

    // 4 ascii digits (32-bit integer)
    set i = 'Armf' // OK
    set i = 'R001' // OK
    set i = 'Itom' // OK

    // anything else
    set i = 'Ar' // ERROR
    set i = 'R00' // ERROR
 

Yizzy

New Member
Reaction score
20
Ok, after modifying Exide's function, in the 2nd post, I came up with this:
Code:
function Trig_Preloading_Test_Actions takes nothing returns nothing
    local integer abilitynr = 'A000'
    local integer loopnr = 0
    local unit preloadunit

    set preloadunit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'H01K', -8000, -6200, 270)

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A010'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A020'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A030'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A040'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A050'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A060'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A070'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A080'

    loop
        exitwhen loopnr > 36
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    set loopnr = 0
    set abilitynr = 'A090'

    loop
        exitwhen loopnr > 5
        call UnitAddAbility( preloadunit, abilitynr )
        call UnitRemoveAbility( preloadunit, abilitynr )
        set loopnr = loopnr + 1
        set abilitynr = abilitynr + 1
    endloop

    call RemoveUnit( preloadunit )
    set preloadunit = null
endfunction

//===========================================================================
function InitTrig_Preloading_Test takes nothing returns nothing
    set gg_trg_Preloading_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Preloading_Test, function Trig_Preloading_Test_Actions )
endfunction

Which cause a several seconds lagg on startup but seem to work.. is this a very bad way to solve this problem?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top