HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Stacking Items

07-09-2004, 04:10 PM#1
dragnstitch
Code:
Events
    Unit - A unit Acquires an item
Conditions
    (Item-type of (Item being manipulated)) Equal to Water Arrows
Actions
    Item - Set charges remaining in (Item being manipulated) to (Charges remaining in (Item carried by (Hero manipulating item) of type Water Arrows))
    Item - Remove (Get last acquired item of (Hero manipulating item))

Is what i have so far..

What i want is so if the player picks up the Water Arrow it stacks it with another Water arrow and removes the old one..

Hero has 12.. buys a bundle of 10... stacks together with the first one 22 and gets rid of the 10

i saw something like this in JASS but err.. i dont know much about Jass..
07-09-2004, 04:52 PM#2
th15
You will need to loop through the hero's inventory slots to find another item of the same type. Then you add the number of charges of the acquired item to the found item.

There's a demo map of how this is done... somewhere. I think elilz's site.

Item - Remove (Get last acquired item of (Hero manipulating item))

This line should read:

Item - Remove (Item being manipulated)
07-09-2004, 10:01 PM#3
dragnstitch
ok that helped it so it stacked but now i have hte problem is iif the player dont have the item in his inventory he cant pick it up..

Code:
Water
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Water Arrows
    Actions
        Item - Set charges remaining in (Item carried by (Hero manipulating item) of type Water Arrows) to ((Charges remaining in (Item being manipulated)) + (Charges remaining in (Item carried by (Hero manipulating item) of type Water Arrows)))
        Item - Remove (Item being manipulated)

i was looking through trying to find it so it detects if the hero has more then 1 of the item in his inventory
07-09-2004, 10:53 PM#4
Anitarf
Here you go, an item merging trigger (it can be easily made to work for multiple item types, just add new item-type conditions in the "or - multiple conditions"):

Code:
Water
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - multiple conditions
            conditions:
                (Item-type of (Item being manipulated)) Equal to Water Arrows
    Actions
        For each integer A from 1 to 6 do actions
            loop - actions:
                if - then - else multiple functions
                    if - conditions:
                        and - multiple conditions
                            conditions:
                                item-type of (Item carried by (Hero manipulating item) in item-slot(integer A)) equal to item-type of (item being manipulated)
                                (item being manipulated) not equal to (Item carried by (Hero manipulating item) in item-slot(integer A))
                    then - actions:
                        Item - Set charges remaining in (Item carried by (Hero manipulating item) in item-slot(integer A)) to ((Charges remaining in (Item being manipulated)) + (Charges remaining in (Item carried by (Hero manipulating item) in item-slot(integer A))))
                        Item - Remove (Item being manipulated)
                        skip remaining actions
                    else - actions:
                        do nothing
07-10-2004, 01:42 AM#5
dragnstitch
Cool thanks works like a charm!!