• 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] How to limit items one unit can have?

Status
Not open for further replies.
Level 6
Joined
Feb 16, 2014
Messages
193
I'm making a shooter kind of map and i want to make a unit only have 1 type of item:
Example: A unit can only have 1 Potion of healing item at once and cant have 2.
How do i do that ? do i have to create a trigger for that ? :vw_wtf: :ogre_rage:
 
Event: Unit aquires item
Condition: Check for your itemType
Actions:
Use the ForEachInteger function to loop from 1-6:
Set tmpItem = Item Carried By TriggeringUnit in Slot[LoopIndex]
Then check if ItemTypeOf(tmpItem) == yourItemType AND tmpItem != ItemBeingManipulated.
If both are true, then drop ItemBeingManipulated from unit.

tmpItem is a item variable
 
Level 6
Joined
Feb 16, 2014
Messages
193
Like this ?
  • Item Limit
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Health Artifact(+50)
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set tmpitem = (Item carried by (Triggering unit) in slot (Integer A))
      • Set tmpitem = (Item being manipulated)
      • Unit - Order (Triggering unit) to drop tmpitem at (Position of (Triggering unit))
 
Level 6
Joined
Feb 16, 2014
Messages
193
I don't know if i did this right:
  • Item Limit
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set tempitem = (Item carried by (Triggering unit) in slot (Integer A))
      • Set tempitem = (Item being manipulated)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item carried by (Triggering unit) in slot 1)) Equal to Health Artifact(+50)
          • (Number of items carried by (Triggering unit)) Equal to 1
          • tempitem Equal to (Item being manipulated)
          • tempitem Equal to (Item carried by (Triggering unit) in slot 1)
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Unit - Order (Triggering unit) to drop tempitem at (Position of (Triggering unit))
        • Else - Actions
 
No, look. Like this:
  • Events
    • Unit - A Unit quires Item
  • Conditions
    • (Item-type of (Item being manipulated)) Equal to Health Artifact(+50)
  • Actions
    • Set u = TriggeringUnit
    • For each i from 1 to 6, do (Actions)
      • Set item = (Item carried by (u) in slot (i))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemType of item Equals Health Artifact(+50)
          • item Not Equals ItemBeingManipulated
        • Then - Actions
          • Hero - Drop ItemBeingManipulated for u
        • Else - Actions
u is a unit type variable
i is integer variable, I use LoopWithIntegerVariable instead of LoopWithIntegerA/B
 
Status
Not open for further replies.
Top