1 QuestHelper_File
["graph_flightpath.lua"] = "Development Version"
2 QuestHelper_Loadtime
["graph_flightpath.lua"] = GetTime()
4 -- Name to Name, gives {time, accurate}
5 QH_Flight_Distances
= {}
7 function QH_redo_flightpath()
8 QuestHelper
: Assert(DB_Ready())
10 -- First, let's figure out if the player can fly.
11 -- The logic we're using: if he has 225 or 300, then he can fly in Outland. If he's got Cold Weather Flying and those levels, he can fly in Northrend.
13 local ridingLevel
= (select(4,GetAchievementInfo(892)) and 300) or (select(4,GetAchievementInfo(890)) and 225) or (select(4,GetAchievementInfo(889)) and 150) or (select(4,GetAchievementInfo(891)) and 75) or 0 -- this is thanks to Maldivia, who is a fucking genius
14 local has_cwf
= not not GetSpellInfo(GetSpellInfo(54197))
17 if ridingLevel
== 225 then
19 elseif ridingLevel
== 300 then
23 if ridingLevel
>= 225 then
24 QH_Graph_Flyplaneset(3, speed
) -- Outland
27 if ridingLevel
>= 225 and has_cwf
then
28 QH_Graph_Flyplaneset(4, speed
) -- Northrend
32 local flightids
= DB_ListItems("flightmasters")
37 for k
, v
in pairs(flightids
) do
38 flightdb
[v
] = DB_GetItem("flightmasters", v
, true, true)
39 if QuestHelper_KnownFlightRoutes
[flightdb
[v
].name
] then
50 for k
, v
in pairs(has
) do
51 local tdb
= DB_GetItem("flightpaths", k
, true, true)
53 for dest
, dat
in pairs(tdb
) do
55 for _
, route
in ipairs(dat
) do
57 if route
.path
then for _
, intermed
in ipairs(route
.path
) do
58 if not has
[intermed
] then passes
= false break end
62 --QuestHelper:TextOut(string.format("Found link between %s and %s, cost %f", flightdb[k].name, flightdb[dest].name, route.distance))
63 if not adjacency
[k
] then adjacency
[k
] = {} end
64 if not adjacency
[dest
] then adjacency
[dest
] = {} end
65 QuestHelper
: Assert(not (adjacency
[k
][dest
] and adjacency
[k
][dest
].time
))
66 adjacency
[k
][dest
] = {time
= route
.distance
, dist
= route
.distance
, original
= true}
68 -- no such thing as strongly asymmetric routes
69 -- note that we're only hitting up adjacency here, because we don't have "time info"
70 if not adjacency
[dest
][k
] then
71 adjacency
[dest
][k
] = {dist
= route
.distance
* 1.1, original
= true} -- It's original because, in theory, we may end up basing other links on this one. It's still not time-authoritative, though.
75 important
[dest
] = true
88 local flightmasters
= {}
89 for k
, v
in pairs(important
) do
90 table.insert(imp_flat
, k
)
91 if flightdb
[k
].mid
then
92 local fmx
= DB_GetItem("monster", flightdb
[k
].mid
, true, true)
94 flightmasters
[k
] = QuestHelper
:CreateTable("flightmaster cachey")
95 for tk
, v
in pairs(fmx
.loc
[1]) do
96 if not tk
:match("__.*") then
97 flightmasters
[k
][tk
] = v
98 QuestHelper
:Assert(type(tk
) ~= "table")
99 QuestHelper
:Assert(type(v
) ~= "table")
103 --QuestHelper:TextOut(string.format("Missing flightmaster location for node %d/%s", k, tostring(flightdb[k].name)))
107 --QuestHelper:TextOut(string.format("Missing flightmaster for node %d/%s", k, tostring(flightdb[k].name)))
112 for _
, v
in ipairs(imp_flat
) do
113 adjacency
[v
] = adjacency
[v
] or {}
116 for _
, pivot
in ipairs(imp_flat
) do
118 for _
, i
in ipairs(imp_flat
) do
119 for _
, j
in ipairs(imp_flat
) do
120 if adjacency
[i
][pivot
] and adjacency
[pivot
][j
] then
121 local cst
= adjacency
[i
][pivot
].dist
+ adjacency
[pivot
][j
].dist
122 if not adjacency
[i
][j
] or adjacency
[i
][j
].dist
> cst
then
123 if not adjacency
[i
][j
] then adjacency
[i
][j
] = {} end
124 adjacency
[i
][j
].dist
= cst
125 adjacency
[i
][j
].original
= nil
137 for src
, t
in pairs(adjacency
) do
138 if not clustaken
[src
] then
142 table.insert(ctd
, src
)
145 local ite
= table.remove(ctd
)
146 QuestHelper
: Assert(not clustaken
[ite
] or tcst
[ite
])
148 if not tcst
[ite
] then
149 clustaken
[ite
] = true
151 for _
, dst
in pairs(imp_flat
) do
152 if adjacency
[ite
][dst
] and not tcst
[dst
] then
153 table.insert(ctd
, dst
)
161 --QuestHelper: TextOut(string.format("Starting with %d, cluster of %d", src, tcct))
166 QH_Graph_Plane_Destroylinks("flightpath")
169 QH_Flight_Distances
= {}
171 for src
, t
in pairs(adjacency
) do
173 for dest
, dat
in pairs(t
) do
175 local fms
= flightmasters
[src
]
176 local fmd
= flightmasters
[dest
]
178 QuestHelper
: Assert(fms
.c
and (fms
.c
== fmd
.c
))
179 QuestHelper
: Assert(fms
.rc
and (fms
.rc
== fmd
.rc
))
184 local sname
= flightdb
[src
].name
185 local dname
= flightdb
[dest
].name
187 if not QH_Flight_Distances
[sname
] then QH_Flight_Distances
[sname
] = {} end
188 QuestHelper
: Assert(not QH_Flight_Distances
[sname
][dname
])
189 QH_Flight_Distances
[sname
][dname
] = {adjacency
[src
][dest
].dist
, not adjacency
[src
][dest
].original
}
192 if dat
.original
and not (src
> dest
and adjacency
[dest
][src
] and adjacency
[dest
][src
].original
) then
193 local fms
= flightmasters
[src
]
194 local fmd
= flightmasters
[dest
]
196 QuestHelper
: Assert(fms
.c
and (fms
.c
== fmd
.c
))
197 QuestHelper
: Assert(fms
.rc
and (fms
.rc
== fmd
.rc
))
199 local snode
= {x
= fms
.x
, y
= fms
.y
, c
= fms
.c
, p
= QuestHelper_IndexLookup
[fms
.rc
][fms
.rz
], map_desc
= {QHFormat("WAYPOINT_REASON", QHFormat("FLIGHT_POINT", flightdb
[dest
].name
))}, condense_class
= "flightpath"}
200 local dnode
= {x
= fmd
.x
, y
= fmd
.y
, c
= fmd
.c
, p
= QuestHelper_IndexLookup
[fmd
.rc
][fmd
.rz
], map_desc
= {QHFormat("WAYPOINT_REASON", QHFormat("FLIGHT_POINT", flightdb
[src
].name
))}, condense_class
= "flightpath"}
202 local ret
= adjacency
[dest
][src
] and adjacency
[dest
][src
].original
and adjacency
[dest
][src
].dist
203 QH_Graph_Plane_Makelink("flightpath", snode
, dnode
, dat
.dist
, ret
)
209 for _
, v
in pairs(flightdb
) do
212 for _
, v
in pairs(flightmasters
) do
213 QuestHelper
:ReleaseTable(v
)