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
86 changes: 86 additions & 0 deletions Modules/Data/Constants.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
local IsTBC = ECS.IsTBC
local IsWotlk = ECS.IsWotlk

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

Expand Down Expand Up @@ -79,6 +82,65 @@ Data.Aura = {
[17800] = (ECS.IsWotlk and -5 or nil), -- Shadow Mastery 5/5
[22959] = (ECS.IsWotlk and -5 or nil), -- Improved Scorch
},
---@type table<Bitmask>
HitReductionMelee = {
[0] = {
[35346] = 50, -- Warp
[54956] = 100, -- Impaling Charge
[59827] = 100, -- Impaling Charge
[50240] = 200, -- Evasive Maneuvers
[2651] = (IsTBC and 20 or nil), -- Elune's Grace
[455868] = -1, -- Revealed Weakness
[445875] = -100, -- Gloom
[460725] = -100, -- Gloom
},
[127] = {
[54603] = 25, -- Serpent's Agility
},
[95] = {
[50280] = 20, -- Oily Coat
},
[14] = {
[47000] = (IsWotlk and 15 or 13), -- Improved Blink
[46989] = (IsWotlk and 30 or 25), -- Improved Blink
},
},
HitReductionRanged = {
[50280] = 20, -- Oily Coat
[455868] = -1, -- Revealed Weakness
[2651] = (IsTBC and 20 or nil), -- Elune's Grace
[26669] = 25, -- Evasion
[47000] = (IsWotlk and 15 or 13), -- Improved Blink
[46989] = (IsWotlk and 30 or 25), -- Improved Blink
[54603] = 25, -- Serpent's Agility
[67801] = 100, -- Deterrence
},
---@type table<Bitmask>
HitReductionSpell = {
[0] = {
[54603] = 25, -- Serpent's Agility
[50280] = 20, -- Oily Coat
[445875] = -100, -- Gloom
[460725] = -100, -- Gloom
[56673] = -100, -- Fight Wyrm
},
[127] = {
[33196] = (IsWotlk and -1 or nil), -- Misery
[33197] = (IsWotlk and -2 or nil), -- Misery
[33198] = (IsWotlk and -1 or nil), -- Misery
},
[126] = {
[47000] = (IsWotlk and 15 or 13), -- Improved Blink
[31965] = -3, -- Spell Debuffs 2 (80)
[46989] = (IsWotlk and 30 or 25), -- Improved Blink
[455868] = -1, -- Revealed Weakness
[31224] = 90, -- Cloak of Shadows
[39666] = 90, -- Cloak of Shadows
[462873] = 90, -- Cloak of Shadows
[65961] = 90, -- Cloak of Shadows
[50240] = 200, -- Evasive Maneuvers
},
},
IsFeralForm = {
[768] = true, -- Cat Form
[5487] = true, -- Bear Form
Expand Down Expand Up @@ -786,6 +848,30 @@ Data.Item = {
[234032] = 2,
},
}
Data.Talent = {
[Data.MAGE] = {
ARCTIC_WINDS = {31674,31675,31676,31677,31678}
},
[Data.DEATHKNIGHT] = {
FRIGID_DREADPLATE = {49186,51108,51109},
},
[Data.HUNTER] = {
DISPLACEMENT = {34478,34479,34481},
},
[Data.ROGUE] = {
HEIGHTENED_SENSES = {30894,30895},
},
[Data.PALADIN] = {
PURSUIT_OF_JUSTICE = {26022,26023,44414},
DIVINE_PURPOSE = {31871,31872},
},
[Data.PALADIN] = {
BALANCE_OF_POWER = {33592,33596},
},
[Data.WARRIOR] = {
IMPROVED_SPELL_REFLECTION = {59088,59089},
},
}
Data.setNames = {
AUGURS_REGALIA = "Augur's Regalia",
BLOODSOUL_EMBRACE = "Bloodsoul Embrace",
Expand Down
138 changes: 137 additions & 1 deletion Modules/Data/Defense.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
local IsTBC = ECS.IsTBC
local IsWotlk = ECS.IsWotlk
local IsSpellKnown = C_SpellBook.IsSpellKnown
local GetDebuffDataByIndex = C_UnitAuras.GetDebuffDataByIndex
local GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex
local band = bit.band
local pairs = pairs

---@class Data
local Data = ECSLoader:ImportModule("Data")
---@type DataUtils
Expand All @@ -8,7 +16,18 @@ local Utils = ECSLoader:ImportModule("Utils")
local _Defense = {}

local _, _, classId = UnitClass("player")

local DRUID = Data.DRUID
local DEATHKNIGHT = Data.DEATHKNIGHT
local WARRIOR = Data.WARRIOR
local MAGE = Data.MAGE
local PALADIN = Data.PALADIN
local HUNTER = Data.HUNTER
local ROGUE = Data.ROGUE
local Talent = Data.Talent
local FROST = Data.FROST_SCHOOL
local NATURE = Data.NATURE_SCHOOL
local ARCANE = Data.ARCANE_SCHOOL
local SHADOW = Data.SHADOW_SCHOOL
local MAX_SKILL = (UnitLevel("player")) * 5
-- Every 25 defense reduce the chance to be critically hit by 1 %
local DEFENSE_FOR_CRIT_REDUCTION = 25
Expand Down Expand Up @@ -236,3 +255,120 @@ function _Defense:GetEnchantsBlockValue()
end
return mod
end

---@return table<number>
function _Defense:GetHitReduction()
local hitReduction = {
spell = {0,0,0,0,0,0,0},
melee= 0,
ranged = 0
}

local i = 1
repeat
local aura = GetBuffDataByIndex("player", i)
i = i + 1
if aura and aura.spellId then
hitReduction.melee = hitReduction.melee + (Data.Aura.HitReductionMelee[aura.spellId] or 0)
hitReduction.ranged = hitReduction.ranged + (Data.Aura.HitReductionRanged[aura.spellId] or 0)

for k,v in pairs(Data.Aura.HitReductionSpell) do
for s=1,7 do
if ((k == 0) or band(k,s-1) ~= 0x0) then
hitReduction.spell[s] = hitReduction.spell[s] + (v[aura.spellId] or 0)
end
end
end
end
until (not aura)
i = 1
repeat
local aura = GetDebuffDataByIndex("player", i)
i = i + 1
if aura and aura.spellId then
hitReduction.melee = hitReduction.melee + (Data.Aura.HitReductionMelee[aura.spellId] or 0)
hitReduction.ranged = hitReduction.ranged + (Data.Aura.HitReductionRanged[aura.spellId] or 0)

for k,v in pairs(Data.Aura.HitReductionSpell) do
for s=1,7 do
if ((k == 0) or band(k,s-1) ~= 0x0) then
hitReduction.spell[s] = hitReduction.spell[s] + (v[aura.spellId] or 0)
end
end
end
end
until (not aura)

if IsWotlk then
if IsSpellKnown(20582) then -- Quickness
hitReduction.melee = hitReduction.melee + 2
hitReduction.ranged = hitReduction.ranged + 2
end
if IsSpellKnown(822) then -- Magic Resistance
for s=1,7 do
if band(126,s-1) ~= 0x0 then
hitReduction.spell[s] = hitReduction.spell[s] + 2
end
end
end
if IsSpellKnown(20579) then -- Magic Resistance
for s=1,7 do
if band(126,s-1) ~= 0x0 then
hitReduction.spell[s] = hitReduction.spell[s] + 2
end
end
end
hitReduction.spell[ARCANE] = hitReduction.spell[ARCANE] + (IsSpellKnown(20592) and 2 or 0) -- Arcane Resistance
hitReduction.spell[FROST] = hitReduction.spell[FROST] + (IsSpellKnown(20596) and 2 or 0) -- Frost Resistance
hitReduction.spell[NATURE] = hitReduction.spell[NATURE] + (IsSpellKnown(20583) and 2 or 0) -- Nature Resistance
hitReduction.spell[NATURE] = hitReduction.spell[NATURE] + (IsSpellKnown(20551) and 2 or 0) -- Nature Resistance
hitReduction.spell[SHADOW] = hitReduction.spell[SHADOW] + (IsSpellKnown(59535) and 2 or 0) -- Shadow Resistance
hitReduction.spell[SHADOW] = hitReduction.spell[SHADOW] + (IsSpellKnown(59540) and 2 or 0) -- Shadow Resistance
hitReduction.spell[SHADOW] = hitReduction.spell[SHADOW] + (IsSpellKnown(59538) and 2 or 0) -- Shadow Resistance
hitReduction.spell[SHADOW] = hitReduction.spell[SHADOW] + (IsSpellKnown(59221) and 2 or 0) -- Shadow Resistance
hitReduction.spell[SHADOW] = hitReduction.spell[SHADOW] + (IsSpellKnown(59541) and 2 or 0) -- Shadow Resistance
hitReduction.spell[SHADOW] = hitReduction.spell[SHADOW] + (IsSpellKnown(59536) and 2 or 0) -- Shadow Resistance
end

local spellMod = 0
if classId == DRUID then
spellMod = 3 * DataUtils:GetActiveTalentSpell(Talent[DRUID].BALANCE_OF_POWER) -- 126
elseif classId == ROGUE then
local mod = 2 * DataUtils:GetActiveTalentSpell(Talent[ROGUE].HEIGHTENED_SENSES)
spellMod = mod -- 126
hitReduction.ranged = hitReduction.ranged + mod
elseif classId == PALADIN then
if IsTBC then
spellMod = 1 * DataUtils:GetActiveTalentSpell(Talent[PALADIN].PURSUIT_OF_JUSTICE) -- 126
elseif IsWotlk then
local mod = 2 * DataUtils:GetActiveTalentSpell(Talent[PALADIN].DIVINE_PURPOSE)
spellMod = mod -- 126
hitReduction.ranged = hitReduction.ranged + mod -- 127
end
elseif classId == DEATHKNIGHT then
hitReduction.melee = hitReduction.melee + 1 * DataUtils:GetActiveTalentSpell(Talent[DEATHKNIGHT].FRIGID_DREADPLATE)
elseif classId == HUNTER then
if not ECS.IsClassic then
local mod = 1 * DataUtils:GetActiveTalentSpell(Talent[HUNTER].DISPLACEMENT)
spellMod = mod -- 126
hitReduction.ranged = hitReduction.ranged + mod
hitReduction.melee = hitReduction.melee + mod
end
elseif classId == MAGE then
if not ECS.IsClassic then
local mod = 1 * DataUtils:GetActiveTalentSpell(Talent[MAGE].ARCTIC_WINDS)
hitReduction.ranged = hitReduction.ranged + mod
hitReduction.melee = hitReduction.melee + mod
end
elseif classId == WARRIOR then
spellMod = 2 * DataUtils:GetActiveTalentSpell(Talent[WARRIOR].IMPROVED_SPELL_REFLECTION) -- 126
end

for s=1,7 do
if band(126,s-1) ~= 0x0 then
hitReduction.spell[s] = hitReduction.spell[s] + spellMod
end
end

return hitReduction
end
1 change: 1 addition & 0 deletions types/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
---@alias EquipSlot string
---@alias ItemLink string
---@alias Color string
---@alias Bitmask number
Loading