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

📄 ct_raidassist.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 5 页
字号:
		end
		return update;
	elseif ( string.find(msg, "^RST ") ) then
		local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(raidid);
		local _, _, plrName = string.find(msg, "^RST %-1 ([^%s]+)$");
		if ( plrName and plrName == playerName ) then
			CT_RADurability_Add(nick, "|c00FFFFFF已禁止查询|r", fileName, -1, -1, -1, -1, -1);
		else
			local _, _, FR, NR, FRR, SR, AR, callPerson = string.find(msg, "^RST (%d+) (%d+) (%d+) (%d+) (%d+) ([^%s]+)$");
			if ( FR and callPerson == playerName ) then
				CT_RADurability_Add(nick, "", fileName, tonumber(FR), tonumber(NR), tonumber(FRR), tonumber(SR), tonumber(AR) );
			end
		end
		return update;
	end
	
	-- Check reagents
	if ( msg == "REAC" ) then
		if ( rank == 0 ) then
			return update;
		end
		local numItems = CT_RAReagents_GetReagents();
		if ( numItems and numItems >= 0 ) then
			CT_RA_AddMessage("REA " .. numItems .. " " .. nick);
		end
		return update;
	elseif ( string.find(msg, "^REA ") ) then
		local _, _, numItems, callPerson = string.find(msg, "^REA ([^%s]+) ([^%s]+)$");
		if ( numItems and callPerson and callPerson == playerName ) then
			local classes = {
				[CT_RA_PRIEST] = CT_REG_PRIEST,
				[CT_RA_MAGE] = CT_REG_MAGE,
				[CT_RA_DRUID] = CT_REG_DRUID,
				[CT_RA_WARLOCK] = CT_REG_WARLOCK,
				[CT_RA_PALADIN] = CT_REG_PALADIN,
				[CT_RA_SHAMAN] = CT_REG_SHAMAN
			};
			local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(raidid);
--			if ( numItems ~= "1" ) then
--				CT_RADurability_Add(nick, "|c00FFFFFF" .. numItems .. "|r " .. classes[UnitClass("raid"..raidid)] .. "s", fileName, numItems);
--			else
				CT_RADurability_Add(nick, "|c00FFFFFF" .. numItems .. "|r " .. classes[UnitClass("raid"..raidid)], fileName, numItems );
--			end
		end
		return update;
	end
	
	-- Check items
	if ( string.find(msg, "^ITMC ") ) then
		local _, _, itemName = string.find(msg, "^ITMC (.+)$");
		if ( itemName ) then
			if ( rank == 0 ) then
				return;
			end
			if ( tempOptions["DisableQuery"] ) then
				CT_RA_AddMessage("ITM " .. -1 .. " " .. itemName .. " " .. nick);
			else
				local numItems = CT_RAItem_GetItems(itemName);
				if ( numItems and numItems > 0 ) then
					CT_RA_AddMessage("ITM " .. numItems .. " " .. itemName .. " " .. nick);
				end
			end
		end
		return update;
	elseif ( string.find(msg, "^ITM ") ) then
		local _, _, numItems, itemName, callPerson = string.find(msg, "^ITM ([-%d]+) (.+) ([^%s]+)$");
		if ( numItems and itemName and callPerson and callPerson == UnitName("player") ) then
			local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(raidid);
			if ( numItems == "-1" ) then
				CT_RADurability_Add(nick, "|c00FFFFFF已禁止查询|r", fileName, "0", class);
