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 "object-hook.h"
29 #include "player-status.h"
33 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
36 void do_cmd_inven(void)
40 /* Note that we are in "inventory" mode */
43 /* Note that we are in "inventory" mode */
44 if (easy_floor) command_wrk = (USE_INVEN);
47 /* Display the inventory */
48 (void)show_inven(0, USE_FULL);
51 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
52 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
53 (long int)((p_ptr->total_weight * 100) / weight_limit()));
55 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
56 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
57 (p_ptr->total_weight * 100) / weight_limit());
61 command_new = inkey();
64 /* Process "Escape" */
65 if (command_new == ESCAPE)
69 Term_get_size(&wid, &hgt);
73 command_gap = wid - 30;
76 /* Process normal keys */
79 /* Hack -- Use "display" mode */
86 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
89 void do_cmd_equip(void)
93 /* Note that we are in "equipment" mode */
96 /* Note that we are in "equipment" mode */
97 if (easy_floor) command_wrk = (USE_EQUIP);
100 (void)show_equip(0, USE_FULL);
104 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
105 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
106 (long int)((p_ptr->total_weight * 100) / weight_limit()));
108 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
109 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
110 (long int)((p_ptr->total_weight * 100) / weight_limit()));
114 command_new = inkey();
117 /* Process "Escape" */
118 if (command_new == ESCAPE)
122 Term_get_size(&wid, &hgt);
126 command_gap = wid - 30;
129 /* Process normal keys */
132 /* Enter "display" mode */
140 bool select_ring_slot = FALSE;
143 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
146 void do_cmd_wield(void)
148 OBJECT_IDX item, slot;
156 GAME_TEXT o_name[MAX_NLEN];
159 OBJECT_IDX need_switch_wielding = 0;
161 if (p_ptr->special_defense & KATA_MUSOU)
163 set_action(ACTION_NONE);
166 /* Restrict the choices */
167 item_tester_hook = item_tester_hook_wear;
169 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
170 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
172 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
176 slot = wield_slot(o_ptr);
180 /* Shields and some misc. items */
185 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
187 /* Restrict the choices */
188 item_tester_hook = item_tester_hook_melee_weapon;
190 /* Choose a weapon from the equipment only */
191 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
192 s = _("おっと。", "Oops.");
193 if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
194 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
197 else if (has_melee_weapon(INVEN_LARM)) slot = INVEN_RARM;
199 /* Both arms are already used by non-weapon */
200 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
201 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
203 /* Restrict the choices */
204 item_tester_hook = item_tester_hook_mochikae;
207 q = _("どちらの手に装備しますか?", "Equip which hand? ");
208 s = _("おっと。", "Oops.");
209 if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
218 /* Asking for dual wielding */
219 if (slot == INVEN_LARM)
221 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
224 else if (!inventory[INVEN_RARM].k_idx && has_melee_weapon(INVEN_LARM))
226 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
229 /* Both arms are already used */
230 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
232 /* Restrict the choices */
233 item_tester_hook = item_tester_hook_mochikae;
236 q = _("どちらの手に装備しますか?", "Equip which hand? ");
237 s = _("おっと。", "Oops.");
239 if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
240 if ((slot == INVEN_LARM) && !has_melee_weapon(INVEN_RARM))
241 need_switch_wielding = INVEN_RARM;
247 /* Choose a ring slot */
248 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
250 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
254 q = _("どちらの手に装備しますか?", "Equip which hand? ");
256 s = _("おっと。", "Oops.");
258 /* Restrict the choices */
259 select_ring_slot = TRUE;
261 if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
263 select_ring_slot = FALSE;
266 select_ring_slot = FALSE;
270 /* Prevent wielding into a cursed slot */
271 if (object_is_cursed(&inventory[slot]))
273 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
276 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
278 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
281 /* Cancel the command */
286 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
287 ((o_ptr->ident & IDENT_SENSE) &&
288 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
290 char dummy[MAX_NLEN+80];
292 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
293 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
295 if (!get_check(dummy)) return;
298 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
300 char dummy[MAX_NLEN+100];
302 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
304 sprintf(dummy, _("%sを装備すると吸血鬼になります。よろしいですか?",
305 "%s will transforms you into a vampire permanently when equiped. Do you become a vampire?"), o_name);
307 if (!get_check(dummy)) return;
310 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
312 object_type *slot_o_ptr = &inventory[slot];
313 object_type *switch_o_ptr = &inventory[need_switch_wielding];
314 object_type object_tmp;
315 object_type *otmp_ptr = &object_tmp;
316 GAME_TEXT switch_name[MAX_NLEN];
318 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
320 object_copy(otmp_ptr, switch_o_ptr);
321 object_copy(switch_o_ptr, slot_o_ptr);
322 object_copy(slot_o_ptr, otmp_ptr);
324 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
325 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
326 (left_hander ? _("右手", "right") : _("左手", "left")));
327 slot = need_switch_wielding;
330 check_find_art_quest_completion(o_ptr);
332 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
334 identify_item(o_ptr);
336 /* Auto-inscription */
337 autopick_alter_item(item, FALSE);
340 take_turn(p_ptr, 100);
343 /* Obtain local object */
344 object_copy(q_ptr, o_ptr);
346 /* Modify quantity */
349 /* Decrease the item (from the pack) */
352 inven_item_increase(item, -1);
353 inven_item_optimize(item);
356 /* Decrease the item (from the floor) */
359 floor_item_increase(0 - item, -1);
360 floor_item_optimize(0 - item);
363 /* Access the wield slot */
364 o_ptr = &inventory[slot];
366 /* Take off existing item */
369 /* Take off existing item */
370 (void)inven_takeoff(slot, 255);
373 /* Wear the new stuff */
374 object_copy(o_ptr, q_ptr);
376 o_ptr->marked |= OM_TOUCHED;
378 p_ptr->total_weight += q_ptr->weight;
380 /* Increment the equip counter by hand */
383 #define STR_WIELD_RARM _("%s(%c)を右手に装備した。", "You are wielding %s (%c) in your right hand.")
384 #define STR_WIELD_LARM _("%s(%c)を左手に装備した。", "You are wielding %s (%c) in your left hand.")
385 #define STR_WIELD_ARMS _("%s(%c)を両手で構えた。", "You are wielding %s (%c) with both hands.")
387 /* Where is the item now */
391 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
392 act = STR_WIELD_ARMS;
394 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
398 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
399 act = STR_WIELD_ARMS;
401 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
405 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
409 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
413 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
417 object_desc(o_name, o_ptr, 0);
418 msg_format(act, o_name, index_to_label(slot));
421 if (object_is_cursed(o_ptr))
423 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
424 chg_virtue(V_HARMONY, -1);
427 o_ptr->ident |= (IDENT_SENSE);
430 /* The Stone Mask make the player current_world_ptr->game_turn into a vampire! */
431 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
433 /* Turn into a vampire */
434 change_race(RACE_VAMPIRE, "");
437 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
438 p_ptr->redraw |= (PR_EQUIPPY);
439 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
446 * @param item 持ち替えを行いたい装備部位ID
449 void kamaenaoshi(INVENTORY_IDX item)
451 object_type *o_ptr, *new_o_ptr;
452 GAME_TEXT o_name[MAX_NLEN];
454 if (item == INVEN_RARM)
456 if (has_melee_weapon(INVEN_LARM))
458 o_ptr = &inventory[INVEN_LARM];
459 object_desc(o_name, o_ptr, 0);
461 if (!object_is_cursed(o_ptr))
463 new_o_ptr = &inventory[INVEN_RARM];
464 object_copy(new_o_ptr, o_ptr);
465 p_ptr->total_weight += o_ptr->weight;
466 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
467 inven_item_optimize(INVEN_LARM);
468 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
469 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
471 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
472 (left_hander ? _("左手", "left") : _("右手", "right")));
476 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
477 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
481 else if (item == INVEN_LARM)
483 o_ptr = &inventory[INVEN_RARM];
484 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
486 if (has_melee_weapon(INVEN_RARM))
488 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
489 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
491 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
493 new_o_ptr = &inventory[INVEN_LARM];
494 object_copy(new_o_ptr, o_ptr);
495 p_ptr->total_weight += o_ptr->weight;
496 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
497 inven_item_optimize(INVEN_RARM);
498 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
505 * @brief 装備を外すコマンドのメインルーチン / Take off an item
508 void do_cmd_takeoff(void)
514 if (p_ptr->special_defense & KATA_MUSOU)
516 set_action(ACTION_NONE);
519 q = _("どれを装備からはずしますか? ", "Take off which item? ");
520 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
522 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
526 if (object_is_cursed(o_ptr))
528 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
530 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
535 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
537 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
539 o_ptr->ident |= (IDENT_SENSE);
540 o_ptr->curse_flags = 0L;
541 o_ptr->feeling = FEEL_NONE;
543 p_ptr->update |= (PU_BONUS);
544 p_ptr->window |= (PW_EQUIP);
546 msg_print(_("呪いを打ち破った。", "You break the curse."));
550 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
551 take_turn(p_ptr, 50);
556 take_turn(p_ptr, 50);
558 /* Take off the item */
559 (void)inven_takeoff(item, 255);
562 p_ptr->redraw |= (PR_EQUIPPY);
567 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
570 void do_cmd_drop(void)
579 if (p_ptr->special_defense & KATA_MUSOU)
581 set_action(ACTION_NONE);
584 q = _("どのアイテムを落としますか? ", "Drop which item? ");
585 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
587 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
590 /* Hack -- Cannot remove cursed items */
591 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
593 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
597 if (o_ptr->number > 1)
599 amt = get_quantity(NULL, o_ptr->number);
600 if (amt <= 0) return;
603 take_turn(p_ptr, 50);
605 /* Drop (some of) the item */
606 inven_drop(item, amt);
608 if (item >= INVEN_RARM)
614 p_ptr->redraw |= (PR_EQUIPPY);
619 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
622 void do_cmd_destroy(void)
632 object_type *q_ptr = &forge;
634 GAME_TEXT o_name[MAX_NLEN];
635 char out_val[MAX_NLEN+40];
639 if (p_ptr->special_defense & KATA_MUSOU)
641 set_action(ACTION_NONE);
644 /* Hack -- force destruction */
645 if (command_arg > 0) force = TRUE;
647 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
648 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
650 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
653 /* Verify unless quantity given beforehand */
654 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
656 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
658 /* Make a verification */
659 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
662 /* HACK : Add the line to message buffer */
663 message_add(out_val);
664 p_ptr->window |= (PW_MESSAGE);
667 /* Get an acceptable answer */
677 /* Erase the prompt */
681 if (i == 'y' || i == 'Y')
685 if (i == ESCAPE || i == 'n' || i == 'N')
692 /* Add an auto-destroy preference line */
693 if (autopick_autoregister(o_ptr))
695 /* Auto-destroy it */
696 autopick_alter_item(item, TRUE);
699 /* The object is already destroyed. */
705 if (o_ptr->number > 1)
707 amt = get_quantity(NULL, o_ptr->number);
708 if (amt <= 0) return;
712 old_number = o_ptr->number;
714 object_desc(o_name, o_ptr, 0);
715 o_ptr->number = old_number;
717 take_turn(p_ptr, 100);
719 /* Artifacts cannot be destroyed */
720 if (!can_player_destroy_object(o_ptr))
724 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
728 object_copy(q_ptr, o_ptr);
730 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
731 sound(SOUND_DESTITEM);
733 /* Reduce the charges of rods/wands */
734 reduce_charges(o_ptr, amt);
736 /* Eliminate the item (from the pack) */
739 inven_item_increase(item, -amt);
740 inven_item_describe(item);
741 inven_item_optimize(item);
744 /* Eliminate the item (from the floor) */
747 floor_item_increase(0 - item, -amt);
748 floor_item_describe(0 - item);
749 floor_item_optimize(0 - item);
752 if (item_tester_high_level_book(q_ptr))
754 bool gain_expr = FALSE;
756 if (p_ptr->prace == RACE_ANDROID)
759 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
763 else if (p_ptr->pclass == CLASS_PALADIN)
765 if (is_good_realm(p_ptr->realm1))
767 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
771 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
775 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
777 s32b tester_exp = p_ptr->max_exp / 20;
778 if (tester_exp > 10000) tester_exp = 10000;
779 if (q_ptr->sval < 3) tester_exp /= 4;
780 if (tester_exp<1) tester_exp = 1;
782 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
783 gain_exp(tester_exp * amt);
785 if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
787 chg_virtue(V_UNLIFE, 1);
788 chg_virtue(V_VITALITY, -1);
790 else if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
792 chg_virtue(V_UNLIFE, -1);
793 chg_virtue(V_VITALITY, 1);
796 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
797 chg_virtue(V_ENCHANT, -1);
799 if (object_value_real(q_ptr) > 30000)
800 chg_virtue(V_SACRIFICE, 2);
802 else if (object_value_real(q_ptr) > 10000)
803 chg_virtue(V_SACRIFICE, 1);
806 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
807 chg_virtue(V_HARMONY, 1);
809 if (item >= INVEN_RARM) calc_android_exp();
814 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
817 void do_cmd_observe(void)
821 GAME_TEXT o_name[MAX_NLEN];
824 q = _("どのアイテムを調べますか? ", "Examine which item? ");
825 s = _("調べられるアイテムがない。", "You have nothing to examine.");
827 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
830 /* Require full knowledge */
831 if (!(o_ptr->ident & IDENT_MENTAL))
833 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
837 object_desc(o_name, o_ptr, 0);
838 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
839 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
845 * @brief アイテムの銘を消すコマンドのメインルーチン
846 * Remove the inscription from an object XXX Mention item (when done)?
849 void do_cmd_uninscribe(void)
855 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
856 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
858 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
861 /* Nothing to remove */
862 if (!o_ptr->inscription)
864 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
868 msg_print(_("銘を消した。", "Inscription removed."));
870 /* Remove the incription */
871 o_ptr->inscription = 0;
872 p_ptr->update |= (PU_COMBINE);
873 p_ptr->window |= (PW_INVEN | PW_EQUIP);
875 /* .や$の関係で, 再計算が必要なはず -- henkma */
876 p_ptr->update |= (PU_BONUS);
882 * @brief アイテムの銘を刻むコマンドのメインルーチン
883 * Inscribe an object with a comment
886 void do_cmd_inscribe(void)
890 GAME_TEXT o_name[MAX_NLEN];
894 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
895 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
897 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
900 /* Describe the activity */
901 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
903 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
906 /* Start with nothing */
909 /* Use old inscription */
910 if (o_ptr->inscription)
912 /* Start with the old inscription */
913 strcpy(out_val, quark_str(o_ptr->inscription));
916 /* Get a new inscription (possibly empty) */
917 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
919 /* Save the inscription */
920 o_ptr->inscription = quark_add(out_val);
921 p_ptr->update |= (PU_COMBINE);
922 p_ptr->window |= (PW_INVEN | PW_EQUIP);
924 /* .や$の関係で, 再計算が必要なはず -- henkma */
925 p_ptr->update |= (PU_BONUS);
931 * @brief ランタンに燃料を加えるコマンドのメインルーチン
932 * Refill the players lamp (from the pack or floor)
935 static void do_cmd_refill_lamp(void)
942 /* Restrict the choices */
943 item_tester_hook = item_tester_refill_lantern;
945 q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
946 s = _("油つぼがない。", "You have no flasks of oil.");
948 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
951 take_turn(p_ptr, 50);
953 /* Access the lantern */
954 j_ptr = &inventory[INVEN_LITE];
957 j_ptr->xtra4 += o_ptr->xtra4;
958 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
960 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
963 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
965 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
968 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
970 else if (j_ptr->xtra4 >= FUEL_LAMP)
972 j_ptr->xtra4 = FUEL_LAMP;
973 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
976 /* Decrease the item (from the pack) */
979 inven_item_increase(item, -1);
980 inven_item_describe(item);
981 inven_item_optimize(item);
984 /* Decrease the item (from the floor) */
987 floor_item_increase(0 - item, -1);
988 floor_item_describe(0 - item);
989 floor_item_optimize(0 - item);
992 p_ptr->update |= (PU_TORCH);
996 * @brief 松明を束ねるコマンドのメインルーチン
997 * Refuel the players torch (from the pack or floor)
1000 static void do_cmd_refill_torch(void)
1009 /* Restrict the choices */
1010 item_tester_hook = object_can_refill_torch;
1012 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1013 s = _("他に松明がない。", "You have no extra torches.");
1015 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1018 take_turn(p_ptr, 50);
1020 /* Access the primary torch */
1021 j_ptr = &inventory[INVEN_LITE];
1024 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1026 msg_print(_("松明を結合した。", "You combine the torches."));
1028 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1031 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1033 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1036 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1038 /* Over-fuel message */
1039 else if (j_ptr->xtra4 >= FUEL_TORCH)
1041 j_ptr->xtra4 = FUEL_TORCH;
1042 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1045 /* Refuel message */
1048 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1051 /* Decrease the item (from the pack) */
1054 inven_item_increase(item, -1);
1055 inven_item_describe(item);
1056 inven_item_optimize(item);
1059 /* Decrease the item (from the floor) */
1062 floor_item_increase(0 - item, -1);
1063 floor_item_describe(0 - item);
1064 floor_item_optimize(0 - item);
1067 p_ptr->update |= (PU_TORCH);
1072 * @brief 燃料を補充するコマンドのメインルーチン
1073 * Refill the players lamp, or restock his torches
1076 void do_cmd_refill(void)
1081 o_ptr = &inventory[INVEN_LITE];
1083 if (p_ptr->special_defense & KATA_MUSOU)
1085 set_action(ACTION_NONE);
1089 if (o_ptr->tval != TV_LITE)
1091 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1095 else if (o_ptr->sval == SV_LITE_LANTERN)
1097 do_cmd_refill_lamp();
1101 else if (o_ptr->sval == SV_LITE_TORCH)
1103 do_cmd_refill_torch();
1106 /* No torch to refill */
1109 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1115 * @brief ターゲットを設定するコマンドのメインルーチン
1119 void do_cmd_target(void)
1121 if (p_ptr->wild_mode) return;
1124 if (target_set(TARGET_KILL))
1126 msg_print(_("ターゲット決定。", "Target Selected."));
1129 /* Target aborted */
1132 msg_print(_("ターゲット解除。", "Target Aborted."));
1139 * @brief 周囲を見渡すコマンドのメインルーチン
1143 void do_cmd_look(void)
1145 p_ptr->window |= PW_MONSTER_LIST;
1149 if (target_set(TARGET_LOOK))
1151 msg_print(_("ターゲット決定。", "Target Selected."));
1157 * @brief 位置を確認するコマンドのメインルーチン
1158 * Allow the player to examine other sectors on the map
1161 void do_cmd_locate(void)
1164 POSITION y1, x1, y2, x2;
1165 GAME_TEXT tmp_val[80];
1166 GAME_TEXT out_val[160];
1169 get_screen_size(&wid, &hgt);
1171 /* Start at current panel */
1172 y2 = y1 = panel_row_min;
1173 x2 = x1 = panel_col_min;
1175 /* Show panels until done */
1178 /* Describe the location */
1179 if ((y2 == y1) && (x2 == x1))
1181 strcpy(tmp_val, _("真上", "\0"));
1185 sprintf(tmp_val, "%s%s",
1186 ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
1187 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
1190 /* Prepare to ask which way to look */
1191 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1192 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1193 y2 / (hgt / 2), y2 % (hgt / 2),
1194 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1196 /* Assume no direction */
1199 /* Get a direction */
1204 /* Get a command (or Cancel) */
1205 if (!get_com(out_val, &command, TRUE)) break;
1207 /* Extract the action (if any) */
1208 dir = get_keymap_dir(command);
1217 /* Apply the motion */
1218 if (change_panel(ddy[dir], ddx[dir]))
1226 /* Recenter the map around the player */
1229 p_ptr->update |= (PU_MONSTERS);
1230 p_ptr->redraw |= (PR_MAP);
1231 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1237 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1238 * Sorting hook -- Comp function -- see below
1239 * @param u モンスター種族情報の入れるポインタ
1241 * @param a 比較するモンスター種族のID1
1242 * @param b 比較するモンスター種族のID2
1243 * @return 2の方が大きければTRUEを返す
1244 * We use "u" to point to array of monster indexes,
1245 * and "v" to select the type of sorting to perform on "u".
1247 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1249 u16b *who = (u16b*)(u);
1250 u16b *why = (u16b*)(v);
1257 /* Sort by player kills */
1260 /* Extract player kills */
1261 z1 = r_info[w1].r_pkills;
1262 z2 = r_info[w2].r_pkills;
1264 /* Compare player kills */
1265 if (z1 < z2) return (TRUE);
1266 if (z1 > z2) return (FALSE);
1270 /* Sort by total kills */
1273 /* Extract total kills */
1274 z1 = r_info[w1].r_tkills;
1275 z2 = r_info[w2].r_tkills;
1277 /* Compare total kills */
1278 if (z1 < z2) return (TRUE);
1279 if (z1 > z2) return (FALSE);
1283 /* Sort by monster level */
1286 /* Extract levels */
1287 z1 = r_info[w1].level;
1288 z2 = r_info[w2].level;
1290 /* Compare levels */
1291 if (z1 < z2) return (TRUE);
1292 if (z1 > z2) return (FALSE);
1296 /* Sort by monster experience */
1299 /* Extract experience */
1300 z1 = r_info[w1].mexp;
1301 z2 = r_info[w2].mexp;
1303 /* Compare experience */
1304 if (z1 < z2) return (TRUE);
1305 if (z1 > z2) return (FALSE);
1309 /* Compare indexes */
1315 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1316 * Sorting hook -- Swap function -- see below
1317 * @param u モンスター種族情報の入れるポインタ
1319 * @param a スワップするモンスター種族のID1
1320 * @param b スワップするモンスター種族のID2
1323 * We use "u" to point to array of monster indexes,
1324 * and "v" to select the type of sorting to perform.
1326 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1328 u16b *who = (u16b*)(u);
1343 * @brief モンスターの思い出を見るコマンドのメインルーチン
1344 * Identify a character, allow recall of monsters
1348 * Several "special" responses recall "multiple" monsters:
1350 * ^U (all unique monsters)
1351 * ^N (all non-unique monsters)
1353 * The responses may be sorted in several ways, see below.
1355 * Note that the player ghosts are ignored.
1358 void do_cmd_query_symbol(void)
1372 bool recall = FALSE;
1377 /* Get a character, or abort */
1378 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1379 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1381 /* Find that character info, and describe it */
1382 for (i = 0; ident_info[i]; ++i)
1384 if (sym == ident_info[i][0]) break;
1386 if (sym == KTRL('A'))
1389 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1391 else if (sym == KTRL('U'))
1394 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1396 else if (sym == KTRL('N'))
1399 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1401 else if (sym == KTRL('R'))
1404 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1406 /* XTRA HACK WHATSEARCH */
1407 else if (sym == KTRL('M'))
1410 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1415 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1417 else if (ident_info[i])
1419 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1423 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1426 /* Display the result */
1429 /* Allocate the "who" array */
1430 C_MAKE(who, max_r_idx, MONRACE_IDX);
1432 /* Collect matching monsters */
1433 for (n = 0, i = 1; i < max_r_idx; i++)
1435 monster_race *r_ptr = &r_info[i];
1437 /* Nothing to recall */
1438 if (!cheat_know && !r_ptr->r_sights) continue;
1440 /* Require non-unique monsters if needed */
1441 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1443 /* Require unique monsters if needed */
1444 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1446 /* Require ridable monsters if needed */
1447 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1449 /* XTRA HACK WHATSEARCH */
1455 for (xx = 0; temp[xx] && xx < 80; xx++)
1458 if (iskanji(temp[xx])) { xx++; continue; }
1460 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1464 strcpy(temp2, r_name + r_ptr->E_name);
1466 strcpy(temp2, r_name + r_ptr->name);
1468 for (xx = 0; temp2[xx] && xx < 80; xx++)
1469 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1472 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1474 if (my_strstr(temp2, temp))
1479 /* Collect "appropriate" monsters */
1480 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1483 /* Nothing to recall */
1486 /* Free the "who" array */
1487 C_KILL(who, max_r_idx, IDX);
1493 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1501 /* Select the sort method */
1502 ang_sort_comp = ang_sort_comp_hook;
1503 ang_sort_swap = ang_sort_swap_hook;
1505 /* Sort the array */
1506 ang_sort(who, &why, n);
1508 /* Sort by kills (and level) */
1515 /* Catch "escape" */
1518 /* Free the "who" array */
1519 C_KILL(who, max_r_idx, IDX);
1524 /* Sort if needed */
1527 /* Select the sort method */
1528 ang_sort_comp = ang_sort_comp_hook;
1529 ang_sort_swap = ang_sort_swap_hook;
1531 /* Sort the array */
1532 ang_sort(who, &why, n);
1536 /* Start at the end */
1539 /* Scan the monster memory */
1542 /* Extract a race */
1545 /* Hack -- Auto-recall */
1546 monster_race_track(r_idx);
1557 /* Recall on screen */
1558 screen_roff(who[i], 0);
1561 /* Hack -- Begin the prompt */
1564 /* Hack -- Complete the prompt */
1565 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1576 /* Normal commands */
1577 if (query != 'r') break;
1584 if (query == ESCAPE) break;
1586 /* Move to "prev" monster */
1592 if (!expand_list) break;
1596 /* Move to "next" monster */
1602 if (!expand_list) break;
1607 /* Free the "who" array */
1608 C_KILL(who, max_r_idx, IDX);
1610 /* Re-display the identity */
1615 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1619 * XXX - Add actions for other item types
1621 void do_cmd_use(void)
1627 if (p_ptr->wild_mode)
1632 if (cmd_limit_arena(p_ptr)) return;
1634 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1636 set_action(ACTION_NONE);
1639 item_tester_hook = item_tester_hook_use;
1641 q = _("どれを使いますか?", "Use which item? ");
1642 s = _("使えるものがありません。", "You have nothing to use.");
1644 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1647 switch (o_ptr->tval)
1659 do_cmd_eat_food_aux(item);
1666 do_cmd_aim_wand_aux(item);
1673 do_cmd_use_staff_aux(item);
1680 do_cmd_zap_rod_aux(item);
1684 /* Quaff a potion */
1687 do_cmd_quaff_potion_aux(item);
1694 if (cmd_limit_blind(p_ptr)) return;
1695 if (cmd_limit_confused(p_ptr)) return;
1697 do_cmd_read_scroll_aux(item, TRUE);
1706 exe_fire(item, &inventory[INVEN_BOW], SP_NONE);
1710 /* Activate an artifact */
1713 do_cmd_activate_aux(item);