Item Stackable

bOb666777

Stand against the ugly world domination face!
Reaction score
117
What do you mean stackable?
It's effect stacks
Or when you pick it up the number of charges it has adds to the number of charge of a same item you already own?
 

ryerye1996

Cool Member
Reaction score
5
What do you mean stackable?
It's effect stacks
Or when you pick it up the number of charges it has adds to the number of charge of a same item you already own?

I mean when you pick it up the number of charges adds to the number of charges of the same item i already own
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
Alright.
Trigger:
  • Add Charges
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-class of (Item being manipulated)) Equal to Charged
          • (Charges remaining in (Item being manipulated)) Greater than 0
        • Then - Actions
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has an item of type (Item-type of (Item being manipulated))) Equal to True
            • Then - Actions
              • Item - Set charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))) + (Charges remaining in (Item being manipulated)))
              • Item - Remove (Item being manipulated)
              • Else - Actions
                • Trigger - Turn off (This trigger)
                • Hero - Give (Item being manipulated) to (Hero manipulating item)
                • Trigger - Turn on (This trigger)
            • Else - Actions
        • Else - Actions
 

ryerye1996

Cool Member
Reaction score
5
I get up to this part but when i get ther it doesnt show the + symbol to continue on

Item - Set charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))))
 

brc

New Member
Reaction score
1
Anyone know how to set a maximum amount of charges though? Like after your item has 10 charges, you cant add anymore.
 

perkeyone

something clever
Reaction score
71
ive seen item charges at 999 before
im not sure if you should go any higher than that as it may cause bugs

oops this was not relevant to your question

to limit max charges just make a condition
integer comparison
item charges less than 10
 

ryerye1996

Cool Member
Reaction score
5
I also cant find this in the conditions. what comparison is it???


(Charges remaining in (Item being manipulated)) Greater than 0
 

dudeim

New Member
Reaction score
22
Well if you're really lazy just copy this into a new trigger:
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 = 50
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

to change the maximum number of charges change set MAXIMUM = 50
 
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