-
Notifications
You must be signed in to change notification settings - Fork 10
/
LM_TravelForm.lua
81 lines (61 loc) · 2.75 KB
/
LM_TravelForm.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
--[[----------------------------------------------------------------------------
LiteMount/LM_TravelForm.lua
Travel Form is the biggest pain in the butt ever invented. Blizzard
change how it works, how fast it is, how many spells it is, and almost
every other aspect of it ALL THE DAMN TIME.
LEAVE TRAVEL FORM ALONE!
Also IsSpellUsable doesn't work right on it.
Copyright 2011 Mike Battersby
----------------------------------------------------------------------------]]--
local _, LM = ...
LM.TravelForm = setmetatable({ }, LM.Spell)
LM.TravelForm.__index = LM.TravelForm
-- Druid forms don't reliably have a corresponding player buff, so we need
-- to check the spell from GetShapeshiftFormInfo.
function LM.TravelForm:IsActive(buffTable)
local id = GetShapeshiftForm()
if id > 0 then
return select(4, GetShapeshiftFormInfo(id)) == self.spellID
end
end
-- In Wrath Classic, you can't fly in Dalaran except in Krasus Landing near
-- the flight master. Normal flying mounts detect this correctly but the
-- flight forms do not.
--
-- As far as I can tell there's no way to tell (that's locale-independent).
-- There's no visible buff, IsFlyablArea() is true and Flight Form is not
-- greyed out. Other flying mounts ARE flagged as unusable but only ones you
-- know ever become usable so it's not reliable.
--
-- So, here's a huge hack that figures out approxiately if you are in the
-- right area or not.
local KrasusLandingCenter = CreateVector2D(0.727, 0.456)
local DalaranDenySpells = { LM.SPELL.FLIGHT_FORM_CLASSIC, LM.SPELL.SWIFT_FLIGHT_FORM_CLASSIC }
function LM.TravelForm:IsAreaDenied()
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then return false end
if not tContains(DalaranDenySpells, self.spellID) then return false end
local map = C_Map.GetBestMapForUnit('player')
if map ~= 125 then return false end
local pos = C_Map.GetPlayerMapPosition(map, 'player')
if not pos then return false end
pos:Subtract(KrasusLandingCenter)
if pos:GetLengthSquared() < 0.0064 then return false end
return true
end
-- IsSpellUsable doesn't return false for Travel Form indoors like it should,
-- because you can swim indoors with it (apparently).
function LM.TravelForm:IsCastable()
if self:IsAreaDenied() then return false end
if IsIndoors() and not IsSubmerged() then return false end
local id = GetShapeshiftFormID()
-- Don't recast over mount-like forms as it behaves as a dismount
if id == 3 or id == 27 then return false end
return LM.Spell.IsCastable(self)
end
function LM.TravelForm:GetCancelAction()
-- Is there any good reason to use /cancelform instead?
return LM.SecureAction:CancelAura(self.name)
end
function LM.TravelForm:IsHidden()
return not IsPlayerSpell(self.spellID)
end