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