Stacking system

Extremedesyr

New Member
Reaction score
6
hey, for as far as I know i've never had a succesful stacking system, now I ended up with

JASS:
function Trig_ChargesAdd_Actions takes nothing returns nothing
    local integer i=-1
    local unit u=GetTriggerUnit()
    local item it=GetManipulatedItem()
    loop
    set i=i+1
    if GetItemType(it) == ITEM_TYPE_CHARGED and GetItemTypeId(UnitItemInSlot(u, i)) == GetItemTypeId(it) and UnitItemInSlot(u, i) != it then
        call SetItemCharges( UnitItemInSlot(u, i), ( GetItemCharges(UnitItemInSlot(u, i)) + GetItemCharges(it) ) )
        call RemoveItem( it )
    endif
    exitwhen i==5
    endloop
    set u=null
    set it=null
endfunction

//===========================================================================
function InitTrig_ChargesAdd takes nothing returns nothing
    set gg_trg_ChargesAdd = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ChargesAdd, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_ChargesAdd, function Trig_ChargesAdd_Actions )
endfunction


but for some reason this doesnt work either, i've allso tried 3 diffrent GUI triggers but none of em worked. :/
 
Reaction score
341
Hopefully you can use vJASS.

JASS:
scope stack initializer InitTrig

    private function Actions takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local item itm = GetManipulatedItem()
        local item i2
        local integer id2
        local integer i = 0
        local integer id = GetItemTypeId(itm)
        if GetItemType(itm) == ITEM_TYPE_CHARGED then
            loop
                exitwhen i > 5
                set i2 = UnitItemInSlot(u, i)
                set id2 = GetItemTypeId(i2)
                if id2 == id and itm != i2 then
                    call SetItemCharges(i2, GetItemCharges(i2) + 1)
                    call RemoveItem(itm)
                endif
                set i = i + 1
            endloop
        endif
        set u = null
        set itm = null
        set i2 = null
        return false
    endfunction

    //===========================================================================
    private function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_PICKUP_ITEM )
        call TriggerAddCondition( t, Condition( function Actions ) )
    endfunction

endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top