OSDN Git Service

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