дополнение The War Within

Открытый раздел для обсуждений
uaz266
Сообщения: 380
Зарегистрирован: 12 ноя 2016, 03:30

Re: дополнение The War Within

Сообщение uaz266 » 01 сен 2025, 03:55

anry89 писал(а):
31 авг 2025, 11:17
Вот мой полный рабочий код

Код: Выделить всё

GetSpellBookItemName = GetSpellBookItemName or C_SpellBook.GetSpellBookItemName
 GetNumSpellTabs = GetNumSpellTabs or C_SpellBook.GetNumSpellBookSkillLines
 GetSpellTabInfo = GetSpellTabInfo or function(tabLine)  skillLine = C_SpellBook.GetSpellBookSkillLineInfo(tabLine) if skillLine then return skillLine.name, skillLine.iconID, skillLine.itemIndexOffset, skillLine.numSpellBookItems, skillLine.isGuild, skillLine.offSpecID end end

PlayerHeroTrees = {}
function UpdateTalents()
    PlayerTalents = {}
    PlayerHeroTrees = {}

    local ActiveConfigID = C_ClassTalents.GetActiveConfigID()

    if ActiveConfigID then
        local ConfigInfo = C_Traits.GetConfigInfo(ActiveConfigID)

        if ConfigInfo then
            local treeIDs = ConfigInfo.treeIDs

            if treeIDs then
                for idx = 1, #treeIDs do
                    for _, TreeNodeID in pairs(C_Traits.GetTreeNodes(treeIDs[idx])) do
                        local NodeInfo = C_Traits.GetNodeInfo(ActiveConfigID, TreeNodeID)

                        if NodeInfo and NodeInfo.activeEntry and NodeInfo.activeRank > 0 then
                            local EntryInfo = C_Traits.GetEntryInfo(ActiveConfigID, NodeInfo.activeEntry.entryID)

                            if EntryInfo.definitionID then
                                local spellID = C_Traits.GetDefinitionInfo(EntryInfo.definitionID).spellID

                                PlayerTalents[tostring(spellID)] = true
                            end
                        end

                        if NodeInfo and NodeInfo.subTreeID then
                            local SubTreeInfo = C_Traits.GetSubTreeInfo(ActiveConfigID, NodeInfo.subTreeID)

                            if SubTreeInfo and SubTreeInfo.isActive then
                                PlayerHeroTrees[SubTreeInfo.name] = true
                            end
                        end
                    end
                end
            end
        end
    end

    for _, talentID in ipairs(C_SpecializationInfo.GetAllSelectedPvpTalentIDs()) do
        local _, _, _, _, _, spellID = GetPvpTalentInfoByID(talentID)

        PlayerTalents[tostring(spellID)] = true
        PlayerTalents[spellID] = true
    end
end

function IsHeroTree(TreeName)
    if PlayerHeroTrees[TreeName] ~= nil then
        return PlayerHeroTrees[TreeName]
    else
        return false
    end
end

function MyIsSpellInRange(SpellName, Unit)
    local in_range = C_Spell.IsSpellInRange(SpellName, Unit)

    if in_range == nil then return true else return in_range end
end

function CanCastUnit(SpellCode, Unit, InMove)
    return UnitExists(Unit) and UnitIsVisible(Unit) and not UnitIsDeadOrGhost(Unit) and Timers["WallBlock" .. UnitGUID(Unit)] == nil and Timers["UnitNotInFront" .. UnitGUID(Unit)] == nil and MyIsSpellInRange(SpellCode, Unit) and CanCast(SpellCode, InMove)
end

function GetSpellInfo(spellIdentifier)
    local data = C_Spell.GetSpellInfo(spellIdentifier)

    if data ~= nil then
        return data.name, 0, data.iconID, data.castTime, data.minRange, data.maxRange, data.spellID, data.originalIconID
    end
end

function GetSpellCooldown(spellIdentifier)
    local data = C_Spell.GetSpellCooldown(spellIdentifier)

    if data ~= nil then
        return data.startTime, data.duration, data.isEnabled, data.modRate
    end
end

function GetItemCooldown(spellIdentifier)
    local data = C_Item.GetItemCooldown(spellIdentifier)

    if data ~= nil then
        return data.startTime, data.duration, data.isEnabled, data.modRate
    end
end

function GetSpellCharges(spellIdentifier)
    local data = C_Spell.GetSpellCharges(spellIdentifier)

    if data ~= nil then
        return data.currentCharges, data.maxCharges, data.cooldownStartTime, data.cooldownDuration, data.chargeModRate
    end
end

function GetSpellDescription(spellIdentifier)
    return C_Spell.GetSpellDescription(spellIdentifier)
end

function IsSpellInRange(spellIdentifier, unit)
    return C_Spell.IsSpellInRange(spellIdentifier, unit)
end

function IsUsableSpell(spellIdentifier)
    return C_Spell.IsSpellUsable(spellIdentifier)
end

function GetSpellCount(spellIdentifier)
    return C_Spell.GetSpellCastCount(spellIdentifier)
end

function IsCurrentSpell(spellIdentifier)
    return C_Spell.IsCurrentSpell(spellIdentifier)
end

function GetSpellPowerCost(spellIdentifier)
    return C_Spell.GetSpellPowerCost(spellIdentifier)
end

function UnitAura(unit, i, kind)
    if kind == "HARMFUL" then
        local data = C_UnitAuras.GetDebuffDataByIndex(unit, i)

        if data ~= nil then
            return data.name, data.icon, data.applications, data.dispelName, data.duration, data.expirationTime, data.sourceUnit, nil, nil, data.spellId, data.canApplyAura, data.isBossDebuff, data.isFromPlayerOrPlayerPet
        end
    end

    if kind == "HELPFUL" then
        local data = C_UnitAuras.GetBuffDataByIndex(unit, i)

        if data ~= nil then
            return data.name, data.icon, data.applications, data.dispelName, data.duration, data.expirationTime, data.sourceUnit, nil, nil, data.spellId, data.canApplyAura, data.isBossDebuff, data.isFromPlayerOrPlayerPet
        end
    end
end
Да всё бьёт максимально хорошо работает, но есть одно но не работает каст предметов
Пример Изображение
Если сделать каст через макрос , то не отслеживает КД через пользовательский код GetItemCooldown() бот просто останавливается, хотел прикрутить КД "Камня здоровья" через слот сумки GetContainerItemCooldown() то же не получилось. Дальше мои познания заканчиваются. Может сможешь прикрутить "Камень здоровья"?

anry89
Сообщения: 45
Зарегистрирован: 04 дек 2022, 21:15

Re: дополнение The War Within

Сообщение anry89 » 21 сен 2025, 12:49

noname123 писал(а):
09 окт 2024, 14:29
kio57 писал(а):
08 окт 2024, 20:01
Как отслеживать бафы, дебафы? например на роге нужно Незаметность вне боя тыкать автоматом. Через стандартное отслеживание стопится. ну и бафы на таргете сразу подскажите плиз. и камни здоровья, хил поты, сейвы ещё же ...
бафы/дебафы можно через этот код отслеживать. К сожалению отслеживается только факт наличия (без определения длительности).


для дебафа
Пользовательский код WA_GetUnitDebuff(unit, "spell name") true
или
Пользовательский код WA_GetUnitDebuff(unit, spellid) true

для бафа
Пользовательский код WA_GetUnitBuff(unit, "spell name") true
или
Пользовательский код WA_GetUnitBuff(unit, spellid) true

Код: Выделить всё

local UnitAura = UnitAura
if UnitAura == nil then
  --- Deprecated in 10.2.5
  UnitAura = function(unitToken, index, filter)
  local auraData = C_UnitAuras.GetAuraDataByIndex(unitToken, index, filter)
  if not auraData then
   return nil;
  end

  return AuraUtil.UnpackAuraData(auraData)
 end
end

-- Unit Aura functions that return info about the first Aura matching the spellName or spellID given on the unit.
local WA_GetUnitAura = function(unit, spell, filter)
  if filter and not filter:upper():find("FUL") then
      filter = filter.."|HELPFUL"
  end
  for i = 1, 255 do
    local name, _, _, _, _, _, _, _, _, spellId = UnitAura(unit, i, filter)
    if not name then return end
    if spell == spellId or spell == name then
      return UnitAura(unit, i, filter)
    end
  end
end

