OSDN Git Service

Add Doxygen comment to cmd6.c.
[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_life && (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  * @return ¤Ê¤·
1595  * @details
1596  * <pre>
1597  * Certain scrolls can be "aborted" without losing the scroll.  These
1598  * include scrolls with no effects but recharge or identify, which are
1599  * cancelled before use.  XXX Reading them still takes a turn, though.
1600  * </pre>
1601  */
1602 static void do_cmd_read_scroll_aux(int item, bool known)
1603 {
1604         int         k, used_up, ident, lev;
1605         object_type *o_ptr;
1606
1607
1608         /* Get the item (in the pack) */
1609         if (item >= 0)
1610         {
1611                 o_ptr = &inventory[item];
1612         }
1613
1614         /* Get the item (on the floor) */
1615         else
1616         {
1617                 o_ptr = &o_list[0 - item];
1618         }
1619
1620
1621         /* Take a turn */
1622         energy_use = 100;
1623
1624         if (world_player)
1625         {
1626                 if (flush_failure) flush();
1627 #ifdef JP
1628                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
1629 #else
1630                 msg_print("Nothing happen.");
1631 #endif
1632
1633                 sound(SOUND_FAIL);
1634                 return;
1635         }
1636
1637         if (p_ptr->pclass == CLASS_BERSERKER)
1638         {
1639 #ifdef JP
1640                 msg_print("´¬Êª¤Ê¤ó¤ÆÆɤá¤Ê¤¤¡£");
1641 #else
1642                 msg_print("You cannot read.");
1643 #endif
1644                 return;
1645         }
1646
1647         if (music_singing_any()) stop_singing();
1648
1649         /* Hex */
1650         if (hex_spelling_any() && ((p_ptr->lev < 35) || hex_spell_fully())) stop_hex_spell_all();
1651
1652         /* Not identified yet */
1653         ident = FALSE;
1654
1655         /* Object level */
1656         lev = k_info[o_ptr->k_idx].level;
1657
1658         /* Assume the scroll will get used up */
1659         used_up = TRUE;
1660
1661         if (o_ptr->tval == TV_SCROLL)
1662         {
1663         /* Analyze the scroll */
1664         switch (o_ptr->sval)
1665         {
1666                 case SV_SCROLL_DARKNESS:
1667                 {
1668                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
1669                         {
1670                                 (void)set_blind(p_ptr->blind + 3 + randint1(5));
1671                         }
1672                         if (unlite_area(10, 3)) ident = TRUE;
1673                         break;
1674                 }
1675
1676                 case SV_SCROLL_AGGRAVATE_MONSTER:
1677                 {
1678 #ifdef JP
1679                         msg_print("¥«¥ó¹â¤¯¤¦¤Ê¤ëÍͤʲ»¤¬ÊÕ¤ê¤òʤ¤Ã¤¿¡£");
1680 #else
1681                         msg_print("There is a high pitched humming noise.");
1682 #endif
1683
1684                         aggravate_monsters(0);
1685                         ident = TRUE;
1686                         break;
1687                 }
1688
1689                 case SV_SCROLL_CURSE_ARMOR:
1690                 {
1691                         if (curse_armor()) ident = TRUE;
1692                         break;
1693                 }
1694
1695                 case SV_SCROLL_CURSE_WEAPON:
1696                 {
1697                         k = 0;
1698                         if (buki_motteruka(INVEN_RARM))
1699                         {
1700                                 k = INVEN_RARM;
1701                                 if (buki_motteruka(INVEN_LARM) && one_in_(2)) k = INVEN_LARM;
1702                         }
1703                         else if (buki_motteruka(INVEN_LARM)) k = INVEN_LARM;
1704                         if (k && curse_weapon(FALSE, k)) ident = TRUE;
1705                         break;
1706                 }
1707
1708                 case SV_SCROLL_SUMMON_MONSTER:
1709                 {
1710                         for (k = 0; k < randint1(3); k++)
1711                         {
1712                                 if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
1713                                 {
1714                                         ident = TRUE;
1715                                 }
1716                         }
1717                         break;
1718                 }
1719
1720                 case SV_SCROLL_SUMMON_UNDEAD:
1721                 {
1722                         for (k = 0; k < randint1(3); k++)
1723                         {
1724                                 if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
1725                                 {
1726                                         ident = TRUE;
1727                                 }
1728                         }
1729                         break;
1730                 }
1731
1732                 case SV_SCROLL_SUMMON_PET:
1733                 {
1734                         if (summon_specific(-1, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
1735                         {
1736                                 ident = TRUE;
1737                         }
1738                         break;
1739                 }
1740
1741                 case SV_SCROLL_SUMMON_KIN:
1742                 {
1743                         if (summon_kin_player(p_ptr->lev, py, px, (PM_FORCE_PET | PM_ALLOW_GROUP)))
1744                         {
1745                                 ident = TRUE;
1746                         }
1747                         break;
1748                 }
1749
1750                 case SV_SCROLL_TRAP_CREATION:
1751                 {
1752                         if (trap_creation(py, px)) ident = TRUE;
1753                         break;
1754                 }
1755
1756                 case SV_SCROLL_PHASE_DOOR:
1757                 {
1758                         teleport_player(10, 0L);
1759                         ident = TRUE;
1760                         break;
1761                 }
1762
1763                 case SV_SCROLL_TELEPORT:
1764                 {
1765                         teleport_player(100, 0L);
1766                         ident = TRUE;
1767                         break;
1768                 }
1769
1770                 case SV_SCROLL_TELEPORT_LEVEL:
1771                 {
1772                         (void)teleport_level(0);
1773                         ident = TRUE;
1774                         break;
1775                 }
1776
1777                 case SV_SCROLL_WORD_OF_RECALL:
1778                 {
1779                         if (!word_of_recall()) used_up = FALSE;
1780                         ident = TRUE;
1781                         break;
1782                 }
1783
1784                 case SV_SCROLL_IDENTIFY:
1785                 {
1786                         if (!ident_spell(FALSE)) used_up = FALSE;
1787                         ident = TRUE;
1788                         break;
1789                 }
1790
1791                 case SV_SCROLL_STAR_IDENTIFY:
1792                 {
1793                         if (!identify_fully(FALSE)) used_up = FALSE;
1794                         ident = TRUE;
1795                         break;
1796                 }
1797
1798                 case SV_SCROLL_REMOVE_CURSE:
1799                 {
1800                         if (remove_curse())
1801                         {
1802 #ifdef JP
1803                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1804 #else
1805                                 msg_print("You feel as if someone is watching over you.");
1806 #endif
1807
1808                                 ident = TRUE;
1809                         }
1810                         break;
1811                 }
1812
1813                 case SV_SCROLL_STAR_REMOVE_CURSE:
1814                 {
1815                         if (remove_all_curse())
1816                         {
1817 #ifdef JP
1818                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1819 #else
1820                                 msg_print("You feel as if someone is watching over you.");
1821 #endif
1822                         }
1823                         ident = TRUE;
1824                         break;
1825                 }
1826
1827                 case SV_SCROLL_ENCHANT_ARMOR:
1828                 {
1829                         ident = TRUE;
1830                         if (!enchant_spell(0, 0, 1)) used_up = FALSE;
1831                         break;
1832                 }
1833
1834                 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
1835                 {
1836                         if (!enchant_spell(1, 0, 0)) used_up = FALSE;
1837                         ident = TRUE;
1838                         break;
1839                 }
1840
1841                 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
1842                 {
1843                         if (!enchant_spell(0, 1, 0)) used_up = FALSE;
1844                         ident = TRUE;
1845                         break;
1846                 }
1847
1848                 case SV_SCROLL_STAR_ENCHANT_ARMOR:
1849                 {
1850                         if (!enchant_spell(0, 0, randint1(3) + 2)) used_up = FALSE;
1851                         ident = TRUE;
1852                         break;
1853                 }
1854
1855                 case SV_SCROLL_STAR_ENCHANT_WEAPON:
1856                 {
1857                         if (!enchant_spell(randint1(3), randint1(3), 0)) used_up = FALSE;
1858                         ident = TRUE;
1859                         break;
1860                 }
1861
1862                 case SV_SCROLL_RECHARGING:
1863                 {
1864                         if (!recharge(130)) used_up = FALSE;
1865                         ident = TRUE;
1866                         break;
1867                 }
1868
1869                 case SV_SCROLL_MUNDANITY:
1870                 {
1871                         ident = TRUE;
1872                         if (!mundane_spell(FALSE)) used_up = FALSE;
1873                         break;
1874                 }
1875
1876                 case SV_SCROLL_LIGHT:
1877                 {
1878                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
1879                         break;
1880                 }
1881
1882                 case SV_SCROLL_MAPPING:
1883                 {
1884                         map_area(DETECT_RAD_MAP);
1885                         ident = TRUE;
1886                         break;
1887                 }
1888
1889                 case SV_SCROLL_DETECT_GOLD:
1890                 {
1891                         if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
1892                         if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
1893                         break;
1894                 }
1895
1896                 case SV_SCROLL_DETECT_ITEM:
1897                 {
1898                         if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
1899                         break;
1900                 }
1901
1902                 case SV_SCROLL_DETECT_TRAP:
1903                 {
1904                         if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
1905                         break;
1906                 }
1907
1908                 case SV_SCROLL_DETECT_DOOR:
1909                 {
1910                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
1911                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
1912                         break;
1913                 }
1914
1915                 case SV_SCROLL_DETECT_INVIS:
1916                 {
1917                         if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
1918                         break;
1919                 }
1920
1921                 case SV_SCROLL_SATISFY_HUNGER:
1922                 {
1923                         if (set_food(PY_FOOD_MAX - 1)) ident = TRUE;
1924                         break;
1925                 }
1926
1927                 case SV_SCROLL_BLESSING:
1928                 {
1929                         if (set_blessed(p_ptr->blessed + randint1(12) + 6, FALSE)) ident = TRUE;
1930                         break;
1931                 }
1932
1933                 case SV_SCROLL_HOLY_CHANT:
1934                 {
1935                         if (set_blessed(p_ptr->blessed + randint1(24) + 12, FALSE)) ident = TRUE;
1936                         break;
1937                 }
1938
1939                 case SV_SCROLL_HOLY_PRAYER:
1940                 {
1941                         if (set_blessed(p_ptr->blessed + randint1(48) + 24, FALSE)) ident = TRUE;
1942                         break;
1943                 }
1944
1945                 case SV_SCROLL_MONSTER_CONFUSION:
1946                 {
1947                         if (!(p_ptr->special_attack & ATTACK_CONFUSE))
1948                         {
1949 #ifdef JP
1950                                 msg_print("¼ê¤¬µ±¤­»Ï¤á¤¿¡£");
1951 #else
1952                                 msg_print("Your hands begin to glow.");
1953 #endif
1954
1955                                 p_ptr->special_attack |= ATTACK_CONFUSE;
1956                                 p_ptr->redraw |= (PR_STATUS);
1957                                 ident = TRUE;
1958                         }
1959                         break;
1960                 }
1961
1962                 case SV_SCROLL_PROTECTION_FROM_EVIL:
1963                 {
1964                         k = 3 * p_ptr->lev;
1965                         if (set_protevil(p_ptr->protevil + randint1(25) + k, FALSE)) ident = TRUE;
1966                         break;
1967                 }
1968
1969                 case SV_SCROLL_RUNE_OF_PROTECTION:
1970                 {
1971                         warding_glyph();
1972                         ident = TRUE;
1973                         break;
1974                 }
1975
1976                 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
1977                 {
1978                         if (destroy_doors_touch()) ident = TRUE;
1979                         break;
1980                 }
1981
1982                 case SV_SCROLL_STAR_DESTRUCTION:
1983                 {
1984                         if (destroy_area(py, px, 13 + randint0(5), FALSE))
1985                                 ident = TRUE;
1986                         else
1987 #ifdef JP
1988 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿...");
1989 #else
1990                                 msg_print("The dungeon trembles...");
1991 #endif
1992
1993
1994                         break;
1995                 }
1996
1997                 case SV_SCROLL_DISPEL_UNDEAD:
1998                 {
1999                         if (dispel_undead(80)) ident = TRUE;
2000                         break;
2001                 }
2002
2003                 case SV_SCROLL_SPELL:
2004                 {
2005                         if ((p_ptr->pclass == CLASS_WARRIOR) ||
2006                                 (p_ptr->pclass == CLASS_IMITATOR) ||
2007                                 (p_ptr->pclass == CLASS_MINDCRAFTER) ||
2008                                 (p_ptr->pclass == CLASS_SORCERER) ||
2009                                 (p_ptr->pclass == CLASS_ARCHER) ||
2010                                 (p_ptr->pclass == CLASS_MAGIC_EATER) ||
2011                                 (p_ptr->pclass == CLASS_RED_MAGE) ||
2012                                 (p_ptr->pclass == CLASS_SAMURAI) ||
2013                                 (p_ptr->pclass == CLASS_BLUE_MAGE) ||
2014                                 (p_ptr->pclass == CLASS_CAVALRY) ||
2015                                 (p_ptr->pclass == CLASS_BERSERKER) ||
2016                                 (p_ptr->pclass == CLASS_SMITH) ||
2017                                 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2018                                 (p_ptr->pclass == CLASS_NINJA) ||
2019                                 (p_ptr->pclass == CLASS_SNIPER)) break;
2020                         p_ptr->add_spells++;
2021                         p_ptr->update |= (PU_SPELLS);
2022                         ident = TRUE;
2023                         break;
2024                 }
2025
2026                 case SV_SCROLL_GENOCIDE:
2027                 {
2028                         (void)symbol_genocide(300, TRUE);
2029                         ident = TRUE;
2030                         break;
2031                 }
2032
2033                 case SV_SCROLL_MASS_GENOCIDE:
2034                 {
2035                         (void)mass_genocide(300, TRUE);
2036                         ident = TRUE;
2037                         break;
2038                 }
2039
2040                 case SV_SCROLL_ACQUIREMENT:
2041                 {
2042                         acquirement(py, px, 1, TRUE, FALSE, FALSE);
2043                         ident = TRUE;
2044                         break;
2045                 }
2046
2047                 case SV_SCROLL_STAR_ACQUIREMENT:
2048                 {
2049                         acquirement(py, px, randint1(2) + 1, TRUE, FALSE, FALSE);
2050                         ident = TRUE;
2051                         break;
2052                 }
2053
2054                 /* New Hengband scrolls */
2055                 case SV_SCROLL_FIRE:
2056                 {
2057                         fire_ball(GF_FIRE, 0, 666, 4);
2058                         /* Note: "Double" damage since it is centered on the player ... */
2059                         if (!(IS_OPPOSE_FIRE() || p_ptr->resist_fire || p_ptr->immune_fire))
2060 #ifdef JP
2061 take_hit(DAMAGE_NOESCAPE, 50+randint1(50), "±ê¤Î´¬Êª", -1);
2062 #else
2063                                 take_hit(DAMAGE_NOESCAPE, 50 + randint1(50), "a Scroll of Fire", -1);
2064 #endif
2065
2066                         ident = TRUE;
2067                         break;
2068                 }
2069
2070
2071                 case SV_SCROLL_ICE:
2072                 {
2073                         fire_ball(GF_ICE, 0, 777, 4);
2074                         if (!(IS_OPPOSE_COLD() || p_ptr->resist_cold || p_ptr->immune_cold))
2075 #ifdef JP
2076 take_hit(DAMAGE_NOESCAPE, 100+randint1(100), "ɹ¤Î´¬Êª", -1);
2077 #else
2078                                 take_hit(DAMAGE_NOESCAPE, 100 + randint1(100), "a Scroll of Ice", -1);
2079 #endif
2080
2081                         ident = TRUE;
2082                         break;
2083                 }
2084
2085                 case SV_SCROLL_CHAOS:
2086                 {
2087                         fire_ball(GF_CHAOS, 0, 1000, 4);
2088                         if (!p_ptr->resist_chaos)
2089 #ifdef JP
2090 take_hit(DAMAGE_NOESCAPE, 111+randint1(111), "¥í¥°¥ë¥¹¤Î´¬Êª", -1);
2091 #else
2092                                 take_hit(DAMAGE_NOESCAPE, 111 + randint1(111), "a Scroll of Logrus", -1);
2093 #endif
2094
2095                         ident = TRUE;
2096                         break;
2097                 }
2098
2099                 case SV_SCROLL_RUMOR:
2100                 {
2101 #ifdef JP
2102                         msg_print("´¬Êª¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¤¬½ñ¤«¤ì¤Æ¤¤¤ë:");
2103 #else
2104                         msg_print("There is message on the scroll. It says:");
2105 #endif
2106
2107                         msg_print(NULL);
2108                         display_rumor(TRUE);
2109                         msg_print(NULL);
2110 #ifdef JP
2111                         msg_print("´¬Êª¤Ï±ì¤òΩ¤Æ¤Æ¾Ã¤¨µî¤Ã¤¿¡ª");
2112 #else
2113                         msg_print("The scroll disappears in a puff of smoke!");
2114 #endif
2115
2116                         ident = TRUE;
2117                         break;
2118                 }
2119
2120                 case SV_SCROLL_ARTIFACT:
2121                 {
2122                         ident = TRUE;
2123                         if (!artifact_scroll()) used_up = FALSE;
2124                         break;
2125                 }
2126
2127                 case SV_SCROLL_RESET_RECALL:
2128                 {
2129                         ident = TRUE;
2130                         if (!reset_recall()) used_up = FALSE;
2131                         break;
2132                 }
2133
2134                 case SV_SCROLL_AMUSEMENT:
2135                 {
2136                         ident = TRUE;
2137                         amusement(py, px, 1, FALSE);
2138                         break;
2139                 }
2140
2141                 case SV_SCROLL_STAR_AMUSEMENT:
2142                 {
2143                         ident = TRUE;
2144                         amusement(py, px,  randint1(2) + 1, FALSE);
2145                         break;
2146                 }
2147         }
2148         }
2149         else if (o_ptr->name1 == ART_GHB)
2150         {
2151 #ifdef JP
2152                 msg_print("»ä¤Ï¶ìÏ«¤·¤Æ¡Ø¥°¥ì¡¼¥¿¡¼¡¦¥Ø¥ë=¥Ó¡¼¥¹¥È¡Ù¤òÅݤ·¤¿¡£");
2153                 msg_print("¤·¤«¤·¼ê¤ËÆþ¤Ã¤¿¤Î¤Ï¤³¤Î¤­¤¿¤Ê¤¤£Ô¥·¥ã¥Ä¤À¤±¤À¤Ã¤¿¡£");
2154 #else
2155                 msg_print("I had a very hard time to kill the Greater hell-beast, ");
2156                 msg_print("but all I got was this lousy t-shirt!");
2157 #endif
2158                 used_up = FALSE;
2159         }
2160         else if (o_ptr->name1 == ART_POWER)
2161         {
2162 #ifdef JP
2163                 msg_print("¡Ö°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÅý¤Ù¡¢");
2164                 msg_print(NULL);
2165                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤ò¸«¤Ä¤±¡¢");
2166                 msg_print(NULL);
2167                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÊá¤é¤¨¤Æ");
2168                 msg_print(NULL);
2169                 msg_print("°Å°Ç¤ÎÃæ¤Ë·Ò¤®¤È¤á¤ë¡£¡×");
2170 #else
2171                 msg_print("'One Ring to rule them all, ");
2172                 msg_print(NULL);
2173                 msg_print("One Ring to find them, ");
2174                 msg_print(NULL);
2175                 msg_print("One Ring to bring them all ");
2176                 msg_print(NULL);
2177                 msg_print("and in the darkness bind them.'");
2178 #endif
2179                 used_up = FALSE;
2180         }
2181         else if (o_ptr->tval==TV_PARCHMENT)
2182         {
2183                 cptr q;
2184                 char o_name[MAX_NLEN];
2185                 char buf[1024];
2186
2187                 /* Save screen */
2188                 screen_save();
2189
2190                 q=format("book-%d_jp.txt",o_ptr->sval);
2191
2192                 /* Display object description */
2193                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2194
2195                 /* Build the filename */
2196                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
2197
2198                 /* Peruse the help file */
2199                 (void)show_file(TRUE, buf, o_name, 0, 0);
2200
2201                 /* Load screen */
2202                 screen_load();
2203
2204                 used_up=FALSE;
2205         }
2206
2207
2208         /* Combine / Reorder the pack (later) */
2209         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2210
2211         if (!(object_is_aware(o_ptr)))
2212         {
2213                 chg_virtue(V_PATIENCE, -1);
2214                 chg_virtue(V_CHANCE, 1);
2215                 chg_virtue(V_KNOWLEDGE, -1);
2216         }
2217
2218         /* The item was tried */
2219         object_tried(o_ptr);
2220
2221         /* An identification was made */
2222         if (ident && !object_is_aware(o_ptr))
2223         {
2224                 object_aware(o_ptr);
2225                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2226         }
2227
2228         /* Window stuff */
2229         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2230
2231
2232         /* Hack -- allow certain scrolls to be "preserved" */
2233         if (!used_up)
2234         {
2235                 return;
2236         }
2237
2238         sound(SOUND_SCROLL);
2239
2240         /* Destroy a scroll in the pack */
2241         if (item >= 0)
2242         {
2243                 inven_item_increase(item, -1);
2244                 inven_item_describe(item);
2245                 inven_item_optimize(item);
2246         }
2247
2248         /* Destroy a scroll on the floor */
2249         else
2250         {
2251                 floor_item_increase(0 - item, -1);
2252                 floor_item_describe(0 - item);
2253                 floor_item_optimize(0 - item);
2254         }
2255 }
2256
2257 /*!
2258  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤¬Æɤळ¤È¤¬¤Ç¤­¤ë¤«¤òȽÄꤹ¤ë /
2259  * Hook to determine if an object is readable
2260  * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2261  * @return Æɤळ¤È¤¬²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
2262  */
2263 static bool item_tester_hook_readable(object_type *o_ptr)
2264 {
2265         if ((o_ptr->tval==TV_SCROLL) || (o_ptr->tval==TV_PARCHMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER)) return (TRUE);
2266
2267         /* Assume not */
2268         return (FALSE);
2269 }
2270
2271 /*!
2272  * @brief Æɤॳ¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2273  * Eat some food (from the pack or floor)
2274  * @return ¤Ê¤·
2275  */
2276 void do_cmd_read_scroll(void)
2277 {
2278         object_type *o_ptr;
2279         int  item;
2280         cptr q, s;
2281
2282         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2283         {
2284                 set_action(ACTION_NONE);
2285         }
2286
2287         /* Check some conditions */
2288         if (p_ptr->blind)
2289         {
2290 #ifdef JP
2291                 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
2292 #else
2293                 msg_print("You can't see anything.");
2294 #endif
2295
2296                 return;
2297         }
2298         if (no_lite())
2299         {
2300 #ifdef JP
2301                 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
2302 #else
2303                 msg_print("You have no light to read by.");
2304 #endif
2305
2306                 return;
2307         }
2308         if (p_ptr->confused)
2309         {
2310 #ifdef JP
2311                 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡£");
2312 #else
2313                 msg_print("You are too confused!");
2314 #endif
2315
2316                 return;
2317         }
2318
2319
2320         /* Restrict choices to scrolls */
2321         item_tester_hook = item_tester_hook_readable;
2322
2323         /* Get an item */
2324 #ifdef JP
2325         q = "¤É¤Î´¬Êª¤òÆɤߤޤ¹¤«? ";
2326         s = "Æɤá¤ë´¬Êª¤¬¤Ê¤¤¡£";
2327 #else
2328         q = "Read which scroll? ";
2329         s = "You have no scrolls to read.";
2330 #endif
2331
2332         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2333
2334         /* Get the item (in the pack) */
2335         if (item >= 0)
2336         {
2337                 o_ptr = &inventory[item];
2338         }
2339
2340         /* Get the item (on the floor) */
2341         else
2342         {
2343                 o_ptr = &o_list[0 - item];
2344         }
2345
2346         /* Read the scroll */
2347         do_cmd_read_scroll_aux(item, object_is_aware(o_ptr));
2348 }
2349
2350 /*!
2351  * @brief ¾ó¤Î¸ú²Ì¤òȯư¤¹¤ë
2352  * @param sval ¥ª¥Ö¥¸¥§¥¯¥È¤Îsval
2353  * @param use_charge »ÈÍѲó¿ô¤ò¾ÃÈñ¤·¤¿¤«¤É¤¦¤«¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
2354  * @param powerful ¶¯ÎÏȯư¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2355  * @param magic ËâÆ»¶ñ½Ñ¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2356  * @param known È½ÌÀºÑ¤Ê¤é¤ÐTRUE
2357  * @return È¯Æ°¤Ë¤è¤ê¸ú²ÌÆâÍƤ¬³ÎÄꤷ¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
2358  */
2359 static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, bool known)
2360 {
2361         int k;
2362         int ident = FALSE;
2363         int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
2364         int detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
2365
2366         /* Analyze the staff */
2367         switch (sval)
2368         {
2369                 case SV_STAFF_DARKNESS:
2370                 {
2371                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
2372                         {
2373                                 if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
2374                         }
2375                         if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
2376                         break;
2377                 }
2378
2379                 case SV_STAFF_SLOWNESS:
2380                 {
2381                         if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
2382                         break;
2383                 }
2384
2385                 case SV_STAFF_HASTE_MONSTERS:
2386                 {
2387                         if (speed_monsters()) ident = TRUE;
2388                         break;
2389                 }
2390
2391                 case SV_STAFF_SUMMONING:
2392                 {
2393                         const int times = randint1(powerful ? 8 : 4);
2394                         for (k = 0; k < times; k++)
2395                         {
2396                                 if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2397                                 {
2398                                         ident = TRUE;
2399                                 }
2400                         }
2401                         break;
2402                 }
2403
2404                 case SV_STAFF_TELEPORTATION:
2405                 {
2406                         teleport_player((powerful ? 150 : 100), 0L);
2407                         ident = TRUE;
2408                         break;
2409                 }
2410
2411                 case SV_STAFF_IDENTIFY:
2412                 {
2413                         if (powerful) {
2414                                 if (!identify_fully(FALSE)) *use_charge = FALSE;
2415                         } else {
2416                                 if (!ident_spell(FALSE)) *use_charge = FALSE;
2417                         }
2418                         ident = TRUE;
2419                         break;
2420                 }
2421
2422                 case SV_STAFF_REMOVE_CURSE:
2423                 {
2424                         bool result = powerful ? remove_all_curse() : remove_curse();
2425                         if (result)
2426                         {
2427                                 if (magic)
2428                                 {
2429 #ifdef JP
2430                                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
2431 #else
2432                                         msg_print("You feel as if someone is watching over you.");
2433 #endif
2434                                 }
2435                                 else if (!p_ptr->blind)
2436                                 {
2437 #ifdef JP
2438                                         msg_print("¾ó¤Ï°ì½Ö¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
2439 #else
2440                                         msg_print("The staff glows blue for a moment...");
2441 #endif
2442
2443                                 }
2444                                 ident = TRUE;
2445                         }
2446                         break;
2447                 }
2448
2449                 case SV_STAFF_STARLITE:
2450                 {
2451                         int num = damroll(5, 3);
2452                         int y, x;
2453                         int attempts;
2454
2455                         if (!p_ptr->blind && !magic)
2456                         {
2457 #ifdef JP
2458                                 msg_print("¾ó¤ÎÀ褬ÌÀ¤ë¤¯µ±¤¤¤¿...");
2459 #else
2460                                 msg_print("The end of the staff glows brightly...");
2461 #endif
2462
2463                         }
2464                         for (k = 0; k < num; k++)
2465                         {
2466                                 attempts = 1000;
2467
2468                                 while (attempts--)
2469                                 {
2470                                         scatter(&y, &x, py, px, 4, 0);
2471
2472                                         if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
2473
2474                                         if (!player_bold(y, x)) break;
2475                                 }
2476
2477                                 project(0, 0, y, x, damroll(6 + lev / 8, 10), GF_LITE_WEAK,
2478                                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1);
2479                         }
2480                         ident = TRUE;
2481                         break;
2482                 }
2483
2484                 case SV_STAFF_LITE:
2485                 {
2486                         if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
2487                         break;
2488                 }
2489
2490                 case SV_STAFF_MAPPING:
2491                 {
2492                         map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
2493                         ident = TRUE;
2494                         break;
2495                 }
2496
2497                 case SV_STAFF_DETECT_GOLD:
2498                 {
2499                         if (detect_treasure(detect_rad)) ident = TRUE;
2500                         if (detect_objects_gold(detect_rad)) ident = TRUE;
2501                         break;
2502                 }
2503
2504                 case SV_STAFF_DETECT_ITEM:
2505                 {
2506                         if (detect_objects_normal(detect_rad)) ident = TRUE;
2507                         break;
2508                 }
2509
2510                 case SV_STAFF_DETECT_TRAP:
2511                 {
2512                         if (detect_traps(detect_rad, known)) ident = TRUE;
2513                         break;
2514                 }
2515
2516                 case SV_STAFF_DETECT_DOOR:
2517                 {
2518                         if (detect_doors(detect_rad)) ident = TRUE;
2519                         if (detect_stairs(detect_rad)) ident = TRUE;
2520                         break;
2521                 }
2522
2523                 case SV_STAFF_DETECT_INVIS:
2524                 {
2525                         if (detect_monsters_invis(detect_rad)) ident = TRUE;
2526                         break;
2527                 }
2528
2529                 case SV_STAFF_DETECT_EVIL:
2530                 {
2531                         if (detect_monsters_evil(detect_rad)) ident = TRUE;
2532                         break;
2533                 }
2534
2535                 case SV_STAFF_CURE_LIGHT:
2536                 {
2537                         if (hp_player(damroll((powerful ? 4 : 2), 8))) ident = TRUE;
2538                         if (powerful) {
2539                                 if (set_blind(0)) ident = TRUE;
2540                                 if (set_poisoned(0)) ident = TRUE;
2541                                 if (set_cut(p_ptr->cut - 10)) ident = TRUE;
2542                         }
2543                         if (set_shero(0,TRUE)) ident = TRUE;
2544                         break;
2545                 }
2546
2547                 case SV_STAFF_CURING:
2548                 {
2549                         if (set_blind(0)) ident = TRUE;
2550                         if (set_poisoned(0)) ident = TRUE;
2551                         if (set_confused(0)) ident = TRUE;
2552                         if (set_stun(0)) ident = TRUE;
2553                         if (set_cut(0)) ident = TRUE;
2554                         if (set_image(0)) ident = TRUE;
2555                         if (set_shero(0,TRUE)) ident = TRUE;
2556                         break;
2557                 }
2558
2559                 case SV_STAFF_HEALING:
2560                 {
2561                         if (hp_player(powerful ? 500 : 300)) ident = TRUE;
2562                         if (set_stun(0)) ident = TRUE;
2563                         if (set_cut(0)) ident = TRUE;
2564                         if (set_shero(0,TRUE)) ident = TRUE;
2565                         break;
2566                 }
2567
2568                 case SV_STAFF_THE_MAGI:
2569                 {
2570                         if (do_res_stat(A_INT)) ident = TRUE;
2571                         if (p_ptr->csp < p_ptr->msp)
2572                         {
2573                                 p_ptr->csp = p_ptr->msp;
2574                                 p_ptr->csp_frac = 0;
2575                                 ident = TRUE;
2576 #ifdef JP
2577                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
2578 #else
2579                                 msg_print("You feel your head clear.");
2580 #endif
2581
2582                                 p_ptr->redraw |= (PR_MANA);
2583                                 p_ptr->window |= (PW_PLAYER);
2584                                 p_ptr->window |= (PW_SPELL);
2585                         }
2586                         if (set_shero(0,TRUE)) ident = TRUE;
2587                         break;
2588                 }
2589
2590                 case SV_STAFF_SLEEP_MONSTERS:
2591                 {
2592                         if (sleep_monsters(lev)) ident = TRUE;
2593                         break;
2594                 }
2595
2596                 case SV_STAFF_SLOW_MONSTERS:
2597                 {
2598                         if (slow_monsters(lev)) ident = TRUE;
2599                         break;
2600                 }
2601
2602                 case SV_STAFF_SPEED:
2603                 {
2604                         if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
2605                         break;
2606                 }
2607
2608                 case SV_STAFF_PROBING:
2609                 {
2610                         probing();
2611                         ident = TRUE;
2612                         break;
2613                 }
2614
2615                 case SV_STAFF_DISPEL_EVIL:
2616                 {
2617                         if (dispel_evil(powerful ? 120 : 80)) ident = TRUE;
2618                         break;
2619                 }
2620
2621                 case SV_STAFF_POWER:
2622                 {
2623                         if (dispel_monsters(powerful ? 225 : 150)) ident = TRUE;
2624                         break;
2625                 }
2626
2627                 case SV_STAFF_HOLINESS:
2628                 {
2629                         if (dispel_evil(powerful ? 225 : 150)) ident = TRUE;
2630                         k = 3 * lev;
2631                         if (set_protevil((magic ? 0 : p_ptr->protevil) + randint1(25) + k, FALSE)) ident = TRUE;
2632                         if (set_poisoned(0)) ident = TRUE;
2633                         if (set_afraid(0)) ident = TRUE;
2634                         if (hp_player(50)) ident = TRUE;
2635                         if (set_stun(0)) ident = TRUE;
2636                         if (set_cut(0)) ident = TRUE;
2637                         break;
2638                 }
2639
2640                 case SV_STAFF_GENOCIDE:
2641                 {
2642                         (void)symbol_genocide((magic ? lev + 50 : 200), TRUE);
2643                         ident = TRUE;
2644                         break;
2645                 }
2646
2647                 case SV_STAFF_EARTHQUAKES:
2648                 {
2649                         if (earthquake(py, px, (powerful ? 15 : 10)))
2650                                 ident = TRUE;
2651                         else
2652 #ifdef JP
2653 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿¡£");
2654 #else
2655                                 msg_print("The dungeon trembles.");
2656 #endif
2657
2658
2659                         break;
2660                 }
2661
2662                 case SV_STAFF_DESTRUCTION:
2663                 {
2664                         if (destroy_area(py, px, (powerful ? 18 : 13) + randint0(5), FALSE))
2665                                 ident = TRUE;
2666
2667                         break;
2668                 }
2669
2670                 case SV_STAFF_ANIMATE_DEAD:
2671                 {
2672                         if (animate_dead(0, py, px))
2673                                 ident = TRUE;
2674
2675                         break;
2676                 }
2677
2678                 case SV_STAFF_MSTORM:
2679                 {
2680 #ifdef JP
2681                         msg_print("¶¯ÎϤÊËâÎϤ¬Å¨¤ò°ú¤­Îö¤¤¤¿¡ª");
2682 #else
2683                         msg_print("Mighty magics rend your enemies!");
2684 #endif
2685                         project(0, (powerful ? 7 : 5), py, px,
2686                                 (randint1(200) + (powerful ? 500 : 300)) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID, -1);
2687                         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))
2688                         {
2689 #ifdef JP
2690                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "¥³¥ó¥È¥í¡¼¥ë¤·Æñ¤¤¶¯ÎϤÊËâÎϤβòÊü", -1);
2691 #else
2692                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "unleashing magics too mighty to control", -1);
2693 #endif
2694                         }
2695                         ident = TRUE;
2696
2697                         break;
2698                 }
2699
2700                 case SV_STAFF_NOTHING:
2701                 {
2702 #ifdef JP
2703                         msg_print("²¿¤âµ¯¤é¤Ê¤«¤Ã¤¿¡£");
2704 #else
2705                         msg_print("Nothing happen.");
2706 #endif
2707                         if (prace_is_(RACE_SKELETON) || prace_is_(RACE_GOLEM) ||
2708                                 prace_is_(RACE_ZOMBIE) || prace_is_(RACE_SPECTRE))
2709 #ifdef JP
2710                                 msg_print("¤â¤Ã¤¿¤¤¤Ê¤¤»ö¤ò¤·¤¿¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£¿©¤Ùʪ¤ÏÂçÀڤˤ·¤Ê¤¯¤Æ¤Ï¡£");
2711 #else
2712                                 msg_print("What a waste.  It's your food!");
2713 #endif
2714                         break;
2715                 }
2716         }
2717         return ident;
2718 }
2719
2720 /*!
2721  * @brief ¾ó¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó / 
2722  * Use a staff.                 -RAK-
2723  * @param item »È¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
2724  * @return ¤Ê¤·
2725  * @details
2726  * One charge of one staff disappears.
2727  * Hack -- staffs of identify can be "cancelled".
2728  */
2729 static void do_cmd_use_staff_aux(int item)
2730 {
2731         int         ident, chance, lev;
2732         object_type *o_ptr;
2733
2734
2735         /* Hack -- let staffs of identify get aborted */
2736         bool use_charge = TRUE;
2737
2738
2739         /* Get the item (in the pack) */
2740         if (item >= 0)
2741         {
2742                 o_ptr = &inventory[item];
2743         }
2744
2745         /* Get the item (on the floor) */
2746         else
2747         {
2748                 o_ptr = &o_list[0 - item];
2749         }
2750
2751
2752         /* Mega-Hack -- refuse to use a pile from the ground */
2753         if ((item < 0) && (o_ptr->number > 1))
2754         {
2755 #ifdef JP
2756                 msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
2757 #else
2758                 msg_print("You must first pick up the staffs.");
2759 #endif
2760
2761                 return;
2762         }
2763
2764
2765         /* Take a turn */
2766         energy_use = 100;
2767
2768         /* Extract the item level */
2769         lev = k_info[o_ptr->k_idx].level;
2770         if (lev > 50) lev = 50 + (lev - 50)/2;
2771
2772         /* Base chance of success */
2773         chance = p_ptr->skill_dev;
2774
2775         /* Confusion hurts skill */
2776         if (p_ptr->confused) chance = chance / 2;
2777
2778         /* Hight level objects are harder */
2779         chance = chance - lev;
2780
2781         /* Give everyone a (slight) chance */
2782         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
2783         {
2784                 chance = USE_DEVICE;
2785         }
2786
2787         if (world_player)
2788         {
2789                 if (flush_failure) flush();
2790 #ifdef JP
2791                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
2792 #else
2793                 msg_print("Nothing happen. Maybe this staff is freezing too.");
2794 #endif
2795
2796                 sound(SOUND_FAIL);
2797                 return;
2798         }
2799
2800         /* Roll for usage */
2801         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
2802         {
2803                 if (flush_failure) flush();
2804 #ifdef JP
2805                 msg_print("¾ó¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
2806 #else
2807                 msg_print("You failed to use the staff properly.");
2808 #endif
2809
2810                 sound(SOUND_FAIL);
2811                 return;
2812         }
2813
2814         /* Notice empty staffs */
2815         if (o_ptr->pval <= 0)
2816         {
2817                 if (flush_failure) flush();
2818 #ifdef JP
2819                 msg_print("¤³¤Î¾ó¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
2820 #else
2821                 msg_print("The staff has no charges left.");
2822 #endif
2823
2824                 o_ptr->ident |= (IDENT_EMPTY);
2825
2826                 /* Combine / Reorder the pack (later) */
2827                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2828                 p_ptr->window |= (PW_INVEN);
2829
2830                 return;
2831         }
2832
2833
2834         /* Sound */
2835         sound(SOUND_ZAP);
2836
2837         ident = staff_effect(o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
2838
2839         if (!(object_is_aware(o_ptr)))
2840         {
2841                 chg_virtue(V_PATIENCE, -1);
2842                 chg_virtue(V_CHANCE, 1);
2843                 chg_virtue(V_KNOWLEDGE, -1);
2844         }
2845
2846         /* Combine / Reorder the pack (later) */
2847         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2848
2849         /* Tried the item */
2850         object_tried(o_ptr);
2851
2852         /* An identification was made */
2853         if (ident && !object_is_aware(o_ptr))
2854         {
2855                 object_aware(o_ptr);
2856                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2857         }
2858
2859         /* Window stuff */
2860         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2861
2862
2863         /* Hack -- some uses are "free" */
2864         if (!use_charge) return;
2865
2866
2867         /* Use a single charge */
2868         o_ptr->pval--;
2869
2870         /* XXX Hack -- unstack if necessary */
2871         if ((item >= 0) && (o_ptr->number > 1))
2872         {
2873                 object_type forge;
2874                 object_type *q_ptr;
2875
2876                 /* Get local object */
2877                 q_ptr = &forge;
2878
2879                 /* Obtain a local object */
2880                 object_copy(q_ptr, o_ptr);
2881
2882                 /* Modify quantity */
2883                 q_ptr->number = 1;
2884
2885                 /* Restore the charges */
2886                 o_ptr->pval++;
2887
2888                 /* Unstack the used item */
2889                 o_ptr->number--;
2890                 p_ptr->total_weight -= q_ptr->weight;
2891                 item = inven_carry(q_ptr);
2892
2893                 /* Message */
2894 #ifdef JP
2895                 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
2896 #else
2897                 msg_print("You unstack your staff.");
2898 #endif
2899
2900         }
2901
2902         /* Describe charges in the pack */
2903         if (item >= 0)
2904         {
2905                 inven_item_charges(item);
2906         }
2907
2908         /* Describe charges on the floor */
2909         else
2910         {
2911                 floor_item_charges(0 - item);
2912         }
2913 }
2914
2915 /*!
2916  * @brief ¾ó¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2917  * @return ¤Ê¤·
2918  */
2919 void do_cmd_use_staff(void)
2920 {
2921         int  item;
2922         cptr q, s;
2923
2924         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2925         {
2926                 set_action(ACTION_NONE);
2927         }
2928
2929         /* Restrict choices to wands */
2930         item_tester_tval = TV_STAFF;
2931
2932         /* Get an item */
2933 #ifdef JP
2934         q = "¤É¤Î¾ó¤ò»È¤¤¤Þ¤¹¤«? ";
2935         s = "»È¤¨¤ë¾ó¤¬¤Ê¤¤¡£";
2936 #else
2937         q = "Use which staff? ";
2938         s = "You have no staff to use.";
2939 #endif
2940
2941         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2942
2943         do_cmd_use_staff_aux(item);
2944 }
2945
2946 /*!
2947  * @brief ËâË¡ËÀ¤Î¸ú²Ì¤òȯư¤¹¤ë
2948  * @param sval ¥ª¥Ö¥¸¥§¥¯¥È¤Îsval
2949  * @param dir È¯Æ°¤ÎÊý¸þID
2950  * @param powerful ¶¯ÎÏȯư¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2951  * @param magic ËâÆ»¶ñ½Ñ¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
2952  * @return È¯Æ°¤Ë¤è¤ê¸ú²ÌÆâÍƤ¬³ÎÄꤷ¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
2953  */
2954 static int wand_effect(int sval, int dir, bool powerful, bool magic)
2955 {
2956         int ident = FALSE;
2957         int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
2958         int rad = powerful ? 3 : 2;
2959
2960         /* XXX Hack -- Wand of wonder can do anything before it */
2961         if (sval == SV_WAND_WONDER)
2962         {
2963                 int vir = virtue_number(V_CHANCE);
2964                 sval = randint0(SV_WAND_WONDER);
2965
2966                 if (vir)
2967                 {
2968                         if (p_ptr->virtues[vir - 1] > 0)
2969                         {
2970                                 while (randint1(300) < p_ptr->virtues[vir - 1]) sval++;
2971                                 if (sval > SV_WAND_COLD_BALL) sval = randint0(4) + SV_WAND_ACID_BALL;
2972                         }
2973                         else
2974                         {
2975                                 while (randint1(300) < (0-p_ptr->virtues[vir - 1])) sval--;
2976                                 if (sval < SV_WAND_HEAL_MONSTER) sval = randint0(3) + SV_WAND_HEAL_MONSTER;
2977                         }
2978                 }
2979                 if (sval < SV_WAND_TELEPORT_AWAY)
2980                         chg_virtue(V_CHANCE, 1);
2981         }
2982
2983         /* Analyze the wand */
2984         switch (sval)
2985         {
2986                 case SV_WAND_HEAL_MONSTER:
2987                 {
2988                         int dam = damroll((powerful ? 20 : 10), 10);
2989                         if (heal_monster(dir, dam)) ident = TRUE;
2990                         break;
2991                 }
2992
2993                 case SV_WAND_HASTE_MONSTER:
2994                 {
2995                         if (speed_monster(dir, lev)) ident = TRUE;
2996                         break;
2997                 }
2998
2999                 case SV_WAND_CLONE_MONSTER:
3000                 {
3001                         if (clone_monster(dir)) ident = TRUE;
3002                         break;
3003                 }
3004
3005                 case SV_WAND_TELEPORT_AWAY:
3006                 {
3007                         int distance = MAX_SIGHT * (powerful ? 8 : 5);
3008                         if (teleport_monster(dir, distance)) ident = TRUE;
3009                         break;
3010                 }
3011
3012                 case SV_WAND_DISARMING:
3013                 {
3014                         if (disarm_trap(dir)) ident = TRUE;
3015                         if (powerful && disarm_traps_touch()) ident = TRUE;
3016                         break;
3017                 }
3018
3019                 case SV_WAND_TRAP_DOOR_DEST:
3020                 {
3021                         if (destroy_door(dir)) ident = TRUE;
3022                         if (powerful && destroy_doors_touch()) ident = TRUE;
3023                         break;
3024                 }
3025
3026                 case SV_WAND_STONE_TO_MUD:
3027                 {
3028                         int dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
3029                         if (wall_to_mud(dir, dam)) ident = TRUE;
3030                         break;
3031                 }
3032
3033                 case SV_WAND_LITE:
3034                 {
3035                         int dam = damroll((powerful ? 12 : 6), 8);
3036 #ifdef JP
3037                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3038 #else
3039                         msg_print("A line of blue shimmering light appears.");
3040 #endif
3041
3042                         (void)lite_line(dir, dam);
3043                         ident = TRUE;
3044                         break;
3045                 }
3046
3047                 case SV_WAND_SLEEP_MONSTER:
3048                 {
3049                         if (sleep_monster(dir, lev)) ident = TRUE;
3050                         break;
3051                 }
3052
3053                 case SV_WAND_SLOW_MONSTER:
3054                 {
3055                         if (slow_monster(dir, lev)) ident = TRUE;
3056                         break;
3057                 }
3058
3059                 case SV_WAND_CONFUSE_MONSTER:
3060                 {
3061                         if (confuse_monster(dir, lev)) ident = TRUE;
3062                         break;
3063                 }
3064
3065                 case SV_WAND_FEAR_MONSTER:
3066                 {
3067                         if (fear_monster(dir, lev)) ident = TRUE;
3068                         break;
3069                 }
3070
3071                 case SV_WAND_DRAIN_LIFE:
3072                 {
3073                         if (drain_life(dir, 80 + lev)) ident = TRUE;
3074                         break;
3075                 }
3076
3077                 case SV_WAND_POLYMORPH:
3078                 {
3079                         if (poly_monster(dir, lev)) ident = TRUE;
3080                         break;
3081                 }
3082
3083                 case SV_WAND_STINKING_CLOUD:
3084                 {
3085                         fire_ball(GF_POIS, dir, 12 + lev / 4, rad);
3086                         ident = TRUE;
3087                         break;
3088                 }
3089
3090                 case SV_WAND_MAGIC_MISSILE:
3091                 {
3092                         fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(2 + lev / 10, 6));
3093                         ident = TRUE;
3094                         break;
3095                 }
3096
3097                 case SV_WAND_ACID_BOLT:
3098                 {
3099                         fire_bolt_or_beam(20, GF_ACID, dir, damroll(6 + lev / 7, 8));
3100                         ident = TRUE;
3101                         break;
3102                 }
3103
3104                 case SV_WAND_CHARM_MONSTER:
3105                 {
3106                         if (charm_monster(dir, MAX(20, lev)))
3107                         ident = TRUE;
3108                         break;
3109                 }
3110
3111                 case SV_WAND_FIRE_BOLT:
3112                 {
3113                         fire_bolt_or_beam(20, GF_FIRE, dir, damroll(7 + lev / 6, 8));
3114                         ident = TRUE;
3115                         break;
3116                 }
3117
3118                 case SV_WAND_COLD_BOLT:
3119                 {
3120                         fire_bolt_or_beam(20, GF_COLD, dir, damroll(5 + lev / 8, 8));
3121                         ident = TRUE;
3122                         break;
3123                 }
3124
3125                 case SV_WAND_ACID_BALL:
3126                 {
3127                         fire_ball(GF_ACID, dir, 60 + 3 * lev / 4, rad);
3128                         ident = TRUE;
3129                         break;
3130                 }
3131
3132                 case SV_WAND_ELEC_BALL:
3133                 {
3134                         fire_ball(GF_ELEC, dir, 40 + 3 * lev / 4, rad);
3135                         ident = TRUE;
3136                         break;
3137                 }
3138
3139                 case SV_WAND_FIRE_BALL:
3140                 {
3141                         fire_ball(GF_FIRE, dir, 70 + 3 * lev / 4, rad);
3142                         ident = TRUE;
3143                         break;
3144                 }
3145
3146                 case SV_WAND_COLD_BALL:
3147                 {
3148                         fire_ball(GF_COLD, dir, 50 + 3 * lev / 4, rad);
3149                         ident = TRUE;
3150                         break;
3151                 }
3152
3153                 case SV_WAND_WONDER:
3154                 {
3155 #ifdef JP
3156                         msg_print("¤ª¤Ã¤È¡¢Ææ¤ÎËâË¡ËÀ¤ò»ÏÆ°¤µ¤»¤¿¡£");
3157 #else
3158                         msg_print("Oops.  Wand of wonder activated.");
3159 #endif
3160
3161                         break;
3162                 }
3163
3164                 case SV_WAND_DRAGON_FIRE:
3165                 {
3166                         fire_ball(GF_FIRE, dir, (powerful ? 300 : 200), -3);
3167                         ident = TRUE;
3168                         break;
3169                 }
3170
3171                 case SV_WAND_DRAGON_COLD:
3172                 {
3173                         fire_ball(GF_COLD, dir, (powerful ? 270 : 180), -3);
3174                         ident = TRUE;
3175                         break;
3176                 }
3177
3178                 case SV_WAND_DRAGON_BREATH:
3179                 {
3180                         int dam;
3181                         int typ;
3182
3183                         switch (randint1(5))
3184                         {
3185                                 case 1:
3186                                         dam = 240;
3187                                         typ = GF_ACID;
3188                                         break;
3189                                 case 2:
3190                                         dam = 210;
3191                                         typ = GF_ELEC;
3192                                         break;
3193                                 case 3:
3194                                         dam = 240;
3195                                         typ = GF_FIRE;
3196                                         break;
3197                                 case 4:
3198                                         dam = 210;
3199                                         typ = GF_COLD;
3200                                         break;
3201                                 default:
3202                                         dam = 180;
3203                                         typ = GF_POIS;
3204                                         break;
3205                         }
3206
3207                         if (powerful) dam = (dam * 3) / 2;
3208
3209                         fire_ball(typ, dir, dam, -3);
3210
3211                         ident = TRUE;
3212                         break;
3213                 }
3214
3215                 case SV_WAND_DISINTEGRATE:
3216                 {
3217                         fire_ball(GF_DISINTEGRATE, dir, 200 + randint1(lev * 2), rad);
3218                         ident = TRUE;
3219                         break;
3220                 }
3221
3222                 case SV_WAND_ROCKETS:
3223                 {
3224 #ifdef JP
3225 msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
3226 #else
3227                         msg_print("You launch a rocket!");
3228 #endif
3229
3230                         fire_rocket(GF_ROCKET, dir, 250 + lev * 3, rad);
3231                         ident = TRUE;
3232                         break;
3233                 }
3234
3235                 case SV_WAND_STRIKING:
3236                 {
3237                         fire_bolt(GF_METEOR, dir, damroll(15 + lev / 3, 13));
3238                         ident = TRUE;
3239                         break;
3240                 }
3241
3242                 case SV_WAND_GENOCIDE:
3243                 {
3244                         fire_ball_hide(GF_GENOCIDE, dir, magic ? lev + 50 : 250, 0);
3245                         ident = TRUE;
3246                         break;
3247                 }
3248         }
3249         return ident;
3250 }
3251
3252 /*!
3253  * @brief ËâË¡ËÀ¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó / 
3254  * Aim a wand (from the pack or floor).
3255  * @param item »È¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
3256  * @return ¤Ê¤·
3257  * @details
3258  * <pre>
3259  * Use a single charge from a single item.
3260  * Handle "unstacking" in a logical manner.
3261  * For simplicity, you cannot use a stack of items from the
3262  * ground.  This would require too much nasty code.
3263  * There are no wands which can "destroy" themselves, in the inventory
3264  * or on the ground, so we can ignore this possibility.  Note that this
3265  * required giving "wand of wonder" the ability to ignore destruction
3266  * by electric balls.
3267  * All wands can be "cancelled" at the "Direction?" prompt for free.
3268  * Note that the basic "bolt" wands do slightly less damage than the
3269  * basic "bolt" rods, but the basic "ball" wands do the same damage
3270  * as the basic "ball" rods.
3271  * </pre>
3272  */
3273 static void do_cmd_aim_wand_aux(int item)
3274 {
3275         int         lev, ident, chance, dir;
3276         object_type *o_ptr;
3277         bool old_target_pet = target_pet;
3278
3279         /* Get the item (in the pack) */
3280         if (item >= 0)
3281         {
3282                 o_ptr = &inventory[item];
3283         }
3284
3285         /* Get the item (on the floor) */
3286         else
3287         {
3288                 o_ptr = &o_list[0 - item];
3289         }
3290
3291         /* Mega-Hack -- refuse to aim a pile from the ground */
3292         if ((item < 0) && (o_ptr->number > 1))
3293         {
3294 #ifdef JP
3295                 msg_print("¤Þ¤º¤ÏËâË¡ËÀ¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3296 #else
3297                 msg_print("You must first pick up the wands.");
3298 #endif
3299
3300                 return;
3301         }
3302
3303
3304         /* Allow direction to be cancelled for free */
3305         if (object_is_aware(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
3306                                       || o_ptr->sval == SV_WAND_HASTE_MONSTER))
3307                         target_pet = TRUE;
3308         if (!get_aim_dir(&dir))
3309         {
3310                 target_pet = old_target_pet;
3311                 return;
3312         }
3313         target_pet = old_target_pet;
3314
3315         /* Take a turn */
3316         energy_use = 100;
3317
3318         /* Get the level */
3319         lev = k_info[o_ptr->k_idx].level;
3320         if (lev > 50) lev = 50 + (lev - 50)/2;
3321
3322         /* Base chance of success */
3323         chance = p_ptr->skill_dev;
3324
3325         /* Confusion hurts skill */
3326         if (p_ptr->confused) chance = chance / 2;
3327
3328         /* Hight level objects are harder */
3329         chance = chance - lev;
3330
3331         /* Give everyone a (slight) chance */
3332         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
3333         {
3334                 chance = USE_DEVICE;
3335         }
3336
3337         if (world_player)
3338         {
3339                 if (flush_failure) flush();
3340 #ifdef JP
3341                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3342 #else
3343                 msg_print("Nothing happen. Maybe this wand is freezing too.");
3344 #endif
3345
3346                 sound(SOUND_FAIL);
3347                 return;
3348         }
3349
3350         /* Roll for usage */
3351         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
3352         {
3353                 if (flush_failure) flush();
3354 #ifdef JP
3355                 msg_print("ËâË¡ËÀ¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
3356 #else
3357                 msg_print("You failed to use the wand properly.");
3358 #endif
3359
3360                 sound(SOUND_FAIL);
3361                 return;
3362         }
3363
3364         /* The wand is already empty! */
3365         if (o_ptr->pval <= 0)
3366         {
3367                 if (flush_failure) flush();
3368 #ifdef JP
3369                 msg_print("¤³¤ÎËâË¡ËÀ¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
3370 #else
3371                 msg_print("The wand has no charges left.");
3372 #endif
3373
3374                 o_ptr->ident |= (IDENT_EMPTY);
3375
3376                 /* Combine / Reorder the pack (later) */
3377                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3378                 p_ptr->window |= (PW_INVEN);
3379
3380                 return;
3381         }
3382
3383         /* Sound */
3384         sound(SOUND_ZAP);
3385
3386         ident = wand_effect(o_ptr->sval, dir, FALSE, FALSE);
3387
3388         /* Combine / Reorder the pack (later) */
3389         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3390
3391         if (!(object_is_aware(o_ptr)))
3392         {
3393                 chg_virtue(V_PATIENCE, -1);
3394                 chg_virtue(V_CHANCE, 1);
3395                 chg_virtue(V_KNOWLEDGE, -1);
3396         }
3397
3398         /* Mark it as tried */
3399         object_tried(o_ptr);
3400
3401         /* Apply identification */
3402         if (ident && !object_is_aware(o_ptr))
3403         {
3404                 object_aware(o_ptr);
3405                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3406         }
3407
3408         /* Window stuff */
3409         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3410
3411
3412         /* Use a single charge */
3413         o_ptr->pval--;
3414
3415         /* Describe the charges in the pack */
3416         if (item >= 0)
3417         {
3418                 inven_item_charges(item);
3419         }
3420
3421         /* Describe the charges on the floor */
3422         else
3423         {
3424                 floor_item_charges(0 - item);
3425         }
3426 }
3427
3428 /*!
3429  * @brief ËâË¡ËÀ¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
3430  * @return ¤Ê¤·
3431  */
3432 void do_cmd_aim_wand(void)
3433 {
3434         int     item;
3435         cptr    q, s;
3436
3437         /* Restrict choices to wands */
3438         item_tester_tval = TV_WAND;
3439
3440         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3441         {
3442                 set_action(ACTION_NONE);
3443         }
3444
3445         /* Get an item */
3446 #ifdef JP
3447         q = "¤É¤ÎËâË¡ËÀ¤ÇÁÀ¤¤¤Þ¤¹¤«? ";
3448         s = "»È¤¨¤ëËâË¡ËÀ¤¬¤Ê¤¤¡£";
3449 #else
3450         q = "Aim which wand? ";
3451         s = "You have no wand to aim.";
3452 #endif
3453
3454         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3455
3456         /* Aim the wand */
3457         do_cmd_aim_wand_aux(item);
3458 }
3459
3460 /*!
3461  * @brief ¥í¥Ã¥É¤Î¸ú²Ì¤òȯư¤¹¤ë
3462  * @param sval ¥ª¥Ö¥¸¥§¥¯¥È¤Îsval
3463  * @param dir È¯Æ°ÌÜɸ¤ÎÊý¸þID
3464  * @param use_charge ¥Á¥ã¡¼¥¸¤ò¾ÃÈñ¤·¤¿¤«¤É¤¦¤«¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
3465  * @param powerful ¶¯ÎÏȯư¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
3466  * @param magic ËâÆ»¶ñ½Ñ¾å¤Î½èÍý¤Ê¤é¤ÐTRUE
3467  * @return È¯Æ°¤Ë¤è¤ê¸ú²ÌÆâÍƤ¬³ÎÄꤷ¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
3468  */
3469 static int rod_effect(int sval, int dir, bool *use_charge, bool powerful, bool magic)
3470 {
3471         int ident = FALSE;
3472         int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
3473         int detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
3474         int rad = powerful ? 3 : 2;
3475
3476         /* Unused */
3477         (void)magic;
3478
3479         /* Analyze the rod */
3480         switch (sval)
3481         {
3482                 case SV_ROD_DETECT_TRAP:
3483                 {
3484                         if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
3485                         break;
3486                 }
3487
3488                 case SV_ROD_DETECT_DOOR:
3489                 {
3490                         if (detect_doors(detect_rad)) ident = TRUE;
3491                         if (detect_stairs(detect_rad)) ident = TRUE;
3492                         break;
3493                 }
3494
3495                 case SV_ROD_IDENTIFY:
3496                 {
3497                         if (powerful) {
3498                                 if (!identify_fully(FALSE)) *use_charge = FALSE;
3499                         } else {
3500                                 if (!ident_spell(FALSE)) *use_charge = FALSE;
3501                         }
3502                         ident = TRUE;
3503                         break;
3504                 }
3505
3506                 case SV_ROD_RECALL:
3507                 {
3508                         if (!word_of_recall()) *use_charge = FALSE;
3509                         ident = TRUE;
3510                         break;
3511                 }
3512
3513                 case SV_ROD_ILLUMINATION:
3514                 {
3515                         if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
3516                         break;
3517                 }
3518
3519                 case SV_ROD_MAPPING:
3520                 {
3521                         map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
3522                         ident = TRUE;
3523                         break;
3524                 }
3525
3526                 case SV_ROD_DETECTION:
3527                 {
3528                         detect_all(detect_rad);
3529                         ident = TRUE;
3530                         break;
3531                 }
3532
3533                 case SV_ROD_PROBING:
3534                 {
3535                         probing();
3536                         ident = TRUE;
3537                         break;
3538                 }
3539
3540                 case SV_ROD_CURING:
3541                 {
3542                         if (set_blind(0)) ident = TRUE;
3543                         if (set_poisoned(0)) ident = TRUE;
3544                         if (set_confused(0)) ident = TRUE;
3545                         if (set_stun(0)) ident = TRUE;
3546                         if (set_cut(0)) ident = TRUE;
3547                         if (set_image(0)) ident = TRUE;
3548                         if (set_shero(0,TRUE)) ident = TRUE;
3549                         break;
3550                 }
3551
3552                 case SV_ROD_HEALING:
3553                 {
3554                         if (hp_player(powerful ? 750 : 500)) ident = TRUE;
3555                         if (set_stun(0)) ident = TRUE;
3556                         if (set_cut(0)) ident = TRUE;
3557                         if (set_shero(0,TRUE)) ident = TRUE;
3558                         break;
3559                 }
3560
3561                 case SV_ROD_RESTORATION:
3562                 {
3563                         if (restore_level()) ident = TRUE;
3564                         if (do_res_stat(A_STR)) ident = TRUE;
3565                         if (do_res_stat(A_INT)) ident = TRUE;
3566                         if (do_res_stat(A_WIS)) ident = TRUE;
3567                         if (do_res_stat(A_DEX)) ident = TRUE;
3568                         if (do_res_stat(A_CON)) ident = TRUE;
3569                         if (do_res_stat(A_CHR)) ident = TRUE;
3570                         break;
3571                 }
3572
3573                 case SV_ROD_SPEED:
3574                 {
3575                         if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
3576                         break;
3577                 }
3578
3579                 case SV_ROD_PESTICIDE:
3580                 {
3581                         if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
3582                         break;
3583                 }
3584
3585                 case SV_ROD_TELEPORT_AWAY:
3586                 {
3587                         int distance = MAX_SIGHT * (powerful ? 8 : 5);
3588                         if (teleport_monster(dir, distance)) ident = TRUE;
3589                         break;
3590                 }
3591
3592                 case SV_ROD_DISARMING:
3593                 {
3594                         if (disarm_trap(dir)) ident = TRUE;
3595                         if (powerful && disarm_traps_touch()) ident = TRUE;
3596                         break;
3597                 }
3598
3599                 case SV_ROD_LITE:
3600                 {
3601                         int dam = damroll((powerful ? 12 : 6), 8);
3602 #ifdef JP
3603                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3604 #else
3605                         msg_print("A line of blue shimmering light appears.");
3606 #endif
3607
3608                         (void)lite_line(dir, dam);
3609                         ident = TRUE;
3610                         break;
3611                 }
3612
3613                 case SV_ROD_SLEEP_MONSTER:
3614                 {
3615                         if (sleep_monster(dir, lev)) ident = TRUE;
3616                         break;
3617                 }
3618
3619                 case SV_ROD_SLOW_MONSTER:
3620                 {
3621                         if (slow_monster(dir, lev)) ident = TRUE;
3622                         break;
3623                 }
3624
3625                 case SV_ROD_DRAIN_LIFE:
3626                 {
3627                         if (drain_life(dir, 70 + 3 * lev / 2)) ident = TRUE;
3628                         break;
3629                 }
3630
3631                 case SV_ROD_POLYMORPH:
3632                 {
3633                         if (poly_monster(dir, lev)) ident = TRUE;
3634                         break;
3635                 }
3636
3637                 case SV_ROD_ACID_BOLT:
3638                 {
3639                         fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
3640                         ident = TRUE;
3641                         break;
3642                 }
3643
3644                 case SV_ROD_ELEC_BOLT:
3645                 {
3646                         fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
3647                         ident = TRUE;
3648                         break;
3649                 }
3650
3651                 case SV_ROD_FIRE_BOLT:
3652                 {
3653                         fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
3654                         ident = TRUE;
3655                         break;
3656                 }
3657
3658                 case SV_ROD_COLD_BOLT:
3659                 {
3660                         fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
3661                         ident = TRUE;
3662                         break;
3663                 }
3664
3665                 case SV_ROD_ACID_BALL:
3666                 {
3667                         fire_ball(GF_ACID, dir, 60 + lev, rad);
3668                         ident = TRUE;
3669                         break;
3670                 }
3671
3672                 case SV_ROD_ELEC_BALL:
3673                 {
3674                         fire_ball(GF_ELEC, dir, 40 + lev, rad);
3675                         ident = TRUE;
3676                         break;
3677                 }
3678
3679                 case SV_ROD_FIRE_BALL:
3680                 {
3681                         fire_ball(GF_FIRE, dir, 70 + lev, rad);
3682                         ident = TRUE;
3683                         break;
3684                 }
3685
3686                 case SV_ROD_COLD_BALL:
3687                 {
3688                         fire_ball(GF_COLD, dir, 50 + lev, rad);
3689                         ident = TRUE;
3690                         break;
3691                 }
3692
3693                 case SV_ROD_HAVOC:
3694                 {
3695                         call_chaos();
3696                         ident = TRUE;
3697                         break;
3698                 }
3699
3700                 case SV_ROD_STONE_TO_MUD:
3701                 {
3702                         int dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
3703                         if (wall_to_mud(dir, dam)) ident = TRUE;
3704                         break;
3705                 }
3706
3707                 case SV_ROD_AGGRAVATE:
3708                 {
3709                         aggravate_monsters(0);
3710                         ident = TRUE;
3711                         break;
3712                 }
3713         }
3714         return ident;
3715 }
3716
3717 /*!
3718  * @brief ËâË¡ËÀ¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó / 
3719  * Activate (zap) a Rod
3720  * @param item »È¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýÉÊID
3721  * @return ¤Ê¤·
3722  * @details
3723  * <pre>
3724  * Unstack fully charged rods as needed.
3725  * Hack -- rods of perception/genocide can be "cancelled"
3726  * All rods can be cancelled at the "Direction?" prompt
3727  * pvals are defined for each rod in k_info. -LM-
3728  * </pre>
3729  */
3730 static void do_cmd_zap_rod_aux(int item)
3731 {
3732         int ident, chance, lev, fail;
3733         int dir = 0;
3734         object_type *o_ptr;
3735         bool success;
3736
3737         /* Hack -- let perception get aborted */
3738         bool use_charge = TRUE;
3739
3740         object_kind *k_ptr;
3741
3742         /* Get the item (in the pack) */
3743         if (item >= 0)
3744         {
3745                 o_ptr = &inventory[item];
3746         }
3747
3748         /* Get the item (on the floor) */
3749         else
3750         {
3751                 o_ptr = &o_list[0 - item];
3752         }
3753
3754
3755         /* Mega-Hack -- refuse to zap a pile from the ground */
3756         if ((item < 0) && (o_ptr->number > 1))
3757         {
3758 #ifdef JP
3759                 msg_print("¤Þ¤º¤Ï¥í¥Ã¥É¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3760 #else
3761                 msg_print("You must first pick up the rods.");
3762 #endif
3763
3764                 return;
3765         }
3766
3767
3768         /* Get a direction (unless KNOWN not to need it) */
3769         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)) ||
3770              !object_is_aware(o_ptr))
3771         {
3772                 /* Get a direction, allow cancel */
3773                 if (!get_aim_dir(&dir)) return;
3774         }
3775
3776
3777         /* Take a turn */
3778         energy_use = 100;
3779
3780         /* Extract the item level */
3781         lev = k_info[o_ptr->k_idx].level;
3782
3783         /* Base chance of success */
3784         chance = p_ptr->skill_dev;
3785
3786         /* Confusion hurts skill */
3787         if (p_ptr->confused) chance = chance / 2;
3788
3789         fail = lev+5;
3790         if (chance > fail) fail -= (chance - fail)*2;
3791         else chance -= (fail - chance)*2;
3792         if (fail < USE_DEVICE) fail = USE_DEVICE;
3793         if (chance < USE_DEVICE) chance = USE_DEVICE;
3794
3795         if (world_player)
3796         {
3797                 if (flush_failure) flush();
3798 #ifdef JP
3799                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3800 #else
3801                 msg_print("Nothing happen. Maybe this rod is freezing too.");
3802 #endif
3803
3804                 sound(SOUND_FAIL);
3805                 return;
3806         }
3807
3808         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
3809         else if (chance > fail)
3810         {
3811                 if (randint0(chance*2) < fail) success = FALSE;
3812                 else success = TRUE;
3813         }
3814         else
3815         {
3816                 if (randint0(fail*2) < chance) success = TRUE;
3817                 else success = FALSE;
3818         }
3819
3820         /* Roll for usage */
3821         if (!success)
3822         {
3823                 if (flush_failure) flush();
3824 #ifdef JP
3825                 msg_print("¤¦¤Þ¤¯¥í¥Ã¥É¤ò»È¤¨¤Ê¤«¤Ã¤¿¡£");
3826 #else
3827                 msg_print("You failed to use the rod properly.");
3828 #endif
3829
3830                 sound(SOUND_FAIL);
3831                 return;
3832         }
3833
3834         k_ptr = &k_info[o_ptr->k_idx];
3835
3836         /* A single rod is still charging */
3837         if ((o_ptr->number == 1) && (o_ptr->timeout))
3838         {
3839                 if (flush_failure) flush();
3840 #ifdef JP
3841                 msg_print("¤³¤Î¥í¥Ã¥É¤Ï¤Þ¤ÀËâÎϤò½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
3842 #else
3843                 msg_print("The rod is still charging.");
3844 #endif
3845
3846                 return;
3847         }
3848         /* A stack of rods lacks enough energy. */
3849         else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
3850         {
3851                 if (flush_failure) flush();
3852 #ifdef JP
3853 msg_print("¤½¤Î¥í¥Ã¥É¤Ï¤Þ¤À½¼Å¶Ãæ¤Ç¤¹¡£");
3854 #else
3855                 msg_print("The rods are all still charging.");
3856 #endif
3857
3858                 return;
3859         }
3860
3861         /* Sound */
3862         sound(SOUND_ZAP);
3863
3864         ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
3865
3866         /* Increase the timeout by the rod kind's pval. -LM- */
3867         if (use_charge) o_ptr->timeout += k_ptr->pval;
3868
3869         /* Combine / Reorder the pack (later) */
3870         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3871
3872         if (!(object_is_aware(o_ptr)))
3873         {
3874                 chg_virtue(V_PATIENCE, -1);
3875                 chg_virtue(V_CHANCE, 1);
3876                 chg_virtue(V_KNOWLEDGE, -1);
3877         }
3878
3879         /* Tried the object */
3880         object_tried(o_ptr);
3881
3882         /* Successfully determined the object function */
3883         if (ident && !object_is_aware(o_ptr))
3884         {
3885                 object_aware(o_ptr);
3886                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3887         }
3888
3889         /* Window stuff */
3890         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3891 }
3892
3893 /*!
3894  * @brief ¥í¥Ã¥É¤ò»È¤¦¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
3895  * @return ¤Ê¤·
3896  */
3897 void do_cmd_zap_rod(void)
3898 {
3899         int item;
3900         cptr q, s;
3901
3902         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3903         {
3904                 set_action(ACTION_NONE);
3905         }
3906
3907         /* Restrict choices to rods */
3908         item_tester_tval = TV_ROD;
3909
3910         /* Get an item */
3911 #ifdef JP
3912         q = "¤É¤Î¥í¥Ã¥É¤ò¿¶¤ê¤Þ¤¹¤«? ";
3913         s = "»È¤¨¤ë¥í¥Ã¥É¤¬¤Ê¤¤¡£";
3914 #else
3915         q = "Zap which rod? ";
3916         s = "You have no rod to zap.";
3917 #endif
3918
3919         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3920
3921         /* Zap the rod */
3922         do_cmd_zap_rod_aux(item);
3923 }
3924
3925 /*!
3926  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤¬ËâÆ»¶ñ¤È¤·¤Æȯư¤Ç¤­¤ë¤«¤òȽÄꤹ¤ë /
3927  * Hook to determine if an object is activatable
3928  * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3929  * @return ËâÆ»¶ñ¤È¤·¤Æȯư²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
3930  */
3931 static bool item_tester_hook_activate(object_type *o_ptr)
3932 {
3933         u32b flgs[TR_FLAG_SIZE];
3934
3935         /* Not known */
3936         if (!object_is_known(o_ptr)) return (FALSE);
3937
3938         /* Extract the flags */
3939         object_flags(o_ptr, flgs);
3940
3941         /* Check activation flag */
3942         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
3943
3944         /* Assume not */
3945         return (FALSE);
3946 }
3947
3948
3949 /*
3950  * Hack -- activate the ring of power
3951  */
3952 void ring_of_power(int dir)
3953 {
3954         /* Pick a random effect */
3955         switch (randint1(10))
3956         {
3957                 case 1:
3958                 case 2:
3959                 {
3960                         /* Message */
3961 #ifdef JP
3962                         msg_print("¤¢¤Ê¤¿¤Ï°­À­¤Î¥ª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3963 #else
3964                         msg_print("You are surrounded by a malignant aura.");
3965 #endif
3966
3967                         sound(SOUND_EVIL);
3968
3969                         /* Decrease all stats (permanently) */
3970                         (void)dec_stat(A_STR, 50, TRUE);
3971                         (void)dec_stat(A_INT, 50, TRUE);
3972                         (void)dec_stat(A_WIS, 50, TRUE);
3973                         (void)dec_stat(A_DEX, 50, TRUE);
3974                         (void)dec_stat(A_CON, 50, TRUE);
3975                         (void)dec_stat(A_CHR, 50, TRUE);
3976
3977                         /* Lose some experience (permanently) */
3978                         p_ptr->exp -= (p_ptr->exp / 4);
3979                         p_ptr->max_exp -= (p_ptr->exp / 4);
3980                         check_experience();
3981
3982                         break;
3983                 }
3984
3985                 case 3:
3986                 {
3987                         /* Message */
3988 #ifdef JP
3989                         msg_print("¤¢¤Ê¤¿¤Ï¶¯ÎϤʥª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3990 #else
3991                         msg_print("You are surrounded by a powerful aura.");
3992 #endif
3993
3994
3995                         /* Dispel monsters */
3996                         dispel_monsters(1000);
3997
3998                         break;
3999                 }
4000
4001                 case 4:
4002                 case 5:
4003                 case 6:
4004                 {
4005                         /* Mana Ball */
4006                         fire_ball(GF_MANA, dir, 600, 3);
4007
4008                         break;
4009                 }
4010
4011                 case 7:
4012                 case 8:
4013                 case 9:
4014                 case 10:
4015                 {
4016                         /* Mana Bolt */
4017                         fire_bolt(GF_MANA, dir, 500);
4018
4019                         break;
4020                 }
4021         }
4022 }
4023
4024
4025 static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
4026 {
4027         u16b *who = (u16b*)(u);
4028
4029         int w1 = who[a];
4030         int w2 = who[b];
4031
4032         monster_type *m_ptr1 = &m_list[w1];
4033         monster_type *m_ptr2 = &m_list[w2];
4034         monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
4035         monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
4036
4037         /* Unused */
4038         (void)v;
4039
4040         if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
4041         if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
4042
4043         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
4044         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
4045
4046         if (r_ptr1->level > r_ptr2->level) return TRUE;
4047         if (r_ptr2->level > r_ptr1->level) return FALSE;
4048
4049         if (m_ptr1->hp > m_ptr2->hp) return TRUE;
4050         if (m_ptr2->hp > m_ptr1->hp) return FALSE;
4051         
4052         return w1 <= w2;
4053 }
4054
4055
4056 /*
4057  * Activate a wielded object.  Wielded objects never stack.
4058  * And even if they did, activatable objects never stack.
4059  *
4060  * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated.
4061  * But one could, for example, easily make an activatable "Ring of Plasma".
4062  *
4063  * Note that it always takes a turn to activate an artifact, even if
4064  * the user hits "escape" at the "direction" prompt.
4065  */
4066 static void do_cmd_activate_aux(int item)
4067 {
4068         int         dir, lev, chance, fail;
4069         object_type *o_ptr;
4070         bool success;
4071
4072
4073         /* Get the item (in the pack) */
4074         if (item >= 0)
4075         {
4076                 o_ptr = &inventory[item];
4077         }
4078
4079         /* Get the item (on the floor) */
4080         else
4081         {
4082                 o_ptr = &o_list[0 - item];
4083         }
4084
4085         /* Take a turn */
4086         energy_use = 100;
4087
4088         /* Extract the item level */
4089         lev = k_info[o_ptr->k_idx].level;
4090
4091         /* Hack -- use artifact level instead */
4092         if (object_is_fixed_artifact(o_ptr)) lev = a_info[o_ptr->name1].level;
4093         else if (object_is_random_artifact(o_ptr))
4094         {
4095                 const activation_type* const act_ptr = find_activation_info(o_ptr);
4096                 if (act_ptr) {
4097                         lev = act_ptr->level;
4098                 }
4099         }
4100         else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
4101
4102         /* Base chance of success */
4103         chance = p_ptr->skill_dev;
4104
4105         /* Confusion hurts skill */
4106         if (p_ptr->confused) chance = chance / 2;
4107
4108         fail = lev+5;
4109         if (chance > fail) fail -= (chance - fail)*2;
4110         else chance -= (fail - chance)*2;
4111         if (fail < USE_DEVICE) fail = USE_DEVICE;
4112         if (chance < USE_DEVICE) chance = USE_DEVICE;
4113
4114         if (world_player)
4115         {
4116                 if (flush_failure) flush();
4117 #ifdef JP
4118                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
4119 #else
4120                 msg_print("It shows no reaction.");
4121 #endif
4122                 sound(SOUND_FAIL);
4123                 return;
4124         }
4125
4126         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
4127         else if (chance > fail)
4128         {
4129                 if (randint0(chance*2) < fail) success = FALSE;
4130                 else success = TRUE;
4131         }
4132         else
4133         {
4134                 if (randint0(fail*2) < chance) success = TRUE;
4135                 else success = FALSE;
4136         }
4137
4138         /* Roll for usage */
4139         if (!success)
4140         {
4141                 if (flush_failure) flush();
4142 #ifdef JP
4143                 msg_print("¤¦¤Þ¤¯»ÏÆ°¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Ê¤«¤Ã¤¿¡£");
4144 #else
4145                 msg_print("You failed to activate it properly.");
4146 #endif
4147                 sound(SOUND_FAIL);
4148                 return;
4149         }
4150
4151         /* Check the recharge */
4152         if (o_ptr->timeout)
4153         {
4154 #ifdef JP
4155                 msg_print("¤½¤ì¤ÏÈù¤«¤Ë²»¤òΩ¤Æ¡¢µ±¤­¡¢¾Ã¤¨¤¿...");
4156 #else
4157                 msg_print("It whines, glows and fades...");
4158 #endif
4159                 return;
4160         }
4161
4162         /* Some lights need enough fuel for activation */
4163         if (!o_ptr->xtra4 && (o_ptr->tval == TV_FLASK) &&
4164                 ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
4165         {
4166 #ifdef JP
4167                 msg_print("dzÎÁ¤¬¤Ê¤¤¡£");
4168 #else
4169                 msg_print("It has no fuel.");
4170 #endif
4171                 energy_use = 0;
4172                 return;
4173         }
4174
4175         /* Activate the artifact */
4176 #ifdef JP
4177         msg_print("»ÏÆ°¤µ¤»¤¿...");
4178 #else
4179         msg_print("You activate it...");
4180 #endif
4181
4182
4183         /* Sound */
4184         sound(SOUND_ZAP);
4185
4186         /* Activate object */
4187         if (activation_index(o_ptr))
4188         {
4189                 (void)activate_random_artifact(o_ptr);
4190
4191                 /* Window stuff */
4192                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4193
4194                 /* Success */
4195                 return;
4196         }
4197
4198         /* Special items */
4199         else if (o_ptr->tval == TV_WHISTLE)
4200         {
4201                 if (music_singing_any()) stop_singing();
4202                 if (hex_spelling_any()) stop_hex_spell_all();
4203
4204 #if 0
4205                 if (object_is_cursed(o_ptr))
4206                 {
4207 #ifdef JP
4208                         msg_print("¥«¥ó¹â¤¤²»¤¬¶Á¤­ÅϤä¿¡£");
4209 #else
4210                         msg_print("You produce a shrill whistling sound.");
4211 #endif
4212                         aggravate_monsters(0);
4213                 }
4214                 else
4215 #endif
4216                 {
4217                         int pet_ctr, i;
4218                         u16b *who;
4219                         int max_pet = 0;
4220                         u16b dummy_why;
4221
4222                         /* Allocate the "who" array */
4223                         C_MAKE(who, max_m_idx, u16b);
4224
4225                         /* Process the monsters (backwards) */
4226                         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
4227                         {
4228                                 if (is_pet(&m_list[pet_ctr]) && (p_ptr->riding != pet_ctr))
4229                                   who[max_pet++] = pet_ctr;
4230                         }
4231
4232                         /* Select the sort method */
4233                         ang_sort_comp = ang_sort_comp_pet;
4234                         ang_sort_swap = ang_sort_swap_hook;
4235
4236                         ang_sort(who, &dummy_why, max_pet);
4237
4238                         /* Process the monsters (backwards) */
4239                         for (i = 0; i < max_pet; i++)
4240                         {
4241                                 pet_ctr = who[i];
4242                                 teleport_monster_to(pet_ctr, py, px, 100, TELEPORT_PASSIVE);
4243                         }
4244
4245                         /* Free the "who" array */
4246                         C_KILL(who, max_m_idx, u16b);
4247                 }
4248                 o_ptr->timeout = 100+randint1(100);
4249                 return;
4250         }
4251         else if (o_ptr->tval == TV_CAPTURE)
4252         {
4253                 if(!o_ptr->pval)
4254                 {
4255                         bool old_target_pet = target_pet;
4256                         target_pet = TRUE;
4257                         if (!get_aim_dir(&dir))
4258                         {
4259                                 target_pet = old_target_pet;
4260                                 return;
4261                         }
4262                         target_pet = old_target_pet;
4263
4264                         if(fire_ball(GF_CAPTURE, dir, 0, 0))
4265                         {
4266                                 o_ptr->pval = cap_mon;
4267                                 o_ptr->xtra3 = cap_mspeed;
4268                                 o_ptr->xtra4 = cap_hp;
4269                                 o_ptr->xtra5 = cap_maxhp;
4270                                 if (cap_nickname)
4271                                 {
4272                                         cptr t;
4273                                         char *s;
4274                                         char buf[80] = "";
4275
4276                                         if (o_ptr->inscription)
4277                                                 strcpy(buf, quark_str(o_ptr->inscription));
4278                                         s = buf;
4279                                         for (s = buf;*s && (*s != '#'); s++)
4280                                         {
4281 #ifdef JP
4282                                                 if (iskanji(*s)) s++;
4283 #endif
4284                                         }
4285                                         *s = '#';
4286                                         s++;
4287 #ifdef JP
4288  /*nothing*/
4289 #else
4290                                         *s++ = '\'';
4291 #endif
4292                                         t = quark_str(cap_nickname);
4293                                         while (*t)
4294                                         {
4295                                                 *s = *t;
4296                                                 s++;
4297                                                 t++;
4298                                         }
4299 #ifdef JP
4300  /*nothing*/
4301 #else
4302                                         *s++ = '\'';
4303 #endif
4304                                         *s = '\0';
4305                                         o_ptr->inscription = quark_add(buf);
4306                                 }
4307                         }
4308                 }
4309                 else
4310                 {
4311                         bool success = FALSE;
4312                         if (!get_rep_dir2(&dir)) return;
4313                         if (monster_can_enter(py + ddy[dir], px + ddx[dir], &r_info[o_ptr->pval], 0))
4314                         {
4315                                 if (place_monster_aux(0, py + ddy[dir], px + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
4316                                 {
4317                                         if (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
4318                                         if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
4319                                         if (o_ptr->xtra4) m_list[hack_m_idx_ii].hp = o_ptr->xtra4;
4320                                         m_list[hack_m_idx_ii].maxhp = m_list[hack_m_idx_ii].max_maxhp;
4321                                         if (o_ptr->inscription)
4322                                         {
4323                                                 char buf[80];
4324                                                 cptr t;
4325 #ifndef JP
4326                                                 bool quote = FALSE;
4327 #endif
4328
4329                                                 t = quark_str(o_ptr->inscription);
4330                                                 for (t = quark_str(o_ptr->inscription);*t && (*t != '#'); t++)
4331                                                 {
4332 #ifdef JP
4333                                                         if (iskanji(*t)) t++;
4334 #endif
4335                                                 }
4336                                                 if (*t)
4337                                                 {
4338                                                         char *s = buf;
4339                                                         t++;
4340 #ifdef JP
4341                                                         /* nothing */
4342 #else
4343                                                         if (*t =='\'')
4344                                                         {
4345                                                                 t++;
4346                                                                 quote = TRUE;
4347                                                         }
4348 #endif
4349                                                         while(*t)
4350                                                         {
4351                                                                 *s = *t;
4352                                                                 t++;
4353                                                                 s++;
4354                                                         }
4355 #ifdef JP
4356                                                         /* nothing */
4357 #else
4358                                                         if (quote && *(s-1) =='\'')
4359                                                                 s--;
4360 #endif
4361                                                         *s = '\0';
4362                                                         m_list[hack_m_idx_ii].nickname = quark_add(buf);
4363                                                         t = quark_str(o_ptr->inscription);
4364                                                         s = buf;
4365                                                         while(*t && (*t != '#'))
4366                                                         {
4367                                                                 *s = *t;
4368                                                                 t++;
4369                                                                 s++;
4370                                                         }
4371                                                         *s = '\0';
4372                                                         o_ptr->inscription = quark_add(buf);
4373                                                 }
4374                                         }
4375                                         o_ptr->pval = 0;
4376                                         o_ptr->xtra3 = 0;
4377                                         o_ptr->xtra4 = 0;
4378                                         o_ptr->xtra5 = 0;
4379                                         success = TRUE;
4380                                 }
4381                         }
4382                         if (!success)
4383 #ifdef JP
4384                                 msg_print("¤ª¤Ã¤È¡¢²òÊü¤Ë¼ºÇÔ¤·¤¿¡£");
4385 #else
4386                                 msg_print("Oops.  You failed to release your pet.");
4387 #endif
4388                 }
4389                 return;
4390         }
4391
4392         /* Mistake */
4393 #ifdef JP
4394         msg_print("¤ª¤Ã¤È¡¢¤³¤Î¥¢¥¤¥Æ¥à¤Ï»ÏÆ°¤Ç¤­¤Ê¤¤¡£");
4395 #else
4396         msg_print("Oops.  That object cannot be activated.");
4397 #endif
4398
4399 }
4400
4401
4402 void do_cmd_activate(void)
4403 {
4404         int     item;
4405         cptr    q, s;
4406
4407
4408         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
4409         {
4410                 set_action(ACTION_NONE);
4411         }
4412
4413         item_tester_no_ryoute = TRUE;
4414         /* Prepare the hook */
4415         item_tester_hook = item_tester_hook_activate;
4416
4417         /* Get an item */
4418 #ifdef JP
4419         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò»ÏÆ°¤µ¤»¤Þ¤¹¤«? ";
4420         s = "»ÏÆ°¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£";
4421 #else
4422         q = "Activate which item? ";
4423         s = "You have nothing to activate.";
4424 #endif
4425
4426         if (!get_item(&item, q, s, (USE_EQUIP))) return;
4427
4428         /* Activate the item */
4429         do_cmd_activate_aux(item);
4430 }
4431
4432
4433 /*
4434  * Hook to determine if an object is useable
4435  */
4436 static bool item_tester_hook_use(object_type *o_ptr)
4437 {
4438         u32b flgs[TR_FLAG_SIZE];
4439
4440         /* Ammo */
4441         if (o_ptr->tval == p_ptr->tval_ammo)
4442                 return (TRUE);
4443
4444         /* Useable object */
4445         switch (o_ptr->tval)
4446         {
4447                 case TV_SPIKE:
4448                 case TV_STAFF:
4449                 case TV_WAND:
4450                 case TV_ROD:
4451                 case TV_SCROLL:
4452                 case TV_POTION:
4453                 case TV_FOOD:
4454                 {
4455                         return (TRUE);
4456                 }
4457
4458                 default:
4459                 {
4460                         int i;
4461
4462                         /* Not known */
4463                         if (!object_is_known(o_ptr)) return (FALSE);
4464
4465                         /* HACK - only items from the equipment can be activated */
4466                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4467                         {
4468                                 if (&inventory[i] == o_ptr)
4469                                 {
4470                                         /* Extract the flags */
4471                                         object_flags(o_ptr, flgs);
4472
4473                                         /* Check activation flag */
4474                                         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
4475                                 }
4476                         }
4477                 }
4478         }
4479
4480         /* Assume not */
4481         return (FALSE);
4482 }
4483
4484
4485 /*
4486  * Use an item
4487  * XXX - Add actions for other item types
4488  */
4489 void do_cmd_use(void)
4490 {
4491         int         item;
4492         object_type *o_ptr;
4493         cptr        q, s;
4494
4495         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
4496         {
4497                 set_action(ACTION_NONE);
4498         }
4499
4500         item_tester_no_ryoute = TRUE;
4501         /* Prepare the hook */
4502         item_tester_hook = item_tester_hook_use;
4503
4504         /* Get an item */
4505 #ifdef JP
4506 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
4507 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4508 #else
4509         q = "Use which item? ";
4510         s = "You have nothing to use.";
4511 #endif
4512
4513         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
4514
4515         /* Get the item (in the pack) */
4516         if (item >= 0)
4517         {
4518                 o_ptr = &inventory[item];
4519         }
4520         /* Get the item (on the floor) */
4521         else
4522         {
4523                 o_ptr = &o_list[0 - item];
4524         }
4525
4526         switch (o_ptr->tval)
4527         {
4528                 /* Spike a door */
4529                 case TV_SPIKE:
4530                 {
4531                         do_cmd_spike();
4532                         break;
4533                 }
4534
4535                 /* Eat some food */
4536                 case TV_FOOD:
4537                 {
4538                         do_cmd_eat_food_aux(item);
4539                         break;
4540                 }
4541
4542                 /* Aim a wand */
4543                 case TV_WAND:
4544                 {
4545                         do_cmd_aim_wand_aux(item);
4546                         break;
4547                 }
4548
4549                 /* Use a staff */
4550                 case TV_STAFF:
4551                 {
4552                         do_cmd_use_staff_aux(item);
4553                         break;
4554                 }
4555
4556                 /* Zap a rod */
4557                 case TV_ROD:
4558                 {
4559                         do_cmd_zap_rod_aux(item);
4560                         break;
4561                 }
4562
4563                 /* Quaff a potion */
4564                 case TV_POTION:
4565                 {
4566                         do_cmd_quaff_potion_aux(item);
4567                         break;
4568                 }
4569
4570                 /* Read a scroll */
4571                 case TV_SCROLL:
4572                 {
4573                         /* Check some conditions */
4574                         if (p_ptr->blind)
4575                         {
4576 #ifdef JP
4577 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
4578 #else
4579                                 msg_print("You can't see anything.");
4580 #endif
4581
4582                                 return;
4583                         }
4584                         if (no_lite())
4585                         {
4586 #ifdef JP
4587 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
4588 #else
4589                                 msg_print("You have no light to read by.");
4590 #endif
4591
4592                                 return;
4593                         }
4594                         if (p_ptr->confused)
4595                         {
4596 #ifdef JP
4597 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
4598 #else
4599                                 msg_print("You are too confused!");
4600 #endif
4601
4602                                 return;
4603                         }
4604
4605                   do_cmd_read_scroll_aux(item, TRUE);
4606                   break;
4607                 }
4608
4609                 /* Fire ammo */
4610                 case TV_SHOT:
4611                 case TV_ARROW:
4612                 case TV_BOLT:
4613                 {
4614                         do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
4615                         break;
4616                 }
4617
4618                 /* Activate an artifact */
4619                 default:
4620                 {
4621                         do_cmd_activate_aux(item);
4622                         break;
4623                 }
4624         }
4625 }
4626
4627 static int select_magic_eater(bool only_browse)
4628 {
4629         int ext=0;
4630         char choice;
4631         bool flag, request_list;
4632         int tval = 0;
4633         int             ask = TRUE, i = 0;
4634         char            out_val[160];
4635
4636         int menu_line = (use_menu ? 1 : 0);
4637
4638 #ifdef ALLOW_REPEAT
4639         int sn;
4640         if (repeat_pull(&sn))
4641         {
4642                 /* Verify the spell */
4643                 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))
4644                         return sn;
4645                 else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE))
4646                         return sn;
4647         }
4648         
4649 #endif /* ALLOW_REPEAT */
4650
4651         for (i = 0; i < 108; i++)
4652         {
4653                 if (p_ptr->magic_num2[i]) break;
4654         }
4655         if (i == 108)
4656         {
4657 #ifdef JP
4658                 msg_print("ËâË¡¤ò³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
4659 #else
4660                 msg_print("You don't have any magic!");
4661 #endif
4662                 return -1;
4663         }
4664
4665         if (use_menu)
4666         {
4667                 screen_save();
4668
4669                 while(!tval)
4670                 {
4671 #ifdef JP
4672                         prt(format(" %s ¾ó", (menu_line == 1) ? "¡Õ" : "  "), 2, 14);
4673                         prt(format(" %s ËâË¡ËÀ", (menu_line == 2) ? "¡Õ" : "  "), 3, 14);
4674                         prt(format(" %s ¥í¥Ã¥É", (menu_line == 3) ? "¡Õ" : "  "), 4, 14);
4675 #else
4676                         prt(format(" %s staff", (menu_line == 1) ? "> " : "  "), 2, 14);
4677                         prt(format(" %s wand", (menu_line == 2) ? "> " : "  "), 3, 14);
4678                         prt(format(" %s rod", (menu_line == 3) ? "> " : "  "), 4, 14);
4679 #endif
4680
4681                         if (only_browse) prt(_("¤É¤Î¼ïÎà¤ÎËâË¡¤ò¸«¤Þ¤¹¤«¡©", "Which type of magic do you browse?"), 0, 0);
4682                         else prt(_("¤É¤Î¼ïÎà¤ÎËâË¡¤ò»È¤¤¤Þ¤¹¤«¡©", "Which type of magic do you use?"), 0, 0);
4683
4684                         choice = inkey();
4685                         switch(choice)
4686                         {
4687                         case ESCAPE:
4688                         case 'z':
4689                         case 'Z':
4690                                 screen_load();
4691                                 return -1;
4692                         case '2':
4693                         case 'j':
4694                         case 'J':
4695                                 menu_line++;
4696                                 break;
4697                         case '8':
4698                         case 'k':
4699                         case 'K':
4700                                 menu_line+= 2;
4701                                 break;
4702                         case '\r':
4703                         case 'x':
4704                         case 'X':
4705                                 ext = (menu_line-1)*EATER_EXT;
4706                                 if (menu_line == 1) tval = TV_STAFF;
4707                                 else if (menu_line == 2) tval = TV_WAND;
4708                                 else tval = TV_ROD;
4709                                 break;
4710                         }
4711                         if (menu_line > 3) menu_line -= 3;
4712                 }
4713                 screen_load();
4714         }
4715         else
4716         {
4717         while (TRUE)
4718         {
4719 #ifdef JP
4720                 if (!get_com("[A] ¾ó, [B] ËâË¡ËÀ, [C] ¥í¥Ã¥É:", &choice, TRUE))
4721 #else
4722                 if (!get_com("[A] staff, [B] wand, [C] rod:", &choice, TRUE))
4723 #endif
4724                 {
4725                         return -1;
4726                 }
4727                 if (choice == 'A' || choice == 'a')
4728                 {
4729                         ext = 0;
4730                         tval = TV_STAFF;
4731                         break;
4732                 }
4733                 if (choice == 'B' || choice == 'b')
4734                 {
4735                         ext = EATER_EXT;
4736                         tval = TV_WAND;
4737                         break;
4738                 }
4739                 if (choice == 'C' || choice == 'c')
4740                 {
4741                         ext = EATER_EXT*2;
4742                         tval = TV_ROD;
4743                         break;
4744                 }
4745         }
4746         }
4747         for (i = ext; i < ext + EATER_EXT; i++)
4748         {
4749                 if (p_ptr->magic_num2[i])
4750                 {
4751                         if (use_menu) menu_line = i-ext+1;
4752                         break;
4753                 }
4754         }
4755         if (i == ext+EATER_EXT)
4756         {
4757 #ifdef JP
4758                 msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
4759 #else
4760                 msg_print("You don't have that type of magic!");
4761 #endif
4762                 return -1;
4763         }
4764
4765         /* Nothing chosen yet */
4766         flag = FALSE;
4767
4768         /* Build a prompt */
4769         if (only_browse) strnfmt(out_val, 78, _("('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò¸«¤Þ¤¹¤«¡©",
4770                                                                                         "(*=List, ESC=exit) Browse which power? "));
4771         else strnfmt(out_val, 78, _("('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò»È¤¤¤Þ¤¹¤«¡©",
4772                                                                 "(*=List, ESC=exit) Use which power? "));
4773         
4774         /* Save the screen */
4775         screen_save();
4776
4777         request_list = always_show_list;
4778
4779         /* Get a spell from the user */
4780         while (!flag)
4781         {
4782                 /* Show the list */
4783                 if (request_list || use_menu)
4784                 {
4785                         byte y, x = 0;
4786                         int ctr, chance;
4787                         int k_idx;
4788                         char dummy[80];
4789                         int x1, y1, level;
4790                         byte col;
4791
4792                         strcpy(dummy, "");
4793
4794                         for (y = 1; y < 20; y++)
4795                                 prt("", y, x);
4796
4797                         y = 1;
4798
4799                         /* Print header(s) */
4800 #ifdef JP
4801                         prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
4802 #else
4803                         prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
4804 #endif
4805
4806                         /* Print list */
4807                         for (ctr = 0; ctr < EATER_EXT; ctr++)
4808                         {
4809                                 if (!p_ptr->magic_num2[ctr+ext]) continue;
4810
4811                                 k_idx = lookup_kind(tval, ctr);
4812
4813                                 if (use_menu)
4814                                 {
4815                                         if (ctr == (menu_line-1))
4816 #ifdef JP
4817                                                 strcpy(dummy, "¡Õ");
4818 #else
4819                                         strcpy(dummy, "> ");
4820 #endif
4821                                         else strcpy(dummy, "  ");
4822                                                 
4823                                 }
4824                                 /* letter/number for power selection */
4825                                 else
4826                                 {
4827                                         char letter;
4828                                         if (ctr < 26)
4829                                                 letter = I2A(ctr);
4830                                         else
4831                                                 letter = '0' + ctr - 26;
4832                                         sprintf(dummy, "%c)",letter);
4833                                 }
4834                                 x1 = ((ctr < EATER_EXT/2) ? x : x + 40);
4835                                 y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2);
4836                                 level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
4837                                 chance = level * 4 / 5 + 20;
4838                                 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4839                                 level /= 2;
4840                                 if (p_ptr->lev > level)
4841                                 {
4842                                         chance -= 3 * (p_ptr->lev - level);
4843                                 }
4844                                 chance = mod_spell_chance_1(chance);
4845                                 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
4846                                 /* Stunning makes spells harder */
4847                                 if (p_ptr->stun > 50) chance += 25;
4848                                 else if (p_ptr->stun) chance += 15;
4849
4850                                 if (chance > 95) chance = 95;
4851
4852                                 chance = mod_spell_chance_2(chance);
4853
4854                                 col = TERM_WHITE;
4855
4856                                 if (k_idx)
4857                                 {
4858                                         if (tval == TV_ROD)
4859                                         {
4860                                                 strcat(dummy, format(
4861 #ifdef JP
4862                                                                " %-22.22s ½¼Å¶:%2d/%2d%3d%%",
4863 #else
4864                                                                " %-22.22s   (%2d/%2d) %3d%%",
4865 #endif
4866                                                                k_name + k_info[k_idx].name, 
4867                                                                p_ptr->magic_num1[ctr+ext] ? 
4868                                                                (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, 
4869                                                                p_ptr->magic_num2[ctr+ext], chance));
4870                                                 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;
4871                                         }
4872                                         else
4873                                         {
4874                                                 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));
4875                                                 if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED;
4876                                         }
4877                                 }
4878                                 else
4879                                         strcpy(dummy, "");
4880                                 c_prt(col, dummy, y1, x1);
4881                         }
4882                 }
4883
4884                 if (!get_com(out_val, &choice, FALSE)) break;
4885
4886                 if (use_menu && choice != ' ')
4887                 {
4888                         switch (choice)
4889                         {
4890                                 case '0':
4891                                 {
4892                                         screen_load();
4893                                         return 0;
4894                                 }
4895
4896                                 case '8':
4897                                 case 'k':
4898                                 case 'K':
4899                                 {
4900                                         do
4901                                         {
4902                                                 menu_line += EATER_EXT - 1;
4903                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
4904                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
4905                                         break;
4906                                 }
4907
4908                                 case '2':
4909                                 case 'j':
4910                                 case 'J':
4911                                 {
4912                                         do
4913                                         {
4914                                                 menu_line++;
4915                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
4916                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
4917                                         break;
4918                                 }
4919
4920                                 case '4':
4921                                 case 'h':
4922                                 case 'H':
4923                                 case '6':
4924                                 case 'l':
4925                                 case 'L':
4926                                 {
4927                                         bool reverse = FALSE;
4928                                         if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
4929                                         if (menu_line > EATER_EXT/2)
4930                                         {
4931                                                 menu_line -= EATER_EXT/2;
4932                                                 reverse = TRUE;
4933                                         }
4934                                         else menu_line+=EATER_EXT/2;
4935                                         while(!p_ptr->magic_num2[menu_line+ext-1])
4936                                         {
4937                                                 if (reverse)
4938                                                 {
4939                                                         menu_line--;
4940                                                         if (menu_line < 2) reverse = FALSE;
4941                                                 }
4942                                                 else
4943                                                 {
4944                                                         menu_line++;
4945                                                         if (menu_line > EATER_EXT-1) reverse = TRUE;
4946                                                 }
4947                                         }
4948                                         break;
4949                                 }
4950
4951                                 case 'x':
4952                                 case 'X':
4953                                 case '\r':
4954                                 {
4955                                         i = menu_line - 1;
4956                                         ask = FALSE;
4957                                         break;
4958                                 }
4959                         }
4960                 }
4961
4962                 /* Request redraw */
4963                 if (use_menu && ask) continue;
4964
4965                 /* Request redraw */
4966                 if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?')))
4967                 {
4968                         /* Hide the list */
4969                         if (request_list)
4970                         {
4971                                 /* Hide list */
4972                                 request_list = FALSE;
4973                                 
4974                                 /* Restore the screen */
4975                                 screen_load();
4976                                 screen_save();
4977                         }
4978                         else
4979                                 request_list = TRUE;
4980
4981                         /* Redo asking */
4982                         continue;
4983                 }
4984
4985                 if (!use_menu)
4986                 {
4987                         if (isalpha(choice))
4988                         {
4989                                 /* Note verify */
4990                                 ask = (isupper(choice));
4991
4992                                 /* Lowercase */
4993                                 if (ask) choice = tolower(choice);
4994
4995                                 /* Extract request */
4996                                 i = (islower(choice) ? A2I(choice) : -1);
4997                         }
4998                         else
4999                         {
5000                                 ask = FALSE; /* Can't uppercase digits */
5001
5002                                 i = choice - '0' + 26;
5003                         }
5004                 }
5005
5006                 /* Totally Illegal */
5007                 if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext])
5008                 {
5009                         bell();
5010                         continue;
5011                 }
5012
5013                 if (!only_browse)
5014                 {
5015                         /* Verify it */
5016                         if (ask)
5017                         {
5018                                 char tmp_val[160];
5019
5020                                 /* Prompt */
5021 #ifdef JP
5022                                 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", k_name + k_info[lookup_kind(tval ,i)].name);
5023 #else
5024                                 (void) strnfmt(tmp_val, 78, "Use %s?", k_name + k_info[lookup_kind(tval ,i)].name);
5025 #endif
5026
5027                                 /* Belay that order */
5028                                 if (!get_check(tmp_val)) continue;
5029                         }
5030                         if (tval == TV_ROD)
5031                         {
5032                                 if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE)
5033                                 {
5034 #ifdef JP
5035                                         msg_print("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
5036 #else
5037                                         msg_print("The magic are still charging.");
5038 #endif
5039                                         msg_print(NULL);
5040                                         if (use_menu) ask = TRUE;
5041                                         continue;
5042                                 }
5043                         }
5044                         else
5045                         {
5046                                 if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
5047                                 {
5048 #ifdef JP
5049                                         msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
5050 #else
5051                                         msg_print("The magic has no charges left.");
5052 #endif
5053                                         msg_print(NULL);
5054                                         if (use_menu) ask = TRUE;
5055                                         continue;
5056                                 }
5057                         }
5058                 }
5059
5060                 /* Browse */
5061                 else
5062                 {
5063                         int line, j;
5064                         char temp[70 * 20];
5065
5066                         /* Clear lines, position cursor  (really should use strlen here) */
5067                         Term_erase(7, 23, 255);
5068                         Term_erase(7, 22, 255);
5069                         Term_erase(7, 21, 255);
5070                         Term_erase(7, 20, 255);
5071
5072                         roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp, sizeof(temp));
5073                         for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j]))
5074                         {
5075                                 prt(&temp[j], line, 10);
5076                                 line++;
5077                         }
5078
5079                         continue;
5080                 }
5081
5082                 /* Stop the loop */
5083                 flag = TRUE;
5084         }
5085
5086         /* Restore the screen */
5087         screen_load();
5088
5089         if (!flag) return -1;
5090
5091 #ifdef ALLOW_REPEAT
5092         repeat_push(ext+i);
5093 #endif /* ALLOW_REPEAT */
5094         return ext+i;
5095 }
5096
5097
5098 /*
5099  *  Use eaten rod, wand or staff
5100  */
5101 bool do_cmd_magic_eater(bool only_browse, bool powerful)
5102 {
5103         int item, chance, level, k_idx, tval, sval;
5104         bool use_charge = TRUE;
5105
5106         /* Not when confused */
5107         if (!only_browse && p_ptr->confused)
5108         {
5109 #ifdef JP
5110 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
5111 #else
5112                 msg_print("You are too confused!");
5113 #endif
5114
5115                 return FALSE;
5116         }
5117
5118         item = select_magic_eater(only_browse);
5119         if (item == -1)
5120         {
5121                 energy_use = 0;
5122                 return FALSE;
5123         }
5124         if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
5125         else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
5126         else {tval = TV_STAFF;sval = item;}
5127         k_idx = lookup_kind(tval, sval);
5128
5129         level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
5130         chance = level * 4 / 5 + 20;
5131         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
5132         level /= 2;
5133         if (p_ptr->lev > level)
5134         {
5135                 chance -= 3 * (p_ptr->lev - level);
5136         }
5137         chance = mod_spell_chance_1(chance);
5138         chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
5139         /* Stunning makes spells harder */
5140         if (p_ptr->stun > 50) chance += 25;
5141         else if (p_ptr->stun) chance += 15;
5142
5143         if (chance > 95) chance = 95;
5144
5145         chance = mod_spell_chance_2(chance);
5146
5147         if (randint0(100) < chance)
5148         {
5149                 if (flush_failure) flush();
5150
5151 #ifdef JP
5152 msg_print("¼öʸ¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª");
5153 #else
5154                 msg_format("You failed to get the magic off!");
5155 #endif
5156
5157                 sound(SOUND_FAIL);
5158                 if (randint1(100) >= chance)
5159                         chg_virtue(V_CHANCE,-1);
5160                 energy_use = 100;
5161
5162                 return TRUE;
5163         }
5164         else
5165         {
5166                 int dir = 0;
5167
5168                 if (tval == TV_ROD)
5169                 {
5170                         if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
5171                                 if (!get_aim_dir(&dir)) return FALSE;
5172                         rod_effect(sval, dir, &use_charge, powerful, TRUE);
5173                         if (!use_charge) return FALSE;
5174                 }
5175                 else if (tval == TV_WAND)
5176                 {
5177                         if (!get_aim_dir(&dir)) return FALSE;
5178                         wand_effect(sval, dir, powerful, TRUE);
5179                 }
5180                 else
5181                 {
5182                         staff_effect(sval, &use_charge, powerful, TRUE, TRUE);
5183                         if (!use_charge) return FALSE;
5184                 }
5185                 if (randint1(100) < chance)
5186                         chg_virtue(V_CHANCE,1);
5187         }
5188         energy_use = 100;
5189         if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
5190         else p_ptr->magic_num1[item] -= EATER_CHARGE;
5191
5192         return TRUE;
5193 }