Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
337 changes: 337 additions & 0 deletions Modules/Config/DefenseSection.lua

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions Modules/Data/Constants.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
local ECSLoader = ECSLoader
local IsClassic = ECS.IsClassic
local IsWotlk = ECS.IsWotlk

---@class Data
local Data = ECSLoader:ImportModule("Data")

Expand Down Expand Up @@ -351,6 +355,10 @@ Data.Aura = {
[25894] = (ECS.IsClassic and 1 or nil), -- Greater Blessing of Wisdom rank 1
[25918] = (ECS.IsClassic and 1 or nil), -- Greater Blessing of Wisdom rank 2
},
ResistanceInterrupt = {
[14743] = IsWotlk and nil or 10, -- Focused Casting
[27828] = IsWotlk and nil or 20, -- Focused Casting
},
SpellCrit = {
[24907] = ((not ECS.IsClassic) and 5 or nil), -- Moonkin Aura
[29177] = 6, -- Elemental Devastation Rank 2
Expand Down Expand Up @@ -519,6 +527,18 @@ Data.Gem = {
[41477] = 4, -- Perfect Sundered Dark Jade
[42146] = 17, -- Lustrous Dragon's Eye
},
ResistRoot = {
[32195] = (IsWotlk and nil or 5), -- Enigmatic Skyfire Diamond
},
ResistSnare = {
[32195] = (IsWotlk and nil or 5), -- Enigmatic Skyfire Diamond
},
ResistStun = {
[25896] = (IsWotlk and nil or 5), -- Powerful Earthstorm Diamond
[32195] = (IsWotlk and nil or 5), -- Enigmatic Skyfire Diamond
[32641] = 5, -- Imbued Unstable Diamond
[32640] = 5, -- Potent Unstable Diamond
}
}
Data.Item = {
IsTimeworn = {
Expand Down Expand Up @@ -643,6 +663,26 @@ Data.Item = {
[234963] = true,
[235047] = true,
},
ResistDisorient = {
[30519] = 10, -- Foreman's Reinforced Helmet
},
ResistFleeing = {
[17759] = (IsWotlk and nil or 1), -- Mark of Resolution
[28428] = 8, -- Lionheart Blade
[28429] = 8, -- Lionheart Champion
[28430] = 8, -- Lionheart Executioner
},
ResistSilence = {
[18345] = (IsClassic and 5 or nil), -- Murmuring Ring
[19786] = (IsClassic and 7 or nil), -- Voice Amplification Modulator
[21517] = (IsClassic and 10 or nil), -- Gnomish Turban of Psychic Might
[234134] = 10, -- Gnomish Turban of Psychic Might
},
ResistStun = {
[17759] = (IsWotlk and nil or 1), -- Mark of Resolution
[23838] = 10, -- Foreman's Enchanted Helmet
[30519] = 10, -- Foreman's Reinforced Helmet
},
SpellHaste = {
[235874] = 2,
[236060] = 2,
Expand Down Expand Up @@ -788,12 +828,15 @@ Data.Item = {
}
Data.setNames = {
AUGURS_REGALIA = "Augur's Regalia",
BATTLECAST_GARB = "Battlecast Garb",
BLOODSOUL_EMBRACE = "Bloodsoul Embrace",
DAWN_OF_TRANSCENDENCE = "Dawn of Transcendence",
FEL_IRON_CHAIN = "Fel Iron Chain",
FREETHINKERS_ARMOR = "Freethinker's Armor",
GREEN_DRAGON_MAIL = "Green Dragon Mail",
HARUSPEXS_GARB = "Haruspex's Garb",
IRONWEAVE_BATTLESUIT = "Ironweave Battlesuit",
IRONWEAVE_BATTLESUIT_SOD = "Ironweave Battlesuit SoD",
LIVING_GREEN_DRAGON_MAIL = "Living Green Dragon Mail",
PRIMAL_MOONCLOTH = "Primal Mooncloth",
STORMRAGE_RAIMENT = "Stormrage Raiment",
Expand Down
13 changes: 13 additions & 0 deletions Modules/Data/Data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local Data = ECSLoader:CreateModule("Data")
local dataFunctionRefs
local playerLevel = UnitLevel("player")
local enemyLevel = playerLevel + 3
local mechanicResistance = Data:GetMechanicResistance()

---@param refName string
---@return number | string
Expand Down Expand Up @@ -67,6 +68,18 @@ dataFunctionRefs = {
["BlockChance"] = function() return Data:GetBlockChance() end,
["BlockValue"] = function() return Data:GetBlockValue() end,
["ResilienceValue"] = function() return ECS.IsClassic and 0 or Data:GetResilienceRating() end,
["StunResistance"] = function() return mechanicResistance.stun end,
["CharmResistance"] = function() return mechanicResistance.charm end,
["DisorientResistance"] = function() return mechanicResistance.disorient end,
["RootResistance"] = function() return mechanicResistance.root end,
["SnareResistance"] = function() return mechanicResistance.snare end,
["InterruptResistance"] = function() return mechanicResistance.interrupt end,
["SilenceResistance"] = function() return mechanicResistance.silence end,
["FleeingResistance"] = function() return mechanicResistance.fleeing end,
["HorrorResistance"] = function() return mechanicResistance.horror end,
["DiseaseResistance"] = function() return mechanicResistance.disease end,
["CurseResistance"] = function() return mechanicResistance.curse end,
["PoisonResistance"] = function() return mechanicResistance.poison end,
-- Spell
["SpellHitRating"] = function() return ECS.IsClassic and 0 or Data:SpellHitRating() end,
["SpellHitBonus"] = function() return Data.SpellHitBonus(Data.HOLY_SCHOOL) end,
Expand Down
59 changes: 45 additions & 14 deletions Modules/Data/DataUtils.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
local ECSLoader = ECSLoader
local floor = math.floor
local GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex
local GetInventoryItemLink = GetInventoryItemLink
local GetItemInfo = C_Item.GetItemInfo
local GetRuneForEquipmentSlot = C_Engraving.GetRuneForEquipmentSlot
local IsSoD = ECS.IsSoD
local IsSpellKnown = C_SpellBook.IsSpellKnown
local IsWotlk = ECS.IsWotlk
local match = string.match
local min = math.min
local strsplit = strsplit
local tonumber = tonumber

---@class DataUtils
local DataUtils = ECSLoader:CreateModule("DataUtils")
---@type Data
local Data = ECSLoader:ImportModule("Data")

local IsSpellKnown = C_SpellBook.IsSpellKnown

--- Rounds every number down to the given decimal places
---@param num number
---@param decimalPlaces number
Expand All @@ -14,14 +26,14 @@ function DataUtils:Round(num, decimalPlaces)
return 0
end
local mult = 10^(decimalPlaces)
return math.floor(num * mult + 0.5) / mult
return floor(num * mult + 0.5) / mult
end

---@return boolean
function DataUtils:IsShapeshifted()
local i = 1
repeat
local aura = C_UnitAuras.GetBuffDataByIndex("player", i)
local aura = GetBuffDataByIndex("player", i)
i = i + 1
if aura and aura.spellId then
if Data.Aura.IsFeralForm[aura.spellId] then
Expand All @@ -44,7 +56,7 @@ function DataUtils.GetMissChanceByDifference(weaponSkill, defenseValue)
-- For a difference of 11-14 each point in weapon skill is worth 0.4% miss chance reduction
local extraWeaponSkillDifference = ((15 - delta) * 0.2)
return DataUtils:Round(6 + delta * 0.2 - extraWeaponSkillDifference, 2)
elseif ECS.IsWotlk then
elseif IsWotlk then
-- For a difference of 15+ each point in weapon skill is worth 0.2% miss chance reduction
return 5 + delta * 0.2
else
Expand All @@ -58,7 +70,7 @@ end
---@param defenseValue number
---@return number
function DataUtils:GetGlancingChanceByDifference(level, weaponSkill, defenseValue)
local glancingChance = 0.1 + (defenseValue - math.min(level*5, weaponSkill)) * 0.02
local glancingChance = 0.1 + (defenseValue - min(level*5, weaponSkill)) * 0.02

-- Ensure the glancing chance does not exceed 1.0 (100%)
if glancingChance > 1.0 then
Expand All @@ -72,7 +84,7 @@ end
---@return number
function DataUtils:GetGlancingDamage(weaponSkill, defenseValue)
local difference = defenseValue - weaponSkill
local low = math.min(0.91 ,(1.3 - 0.05 * difference))
local low = min(0.91 ,(1.3 - 0.05 * difference))

-- Ensure low does not go below 0.01
if low < 0.01 then
Expand Down Expand Up @@ -107,7 +119,7 @@ end
---@return number|nil
function DataUtils:GetEnchantFromItemLink(itemLink)
if itemLink then
local _, itemStringLink = C_Item.GetItemInfo(itemLink)
local _, itemStringLink = GetItemInfo(itemLink)
if itemStringLink then
local _, _, enchant, _ = strsplit(":", itemStringLink, 4)
return tonumber(enchant)
Expand All @@ -120,7 +132,7 @@ end
---@return number|nil
function DataUtils.GetRuneForEquipSlot(equipSlot)
local slotId, _ = GetInventorySlotInfo(equipSlot)
local runeInfo = C_Engraving.GetRuneForEquipmentSlot(slotId)
local runeInfo = GetRuneForEquipmentSlot(slotId)

if runeInfo then
return runeInfo.itemEnchantmentID
Expand All @@ -130,13 +142,13 @@ function DataUtils.GetRuneForEquipSlot(equipSlot)
end

---@param itemLink ItemLink
---@return string | nil, string | nil, string | nil
---@return table<number | nil> | nil
function DataUtils:GetSocketedGemsFromItemLink(itemLink)
if itemLink then
local _, itemStringLink = C_Item.GetItemInfo(itemLink)
local _, itemStringLink = GetItemInfo(itemLink)
if itemStringLink then
local _, _, gem1, gem2, gem3, _ = strsplit(":", itemStringLink, 6)
return gem1, gem2, gem3
return {gem1 and tonumber(gem1) or nil, gem2 and tonumber(gem2) or nil, gem3 and tonumber(gem3) or nil}
end
end
return nil
Expand All @@ -157,7 +169,7 @@ end
---@return number
function DataUtils:GetActiveTalentSpell(talentList)
for i = #talentList,1,-1 do
if C_SpellBook.IsSpellKnown(talentList[i]) then
if IsSpellKnown(talentList[i]) then
return i
end
end
Expand All @@ -167,7 +179,7 @@ function DataUtils:GetActiveTalentSpell(talentList)
---@return number
function DataUtils:CountTimewornItems()
local timeworn = 0
if ECS.IsSoD then
if IsSoD then
for i = 1, 18 do
local id, _ = GetInventoryItemID("player", i)
if Data.Item.IsTimeworn[id] then
Expand All @@ -178,4 +190,23 @@ function DataUtils:CountTimewornItems()
return timeworn
end

---@return number
function DataUtils:GetValueFromAuraTooltip(index, type)
if not ECS.scanningTooltip then
ECS.scanningTooltip = CreateFrame("GameTooltip", "scanningTooltip", nil, "GameTooltipTemplate")
ECS.scanningTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
end

ECS.scanningTooltip:ClearLines()
ECS.scanningTooltip:SetUnitAura("player", index, type)
local region = select(5, ECS.scanningTooltip:GetRegions())
if region and region:GetObjectType() == "FontString" then
local tooltip = region:GetText()
if tooltip then
return tonumber(match(tooltip, "%d[%d,.]*"))
end
end
return 0
end

return DataUtils
Loading
Loading