-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathBBRaisingHp.py
1179 lines (1098 loc) · 63 KB
/
BBRaisingHp.py
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
#Battle Brothers Damage Calculator -- HP Changing Version 1.7.1:
#Welcome. Modify the below values as necessary until you reach the line ----- break.
#The calculator expects you to make smart decisions, such as not giving Xbow Mastery to a Hammer.
#This version of the calculator will run the given scenario starting at 60hp and ending at 140hp and returning the outcome at every 10 hp interval.
#Note: Since this calculator runs multiple times per launch, default trials has been lowered. Adjust this to your preferences.
Trials = 20000 #Number of trials to run through. More trials leads to more accurate results but longer compute times.
#Data Returns: Set these values to 1 if you want more data returned, and 0 if you want less data returned.
#Note: If injuries/morale do not occur because defender is Undead then they will not display even if checked here.
DeathMean = 1 #Returns the average number of hits until death.
DeathStDev = 1 #Returns standard deviation of hits until death.
DeathPercent = 1 #Returns % chance of death by each hit.
InjuryMean = 1 #Returns average number of hits until first injury.
InjuryPercent = 0 #Returns % chance of first injury by each hit.
HeavyInjuryMean = 1 #Returns average number of hits until chance of first heavy injury (heavy injuries are not guaranteed even when threshold is met).
HeavyInjuryPercent = 0 #Returns % chance of first heavy injury chance by each hit.
MoraleMean = 0 #Returns average number of hits until first morale check.
MoralePercent = 0 #Returns % chance of first morale check by each hit.
#Attacker Stats: #Example is Ancient Bladed Pike, follow that formatting.
Mind = 55 #Mind = 55
Maxd = 80 #Maxd = 80
Headchance = 30 #Headchance = 30
Ignore = 30 #Ignore = 30
ArmorMod = 125 #ArmorMod = 125
#Defender Stats:
#IMPORTANT: In this version of the calculator, the HP stat does not need to be set. If you want your HP input run in the script then set the next flag.
Use_My_Input = 0 #Set to 1 if you want a specific HP count tested. Otherwise it will test 60, 70, and so on until 140.
Def_HP = 75
Def_Helmet = 120
Def_Armor = 95
Fatigue = -15 #Fatigue value only effects Nimble.
#DEFENDER FLAGS: Set these values to 1 if they apply and 0 otherwise.
#Perks:
NineLives = 0
Resilient = 0 #Reduces Bleeding duration.
SteelBrow = 0
Nimble = 0
Forge = 0
Indomitable = 0
#Attachments: Note: Only 1 attachment should be selected.
#IMPORTANT: Attachments will automatically add armor or subtract Fatigue. Use the base armor/Fatigue values in the Defender Stats section or else you will double dip the attachment.
Wolf_Hyena = 0 #+15 armor.
LindwurmCloak = 0 #+60 armor, -3 Fatigue.
AdFurPad = 0 #Additional Fur Padding. 33% reduced armor ignoring damage. -2 Fatigue.
Boneplate = 0 #Absorbs first body hit. -2 Fatigue.
HornPlate = 0 #Only select against melee attacks. +30 armor, 10% damage reduction.
UnholdFurCloak = 0 #Only select against range attacks. +10 armor, 20% damage reduction.
SerpentSkin = 0 #Only select in Handgonne tests. +30 armor, -2 Fatigue, 33% damage reduction.
#Light Padding Replacement -- Modify the Fatigue value directly if you wish to apply this. Has no effect except for Nimble.
#Traits:
Ironjaw = 0 #Reduces injury susceptibility.
GloriousEndurance = 0 #The Bear's unique trait. Reduces damage by 5% each time you are hit, up to a 25% max reduction.
#Ijirok Armor: #Choose one between Heal10/Heal20 and one between 1 or 2 Turn Heal interval.
#Note: Ijirok tests are imperfect in a sandbox calculator. 1v1 tests are biased in its favor, while lack of hit chance is biased against it.
IjirokHeal10 = 0 #Ijirok armor passive for one piece. Heals 10 HP at start of player turn.
IjirokHeal20 = 0 #Ijirok armor passive for both pieces. Heals 20 HP at start of player turn.
Ijirok1TurnHeal = 0 #Applies Ijirok healing after every attack.
Ijirok2TurnHeal = 0 #Applies Ijirok healing after every other attack, better simulating 4AP enemies/weapons, or being attacked by multiple enemies per turn.
#ATTACKER FLAGS: Set these values to 1 if they apply and 0 otherwise. If you select a Preset then leave these on 0.
#Weapons:
DoubleGrip = 0 #Only 1Handers are valid for DoubleGrip. Dagger Puncture tests should not be given DoubleGrip.
TwoHander20 = 0 #Damage +20. Applies to the single target 2Hander attacks Cudgel (Mace), Pound (Flail), Smite (Hammer), Overhead Strike (Long/GreatSword).
FlailLash = 0 #Gaurantees headshot. Also apply to 3Head Hail special.
Flail3Head = 0 #3Head Flail. Returns number of swings rather than number of hits.
Flail2HPound = 0 #Ignore +10% on body hits and +20% on headshots. Applies to 2H Flail Pound attack. Apply the +20 damage from Pound using the TwoHander20 switch.
FlailMastery = 0 #Flail Mastery. Will apply an extra 10% armor ignore on headshots for Pound. Does nothing unless Flail2HPound is set.
Hammer10 = 0 #Guarantees at least 10 hp damage, applies to 1H Hammer and Polehammer.
DestroyArmor = 0 #Will use Destroy Armor once and then switch to normal attacks.
DestroyArmorMastery = 0 #Hammer Mastery. Will use Destroy Armor once and then switch to normal attacks.
DestroyArmorTwice = 0 #Uses Destroy Armor two times instead of 1. Does nothing unless DestroyArmor or DestroyArmorMastery are set.
AoE2HHammer = 0 #Applies to Shatter, reduces Ignore by 10%.
Axe1H = 0 #Applies bonus damage to Headshots. Gets negated by SteelBrow.
SplitMan = 0 #Applies to single target 2HAxe except for Longaxe.
AoE2HAxe = 0 #Applies to Round Swing and Split in Two (Bardiche), reduces Ignore by 10%.
CleaverBleed = 0 #5 bleed damage per bleed tick.
CleaverMastery = 0 #10 bleed damage per bleed tick.
Decapitate = 0 #Cleaver Decapitate. Will use Decapitate for all attacks.
SmartDecap50 = 0 #Switches from normal Cleaver attacks to Decapitate once opposing hp is <= 50%.
SmartDecap33 = 0 #Switches from normal Cleaver attacks to Decapitate once opposing hp is <= 33.33%.
Shamshir = 0 #Shamshir special, acts like Crippling Strikes.
ShamshirMastery = 0 #Sword Mastery with Gash, 50% reduction to injury threshold instead of 33%.
Sword2HSplit = 0 #Ignore +5%. Applies to Greatsword Split attack. Does not apply to Overhead or Swing.
Puncture = 0 #Dagger Puncture. Do not apply Double Grip
Deathblow = 0 #Qatal special. Ignore +20%. Damage x1.33. Assumes target is always setup for Deathblow value in calculation.
Spearwall = 0 #Warning: May take a long time to compute against durable targets, considering lowering number of trials.
AimedShot = 0 #HP Damage +10% for Bows. +5% Armor Ignore.
XbowMastery = 0 #Ignore +20%.
R2Throw = 0 #Throwing Mastery for 1 or 2 Range.
R3Throw = 0 #Throwing Mastery for 3 Range.
Scatter = 0 #Ranged attacks that hit an unintended target deal 75% damage.
#Perks:
CripplingStrikes = 0
Executioner = 0
HeadHunter = 0 #Will carry over HH stacks between kills as happens in game.
Duelist = 0 #All Duelists should also be given DoubleGrip except for Throwing weapons.
KillingFrenzy = 0
Fearsome = 0 #Will also return # of Fearsome procs, which are all attacks that deal 1-14 damage.
#Traits:
Brute = 0 #Headshot damage +15%.
Drunkard = 0 #Damage +10%.
Huge = 0 #Damage +10%.
Tiny = 0 #Damage -15%.
#Backgrounds:
Juggler = 0 #Headchance +5%.
KillerOnTheRun = 0 #Headchance +10%.
#Injuries:
BrokenArm = 0 #Damage -50%. Heavy blunt/body.
SplitShoulder = 0 #Damage -50%. Heavy cutting/body.
CutArmSinew = 0 #Damage -40%. Light cutting/body.
InjuredShoulder = 0 #Damage -25%. Light piercing/body.
#Other:
Dazed = 0 #Damage -25%. Set this if you want to simulate the attacker always being Dazed.
Distracted = 0 #Damage -35%. Set this if you want to simulate the attacker always being Distracted (applied by Nomads).
Mushrooms = 0 #Damage +25%. Set this to simulate a Mushroom enhanced brother.
#RACE FLAGS (ATTACKER): Set these values to 1 if they apply and 0 otherwise. If late game only set the second option. #If you use a Preset then leave these on 0.
Young = 0 #Damage +15%.
Berserker = 0 #Damage +20%.
BerserkerDay190 = 0 #Damage +30%.
Warrior = 0 #Damage +15%.
WarriorDay200 = 0 #Damage +25%.
Warlord = 0 #Damage +35%.
WarlordDay200 = 0 #Damage +45%.
Conqueror = 0 #Damage +35%. Monolith.
FallenBetrayer = 0 #Damage +25%. Watermill.
FallenHeroDay100 = 0 #Damage +10%.
ArmoredZombieDay100 = 0 #Damage +10%.
BarbKing = 0 #Damage +20%.
HedgeKnight = 0 #Damage +20%.
BrigandLeader = 0 #Armor Damage + 20%.
Ambusher = 0 #Ignore * 1.25
Skirmisher = 0 #Ignore * 1.25
Overseer = 0 #Ignore * 1.1
Wolfrider = 0 #Ignore * 1.25
MasterArcher = 0 #Ignore * 1.25
FrenziedDirewolf = 0 #Damage +20%.
UnholdDay90 = 0 #Damage +10%.
LindwurmDay170 = 0 #Damage +10%.
#RACE FLAGS (DEFENDER): Set these values to 1 if they apply and 0 otherwise. (This section does not logically apply to this version of the calculator).
Undead = 0 #Immunity to Injury, Bleeding, and Morale.
Savant = 0 #Immunity to Injury and Morale.
SkeletonVsPierce = 0 #50% health damage reduction for Ancient Dead and Alps vs. Daggers, Spears, and Pikes.
SkeletonVsJavelin = 0 #75% health damage reduction for Ancient Dead and Alps vs. Javelins.
SkeletonVsArrow = 0 #90% health damage reduction for Anciend Dead and Alps vs. Arrows.
PossessedUndead = 0 #25% damage reduction. Necromancer buff.
FallenBetrayerD = 0 #25% armor damage reduction for Watermill Betrayers.
#Attacker Preset: Set these values to 1 if you wish to use a attacker preset, and 0 otherwise.
#A preset will atutomatically set attacker stats and attacker perks.
#Attacker presets do not include the late game day related buffs that some races get.
#Does not disable perks that shouldn't be active. For example, don't activate Duelist and then check the Chosen Preset.
APreAncientSword = 0 #Ancient Dead: 38-43, 20% Ignore, 80% Armor, Fearsome.
APreBladedPike = 0 #Ancient Dead: 55-80, 30% Ignore, 125% Armor, 30% Head, Fearsome.
APreWarscytheAoE = 0 #Ancient Dead: 55-80, 25% Ignore, 105% Armor, Fearsome.
APreCryptCleaver = 0 #Ancient Dead: 60-80, 25% Ignore, 120% Armor, Fearsome, Cleaver Mastery.
APreKhopesh = 0 #Necrosavant: 35-55, 25% Ignore, 120% Armor, HeadHunter, Crippling, Double Grip, CleaverBleed.
APreFHGreatAxe = 0 #Fallen Hero: 80-100, 40 %Ignore, 150% Armor, Fearsome, Split Man.
APreBerserkChain = 0 #Orc Berserker: 50-100, 30% Ignore, 125% Armor, 40% Head, TwoHander20, Flail2HPound, FlailMastery, Berserker.
APreHeadSplitter = 0 #Orc Young/Warrior: 35-65, 30% Ignore, 130% Armor, 1HAxe, Warrior.
APreHeadChopper = 0 #Orc Young/Warrior: 40-70, 25% Ignore, 110% Armor, Cleaver Mastery, Warrior.
APreMansplitter = 0 #Orc Warlord: 90-120, 40% Ignore, 160% Armor, Split Man, Fearsome, Warlord.
APreReinBoondock = 0 #Goblin Ambusher: 30-50, 35% Ignore, 60% Armor, Ambusher.
APreSpikedImpaler = 0 #Goblin Overseer: 50-70, 50% Ignore, 75% Armor, Overseer, Xbow Mastery.
APre2HSpikedMace = 0 #Chosen: 50-70, 60% Ignore, 115% Armor, Crippling, Executioner, TwoHander20.
APre2HSkullHammer = 0 #Chosen: 45-65, 60% Ignore, 180% Armor, Crippling, Executioner, TwoHander20.
APreHeavyRustyAxe = 0 #Chosen: 75-90, 50% Ignore, 150% Armor, Crippling, Executioner, Split Man.
APreRustyWarblade = 0 #Chosen: 60-80, 35% Ignore, 110% Armor, Crippling, Executioner, Cleaver Mastery.
APreBillhook = 0 #Billman: 55-85, 30% Ignore, 140% Armor, 30% Head.
APreHeavyXbow = 0 #Arbalester: 50-70, 50% Ignore, 75% Armor, XbowMastery.
APreFightingAxe = 0 #Knight: 35-55, 30% Ignore, 130% Armor, 1HAxe, Crippling, Executioner.
APreWingedMace = 0 #Sergeant: 35-55, 40% Ignore, 110% Armor, Duelist, Double Grip
APreGreatsword = 0 #Zweihander: 85-100, 25% Ignore, 100% Armor, 30% Head, TwoHander20.
APreFlailDGrip = 0 #Raider: 25-55, 30% Ignore, 100% Armor, 35% Head, Double Grip, Executioner.
APreLongAxe = 0 #Raider: 70-95, 30% Ignore, 110% Armor, 30% Head, Executioner.
APreMedXbow = 0 #Marksman: 40-60, 50% Ignore, 70% Armor, Xbow Mastery.
APreNobleSword = 0 #Swordmaster: 45-50, 20% Ignore, 85% Armor, Duelist, Double Grip, Crippling, Executioner.
APreWarbow = 0 #Master Archer: 50-70, 35% Ignore, 60% Armor, Crippling, Executioner, HeadHunter, Master Archer.
APrePoleMace = 0 #Conscript: 60-75, 40% Ignore, 120% Armor, 30% Head.
APreHandgonne = 0 #Gunner: 35-75, 25% Ignore, 90% Armor, Fearsome.
APre2HScimitar = 0 #Officer: 65-85, 25% Ignore, 110% Armor, Crippling, Executioner, Cleaver Mastery.
APreQatal = 0 #Assassin: 30-45, 20% Ignore, 70% Armor, Duelist, Double Grip, Executioner.
APreFDirewolf = 0 #Frenzied Direwolf: 30-50, 20% Ignore, 70% Armor, Executioner, Frenzied Direwolf.
APreNachTier3 = 0 #Tier 3 Nachzehrer: 55-80, 10% Ignore, 75% Armor.
APreLindwurm = 0 #Lindwurm Head: 80-140, 35% Ignore, 150% Armor, Fearsome.
APreUnhold = 0 #Unhold: 40-80, 40% Ignore, 80% Armor, Crippling.
APreSchrat = 0 #Schrat: 70-100, 50% Ignore, 80% Armor, Crippling.
# ------------------------------------------------------------------------
#IMPORTANT --- ALL BELOW FIELDS SHOULD NOT BE MODIFIED. --- IMPORTANT
#DO NOT MODIFY BELOW FIELDS UNLESS YOU KNOW WHAT YOU ARE DOING.
#Dependencies:
import random
import statistics
import collections
import math
import sys
#Attacker presets:
if APreAncientSword == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Fearsome = 38, 43, 25, 20, 80, 1
if APreBladedPike == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Fearsome = 55, 80, 30, 30, 125, 1
if APreWarscytheAoE == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Fearsome = 55, 80, 25, 25, 105, 1
if APreCryptCleaver == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Fearsome, CleaverMastery = 60, 80, 25, 25, 120, 1, 1
if APreKhopesh == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, HeadHunter, CripplingStrikes, DoubleGrip, CleaverBleed = 35, 55, 25, 25, 120, 1, 1, 1, 1
if APreFHGreatAxe == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Fearsome, SplitMan = 80, 100, 25, 40, 150, 1, 1
if APreBerserkChain == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, TwoHander20, Flail2HPound, FlailMastery, Berserker = 50, 100, 40, 30, 125, 1, 1, 1, 1
if APreHeadSplitter == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Axe1H, Warrior = 35, 65, 25, 30, 130, 1, 1
if APreHeadChopper == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CleaverMastery, Warrior = 40, 70, 25, 25, 110, 1, 1
if APreMansplitter == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, SplitMan, Fearsome, Warlord = 90, 120, 25, 40, 160, 1, 1, 1
if APreReinBoondock == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Ambusher = 30, 50, 25, 35, 60, 1
if APreSpikedImpaler == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Overseer, XbowMastery = 50, 70, 25, 50, 75, 1, 1
if APre2HSpikedMace == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CripplingStrikes, Executioner, TwoHander20 = 50, 70, 25, 60, 115, 1, 1, 1
if APre2HSkullHammer == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CripplingStrikes, Executioner, TwoHander20 = 45, 65, 25, 60, 180, 1, 1, 1
if APreHeavyRustyAxe == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CripplingStrikes, Executioner, SplitMan = 75, 90, 25, 50, 150, 1, 1, 1
if APreRustyWarblade == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CripplingStrikes, Executioner, CleaverMastery = 60, 80, 25, 35, 110, 1, 1, 1
if APreBillhook == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod = 55, 85, 30, 30, 140
if APreHeavyXbow == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, XbowMastery = 50, 70, 25, 50, 75, 1
if APreFightingAxe == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Axe1H, CripplingStrikes, Executioner = 35, 55, 25, 30, 130, 1, 1, 1
if APreWingedMace == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Duelist, DoubleGrip = 35, 55, 25, 40, 110, 1, 1
if APreGreatsword == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, TwoHander20 = 85, 100, 30, 25, 100, 1
if APreFlailDGrip == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Executioner, DoubleGrip = 25, 55, 35, 30, 100, 1, 1
if APreLongAxe == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Executioner = 70, 95, 30, 30, 110, 1
if APreMedXbow == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, XbowMastery = 40, 60, 25, 50, 70, 1
if APreNobleSword == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Duelist, DoubleGrip, CripplingStrikes, Executioner = 45, 50, 25, 20, 85, 1, 1, 1, 1
if APreWarbow == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CripplingStrikes, Executioner, MasterArcher, HeadHunter = 50, 70, 25, 35, 60, 1, 1, 1, 1
if APrePoleMace == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod = 60, 75, 30, 40, 120
if APreHandgonne == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Fearsome = 35, 75, 25, 25, 90, 1
if APre2HScimitar == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CleaverMastery, CripplingStrikes, Executioner = 65, 85, 25, 25, 110, 1, 1, 1
if APreQatal == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Duelist, DoubleGrip, Executioner = 30, 45, 25, 20, 70, 1, 1, 1
if APreFDirewolf == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Executioner, FrenziedDirewolf = 30, 50, 25, 20, 70, 1, 1
if APreNachTier3 == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod = 55, 80, 25, 10, 75
if APreLindwurm == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, Fearsome = 80, 140, 25, 35, 150, 1
if APreUnhold == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CripplingStrikes = 40, 80, 25, 40, 80, 1
if APreSchrat == 1:
Mind, Maxd, Headchance, Ignore, ArmorMod, CripplingStrikes = 70, 100, 25, 50, 80, 1
#Error Handling
if (Mind == 0 and Maxd == 0) or Mind < 0 or Maxd < 0:
sys.exit("Damage must be positive.")
if Mind > Maxd:
sys.exit("Min damage must be <= Max damage.")
if Ignore < 0:
sys.exit("Ignore must be positive.")
if ArmorMod <= 0:
sys.exit("Armor damage must be positive.")
if Def_HP <= 0 or Def_Helmet < 0 or Def_Armor < 0:
sys.exit("Hp and armor must be positive or 0.")
if Def_HP > 500 or Def_Helmet > 500 or Def_Armor > 500:
sys.exit("Hp and armor must be <= 500.")
if Trials < 2:
sys.exit("Trials must be >= 2.")
#Base damage modifiers:
if TwoHander20 == 1:
Mind += 20
Maxd += 20
#Headchance modifiers:
if Juggler == 1:
Headchance += 5
if Puncture == 1:
Headchance = 0
if KillerOnTheRun == 1:
Headchance += 10
if FlailLash == 1:
Headchance = 100
Headshotchance = Headchance
#Ignore modifiers:
Ignore = Ignore/100
if Flail2HPound == 1:
Flail2HBodyshot = Ignore + .1
Flail2HHeadshot = Ignore + .2
if FlailMastery == 1:
Flail2HHeadshot += .1
if Sword2HSplit == 1:
Ignore += .05
if Deathblow == 1:
Ignore += .2
if AimedShot == 1:
Ignore += .05
if XbowMastery == 1:
Ignore += .2
if Ambusher == 1:
Ignore *= 1.25
if Skirmisher == 1:
Ignore *= 1.25
if Overseer == 1:
Ignore *= 1.1
if Wolfrider == 1:
Ignore *= 1.25
if MasterArcher == 1:
Ignore *= 1.25
if Duelist == 1:
Ignore += .25
if AoE2HHammer == 1:
Ignore -= .1
if AoE2HAxe == 1:
Ignore -= .1
if Ignore > 1:
Ignore = 1
#Armor damage modifiers:
ArmorMod = ArmorMod/100
if BrigandLeader == 1:
ArmorMod += .2
#Fatigue force negative:
if Fatigue > 0 and Nimble == 1:
Fatigue *= -1
#Attachment modifiers:
AttachMod = 1
if UnholdFurCloak == 1:
AttachMod = .8
Def_Armor += 10
if HornPlate == 1:
AttachMod = .9
Def_Armor += 30
if SerpentSkin == 1:
AttachMod = .66
Def_Armor += 30
Fatigue -= 2
if Wolf_Hyena == 1:
Def_Armor += 15
if LindwurmCloak == 1:
Def_Armor += 60
Fatigue -= 3
if AdFurPad == 1:
AdFurPadMod = .66
Fatigue -= 2
else:
AdFurPadMod = 1
if Boneplate == 1:
Fatigue -= 2
#Nimble calculation:
def NimbleCalc():
global NimbleMod
NimFat = Fatigue
if NimFat > 0 and Nimble == 1:
NimFat *= -1
NimFat = min(0, NimFat + 15)
if Nimble == 1:
NimbleMod = 1.0 - 0.6 + pow(abs(NimFat),1.23)*.01
NimbleMod = min(1,NimbleMod)
else:
NimbleMod = 1
#Headshot damage modifiers:
HeadMod = 1.5
if SteelBrow == 1:
HeadMod = 1
else:
if Brute == 1:
HeadMod += .15
if Axe1H == 1:
HeadMod += .5
#HeadHunter
HHStack = 0
#Damage modifiers:
DamageMod = 1
if DoubleGrip == 1:
DamageMod *= 1.25
if Flail3Head == 1:
DamageMod *= .33
if Deathblow == 1:
DamageMod *= 1.33
if Spearwall == 1:
DamageMod *= .5
if R2Throw == 1:
DamageMod *= 1.3
if R3Throw == 1:
DamageMod *= 1.2
if Scatter == 1:
DamageMod *= .75
if KillingFrenzy == 1:
DamageMod *= 1.25
if Huge == 1:
DamageMod *= 1.1
if Tiny == 1:
DamageMod *= .85
if Drunkard == 1:
DamageMod *= 1.1
if BrokenArm == 1:
DamageMod *= .5
if SplitShoulder == 1:
DamageMod *= .5
if CutArmSinew == 1:
DamageMod *= .6
if InjuredShoulder == 1:
DamageMod *= .75
if Dazed == 1:
DamageMod *= .75
if Distracted == 1:
DamageMod *= .65
if Mushrooms == 1:
DamageMod *= 1.25
if Young == 1:
DamageMod *= 1.15
if Berserker == 1:
DamageMod *= 1.2
if BerserkerDay190 == 1:
DamageMod *= 1.3
if Warrior == 1:
DamageMod *= 1.15
if WarriorDay200 == 1:
DamageMod *= 1.25
if Warlord == 1:
DamageMod *= 1.35
if WarlordDay200 == 1:
DamageMod *= 1.45
if Conqueror == 1:
DamageMod *= 1.35
if FallenBetrayer == 1:
DamageMod *= 1.25
if FallenHeroDay100 == 1:
DamageMod *= 1.1
if ArmoredZombieDay100 == 1:
DamageMod *= 1.1
if BarbKing == 1:
DamageMod *= 1.2
if HedgeKnight == 1:
DamageMod *= 1.2
if FrenziedDirewolf == 1:
DamageMod *= 1.2
if UnholdDay90 == 1:
DamageMod *= 1.1
if LindwurmDay170 == 1:
DamageMod *= 1.1
if AimedShot == 1:
AimedShotMod = 1.1
else:
AimedShotMod = 1
#Injury rate modifiers:
InjuryMod = 1
if CripplingStrikes == 1:
InjuryMod *= 0.66
if Shamshir == 1:
InjuryMod *= 0.66
if ShamshirMastery == 1:
InjuryMod *= 0.5
if Ironjaw == 1:
InjuryMod *= 1.25
#Indomitable:
if Indomitable == 1:
IndomMod = .5
elif PossessedUndead == 1: #This works just like Indom and they will never be both used together, so I put this here instead of writing a new variable.
IndomMod = .75
else:
IndomMod = 1
#Racial defense modifier:
if SkeletonVsPierce == 1:
SkeletonMod = .5
elif SkeletonVsJavelin == 1:
SkeletonMod = .25
elif SkeletonVsArrow == 1:
SkeletonMod = .1
else:
SkeletonMod = 1
#Ijirok:
if IjirokHeal10 == 1:
IjirokHealing = 10
if IjirokHeal20 == 1:
IjirokHealing = 20
#Bleeding damage:
BleedDamage = 0
if CleaverBleed == 1:
BleedDamage = 5
if CleaverMastery == 1:
BleedDamage = 10
if Indomitable == 1 and BleedDamage > 0:
BleedDamage = math.floor(BleedDamage / 2)
print("-----") #Added for readability. If this annoys you then remove this line.
def calc():
global Headshotchance,Ignore, HHStack
#Lists for later analysis:
hits_until_death = [] #This list will hold how many hits until death for each iteration.
hits_until_1st_injury = [] #This list will hold how many hits until first injury for each iteration.
hits_until_1st_heavy_injury_chance = [] #This list will hold how many hits until a chance of heavy injury for each iteration.
hits_until_1st_morale = [] #This list will hold how many hits until first morale check for each iteration.
NumberFearsomeProcs = [] #This list will hold number of Fearsome procs for each iteration (only displays if Fearsome is checked).
Forge_bonus_armor = [] #This list will hold the amount of extra armor provided by Forge for each iteration (only displays if Forge is checked).
Total_Ijirok_Healing = [] #This list will hold the amount of total Ijirok healing from the Ijirok armor for each iteration (only displays if Ijirok switches are checked).
hits_until_1st_poison = [] #This list will hold how many hits until first poisoning against Ambushers (only displays if Ambusher is checked).
hits_until_1st_bleed = [] #This list will hold how many hits until first bleed against cleavers (only displays if CleaverBleed or CleaverMastery is checked).
print("HP = " + str(Def_HP) + ", Helmet = " + str(Def_Helmet) + ", Armor = " + str(Def_Armor))
NimbleCalc()
if Nimble == 1:
print ("Nimble%: " + str(NimbleMod))
#Begin the simulation.
for i in range(0,Trials): #This will run a number of trials as set above by the trials variable.
#Stat initialization:
hp = Def_HP
helmet = Def_Helmet
body = Def_Armor
#Sets various flags to a default state at the start of each new trial.
if HeadHunter == 1:
Headshotchance = Headchance
if Boneplate == 1:
BoneplateMod = 1
else:
BoneplateMod = 0
if NineLives == 1:
NineLivesMod = 1
else:
NineLivesMod = 0
if SplitMan == 1:
SplitManHeadFollowUp = 0
SplitManBodyFollowUp = 0
if GloriousEndurance: #The Bear Gladiator trait.
GloriousEnduranceStacks = 0
Injury = 0
HeavyInjuryChance = 0
UseHeadShotInjuryFormula = 0
UseHeadShotInjuryFormulaHeavy = 0
FirstMoraleCheck = 0
FearsomeProcs = 0
Bleedstack1T = 0
Bleedstack2T = 0
ForgeSaved = 0 #Tracker to add the amount of armor gained from Forge for each iteration.
Poison = 0 #Tracker for when first poisoning occurs against Ambushers.
Bleed = 0 #Tracker for when first bleeding occurs against cleavers.
IjirokTotalHeal = 0 #Tracker for amount of Ijirok healing received.
count = 0 #Number of hits until death. Starts at 0 and goes up after each attack.
while hp > 0: #Continue looping until death.
#Check various modifiers that change over the course of one's life. These will be re-checked after each attack.
#Decapitate:
if Decapitate == 1:
DecapMod = 2 - hp / Def_HP
elif SmartDecap50 == 1 and hp <= Def_HP / 2:
DecapMod = 2 - hp / Def_HP
elif SmartDecap33 == 1 and hp <= Def_HP / 3:
DecapMod = 2 - hp / Def_HP
else:
DecapMod = 1
#Destroy Armor:
if DestroyArmor == 1 and count == 0:
DArmorMod = 1.5
elif DestroyArmor == 1 and count == 1 and DestroyArmorTwice == 1:
DArmorMod = 1.5
elif DestroyArmorMastery == 1 and count == 0:
DArmorMod = 2
elif DestroyArmorMastery == 1 and count == 1 and DestroyArmorTwice == 1:
DArmorMod = 2
else:
DArmorMod = 1
#Battleforged:
if Forge == 1:
ForgeMod = 1 - ((helmet + body) *.0005)
if FallenBetrayerD == 1:
ForgeMod *= .75
else:
ForgeMod = 1
#Gladiator - The Bear - Glorious Endurance:
if GloriousEndurance == 1:
GladMod = max(1 - (.05 * GloriousEnduranceStacks),.75)
else:
GladMod = 1
#Executioner:
if Injury == 1 and Executioner == 1:
ExecMod = 1.2
else:
ExecMod = 1
#HeadHunter:
if HeadHunter == 1:
if HHStack == 1:
Headshotchance = 100
else:
Headshotchance = Headchance
#Combining various damage modifiers used in damage calculations:
HPDamageModifiers = NimbleMod * SkeletonMod * GladMod * IndomMod * DamageMod * ExecMod * AimedShotMod * DecapMod
ArmorDamageModifiers = ArmorMod * GladMod * IndomMod * DamageMod * ExecMod
#Begin damage rolls:
hp_roll = random.randint(Mind,Maxd) #Random roll to determine unmodified hp damage.
head_roll = random.randint(1,100) #Random roll to determine if hit is a headshot.
if head_roll <= Headshotchance: #If headshot, do the following code blocks.
#Headshot Injury Flag -- Headshot injuries use a different formula. This flag will signal later when Injury is checked.
UseHeadShotInjuryFormula = 1
UseHeadShotInjuryFormulaHeavy = 1
#HeadHunter check -- Lose current stack if you had one. Gain stack if you didn't.
if HeadHunter == 1:
if HHStack == 0:
HHStack = 1
elif HHStack == 1:
HHStack = 0
#Split Man Flag -- If SplitMan is being used, this will trigger a follow up body hit later in the code.
if SplitMan == 1:
SplitManBodyFollowUp = 1
#2H Flail Check -- Have a higher armor ignoring% on Pound for headshots compared to bodyshots.
if Flail2HPound == 1:
Ignore = Flail2HHeadshot
#Begin damage calculation.
#Destroy armor check -- if Destroy Armor special is active do this code block and skip the rest.
if DArmorMod != 1:
hp_roll = 10 #DestroyArmor forces hp damage to = 10.
armor_roll = random.randint(Mind,Maxd) * ArmorDamageModifiers * DArmorMod
ForgeSaved += armor_roll - armor_roll * ForgeMod
armor_roll = math.floor(min(helmet,(armor_roll * ForgeMod)))
helmet -= armor_roll
#If not DestroyArmor, and no armor is present, apply damage directly to hp. Damage formula still distincts armor ignore vs. non armor ignore despite no armor present.
elif helmet == 0:
Non_Ignore_Damage = math.floor(hp_roll * (1 - Ignore) * HPDamageModifiers) #Non armor ignoring side of the damage formula. Gets rounded down.
Armor_Ignore_Damage = hp_roll * Ignore * HPDamageModifiers #Armor ignoring side of the damage formula.
hp_roll = math.floor((Armor_Ignore_Damage + Non_Ignore_Damage) * HeadMod) #Adding both sides of the formula together. Applies headshot modifier. Rounds down after.
#Otherwise (armor is present), do the following.
else: #Starts by calculating armor damage.
armor_roll = random.randint(Mind,Maxd) * ArmorDamageModifiers
ForgeSaved += armor_roll - armor_roll * ForgeMod #Calculate how much armor is saved by Forge.
armor_roll = math.floor(min(helmet,(armor_roll * ForgeMod))) #Applying Forge, and armor damage cannot exceed current armor.
helmet -= armor_roll #Armor damage applied to helmet.
#If the helmet does not get destroyed by the attack, do the following.
if helmet > 0: #Helmet was not destroyed. We are calculating how much armor ignoring hp damage is dealt.
hp_roll = math.floor(max(0,(hp_roll * Ignore * HPDamageModifiers - (helmet * 0.1)) * HeadMod))
#If the helmet did get destroyed by the attack, do the following to see how much hp damage is dealt.
else: #Damage is split between armor ignoring damage and non-ignoring damage. Non-ignoring damage cannot be negative but it can be zero.
Non_Ignore_Damage = math.floor(max(0,(hp_roll * (1 - Ignore) * HPDamageModifiers - armor_roll)))
Armor_Ignore_Damage = hp_roll * Ignore * HPDamageModifiers
hp_roll = math.floor((Armor_Ignore_Damage + Non_Ignore_Damage) * HeadMod) #Adding both sides of the formula together. Applies headshot modifier. Rounds down after.
else: #If not a headshot, do the following.
#2H Flail Check -- Have a higher armor ignoring% on Pound for headshots compared to bodyshots.
if Flail2HPound == 1:
Ignore = Flail2HBodyshot
#Split Man Flag -- If SplitMan is being used, this will trigger a follow up head hit later in the code.
if SplitMan == 1:
SplitManHeadFollowUp = 1
#Bone Plates check -- Attack is negated if Boneplates are online, then turns off Boneplates until next trial.
if BoneplateMod == 1 and Puncture != 1:
BoneplateMod = 0
hp_roll = 0
else:
if DArmorMod != 1:
hp_roll = 10
armor_roll = random.randint(Mind,Maxd) * ArmorDamageModifiers * DArmorMod
ForgeSaved += armor_roll - armor_roll * ForgeMod
armor_roll = math.floor(min(body,(armor_roll * ForgeMod)))
body -= armor_roll
elif Puncture == 1: #Puncture ignores armor entirely, including attachments.
hp_roll = math.floor(hp_roll * HPDamageModifiers)
elif body == 0: #If no armor is present, do the following.
Non_Ignore_Damage = math.floor(hp_roll * (1 - Ignore) * HPDamageModifiers * AttachMod)
Armor_Ignore_Damage = hp_roll * Ignore * HPDamageModifiers * AttachMod
hp_roll = math.floor(Armor_Ignore_Damage + Non_Ignore_Damage)
else:
armor_roll = random.randint(Mind,Maxd) * ArmorDamageModifiers * AttachMod
ForgeSaved += armor_roll - armor_roll * ForgeMod
armor_roll = math.floor(min(body,(armor_roll * ForgeMod)))
body -= armor_roll
if body > 0:
hp_roll = math.floor(max(0,(hp_roll * Ignore * HPDamageModifiers * AdFurPadMod * AttachMod - (body * 0.1))))
else:
Non_Ignore_Damage = math.floor(max(0,(hp_roll * (1 - Ignore * AdFurPadMod) * HPDamageModifiers * AttachMod - armor_roll)))
Armor_Ignore_Damage = hp_roll * Ignore * HPDamageModifiers * AdFurPadMod * AttachMod
hp_roll = math.floor(Armor_Ignore_Damage + Non_Ignore_Damage)
#Apply damage to defender:
if Hammer10 == 1: #1H Hammer check to do at least 10 hp damage.
hp_roll = max(hp_roll,10)
hp -= hp_roll #Reducing defender hp.
#Gladiator - Bear trait. Add a stack:
if GloriousEndurance == 1:
GloriousEnduranceStacks += 1
count += 1 #Add +1 to the number of hits taken.
if count > 500: #This if statement is here to prevent accidental infinite loops with Ijirok armor, or simply any abnormal testing scenario that would take a very long time to compute.
print("Defender is surviving over 500 attacks, please adjust testing parameters.")
exit()
#Injury check:
if (hp > 0 or NineLivesMod == 1) and Undead != 1 and Savant != 1:
if Injury == 0:
if UseHeadShotInjuryFormula == 1: #Use headshot injury formula.
InjuryThreshold = 0.3125 * InjuryMod #Base injury rate is 0.25 * 1.25 (headshot) * InjuryMod (Crippling, Shamshir, Ironjaw)
if math.floor(hp_roll) >= Def_HP * InjuryThreshold:
Injury = 1
if Flail3Head == 1:
hits_until_1st_injury.append(math.ceil(count/3))
else:
hits_until_1st_injury.append(count)
UseHeadShotInjuryFormula = 0
else: #Use body injury formula.
InjuryThreshold = 0.25 * InjuryMod #Base injury rate is 0.25 * InjuryMod (Crippling, Shamshir, Ironjaw)
if math.floor(hp_roll) >= Def_HP * InjuryThreshold:
Injury = 1
if Flail3Head == 1:
hits_until_1st_injury.append(math.ceil(count/3))
else:
hits_until_1st_injury.append(count)
#Heavy injury check: Heavy injuries are not guaranteed even when conditions are met, so this is only checking for chance of heavy injury.
if HeavyInjuryChance == 0:
if UseHeadShotInjuryFormulaHeavy == 1: #Use headshot heavy injury formula.
InjuryThreshold = 0.625 * InjuryMod #Base heavy injury rate is 0.5 * 1.25 (headshot) * InjuryMod (Crippling, Shamshir, Ironjaw)
if math.floor(hp_roll) >= Def_HP * InjuryThreshold:
HeavyInjuryChance = 1
if Flail3Head == 1:
hits_until_1st_heavy_injury_chance.append(math.ceil(count/3))
else:
hits_until_1st_heavy_injury_chance.append(count)
UseHeadShotInjuryFormulaHeavy = 0
else: #Use body heavy injury formula.
InjuryThreshold = 0.5 * InjuryMod #Base heavy injury rate is 0.5 * InjuryMod (Crippling, Shamshir, Ironjaw)
if math.floor(hp_roll) >= Def_HP * InjuryThreshold:
HeavyInjuryChance = 1
if Flail3Head == 1:
hits_until_1st_heavy_injury_chance.append(math.ceil(count/3))
else:
hits_until_1st_heavy_injury_chance.append(count)
#SplitMan secondary hits: The following code block accounts for the extra hit for SplitMan
if SplitMan == 1:
#Before calculating damage for the second hit, we need to re-evaluate the value of Forge, Bear trait, and Executioner if they are in play, to account for damage taken by the first hit.
#Battleforged:
if Forge == 1:
ForgeMod = 1 - ((helmet + body) *.0005)
else:
ForgeMod = 1
#Gladiator - The Bear - Glorious Endurance:
if GloriousEndurance == 1:
GladMod = max(1 - (.05 * GloriousEnduranceStacks),.75)
else:
GladMod = 1
#Executioner:
if Injury == 1 and Executioner == 1:
ExecMod = 1.2
else:
ExecMod = 1
#If SplitMan is active, do the following code block for the bonus body hit if the original hit was a headshot.
if SplitManBodyFollowUp == 1:
SplitManBodyFollowUp = 0
if BoneplateMod == 1:
BoneplateMod = 0
SMhp_roll = 0
else:
SMhp_roll = random.randint(Mind,Maxd) * .5 #Split Man has a 50% damage modifier.
if body == 0:
Non_Ignore_Damage = math.floor(SMhp_roll * (1 - Ignore) * HPDamageModifiers * AttachMod)
Armor_Ignore_Damage = SMhp_roll * Ignore * HPDamageModifiers * AttachMod
SMhp_roll = math.floor(Armor_Ignore_Damage + Non_Ignore_Damage)
else:
SMarmor_roll = random.randint(Mind,Maxd) * .5 * ArmorDamageModifiers * AttachMod
ForgeSaved += SMarmor_roll - SMarmor_roll * ForgeMod
SMarmor_roll = math.floor(min(body,(SMarmor_roll * ForgeMod)))
body -= SMarmor_roll
if body > 0:
SMhp_roll = math.floor(max(0,(SMhp_roll * Ignore * HPDamageModifiers * AdFurPadMod * AttachMod - (body * 0.1))))
else:
Non_Ignore_Damage = math.floor(max(0,(SMhp_roll * (1 - Ignore * AdFurPadMod) * HPDamageModifiers * AttachMod - SMarmor_roll)))
Armor_Ignore_Damage = SMhp_roll * Ignore * HPDamageModifiers * AdFurPadMod * AttachMod
SMhp_roll = math.floor(Armor_Ignore_Damage + Non_Ignore_Damage)
#Applying damage to defender hp.
hp -= SMhp_roll
#If SplitMan is active, do the following code block for the bonus head hit if the original hit was a body hit. Split Man secondary hit does not get a headshot bonus.
if SplitManHeadFollowUp == 1:
SplitManHeadFollowUp = 0
SMhp_roll = random.randint(Mind,Maxd) * .5
if helmet == 0:
Non_Ignore_Damage = math.floor(SMhp_roll * (1 - Ignore) * HPDamageModifiers) #Non armor ignoring side of the damage formula. Gets rounded down.
Armor_Ignore_Damage = SMhp_roll * Ignore * HPDamageModifiers #Armor ignoring side of the damage formula.
SMhp_roll = math.floor(Armor_Ignore_Damage + Non_Ignore_Damage) #Adding both sides of the formula together. Applies headshot modifier. Rounds down after.
else:
SMarmor_roll = random.randint(Mind,Maxd) * .5 * ArmorDamageModifiers
ForgeSaved += SMarmor_roll - SMarmor_roll * ForgeMod
SMarmor_roll = math.floor(min(helmet,(SMarmor_roll * ForgeMod)))
helmet -= SMarmor_roll
if helmet > 0:
SMhp_roll = math.floor(max(0,(SMhp_roll * Ignore * HPDamageModifiers - (helmet * 0.1))))
else:
Non_Ignore_Damage = math.floor(max(0,(SMhp_roll * (1 - Ignore) * HPDamageModifiers - SMarmor_roll)))
Armor_Ignore_Damage = SMhp_roll * Ignore * HPDamageModifiers
SMhp_roll = math.floor(Armor_Ignore_Damage + Non_Ignore_Damage) #Adding both sides of the formula together. Applies headshot modifier. Rounds down after.
#Applying damage to defender hp.
hp -= SMhp_roll
#Gladiator - Bear trait check: Add another stack for the Bear to account for the second hit from Split Man
if GloriousEndurance == 1:
GloriousEnduranceStacks += 1
#Morale check:
if FirstMoraleCheck == 0:
if Fearsome == 1:
if math.floor(hp_roll) > 0:
FirstMoraleCheck = 1
hits_until_1st_morale.append(count)
else:
if math.floor(hp_roll) >= 15:
FirstMoraleCheck = 1
hits_until_1st_morale.append(count)
#Fearsome:
if Fearsome == 1:
if Flail3Head != 1:
if math.floor(hp_roll) > 0 and math.floor(hp_roll) < 15:
FearsomeProcs += 1
else:
if Flail3Head == 1 and count % 3 == 1:
if math.floor(hp_roll) > 0 and math.floor(hp_roll) < 15:
FearsomeProcs += 1
#Ijirok armor check:
if (hp > 0 or NineLivesMod == 1) and (IjirokHeal10 == 1 or IjirokHeal20 == 1):
if Ijirok1TurnHeal == 1: #Block to apply healing after every attack.
hp = hp + IjirokHealing #Applying Healing
IjirokTotalHeal += IjirokHealing #Tracking HP Healed for later analysis.
if hp > Def_HP: #Block to ensure HP doesn't exceed max.
IjirokTotalHeal -= (hp - Def_HP)
hp = Def_HP
elif Ijirok2TurnHeal == 1: #Block to apply healing every other attack.
if count % 2 == 0:
hp = hp + IjirokHealing
IjirokTotalHeal += IjirokHealing
if hp > Def_HP:
IjirokTotalHeal -= (hp - Def_HP)
hp = Def_HP
#Bleeding check:
if (CleaverBleed == 1 or CleaverMastery == 1) and Undead != 1:
#If damage taken >= 6 and Decapitate isn't in play, then apply a 2 turn bleed stack.
if math.floor(hp_roll) >= 6 and DecapMod == 1 and Decapitate != 1:
Bleedstack2T += 1
#Track fist instance of bleed for later data return.
if Bleed == 0:
Bleed = 1
hits_until_1st_bleed.append(count)
#Every two attacks (1 turn for Cleavers), apply bleed damage based on current bleed stacks.
#If Resilient, 2 turn bleed stacks apply damage and then are removed. Otherwise 2 turn bleed stacks apply damage and convert into 1 turn bleed stacks.
if count % 2 == 0:
if Resilient == 1:
hp -= BleedDamage * Bleedstack2T
Bleedstack2T = 0
else:
hp -= BleedDamage * Bleedstack1T
Bleedstack1T = Bleedstack2T
hp -= BleedDamage * Bleedstack2T
Bleedstack2T = 0
#Poison check:
if Ambusher == 1:
if Poison == 0:
if math.floor(hp_roll) >= 6:
Poison = 1
hits_until_1st_poison.append(count)
#If death occurs, check for NineLives and otherwise add the hitcount to the list for later analysis and start the next trial.
if hp <= 0:
if NineLivesMod == 1:
hp = random.randint(11,15)
NineLivesMod = 0
Bleedstack1T = 0
Bleedstack2T = 0
else:
if Forge == 1:
Forge_bonus_armor.append(ForgeSaved)
if (IjirokHeal10 == 1 or IjirokHeal20 == 1) and (Ijirok1TurnHeal == 1 or Ijirok2TurnHeal == 1):
Total_Ijirok_Healing.append(IjirokTotalHeal)
if Fearsome == 1:
NumberFearsomeProcs.append(FearsomeProcs)
if Flail3Head == 1:
hits_until_death.append(math.ceil(count/3))
else:
hits_until_death.append(count)
#Check if the following trackers were hit and if not, append the time until death to their lists for later analysis instead of having an empty data point.
if Injury == 0:
if Flail3Head == 1:
hits_until_1st_injury.append(math.ceil(count/3))
else:
hits_until_1st_injury.append(count)
if HeavyInjuryChance == 0:
if Flail3Head == 1:
hits_until_1st_heavy_injury_chance.append(math.ceil(count/3))
else:
hits_until_1st_heavy_injury_chance.append(count)
#Analysis on data collection:
HitsToDeath = statistics.mean(hits_until_death)
StDev = statistics.stdev(hits_until_death)
hits_until_death.sort()
HitsToDeathCounter = collections.Counter(hits_until_death)
HitsToDeathPercent = [(i,HitsToDeathCounter[i]/len(hits_until_death)*100) for i in HitsToDeathCounter]
if Undead != 1 and Savant != 1:
if len(hits_until_1st_injury) != 0:
hits_to_injure = statistics.mean(hits_until_1st_injury)
hits_until_1st_injury.sort()
HitsToInjureCounter = collections.Counter(hits_until_1st_injury)
HitsToInjurePercent = [(i,HitsToInjureCounter[i]/len(hits_until_death)*100) for i in HitsToInjureCounter]
if len(hits_until_1st_heavy_injury_chance) != 0:
hits_to_1st_heavy_injury_chance = statistics.mean(hits_until_1st_heavy_injury_chance)
hits_until_1st_heavy_injury_chance.sort()
HitsToHeavyInjuryChanceCounter = collections.Counter(hits_until_1st_heavy_injury_chance)
HitsToHeavyInjuryChancePercent = [(i,HitsToHeavyInjuryChanceCounter[i]/len(hits_until_death)*100) for i in HitsToHeavyInjuryChanceCounter]
if len(hits_until_1st_morale) != 0:
hits_to_morale = statistics.mean(hits_until_1st_morale)
hits_until_1st_morale.sort()
HitsToMoraleCounter = collections.Counter(hits_until_1st_morale)
HitsToMoralePercent = [(i,HitsToMoraleCounter[i]/len(hits_until_death)*100) for i in HitsToMoraleCounter]
if Fearsome == 1:
AvgFearsomeProcs = statistics.mean(NumberFearsomeProcs)
if Forge == 1:
if len(Forge_bonus_armor) != 0:
AvgForgeArmor = statistics.mean(Forge_bonus_armor)
if (IjirokHeal10 == 1 or IjirokHeal20 == 1) and (Ijirok1TurnHeal == 1 or Ijirok2TurnHeal == 1):
if len(Total_Ijirok_Healing) != 0:
AvgIjirokHealing = statistics.mean(Total_Ijirok_Healing)
if Ambusher == 1:
if len(hits_until_1st_poison) != 0:
hits_to_posion = statistics.mean(hits_until_1st_poison)
if (CleaverBleed == 1 or CleaverMastery == 1):
if len(hits_until_1st_bleed) != 0:
hits_to_bleed = statistics.mean(hits_until_1st_bleed)
#Results:
if DeathMean == 1:
print("Death in " + str(HitsToDeath) + " hits on average.")
if DeathStDev == 1:
print("StDev: " + str(StDev))
if DeathPercent == 1:
print("% Hits to die: " + str(HitsToDeathPercent))
if Undead != 1 and Savant != 1:
if hits_to_injure >= HitsToDeath:
if InjuryMean == 1 or InjuryPercent == 1:
print("No chance of injury.")
else:
if InjuryMean == 1:
print("First injury in " + str(hits_to_injure) + " hits on average.")
if InjuryPercent == 1:
print("% First injury in: " + str(HitsToInjurePercent))
if hits_to_1st_heavy_injury_chance >= HitsToDeath: