|
|
@ -16,8 +16,23 @@ local Unit = { |
|
|
|
ttd_ticker = false, |
|
|
|
ttd_ticker = false, |
|
|
|
ttd = 0, |
|
|
|
ttd = 0, |
|
|
|
id = false, --[[ @asnumber ]] |
|
|
|
id = false, --[[ @asnumber ]] |
|
|
|
|
|
|
|
watching_for_swings = false, |
|
|
|
|
|
|
|
health = {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Unit:UpdateHealth() |
|
|
|
|
|
|
|
if #self.health > 60 then |
|
|
|
|
|
|
|
table.remove(self.health, 1) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
table.insert(self.health, { |
|
|
|
|
|
|
|
time = Bastion.Now, |
|
|
|
|
|
|
|
percent = self:GetHP(), |
|
|
|
|
|
|
|
health = self:GetHealth(), |
|
|
|
|
|
|
|
maxHealth = |
|
|
|
|
|
|
|
self:GetMaxHealth() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Unit:__index(k) |
|
|
|
function Unit:__index(k) |
|
|
|
local response = Bastion.ClassMagic:Resolve(Unit, k) |
|
|
|
local response = Bastion.ClassMagic:Resolve(Unit, k) |
|
|
|
|
|
|
|
|
|
|
@ -56,6 +71,7 @@ end |
|
|
|
|
|
|
|
|
|
|
|
-- Constructor |
|
|
|
-- Constructor |
|
|
|
---@param unit? TinkrObjectReference |
|
|
|
---@param unit? TinkrObjectReference |
|
|
|
|
|
|
|
---@return Bastion.Unit |
|
|
|
function Unit:New(unit) |
|
|
|
function Unit:New(unit) |
|
|
|
---@class Bastion.Unit |
|
|
|
---@class Bastion.Unit |
|
|
|
local self = setmetatable({}, Unit) |
|
|
|
local self = setmetatable({}, Unit) |
|
|
@ -68,6 +84,7 @@ function Unit:New(unit) |
|
|
|
self.cache = Bastion.Cache:New() |
|
|
|
self.cache = Bastion.Cache:New() |
|
|
|
self.aura_table = Bastion.AuraTable:New(self) |
|
|
|
self.aura_table = Bastion.AuraTable:New(self) |
|
|
|
self.regression_history = {} |
|
|
|
self.regression_history = {} |
|
|
|
|
|
|
|
self.health = {} |
|
|
|
return self |
|
|
|
return self |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -78,12 +95,12 @@ function Unit:IsValid() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Check if the unit exists |
|
|
|
-- Check if the unit exists |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:Exists() |
|
|
|
function Unit:Exists() |
|
|
|
return Object(self:GetOMToken()) ~= false |
|
|
|
return Object(self:GetOMToken()) ~= false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the units token |
|
|
|
-- Get the units token |
|
|
|
---@return string |
|
|
|
|
|
|
|
function Unit:Token() |
|
|
|
function Unit:Token() |
|
|
|
return self:GetOMToken() |
|
|
|
return self:GetOMToken() |
|
|
|
end |
|
|
|
end |
|
|
@ -180,7 +197,6 @@ function Unit:GetPowerDeficit(powerType) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the units position |
|
|
|
-- Get the units position |
|
|
|
---@return Bastion.Vector3 |
|
|
|
|
|
|
|
function Unit:GetPosition() |
|
|
|
function Unit:GetPosition() |
|
|
|
local x, y, z = ObjectPosition(self:GetOMToken()) |
|
|
|
local x, y, z = ObjectPosition(self:GetOMToken()) |
|
|
|
return Bastion.Vector3:New(x, y, z) |
|
|
|
return Bastion.Vector3:New(x, y, z) |
|
|
@ -311,11 +327,12 @@ function Unit:IsDamage() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the units role |
|
|
|
-- Get the units role |
|
|
|
---@return "TANK" | "HEALER" | "DAMAGER" |
|
|
|
---@return "TANK" | "HEALER" | "DAMAGER" | "NONE" |
|
|
|
function Unit:GetRole() |
|
|
|
function Unit:GetRole() |
|
|
|
return UnitGroupRolesAssigned(self:GetOMToken()) |
|
|
|
return UnitGroupRolesAssigned(self:GetOMToken()) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return number | boolean |
|
|
|
function Unit:GetSpecializationID() |
|
|
|
function Unit:GetSpecializationID() |
|
|
|
if CanInspect(self:GetOMToken(), false) then |
|
|
|
if CanInspect(self:GetOMToken(), false) then |
|
|
|
return ObjectSpecializationID(self:GetOMToken()) |
|
|
|
return ObjectSpecializationID(self:GetOMToken()) |
|
|
@ -324,10 +341,10 @@ function Unit:GetSpecializationID() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
---@param fallback? boolean |
|
|
|
---@param fallback? boolean |
|
|
|
---@return "TANK" | "HEALER" | "DAMAGER" | false |
|
|
|
---@return "TANK" | "HEALER" | "DAMAGER" | "NONE" | false |
|
|
|
function Unit:GetSpecializationRole(fallback) |
|
|
|
function Unit:GetSpecializationRole(fallback) |
|
|
|
local specID = self:GetSpecializationID() |
|
|
|
local specID = self:GetSpecializationID() |
|
|
|
if specID then |
|
|
|
if type(specID) == "number" then |
|
|
|
return GetSpecializationRoleByID(specID) |
|
|
|
return GetSpecializationRoleByID(specID) |
|
|
|
end |
|
|
|
end |
|
|
|
return fallback and self:GetRole() or false |
|
|
|
return fallback and self:GetRole() or false |
|
|
@ -398,6 +415,15 @@ function Unit:CanSee(unit) |
|
|
|
-- return false |
|
|
|
-- return false |
|
|
|
-- end |
|
|
|
-- end |
|
|
|
-- end |
|
|
|
-- end |
|
|
|
|
|
|
|
local ignoreLoS = { |
|
|
|
|
|
|
|
[98696] = true -- Illysanna Ravencrest (BRH) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if not unit:IsPlayer() then |
|
|
|
|
|
|
|
local id = unit:GetID() |
|
|
|
|
|
|
|
if id and ignoreLoS[id] then |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
local ax, ay, az = ObjectPosition(self:GetOMToken()) |
|
|
|
local ax, ay, az = ObjectPosition(self:GetOMToken()) |
|
|
|
local ah = ObjectHeight(self:GetOMToken()) |
|
|
|
local ah = ObjectHeight(self:GetOMToken()) |
|
|
|
local attx, atty, attz = GetUnitAttachmentPosition(unit:GetOMToken(), 34) |
|
|
|
local attx, atty, attz = GetUnitAttachmentPosition(unit:GetOMToken(), 34) |
|
|
@ -432,6 +458,8 @@ function Unit:IsCasting() |
|
|
|
return UnitCastingInfo(self:GetOMToken()) ~= nil |
|
|
|
return UnitCastingInfo(self:GetOMToken()) ~= nil |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param percent number |
|
|
|
|
|
|
|
---@return number |
|
|
|
function Unit:GetTimeCastIsAt(percent) |
|
|
|
function Unit:GetTimeCastIsAt(percent) |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo( |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo( |
|
|
|
self:GetOMToken()) |
|
|
|
self:GetOMToken()) |
|
|
@ -453,7 +481,7 @@ function Unit:GetTimeCastIsAt(percent) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get Casting or channeling spell |
|
|
|
-- Get Casting or channeling spell |
|
|
|
---@return Bastion.Spell | nil |
|
|
|
---@return Bastion.Spell | boolean |
|
|
|
function Unit:GetCastingOrChannelingSpell() |
|
|
|
function Unit:GetCastingOrChannelingSpell() |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo( |
|
|
|
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo( |
|
|
|
self:GetOMToken()) |
|
|
|
self:GetOMToken()) |
|
|
@ -466,8 +494,7 @@ function Unit:GetCastingOrChannelingSpell() |
|
|
|
if name then |
|
|
|
if name then |
|
|
|
return Bastion.Globals.SpellBook:GetSpell(spellId) |
|
|
|
return Bastion.Globals.SpellBook:GetSpell(spellId) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
return false |
|
|
|
return nil |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the end time of the cast or channel |
|
|
|
-- Get the end time of the cast or channel |
|
|
@ -500,6 +527,7 @@ function Unit:IsCastingOrChanneling() |
|
|
|
return self:IsCasting() or self:IsChanneling() |
|
|
|
return self:IsCasting() or self:IsChanneling() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return Bastion.Unit |
|
|
|
function Unit:CastTarget() |
|
|
|
function Unit:CastTarget() |
|
|
|
---@diagnostic disable-next-line: param-type-mismatch |
|
|
|
---@diagnostic disable-next-line: param-type-mismatch |
|
|
|
return self:IsCastingOrChanneling() and Bastion.UnitManager:Get(ObjectCastingTarget(self:GetOMToken())) or |
|
|
|
return self:IsCastingOrChanneling() and Bastion.UnitManager:Get(ObjectCastingTarget(self:GetOMToken())) or |
|
|
@ -507,10 +535,12 @@ function Unit:CastTarget() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
---@param unit Bastion.Unit |
|
|
|
---@param unit Bastion.Unit |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:CastTargetIsUnit(unit) |
|
|
|
function Unit:CastTargetIsUnit(unit) |
|
|
|
return self:IsCastingOrChanneling() and self:CastTarget():IsUnit(unit) |
|
|
|
return self:IsCastingOrChanneling() and self:CastTarget():IsUnit(unit) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:IsImmobilized() |
|
|
|
function Unit:IsImmobilized() |
|
|
|
return bit.band(self:GetMovementFlag(), 0x400) > 0 |
|
|
|
return bit.band(self:GetMovementFlag(), 0x400) > 0 |
|
|
|
end |
|
|
|
end |
|
|
@ -569,7 +599,7 @@ function Unit:IsInterruptibleAt(percent, ignoreInterruptible) |
|
|
|
return false |
|
|
|
return false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local percent = percent or math.random(2, 5) |
|
|
|
local percent = percent or math.random(2, 20) |
|
|
|
|
|
|
|
|
|
|
|
local castPercent = self:GetChannelOrCastPercentComplete() |
|
|
|
local castPercent = self:GetChannelOrCastPercentComplete() |
|
|
|
if castPercent >= percent then |
|
|
|
if castPercent >= percent then |
|
|
@ -645,6 +675,7 @@ function Unit:IsMoving() |
|
|
|
return GetUnitSpeed(self:GetOMToken()) > 0 |
|
|
|
return GetUnitSpeed(self:GetOMToken()) > 0 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return TinkrMovementFlags |
|
|
|
function Unit:GetMovementFlag() |
|
|
|
function Unit:GetMovementFlag() |
|
|
|
return ObjectMovementFlag(self:GetOMToken()) |
|
|
|
return ObjectMovementFlag(self:GetOMToken()) |
|
|
|
end |
|
|
|
end |
|
|
@ -786,15 +817,15 @@ end |
|
|
|
---@param unit Bastion.Unit |
|
|
|
---@param unit Bastion.Unit |
|
|
|
---@return boolean |
|
|
|
---@return boolean |
|
|
|
function Unit:InMelee(unit) |
|
|
|
function Unit:InMelee(unit) |
|
|
|
local x, y, z = ObjectPosition(self.unit) |
|
|
|
local x, y, z = ObjectPosition(self:GetOMToken()) |
|
|
|
local x2, y2, z2 = ObjectPosition(unit.unit) |
|
|
|
local x2, y2, z2 = ObjectPosition(unit:GetOMToken()) |
|
|
|
|
|
|
|
|
|
|
|
if not x or not x2 then |
|
|
|
if not x or not x2 then |
|
|
|
return false |
|
|
|
return false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local scr = ObjectCombatReach(self.unit) |
|
|
|
local scr = ObjectCombatReach(self:GetOMToken()) |
|
|
|
local ucr = ObjectCombatReach(unit.unit) |
|
|
|
local ucr = ObjectCombatReach(unit:GetOMToken()) |
|
|
|
|
|
|
|
|
|
|
|
if not scr or not ucr then |
|
|
|
if not scr or not ucr then |
|
|
|
return false |
|
|
|
return false |
|
|
@ -808,6 +839,7 @@ function Unit:InMelee(unit) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get object id |
|
|
|
-- Get object id |
|
|
|
|
|
|
|
---@return number |
|
|
|
function Unit:GetID() |
|
|
|
function Unit:GetID() |
|
|
|
if self.id ~= false then |
|
|
|
if self.id ~= false then |
|
|
|
---@type number |
|
|
|
---@type number |
|
|
@ -830,6 +862,7 @@ function Unit:IsInRaid() |
|
|
|
return UnitInRaid(self:GetOMToken()) ~= nil |
|
|
|
return UnitInRaid(self:GetOMToken()) ~= nil |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:IsInPartyOrRaid() |
|
|
|
function Unit:IsInPartyOrRaid() |
|
|
|
return self:IsInParty() or self:IsInRaid() |
|
|
|
return self:IsInParty() or self:IsInRaid() |
|
|
|
end |
|
|
|
end |
|
|
@ -874,7 +907,7 @@ function Unit:PredictHealth(time) |
|
|
|
table.remove(self.regression_history, 1) |
|
|
|
table.remove(self.regression_history, 1) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
table.insert(self.regression_history, { time = GetTime(), percent = self:GetHP() }) |
|
|
|
table.insert(self.regression_history, { time = Bastion.Now, percent = self:GetHP() }) |
|
|
|
|
|
|
|
|
|
|
|
for i = 1, #self.regression_history do |
|
|
|
for i = 1, #self.regression_history do |
|
|
|
local entry = self.regression_history[i] |
|
|
|
local entry = self.regression_history[i] |
|
|
@ -883,7 +916,7 @@ function Unit:PredictHealth(time) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local slope, intercept = self:LinearRegression(x, y) |
|
|
|
local slope, intercept = self:LinearRegression(x, y) |
|
|
|
return slope * time + intercept |
|
|
|
return slope * (Bastion.Now + time) + intercept |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Use linear regression to guess the time until a given health percent |
|
|
|
-- Use linear regression to guess the time until a given health percent |
|
|
@ -897,7 +930,7 @@ function Unit:PredictTime(percent) |
|
|
|
table.remove(self.regression_history, 1) |
|
|
|
table.remove(self.regression_history, 1) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
table.insert(self.regression_history, { time = GetTime(), percent = self:GetHP() }) |
|
|
|
table.insert(self.regression_history, { time = Bastion.Now, percent = self:GetHP() }) |
|
|
|
|
|
|
|
|
|
|
|
for i = 1, #self.regression_history do |
|
|
|
for i = 1, #self.regression_history do |
|
|
|
local entry = self.regression_history[i] |
|
|
|
local entry = self.regression_history[i] |
|
|
@ -926,7 +959,7 @@ end |
|
|
|
function Unit:TimeToDie() |
|
|
|
function Unit:TimeToDie() |
|
|
|
if self:IsDead() then |
|
|
|
if self:IsDead() then |
|
|
|
self.regression_history = {} |
|
|
|
self.regression_history = {} |
|
|
|
if type(self.ttd_ticker) == "table" then |
|
|
|
if self.ttd_ticker then |
|
|
|
self.ttd_ticker:Cancel() |
|
|
|
self.ttd_ticker:Cancel() |
|
|
|
self.ttd_ticker = false |
|
|
|
self.ttd_ticker = false |
|
|
|
end |
|
|
|
end |
|
|
@ -955,6 +988,15 @@ function Unit:TimeToDie() |
|
|
|
return self.ttd |
|
|
|
return self.ttd |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param lower number |
|
|
|
|
|
|
|
---@param upper? number |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
|
|
|
|
function Unit:TTD(lower, upper) |
|
|
|
|
|
|
|
upper = type(upper) == "nil" and lower or upper |
|
|
|
|
|
|
|
local ttd = self:TimeToDie() |
|
|
|
|
|
|
|
return ttd >= lower and ttd <= upper |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Set combat time if affecting combat and return the difference between now and the last time |
|
|
|
-- Set combat time if affecting combat and return the difference between now and the last time |
|
|
|
---@return number |
|
|
|
---@return number |
|
|
|
function Unit:GetCombatTime() |
|
|
|
function Unit:GetCombatTime() |
|
|
@ -1053,37 +1095,39 @@ function Unit:GetSwingTimers() |
|
|
|
return main_speed_remains, off_speed_remains |
|
|
|
return main_speed_remains, off_speed_remains |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
---@return nil |
|
|
|
|
|
|
|
function Unit:WatchForSwings() |
|
|
|
function Unit:WatchForSwings() |
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
if not self.watching_for_swings then |
|
|
|
local _, subtype, _, sourceGUID, sourceName, _, _, destGUID, destName, destFlags, _, spellID, spellName, _, amount, interrupt, a, b, c, d, offhand, multistrike = |
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
CombatLogGetCurrentEventInfo() |
|
|
|
local _, subtype, _, sourceGUID, sourceName, _, _, destGUID, destName, destFlags, _, spellID, spellName, _, amount, interrupt, a, b, c, d, offhand, multistrike = |
|
|
|
|
|
|
|
CombatLogGetCurrentEventInfo() |
|
|
|
if sourceGUID == self:GetGUID() and subtype then |
|
|
|
|
|
|
|
if subtype == "SPELL_ENERGIZE" and spellID == 196911 then |
|
|
|
if sourceGUID == self:GetGUID() and subtype then |
|
|
|
self.last_shadow_techniques = GetTime() |
|
|
|
if subtype == "SPELL_ENERGIZE" and spellID == 196911 then |
|
|
|
self.swings_since_sht = 0 |
|
|
|
self.last_shadow_techniques = GetTime() |
|
|
|
end |
|
|
|
self.swings_since_sht = 0 |
|
|
|
|
|
|
|
|
|
|
|
if subtype:sub(1, 5) == "SWING" and not multistrike then |
|
|
|
|
|
|
|
if subtype == "SWING_MISSED" then |
|
|
|
|
|
|
|
offhand = spellName |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local now = GetTime() |
|
|
|
if subtype:sub(1, 5) == "SWING" and not multistrike then |
|
|
|
|
|
|
|
if subtype == "SWING_MISSED" then |
|
|
|
|
|
|
|
offhand = spellName |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if now > self.last_shadow_techniques + 3 then |
|
|
|
local now = GetTime() |
|
|
|
self.swings_since_sht = self.swings_since_sht + 1 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if offhand then |
|
|
|
if now > self.last_shadow_techniques + 3 then |
|
|
|
self.last_off_attack = GetTime() |
|
|
|
self.swings_since_sht = self.swings_since_sht + 1 |
|
|
|
else |
|
|
|
end |
|
|
|
self.last_main_attack = GetTime() |
|
|
|
|
|
|
|
|
|
|
|
if offhand then |
|
|
|
|
|
|
|
self.last_off_attack = GetTime() |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
self.last_main_attack = GetTime() |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
self.watching_for_swings = true |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- ismounted |
|
|
|
-- ismounted |
|
|
@ -1137,6 +1181,7 @@ function Unit:GetStaggerPercent() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the units power regen rate |
|
|
|
-- Get the units power regen rate |
|
|
|
|
|
|
|
---@return number, number |
|
|
|
function Unit:GetPowerRegen() |
|
|
|
function Unit:GetPowerRegen() |
|
|
|
---@diagnostic disable-next-line: redundant-parameter |
|
|
|
---@diagnostic disable-next-line: redundant-parameter |
|
|
|
return GetPowerRegen(self:GetOMToken()) |
|
|
|
return GetPowerRegen(self:GetOMToken()) |
|
|
@ -1226,6 +1271,7 @@ function Unit:IsWithinCone(Target, Angle, Distance, rotation) |
|
|
|
return diff <= Angle and self:GetDistance(Target) <= Distance |
|
|
|
return diff <= Angle and self:GetDistance(Target) <= Distance |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return number |
|
|
|
function Unit:GetEmpoweredStage() |
|
|
|
function Unit:GetEmpoweredStage() |
|
|
|
local stage = 0 |
|
|
|
local stage = 0 |
|
|
|
local _, _, _, startTime, _, _, _, spellID, _, numStages = UnitChannelInfo(self:GetOMToken()) |
|
|
|
local _, _, _, startTime, _, _, _, spellID, _, numStages = UnitChannelInfo(self:GetOMToken()) |
|
|
@ -1245,26 +1291,33 @@ function Unit:GetEmpoweredStage() |
|
|
|
return stage |
|
|
|
return stage |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:IsConnected() |
|
|
|
function Unit:IsConnected() |
|
|
|
return UnitIsConnected(self:GetOMToken()) |
|
|
|
return UnitIsConnected(self:GetOMToken()) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:HasIncomingRessurection() |
|
|
|
function Unit:HasIncomingRessurection() |
|
|
|
|
|
|
|
---@diagnostic disable-next-line: return-type-mismatch |
|
|
|
return self:IsDead() and UnitHasIncomingResurrection(self:GetOMToken()) |
|
|
|
return self:IsDead() and UnitHasIncomingResurrection(self:GetOMToken()) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return WowGameObject | false |
|
|
|
function Unit:LootTarget() |
|
|
|
function Unit:LootTarget() |
|
|
|
return ObjectLootTarget(self:GetOMToken()) |
|
|
|
return ObjectLootTarget(self:GetOMToken()) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:CanLoot() |
|
|
|
function Unit:CanLoot() |
|
|
|
return ObjectLootable(self:GetOMToken()) |
|
|
|
return ObjectLootable(self:GetOMToken()) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:HasTarget() |
|
|
|
function Unit:HasTarget() |
|
|
|
return ObjectTarget(self:GetOMToken()) ~= false |
|
|
|
return ObjectTarget(self:GetOMToken()) ~= false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return Bastion.Unit |
|
|
|
function Unit:Target() |
|
|
|
function Unit:Target() |
|
|
|
return self:HasTarget() and Bastion.UnitManager:Get(ObjectTarget(self:GetOMToken()):unit()) or |
|
|
|
return self:HasTarget() and Bastion.UnitManager:Get(ObjectTarget(self:GetOMToken()):unit()) or |
|
|
|
Bastion.UnitManager:Get("none") |
|
|
|
Bastion.UnitManager:Get("none") |
|
|
@ -1272,112 +1325,114 @@ end |
|
|
|
|
|
|
|
|
|
|
|
local dummyUnits = { |
|
|
|
local dummyUnits = { |
|
|
|
-- City (SW, Orgri, ...) |
|
|
|
-- City (SW, Orgri, ...) |
|
|
|
[31146] = true, -- Raider's Training Dummy |
|
|
|
[31146] = true, -- Raider's Training Dummy |
|
|
|
[31144] = true, -- Training Dummy |
|
|
|
[31144] = true, -- Training Dummy |
|
|
|
[32666] = true, -- Training Dummy |
|
|
|
[32666] = true, -- Training Dummy |
|
|
|
[32667] = true, -- Training Dummy |
|
|
|
[32667] = true, -- Training Dummy |
|
|
|
[46647] = true, -- Training Dummy |
|
|
|
[46647] = true, -- Training Dummy |
|
|
|
[114832] = true, -- PvP Training Dummy |
|
|
|
[114832] = true, -- PvP Training Dummy |
|
|
|
[153285] = true, -- Training Dummy |
|
|
|
[153285] = true, -- Training Dummy |
|
|
|
[153292] = true, -- Training Dummy |
|
|
|
[153292] = true, -- Training Dummy |
|
|
|
-- MoP Shrine of Two Moons |
|
|
|
-- MoP Shrine of Two Moons |
|
|
|
[67127] = true, -- Training Dummy |
|
|
|
[67127] = true, -- Training Dummy |
|
|
|
-- WoD Alliance Garrison |
|
|
|
-- WoD Alliance Garrison |
|
|
|
[87317] = true, -- Mage Tower Damage Training Dummy |
|
|
|
[87317] = true, -- Mage Tower Damage Training Dummy |
|
|
|
[87318] = true, -- Mage Tower Damage Dungeoneer's Training Dummy (& Garrison) |
|
|
|
[87318] = true, -- Mage Tower Damage Dungeoneer's Training Dummy (& Garrison) |
|
|
|
[87320] = true, -- Mage Tower Damage Raider's Training Dummy |
|
|
|
[87320] = true, -- Mage Tower Damage Raider's Training Dummy |
|
|
|
[88314] = true, -- Tanking Dungeoneer's Training Dummy |
|
|
|
[88314] = true, -- Tanking Dungeoneer's Training Dummy |
|
|
|
[88316] = true, -- Healing Training Dummy ----> FRIENDLY |
|
|
|
[88316] = true, -- Healing Training Dummy ----> FRIENDLY |
|
|
|
-- WoD Horde Garrison |
|
|
|
-- WoD Horde Garrison |
|
|
|
[87760] = true, -- Mage Tower Damage Training Dummy |
|
|
|
[87760] = true, -- Mage Tower Damage Training Dummy |
|
|
|
[87761] = true, -- Mage Tower Damage Dungeoneer's Training Dummy (& Garrison) |
|
|
|
[87761] = true, -- Mage Tower Damage Dungeoneer's Training Dummy (& Garrison) |
|
|
|
[87762] = true, -- Mage Tower Damage Raider's Training Dummy |
|
|
|
[87762] = true, -- Mage Tower Damage Raider's Training Dummy |
|
|
|
[88288] = true, -- Tanking Dungeoneer's Training Dummy |
|
|
|
[88288] = true, -- Tanking Dungeoneer's Training Dummy |
|
|
|
[88289] = true, -- Healing Training Dummy ----> FRIENDLY |
|
|
|
[88289] = true, -- Healing Training Dummy ----> FRIENDLY |
|
|
|
-- Legion Druid Class Order Hall |
|
|
|
-- Legion Druid Class Order Hall |
|
|
|
[113964] = true, -- Raider's Training Dummy |
|
|
|
[113964] = true, -- Raider's Training Dummy |
|
|
|
[113966] = true, -- Dungeoneer's Training Dummy |
|
|
|
[113966] = true, -- Dungeoneer's Training Dummy |
|
|
|
-- Legion Mage Class Order Hall |
|
|
|
-- Legion Mage Class Order Hall |
|
|
|
[103397] = true, -- Greater Bullwark Construct |
|
|
|
[103397] = true, -- Greater Bullwark Construct |
|
|
|
[103404] = true, -- Bullwark Construct |
|
|
|
[103404] = true, -- Bullwark Construct |
|
|
|
[103402] = true, -- Lesser Bullwark Construct |
|
|
|
[103402] = true, -- Lesser Bullwark Construct |
|
|
|
-- Legion Priest Class Order Hall |
|
|
|
-- Legion Priest Class Order Hall |
|
|
|
[107555] = true, -- Bound void Wraith |
|
|
|
[107555] = true, -- Bound void Wraith |
|
|
|
[107556] = true, -- Bound void Walker |
|
|
|
[107556] = true, -- Bound void Walker |
|
|
|
-- Legion Rogue Class Order Hall |
|
|
|
-- Legion Rogue Class Order Hall |
|
|
|
[92164] = true, -- Training Dummy |
|
|
|
[92164] = true, -- Training Dummy |
|
|
|
[92165] = true, -- Dungeoneer's Training Dummy |
|
|
|
[92165] = true, -- Dungeoneer's Training Dummy |
|
|
|
[92166] = true, -- Raider's Training Dummy |
|
|
|
[92166] = true, -- Raider's Training Dummy |
|
|
|
-- Legion Warlock Class Order Hall |
|
|
|
-- Legion Warlock Class Order Hall |
|
|
|
[101956] = true, -- Rebellious Fel Lord |
|
|
|
[101956] = true, -- Rebellious Fel Lord |
|
|
|
[102045] = true, -- Rebellious WrathGuard |
|
|
|
[102045] = true, -- Rebellious WrathGuard |
|
|
|
[102048] = true, -- Rebellious Felguard |
|
|
|
[102048] = true, -- Rebellious Felguard |
|
|
|
[102052] = true, -- Rebellious imp |
|
|
|
[102052] = true, -- Rebellious imp |
|
|
|
-- BfA Dazar'Alor |
|
|
|
-- BfA Dazar'Alor |
|
|
|
[144081] = true, -- Training Dummy |
|
|
|
[144081] = true, -- Training Dummy |
|
|
|
[144082] = true, -- Training Dummy |
|
|
|
[144082] = true, -- Training Dummy |
|
|
|
[144085] = true, -- Training Dummy |
|
|
|
[144085] = true, -- Training Dummy |
|
|
|
[144086] = true, -- Raider's Training Dummy |
|
|
|
[144086] = true, -- Raider's Training Dummy |
|
|
|
-- BfA Boralus |
|
|
|
-- BfA Boralus |
|
|
|
[126781] = true, -- Training Dummy |
|
|
|
[126781] = true, -- Training Dummy |
|
|
|
[131983] = true, -- Raider's Training Dummy |
|
|
|
[131983] = true, -- Raider's Training Dummy |
|
|
|
[131989] = true, -- Training Dummy |
|
|
|
[131989] = true, -- Training Dummy |
|
|
|
[131992] = true, -- Dungeoneer's Training Dummy |
|
|
|
[131992] = true, -- Dungeoneer's Training Dummy |
|
|
|
-- Shadowlands Kyrian |
|
|
|
-- Shadowlands Kyrian |
|
|
|
[154564] = true, -- Valiant's Humility |
|
|
|
[154564] = true, -- Valiant's Humility |
|
|
|
[154567] = true, -- Purity's Cleaning |
|
|
|
[154567] = true, -- Purity's Cleaning |
|
|
|
[154580] = true, -- Reinforced Guardian |
|
|
|
[154580] = true, -- Reinforced Guardian |
|
|
|
[154583] = true, -- Starlwart Guardian |
|
|
|
[154583] = true, -- Starlwart Guardian |
|
|
|
[154585] = true, -- Valiant's Resolve |
|
|
|
[154585] = true, -- Valiant's Resolve |
|
|
|
[154586] = true, -- Stalwart Phalanx |
|
|
|
[154586] = true, -- Stalwart Phalanx |
|
|
|
[160325] = true, -- Humility's Obedience |
|
|
|
[160325] = true, -- Humility's Obedience |
|
|
|
-- Shadowlands Venthyr |
|
|
|
-- Shadowlands Venthyr |
|
|
|
[173942] = true, -- Training Dummy |
|
|
|
[173942] = true, -- Training Dummy |
|
|
|
[175449] = true, -- Raider's Training Dummy |
|
|
|
[175449] = true, -- Raider's Training Dummy |
|
|
|
[175450] = true, -- Dungeoneer's Training Dummy |
|
|
|
[175450] = true, -- Dungeoneer's Training Dummy |
|
|
|
[175451] = true, -- Dungeoneer's Tanking Dummy |
|
|
|
[175451] = true, -- Dungeoneer's Tanking Dummy |
|
|
|
[175452] = true, -- Raider's Tanking Dummy |
|
|
|
[175452] = true, -- Raider's Tanking Dummy |
|
|
|
[175455] = true, -- Cleave Training Dummy |
|
|
|
[175455] = true, -- Cleave Training Dummy |
|
|
|
[175456] = true, -- Swarm Training Dummy |
|
|
|
[175456] = true, -- Swarm Training Dummy |
|
|
|
[175462] = true, -- Sinfall Fiend |
|
|
|
[175462] = true, -- Sinfall Fiend |
|
|
|
-- Shadowlands Night Fae |
|
|
|
-- Shadowlands Night Fae |
|
|
|
[174565] = true, -- Dungeoneer's Tanking Dummy |
|
|
|
[174565] = true, -- Dungeoneer's Tanking Dummy |
|
|
|
[174566] = true, -- Raider's Tanking Dummy |
|
|
|
[174566] = true, -- Raider's Tanking Dummy |
|
|
|
[174567] = true, -- Raider's Training Dummy |
|
|
|
[174567] = true, -- Raider's Training Dummy |
|
|
|
[174568] = true, -- Dungeoneer's Training Dummy |
|
|
|
[174568] = true, -- Dungeoneer's Training Dummy |
|
|
|
[174569] = true, -- Training Dummy |
|
|
|
[174569] = true, -- Training Dummy |
|
|
|
[174570] = true, -- Swarm Training Dummy |
|
|
|
[174570] = true, -- Swarm Training Dummy |
|
|
|
[174571] = true, -- Cleave Training Dummy |
|
|
|
[174571] = true, -- Cleave Training Dummy |
|
|
|
-- Shadowlands Necrolord |
|
|
|
-- Shadowlands Necrolord |
|
|
|
[174484] = true, -- Dungeoneer's Training Dummy |
|
|
|
[174484] = true, -- Dungeoneer's Training Dummy |
|
|
|
[174487] = true, -- Training Dummy |
|
|
|
[174487] = true, -- Training Dummy |
|
|
|
[174488] = true, -- Raider's Training Dummy |
|
|
|
[174488] = true, -- Raider's Training Dummy |
|
|
|
[174491] = true, -- Tanking Dummy |
|
|
|
[174491] = true, -- Tanking Dummy |
|
|
|
-- DargonFlight Valdrakken |
|
|
|
-- DargonFlight Valdrakken |
|
|
|
[198594] = true, -- Cleave Training Dummy |
|
|
|
[198594] = true, -- Cleave Training Dummy |
|
|
|
[194648] = true, -- Training Dummy |
|
|
|
[194648] = false, -- Training Dummy |
|
|
|
[189632] = true, -- Animated Duelist |
|
|
|
[189632] = true, -- Animated Duelist |
|
|
|
[194643] = true, -- Dungeoneer's Training Dummy |
|
|
|
[194643] = true, -- Dungeoneer's Training Dummy |
|
|
|
[194644] = true, -- Dungeoneer's Training Dummy |
|
|
|
[194644] = true, -- Dungeoneer's Training Dummy |
|
|
|
[197833] = true, -- PvP Training Dummy |
|
|
|
[197833] = true, -- PvP Training Dummy |
|
|
|
[189617] = true, -- Boulderfist |
|
|
|
[189617] = true, -- Boulderfist |
|
|
|
[194649] = true, -- Normal Tank Dummy |
|
|
|
[194649] = true, -- Normal Tank Dummy |
|
|
|
-- DargonFlight Iskaara |
|
|
|
-- DargonFlight Iskaara |
|
|
|
[193563] = true, -- Training Dummy |
|
|
|
[193563] = true, -- Training Dummy |
|
|
|
-- Other |
|
|
|
-- Other |
|
|
|
[65310] = true, -- Turnip Punching Bag (toy) |
|
|
|
[65310] = true, -- Turnip Punching Bag (toy) |
|
|
|
[66374] = true, -- Anatomical Dummy (toy) |
|
|
|
[66374] = true, -- Anatomical Dummy (toy) |
|
|
|
[196394] = true, -- Tuskarr Training Dummy (toy) |
|
|
|
[196394] = true, -- Tuskarr Training Dummy (toy) |
|
|
|
[196406] = true, -- Rubbery Fish Head (toy) |
|
|
|
[196406] = true, -- Rubbery Fish Head (toy) |
|
|
|
[199057] = true, -- Black Dragon's Challenge Dummy (toy) |
|
|
|
[199057] = true, -- Black Dragon's Challenge Dummy (toy) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:IsDummy() |
|
|
|
function Unit:IsDummy() |
|
|
|
local npcId = self:GetID() |
|
|
|
local npcId = self:GetID() |
|
|
|
return npcId and npcId >= 0 and dummyUnits[npcId] == true or false |
|
|
|
return npcId and npcId >= 0 and dummyUnits[npcId] == true or false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
---@param npcId? number |
|
|
|
---@param npcId? number |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:IsInBossList(npcId) |
|
|
|
function Unit:IsInBossList(npcId) |
|
|
|
npcId = npcId or self:GetID() |
|
|
|
npcId = npcId or self:GetID() |
|
|
|
for i = 1, 4 do |
|
|
|
for i = 1, 4 do |
|
|
@ -1386,9 +1441,11 @@ function Unit:IsInBossList(npcId) |
|
|
|
return true |
|
|
|
return true |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
return false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
---@param npcId number |
|
|
|
---@param npcId number |
|
|
|
|
|
|
|
---@return number |
|
|
|
function Unit:SpecialTTDPercentage(npcId) |
|
|
|
function Unit:SpecialTTDPercentage(npcId) |
|
|
|
local specialTTDPercentage = Bastion.TimeToDie.specialTTDPercentageData[npcId] |
|
|
|
local specialTTDPercentage = Bastion.TimeToDie.specialTTDPercentageData[npcId] |
|
|
|
if not specialTTDPercentage then return 0 end |
|
|
|
if not specialTTDPercentage then return 0 end |
|
|
@ -1402,6 +1459,7 @@ end |
|
|
|
|
|
|
|
|
|
|
|
---@param npcId? number |
|
|
|
---@param npcId? number |
|
|
|
---@param hp? number |
|
|
|
---@param hp? number |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:CheckHPFromBossList(npcId, hp) |
|
|
|
function Unit:CheckHPFromBossList(npcId, hp) |
|
|
|
npcId = npcId or self:GetID() |
|
|
|
npcId = npcId or self:GetID() |
|
|
|
local thisHP = hp or 100 |
|
|
|
local thisHP = hp or 100 |
|
|
@ -1415,13 +1473,16 @@ function Unit:CheckHPFromBossList(npcId, hp) |
|
|
|
return false |
|
|
|
return false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param percentage number |
|
|
|
|
|
|
|
---@param minSamples? number |
|
|
|
|
|
|
|
---@return Bastion.TimeToDie.Enums | integer |
|
|
|
function Unit:TimeToX(percentage, minSamples) |
|
|
|
function Unit:TimeToX(percentage, minSamples) |
|
|
|
if self:IsDummy() then return 6666 end |
|
|
|
--if self:IsDummy() then return 6666 end |
|
|
|
if self:IsPlayer() and Bastion.UnitManager:Get("player"):CanAttack(self) then return 25 end |
|
|
|
if self:IsPlayer() and Bastion.UnitManager:Get("player"):CanAttack(self) then return Bastion.TimeToDie.Enums.PLAYER end |
|
|
|
local seconds = 8888 |
|
|
|
local seconds = 0 |
|
|
|
local unitGuid = self:GetGUID() |
|
|
|
local unitGuid = self:GetGUID() |
|
|
|
if not unitGuid then |
|
|
|
if not unitGuid then |
|
|
|
return seconds |
|
|
|
return Bastion.TimeToDie.Enums.NO_GUID |
|
|
|
end |
|
|
|
end |
|
|
|
local unitTable = Bastion.TimeToDie.Units[unitGuid] |
|
|
|
local unitTable = Bastion.TimeToDie.Units[unitGuid] |
|
|
|
-- Simple linear regression |
|
|
|
-- Simple linear regression |
|
|
@ -1456,8 +1517,8 @@ function Unit:TimeToX(percentage, minSamples) |
|
|
|
-- Use best fit line to calculate estimated time to reach target health |
|
|
|
-- Use best fit line to calculate estimated time to reach target health |
|
|
|
seconds = (percentage - a) / b |
|
|
|
seconds = (percentage - a) / b |
|
|
|
-- Subtract current time to obtain "time remaining" |
|
|
|
-- Subtract current time to obtain "time remaining" |
|
|
|
seconds = math.min(7777, seconds - (GetTime() - unitTable[2])) |
|
|
|
seconds = seconds - (GetTime() - unitTable[2]) |
|
|
|
if seconds < 0 then seconds = 9999 end |
|
|
|
if seconds < 0 then seconds = Bastion.TimeToDie.Enums.NEGATIVE_TTD end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -1465,12 +1526,15 @@ function Unit:TimeToX(percentage, minSamples) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
---@param minSamples? number |
|
|
|
---@param minSamples? number |
|
|
|
|
|
|
|
---@return Bastion.TimeToDie.Enums | integer |
|
|
|
function Unit:TimeToDie2(minSamples) |
|
|
|
function Unit:TimeToDie2(minSamples) |
|
|
|
if not self:Exists() then |
|
|
|
if not self:Exists() then |
|
|
|
return 11111 |
|
|
|
return Bastion.TimeToDie.Enums.DOES_NOT_EXIST |
|
|
|
end |
|
|
|
end |
|
|
|
local unitGuid = self:GetGUID() |
|
|
|
local unitGuid = self:GetGUID() |
|
|
|
if not unitGuid then return 11111 end |
|
|
|
if not unitGuid then |
|
|
|
|
|
|
|
return Bastion.TimeToDie.Enums.NO_GUID |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
minSamples = minSamples or 3 |
|
|
|
minSamples = minSamples or 3 |
|
|
|
---@type {TTD: {[number]: number}} |
|
|
|
---@type {TTD: {[number]: number}} |
|
|
@ -1482,23 +1546,28 @@ function Unit:TimeToDie2(minSamples) |
|
|
|
ttd = {} |
|
|
|
ttd = {} |
|
|
|
unitInfo.TTD = ttd |
|
|
|
unitInfo.TTD = ttd |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
local v |
|
|
|
if not ttd[minSamples] then |
|
|
|
if not ttd[minSamples] then |
|
|
|
ttd[minSamples] = self:TimeToX(self:SpecialTTDPercentage(self:GetID()), minSamples) |
|
|
|
v = self:TimeToX(self:SpecialTTDPercentage(self:GetID()), minSamples) |
|
|
|
|
|
|
|
if v >= 0 then |
|
|
|
|
|
|
|
ttd[minSamples] = v |
|
|
|
|
|
|
|
Bastion.Globals.UnitInfo:Set(unitGuid, unitInfo, .5) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
Bastion.Globals.UnitInfo:Set(unitGuid, unitInfo, .5) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ttd[minSamples] |
|
|
|
return ttd[minSamples] or v |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get the boss unit TimeToDie |
|
|
|
-- Get the boss unit TimeToDie |
|
|
|
---@param minSamples? number |
|
|
|
---@param minSamples? number |
|
|
|
|
|
|
|
---@return Bastion.TimeToDie.Enums | integer |
|
|
|
function Unit:BossTimeToDie(minSamples) |
|
|
|
function Unit:BossTimeToDie(minSamples) |
|
|
|
if self:IsInBossList() or self:IsDummy() then |
|
|
|
if self:IsInBossList() or self:IsDummy() then |
|
|
|
return self:TimeToDie2(minSamples) |
|
|
|
return self:TimeToDie2(minSamples) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
return 11111 |
|
|
|
return Bastion.TimeToDie.Enums.DOES_NOT_EXIST |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get if the unit meets the TimeToDie requirements. |
|
|
|
-- Get if the unit meets the TimeToDie requirements. |
|
|
@ -1507,10 +1576,11 @@ end |
|
|
|
---@param offset number |
|
|
|
---@param offset number |
|
|
|
---@param valueThreshold number |
|
|
|
---@param valueThreshold number |
|
|
|
---@param minSamples? number |
|
|
|
---@param minSamples? number |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:FilteredTimeToDie(operator, value, offset, valueThreshold, minSamples) |
|
|
|
function Unit:FilteredTimeToDie(operator, value, offset, valueThreshold, minSamples) |
|
|
|
local TTD = self:TimeToDie2(minSamples) |
|
|
|
local TTD = self:TimeToDie2(minSamples) |
|
|
|
|
|
|
|
|
|
|
|
return TTD < (valueThreshold or 7777) and Bastion.Utils.CompareThis(operator, TTD + (offset or 0), value) or false |
|
|
|
return TTD > -1 and TTD < valueThreshold and Bastion.Utils.CompareThis(operator, TTD + (offset or 0), value) or false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get if the boss unit meets the TimeToDie requirements. |
|
|
|
-- Get if the boss unit meets the TimeToDie requirements. |
|
|
@ -1519,6 +1589,7 @@ end |
|
|
|
---@param offset number |
|
|
|
---@param offset number |
|
|
|
---@param valueThreshold number |
|
|
|
---@param valueThreshold number |
|
|
|
---@param minSamples? number |
|
|
|
---@param minSamples? number |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:BossFilteredTimeToDie(operator, value, offset, valueThreshold, minSamples) |
|
|
|
function Unit:BossFilteredTimeToDie(operator, value, offset, valueThreshold, minSamples) |
|
|
|
if self:IsInBossList() or self:IsDummy() then |
|
|
|
if self:IsInBossList() or self:IsDummy() then |
|
|
|
return self:FilteredTimeToDie(operator, value, offset, valueThreshold, minSamples) |
|
|
|
return self:FilteredTimeToDie(operator, value, offset, valueThreshold, minSamples) |
|
|
@ -1529,12 +1600,14 @@ end |
|
|
|
|
|
|
|
|
|
|
|
-- Get if the Time To Die is Valid for an Unit (i.e. not returning a warning code). |
|
|
|
-- Get if the Time To Die is Valid for an Unit (i.e. not returning a warning code). |
|
|
|
---@param minSamples? number |
|
|
|
---@param minSamples? number |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:TimeToDieIsNotValid(minSamples) |
|
|
|
function Unit:TimeToDieIsNotValid(minSamples) |
|
|
|
return self:TimeToDie2(minSamples) >= 7777 |
|
|
|
return self:TimeToDie2(minSamples) > -1 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get if the Time To Die is Valid for a boss Unit (i.e. not returning a warning code or not being a boss). |
|
|
|
-- Get if the Time To Die is Valid for a boss Unit (i.e. not returning a warning code or not being a boss). |
|
|
|
---@param minSamples? number |
|
|
|
---@param minSamples? number |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function Unit:BossTimeToDieIsNotValid(minSamples) |
|
|
|
function Unit:BossTimeToDieIsNotValid(minSamples) |
|
|
|
if self:IsInBossList() then |
|
|
|
if self:IsInBossList() then |
|
|
|
return self:TimeToDieIsNotValid(minSamples) |
|
|
|
return self:TimeToDieIsNotValid(minSamples) |
|
|
@ -1543,62 +1616,4 @@ function Unit:BossTimeToDieIsNotValid(minSamples) |
|
|
|
return true |
|
|
|
return true |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- local empowering = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Bastion.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_EMPOWER_START", function(...) |
|
|
|
|
|
|
|
-- local unit, unk, id = ... |
|
|
|
|
|
|
|
-- if not unit then return end |
|
|
|
|
|
|
|
-- local guid = ObjectGUID(unit) |
|
|
|
|
|
|
|
-- if not guid then return end |
|
|
|
|
|
|
|
-- empowering[guid] = -1 |
|
|
|
|
|
|
|
-- end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Bastion.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_EMPOWER_STOP", function(...) |
|
|
|
|
|
|
|
-- local unit, unk, id = ... |
|
|
|
|
|
|
|
-- if not unit then return end |
|
|
|
|
|
|
|
-- local guid = ObjectGUID(unit) |
|
|
|
|
|
|
|
-- if not guid then return end |
|
|
|
|
|
|
|
-- empowering[guid] = -1 |
|
|
|
|
|
|
|
-- end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- function Unit:GetUnitEmpowerStage() |
|
|
|
|
|
|
|
-- local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = |
|
|
|
|
|
|
|
-- UnitChannelInfo(self:GetOMToken()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- if name and empowering[self:GetGUID()] == -1 then |
|
|
|
|
|
|
|
-- empowering[self:GetGUID()] = numStages |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- if not name and empowering[self:GetGUID()] then |
|
|
|
|
|
|
|
-- return empowering[self:GetGUID()] |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- if not name then |
|
|
|
|
|
|
|
-- return empowering[self:GetGUID()] |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- local getStageDuration = function(stage) |
|
|
|
|
|
|
|
-- if stage == numStages then |
|
|
|
|
|
|
|
-- return GetUnitEmpowerHoldAtMaxTime(self:GetOMToken()); |
|
|
|
|
|
|
|
-- else |
|
|
|
|
|
|
|
-- return GetUnitEmpowerStageDuration(self:GetOMToken(), stage - 1); |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- local time = GetTime() - (startTime / 1000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- local higheststage = 0 |
|
|
|
|
|
|
|
-- local sumdur = 0 |
|
|
|
|
|
|
|
-- for i = 1, numStages - 1, 1 do |
|
|
|
|
|
|
|
-- local duration = getStageDuration(i) / 1000; |
|
|
|
|
|
|
|
-- sumdur = sumdur + duration |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- if time > sumdur then |
|
|
|
|
|
|
|
-- higheststage = i |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- return higheststage |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Unit |
|
|
|
return Unit |
|
|
|