1 /* File: use_obj.c */
2
3 /*
4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
5 *
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
9 */
10
11 #include "mangband.h"
12
13 #define msg_misc(A) msg_format_complex_near(p_ptr, p_ptr, MSG_PY_MISC, (A), p_ptr->name)
eat_food(player_type * p_ptr,object_type * o_ptr,bool * ident)14 static bool eat_food(player_type *p_ptr, object_type *o_ptr, bool *ident)
15 {
16 /* Analyze the food */
17 switch (o_ptr->sval)
18 {
19 case SV_FOOD_POISON:
20 {
21 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
22 {
23 if (set_poisoned(p_ptr, p_ptr->poisoned + randint0(10) + 10))
24 {
25 *ident = TRUE;
26 }
27 }
28 break;
29 }
30
31 case SV_FOOD_BLINDNESS:
32 {
33 if (!p_ptr->resist_blind)
34 {
35 if (set_blind(p_ptr, p_ptr->blind + randint0(200) + 200))
36 {
37 *ident = TRUE;
38 }
39 }
40 break;
41 }
42
43 case SV_FOOD_PARANOIA:
44 {
45 if (!p_ptr->resist_fear)
46 {
47 if (set_afraid(p_ptr, p_ptr->afraid + randint0(10) + 10))
48 {
49 *ident = TRUE;
50 }
51 }
52 break;
53 }
54
55 case SV_FOOD_CONFUSION:
56 {
57 if (!p_ptr->resist_conf)
58 {
59 if (set_confused(p_ptr, p_ptr->confused + randint0(10) + 10))
60 {
61 *ident = TRUE;
62 }
63 }
64 break;
65 }
66
67 case SV_FOOD_HALLUCINATION:
68 {
69 if (!p_ptr->resist_chaos)
70 {
71 if (set_image(p_ptr, p_ptr->image + randint0(250) + 250))
72 {
73 *ident = TRUE;
74 }
75 }
76 break;
77 }
78
79 case SV_FOOD_PARALYSIS:
80 {
81 if (!p_ptr->free_act)
82 {
83 if (set_paralyzed(p_ptr, p_ptr->paralyzed + randint0(10) + 10))
84 {
85 *ident = TRUE;
86 }
87 }
88 break;
89 }
90
91 case SV_FOOD_WEAKNESS:
92 {
93 take_hit(p_ptr, damroll(6, 6), "poisonous food");
94 (void)do_dec_stat(p_ptr, A_STR);
95 *ident = TRUE;
96 break;
97 }
98
99 case SV_FOOD_SICKNESS:
100 {
101 take_hit(p_ptr, damroll(6, 6), "poisonous food");
102 (void)do_dec_stat(p_ptr, A_CON);
103 *ident = TRUE;
104 break;
105 }
106
107 case SV_FOOD_STUPIDITY:
108 {
109 take_hit(p_ptr, damroll(8, 8), "poisonous food");
110 (void)do_dec_stat(p_ptr, A_INT);
111 *ident = TRUE;
112 break;
113 }
114
115 case SV_FOOD_NAIVETY:
116 {
117 take_hit(p_ptr, damroll(8, 8), "poisonous food");
118 (void)do_dec_stat(p_ptr, A_WIS);
119 *ident = TRUE;
120 break;
121 }
122
123 case SV_FOOD_UNHEALTH:
124 {
125 take_hit(p_ptr, damroll(10, 10), "poisonous food");
126 (void)do_dec_stat(p_ptr, A_CON);
127 *ident = TRUE;
128 break;
129 }
130
131 case SV_FOOD_DISEASE:
132 {
133 take_hit(p_ptr, damroll(10, 10), "poisonous food");
134 (void)do_dec_stat(p_ptr, A_STR);
135 *ident = TRUE;
136 break;
137 }
138
139 case SV_FOOD_CURE_POISON:
140 {
141 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
142 break;
143 }
144
145 case SV_FOOD_CURE_BLINDNESS:
146 {
147 if (set_blind(p_ptr, 0)) *ident = TRUE;
148 break;
149 }
150
151 case SV_FOOD_CURE_PARANOIA:
152 {
153 if (set_afraid(p_ptr, 0)) *ident = TRUE;
154 break;
155 }
156
157 case SV_FOOD_CURE_CONFUSION:
158 {
159 if (set_confused(p_ptr, 0)) *ident = TRUE;
160 break;
161 }
162
163 case SV_FOOD_CURE_SERIOUS:
164 {
165 if (hp_player(p_ptr, damroll(4, 8))) *ident = TRUE;
166 break;
167 }
168
169 case SV_FOOD_RESTORE_STR:
170 {
171 if (do_res_stat(p_ptr, A_STR)) *ident = TRUE;
172 break;
173 }
174
175 case SV_FOOD_RESTORE_CON:
176 {
177 if (do_res_stat(p_ptr, A_CON)) *ident = TRUE;
178 break;
179 }
180
181 case SV_FOOD_RESTORING:
182 {
183 if (do_res_stat(p_ptr, A_STR)) *ident = TRUE;
184 if (do_res_stat(p_ptr, A_INT)) *ident = TRUE;
185 if (do_res_stat(p_ptr, A_WIS)) *ident = TRUE;
186 if (do_res_stat(p_ptr, A_DEX)) *ident = TRUE;
187 if (do_res_stat(p_ptr, A_CON)) *ident = TRUE;
188 if (do_res_stat(p_ptr, A_CHR)) *ident = TRUE;
189 break;
190 }
191
192
193 case SV_FOOD_RATION:
194 case SV_FOOD_BISCUIT:
195 case SV_FOOD_JERKY:
196 case SV_FOOD_SLIME_MOLD:
197 {
198 msg_print(p_ptr, "That tastes good.");
199 *ident = TRUE;
200 break;
201 }
202
203 case SV_FOOD_POTATO:
204 case SV_FOOD_HEAD_OF_CABBAGE:
205 case SV_FOOD_CARROT:
206 case SV_FOOD_BEET:
207 case SV_FOOD_SQUASH:
208 case SV_FOOD_EAR_OF_CORN:
209 {
210 hp_player(p_ptr, damroll(1, 4));
211 msg_print(p_ptr, "That tastes especially good.");
212 *ident = TRUE;
213 break;
214 }
215
216 case SV_FOOD_WAYBREAD:
217 {
218 msg_print(p_ptr, "That tastes good.");
219 (void)set_poisoned(p_ptr, 0);
220 (void)hp_player(p_ptr, damroll(4, 8));
221 *ident = TRUE;
222 break;
223 }
224
225 case SV_FOOD_PINT_OF_ALE:
226 case SV_FOOD_PINT_OF_WINE:
227 {
228 msg_print(p_ptr, "That tastes good.");
229 *ident = TRUE;
230 break;
231 }
232 }
233
234 /* Food can feed the player */
235 (void)set_food(p_ptr, p_ptr->food + o_ptr->pval);
236
237 return (TRUE);
238 }
239
240
quaff_potion(player_type * p_ptr,object_type * o_ptr,bool * ident)241 static bool quaff_potion(player_type *p_ptr, object_type *o_ptr, bool *ident)
242 {
243 /* Analyze the potion */
244 switch (o_ptr->sval)
245 {
246 case SV_POTION_WATER:
247 case SV_POTION_APPLE_JUICE:
248 case SV_POTION_SLIME_MOLD:
249 {
250 msg_print(p_ptr, "You feel less thirsty.");
251 *ident = TRUE;
252 break;
253 }
254
255 case SV_POTION_SLOWNESS:
256 {
257 if (set_slow(p_ptr, p_ptr->slow + randint1(25) + 15)) *ident = TRUE;
258 break;
259 }
260
261 case SV_POTION_SALT_WATER:
262 {
263 msg_print(p_ptr, "The potion makes you vomit!");
264 msg_misc("%s vomits!");
265 (void)set_food(p_ptr, PY_FOOD_STARVE - 1);
266 (void)set_poisoned(p_ptr, 0);
267 (void)set_paralyzed(p_ptr, p_ptr->paralyzed + 4);
268 *ident = TRUE;
269 break;
270 }
271
272 case SV_POTION_POISON:
273 {
274 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
275 {
276 if (set_poisoned(p_ptr, p_ptr->poisoned + randint0(15) + 10))
277 {
278 *ident = TRUE;
279 }
280 }
281 break;
282 }
283
284 case SV_POTION_BLINDNESS:
285 {
286 if (!p_ptr->resist_blind)
287 {
288 if (set_blind(p_ptr, p_ptr->blind + randint0(100) + 100))
289 {
290 *ident = TRUE;
291 }
292 }
293 break;
294 }
295
296 case SV_POTION_CONFUSION:
297 {
298 if (!p_ptr->resist_conf)
299 {
300 if (set_confused(p_ptr, p_ptr->confused + randint0(20) + 15))
301 {
302 *ident = TRUE;
303 }
304 }
305 break;
306 }
307
308 case SV_POTION_SLEEP:
309 {
310 if (!p_ptr->free_act)
311 {
312 if (set_paralyzed(p_ptr, p_ptr->paralyzed + randint0(4) + 4))
313 {
314 *ident = TRUE;
315 }
316 }
317 break;
318 }
319
320 case SV_POTION_LOSE_MEMORIES:
321 {
322 if (!p_ptr->hold_life && (p_ptr->exp > 0))
323 {
324 msg_print(p_ptr, "You feel your memories fade.");
325 lose_exp(p_ptr, p_ptr->exp / 4);
326 *ident = TRUE;
327 }
328 break;
329 }
330
331 case SV_POTION_RUINATION:
332 {
333 msg_print(p_ptr, "Your nerves and muscles feel weak and lifeless!");
334 take_hit(p_ptr, damroll(10, 10), "a potion of Ruination");
335 (void)dec_stat(p_ptr, A_DEX, 25, TRUE);
336 (void)dec_stat(p_ptr, A_WIS, 25, TRUE);
337 (void)dec_stat(p_ptr, A_CON, 25, TRUE);
338 (void)dec_stat(p_ptr, A_STR, 25, TRUE);
339 (void)dec_stat(p_ptr, A_CHR, 25, TRUE);
340 (void)dec_stat(p_ptr, A_INT, 25, TRUE);
341 *ident = TRUE;
342 break;
343 }
344
345 case SV_POTION_DEC_STR:
346 {
347 if (do_dec_stat(p_ptr, A_STR)) *ident = TRUE;
348 break;
349 }
350
351 case SV_POTION_DEC_INT:
352 {
353 if (do_dec_stat(p_ptr, A_INT)) *ident = TRUE;
354 break;
355 }
356
357 case SV_POTION_DEC_WIS:
358 {
359 if (do_dec_stat(p_ptr, A_WIS)) *ident = TRUE;
360 break;
361 }
362
363 case SV_POTION_DEC_DEX:
364 {
365 if (do_dec_stat(p_ptr, A_DEX)) *ident = TRUE;
366 break;
367 }
368
369 case SV_POTION_DEC_CON:
370 {
371 if (do_dec_stat(p_ptr, A_CON)) *ident = TRUE;
372 break;
373 }
374
375 case SV_POTION_DEC_CHR:
376 {
377 if (do_dec_stat(p_ptr, A_CHR)) *ident = TRUE;
378 break;
379 }
380
381 case SV_POTION_DETONATIONS:
382 {
383 msg_print(p_ptr, "Massive explosions rupture your body!");
384 msg_misc("%s blows up!");
385 take_hit(p_ptr, damroll(50, 20), "a potion of Detonation");
386 (void)set_stun(p_ptr, p_ptr->stun + 75);
387 (void)set_cut(p_ptr, p_ptr->cut + 5000);
388 *ident = TRUE;
389 break;
390 }
391
392 case SV_POTION_DEATH:
393 {
394 msg_print(p_ptr, "A feeling of Death flows through your body.");
395 take_hit(p_ptr, 5000, "a potion of Death");
396 *ident = TRUE;
397 break;
398 }
399
400 case SV_POTION_INFRAVISION:
401 {
402 if (set_tim_infra(p_ptr, p_ptr->tim_infra + 100 + randint1(100)))
403 {
404 *ident = TRUE;
405 }
406 break;
407 }
408
409 case SV_POTION_DETECT_INVIS:
410 {
411 if (set_tim_invis(p_ptr, p_ptr->tim_invis + 12 + randint1(12)))
412 {
413 *ident = TRUE;
414 }
415 break;
416 }
417
418 case SV_POTION_SLOW_POISON:
419 {
420 if (set_poisoned(p_ptr, p_ptr->poisoned / 2)) *ident = TRUE;
421 break;
422 }
423
424 case SV_POTION_CURE_POISON:
425 {
426 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
427 break;
428 }
429
430 case SV_POTION_BOLDNESS:
431 {
432 if (set_afraid(p_ptr, 0)) *ident = TRUE;
433 break;
434 }
435
436 case SV_POTION_SPEED:
437 {
438 if (!p_ptr->fast)
439 {
440 if (set_fast(p_ptr, randint1(25) + 15)) *ident = TRUE;
441 }
442 else
443 {
444 (void)set_fast(p_ptr, p_ptr->fast + 5);
445 }
446 break;
447 }
448
449 case SV_POTION_RESIST_HEAT:
450 {
451 if (set_oppose_fire(p_ptr, p_ptr->oppose_fire + randint1(10) + 10))
452 {
453 *ident = TRUE;
454 }
455 break;
456 }
457
458 case SV_POTION_RESIST_COLD:
459 {
460 if (set_oppose_cold(p_ptr, p_ptr->oppose_cold + randint1(10) + 10))
461 {
462 *ident = TRUE;
463 }
464 break;
465 }
466
467 case SV_POTION_HEROISM:
468 {
469 if (hp_player(p_ptr, 10)) *ident = TRUE;
470 if (set_afraid(p_ptr, 0)) *ident = TRUE;
471 if (set_hero(p_ptr, p_ptr->hero + randint1(25) + 25)) *ident = TRUE;
472 break;
473 }
474
475 case SV_POTION_BERSERK_STRENGTH:
476 {
477 if (hp_player(p_ptr, 30)) *ident = TRUE;
478 if (set_afraid(p_ptr, 0)) *ident = TRUE;
479 if (set_shero(p_ptr, p_ptr->shero + randint1(25) + 25)) *ident = TRUE;
480 break;
481 }
482
483 case SV_POTION_CURE_LIGHT:
484 {
485 if (hp_player(p_ptr, 15)) *ident = TRUE;
486 if (set_blind(p_ptr, 0)) *ident = TRUE;
487 if (set_cut(p_ptr, p_ptr->cut - 20)) *ident = TRUE;
488 if (set_confused(p_ptr, p_ptr->confused - 20)) *ident = TRUE;
489 break;
490 }
491
492 case SV_POTION_CURE_SERIOUS:
493 {
494 if (hp_player(p_ptr, randint0(5)+20)) *ident = TRUE;
495 if (set_blind(p_ptr, 0)) *ident = TRUE;
496 if (set_confused(p_ptr, 0)) *ident = TRUE;
497 if (set_cut(p_ptr, 0)) *ident = TRUE;
498 break;
499 }
500
501 case SV_POTION_CURE_CRITICAL:
502 {
503 if (hp_player(p_ptr, randint0(5)+25)) *ident = TRUE;
504 if (set_blind(p_ptr, 0)) *ident = TRUE;
505 if (set_confused(p_ptr, 0)) *ident = TRUE;
506 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
507 if (set_stun(p_ptr, 0)) *ident = TRUE;
508 if (set_cut(p_ptr, 0)) *ident = TRUE;
509 break;
510 }
511
512 case SV_POTION_HEALING:
513 {
514 if (hp_player(p_ptr, 300)) *ident = TRUE;
515 if (set_blind(p_ptr, 0)) *ident = TRUE;
516 if (set_confused(p_ptr, 0)) *ident = TRUE;
517 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
518 if (set_stun(p_ptr, 0)) *ident = TRUE;
519 if (set_cut(p_ptr, 0)) *ident = TRUE;
520 break;
521 }
522
523 case SV_POTION_STAR_HEALING:
524 {
525 if (hp_player(p_ptr, 1200)) *ident = TRUE;
526 if (set_blind(p_ptr, 0)) *ident = TRUE;
527 if (set_confused(p_ptr, 0)) *ident = TRUE;
528 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
529 if (set_stun(p_ptr, 0)) *ident = TRUE;
530 if (set_cut(p_ptr, 0)) *ident = TRUE;
531 break;
532 }
533
534 case SV_POTION_LIFE:
535 {
536 msg_print(p_ptr, "You feel life flow through your body!");
537 restore_level(p_ptr);
538 (void)set_poisoned(p_ptr, 0);
539 (void)set_blind(p_ptr, 0);
540 (void)set_confused(p_ptr, 0);
541 (void)set_image(p_ptr, 0);
542 (void)set_stun(p_ptr, 0);
543 (void)set_cut(p_ptr, 0);
544 (void)do_res_stat(p_ptr, A_STR);
545 (void)do_res_stat(p_ptr, A_CON);
546 (void)do_res_stat(p_ptr, A_DEX);
547 (void)do_res_stat(p_ptr, A_WIS);
548 (void)do_res_stat(p_ptr, A_INT);
549 (void)do_res_stat(p_ptr, A_CHR);
550
551 /* Recalculate max. hitpoints */
552 update_stuff(p_ptr);
553
554 hp_player(p_ptr, 5000);
555
556 *ident = TRUE;
557 break;
558 }
559
560 case SV_POTION_RESTORE_MANA:
561 {
562 if (p_ptr->csp < p_ptr->msp)
563 {
564 p_ptr->csp = p_ptr->msp;
565 p_ptr->csp_frac = 0;
566 msg_print(p_ptr, "Your feel your head clear.");
567 p_ptr->redraw |= (PR_MANA);
568 p_ptr->window |= (PW_PLAYER_0 | PW_PLAYER_1);
569 *ident = TRUE;
570 }
571 break;
572 }
573
574 case SV_POTION_RESTORE_EXP:
575 {
576 if (restore_level(p_ptr)) *ident = TRUE;
577 break;
578 }
579
580 case SV_POTION_RES_STR:
581 {
582 if (do_res_stat(p_ptr, A_STR)) *ident = TRUE;
583 break;
584 }
585
586 case SV_POTION_RES_INT:
587 {
588 if (do_res_stat(p_ptr, A_INT)) *ident = TRUE;
589 break;
590 }
591
592 case SV_POTION_RES_WIS:
593 {
594 if (do_res_stat(p_ptr, A_WIS)) *ident = TRUE;
595 break;
596 }
597
598 case SV_POTION_RES_DEX:
599 {
600 if (do_res_stat(p_ptr, A_DEX)) *ident = TRUE;
601 break;
602 }
603
604 case SV_POTION_RES_CON:
605 {
606 if (do_res_stat(p_ptr, A_CON)) *ident = TRUE;
607 break;
608 }
609
610 case SV_POTION_RES_CHR:
611 {
612 if (do_res_stat(p_ptr, A_CHR)) *ident = TRUE;
613 break;
614 }
615
616 case SV_POTION_INC_STR:
617 {
618 if (do_inc_stat(p_ptr, A_STR)) *ident = TRUE;
619 break;
620 }
621
622 case SV_POTION_INC_INT:
623 {
624 if (do_inc_stat(p_ptr, A_INT)) *ident = TRUE;
625 break;
626 }
627
628 case SV_POTION_INC_WIS:
629 {
630 if (do_inc_stat(p_ptr, A_WIS)) *ident = TRUE;
631 break;
632 }
633
634 case SV_POTION_INC_DEX:
635 {
636 if (do_inc_stat(p_ptr, A_DEX)) *ident = TRUE;
637 break;
638 }
639
640 case SV_POTION_INC_CON:
641 {
642 if (do_inc_stat(p_ptr, A_CON)) *ident = TRUE;
643 break;
644 }
645
646 case SV_POTION_INC_CHR:
647 {
648 if (do_inc_stat(p_ptr, A_CHR)) *ident = TRUE;
649 break;
650 }
651
652 case SV_POTION_AUGMENTATION:
653 {
654 if (do_inc_stat(p_ptr, A_STR)) *ident = TRUE;
655 if (do_inc_stat(p_ptr, A_INT)) *ident = TRUE;
656 if (do_inc_stat(p_ptr, A_WIS)) *ident = TRUE;
657 if (do_inc_stat(p_ptr, A_DEX)) *ident = TRUE;
658 if (do_inc_stat(p_ptr, A_CON)) *ident = TRUE;
659 if (do_inc_stat(p_ptr, A_CHR)) *ident = TRUE;
660 break;
661 }
662
663 case SV_POTION_ENLIGHTENMENT:
664 {
665 msg_print(p_ptr, "An image of your surroundings forms in your mind...");
666 wiz_lite(p_ptr);
667 *ident = TRUE;
668 break;
669 }
670
671 case SV_POTION_STAR_ENLIGHTENMENT:
672 {
673 msg_print(p_ptr, "You begin to feel more enlightened...");
674 msg_print(p_ptr, NULL);
675 wiz_lite(p_ptr);
676 (void)do_inc_stat(p_ptr, A_INT);
677 (void)do_inc_stat(p_ptr, A_WIS);
678 (void)detect_trap(p_ptr);
679 (void)detect_sdoor(p_ptr);
680 (void)detect_treasure(p_ptr);
681 //(void)detect_objects_gold(p_ptr);
682 (void)detect_objects_normal(p_ptr);
683 identify_pack(p_ptr);
684 self_knowledge(p_ptr, TRUE);
685 *ident = TRUE;
686 break;
687 }
688
689 case SV_POTION_SELF_KNOWLEDGE:
690 {
691 msg_print(p_ptr, "You begin to know yourself a little better...");
692 msg_print(p_ptr, NULL);
693 self_knowledge(p_ptr, TRUE);
694 *ident = TRUE;
695 break;
696 }
697
698 case SV_POTION_EXPERIENCE:
699 {
700 if (p_ptr->exp < PY_MAX_EXP)
701 {
702 s32b ee = (p_ptr->exp / 2) + 10;
703 if (ee > 100000L) ee = 100000L;
704 msg_print(p_ptr, "You feel more experienced.");
705 gain_exp(p_ptr, ee);
706 *ident = TRUE;
707 }
708 break;
709 }
710 }
711
712 /* Potions can feed the player too */
713 (void)set_food(p_ptr, p_ptr->food + o_ptr->pval);
714
715 return (TRUE);
716 }
717
718
read_scroll(player_type * p_ptr,object_type * o_ptr,bool * ident)719 static bool read_scroll(player_type *p_ptr, object_type *o_ptr, bool *ident)
720 {
721 int py = p_ptr->py;
722 int px = p_ptr->px;
723 int Depth = p_ptr->dun_depth;
724
725 int k;
726
727 bool used_up = TRUE;
728
729
730 /* Analyze the scroll */
731 switch (o_ptr->sval)
732 {
733 case SV_SCROLL_DARKNESS:
734 {
735 if (!p_ptr->resist_blind)
736 {
737 (void)set_blind(p_ptr, p_ptr->blind + 3 + randint1(5));
738 }
739 if (unlite_area(p_ptr, 10, 3)) *ident = TRUE;
740 break;
741 }
742
743 case SV_SCROLL_AGGRAVATE_MONSTER:
744 {
745 msg_print(p_ptr, "There is a high pitched humming noise.");
746 aggravate_monsters(p_ptr, 0);
747 *ident = TRUE;
748 break;
749 }
750
751 case SV_SCROLL_CURSE_ARMOR:
752 {
753 if (curse_armor(p_ptr)) *ident = TRUE;
754 break;
755 }
756
757 case SV_SCROLL_CURSE_WEAPON:
758 {
759 if (curse_weapon(p_ptr)) *ident = TRUE;
760 break;
761 }
762
763 case SV_SCROLL_SUMMON_MONSTER:
764 {
765 sound(p_ptr, MSG_SUM_MONSTER);
766 for (k = 0; k < randint1(3); k++)
767 {
768 if (summon_specific(Depth, py, px, p_ptr->dun_depth, 0))
769 {
770 *ident = TRUE;
771 }
772 }
773 break;
774 }
775
776 case SV_SCROLL_SUMMON_UNDEAD:
777 {
778 sound(p_ptr, MSG_SUM_UNDEAD);
779 for (k = 0; k < randint1(3); k++)
780 {
781 if (summon_specific(Depth, py, px, p_ptr->dun_depth, SUMMON_UNDEAD))
782 {
783 *ident = TRUE;
784 }
785 }
786 break;
787 }
788
789 case SV_SCROLL_TRAP_CREATION:
790 {
791 if (trap_creation(p_ptr)) *ident = TRUE;
792 break;
793 }
794
795 case SV_SCROLL_PHASE_DOOR:
796 {
797 teleport_player(p_ptr, 10);
798 *ident = TRUE;
799 break;
800 }
801
802 case SV_SCROLL_TELEPORT:
803 {
804 teleport_player(p_ptr, 100);
805 *ident = TRUE;
806 break;
807 }
808
809 case SV_SCROLL_TELEPORT_LEVEL:
810 {
811 (void)teleport_player_level(p_ptr);
812 *ident = TRUE;
813 break;
814 }
815
816 case SV_SCROLL_WORD_OF_RECALL:
817 {
818 set_recall(p_ptr, o_ptr);
819 *ident = TRUE;
820 break;
821 }
822
823 case SV_SCROLL_IDENTIFY:
824 {
825 *ident = TRUE;
826 if (!ident_spell(p_ptr)) used_up = FALSE;
827 break;
828 }
829
830 case SV_SCROLL_STAR_IDENTIFY:
831 {
832 *ident = TRUE;
833 if (!identify_fully(p_ptr)) used_up = FALSE;
834 break;
835 }
836
837 case SV_SCROLL_REMOVE_CURSE:
838 {
839 if (remove_curse(p_ptr))
840 {
841 msg_print(p_ptr, "You feel as if someone is watching over you.");
842 *ident = TRUE;
843 }
844 break;
845 }
846
847 case SV_SCROLL_STAR_REMOVE_CURSE:
848 {
849 remove_all_curse(p_ptr);
850 *ident = TRUE;
851 break;
852 }
853
854 case SV_SCROLL_ENCHANT_ARMOR:
855 {
856 *ident = TRUE;
857 if (!enchant_spell(p_ptr, 0, 0, 1, FALSE)) used_up = FALSE;
858 break;
859 }
860
861 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
862 {
863 if (!enchant_spell(p_ptr, 1, 0, 0, FALSE)) used_up = FALSE;
864 *ident = TRUE;
865 break;
866 }
867
868 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
869 {
870 if (!enchant_spell(p_ptr, 0, 1, 0, FALSE)) used_up = FALSE;
871 *ident = TRUE;
872 break;
873 }
874
875 case SV_SCROLL_STAR_ENCHANT_ARMOR:
876 {
877 if (!enchant_spell(p_ptr, 0, 0, randint1(3) + 2, FALSE)) used_up = FALSE;
878 *ident = TRUE;
879 break;
880 }
881
882 case SV_SCROLL_STAR_ENCHANT_WEAPON:
883 {
884 if (!enchant_spell(p_ptr, randint1(3), randint1(3), 0, FALSE)) used_up = FALSE;
885 *ident = TRUE;
886 break;
887 }
888
889 case SV_SCROLL_RECHARGING:
890 {
891 if (!recharge(p_ptr, 60)) used_up = FALSE;
892 *ident = TRUE;
893 break;
894 }
895
896 case SV_SCROLL_LIGHT:
897 {
898 if (lite_area(p_ptr, damroll(2, 8), 2)) *ident = TRUE;
899 break;
900 }
901
902 case SV_SCROLL_MAPPING:
903 {
904 map_area(p_ptr);
905 *ident = TRUE;
906 break;
907 }
908
909 case SV_SCROLL_DETECT_GOLD:
910 {
911 if (detect_treasure(p_ptr)) *ident = TRUE;
912 //if (detect_objects_gold(p_ptr)) *ident = TRUE;
913 break;
914 }
915
916 case SV_SCROLL_DETECT_ITEM:
917 {
918 if (detect_objects_normal(p_ptr)) *ident = TRUE;
919 break;
920 }
921
922 case SV_SCROLL_DETECT_TRAP:
923 {
924 if (detect_trap(p_ptr)) *ident = TRUE;
925 break;
926 }
927
928 case SV_SCROLL_DETECT_DOOR:
929 {
930 if (detect_sdoor(p_ptr)) *ident = TRUE;//_doors
931 //if (detect_stairs(p_ptr)) *ident = TRUE;
932 break;
933 }
934
935 case SV_SCROLL_DETECT_INVIS:
936 {
937 if (detect_invisible(p_ptr, TRUE)) *ident = TRUE;
938 break;
939 }
940
941 case SV_SCROLL_SATISFY_HUNGER:
942 {
943 if (set_food(p_ptr, PY_FOOD_MAX - 1)) *ident = TRUE;
944 break;
945 }
946
947 case SV_SCROLL_BLESSING:
948 {
949 if (set_blessed(p_ptr, p_ptr->blessed + randint1(12) + 6)) *ident = TRUE;
950 break;
951 }
952
953 case SV_SCROLL_HOLY_CHANT:
954 {
955 if (set_blessed(p_ptr, p_ptr->blessed + randint1(24) + 12)) *ident = TRUE;
956 break;
957 }
958
959 case SV_SCROLL_HOLY_PRAYER:
960 {
961 if (set_blessed(p_ptr, p_ptr->blessed + randint1(48) + 24)) *ident = TRUE;
962 break;
963 }
964
965 case SV_SCROLL_MONSTER_CONFUSION:
966 {
967 if (p_ptr->confusing == 0)
968 {
969 msg_print(p_ptr, "Your hands begin to glow.");
970 p_ptr->confusing = TRUE;
971 *ident = TRUE;
972 }
973 break;
974 }
975
976 case SV_SCROLL_PROTECTION_FROM_EVIL:
977 {
978 k = 3 * p_ptr->lev;
979 if (set_protevil(p_ptr, p_ptr->protevil + randint1(25) + k)) *ident = TRUE;
980 break;
981 }
982
983 case SV_SCROLL_RUNE_OF_PROTECTION:
984 {
985 warding_glyph(p_ptr);
986 *ident = TRUE;
987 break;
988 }
989
990 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
991 {
992 if (destroy_doors_touch(p_ptr)) *ident = TRUE;
993 break;
994 }
995
996 case SV_SCROLL_STAR_DESTRUCTION:
997 {
998 destroy_area(Depth, py, px, 15, TRUE);
999 *ident = TRUE;
1000 break;
1001 }
1002
1003 case SV_SCROLL_DISPEL_UNDEAD:
1004 {
1005 if (dispel_undead(p_ptr, 60)) *ident = TRUE;
1006 break;
1007 }
1008
1009 case SV_SCROLL_BANISHMENT:
1010 {
1011 if (!banishment(p_ptr)) used_up = FALSE;
1012 *ident = TRUE;
1013 break;
1014 }
1015
1016 case SV_SCROLL_MASS_BANISHMENT:
1017 {
1018 (void)mass_banishment(p_ptr);
1019 *ident = TRUE;
1020 break;
1021 }
1022
1023 case SV_SCROLL_ACQUIREMENT:
1024 {
1025 acquirement(Depth, py, px, 1, TRUE);
1026 *ident = TRUE;
1027 break;
1028 }
1029
1030 case SV_SCROLL_STAR_ACQUIREMENT:
1031 {
1032 acquirement(Depth, py, px, randint1(2) + 1, TRUE);
1033 *ident = TRUE;
1034 break;
1035 }
1036
1037 /* MAngband-specific scrolls */
1038 case SV_SCROLL_LIFE:
1039 {
1040 restore_level(p_ptr);
1041 do_scroll_life(p_ptr);
1042 *ident = TRUE;
1043 break;
1044 }
1045
1046 case SV_SCROLL_CREATE_ARTIFACT:
1047 {
1048 if (p_ptr->dm_flags & DM_CAN_GENERATE)
1049 {
1050 (void)create_artifact(p_ptr);
1051 used_up = FALSE;
1052 *ident = TRUE;
1053 }
1054 else
1055 {
1056 *ident = TRUE;
1057 msg_print(p_ptr, "You failed to read the scroll properly.");
1058 }
1059 break;
1060 }
1061
1062 case SV_SCROLL_CREATE_HOUSE:
1063 {
1064 msg_print(p_ptr, "This is a scroll of house creation.");
1065 used_up = create_house(p_ptr);
1066 *ident = TRUE;
1067 break;
1068 }
1069
1070 }
1071
1072 return (used_up);
1073 }
1074
1075
use_staff(player_type * p_ptr,object_type * o_ptr,bool * ident)1076 static bool use_staff(player_type *p_ptr, object_type *o_ptr, bool *ident)
1077 {
1078 int py = p_ptr->py;
1079 int px = p_ptr->px;
1080 int Depth = p_ptr->dun_depth;
1081
1082 int k;
1083
1084 bool use_charge = TRUE;
1085
1086 /* Analyze the staff */
1087 switch (o_ptr->sval)
1088 {
1089 case SV_STAFF_DARKNESS:
1090 {
1091 if (!p_ptr->resist_blind)
1092 {
1093 if (set_blind(p_ptr, p_ptr->blind + 3 + randint1(5))) *ident = TRUE;
1094 }
1095 if (unlite_area(p_ptr, 10, 3)) *ident = TRUE;
1096 break;
1097 }
1098
1099 case SV_STAFF_SLOWNESS:
1100 {
1101 if (set_slow(p_ptr, p_ptr->slow + randint1(30) + 15)) *ident = TRUE;
1102 break;
1103 }
1104
1105 case SV_STAFF_HASTE_MONSTERS:
1106 {
1107 if (speed_monsters(p_ptr)) *ident = TRUE;
1108 break;
1109 }
1110
1111 case SV_STAFF_SUMMONING:
1112 {
1113 sound(p_ptr, MSG_SUM_MONSTER);
1114 for (k = 0; k < randint1(4); k++)
1115 {
1116 if (summon_specific(Depth, py, px, p_ptr->dun_depth, 0))
1117 {
1118 *ident = TRUE;
1119 }
1120 }
1121 break;
1122 }
1123
1124 case SV_STAFF_TELEPORTATION:
1125 {
1126 msg_misc("%s teleports away!");
1127 teleport_player(p_ptr, 100);
1128 *ident = TRUE;
1129 break;
1130 }
1131
1132 case SV_STAFF_IDENTIFY:
1133 {
1134 if (!ident_spell(p_ptr)) use_charge = FALSE;
1135 *ident = TRUE;
1136 break;
1137 }
1138
1139 case SV_STAFF_REMOVE_CURSE:
1140 {
1141 if (remove_curse(p_ptr))
1142 {
1143 if (!p_ptr->blind)
1144 {
1145 msg_print(p_ptr, "The staff glows blue for a moment...");
1146 }
1147 *ident = TRUE;
1148 }
1149 break;
1150 }
1151
1152 case SV_STAFF_STARLITE:
1153 {
1154 if (!p_ptr->blind)
1155 {
1156 msg_print(p_ptr, "The end of the staff glows brightly...");
1157 }
1158 for (k = 0; k < 8; k++) lite_line(p_ptr, ddd[k]);
1159 *ident = TRUE;
1160 break;
1161 }
1162
1163 case SV_STAFF_LITE:
1164 {
1165 msg_misc("%s calls light.");
1166 if (lite_area(p_ptr, damroll(2, 8), 2)) *ident = TRUE;
1167 break;
1168 }
1169
1170 case SV_STAFF_MAPPING:
1171 {
1172 map_area(p_ptr);
1173 *ident = TRUE;
1174 break;
1175 }
1176
1177 case SV_STAFF_DETECT_GOLD:
1178 {
1179 if (detect_treasure(p_ptr)) *ident = TRUE;
1180 //if (detect_objects_gold(p_ptr)) *ident = TRUE;
1181 break;
1182 }
1183
1184 case SV_STAFF_DETECT_ITEM:
1185 {
1186 if (detect_objects_normal(p_ptr)) *ident = TRUE;
1187 break;
1188 }
1189
1190 case SV_STAFF_DETECT_TRAP:
1191 {
1192 if (detect_trap(p_ptr)) *ident = TRUE;
1193 break;
1194 }
1195
1196 case SV_STAFF_DETECT_DOOR:
1197 {
1198 if (detect_sdoor(p_ptr)) *ident = TRUE;
1199 break;
1200 }
1201
1202 case SV_STAFF_DETECT_INVIS:
1203 {
1204 if (detect_invisible(p_ptr, TRUE)) *ident = TRUE;
1205 break;
1206 }
1207
1208 case SV_STAFF_DETECT_EVIL:
1209 {
1210 if (detect_evil(p_ptr)) *ident = TRUE;
1211 break;
1212 }
1213
1214 case SV_STAFF_CURE_LIGHT:
1215 {
1216 if (hp_player(p_ptr, randint1(8))) *ident = TRUE;
1217 break;
1218 }
1219
1220 case SV_STAFF_CURING:
1221 {
1222 if (set_blind(p_ptr, 0)) *ident = TRUE;
1223 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
1224 if (set_confused(p_ptr, 0)) *ident = TRUE;
1225 if (set_stun(p_ptr, 0)) *ident = TRUE;
1226 if (set_cut(p_ptr, 0)) *ident = TRUE;
1227 break;
1228 }
1229
1230 case SV_STAFF_HEALING:
1231 {
1232 if (hp_player(p_ptr, 300)) *ident = TRUE;
1233 if (set_stun(p_ptr, 0)) *ident = TRUE;
1234 if (set_cut(p_ptr, 0)) *ident = TRUE;
1235 break;
1236 }
1237
1238 case SV_STAFF_THE_MAGI:
1239 {
1240 if (do_res_stat(p_ptr, A_INT)) *ident = TRUE;
1241 if (p_ptr->csp < p_ptr->msp)
1242 {
1243 p_ptr->csp = p_ptr->msp;
1244 p_ptr->csp_frac = 0;
1245 *ident = TRUE;
1246 msg_print(p_ptr, "Your feel your head clear.");
1247 p_ptr->redraw |= (PR_MANA);
1248 p_ptr->window |= (PW_PLAYER_0 | PW_PLAYER_1);
1249 }
1250 break;
1251 }
1252
1253 case SV_STAFF_SLEEP_MONSTERS:
1254 {
1255 if (sleep_monsters(p_ptr)) *ident = TRUE;
1256 break;
1257 }
1258
1259 case SV_STAFF_SLOW_MONSTERS:
1260 {
1261 if (slow_monsters(p_ptr)) *ident = TRUE;
1262 break;
1263 }
1264
1265 case SV_STAFF_SPEED:
1266 {
1267 if (!p_ptr->fast)
1268 {
1269 if (set_fast(p_ptr, randint1(30) + 15)) *ident = TRUE;
1270 }
1271 else
1272 {
1273 (void)set_fast(p_ptr, p_ptr->fast + 5);
1274 }
1275 break;
1276 }
1277
1278 case SV_STAFF_PROBING:
1279 {
1280 probing(p_ptr);
1281 *ident = TRUE;
1282 break;
1283 }
1284
1285 case SV_STAFF_DISPEL_EVIL:
1286 {
1287 if (dispel_evil(p_ptr, 60)) *ident = TRUE;
1288 break;
1289 }
1290
1291 case SV_STAFF_POWER:
1292 {
1293 if (dispel_monsters(p_ptr, 120)) *ident = TRUE;
1294 break;
1295 }
1296
1297 case SV_STAFF_HOLINESS:
1298 {
1299 if (dispel_evil(p_ptr, 120)) *ident = TRUE;
1300 k = 3 * p_ptr->lev;
1301 if (set_protevil(p_ptr, p_ptr->protevil + randint1(25) + k)) *ident = TRUE;
1302 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
1303 if (set_afraid(p_ptr, 0)) *ident = TRUE;
1304 if (hp_player(p_ptr, 50)) *ident = TRUE;
1305 if (set_stun(p_ptr, 0)) *ident = TRUE;
1306 if (set_cut(p_ptr, 0)) *ident = TRUE;
1307 break;
1308 }
1309
1310 case SV_STAFF_BANISHMENT:
1311 {
1312 if (!banishment(p_ptr)) use_charge = FALSE;
1313 *ident = TRUE;
1314 break;
1315 }
1316
1317 case SV_STAFF_EARTHQUAKES:
1318 {
1319 msg_misc("%s causes the ground to shake!");
1320 earthquake(Depth, py, px, 10);
1321 *ident = TRUE;
1322 break;
1323 }
1324
1325 case SV_STAFF_DESTRUCTION:
1326 {
1327 msg_misc("%s unleashes great power!");
1328 destroy_area(Depth, py, px, 15, TRUE);
1329 *ident = TRUE;
1330 break;
1331 }
1332 }
1333
1334 return (use_charge);
1335 }
1336
1337
aim_wand(player_type * p_ptr,object_type * o_ptr,bool * ident)1338 static bool aim_wand(player_type *p_ptr, object_type *o_ptr, bool *ident)
1339 {
1340 int lev, chance, dir, sval;
1341
1342
1343 /* Allow direction to be cancelled for free */
1344 if (!get_aim_dir(p_ptr, &dir)) return (FALSE);
1345
1346 /* Take a turn */
1347 /*p_ptr->energy_use = 100; */
1348
1349 /* Not identified yet */
1350 *ident = FALSE;
1351
1352 /* Get the level */
1353 lev = k_info[o_ptr->k_idx].level;
1354
1355 /* Base chance of success */
1356 chance = p_ptr->skill_dev;
1357
1358 /* Confusion hurts skill */
1359 if (p_ptr->confused) chance = chance / 2;
1360
1361 /* High level objects are harder */
1362 chance = chance - ((lev > 50) ? 50 : lev);
1363
1364 /* Give everyone a (slight) chance */
1365 if ((chance < USE_DEVICE) && (randint0(USE_DEVICE - chance + 1) == 0))
1366 {
1367 chance = USE_DEVICE;
1368 }
1369
1370 /* Roll for usage */
1371 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE))
1372 {
1373 /*if (flush_failure) flush();*/
1374 msg_print(p_ptr, "You failed to use the wand properly.");
1375 return (FALSE);
1376 }
1377
1378 /* The wand is already empty! */
1379 if (o_ptr->pval <= 0)
1380 {
1381 /*if (flush_failure) flush();*/
1382 if (o_ptr->number == 1)
1383 msg_print(p_ptr, "The wand has no charges left.");
1384 else
1385 msg_print(p_ptr, "The wands have no charges left.");
1386 o_ptr->ident |= (ID_EMPTY);
1387 /* Refresh inventory */
1388 if (o_ptr->ix == 0 && o_ptr->iy == 0)
1389 {
1390 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1391 }
1392 /* Refresh floor */
1393 else
1394 {
1395 p_ptr->redraw |= (PR_FLOOR);
1396 }
1397 return (FALSE);
1398 }
1399
1400
1401 /* sound */
1402
1403
1404 /* XXX Hack -- Extract the "sval" effect */
1405 sval = o_ptr->sval;
1406
1407 /* XXX Hack -- Wand of wonder can do anything before it */
1408 if (sval == SV_WAND_WONDER) sval = randint0(SV_WAND_WONDER);
1409
1410 /* Analyze the wand */
1411 switch (sval)
1412 {
1413 case SV_WAND_HEAL_MONSTER:
1414 {
1415 if (heal_monster(p_ptr, dir)) *ident = TRUE;
1416 break;
1417 }
1418
1419 case SV_WAND_HASTE_MONSTER:
1420 {
1421 if (speed_monster(p_ptr, dir)) *ident = TRUE;
1422 break;
1423 }
1424
1425 case SV_WAND_CLONE_MONSTER:
1426 {
1427 if (clone_monster(p_ptr, dir)) *ident = TRUE;
1428 break;
1429 }
1430
1431 case SV_WAND_TELEPORT_AWAY:
1432 {
1433 if (teleport_monster(p_ptr, dir)) *ident = TRUE;
1434 break;
1435 }
1436
1437 case SV_WAND_DISARMING:
1438 {
1439 if (disarm_trap(p_ptr, dir)) *ident = TRUE;
1440 break;
1441 }
1442
1443 case SV_WAND_TRAP_DOOR_DEST:
1444 {
1445 if (destroy_door(p_ptr, dir)) *ident = TRUE;
1446 break;
1447 }
1448
1449 case SV_WAND_STONE_TO_MUD:
1450 {
1451 if (wall_to_mud(p_ptr, dir)) *ident = TRUE;
1452 break;
1453 }
1454
1455 case SV_WAND_LITE:
1456 {
1457 msg_print(p_ptr, "A line of blue shimmering light appears.");
1458 lite_line(p_ptr, dir);
1459 *ident = TRUE;
1460 break;
1461 }
1462
1463 case SV_WAND_SLEEP_MONSTER:
1464 {
1465 if (sleep_monster(p_ptr, dir)) *ident = TRUE;
1466 break;
1467 }
1468
1469 case SV_WAND_SLOW_MONSTER:
1470 {
1471 if (slow_monster(p_ptr, dir)) *ident = TRUE;
1472 break;
1473 }
1474
1475 case SV_WAND_CONFUSE_MONSTER:
1476 {
1477 if (confuse_monster(p_ptr, dir, 10)) *ident = TRUE;
1478 break;
1479 }
1480
1481 case SV_WAND_FEAR_MONSTER:
1482 {
1483 if (fear_monster(p_ptr, dir, 10)) *ident = TRUE;
1484 break;
1485 }
1486
1487 case SV_WAND_DRAIN_LIFE:
1488 {
1489 if (drain_life(p_ptr, dir, 150)) *ident = TRUE;
1490 break;
1491 }
1492
1493 case SV_WAND_POLYMORPH:
1494 {
1495 if (poly_monster(p_ptr, dir)) *ident = TRUE;
1496 break;
1497 }
1498
1499 case SV_WAND_STINKING_CLOUD:
1500 {
1501 msg_misc("%s fires a stinking cloud.");
1502 fire_ball(p_ptr, GF_POIS, dir, 12, 2);
1503 *ident = TRUE;
1504 break;
1505 }
1506
1507 case SV_WAND_MAGIC_MISSILE:
1508 {
1509 msg_misc("%s fires a magic missile.");
1510 fire_bolt_or_beam(p_ptr, 20, GF_MISSILE, dir, damroll(3, 4));
1511 *ident = TRUE;
1512 break;
1513 }
1514
1515 case SV_WAND_ACID_BOLT:
1516 {
1517 msg_misc("%s fires an acid bolt.");
1518 fire_bolt_or_beam(p_ptr, 20, GF_ACID, dir, damroll(10, 8));
1519 *ident = TRUE;
1520 break;
1521 }
1522
1523 case SV_WAND_ELEC_BOLT:
1524 {
1525 msg_misc("%s fires a lightning bolt.");
1526 fire_bolt_or_beam(p_ptr, 20, GF_ELEC, dir, damroll(6, 6));
1527 *ident = TRUE;
1528 break;
1529 }
1530
1531 case SV_WAND_FIRE_BOLT:
1532 {
1533 msg_misc("%s fires a fire bolt.");
1534 fire_bolt_or_beam(p_ptr, 20, GF_FIRE, dir, damroll(12, 8));
1535 *ident = TRUE;
1536 break;
1537 }
1538
1539 case SV_WAND_COLD_BOLT:
1540 {
1541 msg_misc("%s fires a frost bolt.");
1542 fire_bolt_or_beam(p_ptr, 20, GF_COLD, dir, damroll(6, 8));
1543 *ident = TRUE;
1544 break;
1545 }
1546
1547 case SV_WAND_ACID_BALL:
1548 {
1549 msg_misc("%s fires a ball of acid.");
1550 fire_ball(p_ptr, GF_ACID, dir, 120, 2);
1551 *ident = TRUE;
1552 break;
1553 }
1554
1555 case SV_WAND_ELEC_BALL:
1556 {
1557 msg_misc("%s fires a ball of electricity.");
1558 fire_ball(p_ptr, GF_ELEC, dir, 64, 2);
1559 *ident = TRUE;
1560 break;
1561 }
1562
1563 case SV_WAND_FIRE_BALL:
1564 {
1565 msg_misc("%s fires a fire ball.");
1566 fire_ball(p_ptr, GF_FIRE, dir, 144, 2);
1567 *ident = TRUE;
1568 break;
1569 }
1570
1571 case SV_WAND_COLD_BALL:
1572 {
1573 msg_misc("%s fires a frost ball.");
1574 fire_ball(p_ptr, GF_COLD, dir, 96, 2);
1575 *ident = TRUE;
1576 break;
1577 }
1578
1579 case SV_WAND_WONDER:
1580 {
1581 msg_print(p_ptr, "Oops. Wand of wonder activated.");
1582 break;
1583 }
1584
1585 case SV_WAND_DRAGON_FIRE:
1586 {
1587 msg_misc("%s shoots dragon fire!");
1588 fire_ball(p_ptr, GF_FIRE, dir, 200, 3);
1589 *ident = TRUE;
1590 break;
1591 }
1592
1593 case SV_WAND_DRAGON_COLD:
1594 {
1595 msg_misc("%s shoots dragon frost!");
1596 fire_ball(p_ptr, GF_COLD, dir, 160, 3);
1597 *ident = TRUE;
1598 break;
1599 }
1600
1601 case SV_WAND_DRAGON_BREATH:
1602 {
1603 switch (randint1(5))
1604 {
1605 case 1:
1606 {
1607 msg_misc("%s shoots dragon acid!");
1608 fire_ball(p_ptr, GF_ACID, dir, 200, 3);
1609 break;
1610 }
1611
1612 case 2:
1613 {
1614 msg_misc("%s shoots dragon lightning!");
1615 fire_ball(p_ptr, GF_ELEC, dir, 160, 3);
1616 break;
1617 }
1618
1619 case 3:
1620 {
1621 msg_misc("%s shoots dragon fire!");
1622 fire_ball(p_ptr, GF_FIRE, dir, 200, 3);
1623 break;
1624 }
1625
1626 case 4:
1627 {
1628 msg_misc("%s shoots dragon frost!");
1629 fire_ball(p_ptr, GF_COLD, dir, 160, 3);
1630 break;
1631 }
1632
1633 default:
1634 {
1635 msg_misc("%s shoots dragon poison!");
1636 fire_ball(p_ptr, GF_POIS, dir, 120, 3);
1637 break;
1638 }
1639 }
1640
1641 *ident = TRUE;
1642 break;
1643 }
1644
1645 case SV_WAND_ANNIHILATION:
1646 {
1647 if (drain_life(p_ptr, dir, 250)) *ident = TRUE;
1648 break;
1649 }
1650 }
1651
1652 return (TRUE);
1653 }
1654
1655
zap_rod(player_type * p_ptr,object_type * o_ptr,bool * ident)1656 static bool zap_rod(player_type *p_ptr, object_type *o_ptr, bool *ident)
1657 {
1658 int chance, dir, lev, power;
1659 bool used_charge = TRUE;
1660 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1661
1662
1663 /* Get a direction (unless KNOWN not to need it) */
1664 if ((o_ptr->sval >= SV_ROD_MIN_DIRECTION) || !object_aware_p(p_ptr, o_ptr))
1665 {
1666 /* Get a direction, allow cancel */
1667 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
1668 }
1669
1670
1671 /* Take a turn */
1672 p_ptr->energy -= level_speed(p_ptr->dun_depth);
1673
1674 /* Not identified yet */
1675 *ident = FALSE;
1676
1677 /* Extract the item level */
1678 lev = k_info[o_ptr->k_idx].level;
1679
1680 /* Base chance of success */
1681 chance = p_ptr->skill_dev;
1682
1683 /* Confusion hurts skill */
1684 if (p_ptr->confused) chance = chance / 2;
1685
1686 /* High level objects are harder */
1687 chance = chance - ((lev > 50) ? 50 : lev);
1688
1689 /* Give everyone a (slight) chance */
1690 if ((chance < USE_DEVICE) && (randint0(USE_DEVICE - chance + 1) == 0))
1691 {
1692 chance = USE_DEVICE;
1693 }
1694
1695 /* Roll for usage */
1696 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE))
1697 {
1698 /* if (flush_failure) flush(); */
1699 msg_print(p_ptr, "You failed to use the rod properly.");
1700 return FALSE;
1701 }
1702
1703 /* Find out how many rods are charging, by dividing
1704 * current timeout by each rod's maximum timeout.
1705 * Ensure that any remainder is rounded up.
1706 */
1707 power = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
1708 if (power >= o_ptr->number)
1709 {
1710 /*if (flush_failure) flush();*/
1711
1712 if (o_ptr->number == 1)
1713 msg_print(p_ptr, "The rod is still charging.");
1714 else
1715 msg_print(p_ptr, "The rods are all still charging.");
1716
1717 return FALSE;
1718 }
1719
1720 /* sound */
1721 sound(p_ptr, MSG_ZAP_ROD);
1722
1723 /* Analyze the rod */
1724 switch (o_ptr->sval)
1725 {
1726 case SV_ROD_DETECT_TRAP:
1727 {
1728 if (detect_trap(p_ptr)) *ident = TRUE;
1729 break;
1730 }
1731
1732 case SV_ROD_DETECT_DOOR:
1733 {
1734 if (detect_sdoor(p_ptr)) *ident = TRUE;
1735 break;
1736 }
1737
1738 case SV_ROD_IDENTIFY:
1739 {
1740 *ident = TRUE;
1741 if (!ident_spell(p_ptr)) used_charge = FALSE;
1742 break;
1743 }
1744
1745 case SV_ROD_RECALL:
1746 {
1747 set_recall(p_ptr, o_ptr);
1748 *ident = TRUE;
1749 break;
1750 }
1751
1752 case SV_ROD_ILLUMINATION:
1753 {
1754 msg_misc("%s calls light.");
1755 if (lite_area(p_ptr, damroll(2, 8), 2)) *ident = TRUE;
1756 break;
1757 }
1758
1759 case SV_ROD_MAPPING:
1760 {
1761 map_area(p_ptr);
1762 *ident = TRUE;
1763 break;
1764 }
1765
1766 case SV_ROD_DETECTION:
1767 {
1768 detection(p_ptr);
1769 *ident = TRUE;
1770 break;
1771 }
1772
1773 case SV_ROD_PROBING:
1774 {
1775 probing(p_ptr);
1776 *ident = TRUE;
1777 break;
1778 }
1779
1780 case SV_ROD_CURING:
1781 {
1782 if (set_blind(p_ptr, 0)) *ident = TRUE;
1783 if (set_poisoned(p_ptr, 0)) *ident = TRUE;
1784 if (set_confused(p_ptr, 0)) *ident = TRUE;
1785 if (set_stun(p_ptr, 0)) *ident = TRUE;
1786 if (set_cut(p_ptr, 0)) *ident = TRUE;
1787 break;
1788 }
1789
1790 case SV_ROD_HEALING:
1791 {
1792 if (hp_player(p_ptr, 500)) *ident = TRUE;
1793 if (set_stun(p_ptr, 0)) *ident = TRUE;
1794 if (set_cut(p_ptr, 0)) *ident = TRUE;
1795 break;
1796 }
1797
1798 case SV_ROD_RESTORATION:
1799 {
1800 if (restore_level(p_ptr)) *ident = TRUE;
1801 if (do_res_stat(p_ptr, A_STR)) *ident = TRUE;
1802 if (do_res_stat(p_ptr, A_INT)) *ident = TRUE;
1803 if (do_res_stat(p_ptr, A_WIS)) *ident = TRUE;
1804 if (do_res_stat(p_ptr, A_DEX)) *ident = TRUE;
1805 if (do_res_stat(p_ptr, A_CON)) *ident = TRUE;
1806 if (do_res_stat(p_ptr, A_CHR)) *ident = TRUE;
1807 break;
1808 }
1809
1810 case SV_ROD_SPEED:
1811 {
1812 if (!p_ptr->fast)
1813 {
1814 if (set_fast(p_ptr, randint1(30) + 15)) *ident = TRUE;
1815 }
1816 else
1817 {
1818 (void)set_fast(p_ptr, p_ptr->fast + 5);
1819 }
1820 break;
1821 }
1822
1823 case SV_ROD_TELEPORT_AWAY:
1824 {
1825 if (teleport_monster(p_ptr, dir)) *ident = TRUE;
1826 break;
1827 }
1828
1829 case SV_ROD_DISARMING:
1830 {
1831 if (disarm_trap(p_ptr, dir)) *ident = TRUE;
1832 break;
1833 }
1834
1835 case SV_ROD_LITE:
1836 {
1837 msg_print(p_ptr, "A line of blue shimmering light appears.");
1838 lite_line(p_ptr, dir);
1839 *ident = TRUE;
1840 break;
1841 }
1842
1843 case SV_ROD_SLEEP_MONSTER:
1844 {
1845 if (sleep_monster(p_ptr, dir)) *ident = TRUE;
1846 break;
1847 }
1848
1849 case SV_ROD_SLOW_MONSTER:
1850 {
1851 if (slow_monster(p_ptr, dir)) *ident = TRUE;
1852 break;
1853 }
1854
1855 case SV_ROD_DRAIN_LIFE:
1856 {
1857 if (drain_life(p_ptr, dir, 150)) *ident = TRUE;
1858 break;
1859 }
1860
1861 case SV_ROD_POLYMORPH:
1862 {
1863 if (poly_monster(p_ptr, dir)) *ident = TRUE;
1864 break;
1865 }
1866
1867 case SV_ROD_ACID_BOLT:
1868 {
1869 msg_misc("%s fires an acid bolt.");
1870 fire_bolt_or_beam(p_ptr, 10, GF_ACID, dir, damroll(12, 8));
1871 *ident = TRUE;
1872 break;
1873 }
1874
1875 case SV_ROD_ELEC_BOLT:
1876 {
1877 msg_misc("%s fires a lightning bolt.");
1878 fire_bolt_or_beam(p_ptr, 10, GF_ELEC, dir, damroll(6, 6));
1879 *ident = TRUE;
1880 break;
1881 }
1882
1883 case SV_ROD_FIRE_BOLT:
1884 {
1885 msg_misc("%s fires a fire bolt.");
1886 fire_bolt_or_beam(p_ptr, 10, GF_FIRE, dir, damroll(16, 8));
1887 *ident = TRUE;
1888 break;
1889 }
1890
1891 case SV_ROD_COLD_BOLT:
1892 {
1893 msg_misc("%s fires a frost bolt.");
1894 fire_bolt_or_beam(p_ptr, 10, GF_COLD, dir, damroll(10, 8));
1895 *ident = TRUE;
1896 break;
1897 }
1898
1899 case SV_ROD_ACID_BALL:
1900 {
1901 msg_misc("%s fires an acid ball.");
1902 fire_ball(p_ptr, GF_ACID, dir, 120, 2);
1903 *ident = TRUE;
1904 break;
1905 }
1906
1907 case SV_ROD_ELEC_BALL:
1908 {
1909 msg_misc("%s fires a lightning ball.");
1910 fire_ball(p_ptr, GF_ELEC, dir, 64, 2);
1911 *ident = TRUE;
1912 break;
1913 }
1914
1915 case SV_ROD_FIRE_BALL:
1916 {
1917 msg_misc("%s fires a fire ball.");
1918 fire_ball(p_ptr, GF_FIRE, dir, 144, 2);
1919 *ident = TRUE;
1920 break;
1921 }
1922
1923 case SV_ROD_COLD_BALL:
1924 {
1925 msg_misc("%s fires a frost ball.");
1926 fire_ball(p_ptr, GF_COLD, dir, 96, 2);
1927 *ident = TRUE;
1928 break;
1929 }
1930 }
1931
1932 /* Drain the charge */
1933 if (used_charge) o_ptr->timeout += k_ptr->pval;
1934
1935 return TRUE;
1936 }
1937
1938
1939 /*
1940 * Activate a wielded object. Wielded objects never stack.
1941 * And even if they did, activatable objects never stack.
1942 *
1943 * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated.
1944 * But one could, for example, easily make an activatable "Ring of Plasma".
1945 *
1946 * Note that it always takes a turn to activate an artifact, even if
1947 * the user hits "escape" at the "direction" prompt.
1948 */
activate_object(player_type * p_ptr,object_type * o_ptr,bool * ident)1949 static bool activate_object(player_type *p_ptr, object_type *o_ptr, bool *ident)
1950 {
1951 int k, dir, i, chance;
1952
1953
1954 /* Check the recharge */
1955 if (o_ptr->timeout)
1956 {
1957 msg_print(p_ptr, "It whines, glows and fades...");
1958 return FALSE;
1959 }
1960
1961 /* Activate the artifact */
1962 msg_print_aux(p_ptr, "You activate it...", MSG_ACT_ARTIFACT);
1963
1964 /* Artifacts */
1965 if (artifact_p(o_ptr))
1966 {
1967 artifact_type *a_ptr = artifact_ptr(o_ptr);
1968 char o_name[80];
1969
1970 /* Get the basic name of the object */
1971 object_desc(p_ptr, o_name, sizeof(o_name), o_ptr, FALSE, 0);
1972
1973 switch (a_ptr->activation)
1974 {
1975 case ACT_ILLUMINATION:
1976 {
1977 msg_format(p_ptr, "The %s wells with clear light...", o_name);
1978 lite_area(p_ptr, damroll(2, 15), 3);
1979 break;
1980 }
1981
1982 case ACT_MAGIC_MAP:
1983 {
1984 msg_format(p_ptr, "The %s shines brightly...", o_name);
1985 map_area(p_ptr);
1986 break;
1987 }
1988
1989 case ACT_CLAIRVOYANCE:
1990 {
1991 msg_format(p_ptr, "The %s glows a deep green...", o_name);
1992 wiz_lite(p_ptr);
1993 (void)detect_trap(p_ptr);
1994 (void)detect_sdoor(p_ptr);
1995 break;
1996 }
1997
1998 case ACT_PROT_EVIL:
1999 {
2000 msg_format(p_ptr, "The %s lets out a shrill wail...", o_name);
2001 k = 3 * p_ptr->lev;
2002 (void)set_protevil(p_ptr, p_ptr->protevil + randint1(25) + k);
2003 break;
2004 }
2005
2006 case ACT_DISP_EVIL:
2007 {
2008 msg_format(p_ptr, "The %s floods the area with goodness...", o_name);
2009 dispel_evil(p_ptr, p_ptr->lev * 5);
2010 break;
2011 }
2012
2013 case ACT_HASTE2:
2014 {
2015 msg_format(p_ptr, "The %s glows brightly...", o_name);
2016 if (!p_ptr->fast)
2017 {
2018 (void)set_fast(p_ptr, randint1(75) + 75);
2019 }
2020 else
2021 {
2022 (void)set_fast(p_ptr, p_ptr->fast + 5);
2023 }
2024 break;
2025 }
2026
2027 case ACT_FIRE3:
2028 {
2029 msg_format(p_ptr, "The %s glows deep red...", o_name);
2030 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2031 fire_ball(p_ptr, GF_FIRE, dir, 120, 3);
2032 break;
2033 }
2034
2035 case ACT_FROST5:
2036 {
2037 msg_format(p_ptr, "The %s glows bright white...", o_name);
2038 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2039 fire_ball(p_ptr, GF_COLD, dir, 200, 3);
2040 break;
2041 }
2042
2043 case ACT_ELEC2:
2044 {
2045 msg_format(p_ptr, "The %s glows deep blue...", o_name);
2046 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2047 fire_ball(p_ptr, GF_ELEC, dir, 250, 3);
2048 break;
2049 }
2050
2051 case ACT_BIZZARE:
2052 {
2053 msg_format(p_ptr, "The %s glows intensely black...", o_name);
2054 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2055 ring_of_power(p_ptr, dir);
2056 break;
2057 }
2058
2059
2060 case ACT_STAR_BALL:
2061 {
2062 msg_format(p_ptr, "Your %s is surrounded by lightning...", o_name);
2063 for (i = 0; i < 8; i++) fire_ball(p_ptr, GF_ELEC, ddd[i], 150, 3);
2064 break;
2065 }
2066
2067 case ACT_RAGE_BLESS_RESIST:
2068 {
2069 msg_format(p_ptr, "Your %s glows many colours...", o_name);
2070 (void)hp_player(p_ptr, 30);
2071 (void)set_afraid(p_ptr, 0);
2072 (void)set_shero(p_ptr, p_ptr->shero + randint1(50) + 50);
2073 (void)set_blessed(p_ptr, p_ptr->blessed + randint1(50) + 50);
2074 (void)set_oppose_acid(p_ptr, p_ptr->oppose_acid + randint1(50) + 50);
2075 (void)set_oppose_elec(p_ptr, p_ptr->oppose_elec + randint1(50) + 50);
2076 (void)set_oppose_fire(p_ptr, p_ptr->oppose_fire + randint1(50) + 50);
2077 (void)set_oppose_cold(p_ptr, p_ptr->oppose_cold + randint1(50) + 50);
2078 (void)set_oppose_pois(p_ptr, p_ptr->oppose_pois + randint1(50) + 50);
2079 break;
2080 }
2081
2082 case ACT_HEAL2:
2083 {
2084 msg_format(p_ptr, "Your %s glows a bright white...", o_name);
2085 msg_print(p_ptr, "You feel much better...");
2086 (void)hp_player(p_ptr, 1000);
2087 (void)set_cut(p_ptr, 0);
2088 break;
2089 }
2090
2091 case ACT_PHASE:
2092 {
2093 msg_format(p_ptr, "Your %s twists space around you...", o_name);
2094 teleport_player(p_ptr, 10);
2095 break;
2096 }
2097
2098 case ACT_BANISHMENT:
2099 {
2100 msg_format(p_ptr, "Your %s glows deep blue...", o_name);
2101 if (!banishment(p_ptr)) return FALSE;
2102 break;
2103 }
2104
2105 case ACT_TRAP_DOOR_DEST:
2106 {
2107 msg_format(p_ptr, "Your %s glows bright red...", o_name);
2108 destroy_doors_touch(p_ptr);
2109 break;
2110 }
2111
2112 case ACT_DETECT:
2113 {
2114 msg_format(p_ptr, "Your %s glows bright white...", o_name);
2115 msg_print(p_ptr, "An image forms in your mind...");
2116 detection(p_ptr);
2117 break;
2118 }
2119
2120 case ACT_HEAL1:
2121 {
2122 msg_format(p_ptr, "Your %s glows deep blue...", o_name);
2123 msg_print(p_ptr, "You feel a warm tingling inside...");
2124 (void)hp_player(p_ptr, 500);
2125 (void)set_cut(p_ptr, 0);
2126 break;
2127 }
2128
2129 case ACT_RESIST:
2130 {
2131 msg_format(p_ptr, "Your %s glows many colours...", o_name);
2132 (void)set_oppose_acid(p_ptr, p_ptr->oppose_acid + randint1(20) + 20);
2133 (void)set_oppose_elec(p_ptr, p_ptr->oppose_elec + randint1(20) + 20);
2134 (void)set_oppose_fire(p_ptr, p_ptr->oppose_fire + randint1(20) + 20);
2135 (void)set_oppose_cold(p_ptr, p_ptr->oppose_cold + randint1(20) + 20);
2136 (void)set_oppose_pois(p_ptr, p_ptr->oppose_pois + randint1(20) + 20);
2137 break;
2138 }
2139
2140 case ACT_SLEEP:
2141 {
2142 msg_format(p_ptr, "Your %s glows deep blue...", o_name);
2143 sleep_monsters_touch(p_ptr);
2144 break;
2145 }
2146
2147 case ACT_RECHARGE1:
2148 {
2149 msg_format(p_ptr, "Your %s glows bright yellow...", o_name);
2150 if (!recharge(p_ptr, 60)) return FALSE;
2151 break;
2152 }
2153
2154 case ACT_TELEPORT:
2155 {
2156 msg_format(p_ptr, "Your %s twists space around you...", o_name);
2157 teleport_player(p_ptr, 100);
2158 break;
2159 }
2160
2161 case ACT_RESTORE_LIFE:
2162 {
2163 msg_format(p_ptr, "Your %s glows a deep red...", o_name);
2164 restore_level(p_ptr);
2165 break;
2166 }
2167
2168 case ACT_MISSILE:
2169 {
2170 msg_format(p_ptr, "Your %s glows extremely brightly...", o_name);
2171 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2172 fire_bolt(p_ptr, GF_MISSILE, dir, damroll(2, 6));
2173 break;
2174 }
2175
2176 case ACT_FIRE1:
2177 {
2178 msg_format(p_ptr, "Your %s is covered in fire...", o_name);
2179 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2180 fire_bolt(p_ptr, GF_FIRE, dir, damroll(9, 8));
2181 break;
2182 }
2183
2184 case ACT_FROST1:
2185 {
2186 msg_format(p_ptr, "Your %s is covered in frost...", o_name);
2187 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2188 fire_bolt(p_ptr, GF_COLD, dir, damroll(6, 8));
2189 break;
2190 }
2191
2192 case ACT_LIGHTNING_BOLT:
2193 {
2194 msg_format(p_ptr, "Your %s is covered in sparks...", o_name);
2195 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2196 fire_bolt(p_ptr, GF_ELEC, dir, damroll(4, 8));
2197 break;
2198 }
2199
2200 case ACT_ACID1:
2201 {
2202 msg_format(p_ptr, "Your %s is covered in acid...", o_name);
2203 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2204 fire_bolt(p_ptr, GF_ACID, dir, damroll(5, 8));
2205 break;
2206 }
2207
2208 case ACT_ARROW:
2209 {
2210 msg_format(p_ptr, "Your %s grows magical spikes...", o_name);
2211 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2212 fire_bolt(p_ptr, GF_ARROW, dir, 150);
2213 break;
2214 }
2215
2216 case ACT_HASTE1:
2217 {
2218 msg_format(p_ptr, "Your %s glows bright green...", o_name);
2219 if (!p_ptr->fast)
2220 {
2221 (void)set_fast(p_ptr, randint1(20) + 20);
2222 }
2223 else
2224 {
2225 (void)set_fast(p_ptr, p_ptr->fast + 5);
2226 }
2227 break;
2228 }
2229
2230 case ACT_REM_FEAR_POIS:
2231 {
2232 msg_format(p_ptr, "Your %s glows deep blue...", o_name);
2233 (void)set_afraid(p_ptr, 0);
2234 (void)set_poisoned(p_ptr, 0);
2235 break;
2236 }
2237
2238 case ACT_STINKING_CLOUD:
2239 {
2240 msg_format(p_ptr, "Your %s throbs deep green...", o_name);
2241 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2242 fire_ball(p_ptr, GF_POIS, dir, 12, 3);
2243 break;
2244 }
2245
2246 case ACT_FROST2:
2247 {
2248 msg_format(p_ptr, "Your %s is covered in frost...", o_name);
2249 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2250 fire_ball(p_ptr, GF_COLD, dir, 48, 2);
2251 break;
2252 }
2253
2254 case ACT_FROST4:
2255 {
2256 msg_format(p_ptr, "Your %s glows a pale blue...", o_name);
2257 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2258 fire_bolt(p_ptr, GF_COLD, dir, damroll(12, 8));
2259 break;
2260 }
2261
2262 case ACT_FROST3:
2263 {
2264 msg_format(p_ptr, "Your %s glows a intense blue...", o_name);
2265 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2266 fire_ball(p_ptr, GF_COLD, dir, 100, 2);
2267 break;
2268 }
2269
2270 case ACT_FIRE2:
2271 {
2272 msg_format(p_ptr, "Your %s rages in fire...", o_name);
2273 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2274 fire_ball(p_ptr, GF_FIRE, dir, 72, 2);
2275 break;
2276 }
2277
2278 case ACT_DRAIN_LIFE2:
2279 {
2280 msg_format(p_ptr, "Your %s glows black...", o_name);
2281 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2282 drain_life(p_ptr, dir, 120);
2283 break;
2284 }
2285
2286 case ACT_STONE_TO_MUD:
2287 {
2288 msg_format(p_ptr, "Your %s pulsates...", o_name);
2289 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2290 wall_to_mud(p_ptr, dir);
2291 break;
2292 }
2293
2294 case ACT_MASS_BANISHMENT:
2295 {
2296 msg_format(p_ptr, "Your %s lets out a long, shrill note...", o_name);
2297 (void)mass_banishment(p_ptr);
2298 break;
2299 }
2300
2301 case ACT_CURE_WOUNDS:
2302 {
2303 msg_format(p_ptr, "Your %s radiates deep purple...", o_name);
2304 hp_player(p_ptr, damroll(4, 8));
2305 (void)set_cut(p_ptr, (p_ptr->cut / 2) - 50);
2306 break;
2307 }
2308
2309 case ACT_TELE_AWAY:
2310 {
2311 msg_format(p_ptr, "Your %s glows deep red...", o_name);
2312 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2313 teleport_monster(p_ptr, dir);
2314 break;
2315 }
2316
2317 case ACT_WOR:
2318 {
2319 msg_format(p_ptr, "Your %s glows soft white...", o_name);
2320 set_recall(p_ptr, o_ptr);
2321 break;
2322 }
2323
2324 case ACT_CONFUSE:
2325 {
2326 msg_format(p_ptr, "Your %s glows in scintillating colours...", o_name);
2327 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2328 confuse_monster(p_ptr, dir, 20);
2329 break;
2330 }
2331
2332 case ACT_IDENTIFY:
2333 {
2334 msg_format(p_ptr, "Your %s glows yellow...", o_name);
2335 if (!ident_spell(p_ptr)) return FALSE;
2336 break;
2337 }
2338
2339 case ACT_PROBE:
2340 {
2341 msg_format(p_ptr, "Your %s glows brightly...", o_name);
2342 probing(p_ptr);
2343 break;
2344 }
2345
2346 case ACT_DRAIN_LIFE1:
2347 {
2348 msg_format(p_ptr, "Your %s glows white...", o_name);
2349 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2350 drain_life(p_ptr, dir, 90);
2351 break;
2352 }
2353
2354 case ACT_FIREBRAND:
2355 {
2356 msg_format(p_ptr, "Your %s glows deep red...", o_name);
2357 if (!brand_bolts(p_ptr, TRUE)) return FALSE;
2358 break;
2359 }
2360
2361 case ACT_STARLIGHT:
2362 {
2363 msg_format(p_ptr, "Your %s glows with the light of a thousand stars...", o_name);
2364 for (k = 0; k < 8; k++) strong_lite_line(p_ptr, ddd[k]);
2365 break;
2366 }
2367
2368 case ACT_MANA_BOLT:
2369 {
2370 msg_format(p_ptr, "Your %s glows white...", o_name);
2371 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2372 fire_bolt(p_ptr, GF_MANA, dir, damroll(12, 8));
2373 break;
2374 }
2375
2376 case ACT_BERSERKER:
2377 {
2378 msg_format(p_ptr, "Your %s glows in anger...", o_name);
2379 set_shero(p_ptr, p_ptr->shero + randint1(50) + 50);
2380 break;
2381 }
2382 }
2383
2384 /* Set the recharge time */
2385 if (a_ptr->randtime)
2386 o_ptr->timeout = a_ptr->time + (byte)randint1(a_ptr->randtime);
2387 else
2388 o_ptr->timeout = a_ptr->time;
2389
2390 /* Done */
2391 return FALSE;
2392 }
2393 /* MAngband-specific: Some ego items can be activated */
2394 else if (o_ptr->name2)
2395 {
2396 switch (o_ptr->name2)
2397 {
2398 case EGO_CLOAK_LORDLY_RES:
2399 {
2400 msg_print(p_ptr, "Your cloak flashes many colors...");
2401
2402 (void)set_oppose_acid(p_ptr, p_ptr->oppose_acid + randint1(40) + 40);
2403 (void)set_oppose_elec(p_ptr, p_ptr->oppose_elec + randint1(40) + 40);
2404 (void)set_oppose_fire(p_ptr, p_ptr->oppose_fire + randint1(40) + 40);
2405 (void)set_oppose_cold(p_ptr, p_ptr->oppose_cold + randint1(40) + 40);
2406 (void)set_oppose_pois(p_ptr, p_ptr->oppose_pois + randint1(40) + 40);
2407
2408 o_ptr->timeout = randint0(50) + 150;
2409 break;
2410 }
2411 }
2412
2413 /* Update equipment window */
2414 p_ptr->window |= PW_EQUIP;
2415
2416 /* Success */
2417 return FALSE;
2418 }
2419
2420 /* Hack -- Dragon Scale Mail can be activated as well */
2421 if (o_ptr->tval == TV_DRAG_ARMOR)
2422 {
2423 /* Get a direction for breathing (or abort) */
2424 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2425
2426 /* Branch on the sub-type */
2427 switch (o_ptr->sval)
2428 {
2429 case SV_DRAGON_BLUE:
2430 {
2431 sound(p_ptr, MSG_BR_ELEC);
2432 msg_print(p_ptr, "You breathe lightning.");
2433 fire_ball(p_ptr, GF_ELEC, dir, 100, 2);
2434 o_ptr->timeout = randint0(450) + 450;
2435 break;
2436 }
2437
2438 case SV_DRAGON_WHITE:
2439 {
2440 sound(p_ptr, MSG_BR_FROST);
2441 msg_print(p_ptr, "You breathe frost.");
2442 fire_ball(p_ptr, GF_COLD, dir, 110, 2);
2443 o_ptr->timeout = randint0(450) + 450;
2444 break;
2445 }
2446
2447 case SV_DRAGON_BLACK:
2448 {
2449 sound(p_ptr, MSG_BR_ACID);
2450 msg_print(p_ptr, "You breathe acid.");
2451 fire_ball(p_ptr, GF_ACID, dir, 130, 2);
2452 o_ptr->timeout = randint0(450) + 450;
2453 break;
2454 }
2455
2456 case SV_DRAGON_GREEN:
2457 {
2458 sound(p_ptr, MSG_BR_GAS);
2459 msg_print(p_ptr, "You breathe poison gas.");
2460 fire_ball(p_ptr, GF_POIS, dir, 150, 2);
2461 o_ptr->timeout = randint0(450) + 450;
2462 break;
2463 }
2464
2465 case SV_DRAGON_RED:
2466 {
2467 sound(p_ptr, MSG_BR_FIRE);
2468 msg_print(p_ptr, "You breathe fire.");
2469 fire_ball(p_ptr, GF_FIRE, dir, 200, 2);
2470 o_ptr->timeout = randint0(450) + 450;
2471 break;
2472 }
2473
2474 case SV_DRAGON_MULTIHUED:
2475 {
2476 chance = randint0(5);
2477 sound(p_ptr, ((chance == 1) ? MSG_BR_ELEC :
2478 ((chance == 2) ? MSG_BR_FROST :
2479 ((chance == 3) ? MSG_BR_ACID :
2480 ((chance == 4) ? MSG_BR_GAS : MSG_BR_FIRE)))));
2481 msg_format(p_ptr, "You breathe %s.",
2482 ((chance == 1) ? "lightning" :
2483 ((chance == 2) ? "frost" :
2484 ((chance == 3) ? "acid" :
2485 ((chance == 4) ? "poison gas" : "fire")))));
2486 fire_ball(p_ptr, ((chance == 1) ? GF_ELEC :
2487 ((chance == 2) ? GF_COLD :
2488 ((chance == 3) ? GF_ACID :
2489 ((chance == 4) ? GF_POIS : GF_FIRE)))),
2490 dir, 250, 2);
2491 o_ptr->timeout = randint0(225) + 225;
2492 break;
2493 }
2494
2495 case SV_DRAGON_BRONZE:
2496 {
2497 sound(p_ptr, MSG_BR_CONF);
2498 msg_print(p_ptr, "You breathe confusion.");
2499 fire_ball(p_ptr, GF_CONFUSION, dir, 120, 2);
2500 o_ptr->timeout = randint0(450) + 450;
2501 break;
2502 }
2503
2504 case SV_DRAGON_GOLD:
2505 {
2506 sound(p_ptr, MSG_BR_SOUND);
2507 msg_print(p_ptr, "You breathe sound.");
2508 fire_ball(p_ptr, GF_SOUND, dir, 130, 2);
2509 o_ptr->timeout = randint0(450) + 450;
2510 break;
2511 }
2512
2513 case SV_DRAGON_CHAOS:
2514 {
2515 chance = randint0(2);
2516 sound(p_ptr, ((chance == 1 ? MSG_BR_CHAOS : MSG_BR_DISENCHANT)));
2517 msg_format(p_ptr, "You breathe %s.",
2518 ((chance == 1 ? "chaos" : "disenchantment")));
2519 fire_ball(p_ptr, (chance == 1 ? GF_CHAOS : GF_DISENCHANT),
2520 dir, 220, 2);
2521 o_ptr->timeout = randint0(300) + 300;
2522 break;
2523 }
2524
2525 case SV_DRAGON_LAW:
2526 {
2527 chance = randint0(2);
2528 sound(p_ptr, ((chance == 1 ? MSG_BR_SOUND : MSG_BR_SHARDS)));
2529 msg_format(p_ptr, "You breathe %s.",
2530 ((chance == 1 ? "sound" : "shards")));
2531 fire_ball(p_ptr, (chance == 1 ? GF_SOUND : GF_SHARDS),
2532 dir, 230, 2);
2533 o_ptr->timeout = randint0(300) + 300;
2534 break;
2535 }
2536
2537 case SV_DRAGON_BALANCE:
2538 {
2539 chance = randint0(4);
2540 msg_format(p_ptr, "You breathe %s.",
2541 ((chance == 1) ? "chaos" :
2542 ((chance == 2) ? "disenchantment" :
2543 ((chance == 3) ? "sound" : "shards"))));
2544 fire_ball(p_ptr, ((chance == 1) ? GF_CHAOS :
2545 ((chance == 2) ? GF_DISENCHANT :
2546 ((chance == 3) ? GF_SOUND : GF_SHARDS))),
2547 dir, 250, 2);
2548 o_ptr->timeout = randint0(300) + 300;
2549 break;
2550 }
2551
2552 case SV_DRAGON_SHINING:
2553 {
2554 chance = randint0(2);
2555 sound(p_ptr, ((chance == 0 ? MSG_BR_LIGHT : MSG_BR_DARK)));
2556 msg_format(p_ptr, "You breathe %s.",
2557 ((chance == 0 ? "light" : "darkness")));
2558 fire_ball(p_ptr, (chance == 0 ? GF_LITE : GF_DARK), dir, 200, 2);
2559 o_ptr->timeout = randint0(300) + 300;
2560 break;
2561 }
2562
2563 case SV_DRAGON_POWER:
2564 {
2565 sound(p_ptr, MSG_BR_ELEMENTS);
2566 msg_print(p_ptr, "You breathe the elements.");
2567 fire_ball(p_ptr, GF_MISSILE, dir, 300, 2);
2568 o_ptr->timeout = randint0(300) + 300;
2569 break;
2570 }
2571 }
2572
2573 /* Success */
2574 return FALSE;
2575 }
2576
2577 /* MAngband-specific: Amulets of the moon can be activated for sleep monster */
2578 if ((o_ptr->tval == TV_AMULET) && (o_ptr->sval == SV_AMULET_THE_MOON))
2579 {
2580 msg_print(p_ptr, "Your amulet glows a deep blue...");
2581 sleep_monsters(p_ptr);
2582 o_ptr->timeout = randint0(100) + 100;
2583
2584 /* Update equipment window */
2585 p_ptr->window |= PW_EQUIP;
2586
2587 /* Success */
2588 return FALSE;
2589 }
2590
2591 /* Hack -- some Rings can be activated for double resist and element ball */
2592 if (o_ptr->tval == TV_RING)
2593 {
2594 /* Get a direction for firing (or abort) */
2595 if (!get_aim_dir(p_ptr, &dir)) return FALSE;
2596
2597 /* Branch on the sub-type */
2598 switch (o_ptr->sval)
2599 {
2600 case SV_RING_ACID:
2601 {
2602 fire_ball(p_ptr, GF_ACID, dir, 70, 2);
2603 set_oppose_acid(p_ptr, p_ptr->oppose_acid + randint1(20) + 20);
2604 o_ptr->timeout = randint0(50) + 50;
2605 break;
2606 }
2607
2608 case SV_RING_FLAMES:
2609 {
2610 fire_ball(p_ptr, GF_FIRE, dir, 80, 2);
2611 set_oppose_fire(p_ptr, p_ptr->oppose_fire + randint1(20) + 20);
2612 o_ptr->timeout = randint0(50) + 50;
2613 break;
2614 }
2615
2616 case SV_RING_ICE:
2617 {
2618 fire_ball(p_ptr, GF_COLD, dir, 75, 2);
2619 set_oppose_cold(p_ptr, p_ptr->oppose_cold + randint1(20) + 20);
2620 o_ptr->timeout = randint0(50) + 50;
2621 break;
2622 }
2623
2624 case SV_RING_LIGHTNING:
2625 {
2626 fire_ball(p_ptr, GF_ELEC, dir, 85, 2);
2627 set_oppose_elec(p_ptr, p_ptr->oppose_elec + randint1(20) + 20);
2628 o_ptr->timeout = randint0(50) + 50;
2629 break;
2630 }
2631 }
2632
2633 /* Window stuff */
2634 p_ptr->window |= (PW_EQUIP);
2635
2636 /* Success */
2637 return FALSE;
2638 }
2639
2640 /* Mistake */
2641 msg_print(p_ptr, "Oops. That object cannot be activated.");
2642
2643 /* Not used up */
2644 return (FALSE);
2645 }
2646
use_object_current(player_type * p_ptr)2647 bool use_object_current(player_type *p_ptr)
2648 {
2649 object_type *o_ptr;
2650 int item = p_ptr->current_object;
2651 bool ident;
2652
2653 /* Get the item (in the pack) */
2654 if (item >= 0)
2655 {
2656 o_ptr = &p_ptr->inventory[item];
2657 }
2658
2659 /* Get the item (on the floor) */
2660 else
2661 {
2662 item = -cave[p_ptr->dun_depth][p_ptr->py][p_ptr->px].o_idx;
2663 if (item == 0) return FALSE;
2664 o_ptr = &o_list[0 - item];
2665 }
2666
2667 return use_object(p_ptr, o_ptr, item, &ident);
2668 }
2669
use_object(player_type * p_ptr,object_type * o_ptr,int item,bool * ident)2670 bool use_object(player_type *p_ptr, object_type *o_ptr, int item, bool *ident)
2671 {
2672 bool used;
2673
2674 /* Save object */
2675 p_ptr->current_object = item;
2676
2677 /* Analyze the object */
2678 switch (o_ptr->tval)
2679 {
2680 case TV_FOOD:
2681 {
2682 used = eat_food(p_ptr, o_ptr, ident);
2683 break;
2684 }
2685
2686 case TV_POTION:
2687 {
2688 used = quaff_potion(p_ptr, o_ptr, ident);
2689 break;
2690 }
2691
2692 case TV_SCROLL:
2693 {
2694 used = read_scroll(p_ptr, o_ptr, ident);
2695 if (used) do_cmd_read_scroll_end(p_ptr, item, *ident);
2696 break;
2697 }
2698
2699 case TV_STAFF:
2700 {
2701 used = use_staff(p_ptr, o_ptr, ident);
2702 if (used) do_cmd_use_staff_discharge(p_ptr, item, *ident);
2703 break;
2704 }
2705
2706 case TV_WAND:
2707 {
2708 used = aim_wand(p_ptr, o_ptr, ident);
2709 break;
2710 }
2711
2712 case TV_ROD:
2713 {
2714 used = zap_rod(p_ptr, o_ptr, ident);
2715 if (used) do_cmd_zap_rod_discharge(p_ptr, item, *ident);
2716 break;
2717 }
2718
2719 default:
2720 {
2721 used = activate_object(p_ptr, o_ptr, ident);
2722 break;
2723 }
2724 }
2725
2726 /* Dismiss object */
2727 if (used)
2728 p_ptr->current_object = -2;
2729
2730 /* Hack -- redraw used item */
2731 if (used) player_redraw_item(p_ptr, item);
2732
2733 return (used);
2734 }
2735
2736 #if 0
2737 static cptr act_description[ACT_MAX] =
2738 {
2739 "illumination",
2740 "magic mapping",
2741 "clairvoyance",
2742 "protection from evil",
2743 "dispel evil (x5)",
2744 "heal (500)",
2745 "heal (1000)",
2746 "cure wounds (4d8)",
2747 "haste self (20+d20 turns)",
2748 "haste self (75+d75 turns)",
2749 "fire bolt (9d8)",
2750 "fire ball (72)",
2751 "large fire ball (120)",
2752 "frost bolt (6d8)",
2753 "frost ball (48)",
2754 "frost ball (100)",
2755 "frost bolt (12d8)",
2756 "large frost ball (200)",
2757 "acid bolt (5d8)",
2758 "recharge item I",
2759 "sleep II",
2760 "lightning bolt (4d8)",
2761 "large lightning ball (250)",
2762 "banishment",
2763 "mass banishment",
2764 "identify",
2765 "drain life (90)",
2766 "drain life (120)",
2767 "bizarre things",
2768 "star ball (150)",
2769 "berserk rage, bless, and resistance",
2770 "phase door",
2771 "door and trap destruction",
2772 "detection",
2773 "resistance (20+d20 turns)",
2774 "teleport",
2775 "restore life levels",
2776 "magic missile (2d6)",
2777 "a magical arrow (150)",
2778 "remove fear and cure poison",
2779 "stinking cloud (12)",
2780 "stone to mud",
2781 "teleport away",
2782 "word of recall",
2783 "confuse monster",
2784 "probing",
2785 "fire branding of bolts",
2786 "starlight (10d8)",
2787 "mana bolt (12d8)",
2788 "berserk rage (50+d50 turns)"
2789 };
2790
2791
2792
2793 /*
2794 * Determine the "Activation" (if any) for an artifact
2795 */
2796 void describe_item_activation(const object_type *o_ptr)
2797 {
2798 u32b f1, f2, f3;
2799
2800 /* Extract the flags */
2801 object_flags(o_ptr, &f1, &f2, &f3);
2802
2803 /* Require activation ability */
2804 if (!(f3 & TR3_ACTIVATE)) return;
2805
2806 /* Artifact activations */
2807 if (artifact_p(o_ptr))
2808 {
2809 artifact_type *a_ptr = artifact_ptr(o_ptr);
2810
2811 /* Paranoia */
2812 if (a_ptr->activation >= ACT_MAX) return;
2813
2814 /* Some artifacts can be activated */
2815 text_out(act_description[a_ptr->activation]);
2816
2817 /* Output the number of turns */
2818 if (a_ptr->time && a_ptr->randtime)
2819 text_out(format(" every %d+d%d turns", a_ptr->time, a_ptr->randtime));
2820 else if (a_ptr->time)
2821 text_out(format(" every %d turns", a_ptr->time));
2822 else if (a_ptr->randtime)
2823 text_out(format(" every d%d turns", a_ptr->randtime));
2824
2825 return;
2826 }
2827
2828 /* Ring activations */
2829 if (o_ptr->tval == TV_RING)
2830 {
2831 /* Branch on the sub-type */
2832 switch (o_ptr->sval)
2833 {
2834 case SV_RING_ACID:
2835 {
2836 text_out("acid resistance (20+d20 turns) and acid ball (70) every 50+d50 turns");
2837 break;
2838 }
2839 case SV_RING_FLAMES:
2840 {
2841 text_out("fire resistance (20+d20 turns) and fire ball (80) every 50+d50 turns");
2842 break;
2843 }
2844 case SV_RING_ICE:
2845 {
2846 text_out("cold resistance (20+d20 turns) and cold ball (75) every 50+d50 turns");
2847 break;
2848 }
2849
2850 case SV_RING_LIGHTNING:
2851 {
2852 text_out("electricity resistance (20+d20 turns) and electricity ball (85) every 50+d50 turns");
2853 break;
2854 }
2855 }
2856
2857 return;
2858 }
2859
2860 /* Require dragon scale mail */
2861 if (o_ptr->tval != TV_DRAG_ARMOR) return;
2862
2863 /* Branch on the sub-type */
2864 switch (o_ptr->sval)
2865 {
2866 case SV_DRAGON_BLUE:
2867 {
2868 text_out("breathe lightning (100) every 450+d450 turns");
2869 break;
2870 }
2871 case SV_DRAGON_WHITE:
2872 {
2873 text_out("breathe frost (110) every 450+d450 turns");
2874 break;
2875 }
2876 case SV_DRAGON_BLACK:
2877 {
2878 text_out("breathe acid (130) every 450+d450 turns");
2879 break;
2880 }
2881 case SV_DRAGON_GREEN:
2882 {
2883 text_out("breathe poison gas (150) every 450+d450 turns");
2884 break;
2885 }
2886 case SV_DRAGON_RED:
2887 {
2888 text_out("breathe fire (200) every 450+d450 turns");
2889 break;
2890 }
2891 case SV_DRAGON_MULTIHUED:
2892 {
2893 text_out("breathe multi-hued (250) every 225+d225 turns");
2894 break;
2895 }
2896 case SV_DRAGON_BRONZE:
2897 {
2898 text_out("breathe confusion (120) every 450+d450 turns");
2899 break;
2900 }
2901 case SV_DRAGON_GOLD:
2902 {
2903 text_out("breathe sound (130) every 450+d450 turns");
2904 break;
2905 }
2906 case SV_DRAGON_CHAOS:
2907 {
2908 text_out("breathe chaos/disenchant (220) every 300+d300 turns");
2909 break;
2910 }
2911 case SV_DRAGON_LAW:
2912 {
2913 text_out("breathe sound/shards (230) every 300+d300 turns");
2914 break;
2915 }
2916 case SV_DRAGON_BALANCE:
2917 {
2918 text_out("breathe balance (250) every 300+d300 turns");
2919 break;
2920 }
2921 case SV_DRAGON_SHINING:
2922 {
2923 text_out("breathe light/darkness (200) every 300+d300 turns");
2924 break;
2925 }
2926 case SV_DRAGON_POWER:
2927 {
2928 text_out("breathe the elements (300) every 300+d300 turns");
2929 break;
2930 }
2931 }
2932 }
2933 #endif
2934