local WA_GetUnitBuff = function(unit, spell, filter)
  filter = filter and filter.."|HELPFUL" or "HELPFUL"
  return WA_GetUnitAura(unit, spell, filter)
end

local WA_GetUnitDebuff = function(unit, spell, filter)
  filter = filter and filter.."|HARMFUL" or "HARMFUL"
  return WA_GetUnitAura(unit, spell, filter)
end
Отслеживание готовности камней здоровья, потов, тринкетов.

Код: Выделить всё

function CheckUseItem(itemId)
local status = false;
local count = C_Item.GetItemCount(itemId);
    if (count or 0) > 0 then
        local start,duration,enable = C_Item.GetItemCooldown(itemId);
        if start == 0 and duration == 0 and enable then
            status = true;
        end
    end
    return status;
end
Тригер на текущее здоровье не менялся, так что вопрос с сейвом не актуален.

Для удобства продублирую сюда пользовательский код на отслеживание кд спеллов.

Код: Выделить всё

function Cooldown(spell)
    local start, duration, enabled
    local spellCooldownInfo = spell and C_Spell.GetSpellCooldown(spell)
    start = spellCooldownInfo and spellCooldownInfo.startTime
    duration = spellCooldownInfo and spellCooldownInfo.duration
    enabled = spellCooldownInfo and spellCooldownInfo.isEnabled
    if enabled and duration == 0 and start == 0 then
        return 0
    elseif enabled then
        return (duration - (GetTime() - start))
    else
        return 100000
    end
end
Отслеживание общего количества зарядов. Например будет возвращать 1.5 если второй заряд откатился на половину.
Работает только при наличии предыдущего кода Cooldown(spell)

Код: Выделить всё

function SpellCharges(spell)
    local currentCharges, maxCharges, cooldownStart, cooldownDuration
    local chargeInfo  = spell and C_Spell.GetSpellCharges(spell)
    currentCharges = chargeInfo and chargeInfo.currentCharges
    maxCharges = chargeInfo and chargeInfo.maxCharges
    cooldownStart = chargeInfo and chargeInfo.cooldownStartTime
    cooldownDuration = chargeInfo and chargeInfo.cooldownDuration

    if currentCharges == nil then
        local cd = Cooldown(spell)
        if cd <= 0 then
            return 0, 1, 0
        else
            return cd, 0, 1
        end
    end

    local cd = cooldownDuration - (GetTime() - cooldownStart)
    if cd > cooldownDuration then
        cd = 0
    end

    if cd > 0 then
        currentCharges = currentCharges + (1 - (cd / cooldownDuration))
    end
    return currentCharges
end
Как ты реализовал камень локовский, у меня когда он хочет его съесть , бот стопается. Ошибка

440x BlackDPS/Main.lua:3256: attempt to index local 'data' (a number value)
[BlackDPS/Main.lua]:3256: in function 'GetItemCooldown'
[BlackDPS/Main.lua]:2048: in function 'GetItemLastCD'
[BlackDPS/Main.lua]:3315: in function 'SpellSelector'
[BlackDPS/Main.lua]:1033: in function 'MainScan'
[BlackDPS/Main.lua]:798: in function <BlackDPS/Main.lua:768>

Locals:
spellIdentifier = "1"
data = 0
(*temporary) = 0
(*temporary) = 0
(*temporary) = false
(*temporary) = 0
(*temporary) = "attempt to index local 'data' (a number value)"

anry89
Сообщения: 45
Зарегистрирован: 04 дек 2022, 21:15

Re: дополнение The War Within

Сообщение anry89 » 21 сен 2025, 14:59

Так вроде работает

Код: Выделить всё

function CheckUseItem(itemId)
local status = false;
local count = C_Item.GetItemCount(itemId);
    if (count or 0) > 0 then
        local start,duration,enable = C_Item.GetItemCooldown(itemId);
        if start == 0 and duration == 0 and enable then
            status = true;
        end
    end
    return status;
end
https://ibb.co/mrnLdLPX

uaz266
Сообщения: 380
Зарегистрирован: 12 ноя 2016, 03:30

Re: дополнение The War Within

Сообщение uaz266 » Вчера, 02:09

Спасибо, Камень здоровья работает как надо

Ответить

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 1 гость