vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local XPerl_Party_Pet_Events = {} |
2 | local PartyPetFrames = {} |
||
3 | |||
4 | -- XPerl_Party_Pet_RegisterForPet |
||
5 | local function XPerl_Party_Pet_RegisterForPet() |
||
6 | local reg |
||
7 | for i = 1,4 do |
||
8 | if (UnitExists("partypet"..i)) then |
||
9 | reg = true |
||
10 | end |
||
11 | end |
||
12 | |||
13 | if (reg) then |
||
14 | XPerl_Party_Pet_EventFrame:RegisterEvent("UNIT_FACTION") |
||
15 | XPerl_Party_Pet_EventFrame:RegisterEvent("UNIT_AURA") |
||
16 | XPerl_Party_Pet_EventFrame:RegisterEvent("PARTY_MEMBER_ENABLE") |
||
17 | XPerl_Party_Pet_EventFrame:RegisterEvent("PARTY_MEMBER_DISABLE") |
||
18 | XPerl_Party_Pet_EventFrame:RegisterEvent("UNIT_FLAGS") |
||
19 | XPerl_Party_Pet_EventFrame:RegisterEvent("UNIT_DYNAMIC_FLAGS") |
||
20 | XPerl_RegisterBasics(XPerl_Party_Pet_EventFrame) |
||
21 | XPerl_Party_Pet_EventFrame:Show() -- For OnUpdate |
||
22 | end |
||
23 | end |
||
24 | |||
25 | -- XPerl_Party_Pet_UnregisterForPet |
||
26 | local function XPerl_Party_Pet_UnregisterForPet() |
||
27 | local reg |
||
28 | for i = 1,4 do |
||
29 | if (UnitExists("partypet"..i)) then |
||
30 | reg = true |
||
31 | end |
||
32 | end |
||
33 | |||
34 | if (not reg) then |
||
35 | XPerl_Party_Pet_EventFrame:UnregisterEvent("UNIT_FACTION") |
||
36 | XPerl_Party_Pet_EventFrame:UnregisterEvent("UNIT_AURA") |
||
37 | XPerl_Party_Pet_EventFrame:UnregisterEvent("PARTY_MEMBER_ENABLE") |
||
38 | XPerl_Party_Pet_EventFrame:UnregisterEvent("PARTY_MEMBER_DISABLE") |
||
39 | XPerl_Party_Pet_EventFrame:UnregisterEvent("UNIT_FLAGS") |
||
40 | XPerl_Party_Pet_EventFrame:UnregisterEvent("UNIT_DYNAMIC_FLAGS") |
||
41 | XPerl_UnregisterBasics(XPerl_Party_Pet_EventFrame) |
||
42 | end |
||
43 | end |
||
44 | |||
45 | ---------------------- |
||
46 | -- Loading Function -- |
||
47 | ---------------------- |
||
48 | function XPerl_Party_Pet_OnLoadEvents() |
||
49 | this.time = 0 |
||
50 | XPerl_Party_Pet_EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD") |
||
51 | XPerl_Party_Pet_EventFrame:RegisterEvent("PLAYER_LEAVING_WORLD") |
||
52 | |||
53 | -- Set here to reduce amount of function calls made |
||
54 | XPerl_Party_Pet_EventFrame:SetScript("OnEvent", XPerl_Party_Pet_OnEvent) |
||
55 | XPerl_Party_Pet_EventFrame:SetScript("OnUpdate", XPerl_Party_Pet_OnUpdate) |
||
56 | end |
||
57 | |||
58 | -- XPerl_Party_Pet_OnLoad |
||
59 | function XPerl_Party_Pet_OnLoad() |
||
60 | this.partyunit = "party"..this:GetID() |
||
61 | this.petunit = "partypet"..this:GetID() |
||
62 | |||
63 | PartyPetFrames[this.petunit] = this |
||
64 | |||
65 | XPerl_InitFadeFrame(this) |
||
66 | |||
67 | XPerl_RegisterHighlight(getglobal(this:GetName().."_CastClickOverlay"), 2) |
||
68 | XPerl_RegisterPerlFrames(this, {"NameFrame", "StatsFrame"}) |
||
69 | |||
70 | this.FlashFrames = {getglobal(this:GetName().."_NameFrame"), |
||
71 | getglobal(this:GetName().."_LevelFrame"), |
||
72 | getglobal(this:GetName().."_StatsFrame") } |
||
73 | end |
||
74 | |||
75 | ------------------------- |
||
76 | -- The Update Function -- |
||
77 | ------------------------- |
||
78 | |||
79 | -- XPerl_Party_Pet_CheckPet |
||
80 | -- returns true if full update required (frame shown) |
||
81 | |||
82 | function XPerl_Party_Pet_CheckPet(argFrame) |
||
83 | if (XPerlConfig.ShowPartyPets == 1) then |
||
84 | if (UnitExists(argFrame.partyunit) and UnitExists(argFrame.petunit) and UnitIsConnected(argFrame.petunit) and not UnitIsDead(argFrame.petunit)) then -- and not UnitIsDeadOrGhost(argFrame.partyunit) |
||
85 | if (not argFrame:IsShowing()) then |
||
86 | if (XPerlConfig.ShowPartyRaid == 1 or not UnitInRaid("player")) then |
||
87 | if (XPerlConfig.ShowPartyRaid == 1) then |
||
88 | XPerl_Party_Pet_RegisterForPet() |
||
89 | XPerl_CancelFade(argFrame) |
||
90 | argFrame:Show() |
||
91 | return true |
||
92 | end |
||
93 | end |
||
94 | end |
||
95 | return false |
||
96 | end |
||
97 | end |
||
98 | |||
99 | if (argFrame:IsShowing()) then |
||
100 | XPerl_Party_Pet_UnregisterForPet() |
||
101 | XPerl_StartFade(argFrame) |
||
102 | end |
||
103 | |||
104 | return false |
||
105 | end |
||
106 | |||
107 | -- XPerl_Party_Pet_UpdateName |
||
108 | local function XPerl_Party_Pet_UpdateName(argFrame) |
||
109 | if (argFrame.petunit == nil) then |
||
110 | return |
||
111 | end |
||
112 | |||
113 | local Partypetname = UnitName(argFrame.petunit) |
||
114 | |||
115 | if (Partypetname ~= nil) then |
||
116 | -- Set name |
||
117 | --if (strlen(Partypetname) > 40) then |
||
118 | -- Partypetname = strsub(Partypetname, 1, 39).."..." |
||
119 | --end |
||
120 | if (XPerlConfig.ShowPartyPetNames == 1) then |
||
121 | getglobal(argFrame:GetName().."_NameFrame"):Show() |
||
122 | end |
||
123 | getglobal(argFrame:GetName().."_NameFrameText"):SetText(Partypetname) |
||
124 | |||
125 | if (UnitIsPVP(argFrame.partyunit)) then |
||
126 | getglobal(argFrame:GetName().."_NameFrameText"):SetTextColor(0,1,0) |
||
127 | else |
||
128 | getglobal(argFrame:GetName().."_NameFrameText"):SetTextColor(0.5,0.5,1) |
||
129 | end |
||
130 | end |
||
131 | end |
||
132 | |||
133 | -- XPerl_Party_Pet_UpdateHealth |
||
134 | local function XPerl_Party_Pet_UpdateHealth(argFrame) |
||
135 | local Partypethealth = UnitHealth(argFrame.petunit) |
||
136 | local Partypethealthmax = UnitHealthMax(argFrame.petunit) |
||
137 | |||
138 | local healthPct = Partypethealth / Partypethealthmax |
||
139 | local phealthPct = string.format("%3.0f", healthPct * 100) |
||
140 | |||
141 | getglobal(argFrame:GetName().."_StatsFrame_HealthBar"):SetMinMaxValues(0, Partypethealthmax) |
||
142 | getglobal(argFrame:GetName().."_StatsFrame_HealthBar"):SetValue(Partypethealth) |
||
143 | XPerl_SetSmoothBarColor(getglobal(argFrame:GetName().."_StatsFrame_HealthBar"), healthPct) |
||
144 | |||
145 | if (UnitIsDead(argFrame.petunit)) then |
||
146 | --getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarPercentText"):SetText(XPERL_LOC_DEAD) |
||
147 | --getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarPercentText"):Hide() |
||
148 | XPerl_StartFade(argFrame) |
||
149 | else |
||
150 | local t = getglobal(argFrame:GetName().."_StatsFrame_HealthBarText") |
||
151 | if (XPerlConfig.HealerMode == 1) then |
||
152 | if (XPerlConfig.HealerModeType == 1) then |
||
153 | t:SetText(string.format("%d/%d", Partypethealth - Partypethealthmax, Partypethealthmax)) |
||
154 | else |
||
155 | t:SetText(Partypethealth - Partypethealthmax) |
||
156 | end |
||
157 | else |
||
158 | t:SetText(string.format("%d",(100*(Partypethealth / Partypethealthmax))+0.5).."%") |
||
159 | end |
||
160 | |||
161 | getglobal(argFrame:GetName().."_StatsFrame_HealthBarText"):Show() |
||
162 | end |
||
163 | end |
||
164 | |||
165 | -- XPerl_Party_Pet_UpdateManaType |
||
166 | local function XPerl_Party_Pet_UpdateManaType(argFrame) |
||
167 | local frameName = argFrame:GetName().."_StatsFrame_ManaBar" |
||
168 | XPerl_SetManaBarType(argFrame.petunit, getglobal(frameName), getglobal(frameName.."BG")) |
||
169 | end |
||
170 | |||
171 | -- XPerl_Party_Pet_UpdateMana |
||
172 | local function XPerl_Party_Pet_UpdateMana(argFrame) |
||
173 | local Partypetmana = UnitMana(argFrame.petunit) |
||
174 | local Partypetmanamax = UnitManaMax(argFrame.petunit) |
||
175 | |||
176 | getglobal(argFrame:GetName().."_StatsFrame_ManaBar"):SetMinMaxValues(0, Partypetmanamax) |
||
177 | getglobal(argFrame:GetName().."_StatsFrame_ManaBar"):SetValue(Partypetmana) |
||
178 | |||
179 | pmanaPct = (Partypetmana * 100.0) / Partypetmanamax |
||
180 | pmanaPct = string.format("%3.0f", pmanaPct) |
||
181 | getglobal(argFrame:GetName().."_StatsFrame_ManaBarText"):Show() |
||
182 | if (UnitPowerType(argFrame.petunit) >= 1) then |
||
183 | getglobal(argFrame:GetName().."_StatsFrame_ManaBarText"):SetText(Partypetmana) |
||
184 | else |
||
185 | getglobal(argFrame:GetName().."_StatsFrame_ManaBarText"):SetText(string.format("%d",(100*(Partypetmana / Partypetmanamax))+0.5).."%") |
||
186 | end |
||
187 | if (XPerlConfig.ShowPartyPetPercent == 0) then |
||
188 | getglobal(argFrame:GetName().."_StatsFrame_ManaBarText"):Hide() |
||
189 | end |
||
190 | end |
||
191 | |||
192 | -- XPerl_Party_Pet_UpdateLevel |
||
193 | local function XPerl_Party_Pet_UpdateLevel(argFrame) |
||
194 | local Partypetlevel = UnitLevel(argFrame.petunit) |
||
195 | --local PartypetClassification = UnitClassification(this.petunit) |
||
196 | local color = GetDifficultyColor(Partypetlevel) |
||
197 | |||
198 | getglobal(argFrame:GetName().."_NameFrameLevelText"):SetTextColor(color.r,color.g,color.b) |
||
199 | |||
200 | if (Partypetlevel == 0) then |
||
201 | Partypetlevel = "" |
||
202 | end |
||
203 | getglobal(argFrame:GetName().."_NameFrameLevelText"):SetText(Partypetlevel) |
||
204 | end |
||
205 | |||
206 | -------------------- |
||
207 | -- Buff Functions -- |
||
208 | -------------------- |
||
209 | |||
210 | -- GetBuffButton |
||
211 | local function GetBuffButton(thisFrame, buffnum, debuff, createIfAbsent) |
||
212 | |||
213 | local buffType |
||
214 | if (debuff == 1) then |
||
215 | buffType = "DeBuff" |
||
216 | else |
||
217 | buffType = "Buff" |
||
218 | end |
||
219 | local name = thisFrame:GetName().."_BuffFrame_"..buffType..buffnum |
||
220 | local button = getglobal(name) |
||
221 | |||
222 | if (not button and createIfAbsent) then |
||
223 | button = CreateFrame("Button", name, getglobal(thisFrame:GetName().."_BuffFrame"), "XPerl_"..buffType.."Template") |
||
224 | button:SetID(buffnum) |
||
225 | |||
226 | button:SetHeight(12) |
||
227 | button:SetWidth(12) |
||
228 | |||
229 | if (debuff == 1) then |
||
230 | button:SetScript("OnEnter", XPerl_Party_Pet_SetDeBuffTooltip) |
||
231 | else |
||
232 | button:SetScript("OnEnter", XPerl_Party_Pet_SetBuffTooltip) |
||
233 | end |
||
234 | button:SetScript("OnLeave", XPerl_PlayerTipHide) |
||
235 | |||
236 | button:ClearAllPoints() |
||
237 | if (buffnum == 1) then |
||
238 | if (debuff == 1) then |
||
239 | button:SetPoint("TOPLEFT", 0, -14) |
||
240 | else |
||
241 | button:SetPoint("TOPLEFT", 0, 0) |
||
242 | end |
||
243 | else |
||
244 | local prevButton = getglobal(thisFrame:GetName().."_BuffFrame_"..buffType..(buffnum - 1)) |
||
245 | button:SetPoint("TOPLEFT", prevButton, "TOPRIGHT", 1 + debuff, 0) |
||
246 | end |
||
247 | end |
||
248 | |||
249 | return button |
||
250 | end |
||
251 | |||
252 | -- XPerl_Party_Pet_Buff_UpdateAll |
||
253 | function XPerl_Party_Pet_Buff_UpdateAll(argFrame) |
||
254 | local buffFrame = getglobal(argFrame:GetName().."_BuffFrame") |
||
255 | if (XPerlConfig.ShowPartyPetBuffs == 1) then |
||
256 | if (UnitExists(argFrame.partyunit) and UnitExists(argFrame.petunit)) then |
||
257 | buffFrame:Show() |
||
258 | |||
259 | for buffnum=1,10 do |
||
260 | local buff = XPerl_UnitBuff(argFrame.petunit, buffnum, XPerlConfig.PartyCastableBuffs) |
||
261 | if (buff) then |
||
262 | local button = GetBuffButton(argFrame, buffnum, 0, buff) |
||
263 | local icon = getglobal(button:GetName().."Icon") |
||
264 | icon:SetTexture(buff) |
||
265 | button:Show() |
||
266 | elseif (button) then |
||
267 | local button = getglobal(argFrame:GetName().."_BuffFrame_Buff"..buffnum) |
||
268 | if (button) then |
||
269 | button:Hide() |
||
270 | end |
||
271 | end |
||
272 | end |
||
273 | for buffnum=1,8 do |
||
274 | local buff = XPerl_UnitDebuff(argFrame.petunit, buffnum, XPerlConfig.PartyCurableDebuffs) |
||
275 | if (buff) then |
||
276 | local button = GetBuffButton(argFrame, buffnum, 1, buff) |
||
277 | local icon = getglobal(button:GetName().."Icon") |
||
278 | icon:SetTexture(buff) |
||
279 | button:Show() |
||
280 | elseif (button) then |
||
281 | local button = getglobal(argFrame:GetName().."_BuffFrame_DeBuff"..buffnum) |
||
282 | if (button) then |
||
283 | button:Hide() |
||
284 | end |
||
285 | end |
||
286 | end |
||
287 | else |
||
288 | buffFrame:Hide() |
||
289 | end |
||
290 | else |
||
291 | buffFrame:Hide() |
||
292 | end |
||
293 | |||
294 | XPerl_CheckDebuffs(argFrame.petunit, {getglobal(argFrame:GetName().."_NameFrame"), getglobal(argFrame:GetName().."_StatsFrame")}) |
||
295 | end |
||
296 | |||
297 | function XPerl_Party_Pet_SetBuffTooltip() |
||
298 | local partyid = "partypet"..this:GetParent():GetParent():GetID() |
||
299 | GameTooltip:SetOwner(this,"ANCHOR_BOTTOMRIGHT",30,0) |
||
300 | --GameTooltip:SetUnitBuff(partyid, this:GetID(), XPerlConfig.PartyCastableBuffs) |
||
301 | XPerl_TooltipSetUnitBuff(GameTooltip, partyid, this:GetID(), XPerlConfig.PartyCastableBuffs) |
||
302 | end |
||
303 | function XPerl_Party_Pet_SetDeBuffTooltip() |
||
304 | local partyid = "partypet"..this:GetParent():GetParent():GetID() |
||
305 | GameTooltip:SetOwner(this,"ANCHOR_BOTTOMRIGHT",30,0) |
||
306 | --GameTooltip:SetUnitDebuff(partyid, this:GetID(), XPerlConfig.PartyCurableDebuffs) |
||
307 | XPerl_TooltipSetUnitDebuff(GameTooltip, partyid, this:GetID(), XPerlConfig.PartyCurableDebuffs) |
||
308 | end |
||
309 | |||
310 | function XPerl_Party_Pet_UpdateDisplayAll() |
||
311 | for i,frame in pairs(PartyPetFrames) do |
||
312 | XPerl_Party_Pet_UpdateDisplay(frame) |
||
313 | end |
||
314 | end |
||
315 | |||
316 | function XPerl_Party_Pet_UpdateDisplay(argFrame) |
||
317 | if (XPerl_Party_Pet_CheckPet(argFrame)) then |
||
318 | XPerl_Party_Pet_UpdateName(argFrame) |
||
319 | XPerl_Party_Pet_UpdateHealth(argFrame) |
||
320 | XPerl_Party_Pet_UpdateLevel(argFrame) |
||
321 | XPerl_Party_Pet_UpdateManaType(argFrame) |
||
322 | XPerl_Party_Pet_UpdateMana(argFrame) |
||
323 | XPerl_Party_Pet_UpdateCombat(argFrame) |
||
324 | XPerl_Party_Pet_Buff_UpdateAll(argFrame) |
||
325 | end |
||
326 | end |
||
327 | |||
328 | |||
329 | -------------------- |
||
330 | -- Click Handlers -- |
||
331 | -------------------- |
||
332 | Perl_Party_Pet_FindID = XPerl_Frame_FindID |
||
333 | |||
334 | -- XPerl_Party_Pet_OnClick |
||
335 | function XPerl_Party_Pet_OnClick(button) |
||
336 | local unit = this:GetParent().petunit |
||
337 | if (XPerl_OnClick_Handler(button, unit)) then |
||
338 | return |
||
339 | end |
||
340 | end |
||
341 | |||
342 | -- XPerl_Party_Pet_PlayerTip |
||
343 | function XPerl_Party_Pet_PlayerTip() |
||
344 | local unit = this:GetParent().petunit |
||
345 | if (UnitExists(unit)) then |
||
346 | XPerl_PlayerTip(unit) |
||
347 | end |
||
348 | end |
||
349 | |||
350 | -- XPerl_Party_Pet_Update_Control |
||
351 | local function XPerl_Party_Pet_Update_Control(argFrame) |
||
352 | if (UnitIsVisible(argFrame.petunit) and UnitIsCharmed(argFrame.petunit)) then |
||
353 | getglobal(argFrame:GetName().."_NameFrame_Warning"):Show() |
||
354 | else |
||
355 | getglobal(argFrame:GetName().."_NameFrame_Warning"):Hide() |
||
356 | end |
||
357 | end |
||
358 | |||
359 | -- XPerl_Party_Pet_UpdateCombat |
||
360 | function XPerl_Party_Pet_UpdateCombat(argFrame) |
||
361 | if (UnitExists(argFrame.partyunit) and UnitExists(argFrame.petunit)) then |
||
362 | if (UnitAffectingCombat(argFrame.petunit)) then |
||
363 | getglobal(argFrame:GetName().."_NameFrameLevelText"):Hide() |
||
364 | getglobal(argFrame:GetName().."_NameFrame_ActivityStatus"):Show() |
||
365 | else |
||
366 | getglobal(argFrame:GetName().."_NameFrame_ActivityStatus"):Hide() |
||
367 | getglobal(argFrame:GetName().."_NameFrameLevelText"):Show() |
||
368 | end |
||
369 | XPerl_Party_Pet_Update_Control(argFrame) |
||
370 | end |
||
371 | end |
||
372 | |||
373 | -- XPerl_Party_Pet_CombatFlash |
||
374 | local function XPerl_Party_Pet_CombatFlash(f, elapsed, argNew, argGreen) |
||
375 | if (XPerl_CombatFlashSet (elapsed, f, argNew, argGreen)) then |
||
376 | XPerl_CombatFlashSetFrames(f) |
||
377 | end |
||
378 | end |
||
379 | |||
380 | -- XPerl_Party_Pet_OnUpdate |
||
381 | function XPerl_Party_Pet_OnUpdate() |
||
382 | local any |
||
383 | for i,f in pairs(PartyPetFrames) do |
||
384 | if (f:IsShown()) then |
||
385 | any = true |
||
386 | if (f.PlayerFlash) then |
||
387 | XPerl_Party_Pet_CombatFlash(f, arg1, false) |
||
388 | end |
||
389 | XPerl_ProcessFade(f) |
||
390 | end |
||
391 | end |
||
392 | |||
393 | if (not any) then |
||
394 | XPerl_Party_Pet_EventFrame:Hide() -- Stop processing OnUpdate |
||
395 | end |
||
396 | end |
||
397 | |||
398 | ------------------- |
||
399 | -- Event Handler -- |
||
400 | ------------------- |
||
401 | local function XPerl_Party_Pet_RegisterSome() |
||
402 | XPerl_Party_Pet_EventFrame:RegisterEvent("PARTY_MEMBERS_CHANGED") |
||
403 | XPerl_Party_Pet_EventFrame:RegisterEvent("UNIT_PET") |
||
404 | end |
||
405 | |||
406 | local function XPerl_Party_Pet_UnregisterSome() |
||
407 | XPerl_Party_Pet_EventFrame:UnregisterEvent("PARTY_MEMBERS_CHANGED") |
||
408 | XPerl_Party_Pet_EventFrame:UnregisterEvent("UNIT_PET") |
||
409 | end |
||
410 | |||
411 | -- XPerl_Party_Pet_OnEvent |
||
412 | function XPerl_Party_Pet_OnEvent() |
||
413 | local func = XPerl_Party_Pet_Events[event] |
||
414 | if (func) then |
||
415 | func() |
||
416 | else |
||
417 | XPerl_ShowMessage("EXTRA EVENT") |
||
418 | end |
||
419 | end |
||
420 | |||
421 | -- PLAYER_ENTERING_WORLD |
||
422 | function XPerl_Party_Pet_Events:PLAYER_ENTERING_WORLD() |
||
423 | XPerl_Party_Pet_RegisterSome() |
||
424 | XPerl_Party_Pet_UpdateDisplayAll() |
||
425 | end |
||
426 | |||
427 | -- PLAYER_LEAVING_WORLD |
||
428 | function XPerl_Party_Pet_Events:PLAYER_LEAVING_WORLD() |
||
429 | XPerl_Party_Pet_UnregisterSome() |
||
430 | end |
||
431 | |||
432 | -- PARTY_MEMBERS_CHANGED |
||
433 | function XPerl_Party_Pet_Events:PARTY_MEMBERS_CHANGED() |
||
434 | XPerl_Party_Pet_UpdateDisplayAll() |
||
435 | end |
||
436 | |||
437 | -- UNIT_FLAGS |
||
438 | function XPerl_Party_Pet_Events:UNIT_FLAGS() |
||
439 | local f = PartyPetFrames[arg1] |
||
440 | if (f) then XPerl_Party_Pet_UpdateCombat(f) end |
||
441 | end |
||
442 | |||
443 | XPerl_Party_Pet_Events.UNIT_DYNAMIC_FLAGS = XPerl_Party_Pet_Events.PARTY_MEMBERS_CHANGED |
||
444 | |||
445 | -- UNIT_COMBAT |
||
446 | function XPerl_Party_Pet_Events:UNIT_COMBAT() |
||
447 | local f = PartyPetFrames[arg1] |
||
448 | if (f) then |
||
449 | if (arg2 == "HEAL") then |
||
450 | XPerl_Party_Pet_CombatFlash(f, 0, true, true) |
||
451 | elseif (arg4 and arg4 > 0) then |
||
452 | XPerl_Party_Pet_CombatFlash(f, 0, true) |
||
453 | end |
||
454 | end |
||
455 | end |
||
456 | |||
457 | -- UNIT_PET |
||
458 | function XPerl_Party_Pet_Events:UNIT_PET() |
||
459 | local petid = strfind(arg1, "party(%d)") |
||
460 | if (petid) then |
||
461 | local f = PartyPetFrames["partypet"..petid] |
||
462 | if (f) then |
||
463 | XPerl_Party_Pet_UpdateDisplay(f) |
||
464 | end |
||
465 | end |
||
466 | end |
||
467 | |||
468 | -- PARTY_MEMBER_ENABLE |
||
469 | function XPerl_Party_Pet_Events:PARTY_MEMBER_ENABLE() |
||
470 | local petid = strfind(arg1, "party(%d)") |
||
471 | if (petid) then |
||
472 | local f = PartyPetFrames["partypet"..petid] |
||
473 | if (f) then XPerl_Party_Pet_UpdateDisplay(f) end |
||
474 | end |
||
475 | end |
||
476 | XPerl_Party_Pet_Events.PARTY_MEMBER_DISABLE = XPerl_Party_Pet_Events.PARTY_MEMBER_ENABLE |
||
477 | |||
478 | -- UNIT_NAME_UPDATE |
||
479 | function XPerl_Party_Pet_Events:UNIT_NAME_UPDATE() |
||
480 | local f = PartyPetFrames[arg1] |
||
481 | if (f) then XPerl_Party_Pet_UpdateName(f) end |
||
482 | end |
||
483 | |||
484 | -- UNIT_FACTION |
||
485 | function XPerl_Party_Pet_Events:UNIT_FACTION() |
||
486 | local f = PartyPetFrames[arg1] |
||
487 | if (f) then |
||
488 | XPerl_Party_Pet_UpdateName(f) |
||
489 | XPerl_Party_Pet_UpdateCombat(f) |
||
490 | end |
||
491 | end |
||
492 | |||
493 | -- UNIT_LEVEL |
||
494 | function XPerl_Party_Pet_Events:UNIT_LEVEL() |
||
495 | local f = PartyPetFrames[arg1] |
||
496 | if (f) then XPerl_Party_Pet_UpdateLevel(f) end |
||
497 | end |
||
498 | |||
499 | -- UNIT_HEALTH |
||
500 | function XPerl_Party_Pet_Events:UNIT_HEALTH() |
||
501 | local f = PartyPetFrames[arg1] |
||
502 | if (f) then XPerl_Party_Pet_UpdateHealth(f) end |
||
503 | end |
||
504 | |||
505 | -- UNIT_MAXHEALTH |
||
506 | function XPerl_Party_Pet_Events:UNIT_MAXHEALTH() |
||
507 | local f = PartyPetFrames[arg1] |
||
508 | if (f) then |
||
509 | XPerl_Party_Pet_UpdateHealth(f) |
||
510 | XPerl_Party_Pet_UpdateLevel(f) |
||
511 | end |
||
512 | end |
||
513 | |||
514 | -- UNIT_AURA |
||
515 | function XPerl_Party_Pet_Events:UNIT_AURA() |
||
516 | local f = PartyPetFrames[arg1] |
||
517 | if (f) then XPerl_Party_Pet_Buff_UpdateAll(f) end |
||
518 | end |
||
519 | |||
520 | -- UNIT_DISPLAYPOWER |
||
521 | function XPerl_Party_Pet_Events:UNIT_DISPLAYPOWER() |
||
522 | local f = PartyPetFrames[arg1] |
||
523 | if (f) then XPerl_Party_Pet_UpdateManaType(f) end |
||
524 | end |
||
525 | |||
526 | -- UNIT_MANA |
||
527 | function XPerl_Party_Pet_Events:UNIT_MANA() |
||
528 | local f = PartyPetFrames[arg1] |
||
529 | if (f) then XPerl_Party_Pet_UpdateMana(f) end |
||
530 | end |
||
531 | |||
532 | XPerl_Party_Pet_Events.UNIT_MAXMANA = XPerl_Party_Pet_Events.UNIT_MANA |
||
533 | XPerl_Party_Pet_Events.UNIT_RAGE = XPerl_Party_Pet_Events.UNIT_MANA |
||
534 | XPerl_Party_Pet_Events.UNIT_MAXRAGE = XPerl_Party_Pet_Events.UNIT_MANA |
||
535 | XPerl_Party_Pet_Events.UNIT_FOCUS = XPerl_Party_Pet_Events.UNIT_MANA |
||
536 | XPerl_Party_Pet_Events.UNIT_MAXFOCUS = XPerl_Party_Pet_Events.UNIT_MANA |
||
537 | XPerl_Party_Pet_Events.UNIT_ENERGY = XPerl_Party_Pet_Events.UNIT_MANA |
||
538 | XPerl_Party_Pet_Events.UNIT_MAXENERGY = XPerl_Party_Pet_Events.UNIT_MANA |
||
539 | |||
540 | -- XPerl_Party_Pet_Set_Name |
||
541 | function XPerl_Party_Pet_Set_Name() |
||
542 | for i,frame in pairs(PartyPetFrames) do |
||
543 | local f = getglobal(frame:GetName().."_NameFrame") |
||
544 | if (XPerlConfig.ShowPartyPetName == 1) then |
||
545 | f:Show() |
||
546 | f:SetHeight(24) |
||
547 | else |
||
548 | f:Hide() |
||
549 | f:SetHeight(3) |
||
550 | end |
||
551 | |||
552 | XPerl_Party_Pet_Buff_UpdateAll(frame) |
||
553 | end |
||
554 | end |
||
555 | |||
556 | -- XPerl_ScalePartyPets(num) |
||
557 | function XPerl_ScalePartyPets(num) |
||
558 | XPerl_partypet4:SetScale(num) |
||
559 | XPerl_partypet3:SetScale(num) |
||
560 | XPerl_partypet2:SetScale(num) |
||
561 | XPerl_partypet1:SetScale(num) |
||
562 | end |