OSDN Git Service

[Refactor] #37353 item_tester_hook を object1.c/object.h へ移動.
[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", player_base);
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", player_base);
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  * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
1588  * Check an item against the item tester info
1589  * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
1590  * @return item_tester_hookの参照先、その他いくつかの例外に応じてTRUE/FALSEを返す。
1591  */
1592 bool item_tester_okay(object_type *o_ptr)
1593 {
1594         /* Hack -- allow listing empty slots */
1595         // if (item_tester_full) return (TRUE); // TODO:DELETE
1596
1597         /* Require an item */
1598         if (!o_ptr->k_idx) return (FALSE);
1599
1600         /* Hack -- ignore "gold" */
1601         if (o_ptr->tval == TV_GOLD)
1602         {
1603                 /* See xtra2.c */
1604                 extern bool show_gold_on_floor;
1605
1606                 if (!show_gold_on_floor) return (FALSE);
1607         }
1608
1609         /* Check the tval */
1610         if (item_tester_tval)
1611         {
1612                 /* Is it a spellbook? If so, we need a hack -- TY */
1613                 if ((item_tester_tval <= TV_DEATH_BOOK) &&
1614                         (item_tester_tval >= TV_LIFE_BOOK))
1615                         return check_book_realm(o_ptr->tval, o_ptr->sval);
1616                 else
1617                         if (item_tester_tval != o_ptr->tval) return (FALSE);
1618         }
1619
1620         /* Check the hook */
1621         if (item_tester_hook)
1622         {
1623                 if (!(*item_tester_hook)(o_ptr)) return (FALSE);
1624         }
1625
1626         /* Assume okay */
1627         return (TRUE);
1628 }
1629
1630
1631 /*!
1632  * @brief 所持アイテム一覧を表示する /
1633  * Choice window "shadow" of the "show_inven()" function
1634  * @return なし
1635  */
1636 void display_inven(void)
1637 {
1638         register int i, n, z = 0;
1639         object_type *o_ptr;
1640         TERM_COLOR attr = TERM_WHITE;
1641         char tmp_val[80];
1642         GAME_TEXT o_name[MAX_NLEN];
1643         TERM_LEN wid, hgt;
1644
1645         Term_get_size(&wid, &hgt);
1646
1647         for (i = 0; i < INVEN_PACK; i++)
1648         {
1649                 o_ptr = &p_ptr->inventory_list[i];
1650                 if (!o_ptr->k_idx) continue;
1651                 z = i + 1;
1652         }
1653
1654         for (i = 0; i < z; i++)
1655         {
1656                 o_ptr = &p_ptr->inventory_list[i];
1657                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1658                 if (item_tester_okay(o_ptr))
1659                 {
1660                         tmp_val[0] = index_to_label(i);
1661                         tmp_val[1] = ')';
1662                 }
1663
1664                 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
1665                 object_desc(o_name, o_ptr, 0);
1666                 n = strlen(o_name);
1667                 attr = tval_to_attr[o_ptr->tval % 128];
1668                 if (o_ptr->timeout)
1669                 {
1670                         attr = TERM_L_DARK;
1671                 }
1672
1673                 Term_putstr(3, i, n, attr, o_name);
1674                 Term_erase(3+n, i, 255);
1675
1676                 if (show_weights)
1677                 {
1678                         int wgt = o_ptr->weight * o_ptr->number;
1679 #ifdef JP
1680                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
1681 #else
1682                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1683 #endif
1684                         prt(tmp_val, i, wid - 9);
1685                 }
1686         }
1687
1688         for (i = z; i < hgt; i++)
1689         {
1690                 Term_erase(0, i, 255);
1691         }
1692 }
1693
1694
1695
1696 /*!
1697  * @brief 装備アイテム一覧を表示する /
1698  * Choice window "shadow" of the "show_equip()" function
1699  * @return なし
1700  */
1701 void display_equip(void)
1702 {
1703         register int i, n;
1704         object_type *o_ptr;
1705         TERM_COLOR attr = TERM_WHITE;
1706         char tmp_val[80];
1707         GAME_TEXT o_name[MAX_NLEN];
1708         TERM_LEN wid, hgt;
1709
1710         Term_get_size(&wid, &hgt);
1711
1712         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1713         {
1714                 o_ptr = &p_ptr->inventory_list[i];
1715                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1716                 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
1717                 {
1718                         tmp_val[0] = index_to_label(i);
1719                         tmp_val[1] = ')';
1720                 }
1721
1722                 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
1723                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
1724                 {
1725                         strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
1726                         attr = TERM_WHITE;
1727                 }
1728                 else
1729                 {
1730                         object_desc(o_name, o_ptr, 0);
1731                         attr = tval_to_attr[o_ptr->tval % 128];
1732                 }
1733
1734                 n = strlen(o_name);
1735                 if (o_ptr->timeout)
1736                 {
1737                         attr = TERM_L_DARK;
1738                 }
1739                 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
1740
1741                 Term_erase(3 + n, i - INVEN_RARM, 255);
1742
1743                 if (show_weights)
1744                 {
1745                         int wgt = o_ptr->weight * o_ptr->number;
1746 #ifdef JP
1747                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
1748 #else
1749                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1750 #endif
1751
1752                         prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
1753                 }
1754
1755                 if (show_labels)
1756                 {
1757                         Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
1758                         prt(mention_use(i), i - INVEN_RARM, wid - 15);
1759                 }
1760         }
1761
1762         for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
1763         {
1764                 Term_erase(0, i, 255);
1765         }
1766 }
1767
1768
1769 /*!
1770  * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1771  * Find the "first" p_ptr->inventory_list object with the given "tag".
1772  * @param cp 対応するタグIDを与える参照ポインタ
1773  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1774  * @param mode 所持、装備の切り替え
1775  * @return タグに該当するオブジェクトがあるならTRUEを返す
1776  * @details
1777  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1778  * inscription of an object.  Alphabetical characters don't work as a\n
1779  * tag in this form.\n
1780  *\n
1781  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1782  * and "x" is the "current" command_cmd code.\n
1783  */
1784 static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
1785 {
1786         COMMAND_CODE i;
1787         COMMAND_CODE start, end;
1788         concptr s;
1789
1790         /* Extract index from mode */
1791         switch (mode)
1792         {
1793         case USE_EQUIP:
1794                 start = INVEN_RARM;
1795                 end = INVEN_TOTAL - 1;
1796                 break;
1797
1798         case USE_INVEN:
1799                 start = 0;
1800                 end = INVEN_PACK - 1;
1801                 break;
1802
1803         default:
1804                 return FALSE;
1805         }
1806
1807         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1808
1809         /* Check every p_ptr->inventory_list object */
1810         for (i = start; i <= end; i++)
1811         {
1812                 object_type *o_ptr = &p_ptr->inventory_list[i];
1813                 if (!o_ptr->k_idx) continue;
1814
1815                 /* Skip empty inscriptions */
1816                 if (!o_ptr->inscription) continue;
1817
1818                 /* Skip non-choice */
1819                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1820
1821                 /* Find a '@' */
1822                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1823
1824                 /* Process all tags */
1825                 while (s)
1826                 {
1827                         /* Check the special tags */
1828                         if ((s[1] == command_cmd) && (s[2] == tag))
1829                         {
1830                                 /* Save the actual p_ptr->inventory_list ID */
1831                                 *cp = i;
1832
1833                                 /* Success */
1834                                 return (TRUE);
1835                         }
1836
1837                         /* Find another '@' */
1838                         s = my_strchr(s + 1, '@');
1839                 }
1840         }
1841
1842
1843         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
1844
1845         /* Don't allow {@#} with '#' being alphabet */
1846         if (tag < '0' || '9' < tag)
1847         {
1848                 /* No such tag */
1849                 return FALSE;
1850         }
1851
1852         /* Check every object */
1853         for (i = start; i <= end; i++)
1854         {
1855                 object_type *o_ptr = &p_ptr->inventory_list[i];
1856                 if (!o_ptr->k_idx) continue;
1857
1858                 /* Skip empty inscriptions */
1859                 if (!o_ptr->inscription) continue;
1860
1861                 /* Skip non-choice */
1862                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1863
1864                 /* Find a '@' */
1865                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1866
1867                 /* Process all tags */
1868                 while (s)
1869                 {
1870                         /* Check the normal tags */
1871                         if (s[1] == tag)
1872                         {
1873                                 /* Save the actual p_ptr->inventory_list ID */
1874                                 *cp = i;
1875
1876                                 /* Success */
1877                                 return (TRUE);
1878                         }
1879
1880                         /* Find another '@' */
1881                         s = my_strchr(s + 1, '@');
1882                 }
1883         }
1884
1885         /* No such tag */
1886         return (FALSE);
1887 }
1888
1889
1890 /*!
1891  * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1892  * Find the "first" p_ptr->inventory_list object with the given "tag".
1893  * @param cp 対応するタグIDを与える参照ポインタ
1894  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1895  * @param floor_list 床上アイテムの配列
1896  * @param floor_num  床上アイテムの配列ID
1897  * @return タグに該当するオブジェクトがあるならTRUEを返す
1898  * @details
1899  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1900  * inscription of an object.  Alphabetical characters don't work as a\n
1901  * tag in this form.\n
1902  *\n
1903  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1904  * and "x" is the "current" command_cmd code.\n
1905  */
1906 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
1907 {
1908         COMMAND_CODE i;
1909         concptr s;
1910
1911         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1912
1913         /* Check every object in the grid */
1914         for (i = 0; i < floor_num && i < 23; i++)
1915         {
1916                 object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1917
1918                 /* Skip empty inscriptions */
1919                 if (!o_ptr->inscription) continue;
1920
1921                 /* Find a '@' */
1922                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1923
1924                 /* Process all tags */
1925                 while (s)
1926                 {
1927                         /* Check the special tags */
1928                         if ((s[1] == command_cmd) && (s[2] == tag))
1929                         {
1930                                 /* Save the actual floor object ID */
1931                                 *cp = i;
1932
1933                                 /* Success */
1934                                 return (TRUE);
1935                         }
1936
1937                         /* Find another '@' */
1938                         s = my_strchr(s + 1, '@');
1939                 }
1940         }
1941
1942
1943         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
1944
1945         /* Don't allow {@#} with '#' being alphabet */
1946         if (tag < '0' || '9' < tag)
1947         {
1948                 /* No such tag */
1949                 return FALSE;
1950         }
1951
1952         /* Check every object in the grid */
1953         for (i = 0; i < floor_num && i < 23; i++)
1954         {
1955                 object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1956
1957                 /* Skip empty inscriptions */
1958                 if (!o_ptr->inscription) continue;
1959
1960                 /* Find a '@' */
1961                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1962
1963                 /* Process all tags */
1964                 while (s)
1965                 {
1966                         /* Check the normal tags */
1967                         if (s[1] == tag)
1968                         {
1969                                 /* Save the floor object ID */
1970                                 *cp = i;
1971
1972                                 /* Success */
1973                                 return (TRUE);
1974                         }
1975
1976                         /* Find another '@' */
1977                         s = my_strchr(s + 1, '@');
1978                 }
1979         }
1980
1981         /* No such tag */
1982         return (FALSE);
1983 }
1984
1985
1986 /*!
1987  * @brief タグIDにあわせてタグアルファベットのリストを返す /
1988  * Move around label characters with correspond tags
1989  * @param label ラベルリストを取得する文字列参照ポインタ
1990  * @param mode 所持品リストか装備品リストかの切り替え
1991  * @return なし
1992  */
1993 static void prepare_label_string(char *label, BIT_FLAGS mode)
1994 {
1995         concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1996         int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
1997         int  i;
1998
1999         /* Prepare normal labels */
2000         strcpy(label, alphabet_chars);
2001
2002         /* Move each label */
2003         for (i = 0; i < 52; i++)
2004         {
2005                 COMMAND_CODE index;
2006                 SYMBOL_CODE c = alphabet_chars[i];
2007
2008                 /* Find a tag with this label */
2009                 if (get_tag(&index, c, mode))
2010                 {
2011                         /* Delete the overwritten label */
2012                         if (label[i] == c) label[i] = ' ';
2013
2014                         /* Move the label to the place of corresponding tag */
2015                         label[index - offset] = c;
2016                 }
2017         }
2018 }
2019
2020
2021 /*!
2022  * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
2023  * Move around label characters with correspond tags (floor version)
2024  * @param label ラベルリストを取得する文字列参照ポインタ
2025  * @param floor_list 床上アイテムの配列
2026  * @param floor_num  床上アイテムの配列ID
2027  * @return なし
2028  */
2029 /*
2030  */
2031 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
2032 {
2033         concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2034         int  i;
2035
2036         /* Prepare normal labels */
2037         strcpy(label, alphabet_chars);
2038
2039         /* Move each label */
2040         for (i = 0; i < 52; i++)
2041         {
2042                 COMMAND_CODE index;
2043                 SYMBOL_CODE c = alphabet_chars[i];
2044
2045                 /* Find a tag with this label */
2046                 if (get_tag_floor(&index, c, floor_list, floor_num))
2047                 {
2048                         /* Delete the overwritten label */
2049                         if (label[i] == c) label[i] = ' ';
2050
2051                         /* Move the label to the place of corresponding tag */
2052                         label[index] = c;
2053                 }
2054         }
2055 }
2056
2057
2058 /*!
2059  * @brief 所持アイテムの表示を行う /
2060  * Display the p_ptr->inventory_list.
2061  * @param target_item アイテムの選択処理を行うか否か。
2062  * @return 選択したアイテムのタグ
2063  * @details
2064  * Hack -- do not display "trailing" empty slots
2065  */
2066 COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
2067 {
2068         COMMAND_CODE i;
2069         int j, k, l, z = 0;
2070         int             col, cur_col, len;
2071         object_type *o_ptr;
2072         GAME_TEXT o_name[MAX_NLEN];
2073         char            tmp_val[80];
2074         COMMAND_CODE    out_index[23];
2075         TERM_COLOR      out_color[23];
2076         char            out_desc[23][MAX_NLEN];
2077         COMMAND_CODE target_item_label = 0;
2078         TERM_LEN wid, hgt;
2079         char inven_label[52 + 1];
2080
2081         /* Starting column */
2082         col = command_gap;
2083
2084         Term_get_size(&wid, &hgt);
2085
2086         /* Default "max-length" */
2087         len = wid - col - 1;
2088
2089
2090         /* Find the "final" slot */
2091         for (i = 0; i < INVEN_PACK; i++)
2092         {
2093                 o_ptr = &p_ptr->inventory_list[i];
2094                 if (!o_ptr->k_idx) continue;
2095
2096                 /* Track */
2097                 z = i + 1;
2098         }
2099
2100         prepare_label_string(inven_label, USE_INVEN);
2101
2102         /* Display the p_ptr->inventory_list */
2103         for (k = 0, i = 0; i < z; i++)
2104         {
2105                 o_ptr = &p_ptr->inventory_list[i];
2106
2107                 /* Is this item acceptable? */
2108                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
2109
2110                 object_desc(o_name, o_ptr, 0);
2111
2112                 /* Save the object index, color, and description */
2113                 out_index[k] = i;
2114                 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2115
2116                 /* Grey out charging items */
2117                 if (o_ptr->timeout)
2118                 {
2119                         out_color[k] = TERM_L_DARK;
2120                 }
2121
2122                 (void)strcpy(out_desc[k], o_name);
2123
2124                 /* Find the predicted "line length" */
2125                 l = strlen(out_desc[k]) + 5;
2126
2127                 /* Be sure to account for the weight */
2128                 if (show_weights) l += 9;
2129
2130                 /* Account for icon if displayed */
2131                 if (show_item_graph)
2132                 {
2133                         l += 2;
2134                         if (use_bigtile) l++;
2135                 }
2136
2137                 /* Maintain the maximum length */
2138                 if (l > len) len = l;
2139
2140                 /* Advance to next "line" */
2141                 k++;
2142         }
2143
2144         /* Find the column to start in */
2145         col = (len > wid - 4) ? 0 : (wid - len - 1);
2146
2147         /* Output each entry */
2148         for (j = 0; j < k; j++)
2149         {
2150                 i = out_index[j];
2151                 o_ptr = &p_ptr->inventory_list[i];
2152
2153                 /* Clear the line */
2154                 prt("", j + 1, col ? col - 2 : col);
2155
2156                 if (use_menu && target_item)
2157                 {
2158                         if (j == (target_item-1))
2159                         {
2160                                 strcpy(tmp_val, _("》", "> "));
2161                                 target_item_label = i;
2162                         }
2163                         else strcpy(tmp_val, "  ");
2164                 }
2165                 else if (i <= INVEN_PACK)
2166                 {
2167                         /* Prepare an index --(-- */
2168                         sprintf(tmp_val, "%c)", inven_label[i]);
2169                 }
2170                 else
2171                 {
2172                         /* Prepare an index --(-- */
2173                         sprintf(tmp_val, "%c)", index_to_label(i));
2174                 }
2175
2176                 /* Clear the line with the (possibly indented) index */
2177                 put_str(tmp_val, j + 1, col);
2178
2179                 cur_col = col + 3;
2180
2181                 /* Display graphics for object, if desired */
2182                 if (show_item_graph)
2183                 {
2184                         TERM_COLOR a = object_attr(o_ptr);
2185                         SYMBOL_CODE c = object_char(o_ptr);
2186                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2187                         if (use_bigtile) cur_col++;
2188
2189                         cur_col += 2;
2190                 }
2191
2192
2193                 /* Display the entry itself */
2194                 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2195
2196                 /* Display the weight if needed */
2197                 if (show_weights)
2198                 {
2199                         int wgt = o_ptr->weight * o_ptr->number;
2200 #ifdef JP
2201                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2202 #else
2203                         (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2204 #endif
2205
2206                         prt(tmp_val, j + 1, wid - 9);
2207                 }
2208         }
2209
2210         /* Make a "shadow" below the list (only if needed) */
2211         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2212
2213         /* Save the new column */
2214         command_gap = col;
2215
2216         return target_item_label;
2217 }
2218
2219
2220 /*!
2221  * @brief 装備アイテムの表示を行う /
2222  * Display the equipment.
2223  * @param target_item アイテムの選択処理を行うか否か。
2224  * @return 選択したアイテムのタグ
2225  */
2226 COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
2227 {
2228         COMMAND_CODE i;
2229         int j, k, l;
2230         int             col, cur_col, len;
2231         object_type *o_ptr;
2232         char            tmp_val[80];
2233         GAME_TEXT o_name[MAX_NLEN];
2234         COMMAND_CODE    out_index[23];
2235         TERM_COLOR      out_color[23];
2236         char            out_desc[23][MAX_NLEN];
2237         COMMAND_CODE target_item_label = 0;
2238         TERM_LEN wid, hgt;
2239         char            equip_label[52 + 1];
2240
2241         /* Starting column */
2242         col = command_gap;
2243
2244         Term_get_size(&wid, &hgt);
2245
2246         /* Maximal length */
2247         len = wid - col - 1;
2248
2249
2250         /* Scan the equipment list */
2251         for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2252         {
2253                 o_ptr = &p_ptr->inventory_list[i];
2254
2255                 /* Is this item acceptable? */
2256                 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr) || (mode & USE_FULL)) &&
2257                     (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2258                                 (mode & IGNORE_BOTHHAND_SLOT))) continue;
2259
2260                 object_desc(o_name, o_ptr, 0);
2261
2262                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2263                 {
2264                         (void)strcpy(out_desc[k],_("(武器を両手持ち)", "(wielding with two-hands)"));
2265                         out_color[k] = TERM_WHITE;
2266                 }
2267                 else
2268                 {
2269                         (void)strcpy(out_desc[k], o_name);
2270                         out_color[k] = tval_to_attr[o_ptr->tval % 128];
2271                 }
2272
2273                 out_index[k] = i;
2274                 /* Grey out charging items */
2275                 if (o_ptr->timeout)
2276                 {
2277                         out_color[k] = TERM_L_DARK;
2278                 }
2279
2280                 /* Extract the maximal length (see below) */
2281 #ifdef JP
2282                 l = strlen(out_desc[k]) + (2 + 1);
2283 #else
2284                 l = strlen(out_desc[k]) + (2 + 3);
2285 #endif
2286
2287
2288                 /* Increase length for labels (if needed) */
2289 #ifdef JP
2290                 if (show_labels) l += (7 + 2);
2291 #else
2292                 if (show_labels) l += (14 + 2);
2293 #endif
2294
2295
2296                 /* Increase length for weight (if needed) */
2297                 if (show_weights) l += 9;
2298
2299                 if (show_item_graph) l += 2;
2300
2301                 /* Maintain the max-length */
2302                 if (l > len) len = l;
2303
2304                 /* Advance the entry */
2305                 k++;
2306         }
2307
2308         /* Hack -- Find a column to start in */
2309 #ifdef JP
2310         col = (len > wid - 6) ? 0 : (wid - len - 1);
2311 #else
2312         col = (len > wid - 4) ? 0 : (wid - len - 1);
2313 #endif
2314
2315         prepare_label_string(equip_label, USE_EQUIP);
2316
2317         /* Output each entry */
2318         for (j = 0; j < k; j++)
2319         {
2320                 i = out_index[j];
2321                 o_ptr = &p_ptr->inventory_list[i];
2322
2323                 /* Clear the line */
2324                 prt("", j + 1, col ? col - 2 : col);
2325
2326                 if (use_menu && target_item)
2327                 {
2328                         if (j == (target_item-1))
2329                         {
2330                                 strcpy(tmp_val, _("》", "> "));
2331                                 target_item_label = i;
2332                         }
2333                         else strcpy(tmp_val, "  ");
2334                 }
2335                 else if (i >= INVEN_RARM)
2336                 {
2337                         /* Prepare an index --(-- */
2338                         sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
2339                 }
2340                 else
2341                 {
2342                         /* Prepare an index --(-- */
2343                         sprintf(tmp_val, "%c)", index_to_label(i));
2344                 }
2345
2346                 /* Clear the line with the (possibly indented) index */
2347                 put_str(tmp_val, j+1, col);
2348
2349                 cur_col = col + 3;
2350
2351                 /* Display graphics for object, if desired */
2352                 if (show_item_graph)
2353                 {
2354                         TERM_COLOR a = object_attr(o_ptr);
2355                         SYMBOL_CODE c = object_char(o_ptr);
2356                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2357                         if (use_bigtile) cur_col++;
2358
2359                         cur_col += 2;
2360                 }
2361
2362                 /* Use labels */
2363                 if (show_labels)
2364                 {
2365                         /* Mention the use */
2366                         (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
2367
2368                         put_str(tmp_val, j+1, cur_col);
2369
2370                         /* Display the entry itself */
2371                         c_put_str(out_color[j], out_desc[j], j+1, _(cur_col + 9, cur_col + 16));
2372                 }
2373
2374                 /* No labels */
2375                 else
2376                 {
2377                         /* Display the entry itself */
2378                         c_put_str(out_color[j], out_desc[j], j+1, cur_col);
2379                 }
2380
2381                 /* Display the weight if needed */
2382                 if (show_weights)
2383                 {
2384                         int wgt = o_ptr->weight * o_ptr->number;
2385 #ifdef JP
2386                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2387 #else
2388                         (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
2389 #endif
2390
2391                         prt(tmp_val, j + 1, wid - 9);
2392                 }
2393         }
2394
2395         /* Make a "shadow" below the list (only if needed) */
2396         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2397
2398         /* Save the new column */
2399         command_gap = col;
2400
2401         return target_item_label;
2402 }
2403
2404 /*!
2405  * @brief サブウィンドウに所持品、装備品リストの表示を行う /
2406  * Flip "inven" and "equip" in any sub-windows
2407  * @return なし
2408  */
2409 void toggle_inven_equip(void)
2410 {
2411         int j;
2412
2413         /* Scan windows */
2414         for (j = 0; j < 8; j++)
2415         {
2416                 /* Unused */
2417                 if (!angband_term[j]) continue;
2418
2419                 /* Flip inven to equip */
2420                 if (window_flag[j] & (PW_INVEN))
2421                 {
2422                         /* Flip flags */
2423                         window_flag[j] &= ~(PW_INVEN);
2424                         window_flag[j] |= (PW_EQUIP);
2425
2426                         p_ptr->window |= (PW_EQUIP);
2427                 }
2428
2429                 /* Flip inven to equip */
2430                 else if (window_flag[j] & (PW_EQUIP))
2431                 {
2432                         /* Flip flags */
2433                         window_flag[j] &= ~(PW_EQUIP);
2434                         window_flag[j] |= (PW_INVEN);
2435
2436                         p_ptr->window |= (PW_INVEN);
2437                 }
2438         }
2439 }
2440
2441 /*!
2442  * @brief 選択したアイテムの確認処理の補助 /
2443  * Verify the choice of an item.
2444  * @param prompt メッセージ表示の一部
2445  * @param item 選択アイテムID
2446  * @return 確認がYesならTRUEを返す。
2447  * @details The item can be negative to mean "item on floor".
2448  */
2449 static bool verify(concptr prompt, INVENTORY_IDX item)
2450 {
2451         GAME_TEXT o_name[MAX_NLEN];
2452         char        out_val[MAX_NLEN+20];
2453         object_type *o_ptr;
2454
2455
2456         /* Inventory */
2457         if (item >= 0)
2458         {
2459                 o_ptr = &p_ptr->inventory_list[item];
2460         }
2461
2462         /* Floor */
2463         else
2464         {
2465                 o_ptr = &current_floor_ptr->o_list[0 - item];
2466         }
2467         object_desc(o_name, o_ptr, 0);
2468
2469         /* Prompt */
2470         (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
2471
2472         /* Query */
2473         return (get_check(out_val));
2474 }
2475
2476
2477 /*!
2478  * @brief 選択したアイテムの確認処理のメインルーチン /
2479  * @param item 選択アイテムID
2480  * @return 確認がYesならTRUEを返す。
2481  * @details The item can be negative to mean "item on floor".
2482  * Hack -- allow user to "prevent" certain choices
2483  */
2484 static bool get_item_allow(INVENTORY_IDX item)
2485 {
2486         concptr s;
2487         object_type *o_ptr;
2488         if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
2489
2490         /* Inventory */
2491         if (item >= 0)
2492         {
2493                 o_ptr = &p_ptr->inventory_list[item];
2494         }
2495
2496         /* Floor */
2497         else
2498         {
2499                 o_ptr = &current_floor_ptr->o_list[0 - item];
2500         }
2501
2502         /* No inscription */
2503         if (!o_ptr->inscription) return (TRUE);
2504
2505         /* Find a '!' */
2506         s = my_strchr(quark_str(o_ptr->inscription), '!');
2507
2508         /* Process preventions */
2509         while (s)
2510         {
2511                 /* Check the "restriction" */
2512                 if ((s[1] == command_cmd) || (s[1] == '*'))
2513                 {
2514                         /* Verify the choice */
2515                         if (!verify(_("本当に", "Really try"), item)) return (FALSE);
2516                 }
2517
2518                 /* Find another '!' */
2519                 s = my_strchr(s + 1, '!');
2520         }
2521
2522         /* Allow it */
2523         return (TRUE);
2524 }
2525
2526
2527 /*!
2528  * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
2529  * Auxiliary function for "get_item()" -- test an index
2530  * @param i 選択アイテムID
2531  * @return 正規のIDならばTRUEを返す。
2532  */
2533 static bool get_item_okay(OBJECT_IDX i)
2534 {
2535         /* Illegal items */
2536         if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
2537
2538         if (select_ring_slot) return is_ring_slot(i);
2539
2540         /* Verify the item */
2541         if (!item_tester_okay(&p_ptr->inventory_list[i])) return (FALSE);
2542
2543         /* Assume okay */
2544         return (TRUE);
2545 }
2546
2547 /*!
2548  * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
2549  * Determine whether get_item() can get some item or not
2550  * @return アイテムを拾えるならばTRUEを返す。
2551  * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
2552  */
2553 bool can_get_item(void)
2554 {
2555         int j;
2556         OBJECT_IDX floor_list[23];
2557         ITEM_NUMBER floor_num = 0;
2558
2559         for (j = 0; j < INVEN_TOTAL; j++)
2560                 if (item_tester_okay(&p_ptr->inventory_list[j]))
2561                         return TRUE;
2562
2563         floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2564         if (floor_num)
2565                 return TRUE;
2566
2567         return FALSE;
2568 }
2569
2570 /*!
2571  * @brief オブジェクト選択の汎用関数 /
2572  * Let the user select an item, save its "index"
2573  * @param cp 選択したオブジェクトのIDを返す。
2574  * @param pmt 選択目的のメッセージ
2575  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
2576  * @param mode オプションフラグ
2577  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
2578  * Return TRUE only if an acceptable item was chosen by the user.\n
2579  * @details
2580  * The selected item must satisfy the "item_tester_hook()" function,\n
2581  * if that hook is set, and the "item_tester_tval", if that value is set.\n
2582  *\n
2583  * All "item_tester" restrictions are cleared before this function returns.\n
2584  *\n
2585  * The user is allowed to choose acceptable items from the equipment,\n
2586  * p_ptr->inventory_list, or floor, respectively, if the proper flag was given,\n
2587  * and there are any acceptable items in that location.\n
2588  *\n
2589  * The equipment or p_ptr->inventory_list are displayed (even if no acceptable\n
2590  * items are in that location) if the proper flag was given.\n
2591  *\n
2592  * If there are no acceptable items available anywhere, and "str" is\n
2593  * not NULL, then it will be used as the text of a warning message\n
2594  * before the function returns.\n
2595  *\n
2596  * Note that the user must press "-" to specify the item on the floor,\n
2597  * and there is no way to "examine" the item on the floor, while the\n
2598  * use of "capital" letters will "examine" an p_ptr->inventory_list/equipment item,\n
2599  * and prompt for its use.\n
2600  *\n
2601  * If a legal item is selected from the p_ptr->inventory_list, we save it in "cp"\n
2602  * directly (0 to 35), and return TRUE.\n
2603  *\n
2604  * If a legal item is selected from the floor, we save it in "cp" as\n
2605  * a negative (-1 to -511), and return TRUE.\n
2606  *\n
2607  * If no item is available, we do nothing to "cp", and we display a\n
2608  * warning message, using "str" if available, and return FALSE.\n
2609  *\n
2610  * If no item is selected, we do nothing to "cp", and return FALSE.\n
2611  *\n
2612  * Global "p_ptr->command_new" is used when viewing the p_ptr->inventory_list or equipment\n
2613  * to allow the user to enter a command while viewing those screens, and\n
2614  * also to induce "auto-enter" of stores, and other such stuff.\n
2615  *\n
2616  * Global "p_ptr->command_see" may be set before calling this function to start\n
2617  * out in "browse" mode.  It is cleared before this function returns.\n
2618  *\n
2619  * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
2620  * If it is TRUE then we are viewing p_ptr->inventory_list, else equipment.\n
2621  *\n
2622  * We always erase the prompt when we are done, leaving a blank line,\n
2623  * or a warning message, if appropriate, if no items are available.\n
2624  */
2625 bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode)
2626 {
2627         OBJECT_IDX this_o_idx, next_o_idx = 0;
2628
2629         char which = ' ';
2630
2631         int j;
2632         OBJECT_IDX k;
2633         OBJECT_IDX i1, i2;
2634         OBJECT_IDX e1, e2;
2635
2636         bool done, item;
2637
2638         bool oops = FALSE;
2639
2640         bool equip = FALSE;
2641         bool inven = FALSE;
2642         bool floor = FALSE;
2643
2644         bool allow_floor = FALSE;
2645
2646         bool toggle = FALSE;
2647
2648         char tmp_val[160];
2649         char out_val[160];
2650
2651         int menu_line = (use_menu ? 1 : 0);
2652         int max_inven = 0;
2653         int max_equip = 0;
2654
2655         static char prev_tag = '\0';
2656         char cur_tag = '\0';
2657
2658         if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
2659
2660         /* Extract args */
2661         if (mode & USE_EQUIP) equip = TRUE;
2662         if (mode & USE_INVEN) inven = TRUE;
2663         if (mode & USE_FLOOR) floor = TRUE;
2664
2665         /* Get the item index */
2666         if (repeat_pull(cp))
2667         {
2668                 /* the_force */
2669                 if (mode & USE_FORCE && (*cp == INVEN_FORCE))
2670                 {
2671                         item_tester_tval = 0;
2672                         item_tester_hook = NULL;
2673                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2674                         return (TRUE);
2675                 }
2676
2677                 /* Floor item? */
2678                 else if (floor && (*cp < 0))
2679                 {
2680                         object_type *o_ptr;
2681
2682                         /* Special index */
2683                         k = 0 - (*cp);
2684                         o_ptr = &current_floor_ptr->o_list[k];
2685
2686                         /* Validate the item */
2687                         if (item_tester_okay(o_ptr) || (mode & USE_FULL))
2688                         {
2689                                 /* Forget restrictions */
2690                                 item_tester_tval = 0;
2691                                 item_tester_hook = NULL;
2692                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2693
2694                                 /* Success */
2695                                 return TRUE;
2696                         }
2697                 }
2698
2699                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2700                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2701                 {
2702                         if (prev_tag && command_cmd)
2703                         {
2704                                 /* Look up the tag and validate the item */
2705                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2706                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2707                                 else if (!get_item_okay(k)) /* Reject */;
2708                                 else
2709                                 {
2710                                         /* Accept that choice */
2711                                         (*cp) = k;
2712
2713                                         /* Forget restrictions */
2714                                         item_tester_tval = 0;
2715                                         item_tester_hook = NULL;
2716                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2717
2718                                         /* Success */
2719                                         return TRUE;
2720                                 }
2721
2722                                 prev_tag = '\0'; /* prev_tag is no longer effective */
2723                         }
2724
2725                         /* Verify the item */
2726                         else if (get_item_okay(*cp))
2727                         {
2728                                 /* Forget restrictions */
2729                                 item_tester_tval = 0;
2730                                 item_tester_hook = NULL;
2731                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2732
2733                                 /* Success */
2734                                 return TRUE;
2735                         }
2736                 }
2737         }
2738         msg_print(NULL);
2739
2740         /* Not done */
2741         done = FALSE;
2742
2743         /* No item selected */
2744         item = FALSE;
2745
2746
2747         /* Full p_ptr->inventory_list */
2748         i1 = 0;
2749         i2 = INVEN_PACK - 1;
2750
2751         /* Forbid p_ptr->inventory_list */
2752         if (!inven) i2 = -1;
2753         else if (use_menu)
2754         {
2755                 for (j = 0; j < INVEN_PACK; j++)
2756                         if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
2757         }
2758
2759         /* Restrict p_ptr->inventory_list indexes */
2760         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2761         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2762
2763
2764         /* Full equipment */
2765         e1 = INVEN_RARM;
2766         e2 = INVEN_TOTAL - 1;
2767
2768         /* Forbid equipment */
2769         if (!equip) e2 = -1;
2770         else if (use_menu)
2771         {
2772                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2773                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
2774                 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
2775         }
2776
2777         /* Restrict equipment indexes */
2778         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2779         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2780
2781         if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
2782         {
2783                 if (p_ptr->migite)
2784                 {
2785                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2786                 }
2787                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
2788         }
2789
2790
2791         /* Restrict floor usage */
2792         if (floor)
2793         {
2794                 /* Scan all objects in the grid */
2795                 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)
2796                 {
2797                         object_type *o_ptr;
2798                         o_ptr = &current_floor_ptr->o_list[this_o_idx];
2799                         next_o_idx = o_ptr->next_o_idx;
2800
2801                         /* Accept the item on the floor if legal */
2802                         if ((item_tester_okay(o_ptr) || (mode & USE_FULL)) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
2803                 }
2804         }
2805
2806         /* Require at least one legal choice */
2807         if (!allow_floor && (i1 > i2) && (e1 > e2))
2808         {
2809                 /* Cancel p_ptr->command_see */
2810                 command_see = FALSE;
2811                 oops = TRUE;
2812                 done = TRUE;
2813
2814                 if (mode & USE_FORCE) {
2815                     *cp = INVEN_FORCE;
2816                     item = TRUE;
2817                 }
2818         }
2819
2820         /* Analyze choices */
2821         else
2822         {
2823                 /* Hack -- Start on equipment if requested */
2824                 if (command_see && command_wrk && equip)
2825                 {
2826                         command_wrk = TRUE;
2827                 }
2828
2829                 /* Use p_ptr->inventory_list if allowed */
2830                 else if (inven)
2831                 {
2832                         command_wrk = FALSE;
2833                 }
2834
2835                 /* Use equipment if allowed */
2836                 else if (equip)
2837                 {
2838                         command_wrk = TRUE;
2839                 }
2840
2841                 /* Use p_ptr->inventory_list for floor */
2842                 else
2843                 {
2844                         command_wrk = FALSE;
2845                 }
2846         }
2847
2848
2849         /*
2850          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2851          */
2852         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2853
2854         /* Hack -- start out in "display" mode */
2855         if (command_see)
2856         {
2857                 screen_save();
2858         }
2859
2860
2861         /* Repeat until done */
2862         while (!done)
2863         {
2864                 COMMAND_CODE get_item_label = 0;
2865
2866                 /* Show choices */
2867                 int ni = 0;
2868                 int ne = 0;
2869
2870                 /* Scan windows */
2871                 for (j = 0; j < 8; j++)
2872                 {
2873                         /* Unused */
2874                         if (!angband_term[j]) continue;
2875
2876                         /* Count windows displaying inven */
2877                         if (window_flag[j] & (PW_INVEN)) ni++;
2878
2879                         /* Count windows displaying equip */
2880                         if (window_flag[j] & (PW_EQUIP)) ne++;
2881                 }
2882
2883                 /* Toggle if needed */
2884                 if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
2885                 {
2886                         /* Toggle */
2887                         toggle_inven_equip();
2888
2889                         /* Track toggles */
2890                         toggle = !toggle;
2891                 }
2892
2893                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2894                 handle_stuff();
2895
2896                 /* Inventory screen */
2897                 if (!command_wrk)
2898                 {
2899                         /* Redraw if needed */
2900                         if (command_see) get_item_label = show_inven(menu_line, mode);
2901                 }
2902
2903                 /* Equipment screen */
2904                 else
2905                 {
2906                         /* Redraw if needed */
2907                         if (command_see) get_item_label = show_equip(menu_line, mode);
2908                 }
2909
2910                 /* Viewing p_ptr->inventory_list */
2911                 if (!command_wrk)
2912                 {
2913                         /* Begin the prompt */
2914                         sprintf(out_val, _("持ち物:", "Inven:"));
2915
2916                         /* Some legal items */
2917                         if ((i1 <= i2) && !use_menu)
2918                         {
2919                                 /* Build the prompt */
2920                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2921                                         index_to_label(i1), index_to_label(i2));
2922
2923                                 /* Append */
2924                                 strcat(out_val, tmp_val);
2925                         }
2926
2927                         /* Indicate ability to "view" */
2928                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2929
2930                         /* Append */
2931                         if (equip) strcat(out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
2932                 }
2933
2934                 /* Viewing equipment */
2935                 else
2936                 {
2937                         /* Begin the prompt */
2938                         sprintf(out_val, _("装備品:", "Equip:"));
2939
2940                         /* Some legal items */
2941                         if ((e1 <= e2) && !use_menu)
2942                         {
2943                                 /* Build the prompt */
2944                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2945                                         index_to_label(e1), index_to_label(e2));
2946
2947                                 /* Append */
2948                                 strcat(out_val, tmp_val);
2949                         }
2950
2951                         /* Indicate ability to "view" */
2952                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2953
2954                         /* Append */
2955                         if (inven) strcat(out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
2956                 }
2957
2958                 /* Indicate legality of the "floor" item */
2959                 if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
2960                 if (mode & USE_FORCE) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
2961
2962                 /* Finish the prompt */
2963                 strcat(out_val, " ESC");
2964
2965                 /* Build the prompt */
2966                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
2967
2968                 /* Show the prompt */
2969                 prt(tmp_val, 0, 0);
2970
2971                 /* Get a key */
2972                 which = inkey();
2973
2974                 if (use_menu)
2975                 {
2976                 int max_line = (command_wrk ? max_equip : max_inven);
2977                 switch (which)
2978                 {
2979                         case ESCAPE:
2980                         case 'z':
2981                         case 'Z':
2982                         case '0':
2983                         {
2984                                 done = TRUE;
2985                                 break;
2986                         }
2987
2988                         case '8':
2989                         case 'k':
2990                         case 'K':
2991                         {
2992                                 menu_line += (max_line - 1);
2993                                 break;
2994                         }
2995
2996                         case '2':
2997                         case 'j':
2998                         case 'J':
2999                         {
3000                                 menu_line++;
3001                                 break;
3002                         }
3003
3004                         case '4':
3005                         case '6':
3006                         case 'h':
3007                         case 'H':
3008                         case 'l':
3009                         case 'L':
3010                         {
3011                                 /* Verify legality */
3012                                 if (!inven || !equip)
3013                                 {
3014                                         bell();
3015                                         break;
3016                                 }
3017
3018                                 /* Hack -- Fix screen */
3019                                 if (command_see)
3020                                 {
3021                                         screen_load();
3022                                         screen_save();
3023                                 }
3024
3025                                 /* Switch inven/equip */
3026                                 command_wrk = !command_wrk;
3027                                 max_line = (command_wrk ? max_equip : max_inven);
3028                                 if (menu_line > max_line) menu_line = max_line;
3029
3030                                 /* Need to redraw */
3031                                 break;
3032                         }
3033
3034                         case 'x':
3035                         case 'X':
3036                         case '\r':
3037                         case '\n':
3038                         {
3039                                 if (command_wrk == USE_FLOOR)
3040                                 {
3041                                         /* Special index */
3042                                         (*cp) = -get_item_label;
3043                                 }
3044                                 else
3045                                 {
3046                                         /* Validate the item */
3047                                         if (!get_item_okay(get_item_label))
3048                                         {
3049                                                 bell();
3050                                                 break;
3051                                         }
3052
3053                                         /* Allow player to "refuse" certain actions */
3054                                         if (!get_item_allow(get_item_label))
3055                                         {
3056                                                 done = TRUE;
3057                                                 break;
3058                                         }
3059
3060                                         /* Accept that choice */
3061                                         (*cp) = get_item_label;
3062                                 }
3063
3064                                 item = TRUE;
3065                                 done = TRUE;
3066                                 break;
3067                         }
3068                         case 'w':
3069                         {
3070                                 if (mode & USE_FORCE) {
3071                                         *cp = INVEN_FORCE;
3072                                         item = TRUE;
3073                                         done = TRUE;
3074                                         break;
3075                                 }
3076                         }
3077                 }
3078                 if (menu_line > max_line) menu_line -= max_line;
3079                 }
3080                 else
3081                 {
3082                 /* Parse it */
3083                 switch (which)
3084                 {
3085                         case ESCAPE:
3086                         {
3087                                 done = TRUE;
3088                                 break;
3089                         }
3090
3091                         case '*':
3092                         case '?':
3093                         case ' ':
3094                         {
3095                                 /* Hide the list */
3096                                 if (command_see)
3097                                 {
3098                                         /* Flip flag */
3099                                         command_see = FALSE;
3100                                         screen_load();
3101                                 }
3102
3103                                 /* Show the list */
3104                                 else
3105                                 {
3106                                         screen_save();
3107
3108                                         /* Flip flag */
3109                                         command_see = TRUE;
3110                                 }
3111                                 break;
3112                         }
3113
3114                         case '/':
3115                         {
3116                                 /* Verify legality */
3117                                 if (!inven || !equip)
3118                                 {
3119                                         bell();
3120                                         break;
3121                                 }
3122
3123                                 /* Hack -- Fix screen */
3124                                 if (command_see)
3125                                 {
3126                                         screen_load();
3127                                         screen_save();
3128                                 }
3129
3130                                 /* Switch inven/equip */
3131                                 command_wrk = !command_wrk;
3132
3133                                 /* Need to redraw */
3134                                 break;
3135                         }
3136
3137                         case '-':
3138                         {
3139                                 /* Use floor item */
3140                                 if (allow_floor)
3141                                 {
3142                                         /* Scan all objects in the grid */
3143                                         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)
3144                                         {
3145                                                 object_type *o_ptr;
3146                                                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
3147                                                 next_o_idx = o_ptr->next_o_idx;
3148
3149                                                 /* Validate the item */
3150                                                 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
3151
3152                                                 /* Special index */
3153                                                 k = 0 - this_o_idx;
3154
3155                                                 /* Verify the item (if required) */
3156                                                 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
3157
3158                                                 /* Allow player to "refuse" certain actions */
3159                                                 if (!get_item_allow(k)) continue;
3160
3161                                                 /* Accept that choice */
3162                                                 (*cp) = k;
3163                                                 item = TRUE;
3164                                                 done = TRUE;
3165                                                 break;
3166                                         }
3167
3168                                         /* Outer break */
3169                                         if (done) break;
3170                                 }
3171
3172                                 bell();
3173                                 break;
3174                         }
3175
3176                         case '0':
3177                         case '1': case '2': case '3':
3178                         case '4': case '5': case '6':
3179                         case '7': case '8': case '9':
3180                         {
3181                                 /* Look up the tag */
3182                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3183                                 {
3184                                         bell();
3185                                         break;
3186                                 }
3187
3188                                 /* Hack -- Validate the item */
3189                                 if ((k < INVEN_RARM) ? !inven : !equip)
3190                                 {
3191                                         bell();
3192                                         break;
3193                                 }
3194
3195                                 /* Validate the item */
3196                                 if (!get_item_okay(k))
3197                                 {
3198                                         bell();
3199                                         break;
3200                                 }
3201
3202                                 /* Allow player to "refuse" certain actions */
3203                                 if (!get_item_allow(k))
3204                                 {
3205                                         done = TRUE;
3206                                         break;
3207                                 }
3208
3209                                 /* Accept that choice */
3210                                 (*cp) = k;
3211                                 item = TRUE;
3212                                 done = TRUE;
3213                                 cur_tag = which;
3214                                 break;
3215                         }
3216
3217 #if 0
3218                         case '\n':
3219                         case '\r':
3220                         {
3221                                 /* Choose "default" p_ptr->inventory_list item */
3222                                 if (!command_wrk)
3223                                 {
3224                                         k = ((i1 == i2) ? i1 : -1);
3225                                 }
3226
3227                                 /* Choose "default" equipment item */
3228                                 else
3229                                 {
3230                                         k = ((e1 == e2) ? e1 : -1);
3231                                 }
3232
3233                                 /* Validate the item */
3234                                 if (!get_item_okay(k))
3235                                 {
3236                                         bell();
3237                                         break;
3238                                 }
3239
3240                                 /* Allow player to "refuse" certain actions */
3241                                 if (!get_item_allow(k))
3242                                 {
3243                                         done = TRUE;
3244                                         break;
3245                                 }
3246
3247                                 /* Accept that choice */
3248                                 (*cp) = k;
3249                                 item = TRUE;
3250                                 done = TRUE;
3251                                 break;
3252                         }
3253 #endif
3254
3255                         case 'w':
3256                         {
3257                                 if (mode & USE_FORCE) {
3258                                         *cp = INVEN_FORCE;
3259                                         item = TRUE;
3260                                         done = TRUE;
3261                                         break;
3262                                 }
3263
3264                                 /* Fall through */
3265                         }
3266
3267                         default:
3268                         {
3269                                 int ver;
3270                                 bool not_found = FALSE;
3271
3272                                 /* Look up the alphabetical tag */
3273                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3274                                 {
3275                                         not_found = TRUE;
3276                                 }
3277
3278                                 /* Hack -- Validate the item */
3279                                 else if ((k < INVEN_RARM) ? !inven : !equip)
3280                                 {
3281                                         not_found = TRUE;
3282                                 }
3283
3284                                 /* Validate the item */
3285                                 else if (!get_item_okay(k))
3286                                 {
3287                                         not_found = TRUE;
3288                                 }
3289
3290                                 if (!not_found)
3291                                 {
3292                                         /* Accept that choice */
3293                                         (*cp) = k;
3294                                         item = TRUE;
3295                                         done = TRUE;
3296                                         cur_tag = which;
3297                                         break;
3298                                 }
3299
3300                                 /* Extract "query" setting */
3301                                 ver = isupper(which);
3302                                 which = (char)tolower(which);
3303
3304                                 /* Convert letter to p_ptr->inventory_list index */
3305                                 if (!command_wrk)
3306                                 {
3307                                         if (which == '(') k = i1;
3308                                         else if (which == ')') k = i2;
3309                                         else k = label_to_inven(which);
3310                                 }
3311
3312                                 /* Convert letter to equipment index */
3313                                 else
3314                                 {
3315                                         if (which == '(') k = e1;
3316                                         else if (which == ')') k = e2;
3317                                         else k = label_to_equip(which);
3318                                 }
3319
3320                                 /* Validate the item */
3321                                 if (!get_item_okay(k))
3322                                 {
3323                                         bell();
3324                                         break;
3325                                 }
3326
3327                                 /* Verify the item */
3328                                 if (ver && !verify(_("本当に", "Try"), k))
3329                                 {
3330                                         done = TRUE;
3331                                         break;
3332                                 }
3333
3334                                 /* Allow player to "refuse" certain actions */
3335                                 if (!get_item_allow(k))
3336                                 {
3337                                         done = TRUE;
3338                                         break;
3339                                 }
3340
3341                                 /* Accept that choice */
3342                                 (*cp) = k;
3343                                 item = TRUE;
3344                                 done = TRUE;
3345                                 break;
3346                         }
3347                 }
3348                 }
3349         }
3350
3351
3352         /* Fix the screen if necessary */
3353         if (command_see)
3354         {
3355                 screen_load();
3356
3357                 /* Hack -- Cancel "display" */
3358                 command_see = FALSE;
3359         }
3360
3361
3362         /* Forget the item_tester_tval restriction */
3363         item_tester_tval = 0;
3364
3365         /* Forget the item_tester_hook restriction */
3366         item_tester_hook = NULL;
3367
3368
3369         /* Clean up  'show choices' */
3370         /* Toggle again if needed */
3371         if (toggle) toggle_inven_equip();
3372
3373         p_ptr->window |= (PW_INVEN | PW_EQUIP);
3374         handle_stuff();
3375
3376         /* Clear the prompt line */
3377         prt("", 0, 0);
3378
3379         /* Warning if needed */
3380         if (oops && str) msg_print(str);
3381
3382         if (item)
3383         {
3384                 repeat_push(*cp);
3385                 if (command_cmd) prev_tag = cur_tag;
3386                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3387         }
3388         return (item);
3389 }
3390
3391 /*
3392  * Choose an item and get auto-picker entry from it.
3393  */
3394 object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
3395 {
3396         OBJECT_IDX item;
3397         if (!get_item(&item, q, s, option)) return NULL;
3398         if (idx) *idx = item;
3399
3400         if (item == INVEN_FORCE) return NULL;
3401
3402         /* Get the item (in the pack) */
3403         else if (item >= 0) return &p_ptr->inventory_list[item];
3404
3405         /* Get the item (on the floor) */
3406         else return &current_floor_ptr->o_list[0 - item];
3407 }
3408
3409
3410 /*!
3411  * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
3412  * @param items オブジェクトのIDリストを返すための配列参照ポインタ
3413  * @param y 走査するフロアのY座標
3414  * @param x 走査するフロアのX座標
3415  * @param mode オプションフラグ
3416  * @return 対象のマスに落ちているアイテム数
3417  * @details
3418  * Return a list of o_list[] indexes of items at the given current_floor_ptr->grid_array
3419  * location. Valid flags are:
3420  *
3421  *              mode & 0x01 -- Item tester
3422  *              mode & 0x02 -- Marked items only
3423  *              mode & 0x04 -- Stop after first
3424  */
3425 ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
3426 {
3427         OBJECT_IDX this_o_idx, next_o_idx;
3428
3429         ITEM_NUMBER num = 0;
3430
3431         /* Sanity */
3432         if (!in_bounds(y, x)) return 0;
3433
3434         /* Scan all objects in the grid */
3435         for (this_o_idx = current_floor_ptr->grid_array[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3436         {
3437                 object_type *o_ptr;
3438                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
3439                 next_o_idx = o_ptr->next_o_idx;
3440
3441                 /* Item tester */
3442                 if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
3443
3444                 /* Marked */
3445                 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
3446
3447                 /* Accept this item */
3448                 /* XXX Hack -- Enforce limit */
3449                 if (num < 23)
3450                         items[num] = this_o_idx;
3451
3452                 num++;
3453
3454                 /* Only one */
3455                 if (mode & 0x04) break;
3456         }
3457         return num;
3458 }
3459
3460
3461 /*!
3462  * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
3463  * @param target_item カーソルの初期値
3464  * @param y 走査するフロアのY座標
3465  * @param x 走査するフロアのX座標
3466  * @param min_width 表示の長さ
3467  * @return 選択したアイテムの添え字
3468  * @details
3469  */
3470 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
3471 {
3472         COMMAND_CODE i, m;
3473         int j, k, l;
3474         int col, len;
3475
3476         object_type *o_ptr;
3477
3478         GAME_TEXT o_name[MAX_NLEN];
3479         char tmp_val[80];
3480
3481         COMMAND_CODE out_index[23];
3482         TERM_COLOR out_color[23];
3483         char out_desc[23][MAX_NLEN];
3484         COMMAND_CODE target_item_label = 0;
3485
3486         OBJECT_IDX floor_list[23];
3487         ITEM_NUMBER floor_num;
3488         TERM_LEN wid, hgt;
3489         char floor_label[52 + 1];
3490
3491         bool dont_need_to_show_weights = TRUE;
3492
3493         Term_get_size(&wid, &hgt);
3494
3495         /* Default length */
3496         len = MAX((*min_width), 20);
3497
3498         /* Scan for objects in the grid, using item_tester_okay() */
3499         floor_num = scan_floor(floor_list, y, x, 0x03);
3500
3501         /* Display the floor objects */
3502         for (k = 0, i = 0; i < floor_num && i < 23; i++)
3503         {
3504                 o_ptr = &current_floor_ptr->o_list[floor_list[i]];
3505
3506                 object_desc(o_name, o_ptr, 0);
3507
3508                 /* Save the index */
3509                 out_index[k] = i;
3510
3511                 /* Acquire p_ptr->inventory_list color */
3512                 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
3513
3514                 /* Save the object description */
3515                 strcpy(out_desc[k], o_name);
3516
3517                 /* Find the predicted "line length" */
3518                 l = strlen(out_desc[k]) + 5;
3519
3520                 /* Be sure to account for the weight */
3521                 if (show_weights) l += 9;
3522
3523                 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
3524
3525                 /* Maintain the maximum length */
3526                 if (l > len) len = l;
3527
3528                 /* Advance to next "line" */
3529                 k++;
3530         }
3531
3532         if (show_weights && dont_need_to_show_weights) len -= 9;
3533
3534         /* Save width */
3535         *min_width = len;
3536
3537         /* Find the column to start in */
3538         col = (len > wid - 4) ? 0 : (wid - len - 1);
3539
3540         prepare_label_string_floor(floor_label, floor_list, floor_num);
3541
3542         /* Output each entry */
3543         for (j = 0; j < k; j++)
3544         {
3545                 m = floor_list[out_index[j]];
3546                 o_ptr = &current_floor_ptr->o_list[m];
3547
3548                 /* Clear the line */
3549                 prt("", j + 1, col ? col - 2 : col);
3550
3551                 if (use_menu && target_item)
3552                 {
3553                         if (j == (target_item-1))
3554                         {
3555                                 strcpy(tmp_val, _("》", "> "));
3556                                 target_item_label = m;
3557                         }
3558                         else strcpy(tmp_val, "   ");
3559                 }
3560                 else
3561                 {
3562                         /* Prepare an index --(-- */
3563                         sprintf(tmp_val, "%c)", floor_label[j]);
3564                 }
3565
3566                 /* Clear the line with the (possibly indented) index */
3567                 put_str(tmp_val, j + 1, col);
3568
3569                 /* Display the entry itself */
3570                 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
3571
3572                 /* Display the weight if needed */
3573                 if (show_weights && (o_ptr->tval != TV_GOLD))
3574                 {
3575                         int wgt = o_ptr->weight * o_ptr->number;
3576 #ifdef JP
3577                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3578 #else
3579                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3580 #endif
3581
3582                         prt(tmp_val, j + 1, wid - 9);
3583                 }
3584         }
3585
3586         /* Make a "shadow" below the list (only if needed) */
3587         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3588
3589         return target_item_label;
3590 }
3591
3592 /*!
3593  * @brief オブジェクト選択の汎用関数(床上アイテム用) /
3594  * Let the user select an item, save its "index"
3595  * @param cp 選択したオブジェクトのIDを返す。
3596  * @param pmt 選択目的のメッセージ
3597  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
3598  * @param mode オプションフラグ
3599  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
3600  */
3601 bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode)
3602 {
3603         char n1 = ' ', n2 = ' ', which = ' ';
3604
3605         int j;
3606         COMMAND_CODE i1, i2;
3607         COMMAND_CODE e1, e2;
3608         COMMAND_CODE k;
3609
3610         bool done, item;
3611
3612         bool oops = FALSE;
3613
3614         /* Extract args */
3615         bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
3616         bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
3617         bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
3618         bool force = (mode & USE_FORCE) ? TRUE : FALSE;
3619
3620         bool allow_equip = FALSE;
3621         bool allow_inven = FALSE;
3622         bool allow_floor = FALSE;
3623
3624         bool toggle = FALSE;
3625
3626         char tmp_val[160];
3627         char out_val[160];
3628
3629         ITEM_NUMBER floor_num;
3630         OBJECT_IDX floor_list[23];
3631         int floor_top = 0;
3632         TERM_LEN min_width = 0;
3633
3634         int menu_line = (use_menu ? 1 : 0);
3635         int max_inven = 0;
3636         int max_equip = 0;
3637
3638         static char prev_tag = '\0';
3639         char cur_tag = '\0';
3640
3641         /* Get the item index */
3642         if (repeat_pull(cp))
3643         {
3644                 /* the_force */
3645                 if (force && (*cp == INVEN_FORCE))
3646                 {
3647                         item_tester_tval = 0;
3648                         item_tester_hook = NULL;
3649                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3650                         return (TRUE);
3651                 }
3652
3653                 /* Floor item? */
3654                 else if (floor && (*cp < 0))
3655                 {
3656                         if (prev_tag && command_cmd)
3657                         {
3658                                 /* Scan all objects in the grid */
3659                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3660
3661                                 /* Look up the tag */
3662                                 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
3663                                 {
3664                                         /* Accept that choice */
3665                                         (*cp) = 0 - floor_list[k];
3666
3667                                         /* Forget restrictions */
3668                                         item_tester_tval = 0;
3669                                         item_tester_hook = NULL;
3670                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3671
3672                                         /* Success */
3673                                         return TRUE;
3674                                 }
3675
3676                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3677                         }
3678
3679                         /* Validate the item */
3680                         else if (item_tester_okay(&current_floor_ptr->o_list[0 - (*cp)]) || (mode & USE_FULL))
3681                         {
3682                                 /* Forget restrictions */
3683                                 item_tester_tval = 0;
3684                                 item_tester_hook = NULL;
3685                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3686
3687                                 /* Success */
3688                                 return TRUE;
3689                         }
3690                 }
3691
3692                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3693                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3694                 {
3695                         if (prev_tag && command_cmd)
3696                         {
3697                                 /* Look up the tag and validate the item */
3698                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3699                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3700                                 else if (!get_item_okay(k)) /* Reject */;
3701                                 else
3702                                 {
3703                                         /* Accept that choice */
3704                                         (*cp) = k;
3705
3706                                         /* Forget restrictions */
3707                                         item_tester_tval = 0;
3708                                         item_tester_hook = NULL;
3709                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3710
3711                                         /* Success */
3712                                         return TRUE;
3713                                 }
3714
3715                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3716                         }
3717
3718                         /* Verify the item */
3719                         else if (get_item_okay(*cp))
3720                         {
3721                                 /* Forget restrictions */
3722                                 item_tester_tval = 0;
3723                                 item_tester_hook = NULL;
3724                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3725
3726                                 /* Success */
3727                                 return TRUE;
3728                         }
3729                 }
3730         }
3731
3732         msg_print(NULL);
3733
3734
3735         /* Not done */
3736         done = FALSE;
3737
3738         /* No item selected */
3739         item = FALSE;
3740
3741
3742         /* Full p_ptr->inventory_list */
3743         i1 = 0;
3744         i2 = INVEN_PACK - 1;
3745
3746         /* Forbid p_ptr->inventory_list */
3747         if (!inven) i2 = -1;
3748         else if (use_menu)
3749         {
3750                 for (j = 0; j < INVEN_PACK; j++)
3751                         if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
3752         }
3753
3754         /* Restrict p_ptr->inventory_list indexes */
3755         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3756         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3757
3758
3759         /* Full equipment */
3760         e1 = INVEN_RARM;
3761         e2 = INVEN_TOTAL - 1;
3762
3763         /* Forbid equipment */
3764         if (!equip) e2 = -1;
3765         else if (use_menu)
3766         {
3767                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3768                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
3769                 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
3770         }
3771
3772         /* Restrict equipment indexes */
3773         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3774         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3775
3776         if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
3777         {
3778                 if (p_ptr->migite)
3779                 {
3780                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3781                 }
3782                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
3783         }
3784
3785
3786         /* Count "okay" floor items */
3787         floor_num = 0;
3788
3789         /* Restrict floor usage */
3790         if (floor)
3791         {
3792                 /* Scan all objects in the grid */
3793                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3794         }
3795
3796         /* Accept p_ptr->inventory_list */
3797         if (i1 <= i2) allow_inven = TRUE;
3798
3799         /* Accept equipment */
3800         if (e1 <= e2) allow_equip = TRUE;
3801
3802         /* Accept floor */
3803         if (floor_num) allow_floor = TRUE;
3804
3805         /* Require at least one legal choice */
3806         if (!allow_inven && !allow_equip && !allow_floor)
3807         {
3808                 /* Cancel p_ptr->command_see */
3809                 command_see = FALSE;
3810                 oops = TRUE;
3811                 done = TRUE;
3812
3813                 if (force) {
3814                     *cp = INVEN_FORCE;
3815                     item = TRUE;
3816                 }
3817         }
3818
3819         /* Analyze choices */
3820         else
3821         {
3822                 /* Hack -- Start on equipment if requested */
3823                 if (command_see && (command_wrk == (USE_EQUIP))
3824                         && allow_equip)
3825                 {
3826                         command_wrk = (USE_EQUIP);
3827                 }
3828
3829                 /* Use p_ptr->inventory_list if allowed */
3830                 else if (allow_inven)
3831                 {
3832                         command_wrk = (USE_INVEN);
3833                 }
3834
3835                 /* Use equipment if allowed */
3836                 else if (allow_equip)
3837                 {
3838                         command_wrk = (USE_EQUIP);
3839                 }
3840
3841                 /* Use floor if allowed */
3842                 else if (allow_floor)
3843                 {
3844                         command_wrk = (USE_FLOOR);
3845                 }
3846         }
3847
3848         /*
3849          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
3850          */
3851         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
3852
3853         /* Hack -- start out in "display" mode */
3854         if (command_see)
3855         {
3856                 screen_save();
3857         }
3858
3859         /* Repeat until done */
3860         while (!done)
3861         {
3862                 COMMAND_CODE get_item_label = 0;
3863
3864                 /* Show choices */
3865                 int ni = 0;
3866                 int ne = 0;
3867
3868                 /* Scan windows */
3869                 for (j = 0; j < 8; j++)
3870                 {
3871                         /* Unused */
3872                         if (!angband_term[j]) continue;
3873
3874                         /* Count windows displaying inven */
3875                         if (window_flag[j] & (PW_INVEN)) ni++;
3876
3877                         /* Count windows displaying equip */
3878                         if (window_flag[j] & (PW_EQUIP)) ne++;
3879                 }
3880
3881                 /* Toggle if needed */
3882                 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
3883                     (command_wrk == (USE_INVEN) && !ni && ne))
3884                 {
3885                         /* Toggle */
3886                         toggle_inven_equip();
3887
3888                         /* Track toggles */
3889                         toggle = !toggle;
3890                 }
3891
3892                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3893                 handle_stuff();
3894
3895                 /* Inventory screen */
3896                 if (command_wrk == (USE_INVEN))
3897                 {
3898                         /* Extract the legal requests */
3899                         n1 = I2A(i1);
3900                         n2 = I2A(i2);
3901
3902                         /* Redraw if needed */
3903                         if (command_see) get_item_label = show_inven(menu_line, mode);
3904                 }
3905
3906                 /* Equipment screen */
3907                 else if (command_wrk == (USE_EQUIP))
3908                 {
3909                         /* Extract the legal requests */
3910                         n1 = I2A(e1 - INVEN_RARM);
3911                         n2 = I2A(e2 - INVEN_RARM);
3912
3913                         /* Redraw if needed */
3914                         if (command_see) get_item_label = show_equip(menu_line, mode);
3915                 }
3916
3917                 /* Floor screen */
3918                 else if (command_wrk == (USE_FLOOR))
3919                 {
3920                         j = floor_top;
3921                         k = MIN(floor_top + 23, floor_num) - 1;
3922
3923                         /* Extract the legal requests */
3924                         n1 = I2A(j - floor_top);
3925                         n2 = I2A(k - floor_top);
3926
3927                         /* Redraw if needed */
3928                         if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
3929                 }
3930
3931                 /* Viewing p_ptr->inventory_list */
3932                 if (command_wrk == (USE_INVEN))
3933                 {
3934                         /* Begin the prompt */
3935                         sprintf(out_val, _("持ち物:", "Inven:"));
3936
3937                         if (!use_menu)
3938                         {
3939                                 /* Build the prompt */
3940                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3941                                         index_to_label(i1), index_to_label(i2));
3942
3943                                 /* Append */
3944                                 strcat(out_val, tmp_val);
3945                         }
3946
3947                         /* Indicate ability to "view" */
3948                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3949
3950                         /* Append */
3951                         if (allow_equip)
3952                         {
3953                                 if (!use_menu)
3954                                         strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
3955                                 else if (allow_floor)
3956                                         strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
3957                                 else
3958                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
3959                         }
3960
3961                         /* Append */
3962                         if (allow_floor)
3963                         {
3964                                 if (!use_menu)
3965                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
3966                                 else if (allow_equip)
3967                                         strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
3968                                 else
3969                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
3970                         }
3971                 }
3972
3973                 /* Viewing equipment */
3974                 else if (command_wrk == (USE_EQUIP))
3975                 {
3976                         /* Begin the prompt */
3977                         sprintf(out_val, _("装備品:", "Equip:"));
3978
3979                         if (!use_menu)
3980                         {
3981                                 /* Build the prompt */
3982                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3983                                         index_to_label(e1), index_to_label(e2));
3984
3985                                 /* Append */
3986                                 strcat(out_val, tmp_val);
3987                         }
3988
3989                         /* Indicate ability to "view" */
3990                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3991
3992                         /* Append */
3993                         if (allow_inven)
3994                         {
3995                                 if (!use_menu)
3996                                         strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
3997                                 else if (allow_floor)
3998                                         strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
3999                                 else
4000                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4001                         }
4002
4003                         /* Append */
4004                         if (allow_floor)
4005                         {
4006                                 if (!use_menu)
4007                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
4008                                 else if (allow_inven)
4009                                         strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
4010                                 else
4011                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
4012                         }
4013                 }
4014
4015                 /* Viewing floor */
4016                 else if (command_wrk == (USE_FLOOR))
4017                 {
4018                         /* Begin the prompt */
4019                         sprintf(out_val, _("床上:", "Floor:"));
4020
4021                         if (!use_menu)
4022                         {
4023                                 /* Build the prompt */
4024                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
4025
4026                                 /* Append */
4027                                 strcat(out_val, tmp_val);
4028                         }
4029
4030                         /* Indicate ability to "view" */
4031                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4032
4033                         if (use_menu)
4034                         {
4035                                 if (allow_inven && allow_equip)
4036                                 {
4037                                         strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
4038                                 }
4039                                 else if (allow_inven)
4040                                 {
4041                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4042                                 }
4043                                 else if (allow_equip)
4044                                 {
4045                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
4046                                 }
4047                         }
4048                         /* Append */
4049                         else if (allow_inven)
4050                         {
4051                                 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4052                         }
4053                         else if (allow_equip)
4054                         {
4055                                 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
4056                         }
4057
4058                         /* Append */
4059                         if (command_see && !use_menu)
4060                         {
4061                                 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
4062                         }
4063                 }
4064
4065                 /* Append */
4066                 if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
4067
4068                 /* Finish the prompt */
4069                 strcat(out_val, " ESC");
4070
4071                 /* Build the prompt */
4072                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
4073
4074                 /* Show the prompt */
4075                 prt(tmp_val, 0, 0);
4076
4077                 /* Get a key */
4078                 which = inkey();
4079
4080                 if (use_menu)
4081                 {
4082                 int max_line = 1;
4083                 if (command_wrk == USE_INVEN) max_line = max_inven;
4084                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4085                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4086                 switch (which)
4087                 {
4088                         case ESCAPE:
4089                         case 'z':
4090                         case 'Z':
4091                         case '0':
4092                         {
4093                                 done = TRUE;
4094                                 break;
4095                         }
4096
4097                         case '8':
4098                         case 'k':
4099                         case 'K':
4100                         {
4101                                 menu_line += (max_line - 1);
4102                                 break;
4103                         }
4104
4105                         case '2':
4106                         case 'j':
4107                         case 'J':
4108                         {
4109                                 menu_line++;
4110                                 break;
4111                         }
4112
4113                         case '4':
4114                         case 'h':
4115                         case 'H':
4116                         {
4117                                 /* Verify legality */
4118                                 if (command_wrk == (USE_INVEN))
4119                                 {
4120                                         if (allow_floor) command_wrk = USE_FLOOR;
4121                                         else if (allow_equip) command_wrk = USE_EQUIP;
4122                                         else
4123                                         {
4124                                                 bell();
4125                                                 break;
4126                                         }
4127                                 }
4128                                 else if (command_wrk == (USE_EQUIP))
4129                                 {
4130                                         if (allow_inven) command_wrk = USE_INVEN;
4131                                         else if (allow_floor) command_wrk = USE_FLOOR;
4132                                         else
4133                                         {
4134                                                 bell();
4135                                                 break;
4136                                         }
4137                                 }
4138                                 else if (command_wrk == (USE_FLOOR))
4139                                 {
4140                                         if (allow_equip) command_wrk = USE_EQUIP;
4141                                         else if (allow_inven) command_wrk = USE_INVEN;
4142                                         else
4143                                         {
4144                                                 bell();
4145                                                 break;
4146                                         }
4147                                 }
4148                                 else
4149                                 {
4150                                         bell();
4151                                         break;
4152                                 }
4153
4154                                 /* Hack -- Fix screen */
4155                                 if (command_see)
4156                                 {
4157                                         screen_load();
4158                                         screen_save();
4159                                 }
4160
4161                                 /* Switch inven/equip */
4162                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4163                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4164                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4165                                 if (menu_line > max_line) menu_line = max_line;
4166
4167                                 /* Need to redraw */
4168                                 break;
4169                         }
4170
4171                         case '6':
4172                         case 'l':
4173                         case 'L':
4174                         {
4175                                 /* Verify legality */
4176                                 if (command_wrk == (USE_INVEN))
4177                                 {
4178                                         if (allow_equip) command_wrk = USE_EQUIP;
4179                                         else if (allow_floor) command_wrk = USE_FLOOR;
4180                                         else
4181                                         {
4182                                                 bell();
4183                                                 break;
4184                                         }
4185                                 }
4186                                 else if (command_wrk == (USE_EQUIP))
4187                                 {
4188                                         if (allow_floor) command_wrk = USE_FLOOR;
4189                                         else if (allow_inven) command_wrk = USE_INVEN;
4190                                         else
4191                                         {
4192                                                 bell();
4193                                                 break;
4194                                         }
4195                                 }
4196                                 else if (command_wrk == (USE_FLOOR))
4197                                 {
4198                                         if (allow_inven) command_wrk = USE_INVEN;
4199                                         else if (allow_equip) command_wrk = USE_EQUIP;
4200                                         else
4201                                         {
4202                                                 bell();
4203                                                 break;
4204                                         }
4205                                 }
4206                                 else
4207                                 {
4208                                         bell();
4209                                         break;
4210                                 }
4211
4212                                 /* Hack -- Fix screen */
4213                                 if (command_see)
4214                                 {
4215                                         screen_load();
4216                                         screen_save();
4217                                 }
4218
4219                                 /* Switch inven/equip */
4220                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4221                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4222                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4223                                 if (menu_line > max_line) menu_line = max_line;
4224
4225                                 /* Need to redraw */
4226                                 break;
4227                         }
4228
4229                         case 'x':
4230                         case 'X':
4231                         case '\r':
4232                         case '\n':
4233                         {
4234                                 if (command_wrk == USE_FLOOR)
4235                                 {
4236                                         /* Special index */
4237                                         (*cp) = -get_item_label;
4238                                 }
4239                                 else
4240                                 {
4241                                         /* Validate the item */
4242                                         if (!get_item_okay(get_item_label))
4243                                         {
4244                                                 bell();
4245                                                 break;
4246                                         }
4247
4248                                         /* Allow player to "refuse" certain actions */
4249                                         if (!get_item_allow(get_item_label))
4250                                         {
4251                                                 done = TRUE;
4252                                                 break;
4253                                         }
4254
4255                                         /* Accept that choice */
4256                                         (*cp) = get_item_label;
4257                                 }
4258
4259                                 item = TRUE;
4260                                 done = TRUE;
4261                                 break;
4262                         }
4263                         case 'w':
4264                         {
4265                                 if (force) {
4266                                         *cp = INVEN_FORCE;
4267                                         item = TRUE;
4268                                         done = TRUE;
4269                                         break;
4270                                 }
4271                         }
4272                 }
4273                 if (menu_line > max_line) menu_line -= max_line;
4274                 }
4275                 else
4276                 {
4277                 /* Parse it */
4278                 switch (which)
4279                 {
4280                         case ESCAPE:
4281                         {
4282                                 done = TRUE;
4283                                 break;
4284                         }
4285
4286                         case '*':
4287                         case '?':
4288                         case ' ':
4289                         {
4290                                 /* Hide the list */
4291                                 if (command_see)
4292                                 {
4293                                         /* Flip flag */
4294                                         command_see = FALSE;
4295                                         screen_load();
4296                                 }
4297
4298                                 /* Show the list */
4299                                 else
4300                                 {
4301                                         screen_save();
4302
4303                                         /* Flip flag */
4304                                         command_see = TRUE;
4305                                 }
4306                                 break;
4307                         }
4308
4309                         case '\n':
4310                         case '\r':
4311                         case '+':
4312                         {
4313                                 int i;
4314                                 OBJECT_IDX o_idx;
4315                                 grid_type *g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
4316
4317                                 if (command_wrk != (USE_FLOOR)) break;
4318
4319                                 /* Get the object being moved. */
4320                                 o_idx = g_ptr->o_idx;
4321
4322                                 /* Only rotate a pile of two or more objects. */
4323                                 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) break;
4324
4325                                 /* Remove the first object from the list. */
4326                                 excise_object_idx(o_idx);
4327
4328                                 /* Find end of the list. */
4329                                 i = g_ptr->o_idx;
4330                                 while (current_floor_ptr->o_list[i].next_o_idx)
4331                                         i = current_floor_ptr->o_list[i].next_o_idx;
4332
4333                                 /* Add after the last object. */
4334                                 current_floor_ptr->o_list[i].next_o_idx = o_idx;
4335
4336                                 /* Re-scan floor list */ 
4337                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
4338
4339                                 /* Hack -- Fix screen */
4340                                 if (command_see)
4341                                 {
4342                                         screen_load();
4343                                         screen_save();
4344                                 }
4345
4346                                 break;
4347                         }
4348
4349                         case '/':
4350                         {
4351                                 if (command_wrk == (USE_INVEN))
4352                                 {
4353                                         if (!allow_equip)
4354                                         {
4355                                                 bell();
4356                                                 break;
4357                                         }
4358                                         command_wrk = (USE_EQUIP);
4359                                 }
4360                                 else if (command_wrk == (USE_EQUIP))
4361                                 {
4362                                         if (!allow_inven)
4363                                         {
4364                                                 bell();
4365                                                 break;
4366                                         }
4367                                         command_wrk = (USE_INVEN);
4368                                 }
4369                                 else if (command_wrk == (USE_FLOOR))
4370                                 {
4371                                         if (allow_inven)
4372                                         {
4373                                                 command_wrk = (USE_INVEN);
4374                                         }
4375                                         else if (allow_equip)
4376                                         {
4377                                                 command_wrk = (USE_EQUIP);
4378                                         }
4379                                         else
4380                                         {
4381                                                 bell();
4382                                                 break;
4383                                         }
4384                                 }
4385
4386                                 /* Hack -- Fix screen */
4387                                 if (command_see)
4388                                 {
4389                                         screen_load();
4390                                         screen_save();
4391                                 }
4392
4393                                 /* Need to redraw */
4394                                 break;
4395                         }
4396
4397                         case '-':
4398                         {
4399                                 if (!allow_floor)
4400                                 {
4401                                         bell();
4402                                         break;
4403                                 }
4404
4405                                 /*
4406                                  * If we are already examining the floor, and there
4407                                  * is only one item, we will always select it.
4408                                  * If we aren't examining the floor and there is only
4409                                  * one item, we will select it if floor_query_flag
4410                                  * is FALSE.
4411                                  */
4412                                 if (floor_num == 1)
4413                                 {
4414                                         if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
4415                                         {
4416                                                 /* Special index */
4417                                                 k = 0 - floor_list[0];
4418
4419                                                 /* Allow player to "refuse" certain actions */
4420                                                 if (!get_item_allow(k))
4421                                                 {
4422                                                         done = TRUE;
4423                                                         break;
4424                                                 }
4425
4426                                                 /* Accept that choice */
4427                                                 (*cp) = k;
4428                                                 item = TRUE;
4429                                                 done = TRUE;
4430
4431                                                 break;
4432                                         }
4433                                 }
4434
4435                                 /* Hack -- Fix screen */
4436                                 if (command_see)
4437                                 {
4438                                         screen_load();
4439                                         screen_save();
4440                                 }
4441
4442                                 command_wrk = (USE_FLOOR);
4443
4444                                 break;
4445                         }
4446
4447                         case '0':
4448                         case '1': case '2': case '3':
4449                         case '4': case '5': case '6':
4450                         case '7': case '8': case '9':
4451                         {
4452                                 if (command_wrk != USE_FLOOR)
4453                                 {
4454                                         /* Look up the tag */
4455                                         if (!get_tag(&k, which, command_wrk))
4456                                         {
4457                                                 bell();
4458                                                 break;
4459                                         }
4460
4461                                         /* Hack -- Validate the item */
4462                                         if ((k < INVEN_RARM) ? !inven : !equip)
4463                                         {
4464                                                 bell();
4465                                                 break;
4466                                         }
4467
4468                                         /* Validate the item */
4469                                         if (!get_item_okay(k))
4470                                         {
4471                                                 bell();
4472                                                 break;
4473                                         }
4474                                 }
4475                                 else
4476                                 {
4477                                         /* Look up the alphabetical tag */
4478                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4479                                         {
4480                                                 /* Special index */
4481                                                 k = 0 - floor_list[k];
4482                                         }
4483                                         else
4484                                         {
4485                                                 bell();
4486                                                 break;
4487                                         }
4488                                 }
4489
4490                                 /* Allow player to "refuse" certain actions */
4491                                 if (!get_item_allow(k))
4492                                 {
4493                                         done = TRUE;
4494                                         break;
4495                                 }
4496
4497                                 /* Accept that choice */
4498                                 (*cp) = k;
4499                                 item = TRUE;
4500                                 done = TRUE;
4501                                 cur_tag = which;
4502                                 break;
4503                         }
4504
4505 #if 0
4506                         case '\n':
4507                         case '\r':
4508                         {
4509                                 /* Choose "default" p_ptr->inventory_list item */
4510                                 if (command_wrk == (USE_INVEN))
4511                                 {
4512                                         k = ((i1 == i2) ? i1 : -1);
4513                                 }
4514
4515                                 /* Choose "default" equipment item */
4516                                 else if (command_wrk == (USE_EQUIP))
4517                                 {
4518                                         k = ((e1 == e2) ? e1 : -1);
4519                                 }
4520
4521                                 /* Choose "default" floor item */
4522                                 else if (command_wrk == (USE_FLOOR))
4523                                 {
4524                                         if (floor_num == 1)
4525                                         {
4526                                                 /* Special index */
4527                                                 k = 0 - floor_list[0];
4528
4529                                                 /* Allow player to "refuse" certain actions */
4530                                                 if (!get_item_allow(k))
4531                                                 {
4532                                                         done = TRUE;
4533                                                         break;
4534                                                 }
4535
4536                                                 /* Accept that choice */
4537                                                 (*cp) = k;
4538                                                 item = TRUE;
4539                                                 done = TRUE;
4540                                         }
4541                                         break;
4542                                 }
4543
4544                                 /* Validate the item */
4545                                 if (!get_item_okay(k))
4546                                 {
4547                                         bell();
4548                                         break;
4549                                 }
4550
4551                                 /* Allow player to "refuse" certain actions */
4552                                 if (!get_item_allow(k))
4553                                 {
4554                                         done = TRUE;
4555                                         break;
4556                                 }
4557
4558                                 /* Accept that choice */
4559                                 (*cp) = k;
4560                                 item = TRUE;
4561                                 done = TRUE;
4562                                 break;
4563                         }
4564 #endif
4565
4566                         case 'w':
4567                         {
4568                                 if (force) {
4569                                         *cp = INVEN_FORCE;
4570                                         item = TRUE;
4571                                         done = TRUE;
4572                                         break;
4573                                 }
4574
4575                                 /* Fall through */
4576                         }
4577
4578                         default:
4579                         {
4580                                 int ver;
4581
4582                                 if (command_wrk != USE_FLOOR)
4583                                 {
4584                                         bool not_found = FALSE;
4585
4586                                         /* Look up the alphabetical tag */
4587                                         if (!get_tag(&k, which, command_wrk))
4588                                         {
4589                                                 not_found = TRUE;
4590                                         }
4591
4592                                         /* Hack -- Validate the item */
4593                                         else if ((k < INVEN_RARM) ? !inven : !equip)
4594                                         {
4595                                                 not_found = TRUE;
4596                                         }
4597
4598                                         /* Validate the item */
4599                                         else if (!get_item_okay(k))
4600                                         {
4601                                                 not_found = TRUE;
4602                                         }
4603
4604                                         if (!not_found)
4605                                         {
4606                                                 /* Accept that choice */
4607                                                 (*cp) = k;
4608                                                 item = TRUE;
4609                                                 done = TRUE;
4610                                                 cur_tag = which;
4611                                                 break;
4612                                         }
4613                                 }
4614                                 else
4615                                 {
4616                                         /* Look up the alphabetical tag */
4617                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4618                                         {
4619                                                 /* Special index */
4620                                                 k = 0 - floor_list[k];
4621
4622                                                 /* Accept that choice */
4623                                                 (*cp) = k;
4624                                                 item = TRUE;
4625                                                 done = TRUE;
4626                                                 cur_tag = which;
4627                                                 break;
4628                                         }
4629                                 }
4630
4631                                 /* Extract "query" setting */
4632                                 ver = isupper(which);
4633                                 which = (char)tolower(which);
4634
4635                                 /* Convert letter to p_ptr->inventory_list index */
4636                                 if (command_wrk == (USE_INVEN))
4637                                 {
4638                                         if (which == '(') k = i1;
4639                                         else if (which == ')') k = i2;
4640                                         else k = label_to_inven(which);
4641                                 }
4642
4643                                 /* Convert letter to equipment index */
4644                                 else if (command_wrk == (USE_EQUIP))
4645                                 {
4646                                         if (which == '(') k = e1;
4647                                         else if (which == ')') k = e2;
4648                                         else k = label_to_equip(which);
4649                                 }
4650
4651                                 /* Convert letter to floor index */
4652                                 else if (command_wrk == USE_FLOOR)
4653                                 {
4654                                         if (which == '(') k = 0;
4655                                         else if (which == ')') k = floor_num - 1;
4656                                         else k = islower(which) ? A2I(which) : -1;
4657                                         if (k < 0 || k >= floor_num || k >= 23)
4658                                         {
4659                                                 bell();
4660                                                 break;
4661                                         }
4662
4663                                         /* Special index */
4664                                         k = 0 - floor_list[k];
4665                                 }
4666
4667                                 /* Validate the item */
4668                                 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
4669                                 {
4670                                         bell();
4671                                         break;
4672                                 }
4673
4674                                 /* Verify the item */
4675                                 if (ver && !verify(_("本当に", "Try"), k))
4676                                 {
4677                                         done = TRUE;
4678                                         break;
4679                                 }
4680
4681                                 /* Allow player to "refuse" certain actions */
4682                                 if (!get_item_allow(k))
4683                                 {
4684                                         done = TRUE;
4685                                         break;
4686                                 }
4687
4688                                 /* Accept that choice */
4689                                 (*cp) = k;
4690                                 item = TRUE;
4691                                 done = TRUE;
4692                                 break;
4693                         }
4694                 }
4695                 }
4696         }
4697
4698         /* Fix the screen if necessary */
4699         if (command_see)
4700         {
4701                 screen_load();
4702
4703                 /* Hack -- Cancel "display" */
4704                 command_see = FALSE;
4705         }
4706
4707
4708         /* Forget the item_tester_tval restriction */
4709         item_tester_tval = 0;
4710
4711         /* Forget the item_tester_hook restriction */
4712         item_tester_hook = NULL;
4713
4714
4715         /* Clean up  'show choices' */
4716         /* Toggle again if needed */
4717         if (toggle) toggle_inven_equip();
4718
4719         p_ptr->window |= (PW_INVEN | PW_EQUIP);
4720         handle_stuff();
4721
4722         /* Clear the prompt line */
4723         prt("", 0, 0);
4724
4725         /* Warning if needed */
4726         if (oops && str) msg_print(str);
4727
4728         if (item)
4729         {
4730                 repeat_push(*cp);
4731                 if (command_cmd) prev_tag = cur_tag;
4732                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4733         }
4734         return (item);
4735 }
4736
4737 /*!
4738  * @brief 床上のアイテムを拾う選択用サブルーチン 
4739  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
4740  */
4741 static bool py_pickup_floor_aux(void)
4742 {
4743         OBJECT_IDX this_o_idx;
4744         concptr q, s;
4745         OBJECT_IDX item;
4746
4747         /* Restrict the choices */
4748         item_tester_hook = inven_carry_okay;
4749
4750         /* Get an object */
4751         q = _("どれを拾いますか?", "Get which item? ");
4752         s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
4753
4754         if (choose_object(&item, q, s, (USE_FLOOR)))
4755         {
4756                 this_o_idx = 0 - item;
4757         }
4758         else
4759         {
4760                 return (FALSE);
4761         }
4762
4763         /* Pick up the object */
4764         py_pickup_aux(this_o_idx);
4765
4766         return (TRUE);
4767 }
4768
4769 /*!
4770  * @brief 床上のアイテムを拾うメイン処理
4771  * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
4772  * @return なし
4773  * @details
4774  * This is called by py_pickup() when easy_floor is TRUE.
4775  */
4776 void py_pickup_floor(bool pickup)
4777 {
4778         OBJECT_IDX this_o_idx, next_o_idx = 0;
4779
4780         GAME_TEXT o_name[MAX_NLEN];
4781         object_type *o_ptr;
4782
4783         int floor_num = 0;
4784         OBJECT_IDX floor_o_idx = 0;
4785
4786         int can_pickup = 0;
4787
4788         /* Scan the pile of objects */
4789         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)
4790         {
4791                 /* Access the object */
4792                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
4793
4794                 object_desc(o_name, o_ptr, 0);
4795
4796                 /* Access the next object */
4797                 next_o_idx = o_ptr->next_o_idx;
4798
4799                 disturb(FALSE, FALSE);
4800
4801                 /* Pick up gold */
4802                 if (o_ptr->tval == TV_GOLD)
4803                 {
4804 #ifdef JP
4805                         msg_format(" $%ld の価値がある%sを見つけた。",
4806                                 (long)o_ptr->pval, o_name);
4807 #else
4808                         msg_format("You have found %ld gold pieces worth of %s.",
4809                                 (long)o_ptr->pval, o_name);
4810 #endif
4811
4812                         /* Collect the gold */
4813                         p_ptr->au += o_ptr->pval;
4814
4815                         /* Redraw gold */
4816                         p_ptr->redraw |= (PR_GOLD);
4817
4818                         p_ptr->window |= (PW_PLAYER);
4819
4820                         /* Delete the gold */
4821                         delete_object_idx(this_o_idx);
4822
4823                         /* Check the next object */
4824                         continue;
4825                 }
4826                 else if (o_ptr->marked & OM_NOMSG)
4827                 {
4828                         /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
4829                          * ignored. Otherwise, they are included in the prompt. */
4830                         o_ptr->marked &= ~(OM_NOMSG);
4831                         continue;
4832                 }
4833
4834                 /* Count non-gold objects that can be picked up. */
4835                 if (inven_carry_okay(o_ptr))
4836                 {
4837                         can_pickup++;
4838                 }
4839
4840                 /* Count non-gold objects */
4841                 floor_num++;
4842
4843                 /* Remember this index */
4844                 floor_o_idx = this_o_idx;
4845         }
4846
4847         /* There are no non-gold objects */
4848         if (!floor_num)
4849                 return;
4850
4851         /* Mention the number of objects */
4852         if (!pickup)
4853         {
4854                 /* One object */
4855                 if (floor_num == 1)
4856                 {
4857                         /* Access the object */
4858                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4859
4860 #ifdef ALLOW_EASY_SENSE
4861
4862                         /* Option: Make object sensing easy */
4863                         if (easy_sense)
4864                         {
4865                                 /* Sense the object */
4866                                 (void) sense_object(o_ptr);
4867                         }
4868
4869 #endif /* ALLOW_EASY_SENSE */
4870
4871                         object_desc(o_name, o_ptr, 0);
4872
4873                         msg_format(_("%sがある。", "You see %s."), o_name);
4874                 }
4875
4876                 /* Multiple objects */
4877                 else
4878                 {
4879                         msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
4880                 }
4881
4882                 return;
4883         }
4884
4885         /* The player has no room for anything on the floor. */
4886         if (!can_pickup)
4887         {
4888                 /* One object */
4889                 if (floor_num == 1)
4890                 {
4891                         /* Access the object */
4892                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4893
4894 #ifdef ALLOW_EASY_SENSE
4895
4896                         /* Option: Make object sensing easy */
4897                         if (easy_sense)
4898                         {
4899                                 /* Sense the object */
4900                                 (void) sense_object(o_ptr);
4901                         }
4902
4903 #endif /* ALLOW_EASY_SENSE */
4904
4905                         object_desc(o_name, o_ptr, 0);
4906
4907                         msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
4908                 }
4909
4910                 /* Multiple objects */
4911                 else
4912                 {
4913                         msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
4914
4915                 }
4916
4917                 return;
4918         }
4919
4920         /* One object */
4921         if (floor_num == 1)
4922         {
4923                 /* Hack -- query every object */
4924                 if (carry_query_flag)
4925                 {
4926                         char out_val[MAX_NLEN+20];
4927
4928                         /* Access the object */
4929                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4930
4931 #ifdef ALLOW_EASY_SENSE
4932
4933                         /* Option: Make object sensing easy */
4934                         if (easy_sense)
4935                         {
4936                                 /* Sense the object */
4937                                 (void) sense_object(o_ptr);
4938                         }
4939
4940 #endif /* ALLOW_EASY_SENSE */
4941
4942                         object_desc(o_name, o_ptr, 0);
4943
4944                         /* Build a prompt */
4945                         (void) sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
4946
4947                         /* Ask the user to confirm */
4948                         if (!get_check(out_val))
4949                         {
4950                                 return;
4951                         }
4952                 }
4953
4954                 /* Access the object */
4955                 o_ptr = &current_floor_ptr->o_list[floor_o_idx];
4956
4957 #ifdef ALLOW_EASY_SENSE
4958
4959                 /* Option: Make object sensing easy */
4960                 if (easy_sense)
4961                 {
4962                         /* Sense the object */
4963                         (void) sense_object(o_ptr);
4964                 }
4965
4966 #endif /* ALLOW_EASY_SENSE */
4967
4968                 /* Pick up the object */
4969                 py_pickup_aux(floor_o_idx);
4970         }
4971
4972         /* Allow the user to choose an object */
4973         else
4974         {
4975                 while (can_pickup--)
4976                 {
4977                         if (!py_pickup_floor_aux()) break;
4978                 }
4979         }
4980 }
4981
4982
4983 /*!
4984  * @brief 矢弾を射撃した場合の破損確率を返す /
4985  * Determines the odds of an object breaking when thrown at a monster
4986  * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
4987  * @return 破損確率(%)
4988  * @details
4989  * Note that artifacts never break, see the "drop_near()" function.
4990  */
4991 PERCENTAGE breakage_chance(object_type *o_ptr, SPELL_IDX snipe_type)
4992 {
4993         PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev - 1) / 7 + 4 : 0);
4994
4995         /* Examine the snipe type */
4996         if (snipe_type)
4997         {
4998                 if (snipe_type == SP_KILL_WALL) return (100);
4999                 if (snipe_type == SP_EXPLODE) return (100);
5000                 if (snipe_type == SP_PIERCE) return (100);
5001                 if (snipe_type == SP_FINAL) return (100);
5002                 if (snipe_type == SP_NEEDLE) return (100);
5003                 if (snipe_type == SP_EVILNESS) return (40);
5004                 if (snipe_type == SP_HOLYNESS) return (40);
5005         }
5006
5007         /* Examine the item type */
5008         switch (o_ptr->tval)
5009         {
5010                 /* Always break */
5011         case TV_FLASK:
5012         case TV_POTION:
5013         case TV_BOTTLE:
5014         case TV_FOOD:
5015         case TV_JUNK:
5016                 return (100);
5017
5018                 /* Often break */
5019         case TV_LITE:
5020         case TV_SCROLL:
5021         case TV_SKELETON:
5022                 return (50);
5023
5024                 /* Sometimes break */
5025         case TV_WAND:
5026         case TV_SPIKE:
5027                 return (25);
5028         case TV_ARROW:
5029                 return (20 - archer_bonus * 2);
5030
5031                 /* Rarely break */
5032         case TV_SHOT:
5033         case TV_BOLT:
5034                 return (10 - archer_bonus);
5035         default:
5036                 return (10);
5037         }
5038 }