• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

How to create an item crafting trigger for a non-hero unit?

Status
Not open for further replies.
Level 2
Joined
May 20, 2015
Messages
25
So I have been researching on the forums about a trigger that could craft an item when you put two or more items in the inventory of a building and then you press an ability to craft the items together and make a new item. Unfortunately, I haven't been able to find any solutions so far since all of them required a Hero unit to pick up an item and then instantly craft the item if it detects that all required items are in the inventory.

For an example of what I want the trigger to do: My Hero puts Item1 and Item2 in a building unit controlled by me, then I press a dummy ability that does nothing (its a modified thunder clap) and then it creates a new item.

I'm really new to all these triggers so excuse me if its an obvious solution.
 
certain units can carry items if they have the carry item ability upgrade, but I think that only allows them to carry 2 items
 
The building that the items go into has the 'Inventory(Hero)' ability by default, its capable of holding 6 items at a time. What I want to do is combine the items in the inventory to create a new item if I press an ability that the building has.
 
This is the easiest way i could think of:

  • ItemCombi
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) #Itemforge (Neutral Hostile)
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Claws of Attack +6) Equal to (==) True
          • ((Triggering unit) has an item of type Claws of Attack +9) Equal to (==) True
        • Then - Actions
          • Item - Remove (Item carried by (Triggering unit) of type Claws of Attack +6)
          • Item - Remove (Item carried by (Triggering unit) of type Claws of Attack +9)
          • Hero - Create Claws of Attack +15 and give it to (Triggering unit)
        • Else - Actions
edit: btw, i normally don't like players who mass fiends :ogre_icwydt:
 
Thank you A]mun, works perfectly! :D I literally spent about 6 hours trying to find a working method but failed miserably.

A question if you don't mind: How would I need to change the code so that it would detect multiple items of the same type, lets say two Claws of Attack +6 and create the Claws of Attack +9? I intend to have a couple recipes featuring the same items multiple times as well so that's why I'm wondering.

Also: I'll try to mass less fiends next time... :P
 
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Forge
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Claws of Attack +3) Equal to True
        • Then - Actions
          • Item - Remove (Item carried by (Triggering unit) of type Claws of Attack +3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) has an item of type Claws of Attack +3) Equal to True
            • Then - Actions
              • Item - Remove (Item carried by (Triggering unit) of type Claws of Attack +3)
              • Hero - Create Claws of Attack +6 and give it to (Triggering unit)
            • Else - Actions
              • Hero - Create Claws of Attack +3 and give it to (Triggering unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) has an item of type Greater Replenishment Potion) Equal to True
              • (Charges remaining in (Item carried by (Triggering unit) of type Greater Replenishment Potion)) Greater than or equal to 2
              • ((Triggering unit) has an item of type Maul of Strength) Equal to True
            • Then - Actions
              • Item - Remove (Item carried by (Triggering unit) of type Claws of Attack +3)
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Greater Replenishment Potion) to ((Charges remaining in (Item carried by (Triggering unit) of type Greater Replenishment Potion)) - 2)
              • If ((Charges remaining in (Item carried by (Triggering unit) of type Greater Replenishment Potion)) Less than or equal to 0) then do (Item - Remove (Item carried by (Triggering unit) of type Greater Replenishment Potion)) else do (Do nothing)
              • Hero - Create Killmaim and give it to (Triggering unit)
            • Else - Actions
This is a simple solution that I use in my map if you don't want to deal with looping through the inventory slots and setting each matched item as a variable integer.
If it's going to be a long trigger ideally- you would be setting variables for things you'd use often though (triggering unit) (item of type =your item) etc.
 
Daffa the Mage I'm not sure what you are referring to when you say "integer variable".

Alethos that is a really intriguing trigger I must say, I never thought about approaching it like that. During the time between my last post and now I played around with the trigger editor for a solution and this is what I came up with.

  • Recipe
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Craft
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type Potion of Greater Mana) Equal to True
              • ((Triggering unit) has an item of type Potion of Greater Mana) Equal to True
          • ((Triggering unit) has an item of type Potion of Greater Mana) Equal to True
          • ((Triggering unit) has an item of type Potion of Greater Mana) Equal to True
        • Then - Actions
          • Item - Remove (Item carried by (Triggering unit) of type Potion of Greater Mana)
          • Item - Remove (Item carried by (Triggering unit) of type Potion of Greater Mana)
          • Hero - Create White Potion (Placeholder) and give it to (Triggering unit)
        • Else - Actions
It works and you don't need to check every slot separately, but I wonder if it has any limitations, and I also wonder if your method would be a better approach to crafting items.
 
Status
Not open for further replies.
Back
Top