3 * @brief オブジェクトの実装 / Object code, part 1
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\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
20 #include "cmd-activate.h"
21 #include "objectkind.h"
22 #include "object-ego.h"
23 #include "object-flavor.h"
24 #include "object-hook.h"
25 #include "player-move.h"
30 #if defined(MACINTOSH) || defined(MACH_O_CARBON)
37 * @brief オブジェクト、地形の表示シンボルなど初期化する / Reset the "visual" lists
39 * This involves resetting various things to their "default" state.\n
41 * If the "prefs" flag is TRUE, then we will also load the appropriate\n
42 * "user pref file" based on the current setting of the "use_graphics"\n
43 * flag. This is useful for switching "graphics" on/off.\n
45 * The features, objects, and monsters, should all be encoded in the\n
46 * relevant "font.pref" and/or "graf.prf" files. \n
48 * The "prefs" parameter is no longer meaningful. \n
50 void reset_visuals(void)
54 /* Extract some info about terrain features */
55 for (i = 0; i < max_f_idx; i++)
57 feature_type *f_ptr = &f_info[i];
59 /* Assume we will use the underlying values */
60 for (j = 0; j < F_LIT_MAX; j++)
62 f_ptr->x_attr[j] = f_ptr->d_attr[j];
63 f_ptr->x_char[j] = f_ptr->d_char[j];
67 /* Extract default attr/char code for objects */
68 for (i = 0; i < max_k_idx; i++)
70 object_kind *k_ptr = &k_info[i];
72 /* Default attr/char */
73 k_ptr->x_attr = k_ptr->d_attr;
74 k_ptr->x_char = k_ptr->d_char;
77 /* Extract default attr/char code for monsters */
78 for (i = 0; i < max_r_idx; i++)
80 monster_race *r_ptr = &r_info[i];
82 /* Default attr/char */
83 r_ptr->x_attr = r_ptr->d_attr;
84 r_ptr->x_char = r_ptr->d_char;
91 /* Process "graf.prf" */
92 process_pref_file("graf.prf");
94 /* Access the "character" pref file */
95 sprintf(buf, "graf-%s.prf", p_ptr->base_name);
97 /* Process "graf-<playername>.prf" */
98 process_pref_file(buf);
106 /* Process "font.prf" */
107 process_pref_file("font.prf");
109 /* Access the "character" pref file */
110 sprintf(buf, "font-%s.prf", p_ptr->base_name);
112 /* Process "font-<playername>.prf" */
113 process_pref_file(buf);
118 * @brief オブジェクトのフラグ類を配列に与える
119 * Obtain the "flags" for an item
120 * @param o_ptr フラグ取得元のオブジェクト構造体ポインタ
121 * @param flgs フラグ情報を受け取る配列
124 void object_flags(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
126 object_kind *k_ptr = &k_info[o_ptr->k_idx];
130 for (i = 0; i < TR_FLAG_SIZE; i++)
131 flgs[i] = k_ptr->flags[i];
134 if (object_is_fixed_artifact(o_ptr))
136 artifact_type *a_ptr = &a_info[o_ptr->name1];
138 for (i = 0; i < TR_FLAG_SIZE; i++)
139 flgs[i] = a_ptr->flags[i];
143 if (object_is_ego(o_ptr))
145 ego_item_type *e_ptr = &e_info[o_ptr->name2];
147 for (i = 0; i < TR_FLAG_SIZE; i++)
148 flgs[i] |= e_ptr->flags[i];
150 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
152 remove_flag(flgs, TR_SH_FIRE);
154 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
156 remove_flag(flgs, TR_INFRA);
158 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
160 remove_flag(flgs, TR_RES_BLIND);
161 remove_flag(flgs, TR_SEE_INVIS);
165 /* Random artifact ! */
166 for (i = 0; i < TR_FLAG_SIZE; i++)
167 flgs[i] |= o_ptr->art_flags[i];
169 if (object_is_smith(o_ptr))
171 int add = o_ptr->xtra3 - 1;
173 if (add < TR_FLAG_MAX)
177 else if (add == ESSENCE_TMP_RES_ACID)
179 add_flag(flgs, TR_RES_ACID);
180 add_flag(flgs, TR_ACTIVATE);
182 else if (add == ESSENCE_TMP_RES_ELEC)
184 add_flag(flgs, TR_RES_ELEC);
185 add_flag(flgs, TR_ACTIVATE);
187 else if (add == ESSENCE_TMP_RES_FIRE)
189 add_flag(flgs, TR_RES_FIRE);
190 add_flag(flgs, TR_ACTIVATE);
192 else if (add == ESSENCE_TMP_RES_COLD)
194 add_flag(flgs, TR_RES_COLD);
195 add_flag(flgs, TR_ACTIVATE);
197 else if (add == ESSENCE_SH_FIRE)
199 add_flag(flgs, TR_RES_FIRE);
200 add_flag(flgs, TR_SH_FIRE);
202 else if (add == ESSENCE_SH_ELEC)
204 add_flag(flgs, TR_RES_ELEC);
205 add_flag(flgs, TR_SH_ELEC);
207 else if (add == ESSENCE_SH_COLD)
209 add_flag(flgs, TR_RES_COLD);
210 add_flag(flgs, TR_SH_COLD);
212 else if (add == ESSENCE_RESISTANCE)
214 add_flag(flgs, TR_RES_ACID);
215 add_flag(flgs, TR_RES_ELEC);
216 add_flag(flgs, TR_RES_FIRE);
217 add_flag(flgs, TR_RES_COLD);
219 else if (add == TR_IMPACT)
221 add_flag(flgs, TR_ACTIVATE);
227 * @brief オブジェクトの明示されているフラグ類を取得する
228 * Obtain the "flags" for an item which are known to the player
229 * @param o_ptr フラグ取得元のオブジェクト構造体ポインタ
230 * @param flgs フラグ情報を受け取る配列
233 void object_flags_known(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
238 object_kind *k_ptr = &k_info[o_ptr->k_idx];
241 for (i = 0; i < TR_FLAG_SIZE; i++)
244 if (!object_is_aware(o_ptr)) return;
247 for (i = 0; i < TR_FLAG_SIZE; i++)
248 flgs[i] = k_ptr->flags[i];
250 /* Must be identified */
251 if (!object_is_known(o_ptr)) return;
253 /* Ego-item (known basic flags) */
254 if (object_is_ego(o_ptr))
256 ego_item_type *e_ptr = &e_info[o_ptr->name2];
258 for (i = 0; i < TR_FLAG_SIZE; i++)
259 flgs[i] |= e_ptr->flags[i];
261 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
263 remove_flag(flgs, TR_SH_FIRE);
265 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
267 remove_flag(flgs, TR_INFRA);
269 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
271 remove_flag(flgs, TR_RES_BLIND);
272 remove_flag(flgs, TR_SEE_INVIS);
277 #ifdef SPOIL_ARTIFACTS
278 /* Full knowledge for some artifacts */
279 if (object_is_artifact(o_ptr)) spoil = TRUE;
280 #endif /* SPOIL_ARTIFACTS */
282 #ifdef SPOIL_EGO_ITEMS
283 /* Full knowledge for some ego-items */
284 if (object_is_ego(o_ptr)) spoil = TRUE;
285 #endif /* SPOIL_EGO_ITEMS */
287 /* Need full knowledge or spoilers */
288 if (spoil || (o_ptr->ident & IDENT_MENTAL))
291 if (object_is_fixed_artifact(o_ptr))
293 artifact_type *a_ptr = &a_info[o_ptr->name1];
295 for (i = 0; i < TR_FLAG_SIZE; i++)
296 flgs[i] = a_ptr->flags[i];
299 /* Random artifact ! */
300 for (i = 0; i < TR_FLAG_SIZE; i++)
301 flgs[i] |= o_ptr->art_flags[i];
304 if (object_is_smith(o_ptr))
306 int add = o_ptr->xtra3 - 1;
308 if (add < TR_FLAG_MAX)
312 else if (add == ESSENCE_TMP_RES_ACID)
314 add_flag(flgs, TR_RES_ACID);
316 else if (add == ESSENCE_TMP_RES_ELEC)
318 add_flag(flgs, TR_RES_ELEC);
320 else if (add == ESSENCE_TMP_RES_FIRE)
322 add_flag(flgs, TR_RES_FIRE);
324 else if (add == ESSENCE_TMP_RES_COLD)
326 add_flag(flgs, TR_RES_COLD);
328 else if (add == ESSENCE_SH_FIRE)
330 add_flag(flgs, TR_RES_FIRE);
331 add_flag(flgs, TR_SH_FIRE);
333 else if (add == ESSENCE_SH_ELEC)
335 add_flag(flgs, TR_RES_ELEC);
336 add_flag(flgs, TR_SH_ELEC);
338 else if (add == ESSENCE_SH_COLD)
340 add_flag(flgs, TR_RES_COLD);
341 add_flag(flgs, TR_SH_COLD);
343 else if (add == ESSENCE_RESISTANCE)
345 add_flag(flgs, TR_RES_ACID);
346 add_flag(flgs, TR_RES_ELEC);
347 add_flag(flgs, TR_RES_FIRE);
348 add_flag(flgs, TR_RES_COLD);
354 * @brief オブジェクトの発動効果名称を返す(サブルーチン/ブレス)
355 * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
356 * @return concptr 発動名称を返す文字列ポインタ
358 static concptr item_activation_dragon_breath(object_type *o_ptr)
360 static char desc[256];
361 BIT_FLAGS flgs[TR_FLAG_SIZE]; /* for resistance flags */
364 object_flags(o_ptr, flgs);
365 strcpy(desc, _("", "breath "));
367 for (i = 0; dragonbreath_info[i].flag != 0; i++)
369 if (have_flag(flgs, dragonbreath_info[i].flag))
371 if (n > 0) strcat(desc, _("、", ", "));
372 strcat(desc, dragonbreath_info[i].name);
377 strcat(desc, _("のブレス(250)", ""));
383 * @brief オブジェクトの発動効果名称を返す(サブルーチン/汎用)
384 * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
385 * @return concptr 発動名称を返す文字列ポインタ
387 static concptr item_activation_aux(object_type *o_ptr)
389 static char activation_detail[256];
393 const activation_type* const act_ptr = find_activation_info(o_ptr);
395 if (!act_ptr) return _("未定義", "something undefined");
397 desc = act_ptr->desc;
399 /* Overwrite description if it is special */
400 switch (act_ptr->index) {
402 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
403 desc = _("火炎のブレス (200) と火への耐性", "breath of fire (200) and resist fire");
406 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE))
407 desc = _("冷気のブレス (200) と冷気への耐性", "breath of cold (200) and resist cold");
410 desc = item_activation_dragon_breath(o_ptr);
413 if (o_ptr->name1 == ART_HYOUSIGI)
414 desc = _("拍子木を打ちならす", "beat wooden clappers");
416 case ACT_RESIST_ACID:
417 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ACID)) || (o_ptr->name2 == EGO_BRAND_ACID))
418 desc = _("アシッド・ボール (100) と酸への耐性", "ball of acid (100) and resist acid");
420 case ACT_RESIST_FIRE:
421 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) || (o_ptr->name2 == EGO_BRAND_FIRE))
422 desc = _("ファイア・ボール (100) と火への耐性", "ball of fire (100) and resist fire");
424 case ACT_RESIST_COLD:
425 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) || (o_ptr->name2 == EGO_BRAND_COLD))
426 desc = _("アイス・ボール (100) と冷気への耐性", "ball of cold (100) and resist cold");
428 case ACT_RESIST_ELEC:
429 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ELEC)) || (o_ptr->name2 == EGO_BRAND_ELEC))
430 desc = _("サンダー・ボール (100) と電撃への耐性", "ball of elec (100) and resist elec");
432 case ACT_RESIST_POIS:
433 if (o_ptr->name2 == EGO_BRAND_POIS)
434 desc = _("悪臭雲 (100) と毒への耐性", "ball of poison (100) and resist elec");
438 /* Timeout description */
439 constant = act_ptr->timeout.constant;
440 dice = act_ptr->timeout.dice;
441 if (constant == 0 && dice == 0) {
442 /* We can activate it every current_world_ptr->game_turn */
443 strcpy(timeout, _("いつでも", "every current_world_ptr->game_turn"));
444 } else if (constant < 0) {
445 /* Activations that have special timeout */
446 switch (act_ptr->index) {
448 sprintf(timeout, _("%d ターン毎", "every %d turns"),
449 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250);
452 sprintf(timeout, _("%d ターン毎", "every %d turns"),
453 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250);
456 strcpy(timeout, _("3*(レベル+10) ターン毎", "every 3 * (level+10) turns"));
459 strcpy(timeout, _("確率50%で壊れる", "(destroyed 50%)"));
462 strcpy(timeout, "undefined");
466 /* Normal timeout activations */
467 char constant_str[16], dice_str[16];
468 sprintf(constant_str, "%d", constant);
469 sprintf(dice_str, "d%d", dice);
470 sprintf(timeout, _("%s%s%s ターン毎", "every %s%s%s turns"),
471 (constant > 0) ? constant_str : "",
472 (constant > 0 && dice > 0) ? "+" : "",
473 (dice > 0) ? dice_str : "");
476 /* Build detail activate description */
477 sprintf(activation_detail, _("%s : %s", "%s %s"), desc, timeout);
479 return activation_detail;
483 * @brief オブジェクトの発動効果名称を返す(メインルーチン) /
484 * Determine the "Activation" (if any) for an artifact Return a string, or NULL for "no activation"
485 * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
486 * @return concptr 発動名称を返す文字列ポインタ
488 concptr item_activation(object_type *o_ptr)
490 BIT_FLAGS flgs[TR_FLAG_SIZE];
491 object_flags(o_ptr, flgs);
493 /* Require activation ability */
494 if (!(have_flag(flgs, TR_ACTIVATE))) return (_("なし", "nothing"));
496 /* Get an explain of an activation */
497 if (activation_index(o_ptr))
499 return item_activation_aux(o_ptr);
503 if (o_ptr->tval == TV_WHISTLE)
505 return _("ペット呼び寄せ : 100+d100ターン毎", "call pet every 100+d100 turns");
508 if (o_ptr->tval == TV_CAPTURE)
510 return _("モンスターを捕える、又は解放する。", "captures or releases a monster.");
513 return _("何も起きない", "Nothing");
518 * @brief オブジェクトの*鑑定*内容を詳述して表示する /
519 * Describe a "fully identified" item
520 * @param o_ptr *鑑定*情報を取得する元のオブジェクト構造体参照ポインタ
521 * @param mode 表示オプション
522 * @return 特筆すべき情報が一つでもあった場合TRUE、一つもなく表示がキャンセルされた場合FALSEを返す。
524 bool screen_object(object_type *o_ptr, BIT_FLAGS mode)
528 BIT_FLAGS flgs[TR_FLAG_SIZE];
532 GAME_TEXT o_name[MAX_NLEN];
537 int trivial_info = 0;
538 object_flags(o_ptr, flgs);
540 /* Extract the description */
542 roff_to_buf(o_ptr->name1 ? (a_text + a_info[o_ptr->name1].text) :
543 (k_text + k_info[o_ptr->k_idx].text),
544 77 - 15, temp, sizeof(temp));
545 for (j = 0; temp[j]; j += 1 + strlen(&temp[j]))
546 { info[i] = &temp[j]; i++;}
549 if (object_is_equipment(o_ptr))
551 /* Descriptions of a basic equipment is just a flavor */
555 /* Mega-Hack -- describe activation */
556 if (have_flag(flgs, TR_ACTIVATE))
558 info[i++] = _("始動したときの効果...", "It can be activated for...");
559 info[i++] = item_activation(o_ptr);
560 info[i++] = _("...ただし装備していなければならない。", "...if it is being worn.");
563 /* Figurines, a hack */
564 if (o_ptr->tval == TV_FIGURINE)
566 info[i++] = _("それは投げた時ペットに変化する。", "It will transform into a pet when thrown.");
569 /* Figurines, a hack */
570 if (o_ptr->name1 == ART_STONEMASK)
572 info[i++] = _("それを装備した者は吸血鬼になる。", "It makes you current_world_ptr->game_turn into a vampire permanently.");
575 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
577 info[i++] = _("それは相手を一撃で倒すことがある。", "It will attempt to kill a monster instantly.");
580 if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
582 info[i++] = _("それは自分自身に攻撃が返ってくることがある。", "It causes you to strike yourself sometimes.");
583 info[i++] = _("それは無敵のバリアを切り裂く。", "It always penetrates invulnerability barriers.");
586 if (o_ptr->name2 == EGO_2WEAPON)
588 info[i++] = _("それは二刀流での命中率を向上させる。", "It affects your ability to hit when you are wielding two weapons.");
591 if (have_flag(flgs, TR_EASY_SPELL))
593 info[i++] = _("それは魔法の難易度を下げる。", "It affects your ability to cast spells.");
596 if (o_ptr->name2 == EGO_AMU_FOOL)
598 info[i++] = _("それは魔法の難易度を上げる。", "It interferes with casting spells.");
601 if (o_ptr->name2 == EGO_RING_THROW)
603 info[i++] = _("それは物を強く投げることを可能にする。", "It provides great strength when you throw an item.");
606 if (o_ptr->name2 == EGO_AMU_NAIVETY)
608 info[i++] = _("それは魔法抵抗力を下げる。", "It decreases your magic resistance.");
611 if (o_ptr->tval == TV_STATUE)
613 monster_race *r_ptr = &r_info[o_ptr->pval];
615 if (o_ptr->pval == MON_BULLGATES)
616 info[i++] = _("それは部屋に飾ると恥ずかしい。", "It is shameful.");
617 else if ( r_ptr->flags2 & (RF2_ELDRITCH_HORROR))
618 info[i++] = _("それは部屋に飾ると恐い。", "It is fearful.");
620 info[i++] = _("それは部屋に飾ると楽しい。", "It is cheerful.");
623 /* Hack -- describe lite's */
625 if (o_ptr->name2 == EGO_LITE_DARKNESS) info[i++] = _("それは全く光らない。", "It provides no light.");
628 if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 1;
629 if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 2;
630 if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 3;
631 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
632 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
633 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
635 if(o_ptr->name2 == EGO_LITE_SHINE) rad++;
637 if (have_flag(flgs, TR_LITE_FUEL) && o_ptr->name2 != EGO_LITE_DARKNESS)
639 if(rad > 0) sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), (int)rad);
643 if(rad > 0) sprintf(desc, _("それは永遠なる明かり(半径 %d)を授ける。", "It provides light (radius %d) forever."), (int)rad);
644 if(rad < 0) sprintf(desc, _("それは明かりの半径を狭める(半径に-%d)。", "It decreases radius of light source by %d."), (int)-rad);
647 if(rad != 0) info[i++] = desc;
650 if (o_ptr->name2 == EGO_LITE_LONG)
652 info[i++] = _("それは長いターン明かりを授ける。", "It provides light for much longer time.");
655 /* And then describe it fully */
657 if (have_flag(flgs, TR_RIDING))
659 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
660 info[i++] = _("それは乗馬中は非常に使いやすい。", "It is made for use while riding.");
663 info[i++] = _("それは乗馬中でも使いやすい。", "It is suitable for use while riding.");
664 /* This information is not important enough */
668 if (have_flag(flgs, TR_STR))
670 info[i++] = _("それは腕力に影響を及ぼす。", "It affects your strength.");
672 if (have_flag(flgs, TR_INT))
674 info[i++] = _("それは知能に影響を及ぼす。", "It affects your intelligence.");
676 if (have_flag(flgs, TR_WIS))
678 info[i++] = _("それは賢さに影響を及ぼす。", "It affects your wisdom.");
680 if (have_flag(flgs, TR_DEX))
682 info[i++] = _("それは器用さに影響を及ぼす。", "It affects your dexterity.");
684 if (have_flag(flgs, TR_CON))
686 info[i++] = _("それは耐久力に影響を及ぼす。", "It affects your constitution.");
688 if (have_flag(flgs, TR_CHR))
690 info[i++] = _("それは魅力に影響を及ぼす。", "It affects your charisma.");
693 if (have_flag(flgs, TR_MAGIC_MASTERY))
695 info[i++] = _("それは魔法道具使用能力に影響を及ぼす。", "It affects your ability to use magic devices.");
698 if (have_flag(flgs, TR_STEALTH))
700 info[i++] = _("それは隠密行動能力に影響を及ぼす。", "It affects your stealth.");
702 if (have_flag(flgs, TR_SEARCH))
704 info[i++] = _("それは探索能力に影響を及ぼす。", "It affects your searching.");
706 if (have_flag(flgs, TR_INFRA))
708 info[i++] = _("それは赤外線視力に影響を及ぼす。", "It affects your infravision.");
710 if (have_flag(flgs, TR_TUNNEL))
712 info[i++] = _("それは採掘能力に影響を及ぼす。", "It affects your ability to tunnel.");
714 if (have_flag(flgs, TR_SPEED))
716 info[i++] = _("それはスピードに影響を及ぼす。", "It affects your speed.");
718 if (have_flag(flgs, TR_BLOWS))
720 info[i++] = _("それは打撃回数に影響を及ぼす。", "It affects your attack speed.");
723 if (have_flag(flgs, TR_BRAND_ACID))
725 info[i++] = _("それは酸によって大きなダメージを与える。", "It does extra damage from acid.");
727 if (have_flag(flgs, TR_BRAND_ELEC))
729 info[i++] = _("それは電撃によって大きなダメージを与える。", "It does extra damage from electricity.");
731 if (have_flag(flgs, TR_BRAND_FIRE))
733 info[i++] = _("それは火炎によって大きなダメージを与える。", "It does extra damage from fire.");
735 if (have_flag(flgs, TR_BRAND_COLD))
737 info[i++] = _("それは冷気によって大きなダメージを与える。", "It does extra damage from frost.");
740 if (have_flag(flgs, TR_BRAND_POIS))
742 info[i++] = _("それは敵を毒する。", "It poisons your foes.");
745 if (have_flag(flgs, TR_CHAOTIC))
747 info[i++] = _("それはカオス的な効果を及ぼす。", "It produces chaotic effects.");
750 if (have_flag(flgs, TR_VAMPIRIC))
752 info[i++] = _("それは敵から生命力を吸収する。", "It drains life from your foes.");
755 if (have_flag(flgs, TR_IMPACT))
757 info[i++] = _("それは地震を起こすことができる。", "It can cause earthquakes.");
760 if (have_flag(flgs, TR_VORPAL))
762 info[i++] = _("それは非常に切れ味が鋭く敵を切断することができる。", "It is very sharp and can cut your foes.");
765 if (have_flag(flgs, TR_KILL_DRAGON))
767 info[i++] = _("それはドラゴンにとっての天敵である。", "It is a great bane of dragons.");
769 else if (have_flag(flgs, TR_SLAY_DRAGON))
771 info[i++] = _("それはドラゴンに対して特に恐るべき力を発揮する。", "It is especially deadly against dragons.");
774 if (have_flag(flgs, TR_KILL_ORC))
776 info[i++] = _("それはオークにとっての天敵である。", "It is a great bane of orcs.");
778 if (have_flag(flgs, TR_SLAY_ORC))
780 info[i++] = _("それはオークに対して特に恐るべき力を発揮する。", "It is especially deadly against orcs.");
783 if (have_flag(flgs, TR_KILL_TROLL))
785 info[i++] = _("それはトロルにとっての天敵である。", "It is a great bane of trolls.");
787 if (have_flag(flgs, TR_SLAY_TROLL))
789 info[i++] = _("それはトロルに対して特に恐るべき力を発揮する。", "It is especially deadly against trolls.");
792 if (have_flag(flgs, TR_KILL_GIANT))
794 info[i++] = _("それは巨人にとっての天敵である。", "It is a great bane of giants.");
796 else if (have_flag(flgs, TR_SLAY_GIANT))
798 info[i++] = _("それはジャイアントに対して特に恐るべき力を発揮する。", "It is especially deadly against giants.");
801 if (have_flag(flgs, TR_KILL_DEMON))
803 info[i++] = _("それはデーモンにとっての天敵である。", "It is a great bane of demons.");
805 if (have_flag(flgs, TR_SLAY_DEMON))
807 info[i++] = _("それはデーモンに対して聖なる力を発揮する。", "It strikes at demons with holy wrath.");
810 if (have_flag(flgs, TR_KILL_UNDEAD))
812 info[i++] = _("それはアンデッドにとっての天敵である。", "It is a great bane of undead.");
814 if (have_flag(flgs, TR_SLAY_UNDEAD))
816 info[i++] = _("それはアンデッドに対して聖なる力を発揮する。", "It strikes at undead with holy wrath.");
819 if (have_flag(flgs, TR_KILL_EVIL))
821 info[i++] = _("それは邪悪なる存在にとっての天敵である。", "It is a great bane of evil monsters.");
823 if (have_flag(flgs, TR_SLAY_EVIL))
825 info[i++] = _("それは邪悪なる存在に対して聖なる力で攻撃する。", "It fights against evil with holy fury.");
828 if (have_flag(flgs, TR_KILL_ANIMAL))
830 info[i++] = _("それは自然界の動物にとっての天敵である。", "It is a great bane of natural creatures.");
832 if (have_flag(flgs, TR_SLAY_ANIMAL))
834 info[i++] = _("それは自然界の動物に対して特に恐るべき力を発揮する。", "It is especially deadly against natural creatures.");
837 if (have_flag(flgs, TR_KILL_HUMAN))
839 info[i++] = _("それは人間にとっての天敵である。", "It is a great bane of humans.");
841 if (have_flag(flgs, TR_SLAY_HUMAN))
843 info[i++] = _("それは人間に対して特に恐るべき力を発揮する。", "It is especially deadly against humans.");
846 if (have_flag(flgs, TR_FORCE_WEAPON))
848 info[i++] = _("それは使用者の魔力を使って攻撃する。", "It powerfully strikes at a monster using your mana.");
850 if (have_flag(flgs, TR_DEC_MANA))
852 info[i++] = _("それは魔力の消費を押さえる。", "It decreases your mana consumption.");
854 if (have_flag(flgs, TR_SUST_STR))
856 info[i++] = _("それはあなたの腕力を維持する。", "It sustains your strength.");
858 if (have_flag(flgs, TR_SUST_INT))
860 info[i++] = _("それはあなたの知能を維持する。", "It sustains your intelligence.");
862 if (have_flag(flgs, TR_SUST_WIS))
864 info[i++] = _("それはあなたの賢さを維持する。", "It sustains your wisdom.");
866 if (have_flag(flgs, TR_SUST_DEX))
868 info[i++] = _("それはあなたの器用さを維持する。", "It sustains your dexterity.");
870 if (have_flag(flgs, TR_SUST_CON))
872 info[i++] = _("それはあなたの耐久力を維持する。", "It sustains your constitution.");
874 if (have_flag(flgs, TR_SUST_CHR))
876 info[i++] = _("それはあなたの魅力を維持する。", "It sustains your charisma.");
879 if (have_flag(flgs, TR_IM_ACID))
881 info[i++] = _("それは酸に対する完全な免疫を授ける。", "It provides immunity to acid.");
883 if (have_flag(flgs, TR_IM_ELEC))
885 info[i++] = _("それは電撃に対する完全な免疫を授ける。", "It provides immunity to electricity.");
887 if (have_flag(flgs, TR_IM_FIRE))
889 info[i++] = _("それは火に対する完全な免疫を授ける。", "It provides immunity to fire.");
891 if (have_flag(flgs, TR_IM_COLD))
893 info[i++] = _("それは寒さに対する完全な免疫を授ける。", "It provides immunity to cold.");
896 if (have_flag(flgs, TR_THROW))
898 info[i++] = _("それは敵に投げて大きなダメージを与えることができる。", "It is perfectly balanced for throwing.");
901 if (have_flag(flgs, TR_FREE_ACT))
903 info[i++] = _("それは麻痺に対する完全な免疫を授ける。", "It provides immunity to paralysis.");
905 if (have_flag(flgs, TR_HOLD_EXP))
907 info[i++] = _("それは経験値吸収に対する耐性を授ける。", "It provides resistance to experience draining.");
909 if (have_flag(flgs, TR_RES_FEAR))
911 info[i++] = _("それは恐怖への完全な耐性を授ける。", "It makes you completely fearless.");
913 if (have_flag(flgs, TR_RES_ACID))
915 info[i++] = _("それは酸への耐性を授ける。", "It provides resistance to acid.");
917 if (have_flag(flgs, TR_RES_ELEC))
919 info[i++] = _("それは電撃への耐性を授ける。", "It provides resistance to electricity.");
921 if (have_flag(flgs, TR_RES_FIRE))
923 info[i++] = _("それは火への耐性を授ける。", "It provides resistance to fire.");
925 if (have_flag(flgs, TR_RES_COLD))
927 info[i++] = _("それは寒さへの耐性を授ける。", "It provides resistance to cold.");
929 if (have_flag(flgs, TR_RES_POIS))
931 info[i++] = _("それは毒への耐性を授ける。", "It provides resistance to poison.");
934 if (have_flag(flgs, TR_RES_LITE))
936 info[i++] = _("それは閃光への耐性を授ける。", "It provides resistance to light.");
938 if (have_flag(flgs, TR_RES_DARK))
940 info[i++] = _("それは暗黒への耐性を授ける。", "It provides resistance to dark.");
943 if (have_flag(flgs, TR_RES_BLIND))
945 info[i++] = _("それは盲目への耐性を授ける。", "It provides resistance to blindness.");
947 if (have_flag(flgs, TR_RES_CONF))
949 info[i++] = _("それは混乱への耐性を授ける。", "It provides resistance to confusion.");
951 if (have_flag(flgs, TR_RES_SOUND))
953 info[i++] = _("それは轟音への耐性を授ける。", "It provides resistance to sound.");
955 if (have_flag(flgs, TR_RES_SHARDS))
957 info[i++] = _("それは破片への耐性を授ける。", "It provides resistance to shards.");
960 if (have_flag(flgs, TR_RES_NETHER))
962 info[i++] = _("それは地獄への耐性を授ける。", "It provides resistance to nether.");
964 if (have_flag(flgs, TR_RES_NEXUS))
966 info[i++] = _("それは因果混乱への耐性を授ける。", "It provides resistance to nexus.");
968 if (have_flag(flgs, TR_RES_CHAOS))
970 info[i++] = _("それはカオスへの耐性を授ける。", "It provides resistance to chaos.");
972 if (have_flag(flgs, TR_RES_DISEN))
974 info[i++] = _("それは劣化への耐性を授ける。", "It provides resistance to disenchantment.");
977 if (have_flag(flgs, TR_LEVITATION))
979 info[i++] = _("それは宙に浮くことを可能にする。", "It allows you to levitate.");
982 if (have_flag(flgs, TR_SEE_INVIS))
984 info[i++] = _("それは透明なモンスターを見ることを可能にする。", "It allows you to see invisible monsters.");
986 if (have_flag(flgs, TR_TELEPATHY))
988 info[i++] = _("それはテレパシー能力を授ける。", "It gives telepathic powers.");
990 if (have_flag(flgs, TR_ESP_ANIMAL))
992 info[i++] = _("それは自然界の生物を感知する。", "It senses natural creatures.");
994 if (have_flag(flgs, TR_ESP_UNDEAD))
996 info[i++] = _("それはアンデッドを感知する。", "It senses undead.");
998 if (have_flag(flgs, TR_ESP_DEMON))
1000 info[i++] = _("それは悪魔を感知する。", "It senses demons.");
1002 if (have_flag(flgs, TR_ESP_ORC))
1004 info[i++] = _("それはオークを感知する。", "It senses orcs.");
1006 if (have_flag(flgs, TR_ESP_TROLL))
1008 info[i++] = _("それはトロルを感知する。", "It senses trolls.");
1010 if (have_flag(flgs, TR_ESP_GIANT))
1012 info[i++] = _("それは巨人を感知する。", "It senses giants.");
1014 if (have_flag(flgs, TR_ESP_DRAGON))
1016 info[i++] = _("それはドラゴンを感知する。", "It senses dragons.");
1018 if (have_flag(flgs, TR_ESP_HUMAN))
1020 info[i++] = _("それは人間を感知する。", "It senses humans.");
1022 if (have_flag(flgs, TR_ESP_EVIL))
1024 info[i++] = _("それは邪悪な存在を感知する。", "It senses evil creatures.");
1026 if (have_flag(flgs, TR_ESP_GOOD))
1028 info[i++] = _("それは善良な存在を感知する。", "It senses good creatures.");
1030 if (have_flag(flgs, TR_ESP_NONLIVING))
1032 info[i++] = _("それは活動する無生物体を感知する。", "It senses non-living creatures.");
1034 if (have_flag(flgs, TR_ESP_UNIQUE))
1036 info[i++] = _("それは特別な強敵を感知する。", "It senses unique monsters.");
1038 if (have_flag(flgs, TR_SLOW_DIGEST))
1040 info[i++] = _("それはあなたの新陳代謝を遅くする。", "It slows your metabolism.");
1042 if (have_flag(flgs, TR_REGEN))
1044 info[i++] = _("それは体力回復力を強化する。", "It speeds your regenerative powers.");
1046 if (have_flag(flgs, TR_WARNING))
1048 info[i++] = _("それは危険に対して警告を発する。", "It warns you of danger");
1050 if (have_flag(flgs, TR_REFLECT))
1052 info[i++] = _("それは矢の呪文を反射する。", "It reflects bolt spells.");
1054 if (have_flag(flgs, TR_SH_FIRE))
1056 info[i++] = _("それは炎のバリアを張る。", "It produces a fiery sheath.");
1058 if (have_flag(flgs, TR_SH_ELEC))
1060 info[i++] = _("それは電気のバリアを張る。", "It produces an electric sheath.");
1062 if (have_flag(flgs, TR_SH_COLD))
1064 info[i++] = _("それは冷気のバリアを張る。", "It produces a sheath of coldness.");
1066 if (have_flag(flgs, TR_NO_MAGIC))
1068 info[i++] = _("それは反魔法バリアを張る。", "It produces an anti-magic shell.");
1070 if (have_flag(flgs, TR_NO_TELE))
1072 info[i++] = _("それはテレポートを邪魔する。", "It prevents teleportation.");
1074 if (have_flag(flgs, TR_XTRA_MIGHT))
1076 info[i++] = _("それは矢/ボルト/弾をより強力に発射することができる。", "It fires missiles with extra might.");
1078 if (have_flag(flgs, TR_XTRA_SHOTS))
1080 info[i++] = _("それは矢/ボルト/弾を非常に早く発射することができる。", "It fires missiles excessively fast.");
1083 if (have_flag(flgs, TR_BLESSED))
1085 info[i++] = _("それは神に祝福されている。", "It has been blessed by the gods.");
1088 if (object_is_cursed(o_ptr))
1090 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1092 info[i++] = _("それは永遠の呪いがかけられている。", "It is permanently cursed.");
1094 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1096 info[i++] = _("それは強力な呪いがかけられている。", "It is heavily cursed.");
1100 info[i++] = _("それは呪われている。", "It is cursed.");
1103 * It's a trivial infomation since there is
1104 * fake inscription {cursed}
1110 if ((have_flag(flgs, TR_TY_CURSE)) || (o_ptr->curse_flags & TRC_TY_CURSE))
1112 info[i++] = _("それは太古の禍々しい怨念が宿っている。", "It carries an ancient foul curse.");
1114 if ((have_flag(flgs, TR_AGGRAVATE)) || (o_ptr->curse_flags & TRC_AGGRAVATE))
1116 info[i++] = _("それは付近のモンスターを怒らせる。", "It aggravates nearby creatures.");
1118 if ((have_flag(flgs, TR_DRAIN_EXP)) || (o_ptr->curse_flags & TRC_DRAIN_EXP))
1120 info[i++] = _("それは経験値を吸い取る。", "It drains experience.");
1122 if (o_ptr->curse_flags & TRC_SLOW_REGEN)
1124 info[i++] = _("それは回復力を弱める。", "It slows your regenerative powers.");
1126 if ((o_ptr->curse_flags & TRC_ADD_L_CURSE) || have_flag(flgs, TR_ADD_L_CURSE))
1128 info[i++] = _("それは弱い呪いを増やす。","It adds weak curses.");
1130 if ((o_ptr->curse_flags & TRC_ADD_H_CURSE) || have_flag(flgs, TR_ADD_H_CURSE))
1132 info[i++] = _("それは強力な呪いを増やす。","It adds heavy curses.");
1134 if ((have_flag(flgs, TR_CALL_ANIMAL)) || (o_ptr->curse_flags & TRC_CALL_ANIMAL))
1136 info[i++] = _("それは動物を呼び寄せる。", "It attracts animals.");
1138 if ((have_flag(flgs, TR_CALL_DEMON)) || (o_ptr->curse_flags & TRC_CALL_DEMON))
1140 info[i++] = _("それは悪魔を呼び寄せる。", "It attracts demons.");
1142 if ((have_flag(flgs, TR_CALL_DRAGON)) || (o_ptr->curse_flags & TRC_CALL_DRAGON))
1144 info[i++] = _("それはドラゴンを呼び寄せる。", "It attracts dragons.");
1146 if ((have_flag(flgs, TR_CALL_UNDEAD)) || (o_ptr->curse_flags & TRC_CALL_UNDEAD))
1148 info[i++] = _("それは死霊を呼び寄せる。", "It attracts undeads.");
1150 if ((have_flag(flgs, TR_COWARDICE)) || (o_ptr->curse_flags & TRC_COWARDICE))
1152 info[i++] = _("それは恐怖感を引き起こす。", "It makes you subject to cowardice.");
1154 if ((have_flag(flgs, TR_TELEPORT)) || (o_ptr->curse_flags & TRC_TELEPORT))
1156 info[i++] = _("それはランダムなテレポートを引き起こす。", "It induces random teleportation.");
1158 if ((have_flag(flgs, TR_LOW_MELEE)) || o_ptr->curse_flags & TRC_LOW_MELEE)
1160 info[i++] = _("それは攻撃を外しやすい。", "It causes you to miss blows.");
1162 if ((have_flag(flgs, TR_LOW_AC)) || (o_ptr->curse_flags & TRC_LOW_AC))
1164 info[i++] = _("それは攻撃を受けやすい。", "It helps your enemies' blows.");
1166 if ((have_flag(flgs, TR_LOW_MAGIC)) || (o_ptr->curse_flags & TRC_LOW_MAGIC))
1168 info[i++] = _("それは魔法を唱えにくくする。", "It encumbers you while spellcasting.");
1170 if ((have_flag(flgs, TR_FAST_DIGEST)) || (o_ptr->curse_flags & TRC_FAST_DIGEST))
1172 info[i++] = _("それはあなたの新陳代謝を速くする。", "It speeds your metabolism.");
1174 if ((have_flag(flgs, TR_DRAIN_HP)) || (o_ptr->curse_flags & TRC_DRAIN_HP))
1176 info[i++] = _("それはあなたの体力を吸い取る。", "It drains you.");
1178 if ((have_flag(flgs, TR_DRAIN_MANA)) || (o_ptr->curse_flags & TRC_DRAIN_MANA))
1180 info[i++] = _("それはあなたの魔力を吸い取る。", "It drains your mana.");
1183 /* Describe about this kind of object instead of THIS fake object */
1184 if (mode & SCROBJ_FAKE_OBJECT)
1186 switch (o_ptr->tval)
1189 switch (o_ptr->sval)
1191 case SV_RING_LORDLY:
1192 info[i++] = _("それは幾つかのランダムな耐性を授ける。", "It provides some random resistances.");
1194 case SV_RING_WARNING:
1195 info[i++] = _("それはひとつの低級なESPを授ける事がある。", "It may provide a low rank ESP.");
1201 switch (o_ptr->sval)
1203 case SV_AMULET_RESISTANCE:
1204 info[i++] = _("それは毒への耐性を授ける事がある。", "It may provides resistance to poison.");
1205 info[i++] = _("それはランダムな耐性を授ける事がある。", "It may provide a random resistances.");
1207 case SV_AMULET_THE_MAGI:
1208 info[i++] = _("それは最大で3つまでの低級なESPを授ける。", "It provides up to three low rank ESPs.");
1215 if (have_flag(flgs, TR_IGNORE_ACID) &&
1216 have_flag(flgs, TR_IGNORE_ELEC) &&
1217 have_flag(flgs, TR_IGNORE_FIRE) &&
1218 have_flag(flgs, TR_IGNORE_COLD))
1220 info[i++] = _("それは酸・電撃・火炎・冷気では傷つかない。", "It cannot be harmed by the elements.");
1224 if (have_flag(flgs, TR_IGNORE_ACID))
1226 info[i++] = _("それは酸では傷つかない。", "It cannot be harmed by acid.");
1228 if (have_flag(flgs, TR_IGNORE_ELEC))
1230 info[i++] = _("それは電撃では傷つかない。", "It cannot be harmed by electricity.");
1232 if (have_flag(flgs, TR_IGNORE_FIRE))
1234 info[i++] = _("それは火炎では傷つかない。", "It cannot be harmed by fire.");
1236 if (have_flag(flgs, TR_IGNORE_COLD))
1238 info[i++] = _("それは冷気では傷つかない。", "It cannot be harmed by cold.");
1242 if (mode & SCROBJ_FORCE_DETAIL) trivial_info = 0;
1244 /* No relevant informations */
1245 if (i <= trivial_info) return (FALSE);
1248 Term_get_size(&wid, &hgt);
1250 /* Display Item name */
1251 if (!(mode & SCROBJ_FAKE_OBJECT))
1252 object_desc(o_name, o_ptr, 0);
1254 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1258 /* Erase the screen */
1259 for (k = 1; k < hgt; k++) prt("", k, 13);
1261 /* Label the information */
1262 if ((o_ptr->tval == TV_STATUE) && (o_ptr->sval == SV_PHOTO))
1264 monster_race *r_ptr = &r_info[o_ptr->pval];
1265 int namelen = strlen(r_name + r_ptr->name);
1266 prt(format("%s: '", r_name + r_ptr->name), 1, 15);
1267 Term_queue_bigchar(18 + namelen, 1, r_ptr->x_attr, r_ptr->x_char, 0, 0);
1268 prt("'", 1, (use_bigtile ? 20 : 19) + namelen);
1272 prt(_(" アイテムの能力:", " Item Attributes:"), 1, 15);
1275 /* We will print on top of the map (column 13) */
1276 for (k = 2, j = 0; j < i; j++)
1279 prt(info[j], k++, 15);
1281 /* Every 20 entries (lines 2 to 21), start over */
1282 if ((k == hgt - 2) && (j+1 < i))
1284 prt(_("-- 続く --", "-- more --"), k, 15);
1286 for (; k > 2; k--) prt("", k, 15);
1291 prt(_("[何かキーを押すとゲームに戻ります]", "[Press any key to continue]"), k, 15);
1296 /* Gave knowledge */
1303 * @brief オブジェクト選択時の選択アルファベットラベルを返す /
1304 * Convert an p_ptr->inventory_list index into a one character label
1305 * @param i プレイヤーの所持/装備オブジェクトID
1306 * @return 対応するアルファベット
1307 * @details Note that the label does NOT distinguish inven/equip.
1309 char index_to_label(int i)
1311 /* Indexes for "inven" are easy */
1312 if (i < INVEN_RARM) return (I2A(i));
1314 /* Indexes for "equip" are offset */
1315 return (I2A(i - INVEN_RARM));
1319 * @brief 選択アルファベットラベルからプレイヤーの所持オブジェクトIDを返す /
1320 * Convert a label into the index of an item in the "inven"
1321 * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1322 * @details Note that the label does NOT distinguish inven/equip.
1324 INVENTORY_IDX label_to_inven(int c)
1329 i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1);
1331 /* Verify the index */
1332 if ((i < 0) || (i > INVEN_PACK)) return (-1);
1334 /* Empty slots can never be chosen */
1335 if (!p_ptr->inventory_list[i].k_idx) return (-1);
1337 /* Return the index */
1343 extern bool select_ring_slot;
1347 * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
1348 * @param i プレイヤーの所持/装備オブジェクトID
1349 * @return 指輪枠ならばTRUEを返す。
1351 static bool is_ring_slot(int i)
1353 return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
1358 * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
1359 * Convert a label into the index of a item in the "equip"
1360 * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1362 INVENTORY_IDX label_to_equip(int c)
1367 i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
1369 /* Verify the index */
1370 if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
1372 if (select_ring_slot) return is_ring_slot(i) ? i : -1;
1374 /* Empty slots can never be chosen */
1375 if (!p_ptr->inventory_list[i].k_idx) return (-1);
1377 /* Return the index */
1384 * @brief オブジェクトの該当装備部位IDを返す /
1385 * Determine which equipment slot (if any) an item likes
1386 * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
1387 * @return 対応する装備部位ID
1389 s16b wield_slot(object_type *o_ptr)
1391 /* Slot for equipment */
1392 switch (o_ptr->tval)
1399 if (!p_ptr->inventory_list[INVEN_RARM].k_idx) return (INVEN_RARM);
1400 if (p_ptr->inventory_list[INVEN_LARM].k_idx) return (INVEN_RARM);
1401 return (INVEN_LARM);
1408 if (!p_ptr->inventory_list[INVEN_LARM].k_idx) return (INVEN_LARM);
1409 if (p_ptr->inventory_list[INVEN_RARM].k_idx) return (INVEN_LARM);
1410 return (INVEN_RARM);
1420 /* Use the right hand first */
1421 if (!p_ptr->inventory_list[INVEN_RIGHT].k_idx) return (INVEN_RIGHT);
1423 /* Use the left hand for swapping (by default) */
1424 return (INVEN_LEFT);
1430 return (INVEN_NECK);
1435 return (INVEN_LITE);
1442 return (INVEN_BODY);
1447 return (INVEN_OUTER);
1453 return (INVEN_HEAD);
1458 return (INVEN_HANDS);
1463 return (INVEN_FEET);
1467 /* No slot available */
1472 * @brief 所持/装備オブジェクトIDの部位表現を返す /
1473 * Return a string mentioning how a given item is carried
1474 * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
1475 * @return 部位表現の文字列ポインタ
1477 concptr mention_use(int i)
1481 /* Examine the location */
1485 case INVEN_RARM: p = p_ptr->heavy_wield[0] ? "運搬中" : ((p_ptr->ryoute && p_ptr->migite) ? " 両手" : (left_hander ? " 左手" : " 右手")); break;
1487 case INVEN_RARM: p = p_ptr->heavy_wield[0] ? "Just lifting" : (p_ptr->migite ? "Wielding" : "On arm"); break;
1491 case INVEN_LARM: p = p_ptr->heavy_wield[1] ? "運搬中" : ((p_ptr->ryoute && p_ptr->hidarite) ? " 両手" : (left_hander ? " 右手" : " 左手")); break;
1493 case INVEN_LARM: p = p_ptr->heavy_wield[1] ? "Just lifting" : (p_ptr->hidarite ? "Wielding" : "On arm"); break;
1496 case INVEN_BOW: p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < p_ptr->inventory_list[i].weight / 10) ? _("運搬中", "Just holding") : _("射撃用", "Shooting"); break;
1497 case INVEN_RIGHT: p = (left_hander ? _("左手指", "On left hand") : _("右手指", "On right hand")); break;
1498 case INVEN_LEFT: p = (left_hander ? _("右手指", "On right hand") : _("左手指", "On left hand")); break;
1499 case INVEN_NECK: p = _(" 首", "Around neck"); break;
1500 case INVEN_LITE: p = _(" 光源", "Light source"); break;
1501 case INVEN_BODY: p = _(" 体", "On body"); break;
1502 case INVEN_OUTER: p = _("体の上", "About body"); break;
1503 case INVEN_HEAD: p = _(" 頭", "On head"); break;
1504 case INVEN_HANDS: p = _(" 手", "On hands"); break;
1505 case INVEN_FEET: p = _(" 足", "On feet"); break;
1506 default: p = _("ザック", "In pack"); break;
1509 /* Return the result */
1515 * @brief 所持/装備オブジェクトIDの現在の扱い方の状態表現を返す /
1516 * Return a string describing how a given item is being worn.
1517 * @param i 状態表現を求めるプレイヤーの所持/装備オブジェクトID
1518 * @return 状態表現内容の文字列ポインタ
1520 * Currently, only used for items in the equipment, not p_ptr->inventory_list.
1522 concptr describe_use(int i)
1529 case INVEN_RARM: p = p_ptr->heavy_wield[0] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->migite) ? "両手に装備している" : (left_hander ? "左手に装備している" : "右手に装備している")); break;
1531 case INVEN_RARM: p = p_ptr->heavy_wield[0] ? "just lifting" : (p_ptr->migite ? "attacking monsters with" : "wearing on your arm"); break;
1535 case INVEN_LARM: p = p_ptr->heavy_wield[1] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->hidarite) ? "両手に装備している" : (left_hander ? "右手に装備している" : "左手に装備している")); break;
1537 case INVEN_LARM: p = p_ptr->heavy_wield[1] ? "just lifting" : (p_ptr->hidarite ? "attacking monsters with" : "wearing on your arm"); break;
1540 case INVEN_BOW: p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < p_ptr->inventory_list[i].weight / 10) ? _("持つだけで精一杯の", "just holding") : _("射撃用に装備している", "shooting missiles with"); break;
1541 case INVEN_RIGHT: p = (left_hander ? _("左手の指にはめている", "wearing on your left hand") : _("右手の指にはめている", "wearing on your right hand")); break;
1542 case INVEN_LEFT: p = (left_hander ? _("右手の指にはめている", "wearing on your right hand") : _("左手の指にはめている", "wearing on your left hand")); break;
1543 case INVEN_NECK: p = _("首にかけている", "wearing around your neck"); break;
1544 case INVEN_LITE: p = _("光源にしている", "using to light the way"); break;
1545 case INVEN_BODY: p = _("体に着ている", "wearing on your body"); break;
1546 case INVEN_OUTER: p = _("身にまとっている", "wearing on your back"); break;
1547 case INVEN_HEAD: p = _("頭にかぶっている", "wearing on your head"); break;
1548 case INVEN_HANDS: p = _("手につけている", "wearing on your hands"); break;
1549 case INVEN_FEET: p = _("足にはいている", "wearing on your feet"); break;
1550 default: p = _("ザックに入っている", "carrying in your pack"); break;
1553 /* Return the result */
1559 * @brief tval/sval指定のベースアイテムがプレイヤーの使用可能な魔法書かどうかを返す /
1560 * Hack: Check if a spellbook is one of the realms we can use. -- TY
1561 * @param book_tval ベースアイテムのtval
1562 * @param book_sval ベースアイテムのsval
1563 * @return 使用可能な魔法書ならばTRUEを返す。
1566 bool check_book_realm(const OBJECT_TYPE_VALUE book_tval, const OBJECT_SUBTYPE_VALUE book_sval)
1568 if (book_tval < TV_LIFE_BOOK) return FALSE;
1569 if (p_ptr->pclass == CLASS_SORCERER)
1571 return is_magic(tval2realm(book_tval));
1573 else if (p_ptr->pclass == CLASS_RED_MAGE)
1575 if (is_magic(tval2realm(book_tval)))
1576 return ((book_tval == TV_ARCANE_BOOK) || (book_sval < 2));
1578 return (REALM1_BOOK == book_tval || REALM2_BOOK == book_tval);
1582 * Here is a "hook" used during calls to "get_item()" and
1583 * "show_inven()" and "show_equip()", and the choice window routines.
1585 bool(*item_tester_hook)(object_type*);
1588 * Here is a "pseudo-hook" used during calls to "get_item()" and
1589 * "show_inven()" and "show_equip()", and the choice window routines.
1591 OBJECT_TYPE_VALUE item_tester_tval;
1594 * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
1595 * Check an item against the item tester info
1596 * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
1597 * @return item_tester_hookの参照先、その他いくつかの例外に応じてTRUE/FALSEを返す。
1599 bool item_tester_okay(object_type *o_ptr)
1601 /* Hack -- allow listing empty slots */
1602 // if (item_tester_full) return (TRUE); // TODO:DELETE
1604 /* Require an item */
1605 if (!o_ptr->k_idx) return (FALSE);
1607 /* Hack -- ignore "gold" */
1608 if (o_ptr->tval == TV_GOLD)
1611 extern bool show_gold_on_floor;
1613 if (!show_gold_on_floor) return (FALSE);
1616 /* Check the tval */
1617 if (item_tester_tval)
1619 /* Is it a spellbook? If so, we need a hack -- TY */
1620 if ((item_tester_tval <= TV_DEATH_BOOK) &&
1621 (item_tester_tval >= TV_LIFE_BOOK))
1622 return check_book_realm(o_ptr->tval, o_ptr->sval);
1624 if (item_tester_tval != o_ptr->tval) return (FALSE);
1627 /* Check the hook */
1628 if (item_tester_hook)
1630 if (!(*item_tester_hook)(o_ptr)) return (FALSE);
1639 * @brief 所持アイテム一覧を表示する /
1640 * Choice window "shadow" of the "show_inven()" function
1643 void display_inven(void)
1645 register int i, n, z = 0;
1647 TERM_COLOR attr = TERM_WHITE;
1649 GAME_TEXT o_name[MAX_NLEN];
1652 Term_get_size(&wid, &hgt);
1654 for (i = 0; i < INVEN_PACK; i++)
1656 o_ptr = &p_ptr->inventory_list[i];
1657 if (!o_ptr->k_idx) continue;
1661 for (i = 0; i < z; i++)
1663 o_ptr = &p_ptr->inventory_list[i];
1664 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1665 if (item_tester_okay(o_ptr))
1667 tmp_val[0] = index_to_label(i);
1671 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
1672 object_desc(o_name, o_ptr, 0);
1674 attr = tval_to_attr[o_ptr->tval % 128];
1680 Term_putstr(3, i, n, attr, o_name);
1681 Term_erase(3+n, i, 255);
1685 int wgt = o_ptr->weight * o_ptr->number;
1687 sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
1689 sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1691 prt(tmp_val, i, wid - 9);
1695 for (i = z; i < hgt; i++)
1697 Term_erase(0, i, 255);
1704 * @brief 装備アイテム一覧を表示する /
1705 * Choice window "shadow" of the "show_equip()" function
1708 void display_equip(void)
1712 TERM_COLOR attr = TERM_WHITE;
1714 GAME_TEXT o_name[MAX_NLEN];
1717 Term_get_size(&wid, &hgt);
1719 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1721 o_ptr = &p_ptr->inventory_list[i];
1722 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1723 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
1725 tmp_val[0] = index_to_label(i);
1729 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
1730 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
1732 strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
1737 object_desc(o_name, o_ptr, 0);
1738 attr = tval_to_attr[o_ptr->tval % 128];
1746 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
1748 Term_erase(3 + n, i - INVEN_RARM, 255);
1752 int wgt = o_ptr->weight * o_ptr->number;
1754 sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
1756 sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1759 prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
1764 Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
1765 prt(mention_use(i), i - INVEN_RARM, wid - 15);
1769 for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
1771 Term_erase(0, i, 255);
1777 * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1778 * Find the "first" p_ptr->inventory_list object with the given "tag".
1779 * @param cp 対応するタグIDを与える参照ポインタ
1780 * @param tag 該当するオブジェクトがあるかを調べたいタグ
1781 * @param mode 所持、装備の切り替え
1782 * @return タグに該当するオブジェクトがあるならTRUEを返す
1784 * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1785 * inscription of an object. Alphabetical characters don't work as a\n
1786 * tag in this form.\n
1788 * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1789 * and "x" is the "current" command_cmd code.\n
1791 static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
1794 COMMAND_CODE start, end;
1797 /* Extract index from mode */
1802 end = INVEN_TOTAL - 1;
1807 end = INVEN_PACK - 1;
1814 /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1816 /* Check every p_ptr->inventory_list object */
1817 for (i = start; i <= end; i++)
1819 object_type *o_ptr = &p_ptr->inventory_list[i];
1820 if (!o_ptr->k_idx) continue;
1822 /* Skip empty inscriptions */
1823 if (!o_ptr->inscription) continue;
1825 /* Skip non-choice */
1826 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1829 s = my_strchr(quark_str(o_ptr->inscription), '@');
1831 /* Process all tags */
1834 /* Check the special tags */
1835 if ((s[1] == command_cmd) && (s[2] == tag))
1837 /* Save the actual p_ptr->inventory_list ID */
1844 /* Find another '@' */
1845 s = my_strchr(s + 1, '@');
1850 /**** Find a tag in the form of {@#} (allows only numerals) ***/
1852 /* Don't allow {@#} with '#' being alphabet */
1853 if (tag < '0' || '9' < tag)
1859 /* Check every object */
1860 for (i = start; i <= end; i++)
1862 object_type *o_ptr = &p_ptr->inventory_list[i];
1863 if (!o_ptr->k_idx) continue;
1865 /* Skip empty inscriptions */
1866 if (!o_ptr->inscription) continue;
1868 /* Skip non-choice */
1869 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
1872 s = my_strchr(quark_str(o_ptr->inscription), '@');
1874 /* Process all tags */
1877 /* Check the normal tags */
1880 /* Save the actual p_ptr->inventory_list ID */
1887 /* Find another '@' */
1888 s = my_strchr(s + 1, '@');
1898 * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1899 * Find the "first" p_ptr->inventory_list object with the given "tag".
1900 * @param cp 対応するタグIDを与える参照ポインタ
1901 * @param tag 該当するオブジェクトがあるかを調べたいタグ
1902 * @param floor_list 床上アイテムの配列
1903 * @param floor_num 床上アイテムの配列ID
1904 * @return タグに該当するオブジェクトがあるならTRUEを返す
1906 * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1907 * inscription of an object. Alphabetical characters don't work as a\n
1908 * tag in this form.\n
1910 * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1911 * and "x" is the "current" command_cmd code.\n
1913 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
1918 /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1920 /* Check every object in the grid */
1921 for (i = 0; i < floor_num && i < 23; i++)
1923 object_type *o_ptr = ¤t_floor_ptr->o_list[floor_list[i]];
1925 /* Skip empty inscriptions */
1926 if (!o_ptr->inscription) continue;
1929 s = my_strchr(quark_str(o_ptr->inscription), '@');
1931 /* Process all tags */
1934 /* Check the special tags */
1935 if ((s[1] == command_cmd) && (s[2] == tag))
1937 /* Save the actual floor object ID */
1944 /* Find another '@' */
1945 s = my_strchr(s + 1, '@');
1950 /**** Find a tag in the form of {@#} (allows only numerals) ***/
1952 /* Don't allow {@#} with '#' being alphabet */
1953 if (tag < '0' || '9' < tag)
1959 /* Check every object in the grid */
1960 for (i = 0; i < floor_num && i < 23; i++)
1962 object_type *o_ptr = ¤t_floor_ptr->o_list[floor_list[i]];
1964 /* Skip empty inscriptions */
1965 if (!o_ptr->inscription) continue;
1968 s = my_strchr(quark_str(o_ptr->inscription), '@');
1970 /* Process all tags */
1973 /* Check the normal tags */
1976 /* Save the floor object ID */
1983 /* Find another '@' */
1984 s = my_strchr(s + 1, '@');
1994 * @brief タグIDにあわせてタグアルファベットのリストを返す /
1995 * Move around label characters with correspond tags
1996 * @param label ラベルリストを取得する文字列参照ポインタ
1997 * @param mode 所持品リストか装備品リストかの切り替え
2000 static void prepare_label_string(char *label, BIT_FLAGS mode)
2002 concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2003 int offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
2006 /* Prepare normal labels */
2007 strcpy(label, alphabet_chars);
2009 /* Move each label */
2010 for (i = 0; i < 52; i++)
2013 SYMBOL_CODE c = alphabet_chars[i];
2015 /* Find a tag with this label */
2016 if (get_tag(&index, c, mode))
2018 /* Delete the overwritten label */
2019 if (label[i] == c) label[i] = ' ';
2021 /* Move the label to the place of corresponding tag */
2022 label[index - offset] = c;
2029 * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
2030 * Move around label characters with correspond tags (floor version)
2031 * @param label ラベルリストを取得する文字列参照ポインタ
2032 * @param floor_list 床上アイテムの配列
2033 * @param floor_num 床上アイテムの配列ID
2038 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
2040 concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2043 /* Prepare normal labels */
2044 strcpy(label, alphabet_chars);
2046 /* Move each label */
2047 for (i = 0; i < 52; i++)
2050 SYMBOL_CODE c = alphabet_chars[i];
2052 /* Find a tag with this label */
2053 if (get_tag_floor(&index, c, floor_list, floor_num))
2055 /* Delete the overwritten label */
2056 if (label[i] == c) label[i] = ' ';
2058 /* Move the label to the place of corresponding tag */
2066 * @brief 所持アイテムの表示を行う /
2067 * Display the p_ptr->inventory_list.
2068 * @param target_item アイテムの選択処理を行うか否か。
2069 * @return 選択したアイテムのタグ
2071 * Hack -- do not display "trailing" empty slots
2073 COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
2077 int col, cur_col, len;
2079 GAME_TEXT o_name[MAX_NLEN];
2081 COMMAND_CODE out_index[23];
2082 TERM_COLOR out_color[23];
2083 char out_desc[23][MAX_NLEN];
2084 COMMAND_CODE target_item_label = 0;
2086 char inven_label[52 + 1];
2088 /* Starting column */
2091 Term_get_size(&wid, &hgt);
2093 /* Default "max-length" */
2094 len = wid - col - 1;
2097 /* Find the "final" slot */
2098 for (i = 0; i < INVEN_PACK; i++)
2100 o_ptr = &p_ptr->inventory_list[i];
2101 if (!o_ptr->k_idx) continue;
2107 prepare_label_string(inven_label, USE_INVEN);
2109 /* Display the p_ptr->inventory_list */
2110 for (k = 0, i = 0; i < z; i++)
2112 o_ptr = &p_ptr->inventory_list[i];
2114 /* Is this item acceptable? */
2115 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
2117 object_desc(o_name, o_ptr, 0);
2119 /* Save the object index, color, and description */
2121 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2123 /* Grey out charging items */
2126 out_color[k] = TERM_L_DARK;
2129 (void)strcpy(out_desc[k], o_name);
2131 /* Find the predicted "line length" */
2132 l = strlen(out_desc[k]) + 5;
2134 /* Be sure to account for the weight */
2135 if (show_weights) l += 9;
2137 /* Account for icon if displayed */
2138 if (show_item_graph)
2141 if (use_bigtile) l++;
2144 /* Maintain the maximum length */
2145 if (l > len) len = l;
2147 /* Advance to next "line" */
2151 /* Find the column to start in */
2152 col = (len > wid - 4) ? 0 : (wid - len - 1);
2154 /* Output each entry */
2155 for (j = 0; j < k; j++)
2158 o_ptr = &p_ptr->inventory_list[i];
2160 /* Clear the line */
2161 prt("", j + 1, col ? col - 2 : col);
2163 if (use_menu && target_item)
2165 if (j == (target_item-1))
2167 strcpy(tmp_val, _("》", "> "));
2168 target_item_label = i;
2170 else strcpy(tmp_val, " ");
2172 else if (i <= INVEN_PACK)
2174 /* Prepare an index --(-- */
2175 sprintf(tmp_val, "%c)", inven_label[i]);
2179 /* Prepare an index --(-- */
2180 sprintf(tmp_val, "%c)", index_to_label(i));
2183 /* Clear the line with the (possibly indented) index */
2184 put_str(tmp_val, j + 1, col);
2188 /* Display graphics for object, if desired */
2189 if (show_item_graph)
2191 TERM_COLOR a = object_attr(o_ptr);
2192 SYMBOL_CODE c = object_char(o_ptr);
2193 Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2194 if (use_bigtile) cur_col++;
2200 /* Display the entry itself */
2201 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2203 /* Display the weight if needed */
2206 int wgt = o_ptr->weight * o_ptr->number;
2208 (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2210 (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2213 prt(tmp_val, j + 1, wid - 9);
2217 /* Make a "shadow" below the list (only if needed) */
2218 if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2220 /* Save the new column */
2223 return target_item_label;
2228 * @brief 装備アイテムの表示を行う /
2229 * Display the equipment.
2230 * @param target_item アイテムの選択処理を行うか否か。
2231 * @return 選択したアイテムのタグ
2233 COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
2237 int col, cur_col, len;
2240 GAME_TEXT o_name[MAX_NLEN];
2241 COMMAND_CODE out_index[23];
2242 TERM_COLOR out_color[23];
2243 char out_desc[23][MAX_NLEN];
2244 COMMAND_CODE target_item_label = 0;
2246 char equip_label[52 + 1];
2248 /* Starting column */
2251 Term_get_size(&wid, &hgt);
2253 /* Maximal length */
2254 len = wid - col - 1;
2257 /* Scan the equipment list */
2258 for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2260 o_ptr = &p_ptr->inventory_list[i];
2262 /* Is this item acceptable? */
2263 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr) || (mode & USE_FULL)) &&
2264 (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2265 (mode & IGNORE_BOTHHAND_SLOT))) continue;
2267 object_desc(o_name, o_ptr, 0);
2269 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2271 (void)strcpy(out_desc[k],_("(武器を両手持ち)", "(wielding with two-hands)"));
2272 out_color[k] = TERM_WHITE;
2276 (void)strcpy(out_desc[k], o_name);
2277 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2281 /* Grey out charging items */
2284 out_color[k] = TERM_L_DARK;
2287 /* Extract the maximal length (see below) */
2289 l = strlen(out_desc[k]) + (2 + 1);
2291 l = strlen(out_desc[k]) + (2 + 3);
2295 /* Increase length for labels (if needed) */
2297 if (show_labels) l += (7 + 2);
2299 if (show_labels) l += (14 + 2);
2303 /* Increase length for weight (if needed) */
2304 if (show_weights) l += 9;
2306 if (show_item_graph) l += 2;
2308 /* Maintain the max-length */
2309 if (l > len) len = l;
2311 /* Advance the entry */
2315 /* Hack -- Find a column to start in */
2317 col = (len > wid - 6) ? 0 : (wid - len - 1);
2319 col = (len > wid - 4) ? 0 : (wid - len - 1);
2322 prepare_label_string(equip_label, USE_EQUIP);
2324 /* Output each entry */
2325 for (j = 0; j < k; j++)
2328 o_ptr = &p_ptr->inventory_list[i];
2330 /* Clear the line */
2331 prt("", j + 1, col ? col - 2 : col);
2333 if (use_menu && target_item)
2335 if (j == (target_item-1))
2337 strcpy(tmp_val, _("》", "> "));
2338 target_item_label = i;
2340 else strcpy(tmp_val, " ");
2342 else if (i >= INVEN_RARM)
2344 /* Prepare an index --(-- */
2345 sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
2349 /* Prepare an index --(-- */
2350 sprintf(tmp_val, "%c)", index_to_label(i));
2353 /* Clear the line with the (possibly indented) index */
2354 put_str(tmp_val, j+1, col);
2358 /* Display graphics for object, if desired */
2359 if (show_item_graph)
2361 TERM_COLOR a = object_attr(o_ptr);
2362 SYMBOL_CODE c = object_char(o_ptr);
2363 Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2364 if (use_bigtile) cur_col++;
2372 /* Mention the use */
2373 (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
2375 put_str(tmp_val, j+1, cur_col);
2377 /* Display the entry itself */
2378 c_put_str(out_color[j], out_desc[j], j+1, _(cur_col + 9, cur_col + 16));
2384 /* Display the entry itself */
2385 c_put_str(out_color[j], out_desc[j], j+1, cur_col);
2388 /* Display the weight if needed */
2391 int wgt = o_ptr->weight * o_ptr->number;
2393 (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2395 (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
2398 prt(tmp_val, j + 1, wid - 9);
2402 /* Make a "shadow" below the list (only if needed) */
2403 if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2405 /* Save the new column */
2408 return target_item_label;
2412 * @brief サブウィンドウに所持品、装備品リストの表示を行う /
2413 * Flip "inven" and "equip" in any sub-windows
2416 void toggle_inven_equip(void)
2421 for (j = 0; j < 8; j++)
2424 if (!angband_term[j]) continue;
2426 /* Flip inven to equip */
2427 if (window_flag[j] & (PW_INVEN))
2430 window_flag[j] &= ~(PW_INVEN);
2431 window_flag[j] |= (PW_EQUIP);
2433 p_ptr->window |= (PW_EQUIP);
2436 /* Flip inven to equip */
2437 else if (window_flag[j] & (PW_EQUIP))
2440 window_flag[j] &= ~(PW_EQUIP);
2441 window_flag[j] |= (PW_INVEN);
2443 p_ptr->window |= (PW_INVEN);
2449 * @brief 選択したアイテムの確認処理の補助 /
2450 * Verify the choice of an item.
2451 * @param prompt メッセージ表示の一部
2452 * @param item 選択アイテムID
2453 * @return 確認がYesならTRUEを返す。
2454 * @details The item can be negative to mean "item on floor".
2456 static bool verify(concptr prompt, INVENTORY_IDX item)
2458 GAME_TEXT o_name[MAX_NLEN];
2459 char out_val[MAX_NLEN+20];
2466 o_ptr = &p_ptr->inventory_list[item];
2472 o_ptr = ¤t_floor_ptr->o_list[0 - item];
2474 object_desc(o_name, o_ptr, 0);
2477 (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
2480 return (get_check(out_val));
2485 * @brief 選択したアイテムの確認処理のメインルーチン /
2486 * @param item 選択アイテムID
2487 * @return 確認がYesならTRUEを返す。
2488 * @details The item can be negative to mean "item on floor".
2489 * Hack -- allow user to "prevent" certain choices
2491 static bool get_item_allow(INVENTORY_IDX item)
2495 if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
2500 o_ptr = &p_ptr->inventory_list[item];
2506 o_ptr = ¤t_floor_ptr->o_list[0 - item];
2509 /* No inscription */
2510 if (!o_ptr->inscription) return (TRUE);
2513 s = my_strchr(quark_str(o_ptr->inscription), '!');
2515 /* Process preventions */
2518 /* Check the "restriction" */
2519 if ((s[1] == command_cmd) || (s[1] == '*'))
2521 /* Verify the choice */
2522 if (!verify(_("本当に", "Really try"), item)) return (FALSE);
2525 /* Find another '!' */
2526 s = my_strchr(s + 1, '!');
2535 * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
2536 * Auxiliary function for "get_item()" -- test an index
2538 * @return 正規のIDならばTRUEを返す。
2540 static bool get_item_okay(OBJECT_IDX i)
2543 if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
2545 if (select_ring_slot) return is_ring_slot(i);
2547 /* Verify the item */
2548 if (!item_tester_okay(&p_ptr->inventory_list[i])) return (FALSE);
2555 * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
2556 * Determine whether get_item() can get some item or not
2557 * @return アイテムを拾えるならばTRUEを返す。
2558 * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
2560 bool can_get_item(void)
2563 OBJECT_IDX floor_list[23];
2564 ITEM_NUMBER floor_num = 0;
2566 for (j = 0; j < INVEN_TOTAL; j++)
2567 if (item_tester_okay(&p_ptr->inventory_list[j]))
2570 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2578 * @brief オブジェクト選択の汎用関数 /
2579 * Let the user select an item, save its "index"
2580 * @param cp 選択したオブジェクトのIDを返す。
2581 * @param pmt 選択目的のメッセージ
2582 * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
2583 * @param mode オプションフラグ
2584 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
2585 * Return TRUE only if an acceptable item was chosen by the user.\n
2587 * The selected item must satisfy the "item_tester_hook()" function,\n
2588 * if that hook is set, and the "item_tester_tval", if that value is set.\n
2590 * All "item_tester" restrictions are cleared before this function returns.\n
2592 * The user is allowed to choose acceptable items from the equipment,\n
2593 * p_ptr->inventory_list, or floor, respectively, if the proper flag was given,\n
2594 * and there are any acceptable items in that location.\n
2596 * The equipment or p_ptr->inventory_list are displayed (even if no acceptable\n
2597 * items are in that location) if the proper flag was given.\n
2599 * If there are no acceptable items available anywhere, and "str" is\n
2600 * not NULL, then it will be used as the text of a warning message\n
2601 * before the function returns.\n
2603 * Note that the user must press "-" to specify the item on the floor,\n
2604 * and there is no way to "examine" the item on the floor, while the\n
2605 * use of "capital" letters will "examine" an p_ptr->inventory_list/equipment item,\n
2606 * and prompt for its use.\n
2608 * If a legal item is selected from the p_ptr->inventory_list, we save it in "cp"\n
2609 * directly (0 to 35), and return TRUE.\n
2611 * If a legal item is selected from the floor, we save it in "cp" as\n
2612 * a negative (-1 to -511), and return TRUE.\n
2614 * If no item is available, we do nothing to "cp", and we display a\n
2615 * warning message, using "str" if available, and return FALSE.\n
2617 * If no item is selected, we do nothing to "cp", and return FALSE.\n
2619 * Global "p_ptr->command_new" is used when viewing the p_ptr->inventory_list or equipment\n
2620 * to allow the user to enter a command while viewing those screens, and\n
2621 * also to induce "auto-enter" of stores, and other such stuff.\n
2623 * Global "p_ptr->command_see" may be set before calling this function to start\n
2624 * out in "browse" mode. It is cleared before this function returns.\n
2626 * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
2627 * If it is TRUE then we are viewing p_ptr->inventory_list, else equipment.\n
2629 * We always erase the prompt when we are done, leaving a blank line,\n
2630 * or a warning message, if appropriate, if no items are available.\n
2632 bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode)
2634 OBJECT_IDX this_o_idx, next_o_idx = 0;
2651 bool allow_floor = FALSE;
2653 bool toggle = FALSE;
2658 int menu_line = (use_menu ? 1 : 0);
2662 static char prev_tag = '\0';
2663 char cur_tag = '\0';
2665 if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
2668 if (mode & USE_EQUIP) equip = TRUE;
2669 if (mode & USE_INVEN) inven = TRUE;
2670 if (mode & USE_FLOOR) floor = TRUE;
2672 /* Get the item index */
2673 if (repeat_pull(cp))
2676 if (mode & USE_FORCE && (*cp == INVEN_FORCE))
2678 item_tester_tval = 0;
2679 item_tester_hook = NULL;
2680 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2685 else if (floor && (*cp < 0))
2691 o_ptr = ¤t_floor_ptr->o_list[k];
2693 /* Validate the item */
2694 if (item_tester_okay(o_ptr) || (mode & USE_FULL))
2696 /* Forget restrictions */
2697 item_tester_tval = 0;
2698 item_tester_hook = NULL;
2699 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2706 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2707 (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2709 if (prev_tag && command_cmd)
2711 /* Look up the tag and validate the item */
2712 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2713 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2714 else if (!get_item_okay(k)) /* Reject */;
2717 /* Accept that choice */
2720 /* Forget restrictions */
2721 item_tester_tval = 0;
2722 item_tester_hook = NULL;
2723 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2729 prev_tag = '\0'; /* prev_tag is no longer effective */
2732 /* Verify the item */
2733 else if (get_item_okay(*cp))
2735 /* Forget restrictions */
2736 item_tester_tval = 0;
2737 item_tester_hook = NULL;
2738 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2750 /* No item selected */
2754 /* Full p_ptr->inventory_list */
2756 i2 = INVEN_PACK - 1;
2758 /* Forbid p_ptr->inventory_list */
2759 if (!inven) i2 = -1;
2762 for (j = 0; j < INVEN_PACK; j++)
2763 if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
2766 /* Restrict p_ptr->inventory_list indexes */
2767 while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2768 while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2771 /* Full equipment */
2773 e2 = INVEN_TOTAL - 1;
2775 /* Forbid equipment */
2776 if (!equip) e2 = -1;
2779 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2780 if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
2781 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
2784 /* Restrict equipment indexes */
2785 while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2786 while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2788 if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
2792 if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2794 else if (p_ptr->hidarite) e1 = INVEN_RARM;
2798 /* Restrict floor usage */
2801 /* Scan all objects in the grid */
2802 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2805 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
2806 next_o_idx = o_ptr->next_o_idx;
2808 /* Accept the item on the floor if legal */
2809 if ((item_tester_okay(o_ptr) || (mode & USE_FULL)) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
2813 /* Require at least one legal choice */
2814 if (!allow_floor && (i1 > i2) && (e1 > e2))
2816 /* Cancel p_ptr->command_see */
2817 command_see = FALSE;
2821 if (mode & USE_FORCE) {
2827 /* Analyze choices */
2830 /* Hack -- Start on equipment if requested */
2831 if (command_see && command_wrk && equip)
2836 /* Use p_ptr->inventory_list if allowed */
2839 command_wrk = FALSE;
2842 /* Use equipment if allowed */
2848 /* Use p_ptr->inventory_list for floor */
2851 command_wrk = FALSE;
2857 * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2859 if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2861 /* Hack -- start out in "display" mode */
2868 /* Repeat until done */
2871 COMMAND_CODE get_item_label = 0;
2878 for (j = 0; j < 8; j++)
2881 if (!angband_term[j]) continue;
2883 /* Count windows displaying inven */
2884 if (window_flag[j] & (PW_INVEN)) ni++;
2886 /* Count windows displaying equip */
2887 if (window_flag[j] & (PW_EQUIP)) ne++;
2890 /* Toggle if needed */
2891 if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
2894 toggle_inven_equip();
2900 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2903 /* Inventory screen */
2906 /* Redraw if needed */
2907 if (command_see) get_item_label = show_inven(menu_line, mode);
2910 /* Equipment screen */
2913 /* Redraw if needed */
2914 if (command_see) get_item_label = show_equip(menu_line, mode);
2917 /* Viewing p_ptr->inventory_list */
2920 /* Begin the prompt */
2921 sprintf(out_val, _("持ち物:", "Inven:"));
2923 /* Some legal items */
2924 if ((i1 <= i2) && !use_menu)
2926 /* Build the prompt */
2927 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2928 index_to_label(i1), index_to_label(i2));
2931 strcat(out_val, tmp_val);
2934 /* Indicate ability to "view" */
2935 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2938 if (equip) strcat(out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
2941 /* Viewing equipment */
2944 /* Begin the prompt */
2945 sprintf(out_val, _("装備品:", "Equip:"));
2947 /* Some legal items */
2948 if ((e1 <= e2) && !use_menu)
2950 /* Build the prompt */
2951 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2952 index_to_label(e1), index_to_label(e2));
2955 strcat(out_val, tmp_val);
2958 /* Indicate ability to "view" */
2959 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2962 if (inven) strcat(out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
2965 /* Indicate legality of the "floor" item */
2966 if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
2967 if (mode & USE_FORCE) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
2969 /* Finish the prompt */
2970 strcat(out_val, " ESC");
2972 /* Build the prompt */
2973 sprintf(tmp_val, "(%s) %s", out_val, pmt);
2975 /* Show the prompt */
2983 int max_line = (command_wrk ? max_equip : max_inven);
2999 menu_line += (max_line - 1);
3018 /* Verify legality */
3019 if (!inven || !equip)
3025 /* Hack -- Fix screen */
3032 /* Switch inven/equip */
3033 command_wrk = !command_wrk;
3034 max_line = (command_wrk ? max_equip : max_inven);
3035 if (menu_line > max_line) menu_line = max_line;
3037 /* Need to redraw */
3046 if (command_wrk == USE_FLOOR)
3049 (*cp) = -get_item_label;
3053 /* Validate the item */
3054 if (!get_item_okay(get_item_label))
3060 /* Allow player to "refuse" certain actions */
3061 if (!get_item_allow(get_item_label))
3067 /* Accept that choice */
3068 (*cp) = get_item_label;
3077 if (mode & USE_FORCE) {
3085 if (menu_line > max_line) menu_line -= max_line;
3106 command_see = FALSE;
3123 /* Verify legality */
3124 if (!inven || !equip)
3130 /* Hack -- Fix screen */
3137 /* Switch inven/equip */
3138 command_wrk = !command_wrk;
3140 /* Need to redraw */
3146 /* Use floor item */
3149 /* Scan all objects in the grid */
3150 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3153 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3154 next_o_idx = o_ptr->next_o_idx;
3156 /* Validate the item */
3157 if (!item_tester_okay(o_ptr) && !(mode & USE_FULL)) continue;
3162 /* Verify the item (if required) */
3163 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
3165 /* Allow player to "refuse" certain actions */
3166 if (!get_item_allow(k)) continue;
3168 /* Accept that choice */
3184 case '1': case '2': case '3':
3185 case '4': case '5': case '6':
3186 case '7': case '8': case '9':
3188 /* Look up the tag */
3189 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3195 /* Hack -- Validate the item */
3196 if ((k < INVEN_RARM) ? !inven : !equip)
3202 /* Validate the item */
3203 if (!get_item_okay(k))
3209 /* Allow player to "refuse" certain actions */
3210 if (!get_item_allow(k))
3216 /* Accept that choice */
3228 /* Choose "default" p_ptr->inventory_list item */
3231 k = ((i1 == i2) ? i1 : -1);
3234 /* Choose "default" equipment item */
3237 k = ((e1 == e2) ? e1 : -1);
3240 /* Validate the item */
3241 if (!get_item_okay(k))
3247 /* Allow player to "refuse" certain actions */
3248 if (!get_item_allow(k))
3254 /* Accept that choice */
3264 if (mode & USE_FORCE) {
3277 bool not_found = FALSE;
3279 /* Look up the alphabetical tag */
3280 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3285 /* Hack -- Validate the item */
3286 else if ((k < INVEN_RARM) ? !inven : !equip)
3291 /* Validate the item */
3292 else if (!get_item_okay(k))
3299 /* Accept that choice */
3307 /* Extract "query" setting */
3308 ver = isupper(which);
3309 which = (char)tolower(which);
3311 /* Convert letter to p_ptr->inventory_list index */
3314 if (which == '(') k = i1;
3315 else if (which == ')') k = i2;
3316 else k = label_to_inven(which);
3319 /* Convert letter to equipment index */
3322 if (which == '(') k = e1;
3323 else if (which == ')') k = e2;
3324 else k = label_to_equip(which);
3327 /* Validate the item */
3328 if (!get_item_okay(k))
3334 /* Verify the item */
3335 if (ver && !verify(_("本当に", "Try"), k))
3341 /* Allow player to "refuse" certain actions */
3342 if (!get_item_allow(k))
3348 /* Accept that choice */
3359 /* Fix the screen if necessary */
3364 /* Hack -- Cancel "display" */
3365 command_see = FALSE;
3369 /* Forget the item_tester_tval restriction */
3370 item_tester_tval = 0;
3372 /* Forget the item_tester_hook restriction */
3373 item_tester_hook = NULL;
3376 /* Clean up 'show choices' */
3377 /* Toggle again if needed */
3378 if (toggle) toggle_inven_equip();
3380 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3383 /* Clear the prompt line */
3386 /* Warning if needed */
3387 if (oops && str) msg_print(str);
3392 if (command_cmd) prev_tag = cur_tag;
3393 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3399 * Choose an item and get auto-picker entry from it.
3401 object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
3404 if (!get_item(&item, q, s, option)) return NULL;
3405 if (idx) *idx = item;
3407 if (item == INVEN_FORCE) return NULL;
3409 /* Get the item (in the pack) */
3410 else if (item >= 0) return &p_ptr->inventory_list[item];
3412 /* Get the item (on the floor) */
3413 else return ¤t_floor_ptr->o_list[0 - item];
3418 * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
3419 * @param items オブジェクトのIDリストを返すための配列参照ポインタ
3420 * @param y 走査するフロアのY座標
3421 * @param x 走査するフロアのX座標
3422 * @param mode オプションフラグ
3423 * @return 対象のマスに落ちているアイテム数
3425 * Return a list of o_list[] indexes of items at the given current_floor_ptr->grid_array
3426 * location. Valid flags are:
3428 * mode & 0x01 -- Item tester
3429 * mode & 0x02 -- Marked items only
3430 * mode & 0x04 -- Stop after first
3432 ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
3434 OBJECT_IDX this_o_idx, next_o_idx;
3436 ITEM_NUMBER num = 0;
3439 if (!in_bounds(y, x)) return 0;
3441 /* Scan all objects in the grid */
3442 for (this_o_idx = current_floor_ptr->grid_array[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3445 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3446 next_o_idx = o_ptr->next_o_idx;
3449 if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
3452 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
3454 /* Accept this item */
3455 /* XXX Hack -- Enforce limit */
3457 items[num] = this_o_idx;
3462 if (mode & 0x04) break;
3469 * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
3470 * @param target_item カーソルの初期値
3471 * @param y 走査するフロアのY座標
3472 * @param x 走査するフロアのX座標
3473 * @param min_width 表示の長さ
3474 * @return 選択したアイテムの添え字
3477 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
3485 GAME_TEXT o_name[MAX_NLEN];
3488 COMMAND_CODE out_index[23];
3489 TERM_COLOR out_color[23];
3490 char out_desc[23][MAX_NLEN];
3491 COMMAND_CODE target_item_label = 0;
3493 OBJECT_IDX floor_list[23];
3494 ITEM_NUMBER floor_num;
3496 char floor_label[52 + 1];
3498 bool dont_need_to_show_weights = TRUE;
3500 Term_get_size(&wid, &hgt);
3502 /* Default length */
3503 len = MAX((*min_width), 20);
3505 /* Scan for objects in the grid, using item_tester_okay() */
3506 floor_num = scan_floor(floor_list, y, x, 0x03);
3508 /* Display the floor objects */
3509 for (k = 0, i = 0; i < floor_num && i < 23; i++)
3511 o_ptr = ¤t_floor_ptr->o_list[floor_list[i]];
3513 object_desc(o_name, o_ptr, 0);
3515 /* Save the index */
3518 /* Acquire p_ptr->inventory_list color */
3519 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
3521 /* Save the object description */
3522 strcpy(out_desc[k], o_name);
3524 /* Find the predicted "line length" */
3525 l = strlen(out_desc[k]) + 5;
3527 /* Be sure to account for the weight */
3528 if (show_weights) l += 9;
3530 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
3532 /* Maintain the maximum length */
3533 if (l > len) len = l;
3535 /* Advance to next "line" */
3539 if (show_weights && dont_need_to_show_weights) len -= 9;
3544 /* Find the column to start in */
3545 col = (len > wid - 4) ? 0 : (wid - len - 1);
3547 prepare_label_string_floor(floor_label, floor_list, floor_num);
3549 /* Output each entry */
3550 for (j = 0; j < k; j++)
3552 m = floor_list[out_index[j]];
3553 o_ptr = ¤t_floor_ptr->o_list[m];
3555 /* Clear the line */
3556 prt("", j + 1, col ? col - 2 : col);
3558 if (use_menu && target_item)
3560 if (j == (target_item-1))
3562 strcpy(tmp_val, _("》", "> "));
3563 target_item_label = m;
3565 else strcpy(tmp_val, " ");
3569 /* Prepare an index --(-- */
3570 sprintf(tmp_val, "%c)", floor_label[j]);
3573 /* Clear the line with the (possibly indented) index */
3574 put_str(tmp_val, j + 1, col);
3576 /* Display the entry itself */
3577 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
3579 /* Display the weight if needed */
3580 if (show_weights && (o_ptr->tval != TV_GOLD))
3582 int wgt = o_ptr->weight * o_ptr->number;
3584 sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3586 sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3589 prt(tmp_val, j + 1, wid - 9);
3593 /* Make a "shadow" below the list (only if needed) */
3594 if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3596 return target_item_label;
3600 * @brief オブジェクト選択の汎用関数(床上アイテム用) /
3601 * Let the user select an item, save its "index"
3602 * @param cp 選択したオブジェクトのIDを返す。
3603 * @param pmt 選択目的のメッセージ
3604 * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
3605 * @param mode オプションフラグ
3606 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
3608 bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode)
3610 char n1 = ' ', n2 = ' ', which = ' ';
3613 COMMAND_CODE i1, i2;
3614 COMMAND_CODE e1, e2;
3622 bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
3623 bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
3624 bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
3625 bool force = (mode & USE_FORCE) ? TRUE : FALSE;
3627 bool allow_equip = FALSE;
3628 bool allow_inven = FALSE;
3629 bool allow_floor = FALSE;
3631 bool toggle = FALSE;
3636 ITEM_NUMBER floor_num;
3637 OBJECT_IDX floor_list[23];
3639 TERM_LEN min_width = 0;
3641 int menu_line = (use_menu ? 1 : 0);
3645 static char prev_tag = '\0';
3646 char cur_tag = '\0';
3648 /* Get the item index */
3649 if (repeat_pull(cp))
3652 if (force && (*cp == INVEN_FORCE))
3654 item_tester_tval = 0;
3655 item_tester_hook = NULL;
3656 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3661 else if (floor && (*cp < 0))
3663 if (prev_tag && command_cmd)
3665 /* Scan all objects in the grid */
3666 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3668 /* Look up the tag */
3669 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
3671 /* Accept that choice */
3672 (*cp) = 0 - floor_list[k];
3674 /* Forget restrictions */
3675 item_tester_tval = 0;
3676 item_tester_hook = NULL;
3677 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3683 prev_tag = '\0'; /* prev_tag is no longer effective */
3686 /* Validate the item */
3687 else if (item_tester_okay(¤t_floor_ptr->o_list[0 - (*cp)]) || (mode & USE_FULL))
3689 /* Forget restrictions */
3690 item_tester_tval = 0;
3691 item_tester_hook = NULL;
3692 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3699 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3700 (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3702 if (prev_tag && command_cmd)
3704 /* Look up the tag and validate the item */
3705 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3706 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3707 else if (!get_item_okay(k)) /* Reject */;
3710 /* Accept that choice */
3713 /* Forget restrictions */
3714 item_tester_tval = 0;
3715 item_tester_hook = NULL;
3716 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3722 prev_tag = '\0'; /* prev_tag is no longer effective */
3725 /* Verify the item */
3726 else if (get_item_okay(*cp))
3728 /* Forget restrictions */
3729 item_tester_tval = 0;
3730 item_tester_hook = NULL;
3731 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3745 /* No item selected */
3749 /* Full p_ptr->inventory_list */
3751 i2 = INVEN_PACK - 1;
3753 /* Forbid p_ptr->inventory_list */
3754 if (!inven) i2 = -1;
3757 for (j = 0; j < INVEN_PACK; j++)
3758 if (item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_inven++;
3761 /* Restrict p_ptr->inventory_list indexes */
3762 while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3763 while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3766 /* Full equipment */
3768 e2 = INVEN_TOTAL - 1;
3770 /* Forbid equipment */
3771 if (!equip) e2 = -1;
3774 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3775 if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j]) || (mode & USE_FULL)) max_equip++;
3776 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
3779 /* Restrict equipment indexes */
3780 while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3781 while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3783 if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
3787 if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3789 else if (p_ptr->hidarite) e1 = INVEN_RARM;
3793 /* Count "okay" floor items */
3796 /* Restrict floor usage */
3799 /* Scan all objects in the grid */
3800 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3803 /* Accept p_ptr->inventory_list */
3804 if (i1 <= i2) allow_inven = TRUE;
3806 /* Accept equipment */
3807 if (e1 <= e2) allow_equip = TRUE;
3810 if (floor_num) allow_floor = TRUE;
3812 /* Require at least one legal choice */
3813 if (!allow_inven && !allow_equip && !allow_floor)
3815 /* Cancel p_ptr->command_see */
3816 command_see = FALSE;
3826 /* Analyze choices */
3829 /* Hack -- Start on equipment if requested */
3830 if (command_see && (command_wrk == (USE_EQUIP))
3833 command_wrk = (USE_EQUIP);
3836 /* Use p_ptr->inventory_list if allowed */
3837 else if (allow_inven)
3839 command_wrk = (USE_INVEN);
3842 /* Use equipment if allowed */
3843 else if (allow_equip)
3845 command_wrk = (USE_EQUIP);
3848 /* Use floor if allowed */
3849 else if (allow_floor)
3851 command_wrk = (USE_FLOOR);
3856 * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
3858 if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
3860 /* Hack -- start out in "display" mode */
3866 /* Repeat until done */
3869 COMMAND_CODE get_item_label = 0;
3876 for (j = 0; j < 8; j++)
3879 if (!angband_term[j]) continue;
3881 /* Count windows displaying inven */
3882 if (window_flag[j] & (PW_INVEN)) ni++;
3884 /* Count windows displaying equip */
3885 if (window_flag[j] & (PW_EQUIP)) ne++;
3888 /* Toggle if needed */
3889 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
3890 (command_wrk == (USE_INVEN) && !ni && ne))
3893 toggle_inven_equip();
3899 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3902 /* Inventory screen */
3903 if (command_wrk == (USE_INVEN))
3905 /* Extract the legal requests */
3909 /* Redraw if needed */
3910 if (command_see) get_item_label = show_inven(menu_line, mode);
3913 /* Equipment screen */
3914 else if (command_wrk == (USE_EQUIP))
3916 /* Extract the legal requests */
3917 n1 = I2A(e1 - INVEN_RARM);
3918 n2 = I2A(e2 - INVEN_RARM);
3920 /* Redraw if needed */
3921 if (command_see) get_item_label = show_equip(menu_line, mode);
3925 else if (command_wrk == (USE_FLOOR))
3928 k = MIN(floor_top + 23, floor_num) - 1;
3930 /* Extract the legal requests */
3931 n1 = I2A(j - floor_top);
3932 n2 = I2A(k - floor_top);
3934 /* Redraw if needed */
3935 if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
3938 /* Viewing p_ptr->inventory_list */
3939 if (command_wrk == (USE_INVEN))
3941 /* Begin the prompt */
3942 sprintf(out_val, _("持ち物:", "Inven:"));
3946 /* Build the prompt */
3947 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3948 index_to_label(i1), index_to_label(i2));
3951 strcat(out_val, tmp_val);
3954 /* Indicate ability to "view" */
3955 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3961 strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
3962 else if (allow_floor)
3963 strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
3965 strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
3972 strcat(out_val, _(" '-'床上,", " - for floor,"));
3973 else if (allow_equip)
3974 strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
3976 strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
3980 /* Viewing equipment */
3981 else if (command_wrk == (USE_EQUIP))
3983 /* Begin the prompt */
3984 sprintf(out_val, _("装備品:", "Equip:"));
3988 /* Build the prompt */
3989 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3990 index_to_label(e1), index_to_label(e2));
3993 strcat(out_val, tmp_val);
3996 /* Indicate ability to "view" */
3997 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4003 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4004 else if (allow_floor)
4005 strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
4007 strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4014 strcat(out_val, _(" '-'床上,", " - for floor,"));
4015 else if (allow_inven)
4016 strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
4018 strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
4023 else if (command_wrk == (USE_FLOOR))
4025 /* Begin the prompt */
4026 sprintf(out_val, _("床上:", "Floor:"));
4030 /* Build the prompt */
4031 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
4034 strcat(out_val, tmp_val);
4037 /* Indicate ability to "view" */
4038 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4042 if (allow_inven && allow_equip)
4044 strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
4046 else if (allow_inven)
4048 strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4050 else if (allow_equip)
4052 strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
4056 else if (allow_inven)
4058 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4060 else if (allow_equip)
4062 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
4066 if (command_see && !use_menu)
4068 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
4073 if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
4075 /* Finish the prompt */
4076 strcat(out_val, " ESC");
4078 /* Build the prompt */
4079 sprintf(tmp_val, "(%s) %s", out_val, pmt);
4081 /* Show the prompt */
4090 if (command_wrk == USE_INVEN) max_line = max_inven;
4091 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4092 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4108 menu_line += (max_line - 1);
4124 /* Verify legality */
4125 if (command_wrk == (USE_INVEN))
4127 if (allow_floor) command_wrk = USE_FLOOR;
4128 else if (allow_equip) command_wrk = USE_EQUIP;
4135 else if (command_wrk == (USE_EQUIP))
4137 if (allow_inven) command_wrk = USE_INVEN;
4138 else if (allow_floor) command_wrk = USE_FLOOR;
4145 else if (command_wrk == (USE_FLOOR))
4147 if (allow_equip) command_wrk = USE_EQUIP;
4148 else if (allow_inven) command_wrk = USE_INVEN;
4161 /* Hack -- Fix screen */
4168 /* Switch inven/equip */
4169 if (command_wrk == USE_INVEN) max_line = max_inven;
4170 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4171 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4172 if (menu_line > max_line) menu_line = max_line;
4174 /* Need to redraw */
4182 /* Verify legality */
4183 if (command_wrk == (USE_INVEN))
4185 if (allow_equip) command_wrk = USE_EQUIP;
4186 else if (allow_floor) command_wrk = USE_FLOOR;
4193 else if (command_wrk == (USE_EQUIP))
4195 if (allow_floor) command_wrk = USE_FLOOR;
4196 else if (allow_inven) command_wrk = USE_INVEN;
4203 else if (command_wrk == (USE_FLOOR))
4205 if (allow_inven) command_wrk = USE_INVEN;
4206 else if (allow_equip) command_wrk = USE_EQUIP;
4219 /* Hack -- Fix screen */
4226 /* Switch inven/equip */
4227 if (command_wrk == USE_INVEN) max_line = max_inven;
4228 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4229 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4230 if (menu_line > max_line) menu_line = max_line;
4232 /* Need to redraw */
4241 if (command_wrk == USE_FLOOR)
4244 (*cp) = -get_item_label;
4248 /* Validate the item */
4249 if (!get_item_okay(get_item_label))
4255 /* Allow player to "refuse" certain actions */
4256 if (!get_item_allow(get_item_label))
4262 /* Accept that choice */
4263 (*cp) = get_item_label;
4280 if (menu_line > max_line) menu_line -= max_line;
4301 command_see = FALSE;
4322 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
4324 if (command_wrk != (USE_FLOOR)) break;
4326 /* Get the object being moved. */
4327 o_idx = g_ptr->o_idx;
4329 /* Only rotate a pile of two or more objects. */
4330 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) break;
4332 /* Remove the first object from the list. */
4333 excise_object_idx(o_idx);
4335 /* Find end of the list. */
4337 while (current_floor_ptr->o_list[i].next_o_idx)
4338 i = current_floor_ptr->o_list[i].next_o_idx;
4340 /* Add after the last object. */
4341 current_floor_ptr->o_list[i].next_o_idx = o_idx;
4343 /* Re-scan floor list */
4344 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
4346 /* Hack -- Fix screen */
4358 if (command_wrk == (USE_INVEN))
4365 command_wrk = (USE_EQUIP);
4367 else if (command_wrk == (USE_EQUIP))
4374 command_wrk = (USE_INVEN);
4376 else if (command_wrk == (USE_FLOOR))
4380 command_wrk = (USE_INVEN);
4382 else if (allow_equip)
4384 command_wrk = (USE_EQUIP);
4393 /* Hack -- Fix screen */
4400 /* Need to redraw */
4413 * If we are already examining the floor, and there
4414 * is only one item, we will always select it.
4415 * If we aren't examining the floor and there is only
4416 * one item, we will select it if floor_query_flag
4421 if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
4424 k = 0 - floor_list[0];
4426 /* Allow player to "refuse" certain actions */
4427 if (!get_item_allow(k))
4433 /* Accept that choice */
4442 /* Hack -- Fix screen */
4449 command_wrk = (USE_FLOOR);
4455 case '1': case '2': case '3':
4456 case '4': case '5': case '6':
4457 case '7': case '8': case '9':
4459 if (command_wrk != USE_FLOOR)
4461 /* Look up the tag */
4462 if (!get_tag(&k, which, command_wrk))
4468 /* Hack -- Validate the item */
4469 if ((k < INVEN_RARM) ? !inven : !equip)
4475 /* Validate the item */
4476 if (!get_item_okay(k))
4484 /* Look up the alphabetical tag */
4485 if (get_tag_floor(&k, which, floor_list, floor_num))
4488 k = 0 - floor_list[k];
4497 /* Allow player to "refuse" certain actions */
4498 if (!get_item_allow(k))
4504 /* Accept that choice */
4516 /* Choose "default" p_ptr->inventory_list item */
4517 if (command_wrk == (USE_INVEN))
4519 k = ((i1 == i2) ? i1 : -1);
4522 /* Choose "default" equipment item */
4523 else if (command_wrk == (USE_EQUIP))
4525 k = ((e1 == e2) ? e1 : -1);
4528 /* Choose "default" floor item */
4529 else if (command_wrk == (USE_FLOOR))
4534 k = 0 - floor_list[0];
4536 /* Allow player to "refuse" certain actions */
4537 if (!get_item_allow(k))
4543 /* Accept that choice */
4551 /* Validate the item */
4552 if (!get_item_okay(k))
4558 /* Allow player to "refuse" certain actions */
4559 if (!get_item_allow(k))
4565 /* Accept that choice */
4589 if (command_wrk != USE_FLOOR)
4591 bool not_found = FALSE;
4593 /* Look up the alphabetical tag */
4594 if (!get_tag(&k, which, command_wrk))
4599 /* Hack -- Validate the item */
4600 else if ((k < INVEN_RARM) ? !inven : !equip)
4605 /* Validate the item */
4606 else if (!get_item_okay(k))
4613 /* Accept that choice */
4623 /* Look up the alphabetical tag */
4624 if (get_tag_floor(&k, which, floor_list, floor_num))
4627 k = 0 - floor_list[k];
4629 /* Accept that choice */
4638 /* Extract "query" setting */
4639 ver = isupper(which);
4640 which = (char)tolower(which);
4642 /* Convert letter to p_ptr->inventory_list index */
4643 if (command_wrk == (USE_INVEN))
4645 if (which == '(') k = i1;
4646 else if (which == ')') k = i2;
4647 else k = label_to_inven(which);
4650 /* Convert letter to equipment index */
4651 else if (command_wrk == (USE_EQUIP))
4653 if (which == '(') k = e1;
4654 else if (which == ')') k = e2;
4655 else k = label_to_equip(which);
4658 /* Convert letter to floor index */
4659 else if (command_wrk == USE_FLOOR)
4661 if (which == '(') k = 0;
4662 else if (which == ')') k = floor_num - 1;
4663 else k = islower(which) ? A2I(which) : -1;
4664 if (k < 0 || k >= floor_num || k >= 23)
4671 k = 0 - floor_list[k];
4674 /* Validate the item */
4675 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
4681 /* Verify the item */
4682 if (ver && !verify(_("本当に", "Try"), k))
4688 /* Allow player to "refuse" certain actions */
4689 if (!get_item_allow(k))
4695 /* Accept that choice */
4705 /* Fix the screen if necessary */
4710 /* Hack -- Cancel "display" */
4711 command_see = FALSE;
4715 /* Forget the item_tester_tval restriction */
4716 item_tester_tval = 0;
4718 /* Forget the item_tester_hook restriction */
4719 item_tester_hook = NULL;
4722 /* Clean up 'show choices' */
4723 /* Toggle again if needed */
4724 if (toggle) toggle_inven_equip();
4726 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4729 /* Clear the prompt line */
4732 /* Warning if needed */
4733 if (oops && str) msg_print(str);
4738 if (command_cmd) prev_tag = cur_tag;
4739 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4745 * @brief 床上のアイテムを拾う選択用サブルーチン
4746 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
4748 static bool py_pickup_floor_aux(void)
4750 OBJECT_IDX this_o_idx;
4754 /* Restrict the choices */
4755 item_tester_hook = inven_carry_okay;
4758 q = _("どれを拾いますか?", "Get which item? ");
4759 s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
4761 if (choose_object(&item, q, s, (USE_FLOOR)))
4763 this_o_idx = 0 - item;
4770 /* Pick up the object */
4771 py_pickup_aux(this_o_idx);
4777 * @brief 床上のアイテムを拾うメイン処理
4778 * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
4781 * This is called by py_pickup() when easy_floor is TRUE.
4783 void py_pickup_floor(bool pickup)
4785 OBJECT_IDX this_o_idx, next_o_idx = 0;
4787 GAME_TEXT o_name[MAX_NLEN];
4791 OBJECT_IDX floor_o_idx = 0;
4795 /* Scan the pile of objects */
4796 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
4798 /* Access the object */
4799 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
4801 object_desc(o_name, o_ptr, 0);
4803 /* Access the next object */
4804 next_o_idx = o_ptr->next_o_idx;
4806 disturb(FALSE, FALSE);
4809 if (o_ptr->tval == TV_GOLD)
4812 msg_format(" $%ld の価値がある%sを見つけた。",
4813 (long)o_ptr->pval, o_name);
4815 msg_format("You have found %ld gold pieces worth of %s.",
4816 (long)o_ptr->pval, o_name);
4819 /* Collect the gold */
4820 p_ptr->au += o_ptr->pval;
4823 p_ptr->redraw |= (PR_GOLD);
4825 p_ptr->window |= (PW_PLAYER);
4827 /* Delete the gold */
4828 delete_object_idx(this_o_idx);
4830 /* Check the next object */
4833 else if (o_ptr->marked & OM_NOMSG)
4835 /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
4836 * ignored. Otherwise, they are included in the prompt. */
4837 o_ptr->marked &= ~(OM_NOMSG);
4841 /* Count non-gold objects that can be picked up. */
4842 if (inven_carry_okay(o_ptr))
4847 /* Count non-gold objects */
4850 /* Remember this index */
4851 floor_o_idx = this_o_idx;
4854 /* There are no non-gold objects */
4858 /* Mention the number of objects */
4864 /* Access the object */
4865 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
4867 #ifdef ALLOW_EASY_SENSE
4869 /* Option: Make object sensing easy */
4872 /* Sense the object */
4873 (void) sense_object(o_ptr);
4876 #endif /* ALLOW_EASY_SENSE */
4878 object_desc(o_name, o_ptr, 0);
4880 msg_format(_("%sがある。", "You see %s."), o_name);
4883 /* Multiple objects */
4886 msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
4892 /* The player has no room for anything on the floor. */
4898 /* Access the object */
4899 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
4901 #ifdef ALLOW_EASY_SENSE
4903 /* Option: Make object sensing easy */
4906 /* Sense the object */
4907 (void) sense_object(o_ptr);
4910 #endif /* ALLOW_EASY_SENSE */
4912 object_desc(o_name, o_ptr, 0);
4914 msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
4917 /* Multiple objects */
4920 msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
4930 /* Hack -- query every object */
4931 if (carry_query_flag)
4933 char out_val[MAX_NLEN+20];
4935 /* Access the object */
4936 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
4938 #ifdef ALLOW_EASY_SENSE
4940 /* Option: Make object sensing easy */
4943 /* Sense the object */
4944 (void) sense_object(o_ptr);
4947 #endif /* ALLOW_EASY_SENSE */
4949 object_desc(o_name, o_ptr, 0);
4951 /* Build a prompt */
4952 (void) sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
4954 /* Ask the user to confirm */
4955 if (!get_check(out_val))
4961 /* Access the object */
4962 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
4964 #ifdef ALLOW_EASY_SENSE
4966 /* Option: Make object sensing easy */
4969 /* Sense the object */
4970 (void) sense_object(o_ptr);
4973 #endif /* ALLOW_EASY_SENSE */
4975 /* Pick up the object */
4976 py_pickup_aux(floor_o_idx);
4979 /* Allow the user to choose an object */
4982 while (can_pickup--)
4984 if (!py_pickup_floor_aux()) break;
4991 * @brief 矢弾を射撃した場合の破損確率を返す /
4992 * Determines the odds of an object breaking when thrown at a monster
4993 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
4996 * Note that artifacts never break, see the "drop_near()" function.
4998 PERCENTAGE breakage_chance(object_type *o_ptr, SPELL_IDX snipe_type)
5000 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev - 1) / 7 + 4 : 0);
5002 /* Examine the snipe type */
5005 if (snipe_type == SP_KILL_WALL) return (100);
5006 if (snipe_type == SP_EXPLODE) return (100);
5007 if (snipe_type == SP_PIERCE) return (100);
5008 if (snipe_type == SP_FINAL) return (100);
5009 if (snipe_type == SP_NEEDLE) return (100);
5010 if (snipe_type == SP_EVILNESS) return (40);
5011 if (snipe_type == SP_HOLYNESS) return (40);
5014 /* Examine the item type */
5015 switch (o_ptr->tval)
5031 /* Sometimes break */
5036 return (20 - archer_bonus * 2);
5041 return (10 - archer_bonus);