Find out if an item is in the ground or in the inventory?

Using heartlib I am adding scripts for heartbeats on certain items to have them “decay” (be deleted/garbage collected). This is as much to keep the world free from a bunch of clutter dropped by players as it is any performance concern. Anyone who’s played on a PW probably has an inkling of what I mean.

Right now the pesudo-heartbeat works, but it has no concept of where the item is, deleting it irrespective of location. I would like it only to work if the item is placed on the ground, rather than in a container, or a players inventory.

Is there a way to easily determine if the item is not in an inventory? I did look through the function list but didnt see anything at a glance, but I concede that I could have easily missed something. Wouldn’t be the first time!

Maybe something like: return (!GetHasInventory(GetItemPossessor(oItem)));

1 Like

Exactly, “something like”… :slight_smile:

GetItemPossessor(oItem) returns OBJECT_INVALID, if the Item is lying on the ground.

AddOn: GetNearestObjectByTag will not work, if the item is within a container.

2 Likes

Hmm, blonde moment: I didn’t think of looking of the negation case. Thanks!