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

📄 ct_ratarget.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
		if ( v[1] ) then
			if ( UnitName("raid" .. v[1]) ~= v[2] ) then
				for i = 1, GetNumRaidMembers(), 1 do
					if ( UnitName("raid" .. i) == v[2] ) then
						CT_RATarget.MainTanks[k][1] = i;
						break;
					end
				end
			end
		end
	end
	local errorColors = {
		{ 1, 0, 0 },
		{ 0.5, 0, 0.5 },
		{ 0, 0, 1 },
		{ 0, 0.5, 0.5 },
		{ 0, 1, 0 }
	};
	local errors = { };
	for i = 1, 10, 1 do
		getglobal("CT_RATargetFrameTarget" .. i .. "Error"):Hide();
		local mtText = getglobal("CT_RATargetFrameMT" .. i .. "Text");
		local targetText = getglobal("CT_RATargetFrameTarget" .. i .. "Text");
		if ( CT_RATarget.MainTanks[i] ) then
			for k, v in CT_RATarget.MainTanks do
				if ( v[1] ) then
					if ( k ~= i and UnitExists("raid" .. CT_RATarget.MainTanks[i][1] .. "target") and UnitIsUnit("raid" .. v[1] .. "target", "raid" .. CT_RATarget.MainTanks[i][1] .. "target") ) then
						local currIndex;
						local minVal, maxVal = min(k, i), max(k, i);
						for key, val in errors do
							for index, value in val do
								if ( value == minVal ) then
									currIndex = { key, 1 };
									break;
								elseif ( value == maxVal ) then
									currIndex = { key, 2 };
								end
							end
							if ( currIndex ) then
								break;
							end
						end
						if ( currIndex and currIndex[2] == 1 ) then
							tinsert(errors[currIndex[1]], maxVal);
						elseif ( currIndex and currIndex[2] == 2 ) then
							tinsert(errors[currIndex[1]], minVal);
						elseif ( errors[min(k, i)] ) then
							tinsert(errors[minVal], maxVal);
						else
							errors[minVal] = { maxVal };
						end
					end
				end
			end
			mtText:SetText("MT #" .. i .. ": |c00FFFFFF" .. CT_RATarget.MainTanks[i][2] .. "|r");
			targetText:SetTextColor(1, 0.82, 0);
			getglobal("CT_RATargetFrameTarget" .. i).lock = nil;
			if ( getglobal("CT_RATargetFrameTarget" .. i).isOver ) then
				getglobal("CT_RATargetFrameTarget" .. i .. "MouseOver"):Show();
			end
			if ( UnitName("raid" .. CT_RATarget.MainTanks[i][1] .. "target") ) then
				targetText:SetText("目标 #" .. i .. ": |c00FFFFFF" .. UnitName("raid" .. CT_RATarget.MainTanks[i][1] .. "target"));
			else
				targetText:SetText("目标 #" .. i .. ": |c00FFFFFF<没有目标>|r");
			end
		else
			getglobal("CT_RATargetFrameTarget" .. i .. "MouseOver"):Hide();
			getglobal("CT_RATargetFrameTarget" .. i).lock = 1;
			mtText:SetText("MT #" .. i .. ": |c00FFFFFF<没有设置MT>|r");
			targetText:SetTextColor(0.3, 0.3, 0.3);
			targetText:SetText("目标 #" .. i .. ": 没有设置MT");
		end
	end
	local id = 0;
	for k, v in errors do
		if ( id < 5 ) then
			id = id + 1;
			for key, val in v do
				getglobal("CT_RATargetFrameTarget" .. val .. "Error"):Show();
				getglobal("CT_RATargetFrameTarget" .. val .. "Error"):SetVertexColor(errorColors[id][1], errorColors[id][2], errorColors[id][3]);
			end
			getglobal("CT_RATargetFrameTarget" .. k .. "Error"):Show();
			getglobal("CT_RATargetFrameTarget" .. k .. "Error"):SetVertexColor(errorColors[id][1], errorColors[id][2], errorColors[id][3]);
		end
	end
end

function CT_RATarget_SetMT(id)
	if ( UnitExists("target") and UnitInRaid("target") ) then
		for k, v in CT_RATarget.MainTanks do
			if ( v[2] == UnitName("target") ) then
				CT_RATarget_TargetMT(id);
				return;
			end
		end
		CT_RA_MainTanks[id] = UnitName("target");
		for i = 1, GetNumRaidMembers(), 1 do
			if ( UnitIsUnit("target", "raid" .. i) ) then
				CT_RATarget.MainTanks[id] = { i, UnitName("target") };
				break;
			end
		end
		CT_RA_AddMessage("SET " .. id .. " " .. UnitName("target"));
		CT_RATarget.holdInfo = 2;
		CT_RATargetFrameInfoBoxText:SetText("成功设置|c00FFFFFF" .. UnitName("target") .. "|r为MT |c00FFFFFF#" .. id .. "|r。");
		CT_RATargetFrameInfoBox.lock = 1;
		CT_RATargetFrameInfoBoxMouseOver:Hide();
	end
	CT_RATarget_UpdateStats();
end

