Skip to content

Commit

Permalink
RangeFader: Remove CheckInteractDistance and IsItemInRange checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Nov 17, 2023
1 parent 4dbf868 commit 03842c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 59 deletions.
2 changes: 0 additions & 2 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ globals = {
"C_TooltipInfo",
"CancelItemTempEnchantment",
"CancelUnitBuff",
"CheckInteractDistance",
"CooldownFrame_Set",
"CopyTable",
"CreateFrame",
Expand Down Expand Up @@ -106,7 +105,6 @@ globals = {
"IsAddOnLoaded",
"IsInGroup",
"IsInRaid",
"IsItemInRange",
"IsPlayerInWorld",
"IsPlayerSpell",
"IsPVPTimerRunning",
Expand Down
58 changes: 1 addition & 57 deletions Modules/RangeFader/RangeFader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ function PitBull4_RangeFader:OnEnable()
self:ScheduleRepeatingTimer("UpdateNonWacky", 0.7)
end

local check_method_to_dist_index = {
inspect = 1,
trade = 2,
duel = 3,
follow = 4,
}

local friendly_spells = {}
local pet_spells = {}
local enemy_spells = {}
Expand Down Expand Up @@ -92,10 +85,6 @@ do
end

local function friendly_is_in_range(unit)
if CheckInteractDistance(unit, 1) then
return true
end

if UnitIsDeadOrGhost(unit) then
for _, name in ipairs(res_spells) do
if IsSpellInRange(name, unit) == 1 then
Expand All @@ -118,10 +107,6 @@ local function friendly_is_in_range(unit)
end

local function pet_is_in_range(unit)
if CheckInteractDistance(unit, 2) then
return true
end

for _, name in ipairs(friendly_spells) do
if IsSpellInRange(name, unit) == 1 then
return true
Expand All @@ -137,10 +122,6 @@ local function pet_is_in_range(unit)
end

local function enemy_is_in_range(unit)
if CheckInteractDistance(unit, 2) then
return true
end

for _, name in ipairs(enemy_spells) do
if IsSpellInRange(name, unit) == 1 then
return true
Expand Down Expand Up @@ -169,24 +150,12 @@ function PitBull4_RangeFader:GetOpacity(frame)
return 1
end

if check_method== "follow" or check_method == "trade" or check_method == "duel" or check_method == "follow" then
if CheckInteractDistance(unit, check_method_to_dist_index[check_method]) then
return 1
else
return db.out_of_range_opacity
end
elseif check_method == "custom_spell" and db.custom_spell then
if check_method == "custom_spell" and db.custom_spell then
if IsSpellInRange(db.custom_spell, unit) == 1 then
return 1
else
return db.out_of_range_opacity
end
elseif check_method == "custom_item" and db.custom_item then
if IsItemInRange(db.custom_item, unit) == 1 then
return 1
else
return db.out_of_range_opacity
end
elseif check_method == "helpful" then
if UnitInRange(unit) then
return 1
Expand Down Expand Up @@ -272,11 +241,7 @@ PitBull4_RangeFader:SetLayoutOptionsFunction(function(self)
values = {
helpful = L["Helpful spells (~40 yards)"],
class = L["Class abilities"],
follow = L["Follow (~28 yards)"],
trade = L["Trade (~11 yards)"],
duel = L["Duel (~10 yards)"],
custom_spell = L["Custom spell"],
custom_item = L["Custom item"],
visible = L["Visible (~100 yards)"],
},
get = function(info)
Expand Down Expand Up @@ -354,26 +319,5 @@ PitBull4_RangeFader:SetLayoutOptionsFunction(function(self)
local db = PitBull4.Options.GetLayoutDB(self)
return db.check_method ~= "custom_spell"
end,
}, 'custom_item', {
type = 'input',
name = L["Custom item"],
desc = L["Enter the name of the item you want use to check the range with."],
get = function(info)
local db = PitBull4.Options.GetLayoutDB(self)

return db.custom_item
end,
set = function(info, value)
local db = PitBull4.Options.GetLayoutDB(self)

db.custom_item = value

PitBull4.Options.UpdateFrames()
PitBull4:RecheckAllOpacities()
end,
hidden = function(info)
local db = PitBull4.Options.GetLayoutDB(self)
return db.check_method ~= "custom_item"
end,
}
end)

0 comments on commit 03842c3

Please sign in to comment.