Skip to content

Commit

Permalink
Add "No Enchant" Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Kkthnx committed Apr 18, 2024
1 parent b346cae commit c5640ee
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 6 deletions.
28 changes: 22 additions & 6 deletions KkthnxUI/Libraries/LibRangeCheck-3.0/LibRangeCheck-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ License: MIT
-- @class file
-- @name LibRangeCheck-3.0
local MAJOR_VERSION = "LibRangeCheck-3.0"
local MINOR_VERSION = 15 -- real minor version: 13
local MINOR_VERSION = 16 -- real minor version: 13

-- GLOBALS: LibStub, CreateFrame

Expand All @@ -67,7 +67,7 @@ local CheckInteractDistance = CheckInteractDistance
local GetInventoryItemLink = GetInventoryItemLink
local GetItemInfo = GetItemInfo
local GetNumSpellTabs = GetNumSpellTabs
local GetSpellBookItemInfo = GetSpellBookItemInfo
local GetSpellBookItemName = GetSpellBookItemName
local GetSpellInfo = GetSpellInfo
local GetSpellTabInfo = GetSpellTabInfo
local GetTime = GetTime
Expand Down Expand Up @@ -137,9 +137,24 @@ local InteractLists = {
}

local MeleeRange = 2
local MatchSpellByID = {} -- specific matching to avoid incorrect index
local FriendSpells, HarmSpells, ResSpells, PetSpells = {}, {}, {}, {}

for _, n in ipairs({ "EVOKER", "DEATHKNIGHT", "DEMONHUNTER", "DRUID", "HUNTER", "SHAMAN", "MAGE", "PALADIN", "PRIEST", "WARLOCK", "WARRIOR", "MONK", "ROGUE" }) do
for _, n in ipairs({
"EVOKER",
"DEATHKNIGHT",
"DEMONHUNTER",
"DRUID",
"HUNTER",
"SHAMAN",
"MAGE",
"PALADIN",
"PRIEST",
"WARLOCK",
"WARRIOR",
"MONK",
"ROGUE",
}) do
FriendSpells[n], HarmSpells[n], ResSpells[n], PetSpells[n] = {}, {}, {}, {}
end

Expand Down Expand Up @@ -200,6 +215,8 @@ if not isRetail then
end

if isEraSOD then
MatchSpellByID[401417] = true -- Regeneration (Rune): Conflicts with Racial Passive on Trolls

tinsert(FriendSpells.MAGE, 401417) -- Regeneration (40 yards)
tinsert(FriendSpells.MAGE, 412510) -- Mass Regeneration (40 yards)
end
Expand Down Expand Up @@ -657,15 +674,14 @@ local function getNumSpells()
end

-- return the spellIndex of the given spell by scanning the spellbook
local allowSpellType = { SPELL = true, FUTURESPELL = true }
local function findSpellIdx(spellName, sid)
if not spellName or spellName == "" then
return nil
end

for i = 1, getNumSpells() do
local spellType, id = GetSpellBookItemInfo(i, BOOKTYPE_SPELL)
if sid == id and allowSpellType[spellType] then
local name, _, id = GetSpellBookItemName(i, BOOKTYPE_SPELL)
if sid == id or (spellName == name and not MatchSpellByID[id]) then
return i
end
end
Expand Down
33 changes: 33 additions & 0 deletions KkthnxUI/Modules/Miscellaneous/Elements/SlotItemLevel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,28 @@ function Module:ItemLevel_UpdateTraits(button, id, link)
end
end

local function CanEnchantSlot(unit, slot)
-- all classes have something that increases power or survivability on chest/cloak/weapons/rings/wrist/boots/legs
if slot == 5 or slot == 11 or slot == 12 or slot == 15 or slot == 16 or slot == 8 or slot == 9 or slot == 7 or slot == 6 then
return true
end

-- Offhand filtering smile :)
if slot == 17 then
local offHandItemLink = GetInventoryItemLink(unit, slot)
if offHandItemLink then
local itemEquipLoc = select(4, GetItemInfoInstant(offHandItemLink))
return itemEquipLoc ~= "INVTYPE_HOLDABLE" and itemEquipLoc ~= "INVTYPE_SHIELD"
end
return false
end

return false
end

-- Add a new configuration option in your addon settings
local showNoEnchant = true -- Default to true, meaning the "No Enchant" feature is enabled

function Module:ItemLevel_UpdateInfo(slotFrame, info, quality)
local infoType = type(info)
local level
Expand All @@ -194,6 +216,17 @@ function Module:ItemLevel_UpdateInfo(slotFrame, info, quality)
local enchant = info.enchantText
if enchant then
slotFrame.enchantText:SetText(enchant)
slotFrame.enchantText:SetTextColor(0, 1, 0) -- Set text color to green for normal enchant
elseif showNoEnchant then -- Check if the "No Enchant" feature is enabled
-- Check if the slot can be enchanted
if CanEnchantSlot("player", slotFrame:GetID()) then
slotFrame.enchantText:SetText("No Enchant")
slotFrame.enchantText:SetTextColor(1, 0, 0) -- Set text color to red for missing enchant
else
slotFrame.enchantText:SetText("")
end
else
slotFrame.enchantText:SetText("") -- Clear the enchant text if the feature is disabled
end

local gemStep, essenceStep = 1, 1
Expand Down

0 comments on commit c5640ee

Please sign in to comment.