main
jeffi 9 months ago
parent bb169bf7c5
commit cd029208e3
  1. 9
      src/APLActor/APLActor.lua
  2. 3
      src/Bastion/Bastion.lua
  3. 8
      src/Item/Item.lua
  4. 36
      src/Unit/Unit.lua

@ -5,6 +5,7 @@ Bastion = ...
---@class Bastion.APLActor.Table.Base
---@field type "spell" | "item" | "apl" | "sequencer" | "variable" | "action"
---@field name string
---@alias Bastion.APLActor.Table Bastion.APL.Actor.Spell.Table | Bastion.APL.Actor.Item.Table | Bastion.APL.Actor.APL.Table | Bastion.APL.Actor.Sequencer.Table | Bastion.APL.Actor.Variable.Table | Bastion.APL.Actor.Action.Table
@ -30,15 +31,15 @@ function APLActor:New(actor)
local id = actor.item:GetID() or 0
self.name = string.format("[%s] `%s`<%s>", "item", name, id)
elseif actor.type == "apl" then
self.name = string.format("[%s] `%s`", "apl", actor.apl.name)
self.name = string.format("[%s] `%s`", "apl", actor.apl.name or "Unknown")
elseif actor.type == "sequencer" then
self.name = string.format("[%s]", "sequencer")
elseif actor.type == "variable" then
self.name = string.format("[%s] `%s`", "variable", actor.variable)
self.name = string.format("[%s] `%s`", "variable", actor.variable or "Unknown")
elseif actor.type == "action" then
self.name = string.format("[%s] `%s`", "action", actor.action)
self.name = string.format("[%s] `%s`", "action", actor.action or "Unknown")
else
self.name = string.format("[%s] Unknown", actor.type)
self.name = string.format("[%s] Unknown", actor.type or "Unknown")
end
self.actor = actor
self.enabled = true

@ -6,6 +6,7 @@ local Tinkr = ...
---@class Bastion
local Bastion = {
Enabled = false,
Interval = 0.01,
Globals = {
---@type Bastion.Globals.SpellName
SpellName = {}
@ -280,7 +281,7 @@ function Bastion:Load()
end
end)
self.Ticker = C_Timer.NewTicker(0.1, function()
self.Ticker = C_Timer.NewTicker(self.Interval, function()
self.Globals.CombatTimer:Check()
if Bastion.Enabled then

@ -43,7 +43,7 @@ local usableExcludes = {
---@param itemId number | string
---@return number charges, number maxCharges, number start, number duration
local GetItemCharges = function(itemId)
local _, spellId = GetItemSpell(itemId)
local _, spellId = C_Item.GetItemSpell(itemId)
local charges, maxCharges, start, duration, chargeModRate = GetSpellCharges(spellId)
return charges, maxCharges, start, duration
end
@ -266,7 +266,7 @@ function Item:Use(unit, condition)
return false
end
-- Check if the mouse was looking
self.wasLooking = IsMouselooking()
self.wasLooking = IsMouselooking() --[[@as boolean]]
UseItemByName(self.traits.use.byId and self:GetID() or self:GetName(), target:GetOMToken())
Bastion.Util:Debug("Using", self)
@ -438,7 +438,7 @@ end
---@param unit Bastion.Unit
---@return boolean
function Item:IsInRange(unit)
if not ItemHasRange(self:GetID()) or not self.spellID then
if not C_Item.ItemHasRange(self:GetID()) or not self.spellID then
return true
end
@ -501,7 +501,7 @@ function Item:GetCharges()
end
function Item:GetCount()
return GetItemCount(self:GetID(), false, false, false)
return C_Item.GetItemCount(self:GetID(), false, false, false)
end
-- Get the Items charges remaining

@ -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

Loading…
Cancel
Save