Thread Tools Display Modes
08-15-24, 03:34 AM   #1
liamnap
A Murloc Raider
Join Date: Aug 2024
Posts: 9
Combat Log Horde Battle Standard

hi all,

I've been trying to get the right trigger when a Battle Standard is cast, and then match the faction based on the Battle Standard being Horde or Alliance.

In the screenshot I notice the player casts a Battle Standard and I can get this and print that it happens, however Horde Battle Standard is not a cast, but a summon performed by the players Battle Standard. This doesn't appear as a cast, so I tried text matching, I'm considering next just grabbing the text from the line printed immediately after player casts Battle Standard and then trying to determine from there.

I must be making this harder than it is, any tips?

Code:
                -- Check for battle standard usage
                if spellName == "Battle Standard" then
                    print("Player " .. sourceName .. " has cast a Battle Standard.")

                    -- Store the source GUID and other details for later linking
                    battleStandardCasts[sourceGUID] = {
                        sourceName = sourceName,
                        timestamp = timestamp
                    }

                    -- Store the event data for the generic battle standard cast
                    combatLogEvents[sourceName] = combatLogEvents[sourceName] or {}
                    table.insert(combatLogEvents[sourceName], {
                        spellId = spellId,
                        spellName = spellName,
                        timestamp = timestamp,
                        eventType = "Cast"
                    })
                end
            end
        end

        -- Additional method: Parse the combat log text for the specific summon message
        local fullText = CombatLogGetCurrentEventInfo()
        if fullText and string.find(fullText, "Battle Standard summons") then
            for guid, info in pairs(battleStandardCasts) do
                -- Check if the player's name and the correct faction's Battle Standard are both present
                local hordePattern = "%[" .. info.sourceName .. "'s%] Battle Standard summons %[(Horde Battle Standard)%]"
                local alliancePattern = "%[" .. info.sourceName .. "'s%] Battle Standard summons %[(Alliance Battle Standard)%]"
                if string.find(fullText, hordePattern) or string.find(fullText, alliancePattern) then
                    -- Determine the faction from the combat log text
                    local bannerFaction = string.match(fullText, "%[(Horde Battle Standard)%]") or string.match(fullText, "%[(Alliance Battle Standard)%]")

                    -- Debug: Output the detected faction and player who summoned it
                    print("Detected summon by " .. info.sourceName .. " of " .. bannerFaction .. " via combat log text.")

                    -- Store the event details
                    combatLogEvents[info.sourceName] = combatLogEvents[info.sourceName] or {}
                    table.insert(combatLogEvents[info.sourceName], {
                        spellId = spellId,
                        spellName = spellName,
                        timestamp = timestamp,
                        eventType = "Summon",
                        bannerFaction = bannerFaction -- Store the faction associated with the summon
                    })

                    break
                end
            end
Thank you for any and all help in advance!
Attached Images
File Type: png Screenshot 2024-08-12 180359.png (65.9 KB, 127 views)
  Reply With Quote
08-15-24, 09:14 AM   #2
Sharpedge
A Black Drake
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 82
Instead of looking for the "SPELL_CAST_SUCCESS" event, try monitoring for the "SPELL_SUMMON" event, which is triggered when a Battle Standard is summoned. This may work better.....

Code:
local fullText = CombatLogGetCurrentEventInfo()
if fullText and string.find(fullText, "Battle Standard summons") then
    for guid, info in pairs(battleStandardCasts) do
        -- Use a generic pattern and then match the faction-specific part
        local bannerFaction = string.match(fullText, "%[(Horde Battle Standard)%]") or string.match(fullText, "%[(Alliance Battle Standard)%]")
        if bannerFaction then
            -- Debug: Output the detected faction and player who summoned it
            print("Detected summon by " .. info.sourceName .. " of " .. bannerFaction .. " via combat log text.")

            -- Store the event details
            combatLogEvents[info.sourceName] = combatLogEvents[info.sourceName] or {}
            table.insert(combatLogEvents[info.sourceName], {
                spellId = spellId,
                spellName = "Battle Standard",
                timestamp = timestamp,
                eventType = "Summon",
                bannerFaction = bannerFaction -- Store the faction associated with the summon
            })

            break
        end
    end
end
  Reply With Quote
08-15-24, 01:42 PM   #3
liamnap
A Murloc Raider
Join Date: Aug 2024
Posts: 9
Thank you, finally got there with this:

If anybody reads this in the future printing out your combat log isn't a bad idea, enable it to save to .txt with
Code:
/combatlog
and checking the SPELL_SUMMON API page ffor the structure.

Code:
        elseif subevent == "SPELL_SUMMON" then
            if destName == "Horde Battle Standard" or destName == "Alliance Battle Standard" then
                local bannerFaction = (destName == "Horde Battle Standard") and "Horde" or "Alliance"
                print("Player " .. sanitizedSourceName .. " has summoned a " .. bannerFaction .. " Battle Standard at timestamp " .. timestamp)

                -- Store the event details, associating the banner with the player
                combatLogEvents[sanitizedSourceName] = combatLogEvents[sanitizedSourceName] or {}
                table.insert(combatLogEvents[sanitizedSourceName], {
                    spellId = spellId,
                    spellName = spellName,
                    timestamp = timestamp,
                    sourceName = sanitizedSourceName,
                    bannerFaction = bannerFaction,
                    eventType = "Summon"
                })
            end
        end
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Combat Log Horde Battle Standard


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