Difference between revisions of "Source:NetHack 3.4.3/src/u init.c"

From NetHackWiki
Jump to navigation Jump to search
(Automated source code upload)
 
m (moved Source:U init.c to Source:NetHack 3.4.3/src/u init.c: Moving src to subdirs)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
__MIXEDSYNTAXHIGHLIGHT__
 +
Below is the full text to src/u_init.c from NetHack 3.4.3. To link to a particular line, write [[u_init.c#line123|<nowiki>[[u_init.c#line123]]</nowiki>]], for example.
 +
 +
== Top of file ==
  
Below is the full text to src/u_init.c from NetHack 3.4.3. To link to a particular line, write [[u_init.c#line123|<nowiki>[[u_init.c#line123]]</nowiki>]], for example.
 
 
  <span id="line1">1.    /* SCCS Id: @(#)u_init.c 3.4 2002/10/22 */</span>
 
  <span id="line1">1.    /* SCCS Id: @(#)u_init.c 3.4 2002/10/22 */</span>
 
  <span id="line2">2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */</span>
 
  <span id="line2">2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */</span>
Line 27: Line 30:
 
  <span id="line22">22.  #define UNDEF_BLESS 2</span>
 
  <span id="line22">22.  #define UNDEF_BLESS 2</span>
 
  <span id="line23">23.  </span>
 
  <span id="line23">23.  </span>
 +
 +
== Initial inventories ==
 +
 
  <span id="line24">24.  /*</span>
 
  <span id="line24">24.  /*</span>
 
  <span id="line25">25.    * Initial inventory for the various roles.</span>
 
  <span id="line25">25.    * Initial inventory for the various roles.</span>
 
  <span id="line26">26.    */</span>
 
  <span id="line26">26.    */</span>
 
  <span id="line27">27.  </span>
 
  <span id="line27">27.  </span>
 +
 +
=== Archeologist initial inventory ===
 +
 
  <span id="line28">28.  static struct trobj Archeologist[] = {</span>
 
  <span id="line28">28.  static struct trobj Archeologist[] = {</span>
 
  <span id="line29">29.  /* if adventure has a name...  idea from tan@uvm-gen */</span>
 
  <span id="line29">29.  /* if adventure has a name...  idea from tan@uvm-gen */</span>
Line 43: Line 52:
 
  <span id="line38">38.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line38">38.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line39">39.  };</span>
 
  <span id="line39">39.  };</span>
 +
 +
=== Barbarian initial inventory ===
 +
 
  <span id="line40">40.  static struct trobj Barbarian[] = {</span>
 
  <span id="line40">40.  static struct trobj Barbarian[] = {</span>
 
  <span id="line41">41.  #define B_MAJOR 0 /* two-handed sword or battle-axe  */</span>
 
  <span id="line41">41.  #define B_MAJOR 0 /* two-handed sword or battle-axe  */</span>
Line 52: Line 64:
 
  <span id="line47">47.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line47">47.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line48">48.  };</span>
 
  <span id="line48">48.  };</span>
 +
 +
=== Caveman initial inventory ===
 +
 
  <span id="line49">49.  static struct trobj Cave_man[] = {</span>
 
  <span id="line49">49.  static struct trobj Cave_man[] = {</span>
 
  <span id="line50">50.  #define C_AMMO 2</span>
 
  <span id="line50">50.  #define C_AMMO 2</span>
Line 61: Line 76:
 
  <span id="line56">56.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line56">56.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line57">57.  };</span>
 
  <span id="line57">57.  };</span>
 +
 +
=== Healer initial inventory ===
 +
 
  <span id="line58">58.  static struct trobj Healer[] = {</span>
 
  <span id="line58">58.  static struct trobj Healer[] = {</span>
 
  <span id="line59">59.  { SCALPEL, 0, WEAPON_CLASS, 1, UNDEF_BLESS },</span>
 
  <span id="line59">59.  { SCALPEL, 0, WEAPON_CLASS, 1, UNDEF_BLESS },</span>
Line 75: Line 93:
 
  <span id="line70">70.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line70">70.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line71">71.  };</span>
 
  <span id="line71">71.  };</span>
 +
 +
=== Knight initial inventory ===
 +
 
  <span id="line72">72.  static struct trobj Knight[] = {</span>
 
  <span id="line72">72.  static struct trobj Knight[] = {</span>
 
  <span id="line73">73.  { LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },</span>
 
  <span id="line73">73.  { LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },</span>
Line 86: Line 107:
 
  <span id="line81">81.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line81">81.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line82">82.  };</span>
 
  <span id="line82">82.  };</span>
 +
 +
=== Monk initial inventory ===
 +
 
  <span id="line83">83.  static struct trobj Monk[] = {</span>
 
  <span id="line83">83.  static struct trobj Monk[] = {</span>
 
  <span id="line84">84.  #define M_BOOK 2</span>
 
  <span id="line84">84.  #define M_BOOK 2</span>
Line 102: Line 126:
 
  <span id="line97">97.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line97">97.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line98">98.  };</span>
 
  <span id="line98">98.  };</span>
 +
 +
=== Priest initial inventory ===
 +
 
  <span id="line99">99.  static struct trobj Priest[] = {</span>
 
  <span id="line99">99.  static struct trobj Priest[] = {</span>
 
  <span id="line100">100.  { MACE, 1, WEAPON_CLASS, 1, 1 },</span>
 
  <span id="line100">100.  { MACE, 1, WEAPON_CLASS, 1, 1 },</span>
Line 112: Line 139:
 
  <span id="line107">107.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line107">107.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line108">108.  };</span>
 
  <span id="line108">108.  };</span>
 +
 +
=== Ranger initial inventory ===
 +
 
  <span id="line109">109.  static struct trobj Ranger[] = {</span>
 
  <span id="line109">109.  static struct trobj Ranger[] = {</span>
 
  <span id="line110">110.  #define RAN_BOW 1</span>
 
  <span id="line110">110.  #define RAN_BOW 1</span>
Line 124: Line 154:
 
  <span id="line119">119.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line119">119.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line120">120.  };</span>
 
  <span id="line120">120.  };</span>
 +
 +
=== Rogue initial inventory ===
 +
 
  <span id="line121">121.  static struct trobj Rogue[] = {</span>
 
  <span id="line121">121.  static struct trobj Rogue[] = {</span>
 
  <span id="line122">122.  #define R_DAGGERS 1</span>
 
  <span id="line122">122.  #define R_DAGGERS 1</span>
Line 134: Line 167:
 
  <span id="line129">129.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line129">129.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line130">130.  };</span>
 
  <span id="line130">130.  };</span>
 +
 +
=== Samurai initial inventory ===
 +
 
  <span id="line131">131.  static struct trobj Samurai[] = {</span>
 
  <span id="line131">131.  static struct trobj Samurai[] = {</span>
 
  <span id="line132">132.  #define S_ARROWS 3</span>
 
  <span id="line132">132.  #define S_ARROWS 3</span>
Line 143: Line 179:
 
  <span id="line138">138.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line138">138.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line139">139.  };</span>
 
  <span id="line139">139.  };</span>
 +
 +
=== Tourist initial inventory ===
 +
 
  <span id="line140">140.  #ifdef TOURIST</span>
 
  <span id="line140">140.  #ifdef TOURIST</span>
 
  <span id="line141">141.  static struct trobj Tourist[] = {</span>
 
  <span id="line141">141.  static struct trobj Tourist[] = {</span>
Line 156: Line 195:
 
  <span id="line151">151.  };</span>
 
  <span id="line151">151.  };</span>
 
  <span id="line152">152.  #endif</span>
 
  <span id="line152">152.  #endif</span>
 +
 +
=== Valkyrie initial inventory ===
 +
 
  <span id="line153">153.  static struct trobj Valkyrie[] = {</span>
 
  <span id="line153">153.  static struct trobj Valkyrie[] = {</span>
 
  <span id="line154">154.  { LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },</span>
 
  <span id="line154">154.  { LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },</span>
Line 163: Line 205:
 
  <span id="line158">158.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line158">158.  { 0, 0, 0, 0, 0 }</span>
 
  <span id="line159">159.  };</span>
 
  <span id="line159">159.  };</span>
 +
 +
=== Wizard initial inventory ===
 +
 
  <span id="line160">160.  static struct trobj Wizard[] = {</span>
 
  <span id="line160">160.  static struct trobj Wizard[] = {</span>
 
  <span id="line161">161.  #define W_MULTSTART 2</span>
 
  <span id="line161">161.  #define W_MULTSTART 2</span>
Line 177: Line 222:
 
  <span id="line172">172.  };</span>
 
  <span id="line172">172.  };</span>
 
  <span id="line173">173.  </span>
 
  <span id="line173">173.  </span>
 +
 +
== Optional extra inventory items ==
 +
 
  <span id="line174">174.  /*</span>
 
  <span id="line174">174.  /*</span>
 
  <span id="line175">175.  * Optional extra inventory items.</span>
 
  <span id="line175">175.  * Optional extra inventory items.</span>
Line 226: Line 274:
 
  <span id="line221">221.  #endif</span>
 
  <span id="line221">221.  #endif</span>
 
  <span id="line222">222.  </span>
 
  <span id="line222">222.  </span>
 +
 +
== Race-based substitutions for initial inventory ==
 +
 
  <span id="line223">223.  /* race-based substitutions for initial inventory;</span>
 
  <span id="line223">223.  /* race-based substitutions for initial inventory;</span>
 
  <span id="line224">224.    the weaker cloak for elven rangers is intentional--they shoot better */</span>
 
  <span id="line224">224.    the weaker cloak for elven rangers is intentional--they shoot better */</span>
Line 257: Line 308:
 
  <span id="line252">252.  };</span>
 
  <span id="line252">252.  };</span>
 
  <span id="line253">253.  </span>
 
  <span id="line253">253.  </span>
 +
 +
== Maximum skill levels ==
 +
 +
=== Archeologist max skill levels ===
 +
 
  <span id="line254">254.  static const struct def_skill Skill_A[] = {</span>
 
  <span id="line254">254.  static const struct def_skill Skill_A[] = {</span>
 
  <span id="line255">255.      { P_DAGGER, P_BASIC }, { P_KNIFE,  P_BASIC },</span>
 
  <span id="line255">255.      { P_DAGGER, P_BASIC }, { P_KNIFE,  P_BASIC },</span>
Line 275: Line 331:
 
  <span id="line270">270.  };</span>
 
  <span id="line270">270.  };</span>
 
  <span id="line271">271.  </span>
 
  <span id="line271">271.  </span>
 +
 +
=== Barbarian max skill levels ===
 +
 
  <span id="line272">272.  static const struct def_skill Skill_B[] = {</span>
 
  <span id="line272">272.  static const struct def_skill Skill_B[] = {</span>
 
  <span id="line273">273.      { P_DAGGER, P_BASIC }, { P_AXE, P_EXPERT },</span>
 
  <span id="line273">273.      { P_DAGGER, P_BASIC }, { P_AXE, P_EXPERT },</span>
Line 294: Line 353:
 
  <span id="line289">289.  };</span>
 
  <span id="line289">289.  };</span>
 
  <span id="line290">290.  </span>
 
  <span id="line290">290.  </span>
 +
 +
=== Caveman max skill levels ===
 +
 
  <span id="line291">291.  static const struct def_skill Skill_C[] = {</span>
 
  <span id="line291">291.  static const struct def_skill Skill_C[] = {</span>
 
  <span id="line292">292.      { P_DAGGER, P_BASIC }, { P_KNIFE,  P_SKILLED },</span>
 
  <span id="line292">292.      { P_DAGGER, P_BASIC }, { P_KNIFE,  P_SKILLED },</span>
Line 309: Line 371:
 
  <span id="line304">304.  };</span>
 
  <span id="line304">304.  };</span>
 
  <span id="line305">305.  </span>
 
  <span id="line305">305.  </span>
 +
 +
=== Healer max skill levels ===
 +
 
  <span id="line306">306.  static const struct def_skill Skill_H[] = {</span>
 
  <span id="line306">306.  static const struct def_skill Skill_H[] = {</span>
 
  <span id="line307">307.      { P_DAGGER, P_SKILLED }, { P_KNIFE, P_EXPERT },</span>
 
  <span id="line307">307.      { P_DAGGER, P_SKILLED }, { P_KNIFE, P_EXPERT },</span>
Line 323: Line 388:
 
  <span id="line318">318.  };</span>
 
  <span id="line318">318.  };</span>
 
  <span id="line319">319.  </span>
 
  <span id="line319">319.  </span>
 +
 +
=== Knight max skill levels ===
 +
 
  <span id="line320">320.  static const struct def_skill Skill_K[] = {</span>
 
  <span id="line320">320.  static const struct def_skill Skill_K[] = {</span>
 
  <span id="line321">321.      { P_DAGGER, P_BASIC }, { P_KNIFE, P_BASIC },</span>
 
  <span id="line321">321.      { P_DAGGER, P_BASIC }, { P_KNIFE, P_BASIC },</span>
Line 345: Line 413:
 
  <span id="line340">340.  };</span>
 
  <span id="line340">340.  };</span>
 
  <span id="line341">341.  </span>
 
  <span id="line341">341.  </span>
 +
 +
=== Monk max skill levels ===
 +
 
  <span id="line342">342.  static const struct def_skill Skill_Mon[] = {</span>
 
  <span id="line342">342.  static const struct def_skill Skill_Mon[] = {</span>
 
  <span id="line343">343.      { P_QUARTERSTAFF, P_BASIC },    { P_SPEAR, P_BASIC },</span>
 
  <span id="line343">343.      { P_QUARTERSTAFF, P_BASIC },    { P_SPEAR, P_BASIC },</span>
Line 357: Line 428:
 
  <span id="line352">352.  };</span>
 
  <span id="line352">352.  };</span>
 
  <span id="line353">353.  </span>
 
  <span id="line353">353.  </span>
 +
 +
=== Priest max skill levels ===
 +
 
  <span id="line354">354.  static const struct def_skill Skill_P[] = {</span>
 
  <span id="line354">354.  static const struct def_skill Skill_P[] = {</span>
 
  <span id="line355">355.      { P_CLUB, P_EXPERT }, { P_MACE, P_EXPERT },</span>
 
  <span id="line355">355.      { P_CLUB, P_EXPERT }, { P_MACE, P_EXPERT },</span>
Line 373: Line 447:
 
  <span id="line368">368.  };</span>
 
  <span id="line368">368.  };</span>
 
  <span id="line369">369.  </span>
 
  <span id="line369">369.  </span>
 +
 +
=== Rogue max skill levels ===
 +
 
  <span id="line370">370.  static const struct def_skill Skill_R[] = {</span>
 
  <span id="line370">370.  static const struct def_skill Skill_R[] = {</span>
 
  <span id="line371">371.      { P_DAGGER, P_EXPERT }, { P_KNIFE,  P_EXPERT },</span>
 
  <span id="line371">371.      { P_DAGGER, P_EXPERT }, { P_KNIFE,  P_EXPERT },</span>
Line 393: Line 470:
 
  <span id="line388">388.  };</span>
 
  <span id="line388">388.  };</span>
 
  <span id="line389">389.  </span>
 
  <span id="line389">389.  </span>
 +
 +
=== Ranger max skill levels ===
 +
 
  <span id="line390">390.  static const struct def_skill Skill_Ran[] = {</span>
 
  <span id="line390">390.  static const struct def_skill Skill_Ran[] = {</span>
 
  <span id="line391">391.      { P_DAGGER, P_EXPERT }, { P_KNIFE,  P_SKILLED },</span>
 
  <span id="line391">391.      { P_DAGGER, P_EXPERT }, { P_KNIFE,  P_SKILLED },</span>
Line 414: Line 494:
 
  <span id="line409">409.  };</span>
 
  <span id="line409">409.  };</span>
 
  <span id="line410">410.  </span>
 
  <span id="line410">410.  </span>
 +
 +
=== Samurai max skill levels ===
 +
 
  <span id="line411">411.  static const struct def_skill Skill_S[] = {</span>
 
  <span id="line411">411.  static const struct def_skill Skill_S[] = {</span>
 
  <span id="line412">412.      { P_DAGGER, P_BASIC }, { P_KNIFE,  P_SKILLED },</span>
 
  <span id="line412">412.      { P_DAGGER, P_BASIC }, { P_KNIFE,  P_SKILLED },</span>
Line 432: Line 515:
 
  <span id="line427">427.  };</span>
 
  <span id="line427">427.  };</span>
 
  <span id="line428">428.  </span>
 
  <span id="line428">428.  </span>
 +
 +
=== Tourist max skill levels ===
 +
 
  <span id="line429">429.  #ifdef TOURIST</span>
 
  <span id="line429">429.  #ifdef TOURIST</span>
 
  <span id="line430">430.  static const struct def_skill Skill_T[] = {</span>
 
  <span id="line430">430.  static const struct def_skill Skill_T[] = {</span>
Line 459: Line 545:
 
  <span id="line454">454.  #endif /* TOURIST */</span>
 
  <span id="line454">454.  #endif /* TOURIST */</span>
 
  <span id="line455">455.  </span>
 
  <span id="line455">455.  </span>
 +
 +
=== Valkyrie max skill levels ===
 +
 
  <span id="line456">456.  static const struct def_skill Skill_V[] = {</span>
 
  <span id="line456">456.  static const struct def_skill Skill_V[] = {</span>
 
  <span id="line457">457.      { P_DAGGER, P_EXPERT }, { P_AXE, P_EXPERT },</span>
 
  <span id="line457">457.      { P_DAGGER, P_EXPERT }, { P_AXE, P_EXPERT },</span>
Line 478: Line 567:
 
  <span id="line473">473.  };</span>
 
  <span id="line473">473.  };</span>
 
  <span id="line474">474.  </span>
 
  <span id="line474">474.  </span>
 +
 +
=== Wizard max skill levels ===
 +
 
  <span id="line475">475.  static const struct def_skill Skill_W[] = {</span>
 
  <span id="line475">475.  static const struct def_skill Skill_W[] = {</span>
 
  <span id="line476">476.      { P_DAGGER, P_EXPERT }, { P_KNIFE,  P_SKILLED },</span>
 
  <span id="line476">476.      { P_DAGGER, P_EXPERT }, { P_KNIFE,  P_SKILLED },</span>
Line 498: Line 590:
 
  <span id="line493">493.  </span>
 
  <span id="line493">493.  </span>
 
  <span id="line494">494.  </span>
 
  <span id="line494">494.  </span>
 +
 +
== knows_object ==
 +
 
  <span id="line495">495.  STATIC_OVL void</span>
 
  <span id="line495">495.  STATIC_OVL void</span>
 
  <span id="line496">496.  knows_object(obj)</span>
 
  <span id="line496">496.  knows_object(obj)</span>
Line 506: Line 601:
 
  <span id="line501">501.  }</span>
 
  <span id="line501">501.  }</span>
 
  <span id="line502">502.  </span>
 
  <span id="line502">502.  </span>
 +
 +
== knows_class ==
 +
 
  <span id="line503">503.  /* Know ordinary (non-magical) objects of a certain class,</span>
 
  <span id="line503">503.  /* Know ordinary (non-magical) objects of a certain class,</span>
 
  <span id="line504">504.  * like all gems except the loadstone and luckstone.</span>
 
  <span id="line504">504.  * like all gems except the loadstone and luckstone.</span>
Line 519: Line 617:
 
  <span id="line514">514.  }</span>
 
  <span id="line514">514.  }</span>
 
  <span id="line515">515.  </span>
 
  <span id="line515">515.  </span>
 +
 +
== u_init ==
 +
 
  <span id="line516">516.  void</span>
 
  <span id="line516">516.  void</span>
 
  <span id="line517">517.  u_init()</span>
 
  <span id="line517">517.  u_init()</span>
Line 603: Line 704:
 
  <span id="line598">598.  </span>
 
  <span id="line598">598.  </span>
 
  <span id="line599">599.  </span>
 
  <span id="line599">599.  </span>
 +
 +
=== Role-specific initializations ===
 +
 
  <span id="line600">600.  /*** Role-specific initializations ***/</span>
 
  <span id="line600">600.  /*** Role-specific initializations ***/</span>
 
  <span id="line601">601.  switch (Role_switch) {</span>
 
  <span id="line601">601.  switch (Role_switch) {</span>
Line 609: Line 713:
 
  <span id="line604">604.  * skew the results if we use rn2(2)...  --KAA</span>
 
  <span id="line604">604.  * skew the results if we use rn2(2)...  --KAA</span>
 
  <span id="line605">605.  */</span>
 
  <span id="line605">605.  */</span>
 +
 +
==== Archeologist initializations ====
 +
 
  <span id="line606">606.  case PM_ARCHEOLOGIST:</span>
 
  <span id="line606">606.  case PM_ARCHEOLOGIST:</span>
 
  <span id="line607">607.  ini_inv(Archeologist);</span>
 
  <span id="line607">607.  ini_inv(Archeologist);</span>
Line 618: Line 725:
 
  <span id="line613">613.  skill_init(Skill_A);</span>
 
  <span id="line613">613.  skill_init(Skill_A);</span>
 
  <span id="line614">614.  break;</span>
 
  <span id="line614">614.  break;</span>
 +
 +
==== Barbarian initializations ====
 +
 
  <span id="line615">615.  case PM_BARBARIAN:</span>
 
  <span id="line615">615.  case PM_BARBARIAN:</span>
 
  <span id="line616">616.  if (rn2(100) >= 50) { /* see above comment */</span>
 
  <span id="line616">616.  if (rn2(100) >= 50) { /* see above comment */</span>
Line 629: Line 739:
 
  <span id="line624">624.  skill_init(Skill_B);</span>
 
  <span id="line624">624.  skill_init(Skill_B);</span>
 
  <span id="line625">625.  break;</span>
 
  <span id="line625">625.  break;</span>
 +
 +
==== Caveman initializations ====
 +
 
  <span id="line626">626.  case PM_CAVEMAN:</span>
 
  <span id="line626">626.  case PM_CAVEMAN:</span>
 
  <span id="line627">627.  Cave_man[C_AMMO].trquan = rn1(11, 10); /* 10..20 */</span>
 
  <span id="line627">627.  Cave_man[C_AMMO].trquan = rn1(11, 10); /* 10..20 */</span>
Line 634: Line 747:
 
  <span id="line629">629.  skill_init(Skill_C);</span>
 
  <span id="line629">629.  skill_init(Skill_C);</span>
 
  <span id="line630">630.  break;</span>
 
  <span id="line630">630.  break;</span>
 +
 +
==== Healer initializations ====
 +
 
  <span id="line631">631.  case PM_HEALER:</span>
 
  <span id="line631">631.  case PM_HEALER:</span>
 
  <span id="line632">632.  #ifndef GOLDOBJ</span>
 
  <span id="line632">632.  #ifndef GOLDOBJ</span>
Line 645: Line 761:
 
  <span id="line640">640.  skill_init(Skill_H);</span>
 
  <span id="line640">640.  skill_init(Skill_H);</span>
 
  <span id="line641">641.  break;</span>
 
  <span id="line641">641.  break;</span>
 +
 +
==== Knight initializations ====
 +
 
  <span id="line642">642.  case PM_KNIGHT:</span>
 
  <span id="line642">642.  case PM_KNIGHT:</span>
 
  <span id="line643">643.  ini_inv(Knight);</span>
 
  <span id="line643">643.  ini_inv(Knight);</span>
Line 654: Line 773:
 
  <span id="line649">649.  skill_init(Skill_K);</span>
 
  <span id="line649">649.  skill_init(Skill_K);</span>
 
  <span id="line650">650.  break;</span>
 
  <span id="line650">650.  break;</span>
 +
 +
==== Monk initializations ====
 +
 
  <span id="line651">651.  case PM_MONK:</span>
 
  <span id="line651">651.  case PM_MONK:</span>
 
  <span id="line652">652.  switch (rn2(90) / 30) {</span>
 
  <span id="line652">652.  switch (rn2(90) / 30) {</span>
Line 666: Line 788:
 
  <span id="line661">661.  skill_init(Skill_Mon);</span>
 
  <span id="line661">661.  skill_init(Skill_Mon);</span>
 
  <span id="line662">662.  break;</span>
 
  <span id="line662">662.  break;</span>
 +
 +
==== Priest initializations ====
 +
 
  <span id="line663">663.  case PM_PRIEST:</span>
 
  <span id="line663">663.  case PM_PRIEST:</span>
 
  <span id="line664">664.  ini_inv(Priest);</span>
 
  <span id="line664">664.  ini_inv(Priest);</span>
Line 680: Line 805:
 
  <span id="line675">675.  */</span>
 
  <span id="line675">675.  */</span>
 
  <span id="line676">676.  break;</span>
 
  <span id="line676">676.  break;</span>
 +
 +
==== Ranger initializations ====
 +
 
  <span id="line677">677.  case PM_RANGER:</span>
 
  <span id="line677">677.  case PM_RANGER:</span>
 
  <span id="line678">678.  Ranger[RAN_TWO_ARROWS].trquan = rn1(10, 50);</span>
 
  <span id="line678">678.  Ranger[RAN_TWO_ARROWS].trquan = rn1(10, 50);</span>
Line 686: Line 814:
 
  <span id="line681">681.  skill_init(Skill_Ran);</span>
 
  <span id="line681">681.  skill_init(Skill_Ran);</span>
 
  <span id="line682">682.  break;</span>
 
  <span id="line682">682.  break;</span>
 +
 +
==== Rogue initializations ====
 +
 
  <span id="line683">683.  case PM_ROGUE:</span>
 
  <span id="line683">683.  case PM_ROGUE:</span>
 
  <span id="line684">684.  Rogue[R_DAGGERS].trquan = rn1(10, 6);</span>
 
  <span id="line684">684.  Rogue[R_DAGGERS].trquan = rn1(10, 6);</span>
Line 698: Line 829:
 
  <span id="line693">693.  skill_init(Skill_R);</span>
 
  <span id="line693">693.  skill_init(Skill_R);</span>
 
  <span id="line694">694.  break;</span>
 
  <span id="line694">694.  break;</span>
 +
 +
==== Samurai initializations ====
 +
 
  <span id="line695">695.  case PM_SAMURAI:</span>
 
  <span id="line695">695.  case PM_SAMURAI:</span>
 
  <span id="line696">696.  Samurai[S_ARROWS].trquan = rn1(20, 26);</span>
 
  <span id="line696">696.  Samurai[S_ARROWS].trquan = rn1(20, 26);</span>
Line 706: Line 840:
 
  <span id="line701">701.  skill_init(Skill_S);</span>
 
  <span id="line701">701.  skill_init(Skill_S);</span>
 
  <span id="line702">702.  break;</span>
 
  <span id="line702">702.  break;</span>
 +
 +
==== Tourist initializations ====
 +
 
  <span id="line703">703.  #ifdef TOURIST</span>
 
  <span id="line703">703.  #ifdef TOURIST</span>
 
  <span id="line704">704.  case PM_TOURIST:</span>
 
  <span id="line704">704.  case PM_TOURIST:</span>
Line 722: Line 859:
 
  <span id="line717">717.  break;</span>
 
  <span id="line717">717.  break;</span>
 
  <span id="line718">718.  #endif</span>
 
  <span id="line718">718.  #endif</span>
 +
 +
==== Valkyrie initializations ====
 +
 
  <span id="line719">719.  case PM_VALKYRIE:</span>
 
  <span id="line719">719.  case PM_VALKYRIE:</span>
 
  <span id="line720">720.  ini_inv(Valkyrie);</span>
 
  <span id="line720">720.  ini_inv(Valkyrie);</span>
Line 729: Line 869:
 
  <span id="line724">724.  skill_init(Skill_V);</span>
 
  <span id="line724">724.  skill_init(Skill_V);</span>
 
  <span id="line725">725.  break;</span>
 
  <span id="line725">725.  break;</span>
 +
 +
==== Wizard initializations ====
 +
 
  <span id="line726">726.  case PM_WIZARD:</span>
 
  <span id="line726">726.  case PM_WIZARD:</span>
 
  <span id="line727">727.  ini_inv(Wizard);</span>
 
  <span id="line727">727.  ini_inv(Wizard);</span>
Line 741: Line 884:
 
  <span id="line736">736.  </span>
 
  <span id="line736">736.  </span>
 
  <span id="line737">737.  </span>
 
  <span id="line737">737.  </span>
 +
 +
=== Race-specific initializations ===
 +
 
  <span id="line738">738.  /*** Race-specific initializations ***/</span>
 
  <span id="line738">738.  /*** Race-specific initializations ***/</span>
 
  <span id="line739">739.  switch (Race_switch) {</span>
 
  <span id="line739">739.  switch (Race_switch) {</span>
 +
 +
==== Human initializations ====
 +
 
  <span id="line740">740.  case PM_HUMAN:</span>
 
  <span id="line740">740.  case PM_HUMAN:</span>
 
  <span id="line741">741.      /* Nothing special */</span>
 
  <span id="line741">741.      /* Nothing special */</span>
 
  <span id="line742">742.      break;</span>
 
  <span id="line742">742.      break;</span>
 
  <span id="line743">743.  </span>
 
  <span id="line743">743.  </span>
 +
 +
==== Elf initializations ====
 +
 
  <span id="line744">744.  case PM_ELF:</span>
 
  <span id="line744">744.  case PM_ELF:</span>
 
  <span id="line745">745.      /*</span>
 
  <span id="line745">745.      /*</span>
Line 776: Line 928:
 
  <span id="line771">771.      break;</span>
 
  <span id="line771">771.      break;</span>
 
  <span id="line772">772.  </span>
 
  <span id="line772">772.  </span>
 +
 +
==== Dwarf initializations ====
 +
 
  <span id="line773">773.  case PM_DWARF:</span>
 
  <span id="line773">773.  case PM_DWARF:</span>
 
  <span id="line774">774.      /* Dwarves can recognize all dwarvish objects */</span>
 
  <span id="line774">774.      /* Dwarves can recognize all dwarvish objects */</span>
Line 787: Line 942:
 
  <span id="line782">782.      break;</span>
 
  <span id="line782">782.      break;</span>
 
  <span id="line783">783.  </span>
 
  <span id="line783">783.  </span>
 +
 +
==== Gnome initializations ====
 +
 
  <span id="line784">784.  case PM_GNOME:</span>
 
  <span id="line784">784.  case PM_GNOME:</span>
 
  <span id="line785">785.      break;</span>
 
  <span id="line785">785.      break;</span>
 
  <span id="line786">786.  </span>
 
  <span id="line786">786.  </span>
 +
 +
==== Orc initializations ====
 +
 
  <span id="line787">787.  case PM_ORC:</span>
 
  <span id="line787">787.  case PM_ORC:</span>
 
  <span id="line788">788.      /* compensate for generally inferior equipment */</span>
 
  <span id="line788">788.      /* compensate for generally inferior equipment */</span>
Line 851: Line 1,012:
 
  <span id="line846">846.  }</span>
 
  <span id="line846">846.  }</span>
 
  <span id="line847">847.  </span>
 
  <span id="line847">847.  </span>
 +
 +
== restricted_spell_discipline ==
 +
 
  <span id="line848">848.  /* skills aren't initialized, so we use the role-specific skill lists */</span>
 
  <span id="line848">848.  /* skills aren't initialized, so we use the role-specific skill lists */</span>
 
  <span id="line849">849.  STATIC_OVL boolean</span>
 
  <span id="line849">849.  STATIC_OVL boolean</span>
Line 885: Line 1,049:
 
  <span id="line880">880.  }</span>
 
  <span id="line880">880.  }</span>
 
  <span id="line881">881.  </span>
 
  <span id="line881">881.  </span>
 +
 +
== ini_inv ==
 +
 
  <span id="line882">882.  STATIC_OVL void</span>
 
  <span id="line882">882.  STATIC_OVL void</span>
 
  <span id="line883">883.  ini_inv(trop)</span>
 
  <span id="line883">883.  ini_inv(trop)</span>

Latest revision as of 19:24, 31 January 2011

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

Contents

Top of file

/*	SCCS Id: @(#)u_init.c	3.4	2002/10/22	*/
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* 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.

#include "hack.h"

struct trobj {
	short trotyp;
	schar trspe;
	char trclass;
	Bitfield(trquan,6);
	Bitfield(trbless,2);
};

STATIC_DCL void FDECL(ini_inv, (struct trobj *));
STATIC_DCL void FDECL(knows_object,(int));
STATIC_DCL void FDECL(knows_class,(CHAR_P));
STATIC_DCL boolean FDECL(restricted_spell_discipline, (int));

#define UNDEF_TYP	0
#define UNDEF_SPE	'\177'
#define UNDEF_BLESS	2

Initial inventories

/*
*	Initial inventory for the various roles.
*/

Archeologist initial inventory

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

Barbarian initial inventory

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

Caveman initial inventory

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

Healer initial inventory

static struct trobj Healer[] = {
	{ SCALPEL, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ LEATHER_GLOVES, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ STETHOSCOPE, 0, TOOL_CLASS, 1, 0 },
	{ POT_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS },
	{ POT_EXTRA_HEALING, 0, POTION_CLASS, 4, UNDEF_BLESS },
	{ WAN_SLEEP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS },
	/* always blessed, so it's guaranteed readable */
	{ SPE_HEALING, 0, SPBOOK_CLASS, 1, 1 },
	{ SPE_EXTRA_HEALING, 0, SPBOOK_CLASS, 1, 1 },
	{ SPE_STONE_TO_FLESH, 0, SPBOOK_CLASS, 1, 1 },
	{ APPLE, 0, FOOD_CLASS, 5, 0 },
	{ 0, 0, 0, 0, 0 }
};

Knight initial inventory

static struct trobj Knight[] = {
	{ LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ LANCE, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ RING_MAIL, 1, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ HELMET, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ SMALL_SHIELD, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ LEATHER_GLOVES, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ APPLE, 0, FOOD_CLASS, 10, 0 },
	{ CARROT, 0, FOOD_CLASS, 10, 0 },
	{ 0, 0, 0, 0, 0 }
};

Monk initial inventory

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

Priest initial inventory

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

Ranger initial inventory

static struct trobj Ranger[] = {
#define RAN_BOW			1
#define RAN_TWO_ARROWS	2
#define RAN_ZERO_ARROWS	3
	{ DAGGER, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ BOW, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ ARROW, 2, WEAPON_CLASS, 50, UNDEF_BLESS },
	{ ARROW, 0, WEAPON_CLASS, 30, UNDEF_BLESS },
	{ CLOAK_OF_DISPLACEMENT, 2, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ CRAM_RATION, 0, FOOD_CLASS, 4, 0 },
	{ 0, 0, 0, 0, 0 }
};

Rogue initial inventory

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

Samurai initial inventory

static struct trobj Samurai[] = {
#define S_ARROWS	3
	{ KATANA, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ SHORT_SWORD, 0, WEAPON_CLASS, 1, UNDEF_BLESS }, /* wakizashi */
	{ YUMI, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ YA, 0, WEAPON_CLASS, 25, UNDEF_BLESS }, /* variable quan */
	{ SPLINT_MAIL, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ 0, 0, 0, 0, 0 }
};

Tourist initial inventory

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

Valkyrie initial inventory

static struct trobj Valkyrie[] = {
	{ LONG_SWORD, 1, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ DAGGER, 0, WEAPON_CLASS, 1, UNDEF_BLESS },
	{ SMALL_SHIELD, 3, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ FOOD_RATION, 0, FOOD_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};

Wizard initial inventory

static struct trobj Wizard[] = {
#define W_MULTSTART	2
#define W_MULTEND	6
	{ QUARTERSTAFF, 1, WEAPON_CLASS, 1, 1 },
	{ CLOAK_OF_MAGIC_RESISTANCE, 0, ARMOR_CLASS, 1, UNDEF_BLESS },
	{ UNDEF_TYP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS },
	{ UNDEF_TYP, UNDEF_SPE, RING_CLASS, 2, UNDEF_BLESS },
	{ UNDEF_TYP, UNDEF_SPE, POTION_CLASS, 3, UNDEF_BLESS },
	{ UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 3, UNDEF_BLESS },
	{ SPE_FORCE_BOLT, 0, SPBOOK_CLASS, 1, 1 },
	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, UNDEF_BLESS },
	{ 0, 0, 0, 0, 0 }
};

Optional extra inventory items

/*
*	Optional extra inventory items.
*/

static struct trobj Tinopener[] = {
	{ TIN_OPENER, 0, TOOL_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
static struct trobj Magicmarker[] = {
	{ MAGIC_MARKER, UNDEF_SPE, TOOL_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
static struct trobj Lamp[] = {
	{ OIL_LAMP, 1, TOOL_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
static struct trobj Blindfold[] = {
	{ BLINDFOLD, 0, TOOL_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
static struct trobj Instrument[] = {
	{ WOODEN_FLUTE, 0, TOOL_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
static struct trobj Xtra_food[] = {
	{ UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 2, 0 },
	{ 0, 0, 0, 0, 0 }
};
#ifdef TOURIST
static struct trobj Leash[] = {
	{ LEASH, 0, TOOL_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
static struct trobj Towel[] = {
	{ TOWEL, 0, TOOL_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
#endif	/* TOURIST */
static struct trobj Wishing[] = {
	{ WAN_WISHING, 3, WAND_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
#ifdef GOLDOBJ
static struct trobj Money[] = {
	{ GOLD_PIECE, 0 , COIN_CLASS, 1, 0 },
	{ 0, 0, 0, 0, 0 }
};
#endif

Race-based substitutions for initial inventory

/* race-based substitutions for initial inventory;
the weaker cloak for elven rangers is intentional--they shoot better */
static struct inv_sub { short race_pm, item_otyp, subs_otyp; } inv_subs[] = {
{ PM_ELF,	DAGGER,			ELVEN_DAGGER	      },
{ PM_ELF,	SPEAR,			ELVEN_SPEAR	      },
{ PM_ELF,	SHORT_SWORD,		ELVEN_SHORT_SWORD     },
{ PM_ELF,	BOW,			ELVEN_BOW	      },
{ PM_ELF,	ARROW,			ELVEN_ARROW	      },
{ PM_ELF,	HELMET,			ELVEN_LEATHER_HELM    },
/* { PM_ELF,	SMALL_SHIELD,		ELVEN_SHIELD	      }, */
{ PM_ELF,	CLOAK_OF_DISPLACEMENT,	ELVEN_CLOAK	      },
{ PM_ELF,	CRAM_RATION,		LEMBAS_WAFER	      },
{ PM_ORC,	DAGGER,			ORCISH_DAGGER	      },
{ PM_ORC,	SPEAR,			ORCISH_SPEAR	      },
{ PM_ORC,	SHORT_SWORD,		ORCISH_SHORT_SWORD    },
{ PM_ORC,	BOW,			ORCISH_BOW	      },
{ PM_ORC,	ARROW,			ORCISH_ARROW	      },
{ PM_ORC,	HELMET,			ORCISH_HELM	      },
{ PM_ORC,	SMALL_SHIELD,		ORCISH_SHIELD	      },
{ PM_ORC,	RING_MAIL,		ORCISH_RING_MAIL      },
{ PM_ORC,	CHAIN_MAIL,		ORCISH_CHAIN_MAIL     },
{ PM_DWARF, SPEAR,			DWARVISH_SPEAR	      },
{ PM_DWARF, SHORT_SWORD,		DWARVISH_SHORT_SWORD  },
{ PM_DWARF, HELMET,			DWARVISH_IRON_HELM    },
/* { PM_DWARF, SMALL_SHIELD,		DWARVISH_ROUNDSHIELD  }, */
/* { PM_DWARF, PICK_AXE,		DWARVISH_MATTOCK      }, */
{ PM_GNOME, BOW,			CROSSBOW	      },
{ PM_GNOME, ARROW,			CROSSBOW_BOLT	      },
{ NON_PM,	STRANGE_OBJECT,		STRANGE_OBJECT	      }
};

Maximum skill levels

Archeologist max skill levels

static const struct def_skill Skill_A[] = {
{ P_DAGGER, P_BASIC },		{ P_KNIFE,  P_BASIC },
{ P_PICK_AXE, P_EXPERT },		{ P_SHORT_SWORD, P_BASIC },
{ P_SCIMITAR, P_SKILLED },		{ P_SABER, P_EXPERT },
{ P_CLUB, P_SKILLED },		{ P_QUARTERSTAFF, P_SKILLED },
{ P_SLING, P_SKILLED },		{ P_DART, P_BASIC },
{ P_BOOMERANG, P_EXPERT },		{ P_WHIP, P_EXPERT },
{ P_UNICORN_HORN, P_SKILLED },
{ P_ATTACK_SPELL, P_BASIC },	{ P_HEALING_SPELL, P_BASIC },
{ P_DIVINATION_SPELL, P_EXPERT},	{ P_MATTER_SPELL, P_BASIC},
#ifdef STEED
{ P_RIDING, P_BASIC },
#endif
{ P_TWO_WEAPON_COMBAT, P_BASIC },
{ P_BARE_HANDED_COMBAT, P_EXPERT },
{ P_NONE, 0 }
};

Barbarian max skill levels

static const struct def_skill Skill_B[] = {
{ P_DAGGER, P_BASIC },		{ P_AXE, P_EXPERT },
{ P_PICK_AXE, P_SKILLED },	{ P_SHORT_SWORD, P_EXPERT },
{ P_BROAD_SWORD, P_SKILLED },	{ P_LONG_SWORD, P_SKILLED },
{ P_TWO_HANDED_SWORD, P_EXPERT },	{ P_SCIMITAR, P_SKILLED },
{ P_SABER, P_BASIC },		{ P_CLUB, P_SKILLED },
{ P_MACE, P_SKILLED },		{ P_MORNING_STAR, P_SKILLED },
{ P_FLAIL, P_BASIC },		{ P_HAMMER, P_EXPERT },
{ P_QUARTERSTAFF, P_BASIC },	{ P_SPEAR, P_SKILLED },
{ P_TRIDENT, P_SKILLED },		{ P_BOW, P_BASIC },
{ P_ATTACK_SPELL, P_SKILLED },
#ifdef STEED
{ P_RIDING, P_BASIC },
#endif
{ P_TWO_WEAPON_COMBAT, P_BASIC },
{ P_BARE_HANDED_COMBAT, P_MASTER },
{ P_NONE, 0 }
};

Caveman max skill levels

static const struct def_skill Skill_C[] = {
{ P_DAGGER, P_BASIC },		{ P_KNIFE,  P_SKILLED },
{ P_AXE, P_SKILLED },		{ P_PICK_AXE, P_BASIC },
{ P_CLUB, P_EXPERT },		{ P_MACE, P_EXPERT },
{ P_MORNING_STAR, P_BASIC },	{ P_FLAIL, P_SKILLED },
{ P_HAMMER, P_SKILLED },		{ P_QUARTERSTAFF, P_EXPERT },
{ P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_EXPERT },
{ P_JAVELIN, P_SKILLED },		{ P_TRIDENT, P_SKILLED },
{ P_BOW, P_SKILLED },		{ P_SLING, P_EXPERT },
{ P_ATTACK_SPELL, P_BASIC },	{ P_MATTER_SPELL, P_SKILLED },
{ P_BOOMERANG, P_EXPERT },		{ P_UNICORN_HORN, P_BASIC },
{ P_BARE_HANDED_COMBAT, P_MASTER },
{ P_NONE, 0 }
};

Healer max skill levels

static const struct def_skill Skill_H[] = {
{ P_DAGGER, P_SKILLED },		{ P_KNIFE, P_EXPERT },
{ P_SHORT_SWORD, P_SKILLED },	{ P_SCIMITAR, P_BASIC },
{ P_SABER, P_BASIC },		{ P_CLUB, P_SKILLED },
{ P_MACE, P_BASIC },		{ P_QUARTERSTAFF, P_EXPERT },
{ P_POLEARMS, P_BASIC },		{ P_SPEAR, P_BASIC },
{ P_JAVELIN, P_BASIC },		{ P_TRIDENT, P_BASIC },
{ P_SLING, P_SKILLED },		{ P_DART, P_EXPERT },
{ P_SHURIKEN, P_SKILLED },		{ P_UNICORN_HORN, P_EXPERT },
{ P_HEALING_SPELL, P_EXPERT },
{ P_BARE_HANDED_COMBAT, P_BASIC },
{ P_NONE, 0 }
};

Knight max skill levels

static const struct def_skill Skill_K[] = {
{ P_DAGGER, P_BASIC },		{ P_KNIFE, P_BASIC },
{ P_AXE, P_SKILLED },		{ P_PICK_AXE, P_BASIC },
{ P_SHORT_SWORD, P_SKILLED },	{ P_BROAD_SWORD, P_SKILLED },
{ P_LONG_SWORD, P_EXPERT },	{ P_TWO_HANDED_SWORD, P_SKILLED },
{ P_SCIMITAR, P_BASIC },		{ P_SABER, P_SKILLED },
{ P_CLUB, P_BASIC },		{ P_MACE, P_SKILLED },
{ P_MORNING_STAR, P_SKILLED },	{ P_FLAIL, P_BASIC },
{ P_HAMMER, P_BASIC },		{ P_POLEARMS, P_SKILLED },
{ P_SPEAR, P_SKILLED },		{ P_JAVELIN, P_SKILLED },
{ P_TRIDENT, P_BASIC },		{ P_LANCE, P_EXPERT },
{ P_BOW, P_BASIC },			{ P_CROSSBOW, P_SKILLED },
{ P_ATTACK_SPELL, P_SKILLED },	{ P_HEALING_SPELL, P_SKILLED },
{ P_CLERIC_SPELL, P_SKILLED },
#ifdef STEED
{ P_RIDING, P_EXPERT },
#endif
{ P_TWO_WEAPON_COMBAT, P_SKILLED },
{ P_BARE_HANDED_COMBAT, P_EXPERT },
{ P_NONE, 0 }
};

Monk max skill levels

static const struct def_skill Skill_Mon[] = {
{ P_QUARTERSTAFF, P_BASIC },    { P_SPEAR, P_BASIC },
{ P_JAVELIN, P_BASIC },		    { P_CROSSBOW, P_BASIC },
{ P_SHURIKEN, P_BASIC },
{ P_ATTACK_SPELL, P_BASIC },    { P_HEALING_SPELL, P_EXPERT },
{ P_DIVINATION_SPELL, P_BASIC },{ P_ENCHANTMENT_SPELL, P_BASIC },
{ P_CLERIC_SPELL, P_SKILLED },  { P_ESCAPE_SPELL, P_BASIC },
{ P_MATTER_SPELL, P_BASIC },
{ P_MARTIAL_ARTS, P_GRAND_MASTER },
{ P_NONE, 0 }
};

Priest max skill levels

static const struct def_skill Skill_P[] = {
{ P_CLUB, P_EXPERT },		{ P_MACE, P_EXPERT },
{ P_MORNING_STAR, P_EXPERT },	{ P_FLAIL, P_EXPERT },
{ P_HAMMER, P_EXPERT },		{ P_QUARTERSTAFF, P_EXPERT },
{ P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_SKILLED },
{ P_JAVELIN, P_SKILLED },		{ P_TRIDENT, P_SKILLED },
{ P_LANCE, P_BASIC },		{ P_BOW, P_BASIC },
{ P_SLING, P_BASIC },		{ P_CROSSBOW, P_BASIC },
{ P_DART, P_BASIC },		{ P_SHURIKEN, P_BASIC },
{ P_BOOMERANG, P_BASIC },		{ P_UNICORN_HORN, P_SKILLED },
{ P_HEALING_SPELL, P_EXPERT },	{ P_DIVINATION_SPELL, P_EXPERT },
{ P_CLERIC_SPELL, P_EXPERT },
{ P_BARE_HANDED_COMBAT, P_BASIC },
{ P_NONE, 0 }
};

Rogue max skill levels

static const struct def_skill Skill_R[] = {
{ P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_EXPERT },
{ P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_SKILLED },
{ P_LONG_SWORD, P_SKILLED },	{ P_TWO_HANDED_SWORD, P_BASIC },
{ P_SCIMITAR, P_SKILLED },		{ P_SABER, P_SKILLED },
{ P_CLUB, P_SKILLED },		{ P_MACE, P_SKILLED },
{ P_MORNING_STAR, P_BASIC },	{ P_FLAIL, P_BASIC },
{ P_HAMMER, P_BASIC },		{ P_POLEARMS, P_BASIC },
{ P_SPEAR, P_BASIC },		{ P_CROSSBOW, P_EXPERT },
{ P_DART, P_EXPERT },		{ P_SHURIKEN, P_SKILLED },
{ P_DIVINATION_SPELL, P_SKILLED },	{ P_ESCAPE_SPELL, P_SKILLED },
{ P_MATTER_SPELL, P_SKILLED },
#ifdef STEED
{ P_RIDING, P_BASIC },
#endif
{ P_TWO_WEAPON_COMBAT, P_EXPERT },
{ P_BARE_HANDED_COMBAT, P_EXPERT },
{ P_NONE, 0 }
};

Ranger max skill levels

static const struct def_skill Skill_Ran[] = {
{ P_DAGGER, P_EXPERT },		 { P_KNIFE,  P_SKILLED },
{ P_AXE, P_SKILLED },	 { P_PICK_AXE, P_BASIC },
{ P_SHORT_SWORD, P_BASIC },	 { P_MORNING_STAR, P_BASIC },
{ P_FLAIL, P_SKILLED },	 { P_HAMMER, P_BASIC },
{ P_QUARTERSTAFF, P_BASIC }, { P_POLEARMS, P_SKILLED },
{ P_SPEAR, P_SKILLED },	 { P_JAVELIN, P_EXPERT },
{ P_TRIDENT, P_BASIC },	 { P_BOW, P_EXPERT },
{ P_SLING, P_EXPERT },	 { P_CROSSBOW, P_EXPERT },
{ P_DART, P_EXPERT },	 { P_SHURIKEN, P_SKILLED },
{ P_BOOMERANG, P_EXPERT },	 { P_WHIP, P_BASIC },
{ P_HEALING_SPELL, P_BASIC },
{ P_DIVINATION_SPELL, P_EXPERT },
{ P_ESCAPE_SPELL, P_BASIC },
#ifdef STEED
{ P_RIDING, P_BASIC },
#endif
{ P_BARE_HANDED_COMBAT, P_BASIC },
{ P_NONE, 0 }
};

Samurai max skill levels

static const struct def_skill Skill_S[] = {
{ P_DAGGER, P_BASIC },		{ P_KNIFE,  P_SKILLED },
{ P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_SKILLED },
{ P_LONG_SWORD, P_EXPERT },		{ P_TWO_HANDED_SWORD, P_EXPERT },
{ P_SCIMITAR, P_BASIC },		{ P_SABER, P_BASIC },
{ P_FLAIL, P_SKILLED },		{ P_QUARTERSTAFF, P_BASIC },
{ P_POLEARMS, P_SKILLED },		{ P_SPEAR, P_BASIC },
{ P_JAVELIN, P_BASIC },		{ P_LANCE, P_SKILLED },
{ P_BOW, P_EXPERT },		{ P_SHURIKEN, P_EXPERT },
{ P_ATTACK_SPELL, P_SKILLED },	{ P_CLERIC_SPELL, P_SKILLED },
#ifdef STEED
{ P_RIDING, P_SKILLED },
#endif
{ P_TWO_WEAPON_COMBAT, P_EXPERT },
{ P_MARTIAL_ARTS, P_MASTER },
{ P_NONE, 0 }
};

Tourist max skill levels

#ifdef TOURIST
static const struct def_skill Skill_T[] = {
{ P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_SKILLED },
{ P_AXE, P_BASIC },			{ P_PICK_AXE, P_BASIC },
{ P_SHORT_SWORD, P_EXPERT },	{ P_BROAD_SWORD, P_BASIC },
{ P_LONG_SWORD, P_BASIC },		{ P_TWO_HANDED_SWORD, P_BASIC },
{ P_SCIMITAR, P_SKILLED },		{ P_SABER, P_SKILLED },
{ P_MACE, P_BASIC },		{ P_MORNING_STAR, P_BASIC },
{ P_FLAIL, P_BASIC },		{ P_HAMMER, P_BASIC },
{ P_QUARTERSTAFF, P_BASIC },	{ P_POLEARMS, P_BASIC },
{ P_SPEAR, P_BASIC },		{ P_JAVELIN, P_BASIC },
{ P_TRIDENT, P_BASIC },		{ P_LANCE, P_BASIC },
{ P_BOW, P_BASIC },			{ P_SLING, P_BASIC },
{ P_CROSSBOW, P_BASIC },		{ P_DART, P_EXPERT },
{ P_SHURIKEN, P_BASIC },		{ P_BOOMERANG, P_BASIC },
{ P_WHIP, P_BASIC },		{ P_UNICORN_HORN, P_SKILLED },
{ P_DIVINATION_SPELL, P_BASIC },	{ P_ENCHANTMENT_SPELL, P_BASIC },
{ P_ESCAPE_SPELL, P_SKILLED },
#ifdef STEED
{ P_RIDING, P_BASIC },
#endif
{ P_TWO_WEAPON_COMBAT, P_SKILLED },
{ P_BARE_HANDED_COMBAT, P_SKILLED },
{ P_NONE, 0 }
};
#endif /* TOURIST */

Valkyrie max skill levels

static const struct def_skill Skill_V[] = {
{ P_DAGGER, P_EXPERT },		{ P_AXE, P_EXPERT },
{ P_PICK_AXE, P_SKILLED },		{ P_SHORT_SWORD, P_SKILLED },
{ P_BROAD_SWORD, P_SKILLED },	{ P_LONG_SWORD, P_EXPERT },
{ P_TWO_HANDED_SWORD, P_EXPERT },	{ P_SCIMITAR, P_BASIC },
{ P_SABER, P_BASIC },		{ P_HAMMER, P_EXPERT },
{ P_QUARTERSTAFF, P_BASIC },	{ P_POLEARMS, P_SKILLED },
{ P_SPEAR, P_SKILLED },		{ P_JAVELIN, P_BASIC },
{ P_TRIDENT, P_BASIC },		{ P_LANCE, P_SKILLED },
{ P_SLING, P_BASIC },
{ P_ATTACK_SPELL, P_BASIC },	{ P_ESCAPE_SPELL, P_BASIC },
#ifdef STEED
{ P_RIDING, P_SKILLED },
#endif
{ P_TWO_WEAPON_COMBAT, P_SKILLED },
{ P_BARE_HANDED_COMBAT, P_EXPERT },
{ P_NONE, 0 }
};

Wizard max skill levels

static const struct def_skill Skill_W[] = {
{ P_DAGGER, P_EXPERT },		{ P_KNIFE,  P_SKILLED },
{ P_AXE, P_SKILLED },		{ P_SHORT_SWORD, P_BASIC },
{ P_CLUB, P_SKILLED },		{ P_MACE, P_BASIC },
{ P_QUARTERSTAFF, P_EXPERT },	{ P_POLEARMS, P_SKILLED },
{ P_SPEAR, P_BASIC },		{ P_JAVELIN, P_BASIC },
{ P_TRIDENT, P_BASIC },		{ P_SLING, P_SKILLED },
{ P_DART, P_EXPERT },		{ P_SHURIKEN, P_BASIC },
{ P_ATTACK_SPELL, P_EXPERT },	{ P_HEALING_SPELL, P_SKILLED },
{ P_DIVINATION_SPELL, P_EXPERT },	{ P_ENCHANTMENT_SPELL, P_SKILLED },
{ P_CLERIC_SPELL, P_SKILLED },	{ P_ESCAPE_SPELL, P_EXPERT },
{ P_MATTER_SPELL, P_EXPERT },
#ifdef STEED
{ P_RIDING, P_BASIC },
#endif
{ P_BARE_HANDED_COMBAT, P_BASIC },
{ P_NONE, 0 }
};

knows_object

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

knows_class

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

u_init

void
u_init()
{
	register int i;

	flags.female = flags.initgend;
	flags.beginner = 1;

	/* zero u, including pointer values --
	 * necessary when aborting from a failed restore */
	(void) memset((genericptr_t)&u, 0, sizeof(u));
	u.ustuck = (struct monst *)0;

#if 0	/* documentation of more zero values as desirable */
	u.usick_cause[0] = 0;
	u.uluck  = u.moreluck = 0;
# ifdef TOURIST
	uarmu = 0;
# endif
	uarm = uarmc = uarmh = uarms = uarmg = uarmf = 0;
	uwep = uball = uchain = uleft = uright = 0;
	uswapwep = uquiver = 0;
	u.twoweap = 0;
	u.ublessed = 0;				/* not worthy yet */
	u.ugangr   = 0;				/* gods not angry */
	u.ugifts   = 0;				/* no divine gifts bestowed */
# ifdef ELBERETH
	u.uevent.uhand_of_elbereth = 0;
# endif
	u.uevent.uheard_tune = 0;
	u.uevent.uopened_dbridge = 0;
	u.uevent.udemigod = 0;		/* not a demi-god yet... */
	u.udg_cnt = 0;
	u.mh = u.mhmax = u.mtimedone = 0;
	u.uz.dnum = u.uz0.dnum = 0;
	u.utotype = 0;
#endif	/* 0 */

	u.uz.dlevel = 1;
	u.uz0.dlevel = 0;
	u.utolev = u.uz;

	u.umoved = FALSE;
	u.umortality = 0;
	u.ugrave_arise = NON_PM;

	u.umonnum = u.umonster = (flags.female &&
			urole.femalenum != NON_PM) ? urole.femalenum :
			urole.malenum;
	set_uasmon();

	u.ulevel = 0;	/* set up some of the initial attributes */
	u.uhp = u.uhpmax = newhp();
	u.uenmax = urole.enadv.infix + urace.enadv.infix;
	if (urole.enadv.inrnd > 0)
	    u.uenmax += rnd(urole.enadv.inrnd);
	if (urace.enadv.inrnd > 0)
	    u.uenmax += rnd(urace.enadv.inrnd);
	u.uen = u.uenmax;
	u.uspellprot = 0;
	adjabil(0,1);
	u.ulevel = u.ulevelmax = 1;

	init_uhunger();
	for (i = 0; i <= MAXSPELL; i++) spl_book[i].sp_id = NO_SPELL;
	u.ublesscnt = 300;			/* no prayers just yet */
	u.ualignbase[A_CURRENT] = u.ualignbase[A_ORIGINAL] = u.ualign.type =
			aligns[flags.initalign].value;
	u.ulycn = NON_PM;

#if defined(BSD) && !defined(POSIX_TYPES)
	(void) time((long *)&u.ubirthday);
#else
	(void) time(&u.ubirthday);
#endif

	/*
	 *  For now, everyone starts out with a night vision range of 1 and
	 *  their xray range disabled.
	 */
	u.nv_range   =  1;
	u.xray_range = -1;

Role-specific initializations

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

Archeologist initializations

	case PM_ARCHEOLOGIST:
		ini_inv(Archeologist);
		if(!rn2(10)) ini_inv(Tinopener);
		else if(!rn2(4)) ini_inv(Lamp);
		else if(!rn2(10)) ini_inv(Magicmarker);
		knows_object(SACK);
		knows_object(TOUCHSTONE);
		skill_init(Skill_A);
		break;

Barbarian initializations

	case PM_BARBARIAN:
		if (rn2(100) >= 50) {	/* see above comment */
		    Barbarian[B_MAJOR].trotyp = BATTLE_AXE;
		    Barbarian[B_MINOR].trotyp = SHORT_SWORD;
		}
		ini_inv(Barbarian);
		if(!rn2(6)) ini_inv(Lamp);
		knows_class(WEAPON_CLASS);
		knows_class(ARMOR_CLASS);
		skill_init(Skill_B);
		break;

Caveman initializations

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

Healer initializations

	case PM_HEALER:
#ifndef GOLDOBJ
		u.ugold = u.ugold0 = rn1(1000, 1001);
#else
		u.umoney0 = rn1(1000, 1001);
#endif
		ini_inv(Healer);
		if(!rn2(25)) ini_inv(Lamp);
		knows_object(POT_FULL_HEALING);
		skill_init(Skill_H);
		break;

Knight initializations

	case PM_KNIGHT:
		ini_inv(Knight);
		knows_class(WEAPON_CLASS);
		knows_class(ARMOR_CLASS);
		/* give knights chess-like mobility
		 * -- idea from wooledge@skybridge.scl.cwru.edu */
		HJumping |= FROMOUTSIDE;
		skill_init(Skill_K);
		break;

Monk initializations

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

Priest initializations

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

Ranger initializations

	case PM_RANGER:
		Ranger[RAN_TWO_ARROWS].trquan = rn1(10, 50);
		Ranger[RAN_ZERO_ARROWS].trquan = rn1(10, 30);
		ini_inv(Ranger);
		skill_init(Skill_Ran);
		break;

Rogue initializations

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

Samurai initializations

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

Tourist initializations

#ifdef TOURIST
	case PM_TOURIST:
		Tourist[T_DARTS].trquan = rn1(20, 21);
#ifndef GOLDOBJ
		u.ugold = u.ugold0 = rnd(1000);
#else
		u.umoney0 = rnd(1000);
#endif
		ini_inv(Tourist);
		if(!rn2(25)) ini_inv(Tinopener);
		else if(!rn2(25)) ini_inv(Leash);
		else if(!rn2(25)) ini_inv(Towel);
		else if(!rn2(25)) ini_inv(Magicmarker);
		skill_init(Skill_T);
		break;
#endif

Valkyrie initializations

	case PM_VALKYRIE:
		ini_inv(Valkyrie);
		if(!rn2(6)) ini_inv(Lamp);
		knows_class(WEAPON_CLASS);
		knows_class(ARMOR_CLASS);
		skill_init(Skill_V);
		break;

Wizard initializations

	case PM_WIZARD:
		ini_inv(Wizard);
		if(!rn2(5)) ini_inv(Magicmarker);
		if(!rn2(5)) ini_inv(Blindfold);
		skill_init(Skill_W);
		break;

	default:	/* impossible */
		break;
	}

Race-specific initializations

	/*** Race-specific initializations ***/
	switch (Race_switch) {

Human initializations

	case PM_HUMAN:
	    /* Nothing special */
	    break;

Elf initializations

	case PM_ELF:
	    /*
	     * Elves are people of music and song, or they are warriors.
	     * Non-warriors get an instrument.  We use a kludge to
	     * get only non-magic instruments.
	     */
	    if (Role_if(PM_PRIEST) || Role_if(PM_WIZARD)) {
		static int trotyp[] = {
		    WOODEN_FLUTE, TOOLED_HORN, WOODEN_HARP,
		    BELL, BUGLE, LEATHER_DRUM
		};
		Instrument[0].trotyp = trotyp[rn2(SIZE(trotyp))];
		ini_inv(Instrument);
	    }

	    /* Elves can recognize all elvish objects */
	    knows_object(ELVEN_SHORT_SWORD);
	    knows_object(ELVEN_ARROW);
	    knows_object(ELVEN_BOW);
	    knows_object(ELVEN_SPEAR);
	    knows_object(ELVEN_DAGGER);
	    knows_object(ELVEN_BROADSWORD);
	    knows_object(ELVEN_MITHRIL_COAT);
	    knows_object(ELVEN_LEATHER_HELM);
	    knows_object(ELVEN_SHIELD);
	    knows_object(ELVEN_BOOTS);
	    knows_object(ELVEN_CLOAK);
	    break;

Dwarf initializations

	case PM_DWARF:
	    /* Dwarves can recognize all dwarvish objects */
	    knows_object(DWARVISH_SPEAR);
	    knows_object(DWARVISH_SHORT_SWORD);
	    knows_object(DWARVISH_MATTOCK);
	    knows_object(DWARVISH_IRON_HELM);
	    knows_object(DWARVISH_MITHRIL_COAT);
	    knows_object(DWARVISH_CLOAK);
	    knows_object(DWARVISH_ROUNDSHIELD);
	    break;

Gnome initializations

	case PM_GNOME:
	    break;

Orc initializations

	case PM_ORC:
	    /* compensate for generally inferior equipment */
	    if (!Role_if(PM_WIZARD))
		ini_inv(Xtra_food);
	    /* Orcs can recognize all orcish objects */
	    knows_object(ORCISH_SHORT_SWORD);
	    knows_object(ORCISH_ARROW);
	    knows_object(ORCISH_BOW);
	    knows_object(ORCISH_SPEAR);
	    knows_object(ORCISH_DAGGER);
	    knows_object(ORCISH_CHAIN_MAIL);
	    knows_object(ORCISH_RING_MAIL);
	    knows_object(ORCISH_HELM);
	    knows_object(ORCISH_SHIELD);
	    knows_object(URUK_HAI_SHIELD);
	    knows_object(ORCISH_CLOAK);
	    break;

	default:	/* impossible */
		break;
	}

	if (discover)
		ini_inv(Wishing);

#ifdef WIZARD
	if (wizard)
		read_wizkit();
#endif

#ifndef GOLDOBJ
	u.ugold0 += hidden_gold();	/* in case sack has gold in it */
#else
	if (u.umoney0) ini_inv(Money);
	u.umoney0 += hidden_gold();	/* in case sack has gold in it */
#endif

	find_ac();			/* get initial ac value */
	init_attr(75);			/* init attribute values */
	max_rank_sz();			/* set max str size for class ranks */
/*
*	Do we really need this?
*/
	for(i = 0; i < A_MAX; i++)
	    if(!rn2(20)) {
		register int xd = rn2(7) - 2;	/* biased variation */
		(void) adjattrib(i, xd, TRUE);
		if (ABASE(i) < AMAX(i)) AMAX(i) = ABASE(i);
	    }

	/* make sure you can carry all you have - especially for Tourists */
	while (inv_weight() > 0) {
		if (adjattrib(A_STR, 1, TRUE)) continue;
		if (adjattrib(A_CON, 1, TRUE)) continue;
		/* only get here when didn't boost strength or constitution */
		break;
	}

	return;
}

restricted_spell_discipline

/* skills aren't initialized, so we use the role-specific skill lists */
STATIC_OVL boolean
restricted_spell_discipline(otyp)
int otyp;
{
const struct def_skill *skills;
int this_skill = spell_skilltype(otyp);

switch (Role_switch) {
case PM_ARCHEOLOGIST:	skills = Skill_A; break;
case PM_BARBARIAN:		skills = Skill_B; break;
case PM_CAVEMAN:		skills = Skill_C; break;
case PM_HEALER:		skills = Skill_H; break;
case PM_KNIGHT:		skills = Skill_K; break;
case PM_MONK:		skills = Skill_Mon; break;
case PM_PRIEST:		skills = Skill_P; break;
case PM_RANGER:		skills = Skill_Ran; break;
case PM_ROGUE:		skills = Skill_R; break;
case PM_SAMURAI:		skills = Skill_S; break;
#ifdef TOURIST
case PM_TOURIST:		skills = Skill_T; break;
#endif
case PM_VALKYRIE:		skills = Skill_V; break;
case PM_WIZARD:		skills = Skill_W; break;
default:			skills = 0; break;	/* lint suppression */
}

while (skills->skill != P_NONE) {
	if (skills->skill == this_skill) return FALSE;
	++skills;
}
return TRUE;
}

ini_inv

STATIC_OVL void
ini_inv(trop)
register struct trobj *trop;
{
	struct obj *obj;
	int otyp, i;

	while (trop->trclass) {
		if (trop->trotyp != UNDEF_TYP) {
			otyp = (int)trop->trotyp;
			if (urace.malenum != PM_HUMAN) {
			    /* substitute specific items for generic ones */
			    for (i = 0; inv_subs[i].race_pm != NON_PM; ++i)
				if (inv_subs[i].race_pm == urace.malenum &&
					otyp == inv_subs[i].item_otyp) {
				    otyp = inv_subs[i].subs_otyp;
				    break;
				}
			}
			obj = mksobj(otyp, TRUE, FALSE);
		} else {	/* UNDEF_TYP */
			static NEARDATA short nocreate = STRANGE_OBJECT;
			static NEARDATA short nocreate2 = STRANGE_OBJECT;
			static NEARDATA short nocreate3 = STRANGE_OBJECT;
			static NEARDATA short nocreate4 = STRANGE_OBJECT;
		/*
		 * For random objects, do not create certain overly powerful
		 * items: wand of wishing, ring of levitation, or the
		 * polymorph/polymorph control combination.  Specific objects,
		 * i.e. the discovery wishing, are still OK.
		 * Also, don't get a couple of really useless items.  (Note:
		 * punishment isn't "useless".  Some players who start out with
		 * one will immediately read it and use the iron ball as a
		 * weapon.)
		 */
			obj = mkobj(trop->trclass, FALSE);
			otyp = obj->otyp;
			while (otyp == WAN_WISHING
				|| otyp == nocreate
				|| otyp == nocreate2
				|| otyp == nocreate3
				|| otyp == nocreate4
#ifdef ELBERETH
				|| otyp == RIN_LEVITATION
#endif
				/* 'useless' items */
				|| otyp == POT_HALLUCINATION
				|| otyp == POT_ACID
				|| otyp == SCR_AMNESIA
				|| otyp == SCR_FIRE
				|| otyp == SCR_BLANK_PAPER
				|| otyp == SPE_BLANK_PAPER
				|| otyp == RIN_AGGRAVATE_MONSTER
				|| otyp == RIN_HUNGER
				|| otyp == WAN_NOTHING
				/* Monks don't use weapons */
				|| (otyp == SCR_ENCHANT_WEAPON &&
				    Role_if(PM_MONK))
				/* wizard patch -- they already have one */
				|| (otyp == SPE_FORCE_BOLT &&
				    Role_if(PM_WIZARD))
				/* powerful spells are either useless to
				   low level players or unbalancing; also
				   spells in restricted skill categories */
				|| (obj->oclass == SPBOOK_CLASS &&
				    (objects[otyp].oc_level > 3 ||
				    restricted_spell_discipline(otyp)))
							) {
				dealloc_obj(obj);
				obj = mkobj(trop->trclass, FALSE);
				otyp = obj->otyp;
			}

			/* Don't start with +0 or negative rings */
			if (objects[otyp].oc_charged && obj->spe <= 0)
				obj->spe = rne(3);

			/* Heavily relies on the fact that 1) we create wands
			 * before rings, 2) that we create rings before
			 * spellbooks, and that 3) not more than 1 object of a
			 * particular symbol is to be prohibited.  (For more
			 * objects, we need more nocreate variables...)
			 */
			switch (otyp) {
			    case WAN_POLYMORPH:
			    case RIN_POLYMORPH:
			    case POT_POLYMORPH:
				nocreate = RIN_POLYMORPH_CONTROL;
				break;
			    case RIN_POLYMORPH_CONTROL:
				nocreate = RIN_POLYMORPH;
				nocreate2 = SPE_POLYMORPH;
				nocreate3 = POT_POLYMORPH;
			}
			/* Don't have 2 of the same ring or spellbook */
			if (obj->oclass == RING_CLASS ||
			    obj->oclass == SPBOOK_CLASS)
				nocreate4 = otyp;
		}

#ifdef GOLDOBJ
		if (trop->trclass == COIN_CLASS) {
			/* no "blessed" or "identified" money */
			obj->quan = u.umoney0;
		} else {
#endif
			obj->dknown = obj->bknown = obj->rknown = 1;
			if (objects[otyp].oc_uses_known) obj->known = 1;
			obj->cursed = 0;
			if (obj->opoisoned && u.ualign.type != A_CHAOTIC)
			    obj->opoisoned = 0;
			if (obj->oclass == WEAPON_CLASS ||
				obj->oclass == TOOL_CLASS) {
			    obj->quan = (long) trop->trquan;
			    trop->trquan = 1;
			} else if (obj->oclass == GEM_CLASS &&
				is_graystone(obj) && obj->otyp != FLINT) {
			    obj->quan = 1L;
			}
			if (trop->trspe != UNDEF_SPE)
			    obj->spe = trop->trspe;
			if (trop->trbless != UNDEF_BLESS)
			    obj->blessed = trop->trbless;
#ifdef GOLDOBJ
		}
#endif
		/* defined after setting otyp+quan + blessedness */
		obj->owt = weight(obj);
		obj = addinv(obj);

		/* Make the type known if necessary */
		if (OBJ_DESCR(objects[otyp]) && obj->known)
			discover_object(otyp, TRUE, FALSE);
		if (otyp == OIL_LAMP)
			discover_object(POT_OIL, TRUE, FALSE);

		if(obj->oclass == ARMOR_CLASS){
			if (is_shield(obj) && !uarms) {
				setworn(obj, W_ARMS);
				if (uswapwep) setuswapwep((struct obj *) 0);
			} else if (is_helmet(obj) && !uarmh)
				setworn(obj, W_ARMH);
			else if (is_gloves(obj) && !uarmg)
				setworn(obj, W_ARMG);
#ifdef TOURIST
			else if (is_shirt(obj) && !uarmu)
				setworn(obj, W_ARMU);
#endif
			else if (is_cloak(obj) && !uarmc)
				setworn(obj, W_ARMC);
			else if (is_boots(obj) && !uarmf)
				setworn(obj, W_ARMF);
			else if (is_suit(obj) && !uarm)
				setworn(obj, W_ARM);
		}

		if (obj->oclass == WEAPON_CLASS || is_weptool(obj) ||
			otyp == TIN_OPENER || otyp == FLINT || otyp == ROCK) {
		    if (is_ammo(obj) || is_missile(obj)) {
			if (!uquiver) setuqwep(obj);
		    } else if (!uwep) setuwep(obj);
		    else if (!uswapwep) setuswapwep(obj);
		}
		if (obj->oclass == SPBOOK_CLASS &&
				obj->otyp != SPE_BLANK_PAPER)
		    initialspell(obj);

#if !defined(PYRAMID_BUG) && !defined(MAC)
		if(--trop->trquan) continue;	/* make a similar object */
#else
		if(trop->trquan) {		/* check if zero first */
			--trop->trquan;
			if(trop->trquan)
				continue;	/* make a similar object */
		}
#endif
		trop++;
	}
}

/*u_init.c*/