-
Notifications
You must be signed in to change notification settings - Fork 996
Expand file tree
/
Copy pathCalcOffence-3_0.lua
More file actions
2214 lines (2151 loc) · 102 KB
/
Copy pathCalcOffence-3_0.lua
File metadata and controls
2214 lines (2151 loc) · 102 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
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
-- Path of Building
--
-- Module: Calc Offence
-- Performs offence calculations.
--
local calcs = ...
local pairs = pairs
local ipairs = ipairs
local unpack = unpack
local t_insert = table.insert
local m_floor = math.floor
local m_modf = math.modf
local m_min = math.min
local m_max = math.max
local m_sqrt = math.sqrt
local m_pi = math.pi
local bor = bit.bor
local band = bit.band
local bnot = bit.bnot
local s_format = string.format
local tempTable1 = { }
local tempTable2 = { }
local tempTable3 = { }
local isElemental = { Fire = true, Cold = true, Lightning = true }
-- List of all damage types, ordered according to the conversion sequence
local dmgTypeList = {"Physical", "Lightning", "Cold", "Fire", "Chaos"}
local dmgTypeFlags = {
Physical = 0x01,
Lightning = 0x02,
Cold = 0x04,
Fire = 0x08,
Elemental = 0x0E,
Chaos = 0x10,
}
-- Magic table for caching the modifier name sets used in calcDamage()
local damageStatsForTypes = setmetatable({ }, { __index = function(t, k)
local modNames = { "Damage" }
for type, flag in pairs(dmgTypeFlags) do
if band(k, flag) ~= 0 then
t_insert(modNames, type.."Damage")
end
end
t[k] = modNames
return modNames
end })
-- Calculate min/max damage for the given damage type
local function calcDamage(activeSkill, output, cfg, breakdown, damageType, typeFlags, convDst)
local skillModList = activeSkill.skillModList
typeFlags = bor(typeFlags, dmgTypeFlags[damageType])
-- Calculate conversions
local addMin, addMax = 0, 0
local conversionTable = activeSkill.conversionTable
for _, otherType in ipairs(dmgTypeList) do
if otherType == damageType then
-- Damage can only be converted from damage types that preceed this one in the conversion sequence, so stop here
break
end
local convMult = conversionTable[otherType][damageType]
if convMult > 0 then
-- Damage is being converted/gained from the other damage type
local min, max = calcDamage(activeSkill, output, cfg, breakdown, otherType, typeFlags, damageType)
addMin = addMin + min * convMult
addMax = addMax + max * convMult
end
end
if addMin ~= 0 and addMax ~= 0 then
addMin = round(addMin)
addMax = round(addMax)
end
local baseMin = output[damageType.."MinBase"]
local baseMax = output[damageType.."MaxBase"]
if baseMin == 0 and baseMax == 0 then
-- No base damage for this type, don't need to calculate modifiers
if breakdown and (addMin ~= 0 or addMax ~= 0) then
t_insert(breakdown.damageTypes, {
source = damageType,
convSrc = (addMin ~= 0 or addMax ~= 0) and (addMin .. " to " .. addMax),
total = addMin .. " to " .. addMax,
convDst = convDst and s_format("%d%% to %s", conversionTable[damageType][convDst] * 100, convDst),
})
end
return addMin, addMax
end
-- Combine modifiers
local modNames = damageStatsForTypes[typeFlags]
local inc = 1 + skillModList:Sum("INC", cfg, unpack(modNames)) / 100
local more = m_floor(skillModList:More(cfg, unpack(modNames)) * 100 + 0.50000001) / 100
if breakdown then
t_insert(breakdown.damageTypes, {
source = damageType,
base = baseMin .. " to " .. baseMax,
inc = (inc ~= 1 and "x "..inc),
more = (more ~= 1 and "x "..more),
convSrc = (addMin ~= 0 or addMax ~= 0) and (addMin .. " to " .. addMax),
total = (round(baseMin * inc * more) + addMin) .. " to " .. (round(baseMax * inc * more) + addMax),
convDst = convDst and conversionTable[damageType][convDst] > 0 and s_format("%d%% to %s", conversionTable[damageType][convDst] * 100, convDst),
})
end
return (round(baseMin * inc * more) + addMin),
(round(baseMax * inc * more) + addMax)
end
local function calcAilmentSourceDamage(activeSkill, output, cfg, breakdown, damageType, typeFlags)
local min, max = calcDamage(activeSkill, output, cfg, breakdown, damageType, typeFlags)
local convMult = activeSkill.conversionTable[damageType].mult
if breakdown and convMult ~= 1 then
t_insert(breakdown, "Source damage:")
t_insert(breakdown, s_format("%d to %d ^8(total damage)", min, max))
t_insert(breakdown, s_format("x %g ^8(%g%% converted to other damage types)", convMult, (1-convMult)*100))
t_insert(breakdown, s_format("= %d to %d", min * convMult, max * convMult))
end
return min * convMult, max * convMult
end
-- Performs all offensive calculations
function calcs.offence(env, actor, activeSkill)
local enemyDB = actor.enemy.modDB
local output = actor.output
local breakdown = actor.breakdown
local skillModList = activeSkill.skillModList
local skillData = activeSkill.skillData
local skillFlags = activeSkill.skillFlags
local skillCfg = activeSkill.skillCfg
if skillData.showAverage then
skillFlags.showAverage = true
else
skillFlags.notAverage = true
end
if skillFlags.disable then
-- Skill is disabled
output.CombinedDPS = 0
return
end
local function runSkillFunc(name)
local func = activeSkill.activeEffect.grantedEffect[name]
if func then
func(activeSkill, output)
end
end
runSkillFunc("initialFunc")
-- Update skill data
for _, value in ipairs(skillModList:List(skillCfg, "SkillData")) do
if value.merge == "MAX" then
skillData[value.key] = m_max(value.value, skillData[value.key] or 0)
else
skillData[value.key] = value.value
end
end
skillCfg.skillCond["SkillIsTriggered"] = skillData.triggered
-- Add addition stat bonuses
if skillModList:Flag(nil, "IronGrip") then
skillModList:NewMod("PhysicalDamage", "INC", actor.strDmgBonus, "Strength", bor(ModFlag.Attack, ModFlag.Projectile))
end
if skillModList:Flag(nil, "IronWill") then
skillModList:NewMod("Damage", "INC", actor.strDmgBonus, "Strength", ModFlag.Spell)
end
if skillModList:Flag(nil, "MinionDamageAppliesToPlayer") then
-- Minion Damage conversion from The Scourge
for _, value in ipairs(skillModList:List(skillCfg, "MinionModifier")) do
if value.mod.name == "Damage" and value.mod.type == "INC" then
skillModList:AddMod(value.mod)
end
end
end
if skillModList:Flag(nil, "MinionAttackSpeedAppliesToPlayer") then
-- Minion Attack Speed conversion from Spiritual Command
for _, value in ipairs(skillModList:List(skillCfg, "MinionModifier")) do
if value.mod.name == "Speed" and value.mod.type == "INC" and (value.mod.flags == 0 or band(value.mod.flags, ModFlag.Attack) ~= 0) then
skillModList:NewMod("Speed", "INC", value.mod.value, value.mod.source, ModFlag.Attack, value.mod.keywordFlags, unpack(value.mod))
end
end
end
local spellConvPercent = 0
if skillData.spellDamageAppliesToAttackAtPercentValue then
spellConvPercent = m_max(spellConvPercent, skillData.spellDamageAppliesToAttackAtPercentValue)
end
if skillModList:Flag(nil, "SpellDamageAppliesToAttacksAt150Percent") then
spellConvPercent = m_max(spellConvPercent, 150)
end
if skillModList:Flag(nil, "SpellDamageAppliesToAttacks") then
spellConvPercent = m_max(spellConvPercent, 100)
end
if spellConvPercent > 0 then
-- Spell Damage conversion
for i, value in ipairs(skillModList:Tabulate("INC", { flags = ModFlag.Spell }, "Damage")) do
local mod = value.mod
if band(mod.flags, ModFlag.Spell) ~= 0 then
skillModList:NewMod("Damage", "INC", mod.value * spellConvPercent / 100, mod.source, bor(band(mod.flags, bnot(ModFlag.Spell)), ModFlag.Attack), mod.keywordFlags, unpack(mod))
end
end
end
if skillModList:Flag(nil, "ClawDamageAppliesToUnarmed") then
-- Claw Damage conversion from Rigwald's Curse
for i, value in ipairs(skillModList:Tabulate("INC", { flags = ModFlag.Claw, keywordFlags = KeywordFlag.Hit }, "Damage")) do
local mod = value.mod
if band(mod.flags, ModFlag.Claw) ~= 0 then
skillModList:NewMod("Damage", mod.type, mod.value, mod.source, bor(band(mod.flags, bnot(ModFlag.Claw)), ModFlag.Unarmed), mod.keywordFlags, unpack(mod))
end
end
end
if skillModList:Flag(nil, "ClawAttackSpeedAppliesToUnarmed") then
-- Claw Attack Speed conversion from Rigwald's Curse
for i, value in ipairs(skillModList:Tabulate("INC", { flags = bor(ModFlag.Claw, ModFlag.Attack, ModFlag.Hit) }, "Speed")) do
local mod = value.mod
if band(mod.flags, ModFlag.Claw) ~= 0 and band(mod.flags, ModFlag.Attack) ~= 0 then
skillModList:NewMod("Speed", mod.type, mod.value, mod.source, bor(band(mod.flags, bnot(ModFlag.Claw)), ModFlag.Unarmed), mod.keywordFlags, unpack(mod))
end
end
end
if skillModList:Flag(nil, "ClawCritChanceAppliesToUnarmed") then
-- Claw Crit Chance conversion from Rigwald's Curse
for i, value in ipairs(skillModList:Tabulate("INC", { flags = bor(ModFlag.Claw, ModFlag.Hit) }, "CritChance")) do
local mod = value.mod
if band(mod.flags, ModFlag.Claw) ~= 0 then
skillModList:NewMod("CritChance", mod.type, mod.value, mod.source, bor(band(mod.flags, bnot(ModFlag.Claw)), ModFlag.Unarmed), mod.keywordFlags, unpack(mod))
end
end
end
if skillModList:Flag(nil, "LightRadiusAppliesToAccuracy") then
-- Light Radius conversion from Corona Solaris
for i, value in ipairs(skillModList:Tabulate("INC", { }, "LightRadius")) do
local mod = value.mod
skillModList:NewMod("Accuracy", "INC", mod.value, mod.source, mod.flags, mod.keywordFlags, unpack(mod))
end
end
if skillModList:Flag(nil, "LightRadiusAppliesToAreaOfEffect") then
-- Light Radius conversion from Wreath of Phrecia
for i, value in ipairs(skillModList:Tabulate("INC", { }, "LightRadius")) do
local mod = value.mod
skillModList:NewMod("AreaOfEffect", "INC", math.floor(mod.value / 2), mod.source, mod.flags, mod.keywordFlags, unpack(mod))
end
end
if skillModList:Flag(nil, "LightRadiusAppliesToDamage") then
-- Light Radius conversion from Wreath of Phrecia
for i, value in ipairs(skillModList:Tabulate("INC", { }, "LightRadius")) do
local mod = value.mod
skillModList:NewMod("Damage", "INC", mod.value, mod.source, mod.flags, mod.keywordFlags, unpack(mod))
end
end
if skillModList:Flag(nil, "CastSpeedAppliesToTrapThrowingSpeed") then
-- Cast Speed conversion from Slavedriver's Hand
for i, value in ipairs(skillModList:Tabulate("INC", { flags = ModFlag.Cast }, "Speed")) do
local mod = value.mod
if (mod.flags == 0 or band(mod.flags, ModFlag.Cast) ~= 0) then
skillModList:NewMod("TrapThrowingSpeed", "INC", mod.value, mod.source, band(mod.flags, bnot(ModFlag.Cast), bnot(ModFlag.Attack)), mod.keywordFlags, unpack(mod))
end
end
end
if skillData.arrowSpeedAppliesToAreaOfEffect then
-- Arrow Speed conversion for Galvanic Arrow
for i, value in ipairs(skillModList:Tabulate("INC", { flags = ModFlag.Bow }, "ProjectileSpeed")) do
local mod = value.mod
skillModList:NewMod("AreaOfEffect", "INC", mod.value, mod.source, mod.flags, mod.keywordFlags, unpack(mod))
end
end
if skillModList:Flag(nil, "TransfigurationOfBody") then
skillModList:NewMod("Damage", "INC", m_floor(skillModList:Sum("INC", nil, "Life") * 0.3), "Transfiguration of Body", ModFlag.Attack)
end
if skillModList:Flag(nil, "TransfigurationOfMind") then
skillModList:NewMod("Damage", "INC", m_floor(skillModList:Sum("INC", nil, "Mana") * 0.3), "Transfiguration of Mind")
end
if skillModList:Flag(nil, "TransfigurationOfSoul") then
skillModList:NewMod("Damage", "INC", m_floor(skillModList:Sum("INC", nil, "EnergyShield") * 0.3), "Transfiguration of Soul", ModFlag.Spell)
end
if skillData.gainPercentBaseWandDamage then
local mult = skillData.gainPercentBaseWandDamage / 100
if actor.weaponData1.type == "Wand" and actor.weaponData2.type == "Wand" then
for _, damageType in ipairs(dmgTypeList) do
skillModList:NewMod(damageType.."Min", "BASE", ((actor.weaponData1[damageType.."Min"] or 0) + (actor.weaponData2[damageType.."Min"] or 0)) / 2 * mult, "Spellslinger")
skillModList:NewMod(damageType.."Max", "BASE", ((actor.weaponData1[damageType.."Max"] or 0) + (actor.weaponData2[damageType.."Max"] or 0)) / 2 * mult, "Spellslinger")
end
elseif actor.weaponData1.type == "Wand" then
for _, damageType in ipairs(dmgTypeList) do
skillModList:NewMod(damageType.."Min", "BASE", (actor.weaponData1[damageType.."Min"] or 0) * mult, "Spellslinger")
skillModList:NewMod(damageType.."Max", "BASE", (actor.weaponData1[damageType.."Max"] or 0) * mult, "Spellslinger")
end
elseif actor.weaponData2.type == "Wand" then
for _, damageType in ipairs(dmgTypeList) do
skillModList:NewMod(damageType.."Min", "BASE", (actor.weaponData2[damageType.."Min"] or 0) * mult, "Spellslinger")
skillModList:NewMod(damageType.."Max", "BASE", (actor.weaponData2[damageType.."Max"] or 0) * mult, "Spellslinger")
end
end
end
local isAttack = skillFlags.attack
runSkillFunc("preSkillTypeFunc")
-- Calculate skill type stats
if skillFlags.minion then
if activeSkill.minion and activeSkill.minion.minionData.limit then
output.ActiveMinionLimit = m_floor(calcLib.val(skillModList, activeSkill.minion.minionData.limit, skillCfg))
end
end
if skillFlags.chaining then
if skillModList:Flag(skillCfg, "CannotChain") then
output.ChainMaxString = "Cannot chain"
else
output.ChainMax = skillModList:Sum("BASE", skillCfg, "ChainCountMax", not skillFlags.projectile and "BeamChainCountMax" or nil)
output.ChainMaxString = output.ChainMax
output.Chain = m_min(output.ChainMax, skillModList:Sum("BASE", skillCfg, "ChainCount"))
output.ChainRemaining = m_max(0, output.ChainMax - output.Chain)
end
end
if skillFlags.projectile then
if skillModList:Flag(nil, "PointBlank") then
skillModList:NewMod("Damage", "MORE", 30, "Point Blank", bor(ModFlag.Attack, ModFlag.Projectile), { type = "DistanceRamp", ramp = {{10,1},{35,0},{150,-1}} })
end
if skillModList:Flag(nil, "FarShot") then
skillModList:NewMod("Damage", "MORE", 30, "Far Shot", bor(ModFlag.Attack, ModFlag.Projectile), { type = "DistanceRamp", ramp = {{35,0},{70,1}} })
end
local projBase = skillModList:Sum("BASE", skillCfg, "ProjectileCount")
local projMore = skillModList:More(skillCfg, "ProjectileCount")
output.ProjectileCount = round((projBase - 1) * projMore + 1)
if skillModList:Flag(skillCfg, "CannotPierce") then
output.PierceCountString = "Cannot pierce"
else
if skillModList:Flag(skillCfg, "PierceAllTargets") or enemyDB:Flag(nil, "AlwaysPierceSelf") then
output.PierceCount = 100
output.PierceCountString = "All targets"
else
output.PierceCount = skillModList:Sum("BASE", skillCfg, "PierceCount")
output.PierceCountString = output.PierceCount
end
end
output.ProjectileSpeedMod = calcLib.mod(skillModList, skillCfg, "ProjectileSpeed")
if breakdown then
breakdown.ProjectileSpeedMod = breakdown.mod(skillCfg, "ProjectileSpeed")
end
end
if skillFlags.melee then
if skillFlags.weapon1Attack then
actor.weaponRange1 = (actor.weaponData1.range and actor.weaponData1.range + skillModList:Sum("BASE", activeSkill.weapon1Cfg, "MeleeWeaponRange")) or (6 + skillModList:Sum("BASE", skillCfg, "UnarmedRange"))
end
if skillFlags.weapon2Attack then
actor.weaponRange2 = (actor.weaponData2.range and actor.weaponData2.range + skillModList:Sum("BASE", activeSkill.weapon2Cfg, "MeleeWeaponRange")) or (6 + skillModList:Sum("BASE", skillCfg, "UnarmedRange"))
end
if activeSkill.skillTypes[SkillType.MeleeSingleTarget] then
local range = 100
if skillFlags.weapon1Attack then
range = m_min(range, actor.weaponRange1)
end
if skillFlags.weapon2Attack then
range = m_min(range, actor.weaponRange2)
end
output.WeaponRange = range + 2
if breakdown then
breakdown.WeaponRange = {
radius = output.WeaponRange
}
end
end
end
if skillFlags.area or skillData.radius or (skillFlags.mine and activeSkill.skillTypes[SkillType.Aura]) then
output.AreaOfEffectMod = calcLib.mod(skillModList, skillCfg, "AreaOfEffect")
if skillData.radiusIsWeaponRange then
local range = 0
if skillFlags.weapon1Attack then
range = m_max(range, actor.weaponRange1)
end
if skillFlags.weapon2Attack then
range = m_max(range, actor.weaponRange2)
end
skillData.radius = range + 2
end
if skillData.radius then
skillFlags.area = true
local baseRadius = skillData.radius + (skillData.radiusExtra or 0) + skillModList:Sum("BASE", skillCfg, "AreaOfEffect")
output.AreaOfEffectRadius = m_floor(baseRadius * m_sqrt(output.AreaOfEffectMod))
if breakdown then
breakdown.AreaOfEffectRadius = breakdown.area(baseRadius, output.AreaOfEffectMod, output.AreaOfEffectRadius, skillData.radiusLabel)
end
if skillData.radiusSecondary then
output.AreaOfEffectModSecondary = calcLib.mod(skillModList, skillCfg, "AreaOfEffect", "AreaOfEffectSecondary")
baseRadius = skillData.radiusSecondary + (skillData.radiusExtra or 0)
output.AreaOfEffectRadiusSecondary = m_floor(baseRadius * m_sqrt(output.AreaOfEffectModSecondary))
if breakdown then
breakdown.AreaOfEffectRadiusSecondary = breakdown.area(baseRadius, output.AreaOfEffectModSecondary, output.AreaOfEffectRadiusSecondary, skillData.radiusSecondaryLabel)
end
end
if skillData.radiusTertiary then
output.AreaOfEffectModTertiary = calcLib.mod(skillModList, skillCfg, "AreaOfEffect", "AreaOfEffectTertiary")
baseRadius = skillData.radiusTertiary + (skillData.radiusExtra or 0)
output.AreaOfEffectRadiusTertiary = m_floor(baseRadius * m_sqrt(output.AreaOfEffectModTertiary))
if breakdown then
breakdown.AreaOfEffectRadiusTertiary = breakdown.area(baseRadius, output.AreaOfEffectModTertiary, output.AreaOfEffectRadiusTertiary, skillData.radiusTertiaryLabel)
end
end
end
if breakdown then
breakdown.AreaOfEffectMod = breakdown.mod(skillCfg, "AreaOfEffect")
end
end
if skillFlags.trap then
local baseSpeed = 1 / skillModList:Sum("BASE", skillCfg, "TrapThrowingTime")
output.TrapThrowingSpeed = baseSpeed * calcLib.mod(skillModList, skillCfg, "TrapThrowingSpeed") * output.ActionSpeedMod
output.TrapThrowingTime = 1 / output.TrapThrowingSpeed
if breakdown then
breakdown.TrapThrowingTime = { }
breakdown.multiChain(breakdown.TrapThrowingTime, {
label = "Throwing speed:",
base = s_format("%.2f ^8(base throwing speed)", baseSpeed),
{ "%.2f ^8(increased/reduced throwing speed)", 1 + skillModList:Sum("INC", skillCfg, "TrapThrowingSpeed") / 100 },
{ "%.2f ^8(more/less throwing speed)", skillModList:More(skillCfg, "TrapThrowingSpeed") },
{ "%.2f ^8(action speed modifier)", output.ActionSpeedMod },
total = s_format("= %.2f ^8per second", output.TrapThrowingSpeed),
})
end
output.ActiveTrapLimit = skillModList:Sum("BASE", skillCfg, "ActiveTrapLimit")
local baseCooldown = skillData.trapCooldown or skillData.cooldown
if baseCooldown then
output.TrapCooldown = baseCooldown / calcLib.mod(skillModList, skillCfg, "CooldownRecovery")
if breakdown then
breakdown.TrapCooldown = {
s_format("%.2fs ^8(base)", skillData.trapCooldown or skillData.cooldown or 4),
s_format("/ %.2f ^8(increased/reduced cooldown recovery)", 1 + skillModList:Sum("INC", skillCfg, "CooldownRecovery") / 100),
s_format("= %.2fs", output.TrapCooldown)
}
end
end
local areaMod = calcLib.mod(skillModList, skillCfg, "TrapTriggerAreaOfEffect")
output.TrapTriggerRadius = 10 * m_sqrt(areaMod)
if breakdown then
breakdown.TrapTriggerRadius = breakdown.area(10, areaMod, output.TrapTriggerRadius)
end
elseif skillData.cooldown then
local cooldownOverride = skillModList:Override(skillCfg, "CooldownRecovery")
output.Cooldown = cooldownOverride or skillData.cooldown / calcLib.mod(skillModList, skillCfg, "CooldownRecovery")
if breakdown then
breakdown.Cooldown = {
s_format("%.2fs ^8(base)", skillData.cooldown),
s_format("/ %.2f ^8(increased/reduced cooldown recovery)", 1 + skillModList:Sum("INC", skillCfg, "CooldownRecovery") / 100),
s_format("= %.2fs", output.Cooldown)
}
end
end
if skillFlags.mine then
local baseSpeed = 1 / skillModList:Sum("BASE", skillCfg, "MineLayingTime")
output.MineLayingSpeed = baseSpeed * calcLib.mod(skillModList, skillCfg, "MineLayingSpeed") * output.ActionSpeedMod
output.MineLayingTime = 1 / output.MineLayingSpeed
if breakdown then
breakdown.MineLayingTime = { }
breakdown.multiChain(breakdown.MineLayingTime, {
label = "Throwing speed:",
base = s_format("%.2f ^8(base throwing speed)", baseSpeed),
{ "%.2f ^8(increased/reduced throwing speed)", 1 + skillModList:Sum("INC", skillCfg, "MineLayingSpeed") / 100 },
{ "%.2f ^8(more/less throwing speed)", skillModList:More(skillCfg, "MineLayingSpeed") },
{ "%.2f ^8(action speed modifier)", output.ActionSpeedMod },
total = s_format("= %.2f ^8per second", output.MineLayingSpeed),
})
end
output.ActiveMineLimit = skillModList:Sum("BASE", skillCfg, "ActiveMineLimit")
local areaMod = calcLib.mod(skillModList, skillCfg, "MineDetonationAreaOfEffect")
output.MineDetonationRadius = 60 * m_sqrt(areaMod)
if breakdown then
breakdown.MineDetonationRadius = breakdown.area(60, areaMod, output.MineDetonationRadius)
end
if activeSkill.skillTypes[SkillType.Aura] then
output.MineAuraRadius = 35 * m_sqrt(output.AreaOfEffectMod)
if breakdown then
breakdown.MineAuraRadius = breakdown.area(35, output.AreaOfEffectMod, output.MineAuraRadius)
end
end
end
if skillFlags.totem then
local baseSpeed = 1 / skillModList:Sum("BASE", skillCfg, "TotemPlacementTime")
output.TotemPlacementSpeed = baseSpeed * calcLib.mod(skillModList, skillCfg, "TotemPlacementSpeed") * output.ActionSpeedMod
output.TotemPlacementTime = 1 / output.TotemPlacementSpeed
if breakdown then
breakdown.TotemPlacementTime = { }
breakdown.multiChain(breakdown.TotemPlacementTime, {
label = "Placement speed:",
base = s_format("%.2f ^8(base placement speed)", baseSpeed),
{ "%.2f ^8(increased/reduced placement speed)", 1 + skillModList:Sum("INC", skillCfg, "TotemPlacementSpeed") / 100 },
{ "%.2f ^8(more/less placement speed)", skillModList:More(skillCfg, "TotemPlacementSpeed") },
{ "%.2f ^8(action speed modifier)", output.ActionSpeedMod },
total = s_format("= %.2f ^8per second", output.TotemPlacementSpeed),
})
end
output.ActiveTotemLimit = skillModList:Sum("BASE", skillCfg, "ActiveTotemLimit")
output.TotemLifeMod = calcLib.mod(skillModList, skillCfg, "TotemLife")
output.TotemLife = round(m_floor(env.data.monsterAllyLifeTable[skillData.totemLevel] * env.data.totemLifeMult[activeSkill.skillTotemId]) * output.TotemLifeMod)
if breakdown then
breakdown.TotemLifeMod = breakdown.mod(skillCfg, "TotemLife")
breakdown.TotemLife = {
"Totem level: "..skillData.totemLevel,
env.data.monsterAllyLifeTable[skillData.totemLevel].." ^8(base life for a level "..skillData.totemLevel.." monster)",
"x "..env.data.totemLifeMult[activeSkill.skillTotemId].." ^8(life multiplier for this totem type)",
"x "..output.TotemLifeMod.." ^8(totem life modifier)",
"= "..output.TotemLife,
}
end
end
-- Skill duration
local debuffDurationMult
if env.mode_effective then
debuffDurationMult = 1 / calcLib.mod(enemyDB, skillCfg, "BuffExpireFaster")
else
debuffDurationMult = 1
end
do
output.DurationMod = calcLib.mod(skillModList, skillCfg, "Duration", "PrimaryDuration", "SkillAndDamagingAilmentDuration", skillData.mineDurationAppliesToSkill and "MineDuration" or nil)
if breakdown then
breakdown.DurationMod = breakdown.mod(skillCfg, "Duration", "PrimaryDuration", "SkillAndDamagingAilmentDuration", skillData.mineDurationAppliesToSkill and "MineDuration" or nil)
end
local durationBase = (skillData.duration or 0) + skillModList:Sum("BASE", skillCfg, "Duration", "PrimaryDuration")
if durationBase > 0 then
output.Duration = durationBase * output.DurationMod
if skillData.debuff then
output.Duration = output.Duration * debuffDurationMult
end
if breakdown and output.Duration ~= durationBase then
breakdown.Duration = {
s_format("%.2fs ^8(base)", durationBase),
}
if output.DurationMod ~= 1 then
t_insert(breakdown.Duration, s_format("x %.2f ^8(duration modifier)", output.DurationMod))
end
if skillData.debuff and debuffDurationMult ~= 1 then
t_insert(breakdown.Duration, s_format("/ %.2f ^8(debuff expires slower/faster)", 1 / debuffDurationMult))
end
t_insert(breakdown.Duration, s_format("= %.2fs", output.Duration))
end
end
durationBase = (skillData.durationSecondary or 0) + skillModList:Sum("BASE", skillCfg, "Duration", "SecondaryDuration")
if durationBase > 0 then
local durationMod = calcLib.mod(skillModList, skillCfg, "Duration", "SecondaryDuration", "SkillAndDamagingAilmentDuration", skillData.mineDurationAppliesToSkill and "MineDuration" or nil)
output.DurationSecondary = durationBase * durationMod
if skillData.debuffSecondary then
output.DurationSecondary = output.DurationSecondary * debuffDurationMult
end
if breakdown and output.DurationSecondary ~= durationBase then
breakdown.DurationSecondary = {
s_format("%.2fs ^8(base)", durationBase),
}
if output.DurationMod ~= 1 then
t_insert(breakdown.DurationSecondary, s_format("x %.2f ^8(duration modifier)", durationMod))
end
if skillData.debuffSecondary and debuffDurationMult ~= 1 then
t_insert(breakdown.DurationSecondary, s_format("/ %.2f ^8(debuff expires slower/faster)", 1 / debuffDurationMult))
end
t_insert(breakdown.DurationSecondary, s_format("= %.2fs", output.DurationSecondary))
end
end
durationBase = (skillData.auraDuration or 0)
if durationBase > 0 then
local durationMod = calcLib.mod(skillModList, skillCfg, "Duration", "SkillAndDamagingAilmentDuration")
output.AuraDuration = durationBase * durationMod
if breakdown and output.AuraDuration ~= durationBase then
breakdown.AuraDuration = {
s_format("%.2fs ^8(base)", durationBase),
s_format("x %.2f ^8(duration modifier)", durationMod),
s_format("= %.2fs", output.AuraDuration),
}
end
end
durationBase = (skillData.reserveDuration or 0)
if durationBase > 0 then
local durationMod = calcLib.mod(skillModList, skillCfg, "Duration", "SkillAndDamagingAilmentDuration")
output.ReserveDuration = durationBase * durationMod
if breakdown and output.ReserveDuration ~= durationBase then
breakdown.ReserveDuration = {
s_format("%.2fs ^8(base)", durationBase),
s_format("x %.2f ^8(duration modifier)", durationMod),
s_format("= %.2fs", output.ReserveDuration),
}
end
end
end
-- Calculate mana cost (may be slightly off due to rounding differences)
do
local mult = m_floor(skillModList:More(skillCfg, "SupportManaMultiplier") * 100 + 0.0001) / 100
local more = m_floor(skillModList:More(skillCfg, "ManaCost") * 100 + 0.0001) / 100
local inc = skillModList:Sum("INC", skillCfg, "ManaCost")
local base = skillModList:Sum("BASE", skillCfg, "ManaCost")
local manaCost = activeSkill.activeEffect.grantedEffectLevel.manaCost or 0
if skillData.baseManaCostIsAtLeastPercentUnreservedMana then
manaCost = m_max(manaCost, m_floor((output.ManaUnreserved or 0) * skillData.baseManaCostIsAtLeastPercentUnreservedMana / 100))
end
output.ManaCost = m_floor(m_max(0, manaCost * mult * more * (1 + inc / 100) + base))
if activeSkill.skillTypes[SkillType.ManaCostPercent] and skillFlags.totem then
output.ManaCost = m_floor(output.Mana * output.ManaCost / 100)
end
if breakdown and output.ManaCost ~= manaCost then
breakdown.ManaCost = {
s_format("%d ^8(base mana cost)", manaCost)
}
if mult ~= 1 then
t_insert(breakdown.ManaCost, s_format("x %.2f ^8(mana cost multiplier)", mult))
end
if inc ~= 0 then
t_insert(breakdown.ManaCost, s_format("x %.2f ^8(increased/reduced mana cost)", 1 + inc/100))
end
if more ~= 0 then
t_insert(breakdown.ManaCost, s_format("x %.2f ^8(more/less mana cost)", more))
end
if base ~= 0 then
t_insert(breakdown.ManaCost, s_format("- %d ^8(- mana cost)", -base))
end
t_insert(breakdown.ManaCost, s_format("= %d", output.ManaCost))
end
end
runSkillFunc("preDamageFunc")
-- Handle corpse explosions
if skillData.explodeCorpse and skillData.corpseLife then
local damageType = skillData.corpseExplosionDamageType or "Fire"
skillData[damageType.."BonusMin"] = skillData.corpseLife * skillData.corpseExplosionLifeMultiplier
skillData[damageType.."BonusMax"] = skillData.corpseLife * skillData.corpseExplosionLifeMultiplier
end
-- Cache global damage disabling flags
local canDeal = { }
for _, damageType in pairs(dmgTypeList) do
canDeal[damageType] = not skillModList:Flag(skillCfg, "DealNo"..damageType)
end
-- Calculate damage conversion percentages
activeSkill.conversionTable = wipeTable(activeSkill.conversionTable)
for damageTypeIndex = 1, 4 do
local damageType = dmgTypeList[damageTypeIndex]
local globalConv = wipeTable(tempTable1)
local skillConv = wipeTable(tempTable2)
local add = wipeTable(tempTable3)
local globalTotal, skillTotal = 0, 0
for otherTypeIndex = damageTypeIndex + 1, 5 do
-- For all possible destination types, check for global and skill conversions
otherType = dmgTypeList[otherTypeIndex]
globalConv[otherType] = skillModList:Sum("BASE", skillCfg, damageType.."DamageConvertTo"..otherType, isElemental[damageType] and "ElementalDamageConvertTo"..otherType or nil, damageType ~= "Chaos" and "NonChaosDamageConvertTo"..otherType or nil)
globalTotal = globalTotal + globalConv[otherType]
skillConv[otherType] = skillModList:Sum("BASE", skillCfg, "Skill"..damageType.."DamageConvertTo"..otherType)
skillTotal = skillTotal + skillConv[otherType]
add[otherType] = skillModList:Sum("BASE", skillCfg, damageType.."DamageGainAs"..otherType, isElemental[damageType] and "ElementalDamageGainAs"..otherType or nil, damageType ~= "Chaos" and "NonChaosDamageGainAs"..otherType or nil)
end
if skillTotal > 100 then
-- Skill conversion exceeds 100%, scale it down and remove non-skill conversions
local factor = 100 / skillTotal
for type, val in pairs(skillConv) do
-- Overconversion is fixed in 3.0, so I finally get to uncomment this line!
skillConv[type] = val * factor
end
for type, val in pairs(globalConv) do
globalConv[type] = 0
end
elseif globalTotal + skillTotal > 100 then
-- Conversion exceeds 100%, scale down non-skill conversions
local factor = (100 - skillTotal) / globalTotal
for type, val in pairs(globalConv) do
globalConv[type] = val * factor
end
globalTotal = globalTotal * factor
end
local dmgTable = { }
for type, val in pairs(globalConv) do
dmgTable[type] = (globalConv[type] + skillConv[type] + add[type]) / 100
end
dmgTable.mult = 1 - m_min((globalTotal + skillTotal) / 100, 1)
activeSkill.conversionTable[damageType] = dmgTable
end
activeSkill.conversionTable["Chaos"] = { mult = 1 }
-- Configure damage passes
local passList = { }
if isAttack then
output.MainHand = { }
output.OffHand = { }
local critOverride = skillModList:Override(cfg, "WeaponBaseCritChance")
if skillFlags.weapon1Attack then
if breakdown then
breakdown.MainHand = LoadModule(calcs.breakdownModule, skillModList, output.MainHand)
end
activeSkill.weapon1Cfg.skillStats = output.MainHand
local source = copyTable(actor.weaponData1)
if critOverride and source.type and source.type ~= "None" then
source.CritChance = critOverride
end
t_insert(passList, {
label = "Main Hand",
source = source,
cfg = activeSkill.weapon1Cfg,
output = output.MainHand,
breakdown = breakdown and breakdown.MainHand,
})
end
if skillFlags.weapon2Attack then
if breakdown then
breakdown.OffHand = LoadModule(calcs.breakdownModule, skillModList, output.OffHand)
end
activeSkill.weapon2Cfg.skillStats = output.OffHand
local source = copyTable(actor.weaponData2)
if critOverride and source.type and source.type ~= "None" then
source.CritChance = critOverride
end
if skillData.setOffHandBaseCritChance then
source.CritChance = skillData.setOffHandBaseCritChance
end
if skillData.setOffHandPhysicalMin and skillData.setOffHandPhysicalMax then
source.PhysicalMin = skillData.setOffHandPhysicalMin
source.PhysicalMax = skillData.setOffHandPhysicalMax
end
if skillData.setOffHandAttackTime then
source.AttackRate = 1000 / skillData.setOffHandAttackTime
end
t_insert(passList, {
label = "Off Hand",
source = source,
cfg = activeSkill.weapon2Cfg,
output = output.OffHand,
breakdown = breakdown and breakdown.OffHand,
})
end
else
t_insert(passList, {
label = "Skill",
source = skillData,
cfg = skillCfg,
output = output,
breakdown = breakdown,
})
end
local function combineStat(stat, mode, ...)
-- Combine stats from Main Hand and Off Hand according to the mode
if mode == "OR" or not skillFlags.bothWeaponAttack then
output[stat] = output.MainHand[stat] or output.OffHand[stat]
elseif mode == "ADD" then
output[stat] = (output.MainHand[stat] or 0) + (output.OffHand[stat] or 0)
elseif mode == "AVERAGE" then
output[stat] = ((output.MainHand[stat] or 0) + (output.OffHand[stat] or 0)) / 2
elseif mode == "CHANCE" then
if output.MainHand[stat] and output.OffHand[stat] then
local mainChance = output.MainHand[...] * output.MainHand.HitChance
local offChance = output.OffHand[...] * output.OffHand.HitChance
local mainPortion = mainChance / (mainChance + offChance)
local offPortion = offChance / (mainChance + offChance)
output[stat] = output.MainHand[stat] * mainPortion + output.OffHand[stat] * offPortion
if breakdown then
if not breakdown[stat] then
breakdown[stat] = { }
end
t_insert(breakdown[stat], "Contribution from Main Hand:")
t_insert(breakdown[stat], s_format("%.1f", output.MainHand[stat]))
t_insert(breakdown[stat], s_format("x %.3f ^8(portion of instances created by main hand)", mainPortion))
t_insert(breakdown[stat], s_format("= %.1f", output.MainHand[stat] * mainPortion))
t_insert(breakdown[stat], "Contribution from Off Hand:")
t_insert(breakdown[stat], s_format("%.1f", output.OffHand[stat]))
t_insert(breakdown[stat], s_format("x %.3f ^8(portion of instances created by off hand)", offPortion))
t_insert(breakdown[stat], s_format("= %.1f", output.OffHand[stat] * offPortion))
t_insert(breakdown[stat], "Total:")
t_insert(breakdown[stat], s_format("%.1f + %.1f", output.MainHand[stat] * mainPortion, output.OffHand[stat] * offPortion))
t_insert(breakdown[stat], s_format("= %.1f", output[stat]))
end
else
output[stat] = output.MainHand[stat] or output.OffHand[stat]
end
elseif mode == "DPS" then
output[stat] = (output.MainHand[stat] or 0) + (output.OffHand[stat] or 0)
if not skillData.doubleHitsWhenDualWielding then
output[stat] = output[stat] / 2
end
end
end
for _, pass in ipairs(passList) do
local globalOutput, globalBreakdown = output, breakdown
local source, output, cfg, breakdown = pass.source, pass.output, pass.cfg, pass.breakdown
-- Calculate hit chance
output.Accuracy = calcLib.val(skillModList, "Accuracy", cfg)
if breakdown then
breakdown.Accuracy = breakdown.simple(nil, cfg, output.Accuracy, "Accuracy")
end
if not isAttack or skillModList:Flag(cfg, "CannotBeEvaded") or skillData.cannotBeEvaded or (env.mode_effective and enemyDB:Flag(nil, "CannotEvade")) then
output.HitChance = 100
else
local enemyEvasion = round(calcLib.val(enemyDB, "Evasion"))
output.HitChance = calcs.hitChance(enemyEvasion, output.Accuracy)
if breakdown then
breakdown.HitChance = {
"Enemy level: "..env.enemyLevel..(env.configInput.enemyLevel and " ^8(overridden from the Configuration tab" or " ^8(can be overridden in the Configuration tab)"),
"Average enemy evasion: "..enemyEvasion,
"Approximate hit chance: "..output.HitChance.."%",
}
end
end
-- Calculate attack/cast speed
if activeSkill.activeEffect.grantedEffect.castTime == 0 and not skillData.castTimeOverride then
output.Time = 0
output.Speed = 0
elseif skillData.timeOverride then
output.Time = skillData.timeOverride
output.Speed = 1 / output.Time
elseif skillData.fixedCastTime then
output.Time = activeSkill.activeEffect.grantedEffect.castTime
output.Speed = 1 / output.Time
else
local baseTime
if isAttack then
if skillData.castTimeOverridesAttackTime then
-- Skill is overriding weapon attack speed
baseTime = activeSkill.activeEffect.grantedEffect.castTime / (1 + (source.AttackSpeedInc or 0) / 100)
else
baseTime = 1 / ( source.AttackRate or 1 ) + skillModList:Sum("BASE", cfg, "Speed")
end
else
baseTime = skillData.castTimeOverride or activeSkill.activeEffect.grantedEffect.castTime or 1
end
local inc = skillModList:Sum("INC", cfg, "Speed")
local more = skillModList:More(cfg, "Speed")
output.Speed = 1 / baseTime * round((1 + inc/100) * more, 2)
if skillData.attackRateCap then
output.Speed = m_min(output.Speed, skillData.attackRateCap)
end
if skillFlags.selfCast then
-- Self-cast skill; apply action speed
output.Speed = output.Speed * globalOutput.ActionSpeedMod
end
if breakdown then
breakdown.Speed = { }
breakdown.multiChain(breakdown.Speed, {
base = s_format("%.2f ^8(base)", 1 / baseTime),
{ "%.2f ^8(increased/reduced)", 1 + inc/100 },
{ "%.2f ^8(more/less)", more },
{ "%.2f ^8(action speed modifier)", skillFlags.selfCast and globalOutput.ActionSpeedMod or 1 },
total = s_format("= %.2f ^8per second", output.Speed)
})
end
if output.Speed == 0 then
output.Time = 0
else
output.Time = 1 / output.Speed
end
end
if skillData.hitTimeOverride then
output.HitTime = skillData.hitTimeOverride
output.HitSpeed = 1 / output.HitTime
end
end
if isAttack then
-- Combine hit chance and attack speed
combineStat("HitChance", "AVERAGE")
combineStat("Speed", "AVERAGE")
combineStat("HitSpeed", "OR")
if output.Speed == 0 then
output.Time = 0
else
output.Time = 1 / output.Speed
end
if skillFlags.bothWeaponAttack then
if breakdown then
breakdown.Speed = {
"Both weapons:",
s_format("(%.2f + %.2f) / 2", output.MainHand.Speed, output.OffHand.Speed),
s_format("= %.2f", output.Speed),
}
end
end
end
for _, pass in ipairs(passList) do
local globalOutput, globalBreakdown = output, breakdown
local source, output, cfg, breakdown = pass.source, pass.output, pass.cfg, pass.breakdown
-- Calculate crit chance, crit multiplier, and their combined effect
if skillModList:Flag(nil, "NeverCrit") then
output.PreEffectiveCritChance = 0
output.CritChance = 0
output.CritMultiplier = 0
output.BonusCritDotMultiplier = 0
output.CritEffect = 1
else
local baseCrit = source.CritChance or 0
if baseCrit == 100 then
output.PreEffectiveCritChance = 100
output.CritChance = 100
else
local base = skillModList:Sum("BASE", cfg, "CritChance") + (env.mode_effective and enemyDB:Sum("BASE", nil, "SelfCritChance") or 0)
local inc = skillModList:Sum("INC", cfg, "CritChance") + (env.mode_effective and enemyDB:Sum("INC", nil, "SelfCritChance") or 0)
local more = skillModList:More(cfg, "CritChance")
output.CritChance = (baseCrit + base) * (1 + inc / 100) * more
local preCapCritChance = output.CritChance
output.CritChance = m_min(output.CritChance, 100)
if (baseCrit + base) > 0 then
output.CritChance = m_max(output.CritChance, 0)
end
output.PreEffectiveCritChance = output.CritChance
local preLuckyCritChance = output.CritChance
if env.mode_effective and skillModList:Flag(cfg, "CritChanceLucky") then
output.CritChance = (1 - (1 - output.CritChance / 100) ^ 2) * 100
end
local preHitCheckCritChance = output.CritChance
if env.mode_effective then
output.CritChance = output.CritChance * output.HitChance / 100
end
if breakdown and output.CritChance ~= baseCrit then
breakdown.CritChance = { }
if base ~= 0 then
t_insert(breakdown.CritChance, s_format("(%g + %g) ^8(base)", baseCrit, base))
else
t_insert(breakdown.CritChance, s_format("%g ^8(base)", baseCrit + base))
end
if inc ~= 0 then
t_insert(breakdown.CritChance, s_format("x %.2f", 1 + inc/100).." ^8(increased/reduced)")
end
if more ~= 1 then
t_insert(breakdown.CritChance, s_format("x %.2f", more).." ^8(more/less)")
end
t_insert(breakdown.CritChance, s_format("= %.2f%% ^8(crit chance)", output.PreEffectiveCritChance))
if preCapCritChance > 100 then
local overCap = preCapCritChance - 100
t_insert(breakdown.CritChance, s_format("Crit is overcapped by %.2f%% (%d%% increased Critical Strike Chance)", overCap, overCap / more / (baseCrit + base) * 100))
end
if env.mode_effective and skillModList:Flag(cfg, "CritChanceLucky") then
t_insert(breakdown.CritChance, "Crit Chance is Lucky:")
t_insert(breakdown.CritChance, s_format("1 - (1 - %.4f) x (1 - %.4f)", preLuckyCritChance / 100, preLuckyCritChance / 100))
t_insert(breakdown.CritChance, s_format("= %.2f%%", preHitCheckCritChance))
end
if env.mode_effective and output.HitChance < 100 then
t_insert(breakdown.CritChance, "Crit confirmation roll:")
t_insert(breakdown.CritChance, s_format("%.2f%%", preHitCheckCritChance))
t_insert(breakdown.CritChance, s_format("x %.2f ^8(chance to hit)", output.HitChance / 100))
t_insert(breakdown.CritChance, s_format("= %.2f%%", output.CritChance))
end
end
end
if skillModList:Flag(cfg, "NoCritMultiplier") then
output.CritMultiplier = 1
else
local extraDamage = skillModList:Sum("BASE", cfg, "CritMultiplier") / 100
local multiOverride = skillModList:Override(skillCfg, "CritMultiplier")
if multiOverride then
extraDamage = (multiOverride - 100) / 100
end
if env.mode_effective then
local enemyInc = 1 + enemyDB:Sum("INC", nil, "SelfCritMultiplier") / 100
extraDamage = round(extraDamage * enemyInc, 2)
if breakdown and enemyInc ~= 1 then
breakdown.CritMultiplier = {
s_format("%d%% ^8(additional extra damage)", skillModList:Sum("BASE", cfg, "CritMultiplier") / 100),
s_format("x %.2f ^8(increased/reduced extra crit damage taken by enemy)", enemyInc),
s_format("= %d%% ^8(extra crit damage)", extraDamage * 100),
}
end
end
output.CritMultiplier = 1 + m_max(0, extraDamage)
end
output.CritEffect = 1 - output.CritChance / 100 + output.CritChance / 100 * output.CritMultiplier
output.BonusCritDotMultiplier = (skillModList:Sum("BASE", cfg, "CritMultiplier") - 50) * skillModList:Sum("BASE", cfg, "CritMultiplierAppliesToDegen") / 10000
if breakdown and output.CritEffect ~= 1 then
breakdown.CritEffect = {
s_format("(1 - %.4f) ^8(portion of damage from non-crits)", output.CritChance/100),
s_format("+ (%.4f x %g) ^8(portion of damage from crits)", output.CritChance/100, output.CritMultiplier),
s_format("= %.3f", output.CritEffect),
}
end
end
-- Calculate Double Damage + Ruthless Blow chance/multipliers
output.DoubleDamageChance = m_min(skillModList:Sum("BASE", cfg, "DoubleDamageChance") + (env.mode_effective and enemyDB:Sum("BASE", cfg, "SelfDoubleDamageChance") or 0), 100)
output.DoubleDamageEffect = 1 + output.DoubleDamageChance / 100
output.RuthlessBlowMaxCount = skillModList:Sum("BASE", cfg, "RuthlessBlowMaxCount")
if output.RuthlessBlowMaxCount > 0 then
output.RuthlessBlowChance = round(100 / output.RuthlessBlowMaxCount)
else
output.RuthlessBlowChance = 0
end
output.RuthlessBlowMultiplier = 1 + skillModList:Sum("BASE", cfg, "RuthlessBlowMultiplier") / 100
output.RuthlessBlowEffect = 1 - output.RuthlessBlowChance / 100 + output.RuthlessBlowChance / 100 * output.RuthlessBlowMultiplier
-- Calculate base hit damage
for _, damageType in ipairs(dmgTypeList) do
local damageTypeMin = damageType.."Min"
local damageTypeMax = damageType.."Max"
local baseMultiplier = activeSkill.activeEffect.grantedEffectLevel.baseMultiplier or 1
local damageEffectiveness = activeSkill.activeEffect.grantedEffectLevel.damageEffectiveness or skillData.damageEffectiveness or 1