• 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.

[Solved] Detect many items and go for the actions

Level 18
Joined
Jun 2, 2009
Messages
1,233
Hello everyone. I want to do something like this. How to do that?

Unit acquires item

If Hero has and item type of X AND
Acquired item type is y, z, (there are more than 100 items) in here)


Action -


Of course i can add all items in here but is there any better way for do that?
If Hero has specific item, it CANNOT acquire more than 100 items.
 
Level 30
Joined
Aug 29, 2012
Messages
1,383
You can use one of the item fields as a classification system then reference it, like level for instance

  • (Item level of (Item being manipulated)) Equal to 1
Give the same level to all the items that you want to group under a single category and a different one to those you need to exclude

Since reforged you can also use stuff like priority, which is rarely used except for AI hero

  • (Item: (Last created item)'s Integer Field: Priority ('ipri')) Equal to 1
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
Let me explain this first. As you can see there are 60 weapons in there.
10 Different weapon categories.
IF you own the MACHINEGUN LEVEL 6
You will drop ALL weapons of other categories.
Of course i can do this by calculating every item and category but i know there has to be better and simple solution.


  • SilahMachine Copy
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Arcane Cannon - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Arcane Cannon - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Arcane Cannon - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Arcane Cannon - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Arcane Cannon - Seviye 5
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Axe Cannon - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Axe Cannon - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Axe Cannon - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Axe Cannon - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Axe Cannon - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Axe Cannon - |cffff0000Seviye 6|r
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Ballista - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Ballista - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Ballista - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Ballista - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Ballista - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Ballista - |cffff0000Seviye 6|r
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Bow - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Bow - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Bow - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Bow - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Bow - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Bow - |cffff0000Seviye 6|r
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Energy - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Energy - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Energy - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Energy - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Energy - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Energy - |cffff0000Seviye 6|r
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Fire - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Fire - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Fire - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Fire - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Fire - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Fire - |cffff0000Seviye 6|r
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Machinegun - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Machinegun - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Machinegun - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Machinegun - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Machinegun - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Machinegun - |cffff0000Seviye 6|r
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Mortar - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Mortar - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Mortar - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Mortar - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Mortar - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Mortar - |cffff0000Seviye 6|r
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Nature Cannon - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Nature Cannon - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Nature Cannon - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Nature Cannon - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Nature Cannon - Seviye 5
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Water - Seviye 1
              • (Item-type of (Item being manipulated)) Equal to Water - Seviye 2
              • (Item-type of (Item being manipulated)) Equal to Water - Seviye 3
              • (Item-type of (Item being manipulated)) Equal to Water - Seviye 4
              • (Item-type of (Item being manipulated)) Equal to Water - Seviye 5
              • (Item-type of (Item being manipulated)) Equal to Water - |cffff0000Seviye 6|r
        • Then - Actions
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,872
Let me explain this first. As you can see there are 60 weapons in there.
10 Different weapon categories.
IF you own the MACHINEGUN LEVEL 6
You will drop ALL weapons of other categories.
Of course i can do this by calculating every item and category but i know there has to be better and simple solution.
Here's a basic idea.

When you acquire any item that's Level 6 you will drop all other Weapons (excluding the new item):
  • Level 6 Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Level of (Item being manipulated)) Equal to 6
    • Actions
      • Set Item = (Item being manipulated)
      • Set Item_Unit = (Triggering unit)
      • Trigger - Run Check Item Restrictions (ignoring conditions)
  • Check Item Restrictions
    • Events
    • Conditions
    • Actions
      • For each integer (Item_Slot) from 1 to 6 do (Actions)
        • Loop - Actions
          • Set Item_Other = (Item carried by Item_Unit in slot Item_Slot)
          • If all Conditions are true then do (Actions)
            • If - Conditions
              • Item_Other Not equal to Item
              • (Item-class of Other_Item) Not equal to Purchasable
            • Then - Actions
              • Hero - Drop Item_Other from Item_Unit
            • Else - Actions
I prevent items classified as Purchasable from being dropped, which could be Potions and other items that you want to keep.

You can add as many Conditions as you need. It all depends on how you've setup your map and how you categorize things.
 
Last edited:
Level 18
Joined
Jun 2, 2009
Messages
1,233
Uhm. I do not understand well but here is the additional information maybe it helps us.

I have 10 booleans for a reason. Players are typing -mortar -arcane cannon etc etc before buy the Level 6 weapon and this boolean turns to True.
If player decides to use Mortar 6, they can only use mortar type items. Mortar 1,2,3,4,5 etc. If they will try to buy another gun, i do not want to allow it.

Players can use any weapons between 10 weapon categories UNTIL they decide to use level 6 versions.

If Uncle types -machinegun and upgrades machinegun 5 to machinegun 6, no more can use other weapons. Only he can use machineguns.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,872
Uhm. I do not understand well but here is the additional information maybe it helps us.

I have 10 booleans for a reason. Players are typing -mortar -arcane cannon etc etc before buy the Level 6 weapon and this boolean turns to True.
If player decides to use Mortar 6, they can only use mortar type items. Mortar 1,2,3,4,5 etc. If they will try to buy another gun, i do not want to allow it.

Players can use any weapons between 10 weapon categories UNTIL they decide to use level 6 versions.

If Uncle types -machinegun and upgrades machinegun 5 to machinegun 6, no more can use other weapons. Only he can use machineguns.
The idea is to categorize your Items inside of the Object Editor. For example, make each Level represent a different Weapon Category:

Mortar = Level 1
Arcane
= Level 2
Machine Gun
= Level 3
1736625875324.png

You now have a way to check the category inside of the Trigger Editor -> you get the item's Level.

So when Player 1 picks the Mortar Level 6 you will store this as an Integer (not a Boolean):
  • Events
    • Player - Player 1 types a message containing -mortar 6 as an exact match
  • Conditions
    • Weapon_Category[(Player number of (Triggering player))] Equal to 0
  • Actions
    • Set PN = (Player number of (Triggering player))
    • Set Weapon_Category[PN] = 1
    • Trigger - Run Drop Other Weapons (ignoring conditions)
Then you will drop other items whose Weapon Categories (Levels) are NOT the same:
  • Drop Other Weapons
    • Events
    • Conditions
    • Actions
      • For each integer (Item_Slot) from 1 to 6 do (Actions)
        • Loop - Actions
          • Set Item = (Item carried by Hero[PN] in slot Item_Slot)
          • If all Conditions are true then do (Actions)
            • If - Conditions
              • (Level of Item) Not equal to Weapon_Category[PN]
              • (Level of Item) Not equal to 0
            • Then - Actions
              • Hero - Drop Item from Hero[PN]
            • Else - Actions
Items using Level 0 are safe and won't be dropped, so you could use Level 0 for Potions and other Non-Weapon items.

You can also drop all future Items that don't match your Weapon Category:
  • Events
    • Unit - A unit Acquires an Item
  • Conditions
    • Weapon_Category[(Player number of (Owner of (Triggering unit))] Greater than 0
    • (Level of (Item being manipulated)) Not equal to Weapon_Category[(Player number of (Owner of (Triggering unit))]
    • (Level of (Item being manipulated)) Not equal to 0
  • Actions
    • Hero - Drop (Item being manipulated) from (Triggering unit)
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,872
@Uncle What is the condition of level of item being manipulated? It looks like this when i try to set it

(Item level of (Item being manipulated)) Equal to 0
Not like (Level of (Item being manipulated)) Not equal to 0
I write these triggers from memory so I usually mess up the exact naming of things. Those are the same thing.

But try to not overthink it.

Items have Levels.
Levels are Integers that you set in the Object Editor.
If an Integer Comparison Condition says something about an Item and a Level then it's probably what we're looking for.
 
Last edited:
Top