--			elseif ( numItems ~= "1" ) then
--				CT_RADurability_Add(nick, "|c00FFFFFF" .. numItems .. "|r " .. itemName .. "s", fileName, numItems);
			else
				CT_RADurability_Add(nick, "|c00FFFFFF" .. numItems .. "|r " .. itemName, fileName, numItems);
			end
		end
		return update;
	end
	
	-- Check cooldowns
	if ( string.find(msg, "^CD %d+ %d+$") ) then
		local _, _, num, cooldown = string.find(msg, "^CD (%d+) (%d+)$");
		if ( num == "1" ) then
			unitStats["Rebirth"] = tonumber(cooldown)*60;
		elseif ( num == "2" ) then
			unitStats["Reincarnation"] = tonumber(cooldown)*60;
		elseif ( num == "3" ) then
			unitStats["Soulstone"] = tonumber(cooldown)*60;
		end
		return update;
	end
	
	-- Assist requests
	if ( string.find(msg, "^ASSISTME (.+)$") ) then
		if ( rank >= 1 ) then
			local _, _, name = string.find(msg, "^ASSISTME (.+)$");
			if ( name and name == playerName ) then
				CT_RATarget.assistPerson = { nick, 20 };
				ShowUIPanel(CT_RA_AssistFrame);
			end
		end
		return update;
	elseif ( string.find(msg, "^STOPASSIST (.+)$") ) then
		if ( rank >= 1 ) then
			local _, _, name = string.find(msg, "^STOPASSIST (.+)$");
			if ( name and name == playerName ) then
				HideUIPanel(CT_RA_AssistFrame);
			end
		end
		return update;
	end
	
	-- Vote
	local _, _, question = string.find(msg, "^VOTE (.+)$");
	if ( question ) then
		if ( rank >= 1 ) then
			CT_RA_VotePerson = { nick, 0, 0, question };
			if ( nick ~= playerName ) then
				PlaySoundFile("Sound\\interface\\levelup2.wav");
				CT_RA_VoteFrame.question = question;
				CT_RA_VoteFrame:Show();
			end
		end
		return update;
	elseif ( ( msg == "VOTEYES" or msg == "VOTENO" ) and CT_RA_VotePerson and CT_RA_VotePerson[1] == playerName ) then
		if ( msg == "VOTEYES" ) then
			CT_RA_VotePerson[2] = CT_RA_VotePerson[2] + 1;
		elseif ( msg == "VOTENO" ) then
			CT_RA_VotePerson[3] = CT_RA_VotePerson[3] + 1;
		end
		return update;
	end
	
	return update;
end

-- Send messages
function CT_RA_AddMessage(msg)
	tinsert(CT_RA_Comm_MessageQueue, msg);
end

function CT_RA_SendMessage(msg)
	if ( GetNumRaidMembers() == 0 ) then return; end -- Mod should be disabled if not in raid
	SendAddonMessage("CTRA", msg, "RAID");
end

function CT_RA_OnEvent(event)
	if ( event == "PLAYER_LEAVING_WORLD" ) then
		CT_RAFrame.disableEvents = true;
		return;
	elseif ( CT_RAFrame.disableEvents and event ~= "PLAYER_ENTERING_WORLD" ) then
		return;
	elseif ( event == "PLAYER_ENTERING_WORLD" or event == "RAID_ROSTER_UPDATE" ) then
		CT_RAFrame.disableEvents = nil;
		local numRaidMembers = GetNumRaidMembers();
		local playerName = UnitName("player");
		local tempOptions = CT_RAMenu_Options["temp"];
		if ( event == "RAID_ROSTER_UPDATE" ) then
			if ( numRaidMembers == 0 ) then
				CT_RA_MainTanks = { };
				CT_RA_PTargets = { };
				CT_RATarget.MainTanks = { };
				CT_RA_Stats = { };
				CT_RA_ButtonIndexes = { };
				CT_RA_Emergency_UpdateHealth();
				CT_RA_UpdateMTs();
				CT_RA_UpdatePTs();
			elseif ( CT_RA_NumRaidMembers == 0 and numRaidMembers > 0 ) then
				CT_RA_UpdateFrame.SS = 10;
				if ( CT_RA_UpdateFrame.time ) then
					CT_RA_UpdateFrame.time = nil;
				end
				if ( not CT_RA_HasJoinedRaid ) then
					CT_RA_Print("<团队助手> 检测到第一个团队。感谢使用团队助手!", 1, 0.5, 0);
				end
				CT_RA_PartyMembers = { };
				CT_RA_HasJoinedRaid = 1;
				if ( CT_RA_Squelch > 0 ) then
					CT_RA_Print("<团队助手> 禁言模式已自动停用。(加入团队)", 1, 0.5, 0);
					CT_RA_Squelch = 0;
				end
			end
			CT_RA_CheckGroups();
		end
		if ( numRaidMembers > 0 ) then
			if ( tempOptions["StatusMeters"] and tempOptions["StatusMeters"]["Show"] ) then
				CT_RARaidOverviewFrame:Show();
			else
				CT_RARaidOverviewFrame:Hide();
			end
			if ( tempOptions["ShowMonitor"] ) then
				CT_RA_ResFrame:Show();
			else
				CT_RA_ResFrame:Hide();
			end
		else
			CT_RA_ResFrame:Hide();
		end
		CT_RAOptions_Update();
		if ( CT_RA_NumRaidMembers ~= numRaidMembers ) then
			for i = 1, numRaidMembers, 1 do
				local uId = "raid" .. i;
				local uName = UnitName(uId);
				if ( uName and CT_RA_Stats[uName] ) then
					table.setn(CT_RA_Stats[uName]["Debuffs"], 0);
				end
				CT_RA_ScanPartyAuras(uId);
			end
			CT_RA_UpdateRaidGroup(0);
			if ( CT_RA_NumRaidMembers == 0 and CT_RA_Level >= 2 ) then
				local lootid = ( CT_RATab_DefaultLootMethod or -1 );
				if ( lootid == 1 ) then
					SetLootMethod("freeforall");
				elseif ( lootid == 2 ) then
					SetLootMethod("roundrobin");
				elseif ( lootid == 3 ) then
					SetLootMethod("master", playerName);
				elseif ( lootid == 4 ) then
					SetLootMethod("group");
				elseif ( lootid == 5 ) then
					SetLootMethod("needbeforegreed");
				end
				for i = 1, numRaidMembers, 1 do
					local name, rank = GetRaidRosterInfo(i);
					if ( name ~= playerName and rank < 1 and CT_RATab_AutoPromotions[name] ) then
						PromoteToAssistant(name);
						CT_RA_Print("<CTRaid> Auto-Promoted |c00FFFFFF" .. name .. "|r.", 1, 0.5, 0);
					end
				end
			end
		else
			CT_RA_UpdateRaidGroup(3);
		end
		CT_RA_NumRaidMembers = numRaidMembers;
		if ( event == "PLAYER_ENTERING_WORLD" ) then
			if ( CT_RA_RaidParticipant ) then
				if ( CT_RA_RaidParticipant ~= playerName ) then
					CT_RA_Stats = { { } };
					CT_RA_MainTanks = { };
					CT_RA_PTargets = { };
					CT_RATarget.MainTanks = { };
					CT_RA_ButtonIndexes = { };
				end
			end
			CT_RA_RaidParticipant = playerName;
			-- Add chat frame stuff
			local info = CT_RA_ChatInfo[playerName];
			local chatTypeInfo = ChatTypeInfo["CTRAID"];
			if ( not info ) then
				info = CT_RA_ChatInfo["Default"];
			end
			chatTypeInfo.r = info.r;
			chatTypeInfo.g = info.g;
			chatTypeInfo.b = info.b;
		end
	elseif ( event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH" ) then
		local _, _, id = string.find(arg1, "^raid(%d+)$");
		if ( id ) then
			local frame = getglobal("CT_RAMember" .. id);
			local name, hCurr, hMax = UnitName(arg1), UnitHealth(arg1), UnitHealthMax(arg1);
			local hpp = ( hCurr or 1 ) / ( hMax or 1 );
			local stats = CT_RA_Stats[name];
			if ( name ) then
				if ( not stats ) then
					CT_RA_Stats[name] = {
						["Buffs"] = { },
						["Debuffs"] = { },
						["Position"] = { }
					};
					stats = CT_RA_Stats[name];
				end
				if ( UnitIsDead(arg1) or UnitIsGhost(arg1) ) then
					CT_RA_ScanPartyAuras(arg1);
					if ( not stats["Dead"] ) then
					stats["Dead"] = 1;
					end
					CT_RA_UpdateUnitDead(frame);
				elseif ( stats["Dead"] ) then
					if ( hCurr > 0 and not UnitIsGhost(arg1) ) then
						stats["Dead"] = nil;
					end
					CT_RA_UpdateUnitDead(frame);
				else
					stats["Dead"] = nil;
					if ( not frame.hpp or frame.hpp ~= floor(hpp*100) ) then
						CT_RA_UpdateUnitHealth(frame);
					end
				end
				if ( CT_RA_Emergency_Units[name] or ( not CT_RA_EmergencyFrame.maxPercent or hpp < CT_RA_EmergencyFrame.maxPercent ) ) then
					CT_RA_Emergency_UpdateHealth();
				end
			end
		elseif ( ( GetNumRaidMembers() == 0 and ( arg1 == "player" or string.find(arg1, "^party%d+$") ) ) ) then
			if ( CT_RA_Emergency_Units[UnitName(arg1)] or ( not CT_RA_EmergencyFrame.maxPercent or ( hpp and hpp < CT_RA_EmergencyFrame.maxPercent ) ) ) then
				CT_RA_Emergency_UpdateHealth();
			end
		end
		return;
	elseif ( event == "UNIT_AURA" and GetNumRaidMembers() > 0 ) then
		if ( string.find(arg1, "^raid%d+$") ) then
			CT_RA_ScanPartyAuras(arg1);
		end
	elseif ( event == "UNIT_MANA" or event == "UNIT_MAXMANA" or event == "UNIT_RAGE" or event == "UNIT_MAXRAGE" or event == "UNIT_ENERGY" or event == "UNIT_MAXENERGY" ) then
		local _, _, id = string.find(arg1, "^raid(%d+)$");
		if ( id ) then
			CT_RA_UpdateUnitMana(getglobal("CT_RAMember" .. id));
		end
		return;
	elseif ( event == "UI_ERROR_MESSAGE" or event == "UI_INFO_MESSAGE" ) then
		if ( CT_RA_LastCast and (GetTime()-CT_RA_LastCast) <= 0.1 ) then
			if ( CT_RA_LastCastType == "debuff" ) then
				tinsert(CT_RA_BuffsToCure, 1, CT_RA_LastCastSpell);
			else
				tinsert(CT_RA_BuffsToRecast, 1, CT_RA_LastCastSpell);
			end
			CT_RA_LastCast = nil;
			CT_RA_LastCastSpell = nil;
		end
	elseif ( event == "SPELLCAST_START" ) then
		CT_RA_CurrCastSpell = arg1;
	elseif ( event == "SPELLCAST_INTERRUPTED" or event == "SPELLCAST_FAILED" ) then
		CT_RA_CurrCastSpell = nil;
	elseif ( event == "SPELLCAST_STOP" and CT_RA_CurrCastSpell ) then
		if ( CT_RA_CurrCastSpell == CT_RA_REBIRTH ) then
			CT_RA_AddMessage("CD 1 30");
		elseif ( CT_RA_CurrCastSpell == CT_RA_SOULSTONERESURRECTION ) then
			CT_RA_AddMessage("CD 3 30");
		end
		CT_RA_CurrCastSpell = nil;
	elseif ( event == "PLAYER_TARGET_CHANGED" ) then
		CT_RA_UpdateResFrame();
	end
end

CT_RA_oldUseSoulstone = UseSoulstone;
function CT_RA_newUseSoulstone()
	local text = HasSoulstone();
	if ( text and text == "复生" ) then
		local cooldown;
		for i = 1, GetNumTalentTabs(), 1 do
			for y = 1, GetNumTalents(i), 1 do
				local name, _, _, _, currRank = GetTalentInfo(i, y);
				if ( name == "强化复生" ) then
					cooldown = 60 - (currRank*10);
					break;
				end
			end
			if ( cooldown ) then
				break;
			end
		end
		if ( not cooldown ) then
			cooldown = 60;
		end
		CT_RA_AddMessage("CD 2 " .. cooldown);
	end
	CT_RA_oldUseSoulstone();
end
UseSoulstone = CT_RA_newUseSoulstone;

-----------------------------------------------------
--                  Update Functions               --
-----------------------------------------------------
	
-- Update health
function CT_RA_UpdateUnitHealth(frame)
	local tempOptions = CT_RAMenu_Options["temp"];
	if ( not frame.group or not tempOptions["ShowGroups"][frame.group.id] ) then
		return;
	end
	local id = "raid" .. frame.id;
	local maxHealth = UnitHealthMax(id);
	local percent = floor(UnitHealth(id) / maxHealth * 100);
	local name = UnitName(id);
	if ( not name and tempOptions["SORTTYPE"] == "virtual" ) then
		percent = 100;
		maxHealth = 100;
		name = "虚拟 " .. frame.id;
	end
	frame.hpp = percent;
	local updateDead = frame.status;
	if ( percent and percent > 0 ) then
		-- Commonly used values
		local defaultAlpha = tempOptions.DefaultAlpha;
		if ( defaultAlpha and defaultAlpha < 1 ) then
			frame:SetAlpha(math.max(math.min(defaultAlpha+(1-(percent/100))*(1-defaultAlpha), 1), defaultAlpha));
		else
			frame:SetAlpha(1);
		end
		local showHP = tempOptions["ShowHP"];
		local memberHeight = tempOptions["MemberHeight"];
		local framePercent = frame.Percent;
		local frameHPBar = frame.HPBar;
		local stats = CT_RA_Stats[name];
		
		if ( stats and stats["Ressed"] ) then
			stats["Ressed"] = nil;
			updateDead = 1;
		end
		if ( percent > 100 ) then
			percent = 100;
		end
		frameHPBar:SetValue(percent);
		if ( showHP and showHP == 1 and maxHealth and memberHeight == 40 ) then
			framePercent:SetText(floor(percent/100*maxHealth) .. "/" .. maxHealth);
		elseif ( showHP and showHP == 2 and memberHeight == 40 ) then
			framePercent:SetText(percent .. "%");
		elseif ( showHP and showHP == 3 and memberHeight == 40 ) then
			if ( maxHealth ) then

⌨️ 快捷键说明

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