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