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

[Trigger] Item class restriction bug

Status
Not open for further replies.
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

Last edited:
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:
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!
 
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:
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.
 
Status
Not open for further replies.
Back
Top