Add new Lua files and implement functions for various features

This commit is contained in:
2024-03-03 13:48:29 +01:00
parent b48cb28cb5
commit ea5269617b
10 changed files with 254 additions and 27 deletions

View File

@@ -144,7 +144,7 @@ local mountFilter = {
}
local ilvlFilter = {
enabled = true,
ilvlThreshold = 880,
ilvlThreshold = 700,
filter = function(self, slot)
if (self.enabled) then
aura_env.debugLog("ILvl filter; slot: " .. tostring(slot))
@@ -160,11 +160,12 @@ local ilvlFilter = {
local professionFilter = {
enabled = true,
herbs = true,
cloth = false,
cloth = true,
ore = false,
leather = false,
cooking = true,
inscription = true,
enchanting = true,
filter = function(self, slot)
if (self.enabled) then
aura_env.debugLog("Profession filter; slot: " .. tostring(slot))
@@ -176,7 +177,8 @@ local professionFilter = {
or (itemSubtype == "Cloth" and self.cloth)
or (itemSubtype == "Ore" and self.ore)
or (itemSubtype == "Cooking" and self.cooking)
or (itemSubtype == "Inscription" and self.inscription)) then
or (itemSubtype == "Inscription" and self.inscription)
or (itemSubtype == "Enchanting" and self.enchanting)) then
aura_env.debugLog("Profession filter pass")
return true
end
@@ -247,7 +249,7 @@ local questItemFilter = {
aura_env.debugLog("Quest item filter pass")
return true
end
aura_env.debugLog("Quest item filter fais " .. tostring(itemType) .. " " .. tostring(itemSubtype))
aura_env.debugLog("Quest item filter fails " .. tostring(itemType) .. " " .. tostring(itemSubtype))
end
end
}
@@ -275,7 +277,7 @@ local classGearFilter = {
return true
end
end
aura_env.debugLog("Class gear filter fais " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
aura_env.debugLog("Class gear filter fails " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
end
end
}
@@ -293,7 +295,7 @@ local azeriteFilter = {
aura_env.debugLog("Azerite filter pass")
return true
end
aura_env.debugLog("Azerite filter fais " .. tostring(itemType) .. " " .. tostring(itemSubtype) .. " " .. tostring(itemQuality))
aura_env.debugLog("Azerite filter fails " .. tostring(itemType) .. " " .. tostring(itemSubtype) .. " " .. tostring(itemQuality))
end
end
}
@@ -309,7 +311,7 @@ local arguniteFilter = {
aura_env.debugLog("Argunite filter pass")
return true
end
aura_env.debugLog("Argunite filter fais " .. tostring(itemName) .. " " .. tostring(itemQuality))
aura_env.debugLog("Argunite filter failed " .. tostring(itemName) .. " " .. tostring(itemQuality))
end
end
}
@@ -356,6 +358,20 @@ local bloodOfSargerasFilter = {
end
end
}
local bloodhunerQuarryFilter = {
enabled = true,
filter = function(self, slot)
if (self.enabled) then
aura_env.debugLog("Bloodhunter's Quarry filter; slot: " .. tostring(slot))
local itemName = getItemName(slot)
if (itemName and itemName:match("Bloodhunter")) then
aura_env.debugLog("Bloodhunter's Quarry filter pass")
return true
end
aura_env.debugLog("Bloodhunter's Quarry filter fail " .. tostring(itemName))
end
end
}
local boeFilter = {
enabled = true,
ilvlThreshold = 800,
@@ -380,7 +396,7 @@ local boeFilter = {
return true
end
end
aura_env.debugLog("BoE filter fais " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
aura_env.debugLog("BoE filter fails " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
end
end
}
@@ -401,7 +417,8 @@ aura_env.filterService = {
ancientManaFilter,
reicpeFilter,
bloodOfSargerasFilter,
boeFilter
boeFilter,
bloodhunerQuarryFilter,
},
slotsToLoot = {},
run = function(self, lootInfo)

View File

@@ -1,13 +1,15 @@
-- MERCHANT_SHOW
function(allstates, e)
aura_env.allstates = allstates
if CanMerchantRepair() == true then RepairAllItems() end
for container = 0, 4 do
for slot = 1, GetContainerNumSlots(container) do
aura_env.filterService:run(container, slot)
if (GetMerchantNumItems() > 0) then
aura_env.allstates = allstates
if CanMerchantRepair() == true then RepairAllItems() end
for container = 0, 4 do
for slot = 1, GetContainerNumSlots(container) do
aura_env.filterService:run(container, slot)
end
end
return true
end
return true
end

20
LegionWA/CDs/Color.lua Normal file
View File

@@ -0,0 +1,20 @@
function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
-- if aura_env.state.IsActive then
-- ActionButton_ShowOverlayGlow(aura_env.region.icon)
-- else
-- ActionButton_HideOverlayGlow(aura_env.region.icon)
-- end
if aura_env.state.IsActive then
aura_env.region.icon:SetDesaturated(false)
return r1, g1, b1, a1
end
if aura_env.IsOnCooldown then
aura_env.region.icon:SetDesaturated(true)
return r1, g1, b1, a1
end
aura_env.region.icon:SetDesaturated(false)
return r2, g2, b2, 0.6
end

4
LegionWA/CDs/Event.lua Normal file
View File

@@ -0,0 +1,4 @@
function(allstates)
aura_env.HandleEvent(allstates)
return true
end

100
LegionWA/CDs/Init.lua Normal file
View File

@@ -0,0 +1,100 @@
local CooldownType = {
New = function(self)
local o = {}
setmetatable(o, self)
self.__index = self
return o
end,
}
local NullType = CooldownType:New()
NullType.GetActiveInfo = function(self)
return false, 0, 0
end
local TotemType = CooldownType:New()
TotemType.GetActiveInfo = function(self)
for i = 1, 4 do
local present, name, start, duration = GetTotemInfo(i)
if present and name == self.name then
return true, start, duration
end
end
return false, 0, 0
end
local Cooldown = {
New = function(self, type, spellid, keybind)
local o = {
["type"] = type,
["spellid"] = spellid,
["name"] = GetSpellInfo(spellid),
["icon"] = GetSpellTexture(spellid),
["keybind"] = keybind,
}
setmetatable(o, self)
self.__index = self
return o
end,
GetCooldownInfo = function(self)
local start, duration = GetSpellCooldown(self.spellid)
return start > 0 and duration > aura_env.gcdThreshold, start, duration
end,
GetActiveInfo = function(self)
return self.type:GetActiveInfo()
end
}
aura_env.cooldowns = {
[5394] = Cooldown:New(TotemType, 5394, "C"), -- Healing Stream Totem
[2484] = Cooldown:New(TotemType, 2484, "SY"), -- Earthbind Totem
[8143] = Cooldown:New(TotemType, 8143, "S5"), -- Tremor Totem
[8177] = Cooldown:New(TotemType, 8177, "5"), -- Grounding Totem
[108273] = Cooldown:New(TotemType, 108273, "S4"), -- Windwalk Totem
[108270] = Cooldown:New(TotemType, 108270, "SF"), -- Stone Bulwark Totem
}
aura_env.gcdThreshold = 1.5
aura_env.Update = function(allstates, cd)
local state = allstates[cd.spellid] or {}
state.IsOnCooldown = cd:GetCooldownInfo()
state.IsActive = cd:GetActiveInfo()
state.Keybind = cd.keybind
if state.IsOnCooldown and not state.IsActive then
local _, start, duration = cd:GetCooldownInfo()
state.progressType = "timed"
state.duration = duration
state.expirationTime = start + duration
elseif state.IsOnCooldown and state.IsActive then
local _, start, duration = cd:GetActiveInfo()
state.progressType = "timed"
state.duration = duration
state.expirationTime = start + duration
end
state.changed = true
state.show = true
state.name = cd.name
state.icon = cd.icon
state.spellid = cd.spellid
allstates[cd.spellid] = state
end
aura_env.UpdateAll = function(allstates)
for _, v in pairs(aura_env.cooldowns) do
aura_env.Update(allstates, v)
end
end
aura_env.HandleEvent = function(allstates)
-- TODO: Handle events better
-- On cooldown begin -> trigger update on relevant spell
-- On totem die -> same
-- On buff remove
-- On debuff remove
-- On... Whatever else might happen
aura_env.UpdateAll(allstates)
end

View File

@@ -16,15 +16,15 @@ aura_env.trackedSpells = {
local iconDisplayDuration = 0.4
local gcdDuration = 1.5
aura_env.workData = {}
aura_env.cache = {}
for k, spellId in pairs(aura_env.trackedSpells) do
aura_env.workData[spellId] = {
aura_env.cache[spellId] = {
ready = true,
hasCharges = false,
}
if GetSpellCharges(spellId) then
aura_env.workData[spellId].hasCharges = true
aura_env.workData[spellId].charges = select(1, GetSpellCharges(spellId))
aura_env.cache[spellId].hasCharges = true
aura_env.cache[spellId].charges = select(1, GetSpellCharges(spellId))
end
end
@@ -32,21 +32,21 @@ aura_env.processEvent = function(allstates)
for k, spellId in pairs(aura_env.trackedSpells) do
-- Handle spells with charges
local isReady
if (aura_env.workData[spellId].hasCharges) then
if (aura_env.cache[spellId].hasCharges) then
local charges = select(1, GetSpellCharges(spellId))
if (charges > aura_env.workData[spellId].charges) then
if (charges > aura_env.cache[spellId].charges) then
isReady = true
aura_env.workData[spellId].charges = charges
aura_env.cache[spellId].charges = charges
else
isReady = false
aura_env.workData[spellId].charges = charges
aura_env.cache[spellId].charges = charges
end
else
isReady = select(2, GetSpellCooldown(spellId)) < gcdDuration
end
if (not aura_env.workData[spellId].ready and isReady) then
if (not aura_env.cache[spellId].ready and isReady) then
local icon = select(3, GetSpellInfo(spellId))
allstates[spellId] = {
show = true,
@@ -63,6 +63,6 @@ aura_env.processEvent = function(allstates)
}
end
aura_env.workData[spellId].ready = isReady
aura_env.cache[spellId].ready = isReady
end
end

View File

@@ -0,0 +1,28 @@
-- COMBAT_LOG_EVENT_UNFILTERED
function(allstates, e, ...)
local iconDisplayDuration = 0.5
local se = select(2, ...)
if (se ~= "SPELL_AURA_APPLIED") then return end
local target = select(9, ...)
if (target ~= UnitName("player")) then return end
local auraType = select(15, ...)
if (auraType ~= "DEBUFF") then return end
local spellId = select(12, ...)
print(select(3, GetSpellInfo(spellId)))
allstates[spellId] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = select(3, GetSpellInfo(spellId)),
name = select(13, ...),
progressType = "timed",
expirationTime = GetTime() + iconDisplayDuration,
duration = iconDisplayDuration,
autoHide = true,
}
return true
end

View File

@@ -0,0 +1,5 @@
-- DevTools_Dump(aura_env.region)
-- aura_env.region:SetParent(aura_env.state.frame)
aura_env.region:ClearAllPoints()
aura_env.region:SetPoint("TOPLEFT", aura_env.state.frame.AuraWatch, "TOPLEFT", 0, 0)
aura_env.region:Show()

View File

@@ -0,0 +1,29 @@
local raidFrames = ElvUF_Raid
local group1, group2, group3, group4, group5, group6 = raidFrames:GetChildren()
local groups = { group1, group2, group3, group4, group5, group6 }
aura_env.players = {}
for _, group in ipairs(groups) do
local playerFrame1, playerFrame2, playerFrame3, playerFrame4, playerFrame5 = group:GetChildren()
local playerFrames = { playerFrame1, playerFrame2, playerFrame3, playerFrame4, playerFrame5 }
for _, player in ipairs(playerFrames) do
if player.Name:IsVisible() then
aura_env.players[#aura_env.players + 1] = player
end
end
end
local specs = {
-- We can't get unit spec..........
-- Best we can do is class
-- That fucking sucks
}
aura_env.Player = {
new = function(self, player)
setmetatable({}, self)
self.frame = nil
self.danger = 0
return self
end,
}

View File

@@ -0,0 +1,22 @@
-- TSU
function(allstates, e)
if aura_env.players == nil then
aura_env.players = {}
end
for _,player in ipairs(aura_env.players) do
allstates[player.Name:GetText()] = {
show = true,
changed = true,
name = 0.13,
frame = player,
icon = player.RaidIcon,
progressType = "static",
value = 1,
total = 1,
autoHide = true,
resort = true,
}
end
return true
end