• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Broken Item Level Function

Status
Not open for further replies.
Level 6
Joined
Sep 11, 2006
Messages
172
I've been working on an item system that prevents heroes from picking up more than one type of item. I've set item levels for all my equipment categories, and have tried to set up a trigger that has conditions for the item's level.

  • Mono
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set Item = 0
      • For each (Integer LoopIndex[1]) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item level of (Item carried by (Hero manipulating item) in slot LoopIndex[1])) Equal to (Item level of (Item being manipulated))
            • Then - Actions
              • Set Item = (Item + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item Greater than 1
        • Then - Actions
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Game - Display to (All players) the text: You may only carry ...
        • Else - Actions
      • Trigger - Run Item Check <gen> (ignoring conditions)
The trigger doesn't fire properly at the count item level loop. It wont let me carry more than one item. It returns item levels in the player slots as being the same item level even when they are not.

I put a test message into the trigger to see what the value of the item variable was and it was counting items in the inventory twice. To fix this, I added a function that subtracted 1 from the variable after the inventory count loop. This seemed to work at first until I realized that it was still counting every item I picked up despite its item level.

  • Mono
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set Item = 0
      • For each (Integer LoopIndex[1]) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item level of (Item carried by (Hero manipulating item) in slot LoopIndex[1])) Equal to (Item level of (Item being manipulated))
            • Then - Actions
              • Set Item = (Item + 1)
            • Else - Actions
      • Set Item = (Item - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item Greater than 1
        • Then - Actions
          • Game - Display to (All players) the text: (String(Item))
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Game - Display to (All players) the text: You may only carry ...
        • Else - Actions
      • Trigger - Run Item Check <gen> (ignoring conditions)
So now it's allowing me to pick up 2 of any item even if they are from the same category. Really, all its doing its counting item slots and not repeats of the same item level.

The condition
  • (Item level of (Item carried by (Hero manipulating item) in slot LoopIndex[1])) Equal to (Item level of (Item being manipulated))
is passing for any item and then adding 1 to the item count integer when it is actually only supposed to add 1 if the item in question is in the same category (item level) as the item being picked up.
 
Level 6
Joined
Sep 11, 2006
Messages
172
That had the same end result as the second trigger. I'm still able to carry two swords or two shields. The function doesn't see item levels, only items.

It's possible that my map broke something.

Is there a JASS function that might help me?
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
Show the "Item Check" trigger aswell please.

And all other triggers with the event of picking up / dropping an item.

Also, change the condition inside the loop to this:

  • (Item level of (Item carried by (Hero manipulating item) in slot LoopIndex[1])) Equal to (Item level of (Item being manipulated))
  • Item carried by (Hero manipulating item) in slot LoopIndex[1] not Equal to (Item being manipulated)
Then change the
  • Item Greater than 1
to
  • Item Greater than 0
Also, what is the actual item level of the items you are trying to stack in the OE?
 
Level 12
Joined
May 22, 2015
Messages
1,051
Use debug messages on the item levels.

I think items have two fields for levels, so maybe it's using the one you are not setting. I think one is like 'Level - #' and the other one is 'Level (Unclassified) - #'. I'd check, but can't right now.
 
Level 6
Joined
Sep 11, 2006
Messages
172
Also, change the condition inside the loop to this:

(Item level of (Item carried by (Hero manipulating item) in slot LoopIndex[1])) Equal to (Item level of (Item being manipulated))
Item carried by (Hero manipulating item) in slot LoopIndex[1] not Equal to (Item being manipulated)

Then change the
Item Greater than 1
to
Item Greater than 0

I tried this. Now it only let's me carry one kind of item. If I get a sword, it won't let me pick up a shield or anything that isn't a sword.

Item Level 1 = Sword

Item Level 4 = Shield

Item Level 5 = Bow

  • Mono
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item level of (Item being manipulated)) Not equal to 0
    • Actions
      • Set Item = 0
      • For each (Integer LoopIndex[1]) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LoopIndex[1] Less than 6
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item level of (Item carried by (Hero manipulating item) in slot LoopIndex[1])) Equal to (Item level of (Item being manipulated))
                  • (Item carried by (Hero manipulating item) in slot LoopIndex[1]) Not equal to (Item being manipulated)
                • Then - Actions
                  • Set Item = (Item + 1)
                • Else - Actions
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item Greater than 0
        • Then - Actions
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Matching player))) the text: You may only carry ...
        • Else - Actions
      • Trigger - Run Item Check <gen> (ignoring conditions)
  • Item Check
    • Events
    • Conditions
    • Actions
      • -------- --------------------Knight Items------------------------ --------
      • -------- - --------
      • -------- ----------Weapons------------ --------
      • -------- 1 --------
      • -------- Arming Sword --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Arming Blade
          • (Unit-type of (Hero manipulating item)) Not equal to |cffffd700Hero|r
        • Then - Actions
          • Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Matching player))) the text: |cff99b4d1Knight Cl...
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Skip remaining actions
        • Else - Actions
      • -------- Steel Longsword --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff99b4d1Steel Longsword|r
          • (Unit-type of (Hero manipulating item)) Not equal to |cffffd700Hero|r
        • Then - Actions
          • Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Matching player))) the text: |cff99b4d1Knight Cl...
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Skip remaining actions
        • Else - Actions
      • -------- --------------------Huntress Items------------------------ --------
      • -------- - --------
      • -------- ----------Weapons------------ --------
      • -------- 1 --------
      • -------- Wooden Bow --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Wooden Bow
          • (Unit-type of (Hero manipulating item)) Not equal to |cffffd700Hero|r
        • Then - Actions
          • Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Matching player))) the text: |cff9acd32Huntress ...
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Skip remaining actions
        • Else - Actions
      • -------- --------------------LB Items------------------------ --------
      • -------- - --------
      • -------- ----------Weapons------------ --------
      • -------- 1 --------
      • -------- Hammer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Hammer
          • (Unit-type of (Hero manipulating item)) Not equal to |cffffd700Hero|r
        • Then - Actions
          • Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Matching player))) the text: |cffff8c00Line Brea...
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Skip remaining actions
        • Else - Actions
      • -------- --------------------NC Items------------------------ --------
      • -------- - --------
      • -------- ----------Weapons------------ --------
      • -------- 1 --------
      • -------- Basic Wand --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Primitive Scepter
          • (Unit-type of (Hero manipulating item)) Not equal to |cffffd700Hero|r
        • Then - Actions
          • Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Matching player))) the text: |cff8a2be2Night Cal...
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Skip remaining actions
        • Else - Actions
      • -------- --------------------Runner Items------------------------ --------
      • -------- - --------
      • -------- ----------Weapons------------ --------
      • -------- 1 --------
      • -------- Glaive --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Moonstone
          • (Unit-type of (Hero manipulating item)) Not equal to |cffffd700Hero|r
        • Then - Actions
          • Game - Display to (All players matching ((Owner of (Hero manipulating item)) Equal to (Matching player))) the text: |cff99b4d1Runner Cl...
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Skip remaining actions
        • Else - Actions
The first trigger is the one that is firing because I can see the "You may only carry one of these items." string, which only fires in the first trigger called "Mono"

The second trigger actually works. If I pick up an item meant for another class, it gets dropped and the appropriate message is seen.

I think items have two fields for levels, so maybe it's using the one you are not setting. I think one is like 'Level - #' and the other one is 'Level (Unclassified) - #'. I'd check, but can't right now.

Which one am I supposed to use?

UPDATE: Solved. It's like SAUS said. There are two item levels. All of my items were set to 3. Thank you.
 
Last edited:
Status
Not open for further replies.
Top