OSDN Git Service

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