这一串串数字是加密吗
local function p2pOfLand(x1, z1, x2, z2, other_func)if other_func == nil then
other_func = function() return true end
end
if math(math(x1 - x2), 2) + math(math(z1 - z2), 2) <= 1 then
return IsLandTile(TheWorld:GetTileAtPoint(x2, 0, z2)) and other_func({x = x2, z = z2})
else
if not IsLandTile(TheWorld:GetTileAtPoint(x2, 0, z2)) or not other_func({x = x2, z = z2}) then
return false
end
-- 获取直线公式
local a = z2 - z1
local b = x1 - x2
local c = z1 * x2 - z2 * x1
if a == 0 then
local z = z1
local xs = - (b / math(b)) / 2
for x = x1, x2, xs do
if math(math(x - x1), 2) + math(math(z - z1), 2) >= 1 and (not IsLandTile(TheWorld:GetTileAtPoint(x, 0, z)) or not other_func({x = x, z = z})) then
return false
end
end
elseif b == 0 then
local x = x1
local zs = a / math(a) / 2
for z = z1, z2, zs do
if math(math(x - x1), 2) + math(math(z - z1), 2) >= 1 and (not IsLandTile(TheWorld:GetTileAtPoint(x, 0, z)) or not other_func({x = x, z = z})) then
return false
end
end
else
-- 以x增检测
local xs = - (b / math(b)) / 2
for x = x1, x2, xs do
local z = (a * x + c) / b * -1
if math(math(x - x1), 2) + math(math(z - z1), 2) >= 1 and (not IsLandTile(TheWorld:GetTileAtPoint(x, 0, z)) or not other_func({x = x, z = z})) then
return false
end
end
-- 以z增检测
local zs = a / math(a) / 2
for z = z1, z2, zs do
local x = (b * z + c) / a * -1
if math(math(x - x1), 2) + math(math(z - z1), 2) >= 1 and (not IsLandTile(TheWorld:GetTileAtPoint(x, 0, z)) or not other_func({x = x, z = z})) then
return false
end
end
end
return true
end
end
页:
[1]