• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Item merging

Status
Not open for further replies.
Level 2
Joined
Feb 21, 2014
Messages
18
Hello

I've got problem with item combination. I don't know how to merge 2 same items. For me its Granite Axe+6. I've tried to use this

test
Events
Unit - A unit Acquires an item
Conditions
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Granite Axe +6 [T0]
(Item-type of (Item being manipulated)) Equal to Granite Axe +6 [T0]
((Hero manipulating item) has an item of type Granite Axe +6 [T0]) Equal to True
((Hero manipulating item) has an item of type Granite Axe +6 [T0]) Equal to True
Actions
Set Ingredients = 2
Set RecipeFactor[1] = Granite Axe +6 [T0]
Set RecipeFactor[2] = Granite Axe +6 [T0]
For each (Integer A) from 1 to Ingredients, do (Actions)
Loop - Actions
Set FactorCleared[(Integer A)] = False
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
For each (Integer B) from 1 to Ingredients, 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 RecipeFactor[(Integer B)]
FactorCleared[(Integer B)] Equal to False
Then - Actions
Item - Remove (Item carried by (Hero manipulating item) in slot (Integer A))
Set FactorCleared[(Integer B)] = True
Else - Actions
Hero - Create Granite Axe +11 [T1] and give it to (Hero manipulating item)

but during game merging gets silly. Game thinks that you need only ONE granite axe +6 to make Granite axe +11
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Use this to post your triggers. http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

Also don't use integer A / B. They are slower and less efficient than custom integers.

If you are looking for an item recipe system I have one in my sig.
To make one that can use multiples of one item is a little more complicated than just looping through them.
You have to loop through the units slots and check to make sure it has the desired amount. Then you have to loop through again and remove the correct amount.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Also don't use integer A / B. They are slower and less efficient than custom integers.
I don't know why it's so necessary for this to exist, but it is: http://www.hiveworkshop.com/forums/...ce-announcement-jass-optimization-you-249092/

OP: Your issue is that your condition just checks the same thing (whether the unit has a Granite Axe +6) twice. You should count the number of Granite Axe +6s in the inventory instead and confirm that there are at least two of them.
 
Status
Not open for further replies.
Top