Source:NetHack 3.4.0/u init.c

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

Warning! This is the source code from an old release. For the latest release, see Source code

1.   /*	SCCS Id: @(#)u_init.c	3.4	2002/03/02	*/ 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #include "hack.h"  6. 7.   struct trobj { 8.   	short trotyp; 9.   	schar trspe; 10.  	char trclass; 11.  	Bitfield(trquan,6); 12.  	Bitfield(trbless,2); 13.  };  14.    15.   STATIC_DCL void FDECL(ini_inv, (struct trobj *)); 16.  STATIC_DCL void FDECL(knows_object,(int)); 17.  STATIC_DCL void FDECL(knows_class,(CHAR_P)); 18.  STATIC_DCL boolean FDECL(restricted_spell_discipline, (int)); 19.   20.   #define UNDEF_TYP	0 21.  #define UNDEF_SPE	'\177' 22.  #define UNDEF_BLESS	2 23.   24.   /*  25.    *	Initial inventory for the various roles. 26.   */  27.    28.   static struct trobj Archeologist[] = { 29.  	/* if adventure has a name... idea from tan@uvm-gen */ 30.  	{ BULLWHIP, 2, WEAPON_CLASS, 1, UNDEF_BLESS }, 31.  	{ LEATHER_JACKET, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 32.  	{ FEDORA, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 33.  	{ FOOD_RATION, 0, FOOD_CLASS, 3, 0 }, 34.  	{ PICK_AXE, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS }, 35.  	{ TINNING_KIT, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS }, 36.  	{ TOUCHSTONE, 0, GEM_CLASS, 1, 0 }, 37.  	{ SACK, 0, TOOL_CLASS, 1, 0 }, 38.  	{ 0, 0, 0, 0, 0 }  39.   };  40.   static struct trobj Barbarian[] = { 41.  #define B_MAJOR	0	/* two-handed sword or battle-axe  */ 42.  #define B_MINOR	1	/* matched with axe or short sword */ 43.  	{ TWO_HANDED_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, 44.  	{ AXE, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, 45.  	{ RING_MAIL, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 46.  	{ FOOD_RATION, 0, FOOD_CLASS, 1, 0 }, 47.  	{ 0, 0, 0, 0, 0 }  48.   };  49.   static struct trobj Cave_man[] = { 50.  #define C_AMMO	2 51.  	{ CLUB, 1, WEAPON_CLASS, 1, UNDEF_BLESS }, 52.  	{ SLING, 2, WEAPON_CLASS, 1, UNDEF_BLESS }, 53.  	{ FLINT, 0, GEM_CLASS, 15, UNDEF_BLESS },	/* quan is variable */ 54.  	{ ROCK, 0, GEM_CLASS, 3, 0 },			/* yields 18..33 */ 55.  	{ LEATHER_ARMOR, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 56.  	{ 0, 0, 0, 0, 0 }  57.   };  58.   static struct trobj Healer[] = { 59.  	{ SCALPEL, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, 60.  	{ LEATHER_GLOVES, 1, ARMOR_CLASS, 1, UNDEF_BLESS }, 61.  	{ STETHOSCOPE, 0, TOOL_CLASS, 1, 0 }, 62.  	{ POT_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS }, 63.  	{ POT_EXTRA_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS }, 64.  	{ WAN_SLEEP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS }, 65.  	/* always blessed, so it's guaranteed readable */ 66.  	{ SPE_HEALING, 0, SPBOOK_CLASS, 1, 1 }, 67.  	{ SPE_EXTRA_HEALING, 0, SPBOOK_CLASS, 1, 1 }, 68.  	{ SPE_STONE_TO_FLESH, 0, SPBOOK_CLASS, 1, 1 }, 69.  	{ APPLE, 0, FOOD_CLASS, 5, 0 }, 70.  	{ 0, 0, 0, 0, 0 }  71.   };  72.   static struct trobj Knight[] = { 73.  	{ LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS }, 74.  	{ LANCE, 1, WEAPON_CLASS, 1, UNDEF_BLESS }, 75.  	{ RING_MAIL, 1, ARMOR_CLASS, 1, UNDEF_BLESS }, 76.  	{ HELMET, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 77.  	{ SMALL_SHIELD, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 78.  	{ LEATHER_GLOVES, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 79.  	{ APPLE, 0, FOOD_CLASS, 10, 0 }, 80.  	{ CARROT, 0, FOOD_CLASS, 10, 0 }, 81.  	{ 0, 0, 0, 0, 0 }  82.   };  83.   static struct trobj Monk[] = { 84.  #define M_BOOK		2 85.  	{ LEATHER_GLOVES, 2, ARMOR_CLASS, 1, UNDEF_BLESS }, 86.  	{ ROBE, 1, ARMOR_CLASS, 1, UNDEF_BLESS }, 87.  	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, 1 }, 88.  	{ UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 1, UNDEF_BLESS }, 89.  	{ POT_HEALING, 0, POTION_CLASS, 3, UNDEF_BLESS }, 90.  	{ FOOD_RATION, 0, FOOD_CLASS, 3, 0 }, 91.  	{ APPLE, 0, FOOD_CLASS, 5, UNDEF_BLESS }, 92.  	{ ORANGE, 0, FOOD_CLASS, 5, UNDEF_BLESS }, 93.  	/* Yes, we know fortune cookies aren't really from China. They were 94.  	 * invented by George Jung in Los Angeles, California, USA in 1916. 95.  	 */  96.   	{ FORTUNE_COOKIE, 0, FOOD_CLASS, 3, UNDEF_BLESS }, 97.  	{ 0, 0, 0, 0, 0 }  98.   };  99.   static struct trobj Priest[] = { 100. 	{ MACE, 1, WEAPON_CLASS, 1, 1 }, 101. 	{ ROBE, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 102. 	{ SMALL_SHIELD, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 103. 	{ POT_WATER, 0, POTION_CLASS, 4, 1 },	/* holy water */ 104. 	{ CLOVE_OF_GARLIC, 0, FOOD_CLASS, 1, 0 }, 105. 	{ SPRIG_OF_WOLFSBANE, 0, FOOD_CLASS, 1, 0 }, 106. 	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 2, UNDEF_BLESS }, 107. 	{ 0, 0, 0, 0, 0 }  108.  };  109.  static struct trobj Ranger[] = { 110. #define RAN_BOW			1 111. #define RAN_TWO_ARROWS	2 112. #define RAN_ZERO_ARROWS	3 113. 	{ DAGGER, 1, WEAPON_CLASS, 1, UNDEF_BLESS }, 114. 	{ BOW, 1, WEAPON_CLASS, 1, UNDEF_BLESS }, 115. 	{ ARROW, 2, WEAPON_CLASS, 50, UNDEF_BLESS }, 116. 	{ ARROW, 0, WEAPON_CLASS, 30, UNDEF_BLESS }, 117. 	{ CLOAK_OF_DISPLACEMENT, 2, ARMOR_CLASS, 1, UNDEF_BLESS }, 118. 	{ CRAM_RATION, 0, FOOD_CLASS, 4, 0 }, 119. 	{ 0, 0, 0, 0, 0 }  120.  };  121.  static struct trobj Rogue[] = { 122. #define R_DAGGERS	1 123. 	{ SHORT_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, 124. 	{ DAGGER, 0, WEAPON_CLASS, 10, 0 },	/* quan is variable */ 125. 	{ LEATHER_ARMOR, 1, ARMOR_CLASS, 1, UNDEF_BLESS }, 126. 	{ POT_SICKNESS, 0, POTION_CLASS, 1, 0 }, 127. 	{ LOCK_PICK, 9, TOOL_CLASS, 1, 0 }, 128. 	{ SACK, 0, TOOL_CLASS, 1, 0 }, 129. 	{ 0, 0, 0, 0, 0 }  130.  };  131.  static struct trobj Samurai[] = { 132. #define S_ARROWS	3 133. 	{ KATANA, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, 134. 	{ SHORT_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, /* wakizashi */ 135. 	{ YUMI, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, 136. 	{ YA, 0, WEAPON_CLASS, 25, UNDEF_BLESS }, /* variable quan */ 137. 	{ SPLINT_MAIL, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 138. 	{ 0, 0, 0, 0, 0 }  139.  };  140.  #ifdef TOURIST 141. static struct trobj Tourist[] = { 142. #define T_DARTS		0 143. 	{ DART, 2, WEAPON_CLASS, 25, UNDEF_BLESS },	/* quan is variable */ 144. 	{ UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 10, 0 }, 145. 	{ POT_EXTRA_HEALING, 0, POTION_CLASS, 2, UNDEF_BLESS }, 146. 	{ SCR_MAGIC_MAPPING, 0, SCROLL_CLASS, 4, UNDEF_BLESS }, 147. 	{ HAWAIIAN_SHIRT, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 148. 	{ EXPENSIVE_CAMERA, UNDEF_SPE, TOOL_CLASS, 1, 0 }, 149. 	{ CREDIT_CARD, 0, TOOL_CLASS, 1, 0 }, 150. 	{ 0, 0, 0, 0, 0 }  151.  };  152.  #endif 153. static struct trobj Valkyrie[] = { 154. 	{ LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS }, 155. 	{ DAGGER, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, 156. 	{ SMALL_SHIELD, 3, ARMOR_CLASS, 1, UNDEF_BLESS }, 157. 	{ FOOD_RATION, 0, FOOD_CLASS, 1, 0 }, 158. 	{ 0, 0, 0, 0, 0 }  159.  };  160.  static struct trobj Wizard[] = { 161. #define W_MULTSTART	2 162. #define W_MULTEND	6 163. 	{ QUARTERSTAFF, 1, WEAPON_CLASS, 1, 1 }, 164. 	{ CLOAK_OF_MAGIC_RESISTANCE, 0, ARMOR_CLASS, 1, UNDEF_BLESS }, 165. 	{ UNDEF_TYP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS }, 166. 	{ UNDEF_TYP, UNDEF_SPE, RING_CLASS, 2, UNDEF_BLESS }, 167. 	{ UNDEF_TYP, UNDEF_SPE, POTION_CLASS, 3, UNDEF_BLESS }, 168. 	{ UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 3, UNDEF_BLESS }, 169. 	{ SPE_FORCE_BOLT, 0, SPBOOK_CLASS, 1, 1 }, 170. 	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, UNDEF_BLESS }, 171. 	{ 0, 0, 0, 0, 0 }  172.  };  173.   174.  /*  175.   *	Optional extra inventory items. 176.  */  177.   178.  static struct trobj Tinopener[] = { 179. 	{ TIN_OPENER, 0, TOOL_CLASS, 1, 0 }, 180. 	{ 0, 0, 0, 0, 0 }  181.  };  182.  static struct trobj Magicmarker[] = { 183. 	{ MAGIC_MARKER, UNDEF_SPE, TOOL_CLASS, 1, 0 }, 184. 	{ 0, 0, 0, 0, 0 }  185.  };  186.  static struct trobj Lamp[] = { 187. 	{ OIL_LAMP, 1, TOOL_CLASS, 1, 0 }, 188. 	{ 0, 0, 0, 0, 0 }  189.  };  190.  static struct trobj Blindfold[] = { 191. 	{ BLINDFOLD, 0, TOOL_CLASS, 1, 0 }, 192. 	{ 0, 0, 0, 0, 0 }  193.  };  194.  static struct trobj Instrument[] = { 195. 	{ WOODEN_FLUTE, 0, TOOL_CLASS, 1, 0 }, 196. 	{ 0, 0, 0, 0, 0 }  197.  };  198.  static struct trobj Xtra_food[] = { 199. 	{ UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 2, 0 }, 200. 	{ 0, 0, 0, 0, 0 }  201.  };  202.  #ifdef TOURIST 203. static struct trobj Leash[] = { 204. 	{ LEASH, 0, TOOL_CLASS, 1, 0 }, 205. 	{ 0, 0, 0, 0, 0 }  206.  };  207.  static struct trobj Towel[] = { 208. 	{ TOWEL, 0, TOOL_CLASS, 1, 0 }, 209. 	{ 0, 0, 0, 0, 0 }  210.  };  211.  #endif	/* TOURIST */ 212. static struct trobj Wishing[] = { 213. 	{ WAN_WISHING, 3, WAND_CLASS, 1, 0 }, 214. 	{ 0, 0, 0, 0, 0 }  215.  };  216.  #ifdef GOLDOBJ 217. static struct trobj Money[] = { 218. 	{ GOLD_PIECE, 0, GOLD_CLASS, 1, 0 }, 219. 	{ 0, 0, 0, 0, 0 }  220.  };  221.  #endif 222.  223.  /* race-based substitutions for initial inventory; 224.    the weaker cloak for elven rangers is intentional--they shoot better */ 225. static struct inv_sub { short race_pm, item_otyp, subs_otyp; } inv_subs[] = { 226.     { PM_ELF,	DAGGER,			ELVEN_DAGGER	      }, 227.     { PM_ELF,	SPEAR,			ELVEN_SPEAR	      }, 228.     { PM_ELF,	SHORT_SWORD,		ELVEN_SHORT_SWORD     }, 229.     { PM_ELF,	BOW,			ELVEN_BOW	      }, 230.     { PM_ELF,	ARROW,			ELVEN_ARROW	      }, 231.     { PM_ELF,	HELMET,			ELVEN_LEATHER_HELM    }, 232.  /* { PM_ELF,	SMALL_SHIELD,		ELVEN_SHIELD	      }, */ 233.     { PM_ELF,	CLOAK_OF_DISPLACEMENT,	ELVEN_CLOAK	      }, 234.     { PM_ELF,	CRAM_RATION,		LEMBAS_WAFER	      }, 235.     { PM_ORC,	DAGGER,			ORCISH_DAGGER	      }, 236.     { PM_ORC,	SPEAR,			ORCISH_SPEAR	      }, 237.     { PM_ORC,	SHORT_SWORD,		ORCISH_SHORT_SWORD    }, 238.     { PM_ORC,	BOW,			ORCISH_BOW	      }, 239.     { PM_ORC,	ARROW,			ORCISH_ARROW	      }, 240.     { PM_ORC,	HELMET,			ORCISH_HELM	      }, 241.     { PM_ORC,	SMALL_SHIELD,		ORCISH_SHIELD	      }, 242.     { PM_ORC,	RING_MAIL,		ORCISH_RING_MAIL      }, 243.     { PM_ORC,	CHAIN_MAIL,		ORCISH_CHAIN_MAIL     }, 244.     { PM_DWARF, SPEAR,			DWARVISH_SPEAR	      }, 245.     { PM_DWARF, SHORT_SWORD,		DWARVISH_SHORT_SWORD  }, 246.     { PM_DWARF, HELMET,			DWARVISH_IRON_HELM    }, 247.  /* { PM_DWARF, SMALL_SHIELD,		DWARVISH_ROUNDSHIELD  }, */ 248.  /* { PM_DWARF, PICK_AXE,		DWARVISH_MATTOCK      }, */ 249.     { PM_GNOME, BOW,			CROSSBOW	      }, 250.     { PM_GNOME, ARROW,			CROSSBOW_BOLT	      }, 251.     { NON_PM,	STRANGE_OBJECT,		STRANGE_OBJECT	      } 252. };  253.   254.  static struct def_skill Skill_A[] = { 255.     { P_DAGGER, P_BASIC },		{ P_KNIFE,  P_BASIC }, 256.     { P_PICK_AXE, P_EXPERT },		{ P_SHORT_SWORD, P_BASIC }, 257.     { P_SCIMITAR, P_SKILLED },		{ P_SABER, P_EXPERT }, 258.     { P_CLUB, P_SKILLED },		{ P_QUARTERSTAFF, P_SKILLED }, 259.     { P_SLING, P_SKILLED },		{ P_DART, P_BASIC }, 260.     { P_BOOMERANG, P_EXPERT },		{ P_WHIP, P_EXPERT }, 261.     { P_UNICORN_HORN, P_SKILLED }, 262.     { P_ATTACK_SPELL, P_BASIC },	{ P_HEALING_SPELL, P_BASIC }, 263.     { P_DIVINATION_SPELL, P_EXPERT},	{ P_MATTER_SPELL, P_BASIC}, 264. #ifdef STEED 265.     { P_RIDING, P_BASIC }, 266. #endif 267.     { P_TWO_WEAPON_COMBAT, P_BASIC }, 268.     { P_BARE_HANDED_COMBAT, P_EXPERT }, 269.     { P_NONE, 0 } 270. };  271.   272.  static struct def_skill Skill_B[] = { 273.     { P_DAGGER, P_BASIC },		{ P_AXE, P_EXPERT }, 274.     { P_PICK_AXE, P_EXPERT },		{ P_SHORT_SWORD, P_BASIC }, 275.     { P_BROAD_SWORD, P_SKILLED },	{ P_LONG_SWORD, P_SKILLED }, 276.     { P_TWO_HANDED_SWORD, P_EXPERT },	{ P_SCIMITAR, P_SKILLED }, 277.     { P_SABER, P_BASIC },		{ P_CLUB, P_SKILLED }, 278.     { P_MACE, P_SKILLED },		{ P_MORNING_STAR, P_SKILLED }, 279.     { P_FLAIL, P_BASIC },		{ P_HAMMER, P_EXPERT }, 280.     { P_QUARTERSTAFF, P_BASIC },	{ P_SPEAR, P_SKILLED }, 281.     { P_TRIDENT, P_SKILLED },		{ P_BOW, P_BASIC }, 282.     { P_ATTACK_SPELL, P_SKILLED }, 283. #ifdef STEED 284.     { P_RIDING, P_BASIC }, 285. #endif 286.     { P_TWO_WEAPON_COMBAT, P_BASIC }, 287.     { P_BARE_HANDED_COMBAT, P_GRAND_MASTER }, 288.     { P_NONE, 0 } 289. };  290.   291.  static struct def_skill Skill_C[] = { 292.     { P_DAGGER, P_BASIC },		{ P_KNIFE,  P_SKILLED }, 293.     { P_AXE, P_SKILLED },		{ P_PICK_AXE, P_BASIC }, 294.     { P_CLUB, P_EXPERT },		{ P_MACE, P_EXPERT }, 295.     { P_MORNING_STAR, P_BASIC },	{ P_FLAIL, P_SKILLED }, 296.     { P_HAMMER, P_SKILLED },		{ P_QUARTERSTAFF, P_EXPERT }, 297.     { P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_EXPERT }, 298.     { P_JAVELIN, P_SKILLED },		{ P_TRIDENT, P_SKILLED }, 299.     { P_BOW, P_SKILLED },		{ P_SLING, P_EXPERT }, 300.     { P_ATTACK_SPELL, P_BASIC },	{ P_MATTER_SPELL, P_SKILLED }, 301.     { P_BOOMERANG, P_EXPERT },		{ P_UNICORN_HORN, P_BASIC }, 302.     { P_BARE_HANDED_COMBAT, P_GRAND_MASTER }, 303.     { P_NONE, 0 } 304. };  305.   306.  static struct def_skill Skill_H[] = { 307.     { P_DAGGER, P_SKILLED },		{ P_KNIFE, P_EXPERT }, 308.     { P_SHORT_SWORD, P_SKILLED },	{ P_SCIMITAR, P_BASIC }, 309.     { P_SABER, P_BASIC },		{ P_CLUB, P_SKILLED }, 310.     { P_MACE, P_BASIC },		{ P_QUARTERSTAFF, P_EXPERT }, 311.     { P_POLEARMS, P_BASIC },		{ P_SPEAR, P_BASIC }, 312.     { P_JAVELIN, P_BASIC },		{ P_TRIDENT, P_BASIC }, 313.     { P_SLING, P_SKILLED },		{ P_DART, P_EXPERT }, 314.     { P_SHURIKEN, P_SKILLED },		{ P_UNICORN_HORN, P_EXPERT }, 315.     { P_HEALING_SPELL, P_EXPERT }, 316.     { P_BARE_HANDED_COMBAT, P_BASIC }, 317.     { P_NONE, 0 } 318. };  319.   320.  static struct def_skill Skill_K[] = { 321.     { P_DAGGER, P_BASIC },		{ P_KNIFE, P_BASIC }, 322.     { P_AXE, P_SKILLED },		{ P_PICK_AXE, P_BASIC }, 323.     { P_SHORT_SWORD, P_SKILLED },	{ P_BROAD_SWORD, P_SKILLED }, 324.     { P_LONG_SWORD, P_EXPERT },	{ P_TWO_HANDED_SWORD, P_SKILLED }, 325.     { P_SCIMITAR, P_BASIC },		{ P_SABER, P_SKILLED }, 326.     { P_CLUB, P_BASIC },		{ P_MACE, P_SKILLED }, 327.     { P_MORNING_STAR, P_SKILLED },	{ P_FLAIL, P_BASIC }, 328.     { P_HAMMER, P_BASIC },		{ P_POLEARMS, P_SKILLED }, 329.     { P_SPEAR, P_SKILLED },		{ P_JAVELIN, P_SKILLED }, 330.     { P_TRIDENT, P_BASIC },		{ P_LANCE, P_EXPERT }, 331.     { P_BOW, P_BASIC },			{ P_CROSSBOW, P_SKILLED }, 332.     { P_ATTACK_SPELL, P_SKILLED },	{ P_HEALING_SPELL, P_SKILLED }, 333.     { P_CLERIC_SPELL, P_SKILLED }, 334. #ifdef STEED 335.     { P_RIDING, P_EXPERT }, 336. #endif 337.     { P_TWO_WEAPON_COMBAT, P_SKILLED }, 338.     { P_BARE_HANDED_COMBAT, P_EXPERT }, 339.     { P_NONE, 0 } 340. };  341.   342.  static struct def_skill Skill_Mon[] = { 343.     { P_QUARTERSTAFF, P_BASIC },    { P_SPEAR, P_BASIC }, 344.     { P_JAVELIN, P_BASIC },		    { P_CROSSBOW, P_BASIC }, 345.     { P_SHURIKEN, P_BASIC }, 346.     { P_ATTACK_SPELL, P_BASIC },    { P_HEALING_SPELL, P_EXPERT }, 347.     { P_DIVINATION_SPELL, P_BASIC },{ P_ENCHANTMENT_SPELL, P_BASIC }, 348.     { P_CLERIC_SPELL, P_SKILLED },  { P_ESCAPE_SPELL, P_BASIC }, 349.     { P_MATTER_SPELL, P_BASIC }, 350.     { P_MARTIAL_ARTS, P_GRAND_MASTER }, 351.     { P_NONE, 0 } 352. };  353.   354.  static struct def_skill Skill_P[] = { 355.     { P_CLUB, P_EXPERT },		{ P_MACE, P_EXPERT }, 356.     { P_MORNING_STAR, P_EXPERT },	{ P_FLAIL, P_EXPERT }, 357.     { P_HAMMER, P_EXPERT },		{ P_QUARTERSTAFF, P_EXPERT }, 358.     { P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_SKILLED }, 359.     { P_JAVELIN, P_SKILLED },		{ P_TRIDENT, P_SKILLED }, 360.     { P_LANCE, P_BASIC },		{ P_BOW, P_BASIC }, 361.     { P_SLING, P_BASIC },		{ P_CROSSBOW, P_BASIC }, 362.     { P_DART, P_BASIC },		{ P_SHURIKEN, P_BASIC }, 363.     { P_BOOMERANG, P_BASIC },		{ P_UNICORN_HORN, P_SKILLED }, 364.     { P_HEALING_SPELL, P_EXPERT },	{ P_DIVINATION_SPELL, P_EXPERT }, 365.     { P_CLERIC_SPELL, P_EXPERT }, 366.     { P_BARE_HANDED_COMBAT, P_BASIC }, 367.     { P_NONE, 0 } 368. };  369.   370.  static struct def_skill Skill_R[] = { 371.     { P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_EXPERT }, 372.     { P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_SKILLED }, 373.     { P_LONG_SWORD, P_SKILLED },	{ P_TWO_HANDED_SWORD, P_BASIC }, 374.     { P_SCIMITAR, P_SKILLED },		{ P_SABER, P_SKILLED }, 375.     { P_CLUB, P_SKILLED },		{ P_MACE, P_SKILLED }, 376.     { P_MORNING_STAR, P_BASIC },	{ P_FLAIL, P_BASIC }, 377.     { P_HAMMER, P_BASIC },		{ P_POLEARMS, P_BASIC }, 378.     { P_SPEAR, P_BASIC },		{ P_CROSSBOW, P_EXPERT }, 379.     { P_DART, P_EXPERT },		{ P_SHURIKEN, P_SKILLED }, 380.     { P_DIVINATION_SPELL, P_SKILLED },	{ P_ESCAPE_SPELL, P_SKILLED }, 381.     { P_MATTER_SPELL, P_SKILLED }, 382. #ifdef STEED 383.     { P_RIDING, P_BASIC }, 384. #endif 385.     { P_TWO_WEAPON_COMBAT, P_EXPERT }, 386.     { P_BARE_HANDED_COMBAT, P_EXPERT }, 387.     { P_NONE, 0 } 388. };  389.   390.  static struct def_skill Skill_Ran[] = { 391.     { P_DAGGER, P_EXPERT },		 { P_KNIFE,  P_SKILLED }, 392.     { P_AXE, P_SKILLED },	 { P_PICK_AXE, P_BASIC }, 393.     { P_SHORT_SWORD, P_BASIC },	 { P_MORNING_STAR, P_BASIC }, 394.     { P_FLAIL, P_SKILLED },	 { P_HAMMER, P_BASIC }, 395.     { P_QUARTERSTAFF, P_BASIC }, { P_POLEARMS, P_SKILLED }, 396.     { P_SPEAR, P_SKILLED },	 { P_JAVELIN, P_EXPERT }, 397.     { P_TRIDENT, P_BASIC },	 { P_BOW, P_EXPERT }, 398.     { P_SLING, P_EXPERT },	 { P_CROSSBOW, P_EXPERT }, 399.     { P_DART, P_EXPERT },	 { P_SHURIKEN, P_SKILLED }, 400.     { P_BOOMERANG, P_EXPERT },	 { P_WHIP, P_BASIC }, 401.     { P_HEALING_SPELL, P_BASIC }, 402.     { P_DIVINATION_SPELL, P_EXPERT }, 403.     { P_ESCAPE_SPELL, P_BASIC }, 404. #ifdef STEED 405.     { P_RIDING, P_BASIC }, 406. #endif 407.     { P_BARE_HANDED_COMBAT, P_BASIC }, 408.     { P_NONE, 0 } 409. };  410.   411.  static struct def_skill Skill_S[] = { 412.     { P_DAGGER, P_BASIC },		{ P_KNIFE,  P_SKILLED }, 413.     { P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_SKILLED }, 414.     { P_LONG_SWORD, P_EXPERT },		{ P_TWO_HANDED_SWORD, P_EXPERT }, 415.     { P_SCIMITAR, P_BASIC },		{ P_SABER, P_BASIC }, 416.     { P_FLAIL, P_SKILLED },		{ P_QUARTERSTAFF, P_BASIC }, 417.     { P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_BASIC }, 418.     { P_JAVELIN, P_BASIC },		{ P_LANCE, P_SKILLED }, 419.     { P_BOW, P_EXPERT },		{ P_SHURIKEN, P_EXPERT }, 420.     { P_ATTACK_SPELL, P_SKILLED },	{ P_CLERIC_SPELL, P_SKILLED }, 421. #ifdef STEED 422.     { P_RIDING, P_SKILLED }, 423. #endif 424.     { P_TWO_WEAPON_COMBAT, P_EXPERT }, 425.     { P_MARTIAL_ARTS, P_GRAND_MASTER }, 426.     { P_NONE, 0 } 427. };  428.   429.  #ifdef TOURIST 430. static struct def_skill Skill_T[] = { 431.     { P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_SKILLED }, 432.     { P_AXE, P_BASIC },			{ P_PICK_AXE, P_BASIC }, 433.     { P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_BASIC }, 434.     { P_LONG_SWORD, P_BASIC },		{ P_TWO_HANDED_SWORD, P_BASIC }, 435.     { P_SCIMITAR, P_SKILLED },		{ P_SABER, P_SKILLED }, 436.     { P_MACE, P_BASIC },		{ P_MORNING_STAR, P_BASIC }, 437.     { P_FLAIL, P_BASIC },		{ P_HAMMER, P_BASIC }, 438.     { P_QUARTERSTAFF, P_BASIC },	{ P_POLEARMS, P_BASIC }, 439.     { P_SPEAR, P_BASIC },		{ P_JAVELIN, P_BASIC }, 440.     { P_TRIDENT, P_BASIC },		{ P_LANCE, P_BASIC }, 441.     { P_BOW, P_BASIC },			{ P_SLING, P_BASIC }, 442.     { P_CROSSBOW, P_BASIC },		{ P_DART, P_EXPERT }, 443.     { P_SHURIKEN, P_BASIC },		{ P_BOOMERANG, P_BASIC }, 444.     { P_WHIP, P_BASIC },		{ P_UNICORN_HORN, P_SKILLED }, 445.     { P_DIVINATION_SPELL, P_BASIC },	{ P_ENCHANTMENT_SPELL, P_BASIC }, 446.     { P_ESCAPE_SPELL, P_SKILLED }, 447. #ifdef STEED 448.     { P_RIDING, P_BASIC }, 449. #endif 450.     { P_TWO_WEAPON_COMBAT, P_SKILLED }, 451.     { P_BARE_HANDED_COMBAT, P_SKILLED }, 452.     { P_NONE, 0 } 453. };  454.  #endif /* TOURIST */ 455.  456.  static struct def_skill Skill_V[] = { 457.     { P_DAGGER, P_EXPERT },		{ P_AXE, P_EXPERT }, 458.     { P_PICK_AXE, P_SKILLED },		{ P_SHORT_SWORD, P_SKILLED }, 459.     { P_BROAD_SWORD, P_SKILLED },	{ P_LONG_SWORD, P_EXPERT }, 460.     { P_TWO_HANDED_SWORD, P_EXPERT },	{ P_SCIMITAR, P_BASIC }, 461.     { P_SABER, P_BASIC },		{ P_HAMMER, P_EXPERT }, 462.     { P_QUARTERSTAFF, P_BASIC },	{ P_POLEARMS, P_SKILLED }, 463.     { P_SPEAR, P_SKILLED },		{ P_JAVELIN, P_BASIC }, 464.     { P_TRIDENT, P_BASIC },		{ P_LANCE, P_SKILLED }, 465.     { P_SLING, P_BASIC }, 466.     { P_ATTACK_SPELL, P_BASIC },	{ P_ESCAPE_SPELL, P_BASIC }, 467. #ifdef STEED 468.     { P_RIDING, P_SKILLED }, 469. #endif 470.     { P_TWO_WEAPON_COMBAT, P_SKILLED }, 471.     { P_BARE_HANDED_COMBAT, P_EXPERT }, 472.     { P_NONE, 0 } 473. };  474.   475.  static struct def_skill Skill_W[] = { 476.     { P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_SKILLED }, 477.     { P_AXE, P_SKILLED },		{ P_SHORT_SWORD, P_BASIC }, 478.     { P_CLUB, P_SKILLED },		{ P_MACE, P_BASIC }, 479.     { P_QUARTERSTAFF, P_EXPERT },	{ P_POLEARMS, P_SKILLED }, 480.     { P_SPEAR, P_BASIC },		{ P_JAVELIN, P_BASIC }, 481.     { P_TRIDENT, P_BASIC },		{ P_SLING, P_SKILLED }, 482.     { P_DART, P_EXPERT },		{ P_SHURIKEN, P_BASIC }, 483.     { P_ATTACK_SPELL, P_EXPERT },	{ P_HEALING_SPELL, P_SKILLED }, 484.     { P_DIVINATION_SPELL, P_EXPERT },	{ P_ENCHANTMENT_SPELL, P_SKILLED }, 485.     { P_CLERIC_SPELL, P_SKILLED },	{ P_ESCAPE_SPELL, P_EXPERT }, 486.     { P_MATTER_SPELL, P_EXPERT }, 487. #ifdef STEED 488.     { P_RIDING, P_BASIC }, 489. #endif 490.     { P_BARE_HANDED_COMBAT, P_BASIC }, 491.     { P_NONE, 0 } 492. };  493.   494.   495.  STATIC_OVL void 496. knows_object(obj) 497. register int obj; 498. {  499.  	discover_object(obj,TRUE,FALSE); 500. 	objects[obj].oc_pre_discovered = 1;	/* not a "discovery" */ 501. }  502.   503.  /* Know ordinary (non-magical) objects of a certain class, 504.  * like all gems except the loadstone and luckstone. 505.  */  506.  STATIC_OVL void 507. knows_class(sym) 508. register char sym; 509. {  510.  	register int ct; 511. 	for (ct = 1; ct < NUM_OBJECTS; ct++) 512. 		if (objects[ct].oc_class == sym && !objects[ct].oc_magic) 513. 			knows_object(ct); 514. }  515.   516.  void 517. u_init 518. {  519.  	register int i;  520. 521. 	flags.female = flags.initgend; 522. 	flags.beginner = 1; 523.  524.  	/* zero u, including pointer values -- 525. 	 * necessary when aborting from a failed restore */ 526. 	(void) memset((genericptr_t)&u, 0, sizeof(u)); 527. 	u.ustuck = (struct monst *)0; 528.  529.  #if 0	/* documentation of more zero values as desirable */ 530. 	u.usick_cause[0] = 0; 531. 	u.uluck  = u.moreluck = 0; 532. # ifdef TOURIST 533. 	uarmu = 0; 534. # endif 535. 	uarm = uarmc = uarmh = uarms = uarmg = uarmf = 0; 536. 	uwep = uball = uchain = uleft = uright = 0; 537. 	uswapwep = uquiver = 0; 538. 	u.twoweap = 0; 539. 	u.ublessed = 0;				/* not worthy yet */ 540. 	u.ugangr   = 0;				/* gods not angry */ 541. 	u.ugifts   = 0;				/* no divine gifts bestowed */ 542. # ifdef ELBERETH 543. 	u.uevent.uhand_of_elbereth = 0; 544. # endif 545. 	u.uevent.uheard_tune = 0; 546. 	u.uevent.uopened_dbridge = 0; 547. 	u.uevent.udemigod = 0;		/* not a demi-god yet... */ 548.  	u.udg_cnt = 0; 549. 	u.mh = u.mhmax = u.mtimedone = 0; 550. 	u.uz.dnum = u.uz0.dnum = 0; 551. 	u.utotype = 0; 552. #endif	/* 0 */ 553.  554.  	u.uz.dlevel = 1; 555. 	u.uz0.dlevel = 0; 556. 	u.utolev = u.uz; 557.  558.  	u.umoved = FALSE; 559. 	u.umortality = 0; 560. 	u.ugrave_arise = NON_PM; 561.  562.  	u.umonnum = u.umonster = (flags.female &&  563.  			urole.femalenum != NON_PM) ? urole.femalenum : 564. 			urole.malenum; 565. 	set_uasmon; 566.  567.  	u.ulevel = 0;	/* set up some of the initial attributes */ 568. 	u.uhp = u.uhpmax = newhp; 569. 	u.uenmax = urole.enadv.infix + urace.enadv.infix; 570. 	if (urole.enadv.inrnd > 0) 571. 	    u.uenmax += rnd(urole.enadv.inrnd); 572. 	if (urace.enadv.inrnd > 0) 573. 	    u.uenmax += rnd(urace.enadv.inrnd); 574. 	u.uen = u.uenmax; 575. 	u.uspellprot = 0; 576. 	adjabil(0,1); 577. 	u.ulevel = u.ulevelmax = 1; 578.  579.  	init_uhunger; 580. 	for (i = 0; i <= MAXSPELL; i++) spl_book[i].sp_id = NO_SPELL; 581. 	u.ublesscnt = 300;			/* no prayers just yet */ 582. 	u.ualignbase[A_CURRENT] = u.ualignbase[A_ORIGINAL] = u.ualign.type = 583. 			aligns[flags.initalign].value; 584. 	u.ulycn = NON_PM; 585.  586.  #ifdef BSD 587. 	(void) time((long *)&u.ubirthday); 588. #else 589. 	(void) time(&u.ubirthday); 590. #endif 591.  592.  	/*  593.  	 *  For now, everyone starts out with a night vision range of 1 and 594. 	 *  their xray range disabled. 595. 	 */  596.  	u.nv_range   =  1; 597. 	u.xray_range = -1; 598.  599.   600.  	/*** Role-specific initializations ***/ 601. 	switch (Role_switch) { 602. 	/* rn2(100) > 50 necessary for some choices because some 603. 	 * random number generators are bad enough to seriously 604. 	 * skew the results if we use rn2(2)... --KAA 605. 	 */  606.  	case PM_ARCHEOLOGIST: 607. 		ini_inv(Archeologist); 608. 		if(!rn2(10)) ini_inv(Tinopener); 609. 		else if(!rn2(4)) ini_inv(Lamp); 610. 		else if(!rn2(10)) ini_inv(Magicmarker); 611. 		knows_object(SACK); 612. 		knows_object(TOUCHSTONE); 613. 		skill_init(Skill_A); 614. 		break; 615. 	case PM_BARBARIAN: 616. 		if (rn2(100) >= 50) {	/* see above comment */ 617. 		    Barbarian[B_MAJOR].trotyp = BATTLE_AXE; 618. 		    Barbarian[B_MINOR].trotyp = SHORT_SWORD; 619. 		}  620.  		ini_inv(Barbarian); 621. 		if(!rn2(6)) ini_inv(Lamp); 622. 		knows_class(WEAPON_CLASS); 623. 		knows_class(ARMOR_CLASS); 624. 		skill_init(Skill_B); 625. 		break; 626. 	case PM_CAVEMAN: 627. 		Cave_man[C_AMMO].trquan = rn1(11, 10);	/* 10..20 */ 628. 		ini_inv(Cave_man); 629. 		skill_init(Skill_C); 630. 		break; 631. 	case PM_HEALER: 632. #ifndef GOLDOBJ 633. 		u.ugold = u.ugold0 = rn1(1000, 1001); 634. #else 635. 		u.umoney0 = rn1(1000, 1001); 636. #endif 637. 		ini_inv(Healer); 638. 		if(!rn2(25)) ini_inv(Lamp); 639. 		knows_object(POT_FULL_HEALING); 640. 		skill_init(Skill_H); 641. 		break; 642. 	case PM_KNIGHT: 643. 		ini_inv(Knight); 644. 		knows_class(WEAPON_CLASS); 645. 		knows_class(ARMOR_CLASS); 646. 		/* give knights chess-like mobility 647. 		 * -- idea from wooledge@skybridge.scl.cwru.edu */ 648. 		HJumping |= FROMOUTSIDE; 649. 		skill_init(Skill_K); 650. 		break; 651. 	case PM_MONK: 652. 		switch (rn2(90) / 30) { 653. 		case 0: Monk[M_BOOK].trotyp = SPE_HEALING; break; 654. 		case 1: Monk[M_BOOK].trotyp = SPE_PROTECTION; break; 655. 		case 2: Monk[M_BOOK].trotyp = SPE_SLEEP; break; 656. 		}  657.  		ini_inv(Monk); 658. 		if(!rn2(5)) ini_inv(Magicmarker); 659. 		else if(!rn2(10)) ini_inv(Lamp); 660. 		knows_class(ARMOR_CLASS); 661. 		skill_init(Skill_Mon); 662. 		break; 663. 	case PM_PRIEST: 664. 		ini_inv(Priest); 665. 		if(!rn2(10)) ini_inv(Magicmarker); 666. 		else if(!rn2(10)) ini_inv(Lamp); 667. 		knows_object(POT_WATER); 668. 		skill_init(Skill_P); 669. 		/* KMH, conduct -- 670. 		 * Some may claim that this isn't agnostic, since they 671. 		 * are literally "priests" and they have holy water. 672. 		 * But we don't count it as such. Purists can always 673. 		 * avoid playing priests and/or confirm another player's  674. * role in their YAAP. 675. 		 */  676.  		break; 677. 	case PM_RANGER: 678. 		Ranger[RAN_TWO_ARROWS].trquan = rn1(10, 50); 679. 		Ranger[RAN_ZERO_ARROWS].trquan = rn1(10, 30); 680. 		ini_inv(Ranger); 681. 		skill_init(Skill_Ran); 682. 		break; 683. 	case PM_ROGUE: 684. 		Rogue[R_DAGGERS].trquan = rn1(10, 6); 685. #ifndef GOLDOBJ 686. 		u.ugold = u.ugold0 = 0; 687. #else 688. 		u.umoney0 = 0; 689. #endif 690. 		ini_inv(Rogue); 691. 		if(!rn2(5)) ini_inv(Blindfold); 692. 		knows_object(SACK); 693. 		skill_init(Skill_R); 694. 		break; 695. 	case PM_SAMURAI: 696. 		Samurai[S_ARROWS].trquan = rn1(20, 26); 697. 		ini_inv(Samurai); 698. 		if(!rn2(5)) ini_inv(Blindfold); 699. 		knows_class(WEAPON_CLASS); 700. 		knows_class(ARMOR_CLASS); 701. 		skill_init(Skill_S); 702. 		break; 703. #ifdef TOURIST 704. 	case PM_TOURIST: 705. 		Tourist[T_DARTS].trquan = rn1(20, 21); 706. #ifndef GOLDOBJ 707. 		u.ugold = u.ugold0 = rnd(1000); 708. #else 709. 		u.umoney0 = rnd(1000); 710. #endif 711. 		ini_inv(Tourist); 712. 		if(!rn2(25)) ini_inv(Tinopener); 713. 		else if(!rn2(25)) ini_inv(Leash); 714. 		else if(!rn2(25)) ini_inv(Towel); 715. 		else if(!rn2(25)) ini_inv(Magicmarker); 716. 		skill_init(Skill_T); 717. 		break; 718. #endif 719. 	case PM_VALKYRIE: 720. 		ini_inv(Valkyrie); 721. 		if(!rn2(6)) ini_inv(Lamp); 722. 		knows_class(WEAPON_CLASS); 723. 		knows_class(ARMOR_CLASS); 724. 		skill_init(Skill_V); 725. 		break; 726. 	case PM_WIZARD: 727. 		ini_inv(Wizard); 728. 		if(!rn2(5)) ini_inv(Magicmarker); 729. 		if(!rn2(5)) ini_inv(Blindfold); 730. 		skill_init(Skill_W); 731. 		break; 732.  733.  	default:	/* impossible */ 734. 		break; 735. 	}  736.   737.   738.  	/*** Race-specific initializations ***/ 739. 	switch (Race_switch) { 740. 	case PM_HUMAN: 741. 	    /* Nothing special */ 742. 	    break; 743.  744.  	case PM_ELF: 745. 	    /*  746.  	     * Elves are people of music and song, or they are warriors. 747. 	     * Non-warriors get an instrument. We use a kludge to 748. * get only non-magic instruments. 749. 	     */  750.  	    if (Role_if(PM_PRIEST) || Role_if(PM_WIZARD)) { 751. 		static int trotyp[] = { 752. 		    WOODEN_FLUTE, TOOLED_HORN, WOODEN_HARP, 753. 		    BELL, BUGLE, LEATHER_DRUM 754. 		};  755.  		Instrument[0].trotyp = trotyp[rn2(SIZE(trotyp))]; 756. 		ini_inv(Instrument); 757. 	    }  758.   759.  	    /* Elves can recognize all elvish objects */ 760. 	    knows_object(ELVEN_SHORT_SWORD); 761. 	    knows_object(ELVEN_ARROW); 762. 	    knows_object(ELVEN_BOW); 763. 	    knows_object(ELVEN_SPEAR); 764. 	    knows_object(ELVEN_DAGGER); 765. 	    knows_object(ELVEN_BROADSWORD); 766. 	    knows_object(ELVEN_MITHRIL_COAT); 767. 	    knows_object(ELVEN_LEATHER_HELM); 768. 	    knows_object(ELVEN_SHIELD); 769. 	    knows_object(ELVEN_BOOTS); 770. 	    knows_object(ELVEN_CLOAK); 771. 	    break; 772.  773.  	case PM_DWARF: 774. 	    /* Dwarves can recognize all dwarvish objects */ 775. 	    knows_object(DWARVISH_SPEAR); 776. 	    knows_object(DWARVISH_SHORT_SWORD); 777. 	    knows_object(DWARVISH_MATTOCK); 778. 	    knows_object(DWARVISH_IRON_HELM); 779. 	    knows_object(DWARVISH_MITHRIL_COAT); 780. 	    knows_object(DWARVISH_CLOAK); 781. 	    knows_object(DWARVISH_ROUNDSHIELD); 782. 	    break; 783.  784.  	case PM_GNOME: 785. 	    break; 786.  787.  	case PM_ORC: 788. 	    /* compensate for generally inferior equipment */ 789. 	    if (!Role_if(PM_WIZARD)) 790. 		ini_inv(Xtra_food); 791. 	    /* Orcs can recognize all orcish objects */ 792. 	    knows_object(ORCISH_SHORT_SWORD); 793. 	    knows_object(ORCISH_ARROW); 794. 	    knows_object(ORCISH_BOW); 795. 	    knows_object(ORCISH_SPEAR); 796. 	    knows_object(ORCISH_DAGGER); 797. 	    knows_object(ORCISH_CHAIN_MAIL); 798. 	    knows_object(ORCISH_RING_MAIL); 799. 	    knows_object(ORCISH_HELM); 800. 	    knows_object(ORCISH_SHIELD); 801. 	    knows_object(URUK_HAI_SHIELD); 802. 	    knows_object(ORCISH_CLOAK); 803. 	    break; 804.  805.  	default:	/* impossible */ 806. 		break; 807. 	}  808.   809.  	if (discover) 810. 		ini_inv(Wishing); 811.  812.  #ifdef WIZARD 813. 	if (wizard) 814. 		read_wizkit; 815. #endif 816.  817.  #ifndef GOLDOBJ 818. 	u.ugold0 += hidden_gold;	/* in case sack has gold in it */ 819. #else 820. 	if (u.umoney0) ini_inv(Money); 821. 	u.umoney0 += hidden_gold;	/* in case sack has gold in it */ 822. #endif 823.  824.  	find_ac;			/* get initial ac value */ 825. 	init_attr(75);			/* init attribute values */ 826. 	max_rank_sz;			/* set max str size for class ranks */ 827. /*  828.   *	Do we really need this? 829.  */  830.  	for(i = 0; i < A_MAX; i++) 831. 	    if(!rn2(20)) { 832. 		register int xd = rn2(7) - 2;	/* biased variation */ 833. 		(void) adjattrib(i, xd, TRUE); 834. 		if (ABASE(i) < AMAX(i)) AMAX(i) = ABASE(i); 835. 	    }  836.   837.  	/* make sure you can carry all you have - especially for Tourists */ 838. 	while (inv_weight > 0) { 839. 		if (adjattrib(A_STR, 1, TRUE)) continue; 840. 		if (adjattrib(A_CON, 1, TRUE)) continue; 841. 		/* only get here when didn't boost strength or constitution */ 842. 		break; 843. 	}  844.   845.  	return; 846. }  847.   848.  /* skills aren't initialized, so we use the role-specific skill lists */ 849. STATIC_OVL boolean 850. restricted_spell_discipline(otyp) 851. int otyp; 852. {  853.      struct def_skill *skills; 854.     int this_skill = spell_skilltype(otyp); 855.  856.      switch (Role_switch) { 857.      case PM_ARCHEOLOGIST:	skills = Skill_A; break; 858.      case PM_BARBARIAN:		skills = Skill_B; break; 859.      case PM_CAVEMAN:		skills = Skill_C; break; 860.      case PM_HEALER:		skills = Skill_H; break; 861.      case PM_KNIGHT:		skills = Skill_K; break; 862.      case PM_MONK:		skills = Skill_Mon; break; 863.      case PM_PRIEST:		skills = Skill_P; break; 864.      case PM_RANGER:		skills = Skill_Ran; break; 865.      case PM_ROGUE:		skills = Skill_R; break; 866.      case PM_SAMURAI:		skills = Skill_S; break; 867. #ifdef TOURIST 868.      case PM_TOURIST:		skills = Skill_T; break; 869. #endif 870.      case PM_VALKYRIE:		skills = Skill_V; break; 871.      case PM_WIZARD:		skills = Skill_W; break; 872.      default:			skills = 0; break;	/* lint suppression */ 873.     }  874.   875.      while (skills->skill != P_NONE) { 876. 	if (skills->skill == this_skill) return FALSE; 877. 	++skills; 878.     }  879.      return TRUE; 880. }  881.   882.  STATIC_OVL void 883. ini_inv(trop) 884. register struct trobj *trop; 885. {  886.  	struct obj *obj; 887. 	int otyp, i;  888. 889. 	while (trop->trclass) { 890. 		if (trop->trotyp != UNDEF_TYP) { 891. 			otyp = (int)trop->trotyp; 892. 			if (urace.malenum != PM_HUMAN) { 893. 			    /* substitute specific items for generic ones */ 894. 			    for (i = 0; inv_subs[i].race_pm != NON_PM; ++i) 895. 				if (inv_subs[i].race_pm == urace.malenum &&  896.  					otyp == inv_subs[i].item_otyp) { 897. 				    otyp = inv_subs[i].subs_otyp; 898. 				    break; 899. 				}  900.  			}  901.  			obj = mksobj(otyp, TRUE, FALSE); 902. 		} else {	/* UNDEF_TYP */ 903. 			static NEARDATA short nocreate = STRANGE_OBJECT; 904. 			static NEARDATA short nocreate2 = STRANGE_OBJECT; 905. 			static NEARDATA short nocreate3 = STRANGE_OBJECT; 906. 			static NEARDATA short nocreate4 = STRANGE_OBJECT; 907. 		/*  908.  		 * For random objects, do not create certain overly powerful 909. 		 * items: wand of wishing, ring of levitation, or the 910. 		 * polymorph/polymorph control combination. Specific objects, 911. 		 * i.e. the discovery wishing, are still OK. 912. 		 * Also, don't get a couple of really useless items. (Note: 913.  		 * punishment isn't "useless".  Some players who start out with  914.  		 * one will immediately read it and use the iron ball as a  915.  		 * weapon.) 916. 		 */  917.  			obj = mkobj(trop->trclass, FALSE); 918. 			otyp = obj->otyp; 919. 			while (otyp == WAN_WISHING  920.  				|| otyp == nocreate  921.  				|| otyp == nocreate2  922.  				|| otyp == nocreate3  923.  				|| otyp == nocreate4  924.  #ifdef ELBERETH  925.  				|| otyp == RIN_LEVITATION  926.  #endif  927.  				/* 'useless' items */  928.  				|| otyp == POT_HALLUCINATION  929.  				|| otyp == POT_ACID  930.  				|| otyp == SCR_AMNESIA  931.  				|| otyp == SCR_FIRE  932.  				|| otyp == SCR_BLANK_PAPER  933.  				|| otyp == SPE_BLANK_PAPER  934.  				|| otyp == RIN_AGGRAVATE_MONSTER  935.  				|| otyp == RIN_HUNGER  936.  				|| otyp == WAN_NOTHING  937.  				/* Monks don't use weapons */  938.  				|| (otyp == SCR_ENCHANT_WEAPON && 939. 				    Role_if(PM_MONK))  940.  				/* wizard patch -- they already have one */  941.  				|| (otyp == SPE_FORCE_BOLT && 942. 				    Role_if(PM_WIZARD))  943.  				/* powerful spells are either useless to  944.  				   low level players or unbalancing; also  945.  				   spells in restricted skill categories */  946.  				|| (obj->oclass == SPBOOK_CLASS && 947. 				    (objects[otyp].oc_level > 3 ||  948.  				    restricted_spell_discipline(otyp)))  949.  							) { 950. 				dealloc_obj(obj); 951. 				obj = mkobj(trop->trclass, FALSE); 952. 				otyp = obj->otyp; 953. 			}  954.   955.  			/* Don't start with +0 or negative rings */ 956. 			if (objects[otyp].oc_charged && obj->spe <= 0) 957. 				obj->spe = rne(3); 958.  959.  			/* Heavily relies on the fact that 1) we create wands  960.  			 * before rings, 2) that we create rings before 961. 			 * spellbooks, and that 3) not more than 1 object of a  962.  			 * particular symbol is to be prohibited.  (For more 963. 			 * objects, we need more nocreate variables...)  964.  			 */  965.  			switch (otyp) {  966.  			    case WAN_POLYMORPH:  967.  			    case RIN_POLYMORPH:  968.  			    case POT_POLYMORPH:  969.  				nocreate = RIN_POLYMORPH_CONTROL;  970.  				break;  971.  			    case RIN_POLYMORPH_CONTROL:  972.  				nocreate = RIN_POLYMORPH;  973.  				nocreate2 = SPE_POLYMORPH;  974.  				nocreate3 = POT_POLYMORPH;  975.  			}  976.  			/* Don't have 2 of the same ring or spellbook */  977.  			if (obj->oclass == RING_CLASS || 978. 			    obj->oclass == SPBOOK_CLASS)  979.  				nocreate4 = otyp;  980.  		}  981.   982.  #ifdef GOLDOBJ  983.  		if (trop->trclass == GOLD_CLASS) {  984.  			/* no "blessed" or "identified" money */  985.  			obj->quan = u.umoney0;  986.  		} else {  987.  #endif  988.  			obj->dknown = obj->bknown = obj->rknown = 1;  989.  			if (objects[otyp].oc_uses_known) obj->known = 1;  990.  			obj->cursed = 0;  991.  			if (obj->opoisoned && u.ualign.type != A_CHAOTIC)  992.  			    obj->opoisoned = 0;  993.  			if (obj->oclass == WEAPON_CLASS || 994. 				obj->oclass == TOOL_CLASS) {  995.  			    obj->quan = (long) trop->trquan;  996.  			    trop->trquan = 1;  997.  			} else if (obj->oclass == GEM_CLASS && 998. 				is_graystone(obj) && obj->otyp != FLINT) {  999.  			    obj->quan = 1L;  1000. 			}  1001. 			if (trop->trspe != UNDEF_SPE)  1002. 			    obj->spe = trop->trspe;  1003. 			if (trop->trbless != UNDEF_BLESS)  1004. 			    obj->blessed = trop->trbless;  1005. #ifdef GOLDOBJ  1006. 		}  1007. #endif  1008. 		/* defined after setting otyp+quan + blessedness */  1009. 		obj->owt = weight(obj);  1010. 		obj = addinv(obj);  1011.  1012. 		/* Make the type known if necessary */  1013. 		if (OBJ_DESCR(objects[otyp]) && obj->known)  1014. 			discover_object(otyp, TRUE, FALSE);  1015. 		if (otyp == OIL_LAMP)  1016. 			discover_object(POT_OIL, TRUE, FALSE);  1017.  1018. 		if(obj->oclass == ARMOR_CLASS){  1019. 			if (is_shield(obj) && !uarms) {  1020. 				setworn(obj, W_ARMS);  1021. 				if (uswapwep) setuswapwep((struct obj *) 0);  1022. 			} else if (is_helmet(obj) && !uarmh)  1023. 				setworn(obj, W_ARMH); 1024. 			else if (is_gloves(obj) && !uarmg) 1025. 				setworn(obj, W_ARMG); 1026. #ifdef TOURIST 1027. 			else if (is_shirt(obj) && !uarmu) 1028. 				setworn(obj, W_ARMU); 1029. #endif 1030. 			else if (is_cloak(obj) && !uarmc) 1031. 				setworn(obj, W_ARMC); 1032. 			else if (is_boots(obj) && !uarmf) 1033. 				setworn(obj, W_ARMF); 1034. 			else if (is_suit(obj) && !uarm) 1035. 				setworn(obj, W_ARM); 1036. 		} 1037.  1038. 		if (obj->oclass == WEAPON_CLASS || is_weptool(obj) ||  1039. 			otyp == TIN_OPENER || otyp == FLINT || otyp == ROCK) { 1040. 		   if (is_ammo(obj) || is_missile(obj)) { 1041. 			if (!uquiver) setuqwep(obj); 1042. 		   } else if (!uwep) setuwep(obj); 1043. 		   else if (!uswapwep) setuswapwep(obj); 1044. 		} 1045. 		if (obj->oclass == SPBOOK_CLASS &&  1046. 				obj->otyp != SPE_BLANK_PAPER) 1047. 		   initialspell(obj); 1048. 1049. #if !defined(PYRAMID_BUG) && !defined(MAC) 1050. 		if(--trop->trquan) continue;	/* make a similar object */ 1051. #else 1052. 		if(trop->trquan) {		/* check if zero first */ 1053. 			--trop->trquan; 1054. 			if(trop->trquan) 1055. 				continue;	/* make a similar object */ 1056. 		} 1057. #endif 1058. 		trop++; 1059. 	} 1060. }  1061.  1062. /*u_init.c*/