|
|
|
@ -207,10 +207,13 @@ end |
|
|
|
|
---@param unit Bastion.Unit |
|
|
|
|
---@return number |
|
|
|
|
function Unit:GetDistance(unit) |
|
|
|
|
local pself = self:GetPosition() |
|
|
|
|
local punit = unit:GetPosition() |
|
|
|
|
--local pself = self:GetPosition() |
|
|
|
|
--local punit = unit:GetPosition() |
|
|
|
|
|
|
|
|
|
return pself:Distance(punit) |
|
|
|
|
--return pself:Distance(punit) |
|
|
|
|
local x1, y1, z1 = ObjectPosition(self:GetOMToken()) |
|
|
|
|
local x2, y2, z2 = ObjectPosition(unit:GetOMToken()) |
|
|
|
|
return FastDistance(x1, y1, z1, x2, y2, z2) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Is the unit dead |
|
|
|
@ -335,6 +338,7 @@ end |
|
|
|
|
|
|
|
|
|
---@return number | boolean |
|
|
|
|
function Unit:GetSpecializationID() |
|
|
|
|
---@diagnostic disable-next-line: redundant-parameter |
|
|
|
|
if CanInspect(self:GetOMToken(), false) then |
|
|
|
|
return ObjectSpecializationID(self:GetOMToken()) |
|
|
|
|
end |
|
|
|
@ -395,7 +399,25 @@ local isClassicWow = select(4, GetBuildInfo()) < 40000 |
|
|
|
|
-- return UnitInMelee(self:GetOMToken(), unit:GetOMToken()) |
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
local losFlag = bit.bor(0x1, 0x10) |
|
|
|
|
local flags = { |
|
|
|
|
M2Collision = 0x1, |
|
|
|
|
M2Render = 0x2, |
|
|
|
|
WMOCollision = 0x10, |
|
|
|
|
WMORender = 0x20, |
|
|
|
|
Terrain = 0x100, |
|
|
|
|
WaterWalkableLiquid = 0x10000, |
|
|
|
|
Liquid = 0x20000, |
|
|
|
|
EnityCollision = 0x100000, |
|
|
|
|
Unknown = 0x200000, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
local losFlag = bit.bor(flags.M2Collision, flags.WMOCollision, flags.Terrain) |
|
|
|
|
|
|
|
|
|
---@param attachmentId number |
|
|
|
|
function Unit:GetAttachmentPosition(attachmentId) |
|
|
|
|
local x, y, z = GetUnitAttachmentPosition(self:GetOMToken(), attachmentId) |
|
|
|
|
return Bastion.Vector3:New(x, y, z) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Check if the unit can see another unit |
|
|
|
|
---@param unit Bastion.Unit |
|
|
|
@ -419,12 +441,12 @@ function Unit:CanSee(unit) |
|
|
|
|
local ignoreLoS = { |
|
|
|
|
[98696] = true -- Illysanna Ravencrest (BRH) |
|
|
|
|
} |
|
|
|
|
if not unit:IsPlayer() then |
|
|
|
|
--[[ if not unit:IsPlayer() then |
|
|
|
|
local id = unit:GetID() |
|
|
|
|
if id and ignoreLoS[id] then |
|
|
|
|
return true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end ]] |
|
|
|
|
local ax, ay, az = ObjectPosition(self:GetOMToken()) |
|
|
|
|
local ah = ObjectHeight(self:GetOMToken()) |
|
|
|
|
local attx, atty, attz = GetUnitAttachmentPosition(unit:GetOMToken(), 34) |
|
|
|
@ -445,7 +467,7 @@ function Unit:CanSee(unit) |
|
|
|
|
return false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local x, y, z = TraceLine(ax, ay, az + ah, attx, atty, attz, losFlag) |
|
|
|
|
local x, y, z = TraceLine(ax, ay, az + ah, attx, atty, attz, 0) |
|
|
|
|
if x ~= 0 or y ~= 0 or z ~= 0 then |
|
|
|
|
return false |
|
|
|
|
else |
|
|
|
|