• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[General] Detecting When a Unit Tries to Give an Item to another Unit

Status
Not open for further replies.
Level 10
Joined
Sep 3, 2009
Messages
458
We've all done it before.

You right-click on a potion on your inventory, hover your mouse to another hero, then left-click. Your character will then move close to the target hero to attempt to give them the potion.

I've been wondering if there was a way to detect when a unit starts attempting to give an item from it's inventory to another unit. The item hasn't been transferred yet (so no Unit Acquires/Loses Item happens).

I did some digging around if there was a specific order ID for it. I've only seen moveslot order IDs which only works when you transfer an item to a unit's own inventory.
 
Level 21
Joined
Mar 29, 2020
Messages
1,248
I tried detecting this by printing out the current order of the unit when doing this. the only thing I was able to find is that while the unit transfers the item it's order is "dropitem". but this (ordering to give it over) doesn't trigger as an object based or a point based event (nor an instant event). classic blizzard weirdness.

what are you trying to do?
 
Level 10
Joined
Sep 3, 2009
Messages
458
I tried detecting this by printing out the current order of the unit when doing this. the only thing I was able to find is that while the unit transfers the item it's order is "dropitem". but this (ordering to give it over) doesn't trigger as an object based or a point based event (nor an instant event). classic blizzard weirdness.

what are you trying to do?
Wow this is a neat idea how did you do that?

You are right, The Generic Unit Event - Issue order stuff does not detect 'dropitem'. The messy way I tried to detect it is by making a periodic time trigger and catch a specific unit's current order. If it's 'dropitem' it will display a message.

I did some more digging and I found an action called "Unit - Issue Give Item Order" which when triggered orders a specific unit to take an item from it's inventory slot and give it to another unit. The unique thing about it is it makes the unit walk to the target unit and then gives the item, similar to how a player would do it.

When converted to custom script the function is called "call UnitDropItemTargetBJ( Unit, Item, Unit )". I am currently looking for the function definition of this BJ but I can't seem to find a BJ function definition list to investigate on this further.

I'm assuming this triggers the 'dropitem' order. But I'll have to test it. Tested it. UnitDropItemTargetBJ DOES trigger the 'dropitem' order.

---

To answer your question, what I'm trying to do is detect what item is being "given" or "transported" currently before it is actually "acquired" by the target unit. Let's say the item being given is "SWORD". Only SWORDSMAN can have the "SWORD" in it's inventory. Now if the "target unit" is ARCHER it should show an error message "ONLY SWORDSMAN AN USE THIS ITEM" and stop the unit from continuing the transfer. All of this without the ARCHER ever acquiring the item.
 
Level 21
Joined
Mar 29, 2020
Messages
1,248



from a quick search, these all seem to be able to restrict items to specific unit types/hero classes that can use them. Isn't that what you are trying to do?
 
Status
Not open for further replies.
Top