Tracking down item.

Cohadar

master of fugue
Reaction score
209
At some point I save a handle of some item.
After 60 sec I want to know where is that item.

If it is being carried by a unit I want to know which unit.
If it is on the ground I want to know x and y.

Anyone knows how to do this without ForGrouping all units on the map with UnitHasItem check?
 

Builder Bob

Live free or don't
Reaction score
249
Can't you just attach a struct with that information to the item handle id?

When a unit acquires an item, set a unit variable in the struct to the unit acquiring the item. When dropping the item, change the unit to null so you know it's on the ground, etc (include all events that change where the item will be)
 

Vassilev

New Member
Reaction score
39
local item (variable)
TriggerSleepAction(60)
if item is with unit then
call get the unit Id
else GetItem X and Y

well... I hope thats what you want :p very simple trigger
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
For checking where they are if not carried:

Try something like GetItemX and GetItemY and if those return anything but 0, you know it's on the ground. Only fails if the item is exactly at (0,0), which is highly unlikely.


For anything else: RingBuffer or attaching a struct is indeed the way to go
 

Builder Bob

Live free or don't
Reaction score
249
I guessed that you didn't want to do it the way I suggested Cohadar, cause you would already know how to do that.

I'll let you know if I think of something else.


---
GetItemX and GetItemY returns the coordinates of the last position of the item before it was picked up by the way. It looks as if the game just hides the item when someone picks it up, so you can use the test IsItemHidden (or IsItemOwned) to see if it has been picked up. Not that it helps determining who has it though...


Edit: It appears that you can make the current owner of an item drop the item in question by using the function SetItemPosition. So if IsItemOwned(i) == true, SetItemPosition(i, 0., 0.) will make a unit drop the item. You can then use the EVENT_PLAYER_UNIT_DROP_ITEM to get the unit that owned the item.

Now your next problem is that your unit has lost the item... Unfortunately you cannot use UnitAddItem() directly from the UNIT_DROP_ITEM event to give the item back. Another problem is that you won't know which slot the item was in before it was dropped. Maybe it can be useful for you somehow though. You never know.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top