Well... I'm trying to preload all my abilities as they are a lot and when a hero is selected, each of them having at least 40 abilities (counting that they have spellbooks), it lags for something around 2 or 3 seconds for the 1st time.
So I decided to do a preload in map init but I get a wc3 crash if I get the loop limit to more than 50.
Heres the code, I can't get what is wrong here.
Note that the "100" its just an example, I have 300+ abilities ATM and I think of creating more later. If I put a small number like "20" it doesn't crash but tried with "80" and it crashes my wc3 at the moment of the trigger being executed. What am I doing wrong? Is this loop thing possible? If not, is there another way to preload all my abilities at once so I don't have to make a code of 300+ lines just to preload abilities?
EDIT: Trying with numbers, at "40" the trigger doesn't crash, but the game lags for 1.5 sec and then it starts normally. I'll try to use waits. Please help me in this one XD
So I decided to do a preload in map init but I get a wc3 crash if I get the loop limit to more than 50.
Heres the code, I can't get what is wrong here.
JASS:
local unit dummy = CreateUnit(Player(0), 'n00V', 0, 0, 0)
call PreloadAbilities(dummy, 100)
function PreloadAbilities takes unit u, integer limit returns nothing
local integer i = 0
local integer a = 'A000'
//call Preload("path/sfx.mdx")
//set bj_lastCreatedItem = UnitAddItemById(u, 'I000')
//set bj_lastCreatedItem = null
loop
exitwhen i > limit
call UnitAddAbility(u, a)
call UnitRemoveAbility(u, a)
set a = a + 1
set i = i + 1
endloop
call RemoveUnit(u)
endfunction
Note that the "100" its just an example, I have 300+ abilities ATM and I think of creating more later. If I put a small number like "20" it doesn't crash but tried with "80" and it crashes my wc3 at the moment of the trigger being executed. What am I doing wrong? Is this loop thing possible? If not, is there another way to preload all my abilities at once so I don't have to make a code of 300+ lines just to preload abilities?
EDIT: Trying with numbers, at "40" the trigger doesn't crash, but the game lags for 1.5 sec and then it starts normally. I'll try to use waits. Please help me in this one XD
Last edited: