📄 decursive.lua
字号:
local baseframe = getglobal("DecursiveDebuffMonitorListFrameListItem"..id);
if baseframe:IsVisible() then
local unit = Dcr_NameToUnit(baseframe.unitName)
local max = table.getn(unitArray);
for i = 1 , max do
if unitArray[i] == unit then
table.insert(unitArray,1,table.remove(unitArray,i));
break;
end
end
end
end
if Dcr_vars.targetPrio and Dcr_vars.targetPrioPos == 1 then
if UnitExists("target") and UnitIsVisible("target") then
if UnitIsPlayer("target") and (UnitFactionGroup("target") == UnitFactionGroup("player")) then
local max = table.getn(unitArray);
local targetID = 0;
for i = 1 , max do
if UnitIsUnit("target",unitArray[i]) then
targetID = i;
break;
end
end
if targetID == 0 then
table.insert(unitArray,1,"target");
else
table.insert(unitArray,1,table.remove(unitArray,targetID));
end
end
end
end
return unitArray;
end
-- this gets an array of units for us to check
function Dcr_NameToUnit( Name)
if (not Name) or (Name == UnitName("player")) then
return false;
elseif (Name == UnitName("party1")) then
return "party1";
elseif (Name == UnitName("party2")) then
return "party2";
elseif (Name == UnitName("party3")) then
return "party3";
elseif (Name == UnitName("party4")) then
return "party4";
else
local numRaidMembers = GetNumRaidMembers();
if (numRaidMembers > 0) then
-- we are in a raid
local i;
for i=1, numRaidMembers do
local RaidName = GetRaidRosterInfo(i);
if ( Name == RaidName) then
return "raid"..i;
end
end
end
end
return false;
end
-- check before clean functions
function Dcr_Scan()
--取得顺序指针
local Dcr_Unit_Array = Dcr_GetUnitArray();
--清空两个array
Dcr_Charmed_Array = {};
Dcr_Afflicted_Array = {};
--按照顺序寻找debuff
local unit,debuffIndex,debuffTexture,debuffType,debuffName;
for _, unit in Dcr_Unit_Array do
if UnitIsVisible(unit) then --是不是能看到他,同时也就不再考虑盗贼的潜行
local class = UnitClass(unit);
local Has_Debuff = false;
local Has_NoTypeDebuff = false;
local ignoreUnit = false;
Dcr_Debuff[unit] = { Texture={},Type={},Name={} };
for debuffIndex = 1 , 16 do
debuffTexture = UnitDebuff(unit , debuffIndex);
if debuffTexture ~= nil then
Dcr_Tooltip:SetOwner(Decursive, "ANCHOR_NONE");
Dcr_TooltipTextRight1:SetText(nil);
Dcr_Tooltip:SetUnitDebuff(unit, debuffIndex);
debuffType = Dcr_TooltipTextRight1:GetText();
debuffName = Dcr_TooltipTextLeft1:GetText();
if not debuffType then
Has_NoTypeDebuff = true;
end
if debuffType ~= nil and (not DCR_SKIP_LIST[debuffName]) and (not DCR_SKIP_BY_CLASS_LIST[class][debuffName]) then --有可解的debuff才记录
Has_Debuff = true;
Dcr_Debuff[unit].Type[debuffIndex]=debuffType;
Dcr_Debuff[unit].Texture[debuffIndex]=debuffTexture;
Dcr_Debuff[unit].Name[debuffIndex]=debuffName;
if DCR_IGNORELIST[debuffName] then
ignoreUnit = true;
end
end
else
break;
end
end
--检测是否被媚惑
if Has_Debuff and not ignoreUnit then
if UnitIsCharmed(unit) then
if not Has_NoTypeDebuff then
Dcr_Charmed_Array[unit] = true;
end
--如果没有被魅惑,则加入到普通列表
else
table.insert(Dcr_Afflicted_Array, unit);
end
end
end
end
end
function Dcr_CheckCureMagicRdy()
if DCR_CAN_CURE_MAGIC and Dcr_vars.Cure_Magic then
local slot;
if DCR_SPELL_MAGIC_2 > 0 then
Dcr_Magic_2_Slot = Dcr_GetSpellSlot(DCR_SPELL_MAGIC_2,Dcr_Magic_2_Slot);
slot = Dcr_Magic_2_Slot;
else
Dcr_Magic_1_Slot = Dcr_GetSpellSlot(DCR_SPELL_MAGIC_1,Dcr_Magic_1_Slot);
slot = Dcr_Magic_1_Slot;
end
if slot == 0 then
return 0;
end
if IsUsableAction(slot) == 1 then
local _,coolDownTime = GetActionCooldown(slot);
if coolDownTime == 0 then
return slot;
end
end
end
return 0;
end
function Dcr_CheckCureCurseRdy()
if DCR_CAN_CURE_CURSE and Dcr_vars.Cure_Curse then
Dcr_Curse_Slot = Dcr_GetSpellSlot(DCR_SPELL_CURSE,Dcr_Curse_Slot);
if Dcr_Curse_Slot == 0 then
return 0;
end
if IsUsableAction(Dcr_Curse_Slot) == 1 then
local _,coolDownTime = GetActionCooldown(Dcr_Curse_Slot);
if coolDownTime == 0 then
return Dcr_Curse_Slot;
end
end
end
return 0;
end
function Dcr_CheckCureDiseaseRdy()
if DCR_CAN_CURE_DISEASE and Dcr_vars.Cure_Disease then
local slot;
if DCR_SPELL_DISEASE_2 > 0 then
Dcr_Disease_2_Slot = Dcr_GetSpellSlot(DCR_SPELL_DISEASE_2,Dcr_Disease_2_Slot);
slot = Dcr_Disease_2_Slot;
else
Dcr_Disease_1_Slot = Dcr_GetSpellSlot(DCR_SPELL_DISEASE_1,Dcr_Disease_1_Slot);
slot = Dcr_Disease_1_Slot;
end
if slot == 0 then
return 0;
end
if IsUsableAction(slot) == 1 then
local _,coolDownTime = GetActionCooldown(slot);
if coolDownTime == 0 then
return slot;
end
end
end
return 0;
end
function Dcr_CheckCurePoisonRdy()
if DCR_CAN_CURE_POISON and Dcr_vars.Cure_Poison then
local slot;
if DCR_SPELL_POISON_2 > 0 then
Dcr_Poison_2_Slot = Dcr_GetSpellSlot(DCR_SPELL_POISON_2,Dcr_Poison_2_Slot);
slot = Dcr_Poison_2_Slot;
else
Dcr_Poison_1_Slot = Dcr_GetSpellSlot(DCR_SPELL_POISON_1,Dcr_Poison_1_Slot);
slot = Dcr_Poison_1_Slot;
end
if slot == 0 then
return 0;
end
if IsUsableAction(slot) == 1 then
local _,coolDownTime = GetActionCooldown(slot);
if coolDownTime == 0 then
return slot;
end
end
end
return 0;
end
function Dcr_CheckCureCharmedRdy()
if DCR_CAN_CURE_CHARMED then
local slot;
if DCR_SPELL_CHARMED_2 > 0 then
Dcr_Charmed_2_Slot = Dcr_GetSpellSlot(DCR_SPELL_CHARMED_2,Dcr_Charmed_2_Slot);
slot = Dcr_Charmed_2_Slot;
else
Dcr_Charmed_1_Slot = Dcr_GetSpellSlot(DCR_SPELL_CHARMED_1,Dcr_Charmed_1_Slot);
slot = Dcr_Charmed_1_Slot;
end
if slot == 0 then
return 0;
end
if IsUsableAction(slot) == 1 then
local _,coolDownTime = GetActionCooldown(slot);
if coolDownTime == 0 then
return slot;
end
end
end
return 0;
end
function Dcr_CheckUnitForDebuff(unit, debuffContent)
local i;
for i = 1, 16 do
local buff_texture = UnitDebuff(unit, i);
if buff_texture then
Dcr_Tooltip:SetOwner(Decursive, "ANCHOR_NONE");
Dcr_TooltipTextRight1:SetText(nil);
Dcr_Tooltip:SetUnitDebuff(unit, i);
if Dcr_TooltipTextLeft2:GetText() == debuffContent then
return true;
end
Dcr_Tooltip:Hide();
else
return false;
end
end
end
-- clean functions
function Dcr_Clean(UnitOnLiveList,DebuffTypeOnLiveList,IfSwitchTarget)
-----------------------------------------------------------------------
-- first we do the setup, make sure we can cast the spells
-----------------------------------------------------------------------
if Dcr_CheckUnitForDebuff("player",DCR_STUNNED) then--DCR_STUNNED="昏迷。";
return;
end
local cureMagicRdySlot = Dcr_CheckCureMagicRdy();--如果可以净化,且技能准备好了,则返回技能的slot id,若不行则返回0
local cureCurseRdySlot = Dcr_CheckCureCurseRdy();
local cureDiseaseRdySlot = Dcr_CheckCureDiseaseRdy();
local curePoisonRdySlot = Dcr_CheckCurePoisonRdy();
local cureCharmedRdySlot = Dcr_CheckCureCharmedRdy();
local lastToCure_Array = {};
if not ( (cureMagicRdySlot > 0) or (cureCurseRdySlot > 0) or (cureDiseaseRdySlot > 0) or (curePoisonRdySlot > 0) or (cureCharmedRdySlot > 0)) then
return;
end
Dcr_Scan();
local hasTarget = false;
local cleaned = false; --是否已净化
local resetCombatMode = false;
Dcr_Casting_Unit = nil;
if IfSwitchTarget then
TargetUnit(UnitOnLiveList);
end
if UnitExists("target") then
hasTarget = true;
if (Dcr_CombatMode) or (Dcr_DelayTimer > 0) then
Dcr_printlnForMaxDebug("正在自动攻击!");
Dcr_printlnForMaxDebug("auto attacking is on");
resetCombatMode = true;
end
end
if UnitOnLiveList then
Dcr_printlnForMaxDebug("开始治疗由实时列表指定的目标");
Dcr_printlnForMaxDebug("begin to cure the unit on live list");
if Dcr_Charmed_Array[unit] and cureCharmedRdySlot > 0 then
if Dcr_UnitInRange(UnitOnLiveList,cureCharmedRdySlot,hasTarget) then--以后所有可能改变目标的function均指明是否有目标,从今以后采用绝对的连锁指定目标
cleaned = Dcr_Cure_Charmed(UnitOnLiveList,hasTarget);
end
elseif DebuffTypeOnLiveList == DCR_MAGIC and cureMagicRdySlot > 0 then
if Dcr_UnitInRange(UnitOnLiveList,cureMagicRdySlot,hasTarget) then
cleaned = Dcr_Cure_Magic(UnitOnLiveList,hasTarget);
end
elseif DebuffTypeOnLiveList == DCR_CURSE and cureCurseRdySlot > 0 then
if Dcr_UnitInRange(UnitOnLiveList,cureCurseRdySlot,hasTarget) then
cleaned = Dcr_Cure_Curse(UnitOnLiveList,hasTarget);
end
elseif DebuffTypeOnLiveList == DCR_DISEASE and cureDiseaseRdySlot > 0 then
if Dcr_UnitInRange(UnitOnLiveList,cureDiseaseRdySlot,hasTarget) then
cleaned = Dcr_Cure_Disease(UnitOnLiveList,hasTarget);
end
elseif DebuffTypeOnLiveList == DCR_POISON and curePoisonRdySlot > 0 then
if Dcr_UnitInRange(UnitOnLiveList,curePoisonRdySlot,hasTarget) then
cleaned = Dcr_Cure_Poison(UnitOnLiveList,hasTarget);
end
end
Dcr_printlnForMaxDebug("结束治疗由实时列表指定的目标");
Dcr_printlnForMaxDebug("end of curing unit on live list");
end
local unit;
if cureCharmedRdySlot > 0 and not cleaned then
Dcr_printlnForMaxDebug("开始治疗被控制的队友");
Dcr_printlnForMaxDebug("begin to cure charmed unit");
for unit in Dcr_Charmed_Array do
if Dcr_UnitInRange(unit,cureCharmedRdySlot,hasTarget) then
cleaned = Dcr_Cure_Charmed(unit,hasTarget);
end
if cleaned then
break;
end
end
Dcr_printlnForMaxDebug("结束治疗被控制的队友");
Dcr_printlnForMaxDebug("end of curing charmed unit");
end
if not cleaned then
Dcr_printlnForMaxDebug("开始治疗中debuff的队友");
Dcr_printlnForMaxDebug("begin to cure raid(party) member");
for _,unit in Dcr_Afflicted_Array do
if not Dcr_NotInSight_Array[unit] then
Dcr_printlnForMaxDebug("开始治疗 " .. UnitName(unit) );
Dcr_printlnForMaxDebug("begin to cure " .. UnitName(unit) );
local debuffType;
local hasMagicDebuff = false;
local hasCurseDebuff = false;
local hasDiseaseDebuff = false;
local hasPoisonDebuff = false;
for _, debuffType in Dcr_Debuff[unit].Type do
Dcr_printlnForMaxDebug("他身上有"..debuffType.."debuff");
Dcr_printlnForMaxDebug("he has "..debuffType.." debuff");
if debuffType == DCR_MAGIC then
hasMagicDebuff = true;
elseif debuffType == DCR_CURSE then
hasCurseDebuff = true;
elseif debuffType == DCR_DISEASE then
hasDiseaseDebuff = true;
elseif debuffType == DCR_POISON then
hasPoisonDebuff = true;
end
end
if not cleaned and hasMagicDebuff and cureMagicRdySlot > 0 then
if Dcr_UnitInRange(unit, cureMagicRdySlot,hasTarget) then
cleaned = Dcr_Cure_Magic(unit,hasTarget);
end
end
if not cleaned and hasCurseDebuff and cureCurseRdySlot > 0 then
if Dcr_UnitInRange(unit, cureCurseRdySlot,hasTarget) then
cleaned = Dcr_Cure_Curse(unit,hasTarget);
end
end
if not cleaned and hasDiseaseDebuff and cureDiseaseRdySlot > 0 then
if Dcr_UnitInRange(unit, cureDiseaseRdySlot,hasTarget) then
cleaned = Dcr_Cure_Disease(unit,hasTarget);
end
end
if not cleaned and hasPoisonDebuff and curePoisonRdySlot > 0 then
if Dcr_UnitInRange(unit, curePoisonRdySlot,hasTarget) then
cleaned = Dcr_Cure_Poison(unit,hasTarget);
end
end
else
table.insert(lastToCure_Array,unit);
end
if cleaned then
break;
end
end
Dcr_printlnForMaxDebug("结束治疗中debuff的队友");
Dcr_printlnForMaxDebug("end of curing raid(party) member");
end
--now to cure the unit we skipped previous
if not cleaned then
Dcr_printlnForMaxDebug("开始尝试治疗之前不在视野内的队友");
Dcr_printlnForMaxDebug("begin to cure unit who was not in your sight just before");
for _,unit in lastToCure_Array do
Dcr_printlnForMaxDebug("开始治疗 " .. UnitName(unit) );
Dcr_printlnForMaxDebug("begin to cure " .. UnitName(unit) );
local debuffType;
local hasMagicDebuff = false;
local hasCurseDebuff = false;
local hasDiseaseDebuff = false;
local hasPoisonDebuff = false;
for _, debuffType in Dcr_Debuff[unit].Type do
Dcr_printlnForMaxDebug("他身上有"..debuffType .. "debuff" );
Dcr_printlnForMaxDebug("he has "..debuffType.." debuff");
if debuffType == DCR_MAGIC then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -