Angband 3.0.9b.
[angband.git] / src / use-obj.c
blob36829f255052f00e8929a9231c8497b05883a7e3
1 /* File: use_obj.c */
3 /*
4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
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 */
11 #include "angband.h"
12 #include "script.h"
15 static bool eat_food(object_type *o_ptr, bool *ident)
17 /* Analyze the food */
18 switch (o_ptr->sval)
20 case SV_FOOD_POISON:
22 if (!(p_ptr->resist_pois || p_ptr->timed[TMD_OPP_POIS]))
24 if (inc_timed(TMD_POISONED, rand_int(10) + 10))
26 *ident = TRUE;
29 break;
32 case SV_FOOD_BLINDNESS:
34 if (!p_ptr->resist_blind)
36 if (inc_timed(TMD_BLIND, rand_int(200) + 200))
38 *ident = TRUE;
41 break;
44 case SV_FOOD_PARANOIA:
46 if (!p_ptr->resist_fear)
48 if (inc_timed(TMD_AFRAID, rand_int(10) + 10))
50 *ident = TRUE;
53 break;
56 case SV_FOOD_CONFUSION:
58 if (!p_ptr->resist_confu)
60 if (inc_timed(TMD_CONFUSED, rand_int(10) + 10))
62 *ident = TRUE;
65 break;
68 case SV_FOOD_HALLUCINATION:
70 if (!p_ptr->resist_chaos)
72 if (inc_timed(TMD_IMAGE, rand_int(250) + 250))
74 *ident = TRUE;
77 break;
80 case SV_FOOD_PARALYSIS:
82 if (!p_ptr->free_act)
84 if (inc_timed(TMD_PARALYZED, rand_int(10) + 10))
86 *ident = TRUE;
89 break;
92 case SV_FOOD_WEAKNESS:
94 take_hit(damroll(6, 6), "poisonous food");
95 (void)do_dec_stat(A_STR);
96 *ident = TRUE;
97 break;
100 case SV_FOOD_SICKNESS:
102 take_hit(damroll(6, 6), "poisonous food");
103 (void)do_dec_stat(A_CON);
104 *ident = TRUE;
105 break;
108 case SV_FOOD_STUPIDITY:
110 take_hit(damroll(8, 8), "poisonous food");
111 (void)do_dec_stat(A_INT);
112 *ident = TRUE;
113 break;
116 case SV_FOOD_NAIVETY:
118 take_hit(damroll(8, 8), "poisonous food");
119 (void)do_dec_stat(A_WIS);
120 *ident = TRUE;
121 break;
124 case SV_FOOD_UNHEALTH:
126 take_hit(damroll(10, 10), "poisonous food");
127 (void)do_dec_stat(A_CON);
128 *ident = TRUE;
129 break;
132 case SV_FOOD_DISEASE:
134 take_hit(damroll(10, 10), "poisonous food");
135 (void)do_dec_stat(A_STR);
136 *ident = TRUE;
137 break;
140 case SV_FOOD_CURE_POISON:
142 if (clear_timed(TMD_POISONED)) *ident = TRUE;
143 break;
146 case SV_FOOD_CURE_BLINDNESS:
148 if (clear_timed(TMD_BLIND)) *ident = TRUE;
149 break;
152 case SV_FOOD_CURE_PARANOIA:
154 if (clear_timed(TMD_AFRAID)) *ident = TRUE;
155 break;
158 case SV_FOOD_CURE_CONFUSION:
160 if (clear_timed(TMD_CONFUSED)) *ident = TRUE;
161 break;
164 case SV_FOOD_CURE_SERIOUS:
166 if (hp_player(damroll(4, 8))) *ident = TRUE;
167 break;
170 case SV_FOOD_RESTORE_STR:
172 if (do_res_stat(A_STR)) *ident = TRUE;
173 break;
176 case SV_FOOD_RESTORE_CON:
178 if (do_res_stat(A_CON)) *ident = TRUE;
179 break;
182 case SV_FOOD_RESTORING:
184 if (do_res_stat(A_STR)) *ident = TRUE;
185 if (do_res_stat(A_INT)) *ident = TRUE;
186 if (do_res_stat(A_WIS)) *ident = TRUE;
187 if (do_res_stat(A_DEX)) *ident = TRUE;
188 if (do_res_stat(A_CON)) *ident = TRUE;
189 if (do_res_stat(A_CHR)) *ident = TRUE;
190 break;
194 case SV_FOOD_RATION:
195 case SV_FOOD_BISCUIT:
196 case SV_FOOD_JERKY:
197 case SV_FOOD_SLIME_MOLD:
199 msg_print("That tastes good.");
200 *ident = TRUE;
201 break;
204 case SV_FOOD_WAYBREAD:
206 msg_print("That tastes good.");
207 (void)clear_timed(TMD_POISONED);
208 (void)hp_player(damroll(4, 8));
209 *ident = TRUE;
210 break;
213 case SV_FOOD_PINT_OF_ALE:
214 case SV_FOOD_PINT_OF_WINE:
216 msg_print("That tastes good.");
217 *ident = TRUE;
218 break;
222 /* Food can feed the player */
223 (void)set_food(p_ptr->food + o_ptr->pval);
225 return (TRUE);
229 static bool quaff_potion(object_type *o_ptr, bool *ident)
231 /* Analyze the potion */
232 switch (o_ptr->sval)
234 case SV_POTION_WATER:
235 case SV_POTION_APPLE_JUICE:
236 case SV_POTION_SLIME_MOLD:
238 msg_print("You feel less thirsty.");
239 *ident = TRUE;
240 break;
243 case SV_POTION_SLOWNESS:
245 if (inc_timed(TMD_SLOW, randint(25) + 15)) *ident = TRUE;
246 break;
249 case SV_POTION_SALT_WATER:
251 msg_print("The potion makes you vomit!");
252 (void)set_food(PY_FOOD_STARVE - 1);
253 (void)clear_timed(TMD_POISONED);
254 (void)inc_timed(TMD_PARALYZED, 4);
255 *ident = TRUE;
256 break;
259 case SV_POTION_POISON:
261 if (!(p_ptr->resist_pois || p_ptr->timed[TMD_OPP_POIS]))
263 if (inc_timed(TMD_POISONED, rand_int(15) + 10))
265 *ident = TRUE;
268 break;
271 case SV_POTION_BLINDNESS:
273 if (!p_ptr->resist_blind)
275 if (inc_timed(TMD_BLIND, rand_int(100) + 100))
277 *ident = TRUE;
280 break;
283 case SV_POTION_CONFUSION:
285 if (!p_ptr->resist_confu)
287 if (inc_timed(TMD_CONFUSED, rand_int(20) + 15))
289 *ident = TRUE;
292 break;
295 case SV_POTION_SLEEP:
297 if (!p_ptr->free_act)
299 if (inc_timed(TMD_PARALYZED, rand_int(4) + 4))
301 *ident = TRUE;
304 break;
307 case SV_POTION_LOSE_MEMORIES:
309 if (!p_ptr->hold_life && (p_ptr->exp > 0))
311 msg_print("You feel your memories fade.");
312 lose_exp(p_ptr->exp / 4);
313 *ident = TRUE;
315 break;
318 case SV_POTION_RUINATION:
320 msg_print("Your nerves and muscles feel weak and lifeless!");
321 take_hit(damroll(10, 10), "a potion of Ruination");
322 (void)dec_stat(A_DEX, 25, TRUE);
323 (void)dec_stat(A_WIS, 25, TRUE);
324 (void)dec_stat(A_CON, 25, TRUE);
325 (void)dec_stat(A_STR, 25, TRUE);
326 (void)dec_stat(A_CHR, 25, TRUE);
327 (void)dec_stat(A_INT, 25, TRUE);
328 *ident = TRUE;
329 break;
332 case SV_POTION_DEC_STR:
334 if (do_dec_stat(A_STR)) *ident = TRUE;
335 break;
338 case SV_POTION_DEC_INT:
340 if (do_dec_stat(A_INT)) *ident = TRUE;
341 break;
344 case SV_POTION_DEC_WIS:
346 if (do_dec_stat(A_WIS)) *ident = TRUE;
347 break;
350 case SV_POTION_DEC_DEX:
352 if (do_dec_stat(A_DEX)) *ident = TRUE;
353 break;
356 case SV_POTION_DEC_CON:
358 if (do_dec_stat(A_CON)) *ident = TRUE;
359 break;
362 case SV_POTION_DEC_CHR:
364 if (do_dec_stat(A_CHR)) *ident = TRUE;
365 break;
368 case SV_POTION_DETONATIONS:
370 msg_print("Massive explosions rupture your body!");
371 take_hit(damroll(50, 20), "a potion of Detonation");
372 (void)inc_timed(TMD_STUN, 75);
373 (void)inc_timed(TMD_CUT, 5000);
374 *ident = TRUE;
375 break;
378 case SV_POTION_DEATH:
380 msg_print("A feeling of Death flows through your body.");
381 take_hit(5000, "a potion of Death");
382 *ident = TRUE;
383 break;
386 case SV_POTION_INFRAVISION:
388 if (inc_timed(TMD_SINFRA, 100 + randint(100)))
390 *ident = TRUE;
392 break;
395 case SV_POTION_DETECT_INVIS:
397 if (inc_timed(TMD_SINVIS, 12 + randint(12)))
399 *ident = TRUE;
401 break;
404 case SV_POTION_SLOW_POISON:
406 if (set_timed(TMD_POISONED, p_ptr->timed[TMD_POISONED] / 2)) *ident = TRUE;
407 break;
410 case SV_POTION_CURE_POISON:
412 if (clear_timed(TMD_POISONED)) *ident = TRUE;
413 break;
416 case SV_POTION_BOLDNESS:
418 if (clear_timed(TMD_AFRAID)) *ident = TRUE;
419 break;
422 case SV_POTION_SPEED:
424 if (!p_ptr->timed[TMD_FAST])
426 if (set_timed(TMD_FAST, randint(25) + 15)) *ident = TRUE;
428 else
430 (void)inc_timed(TMD_FAST, 5);
432 break;
435 case SV_POTION_RESIST_HEAT:
437 if (inc_timed(TMD_OPP_FIRE, randint(10) + 10))
439 *ident = TRUE;
441 break;
444 case SV_POTION_RESIST_COLD:
446 if (inc_timed(TMD_OPP_COLD, randint(10) + 10))
448 *ident = TRUE;
450 break;
453 case SV_POTION_HEROISM:
455 if (hp_player(10)) *ident = TRUE;
456 if (clear_timed(TMD_AFRAID)) *ident = TRUE;
457 if (inc_timed(TMD_HERO, randint(25) + 25)) *ident = TRUE;
458 break;
461 case SV_POTION_BERSERK_STRENGTH:
463 if (hp_player(30)) *ident = TRUE;
464 if (clear_timed(TMD_AFRAID)) *ident = TRUE;
465 if (inc_timed(TMD_SHERO, randint(25) + 25)) *ident = TRUE;
466 break;
469 case SV_POTION_CURE_LIGHT:
471 if (hp_player(damroll(2, 8))) *ident = TRUE;
472 if (clear_timed(TMD_BLIND)) *ident = TRUE;
473 if (dec_timed(TMD_CUT, 10)) *ident = TRUE;
474 break;
477 case SV_POTION_CURE_SERIOUS:
479 if (hp_player(damroll(4, 8))) *ident = TRUE;
480 if (clear_timed(TMD_BLIND)) *ident = TRUE;
481 if (clear_timed(TMD_CONFUSED)) *ident = TRUE;
482 if (set_timed(TMD_CUT, (p_ptr->timed[TMD_CUT] / 2) - 50)) *ident = TRUE;
483 break;
486 case SV_POTION_CURE_CRITICAL:
488 if (hp_player(damroll(6, 8))) *ident = TRUE;
489 if (clear_timed(TMD_BLIND)) *ident = TRUE;
490 if (clear_timed(TMD_CONFUSED)) *ident = TRUE;
491 if (clear_timed(TMD_POISONED)) *ident = TRUE;
492 if (clear_timed(TMD_STUN)) *ident = TRUE;
493 if (clear_timed(TMD_CUT)) *ident = TRUE;
494 if (clear_timed(TMD_AMNESIA)) *ident = TRUE;
495 break;
498 case SV_POTION_HEALING:
500 if (hp_player(300)) *ident = TRUE;
501 if (clear_timed(TMD_BLIND)) *ident = TRUE;
502 if (clear_timed(TMD_CONFUSED)) *ident = TRUE;
503 if (clear_timed(TMD_POISONED)) *ident = TRUE;
504 if (clear_timed(TMD_STUN)) *ident = TRUE;
505 if (clear_timed(TMD_CUT)) *ident = TRUE;
506 if (clear_timed(TMD_AMNESIA)) *ident = TRUE;
507 break;
510 case SV_POTION_STAR_HEALING:
512 if (hp_player(1200)) *ident = TRUE;
513 if (clear_timed(TMD_BLIND)) *ident = TRUE;
514 if (clear_timed(TMD_CONFUSED)) *ident = TRUE;
515 if (clear_timed(TMD_POISONED)) *ident = TRUE;
516 if (clear_timed(TMD_STUN)) *ident = TRUE;
517 if (clear_timed(TMD_CUT)) *ident = TRUE;
518 if (clear_timed(TMD_AMNESIA)) *ident = TRUE;
519 break;
522 case SV_POTION_LIFE:
524 msg_print("You feel life flow through your body!");
525 restore_level();
526 (void)clear_timed(TMD_POISONED);
527 (void)clear_timed(TMD_BLIND);
528 (void)clear_timed(TMD_CONFUSED);
529 (void)clear_timed(TMD_IMAGE);
530 (void)clear_timed(TMD_STUN);
531 (void)clear_timed(TMD_CUT);
532 (void)clear_timed(TMD_AMNESIA);
533 (void)do_res_stat(A_STR);
534 (void)do_res_stat(A_CON);
535 (void)do_res_stat(A_DEX);
536 (void)do_res_stat(A_WIS);
537 (void)do_res_stat(A_INT);
538 (void)do_res_stat(A_CHR);
540 /* Recalculate max. hitpoints */
541 update_stuff();
543 hp_player(5000);
545 *ident = TRUE;
546 break;
549 case SV_POTION_RESTORE_MANA:
551 if (p_ptr->csp < p_ptr->msp)
553 p_ptr->csp = p_ptr->msp;
554 p_ptr->csp_frac = 0;
555 msg_print("Your feel your head clear.");
556 p_ptr->redraw |= (PR_MANA);
557 p_ptr->window |= (PW_PLAYER_0 | PW_PLAYER_1);
558 *ident = TRUE;
560 break;
563 case SV_POTION_RESTORE_EXP:
565 if (restore_level()) *ident = TRUE;
566 break;
569 case SV_POTION_RES_STR:
571 if (do_res_stat(A_STR)) *ident = TRUE;
572 break;
575 case SV_POTION_RES_INT:
577 if (do_res_stat(A_INT)) *ident = TRUE;
578 break;
581 case SV_POTION_RES_WIS:
583 if (do_res_stat(A_WIS)) *ident = TRUE;
584 break;
587 case SV_POTION_RES_DEX:
589 if (do_res_stat(A_DEX)) *ident = TRUE;
590 break;
593 case SV_POTION_RES_CON:
595 if (do_res_stat(A_CON)) *ident = TRUE;
596 break;
599 case SV_POTION_RES_CHR:
601 if (do_res_stat(A_CHR)) *ident = TRUE;
602 break;
605 case SV_POTION_INC_STR:
607 if (do_inc_stat(A_STR)) *ident = TRUE;
608 break;
611 case SV_POTION_INC_INT:
613 if (do_inc_stat(A_INT)) *ident = TRUE;
614 break;
617 case SV_POTION_INC_WIS:
619 if (do_inc_stat(A_WIS)) *ident = TRUE;
620 break;
623 case SV_POTION_INC_DEX:
625 if (do_inc_stat(A_DEX)) *ident = TRUE;
626 break;
629 case SV_POTION_INC_CON:
631 if (do_inc_stat(A_CON)) *ident = TRUE;
632 break;
635 case SV_POTION_INC_CHR:
637 if (do_inc_stat(A_CHR)) *ident = TRUE;
638 break;
641 case SV_POTION_AUGMENTATION:
643 if (do_inc_stat(A_STR)) *ident = TRUE;
644 if (do_inc_stat(A_INT)) *ident = TRUE;
645 if (do_inc_stat(A_WIS)) *ident = TRUE;
646 if (do_inc_stat(A_DEX)) *ident = TRUE;
647 if (do_inc_stat(A_CON)) *ident = TRUE;
648 if (do_inc_stat(A_CHR)) *ident = TRUE;
649 break;
652 case SV_POTION_ENLIGHTENMENT:
654 msg_print("An image of your surroundings forms in your mind...");
655 wiz_lite();
656 *ident = TRUE;
657 break;
660 case SV_POTION_STAR_ENLIGHTENMENT:
662 msg_print("You begin to feel more enlightened...");
663 message_flush();
664 wiz_lite();
665 (void)do_inc_stat(A_INT);
666 (void)do_inc_stat(A_WIS);
667 (void)detect_traps();
668 (void)detect_doors();
669 (void)detect_stairs();
670 (void)detect_treasure();
671 (void)detect_objects_gold();
672 (void)detect_objects_normal();
673 identify_pack();
674 self_knowledge(TRUE);
675 *ident = TRUE;
676 break;
679 case SV_POTION_SELF_KNOWLEDGE:
681 msg_print("You begin to know yourself a little better...");
682 message_flush();
683 self_knowledge(TRUE);
684 *ident = TRUE;
685 break;
688 case SV_POTION_EXPERIENCE:
690 if (p_ptr->exp < PY_MAX_EXP)
692 s32b ee = (p_ptr->exp / 2) + 10;
693 if (ee > 100000L) ee = 100000L;
694 msg_print("You feel more experienced.");
695 gain_exp(ee);
696 *ident = TRUE;
698 break;
702 return (TRUE);
706 static bool read_scroll(object_type *o_ptr, bool *ident)
708 int py = p_ptr->py;
709 int px = p_ptr->px;
711 int k;
713 bool used_up = TRUE;
716 /* Analyze the scroll */
717 switch (o_ptr->sval)
719 case SV_SCROLL_DARKNESS:
721 if (!p_ptr->resist_blind)
723 (void)inc_timed(TMD_BLIND, 3 + randint(5));
725 if (unlite_area(10, 3)) *ident = TRUE;
726 break;
729 case SV_SCROLL_AGGRAVATE_MONSTER:
731 msg_print("There is a high pitched humming noise.");
732 aggravate_monsters(0);
733 *ident = TRUE;
734 break;
737 case SV_SCROLL_CURSE_ARMOR:
739 if (curse_armor()) *ident = TRUE;
740 break;
743 case SV_SCROLL_CURSE_WEAPON:
745 if (curse_weapon()) *ident = TRUE;
746 break;
749 case SV_SCROLL_SUMMON_MONSTER:
751 sound(MSG_SUM_MONSTER);
752 for (k = 0; k < randint(3); k++)
754 if (summon_specific(py, px, p_ptr->depth, 0))
756 *ident = TRUE;
759 break;
762 case SV_SCROLL_SUMMON_UNDEAD:
764 sound(MSG_SUM_UNDEAD);
765 for (k = 0; k < randint(3); k++)
767 if (summon_specific(py, px, p_ptr->depth, SUMMON_UNDEAD))
769 *ident = TRUE;
772 break;
775 case SV_SCROLL_TRAP_CREATION:
777 if (trap_creation()) *ident = TRUE;
778 break;
781 case SV_SCROLL_PHASE_DOOR:
783 teleport_player(10);
784 *ident = TRUE;
785 break;
788 case SV_SCROLL_TELEPORT:
790 teleport_player(100);
791 *ident = TRUE;
792 break;
795 case SV_SCROLL_TELEPORT_LEVEL:
797 (void)teleport_player_level();
798 *ident = TRUE;
799 break;
802 case SV_SCROLL_WORD_OF_RECALL:
804 set_recall();
805 *ident = TRUE;
806 break;
809 case SV_SCROLL_IDENTIFY:
811 *ident = TRUE;
812 if (!ident_spell()) used_up = FALSE;
813 break;
816 case SV_SCROLL_STAR_IDENTIFY:
818 *ident = TRUE;
819 if (!identify_fully()) used_up = FALSE;
820 break;
823 case SV_SCROLL_REMOVE_CURSE:
825 if (remove_curse())
827 msg_print("You feel as if someone is watching over you.");
828 *ident = TRUE;
830 break;
833 case SV_SCROLL_STAR_REMOVE_CURSE:
835 remove_all_curse();
836 *ident = TRUE;
837 break;
840 case SV_SCROLL_ENCHANT_ARMOR:
842 *ident = TRUE;
843 if (!enchant_spell(0, 0, 1)) used_up = FALSE;
844 break;
847 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
849 if (!enchant_spell(1, 0, 0)) used_up = FALSE;
850 *ident = TRUE;
851 break;
854 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
856 if (!enchant_spell(0, 1, 0)) used_up = FALSE;
857 *ident = TRUE;
858 break;
861 case SV_SCROLL_STAR_ENCHANT_ARMOR:
863 if (!enchant_spell(0, 0, randint(3) + 2)) used_up = FALSE;
864 *ident = TRUE;
865 break;
868 case SV_SCROLL_STAR_ENCHANT_WEAPON:
870 if (!enchant_spell(randint(3), randint(3), 0)) used_up = FALSE;
871 *ident = TRUE;
872 break;
875 case SV_SCROLL_RECHARGING:
877 if (!recharge(60)) used_up = FALSE;
878 *ident = TRUE;
879 break;
882 case SV_SCROLL_LIGHT:
884 if (lite_area(damroll(2, 8), 2)) *ident = TRUE;
885 break;
888 case SV_SCROLL_MAPPING:
890 map_area();
891 *ident = TRUE;
892 break;
895 case SV_SCROLL_DETECT_GOLD:
897 if (detect_treasure()) *ident = TRUE;
898 if (detect_objects_gold()) *ident = TRUE;
899 break;
902 case SV_SCROLL_DETECT_ITEM:
904 if (detect_objects_normal()) *ident = TRUE;
905 break;
908 case SV_SCROLL_DETECT_TRAP:
910 if (detect_traps()) *ident = TRUE;
911 break;
914 case SV_SCROLL_DETECT_DOOR:
916 if (detect_doors()) *ident = TRUE;
917 if (detect_stairs()) *ident = TRUE;
918 break;
921 case SV_SCROLL_DETECT_INVIS:
923 if (detect_monsters_invis()) *ident = TRUE;
924 break;
927 case SV_SCROLL_SATISFY_HUNGER:
929 if (set_food(PY_FOOD_MAX - 1)) *ident = TRUE;
930 break;
933 case SV_SCROLL_BLESSING:
935 if (inc_timed(TMD_BLESSED, randint(12) + 6)) *ident = TRUE;
936 break;
939 case SV_SCROLL_HOLY_CHANT:
941 if (inc_timed(TMD_BLESSED, randint(24) + 12)) *ident = TRUE;
942 break;
945 case SV_SCROLL_HOLY_PRAYER:
947 if (inc_timed(TMD_BLESSED, randint(48) + 24)) *ident = TRUE;
948 break;
951 case SV_SCROLL_MONSTER_CONFUSION:
953 if (p_ptr->confusing == 0)
955 msg_print("Your hands begin to glow.");
956 p_ptr->confusing = TRUE;
957 *ident = TRUE;
959 break;
962 case SV_SCROLL_PROTECTION_FROM_EVIL:
964 k = 3 * p_ptr->lev;
965 if (inc_timed(TMD_PROTEVIL, randint(25) + k)) *ident = TRUE;
966 break;
969 case SV_SCROLL_RUNE_OF_PROTECTION:
971 warding_glyph();
972 *ident = TRUE;
973 break;
976 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
978 if (destroy_doors_touch()) *ident = TRUE;
979 break;
982 case SV_SCROLL_STAR_DESTRUCTION:
984 destroy_area(py, px, 15, TRUE);
985 *ident = TRUE;
986 break;
989 case SV_SCROLL_DISPEL_UNDEAD:
991 if (dispel_undead(60)) *ident = TRUE;
992 break;
995 case SV_SCROLL_BANISHMENT:
997 if (!banishment()) used_up = FALSE;
998 *ident = TRUE;
999 break;
1002 case SV_SCROLL_MASS_BANISHMENT:
1004 (void)mass_banishment();
1005 *ident = TRUE;
1006 break;
1009 case SV_SCROLL_ACQUIREMENT:
1011 acquirement(py, px, 1, TRUE);
1012 *ident = TRUE;
1013 break;
1016 case SV_SCROLL_STAR_ACQUIREMENT:
1018 acquirement(py, px, randint(2) + 1, TRUE);
1019 *ident = TRUE;
1020 break;
1024 return (used_up);
1028 static bool use_staff(object_type *o_ptr, bool *ident)
1030 int py = p_ptr->py;
1031 int px = p_ptr->px;
1033 int k;
1035 bool use_charge = TRUE;
1037 /* Analyze the staff */
1038 switch (o_ptr->sval)
1040 case SV_STAFF_DARKNESS:
1042 if (!p_ptr->resist_blind)
1044 if (inc_timed(TMD_BLIND, 3 + randint(5))) *ident = TRUE;
1046 if (unlite_area(10, 3)) *ident = TRUE;
1047 break;
1050 case SV_STAFF_SLOWNESS:
1052 if (inc_timed(TMD_SLOW, randint(30) + 15)) *ident = TRUE;
1053 break;
1056 case SV_STAFF_HASTE_MONSTERS:
1058 if (speed_monsters()) *ident = TRUE;
1059 break;
1062 case SV_STAFF_SUMMONING:
1064 sound(MSG_SUM_MONSTER);
1065 for (k = 0; k < randint(4); k++)
1067 if (summon_specific(py, px, p_ptr->depth, 0))
1069 *ident = TRUE;
1072 break;
1075 case SV_STAFF_TELEPORTATION:
1077 teleport_player(100);
1078 *ident = TRUE;
1079 break;
1082 case SV_STAFF_IDENTIFY:
1084 if (!ident_spell()) use_charge = FALSE;
1085 *ident = TRUE;
1086 break;
1089 case SV_STAFF_REMOVE_CURSE:
1091 if (remove_curse())
1093 if (!p_ptr->timed[TMD_BLIND])
1095 msg_print("The staff glows blue for a moment...");
1097 *ident = TRUE;
1099 break;
1102 case SV_STAFF_STARLITE:
1104 if (!p_ptr->timed[TMD_BLIND])
1106 msg_print("The end of the staff glows brightly...");
1108 for (k = 0; k < 8; k++) lite_line(ddd[k]);
1109 *ident = TRUE;
1110 break;
1113 case SV_STAFF_LITE:
1115 if (lite_area(damroll(2, 8), 2)) *ident = TRUE;
1116 break;
1119 case SV_STAFF_MAPPING:
1121 map_area();
1122 *ident = TRUE;
1123 break;
1126 case SV_STAFF_DETECT_GOLD:
1128 if (detect_treasure()) *ident = TRUE;
1129 if (detect_objects_gold()) *ident = TRUE;
1130 break;
1133 case SV_STAFF_DETECT_ITEM:
1135 if (detect_objects_normal()) *ident = TRUE;
1136 break;
1139 case SV_STAFF_DETECT_TRAP:
1141 if (detect_traps()) *ident = TRUE;
1142 break;
1145 case SV_STAFF_DETECT_DOOR:
1147 if (detect_doors()) *ident = TRUE;
1148 if (detect_stairs()) *ident = TRUE;
1149 break;
1152 case SV_STAFF_DETECT_INVIS:
1154 if (detect_monsters_invis()) *ident = TRUE;
1155 break;
1158 case SV_STAFF_DETECT_EVIL:
1160 if (detect_monsters_evil()) *ident = TRUE;
1161 break;
1164 case SV_STAFF_CURE_LIGHT:
1166 if (hp_player(randint(8))) *ident = TRUE;
1167 break;
1170 case SV_STAFF_CURING:
1172 if (clear_timed(TMD_BLIND)) *ident = TRUE;
1173 if (clear_timed(TMD_POISONED)) *ident = TRUE;
1174 if (clear_timed(TMD_CONFUSED)) *ident = TRUE;
1175 if (clear_timed(TMD_STUN)) *ident = TRUE;
1176 if (clear_timed(TMD_CUT)) *ident = TRUE;
1177 break;
1180 case SV_STAFF_HEALING:
1182 if (hp_player(300)) *ident = TRUE;
1183 if (clear_timed(TMD_STUN)) *ident = TRUE;
1184 if (clear_timed(TMD_CUT)) *ident = TRUE;
1185 break;
1188 case SV_STAFF_THE_MAGI:
1190 if (do_res_stat(A_INT)) *ident = TRUE;
1191 if (p_ptr->csp < p_ptr->msp)
1193 p_ptr->csp = p_ptr->msp;
1194 p_ptr->csp_frac = 0;
1195 *ident = TRUE;
1196 msg_print("Your feel your head clear.");
1197 p_ptr->redraw |= (PR_MANA);
1198 p_ptr->window |= (PW_PLAYER_0 | PW_PLAYER_1);
1200 break;
1203 case SV_STAFF_SLEEP_MONSTERS:
1205 if (sleep_monsters()) *ident = TRUE;
1206 break;
1209 case SV_STAFF_SLOW_MONSTERS:
1211 if (slow_monsters()) *ident = TRUE;
1212 break;
1215 case SV_STAFF_SPEED:
1217 if (!p_ptr->timed[TMD_FAST])
1219 if (set_timed(TMD_FAST, randint(30) + 15)) *ident = TRUE;
1221 else
1223 (void)inc_timed(TMD_FAST, 5);
1225 break;
1228 case SV_STAFF_PROBING:
1230 probing();
1231 *ident = TRUE;
1232 break;
1235 case SV_STAFF_DISPEL_EVIL:
1237 if (dispel_evil(60)) *ident = TRUE;
1238 break;
1241 case SV_STAFF_POWER:
1243 if (dispel_monsters(120)) *ident = TRUE;
1244 break;
1247 case SV_STAFF_HOLINESS:
1249 if (dispel_evil(120)) *ident = TRUE;
1250 k = 3 * p_ptr->lev;
1251 if (inc_timed(TMD_PROTEVIL, randint(25) + k)) *ident = TRUE;
1252 if (clear_timed(TMD_POISONED)) *ident = TRUE;
1253 if (clear_timed(TMD_AFRAID)) *ident = TRUE;
1254 if (hp_player(50)) *ident = TRUE;
1255 if (clear_timed(TMD_STUN)) *ident = TRUE;
1256 if (clear_timed(TMD_CUT)) *ident = TRUE;
1257 break;
1260 case SV_STAFF_BANISHMENT:
1262 if (!banishment()) use_charge = FALSE;
1263 *ident = TRUE;
1264 break;
1267 case SV_STAFF_EARTHQUAKES:
1269 earthquake(py, px, 10);
1270 *ident = TRUE;
1271 break;
1274 case SV_STAFF_DESTRUCTION:
1276 destroy_area(py, px, 15, TRUE);
1277 *ident = TRUE;
1278 break;
1282 return (use_charge);
1286 static bool aim_wand(object_type *o_ptr, bool *ident)
1288 int lev, chance, dir, sval;
1291 /* Allow direction to be cancelled for free */
1292 if (!get_aim_dir(&dir)) return (FALSE);
1294 /* Take a turn */
1295 p_ptr->energy_use = 100;
1297 /* Not identified yet */
1298 *ident = FALSE;
1300 /* Get the level */
1301 lev = k_info[o_ptr->k_idx].level;
1303 /* Base chance of success */
1304 chance = p_ptr->skills[SKILL_DEV];
1306 /* Confusion hurts skill */
1307 if (p_ptr->timed[TMD_CONFUSED]) chance = chance / 2;
1309 /* High level objects are harder */
1310 chance = chance - ((lev > 50) ? 50 : lev);
1312 /* Give everyone a (slight) chance */
1313 if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
1315 chance = USE_DEVICE;
1318 /* Roll for usage */
1319 if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE))
1321 if (flush_failure) flush();
1322 msg_print("You failed to use the wand properly.");
1323 return (FALSE);
1326 /* The wand is already empty! */
1327 if (o_ptr->pval <= 0)
1329 if (flush_failure) flush();
1330 msg_print("The wand has no charges left.");
1331 o_ptr->ident |= (IDENT_EMPTY);
1332 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1333 p_ptr->window |= (PW_INVEN);
1334 return (FALSE);
1338 /* Sound */
1339 /* TODO: Create wand sound? Do the individual effects have sounds? */
1340 /* sound(MSG_ZAP_ROD); */
1343 /* XXX Hack -- Extract the "sval" effect */
1344 sval = o_ptr->sval;
1346 /* XXX Hack -- Wand of wonder can do anything before it */
1347 if (sval == SV_WAND_WONDER) sval = rand_int(SV_WAND_WONDER);
1349 /* Analyze the wand */
1350 switch (sval)
1352 case SV_WAND_HEAL_MONSTER:
1354 if (heal_monster(dir)) *ident = TRUE;
1355 break;
1358 case SV_WAND_HASTE_MONSTER:
1360 if (speed_monster(dir)) *ident = TRUE;
1361 break;
1364 case SV_WAND_CLONE_MONSTER:
1366 if (clone_monster(dir)) *ident = TRUE;
1367 break;
1370 case SV_WAND_TELEPORT_AWAY:
1372 if (teleport_monster(dir)) *ident = TRUE;
1373 break;
1376 case SV_WAND_DISARMING:
1378 if (disarm_trap(dir)) *ident = TRUE;
1379 break;
1382 case SV_WAND_TRAP_DOOR_DEST:
1384 if (destroy_door(dir)) *ident = TRUE;
1385 break;
1388 case SV_WAND_STONE_TO_MUD:
1390 if (wall_to_mud(dir)) *ident = TRUE;
1391 break;
1394 case SV_WAND_LITE:
1396 msg_print("A line of blue shimmering light appears.");
1397 lite_line(dir);
1398 *ident = TRUE;
1399 break;
1402 case SV_WAND_SLEEP_MONSTER:
1404 if (sleep_monster(dir)) *ident = TRUE;
1405 break;
1408 case SV_WAND_SLOW_MONSTER:
1410 if (slow_monster(dir)) *ident = TRUE;
1411 break;
1414 case SV_WAND_CONFUSE_MONSTER:
1416 if (confuse_monster(dir, 10)) *ident = TRUE;
1417 break;
1420 case SV_WAND_FEAR_MONSTER:
1422 if (fear_monster(dir, 10)) *ident = TRUE;
1423 break;
1426 case SV_WAND_DRAIN_LIFE:
1428 if (drain_life(dir, 150)) *ident = TRUE;
1429 break;
1432 case SV_WAND_POLYMORPH:
1434 if (poly_monster(dir)) *ident = TRUE;
1435 break;
1438 case SV_WAND_STINKING_CLOUD:
1440 fire_ball(GF_POIS, dir, 12, 2);
1441 *ident = TRUE;
1442 break;
1445 case SV_WAND_MAGIC_MISSILE:
1447 fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(3, 4));
1448 *ident = TRUE;
1449 break;
1452 case SV_WAND_ACID_BOLT:
1454 fire_bolt_or_beam(20, GF_ACID, dir, damroll(10, 8));
1455 *ident = TRUE;
1456 break;
1459 case SV_WAND_ELEC_BOLT:
1461 fire_bolt_or_beam(20, GF_ELEC, dir, damroll(6, 6));
1462 *ident = TRUE;
1463 break;
1466 case SV_WAND_FIRE_BOLT:
1468 fire_bolt_or_beam(20, GF_FIRE, dir, damroll(12, 8));
1469 *ident = TRUE;
1470 break;
1473 case SV_WAND_COLD_BOLT:
1475 fire_bolt_or_beam(20, GF_COLD, dir, damroll(6, 8));
1476 *ident = TRUE;
1477 break;
1480 case SV_WAND_ACID_BALL:
1482 fire_ball(GF_ACID, dir, 120, 2);
1483 *ident = TRUE;
1484 break;
1487 case SV_WAND_ELEC_BALL:
1489 fire_ball(GF_ELEC, dir, 64, 2);
1490 *ident = TRUE;
1491 break;
1494 case SV_WAND_FIRE_BALL:
1496 fire_ball(GF_FIRE, dir, 144, 2);
1497 *ident = TRUE;
1498 break;
1501 case SV_WAND_COLD_BALL:
1503 fire_ball(GF_COLD, dir, 96, 2);
1504 *ident = TRUE;
1505 break;
1508 case SV_WAND_WONDER:
1510 msg_print("Oops. Wand of wonder activated.");
1511 break;
1514 case SV_WAND_DRAGON_FIRE:
1516 fire_ball(GF_FIRE, dir, 200, 3);
1517 *ident = TRUE;
1518 break;
1521 case SV_WAND_DRAGON_COLD:
1523 fire_ball(GF_COLD, dir, 160, 3);
1524 *ident = TRUE;
1525 break;
1528 case SV_WAND_DRAGON_BREATH:
1530 switch (randint(5))
1532 case 1:
1534 fire_ball(GF_ACID, dir, 200, 3);
1535 break;
1538 case 2:
1540 fire_ball(GF_ELEC, dir, 160, 3);
1541 break;
1544 case 3:
1546 fire_ball(GF_FIRE, dir, 200, 3);
1547 break;
1550 case 4:
1552 fire_ball(GF_COLD, dir, 160, 3);
1553 break;
1556 default:
1558 fire_ball(GF_POIS, dir, 120, 3);
1559 break;
1563 *ident = TRUE;
1564 break;
1567 case SV_WAND_ANNIHILATION:
1569 if (drain_life(dir, 250)) *ident = TRUE;
1570 break;
1574 return (TRUE);
1578 static bool zap_rod(object_type *o_ptr, bool *ident)
1580 int chance, dir, lev;
1581 bool used_charge = TRUE;
1582 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1585 /* Get a direction (unless KNOWN not to need it) */
1586 if ((o_ptr->sval >= SV_ROD_MIN_DIRECTION) || !object_aware_p(o_ptr))
1588 /* Get a direction, allow cancel */
1589 if (!get_aim_dir(&dir)) return FALSE;
1593 /* Take a turn */
1594 p_ptr->energy_use = 100;
1596 /* Not identified yet */
1597 *ident = FALSE;
1599 /* Extract the item level */
1600 lev = k_info[o_ptr->k_idx].level;
1602 /* Base chance of success */
1603 chance = p_ptr->skills[SKILL_DEV];
1605 /* Confusion hurts skill */
1606 if (p_ptr->timed[TMD_CONFUSED]) chance = chance / 2;
1608 /* High level objects are harder */
1609 chance = chance - ((lev > 50) ? 50 : lev);
1611 /* Give everyone a (slight) chance */
1612 if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
1614 chance = USE_DEVICE;
1617 /* Roll for usage */
1618 if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE))
1620 if (flush_failure) flush();
1621 msg_print("You failed to use the rod properly.");
1622 return FALSE;
1625 /* Still charging? */
1626 if (o_ptr->timeout > (o_ptr->pval - k_ptr->pval))
1628 if (flush_failure) flush();
1630 if (o_ptr->number == 1)
1631 msg_print("The rod is still charging");
1632 else
1633 msg_print("The rods are all still charging");
1635 return FALSE;
1638 /* Sound */
1639 sound(MSG_ZAP_ROD);
1641 /* Analyze the rod */
1642 switch (o_ptr->sval)
1644 case SV_ROD_DETECT_TRAP:
1646 if (detect_traps()) *ident = TRUE;
1647 break;
1650 case SV_ROD_DETECT_DOOR:
1652 if (detect_doors()) *ident = TRUE;
1653 if (detect_stairs()) *ident = TRUE;
1654 break;
1657 case SV_ROD_IDENTIFY:
1659 *ident = TRUE;
1660 if (!ident_spell()) used_charge = FALSE;
1661 break;
1664 case SV_ROD_RECALL:
1666 set_recall();
1667 *ident = TRUE;
1668 break;
1671 case SV_ROD_ILLUMINATION:
1673 if (lite_area(damroll(2, 8), 2)) *ident = TRUE;
1674 break;
1677 case SV_ROD_MAPPING:
1679 map_area();
1680 *ident = TRUE;
1681 break;
1684 case SV_ROD_DETECTION:
1686 detect_all();
1687 *ident = TRUE;
1688 break;
1691 case SV_ROD_PROBING:
1693 probing();
1694 *ident = TRUE;
1695 break;
1698 case SV_ROD_CURING:
1700 if (clear_timed(TMD_BLIND)) *ident = TRUE;
1701 if (clear_timed(TMD_POISONED)) *ident = TRUE;
1702 if (clear_timed(TMD_CONFUSED)) *ident = TRUE;
1703 if (clear_timed(TMD_STUN)) *ident = TRUE;
1704 if (clear_timed(TMD_CUT)) *ident = TRUE;
1705 break;
1708 case SV_ROD_HEALING:
1710 if (hp_player(500)) *ident = TRUE;
1711 if (clear_timed(TMD_STUN)) *ident = TRUE;
1712 if (clear_timed(TMD_CUT)) *ident = TRUE;
1713 break;
1716 case SV_ROD_RESTORATION:
1718 if (restore_level()) *ident = TRUE;
1719 if (do_res_stat(A_STR)) *ident = TRUE;
1720 if (do_res_stat(A_INT)) *ident = TRUE;
1721 if (do_res_stat(A_WIS)) *ident = TRUE;
1722 if (do_res_stat(A_DEX)) *ident = TRUE;
1723 if (do_res_stat(A_CON)) *ident = TRUE;
1724 if (do_res_stat(A_CHR)) *ident = TRUE;
1725 break;
1728 case SV_ROD_SPEED:
1730 if (!p_ptr->timed[TMD_FAST])
1732 if (set_timed(TMD_FAST, randint(30) + 15)) *ident = TRUE;
1734 else
1736 (void)inc_timed(TMD_FAST, 5);
1738 break;
1741 case SV_ROD_TELEPORT_AWAY:
1743 if (teleport_monster(dir)) *ident = TRUE;
1744 break;
1747 case SV_ROD_DISARMING:
1749 if (disarm_trap(dir)) *ident = TRUE;
1750 break;
1753 case SV_ROD_LITE:
1755 msg_print("A line of blue shimmering light appears.");
1756 lite_line(dir);
1757 *ident = TRUE;
1758 break;
1761 case SV_ROD_SLEEP_MONSTER:
1763 if (sleep_monster(dir)) *ident = TRUE;
1764 break;
1767 case SV_ROD_SLOW_MONSTER:
1769 if (slow_monster(dir)) *ident = TRUE;
1770 break;
1773 case SV_ROD_DRAIN_LIFE:
1775 if (drain_life(dir, 150)) *ident = TRUE;
1776 break;
1779 case SV_ROD_POLYMORPH:
1781 if (poly_monster(dir)) *ident = TRUE;
1782 break;
1785 case SV_ROD_ACID_BOLT:
1787 fire_bolt_or_beam(10, GF_ACID, dir, damroll(12, 8));
1788 *ident = TRUE;
1789 break;
1792 case SV_ROD_ELEC_BOLT:
1794 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(6, 6));
1795 *ident = TRUE;
1796 break;
1799 case SV_ROD_FIRE_BOLT:
1801 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(16, 8));
1802 *ident = TRUE;
1803 break;
1806 case SV_ROD_COLD_BOLT:
1808 fire_bolt_or_beam(10, GF_COLD, dir, damroll(10, 8));
1809 *ident = TRUE;
1810 break;
1813 case SV_ROD_ACID_BALL:
1815 fire_ball(GF_ACID, dir, 120, 2);
1816 *ident = TRUE;
1817 break;
1820 case SV_ROD_ELEC_BALL:
1822 fire_ball(GF_ELEC, dir, 64, 2);
1823 *ident = TRUE;
1824 break;
1827 case SV_ROD_FIRE_BALL:
1829 fire_ball(GF_FIRE, dir, 144, 2);
1830 *ident = TRUE;
1831 break;
1834 case SV_ROD_COLD_BALL:
1836 fire_ball(GF_COLD, dir, 96, 2);
1837 *ident = TRUE;
1838 break;
1842 /* Drain the charge */
1843 if (used_charge) o_ptr->timeout += k_ptr->pval;
1845 return TRUE;
1850 * Activate a wielded object. Wielded objects never stack.
1851 * And even if they did, activatable objects never stack.
1853 * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated.
1854 * But one could, for example, easily make an activatable "Ring of Plasma".
1856 * Note that it always takes a turn to activate an artifact, even if
1857 * the user hits "escape" at the "direction" prompt.
1859 static bool activate_object(object_type *o_ptr, bool *ident)
1861 int k, dir, i, chance;
1864 /* Check the recharge */
1865 if (o_ptr->timeout)
1867 msg_print("It whines, glows and fades...");
1868 return FALSE;
1871 /* Activate the artifact */
1872 message(MSG_ACT_ARTIFACT, 0, "You activate it...");
1874 /* Artifacts */
1875 if (o_ptr->name1)
1877 artifact_type *a_ptr = &a_info[o_ptr->name1];
1878 char o_name[80];
1880 /* Get the basic name of the object */
1881 object_desc(o_name, sizeof(o_name), o_ptr, FALSE, 0);
1883 switch (a_ptr->activation)
1885 case ACT_ILLUMINATION:
1887 msg_format("The %s wells with clear light...", o_name);
1888 lite_area(damroll(2, 15), 3);
1889 break;
1892 case ACT_MAGIC_MAP:
1894 msg_format("The %s shines brightly...", o_name);
1895 map_area();
1896 break;
1899 case ACT_CLAIRVOYANCE:
1901 msg_format("The %s glows a deep green...", o_name);
1902 wiz_lite();
1903 (void)detect_traps();
1904 (void)detect_doors();
1905 (void)detect_stairs();
1906 break;
1909 case ACT_PROT_EVIL:
1911 msg_format("The %s lets out a shrill wail...", o_name);
1912 k = 3 * p_ptr->lev;
1913 (void)inc_timed(TMD_PROTEVIL, randint(25) + k);
1914 break;
1917 case ACT_DISP_EVIL:
1919 msg_format("The %s floods the area with goodness...", o_name);
1920 dispel_evil(p_ptr->lev * 5);
1921 break;
1924 case ACT_HASTE2:
1926 msg_format("The %s glows brightly...", o_name);
1927 if (!p_ptr->timed[TMD_FAST])
1929 (void)set_timed(TMD_FAST, randint(75) + 75);
1931 else
1933 (void)inc_timed(TMD_FAST, 5);
1935 break;
1938 case ACT_FIRE3:
1940 msg_format("The %s glows deep red...", o_name);
1941 if (!get_aim_dir(&dir)) return FALSE;
1942 fire_ball(GF_FIRE, dir, 120, 3);
1943 break;
1946 case ACT_FROST5:
1948 msg_format("The %s glows bright white...", o_name);
1949 if (!get_aim_dir(&dir)) return FALSE;
1950 fire_ball(GF_COLD, dir, 200, 3);
1951 break;
1954 case ACT_ELEC2:
1956 msg_format("The %s glows deep blue...", o_name);
1957 if (!get_aim_dir(&dir)) return FALSE;
1958 fire_ball(GF_ELEC, dir, 250, 3);
1959 break;
1962 case ACT_BIZZARE:
1964 msg_format("The %s glows intensely black...", o_name);
1965 if (!get_aim_dir(&dir)) return FALSE;
1966 ring_of_power(dir);
1967 break;
1971 case ACT_STAR_BALL:
1973 msg_format("Your %s is surrounded by lightning...", o_name);
1974 for (i = 0; i < 8; i++) fire_ball(GF_ELEC, ddd[i], 150, 3);
1975 break;
1978 case ACT_RAGE_BLESS_RESIST:
1980 msg_format("Your %s glows many colours...", o_name);
1981 (void)hp_player(30);
1982 (void)clear_timed(TMD_AFRAID);
1983 (void)inc_timed(TMD_SHERO, randint(50) + 50);
1984 (void)inc_timed(TMD_BLESSED, randint(50) + 50);
1985 (void)inc_timed(TMD_OPP_ACID, randint(50) + 50);
1986 (void)inc_timed(TMD_OPP_ELEC, randint(50) + 50);
1987 (void)inc_timed(TMD_OPP_FIRE, randint(50) + 50);
1988 (void)inc_timed(TMD_OPP_COLD, randint(50) + 50);
1989 (void)inc_timed(TMD_OPP_POIS, randint(50) + 50);
1990 break;
1993 case ACT_HEAL2:
1995 msg_format("Your %s glows a bright white...", o_name);
1996 msg_print("You feel much better...");
1997 (void)hp_player(1000);
1998 (void)clear_timed(TMD_CUT);
1999 break;
2002 case ACT_PHASE:
2004 msg_format("Your %s twists space around you...", o_name);
2005 teleport_player(10);
2006 break;
2009 case ACT_BANISHMENT:
2011 msg_format("Your %s glows deep blue...", o_name);
2012 if (!banishment()) return FALSE;
2013 break;
2016 case ACT_TRAP_DOOR_DEST:
2018 msg_format("Your %s glows bright red...", o_name);
2019 destroy_doors_touch();
2020 break;
2023 case ACT_DETECT:
2025 msg_format("Your %s glows bright white...", o_name);
2026 msg_print("An image forms in your mind...");
2027 detect_all();
2028 break;
2031 case ACT_HEAL1:
2033 msg_format("Your %s glows deep blue...", o_name);
2034 msg_print("You feel a warm tingling inside...");
2035 (void)hp_player(500);
2036 (void)clear_timed(TMD_CUT);
2037 break;
2040 case ACT_RESIST:
2042 msg_format("Your %s glows many colours...", o_name);
2043 (void)inc_timed(TMD_OPP_ACID, randint(20) + 20);
2044 (void)inc_timed(TMD_OPP_ELEC, randint(20) + 20);
2045 (void)inc_timed(TMD_OPP_FIRE, randint(20) + 20);
2046 (void)inc_timed(TMD_OPP_COLD, randint(20) + 20);
2047 (void)inc_timed(TMD_OPP_POIS, randint(20) + 20);
2048 break;
2051 case ACT_SLEEP:
2053 msg_format("Your %s glows deep blue...", o_name);
2054 sleep_monsters_touch();
2055 break;
2058 case ACT_RECHARGE1:
2060 msg_format("Your %s glows bright yellow...", o_name);
2061 if (!recharge(60)) return FALSE;
2062 break;
2065 case ACT_TELEPORT:
2067 msg_format("Your %s twists space around you...", o_name);
2068 teleport_player(100);
2069 break;
2072 case ACT_RESTORE_LIFE:
2074 msg_format("Your %s glows a deep red...", o_name);
2075 restore_level();
2076 break;
2079 case ACT_MISSILE:
2081 msg_format("Your %s glows extremely brightly...", o_name);
2082 if (!get_aim_dir(&dir)) return FALSE;
2083 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
2084 break;
2087 case ACT_FIRE1:
2089 msg_format("Your %s is covered in fire...", o_name);
2090 if (!get_aim_dir(&dir)) return FALSE;
2091 fire_bolt(GF_FIRE, dir, damroll(9, 8));
2092 break;
2095 case ACT_FROST1:
2097 msg_format("Your %s is covered in frost...", o_name);
2098 if (!get_aim_dir(&dir)) return FALSE;
2099 fire_bolt(GF_COLD, dir, damroll(6, 8));
2100 break;
2103 case ACT_LIGHTNING_BOLT:
2105 msg_format("Your %s is covered in sparks...", o_name);
2106 if (!get_aim_dir(&dir)) return FALSE;
2107 fire_bolt(GF_ELEC, dir, damroll(4, 8));
2108 break;
2111 case ACT_ACID1:
2113 msg_format("Your %s is covered in acid...", o_name);
2114 if (!get_aim_dir(&dir)) return FALSE;
2115 fire_bolt(GF_ACID, dir, damroll(5, 8));
2116 break;
2119 case ACT_ARROW:
2121 msg_format("Your %s grows magical spikes...", o_name);
2122 if (!get_aim_dir(&dir)) return FALSE;
2123 fire_bolt(GF_ARROW, dir, 150);
2124 break;
2127 case ACT_HASTE1:
2129 msg_format("Your %s glows bright green...", o_name);
2130 if (!p_ptr->timed[TMD_FAST])
2132 (void)set_timed(TMD_FAST, randint(20) + 20);
2134 else
2136 (void)inc_timed(TMD_FAST, 5);
2138 break;
2141 case ACT_REM_FEAR_POIS:
2143 msg_format("Your %s glows deep blue...", o_name);
2144 (void)clear_timed(TMD_AFRAID);
2145 (void)clear_timed(TMD_POISONED);
2146 break;
2149 case ACT_STINKING_CLOUD:
2151 msg_format("Your %s throbs deep green...", o_name);
2152 if (!get_aim_dir(&dir)) return FALSE;
2153 fire_ball(GF_POIS, dir, 12, 3);
2154 break;
2157 case ACT_FROST2:
2159 msg_format("Your %s is covered in frost...", o_name);
2160 if (!get_aim_dir(&dir)) return FALSE;
2161 fire_ball(GF_COLD, dir, 48, 2);
2162 break;
2165 case ACT_FROST4:
2167 msg_format("Your %s glows a pale blue...", o_name);
2168 if (!get_aim_dir(&dir)) return FALSE;
2169 fire_bolt(GF_COLD, dir, damroll(12, 8));
2170 break;
2173 case ACT_FROST3:
2175 msg_format("Your %s glows a intense blue...", o_name);
2176 if (!get_aim_dir(&dir)) return FALSE;
2177 fire_ball(GF_COLD, dir, 100, 2);
2178 break;
2181 case ACT_FIRE2:
2183 msg_format("Your %s rages in fire...", o_name);
2184 if (!get_aim_dir(&dir)) return FALSE;
2185 fire_ball(GF_FIRE, dir, 72, 2);
2186 break;
2189 case ACT_DRAIN_LIFE2:
2191 msg_format("Your %s glows black...", o_name);
2192 if (!get_aim_dir(&dir)) return FALSE;
2193 drain_life(dir, 120);
2194 break;
2197 case ACT_STONE_TO_MUD:
2199 msg_format("Your %s pulsates...", o_name);
2200 if (!get_aim_dir(&dir)) return FALSE;
2201 wall_to_mud(dir);
2202 break;
2205 case ACT_MASS_BANISHMENT:
2207 msg_format("Your %s lets out a long, shrill note...", o_name);
2208 (void)mass_banishment();
2209 break;
2212 case ACT_CURE_WOUNDS:
2214 msg_format("Your %s radiates deep purple...", o_name);
2215 hp_player(damroll(4, 8));
2216 (void)set_timed(TMD_CUT, (p_ptr->timed[TMD_CUT] / 2) - 50);
2217 break;
2220 case ACT_TELE_AWAY:
2222 msg_format("Your %s glows deep red...", o_name);
2223 if (!get_aim_dir(&dir)) return FALSE;
2224 teleport_monster(dir);
2225 break;
2228 case ACT_WOR:
2230 msg_format("Your %s glows soft white...", o_name);
2231 set_recall();
2232 break;
2235 case ACT_CONFUSE:
2237 msg_format("Your %s glows in scintillating colours...", o_name);
2238 if (!get_aim_dir(&dir)) return FALSE;
2239 confuse_monster(dir, 20);
2240 break;
2243 case ACT_IDENTIFY:
2245 msg_format("Your %s glows yellow...", o_name);
2246 if (!ident_spell()) return FALSE;
2247 break;
2250 case ACT_PROBE:
2252 msg_format("Your %s glows brightly...", o_name);
2253 probing();
2254 break;
2257 case ACT_DRAIN_LIFE1:
2259 msg_format("Your %s glows white...", o_name);
2260 if (!get_aim_dir(&dir)) return FALSE;
2261 drain_life(dir, 90);
2262 break;
2265 case ACT_FIREBRAND:
2267 msg_format("Your %s glows deep red...", o_name);
2268 if (!brand_bolts()) return FALSE;
2269 break;
2272 case ACT_STARLIGHT:
2274 msg_format("Your %s glows with the light of a thousand stars...", o_name);
2275 for (k = 0; k < 8; k++) strong_lite_line(ddd[k]);
2276 break;
2279 case ACT_MANA_BOLT:
2281 msg_format("Your %s glows white...", o_name);
2282 if (!get_aim_dir(&dir)) return FALSE;
2283 fire_bolt(GF_MANA, dir, damroll(12, 8));
2284 break;
2287 case ACT_BERSERKER:
2289 msg_format("Your %s glows in anger...", o_name);
2290 inc_timed(TMD_SHERO, randint(50) + 50);
2291 break;
2295 /* Set the recharge time */
2296 if (a_ptr->randtime)
2297 o_ptr->timeout = a_ptr->time + (byte)randint(a_ptr->randtime);
2298 else
2299 o_ptr->timeout = a_ptr->time;
2301 /* Window stuff */
2302 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2304 /* Done */
2305 return FALSE;
2309 /* Hack -- Dragon Scale Mail can be activated as well */
2310 if (o_ptr->tval == TV_DRAG_ARMOR)
2312 /* Get a direction for breathing (or abort) */
2313 if (!get_aim_dir(&dir)) return FALSE;
2315 /* Branch on the sub-type */
2316 switch (o_ptr->sval)
2318 case SV_DRAGON_BLUE:
2320 sound(MSG_BR_ELEC);
2321 msg_print("You breathe lightning.");
2322 fire_ball(GF_ELEC, dir, 100, 2);
2323 o_ptr->timeout = rand_int(450) + 450;
2324 break;
2327 case SV_DRAGON_WHITE:
2329 sound(MSG_BR_FROST);
2330 msg_print("You breathe frost.");
2331 fire_ball(GF_COLD, dir, 110, 2);
2332 o_ptr->timeout = rand_int(450) + 450;
2333 break;
2336 case SV_DRAGON_BLACK:
2338 sound(MSG_BR_ACID);
2339 msg_print("You breathe acid.");
2340 fire_ball(GF_ACID, dir, 130, 2);
2341 o_ptr->timeout = rand_int(450) + 450;
2342 break;
2345 case SV_DRAGON_GREEN:
2347 sound(MSG_BR_GAS);
2348 msg_print("You breathe poison gas.");
2349 fire_ball(GF_POIS, dir, 150, 2);
2350 o_ptr->timeout = rand_int(450) + 450;
2351 break;
2354 case SV_DRAGON_RED:
2356 sound(MSG_BR_FIRE);
2357 msg_print("You breathe fire.");
2358 fire_ball(GF_FIRE, dir, 200, 2);
2359 o_ptr->timeout = rand_int(450) + 450;
2360 break;
2363 case SV_DRAGON_MULTIHUED:
2365 chance = rand_int(5);
2366 sound( ((chance == 1) ? MSG_BR_ELEC :
2367 ((chance == 2) ? MSG_BR_FROST :
2368 ((chance == 3) ? MSG_BR_ACID :
2369 ((chance == 4) ? MSG_BR_GAS : MSG_BR_FIRE)))));
2370 msg_format("You breathe %s.",
2371 ((chance == 1) ? "lightning" :
2372 ((chance == 2) ? "frost" :
2373 ((chance == 3) ? "acid" :
2374 ((chance == 4) ? "poison gas" : "fire")))));
2375 fire_ball(((chance == 1) ? GF_ELEC :
2376 ((chance == 2) ? GF_COLD :
2377 ((chance == 3) ? GF_ACID :
2378 ((chance == 4) ? GF_POIS : GF_FIRE)))),
2379 dir, 250, 2);
2380 o_ptr->timeout = rand_int(225) + 225;
2381 break;
2384 case SV_DRAGON_BRONZE:
2386 sound(MSG_BR_CONF);
2387 msg_print("You breathe confusion.");
2388 fire_ball(GF_CONFUSION, dir, 120, 2);
2389 o_ptr->timeout = rand_int(450) + 450;
2390 break;
2393 case SV_DRAGON_GOLD:
2395 sound(MSG_BR_SOUND);
2396 msg_print("You breathe sound.");
2397 fire_ball(GF_SOUND, dir, 130, 2);
2398 o_ptr->timeout = rand_int(450) + 450;
2399 break;
2402 case SV_DRAGON_CHAOS:
2404 chance = rand_int(2);
2405 sound(((chance == 1 ? MSG_BR_CHAOS : MSG_BR_DISENCHANT)));
2406 msg_format("You breathe %s.",
2407 ((chance == 1 ? "chaos" : "disenchantment")));
2408 fire_ball((chance == 1 ? GF_CHAOS : GF_DISENCHANT),
2409 dir, 220, 2);
2410 o_ptr->timeout = rand_int(300) + 300;
2411 break;
2414 case SV_DRAGON_LAW:
2416 chance = rand_int(2);
2417 sound(((chance == 1 ? MSG_BR_SOUND : MSG_BR_SHARDS)));
2418 msg_format("You breathe %s.",
2419 ((chance == 1 ? "sound" : "shards")));
2420 fire_ball((chance == 1 ? GF_SOUND : GF_SHARD),
2421 dir, 230, 2);
2422 o_ptr->timeout = rand_int(300) + 300;
2423 break;
2426 case SV_DRAGON_BALANCE:
2428 chance = rand_int(4);
2429 msg_format("You breathe %s.",
2430 ((chance == 1) ? "chaos" :
2431 ((chance == 2) ? "disenchantment" :
2432 ((chance == 3) ? "sound" : "shards"))));
2433 fire_ball(((chance == 1) ? GF_CHAOS :
2434 ((chance == 2) ? GF_DISENCHANT :
2435 ((chance == 3) ? GF_SOUND : GF_SHARD))),
2436 dir, 250, 2);
2437 o_ptr->timeout = rand_int(300) + 300;
2438 break;
2441 case SV_DRAGON_SHINING:
2443 chance = rand_int(2);
2444 sound(((chance == 0 ? MSG_BR_LIGHT : MSG_BR_DARK)));
2445 msg_format("You breathe %s.",
2446 ((chance == 0 ? "light" : "darkness")));
2447 fire_ball((chance == 0 ? GF_LITE : GF_DARK), dir, 200, 2);
2448 o_ptr->timeout = rand_int(300) + 300;
2449 break;
2452 case SV_DRAGON_POWER:
2454 sound(MSG_BR_ELEMENTS);
2455 msg_print("You breathe the elements.");
2456 fire_ball(GF_MISSILE, dir, 300, 2);
2457 o_ptr->timeout = rand_int(300) + 300;
2458 break;
2462 /* Window stuff */
2463 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2465 /* Success */
2466 return FALSE;
2469 /* Hack -- some Rings can be activated for double resist and element ball */
2470 if (o_ptr->tval == TV_RING)
2472 /* Get a direction for firing (or abort) */
2473 if (!get_aim_dir(&dir)) return FALSE;
2475 /* Branch on the sub-type */
2476 switch (o_ptr->sval)
2478 case SV_RING_ACID:
2480 fire_ball(GF_ACID, dir, 70, 2);
2481 inc_timed(TMD_OPP_ACID, randint(20) + 20);
2482 o_ptr->timeout = rand_int(50) + 50;
2483 break;
2486 case SV_RING_FLAMES:
2488 fire_ball(GF_FIRE, dir, 80, 2);
2489 inc_timed(TMD_OPP_FIRE, randint(20) + 20);
2490 o_ptr->timeout = rand_int(50) + 50;
2491 break;
2494 case SV_RING_ICE:
2496 fire_ball(GF_COLD, dir, 75, 2);
2497 inc_timed(TMD_OPP_COLD, randint(20) + 20);
2498 o_ptr->timeout = rand_int(50) + 50;
2499 break;
2502 case SV_RING_LIGHTNING:
2504 fire_ball(GF_ELEC, dir, 85, 2);
2505 inc_timed(TMD_OPP_ELEC, randint(20) + 20);
2506 o_ptr->timeout = rand_int(50) + 50;
2507 break;
2511 /* Window stuff */
2512 p_ptr->window |= (PW_EQUIP);
2514 /* Success */
2515 return FALSE;
2518 /* Mistake */
2519 msg_print("Oops. That object cannot be activated.");
2521 /* Not used up */
2522 return (FALSE);
2526 bool use_object(object_type *o_ptr, bool *ident)
2528 bool used;
2530 /* Analyze the object */
2531 switch (o_ptr->tval)
2533 case TV_FOOD:
2535 used = eat_food(o_ptr, ident);
2536 break;
2539 case TV_POTION:
2541 used = quaff_potion(o_ptr, ident);
2542 break;
2545 case TV_SCROLL:
2547 used = read_scroll(o_ptr, ident);
2548 break;
2551 case TV_STAFF:
2553 used = use_staff(o_ptr, ident);
2554 break;
2557 case TV_WAND:
2559 used = aim_wand(o_ptr, ident);
2560 break;
2563 case TV_ROD:
2565 used = zap_rod(o_ptr, ident);
2566 break;
2569 default:
2571 used = activate_object(o_ptr, ident);
2572 break;
2576 return (used);
2580 static cptr act_description[ACT_MAX] =
2582 "illumination",
2583 "magic mapping",
2584 "clairvoyance",
2585 "protection from evil",
2586 "dispel evil (x5)",
2587 "heal (500)",
2588 "heal (1000)",
2589 "cure wounds (4d8)",
2590 "haste self (20+d20 turns)",
2591 "haste self (75+d75 turns)",
2592 "fire bolt (9d8)",
2593 "fire ball (72)",
2594 "large fire ball (120)",
2595 "frost bolt (6d8)",
2596 "frost ball (48)",
2597 "frost ball (100)",
2598 "frost bolt (12d8)",
2599 "large frost ball (200)",
2600 "acid bolt (5d8)",
2601 "recharge item I",
2602 "sleep II",
2603 "lightning bolt (4d8)",
2604 "large lightning ball (250)",
2605 "banishment",
2606 "mass banishment",
2607 "identify",
2608 "drain life (90)",
2609 "drain life (120)",
2610 "bizarre things",
2611 "star ball (150)",
2612 "berserk rage, bless, and resistance",
2613 "phase door",
2614 "door and trap destruction",
2615 "detection",
2616 "resistance (20+d20 turns)",
2617 "teleport",
2618 "restore life levels",
2619 "magic missile (2d6)",
2620 "a magical arrow (150)",
2621 "remove fear and cure poison",
2622 "stinking cloud (12)",
2623 "stone to mud",
2624 "teleport away",
2625 "word of recall",
2626 "confuse monster",
2627 "probing",
2628 "fire branding of bolts",
2629 "starlight (10d8)",
2630 "mana bolt (12d8)",
2631 "berserk rage (50+d50 turns)"
2637 * Determine the "Activation" (if any) for an artifact
2639 void describe_item_activation(const object_type *o_ptr)
2641 u32b f1, f2, f3;
2643 /* Extract the flags */
2644 object_flags(o_ptr, &f1, &f2, &f3);
2646 /* Require activation ability */
2647 if (!(f3 & TR3_ACTIVATE)) return;
2649 /* Artifact activations */
2650 if (o_ptr->name1)
2652 artifact_type *a_ptr = &a_info[o_ptr->name1];
2654 /* Paranoia */
2655 if (a_ptr->activation >= ACT_MAX) return;
2657 /* Some artifacts can be activated */
2658 text_out(act_description[a_ptr->activation]);
2660 /* Output the number of turns */
2661 if (a_ptr->time && a_ptr->randtime)
2662 text_out(format(" every %d+d%d turns", a_ptr->time, a_ptr->randtime));
2663 else if (a_ptr->time)
2664 text_out(format(" every %d turns", a_ptr->time));
2665 else if (a_ptr->randtime)
2666 text_out(format(" every d%d turns", a_ptr->randtime));
2668 return;
2671 /* Ring activations */
2672 if (o_ptr->tval == TV_RING)
2674 /* Branch on the sub-type */
2675 switch (o_ptr->sval)
2677 case SV_RING_ACID:
2679 text_out("acid resistance (20+d20 turns) and acid ball (70) every 50+d50 turns");
2680 break;
2682 case SV_RING_FLAMES:
2684 text_out("fire resistance (20+d20 turns) and fire ball (80) every 50+d50 turns");
2685 break;
2687 case SV_RING_ICE:
2689 text_out("cold resistance (20+d20 turns) and cold ball (75) every 50+d50 turns");
2690 break;
2693 case SV_RING_LIGHTNING:
2695 text_out("electricity resistance (20+d20 turns) and electricity ball (85) every 50+d50 turns");
2696 break;
2700 return;
2703 /* Require dragon scale mail */
2704 if (o_ptr->tval != TV_DRAG_ARMOR) return;
2706 /* Branch on the sub-type */
2707 switch (o_ptr->sval)
2709 case SV_DRAGON_BLUE:
2711 text_out("breathe lightning (100) every 450+d450 turns");
2712 break;
2714 case SV_DRAGON_WHITE:
2716 text_out("breathe frost (110) every 450+d450 turns");
2717 break;
2719 case SV_DRAGON_BLACK:
2721 text_out("breathe acid (130) every 450+d450 turns");
2722 break;
2724 case SV_DRAGON_GREEN:
2726 text_out("breathe poison gas (150) every 450+d450 turns");
2727 break;
2729 case SV_DRAGON_RED:
2731 text_out("breathe fire (200) every 450+d450 turns");
2732 break;
2734 case SV_DRAGON_MULTIHUED:
2736 text_out("breathe multi-hued (250) every 225+d225 turns");
2737 break;
2739 case SV_DRAGON_BRONZE:
2741 text_out("breathe confusion (120) every 450+d450 turns");
2742 break;
2744 case SV_DRAGON_GOLD:
2746 text_out("breathe sound (130) every 450+d450 turns");
2747 break;
2749 case SV_DRAGON_CHAOS:
2751 text_out("breathe chaos/disenchant (220) every 300+d300 turns");
2752 break;
2754 case SV_DRAGON_LAW:
2756 text_out("breathe sound/shards (230) every 300+d300 turns");
2757 break;
2759 case SV_DRAGON_BALANCE:
2761 text_out("breathe balance (250) every 300+d300 turns");
2762 break;
2764 case SV_DRAGON_SHINING:
2766 text_out("breathe light/darkness (200) every 300+d300 turns");
2767 break;
2769 case SV_DRAGON_POWER:
2771 text_out("breathe the elements (300) every 300+d300 turns");
2772 break;