Source:NetHack 3.6.0/src/u init.c

From NetHackWiki
(Redirected from Source:U init.c)
Jump to: navigation, search

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

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.

Contents

Top of file

  1.  /* NetHack 3.6	u_init.c	$NHDT-Date: 1446861772 2015/11/07 02:02:52 $  $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */
  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.  

Initial inventories

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

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

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.  };
  14.  

Optional extra inventory items

  1.  /*
  2.   *      Optional extra inventory items.
  3.   */
  4.  
  5.  static struct trobj Tinopener[] = { { TIN_OPENER, 0, TOOL_CLASS, 1, 0 },
  6.                                      { 0, 0, 0, 0, 0 } };
  7.  static struct trobj Magicmarker[] = { { MAGIC_MARKER, UNDEF_SPE, TOOL_CLASS,
  8.                                          1, 0 },
  9.                                        { 0, 0, 0, 0, 0 } };
  10.  static struct trobj Lamp[] = { { OIL_LAMP, 1, TOOL_CLASS, 1, 0 },
  11.                                 { 0, 0, 0, 0, 0 } };
  12.  static struct trobj Blindfold[] = { { BLINDFOLD, 0, TOOL_CLASS, 1, 0 },
  13.                                      { 0, 0, 0, 0, 0 } };
  14.  static struct trobj Instrument[] = { { WOODEN_FLUTE, 0, TOOL_CLASS, 1, 0 },
  15.                                       { 0, 0, 0, 0, 0 } };
  16.  static struct trobj Xtra_food[] = { { UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 2, 0 },
  17.                                      { 0, 0, 0, 0, 0 } };
  18.  static struct trobj Leash[] = { { LEASH, 0, TOOL_CLASS, 1, 0 },
  19.                                  { 0, 0, 0, 0, 0 } };
  20.  static struct trobj Towel[] = { { TOWEL, 0, TOOL_CLASS, 1, 0 },
  21.                                  { 0, 0, 0, 0, 0 } };
  22.  static struct trobj Wishing[] = { { WAN_WISHING, 3, WAND_CLASS, 1, 0 },
  23.                                    { 0, 0, 0, 0, 0 } };
  24.  static struct trobj Money[] = { { GOLD_PIECE, 0, COIN_CLASS, 1, 0 },
  25.                                  { 0, 0, 0, 0, 0 } };
  26.  

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 {
  4.      short race_pm, item_otyp, subs_otyp;
  5.  } inv_subs[] = {
  6.      { PM_ELF, DAGGER, ELVEN_DAGGER },
  7.      { PM_ELF, SPEAR, ELVEN_SPEAR },
  8.      { PM_ELF, SHORT_SWORD, ELVEN_SHORT_SWORD },
  9.      { PM_ELF, BOW, ELVEN_BOW },
  10.      { PM_ELF, ARROW, ELVEN_ARROW },
  11.      { PM_ELF, HELMET, ELVEN_LEATHER_HELM },
  12.      /* { PM_ELF, SMALL_SHIELD, ELVEN_SHIELD }, */
  13.      { PM_ELF, CLOAK_OF_DISPLACEMENT, ELVEN_CLOAK },
  14.      { PM_ELF, CRAM_RATION, LEMBAS_WAFER },
  15.      { PM_ORC, DAGGER, ORCISH_DAGGER },
  16.      { PM_ORC, SPEAR, ORCISH_SPEAR },
  17.      { PM_ORC, SHORT_SWORD, ORCISH_SHORT_SWORD },
  18.      { PM_ORC, BOW, ORCISH_BOW },
  19.      { PM_ORC, ARROW, ORCISH_ARROW },
  20.      { PM_ORC, HELMET, ORCISH_HELM },
  21.      { PM_ORC, SMALL_SHIELD, ORCISH_SHIELD },
  22.      { PM_ORC, RING_MAIL, ORCISH_RING_MAIL },
  23.      { PM_ORC, CHAIN_MAIL, ORCISH_CHAIN_MAIL },
  24.      { PM_DWARF, SPEAR, DWARVISH_SPEAR },
  25.      { PM_DWARF, SHORT_SWORD, DWARVISH_SHORT_SWORD },
  26.      { PM_DWARF, HELMET, DWARVISH_IRON_HELM },
  27.      /* { PM_DWARF, SMALL_SHIELD, DWARVISH_ROUNDSHIELD }, */
  28.      /* { PM_DWARF, PICK_AXE, DWARVISH_MATTOCK }, */
  29.      { PM_GNOME, BOW, CROSSBOW },
  30.      { PM_GNOME, ARROW, CROSSBOW_BOLT },
  31.      { NON_PM, STRANGE_OBJECT, STRANGE_OBJECT }
  32.  };
  33.  

Maximum skill levels

Archeologist max skill levels

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

Barbarian max skill levels

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

Caveman max skill levels

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

Healer max skill levels

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

Knight max skill levels

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

Monk max skill levels

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

Priest max skill levels

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

Rogue max skill levels

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

Ranger max skill levels

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

Samurai max skill levels

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

Tourist max skill levels

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

Valkyrie max skill levels

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

Wizard max skill levels

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

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.  }
  8.  

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.  }
  13.  

u_init

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

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))
  4.              ini_inv(Tinopener);
  5.          else if (!rn2(4))
  6.              ini_inv(Lamp);
  7.          else if (!rn2(10))
  8.              ini_inv(Magicmarker);
  9.          knows_object(SACK);
  10.          knows_object(TOUCHSTONE);
  11.          skill_init(Skill_A);
  12.          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))
  8.              ini_inv(Lamp);
  9.          knows_class(WEAPON_CLASS);
  10.          knows_class(ARMOR_CLASS);
  11.          skill_init(Skill_B);
  12.          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.          u.umoney0 = rn1(1000, 1001);
  3.          ini_inv(Healer);
  4.          if (!rn2(25))
  5.              ini_inv(Lamp);
  6.          knows_object(POT_FULL_HEALING);
  7.          skill_init(Skill_H);
  8.          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:
  4.              Monk[M_BOOK].trotyp = SPE_HEALING;
  5.              break;
  6.          case 1:
  7.              Monk[M_BOOK].trotyp = SPE_PROTECTION;
  8.              break;
  9.          case 2:
  10.              Monk[M_BOOK].trotyp = SPE_SLEEP;
  11.              break;
  12.          }
  13.          ini_inv(Monk);
  14.          if (!rn2(5))
  15.              ini_inv(Magicmarker);
  16.          else if (!rn2(10))
  17.              ini_inv(Lamp);
  18.          knows_class(ARMOR_CLASS);
  19.          skill_init(Skill_Mon);
  20.          break;

Priest initializations

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

Samurai initializations

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

Tourist initializations

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

Valkyrie initializations

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

Wizard initializations

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

Race-specific initializations

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

Human initializations

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

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[] = { WOODEN_FLUTE, TOOLED_HORN, WOODEN_HARP,
  9.                                      BELL,         BUGLE,       LEATHER_DRUM };
  10.              Instrument[0].trotyp = trotyp[rn2(SIZE(trotyp))];
  11.              ini_inv(Instrument);
  12.          }
  13.  
  14.          /* Elves can recognize all elvish objects */
  15.          knows_object(ELVEN_SHORT_SWORD);
  16.          knows_object(ELVEN_ARROW);
  17.          knows_object(ELVEN_BOW);
  18.          knows_object(ELVEN_SPEAR);
  19.          knows_object(ELVEN_DAGGER);
  20.          knows_object(ELVEN_BROADSWORD);
  21.          knows_object(ELVEN_MITHRIL_COAT);
  22.          knows_object(ELVEN_LEATHER_HELM);
  23.          knows_object(ELVEN_SHIELD);
  24.          knows_object(ELVEN_BOOTS);
  25.          knows_object(ELVEN_CLOAK);
  26.          break;
  27.  

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;
  11.  

Gnome initializations

  1.      case PM_GNOME:
  2.          break;
  3.  

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.      if (wizard)
  27.          read_wizkit();
  28.  
  29.      if (u.umoney0)
  30.          ini_inv(Money);
  31.      u.umoney0 += hidden_gold(); /* in case sack has gold in it */
  32.  
  33.      find_ac();     /* get initial ac value */
  34.      init_attr(75); /* init attribute values */
  35.      max_rank_sz(); /* set max str size for class ranks */
  36.      /*
  37.       *  Do we really need this?
  38.       */
  39.      for (i = 0; i < A_MAX; i++)
  40.          if (!rn2(20)) {
  41.              register int xd = rn2(7) - 2; /* biased variation */
  42.  
  43.              (void) adjattrib(i, xd, TRUE);
  44.              if (ABASE(i) < AMAX(i))
  45.                  AMAX(i) = ABASE(i);
  46.          }
  47.  
  48.      /* make sure you can carry all you have - especially for Tourists */
  49.      while (inv_weight() > 0) {
  50.          if (adjattrib(A_STR, 1, TRUE))
  51.              continue;
  52.          if (adjattrib(A_CON, 1, TRUE))
  53.              continue;
  54.          /* only get here when didn't boost strength or constitution */
  55.          break;
  56.      }
  57.  
  58.      return;
  59.  }
  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:
  11.          skills = Skill_A;
  12.          break;
  13.      case PM_BARBARIAN:
  14.          skills = Skill_B;
  15.          break;
  16.      case PM_CAVEMAN:
  17.          skills = Skill_C;
  18.          break;
  19.      case PM_HEALER:
  20.          skills = Skill_H;
  21.          break;
  22.      case PM_KNIGHT:
  23.          skills = Skill_K;
  24.          break;
  25.      case PM_MONK:
  26.          skills = Skill_Mon;
  27.          break;
  28.      case PM_PRIEST:
  29.          skills = Skill_P;
  30.          break;
  31.      case PM_RANGER:
  32.          skills = Skill_Ran;
  33.          break;
  34.      case PM_ROGUE:
  35.          skills = Skill_R;
  36.          break;
  37.      case PM_SAMURAI:
  38.          skills = Skill_S;
  39.          break;
  40.      case PM_TOURIST:
  41.          skills = Skill_T;
  42.          break;
  43.      case PM_VALKYRIE:
  44.          skills = Skill_V;
  45.          break;
  46.      case PM_WIZARD:
  47.          skills = Skill_W;
  48.          break;
  49.      default:
  50.          skills = 0; /* lint suppression */
  51.          break;
  52.      }
  53.  
  54.      while (skills && skills->skill != P_NONE) {
  55.          if (skills->skill == this_skill)
  56.              return FALSE;
  57.          ++skills;
  58.      }
  59.      return TRUE;
  60.  }
  61.  

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 || otyp == nocreate
  39.                     || otyp == nocreate2 || otyp == nocreate3
  40.                     || otyp == nocreate4 || otyp == RIN_LEVITATION
  41.                     /* 'useless' items */
  42.                     || otyp == POT_HALLUCINATION
  43.                     || otyp == POT_ACID
  44.                     || otyp == SCR_AMNESIA
  45.                     || otyp == SCR_FIRE
  46.                     || otyp == SCR_BLANK_PAPER
  47.                     || otyp == SPE_BLANK_PAPER
  48.                     || otyp == RIN_AGGRAVATE_MONSTER
  49.                     || otyp == RIN_HUNGER
  50.                     || otyp == WAN_NOTHING
  51.                     /* Monks don't use weapons */
  52.                     || (otyp == SCR_ENCHANT_WEAPON && Role_if(PM_MONK))
  53.                     /* wizard patch -- they already have one */
  54.                     || (otyp == SPE_FORCE_BOLT && Role_if(PM_WIZARD))
  55.                     /* powerful spells are either useless to
  56.                        low level players or unbalancing; also
  57.                        spells in restricted skill categories */
  58.                     || (obj->oclass == SPBOOK_CLASS
  59.                         && (objects[otyp].oc_level > 3
  60.                             || restricted_spell_discipline(otyp)))) {
  61.                  dealloc_obj(obj);
  62.                  obj = mkobj(trop->trclass, FALSE);
  63.                  otyp = obj->otyp;
  64.              }
  65.  
  66.              /* Don't start with +0 or negative rings */
  67.              if (objects[otyp].oc_charged && obj->spe <= 0)
  68.                  obj->spe = rne(3);
  69.  
  70.              /* Heavily relies on the fact that 1) we create wands
  71.               * before rings, 2) that we create rings before
  72.               * spellbooks, and that 3) not more than 1 object of a
  73.               * particular symbol is to be prohibited.  (For more
  74.               * objects, we need more nocreate variables...)
  75.               */
  76.              switch (otyp) {
  77.              case WAN_POLYMORPH:
  78.              case RIN_POLYMORPH:
  79.              case POT_POLYMORPH:
  80.                  nocreate = RIN_POLYMORPH_CONTROL;
  81.                  break;
  82.              case RIN_POLYMORPH_CONTROL:
  83.                  nocreate = RIN_POLYMORPH;
  84.                  nocreate2 = SPE_POLYMORPH;
  85.                  nocreate3 = POT_POLYMORPH;
  86.              }
  87.              /* Don't have 2 of the same ring or spellbook */
  88.              if (obj->oclass == RING_CLASS || obj->oclass == SPBOOK_CLASS)
  89.                  nocreate4 = otyp;
  90.          }
  91.  
  92.          /* nudist gets no armor */
  93.          if (u.uroleplay.nudist && obj->oclass == ARMOR_CLASS) {
  94.              dealloc_obj(obj);
  95.              trop++;
  96.              continue;
  97.          }
  98.  
  99.          if (trop->trclass == COIN_CLASS) {
  100.              /* no "blessed" or "identified" money */
  101.              obj->quan = u.umoney0;
  102.          } else {
  103.              if (objects[otyp].oc_uses_known)
  104.                  obj->known = 1;
  105.              obj->dknown = obj->bknown = obj->rknown = 1;
  106.              if (Is_container(obj) || obj->otyp == STATUE) {
  107.                  obj->cknown = obj->lknown = 1;
  108.                  obj->otrapped = 0;
  109.              }
  110.              obj->cursed = 0;
  111.              if (obj->opoisoned && u.ualign.type != A_CHAOTIC)
  112.                  obj->opoisoned = 0;
  113.              if (obj->oclass == WEAPON_CLASS || obj->oclass == TOOL_CLASS) {
  114.                  obj->quan = (long) trop->trquan;
  115.                  trop->trquan = 1;
  116.              } else if (obj->oclass == GEM_CLASS && is_graystone(obj)
  117.                         && 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.          }
  125.          /* defined after setting otyp+quan + blessedness */
  126.          obj->owt = weight(obj);
  127.          obj = addinv(obj);
  128.  
  129.          /* Make the type known if necessary */
  130.          if (OBJ_DESCR(objects[otyp]) && obj->known)
  131.              discover_object(otyp, TRUE, FALSE);
  132.          if (otyp == OIL_LAMP)
  133.              discover_object(POT_OIL, TRUE, FALSE);
  134.  
  135.          if (obj->oclass == ARMOR_CLASS) {
  136.              if (is_shield(obj) && !uarms) {
  137.                  setworn(obj, W_ARMS);
  138.                  if (uswapwep)
  139.                      setuswapwep((struct obj *) 0);
  140.              } else if (is_helmet(obj) && !uarmh)
  141.                  setworn(obj, W_ARMH);
  142.              else if (is_gloves(obj) && !uarmg)
  143.                  setworn(obj, W_ARMG);
  144.              else if (is_shirt(obj) && !uarmu)
  145.                  setworn(obj, W_ARMU);
  146.              else if (is_cloak(obj) && !uarmc)
  147.                  setworn(obj, W_ARMC);
  148.              else if (is_boots(obj) && !uarmf)
  149.                  setworn(obj, W_ARMF);
  150.              else if (is_suit(obj) && !uarm)
  151.                  setworn(obj, W_ARM);
  152.          }
  153.  
  154.          if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
  155.              || otyp == TIN_OPENER || otyp == FLINT || otyp == ROCK) {
  156.              if (is_ammo(obj) || is_missile(obj)) {
  157.                  if (!uquiver)
  158.                      setuqwep(obj);
  159.              } else if (!uwep)
  160.                  setuwep(obj);
  161.              else if (!uswapwep)
  162.                  setuswapwep(obj);
  163.          }
  164.          if (obj->oclass == SPBOOK_CLASS && obj->otyp != SPE_BLANK_PAPER)
  165.              initialspell(obj);
  166.  
  167.  #if !defined(PYRAMID_BUG) && !defined(MAC)
  168.          if (--trop->trquan)
  169.              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*/