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

📄 ct_raidassist.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 5 页
字号:
			frame.MPBG:Hide();
		end
	end
	if ( stats ) then
		stats["Offline"] = nil;
	end
end

-- Update debuffs
function CT_RA_UpdateUnitDebuffs(debuffs, frame)
	local tempOptions = CT_RAMenu_Options["temp"];
	if ( not frame.group or not tempOptions["ShowGroups"][frame.group.id] ) then
		return;
	end
	local num = 1;
	if ( tempOptions["ShowBuffsDebuffed"] ) then
		num = 2;
	end
	local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(frame.id);
	local stats, setbg = CT_RA_Stats[name], 0;
	if ( name and stats and online and not UnitIsGhost("raid" .. frame.id) and ( not UnitIsDead("raid" .. frame.id) or stats["FD"] ) ) then
		if ( not frame.status ) then
			local defaultColors = tempOptions["DefaultColor"];
			frame:SetBackdropColor(defaultColors.r, defaultColors.g, defaultColors.b, defaultColors.a);
		end
		if ( debuffs ) then
			for key, val in tempOptions["DebuffColors"] do
				for k, v in debuffs do
					local en, de, fr;
					if ( type(val["type"]) == "table" ) then
						en = val["type"]["en"];
						de = val["type"]["de"];
						fr = val["type"]["fr"];
					else
						en = val["type"];
					end
					if ( ( ( en and en == v[1] ) or ( de and de == v[1] ) or ( fr and fr == v[1] ) ) and val["id"] ~= -1 ) then
						if ( tempOptions["ShowBuffsDebuffed"] and num >= 1 ) then
							local button = frame["DebuffButton"..num];
							frameCache[button].Icon:SetTexture("Interface\\Icons\\" ..v[3]);
							button.name = k;
							button.owner = name;
							button.texture = v[3];
							button:Show();
							num = num - 1;
						elseif ( not tempOptions["ShowBuffsDebuffed"] and tempOptions["ShowDebuffs"] and num <= 2 ) then
							local button = frame["DebuffButton"..num];
							frameCache[button].Icon:SetTexture("Interface\\Icons\\" ..v[3]);
							button.name = k;
							button.owner = name;
							button.texture = v[3];
							button:Show();
							num = num + 1;
						end
						if ( setbg == 0 and not frame.status ) then
							frame:SetBackdropColor(val.r, val.g, val.b, val.a);
							setbg = 1;
						end
					end
				end
			end
		end
		if ( tempOptions["ShowBuffsDebuffed"] ) then
			if ( num < 1 ) then
				for i = 1, 4, 1 do
					frame["BuffButton"..i]:Hide();
				end
			end
			for i = num, 1, -1 do
				frame["DebuffButton"..i]:Hide();
			end
		else
			for i = num, 2, 1 do
				frame["DebuffButton"..i]:Hide();
			end
		end
	end
end

-- Get info

function CT_RA_SortClassArray(arr)

	local classValues = {
		[CT_RA_WARRIOR] = 8,
		[CT_RA_PALADIN] = 7,
		[CT_RA_DRUID] = 6,
		[CT_RA_MAGE] = 5,
		[CT_RA_WARLOCK] = 4,
		[CT_RA_ROGUE] = 3,
		[CT_RA_HUNTER] = 2,
		[CT_RA_PRIEST] = 1,
		[CT_RA_SHAMAN] = 0
	};

	local limit, st, j, temp, swapped;
	limit = getn(arr);
	st = 0;
	while ( st < limit ) do
		swapped = false;
		st = st + 1;
		limit = limit - 1;
		local val, val1;

		for j = st, limit, 1 do
			if ( arr[j]["class"] ) then
				val = classValues[arr[j]["class"]];
			else
				val = 0;
			end
			if ( arr[j+1]["class"] ) then
				val1 = classValues[arr[j+1]["class"]];
			else
				val1 = 0;
			end
			if ( val < val1 ) then
				temp = arr[j];
				arr[j] = arr[j+1];
				arr[j+1] = temp;
				swapped = true;
			end
		end
		if ( not swapped ) then return arr; end

		swapped = false;
		for j=limit, st, -1 do
			if ( arr[j]["class"] ) then
				val = classValues[arr[j]["class"]];
			else
				val = 0;
			end
			if ( arr[j+1]["class"] ) then
				val1 = classValues[arr[j+1]["class"]];
			else
				val1 = 0;
			end

			if ( val < val1 ) then
				temp = arr[j];
				arr[j] = arr[j+1];
				arr[j+1] = temp;
				swapped = true;
			end
		end
		if ( not swapped ) then return arr; end
	end
	return arr;
end

function CT_RA_UpdateMT(raidid, mtid, frame, height, key, val)
	local tempOptions = CT_RAMenu_Options["temp"];
	local framecast = frame.CastFrame;
	local frameName = frame.name;
	if ( not tempOptions["ShowMTTT"] or ( UnitIsUnit(mtid, raidid .. "target") or tempOptions["HideColorChange"] ) ) then
		local defaultColors = tempOptions.DefaultColor;
		frame:SetBackdropColor(defaultColors.r, defaultColors.g, defaultColors.b, defaultColors.a);
	else
		frame:SetBackdropColor(1, 0, 0, 1);
	end
	if ( tempOptions["HideBorder"] ) then
		frame.Percent:SetPoint("TOP", frameName, "TOPLEFT", 47, -16);
		frame:SetBackdropBorderColor(1, 1, 1, 0);
		frame.HPBar:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -19);
		frame.HPBG:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -19);
		frame:SetHeight(height-3);
		frame.height = height-3;
		framecast:SetHeight(height-3);
		framecast:SetWidth(85);
	else
		frame:SetBackdropBorderColor(1, 1, 1, 1);
		frame.HPBar:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -22);
		frame.HPBG:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -22);
		frame.Percent:SetPoint("TOP", frameName, "TOPLEFT", 47, -18);
		frame:SetHeight(height);
		frame.height = height;
		framecast:SetHeight(height);
		framecast:SetWidth(90);
	end
	if ( raidid and UnitExists(raidid) and strlen(UnitName(raidid) or "") > 0 ) then
		local health, healthmax, mana, manamax, icon = UnitHealth(raidid), UnitHealthMax(raidid), UnitMana(raidid), UnitManaMax(raidid), GetRaidTargetIndex(raidid);
		frame.Name:SetHeight(15);
		frame.Status:Hide();
		frame.HPBar:Show();
		frame.HPBG:Show();
		frame.MPBar:Show();
		frame.MPBG:Show();
		frame.Name:Show();
		if ( icon ) then
			SetRaidTargetIconTexture(frame.Icon, icon);
			frame.Icon:Show();
		else
			frame.Icon:Hide();
		end
		local manaType = UnitPowerType(raidid);
		if ( ( manaType == 0 and not tempOptions["HideMP"] ) or ( manaType > 0 and not tempOptions["HideRP"] and UnitIsPlayer(raidid) ) ) then
			local manaTbl = ManaBarColor[manaType];
			frame.MPBar:SetStatusBarColor(manaTbl.r, manaTbl.g, manaTbl.b);
			frame.MPBG:SetVertexColor(manaTbl.r, manaTbl.g, manaTbl.b, tempOptions["BGOpacity"]);
			if ( tempOptions["HideBorder"] ) then
				frame:SetHeight(37);
				frame.height = 37;
				framecast:SetHeight(37);
			else
				frame:SetHeight(40);
				frame.height = 40;
				framecast:SetHeight(40);
			end
			frame.MPBar:SetMinMaxValues(0, manamax);
			frame.MPBar:SetValue(mana);
		else
			frame.MPBar:Hide();
			frame.MPBG:Hide();
			if ( tempOptions["HideBorder"] ) then
				frame:SetHeight(33);
				frame.height = 33;
				framecast:SetHeight(33);
			else
				frame:SetHeight(36);
				frame.height = 36;
				framecast:SetHeight(36);
			end
		end
		if ( health and healthmax and not UnitIsDead(raidid) and not UnitIsGhost(raidid) ) then
			if ( tempOptions["ShowHP"] and tempOptions["ShowHP"] <= 4 ) then
				frame.Percent:Show();
			else
				frame.Percent:Hide();
			end
			
			frame.HPBar:SetMinMaxValues(0, healthmax);
			frame.HPBar:SetValue(health);
			
			frame.Percent:SetText(floor(health/healthmax*100+0.5) .. "%");
			local percent = health/healthmax;
			if ( percent >= 0 and percent <= 1 ) then
				local r, g;
				if ( percent > 0.5 ) then
					g = 1;
					r = (1.0 - percent) * 2;
				else
					r = 1;
					g = percent * 2;
				end
				frame.HPBar:SetStatusBarColor(r, g, 0);
				frame.HPBG:SetVertexColor(r, g, 0, tempOptions["BGOpacity"]);
			end
		elseif ( UnitIsDead(raidid) or UnitIsGhost(raidid) ) then
			frame.HPBar:Hide();
			frame.HPBG:Hide();
			frame.Percent:Hide();
			frame.MPBar:Hide();
			frame.MPBG:Hide();
			frame.Status:Show();
			frame.Status:SetText("死亡");
		else
			frame.HPBar:Hide();
			frame.HPBG:Hide();
		end
		frame.Name:SetText(UnitName(raidid));
		if ( UnitCanAttack("player", raidid) ) then
			frame.Name:SetTextColor(1, 0.5, 0);
		else
			frame.Name:SetTextColor(0.5, 1, 0);
		end
		frame.CastFrame.unitName = UnitName(raidid);
	else
		frame.Icon:Hide();
		frame.Percent:Hide();
		frame.HPBar:Hide();
		frame.HPBG:Hide();
		frame.MPBar:Hide();
		frame.MPBG:Hide();
		frame.Status:Hide();
		frame.Name:SetText(val .. "的目标");
		frame.Name:SetHeight(30);
		frame.Name:SetTextColor(1, 0.82, 0);
	end
