⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decursive.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 5 页
字号:
					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
			if cleaned then
				break;
			end
		end
		Dcr_printlnForMaxDebug("结束尝试治疗之前不在视野内的队友");
		Dcr_printlnForMaxDebug("end of curing unit who was not in your sight just before");
	end

	-----------------------------------------------------------------------
	-- ok... done with the cleaning... lets try to clean this up
	-----------------------------------------------------------------------

	if resetCombatMode then
		local _,_,lag = GetNetStats();
		Dcr_DelayTimer = lag/1000 + 0.7;
	end

	if cleaned then
		Dcr_CheckAfterCast_On = true;
		Dcr_CheckAfterCast_LeftTime = 1.5;
	elseif (not cleaned) and Dcr_vars.Show_NoCleaned then
		Dcr_println( DCR_NOT_CLEANED);
	end
end

function Dcr_CleanByDebuffName(debuffNameToCure)
	if Dcr_CheckUnitForDebuff("player",DCR_STUNNED) then--DCR_STUNNED="昏迷。";
		return;
	end

	local cureMagicRdySlot = Dcr_CheckCureMagicRdy();
	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 false;
	end

	Dcr_Scan();

	local hasTarget = false;
	local cleaned = false;
	local resetCombatMode = false;
	Dcr_Casting_Unit = nil;

	if UnitExists("target") then
		hasTarget = true;
		if (Dcr_CombatMode) then
			Dcr_printlnForMaxDebug("正在自动攻击!");
			Dcr_printlnForMaxDebug("auto attacking is on");
			resetCombatMode = true;
		end
	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 debuffIndex,debuffName;
				local hasDebuffType = false;
				for debuffIndex, debuffName in Dcr_Debuff[unit].Name do
					Dcr_printlnForMaxDebug("他身上有"..debuffName.."debuff");
					Dcr_printlnForMaxDebug("he has "..debuffName.." debuff");
					if debuffName == debuffNameToCure then
						hasDebuffType = Dcr_Debuff[unit].Type[debuffIndex];
					end
				end
				if not cleaned and hasDebuffType then
					if (hasDebuffType == DCR_MAGIC) and cureMagicRdySlot > 0 then
						if Dcr_UnitInRange(unit, cureMagicRdySlot,hasTarget) then
							cleaned = Dcr_Cure_Magic(unit,hasTarget);
						end
					elseif (hasDebuffType == DCR_CURSE) and cureCurseRdySlot > 0 then
						if Dcr_UnitInRange(unit, cureCurseRdySlot,hasTarget) then
							cleaned = Dcr_Cure_Curse(unit,hasTarget);
						end
					elseif (hasDebuffType == DCR_DISEASE) and cureDiseaseRdySlot > 0 then
						if Dcr_UnitInRange(unit, cureDiseaseRdySlot,hasTarget) then
							cleaned = Dcr_Cure_Disease(unit,hasTarget);
						end
					elseif (hasDebuffType == DCR_POISON) and curePoisonRdySlot > 0 then
						if Dcr_UnitInRange(unit, curePoisonRdySlot,hasTarget) then
							cleaned = Dcr_Cure_Poison(unit,hasTarget);
						end
					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 debuffIndex,debuffName;
			local hasDebuffType = false;
			for debuffIndex, debuffName in Dcr_Debuff[unit].Name do
				Dcr_printlnForMaxDebug("他身上有"..debuffName.."debuff");
				Dcr_printlnForMaxDebug("he has "..debuffName.." debuff");
				if debuffName == debuffNameToCure then
					hasDebuffType = Dcr_Debuff[unit].Type[debuffIndex];
				end
			end
			if not cleaned and hasDebuffType then
				if (hasDebuffType == DCR_MAGIC) and cureMagicRdySlot > 0 then
					if Dcr_UnitInRange(unit, cureMagicRdySlot,hasTarget) then
						cleaned = Dcr_Cure_Magic(unit,hasTarget);
					end
				elseif (hasDebuffType == DCR_CURSE) and cureCurseRdySlot > 0 then
					if Dcr_UnitInRange(unit, cureCurseRdySlot,hasTarget) then
						cleaned = Dcr_Cure_Curse(unit,hasTarget);
					end
				elseif (hasDebuffType == DCR_DISEASE) and cureDiseaseRdySlot > 0 then
					if Dcr_UnitInRange(unit, cureDiseaseRdySlot,hasTarget) then
						cleaned = Dcr_Cure_Disease(unit,hasTarget);
					end
				elseif (hasDebuffType == DCR_POISON) and curePoisonRdySlot > 0 then
					if Dcr_UnitInRange(unit, curePoisonRdySlot,hasTarget) then
						cleaned = Dcr_Cure_Poison(unit,hasTarget);
					end
				end
			end
			if cleaned then
				break;
			end
		end
		Dcr_printlnForMaxDebug("结束尝试治疗之前不在视野内的队友");
		Dcr_printlnForMaxDebug("end of curing unit who was not in your sight just before");
	end


	-----------------------------------------------------------------------
	-----------------------------------------------------------------------
	-- ok... done with the cleaning... lets try to clean this up
	-- basically switch targets back if they were changed
	-----------------------------------------------------------------------

	if resetCombatMode then
		local _,_,lag = GetNetStats();
		Dcr_DelayTimer = lag/1000 + 0.7;
	end
	if cleaned then
		Dcr_CheckAfterCast_On = true;
		Dcr_CheckAfterCast_LeftTime = 1.5;
	elseif (not cleaned) and Dcr_vars.Show_NoCleaned then
		Dcr_println( DCR_NOT_CLEANED);
	end
