OSDN Git Service

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