Need help: Combining charged items

Sivert

New Member
Reaction score
0
My knowledge about item-triggers are somewhat limited, and I haven't been able to figure out how to combine charged items. I have a custom script enabling it, thanks to the Dota template, but I don't really know enough about it, and it doesn't work when just copying to my own map.. I want charged items (potions and so on) to combine when the hero or unit picks up another item of the same class.

Here is the custom script:
function Trig_Combine_Items_Conditions takes nothing returns boolean
if ( not ( GetItemCharges(GetManipulatedItem()) > 0 ) ) then
return false
endif
if ( not ( udg_Combine_Charged_Items == true ) ) 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 = udg_Combine_Charges_Max
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

There were also some variables ..

Any help is appreciated! :)
 

thewrongvine

The Evolved Panda Commandant
Reaction score
506
Did you test it and it didn't work?

There might be some thing, something, in the Object Editor > Items maybe that allows it to stack.
 

Sivert

New Member
Reaction score
0
Did you test it and it didn't work?

There might be some thing, something, in the Object Editor > Items maybe that allows it to stack.

It works in the original map, but not when I copy it over into my map. I'll try a little more now, but I don't know if I'll accomplish anything :p
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
Code:
Untitled Trigger 001
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
                        (Item carried by (Hero manipulating item) in slot (Integer A)) Not equal to (Item being manipulated)
                    Then - Actions
                        Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A)) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))) + (Charges remaining in (Item being manipulated)))
                        Item - Remove (Item being manipulated)
                    Else - Actions
 

Sivert

New Member
Reaction score
0
It certainly works as a perfect solution. Thank you! :)

I do have one more thing I could trouble you guys with:

How do I get a scroll of town portal to be able to target structures? Use Dota as an example. To be able to target structures only. It seems to say "only town halls", and it doesn't work even if I change the class to town hall on the buildings I want to be able to transport to. I tried editing the item ability a little too, but I might be missing something.
 
P

PirosThe4th

Guest
It certainly works as a perfect solution. Thank you! :)

I do have one more thing I could trouble you guys with:

How do I get a scroll of town portal to be able to target structures? Use Dota as an example. To be able to target structures only. It seems to say "only town halls", and it doesn't work even if I change the class to town hall on the buildings I want to be able to transport to. I tried editing the item ability a little too, but I might be missing something.

Have you tried changing the ability for a Mass Teleport (which can target structures) that only works the caster?
 
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