OSDN Git Service

Merge branch 'master' of git.sourceforge.jp:/gitroot/hengband/hengband
[hengband/hengband.git] / src / cmd6.c
1 /*!
2  * @file cmd6.c
3  * @brief ¥×¥ì¥¤¥ä¡¼¤Î¥¢¥¤¥Æ¥à¤Ë´Ø¤¹¤ë¥³¥Þ¥ó¥É¤Î¼ÂÁõ2 / Spell/Prayer commands
4  * @date 2014/01/27
5  * @author
6  * <pre>
7  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  * 2014 Deskull rearranged comment for Doxygen.\n
12  * </pre>
13  * @details
14  * <pre>
15  * This file includes code for eating food, drinking potions,
16  * reading scrolls, aiming wands, using staffs, zapping rods,
17  * and activating artifacts.
18  *
19  * In all cases, if the player becomes "aware" of the item's use
20  * by testing it, mark it as "aware" and reward some experience
21  * based on the object's level, always rounding up.  If the player
22  * remains "unaware", mark that object "kind" as "tried".
23  *
24  * This code now correctly handles the unstacking of wands, staffs,
25  * and rods.  Note the overly paranoid warning about potential pack
26  * overflow, which allows the player to use and drop a stacked item.
27  *
28  * In all "unstacking" scenarios, the "used" object is "carried" as if
29  * the player had just picked it up.  In particular, this means that if
30  * the use of an item induces pack overflow, that item will be dropped.
31  *
32  * For simplicity, these routines induce a full "pack reorganization"
33  * which not only combines similar items, but also reorganizes various
34  * items to obey the current "sorting" method.  This may require about
35  * 400 item comparisons, but only occasionally.
36  *
37  * There may be a BIG problem with any "effect" that can cause "changes"
38  * to the inventory.  For example, a "scroll of recharging" can cause
39  * a wand/staff to "disappear", moving the inventory up.  Luckily, the
40  * scrolls all appear BEFORE the staffs/wands, so this is not a problem.
41  * But, for example, a "staff of recharging" could cause MAJOR problems.
42  * In such a case, it will be best to either (1) "postpone" the effect
43  * until the end of the function, or (2) "change" the effect, say, into
44  * giving a staff "negative" charges, or "turning a staff into a stick".
45  * It seems as though a "rod of recharging" might in fact cause problems.
46  * The basic problem is that the act of recharging (and destroying) an
47  * item causes the inducer of that action to "move", causing "o_ptr" to
48  * no longer point at the correct item, with horrifying results.
49  *
50  * Note that food/potions/scrolls no longer use bit-flags for effects,
51  * but instead use the "sval" (which is also used to sort the objects).
52  * </pre>
53  */
54
55 #include "angband.h"
56
57
58 /*!
59  * @brief ¿©ÎÁ¤ò¿©¤Ù¤ë¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó
60  * @param item ¿©¤Ù¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
61  * @return ¤Ê¤·
62  */
63 static void do_cmd_eat_food_aux(int item)
64 {
65         int ident, lev;
66         object_type *o_ptr;
67
68         if (music_singing_any()) stop_singing();
69         if (hex_spelling_any()) stop_hex_spell_all();
70
71         /* Get the item (in the pack) */
72         if (item >= 0)
73         {
74                 o_ptr = &inventory[item];
75         }
76
77         /* Get the item (on the floor) */
78         else
79         {
80                 o_ptr = &o_list[0 - item];
81         }
82
83         /* Sound */
84         sound(SOUND_EAT);
85
86         /* Take a turn */
87         energy_use = 100;
88
89         /* Identity not known yet */
90         ident = FALSE;
91
92         /* Object level */
93         lev = k_info[o_ptr->k_idx].level;
94
95         if (o_ptr->tval == TV_FOOD)
96         {
97                 /* Analyze the food */
98                 switch (o_ptr->sval)
99                 {
100                         case SV_FOOD_POISON:
101                         {
102                                 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
103                                 {
104                                         if (set_poisoned(p_ptr->poisoned + randint0(10) + 10))
105                                         {
106                                                 ident = TRUE;
107                                         }
108                                 }
109                                 break;
110                         }
111
112                         case SV_FOOD_BLINDNESS:
113                         {
114                                 if (!p_ptr->resist_blind)
115                                 {
116                                         if (set_blind(p_ptr->blind + randint0(200) + 200))
117                                         {
118                                                 ident = TRUE;
119                                         }
120                                 }
121                                 break;
122                         }
123
124                         case SV_FOOD_PARANOIA:
125                         {
126                                 if (!p_ptr->resist_fear)
127                                 {
128                                         if (set_afraid(p_ptr->afraid + randint0(10) + 10))
129                                         {
130                                                 ident = TRUE;
131                                         }
132                                 }
133                                 break;
134                         }
135
136                         case SV_FOOD_CONFUSION:
137                         {
138                                 if (!p_ptr->resist_conf)
139                                 {
140                                         if (set_confused(p_ptr->confused + randint0(10) + 10))
141                                         {
142                                                 ident = TRUE;
143                                         }
144                                 }
145                                 break;
146                         }
147
148                         case SV_FOOD_HALLUCINATION:
149                         {
150                                 if (!p_ptr->resist_chaos)
151                                 {
152                                         if (set_image(p_ptr->image + randint0(250) + 250))
153                                         {
154                                                 ident = TRUE;
155                                         }
156                                 }
157                                 break;
158                         }
159
160                         case SV_FOOD_PARALYSIS:
161                         {
162                                 if (!p_ptr->free_act)
163                                 {
164                                         if (set_paralyzed(p_ptr->paralyzed + randint0(10) + 10))
165                                         {
166                                                 ident = TRUE;
167                                         }
168                                 }
169                                 break;
170                         }
171
172                         case SV_FOOD_WEAKNESS:
173                         {
174 #ifdef JP
175                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
176 #else
177                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
178 #endif
179
180                                 (void)do_dec_stat(A_STR);
181                                 ident = TRUE;
182                                 break;
183                         }
184
185                         case SV_FOOD_SICKNESS:
186                         {
187 #ifdef JP
188                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
189 #else
190                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
191 #endif
192
193                                 (void)do_dec_stat(A_CON);
194                                 ident = TRUE;
195                                 break;
196                         }
197
198                         case SV_FOOD_STUPIDITY:
199                         {
200 #ifdef JP
201                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
202 #else
203                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
204 #endif
205
206                                 (void)do_dec_stat(A_INT);
207                                 ident = TRUE;
208                                 break;
209                         }
210
211                         case SV_FOOD_NAIVETY:
212                         {
213 #ifdef JP
214                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
215 #else
216                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
217 #endif
218
219                                 (void)do_dec_stat(A_WIS);
220                                 ident = TRUE;
221                                 break;
222                         }
223
224                         case SV_FOOD_UNHEALTH:
225                         {
226 #ifdef JP
227                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
228 #else
229                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
230 #endif
231
232                                 (void)do_dec_stat(A_CON);
233                                 ident = TRUE;
234                                 break;
235                         }
236
237                         case SV_FOOD_DISEASE:
238                         {
239 #ifdef JP
240                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
241 #else
242                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
243 #endif
244
245                                 (void)do_dec_stat(A_STR);
246                                 ident = TRUE;
247                                 break;
248                         }
249
250                         case SV_FOOD_CURE_POISON:
251                         {
252                                 if (set_poisoned(0)) ident = TRUE;
253                                 break;
254                         }
255
256                         case SV_FOOD_CURE_BLINDNESS:
257                         {
258                                 if (set_blind(0)) ident = TRUE;
259                                 break;
260                         }
261
262                         case SV_FOOD_CURE_PARANOIA:
263                         {
264                                 if (set_afraid(0)) ident = TRUE;
265                                 break;
266                         }
267
268                         case SV_FOOD_CURE_CONFUSION:
269                         {
270                                 if (set_confused(0)) ident = TRUE;
271                                 break;
272                         }
273
274                         case SV_FOOD_CURE_SERIOUS:
275                         {
276                                 if (hp_player(damroll(4, 8))) ident = TRUE;
277                                 break;
278                         }
279
280                         case SV_FOOD_RESTORE_STR:
281                         {
282                                 if (do_res_stat(A_STR)) ident = TRUE;
283                                 break;
284                         }
285
286                         case SV_FOOD_RESTORE_CON:
287                         {
288                                 if (do_res_stat(A_CON)) ident = TRUE;
289                                 break;
290                         }
291
292                         case SV_FOOD_RESTORING:
293                         {
294                                 if (do_res_stat(A_STR)) ident = TRUE;
295                                 if (do_res_stat(A_INT)) ident = TRUE;
296                                 if (do_res_stat(A_WIS)) ident = TRUE;
297                                 if (do_res_stat(A_DEX)) ident = TRUE;
298                                 if (do_res_stat(A_CON)) ident = TRUE;
299                                 if (do_res_stat(A_CHR)) ident = TRUE;
300                                 break;
301                         }
302
303
304 #ifdef JP
305                         /* ¤½¤ì¤¾¤ì¤Î¿©¤Ùʪ¤Î´¶ÁÛ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
306                         case SV_FOOD_BISCUIT:
307                         {
308                                 msg_print("´Å¤¯¤Æ¥µ¥¯¥µ¥¯¤·¤Æ¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
309                                 ident = TRUE;
310                                 break;
311                         }
312
313                         case SV_FOOD_JERKY:
314                         {
315                                 msg_print("»õ¤´¤¿¤¨¤¬¤¢¤Ã¤Æ¤ª¤¤¤·¤¤¡£");
316                                 ident = TRUE;
317                                 break;
318                         }
319
320                         case SV_FOOD_SLIME_MOLD:
321                         {
322                                 msg_print("¤³¤ì¤Ï¤Ê¤ó¤È¤â·ÁÍƤ·¤¬¤¿¤¤Ì£¤À¡£");
323                                 ident = TRUE;
324                                 break;
325                         }
326
327                         case SV_FOOD_RATION:
328                         {
329                                 msg_print("¤³¤ì¤Ï¤ª¤¤¤·¤¤¡£");
330                                 ident = TRUE;
331                                 break;
332                         }
333 #else
334                         case SV_FOOD_RATION:
335                         case SV_FOOD_BISCUIT:
336                         case SV_FOOD_JERKY:
337                         case SV_FOOD_SLIME_MOLD:
338                         {
339                                 msg_print("That tastes good.");
340                                 ident = TRUE;
341                                 break;
342                         }
343 #endif
344
345
346                         case SV_FOOD_WAYBREAD:
347                         {
348 #ifdef JP
349                                 msg_print("¤³¤ì¤Ï¤Ò¤¸¤ç¤¦¤ËÈþÌ£¤À¡£");
350 #else
351                                 msg_print("That tastes good.");
352 #endif
353
354                                 (void)set_poisoned(0);
355                                 (void)hp_player(damroll(4, 8));
356                                 ident = TRUE;
357                                 break;
358                         }
359
360 #ifdef JP
361                         case SV_FOOD_PINT_OF_ALE:
362                         {
363                                 msg_print("¤Î¤É¤´¤·Á֤䤫¤À¡£");
364                                 ident = TRUE;
365                                 break;
366                         }
367
368                         case SV_FOOD_PINT_OF_WINE:
369                         {
370                                 msg_print("That tastes good.");
371                                 ident = TRUE;
372                                 break;
373                         }
374 #else
375                         case SV_FOOD_PINT_OF_ALE:
376                         case SV_FOOD_PINT_OF_WINE:
377                         {
378                                 msg_print("That tastes good.");
379                                 ident = TRUE;
380                                 break;
381                         }
382 #endif
383
384                 }
385         }
386
387         /* Combine / Reorder the pack (later) */
388         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
389
390         if (!(object_is_aware(o_ptr)))
391         {
392                 chg_virtue(V_KNOWLEDGE, -1);
393                 chg_virtue(V_PATIENCE, -1);
394                 chg_virtue(V_CHANCE, 1);
395         }
396
397         /* We have tried it */
398         if (o_ptr->tval == TV_FOOD) object_tried(o_ptr);
399
400         /* The player is now aware of the object */
401         if (ident && !object_is_aware(o_ptr))
402         {
403                 object_aware(o_ptr);
404                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
405         }
406
407         /* Window stuff */
408         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
409
410
411         /* Food can feed the player */
412         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
413         {
414                 /* Reduced nutritional benefit */
415                 (void)set_food(p_ptr->food + (o_ptr->pval / 10));
416 #ifdef JP
417 msg_print("¤¢¤Ê¤¿¤Î¤è¤¦¤Ê¼Ô¤Ë¤È¤Ã¤Æ¿©ÎȤʤɶϤ«¤Ê±ÉÍܤˤ·¤«¤Ê¤é¤Ê¤¤¡£");
418 #else
419                 msg_print("Mere victuals hold scant sustenance for a being such as yourself.");
420 #endif
421
422                 if (p_ptr->food < PY_FOOD_ALERT)   /* Hungry */
423 #ifdef JP
424 msg_print("¤¢¤Ê¤¿¤Îµ²¤¨¤Ï¿·Á¯¤Ê·ì¤Ë¤è¤Ã¤Æ¤Î¤ßËþ¤¿¤µ¤ì¤ë¡ª");
425 #else
426                         msg_print("Your hunger can only be satisfied with fresh blood!");
427 #endif
428
429         }
430         else if ((prace_is_(RACE_SKELETON) ||
431                   prace_is_(RACE_GOLEM) ||
432                   prace_is_(RACE_ZOMBIE) ||
433                   prace_is_(RACE_SPECTRE)) &&
434                  (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND))
435         {
436                 cptr staff;
437
438                 if (o_ptr->tval == TV_STAFF &&
439                     (item < 0) && (o_ptr->number > 1))
440                 {
441 #ifdef JP
442                         msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
443 #else
444                         msg_print("You must first pick up the staffs.");
445 #endif
446                         return;
447                 }
448
449 #ifdef JP
450                 staff = (o_ptr->tval == TV_STAFF) ? "¾ó" : "ËâË¡ËÀ";
451 #else
452                 staff = (o_ptr->tval == TV_STAFF) ? "staff" : "wand";
453 #endif
454
455                 /* "Eat" charges */
456                 if (o_ptr->pval == 0)
457                 {
458 #ifdef JP
459                         msg_format("¤³¤Î%s¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£", staff);
460 #else
461                         msg_format("The %s has no charges left.", staff);
462 #endif
463
464                         o_ptr->ident |= (IDENT_EMPTY);
465
466                         /* Combine / Reorder the pack (later) */
467                         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
468                         p_ptr->window |= (PW_INVEN);
469
470                         return;
471                 }
472
473 #ifdef JP
474                 msg_format("¤¢¤Ê¤¿¤Ï%s¤ÎËâÎϤò¥¨¥Í¥ë¥®¡¼¸»¤È¤·¤ÆµÛ¼ý¤·¤¿¡£", staff);
475 #else
476                 msg_format("You absorb mana of the %s as your energy.", staff);
477 #endif
478
479                 /* Use a single charge */
480                 o_ptr->pval--;
481
482                 /* Eat a charge */
483                 set_food(p_ptr->food + 5000);
484
485                 /* XXX Hack -- unstack if necessary */
486                 if (o_ptr->tval == TV_STAFF &&
487                     (item >= 0) && (o_ptr->number > 1))
488                 {
489                         object_type forge;
490                         object_type *q_ptr;
491
492                         /* Get local object */
493                         q_ptr = &forge;
494
495                         /* Obtain a local object */
496                         object_copy(q_ptr, o_ptr);
497
498                         /* Modify quantity */
499                         q_ptr->number = 1;
500
501                         /* Restore the charges */
502                         o_ptr->pval++;
503
504                         /* Unstack the used item */
505                         o_ptr->number--;
506                         p_ptr->total_weight -= q_ptr->weight;
507                         item = inven_carry(q_ptr);
508
509                         /* Message */
510 #ifdef JP
511                         msg_format("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
512 #else
513                         msg_print("You unstack your staff.");
514 #endif
515                 }
516
517                 /* Describe charges in the pack */
518                 if (item >= 0)
519                 {
520                         inven_item_charges(item);
521                 }
522
523                 /* Describe charges on the floor */
524                 else
525                 {
526                         floor_item_charges(0 - item);
527                 }
528
529                 /* Window stuff */
530                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
531
532                 /* Don't eat a staff/wand itself */
533                 return;
534         }
535         else if ((prace_is_(RACE_DEMON) ||
536                  (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) &&
537                  (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE &&
538                   my_strchr("pht", r_info[o_ptr->pval].d_char)))
539         {
540                 /* Drain vitality of humanoids */
541                 char o_name[MAX_NLEN];
542
543                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
544
545 #ifdef JP
546                 msg_format("%s¤Ïdz¤¨¾å¤ê³¥¤Ë¤Ê¤Ã¤¿¡£ÀºÎϤòµÛ¼ý¤·¤¿µ¤¤¬¤¹¤ë¡£", o_name);
547 #else
548                 msg_format("%^s is burnt to ashes.  You absorb its vitality!", o_name);
549 #endif
550                 (void)set_food(PY_FOOD_MAX - 1);
551         }
552         else if (prace_is_(RACE_SKELETON))
553         {
554 #if 0
555                 if (o_ptr->tval == TV_SKELETON ||
556                     (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
557                 {
558 #ifdef JP
559                         msg_print("¤¢¤Ê¤¿¤Ï¹ü¤Ç¼«Ê¬¤ÎÂΤòÊä¤Ã¤¿¡£");
560 #else
561                         msg_print("Your body absorbs the bone.");
562 #endif
563                         set_food(p_ptr->food + 5000);
564                 }
565                 else 
566 #endif
567
568                 if (!((o_ptr->sval == SV_FOOD_WAYBREAD) ||
569                       (o_ptr->sval < SV_FOOD_BISCUIT)))
570                 {
571                         object_type forge;
572                         object_type *q_ptr = &forge;
573
574 #ifdef JP
575 msg_print("¿©¤Ùʪ¤¬¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
576 #else
577                         msg_print("The food falls through your jaws!");
578 #endif
579
580
581                         /* Create the item */
582                         object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval));
583
584                         /* Drop the object from heaven */
585                         (void)drop_near(q_ptr, -1, py, px);
586                 }
587                 else
588                 {
589 #ifdef JP
590 msg_print("¿©¤Ùʪ¤¬¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¡¢¾Ã¤¨¤¿¡ª");
591 #else
592                         msg_print("The food falls through your jaws and vanishes!");
593 #endif
594
595                 }
596         }
597         else if (prace_is_(RACE_GOLEM) ||
598                  prace_is_(RACE_ZOMBIE) ||
599                  prace_is_(RACE_ENT) ||
600                  prace_is_(RACE_DEMON) ||
601                  prace_is_(RACE_ANDROID) ||
602                  prace_is_(RACE_SPECTRE) ||
603                  (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
604         {
605 #ifdef JP
606 msg_print("À¸¼Ô¤Î¿©Êª¤Ï¤¢¤Ê¤¿¤Ë¤È¤Ã¤Æ¤Û¤È¤ó¤É±ÉÍܤˤʤé¤Ê¤¤¡£");
607 #else
608                 msg_print("The food of mortals is poor sustenance for you.");
609 #endif
610
611                 set_food(p_ptr->food + ((o_ptr->pval) / 20));
612         }
613         else if (o_ptr->tval == TV_FOOD && o_ptr->sval == SV_FOOD_WAYBREAD)
614         {
615                 /* Waybread is always fully satisfying. */
616                 set_food(MAX(p_ptr->food, PY_FOOD_MAX - 1));
617         }
618         else
619         {
620                 /* Food can feed the player */
621                 (void)set_food(p_ptr->food + o_ptr->pval);
622         }
623
624         /* Destroy a food in the pack */
625         if (item >= 0)
626         {
627                 inven_item_increase(item, -1);
628                 inven_item_describe(item);
629                 inven_item_optimize(item);
630         }
631
632         /* Destroy a food on the floor */
633         else
634         {
635                 floor_item_increase(0 - item, -1);
636                 floor_item_describe(0 - item);
637                 floor_item_optimize(0 - item);
638         }
639 }
640
641
642 /*!
643  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤¬¿©¤Ù¤ë¤³¤È¤¬¤Ç¤­¤ë¤«¤òȽÄꤹ¤ë /
644  * Hook to determine if an object is eatable
645  * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
646  * @return ¿©¤Ù¤ë¤³¤È¤¬²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
647  */
648 static bool item_tester_hook_eatable(object_type *o_ptr)
649 {
650         if (o_ptr->tval==TV_FOOD) return TRUE;
651
652 #if 0
653         if (prace_is_(RACE_SKELETON))
654         {
655                 if (o_ptr->tval == TV_SKELETON ||
656                     (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
657                         return TRUE;
658         }
659         else 
660 #endif
661
662         if (prace_is_(RACE_SKELETON) ||
663             prace_is_(RACE_GOLEM) ||
664             prace_is_(RACE_ZOMBIE) ||
665             prace_is_(RACE_SPECTRE))
666         {
667                 if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)
668                         return TRUE;
669         }
670         else if (prace_is_(RACE_DEMON) ||
671                  (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON))
672         {
673                 if (o_ptr->tval == TV_CORPSE &&
674                     o_ptr->sval == SV_CORPSE &&
675                     my_strchr("pht", r_info[o_ptr->pval].d_char))
676                         return TRUE;
677         }
678
679         /* Assume not */
680         return (FALSE);
681 }
682
683
684 /*!
685  * @brief ¿©ÎÁ¤ò¿©¤Ù¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
686  * Eat some food (from the pack or floor)
687  * @return ¤Ê¤·
688  */
689 void do_cmd_eat_food(void)
690 {
691         int         item;
692         cptr        q, s;
693
694
695         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
696         {
697                 set_action(ACTION_NONE);
698         }
699
700         /* Restrict choices to food */
701         item_tester_hook = item_tester_hook_eatable;
702
703         /* Get an item */
704 #ifdef JP
705         q = "¤É¤ì¤ò¿©¤Ù¤Þ¤¹¤«? ";
706         s = "¿©¤Ùʪ¤¬¤Ê¤¤¡£";
707 #else
708         q = "Eat which item? ";
709         s = "You have nothing to eat.";
710 #endif
711
712         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
713
714         /* Eat the object */
715         do_cmd_eat_food_aux(item);
716 }
717
718
719 /*!
720  * @brief Ìô¤ò°û¤à¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
721  * Quaff a potion (from the pack or the floor)
722  * @param item °û¤àÌô¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
723  * @return ¤Ê¤·
724  */
725 static void do_cmd_quaff_potion_aux(int item)
726 {
727         int         ident, lev;
728         object_type *o_ptr;
729         object_type forge;
730         object_type *q_ptr;
731
732
733         /* Take a turn */
734         energy_use = 100;
735
736         if (world_player)
737         {
738                 if (flush_failure) flush();
739 #ifdef JP
740                 msg_print("ÉÓ¤«¤é¿å¤¬Î®¤ì½Ð¤Æ¤³¤Ê¤¤¡ª");
741 #else
742                 msg_print("The potion doesn't flow out from a bottle.");
743 #endif
744
745                 sound(SOUND_FAIL);
746                 return;
747         }
748
749         if (music_singing_any()) stop_singing();
750         if (hex_spelling_any())
751         {
752                 if (!hex_spelling(HEX_INHAIL)) stop_hex_spell_all();
753         }
754
755         /* Get the item (in the pack) */
756         if (item >= 0)
757         {
758                 o_ptr = &inventory[item];
759         }
760
761         /* Get the item (on the floor) */
762         else
763         {
764                 o_ptr = &o_list[0 - item];
765         }
766
767         /* Get local object */
768         q_ptr = &forge;
769
770         /* Obtain a local object */
771         object_copy(q_ptr, o_ptr);
772
773         /* Single object */
774         q_ptr->number = 1;
775
776         /* Reduce and describe inventory */
777         if (item >= 0)
778         {
779                 inven_item_increase(item, -1);
780                 inven_item_describe(item);
781                 inven_item_optimize(item);
782         }
783
784         /* Reduce and describe floor item */
785         else
786         {
787                 floor_item_increase(0 - item, -1);
788                 floor_item_describe(0 - item);
789                 floor_item_optimize(0 - item);
790         }
791
792         /* Sound */
793         sound(SOUND_QUAFF);
794
795
796         /* Not identified yet */
797         ident = FALSE;
798
799         /* Object level */
800         lev = k_info[q_ptr->k_idx].level;
801
802         /* Analyze the potion */
803         if (q_ptr->tval == TV_POTION)
804         {
805                 switch (q_ptr->sval)
806                 {
807 #ifdef JP
808                         /* °û¤ß¤´¤¿¤¨¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
809                 case SV_POTION_WATER:
810                         msg_print("¸ý¤ÎÃ椬¤µ¤Ã¤Ñ¤ê¤·¤¿¡£");
811                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
812                         ident = TRUE;
813                         break;
814
815                 case SV_POTION_APPLE_JUICE:
816                         msg_print("´Å¤¯¤Æ¥µ¥Ã¥Ñ¥ê¤È¤·¤Æ¤¤¤Æ¡¢¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
817                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
818                         ident = TRUE;
819                         break;
820
821                 case SV_POTION_SLIME_MOLD:
822                         msg_print("¤Ê¤ó¤È¤âÉÔµ¤Ì£¤ÊÌ£¤À¡£");
823                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
824                         ident = TRUE;
825                         break;
826
827 #else
828                 case SV_POTION_WATER:
829                 case SV_POTION_APPLE_JUICE:
830                 case SV_POTION_SLIME_MOLD:
831                         msg_print("You feel less thirsty.");
832                         ident = TRUE;
833                         break;
834 #endif
835
836                 case SV_POTION_SLOWNESS:
837                         if (set_slow(randint1(25) + 15, FALSE)) ident = TRUE;
838                         break;
839
840                 case SV_POTION_SALT_WATER:
841 #ifdef JP
842                         msg_print("¤¦¤§¡ª»×¤ï¤ºÅǤ¤¤Æ¤·¤Þ¤Ã¤¿¡£");
843 #else
844                         msg_print("The potion makes you vomit!");
845 #endif
846
847                         if (!(prace_is_(RACE_GOLEM) ||
848                               prace_is_(RACE_ZOMBIE) ||
849                               prace_is_(RACE_DEMON) ||
850                               prace_is_(RACE_ANDROID) ||
851                               prace_is_(RACE_SPECTRE) ||
852                               (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)))
853                         {
854                                 /* Only living creatures get thirsty */
855                                 (void)set_food(PY_FOOD_STARVE - 1);
856                         }
857
858                         (void)set_poisoned(0);
859                         (void)set_paralyzed(p_ptr->paralyzed + 4);
860                         ident = TRUE;
861                         break;
862
863                 case SV_POTION_POISON:
864                         if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
865                         {
866                                 if (set_poisoned(p_ptr->poisoned + randint0(15) + 10))
867                                 {
868                                         ident = TRUE;
869                                 }
870                         }
871                         break;
872
873                 case SV_POTION_BLINDNESS:
874                         if (!p_ptr->resist_blind)
875                         {
876                                 if (set_blind(p_ptr->blind + randint0(100) + 100))
877                                 {
878                                         ident = TRUE;
879                                 }
880                         }
881                         break;
882
883                 case SV_POTION_CONFUSION: /* Booze */
884                         if (p_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
885                         else if (!p_ptr->resist_conf) p_ptr->special_attack |= ATTACK_SUIKEN;
886                         if (!p_ptr->resist_conf)
887                         {
888                                 if (set_confused(randint0(20) + 15))
889                                 {
890                                         ident = TRUE;
891                                 }
892                         }
893
894                         if (!p_ptr->resist_chaos)
895                         {
896                                 if (one_in_(2))
897                                 {
898                                         if (set_image(p_ptr->image + randint0(150) + 150))
899                                         {
900                                                 ident = TRUE;
901                                         }
902                                 }
903                                 if (one_in_(13) && (p_ptr->pclass != CLASS_MONK))
904                                 {
905                                         ident = TRUE;
906                                         if (one_in_(3)) lose_all_info();
907                                         else wiz_dark();
908                                         (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
909                                         wiz_dark();
910 #ifdef JP
911                                         msg_print("ÃΤé¤Ê¤¤¾ì½ê¤ÇÌܤ¬Àä᤿¡£Æ¬Äˤ¬¤¹¤ë¡£");
912                                         msg_print("²¿¤â»×¤¤½Ð¤»¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ØÍ褿¤Î¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
913 #else
914                                         msg_print("You wake up somewhere with a sore head...");
915                                         msg_print("You can't remember a thing, or how you got here!");
916 #endif
917
918                                 }
919                         }
920                         break;
921
922                 case SV_POTION_SLEEP:
923                         if (!p_ptr->free_act)
924                         {
925 #ifdef JP
926                 msg_print("¤¢¤Ê¤¿¤Ï̲¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
927 #else
928                 msg_print("You fall asleep.");
929 #endif
930
931
932                                 if (ironman_nightmare)
933                                 {
934 #ifdef JP
935 msg_print("¶²¤í¤·¤¤¸÷·Ê¤¬Æ¬¤ËÉ⤫¤ó¤Ç¤­¤¿¡£");
936 #else
937                                         msg_print("A horrible vision enters your mind.");
938 #endif
939
940
941                                         /* Pick a nightmare */
942                                         get_mon_num_prep(get_nightmare, NULL);
943
944                                         /* Have some nightmares */
945                                         have_nightmare(get_mon_num(MAX_DEPTH));
946
947                                         /* Remove the monster restriction */
948                                         get_mon_num_prep(NULL, NULL);
949                                 }
950                                 if (set_paralyzed(p_ptr->paralyzed + randint0(4) + 4))
951                                 {
952                                         ident = TRUE;
953                                 }
954                         }
955                         break;
956
957                 case SV_POTION_LOSE_MEMORIES:
958                         if (!p_ptr->hold_exp && (p_ptr->exp > 0))
959                         {
960 #ifdef JP
961                                 msg_print("²áµî¤Îµ­²±¤¬Çö¤ì¤Æ¤¤¤¯µ¤¤¬¤¹¤ë¡£");
962 #else
963                                 msg_print("You feel your memories fade.");
964 #endif
965                                 chg_virtue(V_KNOWLEDGE, -5);
966
967                                 lose_exp(p_ptr->exp / 4);
968                                 ident = TRUE;
969                         }
970                         break;
971
972                 case SV_POTION_RUINATION:
973 #ifdef JP
974                         msg_print("¿È¤â¿´¤â¼å¤Ã¤Æ¤­¤Æ¡¢Àºµ¤¤¬È´¤±¤Æ¤¤¤¯¤è¤¦¤À¡£");
975                         take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "ÇËÌǤÎÌô", -1);
976 #else
977                         msg_print("Your nerves and muscles feel weak and lifeless!");
978                         take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "a potion of Ruination", -1);
979 #endif
980
981                         (void)dec_stat(A_DEX, 25, TRUE);
982                         (void)dec_stat(A_WIS, 25, TRUE);
983                         (void)dec_stat(A_CON, 25, TRUE);
984                         (void)dec_stat(A_STR, 25, TRUE);
985                         (void)dec_stat(A_CHR, 25, TRUE);
986                         (void)dec_stat(A_INT, 25, TRUE);
987                         ident = TRUE;
988                         break;
989
990                 case SV_POTION_DEC_STR:
991                         if (do_dec_stat(A_STR)) ident = TRUE;
992                         break;
993
994                 case SV_POTION_DEC_INT:
995                         if (do_dec_stat(A_INT)) ident = TRUE;
996                         break;
997
998                 case SV_POTION_DEC_WIS:
999                         if (do_dec_stat(A_WIS)) ident = TRUE;
1000                         break;
1001
1002                 case SV_POTION_DEC_DEX:
1003                         if (do_dec_stat(A_DEX)) ident = TRUE;
1004                         break;
1005
1006                 case SV_POTION_DEC_CON:
1007                         if (do_dec_stat(A_CON)) ident = TRUE;
1008                         break;
1009
1010                 case SV_POTION_DEC_CHR:
1011                         if (do_dec_stat(A_CHR)) ident = TRUE;
1012                         break;
1013
1014                 case SV_POTION_DETONATIONS:
1015 #ifdef JP
1016                         msg_print("ÂΤÎÃæ¤Ç·ã¤·¤¤Çúȯ¤¬µ¯¤­¤¿¡ª");
1017                         take_hit(DAMAGE_NOESCAPE, damroll(50, 20), "Çúȯ¤ÎÌô", -1);
1018 #else
1019                         msg_print("Massive explosions rupture your body!");
1020                         take_hit(DAMAGE_NOESCAPE, damroll(50, 20), "a potion of Detonation", -1);
1021 #endif
1022
1023                         (void)set_stun(p_ptr->stun + 75);
1024                         (void)set_cut(p_ptr->cut + 5000);
1025                         ident = TRUE;
1026                         break;
1027
1028                 case SV_POTION_DEATH:
1029                         chg_virtue(V_VITALITY, -1);
1030                         chg_virtue(V_UNLIFE, 5);
1031 #ifdef JP
1032                         msg_print("»à¤Îͽ´¶¤¬ÂÎÃæ¤ò¶î¤±¤á¤°¤Ã¤¿¡£");
1033                         take_hit(DAMAGE_LOSELIFE, 5000, "»à¤ÎÌô", -1);
1034 #else
1035                         msg_print("A feeling of Death flows through your body.");
1036                         take_hit(DAMAGE_LOSELIFE, 5000, "a potion of Death", -1);
1037 #endif
1038
1039                         ident = TRUE;
1040                         break;
1041
1042                 case SV_POTION_INFRAVISION:
1043                         if (set_tim_infra(p_ptr->tim_infra + 100 + randint1(100), FALSE))
1044                         {
1045                                 ident = TRUE;
1046                         }
1047                         break;
1048
1049                 case SV_POTION_DETECT_INVIS:
1050                         if (set_tim_invis(p_ptr->tim_invis + 12 + randint1(12), FALSE))
1051                         {
1052                                 ident = TRUE;
1053                         }
1054                         break;
1055
1056                 case SV_POTION_SLOW_POISON:
1057                         if (set_poisoned(p_ptr->poisoned / 2)) ident = TRUE;
1058                         break;
1059
1060                 case SV_POTION_CURE_POISON:
1061                         if (set_poisoned(0)) ident = TRUE;
1062                         break;
1063
1064                 case SV_POTION_BOLDNESS:
1065                         if (set_afraid(0)) ident = TRUE;
1066                         break;
1067
1068                 case SV_POTION_SPEED:
1069                         if (!p_ptr->fast)
1070                         {
1071                                 if (set_fast(randint1(25) + 15, FALSE)) ident = TRUE;
1072                         }
1073                         else
1074                         {
1075                                 (void)set_fast(p_ptr->fast + 5, FALSE);
1076                         }
1077                         break;
1078
1079                 case SV_POTION_RESIST_HEAT:
1080                         if (set_oppose_fire(p_ptr->oppose_fire + randint1(10) + 10, FALSE))
1081                         {
1082                                 ident = TRUE;
1083                         }
1084                         break;
1085
1086                 case SV_POTION_RESIST_COLD:
1087                         if (set_oppose_cold(p_ptr->oppose_cold + randint1(10) + 10, FALSE))
1088                         {
1089                                 ident = TRUE;
1090                         }
1091                         break;
1092
1093                 case SV_POTION_HEROISM:
1094                         if (set_afraid(0)) ident = TRUE;
1095                         if (set_hero(p_ptr->hero + randint1(25) + 25, FALSE)) ident = TRUE;
1096                         if (hp_player(10)) ident = TRUE;
1097                         break;
1098
1099                 case SV_POTION_BESERK_STRENGTH:
1100                         if (set_afraid(0)) ident = TRUE;
1101                         if (set_shero(p_ptr->shero + randint1(25) + 25, FALSE)) ident = TRUE;
1102                         if (hp_player(30)) ident = TRUE;
1103                         break;
1104
1105                 case SV_POTION_CURE_LIGHT:
1106                         if (hp_player(damroll(2, 8))) ident = TRUE;
1107                         if (set_blind(0)) ident = TRUE;
1108                         if (set_cut(p_ptr->cut - 10)) ident = TRUE;
1109                         if (set_shero(0,TRUE)) ident = TRUE;
1110                         break;
1111
1112                 case SV_POTION_CURE_SERIOUS:
1113                         if (hp_player(damroll(4, 8))) ident = TRUE;
1114                         if (set_blind(0)) ident = TRUE;
1115                         if (set_confused(0)) ident = TRUE;
1116                         if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
1117                         if (set_shero(0,TRUE)) ident = TRUE;
1118                         break;
1119
1120                 case SV_POTION_CURE_CRITICAL:
1121                         if (hp_player(damroll(6, 8))) ident = TRUE;
1122                         if (set_blind(0)) ident = TRUE;
1123                         if (set_confused(0)) ident = TRUE;
1124                         if (set_poisoned(0)) ident = TRUE;
1125                         if (set_stun(0)) ident = TRUE;
1126                         if (set_cut(0)) ident = TRUE;
1127                         if (set_shero(0,TRUE)) ident = TRUE;
1128                         break;
1129
1130                 case SV_POTION_HEALING:
1131                         if (hp_player(300)) ident = TRUE;
1132                         if (set_blind(0)) ident = TRUE;
1133                         if (set_confused(0)) ident = TRUE;
1134                         if (set_poisoned(0)) ident = TRUE;
1135                         if (set_stun(0)) ident = TRUE;
1136                         if (set_cut(0)) ident = TRUE;
1137                         if (set_shero(0,TRUE)) ident = TRUE;
1138                         break;
1139
1140                 case SV_POTION_STAR_HEALING:
1141                         if (hp_player(1200)) ident = TRUE;
1142                         if (set_blind(0)) ident = TRUE;
1143                         if (set_confused(0)) ident = TRUE;
1144                         if (set_poisoned(0)) ident = TRUE;
1145                         if (set_stun(0)) ident = TRUE;
1146                         if (set_cut(0)) ident = TRUE;
1147                         if (set_shero(0,TRUE)) ident = TRUE;
1148                         break;
1149
1150                 case SV_POTION_LIFE:
1151                         chg_virtue(V_VITALITY, 1);
1152                         chg_virtue(V_UNLIFE, -5);
1153 #ifdef JP
1154                         msg_print("ÂÎÃæ¤ËÀ¸Ì¿ÎϤ¬Ëþ¤Á¤¢¤Õ¤ì¤Æ¤­¤¿¡ª");
1155 #else
1156                         msg_print("You feel life flow through your body!");
1157 #endif
1158
1159                         restore_level();
1160                         (void)set_poisoned(0);
1161                         (void)set_blind(0);
1162                         (void)set_confused(0);
1163                         (void)set_image(0);
1164                         (void)set_stun(0);
1165                         (void)set_cut(0);
1166                         (void)do_res_stat(A_STR);
1167                         (void)do_res_stat(A_CON);
1168                         (void)do_res_stat(A_DEX);
1169                         (void)do_res_stat(A_WIS);
1170                         (void)do_res_stat(A_INT);
1171                         (void)do_res_stat(A_CHR);
1172                         (void)set_shero(0,TRUE);
1173                         update_stuff();
1174                         hp_player(5000);
1175                         ident = TRUE;
1176                         break;
1177
1178                 case SV_POTION_RESTORE_MANA:
1179                         if (p_ptr->pclass == CLASS_MAGIC_EATER)
1180                         {
1181                                 int i;
1182                                 for (i = 0; i < EATER_EXT*2; i++)
1183                                 {
1184                                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
1185                                         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;
1186                                 }
1187                                 for (; i < EATER_EXT*3; i++)
1188                                 {
1189                                         int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
1190                                         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;
1191                                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
1192                                 }
1193 #ifdef JP
1194                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
1195 #else
1196                                 msg_print("You feel your head clear.");
1197 #endif
1198                                 p_ptr->window |= (PW_PLAYER);
1199                                 ident = TRUE;
1200                         }
1201                         else if (p_ptr->csp < p_ptr->msp)
1202                         {
1203                                 p_ptr->csp = p_ptr->msp;
1204                                 p_ptr->csp_frac = 0;
1205 #ifdef JP
1206                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
1207 #else
1208                                 msg_print("You feel your head clear.");
1209 #endif
1210
1211                                 p_ptr->redraw |= (PR_MANA);
1212                                 p_ptr->window |= (PW_PLAYER);
1213                                 p_ptr->window |= (PW_SPELL);
1214                                 ident = TRUE;
1215                         }
1216                         if (set_shero(0,TRUE)) ident = TRUE;
1217                         break;
1218
1219                 case SV_POTION_RESTORE_EXP:
1220                         if (restore_level()) ident = TRUE;
1221                         break;
1222
1223                 case SV_POTION_RES_STR:
1224                         if (do_res_stat(A_STR)) ident = TRUE;
1225                         break;
1226
1227                 case SV_POTION_RES_INT:
1228                         if (do_res_stat(A_INT)) ident = TRUE;
1229                         break;
1230
1231                 case SV_POTION_RES_WIS:
1232                         if (do_res_stat(A_WIS)) ident = TRUE;
1233                         break;
1234
1235                 case SV_POTION_RES_DEX:
1236                         if (do_res_stat(A_DEX)) ident = TRUE;
1237                         break;
1238
1239                 case SV_POTION_RES_CON:
1240                         if (do_res_stat(A_CON)) ident = TRUE;
1241                         break;
1242
1243                 case SV_POTION_RES_CHR:
1244                         if (do_res_stat(A_CHR)) ident = TRUE;
1245                         break;
1246
1247                 case SV_POTION_INC_STR:
1248                         if (do_inc_stat(A_STR)) ident = TRUE;
1249                         break;
1250
1251                 case SV_POTION_INC_INT:
1252                         if (do_inc_stat(A_INT)) ident = TRUE;
1253                         break;
1254
1255                 case SV_POTION_INC_WIS:
1256                         if (do_inc_stat(A_WIS)) ident = TRUE;
1257                         break;
1258
1259                 case SV_POTION_INC_DEX:
1260                         if (do_inc_stat(A_DEX)) ident = TRUE;
1261                         break;
1262
1263                 case SV_POTION_INC_CON:
1264                         if (do_inc_stat(A_CON)) ident = TRUE;
1265                         break;
1266
1267                 case SV_POTION_INC_CHR:
1268                         if (do_inc_stat(A_CHR)) ident = TRUE;
1269                         break;
1270
1271                 case SV_POTION_AUGMENTATION:
1272                         if (do_inc_stat(A_STR)) ident = TRUE;
1273                         if (do_inc_stat(A_INT)) ident = TRUE;
1274                         if (do_inc_stat(A_WIS)) ident = TRUE;
1275                         if (do_inc_stat(A_DEX)) ident = TRUE;
1276                         if (do_inc_stat(A_CON)) ident = TRUE;
1277                         if (do_inc_stat(A_CHR)) ident = TRUE;
1278                         break;
1279
1280                 case SV_POTION_ENLIGHTENMENT:
1281 #ifdef JP
1282                         msg_print("¼«Ê¬¤ÎÃÖ¤«¤ì¤Æ¤¤¤ë¾õ¶·¤¬Ç¾Î¢¤ËÉ⤫¤ó¤Ç¤­¤¿...");
1283 #else
1284                         msg_print("An image of your surroundings forms in your mind...");
1285 #endif
1286
1287                         chg_virtue(V_KNOWLEDGE, 1);
1288                         chg_virtue(V_ENLIGHTEN, 1);
1289                         wiz_lite(FALSE);
1290                         ident = TRUE;
1291                         break;
1292
1293                 case SV_POTION_STAR_ENLIGHTENMENT:
1294 #ifdef JP
1295                         msg_print("¹¹¤Ê¤ë·¼Ìؤò´¶¤¸¤¿...");
1296 #else
1297                         msg_print("You begin to feel more enlightened...");
1298 #endif
1299
1300                         chg_virtue(V_KNOWLEDGE, 1);
1301                         chg_virtue(V_ENLIGHTEN, 2);
1302                         msg_print(NULL);
1303                         wiz_lite(FALSE);
1304                         (void)do_inc_stat(A_INT);
1305                         (void)do_inc_stat(A_WIS);
1306                         (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
1307                         (void)detect_doors(DETECT_RAD_DEFAULT);
1308                         (void)detect_stairs(DETECT_RAD_DEFAULT);
1309                         (void)detect_treasure(DETECT_RAD_DEFAULT);
1310                         (void)detect_objects_gold(DETECT_RAD_DEFAULT);
1311                         (void)detect_objects_normal(DETECT_RAD_DEFAULT);
1312                         identify_pack();
1313                         self_knowledge();
1314                         ident = TRUE;
1315                         break;
1316
1317                 case SV_POTION_SELF_KNOWLEDGE:
1318 #ifdef JP
1319                         msg_print("¼«Ê¬¼«¿È¤Î¤³¤È¤¬¾¯¤·¤Ïʬ¤«¤Ã¤¿µ¤¤¬¤¹¤ë...");
1320 #else
1321                         msg_print("You begin to know yourself a little better...");
1322 #endif
1323
1324                         msg_print(NULL);
1325                         self_knowledge();
1326                         ident = TRUE;
1327                         break;
1328
1329                 case SV_POTION_EXPERIENCE:
1330                         if (p_ptr->prace == RACE_ANDROID) break;
1331                         chg_virtue(V_ENLIGHTEN, 1);
1332                         if (p_ptr->exp < PY_MAX_EXP)
1333                         {
1334                                 s32b ee = (p_ptr->exp / 2) + 10;
1335                                 if (ee > 100000L) ee = 100000L;
1336 #ifdef JP
1337                                 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1338 #else
1339                                 msg_print("You feel more experienced.");
1340 #endif
1341
1342                                 gain_exp(ee);
1343                                 ident = TRUE;
1344                         }
1345                         break;
1346
1347                 case SV_POTION_RESISTANCE:
1348                         (void)set_oppose_acid(p_ptr->oppose_acid + randint1(20) + 20, FALSE);
1349                         (void)set_oppose_elec(p_ptr->oppose_elec + randint1(20) + 20, FALSE);
1350                         (void)set_oppose_fire(p_ptr->oppose_fire + randint1(20) + 20, FALSE);
1351                         (void)set_oppose_cold(p_ptr->oppose_cold + randint1(20) + 20, FALSE);
1352                         (void)set_oppose_pois(p_ptr->oppose_pois + randint1(20) + 20, FALSE);
1353                         ident = TRUE;
1354                         break;
1355
1356                 case SV_POTION_CURING:
1357                         if (hp_player(50)) ident = TRUE;
1358                         if (set_blind(0)) ident = TRUE;
1359                         if (set_poisoned(0)) ident = TRUE;
1360                         if (set_confused(0)) ident = TRUE;
1361                         if (set_stun(0)) ident = TRUE;
1362                         if (set_cut(0)) ident = TRUE;
1363                         if (set_image(0)) ident = TRUE;
1364                         break;
1365
1366                 case SV_POTION_INVULNERABILITY:
1367                         (void)set_invuln(p_ptr->invuln + randint1(4) + 4, FALSE);
1368                         ident = TRUE;
1369                         break;
1370
1371                 case SV_POTION_NEW_LIFE:
1372                         do_cmd_rerate(FALSE);
1373                         get_max_stats();
1374                         p_ptr->update |= PU_BONUS;
1375                         if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
1376                         {
1377                                 chg_virtue(V_CHANCE, -5);
1378 #ifdef JP
1379 msg_print("Á´¤Æ¤ÎÆÍÁ³ÊÑ°Û¤¬¼£¤Ã¤¿¡£");
1380 #else
1381                                 msg_print("You are cured of all mutations.");
1382 #endif
1383
1384                                 p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
1385                                 p_ptr->update |= PU_BONUS;
1386                                 handle_stuff();
1387                                 mutant_regenerate_mod = calc_mutant_regenerate_mod();
1388                         }
1389                         ident = TRUE;
1390                         break;
1391
1392                 case SV_POTION_NEO_TSUYOSHI:
1393                         (void)set_image(0);
1394                         (void)set_tsuyoshi(p_ptr->tsuyoshi + randint1(100) + 100, FALSE);
1395                         ident = TRUE;
1396                         break;
1397
1398                 case SV_POTION_TSUYOSHI:
1399 #ifdef JP
1400 msg_print("¡Ö¥ª¥¯¥ì·»¤µ¤ó¡ª¡×");
1401 #else
1402                         msg_print("Brother OKURE!");
1403 #endif
1404                         msg_print(NULL);
1405                         p_ptr->tsuyoshi = 1;
1406                         (void)set_tsuyoshi(0, TRUE);
1407                         if (!p_ptr->resist_chaos)
1408                         {
1409                                 (void)set_image(50 + randint1(50));
1410                         }
1411                         ident = TRUE;
1412                         break;
1413                 
1414                 case SV_POTION_POLYMORPH:
1415                         if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && one_in_(23))
1416                         {
1417                                 chg_virtue(V_CHANCE, -5);
1418 #ifdef JP
1419 msg_print("Á´¤Æ¤ÎÆÍÁ³ÊÑ°Û¤¬¼£¤Ã¤¿¡£");
1420 #else
1421                                 msg_print("You are cured of all mutations.");
1422 #endif
1423
1424                                 p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
1425                                 p_ptr->update |= PU_BONUS;
1426                                 handle_stuff();
1427                         }
1428                         else
1429                         {
1430                                 do
1431                                 {
1432                                         if (one_in_(2))
1433                                         {
1434                                                 if(gain_random_mutation(0)) ident = TRUE;
1435                                         }
1436                                         else if (lose_mutation(0)) ident = TRUE;
1437                                 } while(!ident || one_in_(2));
1438                         }
1439                         break;
1440                 }
1441         }
1442
1443         if (prace_is_(RACE_SKELETON))
1444         {
1445 #ifdef JP
1446 msg_print("±ÕÂΤΰìÉô¤Ï¤¢¤Ê¤¿¤Î¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
1447 #else
1448                 msg_print("Some of the fluid falls through your jaws!");
1449 #endif
1450
1451                 (void)potion_smash_effect(0, py, px, q_ptr->k_idx);
1452         }
1453
1454         /* Combine / Reorder the pack (later) */
1455         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1456
1457         if (!(object_is_aware(q_ptr)))
1458         {
1459                 chg_virtue(V_PATIENCE, -1);
1460                 chg_virtue(V_CHANCE, 1);
1461                 chg_virtue(V_KNOWLEDGE, -1);
1462         }
1463
1464         /* The item has been tried */
1465         object_tried(q_ptr);
1466
1467         /* An identification was made */
1468         if (ident && !object_is_aware(q_ptr))
1469         {
1470                 object_aware(q_ptr);
1471                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
1472         }
1473
1474         /* Window stuff */
1475         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1476
1477         /* Potions can feed the player */
1478         switch (p_ptr->mimic_form)
1479         {
1480         case MIMIC_NONE:
1481                 switch (p_ptr->prace)
1482                 {
1483                         case RACE_VAMPIRE:
1484                                 (void)set_food(p_ptr->food + (q_ptr->pval / 10));
1485                                 break;
1486                         case RACE_SKELETON:
1487                                 /* Do nothing */
1488                                 break;
1489                         case RACE_GOLEM:
1490                         case RACE_ZOMBIE:
1491                         case RACE_DEMON:
1492                         case RACE_SPECTRE:
1493                                 set_food(p_ptr->food + ((q_ptr->pval) / 20));
1494                                 break;
1495                         case RACE_ANDROID:
1496                                 if (q_ptr->tval == TV_FLASK)
1497                                 {
1498 #ifdef JP
1499                                         msg_print("¥ª¥¤¥ë¤òÊäµë¤·¤¿¡£");
1500 #else
1501                                         msg_print("You replenish yourself with the oil.");
1502 #endif
1503                                         set_food(p_ptr->food + 5000);
1504                                 }
1505                                 else
1506                                 {
1507                                         set_food(p_ptr->food + ((q_ptr->pval) / 20));
1508                                 }
1509                                 break;
1510                         case RACE_ENT:
1511 #ifdef JP
1512                                 msg_print("¿åʬ¤ò¼è¤ê¹þ¤ó¤À¡£");
1513 #else
1514                                 msg_print("You are moistened.");
1515 #endif
1516                                 set_food(MIN(p_ptr->food + q_ptr->pval + MAX(0, q_ptr->pval * 10) + 2000, PY_FOOD_MAX - 1));
1517                                 break;
1518                         default:
1519                                 (void)set_food(p_ptr->food + q_ptr->pval);
1520                                 break;
1521                 }
1522                 break;
1523         case MIMIC_DEMON:
1524         case MIMIC_DEMON_LORD:
1525                 set_food(p_ptr->food + ((q_ptr->pval) / 20));
1526                 break;
1527         case MIMIC_VAMPIRE:
1528                 (void)set_food(p_ptr->food + (q_ptr->pval / 10));
1529                 break;
1530         default:
1531                 (void)set_food(p_ptr->food + q_ptr->pval);
1532                 break;
1533         }
1534 }
1535
1536
1537 /*!
1538  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤¬°û¤à¤³¤È¤¬¤Ç¤­¤ë¤«¤òȽÄꤹ¤ë /
1539  * Hook to determine if an object can be quaffed
1540  * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1541  * @return °û¤à¤³¤È¤¬²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
1542  */
1543 static bool item_tester_hook_quaff(object_type *o_ptr)
1544 {
1545         if (o_ptr->tval == TV_POTION) return TRUE;
1546
1547         if (prace_is_(RACE_ANDROID))
1548         {
1549                 if (o_ptr->tval == TV_FLASK && o_ptr->sval == SV_FLASK_OIL)
1550                         return TRUE;
1551         }
1552         return FALSE;
1553 }
1554
1555
1556 /*!
1557  * @brief Ìô¤ò°û¤à¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1558  * Quaff some potion (from the pack or floor)
1559  * @return ¤Ê¤·
1560  */
1561 void do_cmd_quaff_potion(void)
1562 {
1563         int  item;
1564         cptr q, s;
1565
1566         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1567         {
1568                 set_action(ACTION_NONE);
1569         }
1570
1571         /* Restrict choices to potions */
1572         item_tester_hook = item_tester_hook_quaff;
1573
1574         /* Get an item */
1575 #ifdef JP
1576         q = "¤É¤ÎÌô¤ò°û¤ß¤Þ¤¹¤«? ";
1577         s = "°û¤á¤ëÌô¤¬¤Ê¤¤¡£";
1578 #else
1579         q = "Quaff which potion? ";
1580         s = "You have no potions to quaff.";
1581 #endif
1582
1583         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1584
1585         /* Quaff the potion */
1586         do_cmd_quaff_potion_aux(item);
1587 }
1588
1589
1590 /*!
1591  * @brief ´¬Êª¤òÆɤॳ¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó
1592  * Read a scroll (from the pack or floor).
1593  * @param item Æɤ४¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
1594  * @param known È½ÌÀºÑ¤Ê¤é¤ÐTRUE
1595  * @return ¤Ê¤·
1596  * @details
1597  * <pre>
1598  * Certain scrolls can be "aborted" without losing the scroll.  These
1599  * include scrolls with no effects but recharge or identify, which are
1600  * cancelled before use.  XXX Reading them still takes a turn, though.
1601  * </pre>
1602  */
1603 static void do_cmd_read_scroll_aux(int item, bool known)
1604 {
1605         int         k, used_up, ident, lev;
1606         object_type *o_ptr;
1607
1608
1609         /* Get the item (in the pack) */
1610         if (item >= 0)
1611         {
1612                 o_ptr = &inventory[item];
1613         }
1614
1615         /* Get the item (on the floor) */
1616         else
1617         {
1618                 o_ptr = &o_list[0 - item];
1619         }
1620
1621
1622         /* Take a turn */
1623         energy_use = 100;
1624
1625         if (world_player)
1626         {
1627                 if (flush_failure) flush();
1628 #ifdef JP
1629                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
1630 #else
1631                 msg_print("Nothing happen.");
1632 #endif
1633
1634                 sound(SOUND_FAIL);
1635                 return;
1636         }
1637
1638         if (p_ptr->pclass == CLASS_BERSERKER)
1639         {
1640 #ifdef JP
1641                 msg_print("´¬Êª¤Ê¤ó¤ÆÆɤá¤Ê¤¤¡£");
1642 #else
1643                 msg_print("You cannot read.");
1644 #endif
1645                 return;
1646         }
1647
1648         if (music_singing_any()) stop_singing();
1649
1650         /* Hex */
1651         if (hex_spelling_any() && ((p_ptr->lev < 35) || hex_spell_fully())) stop_hex_spell_all();
1652
1653         /* Not identified yet */
1654         ident = FALSE;
1655
1656         /* Object level */
1657         lev = k_info[o_ptr->k_idx].level;
1658
1659         /* Assume the scroll will get used up */
1660         used_up = TRUE;
1661
1662         if (o_ptr->tval == TV_SCROLL)
1663         {
1664         /* Analyze the scroll */
1665         switch (o_ptr->sval)
1666         {
1667                 case SV_SCROLL_DARKNESS:
1668                 {
1669                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
1670                         {
1671                                 (void)set_blind(p_ptr->blind + 3 + randint1(5));
1672                         }
1673                         if (unlite_area(10, 3)) ident = TRUE;
1674                         break;
1675                 }
1676
1677                 case SV_SCROLL_AGGRAVATE_MONSTER:
1678                 {
1679 #ifdef JP
1680                         msg_print("¥«¥ó¹â¤¯¤¦¤Ê¤ëÍͤʲ»¤¬ÊÕ¤ê¤òʤ¤Ã¤¿¡£");
1681 #else
1682                         msg_print("There is a high pitched humming noise.");
1683 #endif
1684
1685                         aggravate_monsters(0);
1686                         ident = TRUE;
1687                         break;
1688                 }
1689
1690                 case SV_SCROLL_CURSE_ARMOR:
1691                 {
1692                         if (curse_armor()) ident = TRUE;
1693                         break;
1694                 }
1695
1696                 case SV_SCROLL_CURSE_WEAPON:
1697                 {
1698                         k = 0;
1699                         if (buki_motteruka(INVEN_RARM))
1700                         {
1701                                 k = INVEN_RARM;
1702                                 if (buki_motteruka(INVEN_LARM) && one_in_(2)) k = INVEN_LARM;
1703                         }
1704                         else if (buki_motteruka(INVEN_LARM)) k = INVEN_LARM;
1705                         if (k && curse_weapon(FALSE, k)) ident = TRUE;
1706                         break;
1707                 }
1708
1709                 case SV_SCROLL_SUMMON_MONSTER:
1710                 {
1711                         for (k = 0; k < randint1(3); k++)
1712                         {
1713                                 if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
1714                                 {
1715                                         ident = TRUE;
1716                                 }
1717                         }
1718                         break;
1719                 }
1720
1721                 case SV_SCROLL_SUMMON_UNDEAD:
1722                 {
1723                         for (k = 0; k < randint1(3); k++)
1724                         {
1725                                 if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
1726                                 {
1727                                         ident = TRUE;
1728                                 }
1729                         }
1730                         break;
1731                 }
1732
1733                 case SV_SCROLL_SUMMON_PET:
1734                 {
1735                         if (summon_specific(-1, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
1736                         {
1737                                 ident = TRUE;
1738                         }
1739                         break;
1740                 }
1741
1742                 case SV_SCROLL_SUMMON_KIN:
1743                 {
1744                         if (summon_kin_player(p_ptr->lev, py, px, (PM_FORCE_PET | PM_ALLOW_GROUP)))
1745                         {
1746                                 ident = TRUE;
1747                         }
1748                         break;
1749                 }
1750
1751                 case SV_SCROLL_TRAP_CREATION:
1752                 {
1753                         if (trap_creation(py, px)) ident = TRUE;
1754                         break;
1755                 }
1756
1757                 case SV_SCROLL_PHASE_DOOR:
1758                 {
1759                         teleport_player(10, 0L);
1760                         ident = TRUE;
1761                         break;
1762                 }
1763
1764                 case SV_SCROLL_TELEPORT:
1765                 {
1766                         teleport_player(100, 0L);
1767                         ident = TRUE;
1768                         break;
1769                 }
1770
1771                 case SV_SCROLL_TELEPORT_LEVEL:
1772                 {
1773                         (void)teleport_level(0);
1774                         ident = TRUE;
1775                         break;
1776                 }
1777
1778                 case SV_SCROLL_WORD_OF_RECALL:
1779                 {
1780                         if (!word_of_recall()) used_up = FALSE;
1781                         ident = TRUE;
1782                         break;
1783                 }
1784
1785                 case SV_SCROLL_IDENTIFY:
1786                 {
1787                         if (!ident_spell(FALSE)) used_up = FALSE;
1788                         ident = TRUE;
1789                         break;
1790                 }
1791
1792                 case SV_SCROLL_STAR_IDENTIFY:
1793                 {
1794                         if (!identify_fully(FALSE)) used_up = FALSE;
1795                         ident = TRUE;
1796                         break;
1797                 }
1798
1799                 case SV_SCROLL_REMOVE_CURSE:
1800                 {
1801                         if (remove_curse())
1802                         {
1803 #ifdef JP
1804                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1805 #else
1806                                 msg_print("You feel as if someone is watching over you.");
1807 #endif
1808
1809                                 ident = TRUE;
1810                         }
1811                         break;
1812                 }
1813
1814                 case SV_SCROLL_STAR_REMOVE_CURSE:
1815                 {
1816                         if (remove_all_curse())
1817                         {
1818 #ifdef JP
1819                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1820 #else
1821                                 msg_print("You feel as if someone is watching over you.");
1822 #endif
1823                         }
1824                         ident = TRUE;
1825                         break;
1826                 }
1827
1828                 case SV_SCROLL_ENCHANT_ARMOR:
1829                 {
1830                         ident = TRUE;
1831                         if (!enchant_spell(0, 0, 1)) used_up = FALSE;
1832                         break;
1833                 }
1834
1835                 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
1836                 {
1837                         if (!enchant_spell(1, 0, 0)) used_up = FALSE;
1838                         ident = TRUE;
1839                         break;
1840                 }
1841
1842                 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
1843                 {
1844                         if (!enchant_spell(0, 1, 0)) used_up = FALSE;
1845                         ident = TRUE;
1846                         break;
1847                 }
1848
1849                 case SV_SCROLL_STAR_ENCHANT_ARMOR:
1850                 {
1851                         if (!enchant_spell(0, 0, randint1(3) + 2)) used_up = FALSE;
1852                         ident = TRUE;
1853                         break;
1854                 }
1855
1856                 case SV_SCROLL_STAR_ENCHANT_WEAPON:
1857                 {
1858                         if (!enchant_spell(randint1(3), randint1(3), 0)) used_up = FALSE;
1859                         ident = TRUE;
1860                         break;
1861                 }
1862
1863                 case SV_SCROLL_RECHARGING:
1864                 {
1865                         if (!recharge(130)) used_up = FALSE;
1866                         ident = TRUE;
1867                         break;
1868                 }
1869
1870                 case SV_SCROLL_MUNDANITY:
1871                 {
1872                         ident = TRUE;
1873                         if (!mundane_spell(FALSE)) used_up = FALSE;
1874                         break;
1875                 }
1876
1877                 case SV_SCROLL_LIGHT:
1878                 {
1879                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
1880                         break;
1881                 }
1882
1883                 case SV_SCROLL_MAPPING:
1884                 {
1885                         map_area(DETECT_RAD_MAP);
1886                         ident = TRUE;
1887                         break;
1888                 }
1889
1890                 case SV_SCROLL_DETECT_GOLD:
1891                 {
1892                         if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
1893                         if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
1894                         break;
1895                 }
1896
1897                 case SV_SCROLL_DETECT_ITEM:
1898                 {
1899                         if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
1900                         break;
1901                 }
1902
1903                 case SV_SCROLL_DETECT_TRAP:
1904                 {
1905                         if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
1906                         break;
1907                 }
1908
1909                 case SV_SCROLL_DETECT_DOOR:
1910                 {
1911                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
1912                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
1913                         break;
1914                 }
1915
1916                 case SV_SCROLL_DETECT_INVIS:
1917                 {
1918                         if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
1919                         break;
1920                 }
1921
1922                 case SV_SCROLL_SATISFY_HUNGER:
1923                 {
1924                         if (set_food(PY_FOOD_MAX - 1)) ident = TRUE;
1925                         break;
1926                 }
1927
1928                 case SV_SCROLL_BLESSING:
1929                 {
1930                         if (set_blessed(p_ptr->blessed + randint1(12) + 6, FALSE)) ident = TRUE;
1931                         break;
1932                 }
1933
1934                 case SV_SCROLL_HOLY_CHANT:
1935                 {
1936                         if (set_blessed(p_ptr->blessed + randint1(24) + 12, FALSE)) ident = TRUE;
1937                         break;
1938                 }
1939
1940                 case SV_SCROLL_HOLY_PRAYER:
1941                 {
1942                         if (set_blessed(p_ptr->blessed + randint1(48) + 24, FALSE)) ident = TRUE;
1943                         break;
1944                 }
1945
1946                 case SV_SCROLL_MONSTER_CONFUSION:
1947                 {
1948                         if (!(p_ptr->special_attack & ATTACK_CONFUSE))
1949                         {
1950 #ifdef JP
1951                                 msg_print("¼ê¤¬µ±¤­»Ï¤á¤¿¡£");
1952 #else
1953                                 msg_print("Your hands begin to glow.");
1954 #endif
1955
1956                                 p_ptr->special_attack |= ATTACK_CONFUSE;
1957                                 p_ptr->redraw |= (PR_STATUS);
1958                                 ident = TRUE;
1959                         }
1960                         break;
1961                 }
1962
1963                 case SV_SCROLL_PROTECTION_FROM_EVIL:
1964                 {
1965                         k = 3 * p_ptr->lev;
1966                         if (set_protevil(p_ptr->protevil + randint1(25) + k, FALSE)) ident = TRUE;
1967                         break;
1968                 }
1969
1970                 case SV_SCROLL_RUNE_OF_PROTECTION:
1971                 {
1972                         warding_glyph();
1973                         ident = TRUE;
1974                         break;
1975                 }
1976
1977                 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
1978                 {
1979                         if (destroy_doors_touch()) ident = TRUE;
1980                         break;
1981                 }
1982
1983                 case SV_SCROLL_STAR_DESTRUCTION:
1984                 {
1985                         if (destroy_area(py, px, 13 + randint0(5), FALSE))
1986                                 ident = TRUE;
1987                         else
1988 #ifdef JP
1989 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿...");
1990 #else
1991                                 msg_print("The dungeon trembles...");
1992 #endif
1993
1994
1995                         break;
1996                 }
1997
1998                 case SV_SCROLL_DISPEL_UNDEAD:
1999                 {
2000                         if (dispel_undead(80)) ident = TRUE;
2001                         break;
2002                 }
2003
2004                 case SV_SCROLL_SPELL:
2005                 {
2006                         if ((p_ptr->pclass == CLASS_WARRIOR) ||
2007                                 (p_ptr->pclass == CLASS_IMITATOR) ||
2008                                 (p_ptr->pclass == CLASS_MINDCRAFTER) ||
2009                                 (p_ptr->pclass == CLASS_SORCERER) ||
2010                                 (p_ptr->pclass == CLASS_ARCHER) ||
2011                                 (p_ptr->pclass == CLASS_MAGIC_EATER) ||
2012                                 (p_ptr->pclass == CLASS_RED_MAGE) ||
2013                                 (p_ptr->pclass == CLASS_SAMURAI) ||
2014                                 (p_ptr->pclass == CLASS_BLUE_MAGE) ||
2015                                 (p_ptr->pclass == CLASS_CAVALRY) ||
2016                                 (p_ptr->pclass == CLASS_BERSERKER) ||
2017                                 (p_ptr->pclass == CLASS_SMITH) ||
2018                                 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2019                                 (p_ptr->pclass == CLASS_NINJA) ||
2020                                 (p_ptr->pclass == CLASS_SNIPER)) break;
2021                         p_ptr->add_spells++;
2022                         p_ptr->update |= (PU_SPELLS);
2023                         ident = TRUE;
2024                         break;
2025                 }
2026
2027                 case SV_SCROLL_GENOCIDE:
2028                 {
2029                         (void)symbol_genocide(300, TRUE);
2030                         ident = TRUE;
2031                         break;
2032                 }
2033
2034                 case SV_SCROLL_MASS_GENOCIDE:
2035                 {
2036                         (void)mass_genocide(300, TRUE);
2037                         ident = TRUE;
2038                         break;
2039                 }
2040
2041                 case SV_SCROLL_ACQUIREMENT:
2042                 {
2043                         acquirement(py, px, 1, TRUE, FALSE, FALSE);
2044                         ident = TRUE;
2045                         break;
2046                 }
2047
2048                 case SV_SCROLL_STAR_ACQUIREMENT:
2049                 {
2050                         acquirement(py, px, randint1(2) + 1, TRUE, FALSE, FALSE);
2051                         ident = TRUE;
2052                         break;
2053                 }
2054
2055                 /* New Hengband scrolls */
2056                 case SV_SCROLL_FIRE:
2057                 {
2058                         fire_ball(GF_FIRE, 0, 666, 4);
2059                         /* Note: "Double" damage since it is centered on the player ... */
2060                         if (!(IS_OPPOSE_FIRE() || p_ptr->resist_fire || p_ptr->immune_fire))
2061 #ifdef JP
2062 take_hit(DAMAGE_NOESCAPE, 50+randint1(50), "±ê¤Î´¬Êª", -1);
2063 #else
2064                                 take_hit(DAMAGE_NOESCAPE, 50 + randint1(50), "a Scroll of Fire", -1);
2065 #endif
2066
2067                         ident = TRUE;
2068                         break;
2069                 }
2070
2071
2072                 case SV_SCROLL_ICE:
2073                 {
2074                         fire_ball(GF_ICE, 0, 777, 4);
2075                         if (!(IS_OPPOSE_COLD() || p_ptr->resist_cold || p_ptr->immune_cold))
2076 #ifdef JP
2077 take_hit(DAMAGE_NOESCAPE, 100+randint1(100), "ɹ¤Î´¬Êª", -1);
2078 #else
2079                                 take_hit(DAMAGE_NOESCAPE, 100 + randint1(100), "a Scroll of Ice", -1);
2080 #endif
2081
2082                         ident = TRUE;
2083                         break;
2084                 }
2085
2086                 case SV_SCROLL_CHAOS:
2087                 {
2088                         fire_ball(GF_CHAOS, 0, 1000, 4);
2089                         if (!p_ptr->resist_chaos)
2090 #ifdef JP
2091 take_hit(DAMAGE_NOESCAPE, 111+randint1(111), "¥í¥°¥ë¥¹¤Î´¬Êª", -1);
2092 #else
2093                                 take_hit(DAMAGE_NOESCAPE, 111 + randint1(111), "a Scroll of Logrus", -1);
2094 #endif
2095
2096                         ident = TRUE;
2097                         break;
2098                 }
2099
2100                 case SV_SCROLL_RUMOR:
2101                 {
2102 #ifdef JP
2103                         msg_print("´¬Êª¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¤¬½ñ¤«¤ì¤Æ¤¤¤ë:");
2104 #else
2105                         msg_print("There is message on the scroll. It says:");
2106 #endif
2107
2108                         msg_print(NULL);
2109                         display_rumor(TRUE);
2110                         msg_print(NULL);
2111 #ifdef JP
2112                         msg_print("´¬Êª¤Ï±ì¤òΩ¤Æ¤Æ¾Ã¤¨µî¤Ã¤¿¡ª");
2113 #else
2114                         msg_print("The scroll disappears in a puff of smoke!");
2115 #endif
2116
2117                         ident = TRUE;
2118                         break;
2119                 }
2120
2121                 case SV_SCROLL_ARTIFACT:
2122                 {
2123                         ident = TRUE;
2124                         if (!artifact_scroll()) used_up = FALSE;
2125                         break;
2126                 }
2127
2128                 case SV_SCROLL_RESET_RECALL:
2129                 {
2130                         ident = TRUE;
2131                         if (!reset_recall()) used_up = FALSE;
2132                         break;
2133                 }
2134
2135                 case SV_SCROLL_AMUSEMENT:
2136                 {
2137                         ident = TRUE;
2138                         amusement(py, px, 1, FALSE);
2139                         break;
2140                 }
2141
2142                 case SV_SCROLL_STAR_AMUSEMENT:
2143                 {
2144                         ident = TRUE;
2145                         amusement(py, px,  randint1(2) + 1, FALSE);
2146                         break;
2147                 }
2148         }
2149         }
2150         else if (o_ptr->name1 == ART_GHB)
2151         {
2152 #ifdef JP
2153                 msg_print("»ä¤Ï¶ìÏ«¤·¤Æ¡Ø¥°¥ì¡¼¥¿¡¼¡¦¥Ø¥ë=¥Ó¡¼¥¹¥È¡Ù¤òÅݤ·¤¿¡£");
2154                 msg_print("¤·¤«¤·¼ê¤ËÆþ¤Ã¤¿¤Î¤Ï¤³¤Î¤­¤¿¤Ê¤¤£Ô¥·¥ã¥Ä¤À¤±¤À¤Ã¤¿¡£");
2155 #else
2156                 msg_print("I had a very hard time to kill the Greater hell-beast, ");
2157                 msg_print("but all I got was this lousy t-shirt!");
2158 #endif
2159                 used_up = FALSE;
2160         }
2161         else if (o_ptr->name1 == ART_POWER)
2162         {
2163 #ifdef JP
2164                 msg_print("¡Ö°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÅý¤Ù¡¢");
2165                 msg_print(NULL);
2166                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤ò¸«¤Ä¤±¡¢");
2167                 msg_print(NULL);
2168                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÊá¤é¤¨¤Æ");
2169                 msg_print(NULL);
2170                 msg_print("°Å°Ç¤ÎÃæ¤Ë·Ò¤®¤È¤á¤ë¡£¡×");
2171 #else
2172                 msg_print("'One Ring to rule them all, ");
2173                 msg_print(NULL);
2174                 msg_print("One Ring to find them, ");
2175                 msg_print(NULL);
2176                 msg_print("One Ring to bring them all ");
2177                 msg_print(NULL);
2178                 msg_print("and in the darkness bind them.'");
2179 #endif
2180                 used_up = FALSE;
2181         }
2182         else if (o_ptr->tval==TV_PARCHMENT)
2183         {
2184                 cptr q;
2185                 char o_name[MAX_NLEN];
2186                 char buf[1024];
2187
2188                 /* Save screen */
2189                 screen_save();
2190
2191                 q=format("book-%d_jp.txt",o_ptr->sval);
2192
2193                 /* Display object description */
2194                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2195
2196                 /* Build the filename */
2197                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
2198
2199                 /* Peruse the help file */
2200                 (void)show_file(TRUE, buf, o_name, 0, 0);
2201
2202                 /* Load screen */
2203                 screen_load();
2204
2205                 used_up=FALSE;
2206         }
2207
2208
2209         /* Combine / Reorder the pack (later) */
2210         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2211
2212         if (!(object_is_aware(o_ptr)))
2213         {
2214                 chg_virtue(V_PATIENCE, -1);
2215                 chg_virtue(V_CHANCE, 1);
2216                 chg_virtue(V_KNOWLEDGE, -1);
2217         }
2218
2219         /* The item was tried */
2220         object_tried(o_ptr);
2221
2222         /* An identification was made */
2223         if (ident && !object_is_aware(o_ptr))
2224         {
2225                 object_aware(o_ptr);
2226                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2227         }
2228
2229         /* Window stuff */
2230         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2231
2232
2233         /* Hack -- allow certain scrolls to be "preserved" */
2234         if (!used_up)
2235         {
2236                 return;
2237         }
2238
2239         sound(SOUND_SCROLL);
2240
2241         /* Destroy a scroll in the pack */
2242         if (item >= 0)
2243         {
2244                 inven_item_increase(item, -1);
2245                 inven_item_describe(item);
2246                 inven_item_optimize(item);
2247         }
2248
2249         /* Destroy a scroll on the floor */
2250         else
2251         {
2252                 floor_item_increase(0 - item, -1);
2253                 floor_item_describe(0 - item);
2254                 floor_item_optimize(0 - item);
2255         }
2256 }
2257
2258 /*!
2259  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤¬Æɤळ¤È¤¬¤Ç¤­¤ë¤«¤òȽÄꤹ¤ë /
2260  * Hook to determine if an object is readable
2261  * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2262  * @return Æɤळ¤È¤¬²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
2263  */
2264 static bool item_tester_hook_readable(object_type *o_ptr)
2265 {
2266         if ((o_ptr->tval==TV_SCROLL) || (o_ptr->tval==TV_PARCHMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER)) return (TRUE);
2267
2268         /* Assume not */
2269         return (FALSE);
2270 }
2271
2272 /*!
2273  * @brief Æɤॳ¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2274  * Eat some food (from the pack or floor)
2275  * @return ¤Ê¤·
2276  */
2277 void do_cmd_read_scroll(void)
2278 {
2279         object_type *o_ptr;
2280         int  item;
2281         cptr q, s;
2282
2283         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2284         {
2285                 set_action(ACTION_NONE);
2286         }
2287
2288         /* Check some conditions */
2289         if (p_ptr->blind)
2290         {
2291 #ifdef JP
2292                 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
2293 #else
2294                 msg_print("You can't see anything.");
2295 #endif
2296
2297                 return;
2298         }
2299         if (no_lite())
2300         {
2301 #ifdef JP
2302                 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
2303 #else
2304                 msg_print("You have no light to read by.");
2305 #endif
2306
2307                 return;
2308         }
2309         if (p_ptr->confused)
2310         {
2311 #ifdef JP
2312                 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡£");
2313 #else
2314                 msg_print("You are too confused!");
2315 #endif
2316
2317                 return;
2318         }
2319
2320
2321         /* Restrict choices to scrolls */
2322         item_tester_hook = item_tester_hook_readable;
2323
2324         /* Get an item */
2325 #ifdef JP
2326         q = "¤É¤Î´¬Êª¤òÆɤߤޤ¹¤«? ";
2327         s = "Æɤá¤ë´¬Êª¤¬¤Ê¤¤¡£";
2328 #else
2329         q = "Read which scroll? ";
2330         s = "You have no scrolls to read.";
2331 #endif
2332
2333         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2334
2335         /* Get the item (in the pack) */
2336         if (item >= 0)
2337         {
2338                 o_ptr = &inventory[item];
2339         }
2340
2341         /* Get the item (on the floor) */
2342         else
2343         {
2344                 o_ptr = &o_list[0 - item];
2345         }
2346
2347         /* Read the scroll */
2348         do_cmd_read_scroll_aux(item, object_is_aware(o_ptr));
2349 }
2350
2351 /*!
2352  * @brief ¾ó¤Î¸ú²Ì¤òȯư¤¹¤ë
2353  * @param sval ¥ª¥Ö¥¸¥§¥¯¥È¤Îsval
2354  * @param use_charge »ÈÍѲó¿ô¤ò¾ÃÈñ¤·¤¿¤«¤É¤¦¤«¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
2355  * @param powerful ¶¯ÎÏȯư¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2356  * @param magic ËâÆ»¶ñ½Ñ¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2357  * @param known È½ÌÀºÑ¤Ê¤é¤ÐTRUE
2358  * @return È¯Æ°¤Ë¤è¤ê¸ú²ÌÆâÍƤ¬³ÎÄꤷ¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
2359  */
2360 static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, bool known)
2361 {
2362         int k;
2363         int ident = FALSE;
2364         int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
2365         int detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
2366
2367         /* Analyze the staff */
2368         switch (sval)
2369         {
2370                 case SV_STAFF_DARKNESS:
2371                 {
2372                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
2373                         {
2374                                 if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
2375                         }
2376                         if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
2377                         break;
2378                 }
2379
2380                 case SV_STAFF_SLOWNESS:
2381                 {
2382                         if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
2383                         break;
2384                 }
2385
2386                 case SV_STAFF_HASTE_MONSTERS:
2387                 {
2388                         if (speed_monsters()) ident = TRUE;
2389                         break;
2390                 }
2391
2392                 case SV_STAFF_SUMMONING:
2393                 {
2394                         const int times = randint1(powerful ? 8 : 4);
2395                         for (k = 0; k < times; k++)
2396                         {
2397                                 if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2398                                 {
2399                                         ident = TRUE;
2400                                 }
2401                         }
2402                         break;
2403                 }
2404
2405                 case SV_STAFF_TELEPORTATION:
2406                 {
2407                         teleport_player((powerful ? 150 : 100), 0L);
2408                         ident = TRUE;
2409                         break;
2410                 }
2411
2412                 case SV_STAFF_IDENTIFY:
2413                 {
2414                         if (powerful) {
2415                                 if (!identify_fully(FALSE)) *use_charge = FALSE;
2416                         } else {
2417                                 if (!ident_spell(FALSE)) *use_charge = FALSE;
2418                         }
2419                         ident = TRUE;
2420                         break;
2421                 }
2422
2423                 case SV_STAFF_REMOVE_CURSE:
2424                 {
2425                         bool result = powerful ? remove_all_curse() : remove_curse();
2426                         if (result)
2427                         {
2428                                 if (magic)
2429                                 {
2430 #ifdef JP
2431                                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
2432 #else
2433                                         msg_print("You feel as if someone is watching over you.");
2434 #endif
2435                                 }
2436                                 else if (!p_ptr->blind)
2437                                 {
2438 #ifdef JP
2439                                         msg_print("¾ó¤Ï°ì½Ö¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
2440 #else
2441                                         msg_print("The staff glows blue for a moment...");
2442 #endif
2443
2444                                 }
2445                                 ident = TRUE;
2446                         }
2447                         break;
2448                 }
2449
2450                 case SV_STAFF_STARLITE:
2451                 {
2452                         int num = damroll(5, 3);
2453                         int y, x;
2454                         int attempts;
2455
2456                         if (!p_ptr->blind && !magic)
2457                         {
2458 #ifdef JP
2459                                 msg_print("¾ó¤ÎÀ褬ÌÀ¤ë¤¯µ±¤¤¤¿...");
2460 #else
2461                                 msg_print("The end of the staff glows brightly...");
2462 #endif
2463
2464                         }
2465                         for (k = 0; k < num; k++)
2466                         {
2467                                 attempts = 1000;
2468
2469                                 while (attempts--)
2470                                 {
2471                                         scatter(&y, &x, py, px, 4, 0);
2472
2473                                         if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
2474
2475                                         if (!player_bold(y, x)) break;
2476                                 }
2477
2478                                 project(0, 0, y, x, damroll(6 + lev / 8, 10), GF_LITE_WEAK,
2479                                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1);
2480                         }
2481                         ident = TRUE;
2482                         break;
2483                 }
2484
2485                 case SV_STAFF_LITE:
2486                 {
2487                         if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
2488                         break;
2489                 }
2490
2491                 case SV_STAFF_MAPPING:
2492                 {
2493                         map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
2494                         ident = TRUE;
2495                         break;
2496                 }
2497
2498                 case SV_STAFF_DETECT_GOLD:
2499                 {
2500                         if (detect_treasure(detect_rad)) ident = TRUE;
2501                         if (detect_objects_gold(detect_rad)) ident = TRUE;
2502                         break;
2503                 }
2504
2505                 case SV_STAFF_DETECT_ITEM:
2506                 {
2507                         if (detect_objects_normal(detect_rad)) ident = TRUE;
2508                         break;
2509                 }
2510
2511                 case SV_STAFF_DETECT_TRAP:
2512                 {
2513                         if (detect_traps(detect_rad, known)) ident = TRUE;
2514                         break;
2515                 }
2516
2517                 case SV_STAFF_DETECT_DOOR:
2518                 {
2519                         if (detect_doors(detect_rad)) ident = TRUE;
2520                         if (detect_stairs(detect_rad)) ident = TRUE;
2521                         break;
2522                 }
2523
2524                 case SV_STAFF_DETECT_INVIS:
2525                 {
2526                         if (detect_monsters_invis(detect_rad)) ident = TRUE;
2527                         break;
2528                 }
2529
2530                 case SV_STAFF_DETECT_EVIL:
2531                 {
2532                         if (detect_monsters_evil(detect_rad)) ident = TRUE;
2533                         break;
2534                 }
2535
2536                 case SV_STAFF_CURE_LIGHT:
2537                 {
2538                         if (hp_player(damroll((powerful ? 4 : 2), 8))) ident = TRUE;
2539                         if (powerful) {
2540                                 if (set_blind(0)) ident = TRUE;
2541                                 if (set_poisoned(0)) ident = TRUE;
2542                                 if (set_cut(p_ptr->cut - 10)) ident = TRUE;
2543                         }
2544                         if (set_shero(0,TRUE)) ident = TRUE;
2545                         break;
2546                 }
2547
2548                 case SV_STAFF_CURING:
2549                 {
2550                         if (set_blind(0)) ident = TRUE;
2551                         if (set_poisoned(0)) ident = TRUE;
2552                         if (set_confused(0)) ident = TRUE;
2553                         if (set_stun(0)) ident = TRUE;
2554                         if (set_cut(0)) ident = TRUE;
2555                         if (set_image(0)) ident = TRUE;
2556                         if (set_shero(0,TRUE)) ident = TRUE;
2557                         break;
2558                 }
2559
2560                 case SV_STAFF_HEALING:
2561                 {
2562                         if (hp_player(powerful ? 500 : 300)) ident = TRUE;
2563                         if (set_stun(0)) ident = TRUE;
2564                         if (set_cut(0)) ident = TRUE;
2565                         if (set_shero(0,TRUE)) ident = TRUE;
2566                         break;
2567                 }
2568
2569                 case SV_STAFF_THE_MAGI:
2570                 {
2571                         if (do_res_stat(A_INT)) ident = TRUE;
2572                         if (p_ptr->csp < p_ptr->msp)
2573                         {
2574                                 p_ptr->csp = p_ptr->msp;
2575                                 p_ptr->csp_frac = 0;
2576                                 ident = TRUE;
2577 #ifdef JP
2578                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
2579 #else
2580                                 msg_print("You feel your head clear.");
2581 #endif
2582
2583                                 p_ptr->redraw |= (PR_MANA);
2584                                 p_ptr->window |= (PW_PLAYER);
2585                                 p_ptr->window |= (PW_SPELL);
2586                         }
2587                         if (set_shero(0,TRUE)) ident = TRUE;
2588                         break;
2589                 }
2590
2591                 case SV_STAFF_SLEEP_MONSTERS:
2592                 {
2593                         if (sleep_monsters(lev)) ident = TRUE;
2594                         break;
2595                 }
2596
2597                 case SV_STAFF_SLOW_MONSTERS:
2598                 {
2599                         if (slow_monsters(lev)) ident = TRUE;
2600                         break;
2601                 }
2602
2603                 case SV_STAFF_SPEED:
2604                 {
2605                         if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
2606                         break;
2607                 }
2608
2609                 case SV_STAFF_PROBING:
2610                 {
2611                         probing();
2612                         ident = TRUE;
2613                         break;
2614                 }
2615
2616                 case SV_STAFF_DISPEL_EVIL:
2617                 {
2618                         if (dispel_evil(powerful ? 120 : 80)) ident = TRUE;
2619                         break;
2620                 }
2621
2622                 case SV_STAFF_POWER:
2623                 {
2624                         if (dispel_monsters(powerful ? 225 : 150)) ident = TRUE;
2625                         break;
2626                 }
2627
2628                 case SV_STAFF_HOLINESS:
2629                 {
2630                         if (dispel_evil(powerful ? 225 : 150)) ident = TRUE;
2631                         k = 3 * lev;
2632                         if (set_protevil((magic ? 0 : p_ptr->protevil) + randint1(25) + k, FALSE)) ident = TRUE;
2633                         if (set_poisoned(0)) ident = TRUE;
2634                         if (set_afraid(0)) ident = TRUE;
2635                         if (hp_player(50)) ident = TRUE;
2636                         if (set_stun(0)) ident = TRUE;
2637                         if (set_cut(0)) ident = TRUE;
2638                         break;
2639                 }
2640
2641                 case SV_STAFF_GENOCIDE:
2642                 {
2643                         (void)symbol_genocide((magic ? lev + 50 : 200), TRUE);
2644                         ident = TRUE;
2645                         break;
2646                 }
2647
2648                 case SV_STAFF_EARTHQUAKES:
2649                 {
2650                         if (earthquake(py, px, (powerful ? 15 : 10)))
2651                                 ident = TRUE;
2652                         else
2653 #ifdef JP
2654 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿¡£");
2655 #else
2656                                 msg_print("The dungeon trembles.");
2657 #endif
2658
2659
2660                         break;
2661                 }
2662
2663                 case SV_STAFF_DESTRUCTION:
2664                 {
2665                         if (destroy_area(py, px, (powerful ? 18 : 13) + randint0(5), FALSE))
2666                                 ident = TRUE;
2667
2668                         break;
2669                 }
2670
2671                 case SV_STAFF_ANIMATE_DEAD:
2672                 {
2673                         if (animate_dead(0, py, px))
2674                                 ident = TRUE;
2675
2676                         break;
2677                 }
2678
2679                 case SV_STAFF_MSTORM:
2680                 {
2681 #ifdef JP
2682                         msg_print("¶¯ÎϤÊËâÎϤ¬Å¨¤ò°ú¤­Îö¤¤¤¿¡ª");
2683 #else
2684                         msg_print("Mighty magics rend your enemies!");
2685 #endif
2686                         project(0, (powerful ? 7 : 5), py, px,
2687                                 (randint1(200) + (powerful ? 500 : 300)) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID, -1);
2688                         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))
2689                         {
2690 #ifdef JP
2691                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "¥³¥ó¥È¥í¡¼¥ë¤·Æñ¤¤¶¯ÎϤÊËâÎϤβòÊü", -1);
2692 #else
2693                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "unleashing magics too mighty to control", -1);
2694 #endif
2695                         }
2696                         ident = TRUE;
2697
2698                         break;
2699                 }
2700
2701                 case SV_STAFF_NOTHING:
2702                 {
2703 #ifdef JP
2704                         msg_print("²¿¤âµ¯¤é¤Ê¤«¤Ã¤¿¡£");
2705 #else
2706                         msg_print("Nothing happen.");
2707 #endif
2708                         if (prace_is_(RACE_SKELETON) || prace_is_(RACE_GOLEM) ||
2709                                 prace_is_(RACE_ZOMBIE) || prace_is_(RACE_SPECTRE))
2710 #ifdef JP
2711                                 msg_print("¤â¤Ã¤¿¤¤¤Ê¤¤»ö¤ò¤·¤¿¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£¿©¤Ùʪ¤ÏÂçÀڤˤ·¤Ê¤¯¤Æ¤Ï¡£");
2712 #else
2713                                 msg_print("What a waste.  It's your food!");
2714 #endif
2715                         break;
2716                 }
2717         }
2718         return ident;
2719 }
2720
2721 /*!
2722  * @brief ¾ó¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó / 
2723  * Use a staff.                 -RAK-
2724  * @param item »È¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
2725  * @return ¤Ê¤·
2726  * @details
2727  * One charge of one staff disappears.
2728  * Hack -- staffs of identify can be "cancelled".
2729  */
2730 static void do_cmd_use_staff_aux(int item)
2731 {
2732         int         ident, chance, lev;
2733         object_type *o_ptr;
2734
2735
2736         /* Hack -- let staffs of identify get aborted */
2737         bool use_charge = TRUE;
2738
2739
2740         /* Get the item (in the pack) */
2741         if (item >= 0)
2742         {
2743                 o_ptr = &inventory[item];
2744         }
2745
2746         /* Get the item (on the floor) */
2747         else
2748         {
2749                 o_ptr = &o_list[0 - item];
2750         }
2751
2752
2753         /* Mega-Hack -- refuse to use a pile from the ground */
2754         if ((item < 0) && (o_ptr->number > 1))
2755         {
2756 #ifdef JP
2757                 msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
2758 #else
2759                 msg_print("You must first pick up the staffs.");
2760 #endif
2761
2762                 return;
2763         }
2764
2765
2766         /* Take a turn */
2767         energy_use = 100;
2768
2769         /* Extract the item level */
2770         lev = k_info[o_ptr->k_idx].level;
2771         if (lev > 50) lev = 50 + (lev - 50)/2;
2772
2773         /* Base chance of success */
2774         chance = p_ptr->skill_dev;
2775
2776         /* Confusion hurts skill */
2777         if (p_ptr->confused) chance = chance / 2;
2778
2779         /* Hight level objects are harder */
2780         chance = chance - lev;
2781
2782         /* Give everyone a (slight) chance */
2783         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
2784         {
2785                 chance = USE_DEVICE;
2786         }
2787
2788         if (world_player)
2789         {
2790                 if (flush_failure) flush();
2791 #ifdef JP
2792                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
2793 #else
2794                 msg_print("Nothing happen. Maybe this staff is freezing too.");
2795 #endif
2796
2797                 sound(SOUND_FAIL);
2798                 return;
2799         }
2800
2801         /* Roll for usage */
2802         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
2803         {
2804                 if (flush_failure) flush();
2805 #ifdef JP
2806                 msg_print("¾ó¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
2807 #else
2808                 msg_print("You failed to use the staff properly.");
2809 #endif
2810
2811                 sound(SOUND_FAIL);
2812                 return;
2813         }
2814
2815         /* Notice empty staffs */
2816         if (o_ptr->pval <= 0)
2817         {
2818                 if (flush_failure) flush();
2819 #ifdef JP
2820                 msg_print("¤³¤Î¾ó¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
2821 #else
2822                 msg_print("The staff has no charges left.");
2823 #endif
2824
2825                 o_ptr->ident |= (IDENT_EMPTY);
2826
2827                 /* Combine / Reorder the pack (later) */
2828                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2829                 p_ptr->window |= (PW_INVEN);
2830
2831                 return;
2832         }
2833
2834
2835         /* Sound */
2836         sound(SOUND_ZAP);
2837
2838         ident = staff_effect(o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
2839
2840         if (!(object_is_aware(o_ptr)))
2841         {
2842                 chg_virtue(V_PATIENCE, -1);
2843                 chg_virtue(V_CHANCE, 1);
2844                 chg_virtue(V_KNOWLEDGE, -1);
2845         }
2846
2847         /* Combine / Reorder the pack (later) */
2848         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2849
2850         /* Tried the item */
2851         object_tried(o_ptr);
2852
2853         /* An identification was made */
2854         if (ident && !object_is_aware(o_ptr))
2855         {
2856                 object_aware(o_ptr);
2857                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2858         }
2859
2860         /* Window stuff */
2861         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2862
2863
2864         /* Hack -- some uses are "free" */
2865         if (!use_charge) return;
2866
2867
2868         /* Use a single charge */
2869         o_ptr->pval--;
2870
2871         /* XXX Hack -- unstack if necessary */
2872         if ((item >= 0) && (o_ptr->number > 1))
2873         {
2874                 object_type forge;
2875                 object_type *q_ptr;
2876
2877                 /* Get local object */
2878                 q_ptr = &forge;
2879
2880                 /* Obtain a local object */
2881                 object_copy(q_ptr, o_ptr);
2882
2883                 /* Modify quantity */
2884                 q_ptr->number = 1;
2885
2886                 /* Restore the charges */
2887                 o_ptr->pval++;
2888
2889                 /* Unstack the used item */
2890                 o_ptr->number--;
2891                 p_ptr->total_weight -= q_ptr->weight;
2892                 item = inven_carry(q_ptr);
2893
2894                 /* Message */
2895 #ifdef JP
2896                 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
2897 #else
2898                 msg_print("You unstack your staff.");
2899 #endif
2900
2901         }
2902
2903         /* Describe charges in the pack */
2904         if (item >= 0)
2905         {
2906                 inven_item_charges(item);
2907         }
2908
2909         /* Describe charges on the floor */
2910         else
2911         {
2912                 floor_item_charges(0 - item);
2913         }
2914 }
2915
2916 /*!
2917  * @brief ¾ó¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2918  * @return ¤Ê¤·
2919  */
2920 void do_cmd_use_staff(void)
2921 {
2922         int  item;
2923         cptr q, s;
2924
2925         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2926         {
2927                 set_action(ACTION_NONE);
2928         }
2929
2930         /* Restrict choices to wands */
2931         item_tester_tval = TV_STAFF;
2932
2933         /* Get an item */
2934 #ifdef JP
2935         q = "¤É¤Î¾ó¤ò»È¤¤¤Þ¤¹¤«? ";
2936         s = "»È¤¨¤ë¾ó¤¬¤Ê¤¤¡£";
2937 #else
2938         q = "Use which staff? ";
2939         s = "You have no staff to use.";
2940 #endif
2941
2942         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2943
2944         do_cmd_use_staff_aux(item);
2945 }
2946
2947 /*!
2948  * @brief ËâË¡ËÀ¤Î¸ú²Ì¤òȯư¤¹¤ë
2949  * @param sval ¥ª¥Ö¥¸¥§¥¯¥È¤Îsval
2950  * @param dir È¯Æ°¤ÎÊý¸þID
2951  * @param powerful ¶¯ÎÏȯư¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2952  * @param magic ËâÆ»¶ñ½Ñ¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2953  * @return È¯Æ°¤Ë¤è¤ê¸ú²ÌÆâÍƤ¬³ÎÄꤷ¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
2954  */
2955 static int wand_effect(int sval, int dir, bool powerful, bool magic)
2956 {
2957         int ident = FALSE;
2958         int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
2959         int rad = powerful ? 3 : 2;
2960
2961         /* XXX Hack -- Wand of wonder can do anything before it */
2962         if (sval == SV_WAND_WONDER)
2963         {
2964                 int vir = virtue_number(V_CHANCE);
2965                 sval = randint0(SV_WAND_WONDER);
2966
2967                 if (vir)
2968                 {
2969                         if (p_ptr->virtues[vir - 1] > 0)
2970                         {
2971                                 while (randint1(300) < p_ptr->virtues[vir - 1]) sval++;
2972                                 if (sval > SV_WAND_COLD_BALL) sval = randint0(4) + SV_WAND_ACID_BALL;
2973                         }
2974                         else
2975                         {
2976                                 while (randint1(300) < (0-p_ptr->virtues[vir - 1])) sval--;
2977                                 if (sval < SV_WAND_HEAL_MONSTER) sval = randint0(3) + SV_WAND_HEAL_MONSTER;
2978                         }
2979                 }
2980                 if (sval < SV_WAND_TELEPORT_AWAY)
2981                         chg_virtue(V_CHANCE, 1);
2982         }
2983
2984         /* Analyze the wand */
2985         switch (sval)
2986         {
2987                 case SV_WAND_HEAL_MONSTER:
2988                 {
2989                         int dam = damroll((powerful ? 20 : 10), 10);
2990                         if (heal_monster(dir, dam)) ident = TRUE;
2991                         break;
2992                 }
2993
2994                 case SV_WAND_HASTE_MONSTER:
2995                 {
2996                         if (speed_monster(dir, lev)) ident = TRUE;
2997                         break;
2998                 }
2999
3000                 case SV_WAND_CLONE_MONSTER:
3001                 {
3002                         if (clone_monster(dir)) ident = TRUE;
3003                         break;
3004                 }
3005
3006                 case SV_WAND_TELEPORT_AWAY:
3007                 {
3008                         int distance = MAX_SIGHT * (powerful ? 8 : 5);
3009                         if (teleport_monster(dir, distance)) ident = TRUE;
3010                         break;
3011                 }
3012
3013                 case SV_WAND_DISARMING:
3014                 {
3015                         if (disarm_trap(dir)) ident = TRUE;
3016                         if (powerful && disarm_traps_touch()) ident = TRUE;
3017                         break;
3018                 }
3019
3020                 case SV_WAND_TRAP_DOOR_DEST:
3021                 {
3022                         if (destroy_door(dir)) ident = TRUE;
3023                         if (powerful && destroy_doors_touch()) ident = TRUE;
3024                         break;
3025                 }
3026
3027                 case SV_WAND_STONE_TO_MUD:
3028                 {
3029                         int dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
3030                         if (wall_to_mud(dir, dam)) ident = TRUE;
3031                         break;
3032                 }
3033
3034                 case SV_WAND_LITE:
3035                 {
3036                         int dam = damroll((powerful ? 12 : 6), 8);
3037 #ifdef JP
3038                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3039 #else
3040                         msg_print("A line of blue shimmering light appears.");
3041 #endif
3042
3043                         (void)lite_line(dir, dam);
3044                         ident = TRUE;
3045                         break;
3046                 }
3047
3048                 case SV_WAND_SLEEP_MONSTER:
3049                 {
3050                         if (sleep_monster(dir, lev)) ident = TRUE;
3051                         break;
3052                 }
3053
3054                 case SV_WAND_SLOW_MONSTER:
3055                 {
3056                         if (slow_monster(dir, lev)) ident = TRUE;
3057                         break;
3058                 }
3059
3060                 case SV_WAND_CONFUSE_MONSTER:
3061                 {
3062                         if (confuse_monster(dir, lev)) ident = TRUE;
3063                         break;
3064                 }
3065
3066                 case SV_WAND_FEAR_MONSTER:
3067                 {
3068                         if (fear_monster(dir, lev)) ident = TRUE;
3069                         break;
3070                 }
3071
3072                 case SV_WAND_DRAIN_LIFE:
3073                 {
3074                         if (drain_life(dir, 80 + lev)) ident = TRUE;
3075                         break;
3076                 }
3077
3078                 case SV_WAND_POLYMORPH:
3079                 {
3080                         if (poly_monster(dir, lev)) ident = TRUE;
3081                         break;
3082                 }
3083
3084                 case SV_WAND_STINKING_CLOUD:
3085                 {
3086                         fire_ball(GF_POIS, dir, 12 + lev / 4, rad);
3087                         ident = TRUE;
3088                         break;
3089                 }
3090
3091                 case SV_WAND_MAGIC_MISSILE:
3092                 {
3093                         fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(2 + lev / 10, 6));
3094                         ident = TRUE;
3095                         break;
3096                 }
3097
3098                 case SV_WAND_ACID_BOLT:
3099                 {
3100                         fire_bolt_or_beam(20, GF_ACID, dir, damroll(6 + lev / 7, 8));
3101                         ident = TRUE;
3102                         break;
3103                 }
3104
3105                 case SV_WAND_CHARM_MONSTER:
3106                 {
3107                         if (charm_monster(dir, MAX(20, lev)))
3108                         ident = TRUE;
3109                         break;
3110                 }
3111
3112                 case SV_WAND_FIRE_BOLT:
3113                 {
3114                         fire_bolt_or_beam(20, GF_FIRE, dir, damroll(7 + lev / 6, 8));
3115                         ident = TRUE;
3116                         break;
3117                 }
3118
3119                 case SV_WAND_COLD_BOLT:
3120                 {
3121                         fire_bolt_or_beam(20, GF_COLD, dir, damroll(5 + lev / 8, 8));
3122                         ident = TRUE;
3123                         break;
3124                 }
3125
3126                 case SV_WAND_ACID_BALL:
3127                 {
3128                         fire_ball(GF_ACID, dir, 60 + 3 * lev / 4, rad);
3129                         ident = TRUE;
3130                         break;
3131                 }
3132
3133                 case SV_WAND_ELEC_BALL:
3134                 {
3135                         fire_ball(GF_ELEC, dir, 40 + 3 * lev / 4, rad);
3136                         ident = TRUE;
3137                         break;
3138                 }
3139
3140                 case SV_WAND_FIRE_BALL:
3141                 {
3142                         fire_ball(GF_FIRE, dir, 70 + 3 * lev / 4, rad);
3143                         ident = TRUE;
3144                         break;
3145                 }
3146
3147                 case SV_WAND_COLD_BALL:
3148                 {
3149                         fire_ball(GF_COLD, dir, 50 + 3 * lev / 4, rad);
3150                         ident = TRUE;
3151                         break;
3152                 }
3153
3154                 case SV_WAND_WONDER:
3155                 {
3156 #ifdef JP
3157                         msg_print("¤ª¤Ã¤È¡¢Ææ¤ÎËâË¡ËÀ¤ò»ÏÆ°¤µ¤»¤¿¡£");
3158 #else
3159                         msg_print("Oops.  Wand of wonder activated.");
3160 #endif
3161
3162                         break;
3163                 }
3164
3165                 case SV_WAND_DRAGON_FIRE:
3166                 {
3167                         fire_ball(GF_FIRE, dir, (powerful ? 300 : 200), -3);
3168                         ident = TRUE;
3169                         break;
3170                 }
3171
3172                 case SV_WAND_DRAGON_COLD:
3173                 {
3174                         fire_ball(GF_COLD, dir, (powerful ? 270 : 180), -3);
3175                         ident = TRUE;
3176                         break;
3177                 }
3178
3179                 case SV_WAND_DRAGON_BREATH:
3180                 {
3181                         int dam;
3182                         int typ;
3183
3184                         switch (randint1(5))
3185                         {
3186                                 case 1:
3187                                         dam = 240;
3188                                         typ = GF_ACID;
3189                                         break;
3190                                 case 2:
3191                                         dam = 210;
3192                                         typ = GF_ELEC;
3193                                         break;
3194                                 case 3:
3195                                         dam = 240;
3196                                         typ = GF_FIRE;
3197                                         break;
3198                                 case 4:
3199                                         dam = 210;
3200                                         typ = GF_COLD;
3201                                         break;
3202                                 default:
3203                                         dam = 180;
3204                                         typ = GF_POIS;
3205                                         break;
3206                         }
3207
3208                         if (powerful) dam = (dam * 3) / 2;
3209
3210                         fire_ball(typ, dir, dam, -3);
3211
3212                         ident = TRUE;
3213                         break;
3214                 }
3215
3216                 case SV_WAND_DISINTEGRATE:
3217                 {
3218                         fire_ball(GF_DISINTEGRATE, dir, 200 + randint1(lev * 2), rad);
3219                         ident = TRUE;
3220                         break;
3221                 }
3222
3223                 case SV_WAND_ROCKETS:
3224                 {
3225 #ifdef JP
3226 msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
3227 #else
3228                         msg_print("You launch a rocket!");
3229 #endif
3230
3231                         fire_rocket(GF_ROCKET, dir, 250 + lev * 3, rad);
3232                         ident = TRUE;
3233                         break;
3234                 }
3235
3236                 case SV_WAND_STRIKING:
3237                 {
3238                         fire_bolt(GF_METEOR, dir, damroll(15 + lev / 3, 13));
3239                         ident = TRUE;
3240                         break;
3241                 }
3242
3243                 case SV_WAND_GENOCIDE:
3244                 {
3245                         fire_ball_hide(GF_GENOCIDE, dir, magic ? lev + 50 : 250, 0);
3246                         ident = TRUE;
3247                         break;
3248                 }
3249         }
3250         return ident;
3251 }
3252
3253 /*!
3254  * @brief ËâË¡ËÀ¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó / 
3255  * Aim a wand (from the pack or floor).
3256  * @param item »È¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
3257  * @return ¤Ê¤·
3258  * @details
3259  * <pre>
3260  * Use a single charge from a single item.
3261  * Handle "unstacking" in a logical manner.
3262  * For simplicity, you cannot use a stack of items from the
3263  * ground.  This would require too much nasty code.
3264  * There are no wands which can "destroy" themselves, in the inventory
3265  * or on the ground, so we can ignore this possibility.  Note that this
3266  * required giving "wand of wonder" the ability to ignore destruction
3267  * by electric balls.
3268  * All wands can be "cancelled" at the "Direction?" prompt for free.
3269  * Note that the basic "bolt" wands do slightly less damage than the
3270  * basic "bolt" rods, but the basic "ball" wands do the same damage
3271  * as the basic "ball" rods.
3272  * </pre>
3273  */
3274 static void do_cmd_aim_wand_aux(int item)
3275 {
3276         int         lev, ident, chance, dir;
3277         object_type *o_ptr;
3278         bool old_target_pet = target_pet;
3279
3280         /* Get the item (in the pack) */
3281         if (item >= 0)
3282         {
3283                 o_ptr = &inventory[item];
3284         }
3285
3286         /* Get the item (on the floor) */
3287         else
3288         {
3289                 o_ptr = &o_list[0 - item];
3290         }
3291
3292         /* Mega-Hack -- refuse to aim a pile from the ground */
3293         if ((item < 0) && (o_ptr->number > 1))
3294         {
3295 #ifdef JP
3296                 msg_print("¤Þ¤º¤ÏËâË¡ËÀ¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3297 #else
3298                 msg_print("You must first pick up the wands.");
3299 #endif
3300
3301                 return;
3302         }
3303
3304
3305         /* Allow direction to be cancelled for free */
3306         if (object_is_aware(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
3307                                       || o_ptr->sval == SV_WAND_HASTE_MONSTER))
3308                         target_pet = TRUE;
3309         if (!get_aim_dir(&dir))
3310         {
3311                 target_pet = old_target_pet;
3312                 return;
3313         }
3314         target_pet = old_target_pet;
3315
3316         /* Take a turn */
3317         energy_use = 100;
3318
3319         /* Get the level */
3320         lev = k_info[o_ptr->k_idx].level;
3321         if (lev > 50) lev = 50 + (lev - 50)/2;
3322
3323         /* Base chance of success */
3324         chance = p_ptr->skill_dev;
3325
3326         /* Confusion hurts skill */
3327         if (p_ptr->confused) chance = chance / 2;
3328
3329         /* Hight level objects are harder */
3330         chance = chance - lev;
3331
3332         /* Give everyone a (slight) chance */
3333         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
3334         {
3335                 chance = USE_DEVICE;
3336         }
3337
3338         if (world_player)
3339         {
3340                 if (flush_failure) flush();
3341 #ifdef JP
3342                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3343 #else
3344                 msg_print("Nothing happen. Maybe this wand is freezing too.");
3345 #endif
3346
3347                 sound(SOUND_FAIL);
3348                 return;
3349         }
3350
3351         /* Roll for usage */
3352         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
3353         {
3354                 if (flush_failure) flush();
3355 #ifdef JP
3356                 msg_print("ËâË¡ËÀ¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
3357 #else
3358                 msg_print("You failed to use the wand properly.");
3359 #endif
3360
3361                 sound(SOUND_FAIL);
3362                 return;
3363         }
3364
3365         /* The wand is already empty! */
3366         if (o_ptr->pval <= 0)
3367         {
3368                 if (flush_failure) flush();
3369 #ifdef JP
3370                 msg_print("¤³¤ÎËâË¡ËÀ¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
3371 #else
3372                 msg_print("The wand has no charges left.");
3373 #endif
3374
3375                 o_ptr->ident |= (IDENT_EMPTY);
3376
3377                 /* Combine / Reorder the pack (later) */
3378                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3379                 p_ptr->window |= (PW_INVEN);
3380
3381                 return;
3382         }
3383
3384         /* Sound */
3385         sound(SOUND_ZAP);
3386
3387         ident = wand_effect(o_ptr->sval, dir, FALSE, FALSE);
3388
3389         /* Combine / Reorder the pack (later) */
3390         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3391
3392         if (!(object_is_aware(o_ptr)))
3393         {
3394                 chg_virtue(V_PATIENCE, -1);
3395                 chg_virtue(V_CHANCE, 1);
3396                 chg_virtue(V_KNOWLEDGE, -1);
3397         }
3398
3399         /* Mark it as tried */
3400         object_tried(o_ptr);
3401
3402         /* Apply identification */
3403         if (ident && !object_is_aware(o_ptr))
3404         {
3405                 object_aware(o_ptr);
3406                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3407         }
3408
3409         /* Window stuff */
3410         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3411
3412
3413         /* Use a single charge */
3414         o_ptr->pval--;
3415
3416         /* Describe the charges in the pack */
3417         if (item >= 0)
3418         {
3419                 inven_item_charges(item);
3420         }
3421
3422         /* Describe the charges on the floor */
3423         else
3424         {
3425                 floor_item_charges(0 - item);
3426         }
3427 }
3428
3429 /*!
3430  * @brief ËâË¡ËÀ¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
3431  * @return ¤Ê¤·
3432  */
3433 void do_cmd_aim_wand(void)
3434 {
3435         int     item;
3436         cptr    q, s;
3437
3438         /* Restrict choices to wands */
3439         item_tester_tval = TV_WAND;
3440
3441         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3442         {
3443                 set_action(ACTION_NONE);
3444         }
3445
3446         /* Get an item */
3447 #ifdef JP
3448         q = "¤É¤ÎËâË¡ËÀ¤ÇÁÀ¤¤¤Þ¤¹¤«? ";
3449         s = "»È¤¨¤ëËâË¡ËÀ¤¬¤Ê¤¤¡£";
3450 #else
3451         q = "Aim which wand? ";
3452         s = "You have no wand to aim.";
3453 #endif
3454
3455         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3456
3457         /* Aim the wand */
3458         do_cmd_aim_wand_aux(item);
3459 }
3460
3461 /*!
3462  * @brief ¥í¥Ã¥É¤Î¸ú²Ì¤òȯư¤¹¤ë
3463  * @param sval ¥ª¥Ö¥¸¥§¥¯¥È¤Îsval
3464  * @param dir È¯Æ°ÌÜɸ¤ÎÊý¸þID
3465  * @param use_charge ¥Á¥ã¡¼¥¸¤ò¾ÃÈñ¤·¤¿¤«¤É¤¦¤«¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
3466  * @param powerful ¶¯ÎÏȯư¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
3467  * @param magic ËâÆ»¶ñ½Ñ¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
3468  * @return È¯Æ°¤Ë¤è¤ê¸ú²ÌÆâÍƤ¬³ÎÄꤷ¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
3469  */
3470 static int rod_effect(int sval, int dir, bool *use_charge, bool powerful, bool magic)
3471 {
3472         int ident = FALSE;
3473         int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
3474         int detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
3475         int rad = powerful ? 3 : 2;
3476
3477         /* Unused */
3478         (void)magic;
3479
3480         /* Analyze the rod */
3481         switch (sval)
3482         {
3483                 case SV_ROD_DETECT_TRAP:
3484                 {
3485                         if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
3486                         break;
3487                 }
3488
3489                 case SV_ROD_DETECT_DOOR:
3490                 {
3491                         if (detect_doors(detect_rad)) ident = TRUE;
3492                         if (detect_stairs(detect_rad)) ident = TRUE;
3493                         break;
3494                 }
3495
3496                 case SV_ROD_IDENTIFY:
3497                 {
3498                         if (powerful) {
3499                                 if (!identify_fully(FALSE)) *use_charge = FALSE;
3500                         } else {
3501                                 if (!ident_spell(FALSE)) *use_charge = FALSE;
3502                         }
3503                         ident = TRUE;
3504                         break;
3505                 }
3506
3507                 case SV_ROD_RECALL:
3508                 {
3509                         if (!word_of_recall()) *use_charge = FALSE;
3510                         ident = TRUE;
3511                         break;
3512                 }
3513
3514                 case SV_ROD_ILLUMINATION:
3515                 {
3516                         if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
3517                         break;
3518                 }
3519
3520                 case SV_ROD_MAPPING:
3521                 {
3522                         map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
3523                         ident = TRUE;
3524                         break;
3525                 }
3526
3527                 case SV_ROD_DETECTION:
3528                 {
3529                         detect_all(detect_rad);
3530                         ident = TRUE;
3531                         break;
3532                 }
3533
3534                 case SV_ROD_PROBING:
3535                 {
3536                         probing();
3537                         ident = TRUE;
3538                         break;
3539                 }
3540
3541                 case SV_ROD_CURING:
3542                 {
3543                         if (set_blind(0)) ident = TRUE;
3544                         if (set_poisoned(0)) ident = TRUE;
3545                         if (set_confused(0)) ident = TRUE;
3546                         if (set_stun(0)) ident = TRUE;
3547                         if (set_cut(0)) ident = TRUE;
3548                         if (set_image(0)) ident = TRUE;
3549                         if (set_shero(0,TRUE)) ident = TRUE;
3550                         break;
3551                 }
3552
3553                 case SV_ROD_HEALING:
3554                 {
3555                         if (hp_player(powerful ? 750 : 500)) ident = TRUE;
3556                         if (set_stun(0)) ident = TRUE;
3557                         if (set_cut(0)) ident = TRUE;
3558                         if (set_shero(0,TRUE)) ident = TRUE;
3559                         break;
3560                 }
3561
3562                 case SV_ROD_RESTORATION:
3563                 {
3564                         if (restore_level()) ident = TRUE;
3565                         if (do_res_stat(A_STR)) ident = TRUE;
3566                         if (do_res_stat(A_INT)) ident = TRUE;
3567                         if (do_res_stat(A_WIS)) ident = TRUE;
3568                         if (do_res_stat(A_DEX)) ident = TRUE;
3569                         if (do_res_stat(A_CON)) ident = TRUE;
3570                         if (do_res_stat(A_CHR)) ident = TRUE;
3571                         break;
3572                 }
3573
3574                 case SV_ROD_SPEED:
3575                 {
3576                         if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
3577                         break;
3578                 }
3579
3580                 case SV_ROD_PESTICIDE:
3581                 {
3582                         if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
3583                         break;
3584                 }
3585
3586                 case SV_ROD_TELEPORT_AWAY:
3587                 {
3588                         int distance = MAX_SIGHT * (powerful ? 8 : 5);
3589                         if (teleport_monster(dir, distance)) ident = TRUE;
3590                         break;
3591                 }
3592
3593                 case SV_ROD_DISARMING:
3594                 {
3595                         if (disarm_trap(dir)) ident = TRUE;
3596                         if (powerful && disarm_traps_touch()) ident = TRUE;
3597                         break;
3598                 }
3599
3600                 case SV_ROD_LITE:
3601                 {
3602                         int dam = damroll((powerful ? 12 : 6), 8);
3603 #ifdef JP
3604                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3605 #else
3606                         msg_print("A line of blue shimmering light appears.");
3607 #endif
3608
3609                         (void)lite_line(dir, dam);
3610                         ident = TRUE;
3611                         break;
3612                 }
3613
3614                 case SV_ROD_SLEEP_MONSTER:
3615                 {
3616                         if (sleep_monster(dir, lev)) ident = TRUE;
3617                         break;
3618                 }
3619
3620                 case SV_ROD_SLOW_MONSTER:
3621                 {
3622                         if (slow_monster(dir, lev)) ident = TRUE;
3623                         break;
3624                 }
3625
3626                 case SV_ROD_DRAIN_LIFE:
3627                 {
3628                         if (drain_life(dir, 70 + 3 * lev / 2)) ident = TRUE;
3629                         break;
3630                 }
3631
3632                 case SV_ROD_POLYMORPH:
3633                 {
3634                         if (poly_monster(dir, lev)) ident = TRUE;
3635                         break;
3636                 }
3637
3638                 case SV_ROD_ACID_BOLT:
3639                 {
3640                         fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
3641                         ident = TRUE;
3642                         break;
3643                 }
3644
3645                 case SV_ROD_ELEC_BOLT:
3646                 {
3647                         fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
3648                         ident = TRUE;
3649                         break;
3650                 }
3651
3652                 case SV_ROD_FIRE_BOLT:
3653                 {
3654                         fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
3655                         ident = TRUE;
3656                         break;
3657                 }
3658
3659                 case SV_ROD_COLD_BOLT:
3660                 {
3661                         fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
3662                         ident = TRUE;
3663                         break;
3664                 }
3665
3666                 case SV_ROD_ACID_BALL:
3667                 {
3668                         fire_ball(GF_ACID, dir, 60 + lev, rad);
3669                         ident = TRUE;
3670                         break;
3671                 }
3672
3673                 case SV_ROD_ELEC_BALL:
3674                 {
3675                         fire_ball(GF_ELEC, dir, 40 + lev, rad);
3676                         ident = TRUE;
3677                         break;
3678                 }
3679
3680                 case SV_ROD_FIRE_BALL:
3681                 {
3682                         fire_ball(GF_FIRE, dir, 70 + lev, rad);
3683                         ident = TRUE;
3684                         break;
3685                 }
3686
3687                 case SV_ROD_COLD_BALL:
3688                 {
3689                         fire_ball(GF_COLD, dir, 50 + lev, rad);
3690                         ident = TRUE;
3691                         break;
3692                 }
3693
3694                 case SV_ROD_HAVOC:
3695                 {
3696                         call_chaos();
3697                         ident = TRUE;
3698                         break;
3699                 }
3700
3701                 case SV_ROD_STONE_TO_MUD:
3702                 {
3703                         int dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
3704                         if (wall_to_mud(dir, dam)) ident = TRUE;
3705                         break;
3706                 }
3707
3708                 case SV_ROD_AGGRAVATE:
3709                 {
3710                         aggravate_monsters(0);
3711                         ident = TRUE;
3712                         break;
3713                 }
3714         }
3715         return ident;
3716 }
3717
3718 /*!
3719  * @brief ËâË¡ËÀ¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó / 
3720  * Activate (zap) a Rod
3721  * @param item »È¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
3722  * @return ¤Ê¤·
3723  * @details
3724  * <pre>
3725  * Unstack fully charged rods as needed.
3726  * Hack -- rods of perception/genocide can be "cancelled"
3727  * All rods can be cancelled at the "Direction?" prompt
3728  * pvals are defined for each rod in k_info. -LM-
3729  * </pre>
3730  */
3731 static void do_cmd_zap_rod_aux(int item)
3732 {
3733         int ident, chance, lev, fail;
3734         int dir = 0;
3735         object_type *o_ptr;
3736         bool success;
3737
3738         /* Hack -- let perception get aborted */
3739         bool use_charge = TRUE;
3740
3741         object_kind *k_ptr;
3742
3743         /* Get the item (in the pack) */
3744         if (item >= 0)
3745         {
3746                 o_ptr = &inventory[item];
3747         }
3748
3749         /* Get the item (on the floor) */
3750         else
3751         {
3752                 o_ptr = &o_list[0 - item];
3753         }
3754
3755
3756         /* Mega-Hack -- refuse to zap a pile from the ground */
3757         if ((item < 0) && (o_ptr->number > 1))
3758         {
3759 #ifdef JP
3760                 msg_print("¤Þ¤º¤Ï¥í¥Ã¥É¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3761 #else
3762                 msg_print("You must first pick up the rods.");
3763 #endif
3764
3765                 return;
3766         }
3767
3768
3769         /* Get a direction (unless KNOWN not to need it) */
3770         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)) ||
3771              !object_is_aware(o_ptr))
3772         {
3773                 /* Get a direction, allow cancel */
3774                 if (!get_aim_dir(&dir)) return;
3775         }
3776
3777
3778         /* Take a turn */
3779         energy_use = 100;
3780
3781         /* Extract the item level */
3782         lev = k_info[o_ptr->k_idx].level;
3783
3784         /* Base chance of success */
3785         chance = p_ptr->skill_dev;
3786
3787         /* Confusion hurts skill */
3788         if (p_ptr->confused) chance = chance / 2;
3789
3790         fail = lev+5;
3791         if (chance > fail) fail -= (chance - fail)*2;
3792         else chance -= (fail - chance)*2;
3793         if (fail < USE_DEVICE) fail = USE_DEVICE;
3794         if (chance < USE_DEVICE) chance = USE_DEVICE;
3795
3796         if (world_player)
3797         {
3798                 if (flush_failure) flush();
3799 #ifdef JP
3800                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3801 #else
3802                 msg_print("Nothing happen. Maybe this rod is freezing too.");
3803 #endif
3804
3805                 sound(SOUND_FAIL);
3806                 return;
3807         }
3808
3809         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
3810         else if (chance > fail)
3811         {
3812                 if (randint0(chance*2) < fail) success = FALSE;
3813                 else success = TRUE;
3814         }
3815         else
3816         {
3817                 if (randint0(fail*2) < chance) success = TRUE;
3818                 else success = FALSE;
3819         }
3820
3821         /* Roll for usage */
3822         if (!success)
3823         {
3824                 if (flush_failure) flush();
3825 #ifdef JP
3826                 msg_print("¤¦¤Þ¤¯¥í¥Ã¥É¤ò»È¤¨¤Ê¤«¤Ã¤¿¡£");
3827 #else
3828                 msg_print("You failed to use the rod properly.");
3829 #endif
3830
3831                 sound(SOUND_FAIL);
3832                 return;
3833         }
3834
3835         k_ptr = &k_info[o_ptr->k_idx];
3836
3837         /* A single rod is still charging */
3838         if ((o_ptr->number == 1) && (o_ptr->timeout))
3839         {
3840                 if (flush_failure) flush();
3841 #ifdef JP
3842                 msg_print("¤³¤Î¥í¥Ã¥É¤Ï¤Þ¤ÀËâÎϤò½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
3843 #else
3844                 msg_print("The rod is still charging.");
3845 #endif
3846
3847                 return;
3848         }
3849         /* A stack of rods lacks enough energy. */
3850         else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
3851         {
3852                 if (flush_failure) flush();
3853 #ifdef JP
3854 msg_print("¤½¤Î¥í¥Ã¥É¤Ï¤Þ¤À½¼Å¶Ãæ¤Ç¤¹¡£");
3855 #else
3856                 msg_print("The rods are all still charging.");
3857 #endif
3858
3859                 return;
3860         }
3861
3862         /* Sound */
3863         sound(SOUND_ZAP);
3864
3865         ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
3866
3867         /* Increase the timeout by the rod kind's pval. -LM- */
3868         if (use_charge) o_ptr->timeout += k_ptr->pval;
3869
3870         /* Combine / Reorder the pack (later) */
3871         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3872
3873         if (!(object_is_aware(o_ptr)))
3874         {
3875                 chg_virtue(V_PATIENCE, -1);
3876                 chg_virtue(V_CHANCE, 1);
3877                 chg_virtue(V_KNOWLEDGE, -1);
3878         }
3879
3880         /* Tried the object */
3881         object_tried(o_ptr);
3882
3883         /* Successfully determined the object function */
3884         if (ident && !object_is_aware(o_ptr))
3885         {
3886                 object_aware(o_ptr);
3887                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3888         }
3889
3890         /* Window stuff */
3891         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3892 }
3893
3894 /*!
3895  * @brief ¥í¥Ã¥É¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
3896  * @return ¤Ê¤·
3897  */
3898 void do_cmd_zap_rod(void)
3899 {
3900         int item;
3901         cptr q, s;
3902
3903         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3904         {
3905                 set_action(ACTION_NONE);
3906         }
3907
3908         /* Restrict choices to rods */
3909         item_tester_tval = TV_ROD;
3910
3911         /* Get an item */
3912 #ifdef JP
3913         q = "¤É¤Î¥í¥Ã¥É¤ò¿¶¤ê¤Þ¤¹¤«? ";
3914         s = "»È¤¨¤ë¥í¥Ã¥É¤¬¤Ê¤¤¡£";
3915 #else
3916         q = "Zap which rod? ";
3917         s = "You have no rod to zap.";
3918 #endif
3919
3920         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3921
3922         /* Zap the rod */
3923         do_cmd_zap_rod_aux(item);
3924 }
3925
3926 /*!
3927  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤¬ËâÆ»¶ñ¤È¤·¤Æȯư¤Ç¤­¤ë¤«¤òȽÄꤹ¤ë /
3928  * Hook to determine if an object is activatable
3929  * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3930  * @return ËâÆ»¶ñ¤È¤·¤Æȯư²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
3931  */
3932 static bool item_tester_hook_activate(object_type *o_ptr)
3933 {
3934         u32b flgs[TR_FLAG_SIZE];
3935
3936         /* Not known */
3937         if (!object_is_known(o_ptr)) return (FALSE);
3938
3939         /* Extract the flags */
3940         object_flags(o_ptr, flgs);
3941
3942         /* Check activation flag */
3943         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
3944
3945         /* Assume not */
3946         return (FALSE);
3947 }
3948
3949 /*!
3950  * @brief ¡Ø°ì¤Ä¤Î»ØÎء٤θú²Ì½èÍý /
3951  * Hack -- activate the ring of power
3952  * @param dir È¯Æ°¤ÎÊý¸þID
3953  * @return ¤Ê¤·
3954  */
3955 void ring_of_power(int dir)
3956 {
3957         /* Pick a random effect */
3958         switch (randint1(10))
3959         {
3960                 case 1:
3961                 case 2:
3962                 {
3963                         /* Message */
3964 #ifdef JP
3965                         msg_print("¤¢¤Ê¤¿¤Ï°­À­¤Î¥ª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3966 #else
3967                         msg_print("You are surrounded by a malignant aura.");
3968 #endif
3969
3970                         sound(SOUND_EVIL);
3971
3972                         /* Decrease all stats (permanently) */
3973                         (void)dec_stat(A_STR, 50, TRUE);
3974                         (void)dec_stat(A_INT, 50, TRUE);
3975                         (void)dec_stat(A_WIS, 50, TRUE);
3976                         (void)dec_stat(A_DEX, 50, TRUE);
3977                         (void)dec_stat(A_CON, 50, TRUE);
3978                         (void)dec_stat(A_CHR, 50, TRUE);
3979
3980                         /* Lose some experience (permanently) */
3981                         p_ptr->exp -= (p_ptr->exp / 4);
3982                         p_ptr->max_exp -= (p_ptr->exp / 4);
3983                         check_experience();
3984
3985                         break;
3986                 }
3987
3988                 case 3:
3989                 {
3990                         /* Message */
3991 #ifdef JP
3992                         msg_print("¤¢¤Ê¤¿¤Ï¶¯ÎϤʥª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3993 #else
3994                         msg_print("You are surrounded by a powerful aura.");
3995 #endif
3996
3997
3998                         /* Dispel monsters */
3999                         dispel_monsters(1000);
4000
4001                         break;
4002                 }
4003
4004                 case 4:
4005                 case 5:
4006                 case 6:
4007                 {
4008                         /* Mana Ball */
4009                         fire_ball(GF_MANA, dir, 600, 3);
4010
4011                         break;
4012                 }
4013
4014                 case 7:
4015                 case 8:
4016                 case 9:
4017                 case 10:
4018                 {
4019                         /* Mana Bolt */
4020                         fire_bolt(GF_MANA, dir, 500);
4021
4022                         break;
4023                 }
4024         }
4025 }
4026
4027 /*!
4028  * @brief ¥Ú¥Ã¥ÈÆþ¤ê¥â¥ó¥¹¥¿¡¼¥Ü¡¼¥ë¤ò¥½¡¼¥È¤¹¤ë¤¿¤á¤ÎÈæ³Ó´Ø¿ô
4029  * @param u ½ê»ýÉÊÇÛÎó¤Î»²¾È¥Ý¥¤¥ó¥¿
4030  * @param v Ì¤»ÈÍÑ
4031  * @param a ½ê»ýÉÊID1
4032  * @param b ½ê»ýÉÊID2
4033  * @return 1¤ÎÊý¤¬Âç¤Ç¤¢¤ì¤ÐTRUE
4034  */
4035 static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
4036 {
4037         u16b *who = (u16b*)(u);
4038
4039         int w1 = who[a];
4040         int w2 = who[b];
4041
4042         monster_type *m_ptr1 = &m_list[w1];
4043         monster_type *m_ptr2 = &m_list[w2];
4044         monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
4045         monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
4046
4047         /* Unused */
4048         (void)v;
4049
4050         if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
4051         if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
4052
4053         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
4054         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
4055
4056         if (r_ptr1->level > r_ptr2->level) return TRUE;
4057         if (r_ptr2->level > r_ptr1->level) return FALSE;
4058
4059         if (m_ptr1->hp > m_ptr2->hp) return TRUE;
4060         if (m_ptr2->hp > m_ptr1->hp) return FALSE;
4061         
4062         return w1 <= w2;
4063 }
4064
4065
4066 /*!
4067  * @brief ÁõÈ÷¤òȯư¤¹¤ë¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
4068  * Activate a wielded object.  Wielded objects never stack.
4069  * And even if they did, activatable objects never stack.
4070  * @param item È¯Æ°¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
4071  * @return ¤Ê¤·
4072  * @details
4073  * <pre>
4074  * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated.
4075  * But one could, for example, easily make an activatable "Ring of Plasma".
4076  * Note that it always takes a turn to activate an artifact, even if
4077  * the user hits "escape" at the "direction" prompt.
4078  * </pre>
4079  */
4080 static void do_cmd_activate_aux(int item)
4081 {
4082         int         dir, lev, chance, fail;
4083         object_type *o_ptr;
4084         bool success;
4085
4086
4087         /* Get the item (in the pack) */
4088         if (item >= 0)
4089         {
4090                 o_ptr = &inventory[item];
4091         }
4092
4093         /* Get the item (on the floor) */
4094         else
4095         {
4096                 o_ptr = &o_list[0 - item];
4097         }
4098
4099         /* Take a turn */
4100         energy_use = 100;
4101
4102         /* Extract the item level */
4103         lev = k_info[o_ptr->k_idx].level;
4104
4105         /* Hack -- use artifact level instead */
4106         if (object_is_fixed_artifact(o_ptr)) lev = a_info[o_ptr->name1].level;
4107         else if (object_is_random_artifact(o_ptr))
4108         {
4109                 const activation_type* const act_ptr = find_activation_info(o_ptr);
4110                 if (act_ptr) {
4111                         lev = act_ptr->level;
4112                 }
4113         }
4114         else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
4115
4116         /* Base chance of success */
4117         chance = p_ptr->skill_dev;
4118
4119         /* Confusion hurts skill */
4120         if (p_ptr->confused) chance = chance / 2;
4121
4122         fail = lev+5;
4123         if (chance > fail) fail -= (chance - fail)*2;
4124         else chance -= (fail - chance)*2;
4125         if (fail < USE_DEVICE) fail = USE_DEVICE;
4126         if (chance < USE_DEVICE) chance = USE_DEVICE;
4127
4128         if (world_player)
4129         {
4130                 if (flush_failure) flush();
4131 #ifdef JP
4132                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
4133 #else
4134                 msg_print("It shows no reaction.");
4135 #endif
4136                 sound(SOUND_FAIL);
4137                 return;
4138         }
4139
4140         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
4141         else if (chance > fail)
4142         {
4143                 if (randint0(chance*2) < fail) success = FALSE;
4144                 else success = TRUE;
4145         }
4146         else
4147         {
4148                 if (randint0(fail*2) < chance) success = TRUE;
4149                 else success = FALSE;
4150         }
4151
4152         /* Roll for usage */
4153         if (!success)
4154         {
4155                 if (flush_failure) flush();
4156 #ifdef JP
4157                 msg_print("¤¦¤Þ¤¯»ÏÆ°¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Ê¤«¤Ã¤¿¡£");
4158 #else
4159                 msg_print("You failed to activate it properly.");
4160 #endif
4161                 sound(SOUND_FAIL);
4162                 return;
4163         }
4164
4165         /* Check the recharge */
4166         if (o_ptr->timeout)
4167         {
4168 #ifdef JP
4169                 msg_print("¤½¤ì¤ÏÈù¤«¤Ë²»¤òΩ¤Æ¡¢µ±¤­¡¢¾Ã¤¨¤¿...");
4170 #else
4171                 msg_print("It whines, glows and fades...");
4172 #endif
4173                 return;
4174         }
4175
4176         /* Some lights need enough fuel for activation */
4177         if (!o_ptr->xtra4 && (o_ptr->tval == TV_FLASK) &&
4178                 ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
4179         {
4180 #ifdef JP
4181                 msg_print("dzÎÁ¤¬¤Ê¤¤¡£");
4182 #else
4183                 msg_print("It has no fuel.");
4184 #endif
4185                 energy_use = 0;
4186                 return;
4187         }
4188
4189         /* Activate the artifact */
4190 #ifdef JP
4191         msg_print("»ÏÆ°¤µ¤»¤¿...");
4192 #else
4193         msg_print("You activate it...");
4194 #endif
4195
4196
4197         /* Sound */
4198         sound(SOUND_ZAP);
4199
4200         /* Activate object */
4201         if (activation_index(o_ptr))
4202         {
4203                 (void)activate_random_artifact(o_ptr);
4204
4205                 /* Window stuff */
4206                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4207
4208                 /* Success */
4209                 return;
4210         }
4211
4212         /* Special items */
4213         else if (o_ptr->tval == TV_WHISTLE)
4214         {
4215                 if (music_singing_any()) stop_singing();
4216                 if (hex_spelling_any()) stop_hex_spell_all();
4217
4218 #if 0
4219                 if (object_is_cursed(o_ptr))
4220                 {
4221 #ifdef JP
4222                         msg_print("¥«¥ó¹â¤¤²»¤¬¶Á¤­ÅϤä¿¡£");
4223 #else
4224                         msg_print("You produce a shrill whistling sound.");
4225 #endif
4226                         aggravate_monsters(0);
4227                 }
4228                 else
4229 #endif
4230                 {
4231                         int pet_ctr, i;
4232                         u16b *who;
4233                         int max_pet = 0;
4234                         u16b dummy_why;
4235
4236                         /* Allocate the "who" array */
4237                         C_MAKE(who, max_m_idx, u16b);
4238
4239                         /* Process the monsters (backwards) */
4240                         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
4241                         {
4242                                 if (is_pet(&m_list[pet_ctr]) && (p_ptr->riding != pet_ctr))
4243                                   who[max_pet++] = pet_ctr;
4244                         }
4245
4246                         /* Select the sort method */
4247                         ang_sort_comp = ang_sort_comp_pet;
4248                         ang_sort_swap = ang_sort_swap_hook;
4249
4250                         ang_sort(who, &dummy_why, max_pet);
4251
4252                         /* Process the monsters (backwards) */
4253                         for (i = 0; i < max_pet; i++)
4254                         {
4255                                 pet_ctr = who[i];
4256                                 teleport_monster_to(pet_ctr, py, px, 100, TELEPORT_PASSIVE);
4257                         }
4258
4259                         /* Free the "who" array */
4260                         C_KILL(who, max_m_idx, u16b);
4261                 }
4262                 o_ptr->timeout = 100+randint1(100);
4263                 return;
4264         }
4265         else if (o_ptr->tval == TV_CAPTURE)
4266         {
4267                 if(!o_ptr->pval)
4268                 {
4269                         bool old_target_pet = target_pet;
4270                         target_pet = TRUE;
4271                         if (!get_aim_dir(&dir))
4272                         {
4273                                 target_pet = old_target_pet;
4274                                 return;
4275                         }
4276                         target_pet = old_target_pet;
4277
4278                         if(fire_ball(GF_CAPTURE, dir, 0, 0))
4279                         {
4280                                 o_ptr->pval = cap_mon;
4281                                 o_ptr->xtra3 = cap_mspeed;
4282                                 o_ptr->xtra4 = cap_hp;
4283                                 o_ptr->xtra5 = cap_maxhp;
4284                                 if (cap_nickname)
4285                                 {
4286                                         cptr t;
4287                                         char *s;
4288                                         char buf[80] = "";
4289
4290                                         if (o_ptr->inscription)
4291                                                 strcpy(buf, quark_str(o_ptr->inscription));
4292                                         s = buf;
4293                                         for (s = buf;*s && (*s != '#'); s++)
4294                                         {
4295 #ifdef JP
4296                                                 if (iskanji(*s)) s++;
4297 #endif
4298                                         }
4299                                         *s = '#';
4300                                         s++;
4301 #ifdef JP
4302  /*nothing*/
4303 #else
4304                                         *s++ = '\'';
4305 #endif
4306                                         t = quark_str(cap_nickname);
4307                                         while (*t)
4308                                         {
4309                                                 *s = *t;
4310                                                 s++;
4311                                                 t++;
4312                                         }
4313 #ifdef JP
4314  /*nothing*/
4315 #else
4316                                         *s++ = '\'';
4317 #endif
4318                                         *s = '\0';
4319                                         o_ptr->inscription = quark_add(buf);
4320                                 }
4321                         }
4322                 }
4323                 else
4324                 {
4325                         bool success = FALSE;
4326                         if (!get_rep_dir2(&dir)) return;
4327                         if (monster_can_enter(py + ddy[dir], px + ddx[dir], &r_info[o_ptr->pval], 0))
4328                         {
4329                                 if (place_monster_aux(0, py + ddy[dir], px + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
4330                                 {
4331                                         if (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
4332                                         if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
4333                                         if (o_ptr->xtra4) m_list[hack_m_idx_ii].hp = o_ptr->xtra4;
4334                                         m_list[hack_m_idx_ii].maxhp = m_list[hack_m_idx_ii].max_maxhp;
4335                                         if (o_ptr->inscription)
4336                                         {
4337                                                 char buf[80];
4338                                                 cptr t;
4339 #ifndef JP
4340                                                 bool quote = FALSE;
4341 #endif
4342
4343                                                 t = quark_str(o_ptr->inscription);
4344                                                 for (t = quark_str(o_ptr->inscription);*t && (*t != '#'); t++)
4345                                                 {
4346 #ifdef JP
4347                                                         if (iskanji(*t)) t++;
4348 #endif
4349                                                 }
4350                                                 if (*t)
4351                                                 {
4352                                                         char *s = buf;
4353                                                         t++;
4354 #ifdef JP
4355                                                         /* nothing */
4356 #else
4357                                                         if (*t =='\'')
4358                                                         {
4359                                                                 t++;
4360                                                                 quote = TRUE;
4361                                                         }
4362 #endif
4363                                                         while(*t)
4364                                                         {
4365                                                                 *s = *t;
4366                                                                 t++;
4367                                                                 s++;
4368                                                         }
4369 #ifdef JP
4370                                                         /* nothing */
4371 #else
4372                                                         if (quote && *(s-1) =='\'')
4373                                                                 s--;
4374 #endif
4375                                                         *s = '\0';
4376                                                         m_list[hack_m_idx_ii].nickname = quark_add(buf);
4377                                                         t = quark_str(o_ptr->inscription);
4378                                                         s = buf;
4379                                                         while(*t && (*t != '#'))
4380                                                         {
4381                                                                 *s = *t;
4382                                                                 t++;
4383                                                                 s++;
4384                                                         }
4385                                                         *s = '\0';
4386                                                         o_ptr->inscription = quark_add(buf);
4387                                                 }
4388                                         }
4389                                         o_ptr->pval = 0;
4390                                         o_ptr->xtra3 = 0;
4391                                         o_ptr->xtra4 = 0;
4392                                         o_ptr->xtra5 = 0;
4393                                         success = TRUE;
4394                                 }
4395                         }
4396                         if (!success)
4397 #ifdef JP
4398                                 msg_print("¤ª¤Ã¤È¡¢²òÊü¤Ë¼ºÇÔ¤·¤¿¡£");
4399 #else
4400                                 msg_print("Oops.  You failed to release your pet.");
4401 #endif
4402                 }
4403                 return;
4404         }
4405
4406         /* Mistake */
4407 #ifdef JP
4408         msg_print("¤ª¤Ã¤È¡¢¤³¤Î¥¢¥¤¥Æ¥à¤Ï»ÏÆ°¤Ç¤­¤Ê¤¤¡£");
4409 #else
4410         msg_print("Oops.  That object cannot be activated.");
4411 #endif
4412
4413 }
4414
4415 /*!
4416  * @brief ÁõÈ÷¤òȯư¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
4417  * @return ¤Ê¤·
4418  */
4419 void do_cmd_activate(void)
4420 {
4421         int     item;
4422         cptr    q, s;
4423
4424
4425         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
4426         {
4427                 set_action(ACTION_NONE);
4428         }
4429
4430         item_tester_no_ryoute = TRUE;
4431         /* Prepare the hook */
4432         item_tester_hook = item_tester_hook_activate;
4433
4434         /* Get an item */
4435 #ifdef JP
4436         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò»ÏÆ°¤µ¤»¤Þ¤¹¤«? ";
4437         s = "»ÏÆ°¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£";
4438 #else
4439         q = "Activate which item? ";
4440         s = "You have nothing to activate.";
4441 #endif
4442
4443         if (!get_item(&item, q, s, (USE_EQUIP))) return;
4444
4445         /* Activate the item */
4446         do_cmd_activate_aux(item);
4447 }
4448
4449
4450 /*!
4451  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤¬´Ê°×»ÈÍÑ¥³¥Þ¥ó¥É¤ÇÍøÍѤǤ­¤ë¤«¤òȽÄꤹ¤ë /
4452  * Hook to determine if an object is useable
4453  * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
4454  * @return ÍøÍѲÄǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
4455  */
4456 static bool item_tester_hook_use(object_type *o_ptr)
4457 {
4458         u32b flgs[TR_FLAG_SIZE];
4459
4460         /* Ammo */
4461         if (o_ptr->tval == p_ptr->tval_ammo)
4462                 return (TRUE);
4463
4464         /* Useable object */
4465         switch (o_ptr->tval)
4466         {
4467                 case TV_SPIKE:
4468                 case TV_STAFF:
4469                 case TV_WAND:
4470                 case TV_ROD:
4471                 case TV_SCROLL:
4472                 case TV_POTION:
4473                 case TV_FOOD:
4474                 {
4475                         return (TRUE);
4476                 }
4477
4478                 default:
4479                 {
4480                         int i;
4481
4482                         /* Not known */
4483                         if (!object_is_known(o_ptr)) return (FALSE);
4484
4485                         /* HACK - only items from the equipment can be activated */
4486                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4487                         {
4488                                 if (&inventory[i] == o_ptr)
4489                                 {
4490                                         /* Extract the flags */
4491                                         object_flags(o_ptr, flgs);
4492
4493                                         /* Check activation flag */
4494                                         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
4495                                 }
4496                         }
4497                 }
4498         }
4499
4500         /* Assume not */
4501         return (FALSE);
4502 }
4503
4504
4505 /*!
4506  * @brief ¥¢¥¤¥Æ¥à¤òÈÆÍÑŪ¤Ë¡Ö»È¤¦¡×¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
4507  * Use an item
4508  * @return ¤Ê¤·
4509  * @details
4510  * XXX - Add actions for other item types
4511  */
4512 void do_cmd_use(void)
4513 {
4514         int         item;
4515         object_type *o_ptr;
4516         cptr        q, s;
4517
4518         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
4519         {
4520                 set_action(ACTION_NONE);
4521         }
4522
4523         item_tester_no_ryoute = TRUE;
4524         /* Prepare the hook */
4525         item_tester_hook = item_tester_hook_use;
4526
4527         /* Get an item */
4528 #ifdef JP
4529 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
4530 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4531 #else
4532         q = "Use which item? ";
4533         s = "You have nothing to use.";
4534 #endif
4535
4536         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
4537
4538         /* Get the item (in the pack) */
4539         if (item >= 0)
4540         {
4541                 o_ptr = &inventory[item];
4542         }
4543         /* Get the item (on the floor) */
4544         else
4545         {
4546                 o_ptr = &o_list[0 - item];
4547         }
4548
4549         switch (o_ptr->tval)
4550         {
4551                 /* Spike a door */
4552                 case TV_SPIKE:
4553                 {
4554                         do_cmd_spike();
4555                         break;
4556                 }
4557
4558                 /* Eat some food */
4559                 case TV_FOOD:
4560                 {
4561                         do_cmd_eat_food_aux(item);
4562                         break;
4563                 }
4564
4565                 /* Aim a wand */
4566                 case TV_WAND:
4567                 {
4568                         do_cmd_aim_wand_aux(item);
4569                         break;
4570                 }
4571
4572                 /* Use a staff */
4573                 case TV_STAFF:
4574                 {
4575                         do_cmd_use_staff_aux(item);
4576                         break;
4577                 }
4578
4579                 /* Zap a rod */
4580                 case TV_ROD:
4581                 {
4582                         do_cmd_zap_rod_aux(item);
4583                         break;
4584                 }
4585
4586                 /* Quaff a potion */
4587                 case TV_POTION:
4588                 {
4589                         do_cmd_quaff_potion_aux(item);
4590                         break;
4591                 }
4592
4593                 /* Read a scroll */
4594                 case TV_SCROLL:
4595                 {
4596                         /* Check some conditions */
4597                         if (p_ptr->blind)
4598                         {
4599 #ifdef JP
4600 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
4601 #else
4602                                 msg_print("You can't see anything.");
4603 #endif
4604
4605                                 return;
4606                         }
4607                         if (no_lite())
4608                         {
4609 #ifdef JP
4610 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
4611 #else
4612                                 msg_print("You have no light to read by.");
4613 #endif
4614
4615                                 return;
4616                         }
4617                         if (p_ptr->confused)
4618                         {
4619 #ifdef JP
4620 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
4621 #else
4622                                 msg_print("You are too confused!");
4623 #endif
4624
4625                                 return;
4626                         }
4627
4628                   do_cmd_read_scroll_aux(item, TRUE);
4629                   break;
4630                 }
4631
4632                 /* Fire ammo */
4633                 case TV_SHOT:
4634                 case TV_ARROW:
4635                 case TV_BOLT:
4636                 {
4637                         do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
4638                         break;
4639                 }
4640
4641                 /* Activate an artifact */
4642                 default:
4643                 {
4644                         do_cmd_activate_aux(item);
4645                         break;
4646                 }
4647         }
4648 }
4649
4650 /*!
4651  * @brief ËâÆ»¶ñ½Ñ»Õ¤Î¼è¤ê¹þ¤ó¤ÀËâÎÏ°ìÍ÷¤«¤éÁªÂò/±ÜÍ÷¤¹¤ë /
4652  * @param only_browse ±ÜÍ÷¤¹¤ë¤À¤±¤Ê¤é¤ÐTRUE
4653  * @return ÁªÂò¤·¤¿ËâÎϤÎID¡¢¥­¥ã¥ó¥»¥ë¤Ê¤é¤Ð-1¤òÊÖ¤¹
4654  */
4655 static int select_magic_eater(bool only_browse)
4656 {
4657         int ext=0;
4658         char choice;
4659         bool flag, request_list;
4660         int tval = 0;
4661         int             ask = TRUE, i = 0;
4662         char            out_val[160];
4663
4664         int menu_line = (use_menu ? 1 : 0);
4665
4666 #ifdef ALLOW_REPEAT
4667         int sn;
4668         if (repeat_pull(&sn))
4669         {
4670                 /* Verify the spell */
4671                 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))
4672                         return sn;
4673                 else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE))
4674                         return sn;
4675         }
4676         
4677 #endif /* ALLOW_REPEAT */
4678
4679         for (i = 0; i < 108; i++)
4680         {
4681                 if (p_ptr->magic_num2[i]) break;
4682         }
4683         if (i == 108)
4684         {
4685 #ifdef JP
4686                 msg_print("ËâË¡¤ò³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
4687 #else
4688                 msg_print("You don't have any magic!");
4689 #endif
4690                 return -1;
4691         }
4692
4693         if (use_menu)
4694         {
4695                 screen_save();
4696
4697                 while(!tval)
4698                 {
4699 #ifdef JP
4700                         prt(format(" %s ¾ó", (menu_line == 1) ? "¡Õ" : "  "), 2, 14);
4701                         prt(format(" %s ËâË¡ËÀ", (menu_line == 2) ? "¡Õ" : "  "), 3, 14);
4702                         prt(format(" %s ¥í¥Ã¥É", (menu_line == 3) ? "¡Õ" : "  "), 4, 14);
4703 #else
4704                         prt(format(" %s staff", (menu_line == 1) ? "> " : "  "), 2, 14);
4705                         prt(format(" %s wand", (menu_line == 2) ? "> " : "  "), 3, 14);
4706                         prt(format(" %s rod", (menu_line == 3) ? "> " : "  "), 4, 14);
4707 #endif
4708
4709                         if (only_browse) prt(_("¤É¤Î¼ïÎà¤ÎËâË¡¤ò¸«¤Þ¤¹¤«¡©", "Which type of magic do you browse?"), 0, 0);
4710                         else prt(_("¤É¤Î¼ïÎà¤ÎËâË¡¤ò»È¤¤¤Þ¤¹¤«¡©", "Which type of magic do you use?"), 0, 0);
4711
4712                         choice = inkey();
4713                         switch(choice)
4714                         {
4715                         case ESCAPE:
4716                         case 'z':
4717                         case 'Z':
4718                                 screen_load();
4719                                 return -1;
4720                         case '2':
4721                         case 'j':
4722                         case 'J':
4723                                 menu_line++;
4724                                 break;
4725                         case '8':
4726                         case 'k':
4727                         case 'K':
4728                                 menu_line+= 2;
4729                                 break;
4730                         case '\r':
4731                         case 'x':
4732                         case 'X':
4733                                 ext = (menu_line-1)*EATER_EXT;
4734                                 if (menu_line == 1) tval = TV_STAFF;
4735                                 else if (menu_line == 2) tval = TV_WAND;
4736                                 else tval = TV_ROD;
4737                                 break;
4738                         }
4739                         if (menu_line > 3) menu_line -= 3;
4740                 }
4741                 screen_load();
4742         }
4743         else
4744         {
4745         while (TRUE)
4746         {
4747 #ifdef JP
4748                 if (!get_com("[A] ¾ó, [B] ËâË¡ËÀ, [C] ¥í¥Ã¥É:", &choice, TRUE))
4749 #else
4750                 if (!get_com("[A] staff, [B] wand, [C] rod:", &choice, TRUE))
4751 #endif
4752                 {
4753                         return -1;
4754                 }
4755                 if (choice == 'A' || choice == 'a')
4756                 {
4757                         ext = 0;
4758                         tval = TV_STAFF;
4759                         break;
4760                 }
4761                 if (choice == 'B' || choice == 'b')
4762                 {
4763                         ext = EATER_EXT;
4764                         tval = TV_WAND;
4765                         break;
4766                 }
4767                 if (choice == 'C' || choice == 'c')
4768                 {
4769                         ext = EATER_EXT*2;
4770                         tval = TV_ROD;
4771                         break;
4772                 }
4773         }
4774         }
4775         for (i = ext; i < ext + EATER_EXT; i++)
4776         {
4777                 if (p_ptr->magic_num2[i])
4778                 {
4779                         if (use_menu) menu_line = i-ext+1;
4780                         break;
4781                 }
4782         }
4783         if (i == ext+EATER_EXT)
4784         {
4785 #ifdef JP
4786                 msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
4787 #else
4788                 msg_print("You don't have that type of magic!");
4789 #endif
4790                 return -1;
4791         }
4792
4793         /* Nothing chosen yet */
4794         flag = FALSE;
4795
4796         /* Build a prompt */
4797         if (only_browse) strnfmt(out_val, 78, _("('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò¸«¤Þ¤¹¤«¡©",
4798                                                                                         "(*=List, ESC=exit) Browse which power? "));
4799         else strnfmt(out_val, 78, _("('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò»È¤¤¤Þ¤¹¤«¡©",
4800                                                                 "(*=List, ESC=exit) Use which power? "));
4801         
4802         /* Save the screen */
4803         screen_save();
4804
4805         request_list = always_show_list;
4806
4807         /* Get a spell from the user */
4808         while (!flag)
4809         {
4810                 /* Show the list */
4811                 if (request_list || use_menu)
4812                 {
4813                         byte y, x = 0;
4814                         int ctr, chance;
4815                         int k_idx;
4816                         char dummy[80];
4817                         int x1, y1, level;
4818                         byte col;
4819
4820                         strcpy(dummy, "");
4821
4822                         for (y = 1; y < 20; y++)
4823                                 prt("", y, x);
4824
4825                         y = 1;
4826
4827                         /* Print header(s) */
4828 #ifdef JP
4829                         prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
4830 #else
4831                         prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
4832 #endif
4833
4834                         /* Print list */
4835                         for (ctr = 0; ctr < EATER_EXT; ctr++)
4836                         {
4837                                 if (!p_ptr->magic_num2[ctr+ext]) continue;
4838
4839                                 k_idx = lookup_kind(tval, ctr);
4840
4841                                 if (use_menu)
4842                                 {
4843                                         if (ctr == (menu_line-1))
4844 #ifdef JP
4845                                                 strcpy(dummy, "¡Õ");
4846 #else
4847                                         strcpy(dummy, "> ");
4848 #endif
4849                                         else strcpy(dummy, "  ");
4850                                                 
4851                                 }
4852                                 /* letter/number for power selection */
4853                                 else
4854                                 {
4855                                         char letter;
4856                                         if (ctr < 26)
4857                                                 letter = I2A(ctr);
4858                                         else
4859                                                 letter = '0' + ctr - 26;
4860                                         sprintf(dummy, "%c)",letter);
4861                                 }
4862                                 x1 = ((ctr < EATER_EXT/2) ? x : x + 40);
4863                                 y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2);
4864                                 level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
4865                                 chance = level * 4 / 5 + 20;
4866                                 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4867                                 level /= 2;
4868                                 if (p_ptr->lev > level)
4869                                 {
4870                                         chance -= 3 * (p_ptr->lev - level);
4871                                 }
4872                                 chance = mod_spell_chance_1(chance);
4873                                 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
4874                                 /* Stunning makes spells harder */
4875                                 if (p_ptr->stun > 50) chance += 25;
4876                                 else if (p_ptr->stun) chance += 15;
4877
4878                                 if (chance > 95) chance = 95;
4879
4880                                 chance = mod_spell_chance_2(chance);
4881
4882                                 col = TERM_WHITE;
4883
4884                                 if (k_idx)
4885                                 {
4886                                         if (tval == TV_ROD)
4887                                         {
4888                                                 strcat(dummy, format(
4889 #ifdef JP
4890                                                                " %-22.22s ½¼Å¶:%2d/%2d%3d%%",
4891 #else
4892                                                                " %-22.22s   (%2d/%2d) %3d%%",
4893 #endif
4894                                                                k_name + k_info[k_idx].name, 
4895                                                                p_ptr->magic_num1[ctr+ext] ? 
4896                                                                (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, 
4897                                                                p_ptr->magic_num2[ctr+ext], chance));
4898                                                 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;
4899                                         }
4900                                         else
4901                                         {
4902                                                 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));
4903                                                 if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED;
4904                                         }
4905                                 }
4906                                 else
4907                                         strcpy(dummy, "");
4908                                 c_prt(col, dummy, y1, x1);
4909                         }
4910                 }
4911
4912                 if (!get_com(out_val, &choice, FALSE)) break;
4913
4914                 if (use_menu && choice != ' ')
4915                 {
4916                         switch (choice)
4917                         {
4918                                 case '0':
4919                                 {
4920                                         screen_load();
4921                                         return 0;
4922                                 }
4923
4924                                 case '8':
4925                                 case 'k':
4926                                 case 'K':
4927                                 {
4928                                         do
4929                                         {
4930                                                 menu_line += EATER_EXT - 1;
4931                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
4932                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
4933                                         break;
4934                                 }
4935
4936                                 case '2':
4937                                 case 'j':
4938                                 case 'J':
4939                                 {
4940                                         do
4941                                         {
4942                                                 menu_line++;
4943                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
4944                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
4945                                         break;
4946                                 }
4947
4948                                 case '4':
4949                                 case 'h':
4950                                 case 'H':
4951                                 case '6':
4952                                 case 'l':
4953                                 case 'L':
4954                                 {
4955                                         bool reverse = FALSE;
4956                                         if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
4957                                         if (menu_line > EATER_EXT/2)
4958                                         {
4959                                                 menu_line -= EATER_EXT/2;
4960                                                 reverse = TRUE;
4961                                         }
4962                                         else menu_line+=EATER_EXT/2;
4963                                         while(!p_ptr->magic_num2[menu_line+ext-1])
4964                                         {
4965                                                 if (reverse)
4966                                                 {
4967                                                         menu_line--;
4968                                                         if (menu_line < 2) reverse = FALSE;
4969                                                 }
4970                                                 else
4971                                                 {
4972                                                         menu_line++;
4973                                                         if (menu_line > EATER_EXT-1) reverse = TRUE;
4974                                                 }
4975                                         }
4976                                         break;
4977                                 }
4978
4979                                 case 'x':
4980                                 case 'X':
4981                                 case '\r':
4982                                 {
4983                                         i = menu_line - 1;
4984                                         ask = FALSE;
4985                                         break;
4986                                 }
4987                         }
4988                 }
4989
4990                 /* Request redraw */
4991                 if (use_menu && ask) continue;
4992
4993                 /* Request redraw */
4994                 if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?')))
4995                 {
4996                         /* Hide the list */
4997                         if (request_list)
4998                         {
4999                                 /* Hide list */
5000                                 request_list = FALSE;
5001                                 
5002                                 /* Restore the screen */
5003                                 screen_load();
5004                                 screen_save();
5005                         }
5006                         else
5007                                 request_list = TRUE;
5008
5009                         /* Redo asking */
5010                         continue;
5011                 }
5012
5013                 if (!use_menu)
5014                 {
5015                         if (isalpha(choice))
5016                         {
5017                                 /* Note verify */
5018                                 ask = (isupper(choice));
5019
5020                                 /* Lowercase */
5021                                 if (ask) choice = tolower(choice);
5022
5023                                 /* Extract request */
5024                                 i = (islower(choice) ? A2I(choice) : -1);
5025                         }
5026                         else
5027                         {
5028                                 ask = FALSE; /* Can't uppercase digits */
5029
5030                                 i = choice - '0' + 26;
5031                         }
5032                 }
5033
5034                 /* Totally Illegal */
5035                 if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext])
5036                 {
5037                         bell();
5038                         continue;
5039                 }
5040
5041                 if (!only_browse)
5042                 {
5043                         /* Verify it */
5044                         if (ask)
5045                         {
5046                                 char tmp_val[160];
5047
5048                                 /* Prompt */
5049 #ifdef JP
5050                                 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", k_name + k_info[lookup_kind(tval ,i)].name);
5051 #else
5052                                 (void) strnfmt(tmp_val, 78, "Use %s?", k_name + k_info[lookup_kind(tval ,i)].name);
5053 #endif
5054
5055                                 /* Belay that order */
5056                                 if (!get_check(tmp_val)) continue;
5057                         }
5058                         if (tval == TV_ROD)
5059                         {
5060                                 if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE)
5061                                 {
5062 #ifdef JP
5063                                         msg_print("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
5064 #else
5065                                         msg_print("The magic are still charging.");
5066 #endif
5067                                         msg_print(NULL);
5068                                         if (use_menu) ask = TRUE;
5069                                         continue;
5070                                 }
5071                         }
5072                         else
5073                         {
5074                                 if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
5075                                 {
5076 #ifdef JP
5077                                         msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
5078 #else
5079                                         msg_print("The magic has no charges left.");
5080 #endif
5081                                         msg_print(NULL);
5082                                         if (use_menu) ask = TRUE;
5083                                         continue;
5084                                 }
5085                         }
5086                 }
5087
5088                 /* Browse */
5089                 else
5090                 {
5091                         int line, j;
5092                         char temp[70 * 20];
5093
5094                         /* Clear lines, position cursor  (really should use strlen here) */
5095                         Term_erase(7, 23, 255);
5096                         Term_erase(7, 22, 255);
5097                         Term_erase(7, 21, 255);
5098                         Term_erase(7, 20, 255);
5099
5100                         roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp, sizeof(temp));
5101                         for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j]))
5102                         {
5103                                 prt(&temp[j], line, 10);
5104                                 line++;
5105                         }
5106
5107                         continue;
5108                 }
5109
5110                 /* Stop the loop */
5111                 flag = TRUE;
5112         }
5113
5114         /* Restore the screen */
5115         screen_load();
5116
5117         if (!flag) return -1;
5118
5119 #ifdef ALLOW_REPEAT
5120         repeat_push(ext+i);
5121 #endif /* ALLOW_REPEAT */
5122         return ext+i;
5123 }
5124
5125
5126 /*!
5127  * @brief ¼è¤ê¹þ¤ó¤ÀËâÎϤòÍøÍѤ¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
5128  * Use eaten rod, wand or staff
5129  * @param only_browse ±ÜÍ÷¤¹¤ë¤À¤±¤Ê¤é¤ÐTRUE
5130  * @param powerful ¶¯ÎÏȯưÃæ¤Î½èÍý¤Ê¤é¤ÐTRUE
5131  * @return ¼ÂºÝ¤Ë¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
5132  */
5133 bool do_cmd_magic_eater(bool only_browse, bool powerful)
5134 {
5135         int item, chance, level, k_idx, tval, sval;
5136         bool use_charge = TRUE;
5137
5138         /* Not when confused */
5139         if (!only_browse && p_ptr->confused)
5140         {
5141 #ifdef JP
5142 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
5143 #else
5144                 msg_print("You are too confused!");
5145 #endif
5146
5147                 return FALSE;
5148         }
5149
5150         item = select_magic_eater(only_browse);
5151         if (item == -1)
5152         {
5153                 energy_use = 0;
5154                 return FALSE;
5155         }
5156         if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
5157         else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
5158         else {tval = TV_STAFF;sval = item;}
5159         k_idx = lookup_kind(tval, sval);
5160
5161         level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
5162         chance = level * 4 / 5 + 20;
5163         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
5164         level /= 2;
5165         if (p_ptr->lev > level)
5166         {
5167                 chance -= 3 * (p_ptr->lev - level);
5168         }
5169         chance = mod_spell_chance_1(chance);
5170         chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
5171         /* Stunning makes spells harder */
5172         if (p_ptr->stun > 50) chance += 25;
5173         else if (p_ptr->stun) chance += 15;
5174
5175         if (chance > 95) chance = 95;
5176
5177         chance = mod_spell_chance_2(chance);
5178
5179         if (randint0(100) < chance)
5180         {
5181                 if (flush_failure) flush();
5182
5183 #ifdef JP
5184 msg_print("¼öʸ¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª");
5185 #else
5186                 msg_format("You failed to get the magic off!");
5187 #endif
5188
5189                 sound(SOUND_FAIL);
5190                 if (randint1(100) >= chance)
5191                         chg_virtue(V_CHANCE,-1);
5192                 energy_use = 100;
5193
5194                 return TRUE;
5195         }
5196         else
5197         {
5198                 int dir = 0;
5199
5200                 if (tval == TV_ROD)
5201                 {
5202                         if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
5203                                 if (!get_aim_dir(&dir)) return FALSE;
5204                         rod_effect(sval, dir, &use_charge, powerful, TRUE);
5205                         if (!use_charge) return FALSE;
5206                 }
5207                 else if (tval == TV_WAND)
5208                 {
5209                         if (!get_aim_dir(&dir)) return FALSE;
5210                         wand_effect(sval, dir, powerful, TRUE);
5211                 }
5212                 else
5213                 {
5214                         staff_effect(sval, &use_charge, powerful, TRUE, TRUE);
5215                         if (!use_charge) return FALSE;
5216                 }
5217                 if (randint1(100) < chance)
5218                         chg_virtue(V_CHANCE,1);
5219         }
5220         energy_use = 100;
5221         if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
5222         else p_ptr->magic_num1[item] -= EATER_CHARGE;
5223
5224         return TRUE;
5225 }