OSDN Git Service

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