end
	
function CT_RA_UpdateMTs()
	local tempOptions = CT_RAMenu_Options["temp"];
	CT_RAMTGroupGroupName:SetText("主坦克目标");
	CT_RAMTGroup:Hide();
	CT_RAMTGroupGroupName:Hide();
	for i = 1, 10, 1 do
		local mem = getglobal("CT_RAMTGroupMember" .. i);
		mem:Hide();
		mem:ClearAllPoints();
		if ( i > 1 ) then
			local above = "CT_RAMTGroupMember" .. (i-1);
			if ( tempOptions["HideBorder"] ) then
				if ( tempOptions["HideSpace"] ) then
					if ( tempOptions["ShowReversed"] ) then
						mem:SetPoint("BOTTOMLEFT", above, "TOPLEFT", 0, -10);
					else
						mem:SetPoint("TOPLEFT", above, "BOTTOMLEFT", 0, 10);
					end
				else
					if ( tempOptions["ShowReversed"] ) then
						mem:SetPoint("BOTTOMLEFT", above, "TOPLEFT", 0, -7);
					else
						mem:SetPoint("TOPLEFT", above, "BOTTOMLEFT", 0, 7);
					end
				end
			else
				if ( tempOptions["ShowReversed"] ) then
					mem:SetPoint("BOTTOMLEFT", above, "TOPLEFT", 0, -5);
				else
					mem:SetPoint("TOPLEFT", above, "BOTTOMLEFT", 0, 4);
				end
			end
		else
			if ( tempOptions["ShowReversed"] ) then
				mem:SetPoint("BOTTOMLEFT", "CT_RAMTGroup", "TOPLEFT", 0, -15);
			else
				mem:SetPoint("TOPLEFT", "CT_RAMTGroup", "TOPLEFT", 0, -20);
			end
		end
	end
	if ( GetNumRaidMembers() == 0 or tempOptions["HideMTs"] ) then
		CT_RAMTGroupDrag:Hide();
		return;
	end
	local hide = true;
	for key, val in CT_RA_MainTanks do
		if ( key <= ( tempOptions["ShowNumMTs"] or 10 ) ) then
			local height = tempOptions["MemberHeight"];
			if ( tempOptions["HideMP"] ) then
				height = height - 4;
			end
			local frame = getglobal("CT_RAMTGroupMember" .. key);
			local frameParent = frame.frameParent;
			local raidid, mtid;
			for i = 1, GetNumRaidMembers(), 1 do
				if ( UnitName("raid" .. i) == CT_RA_MainTanks[key] ) then
					raidid = "raid" .. i .. "target";
					mtid = "raid" .. i;
					break;
				end
			end
			if ( raidid and mtid ) then
				local name, hppercent, mppercent = UnitName(raidid), UnitHealth(raidid)/UnitHealthMax(raidid), UnitMana(raidid)/UnitManaMax(raidid);
				if ( name ~= ( frame.unitName or "" ) or hppercent ~= ( frame.hppercent or -1 ) or mppercent ~= ( frame.mppercent or -1 ) or not UnitIsConnected(raidid) ) then
					if ( not UnitIsConnected(raidid) ) then
						frame.unitName = nil; frame.hppercent = nil; frame.mppercent = nil;
					else
						frame.unitName = name; frame.hppercent = hppercent; frame.mppercent = mppercent;
					end
					CT_RA_UpdateMT(raidid, mtid, frame, height, key, val);
				end
				frame:Show();
				frameParent:Show();
			end
			if ( not tempOptions["HideNames"] ) then
				frameCache[frameParent].GroupName:Show();
			else
				frameCache[frameParent].GroupName:Hide();
			end
			if ( not tempOptions["LockGroups"] ) then
				hide = false;
				CT_RAMTGroupDrag:Show();
			end
		end
	end
	if ( hide ) then
		CT_RAMTGroupDrag:Hide();
	end
	CT_RA_UpdateMTTTs();
