-
Notifications
You must be signed in to change notification settings - Fork 453
/
role.c
2079 lines (1956 loc) · 63.7 KB
/
role.c
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
/* NetHack 3.7 role.c $NHDT-Date: 1596498206 2020/08/03 23:43:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.71 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
/*** Table of all roles ***/
/* According to AD&D, HD for some classes (ex. Wizard) should be smaller
* (4-sided for wizards). But this is not AD&D, and using the AD&D
* rule here produces an unplayable character. Thus I have used a minimum
* of an 10-sided hit die for everything. Another AD&D change: wizards get
* a minimum strength of 4 since without one you can't teleport or cast
* spells. --KAA
*
* As the wizard has been updated (wizard patch 5 jun '96) their HD can be
* brought closer into line with AD&D. This forces wizards to use magic more
* and distance themselves from their attackers. --LSZ
*
* With the introduction of races, some hit points and energy
* has been reallocated for each race. The values assigned
* to the roles has been reduced by the amount allocated to
* humans. --KMH
*
* God names use a leading underscore to flag goddesses.
*/
const struct Role roles[NUM_ROLES+1] = {
{ { "Archeologist", 0 },
{ { "Digger", 0 },
{ "Field Worker", 0 },
{ "Investigator", 0 },
{ "Exhumer", 0 },
{ "Excavator", 0 },
{ "Spelunker", 0 },
{ "Speleologist", 0 },
{ "Collector", 0 },
{ "Curator", 0 } },
"Quetzalcoatl", "Camaxtli", "Huhetotl", /* Central American */
"Arc",
"the College of Archeology",
"the Tomb of the Toltec Kings",
PM_ARCHEOLOGIST,
NON_PM,
PM_LORD_CARNARVON,
PM_STUDENT,
PM_MINION_OF_HUHETOTL,
NON_PM,
PM_HUMAN_MUMMY,
S_SNAKE,
S_MUMMY,
ART_ORB_OF_DETECTION,
MH_HUMAN | MH_DWARF | MH_GNOME | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL
| ROLE_NEUTRAL,
/* Str Int Wis Dex Con Cha */
{ 7, 10, 10, 7, 7, 7 },
{ 20, 20, 20, 10, 20, 10 },
/* Init Lower Higher */
{ 11, 0, 0, 8, 1, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
14, /* Energy */
10,
5,
0,
2,
10,
A_INT,
SPE_MAGIC_MAPPING,
-4 },
{ { "Barbarian", 0 },
{ { "Plunderer", "Plunderess" },
{ "Pillager", 0 },
{ "Bandit", 0 },
{ "Brigand", 0 },
{ "Raider", 0 },
{ "Reaver", 0 },
{ "Slayer", 0 },
{ "Chieftain", "Chieftainess" },
{ "Conqueror", "Conqueress" } },
"Mitra", "Crom", "Set", /* Hyborian */
"Bar",
"the Camp of the Duali Tribe",
"the Duali Oasis",
PM_BARBARIAN,
NON_PM,
PM_PELIAS,
PM_CHIEFTAIN,
PM_THOTH_AMON,
PM_OGRE,
PM_TROLL,
S_OGRE,
S_TROLL,
ART_HEART_OF_AHRIMAN,
MH_HUMAN | MH_ORC | ROLE_MALE | ROLE_FEMALE | ROLE_NEUTRAL
| ROLE_CHAOTIC,
/* Str Int Wis Dex Con Cha */
{ 16, 7, 7, 15, 16, 6 },
{ 30, 6, 7, 20, 30, 7 },
/* Init Lower Higher */
{ 14, 0, 0, 10, 2, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
10, /* Energy */
10,
14,
0,
0,
8,
A_INT,
SPE_HASTE_SELF,
-4 },
{ { "Caveman", "Cavewoman" },
{ { "Troglodyte", 0 },
{ "Aborigine", 0 },
{ "Wanderer", 0 },
{ "Vagrant", 0 },
{ "Wayfarer", 0 },
{ "Roamer", 0 },
{ "Nomad", 0 },
{ "Rover", 0 },
{ "Pioneer", 0 } },
"Anu", "_Ishtar", "Anshar", /* Babylonian */
"Cav",
"the Caves of the Ancestors",
"the Dragon's Lair",
PM_CAVE_DWELLER,
PM_LITTLE_DOG,
PM_SHAMAN_KARNOV,
PM_NEANDERTHAL,
PM_CHROMATIC_DRAGON,
PM_BUGBEAR,
PM_HILL_GIANT,
S_HUMANOID,
S_GIANT,
ART_SCEPTRE_OF_MIGHT,
MH_HUMAN | MH_DWARF | MH_GNOME | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL
| ROLE_NEUTRAL,
/* Str Int Wis Dex Con Cha */
{ 10, 7, 7, 7, 8, 6 },
{ 30, 6, 7, 20, 30, 7 },
/* Init Lower Higher */
{ 14, 0, 0, 8, 2, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
10, /* Energy */
0,
12,
0,
1,
8,
A_INT,
SPE_DIG,
-4 },
{ { "Healer", 0 },
{ { "Rhizotomist", 0 },
{ "Empiric", 0 },
{ "Embalmer", 0 },
{ "Dresser", 0 },
{ "Medicus ossium", "Medica ossium" },
{ "Herbalist", 0 },
{ "Magister", "Magistra" },
{ "Physician", 0 },
{ "Chirurgeon", 0 } },
"_Athena", "Hermes", "Poseidon", /* Greek */
"Hea",
"the Temple of Epidaurus",
"the Temple of Coeus",
PM_HEALER,
NON_PM,
PM_HIPPOCRATES,
PM_ATTENDANT,
PM_CYCLOPS,
PM_GIANT_RAT,
PM_SNAKE,
S_RODENT,
S_YETI,
ART_STAFF_OF_AESCULAPIUS,
MH_HUMAN | MH_GNOME | ROLE_MALE | ROLE_FEMALE | ROLE_NEUTRAL,
/* Str Int Wis Dex Con Cha */
{ 7, 7, 13, 7, 11, 16 },
{ 15, 20, 20, 15, 25, 5 },
/* Init Lower Higher */
{ 11, 0, 0, 8, 1, 0 }, /* Hit points */
{ 1, 4, 0, 1, 0, 2 },
20, /* Energy */
10,
3,
-3,
2,
10,
A_WIS,
SPE_CURE_SICKNESS,
-4 },
{ { "Knight", 0 },
{ { "Gallant", 0 },
{ "Esquire", 0 },
{ "Bachelor", 0 },
{ "Sergeant", 0 },
{ "Knight", 0 },
{ "Banneret", 0 },
{ "Chevalier", "Chevaliere" },
{ "Seignieur", "Dame" },
{ "Paladin", 0 } },
"Lugh", "_Brigit", "Manannan Mac Lir", /* Celtic */
"Kni",
"Camelot Castle",
"the Isle of Glass",
PM_KNIGHT,
PM_PONY,
PM_KING_ARTHUR,
PM_PAGE,
PM_IXOTH,
PM_QUASIT,
PM_OCHRE_JELLY,
S_IMP,
S_JELLY,
ART_MAGIC_MIRROR_OF_MERLIN,
MH_HUMAN | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL,
/* Str Int Wis Dex Con Cha */
{ 13, 7, 14, 8, 10, 17 },
{ 30, 15, 15, 10, 20, 10 },
/* Init Lower Higher */
{ 14, 0, 0, 8, 2, 0 }, /* Hit points */
{ 1, 4, 0, 1, 0, 2 },
10, /* Energy */
10,
8,
-2,
0,
9,
A_WIS,
SPE_TURN_UNDEAD,
-4 },
{ { "Monk", 0 },
{ { "Candidate", 0 },
{ "Novice", 0 },
{ "Initiate", 0 },
{ "Student of Stones", 0 },
{ "Student of Waters", 0 },
{ "Student of Metals", 0 },
{ "Student of Winds", 0 },
{ "Student of Fire", 0 },
{ "Master", 0 } },
"Shan Lai Ching", "Chih Sung-tzu", "Huan Ti", /* Chinese */
"Mon",
"the Monastery of Chan-Sune",
"the Monastery of the Earth-Lord",
PM_MONK,
NON_PM,
PM_GRAND_MASTER,
PM_ABBOT,
PM_MASTER_KAEN,
PM_EARTH_ELEMENTAL,
PM_XORN,
S_ELEMENTAL,
S_XORN,
ART_EYES_OF_THE_OVERWORLD,
MH_HUMAN | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL | ROLE_NEUTRAL
| ROLE_CHAOTIC,
/* Str Int Wis Dex Con Cha */
{ 10, 7, 8, 8, 7, 7 },
{ 25, 10, 20, 20, 15, 10 },
/* Init Lower Higher */
{ 12, 0, 0, 8, 1, 0 }, /* Hit points */
{ 2, 2, 0, 2, 0, 2 },
10, /* Energy */
10,
8,
-2,
2,
20,
A_WIS,
SPE_RESTORE_ABILITY,
-4 },
{ { "Priest", "Priestess" },
{ { "Aspirant", 0 },
{ "Acolyte", 0 },
{ "Adept", 0 },
{ "Priest", "Priestess" },
{ "Curate", 0 },
{ "Canon", "Canoness" },
{ "Lama", 0 },
{ "Patriarch", "Matriarch" },
{ "High Priest", "High Priestess" } },
0, 0, 0, /* deities from a randomly chosen other role will be used */
"Pri",
"the Great Temple",
"the Temple of Nalzok",
PM_CLERIC,
NON_PM,
PM_ARCH_PRIEST,
PM_ACOLYTE,
PM_NALZOK,
PM_HUMAN_ZOMBIE,
PM_WRAITH,
S_ZOMBIE,
S_WRAITH,
ART_MITRE_OF_HOLINESS,
MH_HUMAN | MH_ELF | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL | ROLE_NEUTRAL
| ROLE_CHAOTIC,
/* Str Int Wis Dex Con Cha */
{ 7, 7, 10, 7, 7, 7 },
{ 15, 10, 30, 15, 20, 10 },
/* Init Lower Higher */
{ 12, 0, 0, 8, 1, 0 }, /* Hit points */
{ 4, 3, 0, 2, 0, 2 },
10, /* Energy */
0,
3,
-2,
2,
10,
A_WIS,
SPE_REMOVE_CURSE,
-4 },
/* Note: Rogue precedes Ranger so that use of `-R' on the command line
retains its traditional meaning. */
{ { "Rogue", 0 },
{ { "Footpad", 0 },
{ "Cutpurse", 0 },
{ "Rogue", 0 },
{ "Pilferer", 0 },
{ "Robber", 0 },
{ "Burglar", 0 },
{ "Filcher", 0 },
{ "Magsman", "Magswoman" },
{ "Thief", 0 } },
"Issek", "Mog", "Kos", /* Nehwon */
"Rog",
"the Thieves' Guild Hall",
"the Assassins' Guild Hall",
PM_ROGUE,
NON_PM,
PM_MASTER_OF_THIEVES,
PM_THUG,
PM_MASTER_ASSASSIN,
PM_LEPRECHAUN,
PM_GUARDIAN_NAGA,
S_NYMPH,
S_NAGA,
ART_MASTER_KEY_OF_THIEVERY,
MH_HUMAN | MH_ORC | ROLE_MALE | ROLE_FEMALE | ROLE_CHAOTIC,
/* Str Int Wis Dex Con Cha */
{ 7, 7, 7, 10, 7, 6 },
{ 20, 10, 10, 30, 20, 10 },
/* Init Lower Higher */
{ 10, 0, 0, 8, 1, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
11, /* Energy */
10,
8,
0,
1,
9,
A_INT,
SPE_DETECT_TREASURE,
-4 },
{ { "Ranger", 0 },
{
#if 0 /* OBSOLETE */
{"Edhel", "Elleth"},
{"Edhel", "Elleth"}, /* elf-maid */
{"Ohtar", "Ohtie"}, /* warrior */
{"Kano", "Kanie"}, /* commander (Q.) ['a] educated guess,
until further research- SAC */
{"Arandur"," Aranduriel"}, /* king's servant, minister (Q.) - guess */
{"Hir", "Hiril"}, /* lord, lady (S.) ['ir] */
{"Aredhel", "Arwen"}, /* noble elf, maiden (S.) */
{"Ernil", "Elentariel"}, /* prince (S.), elf-maiden (Q.) */
{"Elentar", "Elentari"}, /* Star-king, -queen (Q.) */
"Solonor Thelandira", "Aerdrie Faenya", "Lolth", /* Elven */
#endif
{ "Tenderfoot", 0 },
{ "Lookout", 0 },
{ "Trailblazer", 0 },
{ "Reconnoiterer", "Reconnoiteress" },
{ "Scout", 0 },
{ "Arbalester", 0 }, /* One skilled at crossbows */
{ "Archer", 0 },
{ "Sharpshooter", 0 },
{ "Marksman", "Markswoman" } },
"Mercury", "_Venus", "Mars", /* Roman/planets */
"Ran",
"Orion's camp",
"the cave of the wumpus",
PM_RANGER,
PM_LITTLE_DOG /* Orion & canis major */,
PM_ORION,
PM_HUNTER,
PM_SCORPIUS,
PM_FOREST_CENTAUR,
PM_SCORPION,
S_CENTAUR,
S_SPIDER,
ART_LONGBOW_OF_DIANA,
MH_HUMAN | MH_ELF | MH_GNOME | MH_ORC | ROLE_MALE | ROLE_FEMALE
| ROLE_NEUTRAL | ROLE_CHAOTIC,
/* Str Int Wis Dex Con Cha */
{ 13, 13, 13, 9, 13, 7 },
{ 30, 10, 10, 20, 20, 10 },
/* Init Lower Higher */
{ 13, 0, 0, 6, 1, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
12, /* Energy */
10,
9,
2,
1,
10,
A_INT,
SPE_INVISIBILITY,
-4 },
{ { "Samurai", 0 },
{ { "Hatamoto", 0 }, /* Banner Knight */
{ "Ronin", 0 }, /* no allegiance */
{ "Ninja", "Kunoichi" }, /* secret society */
{ "Joshu", 0 }, /* heads a castle */
{ "Ryoshu", 0 }, /* has a territory */
{ "Kokushu", 0 }, /* heads a province */
{ "Daimyo", 0 }, /* a samurai lord */
{ "Kuge", 0 }, /* Noble of the Court */
{ "Shogun", 0 } }, /* supreme commander, warlord */
"_Amaterasu Omikami", "Raijin", "Susanowo", /* Japanese */
"Sam",
"the Castle of the Taro Clan",
"the Shogun's Castle",
PM_SAMURAI,
PM_LITTLE_DOG,
PM_LORD_SATO,
PM_ROSHI,
PM_ASHIKAGA_TAKAUJI,
PM_WOLF,
PM_STALKER,
S_DOG,
S_ELEMENTAL,
ART_TSURUGI_OF_MURAMASA,
MH_HUMAN | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL,
/* Str Int Wis Dex Con Cha */
{ 10, 8, 7, 10, 17, 6 },
{ 30, 10, 8, 30, 14, 8 },
/* Init Lower Higher */
{ 13, 0, 0, 8, 1, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
11, /* Energy */
10,
10,
0,
0,
8,
A_INT,
SPE_CLAIRVOYANCE,
-4 },
{ { "Tourist", 0 },
{ { "Rambler", 0 },
{ "Sightseer", 0 },
{ "Excursionist", 0 },
{ "Peregrinator", "Peregrinatrix" },
{ "Traveler", 0 },
{ "Journeyer", 0 },
{ "Voyager", 0 },
{ "Explorer", 0 },
{ "Adventurer", 0 } },
"Blind Io", "_The Lady", "Offler", /* Discworld */
"Tou",
"Ankh-Morpork",
"the Thieves' Guild Hall",
PM_TOURIST,
NON_PM,
PM_TWOFLOWER,
PM_GUIDE,
PM_MASTER_OF_THIEVES,
PM_GIANT_SPIDER,
PM_FOREST_CENTAUR,
S_SPIDER,
S_CENTAUR,
ART_YENDORIAN_EXPRESS_CARD,
MH_HUMAN | ROLE_MALE | ROLE_FEMALE | ROLE_NEUTRAL,
/* Str Int Wis Dex Con Cha */
{ 7, 10, 6, 7, 7, 10 },
{ 15, 10, 10, 15, 30, 20 },
/* Init Lower Higher */
{ 8, 0, 0, 8, 0, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
14, /* Energy */
0,
5,
1,
2,
10,
A_INT,
SPE_CHARM_MONSTER,
-4 },
{ { "Valkyrie", 0 },
{ { "Stripling", 0 },
{ "Skirmisher", 0 },
{ "Fighter", 0 },
{ "Man-at-arms", "Woman-at-arms" },
{ "Warrior", 0 },
{ "Swashbuckler", 0 },
{ "Hero", "Heroine" },
{ "Champion", 0 },
{ "Lord", "Lady" } },
"Tyr", "Odin", "Loki", /* Norse */
"Val",
"the Shrine of Destiny",
"the cave of Surtur",
PM_VALKYRIE,
NON_PM /*PM_WINTER_WOLF_CUB*/,
PM_NORN,
PM_WARRIOR,
PM_LORD_SURTUR,
PM_FIRE_ANT,
PM_FIRE_GIANT,
S_ANT,
S_GIANT,
ART_ORB_OF_FATE,
MH_HUMAN | MH_DWARF | ROLE_FEMALE | ROLE_LAWFUL | ROLE_NEUTRAL,
/* Str Int Wis Dex Con Cha */
{ 10, 7, 7, 7, 10, 7 },
{ 30, 6, 7, 20, 30, 7 },
/* Init Lower Higher */
{ 14, 0, 0, 8, 2, 0 }, /* Hit points */
{ 1, 0, 0, 1, 0, 1 },
10, /* Energy */
0,
10,
-2,
0,
9,
A_WIS,
SPE_CONE_OF_COLD,
-4 },
{ { "Wizard", 0 },
{ { "Evoker", 0 },
{ "Conjurer", 0 },
{ "Thaumaturge", 0 },
{ "Magician", 0 },
{ "Enchanter", "Enchantress" },
{ "Sorcerer", "Sorceress" },
{ "Necromancer", 0 },
{ "Wizard", 0 },
{ "Mage", 0 } },
"Ptah", "Thoth", "Anhur", /* Egyptian */
"Wiz",
"the Lonely Tower",
"the Tower of Darkness",
PM_WIZARD,
PM_KITTEN,
PM_NEFERET_THE_GREEN,
PM_APPRENTICE,
PM_DARK_ONE,
PM_VAMPIRE_BAT,
PM_XORN,
S_BAT,
S_WRAITH,
ART_EYE_OF_THE_AETHIOPICA,
MH_HUMAN | MH_ELF | MH_GNOME | MH_ORC | ROLE_MALE | ROLE_FEMALE
| ROLE_NEUTRAL | ROLE_CHAOTIC,
/* Str Int Wis Dex Con Cha */
{ 7, 10, 7, 7, 7, 7 },
{ 10, 30, 10, 20, 20, 10 },
/* Init Lower Higher */
{ 10, 0, 0, 8, 1, 0 }, /* Hit points */
{ 4, 3, 0, 2, 0, 3 },
12, /* Energy */
0,
1,
0,
3,
10,
A_INT,
SPE_MAGIC_MISSILE,
-4 },
/* Array terminator */
{ { 0, 0 } }
};
/* Table of all races */
const struct Race races[] = {
{
"human",
"human",
"humanity",
"Hum",
{ "man", "woman" },
PM_HUMAN,
PM_HUMAN_MUMMY,
PM_HUMAN_ZOMBIE,
MH_HUMAN | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL | ROLE_NEUTRAL
| ROLE_CHAOTIC,
MH_HUMAN,
0,
MH_GNOME | MH_ORC,
/* Str Int Wis Dex Con Cha */
{ 3, 3, 3, 3, 3, 3 },
{ STR18(100), 18, 18, 18, 18, 18 },
/* Init Lower Higher */
{ 2, 0, 0, 2, 1, 0 }, /* Hit points */
{ 1, 0, 2, 0, 2, 0 } /* Energy */
},
{
"elf",
"elven",
"elvenkind",
"Elf",
{ 0, 0 },
PM_ELF,
PM_ELF_MUMMY,
PM_ELF_ZOMBIE,
MH_ELF | ROLE_MALE | ROLE_FEMALE | ROLE_CHAOTIC,
MH_ELF,
MH_ELF,
MH_ORC,
/* Str Int Wis Dex Con Cha */
{ 3, 3, 3, 3, 3, 3 },
{ 18, 20, 20, 18, 16, 18 },
/* Init Lower Higher */
{ 1, 0, 0, 1, 1, 0 }, /* Hit points */
{ 2, 0, 3, 0, 3, 0 } /* Energy */
},
{
"dwarf",
"dwarven",
"dwarvenkind",
"Dwa",
{ 0, 0 },
PM_DWARF,
PM_DWARF_MUMMY,
PM_DWARF_ZOMBIE,
MH_DWARF | ROLE_MALE | ROLE_FEMALE | ROLE_LAWFUL,
MH_DWARF,
MH_DWARF | MH_GNOME,
MH_ORC,
/* Str Int Wis Dex Con Cha */
{ 3, 3, 3, 3, 3, 3 },
{ STR18(100), 16, 16, 20, 20, 16 },
/* Init Lower Higher */
{ 4, 0, 0, 3, 2, 0 }, /* Hit points */
{ 0, 0, 0, 0, 0, 0 } /* Energy */
},
{
"gnome",
"gnomish",
"gnomehood",
"Gno",
{ 0, 0 },
PM_GNOME,
PM_GNOME_MUMMY,
PM_GNOME_ZOMBIE,
MH_GNOME | ROLE_MALE | ROLE_FEMALE | ROLE_NEUTRAL,
MH_GNOME,
MH_DWARF | MH_GNOME,
MH_HUMAN,
/* Str Int Wis Dex Con Cha */
{ 3, 3, 3, 3, 3, 3 },
{ STR18(50), 19, 18, 18, 18, 18 },
/* Init Lower Higher */
{ 1, 0, 0, 1, 0, 0 }, /* Hit points */
{ 2, 0, 2, 0, 2, 0 } /* Energy */
},
{
"orc",
"orcish",
"orcdom",
"Orc",
{ 0, 0 },
PM_ORC,
PM_ORC_MUMMY,
PM_ORC_ZOMBIE,
MH_ORC | ROLE_MALE | ROLE_FEMALE | ROLE_CHAOTIC,
MH_ORC,
0,
MH_HUMAN | MH_ELF | MH_DWARF,
/* Str Int Wis Dex Con Cha */
{ 3, 3, 3, 3, 3, 3 },
{ STR18(50), 16, 16, 18, 18, 16 },
/* Init Lower Higher */
{ 1, 0, 0, 1, 0, 0 }, /* Hit points */
{ 1, 0, 1, 0, 1, 0 } /* Energy */
},
/* Array terminator */
{ 0, 0, 0, 0 }
};
/* Table of all genders */
const struct Gender genders[] = {
{ "male", "he", "him", "his", "Mal", ROLE_MALE },
{ "female", "she", "her", "her", "Fem", ROLE_FEMALE },
{ "neuter", "it", "it", "its", "Ntr", ROLE_NEUTER },
/* used by pronoun_gender() when hallucinating */
{ "group", "they", "them", "their", "Grp", 0 },
};
/* Table of all alignments */
const struct Align aligns[] = {
{ "law", "lawful", "Law", ROLE_LAWFUL, A_LAWFUL },
{ "balance", "neutral", "Neu", ROLE_NEUTRAL, A_NEUTRAL },
{ "chaos", "chaotic", "Cha", ROLE_CHAOTIC, A_CHAOTIC },
{ "evil", "unaligned", "Una", 0, A_NONE }
};
static int randrole_filtered(void);
static char *promptsep(char *, int);
static int role_gendercount(int);
static int race_alignmentcount(int);
/* used by str2XXX() */
static char NEARDATA randomstr[] = "random";
boolean
validrole(int rolenum)
{
return (boolean) (rolenum >= 0 && rolenum < SIZE(roles) - 1);
}
int
randrole(boolean for_display)
{
int res = SIZE(roles) - 1;
if (for_display)
res = rn2_on_display_rng(res);
else
res = rn2(res);
return res;
}
static int
randrole_filtered(void)
{
int i, n = 0, set[SIZE(roles)];
/* this doesn't rule out impossible combinations but attempts to
honor all the filter masks */
for (i = 0; i < SIZE(roles) - 1; ++i) /* -1: avoid terminating element */
if (ok_role(i, ROLE_NONE, ROLE_NONE, ROLE_NONE)
&& ok_race(i, ROLE_RANDOM, ROLE_NONE, ROLE_NONE)
&& ok_gend(i, ROLE_NONE, ROLE_RANDOM, ROLE_NONE)
&& ok_align(i, ROLE_NONE, ROLE_NONE, ROLE_RANDOM))
set[n++] = i;
return n ? set[rn2(n)] : randrole(FALSE);
}
int
str2role(const char *str)
{
int i, len;
/* Is str valid? */
if (!str || !str[0])
return ROLE_NONE;
/* Match as much of str as is provided */
len = Strlen(str);
for (i = 0; roles[i].name.m; i++) {
/* Does it match the male name? */
if (!strncmpi(str, roles[i].name.m, len))
return i;
/* Or the female name? */
if (roles[i].name.f && !strncmpi(str, roles[i].name.f, len))
return i;
/* Or the filecode? */
if (!strcmpi(str, roles[i].filecode))
return i;
}
if ((len == 1 && (*str == '*' || *str == '@'))
|| !strncmpi(str, randomstr, len))
return ROLE_RANDOM;
/* Couldn't find anything appropriate */
return ROLE_NONE;
}
boolean
validrace(int rolenum, int racenum)
{
/* Assumes validrole */
return (boolean) (racenum >= 0 && racenum < SIZE(races) - 1
&& (roles[rolenum].allow & races[racenum].allow
& ROLE_RACEMASK));
}
int
randrace(int rolenum)
{
int i, n = 0;
/* Count the number of valid races */
for (i = 0; races[i].noun; i++)
if (roles[rolenum].allow & races[i].allow & ROLE_RACEMASK)
n++;
/* Pick a random race */
/* Use a factor of 100 in case of bad random number generators */
if (n)
n = rn2(n * 100) / 100;
for (i = 0; races[i].noun; i++)
if (roles[rolenum].allow & races[i].allow & ROLE_RACEMASK) {
if (n)
n--;
else
return i;
}
/* This role has no permitted races? */
return rn2(SIZE(races) - 1);
}
int
str2race(const char *str)
{
int i, len;
/* Is str valid? */
if (!str || !str[0])
return ROLE_NONE;
/* Match as much of str as is provided */
len = Strlen(str);
for (i = 0; races[i].noun; i++) {
/* Does it match the noun? */
if (!strncmpi(str, races[i].noun, len))
return i;
/* Or the filecode? */
if (!strcmpi(str, races[i].filecode))
return i;
}
if ((len == 1 && (*str == '*' || *str == '@'))
|| !strncmpi(str, randomstr, len))
return ROLE_RANDOM;
/* Couldn't find anything appropriate */
return ROLE_NONE;
}
boolean
validgend(int rolenum, int racenum, int gendnum)
{
/* Assumes validrole and validrace */
return (boolean) (gendnum >= 0 && gendnum < ROLE_GENDERS
&& (roles[rolenum].allow & races[racenum].allow
& genders[gendnum].allow & ROLE_GENDMASK));
}
int
randgend(int rolenum, int racenum)
{
int i, n = 0;
/* Count the number of valid genders */
for (i = 0; i < ROLE_GENDERS; i++)
if (roles[rolenum].allow & races[racenum].allow & genders[i].allow
& ROLE_GENDMASK)
n++;
/* Pick a random gender */
if (n)
n = rn2(n);
for (i = 0; i < ROLE_GENDERS; i++)
if (roles[rolenum].allow & races[racenum].allow & genders[i].allow
& ROLE_GENDMASK) {
if (n)
n--;
else
return i;
}
/* This role/race has no permitted genders? */
return rn2(ROLE_GENDERS);
}
int
str2gend(const char *str)
{
int i, len;
/* Is str valid? */
if (!str || !str[0])
return ROLE_NONE;
/* Match as much of str as is provided */
len = Strlen(str);
for (i = 0; i < ROLE_GENDERS; i++) {
/* Does it match the adjective? */
if (!strncmpi(str, genders[i].adj, len))
return i;
/* Or the filecode? */
if (!strcmpi(str, genders[i].filecode))
return i;
}
if ((len == 1 && (*str == '*' || *str == '@'))
|| !strncmpi(str, randomstr, len))
return ROLE_RANDOM;
/* Couldn't find anything appropriate */
return ROLE_NONE;
}
boolean
validalign(int rolenum, int racenum, int alignnum)
{
/* Assumes validrole and validrace */
return (boolean) (alignnum >= 0 && alignnum < ROLE_ALIGNS
&& (roles[rolenum].allow & races[racenum].allow
& aligns[alignnum].allow & ROLE_ALIGNMASK));
}
int
randalign(int rolenum, int racenum)
{
int i, n = 0;
/* Count the number of valid alignments */
for (i = 0; i < ROLE_ALIGNS; i++)
if (roles[rolenum].allow & races[racenum].allow & aligns[i].allow
& ROLE_ALIGNMASK)
n++;
/* Pick a random alignment */
if (n)
n = rn2(n);
for (i = 0; i < ROLE_ALIGNS; i++)
if (roles[rolenum].allow & races[racenum].allow & aligns[i].allow
& ROLE_ALIGNMASK) {
if (n)
n--;
else
return i;
}
/* This role/race has no permitted alignments? */
return rn2(ROLE_ALIGNS);
}
int
str2align(const char *str)
{
int i, len;
/* Is str valid? */
if (!str || !str[0])
return ROLE_NONE;
/* Match as much of str as is provided */
len = Strlen(str);
for (i = 0; i < ROLE_ALIGNS; i++) {
/* Does it match the adjective? */
if (!strncmpi(str, aligns[i].adj, len))
return i;
/* Or the filecode? */
if (!strcmpi(str, aligns[i].filecode))
return i;
}
if ((len == 1 && (*str == '*' || *str == '@'))
|| !strncmpi(str, randomstr, len))
return ROLE_RANDOM;
/* Couldn't find anything appropriate */
return ROLE_NONE;
}
/* is rolenum compatible with any racenum/gendnum/alignnum constraints? */
boolean
ok_role(int rolenum, int racenum, int gendnum, int alignnum)
{
int i;
short allow;
if (rolenum >= 0 && rolenum < SIZE(roles) - 1) {
if (g.rfilter.roles[rolenum])
return FALSE;
allow = roles[rolenum].allow;
if (racenum >= 0 && racenum < SIZE(races) - 1
&& !(allow & races[racenum].allow & ROLE_RACEMASK))
return FALSE;
if (gendnum >= 0 && gendnum < ROLE_GENDERS
&& !(allow & genders[gendnum].allow & ROLE_GENDMASK))
return FALSE;
if (alignnum >= 0 && alignnum < ROLE_ALIGNS
&& !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
return FALSE;
return TRUE;
} else {
/* random; check whether any selection is possible */
for (i = 0; i < SIZE(roles) - 1; i++) {
if (g.rfilter.roles[i])
continue;
allow = roles[i].allow;
if (racenum >= 0 && racenum < SIZE(races) - 1
&& !(allow & races[racenum].allow & ROLE_RACEMASK))
continue;
if (gendnum >= 0 && gendnum < ROLE_GENDERS
&& !(allow & genders[gendnum].allow & ROLE_GENDMASK))
continue;
if (alignnum >= 0 && alignnum < ROLE_ALIGNS
&& !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
continue;
return TRUE;
}
return FALSE;
}