Source:NetHack 3.4.3/src/role.c

From NetHackWiki
(Redirected from Source:Ref/Goodbye)
Jump to: navigation, search

Below is the full text to src/role.c from NetHack 3.4.3. To link to a particular line, write [[role.c#line123]], for example.

Top of file

  1. /*	SCCS Id: @(#)role.c	3.4	2003/01/08	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
  3. /* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. #include "hack.h"

Roles

  1. /*** Table of all roles ***/
  2. /* According to AD&D, HD for some classes (ex. Wizard) should be smaller
  3. * (4-sided for wizards).  But this is not AD&D, and using the AD&D
  4. * rule here produces an unplayable character.  Thus I have used a minimum
  5. * of an 10-sided hit die for everything.  Another AD&D change: wizards get
  6. * a minimum strength of 4 since without one you can't teleport or cast
  7. * spells. --KAA
  8. *
  9. * As the wizard has been updated (wizard patch 5 jun '96) their HD can be
  10. * brought closer into line with AD&D. This forces wizards to use magic more
  11. * and distance themselves from their attackers. --LSZ
  12. *
  13. * With the introduction of races, some hit points and energy
  14. * has been reallocated for each race.  The values assigned
  15. * to the roles has been reduced by the amount allocated to
  16. * humans.  --KMH
  17. *
  18. * God names use a leading underscore to flag goddesses.
  19. */

Archeologist

  1. const struct Role roles[] = {
  2. {	{"Archeologist", 0}, {
  3. 	{"Digger",      0},
  4. 	{"Field Worker",0},
  5. 	{"Investigator",0},
  6. 	{"Exhumer",     0},
  7. 	{"Excavator",   0},
  8. 	{"Spelunker",   0},
  9. 	{"Speleologist",0},
  10. 	{"Collector",   0},
  11. 	{"Curator",     0} },
  12. 	"Quetzalcoatl", "Camaxtli", "Huhetotl", /* Central American */
  13. 	"Arc", "the College of Archeology", "the Tomb of the Toltec Kings",
  14. 	PM_ARCHEOLOGIST, NON_PM, NON_PM,
  15. 	PM_LORD_CARNARVON, PM_STUDENT, PM_MINION_OF_HUHETOTL,
  16. 	NON_PM, PM_HUMAN_MUMMY, S_SNAKE, S_MUMMY,
  17. 	ART_ORB_OF_DETECTION,
  18. 	MH_HUMAN|MH_DWARF|MH_GNOME | ROLE_MALE|ROLE_FEMALE |
  19. 	  ROLE_LAWFUL|ROLE_NEUTRAL,
  20. 	/* Str Int Wis Dex Con Cha */
  21. 	{   7, 10, 10,  7,  7,  7 },
  22. 	{  20, 20, 20, 10, 20, 10 },
  23. 	/* Init   Lower  Higher */
  24. 	{ 11, 0,  0, 8,  1, 0 },	/* Hit points */
  25. 	{  1, 0,  0, 1,  0, 1 },14,	/* Energy */
  26. 	10, 5, 0, 2, 10, A_INT, SPE_MAGIC_MAPPING,   -4
  27. },

Barbarian

  1. {	{"Barbarian", 0}, {
  2. 	{"Plunderer",   "Plunderess"},
  3. 	{"Pillager",    0},
  4. 	{"Bandit",      0},
  5. 	{"Brigand",     0},
  6. 	{"Raider",      0},
  7. 	{"Reaver",      0},
  8. 	{"Slayer",      0},
  9. 	{"Chieftain",   "Chieftainess"},
  10. 	{"Conqueror",   "Conqueress"} },
  11. 	"Mitra", "Crom", "Set", /* Hyborian */
  12. 	"Bar", "the Camp of the Duali Tribe", "the Duali Oasis",
  13. 	PM_BARBARIAN, NON_PM, NON_PM,
  14. 	PM_PELIAS, PM_CHIEFTAIN, PM_THOTH_AMON,
  15. 	PM_OGRE, PM_TROLL, S_OGRE, S_TROLL,
  16. 	ART_HEART_OF_AHRIMAN,
  17. 	MH_HUMAN|MH_ORC | ROLE_MALE|ROLE_FEMALE |
  18. 	  ROLE_NEUTRAL|ROLE_CHAOTIC,
  19. 	/* Str Int Wis Dex Con Cha */
  20. 	{  16,  7,  7, 15, 16,  6 },
  21. 	{  30,  6,  7, 20, 30,  7 },
  22. 	/* Init   Lower  Higher */
  23. 	{ 14, 0,  0,10,  2, 0 },	/* Hit points */
  24. 	{  1, 0,  0, 1,  0, 1 },10,	/* Energy */
  25. 	10, 14, 0, 0,  8, A_INT, SPE_HASTE_SELF,      -4
  26. },

Caveman

  1. {	{"Caveman", "Cavewoman"}, {
  2. 	{"Troglodyte",  0},
  3. 	{"Aborigine",   0},
  4. 	{"Wanderer",    0},
  5. 	{"Vagrant",     0},
  6. 	{"Wayfarer",    0},
  7. 	{"Roamer",      0},
  8. 	{"Nomad",       0},
  9. 	{"Rover",       0},
  10. 	{"Pioneer",     0} },
  11. 	"Anu", "_Ishtar", "Anshar", /* Babylonian */
  12. 	"Cav", "the Caves of the Ancestors", "the Dragon's Lair",
  13. 	PM_CAVEMAN, PM_CAVEWOMAN, PM_LITTLE_DOG,
  14. 	PM_SHAMAN_KARNOV, PM_NEANDERTHAL, PM_CHROMATIC_DRAGON,
  15. 	PM_BUGBEAR, PM_HILL_GIANT, S_HUMANOID, S_GIANT,
  16. 	ART_SCEPTRE_OF_MIGHT,
  17. 	MH_HUMAN|MH_DWARF|MH_GNOME | ROLE_MALE|ROLE_FEMALE |
  18. 	  ROLE_LAWFUL|ROLE_NEUTRAL,
  19. 	/* Str Int Wis Dex Con Cha */
  20. 	{  10,  7,  7,  7,  8,  6 },
  21. 	{  30,  6,  7, 20, 30,  7 },
  22. 	/* Init   Lower  Higher */
  23. 	{ 14, 0,  0, 8,  2, 0 },	/* Hit points */
  24. 	{  1, 0,  0, 1,  0, 1 },10,	/* Energy */
  25. 	0, 12, 0, 1,  8, A_INT, SPE_DIG,             -4
  26. },

Healer

  1. {	{"Healer", 0}, {
  2. 	{"Rhizotomist",    0},
  3. 	{"Empiric",        0},
  4. 	{"Embalmer",       0},
  5. 	{"Dresser",        0},
  6. 	{"Medicus ossium", "Medica ossium"},
  7. 	{"Herbalist",      0},
  8. 	{"Magister",       "Magistra"},
  9. 	{"Physician",      0},
  10. 	{"Chirurgeon",     0} },
  11. 	"_Athena", "Hermes", "Poseidon", /* Greek */
  12. 	"Hea", "the Temple of Epidaurus", "the Temple of Coeus",
  13. 	PM_HEALER, NON_PM, NON_PM,
  14. 	PM_HIPPOCRATES, PM_ATTENDANT, PM_CYCLOPS,
  15. 	PM_GIANT_RAT, PM_SNAKE, S_RODENT, S_YETI,
  16. 	ART_STAFF_OF_AESCULAPIUS,
  17. 	MH_HUMAN|MH_GNOME | ROLE_MALE|ROLE_FEMALE | ROLE_NEUTRAL,
  18. 	/* Str Int Wis Dex Con Cha */
  19. 	{   7,  7, 13,  7, 11, 16 },
  20. 	{  15, 20, 20, 15, 25, 5 },
  21. 	/* Init   Lower  Higher */
  22. 	{ 11, 0,  0, 8,  1, 0 },	/* Hit points */
  23. 	{  1, 4,  0, 1,  0, 2 },20,	/* Energy */
  24. 	10, 3,-3, 2, 10, A_WIS, SPE_CURE_SICKNESS,   -4
  25. },

Knight

  1. {	{"Knight", 0}, {
  2. 	{"Gallant",     0},
  3. 	{"Esquire",     0},
  4. 	{"Bachelor",    0},
  5. 	{"Sergeant",    0},
  6. 	{"Knight",      0},
  7. 	{"Banneret",    0},
  8. 	{"Chevalier",   "Chevaliere"},
  9. 	{"Seignieur",   "Dame"},
  10. 	{"Paladin",     0} },
  11. 	"Lugh", "_Brigit", "Manannan Mac Lir", /* Celtic */
  12. 	"Kni", "Camelot Castle", "the Isle of Glass",
  13. 	PM_KNIGHT, NON_PM, PM_PONY,
  14. 	PM_KING_ARTHUR, PM_PAGE, PM_IXOTH,
  15. 	PM_QUASIT, PM_OCHRE_JELLY, S_IMP, S_JELLY,
  16. 	ART_MAGIC_MIRROR_OF_MERLIN,
  17. 	MH_HUMAN | ROLE_MALE|ROLE_FEMALE | ROLE_LAWFUL,
  18. 	/* Str Int Wis Dex Con Cha */
  19. 	{  13,  7, 14,  8, 10, 17 },
  20. 	{  30, 15, 15, 10, 20, 10 },
  21. 	/* Init   Lower  Higher */
  22. 	{ 14, 0,  0, 8,  2, 0 },	/* Hit points */
  23. 	{  1, 4,  0, 1,  0, 2 },10,	/* Energy */
  24. 	10, 8,-2, 0,  9, A_WIS, SPE_TURN_UNDEAD,     -4
  25. },

Monk

  1. {	{"Monk", 0}, {
  2. 	{"Candidate",         0},
  3. 	{"Novice",            0},
  4. 	{"Initiate",          0},
  5. 	{"Student of Stones", 0},
  6. 	{"Student of Waters", 0},
  7. 	{"Student of Metals", 0},
  8. 	{"Student of Winds",  0},
  9. 	{"Student of Fire",   0},
  10. 	{"Master",            0} },
  11. 	"Shan Lai Ching", "Chih Sung-tzu", "Huan Ti", /* Chinese */
  12. 	"Mon", "the Monastery of Chan-Sune",
  13. 	  "the Monastery of the Earth-Lord",
  14. 	PM_MONK, NON_PM, NON_PM,
  15. 	PM_GRAND_MASTER, PM_ABBOT, PM_MASTER_KAEN,
  16. 	PM_EARTH_ELEMENTAL, PM_XORN, S_ELEMENTAL, S_XORN,
  17. 	ART_EYES_OF_THE_OVERWORLD,
  18. 	MH_HUMAN | ROLE_MALE|ROLE_FEMALE |
  19. 	  ROLE_LAWFUL|ROLE_NEUTRAL|ROLE_CHAOTIC,
  20. 	/* Str Int Wis Dex Con Cha */
  21. 	{  10,  7,  8,  8,  7,  7 },
  22. 	{  25, 10, 20, 20, 15, 10 },
  23. 	/* Init   Lower  Higher */
  24. 	{ 12, 0,  0, 8,  1, 0 },	/* Hit points */
  25. 	{  2, 2,  0, 2,  0, 2 },10,	/* Energy */
  26. 	10, 8,-2, 2, 20, A_WIS, SPE_RESTORE_ABILITY, -4
  27. },

Priest

  1. {	{"Priest", "Priestess"}, {
  2. 	{"Aspirant",    0},
  3. 	{"Acolyte",     0},
  4. 	{"Adept",       0},
  5. 	{"Priest",      "Priestess"},
  6. 	{"Curate",      0},
  7. 	{"Canon",       "Canoness"},
  8. 	{"Lama",        0},
  9. 	{"Patriarch",   "Matriarch"},
  10. 	{"High Priest", "High Priestess"} },
  11. 	0, 0, 0,	/* chosen randomly from among the other roles */
  12. 	"Pri", "the Great Temple", "the Temple of Nalzok",
  13. 	PM_PRIEST, PM_PRIESTESS, NON_PM,
  14. 	PM_ARCH_PRIEST, PM_ACOLYTE, PM_NALZOK,
  15. 	PM_HUMAN_ZOMBIE, PM_WRAITH, S_ZOMBIE, S_WRAITH,
  16. 	ART_MITRE_OF_HOLINESS,
  17. 	MH_HUMAN|MH_ELF | ROLE_MALE|ROLE_FEMALE |
  18. 	  ROLE_LAWFUL|ROLE_NEUTRAL|ROLE_CHAOTIC,
  19. 	/* Str Int Wis Dex Con Cha */
  20. 	{   7,  7, 10,  7,  7,  7 },
  21. 	{  15, 10, 30, 15, 20, 10 },
  22. 	/* Init   Lower  Higher */
  23. 	{ 12, 0,  0, 8,  1, 0 },	/* Hit points */
  24. 	{  4, 3,  0, 2,  0, 2 },10,	/* Energy */
  25. 	0, 3,-2, 2, 10, A_WIS, SPE_REMOVE_CURSE,    -4
  26. },

Rogue

  1. /* Note:  Rogue precedes Ranger so that use of `-R' on the command line
  2. retains its traditional meaning. */
  3. {	{"Rogue", 0}, {
  4. 	{"Footpad",     0},
  5. 	{"Cutpurse",    0},
  6. 	{"Rogue",       0},
  7. 	{"Pilferer",    0},
  8. 	{"Robber",      0},
  9. 	{"Burglar",     0},
  10. 	{"Filcher",     0},
  11. 	{"Magsman",     "Magswoman"},
  12. 	{"Thief",       0} },
  13. 	"Issek", "Mog", "Kos", /* Nehwon */
  14. 	"Rog", "the Thieves' Guild Hall", "the Assassins' Guild Hall",
  15. 	PM_ROGUE, NON_PM, NON_PM,
  16. 	PM_MASTER_OF_THIEVES, PM_THUG, PM_MASTER_ASSASSIN,
  17. 	PM_LEPRECHAUN, PM_GUARDIAN_NAGA, S_NYMPH, S_NAGA,
  18. 	ART_MASTER_KEY_OF_THIEVERY,
  19. 	MH_HUMAN|MH_ORC | ROLE_MALE|ROLE_FEMALE |
  20. 	  ROLE_CHAOTIC,
  21. 	/* Str Int Wis Dex Con Cha */
  22. 	{   7,  7,  7, 10,  7,  6 },
  23. 	{  20, 10, 10, 30, 20, 10 },
  24. 	/* Init   Lower  Higher */
  25. 	{ 10, 0,  0, 8,  1, 0 },	/* Hit points */
  26. 	{  1, 0,  0, 1,  0, 1 },11,	/* Energy */
  27. 	10, 8, 0, 1,  9, A_INT, SPE_DETECT_TREASURE, -4
  28. },

Ranger

  1. {	{"Ranger", 0}, {
  2. #if 0	/* OBSOLETE */
  3. 	{"Edhel",       "Elleth"},
  4. 	{"Edhel",       "Elleth"},      /* elf-maid */
  5. 	{"Ohtar",       "Ohtie"},       /* warrior */
  6. 	{"Kano",			/* commander (Q.) ['a] */
  7. 			"Kanie"},	/* educated guess, until further research- SAC */
  8. 	{"Arandur",			/* king's servant, minister (Q.) - guess */
  9. 			"Aranduriel"},	/* educated guess */
  10. 	{"Hir",         "Hiril"},       /* lord, lady (S.) ['ir] */
  11. 	{"Aredhel",     "Arwen"},       /* noble elf, maiden (S.) */
  12. 	{"Ernil",       "Elentariel"},  /* prince (S.), elf-maiden (Q.) */
  13. 	{"Elentar",     "Elentari"},	/* Star-king, -queen (Q.) */
  14. 	"Solonor Thelandira", "Aerdrie Faenya", "Lolth", /* Elven */
  15. #endif
  16. 	{"Tenderfoot",    0},
  17. 	{"Lookout",       0},
  18. 	{"Trailblazer",   0},
  19. 	{"Reconnoiterer", "Reconnoiteress"},
  20. 	{"Scout",         0},
  21. 	{"Arbalester",    0},	/* One skilled at crossbows */
  22. 	{"Archer",        0},
  23. 	{"Sharpshooter",  0},
  24. 	{"Marksman",      "Markswoman"} },
  25. 	"Mercury", "_Venus", "Mars", /* Roman/planets */
  26. 	"Ran", "Orion's camp", "the cave of the wumpus",
  27. 	PM_RANGER, NON_PM, PM_LITTLE_DOG /* Orion & canis major */,
  28. 	PM_ORION, PM_HUNTER, PM_SCORPIUS,
  29. 	PM_FOREST_CENTAUR, PM_SCORPION, S_CENTAUR, S_SPIDER,
  30. 	ART_LONGBOW_OF_DIANA,
  31. 	MH_HUMAN|MH_ELF|MH_GNOME|MH_ORC | ROLE_MALE|ROLE_FEMALE |
  32. 	  ROLE_NEUTRAL|ROLE_CHAOTIC,
  33. 	/* Str Int Wis Dex Con Cha */
  34. 	{  13, 13, 13,  9, 13,  7 },
  35. 	{  30, 10, 10, 20, 20, 10 },
  36. 	/* Init   Lower  Higher */
  37. 	{ 13, 0,  0, 6,  1, 0 },	/* Hit points */
  38. 	{  1, 0,  0, 1,  0, 1 },12,	/* Energy */
  39. 	10, 9, 2, 1, 10, A_INT, SPE_INVISIBILITY,   -4
  40. },

Samurai

  1. {	{"Samurai", 0}, {
  2. 	{"Hatamoto",    0},  /* Banner Knight */
  3. 	{"Ronin",       0},  /* no allegiance */
  4. 	{"Ninja",       "Kunoichi"},  /* secret society */
  5. 	{"Joshu",       0},  /* heads a castle */
  6. 	{"Ryoshu",      0},  /* has a territory */
  7. 	{"Kokushu",     0},  /* heads a province */
  8. 	{"Daimyo",      0},  /* a samurai lord */
  9. 	{"Kuge",        0},  /* Noble of the Court */
  10. 	{"Shogun",      0} },/* supreme commander, warlord */
  11. 	"_Amaterasu Omikami", "Raijin", "Susanowo", /* Japanese */
  12. 	"Sam", "the Castle of the Taro Clan", "the Shogun's Castle",
  13. 	PM_SAMURAI, NON_PM, PM_LITTLE_DOG,
  14. 	PM_LORD_SATO, PM_ROSHI, PM_ASHIKAGA_TAKAUJI,
  15. 	PM_WOLF, PM_STALKER, S_DOG, S_ELEMENTAL,
  16. 	ART_TSURUGI_OF_MURAMASA,
  17. 	MH_HUMAN | ROLE_MALE|ROLE_FEMALE | ROLE_LAWFUL,
  18. 	/* Str Int Wis Dex Con Cha */
  19. 	{  10,  8,  7, 10, 17,  6 },
  20. 	{  30, 10,  8, 30, 14,  8 },
  21. 	/* Init   Lower  Higher */
  22. 	{ 13, 0,  0, 8,  1, 0 },	/* Hit points */
  23. 	{  1, 0,  0, 1,  0, 1 },11,	/* Energy */
  24. 	10, 10, 0, 0,  8, A_INT, SPE_CLAIRVOYANCE,    -4
  25. },

Tourist

  1. #ifdef TOURIST
  2. {	{"Tourist", 0}, {
  3. 	{"Rambler",     0},
  4. 	{"Sightseer",   0},
  5. 	{"Excursionist",0},
  6. 	{"Peregrinator","Peregrinatrix"},
  7. 	{"Traveler",    0},
  8. 	{"Journeyer",   0},
  9. 	{"Voyager",     0},
  10. 	{"Explorer",    0},
  11. 	{"Adventurer",  0} },
  12. 	"Blind Io", "_The Lady", "Offler", /* Discworld */
  13. 	"Tou", "Ankh-Morpork", "the Thieves' Guild Hall",
  14. 	PM_TOURIST, NON_PM, NON_PM,
  15. 	PM_TWOFLOWER, PM_GUIDE, PM_MASTER_OF_THIEVES,
  16. 	PM_GIANT_SPIDER, PM_FOREST_CENTAUR, S_SPIDER, S_CENTAUR,
  17. 	ART_YENDORIAN_EXPRESS_CARD,
  18. 	MH_HUMAN | ROLE_MALE|ROLE_FEMALE | ROLE_NEUTRAL,
  19. 	/* Str Int Wis Dex Con Cha */
  20. 	{   7, 10,  6,  7,  7, 10 },
  21. 	{  15, 10, 10, 15, 30, 20 },
  22. 	/* Init   Lower  Higher */
  23. 	{  8, 0,  0, 8,  0, 0 },	/* Hit points */
  24. 	{  1, 0,  0, 1,  0, 1 },14,	/* Energy */
  25. 	0, 5, 1, 2, 10, A_INT, SPE_CHARM_MONSTER,   -4
  26. },
  27. #endif

Valkyrie

  1. {	{"Valkyrie", 0}, {
  2. 	{"Stripling",   0},
  3. 	{"Skirmisher",  0},
  4. 	{"Fighter",     0},
  5. 	{"Man-at-arms", "Woman-at-arms"},
  6. 	{"Warrior",     0},
  7. 	{"Swashbuckler",0},
  8. 	{"Hero",        "Heroine"},
  9. 	{"Champion",    0},
  10. 	{"Lord",        "Lady"} },
  11. 	"Tyr", "Odin", "Loki", /* Norse */
  12. 	"Val", "the Shrine of Destiny", "the cave of Surtur",
  13. 	PM_VALKYRIE, NON_PM, NON_PM /*PM_WINTER_WOLF_CUB*/,
  14. 	PM_NORN, PM_WARRIOR, PM_LORD_SURTUR,
  15. 	PM_FIRE_ANT, PM_FIRE_GIANT, S_ANT, S_GIANT,
  16. 	ART_ORB_OF_FATE,
  17. 	MH_HUMAN|MH_DWARF | ROLE_FEMALE | ROLE_LAWFUL|ROLE_NEUTRAL,
  18. 	/* Str Int Wis Dex Con Cha */
  19. 	{  10,  7,  7,  7, 10,  7 },
  20. 	{  30,  6,  7, 20, 30,  7 },
  21. 	/* Init   Lower  Higher */
  22. 	{ 14, 0,  0, 8,  2, 0 },	/* Hit points */
  23. 	{  1, 0,  0, 1,  0, 1 },10,	/* Energy */
  24. 	0, 10,-2, 0,  9, A_WIS, SPE_CONE_OF_COLD,    -4
  25. },

Wizard

  1. {	{"Wizard", 0}, {
  2. 	{"Evoker",      0},
  3. 	{"Conjurer",    0},
  4. 	{"Thaumaturge", 0},
  5. 	{"Magician",    0},
  6. 	{"Enchanter",   "Enchantress"},
  7. 	{"Sorcerer",    "Sorceress"},
  8. 	{"Necromancer", 0},
  9. 	{"Wizard",      0},
  10. 	{"Mage",        0} },
  11. 	"Ptah", "Thoth", "Anhur", /* Egyptian */
  12. 	"Wiz", "the Lonely Tower", "the Tower of Darkness",
  13. 	PM_WIZARD, NON_PM, PM_KITTEN,
  14. 	PM_NEFERET_THE_GREEN, PM_APPRENTICE, PM_DARK_ONE,
  15. 	PM_VAMPIRE_BAT, PM_XORN, S_BAT, S_WRAITH,
  16. 	ART_EYE_OF_THE_AETHIOPICA,
  17. 	MH_HUMAN|MH_ELF|MH_GNOME|MH_ORC | ROLE_MALE|ROLE_FEMALE |
  18. 	  ROLE_NEUTRAL|ROLE_CHAOTIC,
  19. 	/* Str Int Wis Dex Con Cha */
  20. 	{   7, 10,  7,  7,  7,  7 },
  21. 	{  10, 30, 10, 20, 20, 10 },
  22. 	/* Init   Lower  Higher */
  23. 	{ 10, 0,  0, 8,  1, 0 },	/* Hit points */
  24. 	{  4, 3,  0, 2,  0, 3 },12,	/* Energy */
  25. 	0, 1, 0, 3, 10, A_INT, SPE_MAGIC_MISSILE,   -4
  26. },
  1. /* Array terminator */
  2. <nowiki>{{0, 0}}</nowiki>
  3. };
  4.  
  5.  
  6. /* The player's role, created at runtime from initial
  7. * choices.  This may be munged in role_init().
  8. */
  9. struct Role urole =
  10. {	{"Undefined", 0}, { {0, 0}, {0, 0}, {0, 0},
  11. 	{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  12. 	"L", "N", "C", "Xxx", "home", "locate",
  13. 	NON_PM, NON_PM, NON_PM, NON_PM, NON_PM, NON_PM,
  14. 	NON_PM, NON_PM, 0, 0, 0, 0,
  15. 	/* Str Int Wis Dex Con Cha */
  16. 	{   7,  7,  7,  7,  7,  7 },
  17. 	{  20, 15, 15, 20, 20, 10 },
  18. 	/* Init   Lower  Higher */
  19. 	{ 10, 0,  0, 8,  1, 0 },	/* Hit points */
  20. 	{  2, 0,  0, 2,  0, 3 },14,	/* Energy */
  21. 	0, 10, 0, 0,  4, A_INT, 0, -3
  22. };

Races

  1. /* Table of all races */
  2. const struct Race races[] = {

Human

  1. {	"human", "human", "humanity", "Hum",
  2. 	{"man", "woman"},
  3. 	PM_HUMAN, NON_PM, PM_HUMAN_MUMMY, PM_HUMAN_ZOMBIE,
  4. 	MH_HUMAN | ROLE_MALE|ROLE_FEMALE |
  5. 	  ROLE_LAWFUL|ROLE_NEUTRAL|ROLE_CHAOTIC,
  6. 	MH_HUMAN, 0, MH_GNOME|MH_ORC,
  7. 	/*    Str     Int Wis Dex Con Cha */
  8. 	{      3,      3,  3,  3,  3,  3 },
  9. 	{ STR18(100), 18, 18, 18, 18, 18 },
  10. 	/* Init   Lower  Higher */
  11. 	{  2, 0,  0, 2,  1, 0 },	/* Hit points */
  12. 	{  1, 0,  2, 0,  2, 0 }		/* Energy */
  13. },

Elf

  1. {	"elf", "elven", "elvenkind", "Elf",
  2. 	{0, 0},
  3. 	PM_ELF, NON_PM, PM_ELF_MUMMY, PM_ELF_ZOMBIE,
  4. 	MH_ELF | ROLE_MALE|ROLE_FEMALE | ROLE_CHAOTIC,
  5. 	MH_ELF, MH_ELF, MH_ORC,
  6. 	/*  Str    Int Wis Dex Con Cha */
  7. 	{    3,     3,  3,  3,  3,  3 },
  8. 	{   18,    20, 20, 18, 16, 18 },
  9. 	/* Init   Lower  Higher */
  10. 	{  1, 0,  0, 1,  1, 0 },	/* Hit points */
  11. 	{  2, 0,  3, 0,  3, 0 }		/* Energy */
  12. },

Dwarf

  1. {	"dwarf", "dwarven", "dwarvenkind", "Dwa",
  2. 	{0, 0},
  3. 	PM_DWARF, NON_PM, PM_DWARF_MUMMY, PM_DWARF_ZOMBIE,
  4. 	MH_DWARF | ROLE_MALE|ROLE_FEMALE | ROLE_LAWFUL,
  5. 	MH_DWARF, MH_DWARF|MH_GNOME, MH_ORC,
  6. 	/*    Str     Int Wis Dex Con Cha */
  7. 	{      3,      3,  3,  3,  3,  3 },
  8. 	{ STR18(100), 16, 16, 20, 20, 16 },
  9. 	/* Init   Lower  Higher */
  10. 	{  4, 0,  0, 3,  2, 0 },	/* Hit points */
  11. 	{  0, 0,  0, 0,  0, 0 }		/* Energy */
  12. },

Gnome

  1. {	"gnome", "gnomish", "gnomehood", "Gno",
  2. 	{0, 0},
  3. 	PM_GNOME, NON_PM, PM_GNOME_MUMMY, PM_GNOME_ZOMBIE,
  4. 	MH_GNOME | ROLE_MALE|ROLE_FEMALE | ROLE_NEUTRAL,
  5. 	MH_GNOME, MH_DWARF|MH_GNOME, MH_HUMAN,
  6. 	/*  Str    Int Wis Dex Con Cha */
  7. 	{    3,     3,  3,  3,  3,  3 },
  8. 	{STR18(50),19, 18, 18, 18, 18 },
  9. 	/* Init   Lower  Higher */
  10. 	{  1, 0,  0, 1,  0, 0 },	/* Hit points */
  11. 	{  2, 0,  2, 0,  2, 0 }		/* Energy */
  12. },

Orc

  1. {	"orc", "orcish", "orcdom", "Orc",
  2. 	{0, 0},
  3. 	PM_ORC, NON_PM, PM_ORC_MUMMY, PM_ORC_ZOMBIE,
  4. 	MH_ORC | ROLE_MALE|ROLE_FEMALE | ROLE_CHAOTIC,
  5. 	MH_ORC, 0, MH_HUMAN|MH_ELF|MH_DWARF,
  6. 	/*  Str    Int Wis Dex Con Cha */
  7. 	{   3,      3,  3,  3,  3,  3 },
  8. 	{STR18(50),16, 16, 18, 18, 16 },
  9. 	/* Init   Lower  Higher */
  10. 	{  1, 0,  0, 1,  0, 0 },	/* Hit points */
  11. 	{  1, 0,  1, 0,  1, 0 }		/* Energy */
  12. },
  1. /* Array terminator */
  2. { 0, 0, 0, 0 }};
  3.  
  4.  
  5. /* The player's race, created at runtime from initial
  6. * choices.  This may be munged in role_init().
  7. */
  8. struct Race urace =
  9. {	"something", "undefined", "something", "Xxx",
  10. 	{0, 0},
  11. 	NON_PM, NON_PM, NON_PM, NON_PM,
  12. 	0, 0, 0, 0,
  13. 	/*    Str     Int Wis Dex Con Cha */
  14. 	{      3,      3,  3,  3,  3,  3 },
  15. 	{ STR18(100), 18, 18, 18, 18, 18 },
  16. 	/* Init   Lower  Higher */
  17. 	{  2, 0,  0, 2,  1, 0 },	/* Hit points */
  18. 	{  1, 0,  2, 0,  2, 0 }		/* Energy */
  19. };

Genders

  1. /* Table of all genders */
  2. const struct Gender genders[] = {
  3. 	{"male",	"he",	"him",	"his",	"Mal",	ROLE_MALE},
  4. 	{"female",	"she",	"her",	"her",	"Fem",	ROLE_FEMALE},
  5. 	{"neuter",	"it",	"it",	"its",	"Ntr",	ROLE_NEUTER}
  6. };

Alignments

  1. /* Table of all alignments */
  2. const struct Align aligns[] = {
  3. 	{"law",		"lawful",	"Law",	ROLE_LAWFUL,	A_LAWFUL},
  4. 	{"balance",	"neutral",	"Neu",	ROLE_NEUTRAL,	A_NEUTRAL},
  5. 	{"chaos",	"chaotic",	"Cha",	ROLE_CHAOTIC,	A_CHAOTIC},
  6. 	{"evil",	"unaligned",	"Una",	0,		A_NONE}
  7. };
  1. STATIC_DCL char * FDECL(promptsep, (char *, int));
  2. STATIC_DCL int FDECL(role_gendercount, (int));
  3. STATIC_DCL int FDECL(race_alignmentcount, (int));
  4.  
  5. /* used by str2XXX() */
  6. static char NEARDATA randomstr[] = "random";

validrole

  1. boolean
  2. validrole(rolenum)
  3. 	int rolenum;
  4. {
  5. 	return (rolenum >= 0 && rolenum < SIZE(roles)-1);
  6. }

randrole

  1. int
  2. randrole()
  3. {
  4. 	return (rn2(SIZE(roles)-1));
  5. }

str2role

  1. int
  2. str2role(str)
  3. 	char *str;
  4. {
  5. 	int i, len;
  6.  
  7. 	/* Is str valid? */
  8. 	if (!str || !str[0])
  9. 	    return ROLE_NONE;
  10.  
  11. 	/* Match as much of str as is provided */
  12. 	len = strlen(str);
  13. 	for (i = 0; roles[i].name.m; i++) {
  14. 	    /* Does it match the male name? */
  15. 	    if (!strncmpi(str, roles[i].name.m, len))
  16. 		return i;
  17. 	    /* Or the female name? */
  18. 	    if (roles[i].name.f && !strncmpi(str, roles[i].name.f, len))
  19. 		return i;
  20. 	    /* Or the filecode? */
  21. 	    if (!strcmpi(str, roles[i].filecode))
  22. 		return i;
  23. 	}
  24.  
  25. 	if ((len == 1 && (*str == '*' || *str == '@')) ||
  26. 		!strncmpi(str, randomstr, len))
  27. 	    return ROLE_RANDOM;
  28.  
  29. 	/* Couldn't find anything appropriate */
  30. 	return ROLE_NONE;
  31. }

validrace

  1. boolean
  2. validrace(rolenum, racenum)
  3. 	int rolenum, racenum;
  4. {
  5. 	/* Assumes validrole */
  6. 	return (racenum >= 0 && racenum < SIZE(races)-1 &&
  7. 		(roles[rolenum].allow & races[racenum].allow & ROLE_RACEMASK));
  8. }

randrace

  1. int
  2. randrace(rolenum)
  3. 	int rolenum;
  4. {
  5. 	int i, n = 0;
  6.  
  7. 	/* Count the number of valid races */
  8. 	for (i = 0; races[i].noun; i++)
  9. 	    if (roles[rolenum].allow & races[i].allow & ROLE_RACEMASK)
  10. 	    	n++;
  11.  
  12. 	/* Pick a random race */
  13. 	/* Use a factor of 100 in case of bad random number generators */
  14. 	if (n) n = rn2(n*100)/100;
  15. 	for (i = 0; races[i].noun; i++)
  16. 	    if (roles[rolenum].allow & races[i].allow & ROLE_RACEMASK) {
  17. 	    	if (n) n--;
  18. 	    	else return (i);
  19. 	    }
  20.  
  21. 	/* This role has no permitted races? */
  22. 	return (rn2(SIZE(races)-1));
  23. }

str2race

  1. int
  2. str2race(str)
  3. 	char *str;
  4. {
  5. 	int i, len;
  6.  
  7. 	/* Is str valid? */
  8. 	if (!str || !str[0])
  9. 	    return ROLE_NONE;
  10.  
  11. 	/* Match as much of str as is provided */
  12. 	len = strlen(str);
  13. 	for (i = 0; races[i].noun; i++) {
  14. 	    /* Does it match the noun? */
  15. 	    if (!strncmpi(str, races[i].noun, len))
  16. 		return i;
  17. 	    /* Or the filecode? */
  18. 	    if (!strcmpi(str, races[i].filecode))
  19. 		return i;
  20. 	}
  21.  
  22. 	if ((len == 1 && (*str == '*' || *str == '@')) ||
  23. 		!strncmpi(str, randomstr, len))
  24. 	    return ROLE_RANDOM;
  25.  
  26. 	/* Couldn't find anything appropriate */
  27. 	return ROLE_NONE;
  28. }

validgend

  1. boolean
  2. validgend(rolenum, racenum, gendnum)
  3. 	int rolenum, racenum, gendnum;
  4. {
  5. 	/* Assumes validrole and validrace */
  6. 	return (gendnum >= 0 && gendnum < ROLE_GENDERS &&
  7. 		(roles[rolenum].allow & races[racenum].allow &
  8. 		 genders[gendnum].allow & ROLE_GENDMASK));
  9. }

randgend

  1. int
  2. randgend(rolenum, racenum)
  3. 	int rolenum, racenum;
  4. {
  5. 	int i, n = 0;
  6.  
  7. 	/* Count the number of valid genders */
  8. 	for (i = 0; i < ROLE_GENDERS; i++)
  9. 	    if (roles[rolenum].allow & races[racenum].allow &
  10. 	    		genders[i].allow & ROLE_GENDMASK)
  11. 	    	n++;
  12.  
  13. 	/* Pick a random gender */
  14. 	if (n) n = rn2(n);
  15. 	for (i = 0; i < ROLE_GENDERS; i++)
  16. 	    if (roles[rolenum].allow & races[racenum].allow &
  17. 	    		genders[i].allow & ROLE_GENDMASK) {
  18. 	    	if (n) n--;
  19. 	    	else return (i);
  20. 	    }
  21.  
  22. 	/* This role/race has no permitted genders? */
  23. 	return (rn2(ROLE_GENDERS));
  24. }

str2gend

  1. int
  2. str2gend(str)
  3. 	char *str;
  4. {
  5. 	int i, len;
  6.  
  7. 	/* Is str valid? */
  8. 	if (!str || !str[0])
  9. 	    return ROLE_NONE;
  10.  
  11. 	/* Match as much of str as is provided */
  12. 	len = strlen(str);
  13. 	for (i = 0; i < ROLE_GENDERS; i++) {
  14. 	    /* Does it match the adjective? */
  15. 	    if (!strncmpi(str, genders[i].adj, len))
  16. 		return i;
  17. 	    /* Or the filecode? */
  18. 	    if (!strcmpi(str, genders[i].filecode))
  19. 		return i;
  20. 	}
  21. 	if ((len == 1 && (*str == '*' || *str == '@')) ||
  22. 		!strncmpi(str, randomstr, len))
  23. 	    return ROLE_RANDOM;
  24.  
  25. 	/* Couldn't find anything appropriate */
  26. 	return ROLE_NONE;
  27. }

validalign

  1. boolean
  2. validalign(rolenum, racenum, alignnum)
  3. 	int rolenum, racenum, alignnum;
  4. {
  5. 	/* Assumes validrole and validrace */
  6. 	return (alignnum >= 0 && alignnum < ROLE_ALIGNS &&
  7. 		(roles[rolenum].allow & races[racenum].allow &
  8. 		 aligns[alignnum].allow & ROLE_ALIGNMASK));
  9. }

randalign

  1. int
  2. randalign(rolenum, racenum)
  3. 	int rolenum, racenum;
  4. {
  5. 	int i, n = 0;
  6.  
  7. 	/* Count the number of valid alignments */
  8. 	for (i = 0; i < ROLE_ALIGNS; i++)
  9. 	    if (roles[rolenum].allow & races[racenum].allow &
  10. 	    		aligns[i].allow & ROLE_ALIGNMASK)
  11. 	    	n++;
  12.  
  13. 	/* Pick a random alignment */
  14. 	if (n) n = rn2(n);
  15. 	for (i = 0; i < ROLE_ALIGNS; i++)
  16. 	    if (roles[rolenum].allow & races[racenum].allow &
  17. 	    		aligns[i].allow & ROLE_ALIGNMASK) {
  18. 	    	if (n) n--;
  19. 	    	else return (i);
  20. 	    }
  21.  
  22. 	/* This role/race has no permitted alignments? */
  23. 	return (rn2(ROLE_ALIGNS));
  24. }

str2align

  1. int
  2. str2align(str)
  3. 	char *str;
  4. {
  5. 	int i, len;
  6.  
  7. 	/* Is str valid? */
  8. 	if (!str || !str[0])
  9. 	    return ROLE_NONE;
  10.  
  11. 	/* Match as much of str as is provided */
  12. 	len = strlen(str);
  13. 	for (i = 0; i < ROLE_ALIGNS; i++) {
  14. 	    /* Does it match the adjective? */
  15. 	    if (!strncmpi(str, aligns[i].adj, len))
  16. 		return i;
  17. 	    /* Or the filecode? */
  18. 	    if (!strcmpi(str, aligns[i].filecode))
  19. 		return i;
  20. 	}
  21. 	if ((len == 1 && (*str == '*' || *str == '@')) ||
  22. 		!strncmpi(str, randomstr, len))
  23. 	    return ROLE_RANDOM;
  24.  
  25. 	/* Couldn't find anything appropriate */
  26. 	return ROLE_NONE;
  27. }
  28.  
  29. /* is rolenum compatible with any racenum/gendnum/alignnum constraints? */

ok_role

  1. boolean
  2. ok_role(rolenum, racenum, gendnum, alignnum)
  3. int rolenum, racenum, gendnum, alignnum;
  4. {
  5. int i;
  6. short allow;
  7.  
  8. if (rolenum >= 0 && rolenum < SIZE(roles)-1) {
  9. 	allow = roles[rolenum].allow;
  10. 	if (racenum >= 0 && racenum < SIZE(races)-1 &&
  11. 		!(allow & races[racenum].allow & ROLE_RACEMASK))
  12. 	    return FALSE;
  13. 	if (gendnum >= 0 && gendnum < ROLE_GENDERS &&
  14. 		!(allow & genders[gendnum].allow & ROLE_GENDMASK))
  15. 	    return FALSE;
  16. 	if (alignnum >= 0 && alignnum < ROLE_ALIGNS &&
  17. 		!(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
  18. 	    return FALSE;
  19. 	return TRUE;
  20. } else {
  21. 	for (i = 0; i < SIZE(roles)-1; i++) {
  22. 	    allow = roles[i].allow;
  23. 	    if (racenum >= 0 && racenum < SIZE(races)-1 &&
  24. 		    !(allow & races[racenum].allow & ROLE_RACEMASK))
  25. 		continue;
  26. 	    if (gendnum >= 0 && gendnum < ROLE_GENDERS &&
  27. 		    !(allow & genders[gendnum].allow & ROLE_GENDMASK))
  28. 		continue;
  29. 	    if (alignnum >= 0 && alignnum < ROLE_ALIGNS &&
  30. 		    !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
  31. 		continue;
  32. 	    return TRUE;
  33. 	}
  34. 	return FALSE;
  35. }
  36. }

pick_role

  1. /* pick a random role subject to any racenum/gendnum/alignnum constraints */
  2. /* If pickhow == PICK_RIGID a role is returned only if there is  */
  3. /* a single possibility */
  4. int
  5. pick_role(racenum, gendnum, alignnum, pickhow)
  6. int racenum, gendnum, alignnum, pickhow;
  7. {
  8. int i;
  9. int roles_ok = 0;
  10.  
  11. for (i = 0; i < SIZE(roles)-1; i++) {
  12. 	if (ok_role(i, racenum, gendnum, alignnum))
  13. 	    roles_ok++;
  14. }
  15. if (roles_ok == 0 || (roles_ok > 1 && pickhow == PICK_RIGID))
  16. 	return ROLE_NONE;
  17. roles_ok = rn2(roles_ok);
  18. for (i = 0; i < SIZE(roles)-1; i++) {
  19. 	if (ok_role(i, racenum, gendnum, alignnum)) {
  20. 	    if (roles_ok == 0)
  21. 		return i;
  22. 	    else
  23. 		roles_ok--;
  24. 	}
  25. }
  26. return ROLE_NONE;
  27. }

ok_race

  1. /* is racenum compatible with any rolenum/gendnum/alignnum constraints? */
  2. boolean
  3. ok_race(rolenum, racenum, gendnum, alignnum)
  4. int rolenum, racenum, gendnum, alignnum;
  5. {
  6. int i;
  7. short allow;
  8.  
  9. if (racenum >= 0 && racenum < SIZE(races)-1) {
  10. 	allow = races[racenum].allow;
  11. 	if (rolenum >= 0 && rolenum < SIZE(roles)-1 &&
  12. 		!(allow & roles[rolenum].allow & ROLE_RACEMASK))
  13. 	    return FALSE;
  14. 	if (gendnum >= 0 && gendnum < ROLE_GENDERS &&
  15. 		!(allow & genders[gendnum].allow & ROLE_GENDMASK))
  16. 	    return FALSE;
  17. 	if (alignnum >= 0 && alignnum < ROLE_ALIGNS &&
  18. 		!(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
  19. 	    return FALSE;
  20. 	return TRUE;
  21. } else {
  22. 	for (i = 0; i < SIZE(races)-1; i++) {
  23. 	    allow = races[i].allow;
  24. 	    if (rolenum >= 0 && rolenum < SIZE(roles)-1 &&
  25. 		    !(allow & roles[rolenum].allow & ROLE_RACEMASK))
  26. 		continue;
  27. 	    if (gendnum >= 0 && gendnum < ROLE_GENDERS &&
  28. 		    !(allow & genders[gendnum].allow & ROLE_GENDMASK))
  29. 		continue;
  30. 	    if (alignnum >= 0 && alignnum < ROLE_ALIGNS &&
  31. 		    !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
  32. 		continue;
  33. 	    return TRUE;
  34. 	}
  35. 	return FALSE;
  36. }
  37. }

pick_race

  1. /* pick a random race subject to any rolenum/gendnum/alignnum constraints */
  2. /* If pickhow == PICK_RIGID a race is returned only if there is  */
  3. /* a single possibility */
  4. int
  5. pick_race(rolenum, gendnum, alignnum, pickhow)
  6. int rolenum, gendnum, alignnum, pickhow;
  7. {
  8. int i;
  9. int races_ok = 0;
  10.  
  11. for (i = 0; i < SIZE(races)-1; i++) {
  12. 	if (ok_race(rolenum, i, gendnum, alignnum))
  13. 	    races_ok++;
  14. }
  15. if (races_ok == 0 || (races_ok > 1 && pickhow == PICK_RIGID))
  16. 	return ROLE_NONE;
  17. races_ok = rn2(races_ok);
  18. for (i = 0; i < SIZE(races)-1; i++) {
  19. 	if (ok_race(rolenum, i, gendnum, alignnum)) {
  20. 	    if (races_ok == 0)
  21. 		return i;
  22. 	    else
  23. 		races_ok--;
  24. 	}
  25. }
  26. return ROLE_NONE;
  27. }

ok_gend

  1. /* is gendnum compatible with any rolenum/racenum/alignnum constraints? */
  2. /* gender and alignment are not comparable (and also not constrainable) */
  3. boolean
  4. ok_gend(rolenum, racenum, gendnum, alignnum)
  5. int rolenum, racenum, gendnum, alignnum;
  6. {
  7. int i;
  8. short allow;
  9.  
  10. if (gendnum >= 0 && gendnum < ROLE_GENDERS) {
  11. 	allow = genders[gendnum].allow;
  12. 	if (rolenum >= 0 && rolenum < SIZE(roles)-1 &&
  13. 		!(allow & roles[rolenum].allow & ROLE_GENDMASK))
  14. 	    return FALSE;
  15. 	if (racenum >= 0 && racenum < SIZE(races)-1 &&
  16. 		!(allow & races[racenum].allow & ROLE_GENDMASK))
  17. 	    return FALSE;
  18. 	return TRUE;
  19. } else {
  20. 	for (i = 0; i < ROLE_GENDERS; i++) {
  21. 	    allow = genders[i].allow;
  22. 	    if (rolenum >= 0 && rolenum < SIZE(roles)-1 &&
  23. 		    !(allow & roles[rolenum].allow & ROLE_GENDMASK))
  24. 		continue;
  25. 	    if (racenum >= 0 && racenum < SIZE(races)-1 &&
  26. 		    !(allow & races[racenum].allow & ROLE_GENDMASK))
  27. 		continue;
  28. 	    return TRUE;
  29. 	}
  30. 	return FALSE;
  31. }
  32. }

pick_gend

  1. /* pick a random gender subject to any rolenum/racenum/alignnum constraints */
  2. /* gender and alignment are not comparable (and also not constrainable) */
  3. /* If pickhow == PICK_RIGID a gender is returned only if there is  */
  4. /* a single possibility */
  5. int
  6. pick_gend(rolenum, racenum, alignnum, pickhow)
  7. int rolenum, racenum, alignnum, pickhow;
  8. {
  9. int i;
  10. int gends_ok = 0;
  11.  
  12. for (i = 0; i < ROLE_GENDERS; i++) {
  13. 	if (ok_gend(rolenum, racenum, i, alignnum))
  14. 	    gends_ok++;
  15. }
  16. if (gends_ok == 0 || (gends_ok > 1 && pickhow == PICK_RIGID))
  17. 	return ROLE_NONE;
  18. gends_ok = rn2(gends_ok);
  19. for (i = 0; i < ROLE_GENDERS; i++) {
  20. 	if (ok_gend(rolenum, racenum, i, alignnum)) {
  21. 	    if (gends_ok == 0)
  22. 		return i;
  23. 	    else
  24. 		gends_ok--;
  25. 	}
  26. }
  27. return ROLE_NONE;
  28. }

ok_align

  1. /* is alignnum compatible with any rolenum/racenum/gendnum constraints? */
  2. /* alignment and gender are not comparable (and also not constrainable) */
  3. boolean
  4. ok_align(rolenum, racenum, gendnum, alignnum)
  5. int rolenum, racenum, gendnum, alignnum;
  6. {
  7. int i;
  8. short allow;
  9.  
  10. if (alignnum >= 0 && alignnum < ROLE_ALIGNS) {
  11. 	allow = aligns[alignnum].allow;
  12. 	if (rolenum >= 0 && rolenum < SIZE(roles)-1 &&
  13. 		!(allow & roles[rolenum].allow & ROLE_ALIGNMASK))
  14. 	    return FALSE;
  15. 	if (racenum >= 0 && racenum < SIZE(races)-1 &&
  16. 		!(allow & races[racenum].allow & ROLE_ALIGNMASK))
  17. 	    return FALSE;
  18. 	return TRUE;
  19. } else {
  20. 	for (i = 0; i < ROLE_ALIGNS; i++) {
  21. 	    allow = races[i].allow;
  22. 	    if (rolenum >= 0 && rolenum < SIZE(roles)-1 &&
  23. 		    !(allow & roles[rolenum].allow & ROLE_ALIGNMASK))
  24. 		continue;
  25. 	    if (racenum >= 0 && racenum < SIZE(races)-1 &&
  26. 		    !(allow & races[racenum].allow & ROLE_ALIGNMASK))
  27. 		continue;
  28. 	    return TRUE;
  29. 	}
  30. 	return FALSE;
  31. }
  32. }

pick_align

  1. /* pick a random alignment subject to any rolenum/racenum/gendnum constraints */
  2. /* alignment and gender are not comparable (and also not constrainable) */
  3. /* If pickhow == PICK_RIGID an alignment is returned only if there is  */
  4. /* a single possibility */
  5. int
  6. pick_align(rolenum, racenum, gendnum, pickhow)
  7. int rolenum, racenum, gendnum, pickhow;
  8. {
  9. int i;
  10. int aligns_ok = 0;
  11.  
  12. for (i = 0; i < ROLE_ALIGNS; i++) {
  13. 	if (ok_align(rolenum, racenum, gendnum, i))
  14. 	    aligns_ok++;
  15. }
  16. if (aligns_ok == 0 || (aligns_ok > 1 && pickhow == PICK_RIGID))
  17. 	return ROLE_NONE;
  18. aligns_ok = rn2(aligns_ok);
  19. for (i = 0; i < ROLE_ALIGNS; i++) {
  20. 	if (ok_align(rolenum, racenum, gendnum, i)) {
  21. 	    if (aligns_ok == 0)
  22. 		return i;
  23. 	    else
  24. 		aligns_ok--;
  25. 	}
  26. }
  27. return ROLE_NONE;
  28. }

rigid_role_checks

  1. void
  2. rigid_role_checks()
  3. {
  4. /* Some roles are limited to a single race, alignment, or gender and
  5. * calling this routine prior to XXX_player_selection() will help
  6. * prevent an extraneous prompt that actually doesn't allow
  7. * you to choose anything further. Note the use of PICK_RIGID which
  8. * causes the pick_XX() routine to return a value only if there is one
  9. * single possible selection, otherwise it returns ROLE_NONE.
  10. *
  11. */
  12. if (flags.initrole == ROLE_RANDOM) {
  13. 	/* If the role was explicitly specified as ROLE_RANDOM
  14. 	 * via -uXXXX-@ then choose the role in here to narrow down
  15. 	 * later choices. Pick a random role in this case.
  16. 	 */
  17. 	flags.initrole = pick_role(flags.initrace, flags.initgend,
  18. 					flags.initalign, PICK_RANDOM);
  19. 	if (flags.initrole < 0)
  20. 	    flags.initrole = randrole();
  21. }
  22. if (flags.initrole != ROLE_NONE) {
  23. 	if (flags.initrace == ROLE_NONE)
  24. 	     flags.initrace = pick_race(flags.initrole, flags.initgend,
  25. 						flags.initalign, PICK_RIGID);
  26. 	if (flags.initalign == ROLE_NONE)
  27. 	     flags.initalign = pick_align(flags.initrole, flags.initrace,
  28. 						flags.initgend, PICK_RIGID);
  29. 	if (flags.initgend == ROLE_NONE)
  30. 	     flags.initgend = pick_gend(flags.initrole, flags.initrace,
  31. 						flags.initalign, PICK_RIGID);
  32. }
  33. }
  34.  
  35. #define BP_ALIGN	0
  36. #define BP_GEND		1
  37. #define BP_RACE		2
  38. #define BP_ROLE		3
  39. #define NUM_BP		4
  40.  
  41. STATIC_VAR char pa[NUM_BP], post_attribs;

promptsep

  1. STATIC_OVL char *
  2. promptsep(buf, num_post_attribs)
  3. char *buf;
  4. int num_post_attribs;
  5. {
  6. 	const char *conj = "and ";
  7. 	if (num_post_attribs > 1
  8. 	    && post_attribs < num_post_attribs && post_attribs > 1)
  9. 	 	Strcat(buf, ","); 
  10. 	Strcat(buf, " ");
  11. 	--post_attribs;
  12. 	if (!post_attribs && num_post_attribs > 1) Strcat(buf, conj);
  13. 	return buf;
  14. }

role_gendercount

  1. STATIC_OVL int
  2. role_gendercount(rolenum)
  3. int rolenum;
  4. {
  5. 	int gendcount = 0;
  6. 	if (validrole(rolenum)) {
  7. 		if (roles[rolenum].allow & ROLE_MALE) ++gendcount;
  8. 		if (roles[rolenum].allow & ROLE_FEMALE) ++gendcount;
  9. 		if (roles[rolenum].allow & ROLE_NEUTER) ++gendcount;
  10. 	}
  11. 	return gendcount;
  12. }

race_alignmentcount

  1. STATIC_OVL int
  2. race_alignmentcount(racenum)
  3. int racenum;
  4. {
  5. 	int aligncount = 0;
  6. 	if (racenum != ROLE_NONE && racenum != ROLE_RANDOM) {
  7. 		if (races[racenum].allow & ROLE_CHAOTIC) ++aligncount;
  8. 		if (races[racenum].allow & ROLE_LAWFUL) ++aligncount;
  9. 		if (races[racenum].allow & ROLE_NEUTRAL) ++aligncount;
  10. 	}
  11. 	return aligncount;
  12. }

root_plselection_prompt

  1. char *
  2. root_plselection_prompt(suppliedbuf, buflen, rolenum, racenum, gendnum, alignnum)
  3. char *suppliedbuf;
  4. int buflen, rolenum, racenum, gendnum, alignnum;
  5. {
  6. 	int k, gendercount = 0, aligncount = 0;
  7. 	char buf[BUFSZ];
  8. 	static char err_ret[] = " character's";
  9. 	boolean donefirst = FALSE;
  10.  
  11. 	if (!suppliedbuf || buflen < 1) return err_ret;
  12.  
  13. 	/* initialize these static variables each time this is called */
  14. 	post_attribs = 0;
  15. 	for (k=0; k < NUM_BP; ++k)
  16. 		pa[k] = 0;
  17. 	buf[0] = '\0';
  18. 	*suppliedbuf = '\0';
  19.  
  20. 	/* How many alignments are allowed for the desired race? */
  21. 	if (racenum != ROLE_NONE && racenum != ROLE_RANDOM)
  22. 		aligncount = race_alignmentcount(racenum);
  23.  
  24. 	if (alignnum != ROLE_NONE && alignnum != ROLE_RANDOM) {
  25. 		/* if race specified, and multiple choice of alignments for it */
  26. 		if ((racenum >= 0) && (aligncount > 1)) {
  27. 			if (donefirst) Strcat(buf, " ");
  28. 			Strcat(buf, aligns[alignnum].adj);
  29. 			donefirst = TRUE;
  30. 		} else {
  31. 			if (donefirst) Strcat(buf, " ");
  32. 			Strcat(buf, aligns[alignnum].adj);
  33. 			donefirst = TRUE;
  34. 		}
  35. 	} else {
  36. 		/* if alignment not specified, but race is specified
  37. 			and only one choice of alignment for that race then
  38. 			don't include it in the later list */
  39. 		if ((((racenum != ROLE_NONE && racenum != ROLE_RANDOM) &&
  40. 			ok_race(rolenum, racenum, gendnum, alignnum))
  41. 		      && (aligncount > 1))
  42. 		     || (racenum == ROLE_NONE || racenum == ROLE_RANDOM)) {
  43. 			pa[BP_ALIGN] = 1;
  44. 			post_attribs++;
  45. 		}
  46. 	}
  47. 	/* <your lawful> */
  48.  
  49. 	/* How many genders are allowed for the desired role? */
  50. 	if (validrole(rolenum))
  51. 		gendercount = role_gendercount(rolenum);
  52.  
  53. 	if (gendnum != ROLE_NONE  && gendnum != ROLE_RANDOM) {
  54. 		if (validrole(rolenum)) {
  55. 		     /* if role specified, and multiple choice of genders for it,
  56. 			and name of role itself does not distinguish gender */
  57. 			if ((rolenum != ROLE_NONE) && (gendercount > 1)
  58. 						&& !roles[rolenum].name.f) {
  59. 				if (donefirst) Strcat(buf, " ");
  60. 				Strcat(buf, genders[gendnum].adj);
  61. 				donefirst = TRUE;
  62. 			}
  63. 	        } else {
  64. 			if (donefirst) Strcat(buf, " ");
  65. 	        	Strcat(buf, genders[gendnum].adj);
  66. 			donefirst = TRUE;
  67. 	        }
  68. 	} else {
  69. 		/* if gender not specified, but role is specified
  70. 			and only one choice of gender then
  71. 			don't include it in the later list */
  72. 		if ((validrole(rolenum) && (gendercount > 1)) || !validrole(rolenum)) {
  73. 			pa[BP_GEND] = 1;
  74. 			post_attribs++;
  75. 		}
  76. 	}
  77. 	/* <your lawful female> */
  78.  
  79. 	if (racenum != ROLE_NONE && racenum != ROLE_RANDOM) {
  80. 		if (validrole(rolenum) && ok_race(rolenum, racenum, gendnum, alignnum)) {
  81. 			if (donefirst) Strcat(buf, " "); 
  82. 			Strcat(buf, (rolenum == ROLE_NONE) ?
  83. 				races[racenum].noun :
  84. 				races[racenum].adj);
  85. 			donefirst = TRUE;
  86. 		} else if (!validrole(rolenum)) {
  87. 			if (donefirst) Strcat(buf, " ");
  88. 			Strcat(buf, races[racenum].noun);
  89. 			donefirst = TRUE;
  90. 		} else {
  91. 			pa[BP_RACE] = 1;
  92. 			post_attribs++;
  93. 		}
  94. 	} else {
  95. 		pa[BP_RACE] = 1;
  96. 		post_attribs++;
  97. 	}
  98. 	/* <your lawful female gnomish> || <your lawful female gnome> */
  99.  
  100. 	if (validrole(rolenum)) {
  101. 		if (donefirst) Strcat(buf, " ");
  102. 		if (gendnum != ROLE_NONE) {
  103. 		    if (gendnum == 1  && roles[rolenum].name.f)
  104. 			Strcat(buf, roles[rolenum].name.f);
  105. 		    else
  106. 			Strcat(buf, roles[rolenum].name.m);
  107. 		} else {
  108. 			if (roles[rolenum].name.f) {
  109. 				Strcat(buf, roles[rolenum].name.m);
  110. 				Strcat(buf, "/");
  111. 				Strcat(buf, roles[rolenum].name.f);
  112. 			} else 
  113. 				Strcat(buf, roles[rolenum].name.m);
  114. 		}
  115. 		donefirst = TRUE;
  116. 	} else if (rolenum == ROLE_NONE) {
  117. 		pa[BP_ROLE] = 1;
  118. 		post_attribs++;
  119. 	}
  120.  
  121. 	if ((racenum == ROLE_NONE || racenum == ROLE_RANDOM) && !validrole(rolenum)) {
  122. 		if (donefirst) Strcat(buf, " ");
  123. 		Strcat(buf, "character");
  124. 		donefirst = TRUE;
  125. 	}
  126. 	/* <your lawful female gnomish cavewoman> || <your lawful female gnome>
  127. 	 *    || <your lawful female character>
  128. 	 */
  129. 	if (buflen > (int) (strlen(buf) + 1)) {
  130. 		Strcpy(suppliedbuf, buf);
  131. 		return suppliedbuf;
  132. 	} else
  133. 		return err_ret;
  134. }

build_plselection_prompt

  1. char *
  2. build_plselection_prompt(buf, buflen, rolenum, racenum, gendnum, alignnum)
  3. char *buf;
  4. int buflen, rolenum, racenum, gendnum, alignnum;
  5. {
  6. 	const char *defprompt = "Shall I pick a character for you? [ynq] ";
  7. 	int num_post_attribs = 0;
  8. 	char tmpbuf[BUFSZ];
  9.  
  10. 	if (buflen < QBUFSZ)
  11. 		return (char *)defprompt;
  12.  
  13. 	Strcpy(tmpbuf, "Shall I pick ");
  14. 	if (racenum != ROLE_NONE || validrole(rolenum))
  15. 		Strcat(tmpbuf, "your ");
  16. 	else {
  17. 		Strcat(tmpbuf, "a ");
  18. 	}
  19. 	/* <your> */
  20.  
  21. 	(void)  root_plselection_prompt(eos(tmpbuf), buflen - strlen(tmpbuf),
  22. 					rolenum, racenum, gendnum, alignnum);
  23. 	Sprintf(buf, "%s", s_suffix(tmpbuf));
  24.  
  25. 	/* buf should now be:
  26. 	 * < your lawful female gnomish cavewoman's> || <your lawful female gnome's>
  27. 	 *    || <your lawful female character's>
  28. 	 *
  29. * Now append the post attributes to it
  30. 	 */
  31.  
  32. 	num_post_attribs = post_attribs;
  33. 	if (post_attribs) {
  34. 		if (pa[BP_RACE]) {
  35. 			(void) promptsep(eos(buf), num_post_attribs);
  36. 			Strcat(buf, "race");
  37. 		}
  38. 		if (pa[BP_ROLE]) {
  39. 			(void) promptsep(eos(buf), num_post_attribs);
  40. 			Strcat(buf, "role");
  41. 		}
  42. 		if (pa[BP_GEND]) {
  43. 			(void) promptsep(eos(buf), num_post_attribs);
  44. 			Strcat(buf, "gender");
  45. 		}
  46. 		if (pa[BP_ALIGN]) {
  47. 			(void) promptsep(eos(buf), num_post_attribs);
  48. 			Strcat(buf, "alignment");
  49. 		}
  50. 	}
  51. 	Strcat(buf, " for you? [ynq] ");
  52. 	return buf;
  53. }
  54.  
  55. #undef BP_ALIGN
  56. #undef BP_GEND
  57. #undef BP_RACE
  58. #undef BP_ROLE
  59. #undef NUM_BP

plnamesuffix

  1. void
  2. plnamesuffix()
  3. {
  4. 	char *sptr, *eptr;
  5. 	int i;
  6.  
  7. 	/* Look for tokens delimited by '-' */
  8. 	if ((eptr = index(plname, '-')) != (char *) 0)
  9. 	    *eptr++ = '\0';
  10. 	while (eptr) {
  11. 	    /* Isolate the next token */
  12. 	    sptr = eptr;
  13. 	    if ((eptr = index(sptr, '-')) != (char *)0)
  14. 		*eptr++ = '\0';
  15.  
  16. 	    /* Try to match it to something */
  17. 	    if ((i = str2role(sptr)) != ROLE_NONE)
  18. 		flags.initrole = i;
  19. 	    else if ((i = str2race(sptr)) != ROLE_NONE)
  20. 		flags.initrace = i;
  21. 	    else if ((i = str2gend(sptr)) != ROLE_NONE)
  22. 		flags.initgend = i;
  23. 	    else if ((i = str2align(sptr)) != ROLE_NONE)
  24. 		flags.initalign = i;
  25. 	}
  26. 	if(!plname[0]) {
  27. 	    askname();
  28. 	    plnamesuffix();
  29. 	}
  30.  
  31. 	/* commas in the plname confuse the record file, convert to spaces */
  32. 	for (sptr = plname; *sptr; sptr++) {
  33. 		if (*sptr == ',') *sptr = ' ';
  34. 	}
  35. }
  36.  
  37.  
  38. /*
  39. *	Special setup modifications here:
  40. *
  41. *	Unfortunately, this is going to have to be done
  42. *	on each newgame or restore, because you lose the permonst mods
  43. *	across a save/restore.  :-)
  44. *
  45. *	1 - The Rogue Leader is the Tourist Nemesis.
  46. *	2 - Priests start with a random alignment - convert the leader and
  47. *	    guardians here.
  48. *	3 - Elves can have one of two different leaders, but can't work it
  49. *	    out here because it requires hacking the level file data (see
  50. *	    sp_lev.c).
  51. *
  52. * This code also replaces quest_init().
  53. */

role_init

  1. void
  2. role_init()
  3. {
  4. 	int alignmnt;
  5.  
  6. 	/* Strip the role letter out of the player name.
  7. 	 * This is included for backwards compatibility.
  8. 	 */
  9. 	plnamesuffix();
  10.  
  11. 	/* Check for a valid role.  Try flags.initrole first. */
  12. 	if (!validrole(flags.initrole)) {
  13. 	    /* Try the player letter second */
  14. 	    if ((flags.initrole = str2role(pl_character)) < 0)
  15. 	    	/* None specified; pick a random role */
  16. 	    	flags.initrole = randrole();
  17. 	}
  18.  
  19. 	/* We now have a valid role index.  Copy the role name back. */
  20. 	/* This should become OBSOLETE */
  21. 	Strcpy(pl_character, roles[flags.initrole].name.m);
  22. 	pl_character[PL_CSIZ-1] = '\0';
  23.  
  24. 	/* Check for a valid race */
  25. 	if (!validrace(flags.initrole, flags.initrace))
  26. 	    flags.initrace = randrace(flags.initrole);
  27.  
  28. 	/* Check for a valid gender.  If new game, check both initgend
  29. 	 * and female.  On restore, assume flags.female is correct. */
  30. 	if (flags.pantheon == -1) {	/* new game */
  31. 	    if (!validgend(flags.initrole, flags.initrace, flags.female))
  32. 		flags.female = !flags.female;
  33. 	}
  34. 	if (!validgend(flags.initrole, flags.initrace, flags.initgend))
  35. 	    /* Note that there is no way to check for an unspecified gender. */
  36. 	    flags.initgend = flags.female;
  37.  
  38. 	/* Check for a valid alignment */
  39. 	if (!validalign(flags.initrole, flags.initrace, flags.initalign))
  40. 	    /* Pick a random alignment */
  41. 	    flags.initalign = randalign(flags.initrole, flags.initrace);
  42. 	alignmnt = aligns[flags.initalign].value;
  43.  
  44. 	/* Initialize urole and urace */
  45. 	urole = roles[flags.initrole];
  46. 	urace = races[flags.initrace];
  47.  
  48. 	/* Fix up the quest leader */
  49. 	if (urole.ldrnum != NON_PM) {
  50. 	    mons[urole.ldrnum].msound = MS_LEADER;
  51. 	    mons[urole.ldrnum].mflags2 |= (M2_PEACEFUL);
  52. 	    mons[urole.ldrnum].mflags3 |= M3_CLOSE;
  53. 	    mons[urole.ldrnum].maligntyp = alignmnt * 3;
  54. 	}
  55.  
  56. 	/* Fix up the quest guardians */
  57. 	if (urole.guardnum != NON_PM) {
  58. 	    mons[urole.guardnum].mflags2 |= (M2_PEACEFUL);
  59. 	    mons[urole.guardnum].maligntyp = alignmnt * 3;
  60. 	}
  61.  
  62. 	/* Fix up the quest nemesis */
  63. 	if (urole.neminum != NON_PM) {
  64. 	    mons[urole.neminum].msound = MS_NEMESIS;
  65. 	    mons[urole.neminum].mflags2 &= ~(M2_PEACEFUL);
  66. 	    mons[urole.neminum].mflags2 |= (M2_NASTY|M2_STALK|M2_HOSTILE);
  67. 	    mons[urole.neminum].mflags3 |= M3_WANTSARTI | M3_WAITFORU;
  68. 	}
  69.  
  70. 	/* Fix up the god names */
  71. 	if (flags.pantheon == -1) {		/* new game */
  72. 	    flags.pantheon = flags.initrole;	/* use own gods */
  73. 	    while (!roles[flags.pantheon].lgod)	/* unless they're missing */
  74. 		flags.pantheon = randrole();
  75. 	}
  76. 	if (!urole.lgod) {
  77. 	    urole.lgod = roles[flags.pantheon].lgod;
  78. 	    urole.ngod = roles[flags.pantheon].ngod;
  79. 	    urole.cgod = roles[flags.pantheon].cgod;
  80. 	}
  81.  
  82. 	/* Fix up infravision */
  83. 	if (mons[urace.malenum].mflags3 & M3_INFRAVISION) {
  84. 	    /* although an infravision intrinsic is possible, infravision
  85. 	     * is purely a property of the physical race.  This means that we
  86. 	     * must put the infravision flag in the player's current race
  87. 	     * (either that or have separate permonst entries for
  88. 	     * elven/non-elven members of each class).  The side effect is that
  89. 	     * all NPCs of that class will have (probably bogus) infravision,
  90. 	     * but since infravision has no effect for NPCs anyway we can
  91. 	     * ignore this.
  92. 	     */
  93. 	    mons[urole.malenum].mflags3 |= M3_INFRAVISION;
  94. 	    if (urole.femalenum != NON_PM)
  95. 	    	mons[urole.femalenum].mflags3 |= M3_INFRAVISION;
  96. 	}
  97.  
  98. 	/* Artifacts are fixed in hack_artifacts() */
  99.  
  100. 	/* Success! */
  101. 	return;
  102. }

Hello

  1. const char *
  2. Hello(mtmp)
  3. struct monst *mtmp;
  4. {
  5. 	switch (Role_switch) {
  6. 	case PM_KNIGHT:
  7. 	    return ("Salutations"); /* Olde English */
  8. 	case PM_SAMURAI:
  9. 	    return (mtmp && mtmp->data == &mons[PM_SHOPKEEPER] ?
  10. 	    		"Irasshaimase" : "Konnichi wa"); /* Japanese */
  11. #ifdef TOURIST
  12. 	case PM_TOURIST:
  13. 	    return ("Aloha");       /* Hawaiian */
  14. #endif
  15. 	case PM_VALKYRIE:
  16. 	    return (
  17. #ifdef MAIL
  18. 	    		mtmp && mtmp->data == &mons[PM_MAIL_DAEMON] ? "Hallo" :
  19. #endif
  20. 	    		"Velkommen");   /* Norse */
  21. 	default:
  22. 	    return ("Hello");
  23. 	}
  24. }

Main article: Welcome message

Goodbye

  1. const char *
  2. Goodbye()
  3. {
  4. 	switch (Role_switch) {
  5. 	case PM_KNIGHT:
  6. 	    return ("Fare thee well");  /* Olde English */
  7. 	case PM_SAMURAI:
  8. 	    return ("Sayonara");        /* Japanese */
  9. #ifdef TOURIST
  10. 	case PM_TOURIST:
  11. 	    return ("Aloha");           /* Hawaiian */
  12. #endif
  13. 	case PM_VALKYRIE:
  14. 	    return ("Farvel");          /* Norse */
  15. 	default:
  16. 	    return ("Goodbye");
  17. 	}
  18. }

Main article: Welcome message#Goodbye message

  1. /* role.c */