📄 ct_raidassist.lua
字号:
-- Locally bound frame cache
local frameCache = CT_RA_Cache;
-- CT_RA_CustomOnClickFunction
-- Set this variable (CT_RA_CustomOnClickFunction) in your own mod to your function to handle OnClicks.
-- Two arguments are passed, button and raidid.
-- Button is a string that refers to the mouse button pressed, "LeftButton" or "RightButton".
-- Raidid is a string with the unit id, such as "raid1".
-- Example: function MyFunction(button, raidid) doStuff(); end
-- CT_RA_CustomOnClickFunction = MyFunction;
-- Note! If the function returns true, the default CTRA behaviour will not be called.
-- If it returns false or nil, the default behaviour will be called.
-- Variables
CHAT_MSG_CTRAID = "团队助手";
CT_RA_Squelch = 0;
CT_RA_Comm_MessageQueue = { };
CT_RA_Level = 0;
CT_RA_Stats = {
{
{ }
}
};
CT_RA_PTargets = { };
CT_RA_BuffsToCure = { };
CT_RA_BuffsToRecast = { };
CT_RA_RaidParticipant = nil; -- Used to see what player participated in the raid on this account
CT_RA_Auras = {
["buffs"] = { },
["debuffs"] = { }
};
CT_RA_LastSend = nil;
CT_RA_ClassPositions = {
[CT_RA_WARRIOR] = 1,
[CT_RA_DRUID] = 2,
[CT_RA_MAGE] = 3,
[CT_RA_WARLOCK] = 4,
[CT_RA_ROGUE] = 5,
[CT_RA_HUNTER] = 6,
[CT_RA_PRIEST] = 7,
[CT_RA_PALADIN] = 8,
[CT_RA_SHAMAN] = 8
};
CT_RA_Emergency_RaidHealth = { };
CT_RA_Emergency_Units = { };
CT_RA_LastSent = { };
CT_RA_BuffTimeLeft = { };
CT_RA_ResFrame_Options = { };
CT_RA_CurrPlayerName = "";
CT_RA_NumRaidMembers = 0;
ChatTypeGroup["CTRAID"] = {
"CHAT_MSG_CTRAID"
};
ChatTypeInfo["CTRAID"] = { sticky = 0 };
tinsert(OtherMenuChatTypeGroups, "CTRAID");
CHAT_CTRAID_GET = "";
CT_RA_ChatInfo = {
["Default"] = {
["r"] = 1.0,
["g"] = 0.5,
["b"] = 0,
["show"] = {
"ChatFrame1"
}
}
};
CT_oldFCF_Tab_OnClick = FCF_Tab_OnClick;
function CT_newFCF_Tab_OnClick(button)
CT_oldFCF_Tab_OnClick(button);
if ( button == "RightButton" ) then
local frameName = "ChatFrame" .. this:GetID();
local frame = getglobal(frameName);
local info = CT_RA_ChatInfo["Default"];
if ( CT_RA_ChatInfo[UnitName("player")] ) then
info = CT_RA_ChatInfo[UnitName("player")];
end
for k, v in info["show"] do
if ( v == frameName ) then
local y = 1;
while ( frame.messageTypeList[y] ) do
y = y + 1;
end
frame.messageTypeList[y] = "CTRAID";
end
end
end
end
FCF_Tab_OnClick = CT_newFCF_Tab_OnClick;
CT_oldFCF_SetChatTypeColor = FCF_SetChatTypeColor;
function CT_newFCF_SetChatTypeColor()
CT_oldFCF_SetChatTypeColor();
if ( UIDROPDOWNMENU_MENU_VALUE == "CTRAID" ) then
local r,g,b = ColorPickerFrame:GetColorRGB();
local chatInfo = CT_RA_ChatInfo[UnitName("player")];
local chatTypeInfo = ChatTypeInfo["CTRAID"];
if ( not chatInfo ) then
CT_RA_ChatInfo[UnitName("player")] = CT_RA_ChatInfo["Default"];
end
chatInfo.r = r;
chatInfo.g = g;
chatInfo.b = b;
chatTypeInfo.r = r;
chatTypeInfo.g = g;
chatTypeInfo.b = b;
end
end
FCF_SetChatTypeColor = CT_newFCF_SetChatTypeColor;
CT_oldFCF_CancelFontColorSettings = FCF_CancelFontColorSettings;
function CT_newFCF_CancelFontColorSettings(prev)
CT_oldFCF_CancelFontColorSettings(prev);
if ( prev.r and UIDROPDOWNMENU_MENU_VALUE == "CTRAID" ) then
local chatInfo = CT_RA_ChatInfo[UnitName("player")];
local chatTypeInfo = ChatTypeInfo["CTRAID"];
if ( not chatInfo ) then
CT_RA_ChatInfo[UnitName("player")] = CT_RA_ChatInfo["Default"];
end
chatInfo.r = prev.r;
chatInfo.g = prev.g;
chatInfo.b = prev.b;
chatTypeInfo.r = prev.r;
chatTypeInfo.g = prev.g;
chatTypeInfo.b = prev.b;
end
end
FCF_CancelFontColorSettings = CT_newFCF_CancelFontColorSettings;
CT_oldFCFMessageTypeDropDown_OnClick = FCFMessageTypeDropDown_OnClick;
function CT_newFCFMessageTypeDropDown_OnClick()
CT_oldFCFMessageTypeDropDown_OnClick();
if ( not CT_RA_ChatInfo[UnitName("player")] ) then
CT_RA_ChatInfo[UnitName("player")] = CT_RA_ChatInfo["Default"];
end
if ( this.value == "CTRAID" ) then
local chatInfo = CT_RA_ChatInfo[UnitName("player")];
local chatTypeInfo = ChatTypeInfo["CTRAID"];
local currChatFrame = FCF_GetCurrentChatFrame():GetName();
if ( UIDropDownMenuButton_GetChecked() ) then
for k, v in chatInfo["show"] do
if ( v == currChatFrame ) then
chatInfo["show"][k] = nil;
break;
end
end
else
tinsert(chatInfo["show"], currChatFrame);
end
end
end
FCFMessageTypeDropDown_OnClick = CT_newFCFMessageTypeDropDown_OnClick;
function CT_RA_ShowHideWindows()
local tempOptions = CT_RAMenu_Options["temp"];
if ( tempOptions["HiddenGroups"] ) then
tempOptions["ShowGroups"] = tempOptions["HiddenGroups"];
tempOptions["HiddenGroups"] = nil;
local num = 0;
for k, v in tempOptions["ShowGroups"] do
num = num + 1;
getglobal("CT_RAOptionsGroupCB" .. k):SetChecked(1);
end
if ( num > 0 ) then
CT_RACheckAllGroups:SetChecked(1);
else
CT_RACheckAllGroups:SetChecked(nil);
end
else
tempOptions["HiddenGroups"] = tempOptions["ShowGroups"];
tempOptions["ShowGroups"] = { };
for i = 1, 8, 1 do
getglobal("CT_RAOptionsGroupCB" .. i):SetChecked(nil);
end
CT_RACheckAllGroups:SetChecked(nil);
end
CT_RA_UpdateRaidGroup(0);
end
function CT_RA_SetGroup()
local tempOptions = CT_RAMenu_Options["temp"];
tempOptions["ShowGroups"][this.id] = this:GetChecked();
local num = 0;
for k, v in tempOptions["ShowGroups"] do
num = num + 1;
end
if ( num > 0 ) then
CT_RACheckAllGroups:SetChecked(1);
else
CT_RACheckAllGroups:SetChecked(nil);
end
CT_RA_UpdateRaidGroup(0);
end
function CT_RA_CheckAllGroups()
local tempOptions = CT_RAMenu_Options["temp"];
if ( not tempOptions["ShowGroups"] ) then tempOptions["ShowGroups"] = { }; end
for i = 1, 8, 1 do
tempOptions["ShowGroups"][i] = this:GetChecked();
getglobal("CT_RAOptionsGroupCB" .. i):SetChecked(this:GetChecked());
end
CT_RA_UpdateRaidGroup(0);
end
function CT_RA_ParseEvent(event)
local nick, sMsg, msg;
if ( event == "CHAT_MSG_ADDON" ) then
nick, sMsg = arg4, arg2;
else
nick, sMsg = arg2, arg1;
end
local numRaidMembers = GetNumRaidMembers();
local name, rank, subgroup, level, class, fileName, zone, online, isDead, raidid, frame;
for i = 1, numRaidMembers, 1 do
if ( UnitName("raid" .. i) == nick ) then
raidid = i;
name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(i);
frame = getglobal("CT_RAMember"..i);
break;
end
end
local playerName = UnitName("player");
local unitStats = CT_RA_Stats[nick];
if ( name and not unitStats ) then
CT_RA_Stats[nick] = {
["Buffs"] = { },
["Debuffs"] = { },
["Position"] = { }
};
unitStats = CT_RA_Stats[nick];
end
if ( ( event == "CHAT_MSG_RAID" or event == "CHAT_MSG_RAID_LEADER" ) and type(sMsg) == "string" ) then
if ( frame ) then
-- We have a valid frame
msg = gsub(sMsg, "%%", "%%%%");
if ( stats and raidid ) then
if ( arg6 and not unitStats[arg6] and ( arg6 == "AFK" or arg6 == "DND" ) ) then
unitStats[arg6] = { 1, 0 };
CT_RA_UpdateUnitDead(frame);
elseif ( arg2 == name and ( not arg6 or arg6 == "" ) and ( unitStats["DND"] or unitStats["AFK"] ) ) then
unitStats["DND"] = nil;
unitStats["AFK"] = nil;
CT_RA_UpdateUnitDead(frame);
end
end
if ( rank and rank < 1 and CT_RA_Squelch and CT_RA_Squelch > 0 ) then
if ( CT_RA_Level >= 1 and CT_RA_IsSendingWithVersion(1.468) ) then
SendChatMessage("<团队助手> 禁言模式启用,请保持安静。剩余" .. floor(CT_RA_Squelch) .. "秒。", "WHISPER", nil, name);
end
return;
end
if ( rank and rank >= 1 and string.find(sMsg, "<团队助手> 解散团队请求,发送人:(.+)") ) then
LeaveParty();
return;
end
if ( rank >= 1 ) then
if ( name ~= playerName and sMsg == "<团队助手> 禁言模式结束。" ) then
if ( CT_RA_Squelch > 0 ) then
CT_RA_Squelch = 0;
CT_RA_Print("<团队助手> 禁言模式已由" .. name .. "停用。", 1, 0.5, 0);
end
elseif ( name ~= playerName and sMsg == "<团队助手> 禁言模式,禁止发言。" ) then
if ( CT_RA_Squelch == 0 ) then
CT_RA_Squelch = 5*60;
CT_RA_Print("<团队助手> 禁言模式已由" .. name .. "启用。", 1, 0.5, 0);
end
end
return;
end
end
elseif ( event == "CHAT_MSG_WHISPER" and type(sMsg) == "string" ) then
local tempOptions = CT_RAMenu_Options["temp"];
if ( tempOptions["KeyWord"] and strlower(sMsg) == strlower(tempOptions["KeyWord"]) ) then
local temp = arg2;
if ( numRaidMembers == 40 or ( GetNumPartyMembers() == 4 and numRaidMembers == 0 ) ) then
CT_RA_Print("<团队助手> 玩家'|c00FFFFFF" .. temp .. "|r'发出了邀请请求,当前团队已满员。", 1, 0.5, 0);
SendChatMessage("<团队助手> 当前团队已满员。", "WHISPER", nil, temp);
else
CT_RA_Print("<团队助手> 通过邀请关键字功能邀请了'|c00FFFFFF" .. nick .. "|r'。", 1, 0.5, 0);
InviteByName(temp);
CT_RA_UpdateFrame.lastInvite = 1;
CT_RA_UpdateFrame.inviteName = temp;
end
else
local _, _, secRem = string.find(sMsg, "<团队助手> 禁言模式启用,请保持安静。剩余(%d+)秒。");
if ( secRem and CT_RA_Squelch == 0 ) then
if ( rank >= 1 ) then
CT_RA_Squelch = tonumber(secRem);
CT_RA_Print("<团队助手> 禁言模式已由" .. name .. "启用,持续" .. secRem .. "秒。", 1, 0.5, 0);
end
end
end
elseif ( event == "CHAT_MSG_WHISPER_INFORM" ) then
if ( arg1 == "<团队助手> 你已经有组了。" ) then
CT_RA_Print("<团队助手> 提醒'|c00FFFFFF" .. arg2 .. "|r'已经有组了。", 1, 0.5, 0);
end
elseif ( event == "CHAT_MSG_COMBAT_FRIENDLY_DEATH" ) then
if ( not CT_RAMenu_Options["temp"]["HideTankNotifications"] ) then
local _, _, name = string.find(sMsg, CT_RA_TANKHASDIEDREGEXP);
if ( name ) then
for k, v in CT_RA_MainTanks do
if ( v == name ) then
CT_RA_WarningFrame:AddMessage("主坦克 " .. name .. " 已死亡!", 1, 0, 0, 1, UIERRORS_HOLD_TIME);
PlaySoundFile("Sound\\interface\\igQuestFailed.wav");
break;
end
end
end
end
elseif ( strsub(event, 1, 15) == "CHAT_MSG_SYSTEM" and type(sMsg) == "string" ) then
local useless, useless, plr = string.find(sMsg, CT_RA_HASLEFTRAIDREGEXP);
if ( CT_RA_RaidParticipant and plr and plr ~= CT_RA_RaidParticipant ) then
CT_RA_CurrPositions[plr] = nil;
CT_RA_Stats[plr] = nil;
for k, v in CT_RA_MainTanks do
if ( v == plr ) then
CT_RA_MainTanks[k] = nil;
CT_RATarget.MainTanks[k] = nil;
break;
end
end
elseif ( string.find(sMsg, CT_RA_HASJOINEDRAIDREGEXP) ) then
if ( CT_RA_Level >= 2 ) then
local useless, useless, plr = string.find(sMsg, CT_RA_HASJOINEDRAIDREGEXP);
if ( plr and CT_RATab_AutoPromotions[plr] ) then
PromoteToAssistant(plr);
CT_RA_Print("<团队助手> 自动提升 |c00FFFFFF" .. plr .. "|r。", 1, 0.5, 0);
end
end
elseif ( string.find(sMsg, CT_RA_AFKMESSAGE) or sMsg == MARKED_AFK ) then
local _, _, msg = string.find(sMsg, CT_RA_AFKMESSAGE);
if ( msg and msg ~= DEFAULT_AFK_MESSAGE ) then
if ( strlen(msg) > 20 ) then
msg = strsub(msg, 1, 20) .. "...";
end
CT_RA_AddMessage("AFK " .. msg);
else
CT_RA_AddMessage("AFK");
end
elseif ( string.find(sMsg, CT_RA_DNDMESSAGE) ) then
local _, _, msg = string.find(sMsg, CT_RA_DNDMESSAGE);
if ( msg and msg ~= DEFAULT_DND_MESSAGE ) then
if ( strlen(msg) > 20 ) then
msg = strsub(msg, 1, 20) .. "...";
end
CT_RA_AddMessage("DND " .. msg);
else
CT_RA_AddMessage("DND");
end
elseif ( sMsg == CLEARED_AFK ) then
CT_RA_AddMessage("UNAFK");
elseif ( sMsg == CLEARED_DND ) then
CT_RA_AddMessage("UNDND");
end
elseif ( event == "CHAT_MSG_ADDON" and arg1 == "CTRA" and arg3 == "RAID" ) then
if ( frame ) then
-- Unit is in raid
local eventtype = strsub(event, 10);
local info = ChatTypeInfo[eventtype];
event = "CHAT_MSG_CTRAID";
if ( not sMsg ) then
return;
end
msg = sMsg;
local tempUpdate, message;
if ( string.find(msg, "#") ) then
local arr = CT_RA_Split(msg, "#");
for k, v in arr do
tempUpdate, message = CT_RA_ParseMessage(name, v);
if ( message ) then
CT_RA_Print(message, 1, 0.5, 0);
end
if ( tempUpdate ) then
for k, v in tempUpdate do
tinsert(update, v);
end
end
end
else
tempUpdate, message = CT_RA_ParseMessage(name, msg);
if ( message ) then
CT_RA_Print(message, 1, 0.5, 0);
end
if ( tempUpdate ) then
for k, v in tempUpdate do
tinsert(update, v);
end
end
end
if ( type(update) == "table" ) then
for k, v in update do
if ( type(v) == "number" ) then
CT_RA_UpdateUnitStatus(getglobal("CT_RAMember" .. v));
else
for i = 1, GetNumRaidMembers(), 1 do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -