--- Determines whether a given waypoint is a priest of Mondain.
--- @param waypointId is the waypointId in the UO database. valid values are 1 through WindowData.WaypointList.waypointCount
--- @return true if the waypointId is associated with a Priest of Mondain. false otherwise
function MapCommon.isPOM(waypointId)
local wptype, wpflags, wpname = UOGetWaypointInfo(waypointId)
return (string.find(tostring(wpname), "priest of Mondain") and (wptype == 6)) and true or false
end
--- Deletes a PoMwaypoint and removes the associated field from the waypoint-to-POMwaypoint List (MapCommon.POMList)
-- @param wayPointId is the waypointId in the UO database. valid values are 1 through WindowData.WaypointList.waypointCount
-- @return no return
function MapCommon.handleOldPOM(waypointId)
local pomid = MapCommon.POMList[waypointId] --Get the associated POMwaypointId (if it exists)
if pomid ~= nil then -- if the POMwaypointId exists, the two waypoints are associated, and the POM one needs to be deleted
UODeleteUserWaypoint(pomid) -- delete the waypoint
MapCommon.POMList[waypointId] = nil --remove the waypoint's entry from the POMList
end
end
--- Creates a data table to hold the information for a new POM waypoint
-- @param data is the data table of the system-generated waypoint. It will be parsed to build a new waypoint for the priest of Mondain
-- @return pomdata is a table containing the necessar information to create a UserWaypoint for the priest of Mondain. pomdata = {"type","flags","name","facet","x","y","z","icon","scale"}
function MapCommon.buildPOMWaypointData(waypointId)
--begin data fetching
local pomtype, pomflags, pomname, pomfacet, pomx, pomy, pomz = UOGetWaypointInfo(waypointId)
local facet = UOGetRadarFacet()
local area = UOGetRadarArea()
local data = MapCommon.GetWPDataFromString(pomname, pomtype, pomfacet, facet, area) --needed to get the icon and scale
local pomicon = data.icon
local pomiconScale = data.scale
pomtype = MapCommon.WaypointCustomType --this will be a User waypoint (i.e. type 15)
pomdata = {}
pomdata.type = pomtype --number
pomdata.flags = pomflags --number
pomdata.name = pomname --wstring
pomdata.facet = pomfacet --number
pomdata.x = pomx --number
pomdata.y = pomy --number
pomdata.z = pomz --number
pomdata.icon = pomicon --string
pomdata.scale = pomiconScale --number
return pomdata
end
--- Creates a UserWaypoint containing the pom data and then returns the newly created waypointId
-- @param pomData contains the following information: {"type","flags","name","facet","x","y","z","icon","scale"} it is built by MapCommon.buildPOMWaypointData()
-- @return the waypointId for the newly created UserWaypoint representing the priest of Mondain
function MapCommon.CreateNewPOMWaypoint(pomData)
--/script Debug.Print ( PackBytes ( type(pomData.name), type(L"_ICON_"), type(pomData.icon), type(L"_SCALE_"), type(pomData.scale)))
--create the waypoint
UOCreateUserWaypoint( pomData.type, pomData.x, pomData.y, pomData.facet, pomData.name .. L"_ICON_" .. towstring(pomData.icon) .. L"_SCALE_" .. pomData.scale)
-get the waypointId
for i = WindowData.WaypointList.waypointCount, 1 do
if wstring.find(PackBytes(UOGetWaypointInfo(i))[3], pomData.name) ~= nil then --if the first part of the waypoint matches the POMname it's the one we're looking for
return i
end
end
end
--- Updates the PomList to include the new pom waypoint. These must be associate for the pom waypoints to work
-- @param waypointId is the systemgenerated waypoint Id for the priest of Mondain
-- @param pomId is the Usercreated waypoint for the priest of Mondain associated with the waypointId
function MapCommon.addToPOMList(waypointId,pomId)
MapCommon.PomList[waypointId] = pomId
end