OSDN Git Service

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