From 933e67227a4317dea63605e605ea332ee67d47e1 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Wed, 24 Nov 2010 21:42:51 +0000 Subject: [PATCH] Update LibMapData --- libs/LibMapData-1.0/library.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libs/LibMapData-1.0/library.lua b/libs/LibMapData-1.0/library.lua index 82fa48f..28a4547 100644 --- a/libs/LibMapData-1.0/library.lua +++ b/libs/LibMapData-1.0/library.lua @@ -1647,6 +1647,24 @@ function lib:DistanceWithinContinent(srcMap,srcFloor, srcX, srcY, dstMap, dstFlo return (x*x+y*y)^0.5,x,y end +function lib:DistanceAndDirectionWithinContinent(srcMap,srcFloor, srcX, srcY, dstMap, dstFloor, dstX, dstY) + assert(srcFloor == nil or (type(srcFloor) == "number" and srcFloor)) + assert(dstFloor == nil or (type(dstFloor) == "number" and dstFloor)) + if type(dstMap) == "string" then + dstMap = idToMap[dstMap] + end + if type(srcMap) == "string" then + srcMap = idToMap[srcMap] + end + if mapData[srcMap].continent ~= mapData[dstMap].continent then + return 0,0,0 + end + local startX, startY = self:ConvertToContinent(srcMap,srcFloor, srcX, srcY) + local endX, endY = self:ConvertToContinent(dstMap,dstFloor, dstX, dstY) + local x = (endX - startX) + local y = (endY - startY) + return (x*x+y*y)^0.5,x,y +end --- API to convert coords to yards -- @param mapfile or area_id -- @param floor @@ -1871,4 +1889,4 @@ for continent in pairs({GetMapContinents()}) do end end print("All Tests passed") -end \ No newline at end of file +end -- 1.7.9.5