end

function CT_RA_UpdatePT(raidid, frame, height, key, val)
	local tempOptions = CT_RAMenu_Options["temp"];
	local framecast = getglobal("CT_RAPTGroupMember" .. key .. "CastFrame");
	local frameName = frame.name;
	frame:SetBackdropColor(tempOptions["DefaultColor"]["r"], tempOptions["DefaultColor"]["g"], tempOptions["DefaultColor"]["b"], tempOptions["DefaultColor"]["a"]);
	if ( tempOptions["HideBorder"] ) then
		frame.Percent:SetPoint("TOP", frameName, "TOPLEFT", 47, -16);
		frame:SetBackdropBorderColor(1, 1, 1, 0);
		frame.HPBar:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -19);
		frame.HPBG:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -19);
		frame:SetHeight(height-3);
		frame.height = height-3;
		framecast:SetHeight(height-3);
		framecast:SetWidth(85);
	else
		frame:SetBackdropBorderColor(1, 1, 1, 1);
		frame.HPBar:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -22);
		frame.HPBG:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -22);
		frame.Percent:SetPoint("TOP", frameName, "TOPLEFT", 47, -18);
		frame:SetHeight(height);
		frame.height = height;
		framecast:SetHeight(height);
		framecast:SetWidth(90);
	end
	if ( raidid and UnitExists(raidid) and strlen(UnitName(raidid) or "") > 0 ) then
		local health, healthmax, mana, manamax = UnitHealth(raidid), UnitHealthMax(raidid), UnitMana(raidid), UnitManaMax(raidid);
		frame.Name:SetHeight(15);
		frame.Status:Hide();
		frame.HPBar:Show();
		frame.HPBG:Show();
		frame.MPBar:Show();
		frame.MPBG:Show();
		frame.Name:Show();
		local manaType = UnitPowerType(raidid);
		if ( ( manaType == 0 and not tempOptions["HideMP"] ) or ( manaType > 0 and not tempOptions["HideRP"] and UnitIsPlayer(raidid) 

⌨️ 快捷键说明

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