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 */
113 (void)show_equip(0, 0L);
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;
211 /* Choose a weapon from the equipment only */
212 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
213 s = _("おっと。", "Oops.");
214 if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
215 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
218 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
220 /* Both arms are already used by non-weapon */
221 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
222 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
224 /* Restrict the choices */
225 item_tester_hook = item_tester_hook_mochikae;
228 q = _("どちらの手に装備しますか?", "Equip which hand? ");
229 s = _("おっと。", "Oops.");
230 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
239 /* Asking for dual wielding */
240 if (slot == INVEN_LARM)
242 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
245 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
247 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
250 /* Both arms are already used */
251 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
253 /* Restrict the choices */
254 item_tester_hook = item_tester_hook_mochikae;
257 q = _("どちらの手に装備しますか?", "Equip which hand? ");
258 s = _("おっと。", "Oops.");
260 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
261 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
262 need_switch_wielding = INVEN_RARM;
268 /* Choose a ring slot */
269 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
271 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
275 q = _("どちらの手に装備しますか?", "Equip which hand? ");
277 s = _("おっと。", "Oops.");
279 /* Restrict the choices */
280 select_ring_slot = TRUE;
282 if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
284 select_ring_slot = FALSE;
287 select_ring_slot = FALSE;
291 /* Prevent wielding into a cursed slot */
292 if (object_is_cursed(&inventory[slot]))
294 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
297 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
299 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
302 /* Cancel the command */
307 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
308 ((o_ptr->ident & IDENT_SENSE) &&
309 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
311 char dummy[MAX_NLEN+80];
313 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
314 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
316 if (!get_check(dummy)) return;
319 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
321 char dummy[MAX_NLEN+80];
323 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
326 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
328 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
329 sprintf(dummy, "Do you become a vampire?");
332 if (!get_check(dummy)) return;
335 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
337 object_type *slot_o_ptr = &inventory[slot];
338 object_type *switch_o_ptr = &inventory[need_switch_wielding];
339 object_type object_tmp;
340 object_type *otmp_ptr = &object_tmp;
341 char switch_name[MAX_NLEN];
343 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
345 object_copy(otmp_ptr, switch_o_ptr);
346 object_copy(switch_o_ptr, slot_o_ptr);
347 object_copy(slot_o_ptr, otmp_ptr);
349 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
350 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
351 (left_hander ? _("右手", "right") : _("左手", "left")));
352 slot = need_switch_wielding;
355 check_find_art_quest_completion(o_ptr);
357 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
359 identify_item(o_ptr);
361 /* Auto-inscription */
362 autopick_alter_item(item, FALSE);
365 p_ptr->energy_use = 100;
368 /* Obtain local object */
369 object_copy(q_ptr, o_ptr);
371 /* Modify quantity */
374 /* Decrease the item (from the pack) */
377 inven_item_increase(item, -1);
378 inven_item_optimize(item);
381 /* Decrease the item (from the floor) */
384 floor_item_increase(0 - item, -1);
385 floor_item_optimize(0 - item);
388 /* Access the wield slot */
389 o_ptr = &inventory[slot];
391 /* Take off existing item */
394 /* Take off existing item */
395 (void)inven_takeoff(slot, 255);
398 /* Wear the new stuff */
399 object_copy(o_ptr, q_ptr);
401 /* Player touches it */
402 o_ptr->marked |= OM_TOUCHED;
404 /* Increase the weight */
405 p_ptr->total_weight += q_ptr->weight;
407 /* Increment the equip counter by hand */
411 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
412 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
413 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
415 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
416 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
417 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
420 /* Where is the item now */
424 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
425 act = STR_WIELD_ARMS;
427 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
431 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
432 act = STR_WIELD_ARMS;
434 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
438 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
442 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
446 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
450 object_desc(o_name, o_ptr, 0);
451 msg_format(act, o_name, index_to_label(slot));
454 if (object_is_cursed(o_ptr))
456 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
457 chg_virtue(V_HARMONY, -1);
460 o_ptr->ident |= (IDENT_SENSE);
463 /* The Stone Mask make the player turn into a vampire! */
464 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
466 /* Turn into a vampire */
467 change_race(RACE_VAMPIRE, "");
470 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
471 p_ptr->redraw |= (PR_EQUIPPY);
472 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
479 * @param item 持ち替えを行いたい装備部位ID
482 void kamaenaoshi(INVENTORY_IDX item)
484 object_type *o_ptr, *new_o_ptr;
485 char o_name[MAX_NLEN];
487 if (item == INVEN_RARM)
489 if (buki_motteruka(INVEN_LARM))
491 o_ptr = &inventory[INVEN_LARM];
492 object_desc(o_name, o_ptr, 0);
494 if (!object_is_cursed(o_ptr))
496 new_o_ptr = &inventory[INVEN_RARM];
497 object_copy(new_o_ptr, o_ptr);
498 p_ptr->total_weight += o_ptr->weight;
499 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
500 inven_item_optimize(INVEN_LARM);
501 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
502 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
504 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
505 (left_hander ? _("左手", "left") : _("右手", "right")));
509 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
510 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
514 else if (item == INVEN_LARM)
516 o_ptr = &inventory[INVEN_RARM];
517 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
519 if (buki_motteruka(INVEN_RARM))
521 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
522 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
524 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
526 new_o_ptr = &inventory[INVEN_LARM];
527 object_copy(new_o_ptr, o_ptr);
528 p_ptr->total_weight += o_ptr->weight;
529 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
530 inven_item_optimize(INVEN_RARM);
531 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
538 * @brief 装備を外すコマンドのメインルーチン / Take off an item
541 void do_cmd_takeoff(void)
547 if (p_ptr->special_defense & KATA_MUSOU)
549 set_action(ACTION_NONE);
552 q = _("どれを装備からはずしますか? ", "Take off which item? ");
553 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
555 if (!get_item(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
557 /* Get the item (in the pack) */
560 o_ptr = &inventory[item];
563 /* Get the item (on the floor) */
566 o_ptr = &o_list[0 - item];
571 if (object_is_cursed(o_ptr))
573 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
575 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
580 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
582 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
584 o_ptr->ident |= (IDENT_SENSE);
585 o_ptr->curse_flags = 0L;
586 o_ptr->feeling = FEEL_NONE;
588 p_ptr->update |= (PU_BONUS);
589 p_ptr->window |= (PW_EQUIP);
591 msg_print(_("呪いを打ち破った。", "You break the curse."));
595 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
596 p_ptr->energy_use = 50;
601 /* Take a partial turn */
602 p_ptr->energy_use = 50;
604 /* Take off the item */
605 (void)inven_takeoff(item, 255);
608 p_ptr->redraw |= (PR_EQUIPPY);
613 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
616 void do_cmd_drop(void)
625 if (p_ptr->special_defense & KATA_MUSOU)
627 set_action(ACTION_NONE);
630 q = _("どのアイテムを落としますか? ", "Drop which item? ");
631 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
633 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT))) return;
635 /* Get the item (in the pack) */
638 o_ptr = &inventory[item];
641 /* Get the item (on the floor) */
644 o_ptr = &o_list[0 - item];
648 /* Hack -- Cannot remove cursed items */
649 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
651 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
656 /* See how many items */
657 if (o_ptr->number > 1)
660 amt = get_quantity(NULL, o_ptr->number);
662 /* Allow user abort */
663 if (amt <= 0) return;
667 /* Take a partial turn */
668 p_ptr->energy_use = 50;
670 /* Drop (some of) the item */
671 inven_drop(item, amt);
673 if (item >= INVEN_RARM)
679 p_ptr->redraw |= (PR_EQUIPPY);
683 * @brief オブジェクトが高位の魔法書かどうかを判定する
684 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
685 * @return オブジェクトが高位の魔法書ならばTRUEを返す
687 static bool high_level_book(object_type *o_ptr)
689 if ((o_ptr->tval == TV_LIFE_BOOK) ||
690 (o_ptr->tval == TV_SORCERY_BOOK) ||
691 (o_ptr->tval == TV_NATURE_BOOK) ||
692 (o_ptr->tval == TV_CHAOS_BOOK) ||
693 (o_ptr->tval == TV_DEATH_BOOK) ||
694 (o_ptr->tval == TV_TRUMP_BOOK) ||
695 (o_ptr->tval == TV_CRAFT_BOOK) ||
696 (o_ptr->tval == TV_DAEMON_BOOK) ||
697 (o_ptr->tval == TV_CRUSADE_BOOK) ||
698 (o_ptr->tval == TV_MUSIC_BOOK) ||
699 (o_ptr->tval == TV_HEX_BOOK))
712 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
715 void do_cmd_destroy(void)
725 object_type *q_ptr = &forge;
727 char o_name[MAX_NLEN];
728 char out_val[MAX_NLEN+40];
732 if (p_ptr->special_defense & KATA_MUSOU)
734 set_action(ACTION_NONE);
737 /* Hack -- force destruction */
738 if (command_arg > 0) force = TRUE;
740 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
741 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
743 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
745 /* Get the item (in the pack) */
748 o_ptr = &inventory[item];
751 /* Get the item (on the floor) */
754 o_ptr = &o_list[0 - item];
757 /* Verify unless quantity given beforehand */
758 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
760 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
762 /* Make a verification */
763 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
766 /* HACK : Add the line to message buffer */
767 message_add(out_val);
768 p_ptr->window |= (PW_MESSAGE);
771 /* Get an acceptable answer */
781 /* Erase the prompt */
785 if (i == 'y' || i == 'Y')
789 if (i == ESCAPE || i == 'n' || i == 'N')
796 /* Add an auto-destroy preference line */
797 if (autopick_autoregister(o_ptr))
799 /* Auto-destroy it */
800 autopick_alter_item(item, TRUE);
803 /* The object is already destroyed. */
809 /* See how many items */
810 if (o_ptr->number > 1)
813 amt = get_quantity(NULL, o_ptr->number);
815 /* Allow user abort */
816 if (amt <= 0) return;
820 old_number = o_ptr->number;
822 object_desc(o_name, o_ptr, 0);
823 o_ptr->number = old_number;
825 p_ptr->energy_use = 100;
827 /* Artifacts cannot be destroyed */
828 if (!can_player_destroy_object(o_ptr))
830 p_ptr->energy_use = 0;
832 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
836 object_copy(q_ptr, o_ptr);
838 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
839 sound(SOUND_DESTITEM);
841 /* Reduce the charges of rods/wands */
842 reduce_charges(o_ptr, amt);
844 /* Eliminate the item (from the pack) */
847 inven_item_increase(item, -amt);
848 inven_item_describe(item);
849 inven_item_optimize(item);
852 /* Eliminate the item (from the floor) */
855 floor_item_increase(0 - item, -amt);
856 floor_item_describe(0 - item);
857 floor_item_optimize(0 - item);
860 if (high_level_book(q_ptr))
862 bool gain_expr = FALSE;
864 if (p_ptr->prace == RACE_ANDROID)
867 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
871 else if (p_ptr->pclass == CLASS_PALADIN)
873 if (is_good_realm(p_ptr->realm1))
875 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
879 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
883 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
885 s32b tester_exp = p_ptr->max_exp / 20;
886 if (tester_exp > 10000) tester_exp = 10000;
887 if (q_ptr->sval < 3) tester_exp /= 4;
888 if (tester_exp<1) tester_exp = 1;
890 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
891 gain_exp(tester_exp * amt);
893 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
895 chg_virtue(V_UNLIFE, 1);
896 chg_virtue(V_VITALITY, -1);
898 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
900 chg_virtue(V_UNLIFE, -1);
901 chg_virtue(V_VITALITY, 1);
904 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
905 chg_virtue(V_ENCHANT, -1);
907 if (object_value_real(q_ptr) > 30000)
908 chg_virtue(V_SACRIFICE, 2);
910 else if (object_value_real(q_ptr) > 10000)
911 chg_virtue(V_SACRIFICE, 1);
914 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
915 chg_virtue(V_HARMONY, 1);
917 if (item >= INVEN_RARM) calc_android_exp();
922 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
925 void do_cmd_observe(void)
929 char o_name[MAX_NLEN];
933 q = _("どのアイテムを調べますか? ", "Examine which item? ");
934 s = _("調べられるアイテムがない。", "You have nothing to examine.");
936 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
938 /* Get the item (in the pack) */
941 o_ptr = &inventory[item];
944 /* Get the item (on the floor) */
947 o_ptr = &o_list[0 - item];
951 /* Require full knowledge */
952 if (!(o_ptr->ident & IDENT_MENTAL))
954 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
960 object_desc(o_name, o_ptr, 0);
961 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
962 /* Describe it fully */
963 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
969 * @brief アイテムの銘を消すコマンドのメインルーチン
970 * Remove the inscription from an object XXX Mention item (when done)?
973 void do_cmd_uninscribe(void)
979 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
980 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
982 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
984 /* Get the item (in the pack) */
987 o_ptr = &inventory[item];
990 /* Get the item (on the floor) */
993 o_ptr = &o_list[0 - item];
996 /* Nothing to remove */
997 if (!o_ptr->inscription)
999 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1003 msg_print(_("銘を消した。", "Inscription removed."));
1005 /* Remove the incription */
1006 o_ptr->inscription = 0;
1008 /* Combine the pack */
1009 p_ptr->notice |= (PN_COMBINE);
1011 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1013 /* .や$の関係で, 再計算が必要なはず -- henkma */
1014 p_ptr->update |= (PU_BONUS);
1020 * @brief アイテムの銘を刻むコマンドのメインルーチン
1021 * Inscribe an object with a comment
1024 void do_cmd_inscribe(void)
1028 char o_name[MAX_NLEN];
1032 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1033 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1035 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1037 /* Get the item (in the pack) */
1040 o_ptr = &inventory[item];
1043 /* Get the item (on the floor) */
1046 o_ptr = &o_list[0 - item];
1049 /* Describe the activity */
1050 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1052 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1055 /* Start with nothing */
1056 strcpy(out_val, "");
1058 /* Use old inscription */
1059 if (o_ptr->inscription)
1061 /* Start with the old inscription */
1062 strcpy(out_val, quark_str(o_ptr->inscription));
1065 /* Get a new inscription (possibly empty) */
1066 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1068 /* Save the inscription */
1069 o_ptr->inscription = quark_add(out_val);
1071 /* Combine the pack */
1072 p_ptr->notice |= (PN_COMBINE);
1074 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1076 /* .や$の関係で, 再計算が必要なはず -- henkma */
1077 p_ptr->update |= (PU_BONUS);
1084 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1085 * An "item_tester_hook" for refilling lanterns
1086 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1087 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1089 static bool item_tester_refill_lantern(object_type *o_ptr)
1091 /* Flasks of oil are okay */
1092 if (o_ptr->tval == TV_FLASK) return (TRUE);
1094 /* Laterns are okay */
1095 if ((o_ptr->tval == TV_LITE) &&
1096 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1098 /* Assume not okay */
1104 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1105 * Refill the players lamp (from the pack or floor)
1108 static void do_cmd_refill_lamp(void)
1118 /* Restrict the choices */
1119 item_tester_hook = item_tester_refill_lantern;
1122 q = "どの油つぼから注ぎますか? ";
1125 q = "Refill with which flask? ";
1126 s = "You have no flasks of oil.";
1129 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1131 /* Get the item (in the pack) */
1134 o_ptr = &inventory[item];
1137 /* Get the item (on the floor) */
1140 o_ptr = &o_list[0 - item];
1143 /* Take a partial turn */
1144 p_ptr->energy_use = 50;
1146 /* Access the lantern */
1147 j_ptr = &inventory[INVEN_LITE];
1150 j_ptr->xtra4 += o_ptr->xtra4;
1151 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1153 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1156 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1158 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1161 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1163 else if (j_ptr->xtra4 >= FUEL_LAMP)
1165 j_ptr->xtra4 = FUEL_LAMP;
1166 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1169 /* Decrease the item (from the pack) */
1172 inven_item_increase(item, -1);
1173 inven_item_describe(item);
1174 inven_item_optimize(item);
1177 /* Decrease the item (from the floor) */
1180 floor_item_increase(0 - item, -1);
1181 floor_item_describe(0 - item);
1182 floor_item_optimize(0 - item);
1185 /* Recalculate torch */
1186 p_ptr->update |= (PU_TORCH);
1191 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1192 * An "item_tester_hook" for refilling torches
1193 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1194 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1196 static bool item_tester_refill_torch(object_type *o_ptr)
1198 /* Torches are okay */
1199 if ((o_ptr->tval == TV_LITE) &&
1200 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1202 /* Assume not okay */
1208 * @brief 松明を束ねるコマンドのメインルーチン
1209 * Refuel the players torch (from the pack or floor)
1212 static void do_cmd_refill_torch(void)
1221 /* Restrict the choices */
1222 item_tester_hook = item_tester_refill_torch;
1224 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1225 s = _("他に松明がない。", "You have no extra torches.");
1227 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1229 /* Get the item (in the pack) */
1232 o_ptr = &inventory[item];
1235 /* Get the item (on the floor) */
1238 o_ptr = &o_list[0 - item];
1242 /* Take a partial turn */
1243 p_ptr->energy_use = 50;
1245 /* Access the primary torch */
1246 j_ptr = &inventory[INVEN_LITE];
1249 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1251 msg_print(_("松明を結合した。", "You combine the torches."));
1253 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1256 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1258 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1261 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1263 /* Over-fuel message */
1264 else if (j_ptr->xtra4 >= FUEL_TORCH)
1266 j_ptr->xtra4 = FUEL_TORCH;
1267 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1270 /* Refuel message */
1273 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1276 /* Decrease the item (from the pack) */
1279 inven_item_increase(item, -1);
1280 inven_item_describe(item);
1281 inven_item_optimize(item);
1284 /* Decrease the item (from the floor) */
1287 floor_item_increase(0 - item, -1);
1288 floor_item_describe(0 - item);
1289 floor_item_optimize(0 - item);
1292 /* Recalculate torch */
1293 p_ptr->update |= (PU_TORCH);
1298 * @brief 燃料を補充するコマンドのメインルーチン
1299 * Refill the players lamp, or restock his torches
1302 void do_cmd_refill(void)
1307 o_ptr = &inventory[INVEN_LITE];
1309 if (p_ptr->special_defense & KATA_MUSOU)
1311 set_action(ACTION_NONE);
1315 if (o_ptr->tval != TV_LITE)
1317 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1321 else if (o_ptr->sval == SV_LITE_LANTERN)
1323 do_cmd_refill_lamp();
1327 else if (o_ptr->sval == SV_LITE_TORCH)
1329 do_cmd_refill_torch();
1332 /* No torch to refill */
1335 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1341 * @brief ターゲットを設定するコマンドのメインルーチン
1345 void do_cmd_target(void)
1348 if (target_set(TARGET_KILL))
1350 msg_print(_("ターゲット決定。", "Target Selected."));
1353 /* Target aborted */
1356 msg_print(_("ターゲット解除。", "Target Aborted."));
1363 * @brief 周囲を見渡すコマンドのメインルーチン
1367 void do_cmd_look(void)
1369 p_ptr->window |= PW_MONSTER_LIST;
1373 if (target_set(TARGET_LOOK))
1375 msg_print(_("ターゲット決定。", "Target Selected."));
1381 * @brief 位置を確認するコマンドのメインルーチン
1382 * Allow the player to examine other sectors on the map
1385 void do_cmd_locate(void)
1387 int dir, y1, x1, y2, x2;
1395 get_screen_size(&wid, &hgt);
1398 /* Start at current panel */
1399 y2 = y1 = panel_row_min;
1400 x2 = x1 = panel_col_min;
1402 /* Show panels until done */
1405 /* Describe the location */
1406 if ((y2 == y1) && (x2 == x1))
1409 strcpy(tmp_val, "真上");
1418 sprintf(tmp_val, "%s%s",
1419 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1420 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1422 sprintf(tmp_val, "%s%s of",
1423 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1424 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1429 /* Prepare to ask which way to look */
1430 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1431 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1432 y2 / (hgt / 2), y2 % (hgt / 2),
1433 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1435 /* Assume no direction */
1438 /* Get a direction */
1443 /* Get a command (or Cancel) */
1444 if (!get_com(out_val, &command, TRUE)) break;
1446 /* Extract the action (if any) */
1447 dir = get_keymap_dir(command);
1456 /* Apply the motion */
1457 if (change_panel(ddy[dir], ddx[dir]))
1465 /* Recenter the map around the player */
1468 p_ptr->update |= (PU_MONSTERS);
1470 p_ptr->redraw |= (PR_MAP);
1472 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1479 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1480 * Sorting hook -- Comp function -- see below
1481 * @param u モンスター種族情報の入れるポインタ
1483 * @param a 比較するモンスター種族のID1
1484 * @param b 比較するモンスター種族のID2
1485 * @return 2の方が大きければTRUEを返す
1486 * We use "u" to point to array of monster indexes,
1487 * and "v" to select the type of sorting to perform on "u".
1489 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1491 u16b *who = (u16b*)(u);
1493 u16b *why = (u16b*)(v);
1500 /* Sort by player kills */
1503 /* Extract player kills */
1504 z1 = r_info[w1].r_pkills;
1505 z2 = r_info[w2].r_pkills;
1507 /* Compare player kills */
1508 if (z1 < z2) return (TRUE);
1509 if (z1 > z2) return (FALSE);
1513 /* Sort by total kills */
1516 /* Extract total kills */
1517 z1 = r_info[w1].r_tkills;
1518 z2 = r_info[w2].r_tkills;
1520 /* Compare total kills */
1521 if (z1 < z2) return (TRUE);
1522 if (z1 > z2) return (FALSE);
1526 /* Sort by monster level */
1529 /* Extract levels */
1530 z1 = r_info[w1].level;
1531 z2 = r_info[w2].level;
1533 /* Compare levels */
1534 if (z1 < z2) return (TRUE);
1535 if (z1 > z2) return (FALSE);
1539 /* Sort by monster experience */
1542 /* Extract experience */
1543 z1 = r_info[w1].mexp;
1544 z2 = r_info[w2].mexp;
1546 /* Compare experience */
1547 if (z1 < z2) return (TRUE);
1548 if (z1 > z2) return (FALSE);
1552 /* Compare indexes */
1558 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1559 * Sorting hook -- Swap function -- see below
1560 * @param u モンスター種族情報の入れるポインタ
1562 * @param a スワップするモンスター種族のID1
1563 * @param b スワップするモンスター種族のID2
1566 * We use "u" to point to array of monster indexes,
1567 * and "v" to select the type of sorting to perform.
1569 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1571 u16b *who = (u16b*)(u);
1587 * @brief モンスターの思い出を見るコマンドのメインルーチン
1588 * Identify a character, allow recall of monsters
1592 * Several "special" responses recall "multiple" monsters:
1594 * ^U (all unique monsters)
1595 * ^N (all non-unique monsters)
1597 * The responses may be sorted in several ways, see below.
1599 * Note that the player ghosts are ignored.
1602 void do_cmd_query_symbol(void)
1616 bool recall = FALSE;
1621 /* Get a character, or abort */
1622 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1623 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1625 /* Find that character info, and describe it */
1626 for (i = 0; ident_info[i]; ++i)
1628 if (sym == ident_info[i][0]) break;
1630 if (sym == KTRL('A'))
1633 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1635 else if (sym == KTRL('U'))
1638 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1640 else if (sym == KTRL('N'))
1643 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1645 else if (sym == KTRL('R'))
1648 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1650 /* XTRA HACK WHATSEARCH */
1651 else if (sym == KTRL('M'))
1654 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1659 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1661 else if (ident_info[i])
1663 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1667 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1670 /* Display the result */
1673 /* Allocate the "who" array */
1674 C_MAKE(who, max_r_idx, IDX);
1676 /* Collect matching monsters */
1677 for (n = 0, i = 1; i < max_r_idx; i++)
1679 monster_race *r_ptr = &r_info[i];
1681 /* Nothing to recall */
1682 if (!cheat_know && !r_ptr->r_sights) continue;
1684 /* Require non-unique monsters if needed */
1685 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1687 /* Require unique monsters if needed */
1688 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1690 /* Require ridable monsters if needed */
1691 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1693 /* XTRA HACK WHATSEARCH */
1699 for (xx = 0; temp[xx] && xx < 80; xx++)
1702 if (iskanji(temp[xx])) { xx++; continue; }
1704 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1708 strcpy(temp2, r_name + r_ptr->E_name);
1710 strcpy(temp2, r_name + r_ptr->name);
1712 for (xx = 0; temp2[xx] && xx < 80; xx++)
1713 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1716 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1718 if (my_strstr(temp2, temp))
1723 /* Collect "appropriate" monsters */
1724 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1727 /* Nothing to recall */
1730 /* Free the "who" array */
1731 C_KILL(who, max_r_idx, IDX);
1737 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1747 /* Select the sort method */
1748 ang_sort_comp = ang_sort_comp_hook;
1749 ang_sort_swap = ang_sort_swap_hook;
1751 /* Sort the array */
1752 ang_sort(who, &why, n);
1754 /* Sort by kills (and level) */
1761 /* Catch "escape" */
1764 /* Free the "who" array */
1765 C_KILL(who, max_r_idx, IDX);
1770 /* Sort if needed */
1773 /* Select the sort method */
1774 ang_sort_comp = ang_sort_comp_hook;
1775 ang_sort_swap = ang_sort_swap_hook;
1777 /* Sort the array */
1778 ang_sort(who, &why, n);
1782 /* Start at the end */
1785 /* Scan the monster memory */
1788 /* Extract a race */
1791 /* Hack -- Auto-recall */
1792 monster_race_track(r_idx);
1803 /* Recall on screen */
1804 screen_roff(who[i], 0);
1807 /* Hack -- Begin the prompt */
1810 /* Hack -- Complete the prompt */
1811 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1823 /* Normal commands */
1824 if (query != 'r') break;
1831 if (query == ESCAPE) break;
1833 /* Move to "prev" monster */
1839 if (!expand_list) break;
1843 /* Move to "next" monster */
1849 if (!expand_list) break;
1854 /* Free the "who" array */
1855 C_KILL(who, max_r_idx, IDX);
1857 /* Re-display the identity */
1862 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1866 * XXX - Add actions for other item types
1868 void do_cmd_use(void)
1874 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1876 set_action(ACTION_NONE);
1879 item_tester_hook = item_tester_hook_use;
1881 q = _("どれを使いますか?", "Use which item? ");
1882 s = _("使えるものがありません。", "You have nothing to use.");
1884 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1886 /* Get the item (in the pack) */
1889 o_ptr = &inventory[item];
1891 /* Get the item (on the floor) */
1894 o_ptr = &o_list[0 - item];
1897 switch (o_ptr->tval)
1909 do_cmd_eat_food_aux(item);
1916 do_cmd_aim_wand_aux(item);
1923 do_cmd_use_staff_aux(item);
1930 do_cmd_zap_rod_aux(item);
1934 /* Quaff a potion */
1937 do_cmd_quaff_potion_aux(item);
1944 /* Check some conditions */
1947 msg_print(_("目が見えない。", "You can't see anything."));
1952 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
1955 if (p_ptr->confused)
1957 msg_print(_("混乱していて読めない!", "You are too confused!"));
1961 do_cmd_read_scroll_aux(item, TRUE);
1970 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
1974 /* Activate an artifact */
1977 do_cmd_activate_aux(item);