diff --git a/RangeReticle.lua b/RangeReticle.lua
index 442914f..0dc5035 100755
--- a/RangeReticle.lua
+++ b/RangeReticle.lua
@@ -81,6 +81,21 @@ local function RGBPercToHex(r, g, b)
return string.format("%02x%02x%02x", r*255, g*255, b*255)
end
+local function tprint(tbl, indent)
+ if not indent then indent = 0 end
+ for k, v in pairs(tbl) do
+ formatting = string.rep(" ", indent) .. k .. ": "
+ if type(v) == "table" then
+ CHAT_SYSTEM:AddMessage(formatting)
+ tprint(v, indent+1)
+ elseif type(v) == 'boolean' then
+ CHAT_SYSTEM:AddMessage(formatting .. tostring(v))
+ else
+ CHAT_SYSTEM:AddMessage(formatting .. tostring(v))
+ end
+ end
+end
+
-- Setup the addon when it loads
local function AddonSetup()
-- Populate the settings DB
@@ -598,62 +613,63 @@ function OnRangeUpdate()
-- Calculate and display target range
if targetX and targetY then
- -- Default divisor for map types that haven't been calculated yet
- local divisor = mapType * mapWidth
+ -- For debugging map types
+ --[[if true then
+ CHAT_SYSTEM:AddMessage("Width: " .. tostring(mapWidth))
+ CHAT_SYSTEM:AddMessage("Height: " .. tostring(mapHeight))
+ CHAT_SYSTEM:AddMessage("Type: " .. tostring(mapType))
+ CHAT_SYSTEM:AddMessage("Content: " .. tostring(mapContentType))
+ local dimensionsX, dimensionsY = ZO_WorldMapContainer:GetDimensions()
+ CHAT_SYSTEM:AddMessage("WMDimensions: " .. tostring(dimensionsX) .. ', ' .. tostring(dimensionsY))
+ local dimensionsX1, dimensionsY1 = ZO_WorldMapContainer1:GetDimensions()
+ CHAT_SYSTEM:AddMessage("1Dimensions: " .. tostring(dimensionsX1) .. ', ' .. tostring(dimensionsY1))
+ local dimensionsX2, dimensionsY2 = ZO_WorldMapContainer2:GetDimensions()
+ CHAT_SYSTEM:AddMessage("2Dimensions: " .. tostring(dimensionsX2) .. ', ' .. tostring(dimensionsY2))
+ local dimensionsX3, dimensionsY3 = ZO_WorldMapContainer3:GetDimensions()
+ CHAT_SYSTEM:AddMessage("3Dimensions: " .. tostring(dimensionsX3) .. ', ' .. tostring(dimensionsY3))
+ local dimensionsX4, dimensionsY4 = ZO_WorldMapContainer4:GetDimensions()
+ CHAT_SYSTEM:AddMessage("4Dimensions: " .. tostring(dimensionsX4) .. ', ' .. tostring(dimensionsY4))
+
+ CHAT_SYSTEM:AddMessage("Self: " .. tostring(selfX) .. ', ' .. tostring(selfY))
+ CHAT_SYSTEM:AddMessage("Target: " .. tostring(targetX) .. ', ' .. tostring(targetY))
+
+ --local mdata = getmetatable(ZO_WorldMapContainer1)
+ --local mdata = getmetatable(ZO_WorldMapContainer)
+ --tprint(mdata)
+ CHAT_SYSTEM:AddMessage("H: " .. tostring(ZO_WorldMapContainer:GetHeight())) --405
+ CHAT_SYSTEM:AddMessage("W: " .. tostring(ZO_WorldMapContainer:GetWidth())) --405
+
+ CHAT_SYSTEM:AddMessage("ZIndex: " .. tostring(GetCurrentMapZoneIndex()))
+ end]]
+
+ local dimensionsX, dimensionsY = ZO_WorldMapContainer:GetDimensions()
+ local multiplier = 5.0
if mapContentType == MAP_CONTENT_NONE then
if mapType == MAPTYPE_SUBZONE then
- divisor = 14.5
- -- 5,5 (vulkhel) = 15
- -- 5,5 (skywatch) = 14
elseif mapType == MAPTYPE_ZONE then
- divisor = 2.9
- -- 3,3 (bleakrock) = 2.9
- -- 2,2 (stonefalls) = 2.9
- -- 2,2 (auridon) = 2.5
- -- 2,2 (harborage) = broken
end
elseif mapContentType == MAP_CONTENT_AVA then
if mapType == MAPTYPE_SUBZONE then
- divisor = 16
- -- 5,5 (eastern elsweyr) = 16?
elseif mapType == MAPTYPE_ZONE then
- divisor = 1.0
- -- 5,5 (cyrodiil) = 1.0
+ multiplier = 12.0
end
elseif mapContentType == MAP_CONTENT_DUNGEON then
if mapType == MAPTYPE_SUBZONE then
- divisor = 21
- -- 3,3 (elden hollow) = 21
+ dimensionsX, dimensionsY = ZO_WorldMapContainer1:GetDimensions()
+ multiplier = 1.0
elseif mapType == MAPTYPE_ZONE then
- divisor = 26
end
end
-
- -- For debugging map types
- --if divisor == -1 then
- if true then
- CHAT_SYSTEM:AddMessage("Width: " .. tostring(mapWidth))
- CHAT_SYSTEM:AddMessage("Height: " .. tostring(mapHeight))
- CHAT_SYSTEM:AddMessage("Type: " .. tostring(mapType))
- CHAT_SYSTEM:AddMessage("Content: " .. tostring(mapContentType))
- local dimensionsX, dimensionsY = ZO_WorldMapContainer1:GetTextureFileDimensions()
- CHAT_SYSTEM:AddMessage("Dimensions: " .. tostring(dimensionsX) .. ', ' .. tostring(dimensionsY))
- CHAT_SYSTEM:AddMessage("Self: " .. tostring(selfX) .. ', ' .. tostring(selfY))
- CHAT_SYSTEM:AddMessage("Target: " .. tostring(targetX) .. ', ' .. tostring(targetY))
- --local actualSelfX = selfX * dimensionsX * mapWidth
- --local actualSelfY = selfY * dimensionsY * mapHeight
- --local actualTargetX = targetX * dimensionsX * mapWidth
- --local actualTargetY = targetY * dimensionsY * mapHeight
- --local dist = math.sqrt(math.pow((actualSelfX - actualTargetX), 2) + math.pow((actualSelfY - actualTargetY), 2))
- --CHAT_SYSTEM:AddMessage("Dist: " .. tostring(dist))
- end
-
- local dist = math.sqrt(math.pow((selfX - targetX) / divisor, 2) + math.pow((selfY - targetY) / divisor, 2))
- distance = math.floor((dist * 10000) - 0.5)
+ local actualSelfX = selfX * dimensionsX
+ local actualSelfY = selfY * dimensionsY
+ local actualTargetX = targetX * dimensionsX
+ local actualTargetY = targetY * dimensionsY
+ local dist = math.sqrt(math.pow((actualSelfX - actualTargetX), 2) + math.pow((actualSelfY - actualTargetY), 2)) * multiplier
+ distance = math.floor(dist + 0.5)
-- Disable range functionality when a zone isn't working with range calculation
- if distance > 200 then
+ if distance > 100 then
distance = -999
end
@@ -665,6 +681,8 @@ function OnRangeUpdate()
end
if rangeEnabled and distance >= 0 then
RangeReticleRange:SetText(tostring(distance) .. 'm')
+ elseif rangeEnabled then
+ RangeReticleRange:SetText('e')
end
end
end
diff --git a/RangeReticle.txt b/RangeReticle.txt
index bcd54b8..ba148c2 100755
--- a/RangeReticle.txt
+++ b/RangeReticle.txt
@@ -1,5 +1,5 @@
## Title: Range Reticle - by Adein
-## APIVersion: 100003
+## APIVersion: 100004
## Version: @project-version@
## Author: Adein
## OptionalDependsOn: LibAddonMenu-1.0