-
Notifications
You must be signed in to change notification settings - Fork 0
/
MountManager.lua
754 lines (675 loc) · 24.7 KB
/
MountManager.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
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata
local GetNumAddOns = C_AddOns.GetNumAddOns or GetNumAddOns
local IsAddOnLoaded = C_AddOns.IsAddOnLoaded or IsAddOnLoaded;
local IsAddOnLoadOnDemand = C_AddOns.IsAddOnLoadOnDemand or IsAddOnLoadOnDemand;
local GetAddOnInfo = C_AddOns.GetAddOnInfo or GetAddOnInfo
local GetAddOnDependencies = C_AddOns.GetAddOnDependencies or GetAddOnDependencies
local GetAddOnEnableState = C_AddOns.GetAddOnEnableState or GetAddOnEnableState
-- local GetSpellInfo = C_Spell.GetSpellInfo or GetSpellInfo
MountManager = LibStub("AceAddon-3.0"):NewAddon("MountManager", "AceConsole-3.0", "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("MountManager")
------------------------------------------------------------------
-- Local Settings
------------------------------------------------------------------
local state = {}
local options = {
name = "MountManager",
handler = MountManager,
type = "group",
args = {
desc = {
type = "description",
name = L["Description"],
order = 0,
},
showInChat = {
type = "toggle",
name = L["Show in Chat"],
desc = L["Toggles the display of the mount name in the chat window."],
get = "GetShowInChat",
set = "SetShowInChat",
width = "full",
},
alwaysDifferent = {
type = "toggle",
name = L["Always Different"],
desc = L["Always select a different mount than the previous one."],
get = "GetAlwaysDifferent",
set = "SetAlwaysDifferent",
width = "full",
},
safeFlying = {
type = "toggle",
name = L["Safe Flying"],
desc = L["Toggles the ability to dismount when flying"],
get = "GetSafeFlying",
set = "SetSafeFlying",
width = "full",
},
oneClick = {
type = "toggle",
name = L["One Click"],
desc = L["One click will dismount you and summon the next available mount."],
get = "GetOneClick",
set = "SetOneClick",
width = "full",
},
autoNextMount = {
type = "toggle",
name = L["Automatic Next Mount"],
desc = L["Automatically determine the next available random mount after summoning the currently selected one."],
get = "GetAutoNextMount",
set = "SetAutoNextMount",
width = "full",
},
},
}
local defaults = {
char = {
level = level,
race = race,
class = class,
faction = faction,
prof = {},
mount_skill = 0,
serpent = false,
classmounts = true,
mounts = {
skill = {},
ground = {},
flying = {},
water = {},
aq = {},
vashj = {},
}
},
profile = {
showInChat = false,
alwaysDifferent = true,
safeFlying = true,
oneClick = true,
autoNextMount = true
},
}
-- This variable is used for determining the ability to fly in the old world
local flightTest = 60025
-- Worgen racial
local worgenRacial = 87840
-- Druid travel forms
local druidForms = {
travel = 783,
aquatic = 1066,
flight = 33943,
swiftflight = 40120
}
-- Shaman ghost wolf form
local ghostWolf = 2645
-- Monk zen flight
local zenFlight = 125883
-- A list of all the Vashj'ir zones for reference
local vashj = {
[613] = true, -- Vashj'ir
[610] = true, -- Kelp'thar Forest
[615] = true, -- Shimmering Expanse
[614] = true -- Abyssal Depths
}
-- Chauffeured
local chauffeured = {
[678] = 179244, -- Chauffeured Mechano-Hog
[679] = 179245, -- Chauffeured Mekgineer's Chopper
}
local SetMapToCurrentZone = SetMapToCurrentZone;
------------------------------------------------------------------
-- Property Accessors
------------------------------------------------------------------
function MountManager:GetShowInChat(info)
return self.db.profile.showInChat
end
function MountManager:SetShowInChat(info, value)
self.db.profile.showInChat = value
end
function MountManager:GetAlwaysDifferent(info)
return self.db.profile.alwaysDifferent
end
function MountManager:SetAlwaysDifferent(info, value)
self.db.profile.alwaysDifferent = value
end
function MountManager:GetSafeFlying(info)
return self.db.profile.safeFlying
end
function MountManager:SetSafeFlying(info, value)
self.db.profile.safeFlying = value
end
function MountManager:GetOneClick(info)
return self.db.profile.oneClick
end
function MountManager:SetOneClick(info, value)
self.db.profile.oneClick = value
end
function MountManager:GetAutoNextMount(info)
return self.db.profile.autoNextMount
end
function MountManager:SetAutoNextMount(info, value)
self.db.profile.autoNextMount = value
end
------------------------------------------------------------------
-- Initialization
------------------------------------------------------------------
function MountManager:OnInitialize()
-- Called when the addon is loaded
self.db = LibStub("AceDB-3.0"):New("MountManagerDB", defaults, "Default")
LibStub("AceConfig-3.0"):RegisterOptionsTable("MountManager", options)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MountManager", "MountManager")
self:RegisterChatCommand("mountmanager", "ChatCommand")
self:RegisterChatCommand("mm", "ChatCommand")
end
function MountManager:OnEnable()
-- Setup current character values
self.db.char.level = UnitLevel("player")
self.db.char.race = select(2, UnitRace("player"))
self.db.char.class = UnitClass("player")
self.db.char.class2 = select(2, UnitClass("player"))
self.db.char.faction = UnitFactionGroup("player")
local prof1, prof2 = GetProfessions()
if prof1 ~= nil then
local name1, _, rank1 = GetProfessionInfo(prof1)
local name2, _, rank2 = GetProfessionInfo(prof2)
self.db.char.prof = {
[name1] = rank1,
[name2] = rank2
}
end
self:LEARNED_SPELL_IN_TAB()
-- Track the current combat state for summoning
self:RegisterEvent("PLAYER_REGEN_DISABLED", "UpdateCombatState")
self:RegisterEvent("PLAYER_REGEN_ENABLED", "UpdateCombatState")
self:RegisterEvent("PET_BATTLE_OPENING_START", "UpdatePetBattleState")
self:RegisterEvent("PET_BATTLE_OPENING_DONE", "UpdatePetBattleState")
self:RegisterEvent("PET_BATTLE_CLOSE", "UpdatePetBattleState")
-- Track the current zone and player state for summoning restrictions
self:RegisterEvent("ZONE_CHANGED_NEW_AREA") -- new world zone
self:RegisterEvent("ZONE_CHANGED", "UpdateZoneStatus") -- new sub-zone
self:RegisterEvent("ZONE_CHANGED_INDOORS", "UpdateZoneStatus") -- new city sub-zone
-- self:RegisterEvent("UPDATE_WORLD_STATES", "UpdateZoneStatus") -- world pvp objectives updated
self:RegisterEvent("SPELL_UPDATE_USABLE", "UpdateZoneStatus") -- self-explanatory
--[[-- Handle entering and exiting water
local f = CreateFrame("Frame", "MyStateWatcher", UIParent, "SecureHandlerStateTemplate")
f:SetScript("OnShow", function() self:UpdateZoneStatus() end)
f:SetScript("OnHide", function() self:UpdateZoneStatus() end)
RegisterStateDriver(f, "visibility", "[swimming] show; hide")]]
-- Track riding skill to determine what mounts can be used
if self.db.char.mount_skill ~= 5 or not self.db.char.serpent then
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
end
-- Learned a new mount
self:RegisterEvent("COMPANION_LEARNED")
-- Perform an initial scan
self:ScanForNewMounts()
self:ScanForRaceClass()
self:ZONE_CHANGED_NEW_AREA()
-- Track spell cast, to generate a new mount after the current has been cast
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
self:RegisterEvent("ADDON_LOADED")
end
------------------------------------------------------------------
-- Event Handling
------------------------------------------------------------------
function MountManager:ChatCommand(input)
if input == "rescan" then
self:Print(L["Beginning rescan..."])
self.db.char.mounts = {
skill = {},
ground = {},
flying = {},
water = {},
aq = {},
vashj = {},
}
self:ScanForNewMounts()
self:ScanForRaceClass()
self:Print(L["Rescan complete"])
else
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
end
end
function MountManager:UpdateCombatState()
state.inCombat = UnitAffectingCombat("player") == 1
end
function MountManager:UpdatePetBattleState(event)
state.inPetBattle = C_PetBattles.IsInBattle() == true
end
function MountManager:ZONE_CHANGED_NEW_AREA()
if not InCombatLockdown() then
C_Map.GetBestMapForUnit("player");
state.zone = C_Map.GetBestMapForUnit("player")
end
self:UpdateZoneStatus()
end
function MountManager:UpdateZoneStatus(event)
if InCombatLockdown() or state.inCombat or state.inPetBattle then return end
local prevSwimming = state.isSwimming
local prevFlyable = state.isFlyable
state.isSwimming = IsSwimming() or IsSubmerged()
local usable, _ = C_Spell.IsSpellUsable(flightTest)
if IsFlyableArea() and self.db.char.mount_skill > 2 and usable == true then
state.isFlyable = true
else
state.isFlyable = false
end
if (prevSwimming ~= state.isSwimming) or (prevFlyable ~= state.isFlyable) then
self:GenerateMacro()
end
end
function MountManager:LEARNED_SPELL_IN_TAB()
if IsSpellKnown(90265) then -- Master (310 flight)
self.db.char.mount_skill = 5
elseif IsSpellKnown(34091) then -- Artisan (280 flight)
self.db.char.mount_skill = 4
elseif IsSpellKnown(34090) then -- Expert (150 flight)
self.db.char.mount_skill = 3
elseif IsSpellKnown(33391) then -- Journeyman (100 ground)
self.db.char.mount_skill = 2
elseif IsSpellKnown(33388) then -- Apprentice (60 ground)
self.db.char.mount_skill = 1
end
--if IsSpellKnown(130487) then -- Cloud Serpent Riding
self.db.char.serpent = true
--end
--[[if self.db.char.class == "Monk" then
self.db.char.mounts["flying"][zenFlight] = IsSpellKnown(zenFlight);
end]]
end
function MountManager:COMPANION_LEARNED()
self:ScanForNewMounts()
end
function MountManager:UNIT_SPELLCAST_SUCCEEDED(event, unitTarget, castGUID, spellId)
if self.db.profile.autoNextMount and unit == "player" and spellId == select(7, C_Spell.GetSpellInfo(state.mount)) then
self:GenerateMacro()
end
end
function MountManager:UPDATE_SHAPESHIFT_FORMS()
if IsSpellKnown(druidForms.travel) then
self.db.char.mounts["skill"][druidForms.travel] = true
end
if IsSpellKnown(druidForms.aquatic) then
self.db.char.mounts["water"][druidForms.aquatic] = true
end
if IsSpellKnown(druidForms.flight) then
self.db.char.mounts["flying"][druidForms.flight] = true
end
if IsSpellKnown(druidForms.swiftflight) then
self.db.char.mounts["flying"][druidForms.swiftflight] = true
end
end
function MountManager:ADDON_LOADED(event, addon)
if (addon == "Blizzard_PetJournal") then
self:HijackMountFrame()
end
end
------------------------------------------------------------------
-- Mount Methods
------------------------------------------------------------------
function MountManager:ScanForNewMounts()
local newMounts = 0
for _, id in pairs(C_MountJournal.GetMountIDs()) do
local name, spellID, _, _, _, _, _, isFactionSpecific, faction, _, isCollected = C_MountJournal.GetMountInfoByID(id)
--make sure its valid and not already found
local correctFaction = not isFactionSpecific or (self.db.char.faction == "Horde" and faction == 0) or (self.db.char.faction == "Alliance" and faction == 1)
if correctFaction == true and isCollected == true and not self:MountExists(spellID) then
newMounts = newMounts + 1
local _, _, _, _, mountType = C_MountJournal.GetMountInfoExtraByID(id)
-- 284 for 2 Chopper / Mechano-Hog
-- 269 for 2 Water Striders (Azure and Crimson)
-- 254 for 1 Subdued Seahorse (Vashj'ir and water)
-- 248 for 163 "typical" flying mounts, including those that change based on level
-- 247 for 1 Red Flying Cloud (flying mount)
-- 242 for 1 Swift Spectral Gryphon (the one we fly while dead)
-- 241 for 4 Qiraji Battle Tanks (AQ only)
-- 232 for 1 Abyssal Seahorse (Vashj'ir only)
-- 231 for 2 Turtles (Riding and Sea)
-- 230 for 298 land mounts
if mountType == 241 then
self.db.char.mounts["aq"] = self.db.char.mounts["aq"] or {}
self.db.char.mounts["aq"][spellID] = true
end
if mountType == 232 or mountType == 254 then
self.db.char.mounts["vashj"] = self.db.char.mounts["vashj"] or {}
self.db.char.mounts["vashj"][spellID] = true
end
if mountType == 247 or mountType == 248 then
self.db.char.mounts["flying"] = self.db.char.mounts["flying"] or {}
self.db.char.mounts["flying"][spellID] = true
end
if mountType == 231 or mountType == 254 or mountType == 269 then
self.db.char.mounts["water"] = self.db.char.mounts["water"] or {}
self.db.char.mounts["water"][spellID] = true
end
if mountType == 230 or mountType == 231 or mountType == 269 or mountType == 284 then
self.db.char.mounts["ground"] = self.db.char.mounts["ground"] or {}
self.db.char.mounts["ground"][spellID] = true
end
end
end
if newMounts > 0 then
self:Print(string.format("|cff20ff20%s|r %s", newMounts, L["new mount(s) found!"]))
self:UpdateMountChecks()
end
end
function MountManager:ScanForRaceClass()
if self.db.char.race == "Worgen" and self.db.char.mount_skill > 0 then
self.db.char.mounts["ground"][worgenRacial] = true;
end
if self.db.char.class == "Druid" then
self:UPDATE_SHAPESHIFT_FORMS()
end
if self.db.char.class == "Monk" then
self.db.char.mounts["flying"][zenFlight] = IsSpellKnown(zenFlight);
end
if self.db.char.class == "Shaman" and self.db.char.level > 14 then
self.db.char.mounts["skill"][ghostWolf] = true;
end
end
function MountManager:MountExists(spellID)
for mountType, typeTable in pairs(self.db.char.mounts) do
if typeTable[spellID] ~= nil then
return true
end
end
return false
end
function MountManager:SummonMount(mount)
for _, id in pairs(C_MountJournal.GetMountIDs()) do
local _, spellID = C_MountJournal.GetMountInfoByID(id)
if spellID == mount then
C_MountJournal.SummonByID(id)
return
end
end
end
------------------------------------------------------------------
-- Mount Configuration
------------------------------------------------------------------
function MountManager:HijackMountFrame()
self.companionButtons = {}
local numMounts = (C_MountJournal.GetMountIDs())
local scrollFrame = MountJournal.ListScrollFrame
local buttons = scrollFrame.buttons
-- build out check buttons
for idx = 1, #buttons do
local parent = buttons[idx];
if idx <= numMounts then
local button = CreateFrame("CheckButton", "MountCheckButton" .. idx, parent, "UICheckButtonTemplate")
button:SetEnabled(false)
button:SetPoint("TOPRIGHT", 0, 0)
button:HookScript("OnClick", function(self)
MountManager:MountCheckButton_OnClick(self)
end)
self.companionButtons[idx] = button
end
end
-- hook up events to update check state on scrolling
scrollFrame:HookScript("OnMouseWheel", function(self)
MountManager:UpdateMountChecks()
end)
scrollFrame:HookScript("OnVerticalScroll", function(self)
MountManager:UpdateMountChecks()
end)
---- hook up events to update check state on search or filter change
hooksecurefunc("MountJournal_UpdateMountList", function(self)
MountManager:UpdateMountChecks()
end);
-- force an initial update on the journal, as it's coded to only do it upon scroll or selection
MountJournal_UpdateMountList()
end
function MountManager:UpdateMountChecks()
if self.companionButtons then
local offset = HybridScrollFrame_GetOffset(MountJournal.ListScrollFrame);
for idx, button in ipairs(self.companionButtons) do
local parent = button:GetParent()
-- Get information about the currently selected mount
local spellID = parent.spellID
local id = self:FindSelectedID(spellID)
local _, _, _, _, _, _, _, isFactionSpecific, faction, _, isCollected = C_MountJournal.GetMountInfoByID(id)
local correctFaction = (not isFactionSpecific or (self.db.char.faction == "Horde" and faction == 0) or (self.db.char.faction == "Alliance" and faction == 1))
if correctFaction == true and isCollected == true and parent:IsEnabled() == true then
-- Set the checked state based on the currently saved value
local checked = false;
for mountType, typeTable in pairs(self.db.char.mounts) do
if typeTable[spellID] ~= nil then
checked = typeTable[spellID]
end
end
button:SetEnabled(true)
button:SetChecked(checked)
button:SetAlpha(1.0);
else
button:SetEnabled(false)
button:SetChecked(false)
button:SetAlpha(0.25);
end
end
end
end
function MountManager:MountCheckButton_OnClick(button)
local spellID = button:GetParent().spellID
-- Toggle the saved value for the selected mount
for mountType, typeTable in pairs(self.db.char.mounts) do
if typeTable[spellID] ~= nil then
if typeTable[spellID] == true then
typeTable[spellID] = false
else
typeTable[spellID] = true
end
end
end
end
function MountManager:FindSelectedID(selectedSpellID)
for _, id in pairs(C_MountJournal.GetMountIDs()) do
local _, spellID = MountJournal_GetMountInfoByID(id);
if spellID == selectedSpellID then
return id;
end
end
return nil;
end
function MountManager:MountManagerButton_OnClick(button)
if button == "LeftButton" then
if IsIndoors() then return end
if IsFlying() then
if self.db.profile.safeFlying == false then
Dismount()
end
else
local speed = GetUnitSpeed("player")
if IsMounted() then
Dismount()
if speed == 0 and self.db.profile.oneClick then
self:SummonMount(state.mount)
end
else
if speed == 0 then
self:SummonMount(state.mount)
end
end
end
else
self:GenerateMacro()
end
end
------------------------------------------------------------------
-- Macro Setup
------------------------------------------------------------------
function MountManager:GenerateMacro()
if InCombatLockdown() or state.inCombat or state.inPetBattle then return end
-- Create base macro for mount selection
local index = GetMacroIndexByName("MountManager")
if index == 0 then
index = CreateMacro("MountManager", 1, "", 1, nil)
end
if self.db.char.level < 20 then
local id = (UnitFactionGroup("player") == "Horde") and 678 or 679
state.mount = select(5, C_MountJournal.GetMountInfoByID(id)) and chauffeured[id]
else
state.mount = self:GetRandomMount()
end
if state.mount then
local spellInfo = C_Spell.GetSpellInfo(state.mount)
-- icon = string.sub(icon, 17)
if self.db.profile.showInChat then
self:Print(string.format("%s |cff20ff20%s|r", L["The next selected mount is"], spellInfo.name))
end
EditMacro(index, "MountManager", spellInfo.iconID, string.format("/script MountManagerButton:Click(GetMouseButtonClicked());\n#showtooltip %s", spellInfo.name))
else
self:Print(L["There is no mount available for the current character."])
end
end
function MountManager:GetRandomMount()
if self.db.char.mount_skill == 0 then
return nil
end
-- Determine state order for looking for a mount
local typeList = {}
local keyDown = IsModifierKeyDown()
if vashj[state.zone] then -- in Vashj'ir
if state.isSwimming == true and not keyDown then
typeList = { "vashj", "water", "ground" }
elseif state.isFlyable == true then
typeList = { "flying", "vashj", "water", "ground" }
else
typeList = { "ground" }
end
elseif state.zone == 766 then -- in AQ
if keyDown then
typeList = { "ground" }
elseif state.isSwimming == true then
typeList = { "water", "aq", "ground" }
else
typeList = { "aq", "ground" }
end
elseif state.isSwimming == true then
if state.isFlyable == true and not keyDown then
typeList = { "flying", "water", "ground" }
else
typeList = { "water", "ground" }
end
elseif state.isFlyable == true and not keyDown then
typeList = { "flying", "ground" }
else
typeList = { "ground" }
end
-- Cycle through the type list
for i, type in pairs(typeList) do
-- Make a sublist of any valid mounts of the selected type
local mounts = {}
for mount, active in pairs(self.db.char.mounts[type]) do
if self.db.char.mounts[type][mount] == true and self:CheckProfession(mount) and self:CheckSerpent(mount) and self:CheckClass(mount) then
mounts[#mounts + 1] = mount
end
end
-- If there were any matching mounts of the current type, then proceed, otherwise move to the next type
if #mounts > 0 then
-- Grab a random mount from the narrowed list
local rand = random(1, #mounts)
local mount = mounts[rand]
if state.mount == mount and self.db.profile.alwaysDifferent and #mounts > 1 then
while state.mount == mount do
rand = random(1, #mounts)
mount = mounts[rand]
end
end
return mount
end
end
-- If this point has been reached, then no matching mount was found
return nil
end
-- Profession restricted mounts
local TAILORING_ID = 110426
local ENGINEERING_ID = 110403
local profMounts = {
[61451] = { TAILORING_ID, 300 }, --Flying Carpet
[61309] = { TAILORING_ID, 300 }, --Magnificent Flying Carpet
[75596] = { TAILORING_ID, 300 }, --Frosty Flying Carpet
[169952] = { TAILORING_ID, 300 }, --Creeping Carpet
[44153] = { ENGINEERING_ID, 300 }, --Flying Machine
[44151] = { ENGINEERING_ID, 300 }, --Turbo-Charged Flying Machine
}
function MountManager:CheckProfession(spell)
if profMounts[spell] then
local skill = C_Spell.GetSpellInfo(profMounts[spell][1])
local req = profMounts[spell][2]
if self.db.char.prof[skill] then
return self.db.char.prof[skill] >= req
else
return false
end
end
return true
end
-- Cloud Serpents
local serpents = {
[113199] = true, --Jade Cloud Serpent
[123992] = true, --Azure Cloud Serpent
[123993] = true, --Golden Cloud Serpent
[127154] = true, --Onyx Cloud Serpent
[127156] = true, --Crimson Cloud Serpent
[127170] = true, --Astral Cloud Serpent
[127158] = true, --Heavenly Onyx Cloud Serpent
[127161] = true, --Heavenly Crimson Cloud Serpent
[127164] = true, --Heavenly Golden Cloud Serpent
[127165] = true, --Heavenly Jade Cloud Serpent
[127169] = true, --Heavenly Azure Cloud Serpent
[124408] = true, --Thundering Jade Cloud Serpent
[129918] = true, --Thundering August Cloud Serpent
[132036] = true, --Thundering Ruby Cloud Serpent
}
function MountManager:CheckSerpent(spell)
if serpents[spell] then
return self.db.char.serpent
end
return true
end
-- Class Mounts
local classmounts = {
[229387] = "DEATHKNIGHT", --Deathlord's Vilebrood Vanquisher
[48778] = "DEATHKNIGHT", --Acherus Deathcharger
[54729] = "DEATHKNIGHT", --Winged Steed of the Ebon Blade
[200175] = "DEMONHUNTER", --Felsaber
[229417] = "DEMONHUNTER", --Slayer's Felbroken Shrieker
[229386] = "HUNTER", --Huntmaster's Loyal Wolfhawk
[229438] = "HUNTER", --Huntmaster's Fierce Wolfhawk
[229439] = "HUNTER", --Huntmaster's Dire Wolfhawk
[229376] = "MAGE", --Archmage's Prismatic Disc
[229385] = "MONK", --Ban-Lu, Grandmaster's Companion
[23214] = "PALADIN", --Charger
[34767] = "PALADIN", --Thalassian Charger
[73630] = "PALADIN", --HGreat Exarch's Elekk
[69826] = "PALADIN", --Great Sunwalker Kodo
[66906] = "PALADIN", --Argent Charger
[231435] = "PALADIN", --Highlord's Golden Charger
[231589] = "PALADIN", --Highlord's Valorous Charge
[231588] = "PALADIN", --Highlord's Vigilant Charger
[231587] = "PALADIN", --Highlord's Vengeful Charger
[229377] = "PRIEST", --High Priest's Lightsworn Seeker
[231434] = "ROGUE", --Shadowblade's Murderous Omen
[231523] = "ROGUE", --Shadowblade's Lethal Omen
[231524] = "ROGUE", --Shadowblade's Baneful Omen
[231525] = "ROGUE", --Shadowblade's Crimson Omen
[231442] = "SHAMAN", --Farseer's Raging Tempest
[5784] = "WARLOCK", --Felsteed
[23161] = "WARLOCK", --Dreadsteed
[238452] = "WARLOCK", --Netherlord's Brimstone Wrathsteed
[238454] = "WARLOCK", --Netherlord's Accursed Wrathsteed
[232412] = "WARLOCK", --Netherlord's Chaotic Wrathsteed
[229388] = "WARRIOR", --Battlelord's Bloodthirsty War Wyrm
}
function MountManager:CheckClass(spell)
if classmounts[spell] then
if classmounts[spell] == self.db.char.class2 then
return self.db.char.classmounts
else
return false
end
end
return true
end