Thread Tools Display Modes
10-30-13, 05:37 AM   #1
keLston
A Deviate Faerie Dragon
Join Date: Apr 2006
Posts: 11
Buff Addon - Who cast this on me?

Is there a buff addon that provides this sort of information?

Occasionally in the combat log, you can tell with beneficial buffs especially when they wear off who casted a buff on you.

But there are certain buffs, especially with LFR trolls, that there seems to be no way to discern who casted something on you (like Heroism/Bloodlust).

The closest thing I know to this is DBM's spelltracker module but it goes by being in the raid and providing cooldown information and tells you when someone's Heroism ends up on cooldown.

I'd like to be able to tell if someone drive by buffs me or gives me one of the cosmetic item buffs so I can return the favor. There doesn't seem to be an addon that does this so i'm not sure if it's possible? I seem to remember it being a thing once, maybe I remember poorly.
  Reply With Quote
10-30-13, 06:27 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Caster info for buffs is available from the UnitAura API. My addon PhanxBuffs adds this info to its own tooltips; here is a completely drycoded standalone addon that should add caster names to buff and debuff tooltips for the default UI and any addon that uses the standard GameTooltip:

Code:
hooksecurefunc(GameTooltip, "SetUnitAura", function(self, unit, index, filter)
	local _, _, _, _, _, _, _, caster = UnitAura(unit, index, filter)
	local name = caster and UnitName(caster)
	if name then
		self:AddDoubleLine("Cast by:", name, nil, nil, nil, 1, 1, 1)
		self:Show()
	end
end)
If you need help turning the above code into an addon, copy and paste it into this page:
http://addon.bool.no/
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 10-31-13 at 12:06 AM. Reason: Fixed drycode error.
  Reply With Quote
10-30-13, 08:35 AM   #3
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Raven can show this in the tooltip.
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
10-30-13, 10:59 AM   #4
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Fixed Phanx's code. The first argument of a hooksecurefunc function is itself, and there was a missing comma between GameTooltip and "SetUnitAura". Fixed, and working great.

Code:
hooksecurefunc(GameTooltip, "SetUnitAura", function(self, unit, index, filter)
	local _, _, _, _, _, _, _, caster = UnitAura(unit, index, filter)
	local name = caster and UnitName(caster)
	if name then
		GameTooltip:AddDoubleLine("Cast by:", name, nil, nil, nil, 1, 1, 1)
		GameTooltip:Show()
	end
end)
  Reply With Quote
10-30-13, 02:46 PM   #5
keLston
A Deviate Faerie Dragon
Join Date: Apr 2006
Posts: 11
Awesome. Thanks so much!
  Reply With Quote
10-31-13, 12:06 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Clamsoda View Post
The first argument of a hooksecurefunc function is itself, ...
In this case, yes, but as a general rule, no -- hooksecurefunc doesn't have a "self", as it's a function, not an object. There only needs to be a self parameter in this case because the specific function being hooked receives one. I copied and pasted from code that was using method (colon) notation -- eg. frame:Method(x) which is syntatic sugar for frame.Method(self, x) -- and forgot to add the explicitly named parameter to work with function (dot) notation, but don't take that to mean that all functions passed to hooksecurefunc magically get a "self" prepended to their arguments.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
10-31-13, 12:33 AM   #7
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
The anonymous function inside of any hooksecurefunc function WILL have the object as the first argument, no?

Last edited by Clamsoda : 10-31-13 at 12:36 AM.
  Reply With Quote
10-31-13, 12:57 AM   #8
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
In this case, self is a reference to GameTooltip because the function being hooked is a method in a table (GameTooltip.SetUnitAura).

If you were to hook a function directly, "print" for example, self would not be passed as an argument.
  Reply With Quote
10-31-13, 01:07 AM   #9
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Well, I suppose I should have articulated better; I meant to imply that the object is passed as an argument to the anonymous function.
  Reply With Quote
10-31-13, 05:49 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It's not even intrinsic to the function being hooked being a table/object member. It's entirely dependent on how the original function itself is defined. For example, if the original function is defined this way:

Code:
function MyFrame.SetBorderColor(r, g, b)
   MyFrame.BorderTexture:SetVertexColor(r, g, b)
end
... then there would be no "self" parameter passed to secure post-hooks:

Code:
hooksecurefunc(MyFrame, "SetBorderColor", function(r, g, b)
   -- no "self" here!
   print("Border color changed to", r, g, b)
end)
This isn't a common usage (most functions defined as table members use object/method notation, or are explicitly passed the table object as their first parameter even if they don't) but it is a possible usage, and is used in at least one place in the default UI code (though I don't remember exactly where).

Really, you just need to remember that these are the same thing:

Code:
function MyObject.MyFunction(self)
   print("You called your function!")
end

function MyObject:MyFunction()
   print("You called your function!")
end
... and these are also the same thing, and either one can be used no matter which of the above notations was used to define the function:

Code:
MyObject:MyFunction()
MyObject.MyFunction(MyObject)
... and adjust accordingly when you change between colon and dot usage, eg. in places where you can't use a colon.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 10-31-13 at 05:52 PM.
  Reply With Quote
10-31-13, 05:57 PM   #11
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Right, your function is called with exactly the same arguments that the original function was.
  Reply With Quote
01-04-14, 02:46 PM   #12
RLD
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2
just found this....

good snippet of code and variation disussion.

played with this a little bit

print(name) will print locally to see if 'name' would get passed. (this happens on mouse over). would rather have it with OnClick().

then tried to do a CastSpellByName("Mark of the Wild",name) to see if I could buff 'name'

but no matter what my very limited knowledge seems to try I get a taint and error.

any help would be appreciated.

Last edited by RLD : 01-04-14 at 06:12 PM.
  Reply With Quote
01-05-14, 05:12 AM   #13
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by RLD View Post
then tried to do a CastSpellByName("Mark of the Wild",name) to see if I could buff 'name'
CastSpellByName has not been available to addons since before the Burning Crusade, almost 7 years ago. You should probably read:

(1) The list of things addons can't do. It's a sticky thread in this very forum.

(2) The WoW API documentation on Wowpedia or WoW Programming. Both will tell you whether it's even possible for you to use the function, and if so, how you should use it.

If you want any more specific help, you're going to have to be a lot more specific about what you want to do (big picture wise, eg. "I want to keep my raid buffed"). You're talking about names and OnClick scripts in your post, but I have no idea what you're actually talking about. Finally, if you want help with code, you need to show the code.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-05-14, 09:52 AM   #14
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by RLD View Post
print(name) will print locally to see if 'name' would get passed. (this happens on mouse over). would rather have it with OnClick().

then tried to do a CastSpellByName("Mark of the Wild",name)
Are you trying to target the person/mob who gave you that buff by left-clicking on the actual buff or something? If so, I believe that can't be done.
  Reply With Quote
01-07-14, 06:24 PM   #15
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
If you have a custom button that handles your buffs, I bet you can set a macro on it to target the person that cast the spell on you. Then you can specially click that buff button to invoke the macro. I do not think this would work in combat, so raid buffs may not be usable a lot, but it could work out of combat. Once you target the caster of the original buff you can do as you will.

Edit:
In fact, I imagine you might be able to monitor when you get a buff cast on you, and instead of having the actual buff need to be specially clicked, you would have a different button that you could set the macrotext on to target the caster of the buff. Then you click that button to target the benefactor so you can cast MotW on them.

Edit 2:
Something like this should work. It is a bit rough, but you get the idea:

local previousBuffs = {}
local targetButton = CreateFrame("Button", nil, WorldFrame, "SecureActionButtonTemplate,UIPanelButtonTemplate")
targetButton:SetWidth(16)
targetButton:SetHeight(16)
targetButton:SetPoint("LEFT",WorldFrame,"BOTTOMLEFT",50,320)
targetButton:SetAttribute("type1", "macro")
targetButton:SetScript("OnEvent", function(ignored, event, arg1)
if arg1 == "player" then
local i = 1
local currentBuffs = {}
local chosenCaster = nil
while (true) do
local name,_,_,_,_,_,_,caster,_,_,spellId = UnitAura(arg1, i)
if name then
spellId = tonumber(spellId)
if nil ~= spellId then
currentBuffs[spellId] = caster
if nil == previousBuffs[spellId] then chosenCaster = caster end
end
i = i + 1
else
break
end
end
local benefactorName = chosenCaster and UnitName(chosenCaster)
if benefactorName and not InCombatLockdown() then targetButton:SetAttribute("macrotext", SLASH_TARGET1 .. ' ' .. benefactorName) end
previousBuffs = currentBuffs
end
end)
targetButton:RegisterUnitEvent("UNIT_AURA", "player")

Last edited by Nimhfree : 01-07-14 at 07:25 PM.
  Reply With Quote
01-07-14, 08:44 PM   #16
Petrah
A Pyroguard Emberseer
 
Petrah's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 2,988
I've been using this one for almost 4 years. It just tells you in the buff tooltip the name of the person who cast the buff on you. Especially useful if you're leading raids.


http://www.wowinterface.com/download...urce.html#info
__________________
♪~ ( ) I My Sonos!
AddOn Authors: If your addon spams the chat box with "Addon v8.3.4.5.3 now loaded!", please add an option to disable it!

Last edited by Petrah : 01-07-14 at 08:46 PM.
  Reply With Quote
01-07-14, 10:36 PM   #17
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I like how you guys are all throwing out random suggestions for this guy whose post didn't even make any sense, and who will probably never come back and check for replies.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-07-14, 11:13 PM   #18
Petrah
A Pyroguard Emberseer
 
Petrah's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 2,988
So what. Others looking for the same thing will benefit from the thread.
__________________
♪~ ( ) I My Sonos!
AddOn Authors: If your addon spams the chat box with "Addon v8.3.4.5.3 now loaded!", please add an option to disable it!
  Reply With Quote
01-08-14, 02:11 AM   #19
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
Phanx, thank you! Was looking for a addon or how to do this.
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Buff Addon - Who cast this on me?

Thread Tools
Display Modes

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