Source:NetHack 3.4.3/src/u init.c

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

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

Contents

Top of file

  1. /*	SCCS Id: @(#)u_init.c	3.4	2002/10/22	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  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"
  2.  
  3. struct trobj {
  4. 	short trotyp;
  5. 	schar trspe;
  6. 	char trclass;
  7. 	Bitfield(trquan,6);
  8. 	Bitfield(trbless,2);
  9. };
  10.  
  11. STATIC_DCL void FDECL(ini_inv, (struct trobj *));
  12. STATIC_DCL void FDECL(knows_object,(int));
  13. STATIC_DCL void FDECL(knows_class,(CHAR_P));
  14. STATIC_DCL boolean FDECL(restricted_spell_discipline, (int));
  15.  
  16. #define UNDEF_TYP	0
  17. #define UNDEF_SPE	'\177'
  18. #define UNDEF_BLESS	2

Initial inventories

  1. /*
  2. *	Initial inventory for the various roles.
  3. */

Archeologist initial inventory

  1. static struct trobj Archeologist[] = {
  2. 	/* if adventure has a name...  idea from tan@uvm-gen */
  3. 	{ BULLWHIP, 2, WEAPON_CLASS, 1, UNDEF_BLESS },
  4. 	{ LEATHER_JACKET, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  5. 	{ FEDORA, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  6. 	{ FOOD_RATION, 0, FOOD_CLASS, 3, 0 },
  7. 	{ PICK_AXE, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS },
  8. 	{ TINNING_KIT, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS },
  9. 	{ TOUCHSTONE, 0, GEM_CLASS, 1, 0 },
  10. 	{ SACK, 0, TOOL_CLASS, 1, 0 },
  11. 	{ 0, 0, 0, 0, 0 }
  12. };

Barbarian initial inventory

  1. static struct trobj Barbarian[] = {
  2. #define B_MAJOR	0	/* two-handed sword or battle-axe  */
  3. #define B_MINOR	1	/* matched with axe or short sword */
  4. 	{ TWO_HANDED_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  5. 	{ AXE, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  6. 	{ RING_MAIL, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  7. 	{ FOOD_RATION, 0, FOOD_CLASS, 1, 0 },
  8. 	{ 0, 0, 0, 0, 0 }
  9. };

Caveman initial inventory

  1. static struct trobj Cave_man[] = {
  2. #define C_AMMO	2
  3. 	{ CLUB, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  4. 	{ SLING, 2, WEAPON_CLASS, 1, UNDEF_BLESS },
  5. 	{ FLINT, 0, GEM_CLASS, 15, UNDEF_BLESS },	/* quan is variable */
  6. 	{ ROCK, 0, GEM_CLASS, 3, 0 },			/* yields 18..33 */
  7. 	{ LEATHER_ARMOR, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  8. 	{ 0, 0, 0, 0, 0 }
  9. };

Healer initial inventory

  1. static struct trobj Healer[] = {
  2. 	{ SCALPEL, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  3. 	{ LEATHER_GLOVES, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  4. 	{ STETHOSCOPE, 0, TOOL_CLASS, 1, 0 },
  5. 	{ POT_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS },
  6. 	{ POT_EXTRA_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS },
  7. 	{ WAN_SLEEP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS },
  8. 	/* always blessed, so it's guaranteed readable */
  9. 	{ SPE_HEALING, 0, SPBOOK_CLASS, 1, 1 },
  10. 	{ SPE_EXTRA_HEALING, 0, SPBOOK_CLASS, 1, 1 },
  11. 	{ SPE_STONE_TO_FLESH, 0, SPBOOK_CLASS, 1, 1 },
  12. 	{ APPLE, 0, FOOD_CLASS, 5, 0 },
  13. 	{ 0, 0, 0, 0, 0 }
  14. };

Knight initial inventory

  1. static struct trobj Knight[] = {
  2. 	{ LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  3. 	{ LANCE, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  4. 	{ RING_MAIL, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  5. 	{ HELMET, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  6. 	{ SMALL_SHIELD, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  7. 	{ LEATHER_GLOVES, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  8. 	{ APPLE, 0, FOOD_CLASS, 10, 0 },
  9. 	{ CARROT, 0, FOOD_CLASS, 10, 0 },
  10. 	{ 0, 0, 0, 0, 0 }
  11. };

Monk initial inventory

  1. static struct trobj Monk[] = {
  2. #define M_BOOK		2
  3. 	{ LEATHER_GLOVES, 2, ARMOR_CLASS, 1, UNDEF_BLESS },
  4. 	{ ROBE, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  5. 	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, 1 },
  6. 	{ UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 1, UNDEF_BLESS },
  7. 	{ POT_HEALING, 0, POTION_CLASS, 3, UNDEF_BLESS },
  8. 	{ FOOD_RATION, 0, FOOD_CLASS, 3, 0 },
  9. 	{ APPLE, 0, FOOD_CLASS, 5, UNDEF_BLESS },
  10. 	{ ORANGE, 0, FOOD_CLASS, 5, UNDEF_BLESS },
  11. 	/* Yes, we know fortune cookies aren't really from China.  They were
  12. 	 * invented by George Jung in Los Angeles, California, USA in 1916.
  13. 	 */
  14. 	{ FORTUNE_COOKIE, 0, FOOD_CLASS, 3, UNDEF_BLESS },
  15. 	{ 0, 0, 0, 0, 0 }
  16. };

Priest initial inventory

  1. static struct trobj Priest[] = {
  2. 	{ MACE, 1, WEAPON_CLASS, 1, 1 },
  3. 	{ ROBE, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  4. 	{ SMALL_SHIELD, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  5. 	{ POT_WATER, 0, POTION_CLASS, 4, 1 },	/* holy water */
  6. 	{ CLOVE_OF_GARLIC, 0, FOOD_CLASS, 1, 0 },
  7. 	{ SPRIG_OF_WOLFSBANE, 0, FOOD_CLASS, 1, 0 },
  8. 	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 2, UNDEF_BLESS },
  9. 	{ 0, 0, 0, 0, 0 }
  10. };

Ranger initial inventory

  1. static struct trobj Ranger[] = {
  2. #define RAN_BOW			1
  3. #define RAN_TWO_ARROWS	2
  4. #define RAN_ZERO_ARROWS	3
  5. 	{ DAGGER, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  6. 	{ BOW, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  7. 	{ ARROW, 2, WEAPON_CLASS, 50, UNDEF_BLESS },
  8. 	{ ARROW, 0, WEAPON_CLASS, 30, UNDEF_BLESS },
  9. 	{ CLOAK_OF_DISPLACEMENT, 2, ARMOR_CLASS, 1, UNDEF_BLESS },
  10. 	{ CRAM_RATION, 0, FOOD_CLASS, 4, 0 },
  11. 	{ 0, 0, 0, 0, 0 }
  12. };

Rogue initial inventory

  1. static struct trobj Rogue[] = {
  2. #define R_DAGGERS	1
  3. 	{ SHORT_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  4. 	{ DAGGER, 0, WEAPON_CLASS, 10, 0 },	/* quan is variable */
  5. 	{ LEATHER_ARMOR, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  6. 	{ POT_SICKNESS, 0, POTION_CLASS, 1, 0 },
  7. 	{ LOCK_PICK, 9, TOOL_CLASS, 1, 0 },
  8. 	{ SACK, 0, TOOL_CLASS, 1, 0 },
  9. 	{ 0, 0, 0, 0, 0 }
  10. };

Samurai initial inventory

  1. static struct trobj Samurai[] = {
  2. #define S_ARROWS	3
  3. 	{ KATANA, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  4. 	{ SHORT_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, /* wakizashi */
  5. 	{ YUMI, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  6. 	{ YA, 0, WEAPON_CLASS, 25, UNDEF_BLESS }, /* variable quan */
  7. 	{ SPLINT_MAIL, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  8. 	{ 0, 0, 0, 0, 0 }
  9. };

Tourist initial inventory

  1. #ifdef TOURIST
  2. static struct trobj Tourist[] = {
  3. #define T_DARTS		0
  4. 	{ DART, 2, WEAPON_CLASS, 25, UNDEF_BLESS },	/* quan is variable */
  5. 	{ UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 10, 0 },
  6. 	{ POT_EXTRA_HEALING, 0, POTION_CLASS, 2, UNDEF_BLESS },
  7. 	{ SCR_MAGIC_MAPPING, 0, SCROLL_CLASS, 4, UNDEF_BLESS },
  8. 	{ HAWAIIAN_SHIRT, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  9. 	{ EXPENSIVE_CAMERA, UNDEF_SPE, TOOL_CLASS, 1, 0 },
  10. 	{ CREDIT_CARD, 0, TOOL_CLASS, 1, 0 },
  11. 	{ 0, 0, 0, 0, 0 }
  12. };
  13. #endif

Valkyrie initial inventory

  1. static struct trobj Valkyrie[] = {
  2. 	{ LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  3. 	{ DAGGER, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  4. 	{ SMALL_SHIELD, 3, ARMOR_CLASS, 1, UNDEF_BLESS },
  5. 	{ FOOD_RATION, 0, FOOD_CLASS, 1, 0 },
  6. 	{ 0, 0, 0, 0, 0 }
  7. };

Wizard initial inventory

  1. static struct trobj Wizard[] = {
  2. #define W_MULTSTART	2
  3. #define W_MULTEND	6
  4. 	{ QUARTERSTAFF, 1, WEAPON_CLASS, 1, 1 },
  5. 	{ CLOAK_OF_MAGIC_RESISTANCE, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  6. 	{ UNDEF_TYP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS },
  7. 	{ UNDEF_TYP, UNDEF_SPE, RING_CLASS, 2, UNDEF_BLESS },
  8. 	{ UNDEF_TYP, UNDEF_SPE, POTION_CLASS, 3, UNDEF_BLESS },
  9. 	{ UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 3, UNDEF_BLESS },
  10. 	{ SPE_FORCE_BOLT, 0, SPBOOK_CLASS, 1, 1 },
  11. 	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, UNDEF_BLESS },
  12. 	{ 0, 0, 0, 0, 0 }
  13. };

Optional extra inventory items

  1. /*
  2. *	Optional extra inventory items.
  3. */
  4.  
  5. static struct trobj Tinopener[] = {
  6. 	{ TIN_OPENER, 0, TOOL_CLASS, 1, 0 },
  7. 	{ 0, 0, 0, 0, 0 }
  8. };
  9. static struct trobj Magicmarker[] = {
  10. 	{ MAGIC_MARKER, UNDEF_SPE, TOOL_CLASS, 1, 0 },
  11. 	{ 0, 0, 0, 0, 0 }
  12. };
  13. static struct trobj Lamp[] = {
  14. 	{ OIL_LAMP, 1, TOOL_CLASS, 1, 0 },
  15. 	{ 0, 0, 0, 0, 0 }
  16. };
  17. static struct trobj Blindfold[] = {
  18. 	{ BLINDFOLD, 0, TOOL_CLASS, 1, 0 },
  19. 	{ 0, 0, 0, 0, 0 }
  20. };
  21. static struct trobj Instrument[] = {
  22. 	{ WOODEN_FLUTE, 0, TOOL_CLASS, 1, 0 },
  23. 	{ 0, 0, 0, 0, 0 }
  24. };
  25. static struct trobj Xtra_food[] = {
  26. 	{ UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 2, 0 },
  27. 	{ 0, 0, 0, 0, 0 }
  28. };
  29. #ifdef TOURIST
  30. static struct trobj Leash[] = {
  31. 	{ LEASH, 0, TOOL_CLASS, 1, 0 },
  32. 	{ 0, 0, 0, 0, 0 }
  33. };
  34. static struct trobj Towel[] = {
  35. 	{ TOWEL, 0, TOOL_CLASS, 1, 0 },
  36. 	{ 0, 0, 0, 0, 0 }
  37. };
  38. #endif	/* TOURIST */
  39. static struct trobj Wishing[] = {
  40. 	{ WAN_WISHING, 3, WAND_CLASS, 1, 0 },
  41. 	{ 0, 0, 0, 0, 0 }
  42. };
  43. #ifdef GOLDOBJ
  44. static struct trobj Money[] = {
  45. 	{ GOLD_PIECE, 0 , COIN_CLASS, 1, 0 },
  46. 	{ 0, 0, 0, 0, 0 }
  47. };
  48. #endif

Race-based substitutions for initial inventory

  1. /* race-based substitutions for initial inventory;
  2. the weaker cloak for elven rangers is intentional--they shoot better */
  3. static struct inv_sub { short race_pm, item_otyp, subs_otyp; } inv_subs[] = {
  4. { PM_ELF,	DAGGER,			ELVEN_DAGGER	      },
  5. { PM_ELF,	SPEAR,			ELVEN_SPEAR	      },
  6. { PM_ELF,	SHORT_SWORD,		ELVEN_SHORT_SWORD     },
  7. { PM_ELF,	BOW,			ELVEN_BOW	      },
  8. { PM_ELF,	ARROW,			ELVEN_ARROW	      },
  9. { PM_ELF,	HELMET,			ELVEN_LEATHER_HELM    },
  10. /* { PM_ELF,	SMALL_SHIELD,		ELVEN_SHIELD	      }, */
  11. { PM_ELF,	CLOAK_OF_DISPLACEMENT,	ELVEN_CLOAK	      },
  12. { PM_ELF,	CRAM_RATION,		LEMBAS_WAFER	      },
  13. { PM_ORC,	DAGGER,			ORCISH_DAGGER	      },
  14. { PM_ORC,	SPEAR,			ORCISH_SPEAR	      },
  15. { PM_ORC,	SHORT_SWORD,		ORCISH_SHORT_SWORD    },
  16. { PM_ORC,	BOW,			ORCISH_BOW	      },
  17. { PM_ORC,	ARROW,			ORCISH_ARROW	      },
  18. { PM_ORC,	HELMET,			ORCISH_HELM	      },
  19. { PM_ORC,	SMALL_SHIELD,		ORCISH_SHIELD	      },
  20. { PM_ORC,	RING_MAIL,		ORCISH_RING_MAIL      },
  21. { PM_ORC,	CHAIN_MAIL,		ORCISH_CHAIN_MAIL     },
  22. { PM_DWARF, SPEAR,			DWARVISH_SPEAR	      },
  23. { PM_DWARF, SHORT_SWORD,		DWARVISH_SHORT_SWORD  },
  24. { PM_DWARF, HELMET,			DWARVISH_IRON_HELM    },
  25. /* { PM_DWARF, SMALL_SHIELD,		DWARVISH_ROUNDSHIELD  }, */
  26. /* { PM_DWARF, PICK_AXE,		DWARVISH_MATTOCK      }, */
  27. { PM_GNOME, BOW,			CROSSBOW	      },
  28. { PM_GNOME, ARROW,			CROSSBOW_BOLT	      },
  29. { NON_PM,	STRANGE_OBJECT,		STRANGE_OBJECT	      }
  30. };

Maximum skill levels

Archeologist max skill levels

  1. static const struct def_skill Skill_A[] = {
  2. { P_DAGGER, P_BASIC },		{ P_KNIFE,  P_BASIC },
  3. { P_PICK_AXE, P_EXPERT },		{ P_SHORT_SWORD, P_BASIC },
  4. { P_SCIMITAR, P_SKILLED },		{ P_SABER, P_EXPERT },
  5. { P_CLUB, P_SKILLED },		{ P_QUARTERSTAFF, P_SKILLED },
  6. { P_SLING, P_SKILLED },		{ P_DART, P_BASIC },
  7. { P_BOOMERANG, P_EXPERT },		{ P_WHIP, P_EXPERT },
  8. { P_UNICORN_HORN, P_SKILLED },
  9. { P_ATTACK_SPELL, P_BASIC },	{ P_HEALING_SPELL, P_BASIC },
  10. { P_DIVINATION_SPELL, P_EXPERT},	{ P_MATTER_SPELL, P_BASIC},
  11. #ifdef STEED
  12. { P_RIDING, P_BASIC },
  13. #endif
  14. { P_TWO_WEAPON_COMBAT, P_BASIC },
  15. { P_BARE_HANDED_COMBAT, P_EXPERT },
  16. { P_NONE, 0 }
  17. };

Barbarian max skill levels

  1. static const struct def_skill Skill_B[] = {
  2. { P_DAGGER, P_BASIC },		{ P_AXE, P_EXPERT },
  3. { P_PICK_AXE, P_SKILLED },	{ P_SHORT_SWORD, P_EXPERT },
  4. { P_BROAD_SWORD, P_SKILLED },	{ P_LONG_SWORD, P_SKILLED },
  5. { P_TWO_HANDED_SWORD, P_EXPERT },	{ P_SCIMITAR, P_SKILLED },
  6. { P_SABER, P_BASIC },		{ P_CLUB, P_SKILLED },
  7. { P_MACE, P_SKILLED },		{ P_MORNING_STAR, P_SKILLED },
  8. { P_FLAIL, P_BASIC },		{ P_HAMMER, P_EXPERT },
  9. { P_QUARTERSTAFF, P_BASIC },	{ P_SPEAR, P_SKILLED },
  10. { P_TRIDENT, P_SKILLED },		{ P_BOW, P_BASIC },
  11. { P_ATTACK_SPELL, P_SKILLED },
  12. #ifdef STEED
  13. { P_RIDING, P_BASIC },
  14. #endif
  15. { P_TWO_WEAPON_COMBAT, P_BASIC },
  16. { P_BARE_HANDED_COMBAT, P_MASTER },
  17. { P_NONE, 0 }
  18. };

Caveman max skill levels

  1. static const struct def_skill Skill_C[] = {
  2. { P_DAGGER, P_BASIC },		{ P_KNIFE,  P_SKILLED },
  3. { P_AXE, P_SKILLED },		{ P_PICK_AXE, P_BASIC },
  4. { P_CLUB, P_EXPERT },		{ P_MACE, P_EXPERT },
  5. { P_MORNING_STAR, P_BASIC },	{ P_FLAIL, P_SKILLED },
  6. { P_HAMMER, P_SKILLED },		{ P_QUARTERSTAFF, P_EXPERT },
  7. { P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_EXPERT },
  8. { P_JAVELIN, P_SKILLED },		{ P_TRIDENT, P_SKILLED },
  9. { P_BOW, P_SKILLED },		{ P_SLING, P_EXPERT },
  10. { P_ATTACK_SPELL, P_BASIC },	{ P_MATTER_SPELL, P_SKILLED },
  11. { P_BOOMERANG, P_EXPERT },		{ P_UNICORN_HORN, P_BASIC },
  12. { P_BARE_HANDED_COMBAT, P_MASTER },
  13. { P_NONE, 0 }
  14. };

Healer max skill levels

  1. static const struct def_skill Skill_H[] = {
  2. { P_DAGGER, P_SKILLED },		{ P_KNIFE, P_EXPERT },
  3. { P_SHORT_SWORD, P_SKILLED },	{ P_SCIMITAR, P_BASIC },
  4. { P_SABER, P_BASIC },		{ P_CLUB, P_SKILLED },
  5. { P_MACE, P_BASIC },		{ P_QUARTERSTAFF, P_EXPERT },
  6. { P_POLEARMS, P_BASIC },		{ P_SPEAR, P_BASIC },
  7. { P_JAVELIN, P_BASIC },		{ P_TRIDENT, P_BASIC },
  8. { P_SLING, P_SKILLED },		{ P_DART, P_EXPERT },
  9. { P_SHURIKEN, P_SKILLED },		{ P_UNICORN_HORN, P_EXPERT },
  10. { P_HEALING_SPELL, P_EXPERT },
  11. { P_BARE_HANDED_COMBAT, P_BASIC },
  12. { P_NONE, 0 }
  13. };

Knight max skill levels

  1. static const struct def_skill Skill_K[] = {
  2. { P_DAGGER, P_BASIC },		{ P_KNIFE, P_BASIC },
  3. { P_AXE, P_SKILLED },		{ P_PICK_AXE, P_BASIC },
  4. { P_SHORT_SWORD, P_SKILLED },	{ P_BROAD_SWORD, P_SKILLED },
  5. { P_LONG_SWORD, P_EXPERT },	{ P_TWO_HANDED_SWORD, P_SKILLED },
  6. { P_SCIMITAR, P_BASIC },		{ P_SABER, P_SKILLED },
  7. { P_CLUB, P_BASIC },		{ P_MACE, P_SKILLED },
  8. { P_MORNING_STAR, P_SKILLED },	{ P_FLAIL, P_BASIC },
  9. { P_HAMMER, P_BASIC },		{ P_POLEARMS, P_SKILLED },
  10. { P_SPEAR, P_SKILLED },		{ P_JAVELIN, P_SKILLED },
  11. { P_TRIDENT, P_BASIC },		{ P_LANCE, P_EXPERT },
  12. { P_BOW, P_BASIC },			{ P_CROSSBOW, P_SKILLED },
  13. { P_ATTACK_SPELL, P_SKILLED },	{ P_HEALING_SPELL, P_SKILLED },
  14. { P_CLERIC_SPELL, P_SKILLED },
  15. #ifdef STEED
  16. { P_RIDING, P_EXPERT },
  17. #endif
  18. { P_TWO_WEAPON_COMBAT, P_SKILLED },
  19. { P_BARE_HANDED_COMBAT, P_EXPERT },
  20. { P_NONE, 0 }
  21. };

Monk max skill levels

  1. static const struct def_skill Skill_Mon[] = {
  2. { P_QUARTERSTAFF, P_BASIC },    { P_SPEAR, P_BASIC },
  3. { P_JAVELIN, P_BASIC },		    { P_CROSSBOW, P_BASIC },
  4. { P_SHURIKEN, P_BASIC },
  5. { P_ATTACK_SPELL, P_BASIC },    { P_HEALING_SPELL, P_EXPERT },
  6. { P_DIVINATION_SPELL, P_BASIC },{ P_ENCHANTMENT_SPELL, P_BASIC },
  7. { P_CLERIC_SPELL, P_SKILLED },  { P_ESCAPE_SPELL, P_BASIC },
  8. { P_MATTER_SPELL, P_BASIC },
  9. { P_MARTIAL_ARTS, P_GRAND_MASTER },
  10. { P_NONE, 0 }
  11. };

Priest max skill levels

  1. static const struct def_skill Skill_P[] = {
  2. { P_CLUB, P_EXPERT },		{ P_MACE, P_EXPERT },
  3. { P_MORNING_STAR, P_EXPERT },	{ P_FLAIL, P_EXPERT },
  4. { P_HAMMER, P_EXPERT },		{ P_QUARTERSTAFF, P_EXPERT },
  5. { P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_SKILLED },
  6. { P_JAVELIN, P_SKILLED },		{ P_TRIDENT, P_SKILLED },
  7. { P_LANCE, P_BASIC },		{ P_BOW, P_BASIC },
  8. { P_SLING, P_BASIC },		{ P_CROSSBOW, P_BASIC },
  9. { P_DART, P_BASIC },		{ P_SHURIKEN, P_BASIC },
  10. { P_BOOMERANG, P_BASIC },		{ P_UNICORN_HORN, P_SKILLED },
  11. { P_HEALING_SPELL, P_EXPERT },	{ P_DIVINATION_SPELL, P_EXPERT },
  12. { P_CLERIC_SPELL, P_EXPERT },
  13. { P_BARE_HANDED_COMBAT, P_BASIC },
  14. { P_NONE, 0 }
  15. };

Rogue max skill levels

  1. static const struct def_skill Skill_R[] = {
  2. { P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_EXPERT },
  3. { P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_SKILLED },
  4. { P_LONG_SWORD, P_SKILLED },	{ P_TWO_HANDED_SWORD, P_BASIC },
  5. { P_SCIMITAR, P_SKILLED },		{ P_SABER, P_SKILLED },
  6. { P_CLUB, P_SKILLED },		{ P_MACE, P_SKILLED },
  7. { P_MORNING_STAR, P_BASIC },	{ P_FLAIL, P_BASIC },
  8. { P_HAMMER, P_BASIC },		{ P_POLEARMS, P_BASIC },
  9. { P_SPEAR, P_BASIC },		{ P_CROSSBOW, P_EXPERT },
  10. { P_DART, P_EXPERT },		{ P_SHURIKEN, P_SKILLED },
  11. { P_DIVINATION_SPELL, P_SKILLED },	{ P_ESCAPE_SPELL, P_SKILLED },
  12. { P_MATTER_SPELL, P_SKILLED },
  13. #ifdef STEED
  14. { P_RIDING, P_BASIC },
  15. #endif
  16. { P_TWO_WEAPON_COMBAT, P_EXPERT },
  17. { P_BARE_HANDED_COMBAT, P_EXPERT },
  18. { P_NONE, 0 }
  19. };

Ranger max skill levels

  1. static const struct def_skill Skill_Ran[] = {
  2. { P_DAGGER, P_EXPERT },		 { P_KNIFE,  P_SKILLED },
  3. { P_AXE, P_SKILLED },	 { P_PICK_AXE, P_BASIC },
  4. { P_SHORT_SWORD, P_BASIC },	 { P_MORNING_STAR, P_BASIC },
  5. { P_FLAIL, P_SKILLED },	 { P_HAMMER, P_BASIC },
  6. { P_QUARTERSTAFF, P_BASIC }, { P_POLEARMS, P_SKILLED },
  7. { P_SPEAR, P_SKILLED },	 { P_JAVELIN, P_EXPERT },
  8. { P_TRIDENT, P_BASIC },	 { P_BOW, P_EXPERT },
  9. { P_SLING, P_EXPERT },	 { P_CROSSBOW, P_EXPERT },
  10. { P_DART, P_EXPERT },	 { P_SHURIKEN, P_SKILLED },
  11. { P_BOOMERANG, P_EXPERT },	 { P_WHIP, P_BASIC },
  12. { P_HEALING_SPELL, P_BASIC },
  13. { P_DIVINATION_SPELL, P_EXPERT },
  14. { P_ESCAPE_SPELL, P_BASIC },
  15. #ifdef STEED
  16. { P_RIDING, P_BASIC },
  17. #endif
  18. { P_BARE_HANDED_COMBAT, P_BASIC },
  19. { P_NONE, 0 }
  20. };

Samurai max skill levels

  1. static const struct def_skill Skill_S[] = {
  2. { P_DAGGER, P_BASIC },		{ P_KNIFE,  P_SKILLED },
  3. { P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_SKILLED },
  4. { P_LONG_SWORD, P_EXPERT },		{ P_TWO_HANDED_SWORD, P_EXPERT },
  5. { P_SCIMITAR, P_BASIC },		{ P_SABER, P_BASIC },
  6. { P_FLAIL, P_SKILLED },		{ P_QUARTERSTAFF, P_BASIC },
  7. { P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_BASIC },
  8. { P_JAVELIN, P_BASIC },		{ P_LANCE, P_SKILLED },
  9. { P_BOW, P_EXPERT },		{ P_SHURIKEN, P_EXPERT },
  10. { P_ATTACK_SPELL, P_SKILLED },	{ P_CLERIC_SPELL, P_SKILLED },
  11. #ifdef STEED
  12. { P_RIDING, P_SKILLED },
  13. #endif
  14. { P_TWO_WEAPON_COMBAT, P_EXPERT },
  15. { P_MARTIAL_ARTS, P_MASTER },
  16. { P_NONE, 0 }
  17. };

Tourist max skill levels

  1. #ifdef TOURIST
  2. static const struct def_skill Skill_T[] = {
  3. { P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_SKILLED },
  4. { P_AXE, P_BASIC },			{ P_PICK_AXE, P_BASIC },
  5. { P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_BASIC },
  6. { P_LONG_SWORD, P_BASIC },		{ P_TWO_HANDED_SWORD, P_BASIC },
  7. { P_SCIMITAR, P_SKILLED },		{ P_SABER, P_SKILLED },
  8. { P_MACE, P_BASIC },		{ P_MORNING_STAR, P_BASIC },
  9. { P_FLAIL, P_BASIC },		{ P_HAMMER, P_BASIC },
  10. { P_QUARTERSTAFF, P_BASIC },	{ P_POLEARMS, P_BASIC },
  11. { P_SPEAR, P_BASIC },		{ P_JAVELIN, P_BASIC },
  12. { P_TRIDENT, P_BASIC },		{ P_LANCE, P_BASIC },
  13. { P_BOW, P_BASIC },			{ P_SLING, P_BASIC },
  14. { P_CROSSBOW, P_BASIC },		{ P_DART, P_EXPERT },
  15. { P_SHURIKEN, P_BASIC },		{ P_BOOMERANG, P_BASIC },
  16. { P_WHIP, P_BASIC },		{ P_UNICORN_HORN, P_SKILLED },
  17. { P_DIVINATION_SPELL, P_BASIC },	{ P_ENCHANTMENT_SPELL, P_BASIC },
  18. { P_ESCAPE_SPELL, P_SKILLED },
  19. #ifdef STEED
  20. { P_RIDING, P_BASIC },
  21. #endif
  22. { P_TWO_WEAPON_COMBAT, P_SKILLED },
  23. { P_BARE_HANDED_COMBAT, P_SKILLED },
  24. { P_NONE, 0 }
  25. };
  26. #endif /* TOURIST */

Valkyrie max skill levels

  1. static const struct def_skill Skill_V[] = {
  2. { P_DAGGER, P_EXPERT },		{ P_AXE, P_EXPERT },
  3. { P_PICK_AXE, P_SKILLED },		{ P_SHORT_SWORD, P_SKILLED },
  4. { P_BROAD_SWORD, P_SKILLED },	{ P_LONG_SWORD, P_EXPERT },
  5. { P_TWO_HANDED_SWORD, P_EXPERT },	{ P_SCIMITAR, P_BASIC },
  6. { P_SABER, P_BASIC },		{ P_HAMMER, P_EXPERT },
  7. { P_QUARTERSTAFF, P_BASIC },	{ P_POLEARMS, P_SKILLED },
  8. { P_SPEAR, P_SKILLED },		{ P_JAVELIN, P_BASIC },
  9. { P_TRIDENT, P_BASIC },		{ P_LANCE, P_SKILLED },
  10. { P_SLING, P_BASIC },
  11. { P_ATTACK_SPELL, P_BASIC },	{ P_ESCAPE_SPELL, P_BASIC },
  12. #ifdef STEED
  13. { P_RIDING, P_SKILLED },
  14. #endif
  15. { P_TWO_WEAPON_COMBAT, P_SKILLED },
  16. { P_BARE_HANDED_COMBAT, P_EXPERT },
  17. { P_NONE, 0 }
  18. };

Wizard max skill levels

  1. static const struct def_skill Skill_W[] = {
  2. { P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_SKILLED },
  3. { P_AXE, P_SKILLED },		{ P_SHORT_SWORD, P_BASIC },
  4. { P_CLUB, P_SKILLED },		{ P_MACE, P_BASIC },
  5. { P_QUARTERSTAFF, P_EXPERT },	{ P_POLEARMS, P_SKILLED },
  6. { P_SPEAR, P_BASIC },		{ P_JAVELIN, P_BASIC },
  7. { P_TRIDENT, P_BASIC },		{ P_SLING, P_SKILLED },
  8. { P_DART, P_EXPERT },		{ P_SHURIKEN, P_BASIC },
  9. { P_ATTACK_SPELL, P_EXPERT },	{ P_HEALING_SPELL, P_SKILLED },
  10. { P_DIVINATION_SPELL, P_EXPERT },	{ P_ENCHANTMENT_SPELL, P_SKILLED },
  11. { P_CLERIC_SPELL, P_SKILLED },	{ P_ESCAPE_SPELL, P_EXPERT },
  12. { P_MATTER_SPELL, P_EXPERT },
  13. #ifdef STEED
  14. { P_RIDING, P_BASIC },
  15. #endif
  16. { P_BARE_HANDED_COMBAT, P_BASIC },
  17. { P_NONE, 0 }
  18. };

knows_object

  1. STATIC_OVL void
  2. knows_object(obj)
  3. register int obj;
  4. {
  5. 	discover_object(obj,TRUE,FALSE);
  6. 	objects[obj].oc_pre_discovered = 1;	/* not a "discovery" */
  7. }

knows_class

  1. /* Know ordinary (non-magical) objects of a certain class,
  2. * like all gems except the loadstone and luckstone.
  3. */
  4. STATIC_OVL void
  5. knows_class(sym)
  6. register char sym;
  7. {
  8. 	register int ct;
  9. 	for (ct = 1; ct < NUM_OBJECTS; ct++)
  10. 		if (objects[ct].oc_class == sym && !objects[ct].oc_magic)
  11. 			knows_object(ct);
  12. }

u_init

  1. void
  2. u_init()
  3. {
  4. 	register int i;
  5.  
  6. 	flags.female = flags.initgend;
  7. 	flags.beginner = 1;
  8.  
  9. 	/* zero u, including pointer values --
  10. 	 * necessary when aborting from a failed restore */
  11. 	(void) memset((genericptr_t)&u, 0, sizeof(u));
  12. 	u.ustuck = (struct monst *)0;
  13.  
  14. #if 0	/* documentation of more zero values as desirable */
  15. 	u.usick_cause[0] = 0;
  16. 	u.uluck  = u.moreluck = 0;
  17. # ifdef TOURIST
  18. 	uarmu = 0;
  19. # endif
  20. 	uarm = uarmc = uarmh = uarms = uarmg = uarmf = 0;
  21. 	uwep = uball = uchain = uleft = uright = 0;
  22. 	uswapwep = uquiver = 0;
  23. 	u.twoweap = 0;
  24. 	u.ublessed = 0;				/* not worthy yet */
  25. 	u.ugangr   = 0;				/* gods not angry */
  26. 	u.ugifts   = 0;				/* no divine gifts bestowed */
  27. # ifdef ELBERETH
  28. 	u.uevent.uhand_of_elbereth = 0;
  29. # endif
  30. 	u.uevent.uheard_tune = 0;
  31. 	u.uevent.uopened_dbridge = 0;
  32. 	u.uevent.udemigod = 0;		/* not a demi-god yet... */
  33. 	u.udg_cnt = 0;
  34. 	u.mh = u.mhmax = u.mtimedone = 0;
  35. 	u.uz.dnum = u.uz0.dnum = 0;
  36. 	u.utotype = 0;
  37. #endif	/* 0 */
  38.  
  39. 	u.uz.dlevel = 1;
  40. 	u.uz0.dlevel = 0;
  41. 	u.utolev = u.uz;
  42.  
  43. 	u.umoved = FALSE;
  44. 	u.umortality = 0;
  45. 	u.ugrave_arise = NON_PM;
  46.  
  47. 	u.umonnum = u.umonster = (flags.female &&
  48. 			urole.femalenum != NON_PM) ? urole.femalenum :
  49. 			urole.malenum;
  50. 	set_uasmon();
  51.  
  52. 	u.ulevel = 0;	/* set up some of the initial attributes */
  53. 	u.uhp = u.uhpmax = newhp();
  54. 	u.uenmax = urole.enadv.infix + urace.enadv.infix;
  55. 	if (urole.enadv.inrnd > 0)
  56. 	    u.uenmax += rnd(urole.enadv.inrnd);
  57. 	if (urace.enadv.inrnd > 0)
  58. 	    u.uenmax += rnd(urace.enadv.inrnd);
  59. 	u.uen = u.uenmax;
  60. 	u.uspellprot = 0;
  61. 	adjabil(0,1);
  62. 	u.ulevel = u.ulevelmax = 1;
  63.  
  64. 	init_uhunger();
  65. 	for (i = 0; i <= MAXSPELL; i++) spl_book[i].sp_id = NO_SPELL;
  66. 	u.ublesscnt = 300;			/* no prayers just yet */
  67. 	u.ualignbase[A_CURRENT] = u.ualignbase[A_ORIGINAL] = u.ualign.type =
  68. 			aligns[flags.initalign].value;
  69. 	u.ulycn = NON_PM;
  70.  
  71. #if defined(BSD) && !defined(POSIX_TYPES)
  72. 	(void) time((long *)&u.ubirthday);
  73. #else
  74. 	(void) time(&u.ubirthday);
  75. #endif
  76.  
  77. 	/*
  78. 	 *  For now, everyone starts out with a night vision range of 1 and
  79. 	 *  their xray range disabled.
  80. 	 */
  81. 	u.nv_range   =  1;
  82. 	u.xray_range = -1;

Role-specific initializations

  1. 	/*** Role-specific initializations ***/
  2. 	switch (Role_switch) {
  3. 	/* rn2(100) > 50 necessary for some choices because some
  4. 	 * random number generators are bad enough to seriously
  5. 	 * skew the results if we use rn2(2)...  --KAA
  6. 	 */

Archeologist initializations

  1. 	case PM_ARCHEOLOGIST:
  2. 		ini_inv(Archeologist);
  3. 		if(!rn2(10)) ini_inv(Tinopener);
  4. 		else if(!rn2(4)) ini_inv(Lamp);
  5. 		else if(!rn2(10)) ini_inv(Magicmarker);
  6. 		knows_object(SACK);
  7. 		knows_object(TOUCHSTONE);
  8. 		skill_init(Skill_A);
  9. 		break;

Barbarian initializations

  1. 	case PM_BARBARIAN:
  2. 		if (rn2(100) >= 50) {	/* see above comment */
  3. 		    Barbarian[B_MAJOR].trotyp = BATTLE_AXE;
  4. 		    Barbarian[B_MINOR].trotyp = SHORT_SWORD;
  5. 		}
  6. 		ini_inv(Barbarian);
  7. 		if(!rn2(6)) ini_inv(Lamp);
  8. 		knows_class(WEAPON_CLASS);
  9. 		knows_class(ARMOR_CLASS);
  10. 		skill_init(Skill_B);
  11. 		break;

Caveman initializations

  1. 	case PM_CAVEMAN:
  2. 		Cave_man[C_AMMO].trquan = rn1(11, 10);	/* 10..20 */
  3. 		ini_inv(Cave_man);
  4. 		skill_init(Skill_C);
  5. 		break;

Healer initializations

  1. 	case PM_HEALER:
  2. #ifndef GOLDOBJ
  3. 		u.ugold = u.ugold0 = rn1(1000, 1001);
  4. #else
  5. 		u.umoney0 = rn1(1000, 1001);
  6. #endif
  7. 		ini_inv(Healer);
  8. 		if(!rn2(25)) ini_inv(Lamp);
  9. 		knows_object(POT_FULL_HEALING);
  10. 		skill_init(Skill_H);
  11. 		break;

Knight initializations

  1. 	case PM_KNIGHT:
  2. 		ini_inv(Knight);
  3. 		knows_class(WEAPON_CLASS);
  4. 		knows_class(ARMOR_CLASS);
  5. 		/* give knights chess-like mobility
  6. 		 * -- idea from wooledge@skybridge.scl.cwru.edu */
  7. 		HJumping |= FROMOUTSIDE;
  8. 		skill_init(Skill_K);
  9. 		break;

Monk initializations

  1. 	case PM_MONK:
  2. 		switch (rn2(90) / 30) {
  3. 		case 0: Monk[M_BOOK].trotyp = SPE_HEALING; break;
  4. 		case 1: Monk[M_BOOK].trotyp = SPE_PROTECTION; break;
  5. 		case 2: Monk[M_BOOK].trotyp = SPE_SLEEP; break;
  6. 		}
  7. 		ini_inv(Monk);
  8. 		if(!rn2(5)) ini_inv(Magicmarker);
  9. 		else if(!rn2(10)) ini_inv(Lamp);
  10. 		knows_class(ARMOR_CLASS);
  11. 		skill_init(Skill_Mon);
  12. 		break;

Priest initializations

  1. 	case PM_PRIEST:
  2. 		ini_inv(Priest);
  3. 		if(!rn2(10)) ini_inv(Magicmarker);
  4. 		else if(!rn2(10)) ini_inv(Lamp);
  5. 		knows_object(POT_WATER);
  6. 		skill_init(Skill_P);
  7. 		/* KMH, conduct --
  8. 		 * Some may claim that this isn't agnostic, since they
  9. 		 * are literally "priests" and they have holy water.
  10. 		 * But we don't count it as such.  Purists can always
  11. 		 * avoid playing priests and/or confirm another player's
  12. 		 * role in their YAAP.
  13. 		 */
  14. 		break;

Ranger initializations

  1. 	case PM_RANGER:
  2. 		Ranger[RAN_TWO_ARROWS].trquan = rn1(10, 50);
  3. 		Ranger[RAN_ZERO_ARROWS].trquan = rn1(10, 30);
  4. 		ini_inv(Ranger);
  5. 		skill_init(Skill_Ran);
  6. 		break;

Rogue initializations

  1. 	case PM_ROGUE:
  2. 		Rogue[R_DAGGERS].trquan = rn1(10, 6);
  3. #ifndef GOLDOBJ
  4. 		u.ugold = u.ugold0 = 0;
  5. #else
  6. 		u.umoney0 = 0;
  7. #endif
  8. 		ini_inv(Rogue);
  9. 		if(!rn2(5)) ini_inv(Blindfold);
  10. 		knows_object(SACK);
  11. 		skill_init(Skill_R);
  12. 		break;

Samurai initializations

  1. 	case PM_SAMURAI:
  2. 		Samurai[S_ARROWS].trquan = rn1(20, 26);
  3. 		ini_inv(Samurai);
  4. 		if(!rn2(5)) ini_inv(Blindfold);
  5. 		knows_class(WEAPON_CLASS);
  6. 		knows_class(ARMOR_CLASS);
  7. 		skill_init(Skill_S);
  8. 		break;

Tourist initializations

  1. #ifdef TOURIST
  2. 	case PM_TOURIST:
  3. 		Tourist[T_DARTS].trquan = rn1(20, 21);
  4. #ifndef GOLDOBJ
  5. 		u.ugold = u.ugold0 = rnd(1000);
  6. #else
  7. 		u.umoney0 = rnd(1000);
  8. #endif
  9. 		ini_inv(Tourist);
  10. 		if(!rn2(25)) ini_inv(Tinopener);
  11. 		else if(!rn2(25)) ini_inv(Leash);
  12. 		else if(!rn2(25)) ini_inv(Towel);
  13. 		else if(!rn2(25)) ini_inv(Magicmarker);
  14. 		skill_init(Skill_T);
  15. 		break;
  16. #endif

Valkyrie initializations

  1. 	case PM_VALKYRIE:
  2. 		ini_inv(Valkyrie);
  3. 		if(!rn2(6)) ini_inv(Lamp);
  4. 		knows_class(WEAPON_CLASS);
  5. 		knows_class(ARMOR_CLASS);
  6. 		skill_init(Skill_V);
  7. 		break;

Wizard initializations

  1. 	case PM_WIZARD:
  2. 		ini_inv(Wizard);
  3. 		if(!rn2(5)) ini_inv(Magicmarker);
  4. 		if(!rn2(5)) ini_inv(Blindfold);
  5. 		skill_init(Skill_W);
  6. 		break;
  7.  
  8. 	default:	/* impossible */
  9. 		break;
  10. 	}

Race-specific initializations

  1. 	/*** Race-specific initializations ***/
  2. 	switch (Race_switch) {

Human initializations

  1. 	case PM_HUMAN:
  2. 	    /* Nothing special */
  3. 	    break;

Elf initializations

  1. 	case PM_ELF:
  2. 	    /*
  3. 	     * Elves are people of music and song, or they are warriors.
  4. 	     * Non-warriors get an instrument.  We use a kludge to
  5. 	     * get only non-magic instruments.
  6. 	     */
  7. 	    if (Role_if(PM_PRIEST) || Role_if(PM_WIZARD)) {
  8. 		static int trotyp[] = {
  9. 		    WOODEN_FLUTE, TOOLED_HORN, WOODEN_HARP,
  10. 		    BELL, BUGLE, LEATHER_DRUM
  11. 		};
  12. 		Instrument[0].trotyp = trotyp[rn2(SIZE(trotyp))];
  13. 		ini_inv(Instrument);
  14. 	    }
  15.  
  16. 	    /* Elves can recognize all elvish objects */
  17. 	    knows_object(ELVEN_SHORT_SWORD);
  18. 	    knows_object(ELVEN_ARROW);
  19. 	    knows_object(ELVEN_BOW);
  20. 	    knows_object(ELVEN_SPEAR);
  21. 	    knows_object(ELVEN_DAGGER);
  22. 	    knows_object(ELVEN_BROADSWORD);
  23. 	    knows_object(ELVEN_MITHRIL_COAT);
  24. 	    knows_object(ELVEN_LEATHER_HELM);
  25. 	    knows_object(ELVEN_SHIELD);
  26. 	    knows_object(ELVEN_BOOTS);
  27. 	    knows_object(ELVEN_CLOAK);
  28. 	    break;

Dwarf initializations

  1. 	case PM_DWARF:
  2. 	    /* Dwarves can recognize all dwarvish objects */
  3. 	    knows_object(DWARVISH_SPEAR);
  4. 	    knows_object(DWARVISH_SHORT_SWORD);
  5. 	    knows_object(DWARVISH_MATTOCK);
  6. 	    knows_object(DWARVISH_IRON_HELM);
  7. 	    knows_object(DWARVISH_MITHRIL_COAT);
  8. 	    knows_object(DWARVISH_CLOAK);
  9. 	    knows_object(DWARVISH_ROUNDSHIELD);
  10. 	    break;

Gnome initializations

  1. 	case PM_GNOME:
  2. 	    break;

Orc initializations

  1. 	case PM_ORC:
  2. 	    /* compensate for generally inferior equipment */
  3. 	    if (!Role_if(PM_WIZARD))
  4. 		ini_inv(Xtra_food);
  5. 	    /* Orcs can recognize all orcish objects */
  6. 	    knows_object(ORCISH_SHORT_SWORD);
  7. 	    knows_object(ORCISH_ARROW);
  8. 	    knows_object(ORCISH_BOW);
  9. 	    knows_object(ORCISH_SPEAR);
  10. 	    knows_object(ORCISH_DAGGER);
  11. 	    knows_object(ORCISH_CHAIN_MAIL);
  12. 	    knows_object(ORCISH_RING_MAIL);
  13. 	    knows_object(ORCISH_HELM);
  14. 	    knows_object(ORCISH_SHIELD);
  15. 	    knows_object(URUK_HAI_SHIELD);
  16. 	    knows_object(ORCISH_CLOAK);
  17. 	    break;
  18.  
  19. 	default:	/* impossible */
  20. 		break;
  21. 	}
  22.  
  23. 	if (discover)
  24. 		ini_inv(Wishing);
  25.  
  26. #ifdef WIZARD
  27. 	if (wizard)
  28. 		read_wizkit();
  29. #endif
  30.  
  31. #ifndef GOLDOBJ
  32. 	u.ugold0 += hidden_gold();	/* in case sack has gold in it */
  33. #else
  34. 	if (u.umoney0) ini_inv(Money);
  35. 	u.umoney0 += hidden_gold();	/* in case sack has gold in it */
  36. #endif
  37.  
  38. 	find_ac();			/* get initial ac value */
  39. 	init_attr(75);			/* init attribute values */
  40. 	max_rank_sz();			/* set max str size for class ranks */
  41. /*
  42. *	Do we really need this?
  43. */
  44. 	for(i = 0; i < A_MAX; i++)
  45. 	    if(!rn2(20)) {
  46. 		register int xd = rn2(7) - 2;	/* biased variation */
  47. 		(void) adjattrib(i, xd, TRUE);
  48. 		if (ABASE(i) < AMAX(i)) AMAX(i) = ABASE(i);
  49. 	    }
  50.  
  51. 	/* make sure you can carry all you have - especially for Tourists */
  52. 	while (inv_weight() > 0) {
  53. 		if (adjattrib(A_STR, 1, TRUE)) continue;
  54. 		if (adjattrib(A_CON, 1, TRUE)) continue;
  55. 		/* only get here when didn't boost strength or constitution */
  56. 		break;
  57. 	}
  58.  
  59. 	return;
  60. }

restricted_spell_discipline

  1. /* skills aren't initialized, so we use the role-specific skill lists */
  2. STATIC_OVL boolean
  3. restricted_spell_discipline(otyp)
  4. int otyp;
  5. {
  6. const struct def_skill *skills;
  7. int this_skill = spell_skilltype(otyp);
  8.  
  9. switch (Role_switch) {
  10. case PM_ARCHEOLOGIST:	skills = Skill_A; break;
  11. case PM_BARBARIAN:		skills = Skill_B; break;
  12. case PM_CAVEMAN:		skills = Skill_C; break;
  13. case PM_HEALER:		skills = Skill_H; break;
  14. case PM_KNIGHT:		skills = Skill_K; break;
  15. case PM_MONK:		skills = Skill_Mon; break;
  16. case PM_PRIEST:		skills = Skill_P; break;
  17. case PM_RANGER:		skills = Skill_Ran; break;
  18. case PM_ROGUE:		skills = Skill_R; break;
  19. case PM_SAMURAI:		skills = Skill_S; break;
  20. #ifdef TOURIST
  21. case PM_TOURIST:		skills = Skill_T; break;
  22. #endif
  23. case PM_VALKYRIE:		skills = Skill_V; break;
  24. case PM_WIZARD:		skills = Skill_W; break;
  25. default:			skills = 0; break;	/* lint suppression */
  26. }
  27.  
  28. while (skills->skill != P_NONE) {
  29. 	if (skills->skill == this_skill) return FALSE;
  30. 	++skills;
  31. }
  32. return TRUE;
  33. }

ini_inv

  1. STATIC_OVL void
  2. ini_inv(trop)
  3. register struct trobj *trop;
  4. {
  5. 	struct obj *obj;
  6. 	int otyp, i;
  7.  
  8. 	while (trop->trclass) {
  9. 		if (trop->trotyp != UNDEF_TYP) {
  10. 			otyp = (int)trop->trotyp;
  11. 			if (urace.malenum != PM_HUMAN) {
  12. 			    /* substitute specific items for generic ones */
  13. 			    for (i = 0; inv_subs[i].race_pm != NON_PM; ++i)
  14. 				if (inv_subs[i].race_pm == urace.malenum &&
  15. 					otyp == inv_subs[i].item_otyp) {
  16. 				    otyp = inv_subs[i].subs_otyp;
  17. 				    break;
  18. 				}
  19. 			}
  20. 			obj = mksobj(otyp, TRUE, FALSE);
  21. 		} else {	/* UNDEF_TYP */
  22. 			static NEARDATA short nocreate = STRANGE_OBJECT;
  23. 			static NEARDATA short nocreate2 = STRANGE_OBJECT;
  24. 			static NEARDATA short nocreate3 = STRANGE_OBJECT;
  25. 			static NEARDATA short nocreate4 = STRANGE_OBJECT;
  26. 		/*
  27. 		 * For random objects, do not create certain overly powerful
  28. 		 * items: wand of wishing, ring of levitation, or the
  29. 		 * polymorph/polymorph control combination.  Specific objects,
  30. 		 * i.e. the discovery wishing, are still OK.
  31. 		 * Also, don't get a couple of really useless items.  (Note:
  32. 		 * punishment isn't "useless".  Some players who start out with
  33. 		 * one will immediately read it and use the iron ball as a
  34. 		 * weapon.)
  35. 		 */
  36. 			obj = mkobj(trop->trclass, FALSE);
  37. 			otyp = obj->otyp;
  38. 			while (otyp == WAN_WISHING
  39. 				|| otyp == nocreate
  40. 				|| otyp == nocreate2
  41. 				|| otyp == nocreate3
  42. 				|| otyp == nocreate4
  43. #ifdef ELBERETH
  44. 				|| otyp == RIN_LEVITATION
  45. #endif
  46. 				/* 'useless' items */
  47. 				|| otyp == POT_HALLUCINATION
  48. 				|| otyp == POT_ACID
  49. 				|| otyp == SCR_AMNESIA
  50. 				|| otyp == SCR_FIRE
  51. 				|| otyp == SCR_BLANK_PAPER
  52. 				|| otyp == SPE_BLANK_PAPER
  53. 				|| otyp == RIN_AGGRAVATE_MONSTER
  54. 				|| otyp == RIN_HUNGER
  55. 				|| otyp == WAN_NOTHING
  56. 				/* Monks don't use weapons */
  57. 				|| (otyp == SCR_ENCHANT_WEAPON &&
  58. 				    Role_if(PM_MONK))
  59. 				/* wizard patch -- they already have one */
  60. 				|| (otyp == SPE_FORCE_BOLT &&
  61. 				    Role_if(PM_WIZARD))
  62. 				/* powerful spells are either useless to
  63. 				   low level players or unbalancing; also
  64. 				   spells in restricted skill categories */
  65. 				|| (obj->oclass == SPBOOK_CLASS &&
  66. 				    (objects[otyp].oc_level > 3 ||
  67. 				    restricted_spell_discipline(otyp)))
  68. 							) {
  69. 				dealloc_obj(obj);
  70. 				obj = mkobj(trop->trclass, FALSE);
  71. 				otyp = obj->otyp;
  72. 			}
  73.  
  74. 			/* Don't start with +0 or negative rings */
  75. 			if (objects[otyp].oc_charged && obj->spe <= 0)
  76. 				obj->spe = rne(3);
  77.  
  78. 			/* Heavily relies on the fact that 1) we create wands
  79. 			 * before rings, 2) that we create rings before
  80. 			 * spellbooks, and that 3) not more than 1 object of a
  81. 			 * particular symbol is to be prohibited.  (For more
  82. 			 * objects, we need more nocreate variables...)
  83. 			 */
  84. 			switch (otyp) {
  85. 			    case WAN_POLYMORPH:
  86. 			    case RIN_POLYMORPH:
  87. 			    case POT_POLYMORPH:
  88. 				nocreate = RIN_POLYMORPH_CONTROL;
  89. 				break;
  90. 			    case RIN_POLYMORPH_CONTROL:
  91. 				nocreate = RIN_POLYMORPH;
  92. 				nocreate2 = SPE_POLYMORPH;
  93. 				nocreate3 = POT_POLYMORPH;
  94. 			}
  95. 			/* Don't have 2 of the same ring or spellbook */
  96. 			if (obj->oclass == RING_CLASS ||
  97. 			    obj->oclass == SPBOOK_CLASS)
  98. 				nocreate4 = otyp;
  99. 		}
  100.  
  101. #ifdef GOLDOBJ
  102. 		if (trop->trclass == COIN_CLASS) {
  103. 			/* no "blessed" or "identified" money */
  104. 			obj->quan = u.umoney0;
  105. 		} else {
  106. #endif
  107. 			obj->dknown = obj->bknown = obj->rknown = 1;
  108. 			if (objects[otyp].oc_uses_known) obj->known = 1;
  109. 			obj->cursed = 0;
  110. 			if (obj->opoisoned && u.ualign.type != A_CHAOTIC)
  111. 			    obj->opoisoned = 0;
  112. 			if (obj->oclass == WEAPON_CLASS ||
  113. 				obj->oclass == TOOL_CLASS) {
  114. 			    obj->quan = (long) trop->trquan;
  115. 			    trop->trquan = 1;
  116. 			} else if (obj->oclass == GEM_CLASS &&
  117. 				is_graystone(obj) && obj->otyp != FLINT) {
  118. 			    obj->quan = 1L;
  119. 			}
  120. 			if (trop->trspe != UNDEF_SPE)
  121. 			    obj->spe = trop->trspe;
  122. 			if (trop->trbless != UNDEF_BLESS)
  123. 			    obj->blessed = trop->trbless;
  124. #ifdef GOLDOBJ
  125. 		}
  126. #endif
  127. 		/* defined after setting otyp+quan + blessedness */
  128. 		obj->owt = weight(obj);
  129. 		obj = addinv(obj);
  130.  
  131. 		/* Make the type known if necessary */
  132. 		if (OBJ_DESCR(objects[otyp]) && obj->known)
  133. 			discover_object(otyp, TRUE, FALSE);
  134. 		if (otyp == OIL_LAMP)
  135. 			discover_object(POT_OIL, TRUE, FALSE);
  136.  
  137. 		if(obj->oclass == ARMOR_CLASS){
  138. 			if (is_shield(obj) && !uarms) {
  139. 				setworn(obj, W_ARMS);
  140. 				if (uswapwep) setuswapwep((struct obj *) 0);
  141. 			} else if (is_helmet(obj) && !uarmh)
  142. 				setworn(obj, W_ARMH);
  143. 			else if (is_gloves(obj) && !uarmg)
  144. 				setworn(obj, W_ARMG);
  145. #ifdef TOURIST
  146. 			else if (is_shirt(obj) && !uarmu)
  147. 				setworn(obj, W_ARMU);
  148. #endif
  149. 			else if (is_cloak(obj) && !uarmc)
  150. 				setworn(obj, W_ARMC);
  151. 			else if (is_boots(obj) && !uarmf)
  152. 				setworn(obj, W_ARMF);
  153. 			else if (is_suit(obj) && !uarm)
  154. 				setworn(obj, W_ARM);
  155. 		}
  156.  
  157. 		if (obj->oclass == WEAPON_CLASS || is_weptool(obj) ||
  158. 			otyp == TIN_OPENER || otyp == FLINT || otyp == ROCK) {
  159. 		    if (is_ammo(obj) || is_missile(obj)) {
  160. 			if (!uquiver) setuqwep(obj);
  161. 		    } else if (!uwep) setuwep(obj);
  162. 		    else if (!uswapwep) setuswapwep(obj);
  163. 		}
  164. 		if (obj->oclass == SPBOOK_CLASS &&
  165. 				obj->otyp != SPE_BLANK_PAPER)
  166. 		    initialspell(obj);
  167.  
  168. #if !defined(PYRAMID_BUG) && !defined(MAC)
  169. 		if(--trop->trquan) continue;	/* make a similar object */
  170. #else
  171. 		if(trop->trquan) {		/* check if zero first */
  172. 			--trop->trquan;
  173. 			if(trop->trquan)
  174. 				continue;	/* make a similar object */
  175. 		}
  176. #endif
  177. 		trop++;
  178. 	}
  179. }
  180.  
  181. /*u_init.c*/