• 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 do I write a trigger that combines 6 of the same item together?

I think that should be quite straightforward:
  • Acquires item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Ring of Regeneration
    • 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))) Not equal to Ring of Regeneration
            • Then - Actions
              • Skip remaining actions
            • Else - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
      • Hero - Create Your_meme_item and give it to (Triggering unit)
First loop checks if any item carried by hero is not Ring of Regeneration and if so, it prematurely exits the trigger. I assume the inventory size is 6.
If trigger did not prematurely exit, the second loop removes all items from hero's inventory. Finally, your meme item is created and given to the hero.
 
if you wanted to check out systems folks have made for this, you can search for "Recipe" systems in our spells & systems section :thumbs_up:

But it is usually pretty simple to implement similar to how Nichilus posted.

If you do end up adding more recipes into your map--or if you want to customize how many rings are required (e.g. let's say you only want 3 rings required), then I recommend making a helper trigger to count the number of items held by a unit:
  • CountItemsOfType
    • Events
    • Conditions
    • Actions
      • -------- --------
      • -------- Counts how many items of a particular type that a unit is carrying. --------
      • -------- Parameters: --------
      • -------- - CountItems_Unit: Unit to count the items of --------
      • -------- - CountItems_ItemType: Item type to count --------
      • -------- --------
      • -------- Returns: --------
      • -------- - CountItems_Result: Number of that item that the unit is carrying --------
      • -------- --------
      • Set VariableSet CountItems_Result = 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 carried by CountItems_Unit in slot (Integer A))) Equal to CountItems_ItemType
            • Then - Actions
              • Set VariableSet CountItems_Result = (CountItems_Result + 1)
            • Else - Actions
For that trigger, you would just need to make a unit variable, an item-type variable, and an integer variable (to hold the result). Then you could use it for your ring of regeneration recipe like so:
  • RingOfRegenerationRecipe
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Ring of Regeneration
    • Actions
      • -------- --------
      • -------- Counts how many rings of regeneration that the unit has --------
      • -------- --------
      • Set VariableSet CountItems_Unit = (Triggering unit)
      • Set VariableSet CountItems_ItemType = Ring of Regeneration
      • Trigger - Run CountItemsOfType <gen> (ignoring conditions)
      • -------- --------
      • -------- The number of rings is stored in CountItems_Result --------
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CountItems_Result Equal to 6
        • Then - Actions
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Other\Charm\CharmTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Item - Remove (Item carried by (Triggering unit) of type Ring of Regeneration)
          • Hero - Create Necklace of Regeneration and give it to (Triggering unit)
        • Else - Actions
It essentially just runs that helper trigger to count how many rings the unit has (because we set CountItems_ItemType to Ring of Regeneration), and then we just check that result (CountItems_Result) with an if-then-else. That way, you can easily make as many recipes as you want just by following that same format :)
 

Attachments

Back
Top