OSDN Git Service

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