vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1  
2 if (not Nurfed_Units) then
3  
4 local framelib = Nurfed_Frames:New();
5  
6 Nurfed_Units = {};
7  
8 Nurfed_Units.class = {
9 DRUID = { right = 0.75, left = 1, top = 0, bottom = 0.25, color = "|cffff8a00" },
10 HUNTER = { right = 0, left = 0.25, top = 0.25, bottom = 0.5, color = "|cff00ff00" },
11 MAGE = { right = 0.25, left = 0.5, top = 0, bottom = 0.25, color = "|cff00ffff" },
12 PALADIN = { right = 0, left = 0.25, top = 0.5, bottom = 0.75, color = "|cffff71a8" },
13 PRIEST = { right = 0.5, left = 0.75, top = 0.25, bottom = 0.5, color = "|cffffffff" },
14 ROGUE = { right = 0.5, left = 0.75, top = 0, bottom = 0.25, color = "|cffffff00" },
15 SHAMAN = { right = 0.25, left = 0.5, top = 0.25, bottom = 0.5, color = "|cffff71a8" },
16 WARLOCK = { right = 0.75, left = 1, top = 0.25, bottom = 0.5, color = "|cff8d54fb" },
17 WARRIOR = { right = 0, left = 0.25, top = 0, bottom = 0.25, color = "|cffb39442" },
18 };
19  
20 Nurfed_Units.classification = {
21 ["worldboss"] = BOSS,
22 ["rareelite"] = ITEM_QUALITY3_DESC.."-"..ELITE,
23 ["rare"] = ITEM_QUALITY3_DESC,
24 ["elite"] = ELITE,
25 };
26  
27 Nurfed_Units.unitlist = {};
28  
29 function Nurfed_Units:New ()
30 local object = {};
31 setmetatable(object, self);
32 self.__index = self;
33 return object;
34 end
35  
36 function Nurfed_Units:UpdateUnits()
37 local i;
38 self.unitlist = nil;
39 self.unitlist = {};
40 if (GetNumPartyMembers() > 0) then
41 for i = 1, GetNumPartyMembers() do
42 self.unitlist[UnitName("party"..i)] = { t = "Party", c = UnitClass("party"..i) };
43 end
44 end
45 if (GetNumRaidMembers() > 0) then
46 for i = 1, GetNumRaidMembers() do
47 local name, rank, subgroup, _, class, _, _, _, _ = GetRaidRosterInfo(i);
48 if (name and rank and subgroup and class) then
49 if (self.unitlist[name]) then
50 self.unitlist[name].g = subgroup;
51 self.unitlist[name].r = rank;
52 else
53 self.unitlist[name] = { t = "Raid", c = class, g = subgroup, r = rank };
54 end
55 end
56 end
57 end
58 end
59  
60 function Nurfed_Units:GetUnit(name)
61 if (self.unitlist[name]) then
62 return self.unitlist[name];
63 end
64 return nil;
65 end
66  
67 function Nurfed_Units:GetHealth(unit)
68 local currhp, maxhp = UnitHealth(unit), UnitHealthMax(unit);
69 if (maxhp == 100 and (IsAddOnLoaded("MobHealth") or IsAddOnLoaded ("MobInfo2")) and unit == "target") then
70 local check = MobHealth_GetTargetMaxHP();
71 if (check and check > 0) then
72 maxhp = check;
73 currhp = MobHealth_GetTargetCurHP();
74 else
75 currhp = UnitHealth(unit);
76 end
77 else
78 currhp = UnitHealth(unit);
79 end
80 if (not UnitIsConnected(unit)) then
81 currhp = 0;
82 end
83 local perc = currhp/maxhp;
84 local color = {};
85 if(perc > 0.5) then
86 color.r = (1.0 - perc) * 2;
87 color.g = 1.0;
88 else
89 color.r = 1.0;
90 color.g = perc * 2;
91 end
92 color.b = 0.0;
93 perc = format("%.0f", floor(perc * 100));
94 return currhp, maxhp, perc, color;
95 end
96  
97 function Nurfed_Units:GetMana(unit)
98 local currmp, maxmp = UnitMana(unit), UnitManaMax(unit);
99 if (not UnitIsConnected(unit)) then
100 currmp = 0;
101 end
102 local perc = format("%.0f", (currmp / maxmp) * 100);
103 return currmp, maxmp, perc;
104 end
105  
106 function Nurfed_Units:GetXP(unit)
107 if (not UnitExists(unit)) then
108 return 0, 0, 0;
109 end
110 local name, reaction, min, max, value = GetWatchedFactionInfo();
111 local currxp, maxxp, perc;
112 if (name) then
113 currxp = value - min;
114 maxxp = max - min;
115 else
116 currxp = UnitXP(unit);
117 maxxp = UnitXPMax(unit);
118 end
119 local perc = format("%.0f", (currxp / maxxp) * 100);
120 return currxp, maxxp, perc;
121 end
122  
123 function Nurfed_Units:GetReaction(unit)
124 local info = {};
125 if (UnitPlayerControlled(unit)) then
126 if (UnitCanAttack(unit, "player")) then
127 -- Hostile players are red
128 if (not UnitCanAttack("player", unit)) then
129 info.r = 0.0;
130 info.g = 0.0;
131 info.b = 1.0;
132 else
133 info.r = UnitReactionColor[2].r;
134 info.g = UnitReactionColor[2].g;
135 info.b = UnitReactionColor[2].b;
136 end
137 elseif (UnitCanAttack("player", unit)) then
138 -- Players we can attack but which are not hostile are yellow
139 info.r = UnitReactionColor[4].r;
140 info.g = UnitReactionColor[4].g;
141 info.b = UnitReactionColor[4].b;
142 elseif (UnitIsPVP(unit)) then
143 -- Players we can assist but are PvP flagged are green
144 info.r = UnitReactionColor[6].r;
145 info.g = UnitReactionColor[6].g;
146 info.b = UnitReactionColor[6].b;
147 else
148 -- All other players are blue (the usual state on the "blue" server)
149 info.r = 0.0;
150 info.g = 1.0;
151 info.b = 1.0;
152 end
153 elseif (UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
154 info.r = 0.5;
155 info.g = 0.5;
156 info.b = 0.5;
157 else
158 local reaction = UnitReaction(unit, "player");
159 if (reaction) then
160 info.r = UnitReactionColor[reaction].r;
161 info.g = UnitReactionColor[reaction].g;
162 info.b = UnitReactionColor[reaction].b;
163 else
164 info.r = 0.0;
165 info.g = 1.0;
166 info.b = 1.0;
167 end
168 end
169 return info;
170 end
171  
172 function Nurfed_Units:StatusBarUpdate(arg1)
173 if (this.fade < 1) then
174 this.fade = this.fade + arg1;
175 if this.fade > 1 then
176 this.fade = 1;
177 end
178 local delta = this.endvalue - this.startvalue;
179 local diff = delta * (this.fade / 1);
180 this.startvalue = this.startvalue + diff;
181 this:SetValue(this.startvalue);
182 end
183 end
184  
185 function Nurfed_Units:Fade(arg1)
186 this.update = this.update + arg1;
187 if (this.update > 0.04) then
188 this.update = 0;
189 local now = GetTime();
190 local frame, texture, p;
191 if (now - this.flashtime > 0.3) then
192 this.flashdct = this.flashdct * (-1);
193 this.flashtime = now;
194 end
195  
196 if (this.flashdct == 1) then
197 p = (1 - (now - this.flashtime + 0.001) / 0.3 * 0.7);
198 else
199 p = ( (now - this.flashtime + 0.001) / 0.3 * 0.7 + 0.3);
200 end
201 this:SetAlpha(p);
202 end
203 end
204  
205 local tbl = {
206 type = "Frame",
207 OnEvent = function() Nurfed_Units:UpdateUnits() end,
208 events = {
209 "PLAYER_ENTERING_WORLD",
210 "PARTY_MEMBERS_CHANGED",
211 "RAID_ROSTER_UPDATE",
212 },
213 };
214  
215 framelib:ObjectInit("Nurfed_UnitsFrame", tbl, UIParent);
216 tbl = nil;
217 end
218  
219 function Nurfed_RaidFrameDropDown_Initialize()
220 UnitPopup_ShowMenu(getglobal(UIDROPDOWNMENU_OPEN_MENU), "RAID", this.unit, this.name, this.id);
221 end
222  
223 function Nurfed_Unit_OnClick(arg1)
224 local name, dropdown;
225 if (SpellIsTargeting() and arg1 == "RightButton") then
226 SpellStopTargeting();
227 return;
228 end
229 if (arg1 == "LeftButton") then
230 if (SpellIsTargeting() and SpellCanTargetUnit(this.unit)) then
231 SpellTargetUnit(this.unit);
232 elseif (CursorHasItem()) then
233 if (this.unit == "player") then
234 AutoEquipCursorItem();
235 else
236 DropItemOnUnit(this.unit);
237 end
238 else
239 TargetUnit(this.unit);
240 end
241 else
242 if (string.find(this.unit, "party[1-4]")) then
243 name = "PartyMemberFrame"..this:GetID();
244 dropdown = getglobal(name.."DropDown");
245 elseif (string.find(this.unit, "^raid")) then
246 FriendsDropDown.initialize = Nurfed_RaidFrameDropDown_Initialize;
247 FriendsDropDown.displayMode = "MENU";
248 dropdown = FriendsDropDown;
249 else
250 name = string.gsub(this.unit, "^%l", string.upper);
251 dropdown = getglobal(name.."FrameDropDown");
252 end
253 if (dropdown) then
254 ToggleDropDownMenu(1, nil, dropdown, "cursor");
255 end
256 return;
257 end
258 end
259  
260 function Nurfed_SetAuraTooltip()
261 if (not this:IsVisible()) then return; end
262 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT");
263 local unit = this:GetParent().unit;
264 if (this.isdebuff) then
265 GameTooltip:SetUnitDebuff(unit, this.id);
266 else
267 GameTooltip:SetUnitBuff(unit, this.id);
268 end
269 end