Source:NetHack 3.3.0/u init.c

From NetHackWiki
(Redirected from NetHack 3.3.0/u init.c)
Jump to navigation Jump to search

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

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

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