3 * @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory commands
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 #include "cmd-activate.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "player-item.h"
25 #include "object-hook.h"
29 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
32 void do_cmd_inven(void)
37 /* Note that we are in "inventory" mode */
40 /* Note that we are in "inventory" mode */
41 if (easy_floor) command_wrk = (USE_INVEN);
44 /* Hack -- show empty slots */
45 item_tester_full = TRUE;
47 /* Display the inventory */
50 /* Hack -- hide empty slots */
51 item_tester_full = FALSE;
54 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
55 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
56 (long int)((p_ptr->total_weight * 100) / weight_limit()));
58 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
59 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
60 (p_ptr->total_weight * 100) / weight_limit());
67 /* Get a new command */
68 command_new = inkey();
72 /* Process "Escape" */
73 if (command_new == ESCAPE)
77 Term_get_size(&wid, &hgt);
81 command_gap = wid - 30;
84 /* Process normal keys */
87 /* Hack -- Use "display" mode */
94 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
97 void do_cmd_equip(void)
102 /* Note that we are in "equipment" mode */
105 /* Note that we are in "equipment" mode */
106 if (easy_floor) command_wrk = (USE_EQUIP);
109 /* Hack -- show empty slots */
110 item_tester_full = TRUE;
112 /* Display the equipment */
115 /* Hack -- undo the hack above */
116 item_tester_full = FALSE;
120 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
121 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
122 (long int)((p_ptr->total_weight * 100) / weight_limit()));
124 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
125 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
126 (long int)((p_ptr->total_weight * 100) / weight_limit()));
133 /* Get a new command */
134 command_new = inkey();
138 /* Process "Escape" */
139 if (command_new == ESCAPE)
143 Term_get_size(&wid, &hgt);
147 command_gap = wid - 30;
150 /* Process normal keys */
153 /* Enter "display" mode */
161 bool select_ring_slot = FALSE;
164 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
167 void do_cmd_wield(void)
169 OBJECT_IDX item, slot;
177 char o_name[MAX_NLEN];
180 OBJECT_IDX need_switch_wielding = 0;
182 if (p_ptr->special_defense & KATA_MUSOU)
184 set_action(ACTION_NONE);
187 /* Restrict the choices */
188 item_tester_hook = item_tester_hook_wear;
190 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
191 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
193 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
197 slot = wield_slot(o_ptr);
201 /* Shields and some misc. items */
206 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
208 /* Restrict the choices */
209 item_tester_hook = item_tester_hook_melee_weapon;
210 item_tester_no_ryoute = TRUE;
212 /* Choose a weapon from the equipment only */
213 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
214 s = _("おっと。", "Oops.");
215 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
216 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
219 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
221 /* Both arms are already used by non-weapon */
222 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
223 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
225 /* Restrict the choices */
226 item_tester_hook = item_tester_hook_mochikae;
229 q = _("どちらの手に装備しますか?", "Equip which hand? ");
230 s = _("おっと。", "Oops.");
231 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
240 /* Asking for dual wielding */
241 if (slot == INVEN_LARM)
243 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
246 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
248 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
251 /* Both arms are already used */
252 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
254 /* Restrict the choices */
255 item_tester_hook = item_tester_hook_mochikae;
258 q = _("どちらの手に装備しますか?", "Equip which hand? ");
259 s = _("おっと。", "Oops.");
261 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
262 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
263 need_switch_wielding = INVEN_RARM;
269 /* Choose a ring slot */
270 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
272 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
276 q = _("どちらの手に装備しますか?", "Equip which hand? ");
278 s = _("おっと。", "Oops.");
280 /* Restrict the choices */
281 select_ring_slot = TRUE;
282 item_tester_no_ryoute = TRUE;
284 if (!get_item(&slot, q, s, (USE_EQUIP)))
286 select_ring_slot = FALSE;
289 select_ring_slot = FALSE;
293 /* Prevent wielding into a cursed slot */
294 if (object_is_cursed(&inventory[slot]))
297 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
300 msg_format("%s%sは呪われているようだ。",
301 describe_use(slot) , o_name );
303 msg_format("The %s you are %s appears to be cursed.",
304 o_name, describe_use(slot));
307 /* Cancel the command */
312 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
313 ((o_ptr->ident & IDENT_SENSE) &&
314 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
316 char dummy[MAX_NLEN+80];
319 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
320 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
322 if (!get_check(dummy)) return;
325 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
327 char dummy[MAX_NLEN+80];
330 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
333 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
335 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
336 sprintf(dummy, "Do you become a vampire?");
339 if (!get_check(dummy)) return;
342 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
344 object_type *slot_o_ptr = &inventory[slot];
345 object_type *switch_o_ptr = &inventory[need_switch_wielding];
346 object_type object_tmp;
347 object_type *otmp_ptr = &object_tmp;
348 char switch_name[MAX_NLEN];
350 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
352 object_copy(otmp_ptr, switch_o_ptr);
353 object_copy(switch_o_ptr, slot_o_ptr);
354 object_copy(slot_o_ptr, otmp_ptr);
356 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
357 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
358 (left_hander ? _("右手", "right") : _("左手", "left")));
359 slot = need_switch_wielding;
362 check_find_art_quest_completion(o_ptr);
364 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
366 identify_item(o_ptr);
368 /* Auto-inscription */
369 autopick_alter_item(item, FALSE);
372 p_ptr->energy_use = 100;
375 /* Obtain local object */
376 object_copy(q_ptr, o_ptr);
378 /* Modify quantity */
381 /* Decrease the item (from the pack) */
384 inven_item_increase(item, -1);
385 inven_item_optimize(item);
388 /* Decrease the item (from the floor) */
391 floor_item_increase(0 - item, -1);
392 floor_item_optimize(0 - item);
395 /* Access the wield slot */
396 o_ptr = &inventory[slot];
398 /* Take off existing item */
401 /* Take off existing item */
402 (void)inven_takeoff(slot, 255);
405 /* Wear the new stuff */
406 object_copy(o_ptr, q_ptr);
408 /* Player touches it */
409 o_ptr->marked |= OM_TOUCHED;
411 /* Increase the weight */
412 p_ptr->total_weight += q_ptr->weight;
414 /* Increment the equip counter by hand */
418 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
419 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
420 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
422 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
423 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
424 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
427 /* Where is the item now */
431 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
432 act = STR_WIELD_ARMS;
434 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
438 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
439 act = STR_WIELD_ARMS;
441 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
445 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
449 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
453 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
457 /* Describe the result */
458 object_desc(o_name, o_ptr, 0);
459 msg_format(act, o_name, index_to_label(slot));
462 if (object_is_cursed(o_ptr))
464 /* Warn the player */
465 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
466 chg_virtue(V_HARMONY, -1);
469 o_ptr->ident |= (IDENT_SENSE);
472 /* The Stone Mask make the player turn into a vampire! */
473 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
475 /* Turn into a vampire */
476 change_race(RACE_VAMPIRE, "");
479 /* Recalculate bonuses */
480 p_ptr->update |= (PU_BONUS);
482 /* Recalculate torch */
483 p_ptr->update |= (PU_TORCH);
485 /* Recalculate mana */
486 p_ptr->update |= (PU_MANA);
488 p_ptr->redraw |= (PR_EQUIPPY);
490 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
497 * @param item 持ち替えを行いたい装備部位ID
500 void kamaenaoshi(INVENTORY_IDX item)
502 object_type *o_ptr, *new_o_ptr;
503 char o_name[MAX_NLEN];
505 if (item == INVEN_RARM)
507 if (buki_motteruka(INVEN_LARM))
509 o_ptr = &inventory[INVEN_LARM];
510 object_desc(o_name, o_ptr, 0);
512 if (!object_is_cursed(o_ptr))
514 new_o_ptr = &inventory[INVEN_RARM];
515 object_copy(new_o_ptr, o_ptr);
516 p_ptr->total_weight += o_ptr->weight;
517 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
518 inven_item_optimize(INVEN_LARM);
519 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
520 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
522 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
523 (left_hander ? _("左手", "left") : _("右手", "right")));
527 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
528 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
532 else if (item == INVEN_LARM)
534 o_ptr = &inventory[INVEN_RARM];
535 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
537 if (buki_motteruka(INVEN_RARM))
539 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
540 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
542 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
544 new_o_ptr = &inventory[INVEN_LARM];
545 object_copy(new_o_ptr, o_ptr);
546 p_ptr->total_weight += o_ptr->weight;
547 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
548 inven_item_optimize(INVEN_RARM);
549 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
556 * @brief 装備を外すコマンドのメインルーチン / Take off an item
559 void do_cmd_takeoff(void)
565 if (p_ptr->special_defense & KATA_MUSOU)
567 set_action(ACTION_NONE);
570 item_tester_no_ryoute = TRUE;
572 q = _("どれを装備からはずしますか? ", "Take off which item? ");
573 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
575 if (!get_item(&item, q, s, (USE_EQUIP))) return;
577 /* Get the item (in the pack) */
580 o_ptr = &inventory[item];
583 /* Get the item (on the floor) */
586 o_ptr = &o_list[0 - item];
591 if (object_is_cursed(o_ptr))
593 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
595 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
600 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
602 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
604 /* Hack -- Assume felt */
605 o_ptr->ident |= (IDENT_SENSE);
607 o_ptr->curse_flags = 0L;
610 o_ptr->feeling = FEEL_NONE;
612 /* Recalculate the bonuses */
613 p_ptr->update |= (PU_BONUS);
615 p_ptr->window |= (PW_EQUIP);
617 msg_print(_("呪いを打ち破った。", "You break the curse."));
621 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
622 p_ptr->energy_use = 50;
627 /* Take a partial turn */
628 p_ptr->energy_use = 50;
630 /* Take off the item */
631 (void)inven_takeoff(item, 255);
634 p_ptr->redraw |= (PR_EQUIPPY);
639 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
642 void do_cmd_drop(void)
651 if (p_ptr->special_defense & KATA_MUSOU)
653 set_action(ACTION_NONE);
656 item_tester_no_ryoute = TRUE;
657 q = _("どのアイテムを落としますか? ", "Drop which item? ");
658 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
660 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
662 /* Get the item (in the pack) */
665 o_ptr = &inventory[item];
668 /* Get the item (on the floor) */
671 o_ptr = &o_list[0 - item];
675 /* Hack -- Cannot remove cursed items */
676 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
678 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
683 /* See how many items */
684 if (o_ptr->number > 1)
687 amt = get_quantity(NULL, o_ptr->number);
689 /* Allow user abort */
690 if (amt <= 0) return;
694 /* Take a partial turn */
695 p_ptr->energy_use = 50;
697 /* Drop (some of) the item */
698 inven_drop(item, amt);
700 if (item >= INVEN_RARM)
706 p_ptr->redraw |= (PR_EQUIPPY);
710 * @brief オブジェクトが高位の魔法書かどうかを判定する
711 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
712 * @return オブジェクトが高位の魔法書ならばTRUEを返す
714 static bool high_level_book(object_type *o_ptr)
716 if ((o_ptr->tval == TV_LIFE_BOOK) ||
717 (o_ptr->tval == TV_SORCERY_BOOK) ||
718 (o_ptr->tval == TV_NATURE_BOOK) ||
719 (o_ptr->tval == TV_CHAOS_BOOK) ||
720 (o_ptr->tval == TV_DEATH_BOOK) ||
721 (o_ptr->tval == TV_TRUMP_BOOK) ||
722 (o_ptr->tval == TV_CRAFT_BOOK) ||
723 (o_ptr->tval == TV_DAEMON_BOOK) ||
724 (o_ptr->tval == TV_CRUSADE_BOOK) ||
725 (o_ptr->tval == TV_MUSIC_BOOK) ||
726 (o_ptr->tval == TV_HEX_BOOK))
739 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
742 void do_cmd_destroy(void)
752 object_type *q_ptr = &forge;
754 char o_name[MAX_NLEN];
755 char out_val[MAX_NLEN+40];
759 if (p_ptr->special_defense & KATA_MUSOU)
761 set_action(ACTION_NONE);
764 /* Hack -- force destruction */
765 if (command_arg > 0) force = TRUE;
767 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
768 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
770 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
772 /* Get the item (in the pack) */
775 o_ptr = &inventory[item];
778 /* Get the item (on the floor) */
781 o_ptr = &o_list[0 - item];
784 /* Verify unless quantity given beforehand */
785 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
787 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
789 /* Make a verification */
790 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
793 /* HACK : Add the line to message buffer */
794 message_add(out_val);
795 p_ptr->window |= (PW_MESSAGE);
798 /* Get an acceptable answer */
808 /* Erase the prompt */
812 if (i == 'y' || i == 'Y')
816 if (i == ESCAPE || i == 'n' || i == 'N')
823 /* Add an auto-destroy preference line */
824 if (autopick_autoregister(o_ptr))
826 /* Auto-destroy it */
827 autopick_alter_item(item, TRUE);
830 /* The object is already destroyed. */
836 /* See how many items */
837 if (o_ptr->number > 1)
840 amt = get_quantity(NULL, o_ptr->number);
842 /* Allow user abort */
843 if (amt <= 0) return;
847 old_number = o_ptr->number;
849 object_desc(o_name, o_ptr, 0);
850 o_ptr->number = old_number;
852 p_ptr->energy_use = 100;
854 /* Artifacts cannot be destroyed */
855 if (!can_player_destroy_object(o_ptr))
857 p_ptr->energy_use = 0;
859 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
863 object_copy(q_ptr, o_ptr);
865 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
866 sound(SOUND_DESTITEM);
868 /* Reduce the charges of rods/wands */
869 reduce_charges(o_ptr, amt);
871 /* Eliminate the item (from the pack) */
874 inven_item_increase(item, -amt);
875 inven_item_describe(item);
876 inven_item_optimize(item);
879 /* Eliminate the item (from the floor) */
882 floor_item_increase(0 - item, -amt);
883 floor_item_describe(0 - item);
884 floor_item_optimize(0 - item);
887 if (high_level_book(q_ptr))
889 bool gain_expr = FALSE;
891 if (p_ptr->prace == RACE_ANDROID)
894 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
898 else if (p_ptr->pclass == CLASS_PALADIN)
900 if (is_good_realm(p_ptr->realm1))
902 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
906 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
910 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
912 s32b tester_exp = p_ptr->max_exp / 20;
913 if (tester_exp > 10000) tester_exp = 10000;
914 if (q_ptr->sval < 3) tester_exp /= 4;
915 if (tester_exp<1) tester_exp = 1;
917 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
918 gain_exp(tester_exp * amt);
920 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
922 chg_virtue(V_UNLIFE, 1);
923 chg_virtue(V_VITALITY, -1);
925 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
927 chg_virtue(V_UNLIFE, -1);
928 chg_virtue(V_VITALITY, 1);
931 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
932 chg_virtue(V_ENCHANT, -1);
934 if (object_value_real(q_ptr) > 30000)
935 chg_virtue(V_SACRIFICE, 2);
937 else if (object_value_real(q_ptr) > 10000)
938 chg_virtue(V_SACRIFICE, 1);
941 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
942 chg_virtue(V_HARMONY, 1);
944 if (item >= INVEN_RARM) calc_android_exp();
949 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
952 void do_cmd_observe(void)
956 char o_name[MAX_NLEN];
960 item_tester_no_ryoute = TRUE;
962 q = _("どのアイテムを調べますか? ", "Examine which item? ");
963 s = _("調べられるアイテムがない。", "You have nothing to examine.");
965 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
967 /* Get the item (in the pack) */
970 o_ptr = &inventory[item];
973 /* Get the item (on the floor) */
976 o_ptr = &o_list[0 - item];
980 /* Require full knowledge */
981 if (!(o_ptr->ident & IDENT_MENTAL))
983 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
989 object_desc(o_name, o_ptr, 0);
990 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
991 /* Describe it fully */
992 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
998 * @brief アイテムの銘を消すコマンドのメインルーチン
999 * Remove the inscription from an object XXX Mention item (when done)?
1002 void do_cmd_uninscribe(void)
1008 item_tester_no_ryoute = TRUE;
1009 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1010 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1012 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1014 /* Get the item (in the pack) */
1017 o_ptr = &inventory[item];
1020 /* Get the item (on the floor) */
1023 o_ptr = &o_list[0 - item];
1026 /* Nothing to remove */
1027 if (!o_ptr->inscription)
1029 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1033 msg_print(_("銘を消した。", "Inscription removed."));
1035 /* Remove the incription */
1036 o_ptr->inscription = 0;
1038 /* Combine the pack */
1039 p_ptr->notice |= (PN_COMBINE);
1041 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1043 /* .や$の関係で, 再計算が必要なはず -- henkma */
1044 p_ptr->update |= (PU_BONUS);
1050 * @brief アイテムの銘を刻むコマンドのメインルーチン
1051 * Inscribe an object with a comment
1054 void do_cmd_inscribe(void)
1058 char o_name[MAX_NLEN];
1062 item_tester_no_ryoute = TRUE;
1063 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1064 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1066 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1068 /* Get the item (in the pack) */
1071 o_ptr = &inventory[item];
1074 /* Get the item (on the floor) */
1077 o_ptr = &o_list[0 - item];
1080 /* Describe the activity */
1081 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1083 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1086 /* Start with nothing */
1087 strcpy(out_val, "");
1089 /* Use old inscription */
1090 if (o_ptr->inscription)
1092 /* Start with the old inscription */
1093 strcpy(out_val, quark_str(o_ptr->inscription));
1096 /* Get a new inscription (possibly empty) */
1097 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1099 /* Save the inscription */
1100 o_ptr->inscription = quark_add(out_val);
1102 /* Combine the pack */
1103 p_ptr->notice |= (PN_COMBINE);
1105 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1107 /* .や$の関係で, 再計算が必要なはず -- henkma */
1108 p_ptr->update |= (PU_BONUS);
1115 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1116 * An "item_tester_hook" for refilling lanterns
1117 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1118 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1120 static bool item_tester_refill_lantern(object_type *o_ptr)
1122 /* Flasks of oil are okay */
1123 if (o_ptr->tval == TV_FLASK) return (TRUE);
1125 /* Laterns are okay */
1126 if ((o_ptr->tval == TV_LITE) &&
1127 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1129 /* Assume not okay */
1135 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1136 * Refill the players lamp (from the pack or floor)
1139 static void do_cmd_refill_lamp(void)
1149 /* Restrict the choices */
1150 item_tester_hook = item_tester_refill_lantern;
1153 q = "どの油つぼから注ぎますか? ";
1156 q = "Refill with which flask? ";
1157 s = "You have no flasks of oil.";
1160 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1162 /* Get the item (in the pack) */
1165 o_ptr = &inventory[item];
1168 /* Get the item (on the floor) */
1171 o_ptr = &o_list[0 - item];
1174 /* Take a partial turn */
1175 p_ptr->energy_use = 50;
1177 /* Access the lantern */
1178 j_ptr = &inventory[INVEN_LITE];
1181 j_ptr->xtra4 += o_ptr->xtra4;
1182 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1184 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1187 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1189 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1192 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1194 else if (j_ptr->xtra4 >= FUEL_LAMP)
1196 j_ptr->xtra4 = FUEL_LAMP;
1197 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1200 /* Decrease the item (from the pack) */
1203 inven_item_increase(item, -1);
1204 inven_item_describe(item);
1205 inven_item_optimize(item);
1208 /* Decrease the item (from the floor) */
1211 floor_item_increase(0 - item, -1);
1212 floor_item_describe(0 - item);
1213 floor_item_optimize(0 - item);
1216 /* Recalculate torch */
1217 p_ptr->update |= (PU_TORCH);
1222 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1223 * An "item_tester_hook" for refilling torches
1224 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1225 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1227 static bool item_tester_refill_torch(object_type *o_ptr)
1229 /* Torches are okay */
1230 if ((o_ptr->tval == TV_LITE) &&
1231 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1233 /* Assume not okay */
1239 * @brief 松明を束ねるコマンドのメインルーチン
1240 * Refuel the players torch (from the pack or floor)
1243 static void do_cmd_refill_torch(void)
1252 /* Restrict the choices */
1253 item_tester_hook = item_tester_refill_torch;
1255 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1256 s = _("他に松明がない。", "You have no extra torches.");
1258 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1260 /* Get the item (in the pack) */
1263 o_ptr = &inventory[item];
1266 /* Get the item (on the floor) */
1269 o_ptr = &o_list[0 - item];
1273 /* Take a partial turn */
1274 p_ptr->energy_use = 50;
1276 /* Access the primary torch */
1277 j_ptr = &inventory[INVEN_LITE];
1280 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1282 msg_print(_("松明を結合した。", "You combine the torches."));
1284 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1287 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1289 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1292 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1294 /* Over-fuel message */
1295 else if (j_ptr->xtra4 >= FUEL_TORCH)
1297 j_ptr->xtra4 = FUEL_TORCH;
1298 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1301 /* Refuel message */
1304 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1307 /* Decrease the item (from the pack) */
1310 inven_item_increase(item, -1);
1311 inven_item_describe(item);
1312 inven_item_optimize(item);
1315 /* Decrease the item (from the floor) */
1318 floor_item_increase(0 - item, -1);
1319 floor_item_describe(0 - item);
1320 floor_item_optimize(0 - item);
1323 /* Recalculate torch */
1324 p_ptr->update |= (PU_TORCH);
1329 * @brief 燃料を補充するコマンドのメインルーチン
1330 * Refill the players lamp, or restock his torches
1333 void do_cmd_refill(void)
1338 o_ptr = &inventory[INVEN_LITE];
1340 if (p_ptr->special_defense & KATA_MUSOU)
1342 set_action(ACTION_NONE);
1346 if (o_ptr->tval != TV_LITE)
1348 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1352 else if (o_ptr->sval == SV_LITE_LANTERN)
1354 do_cmd_refill_lamp();
1358 else if (o_ptr->sval == SV_LITE_TORCH)
1360 do_cmd_refill_torch();
1363 /* No torch to refill */
1366 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1372 * @brief ターゲットを設定するコマンドのメインルーチン
1376 void do_cmd_target(void)
1379 if (target_set(TARGET_KILL))
1381 msg_print(_("ターゲット決定。", "Target Selected."));
1384 /* Target aborted */
1387 msg_print(_("ターゲット解除。", "Target Aborted."));
1394 * @brief 周囲を見渡すコマンドのメインルーチン
1398 void do_cmd_look(void)
1400 p_ptr->window |= PW_MONSTER_LIST;
1404 if (target_set(TARGET_LOOK))
1406 msg_print(_("ターゲット決定。", "Target Selected."));
1412 * @brief 位置を確認するコマンドのメインルーチン
1413 * Allow the player to examine other sectors on the map
1416 void do_cmd_locate(void)
1418 int dir, y1, x1, y2, x2;
1426 get_screen_size(&wid, &hgt);
1429 /* Start at current panel */
1430 y2 = y1 = panel_row_min;
1431 x2 = x1 = panel_col_min;
1433 /* Show panels until done */
1436 /* Describe the location */
1437 if ((y2 == y1) && (x2 == x1))
1440 strcpy(tmp_val, "真上");
1449 sprintf(tmp_val, "%s%s",
1450 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1451 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1453 sprintf(tmp_val, "%s%s of",
1454 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1455 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1460 /* Prepare to ask which way to look */
1461 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1462 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1463 y2 / (hgt / 2), y2 % (hgt / 2),
1464 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1466 /* Assume no direction */
1469 /* Get a direction */
1474 /* Get a command (or Cancel) */
1475 if (!get_com(out_val, &command, TRUE)) break;
1477 /* Extract the action (if any) */
1478 dir = get_keymap_dir(command);
1487 /* Apply the motion */
1488 if (change_panel(ddy[dir], ddx[dir]))
1496 /* Recenter the map around the player */
1499 p_ptr->update |= (PU_MONSTERS);
1501 p_ptr->redraw |= (PR_MAP);
1503 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1510 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1511 * Sorting hook -- Comp function -- see below
1512 * @param u モンスター種族情報の入れるポインタ
1514 * @param a 比較するモンスター種族のID1
1515 * @param b 比較するモンスター種族のID2
1516 * @return 2の方が大きければTRUEを返す
1517 * We use "u" to point to array of monster indexes,
1518 * and "v" to select the type of sorting to perform on "u".
1520 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1522 u16b *who = (u16b*)(u);
1524 u16b *why = (u16b*)(v);
1531 /* Sort by player kills */
1534 /* Extract player kills */
1535 z1 = r_info[w1].r_pkills;
1536 z2 = r_info[w2].r_pkills;
1538 /* Compare player kills */
1539 if (z1 < z2) return (TRUE);
1540 if (z1 > z2) return (FALSE);
1544 /* Sort by total kills */
1547 /* Extract total kills */
1548 z1 = r_info[w1].r_tkills;
1549 z2 = r_info[w2].r_tkills;
1551 /* Compare total kills */
1552 if (z1 < z2) return (TRUE);
1553 if (z1 > z2) return (FALSE);
1557 /* Sort by monster level */
1560 /* Extract levels */
1561 z1 = r_info[w1].level;
1562 z2 = r_info[w2].level;
1564 /* Compare levels */
1565 if (z1 < z2) return (TRUE);
1566 if (z1 > z2) return (FALSE);
1570 /* Sort by monster experience */
1573 /* Extract experience */
1574 z1 = r_info[w1].mexp;
1575 z2 = r_info[w2].mexp;
1577 /* Compare experience */
1578 if (z1 < z2) return (TRUE);
1579 if (z1 > z2) return (FALSE);
1583 /* Compare indexes */
1589 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1590 * Sorting hook -- Swap function -- see below
1591 * @param u モンスター種族情報の入れるポインタ
1593 * @param a スワップするモンスター種族のID1
1594 * @param b スワップするモンスター種族のID2
1597 * We use "u" to point to array of monster indexes,
1598 * and "v" to select the type of sorting to perform.
1600 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1602 u16b *who = (u16b*)(u);
1618 * @brief モンスターの思い出を見るコマンドのメインルーチン
1619 * Identify a character, allow recall of monsters
1623 * Several "special" responses recall "multiple" monsters:
1625 * ^U (all unique monsters)
1626 * ^N (all non-unique monsters)
1628 * The responses may be sorted in several ways, see below.
1630 * Note that the player ghosts are ignored.
1633 void do_cmd_query_symbol(void)
1647 bool recall = FALSE;
1652 /* Get a character, or abort */
1653 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1654 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1656 /* Find that character info, and describe it */
1657 for (i = 0; ident_info[i]; ++i)
1659 if (sym == ident_info[i][0]) break;
1661 if (sym == KTRL('A'))
1664 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1666 else if (sym == KTRL('U'))
1669 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1671 else if (sym == KTRL('N'))
1674 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1676 else if (sym == KTRL('R'))
1679 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1681 /* XTRA HACK WHATSEARCH */
1682 else if (sym == KTRL('M'))
1685 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1690 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1692 else if (ident_info[i])
1694 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1698 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1701 /* Display the result */
1704 /* Allocate the "who" array */
1705 C_MAKE(who, max_r_idx, IDX);
1707 /* Collect matching monsters */
1708 for (n = 0, i = 1; i < max_r_idx; i++)
1710 monster_race *r_ptr = &r_info[i];
1712 /* Nothing to recall */
1713 if (!cheat_know && !r_ptr->r_sights) continue;
1715 /* Require non-unique monsters if needed */
1716 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1718 /* Require unique monsters if needed */
1719 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1721 /* Require ridable monsters if needed */
1722 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1724 /* XTRA HACK WHATSEARCH */
1730 for (xx = 0; temp[xx] && xx < 80; xx++)
1733 if (iskanji(temp[xx])) { xx++; continue; }
1735 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1739 strcpy(temp2, r_name + r_ptr->E_name);
1741 strcpy(temp2, r_name + r_ptr->name);
1743 for (xx = 0; temp2[xx] && xx < 80; xx++)
1744 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1747 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1749 if (my_strstr(temp2, temp))
1754 /* Collect "appropriate" monsters */
1755 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1758 /* Nothing to recall */
1761 /* Free the "who" array */
1762 C_KILL(who, max_r_idx, IDX);
1768 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1778 /* Select the sort method */
1779 ang_sort_comp = ang_sort_comp_hook;
1780 ang_sort_swap = ang_sort_swap_hook;
1782 /* Sort the array */
1783 ang_sort(who, &why, n);
1785 /* Sort by kills (and level) */
1792 /* Catch "escape" */
1795 /* Free the "who" array */
1796 C_KILL(who, max_r_idx, IDX);
1801 /* Sort if needed */
1804 /* Select the sort method */
1805 ang_sort_comp = ang_sort_comp_hook;
1806 ang_sort_swap = ang_sort_swap_hook;
1808 /* Sort the array */
1809 ang_sort(who, &why, n);
1813 /* Start at the end */
1816 /* Scan the monster memory */
1819 /* Extract a race */
1822 /* Hack -- Auto-recall */
1823 monster_race_track(r_idx);
1834 /* Recall on screen */
1835 screen_roff(who[i], 0);
1838 /* Hack -- Begin the prompt */
1841 /* Hack -- Complete the prompt */
1842 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1854 /* Normal commands */
1855 if (query != 'r') break;
1862 if (query == ESCAPE) break;
1864 /* Move to "prev" monster */
1870 if (!expand_list) break;
1874 /* Move to "next" monster */
1880 if (!expand_list) break;
1885 /* Free the "who" array */
1886 C_KILL(who, max_r_idx, IDX);
1888 /* Re-display the identity */
1893 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1897 * XXX - Add actions for other item types
1899 void do_cmd_use(void)
1905 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1907 set_action(ACTION_NONE);
1910 item_tester_no_ryoute = TRUE;
1911 item_tester_hook = item_tester_hook_use;
1913 q = _("どれを使いますか?", "Use which item? ");
1914 s = _("使えるものがありません。", "You have nothing to use.");
1916 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1918 /* Get the item (in the pack) */
1921 o_ptr = &inventory[item];
1923 /* Get the item (on the floor) */
1926 o_ptr = &o_list[0 - item];
1929 switch (o_ptr->tval)
1941 do_cmd_eat_food_aux(item);
1948 do_cmd_aim_wand_aux(item);
1955 do_cmd_use_staff_aux(item);
1962 do_cmd_zap_rod_aux(item);
1966 /* Quaff a potion */
1969 do_cmd_quaff_potion_aux(item);
1976 /* Check some conditions */
1979 msg_print(_("目が見えない。", "You can't see anything."));
1984 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
1987 if (p_ptr->confused)
1989 msg_print(_("混乱していて読めない!", "You are too confused!"));
1993 do_cmd_read_scroll_aux(item, TRUE);
2002 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2006 /* Activate an artifact */
2009 do_cmd_activate_aux(item);