📄 tipbuddy.lua
字号:
local manatype = UnitPowerType(unit);
local info = ManaTextColor[manatype];
info = ManaBarColor[manatype];
TipBuddy_TargetFrameManaBar:SetStatusBarColor(info.r, info.g, info.b);
UnitFrameManaBar_Update(TipBuddy_TargetFrameManaBar, unit);
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET/SHOW BUFFS
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetBuffs_Initialize()
local frame, bframe;
for i=1, 8 do
frame = "TipBuddy_BuffFrame";
bframe = getglobal(frame.."B"..i);
bframe:Hide();
bframe = getglobal(frame.."D"..i);
bframe:Hide();
frame = "TipBuddy_BuffFrameGTT";
bframe = getglobal(frame.."B"..i);
bframe:Hide();
bframe = getglobal(frame.."D"..i);
bframe:Hide();
end
end
function TipBuddy_TargetBuffs_Update( type, unit )
if (not unit or not type) then
TipBuddy_TargetBuffs_Initialize();
return;
end
local debuff, buff;
local frame, bframe;
local targettype = TipBuddy_SavedVars[type];
if ( targettype.off == 1 ) then
frame = "TipBuddy_BuffFrame";
else
frame = "TipBuddy_BuffFrameGTT";
end
for i=1, 8 do
buff = UnitBuff(unit, i);
bframe = getglobal(frame.."B"..i);
if ( buff ) then
if ( targettype.bff == 1 ) then
getglobal(frame.."B"..i.."Icon"):SetTexture(buff);
bframe:Show();
bframe.id = i;
else
bframe:Hide();
end
else
bframe:Hide();
end
end
for i=1, 8 do
debuff = UnitDebuff(unit, i);
bframe = getglobal(frame.."D"..i);
if ( debuff ) then
if ( targettype.bff == 1 ) then
getglobal(frame.."D"..i.."Icon"):SetTexture(debuff);
bframe:Show();
else
bframe:Hide();
end
else
bframe:Hide();
end
bframe.id = i;
end
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET LEVEL
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetInfo_GetLevel( type, unit )
local targettype = TipBuddy_SavedVars[type];
if (not unit or targettype.off == 2) then
return;
end
local targetLevel = UnitLevel(unit);
if ( targetLevel == -1 ) then
targetLevel = 100;
end
-- Color level number
local color;
if (UnitHealth(unit) <= 0) then
color = tbcolor_corpse;
--TB_AddMessage("level color = corpse");
elseif ( UnitCanAttack(unit, "player") or UnitCanAttack("player", unit) or UnitIsPVP(unit) ) then
-- Hostile unit of friendly unit flagged for PvP
color = TipBuddy_GetDifficultyColor(targetLevel);
--TB_AddMessage("level color = hostile or pvp");
else
color = tbcolor_lvl_same_faction;
--TB_AddMessage("level color = same fac");
end
if ( targetLevel == 100 ) then
targetLevel = "??";
end
TipBuddy.classification = UnitClassification(unit);
if ( not targetLevel or targetLevel == 0 ) then
TipBuddy.gtt_level = ("|r");
TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level);
elseif ( TipBuddy.classification == "worldboss" ) then
TipBuddy.gtt_level = (color..targetLevel..tbcolor_elite_worldboss.." ("..tb_translate_worldboss..")|r");
TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level);
elseif ( TipBuddy.classification == "rareelite" ) then
TipBuddy.gtt_level = (color.."+"..targetLevel..tbcolor_elite_rare.." ("..tb_translate_rareelite..")|r");
TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level);
elseif ( TipBuddy.classification == "elite" ) then
TipBuddy.gtt_level = (color.."+"..targetLevel..tbcolor_elite_rare.." ("..tb_translate_elite..")|r");
TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level);
elseif ( TipBuddy.classification == "rare" ) then
TipBuddy.gtt_level = (color..targetLevel..tbcolor_elite_rare.." ("..tb_translate_rare..")|r");
TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level);
else
TipBuddy.gtt_level = (color..targetLevel.."|r");
TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level);
end
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET CLASS/TYPE
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetInfo_GetClass( type, unit )
local targetLevel = UnitLevel(unit);
local targettype = TipBuddy_SavedVars[type];
TipBuddy.gtt_classlvlcolor = "";
TipBuddy.gtt_classcorpse = "";
TipBuddy.gtt_classcolor = "";
TipBuddy.gtt_class = "";
TipBuddy.gtt_race = "";
if (targettype.off == 2) then
return;
elseif (TipBuddy_SavedVars["general"].classcolor == 1) then
TipBuddy.gtt_classlvlcolor = "";
elseif ( UnitCanAttack(unit, "player") or UnitCanAttack("player", unit) or UnitIsPVP(unit) ) then
-- Hostile Units, use con color system
TipBuddy.gtt_classlvlcolor = TipBuddy_GetDifficultyColor(targetLevel);
else
-- Friendly (non-PvP flagged) Units, we don't want to use the con color cause we don't care
TipBuddy.gtt_classlvlcolor = tbcolor_lvl_same_faction;
end
if (UnitHealth(unit) <= 0) then
TipBuddy.gtt_classlvlcolor = tbcolor_corpse;
TipBuddy.gtt_classcorpse = " "..CORPSE.."|r";
end
if ( UnitPlayerControlled(unit) or UnitRace(unit)) then
if (targettype.rac == 1 and UnitRace(unit) ~= nil) then
TipBuddy.gtt_race = (tbcolor_race..UnitRace(unit).." |r");
else
TipBuddy.gtt_race = "|r";
end
--coloring class text
if (UnitClass(unit) == tb_translate_mage) then
TipBuddy.gtt_classcolor = tbcolor_cls_mage;
elseif (UnitClass(unit) == tb_translate_warlock) then
TipBuddy.gtt_classcolor = tbcolor_cls_warlock;
elseif (UnitClass(unit) == tb_translate_priest) then
TipBuddy.gtt_classcolor = tbcolor_cls_priest;
elseif (UnitClass(unit) == tb_translate_druid) then
TipBuddy.gtt_classcolor = tbcolor_cls_druid;
elseif (UnitClass(unit) == tb_translate_shaman) then
TipBuddy.gtt_classcolor = tbcolor_cls_shaman;
elseif (UnitClass(unit) == tb_translate_paladin) then
TipBuddy.gtt_classcolor = tbcolor_cls_paladin;
elseif (UnitClass(unit) == tb_translate_rogue) then
TipBuddy.gtt_classcolor = tbcolor_cls_rogue;
elseif (UnitClass(unit) == tb_translate_hunter) then
TipBuddy.gtt_classcolor = tbcolor_cls_hunter;
elseif (UnitClass(unit) == tb_translate_warrior) then
TipBuddy.gtt_classcolor = tbcolor_cls_warrior;
else
TipBuddy.gtt_classcolor = tbcolor_cls_other;
end
end
--/script TB_AddMessage(UnitCreatureFamily("mouseover"));
if ( type == "pet_friend" or type == "pet_enemy" ) then
TipBuddy.gtt_race = "";
if (UnitCreatureFamily(unit)) then
TipBuddy.gtt_class = UnitCreatureFamily(unit).."|r";
return;
else
TipBuddy.gtt_class = "|r";
end
return;
end
--TB_AddMessage("Get Class - "..unit);
-- /script TB_AddMessage(UnitCreatureType(unit));
if ( UnitPlayerControlled(unit) or UnitRace(unit)) then
TipBuddy.gtt_class = UnitClass(unit).."|r";
elseif ( UnitCreatureFamily(unit) ) then
TipBuddy.gtt_class = UnitCreatureFamily(unit).."|r";
else
if ( UnitCreatureType(unit) == tb_translate_notspecified) then
TipBuddy.gtt_class = tb_translate_creature.."|r";
else
if (not UnitCreatureType(unit)) then
TipBuddy.gtt_class = "|r";
else
TipBuddy.gtt_class = UnitCreatureType(unit).."|r";
end
end
end
end
function TipBuddy_ShowRank( type, unit )
--TB_AddMessage("TipBuddy_ShowRank");
TipBuddy_RankFrameGTT:Hide();
TipBuddy_RankFrame:Hide();
if (not type or not unit or ( TipBuddy_SavedVars[type].rnk == 0 )) then
--TB_AddMessage("no type or unit");
return;
end
local rankName, rankNumber = GetPVPRankInfo(UnitPVPRank(unit));
local rankFrame, srankFrame;
if ( TipBuddy_SavedVars[type].off == 1 ) then
rankFrame = getglobal("TipBuddy_RankFrame");
srankFrame = "TipBuddy_RankFrame";
else
rankFrame = getglobal("TipBuddy_RankFrameGTT");
srankFrame = "TipBuddy_RankFrameGTT";
end
local rankFrameIcon = getglobal(srankFrame.."Icon");
-- /script DEFAULT_CHAT_FRAME:AddMessage(UnitPVPRank("target"));
if (not UnitPlayerControlled(unit) or rankNumber == 0) then
rankFrame:Hide();
return;
end
-- Set icon
if ( rankNumber > 0 ) then
rankFrameIcon:SetTexture(format("%s%02d","Interface\\PvPRankBadges\\PvPRank",rankNumber));
rankFrame:Show();
else
rankFrame:Hide();
end
end
--------------------------------------------------------------------------------------------------------------------------------------
-- CHECK PET
--------------------------------------------------------------------------------------------------------------------------------------
--[[
UNITNAME_TITLE_CHARM = "%s's Minion"; -- %s is the name of the unit's charmer
UNITNAME_TITLE_CREATION = "%s's Creation";
UNITNAME_TITLE_GUARDIAN = "%s's Guardian";
UNITNAME_TITLE_MINION = "%s's Minion";
UNITNAME_TITLE_PET = "%s's Pet"; -- %s is the name of the unit's summoner
]]--
function TipBuddy_TargetInfo_CheckPet()
for i=1, (GameTooltip:NumLines()), 1 do
local tipstring = getglobal("GameTooltipTextLeft"..i);
if (not tipstring or not tipstring:GetText()) then
return;
end
if ( string.find(tipstring:GetText(), tb_translate_minion) ) then
return 1;
end
if ( string.find(tipstring:GetText(), tb_translate_creation) ) then
return 1;
end
if ( string.find(tipstring:GetText(), tb_translate_guardian) ) then
return 1;
end
if ( string.find(tipstring:GetText(), tb_translate_pet) ) then
return 1;
end
end
return;
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET GUILD
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetInfo_GetGuild( type, unit )
if (not unit or not type) then
return;
end
if (TipBuddy.refresh == 1) then
--TB_AddMessage("REFRESH == 1");
if (TipBuddy.gtt_guild == "" or TipBuddy.gtt_guild == nil) then
return;
end
end
--/script GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);GameTooltip:SetUnit("partypet1"); TB_AddMessage(GameTooltipTextLeft2:GetText());
local targettype = TipBuddy_SavedVars[type];
TipBuddy.gtt_guildcolor = "";
if (targettype.off ~= 2) then
if (GetGuildInfo("player") and GetGuildInfo(unit) == GetGuildInfo("player")) then
TipBuddy.gtt_guildcolor = tbcolor_gld_mate;
elseif ( UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) ) then
TipBuddy.gtt_guildcolor = (tbcolor_gld_tappedother);
elseif (UnitIsTappedByPlayer(unit)) then
TipBuddy.gtt_guildcolor = (tbcolor_gld_tappedplayer);
elseif (TipBuddy.reaction) then
TipBuddy.gtt_guildcolor = getglobal("tbcolor_gld_"..TipBuddy.reaction);
else
TipBuddy.gtt_guildcolor = tbcolor_unknown;
end
if (TipBuddy.refresh == 1) then
return;
end
end
if (unit == "party1" or unit == "partypet1" or unit == "party2" or unit == "partypet2" or unit == "party3" or unit == "partypet3" or unit == "party4" or unit == "partypet4" or unit == "party5" or unit == "partypet5" ) then
if ( GetGuildInfo(unit) ) then
TipBuddy.gtt_guild = (GetGuildInfo(unit));
--TB_AddMessage(GetGuildInfo(unit));
end
if (not TipBuddy.gtt_guild) then
TipBuddy.gtt_guild = "";
end
return;
elseif (UnitPlayerControlled(unit) or (GameTooltipTextLeft2:GetText() and string.find(GameTooltipTextLeft2:GetText(), PLAYER ) ) ) then
if ( type == "pet_friend" or type == "pet_enemy" ) then
TipBuddy.gtt_guild = (GameTooltipTextLeft2:GetText());
--TB_AddMessage("player pet guild: "..TipBuddy.gtt_guild);
return;
elseif ( GetGuildInfo(unit) ) then
TipBuddy.gtt_guild = (GetGuildInfo(unit));
--TB_AddMessage("player guild: "..TipBuddy.gtt_guild);
end
return;
else
--TB_AddMessage("GUILD: npc, testing...");
if (not GameTooltipTextLeft2:GetText()) then
--TB_AddMessage("GUILD: npc, line 2 is blank");
return;
end
if ( type == "pet_friend" or type == "pet_enemy" ) then
TipBuddy.gtt_guild = (GameTooltipTextLeft2:GetText());
--TB_AddMessage("pet guild: "..TipBuddy.gtt_guild);
return;
end
if (string.find(GameTooltipTextLeft2:GetText(), LEVEL ) ) then
--TB_AddMessage("GUILD: npc, line 2 is level");
return;
else
TipBuddy.gtt_guild = (GameTooltipTextLeft2:GetText());
--TB_AddMessage("title guild: "..TipBuddy.gtt_guild);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -