vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local util = Utility_Class:New() |
2 | |||
3 | FBEventHandlers["VARIABLES_LOADED"] = |
||
4 | function(event) |
||
5 | -- Saved Variables available here |
||
6 | -- Convert from old individual global options to a table. |
||
7 | if FBFirstUse then FBToggles["firstuse"] = FBFirstUse end |
||
8 | if FBVerbose then FBToggles["verbose"] = FBVerbose end |
||
9 | if FBNoTooltips then FBToggles["notooltips"] = FBNoTooltips end |
||
10 | if FBSafeLoad then FBToggles["loadtype"] = "safe" end |
||
11 | if FBFastLoad then FBToggles["loadtype"] = "fast" end |
||
12 | if not FBToggles["loadtype"] then FBToggles["loadtype"] = "std" end |
||
13 | if not FBToggles["dropdown"] then FBToggles["dropdown"] = 5 end |
||
14 | if not FBToggles["tooltipinfocolor"] then FBToggles["tooltipinfocolor"] = { r=1, g=1, b=1 } end |
||
15 | |||
16 | if FBToggles["firstuse"] == 0 then |
||
17 | FlexBar_LoadDefaults(); |
||
18 | end |
||
19 | util:Print(format("FlexBar V%.3f loaded. Type /flexbar for usage", FlexBarVersion)); |
||
20 | FBLoadProfileDialog:Hide() |
||
21 | if FBToggles["loadtype"] == "safe" then |
||
22 | LoadProfileButton:Show() |
||
23 | end |
||
24 | end |
||
25 | |||
26 | FBEventHandlers["PLAYER_ENTERING_WORLD"] = |
||
27 | function() |
||
28 | -- moved profile load timer here to avoid setting group bounds while GetRight etc return bad values |
||
29 | -- if profile already loaded, return. |
||
30 | if FBProfileLoaded then return end |
||
31 | -- localize strings |
||
32 | FBLocalize() |
||
33 | local delay=10 |
||
34 | if FBToggles["loadtype"] == "fast" then |
||
35 | delay=1 |
||
36 | end |
||
37 | FBTimers["loadprofile"] = Timer_Class:New(delay, nil, |
||
38 | "Flexbar settings loading", nil, FB_LoadProfile) |
||
39 | end |
||
40 | |||
41 | FBEventHandlers["PLAYER_ENTER_COMBAT"] = |
||
42 | function(event) |
||
43 | -- self explanatory - raise event for player initiating auto-attack |
||
44 | if not FBProfileLoaded then return end |
||
45 | if FBEventToggles["meleecheck"] == "off" then return end |
||
46 | FB_RaiseEvent("EnterCombat") |
||
47 | FBConditionalState["incombat"] = true |
||
48 | end |
||
49 | |||
50 | FBEventHandlers["PLAYER_LEAVE_COMBAT"] = |
||
51 | function(event) |
||
52 | -- raise event for player turning autoattack off |
||
53 | if not FBProfileLoaded then return end |
||
54 | if FBEventToggles["meleecheck"] == "off" then return end |
||
55 | FB_RaiseEvent("LeaveCombat") |
||
56 | FBConditionalState["incombat"] = nil |
||
57 | end |
||
58 | |||
59 | FBEventHandlers["PLAYER_REGEN_ENABLED"] = |
||
60 | function(event) |
||
61 | -- raise event for lose aggro (which is when regen is re-enabled) |
||
62 | if not FBProfileLoaded then return end |
||
63 | if FBEventToggles["aggrocheck"] == "off" then return end |
||
64 | FB_RaiseEvent("LoseAggro") |
||
65 | FBConditionalState["hasaggro"] = nil |
||
66 | end |
||
67 | |||
68 | FBEventHandlers["PLAYER_REGEN_DISABLED"] = |
||
69 | function(event) |
||
70 | -- raise event for gain aggro (player regen is disabled when you have aggro) |
||
71 | if not FBProfileLoaded then return end |
||
72 | if FBEventToggles["aggrocheck"] == "off" then return end |
||
73 | FB_RaiseEvent("GainAggro") |
||
74 | FBConditionalState["hasaggro"] = true |
||
75 | end |
||
76 | |||
77 | local nonraidunits = { |
||
78 | ["player"] = true, |
||
79 | ["party1"] = true, |
||
80 | ["party2"] = true, |
||
81 | ["party3"] = true, |
||
82 | ["party4"] = true, |
||
83 | ["pet"] = true, |
||
84 | ["partypet1"] = true, |
||
85 | ["partypet2"] = true, |
||
86 | ["partypet3"] = true, |
||
87 | ["partypet4"] = true, |
||
88 | ["target"] = true, |
||
89 | } |
||
90 | FBEventHandlers["UNIT_AURA"] = |
||
91 | function(event) |
||
92 | -- lost/gain buff - raise event. Note, losing buffs to dieing doesn't trigger this. |
||
93 | -- also, some forms do not trigger this when they fade apparently |
||
94 | if FBToggles["raidsafe"] and not nonraidunits[arg1] then return end |
||
95 | FB_CheckAllBuffs(arg1) |
||
96 | if arg1 == "pet" then FB_MimicPetButtons() end |
||
97 | end |
||
98 | |||
99 | FBEventHandlers["CHAT_MSG_COMBAT_SELF_MISSES"] = |
||
100 | function(event) |
||
101 | -- pretty sure all these are right - if anyone has trouble getting the right reactions I'll revisit |
||
102 | if not FBProfileLoaded then return end |
||
103 | if FBEventToggles["missevents"] == "off" then return end |
||
104 | if strfind(arg1, "dodges") then |
||
105 | FB_RaiseEvent("PlayerMiss", "dodge") |
||
106 | elseif strfind(arg1, "parries") then |
||
107 | FB_RaiseEvent("PlayerMiss", "parry") |
||
108 | elseif strfind(arg1, "blocks") then |
||
109 | FB_RaiseEvent("PlayerMiss", "block") |
||
110 | else |
||
111 | FB_RaiseEvent("PlayerMiss", "miss") |
||
112 | end |
||
113 | end |
||
114 | |||
115 | FBEventHandlers["CHAT_MSG_SPELL_SELF_DAMAGE"] = |
||
116 | function(event) |
||
117 | -- pretty sure all these are right - if anyone has trouble getting the right reactions I'll revisit |
||
118 | if not FBProfileLoaded then return end |
||
119 | if FBEventToggles["missevents"] == "off" then return end |
||
120 | if strfind(arg1, "was dodged") then |
||
121 | FB_RaiseEvent("PlayerMiss", "dodge") |
||
122 | elseif strfind(arg1, "parries") then |
||
123 | FB_RaiseEvent("PlayerMiss", "parry") |
||
124 | elseif strfind(arg1, "blocks") then |
||
125 | FB_RaiseEvent("PlayerMiss", "block") |
||
126 | else |
||
127 | FB_RaiseEvent("PlayerMiss", "miss") |
||
128 | end |
||
129 | end |
||
130 | |||
131 | FBEventHandlers["CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES"] = |
||
132 | function(event) |
||
133 | -- Same as above |
||
134 | if not FBProfileLoaded then return end |
||
135 | if FBEventToggles["missevents"] == "off" then return end |
||
136 | if strfind(arg1, "dodge") then |
||
137 | FB_RaiseEvent("TargetMiss", "dodge") |
||
138 | elseif strfind(arg1, "parry") then |
||
139 | FB_RaiseEvent("TargetMiss", "parry") |
||
140 | elseif strfind(arg1, "block") then |
||
141 | FB_RaiseEvent("TargetMiss", "block") |
||
142 | else |
||
143 | FB_RaiseEvent("TargetMiss", "miss") |
||
144 | end |
||
145 | end |
||
146 | |||
147 | FBEventHandlers["UNIT_HEALTH"] = |
||
148 | function(event) |
||
149 | -- raise events for the health of available unit codes dropping by 10% increments, and |
||
150 | -- climbing by the same increments. Available units are player, party1-party4, pet, target, mouseover |
||
151 | if FBToggles["raidsafe"] and not nonraidunits[arg1] then return end |
||
152 | if not FBProfileLoaded then return end |
||
153 | if FBEventToggles["healthevents"] == "off" then return end |
||
154 | local list = FBEventToggleInfo["healthevents"][FBEventToggles["healthevents"].."list"] |
||
155 | if FBEventToggles["healthevents"] == "low" and not list[arg1] then return end |
||
156 | FB_CheckTextSub() |
||
157 | local hppercent = UnitHealth(arg1)/UnitHealthMax(arg1) * 100 |
||
158 | if FBLastHealth[arg1] then |
||
159 | local index |
||
160 | for index = 100, 10, -10 do |
||
161 | if FBLastHealth[arg1] >= index and hppercent < index then |
||
162 | FB_RaiseEvent("HealthBelow" .. index, arg1) |
||
163 | end |
||
164 | end |
||
165 | for index = 10, 90, 10 do |
||
166 | if FBLastHealth[arg1] <= index and hppercent > index then |
||
167 | FB_RaiseEvent("HealthAbove" .. index, arg1) |
||
168 | end |
||
169 | end |
||
170 | if FBLastHealth[arg1] <=99 and hppercent > 99 then |
||
171 | FB_RaiseEvent("HealthFull", arg1) |
||
172 | end |
||
173 | end |
||
174 | FBLastHealth[arg1] = hppercent |
||
175 | end |
||
176 | |||
177 | FBEventHandlers["UNIT_MANA"] = |
||
178 | function(event) |
||
179 | -- raise events for the health of available unit codes dropping by 10% increments, and |
||
180 | -- climbing by the same increments. Available units are player, party1-party4, pet, target, mouseover |
||
181 | if FBToggles["raidsafe"] and not nonraidunits[arg1] then return end |
||
182 | if not FBProfileLoaded then return end |
||
183 | if FBEventToggles["manaevents"] == "off" then return end |
||
184 | local list = FBEventToggleInfo["manaevents"][FBEventToggles["manaevents"].."list"] |
||
185 | if FBEventToggles["manaevents"] == "low" and not list[arg1] then return end |
||
186 | FB_CheckTextSub() |
||
187 | local manapercent = UnitMana(arg1)/UnitManaMax(arg1) * 100 |
||
188 | if FBLastMana[arg1] then |
||
189 | local index |
||
190 | for index = 100, 10, -10 do |
||
191 | if FBLastMana[arg1] >= index and manapercent < index then |
||
192 | FB_RaiseEvent("ManaBelow" .. index, arg1) |
||
193 | end |
||
194 | end |
||
195 | for index = 10, 90, 10 do |
||
196 | if FBLastMana[arg1] <= index and manapercent > index then |
||
197 | FB_RaiseEvent("ManaAbove" .. index, arg1) |
||
198 | end |
||
199 | end |
||
200 | if FBLastMana[arg1] <=99 and manapercent > 99 then |
||
201 | FB_RaiseEvent("ManaFull", arg1) |
||
202 | end |
||
203 | end |
||
204 | FBLastMana[arg1] = manapercent |
||
205 | end |
||
206 | |||
207 | FBEventHandlers["UNIT_RAGE"] = FBEventHandlers["UNIT_MANA"] |
||
208 | FBEventHandlers["UNIT_ENERGY"] = FBEventHandlers["UNIT_MANA"] |
||
209 | |||
210 | FBEventHandlers["ACTIONBAR_PAGE_CHANGED"] = |
||
211 | function(event) |
||
212 | -- Action bar changed - allows syncing group to action bar |
||
213 | if not FBProfileLoaded then return end |
||
214 | if FBEventToggles["actionbarpage"] == "off" then return end |
||
215 | FB_RaiseEvent("ActionBarPage", CURRENT_ACTIONBAR_PAGE) |
||
216 | end |
||
217 | |||
218 | FBEventHandlers["SPELLS_CHANGED"] = |
||
219 | function(event) |
||
220 | -- Reload spell info on spells changing |
||
221 | FB_GetSpellInfo() |
||
222 | end |
||
223 | |||
224 | FBEventHandlers["PLAYER_COMBO_POINTS"] = |
||
225 | function(event) |
||
226 | -- Raise event for a change in combo points |
||
227 | if not FBProfileLoaded then return end |
||
228 | FB_CheckTextSub() |
||
229 | if FBEventToggles["comboevents"] == "off" then return end |
||
230 | FB_RaiseEvent("ComboPoints",GetComboPoints()) |
||
231 | end |
||
232 | |||
233 | FBEventHandlers["PLAYER_GAINED_CONTROL"] = |
||
234 | function(event) |
||
235 | -- my tester for Gained Control - hopefully can use for fear etc.. |
||
236 | if not FBScripts[event] then FBScripts[event] = "" end |
||
237 | arg1 = tostring(arg1) |
||
238 | arg2 = tostring(arg2) |
||
239 | arg3 = tostring(arg3) |
||
240 | arg4 = tostring(arg4) |
||
241 | arg5 = tostring(arg5) |
||
242 | local text = GetTime () .. ": arg1=%s;arg2=%s;arg3=%s;arg4=%s;arg5=%s\n" |
||
243 | FBScripts[event] = FBScripts[event] .. text |
||
244 | end |
||
245 | |||
246 | FBEventHandlers["PLAYER_LOST_CONTROL"] = |
||
247 | function(event) |
||
248 | -- my tester for Lost Control - hopefully can use for fear etc.. |
||
249 | if not FBScripts[event] then FBScripts[event] = "" end |
||
250 | arg1 = tostring(arg1) |
||
251 | arg2 = tostring(arg2) |
||
252 | arg3 = tostring(arg3) |
||
253 | arg4 = tostring(arg4) |
||
254 | arg5 = tostring(arg5) |
||
255 | local text = GetTime () .. ": arg1=%s;arg2=%s;arg3=%s;arg4=%s;arg5=%s\n" |
||
256 | FBScripts[event] = FBScripts[event] .. text |
||
257 | end |
||
258 | |||
259 | FBEventHandlers["BAG_UPDATE"] = |
||
260 | function(event) |
||
261 | -- Raise event for bag contents changing |
||
262 | if not FBProfileLoaded then return end |
||
263 | FB_CheckAutoItems() |
||
264 | if FBAutoItemsFrame:IsVisible() then |
||
265 | FB_DisplayAutoItems() |
||
266 | end |
||
267 | FB_CheckTextSub() |
||
268 | end |
||
269 | |||
270 | FBEventHandlers["UNIT_INVENTORY_CHANGED"] = |
||
271 | function(event) |
||
272 | if not FBProfileLoaded then return end |
||
273 | FB_CheckAutoItems() |
||
274 | if FBAutoItemsFrame:IsVisible() then |
||
275 | FB_DisplayAutoItems() |
||
276 | end |
||
277 | end |
||
278 | |||
279 | FBEventHandlers["UPDATE_INVENTORY_ALERTS"] = |
||
280 | function(event) |
||
281 | if not FBProfileLoaded then return end |
||
282 | FB_CheckAutoItems() |
||
283 | if FBAutoItemsFrame:IsVisible() then |
||
284 | FB_DisplayAutoItems() |
||
285 | end |
||
286 | end |
||
287 | |||
288 | FBEventHandlers["ACTIONBAR_SLOT_CHANGED"] = |
||
289 | function(event) |
||
290 | if not FBProfileLoaded then return end |
||
291 | FB_CheckAutoItems() |
||
292 | if FBAutoItemsFrame:IsVisible() then |
||
293 | FB_DisplayAutoItems() |
||
294 | end |
||
295 | end |
||
296 | |||
297 | FBEventHandlers["MERCHANT_CLOSED"] = |
||
298 | function(event) |
||
299 | if not FBProfileLoaded then return end |
||
300 | FB_CheckAutoItems() |
||
301 | if FBAutoItemsFrame:IsVisible() then |
||
302 | FB_DisplayAutoItems() |
||
303 | end |
||
304 | end |
||
305 | |||
306 | FBEventHandlers["MERCHANT_UPDATE"] = |
||
307 | function(event) |
||
308 | if not FBProfileLoaded then return end |
||
309 | FB_CheckAutoItems() |
||
310 | if FBAutoItemsFrame:IsVisible() then |
||
311 | FB_DisplayAutoItems() |
||
312 | end |
||
313 | end |
||
314 | |||
315 | FBEventHandlers["UNIT_COMBAT"] = |
||
316 | function(event) |
||
317 | -- Combat events - replace miss events |
||
318 | if FBToggles["raidsafe"] and not nonraidunits[arg1] then return end |
||
319 | if not FBProfileLoaded then return end |
||
320 | if FBEventToggles["combatevents"] == "off" then return end |
||
321 | -- only raise/check player/target |
||
322 | if arg1 ~= "player" and arg1 ~= "target" then return end |
||
323 | if arg3 ~= "" then |
||
324 | FB_RaiseEvent(arg1.."Combat",tostring(arg3)) |
||
325 | FBCombatTypes["'"..string.lower(arg3).."'"] = true |
||
326 | else |
||
327 | FB_RaiseEvent(arg1.."Combat",tostring(arg2)) |
||
328 | FBCombatTypes["'"..string.lower(arg2).."'"] = true |
||
329 | end |
||
330 | end |
||
331 | |||
332 | FBEventHandlers["PLAYER_TARGET_CHANGED"] = |
||
333 | function(event) |
||
334 | -- Raise target changed events |
||
335 | -- When UnitName("target") is nil we lost the old target |
||
336 | -- when UnitName("target") is not nil we gained a new target |
||
337 | -- arg1 contains the GetTime() * 1000 when we gain a target, nil otherwise |
||
338 | --(DJE 8/16/05) Function altered to fix Duel targets being concidered friendly |
||
339 | --(DJE 8/16/05) It would apear that WoW conciders Duel targets BOTH friendly and hostile |
||
340 | --(DJE 8/16/05) I think that in every case hostility would be more of a concern than friendliness |
||
341 | --(DJE 8/16/05) So the order of the checks were swaped |
||
342 | FBLastTargetTarget = nil |
||
343 | FBLastTargetTargetName = nil |
||
344 | if not FBProfileLoaded then return end |
||
345 | if FBEventToggles["targetcheck"] == "off" then return end |
||
346 | |||
347 | local name = UnitName("target") |
||
348 | local reaction |
||
349 | if name then |
||
350 | --Order of checking hostile and friendly switched (DJE 8/16/05) |
||
351 | if UnitIsEnemy("player","target") then |
||
352 | reaction = "hostile" |
||
353 | elseif UnitIsFriend("player","target") then |
||
354 | reaction = "friendly" |
||
355 | else |
||
356 | reaction = "neutral" |
||
357 | end |
||
358 | FB_RaiseEvent("GainTarget", reaction) |
||
359 | -- FBTimers["targettarget"]:Start() |
||
360 | else |
||
361 | FB_RaiseEvent("LostTarget", reaction) |
||
362 | -- FBTimers["targettarget"]:Pause() |
||
363 | end |
||
364 | end |
||
365 | |||
366 | FBEventHandlers["UNIT_PET"] = |
||
367 | function(event) |
||
368 | -- raise events for party/raid members getting pets |
||
369 | if FBToggles["raidsafe"] and not nonraidunits[arg1] then return end |
||
370 | if not FBProfileLoaded then return end |
||
371 | if arg1 == "target" or arg1 == "mouseover" or arg1 == "npc" or arg1 == "NPC" then return end |
||
372 | if FBEventToggles["petcheck"] == "off" then return end |
||
373 | if not strfind(arg1,"pet") then -- this event fires 3 times on a pet summon, 2 times with pet and once with player |
||
374 | local _,_,base,num = string.find(arg1,"(%a+)(%d+)") |
||
375 | local pet |
||
376 | if arg1 == "player" then |
||
377 | pet = "pet" |
||
378 | else |
||
379 | pet = base .. "pet" .. num |
||
380 | end |
||
381 | -- raise the event after a small delay to let UnitCreatureFamily return right info |
||
382 | FBTimers["petcheck"..GetTime()] = |
||
383 | Timer_Class:New(.5,false,nil,nil,function() FB_CheckPets(pet) end) |
||
384 | end |
||
385 | end |
||
386 | |||
387 | FBEventHandlers["UNIT_FLAGS"] = |
||
388 | function(event) |
||
389 | -- change pet buttons |
||
390 | if arg1 ~= "pet" then return end |
||
391 | FB_MimicPetButtons() |
||
392 | end |
||
393 | |||
394 | FBEventHandlers["PET_BAR_UPDATE"] = |
||
395 | function(event) |
||
396 | -- change pet buttons |
||
397 | FB_MimicPetButtons() |
||
398 | end |
||
399 | |||
400 | FBEventHandlers["PET_BAR_UPDATE_COOLDOWN"] = |
||
401 | function(event) |
||
402 | -- change pet buttons |
||
403 | FB_MimicPetButtons() |
||
404 | end |
||
405 | |||
406 | FBEventHandlers["PARTY_MEMBERS_CHANGED"] = |
||
407 | function(event) |
||
408 | -- Check for different party members |
||
409 | if not FBProfileLoaded then return end |
||
410 | if FBEventToggles["groupcheck"] == "off" then return end |
||
411 | local index, value, list |
||
412 | list = FBEventToggleInfo["groupcheck"][FBEventToggles["groupcheck"] .."list"] |
||
413 | if not list then return end |
||
414 | for index, value in pairs(list) do |
||
415 | local name = UnitName(index) |
||
416 | if name and not FBGroupmates[index] then |
||
417 | FB_RaiseEvent("GainPartymate", index) |
||
418 | end |
||
419 | if not name and FBGroupmates[index] then |
||
420 | FB_RaiseEvent("LosePartyMate", index) |
||
421 | end |
||
422 | |||
423 | FBGroupmates[index] = name |
||
424 | end |
||
425 | end |
||
426 | |||
427 | FBEventHandlers["PLAYER_AURAS_CHANGED"] = |
||
428 | function(event) |
||
429 | -- check new aura |
||
430 | local form = "none" |
||
431 | if FBLastform then |
||
432 | local index |
||
433 | for index = 1, GetNumShapeshiftForms() do |
||
434 | local _, name, active = GetShapeshiftFormInfo(index) |
||
435 | if active then |
||
436 | form = name |
||
437 | break |
||
438 | end |
||
439 | end |
||
440 | end |
||
441 | if FBLastform ~= form then |
||
442 | if FBLastform ~= "none" then |
||
443 | FB_RaiseEvent("LoseAura", FBLastform) |
||
444 | end |
||
445 | if form ~= "none" then |
||
446 | FB_RaiseEvent("GainAura", form) |
||
447 | FBBuffs["auras"]["'"..form.."'"] = true |
||
448 | end |
||
449 | end |
||
450 | FBLastform = form |
||
451 | -- Shirtan doing tracking events..... |
||
452 | if not (GetTrackingTexture() == nil) then |
||
453 | tracking = GetTrackingTexture() |
||
454 | if not (tracking == FBLastTracking) then |
||
455 | FBLastTracking=tracking |
||
456 | for k,v in pairs (FBTrackingList) do |
||
457 | if ( tracking == v) then |
||
458 | FB_RaiseEvent("trackingchanged", k) |
||
459 | break |
||
460 | end |
||
461 | end |
||
462 | end |
||
463 | else |
||
464 | if not (tracking == FBLastTracking) then |
||
465 | FBLastTracking=tracking |
||
466 | FB_RaiseEvent("trackingchanged", "none") |
||
467 | end |
||
468 | end |
||
469 | -- /Tracking events. |
||
470 | end |
||
471 | |||
472 | FBEventHandlers["some event"] = |
||
473 | function(event) |
||
474 | -- my tester for new events to see what I have to work with. |
||
475 | util:Print(event) |
||
476 | util:Print(arg1) |
||
477 | util:Print(arg2) |
||
478 | util:Print(arg3) |
||
479 | util:Print(arg4) |
||
480 | util:Print(arg5) |
||
481 | end |
||
482 |