1. #1

    Question cancel buff via spellid?

    hello everyone!

    couldn't find much on the following, so here it goes:

    is there any (be it a macro or an addon etc.) possiblity to cancel a buff by ID?

  2. #2
    No, the responsible API only accepts spell name or buff index. Theoretically you could update a macro to match the index of the buff with the correct spell id. But that would only be possible while not in combat and as such would not be very useful.

    You can use GetSpellInfo if you don't know the spell name in a specific localisation, but it's not going to help for 2 spells with the same name...
    Last edited by Crudor; 2014-09-17 at 07:41 PM.

  3. #3
    The Lightbringer
    15+ Year Old Account
    Join Date
    Jun 2008
    Location
    Italy
    Posts
    3,564
    Code:
    /run CancelUnitBuff("player", GetSpellInfo("spellID"))
    obviously you can't use this in combat, as you can't cancel buffs in combat

  4. #4
    Quote Originally Posted by S7orm View Post
    obviously you can't use this in combat, as you can't cancel buffs in combat
    You can. You might have some addon protecting them.

  5. #5
    The Lightbringer
    15+ Year Old Account
    Join Date
    Jun 2008
    Location
    Italy
    Posts
    3,564
    strange, i didn't test it but the function itself should be tagged nocombat

  6. #6
    Quote Originally Posted by S7orm View Post
    strange, i didn't test it but the function itself should be tagged nocombat
    Unless you specifically that meant macro, then you definitely can. I'm mid-raid atm and I just cancelled some buffs on the pull.

  7. #7
    The Lightbringer
    15+ Year Old Account
    Join Date
    Jun 2008
    Location
    Italy
    Posts
    3,564
    good thing to know, it used to be nocombat because of str dps cancelbuff "exploit" with Wotlk legendary 2H

  8. #8
    It is protected in combat for me (on live, zero addons):

    Quote Originally Posted by taintlog
    An action was blocked in combat because of taint from MACRO_TAINT - CancelUnitBuff()
    You really only can do /cancelaura, which doesn't accept lua code.
    Last edited by Crudor; 2014-09-17 at 10:52 PM.

  9. #9
    Quote Originally Posted by Crudor View Post
    but it's not going to help for 2 spells with the same name...
    so there is no way to achieve that, even when you're out of combat? :-(
    Last edited by b3n9ti; 2014-09-18 at 12:16 AM.

  10. #10
    Quote Originally Posted by b3n9ti View Post
    so there is no way to achieve that, even when you're out of combat? :-(
    The following code will create and update a macro (called "cancelBySpellID") to remove the spell with spellID (change the first line in the code to the id you want). Just turn it into an addon and drag the macro to your bar.

    As stated above, this will only work when out of combat, so it's pretty much useless.

    Code:
    local spellID = 1126
    local macroText, macroName, buffIndex, lastIndex, blizz, combat = "/cancelaura %d", "cancelBySpellID", "", "", "Blizzard_MacroUI", false
    
    local function getBuff()
    	for i=1,40 do
    		if select(11,UnitBuff("player",i)) == spellID then
    			return i
    		end
    	end
    	return 0
    end
    
    local m = CreateFrame("Frame")
    m:RegisterEvent("ADDON_LOADED")
    m:RegisterEvent("PLAYER_REGEN_DISABLED")
    m:RegisterEvent("PLAYER_REGEN_ENABLED")
    m:SetScript("OnEvent",function(self,event,addon)
    	if event == "PLAYER_REGEN_DISABLED" then
    		combat = true
    		EditMacro(macroName, nil, nil, "")
    	elseif event == "PLAYER_REGEN_ENABLED" then
    		combat = false
    	elseif addon == blizz then
    		if not GetMacroInfo(macroName) then
    			CreateMacro(macroName,"INV_Misc_QuestionMark","")
    		end
    	end
    end)
    
    local f = CreateFrame("Frame")
    f:RegisterUnitEvent("UNIT_AURA","player")
    f:SetScript("OnEvent",function()
    	if not (InCombatLockdown() or combat) then
    		if IsAddOnLoaded(blizz) ~= 1 then
    			LoadAddOn(blizz)
    		end
    		
    		buffIndex = getBuff()
    		
    		if buffIndex~=lastIndex then
    			lastIndex = buffIndex
    			if buffIndex>0 then
    				EditMacro(macroName, nil, nil, macroText:format(buffIndex))
    			else
    				EditMacro(macroName, nil, nil, "")
    			end
    		end
    	end;
    end)
    Last edited by Crudor; 2014-09-18 at 09:52 PM.

  11. #11
    Quote Originally Posted by Crudor View Post
    The following code will create and update a macro (called "cancelBySpellID") to remove the spell[/CODE]
    that is exactly was I was looking for man! :-) :-)

    unfortunately though I can't get it to work and simply can't figure out why. (tried it with mark of the wild) I'd really appreciate if you took another look at it!
    here's the 'addon version' of what you posted: dl.dropboxusercontent.com/u/41246971/GWM.rar

    (can't post proper links yet :P)

  12. #12
    Quote Originally Posted by b3n9ti View Post
    that is exactly was I was looking for man! :-) :-)

    unfortunately though I can't get it to work and simply can't figure out why. (tried it with mark of the wild) I'd really appreciate if you took another look at it!
    here's the 'addon version' of what you posted: dl.dropboxusercontent.com/u/41246971/GWM.rar

    (can't post proper links yet :P)
    Indeed there was a little typo, should work now:

    Code:
    local spellID = 1126
    local macroText, macroName, buffIndex, lastIndex, blizz, combat = "/cancelaura %d", "cancelBySpellID", "", "", "Blizzard_MacroUI", false
    
    local function getBuff()
    	for i=1,40 do
    		if select(11,UnitBuff("player",i)) == spellID then
    			return i
    		end
    	end
    	return 0
    end
    
    local m = CreateFrame("Frame")
    m:RegisterEvent("ADDON_LOADED")
    m:RegisterEvent("PLAYER_REGEN_DISABLED")
    m:RegisterEvent("PLAYER_REGEN_ENABLED")
    m:SetScript("OnEvent",function(self,event,addon)
    	if event == "PLAYER_REGEN_DISABLED" then
    		combat = true
    		EditMacro(macroName, nil, nil, "")
    	elseif event == "PLAYER_REGEN_ENABLED" then
    		combat = false
    	elseif addon == blizz then
    		if not GetMacroInfo(macroName) then
    			CreateMacro(macroName,"INV_Misc_QuestionMark","")
    		end
    	end
    end)
    
    local f = CreateFrame("Frame")
    f:RegisterUnitEvent("UNIT_AURA","player")
    f:SetScript("OnEvent",function()
    	if not (InCombatLockdown() or combat) then
    		if IsAddOnLoaded(blizz) ~= 1 then
    			LoadAddOn(blizz)
    		end
    		
    		buffIndex = getBuff()
    		
    		if buffIndex~=lastIndex then
    			lastIndex = buffIndex
    			if buffIndex>0 then
    				EditMacro(macroName, nil, nil, macroText:format(buffIndex))
    			else
    				EditMacro(macroName, nil, nil, "")
    			end
    		end
    	end;
    end)

  13. #13
    Quote Originally Posted by Crudor View Post
    should work now
    works flawlessly now! thanks soooo much! :-) :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •