Source:NetHack 3.0.0/u init.c

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to u_init.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.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.0	88/04/13
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.    	unsigned short int trotyp;
9.    	schar trspe;
10.   	char trolet;
11.   	Bitfield(trquan,6);
12.   	Bitfield(trknown,1);
13.   	Bitfield(trbless,2);
14.   };
15.   
16.   static void ini_inv P((struct trobj *));
17.   
18.   #define	UNDEF_TYP	0
19.   #define	UNDEF_SPE	'\177'
20.   #define	UNDEF_BLESS	2
21.   
22.   char *(roles[]) = {	/* must all have distinct first letter */
23.   			/* roles[2] and [6] are changed for females */
24.   			/* in all cases, the corresponding male and female */
25.   			/* roles must start with the same letter */
26.   	"Archeologist", "Barbarian", "Cave-man", "Elf", "Healer", "Knight",
27.   	"Priest", "Rogue", "Samurai", "Tourist", "Valkyrie", "Wizard"
28.   };
29.   
30.   struct you zerou;
31.   
32.   #define	NR_OF_ROLES	SIZE(roles)
33.   char rolesyms[NR_OF_ROLES + 1];		/* filled by u_init() */
34.   
35.   struct trobj Cave_man[] = {
36.   #define C_ARROWS	2
37.   	{ CLUB, 1, WEAPON_SYM, 1, 1, UNDEF_BLESS },
38.   	{ BOW, 1, WEAPON_SYM, 1, 1, UNDEF_BLESS },
39.   	{ ARROW, 0, WEAPON_SYM, 25, 1, UNDEF_BLESS },	/* quan is variable */
40.   	{ LEATHER_ARMOR, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
41.   	{ 0, 0, 0, 0, 0, 0 }
42.   };
43.   
44.   struct trobj Barbarian[] = {
45.   	{ TWO_HANDED_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
46.   	{ AXE, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
47.   	{ RING_MAIL, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
48.   	{ FOOD_RATION, 0, FOOD_SYM, 1, 1, 0 },
49.   	{ 0, 0, 0, 0, 0, 0 }
50.   };
51.   
52.   struct trobj Knight[] = {
53.   	{ LONG_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
54.   	{ SPEAR, 2, WEAPON_SYM, 1, 1, UNDEF_BLESS },
55.   	{ RING_MAIL, 1, ARMOR_SYM, 1, 1, UNDEF_BLESS },
56.   	{ HELMET, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
57.   	{ SMALL_SHIELD, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
58.   	{ LEATHER_GLOVES, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
59.   	{ 0, 0, 0, 0, 0, 0 }
60.   };
61.   
62.   struct trobj Elf[] = {
63.   #define E_ARROWS	2
64.   #define E_ARMOR		3
65.   #ifdef TOLKIEN
66.   	{ ELVEN_SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
67.   	{ ELVEN_BOW, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
68.   	{ ELVEN_ARROW, 0, WEAPON_SYM, 25, 1, UNDEF_BLESS },
69.   	{ UNDEF_TYP, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
70.   	{ LEMBAS_WAFER, 0, FOOD_SYM, 2, 1, 0 },
71.   #else
72.   	{ SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
73.   	{ BOW, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
74.   	{ ARROW, 0, WEAPON_SYM, 25, 1, UNDEF_BLESS },
75.   	{ ELVEN_CLOAK, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
76.   	{ FOOD_RATION, 0, FOOD_SYM, 2, 1, 0 },
77.   #endif
78.   	{ 0, 0, 0, 0, 0, 0 }
79.   };
80.   
81.   struct trobj Valkyrie[] = {
82.   	{ LONG_SWORD, 1, WEAPON_SYM, 1, 1, UNDEF_BLESS },
83.   	{ DAGGER, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
84.   	{ SMALL_SHIELD, 3, ARMOR_SYM, 1, 1, UNDEF_BLESS },
85.   	{ FOOD_RATION, 0, FOOD_SYM, 1, 1, 0 },
86.   	{ 0, 0, 0, 0, 0, 0 }
87.   };
88.   
89.   struct trobj Healer[] = {
90.   	{ SCALPEL, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
91.   	{ LEATHER_GLOVES, 1, ARMOR_SYM, 1, 1, UNDEF_BLESS },
92.   	{ STETHOSCOPE, 0, TOOL_SYM, 1, 1, 0 },
93.   	{ POT_HEALING, 0, POTION_SYM, 4, 1, UNDEF_BLESS },
94.   	{ POT_EXTRA_HEALING, 0, POTION_SYM, 4, 1, UNDEF_BLESS },
95.   	{ WAN_SLEEP, UNDEF_SPE, WAND_SYM, 1, 1, UNDEF_BLESS },
96.   	{ APPLE, 0, FOOD_SYM, 5, 1, 0 },
97.   	{ 0, 0, 0, 0, 0, 0 }
98.   };
99.   
100.  struct trobj Archeologist[] = {
101.  	/* if adventure has a name...  idea from tan@uvm-gen */
102.  	{ BULLWHIP, 2, WEAPON_SYM, 1, 1, UNDEF_BLESS },
103.  	{ LEATHER_ARMOR, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
104.  	{ FEDORA, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
105.  	{ FOOD_RATION, 0, FOOD_SYM, 3, 1, 0 },
106.  	{ PICK_AXE, UNDEF_SPE, TOOL_SYM, 1, 1, UNDEF_BLESS },
107.  	{ TINNING_KIT, 0, TOOL_SYM, 1, 1, UNDEF_BLESS },
108.  	{ SACK, 0, TOOL_SYM, 1, 0, 0 },
109.  	{ 0, 0, 0, 0, 0, 0 }
110.  };
111.  
112.  struct trobj Tinopener[] = {
113.  	{ TIN_OPENER, 0, TOOL_SYM, 1, 1, 0 },
114.  	{ 0, 0, 0, 0, 0, 0 }
115.  };
116.  
117.  struct trobj Magicmarker[] = {
118.  	{ MAGIC_MARKER, UNDEF_SPE, TOOL_SYM, 1, 1, 0 },
119.  	{ 0, 0, 0, 0, 0, 0 }
120.  };
121.  
122.  struct trobj Lamp[] = {
123.  	{ LAMP, 5, TOOL_SYM, 1, 1, 0 },
124.  	{ 0, 0, 0, 0, 0, 0 }
125.  };
126.  
127.  #ifndef HARD
128.  struct trobj Saving[] = {
129.  	{ AMULET_OF_LIFE_SAVING, 0, TOOL_SYM, 1, 1, 0 },
130.  	{ 0, 0, 0, 0, 0, 0 }
131.  };
132.  #endif
133.  
134.  #ifdef EXPLORE_MODE
135.  struct trobj Wishing[] = {
136.  	{ WAN_WISHING, 3, WAND_SYM, 1, 1, 0 },
137.  	{ 0, 0, 0, 0, 0, 0 }
138.  };
139.  #endif
140.  
141.  #ifdef WALKIES
142.  struct trobj Leash[] = {
143.  	{ LEASH, 0, TOOL_SYM, 1, 1, 0 },
144.  	{ 0, 0, 0, 0, 0, 0 }
145.  };
146.  #endif
147.  
148.  struct trobj Blindfold[] = {
149.  	{ BLINDFOLD, 0, TOOL_SYM, 1, 1, 0 },
150.  	{ 0, 0, 0, 0, 0, 0 }
151.  };
152.  
153.  struct trobj Tourist[] = {
154.  #define	T_DARTS		0
155.  	{ DART, 2, WEAPON_SYM, 25, 1, UNDEF_BLESS },	/* quan is variable */
156.  	{ UNDEF_TYP, UNDEF_SPE, FOOD_SYM, 10, 1, 0 },
157.  	{ POT_EXTRA_HEALING, 0, POTION_SYM, 2, 1, UNDEF_BLESS },
158.  	{ SCR_MAGIC_MAPPING, 0, SCROLL_SYM, 4, 1, UNDEF_BLESS },
159.  	{ EXPENSIVE_CAMERA, 0, TOOL_SYM, 1, 1, 0 },
160.  #ifdef SHIRT
161.  	{ HAWAIIAN_SHIRT, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
162.  #endif
163.  	{ CREDIT_CARD, 0, TOOL_SYM, 1, 1, 0 },
164.  	{ 0, 0, 0, 0, 0, 0 }
165.  };
166.  
167.  struct trobj Rogue[] = {
168.  #define R_DAGGERS	1
169.  	{ SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
170.  	{ DAGGER, 0, WEAPON_SYM, 10, 1, 0 },	/* quan is variable */
171.  	{ LEATHER_ARMOR, 1, ARMOR_SYM, 1, 1, UNDEF_BLESS },
172.  	{ POT_SICKNESS, 0, POTION_SYM, 1, 1, 0 },
173.  	{ LOCK_PICK, 9, TOOL_SYM, 1, 1, 0 },
174.  	{ SACK, 0, TOOL_SYM, 1, 0, 0 },
175.  	{ 0, 0, 0, 0, 0, 0 }
176.  };
177.  
178.  struct trobj Wizard[] = {
179.  #define W_MULTSTART	2
180.  #ifdef SPELLS
181.  #  define W_MULTEND	6
182.  #else
183.  #  define W_MULTEND	5
184.  #endif
185.  	{ DAGGER, 0, WEAPON_SYM, 1, 1, 1 },	/* for dealing with ghosts */
186.  	{ CLOAK_OF_MAGIC_RESISTANCE, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
187.  	{ UNDEF_TYP, UNDEF_SPE, WAND_SYM, 1, 1, UNDEF_BLESS },
188.  	{ UNDEF_TYP, UNDEF_SPE, RING_SYM, 2, 1, UNDEF_BLESS },
189.  	{ UNDEF_TYP, UNDEF_SPE, POTION_SYM, 3, 1, UNDEF_BLESS },
190.  	{ UNDEF_TYP, UNDEF_SPE, SCROLL_SYM, 3, 1, UNDEF_BLESS },
191.  #ifdef SPELLS
192.  	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_SYM, 1, 1, UNDEF_BLESS },
193.  #endif
194.  	{ 0, 0, 0, 0, 0, 0 }
195.  };
196.  
197.  struct	trobj	Samurai[] = {
198.  	{ KATANA, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
199.  	{ SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },	/* the wakizashi */
200.  	{ SHURIKEN, 0, WEAPON_SYM, 9, 1, UNDEF_BLESS },        /* quan is variable */
201.  	{ SPLINT_MAIL, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
202.  	{ FORTUNE_COOKIE, 0, FOOD_SYM, 3, 1, 0 },
203.  	{ 0, 0, 0, 0, 0, 0 }
204.  };
205.  
206.  struct	trobj	Priest[] = {
207.  	{ MACE, 1, WEAPON_SYM, 1, 1, 1 },
208.  	{ CHAIN_MAIL, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
209.  	{ SMALL_SHIELD, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
210.  	{ POT_WATER, 0, POTION_SYM, 4, 1, 1 },	/* holy water */
211.  	{ CLOVE_OF_GARLIC, 0, FOOD_SYM, 1, 1, 0 },
212.  #ifdef SPELLS
213.  	{ UNDEF_TYP, UNDEF_SPE, SPBOOK_SYM, 2, 1, UNDEF_BLESS },
214.  #endif
215.  	{ 0, 0, 0, 0, 0, 0 }
216.  };
217.  
218.  static void
219.  knows_class(sym)
220.  register char sym;
221.  {
222.  	register unsigned ct;
223.  	for (ct = 1; ct <= NROFOBJECTS; ct++)
224.  		if (objects[ct].oc_olet == sym) {
225.  			makeknown(ct);
226.  			objects[ct].oc_descr = NULL;	/* not a "discovery" */
227.  		}
228.  }
229.  
230.  static int
231.  role_index(pc)
232.  char pc;
233.  {		/* must be called only from u_init() */
234.  		/* so that rolesyms[] is defined */
235.  	register char *cp;
236.  
237.  	if(cp = index(rolesyms, pc))
238.  		return(cp - rolesyms);
239.  	return(-1);
240.  }
241.  
242.  void
243.  u_init()
244.  {
245.  	register int i;
246.  	char pick, pc;
247.  
248.  	Printf("\nNetHack, Copyright 1985, 1986, 1987, 1988, 1989.");
249.  	Printf("\n         By Stichting Mathematisch Centrum and M. Stephenson.");
250.  	Printf("\n         See license for details.\n\n");
251.  
252.  	if(flags.female)  {	/* should have been set in NETHACKOPTIONS */
253.  		roles[2] = "Cave-woman";
254.  		roles[6] = "Priestess";
255.  	}
256.  	for(i = 0; i < NR_OF_ROLES; i++)
257.  		rolesyms[i] = roles[i][0];
258.  	rolesyms[i] = 0;
259.  
260.  	if(pc = pl_character[0]) {
261.  		if('a' <= pc && pc <= 'z') pc += 'A'-'a';
262.  		if((i = role_index(pc)) >= 0)
263.  			goto got_suffix;
264.  		Printf("\nUnknown role: %c\n", pc);
265.  		pl_character[0] = pc = 0;
266.  	}
267.  
268.  	Printf("\nShall I pick a character for you? [Y,N, or Q(quit)] ");
269.  
270.  	while(!index("yYnNqQ", (pick = readchar())) && !index(quitchars, pick))
271.  		bell();
272.  
273.  	if(index(quitchars, pick)) pick = 'Y';
274.  	else if('a' <= pick && pick <= 'z') pick += 'A'-'a';
275.  
276.  	Printf("%c\n", pick);		/* echo */
277.  
278.  	if (pick == 'Q') {
279.  		clearlocks();
280.  		settty(NULL);
281.  		exit(0);
282.  	}
283.  
284.  	if (pick == 'Y')
285.  		goto beginner;
286.  
287.  	Printf("\nWhat kind of character are you:\n\n");
288.  	Printf("         An");
289.  	Printf(" %s,",roles[0]);
290.  	for(i = 1; i < NR_OF_ROLES; i++) {
291.  		Printf(" a%s %s", index(vowels,roles[i][0]) ? "n" : "", roles[i]);
292.  		if((((i + 1) % 4) == 0) && (i != NR_OF_ROLES -1)) Printf(",\n        ");
293.  		else if(i < NR_OF_ROLES - 2)	Printf(",");
294.  		if(i == NR_OF_ROLES - 2)	Printf(" or");
295.  	}
296.  	Printf("?\n         [");
297.  	for(i = 0; i < NR_OF_ROLES; i++) Printf("%c,", rolesyms[i]);
298.  	Printf(" or Q] ");
299.  
300.  	while(pc = readchar()) {
301.  		if('a' <= pc && pc <= 'z') pc += 'A'-'a';
302.  		if (pc == 'Q') {
303.  			clearlocks();
304.  			settty(NULL);
305.  			exit(0);
306.  		}
307.  		if((i = role_index(pc)) >= 0) {
308.  			Printf("%c\n", pc);	/* echo */
309.  			(void) fflush(stdout);	/* should be seen */
310.  			break;
311.  		}
312.  		if(pc == '\n') break;
313.  		bell();
314.  	}
315.  	if(pc == '\n')	pc = 0;
316.  
317.  beginner:
318.  	if(!pc) {
319.  		i = rn2(NR_OF_ROLES);
320.  		pc = rolesyms[i];
321.  		Printf("\nThis game you will be %s %s.\n",
322.  			index("AEIOU", roles[i][0]) ? "an" : "a",
323.  			roles[i]);
324.  		getret();
325.  		/* give him some feedback in case mklev takes much time */
326.  		(void) putchar('\n');
327.  		(void) fflush(stdout);
328.  	}
329.  
330.  got_suffix:
331.  
332.  	(void) strncpy(pl_character, roles[i], PL_CSIZ-1);
333.  	pl_character[PL_CSIZ-1] = 0;
334.  	flags.beginner = 1;
335.  	u = zerou;
336.  	u.usym = S_HUMAN;
337.  	u.umoved = FALSE;
338.  	u.ugrave_arise = -1;
339.  
340.  	u.ulevel = 0;	/* set up some of the initial attributes */
341.  	u.uhp = u.uhpmax = newhp();
342.  	adjabil(1);
343.  	u.ulevel = 1;
344.  
345.  	u.uluck  = u.moreluck = 0;
346.  	init_uhunger();
347.  	uarm = uarmc = uarmh = uarms = uarmg = uarmf =
348.  #ifdef SHIRT
349.  	uarmu =
350.  #endif
351.  	uwep = uball = uchain = uleft = uright = 0;
352.  
353.  #ifdef SPELLS
354.  	u.uen = u.uenmax = 1;
355.  	for (i = 0; i <= MAXSPELL; i++) spl_book[i].sp_id = NO_SPELL;
356.  #endif
357.  #ifdef THEOLOGY
358.  	u.ublesscnt = 300;			/* no prayers just yet */
359.  	u.ublessed = 0;				/* not worthy yet */
360.  	u.ugangr   = 0;				/* gods not angry */
361.  #endif
362.  #if defined(THEOLOGY) && defined(ELBERETH)
363.  	u.uhand_of_elbereth = 0;
364.  #endif
365.  #ifdef MEDUSA
366.  	u.ukilled_medusa = 0;
367.  #endif
368.  #ifdef HARD
369.  	u.udemigod = u.udg_cnt = 0;		/* not a demi-god yet... */
370.  #endif
371.  #ifdef POLYSELF
372.  	u.umonnum = u.ulycn = -1;
373.  	u.mh = u.mhmax = u.mtimedone = 0;
374.  	set_uasmon();
375.  #endif
376.  	switch(pc) {
377.  	/* pc will always be in uppercase by this point */
378.  	case 'C':
379.  		Cave_man[C_ARROWS].trquan = 12 + rnd(30);
380.  		ini_inv(Cave_man);
381.  		break;
382.  	case 'T':
383.  		Tourist[T_DARTS].trquan = 20 + rnd(20);
384.  		u.ugold = u.ugold0 = rnd(1000);
385.  		ini_inv(Tourist);
386.  		if(!rn2(25)) ini_inv(Tinopener);
387.  		else if(!rn2(25)) ini_inv(Magicmarker);
388.  #ifdef WALKIES
389.  		else if(!rn2(25)) ini_inv(Leash);
390.  #endif
391.  		break;
392.  	case 'R':
393.  		Rogue[R_DAGGERS].trquan = 5 + rnd(10);
394.  		u.ugold = u.ugold0 = 0;
395.  		ini_inv(Rogue);
396.  		if(!rn2(5)) ini_inv(Blindfold);
397.  		makeknown(SACK);
398.  		break;
399.  	case 'W':
400.  #ifdef SPELLS
401.  		u.uen = u.uenmax += rn2(4);
402.  #endif
403.  		ini_inv(Wizard);
404.  		if(!rn2(5)) ini_inv(Magicmarker);
405.  		if(!rn2(5)) ini_inv(Blindfold);
406.  		break;
407.  	case 'A':
408.  		ini_inv(Archeologist);
409.  		if(!rn2(10)) ini_inv(Tinopener);
410.  		else if(!rn2(4)) ini_inv(Lamp);
411.  		else if(!rn2(10)) ini_inv(Magicmarker);
412.  		knows_class(GEM_SYM);
413.  		makeknown(SACK);
414.  		/* We can't set trknown for it, then it'd be "uncursed"
415.  		 * sack...
416.  		 */
417.  		break;
418.  	case 'E':
419.  		Elf[E_ARROWS].trquan = 15+rnd(20);
420.  #ifdef TOLKIEN
421.  		Elf[E_ARMOR].trotyp = ((rn2(100) >= 50)
422.  				 ? ELVEN_MITHRIL_COAT : ELVEN_CLOAK);
423.  			/* rn2(100) > 50 necessary because some random number
424.  			 * generators are bad enough to seriously skew the
425.  			 * results if we use rn2(2)...  --KAA
426.  			 */
427.  #endif
428.  		ini_inv(Elf);
429.  		if(!rn2(5)) ini_inv(Blindfold);
430.  		else if(!rn2(6)) ini_inv(Lamp);
431.  #ifdef TOLKIEN
432.  		/* makeknown(ELVEN_SHORT_SWORD);
433.  		 * no need to do this since the initial inventory contains one,
434.  		 * so ini_inv already did it for us
435.  		 */
436.  		objects[ELVEN_SHORT_SWORD].oc_descr = NULL;
437.  		/* makeknown(ELVEN_ARROW); */
438.  		objects[ELVEN_ARROW].oc_descr = NULL;
439.  		/* makeknown(ELVEN_BOW); */
440.  		objects[ELVEN_BOW].oc_descr = NULL;
441.  		makeknown(ELVEN_SPEAR);
442.  		objects[ELVEN_SPEAR].oc_descr = NULL;
443.  		makeknown(ELVEN_DAGGER);
444.  		objects[ELVEN_DAGGER].oc_descr = NULL;
445.  		makeknown(ELVEN_BROADSWORD);
446.  		objects[ELVEN_BROADSWORD].oc_descr = NULL;
447.  #endif
448.  		makeknown(ELVEN_CLOAK);
449.  		objects[ELVEN_CLOAK].oc_descr = NULL;
450.  		break;
451.  	case 'V':
452.  		flags.female = TRUE;
453.  		ini_inv(Valkyrie);
454.  		if(!rn2(6)) ini_inv(Lamp);
455.  		knows_class(WEAPON_SYM);
456.  		break;
457.  	case 'H':
458.  		u.ugold = u.ugold0 = rnd(1000)+1000;
459.  		ini_inv(Healer);
460.  		if(!rn2(25)) ini_inv(Lamp);
461.  		break;
462.  	case 'K':
463.  		ini_inv(Knight);
464.  		knows_class(WEAPON_SYM);
465.  		break;
466.  	case 'B':
467.  		ini_inv(Barbarian);
468.  		if(!rn2(6)) ini_inv(Lamp);
469.  		knows_class(WEAPON_SYM);
470.  		break;
471.  	case 'S':
472.  		ini_inv(Samurai);
473.  		if(!rn2(5)) ini_inv(Blindfold);
474.  		objects[SHORT_SWORD].oc_name = "wakizashi";
475.  		objects[BROADSWORD].oc_name = "ninja-to";
476.  		objects[GLAIVE].oc_name = "naginata";
477.  		/* objects[BOW].oc_name = "yumi"; */
478.  		objects[LOCK_PICK].oc_name = "osaku";
479.  		knows_class(WEAPON_SYM);
480.  		break;
481.  	case 'P':
482.  #ifdef SPELLS
483.  		u.uen = u.uenmax += rn2(4);
484.  #endif
485.  		ini_inv(Priest);
486.  		if(!rn2(10)) ini_inv(Magicmarker);
487.  		else if(!rn2(10)) ini_inv(Lamp);
488.  		break;
489.  
490.  	default:	/* impossible */
491.  		break;
492.  	}
493.  #ifndef HARD
494.  	ini_inv(Saving);	/* give beginners an extra chance */
495.  #endif
496.  #ifdef EXPLORE_MODE
497.  	if (discover)
498.  		ini_inv(Wishing);
499.  #endif
500.  	find_ac();			/* get initial ac value */
501.  	init_attr((pick != 'y') ? 69 : 72);	/* init attribute values */
502.  	max_rank_sz();			/* set max str size for class ranks */
503.  /*
504.   *	Do we really need this?
505.   */
506.  	for(i = 0; i < A_MAX; i++)
507.  	    if(!rn2(20)) {
508.  		register int xd = rn2(7) - 2;	/* biased variation */
509.  		adjattrib(i, xd, TRUE);
510.  	    }
511.  
512.  	/* make sure he can carry all he has - especially for T's */
513.  	while(inv_weight() > 0)
514.  		adjattrib(A_STR, 1, TRUE);
515.  
516.  #ifdef THEOLOGY
517.  	u.ualignbase[0] = u.ualignbase[1] = u.ualigntyp;
518.  #endif
519.  }
520.  
521.  static void
522.  ini_inv(trop)
523.  register struct trobj *trop;
524.  {
525.  	struct obj *obj;
526.  	while(trop->trolet) {
527.  		boolean undefined = (trop->trotyp == UNDEF_TYP);
528.  
529.  		if (!undefined)
530.  			obj = mksobj((int)trop->trotyp,FALSE);
531.  		else obj = mkobj(trop->trolet,FALSE);
532.  
533.  		/* For random objects, do not create certain overly powerful
534.  		 * items: wand of wishing, ring of levitation, or the
535.  		 * polymorph/polymorph control combination.  Specific objects,
536.  		 * i.e. the discovery wishing, are still OK.
537.  		 */
538.  		if (undefined) {
539.  #ifdef POLYSELF
540.  			static int nocreate = STRANGE_OBJECT;
541.  #  ifdef SPELLS
542.  			static int nocreate2 = STRANGE_OBJECT;
543.  #  endif
544.  #endif
545.  
546.  			while(obj->otyp == WAN_WISHING
547.  #ifdef POLYSELF
548.  				|| obj->otyp == nocreate
549.  #  ifdef SPELLS
550.  				|| obj->otyp == nocreate2
551.  #  endif
552.  #endif
553.  #ifdef ELBERETH
554.  				|| obj->otyp == RIN_LEVITATION
555.  #endif
556.  							) {
557.  				free((genericptr_t) obj);
558.  				obj = mkobj(trop->trolet, FALSE);
559.  			}
560.  
561.  			/* Don't start with +0 or negative rings */
562.  			if(objects[obj->otyp].oc_charged && obj->spe <= 0)
563.  				obj->spe = rne(3);
564.  
565.  			/* Heavily relies on the fact that 1) we create wands
566.  			 * before rings, 2) that we create rings before
567.  			 * spellbooks, and that 3) not more than 1 object of a
568.  			 * particular symbol is to be prohibited.
569.  			 */
570.  #ifdef POLYSELF
571.  			if (obj->otyp == WAN_POLYMORPH)
572.  				nocreate = RIN_POLYMORPH_CONTROL;
573.  			if (obj->otyp == RIN_POLYMORPH)
574.  				nocreate = RIN_POLYMORPH_CONTROL;
575.  			if (obj->otyp == RIN_POLYMORPH_CONTROL) {
576.  				nocreate = RIN_POLYMORPH;
577.  #  ifdef SPELLS
578.  				nocreate2 = SPE_POLYMORPH;
579.  #  endif /* SPELLS */
580.  			}
581.  #endif /* POLYSELF */
582.  		}
583.  
584.  		obj->bknown = trop->trknown;
585.  		if(uses_known(obj)) obj->known = trop->trknown;
586.  		/* not obj->dknown = 1; - let him look at it at least once */
587.  		obj->cursed = 0;
588.  		if(obj->olet == TOOL_SYM){ /* problem with multiple tools */
589.  			obj->quan = 1;     /* might be > because of grenades */
590.  		}
591.  		if(obj->olet == WEAPON_SYM) {
592.  			obj->quan = trop->trquan;
593.  			trop->trquan = 1;
594.  		}
595.  		if(obj->olet == FOOD_SYM && undefined) {
596.  			obj->known = 1;
597.  			/* needed for tins and eggs; harmless otherwise */
598.  			obj->bknown = (obj->otyp != DEAD_LIZARD);
599.  			/* only for dead lizards does the blessing not matter */
600.  		}
601.  		/*
602.  		 * The below lines not needed because they don't correspond
603.  		 * to any actual inventory; nobody gets random tools.
604.  		else if(obj->olet == TOOL_SYM && undefined) {
605.  			obj->bknown = (obj->otyp != BAG_OF_TRICKS
606.  				&& obj->otyp != SACK
607.  				&& obj->otyp != CHEST
608.  				&& obj->otyp != LARGE_BOX
609.  				&& obj->otyp != ICE_BOX)
610.  		}
611.  		*/
612.  		if(trop->trspe != UNDEF_SPE)
613.  			obj->spe = trop->trspe;
614.  		if(trop->trbless != UNDEF_BLESS)
615.  			obj->blessed = trop->trbless;
616.  
617.  		if (!Is_container(obj))
618.  			obj->owt = weight(obj);
619.  			/* defined after setting otyp+quan */
620.  		obj = addinv(obj);
621.  
622.  		/* Make the type known if necessary */
623.  		if (objects[obj->otyp].oc_descr && obj->known)
624.  		    	makeknown(obj->otyp);
625.  
626.  		if(obj->olet == ARMOR_SYM){
627.  			if (is_shield(obj) && !uarms)
628.  				setworn(obj, W_ARMS);
629.  			else if (is_helmet(obj) && !uarmh)
630.  				setworn(obj, W_ARMH);
631.  			else if (is_gloves(obj) && !uarmg)
632.  				setworn(obj, W_ARMG);
633.  #ifdef SHIRT
634.  			else if (obj->otyp == HAWAIIAN_SHIRT && !uarmu)
635.  				setworn(obj, W_ARMU);
636.  #endif
637.  			else if (is_cloak(obj) && !uarmc)
638.  				setworn(obj, W_ARMC);
639.  			else if (is_boots(obj) && !uarmf)
640.  				setworn(obj, W_ARMF);
641.  			else if (!uarm)
642.  				setworn(obj, W_ARM);
643.  		}
644.  		/* below changed by GAN 01/09/87 to allow wielding of
645.  		 * pick-axe or can-opener if there is no weapon
646.  		 */
647.  		if(obj->olet == WEAPON_SYM || obj->otyp == PICK_AXE ||
648.  		   obj->otyp == TIN_OPENER)
649.  			if(!uwep) setuwep(obj);
650.  #ifndef PYRAMID_BUG
651.  		if(--trop->trquan) continue;	/* make a similar object */
652.  #else
653.  		if(trop->trquan) {		/* check if zero first */
654.  			--trop->trquan;
655.  			if(trop->trquan)
656.  				continue;	/* make a similar object */
657.  		}
658.  #endif
659.  		trop++;
660.  	}
661.  }
662.  
663.  void
664.  plnamesuffix() {
665.  	register char *p;
666.  	if(p = rindex(plname, '-')) {
667.  		*p = 0;
668.  		pl_character[0] = p[1];
669.  		pl_character[1] = 0;
670.  		if(!plname[0]) {
671.  			askname();
672.  			plnamesuffix();
673.  		}
674.  	}
675.  }