Нашёл на просторах интрнета, но не знаю как реализовать.
Код: Выделить всё
-- Добавляет в таблицу "members" указанного юнита, при этом делая проверки (возможность лечить)
function InsertNewUnitToHeallersTable(unit)
if UnitExists(unit)
and not UnitIsDeadOrGhost(unit)
and not UnitIsCorpse(unit)
and UnitHealth(unit) > 100
and UnitCanAssist(unit, "player")
and IsSpellInRange(GetSpellInfo(MAIN_CLASS_SPELL), unit) == 1
and not IsNotLineOfSight(unit) then
for _,member in ipairs(members) do
if UnitGUID(member.Unit) == UnitGUID(unit) then
return;
end
end
table.insert(members, { Unit = unit, IsInMyParty = false });
end
end
Код: Выделить всё
-- Формирует таблицу "members" которая содержит юнитов нуждающихся в лечении.
-- при формировании происходят проверки: (доступность + рейдовая логика)
-- сформированная таблица будет отсортирована по наименьшему здоровью.
function FillPartyTables(standartSpellId)
-- Обнуляем все хиловские глобальные переменные.
FORCE_IN_COMBAT = false;
MAIN_CLASS_SPELL = standartSpellId;
LowHP = { };
members = { { Unit = "player", IsInMyParty = true } };
for i = 95, 10, -5 do
LowHP["H"..i] = 0;
end
local prefix = "party";
if IsInRaid() then
prefix = "raid";
elseif IsInArenaTeam() then
prefix = "arena";
end
for index = 1, GetNumGroupMembers() do
local unit = prefix..index;
if UnitExists(unit)
and not UnitIsCorpse(unit)
and not UnitIsUnit("player", unit)
and UnitIsConnected(unit)
and not UnitIsEnemy("player", unit)
and not UnitIsDeadOrGhost(unit)
and UnitInRange(unit)
and not IsNotLineOfSight(unit) then
table.insert(members, { Unit = unit, IsInMyParty = true });
end
end
Код: Выделить всё
-- Проверяет, надо ли сбивать заклинание текущему юниту.
function CheckInterrupt(unit, sec)
-- чтение заклинания прерываем только перед окончанием каста.
local name,_,_,_,startTime,endTime,isTrade,_,notInterruptible = UnitCastingInfo(unit);
if name and not (notInterruptible or isTrade) then
if (((endTime / 1000) - GetTime()) - AddonFrame.ping) <= (sec or 1) then
return true;
end
end
-- канальное заклинание прерываем сразу.
local name,_,_,_,_,_,isTrade,notInterruptible = UnitChannelInfo(unit);
if name and not (notInterruptible or isTrade) then
return true;
end
end