-
Notifications
You must be signed in to change notification settings - Fork 10
/
CharacterStatsClassicClassUtils.lua
363 lines (278 loc) · 9.24 KB
/
CharacterStatsClassicClassUtils.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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
--[[
Util functions specific for Classes
]]
g_TalentsIndexMap = nil
CSC_GenerateTalentsIndexMap = function()
if g_TalentsIndexMap then return end;
local talentsIndexMap = {};
for tab=1,3 do
local tierColumn = {};
local maxTier = 0;
local numTalents = GetNumTalents(tab);
if not numTalents or numTalents <= 0 then return end;
for idx=numTalents,1,-1 do
local _,_,tier,column = GetTalentInfo(tab,idx);
tierColumn[tier] = tierColumn[tier] or {};
tierColumn[tier][column] = idx;
maxTier = tier > maxTier and tier or maxTier
end
if maxTier == 0 then return end;
local oldIdx = 1;
talentsIndexMap[tab] = {};
for tier=1,maxTier do
for column=1,4 do
local wowIdx = tierColumn[tier][column];
if wowIdx then
talentsIndexMap[tab][oldIdx] = wowIdx;
oldIdx = oldIdx + 1;
end
end
end
end
g_TalentsIndexMap = talentsIndexMap;
--print("Generated Talents Index Map...")
end
function CSC_GetTalentInfo(tabIndex, talentIndex)
if not g_TalentsIndexMap then return GetTalentInfo(tabIndex, talentIndex) end
local newTalentIndex = g_TalentsIndexMap[tabIndex][talentIndex];
if not newTalentIndex then return GetTalentInfo(tabIndex, talentIndex) end
return GetTalentInfo(tabIndex, newTalentIndex);
end
-- returns additional crit % stats from Arcane instability and Critical Mass if any
function CSC_GetMageCritStatsFromTalents()
local arcaneInstabilityCrit = 0;
local criticalMassCrit = 0;
-- Arcane Instability (1, 2, 3)%
local arcaneInstabilityTable = { 1, 2, 3 };
local spellRank = select(5, CSC_GetTalentInfo(1, 15));
if (spellRank > 0) and (spellRank <= 3) then
arcaneInstabilityCrit = arcaneInstabilityTable[spellRank];
end
-- Critical Mass (2, 4, 6)%
local criticalMassTable = { 2, 4, 6 };
spellRank = select(5, CSC_GetTalentInfo(2, 13));
if (spellRank > 0) and (spellRank <= 3) then
criticalMassCrit = criticalMassTable[spellRank];
end
return arcaneInstabilityCrit, criticalMassCrit;
end
-- returns the spell hit from Arcane Focus and Elemental Precision talents
function CSC_GetMageSpellHitFromTalents()
local arcaneHit = 0;
local frostFireHit = 0;
-- Arcane Focus
local spellRank = select(5, CSC_GetTalentInfo(1, 2));
arcaneHit = spellRank * 2; -- 2% for each point
-- Elemental Precision
spellRank = select(5, CSC_GetTalentInfo(3, 3));
frostFireHit = spellRank * 2; -- 2% for each point
return arcaneHit, frostFireHit;
end
-- returns the spell hit from Suppression talent
function CSC_GetWarlockSpellHitFromTalents()
local afflictionHit = 0;
-- Suppression
local spellRank = select(5, CSC_GetTalentInfo(1, 1));
afflictionHit = spellRank * 2; -- 2% for each point
return afflictionHit;
end
-- returns the spell crit from Devastation talent
function CSC_GetWarlockCritStatsFromTalents()
-- the spell rank is equal to the value
local devastationCrit = select(5, CSC_GetTalentInfo(3, 7));
return devastationCrit;
end
-- returns the combined crit stats from Holy Specialization and Force of Will
function CSC_GetPriestCritStatsFromTalents()
local holySpecializationCrit = 0;
local forceOfWillCrit = 0;
local critTable = { 1, 2, 3, 4, 5 };
-- Holy Specialization (1, 2, 3, 4, 5)%
local spellRank = select(5, CSC_GetTalentInfo(2, 3));
if (spellRank > 0) and (spellRank <= 5) then
holySpecializationCrit = critTable[spellRank];
end
-- Force of Will (1, 2, 3, 4, 5)%
spellRank = select(5, CSC_GetTalentInfo(1, 14));
if (spellRank > 0) and (spellRank <= 5) then
forceOfWillCrit = critTable[spellRank];
end
local critCombined = holySpecializationCrit + forceOfWillCrit;
return critCombined;
end
-- returns the healing modifier from Spiritual Healing talent for Priests
function CSC_GetPriestBonusHealingModifierFromTalents()
-- Spiritual Healing
local spellRank = select(5, CSC_GetTalentInfo(2, 15));
return spellRank * 0.02;
end
-- returns the crit bonus from Holy Power
function CSC_GetPaladinCritStatsFromTalents()
-- Holy Power (1, 2, 3, 4, 5)%
local spellRank = select(5, CSC_GetTalentInfo(1, 13));
return spellRank;
end
-- returns the defense bonus from the Anticipation Prot talent
local function CSC_GetPaladinDefenseFromTalents()
local defense = 0;
local defenseTable = { 2, 4, 6, 8, 10 };
-- Anticipation (2, 4, 6, 8, 10)%
local spellRank = select(5, CSC_GetTalentInfo(2, 9));
if (spellRank > 0) and (spellRank <=5) then
defense = defenseTable[spellRank];
end
return defense;
end
-- returns the modifier from Improved Blessing of Wisdom Holy talent
function CSC_GetPaladinImprovedBoWModifier()
-- Improved Blessing of Wisdom
local spellRank = select(5, CSC_GetTalentInfo(1, 10));
return spellRank * 0.1;
end
-- Checks if spellId is Blessing of Wisdom
function CSC_IsBoWSpellId(spellId)
if (spellId == 19742 or spellId == 19850 or spellId == 19852 or spellId == 19853 or spellId == 19854 or spellId == 25290 or spellId == 25894 or spellId == 25918) then
return true;
end
return false;
end
-- returns the defense bonus from the Anticipation Prot talent
local function CSC_GetWarriorDefenseFromTalents()
local defense = 0;
local defenseTable = { 2, 4, 6, 8, 10 };
-- Anticipation (2, 4, 6, 8, 10)%
local spellRank = select(5, CSC_GetTalentInfo(3, 2));
if (spellRank > 0) and (spellRank <=5) then
defense = defenseTable[spellRank];
end
return defense;
end
function CSC_GetDefenseFromTalents(unit)
local defense = 0;
local unitClassId = select(3, UnitClass(unit));
if (unitClassId == CSC_PALADIN_CLASS_ID) then
defense = CSC_GetPaladinDefenseFromTalents();
elseif (unitClassId == CSC_WARRIOR_CLASS_ID) then
defense = CSC_GetWarriorDefenseFromTalents();
end
return defense;
end
-- returns the shapeshift form index for druids
function CSC_GetShapeshiftForm()
local shapeIndex = 0;
for possibleForm=1, GetNumShapeshiftForms() do
if select(2, GetShapeshiftFormInfo(possibleForm)) then
shapeIndex = possibleForm;
end
end
return shapeIndex;
end
-- returns the bonus hit from Nature's Guidance talent (counts as melee and spell hit)
function CSC_GetShamanHitFromTalents()
-- Nature's Guidance
local spellRank = select(5, CSC_GetTalentInfo(3, 6));
return spellRank;
end
-- returns the bonus crit from the Call of Thunder talent for Shamans
function CSC_GetShamanCallOfThunderCrit()
local bonusCrit = 0;
local talentTable = { 1, 2, 3, 4, 6 };
-- Call of Thunder (Lightning)
local spellRank = select(5, CSC_GetTalentInfo(1, 8));
if (spellRank > 0) and (spellRank <=5) then
bonusCrit = talentTable[spellRank];
end
return bonusCrit;
end
-- returns the bonus crit from the Tidal Mastery telent for Shamans
function CSC_GetShamanTidalMasteryCrit()
-- Tidal Mastery (Nature/Lightning)
local spellRank = select(5, CSC_GetTalentInfo(3, 11));
return spellRank;
end
-- ITEMS AND ENCHANTS RELATED
function CSC_GetMP5ModifierFromTalents(unit)
local unitClassId = select(3, UnitClass(unit));
local spellRank = 0;
if unitClassId == CSC_PRIEST_CLASS_ID then
-- Meditation
spellRank = select(5, CSC_GetTalentInfo(1, 8));
elseif unitClassId == CSC_MAGE_CLASS_ID then
-- Arcane Meditation
spellRank = select(5, CSC_GetTalentInfo(1, 12));
elseif unitClassId == CSC_DRUID_CLASS_ID then
-- Reflection
spellRank = select(5, CSC_GetTalentInfo(3, 6));
end
local modifier = spellRank * 0.05;
return modifier;
end
function CSC_GetMP5ModifierFromSetBonus(unit)
local unitClassId = select(3, UnitClass(unit));
local modifier = 0;
-- not Druid or Priest
if unitClassId ~= CSC_DRUID_CLASS_ID and unitClassId ~= CSC_PRIEST_CLASS_ID then
return modifier;
end
local firstItemslotIndex = 1;
local lastItemslotIndex = 18;
local equippedSetItems = 0;
for itemSlot = firstItemslotIndex, lastItemslotIndex do
local itemId = GetInventoryItemID(unit, itemSlot);
if (itemId) then
if (itemId == g_VestmentsOfTranscendenceIds[itemId] or itemId == g_StormrageRaimentIds[itemId]) then
equippedSetItems = equippedSetItems + 1;
end
end
end
if equippedSetItems >= 3 then
modifier = 0.15;
end
return modifier;
end
function CSC_GetShamanT2SpellCrit(unit)
local spellCritFromSet = 0;
local firstItemslotIndex = 1;
local lastItemslotIndex = 18;
local equippedSetItems = 0;
for itemSlot = firstItemslotIndex, lastItemslotIndex do
local itemId = GetInventoryItemID(unit, itemSlot);
if (itemId) then
if (itemId == g_TheTenStormsIds[itemId]) then
equippedSetItems = equippedSetItems + 1;
end
end
end
if equippedSetItems >= 5 then
spellCritFromSet = 3;
end
return spellCritFromSet;
end
function CSC_GetHolyCritFromBenediction(unit)
local benedictionCrit = 0;
local itemId = GetInventoryItemID(unit, INVSLOT_MAINHAND);
if itemId == 18608 then
benedictionCrit = 2;
end
return benedictionCrit;
end
function CSC_GetBlockValueFromWarriorZGEnchants(unit)
local blockValue = 0;
if CSC_HasEnchant(unit, INVSLOT_HEAD, 2583) then
blockValue = blockValue + 15;
end
if CSC_HasEnchant(unit, INVSLOT_LEGS, 2583) then
blockValue = blockValue + 15;
end
return blockValue;
end
function CSC_GetMp5FromPriestZGEnchants(unit)
local mp5 = 0;
if CSC_HasEnchant(unit, INVSLOT_HEAD, 2590) then
mp5 = mp5 + 4;
end
if CSC_HasEnchant(unit, INVSLOT_LEGS, 2590) then
mp5 = mp5 + 4;
end
return mp5;
end