end

-- range check
function Dcr_UnitInRange(unit,slot)
	if CheckInteractDistance(unit, 4) then
		return true;
	else
		if UnitIsUnit(unit,"target") then
			if IsActionInRange(slot) == 1 then
				return true;
			end
		else
			TargetUnit(unit);
			if IsActionInRange(slot) == 1 then
				TargetLastTarget();
				return true;
			else
				TargetLastTarget();
			end
		end
	end
	return false;
end

-- cast spell functions
function Dcr_CastSpell_Client(spell,book)
	CastSpell(spell,book);
end

function Dcr_Cure_Charmed(unit,hasTarget)
	Dcr_Casting_Unit = unit;
	local spell;
	if DCR_SPELL_CHARMED_2 > 0 then
		spell = DCR_SPELL_CHARMED_2;
	else
		spell = DCR_SPELL_CHARMED_1;
	end
	if UnitIsUnit(unit,"target") then
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);--萨满的净化是无法等待选择目标的,所以施法部分完全不同
	else
		TargetUnit(unit);
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);
		TargetLastTarget();
	end
	Dcr_println( string.gsub( string.gsub( string.gsub(DCR_CLEAN_STRING, "$t", (UnitName(unit))), "$a", DCR_CHARMED), "$s", (GetSpellName(spell, SpellBookFrame.bookType))));
	return true;
end

function Dcr_Cure_Magic(unit,hasTarget)
	Dcr_Casting_Unit = unit;
	local spell;
	if DCR_SPELL_MAGIC_2 > 0 then
		spell = DCR_SPELL_MAGIC_2;
	else
		spell = DCR_SPELL_MAGIC_1;
	end
	if unit == "target" then
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);
	else
		ClearTarget();
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);
		if SpellIsTargeting() then
			if not SpellCanTargetUnit(unit) then
				SpellStopCasting();
				if hasTarget then
					TargetLastTarget();
				end
				return false;
			end
			SpellTargetUnit(unit);
			if hasTarget then
				TargetLastTarget();
			end
		end
	end
	Dcr_println( string.gsub( string.gsub( string.gsub(DCR_CLEAN_STRING, "$t", (UnitName(unit))), "$a", DCR_MAGIC), "$s", (GetSpellName(spell, SpellBookFrame.bookType))));
	return true;