function CT_RATarget_RemoveMT(id)
	if ( CT_RATarget.MainTanks[id] ) then
		CT_RATarget.holdInfo = 2;
		CT_RATargetFrameInfoBoxText:SetText("成功从MT列表中移除|c00FFFFFF" .. CT_RATarget.MainTanks[id][2] .. "|r。");
	end
	CT_RATargetFrameInfoBox.lock = 1;
	CT_RATargetFrameInfoBoxMouseOver:Hide();
	if ( CT_RA_MainTanks[id] ) then
		CT_RA_AddMessage("R " .. CT_RA_MainTanks[id]);
	end
	CT_RA_MainTanks[id] = nil;
	CT_RATarget.MainTanks[id] = nil;
	CT_RATarget_UpdateStats();
end

function CT_RATarget_MTAssist(id)
	if ( CT_RATarget.MainTanks[id] and CT_RA_Level >= 1 and not UnitIsUnit("player", "raid" .. CT_RATarget.MainTanks[id][1]) ) then
		for k, v in CT_RATarget.MainTanks do
			if ( UnitIsUnit("target", "raid" .. v[1] .. "target") and not UnitIsUnit("player", "raid" .. v[1]) ) then
				return;
			end
		end
		if ( not CT_RA_Stats[CT_RATarget.MainTanks[id][2]] or not CT_RA_Stats[CT_RATarget.MainTanks[id][2]]["Reporting"] or not CT_RA_Stats[CT_RATarget.MainTanks[id][2]]["Version"] or CT_RA_Stats[CT_RATarget.MainTanks[id][2]]["Version"] < 1.4 ) then
			SendChatMessage("<团队助手> 请协助我以获得分配给你的目标。选择我,然后按协助键(默认F)", "WHISPER", nil, CT_RATarget.MainTanks[id][2]);
			SendChatMessage("<团队助手> " .. CT_RATarget.MainTanks[id][2] .. ",请协助我以获得分配给你的目标。选择我,然后按协助键(默认F)", "RAID");
		end
		if ( CT_RA_HMark ) then
			CastSpell(CT_RA_HMark[1], CT_RA_HMark[2]);
		end
		CT_RA_AddMessage("ASSISTME " .. CT_RATarget.MainTanks[id][2]);
		CT_RATarget.waitingForAssist = { 20, CT_RATarget.MainTanks[id][2], CT_RATarget.MainTanks[id][1], id } ;
		CT_RATarget_UpdateInfoBox();
	end
end

function CT_RATarget_TargetMT(id)
	if ( CT_RATarget.MainTanks[id] ) then
		TargetUnit("raid" .. CT_RATarget.MainTanks[id][1]);
		CT_RATarget_UpdateInfoBox();
	end
end

function CT_RATarget_AssistMT(id)
	if ( CT_RATarget.MainTanks[id] ) then
		AssistUnit("raid" .. CT_RATarget.MainTanks[id][1]);
		CT_RATarget_UpdateInfoBox();
	end
end

function CT_RATarget_CancelAssist()
	CT_RA_AddMessage("STOPASSIST " .. CT_RATarget.waitingForAssist[2]);
	CT_RATarget.waitingForAssist = nil;
	CT_RATarget_UpdateInfoBox();
end

function CT_RATarget_CheckAssist()
	if ( CT_RATarget.waitingForAssist and UnitIsUnit("target", "raid" .. CT_RATarget.waitingForAssist[3] .. "target") ) then
		CT_RATarget.holdInfo = 0.75;
		CT_RATargetFrameInfoBoxText:SetText("|c00FFFFFF" .. CT_RATarget.waitingForAssist[2] .. "|r (MT |c00FFFFFF#" .. CT_RATarget.waitingForAssist[4] .. "|r) 已获取了你的目标。");
		CT_RATarget.waitingForAssist = nil;
		CT_RATargetFrameInfoBox.lock = 1;
		CT_RATargetFrameInfoBoxMouseOver:Hide();
	end
end

-- Slash command
CT_RA_RegisterSlashCmd("/tm", "显示目标管理系统对话框。", 15, "TM", function()
	if ( CT_RA_Level >= 1 ) then
		if ( CT_RATargetFrame:IsVisible() ) then
			HideUIPanel(CT_RATargetFrame);
		else
			ShowUIPanel(CT_RATargetFrame);
		end
	else
		CT_RA_Print("<团队助手> 你必须是团队领袖或者助理才能那么做!", 1, 0.5, 0);
	end
end, "/tm");

-- Add to UISpecialFrames
tinsert(UISpecialFrames, "CT_RATargetFrame");

function AttackMTTarget()
	if ( CT_RA_Level < 1 ) then
		return;
	end

	if ( not UnitExists("target") ) then
		return;
	end

	local isMTTarget = false;
	local mtid = nil;
	local icons = { "星形", "圆形", "菱形", "三角", "月亮", "方块", "十字", "骷髅" };

	for k, v in CT_RATarget.MainTanks do
		if ( v[1] ) then
			if ( UnitIsUnit("raid" .. v[1] .. "target", "target") ) then
				mtid = k;
				break;
			end
		end
	end

	local sMsg = "";
	local icon = "";
	local index = GetRaidTargetIndex("target");
	if (index) then
		icon = " " .. icons[index];
	end

	if ( mtid ) then
		sMsg = "攻击 MT" .. mtid .. " 目标:>>> " .. UnitName("target") .. " <<<" .. icon;
	else
		sMsg = "攻击 >>> " .. UnitName("target") .. " <<<" .. icon;
	end

	CT_RA_AddMessage("MS " .. sMsg);
end

⌨️ 快捷键说明

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