vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- EzDismount : A quick and dirty dismounting mod, useful for PVP or herb/ore collecting
2 -- By Gaddur of the Eonar Server
3 -- Modified v2.01 by nathan
4  
5 local EzDClass
6 local EzDPlayer
7  
8 EzDismount_ver = "v2.03";
9 EzDismount_fullver = ("EzDismount " .. EzDismount_ver);
10  
11 BINDING_HEADER_EZDISMOUNT = "EzDismount";
12 BINDING_NAME_EZDISMOUNT = "Dismount";
13  
14 ---------------------------------
15 -- Stuff to do when Mod is loaded
16 ---------------------------------
17 function EzDismount_onload()
18  
19 EzDClass = UnitClass("player");
20 EzDPlayer = (UnitName("player").." of "..GetCVar("realmName"))
21 EZDismount_DetPlayer:SetText(EzDPlayer.." Server");
22  
23 --Create user table if it doesnt exist
24 if (EzDismount_Config == nil) then
25 EzDismount_Config = {};
26 end
27  
28 if (EzDismount_Config[EzDPlayer] == nil) then
29 EzDismount_reset();
30 end
31  
32 DEFAULT_CHAT_FRAME:AddMessage("## " .. EzDismount_fullver .. " Loaded ## Use /ezd or /ezd help", 0.0, 1.0, 0.0);
33  
34 SlashCmdList["EZDISMOUNT"] = EzDismount_options;
35 SLASH_EZDISMOUNT1 = "/ezd";
36 SLASH_EZDISMOUNT2 = "/ezdismount";
37  
38 -- Set Default Colors
39 EZDismount_ShamanTitle:SetTextColor(255,255,255,255);
40 EZDismount_DruidTitle:SetTextColor(255,255,255,255);
41 EZDismount_PriestTitle:SetTextColor(255,255,255,255);
42 EzDismount_Text_Status_VOFF:SetTextColor(255,0,0,255);
43 EzDismount_Text_Status_VON:SetTextColor(0,255,0,255);
44 EzDismount_Text_Shaman_VOFF:SetTextColor(255,0,0,255);
45 EzDismount_Text_Shaman_VON:SetTextColor(0,255,0,255);
46 EzDismount_Text_Druid_VOFF:SetTextColor(255,0,0,255);
47 EzDismount_Text_Druid_VON:SetTextColor(0,255,0,255);
48 EzDismount_Text_Moonkin_VOFF:SetTextColor(255,0,0,255);
49 EzDismount_Text_Moonkin_VON:SetTextColor(0,255,0,255);
50 EzDismount_Text_Shadowform_VOFF:SetTextColor(255,0,0,255);
51 EzDismount_Text_Shadowform_VON:SetTextColor(0,255,0,255);
52 EzDismount_Text_Stand_VOFF:SetTextColor(255,0,0,255);
53 EzDismount_Text_Stand_VON:SetTextColor(0,255,0,255);
54 EzDismount_Text_Auction_VOFF:SetTextColor(255,0,0,255);
55 EzDismount_Text_Auction_VON:SetTextColor(0,255,0,255);
56 EZDismount_DetPlayer:SetTextColor(255,255,255,255);
57  
58 end
59  
60 ----------------------------------
61 -- Parse out option from / Command
62 ----------------------------------
63 function EzDismount_options(msg)
64  
65 -- Show Config Menu
66 if (msg == "") then
67 EzDismount_Toggle();
68 end
69  
70 -- Dump Textures to chatwindow
71 if (string.lower(msg) == "debug") then
72 EzDismount_dumpbuff();
73 end
74  
75 -- Reload UI
76 if (string.lower(msg) == "reload") then
77 ReloadUI();
78 end
79  
80 -- Reset Settings
81 if (string.lower(msg) == "reset") then
82 EzDismount_reset();
83 end
84  
85 -- Help
86 if (string.lower(msg) == "help") or (msg == "?") then
87 EzDismount_help();
88 end
89  
90  
91 end
92  
93 ------------------
94 -- Reset Variables
95 ------------------
96 function EzDismount_reset()
97  
98 EzDismount_Config[EzDPlayer] = {
99 ["Dismount"] = "ON";
100 ["Druid"] = "ON";
101 ["Shadowform"] = "ON";
102 ["Wolf"] = "ON";
103 ["Moonkin"] = "ON";
104 ["Stand"] = "ON";
105 ["Auction"] = "ON";
106 }
107  
108 end
109  
110 ----------------
111 -- Toggle Values
112 ----------------
113 function EzDismount_ChgValue(msg)
114  
115  
116 local NewVal = ""
117  
118 -- Auto-dismount toggle
119 if (string.lower(msg) == "on/off") then
120  
121 if (EzDismount_Config[EzDPlayer]["Dismount"] == "ON") then
122 EzDismount_Config[EzDPlayer]["Dismount"] = "TAXI";
123 NewVal = "Y";
124 end
125  
126 if ((EzDismount_Config[EzDPlayer]["Dismount"] == "TAXI") and (NewVal == "")) then
127 EzDismount_Config[EzDPlayer]["Dismount"] = "OFF";
128 NewVal = "Y";
129 end
130  
131 if ((EzDismount_Config[EzDPlayer]["Dismount"] == "OFF") and (NewVal == "")) then
132 EzDismount_Config[EzDPlayer]["Dismount"] = "ON";
133 NewVal = "Y";
134 end
135  
136 -- Auctioneer toggle
137 elseif (string.lower(msg) == "auction") then
138  
139 if (EzDismount_Config[EzDPlayer]["Auction"] == "ON") then
140 EzDismount_Config[EzDPlayer]["Auction"] = "OFF";
141 else
142 EzDismount_Config[EzDPlayer]["Auction"] = "ON";
143 end
144  
145 -- Stand toggle
146 elseif (string.lower(msg) == "stand") then
147  
148 if (EzDismount_Config[EzDPlayer]["Stand"] == "ON") then
149 EzDismount_Config[EzDPlayer]["Stand"] = "OFF";
150 else
151 EzDismount_Config[EzDPlayer]["Stand"] = "ON";
152 end
153  
154  
155 -- Druid toggle
156 elseif (string.lower(msg) == "druid") then
157  
158 if (EzDismount_Config[EzDPlayer]["Druid"] == "ON") then
159 EzDismount_Config[EzDPlayer]["Druid"] = "OFF";
160 else
161 EzDismount_Config[EzDPlayer]["Druid"] = "ON";
162 end
163  
164 -- Shaman toggle
165 elseif (string.lower(msg) == "wolf") then
166  
167 if (EzDismount_Config[EzDPlayer]["Wolf"] == "ON") then
168 EzDismount_Config[EzDPlayer]["Wolf"] = "OFF";
169 else
170 EzDismount_Config[EzDPlayer]["Wolf"] = "ON";
171 end
172  
173  
174 -- Moonkin toggle
175 elseif (string.lower(msg) == "moonkin") then
176  
177 if (EzDismount_Config[EzDPlayer]["Moonkin"] == "ON") then
178 EzDismount_Config[EzDPlayer]["Moonkin"] = "OFF";
179 else
180 EzDismount_Config[EzDPlayer]["Moonkin"] = "ON";
181 end
182  
183  
184 -- Shadowform toggle
185 elseif (string.lower(msg) == "shadowform") then
186  
187 if (EzDismount_Config[EzDPlayer]["Shadowform"] == "ON") then
188 EzDismount_Config[EzDPlayer]["Shadowform"] = "OFF";
189 else
190 EzDismount_Config[EzDPlayer]["Shadowform"] = "ON";
191 end
192  
193 end
194  
195 EzDismount_Refresh();
196  
197 end
198  
199  
200 -------------------------------
201 -- Check UI_ERROR_MESSAGE Event
202 -------------------------------
203 function EzDismount_chkerror(arg1)
204  
205  
206 -- See if auto dismount is enabled
207 if (EzDismount_Config[EzDPlayer]["Dismount"] ~= "OFF") then
208  
209 EzDismount_chkandgetdown("Dismount", EzDMountErr.Error, arg1, true);
210  
211 if ( arg1 == "TAXI") then
212 EzDismount_getdown(true);
213 end;
214  
215 end
216  
217 -- Auctioneer Dismount enabled
218 if (EzDismount_Config[EzDPlayer]["Auction"] ~= "OFF") then
219  
220 if ( arg1 == "AUCTION") then
221 EzDismount_getdown(true);
222 end
223 end
224  
225 -- Stand up if you are trying to do something while sitting
226 if (EzDismount_Config[EzDPlayer]["Stand"] ~= "OFF") then
227  
228 if ( arg1 == EzDSitErr) then
229 SitOrStand();
230 end
231 end
232  
233 -- Check class specific things
234 if (EzDClass == "Druid") then
235 EzDismount_chkandgetdown("Druid", EzDShiftErr.Error, arg1);
236 EzDismount_chkandgetdown("Moonkin", EzDShiftErr.Error, arg1);
237  
238 elseif (EzDClass == "Shaman") then
239 EzDismount_chkandgetdown("Wolf", EzDShiftErr.Error, arg1);
240  
241  
242 elseif (EzDClass == "Priest") then
243 EzDismount_chkandgetdown("Shadowform", EzDShiftErr.Error, arg1);
244  
245  
246 end
247 end
248  
249  
250 function EzDismount_chkandgetdown(chkType, errorTable, msg, mount)
251  
252 -- See if chkType is enabled
253 if (EzDismount_Config[EzDPlayer][chkType] ~= "OFF") then
254  
255 -- If not on Taxi
256 if ( not UnitOnTaxi("player") ) then
257 for _, value in pairs(errorTable) do
258 if ( msg == value) then
259 EzDismount_getdown(mount);
260 break;
261 end
262 end
263  
264 end
265 end
266 end
267  
268  
269 -----------------------------------------
270 -- Look for Mount Buff Icon and cancel it
271 -----------------------------------------
272 function EzDismount_getdown(mount)
273  
274 local currBuffTex;
275 local pallyhorse = "spell_nature_swiftness";
276 local regMount = "_mount_";
277 local bearform = "ability_racial_bearform";
278 local catform = "ability_druid_catform";
279 local travelform = "ability_druid_travelform";
280 local shadowform = "spell_shadow_shadowform";
281 local spiritwolf = "spell_nature_spiritwolf";
282 local moonkin = "spell_nature_forceofnature";
283 local aqmount = "_qirajicrystal_"
284 local aquaticform = "ability_druid_aquaticform";
285  
286  
287 -- was this a dismount request or a shapeshift request?
288 if mount then
289 for i=0,15,1 do
290  
291 currBuffTex = GetPlayerBuffTexture(i);
292  
293 if (currBuffTex and (not EzD_exclude(i))) then
294  
295 -- Mount (or level 40 pally horse) or Qiraji Mounts
296 if ((string.find(string.lower(currBuffTex), regMount) or string.find(string.lower(currBuffTex), pallyhorse)) or (string.find(string.lower(currBuffTex), aqmount))) then
297 if ((EzDismount_Config[EzDPlayer]["Dismount"] == "ON") or (EzDismount_Config[EzDPlayer]["Dismount"] == "TAXI")) then
298 CancelPlayerBuff(i);
299 end
300 end
301 end
302 end
303  
304 else
305 for i=0,15,1 do
306  
307 currBuffTex = GetPlayerBuffTexture(i);
308  
309 if (currBuffTex and (not EzD_exclude(i))) then
310  
311 -- GhostWolf
312 if (string.find(string.lower(currBuffTex), spiritwolf)) then
313 if (EzDismount_Config[EzDPlayer]["Wolf"] == "ON") then
314 CancelPlayerBuff(i);
315 break;
316 end
317  
318 -- Bear Form
319 elseif (string.find(string.lower(currBuffTex), bearform)) then
320 if (EzDismount_Config[EzDPlayer]["Druid"] == "ON") then
321 CancelPlayerBuff(i);
322 break;
323 end
324  
325 -- Cat Form
326 elseif (string.find(string.lower(currBuffTex), catform)) then
327 if (EzDismount_Config[EzDPlayer]["Druid"] == "ON") then
328 CancelPlayerBuff(i);
329 break;
330 end
331  
332 -- Travel Form
333 elseif (string.find(string.lower(currBuffTex), travelform)) then
334 if (EzDismount_Config[EzDPlayer]["Druid"] == "ON") then
335 CancelPlayerBuff(i);
336 break;
337 end
338  
339 -- Aquatic Form
340 elseif (string.find(string.lower(currBuffTex), aquaticform)) then
341 if (EzDismount_Config[EzDPlayer]["Druid"] == "ON") then
342 CancelPlayerBuff(i);
343 break;
344 end
345  
346 -- Moonkin Form
347 elseif (string.find(string.lower(currBuffTex), moonkin)) then
348 if (EzDismount_Config[EzDPlayer]["Moonkin"] == "ON") then
349 CancelPlayerBuff(i);
350 break;
351 end
352  
353 -- Shadowform
354 elseif (string.find(string.lower(currBuffTex), shadowform)) then
355 if (EzDismount_Config[EzDPlayer]["Shadowform"] == "ON") then
356 CancelPlayerBuff(i);
357 break;
358 end
359  
360  
361 end
362 end
363 end
364 end
365  
366 end
367  
368 --------------------------------------
369 -- Exclude as mount based on buff name
370 --------------------------------------
371 function EzD_exclude(i)
372  
373 local buffname;
374 local result = false;
375  
376 EzDTooltip:SetOwner(UIParent, "ANCHOR_NONE");
377  
378 EzDTooltip:ClearLines();
379 EzDTooltip:SetPlayerBuff(i);
380 buffname = EzDTooltipTextLeft1:GetText();
381  
382 if ( buffname ~= nil ) then
383 for index=1, table.getn(EzDMountTable.Exclude), 1 do
384 if ( EzDMountTable.Exclude[index] == string.lower(buffname) ) then
385 result = true;
386 break;
387 end
388 end
389 end
390  
391 return result
392  
393 end
394  
395 ----------------------------------------------------
396 -- Dump current Buff icon texture names (Debug Code)
397 ----------------------------------------------------
398 function EzDismount_dumpbuff()
399  
400 local bufftext;
401 local buffname;
402 local debugmsg;
403  
404 EzDTooltip:SetOwner(UIParent, "ANCHOR_NONE");
405  
406 for i=0,15,1 do
407  
408 EzDTooltip:ClearLines();
409 EzDTooltip:SetPlayerBuff(i);
410  
411 buffname = EzDTooltipTextLeft1:GetText();
412 bufftext = GetPlayerBuffTexture(i);
413  
414 if (bufftext ~= nil) then
415 debugmsg = ("(" .. i .. ") [" ..buffname.. "] "..bufftext);
416 DEFAULT_CHAT_FRAME:AddMessage(debugmsg, 0.0, 1.0, 0.0);
417 end
418  
419 end
420 end
421  
422 --------------------------------------------------------------
423 -- Look for Mount Buff Icon and cancel it (Alternate Function)
424 --------------------------------------------------------------
425 function EzD_getdown()
426  
427 EzDismount_getdown(1);
428  
429 end
430  
431  
432 ------------------------
433 -- Cancel Buff by Name
434 ------------------------
435 function EzD_drop(dropbuff)
436  
437 local buffname;
438  
439 if ( dropbuff ~= nil ) then
440  
441 EzDTooltip:SetOwner(UIParent, "ANCHOR_NONE");
442  
443 for i=0,15,1 do
444  
445 EzDTooltip:ClearLines();
446 EzDTooltip:SetPlayerBuff(i);
447 buffname = EzDTooltipTextLeft1:GetText();
448  
449 if (buffname ~= nil) then
450 if string.find(string.lower(buffname), string.lower(dropbuff)) then
451 CancelPlayerBuff(i);
452 break;
453 end
454 end
455 end
456  
457 end
458 end
459  
460 ------------------------
461 -- Check if Buff exists
462 ------------------------
463 function EzD_buffexist(findbuff)
464  
465 local buffname;
466 local result = false;
467  
468 if ( findbuff ~= nil ) then
469  
470 EzDTooltip:SetOwner(UIParent, "ANCHOR_NONE");
471  
472 for i=0,15,1 do
473  
474 EzDTooltip:ClearLines();
475 EzDTooltip:SetPlayerBuff(i);
476 buffname = EzDTooltipTextLeft1:GetText();
477  
478 if (buffname ~= nil) then
479 if string.find(string.lower(buffname), string.lower(findbuff)) then
480 result = true;
481 break;
482 end
483 end
484 end
485 end
486  
487 return result;
488  
489 end
490  
491  
492 -----------------------------------------
493 -- Toggles the showing/hiding of the Menu
494 -----------------------------------------
495 function EzDismount_Toggle()
496  
497 if ( EzDismount_Menu:IsVisible() ) then
498 EzDismount_Menu:Hide();
499 else
500 EzDismount_Menu:Show();
501 end
502  
503 end
504  
505 --------------------
506 -- Refresh Screen
507 --------------------
508  
509 function EzDismount_Refresh()
510  
511 EzDismount_Text_Status_VOFF:SetText("");
512 EzDismount_Text_Status_VON:SetText("");
513 EzDismount_Text_Shaman_VOFF:SetText("");
514 EzDismount_Text_Shaman_VON:SetText("");
515 EzDismount_Text_Druid_VOFF:SetText("");
516 EzDismount_Text_Druid_VON:SetText("");
517 EzDismount_Text_Moonkin_VOFF:SetText("");
518 EzDismount_Text_Moonkin_VON:SetText("");
519 EzDismount_Text_Shadowform_VOFF:SetText("");
520 EzDismount_Text_Shadowform_VON:SetText("");
521 EzDismount_Text_Stand_VOFF:SetText("");
522 EzDismount_Text_Stand_VON:SetText("");
523 EzDismount_Text_Auction_VOFF:SetText("");
524 EzDismount_Text_Auction_VON:SetText("");
525  
526 -- Mounts
527 EzDismount_Text_Status:SetText("Automatic dismounting is :");
528 if ( EzDismount_Config[EzDPlayer]["Dismount"] == "OFF" ) then
529 EzDismount_Text_Status_VOFF:SetText("[OFF]");
530 end
531  
532 if (EzDismount_Config[EzDPlayer]["Dismount"] == "ON" ) then
533 EzDismount_Text_Status_VON:SetText("[ON]");
534 end
535  
536 if ( EzDismount_Config[EzDPlayer]["Dismount"] == "TAXI" ) then
537 EzDismount_Text_Status_VON:SetText("[TAXI]");
538 end
539  
540 -- Auctioneer Dismount
541 EzDismount_Text_Auction:SetText("Automatic auctioneer dismount is :");
542 if ( EzDismount_Config[EzDPlayer]["Auction"] == "OFF" ) then
543 EzDismount_Text_Auction_VOFF:SetText("[OFF]");
544 else
545 EzDismount_Text_Auction_VON:SetText("[ON]");
546 end
547  
548 -- Auto-Stand
549 EzDismount_Text_Stand:SetText("Automatic stand from sit is :");
550 if ( EzDismount_Config[EzDPlayer]["Stand"] == "OFF" ) then
551 EzDismount_Text_Stand_VOFF:SetText("[OFF]");
552 else
553 EzDismount_Text_Stand_VON:SetText("[ON]");
554 end
555  
556 -- Shaman
557 EzDismount_Text_Shaman:SetText("Auto-cancel of Ghostwolf is :");
558 if ( EzDismount_Config[EzDPlayer]["Wolf"] == "OFF" ) then
559 EzDismount_Text_Shaman_VOFF:SetText("[OFF]");
560 else
561 EzDismount_Text_Shaman_VON:SetText("[ON]");
562 end
563  
564 -- Druid
565 EzDismount_Text_Druid:SetText("Auto-cancel of shapeshifts is :");
566 if ( EzDismount_Config[EzDPlayer]["Druid"] == "OFF" ) then
567 EzDismount_Text_Druid_VOFF:SetText("[OFF]");
568 else
569 EzDismount_Text_Druid_VON:SetText("[ON]");
570 end
571  
572 -- Moonkin
573 EzDismount_Text_Moonkin:SetText("Auto-cancel of Moonkin form :");
574 if ( EzDismount_Config[EzDPlayer]["Moonkin"] == "OFF" ) then
575 EzDismount_Text_Moonkin_VOFF:SetText("[OFF]");
576 else
577 EzDismount_Text_Moonkin_VON:SetText("[ON]");
578 end
579  
580 -- Shadowform
581 EzDismount_Text_Shadowform:SetText("Auto-cancel of Shadowform :");
582 if ( EzDismount_Config[EzDPlayer]["Shadowform"] == "OFF" ) then
583 EzDismount_Text_Shadowform_VOFF:SetText("[OFF]");
584 else
585 EzDismount_Text_Shadowform_VON:SetText("[ON]");
586 end
587  
588 end
589  
590 --------------------------
591 -- Show slash command help
592 --------------------------
593 function EzDismount_help()
594  
595 DEFAULT_CHAT_FRAME:AddMessage("## " .. EzDismount_fullver .. " ##", 0.0, 1.0, 0.0);
596  
597 for index=1, table.getn(EzDHelp.List), 1 do
598 DEFAULT_CHAT_FRAME:AddMessage(EzDHelp.List[index], 0.0, 1.0, 0.0);
599 end;
600 end