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

[Trigger] Item class restriction bug

Level 3
Joined
Sep 2, 2024
Messages
9
HI,

I'm created a trigger to restrict number of item of same class.
When a hero try to pick an item with same class of carried item, he stop action and a text appears
BUT
Now when i try to use capacity (attack or spell) with all units, they stop action and the text appears 6 times but they can attack automatically.

my trigger :
Item Trigger.PNG


I don't understand why.

(Sorry to my bad English)

A test map with the trigger:
 

Attachments

  • Item Restriction trigger Bug.w3m
    14 KB · Views: 3
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
You're not checking which Order was issued or whether your Order targeted an item in the first place.

That means this trigger runs whenever you issue ANY order that targets an object. There's 100's of orders that do that -> attack, patrol, smart, storm bolt, cripple, bloodlust, etc.

So your Conditions need to confirm that you're actually trying to pick-up an item before going any further:
  • Prevent Same Class Items
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • (Target item of issued order) Not equal to No item
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: (String((Issued order)))
      • Set VariableSet Item_Order_Unit = (Triggering unit)
      • Set VariableSet Item_Order_Class = (Item-class of (Target item of issued order))
      • For each (Integer Item_Order_Slot) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Item_Order_Class Equal to (Item-class of (Item carried by Item_Order_Unit in slot Item_Order_Slot))
            • Then - Actions
              • Unit - Pause Item_Order_Unit
              • Unit - Order Item_Order_Unit to Stop.
              • Unit - Unpause Item_Order_Unit
            • Else - Actions
"smart" is the name of the Order issued when you try to pick-up an item.
 
Last edited:
Level 3
Joined
Sep 2, 2024
Messages
9
Thank's!
With my english level I confused the "object" (target of order) with "item" (an object IRL).
Now I Know the pick-up item order name.

I really need to learn to use variables. 😅

Thank's again!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Thank's!
With my english level I confused the "object" (target of order) with "item" (an object IRL).
Now I Know the pick-up item order name.

I really need to learn to use variables. 😅

Thank's again!
No problem.

The variables are optional, they just make the trigger more efficient (faster) and can SOMETIMES help avoid bugs.

But people generally avoid using (Integer A) and (Integer B) in For Loops, I've heard bad things about them as well. Although, it's likely just a case of people misusing global variables in general.
 
Last edited:
Level 3
Joined
Sep 2, 2024
Messages
9
I used "Integer A" because it's the only solution I found to take into account any inventory slot without having to add a condition for each one.
 
Top