end

function Dcr_Cure_Curse(unit,hasTarget)
	Dcr_Casting_Unit = unit;
	if unit == "target" then
		Dcr_CastSpell_Client(DCR_SPELL_CURSE, SpellBookFrame.bookType);
	else
		ClearTarget();
		Dcr_CastSpell_Client(DCR_SPELL_CURSE, SpellBookFrame.bookType);
		if SpellIsTargeting() then
			if not SpellCanTargetUnit(unit) then
				SpellStopCasting();
				if hasTarget then
					TargetLastTarget();
				end
				return false;
			end
			SpellTargetUnit(unit);
			if hasTarget then
				TargetLastTarget();
			end
		end
	end
	Dcr_println( string.gsub( string.gsub( string.gsub(DCR_CLEAN_STRING, "$t", (UnitName(unit))), "$a", DCR_CURSE), "$s", (GetSpellName(DCR_SPELL_CURSE, SpellBookFrame.bookType))));
	return true;
end

function Dcr_Cure_Poison(unit,hasTarget)
	if Dcr_CheckUnitForBuff(unit, DCR_SPELL_ABOLISH_POISON) then
		return false;
	end
	Dcr_Casting_Unit = unit;
	local spell;
	if DCR_SPELL_POISON_2 > 0 then
		spell = DCR_SPELL_POISON_2;
	else
		spell = DCR_SPELL_POISON_1;
	end
	if unit == "target" then
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);
	else
		ClearTarget();
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);
		if SpellIsTargeting() then
			if not SpellCanTargetUnit(unit) then
				SpellStopCasting();
				if hasTarget then
					TargetLastTarget();
				end
				return false;
			end
			SpellTargetUnit(unit);
			if hasTarget then
				TargetLastTarget();
			end
		end
	end
	Dcr_println( string.gsub( string.gsub( string.gsub(DCR_CLEAN_STRING, "$t", (UnitName(unit))), "$a", DCR_POISON), "$s", (GetSpellName(spell, SpellBookFrame.bookType))));
	return true;
end

function Dcr_Cure_Disease(unit,hasTarget)
	if Dcr_CheckUnitForBuff(unit, DCR_SPELL_ABOLISH_DISEASE) then
		return false;
	end
	Dcr_Casting_Unit = unit;
	local spell;
	if DCR_SPELL_DISEASE_2 > 0 then
		spell = DCR_SPELL_DISEASE_2;
	else
		spell = DCR_SPELL_DISEASE_1;
	end
	if unit == "target" then
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);
	else
		ClearTarget();
		Dcr_CastSpell_Client(spell, SpellBookFrame.bookType);
		if SpellIsTargeting() then
			if not SpellCanTargetUnit(unit) then
				SpellStopCasting();
				if hasTarget then
					TargetLastTarget();
				end
				return false;
			end
			SpellTargetUnit(unit);
			if hasTarget then
				TargetLastTarget();
			end
		end
	end
	Dcr_println( string.gsub( string.gsub( string.gsub(DCR_CLEAN_STRING, "$t", (UnitName(unit))), "$a", DCR_DISEASE), "$s", (GetSpellName(spell, SpellBookFrame.bookType))));
	return true;
end

function Dcr_CheckUnitForBuff(Unit, BuffName)
	if (Dcr_vars.Check_For_Abolish) then
		for i = 1, 16 do
			local buff_texture = UnitBuff(Unit, i);

			if buff_texture then

				Dcr_Tooltip:SetOwner(Decursive, "ANCHOR_NONE");

				Dcr_TooltipTextRight1:SetText(nil);
				Dcr_Tooltip:SetUnitBuff(Unit, i);

				if (Dcr_TooltipTextLeft1:GetText() == BuffName) then
					Dcr_Tooltip:Hide();
					return true;
				end

				Dcr_Tooltip:Hide();

			end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -