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

"Count Items of Type Carried by Hero" Condition

Status
Not open for further replies.
Level 7
Joined
Jul 1, 2008
Messages
1,025
I need something that detects when a hero has 2 of the same item and drops one of them.

I have an item that gives permanent invisibility, only problem is when a hero gets two of these he comes perma PERMA invisibility. Can not be detected even when attacking, this is obviously easily exploitable. So how can I limit heroes to only 1 type of this item?

A "Count Items of Type Carried by Hero" integer condition would be ideal but I cant see anything like that!
 
Level 9
Joined
Jul 10, 2011
Messages
562
when a hero picks up an item loop through the inventory an whenever theres an ite m of that item set an integer value +1. at the end check whether the integer value is 2 or more and if so drop the item picked up.
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
errrm how I do that? :S

This is what I got so far but i dont know how to "loop through an inventory"?

  • Cloak of Lies 1 Only
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to (==) Cloak of Lies
    • Actions
      • Set DropItemPlayer = (Owner of (Triggering unit))
      • Player Group - Add DropItemPlayer to DropItemPlayerGroup
      • Hero - Drop (Item carried by (Triggering unit) of type Cloak of Lies) from (Triggering unit)
      • Game - Display to DropItemPlayerGroup the text: Only 1 type of this...
      • Wait 1.00 seconds
      • Player Group - Remove DropItemPlayer from DropItemPlayerGroup
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
try this its easier.

  • awesome trigger
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
            • Then - Actions
              • Hero - Drop (Item being manipulated) from (Hero manipulating item)
            • Else - Actions
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
Its work but abit too well! It drops even when hero dosnt have any other items of that type on him. What am I doing wrong? Sorry I'm so rubbish with triggers.

  • Cloak of Lies 1 Only
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to (==) (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
            • Then - Actions
              • Set DropItemPlayer = (Owner of (Triggering unit))
              • Player Group - Add DropItemPlayer to DropItemPlayerGroup
              • Hero - Drop (Item carried by (Triggering unit) of type Cloak of Lies) from (Triggering unit)
              • Game - Display to DropItemPlayerGroup the text: Only 1 type of this...
              • Wait 1.00 seconds
              • Player Group - Remove DropItemPlayer from DropItemPlayerGroup
            • Else - Actions
 
Level 9
Joined
Jul 10, 2011
Messages
562
1. you have to do the following :

-you add a integer variable before the integer A loop and set it to 0
-on the then actions you set the integer value to (integer value +1)
-then you add the action you have in then at the moment in another if/then/else inside of the then action but after the set of the integer value
-to the if of this if/then/else you check whether the integer value is equal or higher than 2
-to the then actions you add your actions (even though i dont understand the player group and the wait but...)


and thats it ;D

p.s. in the way chaosy posted it even recognizes the item thats is picked up so there is this item everytime and so the item is dropped automatically.
 
Level 9
Joined
Jul 10, 2011
Messages
562
just add what i said to chaosys trigger ^^ his has just the problem that it recognizes the item that is picked up and compares it to itself so it drops it everytime....so and to avoid that you have to add what i said ^^
 
Level 9
Joined
Jul 10, 2011
Messages
562
wait a mom ill do an example

EDIT: here it is...:D

  • item drop
    • Events
      • Unit - A unit Acquires an Item
    • Conditions
    • Actions
      • Set TempInteger = 0
        • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Conditions
                • (Item-type of (Item being manipulated)) Equal to (==) (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
              • 'THEN'-Actions
                • Set TempInteger = (TempInteger + 1)
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Conditions
                      • TempInteger Equal to/Greater than (>=) 2
                    • 'THEN'-Actions
                      • Hero - Drop (Item being manipulated) from (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) the text: BlaBlaBla
                      • Skip remaining actions
                    • 'ELSE'-Actions
              • 'ELSE'-Actions
 
Level 4
Joined
Jul 16, 2012
Messages
42
  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot (Integer A)) Not equal to (Item being manipulated)
              • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
            • Then - Actions
              • Hero - Drop (Item being manipulated) from (Triggering unit)
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You may only have o...
            • Else - Actions
This should work. ^^
EDIT: Btw, you ofc need to clear leaks.
 
Status
Not open for further replies.
Top