OSDN Git Service

57dacd346b609ea2b981685fc300a8d57cb31eb4
[hengband/hengband.git] / src / cmd6.c
1 /* File: cmd6.c */
2
3 /* Purpose: Object commands */
4
5 /*
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research, and
9  * not for profit purposes provided that this copyright and statement are
10  * included in all such copies.
11  */
12
13 #include "angband.h"
14
15
16 /*
17  * This file includes code for eating food, drinking potions,
18  * reading scrolls, aiming wands, using staffs, zapping rods,
19  * and activating artifacts.
20  *
21  * In all cases, if the player becomes "aware" of the item's use
22  * by testing it, mark it as "aware" and reward some experience
23  * based on the object's level, always rounding up.  If the player
24  * remains "unaware", mark that object "kind" as "tried".
25  *
26  * This code now correctly handles the unstacking of wands, staffs,
27  * and rods.  Note the overly paranoid warning about potential pack
28  * overflow, which allows the player to use and drop a stacked item.
29  *
30  * In all "unstacking" scenarios, the "used" object is "carried" as if
31  * the player had just picked it up.  In particular, this means that if
32  * the use of an item induces pack overflow, that item will be dropped.
33  *
34  * For simplicity, these routines induce a full "pack reorganization"
35  * which not only combines similar items, but also reorganizes various
36  * items to obey the current "sorting" method.  This may require about
37  * 400 item comparisons, but only occasionally.
38  *
39  * There may be a BIG problem with any "effect" that can cause "changes"
40  * to the inventory.  For example, a "scroll of recharging" can cause
41  * a wand/staff to "disappear", moving the inventory up.  Luckily, the
42  * scrolls all appear BEFORE the staffs/wands, so this is not a problem.
43  * But, for example, a "staff of recharging" could cause MAJOR problems.
44  * In such a case, it will be best to either (1) "postpone" the effect
45  * until the end of the function, or (2) "change" the effect, say, into
46  * giving a staff "negative" charges, or "turning a staff into a stick".
47  * It seems as though a "rod of recharging" might in fact cause problems.
48  * The basic problem is that the act of recharging (and destroying) an
49  * item causes the inducer of that action to "move", causing "o_ptr" to
50  * no longer point at the correct item, with horrifying results.
51  *
52  * Note that food/potions/scrolls no longer use bit-flags for effects,
53  * but instead use the "sval" (which is also used to sort the objects).
54  */
55
56
57 static void do_cmd_eat_food_aux(int item)
58 {
59         int ident, lev;
60         object_type *o_ptr;
61
62         /* Get the item (in the pack) */
63         if (item >= 0)
64         {
65                 o_ptr = &inventory[item];
66         }
67
68         /* Get the item (on the floor) */
69         else
70         {
71                 o_ptr = &o_list[0 - item];
72         }
73
74         /* Sound */
75         sound(SOUND_EAT);
76
77         /* Take a turn */
78         energy_use = 100;
79
80         /* Identity not known yet */
81         ident = FALSE;
82
83         /* Object level */
84         lev = get_object_level(o_ptr);
85
86         if (o_ptr->tval == TV_FOOD)
87         {
88                 /* Analyze the food */
89                 switch (o_ptr->sval)
90                 {
91                         case SV_FOOD_POISON:
92                         {
93                                 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
94                                 {
95                                         if (set_poisoned(p_ptr->poisoned + randint0(10) + 10))
96                                         {
97                                                 ident = TRUE;
98                                         }
99                                 }
100                                 break;
101                         }
102
103                         case SV_FOOD_BLINDNESS:
104                         {
105                                 if (!p_ptr->resist_blind)
106                                 {
107                                         if (set_blind(p_ptr->blind + randint0(200) + 200))
108                                         {
109                                                 ident = TRUE;
110                                         }
111                                 }
112                                 break;
113                         }
114
115                         case SV_FOOD_PARANOIA:
116                         {
117                                 if (!p_ptr->resist_fear)
118                                 {
119                                         if (set_afraid(p_ptr->afraid + randint0(10) + 10))
120                                         {
121                                                 ident = TRUE;
122                                         }
123                                 }
124                                 break;
125                         }
126
127                         case SV_FOOD_CONFUSION:
128                         {
129                                 if (!p_ptr->resist_conf)
130                                 {
131                                         if (set_confused(p_ptr->confused + randint0(10) + 10))
132                                         {
133                                                 ident = TRUE;
134                                         }
135                                 }
136                                 break;
137                         }
138
139                         case SV_FOOD_HALLUCINATION:
140                         {
141                                 if (!p_ptr->resist_chaos)
142                                 {
143                                         if (set_image(p_ptr->image + randint0(250) + 250))
144                                         {
145                                                 ident = TRUE;
146                                         }
147                                 }
148                                 break;
149                         }
150
151                         case SV_FOOD_PARALYSIS:
152                         {
153                                 if (!p_ptr->free_act)
154                                 {
155                                         if (set_paralyzed(p_ptr->paralyzed + randint0(10) + 10))
156                                         {
157                                                 ident = TRUE;
158                                         }
159                                 }
160                                 break;
161                         }
162
163                         case SV_FOOD_WEAKNESS:
164                         {
165 #ifdef JP
166                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
167 #else
168                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
169 #endif
170
171                                 (void)do_dec_stat(A_STR);
172                                 ident = TRUE;
173                                 break;
174                         }
175
176                         case SV_FOOD_SICKNESS:
177                         {
178 #ifdef JP
179                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
180 #else
181                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
182 #endif
183
184                                 (void)do_dec_stat(A_CON);
185                                 ident = TRUE;
186                                 break;
187                         }
188
189                         case SV_FOOD_STUPIDITY:
190                         {
191 #ifdef JP
192                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
193 #else
194                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
195 #endif
196
197                                 (void)do_dec_stat(A_INT);
198                                 ident = TRUE;
199                                 break;
200                         }
201
202                         case SV_FOOD_NAIVETY:
203                         {
204 #ifdef JP
205                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
206 #else
207                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
208 #endif
209
210                                 (void)do_dec_stat(A_WIS);
211                                 ident = TRUE;
212                                 break;
213                         }
214
215                         case SV_FOOD_UNHEALTH:
216                         {
217 #ifdef JP
218                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
219 #else
220                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
221 #endif
222
223                                 (void)do_dec_stat(A_CON);
224                                 ident = TRUE;
225                                 break;
226                         }
227
228                         case SV_FOOD_DISEASE:
229                         {
230 #ifdef JP
231                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
232 #else
233                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
234 #endif
235
236                                 (void)do_dec_stat(A_STR);
237                                 ident = TRUE;
238                                 break;
239                         }
240
241                         case SV_FOOD_CURE_POISON:
242                         {
243                                 if (set_poisoned(0)) ident = TRUE;
244                                 break;
245                         }
246
247                         case SV_FOOD_CURE_BLINDNESS:
248                         {
249                                 if (set_blind(0)) ident = TRUE;
250                                 break;
251                         }
252
253                         case SV_FOOD_CURE_PARANOIA:
254                         {
255                                 if (set_afraid(0)) ident = TRUE;
256                                 break;
257                         }
258
259                         case SV_FOOD_CURE_CONFUSION:
260                         {
261                                 if (set_confused(0)) ident = TRUE;
262                                 break;
263                         }
264
265                         case SV_FOOD_CURE_SERIOUS:
266                         {
267                                 if (hp_player(damroll(4, 8))) ident = TRUE;
268                                 break;
269                         }
270
271                         case SV_FOOD_RESTORE_STR:
272                         {
273                                 if (do_res_stat(A_STR)) ident = TRUE;
274                                 break;
275                         }
276
277                         case SV_FOOD_RESTORE_CON:
278                         {
279                                 if (do_res_stat(A_CON)) ident = TRUE;
280                                 break;
281                         }
282
283                         case SV_FOOD_RESTORING:
284                         {
285                                 if (do_res_stat(A_STR)) ident = TRUE;
286                                 if (do_res_stat(A_INT)) ident = TRUE;
287                                 if (do_res_stat(A_WIS)) ident = TRUE;
288                                 if (do_res_stat(A_DEX)) ident = TRUE;
289                                 if (do_res_stat(A_CON)) ident = TRUE;
290                                 if (do_res_stat(A_CHR)) ident = TRUE;
291                                 break;
292                         }
293
294
295 #ifdef JP
296                         /* ¤½¤ì¤¾¤ì¤Î¿©¤Ùʪ¤Î´¶ÁÛ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
297                         case SV_FOOD_BISCUIT:
298                         {
299                                 msg_print("´Å¤¯¤Æ¥µ¥¯¥µ¥¯¤·¤Æ¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
300                                 ident = TRUE;
301                                 break;
302                         }
303
304                         case SV_FOOD_JERKY:
305                         {
306                                 msg_print("»õ¤´¤¿¤¨¤¬¤¢¤Ã¤Æ¤ª¤¤¤·¤¤¡£");
307                                 ident = TRUE;
308                                 break;
309                         }
310
311                         case SV_FOOD_SLIME_MOLD:
312                         {
313                                 msg_print("¤³¤ì¤Ï¤Ê¤ó¤È¤â·ÁÍƤ·¤¬¤¿¤¤Ì£¤À¡£");
314                                 ident = TRUE;
315                                 break;
316                         }
317
318                         case SV_FOOD_RATION:
319                         {
320                                 msg_print("¤³¤ì¤Ï¤ª¤¤¤·¤¤¡£");
321                                 ident = TRUE;
322                                 break;
323                         }
324 #else
325                         case SV_FOOD_RATION:
326                         case SV_FOOD_BISCUIT:
327                         case SV_FOOD_JERKY:
328                         case SV_FOOD_SLIME_MOLD:
329                         {
330                                 msg_print("That tastes good.");
331                                 ident = TRUE;
332                                 break;
333                         }
334 #endif
335
336
337                         case SV_FOOD_WAYBREAD:
338                         {
339 #ifdef JP
340                                 msg_print("¤³¤ì¤Ï¤Ò¤¸¤ç¤¦¤ËÈþÌ£¤À¡£");
341 #else
342                                 msg_print("That tastes good.");
343 #endif
344
345                                 (void)set_poisoned(0);
346                                 (void)hp_player(damroll(4, 8));
347                                 ident = TRUE;
348                                 break;
349                         }
350
351 #ifdef JP
352                         case SV_FOOD_PINT_OF_ALE:
353                         {
354                                 msg_print("¤Î¤É¤´¤·Á֤䤫¤À¡£");
355                                 ident = TRUE;
356                                 break;
357                         }
358
359                         case SV_FOOD_PINT_OF_WINE:
360                         {
361                                 msg_print("That tastes good.");
362                                 ident = TRUE;
363                                 break;
364                         }
365 #else
366                         case SV_FOOD_PINT_OF_ALE:
367                         case SV_FOOD_PINT_OF_WINE:
368                         {
369                                 msg_print("That tastes good.");
370                                 ident = TRUE;
371                                 break;
372                         }
373 #endif
374
375                 }
376         }
377
378         /* Combine / Reorder the pack (later) */
379         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
380
381         if (!(object_aware_p(o_ptr)))
382         {
383                 chg_virtue(V_KNOWLEDGE, -1);
384                 chg_virtue(V_PATIENCE, -1);
385                 chg_virtue(V_CHANCE, 1);
386         }
387
388         /* We have tried it */
389         if (o_ptr->tval == TV_FOOD) object_tried(o_ptr);
390
391         /* The player is now aware of the object */
392         if (ident && !object_aware_p(o_ptr))
393         {
394                 object_aware(o_ptr);
395                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
396         }
397
398         /* Window stuff */
399         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
400
401
402         /* Food can feed the player */
403         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
404         {
405                 /* Reduced nutritional benefit */
406                 (void)set_food(p_ptr->food + (o_ptr->pval / 10));
407 #ifdef JP
408 msg_print("¤¢¤Ê¤¿¤Î¤è¤¦¤Ê¼Ô¤Ë¤È¤Ã¤Æ¿©ÎȤʤɶϤ«¤Ê±ÉÍܤˤ·¤«¤Ê¤é¤Ê¤¤¡£");
409 #else
410                 msg_print("Mere victuals hold scant sustenance for a being such as yourself.");
411 #endif
412
413                 if (p_ptr->food < PY_FOOD_ALERT)   /* Hungry */
414 #ifdef JP
415 msg_print("¤¢¤Ê¤¿¤Îµ²¤¨¤Ï¿·Á¯¤Ê·ì¤Ë¤è¤Ã¤Æ¤Î¤ßËþ¤¿¤µ¤ì¤ë¡ª");
416 #else
417                         msg_print("Your hunger can only be satisfied with fresh blood!");
418 #endif
419
420         }
421         else if ((p_ptr->prace == RACE_SKELETON ||
422                   p_ptr->prace == RACE_GOLEM ||
423                   p_ptr->prace == RACE_ZOMBIE ||
424                   p_ptr->prace == RACE_SPECTRE) &&
425                  (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND))
426         {
427                 cptr staff;
428
429                 if (o_ptr->tval == TV_STAFF &&
430                     (item < 0) && (o_ptr->number > 1))
431                 {
432 #ifdef JP
433                         msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
434 #else
435                         msg_print("You must first pick up the staffs.");
436 #endif
437                         return;
438                 }
439
440 #ifdef JP
441                 staff = (o_ptr->tval == TV_STAFF) ? "¾ó" : "ËâË¡ËÀ";
442 #else
443                 staff = (o_ptr->tval == TV_STAFF) ? "staff" : "wand";
444 #endif
445
446                 /* "Eat" charges */
447                 if (o_ptr->pval == 0)
448                 {
449 #ifdef JP
450                         msg_format("¤³¤Î%s¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£", staff);
451 #else
452                         msg_format("The %s has no charges left.", staff);
453 #endif
454                         return;
455                 }
456
457 #ifdef JP
458                 msg_format("¤¢¤Ê¤¿¤Ï%s¤ÎËâÎϤò¥¨¥Í¥ë¥®¡¼¸»¤È¤·¤ÆµÛ¼ý¤·¤¿¡£", staff);
459 #else
460                 msg_format("You absorb mana of the %s as your energy.", staff);
461 #endif
462
463                 /* Use a single charge */
464                 o_ptr->pval--;
465
466                 /* Eat a charge */
467                 set_food(p_ptr->food + 5000);
468
469                 /* XXX Hack -- unstack if necessary */
470                 if (o_ptr->tval == TV_STAFF &&
471                     (item >= 0) && (o_ptr->number > 1))
472                 {
473                         object_type forge;
474                         object_type *q_ptr;
475
476                         /* Get local object */
477                         q_ptr = &forge;
478
479                         /* Obtain a local object */
480                         object_copy(q_ptr, o_ptr);
481
482                         /* Modify quantity */
483                         q_ptr->number = 1;
484
485                         /* Restore the charges */
486                         o_ptr->pval++;
487
488                         /* Unstack the used item */
489                         o_ptr->number--;
490                         p_ptr->total_weight -= q_ptr->weight;
491                         item = inven_carry(q_ptr);
492
493                         /* Message */
494 #ifdef JP
495                         msg_format("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
496 #else
497                         msg_print("You unstack your staff.");
498 #endif
499                 }
500
501                 /* Describe charges in the pack */
502                 if (item >= 0)
503                 {
504                         inven_item_charges(item);
505                 }
506
507                 /* Describe charges on the floor */
508                 else
509                 {
510                         floor_item_charges(0 - item);
511                 }
512
513                 /* Don't eat a staff/wand itself */
514                 return;
515         }
516         else if ((p_ptr->prace == RACE_DEMON ||
517                  (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) &&
518                  (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE &&
519                   strchr("pht", r_info[o_ptr->pval].d_char)))
520         {
521                 /* Drain vitality of humanoids */
522                 char o_name[MAX_NLEN];
523
524                 object_desc(o_name, o_ptr, FALSE, 0);
525
526 #ifdef JP
527                 msg_format("%s¤Ïdz¤¨¾å¤ê³¥¤Ë¤Ê¤Ã¤¿¡£ÀºÎϤòµÛ¼ý¤·¤¿µ¤¤¬¤¹¤ë¡£", o_name);
528 #else
529                 msg_format("%^s is burnt to ashes.  You absorb its vitality!", o_name);
530 #endif
531                 (void)set_food(PY_FOOD_MAX - 1);
532         }
533         else if (p_ptr->prace == RACE_SKELETON)
534         {
535 #if 0
536                 if (o_ptr->tval == TV_SKELETON ||
537                     (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
538                 {
539 #ifdef JP
540                         msg_print("¤¢¤Ê¤¿¤Ï¹ü¤Ç¼«Ê¬¤ÎÂΤòÊä¤Ã¤¿¡£");
541 #else
542                         msg_print("Your body absorbs the bone.");
543 #endif
544                         set_food(p_ptr->food + 5000);
545                 }
546                 else 
547 #endif
548
549                 if (!((o_ptr->sval == SV_FOOD_WAYBREAD) ||
550                       (o_ptr->sval < SV_FOOD_BISCUIT)))
551                 {
552                         object_type forge;
553                         object_type *q_ptr = &forge;
554
555 #ifdef JP
556 msg_print("¿©¤Ùʪ¤¬¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
557 #else
558                         msg_print("The food falls through your jaws!");
559 #endif
560
561
562                         /* Create the item */
563                         object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval));
564
565                         /* Drop the object from heaven */
566                         (void)drop_near(q_ptr, -1, py, px);
567                 }
568                 else
569                 {
570 #ifdef JP
571 msg_print("¿©¤Ùʪ¤¬¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¡¢¾Ã¤¨¤¿¡ª");
572 #else
573                         msg_print("The food falls through your jaws and vanishes!");
574 #endif
575
576                 }
577         }
578         else if ((p_ptr->prace == RACE_GOLEM) ||
579                  (p_ptr->prace == RACE_ZOMBIE) ||
580                  (p_ptr->prace == RACE_ENT) ||
581                  (p_ptr->prace == RACE_DEMON) ||
582                  (p_ptr->prace == RACE_ANDROID) ||
583                  (p_ptr->prace == RACE_SPECTRE) ||
584                  (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
585         {
586 #ifdef JP
587 msg_print("À¸¼Ô¤Î¿©Êª¤Ï¤¢¤Ê¤¿¤Ë¤È¤Ã¤Æ¤Û¤È¤ó¤É±ÉÍܤˤʤé¤Ê¤¤¡£");
588 #else
589                 msg_print("The food of mortals is poor sustenance for you.");
590 #endif
591
592                 set_food(p_ptr->food + ((o_ptr->pval) / 20));
593         }
594         else
595         {
596                 (void)set_food(p_ptr->food + o_ptr->pval);
597         }
598
599         /* Destroy a food in the pack */
600         if (item >= 0)
601         {
602                 inven_item_increase(item, -1);
603                 inven_item_describe(item);
604                 inven_item_optimize(item);
605         }
606
607         /* Destroy a food on the floor */
608         else
609         {
610                 floor_item_increase(0 - item, -1);
611                 floor_item_describe(0 - item);
612                 floor_item_optimize(0 - item);
613         }
614 }
615
616
617 /*
618  * Hook to determine if an object is eatable
619  */
620 static bool item_tester_hook_eatable(object_type *o_ptr)
621 {
622         if (o_ptr->tval==TV_FOOD) return TRUE;
623
624 #if 0
625         if (p_ptr->prace == RACE_SKELETON)
626         {
627                 if (o_ptr->tval == TV_SKELETON ||
628                     (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
629                         return TRUE;
630         }
631         else 
632 #endif
633
634         if (p_ptr->prace == RACE_SKELETON ||
635             p_ptr->prace == RACE_GOLEM ||
636             p_ptr->prace == RACE_ZOMBIE ||
637             p_ptr->prace == RACE_SPECTRE)
638         {
639                 if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)
640                         return TRUE;
641         }
642         else if ((p_ptr->prace == RACE_DEMON) ||
643                  (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON))
644         {
645                 if (o_ptr->tval == TV_CORPSE &&
646                     o_ptr->sval == SV_CORPSE &&
647                     strchr("pht", r_info[o_ptr->pval].d_char))
648                         return TRUE;
649         }
650
651         /* Assume not */
652         return (FALSE);
653 }
654
655
656 /*
657  * Eat some food (from the pack or floor)
658  */
659 void do_cmd_eat_food(void)
660 {
661         int         item;
662         cptr        q, s;
663
664
665         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
666         {
667                 set_action(ACTION_NONE);
668         }
669
670         /* Restrict choices to food */
671         item_tester_hook = item_tester_hook_eatable;
672
673         /* Get an item */
674 #ifdef JP
675         q = "¤É¤ì¤ò¿©¤Ù¤Þ¤¹¤«? ";
676         s = "¿©¤Ùʪ¤¬¤Ê¤¤¡£";
677 #else
678         q = "Eat which item? ";
679         s = "You have nothing to eat.";
680 #endif
681
682         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
683
684         /* Eat the object */
685         do_cmd_eat_food_aux(item);
686 }
687
688
689 /*
690  * Quaff a potion (from the pack or the floor)
691  */
692 static void do_cmd_quaff_potion_aux(int item)
693 {
694         int         ident, lev;
695         object_type     *o_ptr;
696         object_type forge;
697         object_type *q_ptr;
698
699
700         /* Take a turn */
701         energy_use = 100;
702
703         if (world_player)
704         {
705                 if (flush_failure) flush();
706 #ifdef JP
707                 msg_print("ÉÓ¤«¤é¿å¤¬Î®¤ì½Ð¤Æ¤³¤Ê¤¤¡ª");
708 #else
709                 msg_print("The potion doesn't flow out from a bottle.");
710 #endif
711
712                 sound(SOUND_FAIL);
713                 return;
714         }
715
716         if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
717         {
718                 stop_singing();
719         }
720
721         /* Get the item (in the pack) */
722         if (item >= 0)
723         {
724                 o_ptr = &inventory[item];
725         }
726
727         /* Get the item (on the floor) */
728         else
729         {
730                 o_ptr = &o_list[0 - item];
731         }
732
733         /* Get local object */
734         q_ptr = &forge;
735
736         /* Obtain a local object */
737         object_copy(q_ptr, o_ptr);
738
739         /* Single object */
740         q_ptr->number = 1;
741
742         /* Reduce and describe inventory */
743         if (item >= 0)
744         {
745                 inven_item_increase(item, -1);
746                 inven_item_describe(item);
747                 inven_item_optimize(item);
748         }
749
750         /* Reduce and describe floor item */
751         else
752         {
753                 floor_item_increase(0 - item, -1);
754                 floor_item_describe(0 - item);
755                 floor_item_optimize(0 - item);
756         }
757
758         /* Sound */
759         sound(SOUND_QUAFF);
760
761
762         /* Not identified yet */
763         ident = FALSE;
764
765         /* Object level */
766         lev = get_object_level(q_ptr);
767
768         /* Analyze the potion */
769         if (q_ptr->tval == TV_POTION)
770         {
771                 switch (q_ptr->sval)
772                 {
773 #ifdef JP
774                         /* °û¤ß¤´¤¿¤¨¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
775                 case SV_POTION_WATER:
776                         msg_print("¸ý¤ÎÃ椬¤µ¤Ã¤Ñ¤ê¤·¤¿¡£");
777                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
778                         ident = TRUE;
779                         break;
780
781                 case SV_POTION_APPLE_JUICE:
782                         msg_print("´Å¤¯¤Æ¥µ¥Ã¥Ñ¥ê¤È¤·¤Æ¤¤¤Æ¡¢¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
783                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
784                         ident = TRUE;
785                         break;
786
787                 case SV_POTION_SLIME_MOLD:
788                         msg_print("¤Ê¤ó¤È¤âÉÔµ¤Ì£¤ÊÌ£¤À¡£");
789                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
790                         ident = TRUE;
791                         break;
792
793 #else
794                 case SV_POTION_WATER:
795                 case SV_POTION_APPLE_JUICE:
796                 case SV_POTION_SLIME_MOLD:
797                         msg_print("You feel less thirsty.");
798                         ident = TRUE;
799                         break;
800 #endif
801
802                 case SV_POTION_SLOWNESS:
803                         if (set_slow(randint1(25) + 15, FALSE)) ident = TRUE;
804                         break;
805
806                 case SV_POTION_SALT_WATER:
807 #ifdef JP
808                         msg_print("¤¦¤§¡ª»×¤ï¤ºÅǤ¤¤Æ¤·¤Þ¤Ã¤¿¡£");
809 #else
810                         msg_print("The potion makes you vomit!");
811 #endif
812
813                         (void)set_food(PY_FOOD_STARVE - 1);
814                         (void)set_poisoned(0);
815                         (void)set_paralyzed(p_ptr->paralyzed + 4);
816                         ident = TRUE;
817                         break;
818
819                 case SV_POTION_POISON:
820                         if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
821                         {
822                                 if (set_poisoned(p_ptr->poisoned + randint0(15) + 10))
823                                 {
824                                         ident = TRUE;
825                                 }
826                         }
827                         break;
828
829                 case SV_POTION_BLINDNESS:
830                         if (!p_ptr->resist_blind)
831                         {
832                                 if (set_blind(p_ptr->blind + randint0(100) + 100))
833                                 {
834                                         ident = TRUE;
835                                 }
836                         }
837                         break;
838
839                 case SV_POTION_CONFUSION: /* Booze */
840                         if (p_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
841                         else if (!p_ptr->resist_conf) p_ptr->special_attack |= ATTACK_SUIKEN;
842                         if (!p_ptr->resist_conf)
843                         {
844                                 if (set_confused(randint0(20) + 15))
845                                 {
846                                         ident = TRUE;
847                                 }
848                         }
849
850                         if (!p_ptr->resist_chaos)
851                         {
852                                 if (one_in_(2))
853                                 {
854                                         if (set_image(p_ptr->image + randint0(150) + 150))
855                                         {
856                                                 ident = TRUE;
857                                         }
858                                 }
859                                 if (one_in_(13) && (p_ptr->pclass != CLASS_MONK))
860                                 {
861                                         ident = TRUE;
862                                         if (one_in_(3)) lose_all_info();
863                                         else wiz_dark();
864                                         teleport_player(100);
865                                         wiz_dark();
866 #ifdef JP
867 msg_print("ÃΤé¤Ê¤¤¾ì½ê¤ÇÌܤ¬Àä᤿¡£Æ¬Äˤ¬¤¹¤ë¡£");
868 msg_print("²¿¤â»×¤¤½Ð¤»¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ØÍ褿¤Î¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
869 #else
870                                         msg_print("You wake up somewhere with a sore head...");
871                                         msg_print("You can't remember a thing, or how you got here!");
872 #endif
873
874                                 }
875                         }
876                         break;
877
878                 case SV_POTION_SLEEP:
879                         if (!p_ptr->free_act)
880                         {
881 #ifdef JP
882                 msg_print("¤¢¤Ê¤¿¤Ï̲¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
883 #else
884                 msg_print("You fall asleep.");
885 #endif
886
887
888                                 if (ironman_nightmare)
889                                 {
890 #ifdef JP
891 msg_print("¶²¤í¤·¤¤¸÷·Ê¤¬Æ¬¤ËÉ⤫¤ó¤Ç¤­¤¿¡£");
892 #else
893                                         msg_print("A horrible vision enters your mind.");
894 #endif
895
896
897                                         /* Pick a nightmare */
898                                         get_mon_num_prep(get_nightmare, NULL);
899
900                                         /* Have some nightmares */
901                                         have_nightmare(get_mon_num(MAX_DEPTH));
902
903                                         /* Remove the monster restriction */
904                                         get_mon_num_prep(NULL, NULL);
905                                 }
906                                 if (set_paralyzed(p_ptr->paralyzed + randint0(4) + 4))
907                                 {
908                                         ident = TRUE;
909                                 }
910                         }
911                         break;
912
913                 case SV_POTION_LOSE_MEMORIES:
914                         if (!p_ptr->hold_life && (p_ptr->exp > 0))
915                         {
916 #ifdef JP
917                                 msg_print("²áµî¤Îµ­²±¤¬Çö¤ì¤Æ¤¤¤¯µ¤¤¬¤¹¤ë¡£");
918 #else
919                                 msg_print("You feel your memories fade.");
920 #endif
921                                 chg_virtue(V_KNOWLEDGE, -5);
922
923                                 lose_exp(p_ptr->exp / 4);
924                                 ident = TRUE;
925                         }
926                         break;
927
928                 case SV_POTION_RUINATION:
929 #ifdef JP
930                         msg_print("¿È¤â¿´¤â¼å¤Ã¤Æ¤­¤Æ¡¢Àºµ¤¤¬È´¤±¤Æ¤¤¤¯¤è¤¦¤À¡£");
931                         take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "ÇËÌǤÎÌô", -1);
932 #else
933                         msg_print("Your nerves and muscles feel weak and lifeless!");
934                         take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "a potion of Ruination", -1);
935 #endif
936
937                         (void)dec_stat(A_DEX, 25, TRUE);
938                         (void)dec_stat(A_WIS, 25, TRUE);
939                         (void)dec_stat(A_CON, 25, TRUE);
940                         (void)dec_stat(A_STR, 25, TRUE);
941                         (void)dec_stat(A_CHR, 25, TRUE);
942                         (void)dec_stat(A_INT, 25, TRUE);
943                         ident = TRUE;
944                         break;
945
946                 case SV_POTION_DEC_STR:
947                         if (do_dec_stat(A_STR)) ident = TRUE;
948                         break;
949
950                 case SV_POTION_DEC_INT:
951                         if (do_dec_stat(A_INT)) ident = TRUE;
952                         break;
953
954                 case SV_POTION_DEC_WIS:
955                         if (do_dec_stat(A_WIS)) ident = TRUE;
956                         break;
957
958                 case SV_POTION_DEC_DEX:
959                         if (do_dec_stat(A_DEX)) ident = TRUE;
960                         break;
961
962                 case SV_POTION_DEC_CON:
963                         if (do_dec_stat(A_CON)) ident = TRUE;
964                         break;
965
966                 case SV_POTION_DEC_CHR:
967                         if (do_dec_stat(A_CHR)) ident = TRUE;
968                         break;
969
970                 case SV_POTION_DETONATIONS:
971 #ifdef JP
972                         msg_print("ÂΤÎÃæ¤Ç·ã¤·¤¤Çúȯ¤¬µ¯¤­¤¿¡ª");
973                         take_hit(DAMAGE_NOESCAPE, damroll(50, 20), "Çúȯ¤ÎÌô", -1);
974 #else
975                         msg_print("Massive explosions rupture your body!");
976                         take_hit(DAMAGE_NOESCAPE, damroll(50, 20), "a potion of Detonation", -1);
977 #endif
978
979                         (void)set_stun(p_ptr->stun + 75);
980                         (void)set_cut(p_ptr->cut + 5000);
981                         ident = TRUE;
982                         break;
983
984                 case SV_POTION_DEATH:
985                         chg_virtue(V_VITALITY, -1);
986                         chg_virtue(V_UNLIFE, 5);
987 #ifdef JP
988                         msg_print("»à¤Îͽ´¶¤¬ÂÎÃæ¤ò¶î¤±¤á¤°¤Ã¤¿¡£");
989                         take_hit(DAMAGE_LOSELIFE, 5000, "»à¤ÎÌô", -1);
990 #else
991                         msg_print("A feeling of Death flows through your body.");
992                         take_hit(DAMAGE_LOSELIFE, 5000, "a potion of Death", -1);
993 #endif
994
995                         ident = TRUE;
996                         break;
997
998                 case SV_POTION_INFRAVISION:
999                         if (set_tim_infra(p_ptr->tim_infra + 100 + randint1(100), FALSE))
1000                         {
1001                                 ident = TRUE;
1002                         }
1003                         break;
1004
1005                 case SV_POTION_DETECT_INVIS:
1006                         if (set_tim_invis(p_ptr->tim_invis + 12 + randint1(12), FALSE))
1007                         {
1008                                 ident = TRUE;
1009                         }
1010                         break;
1011
1012                 case SV_POTION_SLOW_POISON:
1013                         if (set_poisoned(p_ptr->poisoned / 2)) ident = TRUE;
1014                         break;
1015
1016                 case SV_POTION_CURE_POISON:
1017                         if (set_poisoned(0)) ident = TRUE;
1018                         break;
1019
1020                 case SV_POTION_BOLDNESS:
1021                         if (set_afraid(0)) ident = TRUE;
1022                         break;
1023
1024                 case SV_POTION_SPEED:
1025                         if (!p_ptr->fast)
1026                         {
1027                                 if (set_fast(randint1(25) + 15, FALSE)) ident = TRUE;
1028                         }
1029                         else
1030                         {
1031                                 (void)set_fast(p_ptr->fast + 5, FALSE);
1032                         }
1033                         break;
1034
1035                 case SV_POTION_RESIST_HEAT:
1036                         if (set_oppose_fire(p_ptr->oppose_fire + randint1(10) + 10, FALSE))
1037                         {
1038                                 ident = TRUE;
1039                         }
1040                         break;
1041
1042                 case SV_POTION_RESIST_COLD:
1043                         if (set_oppose_cold(p_ptr->oppose_cold + randint1(10) + 10, FALSE))
1044                         {
1045                                 ident = TRUE;
1046                         }
1047                         break;
1048
1049                 case SV_POTION_HEROISM:
1050                         if (set_afraid(0)) ident = TRUE;
1051                         if (set_hero(p_ptr->hero + randint1(25) + 25, FALSE)) ident = TRUE;
1052                         if (hp_player(10)) ident = TRUE;
1053                         break;
1054
1055                 case SV_POTION_BESERK_STRENGTH:
1056                         if (set_afraid(0)) ident = TRUE;
1057                         if (set_shero(p_ptr->shero + randint1(25) + 25, FALSE)) ident = TRUE;
1058                         if (hp_player(30)) ident = TRUE;
1059                         break;
1060
1061                 case SV_POTION_CURE_LIGHT:
1062                         if (hp_player(damroll(2, 8))) ident = TRUE;
1063                         if (set_blind(0)) ident = TRUE;
1064                         if (set_cut(p_ptr->cut - 10)) ident = TRUE;
1065                         if (set_shero(0,TRUE)) ident = TRUE;
1066                         break;
1067
1068                 case SV_POTION_CURE_SERIOUS:
1069                         if (hp_player(damroll(4, 8))) ident = TRUE;
1070                         if (set_blind(0)) ident = TRUE;
1071                         if (set_confused(0)) ident = TRUE;
1072                         if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
1073                         if (set_shero(0,TRUE)) ident = TRUE;
1074                         break;
1075
1076                 case SV_POTION_CURE_CRITICAL:
1077                         if (hp_player(damroll(6, 8))) ident = TRUE;
1078                         if (set_blind(0)) ident = TRUE;
1079                         if (set_confused(0)) ident = TRUE;
1080                         if (set_poisoned(0)) ident = TRUE;
1081                         if (set_stun(0)) ident = TRUE;
1082                         if (set_cut(0)) ident = TRUE;
1083                         if (set_shero(0,TRUE)) ident = TRUE;
1084                         break;
1085
1086                 case SV_POTION_HEALING:
1087                         if (hp_player(300)) ident = TRUE;
1088                         if (set_blind(0)) ident = TRUE;
1089                         if (set_confused(0)) ident = TRUE;
1090                         if (set_poisoned(0)) ident = TRUE;
1091                         if (set_stun(0)) ident = TRUE;
1092                         if (set_cut(0)) ident = TRUE;
1093                         if (set_shero(0,TRUE)) ident = TRUE;
1094                         break;
1095
1096                 case SV_POTION_STAR_HEALING:
1097                         if (hp_player(1200)) ident = TRUE;
1098                         if (set_blind(0)) ident = TRUE;
1099                         if (set_confused(0)) ident = TRUE;
1100                         if (set_poisoned(0)) ident = TRUE;
1101                         if (set_stun(0)) ident = TRUE;
1102                         if (set_cut(0)) ident = TRUE;
1103                         if (set_shero(0,TRUE)) ident = TRUE;
1104                         break;
1105
1106                 case SV_POTION_LIFE:
1107                         chg_virtue(V_VITALITY, 1);
1108                         chg_virtue(V_UNLIFE, -5);
1109 #ifdef JP
1110                         msg_print("ÂÎÃæ¤ËÀ¸Ì¿ÎϤ¬Ëþ¤Á¤¢¤Õ¤ì¤Æ¤­¤¿¡ª");
1111 #else
1112                         msg_print("You feel life flow through your body!");
1113 #endif
1114
1115                         restore_level();
1116                         (void)set_poisoned(0);
1117                         (void)set_blind(0);
1118                         (void)set_confused(0);
1119                         (void)set_image(0);
1120                         (void)set_stun(0);
1121                         (void)set_cut(0);
1122                         (void)do_res_stat(A_STR);
1123                         (void)do_res_stat(A_CON);
1124                         (void)do_res_stat(A_DEX);
1125                         (void)do_res_stat(A_WIS);
1126                         (void)do_res_stat(A_INT);
1127                         (void)do_res_stat(A_CHR);
1128                         (void)set_shero(0,TRUE);
1129                         update_stuff();
1130                         hp_player(5000);
1131                         ident = TRUE;
1132                         break;
1133
1134                 case SV_POTION_RESTORE_MANA:
1135                         if (p_ptr->pclass == CLASS_MAGIC_EATER)
1136                         {
1137                                 int i;
1138                                 for (i = 0; i < EATER_EXT*2; i++)
1139                                 {
1140                                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
1141                                         if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
1142                                 }
1143                                 for (; i < EATER_EXT*3; i++)
1144                                 {
1145                                         int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
1146                                         p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE*3 : p_ptr->magic_num2[i]*EATER_ROD_CHARGE/3)*k_info[k_idx].pval;
1147                                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
1148                                 }
1149 #ifdef JP
1150                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
1151 #else
1152                                 msg_print("Your feel your head clear.");
1153 #endif
1154                                 p_ptr->window |= (PW_PLAYER);
1155                                 ident = TRUE;
1156                         }
1157                         else if (p_ptr->csp < p_ptr->msp)
1158                         {
1159                                 p_ptr->csp = p_ptr->msp;
1160                                 p_ptr->csp_frac = 0;
1161 #ifdef JP
1162                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
1163 #else
1164                                 msg_print("Your feel your head clear.");
1165 #endif
1166
1167                                 p_ptr->redraw |= (PR_MANA);
1168                                 p_ptr->window |= (PW_PLAYER);
1169                                 p_ptr->window |= (PW_SPELL);
1170                                 ident = TRUE;
1171                         }
1172                         if (set_shero(0,TRUE)) ident = TRUE;
1173                         break;
1174
1175                 case SV_POTION_RESTORE_EXP:
1176                         if (restore_level()) ident = TRUE;
1177                         break;
1178
1179                 case SV_POTION_RES_STR:
1180                         if (do_res_stat(A_STR)) ident = TRUE;
1181                         break;
1182
1183                 case SV_POTION_RES_INT:
1184                         if (do_res_stat(A_INT)) ident = TRUE;
1185                         break;
1186
1187                 case SV_POTION_RES_WIS:
1188                         if (do_res_stat(A_WIS)) ident = TRUE;
1189                         break;
1190
1191                 case SV_POTION_RES_DEX:
1192                         if (do_res_stat(A_DEX)) ident = TRUE;
1193                         break;
1194
1195                 case SV_POTION_RES_CON:
1196                         if (do_res_stat(A_CON)) ident = TRUE;
1197                         break;
1198
1199                 case SV_POTION_RES_CHR:
1200                         if (do_res_stat(A_CHR)) ident = TRUE;
1201                         break;
1202
1203                 case SV_POTION_INC_STR:
1204                         if (do_inc_stat(A_STR)) ident = TRUE;
1205                         break;
1206
1207                 case SV_POTION_INC_INT:
1208                         if (do_inc_stat(A_INT)) ident = TRUE;
1209                         break;
1210
1211                 case SV_POTION_INC_WIS:
1212                         if (do_inc_stat(A_WIS)) ident = TRUE;
1213                         break;
1214
1215                 case SV_POTION_INC_DEX:
1216                         if (do_inc_stat(A_DEX)) ident = TRUE;
1217                         break;
1218
1219                 case SV_POTION_INC_CON:
1220                         if (do_inc_stat(A_CON)) ident = TRUE;
1221                         break;
1222
1223                 case SV_POTION_INC_CHR:
1224                         if (do_inc_stat(A_CHR)) ident = TRUE;
1225                         break;
1226
1227                 case SV_POTION_AUGMENTATION:
1228                         if (do_inc_stat(A_STR)) ident = TRUE;
1229                         if (do_inc_stat(A_INT)) ident = TRUE;
1230                         if (do_inc_stat(A_WIS)) ident = TRUE;
1231                         if (do_inc_stat(A_DEX)) ident = TRUE;
1232                         if (do_inc_stat(A_CON)) ident = TRUE;
1233                         if (do_inc_stat(A_CHR)) ident = TRUE;
1234                         break;
1235
1236                 case SV_POTION_ENLIGHTENMENT:
1237 #ifdef JP
1238                         msg_print("¼«Ê¬¤ÎÃÖ¤«¤ì¤Æ¤¤¤ë¾õ¶·¤¬Ç¾Î¢¤ËÉ⤫¤ó¤Ç¤­¤¿...");
1239 #else
1240                         msg_print("An image of your surroundings forms in your mind...");
1241 #endif
1242
1243                         chg_virtue(V_KNOWLEDGE, 1);
1244                         chg_virtue(V_ENLIGHTEN, 1);
1245                         wiz_lite(FALSE, FALSE);
1246                         ident = TRUE;
1247                         break;
1248
1249                 case SV_POTION_STAR_ENLIGHTENMENT:
1250 #ifdef JP
1251                         msg_print("¹¹¤Ê¤ë·¼Ìؤò´¶¤¸¤¿...");
1252 #else
1253                         msg_print("You begin to feel more enlightened...");
1254 #endif
1255
1256                         chg_virtue(V_KNOWLEDGE, 1);
1257                         chg_virtue(V_ENLIGHTEN, 2);
1258                         msg_print(NULL);
1259                         wiz_lite(TRUE, FALSE);
1260                         (void)do_inc_stat(A_INT);
1261                         (void)do_inc_stat(A_WIS);
1262                         (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
1263                         (void)detect_doors(DETECT_RAD_DEFAULT);
1264                         (void)detect_stairs(DETECT_RAD_DEFAULT);
1265                         (void)detect_treasure(DETECT_RAD_DEFAULT);
1266                         (void)detect_objects_gold(DETECT_RAD_DEFAULT);
1267                         (void)detect_objects_normal(DETECT_RAD_DEFAULT);
1268                         identify_pack();
1269                         self_knowledge();
1270                         ident = TRUE;
1271                         break;
1272
1273                 case SV_POTION_SELF_KNOWLEDGE:
1274 #ifdef JP
1275                         msg_print("¼«Ê¬¼«¿È¤Î¤³¤È¤¬¾¯¤·¤Ïʬ¤«¤Ã¤¿µ¤¤¬¤¹¤ë...");
1276 #else
1277                         msg_print("You begin to know yourself a little better...");
1278 #endif
1279
1280                         msg_print(NULL);
1281                         self_knowledge();
1282                         ident = TRUE;
1283                         break;
1284
1285                 case SV_POTION_EXPERIENCE:
1286                         if (p_ptr->prace == RACE_ANDROID) break;
1287                         chg_virtue(V_ENLIGHTEN, 1);
1288                         if (p_ptr->exp < PY_MAX_EXP)
1289                         {
1290                                 s32b ee = (p_ptr->exp / 2) + 10;
1291                                 if (ee > 100000L) ee = 100000L;
1292 #ifdef JP
1293                                 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1294 #else
1295                                 msg_print("You feel more experienced.");
1296 #endif
1297
1298                                 gain_exp(ee);
1299                                 ident = TRUE;
1300                         }
1301                         break;
1302
1303                 case SV_POTION_RESISTANCE:
1304                         (void)set_oppose_acid(p_ptr->oppose_acid + randint1(20) + 20, FALSE);
1305                         (void)set_oppose_elec(p_ptr->oppose_elec + randint1(20) + 20, FALSE);
1306                         (void)set_oppose_fire(p_ptr->oppose_fire + randint1(20) + 20, FALSE);
1307                         (void)set_oppose_cold(p_ptr->oppose_cold + randint1(20) + 20, FALSE);
1308                         (void)set_oppose_pois(p_ptr->oppose_pois + randint1(20) + 20, FALSE);
1309                         ident = TRUE;
1310                         break;
1311
1312                 case SV_POTION_CURING:
1313                         if (hp_player(50)) ident = TRUE;
1314                         if (set_blind(0)) ident = TRUE;
1315                         if (set_poisoned(0)) ident = TRUE;
1316                         if (set_confused(0)) ident = TRUE;
1317                         if (set_stun(0)) ident = TRUE;
1318                         if (set_cut(0)) ident = TRUE;
1319                         if (set_image(0)) ident = TRUE;
1320                         break;
1321
1322                 case SV_POTION_INVULNERABILITY:
1323                         (void)set_invuln(p_ptr->invuln + randint1(4) + 4, FALSE);
1324                         ident = TRUE;
1325                         break;
1326
1327                 case SV_POTION_NEW_LIFE:
1328                         do_cmd_rerate(FALSE);
1329                         get_max_stats();
1330                         p_ptr->update |= PU_BONUS;
1331                         if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
1332                         {
1333                                 chg_virtue(V_CHANCE, -5);
1334 #ifdef JP
1335 msg_print("Á´¤Æ¤ÎÆÍÁ³ÊÑ°Û¤¬¼£¤Ã¤¿¡£");
1336 #else
1337                                 msg_print("You are cured of all mutations.");
1338 #endif
1339
1340                                 p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
1341                                 p_ptr->update |= PU_BONUS;
1342                                 handle_stuff();
1343                                 mutant_regenerate_mod = calc_mutant_regenerate_mod();
1344                         }
1345                         ident = TRUE;
1346                         break;
1347
1348                 case SV_POTION_NEO_TSUYOSHI:
1349                         (void)set_image(0);
1350                         (void)set_tsuyoshi(p_ptr->tsuyoshi + randint1(100) + 100, FALSE);
1351                         ident = TRUE;
1352                         break;
1353
1354                 case SV_POTION_TSUYOSHI:
1355 #ifdef JP
1356 msg_print("¡Ö¥ª¥¯¥ì·»¤µ¤ó¡ª¡×");
1357 #else
1358                         msg_print("Brother OKURE!");
1359 #endif
1360                         msg_print(NULL);
1361                         p_ptr->tsuyoshi = 1;
1362                         (void)set_tsuyoshi(0, TRUE);
1363                         if (!p_ptr->resist_chaos)
1364                         {
1365                                 (void)set_image(50 + randint1(50));
1366                         }
1367                         ident = TRUE;
1368                         break;
1369                 
1370                 case SV_POTION_POLYMORPH:
1371                         if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && one_in_(23))
1372                         {
1373                                 chg_virtue(V_CHANCE, -5);
1374 #ifdef JP
1375 msg_print("Á´¤Æ¤ÎÆÍÁ³ÊÑ°Û¤¬¼£¤Ã¤¿¡£");
1376 #else
1377                                 msg_print("You are cured of all mutations.");
1378 #endif
1379
1380                                 p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
1381                                 p_ptr->update |= PU_BONUS;
1382                                 handle_stuff();
1383                         }
1384                         else
1385                         {
1386                                 do
1387                                 {
1388                                         if (one_in_(2))
1389                                         {
1390                                                 if(gain_random_mutation(0)) ident = TRUE;
1391                                         }
1392                                         else if (lose_mutation(0)) ident = TRUE;
1393                                 } while(!ident || one_in_(2));
1394                         }
1395                         break;
1396                 }
1397         }
1398
1399         if (p_ptr->prace == RACE_SKELETON)
1400         {
1401 #ifdef JP
1402 msg_print("±ÕÂΤΰìÉô¤Ï¤¢¤Ê¤¿¤Î¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
1403 #else
1404                 msg_print("Some of the fluid falls through your jaws!");
1405 #endif
1406
1407                 (void)potion_smash_effect(0, py, px, q_ptr->k_idx);
1408         }
1409
1410         /* Combine / Reorder the pack (later) */
1411         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1412
1413         if (!(object_aware_p(o_ptr)))
1414         {
1415                 chg_virtue(V_PATIENCE, -1);
1416                 chg_virtue(V_CHANCE, 1);
1417                 chg_virtue(V_KNOWLEDGE, -1);
1418         }
1419
1420         /* The item has been tried */
1421         object_tried(q_ptr);
1422
1423         /* An identification was made */
1424         if (ident && !object_aware_p(q_ptr))
1425         {
1426                 object_aware(q_ptr);
1427                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
1428         }
1429
1430         /* Window stuff */
1431         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1432
1433         /* Potions can feed the player */
1434         switch (p_ptr->mimic_form)
1435         {
1436         case MIMIC_NONE:
1437                 switch (p_ptr->prace)
1438                 {
1439                         case RACE_VAMPIRE:
1440                                 (void)set_food(p_ptr->food + (o_ptr->pval / 10));
1441                                 break;
1442                         case RACE_SKELETON:
1443                                 /* Do nothing */
1444                                 break;
1445                         case RACE_GOLEM:
1446                         case RACE_ZOMBIE:
1447                         case RACE_DEMON:
1448                         case RACE_SPECTRE:
1449                                 set_food(p_ptr->food + ((o_ptr->pval) / 20));
1450                                 break;
1451                         case RACE_ANDROID:
1452                                 if (o_ptr->tval == TV_FLASK)
1453                                 {
1454 #ifdef JP
1455                                         msg_print("¥ª¥¤¥ë¤òÊäµë¤·¤¿¡£");
1456 #else
1457                                         msg_print("You replenish yourself with the oil.");
1458 #endif
1459                                         set_food(p_ptr->food + 5000);
1460                                 }
1461                                 else
1462                                 {
1463                                         set_food(p_ptr->food + ((o_ptr->pval) / 20));
1464                                 }
1465                                 break;
1466                         case RACE_ENT:
1467 #ifdef JP
1468                                 msg_print("¿åʬ¤ò¼è¤ê¹þ¤ó¤À¡£");
1469 #else
1470                                 msg_print("You are moistened.");
1471 #endif
1472                                 set_food(MIN(p_ptr->food + o_ptr->pval + 1000, PY_FOOD_MAX - 1));
1473                                 break;
1474                         default:
1475                                 (void)set_food(p_ptr->food + o_ptr->pval);
1476                                 break;
1477                 }
1478                 break;
1479         case MIMIC_DEMON:
1480         case MIMIC_DEMON_LORD:
1481                 set_food(p_ptr->food + ((o_ptr->pval) / 20));
1482                 break;
1483         case MIMIC_VAMPIRE:
1484                 (void)set_food(p_ptr->food + (o_ptr->pval / 10));
1485                 break;
1486         default:
1487                 (void)set_food(p_ptr->food + o_ptr->pval);
1488                 break;
1489         }
1490 }
1491
1492
1493 /*
1494  * Hook to determine if an object can be quaffed
1495  */
1496 static bool item_tester_hook_quaff(object_type *o_ptr)
1497 {
1498         if (o_ptr->tval == TV_POTION) return TRUE;
1499
1500         if (p_ptr->prace == RACE_ANDROID)
1501         {
1502                 if (o_ptr->tval == TV_FLASK && o_ptr->sval == SV_FLASK_OIL)
1503                         return TRUE;
1504         }
1505
1506         return FALSE;
1507 }
1508
1509
1510 /*
1511  * Quaff some potion (from the pack or floor)
1512  */
1513 void do_cmd_quaff_potion(void)
1514 {
1515         int  item;
1516         cptr q, s;
1517
1518         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1519         {
1520                 set_action(ACTION_NONE);
1521         }
1522
1523         /* Restrict choices to potions */
1524         item_tester_hook = item_tester_hook_quaff;
1525
1526         /* Get an item */
1527 #ifdef JP
1528         q = "¤É¤ÎÌô¤ò°û¤ß¤Þ¤¹¤«? ";
1529         s = "°û¤á¤ëÌô¤¬¤Ê¤¤¡£";
1530 #else
1531         q = "Quaff which potion? ";
1532         s = "You have no potions to quaff.";
1533 #endif
1534
1535         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1536
1537         /* Quaff the potion */
1538         do_cmd_quaff_potion_aux(item);
1539 }
1540
1541
1542 /*
1543  * Read a scroll (from the pack or floor).
1544  *
1545  * Certain scrolls can be "aborted" without losing the scroll.  These
1546  * include scrolls with no effects but recharge or identify, which are
1547  * cancelled before use.  XXX Reading them still takes a turn, though.
1548  */
1549 static void do_cmd_read_scroll_aux(int item, bool known)
1550 {
1551         int         k, used_up, ident, lev;
1552         object_type *o_ptr;
1553         char        Rumor[1024];
1554
1555
1556         /* Get the item (in the pack) */
1557         if (item >= 0)
1558         {
1559                 o_ptr = &inventory[item];
1560         }
1561
1562         /* Get the item (on the floor) */
1563         else
1564         {
1565                 o_ptr = &o_list[0 - item];
1566         }
1567
1568
1569         /* Take a turn */
1570         energy_use = 100;
1571
1572         if (world_player)
1573         {
1574                 if (flush_failure) flush();
1575 #ifdef JP
1576                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
1577 #else
1578                 msg_print("Nothing happen.");
1579 #endif
1580
1581                 sound(SOUND_FAIL);
1582                 return;
1583         }
1584
1585         if (p_ptr->pclass == CLASS_BERSERKER)
1586         {
1587 #ifdef JP
1588                 msg_print("´¬Êª¤Ê¤ó¤ÆÆɤá¤Ê¤¤¡£");
1589 #else
1590                 msg_print("You cannot read.");
1591 #endif
1592                 return;
1593         }
1594
1595         if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
1596         {
1597                 stop_singing();
1598         }
1599
1600         /* Not identified yet */
1601         ident = FALSE;
1602
1603         /* Object level */
1604         lev = get_object_level(o_ptr);
1605
1606         /* Assume the scroll will get used up */
1607         used_up = TRUE;
1608
1609         if (o_ptr->tval == TV_SCROLL)
1610         {
1611         /* Analyze the scroll */
1612         switch (o_ptr->sval)
1613         {
1614                 case SV_SCROLL_DARKNESS:
1615                 {
1616                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
1617                         {
1618                                 (void)set_blind(p_ptr->blind + 3 + randint1(5));
1619                         }
1620                         if (unlite_area(10, 3)) ident = TRUE;
1621                         break;
1622                 }
1623
1624                 case SV_SCROLL_AGGRAVATE_MONSTER:
1625                 {
1626 #ifdef JP
1627                         msg_print("¥«¥ó¹â¤¯¤¦¤Ê¤ëÍͤʲ»¤¬ÊÕ¤ê¤òʤ¤Ã¤¿¡£");
1628 #else
1629                         msg_print("There is a high pitched humming noise.");
1630 #endif
1631
1632                         aggravate_monsters(0);
1633                         ident = TRUE;
1634                         break;
1635                 }
1636
1637                 case SV_SCROLL_CURSE_ARMOR:
1638                 {
1639                         if (curse_armor()) ident = TRUE;
1640                         break;
1641                 }
1642
1643                 case SV_SCROLL_CURSE_WEAPON:
1644                 {
1645                         if (curse_weapon(FALSE, INVEN_RARM)) ident = TRUE;
1646                         break;
1647                 }
1648
1649                 case SV_SCROLL_SUMMON_MONSTER:
1650                 {
1651                         for (k = 0; k < randint1(3); k++)
1652                         {
1653                                 if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
1654                                 {
1655                                         ident = TRUE;
1656                                 }
1657                         }
1658                         break;
1659                 }
1660
1661                 case SV_SCROLL_SUMMON_UNDEAD:
1662                 {
1663                         for (k = 0; k < randint1(3); k++)
1664                         {
1665                                 if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
1666                                 {
1667                                         ident = TRUE;
1668                                 }
1669                         }
1670                         break;
1671                 }
1672
1673                 case SV_SCROLL_SUMMON_PET:
1674                 {
1675                         if (summon_specific(-1, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
1676                         {
1677                                 ident = TRUE;
1678                         }
1679                         break;
1680                 }
1681
1682                 case SV_SCROLL_SUMMON_KIN:
1683                 {
1684                         if (summon_kin_player(p_ptr->lev, py, px, (PM_FORCE_PET | PM_ALLOW_GROUP)))
1685                         {
1686                                 ident = TRUE;
1687                         }
1688                         break;
1689                 }
1690
1691                 case SV_SCROLL_TRAP_CREATION:
1692                 {
1693                         if (trap_creation(py, px)) ident = TRUE;
1694                         break;
1695                 }
1696
1697                 case SV_SCROLL_PHASE_DOOR:
1698                 {
1699                         teleport_player(10);
1700                         ident = TRUE;
1701                         break;
1702                 }
1703
1704                 case SV_SCROLL_TELEPORT:
1705                 {
1706                         teleport_player(100);
1707                         ident = TRUE;
1708                         break;
1709                 }
1710
1711                 case SV_SCROLL_TELEPORT_LEVEL:
1712                 {
1713                         (void)teleport_player_level();
1714                         ident = TRUE;
1715                         break;
1716                 }
1717
1718                 case SV_SCROLL_WORD_OF_RECALL:
1719                 {
1720                         if (!word_of_recall()) used_up = FALSE;
1721                         ident = TRUE;
1722                         break;
1723                 }
1724
1725                 case SV_SCROLL_IDENTIFY:
1726                 {
1727                         if (!ident_spell(FALSE)) used_up = FALSE;
1728                         ident = TRUE;
1729                         break;
1730                 }
1731
1732                 case SV_SCROLL_STAR_IDENTIFY:
1733                 {
1734                         if (!identify_fully(FALSE)) used_up = FALSE;
1735                         ident = TRUE;
1736                         break;
1737                 }
1738
1739                 case SV_SCROLL_REMOVE_CURSE:
1740                 {
1741                         if (remove_curse())
1742                         {
1743 #ifdef JP
1744                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1745 #else
1746                                 msg_print("You feel as if someone is watching over you.");
1747 #endif
1748
1749                                 ident = TRUE;
1750                         }
1751                         break;
1752                 }
1753
1754                 case SV_SCROLL_STAR_REMOVE_CURSE:
1755                 {
1756                         if (remove_all_curse())
1757                         {
1758 #ifdef JP
1759                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1760 #else
1761                                 msg_print("You feel as if someone is watching over you.");
1762 #endif
1763                         }
1764                         ident = TRUE;
1765                         break;
1766                 }
1767
1768                 case SV_SCROLL_ENCHANT_ARMOR:
1769                 {
1770                         ident = TRUE;
1771                         if (!enchant_spell(0, 0, 1)) used_up = FALSE;
1772                         break;
1773                 }
1774
1775                 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
1776                 {
1777                         if (!enchant_spell(1, 0, 0)) used_up = FALSE;
1778                         ident = TRUE;
1779                         break;
1780                 }
1781
1782                 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
1783                 {
1784                         if (!enchant_spell(0, 1, 0)) used_up = FALSE;
1785                         ident = TRUE;
1786                         break;
1787                 }
1788
1789                 case SV_SCROLL_STAR_ENCHANT_ARMOR:
1790                 {
1791                         if (!enchant_spell(0, 0, randint1(3) + 2)) used_up = FALSE;
1792                         ident = TRUE;
1793                         break;
1794                 }
1795
1796                 case SV_SCROLL_STAR_ENCHANT_WEAPON:
1797                 {
1798                         if (!enchant_spell(randint1(3), randint1(3), 0)) used_up = FALSE;
1799                         ident = TRUE;
1800                         break;
1801                 }
1802
1803                 case SV_SCROLL_RECHARGING:
1804                 {
1805                         if (!recharge(130)) used_up = FALSE;
1806                         ident = TRUE;
1807                         break;
1808                 }
1809
1810                 case SV_SCROLL_MUNDANITY:
1811                 {
1812                         ident = TRUE;
1813                         if (!mundane_spell(FALSE)) used_up = FALSE;
1814                         break;
1815                 }
1816
1817                 case SV_SCROLL_LIGHT:
1818                 {
1819                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
1820                         break;
1821                 }
1822
1823                 case SV_SCROLL_MAPPING:
1824                 {
1825                         map_area(DETECT_RAD_MAP);
1826                         ident = TRUE;
1827                         break;
1828                 }
1829
1830                 case SV_SCROLL_DETECT_GOLD:
1831                 {
1832                         if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
1833                         if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
1834                         break;
1835                 }
1836
1837                 case SV_SCROLL_DETECT_ITEM:
1838                 {
1839                         if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
1840                         break;
1841                 }
1842
1843                 case SV_SCROLL_DETECT_TRAP:
1844                 {
1845                         if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
1846                         break;
1847                 }
1848
1849                 case SV_SCROLL_DETECT_DOOR:
1850                 {
1851                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
1852                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
1853                         break;
1854                 }
1855
1856                 case SV_SCROLL_DETECT_INVIS:
1857                 {
1858                         if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
1859                         break;
1860                 }
1861
1862                 case SV_SCROLL_SATISFY_HUNGER:
1863                 {
1864                         if (set_food(PY_FOOD_MAX - 1)) ident = TRUE;
1865                         break;
1866                 }
1867
1868                 case SV_SCROLL_BLESSING:
1869                 {
1870                         if (set_blessed(p_ptr->blessed + randint1(12) + 6, FALSE)) ident = TRUE;
1871                         break;
1872                 }
1873
1874                 case SV_SCROLL_HOLY_CHANT:
1875                 {
1876                         if (set_blessed(p_ptr->blessed + randint1(24) + 12, FALSE)) ident = TRUE;
1877                         break;
1878                 }
1879
1880                 case SV_SCROLL_HOLY_PRAYER:
1881                 {
1882                         if (set_blessed(p_ptr->blessed + randint1(48) + 24, FALSE)) ident = TRUE;
1883                         break;
1884                 }
1885
1886                 case SV_SCROLL_MONSTER_CONFUSION:
1887                 {
1888                         if (!(p_ptr->special_attack & ATTACK_CONFUSE))
1889                         {
1890 #ifdef JP
1891                                 msg_print("¼ê¤¬µ±¤­»Ï¤á¤¿¡£");
1892 #else
1893                                 msg_print("Your hands begin to glow.");
1894 #endif
1895
1896                                 p_ptr->special_attack |= ATTACK_CONFUSE;
1897                                 p_ptr->redraw |= (PR_STATUS);
1898                                 ident = TRUE;
1899                         }
1900                         break;
1901                 }
1902
1903                 case SV_SCROLL_PROTECTION_FROM_EVIL:
1904                 {
1905                         k = 3 * p_ptr->lev;
1906                         if (set_protevil(p_ptr->protevil + randint1(25) + k, FALSE)) ident = TRUE;
1907                         break;
1908                 }
1909
1910                 case SV_SCROLL_RUNE_OF_PROTECTION:
1911                 {
1912                         warding_glyph();
1913                         ident = TRUE;
1914                         break;
1915                 }
1916
1917                 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
1918                 {
1919                         if (destroy_doors_touch()) ident = TRUE;
1920                         break;
1921                 }
1922
1923                 case SV_SCROLL_STAR_DESTRUCTION:
1924                 {
1925                         if (destroy_area(py, px, 13+randint0(5), TRUE))
1926                                 ident = TRUE;
1927                         else
1928 #ifdef JP
1929 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿...");
1930 #else
1931                                 msg_print("The dungeon trembles...");
1932 #endif
1933
1934
1935                         break;
1936                 }
1937
1938                 case SV_SCROLL_DISPEL_UNDEAD:
1939                 {
1940                         if (dispel_undead(80)) ident = TRUE;
1941                         break;
1942                 }
1943
1944                 case SV_SCROLL_SPELL:
1945                 {
1946                         if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_IMITATOR) || (p_ptr->pclass == CLASS_MINDCRAFTER) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_MAGIC_EATER) || (p_ptr->pclass == CLASS_RED_MAGE) || (p_ptr->pclass == CLASS_SAMURAI) || (p_ptr->pclass == CLASS_BLUE_MAGE) || (p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BERSERKER) || (p_ptr->pclass == CLASS_SMITH) || (p_ptr->pclass == CLASS_MIRROR_MASTER) || (p_ptr->pclass == CLASS_NINJA)) break;
1947                         p_ptr->add_spells++;
1948                         p_ptr->update |= (PU_SPELLS);
1949                         ident = TRUE;
1950                         break;
1951                 }
1952
1953                 case SV_SCROLL_GENOCIDE:
1954                 {
1955                         (void)symbol_genocide(300, TRUE);
1956                         ident = TRUE;
1957                         break;
1958                 }
1959
1960                 case SV_SCROLL_MASS_GENOCIDE:
1961                 {
1962                         (void)mass_genocide(300, TRUE);
1963                         ident = TRUE;
1964                         break;
1965                 }
1966
1967                 case SV_SCROLL_ACQUIREMENT:
1968                 {
1969                         acquirement(py, px, 1, TRUE, FALSE);
1970                         ident = TRUE;
1971                         break;
1972                 }
1973
1974                 case SV_SCROLL_STAR_ACQUIREMENT:
1975                 {
1976                         acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
1977                         ident = TRUE;
1978                         break;
1979                 }
1980
1981                 /* New Hengband scrolls */
1982                 case SV_SCROLL_FIRE:
1983                 {
1984                         fire_ball(GF_FIRE, 0, 666, 4);
1985                         /* Note: "Double" damage since it is centered on the player ... */
1986                         if (!(p_ptr->oppose_fire || p_ptr->resist_fire || p_ptr->immune_fire))
1987 #ifdef JP
1988 take_hit(DAMAGE_NOESCAPE, 50+randint1(50), "±ê¤Î´¬Êª", -1);
1989 #else
1990                                 take_hit(DAMAGE_NOESCAPE, 50 + randint1(50), "a Scroll of Fire", -1);
1991 #endif
1992
1993                         ident = TRUE;
1994                         break;
1995                 }
1996
1997
1998                 case SV_SCROLL_ICE:
1999                 {
2000                         fire_ball(GF_ICE, 0, 777, 4);
2001                         if (!(p_ptr->oppose_cold || p_ptr->resist_cold || p_ptr->immune_cold))
2002 #ifdef JP
2003 take_hit(DAMAGE_NOESCAPE, 100+randint1(100), "ɹ¤Î´¬Êª", -1);
2004 #else
2005                                 take_hit(DAMAGE_NOESCAPE, 100 + randint1(100), "a Scroll of Ice", -1);
2006 #endif
2007
2008                         ident = TRUE;
2009                         break;
2010                 }
2011
2012                 case SV_SCROLL_CHAOS:
2013                 {
2014                         fire_ball(GF_CHAOS, 0, 1000, 4);
2015                         if (!p_ptr->resist_chaos)
2016 #ifdef JP
2017 take_hit(DAMAGE_NOESCAPE, 111+randint1(111), "¥í¥°¥ë¥¹¤Î´¬Êª", -1);
2018 #else
2019                                 take_hit(DAMAGE_NOESCAPE, 111 + randint1(111), "a Scroll of Logrus", -1);
2020 #endif
2021
2022                         ident = TRUE;
2023                         break;
2024                 }
2025
2026                 case SV_SCROLL_RUMOR:
2027                 {
2028                         errr err = 0;
2029
2030                         switch (randint1(20))
2031                         {
2032                                 case 1:
2033 #ifdef JP
2034 err = get_rnd_line("chainswd_j.txt", 0, Rumor);
2035 #else
2036                                         err = get_rnd_line("chainswd.txt", 0, Rumor);
2037 #endif
2038
2039                                         break;
2040                                 case 2:
2041 #ifdef JP
2042 err = get_rnd_line("error_j.txt", 0, Rumor);
2043 #else
2044                                         err = get_rnd_line("error.txt", 0, Rumor);
2045 #endif
2046
2047                                         break;
2048                                 case 3:
2049                                 case 4:
2050                                 case 5:
2051 #ifdef JP
2052 err = get_rnd_line("death_j.txt", 0, Rumor);
2053 #else
2054                                         err = get_rnd_line("death.txt", 0, Rumor);
2055 #endif
2056
2057                                         break;
2058                                 default:
2059 #ifdef JP
2060 err = get_rnd_line_jonly("rumors_j.txt", 0, Rumor, 10);
2061 #else
2062                                         err = get_rnd_line("rumors.txt", 0, Rumor);
2063 #endif
2064
2065                                         break;
2066                         }
2067
2068                         /* An error occured */
2069 #ifdef JP
2070 if (err) strcpy(Rumor, "±³¤Î±½¤â¤¢¤ë¡£");
2071 #else
2072                         if (err) strcpy(Rumor, "Some rumors are wrong.");
2073 #endif
2074
2075
2076 #ifdef JP
2077 msg_print("´¬Êª¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¤¬½ñ¤«¤ì¤Æ¤¤¤ë:");
2078 #else
2079                         msg_print("There is message on the scroll. It says:");
2080 #endif
2081
2082                         msg_print(NULL);
2083                         msg_format("%s", Rumor);
2084                         msg_print(NULL);
2085 #ifdef JP
2086 msg_print("´¬Êª¤Ï±ì¤òΩ¤Æ¤Æ¾Ã¤¨µî¤Ã¤¿¡ª");
2087 #else
2088                         msg_print("The scroll disappears in a puff of smoke!");
2089 #endif
2090
2091                         ident = TRUE;
2092                         break;
2093                 }
2094
2095                 case SV_SCROLL_ARTIFACT:
2096                 {
2097                         ident = TRUE;
2098                         if (!artifact_scroll()) used_up = FALSE;
2099                         break;
2100                 }
2101
2102                 case SV_SCROLL_RESET_RECALL:
2103                 {
2104                         ident = TRUE;
2105                         if (!reset_recall()) used_up = FALSE;
2106                         break;
2107                 }
2108         }
2109         }
2110         else if (o_ptr->name1 == ART_GHB)
2111         {
2112 #ifdef JP
2113                 msg_print("»ä¤Ï¶ìÏ«¤·¤Æ¡Ø¥°¥ì¡¼¥¿¡¼¡¦¥Ø¥ë=¥Ó¡¼¥¹¥È¡Ù¤òÅݤ·¤¿¡£");
2114                 msg_print("¤·¤«¤·¼ê¤ËÆþ¤Ã¤¿¤Î¤Ï¤³¤Î¤­¤¿¤Ê¤¤£Ô¥·¥ã¥Ä¤À¤±¤À¤Ã¤¿¡£");
2115 #else
2116                 msg_print("I had a very hard time to kill the Greater hell-beast, ");
2117                 msg_print("but all I got was this lousy t-shirt!");
2118 #endif
2119                 used_up = FALSE;
2120         }
2121         else if (o_ptr->name1 == ART_POWER)
2122         {
2123 #ifdef JP
2124                 msg_print("¡Ö°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÅý¤Ù¡¢");
2125                 msg_print(NULL);
2126                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤ò¸«¤Ä¤±¡¢");
2127                 msg_print(NULL);
2128                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÊá¤é¤¨¤Æ");
2129                 msg_print(NULL);
2130                 msg_print("°Å°Ç¤ÎÃæ¤Ë·Ò¤®¤È¤á¤ë¡£¡×");
2131 #else
2132                 msg_print("'One Ring to rule them all, ");
2133                 msg_print(NULL);
2134                 msg_print("One Ring to find them, ");
2135                 msg_print(NULL);
2136                 msg_print("One Ring to bring them all ");
2137                 msg_print(NULL);
2138                 msg_print("and in the darkness bind them.'");
2139 #endif
2140                 used_up = FALSE;
2141         }
2142         else if (o_ptr->tval==TV_PARCHEMENT)
2143         {
2144                 cptr q;
2145                 char o_name[MAX_NLEN];
2146                 char buf[1024];
2147
2148                 /* Save screen */
2149                 screen_save();
2150
2151                 q=format("book-%d_jp.txt",o_ptr->sval);
2152
2153                 /* Display object description */
2154                 object_desc(o_name, o_ptr, TRUE, 0);
2155
2156                 /* Build the filename */
2157                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
2158
2159                 /* Peruse the help file */
2160                 (void)show_file(TRUE, buf, o_name, 0, 0);
2161
2162                 /* Load screen */
2163                 screen_load();
2164
2165                 used_up=FALSE;
2166         }
2167
2168
2169         /* Combine / Reorder the pack (later) */
2170         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2171
2172         if (!(object_aware_p(o_ptr)))
2173         {
2174                 chg_virtue(V_PATIENCE, -1);
2175                 chg_virtue(V_CHANCE, 1);
2176                 chg_virtue(V_KNOWLEDGE, -1);
2177         }
2178
2179         /* The item was tried */
2180         object_tried(o_ptr);
2181
2182         /* An identification was made */
2183         if (ident && !object_aware_p(o_ptr))
2184         {
2185                 object_aware(o_ptr);
2186                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2187         }
2188
2189         /* Window stuff */
2190         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2191
2192
2193         /* Hack -- allow certain scrolls to be "preserved" */
2194         if (!used_up)
2195         {
2196                 return;
2197         }
2198
2199         sound(SOUND_SCROLL);
2200
2201         /* Destroy a scroll in the pack */
2202         if (item >= 0)
2203         {
2204                 inven_item_increase(item, -1);
2205                 inven_item_describe(item);
2206                 inven_item_optimize(item);
2207         }
2208
2209         /* Destroy a scroll on the floor */
2210         else
2211         {
2212                 floor_item_increase(0 - item, -1);
2213                 floor_item_describe(0 - item);
2214                 floor_item_optimize(0 - item);
2215         }
2216 }
2217
2218
2219 /*
2220  * Hook to determine if an object is readable
2221  */
2222 static bool item_tester_hook_readable(object_type *o_ptr)
2223 {
2224         if ((o_ptr->tval==TV_SCROLL) || (o_ptr->tval==TV_PARCHEMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER)) return (TRUE);
2225
2226         /* Assume not */
2227         return (FALSE);
2228 }
2229
2230
2231 void do_cmd_read_scroll(void)
2232 {
2233         object_type *o_ptr;
2234         int  item;
2235         cptr q, s;
2236
2237         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2238         {
2239                 set_action(ACTION_NONE);
2240         }
2241
2242         /* Check some conditions */
2243         if (p_ptr->blind)
2244         {
2245 #ifdef JP
2246                 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
2247 #else
2248                 msg_print("You can't see anything.");
2249 #endif
2250
2251                 return;
2252         }
2253         if (no_lite())
2254         {
2255 #ifdef JP
2256                 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
2257 #else
2258                 msg_print("You have no light to read by.");
2259 #endif
2260
2261                 return;
2262         }
2263         if (p_ptr->confused)
2264         {
2265 #ifdef JP
2266                 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡£");
2267 #else
2268                 msg_print("You are too confused!");
2269 #endif
2270
2271                 return;
2272         }
2273
2274
2275         /* Restrict choices to scrolls */
2276         item_tester_hook = item_tester_hook_readable;
2277
2278         /* Get an item */
2279 #ifdef JP
2280         q = "¤É¤Î´¬Êª¤òÆɤߤޤ¹¤«? ";
2281         s = "Æɤá¤ë´¬Êª¤¬¤Ê¤¤¡£";
2282 #else
2283         q = "Read which scroll? ";
2284         s = "You have no scrolls to read.";
2285 #endif
2286
2287         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2288
2289         /* Get the item (in the pack) */
2290         if (item >= 0)
2291         {
2292                 o_ptr = &inventory[item];
2293         }
2294
2295         /* Get the item (on the floor) */
2296         else
2297         {
2298                 o_ptr = &o_list[0 - item];
2299         }
2300
2301         /* Read the scroll */
2302         do_cmd_read_scroll_aux(item, object_aware_p(o_ptr));
2303 }
2304
2305
2306 static int staff_effect(int sval, bool *use_charge, bool magic, bool known)
2307 {
2308         int k;
2309         int ident = FALSE;
2310
2311         /* Analyze the staff */
2312         switch (sval)
2313         {
2314                 case SV_STAFF_DARKNESS:
2315                 {
2316                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
2317                         {
2318                                 if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
2319                         }
2320                         if (unlite_area(10, 3)) ident = TRUE;
2321                         break;
2322                 }
2323
2324                 case SV_STAFF_SLOWNESS:
2325                 {
2326                         if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
2327                         break;
2328                 }
2329
2330                 case SV_STAFF_HASTE_MONSTERS:
2331                 {
2332                         if (speed_monsters()) ident = TRUE;
2333                         break;
2334                 }
2335
2336                 case SV_STAFF_SUMMONING:
2337                 {
2338                         for (k = 0; k < randint1(4); k++)
2339                         {
2340                                 if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2341                                 {
2342                                         ident = TRUE;
2343                                 }
2344                         }
2345                         break;
2346                 }
2347
2348                 case SV_STAFF_TELEPORTATION:
2349                 {
2350                         teleport_player(100);
2351                         ident = TRUE;
2352                         break;
2353                 }
2354
2355                 case SV_STAFF_IDENTIFY:
2356                 {
2357                         if (!ident_spell(FALSE)) *use_charge = FALSE;
2358                         ident = TRUE;
2359                         break;
2360                 }
2361
2362                 case SV_STAFF_REMOVE_CURSE:
2363                 {
2364                         if (remove_curse())
2365                         {
2366                                 if (magic)
2367                                 {
2368 #ifdef JP
2369                                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
2370 #else
2371                                         msg_print("You feel as if someone is watching over you.");
2372 #endif
2373                                 }
2374                                 else if (!p_ptr->blind)
2375                                 {
2376 #ifdef JP
2377                                         msg_print("¾ó¤Ï°ì½Ö¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
2378 #else
2379                                         msg_print("The staff glows blue for a moment...");
2380 #endif
2381
2382                                 }
2383                                 ident = TRUE;
2384                         }
2385                         break;
2386                 }
2387
2388                 case SV_STAFF_STARLITE:
2389                 {
2390                         int num = damroll(5, 3);
2391                         int y, x;
2392                         int attempts;
2393
2394                         if (!p_ptr->blind && !magic)
2395                         {
2396 #ifdef JP
2397                                 msg_print("¾ó¤ÎÀ褬ÌÀ¤ë¤¯µ±¤¤¤¿...");
2398 #else
2399                                 msg_print("The end of the staff glows brightly...");
2400 #endif
2401
2402                         }
2403                         for (k = 0; k < num; k++)
2404                         {
2405                 attempts = 1000;
2406
2407                                 while(attempts--)
2408                                 {
2409                                         scatter(&y, &x, py, px, 4, 0);
2410
2411                                         if (!cave_floor_bold(y, x)) continue;
2412
2413                                         if ((y != py) || (x != px)) break;
2414                                 }
2415
2416                                 project(0, 0, y, x, damroll(6 + p_ptr->lev / 8, 10), GF_LITE_WEAK,
2417                                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1);
2418                         }
2419                         ident = TRUE;
2420                         break;
2421                 }
2422
2423                 case SV_STAFF_LITE:
2424                 {
2425                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
2426                         break;
2427                 }
2428
2429                 case SV_STAFF_MAPPING:
2430                 {
2431                         map_area(DETECT_RAD_MAP);
2432                         ident = TRUE;
2433                         break;
2434                 }
2435
2436                 case SV_STAFF_DETECT_GOLD:
2437                 {
2438                         if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
2439                         if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
2440                         break;
2441                 }
2442
2443                 case SV_STAFF_DETECT_ITEM:
2444                 {
2445                         if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
2446                         break;
2447                 }
2448
2449                 case SV_STAFF_DETECT_TRAP:
2450                 {
2451                         if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
2452                         break;
2453                 }
2454
2455                 case SV_STAFF_DETECT_DOOR:
2456                 {
2457                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
2458                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
2459                         break;
2460                 }
2461
2462                 case SV_STAFF_DETECT_INVIS:
2463                 {
2464                         if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
2465                         break;
2466                 }
2467
2468                 case SV_STAFF_DETECT_EVIL:
2469                 {
2470                         if (detect_monsters_evil(DETECT_RAD_DEFAULT)) ident = TRUE;
2471                         break;
2472                 }
2473
2474                 case SV_STAFF_CURE_LIGHT:
2475                 {
2476                         if (hp_player(damroll(2, 8))) ident = TRUE;
2477                         if (set_shero(0,TRUE)) ident = TRUE;
2478                         break;
2479                 }
2480
2481                 case SV_STAFF_CURING:
2482                 {
2483                         if (set_blind(0)) ident = TRUE;
2484                         if (set_poisoned(0)) ident = TRUE;
2485                         if (set_confused(0)) ident = TRUE;
2486                         if (set_stun(0)) ident = TRUE;
2487                         if (set_cut(0)) ident = TRUE;
2488                         if (set_image(0)) ident = TRUE;
2489                         if (set_shero(0,TRUE)) ident = TRUE;
2490                         break;
2491                 }
2492
2493                 case SV_STAFF_HEALING:
2494                 {
2495                         if (hp_player(300)) ident = TRUE;
2496                         if (set_stun(0)) ident = TRUE;
2497                         if (set_cut(0)) ident = TRUE;
2498                         if (set_shero(0,TRUE)) ident = TRUE;
2499                         break;
2500                 }
2501
2502                 case SV_STAFF_THE_MAGI:
2503                 {
2504                         if (do_res_stat(A_INT)) ident = TRUE;
2505                         if (p_ptr->csp < p_ptr->msp)
2506                         {
2507                                 p_ptr->csp = p_ptr->msp;
2508                                 p_ptr->csp_frac = 0;
2509                                 ident = TRUE;
2510 #ifdef JP
2511                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
2512 #else
2513                                 msg_print("Your feel your head clear.");
2514 #endif
2515
2516                                 p_ptr->redraw |= (PR_MANA);
2517                                 p_ptr->window |= (PW_PLAYER);
2518                                 p_ptr->window |= (PW_SPELL);
2519                         }
2520                         if (set_shero(0,TRUE)) ident = TRUE;
2521                         break;
2522                 }
2523
2524                 case SV_STAFF_SLEEP_MONSTERS:
2525                 {
2526                         if (sleep_monsters()) ident = TRUE;
2527                         break;
2528                 }
2529
2530                 case SV_STAFF_SLOW_MONSTERS:
2531                 {
2532                         if (slow_monsters()) ident = TRUE;
2533                         break;
2534                 }
2535
2536                 case SV_STAFF_SPEED:
2537                 {
2538                         if (set_fast(randint1(30) + 15, FALSE)) ident = TRUE;
2539                         break;
2540                 }
2541
2542                 case SV_STAFF_PROBING:
2543                 {
2544                         probing();
2545                         ident = TRUE;
2546                         break;
2547                 }
2548
2549                 case SV_STAFF_DISPEL_EVIL:
2550                 {
2551                         if (dispel_evil(80)) ident = TRUE;
2552                         break;
2553                 }
2554
2555                 case SV_STAFF_POWER:
2556                 {
2557                         if (dispel_monsters(150)) ident = TRUE;
2558                         break;
2559                 }
2560
2561                 case SV_STAFF_HOLINESS:
2562                 {
2563                         if (dispel_evil(150)) ident = TRUE;
2564                         k = 3 * p_ptr->lev;
2565                         if (set_protevil((magic ? 0 : p_ptr->protevil) + randint1(25) + k, FALSE)) ident = TRUE;
2566                         if (set_poisoned(0)) ident = TRUE;
2567                         if (set_afraid(0)) ident = TRUE;
2568                         if (hp_player(50)) ident = TRUE;
2569                         if (set_stun(0)) ident = TRUE;
2570                         if (set_cut(0)) ident = TRUE;
2571                         break;
2572                 }
2573
2574                 case SV_STAFF_GENOCIDE:
2575                 {
2576                         (void)symbol_genocide((magic ? p_ptr->lev + 50 : 200), TRUE);
2577                         ident = TRUE;
2578                         break;
2579                 }
2580
2581                 case SV_STAFF_EARTHQUAKES:
2582                 {
2583                         if (earthquake(py, px, 10))
2584                                 ident = TRUE;
2585                         else
2586 #ifdef JP
2587 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿¡£");
2588 #else
2589                                 msg_print("The dungeon trembles.");
2590 #endif
2591
2592
2593                         break;
2594                 }
2595
2596                 case SV_STAFF_DESTRUCTION:
2597                 {
2598                         if (destroy_area(py, px, 13+randint0(5), TRUE))
2599                                 ident = TRUE;
2600
2601                         break;
2602                 }
2603
2604                 case SV_STAFF_ANIMATE_DEAD:
2605                 {
2606                         if (animate_dead(0, py, px))
2607                                 ident = TRUE;
2608
2609                         break;
2610                 }
2611
2612                 case SV_STAFF_MSTORM:
2613                 {
2614 #ifdef JP
2615                         msg_print("¶¯ÎϤÊËâÎϤ¬Å¨¤ò°ú¤­Îö¤¤¤¿¡ª");
2616 #else
2617                         msg_print("Mighty magics rend your enemies!");
2618 #endif
2619                         project(0, 5, py, px,
2620                                 (randint1(200) + 300) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID, -1);
2621                         if ((p_ptr->pclass != CLASS_MAGE) && (p_ptr->pclass != CLASS_HIGH_MAGE) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_MAGIC_EATER) && (p_ptr->pclass != CLASS_BLUE_MAGE))
2622                         {
2623 #ifdef JP
2624                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "¥³¥ó¥È¥í¡¼¥ë¤·Æñ¤¤¶¯ÎϤÊËâÎϤβòÊü", -1);
2625 #else
2626                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "unleashing magics too mighty to control", -1);
2627 #endif
2628                         }
2629                         ident = TRUE;
2630
2631                         break;
2632                 }
2633
2634                 case SV_STAFF_NOTHING:
2635                 {
2636 #ifdef JP
2637                         msg_print("²¿¤âµ¯¤é¤Ê¤«¤Ã¤¿¡£");
2638                         msg_print("¤â¤Ã¤¿¤¤¤Ê¤¤»ö¤ò¤·¤¿¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£¿©¤Ùʪ¤ÏÂçÀڤˤ·¤Ê¤¯¤Æ¤Ï¡£");
2639 #else
2640                         msg_print("Nothing happen.");
2641                         msg_print("What a waste.  It's your food!");
2642 #endif
2643                         break;
2644                 }
2645         }
2646         return ident;
2647 }
2648
2649 /*
2650  * Use a staff.                 -RAK-
2651  *
2652  * One charge of one staff disappears.
2653  *
2654  * Hack -- staffs of identify can be "cancelled".
2655  */
2656 static void do_cmd_use_staff_aux(int item)
2657 {
2658         int         ident, chance, lev;
2659         object_type *o_ptr;
2660
2661
2662         /* Hack -- let staffs of identify get aborted */
2663         bool use_charge = TRUE;
2664
2665
2666         /* Get the item (in the pack) */
2667         if (item >= 0)
2668         {
2669                 o_ptr = &inventory[item];
2670         }
2671
2672         /* Get the item (on the floor) */
2673         else
2674         {
2675                 o_ptr = &o_list[0 - item];
2676         }
2677
2678
2679         /* Mega-Hack -- refuse to use a pile from the ground */
2680         if ((item < 0) && (o_ptr->number > 1))
2681         {
2682 #ifdef JP
2683                 msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
2684 #else
2685                 msg_print("You must first pick up the staffs.");
2686 #endif
2687
2688                 return;
2689         }
2690
2691
2692         /* Take a turn */
2693         energy_use = 100;
2694
2695         /* Extract the item level */
2696         lev = get_object_level(o_ptr);
2697         if (lev > 50) lev = 50 + (lev - 50)/2;
2698
2699         /* Base chance of success */
2700         chance = p_ptr->skill_dev;
2701
2702         /* Confusion hurts skill */
2703         if (p_ptr->confused) chance = chance / 2;
2704
2705         /* Hight level objects are harder */
2706         chance = chance - lev;
2707
2708         /* Give everyone a (slight) chance */
2709         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
2710         {
2711                 chance = USE_DEVICE;
2712         }
2713
2714         if (world_player)
2715         {
2716                 if (flush_failure) flush();
2717 #ifdef JP
2718                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
2719 #else
2720                 msg_print("Nothing happen. Maybe this staff is freezing too.");
2721 #endif
2722
2723                 sound(SOUND_FAIL);
2724                 return;
2725         }
2726
2727         /* Roll for usage */
2728         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
2729         {
2730                 if (flush_failure) flush();
2731 #ifdef JP
2732                 msg_print("¾ó¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
2733 #else
2734                 msg_print("You failed to use the staff properly.");
2735 #endif
2736
2737                 sound(SOUND_FAIL);
2738                 return;
2739         }
2740
2741         /* Notice empty staffs */
2742         if (o_ptr->pval <= 0)
2743         {
2744                 if (flush_failure) flush();
2745 #ifdef JP
2746                 msg_print("¤³¤Î¾ó¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
2747 #else
2748                 msg_print("The staff has no charges left.");
2749 #endif
2750
2751                 o_ptr->ident |= (IDENT_EMPTY);
2752
2753                 /* Combine / Reorder the pack (later) */
2754                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2755                 p_ptr->window |= (PW_INVEN);
2756
2757                 return;
2758         }
2759
2760
2761         /* Sound */
2762         sound(SOUND_ZAP);
2763
2764         ident = staff_effect(o_ptr->sval, &use_charge, FALSE, object_aware_p(o_ptr));
2765
2766         if (!(object_aware_p(o_ptr)))
2767         {
2768                 chg_virtue(V_PATIENCE, -1);
2769                 chg_virtue(V_CHANCE, 1);
2770                 chg_virtue(V_KNOWLEDGE, -1);
2771         }
2772
2773         /* Combine / Reorder the pack (later) */
2774         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2775
2776         /* Tried the item */
2777         object_tried(o_ptr);
2778
2779         /* An identification was made */
2780         if (ident && !object_aware_p(o_ptr))
2781         {
2782                 object_aware(o_ptr);
2783                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2784         }
2785
2786         /* Window stuff */
2787         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2788
2789
2790         /* Hack -- some uses are "free" */
2791         if (!use_charge) return;
2792
2793
2794         /* Use a single charge */
2795         o_ptr->pval--;
2796
2797         /* XXX Hack -- unstack if necessary */
2798         if ((item >= 0) && (o_ptr->number > 1))
2799         {
2800                 object_type forge;
2801                 object_type *q_ptr;
2802
2803                 /* Get local object */
2804                 q_ptr = &forge;
2805
2806                 /* Obtain a local object */
2807                 object_copy(q_ptr, o_ptr);
2808
2809                 /* Modify quantity */
2810                 q_ptr->number = 1;
2811
2812                 /* Restore the charges */
2813                 o_ptr->pval++;
2814
2815                 /* Unstack the used item */
2816                 o_ptr->number--;
2817                 p_ptr->total_weight -= q_ptr->weight;
2818                 item = inven_carry(q_ptr);
2819
2820                 /* Message */
2821 #ifdef JP
2822                 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
2823 #else
2824                 msg_print("You unstack your staff.");
2825 #endif
2826
2827         }
2828
2829         /* Describe charges in the pack */
2830         if (item >= 0)
2831         {
2832                 inven_item_charges(item);
2833         }
2834
2835         /* Describe charges on the floor */
2836         else
2837         {
2838                 floor_item_charges(0 - item);
2839         }
2840 }
2841
2842
2843 void do_cmd_use_staff(void)
2844 {
2845         int  item;
2846         cptr q, s;
2847
2848         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2849         {
2850                 set_action(ACTION_NONE);
2851         }
2852
2853         /* Restrict choices to wands */
2854         item_tester_tval = TV_STAFF;
2855
2856         /* Get an item */
2857 #ifdef JP
2858         q = "¤É¤Î¾ó¤ò»È¤¤¤Þ¤¹¤«? ";
2859         s = "»È¤¨¤ë¾ó¤¬¤Ê¤¤¡£";
2860 #else
2861         q = "Use which staff? ";
2862         s = "You have no staff to use.";
2863 #endif
2864
2865         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2866
2867         do_cmd_use_staff_aux(item);
2868 }
2869
2870
2871 static int wand_effect(int sval, int dir, bool magic)
2872 {
2873         int ident = FALSE;
2874
2875         /* XXX Hack -- Wand of wonder can do anything before it */
2876         if (sval == SV_WAND_WONDER)
2877         {
2878                 int vir = virtue_number(V_CHANCE);
2879                 sval = randint0(SV_WAND_WONDER);
2880
2881                 if (vir)
2882                 {
2883                         if (p_ptr->virtues[vir - 1] > 0)
2884                         {
2885                                 while (randint1(300) < p_ptr->virtues[vir - 1]) sval++;
2886                                 if (sval > SV_WAND_COLD_BALL) sval = randint0(4) + SV_WAND_ACID_BALL;
2887                         }
2888                         else
2889                         {
2890                                 while (randint1(300) < (0-p_ptr->virtues[vir - 1])) sval--;
2891                                 if (sval < SV_WAND_HEAL_MONSTER) sval = randint0(3) + SV_WAND_HEAL_MONSTER;
2892                         }
2893                 }
2894                 if (sval < SV_WAND_TELEPORT_AWAY)
2895                         chg_virtue(V_CHANCE, 1);
2896         }
2897
2898         /* Analyze the wand */
2899         switch (sval)
2900         {
2901                 case SV_WAND_HEAL_MONSTER:
2902                 {
2903                         if (heal_monster(dir, damroll(10, 10))) ident = TRUE;
2904                         break;
2905                 }
2906
2907                 case SV_WAND_HASTE_MONSTER:
2908                 {
2909                         if (speed_monster(dir)) ident = TRUE;
2910                         break;
2911                 }
2912
2913                 case SV_WAND_CLONE_MONSTER:
2914                 {
2915                         if (clone_monster(dir)) ident = TRUE;
2916                         break;
2917                 }
2918
2919                 case SV_WAND_TELEPORT_AWAY:
2920                 {
2921                         if (teleport_monster(dir)) ident = TRUE;
2922                         break;
2923                 }
2924
2925                 case SV_WAND_DISARMING:
2926                 {
2927                         if (disarm_trap(dir)) ident = TRUE;
2928                         break;
2929                 }
2930
2931                 case SV_WAND_TRAP_DOOR_DEST:
2932                 {
2933                         if (destroy_door(dir)) ident = TRUE;
2934                         break;
2935                 }
2936
2937                 case SV_WAND_STONE_TO_MUD:
2938                 {
2939                         if (wall_to_mud(dir)) ident = TRUE;
2940                         break;
2941                 }
2942
2943                 case SV_WAND_LITE:
2944                 {
2945 #ifdef JP
2946                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
2947 #else
2948                         msg_print("A line of blue shimmering light appears.");
2949 #endif
2950
2951                         (void)lite_line(dir);
2952                         ident = TRUE;
2953                         break;
2954                 }
2955
2956                 case SV_WAND_SLEEP_MONSTER:
2957                 {
2958                         if (sleep_monster(dir)) ident = TRUE;
2959                         break;
2960                 }
2961
2962                 case SV_WAND_SLOW_MONSTER:
2963                 {
2964                         if (slow_monster(dir)) ident = TRUE;
2965                         break;
2966                 }
2967
2968                 case SV_WAND_CONFUSE_MONSTER:
2969                 {
2970                         if (confuse_monster(dir, p_ptr->lev)) ident = TRUE;
2971                         break;
2972                 }
2973
2974                 case SV_WAND_FEAR_MONSTER:
2975                 {
2976                         if (fear_monster(dir, p_ptr->lev)) ident = TRUE;
2977                         break;
2978                 }
2979
2980                 case SV_WAND_DRAIN_LIFE:
2981                 {
2982                         if (drain_life(dir, 80 + p_ptr->lev)) ident = TRUE;
2983                         break;
2984                 }
2985
2986                 case SV_WAND_POLYMORPH:
2987                 {
2988                         if (poly_monster(dir)) ident = TRUE;
2989                         break;
2990                 }
2991
2992                 case SV_WAND_STINKING_CLOUD:
2993                 {
2994                         fire_ball(GF_POIS, dir, 12 + p_ptr->lev / 4, 2);
2995                         ident = TRUE;
2996                         break;
2997                 }
2998
2999                 case SV_WAND_MAGIC_MISSILE:
3000                 {
3001                         fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(2 + p_ptr->lev / 10, 6));
3002                         ident = TRUE;
3003                         break;
3004                 }
3005
3006                 case SV_WAND_ACID_BOLT:
3007                 {
3008                         fire_bolt_or_beam(20, GF_ACID, dir, damroll(6 + p_ptr->lev / 7, 8));
3009                         ident = TRUE;
3010                         break;
3011                 }
3012
3013                 case SV_WAND_CHARM_MONSTER:
3014                 {
3015                         if (charm_monster(dir, MAX(20, p_ptr->lev)))
3016                         ident = TRUE;
3017                         break;
3018                 }
3019
3020                 case SV_WAND_FIRE_BOLT:
3021                 {
3022                         fire_bolt_or_beam(20, GF_FIRE, dir, damroll(7 + p_ptr->lev / 6, 8));
3023                         ident = TRUE;
3024                         break;
3025                 }
3026
3027                 case SV_WAND_COLD_BOLT:
3028                 {
3029                         fire_bolt_or_beam(20, GF_COLD, dir, damroll(5 + p_ptr->lev / 8, 8));
3030                         ident = TRUE;
3031                         break;
3032                 }
3033
3034                 case SV_WAND_ACID_BALL:
3035                 {
3036                         fire_ball(GF_ACID, dir, 60 + 3 * p_ptr->lev / 4, 2);
3037                         ident = TRUE;
3038                         break;
3039                 }
3040
3041                 case SV_WAND_ELEC_BALL:
3042                 {
3043                         fire_ball(GF_ELEC, dir, 40 + 3 * p_ptr->lev / 4, 2);
3044                         ident = TRUE;
3045                         break;
3046                 }
3047
3048                 case SV_WAND_FIRE_BALL:
3049                 {
3050                         fire_ball(GF_FIRE, dir, 70 + 3 * p_ptr->lev / 4, 2);
3051                         ident = TRUE;
3052                         break;
3053                 }
3054
3055                 case SV_WAND_COLD_BALL:
3056                 {
3057                         fire_ball(GF_COLD, dir, 50 + 3 * p_ptr->lev / 4, 2);
3058                         ident = TRUE;
3059                         break;
3060                 }
3061
3062                 case SV_WAND_WONDER:
3063                 {
3064 #ifdef JP
3065                         msg_print("¤ª¤Ã¤È¡¢Ææ¤ÎËâË¡ËÀ¤ò»ÏÆ°¤µ¤»¤¿¡£");
3066 #else
3067                         msg_print("Oops.  Wand of wonder activated.");
3068 #endif
3069
3070                         break;
3071                 }
3072
3073                 case SV_WAND_DRAGON_FIRE:
3074                 {
3075                         fire_ball(GF_FIRE, dir, 200, -3);
3076                         ident = TRUE;
3077                         break;
3078                 }
3079
3080                 case SV_WAND_DRAGON_COLD:
3081                 {
3082                         fire_ball(GF_COLD, dir, 180, -3);
3083                         ident = TRUE;
3084                         break;
3085                 }
3086
3087                 case SV_WAND_DRAGON_BREATH:
3088                 {
3089                         switch (randint1(5))
3090                         {
3091                                 case 1:
3092                                 {
3093                                         fire_ball(GF_ACID, dir, 240, -3);
3094                                         break;
3095                                 }
3096
3097                                 case 2:
3098                                 {
3099                                         fire_ball(GF_ELEC, dir, 210, -3);
3100                                         break;
3101                                 }
3102
3103                                 case 3:
3104                                 {
3105                                         fire_ball(GF_FIRE, dir, 240, -3);
3106                                         break;
3107                                 }
3108
3109                                 case 4:
3110                                 {
3111                                         fire_ball(GF_COLD, dir, 210, -3);
3112                                         break;
3113                                 }
3114
3115                                 default:
3116                                 {
3117                                         fire_ball(GF_POIS, dir, 180, -3);
3118                                         break;
3119                                 }
3120                         }
3121
3122                         ident = TRUE;
3123                         break;
3124                 }
3125
3126                 case SV_WAND_DISINTEGRATE:
3127                 {
3128                         fire_ball(GF_DISINTEGRATE, dir, 200 + randint1(p_ptr->lev * 2), 2);
3129                         ident = TRUE;
3130                         break;
3131                 }
3132
3133                 case SV_WAND_ROCKETS:
3134                 {
3135 #ifdef JP
3136 msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
3137 #else
3138                         msg_print("You launch a rocket!");
3139 #endif
3140
3141                         fire_rocket(GF_ROCKET, dir, 250 + p_ptr->lev * 3, 2);
3142                         ident = TRUE;
3143                         break;
3144                 }
3145
3146                 case SV_WAND_STRIKING:
3147                 {
3148                         fire_bolt(GF_METEOR, dir, damroll(15 + p_ptr->lev / 3, 13));
3149                         ident = TRUE;
3150                         break;
3151                 }
3152
3153                 case SV_WAND_GENOCIDE:
3154                 {
3155                         fire_ball_hide(GF_GENOCIDE, dir, magic ? p_ptr->lev + 50 : 250, 0);
3156                         ident = TRUE;
3157                         break;
3158                 }
3159         }
3160         return ident;
3161 }
3162
3163
3164 /*
3165  * Aim a wand (from the pack or floor).
3166  *
3167  * Use a single charge from a single item.
3168  * Handle "unstacking" in a logical manner.
3169  *
3170  * For simplicity, you cannot use a stack of items from the
3171  * ground.  This would require too much nasty code.
3172  *
3173  * There are no wands which can "destroy" themselves, in the inventory
3174  * or on the ground, so we can ignore this possibility.  Note that this
3175  * required giving "wand of wonder" the ability to ignore destruction
3176  * by electric balls.
3177  *
3178  * All wands can be "cancelled" at the "Direction?" prompt for free.
3179  *
3180  * Note that the basic "bolt" wands do slightly less damage than the
3181  * basic "bolt" rods, but the basic "ball" wands do the same damage
3182  * as the basic "ball" rods.
3183  */
3184 static void do_cmd_aim_wand_aux(int item)
3185 {
3186         int         lev, ident, chance, dir;
3187         object_type *o_ptr;
3188         bool old_target_pet = target_pet;
3189
3190         /* Get the item (in the pack) */
3191         if (item >= 0)
3192         {
3193                 o_ptr = &inventory[item];
3194         }
3195
3196         /* Get the item (on the floor) */
3197         else
3198         {
3199                 o_ptr = &o_list[0 - item];
3200         }
3201
3202         /* Mega-Hack -- refuse to aim a pile from the ground */
3203         if ((item < 0) && (o_ptr->number > 1))
3204         {
3205 #ifdef JP
3206                 msg_print("¤Þ¤º¤ÏËâË¡ËÀ¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3207 #else
3208                 msg_print("You must first pick up the wands.");
3209 #endif
3210
3211                 return;
3212         }
3213
3214
3215         /* Allow direction to be cancelled for free */
3216         if (object_aware_p(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
3217                                       || o_ptr->sval == SV_WAND_HASTE_MONSTER))
3218                         target_pet = TRUE;
3219         if (!get_aim_dir(&dir))
3220         {
3221                 target_pet = old_target_pet;
3222                 return;
3223         }
3224         target_pet = old_target_pet;
3225
3226         /* Take a turn */
3227         energy_use = 100;
3228
3229         /* Get the level */
3230         lev = get_object_level(o_ptr);
3231         if (lev > 50) lev = 50 + (lev - 50)/2;
3232
3233         /* Base chance of success */
3234         chance = p_ptr->skill_dev;
3235
3236         /* Confusion hurts skill */
3237         if (p_ptr->confused) chance = chance / 2;
3238
3239         /* Hight level objects are harder */
3240         chance = chance - lev;
3241
3242         /* Give everyone a (slight) chance */
3243         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
3244         {
3245                 chance = USE_DEVICE;
3246         }
3247
3248         if (world_player)
3249         {
3250                 if (flush_failure) flush();
3251 #ifdef JP
3252                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3253 #else
3254                 msg_print("Nothing happen. Maybe this wand is freezing too.");
3255 #endif
3256
3257                 sound(SOUND_FAIL);
3258                 return;
3259         }
3260
3261         /* Roll for usage */
3262         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
3263         {
3264                 if (flush_failure) flush();
3265 #ifdef JP
3266                 msg_print("ËâË¡ËÀ¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
3267 #else
3268                 msg_print("You failed to use the wand properly.");
3269 #endif
3270
3271                 sound(SOUND_FAIL);
3272                 return;
3273         }
3274
3275         /* The wand is already empty! */
3276         if (o_ptr->pval <= 0)
3277         {
3278                 if (flush_failure) flush();
3279 #ifdef JP
3280                 msg_print("¤³¤ÎËâË¡ËÀ¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
3281 #else
3282                 msg_print("The wand has no charges left.");
3283 #endif
3284
3285                 o_ptr->ident |= (IDENT_EMPTY);
3286
3287                 /* Combine / Reorder the pack (later) */
3288                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3289                 p_ptr->window |= (PW_INVEN);
3290
3291                 return;
3292         }
3293
3294         /* Sound */
3295         sound(SOUND_ZAP);
3296
3297         ident = wand_effect(o_ptr->sval, dir, FALSE);
3298
3299         /* Combine / Reorder the pack (later) */
3300         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3301
3302         if (!(object_aware_p(o_ptr)))
3303         {
3304                 chg_virtue(V_PATIENCE, -1);
3305                 chg_virtue(V_CHANCE, 1);
3306                 chg_virtue(V_KNOWLEDGE, -1);
3307         }
3308
3309         /* Mark it as tried */
3310         object_tried(o_ptr);
3311
3312         /* Apply identification */
3313         if (ident && !object_aware_p(o_ptr))
3314         {
3315                 object_aware(o_ptr);
3316                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3317         }
3318
3319         /* Window stuff */
3320         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3321
3322
3323         /* Use a single charge */
3324         o_ptr->pval--;
3325
3326         /* Describe the charges in the pack */
3327         if (item >= 0)
3328         {
3329                 inven_item_charges(item);
3330         }
3331
3332         /* Describe the charges on the floor */
3333         else
3334         {
3335                 floor_item_charges(0 - item);
3336         }
3337 }
3338
3339
3340 void do_cmd_aim_wand(void)
3341 {
3342         int     item;
3343         cptr    q, s;
3344
3345         /* Restrict choices to wands */
3346         item_tester_tval = TV_WAND;
3347
3348         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3349         {
3350                 set_action(ACTION_NONE);
3351         }
3352
3353         /* Get an item */
3354 #ifdef JP
3355         q = "¤É¤ÎËâË¡ËÀ¤ÇÁÀ¤¤¤Þ¤¹¤«? ";
3356         s = "»È¤¨¤ëËâË¡ËÀ¤¬¤Ê¤¤¡£";
3357 #else
3358         q = "Aim which wand? ";
3359         s = "You have no wand to aim.";
3360 #endif
3361
3362         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3363
3364         /* Aim the wand */
3365         do_cmd_aim_wand_aux(item);
3366 }
3367
3368
3369 static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
3370 {
3371         int ident = FALSE;
3372
3373         /* Analyze the rod */
3374         switch (sval)
3375         {
3376                 case SV_ROD_DETECT_TRAP:
3377                 {
3378                         if (detect_traps(DETECT_RAD_DEFAULT, dir ? FALSE : TRUE)) ident = TRUE;
3379                         break;
3380                 }
3381
3382                 case SV_ROD_DETECT_DOOR:
3383                 {
3384                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
3385                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
3386                         break;
3387                 }
3388
3389                 case SV_ROD_IDENTIFY:
3390                 {
3391                         if (!ident_spell(FALSE)) *use_charge = FALSE;
3392                         ident = TRUE;
3393                         break;
3394                 }
3395
3396                 case SV_ROD_RECALL:
3397                 {
3398                         if (!word_of_recall()) *use_charge = FALSE;
3399                         ident = TRUE;
3400                         break;
3401                 }
3402
3403                 case SV_ROD_ILLUMINATION:
3404                 {
3405                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
3406                         break;
3407                 }
3408
3409                 case SV_ROD_MAPPING:
3410                 {
3411                         map_area(DETECT_RAD_MAP);
3412                         ident = TRUE;
3413                         break;
3414                 }
3415
3416                 case SV_ROD_DETECTION:
3417                 {
3418                         detect_all(DETECT_RAD_DEFAULT);
3419                         ident = TRUE;
3420                         break;
3421                 }
3422
3423                 case SV_ROD_PROBING:
3424                 {
3425                         probing();
3426                         ident = TRUE;
3427                         break;
3428                 }
3429
3430                 case SV_ROD_CURING:
3431                 {
3432                         if (set_blind(0)) ident = TRUE;
3433                         if (set_poisoned(0)) ident = TRUE;
3434                         if (set_confused(0)) ident = TRUE;
3435                         if (set_stun(0)) ident = TRUE;
3436                         if (set_cut(0)) ident = TRUE;
3437                         if (set_image(0)) ident = TRUE;
3438                         if (set_shero(0,TRUE)) ident = TRUE;
3439                         break;
3440                 }
3441
3442                 case SV_ROD_HEALING:
3443                 {
3444                         if (hp_player(500)) ident = TRUE;
3445                         if (set_stun(0)) ident = TRUE;
3446                         if (set_cut(0)) ident = TRUE;
3447                         if (set_shero(0,TRUE)) ident = TRUE;
3448                         break;
3449                 }
3450
3451                 case SV_ROD_RESTORATION:
3452                 {
3453                         if (restore_level()) ident = TRUE;
3454                         if (do_res_stat(A_STR)) ident = TRUE;
3455                         if (do_res_stat(A_INT)) ident = TRUE;
3456                         if (do_res_stat(A_WIS)) ident = TRUE;
3457                         if (do_res_stat(A_DEX)) ident = TRUE;
3458                         if (do_res_stat(A_CON)) ident = TRUE;
3459                         if (do_res_stat(A_CHR)) ident = TRUE;
3460                         break;
3461                 }
3462
3463                 case SV_ROD_SPEED:
3464                 {
3465                         if (set_fast(randint1(30) + 15, FALSE)) ident = TRUE;
3466                         break;
3467                 }
3468
3469                 case SV_ROD_PESTICIDE:
3470                 {
3471                         if (dispel_monsters(4)) ident = TRUE;
3472                         break;
3473                 }
3474
3475                 case SV_ROD_TELEPORT_AWAY:
3476                 {
3477                         if (teleport_monster(dir)) ident = TRUE;
3478                         break;
3479                 }
3480
3481                 case SV_ROD_DISARMING:
3482                 {
3483                         if (disarm_trap(dir)) ident = TRUE;
3484                         break;
3485                 }
3486
3487                 case SV_ROD_LITE:
3488                 {
3489 #ifdef JP
3490                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3491 #else
3492                         msg_print("A line of blue shimmering light appears.");
3493 #endif
3494
3495                         (void)lite_line(dir);
3496                         ident = TRUE;
3497                         break;
3498                 }
3499
3500                 case SV_ROD_SLEEP_MONSTER:
3501                 {
3502                         if (sleep_monster(dir)) ident = TRUE;
3503                         break;
3504                 }
3505
3506                 case SV_ROD_SLOW_MONSTER:
3507                 {
3508                         if (slow_monster(dir)) ident = TRUE;
3509                         break;
3510                 }
3511
3512                 case SV_ROD_DRAIN_LIFE:
3513                 {
3514                         if (drain_life(dir, 70 + 3 * p_ptr->lev / 2)) ident = TRUE;
3515                         break;
3516                 }
3517
3518                 case SV_ROD_POLYMORPH:
3519                 {
3520                         if (poly_monster(dir)) ident = TRUE;
3521                         break;
3522                 }
3523
3524                 case SV_ROD_ACID_BOLT:
3525                 {
3526                         fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + p_ptr->lev / 7, 8));
3527                         ident = TRUE;
3528                         break;
3529                 }
3530
3531                 case SV_ROD_ELEC_BOLT:
3532                 {
3533                         fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + p_ptr->lev / 9, 8));
3534                         ident = TRUE;
3535                         break;
3536                 }
3537
3538                 case SV_ROD_FIRE_BOLT:
3539                 {
3540                         fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + p_ptr->lev / 6, 8));
3541                         ident = TRUE;
3542                         break;
3543                 }
3544
3545                 case SV_ROD_COLD_BOLT:
3546                 {
3547                         fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + p_ptr->lev / 8, 8));
3548                         ident = TRUE;
3549                         break;
3550                 }
3551
3552                 case SV_ROD_ACID_BALL:
3553                 {
3554                         fire_ball(GF_ACID, dir, 60 + p_ptr->lev, 2);
3555                         ident = TRUE;
3556                         break;
3557                 }
3558
3559                 case SV_ROD_ELEC_BALL:
3560                 {
3561                         fire_ball(GF_ELEC, dir, 40 + p_ptr->lev, 2);
3562                         ident = TRUE;
3563                         break;
3564                 }
3565
3566                 case SV_ROD_FIRE_BALL:
3567                 {
3568                         fire_ball(GF_FIRE, dir, 70 + p_ptr->lev, 2);
3569                         ident = TRUE;
3570                         break;
3571                 }
3572
3573                 case SV_ROD_COLD_BALL:
3574                 {
3575                         fire_ball(GF_COLD, dir, 50 + p_ptr->lev, 2);
3576                         ident = TRUE;
3577                         break;
3578                 }
3579
3580                 case SV_ROD_HAVOC:
3581                 {
3582                         call_chaos();
3583                         ident = TRUE;
3584                         break;
3585                 }
3586
3587                 case SV_ROD_STONE_TO_MUD:
3588                 {
3589                         if (wall_to_mud(dir)) ident = TRUE;
3590                         break;
3591                 }
3592
3593                 case SV_ROD_AGGRAVATE:
3594                 {
3595                         aggravate_monsters(0);
3596                         ident = TRUE;
3597                         break;
3598                 }
3599         }
3600         return ident;
3601 }
3602
3603 /*
3604  * Activate (zap) a Rod
3605  *
3606  * Unstack fully charged rods as needed.
3607  *
3608  * Hack -- rods of perception/genocide can be "cancelled"
3609  * All rods can be cancelled at the "Direction?" prompt
3610  *
3611  * pvals are defined for each rod in k_info. -LM-
3612  */
3613 static void do_cmd_zap_rod_aux(int item)
3614 {
3615         int ident, chance, lev, fail;
3616         int dir = 0;
3617         object_type *o_ptr;
3618         bool success;
3619
3620         /* Hack -- let perception get aborted */
3621         bool use_charge = TRUE;
3622
3623         object_kind *k_ptr;
3624
3625         /* Get the item (in the pack) */
3626         if (item >= 0)
3627         {
3628                 o_ptr = &inventory[item];
3629         }
3630
3631         /* Get the item (on the floor) */
3632         else
3633         {
3634                 o_ptr = &o_list[0 - item];
3635         }
3636
3637
3638         /* Mega-Hack -- refuse to zap a pile from the ground */
3639         if ((item < 0) && (o_ptr->number > 1))
3640         {
3641 #ifdef JP
3642                 msg_print("¤Þ¤º¤Ï¥í¥Ã¥É¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3643 #else
3644                 msg_print("You must first pick up the rods.");
3645 #endif
3646
3647                 return;
3648         }
3649
3650
3651         /* Get a direction (unless KNOWN not to need it) */
3652         if (((o_ptr->sval >= SV_ROD_MIN_DIRECTION) && (o_ptr->sval != SV_ROD_HAVOC) && (o_ptr->sval != SV_ROD_AGGRAVATE) && (o_ptr->sval != SV_ROD_PESTICIDE)) ||
3653              !object_aware_p(o_ptr))
3654         {
3655                 /* Get a direction, allow cancel */
3656                 if (!get_aim_dir(&dir)) return;
3657         }
3658
3659
3660         /* Take a turn */
3661         energy_use = 100;
3662
3663         /* Extract the item level */
3664         lev = get_object_level(o_ptr);
3665
3666         /* Base chance of success */
3667         chance = p_ptr->skill_dev;
3668
3669         /* Confusion hurts skill */
3670         if (p_ptr->confused) chance = chance / 2;
3671
3672         fail = lev+5;
3673         if (chance > fail) fail -= (chance - fail)*2;
3674         else chance -= (fail - chance)*2;
3675         if (fail < USE_DEVICE) fail = USE_DEVICE;
3676         if (chance < USE_DEVICE) chance = USE_DEVICE;
3677
3678         if (world_player)
3679         {
3680                 if (flush_failure) flush();
3681 #ifdef JP
3682                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3683 #else
3684                 msg_print("Nothing happen. Maybe this rod is freezing too.");
3685 #endif
3686
3687                 sound(SOUND_FAIL);
3688                 return;
3689         }
3690
3691         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
3692         else if (chance > fail)
3693         {
3694                 if (randint0(chance*2) < fail) success = FALSE;
3695                 else success = TRUE;
3696         }
3697         else
3698         {
3699                 if (randint0(fail*2) < chance) success = TRUE;
3700                 else success = FALSE;
3701         }
3702
3703         /* Roll for usage */
3704         if (!success)
3705         {
3706                 if (flush_failure) flush();
3707 #ifdef JP
3708                 msg_print("¤¦¤Þ¤¯¥í¥Ã¥É¤ò»È¤¨¤Ê¤«¤Ã¤¿¡£");
3709 #else
3710                 msg_print("You failed to use the rod properly.");
3711 #endif
3712
3713                 sound(SOUND_FAIL);
3714                 return;
3715         }
3716
3717         k_ptr = &k_info[o_ptr->k_idx];
3718
3719         /* A single rod is still charging */
3720         if ((o_ptr->number == 1) && (o_ptr->timeout))
3721         {
3722                 if (flush_failure) flush();
3723 #ifdef JP
3724                 msg_print("¤³¤Î¥í¥Ã¥É¤Ï¤Þ¤ÀËâÎϤò½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
3725 #else
3726                 msg_print("The rod is still charging.");
3727 #endif
3728
3729                 return;
3730         }
3731         /* A stack of rods lacks enough energy. */
3732         else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
3733         {
3734                 if (flush_failure) flush();
3735 #ifdef JP
3736 msg_print("¤½¤Î¥í¥Ã¥É¤Ï¤Þ¤À½¼Å¶Ãæ¤Ç¤¹¡£");
3737 #else
3738                 msg_print("The rods are all still charging.");
3739 #endif
3740
3741                 return;
3742         }
3743
3744         /* Sound */
3745         sound(SOUND_ZAP);
3746
3747         ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE);
3748
3749         /* Increase the timeout by the rod kind's pval. -LM- */
3750         if (use_charge) o_ptr->timeout += k_ptr->pval;
3751
3752         /* Combine / Reorder the pack (later) */
3753         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3754
3755         if (!(object_aware_p(o_ptr)))
3756         {
3757                 chg_virtue(V_PATIENCE, -1);
3758                 chg_virtue(V_CHANCE, 1);
3759                 chg_virtue(V_KNOWLEDGE, -1);
3760         }
3761
3762         /* Tried the object */
3763         object_tried(o_ptr);
3764
3765         /* Successfully determined the object function */
3766         if (ident && !object_aware_p(o_ptr))
3767         {
3768                 object_aware(o_ptr);
3769                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3770         }
3771
3772         /* Window stuff */
3773         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3774 }
3775
3776
3777 void do_cmd_zap_rod(void)
3778 {
3779         int item;
3780         cptr q, s;
3781
3782         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3783         {
3784                 set_action(ACTION_NONE);
3785         }
3786
3787         /* Restrict choices to rods */
3788         item_tester_tval = TV_ROD;
3789
3790         /* Get an item */
3791 #ifdef JP
3792         q = "¤É¤Î¥í¥Ã¥É¤ò¿¶¤ê¤Þ¤¹¤«? ";
3793         s = "»È¤¨¤ë¥í¥Ã¥É¤¬¤Ê¤¤¡£";
3794 #else
3795         q = "Zap which rod? ";
3796         s = "You have no rod to zap.";
3797 #endif
3798
3799         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3800
3801         /* Zap the rod */
3802         do_cmd_zap_rod_aux(item);
3803 }
3804
3805
3806 /*
3807  * Hook to determine if an object is activatable
3808  */
3809 static bool item_tester_hook_activate(object_type *o_ptr)
3810 {
3811         u32b flgs[TR_FLAG_SIZE];
3812
3813         /* Not known */
3814         if (!object_known_p(o_ptr)) return (FALSE);
3815
3816         /* Extract the flags */
3817         object_flags(o_ptr, flgs);
3818
3819         /* Check activation flag */
3820         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
3821
3822         /* Assume not */
3823         return (FALSE);
3824 }
3825
3826
3827 /*
3828  * Hack -- activate the ring of power
3829  */
3830 void ring_of_power(int dir)
3831 {
3832         /* Pick a random effect */
3833         switch (randint1(10))
3834         {
3835                 case 1:
3836                 case 2:
3837                 {
3838                         /* Message */
3839 #ifdef JP
3840                         msg_print("¤¢¤Ê¤¿¤Ï°­À­¤Î¥ª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3841 #else
3842                         msg_print("You are surrounded by a malignant aura.");
3843 #endif
3844
3845                         sound(SOUND_EVIL);
3846
3847                         /* Decrease all stats (permanently) */
3848                         (void)dec_stat(A_STR, 50, TRUE);
3849                         (void)dec_stat(A_INT, 50, TRUE);
3850                         (void)dec_stat(A_WIS, 50, TRUE);
3851                         (void)dec_stat(A_DEX, 50, TRUE);
3852                         (void)dec_stat(A_CON, 50, TRUE);
3853                         (void)dec_stat(A_CHR, 50, TRUE);
3854
3855                         /* Lose some experience (permanently) */
3856                         p_ptr->exp -= (p_ptr->exp / 4);
3857                         p_ptr->max_exp -= (p_ptr->exp / 4);
3858                         check_experience();
3859
3860                         break;
3861                 }
3862
3863                 case 3:
3864                 {
3865                         /* Message */
3866 #ifdef JP
3867                         msg_print("¤¢¤Ê¤¿¤Ï¶¯ÎϤʥª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3868 #else
3869                         msg_print("You are surrounded by a powerful aura.");
3870 #endif
3871
3872
3873                         /* Dispel monsters */
3874                         dispel_monsters(1000);
3875
3876                         break;
3877                 }
3878
3879                 case 4:
3880                 case 5:
3881                 case 6:
3882                 {
3883                         /* Mana Ball */
3884                         fire_ball(GF_MANA, dir, 600, 3);
3885
3886                         break;
3887                 }
3888
3889                 case 7:
3890                 case 8:
3891                 case 9:
3892                 case 10:
3893                 {
3894                         /* Mana Bolt */
3895                         fire_bolt(GF_MANA, dir, 500);
3896
3897                         break;
3898                 }
3899         }
3900 }
3901
3902
3903 static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
3904 {
3905         u16b *who = (u16b*)(u);
3906
3907         int w1 = who[a];
3908         int w2 = who[b];
3909
3910         monster_type *m_ptr1 = &m_list[w1];
3911         monster_type *m_ptr2 = &m_list[w2];
3912         monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
3913         monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
3914
3915         if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
3916         if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
3917
3918         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
3919         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
3920
3921         if (r_ptr1->level > r_ptr2->level) return TRUE;
3922         if (r_ptr2->level > r_ptr1->level) return FALSE;
3923
3924         if (m_ptr1->hp > m_ptr2->hp) return TRUE;
3925         if (m_ptr2->hp > m_ptr1->hp) return FALSE;
3926         
3927         return w1 <= w2;
3928 }
3929
3930 /*
3931  * Activate a wielded object.  Wielded objects never stack.
3932  * And even if they did, activatable objects never stack.
3933  *
3934  * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated.
3935  * But one could, for example, easily make an activatable "Ring of Plasma".
3936  *
3937  * Note that it always takes a turn to activate an artifact, even if
3938  * the user hits "escape" at the "direction" prompt.
3939  */
3940 static void do_cmd_activate_aux(int item)
3941 {
3942         int         k, dir, lev, chance, fail;
3943         object_type *o_ptr;
3944         bool success;
3945
3946
3947         /* Get the item (in the pack) */
3948         if (item >= 0)
3949         {
3950                 o_ptr = &inventory[item];
3951         }
3952
3953         /* Get the item (on the floor) */
3954         else
3955         {
3956                 o_ptr = &o_list[0 - item];
3957         }
3958
3959         /* Take a turn */
3960         energy_use = 100;
3961
3962         /* Extract the item level */
3963         lev = get_object_level(o_ptr);
3964
3965         /* Hack -- use artifact level instead */
3966         if (artifact_p(o_ptr)) lev = a_info[o_ptr->name1].level;
3967         else if (o_ptr->art_name)
3968         {
3969                 switch (o_ptr->xtra2)
3970                 {
3971                         case ACT_SUNLIGHT:
3972                         case ACT_BO_MISS_1:
3973                         case ACT_BA_POIS_1:
3974                         case ACT_CONFUSE:
3975                         case ACT_SLEEP:
3976                         case ACT_CURE_LW:
3977                         case ACT_CURE_POISON:
3978                         case ACT_BERSERK:
3979                         case ACT_LIGHT:
3980                         case ACT_DEST_DOOR:
3981                         case ACT_TELEPORT:
3982                                 lev = 10;
3983                                 break;
3984                         case ACT_BO_ELEC_1:
3985                         case ACT_BO_ACID_1:
3986                         case ACT_BO_COLD_1:
3987                         case ACT_BO_FIRE_1:
3988                         case ACT_MAP_LIGHT:
3989                         case ACT_STONE_MUD:
3990                         case ACT_CURE_MW:
3991                         case ACT_QUAKE:
3992                                 lev = 20;
3993                                 break;
3994                         case ACT_DRAIN_1:
3995                         case ACT_TELE_AWAY:
3996                         case ACT_ESP:
3997                         case ACT_RESIST_ALL:
3998                         case ACT_DETECT_ALL:
3999                         case ACT_RECALL:
4000                         case ACT_SATIATE:
4001                         case ACT_RECHARGE:
4002                                 lev = 30;
4003                                 break;
4004                         case ACT_BA_COLD_1:
4005                         case ACT_BA_FIRE_1:
4006                         case ACT_TERROR:
4007                         case ACT_PROT_EVIL:
4008                         case ACT_ID_PLAIN:
4009                         case ACT_REST_LIFE:
4010                         case ACT_SPEED:
4011                         case ACT_BANISH_EVIL:
4012                                 lev = 40;
4013                                 break;
4014                         case ACT_DRAIN_2:
4015                         case ACT_VAMPIRE_1:
4016                         case ACT_BO_MISS_2:
4017                         case ACT_BA_FIRE_2:
4018                         case ACT_WHIRLWIND:
4019                         case ACT_CHARM_ANIMAL:
4020                         case ACT_SUMMON_ANIMAL:
4021                         case ACT_DISP_EVIL:
4022                         case ACT_DISP_GOOD:
4023                         case ACT_XTRA_SPEED:
4024                         case ACT_DETECT_XTRA:
4025                         case ACT_ID_FULL:
4026                                 lev = 50;
4027                                 break;
4028                         case ACT_VAMPIRE_2:
4029                         case ACT_BA_COLD_3:
4030                         case ACT_BA_ELEC_3:
4031                         case ACT_GENOCIDE:
4032                         case ACT_CHARM_UNDEAD:
4033                         case ACT_CHARM_OTHER:
4034                         case ACT_SUMMON_PHANTOM:
4035                         case ACT_SUMMON_ELEMENTAL:
4036                         case ACT_RUNE_EXPLO:
4037                                 lev = 60;
4038                                 break;
4039                         case ACT_MASS_GENO:
4040                         case ACT_CHARM_ANIMALS:
4041                         case ACT_CHARM_OTHERS:
4042                         case ACT_CURE_700:
4043                         case ACT_RUNE_PROT:
4044                         case ACT_ALCHEMY:
4045                         case ACT_REST_ALL:
4046                                 lev = 70;
4047                                 break;
4048                         case ACT_CALL_CHAOS:
4049                         case ACT_ROCKET:
4050                         case ACT_BA_MISS_3:
4051                         case ACT_CURE_1000:
4052                         case ACT_DIM_DOOR:
4053                         case ACT_SUMMON_UNDEAD:
4054                         case ACT_SUMMON_DEMON:
4055                                 lev = 80;
4056                                 break;
4057                         case ACT_WRAITH:
4058                         case ACT_INVULN:
4059                                 lev = 100;
4060                                 break;
4061                         default:
4062                                 lev = 0;
4063                 }
4064         }
4065         else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
4066
4067         /* Base chance of success */
4068         chance = p_ptr->skill_dev;
4069
4070         /* Confusion hurts skill */
4071         if (p_ptr->confused) chance = chance / 2;
4072
4073         fail = lev+5;
4074         if (chance > fail) fail -= (chance - fail)*2;
4075         else chance -= (fail - chance)*2;
4076         if (fail < USE_DEVICE) fail = USE_DEVICE;
4077         if (chance < USE_DEVICE) chance = USE_DEVICE;
4078
4079         if (world_player)
4080         {
4081                 if (flush_failure) flush();
4082 #ifdef JP
4083                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
4084 #else
4085                 msg_print("It shows no reaction.");
4086 #endif
4087
4088                 sound(SOUND_FAIL);
4089                 return;
4090         }
4091
4092         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
4093         else if (chance > fail)
4094         {
4095                 if (randint0(chance*2) < fail) success = FALSE;
4096                 else success = TRUE;
4097         }
4098         else
4099         {
4100                 if (randint0(fail*2) < chance) success = TRUE;
4101                 else success = FALSE;
4102         }
4103
4104         /* Roll for usage */
4105         if (!success)
4106         {
4107                 if (flush_failure) flush();
4108 #ifdef JP
4109                 msg_print("¤¦¤Þ¤¯»ÏÆ°¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Ê¤«¤Ã¤¿¡£");
4110 #else
4111                 msg_print("You failed to activate it properly.");
4112 #endif
4113
4114                 sound(SOUND_FAIL);
4115                 return;
4116         }
4117
4118         /* Check the recharge */
4119         if (o_ptr->timeout)
4120         {
4121 #ifdef JP
4122                 msg_print("¤½¤ì¤ÏÈù¤«¤Ë²»¤òΩ¤Æ¡¢µ±¤­¡¢¾Ã¤¨¤¿...");
4123 #else
4124                 msg_print("It whines, glows and fades...");
4125 #endif
4126
4127                 return;
4128         }
4129
4130
4131         /* Activate the artifact */
4132 #ifdef JP
4133         msg_print("»ÏÆ°¤µ¤»¤¿...");
4134 #else
4135         msg_print("You activate it...");
4136 #endif
4137
4138
4139         /* Sound */
4140         sound(SOUND_ZAP);
4141
4142
4143         if (o_ptr->art_name && o_ptr->xtra2)
4144         {
4145                 (void)activate_random_artifact(o_ptr);
4146
4147                 /* Window stuff */
4148                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4149
4150                 /* Success */
4151                 return;
4152         }
4153
4154         /* Artifacts */
4155         else if (o_ptr->name1)
4156         {
4157                 /* Choose effect */
4158                 switch (o_ptr->name1)
4159                 {
4160                         case ART_GALADRIEL:
4161                         {
4162 #ifdef JP
4163                                 msg_print("ààÎÜÉÓ¤«¤éÀ¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
4164 #else
4165                                 msg_print("The phial wells with clear light...");
4166 #endif
4167
4168                                 lite_area(damroll(2, 15), 3);
4169                                 o_ptr->timeout = randint0(10) + 10;
4170                                 break;
4171                         }
4172
4173                         case ART_ELENDIL:
4174                         {
4175 #ifdef JP
4176                                 msg_print("À±¤¬âÁ¤·¤¯µ±¤¤¤¿...");
4177 #else
4178                                 msg_print("The star shines brightly...");
4179 #endif
4180
4181                                 map_area(DETECT_RAD_MAP);
4182                                 lite_area(damroll(2, 15), 3);
4183                                 o_ptr->timeout = randint0(50) + 50;
4184                                 break;
4185                         }
4186
4187                         case ART_JUDGE:
4188                         {
4189 #ifdef JP
4190 msg_print("¤½¤ÎÊõÀФÏÀÖ¤¯ÌÀ¤ë¤¯¸÷¤Ã¤¿¡ª");
4191 #else
4192                                 msg_print("The Jewel flashes bright red!");
4193 #endif
4194
4195                                 chg_virtue(V_KNOWLEDGE, 1);
4196                                 chg_virtue(V_ENLIGHTEN, 1);
4197                                 wiz_lite(FALSE, FALSE);
4198 #ifdef JP
4199 msg_print("¤½¤ÎÊõÀФϤ¢¤Ê¤¿¤ÎÂÎÎϤòÃ¥¤Ã¤¿...");
4200 take_hit(DAMAGE_LOSELIFE, damroll(3,8), "¿³È½¤ÎÊõÀÐ", -1);
4201 #else
4202                                 msg_print("The Jewel drains your vitality...");
4203                                 take_hit(DAMAGE_LOSELIFE, damroll(3, 8), "the Jewel of Judgement", -1);
4204 #endif
4205
4206                                 (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
4207                                 (void)detect_doors(DETECT_RAD_DEFAULT);
4208                                 (void)detect_stairs(DETECT_RAD_DEFAULT);
4209
4210 #ifdef JP
4211 if (get_check("µ¢´Ô¤ÎÎϤò»È¤¤¤Þ¤¹¤«¡©"))
4212 #else
4213                                 if (get_check("Activate recall? "))
4214 #endif
4215
4216                                 {
4217                                         (void)word_of_recall();
4218                                 }
4219
4220                                 o_ptr->timeout = randint0(20) + 20;
4221                                 break;
4222                         }
4223
4224                         case ART_CARLAMMAS:
4225                         {
4226 #ifdef JP
4227                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
4228 #else
4229                                 msg_print("The amulet lets out a shrill wail...");
4230 #endif
4231
4232                                 k = 3 * p_ptr->lev;
4233                                 (void)set_protevil(randint1(25) + k, FALSE);
4234                                 o_ptr->timeout = randint0(225) + 225;
4235                                 break;
4236                         }
4237
4238                         case ART_INGWE:
4239                         {
4240 #ifdef JP
4241                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
4242 #else
4243                                 msg_print("The amulet floods the area with goodness...");
4244 #endif
4245
4246                                 dispel_evil(p_ptr->lev * 5);
4247                                 o_ptr->timeout = randint0(200) + 200;
4248                                 break;
4249                         }
4250
4251                         case ART_YATA:
4252                         {
4253 #ifdef JP
4254                                 msg_print("¶À¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
4255 #else
4256                                 msg_print("The mirror floods the area with goodness...");
4257 #endif
4258
4259                                 dispel_evil(p_ptr->lev * 5);
4260                                 o_ptr->timeout = randint0(200) + 200;
4261                                 break;
4262                         }
4263
4264                         case ART_FRAKIR:
4265                         {
4266 #ifdef JP
4267 msg_print("¤¢¤Ê¤¿¤Ï¥Õ¥é¥­¥¢¤ËŨ¤òÄù¤á»¦¤¹¤è¤¦Ì¿¤¸¤¿¡£");
4268 #else
4269                                 msg_print("You order Frakir to strangle your opponent.");
4270 #endif
4271
4272                                 if (!get_aim_dir(&dir)) return;
4273                                 if (drain_life(dir, 100))
4274                                 o_ptr->timeout = randint0(100) + 100;
4275                                 break;
4276                         }
4277
4278                         case ART_TULKAS:
4279                         {
4280 #ifdef JP
4281                                 msg_print("»ØÎؤÏÌÀ¤ë¤¯µ±¤¤¤¿...");
4282 #else
4283                                 msg_print("The ring glows brightly...");
4284 #endif
4285
4286                                 (void)set_fast(randint1(75) + 75, FALSE);
4287                                 o_ptr->timeout = randint0(150) + 150;
4288                                 break;
4289                         }
4290
4291                         case ART_NARYA:
4292                         {
4293 #ifdef JP
4294                                 msg_print("»ØÎؤϿ¼¹È¤Ëµ±¤¤¤¿...");
4295 #else
4296                                 msg_print("The ring glows deep red...");
4297 #endif
4298
4299                                 if (!get_aim_dir(&dir)) return;
4300                                 fire_ball(GF_FIRE, dir, 300, 3);
4301                                 o_ptr->timeout = randint0(225) + 225;
4302                                 break;
4303                         }
4304
4305                         case ART_NENYA:
4306                         {
4307 #ifdef JP
4308                                 msg_print("»ØÎؤÏÇò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4309 #else
4310                                 msg_print("The ring glows bright white...");
4311 #endif
4312
4313                                 if (!get_aim_dir(&dir)) return;
4314                                 fire_ball(GF_COLD, dir, 400, 3);
4315                                 o_ptr->timeout = randint0(325) + 325;
4316                                 break;
4317                         }
4318
4319                         case ART_VILYA:
4320                         case ART_GOURYU:
4321                         {
4322 #ifdef JP
4323                                 msg_format("%s¤Ï¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_VILYA ? "»ØÎØ" : "¥½¡¼¥É");
4324 #else
4325                                 msg_format("The %s glows deep blue...", o_ptr->name1 == ART_VILYA ? "ring" : "sword");
4326 #endif
4327
4328                                 if (!get_aim_dir(&dir)) return;
4329                                 fire_ball(GF_ELEC, dir, 500, 3);
4330                                 o_ptr->timeout = randint0(425) + 425;
4331                                 break;
4332                         }
4333
4334                         case ART_POWER:
4335                         case ART_AHO:
4336                         {
4337 #ifdef JP
4338                                 msg_print("»ØÎؤϼ¿¹õ¤Ëµ±¤¤¤¿...");
4339 #else
4340                                 msg_print("The ring glows intensely black...");
4341 #endif
4342
4343                                 if (!get_aim_dir(&dir)) return;
4344                                 ring_of_power(dir);
4345                                 o_ptr->timeout = randint0(450) + 450;
4346                                 break;
4347                         }
4348
4349                         case ART_RAZORBACK:
4350                         {
4351                                 int num = damroll(5, 3);
4352                                 int y, x;
4353                                 int attempts;
4354
4355 #ifdef JP
4356                                 msg_print("³»¤¬°ðºÊ¤Çʤ¤ï¤ì¤¿...");
4357 #else
4358                                 msg_print("Your armor is surrounded by lightning...");
4359 #endif
4360
4361
4362                                 for (k = 0; k < num; k++)
4363                                 {
4364                 attempts = 1000;
4365
4366                                         while(attempts--)
4367                                         {
4368                                                 scatter(&y, &x, py, px, 4, 0);
4369
4370                                                 if (!cave_floor_bold(y, x)) continue;
4371
4372                                                 if ((y != py) || (x != px)) break;
4373                                         }
4374
4375                                         project(0, 3, y, x, 150, GF_ELEC,
4376                                                           (PROJECT_THRU | PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
4377                                 }
4378
4379                                 o_ptr->timeout = 1000;
4380                                 break;
4381                         }
4382
4383                         case ART_BLADETURNER:
4384                         {
4385                                 if (!get_aim_dir(&dir)) return;
4386 #ifdef JP
4387                                 msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
4388 #else
4389                                 msg_print("You breathe the elements.");
4390 #endif
4391
4392                                 fire_ball(GF_MISSILE, dir, 300, 4);
4393 #ifdef JP
4394                                 msg_print("³»¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...");
4395 #else
4396                                 msg_print("Your armor glows many colours...");
4397 #endif
4398
4399                                 (void)set_afraid(0);
4400                                 (void)set_hero(randint1(50) + 50, FALSE);
4401                                 (void)hp_player(10);
4402                                 (void)set_blessed(randint1(50) + 50, FALSE);
4403                                 (void)set_oppose_acid(randint1(50) + 50, FALSE);
4404                                 (void)set_oppose_elec(randint1(50) + 50, FALSE);
4405                                 (void)set_oppose_fire(randint1(50) + 50, FALSE);
4406                                 (void)set_oppose_cold(randint1(50) + 50, FALSE);
4407                                 (void)set_oppose_pois(randint1(50) + 50, FALSE);
4408                                 o_ptr->timeout = 400;
4409                                 break;
4410                         }
4411
4412                         case ART_SOULKEEPER:
4413                         {
4414 #ifdef JP
4415                                 msg_print("³»¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4416                                 msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
4417 #else
4418                                 msg_print("Your armor glows a bright white...");
4419                                 msg_print("You feel much better...");
4420 #endif
4421
4422                                 (void)hp_player(1000);
4423                                 (void)set_cut(0);
4424                                 o_ptr->timeout = 888;
4425                                 break;
4426                         }
4427
4428                         case ART_LOHENGRIN:
4429                         {
4430 #ifdef JP
4431 msg_print("Å·¹ñ¤Î²Î¤¬Ê¹¤³¤¨¤ë...");
4432 #else
4433                                 msg_print("A heavenly choir sings...");
4434 #endif
4435
4436                                 (void)set_poisoned(0);
4437                                 (void)set_cut(0);
4438                                 (void)set_stun(0);
4439                                 (void)set_confused(0);
4440                                 (void)set_blind(0);
4441                                 (void)set_hero(randint1(25) + 25, FALSE);
4442                                 (void)hp_player(777);
4443                                 o_ptr->timeout = 300;
4444                                 break;
4445                         }
4446
4447                         case ART_JULIAN:
4448                         {
4449 #ifdef JP
4450                                 msg_print("³»¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4451 #else
4452                                 msg_print("Your armor glows deep blue...");
4453 #endif
4454
4455                                 (void)symbol_genocide(200, TRUE);
4456                                 o_ptr->timeout = 500;
4457                                 break;
4458                         }
4459
4460                         case ART_CASPANION:
4461                         {
4462 #ifdef JP
4463                                 msg_print("³»¤¬ÀÖ¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4464 #else
4465                                 msg_print("Your armor glows bright red...");
4466 #endif
4467
4468                                 destroy_doors_touch();
4469                                 o_ptr->timeout = 10;
4470                                 break;
4471                         }
4472
4473                         case ART_DOR:
4474                         case ART_TERROR:
4475                         case ART_STONEMASK:
4476                         {
4477                                 turn_monsters(40 + p_ptr->lev);
4478                                 o_ptr->timeout = 3 * (p_ptr->lev + 10);
4479
4480                                 break;
4481                         }
4482
4483                         case ART_HOLHENNETH:
4484                         {
4485 #ifdef JP
4486                                 msg_print("¥Ø¥ë¥á¥Ã¥È¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4487                                 msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
4488 #else
4489                                 msg_print("Your helm glows bright white...");
4490                                 msg_print("An image forms in your mind...");
4491 #endif
4492
4493                                 detect_all(DETECT_RAD_DEFAULT);
4494                                 o_ptr->timeout = randint0(55) + 55;
4495                                 break;
4496                         }
4497
4498                         case ART_AMBER:
4499                         {
4500 #ifdef JP
4501                                 msg_print("²¦´§¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4502                                 msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
4503 #else
4504                                 msg_print("Your crown glows deep blue...");
4505                                 msg_print("You feel a warm tingling inside...");
4506 #endif
4507
4508                                 (void)hp_player(700);
4509                                 (void)set_cut(0);
4510                                 o_ptr->timeout = 250;
4511                                 break;
4512                         }
4513
4514                         case ART_COLLUIN:
4515                         case ART_SEIRYU:
4516                         {
4517 #ifdef JP
4518                                 msg_format("%s¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_COLLUIN ? "¥¯¥í¡¼¥¯" : "³»");
4519 #else
4520                                 msg_format("Your %s glows many colours...", o_ptr->name1 == ART_COLLUIN ? "cloak" : "armor");
4521 #endif
4522
4523                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
4524                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
4525                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
4526                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
4527                                 (void)set_oppose_pois(randint1(20) + 20, FALSE);
4528                                 o_ptr->timeout = 111;
4529                                 break;
4530                         }
4531
4532                         case ART_HOLCOLLETH:
4533                         {
4534 #ifdef JP
4535                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4536 #else
4537                                 msg_print("Your cloak glows deep blue...");
4538 #endif
4539
4540                                 sleep_monsters_touch();
4541                                 o_ptr->timeout = 55;
4542                                 break;
4543                         }
4544
4545                         case ART_THINGOL:
4546                         {
4547 #ifdef JP
4548                                 msg_print("¥¯¥í¡¼¥¯¤¬²«¿§¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4549 #else
4550                                 msg_print("Your cloak glows bright yellow...");
4551 #endif
4552
4553                                 recharge(130);
4554                                 o_ptr->timeout = 70;
4555                                 break;
4556                         }
4557
4558                         case ART_COLANNON:
4559                         {
4560 #ifdef JP
4561                                 msg_print("¥¯¥í¡¼¥¯¤¬ÊÕ¤ê¤Î¶õ´Ö¤ò¤æ¤¬¤Þ¤»¤¿...");
4562 #else
4563                                 msg_print("Your cloak twists space around you...");
4564 #endif
4565
4566                                 teleport_player(100);
4567                                 o_ptr->timeout = 45;
4568                                 break;
4569                         }
4570
4571                         case ART_LUTHIEN:
4572                         {
4573 #ifdef JP
4574                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4575 #else
4576                                 msg_print("Your cloak glows a deep red...");
4577 #endif
4578
4579                                 restore_level();
4580                                 o_ptr->timeout = 450;
4581                                 break;
4582                         }
4583
4584                         case ART_CAMMITHRIM:
4585                         {
4586 #ifdef JP
4587                                 msg_print("¥°¥í¡¼¥Ö¤¬âÁ¤·¤¤¤¯¤é¤¤¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4588 #else
4589                                 msg_print("Your gloves glow extremely brightly...");
4590 #endif
4591
4592                                 if (!get_aim_dir(&dir)) return;
4593                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
4594                                 o_ptr->timeout = 2;
4595                                 break;
4596                         }
4597
4598                         case ART_PAURHACH:
4599                         {
4600 #ifdef JP
4601                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4602 #else
4603                                 msg_print("Your gauntlets are covered in fire...");
4604 #endif
4605
4606                                 if (!get_aim_dir(&dir)) return;
4607                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4608                                 o_ptr->timeout = randint0(8) + 8;
4609                                 break;
4610                         }
4611
4612                         case ART_PAURNIMMEN:
4613                         {
4614 #ifdef JP
4615                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4616 #else
4617                                 msg_print("Your gauntlets are covered in frost...");
4618 #endif
4619
4620                                 if (!get_aim_dir(&dir)) return;
4621                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4622                                 o_ptr->timeout = randint0(7) + 7;
4623                                 break;
4624                         }
4625
4626                         case ART_PAURAEGEN:
4627                         {
4628 #ifdef JP
4629                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4630 #else
4631                                 msg_print("Your gauntlets are covered in sparks...");
4632 #endif
4633
4634                                 if (!get_aim_dir(&dir)) return;
4635                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4636                                 o_ptr->timeout = randint0(5) + 5;
4637                                 break;
4638                         }
4639
4640                         case ART_PAURNEN:
4641                         {
4642 #ifdef JP
4643                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬»À¤Ëʤ¤ï¤ì¤¿...");
4644 #else
4645                                 msg_print("Your gauntlets are covered in acid...");
4646 #endif
4647
4648                                 if (!get_aim_dir(&dir)) return;
4649                                 fire_bolt(GF_ACID, dir, damroll(5, 8));
4650                                 o_ptr->timeout = randint0(6) + 6;
4651                                 break;
4652                         }
4653
4654                         case ART_FINGOLFIN:
4655                         {
4656 #ifdef JP
4657                                 msg_print("¥»¥¹¥¿¥¹¤ËËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
4658 #else
4659                                 msg_print("Your cesti grows magical spikes...");
4660 #endif
4661
4662                                 if (!get_aim_dir(&dir)) return;
4663                                 fire_bolt(GF_ARROW, dir, 150);
4664                                 o_ptr->timeout = randint0(90) + 90;
4665                                 break;
4666                         }
4667
4668                         case ART_FEANOR:
4669                         {
4670 #ifdef JP
4671                                 msg_print("¥Ö¡¼¥Ä¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4672 #else
4673                                 msg_print("Your boots glow bright green...");
4674 #endif
4675
4676                                 (void)set_fast(randint1(20) + 20, FALSE);
4677                                 o_ptr->timeout = 200;
4678                                 break;
4679                         }
4680
4681                         case ART_FLORA:
4682                         {
4683 #ifdef JP
4684                                 msg_print("¥Ö¡¼¥Ä¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4685 #else
4686                                 msg_print("Your boots glow deep blue...");
4687 #endif
4688
4689                                 (void)set_afraid(0);
4690                                 (void)set_poisoned(0);
4691                                 o_ptr->timeout = 5;
4692                                 break;
4693                         }
4694
4695                         case ART_NARTHANC:
4696                         {
4697 #ifdef JP
4698                                 msg_print("¥À¥¬¡¼¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4699 #else
4700                                 msg_print("Your dagger is covered in fire...");
4701 #endif
4702
4703                                 if (!get_aim_dir(&dir)) return;
4704                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4705                                 o_ptr->timeout = randint0(8) + 8;
4706                                 break;
4707                         }
4708
4709                         case ART_NIMTHANC:
4710                         {
4711 #ifdef JP
4712                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4713 #else
4714                                 msg_print("Your dagger is covered in frost...");
4715 #endif
4716
4717                                 if (!get_aim_dir(&dir)) return;
4718                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4719                                 o_ptr->timeout = randint0(7) + 7;
4720                                 break;
4721                         }
4722
4723                         case ART_DETHANC:
4724                         {
4725 #ifdef JP
4726                                 msg_print("¥À¥¬¡¼¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4727 #else
4728                                 msg_print("Your dagger is covered in sparks...");
4729 #endif
4730
4731                                 if (!get_aim_dir(&dir)) return;
4732                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4733                                 o_ptr->timeout = randint0(5) + 5;
4734                                 break;
4735                         }
4736
4737                         case ART_RILIA:
4738                         {
4739 #ifdef JP
4740                                 msg_print("¥À¥¬¡¼¤¬¿¼¤¤Îп§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4741 #else
4742                                 msg_print("Your dagger throbs deep green...");
4743 #endif
4744
4745                                 if (!get_aim_dir(&dir)) return;
4746                                 fire_ball(GF_POIS, dir, 12, 3);
4747                                 o_ptr->timeout = randint0(4) + 4;
4748                                 break;
4749                         }
4750
4751                         case ART_NUMAHOKO:
4752                         {
4753 #ifdef JP
4754                                 msg_print("Ì·¤¬¿¼¤¤ÀÄ¿§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4755 #else
4756                                 msg_print("Your dagger throbs deep blue...");
4757 #endif
4758
4759                                 if (!get_aim_dir(&dir)) return;
4760                                 fire_ball(GF_WATER, dir, 200, 3);
4761                                 o_ptr->timeout = 250;
4762                                 break;
4763                         }
4764
4765                         case ART_FIONA:
4766                         {
4767 #ifdef JP
4768                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4769 #else
4770                                 msg_print("Your dagger is covered in frost...");
4771 #endif
4772
4773                                 if (!get_aim_dir(&dir)) return;
4774                                 fire_ball(GF_COLD, dir, 48, 2);
4775                                 o_ptr->timeout = randint0(5) + 5;
4776                                 break;
4777                         }
4778
4779                         case ART_KUSANAGI:
4780                         case ART_WEREWINDLE:
4781                         {
4782                                 switch (randint1(13))
4783                                 {
4784                                 case 1: case 2: case 3: case 4: case 5:
4785                                         teleport_player(10);
4786                                         break;
4787                                 case 6: case 7: case 8: case 9: case 10:
4788                                         teleport_player(222);
4789                                         break;
4790                                 case 11: case 12:
4791                                         (void)stair_creation();
4792                                         break;
4793                                 default:
4794 #ifdef JP
4795 if (get_check("¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
4796 #else
4797                                         if (get_check("Leave this level? "))
4798 #endif
4799
4800                                         {
4801                                                 if (autosave_l) do_cmd_save_game(TRUE);
4802
4803                                                 /* Leaving */
4804                                                 p_ptr->leaving = TRUE;
4805                                         }
4806                                 }
4807                                 o_ptr->timeout = 35;
4808                                 break;
4809                         }
4810
4811                         case ART_KAMUI:
4812                         {
4813                                 teleport_player(222);
4814                                 o_ptr->timeout = 25;
4815                                 break;
4816                         }
4817
4818                         case ART_RINGIL:
4819                         {
4820 #ifdef JP
4821                                 msg_print("¥½¡¼¥É¤¬ÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
4822 #else
4823                                 msg_print("Your sword glows an intense blue...");
4824 #endif
4825
4826                                 if (!get_aim_dir(&dir)) return;
4827                                 fire_ball(GF_COLD, dir, 100, 2);
4828                                 o_ptr->timeout = 200;
4829                                 break;
4830                         }
4831
4832                         case ART_DAWN:
4833                         {
4834 #ifdef JP
4835 msg_print("¶Ç¤Î»ÕÃĤò¾¤´­¤·¤¿¡£");
4836 #else
4837                                 msg_print("You summon the Legion of the Dawn.");
4838 #endif
4839
4840                                 (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET));
4841                                 o_ptr->timeout = 500 + randint1(500);
4842                                 break;
4843                         }
4844
4845                         case ART_ANDURIL:
4846                         {
4847 #ifdef JP
4848                                 msg_print("¥½¡¼¥É¤¬ÀÖ¤¯·ã¤·¤¯µ±¤¤¤¿...");
4849 #else
4850                                 msg_print("Your sword glows an intense red...");
4851 #endif
4852
4853                                 if (!get_aim_dir(&dir)) return;
4854                                 fire_ball(GF_FIRE, dir, 72, 2);
4855                                 o_ptr->timeout = 400;
4856                                 break;
4857                         }
4858
4859                         case ART_THEODEN:
4860                         {
4861 #ifdef JP
4862                                  msg_print("¥¢¥Ã¥¯¥¹¤Î¿Ï¤¬¹õ¤¯µ±¤¤¤¿...");
4863 #else
4864                                 msg_print("Your axe blade glows black...");
4865 #endif
4866
4867                                 if (!get_aim_dir(&dir)) return;
4868                                 drain_life(dir, 120);
4869                                 o_ptr->timeout = 400;
4870                                 break;
4871                         }
4872
4873                         case ART_RUNESPEAR:
4874                         {
4875 #ifdef JP
4876 msg_print("¤¢¤Ê¤¿¤ÎÁä¤ÏÅŵ¤¤Ç¥¹¥Ñ¡¼¥¯¤·¤Æ¤¤¤ë...");
4877 #else
4878                                 msg_print("Your spear crackles with electricity...");
4879 #endif
4880
4881                                 if (!get_aim_dir(&dir)) return;
4882                                 fire_ball(GF_ELEC, dir, 100, 3);
4883                                 o_ptr->timeout = 200;
4884                                 break;
4885                         }
4886
4887                         case ART_AEGLOS:
4888                         {
4889 #ifdef JP
4890                                 msg_print("¥¹¥Ô¥¢¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4891 #else
4892                                 msg_print("Your spear glows a bright white...");
4893 #endif
4894
4895                                 if (!get_aim_dir(&dir)) return;
4896                                 fire_ball(GF_COLD, dir, 100, 3);
4897                                 o_ptr->timeout = 200;
4898                                 break;
4899                         }
4900
4901                         case ART_DESTINY:
4902                         {
4903 #ifdef JP
4904                                 msg_print("¥¹¥Ô¥¢¤¬¸ÝÆ°¤·¤¿...");
4905 #else
4906                                 msg_print("Your spear pulsates...");
4907 #endif
4908
4909                                 if (!get_aim_dir(&dir)) return;
4910                                 wall_to_mud(dir);
4911                                 o_ptr->timeout = 5;
4912                                 break;
4913                         }
4914
4915                         case ART_NAIN:
4916                         {
4917 #ifdef JP
4918                                 msg_print("¤Ä¤ë¤Ï¤·¤¬¸ÝÆ°¤·¤¿...");
4919 #else
4920                                 msg_print("Your mattock pulsates...");
4921 #endif
4922
4923                                 if (!get_aim_dir(&dir)) return;
4924                                 wall_to_mud(dir);
4925                                 o_ptr->timeout = 2;
4926                                 break;
4927                         }
4928
4929                         case ART_EONWE:
4930                         {
4931 #ifdef JP
4932                                 msg_print("¥¢¥Ã¥¯¥¹¤«¤é¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
4933 #else
4934                                 msg_print("Your axe lets out a long, shrill note...");
4935 #endif
4936
4937                                 (void)mass_genocide(200, TRUE);
4938                                 o_ptr->timeout = 1000;
4939                                 break;
4940                         }
4941
4942                         case ART_LOTHARANG:
4943                         {
4944 #ifdef JP
4945                                 msg_print("¥Ð¥È¥ë¡¦¥¢¥Ã¥¯¥¹¤¬¿¼»ç¤Î¸÷¤òÊü¼Í¤·¤¿...");
4946 #else
4947                                 msg_print("Your battle axe radiates deep purple...");
4948 #endif
4949
4950                                 hp_player(damroll(4, 8));
4951                                 (void)set_cut((p_ptr->cut / 2) - 50);
4952                                 o_ptr->timeout = randint0(3) + 3;
4953                                 break;
4954                         }
4955
4956                         case ART_ULMO:
4957                         {
4958 #ifdef JP
4959                                 msg_print("¥È¥é¥¤¥Ç¥ó¥È¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4960 #else
4961                                 msg_print("Your trident glows deep red...");
4962 #endif
4963
4964                                 if (!get_aim_dir(&dir)) return;
4965                                 teleport_monster(dir);
4966                                 o_ptr->timeout = 150;
4967                                 break;
4968                         }
4969
4970                         case ART_AVAVIR:
4971                         {
4972 #ifdef JP
4973                                 msg_print("Âç³ù¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
4974 #else
4975                                 msg_print("Your scythe glows soft white...");
4976 #endif
4977                                 if (!word_of_recall()) return;
4978                                 o_ptr->timeout = 200;
4979                                 break;
4980                         }
4981
4982                         case ART_MAGATAMA:
4983                         {
4984 #ifdef JP
4985                                 msg_print("¸û¶Ì¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
4986 #else
4987                                 msg_print("Your scythe glows soft white...");
4988 #endif
4989                                 if (!word_of_recall()) return;
4990                                 o_ptr->timeout = 200;
4991                                 break;
4992                         }
4993
4994                         case ART_TOTILA:
4995                         {
4996 #ifdef JP
4997                                 msg_print("¥Õ¥ì¥¤¥ë¤¬ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤¿...");
4998 #else
4999                                 msg_print("Your flail glows in scintillating colours...");
5000 #endif
5001
5002                                 if (!get_aim_dir(&dir)) return;
5003                                 confuse_monster(dir, 20);
5004                                 o_ptr->timeout = 15;
5005                                 break;
5006                         }
5007
5008                         case ART_FIRESTAR:
5009                         {
5010 #ifdef JP
5011                                 msg_print("¥â¡¼¥Ë¥ó¥°¥¹¥¿¡¼¤«¤é±ê¤¬¿á¤­½Ð¤·¤¿...");
5012 #else
5013                                 msg_print("Your morning star rages in fire...");
5014 #endif
5015
5016                                 if (!get_aim_dir(&dir)) return;
5017                                 fire_ball(GF_FIRE, dir, 72, 3);
5018                                 o_ptr->timeout = 100;
5019                                 break;
5020                         }
5021
5022                         case ART_GOTHMOG:
5023                         {
5024 #ifdef JP
5025                                 msg_print("¥à¥Á¤¬¿¼¤¤ÀÖ¿§¤Ëµ±¤¤¤¿...");
5026 #else
5027                                 msg_print("Your whip glows deep red...");
5028 #endif
5029
5030                                 if (!get_aim_dir(&dir)) return;
5031                                 fire_ball(GF_FIRE, dir, 120, 3);
5032                                 o_ptr->timeout = 15;
5033                                 break;
5034                         }
5035
5036                         case ART_TARATOL:
5037                         {
5038 #ifdef JP
5039                                 msg_print("¥á¥¤¥¹¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
5040 #else
5041                                 msg_print("Your mace glows bright green...");
5042 #endif
5043
5044                                 (void)set_fast(randint1(20) + 20, FALSE);
5045                                 o_ptr->timeout = randint0(100) + 100;
5046                                 break;
5047                         }
5048
5049                         case ART_ERIRIL:
5050                         {
5051 #ifdef JP
5052                                 msg_print("¥¯¥©¡¼¥¿¡¼¥¹¥¿¥Ã¥Õ¤¬²«¿§¤¯µ±¤¤¤¿...");
5053 #else
5054                                 msg_print("Your quarterstaff glows yellow...");
5055 #endif
5056
5057                                 if (!ident_spell(FALSE)) return;
5058                                 o_ptr->timeout = 10;
5059                                 break;
5060                         }
5061
5062                         case ART_GANDALF:
5063                         {
5064 #ifdef JP
5065                                 msg_print("¾ó¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
5066 #else
5067                                 msg_print("Your quarterstaff glows brightly...");
5068 #endif
5069
5070                                 detect_all(DETECT_RAD_DEFAULT);
5071                                 probing();
5072                                 identify_fully(FALSE);
5073                                 o_ptr->timeout = 1000;
5074                                 break;
5075                         }
5076
5077                         case ART_TURMIL:
5078                         {
5079 #ifdef JP
5080                                 msg_print("¥Ï¥ó¥Þ¡¼¤¬Çò¤¯µ±¤¤¤¿...");
5081 #else
5082                                 msg_print("Your hammer glows white...");
5083 #endif
5084
5085                                 if (!get_aim_dir(&dir)) return;
5086                                 drain_life(dir, 90);
5087                                 o_ptr->timeout = 70;
5088                                 break;
5089                         }
5090
5091                         case ART_BRAND:
5092                         {
5093 #ifdef JP
5094                                 msg_print("¥¯¥í¥¹¥Ü¥¦¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
5095 #else
5096                                 msg_print("Your crossbow glows deep red...");
5097 #endif
5098
5099                                 (void)brand_bolts();
5100                                 o_ptr->timeout = 999;
5101                                 break;
5102                         }
5103                         case ART_CRIMSON:
5104                         {
5105                                 int num = 1;
5106                                 int i;
5107                                 int flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
5108                                 int tx, ty;
5109 #ifdef JP
5110                                 msg_print("¤»¤Ã¤«¤¯¤À¤«¤é¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¤Ö¤Ã¤Ñ¤Ê¤¹¤¼¡ª");
5111 #else
5112                                 msg_print("I'll fire CRIMSON! SEKKAKUDAKARA!");
5113 #endif
5114
5115                                 if (!get_aim_dir(&dir)) return;
5116
5117                                 /* Use the given direction */
5118                                 tx = px + 99 * ddx[dir];
5119                                 ty = py + 99 * ddy[dir];
5120
5121                                 /* Hack -- Use an actual "target" */
5122                                 if ((dir == 5) && target_okay())
5123                                 {
5124                                         tx = target_col;
5125                                         ty = target_row;
5126                                 }
5127
5128                                 if (p_ptr->pclass == CLASS_ARCHER)
5129                                 {
5130                                         /* Extra shot at level 10 */
5131                                         if (p_ptr->lev >= 10) num++;
5132
5133                                         /* Extra shot at level 30 */
5134                                         if (p_ptr->lev >= 30) num++;
5135
5136                                         /* Extra shot at level 45 */
5137                                         if (p_ptr->lev >= 45) num++;
5138                                 }
5139
5140                                 for (i = 0; i < num; i++)
5141                                         project(0, p_ptr->lev/20+1, ty, tx, p_ptr->lev*p_ptr->lev*6/50, GF_ROCKET, flg, -1);
5142                                 o_ptr->timeout = 15;
5143                                 break;
5144                         }
5145                         case ART_PALANTIR:
5146                         {
5147                                 monster_type *m_ptr;
5148                                 monster_race *r_ptr;
5149                                 int i;
5150
5151 #ifdef JP
5152                                 msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
5153 #else
5154                                 msg_print("Some strange places show up in your mind. And you see ...");
5155 #endif
5156
5157                                 /* Process the monsters (backwards) */
5158                                 for (i = m_max - 1; i >= 1; i--)
5159                                 {
5160                                         /* Access the monster */
5161                                         m_ptr = &m_list[i];
5162
5163                                         /* Ignore "dead" monsters */
5164                                         if (!m_ptr->r_idx) continue;
5165
5166                                         r_ptr = &r_info[m_ptr->r_idx];
5167
5168                                         if(r_ptr->flags1 & RF1_UNIQUE)
5169                                         {
5170 #ifdef JP
5171                                                 msg_format("%s¡¥ ",r_name + r_ptr->name);
5172 #else
5173                                                 msg_format("%s. ",r_name + r_ptr->name);
5174 #endif
5175                                         }
5176                                 }
5177                                 o_ptr->timeout = 200;
5178                                 break;
5179                         }
5180
5181                         case ART_STONE_LORE:
5182                         {
5183 #ifdef JP
5184                                 msg_print("ÀФ¬±£¤µ¤ì¤¿ÈëÌ©¤ò¼Ì¤·½Ð¤·¤¿¡¥¡¥¡¥");
5185 #else
5186                                 msg_print("The stone reveals hidden mysteries...");
5187 #endif
5188                                 if (!ident_spell(FALSE)) return;
5189
5190                                 if (mp_ptr->spell_book)
5191                                 {
5192                                         /* Sufficient mana */
5193                                         if (20 <= p_ptr->csp)
5194                                         {
5195                                                 /* Use some mana */
5196                                                 p_ptr->csp -= 20;
5197                                         }
5198
5199                                         /* Over-exert the player */
5200                                         else
5201                                         {
5202                                                 int oops = 20 - p_ptr->csp;
5203
5204                                                 /* No mana left */
5205                                                 p_ptr->csp = 0;
5206                                                 p_ptr->csp_frac = 0;
5207
5208                                                 /* Message */
5209 #ifdef JP
5210                                                 msg_print("ÀФòÀ©¸æ¤Ç¤­¤Ê¤¤¡ª");
5211 #else
5212                                                 msg_print("You are too weak to control the stone!");
5213 #endif
5214
5215                                                 /* Hack -- Bypass free action */
5216                                                 (void)set_paralyzed(p_ptr->paralyzed +
5217                                                         randint1(5 * oops + 1));
5218
5219                                                 /* Confusing. */
5220                                                 (void)set_confused(p_ptr->confused +
5221                                                         randint1(5 * oops + 1));
5222                                         }
5223
5224                                         /* Redraw mana */
5225                                         p_ptr->redraw |= (PR_MANA);
5226                                 }
5227
5228 #ifdef JP
5229                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "´í¸±¤ÊÈëÌ©", -1);
5230 #else
5231                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "perilous secrets", -1);
5232 #endif
5233
5234                                 /* Confusing. */
5235                                 if (one_in_(5)) (void)set_confused(p_ptr->confused +
5236                                         randint1(10));
5237
5238                                 /* Exercise a little care... */
5239                                 if (one_in_(20))
5240 #ifdef JP
5241                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "´í¸±¤ÊÈëÌ©", -1);
5242 #else
5243                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "perilous secrets", -1);
5244 #endif
5245                                 o_ptr->timeout = 0;
5246                                 break;
5247                         }
5248
5249                         case ART_BOROMIR:
5250                         {
5251                                 msg_print("You wind a mighty blast; your enemies tremble!");
5252                                 (void)turn_monsters((3 * p_ptr->lev / 2) + 10);
5253                                 o_ptr->timeout = randint0(40) + 40;
5254                                 break;
5255                         }
5256                         case ART_FARAMIR:
5257                         {
5258 #ifdef JP
5259                                 msg_print("¤¢¤Ê¤¿¤Ï³²Ãî¤ò°ìÁݤ·¤¿¡£");
5260 #else
5261                                 msg_print("You exterminate small life.");
5262 #endif
5263                                 (void)dispel_monsters(4);
5264                                 o_ptr->timeout = randint0(55) + 55;
5265                                 break;
5266                         }
5267
5268                         case ART_HIMRING:
5269                         {
5270 #ifdef JP
5271                                 msg_print("Æߤ¤²»¤¬ÊÕ¤ê¤òÊñ¤ß¤³¤ó¤À¡£");
5272 #else
5273                                 msg_print("A shrill wailing sound surrounds you.");
5274 #endif
5275                                 (void)set_protevil(randint1(25) + p_ptr->lev, FALSE);
5276                                 o_ptr->timeout = randint0(200) + 200;
5277                                 break;
5278                         }
5279
5280                         case ART_ICANUS:
5281                         {
5282
5283 #ifdef JP
5284                                 msg_print("¥í¡¼¥Ö¤¬½ã¿è¤ÊËâÎϤǿ̤¨¤¿¡£");
5285 #else
5286                                 msg_print("The robe pulsates with raw mana...");
5287 #endif
5288                                 if (!get_aim_dir(&dir)) return;
5289                                 fire_bolt(GF_MANA, dir, 120);
5290                                 o_ptr->timeout = randint0(120) + 120;
5291                                 break;
5292                         }
5293                         case ART_HURIN:
5294                         {
5295                                 (void)set_fast(randint1(50) + 50, FALSE);
5296                                 hp_player(10);
5297                                 set_afraid(0);
5298                                 set_hero(randint1(50) + 50, FALSE);
5299                                 o_ptr->timeout = randint0(200) + 100;
5300                                 break;
5301                         }
5302                         case ART_GIL_GALAD:
5303                         {
5304 #ifdef JP
5305                                 msg_print("¥·¡¼¥ë¥É¤¬âÁ¤·¤¤¸÷¤Çµ±¤¤¤¿¡¥¡¥¡¥");
5306 #else
5307                                 msg_print("Your shield gleams with blinding light...");
5308 #endif
5309                                 fire_ball(GF_LITE, 0, 300, 6);
5310                                 confuse_monsters(3 * p_ptr->lev / 2);
5311                                 o_ptr->timeout = 250;
5312                                 break;
5313                         }
5314                         case ART_YENDOR:
5315                         {
5316 #ifdef JP
5317                                 msg_print("¥«¡¼¥É¤¬Çò¤¯µ±¤¤¤¿¡¥¡¥¡¥");
5318 #else
5319                                 msg_print("Your card gleams with blinding light...");
5320 #endif
5321                                 if (!recharge(1000)) return;
5322                                 o_ptr->timeout = 200;
5323                                 break;
5324                         }
5325                         case ART_MURAMASA:
5326                         {
5327 #ifdef JP
5328                                 if (get_check("ËÜÅö¤Ë»È¤¤¤Þ¤¹¤«¡©"))
5329 #else
5330                                 if (get_check("Are you sure?!"))
5331 #endif
5332                                 {
5333 #ifdef JP
5334                                         msg_print("¼Àµ¤¬¿Ì¤¨¤¿¡¥¡¥¡¥");
5335 #else
5336                                         msg_print("The Muramasa pulsates...");
5337 #endif
5338                                         do_inc_stat(A_STR);
5339                                         if (one_in_(2))
5340                                         {
5341 #ifdef JP
5342                                                 msg_print("¼Àµ¤Ï²õ¤ì¤¿¡ª");
5343 #else
5344                                                 msg_print("The Muramasa is destroyed!");
5345 #endif
5346                                                 curse_weapon(TRUE, item);
5347                                         }
5348                                 }
5349                                 break;
5350                         }
5351                         case ART_FLY_STONE:
5352                         {
5353 #ifdef JP
5354                                 msg_print("ÀФ¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥");
5355 #else
5356                                 msg_print("Your stone glows pale...");
5357 #endif
5358
5359                                 if (!get_aim_dir(&dir)) return;
5360                                 fire_ball(GF_MANA, dir, 400, 4);
5361                                 o_ptr->timeout = randint0(250) + 250;
5362                                 break;
5363                         }
5364                         case ART_TAIKOBO:
5365                         {
5366                                 int x, y;
5367
5368                                 if (!get_rep_dir2(&dir)) return;
5369                                 y = py+ddy[dir];
5370                                 x = px+ddx[dir];
5371                                 tsuri_dir = dir;
5372                                 if (!(cave[y][x].feat == FEAT_DEEP_WATER) && !(cave[y][x].feat == FEAT_SHAL_WATER))
5373                                 {
5374 #ifdef JP
5375                                         msg_print("¤½¤³¤ÏΦÃϤÀ¡£");
5376 #else
5377                                         msg_print("There is no fishing place.");
5378 #endif
5379                                         return;
5380                                 }
5381                                 else if (cave[y][x].m_idx)
5382                                 {
5383                                         char m_name[80];
5384                                         monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5385 #ifdef JP
5386                                         msg_format("%s¤¬¼ÙËâ¤À¡ª", m_name);
5387 #else
5388                                         msg_format("%^s is stand in your way.", m_name);
5389 #endif
5390                                         energy_use = 0;
5391                                         return;
5392                                 }
5393                                 set_action(ACTION_FISH);
5394                                 p_ptr->redraw |= (PR_STATE);
5395                                 break;
5396                         }
5397                         case ART_JONES:
5398                         {
5399                                 if (!get_aim_dir(&dir)) return;
5400 #ifdef JP
5401                                 msg_print("¥à¥Á¤ò¿­¤Ð¤·¤¿¡£");
5402 #else
5403                                 msg_print("You stretched your wip.");
5404 #endif
5405
5406                                 fetch(dir, 500, TRUE);
5407                                 o_ptr->timeout = randint0(25) + 25;
5408                                 break;
5409                         }
5410                         case ART_ARRYU:
5411                         {
5412                                 u32b mode = PM_ALLOW_GROUP;
5413                                 bool pet = !one_in_(5);
5414                                 if (pet) mode |= PM_FORCE_PET;
5415                                 else mode |= PM_NO_PET;
5416
5417                                 if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
5418                                 {
5419
5420                                         if (pet)
5421 #ifdef JP
5422                                                 msg_print("¥Ï¥¦¥ó¥É¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5423 #else
5424                                         msg_print("A group of hounds appear as your servant.");
5425 #endif
5426
5427                                         else
5428 #ifdef JP
5429                                                 msg_print("¥Ï¥¦¥ó¥É¤Ï¤¢¤Ê¤¿¤Ë²ç¤ò¸þ¤±¤Æ¤¤¤ë¡ª");
5430 #else
5431                                                 msg_print("A group of hounds appear as your enemy!");
5432 #endif
5433
5434                                 }
5435
5436                                 o_ptr->timeout = 300 + randint1(150);
5437                                 break;
5438                         }
5439
5440                         case ART_GAEBOLG:
5441                         {
5442 #ifdef JP
5443                                 msg_print("¥¹¥Ô¥¢¤ÏâÁ¤·¤¯µ±¤¤¤¿...");
5444 #else
5445                                 msg_print("Your spear grows brightly...");
5446 #endif
5447
5448                                 if (!get_aim_dir(&dir)) return;
5449                                 fire_ball(GF_LITE, dir, 200, 3);
5450                                 o_ptr->timeout = randint0(200) + 200;
5451                                 break;
5452                         }
5453
5454                         case ART_INROU:
5455                         {
5456                                 int count = 0, i;
5457                                 monster_type *m_ptr;
5458 #ifndef JP
5459                                 cptr kakusan = "";
5460 #endif
5461
5462                                 if (summon_named_creature(0, py, px, MON_SUKE, PM_FORCE_PET))
5463                                 {
5464 #ifdef JP
5465                                         msg_print("¡Ø½õ¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5466 #else
5467                                         msg_print("Suke-san apperars.");
5468                                         kakusan = "Suke-san";
5469 #endif
5470                                         count++;
5471                                 }
5472                                 if (summon_named_creature(0, py, px, MON_KAKU, PM_FORCE_PET))
5473                                 {
5474 #ifdef JP
5475                                         msg_print("¡Ø³Ê¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5476 #else
5477                                         msg_print("Kaku-san appears.");
5478                                         kakusan = "Kaku-san";
5479 #endif
5480                                         count++;
5481                                 }
5482                                 if (!count)
5483                                 {
5484                                         for (i = m_max - 1; i > 0; i--)
5485                                         {
5486                                                 m_ptr = &m_list[i];
5487                                                 if (!m_ptr->r_idx) continue;
5488                                                 if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
5489                                                 if (!los(m_ptr->fy, m_ptr->fx, py, px)) continue;
5490                                                 count++;
5491                                                 break;
5492                                         }
5493                                 }
5494
5495                                 if (count)
5496                                 {
5497 #ifdef JP
5498                                         msg_print("¡Ö¼Ô¤É¤â¡¢¤Ò¤«¤¨¤ª¤í¤¦¡ª¡ª¡ª¤³¤Î¤ªÊý¤ò¤É¤Ê¤¿¤È¤³¤³¤í¤¨¤ë¡£¡×");
5499 #else
5500                                         msg_format("%^s says 'WHO do you think this person is! Bow your head, down your knees!'", kakusan);
5501 #endif
5502
5503                                         sukekaku = TRUE;
5504                                         stun_monsters(120);
5505                                         confuse_monsters(120);
5506                                         turn_monsters(120);
5507                                         stasis_monsters(120);
5508                                         sukekaku = FALSE;
5509                                 }
5510                                 else
5511                                 {
5512 #ifdef JP
5513                                         msg_print("¤·¤«¤·¡¢²¿¤âµ¯¤­¤Ê¤«¤Ã¤¿¡£");
5514 #else
5515                                         msg_print("Nothing happen.");
5516 #endif
5517                                 }
5518                                 o_ptr->timeout = randint0(150) + 150;
5519                                 break;
5520                         }
5521
5522                         case ART_HYOUSIGI:
5523                         {
5524 #ifdef JP
5525                                 msg_print("Çï»ÒÌÚ¤òÂǤä¿¡£");
5526 #else
5527                                 msg_print("You beat Your wooden clappers.");
5528 #endif
5529                                 aggravate_monsters(0);
5530                                 break;
5531                         }
5532
5533                         case ART_MATOI:
5534                         case ART_AEGISFANG:
5535                         {
5536                                 set_hero(randint1(25)+25, FALSE);
5537                                 hp_player(10);
5538                                 o_ptr->timeout = randint0(30) + 30;
5539                                 break;
5540                         }
5541
5542                         case ART_EARENDIL:
5543                         {
5544                                 (void)set_poisoned(0);
5545                                 (void)set_confused(0);
5546                                 (void)set_blind(0);
5547                                 (void)set_stun(0);
5548                                 (void)set_cut(0);
5549                                 (void)set_image(0);
5550
5551                                 o_ptr->timeout = 100;
5552                                 break;
5553                         }
5554
5555                         case ART_BOLISHOI:
5556                         {
5557                                 if (!get_aim_dir(&dir)) return;
5558                                 (void)charm_animal(dir, p_ptr->lev);
5559
5560                                 o_ptr->timeout = 200;
5561                                 break;
5562                         }
5563
5564                         case ART_ARUNRUTH:
5565                         {
5566 #ifdef JP
5567                                 msg_print("¥½¡¼¥É¤¬Ã¸¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
5568 #else
5569                                 msg_print("Your sword glows a pale blue...");
5570 #endif
5571                                 if (!get_aim_dir(&dir)) return;
5572                                 fire_bolt(GF_COLD, dir, damroll(12, 8));
5573                                 o_ptr->timeout = 50;
5574                                 break;
5575                         }
5576                         case ART_BLOOD:
5577                         {
5578                                 int dummy, i;
5579 #ifdef JP
5580                                 msg_print("³ù¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
5581 #else
5582                                 msg_print("Your scythe glows brightly!");
5583 #endif
5584                                 for (i = 0; i < TR_FLAG_SIZE; i++)
5585                                         o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
5586
5587                                 dummy = randint1(2)+randint1(2);
5588                                 for (i = 0; i < dummy; i++)
5589                                 {
5590                                         int flag = randint0(19);
5591                                         if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
5592                                         else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
5593                                 }
5594                                 dummy = randint1(2);
5595                                 for (i = 0; i < dummy; i++)
5596                                         one_resistance(o_ptr);
5597                                 dummy = 2;
5598                                 for (i = 0; i < dummy; i++)
5599                                 {
5600                                         int tmp = randint0(11);
5601                                         if (tmp < 6) add_flag(o_ptr->art_flags, TR_STR + tmp);
5602                                         else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
5603                                 }
5604                                 o_ptr->timeout = 3333;
5605                                 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5606                                 p_ptr->update |= (PU_BONUS | PU_HP);
5607                                 break;
5608                         }
5609                         case ART_KESHO:
5610                         {
5611 #ifdef JP
5612                                 msg_print("Î϶¯¤¯»Í¸Ô¤òƧ¤ó¤À¡£");
5613 #else
5614                                 msg_print("You stamp. (as if you are in a ring.)");
5615 #endif
5616                                 (void)set_hero(randint1(20) + 20, FALSE);
5617                                 dispel_evil(p_ptr->lev * 3);
5618                                 o_ptr->timeout = 100 + randint1(100);
5619                                 break;
5620                         }
5621                         case ART_MOOK:
5622                         {
5623 #ifdef JP
5624                                 msg_print("¥¯¥í¡¼¥¯¤¬Çò¤¯µ±¤¤¤¿...");
5625 #else
5626                                 msg_print("Your cloak grows white.");
5627 #endif
5628                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
5629                                 o_ptr->timeout = 40 + randint1(40);
5630                                 break;
5631                         }
5632                         case ART_HERMIT:
5633                         {
5634 #ifdef JP
5635                                 msg_print("¥à¥Á¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
5636 #else
5637                                 msg_print("The whip lets out a shrill wail...");
5638 #endif
5639
5640                                 k = 3 * p_ptr->lev;
5641                                 (void)set_protevil(randint1(25) + k, FALSE);
5642                                 o_ptr->timeout = randint0(225) + 225;
5643                                 break;
5644                         }
5645                         case ART_JIZO:
5646                         {
5647                                 u32b mode = PM_ALLOW_GROUP;
5648                                 bool pet = !one_in_(5);
5649                                 if (pet) mode |= PM_FORCE_PET;
5650
5651                                 if (summon_named_creature(0, py, px, MON_JIZOTAKO, mode))
5652                                 {
5653                                         if (pet)
5654 #ifdef JP
5655                                                 msg_print("Âý¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5656 #else
5657                                         msg_print("A group of octopuses appear as your servant.");
5658 #endif
5659
5660                                         else
5661 #ifdef JP
5662                                                 msg_print("Âý¤Ï¤¢¤Ê¤¿¤òâˤó¤Ç¤¤¤ë¡ª");
5663 #else
5664                                                 msg_print("A group of octopuses appear as your enemy!");
5665 #endif
5666
5667                                 }
5668
5669                                 o_ptr->timeout = 300 + randint1(150);
5670                                 break;
5671                         }
5672
5673                         case ART_FUNDIN:
5674                         {
5675 #ifdef JP
5676                                 msg_print("Å´µå¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
5677 #else
5678                                 msg_print("The iron ball floods the area with goodness...");
5679 #endif
5680
5681                                 dispel_evil(p_ptr->lev * 5);
5682                                 o_ptr->timeout = randint0(100) + 100;
5683                                 break;
5684                         }
5685
5686                         case ART_NIGHT:
5687                         {
5688 #ifdef JP
5689                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
5690 #else
5691                                 msg_print("Your amulet is coverd in pitch-darkness...");
5692 #endif
5693                                 if (!get_aim_dir(&dir)) return;
5694                                 fire_ball(GF_DARK, dir, 250, 4);
5695                                 o_ptr->timeout = randint0(150) + 150;
5696                                 break;
5697                         }
5698                 }
5699
5700                 /* Window stuff */
5701                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5702
5703                 /* Done */
5704                 return;
5705         }
5706
5707         else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3))
5708         {
5709                 switch (o_ptr->xtra3-1)
5710                 {
5711                 case ESSENCE_TMP_RES_ACID:
5712                         (void)set_oppose_acid(randint1(20) + 20, FALSE);
5713                         o_ptr->timeout = randint0(50) + 50;
5714                         return;
5715
5716                 case ESSENCE_TMP_RES_ELEC:
5717                         (void)set_oppose_elec(randint1(20) + 20, FALSE);
5718                         o_ptr->timeout = randint0(50) + 50;
5719                         return;
5720
5721                 case ESSENCE_TMP_RES_FIRE:
5722                         (void)set_oppose_fire(randint1(20) + 20, FALSE);
5723                         o_ptr->timeout = randint0(50) + 50;
5724                         return;
5725
5726                 case ESSENCE_TMP_RES_COLD:
5727                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
5728                         o_ptr->timeout = randint0(50) + 50;
5729                         return;
5730
5731                 case TR_IMPACT:
5732                         earthquake(py, px, 5);
5733                         o_ptr->timeout = 100 + randint1(100);
5734                         
5735                         /* Window stuff */
5736                         p_ptr->window |= (PW_INVEN | PW_EQUIP);
5737
5738                         /* Done */
5739                         return;
5740                 }
5741         }
5742
5743
5744         else if (o_ptr->name2 == EGO_TRUMP)
5745         {
5746                 teleport_player(100);
5747                 o_ptr->timeout = 50 + randint1(50);
5748
5749                 /* Window stuff */
5750                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5751
5752                 /* Done */
5753                 return;
5754         }
5755
5756
5757         else if (o_ptr->name2 == EGO_LITE_ILLUMINATION)
5758         {
5759                 if (!o_ptr->xtra4 && ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
5760                 {
5761 #ifdef JP
5762                         msg_print("dzÎÁ¤¬¤Ê¤¤¡£");
5763 #else
5764                         msg_print("It has no fuel.");
5765 #endif
5766                         energy_use = 0;
5767                         return;
5768                 }
5769                 lite_area(damroll(2, 15), 3);
5770                 o_ptr->timeout = randint0(10) + 10;
5771
5772                 /* Window stuff */
5773                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5774
5775                 return;
5776         }
5777
5778
5779         else if (o_ptr->name2 == EGO_EARTHQUAKES)
5780         {
5781                 earthquake(py, px, 5);
5782                 o_ptr->timeout = 100 + randint1(100);
5783
5784                 /* Window stuff */
5785                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5786
5787                 /* Done */
5788                 return;
5789         }
5790
5791
5792         else if (o_ptr->name2 == EGO_JUMP)
5793         {
5794                 teleport_player(10);
5795                 o_ptr->timeout = 10 + randint1(10);
5796
5797                 /* Window stuff */
5798                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5799
5800                 /* Done */
5801                 return;
5802         }
5803
5804
5805         /* Hack -- Dragon Scale Mail can be activated as well */
5806         else if (o_ptr->tval == TV_DRAG_ARMOR)
5807         {
5808                 /* Get a direction for breathing (or abort) */
5809                 if (!get_aim_dir(&dir)) return;
5810
5811                 /* Branch on the sub-type */
5812                 switch (o_ptr->sval)
5813                 {
5814                         case SV_DRAGON_BLUE:
5815                         {
5816 #ifdef JP
5817                                 msg_print("¤¢¤Ê¤¿¤Ï°ðºÊ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5818 #else
5819                                 msg_print("You breathe lightning.");
5820 #endif
5821
5822                                 fire_ball(GF_ELEC, dir, 100, -2);
5823                                 o_ptr->timeout = randint0(150) + 150;
5824                                 break;
5825                         }
5826
5827                         case SV_DRAGON_WHITE:
5828                         {
5829 #ifdef JP
5830                                 msg_print("¤¢¤Ê¤¿¤ÏÎ䵤¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5831 #else
5832                                 msg_print("You breathe frost.");
5833 #endif
5834
5835                                 fire_ball(GF_COLD, dir, 110, -2);
5836                                 o_ptr->timeout = randint0(150) + 150;
5837                                 break;
5838                         }
5839
5840                         case SV_DRAGON_BLACK:
5841                         {
5842 #ifdef JP
5843                                 msg_print("¤¢¤Ê¤¿¤Ï»À¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5844 #else
5845                                 msg_print("You breathe acid.");
5846 #endif
5847
5848                                 fire_ball(GF_ACID, dir, 130, -2);
5849                                 o_ptr->timeout = randint0(150) + 150;
5850                                 break;
5851                         }
5852
5853                         case SV_DRAGON_GREEN:
5854                         {
5855 #ifdef JP
5856                                 msg_print("¤¢¤Ê¤¿¤ÏÆÇ¥¬¥¹¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5857 #else
5858                                 msg_print("You breathe poison gas.");
5859 #endif
5860
5861                                 fire_ball(GF_POIS, dir, 150, -2);
5862                                 o_ptr->timeout = randint0(180) + 180;
5863                                 break;
5864                         }
5865
5866                         case SV_DRAGON_RED:
5867                         {
5868 #ifdef JP
5869                                 msg_print("¤¢¤Ê¤¿¤Ï²Ð±ê¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5870 #else
5871                                 msg_print("You breathe fire.");
5872 #endif
5873
5874                                 fire_ball(GF_FIRE, dir, 200, -2);
5875                                 o_ptr->timeout = randint0(200) + 200;
5876                                 break;
5877                         }
5878
5879                         case SV_DRAGON_MULTIHUED:
5880                         {
5881                                 chance = randint0(5);
5882 #ifdef JP
5883                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5884                                            ((chance == 1) ? "°ðºÊ" :
5885                                             ((chance == 2) ? "Î䵤" :
5886                                              ((chance == 3) ? "»À" :
5887                                               ((chance == 4) ? "ÆÇ¥¬¥¹" : "²Ð±ê")))));
5888 #else
5889                                 msg_format("You breathe %s.",
5890                                            ((chance == 1) ? "lightning" :
5891                                             ((chance == 2) ? "frost" :
5892                                              ((chance == 3) ? "acid" :
5893                                               ((chance == 4) ? "poison gas" : "fire")))));
5894 #endif
5895
5896                                 fire_ball(((chance == 1) ? GF_ELEC :
5897                                            ((chance == 2) ? GF_COLD :
5898                                             ((chance == 3) ? GF_ACID :
5899                                              ((chance == 4) ? GF_POIS : GF_FIRE)))),
5900                                           dir, 250, -2);
5901                                 o_ptr->timeout = randint0(200) + 200;
5902                                 break;
5903                         }
5904
5905                         case SV_DRAGON_BRONZE:
5906                         {
5907 #ifdef JP
5908                                 msg_print("¤¢¤Ê¤¿¤Ïº®Íð¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5909 #else
5910                                 msg_print("You breathe confusion.");
5911 #endif
5912
5913                                 fire_ball(GF_CONFUSION, dir, 120, -2);
5914                                 o_ptr->timeout = randint0(180) + 180;
5915                                 break;
5916                         }
5917
5918                         case SV_DRAGON_GOLD:
5919                         {
5920 #ifdef JP
5921                                 msg_print("¤¢¤Ê¤¿¤Ï¹ì²»¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5922 #else
5923                                 msg_print("You breathe sound.");
5924 #endif
5925
5926                                 fire_ball(GF_SOUND, dir, 130, -2);
5927                                 o_ptr->timeout = randint0(180) + 180;
5928                                 break;
5929                         }
5930
5931                         case SV_DRAGON_CHAOS:
5932                         {
5933                                 chance = randint0(2);
5934 #ifdef JP
5935                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5936                                            ((chance == 1 ? "¥«¥ª¥¹" : "Îô²½")));
5937 #else
5938                                 msg_format("You breathe %s.",
5939                                            ((chance == 1 ? "chaos" : "disenchantment")));
5940 #endif
5941
5942                                 fire_ball((chance == 1 ? GF_CHAOS : GF_DISENCHANT),
5943                                           dir, 220, -2);
5944                                 o_ptr->timeout = randint0(200) + 200;
5945                                 break;
5946                         }
5947
5948                         case SV_DRAGON_LAW:
5949                         {
5950                                 chance = randint0(2);
5951 #ifdef JP
5952                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5953                                            ((chance == 1 ? "¹ì²»" : "ÇËÊÒ")));
5954 #else
5955                                 msg_format("You breathe %s.",
5956                                            ((chance == 1 ? "sound" : "shards")));
5957 #endif
5958
5959                                 fire_ball((chance == 1 ? GF_SOUND : GF_SHARDS),
5960                                           dir, 230, -2);
5961                                 o_ptr->timeout = randint0(200) + 200;
5962                                 break;
5963                         }
5964
5965                         case SV_DRAGON_BALANCE:
5966                         {
5967                                 chance = randint0(4);
5968 #ifdef JP
5969                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿",
5970                                            ((chance == 1) ? "¥«¥ª¥¹" :
5971                                             ((chance == 2) ? "Îô²½" :
5972                                              ((chance == 3) ? "¹ì²»" : "ÇËÊÒ"))));
5973 #else
5974                                 msg_format("You breathe %s.",
5975                                            ((chance == 1) ? "chaos" :
5976                                             ((chance == 2) ? "disenchantment" :
5977                                              ((chance == 3) ? "sound" : "shards"))));
5978 #endif
5979
5980                                 fire_ball(((chance == 1) ? GF_CHAOS :
5981                                            ((chance == 2) ? GF_DISENCHANT :
5982                                             ((chance == 3) ? GF_SOUND : GF_SHARDS))),
5983                                           dir, 250, -2);
5984                                 o_ptr->timeout = randint0(200) + 200;
5985                                 break;
5986                         }
5987
5988                         case SV_DRAGON_SHINING:
5989                         {
5990                                 chance = randint0(2);
5991 #ifdef JP
5992                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5993                                            ((chance == 0 ? "Á®¸÷" : "°Å¹õ")));
5994 #else
5995                                 msg_format("You breathe %s.",
5996                                            ((chance == 0 ? "light" : "darkness")));
5997 #endif
5998
5999                                 fire_ball((chance == 0 ? GF_LITE : GF_DARK), dir, 200, -2);
6000                                 o_ptr->timeout = randint0(200) + 200;
6001                                 break;
6002                         }
6003
6004                         case SV_DRAGON_POWER:
6005                         {
6006 #ifdef JP
6007 msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
6008 #else
6009                                 msg_print("You breathe the elements.");
6010 #endif
6011
6012                                 fire_ball(GF_MISSILE, dir, 300, -3);
6013                                 o_ptr->timeout = randint0(200) + 200;
6014                                 break;
6015                         }
6016                 }
6017
6018                 /* Window stuff */
6019                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
6020
6021                 /* Success */
6022                 return;
6023         }
6024
6025         else if (o_ptr->tval == TV_RING)
6026         {
6027                 if (o_ptr->name2)
6028                 {
6029                         bool success = TRUE;
6030
6031                         switch (o_ptr->name2)
6032                         {
6033                         case EGO_RING_HERO:
6034                                 (void)set_afraid(0);
6035                                 (void)set_hero(randint1(25) + 25, FALSE);
6036                                 (void)hp_player(10);
6037                                 o_ptr->timeout = randint1(100)+100;
6038                                 break;
6039                         case EGO_RING_MAGIC_MIS:
6040                                 if (!get_aim_dir(&dir)) return;
6041                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
6042                                 o_ptr->timeout = 2;
6043                                 break;
6044                         case EGO_RING_FIRE_BOLT:
6045                                 if (!get_aim_dir(&dir)) return;
6046                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
6047                                 o_ptr->timeout = randint0(8) + 8;
6048                                 break;
6049                         case EGO_RING_COLD_BOLT:
6050                                 if (!get_aim_dir(&dir)) return;
6051                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
6052                                 o_ptr->timeout = randint0(7) + 7;
6053                                 break;
6054                         case EGO_RING_ELEC_BOLT:
6055                                 if (!get_aim_dir(&dir)) return;
6056                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
6057                                 o_ptr->timeout = randint0(5) + 5;
6058                                 break;
6059                         case EGO_RING_ACID_BOLT:
6060                                 if (!get_aim_dir(&dir)) return;
6061                                 fire_bolt(GF_FIRE, dir, damroll(5, 8));
6062                                 o_ptr->timeout = randint0(6) + 6;
6063                                 break;
6064                         case EGO_RING_MANA_BOLT:
6065                                 if (!get_aim_dir(&dir)) return;
6066                                 fire_bolt(GF_MANA, dir, 120);
6067                                 o_ptr->timeout = randint0(120)+120;
6068                                 break;
6069                         case EGO_RING_FIRE_BALL:
6070                                 if (!get_aim_dir(&dir)) return;
6071                                 fire_ball(GF_FIRE, dir, 100, 2);
6072                                 o_ptr->timeout = randint0(80) + 80;
6073                                 break;
6074                         case EGO_RING_COLD_BALL:
6075                                 if (!get_aim_dir(&dir)) return;
6076                                 fire_ball(GF_COLD, dir, 100, 2);
6077                                 o_ptr->timeout = randint0(80) + 80;
6078                                 break;
6079                         case EGO_RING_ELEC_BALL:
6080                                 if (!get_aim_dir(&dir)) return;
6081                                 fire_ball(GF_ELEC, dir, 100, 2);
6082                                 o_ptr->timeout = randint0(80) + 80;
6083                                 break;
6084                         case EGO_RING_ACID_BALL:
6085                                 if (!get_aim_dir(&dir)) return;
6086                                 fire_ball(GF_ACID, dir, 100, 2);
6087                                 o_ptr->timeout = randint0(80) + 80;
6088                                 break;
6089                         case EGO_RING_MANA_BALL:
6090                                 if (!get_aim_dir(&dir)) return;
6091                                 fire_ball(GF_MANA, dir, 250, 2);
6092                                 o_ptr->timeout = 300;
6093                                 break;
6094                         case EGO_RING_DRAGON_F:
6095                                 if (!get_aim_dir(&dir)) return;
6096                                 fire_ball(GF_FIRE, dir, 200, -2);
6097                                 if (o_ptr->sval == SV_RING_FLAMES)
6098                                 {
6099                                         (void)set_oppose_fire(randint1(20) + 20, FALSE);
6100                                         o_ptr->timeout = 200;
6101                                 }
6102                                 else o_ptr->timeout = 250;
6103                                 break;
6104                         case EGO_RING_DRAGON_C:
6105                                 if (!get_aim_dir(&dir)) return;
6106                                 fire_ball(GF_COLD, dir, 200, -2);
6107                                 if (o_ptr->sval == SV_RING_ICE)
6108                                 {
6109                                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
6110                                         o_ptr->timeout = 200;
6111                                 }
6112                                 else o_ptr->timeout = 250;
6113                                 break;
6114                         case EGO_RING_M_DETECT:
6115                                 (void)detect_monsters_invis(255);
6116                                 (void)detect_monsters_normal(255);
6117                                 o_ptr->timeout = 150;
6118                                 break;
6119                         case EGO_RING_D_SPEED:
6120                                 (void)set_fast(randint1(30) + 15, FALSE);
6121                                 o_ptr->timeout = 100;
6122                                 break;
6123                         case EGO_RING_BERSERKER:
6124                                 (void)set_shero(randint1(25) + 25, FALSE);
6125                                 o_ptr->timeout = randint0(75)+75;
6126                                 break;
6127                         case EGO_RING_TELE_AWAY:
6128                                 if (!get_aim_dir(&dir)) return;
6129                                 teleport_monster(dir);
6130                                 o_ptr->timeout = 150;
6131                                 break;
6132                         case EGO_RING_TRUE:
6133                         {
6134                                 int v = randint1(25)+25;
6135                                 (void)set_afraid(0);
6136                                 (void)set_hero(v, FALSE);
6137                                 (void)hp_player(10);
6138                                 (void)set_blessed(v, FALSE);
6139                                 (void)set_oppose_acid(v, FALSE);
6140                                 (void)set_oppose_elec(v, FALSE);
6141                                 (void)set_oppose_fire(v, FALSE);
6142                                 (void)set_oppose_cold(v, FALSE);
6143                                 (void)set_oppose_pois(v, FALSE);
6144                                 (void)set_ultimate_res(v, FALSE);
6145                                 o_ptr->timeout = 777;
6146                                 break;
6147                         }
6148                         default:
6149                                 success = FALSE;
6150                                 break;
6151                         }
6152                         if (success) return;
6153                 }
6154
6155                 /* Get a direction for breathing (or abort) */
6156                 if (!get_aim_dir(&dir)) return;
6157
6158                 switch (o_ptr->sval)
6159                 {
6160                         case SV_RING_ACID:
6161                         {
6162                                 fire_ball(GF_ACID, dir, 100, 2);
6163                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
6164                                 o_ptr->timeout = randint0(50) + 50;
6165                                 break;
6166                         }
6167
6168                         case SV_RING_ICE:
6169                         {
6170                                 fire_ball(GF_COLD, dir, 100, 2);
6171                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
6172                                 o_ptr->timeout = randint0(50) + 50;
6173                                 break;
6174                         }
6175
6176                         case SV_RING_FLAMES:
6177                         {
6178                                 fire_ball(GF_FIRE, dir, 100, 2);
6179                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
6180                                 o_ptr->timeout = randint0(50) + 50;
6181                                 break;
6182                         }
6183
6184                         case SV_RING_ELEC:
6185                         {
6186                                 fire_ball(GF_ELEC, dir, 100, 2);
6187                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
6188                                 o_ptr->timeout = randint0(50) + 50;
6189                                 break;
6190                         }
6191                 }
6192
6193                 /* Window stuff */
6194                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
6195
6196                 /* Success */
6197                 return;
6198         }
6199
6200         else if (o_ptr->tval == TV_AMULET)
6201         {
6202                 if (o_ptr->name2)
6203                 {
6204                         switch (o_ptr->name2)
6205                         {
6206                         case EGO_AMU_IDENT:
6207                                 if (!ident_spell(FALSE)) return;
6208                                 o_ptr->timeout = 10;
6209                                 break;
6210                         case EGO_AMU_CHARM:
6211                                 if (!get_aim_dir(&dir)) return;
6212                                 charm_monster(dir, MAX(20, p_ptr->lev));
6213                                 o_ptr->timeout = 200;
6214                                 break;
6215                         case EGO_AMU_JUMP:
6216                                 teleport_player(10);
6217                                 o_ptr->timeout = randint0(10) + 10;
6218                                 break;
6219                         case EGO_AMU_TELEPORT:
6220                                 teleport_player(100);
6221                                 o_ptr->timeout = randint0(50) + 50;
6222                                 break;
6223                         case EGO_AMU_D_DOOR:
6224                                 (void)dimension_door();
6225                                 o_ptr->timeout = 200;
6226                                 break;
6227                         case EGO_AMU_RES_FIRE_:
6228                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
6229                                 o_ptr->timeout = randint0(50) + 50;
6230                                 break;
6231                         case EGO_AMU_RES_COLD_:
6232                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
6233                                 o_ptr->timeout = randint0(50) + 50;
6234                                 break;
6235                         case EGO_AMU_RES_ELEC_:
6236                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
6237                                 o_ptr->timeout = randint0(50) + 50;
6238                                 break;
6239                         case EGO_AMU_RES_ACID_:
6240                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
6241                                 o_ptr->timeout = randint0(50) + 50;
6242                                 break;
6243                         case EGO_AMU_DETECTION:
6244                                 detect_all(DETECT_RAD_DEFAULT);
6245                                 o_ptr->timeout = randint0(55)+55;
6246                                 break;
6247                         }
6248                 }
6249                 return;
6250         }
6251
6252         else if (o_ptr->tval == TV_WHISTLE)
6253         {
6254 #if 0
6255                 if (cursed_p(o_ptr))
6256                 {
6257 #ifdef JP
6258                         msg_print("¥«¥ó¹â¤¤²»¤¬¶Á¤­ÅϤä¿¡£");
6259 #else
6260                         msg_print("You produce a shrill whistling sound.");
6261 #endif
6262                         aggravate_monsters(0);
6263                 }
6264                 else
6265 #endif
6266                 {
6267                         int pet_ctr, i;
6268                         u16b *who;
6269                         int max_pet = 0;
6270                         u16b dummy_why;
6271
6272                         /* Allocate the "who" array */
6273                         C_MAKE(who, max_m_idx, u16b);
6274
6275                         /* Process the monsters (backwards) */
6276                         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
6277                         {
6278                                 if (is_pet(&m_list[pet_ctr]) && (p_ptr->riding != pet_ctr))
6279                                   who[max_pet++] = pet_ctr;
6280                         }
6281
6282                         /* Select the sort method */
6283                         ang_sort_comp = ang_sort_comp_pet;
6284                         ang_sort_swap = ang_sort_swap_hook;
6285
6286                         ang_sort(who, &dummy_why, max_pet);
6287
6288                         /* Process the monsters (backwards) */
6289                         for (i = 0; i < max_pet; i++)
6290                         {
6291                                 pet_ctr = who[i];
6292                                 teleport_to_player(pet_ctr, 100);
6293                         }
6294
6295                         /* Free the "who" array */
6296                         C_KILL(who, max_m_idx, u16b);
6297                 }
6298                 o_ptr->timeout = 100+randint1(100);
6299                 return;
6300         }
6301         else if (o_ptr->tval == TV_CAPTURE)
6302         {
6303                 if(!o_ptr->pval)
6304                 {
6305                         bool old_target_pet = target_pet;
6306                         target_pet = TRUE;
6307                         if (!get_aim_dir(&dir))
6308                         {
6309                                 target_pet = old_target_pet;
6310                                 return;
6311                         }
6312                         target_pet = old_target_pet;
6313
6314                         if(fire_ball(GF_CAPTURE, dir, 0, 0))
6315                         {
6316                                 o_ptr->pval = cap_mon;
6317                                 o_ptr->xtra3 = cap_mspeed;
6318                                 o_ptr->xtra4 = cap_hp;
6319                                 o_ptr->xtra5 = cap_maxhp;
6320                                 if (cap_nickname)
6321                                 {
6322                                         cptr t;
6323                                         char *s;
6324                                         char buf[80] = "";
6325
6326                                         if (o_ptr->inscription)
6327                                                 strcpy(buf, quark_str(o_ptr->inscription));
6328                                         s = buf;
6329                                         for (s = buf;*s && (*s != '#'); s++)
6330                                         {
6331 #ifdef JP
6332                                                 if (iskanji(*s)) s++;
6333 #endif
6334                                         }
6335                                         *s = '#';
6336                                         s++;
6337 #ifdef JP
6338  /*nothing*/
6339 #else
6340                                         *s++ = '\'';
6341 #endif
6342                                         t = quark_str(cap_nickname);
6343                                         while (*t)
6344                                         {
6345                                                 *s = *t;
6346                                                 s++;
6347                                                 t++;
6348                                         }
6349 #ifdef JP
6350  /*nothing*/
6351 #else
6352                                         *s++ = '\'';
6353 #endif
6354                                         *s = '\0';
6355                                         o_ptr->inscription = quark_add(buf);
6356                                 }
6357                         }
6358                 }
6359                 else
6360                 {
6361                         bool success = FALSE;
6362                         if (!get_rep_dir2(&dir)) return;
6363                         if (cave_floor_bold(py+ddy[dir],px+ddx[dir]))
6364                         {
6365                                 if (place_monster_aux(0, py + ddy[dir], px + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
6366                                 {
6367                                         if (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
6368                                         if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
6369                                         if (o_ptr->xtra4) m_list[hack_m_idx_ii].hp = o_ptr->xtra4;
6370                                         m_list[hack_m_idx_ii].maxhp = m_list[hack_m_idx_ii].max_maxhp;
6371                                         if (o_ptr->inscription)
6372                                         {
6373                                                 char buf[80];
6374                                                 cptr t;
6375 #ifndef JP
6376                                                 bool quote = FALSE;
6377 #endif
6378
6379                                                 t = quark_str(o_ptr->inscription);
6380                                                 for (t = quark_str(o_ptr->inscription);*t && (*t != '#'); t++)
6381                                                 {
6382 #ifdef JP
6383                                                         if (iskanji(*t)) t++;
6384 #endif
6385                                                 }
6386                                                 if (*t)
6387                                                 {
6388                                                         char *s = buf;
6389                                                         t++;
6390 #ifdef JP
6391                                                         /* nothing */
6392 #else
6393                                                         if (*t =='\'')
6394                                                         {
6395                                                                 t++;
6396                                                                 quote = TRUE;
6397                                                         }
6398 #endif
6399                                                         while(*t)
6400                                                         {
6401                                                                 *s = *t;
6402                                                                 t++;
6403                                                                 s++;
6404                                                         }
6405 #ifdef JP
6406                                                         /* nothing */
6407 #else
6408                                                         if (quote && *(s-1) =='\'')
6409                                                                 s--;
6410 #endif
6411                                                         *s = '\0';
6412                                                         m_list[hack_m_idx_ii].nickname = quark_add(buf);
6413                                                         t = quark_str(o_ptr->inscription);
6414                                                         s = buf;
6415                                                         while(*t && (*t != '#'))
6416                                                         {
6417                                                                 *s = *t;
6418                                                                 t++;
6419                                                                 s++;
6420                                                         }
6421                                                         *s = '\0';
6422                                                         o_ptr->inscription = quark_add(buf);
6423                                                 }
6424                                         }
6425                                         o_ptr->pval = 0;
6426                                         o_ptr->xtra3 = 0;
6427                                         o_ptr->xtra4 = 0;
6428                                         o_ptr->xtra5 = 0;
6429                                         success = TRUE;
6430                                 }
6431                         }
6432                         if (!success)
6433 #ifdef JP
6434                                 msg_print("¤ª¤Ã¤È¡¢²òÊü¤Ë¼ºÇÔ¤·¤¿¡£");
6435 #else
6436                                 msg_print("Oops.  You failed to release your pet.");
6437 #endif
6438                 }
6439                 return;
6440         }
6441
6442         /* Mistake */
6443 #ifdef JP
6444         msg_print("¤ª¤Ã¤È¡¢¤³¤Î¥¢¥¤¥Æ¥à¤Ï»ÏÆ°¤Ç¤­¤Ê¤¤¡£");
6445 #else
6446         msg_print("Oops.  That object cannot be activated.");
6447 #endif
6448
6449 }
6450
6451
6452 void do_cmd_activate(void)
6453 {
6454         int     item;
6455         cptr    q, s;
6456
6457
6458         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6459         {
6460                 set_action(ACTION_NONE);
6461         }
6462
6463         item_tester_no_ryoute = TRUE;
6464         /* Prepare the hook */
6465         item_tester_hook = item_tester_hook_activate;
6466
6467         /* Get an item */
6468 #ifdef JP
6469         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò»ÏÆ°¤µ¤»¤Þ¤¹¤«? ";
6470         s = "»ÏÆ°¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£";
6471 #else
6472         q = "Activate which item? ";
6473         s = "You have nothing to activate.";
6474 #endif
6475
6476         if (!get_item(&item, q, s, (USE_EQUIP))) return;
6477
6478         /* Activate the item */
6479         do_cmd_activate_aux(item);
6480 }
6481
6482
6483 /*
6484  * Hook to determine if an object is useable
6485  */
6486 static bool item_tester_hook_use(object_type *o_ptr)
6487 {
6488         u32b flgs[TR_FLAG_SIZE];
6489
6490         /* Ammo */
6491         if (o_ptr->tval == p_ptr->tval_ammo)
6492                 return (TRUE);
6493
6494         /* Useable object */
6495         switch (o_ptr->tval)
6496         {
6497                 case TV_SPIKE:
6498                 case TV_STAFF:
6499                 case TV_WAND:
6500                 case TV_ROD:
6501                 case TV_SCROLL:
6502                 case TV_POTION:
6503                 case TV_FOOD:
6504                 {
6505                         return (TRUE);
6506                 }
6507
6508                 default:
6509                 {
6510                         int i;
6511
6512                         /* Not known */
6513                         if (!object_known_p(o_ptr)) return (FALSE);
6514
6515                         /* HACK - only items from the equipment can be activated */
6516                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6517                         {
6518                                 if (&inventory[i] == o_ptr)
6519                                 {
6520                                         /* Extract the flags */
6521                                         object_flags(o_ptr, flgs);
6522
6523                                         /* Check activation flag */
6524                                         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
6525                                 }
6526                         }
6527                 }
6528         }
6529
6530         /* Assume not */
6531         return (FALSE);
6532 }
6533
6534
6535 /*
6536  * Use an item
6537  * XXX - Add actions for other item types
6538  */
6539 void do_cmd_use(void)
6540 {
6541         int         item;
6542         object_type *o_ptr;
6543         cptr        q, s;
6544
6545         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6546         {
6547                 set_action(ACTION_NONE);
6548         }
6549
6550         item_tester_no_ryoute = TRUE;
6551         /* Prepare the hook */
6552         item_tester_hook = item_tester_hook_use;
6553
6554         /* Get an item */
6555 #ifdef JP
6556 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
6557 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6558 #else
6559         q = "Use which item? ";
6560         s = "You have nothing to use.";
6561 #endif
6562
6563         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
6564
6565         /* Get the item (in the pack) */
6566         if (item >= 0)
6567         {
6568                 o_ptr = &inventory[item];
6569         }
6570         /* Get the item (on the floor) */
6571         else
6572         {
6573                 o_ptr = &o_list[0 - item];
6574         }
6575
6576         switch (o_ptr->tval)
6577         {
6578                 /* Spike a door */
6579                 case TV_SPIKE:
6580                 {
6581                         do_cmd_spike();
6582                         break;
6583                 }
6584
6585                 /* Eat some food */
6586                 case TV_FOOD:
6587                 {
6588                         do_cmd_eat_food_aux(item);
6589                         break;
6590                 }
6591
6592                 /* Aim a wand */
6593                 case TV_WAND:
6594                 {
6595                         do_cmd_aim_wand_aux(item);
6596                         break;
6597                 }
6598
6599                 /* Use a staff */
6600                 case TV_STAFF:
6601                 {
6602                         do_cmd_use_staff_aux(item);
6603                         break;
6604                 }
6605
6606                 /* Zap a rod */
6607                 case TV_ROD:
6608                 {
6609                         do_cmd_zap_rod_aux(item);
6610                         break;
6611                 }
6612
6613                 /* Quaff a potion */
6614                 case TV_POTION:
6615                 {
6616                         do_cmd_quaff_potion_aux(item);
6617                         break;
6618                 }
6619
6620                 /* Read a scroll */
6621                 case TV_SCROLL:
6622                 {
6623                         /* Check some conditions */
6624                         if (p_ptr->blind)
6625                         {
6626 #ifdef JP
6627 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
6628 #else
6629                                 msg_print("You can't see anything.");
6630 #endif
6631
6632                                 return;
6633                         }
6634                         if (no_lite())
6635                         {
6636 #ifdef JP
6637 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
6638 #else
6639                                 msg_print("You have no light to read by.");
6640 #endif
6641
6642                                 return;
6643                         }
6644                         if (p_ptr->confused)
6645                         {
6646 #ifdef JP
6647 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
6648 #else
6649                                 msg_print("You are too confused!");
6650 #endif
6651
6652                                 return;
6653                         }
6654
6655                   do_cmd_read_scroll_aux(item, TRUE);
6656                   break;
6657                 }
6658
6659                 /* Fire ammo */
6660                 case TV_SHOT:
6661                 case TV_ARROW:
6662                 case TV_BOLT:
6663                 {
6664                         do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
6665                         break;
6666                 }
6667
6668                 /* Activate an artifact */
6669                 default:
6670                 {
6671                         do_cmd_activate_aux(item);
6672                         break;
6673                 }
6674         }
6675 }
6676
6677 static bool select_magic_eater(bool only_browse)
6678 {
6679         int ext=0;
6680         char choice;
6681         bool flag, redraw, request_list;
6682         int tval = 0;
6683         int             ask = TRUE, i = 0;
6684         char            out_val[160];
6685
6686         int menu_line = (use_menu ? 1 : 0);
6687
6688 #ifdef ALLOW_REPEAT
6689         int sn;
6690         if (repeat_pull(&sn))
6691         {
6692                 /* Verify the spell */
6693                 if (sn >= EATER_EXT*2 && !(p_ptr->magic_num1[sn] > k_info[lookup_kind(TV_ROD, sn-EATER_EXT*2)].pval * (p_ptr->magic_num2[sn] - 1) * EATER_ROD_CHARGE))
6694                         return sn;
6695                 else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE))
6696                         return sn;
6697         }
6698         
6699 #endif /* ALLOW_REPEAT */
6700
6701         for (i = 0; i < 108; i++)
6702         {
6703                 if (p_ptr->magic_num2[i]) break;
6704         }
6705         if (i == 108)
6706         {
6707 #ifdef JP
6708                 msg_print("ËâË¡¤ò³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6709 #else
6710                 msg_print("You don't have any magic!");
6711 #endif
6712                 return -1;
6713         }
6714
6715         if (use_menu)
6716         {
6717                 screen_save();
6718
6719                 while(!tval)
6720                 {
6721 #ifdef JP
6722                         prt(format(" %s ¾ó", (menu_line == 1) ? "¡Õ" : "  "), 2, 14);
6723                         prt(format(" %s ËâË¡ËÀ", (menu_line == 2) ? "¡Õ" : "  "), 3, 14);
6724                         prt(format(" %s ¥í¥Ã¥É", (menu_line == 3) ? "¡Õ" : "  "), 4, 14);
6725                         prt("¤É¤Î¼ïÎà¤ÎËâË¡¤ò»È¤¤¤Þ¤¹¤«¡©", 0, 0);
6726 #else
6727                         prt(format(" %s staff", (menu_line == 1) ? "> " : "  "), 2, 14);
6728                         prt(format(" %s wand", (menu_line == 2) ? "> " : "  "), 3, 14);
6729                         prt(format(" %s rod", (menu_line == 3) ? "> " : "  "), 4, 14);
6730                         prt("Which type of magic do you usu?", 0, 0);
6731 #endif
6732                         choice = inkey();
6733                         switch(choice)
6734                         {
6735                         case ESCAPE:
6736                         case 'z':
6737                         case 'Z':
6738                                 screen_load();
6739                                 return -1;
6740                         case '2':
6741                         case 'j':
6742                         case 'J':
6743                                 menu_line++;
6744                                 break;
6745                         case '8':
6746                         case 'k':
6747                         case 'K':
6748                                 menu_line+= 2;
6749                                 break;
6750                         case '\r':
6751                         case 'x':
6752                         case 'X':
6753                                 ext = (menu_line-1)*EATER_EXT;
6754                                 if (menu_line == 1) tval = TV_STAFF;
6755                                 else if (menu_line == 2) tval = TV_WAND;
6756                                 else tval = TV_ROD;
6757                                 break;
6758                         }
6759                         if (menu_line > 3) menu_line -= 3;
6760                 }
6761                 screen_load();
6762         }
6763         else
6764         {
6765         while (TRUE)
6766         {
6767 #ifdef JP
6768                 if (!get_com("[A] ¾ó, [B] ËâË¡ËÀ, [C] ¥í¥Ã¥É:", &choice, TRUE))
6769 #else
6770                 if (!get_com("[A] staff, [B] wand, [C] rod:", &choice, TRUE))
6771 #endif
6772                 {
6773                         return -1;
6774                 }
6775                 if (choice == 'A' || choice == 'a')
6776                 {
6777                         ext = 0;
6778                         tval = TV_STAFF;
6779                         break;
6780                 }
6781                 if (choice == 'B' || choice == 'b')
6782                 {
6783                         ext = EATER_EXT;
6784                         tval = TV_WAND;
6785                         break;
6786                 }
6787                 if (choice == 'C' || choice == 'c')
6788                 {
6789                         ext = EATER_EXT*2;
6790                         tval = TV_ROD;
6791                         break;
6792                 }
6793         }
6794         }
6795         for (i = ext; i < ext + EATER_EXT; i++)
6796         {
6797                 if (p_ptr->magic_num2[i])
6798                 {
6799                         if (use_menu) menu_line = i-ext+1;
6800                         break;
6801                 }
6802         }
6803         if (i == ext+EATER_EXT)
6804         {
6805 #ifdef JP
6806                 msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6807 #else
6808                 msg_print("You don't have that type of magic!");
6809 #endif
6810                 return -1;
6811         }
6812
6813         /* Nothing chosen yet */
6814         flag = FALSE;
6815
6816         /* No redraw yet */
6817         redraw = FALSE;
6818
6819         /* Build a prompt */
6820 #ifdef JP
6821 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò»È¤¤¤Þ¤¹¤«¡©");
6822 #else
6823         (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Use which power? ");
6824 #endif
6825         
6826         /* Save the screen */
6827         screen_save();
6828
6829         request_list = always_show_list;
6830
6831         /* Get a spell from the user */
6832         while (!flag)
6833         {
6834                 /* Show the list */
6835                 if (request_list || use_menu)
6836                 {
6837                         byte y, x = 0;
6838                         int ctr, chance;
6839                         int k_idx;
6840                         char dummy[80];
6841                         int x1, y1, level;
6842                         byte col;
6843
6844                         strcpy(dummy, "");
6845
6846                         for (y = 1; y < 20; y++)
6847                                 prt("", y, x);
6848
6849                         y = 1;
6850
6851                         /* Print header(s) */
6852 #ifdef JP
6853                         prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
6854 #else
6855                         prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
6856 #endif
6857
6858                         /* Print list */
6859                         for (ctr = 0; ctr < EATER_EXT; ctr++)
6860                         {
6861                                 if (!p_ptr->magic_num2[ctr+ext]) continue;
6862
6863                                 k_idx = lookup_kind(tval, ctr);
6864
6865                                 if (use_menu)
6866                                 {
6867                                         if (ctr == (menu_line-1))
6868 #ifdef JP
6869                                                 strcpy(dummy, "¡Õ");
6870 #else
6871                                         strcpy(dummy, "> ");
6872 #endif
6873                                         else strcpy(dummy, "  ");
6874                                                 
6875                                 }
6876                                 /* letter/number for power selection */
6877                                 else
6878                                 {
6879                                         char letter;
6880                                         if (ctr < 26)
6881                                                 letter = I2A(ctr);
6882                                         else
6883                                                 letter = '0' + ctr - 26;
6884                                         sprintf(dummy, "%c)",letter);
6885                                 }
6886                                 x1 = ((ctr < EATER_EXT/2) ? x : x + 40);
6887                                 y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2);
6888                                 level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
6889                                 chance = level * 4 / 5 + 20;
6890                                 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
6891                                 level /= 2;
6892                                 if (p_ptr->lev > level)
6893                                 {
6894                                         chance -= 3 * (p_ptr->lev - level);
6895                                 }
6896                                 chance += p_ptr->to_m_chance;
6897                                 if (p_ptr->heavy_spell) chance += 20;
6898                                 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
6899                                 else if (p_ptr->easy_spell) chance-=3;
6900                                 else if (p_ptr->dec_mana) chance-=2;
6901                                 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
6902                                 /* Stunning makes spells harder */
6903                                 if (p_ptr->stun > 50) chance += 25;
6904                                 else if (p_ptr->stun) chance += 15;
6905
6906                                 if (chance > 95) chance = 95;
6907
6908                                 if(p_ptr->dec_mana) chance--;
6909                                 if (p_ptr->heavy_spell) chance += 5;
6910
6911                                 col = TERM_WHITE;
6912
6913                                 if (k_idx)
6914                                 {
6915                                         if (tval == TV_ROD)
6916                                         {
6917                                                 strcat(dummy, format(
6918 #ifdef JP
6919                                                                " %-22.22s ½¼Å¶:%2d/%2d%3d%%",
6920 #else
6921                                                                " %-22.22s   (%2d/%2d) %3d%%",
6922 #endif
6923                                                                k_name + k_info[k_idx].name, 
6924                                                                p_ptr->magic_num1[ctr+ext] ? 
6925                                                                (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, 
6926                                                                p_ptr->magic_num2[ctr+ext], chance));
6927                                                 if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * EATER_ROD_CHARGE) col = TERM_RED;
6928                                         }
6929                                         else
6930                                         {
6931                                                 strcat(dummy, format(" %-22.22s    %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/EATER_CHARGE), p_ptr->magic_num2[ctr+ext], chance));
6932                                                 if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED;
6933                                         }
6934                                 }
6935                                 else
6936                                         strcpy(dummy, "");
6937                                 c_prt(col, dummy, y1, x1);
6938                         }
6939                 }
6940
6941                 if(!get_com(out_val, &choice, FALSE)) break; 
6942
6943                 if (use_menu && choice != ' ')
6944                 {
6945                         switch(choice)
6946                         {
6947                                 case '0':
6948                                 {
6949                                         screen_load();
6950                                         return (FALSE);
6951                                         break;
6952                                 }
6953
6954                                 case '8':
6955                                 case 'k':
6956                                 case 'K':
6957                                 {
6958                                         do
6959                                         {
6960                                                 menu_line += EATER_EXT - 1;
6961                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
6962                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
6963                                         break;
6964                                 }
6965
6966                                 case '2':
6967                                 case 'j':
6968                                 case 'J':
6969                                 {
6970                                         do
6971                                         {
6972                                                 menu_line++;
6973                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
6974                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
6975                                         break;
6976                                 }
6977
6978                                 case '4':
6979                                 case 'h':
6980                                 case 'H':
6981                                 case '6':
6982                                 case 'l':
6983                                 case 'L':
6984                                 {
6985                                         bool reverse = FALSE;
6986                                         if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
6987                                         if (menu_line > EATER_EXT/2)
6988                                         {
6989                                                 menu_line -= EATER_EXT/2;
6990                                                 reverse = TRUE;
6991                                         }
6992                                         else menu_line+=EATER_EXT/2;
6993                                         while(!p_ptr->magic_num2[menu_line+ext-1])
6994                                         {
6995                                                 if (reverse)
6996                                                 {
6997                                                         menu_line--;
6998                                                         if (menu_line < 2) reverse = FALSE;
6999                                                 }
7000                                                 else
7001                                                 {
7002                                                         menu_line++;
7003                                                         if (menu_line > EATER_EXT-1) reverse = TRUE;
7004                                                 }
7005                                         }
7006                                         break;
7007                                 }
7008
7009                                 case 'x':
7010                                 case 'X':
7011                                 case '\r':
7012                                 {
7013                                         i = menu_line - 1;
7014                                         ask = FALSE;
7015                                         break;
7016                                 }
7017                         }
7018                 }
7019
7020                 /* Request redraw */
7021                 if (use_menu && ask) continue;
7022
7023                 /* Request redraw */
7024                 if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?')))
7025                 {
7026                         /* Hide the list */
7027                         if (request_list)
7028                         {
7029                                 /* Hide list */
7030                                 request_list = FALSE;
7031                                 
7032                                 /* Restore the screen */
7033                                 screen_load();
7034                                 screen_save();
7035                         }
7036                         else
7037                                 request_list = TRUE;
7038
7039                         /* Redo asking */
7040                         continue;
7041                 }
7042
7043                 if (!use_menu)
7044                 {
7045                         if (isalpha(choice))
7046                         {
7047                                 /* Note verify */
7048                                 ask = (isupper(choice));
7049
7050                                 /* Lowercase */
7051                                 if (ask) choice = tolower(choice);
7052
7053                                 /* Extract request */
7054                                 i = (islower(choice) ? A2I(choice) : -1);
7055                         }
7056                         else
7057                         {
7058                                 ask = FALSE; /* Can't uppercase digits */
7059
7060                                 i = choice - '0' + 26;
7061                         }
7062                 }
7063
7064                 /* Totally Illegal */
7065                 if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext])
7066                 {
7067                         bell();
7068                         continue;
7069                 }
7070
7071                 if (!only_browse)
7072                 {
7073                         /* Verify it */
7074                         if (ask)
7075                         {
7076                                 char tmp_val[160];
7077
7078                                 /* Prompt */
7079 #ifdef JP
7080                                 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", k_name + k_info[lookup_kind(tval ,i)].name);
7081 #else
7082                                 (void) strnfmt(tmp_val, 78, "Use %s?", k_name + k_info[lookup_kind(tval ,i)].name);
7083 #endif
7084
7085                                 /* Belay that order */
7086                                 if (!get_check(tmp_val)) continue;
7087                         }
7088                         if (tval == TV_ROD)
7089                         {
7090                                 if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE)
7091                                 {
7092 #ifdef JP
7093                                         msg_print("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
7094 #else
7095                                         msg_print("The magic are still charging.");
7096 #endif
7097                                         msg_print(NULL);
7098                                         if (use_menu) ask = TRUE;
7099                                         continue;
7100                                 }
7101                         }
7102                         else
7103                         {
7104                                 if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
7105                                 {
7106 #ifdef JP
7107                                         msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
7108 #else
7109                                         msg_print("The magic has no charges left.");
7110 #endif
7111                                         msg_print(NULL);
7112                                         if (use_menu) ask = TRUE;
7113                                         continue;
7114                                 }
7115                         }
7116                 }
7117
7118                 /* Browse */
7119                 else
7120                 {
7121                         int line, j;
7122                         char temp[70 * 20];
7123
7124                         /* Clear lines, position cursor  (really should use strlen here) */
7125                         Term_erase(7, 23, 255);
7126                         Term_erase(7, 22, 255);
7127                         Term_erase(7, 21, 255);
7128                         Term_erase(7, 20, 255);
7129
7130                         roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp);
7131                         for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j]))
7132                         {
7133                                 prt(&temp[j], line, 10);
7134                                 line++;
7135                         }
7136         
7137 #ifdef JP
7138                         prt("²¿¤«¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£",0,0);
7139 #else
7140                         prt("Hit any key.",0,0);
7141 #endif
7142                         (void)inkey();
7143                         continue;
7144                 }
7145
7146                 /* Stop the loop */
7147                 flag = TRUE;
7148         }
7149
7150         /* Restore the screen */
7151         screen_load();
7152
7153         if (!flag) return -1;
7154
7155 #ifdef ALLOW_REPEAT
7156         repeat_push(ext+i);
7157 #endif /* ALLOW_REPEAT */
7158         return ext+i;
7159 }
7160
7161
7162 /*
7163  *  Use eaten rod, wand or staff
7164  */
7165 void do_cmd_magic_eater(bool only_browse)
7166 {
7167         int item, chance, level, k_idx, tval, sval;
7168         bool use_charge = TRUE;
7169
7170         /* Not when confused */
7171         if (!only_browse && p_ptr->confused)
7172         {
7173 #ifdef JP
7174 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
7175 #else
7176                 msg_print("You are too confused!");
7177 #endif
7178
7179                 return;
7180         }
7181
7182         item = select_magic_eater(only_browse);
7183         if (item == -1)
7184         {
7185                 energy_use = 0;
7186                 return;
7187         }
7188         if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
7189         else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
7190         else {tval = TV_STAFF;sval = item;}
7191         k_idx = lookup_kind(tval, sval);
7192
7193         level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
7194         chance = level * 4 / 5 + 20;
7195         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
7196         level /= 2;
7197         if (p_ptr->lev > level)
7198         {
7199                 chance -= 3 * (p_ptr->lev - level);
7200         }
7201         chance += p_ptr->to_m_chance;
7202         if (p_ptr->heavy_spell) chance += 20;
7203         if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
7204         else if (p_ptr->easy_spell) chance-=3;
7205         else if (p_ptr->dec_mana) chance-=2;
7206         chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
7207         /* Stunning makes spells harder */
7208         if (p_ptr->stun > 50) chance += 25;
7209         else if (p_ptr->stun) chance += 15;
7210
7211         if (chance > 95) chance = 95;
7212
7213         if(p_ptr->dec_mana) chance--;
7214         if (p_ptr->heavy_spell) chance += 5;
7215
7216         if (randint0(100) < chance)
7217         {
7218                 if (flush_failure) flush();
7219
7220 #ifdef JP
7221 msg_print("¼öʸ¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª");
7222 #else
7223                 msg_format("You failed to get the magic off!");
7224 #endif
7225
7226                 sound(SOUND_FAIL);
7227                 if (randint1(100) >= chance)
7228                         chg_virtue(V_CHANCE,-1);
7229                 energy_use = 100;
7230
7231                 return;
7232         }
7233         else
7234         {
7235                 int dir = 0;
7236
7237                 if (tval == TV_ROD)
7238                 {
7239                         if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
7240                                 if (!get_aim_dir(&dir)) return;
7241                         rod_effect(sval, dir, &use_charge, TRUE);
7242                         if (!use_charge) return;
7243                 }
7244                 else if (tval == TV_WAND)
7245                 {
7246                         if (!get_aim_dir(&dir)) return;
7247                         wand_effect(sval, dir, TRUE);
7248                 }
7249                 else
7250                 {
7251                         staff_effect(sval, &use_charge, TRUE, TRUE);
7252                         if (!use_charge) return;
7253                 }
7254                 if (randint1(100) < chance)
7255                         chg_virtue(V_CHANCE,1);
7256         }
7257         energy_use = 100;
7258         if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
7259         else p_ptr->magic_num1[item] -= EATER_CHARGE;
7260 }