OSDN Git Service

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