OSDN Git Service

[Refactor] #37353 object-ego.c/h を作成して関連構造体と変数を移動.
[hengband/hengband.git] / src / object1.c
1 /*!
2  * @file object1.c
3  * @brief オブジェクトの実装 / Object code, part 1
4  * @date 2014/01/10
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7  *\n
8  * This software may be copied and distributed for educational, research,\n
9  * and not for profit purposes provided that this copyright and statement\n
10  * are included in all such copies.  Other copyrights may also apply.\n
11  * 2014 Deskull rearranged comment for Doxygen.\n
12  */
13
14 #include "angband.h"
15 #include "util.h"
16
17 #include "artifact.h"
18 #include "floor.h"
19 #include "cmd-activate.h"
20 #include "objectkind.h"
21 #include "object-ego.h"
22 #include "object-flavor.h"
23 #include "object-hook.h"
24 #include "player-move.h"
25 #include "monster.h"
26 #include "files.h"
27
28 #if defined(MACINTOSH) || defined(MACH_O_CARBON)
29 #ifdef verify
30 #undef verify
31 #endif
32 #endif
33
34 /*!
35  * @brief オブジェクト、地形の表示シンボルなど初期化する / Reset the "visual" lists
36  * @return なし
37  * This involves resetting various things to their "default" state.\n
38  *\n
39  * If the "prefs" flag is TRUE, then we will also load the appropriate\n
40  * "user pref file" based on the current setting of the "use_graphics"\n
41  * flag.  This is useful for switching "graphics" on/off.\n
42  *\n
43  * The features, objects, and monsters, should all be encoded in the\n
44  * relevant "font.pref" and/or "graf.prf" files.  \n
45  *\n
46  * The "prefs" parameter is no longer meaningful.  \n
47  */
48 void reset_visuals(void)
49 {
50         int i, j;
51
52         /* Extract some info about terrain features */
53         for (i = 0; i < max_f_idx; i++)
54         {
55                 feature_type *f_ptr = &f_info[i];
56
57                 /* Assume we will use the underlying values */
58                 for (j = 0; j < F_LIT_MAX; j++)
59                 {
60                         f_ptr->x_attr[j] = f_ptr->d_attr[j];
61                         f_ptr->x_char[j] = f_ptr->d_char[j];
62                 }
63         }
64
65         /* Extract default attr/char code for objects */
66         for (i = 0; i < max_k_idx; i++)
67         {
68                 object_kind *k_ptr = &k_info[i];
69
70                 /* Default attr/char */
71                 k_ptr->x_attr = k_ptr->d_attr;
72                 k_ptr->x_char = k_ptr->d_char;
73         }
74
75         /* Extract default attr/char code for monsters */
76         for (i = 0; i < max_r_idx; i++)
77         {
78                 monster_race *r_ptr = &r_info[i];
79
80                 /* Default attr/char */
81                 r_ptr->x_attr = r_ptr->d_attr;
82                 r_ptr->x_char = r_ptr->d_char;
83         }
84
85         if (use_graphics)
86         {
87                 char buf[1024];
88
89                 /* Process "graf.prf" */
90                 process_pref_file("graf.prf");
91
92                 /* Access the "character" pref file */
93                 sprintf(buf, "graf-%s.prf", player_base);
94
95                 /* Process "graf-<playername>.prf" */
96                 process_pref_file(buf);
97         }
98
99         /* Normal symbols */
100         else
101         {
102                 char buf[1024];
103
104                 /* Process "font.prf" */
105                 process_pref_file("font.prf");
106
107                 /* Access the "character" pref file */
108                 sprintf(buf, "font-%s.prf", player_base);
109
110                 /* Process "font-<playername>.prf" */
111                 process_pref_file(buf);
112         }
113 }
114
115 /*!
116  * @brief オブジェクトのフラグ類を配列に与える
117  * Obtain the "flags" for an item
118  * @param o_ptr フラグ取得元のオブジェクト構造体ポインタ
119  * @param flgs フラグ情報を受け取る配列
120  * @return なし
121  */
122 void object_flags(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
123 {
124         object_kind *k_ptr = &k_info[o_ptr->k_idx];
125         int i;
126
127         /* Base object */
128         for (i = 0; i < TR_FLAG_SIZE; i++)
129                 flgs[i] = k_ptr->flags[i];
130
131         /* Artifact */
132         if (object_is_fixed_artifact(o_ptr))
133         {
134                 artifact_type *a_ptr = &a_info[o_ptr->name1];
135
136                 for (i = 0; i < TR_FLAG_SIZE; i++)
137                         flgs[i] = a_ptr->flags[i];
138         }
139
140         /* Ego-item */
141         if (object_is_ego(o_ptr))
142         {
143                 ego_item_type *e_ptr = &e_info[o_ptr->name2];
144
145                 for (i = 0; i < TR_FLAG_SIZE; i++)
146                         flgs[i] |= e_ptr->flags[i];
147
148                 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
149                 {
150                         remove_flag(flgs, TR_SH_FIRE);
151                 }
152                 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
153                 {
154                         remove_flag(flgs, TR_INFRA);
155                 }
156                 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
157                 {
158                         remove_flag(flgs, TR_RES_BLIND);
159                         remove_flag(flgs, TR_SEE_INVIS);
160                 }
161         }
162
163         /* Random artifact ! */
164         for (i = 0; i < TR_FLAG_SIZE; i++)
165                 flgs[i] |= o_ptr->art_flags[i];
166
167         if (object_is_smith(o_ptr))
168         {
169                 int add = o_ptr->xtra3 - 1;
170
171                 if (add < TR_FLAG_MAX)
172                 {
173                         add_flag(flgs, add);
174                 }
175                 else if (add == ESSENCE_TMP_RES_ACID)
176                 {
177                         add_flag(flgs, TR_RES_ACID);
178                         add_flag(flgs, TR_ACTIVATE);
179                 }
180                 else if (add == ESSENCE_TMP_RES_ELEC)
181                 {
182                         add_flag(flgs, TR_RES_ELEC);
183                         add_flag(flgs, TR_ACTIVATE);
184                 }
185                 else if (add == ESSENCE_TMP_RES_FIRE)
186                 {
187                         add_flag(flgs, TR_RES_FIRE);
188                         add_flag(flgs, TR_ACTIVATE);
189                 }
190                 else if (add == ESSENCE_TMP_RES_COLD)
191                 {
192                         add_flag(flgs, TR_RES_COLD);
193                         add_flag(flgs, TR_ACTIVATE);
194                 }
195                 else if (add == ESSENCE_SH_FIRE)
196                 {
197                         add_flag(flgs, TR_RES_FIRE);
198                         add_flag(flgs, TR_SH_FIRE);
199                 }
200                 else if (add == ESSENCE_SH_ELEC)
201                 {
202                         add_flag(flgs, TR_RES_ELEC);
203                         add_flag(flgs, TR_SH_ELEC);
204                 }
205                 else if (add == ESSENCE_SH_COLD)
206                 {
207                         add_flag(flgs, TR_RES_COLD);
208                         add_flag(flgs, TR_SH_COLD);
209                 }
210                 else if (add == ESSENCE_RESISTANCE)
211                 {
212                         add_flag(flgs, TR_RES_ACID);
213                         add_flag(flgs, TR_RES_ELEC);
214                         add_flag(flgs, TR_RES_FIRE);
215                         add_flag(flgs, TR_RES_COLD);
216                 }
217                 else if (add == TR_IMPACT)
218                 {
219                         add_flag(flgs, TR_ACTIVATE);
220                 }
221         }
222 }
223
224 /*!
225  * @brief オブジェクトの明示されているフラグ類を取得する
226  * Obtain the "flags" for an item which are known to the player
227  * @param o_ptr フラグ取得元のオブジェクト構造体ポインタ
228  * @param flgs フラグ情報を受け取る配列
229  * @return なし
230  */
231 void object_flags_known(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
232 {
233         bool spoil = FALSE;
234         int i;
235
236         object_kind *k_ptr = &k_info[o_ptr->k_idx];
237
238         /* Clear */
239         for (i = 0; i < TR_FLAG_SIZE; i++)
240                 flgs[i] = 0;
241
242         if (!object_is_aware(o_ptr)) return;
243
244         /* Base object */
245         for (i = 0; i < TR_FLAG_SIZE; i++)
246                 flgs[i] = k_ptr->flags[i];
247
248         /* Must be identified */
249         if (!object_is_known(o_ptr)) return;
250
251         /* Ego-item (known basic flags) */
252         if (object_is_ego(o_ptr))
253         {
254                 ego_item_type *e_ptr = &e_info[o_ptr->name2];
255
256                 for (i = 0; i < TR_FLAG_SIZE; i++)
257                         flgs[i] |= e_ptr->flags[i];
258
259                 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
260                 {
261                         remove_flag(flgs, TR_SH_FIRE);
262                 }
263                 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
264                 {
265                         remove_flag(flgs, TR_INFRA);
266                 }
267                 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
268                 {
269                         remove_flag(flgs, TR_RES_BLIND);
270                         remove_flag(flgs, TR_SEE_INVIS);
271                 }
272         }
273
274
275 #ifdef SPOIL_ARTIFACTS
276         /* Full knowledge for some artifacts */
277         if (object_is_artifact(o_ptr)) spoil = TRUE;
278 #endif /* SPOIL_ARTIFACTS */
279
280 #ifdef SPOIL_EGO_ITEMS
281         /* Full knowledge for some ego-items */
282         if (object_is_ego(o_ptr)) spoil = TRUE;
283 #endif /* SPOIL_EGO_ITEMS */
284
285         /* Need full knowledge or spoilers */
286         if (spoil || (o_ptr->ident & IDENT_MENTAL))
287         {
288                 /* Artifact */
289                 if (object_is_fixed_artifact(o_ptr))
290                 {
291                         artifact_type *a_ptr = &a_info[o_ptr->name1];
292
293                         for (i = 0; i < TR_FLAG_SIZE; i++)
294                                 flgs[i] = a_ptr->flags[i];
295                 }
296
297                 /* Random artifact ! */
298                 for (i = 0; i < TR_FLAG_SIZE; i++)
299                         flgs[i] |= o_ptr->art_flags[i];
300         }
301
302         if (object_is_smith(o_ptr))
303         {
304                 int add = o_ptr->xtra3 - 1;
305
306                 if (add < TR_FLAG_MAX)
307                 {
308                         add_flag(flgs, add);
309                 }
310                 else if (add == ESSENCE_TMP_RES_ACID)
311                 {
312                         add_flag(flgs, TR_RES_ACID);
313                 }
314                 else if (add == ESSENCE_TMP_RES_ELEC)
315                 {
316                         add_flag(flgs, TR_RES_ELEC);
317                 }
318                 else if (add == ESSENCE_TMP_RES_FIRE)
319                 {
320                         add_flag(flgs, TR_RES_FIRE);
321                 }
322                 else if (add == ESSENCE_TMP_RES_COLD)
323                 {
324                         add_flag(flgs, TR_RES_COLD);
325                 }
326                 else if (add == ESSENCE_SH_FIRE)
327                 {
328                         add_flag(flgs, TR_RES_FIRE);
329                         add_flag(flgs, TR_SH_FIRE);
330                 }
331                 else if (add == ESSENCE_SH_ELEC)
332                 {
333                         add_flag(flgs, TR_RES_ELEC);
334                         add_flag(flgs, TR_SH_ELEC);
335                 }
336                 else if (add == ESSENCE_SH_COLD)
337                 {
338                         add_flag(flgs, TR_RES_COLD);
339                         add_flag(flgs, TR_SH_COLD);
340                 }
341                 else if (add == ESSENCE_RESISTANCE)
342                 {
343                         add_flag(flgs, TR_RES_ACID);
344                         add_flag(flgs, TR_RES_ELEC);
345                         add_flag(flgs, TR_RES_FIRE);
346                         add_flag(flgs, TR_RES_COLD);
347                 }
348         }
349 }
350
351 /*!
352  * @brief オブジェクトの発動効果名称を返す(サブルーチン/ブレス)
353  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
354  * @return concptr 発動名称を返す文字列ポインタ
355  */
356 static concptr item_activation_dragon_breath(object_type *o_ptr)
357 {
358         static char desc[256];
359         BIT_FLAGS flgs[TR_FLAG_SIZE]; /* for resistance flags */
360         int i, n = 0;
361
362         object_flags(o_ptr, flgs);
363         strcpy(desc, _("", "breath "));
364
365         for (i = 0; dragonbreath_info[i].flag != 0; i++)
366         {
367                 if (have_flag(flgs, dragonbreath_info[i].flag))
368                 {
369                         if (n > 0) strcat(desc, _("、", ", "));
370                         strcat(desc, dragonbreath_info[i].name);
371                         n++;
372                 }
373         }
374
375         strcat(desc, _("のブレス(250)", ""));
376
377         return (desc);
378 }
379
380 /*!
381  * @brief オブジェクトの発動効果名称を返す(サブルーチン/汎用)
382  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
383  * @return concptr 発動名称を返す文字列ポインタ
384  */
385 static concptr item_activation_aux(object_type *o_ptr)
386 {
387         static char activation_detail[256];
388         concptr desc;
389         char timeout[32];
390         int constant, dice;
391         const activation_type* const act_ptr = find_activation_info(o_ptr);
392
393         if (!act_ptr) return _("未定義", "something undefined");
394
395         desc = act_ptr->desc;
396
397         /* Overwrite description if it is special */
398         switch (act_ptr->index) {
399         case ACT_BR_FIRE:
400                 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
401                         desc = _("火炎のブレス (200) と火への耐性", "breath of fire (200) and resist fire");
402                 break;
403         case ACT_BR_COLD:
404                 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE))
405                         desc = _("冷気のブレス (200) と冷気への耐性", "breath of cold (200) and resist cold");
406                 break;
407         case ACT_BR_DRAGON:
408                 desc = item_activation_dragon_breath(o_ptr);
409                 break;
410         case ACT_AGGRAVATE:
411                 if (o_ptr->name1 == ART_HYOUSIGI)
412                         desc = _("拍子木を打ちならす", "beat wooden clappers");
413                 break;
414         case ACT_RESIST_ACID:
415                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ACID)) || (o_ptr->name2 == EGO_BRAND_ACID))
416                         desc = _("アシッド・ボール (100) と酸への耐性", "ball of acid (100) and resist acid");
417                 break;
418         case ACT_RESIST_FIRE:
419                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) || (o_ptr->name2 == EGO_BRAND_FIRE))
420                         desc = _("ファイア・ボール (100) と火への耐性", "ball of fire (100) and resist fire");
421                 break;
422         case ACT_RESIST_COLD:
423                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) || (o_ptr->name2 == EGO_BRAND_COLD))
424                         desc = _("アイス・ボール (100) と冷気への耐性", "ball of cold (100) and resist cold");
425                 break;
426         case ACT_RESIST_ELEC:
427                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ELEC)) || (o_ptr->name2 == EGO_BRAND_ELEC))
428                         desc = _("サンダー・ボール (100) と電撃への耐性", "ball of elec (100) and resist elec");
429                 break;
430         case ACT_RESIST_POIS:
431                 if (o_ptr->name2 == EGO_BRAND_POIS)
432                         desc = _("悪臭雲 (100) と毒への耐性", "ball of poison (100) and resist elec");
433                 break;
434         }
435
436         /* Timeout description */
437         constant = act_ptr->timeout.constant;
438         dice = act_ptr->timeout.dice;
439         if (constant == 0 && dice == 0) {
440                 /* We can activate it every current_world_ptr->game_turn */
441                 strcpy(timeout, _("いつでも", "every current_world_ptr->game_turn"));
442         } else if (constant < 0) {
443                 /* Activations that have special timeout */
444                 switch (act_ptr->index) {
445                 case ACT_BR_FIRE:
446                         sprintf(timeout, _("%d ターン毎", "every %d turns"),
447                                 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250);
448                         break;
449                 case ACT_BR_COLD:
450                         sprintf(timeout, _("%d ターン毎", "every %d turns"),
451                                 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250);
452                         break;
453                 case ACT_TERROR:
454                         strcpy(timeout, _("3*(レベル+10) ターン毎", "every 3 * (level+10) turns"));
455                         break;
456                 case ACT_MURAMASA:
457                         strcpy(timeout, _("確率50%で壊れる", "(destroyed 50%)"));
458                         break;
459                 default:
460                         strcpy(timeout, "undefined");
461                         break;
462                 }
463         } else {
464                 /* Normal timeout activations */
465                 char constant_str[16], dice_str[16];
466                 sprintf(constant_str, "%d", constant);
467                 sprintf(dice_str, "d%d", dice);
468                 sprintf(timeout, _("%s%s%s ターン毎", "every %s%s%s turns"),
469                         (constant > 0) ? constant_str : "",
470                         (constant > 0 && dice > 0) ? "+" : "",
471                         (dice > 0) ? dice_str : "");
472         }
473
474         /* Build detail activate description */
475         sprintf(activation_detail, _("%s : %s", "%s %s"), desc, timeout);
476
477         return activation_detail;
478 }
479
480 /*!
481  * @brief オブジェクトの発動効果名称を返す(メインルーチン) /
482  * Determine the "Activation" (if any) for an artifact Return a string, or NULL for "no activation"
483  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
484  * @return concptr 発動名称を返す文字列ポインタ
485  */
486 concptr item_activation(object_type *o_ptr)
487 {
488         BIT_FLAGS flgs[TR_FLAG_SIZE];
489         object_flags(o_ptr, flgs);
490
491         /* Require activation ability */
492         if (!(have_flag(flgs, TR_ACTIVATE))) return (_("なし", "nothing"));
493
494         /* Get an explain of an activation */
495         if (activation_index(o_ptr))
496         {
497                 return item_activation_aux(o_ptr);
498         }
499
500         /* Special items */
501         if (o_ptr->tval == TV_WHISTLE)
502         {
503                 return _("ペット呼び寄せ : 100+d100ターン毎", "call pet every 100+d100 turns");
504         }
505
506         if (o_ptr->tval == TV_CAPTURE)
507         {
508                 return _("モンスターを捕える、又は解放する。", "captures or releases a monster.");
509         }
510
511         return _("何も起きない", "Nothing");
512 }
513
514
515 /*!
516  * @brief オブジェクトの*鑑定*内容を詳述して表示する /
517  * Describe a "fully identified" item
518  * @param o_ptr *鑑定*情報を取得する元のオブジェクト構造体参照ポインタ
519  * @param mode 表示オプション
520  * @return 特筆すべき情報が一つでもあった場合TRUE、一つもなく表示がキャンセルされた場合FALSEを返す。
521  */
522 bool screen_object(object_type *o_ptr, BIT_FLAGS mode)
523 {
524         int i = 0, j, k;
525
526         BIT_FLAGS flgs[TR_FLAG_SIZE];
527
528         char temp[70 * 20];
529         concptr            info[128];
530         GAME_TEXT o_name[MAX_NLEN];
531         int wid, hgt;
532         POSITION rad;
533         char desc[256];
534
535         int trivial_info = 0;
536         object_flags(o_ptr, flgs);
537
538         /* Extract the description */
539         {
540                 roff_to_buf(o_ptr->name1 ? (a_text + a_info[o_ptr->name1].text) :
541                             (k_text + k_info[o_ptr->k_idx].text),
542                             77 - 15, temp, sizeof(temp));
543                 for (j = 0; temp[j]; j += 1 + strlen(&temp[j]))
544                 { info[i] = &temp[j]; i++;}
545         }
546
547         if (object_is_equipment(o_ptr))
548         {
549                 /* Descriptions of a basic equipment is just a flavor */
550                 trivial_info = i;
551         }
552
553         /* Mega-Hack -- describe activation */
554         if (have_flag(flgs, TR_ACTIVATE))
555         {
556                 info[i++] = _("始動したときの効果...", "It can be activated for...");
557                 info[i++] = item_activation(o_ptr);
558                 info[i++] = _("...ただし装備していなければならない。", "...if it is being worn.");
559         }
560
561         /* Figurines, a hack */
562         if (o_ptr->tval == TV_FIGURINE)
563         {
564                 info[i++] = _("それは投げた時ペットに変化する。", "It will transform into a pet when thrown.");
565         }
566
567         /* Figurines, a hack */
568         if (o_ptr->name1 == ART_STONEMASK)
569         {
570                 info[i++] = _("それを装備した者は吸血鬼になる。", "It makes you current_world_ptr->game_turn into a vampire permanently.");
571         }
572
573         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
574         {
575                 info[i++] = _("それは相手を一撃で倒すことがある。", "It will attempt to kill a monster instantly.");
576         }
577
578         if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
579         {
580                 info[i++] = _("それは自分自身に攻撃が返ってくることがある。", "It causes you to strike yourself sometimes.");
581                 info[i++] = _("それは無敵のバリアを切り裂く。", "It always penetrates invulnerability barriers.");
582         }
583
584         if (o_ptr->name2 == EGO_2WEAPON)
585         {
586                 info[i++] = _("それは二刀流での命中率を向上させる。", "It affects your ability to hit when you are wielding two weapons.");
587         }
588
589         if (have_flag(flgs, TR_EASY_SPELL))
590         {
591                 info[i++] = _("それは魔法の難易度を下げる。", "It affects your ability to cast spells.");
592         }
593
594         if (o_ptr->name2 == EGO_AMU_FOOL)
595         {
596                 info[i++] = _("それは魔法の難易度を上げる。", "It interferes with casting spells.");
597         }
598
599         if (o_ptr->name2 == EGO_RING_THROW)
600         {
601                 info[i++] = _("それは物を強く投げることを可能にする。", "It provides great strength when you throw an item.");
602         }
603
604         if (o_ptr->name2 == EGO_AMU_NAIVETY)
605         {
606                 info[i++] = _("それは魔法抵抗力を下げる。", "It decreases your magic resistance.");
607         }
608
609         if (o_ptr->tval == TV_STATUE)
610         {
611                 monster_race *r_ptr = &r_info[o_ptr->pval];
612
613                 if (o_ptr->pval == MON_BULLGATES)
614                         info[i++] = _("それは部屋に飾ると恥ずかしい。", "It is shameful.");
615                 else if ( r_ptr->flags2 & (RF2_ELDRITCH_HORROR))
616                         info[i++] = _("それは部屋に飾ると恐い。", "It is fearful.");
617                 else
618                         info[i++] = _("それは部屋に飾ると楽しい。", "It is cheerful.");
619         }
620         
621         /* Hack -- describe lite's */
622         
623         if (o_ptr->name2 == EGO_LITE_DARKNESS) info[i++] = _("それは全く光らない。", "It provides no light.");
624         
625         rad = 0;
626         if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 1;
627         if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 2;
628         if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 3;
629         if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
630         if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
631         if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
632         
633         if(o_ptr->name2 == EGO_LITE_SHINE) rad++;
634                 
635         if (have_flag(flgs, TR_LITE_FUEL) && o_ptr->name2 != EGO_LITE_DARKNESS)
636         {
637                 if(rad > 0) sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), (int)rad);   
638         }
639         else
640         {
641                 if(rad > 0) sprintf(desc, _("それは永遠なる明かり(半径 %d)を授ける。", "It provides light (radius %d) forever."), (int)rad);
642                 if(rad < 0) sprintf(desc, _("それは明かりの半径を狭める(半径に-%d)。", "It decreases radius of light source by %d."), (int)-rad);
643         }
644         
645         if(rad != 0) info[i++] = desc;
646
647         
648         if (o_ptr->name2 == EGO_LITE_LONG)
649         {
650                 info[i++] = _("それは長いターン明かりを授ける。", "It provides light for much longer time.");
651         }
652
653         /* And then describe it fully */
654
655         if (have_flag(flgs, TR_RIDING))
656         {
657                 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
658                         info[i++] = _("それは乗馬中は非常に使いやすい。", "It is made for use while riding.");
659                 else
660                 {
661                         info[i++] = _("それは乗馬中でも使いやすい。", "It is suitable for use while riding.");
662                         /* This information is not important enough */
663                         trivial_info++;
664                 }
665         }
666         if (have_flag(flgs, TR_STR))
667         {
668                 info[i++] = _("それは腕力に影響を及ぼす。", "It affects your strength.");
669         }
670         if (have_flag(flgs, TR_INT))
671         {
672                 info[i++] = _("それは知能に影響を及ぼす。", "It affects your intelligence.");
673         }
674         if (have_flag(flgs, TR_WIS))
675         {
676                 info[i++] = _("それは賢さに影響を及ぼす。", "It affects your wisdom.");
677         }
678         if (have_flag(flgs, TR_DEX))
679         {
680                 info[i++] = _("それは器用さに影響を及ぼす。", "It affects your dexterity.");
681         }
682         if (have_flag(flgs, TR_CON))
683         {
684                 info[i++] = _("それは耐久力に影響を及ぼす。", "It affects your constitution.");
685         }
686         if (have_flag(flgs, TR_CHR))
687         {
688                 info[i++] = _("それは魅力に影響を及ぼす。", "It affects your charisma.");
689         }
690
691         if (have_flag(flgs, TR_MAGIC_MASTERY))
692         {
693                 info[i++] = _("それは魔法道具使用能力に影響を及ぼす。", "It affects your ability to use magic devices.");
694
695         }
696         if (have_flag(flgs, TR_STEALTH))
697         {
698                 info[i++] = _("それは隠密行動能力に影響を及ぼす。", "It affects your stealth.");
699         }
700         if (have_flag(flgs, TR_SEARCH))
701         {
702                 info[i++] = _("それは探索能力に影響を及ぼす。", "It affects your searching.");
703         }
704         if (have_flag(flgs, TR_INFRA))
705         {
706                 info[i++] = _("それは赤外線視力に影響を及ぼす。", "It affects your infravision.");
707         }
708         if (have_flag(flgs, TR_TUNNEL))
709         {
710                 info[i++] = _("それは採掘能力に影響を及ぼす。", "It affects your ability to tunnel.");
711         }
712         if (have_flag(flgs, TR_SPEED))
713         {
714                 info[i++] = _("それはスピードに影響を及ぼす。", "It affects your speed.");
715         }
716         if (have_flag(flgs, TR_BLOWS))
717         {
718                 info[i++] = _("それは打撃回数に影響を及ぼす。", "It affects your attack speed.");
719         }
720
721         if (have_flag(flgs, TR_BRAND_ACID))
722         {
723                 info[i++] = _("それは酸によって大きなダメージを与える。", "It does extra damage from acid.");
724         }
725         if (have_flag(flgs, TR_BRAND_ELEC))
726         {
727                 info[i++] = _("それは電撃によって大きなダメージを与える。", "It does extra damage from electricity.");
728         }
729         if (have_flag(flgs, TR_BRAND_FIRE))
730         {
731                 info[i++] = _("それは火炎によって大きなダメージを与える。", "It does extra damage from fire.");
732         }
733         if (have_flag(flgs, TR_BRAND_COLD))
734         {
735                 info[i++] = _("それは冷気によって大きなダメージを与える。", "It does extra damage from frost.");
736         }
737
738         if (have_flag(flgs, TR_BRAND_POIS))
739         {
740                 info[i++] = _("それは敵を毒する。", "It poisons your foes.");
741         }
742
743         if (have_flag(flgs, TR_CHAOTIC))
744         {
745                 info[i++] = _("それはカオス的な効果を及ぼす。", "It produces chaotic effects.");
746         }
747
748         if (have_flag(flgs, TR_VAMPIRIC))
749         {
750                 info[i++] = _("それは敵から生命力を吸収する。", "It drains life from your foes.");
751         }
752
753         if (have_flag(flgs, TR_IMPACT))
754         {
755                 info[i++] = _("それは地震を起こすことができる。", "It can cause earthquakes.");
756         }
757
758         if (have_flag(flgs, TR_VORPAL))
759         {
760                 info[i++] = _("それは非常に切れ味が鋭く敵を切断することができる。", "It is very sharp and can cut your foes.");
761         }
762
763         if (have_flag(flgs, TR_KILL_DRAGON))
764         {
765                 info[i++] = _("それはドラゴンにとっての天敵である。", "It is a great bane of dragons.");
766         }
767         else if (have_flag(flgs, TR_SLAY_DRAGON))
768         {
769                 info[i++] = _("それはドラゴンに対して特に恐るべき力を発揮する。", "It is especially deadly against dragons.");
770         }
771
772         if (have_flag(flgs, TR_KILL_ORC))
773         {
774                 info[i++] = _("それはオークにとっての天敵である。", "It is a great bane of orcs.");
775         }
776         if (have_flag(flgs, TR_SLAY_ORC))
777         {
778                 info[i++] = _("それはオークに対して特に恐るべき力を発揮する。", "It is especially deadly against orcs.");
779         }
780
781         if (have_flag(flgs, TR_KILL_TROLL))
782         {
783                 info[i++] = _("それはトロルにとっての天敵である。", "It is a great bane of trolls.");
784         }
785         if (have_flag(flgs, TR_SLAY_TROLL))
786         {
787                 info[i++] = _("それはトロルに対して特に恐るべき力を発揮する。", "It is especially deadly against trolls.");
788         }
789
790         if (have_flag(flgs, TR_KILL_GIANT))
791         {
792                 info[i++] = _("それは巨人にとっての天敵である。", "It is a great bane of giants.");
793         }
794         else if (have_flag(flgs, TR_SLAY_GIANT))
795         {
796                 info[i++] = _("それはジャイアントに対して特に恐るべき力を発揮する。", "It is especially deadly against giants.");
797         }
798
799         if (have_flag(flgs, TR_KILL_DEMON))
800         {
801                 info[i++] = _("それはデーモンにとっての天敵である。", "It is a great bane of demons.");
802         }
803         if (have_flag(flgs, TR_SLAY_DEMON))
804         {
805                 info[i++] = _("それはデーモンに対して聖なる力を発揮する。", "It strikes at demons with holy wrath.");
806         }
807
808         if (have_flag(flgs, TR_KILL_UNDEAD))
809         {
810                 info[i++] = _("それはアンデッドにとっての天敵である。", "It is a great bane of undead.");
811         }
812         if (have_flag(flgs, TR_SLAY_UNDEAD))
813         {
814                 info[i++] = _("それはアンデッドに対して聖なる力を発揮する。", "It strikes at undead with holy wrath.");
815         }
816
817         if (have_flag(flgs, TR_KILL_EVIL))
818         {
819                 info[i++] = _("それは邪悪なる存在にとっての天敵である。", "It is a great bane of evil monsters.");
820         }
821         if (have_flag(flgs, TR_SLAY_EVIL))
822         {
823                 info[i++] = _("それは邪悪なる存在に対して聖なる力で攻撃する。", "It fights against evil with holy fury.");
824         }
825
826         if (have_flag(flgs, TR_KILL_ANIMAL))
827         {
828                 info[i++] = _("それは自然界の動物にとっての天敵である。", "It is a great bane of natural creatures.");
829         }
830         if (have_flag(flgs, TR_SLAY_ANIMAL))
831         {
832                 info[i++] = _("それは自然界の動物に対して特に恐るべき力を発揮する。", "It is especially deadly against natural creatures.");
833         }
834
835         if (have_flag(flgs, TR_KILL_HUMAN))
836         {
837                 info[i++] = _("それは人間にとっての天敵である。", "It is a great bane of humans.");
838         }
839         if (have_flag(flgs, TR_SLAY_HUMAN))
840         {
841                 info[i++] = _("それは人間に対して特に恐るべき力を発揮する。", "It is especially deadly against humans.");
842         }
843
844         if (have_flag(flgs, TR_FORCE_WEAPON))
845         {
846                 info[i++] = _("それは使用者の魔力を使って攻撃する。", "It powerfully strikes at a monster using your mana.");
847         }
848         if (have_flag(flgs, TR_DEC_MANA))
849         {
850                 info[i++] = _("それは魔力の消費を押さえる。", "It decreases your mana consumption.");
851         }
852         if (have_flag(flgs, TR_SUST_STR))
853         {
854                 info[i++] = _("それはあなたの腕力を維持する。", "It sustains your strength.");
855         }
856         if (have_flag(flgs, TR_SUST_INT))
857         {
858                 info[i++] = _("それはあなたの知能を維持する。", "It sustains your intelligence.");
859         }
860         if (have_flag(flgs, TR_SUST_WIS))
861         {
862                 info[i++] = _("それはあなたの賢さを維持する。", "It sustains your wisdom.");
863         }
864         if (have_flag(flgs, TR_SUST_DEX))
865         {
866                 info[i++] = _("それはあなたの器用さを維持する。", "It sustains your dexterity.");
867         }
868         if (have_flag(flgs, TR_SUST_CON))
869         {
870                 info[i++] = _("それはあなたの耐久力を維持する。", "It sustains your constitution.");
871         }
872         if (have_flag(flgs, TR_SUST_CHR))
873         {
874                 info[i++] = _("それはあなたの魅力を維持する。", "It sustains your charisma.");
875         }
876
877         if (have_flag(flgs, TR_IM_ACID))
878         {
879                 info[i++] = _("それは酸に対する完全な免疫を授ける。", "It provides immunity to acid.");
880         }
881         if (have_flag(flgs, TR_IM_ELEC))
882         {
883                 info[i++] = _("それは電撃に対する完全な免疫を授ける。", "It provides immunity to electricity.");
884         }
885         if (have_flag(flgs, TR_IM_FIRE))
886         {
887                 info[i++] = _("それは火に対する完全な免疫を授ける。", "It provides immunity to fire.");
888         }
889         if (have_flag(flgs, TR_IM_COLD))
890         {
891                 info[i++] = _("それは寒さに対する完全な免疫を授ける。", "It provides immunity to cold.");
892         }
893
894         if (have_flag(flgs, TR_THROW))
895         {
896                 info[i++] = _("それは敵に投げて大きなダメージを与えることができる。", "It is perfectly balanced for throwing.");
897         }
898
899         if (have_flag(flgs, TR_FREE_ACT))
900         {
901                 info[i++] = _("それは麻痺に対する完全な免疫を授ける。", "It provides immunity to paralysis.");
902         }
903         if (have_flag(flgs, TR_HOLD_EXP))
904         {
905                 info[i++] = _("それは経験値吸収に対する耐性を授ける。", "It provides resistance to experience draining.");
906         }
907         if (have_flag(flgs, TR_RES_FEAR))
908         {
909                 info[i++] = _("それは恐怖への完全な耐性を授ける。", "It makes you completely fearless.");
910         }
911         if (have_flag(flgs, TR_RES_ACID))
912         {
913                 info[i++] = _("それは酸への耐性を授ける。", "It provides resistance to acid.");
914         }
915         if (have_flag(flgs, TR_RES_ELEC))
916         {
917                 info[i++] = _("それは電撃への耐性を授ける。", "It provides resistance to electricity.");
918         }
919         if (have_flag(flgs, TR_RES_FIRE))
920         {
921                 info[i++] = _("それは火への耐性を授ける。", "It provides resistance to fire.");
922         }
923         if (have_flag(flgs, TR_RES_COLD))
924         {
925                 info[i++] = _("それは寒さへの耐性を授ける。", "It provides resistance to cold.");
926         }
927         if (have_flag(flgs, TR_RES_POIS))
928         {
929                 info[i++] = _("それは毒への耐性を授ける。", "It provides resistance to poison.");
930         }
931
932         if (have_flag(flgs, TR_RES_LITE))
933         {
934                 info[i++] = _("それは閃光への耐性を授ける。", "It provides resistance to light.");
935         }
936         if (have_flag(flgs, TR_RES_DARK))
937         {
938                 info[i++] = _("それは暗黒への耐性を授ける。", "It provides resistance to dark.");
939         }
940
941         if (have_flag(flgs, TR_RES_BLIND))
942         {
943                 info[i++] = _("それは盲目への耐性を授ける。", "It provides resistance to blindness.");
944         }
945         if (have_flag(flgs, TR_RES_CONF))
946         {
947                 info[i++] = _("それは混乱への耐性を授ける。", "It provides resistance to confusion.");
948         }
949         if (have_flag(flgs, TR_RES_SOUND))
950         {
951                 info[i++] = _("それは轟音への耐性を授ける。", "It provides resistance to sound.");
952         }
953         if (have_flag(flgs, TR_RES_SHARDS))
954         {
955                 info[i++] = _("それは破片への耐性を授ける。", "It provides resistance to shards.");
956         }
957
958         if (have_flag(flgs, TR_RES_NETHER))
959         {
960                 info[i++] = _("それは地獄への耐性を授ける。", "It provides resistance to nether.");
961         }
962         if (have_flag(flgs, TR_RES_NEXUS))
963         {
964                 info[i++] = _("それは因果混乱への耐性を授ける。", "It provides resistance to nexus.");
965         }
966         if (have_flag(flgs, TR_RES_CHAOS))
967         {
968                 info[i++] = _("それはカオスへの耐性を授ける。", "It provides resistance to chaos.");
969         }
970         if (have_flag(flgs, TR_RES_DISEN))
971         {
972                 info[i++] = _("それは劣化への耐性を授ける。", "It provides resistance to disenchantment.");
973         }
974
975         if (have_flag(flgs, TR_LEVITATION))
976         {
977                 info[i++] = _("それは宙に浮くことを可能にする。", "It allows you to levitate.");
978         }
979                 
980         if (have_flag(flgs, TR_SEE_INVIS))
981         {
982                 info[i++] = _("それは透明なモンスターを見ることを可能にする。", "It allows you to see invisible monsters.");
983         }
984         if (have_flag(flgs, TR_TELEPATHY))
985         {
986                 info[i++] = _("それはテレパシー能力を授ける。", "It gives telepathic powers.");
987         }
988         if (have_flag(flgs, TR_ESP_ANIMAL))
989         {
990                 info[i++] = _("それは自然界の生物を感知する。", "It senses natural creatures.");
991         }
992         if (have_flag(flgs, TR_ESP_UNDEAD))
993         {
994                 info[i++] = _("それはアンデッドを感知する。", "It senses undead.");
995         }
996         if (have_flag(flgs, TR_ESP_DEMON))
997         {
998                 info[i++] = _("それは悪魔を感知する。", "It senses demons.");
999         }
1000         if (have_flag(flgs, TR_ESP_ORC))
1001         {
1002                 info[i++] = _("それはオークを感知する。", "It senses orcs.");
1003         }
1004         if (have_flag(flgs, TR_ESP_TROLL))
1005         {
1006                 info[i++] = _("それはトロルを感知する。", "It senses trolls.");
1007         }
1008         if (have_flag(flgs, TR_ESP_GIANT))
1009         {
1010                 info[i++] = _("それは巨人を感知する。", "It senses giants.");
1011         }
1012         if (have_flag(flgs, TR_ESP_DRAGON))
1013         {
1014                 info[i++] = _("それはドラゴンを感知する。", "It senses dragons.");
1015         }
1016         if (have_flag(flgs, TR_ESP_HUMAN))
1017         {
1018                 info[i++] = _("それは人間を感知する。", "It senses humans.");
1019         }
1020         if (have_flag(flgs, TR_ESP_EVIL))
1021         {
1022                 info[i++] = _("それは邪悪な存在を感知する。", "It senses evil creatures.");
1023         }
1024         if (have_flag(flgs, TR_ESP_GOOD))
1025         {
1026                 info[i++] = _("それは善良な存在を感知する。", "It senses good creatures.");
1027         }
1028         if (have_flag(flgs, TR_ESP_NONLIVING))
1029         {
1030                 info[i++] = _("それは活動する無生物体を感知する。", "It senses non-living creatures.");
1031         }
1032         if (have_flag(flgs, TR_ESP_UNIQUE))
1033         {
1034                 info[i++] = _("それは特別な強敵を感知する。", "It senses unique monsters.");
1035         }
1036         if (have_flag(flgs, TR_SLOW_DIGEST))
1037         {
1038                 info[i++] = _("それはあなたの新陳代謝を遅くする。", "It slows your metabolism.");
1039         }
1040         if (have_flag(flgs, TR_REGEN))
1041         {
1042                 info[i++] = _("それは体力回復力を強化する。", "It speeds your regenerative powers.");
1043         }
1044         if (have_flag(flgs, TR_WARNING))
1045         {
1046                 info[i++] = _("それは危険に対して警告を発する。", "It warns you of danger");
1047         }
1048         if (have_flag(flgs, TR_REFLECT))
1049         {
1050                 info[i++] = _("それは矢の呪文を反射する。", "It reflects bolt spells.");
1051         }
1052         if (have_flag(flgs, TR_SH_FIRE))
1053         {
1054                 info[i++] = _("それは炎のバリアを張る。", "It produces a fiery sheath.");
1055         }
1056         if (have_flag(flgs, TR_SH_ELEC))
1057         {
1058                 info[i++] = _("それは電気のバリアを張る。", "It produces an electric sheath.");
1059         }
1060         if (have_flag(flgs, TR_SH_COLD))
1061         {
1062                 info[i++] = _("それは冷気のバリアを張る。", "It produces a sheath of coldness.");
1063         }
1064         if (have_flag(flgs, TR_NO_MAGIC))
1065         {
1066                 info[i++] = _("それは反魔法バリアを張る。", "It produces an anti-magic shell.");
1067         }
1068         if (have_flag(flgs, TR_NO_TELE))
1069         {
1070                 info[i++] = _("それはテレポートを邪魔する。", "It prevents teleportation.");
1071         }
1072         if (have_flag(flgs, TR_XTRA_MIGHT))
1073         {
1074                 info[i++] = _("それは矢/ボルト/弾をより強力に発射することができる。", "It fires missiles with extra might.");
1075         }
1076         if (have_flag(flgs, TR_XTRA_SHOTS))
1077         {
1078                 info[i++] = _("それは矢/ボルト/弾を非常に早く発射することができる。", "It fires missiles excessively fast.");
1079         }
1080
1081         if (have_flag(flgs, TR_BLESSED))
1082         {
1083                 info[i++] = _("それは神に祝福されている。", "It has been blessed by the gods.");
1084         }
1085
1086         if (object_is_cursed(o_ptr))
1087         {
1088                 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1089                 {
1090                         info[i++] = _("それは永遠の呪いがかけられている。", "It is permanently cursed.");
1091                 }
1092                 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1093                 {
1094                         info[i++] = _("それは強力な呪いがかけられている。", "It is heavily cursed.");
1095                 }
1096                 else
1097                 {
1098                         info[i++] = _("それは呪われている。", "It is cursed.");
1099
1100                         /*
1101                          * It's a trivial infomation since there is
1102                          * fake inscription {cursed}
1103                          */
1104                         trivial_info++;
1105                 }
1106         }
1107
1108         if ((have_flag(flgs, TR_TY_CURSE)) || (o_ptr->curse_flags & TRC_TY_CURSE))
1109         {
1110                 info[i++] = _("それは太古の禍々しい怨念が宿っている。", "It carries an ancient foul curse.");
1111         }
1112         if ((have_flag(flgs, TR_AGGRAVATE)) || (o_ptr->curse_flags & TRC_AGGRAVATE))
1113         {
1114                 info[i++] = _("それは付近のモンスターを怒らせる。", "It aggravates nearby creatures.");
1115         }
1116         if ((have_flag(flgs, TR_DRAIN_EXP)) || (o_ptr->curse_flags & TRC_DRAIN_EXP))
1117         {
1118                 info[i++] = _("それは経験値を吸い取る。", "It drains experience.");
1119         }
1120         if (o_ptr->curse_flags & TRC_SLOW_REGEN)
1121         {
1122                 info[i++] = _("それは回復力を弱める。", "It slows your regenerative powers.");
1123         }
1124         if ((o_ptr->curse_flags & TRC_ADD_L_CURSE) || have_flag(flgs, TR_ADD_L_CURSE))
1125         {
1126                 info[i++] = _("それは弱い呪いを増やす。","It adds weak curses.");
1127         }
1128         if ((o_ptr->curse_flags & TRC_ADD_H_CURSE) || have_flag(flgs, TR_ADD_H_CURSE))
1129         {
1130                 info[i++] = _("それは強力な呪いを増やす。","It adds heavy curses.");
1131         }
1132         if ((have_flag(flgs, TR_CALL_ANIMAL)) || (o_ptr->curse_flags & TRC_CALL_ANIMAL))
1133         {
1134                 info[i++] = _("それは動物を呼び寄せる。", "It attracts animals.");
1135         }
1136         if ((have_flag(flgs, TR_CALL_DEMON)) || (o_ptr->curse_flags & TRC_CALL_DEMON))
1137         {
1138                 info[i++] = _("それは悪魔を呼び寄せる。", "It attracts demons.");
1139         }
1140         if ((have_flag(flgs, TR_CALL_DRAGON)) || (o_ptr->curse_flags & TRC_CALL_DRAGON))
1141         {
1142                 info[i++] = _("それはドラゴンを呼び寄せる。", "It attracts dragons.");
1143         }
1144         if ((have_flag(flgs, TR_CALL_UNDEAD)) || (o_ptr->curse_flags & TRC_CALL_UNDEAD))
1145         {
1146                 info[i++] = _("それは死霊を呼び寄せる。", "It attracts undeads.");
1147         }
1148         if ((have_flag(flgs, TR_COWARDICE)) ||  (o_ptr->curse_flags & TRC_COWARDICE))
1149         {
1150                 info[i++] = _("それは恐怖感を引き起こす。", "It makes you subject to cowardice.");
1151         }
1152         if ((have_flag(flgs, TR_TELEPORT)) || (o_ptr->curse_flags & TRC_TELEPORT))
1153         {
1154                 info[i++] = _("それはランダムなテレポートを引き起こす。", "It induces random teleportation.");
1155         }
1156         if ((have_flag(flgs, TR_LOW_MELEE)) || o_ptr->curse_flags & TRC_LOW_MELEE)
1157         {
1158                 info[i++] = _("それは攻撃を外しやすい。", "It causes you to miss blows.");
1159         }
1160         if ((have_flag(flgs, TR_LOW_AC)) || (o_ptr->curse_flags & TRC_LOW_AC))
1161         {
1162                 info[i++] = _("それは攻撃を受けやすい。", "It helps your enemies' blows.");
1163         }
1164         if ((have_flag(flgs, TR_LOW_MAGIC)) || (o_ptr->curse_flags & TRC_LOW_MAGIC))
1165         {
1166                 info[i++] = _("それは魔法を唱えにくくする。", "It encumbers you while spellcasting.");
1167         }
1168         if ((have_flag(flgs, TR_FAST_DIGEST)) || (o_ptr->curse_flags & TRC_FAST_DIGEST))
1169         {
1170                 info[i++] = _("それはあなたの新陳代謝を速くする。", "It speeds your metabolism.");
1171         }
1172         if ((have_flag(flgs, TR_DRAIN_HP)) || (o_ptr->curse_flags & TRC_DRAIN_HP))
1173         {
1174                 info[i++] = _("それはあなたの体力を吸い取る。", "It drains you.");
1175         }
1176         if ((have_flag(flgs, TR_DRAIN_MANA)) || (o_ptr->curse_flags & TRC_DRAIN_MANA))
1177         {
1178                 info[i++] = _("それはあなたの魔力を吸い取る。", "It drains your mana.");
1179         }
1180
1181         /* Describe about this kind of object instead of THIS fake object */
1182         if (mode & SCROBJ_FAKE_OBJECT)
1183         {
1184                 switch (o_ptr->tval)
1185                 {
1186                 case TV_RING:
1187                         switch (o_ptr->sval)
1188                         {
1189                         case SV_RING_LORDLY:
1190                                 info[i++] = _("それは幾つかのランダムな耐性を授ける。", "It provides some random resistances.");
1191                                 break;
1192                         case SV_RING_WARNING:
1193                                 info[i++] = _("それはひとつの低級なESPを授ける事がある。", "It may provide a low rank ESP.");
1194                                 break;
1195                         }
1196                         break;
1197
1198                 case TV_AMULET:
1199                         switch (o_ptr->sval)
1200                         {
1201                         case SV_AMULET_RESISTANCE:
1202                                 info[i++] = _("それは毒への耐性を授ける事がある。", "It may provides resistance to poison.");
1203                                 info[i++] = _("それはランダムな耐性を授ける事がある。", "It may provide a random resistances.");
1204                                 break;
1205                         case SV_AMULET_THE_MAGI:
1206                                 info[i++] = _("それは最大で3つまでの低級なESPを授ける。", "It provides up to three low rank ESPs.");
1207                                 break;
1208                         }
1209                         break;
1210                 }
1211         }
1212
1213         if (have_flag(flgs, TR_IGNORE_ACID) &&
1214             have_flag(flgs, TR_IGNORE_ELEC) &&
1215             have_flag(flgs, TR_IGNORE_FIRE) &&
1216             have_flag(flgs, TR_IGNORE_COLD))
1217         {
1218                 info[i++] = _("それは酸・電撃・火炎・冷気では傷つかない。", "It cannot be harmed by the elements.");
1219         }
1220         else
1221         {
1222                 if (have_flag(flgs, TR_IGNORE_ACID))
1223                 {
1224                         info[i++] = _("それは酸では傷つかない。", "It cannot be harmed by acid.");
1225                 }
1226                 if (have_flag(flgs, TR_IGNORE_ELEC))
1227                 {
1228                         info[i++] = _("それは電撃では傷つかない。", "It cannot be harmed by electricity.");
1229                 }
1230                 if (have_flag(flgs, TR_IGNORE_FIRE))
1231                 {
1232                         info[i++] = _("それは火炎では傷つかない。", "It cannot be harmed by fire.");
1233                 }
1234                 if (have_flag(flgs, TR_IGNORE_COLD))
1235                 {
1236                         info[i++] = _("それは冷気では傷つかない。", "It cannot be harmed by cold.");
1237                 }
1238         }
1239
1240         if (mode & SCROBJ_FORCE_DETAIL) trivial_info = 0;
1241
1242         /* No relevant informations */
1243         if (i <= trivial_info) return (FALSE);
1244         screen_save();
1245
1246         Term_get_size(&wid, &hgt);
1247
1248         /* Display Item name */
1249         if (!(mode & SCROBJ_FAKE_OBJECT))
1250                 object_desc(o_name, o_ptr, 0);
1251         else
1252                 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1253
1254         prt(o_name, 0, 0);
1255
1256         /* Erase the screen */
1257         for (k = 1; k < hgt; k++) prt("", k, 13);
1258
1259         /* Label the information */
1260         if ((o_ptr->tval == TV_STATUE) && (o_ptr->sval == SV_PHOTO))
1261         {
1262                 monster_race *r_ptr = &r_info[o_ptr->pval];
1263                 int namelen = strlen(r_name + r_ptr->name);
1264                 prt(format("%s: '", r_name + r_ptr->name), 1, 15);
1265                 Term_queue_bigchar(18 + namelen, 1, r_ptr->x_attr, r_ptr->x_char, 0, 0);
1266                 prt("'", 1, (use_bigtile ? 20 : 19) + namelen);
1267         }
1268         else
1269         {
1270                 prt(_("     アイテムの能力:", "     Item Attributes:"), 1, 15);
1271         }
1272
1273         /* We will print on top of the map (column 13) */
1274         for (k = 2, j = 0; j < i; j++)
1275         {
1276                 /* Show the info */
1277                 prt(info[j], k++, 15);
1278
1279                 /* Every 20 entries (lines 2 to 21), start over */
1280                 if ((k == hgt - 2) && (j+1 < i))
1281                 {
1282                         prt(_("-- 続く --", "-- more --"), k, 15);
1283                         inkey();
1284                         for (; k > 2; k--) prt("", k, 15);
1285                 }
1286         }
1287
1288         /* Wait for it */
1289         prt(_("[何かキーを押すとゲームに戻ります]", "[Press any key to continue]"), k, 15);
1290
1291         inkey();
1292         screen_load();
1293
1294         /* Gave knowledge */
1295         return (TRUE);
1296 }
1297
1298
1299
1300 /*!
1301  * @brief オブジェクト選択時の選択アルファベットラベルを返す /
1302  * Convert an p_ptr->inventory_list index into a one character label
1303  * @param i プレイヤーの所持/装備オブジェクトID
1304  * @return 対応するアルファベット
1305  * @details Note that the label does NOT distinguish inven/equip.
1306  */
1307 char index_to_label(int i)
1308 {
1309         /* Indexes for "inven" are easy */
1310         if (i < INVEN_RARM) return (I2A(i));
1311
1312         /* Indexes for "equip" are offset */
1313         return (I2A(i - INVEN_RARM));
1314 }
1315
1316 /*!
1317  * @brief 選択アルファベットラベルからプレイヤーの所持オブジェクトIDを返す /
1318  * Convert a label into the index of an item in the "inven"
1319  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1320  * @details Note that the label does NOT distinguish inven/equip.
1321  */
1322 INVENTORY_IDX label_to_inven(int c)
1323 {
1324         INVENTORY_IDX i;
1325
1326         /* Convert */
1327         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1);
1328
1329         /* Verify the index */
1330         if ((i < 0) || (i > INVEN_PACK)) return (-1);
1331
1332         /* Empty slots can never be chosen */
1333         if (!p_ptr->inventory_list[i].k_idx) return (-1);
1334
1335         /* Return the index */
1336         return (i);
1337 }
1338
1339
1340 /*! See cmd5.c */
1341 extern bool select_ring_slot;
1342
1343
1344 /*!
1345  * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
1346  * @param i プレイヤーの所持/装備オブジェクトID
1347  * @return 指輪枠ならばTRUEを返す。
1348  */
1349 static bool is_ring_slot(int i)
1350 {
1351         return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
1352 }
1353
1354
1355 /*!
1356  * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
1357  * Convert a label into the index of a item in the "equip"
1358  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1359  */
1360 INVENTORY_IDX label_to_equip(int c)
1361 {
1362         INVENTORY_IDX i;
1363
1364         /* Convert */
1365         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
1366
1367         /* Verify the index */
1368         if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
1369
1370         if (select_ring_slot) return is_ring_slot(i) ? i : -1;
1371
1372         /* Empty slots can never be chosen */
1373         if (!p_ptr->inventory_list[i].k_idx) return (-1);
1374
1375         /* Return the index */
1376         return (i);
1377 }
1378
1379
1380
1381 /*!
1382  * @brief オブジェクトの該当装備部位IDを返す /
1383  * Determine which equipment slot (if any) an item likes
1384  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
1385  * @return 対応する装備部位ID
1386  */
1387 s16b wield_slot(object_type *o_ptr)
1388 {
1389         /* Slot for equipment */
1390         switch (o_ptr->tval)
1391         {
1392                 case TV_DIGGING:
1393                 case TV_HAFTED:
1394                 case TV_POLEARM:
1395                 case TV_SWORD:
1396                 {
1397                         if (!p_ptr->inventory_list[INVEN_RARM].k_idx) return (INVEN_RARM);
1398                         if (p_ptr->inventory_list[INVEN_LARM].k_idx) return (INVEN_RARM);
1399                         return (INVEN_LARM);
1400                 }
1401
1402                 case TV_CAPTURE:
1403                 case TV_CARD:
1404                 case TV_SHIELD:
1405                 {
1406                         if (!p_ptr->inventory_list[INVEN_LARM].k_idx) return (INVEN_LARM);
1407                         if (p_ptr->inventory_list[INVEN_RARM].k_idx) return (INVEN_LARM);
1408                         return (INVEN_RARM);
1409                 }
1410
1411                 case TV_BOW:
1412                 {
1413                         return (INVEN_BOW);
1414                 }
1415
1416                 case TV_RING:
1417                 {
1418                         /* Use the right hand first */
1419                         if (!p_ptr->inventory_list[INVEN_RIGHT].k_idx) return (INVEN_RIGHT);
1420
1421                         /* Use the left hand for swapping (by default) */
1422                         return (INVEN_LEFT);
1423                 }
1424
1425                 case TV_AMULET:
1426                 case TV_WHISTLE:
1427                 {
1428                         return (INVEN_NECK);
1429                 }
1430
1431                 case TV_LITE:
1432                 {
1433                         return (INVEN_LITE);
1434                 }
1435
1436                 case TV_DRAG_ARMOR:
1437                 case TV_HARD_ARMOR:
1438                 case TV_SOFT_ARMOR:
1439                 {
1440                         return (INVEN_BODY);
1441                 }
1442
1443                 case TV_CLOAK:
1444                 {
1445                         return (INVEN_OUTER);
1446                 }
1447
1448                 case TV_CROWN:
1449                 case TV_HELM:
1450                 {
1451                         return (INVEN_HEAD);
1452                 }
1453
1454                 case TV_GLOVES:
1455                 {
1456                         return (INVEN_HANDS);
1457                 }
1458
1459                 case TV_BOOTS:
1460                 {
1461                         return (INVEN_FEET);
1462                 }
1463         }
1464
1465         /* No slot available */
1466         return (-1);
1467 }
1468
1469 /*!
1470  * @brief 所持/装備オブジェクトIDの部位表現を返す /
1471  * Return a string mentioning how a given item is carried
1472  * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
1473  * @return 部位表現の文字列ポインタ
1474  */
1475 concptr mention_use(int i)
1476 {
1477         concptr p;
1478
1479         /* Examine the location */
1480         switch (i)
1481         {
1482 #ifdef JP
1483                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中" : ((p_ptr->ryoute && p_ptr->migite) ? " 両手" : (left_hander ? " 左手" : " 右手")); break;
1484 #else
1485                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "Just lifting" : (p_ptr->migite ? "Wielding" : "On arm"); break;
1486 #endif
1487
1488 #ifdef JP
1489                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中" : ((p_ptr->ryoute && p_ptr->hidarite) ? " 両手" : (left_hander ? " 右手" : " 左手")); break;
1490 #else
1491                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "Just lifting" : (p_ptr->hidarite ? "Wielding" : "On arm"); break;
1492 #endif
1493
1494                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < p_ptr->inventory_list[i].weight / 10) ? _("運搬中", "Just holding") : _("射撃用", "Shooting"); break;
1495                 case INVEN_RIGHT: p = (left_hander ? _("左手指", "On left hand") : _("右手指", "On right hand")); break;
1496                 case INVEN_LEFT:  p = (left_hander ? _("右手指", "On right hand") : _("左手指", "On left hand")); break;
1497                 case INVEN_NECK:  p = _("  首", "Around neck"); break;
1498                 case INVEN_LITE:  p = _(" 光源", "Light source"); break;
1499                 case INVEN_BODY:  p = _("  体", "On body"); break;
1500                 case INVEN_OUTER: p = _("体の上", "About body"); break;
1501                 case INVEN_HEAD:  p = _("  頭", "On head"); break;
1502                 case INVEN_HANDS: p = _("  手", "On hands"); break;
1503                 case INVEN_FEET:  p = _("  足", "On feet"); break;
1504                 default:          p = _("ザック", "In pack"); break;
1505         }
1506
1507         /* Return the result */
1508         return p;
1509 }
1510
1511
1512 /*!
1513  * @brief 所持/装備オブジェクトIDの現在の扱い方の状態表現を返す /
1514  * Return a string describing how a given item is being worn.
1515  * @param i 状態表現を求めるプレイヤーの所持/装備オブジェクトID
1516  * @return 状態表現内容の文字列ポインタ
1517  * @details
1518  * Currently, only used for items in the equipment, not p_ptr->inventory_list.
1519  */
1520 concptr describe_use(int i)
1521 {
1522         concptr p;
1523
1524         switch (i)
1525         {
1526 #ifdef JP
1527                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->migite) ? "両手に装備している" : (left_hander ? "左手に装備している" : "右手に装備している")); break;
1528 #else
1529                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "just lifting" : (p_ptr->migite ? "attacking monsters with" : "wearing on your arm"); break;
1530 #endif
1531
1532 #ifdef JP
1533                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->hidarite) ? "両手に装備している" : (left_hander ? "右手に装備している" : "左手に装備している")); break;
1534 #else
1535                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "just lifting" : (p_ptr->hidarite ? "attacking monsters with" : "wearing on your arm"); break;
1536 #endif
1537
1538                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < p_ptr->inventory_list[i].weight / 10) ? _("持つだけで精一杯の", "just holding") : _("射撃用に装備している", "shooting missiles with"); break;
1539                 case INVEN_RIGHT: p = (left_hander ? _("左手の指にはめている", "wearing on your left hand") : _("右手の指にはめている", "wearing on your right hand")); break;
1540                 case INVEN_LEFT:  p = (left_hander ? _("右手の指にはめている", "wearing on your right hand") : _("左手の指にはめている", "wearing on your left hand")); break;
1541                 case INVEN_NECK:  p = _("首にかけている", "wearing around your neck"); break;
1542                 case INVEN_LITE:  p = _("光源にしている", "using to light the way"); break;
1543                 case INVEN_BODY:  p = _("体に着ている", "wearing on your body"); break;
1544                 case INVEN_OUTER: p = _("身にまとっている", "wearing on your back"); break;
1545                 case INVEN_HEAD:  p = _("頭にかぶっている", "wearing on your head"); break;
1546                 case INVEN_HANDS: p = _("手につけている", "wearing on your hands"); break;
1547                 case INVEN_FEET:  p = _("足にはいている", "wearing on your feet"); break;
1548                 default:          p = _("ザックに入っている", "carrying in your pack"); break;
1549         }
1550
1551         /* Return the result */
1552         return p;
1553 }
1554
1555
1556 /*!
1557  * @brief tval/sval指定のベースアイテムがプレイヤーの使用可能な魔法書かどうかを返す /
1558  * Hack: Check if a spellbook is one of the realms we can use. -- TY
1559  * @param book_tval ベースアイテムのtval
1560  * @param book_sval ベースアイテムのsval
1561  * @return 使用可能な魔法書ならばTRUEを返す。
1562  */
1563
1564 bool check_book_realm(const OBJECT_TYPE_VALUE book_tval, const OBJECT_SUBTYPE_VALUE book_sval)
1565 {
1566         if (book_tval < TV_LIFE_BOOK) return FALSE;
1567         if (p_ptr->pclass == CLASS_SORCERER)
1568         {
1569                 return is_magic(tval2realm(book_tval));
1570         }
1571         else if (p_ptr->pclass == CLASS_RED_MAGE)
1572         {
1573                 if (is_magic(tval2realm(book_tval)))
1574                         return ((book_tval == TV_ARCANE_BOOK) || (book_sval < 2));
1575         }
1576         return (REALM1_BOOK == book_tval || REALM2_BOOK == book_tval);
1577 }
1578
1579 /*!
1580  * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
1581  * Check an item against the item tester info
1582  * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
1583  * @return item_tester_hookの参照先、その他いくつかの例外に応じてTRUE/FALSEを返す。
1584  */
1585 bool item_tester_okay(object_type *o_ptr)
1586 {
1587         /* Hack -- allow listing empty slots */
1588         // if (item_tester_full) return (TRUE); // TODO:DELETE
1589
1590         /* Require an item */
1591         if (!o_ptr->k_idx) return (FALSE);
1592
1593         /* Hack -- ignore "gold" */
1594         if (o_ptr->tval == TV_GOLD)
1595         {
1596                 /* See xtra2.c */
1597                 extern bool show_gold_on_floor;
1598
1599                 if (!show_gold_on_floor) return (FALSE);
1600         }
1601
1602         /* Check the tval */
1603         if (item_tester_tval)
1604         {
1605                 /* Is it a spellbook? If so, we need a hack -- TY */
1606                 if ((item_tester_tval <= TV_DEATH_BOOK) &&
1607                         (item_tester_tval >= TV_LIFE_BOOK))
1608                         return check_book_realm(o_ptr->tval, o_ptr->sval);
1609                 else
1610                         if (item_tester_tval != o_ptr->tval) return (FALSE);
1611         }
1612
1613         /* Check the hook */
1614         if (item_tester_hook)
1615         {
1616                 if (!(*item_tester_hook)(o_ptr)) return (FALSE);
1617         }
1618
1619         /* Assume okay */
1620         return (TRUE);
1621 }
1622
1623
1624 /*!
1625  * @brief 所持アイテム一覧を表示する /
1626  * Choice window "shadow" of the "show_inven()" function
1627  * @return なし
1628  */
1629 void display_inven(void)
1630 {
1631         register int i, n, z = 0;
1632         object_type *o_ptr;
1633         TERM_COLOR attr = TERM_WHITE;
1634         char tmp_val[80];
1635         GAME_TEXT o_name[MAX_NLEN];
1636         TERM_LEN wid, hgt;
1637
1638         Term_get_size(&wid, &hgt);
1639
1640         for (i = 0; i < INVEN_PACK; i++)
1641         {
1642                 o_ptr = &p_ptr->inventory_list[i];
1643                 if (!o_ptr->k_idx) continue;
1644                 z = i + 1;
1645         }
1646
1647         for (i = 0; i < z; i++)
1648         {
1649                 o_ptr = &p_ptr->inventory_list[i];
1650                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1651                 if (item_tester_okay(o_ptr))
1652                 {
1653                         tmp_val[0] = index_to_label(i);
1654                         tmp_val[1] = ')';
1655                 }
1656
1657                 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
1658                 object_desc(o_name, o_ptr, 0);
1659                 n = strlen(o_name);
1660                 attr = tval_to_attr[o_ptr->tval % 128];
1661                 if (o_ptr->timeout)
1662                 {
1663                         attr = TERM_L_DARK;
1664                 }
1665
1666                 Term_putstr(3, i, n, attr, o_name);
1667                 Term_erase(3+n, i, 255);
1668
1669                 if (show_weights)
1670                 {
1671                         int wgt = o_ptr->weight * o_ptr->number;
1672 #ifdef JP
1673                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
1674 #else
1675                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1676 #endif
1677                         prt(tmp_val, i, wid - 9);
1678                 }
1679         }
1680
1681         for (i = z; i < hgt; i++)
1682         {
1683                 Term_erase(0, i, 255);
1684         }
1685 }
1686
1687
1688
1689 /*!
1690  * @brief 装備アイテム一覧を表示する /
1691  * Choice window "shadow" of the "show_equip()" function
1692  * @return なし
1693  */
1694 void display_equip(void)
1695 {
1696         register int i, n;
1697         object_type *o_ptr;
1698         TERM_COLOR attr = TERM_WHITE;
1699         char tmp_val[80];
1700         GAME_TEXT o_name[MAX_NLEN];
1701         TERM_LEN wid, hgt;
1702
1703         Term_get_size(&wid, &hgt);
1704
1705         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1706         {
1707                 o_ptr = &p_ptr->inventory_list[i];
1708                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1709                 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
1710                 {
1711                         tmp_val[0] = index_to_label(i);
1712                         tmp_val[1] = ')';
1713                 }
1714
1715                 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
1716                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
1717                 {
1718                         strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
1719                         attr = TERM_WHITE;
1720                 }
1721                 else
1722                 {
1723                         object_desc(o_name, o_ptr, 0);
1724                         attr = tval_to_attr[o_ptr->tval % 128];
1725                 }
1726
1727                 n = strlen(o_name);
1728                 if (o_ptr->timeout)
1729                 {
1730                         attr = TERM_L_DARK;
1731                 }
1732                 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
1733
1734                 Term_erase(3 + n, i - INVEN_RARM, 255);
1735
1736                 if (show_weights)
1737                 {
1738                         int wgt = o_ptr->weight * o_ptr->number;
1739 #ifdef JP
1740                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
1741 #else
1742                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1743 #endif
1744
1745                         prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
1746                 }
1747
1748                 if (show_labels)
1749                 {
1750                         Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
1751                         prt(mention_use(i), i - INVEN_RARM, wid - 15);
1752                 }
1753         }
1754
1755         for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
1756         {
1757                 Term_erase(0, i, 255);
1758         }
1759 }
1760
1761
1762 /*!
1763  * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1764  * Find the "first" p_ptr->inventory_list object with the given "tag".
1765  * @param cp 対応するタグIDを与える参照ポインタ
1766  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1767  * @param mode 所持、装備の切り替え
1768  * @return タグに該当するオブジェクトがあるならTRUEを返す
1769  * @details
1770  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1771  * inscription of an object.  Alphabetical characters don't work as a\n
1772  * tag in this form.\n
1773  *\n
1774  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1775  * and "x" is the "current" command_cmd code.\n
1776  */
1777 static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
1778 {
1779         COMMAND_CODE i;
1780         COMMAND_CODE start, end;
1781         concptr s;
1782
1783         /* Extract index from mode */
1784         switch (mode)
1785         {
1786         case USE_EQUIP:
1787                 start = INVEN_RARM;
1788                 end = INVEN_TOTAL - 1;
1789                 break;
1790
1791         case USE_INVEN:
1792                 start = 0;
1793                 end = INVEN_PACK - 1;
1794                 break;
1795
1796         default:
1797                 return FALSE;
1798         }
1799
1800         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1801
1802         /* Check every p_ptr->inventory_list object */
1803         for (i = start; i <= end; i++)
1804         {
1805                 object_type *o_ptr = &p_ptr->inventory_list[i];
1806                 if (!o_ptr->k_idx) continue;
1807
1808                 /* Skip empty inscriptions */
1809                 if (!o_ptr->inscription) continue;
1810
1811                 /* Skip non-choice */
1812                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1813
1814                 /* Find a '@' */
1815                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1816
1817                 /* Process all tags */
1818                 while (s)
1819                 {
1820                         /* Check the special tags */
1821                         if ((s[1] == command_cmd) && (s[2] == tag))
1822                         {
1823                                 /* Save the actual p_ptr->inventory_list ID */
1824                                 *cp = i;
1825
1826                                 /* Success */
1827                                 return (TRUE);
1828                         }
1829
1830                         /* Find another '@' */
1831                         s = my_strchr(s + 1, '@');
1832                 }
1833         }
1834
1835
1836         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
1837
1838         /* Don't allow {@#} with '#' being alphabet */
1839         if (tag < '0' || '9' < tag)
1840         {
1841                 /* No such tag */
1842                 return FALSE;
1843         }
1844
1845         /* Check every object */
1846         for (i = start; i <= end; i++)
1847         {
1848                 object_type *o_ptr = &p_ptr->inventory_list[i];
1849                 if (!o_ptr->k_idx) continue;
1850
1851                 /* Skip empty inscriptions */
1852                 if (!o_ptr->inscription) continue;
1853
1854                 /* Skip non-choice */
1855                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1856
1857                 /* Find a '@' */
1858                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1859
1860                 /* Process all tags */
1861                 while (s)
1862                 {
1863                         /* Check the normal tags */
1864                         if (s[1] == tag)
1865                         {
1866                                 /* Save the actual p_ptr->inventory_list ID */
1867                                 *cp = i;
1868
1869                                 /* Success */
1870                                 return (TRUE);
1871                         }
1872
1873                         /* Find another '@' */
1874                         s = my_strchr(s + 1, '@');
1875                 }
1876         }
1877
1878         /* No such tag */
1879         return (FALSE);
1880 }
1881
1882
1883 /*!
1884  * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1885  * Find the "first" p_ptr->inventory_list object with the given "tag".
1886  * @param cp 対応するタグIDを与える参照ポインタ
1887  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1888  * @param floor_list 床上アイテムの配列
1889  * @param floor_num  床上アイテムの配列ID
1890  * @return タグに該当するオブジェクトがあるならTRUEを返す
1891  * @details
1892  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1893  * inscription of an object.  Alphabetical characters don't work as a\n
1894  * tag in this form.\n
1895  *\n
1896  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1897  * and "x" is the "current" command_cmd code.\n
1898  */
1899 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
1900 {
1901         COMMAND_CODE i;
1902         concptr s;
1903
1904         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1905
1906         /* Check every object in the grid */
1907         for (i = 0; i < floor_num && i < 23; i++)
1908         {
1909                 object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1910
1911                 /* Skip empty inscriptions */
1912                 if (!o_ptr->inscription) continue;
1913
1914                 /* Find a '@' */
1915                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1916
1917                 /* Process all tags */
1918                 while (s)
1919                 {
1920                         /* Check the special tags */
1921                         if ((s[1] == command_cmd) && (s[2] == tag))
1922                         {
1923                                 /* Save the actual floor object ID */
1924                                 *cp = i;
1925
1926                                 /* Success */
1927                                 return (TRUE);
1928                         }
1929
1930                         /* Find another '@' */
1931                         s = my_strchr(s + 1, '@');
1932                 }
1933         }
1934
1935
1936         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
1937
1938         /* Don't allow {@#} with '#' being alphabet */
1939         if (tag < '0' || '9' < tag)
1940         {
1941                 /* No such tag */
1942                 return FALSE;
1943         }
1944
1945         /* Check every object in the grid */
1946         for (i = 0; i < floor_num && i < 23; i++)
1947         {
1948                 object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1949
1950                 /* Skip empty inscriptions */
1951                 if (!o_ptr->inscription) continue;
1952
1953                 /* Find a '@' */
1954                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1955
1956                 /* Process all tags */
1957                 while (s)
1958                 {
1959                         /* Check the normal tags */
1960                         if (s[1] == tag)
1961                         {
1962                                 /* Save the floor object ID */
1963                                 *cp = i;
1964
1965                                 /* Success */
1966                                 return (TRUE);
1967                         }
1968
1969                         /* Find another '@' */
1970                         s = my_strchr(s + 1, '@');
1971                 }
1972         }
1973
1974         /* No such tag */
1975         return (FALSE);
1976 }
1977
1978
1979 /*!
1980  * @brief タグIDにあわせてタグアルファベットのリストを返す /
1981  * Move around label characters with correspond tags
1982  * @param label ラベルリストを取得する文字列参照ポインタ
1983  * @param mode 所持品リストか装備品リストかの切り替え
1984  * @return なし
1985  */
1986 static void prepare_label_string(char *label, BIT_FLAGS mode)
1987 {
1988         concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1989         int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
1990         int  i;
1991
1992         /* Prepare normal labels */
1993         strcpy(label, alphabet_chars);
1994
1995         /* Move each label */
1996         for (i = 0; i < 52; i++)
1997         {
1998                 COMMAND_CODE index;
1999                 SYMBOL_CODE c = alphabet_chars[i];
2000
2001                 /* Find a tag with this label */
2002                 if (get_tag(&index, c, mode))
2003                 {
2004                         /* Delete the overwritten label */
2005                         if (label[i] == c) label[i] = ' ';
2006
2007                         /* Move the label to the place of corresponding tag */
2008                         label[index - offset] = c;
2009                 }
2010         }
2011 }
2012
2013
2014 /*!
2015  * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
2016  * Move around label characters with correspond tags (floor version)
2017  * @param label ラベルリストを取得する文字列参照ポインタ
2018  * @param floor_list 床上アイテムの配列
2019  * @param floor_num  床上アイテムの配列ID
2020  * @return なし
2021  */
2022 /*
2023  */
2024 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
2025 {
2026         concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2027         int  i;
2028
2029         /* Prepare normal labels */
2030         strcpy(label, alphabet_chars);
2031
2032         /* Move each label */
2033         for (i = 0; i < 52; i++)
2034         {
2035                 COMMAND_CODE index;
2036                 SYMBOL_CODE c = alphabet_chars[i];
2037
2038                 /* Find a tag with this label */
2039                 if (get_tag_floor(&index, c, floor_list, floor_num))
2040                 {
2041                         /* Delete the overwritten label */
2042                         if (label[i] == c) label[i] = ' ';
2043
2044                         /* Move the label to the place of corresponding tag */
2045                         label[index] = c;
2046                 }
2047         }
2048 }
2049
2050
2051 /*!
2052  * @brief 所持アイテムの表示を行う /
2053  * Display the p_ptr->inventory_list.
2054  * @param target_item アイテムの選択処理を行うか否か。
2055  * @return 選択したアイテムのタグ
2056  * @details
2057  * Hack -- do not display "trailing" empty slots
2058  */
2059 COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
2060 {
2061         COMMAND_CODE i;
2062         int j, k, l, z = 0;
2063         int             col, cur_col, len;
2064         object_type *o_ptr;
2065         GAME_TEXT o_name[MAX_NLEN];
2066         char            tmp_val[80];
2067         COMMAND_CODE    out_index[23];
2068         TERM_COLOR      out_color[23];
2069         char            out_desc[23][MAX_NLEN];
2070         COMMAND_CODE target_item_label = 0;
2071         TERM_LEN wid, hgt;
2072         char inven_label[52 + 1];
2073
2074         /* Starting column */
2075         col = command_gap;
2076
2077         Term_get_size(&wid, &hgt);
2078
2079         /* Default "max-length" */
2080         len = wid - col - 1;
2081
2082
2083         /* Find the "final" slot */
2084         for (i = 0; i < INVEN_PACK; i++)
2085         {
2086                 o_ptr = &p_ptr->inventory_list[i];
2087                 if (!o_ptr->k_idx) continue;
2088
2089                 /* Track */
2090                 z = i + 1;
2091         }
2092
2093         prepare_label_string(inven_label, USE_INVEN);
2094
2095         /* Display the p_ptr->inventory_list */
2096         for (k = 0, i = 0; i < z; i++)
2097         {
2098                 o_ptr = &p_ptr->inventory_list[i];
2099
2100                 /* Is this item acceptable? */
2101                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
2102
2103                 object_desc(o_name, o_ptr, 0);
2104
2105                 /* Save the object index, color, and description */
2106                 out_index[k] = i;
2107                 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2108
2109                 /* Grey out charging items */
2110                 if (o_ptr->timeout)
2111                 {
2112                         out_color[k] = TERM_L_DARK;
2113                 }
2114
2115                 (void)strcpy(out_desc[k], o_name);
2116
2117                 /* Find the predicted "line length" */
2118                 l = strlen(out_desc[k]) + 5;
2119
2120                 /* Be sure to account for the weight */
2121                 if (show_weights) l += 9;
2122
2123                 /* Account for icon if displayed */
2124                 if (show_item_graph)
2125                 {
2126                         l += 2;
2127                         if (use_bigtile) l++;
2128                 }
2129
2130                 /* Maintain the maximum length */
2131                 if (l > len) len = l;
2132
2133                 /* Advance to next "line" */
2134                 k++;
2135         }
2136
2137         /* Find the column to start in */
2138         col = (len > wid - 4) ? 0 : (wid - len - 1);
2139
2140         /* Output each entry */
2141         for (j = 0; j < k; j++)
2142         {
2143                 i = out_index[j];
2144                 o_ptr = &p_ptr->inventory_list[i];
2145
2146                 /* Clear the line */
2147                 prt("", j + 1, col ? col - 2 : col);
2148
2149                 if (use_menu && target_item)
2150                 {
2151                         if (j == (target_item-1))
2152                         {
2153                                 strcpy(tmp_val, _("》", "> "));
2154                                 target_item_label = i;
2155                         }
2156                         else strcpy(tmp_val, "  ");
2157                 }
2158                 else if (i <= INVEN_PACK)
2159                 {
2160                         /* Prepare an index --(-- */
2161                         sprintf(tmp_val, "%c)", inven_label[i]);
2162                 }
2163                 else
2164                 {
2165                         /* Prepare an index --(-- */
2166                         sprintf(tmp_val, "%c)", index_to_label(i));
2167                 }
2168
2169                 /* Clear the line with the (possibly indented) index */
2170                 put_str(tmp_val, j + 1, col);
2171
2172                 cur_col = col + 3;
2173
2174                 /* Display graphics for object, if desired */
2175                 if (show_item_graph)
2176                 {
2177                         TERM_COLOR a = object_attr(o_ptr);
2178                         SYMBOL_CODE c = object_char(o_ptr);
2179                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2180                         if (use_bigtile) cur_col++;
2181
2182                         cur_col += 2;
2183                 }
2184
2185
2186                 /* Display the entry itself */
2187                 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2188
2189                 /* Display the weight if needed */
2190                 if (show_weights)
2191                 {
2192                         int wgt = o_ptr->weight * o_ptr->number;
2193 #ifdef JP
2194                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2195 #else
2196                         (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2197 #endif
2198
2199                         prt(tmp_val, j + 1, wid - 9);
2200                 }
2201         }
2202
2203         /* Make a "shadow" below the list (only if needed) */
2204         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2205
2206         /* Save the new column */
2207         command_gap = col;
2208
2209         return target_item_label;
2210 }
2211
2212
2213 /*!
2214  * @brief 装備アイテムの表示を行う /
2215  * Display the equipment.
2216  * @param target_item アイテムの選択処理を行うか否か。
2217  * @return 選択したアイテムのタグ
2218  */
2219 COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
2220 {
2221         COMMAND_CODE i;
2222         int j, k, l;
2223         int             col, cur_col, len;
2224         object_type *o_ptr;
2225         char            tmp_val[80];
2226         GAME_TEXT o_name[MAX_NLEN];
2227         COMMAND_CODE    out_index[23];
2228         TERM_COLOR      out_color[23];
2229         char            out_desc[23][MAX_NLEN];
2230         COMMAND_CODE target_item_label = 0;
2231         TERM_LEN wid, hgt;
2232         char            equip_label[52 + 1];
2233
2234         /* Starting column */
2235         col = command_gap;
2236
2237         Term_get_size(&wid, &hgt);
2238
2239         /* Maximal length */
2240         len = wid - col - 1;
2241
2242
2243         /* Scan the equipment list */
2244         for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2245         {
2246                 o_ptr = &p_ptr->inventory_list[i];
2247
2248                 /* Is this item acceptable? */
2249                 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr) || (mode & USE_FULL)) &&
2250                     (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2251                                 (mode & IGNORE_BOTHHAND_SLOT))) continue;
2252
2253                 object_desc(o_name, o_ptr, 0);
2254
2255                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2256                 {
2257                         (void)strcpy(out_desc[k],_("(武器を両手持ち)", "(wielding with two-hands)"));
2258                         out_color[k] = TERM_WHITE;
2259                 }
2260                 else
2261                 {
2262                         (void)strcpy(out_desc[k], o_name);
2263                         out_color[k] = tval_to_attr[o_ptr->tval % 128];
2264                 }
2265
2266                 out_index[k] = i;
2267                 /* Grey out charging items */
2268                 if (o_ptr->timeout)
2269                 {
2270                         out_color[k] = TERM_L_DARK;
2271                 }
2272
2273                 /* Extract the maximal length (see below) */
2274 #ifdef JP
2275                 l = strlen(out_desc[k]) + (2 + 1);
2276 #else
2277                 l = strlen(out_desc[k]) + (2 + 3);
2278 #endif
2279
2280
2281                 /* Increase length for labels (if needed) */
2282 #ifdef JP
2283                 if (show_labels) l += (7 + 2);
2284 #else
2285                 if (show_labels) l += (14 + 2);
2286 #endif
2287
2288
2289                 /* Increase length for weight (if needed) */
2290                 if (show_weights) l += 9;
2291
2292                 if (show_item_graph) l += 2;
2293
2294                 /* Maintain the max-length */
2295                 if (l > len) len = l;
2296
2297                 /* Advance the entry */
2298                 k++;
2299         }
2300
2301         /* Hack -- Find a column to start in */
2302 #ifdef JP
2303         col = (len > wid - 6) ? 0 : (wid - len - 1);
2304 #else
2305         col = (len > wid - 4) ? 0 : (wid - len - 1);
2306 #endif
2307
2308         prepare_label_string(equip_label, USE_EQUIP);
2309
2310         /* Output each entry */
2311         for (j = 0; j < k; j++)
2312         {
2313                 i = out_index[j];
2314                 o_ptr = &p_ptr->inventory_list[i];
2315
2316                 /* Clear the line */
2317                 prt("", j + 1, col ? col - 2 : col);
2318
2319                 if (use_menu && target_item)
2320                 {
2321                         if (j == (target_item-1))
2322                         {
2323                                 strcpy(tmp_val, _("》", "> "));
2324                                 target_item_label = i;
2325                         }
2326                         else strcpy(tmp_val, "  ");
2327                 }
2328                 else if (i >= INVEN_RARM)
2329                 {
2330                         /* Prepare an index --(-- */
2331                         sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
2332                 }
2333                 else
2334                 {
2335                         /* Prepare an index --(-- */
2336                         sprintf(tmp_val, "%c)", index_to_label(i));
2337                 }
2338
2339                 /* Clear the line with the (possibly indented) index */
2340                 put_str(tmp_val, j+1, col);
2341
2342                 cur_col = col + 3;
2343
2344                 /* Display graphics for object, if desired */
2345                 if (show_item_graph)
2346                 {
2347                         TERM_COLOR a = object_attr(o_ptr);
2348                         SYMBOL_CODE c = object_char(o_ptr);
2349                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2350                         if (use_bigtile) cur_col++;
2351
2352                         cur_col += 2;
2353                 }
2354
2355                 /* Use labels */
2356                 if (show_labels)
2357                 {
2358                         /* Mention the use */
2359                         (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
2360
2361                         put_str(tmp_val, j+1, cur_col);
2362
2363                         /* Display the entry itself */
2364                         c_put_str(out_color[j], out_desc[j], j+1, _(cur_col + 9, cur_col + 16));
2365                 }
2366
2367                 /* No labels */
2368                 else
2369                 {
2370                         /* Display the entry itself */
2371                         c_put_str(out_color[j], out_desc[j], j+1, cur_col);
2372                 }
2373
2374                 /* Display the weight if needed */
2375                 if (show_weights)
2376                 {
2377                         int wgt = o_ptr->weight * o_ptr->number;
2378 #ifdef JP
2379                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2380 #else
2381                         (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
2382 #endif
2383
2384                         prt(tmp_val, j + 1, wid - 9);
2385                 }
2386         }
2387
2388         /* Make a "shadow" below the list (only if needed) */
2389         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2390
2391         /* Save the new column */
2392         command_gap = col;
2393
2394         return target_item_label;
2395 }
2396
2397 /*!
2398  * @brief サブウィンドウに所持品、装備品リストの表示を行う /
2399  * Flip "inven" and "equip" in any sub-windows
2400  * @return なし
2401  */
2402 void toggle_inven_equip(void)
2403 {
2404         int j;
2405
2406         /* Scan windows */
2407         for (j = 0; j < 8; j++)
2408         {
2409                 /* Unused */
2410                 if (!angband_term[j]) continue;
2411
2412                 /* Flip inven to equip */
2413                 if (window_flag[j] & (PW_INVEN))
2414                 {
2415                         /* Flip flags */
2416                         window_flag[j] &= ~(PW_INVEN);
2417                         window_flag[j] |= (PW_EQUIP);
2418
2419                         p_ptr->window |= (PW_EQUIP);
2420                 }
2421
2422                 /* Flip inven to equip */
2423                 else if (window_flag[j] & (PW_EQUIP))
2424                 {
2425                         /* Flip flags */
2426                         window_flag[j] &= ~(PW_EQUIP);
2427                         window_flag[j] |= (PW_INVEN);
2428
2429                         p_ptr->window |= (PW_INVEN);
2430                 }
2431         }
2432 }
2433
2434 /*!
2435  * @brief 選択したアイテムの確認処理の補助 /
2436  * Verify the choice of an item.
2437  * @param prompt メッセージ表示の一部
2438  * @param item 選択アイテムID
2439  * @return 確認がYesならTRUEを返す。
2440  * @details The item can be negative to mean "item on floor".
2441  */
2442 static bool verify(concptr prompt, INVENTORY_IDX item)
2443 {
2444         GAME_TEXT o_name[MAX_NLEN];
2445         char        out_val[MAX_NLEN+20];
2446         object_type *o_ptr;
2447
2448
2449         /* Inventory */
2450         if (item >= 0)
2451         {
2452                 o_ptr = &p_ptr->inventory_list[item];
2453         }
2454
2455         /* Floor */
2456         else
2457         {
2458                 o_ptr = &current_floor_ptr->o_list[0 - item];
2459         }
2460         object_desc(o_name, o_ptr, 0);
2461
2462         /* Prompt */
2463         (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
2464
2465         /* Query */
2466         return (get_check(out_val));
2467 }
2468
2469
2470 /*!
2471  * @brief 選択したアイテムの確認処理のメインルーチン /
2472  * @param item 選択アイテムID
2473  * @return 確認がYesならTRUEを返す。
2474  * @details The item can be negative to mean "item on floor".
2475  * Hack -- allow user to "prevent" certain choices
2476  */
2477 static bool get_item_allow(INVENTORY_IDX item)
2478 {
2479         concptr s;
2480         object_type *o_ptr;
2481         if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
2482
2483         /* Inventory */
2484         if (item >= 0)
2485         {
2486                 o_ptr = &p_ptr->inventory_list[item];
2487         }
2488
2489         /* Floor */
2490         else
2491         {
2492                 o_ptr = &current_floor_ptr->o_list[0 - item];
2493         }
2494
2495         /* No inscription */
2496         if (!o_ptr->inscription) return (TRUE);
2497
2498         /* Find a '!' */
2499         s = my_strchr(quark_str(o_ptr->inscription), '!');
2500
2501         /* Process preventions */
2502         while (s)
2503         {
2504                 /* Check the "restriction" */
2505                 if ((s[1] == command_cmd) || (s[1] == '*'))
2506                 {
2507                         /* Verify the choice */
2508                         if (!verify(_("本当に", "Really try"), item)) return (FALSE);
2509                 }
2510
2511                 /* Find another '!' */
2512                 s = my_strchr(s + 1, '!');
2513         }
2514
2515         /* Allow it */
2516         return (TRUE);
2517 }
2518
2519
2520 /*!
2521  * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
2522  * Auxiliary function for "get_item()" -- test an index
2523  * @param i 選択アイテムID
2524  * @return 正規のIDならばTRUEを返す。
2525  */
2526 static bool get_item_okay(OBJECT_IDX i)
2527 {
2528         /* Illegal items */
2529         if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
2530
2531         if (select_ring_slot) return is_ring_slot(i);
2532
2533         /* Verify the item */
2534         if (!item_tester_okay(&p_ptr->inventory_list[i])) return (FALSE);
2535
2536         /* Assume okay */
2537         return (TRUE);
2538 }
2539
2540 /*!
2541  * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
2542  * Determine whether get_item() can get some item or not
2543  * @return アイテムを拾えるならばTRUEを返す。
2544  * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
2545  */
2546 bool can_get_item(void)
2547 {
2548         int j;
2549         OBJECT_IDX floor_list[23];
2550         ITEM_NUMBER floor_num = 0;
2551
2552         for (j = 0; j < INVEN_TOTAL; j++)
2553                 if (item_tester_okay(&p_ptr->inventory_list[j]))
2554                         return TRUE;
2555
2556         floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2557         if (floor_num)
2558                 return TRUE;
2559
2560         return FALSE;
2561 }
2562
2563 /*!
2564  * @brief オブジェクト選択の汎用関数 /
2565  * Let the user select an item, save its "index"
2566  * @param cp 選択したオブジェクトのIDを返す。
2567  * @param pmt 選択目的のメッセージ
2568  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
2569  * @param mode オプションフラグ
2570  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
2571  * Return TRUE only if an acceptable item was chosen by the user.\n
2572  * @details
2573  * The selected item must satisfy the "item_tester_hook()" function,\n
2574  * if that hook is set, and the "item_tester_tval", if that value is set.\n
2575  *\n
2576  * All "item_tester" restrictions are cleared before this function returns.\n
2577  *\n
2578  * The user is allowed to choose acceptable items from the equipment,\n
2579  * p_ptr->inventory_list, or floor, respectively, if the proper flag was given,\n
2580  * and there are any acceptable items in that location.\n
2581  *\n
2582  * The equipment or p_ptr->inventory_list are displayed (even if no acceptable\n
2583  * items are in that location) if the proper flag was given.\n
2584  *\n
2585  * If there are no acceptable items available anywhere, and "str" is\n
2586  * not NULL, then it will be used as the text of a warning message\n
2587  * before the function returns.\n
2588  *\n
2589  * Note that the user must press "-" to specify the item on the floor,\n
2590  * and there is no way to "examine" the item on the floor, while the\n
2591  * use of "capital" letters will "examine" an p_ptr->inventory_list/equipment item,\n
2592  * and prompt for its use.\n
2593  *\n
2594  * If a legal item is selected from the p_ptr->inventory_list, we save it in "cp"\n
2595  * directly (0 to 35), and return TRUE.\n
2596  *\n
2597  * If a legal item is selected from the floor, we save it in "cp" as\n
2598  * a negative (-1 to -511), and return TRUE.\n
2599  *\n
2600  * If no item is available, we do nothing to "cp", and we display a\n
2601  * warning message, using "str" if available, and return FALSE.\n
2602  *\n
2603  * If no item is selected, we do nothing to "cp", and return FALSE.\n
2604  *\n
2605  * Global "p_ptr->command_new" is used when viewing the p_ptr->inventory_list or equipment\n
2606  * to allow the user to enter a command while viewing those screens, and\n
2607  * also to induce "auto-enter" of stores, and other such stuff.\n
2608  *\n
2609  * Global "p_ptr->command_see" may be set before calling this function to start\n
2610  * out in "browse" mode.  It is cleared before this function returns.\n
2611  *\n
2612  * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
2613  * If it is TRUE then we are viewing p_ptr->inventory_list, else equipment.\n
2614  *\n
2615  * We always erase the prompt when we are done, leaving a blank line,\n
2616  * or a warning message, if appropriate, if no items are available.\n
2617  */
2618 bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode)
2619 {
2620         OBJECT_IDX this_o_idx, next_o_idx = 0;
2621
2622         char which = ' ';
2623
2624         int j;
2625         OBJECT_IDX k;
2626         OBJECT_IDX i1, i2;
2627         OBJECT_IDX e1, e2;
2628
2629         bool done, item;
2630
2631         bool oops = FALSE;
2632
2633         bool equip = FALSE;
2634         bool inven = FALSE;
2635         bool floor = FALSE;
2636
2637         bool allow_floor = FALSE;
2638
2639         bool toggle = FALSE;
2640
2641         char tmp_val[160];
2642         char out_val[160];
2643
2644         int menu_line = (use_menu ? 1 : 0);
2645         int max_inven = 0;
2646         int max_equip = 0;
2647
2648         static char prev_tag = '\0';
2649         char cur_tag = '\0';
2650
2651         if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
2652
2653         /* Extract args */
2654         if (mode & USE_EQUIP) equip = TRUE;
2655         if (mode & USE_INVEN) inven = TRUE;
2656         if (mode & USE_FLOOR) floor = TRUE;
2657
2658         /* Get the item index */
2659         if (repeat_pull(cp))
2660         {
2661                 /* the_force */
2662                 if (mode & USE_FORCE && (*cp == INVEN_FORCE))
2663                 {
2664                         item_tester_tval = 0;
2665                         item_tester_hook = NULL;
2666                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2667                         return (TRUE);
2668                 }
2669
2670                 /* Floor item? */
2671                 else if (floor && (*cp < 0))
2672                 {
2673                         object_type *o_ptr;
2674
2675                         /* Special index */
2676                         k = 0 - (*cp);
2677                         o_ptr = &current_floor_ptr->o_list[k];
2678
2679                         /* Validate the item */
2680                         if (item_tester_okay(o_ptr) || (mode & USE_FULL))
2681                         {
2682                                 /* Forget restrictions */
2683                                 item_tester_tval = 0;
2684                                 item_tester_hook = NULL;
2685                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2686
2687                                 /* Success */
2688                                 return TRUE;
2689                         }
2690                 }
2691
2692                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2693                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2694                 {
2695                         if (prev_tag && command_cmd)
2696                         {
2697                                 /* Look up the tag and validate the item */
2698                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2699                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2700                                 else if (!get_item_okay(k)) /* Reject */;
2701                                 else
2702                                 {
2703                                         /* Accept that choice */
2704                                         (*cp) = k;
2705
2706                                         /* Forget restrictions */
2707                                         item_tester_tval = 0;
2708                                         item_tester_hook = NULL;
2709                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2710
2711                                         /* Success */
2712                                         return TRUE;
2713                                 }
2714
2715                                 prev_tag = '\0'; /* prev_tag is no longer effective */
2716                         }
2717
2718                         /* Verify the item */
2719                         else if (get_item_okay(*cp))
2720                         {
2721                                 /* Forget restrictions */
2722                                 item_tester_tval = 0;
2723                                 item_tester_hook = NULL;
2724                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2725
2726                                 /* Success */
2727                                 return TRUE;
2728                         }
2729                 }
2730         }
2731         msg_print(NULL);
2732
2733         /* Not done */
2734         done = FALSE;
2735
2736         /* No item selected */
2737         item = FALSE;
2738
2739
2740         /* Full p_ptr->inventory_list */
2741         i1 = 0;
2742         i2 = INVEN_PACK - 1;
2743
2744         /* Forbid p_ptr->inventory_list */
2745         if (!inven) i2 = -1;
2746         else if (use_menu)
2747         {
2748                 for (j = 0; j < INVEN_PACK; j++)
2749                         if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
2750         }
2751
2752         /* Restrict p_ptr->inventory_list indexes */
2753         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2754         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2755
2756
2757         /* Full equipment */
2758         e1 = INVEN_RARM;
2759         e2 = INVEN_TOTAL - 1;
2760
2761         /* Forbid equipment */
2762         if (!equip) e2 = -1;
2763         else if (use_menu)
2764         {
2765                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2766                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
2767                 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
2768         }
2769
2770         /* Restrict equipment indexes */
2771         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2772         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2773
2774         if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
2775         {
2776                 if (p_ptr->migite)
2777                 {
2778                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2779                 }
2780                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
2781         }
2782
2783
2784         /* Restrict floor usage */
2785         if (floor)
2786         {
2787                 /* Scan all objects in the grid */
2788                 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2789                 {
2790                         object_type *o_ptr;
2791                         o_ptr = &current_floor_ptr->o_list[this_o_idx];
2792                         next_o_idx = o_ptr->next_o_idx;
2793
2794                         /* Accept the item on the floor if legal */
2795                         if ((item_tester_okay(o_ptr) || (mode & USE_FULL)) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
2796                 }
2797         }
2798
2799         /* Require at least one legal choice */
2800         if (!allow_floor && (i1 > i2) && (e1 > e2))
2801         {
2802                 /* Cancel p_ptr->command_see */
2803                 command_see = FALSE;
2804                 oops = TRUE;
2805                 done = TRUE;
2806
2807                 if (mode & USE_FORCE) {
2808                     *cp = INVEN_FORCE;
2809                     item = TRUE;
2810                 }
2811         }
2812
2813         /* Analyze choices */
2814         else
2815         {
2816                 /* Hack -- Start on equipment if requested */
2817                 if (command_see && command_wrk && equip)
2818                 {
2819                         command_wrk = TRUE;
2820                 }
2821
2822                 /* Use p_ptr->inventory_list if allowed */
2823                 else if (inven)
2824                 {
2825                         command_wrk = FALSE;
2826                 }
2827
2828                 /* Use equipment if allowed */
2829                 else if (equip)
2830                 {
2831                         command_wrk = TRUE;
2832                 }
2833
2834                 /* Use p_ptr->inventory_list for floor */
2835                 else
2836                 {
2837                         command_wrk = FALSE;
2838                 }
2839         }
2840
2841
2842         /*
2843          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2844          */
2845         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2846
2847         /* Hack -- start out in "display" mode */
2848         if (command_see)
2849         {
2850                 screen_save();
2851         }
2852
2853
2854         /* Repeat until done */
2855         while (!done)
2856         {
2857                 COMMAND_CODE get_item_label = 0;
2858
2859                 /* Show choices */
2860                 int ni = 0;
2861                 int ne = 0;
2862
2863                 /* Scan windows */
2864                 for (j = 0; j < 8; j++)
2865                 {
2866                         /* Unused */
2867                         if (!angband_term[j]) continue;
2868
2869                         /* Count windows displaying inven */
2870                         if (window_flag[j] & (PW_INVEN)) ni++;
2871
2872                         /* Count windows displaying equip */
2873                         if (window_flag[j] & (PW_EQUIP)) ne++;
2874                 }
2875
2876                 /* Toggle if needed */
2877                 if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
2878                 {
2879                         /* Toggle */
2880                         toggle_inven_equip();
2881
2882                         /* Track toggles */
2883                         toggle = !toggle;
2884                 }
2885
2886                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2887                 handle_stuff();
2888
2889                 /* Inventory screen */
2890                 if (!command_wrk)
2891                 {
2892                         /* Redraw if needed */
2893                         if (command_see) get_item_label = show_inven(menu_line, mode);
2894                 }
2895
2896                 /* Equipment screen */
2897                 else
2898                 {
2899                         /* Redraw if needed */
2900                         if (command_see) get_item_label = show_equip(menu_line, mode);
2901                 }
2902
2903                 /* Viewing p_ptr->inventory_list */
2904                 if (!command_wrk)
2905                 {
2906                         /* Begin the prompt */
2907                         sprintf(out_val, _("持ち物:", "Inven:"));
2908
2909                         /* Some legal items */
2910                         if ((i1 <= i2) && !use_menu)
2911                         {
2912                                 /* Build the prompt */
2913                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2914                                         index_to_label(i1), index_to_label(i2));
2915
2916                                 /* Append */
2917                                 strcat(out_val, tmp_val);
2918                         }
2919
2920                         /* Indicate ability to "view" */
2921                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2922
2923                         /* Append */
2924                         if (equip) strcat(out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
2925                 }
2926
2927                 /* Viewing equipment */
2928                 else
2929                 {
2930                         /* Begin the prompt */
2931                         sprintf(out_val, _("装備品:", "Equip:"));
2932
2933                         /* Some legal items */
2934                         if ((e1 <= e2) && !use_menu)
2935                         {
2936                                 /* Build the prompt */
2937                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2938                                         index_to_label(e1), index_to_label(e2));
2939
2940                                 /* Append */
2941                                 strcat(out_val, tmp_val);
2942                         }
2943
2944                         /* Indicate ability to "view" */
2945                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2946
2947                         /* Append */
2948                         if (inven) strcat(out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
2949                 }
2950
2951                 /* Indicate legality of the "floor" item */
2952                 if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
2953                 if (mode & USE_FORCE) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
2954
2955                 /* Finish the prompt */
2956                 strcat(out_val, " ESC");
2957
2958                 /* Build the prompt */
2959                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
2960
2961                 /* Show the prompt */
2962                 prt(tmp_val, 0, 0);
2963
2964                 /* Get a key */
2965                 which = inkey();
2966
2967                 if (use_menu)
2968                 {
2969                 int max_line = (command_wrk ? max_equip : max_inven);
2970                 switch (which)
2971                 {
2972                         case ESCAPE:
2973                         case 'z':
2974                         case 'Z':
2975                         case '0':
2976                         {
2977                                 done = TRUE;
2978                                 break;
2979                         }
2980
2981                         case '8':
2982                         case 'k':
2983                         case 'K':
2984                         {
2985                                 menu_line += (max_line - 1);
2986                                 break;
2987                         }
2988
2989                         case '2':
2990                         case 'j':
2991                         case 'J':
2992                         {
2993                                 menu_line++;
2994                                 break;
2995                         }
2996
2997                         case '4':
2998                         case '6':
2999                         case 'h':
3000                         case 'H':
3001                         case 'l':
3002                         case 'L':
3003                         {
3004                                 /* Verify legality */
3005                                 if (!inven || !equip)
3006                                 {
3007                                         bell();
3008                                         break;
3009                                 }
3010
3011                                 /* Hack -- Fix screen */
3012                                 if (command_see)
3013                                 {
3014                                         screen_load();
3015                                         screen_save();
3016                                 }
3017
3018                                 /* Switch inven/equip */
3019                                 command_wrk = !command_wrk;
3020                                 max_line = (command_wrk ? max_equip : max_inven);
3021                                 if (menu_line > max_line) menu_line = max_line;
3022
3023                                 /* Need to redraw */
3024                                 break;
3025                         }
3026
3027                         case 'x':
3028                         case 'X':
3029                         case '\r':
3030                         case '\n':
3031                         {
3032                                 if (command_wrk == USE_FLOOR)
3033                                 {
3034                                         /* Special index */
3035                                         (*cp) = -get_item_label;
3036                                 }
3037                                 else
3038                                 {
3039                                         /* Validate the item */
3040                                         if (!get_item_okay(get_item_label))
3041                                         {
3042                                                 bell();
3043                                                 break;
3044                                         }
3045
3046                                         /* Allow player to "refuse" certain actions */
3047                                         if (!get_item_allow(get_item_label))
3048                                         {
3049                                                 done = TRUE;
3050                                                 break;
3051                                         }
3052
3053                                         /* Accept that choice */
3054                                         (*cp) = get_item_label;
3055                                 }
3056
3057                                 item = TRUE;
3058                                 done = TRUE;
3059                                 break;
3060                         }
3061                         case 'w':
3062                         {
3063                                 if (mode & USE_FORCE) {
3064                                         *cp = INVEN_FORCE;
3065                                         item = TRUE;
3066                                         done = TRUE;
3067                                         break;
3068                                 }
3069                         }
3070                 }
3071                 if (menu_line > max_line) menu_line -= max_line;
3072                 }
3073                 else
3074                 {
3075                 /* Parse it */
3076                 switch (which)
3077                 {
3078                         case ESCAPE:
3079                         {
3080                                 done = TRUE;
3081                                 break;
3082                         }
3083
3084                         case '*':
3085                         case '?':
3086                         case ' ':
3087                         {
3088                                 /* Hide the list */
3089                                 if (command_see)
3090                                 {
3091                                         /* Flip flag */
3092                                         command_see = FALSE;
3093                                         screen_load();
3094                                 }
3095
3096                                 /* Show the list */
3097                                 else
3098                                 {
3099                                         screen_save();
3100
3101                                         /* Flip flag */
3102                                         command_see = TRUE;
3103                                 }
3104                                 break;
3105                         }
3106
3107                         case '/':
3108                         {
3109                                 /* Verify legality */
3110                                 if (!inven || !equip)
3111                                 {
3112                                         bell();
3113                                         break;
3114                                 }
3115
3116                                 /* Hack -- Fix screen */
3117                                 if (command_see)
3118                                 {
3119                                         screen_load();
3120                                         screen_save();
3121                                 }
3122
3123                                 /* Switch inven/equip */
3124                                 command_wrk = !command_wrk;
3125
3126                                 /* Need to redraw */
3127                                 break;
3128                         }
3129
3130                         case '-':
3131                         {
3132                                 /* Use floor item */
3133                                 if (allow_floor)
3134                                 {
3135                                         /* Scan all objects in the grid */
3136                                         for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3137                                         {
3138                                                 object_type *o_ptr;
3139                                                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
3140                                                 next_o_idx = o_ptr->next_o_idx;
3141
3142                                                 /* Validate the item */
3143                                                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
3144
3145                                                 /* Special index */
3146                                                 k = 0 - this_o_idx;
3147
3148                                                 /* Verify the item (if required) */
3149                                                 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
3150
3151                                                 /* Allow player to "refuse" certain actions */
3152                                                 if (!get_item_allow(k)) continue;
3153
3154                                                 /* Accept that choice */
3155                                                 (*cp) = k;
3156                                                 item = TRUE;
3157                                                 done = TRUE;
3158                                                 break;
3159                                         }
3160
3161                                         /* Outer break */
3162                                         if (done) break;
3163                                 }
3164
3165                                 bell();
3166                                 break;
3167                         }
3168
3169                         case '0':
3170                         case '1': case '2': case '3':
3171                         case '4': case '5': case '6':
3172                         case '7': case '8': case '9':
3173                         {
3174                                 /* Look up the tag */
3175                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3176                                 {
3177                                         bell();
3178                                         break;
3179                                 }
3180
3181                                 /* Hack -- Validate the item */
3182                                 if ((k < INVEN_RARM) ? !inven : !equip)
3183                                 {
3184                                         bell();
3185                                         break;
3186                                 }
3187
3188                                 /* Validate the item */
3189                                 if (!get_item_okay(k))
3190                                 {
3191                                         bell();
3192                                         break;
3193                                 }
3194
3195                                 /* Allow player to "refuse" certain actions */
3196                                 if (!get_item_allow(k))
3197                                 {
3198                                         done = TRUE;
3199                                         break;
3200                                 }
3201
3202                                 /* Accept that choice */
3203                                 (*cp) = k;
3204                                 item = TRUE;
3205                                 done = TRUE;
3206                                 cur_tag = which;
3207                                 break;
3208                         }
3209
3210 #if 0
3211                         case '\n':
3212                         case '\r':
3213                         {
3214                                 /* Choose "default" p_ptr->inventory_list item */
3215                                 if (!command_wrk)
3216                                 {
3217                                         k = ((i1 == i2) ? i1 : -1);
3218                                 }
3219
3220                                 /* Choose "default" equipment item */
3221                                 else
3222                                 {
3223                                         k = ((e1 == e2) ? e1 : -1);
3224                                 }
3225
3226                                 /* Validate the item */
3227                                 if (!get_item_okay(k))
3228                                 {
3229                                         bell();
3230                                         break;
3231                                 }
3232
3233                                 /* Allow player to "refuse" certain actions */
3234                                 if (!get_item_allow(k))
3235                                 {
3236                                         done = TRUE;
3237                                         break;
3238                                 }
3239
3240                                 /* Accept that choice */
3241                                 (*cp) = k;
3242                                 item = TRUE;
3243                                 done = TRUE;
3244                                 break;
3245                         }
3246 #endif
3247
3248                         case 'w':
3249                         {
3250                                 if (mode & USE_FORCE) {
3251                                         *cp = INVEN_FORCE;
3252                                         item = TRUE;
3253                                         done = TRUE;
3254                                         break;
3255                                 }
3256
3257                                 /* Fall through */
3258                         }
3259
3260                         default:
3261                         {
3262                                 int ver;
3263                                 bool not_found = FALSE;
3264
3265                                 /* Look up the alphabetical tag */
3266                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3267                                 {
3268                                         not_found = TRUE;
3269                                 }
3270
3271                                 /* Hack -- Validate the item */
3272                                 else if ((k < INVEN_RARM) ? !inven : !equip)
3273                                 {
3274                                         not_found = TRUE;
3275                                 }
3276
3277                                 /* Validate the item */
3278                                 else if (!get_item_okay(k))
3279                                 {
3280                                         not_found = TRUE;
3281                                 }
3282
3283                                 if (!not_found)
3284                                 {
3285                                         /* Accept that choice */
3286                                         (*cp) = k;
3287                                         item = TRUE;
3288                                         done = TRUE;
3289                                         cur_tag = which;
3290                                         break;
3291                                 }
3292
3293                                 /* Extract "query" setting */
3294                                 ver = isupper(which);
3295                                 which = (char)tolower(which);
3296
3297                                 /* Convert letter to p_ptr->inventory_list index */
3298                                 if (!command_wrk)
3299                                 {
3300                                         if (which == '(') k = i1;
3301                                         else if (which == ')') k = i2;
3302                                         else k = label_to_inven(which);
3303                                 }
3304
3305                                 /* Convert letter to equipment index */
3306                                 else
3307                                 {
3308                                         if (which == '(') k = e1;
3309                                         else if (which == ')') k = e2;
3310                                         else k = label_to_equip(which);
3311                                 }
3312
3313                                 /* Validate the item */
3314                                 if (!get_item_okay(k))
3315                                 {
3316                                         bell();
3317                                         break;
3318                                 }
3319
3320                                 /* Verify the item */
3321                                 if (ver && !verify(_("本当に", "Try"), k))
3322                                 {
3323                                         done = TRUE;
3324                                         break;
3325                                 }
3326
3327                                 /* Allow player to "refuse" certain actions */
3328                                 if (!get_item_allow(k))
3329                                 {
3330                                         done = TRUE;
3331                                         break;
3332                                 }
3333
3334                                 /* Accept that choice */
3335                                 (*cp) = k;
3336                                 item = TRUE;
3337                                 done = TRUE;
3338                                 break;
3339                         }
3340                 }
3341                 }
3342         }
3343
3344
3345         /* Fix the screen if necessary */
3346         if (command_see)
3347         {
3348                 screen_load();
3349
3350                 /* Hack -- Cancel "display" */
3351                 command_see = FALSE;
3352         }
3353
3354
3355         /* Forget the item_tester_tval restriction */
3356         item_tester_tval = 0;
3357
3358         /* Forget the item_tester_hook restriction */
3359         item_tester_hook = NULL;
3360
3361
3362         /* Clean up  'show choices' */
3363         /* Toggle again if needed */
3364         if (toggle) toggle_inven_equip();
3365
3366         p_ptr->window |= (PW_INVEN | PW_EQUIP);
3367         handle_stuff();
3368
3369         /* Clear the prompt line */
3370         prt("", 0, 0);
3371
3372         /* Warning if needed */
3373         if (oops && str) msg_print(str);
3374
3375         if (item)
3376         {
3377                 repeat_push(*cp);
3378                 if (command_cmd) prev_tag = cur_tag;
3379                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3380         }
3381         return (item);
3382 }
3383
3384 /*
3385  * Choose an item and get auto-picker entry from it.
3386  */
3387 object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
3388 {
3389         OBJECT_IDX item;
3390         if (!get_item(&item, q, s, option)) return NULL;
3391         if (idx) *idx = item;
3392
3393         if (item == INVEN_FORCE) return NULL;
3394
3395         /* Get the item (in the pack) */
3396         else if (item >= 0) return &p_ptr->inventory_list[item];
3397
3398         /* Get the item (on the floor) */
3399         else return &current_floor_ptr->o_list[0 - item];
3400 }
3401
3402
3403 /*!
3404  * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
3405  * @param items オブジェクトのIDリストを返すための配列参照ポインタ
3406  * @param y 走査するフロアのY座標
3407  * @param x 走査するフロアのX座標
3408  * @param mode オプションフラグ
3409  * @return 対象のマスに落ちているアイテム数
3410  * @details
3411  * Return a list of o_list[] indexes of items at the given current_floor_ptr->grid_array
3412  * location. Valid flags are:
3413  *
3414  *              mode & 0x01 -- Item tester
3415  *              mode & 0x02 -- Marked items only
3416  *              mode & 0x04 -- Stop after first
3417  */
3418 ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
3419 {
3420         OBJECT_IDX this_o_idx, next_o_idx;
3421
3422         ITEM_NUMBER num = 0;
3423
3424         /* Sanity */
3425         if (!in_bounds(y, x)) return 0;
3426
3427         /* Scan all objects in the grid */
3428         for (this_o_idx = current_floor_ptr->grid_array[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3429         {
3430                 object_type *o_ptr;
3431                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
3432                 next_o_idx = o_ptr->next_o_idx;
3433
3434                 /* Item tester */
3435                 if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
3436
3437                 /* Marked */
3438                 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
3439
3440                 /* Accept this item */
3441                 /* XXX Hack -- Enforce limit */
3442                 if (num < 23)
3443                         items[num] = this_o_idx;
3444
3445                 num++;
3446
3447                 /* Only one */
3448                 if (mode & 0x04) break;
3449         }
3450         return num;
3451 }
3452
3453
3454 /*!
3455  * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
3456  * @param target_item カーソルの初期値
3457  * @param y 走査するフロアのY座標
3458  * @param x 走査するフロアのX座標
3459  * @param min_width 表示の長さ
3460  * @return 選択したアイテムの添え字
3461  * @details
3462  */
3463 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
3464 {
3465         COMMAND_CODE i, m;
3466         int j, k, l;
3467         int col, len;
3468
3469         object_type *o_ptr;
3470
3471         GAME_TEXT o_name[MAX_NLEN];
3472         char tmp_val[80];
3473
3474         COMMAND_CODE out_index[23];
3475         TERM_COLOR out_color[23];
3476         char out_desc[23][MAX_NLEN];
3477         COMMAND_CODE target_item_label = 0;
3478
3479         OBJECT_IDX floor_list[23];
3480         ITEM_NUMBER floor_num;
3481         TERM_LEN wid, hgt;
3482         char floor_label[52 + 1];
3483
3484         bool dont_need_to_show_weights = TRUE;
3485
3486         Term_get_size(&wid, &hgt);
3487
3488         /* Default length */
3489         len = MAX((*min_width), 20);
3490
3491         /* Scan for objects in the grid, using item_tester_okay() */
3492         floor_num = scan_floor(floor_list, y, x, 0x03);
3493
3494         /* Display the floor objects */
3495         for (k = 0, i = 0; i < floor_num && i < 23; i++)
3496         {
3497                 o_ptr = &current_floor_ptr->o_list[floor_list[i]];
3498
3499                 object_desc(o_name, o_ptr, 0);
3500
3501                 /* Save the index */
3502                 out_index[k] = i;
3503
3504                 /* Acquire p_ptr->inventory_list color */
3505                 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
3506
3507                 /* Save the object description */
3508                 strcpy(out_desc[k], o_name);
3509
3510                 /* Find the predicted "line length" */
3511                 l = strlen(out_desc[k]) + 5;
3512
3513                 /* Be sure to account for the weight */
3514                 if (show_weights) l += 9;
3515
3516                 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
3517
3518                 /* Maintain the maximum length */
3519                 if (l > len) len = l;
3520
3521                 /* Advance to next "line" */
3522                 k++;
3523         }
3524
3525         if (show_weights && dont_need_to_show_weights) len -= 9;
3526
3527         /* Save width */
3528         *min_width = len;
3529
3530         /* Find the column to start in */
3531         col = (len > wid - 4) ? 0 : (wid - len - 1);
3532
3533         prepare_label_string_floor(floor_label, floor_list, floor_num);
3534
3535         /* Output each entry */
3536         for (j = 0; j < k; j++)
3537         {
3538                 m = floor_list[out_index[j]];
3539                 o_ptr = &current_floor_ptr->o_list[m];
3540
3541                 /* Clear the line */
3542                 prt("", j + 1, col ? col - 2 : col);
3543
3544                 if (use_menu && target_item)
3545                 {
3546                         if (j == (target_item-1))
3547                         {
3548                                 strcpy(tmp_val, _("》", "> "));
3549                                 target_item_label = m;
3550                         }
3551                         else strcpy(tmp_val, "   ");
3552                 }
3553                 else
3554                 {
3555                         /* Prepare an index --(-- */
3556                         sprintf(tmp_val, "%c)", floor_label[j]);
3557                 }
3558
3559                 /* Clear the line with the (possibly indented) index */
3560                 put_str(tmp_val, j + 1, col);
3561
3562                 /* Display the entry itself */
3563                 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
3564
3565                 /* Display the weight if needed */
3566                 if (show_weights && (o_ptr->tval != TV_GOLD))
3567                 {
3568                         int wgt = o_ptr->weight * o_ptr->number;
3569 #ifdef JP
3570                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3571 #else
3572                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3573 #endif
3574
3575                         prt(tmp_val, j + 1, wid - 9);
3576                 }
3577         }
3578
3579         /* Make a "shadow" below the list (only if needed) */
3580         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3581
3582         return target_item_label;
3583 }
3584
3585 /*!
3586  * @brief オブジェクト選択の汎用関数(床上アイテム用) /
3587  * Let the user select an item, save its "index"
3588  * @param cp 選択したオブジェクトのIDを返す。
3589  * @param pmt 選択目的のメッセージ
3590  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
3591  * @param mode オプションフラグ
3592  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
3593  */
3594 bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode)
3595 {
3596         char n1 = ' ', n2 = ' ', which = ' ';
3597
3598         int j;
3599         COMMAND_CODE i1, i2;
3600         COMMAND_CODE e1, e2;
3601         COMMAND_CODE k;
3602
3603         bool done, item;
3604
3605         bool oops = FALSE;
3606
3607         /* Extract args */
3608         bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
3609         bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
3610         bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
3611         bool force = (mode & USE_FORCE) ? TRUE : FALSE;
3612
3613         bool allow_equip = FALSE;
3614         bool allow_inven = FALSE;
3615         bool allow_floor = FALSE;
3616
3617         bool toggle = FALSE;
3618
3619         char tmp_val[160];
3620         char out_val[160];
3621
3622         ITEM_NUMBER floor_num;
3623         OBJECT_IDX floor_list[23];
3624         int floor_top = 0;
3625         TERM_LEN min_width = 0;
3626
3627         int menu_line = (use_menu ? 1 : 0);
3628         int max_inven = 0;
3629         int max_equip = 0;
3630
3631         static char prev_tag = '\0';
3632         char cur_tag = '\0';
3633
3634         /* Get the item index */
3635         if (repeat_pull(cp))
3636         {
3637                 /* the_force */
3638                 if (force && (*cp == INVEN_FORCE))
3639                 {
3640                         item_tester_tval = 0;
3641                         item_tester_hook = NULL;
3642                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3643                         return (TRUE);
3644                 }
3645
3646                 /* Floor item? */
3647                 else if (floor && (*cp < 0))
3648                 {
3649                         if (prev_tag && command_cmd)
3650                         {
3651                                 /* Scan all objects in the grid */
3652                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3653
3654                                 /* Look up the tag */
3655                                 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
3656                                 {
3657                                         /* Accept that choice */
3658                                         (*cp) = 0 - floor_list[k];
3659
3660                                         /* Forget restrictions */
3661                                         item_tester_tval = 0;
3662                                         item_tester_hook = NULL;
3663                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3664
3665                                         /* Success */
3666                                         return TRUE;
3667                                 }
3668
3669                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3670                         }
3671
3672                         /* Validate the item */
3673                         else if (item_tester_okay(&current_floor_ptr->o_list[0 - (*cp)]) || (mode & USE_FULL))
3674                         {
3675                                 /* Forget restrictions */
3676                                 item_tester_tval = 0;
3677                                 item_tester_hook = NULL;
3678                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3679
3680                                 /* Success */
3681                                 return TRUE;
3682                         }
3683                 }
3684
3685                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3686                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3687                 {
3688                         if (prev_tag && command_cmd)
3689                         {
3690                                 /* Look up the tag and validate the item */
3691                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3692                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3693                                 else if (!get_item_okay(k)) /* Reject */;
3694                                 else
3695                                 {
3696                                         /* Accept that choice */
3697                                         (*cp) = k;
3698
3699                                         /* Forget restrictions */
3700                                         item_tester_tval = 0;
3701                                         item_tester_hook = NULL;
3702                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3703
3704                                         /* Success */
3705                                         return TRUE;
3706                                 }
3707
3708                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3709                         }
3710
3711                         /* Verify the item */
3712                         else if (get_item_okay(*cp))
3713                         {
3714                                 /* Forget restrictions */
3715                                 item_tester_tval = 0;
3716                                 item_tester_hook = NULL;
3717                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3718
3719                                 /* Success */
3720                                 return TRUE;
3721                         }
3722                 }
3723         }
3724
3725         msg_print(NULL);
3726
3727
3728         /* Not done */
3729         done = FALSE;
3730
3731         /* No item selected */
3732         item = FALSE;
3733
3734
3735         /* Full p_ptr->inventory_list */
3736         i1 = 0;
3737         i2 = INVEN_PACK - 1;
3738
3739         /* Forbid p_ptr->inventory_list */
3740         if (!inven) i2 = -1;
3741         else if (use_menu)
3742         {
3743                 for (j = 0; j < INVEN_PACK; j++)
3744                         if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
3745         }
3746
3747         /* Restrict p_ptr->inventory_list indexes */
3748         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3749         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3750
3751
3752         /* Full equipment */
3753         e1 = INVEN_RARM;
3754         e2 = INVEN_TOTAL - 1;
3755
3756         /* Forbid equipment */
3757         if (!equip) e2 = -1;
3758         else if (use_menu)
3759         {
3760                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3761                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
3762                 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
3763         }
3764
3765         /* Restrict equipment indexes */
3766         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3767         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3768
3769         if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
3770         {
3771                 if (p_ptr->migite)
3772                 {
3773                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3774                 }
3775                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
3776         }
3777
3778
3779         /* Count "okay" floor items */
3780         floor_num = 0;
3781
3782         /* Restrict floor usage */
3783         if (floor)
3784         {
3785                 /* Scan all objects in the grid */
3786                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3787         }
3788
3789         /* Accept p_ptr->inventory_list */
3790         if (i1 <= i2) allow_inven = TRUE;
3791
3792         /* Accept equipment */
3793         if (e1 <= e2) allow_equip = TRUE;
3794
3795         /* Accept floor */
3796         if (floor_num) allow_floor = TRUE;
3797
3798         /* Require at least one legal choice */
3799         if (!allow_inven && !allow_equip && !allow_floor)
3800         {
3801                 /* Cancel p_ptr->command_see */
3802                 command_see = FALSE;
3803                 oops = TRUE;
3804                 done = TRUE;
3805
3806                 if (force) {
3807                     *cp = INVEN_FORCE;
3808                     item = TRUE;
3809                 }
3810         }
3811
3812         /* Analyze choices */
3813         else
3814         {
3815                 /* Hack -- Start on equipment if requested */
3816                 if (command_see && (command_wrk == (USE_EQUIP))
3817                         && allow_equip)
3818                 {
3819                         command_wrk = (USE_EQUIP);
3820                 }
3821
3822                 /* Use p_ptr->inventory_list if allowed */
3823                 else if (allow_inven)
3824                 {
3825                         command_wrk = (USE_INVEN);
3826                 }
3827
3828                 /* Use equipment if allowed */
3829                 else if (allow_equip)
3830                 {
3831                         command_wrk = (USE_EQUIP);
3832                 }
3833
3834                 /* Use floor if allowed */
3835                 else if (allow_floor)
3836                 {
3837                         command_wrk = (USE_FLOOR);
3838                 }
3839         }
3840
3841         /*
3842          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
3843          */
3844         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
3845
3846         /* Hack -- start out in "display" mode */
3847         if (command_see)
3848         {
3849                 screen_save();
3850         }
3851
3852         /* Repeat until done */
3853         while (!done)
3854         {
3855                 COMMAND_CODE get_item_label = 0;
3856
3857                 /* Show choices */
3858                 int ni = 0;
3859                 int ne = 0;
3860
3861                 /* Scan windows */
3862                 for (j = 0; j < 8; j++)
3863                 {
3864                         /* Unused */
3865                         if (!angband_term[j]) continue;
3866
3867                         /* Count windows displaying inven */
3868                         if (window_flag[j] & (PW_INVEN)) ni++;
3869
3870                         /* Count windows displaying equip */
3871                         if (window_flag[j] & (PW_EQUIP)) ne++;
3872                 }
3873
3874                 /* Toggle if needed */
3875                 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
3876                     (command_wrk == (USE_INVEN) && !ni && ne))
3877                 {
3878                         /* Toggle */
3879                         toggle_inven_equip();
3880
3881                         /* Track toggles */
3882                         toggle = !toggle;
3883                 }
3884
3885                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3886                 handle_stuff();
3887
3888                 /* Inventory screen */
3889                 if (command_wrk == (USE_INVEN))
3890                 {
3891                         /* Extract the legal requests */
3892                         n1 = I2A(i1);
3893                         n2 = I2A(i2);
3894
3895                         /* Redraw if needed */
3896                         if (command_see) get_item_label = show_inven(menu_line, mode);
3897                 }
3898
3899                 /* Equipment screen */
3900                 else if (command_wrk == (USE_EQUIP))
3901                 {
3902                         /* Extract the legal requests */
3903                         n1 = I2A(e1 - INVEN_RARM);
3904                         n2 = I2A(e2 - INVEN_RARM);
3905
3906                         /* Redraw if needed */
3907                         if (command_see) get_item_label = show_equip(menu_line, mode);
3908                 }
3909
3910                 /* Floor screen */
3911                 else if (command_wrk == (USE_FLOOR))
3912                 {
3913                         j = floor_top;
3914                         k = MIN(floor_top + 23, floor_num) - 1;
3915
3916                         /* Extract the legal requests */
3917                         n1 = I2A(j - floor_top);
3918                         n2 = I2A(k - floor_top);
3919
3920                         /* Redraw if needed */
3921                         if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
3922                 }
3923
3924                 /* Viewing p_ptr->inventory_list */
3925                 if (command_wrk == (USE_INVEN))
3926                 {
3927                         /* Begin the prompt */
3928                         sprintf(out_val, _("持ち物:", "Inven:"));
3929
3930                         if (!use_menu)
3931                         {
3932                                 /* Build the prompt */
3933                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3934                                         index_to_label(i1), index_to_label(i2));
3935
3936                                 /* Append */
3937                                 strcat(out_val, tmp_val);
3938                         }
3939
3940                         /* Indicate ability to "view" */
3941                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3942
3943                         /* Append */
3944                         if (allow_equip)
3945                         {
3946                                 if (!use_menu)
3947                                         strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
3948                                 else if (allow_floor)
3949                                         strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
3950                                 else
3951                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
3952                         }
3953
3954                         /* Append */
3955                         if (allow_floor)
3956                         {
3957                                 if (!use_menu)
3958                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
3959                                 else if (allow_equip)
3960                                         strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
3961                                 else
3962                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
3963                         }
3964                 }
3965
3966                 /* Viewing equipment */
3967                 else if (command_wrk == (USE_EQUIP))
3968                 {
3969                         /* Begin the prompt */
3970                         sprintf(out_val, _("装備品:", "Equip:"));
3971
3972                         if (!use_menu)
3973                         {
3974                                 /* Build the prompt */
3975                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3976                                         index_to_label(e1), index_to_label(e2));
3977
3978                                 /* Append */
3979                                 strcat(out_val, tmp_val);
3980                         }
3981
3982                         /* Indicate ability to "view" */
3983                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3984
3985                         /* Append */
3986                         if (allow_inven)
3987                         {
3988                                 if (!use_menu)
3989                                         strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
3990                                 else if (allow_floor)
3991                                         strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
3992                                 else
3993                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
3994                         }
3995
3996                         /* Append */
3997                         if (allow_floor)
3998                         {
3999                                 if (!use_menu)
4000                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
4001                                 else if (allow_inven)
4002                                         strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
4003                                 else
4004                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
4005                         }
4006                 }
4007
4008                 /* Viewing floor */
4009                 else if (command_wrk == (USE_FLOOR))
4010                 {
4011                         /* Begin the prompt */
4012                         sprintf(out_val, _("床上:", "Floor:"));
4013
4014                         if (!use_menu)
4015                         {
4016                                 /* Build the prompt */
4017                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
4018
4019                                 /* Append */
4020                                 strcat(out_val, tmp_val);
4021                         }
4022
4023                         /* Indicate ability to "view" */
4024                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4025
4026                         if (use_menu)
4027                         {
4028                                 if (allow_inven && allow_equip)
4029                                 {
4030                                         strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
4031                                 }
4032                                 else if (allow_inven)
4033                                 {
4034                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4035                                 }
4036                                 else if (allow_equip)
4037                                 {
4038                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
4039                                 }
4040                         }
4041                         /* Append */
4042                         else if (allow_inven)
4043                         {
4044                                 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4045                         }
4046                         else if (allow_equip)
4047                         {
4048                                 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
4049                         }
4050
4051                         /* Append */
4052                         if (command_see && !use_menu)
4053                         {
4054                                 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
4055                         }
4056                 }
4057
4058                 /* Append */
4059                 if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
4060
4061                 /* Finish the prompt */
4062                 strcat(out_val, " ESC");
4063
4064                 /* Build the prompt */
4065                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
4066
4067                 /* Show the prompt */
4068                 prt(tmp_val, 0, 0);
4069
4070                 /* Get a key */
4071                 which = inkey();
4072
4073                 if (use_menu)
4074                 {
4075                 int max_line = 1;
4076                 if (command_wrk == USE_INVEN) max_line = max_inven;
4077                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4078                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4079                 switch (which)
4080                 {
4081                         case ESCAPE:
4082                         case 'z':
4083                         case 'Z':
4084                         case '0':
4085                         {
4086                                 done = TRUE;
4087                                 break;
4088                         }
4089
4090                         case '8':
4091                         case 'k':
4092                         case 'K':
4093                         {
4094                                 menu_line += (max_line - 1);
4095                                 break;
4096                         }
4097
4098                         case '2':
4099                         case 'j':
4100                         case 'J':
4101                         {
4102                                 menu_line++;
4103                                 break;
4104                         }
4105
4106                         case '4':
4107                         case 'h':
4108                         case 'H':
4109                         {
4110                                 /* Verify legality */
4111                                 if (command_wrk == (USE_INVEN))
4112                                 {
4113                                         if (allow_floor) command_wrk = USE_FLOOR;
4114                                         else if (allow_equip) command_wrk = USE_EQUIP;
4115                                         else
4116                                         {
4117                                                 bell();
4118                                                 break;
4119                                         }
4120                                 }
4121                                 else if (command_wrk == (USE_EQUIP))
4122                                 {
4123                                         if (allow_inven) command_wrk = USE_INVEN;
4124                                         else if (allow_floor) command_wrk = USE_FLOOR;
4125                                         else
4126                                         {
4127                                                 bell();
4128                                                 break;
4129                                         }
4130                                 }
4131                                 else if (command_wrk == (USE_FLOOR))
4132                                 {
4133                                         if (allow_equip) command_wrk = USE_EQUIP;
4134                                         else if (allow_inven) command_wrk = USE_INVEN;
4135                                         else
4136                                         {
4137                                                 bell();
4138                                                 break;
4139                                         }
4140                                 }
4141                                 else
4142                                 {
4143                                         bell();
4144                                         break;
4145                                 }
4146
4147                                 /* Hack -- Fix screen */
4148                                 if (command_see)
4149                                 {
4150                                         screen_load();
4151                                         screen_save();
4152                                 }
4153
4154                                 /* Switch inven/equip */
4155                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4156                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4157                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4158                                 if (menu_line > max_line) menu_line = max_line;
4159
4160                                 /* Need to redraw */
4161                                 break;
4162                         }
4163
4164                         case '6':
4165                         case 'l':
4166                         case 'L':
4167                         {
4168                                 /* Verify legality */
4169                                 if (command_wrk == (USE_INVEN))
4170                                 {
4171                                         if (allow_equip) command_wrk = USE_EQUIP;
4172                                         else if (allow_floor) command_wrk = USE_FLOOR;
4173                                         else
4174                                         {
4175                                                 bell();
4176                                                 break;
4177                                         }
4178                                 }
4179                                 else if (command_wrk == (USE_EQUIP))
4180                                 {
4181                                         if (allow_floor) command_wrk = USE_FLOOR;
4182                                         else if (allow_inven) command_wrk = USE_INVEN;
4183                                         else
4184                                         {
4185                                                 bell();
4186                                                 break;
4187                                         }
4188                                 }
4189                                 else if (command_wrk == (USE_FLOOR))
4190                                 {
4191                                         if (allow_inven) command_wrk = USE_INVEN;
4192                                         else if (allow_equip) command_wrk = USE_EQUIP;
4193                                         else
4194                                         {
4195                                                 bell();
4196                                                 break;
4197                                         }
4198                                 }
4199                                 else
4200                                 {
4201                                         bell();
4202                                         break;
4203                                 }
4204
4205                                 /* Hack -- Fix screen */
4206                                 if (command_see)
4207                                 {
4208                                         screen_load();
4209                                         screen_save();
4210                                 }
4211
4212                                 /* Switch inven/equip */
4213                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4214                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4215                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4216                                 if (menu_line > max_line) menu_line = max_line;
4217
4218                                 /* Need to redraw */
4219                                 break;
4220                         }
4221
4222                         case 'x':
4223                         case 'X':
4224                         case '\r':
4225                         case '\n':
4226                         {
4227                                 if (command_wrk == USE_FLOOR)
4228                                 {
4229                                         /* Special index */
4230                                         (*cp) = -get_item_label;
4231                                 }
4232                                 else
4233                                 {
4234                                         /* Validate the item */
4235                                         if (!get_item_okay(get_item_label))
4236                                         {
4237                                                 bell();
4238                                                 break;
4239                                         }
4240
4241                                         /* Allow player to "refuse" certain actions */
4242                                         if (!get_item_allow(get_item_label))
4243                                         {
4244                                                 done = TRUE;
4245                                                 break;
4246                                         }
4247
4248                                         /* Accept that choice */
4249                                         (*cp) = get_item_label;
4250                                 }
4251
4252                                 item = TRUE;
4253                                 done = TRUE;
4254                                 break;
4255                         }
4256                         case 'w':
4257                         {
4258                                 if (force) {
4259                                         *cp = INVEN_FORCE;
4260                                         item = TRUE;
4261                                         done = TRUE;
4262                                         break;
4263                                 }
4264                         }
4265                 }
4266                 if (menu_line > max_line) menu_line -= max_line;
4267                 }
4268                 else
4269                 {
4270                 /* Parse it */
4271                 switch (which)
4272                 {
4273                         case ESCAPE:
4274                         {
4275                                 done = TRUE;
4276                                 break;
4277                         }
4278
4279                         case '*':
4280                         case '?':
4281                         case ' ':
4282                         {
4283                                 /* Hide the list */
4284                                 if (command_see)
4285                                 {
4286                                         /* Flip flag */
4287                                         command_see = FALSE;
4288                                         screen_load();
4289                                 }
4290
4291                                 /* Show the list */
4292                                 else
4293                                 {
4294                                         screen_save();
4295
4296                                         /* Flip flag */
4297                                         command_see = TRUE;
4298                                 }
4299                                 break;
4300                         }
4301
4302                         case '\n':
4303                         case '\r':
4304                         case '+':
4305                         {
4306                                 int i;
4307                                 OBJECT_IDX o_idx;
4308                                 grid_type *g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
4309
4310                                 if (command_wrk != (USE_FLOOR)) break;
4311
4312                                 /* Get the object being moved. */
4313                                 o_idx = g_ptr->o_idx;
4314
4315                                 /* Only rotate a pile of two or more objects. */
4316                                 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) break;
4317
4318                                 /* Remove the first object from the list. */
4319                                 excise_object_idx(o_idx);
4320
4321                                 /* Find end of the list. */
4322                                 i = g_ptr->o_idx;
4323                                 while (current_floor_ptr->o_list[i].next_o_idx)
4324                                         i = current_floor_ptr->o_list[i].next_o_idx;
4325
4326                                 /* Add after the last object. */
4327                                 current_floor_ptr->o_list[i].next_o_idx = o_idx;
4328
4329                                 /* Re-scan floor list */ 
4330                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
4331
4332                                 /* Hack -- Fix screen */
4333                                 if (command_see)
4334                                 {
4335                                         screen_load();
4336                                         screen_save();
4337                                 }
4338
4339                                 break;
4340                         }
4341
4342                         case '/':
4343                         {
4344                                 if (command_wrk == (USE_INVEN))
4345                                 {
4346                                         if (!allow_equip)
4347                                         {
4348                                                 bell();
4349                                                 break;
4350                                         }
4351                                         command_wrk = (USE_EQUIP);
4352                                 }
4353                                 else if (command_wrk == (USE_EQUIP))
4354                                 {
4355                                         if (!allow_inven)
4356                                         {
4357                                                 bell();
4358                                                 break;
4359                                         }
4360                                         command_wrk = (USE_INVEN);
4361                                 }
4362                                 else if (command_wrk == (USE_FLOOR))
4363                                 {
4364                                         if (allow_inven)
4365                                         {
4366                                                 command_wrk = (USE_INVEN);
4367                                         }
4368                                         else if (allow_equip)
4369                                         {
4370                                                 command_wrk = (USE_EQUIP);
4371                                         }
4372                                         else
4373                                         {
4374                                                 bell();
4375                                                 break;
4376                                         }
4377                                 }
4378
4379                                 /* Hack -- Fix screen */
4380                                 if (command_see)
4381                                 {
4382                                         screen_load();
4383                                         screen_save();
4384                                 }
4385
4386                                 /* Need to redraw */
4387                                 break;
4388                         }
4389
4390                         case '-':
4391                         {
4392                                 if (!allow_floor)
4393                                 {
4394                                         bell();
4395                                         break;
4396                                 }
4397
4398                                 /*
4399                                  * If we are already examining the floor, and there
4400                                  * is only one item, we will always select it.
4401                                  * If we aren't examining the floor and there is only
4402                                  * one item, we will select it if floor_query_flag
4403                                  * is FALSE.
4404                                  */
4405                                 if (floor_num == 1)
4406                                 {
4407                                         if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
4408                                         {
4409                                                 /* Special index */
4410                                                 k = 0 - floor_list[0];
4411
4412                                                 /* Allow player to "refuse" certain actions */
4413                                                 if (!get_item_allow(k))
4414                                                 {
4415                                                         done = TRUE;
4416                                                         break;
4417                                                 }
4418
4419                                                 /* Accept that choice */
4420                                                 (*cp) = k;
4421                                                 item = TRUE;
4422                                                 done = TRUE;
4423
4424                                                 break;
4425                                         }
4426                                 }
4427
4428                                 /* Hack -- Fix screen */
4429                                 if (command_see)
4430                                 {
4431                                         screen_load();
4432                                         screen_save();
4433                                 }
4434
4435                                 command_wrk = (USE_FLOOR);
4436
4437                                 break;
4438                         }
4439
4440                         case '0':
4441                         case '1': case '2': case '3':
4442                         case '4': case '5': case '6':
4443                         case '7': case '8': case '9':
4444                         {
4445                                 if (command_wrk != USE_FLOOR)
4446                                 {
4447                                         /* Look up the tag */
4448                                         if (!get_tag(&k, which, command_wrk))
4449                                         {
4450                                                 bell();
4451                                                 break;
4452                                         }
4453
4454                                         /* Hack -- Validate the item */
4455                                         if ((k < INVEN_RARM) ? !inven : !equip)
4456                                         {
4457                                                 bell();
4458                                                 break;
4459                                         }
4460
4461                                         /* Validate the item */
4462                                         if (!get_item_okay(k))
4463                                         {
4464                                                 bell();
4465                                                 break;
4466                                         }
4467                                 }
4468                                 else
4469                                 {
4470                                         /* Look up the alphabetical tag */
4471                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4472                                         {
4473                                                 /* Special index */
4474                                                 k = 0 - floor_list[k];
4475                                         }
4476                                         else
4477                                         {
4478                                                 bell();
4479                                                 break;
4480                                         }
4481                                 }
4482
4483                                 /* Allow player to "refuse" certain actions */
4484                                 if (!get_item_allow(k))
4485                                 {
4486                                         done = TRUE;
4487                                         break;
4488                                 }
4489
4490                                 /* Accept that choice */
4491                                 (*cp) = k;
4492                                 item = TRUE;
4493                                 done = TRUE;
4494                                 cur_tag = which;
4495                                 break;
4496                         }
4497
4498 #if 0
4499                         case '\n':
4500                         case '\r':
4501                         {
4502                                 /* Choose "default" p_ptr->inventory_list item */
4503                                 if (command_wrk == (USE_INVEN))
4504                                 {
4505                                         k = ((i1 == i2) ? i1 : -1);
4506                                 }
4507
4508                                 /* Choose "default" equipment item */
4509                                 else if (command_wrk == (USE_EQUIP))
4510                                 {
4511                                         k = ((e1 == e2) ? e1 : -1);
4512                                 }
4513
4514                                 /* Choose "default" floor item */
4515                                 else if (command_wrk == (USE_FLOOR))
4516                                 {
4517                                         if (floor_num == 1)
4518                                         {
4519                                                 /* Special index */
4520                                                 k = 0 - floor_list[0];
4521
4522                                                 /* Allow player to "refuse" certain actions */
4523                                                 if (!get_item_allow(k))
4524                                                 {
4525                                                         done = TRUE;
4526                                                         break;
4527                                                 }
4528
4529                                                 /* Accept that choice */
4530                                                 (*cp) = k;
4531                                                 item = TRUE;
4532                                                 done = TRUE;
4533                                         }
4534                                         break;
4535                                 }
4536
4537                                 /* Validate the item */
4538                                 if (!get_item_okay(k))
4539                                 {
4540                                         bell();
4541                                         break;
4542                                 }
4543
4544                                 /* Allow player to "refuse" certain actions */
4545                                 if (!get_item_allow(k))
4546                                 {
4547                                         done = TRUE;
4548                                         break;
4549                                 }
4550
4551                                 /* Accept that choice */
4552                                 (*cp) = k;
4553                                 item = TRUE;
4554                                 done = TRUE;
4555                                 break;
4556                         }
4557 #endif
4558
4559                         case 'w':
4560                         {
4561                                 if (force) {
4562                                         *cp = INVEN_FORCE;
4563                                         item = TRUE;
4564                                         done = TRUE;
4565                                         break;
4566                                 }
4567
4568                                 /* Fall through */
4569                         }
4570
4571                         default:
4572                         {
4573                                 int ver;
4574
4575                                 if (command_wrk != USE_FLOOR)
4576                                 {
4577                                         bool not_found = FALSE;
4578
4579                                         /* Look up the alphabetical tag */
4580                                         if (!get_tag(&k, which, command_wrk))
4581                                         {
4582                                                 not_found = TRUE;
4583                                         }
4584
4585                                         /* Hack -- Validate the item */
4586                                         else if ((k < INVEN_RARM) ? !inven : !equip)
4587                                         {
4588                                                 not_found = TRUE;
4589                                         }
4590
4591                                         /* Validate the item */
4592                                         else if (!get_item_okay(k))
4593                                         {
4594                                                 not_found = TRUE;
4595                                         }
4596
4597                                         if (!not_found)
4598                                         {
4599                                                 /* Accept that choice */
4600                                                 (*cp) = k;
4601                                                 item = TRUE;
4602                                                 done = TRUE;
4603                                                 cur_tag = which;
4604                                                 break;
4605                                         }
4606                                 }
4607                                 else
4608                                 {
4609                                         /* Look up the alphabetical tag */
4610                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4611                                         {
4612                                                 /* Special index */
4613                                                 k = 0 - floor_list[k];
4614
4615                                                 /* Accept that choice */
4616                                                 (*cp) = k;
4617                                                 item = TRUE;
4618                                                 done = TRUE;
4619                                                 cur_tag = which;
4620                                                 break;
4621                                         }
4622                                 }
4623
4624                                 /* Extract "query" setting */
4625                                 ver = isupper(which);
4626                                 which = (char)tolower(which);
4627
4628                                 /* Convert letter to p_ptr->inventory_list index */
4629                                 if (command_wrk == (USE_INVEN))
4630                                 {
4631                                         if (which == '(') k = i1;
4632                                         else if (which == ')') k = i2;
4633                                         else k = label_to_inven(which);
4634                                 }
4635
4636                                 /* Convert letter to equipment index */
4637                                 else if (command_wrk == (USE_EQUIP))
4638                                 {
4639                                         if (which == '(') k = e1;
4640                                         else if (which == ')') k = e2;
4641                                         else k = label_to_equip(which);
4642                                 }
4643
4644                                 /* Convert letter to floor index */
4645                                 else if (command_wrk == USE_FLOOR)
4646                                 {
4647                                         if (which == '(') k = 0;
4648                                         else if (which == ')') k = floor_num - 1;
4649                                         else k = islower(which) ? A2I(which) : -1;
4650                                         if (k < 0 || k >= floor_num || k >= 23)
4651                                         {
4652                                                 bell();
4653                                                 break;
4654                                         }
4655
4656                                         /* Special index */
4657                                         k = 0 - floor_list[k];
4658                                 }
4659
4660                                 /* Validate the item */
4661                                 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
4662                                 {
4663                                         bell();
4664                                         break;
4665                                 }
4666
4667                                 /* Verify the item */
4668                                 if (ver && !verify(_("本当に", "Try"), k))
4669                                 {
4670                                         done = TRUE;
4671                                         break;
4672                                 }
4673
4674                                 /* Allow player to "refuse" certain actions */
4675                                 if (!get_item_allow(k))
4676                                 {
4677                                         done = TRUE;
4678                                         break;
4679                                 }
4680
4681                                 /* Accept that choice */
4682                                 (*cp) = k;
4683                                 item = TRUE;
4684                                 done = TRUE;
4685                                 break;
4686                         }
4687                 }
4688                 }
4689         }
4690
4691         /* Fix the screen if necessary */
4692         if (command_see)
4693         {
4694                 screen_load();
4695
4696                 /* Hack -- Cancel "display" */
4697                 command_see = FALSE;
4698         }
4699
4700
4701         /* Forget the item_tester_tval restriction */
4702         item_tester_tval = 0;
4703
4704         /* Forget the item_tester_hook restriction */
4705         item_tester_hook = NULL;
4706
4707
4708         /* Clean up  'show choices' */
4709         /* Toggle again if needed */
4710         if (toggle) toggle_inven_equip();
4711
4712         p_ptr->window |= (PW_INVEN | PW_EQUIP);
4713         handle_stuff();
4714
4715         /* Clear the prompt line */
4716         prt("", 0, 0);
4717
4718         /* Warning if needed */
4719         if (oops && str) msg_print(str);
4720
4721         if (item)
4722         {
4723                 repeat_push(*cp);
4724                 if (command_cmd) prev_tag = cur_tag;
4725                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4726         }
4727         return (item);
4728 }
4729
4730 /*!
4731  * @brief 床上のアイテムを拾う選択用サブルーチン 
4732  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
4733  */
4734 static bool py_pickup_floor_aux(void)
4735 {
4736         OBJECT_IDX this_o_idx;
4737         concptr q, s;
4738         OBJECT_IDX item;
4739
4740         /* Restrict the choices */
4741         item_tester_hook = inven_carry_okay;
4742
4743         /* Get an object */
4744         q = _("どれを拾いますか?", "Get which item? ");
4745         s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
4746
4747         if (choose_object(&item, q, s, (USE_FLOOR)))
4748         {
4749                 this_o_idx = 0 - item;
4750         }
4751         else
4752         {
4753                 return (FALSE);
4754         }
4755
4756         /* Pick up the object */
4757         py_pickup_aux(this_o_idx);
4758
4759         return (TRUE);
4760 }
4761
4762 /*!
4763  * @brief 床上のアイテムを拾うメイン処理
4764  * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
4765  * @return なし
4766  * @details
4767  * This is called by py_pickup() when easy_floor is TRUE.
4768  */
4769 void py_pickup_floor(bool pickup)
4770 {
4771         OBJECT_IDX this_o_idx, next_o_idx = 0;
4772
4773         GAME_TEXT o_name[MAX_NLEN];
4774         object_type *o_ptr;
4775
4776         int floor_num = 0;
4777         OBJECT_IDX floor_o_idx = 0;
4778
4779         int can_pickup = 0;
4780
4781         /* Scan the pile of objects */
4782         for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
4783         {
4784                 /* Access the object */
4785                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
4786
4787                 object_desc(o_name, o_ptr, 0);
4788
4789                 /* Access the next object */
4790                 next_o_idx = o_ptr->next_o_idx;
4791
4792                 disturb(FALSE, FALSE);
4793
4794                 /* Pick up gold */
4795                 if (o_ptr->tval == TV_GOLD)
4796                 {
4797 #ifdef JP
4798                         msg_format(" $%ld の価値がある%sを見つけた。",
4799                                 (long)o_ptr->pval, o_name);
4800 #else
4801                         msg_format("You have found %ld gold pieces worth of %s.",
4802                                 (long)o_ptr->pval, o_name);
4803 #endif
4804
4805                         /* Collect the gold */
4806                         p_ptr->au += o_ptr->pval;
4807
4808                         /* Redraw gold */
4809                         p_ptr->redraw |= (PR_GOLD);
4810
4811                         p_ptr->window |= (PW_PLAYER);
4812
4813                         /* Delete the gold */
4814                         delete_object_idx(this_o_idx);
4815
4816                         /* Check the next object */
4817                         continue;
4818                 }
4819                 else if (o_ptr->marked & OM_NOMSG)
4820                 {
4821                         /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
4822                          * ignored. Otherwise, they are included in the prompt. */
4823                         o_ptr->marked &= ~(OM_NOMSG);
4824                         continue;
4825                 }
4826
4827                 /* Count non-gold objects that can be picked up. */
4828                 if (inven_carry_okay(o_ptr))
4829                 {
4830                         can_pickup++;
4831                 }
4832
4833                 /* Count non-gold objects */
4834                 floor_num++;
4835
4836                 /* Remember this index */
4837                 floor_o_idx = this_o_idx;
4838         }
4839
4840         /* There are no non-gold objects */
4841         if (!floor_num)
4842                 return;
4843
4844         /* Mention the number of objects */
4845         if (!pickup)
4846         {
4847                 /* One object */
4848                 if (floor_num == 1)
4849                 {
4850                         /* Access the object */
4851                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4852
4853 #ifdef ALLOW_EASY_SENSE
4854
4855                         /* Option: Make object sensing easy */
4856                         if (easy_sense)
4857                         {
4858                                 /* Sense the object */
4859                                 (void) sense_object(o_ptr);
4860                         }
4861
4862 #endif /* ALLOW_EASY_SENSE */
4863
4864                         object_desc(o_name, o_ptr, 0);
4865
4866                         msg_format(_("%sがある。", "You see %s."), o_name);
4867                 }
4868
4869                 /* Multiple objects */
4870                 else
4871                 {
4872                         msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
4873                 }
4874
4875                 return;
4876         }
4877
4878         /* The player has no room for anything on the floor. */
4879         if (!can_pickup)
4880         {
4881                 /* One object */
4882                 if (floor_num == 1)
4883                 {
4884                         /* Access the object */
4885                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4886
4887 #ifdef ALLOW_EASY_SENSE
4888
4889                         /* Option: Make object sensing easy */
4890                         if (easy_sense)
4891                         {
4892                                 /* Sense the object */
4893                                 (void) sense_object(o_ptr);
4894                         }
4895
4896 #endif /* ALLOW_EASY_SENSE */
4897
4898                         object_desc(o_name, o_ptr, 0);
4899
4900                         msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
4901                 }
4902
4903                 /* Multiple objects */
4904                 else
4905                 {
4906                         msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
4907
4908                 }
4909
4910                 return;
4911         }
4912
4913         /* One object */
4914         if (floor_num == 1)
4915         {
4916                 /* Hack -- query every object */
4917                 if (carry_query_flag)
4918                 {
4919                         char out_val[MAX_NLEN+20];
4920
4921                         /* Access the object */
4922                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4923
4924 #ifdef ALLOW_EASY_SENSE
4925
4926                         /* Option: Make object sensing easy */
4927                         if (easy_sense)
4928                         {
4929                                 /* Sense the object */
4930                                 (void) sense_object(o_ptr);
4931                         }
4932
4933 #endif /* ALLOW_EASY_SENSE */
4934
4935                         object_desc(o_name, o_ptr, 0);
4936
4937                         /* Build a prompt */
4938                         (void) sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
4939
4940                         /* Ask the user to confirm */
4941                         if (!get_check(out_val))
4942                         {
4943                                 return;
4944                         }
4945                 }
4946
4947                 /* Access the object */
4948                 o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4949
4950 #ifdef ALLOW_EASY_SENSE
4951
4952                 /* Option: Make object sensing easy */
4953                 if (easy_sense)
4954                 {
4955                         /* Sense the object */
4956                         (void) sense_object(o_ptr);
4957                 }
4958
4959 #endif /* ALLOW_EASY_SENSE */
4960
4961                 /* Pick up the object */
4962                 py_pickup_aux(floor_o_idx);
4963         }
4964
4965         /* Allow the user to choose an object */
4966         else
4967         {
4968                 while (can_pickup--)
4969                 {
4970                         if (!py_pickup_floor_aux()) break;
4971                 }
4972         }
4973 }
4974
4975
4976 /*!
4977  * @brief 矢弾を射撃した場合の破損確率を返す /
4978  * Determines the odds of an object breaking when thrown at a monster
4979  * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
4980  * @return 破損確率(%)
4981  * @details
4982  * Note that artifacts never break, see the "drop_near()" function.
4983  */
4984 PERCENTAGE breakage_chance(object_type *o_ptr, SPELL_IDX snipe_type)
4985 {
4986         PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev - 1) / 7 + 4 : 0);
4987
4988         /* Examine the snipe type */
4989         if (snipe_type)
4990         {
4991                 if (snipe_type == SP_KILL_WALL) return (100);
4992                 if (snipe_type == SP_EXPLODE) return (100);
4993                 if (snipe_type == SP_PIERCE) return (100);
4994                 if (snipe_type == SP_FINAL) return (100);
4995                 if (snipe_type == SP_NEEDLE) return (100);
4996                 if (snipe_type == SP_EVILNESS) return (40);
4997                 if (snipe_type == SP_HOLYNESS) return (40);
4998         }
4999
5000         /* Examine the item type */
5001         switch (o_ptr->tval)
5002         {
5003                 /* Always break */
5004         case TV_FLASK:
5005         case TV_POTION:
5006         case TV_BOTTLE:
5007         case TV_FOOD:
5008         case TV_JUNK:
5009                 return (100);
5010
5011                 /* Often break */
5012         case TV_LITE:
5013         case TV_SCROLL:
5014         case TV_SKELETON:
5015                 return (50);
5016
5017                 /* Sometimes break */
5018         case TV_WAND:
5019         case TV_SPIKE:
5020                 return (25);
5021         case TV_ARROW:
5022                 return (20 - archer_bonus * 2);
5023
5024                 /* Rarely break */
5025         case TV_SHOT:
5026         case TV_BOLT:
5027                 return (10 - archer_bonus);
5028         default:
5029                 return (10);
5030         }
5031 }