-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathCalcPerform.lua
3217 lines (3081 loc) · 156 KB
/
CalcPerform.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
-- Path of Building
--
-- Module: Calc Perform
-- Manages the offence/defence calculations.
--
local calcs = ...
local pairs = pairs
local ipairs = ipairs
local t_insert = table.insert
local t_remove = table.remove
local m_min = math.min
local m_max = math.max
local m_ceil = math.ceil
local m_floor = math.floor
local m_modf = math.modf
local s_format = string.format
local m_huge = math.huge
local bor = bit.bor
local band = bit.band
--- getCachedOutputValue
--- retrieves a value specified by key from a cached version of skill
--- specified by @uuid or if not found in cache computes teh cache.
--- @param env table
--- @param activeSkill table active skill to be used as main when calculating output values
--- @param ... table keys to values to be returned (Note: EmmyLua does not natively support documenting variadic parameters)
--- @return table unpacked table containing the desired values
local function getCachedOutputValue(env, activeSkill, ...)
local uuid = cacheSkillUUID(activeSkill, env)
if not GlobalCache.cachedData[env.mode][uuid] or env.mode == "CALCULATOR" then
calcs.buildActiveSkill(env, env.mode, activeSkill, uuid, {[uuid] = true})
end
local tempValues = {}
for i,v in ipairs({...}) do
tempValues[i] = GlobalCache.cachedData[env.mode][uuid].Env.player.output[v]
end
return unpack(tempValues)
end
-- Merge an instance of a buff, taking the highest value of each modifier
local function mergeBuff(src, destTable, destKey)
if not destTable[destKey] then
destTable[destKey] = new("ModList")
end
local dest = destTable[destKey]
for _, mod in ipairs(src) do
local match = false
if mod.type ~= "LIST" then
for index, destMod in ipairs(dest) do
if modLib.compareModParams(mod, destMod) then
if type(destMod.value) == "number" and mod.value > destMod.value then
dest[index] = mod
end
match = true
break
end
end
end
if not match then
t_insert(dest, mod)
end
end
end
-- Merge keystone modifiers
local function mergeKeystones(env)
for _, modObj in ipairs(env.modDB:Tabulate("LIST", nil, "Keystone")) do
if not env.keystonesAdded[modObj.value] and env.spec.tree.keystoneMap[modObj.value] then
env.keystonesAdded[modObj.value] = true
local fromTree = modObj.mod.source and not modObj.mod.source:lower():match("tree")
for _, mod in ipairs(env.spec.tree.keystoneMap[modObj.value].modList) do
env.modDB:AddMod(fromTree and modLib.setSource(mod, modObj.mod.source) or mod)
end
end
end
end
function doActorLifeMana(actor)
local modDB = actor.modDB
local output = actor.output
local breakdown = actor.breakdown
local condList = modDB.conditions
local lowLifePerc = modDB:Sum("BASE", nil, "LowLifePercentage")
output.LowLifePercentage = 100.0 * (lowLifePerc > 0 and lowLifePerc or data.misc.LowPoolThreshold)
local fullLifePerc = modDB:Sum("BASE", nil, "FullLifePercentage")
output.FullLifePercentage = 100.0 * (fullLifePerc > 0 and fullLifePerc or 1.0)
output.ChaosInoculation = modDB:Flag(nil, "ChaosInoculation")
-- Life/mana pools
if output.ChaosInoculation then
output.Life = 1
condList["FullLife"] = true
else
local base = modDB:Sum("BASE", nil, "Life")
local inc = modDB:Sum("INC", nil, "Life")
local more = modDB:More(nil, "Life")
local conv = modDB:Sum("BASE", nil, "LifeConvertToEnergyShield")
output.Life = m_max(round(base * (1 + inc/100) * more * (1 - conv/100)), 1)
if breakdown then
if inc ~= 0 or more ~= 1 or conv ~= 0 then
breakdown.Life = { }
breakdown.Life[1] = s_format("%g ^8(base)", base)
if inc ~= 0 then
t_insert(breakdown.Life, s_format("x %.2f ^8(increased/reduced)", 1 + inc/100))
end
if more ~= 1 then
t_insert(breakdown.Life, s_format("x %.2f ^8(more/less)", more))
end
if conv ~= 0 then
t_insert(breakdown.Life, s_format("x %.2f ^8(converted to Energy Shield)", 1 - conv/100))
end
t_insert(breakdown.Life, s_format("= %g", output.Life))
end
end
end
local manaConv = modDB:Sum("BASE", nil, "ManaConvertToArmour")
output.Mana = round(calcLib.val(modDB, "Mana") * (1 - manaConv / 100))
local base = modDB:Sum("BASE", nil, "Mana")
local inc = modDB:Sum("INC", nil, "Mana")
local more = modDB:More(nil, "Mana")
if breakdown then
if inc ~= 0 or more ~= 1 or manaConv ~= 0 then
breakdown.Mana = { }
breakdown.Mana[1] = s_format("%g ^8(base)", base)
if inc ~= 0 then
t_insert(breakdown.Mana, s_format("x %.2f ^8(increased/reduced)", 1 + inc/100))
end
if more ~= 1 then
t_insert(breakdown.Mana, s_format("x %.2f ^8(more/less)", more))
end
if manaConv ~= 0 then
t_insert(breakdown.Mana, s_format("x %.2f ^8(converted to Armour)", 1 - manaConv/100))
end
t_insert(breakdown.Mana, s_format("= %g", output.Mana))
end
end
output.LowestOfMaximumLifeAndMaximumMana = m_min(output.Life, output.Mana)
end
-- Calculate attributes, and set conditions
---@param env table
---@param actor table
local function doActorAttribsConditions(env, actor)
local modDB = actor.modDB
local output = actor.output
local breakdown = actor.breakdown
local condList = modDB.conditions
-- Set conditions
if (actor.itemList["Weapon 2"] and actor.itemList["Weapon 2"].type == "Shield") or (actor == env.player and env.aegisModList) then
condList["UsingShield"] = true
end
if not actor.itemList["Weapon 2"] then
condList["OffHandIsEmpty"] = true
end
if actor.weaponData1.type == "None" then
condList["Unarmed"] = true
if not actor.itemList["Weapon 2"] and not actor.itemList["Gloves"] then
condList["Unencumbered"] = true
end
else
local info = env.data.weaponTypeInfo[actor.weaponData1.type]
condList["Using"..info.flag] = true
if actor.weaponData1.countsAsAll1H then
actor.weaponData1["AddedUsingAxe"] = not condList["UsingAxe"]
condList["UsingAxe"] = true
actor.weaponData1["AddedUsingSword"] = actor.weaponData1.name:match("Varunastra") or not condList["UsingSword"] --Varunastra is a sword
condList["UsingSword"] = true
actor.weaponData1["AddedUsingDagger"] = not condList["UsingDagger"]
condList["UsingDagger"] = true
actor.weaponData1["AddedUsingMace"] = not condList["UsingMace"]
condList["UsingMace"] = true
actor.weaponData1["AddedUsingClaw"] = not condList["UsingClaw"]
condList["UsingClaw"] = true
-- GGG stated that a single Varunastra satisfied requirement for wielding two different weapons
condList["WieldingDifferentWeaponTypes"] = true
end
if info.melee then
condList["UsingMeleeWeapon"] = true
end
if info.oneHand then
condList["UsingOneHandedWeapon"] = true
else
condList["UsingTwoHandedWeapon"] = true
end
end
local armourSlots = { "Helmet", "Body Armour", "Gloves", "Boots" }
for _, slotName in ipairs(armourSlots) do
if actor.itemList[slotName] then
condList["Using"..slotName] = true
end
end
if actor.weaponData2.type then
local info = env.data.weaponTypeInfo[actor.weaponData2.type]
condList["Using"..info.flag] = true
if actor.weaponData2.countsAsAll1H then
actor.weaponData2["AddedUsingAxe"] = not condList["UsingAxe"]
condList["UsingAxe"] = true
actor.weaponData2["AddedUsingSword"] = actor.weaponData2.name:match("Varunastra") or not condList["UsingSword"] --Varunastra is a sword
condList["UsingSword"] = true
actor.weaponData2["AddedUsingDagger"] = not condList["UsingDagger"]
condList["UsingDagger"] = true
actor.weaponData2["AddedUsingMace"] = not condList["UsingMace"]
condList["UsingMace"] = true
actor.weaponData2["AddedUsingClaw"] = not condList["UsingClaw"]
condList["UsingClaw"] = true
-- GGG stated that a single Varunastra satisfied requirement for wielding two different weapons
condList["WieldingDifferentWeaponTypes"] = true
end
if info.melee then
condList["UsingMeleeWeapon"] = true
end
if info.oneHand then
condList["UsingOneHandedWeapon"] = true
else
condList["UsingTwoHandedWeapon"] = true
end
end
if actor.weaponData1.type and actor.weaponData2.type then
condList["DualWielding"] = true
if (actor.weaponData1.type == "Claw" or actor.weaponData1.countsAsAll1H) and (actor.weaponData2.type == "Claw" or actor.weaponData2.countsAsAll1H) then
condList["DualWieldingClaws"] = true
end
if (actor.weaponData1.type == "Dagger" or actor.weaponData1.countsAsAll1H) and (actor.weaponData2.type == "Dagger" or actor.weaponData2.countsAsAll1H) then
condList["DualWieldingDaggers"] = true
end
if (env.data.weaponTypeInfo[actor.weaponData1.type].label or actor.weaponData1.type) ~= (env.data.weaponTypeInfo[actor.weaponData2.type].label or actor.weaponData2.type) then
local info1 = env.data.weaponTypeInfo[actor.weaponData1.type]
local info2 = env.data.weaponTypeInfo[actor.weaponData2.type]
if info1.oneHand and info2.oneHand then
condList["WieldingDifferentWeaponTypes"] = true
end
end
end
if env.mode_combat then
if not modDB:Flag(env.player.mainSkill.skillCfg, "NeverCrit") then
condList["CritInPast8Sec"] = true
end
if not actor.mainSkill.skillData.triggered and not actor.mainSkill.skillFlags.trap and not actor.mainSkill.skillFlags.mine and not actor.mainSkill.skillFlags.totem then
if actor.mainSkill.skillFlags.attack then
condList["AttackedRecently"] = true
elseif actor.mainSkill.skillFlags.spell then
condList["CastSpellRecently"] = true
end
if actor.mainSkill.skillTypes[SkillType.Movement] then
condList["UsedMovementSkillRecently"] = true
end
if actor.mainSkill.skillFlags.minion and not actor.mainSkill.skillFlags.permanentMinion then
condList["UsedMinionSkillRecently"] = true
end
if actor.mainSkill.skillTypes[SkillType.Vaal] then
condList["UsedVaalSkillRecently"] = true
end
if actor.mainSkill.skillTypes[SkillType.Channel] then
condList["Channelling"] = true
end
end
if actor.mainSkill.skillFlags.hit and not actor.mainSkill.skillFlags.trap and not actor.mainSkill.skillFlags.mine and not actor.mainSkill.skillFlags.totem then
condList["HitRecently"] = true
if actor.mainSkill.skillFlags.spell then
condList["HitSpellRecently"] = true
end
end
if actor.mainSkill.skillFlags.totem then
condList["HaveTotem"] = true
condList["SummonedTotemRecently"] = true
if actor.mainSkill.skillFlags.hit then
condList["TotemsHitRecently"] = true
if actor.mainSkill.skillFlags.spell then
condList["TotemsSpellHitRecently"] = true
end
end
end
if actor.mainSkill.skillFlags.mine then
condList["DetonatedMinesRecently"] = true
end
if actor.mainSkill.skillFlags.trap then
condList["TriggeredTrapsRecently"] = true
end
if modDB:Sum("BASE", nil, "EnemyScorchChance") > 0 or modDB:Flag(nil, "CritAlwaysAltAilments") and not modDB:Flag(env.player.mainSkill.skillCfg, "NeverCrit") or modDB:Flag(nil, "IgniteCanScorch") then
condList["CanInflictScorch"] = true
end
if modDB:Sum("BASE", nil, "EnemyBrittleChance") > 0 or modDB:Flag(nil, "CritAlwaysAltAilments") and not modDB:Flag(env.player.mainSkill.skillCfg, "NeverCrit") then
condList["CanInflictBrittle"] = true
end
if modDB:Sum("BASE", nil, "EnemySapChance") > 0 or modDB:Flag(nil, "CritAlwaysAltAilments") and not modDB:Flag(env.player.mainSkill.skillCfg, "NeverCrit") then
condList["CanInflictSap"] = true
end
-- Shrine Buffs: Must be done before life pool calculated for massive shrine
local shrineEffectMod = 1 + modDB:Sum("INC", nil, "BuffEffectOnSelf", "ShrineBuffEffect") / 100
if modDB:Flag(nil, "LesserMassiveShrine") then
modDB:NewMod("Life", "INC", m_floor(20 * shrineEffectMod), "Lesser Massive Shrine")
modDB:NewMod("AreaOfEffect", "INC", m_floor(20 * shrineEffectMod), "Lesser Massive Shrine")
end
if modDB:Flag(nil, "LesserBrutalShrine") then
modDB:NewMod("Damage", "INC", m_floor(20 * shrineEffectMod), "Lesser Brutal Shrine")
modDB:NewMod("EnemyStunDuration", "INC", m_floor(20 * shrineEffectMod), "Lesser Brutal Shrine")
modDB:NewMod("EnemyKnockbackChance", "INC", 100, "Lesser Brutal Shrine")
end
if modDB:Flag(nil, "DiamondShrine") then
modDB:NewMod("CritChance", "OVERRIDE", 100, "Diamond Shrine")
end
if modDB:Flag(nil, "MassiveShrine") then
modDB:NewMod("Life", "INC", m_floor(40 * shrineEffectMod), "Massive Shrine")
modDB:NewMod("AreaOfEffect", "INC", m_floor(40 * shrineEffectMod), "Massive Shrine")
end
end
if env.mode_effective then
if env.player.mainSkill.skillModList:Sum("BASE", env.player.mainSkill.skillCfg, "FireExposureChance") > 0 or modDB:Sum("BASE", nil, "FireExposureChance") > 0 then
condList["CanApplyFireExposure"] = true
end
if env.player.mainSkill.skillModList:Sum("BASE", env.player.mainSkill.skillCfg, "ColdExposureChance") > 0 or modDB:Sum("BASE", nil, "ColdExposureChance") > 0 then
condList["CanApplyColdExposure"] = true
end
if env.player.mainSkill.skillModList:Sum("BASE", env.player.mainSkill.skillCfg, "LightningExposureChance") > 0 or modDB:Sum("BASE", nil, "LightningExposureChance") > 0 then
condList["CanApplyLightningExposure"] = true
end
end
-- Calculate attributes
local calculateAttributes = function()
for pass = 1, 2 do -- Calculate twice because of circular dependency (X attribute higher than Y attribute)
for _, stat in pairs({"Str","Dex","Int"}) do
output[stat] = m_max(round(calcLib.val(modDB, stat)), 0)
if breakdown then
breakdown[stat] = breakdown.simple(nil, nil, output[stat], stat)
end
end
local stats = { output.Str, output.Dex, output.Int }
table.sort(stats)
output.LowestAttribute = stats[1]
condList["TwoHighestAttributesEqual"] = stats[2] == stats[3]
condList["DexHigherThanInt"] = output.Dex > output.Int
condList["StrHigherThanInt"] = output.Str > output.Int
condList["IntHigherThanDex"] = output.Int > output.Dex
condList["StrHigherThanDex"] = output.Str > output.Dex
condList["IntHigherThanStr"] = output.Int > output.Str
condList["DexHigherThanStr"] = output.Dex > output.Str
condList["StrHighestAttribute"] = output.Str >= output.Dex and output.Str >= output.Int
condList["IntHighestAttribute"] = output.Int >= output.Str and output.Int >= output.Dex
condList["DexHighestAttribute"] = output.Dex >= output.Str and output.Dex >= output.Int
end
end
local calculateOmniscience = function (convert)
local classStats = env.spec.tree.characterData and env.spec.tree.characterData[env.classId] or env.spec.tree.classes[env.classId]
for pass = 1, 2 do -- Calculate twice because of circular dependency (X attribute higher than Y attribute)
if pass ~= 1 then
for _, stat in pairs({"Str","Dex","Int"}) do
local base = classStats["base_"..stat:lower()]
output[stat] = m_min(round(calcLib.val(modDB, stat)), base)
if breakdown then
breakdown[stat] = breakdown.simple(nil, nil, output[stat], stat)
end
modDB:NewMod("Omni", "BASE", (modDB:Sum("BASE", nil, stat) - base), stat.." conversion Omniscience")
modDB:NewMod("Omni", "INC", modDB:Sum("INC", nil, stat), "Omniscience")
modDB:NewMod("Omni", "MORE", modDB:Sum("MORE", nil, stat), "Omniscience")
end
end
if pass ~= 2 then
-- Subtract out double and triple dips
local conversion = { }
local reduction = { }
for _, type in pairs({"BASE", "INC", "MORE"}) do
conversion[type] = { }
for _, stat in pairs({"StrDex", "StrInt", "DexInt", "All"}) do
conversion[type][stat] = modDB:Sum(type, nil, stat) or 0
end
reduction[type] = conversion[type].StrDex + conversion[type].StrInt + conversion[type].DexInt + 2*conversion[type].All
end
modDB:NewMod("Omni", "BASE", -reduction["BASE"], "Reduction from Double/Triple Dipped attributes to Omniscience")
modDB:NewMod("Omni", "INC", -reduction["INC"], "Reduction from Double/Triple Dipped attributes to Omniscience")
modDB:NewMod("Omni", "MORE", -reduction["MORE"], "Reduction from Double/Triple Dipped attributes to Omniscience")
end
for _, stat in pairs({"Str","Dex","Int"}) do
local base = classStats["base_"..stat:lower()]
output[stat] = base
end
output["Omni"] = m_max(round(calcLib.val(modDB, "Omni")), 0)
if breakdown then
breakdown["Omni"] = breakdown.simple(nil, nil, output["Omni"], "Omni")
end
local stats = { output.Str, output.Dex, output.Int }
table.sort(stats)
output.LowestAttribute = stats[1]
condList["TwoHighestAttributesEqual"] = stats[2] == stats[3]
condList["DexHigherThanInt"] = output.Dex > output.Int
condList["StrHigherThanInt"] = output.Str > output.Int
condList["IntHigherThanDex"] = output.Int > output.Dex
condList["StrHigherThanDex"] = output.Str > output.Dex
condList["IntHigherThanStr"] = output.Int > output.Str
condList["DexHigherThanStr"] = output.Dex > output.Str
condList["StrHighestAttribute"] = output.Str >= output.Dex and output.Str >= output.Int
condList["IntHighestAttribute"] = output.Int >= output.Str and output.Int >= output.Dex
condList["DexHighestAttribute"] = output.Dex >= output.Str and output.Dex >= output.Int
end
end
if modDB:Flag(nil, "Omniscience") then
calculateOmniscience()
else
calculateAttributes()
end
-- Calculate total attributes
output.TotalAttr = output.Str + output.Dex + output.Int
-- Special case for Devotion
output.Devotion = modDB:Sum("BASE", nil, "Devotion")
-- Add attribute bonuses
if not modDB:Flag(nil, "NoAttributeBonuses") then
if not modDB:Flag(nil, "NoStrengthAttributeBonuses") then
if not modDB:Flag(nil, "NoStrBonusToLife") then
modDB:NewMod("Life", "BASE", m_floor(output.Str / 2), "Strength")
end
local strDmgBonusRatioOverride = modDB:Sum("BASE", nil, "StrDmgBonusRatioOverride")
if strDmgBonusRatioOverride > 0 then
actor.strDmgBonus = m_floor((output.Str + modDB:Sum("BASE", nil, "DexIntToMeleeBonus")) * strDmgBonusRatioOverride)
else
actor.strDmgBonus = m_floor((output.Str + modDB:Sum("BASE", nil, "DexIntToMeleeBonus")) / 5)
end
modDB:NewMod("PhysicalDamage", "INC", actor.strDmgBonus, "Strength", ModFlag.Melee)
end
if not modDB:Flag(nil, "NoDexterityAttributeBonuses") then
modDB:NewMod("Accuracy", "BASE", output.Dex * (modDB:Override(nil, "DexAccBonusOverride") or data.misc.AccuracyPerDexBase), "Dexterity")
if not modDB:Flag(nil, "NoDexBonusToEvasion") then
modDB:NewMod("Evasion", "INC", m_floor(output.Dex / 5), "Dexterity")
end
end
if not modDB:Flag(nil, "NoIntelligenceAttributeBonuses") then
if not modDB:Flag(nil, "NoIntBonusToMana") then
modDB:NewMod("Mana", "BASE", m_floor(output.Int / 2), "Intelligence")
end
if not modDB:Flag(nil, "NoIntBonusToES") then
modDB:NewMod("EnergyShield", "INC", m_floor(output.Int / 5), "Intelligence")
end
end
end
doActorLifeMana(actor)
end
-- Calculate life/mana reservation
---@param actor table
function doActorLifeManaReservation(actor)
local modDB = actor.modDB
local output = actor.output
local condList = modDB.conditions
for _, pool in pairs({"Life", "Mana"}) do
local max = output[pool]
local reserved
if max > 0 then
local lowPerc = modDB:Sum("BASE", nil, "Low" .. pool .. "Percentage")
reserved = (actor["reserved_"..pool.."Base"] or 0) + m_ceil(max * (actor["reserved_"..pool.."Percent"] or 0) / 100)
uncancellableReservation = actor["uncancellable_"..pool.."Reservation"] or 0
output[pool.."Reserved"] = m_min(reserved, max)
output[pool.."ReservedPercent"] = m_min(reserved / max * 100, 100)
output[pool.."Unreserved"] = max - reserved
output[pool.."UnreservedPercent"] = (max - reserved) / max * 100
output[pool.."UncancellableReservation"] = m_min(uncancellableReservation, 0)
output[pool.."CancellableReservation"] = 100 - uncancellableReservation
if (max - reserved) / max <= (lowPerc > 0 and lowPerc or data.misc.LowPoolThreshold) then
condList["Low"..pool] = true
end
else
reserved = 0
end
for _, value in ipairs(modDB:List(nil, "GrantReserved"..pool.."AsAura")) do
local auraMod = copyTable(value.mod)
auraMod.value = m_floor(auraMod.value * m_min(reserved, max))
modDB:NewMod("ExtraAura", "LIST", { mod = auraMod })
end
end
end
-- Helper function to determine curse priority when processing curses beyond the curse limit
local function determineCursePriority(curseName, activeSkill)
local curseName = curseName or ""
local source = ""
local slot = ""
local socket = 1
if activeSkill and activeSkill.socketGroup then
source = activeSkill.socketGroup.source or ""
slot = activeSkill.socketGroup.slot or ""
for k, v in ipairs(activeSkill.socketGroup.gemList) do
if v.gemData and v.gemData.name == curseName then
-- We need to enforce a limit of 8 here to avoid collision with data.cursePriority["CurseFromEquipment"]
socket = m_min(k, 8)
break
end
end
end
local basePriority = data.cursePriority[curseName] or 0
local socketPriority = socket * data.cursePriority["SocketPriorityBase"]
local slotPriority = data.cursePriority[slot:gsub(" (Swap)", "")] or 0
local sourcePriority = 0
if activeSkill and activeSkill.skillTypes and activeSkill.skillTypes[SkillType.Aura] then
sourcePriority = data.cursePriority["CurseFromAura"]
elseif source ~= "" then
sourcePriority = data.cursePriority["CurseFromEquipment"]
end
if source ~= "" and slotPriority == data.cursePriority["Ring 2"] then
-- Implicit and explicit curses from rings have equal priority; only curses from socketed skill gems care about which ring slot they're equipped in
slotPriority = data.cursePriority["Ring 1"]
end
return basePriority + socketPriority + slotPriority + sourcePriority
end
-- Process enemy modifiers and other buffs
local function doActorMisc(env, actor)
local modDB = actor.modDB
local enemyDB = actor.enemy.modDB
local output = actor.output
local condList = modDB.conditions
-- Process enemy modifiers
for _, value in ipairs(modDB:Tabulate(nil, nil, "EnemyModifier")) do
enemyDB:AddMod(modLib.setSource(value.value.mod, value.value.mod.source or value.mod.source))
end
-- Add misc buffs/debuffs
if env.mode_combat then
if env.player.mainSkill.baseSkillModList:Flag(nil, "Cruelty") then
modDB.multipliers["Cruelty"] = modDB:Override(nil, "Cruelty") or 40
end
-- Minimum Rage
if modDB:Sum("BASE", nil, "MinimumRage") > (modDB.multipliers["Rage"] or 0) then
modDB.multipliers["Rage"] = modDB:Sum("BASE", nil, "MinimumRage")
end
local alliedFortify = modDB:Flag(nil, "YourFortifyEqualToParent") and actor.parent.output.FortificationStacks or env.partyMembers and env.partyMembers.modDB:Flag(nil, "PartyMemberFortifyEqualToYours") and env.partyMembers.output.FortificationStacks or 0
-- Minimum Fortification from King Maker or Perfect Naval Officer spectres or Ally override
if modDB:Sum("BASE", nil, "MinimumFortification") > 0 or alliedFortify > 0 then
condList["Fortified"] = true
end
-- Fortify
if modDB:Flag(nil, "Fortified") or modDB:Sum("BASE", nil, "Multiplier:Fortification") > 0 then
local maxStacks = modDB:Override(nil, "MaximumFortification") or modDB:Sum("BASE", skillCfg, "MaximumFortification")
local minStacks = m_min(modDB:Sum("BASE", nil, "MinimumFortification"), maxStacks)
local stacks = modDB:Override(nil, "FortificationStacks") or (alliedFortify > 0 and alliedFortify) or (minStacks > 0 and minStacks) or maxStacks
output.FortificationStacks = stacks
if not modDB:Flag(nil,"Condition:NoFortificationMitigation") then
local effectScale = 1 + modDB:Sum("INC", nil, "BuffEffectOnSelf") / 100
local effect = m_floor(effectScale * stacks)
modDB:NewMod("DamageTakenWhenHit", "MORE", -effect, "Fortification")
end
if stacks >= maxStacks then
modDB:NewMod("Condition:HaveMaximumFortification", "FLAG", true, "")
end
modDB.multipliers["BuffOnSelf"] = (modDB.multipliers["BuffOnSelf"] or 0) + 1
end
if modDB:Flag(nil, "Onslaught") then
local effect
--Loop detects if a Silver flask is used to grant Onslaught. If statement adds flask effect to calculation if one is being used
local onslaughtFromFlask
--This value is set to negative and not 0 or else reduced effect would not properly apply
local flaskEffectInc = -100
for item in pairs(env.flasks) do
if item.baseName:match("Silver Flask") then
onslaughtFromFlask = true
local curFlaskEffectInc = item.flaskData.effectInc + modDB:Sum("INC", { actor = "player" }, "FlaskEffect")
if item.rarity == "MAGIC" then
curFlaskEffectInc = curFlaskEffectInc + modDB:Sum("INC", { actor = "player" }, "MagicUtilityFlaskEffect")
end
if flaskEffectInc < curFlaskEffectInc / 100 then
flaskEffectInc = curFlaskEffectInc / 100
end
end
end
local onslaughtEffectInc = modDB:Sum("INC", nil, "OnslaughtEffect", "BuffEffectOnSelf") / 100
if onslaughtFromFlask then
effect = m_floor(20 * (1 + flaskEffectInc + onslaughtEffectInc))
else
effect = m_floor(20 * (1 + onslaughtEffectInc))
end
modDB:NewMod("Speed", "INC", effect, "Onslaught", ModFlag.Attack)
modDB:NewMod("Speed", "INC", effect, "Onslaught", ModFlag.Cast)
modDB:NewMod("MovementSpeed", "INC", effect, "Onslaught")
end
if modDB.conditions["AffectedByArcaneSurge"] or modDB:Flag(nil, "Condition:ArcaneSurge") then
modDB.conditions["AffectedByArcaneSurge"] = true
local effect = 1 + modDB:Sum("INC", nil, "ArcaneSurgeEffect", "BuffEffectOnSelf") / 100
modDB:NewMod("ManaRegen", "INC", (modDB:Max(nil, "ArcaneSurgeManaRegen") or 30) * effect, "Arcane Surge")
modDB:NewMod("Speed", "INC", (modDB:Max(nil, "ArcaneSurgeCastSpeed") or 10) * effect, "Arcane Surge", ModFlag.Cast)
local arcaneSurgeDamage = modDB:Max(nil, "ArcaneSurgeDamage") or 0
if arcaneSurgeDamage ~= 0 then modDB:NewMod("Damage", "MORE", arcaneSurgeDamage * effect, "Arcane Surge", ModFlag.Spell) end
end
if modDB:Flag(nil, "Fanaticism") and actor.mainSkill and actor.mainSkill.skillFlags.selfCast then
local effect = m_floor(75 * (1 + modDB:Sum("INC", nil, "BuffEffectOnSelf") / 100))
modDB:NewMod("Speed", "MORE", effect, "Fanaticism", ModFlag.Cast)
modDB:NewMod("Cost", "INC", -effect, "Fanaticism", ModFlag.Cast)
modDB:NewMod("AreaOfEffect", "INC", effect, "Fanaticism", ModFlag.Cast)
end
if modDB:Flag(nil, "UnholyMight") then
local effect = 1 + modDB:Sum("INC", nil, "BuffEffectOnSelf") / 100
modDB:NewMod("PhysicalDamageConvertToChaos", "BASE", m_floor(100 * effect), "Unholy Might")
modDB:NewMod("Condition:CanWither", "FLAG", true, "Unholy Might")
end
if modDB:Flag(nil, "ChaoticMight") then
local effect = m_floor(30 * (1 + modDB:Sum("INC", nil, "BuffEffectOnSelf") / 100))
modDB:NewMod("PhysicalDamageGainAsChaos", "BASE", effect, "Chaotic Might")
end
if modDB:Flag(nil, "Tailwind") then
local effect = m_floor(8 * (1 + modDB:Sum("INC", nil, "TailwindEffectOnSelf", "BuffEffectOnSelf") / 100))
modDB:NewMod("ActionSpeed", "INC", effect, "Tailwind")
end
if modDB:Flag(nil, "Condition:TotemTailwind") then
modDB:NewMod("TotemActionSpeed", "INC", 8, "Tailwind")
end
if modDB:Flag(nil, "Adrenaline") then
local effectMod = 1 + modDB:Sum("INC", nil, "BuffEffectOnSelf") / 100
modDB:NewMod("Damage", "INC", m_floor(100 * effectMod), "Adrenaline")
modDB:NewMod("Speed", "INC", m_floor(25 * effectMod), "Adrenaline", ModFlag.Attack)
modDB:NewMod("Speed", "INC", m_floor(25 * effectMod), "Adrenaline", ModFlag.Cast)
modDB:NewMod("MovementSpeed", "INC", m_floor(25 * effectMod), "Adrenaline")
modDB:NewMod("PhysicalDamageReduction", "BASE", m_floor(10 * effectMod), "Adrenaline")
end
if modDB:Flag(nil, "Convergence") then
local effect = m_floor(30 * (1 + modDB:Sum("INC", nil, "BuffEffectOnSelf") / 100))
modDB:NewMod("ElementalDamage", "MORE", effect, "Convergence")
end
if modDB:Flag(nil, "HerEmbrace") then
condList["HerEmbrace"] = true
modDB:NewMod("AvoidStun", "BASE", 100, "Her Embrace")
modDB:NewMod("PhysicalDamageGainAsFire", "BASE", 123, "Her Embrace", ModFlag.Sword)
modDB:NewMod("AvoidFreeze", "BASE", 100, "Her Embrace")
modDB:NewMod("AvoidChill", "BASE", 100, "Her Embrace")
modDB:NewMod("AvoidIgnite", "BASE", 100, "Her Embrace")
modDB:NewMod("Speed", "INC", 20, "Her Embrace", ModFlag.Attack)
modDB:NewMod("Speed", "INC", 20, "Her Embrace", ModFlag.Cast)
modDB:NewMod("MovementSpeed", "INC", 20, "Her Embrace")
end
if modDB:Flag(nil, "Condition:PhantasmalMight") then
modDB.multipliers["BuffOnSelf"] = (modDB.multipliers["BuffOnSelf"] or 0) + (output.ActivePhantasmLimit or 1) - 1 -- slight hack to not double count the initial buff
end
if modDB:Flag(nil, "Elusive") then
local maxSkillInc = modDB:Max({ source = "Skill" }, "ElusiveEffect") or 0
local inc = modDB:Sum("INC", nil, "ElusiveEffect", "BuffEffectOnSelf")
if actor.mainSkill.skillModList:Flag(nil, "SupportedByNightblade") then
inc = inc + modDB:Sum("INC", nil, "NightbladeSupportedElusiveEffect")
end
inc = inc + maxSkillInc
local elusiveEffectMod = (1 + inc / 100) * modDB:More(nil, "ElusiveEffect", "BuffEffectOnSelf") * 100
output.ElusiveEffectMod = (elusiveEffectMod + (modDB:Override(nil, "ElusiveEffectMinThreshold") or 0)) / 2
-- if we want the max skill to not be noted as its own breakdown table entry, comment out below
modDB:NewMod("ElusiveEffect", "INC", maxSkillInc, "Max Skill Effect")
-- Override elusive effect if set.
if modDB:Override(nil, "ElusiveEffect") then
output.ElusiveEffectMod = m_min(modDB:Override(nil, "ElusiveEffect"), elusiveEffectMod)
end
local effect = output.ElusiveEffectMod / 100
condList["Elusive"] = true
modDB:NewMod("AvoidAllDamageFromHitsChance", "BASE", m_floor(15 * effect), "Elusive")
modDB:NewMod("MovementSpeed", "INC", m_floor(30 * effect), "Elusive")
end
if modDB:Max(nil, "WitherEffectStack") then
modDB:NewMod("Condition:CanWither", "FLAG", true, "Config")
local effect = modDB:Max(nil, "WitherEffectStack")
enemyDB:NewMod("ChaosDamageTaken", "INC", effect, "Withered", { type = "Multiplier", var = "WitheredStack", limit = 15 } )
end
if modDB:Flag(nil, "Condition:CanBeWithered") then
local effect = 6 * (100 + modDB:Sum("INC", nil, "WitherEffectOnSelf")) / 100 * modDB:More(nil, "WitherEffectOnSelf")
modDB:NewMod("ChaosDamageTaken", "INC", effect, "Withered", { type = "Multiplier", var = "WitheredStack", limit = 15 } )
end
if modDB:Flag(nil, "Blind") and not modDB:Flag(nil, "CannotBeBlinded") then
if not modDB:Flag(nil, "IgnoreBlindHitChance") then
local effect = 1 + modDB:Sum("INC", nil, "BlindEffect", "BuffEffectOnSelf") / 100
-- Override Blind effect if set.
if modDB:Override(nil, "BlindEffect") then
effect = m_min(modDB:Override(nil, "BlindEffect") / 100, effect)
end
modDB:NewMod("Accuracy", "MORE", m_floor(-20 * effect), "Blind")
modDB:NewMod("Evasion", "MORE", m_floor(-20 * effect), "Blind")
end
end
if modDB:Flag(nil, "Chill") then
local ailmentData = data.nonDamagingAilment
local chillValue = modDB:Override(nil, "ChillVal") or ailmentData.Chill.default
local chillSelf = (modDB:Flag(nil, "Condition:ChilledSelf") and modDB:Sum("INC", nil, "EnemyChillEffect") / 100) or 0
local totalChillSelfEffect = calcLib.mod(modDB, nil, "SelfChillEffect") + chillSelf
local effect = m_min(m_max(m_floor(chillValue * totalChillSelfEffect), 0), modDB:Override(nil, "ChillMax") or ailmentData.Chill.max)
modDB:NewMod("ActionSpeed", "INC", effect * (modDB:Flag(nil, "SelfChillEffectIsReversed") and 1 or -1), "Chill")
end
if modDB:Flag(nil, "Freeze") then
local effect = m_max(m_floor(70 * calcLib.mod(modDB, nil, "SelfChillEffect")), 0)
modDB:NewMod("ActionSpeed", "INC", -effect, "Freeze")
end
if modDB:Flag(nil, "CanLeechLifeOnFullLife") then
condList["Leeching"] = true
condList["LeechingLife"] = true
end
if modDB:Flag(nil, "CanLeechEnergyShieldOnFullEnergyShield") then
condList["Leeching"] = true
condList["LeechingEnergyShield"] = true
end
if modDB:Flag(nil, "Condition:CanGainRage") or modDB:Sum("BASE", nil, "RageRegen") > 0 then
local maxStacks = modDB:Sum("BASE", skillCfg, "MaximumRage")
local minStacks = m_min(modDB:Sum("BASE", nil, "MinimumRage"), maxStacks)
local rageConfig = modDB:Sum("BASE", nil, "Multiplier:RageStack")
local stacks = m_max(m_min(rageConfig, maxStacks), (minStacks > 0 and minStacks) or 0)
local effect = m_floor(stacks * calcLib.mod(modDB, nil, "RageEffect"))
modDB:NewMod("Multiplier:RageEffect", "BASE", effect, "Base")
output.Rage = stacks
output.MaximumRage = maxStacks
modDB:NewMod("Multiplier:Rage", "BASE", output.Rage, "Base")
if modDB.conditions["RageSpellDamage"] then
modDB:NewMod("Damage", "MORE", effect, "Base", ModFlag.Cast)
else
modDB:NewMod("Damage", "MORE", effect, "Rage", ModFlag.Attack)
end
if stacks == maxStacks then
modDB:NewMod("Condition:HaveMaximumRage", "FLAG", true, "")
end
end
if modDB:Sum("BASE", nil, "CoveredInAshEffect") > 0 then
local effect = modDB:Sum("BASE", nil, "CoveredInAshEffect")
enemyDB:NewMod("FireDamageTaken", "INC", m_min(effect, 20), "Covered in Ash")
end
if modDB:Sum("BASE", nil, "CoveredInFrostEffect") > 0 then
local effect = modDB:Sum("BASE", nil, "CoveredInFrostEffect")
enemyDB:NewMod("ColdDamageTaken", "INC", m_min(effect, 20), "Covered in Frost")
end
if modDB:Flag(nil, "HasMalediction") then
modDB:NewMod("DamageTaken", "INC", 10, "Malediction")
modDB:NewMod("Damage", "INC", -10, "Malediction")
end
if modDB:Flag(nil, "HasMaddeningPresence") then
modDB:NewMod("ActionSpeed", "INC", -10, "Maddening Presence")
modDB:NewMod("Damage", "INC", -10, "Maddening Presence")
end
if modDB:Flag(nil, "HasShapersPresence") then
modDB:NewMod("BuffExpireFaster", "MORE", -20, "Shapers Presence")
end
if modDB:Flag(nil, "Condition:CanHaveSoulEater") then
local max = modDB:Override(nil, "SoulEaterMax") or modDB:Sum("BASE", nil, "SoulEaterMax")
modDB:NewMod("Multiplier:SoulEater", "BASE", 1, "Base", { type = "Multiplier", var = "SoulEaterStack", limit = max })
end
end
end
-- Process charges
local function doActorCharges(env, actor)
local modDB = actor.modDB
local output = actor.output
-- Calculate current and maximum charges
output.PowerChargesMin = m_max(modDB:Sum("BASE", nil, "PowerChargesMin"), 0)
output.PowerChargesMax = m_max(modDB:Sum("BASE", nil, "PowerChargesMax"), 0)
output.PowerChargesDuration = m_floor(modDB:Sum("BASE", nil, "ChargeDuration") * (1 + modDB:Sum("INC", nil, "PowerChargesDuration", "ChargeDuration") / 100))
if modDB:Flag(nil, "MaximumFrenzyChargesIsMaximumPowerCharges") then
local source = modDB.mods["MaximumFrenzyChargesIsMaximumPowerCharges"][1].source
if not modDB:HasMod("OVERRIDE", {source = source:match("[^:]+")}, "FrenzyChargesMax") then
modDB:NewMod("FrenzyChargesMax", "OVERRIDE", output.PowerChargesMax, source)
end
end
output.FrenzyChargesMin = m_max(modDB:Sum("BASE", nil, "FrenzyChargesMin"), 0)
output.FrenzyChargesMax = m_max(modDB:Flag(nil, "MaximumFrenzyChargesIsMaximumPowerCharges") and output.PowerChargesMax or modDB:Sum("BASE", nil, "FrenzyChargesMax"), 0)
output.FrenzyChargesDuration = m_floor(modDB:Sum("BASE", nil, "ChargeDuration") * (1 + modDB:Sum("INC", nil, "FrenzyChargesDuration", "ChargeDuration") / 100))
if modDB:Flag(nil, "MaximumEnduranceChargesIsMaximumFrenzyCharges") then
local source = modDB.mods["MaximumEnduranceChargesIsMaximumFrenzyCharges"][1].source
if not modDB:HasMod("OVERRIDE", {source = source:match("[^:]+")}, "EnduranceChargesMax") then
modDB:NewMod("EnduranceChargesMax", "OVERRIDE", output.FrenzyChargesMax, source)
end
end
output.EnduranceChargesMin = m_max(modDB:Sum("BASE", nil, "EnduranceChargesMin"), 0)
output.EnduranceChargesMax = m_max(env.partyMembers.modDB:Flag(nil, "PartyMemberMaximumEnduranceChargesEqualToYours") and env.partyMembers.output.EnduranceChargesMax or (modDB:Flag(nil, "MaximumEnduranceChargesIsMaximumFrenzyCharges") and output.FrenzyChargesMax or modDB:Sum("BASE", nil, "EnduranceChargesMax")), 0)
output.EnduranceChargesDuration = m_floor(modDB:Sum("BASE", nil, "ChargeDuration") * (1 + modDB:Sum("INC", nil, "EnduranceChargesDuration", "ChargeDuration") / 100))
output.SiphoningChargesMax = m_max(modDB:Sum("BASE", nil, "SiphoningChargesMax"), 0)
output.ChallengerChargesMax = m_max(modDB:Sum("BASE", nil, "ChallengerChargesMax"), 0)
output.BlitzChargesMax = m_max(modDB:Sum("BASE", nil, "BlitzChargesMax"), 0)
output.InspirationChargesMax = m_max(modDB:Sum("BASE", nil, "InspirationChargesMax"), 0)
output.CrabBarriersMax = m_max(modDB:Sum("BASE", nil, "CrabBarriersMax"), 0)
output.BrutalChargesMin = m_max(modDB:Flag(nil, "MinimumEnduranceChargesEqualsMinimumBrutalCharges") and (modDB:Flag(nil, "MinimumEnduranceChargesIsMaximumEnduranceCharges") and output.EnduranceChargesMax or output.EnduranceChargesMin) or 0 , 0)
output.BrutalChargesMax = m_max(modDB:Flag(nil, "MaximumEnduranceChargesEqualsMaximumBrutalCharges") and output.EnduranceChargesMax or 0, 0)
output.AbsorptionChargesMin = m_max(modDB:Flag(nil, "MinimumPowerChargesEqualsMinimumAbsorptionCharges") and (modDB:Flag(nil, "MinimumPowerChargesIsMaximumPowerCharges") and output.PowerChargesMax or output.PowerChargesMin) or 0, 0)
output.AbsorptionChargesMax = m_max(modDB:Flag(nil, "MaximumPowerChargesEqualsMaximumAbsorptionCharges") and output.PowerChargesMax or 0, 0)
output.AfflictionChargesMin = m_max(modDB:Flag(nil, "MinimumFrenzyChargesEqualsMinimumAfflictionCharges") and (modDB:Flag(nil, "MinimumFrenzyChargesIsMaximumFrenzyCharges") and output.FrenzyChargesMax or output.FrenzyChargesMin) or 0, 0)
output.AfflictionChargesMax = m_max(modDB:Flag(nil, "MaximumFrenzyChargesEqualsMaximumAfflictionCharges") and output.FrenzyChargesMax or 0, 0)
output.BloodChargesMax = m_max(modDB:Sum("BASE", nil, "BloodChargesMax"), 0)
output.SpiritChargesMax = m_max(modDB:Sum("BASE", nil, "SpiritChargesMax"), 0)
-- Initialize Charges
output.PowerCharges = 0
output.FrenzyCharges = 0
output.EnduranceCharges = 0
output.SiphoningCharges = 0
output.ChallengerCharges = 0
output.BlitzCharges = 0
output.InspirationCharges = 0
output.GhostShrouds = 0
output.BrutalCharges = 0
output.AbsorptionCharges = 0
output.AfflictionCharges = 0
output.BloodCharges = 0
output.SpiritCharges = 0
-- Conditionally over-write Charge values
if modDB:Flag(nil, "MinimumFrenzyChargesIsMaximumFrenzyCharges") then
output.FrenzyChargesMin = output.FrenzyChargesMax
end
if modDB:Flag(nil, "MinimumEnduranceChargesIsMaximumEnduranceCharges") then
output.EnduranceChargesMin = output.EnduranceChargesMax
end
if modDB:Flag(nil, "MinimumPowerChargesIsMaximumPowerCharges") then
output.PowerChargesMin = output.PowerChargesMax
end
if modDB:Flag(nil, "UsePowerCharges") then
output.PowerCharges = modDB:Override(nil, "PowerCharges") or output.PowerChargesMax
end
if modDB:Flag(nil, "PowerChargesConvertToAbsorptionCharges") then
-- we max with possible Power Charge Override from Config since Absorption Charges won't have their own config entry
-- and are converted from Power Charges
output.AbsorptionCharges = m_max(output.PowerCharges, m_min(output.AbsorptionChargesMax, output.AbsorptionChargesMin))
output.PowerCharges = 0
else
output.PowerCharges = m_max(output.PowerCharges, m_min(output.PowerChargesMax, output.PowerChargesMin))
end
output.RemovablePowerCharges = m_max(output.PowerCharges - output.PowerChargesMin, 0)
if modDB:Flag(nil, "UseFrenzyCharges") then
output.FrenzyCharges = modDB:Override(nil, "FrenzyCharges") or output.FrenzyChargesMax
end
if modDB:Flag(nil, "FrenzyChargesConvertToAfflictionCharges") then
-- we max with possible Power Charge Override from Config since Absorption Charges won't have their own config entry
-- and are converted from Power Charges
output.AfflictionCharges = m_max(output.FrenzyCharges, m_min(output.AfflictionChargesMax, output.AfflictionChargesMin))
output.FrenzyCharges = 0
else
output.FrenzyCharges = m_max(output.FrenzyCharges, m_min(output.FrenzyChargesMax, output.FrenzyChargesMin))
end
output.RemovableFrenzyCharges = m_max(output.FrenzyCharges - output.FrenzyChargesMin, 0)
if modDB:Flag(nil, "UseEnduranceCharges") then
output.EnduranceCharges = modDB:Override(nil, "EnduranceCharges") or output.EnduranceChargesMax
end
if modDB:Flag(nil, "EnduranceChargesConvertToBrutalCharges") then
-- we max with possible Endurance Charge Override from Config since Brutal Charges won't have their own config entry
-- and are converted from Endurance Charges
output.BrutalCharges = m_max(output.EnduranceCharges, m_min(output.BrutalChargesMax, output.BrutalChargesMin))
output.EnduranceCharges = 0
else
output.EnduranceCharges = m_max(output.EnduranceCharges, m_min(output.EnduranceChargesMax, output.EnduranceChargesMin))
end
output.RemovableEnduranceCharges = m_max(output.EnduranceCharges - output.EnduranceChargesMin, 0)
if modDB:Flag(nil, "UseSiphoningCharges") then
output.SiphoningCharges = modDB:Override(nil, "SiphoningCharges") or output.SiphoningChargesMax
end
if modDB:Flag(nil, "UseChallengerCharges") then
output.ChallengerCharges = modDB:Override(nil, "ChallengerCharges") or output.ChallengerChargesMax
end
if modDB:Flag(nil, "UseBlitzCharges") then
output.BlitzCharges = modDB:Override(nil, "BlitzCharges") or output.BlitzChargesMax
end
if actor == env.player then
output.InspirationCharges = modDB:Override(nil, "InspirationCharges") or output.InspirationChargesMax
end
if modDB:Flag(nil, "UseGhostShrouds") then
output.GhostShrouds = modDB:Override(nil, "GhostShrouds") or 3
end
output.BloodCharges = m_min(modDB:Override(nil, "BloodCharges") or output.BloodChargesMax, output.BloodChargesMax)
output.SpiritCharges = m_min(modDB:Override(nil, "SpiritCharges") or 0, output.SpiritChargesMax)
output.CrabBarriers = m_min(modDB:Override(nil, "CrabBarriers") or output.CrabBarriersMax, output.CrabBarriersMax)
if modDB:Flag(nil, "HaveMaximumPowerCharges") then
output.PowerCharges = output.PowerChargesMax
end
if modDB:Flag(nil, "HaveMaximumFrenzyCharges") then
output.FrenzyCharges = output.FrenzyChargesMax
end
if modDB:Flag(nil, "HaveMaximumEnduranceCharges") then
output.EnduranceCharges = output.EnduranceChargesMax
end
output.TotalCharges = output.PowerCharges + output.FrenzyCharges + output.EnduranceCharges
output.RemovableTotalCharges = output.RemovableEnduranceCharges + output.RemovableFrenzyCharges + output.RemovablePowerCharges
modDB.multipliers["PowerCharge"] = output.PowerCharges
modDB.multipliers["PowerChargeMax"] = output.PowerChargesMax
modDB.multipliers["RemovablePowerCharge"] = output.RemovablePowerCharges
modDB.multipliers["FrenzyCharge"] = output.FrenzyCharges
modDB.multipliers["RemovableFrenzyCharge"] = output.RemovableFrenzyCharges
modDB.multipliers["EnduranceCharge"] = output.EnduranceCharges
modDB.multipliers["RemovableEnduranceCharge"] = output.RemovableEnduranceCharges
modDB.multipliers["TotalCharges"] = output.TotalCharges
modDB.multipliers["RemovableTotalCharges"] = output.RemovableTotalCharges
modDB.multipliers["SiphoningCharge"] = output.SiphoningCharges
modDB.multipliers["ChallengerCharge"] = output.ChallengerCharges
modDB.multipliers["BlitzCharge"] = output.BlitzCharges
modDB.multipliers["InspirationCharge"] = output.InspirationCharges
modDB.multipliers["GhostShroud"] = output.GhostShrouds
modDB.multipliers["CrabBarrier"] = output.CrabBarriers
modDB.multipliers["BrutalCharge"] = output.BrutalCharges
modDB.multipliers["AbsorptionCharge"] = output.AbsorptionCharges
modDB.multipliers["AfflictionCharge"] = output.AfflictionCharges
modDB.multipliers["BloodCharge"] = output.BloodCharges
modDB.multipliers["SpiritCharge"] = output.SpiritCharges
end
function calcs.actionSpeedMod(actor)
local modDB = actor.modDB
local minimumActionSpeed = modDB:Max(nil, "MinimumActionSpeed") or 0
local maximumActionSpeedReduction = modDB:Max(nil, "MaximumActionSpeedReduction")
local actionSpeedMod = 1 + (m_max(-data.misc.TemporalChainsEffectCap, modDB:Sum("INC", nil, "TemporalChainsActionSpeed")) + modDB:Sum("INC", nil, "ActionSpeed")) / 100
actionSpeedMod = m_max(minimumActionSpeed / 100, actionSpeedMod)
if maximumActionSpeedReduction then
actionSpeedMod = m_min((100 - maximumActionSpeedReduction) / 100, actionSpeedMod)
end
return actionSpeedMod
end
-- Finalises the environment and performs the stat calculations:
-- 1. Merges keystone modifiers
-- 2. Initialises minion skills
-- 3. Initialises the main skill's minion, if present
-- 4. Merges flask effects
-- 5. Sets conditions and calculates attributes (doActorAttribsConditions)
-- 6. Calculates life and mana (doActorLifeMana)
-- 6. Calculates reservations
-- 7. Sets life/mana reservation (doActorLifeManaReservation)
-- 8. Processes buffs and debuffs
-- 9. Processes charges and misc buffs (doActorCharges, doActorMisc)
-- 10. Calculates defence and offence stats (calcs.defence, calcs.offence)
function calcs.perform(env, skipEHP)
local modDB = env.modDB
local enemyDB = env.enemyDB
-- Merge keystone modifiers
env.keystonesAdded = { }
mergeKeystones(env)
-- Build minion skills
for _, activeSkill in ipairs(env.player.activeSkillList) do
activeSkill.skillModList = new("ModList", activeSkill.baseSkillModList)
if activeSkill.minion then
activeSkill.minion.modDB = new("ModDB")
activeSkill.minion.modDB.actor = activeSkill.minion
calcs.createMinionSkills(env, activeSkill)
activeSkill.skillPartName = activeSkill.minion.mainSkill.activeEffect.grantedEffect.name
end
end
env.player.output = { }
env.enemy.output = { }
local output = env.player.output
env.partyMembers = env.build.partyTab.actor
env.player.partyMembers = env.partyMembers
local partyTabEnableExportBuffs = env.build.partyTab.enableExportBuffs and env.mode ~= "CALCULATOR"
env.minion = env.player.mainSkill.minion
if env.minion then
-- Initialise minion modifier database
output.Minion = { }
env.minion.output = output.Minion
env.minion.modDB.multipliers["Level"] = env.minion.level
calcs.initModDB(env, env.minion.modDB)
env.minion.modDB:NewMod("Life", "BASE", m_floor(env.minion.lifeTable[env.minion.level] * env.minion.minionData.life), "Base")
if env.minion.minionData.energyShield then
env.minion.modDB:NewMod("EnergyShield", "BASE", m_floor(env.data.monsterAllyLifeTable[env.minion.level] * env.minion.minionData.life * env.minion.minionData.energyShield), "Base")
end
--Armour formula is math.floor((10 + 2 * level) * 1.067 ^ level)
env.minion.modDB:NewMod("Armour", "BASE", round(env.data.monsterArmourTable[env.minion.level] * (env.minion.minionData.armour or 1)), "Base")
--Evasion formula is math.floor((50 + 16 * level + 16 * level * (MonsterType.Evasion / 100)) * (1.0212 ^ level)
env.minion.modDB:NewMod("Evasion", "BASE", round(env.data.monsterEvasionTable[env.minion.level] * (env.minion.minionData.evasion or 1)), "Base")
if modDB:Flag(nil, "MinionAccuracyEqualsAccuracy") then
env.minion.modDB:NewMod("Accuracy", "BASE", calcLib.val(modDB, "Accuracy") + calcLib.val(modDB, "Dex") * (modDB:Override(nil, "DexAccBonusOverride") or data.misc.AccuracyPerDexBase), "Player")
else
env.minion.modDB:NewMod("Accuracy", "BASE", round(env.data.monsterAccuracyTable[env.minion.level] * (env.minion.minionData.accuracy or 1)), "Base")
end
env.minion.modDB:NewMod("CritMultiplier", "BASE", 30, "Base")
env.minion.modDB:NewMod("CritDegenMultiplier", "BASE", 30, "Base")
env.minion.modDB:NewMod("FireResist", "BASE", env.minion.minionData.fireResist, "Base")
env.minion.modDB:NewMod("ColdResist", "BASE", env.minion.minionData.coldResist, "Base")
env.minion.modDB:NewMod("LightningResist", "BASE", env.minion.minionData.lightningResist, "Base")
env.minion.modDB:NewMod("ChaosResist", "BASE", env.minion.minionData.chaosResist, "Base")
env.minion.modDB:NewMod("CritChance", "INC", 50, "Base", { type = "Multiplier", var = "PowerCharge" })
env.minion.modDB:NewMod("Speed", "INC", 4, "Base", ModFlag.Attack, { type = "Multiplier", var = "FrenzyCharge" })
env.minion.modDB:NewMod("Speed", "INC", 4, "Base", ModFlag.Cast, { type = "Multiplier", var = "FrenzyCharge" })
env.minion.modDB:NewMod("Damage", "MORE", 4, "Base", { type = "Multiplier", var = "FrenzyCharge" })
env.minion.modDB:NewMod("PhysicalDamageReduction", "BASE", 4, "Base", { type = "Multiplier", var = "EnduranceCharge" })
env.minion.modDB:NewMod("ElementalResist", "BASE", 4, "Base", { type = "Multiplier", var = "EnduranceCharge" })
env.minion.modDB:NewMod("ProjectileCount", "BASE", 1, "Base")
env.minion.modDB:NewMod("MaximumFortification", "BASE", 20, "Base")
env.minion.modDB:NewMod("Damage", "MORE", 200, "Base", 0, KeywordFlag.Bleed, { type = "ActorCondition", actor = "enemy", var = "Moving" })