Thread Tools Display Modes
10-11-05, 11:56 AM   #1
ProfOak
A Cyclonian
Join Date: Oct 2005
Posts: 47
Buff/DeBuff Detection Help... kinda desperate here :(

Hi

I'm trying to find a way to detect a buff/debuff type (i.e. Poison, Curse, etc).
I know that there are 2 functions, UnitBuff(target) and UnitDebuff(target), but they use the buff texture, which might not have the sub string i'm looking for (ex. Mark of the Wild = Spell_Nature_Regeneration).

I know that the tooltip have that kind of info but i have no clue on how to use the tooltip.
How can i get access to the tooltip or there's another way to know the buff type?

I really need help, searched all over the place but i'm still in the dark here.

Thks in advance
  Reply With Quote
10-11-05, 12:24 PM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
Yeah scanning tooltips is a popular method for determining if a buff/debuff is "Magic", "Poison", etc. Scanning tooltips is basically these steps:

1. Make a custom tooltip: In your XML, make a custom tooltip like this:

<GameTooltip name="MyMod_TooltipScan" inherits="GameTooltipTemplate" parent="UIParent" hidden="true"/>

While this can go anywhere, I generally put it outside the normal "Frames" of my mod, where you define templates and stuff:

<Ui>
<Script file="MyMod.lua"/>
<GameTooltip name="MyMod_TooltipScan" inherits="GameTooltipTemplate" parent="UIParent" hidden="true"/>
<Frame name="MyMod_Frame">
<Size>
etc

2. Use a GameTooltip widget to write a tooltip to your custom one: You can see a list here: http://www.wowwiki.com/Widget_API#GameTooltip All the GameTooltip:Set(something) constructs a tooltip. There's a lot of them as you can see. At the bottom are two you'd be interested in:
GameTooltip:SetUnitBuff("unit",buffIndex) - Shows the tooltip for a unit's buff.
GameTooltip:SetUnitDebuff("unit",buffIndex) - Shows the tooltip for a unit's debuff.
In your code, when you want to scan the tooltip:

MyMod_TooltipScan:SetUnitDebuff("player",1) -- create tooltip for first debuff on player

Now MyMod_TooltipScan is a hidden copy of the tooltip you'd see for that buff.

3. Read what's on the tooltip: GameTooltip (and any GameTooltips that inherit its template) have 30 rows and two columns:

GameTooltipTextLeft1 GameTooltipTextRight1
GameTooltipTextLeft2 GameTooltipTextRight2
GameTooltipTextLeft3 GameTooltipTextRight3
GameTooltipTextLeft4 GameTooltipTextRight4
etc

Replace GameTooltip with MyMod_TooltipScan:

MyMod_TooltipScanTextLeft1 MyMod_TooltipScanTextRight1
MyMod_TooltipScanTextLeft2 MyMod_TooltipScanTextRight2
MyMod_TooltipScanTextLeft3 MyMod_TooltipScanTextRight3
MyMod_TooltipScanTextLeft4 MyMod_TooltipScanTextRight4
etc

For debuffs I think the "magic"/"poison" is always TextRight2? Not certain. If so your mod can do:

local debuffType = MyMod_TooltipScanTextRight3:GetText()

and that's it. It sounds like a lot but it's not really. Define a custom tooltip in your xml, :SetUnitDebuff to the tooltip when you want to scan it, and then read the tooltip lines you're interested in.

It's probably worth noting that scanning tooltips is not lightning-fast if you plan to do hundreds of scans a second. I would avoid scanning all 30 lines for something that appears near the top for instance. But it's a great way to find out information about stuff and very commonly used so I wouldn't hesitate to play around with them.
  Reply With Quote
10-12-05, 10:53 AM   #3
ProfOak
A Cyclonian
Join Date: Oct 2005
Posts: 47
You are a life saver :P

IT WORKS :P

And the niciest thing is that you not only told me how to do it, but you also told me why. That way i did understand the point of doing things the way you explanied :P

Thks BIG TIME :P
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Buff/DeBuff Detection Help... kinda desperate here :(


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off