From f467be5891a535f8d13b85d06443a0087a4242b0 Mon Sep 17 00:00:00 2001 From: "Ashley (CuteOne)" Date: Sat, 31 Aug 2024 14:59:50 -0400 Subject: [PATCH] System - Use br.UnitBuff instead of br._G.UnitBuff --- System/Functions/Aura.lua | 8 ++-- System/Functions/Custom.lua | 8 ++-- System/Misc/foodflaskpot.lua | 88 ++++++++++++++++++------------------ System/SlashCommands.lua | 8 ++-- System/UsefulFeatures.lua | 2 +- unusedFunctions.lua | 2 +- 6 files changed, 58 insertions(+), 58 deletions(-) diff --git a/System/Functions/Aura.lua b/System/Functions/Aura.lua index 5690cf7d9..7d55d104a 100644 --- a/System/Functions/Aura.lua +++ b/System/Functions/Aura.lua @@ -18,7 +18,7 @@ end function br.CancelUnitBuffID(unit, spellID, filter) -- local spellName = GetSpellInfo(spellID) for i = 1, 40 do - local _, _, _, _, _, _, _, _, _, buffSpellID = br._G.UnitBuff(unit, i) + local _, _, _, _, _, _, _, _, _, buffSpellID = br.UnitBuff(unit, i) if buffSpellID ~= nil then if buffSpellID == spellID then br._G.CancelUnitBuff(unit, i, filter) @@ -294,8 +294,8 @@ function br.canDispel(Unit, spellID) i = i + 1 end else - while br._G.UnitBuff(Unit, i) do - local _, _, stacks, buffType, buffDuration, buffExpire, _, _, _, buffid = br._G.UnitBuff(Unit, i) + while br.UnitBuff(Unit, i) do + local _, _, stacks, buffType, buffDuration, buffExpire, _, _, _, buffid = br.UnitBuff(Unit, i) local buffRemain = buffExpire - br._G.GetTime() if (buffType and ValidType(buffType)) and not br._G.UnitIsPlayer(Unit) then local dispelUnitObj = Dispel(Unit, stacks, buffDuration, buffRemain, buffid, true) @@ -680,7 +680,7 @@ function br.isBuffed(UnitID, SpellID, TimeLeft, Filter) for i = 1, #SpellID do local buff, _, _, _, _, _, buffID = br._G.GetSpellInfo(SpellID[i]) if buff then - local expire = select(6, br._G.UnitBuff(UnitID, buffID, Filter)) + local expire = select(6, br.UnitBuff(UnitID, buffID, Filter)) if expire and (expire == 0 or expire - br._G.GetTime() > TimeLeft) then return true end diff --git a/System/Functions/Custom.lua b/System/Functions/Custom.lua index b2757d5ee..0eb8d6e4c 100644 --- a/System/Functions/Custom.lua +++ b/System/Functions/Custom.lua @@ -713,11 +713,11 @@ end -- hasBuff(12345) function br.hasBuff(spellID) local buffs, i = {}, 1 - local buff = br._G.UnitBuff("player", i) + local buff = br.UnitBuff("player", i) while buff do buffs[#buffs + 1] = buff i = i + 1 - buff = select(10, br._G.UnitBuff("player", i)) + buff = select(10, br.UnitBuff("player", i)) if buff ~= nil then if buff == spellID then return true end end @@ -730,11 +730,11 @@ end -- cancelBuff(12345) function br.cancelBuff(spellID) local buffs, i = {}, 1 - local buff = br._G.UnitBuff("player", i) + local buff = br.UnitBuff("player", i) while buff do buffs[#buffs + 1] = buff i = i + 1 - buff = select(10, br._G.UnitBuff("player", i)) + buff = select(10, br.UnitBuff("player", i)) if buff ~= nil then if buff == spellID then br._G.CancelUnitBuff("player", i, "") diff --git a/System/Misc/foodflaskpot.lua b/System/Misc/foodflaskpot.lua index c89008260..4a3da4f56 100644 --- a/System/Misc/foodflaskpot.lua +++ b/System/Misc/foodflaskpot.lua @@ -28,24 +28,24 @@ local staminaFoodBuff = 0 --playerHasBuff(x) @param spellID # returns true if player has buff x function br.playerHasBuff(spellID) - local buffs, i = { }, 1 - local buff = br._G.UnitBuff("player", i) - while buff do - buffs[#buffs + 1] = buff - i = i + 1 - buff = select(10,br._G.UnitBuff("player", i)) - if buff ~= nil then - if buff == spellID then return true end - end - end - return false + local buffs, i = {}, 1 + local buff = br.UnitBuff("player", i) + while buff do + buffs[#buffs + 1] = buff + i = i + 1 + buff = select(10, br.UnitBuff("player", i)) + if buff ~= nil then + if buff == spellID then return true end + end + end + return false end --getClass # returns class as string function br.getClass() local myClass = "nil" local class = select(3, br._G.UnitClass("player")) - if class == 1 then -- Warrior + if class == 1 then -- Warrior myClass = "Warrior" elseif class == 2 then -- Paladin myClass = "Paladin" @@ -78,31 +78,31 @@ function br.getClassType() local mySpec = br._G.GetSpecialization() --Agility if myClass == "Hunter" - or myClass == "Rogue" - or (myClass == "Shaman" and mySpec == 2) - or (myClass == "Monk" and mySpec == 3) - or (myClass == "Druid" and mySpec == 2) then + or myClass == "Rogue" + or (myClass == "Shaman" and mySpec == 2) + or (myClass == "Monk" and mySpec == 3) + or (myClass == "Druid" and mySpec == 2) then classType = "agilityClass" - --Intellect + --Intellect elseif (myClass == "Paladin" and mySpec == 1) - or myClass == "Priest" - or (myClass == "Shaman" and (mySpec == 1 or mySpec == 3)) - or myClass == "Mage" - or myClass == "Warlock" - or (myClass == "Monk" and mySpec == 2) - or (myClass == "Druid" and (mySpec == 1 or mySpec == 4)) then + or myClass == "Priest" + or (myClass == "Shaman" and (mySpec == 1 or mySpec == 3)) + or myClass == "Mage" + or myClass == "Warlock" + or (myClass == "Monk" and mySpec == 2) + or (myClass == "Druid" and (mySpec == 1 or mySpec == 4)) then classType = "intellectClass" - --Strength + --Strength elseif (myClass == "Warrior" and (mySpec == 1 or mySpec == 2)) - or (myClass == "Paladin" and mySpec == 3) - or (myClass == "DeathKnight" and (mySpec == 2 or mySpec == 3)) then + or (myClass == "Paladin" and mySpec == 3) + or (myClass == "DeathKnight" and (mySpec == 2 or mySpec == 3)) then classType = "strengthClass" - --Stamina + --Stamina elseif (myClass == "Warrior" and mySpec == 3) - or (myClass == "Paladin" and mySpec == 2) - or (myClass == "DeathKnight" and mySpec == 1) - or (myClass == "Monk" and mySpec == 1) - or (myClass == "Druid" and mySpec == 3) then + or (myClass == "Paladin" and mySpec == 2) + or (myClass == "DeathKnight" and mySpec == 1) + or (myClass == "Monk" and mySpec == 1) + or (myClass == "Druid" and mySpec == 3) then classType = "staminaClass" end return classType @@ -112,11 +112,11 @@ end function br.playerHasItem(itemID) if itemID == nil then return false end local itemFound = false - for i = 0, 4 do --Let's look at each bag + for i = 0, 4 do --Let's look at each bag local numBagSlots = C_Container.GetContainerNumSlots(i) - if numBagSlots > 0 then --Only look for slots if bag present - for x = 1, numBagSlots do --Let's look at each bag slot - local bagItemID = C_Container.GetContainerItemID(i,x) + if numBagSlots > 0 then --Only look for slots if bag present + for x = 1, numBagSlots do --Let's look at each bag slot + local bagItemID = C_Container.GetContainerItemID(i, x) if tostring(bagItemID) == tostring(itemID) then --Compare bagItemID to parameter itemFound = true end @@ -149,7 +149,7 @@ function br.usePotion(skipSurvivability) return true end end - --Intellect + --Intellect elseif classType == "intellectClass" then if br.playerCanUseItem(intellectPotion) then if br.playerHasBuff(intellectPotionBuff) == false then @@ -157,7 +157,7 @@ function br.usePotion(skipSurvivability) return true end end - --Strength + --Strength elseif classType == "strengthClass" or (classType == "staminaClass" and skipSurvivability == true) then if br.playerCanUseItem(strengthPotion) then if br.playerHasBuff(strengthPotionBuff) == false then @@ -165,7 +165,7 @@ function br.usePotion(skipSurvivability) return true end end - --Armor + --Armor elseif classType == "staminaClass" and skipSurvivability == false then if br.playerCanUseItem(armorPotion) then if br.playerHasBuff(armorPotionBuff) == false then @@ -189,7 +189,7 @@ function br.useFlask(skipSurvivability) return true end end - --Intellect + --Intellect elseif classType == "intellectClass" then if br.playerCanUseItem(intellectFlask) then if br.playerHasBuff(intellectFlaskBuff) == false then @@ -197,7 +197,7 @@ function br.useFlask(skipSurvivability) return true end end - --Strength + --Strength elseif classType == "strengthClass" or (classType == "staminaClass" and skipSurvivability == true) then if br.playerCanUseItem(strengthFlask) then if br.playerHasBuff(strengthFlaskBuff) == false then @@ -205,7 +205,7 @@ function br.useFlask(skipSurvivability) return true end end - --Stamina + --Stamina elseif classType == "staminaClass" and skipSurvivability == false then if br.playerCanUseItem(staminaFlask) then if br.playerHasBuff(staminaFlaskBuff) == false then @@ -229,7 +229,7 @@ function br.useFood(skipSurvivability) return true end end - --Intellect + --Intellect elseif classType == "intellectClass" then if br.playerCanUseItem(intellectFood) then if br.playerHasBuff(intellectFoodBuff) == false then @@ -237,7 +237,7 @@ function br.useFood(skipSurvivability) return true end end - --Strength + --Strength elseif classType == "strengthClass" or (classType == "staminaClass" and skipSurvivability == true) then if br.playerCanUseItem(strengthFood) then if br.playerHasBuff(strengthFoodBuff) == false then @@ -245,7 +245,7 @@ function br.useFood(skipSurvivability) return true end end - --Stamina + --Stamina elseif classType == "staminaClass" and skipSurvivability == false then if br.playerCanUseItem(staminaFood) then if br.playerHasBuff(staminaFoodBuff) == false then diff --git a/System/SlashCommands.lua b/System/SlashCommands.lua index 3083e4c2d..f19e2ee12 100644 --- a/System/SlashCommands.lua +++ b/System/SlashCommands.lua @@ -485,10 +485,10 @@ function br._G.SlashCmdList.dumpInfo(msg, editbox) _G.targetInfo.name = br._G.UnitName("target") local thisUnit = br.enemy[k].unit _G.targetInfo.unitID = thisUnit.id - local buff1 = br._G.UnitBuff("target", 1) - local buff2 = br._G.UnitBuff("target", 2) - local deBuff1 = br._G.UnitBuff("target", 1) - local deBuff2 = br._G.UnitBuff("target", 2) + local buff1 = br.UnitBuff("target", 1) + local buff2 = br.UnitBuff("target", 2) + local deBuff1 = br.UnitBuff("target", 1) + local deBuff2 = br.UnitBuff("target", 2) if buff1 then _G.targetInfo.buff1 = buff1 end diff --git a/System/UsefulFeatures.lua b/System/UsefulFeatures.lua index 41fc697d9..ec656b544 100644 --- a/System/UsefulFeatures.lua +++ b/System/UsefulFeatures.lua @@ -17,7 +17,7 @@ end local hooksecurefunc, select, UnitBuff, UnitDebuff, UnitAura, UnitGUID, _, tonumber, strfind = br._G.hooksecurefunc, br._G.select, - br._G.UnitBuff, + br.UnitBuff, br._G.UnitDebuff, br._G.UnitAura, br._G.UnitGUID, diff --git a/unusedFunctions.lua b/unusedFunctions.lua index eecb616e9..93e3881ea 100644 --- a/unusedFunctions.lua +++ b/unusedFunctions.lua @@ -82,7 +82,7 @@ function br.getVengeance() elseif select(3, br._G.UnitClass("player")) == 11 then VengeanceID = 84840 -- Druid end - if br._G.UnitBuff("player", VengeanceID) then + if br.UnitBuff("player", VengeanceID) then return select(14, br._G.UnitAura("player", br._G.GetSpellInfo(VengeanceID))) end return 0