-
Notifications
You must be signed in to change notification settings - Fork 0
/
effect.lua
1271 lines (1214 loc) · 44.8 KB
/
effect.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
---@class EffectResolver
local this = {}
local combat = require("longod.DPSTooltips.combat")
local logger = require("longod.DPSTooltips.logger")
-- TODO key should use tes3.effect.*attribute to be better than original?
---@class AttributeModifier
---@field damage {[tes3.attribute] : number},
---@field drain {[tes3.attribute] : number},
---@field absorb {[tes3.attribute] : number},
---@field restore {[tes3.attribute] : number},
---@field fortify {[tes3.attribute] : number},
-- TODO key should use tes3.effect.*skill to be better than original?
---@class SkillModifier
---@field damage {[tes3.skill] : number},
---@field drain {[tes3.skill] : number},
---@field absorb {[tes3.skill] : number},
---@field restore {[tes3.skill] : number},
---@field fortify {[tes3.skill] : number},
---@class Modifier
---@field damages {[tes3.effect] : number}
---@field positives {[tes3.effect] : number}
---@field negatives {[tes3.effect] : number}
---@field attributes AttributeModifier
---@field skills SkillModifier
---@field resists {[tes3.effect] : number} resolved resistance
---@field actived Modifier
---@class ScratchData
---@field attacker Modifier
---@field target Modifier
---@class Params
---@field data ScratchData
---@field key tes3.effect
---@field value number
---@field speed number
---@field isSelf boolean
---@field attacker boolean
---@field target boolean
---@field attribute tes3.attribute
---@field skill tes3.skill
---@field weaponSkillId tes3.skill
---@field actived boolean
---@return ScratchData
function this.CreateScratchData()
---@type ScratchData
local data = {
attacker = {
positives = {},
negatives = {},
attributes = {
damage = {},
drain = {},
absorb = {},
restore = {},
fortify = {},
},
skills = {
damage = {},
drain = {},
absorb = {},
restore = {},
fortify = {},
},
resists = {},
actived = {
positives = {},
negatives = {},
attributes = {
damage = {},
drain = {},
absorb = {},
restore = {},
fortify = {},
},
skills = {
damage = {},
drain = {},
absorb = {},
restore = {},
fortify = {},
},
resists = {},
},
},
target = {
damages = {},
positives = {},
negatives = {},
attributes = {
damage = {},
drain = {},
absorb = {},
restore = {},
fortify = {},
},
skills = {
damage = {},
drain = {},
absorb = {},
restore = {},
fortify = {},
},
resists = {},
},
}
return data
end
---@param tbl { [number]: number }
---@param key number
---@param initial number
---@return number
function this.GetValue(tbl, key, initial)
if not tbl[key] then -- no allocate if it does not exists
return initial
end
return tbl[key]
end
---@param tbl { [number]: number }
---@param key number
---@param value number
---@return number
function this.AddValue(tbl, key, value)
tbl[key] = this.GetValue(tbl, key, 0) + value
return tbl[key]
end
---@param tbl { [number]: number }
---@param key number
---@param value number
---@return number
function this.MulValue(tbl, key, value)
tbl[key] = this.GetValue(tbl, key, 1) * value
return tbl[key]
end
---@class FilterFlag
---@field attacker boolean
---@field target boolean
---@class AttributeFilter
---@field [tes3.attribute] FilterFlag
local attributeFilter = {
[tes3.attribute.strength] = { attacker = true, target = false }, -- damage
[tes3.attribute.intelligence] = { attacker = false, target = false },
[tes3.attribute.willpower] = { attacker = true, target = true }, -- fatigue
[tes3.attribute.agility] = { attacker = true, target = true }, -- evade, hit, fatigue
[tes3.attribute.speed] = { attacker = false, target = false }, -- if weapon swing mod
[tes3.attribute.endurance] = { attacker = true, target = true }, -- fatigue or if realtime health calculate mod
[tes3.attribute.personality] = { attacker = false, target = false },
[tes3.attribute.luck] = { attacker = true, target = true }, -- evade, hit
}
---@class SkillFilter
---@field [tes3.skill] FilterFlag
local skillFilter = {
[tes3.skill.block] = { attacker = false, target = true },
[tes3.skill.armorer] = { attacker = false, target = false },
[tes3.skill.mediumArmor] = { attacker = false, target = true },
[tes3.skill.heavyArmor] = { attacker = false, target = true },
[tes3.skill.bluntWeapon] = { attacker = true, target = false },
[tes3.skill.longBlade] = { attacker = true, target = false },
[tes3.skill.axe] = { attacker = true, target = false },
[tes3.skill.spear] = { attacker = true, target = false },
[tes3.skill.athletics] = { attacker = false, target = false },
[tes3.skill.enchant] = { attacker = false, target = false },
[tes3.skill.destruction] = { attacker = false, target = false },
[tes3.skill.alteration] = { attacker = false, target = false },
[tes3.skill.illusion] = { attacker = false, target = false },
[tes3.skill.conjuration] = { attacker = false, target = false },
[tes3.skill.mysticism] = { attacker = false, target = false },
[tes3.skill.restoration] = { attacker = false, target = false },
[tes3.skill.alchemy] = { attacker = false, target = false },
[tes3.skill.unarmored] = { attacker = false, target = false },
[tes3.skill.security] = { attacker = false, target = false },
[tes3.skill.sneak] = { attacker = false, target = false },
[tes3.skill.acrobatics] = { attacker = false, target = false },
[tes3.skill.lightArmor] = { attacker = false, target = true },
[tes3.skill.shortBlade] = { attacker = true, target = false },
[tes3.skill.marksman] = { attacker = true, target = false },
[tes3.skill.mercantile] = { attacker = false, target = false },
[tes3.skill.speechcraft] = { attacker = false, target = false },
[tes3.skill.handToHand] = { attacker = false, target = false },
}
---@param params Params
---@param absorb boolean
---@return boolean
local function IsAffectedAttribute(params, absorb)
local f = attributeFilter[params.attribute]
if f then
-- lua: a and b or c idiom is useless when b and c are boolean, it return b or c.
if absorb then
local both = f.target or f.attacker
return params.target and both
elseif params.isSelf then
return params.attacker and f.attacker
else
return params.target and f.target
end
end
return false
end
---@param params Params
---@param absorb boolean
---@return boolean
local function IsAffectedSkill(params, absorb)
local f = skillFilter[params.skill]
if f then
-- lua: a and b or c idiom is useless when b and c are boolean, it return b or c.
if absorb then
local both = f.target or (f.attacker and params.skill == params.weaponSkillId)
return params.target and both
elseif params.isSelf then
return params.skill == params.weaponSkillId and params.attacker and f.attacker
else
return params.target and f.target
end
end
return false
end
---@param params Params
---@return boolean
local function DamageHealth(params)
if params.isSelf then
else
if params.target then
this.AddValue(params.data.target.damages, params.key, combat.CalculateDPS(params.value, params.speed))
return true
end
end
return false
end
---@param params Params
---@return boolean
local function DrainHealth(params)
if params.isSelf then
else
if params.target then
this.AddValue(params.data.target.damages, params.key, params.value)
return true
end
end
return false
end
---@param params Params
---@return boolean
local function CurePoison(params)
if params.isSelf then
else
if params.target then
params.data.target.positives[params.key] = 1
return true
end
end
return false
end
---@param params Params
---@return boolean
local function PositiveModifier(params)
if params.isSelf then
if params.attacker then
if params.actived then
this.AddValue(params.data.attacker.actived.positives, params.key, params.value)
else
this.AddValue(params.data.attacker.positives, params.key, params.value)
end
return true
end
else
if params.target then
this.AddValue(params.data.target.positives, params.key, params.value)
return true
end
end
return false
end
---@param params Params
---@return boolean
local function PositiveModifierWithSpeed(params)
if params.isSelf then
if params.attacker then
if params.actived then
this.AddValue(params.data.attacker.actived.positives, params.key,
combat.CalculateDPS(params.value, params.speed))
else
this.AddValue(params.data.attacker.positives, params.key, combat.CalculateDPS(params.value, params.speed))
end
return true
end
else
if params.target then
this.AddValue(params.data.target.positives, params.key, combat.CalculateDPS(params.value, params.speed))
return true
end
end
return false
end
---@param params Params
---@return boolean
local function NegativeModifier(params)
if params.isSelf then
if params.attacker then
if params.actived then
this.AddValue(params.data.attacker.actived.negatives, params.key, params.value)
else
this.AddValue(params.data.attacker.negatives, params.key, params.value)
end
return true
end
else
if params.target then
this.AddValue(params.data.target.negatives, params.key, params.value)
return true
end
end
return false
end
-- only positive
---@param params Params
---@return boolean
local function MultModifier(params)
if params.isSelf then
else
if params.target then
this.MulValue(params.data.target.positives, params.key, combat.InverseNormalize(params.value))
return true
end
end
return false
end
---@param params Params
---@return boolean
local function FortifyAttribute(params)
if not IsAffectedAttribute(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.attributes.fortify, params.attribute, params.value)
else
this.AddValue(params.data.attacker.attributes.fortify, params.attribute, params.value)
end
else
this.AddValue(params.data.target.attributes.fortify, params.attribute, params.value)
end
return true
end
---@param params Params
---@return boolean
local function DamageAttribute(params)
if not IsAffectedAttribute(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.attributes.damage, params.attribute,
combat.CalculateDPS(params.value, params.speed))
else
this.AddValue(params.data.attacker.attributes.damage, params.attribute,
combat.CalculateDPS(params.value, params.speed))
end
else
this.AddValue(params.data.target.attributes.damage, params.attribute,
combat.CalculateDPS(params.value, params.speed))
end
return true
end
---@param params Params
---@return boolean
local function DrainAttribute(params)
if not IsAffectedAttribute(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.attributes.drain, params.attribute, params.value)
else
this.AddValue(params.data.attacker.attributes.drain, params.attribute, params.value)
end
else
this.AddValue(params.data.target.attributes.drain, params.attribute, params.value)
end
return true
end
---@param params Params
---@return boolean
local function AbsorbAttribute(params)
if not IsAffectedAttribute(params, true) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.attributes.absorb, params.attribute, params.value)
else
return false
end
else
this.AddValue(params.data.attacker.attributes.absorb, params.attribute, params.value)
this.AddValue(params.data.target.attributes.absorb, params.attribute, params.value)
end
return true
end
---@param params Params
---@return boolean
local function RestoreAttribute(params)
if not IsAffectedAttribute(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.attributes.restore, params.attribute,
combat.CalculateDPS(params.value, params.speed))
else
this.AddValue(params.data.attacker.attributes.restore, params.attribute,
combat.CalculateDPS(params.value, params.speed))
end
else
this.AddValue(params.data.target.attributes.restore, params.attribute,
combat.CalculateDPS(params.value, params.speed))
end
return true
end
---@param params Params
---@return boolean
local function FortifySkill(params)
if not IsAffectedSkill(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.skills.fortify, params.skill, params.value)
else
this.AddValue(params.data.attacker.skills.fortify, params.skill, params.value)
end
else
this.AddValue(params.data.target.skills.fortify, params.skill, params.value)
end
return true
end
---@param params Params
---@return boolean
local function DamageSkill(params)
if not IsAffectedSkill(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.skills.damage, params.skill,
combat.CalculateDPS(params.value, params.speed))
else
this.AddValue(params.data.attacker.skills.damage, params.skill,
combat.CalculateDPS(params.value, params.speed))
end
else
this.AddValue(params.data.target.skills.damage, params.skill, combat.CalculateDPS(params.value, params.speed))
end
return true
end
---@param params Params
---@return boolean
local function DrainSkill(params)
if not IsAffectedSkill(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.skills.drain, params.skill, params.value)
else
this.AddValue(params.data.attacker.skills.drain, params.skill, params.value)
end
else
this.AddValue(params.data.target.skills.drain, params.skill, params.value)
end
return true
end
---@param params Params
---@return boolean
local function AbsorbSkill(params)
if not IsAffectedSkill(params, true) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.skills.absorb, params.skill, params.value)
else
return false
end
else
this.AddValue(params.data.attacker.skills.absorb, params.skill, params.value)
this.AddValue(params.data.target.skills.absorb, params.skill, params.value)
end
return true
end
---@param params Params
---@return boolean
local function RestoreSkill(params)
if not IsAffectedSkill(params, false) then
return false
end
if params.isSelf then
if params.actived then
this.AddValue(params.data.attacker.actived.skills.restore, params.skill,
combat.CalculateDPS(params.value, params.speed))
else
this.AddValue(params.data.attacker.skills.restore, params.skill,
combat.CalculateDPS(params.value, params.speed))
end
else
this.AddValue(params.data.target.skills.restore, params.skill, combat.CalculateDPS(params.value, params.speed))
end
return true
end
---@class Resolver
---@field func fun(params: Params): boolean
---@field attacker boolean affect when hitting
---@field target boolean affect when hitting
-- only vanilla effects
---@class ResolverTable
---@field [number] Resolver?
local resolver = {
-- waterBreathing 0
-- swiftSwim 1
-- waterWalking 2
[3] = { func = PositiveModifier, attacker = false, target = true }, -- shield 3
[4] = { func = PositiveModifier, attacker = false, target = true }, -- fireShield 4
[5] = { func = PositiveModifier, attacker = false, target = true }, -- lightningShield 5
[6] = { func = PositiveModifier, attacker = false, target = true }, -- frostShield 6
-- burden 7
-- feather 8
-- jump 9
-- levitate 10
-- slowFall 11
-- lock 12
-- open 13
[14] = { func = DamageHealth, attacker = false, target = true }, -- fireDamage 14
[15] = { func = DamageHealth, attacker = false, target = true }, -- shockDamage 15
[16] = { func = DamageHealth, attacker = false, target = true }, -- frostDamage 16
[17] = { func = DrainAttribute, attacker = true, target = true }, -- drainAttribute 17
[18] = { func = DrainHealth, attacker = false, target = true }, -- drainHealth 18
-- drainMagicka 19
[20] = nil, -- drainFatigue 20
[21] = { func = DrainSkill, attacker = true, target = true }, -- drainSkill 21
[22] = { func = DamageAttribute, attacker = true, target = true }, -- damageAttribute 22
[23] = { func = DamageHealth, attacker = false, target = true }, -- damageHealth 23
-- damageMagicka 24
[25] = nil, -- damageFatigue 25
[26] = { func = DamageSkill, attacker = true, target = true }, -- damageSkill 26
[27] = { func = DamageHealth, attacker = false, target = true }, -- poison 27
[28] = { func = NegativeModifier, attacker = false, target = true }, -- weaknesstoFire 28
[29] = { func = NegativeModifier, attacker = false, target = true }, -- weaknesstoFrost 29
[30] = { func = NegativeModifier, attacker = false, target = true }, -- weaknesstoShock 30
[31] = { func = NegativeModifier, attacker = true, target = true }, -- weaknesstoMagicka 31
-- weaknesstoCommonDisease 32
-- weaknesstoBlightDisease 33
-- weaknesstoCorprusDisease 34
[35] = { func = NegativeModifier, attacker = false, target = true }, -- weaknesstoPoison 35
[36] = { func = NegativeModifier, attacker = false, target = true }, -- weaknesstoNormalWeapons 36
-- disintegrateWeapon 37
[38] = nil, -- disintegrateArmor 38
-- invisibility 39
-- chameleon 40
-- light 41
[42] = { func = PositiveModifier, attacker = false, target = true }, -- sanctuary 42
-- nightEye 43
-- charm 44
-- paralyze 45
-- silence 46
[47] = { func = NegativeModifier, attacker = true, target = false }, -- blind 47
-- sound 48
-- calmHumanoid 49
-- calmCreature 50
-- frenzyHumanoid 51
-- frenzyCreature 52
-- demoralizeHumanoid 53
-- demoralizeCreature 54
-- rallyHumanoid 55
-- rallyCreature 56
[57] = { func = PositiveModifier, attacker = true, target = true }, -- dispel 57
-- soultrap 58
-- telekinesis 59
-- mark 60
-- recall 61
-- divineIntervention 62
-- almsiviIntervention 63
-- detectAnimal 64
-- detectEnchantment 65
-- detectKey 66
[67] = { func = MultModifier, attacker = true, target = true }, -- spellAbsorption 67
[68] = { func = MultModifier, attacker = true, target = true }, -- reflect 68
-- cureCommonDisease 69
-- cureBlightDisease 70
-- cureCorprusDisease 71
[72] = { func = CurePoison, attacker = false, target = true }, -- curePoison 72
-- cureParalyzation 73
[74] = { func = RestoreAttribute, attacker = true, target = true }, -- restoreAttribute 74
[75] = { func = PositiveModifierWithSpeed, attacker = false, target = true }, -- restoreHealth 75
-- restoreMagicka 76
[77] = nil, -- restoreFatigue 77
[78] = { func = RestoreSkill, attacker = true, target = true }, -- restoreSkill 78
[79] = { func = FortifyAttribute, attacker = true, target = true }, -- fortifyAttribute 79
[80] = { func = PositiveModifier, attacker = false, target = true }, -- fortifyHealth 80
-- fortifyMagicka 81
[82] = nil, -- fortifyFatigue 82
[83] = { func = FortifySkill, attacker = true, target = true }, -- fortifySkill 83
-- fortifyMaximumMagicka 84
[85] = { func = AbsorbAttribute, attacker = false, target = true }, -- absorbAttribute 85
[86] = { func = DamageHealth, attacker = false, target = true }, -- absorbHealth 86
-- absorbMagicka 87
[88] = nil, -- absorbFatigue 88
[89] = { func = AbsorbSkill, attacker = false, target = true }, -- absorbSkill 89
[90] = { func = PositiveModifier, attacker = false, target = true }, -- resistFire 90
[91] = { func = PositiveModifier, attacker = false, target = true }, -- resistFrost 91
[92] = { func = PositiveModifier, attacker = false, target = true }, -- resistShock 92
[93] = { func = PositiveModifier, attacker = true, target = true }, -- resistMagicka 93
-- resistCommonDisease 94
-- resistBlightDisease 95
-- resistCorprusDisease 96
[97] = { func = PositiveModifier, attacker = false, target = true }, -- resistPoison 97
[98] = { func = PositiveModifier, attacker = false, target = true }, -- resistNormalWeapons 98
-- resistParalysis 99
-- removeCurse 100
-- turnUndead 101
-- summonScamp 102
-- summonClannfear 103
-- summonDaedroth 104
-- summonDremora 105
-- summonAncestralGhost 106
-- summonSkeletalMinion 107
-- summonBonewalker 108
-- summonGreaterBonewalker 109
-- summonBonelord 110
-- summonWingedTwilight 111
-- summonHunger 112
-- summonGoldenSaint 113
-- summonFlameAtronach 114
-- summonFrostAtronach 115
-- summonStormAtronach 116
[117] = { func = PositiveModifier, attacker = true, target = false }, -- fortifyAttack 117
-- commandCreature 118
-- commandHumanoid 119
[120] = nil, -- boundDagger 120
[121] = nil, -- boundLongsword 121
[122] = nil, -- boundMace 122
[123] = nil, -- boundBattleAxe 123
[124] = nil, -- boundSpear 124
[125] = nil, -- boundLongbow 125
-- eXTRASPELL 126
-- boundCuirass 127
-- boundHelm 128
-- boundBoots 129
-- boundShield 130
-- boundGloves 131
-- corprus 132
-- vampirism 133
-- summonCenturionSphere 134
[135] = { func = DamageHealth, attacker = false, target = true }, -- sunDamage 135
-- stuntedMagicka 136
-- summonFabricant 137
-- callWolf 138
-- callBear 139
-- summonBonewolf 140
-- sEffectSummonCreature04 141
-- sEffectSummonCreature05 142
}
---@param effectId tes3.effect
---@return Resolver
function this.Get(effectId)
return resolver[effectId]
end
-- TODO test actived case
-- unittest
---@param self EffectResolver
---@param unitwind MyUnitWind
function this.RunTest(self, unitwind)
unitwind:start("DPSTooltips.effect")
unitwind:test("Empty", function()
local r = self.Get(tes3.effect.detectAnimal)
unitwind:expect(r).toBe(nil)
end)
unitwind:test("DamageHealth", function()
local e = {
tes3.effect.fireDamage,
tes3.effect.shockDamage,
tes3.effect.frostDamage,
tes3.effect.damageHealth,
tes3.effect.poison,
tes3.effect.absorbHealth,
tes3.effect.sunDamage,
}
for _, v in ipairs(e) do
--logger:debug(tostring(v))
local r = self.Get(v)
unitwind:expect(r).NOT.toBe(nil)
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = v,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(true)
unitwind:expect(data.target.damages[params.key]).toBe(20)
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(false)
end
end)
unitwind:test("DrainHealth", function()
local v = tes3.effect.drainHealth
local r = self.Get(v)
unitwind:expect(r).NOT.toBe(nil)
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = v,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(true)
unitwind:expect(data.target.damages[params.key]).toBe(10)
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(false)
end)
unitwind:test("CurePoison", function()
local v = tes3.effect.curePoison
local r = self.Get(v)
unitwind:expect(r).NOT.toBe(nil)
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = v,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(true)
unitwind:expect(data.target.positives[params.key]).toBe(1)
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(false)
end)
unitwind:test("PositiveModifier", function()
local e = {
[tes3.effect.shield] = { true, false },
[tes3.effect.fireShield] = { true, false },
[tes3.effect.lightningShield] = { true, false },
[tes3.effect.frostShield] = { true, false },
[tes3.effect.sanctuary] = { true, false },
[tes3.effect.dispel] = { true, true },
[tes3.effect.fortifyHealth] = { true, false },
[tes3.effect.resistFire] = { true, false },
[tes3.effect.resistFrost] = { true, false },
[tes3.effect.resistShock] = { true, false },
[tes3.effect.resistMagicka] = { true, true },
[tes3.effect.resistPoison] = { true, false },
[tes3.effect.resistNormalWeapons] = { true, false },
[tes3.effect.fortifyAttack] = { false, true },
}
for k, v in pairs(e) do
-- logger:debug(tostring(k))
local r = self.Get(k)
unitwind:expect(r).NOT.toBe(nil)
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = k,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(v[1])
if affect then
unitwind:expect(data.target.positives[params.key]).toBe(10)
end
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(v[2])
if affect then
unitwind:expect(data.attacker.positives[params.key]).toBe(10)
end
end
end)
unitwind:test("PositiveModifierWithSpeed", function()
local v = tes3.effect.restoreHealth
local r = self.Get(v)
unitwind:expect(r).NOT.toBe(nil)
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = v,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(true)
unitwind:expect(data.target.positives[params.key]).toBe(20)
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(false)
end)
unitwind:test("NegativeModifier", function()
local e = {
[tes3.effect.weaknesstoFire] = { true, false },
[tes3.effect.weaknesstoFrost] = { true, false },
[tes3.effect.weaknesstoShock] = { true, false },
[tes3.effect.weaknesstoMagicka] = { true, true },
[tes3.effect.weaknesstoPoison] = { true, false },
[tes3.effect.weaknesstoNormalWeapons] = { true, false },
[tes3.effect.blind] = { false, true },
}
for k, v in pairs(e) do
-- logger:debug(tostring(k))
local r = self.Get(k)
unitwind:expect(r).NOT.toBe(nil)
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = k,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(v[1])
if affect then
unitwind:expect(data.target.negatives[params.key]).toBe(10)
end
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(v[2])
if affect then
unitwind:expect(data.attacker.negatives[params.key]).toBe(10)
end
end
end)
unitwind:test("MultModifier", function()
local e = {
tes3.effect.spellAbsorption,
tes3.effect.reflect,
}
for _, v in ipairs(e) do
-- logger:debug(tostring(k))
local r = self.Get(v)
unitwind:expect(r).NOT.toBe(nil)
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = v,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(true)
unitwind:expect(data.target.positives[params.key]).toBe(0.9)
affect = r.func(params)
unitwind:expect(data.target.positives[params.key]).toBe(0.81)
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(false)
end
end)
unitwind:test("FortifyAttribute", function()
local e = tes3.effect.fortifyAttribute
local r = self.Get(e)
unitwind:expect(r).NOT.toBe(nil)
for k, v in pairs(attributeFilter) do
-- logger:debug(tostring(k))
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = e,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
attribute = k,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(v.target)
if affect then
unitwind:expect(data.target.attributes.fortify[params.attribute]).toBe(10)
end
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(v.attacker)
if affect then
unitwind:expect(data.attacker.attributes.fortify[params.attribute]).toBe(10)
end
end
end)
unitwind:test("DamageAttribute", function()
local e = tes3.effect.damageAttribute
local r = self.Get(e)
unitwind:expect(r).NOT.toBe(nil)
for k, v in pairs(attributeFilter) do
-- logger:debug(tostring(k))
local data = self.CreateScratchData()
---@type Params
local params = {
data = data,
key = e,
value = 10,
speed = 2,
isSelf = false,
attacker = r.attacker,
target = r.target,
attribute = k,
}
local affect = r.func(params)
unitwind:expect(affect).toBe(v.target)
if affect then
unitwind:expect(data.target.attributes.damage[params.attribute]).toBe(20)
end
params.isSelf = true
affect = r.func(params)
unitwind:expect(affect).toBe(v.attacker)
if affect then
unitwind:expect(data.attacker.attributes.damage[params.attribute]).toBe(20)
end
end
end)
unitwind:test("DrainAttribute", function()
local e = tes3.effect.drainAttribute
local r = self.Get(e)
unitwind:expect(r).NOT.toBe(nil)
for k, v in pairs(attributeFilter) do