-
Notifications
You must be signed in to change notification settings - Fork 18
/
SpellHit.lua
executable file
·153 lines (125 loc) · 4.13 KB
/
SpellHit.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---@type Data
local Data = ECSLoader:ImportModule("Data")
---@type DataUtils
local DataUtils = ECSLoader:ImportModule("DataUtils")
local _SpellHit = {}
function Data:SpellMissChanceSameLevel()
local missChance = ECS.IsWotlk and 3 or 4
missChance = missChance - _SpellHit:GetTalentSpellHitBonus()
local mod = _SpellHit:GetSpellHitBonus()
if mod then
missChance = missChance - mod
end
if ECS.IsWotlk and missChance < 0 then
missChance = 0
elseif (not ECS.IsWotlk) and missChance < 1 then
missChance = 1
elseif missChance > 100 then
missChance = 100
end
return DataUtils:Round(missChance, 2) .. "%"
end
function Data:SpellMissChanceBossLevel()
local missChance = 17
missChance = missChance - _SpellHit:GetTalentSpellHitBonus()
local mod = _SpellHit:GetSpellHitBonus()
if mod then
missChance = missChance - mod
end
if ECS.IsWotlk and missChance < 0 then
missChance = 0
elseif (not ECS.IsWotlk) and missChance < 1 then
missChance = 1
elseif missChance > 100 then
missChance = 100
end
return DataUtils:Round(missChance, 2) .. "%"
end
function _SpellHit:GetTalentSpellHitBonus()
local _, _, classId = UnitClass("player")
local bonus = 0
if classId == Data.PRIEST then
if ECS.IsWotlk then
local _, _, _, _, points, _, _, _ = GetTalentInfo(3, 3)
bonus = points -- 0-3% from Shadow Focus
else
local _, _, _, _, points, _, _, _ = GetTalentInfo(3, 3)
bonus = points * 2 -- 0-10% from Shadow Focus
end
end
if classId == Data.PALADIN and (not ECS.IsWotlk) then
local _, _, _, _, points, _, _, _ = GetTalentInfo(2, 3)
bonus = points * 1 -- 0-3% Precision
end
if classId == Data.MAGE then
if ECS.IsWotlk then
local _, _, _, _, points, _, _, _ = GetTalentInfo(3, 17)
bonus = points * 1 -- 0-3% from Elemental Precision
else
local _, _, _, _, points, _, _, _ = GetTalentInfo(3, 17)
bonus = points * 2 -- 0-6% from Elemental Precision
end
end
if classId == Data.SHAMAN then
if ECS.IsWotlk then
local _, _, _, _, points, _, _, _ = GetTalentInfo(1, 16)
bonus = points -- 0-3% from Elemental Precision
end
if (not ECS.IsWotlk) then
local _, _, _, _, points, _, _, _ = GetTalentInfo(3, 3)
bonus = bonus + points * 1 -- 0-3% Nature's Guidance
end
end
if classId == Data.DRUID then
if ECS.IsWotlk then
local _, _, _, _, points, _, _, _ = GetTalentInfo(1, 13)
bonus = points * 2 -- 0-4% from Balance of Power
end
end
if classId == Data.WARLOCK then
local _, _, _, _, points, _, _, _ = GetTalentInfo(1, 5)
bonus = points -- 0-3% from Suppression
end
return bonus
end
---@return number
function _SpellHit:GetSpellHitBonus()
if CR_HIT_SPELL then
return GetCombatRatingBonus(CR_HIT_SPELL) + _SpellHit:GetSpellHitFromBuffs()
end
return (GetSpellHitModifier() or 0) / 7 -- For 1% hit on gear GetSpellHitModifier returns 7
end
function _SpellHit:GetSpellHitFromBuffs()
local mod = 0
local otherDraeneiInGroup = false
for i = 1, 40 do
local _, _, _, _, _, _, _, _, _, spellId, _ = UnitAura("player", i, "HELPFUL")
if spellId == nil then
break
end
if spellId == 28878 then
mod = mod + 1 -- 1% from Inspiring Presence
otherDraeneiInGroup = true
end
if spellId == 30708 then
mod = mod + 3 -- 3% from Totem of Wrath
end
end
if (not otherDraeneiInGroup) and (IsSpellKnown(28878) or IsSpellKnown(6562)) then
mod = mod + 1
end
return mod
end
---@return string
function Data:SpellHitBonus()
local hit = _SpellHit:GetTalentSpellHitBonus()
local mod = _SpellHit:GetSpellHitBonus()
if mod then
hit = hit + mod
end
return DataUtils:Round(hit, 2) .. "%"
end
---@return number
function Data:SpellHitRating()
return GetCombatRating(CR_HIT_SPELL)
end