|
|
@ -60,7 +60,7 @@ function Unit:__tostring() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Constructor |
|
|
|
-- Constructor |
|
|
|
---@param unit TinkrObjectReference |
|
|
|
---@param unit? TinkrObjectReference |
|
|
|
---@return Unit |
|
|
|
---@return Unit |
|
|
|
function Unit:New(unit) |
|
|
|
function Unit:New(unit) |
|
|
|
local self = setmetatable({}, Unit) |
|
|
|
local self = setmetatable({}, Unit) |
|
|
@ -214,6 +214,17 @@ function Unit:IsPet() |
|
|
|
return UnitIsUnit(self:GetOMToken(), "pet") |
|
|
|
return UnitIsUnit(self:GetOMToken(), "pet") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Unit:IsOtherPet() |
|
|
|
|
|
|
|
local petName = self:GetName() |
|
|
|
|
|
|
|
local ownerName = "" |
|
|
|
|
|
|
|
ownerName = ( |
|
|
|
|
|
|
|
string.match(petName, string.gsub(UNITNAME_TITLE_PET, "%%s", "(%.*)")) |
|
|
|
|
|
|
|
or string.match(petName, string.gsub(UNITNAME_TITLE_MINION, "%%s", "(%.*)")) |
|
|
|
|
|
|
|
or string.match(petName, string.gsub(UNITNAME_TITLE_GUARDIAN, "%%s", "(%.*)")) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
return ownerName ~= nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Is the unit a friendly unit |
|
|
|
-- Is the unit a friendly unit |
|
|
|
---@return boolean |
|
|
|
---@return boolean |
|
|
|
function Unit:IsFriendly() |
|
|
|
function Unit:IsFriendly() |
|
|
@ -300,6 +311,29 @@ function Unit:IsDamage() |
|
|
|
return UnitGroupRolesAssigned(self:GetOMToken()) == "DAMAGER" |
|
|
|
return UnitGroupRolesAssigned(self:GetOMToken()) == "DAMAGER" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Get the units role |
|
|
|
|
|
|
|
---@return "TANK" | "HEALER" | "DAMAGER" |
|
|
|
|
|
|
|
function Unit:GetRole() |
|
|
|
|
|
|
|
return UnitGroupRolesAssigned(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Unit:GetSpecializationID() |
|
|
|
|
|
|
|
if CanInspect(self:GetOMToken(), false) then |
|
|
|
|
|
|
|
return ObjectSpecializationID(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param fallback? boolean |
|
|
|
|
|
|
|
---@return "TANK" | "HEALER" | "DAMAGER" | false |
|
|
|
|
|
|
|
function Unit:GetSpecializationRole(fallback) |
|
|
|
|
|
|
|
local specID = self:GetSpecializationID() |
|
|
|
|
|
|
|
if specID then |
|
|
|
|
|
|
|
return GetSpecializationRoleByID(specID) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
return fallback and self:GetRole() or false |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Is the unit a player |
|
|
|
-- Is the unit a player |
|
|
|
---@return boolean |
|
|
|
---@return boolean |
|
|
|
function Unit:IsPlayer() |
|
|
|
function Unit:IsPlayer() |
|
|
@ -344,6 +378,109 @@ local isClassicWow = select(4, GetBuildInfo()) < 40000 |
|
|
|
-- return UnitInMelee(self:GetOMToken(), unit:GetOMToken()) |
|
|
|
-- return UnitInMelee(self:GetOMToken(), unit:GetOMToken()) |
|
|
|
-- end |
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 1048593 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local losBlacklist = { |
|
|
|
|
|
|
|
[131863] = true, -- Raal the Gluttonous (WCM) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local AttachmentPoisitions = { |
|
|
|
|
|
|
|
MountMain = 0, |
|
|
|
|
|
|
|
HandRight = 1, |
|
|
|
|
|
|
|
HandLeft = 2, |
|
|
|
|
|
|
|
ElbowRight = 3, |
|
|
|
|
|
|
|
ElbowLeft = 4, |
|
|
|
|
|
|
|
ShoulderRight = 5, |
|
|
|
|
|
|
|
ShoulderLeft = 6, |
|
|
|
|
|
|
|
KneeRight = 7, |
|
|
|
|
|
|
|
KneeLeft = 8, |
|
|
|
|
|
|
|
HipRight = 9, |
|
|
|
|
|
|
|
HipLeft = 10, |
|
|
|
|
|
|
|
Helm = 11, |
|
|
|
|
|
|
|
Back = 12, |
|
|
|
|
|
|
|
ShoulderFlapRight = 13, |
|
|
|
|
|
|
|
ShoulderFlapLeft = 14, |
|
|
|
|
|
|
|
ChestBloodFront = 15, |
|
|
|
|
|
|
|
ChestBloodBack = 16, |
|
|
|
|
|
|
|
Breath = 17, |
|
|
|
|
|
|
|
PlayerName = 18, |
|
|
|
|
|
|
|
Base = 19, |
|
|
|
|
|
|
|
Head = 20, |
|
|
|
|
|
|
|
SpellLeftHand = 21, |
|
|
|
|
|
|
|
SpellRightHand = 22, |
|
|
|
|
|
|
|
Special1 = 23, |
|
|
|
|
|
|
|
Special2 = 24, |
|
|
|
|
|
|
|
Special3 = 25, |
|
|
|
|
|
|
|
SheathMainHand = 26, |
|
|
|
|
|
|
|
SheathOffHand = 27, |
|
|
|
|
|
|
|
SheathShield = 28, |
|
|
|
|
|
|
|
PlayerNameMounted = 29, |
|
|
|
|
|
|
|
LargeWeaponLeft = 30, |
|
|
|
|
|
|
|
LargeWeaponRight = 31, |
|
|
|
|
|
|
|
HipWeaponLeft = 32, |
|
|
|
|
|
|
|
HipWeaponRight = 33, |
|
|
|
|
|
|
|
Chest = 34, |
|
|
|
|
|
|
|
HandArrow = 35, |
|
|
|
|
|
|
|
Bullet = 36, |
|
|
|
|
|
|
|
SpellHandOmni = 37, |
|
|
|
|
|
|
|
SpellHandDirected = 38, |
|
|
|
|
|
|
|
VehicleSeat1 = 39, |
|
|
|
|
|
|
|
VehicleSeat2 = 40, |
|
|
|
|
|
|
|
VehicleSeat3 = 41, |
|
|
|
|
|
|
|
VehicleSeat4 = 42, |
|
|
|
|
|
|
|
VehicleSeat5 = 43, |
|
|
|
|
|
|
|
VehicleSeat6 = 44, |
|
|
|
|
|
|
|
VehicleSeat7 = 45, |
|
|
|
|
|
|
|
VehicleSeat8 = 46, |
|
|
|
|
|
|
|
LeftFoot = 47, |
|
|
|
|
|
|
|
RightFoot = 48, |
|
|
|
|
|
|
|
ShieldNoGlove = 49, |
|
|
|
|
|
|
|
SpinLow = 50, |
|
|
|
|
|
|
|
AlteredShoulderR = 51, |
|
|
|
|
|
|
|
AlteredShoulderL = 52, |
|
|
|
|
|
|
|
BeltBuckle = 53, |
|
|
|
|
|
|
|
SheathCrossbow = 54, |
|
|
|
|
|
|
|
HeadTop = 55, |
|
|
|
|
|
|
|
VirtualSpellDirected = 56, |
|
|
|
|
|
|
|
Backpack = 57, |
|
|
|
|
|
|
|
Unknown = 60, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--[[ |
|
|
|
|
|
|
|
M2Collision = 1, -- 0x1 |
|
|
|
|
|
|
|
M2Render = 2, -- 0x2 |
|
|
|
|
|
|
|
WMOCollision = 16, -- 0x10 |
|
|
|
|
|
|
|
WMORender = 32, -- 0x20 |
|
|
|
|
|
|
|
Terrain = 256, -- 0x100 |
|
|
|
|
|
|
|
WaterWalkableLiquid = 65536, -- 0x10000 |
|
|
|
|
|
|
|
Liquid = 131072, -- 0x20000 |
|
|
|
|
|
|
|
WaterOrLiquid = 196608, -- 0x30000 |
|
|
|
|
|
|
|
EntityCollision = 1048576, -- 0x100000 |
|
|
|
|
|
|
|
Most = 1048849, -- 0x100201 |
|
|
|
|
|
|
|
Unknown = 2097152, -- 0x200000 |
|
|
|
|
|
|
|
All = 3211571, -- 0x310003 |
|
|
|
|
|
|
|
]] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--[[ |
|
|
|
|
|
|
|
public enum IntersectFlags { |
|
|
|
|
|
|
|
None, |
|
|
|
|
|
|
|
DoodadCollision = 0x00000001, |
|
|
|
|
|
|
|
DoodadRender = 0x00000002, |
|
|
|
|
|
|
|
WmoCollision = 0x00000010, |
|
|
|
|
|
|
|
WmoRender = 0x00000020, |
|
|
|
|
|
|
|
WmoNoCamCollision = 0x00000040, |
|
|
|
|
|
|
|
Terrain = 0x00000100, |
|
|
|
|
|
|
|
IgnoreWmoDoodad = 0x00002000, |
|
|
|
|
|
|
|
LiquidWaterWalkable = 0x00010000, |
|
|
|
|
|
|
|
LiquidAll = 0x00020000, |
|
|
|
|
|
|
|
Cull = 0x00080000, |
|
|
|
|
|
|
|
EntityCollision = 0x00100000, |
|
|
|
|
|
|
|
EntityRender = 0x00200000, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collision = DoodadCollision | WmoCollision | Terrain | EntityCollision, |
|
|
|
|
|
|
|
LineOfSight = WmoCollision | EntityCollision |
|
|
|
|
|
|
|
]] |
|
|
|
|
|
|
|
|
|
|
|
--[[ |
|
|
|
--[[ |
|
|
|
M2Collision = 0x1 |
|
|
|
M2Collision = 0x1 |
|
|
|
M2Render = 0x2 |
|
|
|
M2Render = 0x2 |
|
|
@ -352,45 +489,49 @@ local isClassicWow = select(4, GetBuildInfo()) < 40000 |
|
|
|
Terrain = 0x100 |
|
|
|
Terrain = 0x100 |
|
|
|
WaterWalkableLiquid = 0x10000 |
|
|
|
WaterWalkableLiquid = 0x10000 |
|
|
|
Liquid = 0x20000 |
|
|
|
Liquid = 0x20000 |
|
|
|
|
|
|
|
WaterOrLiquid = 0x30000, |
|
|
|
EntityCollision = 0x100000 |
|
|
|
EntityCollision = 0x100000 |
|
|
|
Unknown = 0x200000 |
|
|
|
Most = 0x100201, |
|
|
|
|
|
|
|
Unknown = 0x200000, |
|
|
|
|
|
|
|
All = 0x310003, |
|
|
|
]] |
|
|
|
]] |
|
|
|
|
|
|
|
|
|
|
|
local losFlag = bit.bor(0x1, 0x10, 0x100000) |
|
|
|
local attachmentOverride = { |
|
|
|
|
|
|
|
[131863] = AttachmentPoisitions.Head, -- WCM Raal the Gluttonous |
|
|
|
-- Check if the unit can see another unit |
|
|
|
|
|
|
|
---@param unit Unit |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
|
|
|
|
function Unit:CanSee(unit) |
|
|
|
|
|
|
|
local ax, ay, az = ObjectPosition(self:GetOMToken()) |
|
|
|
|
|
|
|
local ah = ObjectHeight(self:GetOMToken()) |
|
|
|
|
|
|
|
local attx, atty, attz = GetUnitAttachmentPosition(unit:GetOMToken(), 18) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local alwaysLos = { |
|
|
|
|
|
|
|
[189727] = true, -- Khajin the Unyielding |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
--if alwaysLos[unit:GetID()] then |
|
|
|
function Unit:GetHitSphere() |
|
|
|
--return true |
|
|
|
--local srcX, srcY, srcZ = GetUnitAttachmentPosition(self:GetOMToken(), attachmentOverride[self:GetID()] or AttachmentPoisitions.PlayerName) |
|
|
|
--end |
|
|
|
--local srcHeight = UnitIsMounted(self:GetOMToken()) and 3.081099 or 2.43808 |
|
|
|
|
|
|
|
return Bastion.Vector3:New(GetUnitAttachmentPosition(self:GetOMToken(), attachmentOverride[self:GetID()] or AttachmentPoisitions.PlayerName)) |
|
|
|
if not attx or not ax then |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if not ah then |
|
|
|
function Unit:GetLOSSourcePosition() |
|
|
|
return false |
|
|
|
local src = self:GetPosition() |
|
|
|
|
|
|
|
src.z = UnitIsMounted(self:GetOMToken()) and 3.081099 or 2.43808 |
|
|
|
|
|
|
|
return src |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if (ax == 0 and ay == 0 and az == 0) or (attx == 0 and atty == 0 and attz == 0) then |
|
|
|
local losFlag = bit.bor(0x10) |
|
|
|
|
|
|
|
-- Check if the unit can see another unit |
|
|
|
|
|
|
|
---@param targetUnit Unit |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
|
|
|
|
function Unit:CanSee(targetUnit) |
|
|
|
|
|
|
|
local npcId = targetUnit:GetID() |
|
|
|
|
|
|
|
if npcId and losBlacklist[npcId] then |
|
|
|
return true |
|
|
|
return true |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if not attx or not ax then |
|
|
|
local src = self:GetLOSSourcePosition() |
|
|
|
return false |
|
|
|
local dst = targetUnit:GetHitSphere() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (src.x == 0 and src.y == 0 and src.z == 0) or (dst.x == 0 and dst.y == 0 and dst.z == 0) then |
|
|
|
|
|
|
|
return true |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local x, y, z = TraceLine(ax, ay, az + ah, attx, atty, attz, losFlag) |
|
|
|
local contactPoint = src + (dst - src):directionOrZero() * math.min(targetUnit:GetDistance(self), self:GetCombatReach()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local x, y, z = TraceLine(src.x, src.y, src.z, contactPoint.x, contactPoint.y, contactPoint.z, losFlag) |
|
|
|
if x ~= 0 or y ~= 0 or z ~= 0 then |
|
|
|
if x ~= 0 or y ~= 0 or z ~= 0 then |
|
|
|
return false |
|
|
|
return false |
|
|
|
else |
|
|
|
else |
|
|
@ -405,12 +546,10 @@ function Unit:IsCasting() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Unit:GetTimeCastIsAt(percent) |
|
|
|
function Unit:GetTimeCastIsAt(percent) |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self:GetOMToken()) |
|
|
|
UnitCastingInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not name then |
|
|
|
if not name then |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self:GetOMToken()) |
|
|
|
UnitChannelInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if name and startTimeMS and endTimeMS then |
|
|
|
if name and startTimeMS and endTimeMS then |
|
|
@ -427,12 +566,10 @@ end |
|
|
|
-- Get Casting or channeling spell |
|
|
|
-- Get Casting or channeling spell |
|
|
|
---@return Spell | nil |
|
|
|
---@return Spell | nil |
|
|
|
function Unit:GetCastingOrChannelingSpell() |
|
|
|
function Unit:GetCastingOrChannelingSpell() |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self:GetOMToken()) |
|
|
|
UnitCastingInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not name then |
|
|
|
if not name then |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self:GetOMToken()) |
|
|
|
UnitChannelInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if name then |
|
|
|
if name then |
|
|
@ -445,12 +582,10 @@ end |
|
|
|
-- Get the end time of the cast or channel |
|
|
|
-- Get the end time of the cast or channel |
|
|
|
---@return number |
|
|
|
---@return number |
|
|
|
function Unit:GetCastingOrChannelingEndTime() |
|
|
|
function Unit:GetCastingOrChannelingEndTime() |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self:GetOMToken()) |
|
|
|
UnitCastingInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not name then |
|
|
|
if not name then |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self:GetOMToken()) |
|
|
|
UnitChannelInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if name then |
|
|
|
if name then |
|
|
@ -472,6 +607,15 @@ function Unit:IsCastingOrChanneling() |
|
|
|
return self:IsCasting() or self:IsChanneling() |
|
|
|
return self:IsCasting() or self:IsChanneling() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Unit:CastTarget() |
|
|
|
|
|
|
|
return self:IsCastingOrChanneling() and Bastion.UnitManager:Get(ObjectCastingTarget(self:GetOMToken())) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param unit Unit |
|
|
|
|
|
|
|
function Unit:CastTargetIsUnit(unit) |
|
|
|
|
|
|
|
return self:IsCastingOrChanneling() and self:CastTarget():IsUnit(unit) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Unit:IsImmobilized() |
|
|
|
function Unit:IsImmobilized() |
|
|
|
return bit.band(self:GetMovementFlag(), 0x400) > 0 |
|
|
|
return bit.band(self:GetMovementFlag(), 0x400) > 0 |
|
|
|
end |
|
|
|
end |
|
|
@ -485,12 +629,10 @@ end |
|
|
|
|
|
|
|
|
|
|
|
---@return number |
|
|
|
---@return number |
|
|
|
function Unit:GetChannelOrCastPercentComplete() |
|
|
|
function Unit:GetChannelOrCastPercentComplete() |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self:GetOMToken()) |
|
|
|
UnitCastingInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not name then |
|
|
|
if not name then |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self:GetOMToken()) |
|
|
|
UnitChannelInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if name and startTimeMS and endTimeMS then |
|
|
|
if name and startTimeMS and endTimeMS then |
|
|
@ -506,12 +648,10 @@ end |
|
|
|
-- Check if unit is interruptible |
|
|
|
-- Check if unit is interruptible |
|
|
|
---@return boolean |
|
|
|
---@return boolean |
|
|
|
function Unit:IsInterruptible() |
|
|
|
function Unit:IsInterruptible() |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self:GetOMToken()) |
|
|
|
UnitCastingInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not name then |
|
|
|
if not name then |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = |
|
|
|
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self:GetOMToken()) |
|
|
|
UnitChannelInfo(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if name then |
|
|
|
if name then |
|
|
@ -552,13 +692,7 @@ function Unit:GetEnemies(range) |
|
|
|
local count = 0 |
|
|
|
local count = 0 |
|
|
|
|
|
|
|
|
|
|
|
Bastion.UnitManager:EnumEnemies(function(unit) |
|
|
|
Bastion.UnitManager:EnumEnemies(function(unit) |
|
|
|
if |
|
|
|
if not self:IsUnit(unit) and self:IsWithinCombatDistance(unit, range) and unit:IsAlive() and self:CanSee(unit) and unit:IsEnemy() then |
|
|
|
not self:IsUnit(unit) |
|
|
|
|
|
|
|
and self:IsWithinCombatDistance(unit, range) |
|
|
|
|
|
|
|
and unit:IsAlive() |
|
|
|
|
|
|
|
and self:CanSee(unit) |
|
|
|
|
|
|
|
and unit:IsEnemy() |
|
|
|
|
|
|
|
then |
|
|
|
|
|
|
|
count = count + 1 |
|
|
|
count = count + 1 |
|
|
|
end |
|
|
|
end |
|
|
|
return false |
|
|
|
return false |
|
|
@ -569,8 +703,9 @@ function Unit:GetEnemies(range) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the number of melee attackers |
|
|
|
-- Get the number of melee attackers |
|
|
|
|
|
|
|
---@param facing? boolean |
|
|
|
---@return number |
|
|
|
---@return number |
|
|
|
function Unit:GetMeleeAttackers() |
|
|
|
function Unit:GetMeleeAttackers(facing) |
|
|
|
local enemies = self.cache:Get("melee_attackers") |
|
|
|
local enemies = self.cache:Get("melee_attackers") |
|
|
|
if enemies then |
|
|
|
if enemies then |
|
|
|
return enemies |
|
|
|
return enemies |
|
|
@ -579,7 +714,7 @@ function Unit:GetMeleeAttackers() |
|
|
|
local count = 0 |
|
|
|
local count = 0 |
|
|
|
|
|
|
|
|
|
|
|
Bastion.UnitManager:EnumEnemies(function(unit) |
|
|
|
Bastion.UnitManager:EnumEnemies(function(unit) |
|
|
|
if not self:IsUnit(unit) and unit:IsAlive() and self:CanSee(unit) and self:InMelee(unit) and unit:IsEnemy() then |
|
|
|
if not self:IsUnit(unit) and unit:IsAlive() and self:CanSee(unit) and self:InMelee(unit) and unit:IsEnemy() and (not facing or self:IsFacing(unit)) then |
|
|
|
count = count + 1 |
|
|
|
count = count + 1 |
|
|
|
end |
|
|
|
end |
|
|
|
return false |
|
|
|
return false |
|
|
@ -596,13 +731,7 @@ function Unit:GetPartyHPAround(distance, percent) |
|
|
|
local count = 0 |
|
|
|
local count = 0 |
|
|
|
|
|
|
|
|
|
|
|
Bastion.UnitManager:EnumFriends(function(unit) |
|
|
|
Bastion.UnitManager:EnumFriends(function(unit) |
|
|
|
if |
|
|
|
if not self:IsUnit(unit) and unit:GetDistance(self) <= distance and unit:IsAlive() and self:CanSee(unit) and unit:GetHP() <= percent then |
|
|
|
not self:IsUnit(unit) |
|
|
|
|
|
|
|
and unit:GetDistance(self) <= distance |
|
|
|
|
|
|
|
and unit:IsAlive() |
|
|
|
|
|
|
|
and self:CanSee(unit) |
|
|
|
|
|
|
|
and unit:GetHP() <= percent |
|
|
|
|
|
|
|
then |
|
|
|
|
|
|
|
count = count + 1 |
|
|
|
count = count + 1 |
|
|
|
end |
|
|
|
end |
|
|
|
return false |
|
|
|
return false |
|
|
@ -668,8 +797,7 @@ end |
|
|
|
---@param unit Unit |
|
|
|
---@param unit Unit |
|
|
|
---@return boolean |
|
|
|
---@return boolean |
|
|
|
function Unit:IsTanking(unit) |
|
|
|
function Unit:IsTanking(unit) |
|
|
|
local isTanking, status, threatpct, rawthreatpct, threatvalue = |
|
|
|
local isTanking, status, threatpct, rawthreatpct, threatvalue = UnitDetailedThreatSituation(self:GetOMToken(), unit:GetOMToken()) |
|
|
|
UnitDetailedThreatSituation(self:GetOMToken(), unit:GetOMToken()) |
|
|
|
|
|
|
|
return isTanking |
|
|
|
return isTanking |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -742,6 +870,10 @@ function Unit:GetMeleeBoost() |
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Unit:GetModelId() |
|
|
|
|
|
|
|
return ObjectModelId(self:GetOMToken()) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Melee calculation |
|
|
|
-- Melee calculation |
|
|
|
-- float fMaxDist = fmaxf((float)(*(float*)((uintptr_t)this + 0x1BF8) + 1.3333) + *(float*)((uintptr_t)target + 0x1BF8), 5.0); |
|
|
|
-- float fMaxDist = fmaxf((float)(*(float*)((uintptr_t)this + 0x1BF8) + 1.3333) + *(float*)((uintptr_t)target + 0x1BF8), 5.0); |
|
|
|
-- fMaxDist = fMaxDist + 1.0; |
|
|
|
-- fMaxDist = fMaxDist + 1.0; |
|
|
@ -790,6 +922,16 @@ function Unit:IsInParty() |
|
|
|
return UnitInParty(self:GetOMToken()) |
|
|
|
return UnitInParty(self:GetOMToken()) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- In party |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
|
|
|
|
function Unit:IsInRaid() |
|
|
|
|
|
|
|
return UnitInRaid(self:GetOMToken()) ~= nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Unit:IsInPartyOrRaid() |
|
|
|
|
|
|
|
return self:IsInParty() or self:IsInRaid() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Linear regression between time and percent to something |
|
|
|
-- Linear regression between time and percent to something |
|
|
|
---@param time table |
|
|
|
---@param time table |
|
|
|
---@param percent table |
|
|
|
---@param percent table |
|
|
@ -1110,9 +1252,9 @@ function Unit:GetStaggeredHealth() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- get the units combat reach |
|
|
|
-- get the units combat reach |
|
|
|
---@return number | false |
|
|
|
---@return number |
|
|
|
function Unit:GetCombatReach() |
|
|
|
function Unit:GetCombatReach() |
|
|
|
return ObjectCombatReach(self:GetOMToken()) |
|
|
|
return ObjectCombatReach(self:GetOMToken()) or 0 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the units combat distance (distance - combat reach (realized distance)) |
|
|
|
-- Get the units combat distance (distance - combat reach (realized distance)) |
|
|
@ -1220,8 +1362,7 @@ function Unit:HasTarget() |
|
|
|
return ObjectTarget(self:GetOMToken()) ~= false |
|
|
|
return ObjectTarget(self:GetOMToken()) ~= false |
|
|
|
end |
|
|
|
end |
|
|
|
function Unit:Target() |
|
|
|
function Unit:Target() |
|
|
|
return self:HasTarget() and Bastion.UnitManager:Get(ObjectTarget(self:GetOMToken()):unit()) |
|
|
|
return self:HasTarget() and Bastion.UnitManager:Get(ObjectTarget(self:GetOMToken()):unit()) or Bastion.UnitManager:Get("none") |
|
|
|
or Bastion.UnitManager:Get("none") |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- local empowering = {} |
|
|
|
-- local empowering = {} |
|
|
|