forked from Lexiebean/BetterCharacterStats
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelper.lua
1992 lines (1898 loc) · 74.3 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
BCScache = BCScache or {
["gear"] = {
damage_and_healing = 0,
arcane = 0,
fire = 0,
frost = 0,
holy = 0,
nature = 0,
shadow = 0,
healing = 0,
mp5 = 0,
casting = 0,
spell_hit = 0,
spell_crit = 0,
hit = 0,
ranged_hit = 0,
ranged_crit = 0
},
["talents"] = {
damage_and_healing = 0,
healing = 0,
spell_hit = 0,
spell_hit_fire = 0,
spell_hit_frost = 0,
spell_hit_arcane = 0,
spell_hit_shadow = 0,
spell_hit_holy = 0,
spell_crit = 0,
casting = 0,
mp5 = 0,
hit = 0,
ranged_hit = 0,
ranged_crit = 0
},
["auras"] = {
damage_and_healing = 0,
only_damage = 0, -- +dmg to all schools, needed to calculate healing
arcane = 0,
fire = 0,
frost = 0,
holy = 0,
nature = 0,
shadow = 0,
healing = 0,
mp5 = 0,
casting = 0,
spell_hit = 0,
spell_crit = 0,
hit = 0,
ranged_hit = 0,
ranged_crit = 0,
hit_debuff = 0
},
["skills"] = {
mh = 0,
oh = 0,
ranged = 0
}
}
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)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
if text == "Power of the Guardian" and searchText == "Power of the Guardian Crit" then
searchText = "Increases spell critical chance by (%d)%%."
left = getglobal(BCS_Prefix .. "TextLeft" .. 2)
end
local value = {strfind(text, 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)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local value = {strfind(text, searchText)}
if value[1] then
return unpack(value)
end
end
end
end
end
end
end
function BCS:GetHitRating(hitOnly)
local Hit_Set_Bonus = {}
local hit = 0
if BCS.needScanGear then
BCScache["gear"].hit = 0
--scan gear
for slot=1, 19 do
if BCS_Tooltip:SetInventoryItem('player', slot) then
local _, _, eqItemLink = strfind(GetInventoryItemLink('player', slot), "(item:%d+:%d+:%d+:%d+)")
if eqItemLink then BCS_Tooltip:ClearLines() BCS_Tooltip:SetHyperlink(eqItemLink) end
local SET_NAME = nil
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _,_, value = strfind(text, L["Equip: Improves your chance to hit by (%d)%%."])
if value then
BCScache["gear"].hit = BCScache["gear"].hit + tonumber(value)
end
_,_, value = strfind(text, L["/Hit %+(%d+)"])
if value then
BCScache["gear"].hit = BCScache["gear"].hit + tonumber(value)
end
_,_, value = strfind(text, "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_,_, value = strfind(text, 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)
BCScache["gear"].hit = BCScache["gear"].hit + tonumber(value)
break
end
end
end
end
end
end
if BCS.needScanAuras then
BCScache["auras"].hit = 0
BCScache["auras"].hit_debuff = 0
-- buffs
local _, _, hitFromAura = BCS:GetPlayerAura(L["Chance to hit increased by (%d)%%."])
if hitFromAura then
BCScache["auras"].hit = BCScache["auras"].hit + tonumber(hitFromAura)
end
_, _, hitFromAura = BCS:GetPlayerAura(L["Improves your chance to hit by (%d+)%%."])
if hitFromAura then
BCScache["auras"].hit = BCScache["auras"].hit + tonumber(hitFromAura)
end
_, _, hitFromAura = BCS:GetPlayerAura(L["Increases attack power by %d+ and chance to hit by (%d+)%%."])
if hitFromAura then
BCScache["auras"].hit = BCScache["auras"].hit + tonumber(hitFromAura)
end
-- debuffs
_, _, hitFromAura = BCS:GetPlayerAura(L["Chance to hit reduced by (%d+)%%."], 'HARMFUL')
if hitFromAura then
BCScache["auras"].hit_debuff = BCScache["auras"].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
BCScache["auras"].hit_debuff = BCScache["auras"].hit_debuff + tonumber(hitFromAura)
end
hitFromAura = BCS:GetPlayerAura(L["Lowered chance to hit."], 'HARMFUL')
if hitFromAura then
BCScache["auras"].hit_debuff = BCScache["auras"].hit_debuff + 25
end
end
if BCS.needScanTalents then
BCScache["talents"].hit = 0
--scan talents
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Rogue
local _,_, value = strfind(text, L["Increases your chance to hit with melee weapons by (%d)%%."])
if value and rank > 0 then
BCScache["talents"].hit = BCScache["talents"].hit + tonumber(value)
break
end
-- Hunter
_,_, value = strfind(text, L["Increases hit chance by (%d)%% and increases the chance movement impairing effects will be resisted by an additional %d+%%."])
if value and rank > 0 then
BCScache["talents"].hit = BCScache["talents"].hit + tonumber(value)
break
end
-- Druid
-- Natural Weapons
_,_, value = strfind(text, "Also increases chance to hit with melee attacks and spells by (%d+)%%.")
if value and rank > 0 then
BCScache["talents"].hit = BCScache["talents"].hit + tonumber(value)
break
end
-- Paladin
-- Precision
_,_, value = strfind(text, "Increases your chance to hit with melee attacks and spells by (%d+)%%.")
if value and rank > 0 then
BCScache["talents"].hit = BCScache["talents"].hit + tonumber(value)
break
end
-- Shaman
-- Elemental Devastation
_,_, value = strfind(text, "Increases your chance to hit with spells and melee attacks by (%d+)%%")
if value and rank > 0 then
BCScache["talents"].hit = BCScache["talents"].hit + tonumber(value)
break
end
end
end
end
end
end
hit = BCScache["talents"].hit + BCScache["gear"].hit + BCScache["auras"].hit
if not hitOnly then
hit = hit - BCScache["auras"].hit_debuff
if hit < 0 then hit = 0 end -- Dust Cloud OP
return hit
else
return hit
end
end
function BCS:GetRangedHitRating()
if BCS.needScanGear then
BCScache["gear"].ranged_hit = 0
if BCS_Tooltip:SetInventoryItem("player", 18) then
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _,_, value = strfind(text, L["+(%d)%% Ranged Hit"])
if value then
BCScache["gear"].ranged_hit = BCScache["gear"].ranged_hit + tonumber(value)
break
end
end
end
end
end
local ranged_hit = BCS:GetHitRating(true) + BCScache["gear"].ranged_hit - BCScache["auras"].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_holy = 0
local hit_Set_Bonus = {}
if BCS.needScanGear then
BCScache["gear"].spell_hit = 0
-- scan gear
for slot=1, 19 do
if BCS_Tooltip:SetInventoryItem('player', slot) then
local _, _, eqItemLink = strfind(GetInventoryItemLink('player', slot), "(item:%d+:%d+:%d+:%d+)")
if eqItemLink then BCS_Tooltip:ClearLines() BCS_Tooltip:SetHyperlink(eqItemLink) end
local SET_NAME
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _,_, value = strfind(text, L["Equip: Improves your chance to hit with spells by (%d)%%."])
if value then
BCScache["gear"].spell_hit = BCScache["gear"].spell_hit + tonumber(value)
end
_,_, value = strfind(text, L["/Spell Hit %+(%d+)"])
if value then
BCScache["gear"].spell_hit = BCScache["gear"].spell_hit + tonumber(value)
end
_,_, value = strfind(text, "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_, _, value = strfind(text, 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)
BCScache["gear"].spell_hit = BCScache["gear"].spell_hit + tonumber(value)
end
end
end
end
end
end
if BCS.needScanTalents then
BCScache["talents"].spell_hit = 0
BCScache["talents"].spell_hit_fire = 0
BCScache["talents"].spell_hit_frost = 0
BCScache["talents"].spell_hit_arcane = 0
BCScache["talents"].spell_hit_shadow = 0
BCScache["talents"].spell_hit_holy = 0
-- scan talents
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Mage
-- Elemental Precision
local _,_, value = strfind(text, L["Reduces the chance that the opponent can resist your Frost and Fire spells by (%d)%%."])
if value and rank > 0 then
BCScache["talents"].spell_hit_fire = BCScache["talents"].spell_hit_fire + tonumber(value)
BCScache["talents"].spell_hit_frost = BCScache["talents"].spell_hit_frost + tonumber(value)
break
end
-- Arcane Focus
_,_, value = strfind(text, L["Reduces the chance that the opponent can resist your Arcane spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].spell_hit_arcane = BCScache["talents"].spell_hit_arcane + tonumber(value)
break
end
-- Priest
-- Piercing Light
_,_, value = strfind(text, L["Reduces the chance for enemies to resist your Holy and Discipline spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].spell_hit_holy = BCScache["talents"].spell_hit_holy + tonumber(value)
break
end
-- Shadow Focus
_,_, value = strfind(text, L["Reduces your target's chance to resist your Shadow spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].spell_hit_shadow = BCScache["talents"].spell_hit_shadow + tonumber(value)
break
end
-- Druid
-- Natural Weapons
_,_, value = strfind(text, "Also increases chance to hit with melee attacks and spells by (%d+)%%.")
if value and rank > 0 then
BCScache["talents"].spell_hit = BCScache["talents"].spell_hit + tonumber(value)
break
end
-- Paladin
-- Precision
_,_, value = strfind(text, "Increases your chance to hit with melee attacks and spells by (%d+)%%.")
if value and rank > 0 then
BCScache["talents"].spell_hit = BCScache["talents"].spell_hit + tonumber(value)
break
end
-- Shaman
-- Elemental Devastation
_,_, value = strfind(text, "Increases your chance to hit with spells and melee attacks by (%d+)%%")
if value and rank > 0 then
BCScache["talents"].spell_hit = BCScache["talents"].spell_hit + tonumber(value)
break
end
-- Warlock
-- Suppression
_,_, value = strfind(text, L["Reduces the chance for enemies to resist your Affliction spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].spell_hit_shadow = BCScache["talents"].spell_hit_shadow + tonumber(value)
break
end
end
end
end
end
end
-- buffs
if BCS.needScanAuras then
BCScache["auras"].spell_hit = 0
local _, _, hitFromAura = BCS:GetPlayerAura(L["Spell hit chance increased by (%d+)%%."])
if hitFromAura then
BCScache["auras"].spell_hit = BCScache["auras"].spell_hit + tonumber(hitFromAura)
end
-- Elemental Devastation
_, _, hitFromAura = BCS:GetPlayerAura("Increases your chance to hit with spells by (%d+)%%")
if hitFromAura then
BCScache["auras"].spell_hit = BCScache["auras"].spell_hit + tonumber(hitFromAura)
end
end
hit = BCScache["gear"].spell_hit + BCScache["talents"].spell_hit + BCScache["auras"].spell_hit
hit_fire = BCScache["talents"].spell_hit_fire
hit_frost = BCScache["talents"].spell_hit_frost
hit_arcane = BCScache["talents"].spell_hit_arcane
hit_shadow = BCScache["talents"].spell_hit_shadow
hit_holy = BCScache["talents"].spell_hit_holy
return hit, hit_fire, hit_frost, hit_arcane, hit_shadow, hit_holy
end
function BCS:GetCritChance()
local crit = 0
--scan spellbook
for tab=1, GetNumSpellTabs() do
local _, _, 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)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _,_, value = strfind(text, L["([%d.]+)%% chance to crit"])
if value then
crit = crit + tonumber(value)
break
end
end
end
end
end
return crit
end
function BCS:GetRangedCritChance()
-- values from vmangos core
local crit = 0
local _, class = UnitClass("player")
local _, agility = UnitStat("player", 2)
local vallvl1 = 0
local vallvl60 = 0
local classrate = 0
if class == "MAGE" then
vallvl1 = 12.9
vallvl60 = 20
elseif class == "ROGUE" then
vallvl1 = 2.2
vallvl60 = 29
elseif class == "HUNTER" then
vallvl1 = 3.5
vallvl60 = 53
elseif class == "PRIEST" then
vallvl1 = 11
vallvl60 = 20
elseif class == "WARLOCK" then
vallvl1 = 8.4
vallvl60 = 20
elseif class == "WARRIOR" then
vallvl1 = 3.9
vallvl60 = 20
else
return crit
end
classrate = vallvl1 * (60 - UnitLevel("player")) / 59 + vallvl60 * (UnitLevel("player") - 1) / 59
crit = agility / classrate
if BCS.needScanTalents then
BCScache["talents"].ranged_crit = 0
--scan talents
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
local _,_, value = strfind(text, L["Increases your critical strike chance with ranged weapons by (%d)%%."])
if value and rank > 0 then
BCScache["talents"].ranged_crit = BCScache["talents"].ranged_crit + tonumber(value)
break
end
_,_, value = strfind(text, L["Increases your critical strike chance with all attacks by (%d)%%."])
if value and rank > 0 then
BCScache["talents"].ranged_crit = BCScache["talents"].ranged_crit + tonumber(value)
break
end
end
end
end
end
end
if BCS.needScanGear then
BCScache["gear"].ranged_crit = 0
--scan gear
local Crit_Set_Bonus = {}
for slot=1, 19 do
if BCS_Tooltip:SetInventoryItem('player', slot) then
local _, _, eqItemLink = strfind(GetInventoryItemLink('player', slot), "(item:%d+:%d+:%d+:%d+)")
if eqItemLink then BCS_Tooltip:ClearLines() BCS_Tooltip:SetHyperlink(eqItemLink) end
local SET_NAME
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _,_, value = strfind(text, L["Equip: Improves your chance to get a critical strike by (%d)%%."])
if value then
BCScache["gear"].ranged_crit = BCScache["gear"].ranged_crit + tonumber(value)
end
_,_, value = strfind(text, "Equip: Improves your chance to get a critical strike with missile weapons by (%d)%%.")
if value then
BCScache["gear"].ranged_crit = BCScache["gear"].ranged_crit + tonumber(value)
end
-- Might of the Scourge (shoulder enchant)
_,_, value = strfind(text, L["%+(%d+)%% Critical Strike"])
if value then
BCScache["gear"].ranged_crit = BCScache["gear"].ranged_crit + tonumber(value)
end
_,_, value = strfind(text, "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_, _, value = strfind(text, L["^Set: Improves your chance to get a critical strike by (%d)%%."])
if value and SET_NAME and not tContains(Crit_Set_Bonus, SET_NAME) then
tinsert(Crit_Set_Bonus, SET_NAME)
BCScache["gear"].ranged_crit = BCScache["gear"].ranged_crit + tonumber(value)
end
end
end
end
end
end
if BCS.needScanAuras then
BCScache["auras"].ranged_crit = 0
--buffs
--ony head
local 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
BCScache["auras"].ranged_crit = BCScache["auras"].ranged_crit + 5
end
--mongoose
_, _, critFromAura = BCS:GetPlayerAura(L["Agility increased by 25, Critical hit chance increases by (%d)%%."])
if critFromAura then
BCScache["auras"].ranged_crit = BCScache["auras"].ranged_crit + tonumber(critFromAura)
end
--songflower
_, _, critFromAura = BCS:GetPlayerAura(L["Increases chance for a melee, ranged, or spell critical by (%d+)%% and all attributes by %d+."])
if critFromAura then
BCScache["auras"].ranged_crit = BCScache["auras"].ranged_crit + tonumber(critFromAura)
end
--leader of the pack
_, _, critFromAura = BCS:GetPlayerAura(L["Increases ranged and melee critical chance by (%d+)%%."])
if critFromAura then
BCScache["auras"].ranged_crit = BCScache["auras"].ranged_crit + tonumber(critFromAura)
--check if druid is shapeshifted and have Idol of the Moonfang equipped
for i=1, GetNumPartyMembers() do
local _, partyClass = UnitClass("party"..i)
if partyClass == "DRUID" then
if BCS_Tooltip:SetInventoryItem("party"..i, 18) and UnitCreatureType("party"..i) == "Beast" then
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
_, _, critFromAura = strfind(text, L["Equip: Increases the critical chance provided by Leader of the Pack and Moonkin Aura by (%d)%%."])
if critFromAura then
BCScache["auras"].ranged_crit = BCScache["auras"].ranged_crit + tonumber(critFromAura)
break
end
end
end
end
end
end
end
end
if class == "MAGE" then
crit = crit + 3.2
elseif class == "PRIEST" then
crit = crit + 3
elseif class == "WARLOCK" then
crit = crit + 2
end
crit = crit + BCScache["gear"].ranged_crit + BCScache["talents"].ranged_crit + BCScache["auras"].ranged_crit
return crit
end
function BCS:GetSpellCritChance()
local Crit_Set_Bonus = {}
local spellCrit = 0;
local _, intellect = UnitStat("player", 4)
local _, class = UnitClass("player")
-- values from vmangos core
local playerLevel = UnitLevel("player")
if class == "MAGE" then
spellCrit = 3.7 + intellect / (14.77 + .65 * playerLevel)
elseif class == "WARLOCK" then
spellCrit = 3.18 + intellect / (11.30 + .82 * playerLevel)
elseif class == "PRIEST" then
spellCrit = 2.97 + intellect / (10.03 + .82 * playerLevel)
elseif class == "DRUID" then
spellCrit = 3.33 + intellect / (12.41 + .79 * playerLevel)
elseif class == "SHAMAN" then
spellCrit = 3.54 + intellect / (11.51 + .8 * playerLevel)
elseif class == "PALADIN" then
spellCrit = 3.7 + intellect / (14.77 + .65 * playerLevel)
end
if BCS.needScanGear then
BCScache["gear"].spell_crit = 0
--scan gear
for slot=1, 19 do
if BCS_Tooltip:SetInventoryItem('player', slot) then
local _, _, eqItemLink = strfind(GetInventoryItemLink('player', slot), "(item:%d+:%d+:%d+:%d+)")
if eqItemLink then BCS_Tooltip:ClearLines() BCS_Tooltip:SetHyperlink(eqItemLink) end
local SET_NAME = nil
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _,_, value = strfind(text, L["Equip: Improves your chance to get a critical strike with spells by (%d)%%."])
if value then
BCScache["gear"].spell_crit = BCScache["gear"].spell_crit + tonumber(value)
end
_,_, value = strfind(text, "(.+) %(%d/%d%)")
if value then
SET_NAME = value
end
_, _, value = strfind(text, 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)
BCScache["gear"].spell_crit = BCScache["gear"].spell_crit + tonumber(value)
end
_,_, value = strfind(text, "(%d)%% Spell Critical Strike")
if value then
BCScache["gear"].spell_crit = BCScache["gear"].spell_crit + tonumber(value)
end
end
end
end
end
if BCS_Tooltip:SetInventoryItem("player", 16) then
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local found = strfind(text, "Brilliant Wizard Oil")
if found then
BCScache["gear"].spell_crit = BCScache["gear"].spell_crit + 1
end
end
end
end
end
if BCS.needScanAuras then
BCScache["auras"].spell_crit = 0
-- buffs
local _, _, critFromAura = BCS:GetPlayerAura(L["Chance for a critical hit with a spell increased by (%d+)%%."])
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + tonumber(critFromAura)
end
_, _, critFromAura = BCS:GetPlayerAura("(Moonkin Aura)")
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + 3
if BCS:GetPlayerAura("Moonkin Form") and BCS_Tooltip:SetInventoryItem("player", 18) then
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
_, _, critFromAura = strfind(text, L["Equip: Increases the critical chance provided by Leader of the Pack and Moonkin Aura by (%d)%%."])
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + tonumber(critFromAura)
end
end
end
else
--check if druid is shapeshifted and have Idol of the Moonfang equipped
for i=1, GetNumPartyMembers() do
local _, partyClass = UnitClass("party"..i)
if partyClass == "DRUID" then
if BCS_Tooltip:SetInventoryItem("party"..i, 18) then
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
_, _, critFromAura = strfind(text, L["Equip: Increases the critical chance provided by Leader of the Pack and Moonkin Aura by (%d)%%."])
if critFromAura then
for buff = 1, 32 do
if UnitBuff("party"..i, buff) and UnitBuff("party"..i, buff) == "Interface\\Icons\\Spell_Nature_ForceOfNature" then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + tonumber(critFromAura)
break
end
end
end
end
end
end
end
end
end
end
critFromAura = BCS:GetPlayerAura("Inner Focus")
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + 25
end
_, _, critFromAura = BCS:GetPlayerAura("Power of the Guardian Crit")
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + tonumber(critFromAura)
end
_, _, critFromAura = BCS:GetPlayerAura("Chance to get a critical strike with spells is increased by (%d+)%%")
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + tonumber(critFromAura)
end
_, _, critFromAura = BCS:GetPlayerAura(L["While active, target's critical hit chance with spells and attacks increases by 10%%."])--SoD spell? 23964
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + 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
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + 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
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + 10
end
_, _, critFromAura = BCS:GetPlayerAura(L["Critical strike chance with spells and melee attacks increased by (%d+)%%."])
if critFromAura then
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit + 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
BCScache["auras"].spell_crit = BCScache["auras"].spell_crit - tonumber(critFromAura)
end
end
-- scan talents
if BCS.needScanTalents then
BCScache["talents"].spell_crit = 0
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Arcane Instability
local _,_, value = strfind(text, L["Increases your spell damage and critical srike chance by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].spell_crit = BCScache["talents"].spell_crit + tonumber(value)
break
end
end
end
end
end
end
spellCrit = spellCrit + BCScache["talents"].spell_crit + BCScache["gear"].spell_crit + BCScache["auras"].spell_crit
return spellCrit
end
function BCS:GetSpellCritFromClass(class)
if not class then
return 0, 0, 0, 0, 0, 0
end
if class == "PALADIN" then
--scan talents
if BCS.needScanTalents or BCS.needScanAuras then
BCScache["talents"].paladin_holy_light = 0
BCScache["talents"].paladin_flash = 0
BCScache["talents"].paladin_shock = 0
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Holy Power
local _,_, value = strfind(text, L["Increases the critical effect chance of your Holy Light and Flash of Light by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].paladin_holy_light = BCScache["talents"].paladin_holy_light + tonumber(value)
BCScache["talents"].paladin_flash = BCScache["talents"].paladin_flash + tonumber(value)
break
end
-- Divine Favor
_,_, value = strfind(text, L["Improves your chance to get a critical strike with Holy Shock by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].paladin_shock = BCScache["talents"].paladin_shock + tonumber(value)
break
end
end
end
end
end
end
return BCScache["talents"].paladin_holy_light,
BCScache["talents"].paladin_flash,
BCScache["talents"].paladin_shock, 0, 0, 0
elseif class == "DRUID" then
--scan talents
if BCS.needScanTalents then
BCScache["talents"].druid_moonfire = 0
BCScache["talents"].druid_regrowth = 0
-- scan talents
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Improved Moonfire
local _,_, value = strfind(text, L["Increases the damage and critical strike chance of your Moonfire spell by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].druid_moonfire = BCScache["talents"].druid_moonfire + tonumber(value)
break
end
-- Improved Regrowth
_,_, value = strfind(text, L["Increases the critical effect chance of your Regrowth spell by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].druid_regrowth = BCScache["talents"].druid_regrowth + tonumber(value)
break
end
end
end
end
end
end
return BCScache["talents"].druid_moonfire,
BCScache["talents"].druid_regrowth, 0, 0, 0, 0
elseif class == "WARLOCK" then
--scan talents
if BCS.needScanTalents then
BCScache["talents"].warlock_destruction_spells = 0
BCScache["talents"].warlock_searing_pain = 0
-- scan talents
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Devastation
local _,_, value = strfind(text, L["Increases the critical strike chance of your Destruction spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].warlock_destruction_spells = BCScache["talents"].warlock_destruction_spells + tonumber(value)
BCScache["talents"].warlock_searing_pain = BCScache["talents"].warlock_searing_pain + tonumber(value)
break
end
-- Improved Searing Pain
_,_, value = strfind(text, L["Increases the critical strike chance of your Searing Pain spell by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].warlock_searing_pain = BCScache["talents"].warlock_searing_pain + tonumber(value)
break
end
end
end
end
end
end
return BCScache["talents"].warlock_destruction_spells,
BCScache["talents"].warlock_searing_pain, 0, 0, 0, 0
elseif class == "MAGE" then
--scan talents
if BCS.needScanTalents or BCS.needScanAuras then
BCScache["talents"].mage_arcane_spells = 0
BCScache["talents"].mage_fire_spells = 0
BCScache["talents"].mage_fireblast = 0
BCScache["talents"].mage_scorch = 0
BCScache["talents"].mage_flamestrike = 0
BCScache["talents"].mage_shatter = 0
-- scan talents
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Arcane Impact
local _,_, value = strfind(text, L["Increases the critical strike chance of your Arcane Explosion and Arcane Missiles spells by an additional (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].mage_arcane_spells = BCScache["talents"].mage_arcane_spells + tonumber(value)
break
end
-- Incinerate
_,_, value = strfind(text, L["Increases the critical strike chance of your Fire Blast and Scorch spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].mage_fireblast = BCScache["talents"].mage_fireblast + tonumber(value)
BCScache["talents"].mage_scorch = BCScache["talents"].mage_scorch + tonumber(value)
break
end
-- Improved Flamestrike
_,_, value = strfind(text, L["Increases the critical strike chance of your Flamestrike spell by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].mage_flamestrike = BCScache["talents"].mage_flamestrike + tonumber(value)
break
end
-- Critical Mass
_,_, value = strfind(text, L["Increases the critical strike chance of your Fire spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].mage_fire_spells = BCScache["talents"].mage_fire_spells + tonumber(value)
BCScache["talents"].mage_fireblast = BCScache["talents"].mage_fireblast + tonumber(value)
BCScache["talents"].mage_flamestrike = BCScache["talents"].mage_flamestrike + tonumber(value)
BCScache["talents"].mage_scorch = BCScache["talents"].mage_scorch + tonumber(value)
break
end
-- Shatter
_,_, value = strfind(text, L["Increases the critical strike chance of all your spells against frozen targets by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].mage_shatter = BCScache["talents"].mage_shatter + tonumber(value)
break
end
end
end
end
end
-- Buffs
local _, _, value = BCS:GetPlayerAura(L["Increases critical strike chance from Fire damage spells by (%d+)%%."])
-- Combustion
if value then
BCScache["talents"].mage_fire_spells = BCScache["talents"].mage_fire_spells + tonumber(value)
BCScache["talents"].mage_fireblast = BCScache["talents"].mage_fireblast + tonumber(value)
BCScache["talents"].mage_flamestrike = BCScache["talents"].mage_flamestrike + tonumber(value)
BCScache["talents"].mage_scorch = BCScache["talents"].mage_scorch + tonumber(value)
end
end
return BCScache["talents"].mage_arcane_spells,
BCScache["talents"].mage_fire_spells,
BCScache["talents"].mage_fireblast,
BCScache["talents"].mage_scorch,
BCScache["talents"].mage_flamestrike,
BCScache["talents"].mage_shatter
elseif class == "PRIEST" then
if BCS.needScanTalents then
BCScache["talents"].priest_holy_spells = 0
BCScache["talents"].priest_discipline_spells = 0
BCScache["talents"].priest_offensive_spells = 0
-- scan talents
for tab=1, GetNumTalentTabs() do
for talent=1, GetNumTalents(tab) do
BCS_Tooltip:SetTalent(tab, talent)
for line=1, BCS_Tooltip:NumLines() do
local left = getglobal(BCS_Prefix .. "TextLeft" .. line)
local text = left:GetText()
if text then
local _, _, _, _, rank = GetTalentInfo(tab, talent)
-- Divinity
local _,_, value = strfind(text, L["Increases the critical effect chance of your Holy and Discipline spells by (%d+)%%."])
if value and rank > 0 then
BCScache["talents"].priest_holy_spells = BCScache["talents"].priest_holy_spells + tonumber(value)
BCScache["talents"].priest_discipline_spells = BCScache["talents"].priest_discipline_spells + tonumber(value)
break
end
-- Force of Will
_,_, value = strfind(text, "Increases your spell damage and the critical strike chance of your offensive spells by (%d+)%%")
if value and rank > 0 then
BCScache["talents"].priest_offensive_spells = BCScache["talents"].priest_offensive_spells + tonumber(value)
break
end
end