local worldWidth, worldHeight, x, y, z, width, height, avoidance, name, policy, areaType
local specialAreaRect = {}
local innerRect = {}
function gettilepos(x, y, z)
local tile = getobjectarea(x, y, z)
if tile == nil then
local xDiff, yDiff = x - $posx, y - $posy
if math.abs($posx - x) <= 7 then
tile = getobjectarea(x, $posy, $posz)
xDiff = 0
elseif math.abs($posy - y) <= 5 then
tile = getobjectarea($posx, y, $posz)
yDiff = 0
else
tile = getobjectarea($posx, $posy, $posz)
end
-- Some strange stuff happens when you go from 0 to -1, so I'm
-- adding this as a precaution.
if tile ~= nil then
local width, height = $worldwin.width, $worldwin.height
local function getAreaRect(x, y, w, h)
local ret = {x = 0, y = 0, w = 0, h = 0}
local topLeftTilePos = gettilepos(x, y, $posz)
local botRightTilePos = gettilepos(x + w - 1, y + h - 1, $posz)
if topLeftTilePos and botRightTilePos then
ret.x = math.max(topLeftTilePos.left, 0)
ret.y = math.max(topLeftTilePos.top, 0)
ret.w = math.min(botRightTilePos.right, worldWidth) - ret.x
ret.h = math.min(botRightTilePos.bottom, worldHeight) - ret.y
end
return ret
end
local function drawInnerRect(areaType, x, y, width, height)
innerRect = {w = 0, h = 0}
if areaType == 'Square (Border Only)' then
innerRect = getAreaRect(x + 1, y + 1, width - 2, height - 2)
elseif areaType == 'Square (Double Border)' then
innerRect = getAreaRect(x + 2, y + 2, width - 4, height - 4)
end
if innerRect.w > 0 and innerRect.h > 0 then
setfillstyle('color', 0xFF000000)
drawroundrect(innerRect.x, innerRect.y, innerRect.w, innerRect.h, 10, 10)
end
end
useworldhud()
init end
worldWidth, worldHeight = $worldwin.width - 2, $worldwin.height - 2
for i=-8,9 do
for j=-6,7 do
local tile = gettile($posx + i, $posy + j, $posz)
for k=1, tile.itemcount do
local tileid = tile.item[k].id
if (tileid == 372) then
local test = gettilepos($posx + i, $posy + j, $posz)
local xpos = tonumber($posx + i)
local ypos = tonumber($posy + j)
local retangulo = getAreaRect(xpos, ypos, 3, 3)
--print(retangulo)