WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Classic - AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=179)
-   -   Who Buffed Me in Classic (https://www.wowinterface.com/forums/showthread.php?t=58059)

JDoubleU00 06-18-20 11:52 PM

Who Buffed Me in Classic
 
In classic, drive by buffs are common. I had an idea to create an addon that grabs the name of the player who buffed you and do a /ty. The later part is theoretical, but here is my hacked together code.


Code:

local JWB = CreateFrame("Frame")

local function(WhoBuff)
        print("Buffed!")
        local buffnum=0
        for i=1, 40 do
                local name, __, count,_,_,_,caster = UnitBuff("player", i, "HELPFUL");    -- buffs only
                if (not name) then
                        buffnum=i
                        casterName = caster==nil and "unknown" or caster=="player" and "you" or caster=="pet" and "your pet" or UnitName(caster)
                        print("Caster: "..casterName)
                        print("break"..i)
                        break;    --end the loop
                end
  end
end

JWB:SetScript("OnEvent", WhoBuff)
JWB:RegisterUnitEvent("UNIT_AURA", "player")

What I thought would happen is when my toon is buffed, the code would loop through the buffs and pick the last one and print the caster name. Maybe I am misreading the API documentation or I should not try coding until I adjust to a new shift.

Ketho 06-19-20 12:50 AM

You can reference Thanks For The Buff which registers COMBAT_LOG_EVENT_UNFILTERED and checks the spell against a list of buffs

JDoubleU00 06-19-20 01:01 AM

Quote:

Originally Posted by Ketho (Post 336187)
You can reference Thanks For The Buff which registers COMBAT_LOG_EVENT_UNFILTERED and checks the spell against a list of buffs

I love this community. I tried to find an existing addon with no luck and you guys say look here. :D That looks pretty good and may very well meet my needs. But if I am bored, I might try looking the author's techniques.

Thanks as always!

Ketho 06-19-20 03:37 AM

Buff Owner Classic and this snippet by Phanx (see UnitAura for updated returns) are actually good solutions if all you wanted was just to see who casted a buff on you on mouseover, instead of the automated emote


All times are GMT -6. The time now is 08:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI