-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
1114 lines (1049 loc) · 42 KB
/
main.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
# Design Notes #
# This program should be able to take in a multitude of csv files including Species, Class, Gender, Alignment, Attitude, CR, Goal/Motivation, and more.
# This program should take values from the listed CSV files and combine them into Unique and memorable NPCs.
# This program should be able to then take these generated NPCs and export them to a json file that is compatible with Alchemy.
# Extended Features #
# A GUI that allows for editing of any of the generated values.
# Name Generation.
# Stat Generation. DONE
# interpreting personality from Species, Class, and Alignment.
# Notes #
# Would like to implement Skills/Proficiencies sooner rather than later. DONE
# Proficiency Bonus, HP based on level and Class, AC based on level dex score and pb? Initative Bonus. DONE (Although AC is simplified, may want to change later)
# Set Tracker HP to match NPC HP. DONE (Maybe alter die size based on class later) DONE
# Saving throw proficiencies. DONE
# Auto-Generate a set of actions based on class?
# Make Species actually respect their rarity. DONE
# Make a setting to force a certain level or level range.
# Bugs #
# Direct editing a class will result in N/A saving throws.
# Direct editing a class will result in inaccurate HP generation(?).
# Alchemy update broke HP generation.
# Imports #
import csv
import random
import json
import time
import math
# Species #
def SpeciesGen(Classification, PHBCLASSES):
if PHBCLASSES == False:
if Classification == "":
ClassificationRandom = random.randint(1, 12)
elif Classification == "Naturalborn":
ClassificationRandom = 5
elif Classification == "Oddity":
ClassificationRandom = 10
elif Classification == "Outlander":
ClassificationRandom = 15
if ClassificationRandom < 7:
NaturalbornRandom = random.randint(1, 200)
if NaturalbornRandom <= 3:
SPECIES = "Aasimar"
elif NaturalbornRandom <= 11:
SPECIES = "Dragonborn (Chromatic)"
elif NaturalbornRandom <= 19:
SPECIES = "Dragonborn (Metallic)"
elif NaturalbornRandom <= 22:
SPECIES = "Dwarf (Gray)(Duergar)"
elif NaturalbornRandom <= 26:
SPECIES = "Dwarf (Hill)"
elif NaturalbornRandom <= 30:
SPECIES = "Dwarf (Mountain)"
elif NaturalbornRandom <= 32:
SPECIES = "Dwarf (Seaborn)"
elif NaturalbornRandom <= 35:
SPECIES = "Dwarf (Strongblood)"
elif NaturalbornRandom <= 37:
SPECIES = "Elf (Ash)"
elif NaturalbornRandom <= 40:
SPECIES = "Elf (Dark)(Drow)"
elif NaturalbornRandom <= 45:
SPECIES = "Elf (High)"
elif NaturalbornRandom <= 47:
SPECIES = "Elf (Sea)"
elif NaturalbornRandom <= 52:
SPECIES = "Elf (Wood)"
elif NaturalbornRandom <= 53:
SPECIES = "Faunus (Bear)"
elif NaturalbornRandom <= 54:
SPECIES = "Faunus (Bird)"
elif NaturalbornRandom <= 55:
SPECIES = "Faunus (Cat)"
elif NaturalbornRandom <= 56:
SPECIES = "Faunus (Cow/Bull)"
elif NaturalbornRandom <= 57:
SPECIES = "Faunus (Deer)"
elif NaturalbornRandom <= 58:
SPECIES = "Faunus (Dog)"
elif NaturalbornRandom <= 59:
SPECIES = "Faunus (Fox)"
elif NaturalbornRandom <= 60:
SPECIES = "Faunus (Horse)"
elif NaturalbornRandom <= 61:
SPECIES = "Faunus (Pig)"
elif NaturalbornRandom <= 62:
SPECIES = "Faunus (Rabbit)"
elif NaturalbornRandom <= 63:
SPECIES = "Faunus (Raccoon)"
elif NaturalbornRandom <= 64:
SPECIES = "Faunus (Sheep)"
elif NaturalbornRandom <= 65:
SPECIES = "Faunus (Wolf)"
elif NaturalbornRandom <= 69:
SPECIES = "Gnome (Deep)"
elif NaturalbornRandom <= 74:
SPECIES = "Gnome (Forest)"
elif NaturalbornRandom <= 78:
SPECIES = "Gnome (Rock)"
elif NaturalbornRandom <= 81:
SPECIES = "Goblin"
elif NaturalbornRandom <= 84:
SPECIES = "Goblin (Hoardshine)"
elif NaturalbornRandom <= 86:
SPECIES = "Goliath"
elif NaturalbornRandom <= 87:
SPECIES = "Goliath (Cloudborn)"
elif NaturalbornRandom <= 88:
SPECIES = "Goliath (Fireborn)"
elif NaturalbornRandom <= 89:
SPECIES = "Goliath (Frostborn)"
elif NaturalbornRandom <= 90:
SPECIES = "Goliath (Hillborn)"
elif NaturalbornRandom <= 91:
SPECIES = "Goliath (Stoneborn)"
elif NaturalbornRandom <= 104:
SPECIES = "Half-Elf"
elif NaturalbornRandom <= 110:
SPECIES = "Half-Orc"
elif NaturalbornRandom <= 113:
SPECIES = "Half-Orc (Coldheart)"
elif NaturalbornRandom <= 118:
SPECIES = "Halfling (Lightfoot)"
elif NaturalbornRandom <= 121:
SPECIES = "Halfling (Lotusden)"
elif NaturalbornRandom <= 125:
SPECIES = "Halfling (Stout)"
elif NaturalbornRandom <= 141:
SPECIES = "Human"
elif NaturalbornRandom <= 147:
SPECIES = "Kobold"
elif NaturalbornRandom <= 156:
SPECIES = "Leonin"
elif NaturalbornRandom <= 169:
SPECIES = "Orc"
elif NaturalbornRandom <= 175:
SPECIES = "Tabaxi"
elif NaturalbornRandom <= 178:
SPECIES = "Tabaxi (Softpaw)"
elif NaturalbornRandom <= 191:
SPECIES = "Tiefling"
elif NaturalbornRandom <= 200:
SPECIES = "Tortle"
# csvfile = open(r"Lists\Naturalborn.csv", "r")
# SPECIES = list(csv.reader(csvfile, delimiter=','))
# selected_row = random.choice(SPECIES) # Select a random row (list)
# SPECIES = ','.join(selected_row) # Convert the list to a comma-separated string
# if SPECIES == 'Aasimar':
# SPECIES = 'Aasimar'
elif ClassificationRandom < 11:
OddityRandom = random.randint(1, 200)
if OddityRandom <= 12:
SPECIES = "Aarakocra"
elif OddityRandom <= 18:
SPECIES = "Aasimar (Mystic)"
elif OddityRandom <= 26:
SPECIES = "Dragonborn (Gem)"
elif OddityRandom <= 32:
SPECIES = "Dragonborn (Radiant)"
elif OddityRandom <= 40:
SPECIES = "Elf (Pallid)"
elif OddityRandom <= 46:
SPECIES = "Halfling (Jinx)"
elif OddityRandom <= 52:
SPECIES = "Kalashtar"
elif OddityRandom <= 57:
SPECIES = "Kenku"
elif OddityRandom <= 60:
SPECIES = "Kenku (Harrowfeather)"
elif OddityRandom <= 63:
SPECIES = "Kenku (Shroudeye)"
elif OddityRandom <= 64:
SPECIES = "Lineage (Dhampir)"
elif OddityRandom <= 65:
SPECIES = "Lineage (Disembodied)"
elif OddityRandom <= 66:
SPECIES = "Lineage (Hexblood)"
elif OddityRandom <= 68:
SPECIES = "Lineage (Reborn)"
elif OddityRandom <= 71:
SPECIES = "Lupin (Fabled)"
elif OddityRandom <= 74:
SPECIES = "Lupin (Isolated)"
elif OddityRandom <= 77:
SPECIES = "Lupin (Leader)"
elif OddityRandom <= 84:
SPECIES = "Lupin (Pack)"
elif OddityRandom <= 85:
SPECIES = "Lustrous (Ore)"
elif OddityRandom <= 87:
SPECIES = "Lustrous (Precious)"
elif OddityRandom <= 89:
SPECIES = "Lustrous (Semi-Precious)"
elif OddityRandom <= 101:
SPECIES = "Macawkra"
elif OddityRandom <= 103:
SPECIES = "Nymph (Alseid)"
elif OddityRandom <= 105:
SPECIES = "Nymph (Asteria)"
elif OddityRandom <= 108:
SPECIES = "Nymph (Aurae)"
elif OddityRandom <= 110:
SPECIES = "Nymph (Dryad)"
elif OddityRandom <= 112:
SPECIES = "Nymph (Lampad)"
elif OddityRandom <= 114:
SPECIES = "Nymph (Naiad)"
elif OddityRandom <= 116:
SPECIES = "Nymph (Oread)"
elif OddityRandom <= 128:
SPECIES = "Owlin"
elif OddityRandom <= 134:
SPECIES = "Rakin (Posskin)"
elif OddityRandom <= 140:
SPECIES = "Rakin (Tanukin)"
elif OddityRandom <= 146:
SPECIES = "Rakin (Urkin)"
elif OddityRandom <= 152:
SPECIES = "Ratfolk (Packrat)"
elif OddityRandom <= 158:
SPECIES = "Ratfolk (Ratical)"
elif OddityRandom <= 164:
SPECIES = "Ratfolk (Scourgerat)"
elif OddityRandom <= 170:
SPECIES = "Tengu"
elif OddityRandom <= 182:
SPECIES = "Tiefling (Amethyst Bloodline)"
elif OddityRandom <= 194:
SPECIES = "Tiefling (Gold Bloodline)"
elif OddityRandom <= 200:
SPECIES = "Warforged"
# csvfile = open(r"Lists\Oddity.csv", "r")
# SPECIES = list(csv.reader(csvfile, delimiter=','))
# selected_row = random.choice(SPECIES) # Select a random row (list)
# SPECIES = ','.join(selected_row) # Convert the list to a comma-separated string
# if SPECIES == 'Aarakocra':
# SPECIES = 'Aarakocra'
else:
OutlanderRandom = random.randint(1, 200)
if OutlanderRandom <= 9:
SPECIES = "Aasimar (Cosmic)"
elif OutlanderRandom <= 17:
SPECIES = "Aasimar (Elfriche)"
elif OutlanderRandom <= 28:
SPECIES = "Changeling"
elif OutlanderRandom <= 44:
SPECIES = "Dragonborn (Faerie)"
elif OutlanderRandom <= 55:
SPECIES = "Dragonborn (Moonstone)"
elif OutlanderRandom <= 71:
SPECIES = "Elf (Eladrin)"
elif OutlanderRandom <= 87:
SPECIES = "Elf (Shadar-kai)"
elif OutlanderRandom <= 93:
SPECIES = "Elf (Snow)"
elif OutlanderRandom <= 104:
SPECIES = "Firbolg"
elif OutlanderRandom <= 110:
SPECIES = "Genasi (Air)"
elif OutlanderRandom <= 116:
SPECIES = "Genasi (Earth)"
elif OutlanderRandom <= 122:
SPECIES = "Genasi (Fire)"
elif OutlanderRandom <= 128:
SPECIES = "Genasi (Water)"
elif OutlanderRandom <= 131:
SPECIES = "Lunarran (Bloodmoon)"
elif OutlanderRandom <= 134:
SPECIES = "Lunarran (Bluemoon)"
elif OutlanderRandom <= 137:
SPECIES = "Lunarran (Crescent)"
elif OutlanderRandom <= 140:
SPECIES = "Lunarran (Waning)"
elif OutlanderRandom <= 148:
SPECIES = "Metallus (Alloy)"
elif OutlanderRandom <= 156:
SPECIES = "Metallus (Gold)"
elif OutlanderRandom <= 164:
SPECIES = "Opteran (Cityborn)"
elif OutlanderRandom <= 172:
SPECIES = "Opteran (Natureborn)"
elif OutlanderRandom <= 181:
SPECIES = "Tlakah (High Senye)"
elif OutlanderRandom <= 190:
SPECIES = "Tlakah (Low Senye)"
elif OutlanderRandom <= 200:
SPECIES = "Tlakah (Mid Senye)"
# csvfile = open(r"Lists\Outlander.csv", "r")
# SPECIES = list(csv.reader(csvfile, delimiter=','))
# selected_row = random.choice(SPECIES) # Select a random row (list)
# SPECIES = ','.join(selected_row) # Convert the list to a comma-separated string
# if SPECIES == 'Aasimar (Cosmic)':
# SPECIES = 'Aasimar (Cosmic)'
else:
PHBList = ['Dwarf', 'Elf', 'Halfling', 'Human', 'Dragonborn', 'Gnome', 'Half-Elf', 'Half-Orc', 'Tiefling']
SPECIES = random.choice(PHBList)
return SPECIES
# Class #
def ClassGen(CLASSTOGGLE, INCLUDEHOMEBREWCLASSES):
if CLASSTOGGLE == False:
ClassRandom = random.randint(1, 20)
else:
ClassRandom = 20
SAVE1 = "N/A"
SAVE2 = "N/A"
if ClassRandom < 19:
CommonerRandom = random.randint(1, 100)
if ClassRandom < 80:
CLASS = "Commoner"
MAINSTAT = "RAND"
SECONDSTAT = "RAND"
HITDIE = 4
else:
if CommonerRandom < 80:
CLASS = "Commoner"
MAINSTAT = "RAND"
SECONDSTAT = "RAND"
HITDIE = 4
elif CommonerRandom == 80:
CLASS = "Alchemist"
if random.randint(1, 2) == 1:
MAINSTAT = "wis"
else:
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 81:
CLASS = "Artificer"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 82:
CLASS = "Blacksmith"
MAINSTAT = "str"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 83:
CLASS = "Brewer"
MAINSTAT = "wis"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 84:
CLASS = "Carpenter"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 85:
CLASS = "Cobbler"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 86:
CLASS = "Cook"
MAINSTAT = "wis"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 87:
CLASS = "Enchanter"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 88:
CLASS = "Engineer"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 89:
CLASS = "Glassblower"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 90:
CLASS = "Jeweler"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 91:
CLASS = "Leatherworker"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 92:
CLASS = "Mason"
MAINSTAT = "str"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 93:
CLASS = "Painter"
MAINSTAT = "wis"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 94:
CLASS = "Poisoner"
if random.randint(1, 2) == 1:
MAINSTAT = "wis"
else:
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 95:
CLASS = "Scroll Scriber"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 96:
CLASS = "Tailor"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 97:
CLASS = "Tinkerer"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 98:
CLASS = "Wand Whittler"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 99:
CLASS = "Weaver"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
elif CommonerRandom == 100:
CLASS = "Wood Carver"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 6
else:
if INCLUDEHOMEBREWCLASSES == False:
PClassRandom = random.randint(1, 14)
if PClassRandom == 1:
CLASS = "Artificer"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Constitution"
SAVE2 = "Intelligence"
elif PClassRandom == 2:
CLASS = "Barbarian"
MAINSTAT = "str"
SECONDSTAT = "con"
HITDIE = 12
SAVE1 = "Strength"
SAVE2 = "Constitution"
elif PClassRandom == 3:
CLASS = "Bard"
MAINSTAT = "cha"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Dexterity"
SAVE2 = "Charisma"
elif PClassRandom == 4:
CLASS = "Bloodhunter"
MAINSTAT = "dex"
SECONDSTAT = "int"
HITDIE = 10
SAVE1 = "Dexterity"
SAVE2 = "Intelligence"
elif PClassRandom == 5:
CLASS = "Cleric"
MAINSTAT = "wis"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Wisdom"
SAVE2 = "Charisma"
elif PClassRandom == 6:
CLASS = "Druid"
MAINSTAT = "wis"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Intelligence"
SAVE2 = "Wisdom"
elif PClassRandom == 7:
CLASS = "Fighter"
if random.randint(1, 2) == 1:
MAINSTAT = "str"
else:
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 10
SAVE1 = "Strength"
SAVE2 = "Constitution"
elif PClassRandom == 8:
CLASS = "Monk"
MAINSTAT = "dex"
SECONDSTAT = "wis"
HITDIE = 8
SAVE1 = "Strength"
SAVE2 = "Dexterity"
elif PClassRandom == 9:
CLASS = "Paladin"
MAINSTAT = "cha"
SECONDSTAT = "str"
HITDIE = 10
SAVE1 = "Wisdom"
SAVE2 = "Charisma"
elif PClassRandom == 10:
CLASS = "Ranger"
MAINSTAT = "dex"
SECONDSTAT = "wis"
HITDIE = 10
SAVE1 = "Strength"
SAVE2 = "Dexterity"
elif PClassRandom == 11:
CLASS = "Rogue"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Dexterity"
SAVE2 = "Intelligence"
elif PClassRandom == 12:
CLASS = "Sorcerer"
MAINSTAT = "cha"
SECONDSTAT = "RAND"
HITDIE = 6
SAVE1 = "Constitution"
SAVE2 = "Charisma"
elif PClassRandom == 13:
CLASS = "Warlock"
MAINSTAT = "cha"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Wisdom"
SAVE2 = "Charisma"
elif PClassRandom == 14:
CLASS = "Wizard"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
SAVE1 = "Intelligence"
SAVE2 = "Wisdom"
else:
PClassRandom = random.randint(1, 20)
if PClassRandom == 1:
CLASS = "Artificer"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Constitution"
SAVE2 = "Intelligence"
elif PClassRandom == 2:
CLASS = "Barbarian"
MAINSTAT = "str"
SECONDSTAT = "con"
HITDIE = 12
SAVE1 = "Strength"
SAVE2 = "Constitution"
elif PClassRandom == 3:
CLASS = "Bard"
MAINSTAT = "cha"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Dexterity"
SAVE2 = "Charisma"
elif PClassRandom == 4:
CLASS = "Bloodhunter"
MAINSTAT = "dex"
SECONDSTAT = "int"
HITDIE = 10
SAVE1 = "Dexterity"
SAVE2 = "Intelligence"
elif PClassRandom == 5:
CLASS = "Cleric"
MAINSTAT = "wis"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Wisdom"
SAVE2 = "Charisma"
elif PClassRandom == 6:
CLASS = "Druid"
MAINSTAT = "wis"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Intelligence"
SAVE2 = "Wisdom"
elif PClassRandom == 7:
CLASS = "Falconer"
MAINSTAT = "dex"
SECONDSTAT = "wis"
HITDIE = 8
SAVE1 = "Strength"
SAVE2 = "Dexterity"
elif PClassRandom == 8:
CLASS = "Fighter"
if random.randint(1, 2) == 1:
MAINSTAT = "str"
else:
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 10
SAVE1 = "Strength"
SAVE2 = "Constitution"
elif PClassRandom == 9:
CLASS = "Guardian"
MAINSTAT = "str"
if random.randint(1, 2) == 1:
SECONDSTAT = "con"
else:
SECONDSTAT = "cha"
HITDIE = 12
SAVE1 = "Constitution"
SAVE2 = "Charisma"
elif PClassRandom == 10:
CLASS = "Keeper"
MAINSTAT = "cha"
if random.randint(1, 2) == 1:
SECONDSTAT = "con"
else:
if random.randint(1, 2) == 1:
SECONDSTAT = "str"
else:
SECONDSTAT = "dex"
HITDIE = 8
SAVE1 = "Constitution"
SAVE2 = "Charisma"
elif PClassRandom == 11:
CLASS = "Magus"
if random.randint(1, 2) == 1:
MAINSTAT = "str"
else:
MAINSTAT = "dex"
SECONDSTAT = "int"
HITDIE = 10
SAVE1 = "Constitution"
SAVE2 = "Intelligence"
elif PClassRandom == 12:
CLASS = "Monk"
MAINSTAT = "dex"
SECONDSTAT = "wis"
HITDIE = 8
SAVE1 = "Strength"
SAVE2 = "Dexterity"
elif PClassRandom == 13:
CLASS = "Paladin"
MAINSTAT = "cha"
SECONDSTAT = "str"
HITDIE = 10
SAVE1 = "Wisdom"
SAVE2 = "Charisma"
elif PClassRandom == 14:
CLASS = "Pugilist"
MAINSTAT = "str"
SECONDSTAT = "con"
HITDIE = 8
SAVE1 = "Strength"
SAVE2 = "Constitution"
elif PClassRandom == 15:
CLASS = "Ranger"
MAINSTAT = "dex"
SECONDSTAT = "wis"
HITDIE = 10
SAVE1 = "Strength"
SAVE2 = "Dexterity"
elif PClassRandom == 16:
CLASS = "Rogue"
MAINSTAT = "dex"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Dexterity"
SAVE2 = "Intelligence"
elif PClassRandom == 17:
CLASS = "Sorcerer"
MAINSTAT = "cha"
SECONDSTAT = "RAND"
HITDIE = 6
SAVE1 = "Constitution"
SAVE2 = "Charisma"
elif PClassRandom == 18:
CLASS = "Warlock"
MAINSTAT = "cha"
SECONDSTAT = "RAND"
HITDIE = 8
SAVE1 = "Wisdom"
SAVE2 = "Charisma"
elif PClassRandom == 19:
CLASS = "Warlord"
MAINSTAT = "str"
if random.randint(1, 2) == 1:
SECONDSTAT = "wis"
else:
SECONDSTAT = "cha"
HITDIE = 8
SAVE1 = "Wisdom"
SAVE2 = "Charisma"
elif PClassRandom == 20:
CLASS = "Wizard"
MAINSTAT = "int"
SECONDSTAT = "RAND"
HITDIE = 6
SAVE1 = "Intelligence"
SAVE2 = "Wisdom"
Abilities = ["str", "dex", "con", "int", "wis", "cha"]
if MAINSTAT == "RAND":
MAINSTAT = Abilities.pop(random.randint(0, len(Abilities)-1))
if SECONDSTAT == "RAND":
SECONDSTAT = Abilities.pop(random.randint(0, len(Abilities)-1))
if SECONDSTAT == MAINSTAT:
SECONDSTAT = Abilities.pop(random.randint(0, len(Abilities)-1))
if MAINSTAT == "RAND":
randomstat = random.randint(1, 6)
if randomstat == 1:
MAINSTAT = "str"
elif randomstat == 2:
MAINSTAT = "dex"
elif randomstat == 3:
MAINSTAT = "con"
elif randomstat == 4:
MAINSTAT = "int"
elif randomstat == 5:
MAINSTAT = "wis"
else:
MAINSTAT = "cha"
if SECONDSTAT == "RAND":
randomstat = random.randint(1, 6)
if randomstat == 1:
SECONDSTAT = "str"
elif randomstat == 2:
SECONDSTAT = "dex"
elif randomstat == 3:
SECONDSTAT = "con"
elif randomstat == 4:
SECONDSTAT = "int"
elif randomstat == 5:
SECONDSTAT = "wis"
else:
SECONDSTAT = "cha"
return CLASS, MAINSTAT, SECONDSTAT, ClassRandom, HITDIE, SAVE1, SAVE2
# Level/challenge Rating #
def LevelCRGen(ClassRandom):
LEVEL = 0
if ClassRandom >= 18:
Leveling = 1
while Leveling == 1:
Leveling = random.randint(1,2) # 50% chance to level up
LEVEL += 1
CHALLENGERATING = "Party CR"
if ClassRandom >= 18:
CHALLENGERATING = random.randint(1, 6)
if CHALLENGERATING == 1:
CHALLENGERATING = "Party CR-2"
elif CHALLENGERATING == 2:
CHALLENGERATING = "Party CR-1"
elif CHALLENGERATING == 3:
CHALLENGERATING = "Party CR"
elif CHALLENGERATING == 4:
CHALLENGERATING = "Party CR"
elif CHALLENGERATING == 5:
CHALLENGERATING = "Party CR+1"
else:
CHALLENGERATING = "Party CR+2"
PROFICIENCYBONUS = 0
if LEVEL < 5:
PROFICIENCYBONUS = 2
elif LEVEL < 9:
PROFICIENCYBONUS = 3
elif LEVEL < 13:
PROFICIENCYBONUS = 4
elif LEVEL < 17:
PROFICIENCYBONUS = 5
else:
PROFICIENCYBONUS = 6
return LEVEL, CHALLENGERATING, PROFICIENCYBONUS
# Gender #
def GenderGen():
GENDER = random.randint(1, 100)
if GENDER <= 40:
GENDER = "Male"
elif GENDER <= 80:
GENDER = "Female"
elif GENDER <= 90:
GENDER = "Androgynous"
elif GENDER <= 95:
GENDER = "Effeminate Male"
elif GENDER <= 100:
GENDER = "Masculine Female"
return GENDER
# Disposition #
def DispositionGen():
DISPOSITION = random.randint(1, 6)
if DISPOSITION == 1:
DISPOSITION = "Hostile"
elif DISPOSITION == 2:
DISPOSITION = "Friendly"
elif DISPOSITION == 3:
DISPOSITION = "Friendly"
elif DISPOSITION == 4:
DISPOSITION = "Indifferent"
elif DISPOSITION == 5:
DISPOSITION = "Indifferent"
else:
DISPOSITION = "Indifferent"
return DISPOSITION
# Alignment #
def AlignmentGen():
ALIGNMENT = random.randint(1, 10)
# Disposition altering alignment may not be necessarily what I'm looking for, but the idea holds merit for later use.
# if DISPOSITION == "Hostile":
# ALIGNMENT += 3
# elif DISPOSITION == "Friendly":
# ALIGNMENT -= 3
if ALIGNMENT == 1:
ALIGNMENT = "Lawful Good"
elif ALIGNMENT == 2:
ALIGNMENT = "Lawful Neutral"
elif ALIGNMENT == 3:
ALIGNMENT = "Lawful Evil"
elif ALIGNMENT == 4:
ALIGNMENT = "Neutral Good"
elif ALIGNMENT == 5:
ALIGNMENT = "True Neutral"
elif ALIGNMENT == 6:
ALIGNMENT = "True Neutral"
elif ALIGNMENT == 7:
ALIGNMENT = "Neutral Evil"
elif ALIGNMENT == 8:
ALIGNMENT = "Chaotic Good"
elif ALIGNMENT == 9:
ALIGNMENT = "Chaotic Neutral"
else:
ALIGNMENT = "Chaotic Evil"
return ALIGNMENT
# Goal/Motivation #
def GoalGen():
with open(r"Lists\Goals.csv", "r", encoding="utf-8") as csvfile:
GOAL = list(csv.reader(csvfile, delimiter=','))
selected_row = random.choice(GOAL) # Select a random row (list)
GOAL = ','.join(selected_row) # Convert the list to a comma-separated string
return GOAL
def GenerateNPC(CLASSTOGGLE, Classification, INCLUDEHOMEBREWCLASSES):
SPECIES = SpeciesGen(Classification, PHBCLASSES)
CLASS, MAINSTAT, SECONDSTAT, ClassRandom, HITDIE, SAVE1, SAVE2 = ClassGen(CLASSTOGGLE, INCLUDEHOMEBREWCLASSES)
LEVEL, CHALLENGERATING, PROFICIENCYBONUS = LevelCRGen(ClassRandom)
GENDER = GenderGen()
DISPOSITION = DispositionGen()
ALIGNMENT = AlignmentGen()
GOAL = GoalGen()
return SPECIES, CLASS, MAINSTAT, SECONDSTAT, LEVEL, CHALLENGERATING, GENDER, DISPOSITION, ALIGNMENT, GOAL, PROFICIENCYBONUS, HITDIE, SAVE1, SAVE2
def PrintResults():
print(f"\nGender: {GENDER}\nSpecies: {SPECIES}\nClass: {CLASS}\nLevel: {LEVEL}\nChallenge Rating: {CHALLENGERATING}\nDisposition: {DISPOSITION}\nAlignment: {ALIGNMENT}\n\nGoal: {GOAL}")
def ExportNPC(HITDIE, SAVE1, SAVE2):
with open(r'Lists\template-character.json', 'r') as json_file:
template_json = json.load(json_file)
# Ability Scores
ability_scores = template_json["abilityScores"]
StandardArray = [13, 12, 10, 8]
Count = 0
for ability in ability_scores:
if ability['name'] == MAINSTAT:
ability['value'] = 15
elif ability['name'] == SECONDSTAT:
ability['value'] = 14
else:
if ability['name'] != MAINSTAT or ability['name'] != SECONDSTAT:
ability['value'] = StandardArray.pop(random.randint(0, len(StandardArray)-1))
if Count == 0:
ability['value'] += 2
if Count == 4:
ability['value'] += 1
if ability['name'] == "dex": # Initative Bonus
template_json["initiativeBonus"] = math.floor((int(ability['value'])-10)/2)
if ability['name'] == "con": # HP
for tracker in template_json["trackers"]:
if tracker['name'] == "HP": # HP
HPROLLING = LEVEL -1
tracker['max'] = 0
while HPROLLING > 0:
HPROLLING -= 1
tracker['max'] += random.randint(1, HITDIE) + math.floor((int(ability['value'])-10)/2)
tracker['max'] = tracker['max'] + HITDIE + math.floor((int(ability['value'])-10)/2) # First Level Max HP
tracker['value'] = tracker['max']
Count += 1
# Skills
SkillList = ["Acrobatics", "Animal Handling", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"]
Skills = template_json["skills"]
NumberofSkills = random.randint(3, 5)
while NumberofSkills > 0:
ChosenSkill = SkillList.pop(random.randint(0, len(SkillList)-1))
for skill in Skills:
if skill['name'] == ChosenSkill:
skill['proficient'] = True
NumberofSkills -= 1
break
# Proficiencies
Proficiencies = template_json["proficiencies"]
for entry in Proficiencies:
if entry['name'] == "SAVE1":
entry['name'] = SAVE1
elif entry['name'] == "SAVE2":
entry['name'] = SAVE2
# Name
# Define a variable with a new value
new_name = SPECIES+" "+CLASS
# Update the 'name' field in the dictionary with the new value
template_json["name"] = new_name
# Alignment
template_json["alignment"] = ALIGNMENT
# Class & Level
for entry in template_json["classes"]:
entry["class"] = CLASS
entry["level"] = LEVEL
# Challenge Rating/Proficiency Bonus
template_json["challengeRating"] = CHALLENGERATING
template_json["proficiencyBonus"] = PROFICIENCYBONUS
# Armor Class
ClassACMOD = 0
if CLASS == "Artificer":
ClassACMOD = 0
elif CLASS == "Barbarian":
ClassACMOD = 1
elif CLASS == "Bard":
ClassACMOD = 0
elif CLASS == "Bloodhunter":
ClassACMOD = 0
elif CLASS == "Cleric":
ClassACMOD = 0
elif CLASS == "Paladin":
ClassACMOD = 1
template_json["armorClass"] = 12 + math.floor((random.randint(15,22)/10)*PROFICIENCYBONUS)+ClassACMOD
# Race
template_json["race"] = SPECIES
# Description
template_json["description"] = f"# Visual\nRace: {SPECIES}\nGender: {GENDER}\nHeight: \nHair Color: \nNotable Features: \n\n# Brief\nThis section should be 2-3 sentences long and briefly describe the character's physical appearance and personality regarding the party.\n\n# Relation\n## Party\nHow the party knows/met the NPC and how they affect them.\n\n## World\nHow the NPC knows/interacts with various organizations and or other NPCs throughout the world.\n\n# Background\nThis section should vary in length substantially, revealing more about an NPC's past as the players continue to learn about them. Should be written in the past tense.\n\n# Important Notes\nWhen this NPC mentions something important to them or to the party, it should be put here in a list format.\n\n![# DM Section]()\n![## Voice]()\n![A description of this character's voice when appropriate should be described here.]()\n\n![## Current Goals]()\n![This should be the NPC's CURRENT Goals, likely in a list format, with older goals crossed out.]()\n\n![## Motivations]()\n![This motivation should inform the NPC's current and longterm goals, what they strive for.]()\n\n![## Secrets]()\n![Anything this NPC attempts to keep from the party or the world in general.]()\n\n![## Other]()\n![Misc that I have not yet catagorized.]()"
# Export the modified dictionary as a JSON file
outputfilename = "NPCs\\"+ str(int(time.time()))+GENDER+" "+SPECIES+" "+CLASS+'.json'
with open(outputfilename, 'w') as json_file:
json.dump(template_json, json_file, indent=4)
print("Exported NPC to "+outputfilename)
print("Welcome to Nox's NPC Generator.")
SPECIES = ""
CLASSTOGGLE = False
INCLUDEHOMEBREWCLASSES = False
PHBCLASSES = False
Classification = ""
Choice = "1"
while Choice != "5":
Choice = input("\n1. Generate New NPC\n2. Edit NPC\n3. Export NPC\n4. Settings\n5. Exit\n\nInput: ")
print("----------------------------------------")
if Choice == "1":
SPECIES, CLASS, MAINSTAT, SECONDSTAT, LEVEL, CHALLENGERATING, GENDER, DISPOSITION, ALIGNMENT, GOAL, PROFICIENCYBONUS, HITDIE, SAVE1, SAVE2 = GenerateNPC(CLASSTOGGLE, Classification, INCLUDEHOMEBREWCLASSES)
PrintResults()
elif Choice == "2":
if SPECIES == "":