This repository has been archived by the owner on Oct 29, 2023. It is now read-only.
forked from yutsuku/BetterCharacterStats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.lua
1020 lines (863 loc) · 31.5 KB
/
helper.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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
BCS = BCS or {}
local BCS_Tooltip = getglobal("BetterCharacterStatsTooltip") or CreateFrame("GameTooltip", "BetterCharacterStatsTooltip", nil, "GameTooltipTemplate")
local BCS_Prefix = "BetterCharacterStatsTooltip"
BCS_Tooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
local L = BCS["L"]
local strfind = strfind
local tonumber = tonumber
local tinsert = tinsert
local function tContains(table, item)
local index = 1
while table[index] do
if ( item == table[index] ) then
return 1
end
index = index + 1
end
return nil
end
function BCS:GetPlayerAura(searchText, auraType)
if not auraType then
-- buffs
-- http://blue.cardplace.com/cache/wow-dungeons/624230.htm
-- 32 buffs max
for i=0, 31 do
local index = GetPlayerBuff(i, 'HELPFUL')
if index > -1 then
BCS_Tooltip:SetPlayerBuff(index)
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local value = {strfind(left:GetText(), searchText)}
if value[1] then
return unpack(value)
end
end
end
end
end
elseif auraType == 'HARMFUL' then
for i=0, 6 do
local index = GetPlayerBuff(i, auraType)
if index > -1 then
BCS_Tooltip:SetPlayerBuff(index)
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local value = {strfind(left:GetText(), searchText)}
if value[1] then
return unpack(value)
end
end
end
end
end
end
end
local Cache_GetHitRating_Tab, Cache_GetHitRating_Talent
local hit_debuff = 0
function BCS:GetHitRating(hitOnly)
local Hit_Set_Bonus = {}
local hit = 0;
local MAX_INVENTORY_SLOTS = 19;
hit_debuff = 0;
for slot=0, MAX_INVENTORY_SLOTS do
local hasItem = BCS_Tooltip:SetInventoryItem("player", slot)
if hasItem then
local MAX_LINES = BCS_Tooltip:NumLines()
local SET_NAME = nil
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Equip: Improves your chance to hit by (%d)%%."])
if value then
hit = hit + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["/Hit %+(%d+)"])
if value then
hit = hit + tonumber(value)
end
_,_, value = strfind(left:GetText(), "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_,_, value = strfind(left:GetText(), L["^Set: Improves your chance to hit by (%d)%%."])
if value and SET_NAME and not tContains(Hit_Set_Bonus, SET_NAME) then
tinsert(Hit_Set_Bonus, SET_NAME)
hit = hit + tonumber(value)
line = MAX_LINES
end
end
end
end
end
-- buffs
local _, _, hitFromAura = BCS:GetPlayerAura(L["Chance to hit increased by (%d)%%."])
if hitFromAura then
hit = hit + tonumber(hitFromAura)
end
_, _, hitFromAura = BCS:GetPlayerAura(L["Improves your chance to hit by (%d+)%%."])
if hitFromAura then
hit = hit + tonumber(hitFromAura)
end
_, _, hitFromAura = BCS:GetPlayerAura(L["Increases attack power by %d+ and chance to hit by (%d+)%%."])
if hitFromAura then
hit = hit + tonumber(hitFromAura)
end
-- debuffs
_, _, hitFromAura = BCS:GetPlayerAura(L["Chance to hit reduced by (%d+)%%."], 'HARMFUL')
if hitFromAura then
hit_debuff = hit_debuff + tonumber(hitFromAura)
end
_, _, hitFromAura = BCS:GetPlayerAura(L["Chance to hit decreased by (%d+)%% and %d+ Nature damage every %d+ sec."], 'HARMFUL')
if hitFromAura then
hit_debuff = hit_debuff + tonumber(hitFromAura)
end
hitFromAura = BCS:GetPlayerAura(L["Lowered chance to hit."], 'HARMFUL')
if hitFromAura then
hit_debuff = hit_debuff + 25
end
local MAX_TABS = GetNumTalentTabs()
-- speedup
if Cache_GetHitRating_Tab and Cache_GetHitRating_Talent then
BCS_Tooltip:SetTalent(Cache_GetHitRating_Tab, Cache_GetHitRating_Talent)
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
-- rogues
local _,_, value = strfind(left:GetText(), L["Increases your chance to hit with melee weapons by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(Cache_GetHitRating_Tab, Cache_GetHitRating_Talent)
if value and rank > 0 then
hit = hit + tonumber(value)
line = MAX_LINES
end
-- hunters
_,_, value = strfind(left:GetText(), L["Increases hit chance by (%d)%% and increases the chance movement impairing effects will be resisted by an additional %d+%%."])
name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(Cache_GetHitRating_Tab, Cache_GetHitRating_Talent)
if value and rank > 0 then
hit = hit + tonumber(value)
line = MAX_LINES
end
-- paladins
_,_, value = strfind(left:GetText(), L["Increases your chance to hit with melee attacks and spells by (%d)%%."])
name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(Cache_GetHitRating_Tab, Cache_GetHitRating_Talent)
if value and rank > 0 then
hit = hit + tonumber(value)
line = MAX_LINES
end
end
end
if not hitOnly then
hit = hit - hit_debuff
if hit < 0 then hit = 0 end
return hit
else
return hit
end
end
for tab=1, MAX_TABS do
local MAX_TALENTS = GetNumTalents(tab)
for talent=1, MAX_TALENTS do
BCS_Tooltip:SetTalent(tab, talent);
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
-- rogues
local _,_, value = strfind(left:GetText(), L["Increases your chance to hit with melee weapons by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
hit = hit + tonumber(value)
Cache_GetHitRating_Tab = tab
Cache_GetHitRating_Talent = talent
line = MAX_LINES
talent = MAX_TALENTS
tab = MAX_TABS
end
-- hunters
_,_, value = strfind(left:GetText(), L["Increases hit chance by (%d)%% and increases the chance movement impairing effects will be resisted by an additional %d+%%."])
name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
hit = hit + tonumber(value)
Cache_GetHitRating_Tab = tab
Cache_GetHitRating_Talent = talent
line = MAX_LINES
talent = MAX_TALENTS
tab = MAX_TABS
end
-- paladins
_,_, value = strfind(left:GetText(), L["Increases your chance to hit with melee attacks and spells by (%d)%%."])
name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
hit = hit + tonumber(value)
Cache_GetHitRating_Tab = tab
Cache_GetHitRating_Talent = talent
line = MAX_LINES
talent = MAX_TALENTS
tab = MAX_TABS
end
end
end
end
end
if not hitOnly then
hit = hit - hit_debuff
if hit < 0 then hit = 0 end -- Dust Cloud OP
return hit
else
return hit
end
end
function BCS:GetRangedHitRating()
local melee_hit = BCS:GetHitRating(true)
local ranged_hit = melee_hit
local debuff = hit_debuff
local hasItem = BCS_Tooltip:SetInventoryItem("player", 18) -- ranged enchant
if hasItem then
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["+(%d)%% Hit"])
if value then
ranged_hit = ranged_hit + tonumber(value)
line = MAX_LINES
end
end
end
end
ranged_hit = ranged_hit - debuff
if ranged_hit < 0 then ranged_hit = 0 end
return ranged_hit
end
function BCS:GetSpellHitRating()
local hit = 0
local hit_fire = 0
local hit_frost = 0
local hit_arcane = 0
local hit_shadow = 0
local hit_Set_Bonus = {}
-- scan gear
local MAX_INVENTORY_SLOTS = 19
for slot=0, MAX_INVENTORY_SLOTS do
local hasItem = BCS_Tooltip:SetInventoryItem("player", slot)
if hasItem then
local SET_NAME
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Equip: Improves your chance to hit with spells by (%d)%%."])
if value then
hit = hit + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["/Spell Hit %+(%d+)"])
if value then
hit = hit + tonumber(value)
end
_,_, value = strfind(left:GetText(), "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_, _, value = strfind(left:GetText(), L["^Set: Improves your chance to hit with spells by (%d)%%."])
if value and SET_NAME and not tContains(hit_Set_Bonus, SET_NAME) then
tinsert(hit_Set_Bonus, SET_NAME)
hit = hit + tonumber(value)
end
end
end
end
end
-- scan talents
local MAX_TABS = GetNumTalentTabs()
for tab=1, MAX_TABS do
local MAX_TALENTS = GetNumTalents(tab)
for talent=1, MAX_TALENTS do
BCS_Tooltip:SetTalent(tab, talent)
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
-- Mage
-- Elemental Precision
local _,_, value = strfind(left:GetText(), L["Reduces the chance that the opponent can resist your Frost and Fire spells by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
hit_fire = hit_fire + tonumber(value)
hit_frost = hit_frost + tonumber(value)
line = MAX_LINES
end
-- Arcane Focus
_,_, value = strfind(left:GetText(), L["Reduces the chance that the opponent can resist your Arcane spells by (%d+)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
hit_arcane = hit_arcane + tonumber(value)
line = MAX_LINES
end
-- Priest
-- Shadow Focus
_,_, value = strfind(left:GetText(), L["Reduces your target's chance to resist your Shadow spells by (%d+)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
hit_shadow = hit_shadow + tonumber(value)
line = MAX_LINES
end
-- Paladin
-- Precision
_,_, value = strfind(left:GetText(), L["Increases your chance to hit with melee attacks and spells by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
hit = hit + tonumber(value)
line = MAX_LINES
end
end
end
end
end
-- buffs
local _, _, hitFromAura = BCS:GetPlayerAura(L["Spell hit chance increased by (%d+)%%."])
if hitFromAura then
hit = hit + tonumber(hitFromAura)
end
return hit, hit_fire, hit_frost, hit_arcane, hit_shadow
end
local Cache_GetCritChance_SpellID, Cache_GetCritChance_BookType, Cache_GetCritChance_Line
local Cache_GetCritChance_Tab, Cache_GetCritChance_Talent
function BCS:GetCritChance()
local crit = 0
local _, class = UnitClass('player')
if class == 'HUNTER' then
local MAX_TABS = GetNumTalentTabs()
-- speedup
if Cache_GetCritChance_Tab and Cache_GetCritChance_Talent then
BCS_Tooltip:SetTalent(Cache_GetCritChance_Tab, Cache_GetCritChance_Talent)
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Increases your critical strike chance with all attacks by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(Cache_GetCritChance_Tab, Cache_GetCritChance_Talent)
if value and rank > 0 then
crit = crit + tonumber(value)
line = MAX_LINES
end
end
end
else
for tab=1, MAX_TABS do
local MAX_TALENTS = GetNumTalents(tab)
for talent=1, MAX_TALENTS do
BCS_Tooltip:SetTalent(tab, talent);
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Increases your critical strike chance with all attacks by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
crit = crit + tonumber(value)
Cache_GetCritChance_Tab = tab
Cache_GetCritChance_Talent = talent
line = MAX_LINES
talent = MAX_TALENTS
tab = MAX_TABS
end
end
end
end
end
end
end
-- speedup
if Cache_GetCritChance_SpellID and Cache_GetCritChance_BookType and Cache_GetCritChance_Line then
BCS_Tooltip:SetSpell(Cache_GetCritChance_SpellID, Cache_GetCritChance_BookType)
local left = getglobal(BCS_Prefix .. "TextLeft" .. Cache_GetCritChance_Line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["([%d.]+)%% chance to crit"])
if value then
crit = crit + tonumber(value)
end
end
return crit
end
local MAX_TABS = GetNumSpellTabs()
for tab=1, MAX_TABS do
local name, texture, offset, numSpells = GetSpellTabInfo(tab)
for spell=1, numSpells do
local currentPage = ceil(spell/SPELLS_PER_PAGE)
local SpellID = spell + offset + ( SPELLS_PER_PAGE * (currentPage - 1))
BCS_Tooltip:SetSpell(SpellID, BOOKTYPE_SPELL)
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["([%d.]+)%% chance to crit"])
if value then
crit = crit + tonumber(value)
Cache_GetCritChance_SpellID = SpellID
Cache_GetCritChance_BookType = BOOKTYPE_SPELL
Cache_GetCritChance_Line = line
line = MAX_LINES
spell = numSpells
tab = MAX_TABS
end
end
end
end
end
return crit
end
local Cache_GetRangedCritChance_Tab, Cache_GetRangedCritChance_Talent, Cache_GetRangedCritChance_Line
function BCS:GetRangedCritChance()
local crit = BCS:GetCritChance()
if Cache_GetRangedCritChance_Tab and Cache_GetRangedCritChance_Talent and Cache_GetRangedCritChance_Line then
BCS_Tooltip:SetTalent(Cache_GetRangedCritChance_Tab, Cache_GetRangedCritChance_Talent)
local left = getglobal(BCS_Prefix .. "TextLeft" .. Cache_GetRangedCritChance_Line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Increases your critical strike chance with ranged weapons by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(Cache_GetRangedCritChance_Tab, Cache_GetRangedCritChance_Talent)
if value and rank > 0 then
crit = crit + tonumber(value)
end
end
return crit
end
local MAX_TABS = GetNumTalentTabs()
for tab=1, MAX_TABS do
local MAX_TALENTS = GetNumTalents(tab)
for talent=1, MAX_TALENTS do
BCS_Tooltip:SetTalent(tab, talent);
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Increases your critical strike chance with ranged weapons by (%d)%%."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
crit = crit + tonumber(value)
line = MAX_LINES
talent = MAX_TALENTS
tab = MAX_TABS
end
end
end
end
end
return crit
end
function BCS:GetSpellCritChance()
-- school crit: most likely never
local Crit_Set_Bonus = {}
local spellCrit = 0;
local _, intelect = UnitStat("player", 4)
local _, class = UnitClass("player")
-- values from theorycraft / http://wow.allakhazam.com/forum.html?forum=21&mid=1157230638252681707
if class == "MAGE" then
spellCrit = 0.2 + (intelect / 59.5)
elseif class == "WARLOCK" then
spellCrit = 1.7 + (intelect / 60.6)
elseif class == "PRIEST" then
spellCrit = 0.8 + (intelect / 59.56)
elseif class == "DRUID" then
spellCrit = 1.8 + (intelect / 60)
elseif class == "SHAMAN" then
spellCrit = 1.8 + (intelect / 59.2)
elseif class == "PALADIN" then
spellCrit = intelect / 29.5
end
local MAX_INVENTORY_SLOTS = 19
for slot=0, MAX_INVENTORY_SLOTS do
local hasItem = BCS_Tooltip:SetInventoryItem("player", slot)
if hasItem then
local SET_NAME = nil
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Equip: Improves your chance to get a critical strike with spells by (%d)%%."])
if value then
spellCrit = spellCrit + tonumber(value)
end
_,_, value = strfind(left:GetText(), "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_, _, value = strfind(left:GetText(), L["^Set: Improves your chance to get a critical strike with spells by (%d)%%."])
if value and SET_NAME and not tContains(Crit_Set_Bonus, SET_NAME) then
tinsert(Crit_Set_Bonus, SET_NAME)
spellCrit = spellCrit + tonumber(value)
end
end
end
end
end
-- buffs
local _, _, critFromAura = BCS:GetPlayerAura(L["Chance for a critical hit with a spell increased by (%d+)%%."])
if critFromAura then
spellCrit = spellCrit + tonumber(critFromAura)
end
_, _, critFromAura = BCS:GetPlayerAura(L["While active, target's critical hit chance with spells and attacks increases by 10%%."])
if critFromAura then
spellCrit = spellCrit + 10
end
_, _, critFromAura = BCS:GetPlayerAura(L["Increases chance for a melee, ranged, or spell critical by (%d+)%% and all attributes by %d+."])
if critFromAura then
spellCrit = spellCrit + tonumber(critFromAura)
end
critFromAura = BCS:GetPlayerAura(L["Increases critical chance of spells by 10%%, melee and ranged by 5%% and grants 140 attack power. 120 minute duration."])
if critFromAura then
spellCrit = spellCrit + 10
end
_, _, critFromAura = BCS:GetPlayerAura(L["Critical strike chance with spells and melee attacks increased by (%d+)%%."])
if critFromAura then
spellCrit = spellCrit + tonumber(critFromAura)
end
-- debuffs
_, _, _, critFromAura = BCS:GetPlayerAura(L["Melee critical-hit chance reduced by (%d+)%%.\r\nSpell critical-hit chance reduced by (%d+)%%."], 'HARMFUL')
if critFromAura then
spellCrit = spellCrit - tonumber(critFromAura)
end
return spellCrit
end
function BCS:GetSpellPower(school)
if school then
if not L["Equip: Increases damage done by "..school.." spells and effects by up to (%d+)."] then return -1 end
local spellPower = 0;
local MAX_INVENTORY_SLOTS = 19
for slot=0, MAX_INVENTORY_SLOTS do
local hasItem = BCS_Tooltip:SetInventoryItem("player", slot)
if hasItem then
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Equip: Increases damage done by "..school.." spells and effects by up to (%d+)."])
if value then
spellPower = spellPower + tonumber(value)
end
if L[school.." Damage %+(%d+)"] then
_,_, value = strfind(left:GetText(), L[school.." Damage %+(%d+)"])
if value then
spellPower = spellPower + tonumber(value)
end
end
if L["^%+(%d+) "..school.." Spell Damage"] then
_,_, value = strfind(left:GetText(), L["^%+(%d+) "..school.." Spell Damage"])
if value then
spellPower = spellPower + tonumber(value)
end
end
end
end
end
end
return spellPower
else
local spellPower = 0;
local arcanePower = 0;
local firePower = 0;
local frostPower = 0;
local holyPower = 0;
local naturePower = 0;
local shadowPower = 0;
local damagePower = 0;
local MAX_INVENTORY_SLOTS = 19
local SpellPower_Set_Bonus = {}
-- scan gear
for slot=0, MAX_INVENTORY_SLOTS do
local hasItem = BCS_Tooltip:SetInventoryItem("player", slot)
if hasItem then
local SET_NAME
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Equip: Increases damage and healing done by magical spells and effects by up to (%d+)."])
if value then
spellPower = spellPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Spell Damage %+(%d+)"])
if value then
spellPower = spellPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Spell Damage and Healing"])
if value then
spellPower = spellPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Damage and Healing Spells"])
if value then
spellPower = spellPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Equip: Increases damage done by Arcane spells and effects by up to (%d+)."])
if value then
arcanePower = arcanePower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Arcane Spell Damage"])
if value then
arcanePower = arcanePower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Equip: Increases damage done by Fire spells and effects by up to (%d+)."])
if value then
firePower = firePower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Fire Damage %+(%d+)"])
if value then
firePower = firePower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Fire Spell Damage"])
if value then
firePower = firePower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Equip: Increases damage done by Frost spells and effects by up to (%d+)."])
if value then
frostPower = frostPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Frost Damage %+(%d+)"])
if value then
frostPower = frostPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Frost Spell Damage"])
if value then
frostPower = frostPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Equip: Increases damage done by Holy spells and effects by up to (%d+)."])
if value then
holyPower = holyPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Holy Spell Damage"])
if value then
holyPower = holyPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Equip: Increases damage done by Nature spells and effects by up to (%d+)."])
if value then
naturePower = naturePower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Nature Spell Damage"])
if value then
naturePower = naturePower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Equip: Increases damage done by Shadow spells and effects by up to (%d+)."])
if value then
shadowPower = shadowPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Shadow Damage %+(%d+)"])
if value then
shadowPower = shadowPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Shadow Spell Damage"])
if value then
shadowPower = shadowPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_, _, value = strfind(left:GetText(), L["^Set: Increases damage and healing done by magical spells and effects by up to (%d+)%."])
if value and SET_NAME and not tContains(SpellPower_Set_Bonus, SET_NAME) then
tinsert(SpellPower_Set_Bonus, SET_NAME)
spellPower = spellPower + tonumber(value)
end
end
end
end
end
-- scan talents
local MAX_TABS = GetNumTalentTabs()
for tab=1, MAX_TABS do
local MAX_TALENTS = GetNumTalents(tab)
for talent=1, MAX_TALENTS do
BCS_Tooltip:SetTalent(tab, talent)
local MAX_LINES = BCS_Tooltip:NumLines()
for line=1, MAX_LINES do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
-- Priest
-- Spiritual Guidance
local _,_, value = strfind(left:GetText(), L["Increases spell damage and healing by up to (%d+)%% of your total Spirit."])
local name, iconTexture, tier, column, rank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, talent)
if value and rank > 0 then
local stat, effectiveStat = UnitStat("player", 5)
spellPower = spellPower + floor(((tonumber(value) / 100) * effectiveStat))
-- nothing more is currenlty supported, break out of the loops
line = MAX_LINES
talent = MAX_TALENTS
tab = MAX_TABS
end
end
end
end
end
-- buffs
local _, _, spellPowerFromAura = BCS:GetPlayerAura(L["Magical damage dealt is increased by up to (%d+)."])
if spellPowerFromAura then
spellPower = spellPower + tonumber(spellPowerFromAura)
damagePower = damagePower + tonumber(spellPowerFromAura)
end
local secondaryPower = 0
local secondaryPowerName = ""
if arcanePower > secondaryPower then
secondaryPower = arcanePower
secondaryPowerName = L.SPELL_SCHOOL_ARCANE
end
if firePower > secondaryPower then
secondaryPower = firePower
secondaryPowerName = L.SPELL_SCHOOL_FIRE
end
if frostPower > secondaryPower then
secondaryPower = frostPower
secondaryPowerName = L.SPELL_SCHOOL_FROST
end
if holyPower > secondaryPower then
secondaryPower = holyPower
secondaryPowerName = L.SPELL_SCHOOL_HOLY
end
if naturePower > secondaryPower then
secondaryPower = naturePower
secondaryPowerName = L.SPELL_SCHOOL_NATURE
end
if shadowPower > secondaryPower then
secondaryPower = shadowPower
secondaryPowerName = L.SPELL_SCHOOL_SHADOW
end
return spellPower, secondaryPower, secondaryPowerName, damagePower
end
end
function BCS:GetHealingPower()
local healPower = 0;
local healPower_Set_Bonus = {}
local MAX_INVENTORY_SLOTS = 19
for slot=0, MAX_INVENTORY_SLOTS do
local hasItem = BCS_Tooltip:SetInventoryItem("player", slot)
if hasItem then
local SET_NAME
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["Equip: Increases healing done by spells and effects by up to (%d+)."])
if value then
healPower = healPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Healing Spells %+(%d+)"])
if value then
healPower = healPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["^%+(%d+) Healing Spells"])
if value then
healPower = healPower + tonumber(value)
end
_,_, value = strfind(left:GetText(), "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_, _, value = strfind(left:GetText(), L["^Set: Increases healing done by spells and effects by up to (%d+)%."])
if value and SET_NAME and not tContains(healPower_Set_Bonus, SET_NAME) then
tinsert(healPower_Set_Bonus, SET_NAME)
healPower = healPower + tonumber(value)
end
end
end
end
end
-- buffs
local _, _, healPowerFromAura = BCS:GetPlayerAura(L["Healing done by magical spells is increased by up to (%d+)."])
if healPowerFromAura then
healPower = healPower + tonumber(healPowerFromAura)
end
return healPower
end
--[[
-- server\src\game\Object\Player.cpp
float Player::OCTRegenMPPerSpirit()
{
float addvalue = 0.0;
float Spirit = GetStat(STAT_SPIRIT);
uint8 Class = getClass();
switch (Class)
{
case CLASS_DRUID: addvalue = (Spirit / 5 + 15); break;
case CLASS_HUNTER: addvalue = (Spirit / 5 + 15); break;
case CLASS_MAGE: addvalue = (Spirit / 4 + 12.5); break;
case CLASS_PALADIN: addvalue = (Spirit / 5 + 15); break;
case CLASS_PRIEST: addvalue = (Spirit / 4 + 12.5); break;
case CLASS_SHAMAN: addvalue = (Spirit / 5 + 17); break;
case CLASS_WARLOCK: addvalue = (Spirit / 5 + 15); break;
}
addvalue /= 2.0f; // the above addvalue are given per tick which occurs every 2 seconds, hence this divide by 2
return addvalue;
}
void Player::UpdateManaRegen()
{
// Mana regen from spirit
float power_regen = OCTRegenMPPerSpirit();
// Apply PCT bonus from SPELL_AURA_MOD_POWER_REGEN_PERCENT aura on spirit base regen
power_regen *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_POWER_REGEN_PERCENT, POWER_MANA);
// Mana regen from SPELL_AURA_MOD_POWER_REGEN aura
float power_regen_mp5 = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) / 5.0f;
// Set regen rate in cast state apply only on spirit based regen
int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT);
if (modManaRegenInterrupt > 100)
{ modManaRegenInterrupt = 100; }
m_modManaRegenInterrupt = power_regen_mp5 + power_regen * modManaRegenInterrupt / 100.0f;
m_modManaRegen = power_regen_mp5 + power_regen;
}
]]
local function GetRegenMPPerSpirit()
local addvalue = 0
local stat, Spirit, posBuff, negBuff = UnitStat("player", 5)
local lClass, class = UnitClass("player")
if class == "DRUID" then
addvalue = (Spirit / 5 + 15)
elseif class == "HUNTER" then
addvalue = (Spirit / 5 + 15)
elseif class == "MAGE" then
addvalue = (Spirit / 4 + 12.5)
elseif class == "PALADIN" then
addvalue = (Spirit / 5 + 15)
elseif class == "PRIEST" then
addvalue = (Spirit / 4 + 12.5)
elseif class == "SHAMAN" then
addvalue = (Spirit / 5 + 17)
elseif class == "WARLOCK" then
addvalue = (Spirit / 5 + 15)
else
return addvalue
end
return addvalue
end
function BCS:GetManaRegen()
-- to-maybe-do: apply buffs/talents
local base, casting
local power_regen = GetRegenMPPerSpirit()
casting = power_regen / 100
base = power_regen
local mp5 = 0;
local MAX_INVENTORY_SLOTS = 19
for slot=0, MAX_INVENTORY_SLOTS do
local hasItem = BCS_Tooltip:SetInventoryItem("player", slot)
if hasItem then
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
if left:GetText() then
local _,_, value = strfind(left:GetText(), L["^Mana Regen %+(%d+)"])
if value then
mp5 = mp5 + tonumber(value)
end
_,_, value = strfind(left:GetText(), L["Equip: Restores (%d+) mana per 5 sec."])
if value then