Source:NetHack 3.6.1/src/u init.c

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

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

Top of file

  1.  /* NetHack 3.6	u_init.c	$NHDT-Date: 1503960969 2017/08/28 22:56:09 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.40 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /*-Copyright (c) Robert Patrick Rankin, 2017. */
  4.  /* 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.  
  2.  #include "hack.h"
  3.  
  4.  struct trobj {
  5.      short trotyp;
  6.      schar trspe;
  7.      char trclass;
  8.      Bitfield(trquan, 6);
  9.      Bitfield(trbless, 2);
  10.  };
  11.  
  12.  STATIC_DCL void FDECL(ini_inv, (struct trobj *));
  13.  STATIC_DCL void FDECL(knows_object, (int));
  14.  STATIC_DCL void FDECL(knows_class, (CHAR_P));
  15.  STATIC_DCL boolean FDECL(restricted_spell_discipline, (int));
  16.  
  17.  #define UNDEF_TYP 0
  18.  #define UNDEF_SPE '\177'
  19.  #define UNDEF_BLESS 2
  20.  
  21.  /*
  22.   *      Initial inventory for the various roles.
  23.   */
  24.  
  25.  static struct trobj Archeologist[] = {
  26.      /* if adventure has a name...  idea from tan@uvm-gen */
  27.      { BULLWHIP, 2, WEAPON_CLASS, 1, UNDEF_BLESS },
  28.      { LEATHER_JACKET, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  29.      { FEDORA, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  30.      { FOOD_RATION, 0, FOOD_CLASS, 3, 0 },
  31.      { PICK_AXE, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS },
  32.      { TINNING_KIT, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS },
  33.      { TOUCHSTONE, 0, GEM_CLASS, 1, 0 },
  34.      { SACK, 0, TOOL_CLASS, 1, 0 },
  35.      { 0, 0, 0, 0, 0 }
  36.  };
  37.  static struct trobj Barbarian[] = {
  38.  #define B_MAJOR 0 /* two-handed sword or battle-axe  */
  39.  #define B_MINOR 1 /* matched with axe or short sword */
  40.      { TWO_HANDED_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  41.      { AXE, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  42.      { RING_MAIL, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  43.      { FOOD_RATION, 0, FOOD_CLASS, 1, 0 },
  44.      { 0, 0, 0, 0, 0 }
  45.  };
  46.  static struct trobj Cave_man[] = {
  47.  #define C_AMMO 2
  48.      { CLUB, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  49.      { SLING, 2, WEAPON_CLASS, 1, UNDEF_BLESS },
  50.      { FLINT, 0, GEM_CLASS, 15, UNDEF_BLESS }, /* quan is variable */
  51.      { ROCK, 0, GEM_CLASS, 3, 0 },             /* yields 18..33 */
  52.      { LEATHER_ARMOR, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  53.      { 0, 0, 0, 0, 0 }
  54.  };
  55.  static struct trobj Healer[] = {
  56.      { SCALPEL, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  57.      { LEATHER_GLOVES, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  58.      { STETHOSCOPE, 0, TOOL_CLASS, 1, 0 },
  59.      { POT_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS },
  60.      { POT_EXTRA_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS },
  61.      { WAN_SLEEP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS },
  62.      /* always blessed, so it's guaranteed readable */
  63.      { SPE_HEALING, 0, SPBOOK_CLASS, 1, 1 },
  64.      { SPE_EXTRA_HEALING, 0, SPBOOK_CLASS, 1, 1 },
  65.      { SPE_STONE_TO_FLESH, 0, SPBOOK_CLASS, 1, 1 },
  66.      { APPLE, 0, FOOD_CLASS, 5, 0 },
  67.      { 0, 0, 0, 0, 0 }
  68.  };
  69.  static struct trobj Knight[] = {
  70.      { LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  71.      { LANCE, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  72.      { RING_MAIL, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  73.      { HELMET, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  74.      { SMALL_SHIELD, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  75.      { LEATHER_GLOVES, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  76.      { APPLE, 0, FOOD_CLASS, 10, 0 },
  77.      { CARROT, 0, FOOD_CLASS, 10, 0 },
  78.      { 0, 0, 0, 0, 0 }
  79.  };
  80.  static struct trobj Monk[] = {
  81.  #define M_BOOK 2
  82.      { LEATHER_GLOVES, 2, ARMOR_CLASS, 1, UNDEF_BLESS },
  83.      { ROBE, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  84.      { UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, 1 },
  85.      { UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 1, UNDEF_BLESS },
  86.      { POT_HEALING, 0, POTION_CLASS, 3, UNDEF_BLESS },
  87.      { FOOD_RATION, 0, FOOD_CLASS, 3, 0 },
  88.      { APPLE, 0, FOOD_CLASS, 5, UNDEF_BLESS },
  89.      { ORANGE, 0, FOOD_CLASS, 5, UNDEF_BLESS },
  90.      /* Yes, we know fortune cookies aren't really from China.  They were
  91.       * invented by George Jung in Los Angeles, California, USA in 1916.
  92.       */
  93.      { FORTUNE_COOKIE, 0, FOOD_CLASS, 3, UNDEF_BLESS },
  94.      { 0, 0, 0, 0, 0 }
  95.  };
  96.  static struct trobj Priest[] = {
  97.      { MACE, 1, WEAPON_CLASS, 1, 1 },
  98.      { ROBE, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  99.      { SMALL_SHIELD, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  100.      { POT_WATER, 0, POTION_CLASS, 4, 1 }, /* holy water */
  101.      { CLOVE_OF_GARLIC, 0, FOOD_CLASS, 1, 0 },
  102.      { SPRIG_OF_WOLFSBANE, 0, FOOD_CLASS, 1, 0 },
  103.      { UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 2, UNDEF_BLESS },
  104.      { 0, 0, 0, 0, 0 }
  105.  };
  106.  static struct trobj Ranger[] = {
  107.  #define RAN_BOW 1
  108.  #define RAN_TWO_ARROWS 2
  109.  #define RAN_ZERO_ARROWS 3
  110.      { DAGGER, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  111.      { BOW, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  112.      { ARROW, 2, WEAPON_CLASS, 50, UNDEF_BLESS },
  113.      { ARROW, 0, WEAPON_CLASS, 30, UNDEF_BLESS },
  114.      { CLOAK_OF_DISPLACEMENT, 2, ARMOR_CLASS, 1, UNDEF_BLESS },
  115.      { CRAM_RATION, 0, FOOD_CLASS, 4, 0 },
  116.      { 0, 0, 0, 0, 0 }
  117.  };
  118.  static struct trobj Rogue[] = {
  119.  #define R_DAGGERS 1
  120.      { SHORT_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  121.      { DAGGER, 0, WEAPON_CLASS, 10, 0 }, /* quan is variable */
  122.      { LEATHER_ARMOR, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
  123.      { POT_SICKNESS, 0, POTION_CLASS, 1, 0 },
  124.      { LOCK_PICK, 0, TOOL_CLASS, 1, 0 },
  125.      { SACK, 0, TOOL_CLASS, 1, 0 },
  126.      { 0, 0, 0, 0, 0 }
  127.  };
  128.  static struct trobj Samurai[] = {
  129.  #define S_ARROWS 3
  130.      { KATANA, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  131.      { SHORT_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, /* wakizashi */
  132.      { YUMI, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  133.      { YA, 0, WEAPON_CLASS, 25, UNDEF_BLESS }, /* variable quan */
  134.      { SPLINT_MAIL, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  135.      { 0, 0, 0, 0, 0 }
  136.  };
  137.  static struct trobj Tourist[] = {
  138.  #define T_DARTS 0
  139.      { DART, 2, WEAPON_CLASS, 25, UNDEF_BLESS }, /* quan is variable */
  140.      { UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 10, 0 },
  141.      { POT_EXTRA_HEALING, 0, POTION_CLASS, 2, UNDEF_BLESS },
  142.      { SCR_MAGIC_MAPPING, 0, SCROLL_CLASS, 4, UNDEF_BLESS },
  143.      { HAWAIIAN_SHIRT, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  144.      { EXPENSIVE_CAMERA, UNDEF_SPE, TOOL_CLASS, 1, 0 },
  145.      { CREDIT_CARD, 0, TOOL_CLASS, 1, 0 },
  146.      { 0, 0, 0, 0, 0 }
  147.  };
  148.  static struct trobj Valkyrie[] = {
  149.      { LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
  150.      { DAGGER, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
  151.      { SMALL_SHIELD, 3, ARMOR_CLASS, 1, UNDEF_BLESS },
  152.      { FOOD_RATION, 0, FOOD_CLASS, 1, 0 },
  153.      { 0, 0, 0, 0, 0 }
  154.  };
  155.  static struct trobj Wizard[] = {
  156.  #define W_MULTSTART 2
  157.  #define W_MULTEND 6
  158.      { QUARTERSTAFF, 1, WEAPON_CLASS, 1, 1 },
  159.      { CLOAK_OF_MAGIC_RESISTANCE, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
  160.      { UNDEF_TYP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS },
  161.      { UNDEF_TYP, UNDEF_SPE, RING_CLASS, 2, UNDEF_BLESS },
  162.      { UNDEF_TYP, UNDEF_SPE, POTION_CLASS, 3, UNDEF_BLESS },
  163.      { UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 3, UNDEF_BLESS },
  164.      { SPE_FORCE_BOLT, 0, SPBOOK_CLASS, 1, 1 },
  165.      { UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, UNDEF_BLESS },
  166.      { 0, 0, 0, 0, 0 }
  167.  };
  168.  
  169.  /*
  170.   *      Optional extra inventory items.
  171.   */
  172.  
  173.  static struct trobj Tinopener[] = { { TIN_OPENER, 0, TOOL_CLASS, 1, 0 },
  174.                                      { 0, 0, 0, 0, 0 } };
  175.  static struct trobj Magicmarker[] = { { MAGIC_MARKER, UNDEF_SPE, TOOL_CLASS,
  176.                                          1, 0 },
  177.                                        { 0, 0, 0, 0, 0 } };
  178.  static struct trobj Lamp[] = { { OIL_LAMP, 1, TOOL_CLASS, 1, 0 },
  179.                                 { 0, 0, 0, 0, 0 } };
  180.  static struct trobj Blindfold[] = { { BLINDFOLD, 0, TOOL_CLASS, 1, 0 },
  181.                                      { 0, 0, 0, 0, 0 } };
  182.  static struct trobj Instrument[] = { { WOODEN_FLUTE, 0, TOOL_CLASS, 1, 0 },
  183.                                       { 0, 0, 0, 0, 0 } };
  184.  static struct trobj Xtra_food[] = { { UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 2, 0 },
  185.                                      { 0, 0, 0, 0, 0 } };
  186.  static struct trobj Leash[] = { { LEASH, 0, TOOL_CLASS, 1, 0 },
  187.                                  { 0, 0, 0, 0, 0 } };
  188.  static struct trobj Towel[] = { { TOWEL, 0, TOOL_CLASS, 1, 0 },
  189.                                  { 0, 0, 0, 0, 0 } };
  190.  static struct trobj Wishing[] = { { WAN_WISHING, 3, WAND_CLASS, 1, 0 },
  191.                                    { 0, 0, 0, 0, 0 } };
  192.  static struct trobj Money[] = { { GOLD_PIECE, 0, COIN_CLASS, 1, 0 },
  193.                                  { 0, 0, 0, 0, 0 } };
  194.  
  195.  /* race-based substitutions for initial inventory;
  196.     the weaker cloak for elven rangers is intentional--they shoot better */
  197.  static struct inv_sub {
  198.      short race_pm, item_otyp, subs_otyp;
  199.  } inv_subs[] = {
  200.      { PM_ELF, DAGGER, ELVEN_DAGGER },
  201.      { PM_ELF, SPEAR, ELVEN_SPEAR },
  202.      { PM_ELF, SHORT_SWORD, ELVEN_SHORT_SWORD },
  203.      { PM_ELF, BOW, ELVEN_BOW },
  204.      { PM_ELF, ARROW, ELVEN_ARROW },
  205.      { PM_ELF, HELMET, ELVEN_LEATHER_HELM },
  206.      /* { PM_ELF, SMALL_SHIELD, ELVEN_SHIELD }, */
  207.      { PM_ELF, CLOAK_OF_DISPLACEMENT, ELVEN_CLOAK },
  208.      { PM_ELF, CRAM_RATION, LEMBAS_WAFER },
  209.      { PM_ORC, DAGGER, ORCISH_DAGGER },
  210.      { PM_ORC, SPEAR, ORCISH_SPEAR },
  211.      { PM_ORC, SHORT_SWORD, ORCISH_SHORT_SWORD },
  212.      { PM_ORC, BOW, ORCISH_BOW },
  213.      { PM_ORC, ARROW, ORCISH_ARROW },
  214.      { PM_ORC, HELMET, ORCISH_HELM },
  215.      { PM_ORC, SMALL_SHIELD, ORCISH_SHIELD },
  216.      { PM_ORC, RING_MAIL, ORCISH_RING_MAIL },
  217.      { PM_ORC, CHAIN_MAIL, ORCISH_CHAIN_MAIL },
  218.      { PM_DWARF, SPEAR, DWARVISH_SPEAR },
  219.      { PM_DWARF, SHORT_SWORD, DWARVISH_SHORT_SWORD },
  220.      { PM_DWARF, HELMET, DWARVISH_IRON_HELM },
  221.      /* { PM_DWARF, SMALL_SHIELD, DWARVISH_ROUNDSHIELD }, */
  222.      /* { PM_DWARF, PICK_AXE, DWARVISH_MATTOCK }, */
  223.      { PM_GNOME, BOW, CROSSBOW },
  224.      { PM_GNOME, ARROW, CROSSBOW_BOLT },
  225.      { NON_PM, STRANGE_OBJECT, STRANGE_OBJECT }
  226.  };
  227.  
  228.  static const struct def_skill Skill_A[] = {
  229.      { P_DAGGER, P_BASIC },
  230.      { P_KNIFE, P_BASIC },
  231.      { P_PICK_AXE, P_EXPERT },
  232.      { P_SHORT_SWORD, P_BASIC },
  233.      { P_SCIMITAR, P_SKILLED },
  234.      { P_SABER, P_EXPERT },
  235.      { P_CLUB, P_SKILLED },
  236.      { P_QUARTERSTAFF, P_SKILLED },
  237.      { P_SLING, P_SKILLED },
  238.      { P_DART, P_BASIC },
  239.      { P_BOOMERANG, P_EXPERT },
  240.      { P_WHIP, P_EXPERT },
  241.      { P_UNICORN_HORN, P_SKILLED },
  242.      { P_ATTACK_SPELL, P_BASIC },
  243.      { P_HEALING_SPELL, P_BASIC },
  244.      { P_DIVINATION_SPELL, P_EXPERT },
  245.      { P_MATTER_SPELL, P_BASIC },
  246.      { P_RIDING, P_BASIC },
  247.      { P_TWO_WEAPON_COMBAT, P_BASIC },
  248.      { P_BARE_HANDED_COMBAT, P_EXPERT },
  249.      { P_NONE, 0 }
  250.  };
  251.  static const struct def_skill Skill_B[] = {
  252.      { P_DAGGER, P_BASIC },
  253.      { P_AXE, P_EXPERT },
  254.      { P_PICK_AXE, P_SKILLED },
  255.      { P_SHORT_SWORD, P_EXPERT },
  256.      { P_BROAD_SWORD, P_SKILLED },
  257.      { P_LONG_SWORD, P_SKILLED },
  258.      { P_TWO_HANDED_SWORD, P_EXPERT },
  259.      { P_SCIMITAR, P_SKILLED },
  260.      { P_SABER, P_BASIC },
  261.      { P_CLUB, P_SKILLED },
  262.      { P_MACE, P_SKILLED },
  263.      { P_MORNING_STAR, P_SKILLED },
  264.      { P_FLAIL, P_BASIC },
  265.      { P_HAMMER, P_EXPERT },
  266.      { P_QUARTERSTAFF, P_BASIC },
  267.      { P_SPEAR, P_SKILLED },
  268.      { P_TRIDENT, P_SKILLED },
  269.      { P_BOW, P_BASIC },
  270.      { P_ATTACK_SPELL, P_BASIC },
  271.      { P_ESCAPE_SPELL, P_BASIC }, /* special spell is haste self */
  272.      { P_RIDING, P_BASIC },
  273.      { P_TWO_WEAPON_COMBAT, P_BASIC },
  274.      { P_BARE_HANDED_COMBAT, P_MASTER },
  275.      { P_NONE, 0 }
  276.  };
  277.  static const struct def_skill Skill_C[] = {
  278.      { P_DAGGER, P_BASIC },
  279.      { P_KNIFE, P_SKILLED },
  280.      { P_AXE, P_SKILLED },
  281.      { P_PICK_AXE, P_BASIC },
  282.      { P_CLUB, P_EXPERT },
  283.      { P_MACE, P_EXPERT },
  284.      { P_MORNING_STAR, P_BASIC },
  285.      { P_FLAIL, P_SKILLED },
  286.      { P_HAMMER, P_SKILLED },
  287.      { P_QUARTERSTAFF, P_EXPERT },
  288.      { P_POLEARMS, P_SKILLED },
  289.      { P_SPEAR, P_EXPERT },
  290.      { P_TRIDENT, P_SKILLED },
  291.      { P_BOW, P_SKILLED },
  292.      { P_SLING, P_EXPERT },
  293.      { P_ATTACK_SPELL, P_BASIC },
  294.      { P_MATTER_SPELL, P_SKILLED },
  295.      { P_BOOMERANG, P_EXPERT },
  296.      { P_UNICORN_HORN, P_BASIC },
  297.      { P_BARE_HANDED_COMBAT, P_MASTER },
  298.      { P_NONE, 0 }
  299.  };
  300.  static const struct def_skill Skill_H[] = {
  301.      { P_DAGGER, P_SKILLED },
  302.      { P_KNIFE, P_EXPERT },
  303.      { P_SHORT_SWORD, P_SKILLED },
  304.      { P_SCIMITAR, P_BASIC },
  305.      { P_SABER, P_BASIC },
  306.      { P_CLUB, P_SKILLED },
  307.      { P_MACE, P_BASIC },
  308.      { P_QUARTERSTAFF, P_EXPERT },
  309.      { P_POLEARMS, P_BASIC },
  310.      { P_SPEAR, P_BASIC },
  311.      { P_TRIDENT, P_BASIC },
  312.      { P_SLING, P_SKILLED },
  313.      { P_DART, P_EXPERT },
  314.      { P_SHURIKEN, P_SKILLED },
  315.      { P_UNICORN_HORN, P_EXPERT },
  316.      { P_HEALING_SPELL, P_EXPERT },
  317.      { P_BARE_HANDED_COMBAT, P_BASIC },
  318.      { P_NONE, 0 }
  319.  };
  320.  static const struct def_skill Skill_K[] = {
  321.      { P_DAGGER, P_BASIC },
  322.      { P_KNIFE, P_BASIC },
  323.      { P_AXE, P_SKILLED },
  324.      { P_PICK_AXE, P_BASIC },
  325.      { P_SHORT_SWORD, P_SKILLED },
  326.      { P_BROAD_SWORD, P_SKILLED },
  327.      { P_LONG_SWORD, P_EXPERT },
  328.      { P_TWO_HANDED_SWORD, P_SKILLED },
  329.      { P_SCIMITAR, P_BASIC },
  330.      { P_SABER, P_SKILLED },
  331.      { P_CLUB, P_BASIC },
  332.      { P_MACE, P_SKILLED },
  333.      { P_MORNING_STAR, P_SKILLED },
  334.      { P_FLAIL, P_BASIC },
  335.      { P_HAMMER, P_BASIC },
  336.      { P_POLEARMS, P_SKILLED },
  337.      { P_SPEAR, P_SKILLED },
  338.      { P_TRIDENT, P_BASIC },
  339.      { P_LANCE, P_EXPERT },
  340.      { P_BOW, P_BASIC },
  341.      { P_CROSSBOW, P_SKILLED },
  342.      { P_ATTACK_SPELL, P_SKILLED },
  343.      { P_HEALING_SPELL, P_SKILLED },
  344.      { P_CLERIC_SPELL, P_SKILLED },
  345.      { P_RIDING, P_EXPERT },
  346.      { P_TWO_WEAPON_COMBAT, P_SKILLED },
  347.      { P_BARE_HANDED_COMBAT, P_EXPERT },
  348.      { P_NONE, 0 }
  349.  };
  350.  static const struct def_skill Skill_Mon[] = {
  351.      { P_QUARTERSTAFF, P_BASIC },
  352.      { P_SPEAR, P_BASIC },
  353.      { P_CROSSBOW, P_BASIC },
  354.      { P_SHURIKEN, P_BASIC },
  355.      { P_ATTACK_SPELL, P_BASIC },
  356.      { P_HEALING_SPELL, P_EXPERT },
  357.      { P_DIVINATION_SPELL, P_BASIC },
  358.      { P_ENCHANTMENT_SPELL, P_BASIC },
  359.      { P_CLERIC_SPELL, P_SKILLED },
  360.      { P_ESCAPE_SPELL, P_SKILLED },
  361.      { P_MATTER_SPELL, P_BASIC },
  362.      { P_MARTIAL_ARTS, P_GRAND_MASTER },
  363.      { P_NONE, 0 }
  364.  };
  365.  static const struct def_skill Skill_P[] = {
  366.      { P_CLUB, P_EXPERT },
  367.      { P_MACE, P_EXPERT },
  368.      { P_MORNING_STAR, P_EXPERT },
  369.      { P_FLAIL, P_EXPERT },
  370.      { P_HAMMER, P_EXPERT },
  371.      { P_QUARTERSTAFF, P_EXPERT },
  372.      { P_POLEARMS, P_SKILLED },
  373.      { P_SPEAR, P_SKILLED },
  374.      { P_TRIDENT, P_SKILLED },
  375.      { P_LANCE, P_BASIC },
  376.      { P_BOW, P_BASIC },
  377.      { P_SLING, P_BASIC },
  378.      { P_CROSSBOW, P_BASIC },
  379.      { P_DART, P_BASIC },
  380.      { P_SHURIKEN, P_BASIC },
  381.      { P_BOOMERANG, P_BASIC },
  382.      { P_UNICORN_HORN, P_SKILLED },
  383.      { P_HEALING_SPELL, P_EXPERT },
  384.      { P_DIVINATION_SPELL, P_EXPERT },
  385.      { P_CLERIC_SPELL, P_EXPERT },
  386.      { P_BARE_HANDED_COMBAT, P_BASIC },
  387.      { P_NONE, 0 }
  388.  };
  389.  static const struct def_skill Skill_R[] = {
  390.      { P_DAGGER, P_EXPERT },
  391.      { P_KNIFE, P_EXPERT },
  392.      { P_SHORT_SWORD, P_EXPERT },
  393.      { P_BROAD_SWORD, P_SKILLED },
  394.      { P_LONG_SWORD, P_SKILLED },
  395.      { P_TWO_HANDED_SWORD, P_BASIC },
  396.      { P_SCIMITAR, P_SKILLED },
  397.      { P_SABER, P_SKILLED },
  398.      { P_CLUB, P_SKILLED },
  399.      { P_MACE, P_SKILLED },
  400.      { P_MORNING_STAR, P_BASIC },
  401.      { P_FLAIL, P_BASIC },
  402.      { P_HAMMER, P_BASIC },
  403.      { P_POLEARMS, P_BASIC },
  404.      { P_SPEAR, P_BASIC },
  405.      { P_CROSSBOW, P_EXPERT },
  406.      { P_DART, P_EXPERT },
  407.      { P_SHURIKEN, P_SKILLED },
  408.      { P_DIVINATION_SPELL, P_SKILLED },
  409.      { P_ESCAPE_SPELL, P_SKILLED },
  410.      { P_MATTER_SPELL, P_SKILLED },
  411.      { P_RIDING, P_BASIC },
  412.      { P_TWO_WEAPON_COMBAT, P_EXPERT },
  413.      { P_BARE_HANDED_COMBAT, P_EXPERT },
  414.      { P_NONE, 0 }
  415.  };
  416.  static const struct def_skill Skill_Ran[] = {
  417.      { P_DAGGER, P_EXPERT },
  418.      { P_KNIFE, P_SKILLED },
  419.      { P_AXE, P_SKILLED },
  420.      { P_PICK_AXE, P_BASIC },
  421.      { P_SHORT_SWORD, P_BASIC },
  422.      { P_MORNING_STAR, P_BASIC },
  423.      { P_FLAIL, P_SKILLED },
  424.      { P_HAMMER, P_BASIC },
  425.      { P_QUARTERSTAFF, P_BASIC },
  426.      { P_POLEARMS, P_SKILLED },
  427.      { P_SPEAR, P_EXPERT },
  428.      { P_TRIDENT, P_BASIC },
  429.      { P_BOW, P_EXPERT },
  430.      { P_SLING, P_EXPERT },
  431.      { P_CROSSBOW, P_EXPERT },
  432.      { P_DART, P_EXPERT },
  433.      { P_SHURIKEN, P_SKILLED },
  434.      { P_BOOMERANG, P_EXPERT },
  435.      { P_WHIP, P_BASIC },
  436.      { P_HEALING_SPELL, P_BASIC },
  437.      { P_DIVINATION_SPELL, P_EXPERT },
  438.      { P_ESCAPE_SPELL, P_BASIC },
  439.      { P_RIDING, P_BASIC },
  440.      { P_BARE_HANDED_COMBAT, P_BASIC },
  441.      { P_NONE, 0 }
  442.  };
  443.  static const struct def_skill Skill_S[] = {
  444.      { P_DAGGER, P_BASIC },
  445.      { P_KNIFE, P_SKILLED },
  446.      { P_SHORT_SWORD, P_EXPERT },
  447.      { P_BROAD_SWORD, P_SKILLED },
  448.      { P_LONG_SWORD, P_EXPERT },
  449.      { P_TWO_HANDED_SWORD, P_EXPERT },
  450.      { P_SCIMITAR, P_BASIC },
  451.      { P_SABER, P_BASIC },
  452.      { P_FLAIL, P_SKILLED },
  453.      { P_QUARTERSTAFF, P_BASIC },
  454.      { P_POLEARMS, P_SKILLED },
  455.      { P_SPEAR, P_SKILLED },
  456.      { P_LANCE, P_SKILLED },
  457.      { P_BOW, P_EXPERT },
  458.      { P_SHURIKEN, P_EXPERT },
  459.      { P_ATTACK_SPELL, P_BASIC },
  460.      { P_DIVINATION_SPELL, P_BASIC }, /* special spell is clairvoyance */
  461.      { P_CLERIC_SPELL, P_SKILLED },
  462.      { P_RIDING, P_SKILLED },
  463.      { P_TWO_WEAPON_COMBAT, P_EXPERT },
  464.      { P_MARTIAL_ARTS, P_MASTER },
  465.      { P_NONE, 0 }
  466.  };
  467.  static const struct def_skill Skill_T[] = {
  468.      { P_DAGGER, P_EXPERT },
  469.      { P_KNIFE, P_SKILLED },
  470.      { P_AXE, P_BASIC },
  471.      { P_PICK_AXE, P_BASIC },
  472.      { P_SHORT_SWORD, P_EXPERT },
  473.      { P_BROAD_SWORD, P_BASIC },
  474.      { P_LONG_SWORD, P_BASIC },
  475.      { P_TWO_HANDED_SWORD, P_BASIC },
  476.      { P_SCIMITAR, P_SKILLED },
  477.      { P_SABER, P_SKILLED },
  478.      { P_MACE, P_BASIC },
  479.      { P_MORNING_STAR, P_BASIC },
  480.      { P_FLAIL, P_BASIC },
  481.      { P_HAMMER, P_BASIC },
  482.      { P_QUARTERSTAFF, P_BASIC },
  483.      { P_POLEARMS, P_BASIC },
  484.      { P_SPEAR, P_BASIC },
  485.      { P_TRIDENT, P_BASIC },
  486.      { P_LANCE, P_BASIC },
  487.      { P_BOW, P_BASIC },
  488.      { P_SLING, P_BASIC },
  489.      { P_CROSSBOW, P_BASIC },
  490.      { P_DART, P_EXPERT },
  491.      { P_SHURIKEN, P_BASIC },
  492.      { P_BOOMERANG, P_BASIC },
  493.      { P_WHIP, P_BASIC },
  494.      { P_UNICORN_HORN, P_SKILLED },
  495.      { P_DIVINATION_SPELL, P_BASIC },
  496.      { P_ENCHANTMENT_SPELL, P_BASIC },
  497.      { P_ESCAPE_SPELL, P_SKILLED },
  498.      { P_RIDING, P_BASIC },
  499.      { P_TWO_WEAPON_COMBAT, P_SKILLED },
  500.      { P_BARE_HANDED_COMBAT, P_SKILLED },
  501.      { P_NONE, 0 }
  502.  };
  503.  static const struct def_skill Skill_V[] = {
  504.      { P_DAGGER, P_EXPERT },
  505.      { P_AXE, P_EXPERT },
  506.      { P_PICK_AXE, P_SKILLED },
  507.      { P_SHORT_SWORD, P_SKILLED },
  508.      { P_BROAD_SWORD, P_SKILLED },
  509.      { P_LONG_SWORD, P_EXPERT },
  510.      { P_TWO_HANDED_SWORD, P_EXPERT },
  511.      { P_SCIMITAR, P_BASIC },
  512.      { P_SABER, P_BASIC },
  513.      { P_HAMMER, P_EXPERT },
  514.      { P_QUARTERSTAFF, P_BASIC },
  515.      { P_POLEARMS, P_SKILLED },
  516.      { P_SPEAR, P_SKILLED },
  517.      { P_TRIDENT, P_BASIC },
  518.      { P_LANCE, P_SKILLED },
  519.      { P_SLING, P_BASIC },
  520.      { P_ATTACK_SPELL, P_BASIC },
  521.      { P_ESCAPE_SPELL, P_BASIC },
  522.      { P_RIDING, P_SKILLED },
  523.      { P_TWO_WEAPON_COMBAT, P_SKILLED },
  524.      { P_BARE_HANDED_COMBAT, P_EXPERT },
  525.      { P_NONE, 0 }
  526.  };
  527.  static const struct def_skill Skill_W[] = {
  528.      { P_DAGGER, P_EXPERT },
  529.      { P_KNIFE, P_SKILLED },
  530.      { P_AXE, P_SKILLED },
  531.      { P_SHORT_SWORD, P_BASIC },
  532.      { P_CLUB, P_SKILLED },
  533.      { P_MACE, P_BASIC },
  534.      { P_QUARTERSTAFF, P_EXPERT },
  535.      { P_POLEARMS, P_SKILLED },
  536.      { P_SPEAR, P_BASIC },
  537.      { P_TRIDENT, P_BASIC },
  538.      { P_SLING, P_SKILLED },
  539.      { P_DART, P_EXPERT },
  540.      { P_SHURIKEN, P_BASIC },
  541.      { P_ATTACK_SPELL, P_EXPERT },
  542.      { P_HEALING_SPELL, P_SKILLED },
  543.      { P_DIVINATION_SPELL, P_EXPERT },
  544.      { P_ENCHANTMENT_SPELL, P_SKILLED },
  545.      { P_CLERIC_SPELL, P_SKILLED },
  546.      { P_ESCAPE_SPELL, P_EXPERT },
  547.      { P_MATTER_SPELL, P_EXPERT },
  548.      { P_RIDING, P_BASIC },
  549.      { P_BARE_HANDED_COMBAT, P_BASIC },
  550.      { P_NONE, 0 }
  551.  };
  552.  

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.  
  81.      /*** Role-specific initializations ***/
  82.      switch (Role_switch) {
  83.      /* rn2(100) > 50 necessary for some choices because some
  84.       * random number generators are bad enough to seriously
  85.       * skew the results if we use rn2(2)...  --KAA
  86.       */
  87.      case PM_ARCHEOLOGIST:
  88.          ini_inv(Archeologist);
  89.          if (!rn2(10))
  90.              ini_inv(Tinopener);
  91.          else if (!rn2(4))
  92.              ini_inv(Lamp);
  93.          else if (!rn2(10))
  94.              ini_inv(Magicmarker);
  95.          knows_object(SACK);
  96.          knows_object(TOUCHSTONE);
  97.          skill_init(Skill_A);
  98.          break;
  99.      case PM_BARBARIAN:
  100.          if (rn2(100) >= 50) { /* see above comment */
  101.              Barbarian[B_MAJOR].trotyp = BATTLE_AXE;
  102.              Barbarian[B_MINOR].trotyp = SHORT_SWORD;
  103.          }
  104.          ini_inv(Barbarian);
  105.          if (!rn2(6))
  106.              ini_inv(Lamp);
  107.          knows_class(WEAPON_CLASS);
  108.          knows_class(ARMOR_CLASS);
  109.          skill_init(Skill_B);
  110.          break;
  111.      case PM_CAVEMAN:
  112.          Cave_man[C_AMMO].trquan = rn1(11, 10); /* 10..20 */
  113.          ini_inv(Cave_man);
  114.          skill_init(Skill_C);
  115.          break;
  116.      case PM_HEALER:
  117.          u.umoney0 = rn1(1000, 1001);
  118.          ini_inv(Healer);
  119.          if (!rn2(25))
  120.              ini_inv(Lamp);
  121.          knows_object(POT_FULL_HEALING);
  122.          skill_init(Skill_H);
  123.          break;
  124.      case PM_KNIGHT:
  125.          ini_inv(Knight);
  126.          knows_class(WEAPON_CLASS);
  127.          knows_class(ARMOR_CLASS);
  128.          /* give knights chess-like mobility--idea from wooledge@..cwru.edu */
  129.          HJumping |= FROMOUTSIDE;
  130.          skill_init(Skill_K);
  131.          break;
  132.      case PM_MONK: {
  133.          static short M_spell[] = { SPE_HEALING, SPE_PROTECTION, SPE_SLEEP };
  134.  
  135.          Monk[M_BOOK].trotyp = M_spell[rn2(90) / 30]; /* [0..2] */
  136.          ini_inv(Monk);
  137.          if (!rn2(5))
  138.              ini_inv(Magicmarker);
  139.          else if (!rn2(10))
  140.              ini_inv(Lamp);
  141.          knows_class(ARMOR_CLASS);
  142.          /* sufficiently martial-arts oriented item to ignore language issue */
  143.          knows_object(SHURIKEN);
  144.          skill_init(Skill_Mon);
  145.          break;
  146.      }
  147.      case PM_PRIEST:
  148.          ini_inv(Priest);
  149.          if (!rn2(10))
  150.              ini_inv(Magicmarker);
  151.          else if (!rn2(10))
  152.              ini_inv(Lamp);
  153.          knows_object(POT_WATER);
  154.          skill_init(Skill_P);
  155.          /* KMH, conduct --
  156.           * Some may claim that this isn't agnostic, since they
  157.           * are literally "priests" and they have holy water.
  158.           * But we don't count it as such.  Purists can always
  159.           * avoid playing priests and/or confirm another player's
  160.           * role in their YAAP.
  161.           */
  162.          break;
  163.      case PM_RANGER:
  164.          Ranger[RAN_TWO_ARROWS].trquan = rn1(10, 50);
  165.          Ranger[RAN_ZERO_ARROWS].trquan = rn1(10, 30);
  166.          ini_inv(Ranger);
  167.          skill_init(Skill_Ran);
  168.          break;
  169.      case PM_ROGUE:
  170.          Rogue[R_DAGGERS].trquan = rn1(10, 6);
  171.          u.umoney0 = 0;
  172.          ini_inv(Rogue);
  173.          if (!rn2(5))
  174.              ini_inv(Blindfold);
  175.          knows_object(SACK);
  176.          skill_init(Skill_R);
  177.          break;
  178.      case PM_SAMURAI:
  179.          Samurai[S_ARROWS].trquan = rn1(20, 26);
  180.          ini_inv(Samurai);
  181.          if (!rn2(5))
  182.              ini_inv(Blindfold);
  183.          knows_class(WEAPON_CLASS);
  184.          knows_class(ARMOR_CLASS);
  185.          skill_init(Skill_S);
  186.          break;
  187.      case PM_TOURIST:
  188.          Tourist[T_DARTS].trquan = rn1(20, 21);
  189.          u.umoney0 = rnd(1000);
  190.          ini_inv(Tourist);
  191.          if (!rn2(25))
  192.              ini_inv(Tinopener);
  193.          else if (!rn2(25))
  194.              ini_inv(Leash);
  195.          else if (!rn2(25))
  196.              ini_inv(Towel);
  197.          else if (!rn2(25))
  198.              ini_inv(Magicmarker);
  199.          skill_init(Skill_T);
  200.          break;
  201.      case PM_VALKYRIE:
  202.          ini_inv(Valkyrie);
  203.          if (!rn2(6))
  204.              ini_inv(Lamp);
  205.          knows_class(WEAPON_CLASS);
  206.          knows_class(ARMOR_CLASS);
  207.          skill_init(Skill_V);
  208.          break;
  209.      case PM_WIZARD:
  210.          ini_inv(Wizard);
  211.          if (!rn2(5))
  212.              ini_inv(Magicmarker);
  213.          if (!rn2(5))
  214.              ini_inv(Blindfold);
  215.          skill_init(Skill_W);
  216.          break;
  217.  
  218.      default: /* impossible */
  219.          break;
  220.      }
  221.  
  222.      /*** Race-specific initializations ***/
  223.      switch (Race_switch) {
  224.      case PM_HUMAN:
  225.          /* Nothing special */
  226.          break;
  227.  
  228.      case PM_ELF:
  229.          /*
  230.           * Elves are people of music and song, or they are warriors.
  231.           * Non-warriors get an instrument.  We use a kludge to
  232.           * get only non-magic instruments.
  233.           */
  234.          if (Role_if(PM_PRIEST) || Role_if(PM_WIZARD)) {
  235.              static int trotyp[] = { WOODEN_FLUTE, TOOLED_HORN, WOODEN_HARP,
  236.                                      BELL,         BUGLE,       LEATHER_DRUM };
  237.              Instrument[0].trotyp = trotyp[rn2(SIZE(trotyp))];
  238.              ini_inv(Instrument);
  239.          }
  240.  
  241.          /* Elves can recognize all elvish objects */
  242.          knows_object(ELVEN_SHORT_SWORD);
  243.          knows_object(ELVEN_ARROW);
  244.          knows_object(ELVEN_BOW);
  245.          knows_object(ELVEN_SPEAR);
  246.          knows_object(ELVEN_DAGGER);
  247.          knows_object(ELVEN_BROADSWORD);
  248.          knows_object(ELVEN_MITHRIL_COAT);
  249.          knows_object(ELVEN_LEATHER_HELM);
  250.          knows_object(ELVEN_SHIELD);
  251.          knows_object(ELVEN_BOOTS);
  252.          knows_object(ELVEN_CLOAK);
  253.          break;
  254.  
  255.      case PM_DWARF:
  256.          /* Dwarves can recognize all dwarvish objects */
  257.          knows_object(DWARVISH_SPEAR);
  258.          knows_object(DWARVISH_SHORT_SWORD);
  259.          knows_object(DWARVISH_MATTOCK);
  260.          knows_object(DWARVISH_IRON_HELM);
  261.          knows_object(DWARVISH_MITHRIL_COAT);
  262.          knows_object(DWARVISH_CLOAK);
  263.          knows_object(DWARVISH_ROUNDSHIELD);
  264.          break;
  265.  
  266.      case PM_GNOME:
  267.          break;
  268.  
  269.      case PM_ORC:
  270.          /* compensate for generally inferior equipment */
  271.          if (!Role_if(PM_WIZARD))
  272.              ini_inv(Xtra_food);
  273.          /* Orcs can recognize all orcish objects */
  274.          knows_object(ORCISH_SHORT_SWORD);
  275.          knows_object(ORCISH_ARROW);
  276.          knows_object(ORCISH_BOW);
  277.          knows_object(ORCISH_SPEAR);
  278.          knows_object(ORCISH_DAGGER);
  279.          knows_object(ORCISH_CHAIN_MAIL);
  280.          knows_object(ORCISH_RING_MAIL);
  281.          knows_object(ORCISH_HELM);
  282.          knows_object(ORCISH_SHIELD);
  283.          knows_object(URUK_HAI_SHIELD);
  284.          knows_object(ORCISH_CLOAK);
  285.          break;
  286.  
  287.      default: /* impossible */
  288.          break;
  289.      }
  290.  
  291.      if (discover)
  292.          ini_inv(Wishing);
  293.  
  294.      if (wizard)
  295.          read_wizkit();
  296.  
  297.      if (u.umoney0)
  298.          ini_inv(Money);
  299.      u.umoney0 += hidden_gold(); /* in case sack has gold in it */
  300.  
  301.      find_ac();     /* get initial ac value */
  302.      init_attr(75); /* init attribute values */
  303.      max_rank_sz(); /* set max str size for class ranks */
  304.      /*
  305.       *  Do we really need this?
  306.       */
  307.      for (i = 0; i < A_MAX; i++)
  308.          if (!rn2(20)) {
  309.              register int xd = rn2(7) - 2; /* biased variation */
  310.  
  311.              (void) adjattrib(i, xd, TRUE);
  312.              if (ABASE(i) < AMAX(i))
  313.                  AMAX(i) = ABASE(i);
  314.          }
  315.  
  316.      /* make sure you can carry all you have - especially for Tourists */
  317.      while (inv_weight() > 0) {
  318.          if (adjattrib(A_STR, 1, TRUE))
  319.              continue;
  320.          if (adjattrib(A_CON, 1, TRUE))
  321.              continue;
  322.          /* only get here when didn't boost strength or constitution */
  323.          break;
  324.      }
  325.  
  326.      return;
  327.  }
  328.  

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.                     /* orcs start with poison resistance */
  52.                     || (otyp == RIN_POISON_RESISTANCE && Race_if(PM_ORC))
  53.                     /* Monks don't use weapons */
  54.                     || (otyp == SCR_ENCHANT_WEAPON && Role_if(PM_MONK))
  55.                     /* wizard patch -- they already have one */
  56.                     || (otyp == SPE_FORCE_BOLT && Role_if(PM_WIZARD))
  57.                     /* powerful spells are either useless to
  58.                        low level players or unbalancing; also
  59.                        spells in restricted skill categories */
  60.                     || (obj->oclass == SPBOOK_CLASS
  61.                         && (objects[otyp].oc_level > 3
  62.                             || restricted_spell_discipline(otyp)))) {
  63.                  dealloc_obj(obj);
  64.                  obj = mkobj(trop->trclass, FALSE);
  65.                  otyp = obj->otyp;
  66.              }
  67.  
  68.              /* Don't start with +0 or negative rings */
  69.              if (objects[otyp].oc_charged && obj->spe <= 0)
  70.                  obj->spe = rne(3);
  71.  
  72.              /* Heavily relies on the fact that 1) we create wands
  73.               * before rings, 2) that we create rings before
  74.               * spellbooks, and that 3) not more than 1 object of a
  75.               * particular symbol is to be prohibited.  (For more
  76.               * objects, we need more nocreate variables...)
  77.               */
  78.              switch (otyp) {
  79.              case WAN_POLYMORPH:
  80.              case RIN_POLYMORPH:
  81.              case POT_POLYMORPH:
  82.                  nocreate = RIN_POLYMORPH_CONTROL;
  83.                  break;
  84.              case RIN_POLYMORPH_CONTROL:
  85.                  nocreate = RIN_POLYMORPH;
  86.                  nocreate2 = SPE_POLYMORPH;
  87.                  nocreate3 = POT_POLYMORPH;
  88.              }
  89.              /* Don't have 2 of the same ring or spellbook */
  90.              if (obj->oclass == RING_CLASS || obj->oclass == SPBOOK_CLASS)
  91.                  nocreate4 = otyp;
  92.          }
  93.  
  94.          /* nudist gets no armor */
  95.          if (u.uroleplay.nudist && obj->oclass == ARMOR_CLASS) {
  96.              dealloc_obj(obj);
  97.              trop++;
  98.              continue;
  99.          }
  100.  
  101.          if (trop->trclass == COIN_CLASS) {
  102.              /* no "blessed" or "identified" money */
  103.              obj->quan = u.umoney0;
  104.          } else {
  105.              if (objects[otyp].oc_uses_known)
  106.                  obj->known = 1;
  107.              obj->dknown = obj->bknown = obj->rknown = 1;
  108.              if (Is_container(obj) || obj->otyp == STATUE) {
  109.                  obj->cknown = obj->lknown = 1;
  110.                  obj->otrapped = 0;
  111.              }
  112.              obj->cursed = 0;
  113.              if (obj->opoisoned && u.ualign.type != A_CHAOTIC)
  114.                  obj->opoisoned = 0;
  115.              if (obj->oclass == WEAPON_CLASS || obj->oclass == TOOL_CLASS) {
  116.                  obj->quan = (long) trop->trquan;
  117.                  trop->trquan = 1;
  118.              } else if (obj->oclass == GEM_CLASS && is_graystone(obj)
  119.                         && obj->otyp != FLINT) {
  120.                  obj->quan = 1L;
  121.              }
  122.              if (trop->trspe != UNDEF_SPE)
  123.                  obj->spe = trop->trspe;
  124.              if (trop->trbless != UNDEF_BLESS)
  125.                  obj->blessed = trop->trbless;
  126.          }
  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)
  141.                      setuswapwep((struct obj *) 0);
  142.              } else if (is_helmet(obj) && !uarmh)
  143.                  setworn(obj, W_ARMH);
  144.              else if (is_gloves(obj) && !uarmg)
  145.                  setworn(obj, W_ARMG);
  146.              else if (is_shirt(obj) && !uarmu)
  147.                  setworn(obj, W_ARMU);
  148.              else if (is_cloak(obj) && !uarmc)
  149.                  setworn(obj, W_ARMC);
  150.              else if (is_boots(obj) && !uarmf)
  151.                  setworn(obj, W_ARMF);
  152.              else if (is_suit(obj) && !uarm)
  153.                  setworn(obj, W_ARM);
  154.          }
  155.  
  156.          if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
  157.              || otyp == TIN_OPENER || otyp == FLINT || otyp == ROCK) {
  158.              if (is_ammo(obj) || is_missile(obj)) {
  159.                  if (!uquiver)
  160.                      setuqwep(obj);
  161.              } else if (!uwep)
  162.                  setuwep(obj);
  163.              else if (!uswapwep)
  164.                  setuswapwep(obj);
  165.          }
  166.          if (obj->oclass == SPBOOK_CLASS && obj->otyp != SPE_BLANK_PAPER)
  167.              initialspell(obj);
  168.  
  169.  #if !defined(PYRAMID_BUG) && !defined(MAC)
  170.          if (--trop->trquan)
  171.              continue; /* make a similar object */
  172.  #else
  173.          if (trop->trquan) { /* check if zero first */
  174.              --trop->trquan;
  175.              if (trop->trquan)
  176.                  continue; /* make a similar object */
  177.          }
  178.  #endif
  179.          trop++;
  180.      }
  181.  }
  182.  
  183.  /*u_init.c*/