-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMelee.lua
More file actions
executable file
·257 lines (207 loc) · 6.88 KB
/
Melee.lua
File metadata and controls
executable file
·257 lines (207 loc) · 6.88 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
---@class Data
local Data = ECSLoader:ImportModule("Data")
---@type DataUtils
local DataUtils = ECSLoader:ImportModule("DataUtils")
---@type Utils
local Utils = ECSLoader:ImportModule("Utils")
-- keep-sorted start case=no
local _, _, classId = UnitClass("player")
local _Melee = {}
local DEATHKNIGHT = Data.DEATHKNIGHT
local DRUID = Data.DRUID
local ROGUE = Data.ROGUE
local SHAMAN = Data.SHAMAN
local WARRIOR = Data.WARRIOR
-- keep-sorted end
---@return number
function Data:GetMeleeAttackPower()
local melee, posBuff, negBuff = UnitAttackPower("player")
return melee + posBuff + negBuff
end
---@return number
function Data:GetMeleeAttackSpeedMainHand()
local mainHand, _ = UnitAttackSpeed("player")
return DataUtils:Round(mainHand, 2)
end
---@return number
function Data:GetMeleeAttackSpeedOffHand()
local _, offHand = UnitAttackSpeed("player")
return DataUtils:Round(offHand, 2)
end
---@return string
function Data:MeleeCrit()
return DataUtils:Round(GetCritChance(), 2) .. "%"
end
---@return string
function Data:MeleeHitBonus()
return DataUtils:Round(_Melee:GetHitRatingBonus(), 2) .. "%"
end
---@return number
function Data:MeleeHitRating()
if (not CR_HIT_MELEE) then
return 0
end
return GetCombatRating(CR_HIT_MELEE)
end
---@return number
function _Melee:GetHitRatingBonus()
local hit = _Melee:GetHitTalentBonus() + _Melee.GetHitFromRunes()
if CR_HIT_MELEE then
hit = hit + GetCombatRatingBonus(CR_HIT_MELEE)
end
-- GetHitModifier returns nil on dungeon entering/teleport
return hit + (GetHitModifier() or 0)
end
---In TBC and WotLK clients, if a talent spell has the "Apply Aura: Mod Melee & Ranged Hit Chance %", then GetHitModifier() already accounts for it and we don't need to handle it here.
---@return number
function _Melee:GetHitTalentBonus()
local mod = 0
if ECS.IsClassic then
if classId == Data.SHAMAN then
mod = 1 * DataUtils:GetActiveTalentSpell(Data.Talent[SHAMAN].NATURES_GUIDANCE)
elseif classId == Data.ROGUE then
mod = 1 * DataUtils:GetActiveTalentSpell(Data.Talent[ROGUE].PRECISION)
end
end
return mod
end
---@return number
function _Melee.GetHitFromRunes()
local mod = 0
if (not ECS.IsSoD) then
return mod
end
local finger1Rune = DataUtils.GetRuneForEquipSlot(Utils.CHAR_EQUIP_SLOTS.Finger1)
local finger2Rune = DataUtils.GetRuneForEquipSlot(Utils.CHAR_EQUIP_SLOTS.Finger2)
if classId == DRUID and (finger1Rune == 7520 or finger2Rune == 7520) and DataUtils:IsShapeshifted() then
mod = mod + 3 -- 3% from Feral Combat Specialization Rune
end
return mod
end
---@return string
function Data:MeleeHitMissChanceSameLevel()
local mainBase, mainMod, _, _ = UnitAttackBothHands("player")
local playerLevel = UnitLevel("player")
local enemyDefenseValue = playerLevel * 5
local missChance
if DataUtils:IsShapeshifted() then
missChance = 5
else
missChance = DataUtils.GetMissChanceByDifference(mainBase + mainMod, enemyDefenseValue)
end
if Data:GetMeleeAttackSpeedOffHand() > 0 then
missChance = missChance + 19;
end
local hitValue = _Melee:GetHitRatingBonus()
missChance = missChance - hitValue
if missChance < 0 then
missChance = 0
elseif missChance > 100 then
missChance = 100
end
return DataUtils:Round(missChance, 2) .. "%"
end
---@return string
function Data:MeleeHitMissChanceBossLevel()
local mainBase, mainMod, _, _ = UnitAttackBothHands("player")
local playerLevel = UnitLevel("player")
local enemyDefenseValue = (playerLevel + 3) * 5
local missChance
if DataUtils:IsShapeshifted() then
missChance = ECS.IsWotlk and 8 or 9
else
missChance = DataUtils.GetMissChanceByDifference(mainBase + mainMod, enemyDefenseValue)
end
if Data:GetMeleeAttackSpeedOffHand() > 0 then
missChance = missChance + 19;
end
local hitValue = _Melee:GetHitRatingBonus()
missChance = missChance - hitValue
if missChance < 0 then
missChance = 0
elseif missChance > 100 then
missChance = 100
end
return DataUtils:Round(missChance, 2) .. "%"
end
function Data:GlanceHitChanceSameLevel()
return Data:GlanceHitChanceByLevel(0)
end
function Data:GlanceHitChanceBossLevel()
return Data:GlanceHitChanceByLevel(3)
end
---@return string
function Data:GlanceHitChanceByLevel(level)
local mainBase, mainMod, _, _ = UnitAttackBothHands("player")
local playerLevel = UnitLevel("player")
local enemyDefenseValue = (playerLevel + level) * 5
local glancingChance = DataUtils:GetGlancingChanceByDifference(playerLevel, mainBase + mainMod, enemyDefenseValue)
return DataUtils:Round(glancingChance*100, 2) .. "%"
end
---@return string
function Data:GlanceDamageSameLevel()
return Data:GlanceDamageByLevel(0)
end
---@return string
function Data:GlanceDamageBossLevel()
return Data:GlanceDamageByLevel(3)
end
---@return string
function Data:GlanceDamageByLevel(level)
local mainBase, mainMod, _, _ = UnitAttackBothHands("player")
local playerLevel = UnitLevel("player")
local enemyDefenseValue = (playerLevel + level) * 5
local glancePenalty = DataUtils:GetGlancingDamage(mainBase + mainMod, enemyDefenseValue)
return DataUtils:Round(glancePenalty*100, 2) .. "%"
end
---@return number
function Data:GetExpertise()
local expertise, _ = GetExpertise()
return DataUtils:Round(expertise, 0)
end
---@return number
function Data:GetExpertiseRating()
if (not CR_EXPERTISE) then
return 0
end
local expertiseRating = GetCombatRating(CR_EXPERTISE)
return DataUtils:Round(expertiseRating, 0)
end
---@return string
function Data:GetArmorPenetration()
local armorPenetration = GetArmorPenetration()
if ECS.IsWotlk and classId == WARRIOR then
local _, isActive = GetShapeshiftFormInfo(1)
if isActive then
armorPenetration = armorPenetration + 10 -- 10% from Battle Stance
end
end
if classId == DEATHKNIGHT then
armorPenetration = armorPenetration + 2 * DataUtils:GetActiveTalentSpell(Data.Talent[DEATHKNIGHT].BLOOD_GORGED)
end
return DataUtils:Round(armorPenetration, 2) .. "%"
end
---@return number
function Data:GetArmorPenetrationRating()
if (not CR_ARMOR_PENETRATION) then
return 0
end
local armorPenetrationRating = GetCombatRating(CR_ARMOR_PENETRATION)
return DataUtils:Round(armorPenetrationRating, 0)
end
---@return number
function Data:GetMeleeHasteRating()
if (not CR_HASTE_MELEE) then
return 0
end
local hasteRating = GetCombatRating(CR_HASTE_MELEE)
return DataUtils:Round(hasteRating, 0)
end
---@return string
function Data:GetMeleeHasteBonus()
if (not CR_HASTE_MELEE) then
return "0%"
end
local hasteBonus = GetCombatRatingBonus(CR_HASTE_MELEE)
return DataUtils:Round(hasteBonus, 2) .. "%"
end