OSDN Git Service

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