-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnpc_generator.py
619 lines (554 loc) · 34.7 KB
/
npc_generator.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
from importlib.resources import path
import random
import os
from numpy.random import choice
class NpcGenerator():
def __init__(self):
self.name = ""
self.race = ""
self.sex = ""
self.alignment = ""
self.MAXIMUM_ATTRIBUTE_SCORE = 14
self.MINIMUM_ATTRIBUTE_SCORE = 6
self.attribute_scores = []
self.pt = ""
self.quirk = ""
self.ideal = ""
self.bond = ""
self.flaw = ""
self.physical = ""
self.traits = []
# separate attribute score lineup so that if a user desires to manually set their attributes, they can
self.custom_attributes_enabled = False
self.strength = 10
self.dexterity = 10
self.constitution = 10
self.intelligence = 10
self.wisdom = 10
self.charisma = 10
# Wealth, occupation, languages, other advanced options
self.wealth = ""
self.occupation = ""
self.knows_common = True #Default value of true as most NPCs would speak common, can be set false only in GUI or webapp
self.knows_obscure_languages = False
self.languages = []
self.languages_known = 1
self.religion = ""
# Current coin values are determined based on wealth status
self.current_gold_pieces = 0
self.current_silver_pieces = 0
self.current_copper_pieces = 0
# designates target folder for saved NPCs, folder must exist before running generator or it will be saved locally.
self.OUTPUT_FOLDER = "NPCs"
def race_gen(self): # races are biased towards the earlier part of the list, as these are more prevalent races in major cities
races = ["Human", "Elf", "Dwarf", "Half-Elf", "Tiefling", "Halfling", "Half-Orc", "Dragonborn", "Gnome", "Goblin", "Hobgoblin", "Drow", "Satyr", "Changeling"]
self.race = choice(races, 1, p=[0.23, 0.20, 0.10, 0.10, 0.10, 0.05, 0.05, 0.04, 0.03, 0.03, 0.02, 0.02, 0.02, 0.01])
def sex_gen(self):
sexes = ["Male", "Female"]
self.sex = choice(sexes, 1, p=[0.60, 0.40])
def name_gen(self):
if self.race == "Human":
if self.sex == "Male":
with open("names/male human names", "r") as names: # All names are saved in txt docs locally to save processing power and document space to exponentially increase num of options
import_male_human_names = names.readlines()
male_human_names = []
for each in import_male_human_names:
male_human_names.append(each.replace("\n", ""))
self.name = random.choice(male_human_names)
elif self.sex == "Female":
with open("names/female human names", "r") as names:
import_female_human_names = names.readlines()
female_human_names = []
for each in import_female_human_names:
female_human_names.append(each.replace("\n", ""))
self.name = random.choice(female_human_names)
elif self.race == "Elf":
if self.sex == "Male":
with open ("names/male elf names", "r") as names:
import_male_elf_names = names.readlines()
male_elf_names = []
for each in import_male_elf_names:
male_elf_names.append(each.replace("\n", ""))
self.name = random.choice(male_elf_names)
elif self.sex == "Female":
with open ("names/female elf names", "r") as names:
import_female_elf_names = names.readlines()
female_elf_names = []
for each in import_female_elf_names:
female_elf_names.append(each.replace("\n", ""))
self.name = random.choice(female_elf_names)
elif self.race == "Dwarf":
if self.sex == "Male":
with open("names/male dwarf names", "r") as names:
import_male_dwarf_names = names.readlines()
male_dwarf_names = []
for each in import_male_dwarf_names:
male_dwarf_names.append(each.replace("\n", ""))
self.name = random.choice(male_dwarf_names)
elif self.sex == "Female":
with open("names/female dwarf names", "r") as names:
import_female_dwarf_names = names.readlines()
female_dwarf_names = []
for each in import_female_dwarf_names:
female_dwarf_names.append(each.replace("\n", ""))
self.name = random.choice(female_dwarf_names)
elif self.race == "Half-Elf":
if self.sex == "Male":
with open("names/male half elf names", "r") as names:
import_male_halfelf_names = names.readlines()
male_halfelf_names = []
for each in import_male_halfelf_names:
male_halfelf_names.append(each.replace("\n", ""))
self.name = random.choice(male_halfelf_names)
elif self.sex == "Female":
with open("names/female half elf names", "r") as names:
import_female_halfelf_names = names.readlines()
female_halfelf_names = []
for each in import_female_halfelf_names:
female_halfelf_names.append(each.replace("\n", ""))
self.name = random.choice(female_halfelf_names)
elif self.race == "Tiefling":
if self.sex == "Male":
with open("names/male tiefling names", "r") as names:
import_male_tiefling_names = names.readlines()
male_tiefling_names = []
for each in import_male_tiefling_names:
male_tiefling_names.append(each.replace("\n", ""))
self.name = random.choice(male_tiefling_names)
elif self.sex == "Female":
with open("names/female tiefling names", "r") as names:
import_female_tiefling_names = names.readlines()
female_tiefling_names = []
for each in import_female_tiefling_names:
female_tiefling_names.append(each.replace("\n", ""))
self.name = random.choice(female_tiefling_names)
elif self.race == "Halfling":
if self.sex == "Male":
with open("names/male halfling names", "r") as names:
import_male_halfling_names = names.readlines()
male_halfling_names = []
for each in import_male_halfling_names:
male_halfling_names.append(each.replace("\n", ""))
self.name = random.choice(male_halfling_names)
elif self.sex == "Female":
with open("names/female halfling names", "r") as names:
import_female_halfling_names = names.readlines()
female_halfling_names = []
for each in import_female_halfling_names:
female_halfling_names.append(each.replace("\n", ""))
self.name = random.choice(female_halfling_names)
elif self.race == "Half-Orc":
if self.sex == "Male":
with open("names/male half orc names", "r") as names:
import_male_halforc_names = names.readlines()
male_halforc_names = []
for each in import_male_halforc_names:
male_halforc_names.append(each.replace("\n", ""))
self.name = random.choice(male_halforc_names)
elif self.sex == "Female":
with open("names/female half orc names", "r") as names:
import_female_halforc_names = names.readlines()
female_halforc_names = []
for each in import_female_halforc_names:
female_halforc_names.append(each.replace("\n", ""))
self.name = random.choice(female_halforc_names)
elif self.race == "Dragonborn":
if self.sex == "Male":
with open("names/male dragonborn names", "r") as names:
import_male_dragonborn_names = names.readlines()
male_dragonborn_names = []
for each in import_male_dragonborn_names:
male_dragonborn_names.append(each.replace("\n", ""))
self.name = random.choice(male_dragonborn_names)
elif self.sex == "Female":
with open("names/female dragonborn names", "r") as names:
import_female_dragonborn_names = names.readlines()
female_dragonborn_names = []
for each in import_female_dragonborn_names:
female_dragonborn_names.append(each.replace("\n", ""))
self.name = random.choice(female_dragonborn_names)
elif self.race == "Gnome":
if self.sex == "Male":
with open("names/male gnome names", "r") as names:
import_male_gnome_names = names.readlines()
male_gnome_names = []
for each in import_male_gnome_names:
male_gnome_names.append(each.replace("\n", ""))
self.name = random.choice(male_gnome_names)
elif self.sex == "Female":
with open("names/female gnome names", "r") as names:
import_female_gnome_names = names.readlines()
female_gnome_names = []
for each in import_female_gnome_names:
female_gnome_names.append(each.replace("\n", ""))
self.name = random.choice(female_gnome_names)
elif self.race == "Goblin":
if self.sex == "Male":
with open("names/male goblin names", "r") as names:
import_male_goblin_names = names.readlines()
male_goblin_names = []
for each in import_male_goblin_names:
male_goblin_names.append(each.replace("\n", ""))
self.name = random.choice(male_goblin_names)
elif self.sex == "Female":
with open("names/female goblin names", "r") as names:
import_female_goblin_names = names.readlines()
female_goblin_names = []
for each in import_female_goblin_names:
female_goblin_names.append(each.replace("\n", ""))
self.name = random.choice(female_goblin_names)
elif self.race == "Hobgoblin":
if self.sex == "Male":
with open("names/male hobgoblin names", "r") as names:
import_male_hobgoblin_names = names.readlines()
male_hobgoblin_names = []
for each in import_male_hobgoblin_names:
male_hobgoblin_names.append(each.replace("\n", ""))
self.name = random.choice(male_hobgoblin_names)
elif self.sex == "Female":
with open("names/female hobgoblin names", "r") as names:
import_female_hobgoblin_names = names.readlines()
female_hobgoblin_names = []
for each in import_female_hobgoblin_names:
female_hobgoblin_names.append(each.replace("\n", ""))
self.name = random.choice(female_hobgoblin_names)
elif self.race == "Drow":
if self.sex == "Male":
with open("names/male drow names", "r") as names:
import_male_drow_names = names.readlines()
male_drow_names = []
for each in import_male_drow_names:
male_drow_names.append(each.replace("\n", ""))
self.name = random.choice(male_drow_names)
elif self.sex == "Female":
with open("names/female drow names", "r") as names:
import_female_drow_names = names.readlines()
female_drow_names = []
for each in import_female_drow_names:
female_drow_names.append(each.replace("\n", ""))
self.name = random.choice(female_drow_names)
elif self.race == "Satyr":
if self.sex == "Male":
with open("names/male satyr names", "r") as names:
import_male_satyr_names = names.readlines()
male_satyr_names = []
for each in import_male_satyr_names:
male_satyr_names.append(each.replace("\n", ""))
self.name = random.choice(male_satyr_names)
elif self.sex == "Female":
with open("names/female satyr names", "r") as names:
import_female_satyr_names = names.readlines()
female_satyr_names = []
for each in import_female_satyr_names:
female_satyr_names.append(each.replace("\n", ""))
self.name = random.choice(female_satyr_names)
elif self.race == "Changeling":
with open("names/changeling names", "r") as names: # Changelings are intentionally left sexless due to their mutable form
import_changeling_names = names.readlines()
changeling_names = []
for each in import_changeling_names:
changeling_names.append(each.replace("\n", ""))
self.name = random.choice(changeling_names)
else:
return "Invalid Race Selection - or - No Available Names"
def alignment_gen(self):
alignments = ["Lawful Good", "Lawful Neutral", "Lawful Evil", "Neutral Good", "True Neutral", "Neutral Evil", "Chaotic Good", "Chaotic Neutral", "Chaotic Evil"]
self.alignment = random.choice(alignments) # alignments are not biased currently, a random character can be chaotic evil without reason, they simply do not need to act on it
def flaw_gen(self):
with open("personalityelements/Flaws", "r") as flaws:
flaw_options = flaws.readlines()
flaw_list = []
for each in flaw_options:
flaw_list.append(each.replace("\n", ""))
self.flaw = random.choice(flaw_list)
def bond_gen(self):
with open("personalityelements/Bonds", "r") as bonds:
bond_options = bonds.readlines()
bond_list = []
for each in bond_options:
bond_list.append(each.replace("\n", ""))
self.bond = random.choice(bond_list)
def personality_gen(self):
with open("personalityelements/Personality Traits", "r") as ptraits:
pt_options = ptraits.readlines()
pt_list = []
for each in pt_options:
pt_list.append(each.replace("\n", ""))
self.pt = random.choice(pt_list)
def ideal_gen(self):
with open("personalityelements/Ideals", "r") as ideals:
ideal_options = ideals.readlines()
ideal_list = []
for each in ideal_options:
ideal_list.append(each.replace("\n", ""))
self.ideal = random.choice(ideal_list)
def quirk_gen(self):
with open("personalityelements/Quirks", "r") as quirks:
quirk_options = quirks.readlines()
quirk_list = []
for each in quirk_options:
quirk_list.append(each.replace("\n", ""))
self.quirk = random.choice(quirk_list)
def physical_gen(self):
with open("personalityelements/Physical Traits", "r") as physicals:
phys_options = physicals.readlines()
phys_list = []
for each in phys_options:
phys_list.append(each.replace("\n", ""))
self.physical = random.choice(phys_list)
def attributes_gen(self): # Uses dictionary to create attributes, then writes them to an ability list for later reference
abilities = []
skills = {"Strength":8, "Dexterity":8, "Constitution":8, "Intelligence":8, "Wisdom":8, "Charisma":8} # sets baseline for stats in the event that it does not generate a stat array.
for each in skills:
skills[each] = random.randint(self.MINIMUM_ATTRIBUTE_SCORE,self.MAXIMUM_ATTRIBUTE_SCORE)
for ability, score in skills.items():
abilities.append(str(ability) + ": " + str(score))
self.attribute_scores = abilities
def custom_attribute_selection(self):
self.custom_attributes_enabled = True
def income_determinator(self):
wealth_options = ["Aristocratic", "Wealthy", "Comfortable", "Modest", "Poor", "Squalid", "Wretched"]
self.wealth = choice(wealth_options, 1, p=[0.05, 0.05, 0.23, 0.40, 0.17, 0.07, 0.03])
def current_gold(self):
if self.wealth == "Aristocratic":
self.current_gold_pieces = random.randint(20, 85)
self.current_silver_pieces = random.randint(1, 100)
self.current_copper_pieces = random.randint(1, 100)
if self.wealth == "Wealthy":
self.current_gold_pieces = random.randint(1, 10)
self.current_silver_pieces = random.randint(1, 100)
self.current_copper_pieces = random.randint(1, 100)
if self.wealth == "Comfortable":
self.current_gold_pieces = random.randint(0,6)
self.current_silver_pieces = random.randint(0, 100)
self.current_copper_pieces = random.randint(1, 100)
if self.wealth == "Modest":
self.current_gold_pieces = random.randint(0,2)
self.current_silver_pieces = random.randint(0,45)
self.current_copper_pieces = random.randint(1, 80)
if self.wealth == "Poor":
self.current_gold_pieces = 0
self.current_silver_pieces = random.randint(0, 30)
self.current_copper_pieces = random.randint(0,40)
if self.wealth == "Squalid":
self.current_gold_pieces = 0
self.current_silver_pieces = random.randint(0,10)
self.current_copper_pieces = random.randint(0,20)
if self.wealth == "Wretched":
self.current_gold_pieces = 0
self.current_silver_pieces = 0
self.current_copper_pieces = random.randint(0,10)
def job_determinator(self):
if self.wealth == "Aristocratic" or self.wealth == "Wealthy":
job_list = ["Politician", "Merchant", "Caravan Owner", "Brothelkeep", "Tavern Chain Owner", "Lord/Lady", "Underworld Crime Lord", "Famed Artist", "Landlord", "Military Doctor", "Surgeon", "Court Advisor", "Diplomat", "Translator", "Con Man", "High-Ranked Military", "Fine Wine Seller", "Artisan", "Real Estate Mogul", "Unemployed/Inherited Wealth"]
self.occupation = random.choice(job_list)
if self.wealth == "Comfortable" or self.wealth == "Modest":
job_list = ["Merchant", "Tavern Owner", "Tavernkeeper", "Underworld Criminal", "Underworld Crime Boss", "Artist", "Artisan", "Farmer/Crops", "Farmer/Animals", "Farmer/All Agriculture", "Doctor", "Shopkeeper", "Small Town Mayor", "Town Guard", "Wine Maker", "Wine Seller", "Basket Weaver", "Smith (Armor)", "Smith (Weapons)", "Cook", "Silversmith", "Jeweler", "Woodcarver", "Woodworker", "Woodcutter", "Soldier", "Famous Fighter", "Bard", "Clockmaker"]
self.occupation = random.choice(job_list)
if self.wealth == "Poor" or self.wealth == "Squalid":
job_list = ["Farmer/Animals", "Farmer/Agriculture", "Farmer/All Agriculture", "Criminal", "Outlaw", "Basket Weaver", "Smith (Armor)", "Smith (Weapons)", "Silversmith", "Jeweller", "Shopkeeper", "Town Guard", "Soldier", "Wine Maker", "Wine Seller", "Basket Weaver", "Cook", "Woodcarver", "Woodcutter", "Woodworker", "Construction Worker", "Cobbler", "Bard", "Clockmaker", "Miner", "Servant", "Barber", "Fighter", "Fighter (Gladiator)", "Gardener", "Unemployed"]
self.occupation = random.choice(job_list)
if self.wealth == "Wretched":
job_list = ["Unemployed", "Farm Hand", "Slave", "Prisoner", "Prisoner (Escaped)"]
self.occupation = random.choice(job_list)
def known_languages(self):
languages = []
if self.knows_common == True:
languages = ["Dwarvish", "Elvish", "Giant", "Gnomish", "Goblin", "Halfling", "Orcish"]
if self.knows_obscure_languages == True:
obscure_languages = ["Abyssal", "Celestial", "Draconic", "Deep Speech", "Infernal", "Primordial", "Sylvan", "Undercommon"]
for each in obscure_languages:
languages = languages.append(each)
self.languages = random.sample(languages, self.languages_known)
self.languages.append("Common")
elif self.knows_common == False:
self.languages_known = 1
languages = ["Dwarvish", "Elvish", "Giant", "Gnomish", "Goblin", "Halfling", "Orcish"]
if self.knows_obscure_languages == True:
obscure_languages = ["Abyssal", "Celestial", "Draconic", "Deep Speech", "Infernal", "Primordial", "Sylvan", "Undercommon"]
for each in obscure_languages:
languages = languages.append(each)
self.languages = random.sample(languages, self.languages_known)
def religion_generation_random(self):
# Main religion gen accounts for the Gods of Faerun, as well as no religious following, and a few unorthodox systems
# Religion chosen in this method is truly random, and not accounted for alignment
religions = ["Auril, Goddess of Winter", "Azuth, God of Wizards", "Bane, God of Tyrany", "Beshaba, Goddess of Misfortune", "Bhaal, God of Murder", "Chauntea, Goddess of Agriculture", "Cyric, God of Lies", "Deneir, God of Writing", "Eldath, Goddess of Peace", "Gond, God of Craft", "Helm, God of Protection", "Ilmater, God of Endurance", "Kelemvor, God of the Dead", "Lathander, Goddess of Illusion", "Lliira, Goddess of Joy", "Loviatar, Goddess of Pain", "Malar, God of the Hunt", "Mask, God of Thieves", "Mielikki, Goddess of Forests", "Milil, God of Poetry and Song", "Myrkul, God of Death", "Mystra, Goddess of Magic", "Oghma, God of Knowledge", "Savras, God of Divination and Fate", "Selûne, Goddess of the Moon", "Shar, Goddess of Darkness and Loss", "Silvanus, God of Wild Nature", "Sune, Goddess of Love and Beauty", "Talona, Goddess of Disease and Poison", "Talos, God of Storms", "Tempus, God of War", "Torm, God of Courage and Self-Sacrifice", "Tymora, Goddess of Good Fortune", "Tyr, God of Justice", "Umberlee, Goddess of the Sea", "Waukeen, Goddess of Trade", "Nonreligious/Athiest"]
self.religion = random.choice(religions)
def religion_generation_alignment(self):
# Religion is Generated on an alignment basis, with gods specifically matching the NPC's alignment being most likely, followed by adjacent alignments
# E.G. NPC is True Neutral, and Gods with the same general alignment will be chosen first, followed by those who may be CN, LN, NG, NE at a lesser percentage
# Also appends the racial religions to the end of each
religions = []
if (self.alignment == "Lawful Good" or self.alignment == "Neutral Good") or "Chaotic Good":
religions = ["Ilmater, God of Endurance", "Torm, God of Courage and Self-Sacrifice", "Tyr, God of Justice", "Azuth, God of Wizards", "Chauntea, Goddess of Agriculture", "Deneir, God of Writing", "Eldath, Goddess of Peace", "Gond, God of Craft", "Helm, God of Protection", "Kelemvor, God of the Dead", "Lathander, God of Birth and Renewal", "Lliira, Goddess of Joy", "Mielikki, Goddess of Forest", "Milil, God of Poetry and Song", "Mystra, Goddess of Magic", "Silvanus, God of Wild Nature", "Sune, Goddess of Love and Beauty", "Tempus, God of War", "Tymora, Goddess of Good Fortune", "Nonreligious/Athiest"]
if self.race == "Dragonborn":
religions.append("Bahamut, Dragon God of Good")
religions.append("Tiamat, Dragon Goddess of Evil")
if self.race == "Elf" or self.race == "Half-Elf":
religions.append("Corellon Larethian, Elf Deity of Art and Magic")
religions.append("Deep Sashelas, Elf God of the Sea")
religions.append("Rillifane Rallathil, Wood Elf God of Nature")
religions.append("Sehanine Moonbow, Elf Goddess of the Moon")
if self.race == "Gnome":
religions.append("Garl Glittergold, Gnome God of Trickery and Wiles")
if self.race == "Halfling":
religions.append("Yondalla, Halfling Goddess of Fertility and Protection")
if self.race == "Giant" or self.race == "Goliath":
religions.append("Grolantor, Hill Giant God of War")
religions.append("Skoraeus Stonebones, God of Stone Giants and Art")
religions.append("Surtur, God of fire Giants and Craft")
religions.append("Thrym, God of Frost Giants and Strength")
if self.race == "Orc" or self.race == "Half-Orc":
religions.append("Gruumsh, Orc God of Storms and War")
if self.race == "Kobold":
religions.append("Kurtulmak, Kobold God of War and Mining")
if self.race == "Drow":
religions.append("Lolth, Drow Goddess of Spiders")
if self.race == "Goblin":
religions.append("Maglubiyet, Goblinoid God of War")
if self.race == "Dwarf":
religions.append("Moradin, Dwarf God of Creation")
if (self.alignment == "Lawful Neutral" or self.alignment == "True Neutral") or "Chaotic Neutral":
religions = ["Azuth, God of Wizards", "Chauntea, Goddess of Agriculture", "Deneir, God of Writing", "Eldath, Goddess of Peace", "Gond, God of Craft", "Helm, God of Protection", "Kelemvor, God of the Dead", "Lathander, God of Birth and Renewal", "Leira, Goddess of Illusion", "Mask, God of Thieves", "Mielikki, Goddess of Forests", "Milil God of Poetry and Song", "Mystra, Goddess of Magic", "Oghma, God of Knowledge", "Savras, God of Divination and Fate", "Silvanus, God of Wild Nature", "Tempus, God of War", "Waukeen, Goddess of Trade", "Nonreligious/Athiest"]
if self.race == "Dragonborn":
religions.append("Bahamut, Dragon God of Good")
religions.append("Tiamat, Dragon Goddess of Evil")
if self.race == "Elf" or self.race == "Half-Elf":
religions.append("Corellon Larethian, Elf Deity of Art and Magic")
religions.append("Deep Sashelas, Elf God of the Sea")
religions.append("Rillifane Rallathil, Wood Elf God of Nature")
religions.append("Sehanine Moonbow, Elf Goddess of the Moon")
if self.race == "Gnome":
religions.append("Garl Glittergold, Gnome God of Trickery and Wiles")
if self.race == "Halfling":
religions.append("Yondalla, Halfling Goddess of Fertility and Protection")
if self.race == "Giant" or self.race == "Goliath":
religions.append("Grolantor, Hill Giant God of War")
religions.append("Skoraeus Stonebones, God of Stone Giants and Art")
religions.append("Surtur, God of fire Giants and Craft")
religions.append("Thrym, God of Frost Giants and Strength")
if self.race == "Orc" or self.race == "Half-Orc":
religions.append("Gruumsh, Orc God of Storms and War")
if self.race == "Kobold":
religions.append("Kurtulmak, Kobold God of War and Mining")
if self.race == "Drow":
religions.append("Lolth, Drow Goddess of Spiders")
if self.race == "Goblin":
religions.append("Maglubiyet, Goblinoid God of War")
if self.race == "Dwarf":
religions.append("Moradin, Dwarf God of Creation")
if (self.alignment == "Lawful Evil" or self.alignment == "Neutral Evil") or self.alignment == "Chaotic Evil":
religions = ["Auril, Goddess of Winter", "Bane, God of Tyranny", "Beshaba, Goddess of Misfortune", "Bhaal, God of Murder", "Cyric, God of Lies", "Leira, Goddess of Illusion", "Loviatar, Goddess of Pain", "Malar, God of the Hunt", "Mask, God of Thieves", "Myrkul, God of Death", "Oghma, God of Knowledge", "Shar, Goddess of Darkness and Loss", "Silvanus, God of Wild Nature", "Talona, Goddess of Disease and Poison", "Talos, God of Storms", "Tempus, God of War", "Umberlee, Goddess of the Sea", "Waukeen, Goddess of Trade", "Nonreligious/Athiest"]
if self.race == "Dragonborn":
religions.append("Bahamut, Dragon God of Good")
religions.append("Tiamat, Dragon Goddess of Evil")
if self.race == "Elf" or self.race == "Half-Elf":
religions.append("Corellon Larethian, Elf Deity of Art and Magic")
religions.append("Deep Sashelas, Elf God of the Sea")
religions.append("Rillifane Rallathil, Wood Elf God of Nature")
religions.append("Sehanine Moonbow, Elf Goddess of the Moon")
if self.race == "Gnome":
religions.append("Garl Glittergold, Gnome God of Trickery and Wiles")
if self.race == "Halfling":
religions.append("Yondalla, Halfling Goddess of Fertility and Protection")
if self.race == "Giant" or self.race == "Goliath":
religions.append("Grolantor, Hill Giant God of War")
religions.append("Skoraeus Stonebones, God of Stone Giants and Art")
religions.append("Surtur, God of fire Giants and Craft")
religions.append("Thrym, God of Frost Giants and Strength")
if self.race == "Orc" or self.race == "Half-Orc":
religions.append("Gruumsh, Orc God of Storms and War")
if self.race == "Kobold":
religions.append("Kurtulmak, Kobold God of War and Mining")
if self.race == "Drow":
religions.append("Lolth, Drow Goddess of Spiders")
if self.race == "Goblin":
religions.append("Maglubiyet, Goblinoid God of War")
if self.race == "Dwarf":
religions.append("Moradin, Dwarf God of Creation")
self.religion = random.choice(religions)
def religion_generation_racial(self):
# Religion generation based SOLELY on race. Main-pantheon gods are excluded from this list and is only used if user selects Racial Only
if self.race == "Dragonborn":
religions = ["Bahamut, Dragon God of Good", "Tiamat, Dragon Goddess of Evil"]
self.religion = random.choice(religions)
if self.race == "Elf" or "Half-Elf":
religions = ["Corellon Larethian, Elf Deity of Art and Magic", "Deep Sashelas, Elf God of the Sea", "Rillifane Rallathil, Wood Elf God of Nature", "Sehanine Moonbow, Elf Goddess of the Moon"]
self.religion = random.choice(religions)
if self.race == "Gnome":
religions = ["Garl Glittergold, Gnome God of Trickery and Wiles"]
self.religion = random.choice(religions)
if self.race == "Halfling":
religions = ["Yondalla, Halfling Goddess of Fertility and Protection"]
self.religion = random.choice(religions)
if self.race == "Giant" or "Goliath":
religions =["Grolantor, Hill Giant God of War", "Skoraeus Stonebones, God of Stone Giants and Art", "Surtur, God of fire Giants and Craft", "Thrym, God of Frost Giants and Strength"]
self.religion = random.choice(religions)
if self.race == "Orc" or "Half-Orc":
religions = ["Gruumsh, Orc God of Storms and War"]
self.religion = random.choice(religions)
if self.race == "Kobold":
religions = ["Kurtulmak, Kobold God of War and Mining"]
self.religion = random.choice(religions)
if self.race == "Drow":
religions = ["Lolth, Drow Goddess of Spiders"]
self.religion = random.choice(religions)
if self.race == "Goblin":
religions = ["Maglubiyet, Goblinoid God of War"]
self.religion = random.choice(religions)
if self.race == "Dwarf":
religions = ["Moradin, Dwarf God of Creation"]
self.religion = random.choice(religions)
def display(self): # Returns in-terminal output of the generated NPC
print("NPC Generated! \n")
print("Name: ", self.name)
print("Race: ", self.race)
print("Sex: ", self.sex)
print("Alignment: ", self.alignment)
for each in self.attribute_scores:
print(each)
print("\n")
for each in self.traits:
print(each)
def output(self): # Writes the NPC to file for reference
filename = "{}.txt".format(self.name)
file = open(filename, "w")
file.write("Name: {}\n".format(self.name))
file.write("Race: {} {}\n".format(str(self.sex),str(self.race)))
file.write("Alignment: {}\n\n".format(self.alignment))
file.write("-------ATTRIBUTE SCORE ARRAY-------\n")
if self.custom_attributes_enabled == True:
file.write("Strength: " + str(self.strength) + "\n")
file.write("Dexterity: " + str(self.dexterity) + "\n")
file.write("Constitution: " + str(self.constitution) + "\n")
file.write("Intelligence: " + str(self.intelligence) + "\n")
file.write("Wisdom: " + str(self.wisdom) + "\n")
file.write("Charisma: " + str(self.charisma) + "\n")
elif self.custom_attributes_enabled == False:
for each in self.attribute_scores:
file.write(each + "\n")
file.write("\n\n")
file.write("-------TRAITS AND FLAWS-------\n")
for each in self.traits:
file.write(each)
file.write("\n")
file.close()
os.rename(filename, "{}/{}".format(self.OUTPUT_FOLDER, filename))
path = os.path.abspath(filename)
print("NPC file saved to location ", path)
'''
# Temporarily disabled for GUI Testing, GUI inherently runs each method as selected.
npc = NpcGenerator()
npc.race_gen()
npc.alignment_gen()
npc.sex_gen()
npc.name_gen()
npc.attributes_gen()
npc.income_determinator()
npc.job_determinator()
npc.religion_generation_alignment()
print(npc.religion)
npc.known_languages()
print(npc.languages)
npc.display()
'''