PVP talent macro

Trying a different version of the macro.

#showtooltip
/use Gateway Control Shard
/cast [@mouseover, exists, harm, nodead][] Disarm
/cast [@mouseover, exists, harm, nodead][] Duel
/run local G=GetSpellInfo SetMacroSpell(GetRunningMacro(), G"Disarm" or G"Duel" or G"Gateway Control Shard")

Switching from the shard to Disarm or Duel when they are talented works fine, but if those are not talented, then the macro has trouble swapping back to /use shard.

1 Like

“G” as “GetSpellInfo” will work on spells, but not necessarily on items.

You need to use SetMacroItem() for the shard, like I did in the other macro.

#showtooltip
/cast Gateway Control Shard
/cast [@mouseover][] Disarm
/run local G=GetSpellInfo SetMacroSpell(GetRunningMacro(), G"Disarm") else SetMacroItem(GetRunningMacro(), GetItemInfo(188152))end

does this look right? it doesn’t quite work.

#showtooltip
/cast Gateway Control Shard
/cast [@mouseover,harm,nodead] [] Disarm
/run local G=GetSpellInfo("Disarm") and SetMacroSpell(GetRunningMacro(), G) or SetMacroItem(GetRunningMacro(), GetItemInfo(188152))end

this did not work

and how would i add Duel to that?

#showtooltip
/cast Gateway Control Shard
/cast [@mouseover,harm,nodead] [] Disarm
/cast [@mouseover,harm,nodead] [] Duel
/run local G=GetSpellInfo(“Disarm” or “Duel”) and SetMacroSpell(GetRunningMacro(), G) or SetMacroItem(GetRunningMacro(), GetItemInfo(188152))end

Oops over ternary’d the crap outa that.

#showtooltip
/use Gateway Control Shard
/cast [@mouseover,harm,nodead] [] Disarm
/cast [@mouseover,harm,nodead] [] Duel
/run local G=GetSpellInfo local S=G"Disarm" or G"Duel" if S then SetMacroSpell(GetRunningMacro(), S) else SetMacroItem(GetRunningMacro(), "Gateway Control Shard")end

#showtooltip
/use Gateway Control Shard
/cast [@mouseover][] Disarm
/cast [@mouseover][] Duel
/run local G=GetSpellInfo local S=G"Disarm" or G"Duel" if S then SetMacroSpell(GetRunningMacro(), S) else SetMacroItem(GetRunningMacro(), GetItemInfo(188152))end

Shortened a bit and made it work!

That version will only ever cast Disarm and Duel on your mouseover because you’re not including an existence check.

#showtooltip
/use Gateway Control Shard
/cast [@mouseover,harm][] Disarm
/cast [@mouseover,harm][] Duel
/run local G,M=GetSpellInfo,GetRunningMacro() local S=G"Disarm" or G"Duel" if S then SetMacroSpell(M, S) else SetMacroItem(M, GetItemInfo(188152))end

this didn’t work :frowning: any ideas?

@mouseover with no existence check (any target conditional that doesn’t have a “no” in front of it like harm or dead) will lock up at that point because you’re essentially saying “cast on my mouseover unit whether it’s there or not” and it doesn’t make it to the next step.

I honestly think at this point you’d be better off with a small addon that simply changes the macro every time you change your PVP talents and sets it to the correct one.

Assuming you’ve named the macro DisarmOrDuel this code will work (minus the event registration part).

<register the event - not sure which one>

local function PVPTalentChangedHandler(preferPerCharacter)

    local c = UnitClass('player')
    local s = GetSpecialization()

    if c == 'WARRIOR' and s == 1 then

        local _, _, _, _, _, _, disarmKnown = GetSpellInfo('Disarm')
        local _, _, _, _, _, _, duelKnown = GetSpellInfo('Duel')

        if not (disarmKnown and duelKnown) and (disarmKnown or duelKnown) then
            local t1 = ((duelKnown and 'Disarm') or 'Duel')
            local t2 = ((disarmKnown and 'Disarm') or 'Duel')
            local n, i, b, l = GetMacroInfo('DisarmOrDuel')
            if n then
                gsub(b, t1, t2)
                EditMacro(n, b, i, l)
            else
                local gl, pc = GetNumMacros()
                if (gl + pc) = (MAX_ACCOUNT_MACROS + MAX_CHARACTER_MACROS) then
                    print("No room in your macro library for another macro.")
                else
                    local storePerCharacter
                    if preferPerCharacter then
                        if pc < MAX_CHARACTER_MACROS then
                            storePerCharacter= true
                        else
                            storePerCharacter= false
                        end
                    else
                        if gl < MAX_ACCOUNT_MACROS then
                            storePerCharacter= false
                        else
                            storePerCharacter= true
                        end
                    end
                    CreateMacro('DisarmOrDuel', 
                                'INV_Misc_QuestionMark', 
                                '#showtooltip\n'..
                                '/use Gateway Control Shard\n'..
                                '/cast [@mouseover, harm, nodead][harm, nodead]'..t2, 
                                storePerCharacter)
                end
            end
        else
            print('You do not know either Disarm or Duel.')
        end
    else
        --  skipping the update - not an Arms Warrior - no print
    end
end

Formatting is a little wonky for actual code - I needed to chop up some lines to make it fit in the forum window a little better.

I haven’t tested this, but even if it’s got an error or two, it’s a good running start at the necessary code.

This will (assuming it works) verify that you are an arms warrior, that you know one or the other of the two spells, update the macro in place (under the name I chose - change that if you need to), or create the macro - it verifies that you have enough space to store a macro and places it in your preferred location (perCharacter or global) if there is room in that space and in the other location if not - with appropriate messages if something goes wrong.

The version I posted yesterday works without issue for me.

how do i even use this code

https://www.wowhead.com/guide=1949/addon-writing-guide-a-basic-introduction-by-example

so how do i figure this out?

also, i just need to create a macro named “DisarmorDuel” and can leave it empty right? the addon will fill out the macro?

https://www.wowhead.com/guide=1949/addon-writing-guide-a-basic-introduction-by-example

I don’t mean to be rude, but I am not in a position to explain the add-on development process and that link does a reasonable job of it.

There was a time when I did, but I’m in an active raiding guild right now and I’ve got multiple characters involved in that and my leisure time is mostly spent gearing them and running raids.

The event (or possible multiple events) are going to be related to entering PVP and changing your PVP talents. You can look at what events FIRE by running /etrace and doing some of those things and looking at what flies by when you do.

PVPTalentChangedHandler:RegisterEvent("PLAYER_PVP_TALENT_UPDATE")
PVPTalentChangedHandler:RegisterEvent("PLAYER_LOGIN")
PVPTalentChangedHandler:RegisterEvent("PLAYER_REGEN_ENABLED")

local function PVPTalentChangedHandler(preferPerCharacter)

    local c = UnitClass('player')
    local s = GetSpecialization()

    if c == 'WARRIOR' and s == 1 then

        local _, _, _, _, _, _, disarmKnown = GetSpellInfo('Disarm')
        local _, _, _, _, _, _, duelKnown = GetSpellInfo('Duel')

        if not (disarmKnown and duelKnown) and (disarmKnown or duelKnown) then
            local t1 = ((duelKnown and 'Disarm') or 'Duel')
            local t2 = ((disarmKnown and 'Disarm') or 'Duel')
            local n, i, b, l = GetMacroInfo('DisarmOrDuel')
            if n then
                gsub(b, t1, t2)
                EditMacro(n, b, i, l)
            else
                local gl, pc = GetNumMacros()
                if (gl + pc) = (MAX_ACCOUNT_MACROS + MAX_CHARACTER_MACROS) then
                    print("No room in your macro library for another macro.")
                else
                    local storePerCharacter
                    if preferPerCharacter then
                        if pc < MAX_CHARACTER_MACROS then
                            storePerCharacter= true
                        else
                            storePerCharacter= false
                        end
                    else
                        if gl < MAX_ACCOUNT_MACROS then
                            storePerCharacter= false
                        else
                            storePerCharacter= true
                        end
                    end
                    CreateMacro('DisarmOrDuel', 
                                'INV_Misc_QuestionMark', 
                                '#showtooltip\n'..
                                '/use Gateway Control Shard\n'..
                                '/cast [@mouseover, harm, nodead][harm, nodead]'..t2, 
                                storePerCharacter)
                end
            end
        else
            print('You do not know either Disarm or Duel.')
        end
    else
        --  skipping the update - not an Arms Warrior - no print
    end
end

This is what I’ve got so far, doesn’t work :frowning:

Really don’t understand why you’re going to the trouble when I posted a <=255 macro that does everything you asked for.

Oh ya that one worked great, thank you Elvenbane!!! But then i discovered that I need to use more PVP talents, and some of them, like War Banner, will be cast when i press on the macro to get it to update with Getmacroinfo, therefore wasting the cooldown.

Phodge was right, at this point, the most complete solution is to just make a WA or addon that can swap/update/change macros based on what pvp talent i have.

Fair. You could try putting them higher in the list so they’re picked up by #showtooltip off the bat.