OSDN Git Service

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