OSDN Git Service

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