Stack

skarkai

New Member
Reaction score
0
Does anyone knows the trigger for item stacking and its a 100% working condition? :confused:
+reps for help :D
 

crazyfanatic

New Member
Reaction score
20
Currently i cant post an exact trigger (working from a phone lol), but I can give you the instructions:
1. Unit aquires an item. Set a variable for Item to the type and an Integer to the charge count.
2. Remove item being manipulated.
3. Wait 0.01 second. This action is important, without it Wc will crash.
4. If triggering unit has item of type X, set charges of item, carried by triggering unit to crarges + the iteger, containing the charges of the aquired item. If not, just give an item of the same type and set its charges to the integer.
5. Reset your variables.

This is the system i have found, it works fine with me.
 

FoxWizzy

New Member
Reaction score
3
i use this on (stack any item that have charges)
Code:
function Trig_Combine_Items_Conditions takes nothing returns boolean
    if ( not ( GetItemCharges(GetManipulatedItem()) > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Combine_Items_Actions takes nothing returns nothing
    local integer ITEMCOUNT
    local integer ITEMLOOP
    local integer CHARGES
    local integer MAXIMUM
    local item NEWITEM
    local unit OURUNIT

    set MAXIMUM = 15
    set ITEMCOUNT = 0
    set ITEMLOOP = 0
    set CHARGES = 0
    set NEWITEM = GetManipulatedItem()
    set OURUNIT = GetManipulatingUnit()
    
    loop
        exitwhen ITEMLOOP > 6
        if ((GetItemTypeId(NEWITEM)) == (GetItemTypeId(UnitItemInSlotBJ(OURUNIT, ITEMLOOP)))) then
            if ((GetItemCharges(UnitItemInSlotBJ(OURUNIT, ITEMLOOP)) + GetItemCharges(NEWITEM)) <= MAXIMUM) then
                if not ( (UnitItemInSlotBJ(OURUNIT, ITEMLOOP)) == (NEWITEM)) then                
                    set CHARGES = (GetItemCharges(UnitItemInSlotBJ(OURUNIT, ITEMLOOP))) + GetItemCharges(NEWITEM)
                    call SetItemCharges( UnitItemInSlotBJ(OURUNIT, ITEMLOOP), CHARGES )
                    call RemoveItem( NEWITEM )
                    set ITEMLOOP=7
                endif
            endif
        endif
        if ( ITEMLOOP < 7 ) then
            set ITEMLOOP = ITEMLOOP + 1
        endif
    endloop
endfunction

//===========================================================================
function InitTrig_Combine_Items takes nothing returns nothing
    set gg_trg_Combine_Items = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Combine_Items, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddCondition( gg_trg_Combine_Items, Condition( function Trig_Combine_Items_Conditions ) )
    call TriggerAddAction( gg_trg_Combine_Items, function Trig_Combine_Items_Actions )
endfunction
You can replace the 15 in set MAXIMUM = 15 to the max stack you need
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top