Skip to content

Commit

Permalink
System - Use br.UnitBuff instead of br._G.UnitBuff
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteOne committed Aug 31, 2024
1 parent defd97f commit f467be5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions System/Functions/Aura.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions System/Functions/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, "")
Expand Down
88 changes: 44 additions & 44 deletions System/Misc/foodflaskpot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -149,23 +149,23 @@ 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
br.useItem(intellectPotion)
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
br.useItem(strengthPotion)
return true
end
end
--Armor
--Armor
elseif classType == "staminaClass" and skipSurvivability == false then
if br.playerCanUseItem(armorPotion) then
if br.playerHasBuff(armorPotionBuff) == false then
Expand All @@ -189,23 +189,23 @@ 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
br.useItem(intellectFlask)
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
br.useItem(strengthFlask)
return true
end
end
--Stamina
--Stamina
elseif classType == "staminaClass" and skipSurvivability == false then
if br.playerCanUseItem(staminaFlask) then
if br.playerHasBuff(staminaFlaskBuff) == false then
Expand All @@ -229,23 +229,23 @@ 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
br.useItem(intellectFood)
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
br.useItem(strengthFood)
return true
end
end
--Stamina
--Stamina
elseif classType == "staminaClass" and skipSurvivability == false then
if br.playerCanUseItem(staminaFood) then
if br.playerHasBuff(staminaFoodBuff) == false then
Expand Down
8 changes: 4 additions & 4 deletions System/SlashCommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion System/UsefulFeatures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion unusedFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f467be5

Please sign in to comment.