#Possible to detect when an item is "upgraded"?

1 messages · Page 1 of 1 (latest)

sweet saddle
#

What I mean by "upgraded" is when the base level of the item increases from 1>2. For example item_test becomes item_test_2, or item_test_2 becomes item_test_3, and so on. They use the same base class in the code so essentially it's much like an ability gaining a level, since they also contain the ItemBaseLevel key.

Is there a way to detect this on a global level? There seem to be no order for assembling items and such, so both that and the inventory filter is of little use. For example, the order filter will only detect the last item that you purchase/pick up, whether it's the recipe or some of the other components to the item. The inventory filter also does not detect when anything leaves the inventory and acts in a similar way.

It's probably not possible to do this at all but I guess I'm still curious if there's any hope.

shy jungle
#

afaik there is no event that detects items being built from components.

#

best i can think of is either:
periodically tracking what items they have and determining yourself if one of them increased in level.
or:
keeping track of their inventory using events/filters for any item move/buy/drop/etc and determining if their new item will build a recipe

#

for the latter option you would have to read from the items kv just once and make a table of every recipe

#

problem with recipe tracking is couriers also dont have any kind of event for when they finish delivering items afaik.

shadow drum
#
local item = ... 
local level = tonumber(item:GetAbilityKeyValues().ItemBaseLevel)
OR
local item_name = "item_test_2"
local level = tonumber(GetAbilityKeyValuesByName(item_name))
OR
local item_name = "item_test_2"
local level = tonumber(string.sub(item_name, string.len(item_name)))
#

I think Dankbud mentioned in some other thread: storing lvls on the hero and then in Spawn() checking item level.

sweet saddle
#

I ended up just creating a timer to compare your current inventory to another table that stores an older inventory, and if an entity index suddenly is nil, I just remove it from other tables where it's used