HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item Stacking help

09-12-2004, 01:42 AM#1
BuRnInSpartan
to be honest i didn't know where to put this but i have a question... is there any way of stacking items? like if you have a potion of healing and you get another it stacks onto that so now you have 2?
09-12-2004, 02:32 AM#2
DarkMage
yes there is and its simple.

Code:
Event  Unit Acquires an item
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 (Triggering unit) in slot (Integer A))) Equal to Healing Potion
                Then - Actions
                    For each (Integer B) 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 (Triggering unit) in slot (Integer B))) Equal to Healing Potion
                                    (Integer A) Not equal to (Integer B)
                                Then - Actions
                                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        If - Conditions
                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 1
                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 9
                                        Then - Actions
                                            Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                            Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                        Else - Actions
                                            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                If - Conditions
                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 2
                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 8
                                                Then - Actions
                                                    Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                    Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                Else - Actions
                                                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                        If - Conditions
                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 3
                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 7
                                                        Then - Actions
                                                            Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                            Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                        Else - Actions
                                                            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                If - Conditions
                                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 4
                                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 6
                                                                Then - Actions
                                                                    Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                                    Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                                Else - Actions
                                                                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                        If - Conditions
                                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 5
                                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 5
                                                                        Then - Actions
                                                                            Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                                            Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                                        Else - Actions
                                                                            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                                If - Conditions
                                                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 6
                                                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 4
                                                                                Then - Actions
                                                                                    Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                                                    Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                                                Else - Actions
                                                                                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                                        If - Conditions
                                                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 7
                                                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 3
                                                                                        Then - Actions
                                                                                            Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                                                            Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                                                        Else - Actions
                                                                                            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                                                If - Conditions
                                                                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 8
                                                                                                    (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 2
                                                                                                Then - Actions
                                                                                                    Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                                                                    Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                                                                Else - Actions
                                                                                                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                                                        If - Conditions
                                                                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than or equal to 9
                                                                                                            (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))) Less than or equal to 1
                                                                                                        Then - Actions
                                                                                                            Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer B))))
                                                                                                            Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                                                                                        Else - Actions
                                Else - Actions
                Else - Actions    <-- Add to this
                  


For every other item you what stacked just copy/past the first If,than,elss to the first "Else". it looks big but you can stack up to 10 healing pots. more if you like
09-12-2004, 02:42 AM#3
BuRnInSpartan
well sorry i can't give you some more rep but thanks again let me test
09-12-2004, 02:50 AM#4
DarkMage
Hope it works for you as well as it works for me.

Esit: If you have any problems with it, ill chop it into small sections. for a step by step kind-of-thing. but im sure you wont have any problems.
09-12-2004, 03:19 AM#5
BuRnInSpartan
problem... it stacks over my other items and it doesn't even let me heal (for example. i have a claws of attack and the potion stacks onto it and there is a four at bottom corner of it... i click it and nothing even happens? o_O )
09-12-2004, 03:50 AM#6
DarkMage
realy? hmm... strage...

hmm... You do have the 2 item types set to healing potion right? that might be your problem if not, i cant realy think of any thing else. when i test it, it works fine.

also you might whant to set the quonity of the healing pot to 10 and when you get it have a trigger to change it to 1 or what ever.
09-12-2004, 07:29 AM#7
Grater
Good grief there has to be a much smaller GUI trigger for stacking items
I have a JASS one that is short and adds lots of stuff like weight limits and stuff... I just wrote this simple GUI one in a couple of minutes, and it seems to work flawlessly.
Code:
Item Stacking
    Events
        Unit - A unit Acquires an item
    Conditions
        (Charges remaining in (Item being manipulated)) Greater than 0
    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 being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
                        (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)
                        Skip remaining actions
                    Else - Actions
09-12-2004, 11:39 AM#8
BuRnInSpartan
wow that's much smaller
09-12-2004, 11:40 AM#9
BuRnInSpartan
Quote:
Originally Posted by DarkMage
realy? hmm... strage...

hmm... You do have the 2 item types set to healing potion right? that might be your problem if not, i cant realy think of any thing else. when i test it, it works fine.

also you might whant to set the quonity of the healing pot to 10 and when you get it have a trigger to change it to 1 or what ever.


_________________________________________________________________

nope i set the item to healing potion o_O