1

在《魔兽世界》中,我已经研究了一段时间的 Weakaura,它可以跟踪玩家已经损坏了多少存活的敌方单位。遇到的主要问题之一是,在组中时,当COMBAT_LOG_EVENT_UNFILTERED您组中的某人执行某项操作时,会强制光环触发,这可能会导致大量丢帧。我能遇到的唯一其他选项是COMBAT_LOG_EVENT,但是当敌人死亡时这不会触发,因此不会从列表中删除。

我的问题:有没有办法在 UI 线程以外的线程上收集这些数据以防止丢帧?在另一个线程上收集这些数据时,这些数据能否用于向用户显示信息?

以下是当前使用的触发器(这些都按预期工作)

触发器 1

类型 - 自定义

事件类型 - 事件

事件 - COMBAT_LOG_EVENT_UNFILTERED

自定义触发器:

function(...)
    ADDS = ADDS or {}; -- Where enemy units are stored

    local _, _, event, _, src, _, _, _, dest, _, _, _ = select(1, ...);
    local player = UnitGUID("player");

    -- Attempts to only read data coming from the player casting harmful abilities
    if ((event == "SPELL_DAMAGE") and (src == player)) then

        -- Checks if the enemy unit is already being tracked and that it is NOT
        -- a part of your group (prevents friendly fire events from adding a friendly
        -- unit to this list)
        if ((not tContains(ADDS, dest)) and (not tContains(GROUP, dest))) then
            table.insert(ADDS, dest);
        end
    elseif event=="UNIT_DIED" then -- Remove a unit if it has died
        for i = #ADDS, 1, -1 do
            if ADDS[i] == dest then
                table.remove(ADDS, i);
            end
        end
    end

    return true;
end

上面的代码块是丢帧的原因。下一个触发器只是在战斗开始或结束时重置列表的一种方式(可以肯定的是,此块中的任何内容都不会导致丢帧,但想包括它以防万一)。

触发器 2

类型 - 自定义

事件类型 - 事件

事件 - PLAYER_REGEN_DISABLED、PLAYER_REGEN_ENABLED

function(...)
    GROUP = GROUP or {};

    local size = GetNumGroupMembers();

    if (size == 0) then
        GROUP = {};
    end

    if (size ~= #GROUP and size ~= 0) then
        for i = 1, size do
            local name = GetRaidRosterInfo(i);

            if (name ~= nil) then
                local guid = UnitGUID(name);

                if (not tContains(GROUP, guid)) then
                    table.insert(GROUP, guid);
                end
            end
        end
    end

    ADDS = {};
    return true;
end
4

0 回答 0