Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MaintainTrackedAuras()
- for k, v in pairs(aura_env.cons) do
- if aura_env.config.trackedGroup["consTracked"][k] == false then
- aura_env.cons[k] = {-1}
- end
- end
- for k, v in pairs(aura_env.wbs) do
- if aura_env.config.trackedGroup["wbTracked"][k] == false then
- aura_env.wbs[k] = {-1}
- end
- end
- end
- function MaintainCustomOptions()
- aura_env.buff_removal = aura_env.config.optionGroup.buffRemoval
- aura_env.buffer = aura_env.config.optionGroup.bufferOption
- aura_env.blacklist = UpdateBlacklist()
- aura_env.dropdown = aura_env.config.optionGroup["isDropdown"]
- aura_env.announcerAuto = aura_env.config.optionGroup["announcerAuto"]
- aura_env.announcerTracked = aura_env.config.optionGroup["announcerTracked"]
- MaintainTrackedAuras()
- end
- function MaintainGlobals()
- GetTrackedCons = aura_env.cons
- GetTrackedWbs = aura_env.wbs
- GetBlacklist = aura_env.blacklist
- GetDropdown = aura_env.dropdown
- GetAnnounceAuto = aura_env.announcerAuto
- GetAnnounceTracked = aura_env.announcerTracked
- GetAurasTotal = aura_env.aurasTotal
- end
- function MaintainState()
- aura_env.enchantCount = CountEnchants()
- aura_env.enchantsPushed = CountEnchantsPushed()
- aura_env.buffCount = CountBuffs()
- aura_env.aurasTotal = aura_env.enchantCount - aura_env.enchantsPushed + aura_env.buffCount
- aura_env.openSlots = 32 - aura_env.aurasTotal
- aura_env.buffsMax = 32 - aura_env.enchantCount + aura_env.enchantsPushed
- MaintainGlobals()
- end
- function GetItemId(invId)
- itemLink = GetInventoryItemLink("player", invId)
- if itemLink ~= nil then
- local _, _, _, _, itemId, Enchant = string.find(itemLink,
- "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
- return itemId
- end
- return -1
- end
- function GetItemEnchant(invId)
- itemLink = GetInventoryItemLink("player", invId)
- if itemLink ~= nil then
- local _, _, _, _, _, Enchant = string.find(itemLink,
- "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
- return Enchant
- end
- return -1
- end
- function GetItemEnchantWeapon(invId)
- itemLink = GetInventoryItemLink("player", invId)
- if itemLink ~= nil then
- local hasMainHandEnchant, mainHandExpiration, mainHandCharges, mainHandEnchantID, hasOffHandEnchant, offHandExpiration, offHandCharges, offHandEnchantId = GetWeaponEnchantInfo()
- if invId == INVSLOT_MAINHAND then
- return mainHandEnchantID
- else
- return offHandEnchantId
- end
- end
- return -1
- end
- function IsEnchanted(itemLink)
- local _, _, _, _, itemId, Enchant = string.find(itemLink,
- "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
- if Enchant == "" then return false else return true end
- end
- function IsEnchantedWeapon(InventorySlotName)
- local hasMainHandEnchant, mainHandExpiration, mainHandCharges, mainHandEnchantID, hasOffHandEnchant, offHandExpiration, offHandCharges, offHandEnchantId = GetWeaponEnchantInfo()
- if (InventorySlotName == INVSLOT_MAINHAND and tonumber(mainHandEnchantID) == 2506) or (InventorySlotName == INVSLOT_OFFHAND and (tonumber(offHandEnchantId) == 2506 or tonumber(offHandEnchantId) == 1704)) then return true else return false end
- end
- function UpdateBlacklist()
- blacklistTable = {}
- for k,v in pairs(aura_env.spells) do
- if aura_env.config.blacklistGroup["buffsBlacklist"][k] then
- blacklistTable[aura_env.spells[k]] = 1
- end
- end
- return blacklistTable
- end
- function GetFirstBuff()
- if next(aura_env.buffOrder) ~= nil then
- local t = aura_env.buffOrder[1]
- return aura_env.buffs[t]
- else
- return "No buffs"
- end
- end
- function AddStance(buffTable)
- if UnitClass(UnitName("player")) == "Warrior" then
- buffTable[math.huge] = "Stance"
- end
- end
- function AddTracking(buffTable)
- if GetTrackingTexture() ~= nil then
- buffTable[math.huge] = "Tracking"
- end
- end
- function AddEnchants(buffTable)
- local enchantAdded = 0
- local enchantBuffNames = {
- [INVSLOT_HEAD] = "Head Enchant",
- [INVSLOT_LEGS] = "Legs Enchant",
- [INVSLOT_FEET] = "Mithril Spurs",
- [INVSLOT_MAINHAND] = "MH Ele",
- [INVSLOT_OFFHAND] = "OH Ele/Spike",
- }
- local function AddEnchant(InventorySlotName, buffTable)
- local itemLink = GetInventoryItemLink("player", InventorySlotName)
- local enchantId = GetItemEnchant(InventorySlotName)
- if InventorySlotName == INVSLOT_FEET then
- if tonumber(enchantId) == 464 then
- if itemLink ~= nil then
- if IsEnchanted(itemLink) then
- enchantAdded = enchantAdded + 1
- if enchantAdded <= CountEnchants() - CountEnchantsPushed() then
- buffTable[aura_env.items[InventorySlotName][1]] = enchantBuffNames[InventorySlotName]
- end
- end
- end
- end
- else
- if itemLink ~= nil then
- if IsEnchanted(itemLink) or IsEnchantedWeapon(InventorySlotName) then
- enchantAdded = enchantAdded + 1
- if enchantAdded <= CountEnchants() - CountEnchantsPushed() then
- buffTable[aura_env.items[InventorySlotName][1]] = enchantBuffNames[InventorySlotName]
- end
- end
- end
- end
- end
- for k,v in pairs(aura_env.items) do
- AddEnchant(k, buffTable)
- end
- end
- function CreateBuffTable()
- local buffTable = {}
- for i=1,40 do
- local name, _, _, _, duration, expirationTime, _, _, _, spellId = UnitBuff("player",i)
- if name and duration > 0 then
- buffTable[(expirationTime - duration)] = name
- end
- if name and duration == 0 then
- buffTable[GetTime()+spellId] = name
- end
- end
- AddStance(buffTable)
- AddTracking(buffTable)
- AddEnchants(buffTable)
- return buffTable
- end
- function GetSortedBuffTable(tbl)
- local sortedTimeTable = {}
- for k,v in pairs(tbl) do
- if k ~= nil then
- table.insert(sortedTimeTable, k)
- end
- end
- table.sort(sortedTimeTable)
- return sortedTimeTable
- end
- function CountEnchants()
- local enchants = 0
- for InventorySlot,v in pairs(aura_env.items) do
- local enchantId = GetItemEnchant(InventorySlot)
- local itemLink = GetInventoryItemLink("player", InventorySlot)
- if itemLink ~= nil then
- if tonumber(InventorySlot) == INVSLOT_MAINHAND or tonumber(InventorySlot) == INVSLOT_OFFHAND then
- if IsEnchantedWeapon(InventorySlot) then
- enchants = enchants + 1
- end
- else
- if IsEnchanted(itemLink) then
- if InventorySlot == INVSLOT_FEET then
- if tonumber(enchantId) == 464 then
- enchants = enchants + 1
- end
- else
- enchants = enchants + 1
- end
- end
- end
- end
- end
- return enchants
- end
- function CountBuffs()
- local count = 0
- if UnitClass(UnitName("player")) == "Warrior" then count = count + 1 end
- if GetTrackingTexture() ~= nil then count = count + 1 end
- for i=1,40 do
- local name, icon, _, _, _, etime = UnitBuff("player",i)
- if name then
- count = count + 1
- end
- end
- return count
- end
- function CountEnchantsPushed()
- local counter = 32 - (CountBuffs() + CountEnchants())
- local enchantsPushed = 0
- if counter < 0 then enchantsPushed = abs(counter) end
- return enchantsPushed
- end
- function GetBuffIdx(buffName)
- for i=1,40 do
- local name = UnitBuff("player",i)
- if name == buffName then
- return i
- end
- end
- return -1
- end
- function GetAuraDur(name, buff)
- if buff then
- _, _, _, _, _, etime = WA_GetUnitBuff("player", name)
- else
- _, _, _, _, _, etime = WA_GetUnitDebuff("player", name)
- end
- local timestamp = GetTime()
- local tmp = etime or ""
- if string.len(tmp) > 0 then
- secs = etime-timestamp
- mins = math.floor(secs/60)
- if mins == 0 then
- time = math.floor(secs) .. " secs"
- else
- time = mins .. " mins"
- end
- tmp = " (" .. time .. ")"
- end
- return tmp
- end
- function isNextTracked()
- for k, _ in pairs(aura_env.wbs) do
- if aura_env.wbs[k][1] == aura_env.buffNext then
- return true
- end
- end
- for k, _ in pairs(aura_env.cons) do
- if aura_env.cons[k][1] == aura_env.buffNext then
- return true
- end
- end
- return false
- end
- function GetSuffix (n)
- local lastTwo, lastOne = n % 100, n % 10
- if lastTwo > 3 and lastTwo < 21 then return "th" end
- if lastOne == 1 then return "st" end
- if lastOne == 2 then return "nd" end
- if lastOne == 3 then return "rd" end
- return "th"
- end
- function Nth (n) return n .. GetSuffix(n) end
- function GetTableEntries(tbl)
- local count = 0
- for _ in pairs(tbl) do count = count + 1 end
- return count
- end
- ---------------------------------- String functions for display
- function FindBuff(buffName) -- shitty abstraction
- local key = 0;
- for k,v in pairs(aura_env.buffs) do
- if v == buffName then
- key = k
- end
- end
- if key > 0 then
- for k,v in pairs(aura_env.buffOrder) do
- if v == key then
- if k == 1 then
- return ("|cffFF8000" .. Nth(k) .. "|r")
- else
- return ("|cff00FF00" .. Nth(k) .. "|r")
- end
- end
- end
- end
- if WA_GetUnitDebuff("player", buffName) ~= nil then return ("|cffFF8000DEBUFF|r") end
- return "|cffFF0000N/A|r"
- end
- function GetBuffNextString()
- if isNextTracked() then
- return ("|cffFF0000" .. aura_env.buffNext .. "|r"):upper()
- else
- return ("|cff00FF00" .. aura_env.buffNext .. "|r"):upper()
- end
- end
- function GetBuffRemovalString()
- if (aura_env.buffsMax - aura_env.buffCount) <= aura_env.buffer and not UnitAffectingCombat("player") and aura_env.config.optionGroup.buffRemoval then
- return "|cffFF8000ACTIVE|r"
- elseif (aura_env.buffsMax - aura_env.buffCount) == 0 and not UnitAffectingCombat("player") and aura_env.config.optionGroup.buffRemoval then
- return "|cffFF0000ACTIVE|r"
- else
- return "|cff00FF00INACTIVE|r"
- end
- end
- function GetBuffCountString()
- if (aura_env.buffsMax - aura_env.buffCount) <= aura_env.buffer then
- return "|cffFF8000" .. aura_env.buffCount .. "|r"
- elseif (aura_env.buffsMax - aura_env.buffCount) == 0 then
- return "|cffFF0000" .. aura_env.buffCount .. "|r"
- else
- return "|cff00FF00" .. aura_env.buffCount .. "|r"
- end
- end
- function GetEnchantString()
- local activeEnchants = aura_env.enchantCount - aura_env.enchantsPushed
- if (activeEnchants) < aura_env.enchantCount then
- return "|cffff0000" .. activeEnchants .. "|r"
- else
- return "|cff00FF00" .. activeEnchants .. "|r"
- end
- end
- function BuildTrackedString(tbl)
- local tmp = "\n"
- for i=1,GetTableEntries(tbl),1 do
- local wb = tbl[i]
- if wb[1] ~= -1 then
- tmp = tmp .. "\n" .. wb[2] .. ": " .. FindBuff(wb[1]) .. GetAuraDur(wb[1], wb[3])
- end
- end
- if string.len(tmp) == 1 then tmp = "" end
- return tmp
- end
- -- Blacklisted Auras. Must match the corresponding Custom Option.
- -- Key = idx in custom options, v[1] = aura name
- aura_env.spells = {
- [1] = "Thorns",
- [2] = "Arcane Intellect",
- [3] = "Arcane Brilliance",
- [4] = "Amplify Magic",
- [5] = "Dampen Magic",
- [6] = "Shadow Protection",
- [7] = "Divine Spirit",
- [8] = "Prayer of Spirit",
- [9] = "Fear Ward",
- [10] = "Water Breathing",
- [11] = "Water Walking",
- [12] = "Unending Breath",
- [13] = "Detect Invisibility",
- [14] = "Battle Shout",
- [15] = "Juju Flurry",
- [16] = "Blessing of Might",
- [17] = "Blessing of Kings",
- [18] = "Blessing of Salvation",
- [19] = "Blessing of Wisdom",
- [20] = "Blessing of Light",
- [21] = "Blessing of Sanctuary",
- [22] = "Greater Blessing of Might",
- [23] = "Greater Blessing of Kings",
- [24] = "Greater Blessing of Salvation",
- [25] = "Greater Blessing of Wisdom",
- [26] = "Greater Blessing of Light",
- [27] = "Greater Blessing of Sanctuary",
- [28] = "Renew",
- [29] = "Rejuvenation",
- [30] = "Regrowth",
- [31] = "Power Word: Shield",
- [32] = "Detect Greater Invisibility",
- }
- -- Tracked Consumables. Must match the corresponding Custom Option.
- -- Key = idx in custom options, v[1] = aura name, v[2] = name displayed in tracker, v[3] = buff/debuff
- aura_env.cons = {
- [1] = {"Flask of the Titans","FLASK", true},
- [2] = {"Distilled Wisdom","FLASK", true},
- [3] = {"Supreme Power","FLASK", true},
- [4] = {"Juju Flurry","JJ FLURRY", true},
- [5] = {"Juju Might","JJ MIGHT", true},
- [6] = {"Juju Power","JJ POWER", true},
- [7] = {"Rage of Ages","BL", true},
- [8] = {"Spirit of Boar","BL", true},
- [9] = {"Strike of the Scorpok","BL", true},
- [10] = {"Infallible Mind","BL", true},
- [11] = {"Elixir of the Mongoose","MONGOOSE", true},
- [12] = {"Greater Arcane Elixir","ARCANE", true},
- [13] = {"Shadow Power","SHADOWPOWER", true},
- [14] = {"Spirit of Zanza","ZANZA", true},
- [15] = {"Swiftness of Zanza","ZANZA", true},
- [16] = {"Winterfall Firewater","WF", true},
- [17] = {"Increased Agility","FOOD", true},
- [18] = {"Blessed Sunfruit","FOOD", true},
- [19] = {"Increased Intellect","FOOD", true},
- [20] = {"Mana Regeneration","FOOD", true}, -- Will break when mageblood is added to the game, fix with id's
- [21] = {"Well Fed","FOOD", true},
- [22] = {"Rumsey Rum Black Label","RUMSEY", true},
- [23] = {"Kreeg's Stout Beatdown","KREEG", true},
- [24] = {"Gordok Green Grog","GORDOK", true},
- [25] = {"Health II","FORT", true},
- [26] = {"Regeneration","TROLL", true},
- [27] = {"Greater Armor","SUP DEFENSE", true},
- }
- -- Tracked World Buffs. Must match the corresponding Custom Option.
- -- Key = idx in custom options, v[1] = aura name, v[2] = name displayed in tracker, v[3] = buff/debuff
- aura_env.wbs = {
- [1] = {"Songflower Serenade","SF", true},
- [2] = {"Rallying Cry of the Dragonslayer","ONY", true},
- [3] = {"Warchief's Blessing","WCB", true},
- [4] = {"Fengus' Ferocity","DM AP", true},
- [5] = {"Slip'kik's Savvy","DM CRIT", true},
- [6] = {"Mol'dar's Moxie","DM STAM", true},
- [7] = {"Fury of Ragnaros","BRD", true},
- [8] = {"Blessing of Blackfathom","BFD", false},
- [9] = {"Resist Fire", "FR", true},
- [10] = {"Arcane Might", "STRAT", true},
- }
- aura_env.tradeClosed = true
- local timeAtLogin = GetTime()
- aura_env.items = {
- [INVSLOT_HEAD] = {timeAtLogin + INVSLOT_HEAD,GetItemId(INVSLOT_HEAD),GetItemEnchant(INVSLOT_HEAD)},
- [INVSLOT_LEGS] = {timeAtLogin + INVSLOT_LEGS,GetItemId(INVSLOT_LEGS),GetItemEnchant(INVSLOT_LEGS)},
- [INVSLOT_FEET] = {timeAtLogin + INVSLOT_FEET,GetItemId(INVSLOT_FEET),GetItemEnchant(INVSLOT_FEET)},
- [INVSLOT_MAINHAND] = {timeAtLogin + INVSLOT_MAINHAND,GetItemId(INVSLOT_MAINHAND),GetItemEnchantWeapon(INVSLOT_MAINHAND)},
- [INVSLOT_OFFHAND] = {timeAtLogin + INVSLOT_OFFHAND,GetItemId(INVSLOT_OFFHAND),GetItemEnchant(INVSLOT_OFFHAND)},
- }
- MaintainCustomOptions()
- MaintainState()
- aura_env.buffs = CreateBuffTable()
- aura_env.buffOrder = GetSortedBuffTable(aura_env.buffs)
- aura_env.buffNext = GetFirstBuff()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement