PDA

View Full Version : How to find out the Damage of an item?


infiwow
08-03-2007, 07:04 PM
Hello!

I searched this forum, but didn't find anything related.
Is there any function to find out the damage of an item eg. sword, arrow etc?
The GetItemInfo() function doesn't return the damage...

Stigg
08-03-2007, 07:05 PM
Is there something wrong with hovering your mouse over said item?

EDIT: Didn't see this was in the UI/Mod section...so maybe your question is a bit more detailed than I presumed. Sorry!

Daggermaniac
08-03-2007, 11:40 PM
^^^ lol @ Stigg.

EDIT: Sorry, umm, I don't know anything about that at all (can't make Mods at all!, barely learned how to ues them)

Reknaw
08-03-2007, 11:55 PM
you can get that sort of info from a ToolTip:

myTooltip = CreateFrame("GameToolTip", "myTempTooltip", UIParent, "GameTooltipTemplate");
function getDamage(itemLink)
local minDmg, maxDmg, speed;

myTooltip:SetOwner(UIParent, "ANCHOR_NONE");
myTooltip:ClearLines();
myTooltip:SetHyperlink(itemLink);

_, _, minDmg, maxDmg = string.find(getglobal("myTempTooltipTextLeft4"):GetText(), "^(%d+) . (%d+) Damage");
_, _, speed = string.find(getglobal("myTempTooltipTextRight4"):GetText(), "^Speed (%d*.%d+)");

return tonumber(minDmg), tonumber(maxDmg), tonumber(speed);
end


EDIT: that example uses an itemLink, you can get that out of GetItemInfo(). Also this was meant to get it from a certain item, so i knew it would be on the fourth line of the tooltip, on unique items it would be the fifth line. To make it more generic it wouldnt be too hard to make it iterate over all the tooltip lines until it finds a match.

infiwow
09-03-2007, 12:36 AM
@Reknaw

Many thanks for your answer. That's what I was looking for. I found something similar at www.wowwiki.com. They use this method to get some infos about instant spells.

Rowaa
12-03-2007, 12:43 PM
You also shouldn't use hard-coded English strings and instead reverse appropriate templates from GlobalStrings if you want this function to work on other languages of client besides English.

GoreSpilr
20-03-2007, 02:32 AM
this is just what Ive been trying to do. Once I get the item strings I'm golden. However this code generates an error in moneyframe.lua:185. I disabled all my mods with the same result. Any suggestions?