Item Limit Charges

ryerye1996

Cool Member
Reaction score
5
How can you make an item have a limit amount of charges? i alredy know how to make an item gain charges.

This is what i have for the trigger:

Events
Unit - A unit Acquires an item
Conditions
(Item-class of (Item being manipulated)) Equal to Charged
(Charges remaining in (Item being manipulated)) Greater than 20
Actions
Hero - Create (Item-type of (Item being manipulated)) and give it to (Hero manipulating item)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Charges remaining in (Item being manipulated)) Greater than 20
(Size of inventory for (Hero manipulating item)) Equal to 6
Then - Actions
Item - Remove (Item being manipulated)
Else - Actions
Do nothing


but, when i do this, the item continues to stack (just to let you know, the if,then,else action is that if your inventory is full you dont get an item)
 

dudeim

New Member
Reaction score
22
Well i got a Trigger in jass for you (no knowledge of jass required) just copy paste it into a custom trigger and set the maximum to your value (in the trigger it's on 50 that the max you can combine in 1 place)
JASS:
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


Hope I helped
 

ryerye1996

Cool Member
Reaction score
5
can somebody show me that using the regular WE trigger because i have tried to dowload JASS for the past 3 hours and it still didnt work. :banghead:
 

Tom Jones

N/A
Reaction score
437
Download jass? Your editor comes with jass :)

And back on topic, why don't you simply modify your items charges to a desired value in the object editor?

Object Editor -> Item Editor -> Find your item -> Stats - Number of charges
 

ShadowInTheD

Active Member
Reaction score
12
Your trigger seems pointless. Instead, don't give your hero an item. Your check of charges was okay, but after that, you need to get the total charges, then drop (total charges - 20) from the hero.
 
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