OSDN Git Service

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