# [Solved]Drop items if they have same custom value [Reforged]

Level 9
I have searched the forum for a good 60 minutes now. Didn't find the answers I wanted.

What I want to do is drop the item if the hero is already carrying an item with same custom value.

Now it always drops the item == meaning the hero can never carry an item with custom value of 1.

• Weapon
• Events
• Unit - A unit Acquires an item
• Conditions
• Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Custom value of (Item being manipulated)) Equal to 1
• Then - 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
• (Custom value of (Item being manipulated)) Equal to (Custom value of (Item carried by (Triggering unit) in slot (Integer A)))
• Then - Actions
• Hero - Drop (Item being manipulated) from (Triggering unit).
• Game - Display to (All players) the text: |cffff0000Warning:|...
• Else - Actions
• Else - Actions

#### Uncle

Level 24
It's comparing custom values with itself, so it will always drop.

Add a condition: Item being manipulated NOT equal to Item carried in slot Integer A

Level 9
Add a condition: Item being manipulated NOT equal to Item carried in slot Integer A

Yes then it will not allow to have items with same custom value, but It will allow the hero to have the exact same item multiple times.

Example:
Picks up Hammer
Can't pick up Axe --> Item drops
Picks up Hammer --> Item does not drop

So now the hero has 2 hammers.

#### Uncle

Level 24
Okay, then you just need more conditions.

If Item-type of item being manipulated equal to Item-type of item carried by hero in slot Integer A then drop item

• example
• 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
• Or - Any (Conditions) are true
• Conditions
• (Custom value of (Item being manipulated)) Equal to (Custom value of (Item carried by (Triggering unit) in slot (Integer A)))
• (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).
• Else - Actions

Level 9
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Custom value of (Item being manipulated)) Equal to 1
• Then - 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
• (Custom value of (Item being manipulated)) Equal to (Custom value of (Item carried by (Triggering unit) in slot (Integer A)))
• (Item-type of (Item being manipulated)) Not equal to (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
• Then - Actions
• Hero - Drop (Item being manipulated) from (Triggering unit).
• Else - Actions
• Game - Display to (All players) the text: |cffff0000Warning:|...
• 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 (Triggering unit) in slot (Integer A)))
• Then - Actions
• Hero - Drop (Item being manipulated) from (Triggering unit).
• Game - Display to (All players) the text: |cffff0000Warning:|...
• Else - Actions
• Else - Actions
Nope, couldn't get it right

#### Uncle

Level 24
I have a triggered example in my above comment if you didn't notice.

Also, you can add (Custom value of (Item being manipulated)) Equal to 1 to the main Conditions. And by main I mean the Conditions located below Events, not inside the If Then Else.

Level 9
Yeah I tried with your example, it results in the unit not being able to carry the item at all. I'm so lost with this one.

#### Uncle

Level 24
Ah, I didn't think about that. So all we need to do is adjust our conditions to take that into consideration:

• example
• 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 being manipulated) Not Equal to (Item carried by (Triggering unit) in slot (Integer A))
• Or - Any (Conditions) are true
• Conditions
• (Custom value of (Item being manipulated)) Equal to (Custom value of (Item carried by (Triggering unit) in slot (Integer A)))
• (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).
• Else - Actions

Level 9
Yay, it works! Thanks once again uncle =)

Level 9
@Uncle can you help me with one more thing?

Need almost the same thing, but with custom values being different.

Custom Value 1 = Main-Hand Weapon
Custom Value 2 = Off-Hand Weapon
Custom value 3 = Two-Handed weapon

So if the hero has a weapon with custom value 1 or 2 == It cannot equip an item with custom value 3.

And if the hero has a weapon with custom value 3 == It cannot equip an item with custom value 1 or 2.

#### Uncle

Level 24
I would use a Unit Indexer in combination with an Item Indexer to keep track of the different states of these items/units.

Then you could have boolean variables to keep track of item categories and whether or not units have these items equipped.

Booleans associated with units:

hasWep[custom value of unit] = True/False
hasMainHandWep[custom value of unit] = True/False
hasOffHandWep[custom value of unit] = True/False
hasTwoHandWep[custom value of unit] = True/False

Booleans associated with items:

isWeapon[custom value of item] = True/False
isMainHandWep[custom value of item] = True/False
isOffHandWep[custom value of item] = True/False
isTwoHandWep[custom value of item] = True/False

Rough idea off the top of my head:
• Events:
• A unit acquires an item
• Conditions:
• isWeapon[custom value of item being manipulated] = True
• Actions:
• Set item_cv = Custom value of item being manipulated
• Set unit_cv = Custom value of hero manipulating item
• If isTwoHandWep[item_cv] = True and hasWep[unit_cv] = True then:
• Drop Item
• Skip remaining actions
• Else
• If isMainHandWep[item_cv] = True and hasMainHandWep[unit_cv] = True then:
• Drop Item
• Skip remaining actions
• Else
• If isOffHandWep[item_cv] = True and hasOffHandWep[unit_cv] = True then:
• Drop Item
• Skip remaining actions
• ------ If the item wasn't dropped then apply the necessary variables ------
• Set hasWep[unit_cv] = True
• If isTwoHandWep[item_cv] = True then:
• Set hasTwoHandWep[unit_cv] = True
• Else
• If isMainHandWep[item_cv] = True then:
• Set hasMainHandWep[unit_cv] = True
• Else
• If isOffHandWep[item_cv] = True then:
• Set hasOffHandWep[unit_cv] = True
item_cv is an Integer variable that's set to the custom value of the item being manipulated
unit_cv is an Integer variable that's set to the custom value of the hero manipulating the item

You would also need to set the Item booleans upon item creation:
• Create 1 Claws of Attack
• Set item_cv = Custom value of last created item
• Set isMainHandWep[item_cv] = True
• Set isWep[item_cv] = True
Additionally, when the unit loses the Item you need to set the matching hasX variable to False. So if it loses it's Main Hand Weapon, set hasMainHandWep[unit_cv] = False.
Also, adjust hasWep[unit_cv] if it no longer has any Weapons equipped. For example, if it loses it's Main Hand Weapon it may still have an Off Hand Weapon so you would need to check for that before setting hasWep[unit_cv] to False.

With this setup you'd have full control over everything. Want to know if an Item is an Off Hand? Simply check if isOffHandWep[custom value of item] is True. Same goes for checking if a Unit has an Item of a certain category.

Long story short, it offers a lot more flexibility, which may or may not be worth it depending on your map.

Last edited:

Level 9
Alright, I will try my best with your suggestions. I will marked this solved for now, since you already helped with my original issue.

+rep to you as always. A truly helpful person you are.

Replies
8
Views
535
Replies
3
Views
100
Replies
5
Views
398
Replies
5
Views
734
Replies
6
Views
638