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

[Trigger] Unique item equipped

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hi

I will try to keep it short. In my map I want a loot system which allows the player to have:

1:
One piece of helmet, armor and misc.

2:
A one-handed weapon and a shield, 2 one-handed or 1 two-handed.

3:
I have made attachable models for each weapon and by default all item drops will be left handed. However, what I want is when you have a one-handed (left-handed) equipped, and equip yet another one-handed weapon, it will be removed and exchanged by a right-handed weapon. I have made clones of each one-handed weapon to make this possible. This must not accour if the Hero has a shield, a two-handed weapon or already has 2 one-handed weapons equipped.

So far I have tried myself, but I find it difficult to see how to solve this trigger.

This trigger does NOT work:
  • Weapon Item Levels
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item level of (Item being manipulated)) Equal to 1
          • (Item level of (Item being manipulated)) Equal to 2
      • (Item-type of (Item being manipulated)) Not equal to Captain Vanguard
      • (Item-type of (Item being manipulated)) Not equal to Druid Buckler
      • (Item-type of (Item being manipulated)) Not equal to Necromancer Bulwark
    • Actions
      • Set Item_Limiter = 0
      • Set Item = (Item being manipulated)
      • Set Item_Level = (Item level of Item)
      • Set Item_TriggeringUnit = (Triggering unit)
      • Set Item_UnitInventory = (Size of inventory for Item_TriggeringUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item level of Item) Equal to 1
        • Then - Actions
          • For each (Integer Item_Loop) from 1 to Item_UnitInventory, 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 Item_TriggeringUnit in slot Item_Loop)) Equal to 1
                • Then - Actions
                  • Set Item_Limiter = (Item_Limiter + 1)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Item_Limiter Greater than 1
            • Then - Actions
              • Set Item_Limiter = 0
              • For each (Integer Item_Loop) from 1 to Item_UnitInventory, 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 Item_TriggeringUnit in slot Item_Loop)) Equal to 2
                    • Then - Actions
                      • Set Item_Limiter = (Item_Limiter + 1)
                    • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Item_Limiter Greater than 1
                • Then - Actions
                  • Hero - Drop Item from Item_TriggeringUnit
                  • Game - Display to (Player group((Owner of Item_TriggeringUnit))) for 2.00 seconds the text: You are already wea...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of Item) Equal to Anvil Hammer (Left)
                    • Then - Actions
                      • Hero - Create Anvil Hammer (Right) and give it to Item_TriggeringUnit
                    • Else - Actions
                  • Item - Remove Item
            • Else - Actions
        • Else - Actions

Second attempt (does not work either):
The problem here is for some reason it will not create an item for the Hero, but just acquires the item that was looted in the first place...

  • Weapon Item Levels
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item level of (Item being manipulated)) Equal to 1
          • (Item level of (Item being manipulated)) Equal to 2
          • (Item level of (Item being manipulated)) Equal to 3
      • (Item-type of (Item being manipulated)) Not equal to Captain Vanguard
      • (Item-type of (Item being manipulated)) Not equal to Druid Buckler
      • (Item-type of (Item being manipulated)) Not equal to Necromancer Bulwark
    • Actions
      • Set Item_HandLeft = 0
      • Set Item_HandRight = 0
      • Set Item_HandTwo = 0
      • Set Item = (Item being manipulated)
      • Set Item_Level = (Item level of Item)
      • Set Item_TriggeringUnit = (Triggering unit)
      • Set Item_UnitInventory = (Size of inventory for Item_TriggeringUnit)
      • -------- --------
      • -------- Count Items --------
      • -------- --------
      • For each (Integer Item_Loop) from 1 to Item_UnitInventory, 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 Item_TriggeringUnit in slot Item_Loop)) Equal to 1
            • Then - Actions
              • Set Item_HandLeft = (Item_HandLeft + 1)
            • Else - Actions
      • For each (Integer Item_Loop) from 1 to Item_UnitInventory, 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 Item_TriggeringUnit in slot Item_Loop)) Equal to 2
            • Then - Actions
              • Set Item_HandRight = (Item_HandRight + 1)
            • Else - Actions
      • For each (Integer Item_Loop) from 1 to Item_UnitInventory, 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 Item_TriggeringUnit in slot Item_Loop)) Equal to 3
            • Then - Actions
              • Set Item_HandTwo = (Item_HandTwo + 1)
            • Else - Actions
      • -------- --------
      • -------- Give Item --------
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item_HandRight Greater than or equal to 1
          • Item_HandLeft Equal to 0
          • Item_HandTwo Equal to 0
          • (Item level of Item) Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of Item) Equal to Anvil Hammer (Left)
            • Then - Actions
              • Hero - Create Anvil Hammer (Right) and give it to Item_TriggeringUnit
            • Else - Actions
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • -------- Drop Item --------
      • -------- --------

