• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Lag

Status
Not open for further replies.
Hi again, this trigger works properly but lags once per game when first run with a certain if true, but everytime after that, no lag. Strange right? Well, heres the whole trigger, if you need anything else let me know.
JASS:
function Trig_Item_Upgrades_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit())!='H00B'
endfunction
function ai takes integer i,unit u returns item
    return UnitAddItemByIdSwapped(i,u)
endfunction
function ri takes unit u,integer i returns nothing
    call RemoveItem(GetItemOfTypeFromUnitBJ(u,i))
endfunction
function Trig_Item_Upgrades_Actions takes nothing returns nothing
    local unit u=GetTriggerUnit()
    local integer i=GetItemTypeId(GetManipulatedItem())
    if i=='rde1'then
        call RemoveItem(GetManipulatedItem())
        if UnitHasItemOfTypeBJ(u,'I004')==true then
            call ri(u,'I004')
            call ai('I000',u)
        elseif UnitHasItemOfTypeBJ(u,'I003')==true then
            call ri(u,'I003')
            call ai('I004',u)
        elseif UnitHasItemOfTypeBJ(u,'I002')==true then
            call ri(u,'I002')
            call ai('I003',u)
        elseif UnitHasItemOfTypeBJ(u,'I001')==true then
            call ri(u,'I001')
            call ai('I002',u)
        else
            call ai('I001',u)
        endif
    elseif i=='rat3'then
        call RemoveItem(GetManipulatedItem())
        if UnitHasItemOfTypeBJ(u,'I008')==true then
            call ri(u,'I008')
            call ai('I009',u)
        elseif UnitHasItemOfTypeBJ(u,'I007')==true then
            call ri(u,'I007')
            call ai('I008',u)
        elseif UnitHasItemOfTypeBJ(u,'I006')==true then
            call ri(u,'I006')
            call ai('I007',u)
        elseif UnitHasItemOfTypeBJ(u,'I005')==true then
            call ri(u,'I005')
            call ai('I006',u)
        else
            call ai('I005',u)
        endif
    elseif i=='rst1'then
        call RemoveItem(GetManipulatedItem())
        if UnitHasItemOfTypeBJ(u,'I00B')==true then
            call ri(u,'I00B')
            call ai('I00A',u)
        elseif UnitHasItemOfTypeBJ(u,'I00E')==true then
            call ri(u,'I00E')
            call ai('I00B',u)
        elseif UnitHasItemOfTypeBJ(u,'I00C')==true then
            call ri(u,'I00C')
            call ai('I00E',u)
        elseif UnitHasItemOfTypeBJ(u,'I00D')==true then
            call ri(u,'I00D')
            call ai('I00C',u)
        else
            call ai('I00D',u)
        endif
    elseif i=='rin1'then
        call RemoveItem(GetManipulatedItem())
        if UnitHasItemOfTypeBJ(u,'I00G')==true then
            call ri(u,'I00G')
            call ai('I00J',u)
        elseif UnitHasItemOfTypeBJ(u,'I00H')==true then
            call ri(u,'I00H')
            call ai('I00G',u)
        elseif UnitHasItemOfTypeBJ(u,'I00I')==true then
            call ri(u,'I00I')
            call ai('I00H',u)
        elseif UnitHasItemOfTypeBJ(u,'I00F')==true then
            call ri(u,'I00F')
            call ai('I00I',u)
        else
            call ai('I00F',u)
        endif
    elseif i=='lhst'then
        call UnitAddAbility(u,'A00N')
        return
    endif
endfunction
function InitTrig_Item_Upgrades takes nothing returns nothing
    set gg_trg_Item_Upgrades=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Item_Upgrades,EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddCondition(gg_trg_Item_Upgrades,Condition(function Trig_Item_Upgrades_Conditions))
    call TriggerAddAction(gg_trg_Item_Upgrades,function Trig_Item_Upgrades_Actions)
endfunction
The laggy if is:
JASS:
elseif i=='lhst'then
        call UnitAddAbility(u,'A00N')
        return
    endif
-Thanks
 
Well, warcraft saves anything he has done in some sort of cache (I don't know what excactly it does), so that it can be referenced faster. If a spell is added for the first time, there is no "cache"-reference and it laggs, dunno, I think they have to load it from a SLK-Table, not your problem :D As soon as it "was in the game once" the cache contains the spell and adding doesn't lagg.
Preloading means, that you add all these abilitys on map initalization to a unit, increasing the loading time, but preventing those "first-add"-laggs.
 
Status
Not open for further replies.
Top