vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --------------- |
2 | -- Variables -- |
||
3 | --------------- |
||
4 | Perl_Target_Target_Config = {}; |
||
5 | |||
6 | -- Default Saved Variables (also set in Perl_Target_Target_GetVars) |
||
7 | local locked = 0; -- unlocked by default |
||
8 | local mobhealthsupport = 1; -- mobhealth support is on by default |
||
9 | local scale = 1; -- default scale |
||
10 | local totsupport = 1; -- target of target support enabled by default |
||
11 | local tototsupport = 1; -- target of target of target support enabled by default |
||
12 | local transparency = 1; -- transparency for frames |
||
13 | local alertsound = 0; -- audible alert disabled by default |
||
14 | local alertmode = 0; -- DPS, Tank, Healer modes |
||
15 | local alertsize = 0; -- Variable which controls the size of the text |
||
16 | |||
17 | -- Default Local Variables |
||
18 | local Initialized = nil; -- waiting to be initialized |
||
19 | local Perl_Target_Target_Time_Elapsed = 0; -- set the update timer to 0 |
||
20 | local Perl_Target_Target_Time_Update_Rate = 0.2; -- the update interval |
||
21 | local aggroWarningCount = 0; -- the check to see if we have alerted the player of a ToT event |
||
22 | local aggroToToTWarningCount = 0; -- the check to see if we have alerted the player of a ToToT event |
||
23 | local startTime = 0; -- used to keep track of fading the big alert text |
||
24 | local mouseovertargettargethealthflag = 0; -- is the mouse over the health bar for healer mode? |
||
25 | local mouseovertargettargetmanaflag = 0; -- is the mouse over the mana bar for healer mode? |
||
26 | local mouseovertargettargettargethealthflag = 0; -- is the mouse over the health bar for healer mode? |
||
27 | local mouseovertargettargettargetmanaflag = 0; -- is the mouse over the mana bar for healer mode? |
||
28 | |||
29 | |||
30 | ---------------------- |
||
31 | -- Loading Function -- |
||
32 | ---------------------- |
||
33 | function Perl_Target_Target_OnLoad() |
||
34 | -- Events |
||
35 | this:RegisterEvent("ADDON_LOADED"); |
||
36 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
37 | this:RegisterEvent("PLAYER_REGEN_ENABLED"); |
||
38 | this:RegisterEvent("PLAYER_TARGET_CHANGED"); |
||
39 | this:RegisterEvent("VARIABLES_LOADED"); |
||
40 | |||
41 | -- Button Click Overlays (in order of occurrence in XML) |
||
42 | Perl_Target_Target_NameFrame_CastClickOverlay:SetFrameLevel(Perl_Target_Target_NameFrame:GetFrameLevel() + 1); |
||
43 | Perl_Target_Target_StatsFrame_CastClickOverlay:SetFrameLevel(Perl_Target_Target_StatsFrame:GetFrameLevel() + 1); |
||
44 | Perl_Target_Target_HealthBar_CastClickOverlay:SetFrameLevel(Perl_Target_Target_StatsFrame:GetFrameLevel() + 2); |
||
45 | Perl_Target_Target_ManaBar_CastClickOverlay:SetFrameLevel(Perl_Target_Target_StatsFrame:GetFrameLevel() + 2); |
||
46 | Perl_Target_Target_Target_NameFrame_CastClickOverlay:SetFrameLevel(Perl_Target_Target_Target_NameFrame:GetFrameLevel() + 1); |
||
47 | Perl_Target_Target_Target_StatsFrame_CastClickOverlay:SetFrameLevel(Perl_Target_Target_Target_StatsFrame:GetFrameLevel() + 1); |
||
48 | Perl_Target_Target_Target_HealthBar_CastClickOverlay:SetFrameLevel(Perl_Target_Target_Target_StatsFrame:GetFrameLevel() + 2); |
||
49 | Perl_Target_Target_Target_ManaBar_CastClickOverlay:SetFrameLevel(Perl_Target_Target_Target_StatsFrame:GetFrameLevel() + 2); |
||
50 | |||
51 | if (DEFAULT_CHAT_FRAME) then |
||
52 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Perl Classic: Target_Target loaded successfully."); |
||
53 | end |
||
54 | end |
||
55 | |||
56 | |||
57 | ------------------- |
||
58 | -- Event Handler -- |
||
59 | ------------------- |
||
60 | function Perl_Target_Target_OnEvent(event) |
||
61 | if (event == "PLAYER_REGEN_ENABLED" or event == "PLAYER_TARGET_CHANGED") then |
||
62 | aggroWarningCount = 0; |
||
63 | elseif (event == "VARIABLES_LOADED") or (event=="PLAYER_ENTERING_WORLD") then |
||
64 | Perl_Target_Target_Initialize(); |
||
65 | return; |
||
66 | elseif (event == "ADDON_LOADED") then |
||
67 | if (arg1 == "Perl_Target_Target") then |
||
68 | Perl_Target_Target_myAddOns_Support(); |
||
69 | end |
||
70 | return; |
||
71 | else |
||
72 | return; |
||
73 | end |
||
74 | end |
||
75 | |||
76 | |||
77 | ------------------------------- |
||
78 | -- Loading Settings Function -- |
||
79 | ------------------------------- |
||
80 | function Perl_Target_Target_Initialize() |
||
81 | if (Initialized) then |
||
82 | Perl_Target_Target_Set_Scale(); -- Set the scale |
||
83 | Perl_Target_Target_Set_Transparency(); -- Set the transparency |
||
84 | return; |
||
85 | end |
||
86 | |||
87 | -- Check if a previous exists, if not, enable by default. |
||
88 | if (type(Perl_Target_Target_Config[UnitName("player")]) == "table") then |
||
89 | Perl_Target_Target_GetVars(); |
||
90 | else |
||
91 | Perl_Target_Target_UpdateVars(); |
||
92 | end |
||
93 | |||
94 | -- Major config options. |
||
95 | Perl_Target_Target_Initialize_Frame_Color(); |
||
96 | Perl_Target_Target_Frame:Hide(); |
||
97 | Perl_Target_Target_Target_Frame:Hide(); |
||
98 | |||
99 | Initialized = 1; |
||
100 | end |
||
101 | |||
102 | function Perl_Target_Target_Initialize_Frame_Color() |
||
103 | Perl_Target_Target_StatsFrame:SetBackdropColor(0, 0, 0, 1); |
||
104 | Perl_Target_Target_StatsFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1); |
||
105 | Perl_Target_Target_NameFrame:SetBackdropColor(0, 0, 0, 1); |
||
106 | Perl_Target_Target_NameFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1); |
||
107 | Perl_Target_Target_HealthBarText:SetTextColor(1, 1, 1, 1); |
||
108 | Perl_Target_Target_ManaBarText:SetTextColor(1, 1, 1, 1); |
||
109 | |||
110 | Perl_Target_Target_Target_StatsFrame:SetBackdropColor(0, 0, 0, 1); |
||
111 | Perl_Target_Target_Target_StatsFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1); |
||
112 | Perl_Target_Target_Target_NameFrame:SetBackdropColor(0, 0, 0, 1); |
||
113 | Perl_Target_Target_Target_NameFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1); |
||
114 | Perl_Target_Target_Target_HealthBarText:SetTextColor(1, 1, 1, 1); |
||
115 | Perl_Target_Target_Target_ManaBarText:SetTextColor(1, 1, 1, 1); |
||
116 | end |
||
117 | |||
118 | |||
119 | -------------------------- |
||
120 | -- The Update Functions -- |
||
121 | -------------------------- |
||
122 | function Perl_Target_Target_OnUpdate(arg1) |
||
123 | Perl_Target_Target_Time_Elapsed = Perl_Target_Target_Time_Elapsed + arg1; |
||
124 | if (Perl_Target_Target_Time_Elapsed > Perl_Target_Target_Time_Update_Rate) then |
||
125 | Perl_Target_Target_Time_Elapsed = 0; |
||
126 | |||
127 | if (UnitExists("targettarget") and totsupport == 1) then |
||
128 | Perl_Target_Target_Warn(); -- Display any warnings if needed |
||
129 | Perl_Target_Target_Frame:Show(); -- Show the frame |
||
130 | |||
131 | -- Begin: Set the name |
||
132 | local targettargetname = UnitName("targettarget"); |
||
133 | if (strlen(targettargetname) > 11) then |
||
134 | targettargetname = strsub(targettargetname, 1, 10).."..."; |
||
135 | end |
||
136 | Perl_Target_Target_NameBarText:SetText(targettargetname); |
||
137 | -- End: Set the name |
||
138 | |||
139 | -- Begin: Set the name text color |
||
140 | if (UnitIsPlayer("targettarget") or UnitPlayerControlled("targettarget")) then -- is it a player |
||
141 | local r, g, b; |
||
142 | if (UnitCanAttack("targettarget", "player")) then -- are we in an enemy controlled zone |
||
143 | -- Hostile players are red |
||
144 | if (not UnitCanAttack("player", "targettarget")) then -- enemy is not pvp enabled |
||
145 | r = 0.5; |
||
146 | g = 0.5; |
||
147 | b = 1.0; |
||
148 | else -- enemy is pvp enabled |
||
149 | r = 1.0; |
||
150 | g = 0.0; |
||
151 | b = 0.0; |
||
152 | end |
||
153 | elseif (UnitCanAttack("player", "targettarget")) then -- enemy in a zone controlled by friendlies or when we're a ghost |
||
154 | -- Players we can attack but which are not hostile are yellow |
||
155 | r = 1.0; |
||
156 | g = 1.0; |
||
157 | b = 0.0; |
||
158 | elseif (UnitIsPVP("targettarget")) then -- friendly pvp enabled character |
||
159 | -- Players we can assist but are PvP flagged are green |
||
160 | r = 0.0; |
||
161 | g = 1.0; |
||
162 | b = 0.0; |
||
163 | else -- friendly non pvp enabled character |
||
164 | -- All other players are blue (the usual state on the "blue" server) |
||
165 | r = 0.5; |
||
166 | g = 0.5; |
||
167 | b = 1.0; |
||
168 | end |
||
169 | Perl_Target_Target_NameBarText:SetTextColor(r, g, b); |
||
170 | elseif (UnitIsTapped("targettarget") and not UnitIsTappedByPlayer("targettarget")) then |
||
171 | Perl_Target_Target_NameBarText:SetTextColor(0.5,0.5,0.5); -- not our tap |
||
172 | else |
||
173 | local reaction = UnitReaction("targettarget", "player"); |
||
174 | if (reaction) then |
||
175 | local r, g, b; |
||
176 | r = UnitReactionColor[reaction].r; |
||
177 | g = UnitReactionColor[reaction].g; |
||
178 | b = UnitReactionColor[reaction].b; |
||
179 | Perl_Target_Target_NameBarText:SetTextColor(r, g, b); |
||
180 | else |
||
181 | Perl_Target_Target_NameBarText:SetTextColor(0.5, 0.5, 1.0); |
||
182 | end |
||
183 | end |
||
184 | -- End: Set the name text color |
||
185 | |||
186 | -- Begin: Update the health bar |
||
187 | local targettargethealth = UnitHealth("targettarget"); |
||
188 | local targettargethealthmax = UnitHealthMax("targettarget"); |
||
189 | local targettargethealthpercent = floor(targettargethealth/targettargethealthmax*100+0.5); |
||
190 | |||
191 | if (UnitIsDead("targettarget") or UnitIsGhost("targettarget")) then -- This prevents negative health |
||
192 | targettargethealth = 0; |
||
193 | targettargethealthpercent = 0; |
||
194 | end |
||
195 | |||
196 | Perl_Target_Target_HealthBar:SetMinMaxValues(0, targettargethealthmax); |
||
197 | Perl_Target_Target_HealthBar:SetValue(targettargethealth); |
||
198 | |||
199 | if (PCUF_COLORHEALTH == 1) then |
||
200 | if ((targettargethealthpercent <= 100) and (targettargethealthpercent > 75)) then |
||
201 | Perl_Target_Target_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
202 | Perl_Target_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
203 | elseif ((targettargethealthpercent <= 75) and (targettargethealthpercent > 50)) then |
||
204 | Perl_Target_Target_HealthBar:SetStatusBarColor(1, 1, 0); |
||
205 | Perl_Target_Target_HealthBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
206 | elseif ((targettargethealthpercent <= 50) and (targettargethealthpercent > 25)) then |
||
207 | Perl_Target_Target_HealthBar:SetStatusBarColor(1, 0.5, 0); |
||
208 | Perl_Target_Target_HealthBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
209 | else |
||
210 | Perl_Target_Target_HealthBar:SetStatusBarColor(1, 0, 0); |
||
211 | Perl_Target_Target_HealthBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
212 | end |
||
213 | else |
||
214 | Perl_Target_Target_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
215 | Perl_Target_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
216 | end |
||
217 | |||
218 | if (mouseovertargettargethealthflag == 1) then |
||
219 | Perl_Target_Target_HealthShow(); |
||
220 | else |
||
221 | Perl_Target_Target_HealthBarText:SetText(targettargethealthpercent.."%"); |
||
222 | end |
||
223 | -- End: Update the health bar |
||
224 | |||
225 | -- Begin: Update the mana bar |
||
226 | local targettargetmana = UnitMana("targettarget"); |
||
227 | local targettargetmanamax = UnitManaMax("targettarget"); |
||
228 | |||
229 | if (UnitIsDead("targettarget") or UnitIsGhost("targettarget")) then -- This prevents negative mana |
||
230 | targettargetmana = 0; |
||
231 | end |
||
232 | |||
233 | Perl_Target_Target_ManaBar:SetMinMaxValues(0, targettargetmanamax); |
||
234 | Perl_Target_Target_ManaBar:SetValue(targettargetmana); |
||
235 | |||
236 | if (mouseovertargettargetmanaflag == 1) then |
||
237 | if (UnitPowerType("targettarget") == 1 or UnitPowerType("targettarget") == 2) then |
||
238 | Perl_Target_Target_ManaBarText:SetText(targettargetmana); |
||
239 | else |
||
240 | Perl_Target_Target_ManaBarText:SetText(targettargetmana.."/"..targettargetmanamax); |
||
241 | end |
||
242 | else |
||
243 | Perl_Target_Target_ManaBarText:Hide(); |
||
244 | end |
||
245 | -- End: Update the mana bar |
||
246 | |||
247 | -- Begin: Update the mana bar color |
||
248 | local targettargetmanamax = UnitManaMax("targettarget"); |
||
249 | local targettargetpower = UnitPowerType("targettarget"); |
||
250 | |||
251 | -- Set mana bar color |
||
252 | if (targettargetmanamax == 0) then |
||
253 | Perl_Target_Target_ManaBar:Hide(); |
||
254 | Perl_Target_Target_ManaBarBG:Hide(); |
||
255 | Perl_Target_Target_ManaBar_CastClickOverlay:Hide(); |
||
256 | Perl_Target_Target_StatsFrame:SetHeight(30); |
||
257 | Perl_Target_Target_StatsFrame_CastClickOverlay:SetHeight(30); |
||
258 | elseif (targettargetpower == 1) then |
||
259 | Perl_Target_Target_ManaBar:SetStatusBarColor(1, 0, 0, 1); |
||
260 | Perl_Target_Target_ManaBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
261 | Perl_Target_Target_ManaBar:Show(); |
||
262 | Perl_Target_Target_ManaBarBG:Show(); |
||
263 | Perl_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
264 | Perl_Target_Target_StatsFrame:SetHeight(42); |
||
265 | Perl_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
266 | elseif (targettargetpower == 2) then |
||
267 | Perl_Target_Target_ManaBar:SetStatusBarColor(1, 0.5, 0, 1); |
||
268 | Perl_Target_Target_ManaBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
269 | Perl_Target_Target_ManaBar:Show(); |
||
270 | Perl_Target_Target_ManaBarBG:Show(); |
||
271 | Perl_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
272 | Perl_Target_Target_StatsFrame:SetHeight(42); |
||
273 | Perl_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
274 | elseif (targettargetpower == 3) then |
||
275 | Perl_Target_Target_ManaBar:SetStatusBarColor(1, 1, 0, 1); |
||
276 | Perl_Target_Target_ManaBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
277 | Perl_Target_Target_ManaBar:Show(); |
||
278 | Perl_Target_Target_ManaBarBG:Show(); |
||
279 | Perl_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
280 | Perl_Target_Target_StatsFrame:SetHeight(42); |
||
281 | Perl_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
282 | else |
||
283 | Perl_Target_Target_ManaBar:SetStatusBarColor(0, 0, 1, 1); |
||
284 | Perl_Target_Target_ManaBarBG:SetStatusBarColor(0, 0, 1, 0.25); |
||
285 | Perl_Target_Target_ManaBar:Show(); |
||
286 | Perl_Target_Target_ManaBarBG:Show(); |
||
287 | Perl_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
288 | Perl_Target_Target_StatsFrame:SetHeight(42); |
||
289 | Perl_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
290 | end |
||
291 | -- End: Update the mana bar color |
||
292 | else |
||
293 | Perl_Target_Target_Frame:Hide(); -- Hide the frame |
||
294 | end |
||
295 | |||
296 | if (UnitExists("targettargettarget") and tototsupport == 1) then |
||
297 | Perl_Target_Target_Target_Frame:Show(); -- Show the frame |
||
298 | |||
299 | if (UnitAffectingCombat("targettarget")) then |
||
300 | if (UnitIsDead("targettargettarget") or UnitIsCorpse("targettargettarget")) then |
||
301 | -- Im thinking targetting something that is targetting a corpse or dead thing is causing crashes |
||
302 | -- Hence this safety check. If it is, we do nothing. |
||
303 | else |
||
304 | if (UnitName("targettargettarget")) then |
||
305 | if (UnitIsEnemy("targettarget", "player")) then |
||
306 | if (UnitName("targettargettarget") == UnitName("player")) then -- play the warning sound if needed |
||
307 | if (aggroWarningCount == 0 and aggroToToTWarningCount == 0) then |
||
308 | -- Its coming right for us! |
||
309 | if (aggroToToTWarningCount == 0) then |
||
310 | aggroToToTWarningCount = 1; |
||
311 | Perl_Target_Target_Play_Sound(); |
||
312 | end |
||
313 | end |
||
314 | else |
||
315 | -- Whew it isnt fighting us |
||
316 | aggroToToTWarningCount = 0; |
||
317 | end |
||
318 | else |
||
319 | -- Friendly target |
||
320 | aggroToToTWarningCount = 0; |
||
321 | end |
||
322 | end |
||
323 | end |
||
324 | end |
||
325 | |||
326 | |||
327 | -- Begin: Set the name |
||
328 | local targettargettargetname = UnitName("targettargettarget"); |
||
329 | if (strlen(targettargettargetname) > 11) then |
||
330 | targettargettargetname = strsub(targettargettargetname, 1, 10).."..."; |
||
331 | end |
||
332 | Perl_Target_Target_Target_NameBarText:SetText(targettargettargetname); |
||
333 | -- End: Set the name |
||
334 | |||
335 | -- Begin: Set the name text color |
||
336 | if (UnitIsPlayer("targettargettarget") or UnitPlayerControlled("targettargettarget")) then -- is it a player |
||
337 | local r, g, b; |
||
338 | if (UnitCanAttack("targettargettarget", "player")) then -- are we in an enemy controlled zone |
||
339 | -- Hostile players are red |
||
340 | if (not UnitCanAttack("player", "targettargettarget")) then -- enemy is not pvp enabled |
||
341 | r = 0.5; |
||
342 | g = 0.5; |
||
343 | b = 1.0; |
||
344 | else -- enemy is pvp enabled |
||
345 | r = 1.0; |
||
346 | g = 0.0; |
||
347 | b = 0.0; |
||
348 | end |
||
349 | elseif (UnitCanAttack("player", "targettargettarget")) then -- enemy in a zone controlled by friendlies or when we're a ghost |
||
350 | -- Players we can attack but which are not hostile are yellow |
||
351 | r = 1.0; |
||
352 | g = 1.0; |
||
353 | b = 0.0; |
||
354 | elseif (UnitIsPVP("targettargettarget")) then -- friendly pvp enabled character |
||
355 | -- Players we can assist but are PvP flagged are green |
||
356 | r = 0.0; |
||
357 | g = 1.0; |
||
358 | b = 0.0; |
||
359 | else -- friendly non pvp enabled character |
||
360 | -- All other players are blue (the usual state on the "blue" server) |
||
361 | r = 0.5; |
||
362 | g = 0.5; |
||
363 | b = 1.0; |
||
364 | end |
||
365 | Perl_Target_Target_Target_NameBarText:SetTextColor(r, g, b); |
||
366 | elseif (UnitIsTapped("targettargettarget") and not UnitIsTappedByPlayer("targettargettarget")) then |
||
367 | Perl_Target_Target_Target_NameBarText:SetTextColor(0.5,0.5,0.5); -- not our tap |
||
368 | else |
||
369 | local reaction = UnitReaction("targettargettarget", "player"); |
||
370 | if (reaction) then |
||
371 | local r, g, b; |
||
372 | r = UnitReactionColor[reaction].r; |
||
373 | g = UnitReactionColor[reaction].g; |
||
374 | b = UnitReactionColor[reaction].b; |
||
375 | Perl_Target_Target_Target_NameBarText:SetTextColor(r, g, b); |
||
376 | else |
||
377 | Perl_Target_Target_Target_NameBarText:SetTextColor(0.5, 0.5, 1.0); |
||
378 | end |
||
379 | end |
||
380 | -- End: Set the name text color |
||
381 | |||
382 | -- Begin: Update the health bar |
||
383 | local targettargettargethealth = UnitHealth("targettargettarget"); |
||
384 | local targettargettargethealthmax = UnitHealthMax("targettargettarget"); |
||
385 | local targettargettargethealthpercent = floor(targettargettargethealth/targettargettargethealthmax*100+0.5); |
||
386 | |||
387 | if (UnitIsDead("targettargettarget") or UnitIsGhost("targettargettarget")) then -- This prevents negative health |
||
388 | targettargettargethealth = 0; |
||
389 | targettargettargethealthpercent = 0; |
||
390 | end |
||
391 | |||
392 | Perl_Target_Target_Target_HealthBar:SetMinMaxValues(0, targettargettargethealthmax); |
||
393 | Perl_Target_Target_Target_HealthBar:SetValue(targettargettargethealth); |
||
394 | |||
395 | if (PCUF_COLORHEALTH == 1) then |
||
396 | if ((targettargettargethealthpercent <= 100) and (targettargettargethealthpercent > 75)) then |
||
397 | Perl_Target_Target_Target_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
398 | Perl_Target_Target_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
399 | elseif ((targettargettargethealthpercent <= 75) and (targettargettargethealthpercent > 50)) then |
||
400 | Perl_Target_Target_Target_HealthBar:SetStatusBarColor(1, 1, 0); |
||
401 | Perl_Target_Target_Target_HealthBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
402 | elseif ((targettargettargethealthpercent <= 50) and (targettargettargethealthpercent > 25)) then |
||
403 | Perl_Target_Target_Target_HealthBar:SetStatusBarColor(1, 0.5, 0); |
||
404 | Perl_Target_Target_Target_HealthBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
405 | else |
||
406 | Perl_Target_Target_Target_HealthBar:SetStatusBarColor(1, 0, 0); |
||
407 | Perl_Target_Target_Target_HealthBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
408 | end |
||
409 | else |
||
410 | Perl_Target_Target_Target_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
411 | Perl_Target_Target_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
412 | end |
||
413 | |||
414 | if (mouseovertargettargettargethealthflag == 1) then |
||
415 | Perl_Target_Target_Target_HealthShow(); |
||
416 | else |
||
417 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealthpercent.."%"); |
||
418 | end |
||
419 | -- End: Update the health bar |
||
420 | |||
421 | -- Begin: Update the mana bar |
||
422 | local targettargettargetmana = UnitMana("targettargettarget"); |
||
423 | local targettargettargetmanamax = UnitManaMax("targettargettarget"); |
||
424 | |||
425 | if (UnitIsDead("targettargettarget") or UnitIsGhost("targettargettarget")) then -- This prevents negative mana |
||
426 | targettargettargetmana = 0; |
||
427 | end |
||
428 | |||
429 | Perl_Target_Target_Target_ManaBar:SetMinMaxValues(0, targettargettargetmanamax); |
||
430 | Perl_Target_Target_Target_ManaBar:SetValue(targettargettargetmana); |
||
431 | |||
432 | if (mouseovertargettargettargetmanaflag == 1) then |
||
433 | if (UnitPowerType("targettargettarget") == 1 or UnitPowerType("targettargettarget") == 2) then |
||
434 | Perl_Target_Target_Target_ManaBarText:SetText(targettargettargetmana); |
||
435 | else |
||
436 | Perl_Target_Target_Target_ManaBarText:SetText(targettargettargetmana.."/"..targettargettargetmanamax); |
||
437 | end |
||
438 | else |
||
439 | Perl_Target_Target_Target_ManaBarText:Hide(); |
||
440 | end |
||
441 | -- End: Update the mana bar |
||
442 | |||
443 | -- Begin: Update the mana bar color |
||
444 | local targettargettargetmanamax = UnitManaMax("targettargettarget"); |
||
445 | local targettargettargetpower = UnitPowerType("targettargettarget"); |
||
446 | |||
447 | -- Set mana bar color |
||
448 | if (targettargettargetmanamax == 0) then |
||
449 | Perl_Target_Target_Target_ManaBar:Hide(); |
||
450 | Perl_Target_Target_Target_ManaBarBG:Hide(); |
||
451 | Perl_Target_Target_Target_ManaBar_CastClickOverlay:Hide(); |
||
452 | Perl_Target_Target_Target_StatsFrame:SetHeight(30); |
||
453 | Perl_Target_Target_Target_StatsFrame_CastClickOverlay:SetHeight(30); |
||
454 | elseif (targettargettargetpower == 1) then |
||
455 | Perl_Target_Target_Target_ManaBar:SetStatusBarColor(1, 0, 0, 1); |
||
456 | Perl_Target_Target_Target_ManaBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
457 | Perl_Target_Target_Target_ManaBar:Show(); |
||
458 | Perl_Target_Target_Target_ManaBarBG:Show(); |
||
459 | Perl_Target_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
460 | Perl_Target_Target_Target_StatsFrame:SetHeight(42); |
||
461 | Perl_Target_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
462 | elseif (targettargettargetpower == 2) then |
||
463 | Perl_Target_Target_Target_ManaBar:SetStatusBarColor(1, 0.5, 0, 1); |
||
464 | Perl_Target_Target_Target_ManaBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
465 | Perl_Target_Target_Target_ManaBar:Show(); |
||
466 | Perl_Target_Target_Target_ManaBarBG:Show(); |
||
467 | Perl_Target_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
468 | Perl_Target_Target_Target_StatsFrame:SetHeight(42); |
||
469 | Perl_Target_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
470 | elseif (targettargettargetpower == 3) then |
||
471 | Perl_Target_Target_Target_ManaBar:SetStatusBarColor(1, 1, 0, 1); |
||
472 | Perl_Target_Target_Target_ManaBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
473 | Perl_Target_Target_Target_ManaBar:Show(); |
||
474 | Perl_Target_Target_Target_ManaBarBG:Show(); |
||
475 | Perl_Target_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
476 | Perl_Target_Target_Target_StatsFrame:SetHeight(42); |
||
477 | Perl_Target_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
478 | else |
||
479 | Perl_Target_Target_Target_ManaBar:SetStatusBarColor(0, 0, 1, 1); |
||
480 | Perl_Target_Target_Target_ManaBarBG:SetStatusBarColor(0, 0, 1, 0.25); |
||
481 | Perl_Target_Target_Target_ManaBar:Show(); |
||
482 | Perl_Target_Target_Target_ManaBarBG:Show(); |
||
483 | Perl_Target_Target_Target_ManaBar_CastClickOverlay:Show(); |
||
484 | Perl_Target_Target_Target_StatsFrame:SetHeight(42); |
||
485 | Perl_Target_Target_Target_StatsFrame_CastClickOverlay:SetHeight(42); |
||
486 | end |
||
487 | -- End: Update the mana bar color |
||
488 | else |
||
489 | Perl_Target_Target_Target_Frame:Hide(); -- Hide the frame |
||
490 | end |
||
491 | |||
492 | end |
||
493 | end |
||
494 | |||
495 | function Perl_Target_Target_Warn() |
||
496 | -- Player has something targetted |
||
497 | if (UnitAffectingCombat("target")) then -- Target is in an active combat situation |
||
498 | if (UnitIsDead("targettarget") or UnitIsCorpse("targettarget")) then -- Target is dead, do nothing |
||
499 | -- Previous author had this in as a safety check |
||
500 | else |
||
501 | if (not UnitIsFriend("target", "player")) then -- Target isn't dead |
||
502 | -- Stupid mobs dont have targets when they are trapped/polyd/sapped/stunned, check for this |
||
503 | if (alertmode == 0) then -- Disabled but still have audible alert enabled |
||
504 | if (UnitName("targettarget") == UnitName("player")) then -- play the warning sound if needed |
||
505 | -- Its coming right for us! |
||
506 | if (aggroWarningCount == 0) then |
||
507 | aggroWarningCount = 1; |
||
508 | Perl_Target_Target_Play_Sound(); |
||
509 | end |
||
510 | else |
||
511 | -- Whew it isnt fighting us |
||
512 | aggroWarningCount = 0; |
||
513 | end |
||
514 | elseif (alertmode == 1) then -- DPS Mode |
||
515 | if (UnitName("targettarget") == UnitName("player")) then |
||
516 | -- Its coming right for us! |
||
517 | if (aggroWarningCount == 0) then |
||
518 | if (alertsize == 0) then |
||
519 | UIErrorsFrame:AddMessage(UnitName("target").." has changed targets to you!",1,0,0,1,3); |
||
520 | elseif (alertsize == 1) then |
||
521 | Perl_Target_Target_BigWarning_Show(UnitName("target").." has changed targets to you!"); |
||
522 | elseif (alertsize == 2) then |
||
523 | -- Warning disabled |
||
524 | end |
||
525 | aggroWarningCount = 1; |
||
526 | Perl_Target_Target_Play_Sound(); |
||
527 | end |
||
528 | else |
||
529 | -- Whew it isnt fighting us |
||
530 | aggroWarningCount = 0; |
||
531 | end |
||
532 | elseif (alertmode == 2) then -- Tank mode |
||
533 | if (UnitName("targettarget") == UnitName("player")) then |
||
534 | -- Its coming right for us! (A good thing, im tanking it) |
||
535 | aggroWarningCount = 0; |
||
536 | else |
||
537 | -- Some dumb hunter pulled aggro |
||
538 | if (aggroWarningCount == 0) then |
||
539 | if (alertsize == 0) then |
||
540 | UIErrorsFrame:AddMessage("You have lost aggro to "..UnitName("targettarget").."!",1,0,0,1,3); |
||
541 | elseif (alertsize == 1) then |
||
542 | Perl_Target_Target_BigWarning_Show("You have lost aggro to "..UnitName("targettarget").."!"); |
||
543 | elseif (alertsize == 2) then |
||
544 | -- Warning disabled |
||
545 | end |
||
546 | aggroWarningCount = 1; |
||
547 | Perl_Target_Target_Play_Sound(); |
||
548 | end |
||
549 | end |
||
550 | elseif (alertmode == 3) then -- Healer Mode (Do this check down here for sanity reasons) |
||
551 | Perl_Target_Target_Warn_Healer_Mode(); |
||
552 | else |
||
553 | -- Friendly target |
||
554 | aggroWarningCount = 0; |
||
555 | end |
||
556 | --end |
||
557 | else |
||
558 | if (alertmode == 3) then -- Healer Mode (Do this check down here for sanity reasons) |
||
559 | Perl_Target_Target_Warn_Healer_Mode(); |
||
560 | else |
||
561 | -- Friendly target |
||
562 | aggroWarningCount = 0; |
||
563 | end |
||
564 | end |
||
565 | end |
||
566 | end |
||
567 | end |
||
568 | |||
569 | function Perl_Target_Target_Warn_Healer_Mode() -- This chunk of code is called in 2 places so may as well place it as it's own function |
||
570 | if (UnitIsPlayer("target")) then |
||
571 | if (UnitIsFriend("player", "target")) then |
||
572 | if (UnitIsUnit("target", "targettargettarget")) then -- The target and the targets target target (whew) are the same |
||
573 | if (aggroWarningCount == 0) then |
||
574 | if (alertsize == 0) then |
||
575 | UIErrorsFrame:AddMessage(UnitName("target").." is now tanking "..UnitName("targettarget"),1,0,0,1,3); |
||
576 | elseif (alertsize == 1) then |
||
577 | if ((UnitName("player") == UnitName("target")) or (UnitName("target") == UnitName("targettarget"))) then |
||
578 | -- Do nothing |
||
579 | else |
||
580 | Perl_Target_Target_BigWarning_Show(UnitName("target").." is now tanking "..UnitName("targettarget")); |
||
581 | end |
||
582 | elseif (alertsize == 2) then |
||
583 | -- Warning disabled |
||
584 | end |
||
585 | aggroWarningCount = 1; |
||
586 | end |
||
587 | else |
||
588 | -- Lazy warrior isnt tanking anything! |
||
589 | aggroWarningCount = 0; |
||
590 | end |
||
591 | else |
||
592 | if (UnitName("targettarget") == UnitName("player")) then |
||
593 | -- Its coming right for us! |
||
594 | if (aggroWarningCount == 0) then |
||
595 | if (alertsize == 0) then |
||
596 | UIErrorsFrame:AddMessage(UnitName("target").." has changed targets to you!",1,0,0,1,3); |
||
597 | elseif (alertsize == 1) then |
||
598 | Perl_Target_Target_BigWarning_Show(UnitName("target").." has changed targets to you!"); |
||
599 | elseif (alertsize == 2) then |
||
600 | -- Warning disabled |
||
601 | end |
||
602 | aggroWarningCount = 1; |
||
603 | Perl_Target_Target_Play_Sound(); |
||
604 | end |
||
605 | else |
||
606 | -- Whew it isnt fighting us |
||
607 | aggroWarningCount = 0; |
||
608 | end |
||
609 | end |
||
610 | else |
||
611 | if (UnitName("targettarget") == UnitName("player")) then |
||
612 | -- Its coming right for us! |
||
613 | if (aggroWarningCount == 0) then |
||
614 | if (alertsize == 0) then |
||
615 | UIErrorsFrame:AddMessage(UnitName("target").." has changed targets to you!",1,0,0,1,3); |
||
616 | elseif (alertsize == 1) then |
||
617 | Perl_Target_Target_BigWarning_Show(UnitName("target").." has changed targets to you!"); |
||
618 | elseif (alertsize == 2) then |
||
619 | -- Warning disabled |
||
620 | end |
||
621 | aggroWarningCount = 1; |
||
622 | Perl_Target_Target_Play_Sound(); |
||
623 | end |
||
624 | else |
||
625 | -- Whew it isnt fighting us |
||
626 | aggroWarningCount = 0; |
||
627 | end |
||
628 | end |
||
629 | end |
||
630 | |||
631 | function Perl_Target_Target_Play_Sound() |
||
632 | if (alertsound == 1) then |
||
633 | PlaySoundFile("Sound\\Spells\\PVPFlagTakenHorde.wav"); |
||
634 | end |
||
635 | end |
||
636 | |||
637 | |||
638 | ------------------------- |
||
639 | -- Mouseover Functions -- |
||
640 | ------------------------- |
||
641 | -- Target of Target Start |
||
642 | function Perl_Target_Target_HealthShow() |
||
643 | local targettargethealth = UnitHealth("targettarget"); |
||
644 | local targettargethealthmax = UnitHealthMax("targettarget"); |
||
645 | |||
646 | if (UnitIsDead("targettarget") or UnitIsGhost("targettarget")) then -- This prevents negative health |
||
647 | targettargethealth = 0; |
||
648 | targettargethealthpercent = 0; |
||
649 | end |
||
650 | |||
651 | if (targettargethealthmax == 100) then |
||
652 | -- Begin Mobhealth support |
||
653 | if (mobhealthsupport == 1) then |
||
654 | if (MobHealthFrame) then |
||
655 | |||
656 | local index; |
||
657 | if UnitIsPlayer("targettarget") then |
||
658 | index = UnitName("targettarget"); |
||
659 | else |
||
660 | index = UnitName("targettarget")..":"..UnitLevel("targettarget"); |
||
661 | end |
||
662 | |||
663 | if ((MobHealthDB and MobHealthDB[index]) or (MobHealthPlayerDB and MobHealthPlayerDB[index])) then |
||
664 | local s, e; |
||
665 | local pts; |
||
666 | local pct; |
||
667 | |||
668 | if MobHealthDB[index] then |
||
669 | if (type(MobHealthDB[index]) ~= "string") then |
||
670 | Perl_Target_Target_HealthBarText:SetText(targettargethealth.."%"); |
||
671 | end |
||
672 | s, e, pts, pct = string.find(MobHealthDB[index], "^(%d+)/(%d+)$"); |
||
673 | else |
||
674 | if (type(MobHealthPlayerDB[index]) ~= "string") then |
||
675 | Perl_Target_Target_HealthBarText:SetText(targettargethealth.."%"); |
||
676 | end |
||
677 | s, e, pts, pct = string.find(MobHealthPlayerDB[index], "^(%d+)/(%d+)$"); |
||
678 | end |
||
679 | |||
680 | if (pts and pct) then |
||
681 | pts = pts + 0; |
||
682 | pct = pct + 0; |
||
683 | if (pct ~= 0) then |
||
684 | pointsPerPct = pts / pct; |
||
685 | else |
||
686 | pointsPerPct = 0; |
||
687 | end |
||
688 | end |
||
689 | |||
690 | local currentPct = UnitHealth("targettarget"); |
||
691 | if (pointsPerPct > 0) then |
||
692 | Perl_Target_Target_HealthBarText:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5)); -- Stored unit info from the DB |
||
693 | end |
||
694 | else |
||
695 | Perl_Target_Target_HealthBarText:SetText(targettargethealth.."%"); -- Unit not in MobHealth DB |
||
696 | end |
||
697 | -- End MobHealth Support |
||
698 | else |
||
699 | Perl_Target_Target_HealthBarText:SetText(targettargethealth.."%"); -- MobHealth isn't installed |
||
700 | end |
||
701 | else -- mobhealthsupport == 0 |
||
702 | Perl_Target_Target_HealthBarText:SetText(targettargethealth.."%"); -- MobHealth support is disabled |
||
703 | end |
||
704 | else |
||
705 | Perl_Target_Target_HealthBarText:SetText(targettargethealth.."/"..targettargethealthmax); -- Self/Party/Raid member |
||
706 | end |
||
707 | |||
708 | mouseovertargettargethealthflag = 1; |
||
709 | end |
||
710 | |||
711 | function Perl_Target_Target_HealthHide() |
||
712 | local targettargethealthpercent = floor(UnitHealth("targettarget")/UnitHealthMax("targettarget")*100+0.5); |
||
713 | |||
714 | if (UnitIsDead("targettarget") or UnitIsGhost("targettarget")) then -- This prevents negative health |
||
715 | targettargethealthpercent = 0; |
||
716 | end |
||
717 | |||
718 | Perl_Target_Target_HealthBarText:SetText(targettargethealthpercent.."%"); |
||
719 | mouseovertargettargethealthflag = 0; |
||
720 | end |
||
721 | |||
722 | function Perl_Target_Target_ManaShow() |
||
723 | local targettargetmana = UnitMana("targettarget"); |
||
724 | local targettargetmanamax = UnitManaMax("targettarget"); |
||
725 | |||
726 | if (UnitIsDead("targettarget") or UnitIsGhost("targettarget")) then -- This prevents negative mana |
||
727 | targettargetmana = 0; |
||
728 | end |
||
729 | |||
730 | if (UnitPowerType("targettarget") == 1) then |
||
731 | Perl_Target_Target_ManaBarText:SetText(targettargetmana); |
||
732 | else |
||
733 | Perl_Target_Target_ManaBarText:SetText(targettargetmana.."/"..targettargetmanamax); |
||
734 | end |
||
735 | Perl_Target_Target_ManaBarText:Show(); |
||
736 | mouseovertargettargetmanaflag = 1; |
||
737 | end |
||
738 | |||
739 | function Perl_Target_Target_ManaHide() |
||
740 | Perl_Target_Target_ManaBarText:Hide(); |
||
741 | mouseovertargettargetmanaflag = 0; |
||
742 | end |
||
743 | -- Target of Target End |
||
744 | |||
745 | -- Target of Target of Target Start |
||
746 | function Perl_Target_Target_Target_HealthShow() |
||
747 | local targettargettargethealth = UnitHealth("targettargettarget"); |
||
748 | local targettargettargethealthmax = UnitHealthMax("targettargettarget"); |
||
749 | |||
750 | if (UnitIsDead("targettargettarget") or UnitIsGhost("targettargettarget")) then -- This prevents negative health |
||
751 | targettargettargethealth = 0; |
||
752 | targettargettargethealthpercent = 0; |
||
753 | end |
||
754 | |||
755 | if (targettargettargethealthmax == 100) then |
||
756 | -- Begin Mobhealth support |
||
757 | if (mobhealthsupport == 1) then |
||
758 | if (MobHealthFrame) then |
||
759 | |||
760 | local index; |
||
761 | if UnitIsPlayer("targettargettarget") then |
||
762 | index = UnitName("targettargettarget"); |
||
763 | else |
||
764 | index = UnitName("targettargettarget")..":"..UnitLevel("targettargettarget"); |
||
765 | end |
||
766 | |||
767 | if ((MobHealthDB and MobHealthDB[index]) or (MobHealthPlayerDB and MobHealthPlayerDB[index])) then |
||
768 | local s, e; |
||
769 | local pts; |
||
770 | local pct; |
||
771 | |||
772 | if MobHealthDB[index] then |
||
773 | if (type(MobHealthDB[index]) ~= "string") then |
||
774 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealth.."%"); |
||
775 | end |
||
776 | s, e, pts, pct = string.find(MobHealthDB[index], "^(%d+)/(%d+)$"); |
||
777 | else |
||
778 | if (type(MobHealthPlayerDB[index]) ~= "string") then |
||
779 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealth.."%"); |
||
780 | end |
||
781 | s, e, pts, pct = string.find(MobHealthPlayerDB[index], "^(%d+)/(%d+)$"); |
||
782 | end |
||
783 | |||
784 | if (pts and pct) then |
||
785 | pts = pts + 0; |
||
786 | pct = pct + 0; |
||
787 | if (pct ~= 0) then |
||
788 | pointsPerPct = pts / pct; |
||
789 | else |
||
790 | pointsPerPct = 0; |
||
791 | end |
||
792 | end |
||
793 | |||
794 | local currentPct = UnitHealth("targettargettarget"); |
||
795 | if (pointsPerPct > 0) then |
||
796 | Perl_Target_Target_Target_HealthBarText:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5)); -- Stored unit info from the DB |
||
797 | end |
||
798 | else |
||
799 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealth.."%"); -- Unit not in MobHealth DB |
||
800 | end |
||
801 | -- End MobHealth Support |
||
802 | else |
||
803 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealth.."%"); -- MobHealth isn't installed |
||
804 | end |
||
805 | else -- mobhealthsupport == 0 |
||
806 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealth.."%"); -- MobHealth support is disabled |
||
807 | end |
||
808 | else |
||
809 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealth.."/"..targettargettargethealthmax); -- Self/Party/Raid member |
||
810 | end |
||
811 | |||
812 | mouseovertargettargettargethealthflag = 1; |
||
813 | end |
||
814 | |||
815 | function Perl_Target_Target_Target_HealthHide() |
||
816 | local targettargettargethealthpercent = floor(UnitHealth("targettargettarget")/UnitHealthMax("targettargettarget")*100+0.5); |
||
817 | |||
818 | if (UnitIsDead("targettargettarget") or UnitIsGhost("targettargettarget")) then -- This prevents negative health |
||
819 | targettargettargethealthpercent = 0; |
||
820 | end |
||
821 | |||
822 | Perl_Target_Target_Target_HealthBarText:SetText(targettargettargethealthpercent.."%"); |
||
823 | mouseovertargettargettargethealthflag = 0; |
||
824 | end |
||
825 | |||
826 | function Perl_Target_Target_Target_ManaShow() |
||
827 | local targettargettargetmana = UnitMana("targettargettarget"); |
||
828 | local targettargettargetmanamax = UnitManaMax("targettargettarget"); |
||
829 | |||
830 | if (UnitIsDead("targettargettarget") or UnitIsGhost("targettargettarget")) then -- This prevents negative mana |
||
831 | targettargettargetmana = 0; |
||
832 | end |
||
833 | |||
834 | if (UnitPowerType("targettargettarget") == 1) then |
||
835 | Perl_Target_Target_Target_ManaBarText:SetText(targettargettargetmana); |
||
836 | else |
||
837 | Perl_Target_Target_Target_ManaBarText:SetText(targettargettargetmana.."/"..targettargettargetmanamax); |
||
838 | end |
||
839 | Perl_Target_Target_Target_ManaBarText:Show(); |
||
840 | mouseovertargettargettargetmanaflag = 1; |
||
841 | end |
||
842 | |||
843 | function Perl_Target_Target_Target_ManaHide() |
||
844 | Perl_Target_Target_Target_ManaBarText:Hide(); |
||
845 | mouseovertargettargettargetmanaflag = 0; |
||
846 | end |
||
847 | -- Target of Target of Target End |
||
848 | |||
849 | |||
850 | -------------------------- |
||
851 | -- GUI Config Functions -- |
||
852 | -------------------------- |
||
853 | function Perl_Target_Target_Set_ToT(newvalue) |
||
854 | totsupport = newvalue; |
||
855 | Perl_Target_Target_UpdateVars(); |
||
856 | end |
||
857 | |||
858 | function Perl_Target_Target_Set_ToToT(newvalue) |
||
859 | tototsupport = newvalue; |
||
860 | Perl_Target_Target_UpdateVars(); |
||
861 | end |
||
862 | |||
863 | function Perl_Target_Target_Set_Mode(newvalue) |
||
864 | alertmode = newvalue; |
||
865 | Perl_Target_Target_UpdateVars(); |
||
866 | end |
||
867 | |||
868 | function Perl_Target_Target_Set_Sound_Alert(newvalue) |
||
869 | alertsound = newvalue; |
||
870 | Perl_Target_Target_UpdateVars(); |
||
871 | end |
||
872 | |||
873 | function Perl_Target_Target_Set_Alert_Size(newvalue) |
||
874 | alertsize = newvalue; |
||
875 | Perl_Target_Target_UpdateVars(); |
||
876 | end |
||
877 | |||
878 | function Perl_Target_Target_Set_MobHealth(newvalue) |
||
879 | mobhealthsupport = newvalue; |
||
880 | Perl_Target_Target_UpdateVars(); |
||
881 | end |
||
882 | |||
883 | function Perl_Target_Target_Set_Lock(newvalue) |
||
884 | locked = newvalue; |
||
885 | Perl_Target_Target_UpdateVars(); |
||
886 | end |
||
887 | |||
888 | function Perl_Target_Target_Set_Scale(number) |
||
889 | local unsavedscale; |
||
890 | if (number ~= nil) then |
||
891 | scale = (number / 100); -- convert the user input to a wow acceptable value |
||
892 | --DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Target of Target Display is now scaled to |cffffffff"..floor(scale * 100 + 0.5).."%|cffffff00."); -- only display if the user gave us a number |
||
893 | end |
||
894 | unsavedscale = 1 - UIParent:GetEffectiveScale() + scale; -- run it through the scaling formula introduced in 1.9 |
||
895 | Perl_Target_Target_Frame:SetScale(unsavedscale); |
||
896 | Perl_Target_Target_Target_Frame:SetScale(unsavedscale); |
||
897 | Perl_Target_Target_UpdateVars(); |
||
898 | end |
||
899 | |||
900 | function Perl_Target_Target_Set_Transparency(number) |
||
901 | if (number ~= nil) then |
||
902 | transparency = (number / 100); -- convert the user input to a wow acceptable value |
||
903 | end |
||
904 | Perl_Target_Target_Frame:SetAlpha(transparency); |
||
905 | Perl_Target_Target_Target_Frame:SetAlpha(transparency); |
||
906 | Perl_Target_Target_UpdateVars(); |
||
907 | end |
||
908 | |||
909 | function Perl_Target_Target_Allign(button) |
||
910 | if (Perl_Target_Frame) then |
||
911 | local vartable = Perl_Target_GetVars(); -- Get the target frame settings |
||
912 | |||
913 | Perl_Target_Target_Frame:SetUserPlaced(1); -- This makes wow remember the changes if the frames have never been moved before |
||
914 | Perl_Target_Target_Target_Frame:SetUserPlaced(1); |
||
915 | |||
916 | if (button == 1) then |
||
917 | if (vartable["showportrait"] == 1) then |
||
918 | if (vartable["showcp"] == 1 or vartable["comboframedebuffs"] == 1) then |
||
919 | Perl_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_PortraitFrame, "TOPRIGHT", 17, 0); |
||
920 | Perl_Target_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_Target_Frame, "TOPRIGHT", -4, 0); |
||
921 | else |
||
922 | Perl_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_PortraitFrame, "TOPRIGHT", -4, 0); |
||
923 | Perl_Target_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_Target_Frame, "TOPRIGHT", -4, 0); |
||
924 | end |
||
925 | else |
||
926 | if (vartable["showcp"] == 1 or vartable["comboframedebuffs"] == 1) then |
||
927 | Perl_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_LevelFrame, "TOPRIGHT", 17, 0); |
||
928 | Perl_Target_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_Target_Frame, "TOPRIGHT", -4, 0); |
||
929 | else |
||
930 | Perl_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_LevelFrame, "TOPRIGHT", -4, 0); |
||
931 | Perl_Target_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_Target_Frame, "TOPRIGHT", -4, 0); |
||
932 | end |
||
933 | end |
||
934 | elseif (button == 2) then |
||
935 | if (vartable["showclassframe"] == 1 or vartable["showrareeliteframe"] == 1) then |
||
936 | Perl_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_NameFrame, "TOPLEFT", 0, 77); |
||
937 | Perl_Target_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_Target_Frame, "TOPRIGHT", 1, 0); |
||
938 | else |
||
939 | Perl_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_NameFrame, "TOPLEFT", 0, 57); |
||
940 | Perl_Target_Target_Target_Frame:SetPoint("TOPLEFT", Perl_Target_Target_Frame, "TOPRIGHT", 1, 0); |
||
941 | end |
||
942 | end |
||
943 | else |
||
944 | DEFAULT_CHAT_FRAME:AddMessage("This feature is disabled due to Perl_Target not being installed/enabled."); |
||
945 | end |
||
946 | end |
||
947 | |||
948 | |||
949 | ------------------------------ |
||
950 | -- Saved Variable Functions -- |
||
951 | ------------------------------ |
||
952 | function Perl_Target_Target_GetVars() |
||
953 | locked = Perl_Target_Target_Config[UnitName("player")]["Locked"]; |
||
954 | mobhealthsupport = Perl_Target_Target_Config[UnitName("player")]["MobHealthSupport"]; |
||
955 | scale = Perl_Target_Target_Config[UnitName("player")]["Scale"]; |
||
956 | totsupport = Perl_Target_Target_Config[UnitName("player")]["ToTSupport"]; |
||
957 | tototsupport = Perl_Target_Target_Config[UnitName("player")]["ToToTSupport"]; |
||
958 | transparency = Perl_Target_Target_Config[UnitName("player")]["Transparency"]; |
||
959 | alertsound = Perl_Target_Target_Config[UnitName("player")]["AlertSound"]; |
||
960 | alertmode = Perl_Target_Target_Config[UnitName("player")]["AlertMode"]; |
||
961 | alertsize = Perl_Target_Target_Config[UnitName("player")]["AlertSize"]; |
||
962 | |||
963 | if (locked == nil) then |
||
964 | locked = 0; |
||
965 | end |
||
966 | if (mobhealthsupport == nil) then |
||
967 | mobhealthsupport = 1; |
||
968 | end |
||
969 | if (scale == nil) then |
||
970 | scale = 1; |
||
971 | end |
||
972 | if (totsupport == nil) then |
||
973 | totsupport = 1; |
||
974 | end |
||
975 | if (tototsupport == nil) then |
||
976 | tototsupport = 1; |
||
977 | end |
||
978 | if (transparency == nil) then |
||
979 | transparency = 1; |
||
980 | end |
||
981 | if (alertsound == nil) then |
||
982 | alertsound = 0; |
||
983 | end |
||
984 | if (alertmode == nil) then |
||
985 | alertmode = 0; |
||
986 | end |
||
987 | if (alertsize == nil) then |
||
988 | alertsize = 0; |
||
989 | end |
||
990 | |||
991 | local vars = { |
||
992 | ["locked"] = locked, |
||
993 | ["mobhealthsupport"] = mobhealthsupport, |
||
994 | ["scale"] = scale, |
||
995 | ["totsupport"] = totsupport, |
||
996 | ["tototsupport"] = tototsupport, |
||
997 | ["transparency"] = transparency, |
||
998 | ["alertsound"] = alertsound, |
||
999 | ["alertmode"] = alertmode, |
||
1000 | ["alertsize"] = alertsize, |
||
1001 | } |
||
1002 | return vars; |
||
1003 | end |
||
1004 | |||
1005 | function Perl_Target_Target_UpdateVars(vartable) |
||
1006 | if (vartable ~= nil) then |
||
1007 | -- Sanity checks in case you use a load from an old version |
||
1008 | if (vartable["Global Settings"] ~= nil) then |
||
1009 | if (vartable["Global Settings"]["Locked"] ~= nil) then |
||
1010 | locked = vartable["Global Settings"]["Locked"]; |
||
1011 | else |
||
1012 | locked = nil; |
||
1013 | end |
||
1014 | if (vartable["Global Settings"]["MobHealthSupport"] ~= nil) then |
||
1015 | mobhealthsupport = vartable["Global Settings"]["MobHealthSupport"]; |
||
1016 | else |
||
1017 | mobhealthsupport = nil; |
||
1018 | end |
||
1019 | if (vartable["Global Settings"]["Scale"] ~= nil) then |
||
1020 | scale = vartable["Global Settings"]["Scale"]; |
||
1021 | else |
||
1022 | scale = nil; |
||
1023 | end |
||
1024 | if (vartable["Global Settings"]["ToTSupport"] ~= nil) then |
||
1025 | totsupport = vartable["Global Settings"]["ToTSupport"]; |
||
1026 | else |
||
1027 | totsupport = nil; |
||
1028 | end |
||
1029 | if (vartable["Global Settings"]["ToToTSupport"] ~= nil) then |
||
1030 | tototsupport = vartable["Global Settings"]["ToToTSupport"]; |
||
1031 | else |
||
1032 | tototsupport = nil; |
||
1033 | end |
||
1034 | if (vartable["Global Settings"]["Transparency"] ~= nil) then |
||
1035 | transparency = vartable["Global Settings"]["Transparency"]; |
||
1036 | else |
||
1037 | transparency = nil; |
||
1038 | end |
||
1039 | if (vartable["Global Settings"]["AlertSound"] ~= nil) then |
||
1040 | alertsound = vartable["Global Settings"]["AlertSound"]; |
||
1041 | else |
||
1042 | alertsound = nil; |
||
1043 | end |
||
1044 | if (vartable["Global Settings"]["AlertMode"] ~= nil) then |
||
1045 | alertmode = vartable["Global Settings"]["AlertMode"]; |
||
1046 | else |
||
1047 | alertmode = nil; |
||
1048 | end |
||
1049 | if (vartable["Global Settings"]["AlertSize"] ~= nil) then |
||
1050 | alertsize = vartable["Global Settings"]["AlertSize"]; |
||
1051 | else |
||
1052 | alertsize = nil; |
||
1053 | end |
||
1054 | end |
||
1055 | |||
1056 | -- Set the new values if any new values were found, same defaults as above |
||
1057 | if (locked == nil) then |
||
1058 | locked = 0; |
||
1059 | end |
||
1060 | if (mobhealthsupport == nil) then |
||
1061 | mobhealthsupport = 1; |
||
1062 | end |
||
1063 | if (scale == nil) then |
||
1064 | scale = 1; |
||
1065 | end |
||
1066 | if (totsupport == nil) then |
||
1067 | totsupport = 1; |
||
1068 | end |
||
1069 | if (tototsupport == nil) then |
||
1070 | tototsupport = 1; |
||
1071 | end |
||
1072 | if (transparency == nil) then |
||
1073 | transparency = 1; |
||
1074 | end |
||
1075 | if (alertsound == nil) then |
||
1076 | alertsound = 0; |
||
1077 | end |
||
1078 | if (alertmode == nil) then |
||
1079 | alertmode = 0; |
||
1080 | end |
||
1081 | if (alertsize == nil) then |
||
1082 | alertsize = 0; |
||
1083 | end |
||
1084 | |||
1085 | -- Call any code we need to activate them |
||
1086 | Perl_Target_Target_Set_Scale(); |
||
1087 | Perl_Target_Target_Set_Transparency(); |
||
1088 | end |
||
1089 | |||
1090 | Perl_Target_Target_Config[UnitName("player")] = { |
||
1091 | ["Locked"] = locked, |
||
1092 | ["MobHealthSupport"] = mobhealthsupport, |
||
1093 | ["Scale"] = scale, |
||
1094 | ["ToTSupport"] = totsupport, |
||
1095 | ["ToToTSupport"] = tototsupport, |
||
1096 | ["Transparency"] = transparency, |
||
1097 | ["AlertSound"] = alertsound, |
||
1098 | ["AlertMode"] = alertmode, |
||
1099 | ["AlertSize"] = alertsize, |
||
1100 | }; |
||
1101 | end |
||
1102 | |||
1103 | |||
1104 | -------------------- |
||
1105 | -- Click Handlers -- |
||
1106 | -------------------- |
||
1107 | -- Target of Target Start |
||
1108 | function Perl_TargetTargetDropDown_OnLoad() |
||
1109 | UIDropDownMenu_Initialize(this, Perl_TargetTargetDropDown_Initialize, "MENU"); |
||
1110 | end |
||
1111 | |||
1112 | function Perl_TargetTargetDropDown_Initialize() |
||
1113 | local menu = nil; |
||
1114 | if (UnitIsEnemy("targettarget", "player")) then |
||
1115 | return; |
||
1116 | end |
||
1117 | if (UnitIsUnit("targettarget", "player")) then |
||
1118 | menu = "SELF"; |
||
1119 | elseif (UnitIsUnit("targettarget", "pet")) then |
||
1120 | menu = "PET"; |
||
1121 | elseif (UnitIsPlayer("targettarget")) then |
||
1122 | if (UnitInParty("targettarget")) then |
||
1123 | menu = "PARTY"; |
||
1124 | else |
||
1125 | menu = "PLAYER"; |
||
1126 | end |
||
1127 | end |
||
1128 | if (menu) then |
||
1129 | UnitPopup_ShowMenu(Perl_Target_Target_DropDown, menu, "targettarget"); |
||
1130 | end |
||
1131 | end |
||
1132 | |||
1133 | function Perl_Target_Target_MouseClick(button) |
||
1134 | if (SpellIsTargeting() and button == "RightButton") then |
||
1135 | SpellStopTargeting(); |
||
1136 | return; |
||
1137 | end |
||
1138 | |||
1139 | if (button == "LeftButton") then |
||
1140 | if (SpellIsTargeting()) then |
||
1141 | SpellTargetUnit("targettarget"); |
||
1142 | elseif (CursorHasItem()) then |
||
1143 | DropItemOnUnit("targettarget"); |
||
1144 | else |
||
1145 | TargetUnit("targettarget"); |
||
1146 | end |
||
1147 | end |
||
1148 | end |
||
1149 | |||
1150 | function Perl_Target_Target_MouseDown(button) |
||
1151 | if (button == "LeftButton" and locked == 0) then |
||
1152 | Perl_Target_Target_Frame:StartMoving(); |
||
1153 | end |
||
1154 | end |
||
1155 | |||
1156 | function Perl_Target_Target_MouseUp(button) |
||
1157 | if (button == "RightButton") then |
||
1158 | if (not (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown())) then -- if alt, ctrl, or shift ARE NOT held, show the menu |
||
1159 | ToggleDropDownMenu(1, nil, Perl_Target_Target_DropDown, "Perl_Target_Target_NameFrame", 40, 0); |
||
1160 | end |
||
1161 | end |
||
1162 | |||
1163 | Perl_Target_Target_Frame:StopMovingOrSizing(); |
||
1164 | end |
||
1165 | -- Target of Target End |
||
1166 | |||
1167 | -- Target of Target of Target Start |
||
1168 | function Perl_TargetTargetTargetDropDown_OnLoad() |
||
1169 | UIDropDownMenu_Initialize(this, Perl_TargetTargetTargetDropDown_Initialize, "MENU"); |
||
1170 | end |
||
1171 | |||
1172 | function Perl_TargetTargetTargetDropDown_Initialize() |
||
1173 | local menu = nil; |
||
1174 | if (UnitIsEnemy("targettargettarget", "player")) then |
||
1175 | return; |
||
1176 | end |
||
1177 | if (UnitIsUnit("targettargettarget", "player")) then |
||
1178 | menu = "SELF"; |
||
1179 | elseif (UnitIsUnit("targettargettarget", "pet")) then |
||
1180 | menu = "PET"; |
||
1181 | elseif (UnitIsPlayer("targettargettarget")) then |
||
1182 | if (UnitInParty("targettargettarget")) then |
||
1183 | menu = "PARTY"; |
||
1184 | else |
||
1185 | menu = "PLAYER"; |
||
1186 | end |
||
1187 | end |
||
1188 | if (menu) then |
||
1189 | UnitPopup_ShowMenu(Perl_Target_Target_Target_DropDown, menu, "targettargettarget"); |
||
1190 | end |
||
1191 | end |
||
1192 | |||
1193 | function Perl_Target_Target_Target_MouseClick(button) |
||
1194 | if (SpellIsTargeting() and button == "RightButton") then |
||
1195 | SpellStopTargeting(); |
||
1196 | return; |
||
1197 | end |
||
1198 | |||
1199 | if (button == "LeftButton") then |
||
1200 | if (SpellIsTargeting()) then |
||
1201 | SpellTargetUnit("targettargettarget"); |
||
1202 | elseif (CursorHasItem()) then |
||
1203 | DropItemOnUnit("targettargettarget"); |
||
1204 | else |
||
1205 | TargetUnit("targettargettarget"); |
||
1206 | end |
||
1207 | end |
||
1208 | end |
||
1209 | |||
1210 | function Perl_Target_Target_Target_MouseDown(button) |
||
1211 | if (button == "LeftButton" and locked == 0) then |
||
1212 | Perl_Target_Target_Target_Frame:StartMoving(); |
||
1213 | end |
||
1214 | end |
||
1215 | |||
1216 | function Perl_Target_Target_Target_MouseUp(button) |
||
1217 | if (button == "RightButton") then |
||
1218 | if (not (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown())) then -- if alt, ctrl, or shift ARE NOT held, show the menu |
||
1219 | ToggleDropDownMenu(1, nil, Perl_Target_Target_Target_DropDown, "Perl_Target_Target_Target_NameFrame", 40, 0); |
||
1220 | end |
||
1221 | end |
||
1222 | |||
1223 | Perl_Target_Target_Target_Frame:StopMovingOrSizing(); |
||
1224 | end |
||
1225 | -- Target of Target of Target End |
||
1226 | |||
1227 | |||
1228 | ---------------------------- |
||
1229 | -- Big Warning Text Frame -- |
||
1230 | ---------------------------- |
||
1231 | -- Fade in/out frame stuff |
||
1232 | -- Ripped/modified from FadingFrame from Blizzard |
||
1233 | -- Ripped from AggroAlert 1.5 |
||
1234 | |||
1235 | function Perl_Target_Target_BigWarning_OnLoad() |
||
1236 | Perl_Target_Target_BigWarning:Hide(); |
||
1237 | end |
||
1238 | |||
1239 | function Perl_Target_Target_BigWarning_Show(message) |
||
1240 | startTime = GetTime(); |
||
1241 | if (message) then |
||
1242 | Perl_Target_Target_BigWarning_Text:SetText(message); |
||
1243 | end |
||
1244 | Perl_Target_Target_BigWarning:Show(); |
||
1245 | end |
||
1246 | |||
1247 | |||
1248 | function Perl_Target_Target_BigWarning_OnUpdate() |
||
1249 | local elapsed = GetTime() - startTime; |
||
1250 | local fadeInTime = 0.2; |
||
1251 | if (elapsed < fadeInTime) then |
||
1252 | local alpha = (elapsed / fadeInTime); |
||
1253 | Perl_Target_Target_BigWarning:SetAlpha(alpha); |
||
1254 | return; |
||
1255 | end |
||
1256 | local holdTime = 2.5; |
||
1257 | if (elapsed < (fadeInTime + holdTime)) then |
||
1258 | Perl_Target_Target_BigWarning:SetAlpha(1.0); |
||
1259 | return; |
||
1260 | end |
||
1261 | local fadeOutTime = 2; |
||
1262 | if (elapsed < (fadeInTime + holdTime + fadeOutTime)) then |
||
1263 | local alpha = 1.0 - ((elapsed - holdTime - fadeInTime) / fadeOutTime); |
||
1264 | Perl_Target_Target_BigWarning:SetAlpha(alpha); |
||
1265 | return; |
||
1266 | end |
||
1267 | Perl_Target_Target_BigWarning:Hide(); |
||
1268 | end |
||
1269 | |||
1270 | |||
1271 | ------------- |
||
1272 | -- Tooltip -- |
||
1273 | ------------- |
||
1274 | function Perl_Target_Target_Tip() |
||
1275 | UnitFrame_Initialize("targettarget") |
||
1276 | end |
||
1277 | |||
1278 | function Perl_Target_Target_Target_Tip() |
||
1279 | UnitFrame_Initialize("targettargettarget") |
||
1280 | end |
||
1281 | |||
1282 | function UnitFrame_Initialize(unit) -- Hopefully this doesn't break any mods |
||
1283 | this.unit = unit; |
||
1284 | end |
||
1285 | |||
1286 | |||
1287 | ---------------------- |
||
1288 | -- myAddOns Support -- |
||
1289 | ---------------------- |
||
1290 | function Perl_Target_Target_myAddOns_Support() |
||
1291 | -- Register the addon in myAddOns |
||
1292 | if (myAddOnsFrame_Register) then |
||
1293 | local Perl_Target_Target_myAddOns_Details = { |
||
1294 | name = "Perl_Target_Target", |
||
1295 | version = "Version 0.58", |
||
1296 | releaseDate = "April 15, 2006", |
||
1297 | author = "Global", |
||
1298 | email = "global@g-ball.com", |
||
1299 | website = "http://www.curse-gaming.com/mod.php?addid=2257", |
||
1300 | category = MYADDONS_CATEGORY_OTHERS |
||
1301 | }; |
||
1302 | Perl_Target_Target_myAddOns_Help = {}; |
||
1303 | Perl_Target_Target_myAddOns_Help[1] = "/perl"; |
||
1304 | myAddOnsFrame_Register(Perl_Target_Target_myAddOns_Details, Perl_Target_Target_myAddOns_Help); |
||
1305 | end |
||
1306 | end |