I have already made it work with the armor and shield triggering, since I have asked this type of question before. :)

This trigger works:
  • Armor and Shield Item Levels
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item level of (Item being manipulated)) Equal to 3
          • (Item level of (Item being manipulated)) Equal to 4
          • (Item level of (Item being manipulated)) Equal to 5
          • (Item-type of (Item being manipulated)) Equal to Captain Vanguard
          • (Item-type of (Item being manipulated)) Equal to Druid Buckler
          • (Item-type of (Item being manipulated)) Equal to Necromancer Bulwark
    • Actions
      • Set Item_Limiter = 0
      • Set Item = (Item being manipulated)
      • Set Item_Level = (Item level of Item)
      • Set Item_TriggeringUnit = (Triggering unit)
      • Set Item_UnitInventory = (Size of inventory for Item_TriggeringUnit)
      • For each (Integer Item_Loop) from 1 to Item_UnitInventory, 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 Item_TriggeringUnit in slot Item_Loop)) Equal to Item_Level
            • Then - Actions
              • Set Item_Limiter = (Item_Limiter + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item_Limiter Greater than 1
        • Then - Actions
          • Hero - Drop Item from Item_TriggeringUnit
          • Game - Display to (Player group((Owner of Item_TriggeringUnit))) for 2.00 seconds the text: You are already wea...
        • Else - Actions
 
Last edited:
Level 13
Joined
Jul 15, 2007
Messages
763
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Item level of Item) Equal to 1
    • Then - Actions
      • For each (Integer Item_Loop) from 1 to Item_UnitInventory, 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 Item_TriggeringUnit in slot Item_Loop)) Equal to 1
            • Then - Actions
              • Set Item_Limiter = (Item_Limiter + 1)
            • Else - Actions
I noted that your trigger's conditions check for items of level 1 or 2, but the main body of your trigger only reacts to items of level 1. Could that be why?
 
Level 8
Joined
Jun 13, 2010
Messages
344
I noted that your trigger's conditions check for items of level 1 or 2, but the main body of your trigger only reacts to items of level 1. Could that be why?

Well, obviously the trigger does not work, but this part here should be alright. It has to verify the level 1 item (being a one-handed weapon) and the next action just detects if the unit already has a level 1 or 2 item (level 2 being an off-hand).
 
Level 13
Joined
Jul 15, 2007
Messages
763
Oh ok, that makes sense i guess if you're picking up only the (left) hand weapon. And assuming that "trigger does not work" means you're not getting the intended effects of the trigger (as opposed to trigger not firing at all):
  1. Unit picks up left handed weapon.
  2. Your first nested if/then/else just checks to see if the unit already has a Left Handed weapon, and if so, puts the Item_Limiter up by 1.
  3. And nested within that, the next if/then/else checks to see if the unit already has a Right Handed weapon, and that puts the Item_Limiter up by 1, (after resetting Item_Limiter to 0)
  4. And the next ITE that runs after that drops the item (because the unit has a Left Handed and Right Handed weapon), or gives it a Right Handed weapon (because it already has a Left Hander)
But i cannot see how Item_Limiter would ever be Greater Than 1? I mean, the unit would have to be holding two items of the same item level for your condition to ever work, and i thought they can only hold 1? But you say your other trigger works fine that seems to use this so maybe there's more context missing or something...

I dunno, i tried to understand it :p

P.S. For debugging purposes, don't leave blank 'Else's', a simple debug message will help you find where the trigger doesn't work as you think it does
 
Level 8
Joined
Jun 13, 2010
Messages
344
But i cannot see how Item_Limiter would ever be Greater Than 1?
There might be an easier or clean way to do this. I am just experimenting as I go, but I can't really seem to find out what to do. :/

P.S. For debugging purposes, don't leave blank 'Else's', a simple debug message will help you find where the trigger doesn't work as you think it does
Ye, I usually do this, just didn't want to make it more confusing for people here to read. :)
 
Status
Not open for further replies.
Top