Mercurial > hg > early-roguelike
comparison arogue5/misc.c @ 63:0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
author | elwin |
---|---|
date | Thu, 09 Aug 2012 22:58:48 +0000 |
parents | |
children | c49f7927b0fa |
comparison
equal
deleted
inserted
replaced
62:0ef99244acb8 | 63:0ed67132cf10 |
---|---|
1 /* | |
2 * routines dealing specifically with miscellaneous magic | |
3 * | |
4 * Advanced Rogue | |
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
6 * All rights reserved. | |
7 * | |
8 * See the file LICENSE.TXT for full copyright and licensing information. | |
9 */ | |
10 | |
11 #include "curses.h" | |
12 #include <ctype.h> | |
13 #include "rogue.h" | |
14 | |
15 /* | |
16 * See if a monster has some magic it can use. Use it and return TRUE if so. | |
17 */ | |
18 bool | |
19 m_use_item(monster, monst_pos, defend_pos) | |
20 register struct thing *monster; | |
21 register coord *monst_pos, *defend_pos; | |
22 { | |
23 register struct linked_list *pitem; | |
24 register struct object *obj; | |
25 register coord *shoot_dir = can_shoot(monst_pos, defend_pos); | |
26 int dist=DISTANCE(monst_pos->y, monst_pos->x, defend_pos->y, defend_pos->x); | |
27 | |
28 for (pitem=monster->t_pack; pitem; pitem=next(pitem)) { | |
29 obj = OBJPTR(pitem); | |
30 if (obj->o_type != RELIC) continue; /* Only care about relics now */ | |
31 switch (obj->o_which) { | |
32 case MING_STAFF: { | |
33 static struct object missile = { | |
34 MISSILE, {0,0}, "", 0, "", "0d4 " , NULL, 0, WS_MISSILE, 100, 1 | |
35 }; | |
36 | |
37 if (shoot_dir != NULL) { | |
38 sprintf(missile.o_hurldmg, "%dd4", monster->t_stats.s_lvl); | |
39 do_motion(&missile, shoot_dir->y, shoot_dir->x, monster); | |
40 hit_monster(unc(missile.o_pos), &missile, monster); | |
41 return(TRUE); | |
42 } | |
43 } | |
44 when ASMO_ROD: | |
45 /* The bolt must be able to reach the defendant */ | |
46 if (shoot_dir != NULL && dist < BOLT_LENGTH * BOLT_LENGTH) { | |
47 char *name; | |
48 | |
49 switch (rnd(3)) { /* Select a function */ | |
50 case 0: name = "lightning bolt"; | |
51 when 1: name = "flame"; | |
52 otherwise: name = "ice"; | |
53 } | |
54 shoot_bolt( monster, | |
55 *monst_pos, | |
56 *shoot_dir, | |
57 FALSE, | |
58 monster->t_index, | |
59 name, | |
60 roll(monster->t_stats.s_lvl,6)); | |
61 return(TRUE); | |
62 } | |
63 when BRIAN_MANDOLIN: | |
64 /* The defendant must be the player and within 2 spaces */ | |
65 if (ce(*defend_pos, hero) && dist < 9 && no_command == 0 && | |
66 rnd(100) < 33) { | |
67 if (!save(VS_MAGIC, &player, -4) && | |
68 !ISWEARING(R_ALERT)) { | |
69 msg("Some beautiful music enthralls you."); | |
70 no_command += FREEZETIME; | |
71 } | |
72 else msg("You wince at a sour note."); | |
73 return(TRUE); | |
74 } | |
75 when GERYON_HORN: | |
76 /* The defendant must be the player and within 2 spaces */ | |
77 if (ce(*defend_pos, hero) && dist < 9 && | |
78 (off(player, ISFLEE) || player.t_dest != &monster->t_pos) | |
79 && rnd(100) < 33) { | |
80 if (!ISWEARING(R_HEROISM) && | |
81 !save(VS_MAGIC, &player, -4)) { | |
82 turn_on(player, ISFLEE); | |
83 player.t_dest = &monster->t_pos; | |
84 msg("A shrill blast terrifies you."); | |
85 } | |
86 else msg("A shrill blast sends chills up your spine."); | |
87 return(TRUE); | |
88 } | |
89 } | |
90 } | |
91 return(FALSE); | |
92 } | |
93 | |
94 /* | |
95 * add something to the contents of something else | |
96 */ | |
97 put_contents(bag, item) | |
98 register struct object *bag; /* the holder of the items */ | |
99 register struct linked_list *item; /* the item to put inside */ | |
100 { | |
101 register struct linked_list *titem; | |
102 register struct object *tobj; | |
103 | |
104 bag->o_ac++; | |
105 tobj = OBJPTR(item); | |
106 for (titem = bag->contents; titem != NULL; titem = next(titem)) { | |
107 if ((OBJPTR(titem))->o_which == tobj->o_which) | |
108 break; | |
109 } | |
110 if (titem == NULL) { /* if not a duplicate put at beginning */ | |
111 attach(bag->contents, item); | |
112 } | |
113 else { | |
114 item->l_prev = titem; | |
115 item->l_next = titem->l_next; | |
116 if (next(titem) != NULL) | |
117 (titem->l_next)->l_prev = item; | |
118 titem->l_next = item; | |
119 } | |
120 } | |
121 | |
122 /* | |
123 * remove something from something else | |
124 */ | |
125 take_contents(bag, item) | |
126 register struct object *bag; /* the holder of the items */ | |
127 register struct linked_list *item; | |
128 { | |
129 | |
130 if (bag->o_ac <= 0) { | |
131 msg("Nothing to take out"); | |
132 return; | |
133 } | |
134 bag->o_ac--; | |
135 detach(bag->contents, item); | |
136 if (!add_pack(item, FALSE, NULL)) | |
137 put_contents(bag, item); | |
138 } | |
139 | |
140 | |
141 do_bag(item) | |
142 register struct linked_list *item; | |
143 { | |
144 | |
145 register struct linked_list *titem = NULL; | |
146 register struct object *obj; | |
147 bool doit = TRUE; | |
148 | |
149 obj = OBJPTR(item); | |
150 while (doit) { | |
151 msg("What do you want to do? (* for a list): "); | |
152 mpos = 0; | |
153 switch (readchar()) { | |
154 case EOF: | |
155 case ESCAPE: | |
156 msg (""); | |
157 doit = FALSE; | |
158 when '1': | |
159 inventory(obj->contents, ALL); | |
160 | |
161 when '2': | |
162 if (obj->o_ac >= MAXCONTENTS) { | |
163 msg("the %s is full", m_magic[obj->o_which].mi_name); | |
164 break; | |
165 } | |
166 switch (obj->o_which) { | |
167 case MM_BEAKER: titem = get_item(pack, "put in", POTION); | |
168 when MM_BOOK: titem = get_item(pack, "put in", SCROLL); | |
169 } | |
170 if (titem == NULL) | |
171 break; | |
172 detach(pack, titem); | |
173 inpack--; | |
174 put_contents(obj, titem); | |
175 | |
176 when '3': | |
177 titem = get_item(obj->contents,"take out",ALL); | |
178 if (titem == NULL) | |
179 break; | |
180 take_contents(obj, titem); | |
181 | |
182 when '4': | |
183 switch (obj->o_which) { | |
184 case MM_BEAKER: | |
185 titem = get_item(obj->contents,"quaff",ALL); | |
186 if (titem == NULL) | |
187 break; | |
188 obj->o_ac--; | |
189 detach(obj->contents, titem); | |
190 quaff((OBJPTR(titem))->o_which, | |
191 (OBJPTR(titem))->o_flags & (ISCURSED | ISBLESSED), | |
192 TRUE); | |
193 o_discard(titem); | |
194 when MM_BOOK: | |
195 if (on(player, ISBLIND)) { | |
196 msg("You can't see to read anything"); | |
197 break; | |
198 } | |
199 titem = get_item(obj->contents,"read",ALL); | |
200 if (titem == NULL) | |
201 break; | |
202 obj->o_ac--; | |
203 detach(obj->contents, titem); | |
204 read_scroll((OBJPTR(titem))->o_which, | |
205 (OBJPTR(titem))->o_flags & (ISCURSED|ISBLESSED), | |
206 TRUE); | |
207 o_discard(titem); | |
208 } | |
209 doit = FALSE; | |
210 | |
211 otherwise: | |
212 wclear(hw); | |
213 touchwin(hw); | |
214 mvwaddstr(hw,0,0,"The following operations are available:"); | |
215 mvwaddstr(hw,2,0,"[1]\tInventory\n"); | |
216 wprintw(hw,"[2]\tPut something in the %s\n", | |
217 m_magic[obj->o_which].mi_name); | |
218 wprintw(hw,"[3]\tTake something out of the %s\n", | |
219 m_magic[obj->o_which].mi_name); | |
220 switch(obj->o_which) { | |
221 case MM_BEAKER: waddstr(hw,"[4]\tQuaff a potion\n"); | |
222 when MM_BOOK: waddstr(hw,"[4]\tRead a scroll\n"); | |
223 } | |
224 waddstr(hw,"[ESC]\tLeave this menu\n"); | |
225 mvwaddstr(hw, LINES-1, 0, spacemsg); | |
226 draw(hw); | |
227 wait_for (hw,' '); | |
228 clearok(cw, TRUE); | |
229 touchwin(cw); | |
230 } | |
231 } | |
232 } | |
233 | |
234 do_panic() | |
235 { | |
236 register int x,y; | |
237 register struct linked_list *mon; | |
238 register struct thing *th; | |
239 | |
240 for (x = hero.x-2; x <= hero.x+2; x++) { | |
241 for (y = hero.y-2; y <= hero.y+2; y++) { | |
242 if (y < 1 || x < 0 || y > LINES - 3 || x > COLS - 1) | |
243 continue; | |
244 if (isalpha(mvwinch(mw, y, x))) { | |
245 if ((mon = find_mons(y, x)) != NULL) { | |
246 th = THINGPTR(mon); | |
247 if (!on(*th, ISUNDEAD) && !save(VS_MAGIC, th, 0)) { | |
248 turn_on(*th, ISFLEE); | |
249 turn_on(*th, WASTURNED); | |
250 | |
251 /* If monster was suffocating, stop it */ | |
252 if (on(*th, DIDSUFFOCATE)) { | |
253 turn_off(*th, DIDSUFFOCATE); | |
254 extinguish(suffocate); | |
255 } | |
256 | |
257 /* If monster held us, stop it */ | |
258 if (on(*th, DIDHOLD) && (--hold_count == 0)) | |
259 turn_off(player, ISHELD); | |
260 turn_off(*th, DIDHOLD); | |
261 } | |
262 runto(th, &hero); | |
263 } | |
264 } | |
265 } | |
266 } | |
267 } | |
268 | |
269 /* | |
270 * print miscellaneous magic bonuses | |
271 */ | |
272 char * | |
273 misc_name(obj) | |
274 register struct object *obj; | |
275 { | |
276 static char buf[LINELEN]; | |
277 char buf1[LINELEN]; | |
278 | |
279 buf[0] = '\0'; | |
280 buf1[0] = '\0'; | |
281 if (!(obj->o_flags & ISKNOW)) | |
282 return (m_magic[obj->o_which].mi_name); | |
283 switch (obj->o_which) { | |
284 case MM_BRACERS: | |
285 case MM_PROTECT: | |
286 strcat(buf, num(obj->o_ac, 0)); | |
287 strcat(buf, " "); | |
288 } | |
289 switch (obj->o_which) { | |
290 case MM_G_OGRE: | |
291 case MM_G_DEXTERITY: | |
292 case MM_JEWEL: | |
293 case MM_STRANGLE: | |
294 case MM_R_POWERLESS: | |
295 case MM_DANCE: | |
296 if (obj->o_flags & ISCURSED) | |
297 strcat(buf, "cursed "); | |
298 } | |
299 strcat(buf, m_magic[obj->o_which].mi_name); | |
300 switch (obj->o_which) { | |
301 case MM_JUG: | |
302 if (obj->o_ac == JUG_EMPTY) | |
303 strcat(buf1, " [empty]"); | |
304 else if (p_know[obj->o_ac]) | |
305 sprintf(buf1, " [containing a potion of %s (%s)]", | |
306 p_magic[obj->o_ac].mi_name, | |
307 p_colors[obj->o_ac]); | |
308 else sprintf(buf1, " [containing a%s %s liquid]", | |
309 vowelstr(p_colors[obj->o_ac]), | |
310 p_colors[obj->o_ac]); | |
311 when MM_BEAKER: | |
312 case MM_BOOK: { | |
313 sprintf(buf1, " [containing %d]", obj->o_ac); | |
314 } | |
315 when MM_OPEN: | |
316 case MM_HUNGER: | |
317 sprintf(buf1, " [%d ring%s]", obj->o_charges, | |
318 obj->o_charges == 1 ? "" : "s"); | |
319 when MM_DRUMS: | |
320 sprintf(buf1, " [%d beat%s]", obj->o_charges, | |
321 obj->o_charges == 1 ? "" : "s"); | |
322 when MM_DISAPPEAR: | |
323 case MM_CHOKE: | |
324 sprintf(buf1, " [%d pinch%s]", obj->o_charges, | |
325 obj->o_charges == 1 ? "" : "es"); | |
326 when MM_KEOGHTOM: | |
327 sprintf(buf1, " [%d application%s]", obj->o_charges, | |
328 obj->o_charges == 1 ? "" : "s"); | |
329 when MM_SKILLS: | |
330 switch (obj->o_ac) { | |
331 case C_MAGICIAN: strcpy(buf1, " [magic user]"); | |
332 when C_FIGHTER: strcpy(buf1, " [fighter]"); | |
333 when C_CLERIC: strcpy(buf1, " [cleric]"); | |
334 when C_THIEF: strcpy(buf1, " [thief]"); | |
335 } | |
336 } | |
337 strcat (buf, buf1); | |
338 return buf; | |
339 } | |
340 | |
341 use_emori() | |
342 { | |
343 char selection; /* Cloak function */ | |
344 int state = 0; /* Menu state */ | |
345 | |
346 msg("What do you want to do? (* for a list): "); | |
347 do { | |
348 selection = tolower(readchar()); | |
349 switch (selection) { | |
350 case '*': | |
351 if (state != 1) { | |
352 wclear(hw); | |
353 touchwin(hw); | |
354 mvwaddstr(hw, 2, 0, "[1] Fly\n[2] Stop flying\n"); | |
355 waddstr(hw, "[3] Turn invisible\n[4] Turn Visible\n"); | |
356 mvwaddstr(hw, 0, 0, "What do you want to do? "); | |
357 draw(hw); | |
358 state = 1; /* Now in prompt window */ | |
359 } | |
360 break; | |
361 | |
362 case ESCAPE: | |
363 if (state == 1) { | |
364 clearok(cw, TRUE); /* Set up for redraw */ | |
365 touchwin(cw); | |
366 } | |
367 msg(""); | |
368 | |
369 after = FALSE; | |
370 return; | |
371 | |
372 when '1': | |
373 case '2': | |
374 case '3': | |
375 case '4': | |
376 if (state == 1) { /* In prompt window */ | |
377 clearok(cw, TRUE); /* Set up for redraw */ | |
378 touchwin(cw); | |
379 } | |
380 | |
381 msg(""); | |
382 | |
383 state = 2; /* Finished */ | |
384 break; | |
385 | |
386 default: | |
387 if (state == 1) { /* In the prompt window */ | |
388 mvwaddstr(hw, 0, 0, | |
389 "Please enter a selection between 1 and 4: "); | |
390 draw(hw); | |
391 } | |
392 else { /* Normal window */ | |
393 mpos = 0; | |
394 msg("Please enter a selection between 1 and 4: "); | |
395 } | |
396 } | |
397 } while (state != 2); | |
398 | |
399 /* We now must have a selection between 1 and 4 */ | |
400 switch (selection) { | |
401 case '1': /* Fly */ | |
402 if (on(player, ISFLY)) { | |
403 extinguish(land); /* Extinguish in case of potion */ | |
404 msg("%slready flying.", terse ? "A" : "You are a"); | |
405 } | |
406 else { | |
407 msg("You feel lighter than air!"); | |
408 turn_on(player, ISFLY); | |
409 } | |
410 when '2': /* Stop flying */ | |
411 if (off(player, ISFLY)) | |
412 msg("%sot flying.", terse ? "N" : "You are n"); | |
413 else { | |
414 if (find_slot(land)) | |
415 msg("%sot flying by the cloak.", | |
416 terse ? "N" : "You are n"); | |
417 else land(); | |
418 } | |
419 when '3': /* Turn invisible */ | |
420 if (off(player, ISINVIS)) { | |
421 turn_on(player, ISINVIS); | |
422 msg("You have a tingling feeling all over your body"); | |
423 PLAYER = IPLAYER; | |
424 light(&hero); | |
425 } | |
426 else { | |
427 extinguish(appear); /* Extinguish in case of potion */ | |
428 extinguish(dust_appear);/* dust of disappearance */ | |
429 msg("%slready invisible.", terse ? "A" : "You are a"); | |
430 } | |
431 when '4': /* Turn visible */ | |
432 if (off(player, ISINVIS)) | |
433 msg("%sot invisible.", terse ? "N" : "You are n"); | |
434 else { | |
435 if (find_slot(appear) || find_slot(dust_appear)) | |
436 msg("%sot invisible by the cloak.", | |
437 terse ? "N" : "You are n"); | |
438 else appear(); | |
439 } | |
440 } | |
441 } | |
442 | |
443 use_mm(which) | |
444 int which; | |
445 { | |
446 register struct object *obj = NULL; | |
447 register struct linked_list *item = NULL; | |
448 bool cursed, blessed, is_mm; | |
449 char buf[LINELEN]; | |
450 | |
451 cursed = FALSE; | |
452 is_mm = FALSE; | |
453 | |
454 if (which < 0) { /* A real miscellaneous magic item */ | |
455 is_mm = TRUE; | |
456 item = get_item(pack, "use", USEABLE); | |
457 /* | |
458 * Make certain that it is a micellaneous magic item | |
459 */ | |
460 if (item == NULL) | |
461 return; | |
462 | |
463 obj = OBJPTR(item); | |
464 cursed = (obj->o_flags & ISCURSED) != 0; | |
465 blessed = (obj->o_flags & ISBLESSED) != 0; | |
466 which = obj->o_which; | |
467 } | |
468 | |
469 if (obj->o_type == RELIC) { /* An artifact */ | |
470 is_mm = FALSE; | |
471 switch (obj->o_which) { | |
472 case EMORI_CLOAK: | |
473 use_emori(); | |
474 when BRIAN_MANDOLIN: | |
475 /* Put monsters around us to sleep */ | |
476 read_scroll(S_HOLD, 0, FALSE); | |
477 when GERYON_HORN: | |
478 /* Chase close monsters away */ | |
479 msg("The horn blasts a shrill tone."); | |
480 do_panic(); | |
481 when HEIL_ANKH: | |
482 case YENDOR_AMULET: | |
483 /* Nothing happens by this mode */ | |
484 msg("Nothing happens."); | |
485 } | |
486 } | |
487 else switch (which) { /* Miscellaneous Magic */ | |
488 /* | |
489 * the jug of alchemy manufactures potions when you drink | |
490 * the potion it will make another after a while | |
491 */ | |
492 case MM_JUG: | |
493 if (obj->o_ac == JUG_EMPTY) { | |
494 msg("The jug is empty"); | |
495 break; | |
496 } | |
497 quaff (obj->o_ac, NULL, FALSE); | |
498 obj->o_ac = JUG_EMPTY; | |
499 fuse (alchemy, obj, ALCHEMYTIME, AFTER); | |
500 if (!(obj->o_flags & ISKNOW)) | |
501 whatis(item); | |
502 | |
503 /* | |
504 * the beaker of plentiful potions is used to hold potions | |
505 * the book of infinite spells is used to hold scrolls | |
506 */ | |
507 when MM_BEAKER: | |
508 case MM_BOOK: | |
509 do_bag(item); | |
510 | |
511 /* | |
512 * the chime of opening opens up secret doors | |
513 */ | |
514 when MM_OPEN: | |
515 { | |
516 register struct linked_list *exit; | |
517 register struct room *rp; | |
518 register coord *cp; | |
519 | |
520 if (obj->o_charges <= 0) { | |
521 msg("The chime is cracked!"); | |
522 break; | |
523 } | |
524 obj->o_charges--; | |
525 msg("chime... chime... hime... ime... me... e..."); | |
526 if ((rp = roomin(&hero)) == NULL) { | |
527 search(FALSE, TRUE); /* Non-failing search for door */ | |
528 break; | |
529 } | |
530 for (exit = rp->r_exit; exit != NULL; exit = next(exit)) { | |
531 cp = DOORPTR(exit); | |
532 if (winat(cp->y, cp->x) == SECRETDOOR) { | |
533 mvaddch (cp->y, cp->x, DOOR); | |
534 if (cansee (cp->y, cp->x)) | |
535 mvwaddch(cw, cp->y, cp->x, DOOR); | |
536 } | |
537 } | |
538 } | |
539 | |
540 /* | |
541 * the chime of hunger just makes the hero hungry | |
542 */ | |
543 when MM_HUNGER: | |
544 if (obj->o_charges <= 0) { | |
545 msg("The chime is cracked!"); | |
546 break; | |
547 } | |
548 obj->o_charges--; | |
549 food_left = MORETIME + 5; | |
550 msg(terse ? "Getting hungry" : "You are starting to get hungry"); | |
551 hungry_state = F_HUNGRY; | |
552 aggravate(); | |
553 | |
554 /* | |
555 * the drums of panic make all creatures within two squares run | |
556 * from the hero in panic unless they save or they are mindless | |
557 * undead | |
558 */ | |
559 when MM_DRUMS: | |
560 if (obj->o_charges <= 0) { | |
561 msg("The drum is broken!"); | |
562 break; | |
563 } | |
564 obj->o_charges--; | |
565 /* | |
566 * dust of disappearance makes the player invisible for a while | |
567 */ | |
568 when MM_DISAPPEAR: | |
569 m_know[MM_DISAPPEAR] = TRUE; | |
570 if (obj->o_charges <= 0) { | |
571 msg("No more dust!"); | |
572 break; | |
573 } | |
574 obj->o_charges--; | |
575 msg("aaAAACHOOOooo. Cough. Cough. Sneeze. Sneeze."); | |
576 if (!find_slot(dust_appear)) { | |
577 turn_on(player, ISINVIS); | |
578 fuse(dust_appear, 0, DUSTTIME, AFTER); | |
579 PLAYER = IPLAYER; | |
580 light(&hero); | |
581 } | |
582 else lengthen(dust_appear, DUSTTIME); | |
583 | |
584 /* | |
585 * dust of choking and sneezing can kill the hero if he misses | |
586 * the save | |
587 */ | |
588 when MM_CHOKE: | |
589 m_know[MM_CHOKE] = TRUE; | |
590 if (obj->o_charges <= 0) { | |
591 msg("No more dust!"); | |
592 break; | |
593 } | |
594 obj->o_charges--; | |
595 msg("aaAAACHOOOooo. Cough. Cough. Sneeze. Sneeze."); | |
596 if (!save(VS_POISON, &player, 0)) { | |
597 msg ("You choke to death!!! --More--"); | |
598 pstats.s_hpt = -1; /* in case he hangs up the phone */ | |
599 wait_for(cw,' '); | |
600 death(D_CHOKE); | |
601 } | |
602 else { | |
603 msg("You begin to cough and choke uncontrollably"); | |
604 if (find_slot(unchoke)) | |
605 lengthen(unchoke, DUSTTIME); | |
606 else | |
607 fuse(unchoke, 0, DUSTTIME, AFTER); | |
608 turn_on(player, ISHUH); | |
609 turn_on(player, ISBLIND); | |
610 light(&hero); | |
611 } | |
612 | |
613 when MM_KEOGHTOM: | |
614 /* | |
615 * this is a very powerful healing ointment | |
616 * but it takes a while to put on... | |
617 */ | |
618 if (obj->o_charges <= 0) { | |
619 msg("The jar is empty!"); | |
620 break; | |
621 } | |
622 obj->o_charges--; | |
623 waste_time(); | |
624 if (on(player, HASDISEASE)) { | |
625 extinguish(cure_disease); | |
626 cure_disease(); | |
627 msg(terse ? "You feel yourself improving." | |
628 : "You begin to feel yourself improving again."); | |
629 } | |
630 if (on(player, HASINFEST)) { | |
631 turn_off(player, HASINFEST); | |
632 infest_dam = 0; | |
633 msg(terse ? "You feel yourself improving." | |
634 : "You begin to feel yourself improving again."); | |
635 } | |
636 if (on(player, DOROT)) { | |
637 msg("You feel your skin returning to normal."); | |
638 turn_off(player, DOROT); | |
639 } | |
640 pstats.s_hpt += roll(pstats.s_lvl, 6); | |
641 if (pstats.s_hpt > max_stats.s_hpt) | |
642 pstats.s_hpt = max_stats.s_hpt; | |
643 sight(); | |
644 msg("You begin to feel much better."); | |
645 | |
646 /* | |
647 * The book has a character class associated with it. | |
648 * if your class matches that of the book, it will raise your | |
649 * level by one. If your class does not match the one of the book, | |
650 * it change your class to that of book. | |
651 * Note that it takes a while to read. | |
652 */ | |
653 when MM_SKILLS: | |
654 detach (pack, item); | |
655 inpack--; | |
656 waste_time(); | |
657 waste_time(); | |
658 waste_time(); | |
659 waste_time(); | |
660 waste_time(); | |
661 if (obj->o_ac == player.t_ctype) { | |
662 msg("You feel more skillful"); | |
663 raise_level(TRUE); | |
664 } | |
665 else { | |
666 /* | |
667 * reset his class and then use check_level to reset hit | |
668 * points and the right level for his exp pts | |
669 * drop exp pts by 10% | |
670 */ | |
671 long save; | |
672 | |
673 msg("You feel like a whole new person!"); | |
674 /* | |
675 * if he becomes a thief he has to have leather armor | |
676 */ | |
677 if (obj->o_ac == C_THIEF && | |
678 cur_armor != NULL && | |
679 cur_armor->o_which != LEATHER && | |
680 cur_armor->o_which != STUDDED_LEATHER ) | |
681 cur_armor->o_which = STUDDED_LEATHER; | |
682 /* | |
683 * if he's changing from a fighter then may have to change | |
684 * his sword since only fighter can use two-handed | |
685 * and bastard swords | |
686 */ | |
687 if (player.t_ctype == C_FIGHTER && | |
688 cur_weapon != NULL && | |
689 cur_weapon->o_type == WEAPON && | |
690 (cur_weapon->o_which== BASWORD || | |
691 cur_weapon->o_which== TWOSWORD )) | |
692 cur_weapon->o_which = SWORD; | |
693 | |
694 /* | |
695 * if he was a thief then take out the trap_look() daemon | |
696 */ | |
697 if (player.t_ctype == C_THIEF) | |
698 kill_daemon(trap_look); | |
699 /* | |
700 * if he becomes a thief then add the trap_look() daemon | |
701 */ | |
702 if (obj->o_ac == C_THIEF) | |
703 daemon(trap_look, 0, AFTER); | |
704 char_type = player.t_ctype = obj->o_ac; | |
705 save = pstats.s_hpt; | |
706 max_stats.s_hpt = pstats.s_hpt = 0; | |
707 max_stats.s_lvl = pstats.s_lvl = 0; | |
708 max_stats.s_exp = pstats.s_exp -= pstats.s_exp/10; | |
709 check_level(TRUE); | |
710 if (pstats.s_hpt > save) /* don't add to current hits */ | |
711 pstats.s_hpt = save; | |
712 } | |
713 | |
714 otherwise: | |
715 msg("What a strange magic item you have!"); | |
716 } | |
717 status(FALSE); | |
718 if (is_mm && m_know[which] && m_guess[which]) { | |
719 free(m_guess[which]); | |
720 m_guess[which] = NULL; | |
721 } | |
722 else if (is_mm && | |
723 !m_know[which] && | |
724 askme && | |
725 (obj->o_flags & ISKNOW) == 0 && | |
726 m_guess[which] == NULL) { | |
727 msg(terse ? "Call it: " : "What do you want to call it? "); | |
728 if (get_str(buf, cw) == NORM) { | |
729 m_guess[which] = new((unsigned int) strlen(buf) + 1); | |
730 strcpy(m_guess[which], buf); | |
731 } | |
732 } | |
733 if (item != NULL && which == MM_SKILLS) | |
734 o_discard(item); | |
735 updpack(TRUE); | |
736 } |