1 QuestHelper_File
["collect_flight.lua"] = "Development Version"
2 QuestHelper_Loadtime
["collect_flight.lua"] = GetTime()
4 local debug_output
= false
5 if QuestHelper_File
["collect_flight.lua"] == "Development Version" then debug_output
= true end
13 local function GetRoute(currentname
, endnode
)
14 local path
= currentname
.. "@@" .. TaxiNodeName(endnode
)
16 local links
= GetNumRoutes(endnode
)
17 if links
> 50 then -- links is apparently sometimes 999998. Why? I could not say. It is a mystery. Hopefully this will show up in the datafiles and I'll be able to debug it.
18 return path
, string.format("@@@ WACKYLAND %s %d @@@", TaxiNodeGetType(endnode
), links
)
22 for j
= 1, links
- 1 do
23 if #route
> 0 then route
= route
.. "@@" end
24 route
= route
.. string.format("%f:%f", TaxiGetDestX(endnode
, j
), TaxiGetDestY(endnode
, j
))
30 local function GetCurrentname()
31 QuestHelper
: Assert(NumTaxiNodes() < 150, tostring(NumTaxiNodes())) -- hmm what
32 for i
= 1, NumTaxiNodes() do if TaxiNodeGetType(i
) == "CURRENT" then return TaxiNodeName(i
) end end
39 local real_TakeTaxiNode
= TakeTaxiNode
40 TakeTaxiNode
= function(id
)
41 path
, route
= GetRoute(GetCurrentname(), id
)
45 start_time
= GetTime()
50 local function TaximapOpened()
51 -- Figure out who we have targeted and what our location name is
52 local currentname
= GetCurrentname()
53 if not currentname
then return end -- must not actually have opened the map
55 QuestHelper
: Assert(NumTaxiNodes() < 100)
56 for i
= 1, NumTaxiNodes() do
57 local name
, type = TaxiNodeName(i
), TaxiNodeGetType(i
)
58 if not QHCFM
[name
] then QHCFM
[name
] = {} end
59 QHCFM
[name
].x
, QHCFM
[name
].y
= TaxiNodePosition(i
)
60 if type == "CURRENT" then
61 local guid
= UnitGUID("target")
62 if guid
and IsMonsterGUID(guid
) then QHCFM
[name
].master
= GetMonsterType(guid
) end
65 if type ~= "CURRENT" then
66 local path
, route
= GetRoute(currentname
, i
)
67 if not QHCFT
[path
] then QHCFT
[path
] = {} end
68 if not QHCFT
[path
][route
] then QHCFT
[path
][route
] = true end
73 local function OnUpdate()
74 if UnitOnTaxi("player") then
75 if phase
== "PENDING" then
76 start_time
= GetTime()
80 if phase
== "PENDING" then
81 if GetTime() > start_time
+ 5 then -- something has gone wrong, abort
83 path
, route
, start_time
= nil, nil, nil
85 elseif phase
== "FLYING" then
87 QHCFT
[path
][route
] = (type(QHCFT
[path
][route
]) == "number" and QHCFT
[path
][route
] or 0) + (GetTime() - start_time
)
88 QHCFT
[path
][route
.. "##count"] = (QHCFT
[path
][route
.. "##count"] or 0) + 1
90 path
, route
, start_time
= nil, nil, nil
95 function QH_Collect_Flight_Init(QHCData
, API
)
96 if not QHCData
.flight_master
then QHCData
.flight_master
= {} end
97 if not QHCData
.flight_times
then QHCData
.flight_times
= {} end
98 QHCFM
, QHCFT
= QHCData
.flight_master
, QHCData
.flight_times
100 IsMonsterGUID
= API
.Utility_IsMonsterGUID
101 GetMonsterType
= API
.Utility_GetMonsterType
102 QuestHelper
: Assert(IsMonsterGUID
)
103 QuestHelper
: Assert(GetMonsterType
)
105 QH_Event("TAXIMAP_OPENED", TaximapOpened
)
107 API
.Registrar_OnUpdateHook(OnUpdate
)