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