Get Item Icon issue

I’m working on this script, for TrinityCore 7.x f and I’m looking for a way to retrieve the icon of an item.

For example for item item 128476 I should find the icon | TInterface / ICONS / inv_knife_1h_artifactfangs_d_01

if (ItemTemplate const* proto = pitem->GetTemplate())
{
std::ostringstream icon;
icon << “|TInterface”;

ItemEntry const* dispInfo = sItemStore.LookupEntry(128476);
if (dispInfo)
	icon << "/ICONS/" << here function to get item icon;
else
	icon << "/InventoryItems/WoWUnknownItem01";

icon << ":30:30:-18:0 << |t";
return icon.str().c_str();

}

Thank you for your support

This is not possible anymore, item icons have been migrated to using FileDataId, there is no mapping it back to a string.

That’s what I feared. Can I get at least the id of the filedata, if so what is the function please?

Thank for your answer Shauren.

You need to access IconFileDataID from ItemAppearanceEntry

sample code

ItemModifiedAppearanceEntry const* itemModifiedAppearance = item->GetItemModifiedAppearance(); if (ItemAppearanceEntry const* itemAppearance = sItemAppearanceStore.LookupEntry(itemModifiedAppearance->AppearanceID)) itemAppearance->IconFileDataID // do your thing

Hmm, but couldnt you just edit mapextractor to extract the filedata file (doesnt look like it does atm) and then load it in the core and then do like this? Or similar.

std::string myfun(Item* item) { std::ostringstream icon; icon << "|TInterface"; ItemModifiedAppearanceEntry const* itemModifiedAppearance = item->GetItemModifiedAppearance(); if (ItemAppearanceEntry const* itemAppearance = sItemAppearanceStore.LookupEntry(itemModifiedAppearance->AppearanceID)) if (auto const* data = sItemFileDataStore.LookupEntry(itemAppearance->IconFileDataID)) return (icon << "/ICONS/" << data.filename << ":30:30:-18:0 << |t").str(); icon << "/InventoryItems/WoWUnknownItem01"; icon << ":30:30:-18:0 << |t"; return icon.str(); }
I mean … the client has to know which file the ID links to or it wouldnt be able to show anything as the icon. And the DBC files probably have that info. And if you have the ID and the DBC files, then you would be enabled to get the icon.
Ofcourse if the info cant be extracted then there is a bit of trouble…
Or if the client no longer supports showing images (specifically item icons) with the texture link path…

@Rochet2 no. Files in CASC can be opened both by FileDataId and by path (you do not need a id<->path mapping)

Thanks for your answer I 'll check all of that