Page 1 of 1

Hook request in combat.lua (attackTargetWith)

Posted: Tue Jun 07, 2016 4:07 am
by Peppersauce
So, I have a talent in my addon that keeps track of enemies with a certain debuff and grants attack, apr and damage multiplier if the player is attacking any enemy with this debuff. When I was coding it I was unable to find a simple way to actually apply the bonuses based on those conditions and I ended up with a really bad superload of attackTargetWith, because I had to change those values in the very middle of the function. This could be solved by making a hook so... here I am.
The hook should be placed at line 435, after the apr is declared and before the Repel check and any actual hit check is done. Alternatively, placing it at line 472 would still work as intended.

Here's an example of how the hook could look like:

Code: Select all

	local hd = {"Combat:attackTargetWith:attackerBonuses", target=target, weapon=weapon, damtype=damtype, mult=mult, dam=dam, apr=apr, atk=atk, def=def, armor=armor}
	if self:triggerHook(hd) then
		target, weapon, damtype, mult, dam, apr, atk, def, armor = hd.target, hd.weapon, hd.damtype, hd.mult, hd.dam, hd.apr, hd.atk, hd.def, hd.armor
	if hd.stop then return end
	end
I may be giving too many parameters too the hook this way, also giving the ability to addon makers to change target and weapon used by the function *might* be a bad idea, but that's your call if you get around to it. :twisted:

PS: the hook can't be called "Combat:attackTargetWith" because that's the name of a hook at the very end of "attackTargetHitProcs", just saying.

Re: Hook request in combat.lua (attackTargetWith)

Posted: Fri Jun 10, 2016 2:05 am
by HousePet
Hooray its finally added!

I was going to add it with the Cursed stuff (since it would use it a lot), but Hooray anyway!

Re: Hook request in combat.lua (attackTargetWith)

Posted: Fri Jun 10, 2016 2:33 am
by Peppersauce
Yeah! Definitely a great addition for all of us :D