CurseForge and Overwolf are joining forces!
Awesome More Information
  • 0

    posted a message on Applied spell aura - Find people

    The question is about Wotlk 3.3.5 - Icecrown Citadel - Sindragosa - Frost Beacon spell aura. The AddOn should recognize all people with Frost Beacon during the air phase and assign them sides. For example: DeadlyBossMods says "Frost Beacon on: Player1, Player2, Player3, Player4, Player5, Player6" in 25-heroic mode. The AddOn should whisper those people: Player1 and Player2 - left, Player3 and Player4 - center and Player5 and Player6 - right, as well as a HUD message with the sides to me (check FBgetString).

     

    If it was in retail, the code would work. The problem is that GetInstanceDifficulty() returns 2 for 25-heroic mode, even tho it's supposed to return 4, because the IDs are shared. In other words, I can't use GetInstanceDifficulty(), it should be replaced with something else.

     

    You can check the code below, more specifically FBdoDisplay(), FBSendMessage() and possibly SPELL_AURA_APPLIED event handling. The event handler for SPELL_AURA_APPLIED adds each affected person to a table and then if checks instance's difficulty as well as the table size.

     

    10 normal and heroic modes - 2 tombs, 25-normal - 5, 25-heroic - 6.

     

    I can't think of a replacement solution. If it only counts table's size, then I wouldn't know when to stop adding people to the table, because  I don't know the mode.

    FB:SetScript("OnEvent", function(self, event, ...)
        if event == "PLAYER_ENTERING_WORLD" then
            if IsInInstance() and GetInstanceInfo() == "Icecrown Citadel" then
                FB:RegisterEvent("CHAT_MSG_MONSTER_YELL")
            else
                FB:UnregisterEvent("CHAT_MSG_MONSTER_YELL")
                FB:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
            end
        elseif event == "CHAT_MSG_MONSTER_YELL" then
            local text, srcName = ...
            if srcName == "Sindragosa" and string.find(text, "Your incursion ends here") then
                FB:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
            end
        elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
            local _, subEvent, _, _, _, _, destName, _, _, spellName = ...
            
            if subEvent == "SPELL_CAST_START" and spellName == "Ice Tomb" then
                affected = {}
                
            elseif subEvent == "SPELL_AURA_APPLIED" and spellName == "Frost Beacon" then
                affected = affected or {}
                table.insert(affected, destName)
                if FBdoDisplay() then 
                    local result = FBgetString(affected)
                    displayMSG(self, result, 7)
                    FB:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
                end
            end
        end
    end)
    
    local function FBdoDisplay()
        local difficultyIndex = GetInstanceDifficulty()
        if difficultyIndex == 1 or difficultyIndex == 3 then 
            if table.getn(affected) == 2 then return true end
        elseif difficultyIndex == 2 then
            if table.getn(affected) == 5 then return true end
        elseif difficultyIndex == 4 then
            if table.getn(affected) == 6 then return true end
        end
    end
    
    local function FBSendMessage(index)
        local difficultyIndex = GetInstanceDifficulty() -- 1-10nm, 3-10hc, 2-25nm, 4-25hc
        local name = affected[index]
        if name == UnitName("player") then return end
        if difficultyIndex == 1 or difficultyIndex == 3 then 
            if index == 1 then SCMside("LEFT", name) end
            if index == 2 then SCMside("RIGHT", name) end
        elseif difficultyIndex == 2 then
            if index == 1 then SCMside("LEFT", name) end
            if index == 2 then SCMside("LEFT", name) end
            if index == 3 then SCMside("CENTER", name) end
            if index == 4 then SCMside("RIGHT", name) end
            if index == 5 then SCMside("RIGHT", name) end
        elseif difficultyIndex == 4 then
            if index == 1 then SCMside("LEFT", name) end
            if index == 2 then SCMside("LEFT", name) end
            if index == 3 then SCMside("CENTER", name) end
            if index == 4 then SCMside("CENTER", name) end
            if index == 5 then SCMside("RIGHT", name) end
            if index == 6 then SCMside("RIGHT", name) end
        end
    end
    
    local function FBisPlayer(index)  
        if UnitName("player") == affected[index] then
            FBPlaySoundFile(index)
            return "<!!"..affected[index].."!!>"
        else
            if IsRaidOfficer() then
                FBSendMessage(index)
            end
            return affected[index]
        end
    end
    
    local function FBgetString(affectedTable)
        local s = ""
        if table.getn(affectedTable) == 2 then
            local leftA = setClassColor(FBisPlayer(1), UnitClass(raidIbyName(affectedTable[1])))
            local leftB = setClassColor(FBisPlayer(2), UnitClass(raidIbyName(affectedTable[2])))
            s = string.format("|cFF00FF00Left:|r %s\n|cFF00FF00Right:|r %s", leftA, leftB)
        elseif table.getn(affectedTable) == 5 then
            local leftA = setClassColor(FBisPlayer(1), UnitClass(raidIbyName(affectedTable[1])))
            local leftB = setClassColor(FBisPlayer(2), UnitClass(raidIbyName(affectedTable[2])))
            local leftC = setClassColor(FBisPlayer(3), UnitClass(raidIbyName(affectedTable[3])))
            local leftD = setClassColor(FBisPlayer(4), UnitClass(raidIbyName(affectedTable[4])))
            local leftE = setClassColor(FBisPlayer(5), UnitClass(raidIbyName(affectedTable[5])))
            s = string.format("|cFF00FF00Left:|r %s, %s\n|cFF00FF00Center:|r %s\n|cFF00FF00Right:|r %s, %s", leftA, leftB, leftC, leftD, leftE)
        elseif table.getn(affectedTable) == 6 then
            local leftA = setClassColor(FBisPlayer(1), UnitClass(raidIbyName(affectedTable[1])))
            local leftB = setClassColor(FBisPlayer(2), UnitClass(raidIbyName(affectedTable[2])))
            local leftC = setClassColor(FBisPlayer(3), UnitClass(raidIbyName(affectedTable[3])))
            local leftD = setClassColor(FBisPlayer(4), UnitClass(raidIbyName(affectedTable[4])))
            local leftE = setClassColor(FBisPlayer(5), UnitClass(raidIbyName(affectedTable[5])))
            local leftF = setClassColor(FBisPlayer(6), UnitClass(raidIbyName(affectedTable[6])))
            s = string.format("|cFF00FF00Left:|r %s, %s\n|cFF00FF00Center:|r %s, %s\n|cFF00FF00Right:|r %s, %s", leftA, leftB, leftC, leftD, leftE, leftF)
        end
        return s
    end

     

    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.