Skip to content

Commit

Permalink
If LH is present, poll it for NPC coords to map for Accept/Turnin obj…
Browse files Browse the repository at this point in the history
…ectives
  • Loading branch information
tekkub committed Apr 28, 2008
1 parent eb2d520 commit 5848953
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
28 changes: 21 additions & 7 deletions Mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ end


local cache = {}
local function MapPoint(zone, x, y, desc)
TourGuide:DebugF(1, "Mapping %q - %s (%.2f, %.2f)", desc, zone, x, y)
local zi, zc = zone and zonei[zone], zone and zonec[zone]
local function MapPoint(zone, x, y, desc, c, z)
TourGuide:DebugF(1, "Mapping %q - %s (%.2f, %.2f)", desc, zone or z, x, y)
local zi, zc = z or zone and zonei[zone], c or zone and zonec[zone]
if not zi then
if zone then TourGuide:PrintF("Cannot find zone %q, using current zone.", zone)
else TourGuide:Print("No zone provided, using current zone.") end
Expand All @@ -22,26 +22,40 @@ local function MapPoint(zone, x, y, desc)
zone = zonenames[zc][zi]
end

if TomTom then table.insert(cache, TomTom:AddZWaypoint(zc, zi, x, y, "[TG] "..desc, false))
if TomTom then table.insert(cache, TomTom:AddZWaypoint(zc, zi, x, y, desc, false))
elseif Cartographer_Waypoints then
local pt = NotePoint:new(zone, x/100, y/100, "[TG] "..desc)
local pt = NotePoint:new(zone, x/100, y/100, desc)
Cartographer_Waypoints:AddWaypoint(pt)
table.insert(cache, pt.WaypointID)
end
end


local temp = {}
function TourGuide:ParseAndMapCoords(note, desc, zone)
function TourGuide:ParseAndMapCoords(action, quest, zone, note, qid)
if TomTom and TomTom.RemoveWaypoint then
while cache[1] do TomTom:RemoveWaypoint(table.remove(cache)) end
elseif Cartographer_Waypoints then
while cache[1] do Cartographer_Waypoints:CancelWaypoint(table.remove(cache)) end
end

if (action == "ACCEPT" or action == "TURNIN") and LightHeaded then self:MapLightHeadedNPC(qid, action, quest) end

if not note then return end

for x,y in note:gmatch(L.COORD_MATCH) do table.insert(temp, tonumber(y)); table.insert(temp, tonumber(x)) end
while temp[1] do MapPoint(zone, table.remove(temp), table.remove(temp), desc) end
while temp[1] do MapPoint(zone, table.remove(temp), table.remove(temp), "[TG] "..quest) end
end


function TourGuide:MapLightHeadedNPC(qid, action, quest)
local npcid, npcname, stype
if action == "ACCEPT" then _, _, _, _, stype, npcname, npcid = LightHeaded:GetQuestInfo(qid)
else _, _, _, _, _, _, _, stype, npcname, npcid = LightHeaded:GetQuestInfo(qid) end
self:Debug(1, "LightHeaded lookup", action, qid, stype, npcname, npcid)
if stype ~= "npc" then return end

local data = LightHeaded:LoadNPCData(tonumber(npcid))
if not data then return end
for zid,x,y in data:gmatch("([^,]+),([^,]+),([^:]+):") do MapPoint(nil, tonumber(x), tonumber(y), "[TG] "..quest.." ("..npcname..")", LightHeaded:WZIDToCZ(tonumber(zid))) end
end
2 changes: 1 addition & 1 deletion StatusFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function TourGuide:UpdateStatusFrame()
-- Mapping
if (TomTom or Cartographer_Waypoints) and (lastmapped ~= quest or lastmappedaction ~= action) then
lastmappedaction, lastmapped = action, quest
self:ParseAndMapCoords(note, quest, zonename) --, zone)
self:ParseAndMapCoords(action, quest, zonename, note, self:GetObjectiveTag("QID", nextstep))
end


Expand Down

0 comments on commit 5848953

Please sign in to comment.