OSDN Git Service

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