OSDN Git Service

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