• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to level of item from item id?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

Is there a way to get the level of an item based on its integer id?

Otherwise, do we have to create a dummy item--how does this sound (and leakless too I hope..)?

JASS:
function GetItemLevelById takes integer itemID returns integer
  local item i = CreateItem(itemId, X, Y)
  local integer level = GetItemLevel(i)
  call RemoveItem(i)
  set i = null
  return level
endfunction
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
But if you need to do these level checks very frequently you should cache them in a hashtable.

Already doing that basically. I should only have to calculate the level of each item type once, then I'll store it away.

Thanks for the responses--wasn't sure if there was a native or a better way (besides hardcoding it in).
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Well one more thing: if you are generating the itemtypes you could try to pass the respective values from the objectgenerator to the map script. Im not sure how convenient this is with vJass and ObjectMerger/LUA, but with WurstScript its very simple.
 
Status
Not open for further replies.
Top