+ Reply to Thread
Results 1 to 7 of 7

Thread: I need help for my project spoken raid alerts.

  1. #1
    Prophet of Telara
    Join Date
    Sep 2010
    Posts
    1,008

    Question I need help for my project spoken raid alerts.

    Hey folks,

    I'm working on a program (written in Python) which can be used to create spoken raid alerts for Rift.

    Here is a sample video for Pagura.

    My problem not all skills appear in the log or combatlogfile.txt. For example Absorb Power from Thalguur or the interruptible channels Petrified, Pain and Weakness from Lord Arak are absent.

    I want to write an addon to fill this gap.
    I'm inexperienced with the lua scripting language and hope someone can help me with his experience.

    I need a simple addon that can detect if a Boss like Lord Arak cast a spell and write Lord Arak begins casting xyz to a chat channel so it appears in the logfile. Maybe a widely used Addon like King Boss Mod can be modified to write an alert to the chat channel.

    I think somehow I have to use Inspect.Unit.Castbar

    For any hint I would be very grateful.

  2. #2
    Plane Touched
    Join Date
    Jan 2011
    Posts
    209

    Default KBM would be a logical start

    Have you inspected the KBM LUA files? I expect most everything you need should be in there.

  3. #3
    Prophet of Telara
    Join Date
    Sep 2010
    Posts
    1,008

    Default

    Quote Originally Posted by xeroid View Post
    Have you inspected the KBM LUA files? I expect most everything you need should be in there.
    Yes but KBM is quite complex for someone who is not familiar with LUA. I need a starting point. I think for someone that's been versed with LUA it is very simple, probably only a few lines code.

  4. #4
    Prophet of Telara
    Join Date
    Sep 2010
    Posts
    1,008

    Default

    This ingame macro works:
    script name = Inspect.Unit.Detail("player.target").name
    script spellname= Inspect.Unit.Castbar("player.target").abilityName
    script dump(name, spellname)
    But my Addon do nothing:
    Code:
    local function getSpellname()
            local name = Inspect.Unit.Detail("player.target").name
    	local spellname = Inspect.Unit.Castbar("player.target").abilityName
    	return dump(name, spellname)
    end
    Command.Event.Attach(Event.Unit.Castbar, getSpellname, "Spellname")
    I think i miss something in the Event Call.

  5. #5
    General of Telara
    Join Date
    Mar 2014
    Posts
    967

    Default

    Yes you're doing it somewhat wrong.
    This event is called for all units relevant to combat, and you don't check if it's relevant to you at all.
    Events typically get called with arguments, in case of Event.Unit.Castbar() it's a table of units changed and their cast bar flag. And the first argument is always the event object itself, although it usually doesn't contain useful information.

    So your callback should look something like this:
    Code:
    local function getSpellname(event, units)
            for unit_id, casting in pairs(units) do
                    if casting and I_care_about(unit_id) then
                    	local spellname = Inspect.Unit.Castbar(unit_id).abilityName
                    	dump(unit_id, spellname)
                    end
            end
    end
    The question then is what "I_care_about(unit_id)" should do, it seems you only want player.target currently, so the easiest would be to compare unit_id against Inspect.Unit.Lookup("player.target"), or you could use LibUnitChange to keep track of player.target to avoid the lookup on each call.
    Last edited by Lynx3d; 05-02-2016 at 02:25 PM.

  6. #6
    Prophet of Telara
    Join Date
    Sep 2010
    Posts
    1,008

    Default

    This works now for me. I'll look at the LibUnitChange so thanks for the note.

    Code:
    -- print Debuffs on all Player's (Player <-  NPC) and Buffs on all NPC's (NPC <- Buff)
    local function getAddBuffName(event, unit, buffs)
        if unit then
            local details = Inspect.Unit.Detail(unit)
            for buffid, typeid in pairs(buffs) do
                local buff = Inspect.Buff.Detail(unit, buffid)
                local target = Inspect.Unit.Detail(buff.caster)
                if details.player ~= nil then
                    if details.id ~= buff.caster then
                        if target ~= nil then
                            if target.player == nil then
                                if buff.curse or buff.debuff or buff.disase or buff.poison then
                                    print(details.name .. " <- " ..buff.name)
                                    local bufflist = { id = buffid, name = buff.name }
                                    table.insert(rra_bufflist, bufflist)
                                end
                            end
                        end
                    end
                else
                    if details.id == buff.caster and details.relation == "hostile" then
                        print(details.name .. " <- " ..buff.name)
                        local bufflist = { id = buffid, name = buff.name }
                        table.insert(rra_bufflist, bufflist)
                    end
                end
            end
        end
    end
    
    
    -- print all removed Debuffs (Player <-  remove Debuff)  and Buffs (NPC <- remove Buff)
    local function getRemoveBuffName(event, unit, buffs)
        if unit then
            local buff_existing = false
            local details = Inspect.Unit.Detail(unit)
            for buffid, typeid in pairs(buffs) do
                for key, value in pairs(rra_bufflist) do
                    if value.id == buffid then
                        local buff_list = Inspect.Buff.List(unit)
                        local buff_details = Inspect.Buff.Detail(unit,buff_list)
                        if buff_list ~= nill then
                            for k, v in pairs(buff_details) do
                               if v.name == value.name then
                                   buff_existing = true
                               end
                            end
                        end
                        if buff_existing == false then
                            print(details.name .. " <- remove " .. value.name )
                        end
                        table.remove(rra_bufflist, key)
                    end
                end
            end
        end
    end
    
    
    -- print all Abilities (with cast time) from NPC's and show their target (NPC -> Ability -> Target)
    local function getAbilityName(event, units)
        if units then
            for id, value in pairs(units) do
                if value then
                    local details = Inspect.Unit.Detail(id)
                    local cast = Inspect.Unit.Castbar(id)
                    if details.relation == "hostile" then
                        local target = Inspect.Unit.Detail(id..".target")
                        if target ~= nil then
                            print (details.name .. " -> " .. cast.abilityName.. " -> " .. target.name)
                        else
                            print(details.name .. " -> " .. cast.abilityName)
                        end
                    end
                end
            end
        end
    end
    
    
    local function CombatBegin()
        local details = Inspect.Unit.Detail("player.target")
        if details ~= nil then
            print("Combat Begin -> " .. details.name)
        else
            print("Combat Begin")
        end
    end
    
    
    local function CombatEnd()
        print("Combat End")
        local count = #rra_bufflist
        for i=0, count do rra_bufflist[i]=nil end
    end
    
    
    local function rra_stop()
        Command.Event.Detach(Event.Buff.Add, getAddBuffName, "buffaddevent")
        Command.Event.Detach(Event.Buff.Remove, getRemoveBuffName, "buffremoveevent")
        Command.Event.Detach(Event.Unit.Castbar, getAbilityName, "AbilityName")
        Command.Event.Detach(Event.System.Secure.Enter, CombatBegin, "CombatBegin")
        Command.Event.Detach(Event.System.Secure.Leave, CombatEnd, "CombatEnd")
    end
    
    
    local function rra_start()
        rra_stop()
        Command.Event.Attach(Event.Buff.Add, getAddBuffName, "buffaddevent")
        Command.Event.Attach(Event.Buff.Remove, getRemoveBuffName, "buffremoveevent")
        Command.Event.Attach(Event.Unit.Castbar, getAbilityName, "AbilityName")
        Command.Event.Attach(Event.System.Secure.Enter, CombatBegin, "CombatBegin")
        Command.Event.Attach(Event.System.Secure.Leave, CombatEnd, "CombatEnd")
    end
    
    
    local function slashHandler(h, args)
        local r = {}
        local numargs = 0
        for token in string.gmatch(args, "[^%s]+") do
            r[numargs] = token
            numargs = numargs + 1
        end
        if r[0] == "start" then
            print("Rift Raid Alert started")
            rra_start()
            return
        end
        if r[0] == "stop" then
            print("Rift Raid Alert stoped")
            rra_stop()
            return
        end
        print("/rra start - Rift Raid Alert start")
        print("/rra stop - Rift Raid Alert stop")
    end
    
    
    rra_bufflist = {}
    print("/rra - for a list of commands")
    Command.Event.Attach(Command.Slash.Register("rra"), slashHandler, "Command.Slash.Register")

  7. #7
    Prophet of Telara
    Join Date
    Sep 2010
    Posts
    1,008

    Default

    What is the best way to determine the combat begin in a raid ?
    Event.System.Secure.Enter seems only determine my personal combat begin but not the entire raid.
    I need this for encounters like Thalguur where the first ability (group damage) start exactly 15 seconds after combat begin.

+ Reply to Thread

Bookmarks

Posting Permissions

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