• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Need a simple Item upgrade trigger

Level 5
Joined
Mar 18, 2023
Messages
63
So on my map, I have a Longbow item that goes from level 1-5. Every time you buy the Longbow, it upgrades itself. My only problem is getting around the first level and having it detect that the unit is holding two level 1 Longbows. I feel like this is something that should be really easy to do, but I haven't work on items in ages and haven't done anything crazy with them. IF anyone can be an easy example I'd appreciate it a lot
 
Something like this?

  • Combine
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) has an item of type Claws of Attack +1) Equal to True // Boolean, "hero has item of type" check
      • (Item carried by (Triggering unit) of type Claws of Attack +1) Not equal to (Item being manipulated) //Item check, necessary otherwise the item acquired would count double
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +1 //Item type check
    • Actions
      • Item - Remove (Item carried by (Triggering unit) of type Claws of Attack +1)
      • Item - Remove (Item being manipulated)
      • Hero - Create Claws of Attack +2 and give it to (Triggering unit)
 
So on my map, I have a Longbow item that goes from level 1-5. Every time you buy the Longbow, it upgrades itself. My only problem is getting around the first level and having it detect that the unit is holding two level 1 Longbows. I feel like this is something that should be really easy to do, but I haven't work on items in ages and haven't done anything crazy with them. IF anyone can be an easy example I'd appreciate it a lot
Here's a slightly more advanced approach which breaks down the logic - it's really not that complex:
  • Combine Items
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Weapon Level 1
    • Actions
      • Set Inv_Unit = (Triggering unit)
      • Set Inv_Item = (Item being manipulated)
      • Set Inv_Item_Type = (Item-type of Inv_Item)
      • -------- --------
      • -------- Loop over our unit's inventory and try to find items that match our newly acquired item: --------
      • Set Inv_Matches = 0
      • For each (Integer Inv_Slot) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Inv_Other_Item = (Item carried by Inv_Unit in slot Inv_Slot)
          • Set Inv_Other_Item_Type = (Item-type of Inv_Other_Item)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Inv_Item_Type Equal to Inv_Other_Item_Type
            • Then - Actions
              • Set Inv_Matches = (Inv_Matches + 1)
              • Set Inv_Items_To_Remove[Inv_Matches] = Inv_Other_Item
            • Else - Actions
      • -------- --------
      • -------- If we found 2 or more matches then we know that we can finish the combination: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Inv_Matches Greater than or equal to 2
        • Then - Actions
          • -------- Remove the items used in this combination: --------
          • For each (Integer Inv_Slot) from 1 to Inv_Matches, do (Actions)
            • Loop - Actions
              • Item - Remove Inv_Items_To_Remove[Inv_Slot]
          • -------- --------
          • -------- Create the new item: --------
          • Hero - Create Weapon Level 2 and give it to Inv_Unit
        • Else - Actions
This design counts the item you just found as a "match", which is why finding 2 or more matches is considered a success and creates the new item.

You could easily turn this into a system that automates the process for every single item combination. This trigger plus a setup trigger for defining the different item combinations (ie: In a Hashtable) would be all that's necessary.
 

Attachments

Last edited:
Here's a slightly more advanced approach which breaks down the logic - it's really not that complex:
  • Combine Items
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Weapon Level 1
    • Actions
      • Set Inv_Unit = (Triggering unit)
      • Set Inv_Item = (Item being manipulated)
      • Set Inv_Item_Type = (Item-type of Inv_Item)
      • -------- --------
      • -------- Loop over our unit's inventory and try to find items that match our newly acquired item: --------
      • Set Inv_Matches = 0
      • For each (Integer Inv_Slot) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Inv_Other_Item = (Item carried by Inv_Unit in slot Inv_Slot)
          • Set Inv_Other_Item_Type = (Item-type of Inv_Other_Item)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Inv_Item_Type Equal to Inv_Other_Item_Type
            • Then - Actions
              • Set Inv_Matches = (Inv_Matches + 1)
              • Set Inv_Items_To_Remove[Inv_Matches] = Inv_Other_Item
            • Else - Actions
      • -------- --------
      • -------- If we found 2 or more matches then we know that we can finish the combination: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Inv_Matches Greater than or equal to 2
        • Then - Actions
          • -------- Remove the items used in this combination: --------
          • For each (Integer Inv_Slot) from 1 to Inv_Matches, do (Actions)
            • Loop - Actions
              • Item - Remove Inv_Items_To_Remove[Inv_Slot]
          • -------- --------
          • -------- Create the new item: --------
          • Hero - Create Weapon Level 2 and give it to Inv_Unit
        • Else - Actions
This design counts the item you just found as a "match", which is why finding 2 or more matches is considered a success and creates the new item.

You could easily turn this into a system that automates the process for every single item combination. This trigger plus a setup trigger for defining the different item combinations (ie: In a Hashtable) would be all that's necessary.
Ok was going for simple, but now that you mention having it being able to automate the combination, how would I go and set that up? Originally the map was going to only have some items use this leveling thing, but now we figured might as well do it for the recipe stuff too. Once a player creates the recipe item, they would only need to buy the recipe by itself to increase it. This should help with items not being too much a hassle haha
 
Well, this trigger is currently setup for combining the exact same types of items. If you want a full blown recipe system that say combines Boots of Speed + Gloves of Haste = Power Treads, then you'll need to expand upon the concepts found in this trigger.

But before doing that, you can always try a pre-existing system for your item recipes:

Also, here's a system I made for someone a few years ago:
It seems to have a working recipe system that utilizes a Hashtable, although I can't promise that it's flawless.
 
Well, this trigger is currently setup for combining the exact same types of items. If you want a full blown recipe system that say combines Boots of Speed + Gloves of Haste = Power Treads, then you'll need to expand upon the concepts found in this trigger.

But before doing that, you can always try a pre-existing system for your item recipes:

Also, here's a system I made for someone a few years ago:
It seems to have a working recipe system that utilizes a Hashtable, although I can't promise that it's flawless.
thank you uncle!
 
Back
Top