Return an item's description

Level 15
Aug 7, 2013

What is the native that returns the string which is a given item's (or unit's) description (the text that is produced when the cursor is above an item, e.g. "Restores 500 hit points")?

native function GetItemDescription takes item whichItem returns string
  //returns a string that is the item's text description
There is technically a way to do it, sort of, by reading the wts file. It just isn't a guaranteed method (and I don't know if the optimizer will alter the results).

Tooltips, names, etc. are statically stored within the map's wts file, as are trigger strings that are used in GUI. You can refer to those trigger strings with TRIGSTR_####, but you can also read the other contents of the wts file through this method. See:
(you can extend it beyond 1000, since your map may have more strings than that. Also, the GetLocalizedString() isn't necessary. I think that is mostly used for strings that vary based on language.)

So if you have a keyword, you could perform a linear search to find the description. But I don't quite remember the exact behavior of the string table. I don't remember if it is all ordered, or if it is ordered based on the last edited string, or what. You'll have to experiment. A linear search is obviously very performance-heavy (since it'll be O(n) worst-case), but there are ways to improve it with hashtables (i.e. hash an item to the ### of its trigger string).

As for default items, you can't find them without databasing (store its description under the rawcode of the item).

idk, this may not be that helpful. Someone should really write a script that'll generate a database for a field of your choice. There is one, but I haven't tested it. Perhaps you could give it a go.