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

📄 ct_radebuffs.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
		while ( UnitDebuff("player", iIndex) ) do
			-- Clear and set the tooltip
			CT_RATooltipTextLeft1:SetText("");
			CT_RATooltipTextRight1:SetText("");
			CT_RATooltip:SetUnitDebuff("player", iIndex);
			
			-- Control to make sure we have a new debuff
			if ( CT_RATooltipTextLeft1:GetText() ~= "" ) then
				-- Fetch the data
				local sName, sType, sDesc, iTblIndex = CT_RATooltipTextLeft1:GetText() or "", CT_RATooltipTextRight1:GetText() or "", CT_RATooltipTextLeft2:GetText() or "", -1;
				if ( sType ~= "" and ( UIParent.GetEffectiveScale or CT_RADebuff_CanCure(sType) ) and not CT_RADebuff_IgnoreDebuffs[(sName or "")] ) then
					-- See if we can find the CT_RA_DebuffTemplates index
					for k, v in CT_RA_DebuffTemplates do
						
						-- See if we have a match
						if ( string.find(strlower(sName), strlower(v["debuffName"])) and string.find(strlower(sType), strlower(v["debuffType"])) and string.find(strlower(sDesc), strlower(v["debuffDesc"])) ) then
							iTblIndex = k;
							break;
						end
					end
					
					if ( iTblIndex > 0 and ( not CT_RADebuff_CureTable[2] or CT_RADebuff_CureTable[2] > iTblIndex ) ) then
						-- Clean the table
						CT_RADebuff_CureTable = {
							[1] = {
								{ sName, sType, sDesc, "player", CT_RADebuff_ClassIndexes[UnitClass("player")], UnitHealth("player") }
							},
							[2] = iTblIndex
						};
						
					elseif ( iTblIndex > 0 and iTblIndex == CT_RADebuff_CureTable[2] ) then
						-- Add the data to the table, as well as class, health percentage, if the player is in your party or if the player is you
						tinsert(CT_RADebuff_CureTable[1], { sName, sType, sDesc, "player", CT_RADebuff_ClassIndexes[UnitClass("player")], UnitHealth("player") });
						
					end
				end
			end
			
			iIndex = iIndex + 1;
			
		end
		if ( UnitExists("pet") ) then
			local iIndex = 1;
			
			-- Loop through the debuffs
			while ( UnitDebuff("pet", iIndex, 1) ) do
				-- Clear and set the tooltip
				CT_RATooltipTextLeft1:SetText("");
				CT_RATooltipTextRight1:SetText("");
				CT_RATooltip:SetUnitDebuff("pet", iIndex);
				
				-- Control to make sure we have a new debuff
				if ( CT_RATooltipTextLeft1:GetText() ~= "" ) then
				
					-- Fetch the data
					local sName, sType, sDesc, iTblIndex = CT_RATooltipTextLeft1:GetText() or "", CT_RATooltipTextRight1:GetText() or "", CT_RATooltipTextLeft2:GetText() or "", -1;
					if ( sType ~= "" and ( UIParent.GetEffectiveScale or CT_RADebuff_CanCure(sType) ) and not CT_RADebuff_IgnoreDebuffs[(sName or "")] ) then
						-- See if we can find the CT_RA_DebuffTemplates index
						for k, v in CT_RA_DebuffTemplates do
							
							-- See if we have a match
							if ( string.find(strlower(sName), strlower(v["debuffName"])) and string.find(strlower(sType), strlower(v["debuffType"])) and string.find(strlower(sDesc), strlower(v["debuffDesc"])) ) then
								iTblIndex = k;
								break;
							end
						end
						
						if ( iTblIndex > 0 and ( not CT_RADebuff_CureTable[2] or CT_RADebuff_CureTable[2] > iTblIndex ) ) then
							-- Clean the table
							CT_RADebuff_CureTable = {
								[1] = {
									{ sName, sType, sDesc, "pet", CT_RADebuff_ClassIndexes[UnitClass("pet")], UnitHealth("pet") }
								},
								[2] = iTblIndex
							};
							
						elseif ( iTblIndex > 0 and iTblIndex == CT_RADebuff_CureTable[2] ) then
							-- Add the data to the table, as well as class, health percentage, if the player is in your party or if the player is you
							tinsert(CT_RADebuff_CureTable[1], { sName, sType, sDesc, "pet", CT_RADebuff_ClassIndexes[UnitClass("pet")], UnitHealth("pet") });
							
						end
					end
				end
				
				iIndex = iIndex + 1;
				
			end
		end
	end
	local prefix, func = "raid", GetNumRaidMembers;
	if ( GetNumRaidMembers() == 0 and GetNumPartyMembers() > 0 ) then
		prefix, func = "party", GetNumPartyMembers;
	end
	-- Loop through the players in the raid
	for i = 1, func(), 1 do
		if ( not UnitCanAttack("player", prefix .. i) or ( UnitIsCharmed(prefix .. i) and UnitIsFriend("player", prefix .. i) ) ) then
			local iIndex = 1;
			
			-- Loop through the debuffs
			while ( UnitDebuff(prefix .. i, iIndex, 1) ) do
				-- Clear and set the tooltip
				CT_RATooltipTextLeft1:SetText("");
				CT_RATooltipTextRight1:SetText("");
				CT_RATooltip:SetUnitDebuff(prefix .. i, iIndex);
				
				-- Control to make sure we have a new debuff
				if ( CT_RATooltipTextLeft1:GetText() ~= "" ) then

					-- Fetch the data
					local sName, sType, sDesc, iTblIndex = CT_RATooltipTextLeft1:GetText() or "", CT_RATooltipTextRight1:GetText() or "", CT_RATooltipTextLeft2:GetText() or "", -1;
					if ( sType ~= "" and ( UIParent.GetEffectiveScale or CT_RADebuff_CanCure(sType) ) and not CT_RADebuff_IgnoreDebuffs[(sName or "")] ) then
						-- See if we can find the CT_RA_DebuffTemplates index
						for k, v in CT_RA_DebuffTemplates do
							
							-- See if we have a match
							if ( string.find(strlower(sName), strlower(v["debuffName"])) and string.find(strlower(sType), strlower(v["debuffType"])) and string.find(strlower(sDesc), strlower(v["debuffDesc"])) ) then
								iTblIndex = k;
								break;
							end
						end
						
						if ( iTblIndex > 0 and ( not CT_RADebuff_CureTable[2] or CT_RADebuff_CureTable[2] > iTblIndex ) ) then
							-- Clean the table
							CT_RADebuff_CureTable = {
								[1] = {
									{ sName, sType, sDesc, prefix .. i, CT_RADebuff_ClassIndexes[UnitClass(prefix .. i)], UnitHealth(prefix .. i) }
								},
								[2] = iTblIndex
							};
							
						elseif ( iTblIndex > 0 and iTblIndex == CT_RADebuff_CureTable[2] ) then
							-- Add the data to the table, as well as class, health percentage, if the player is in your party or if the player is you
							tinsert(CT_RADebuff_CureTable[1], { sName, sType, sDesc, prefix .. i, CT_RADebuff_ClassIndexes[UnitClass(prefix .. i)], UnitHealth(prefix .. i) });
							
						end
					end
				end
				
				iIndex = iIndex + 1;
				
			end
		end
		if ( UnitExists(prefix .. "pet" .. i) and ( not UnitCanAttack("player", prefix .. "pet" .. i) or ( UnitIsCharmed(prefix .. "pet" .. i) and UnitIsFriend("player", prefix .. "pet" .. i) ) ) ) then
			local iIndex = 1;
			-- Loop through the debuffs
			while ( UnitDebuff(prefix .. "pet" .. i, iIndex, 1) ) do
				-- Clear and set the tooltip
				CT_RATooltipTextLeft1:SetText("");
				CT_RATooltipTextRight1:SetText("");
				CT_RATooltip:SetUnitDebuff(prefix .. "pet" .. i, iIndex);
				
				-- Control to make sure we have a new debuff
				if ( CT_RATooltipTextLeft1:GetText() ~= "" ) then
				
					-- Fetch the data
					local sName, sType, sDesc, iTblIndex = CT_RATooltipTextLeft1:GetText() or "", CT_RATooltipTextRight1:GetText() or "", CT_RATooltipTextLeft2:GetText() or "", -1;
					if ( sType ~= "" and ( UIParent.GetEffectiveScale or CT_RADebuff_CanCure(sType) ) and not CT_RADebuff_IgnoreDebuffs[(sName or "")] ) then
						-- See if we can find the CT_RA_DebuffTemplates index
						for k, v in CT_RA_DebuffTemplates do
							
							-- See if we have a match
							if ( string.find(strlower(sName), strlower(v["debuffName"])) and string.find(strlower(sType), strlower(v["debuffType"])) and string.find(strlower(sDesc), strlower(v["debuffDesc"])) ) then
								iTblIndex = k;
								break;
							end
						end
						
						if ( iTblIndex > 0 and ( not CT_RADebuff_CureTable[2] or CT_RADebuff_CureTable[2] > iTblIndex ) ) then
							-- Clean the table
							CT_RADebuff_CureTable = {
								[1] = {
									{ sName, sType, sDesc, prefix .. "pet" .. i, CT_RADebuff_ClassIndexes[UnitClass(prefix .. "pet" .. i)], UnitHealth(prefix .. "pet" .. i) }
								},
								[2] = iTblIndex
							};
							
						elseif ( iTblIndex > 0 and iTblIndex == CT_RADebuff_CureTable[2] ) then
							-- Add the data to the table, as well as class, health percentage, if the player is in your party or if the player is you
							tinsert(CT_RADebuff_CureTable[1], { sName, sType, sDesc, prefix .. "pet" .. i, CT_RADebuff_ClassIndexes[UnitClass(prefix .. "pet" .. i)], UnitHealth(prefix .. "pet" .. i) });
							
						end
					end
				end
				
				iIndex = iIndex + 1;
				
			end
		end
	end
end

----------------------------------------------------------------
--                 CT_RADebuff_BeginRangeCheck()              --
--   Finds the first cure ability available and uses it for   --
--                      range measurement.                    --
----------------------------------------------------------------

function CT_RADebuff_BeginRangeCheck()
	-- Returns:
		-- nil -> Failure
		-- 0 -> Success
		-- 1 -> Success & Change target back
	local shallSwitch = false;
	if ( UnitExists("target") ) then
		if ( CT_RADebuff_InCombat ) then
			resetCombat = 1;
		end
		shallSwitch = true;
		ClearTarget();
	end
	
	for k, v in CT_RADebuff_CureSpells[UnitClass("player")] do
		if ( type(v) == "table" ) then
			for key, val in v do
				if ( CT_RA_ClassSpells[val] ) then
					CastSpell(CT_RA_ClassSpells[val]["spell"], CT_RA_ClassSpells[val]["tab"]+1);
					break;
				end
			end
		else
			if ( CT_RA_ClassSpells[v] ) then
				CastSpell(CT_RA_ClassSpells[v]["spell"], CT_RA_ClassSpells[v]["tab"]+1);
				break;
			end
		end
	end
	if ( SpellIsTargeting() ) then
		return 1, ( shallSwitch and 1 ) or 0;
	else
		return nil, ( shallSwitch and 1 ) or 0;
	end
end
----------------------------------------------------------------
--                     CT_RADebuff_Cure()                     --
-- Cures the next person in the list, using the chosen order. --
--      This is where most of the curing stuff is done.       --
----------------------------------------------------------------
function CT_RADebuff_Cure()
	if ( not CT_RADebuff_CureSpells[UnitClass("player")] ) then
		return;
	end
	local cannotCast, cooldownStart, cooldownDuration, oorTargets;
	for k, v in CT_RADebuff_CureSpells[UnitClass("player")] do
		if ( type(v) == "table" ) then
			for key, val in v do
				if ( CT_RA_ClassSpells[val] ) then
					cooldownStart, cooldownDuration = GetSpellCooldown(CT_RA_ClassSpells[val]["spell"], SpellBookFrame.bookType);
					if ( cooldownStart > 0 and cooldownDuration > 0 ) then
						cannotCast = true;
						break;
					end
				end
			end
		else
			if ( CT_RA_ClassSpells[v] ) then
				cooldownStart, cooldownDuration = GetSpellCooldown(CT_RA_ClassSpells[v]["spell"], SpellBookFrame.bookType);
				if ( cooldownStart > 0 and cooldownDuration > 0 ) then
					cannotCast = true;
					break;
				end
			end
		end
	end
	if ( cannotCast ) then
		return;
	end
	CT_RADebuff_UpdateCureTable();
	local success, retarget = CT_RADebuff_BeginRangeCheck();
	if ( not success ) then
		-- We couldn't cast the spell for some reason...
		SpellStopTargeting();
		if ( retarget == 1 ) then
			TargetLastTarget();
		end
		return;
	end
	-- Make sure we have an index
	if ( CT_RADebuff_CureTable[2] ) then
		
		-- Process if we have a target to cure
		local blacklistTable, blacklistUId, uId, tblIndex;
		while ( getn(CT_RADebuff_CureTable[1]) > 0 ) do
			uId, tblIndex = CT_RADebuff_PriorityCure(CT_RA_DebuffTemplates[CT_RADebuff_CureTable[2]]["cureOrder"], CT_RADebuff_CureTable[1], CT_RA_DebuffTemplates[CT_RADebuff_CureTable[2]]["affectClasses"]);
			if ( uId ) then
				if ( uId == "target" ) then
					SpellStopCasting();
					TargetLastTarget();
					if ( not blacklistUId and CT_RADebuff_Blacklist[UnitName(uId)] ) then
						blacklistUId, blacklistTable = ( blacklistUId or uId), ( blacklistTable or CT_RADebuff_CureTable[1][tblIndex] );
					else
						local shallReturn = CT_RADebuff_CureTarget(CT_RADebuff_CureTable[1][tblIndex][2], CT_RADebuff_CureTable[1][tblIndex][1], uId);
						if ( shallReturn == 1 ) then
							SpellStopTargeting();
							if ( retarget == 1 ) then
								TargetLastTarget();
								if ( resetCombat ) then
									CT_RADebuff_ResetCombat = 1;
								end
							end
							return;
						elseif ( not oorTargets and shallReturn == -1 ) then
							oorTargets = { UnitName(uId), CT_RADebuff_CureTable[1][tblIndex][1], CT_RADebuff_CureTable[1][tblIndex][2] };
						end
					end
					-- Redo the check since we cleared target and spell
					success, retarget = CT_RADebuff_BeginRangeCheck();
					if ( not success ) then
						-- We couldn't cast the spell for some reason...
						SpellStopTargeting();
						if ( retarget == 1 ) then
							TargetLastTarget();
						end
						return;
					end
				else
					if ( not blacklistUId and CT_RADebuff_Blacklist[UnitName(uId)] ) then
						blacklistUId, blacklistTable = ( blacklistUId or uId), ( blacklistTable or CT_RADebuff_CureTable[1][tblIndex] );
					else
						if ( SpellCanTargetUnit(uId) ) then
							-- Unit could be cast upon! Grab the opportunity
							local shallReturn = CT_RADebuff_CureTarget(CT_RADebuff_CureTable[1][tblIndex][2], CT_RADebuff_CureTable[1][tblIndex][1], uId);
							if ( shallReturn == 1 ) then
								SpellStopTargeting();
								if ( retarget == 1 ) then
									TargetLastTarget();
									if ( resetCombat ) then
										CT_RADebuff_ResetCombat = 1;
									end
								end
								return;
							end
						elseif ( not oorTargets and shallReturn == -1 ) then
							oorTargets = { UnitName(uId), CT_RADebuff_CureTable[1][tblIndex][1], CT_RADebuff_CureTable[1][tblIndex][2] };
						end
					end
				end
			elseif ( blacklistUId ) then
				uId, tblIndex, cureBlacklisted = blacklistUId, 1, 1;
				tinsert(CT_RADebuff_CureTable[1], 1, blacklistTable);
				blacklistUId, blacklistTable = nil;
			end
			if ( tblIndex ) then
				-- Remove the previous one, and check again
				table.remove(CT_RADebuff_CureTable[1], tblIndex);
			else
				break;
			end
		end
		if ( oorTargets ) then
			-- We could not cure due to targets being out of range
			CT_RA_Print("<团队助手> 无法治愈|c00FFFFFF" .. oorTargets[1] .. "|r身上的|c00FFFFFF" .. oorTargets[2] .. "|r (|c00FFFFFF" .. oorTargets[3] .. "|r)(超出范围?)。", 1, 0.5, 0);
		end
	end
	SpellStopTargeting();
	if ( retarget == 1 ) then
		TargetLastTarget();
		if ( resetCombat ) then
			CT_RADebuff_ResetCombat = 1;
		end
	end
end

function CT_RADebuff_Cure_DEPRECATED()
	if ( not CT_RADebuff_CureSpells[UnitClass("player")] ) then
		return;
	end
	local cannotCast, cooldownStart, cooldownDuration, oorTargets;
	for k, v in CT_RADebuff_CureSpells[UnitClass("player")] do
		if ( type(v) == "table" ) then
			for key, val in v do
				if ( CT_RA_ClassSpells[val] ) then
					cooldownStart, cooldownDuration = GetSpellCooldown(CT_RA_ClassSpells[val]["spell"], SpellBookFrame.bookType);
					if ( cooldownStart > 0 and cooldownDuration > 0 ) then
						cannotCast = true;
						break;
					end
				end
			end
		else
			if ( CT_RA_ClassSpells[v] ) then
				cooldownStart, cooldownDuration = GetSpellCooldown(CT_RA_ClassSpells[v]["spell"], SpellBookFrame.bookType);
				if ( cooldownStart > 0 and cooldownDuration > 0 ) then
					cannotCast = true;

⌨️ 快捷键说明

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