HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mix Together Items

04-14-2005, 04:50 PM#1
Thunder_Eye
This is probably easy but I just wonder.
I got 2 Healing Potions, 1 in "slot 1" and 1 in "slot 2"
Now I want them to be for example, 2 in "slot 1"
How to do that?
04-14-2005, 05:01 PM#2
Anitarf
With triggers. On event "unit acquires an item", you should do a check of all items in the unit's inventory and if there's... blah, let me just write the trigger for you.
Code:
Events:
    Generic unit event - Unit acquires an item
Conditions:
    Item class comparison - item class of (item being manipulated) equal to Charged
Actions:
    For each integer A from 1 to 6 do actions
        Loop - Actions:
            If - Then - Else multiple functions
                If - Conditions:
                    item comparison - (item carried by (hero manipulating item) in slot (Integer A)) not equal to (item being manipulated)
                    item type comparison - item type of (item carried by (hero manipulating item) in slot (Integer A)) equal to item type of (item being manipulated)
                Then - Actions:
                    item - set charges remaining on (item carried by (hero manipulating item)in slot (Integer A)) to ((number of charges of (item carried by (hero manipulating item) in slot (Integer A)) + (number of charges of (item being manipulated))
                    item - remove item being manipulated
                    skip remaining actions
                Else - Actions:
                    do nothing

This is a very simple trigger, it will just stack items without any limit.
04-14-2005, 05:03 PM#3
Thunder_Eye
ok thanks, thought It would be easier then with trigger cause I think you could just do it without in RoC
04-14-2005, 07:03 PM#4
Thunder_Eye
Well it didnt really work.
04-14-2005, 09:28 PM#5
Anitarf
Did you by any chance try it with a normal potion, which is in fact under the purchaseable category rather than charged, which the trigger asks for? My mistake. I have now revised the condition and it should work for any charged item no matter what category it's in now (as I should have done it originaly). So, here's a copy&paste of an updated and working trigger directly from the trigger editor:
Code:
Charged Item Merge
    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 being manipulated) Not equal to (Item carried by (Hero manipulating item) in slot (Integer A))
                        (Item-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
                    Then - Actions
                        Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A)) to ((Charges remaining in (Item being manipulated)) + (Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))))
                        Item - Remove (Item being manipulated)
                        Skip remaining actions
                    Else - Actions
                        Do nothing
04-15-2005, 02:12 PM#6
Thunder_Eye
No, the problem is that when I want to have the charges to more then 1,
I have to set them to at least 2 in "Number of Charges", and then when the player recieves the potion, its already full. So it kind of bugs and makes 2x2 potions to 1.
04-15-2005, 03:40 PM#7
Anitarf
You must be doing something wrong. I tested the above written code in-game with regular 1-charge default warcraft items and it merged them flawlessly.
04-16-2005, 03:08 AM#8
Raptor--
heres what i use,

Code:
//Custom Script
//***************************************************************************
//Returns what box the item was dropped on, if it was not a drop order,
//returns -1
//***************************************************************************
function getItemDropBox takes integer o returns integer
    if ( (o > 852001) and (o < 852008) ) then
        return (o - 852001)
    else
        return -1
    endif
endfunction
//End Custom Script

//Trigger Section
EQUIP Drag n Drop Event
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Custom script:   local integer tempint1
        Custom script:   local integer s1
        Custom script:   local integer p1
        Custom script:   local integer s2
        Custom script:   local integer p2
        Set OTHER_nPlayerIndex = (Player number of (Owner of (Ordered unit)))
        Set INVENTORY_bDisableDropCheck[OTHER_nPlayerIndex] = True
        Custom script:   set udg_XTEMP_n01 = getItemDropBox( GetIssuedOrderId() )
        Custom script:   set tempint1 = udg_XTEMP_n01
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                XTEMP_n01 Not equal to -1
            Then - Actions
                -------- item01 = Item being moved // item02 = Item being moved to --------
                Set XTEMP_item01 = (Target item of issued order)
                Set XTEMP_item02 = (Item carried by PLAYER_unitHero_A[OTHER_nPlayerIndex] in slot XTEMP_n01)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        XTEMP_item01 Not equal to XTEMP_item02
                    Then - Actions
                        -------- ---------------------------------------------------------------------------------------------------//Swap Internal Positions (not needed for your purposes) --------
                        -------- ---------------------------------------------------------------------------------------------------//End swap --------
                        -------- ---------------------------------------------------------------------------------------------------//Check if both items are stackable --------
                        //You can choose to break the thing here if theres some checks (noted in the next check as XTEMP_b01 which has to be true)
                        -------- ---------------------------------------------------------------------------------------------------//End check --------
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Item-type of XTEMP_item01) Equal to (Item-type of XTEMP_item02)
                                XTEMP_b01 Equal to True
                            Then - Actions
                                [PSEUDO LINE]Custom script:   set udg_XTEMP_n01 = Remaining charges of (udg_XTEMP_item01)
                                [PSEDUO LINE]Custom script:   set udg_XTEMP_n02 = Remaining charges of (udg_XTEMP_item02)
                                Item - Set charges remaining in XTEMP_item01 to (XTEMP_n01 + XTEMP_n02)
                                Set EQUIPMENT_itemTemp = XTEMP_item02
                                Item - Remove EQUIPMENT_itemTemp
                            Else - Actions
                                Do nothing
                        Custom script:   set udg_XTEMP_n01 = tempint1
                    Else - Actions
                        Do nothing
            Else - Actions
                Do nothing

Edited because: ok i trimed it down a bit to whats needed, this allows you to stack items by draging on ontop of another .
04-29-2005, 05:22 PM#9
thedevil
Charged class item add
Events
Unit - A unit Acquires an item
Conditions
And - All (Conditions) are true
Conditions
((Triggering unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Item-class of (Item being manipulated)) Equal to Charged
Actions
Set Interger_Chargeitemcount = 0
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 (Triggering unit) in slot (Integer A)))
Then - Actions
Set Interger_Chargeitemcount = (Interger_Chargeitemcount + 1)
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Interger_Chargeitemcount Equal to 2
Then - Actions
Item - Set charges remaining in (Item carried by (Triggering unit) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item carried by (Triggering unit) of type (Item-type of (Item being manipulated)))) + (Charges remaining in (Item being manipulated)))
Item - Remove (Item being manipulated)
Else - Actions
Do nothing
The only problem with this trigger is charged item wont add if the charged item in hero inventory not at the nearest empty slot when he accquire charged item(for example your hero have slot 1 empty and slot 2 have 1 charged item then when your hero pick up an charged item then nothing happenT_T) beside of that its work well.
05-02-2005, 06:55 PM#10
Anitarf
Quote:
Originally Posted by thedevil
*a long trigger not posted in code tags*

The only problem with this trigger is charged item wont add if the charged item in hero inventory not at the nearest empty slot when he accquire charged item(for example your hero have slot 1 empty and slot 2 have 1 charged item then when your hero pick up an charged item then nothing happenT_T) beside of that its work well.

That's quite a glaring problem. Use the trigger I posted above, if you copy it right it works perfectly.
05-02-2005, 09:56 PM#11
Raptor--
you can also use mine, it doesn't require actually understanding how it works, but if you have that, when you drop an item on another one of same type in your inventory they will stack
05-16-2005, 11:15 AM#12
Thunder_Eye
Well Ive tried both of yous triggers and none of them work.
When I tested Raptor´s trigger and saved "Expected Name" Appeared and Ive done all the things right.
And when I tested Anitarf´s trigger it works to save but when I test it ingame it just removes the potions when I try to pick them up.
This is the trigger:

Stack Items
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 being manipulated) Not equal to (Item carried by (Damage source) in slot (Integer A))
(Item-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
Then - Actions
Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A)) to ((Charges remaining in (Item being manipulated)) + (Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))))
Item - Remove (Item being manipulated)
Skip remaining actions
Else - Actions
Do nothing
05-16-2005, 11:19 AM#13
Anitarf
(Item being manipulated) Not equal to (Item carried by (Damage source) in slot (Integer A))

Here's your problem, you accidentaly put "damage source" instead of "hero manipulating item".
05-16-2005, 04:44 PM#14
Vexorian
Quote:
Well Ive tried both of yous triggers and none of them work.
When I tested Raptor´s trigger and saved "Expected Name" Appeared and Ive done all the things right.

You didn't.

You either didn't create a variable or didn't consider that JASS is case sensitive
07-04-2005, 05:51 PM#15
MeTaCo
Quote:
Originally Posted by Anitarf
That's quite a glaring problem. Use the trigger I posted above, if you copy it right it works perfectly.


I tried this code of yours, it works and all but the thing is it'll only stack the first type of charged item, and when u grab a different type of charged item it'll stack the first 1, Say I picked up mana pot, and then I pick up ank, it'll stack up on mana pot wether I pick up mana or ank. it adds the charge yeah, but the glitch lies between the "not equal to" part of item being manipulated, I think u might need another condition which requires to check that both item Types are different or same.

*edit* I found the problem, u need to add the following to the If/Then/Else condition

(Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))

This checks to see that the item being picked up matches the type in the slot, and only will change the same Type of item.