📄 ct_raidassist.lua
字号:
local diff = floor(percent/100*maxHealth)-maxHealth;
if ( diff == 0 ) then diff = ""; end
framePercent:SetText(diff);
else
framePercent:SetText(percent-100 .. "%");
end
else
framePercent:Hide();
end
local hppercent = percent/100;
local r, g;
if ( hppercent > 0.5 and hppercent <= 1) then
g = 1;
r = (1.0 - hppercent) * 2;
elseif ( hppercent >= 0 and hppercent <= 0.5 ) then
r = 1.0;
g = hppercent * 2;
else
r = 0;
g = 1;
end
frameHPBar:SetStatusBarColor(r, g, 0);
frame.HPBG:SetVertexColor(r, g, 0, tempOptions["BGOpacity"]);
end
local isDead;
if ( updateDead ) then
CT_RA_UpdateUnitDead(frame, 1);
end
end
-- Update status
function CT_RA_UpdateUnitStatus(frame)
local tempOptions = CT_RAMenu_Options["temp"];
if ( not frame.group or not tempOptions["ShowGroups"][frame.group.id] ) then
return;
end
local frameName = frame.name;
local id = frame.id;
local castFrame = frame.CastFrame;
local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(id);
if ( not name and tempOptions["SORTTYPE"] == "virtual" ) then
name, rank, subgroup, level, class, fileName, zone, online, isDead = "虚拟 " .. id, 0, floor((id-1)/5)+1, 60, CT_RA_PRIEST, "PRIEST", "翡翠梦境", 1, nil;
end
local height = tempOptions["MemberHeight"];
if ( ( ( class == CT_RA_WARRIOR or class == CT_RA_ROGUE ) and tempOptions["HideRP"] ) or ( class ~= CT_RA_WARRIOR and class ~= CT_RA_ROGUE and tempOptions["HideMP"] ) ) then
height = height - 4;
end
if ( tempOptions["HideBorder"] ) then
if ( height == 28 ) then
frame.BuffButton1:SetPoint("TOPRIGHT", frameName, "TOPRIGHT", -5, -5);
frame.DebuffButton1:SetPoint("TOPRIGHT", frameName, "TOPRIGHT", -5, -5);
else
frame.BuffButton1:SetPoint("TOPRIGHT", frameName, "TOPRIGHT", -5, -3);
frame.DebuffButton1:SetPoint("TOPRIGHT", frameName, "TOPRIGHT", -5, -3);
end
frame:SetBackdropBorderColor(1, 1, 1, 0);
frame.Percent:SetPoint("TOP", frameName, "TOP", 2, -16);
frame.HPBar:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -19);
frame.HPBG:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -19);
castFrame:SetWidth(85);
if ( not online ) then
frame:SetHeight(37);
castFrame:SetHeight(37);
else
frame:SetHeight(height-3);
castFrame:SetHeight(height-3);
end
else
frame:SetBackdropBorderColor(1, 1, 1, 1);
frame.BuffButton1:SetPoint("TOPRIGHT", frameName, "TOPRIGHT", -5, -5);
frame.DebuffButton1:SetPoint("TOPRIGHT", frameName, "TOPRIGHT", -5, -5);
frame.HPBar:SetPoint("TOPLEFT", frameName, "TOPLEFT", 10, -22);
frame.HPBG:SetPoint("TOPLEFT",frameName, "TOPLEFT", 10, -22);
frame.Percent:SetPoint("TOP", frameName, "TOP", 2, -18);
castFrame:SetWidth(90);
if ( not online ) then
frame:SetHeight(40);
castFrame:SetHeight(40);
else
frame:SetHeight(height);
castFrame:SetHeight(height);
end
end
if ( height == 32 or height == 28 ) then
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
else
frame.HPBar:Show();
frame.HPBG:Show();
end
stats = CT_RA_Stats[name];
if ( frame.group and tempOptions["ShowGroups"][frame.group.id] ) then
frame:Show();
end
frame.Name:SetText(name);
CT_RA_UpdateUnitDead(frame);
if ( stats ) then
CT_RA_UpdateUnitBuffs(stats["Buffs"], frame, name);
end
if ( online ) then
CT_RA_UpdateUnitHealth(frame, 1);
CT_RA_UpdateUnitMana(frame);
if ( stats ) then
CT_RA_UpdateUnitBuffs(stats["Buffs"], frame, name);
end
end
end
function CT_RA_CanShowInfo(id)
local tempOptions = CT_RAMenu_Options["temp"];
local stats = CT_RA_Stats[UnitName(id)];
local showHP, hasFD, isRessed, isNotReady, showAFK, isDead;
local hp = tempOptions["ShowHP"];
showHP = ( hp and hp <= 3 );
hasFD = ( stats and stats["FD"] );
isRessed = ( stats and stats["Ressed"] );
isNotReady = ( stats and stats["notready"] );
showAFK = ( tempOptions["ShowAFK"] and stats and stats["AFK"] );
isDead = ( ( stats and stats["Dead"] ) or UnitIsDead(id) or UnitIsGhost(id) );
if ( showHP and not hasFD and not isRessed and not isNotReady and not showAFK and not isDead ) then
return true;
else
return nil;
end
end
-- Update mana
function CT_RA_UpdateUnitMana(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 percent;
if ( not UnitExists(id) and tempOptions["SORTTYPE"] == "virtual" ) then
percent = 100;
else
percent = floor(UnitMana(id) / UnitManaMax(id) * 100);
end
frame.MPBar:SetValue(percent);
end
-- Update buffs
function CT_RA_UpdateUnitBuffs(buffs, frame, nick)
local tempOptions = CT_RAMenu_Options["temp"];
if ( not frame.group or not tempOptions["ShowGroups"][frame.group.id] ) then
return;
end
local num = 1;
if ( buffs ) then
if ( not tempOptions["ShowDebuffs"] or tempOptions["ShowBuffsDebuffed"] ) then
for key, val in tempOptions["BuffArray"] do
local name;
if ( type(val["name"]) == "table" ) then
if ( buffs[val["name"][1]] ) then
name = val["name"][1];
elseif ( buffs[val["name"][2]] ) then
name = val["name"][2];
end
elseif ( buffs[val["name"]] ) then
name = val["name"];
end
if ( name ) then
if ( num <= 4 and val["show"] ~= -1 ) then -- Change 4 to number of buffs
local button = frame["BuffButton"..num];
frameCache[button].Icon:SetTexture("Interface\\Icons\\" .. CT_RA_BuffTextures[name][1]);
button.name = name;
button.owner = nick;
button.texture = CT_RA_BuffTextures[name][1];
button:Show();
num = num + 1;
end
end
end
end
end
for i = num, 4, 1 do -- Change 4 to number of buffs
frame["BuffButton"..i]:Hide();
end
local stats = CT_RA_Stats[nick];
if ( stats ) then
CT_RA_UpdateUnitDebuffs(stats["Debuffs"], frame);
end
end
function CT_RA_UpdateUnitDead(frame, didUpdateHealth)
local tempOptions = CT_RAMenu_Options["temp"];
if ( not frame.group or not tempOptions["ShowGroups"][frame.group.id] ) then
return;
end
local raidid = "raid" .. frame.id;
local name, rank, subgroup, level, class, fileName, zone, online, dead = GetRaidRosterInfo(frame.id);
if ( not name and tempOptions["SORTTYPE"] == "virtual" ) then
name, rank, subgroup, level, class, fileName, zone, online, isDead = "虚拟 " .. frame.id, 0, floor((frame.id-1)/5)+1, 60, CT_RA_PRIEST, "PRIEST", "翡翠梦境", 1, nil;
end
local color = RAID_CLASS_COLORS[fileName];
if ( color ) then
frame.Name:SetTextColor(color.r, color.g, color.b);
end
local stats, isFD, isDead = CT_RA_Stats[name], false, false;
if ( UnitIsGhost(raidid) or UnitIsDead(raidid) ) then
isFD = CT_RA_CheckFD(name, raidid)
if ( isFD == 0 ) then
isDead = 1;
-- Scan buffs&debuffs on death
CT_RA_ScanPartyAuras(raidid);
end
end
local height = tempOptions["MemberHeight"];
if ( ( ( class == CT_RA_WARRIOR or class == CT_RA_ROGUE ) and tempOptions["HideRP"] ) or ( class ~= CT_RA_WARRIOR and class ~= CT_RA_ROGUE and tempOptions["HideMP"] ) ) then
height = height - 4;
end
if ( not online ) then
if ( tempOptions["HideOffline"] ) then
frame:Hide();
end
for i = 1, 4, 1 do
if ( i <= 2 ) then
frame["DebuffButton"..i]:Hide();
end
frame["BuffButton"..i]:Hide();
end
frame:SetBackdropColor(0.3, 0.3, 0.3, 1);
if ( tempOptions["HideBorder"] ) then
frame:SetHeight(37);
else
frame:SetHeight(40);
end
if ( name ) then
if ( not stats ) then
CT_RA_Stats[name] = {
["Buffs"] = { },
["Debuffs"] = { },
["Position"] = { },
};
stats = CT_RA_Stats[name];
end
if ( not stats["Offline"] ) then
stats["Offline"] = 1;
end
end
frame.status = "offline";
frame.Status:SetText("离线");
frame.Status:Show();
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
frame.MPBar:Hide();
frame.MPBG:Hide();
frame:SetAlpha(1);
return;
elseif ( stats and stats["notready"] ) then
frame.Status:Show();
if ( tempOptions["HideBorder"] ) then
frame:SetHeight(37);
else
frame:SetHeight(40);
end
if ( stats["notready"] == 1 ) then
frame.status = "noreply";
frame.Status:SetText("没有回答");
frame:SetBackdropColor(0.45, 0.45, 0.45, 1);
else
frame.status = "notready";
frame.Status:SetText("未准备好");
frame:SetBackdropColor(0.8, 0.45, 0.45, 1);
end
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
frame.MPBar:Hide();
frame.MPBG:Hide();
frame:SetAlpha(1);
elseif ( isFD == 1 ) then
frame.status = "feigndeath";
frame.Status:Show();
frame.Status:SetText("假死");
frame:SetBackdropColor(0.3, 0.3, 0.3, 1);
if ( tempOptions["HideBorder"] and ( ( ( class == CT_RA_WARRIOR or class == CT_RA_ROGUE ) and tempOptions["HideRP"] ) or ( class ~= CT_RA_WARRIOR and class ~= CT_RA_ROGUE and tempOptions["HideMP"] ) ) ) then
frame:SetHeight(height+3);
end
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
frame.MPBar:Hide();
frame.MPBG:Hide();
frame:SetAlpha(1);
elseif ( isFD == 2 ) then
frame.status = "spiritofredemption";
frame.Status:Show();
frame.Status:SetText("救赎之魂");
frame:SetBackdropColor(0.3, 0.3, 0.3, 1);
if ( tempOptions["HideBorder"] and ( ( ( class == CT_RA_WARRIOR or class == CT_RA_ROGUE ) and tempOptions["HideRP"] ) or ( class ~= CT_RA_WARRIOR and class ~= CT_RA_ROGUE and tempOptions["HideMP"] ) ) ) then
frame:SetHeight(height+3);
end
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
frame.MPBar:Hide();
frame.MPBG:Hide();
frame:SetAlpha(1);
elseif ( stats and stats["Ressed"] ) then
frame.status = "resurrected";
frame.Status:Show();
frame:SetBackdropColor(0.3, 0.3, 0.3, 1);
if ( tempOptions["HideBorder"] ) then
frame:SetHeight(37);
else
frame:SetHeight(40);
end
if ( stats["Ressed"] == 1 ) then
frame.Status:SetText("复活");
elseif ( stats["Ressed"] == 2 ) then
frame.Status:SetText("灵魂已保存");
end
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
frame.MPBar:Hide();
frame.MPBG:Hide();
frame:SetAlpha(1);
elseif ( isDead ) then
frame.status = "dead";
for i = 1, 4, 1 do
if ( i <= 2 ) then
frame["DebuffButton"..i]:Hide();
end
frame["BuffButton"..i]:Hide();
end
frame.Status:Show();
frame:SetBackdropColor(0.3, 0.3, 0.3, 1);
if ( tempOptions["HideBorder"] ) then
frame:SetHeight(37);
else
frame:SetHeight(40);
end
frame.Status:SetText("死亡");
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
frame.MPBar:Hide();
frame.MPBG:Hide();
frame:SetAlpha(1);
elseif ( stats and stats["AFK"] and tempOptions["ShowAFK"] ) then
frame.status = "afk";
frame.Status:Show();
frame:SetBackdropColor(0.3, 0.3, 0.3, 1);
if ( tempOptions["HideBorder"] ) then
frame:SetHeight(37);
else
frame:SetHeight(40);
end
frame.Status:SetText("暂离");
frame.HPBar:Hide();
frame.HPBG:Hide();
frame.Percent:Hide();
frame.MPBar:Hide();
frame.MPBG:Hide();
frame:SetAlpha(1);
else
if ( frame.status and not didUpdateHealth ) then
CT_RA_UpdateUnitHealth(frame);
end
local canShowInfo = CT_RA_CanShowInfo("raid"..frame.id);
frame.status = nil;
frame:SetBackdropColor(tempOptions["DefaultColor"].r, tempOptions["DefaultColor"].g, tempOptions["DefaultColor"].b, tempOptions["DefaultColor"].a);
if ( tempOptions["MemberHeight"] == 40 ) then
frame.HPBar:Show();
frame.HPBG:Show();
if ( canShowInfo ) then
frame.Percent:Show();
else
frame.Percent:Hide();
end
end
if ( tempOptions["HideBorder"] ) then
frame:SetHeight(height-3);
else
frame:SetHeight(height);
end
if ( class == CT_RA_WARRIOR ) then
frame.MPBar:SetStatusBarColor(1, 0, 0);
frame.MPBG:SetVertexColor(1, 0, 0, tempOptions["BGOpacity"]);
elseif ( class == CT_RA_ROGUE ) then
frame.MPBar:SetStatusBarColor(1, 1, 0);
frame.MPBG:SetVertexColor(1, 1, 0, tempOptions["BGOpacity"]);
else
frame.MPBar:SetStatusBarColor(0, 0, 1);
frame.MPBG:SetVertexColor(0, 0, 1, tempOptions["BGOpacity"]);
end
frame.Status:Hide();
if ( ( ( class == CT_RA_WARRIOR or class == CT_RA_ROGUE ) and not tempOptions["HideRP"] ) or ( class ~= CT_RA_WARRIOR and class ~= CT_RA_ROGUE and not tempOptions["HideMP"] ) ) then
frame.MPBar:Show();
frame.MPBG:Show();
if ( canShowInfo ) then
frame.Percent:Show();
else
frame.Percent:Hide();
end
else
frame.MPBar:Hide();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -