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.
21 #include "cmd-activate.h"
23 #include "cmd-quaff.h"
25 #include "cmd-usestaff.h"
26 #include "cmd-zaprod.h"
27 #include "cmd-zapwand.h"
29 #include "cmd-basic.h"
31 #include "object-flavor.h"
32 #include "object-hook.h"
37 #include "player-status.h"
38 #include "player-effects.h"
40 #include "view-mainwindow.h"
42 #include "objectkind.h"
44 #include "targeting.h"
47 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display p_ptr->inventory_list
50 void do_cmd_inven(void)
54 /* Note that we are in "p_ptr->inventory_list" mode */
57 /* Note that we are in "p_ptr->inventory_list" mode */
58 if (easy_floor) command_wrk = (USE_INVEN);
61 /* Display the p_ptr->inventory_list */
62 (void)show_inven(0, USE_FULL);
65 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
66 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
67 (long int)((p_ptr->total_weight * 100) / weight_limit()));
69 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
70 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
71 (p_ptr->total_weight * 100) / weight_limit());
75 command_new = inkey();
78 /* Process "Escape" */
79 if (command_new == ESCAPE)
83 Term_get_size(&wid, &hgt);
87 command_gap = wid - 30;
90 /* Process normal keys */
93 /* Hack -- Use "display" mode */
100 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
103 void do_cmd_equip(void)
107 /* Note that we are in "equipment" mode */
110 /* Note that we are in "equipment" mode */
111 if (easy_floor) command_wrk = (USE_EQUIP);
114 (void)show_equip(0, USE_FULL);
118 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
119 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
120 (long int)((p_ptr->total_weight * 100) / weight_limit()));
122 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
123 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
124 (long int)((p_ptr->total_weight * 100) / weight_limit()));
128 command_new = inkey();
131 /* Process "Escape" */
132 if (command_new == ESCAPE)
136 Term_get_size(&wid, &hgt);
140 command_gap = wid - 30;
143 /* Process normal keys */
146 /* Enter "display" mode */
154 bool select_ring_slot = FALSE;
157 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
160 void do_cmd_wield(void)
162 OBJECT_IDX item, slot;
170 GAME_TEXT o_name[MAX_NLEN];
173 OBJECT_IDX need_switch_wielding = 0;
175 if (p_ptr->special_defense & KATA_MUSOU)
177 set_action(ACTION_NONE);
180 /* Restrict the choices */
181 item_tester_hook = item_tester_hook_wear;
183 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
184 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
186 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
190 slot = wield_slot(o_ptr);
194 /* Shields and some misc. items */
199 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
201 /* Restrict the choices */
202 item_tester_hook = item_tester_hook_melee_weapon;
204 /* Choose a weapon from the equipment only */
205 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
206 s = _("おっと。", "Oops.");
207 if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
208 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
211 else if (has_melee_weapon(INVEN_LARM)) slot = INVEN_RARM;
213 /* Both arms are already used by non-weapon */
214 else if (p_ptr->inventory_list[INVEN_RARM].k_idx && !object_is_melee_weapon(&p_ptr->inventory_list[INVEN_RARM]) &&
215 p_ptr->inventory_list[INVEN_LARM].k_idx && !object_is_melee_weapon(&p_ptr->inventory_list[INVEN_LARM]))
217 /* Restrict the choices */
218 item_tester_hook = item_tester_hook_mochikae;
221 q = _("どちらの手に装備しますか?", "Equip which hand? ");
222 s = _("おっと。", "Oops.");
223 if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
232 /* Asking for dual wielding */
233 if (slot == INVEN_LARM)
235 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
238 else if (!p_ptr->inventory_list[INVEN_RARM].k_idx && has_melee_weapon(INVEN_LARM))
240 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
243 /* Both arms are already used */
244 else if (p_ptr->inventory_list[INVEN_LARM].k_idx && p_ptr->inventory_list[INVEN_RARM].k_idx)
246 /* Restrict the choices */
247 item_tester_hook = item_tester_hook_mochikae;
250 q = _("どちらの手に装備しますか?", "Equip which hand? ");
251 s = _("おっと。", "Oops.");
253 if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
254 if ((slot == INVEN_LARM) && !has_melee_weapon(INVEN_RARM))
255 need_switch_wielding = INVEN_RARM;
261 /* Choose a ring slot */
262 if (p_ptr->inventory_list[INVEN_LEFT].k_idx && p_ptr->inventory_list[INVEN_RIGHT].k_idx)
264 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
268 q = _("どちらの手に装備しますか?", "Equip which hand? ");
270 s = _("おっと。", "Oops.");
272 /* Restrict the choices */
273 select_ring_slot = TRUE;
275 if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
277 select_ring_slot = FALSE;
280 select_ring_slot = FALSE;
284 /* Prevent wielding into a cursed slot */
285 if (object_is_cursed(&p_ptr->inventory_list[slot]))
287 object_desc(o_name, &p_ptr->inventory_list[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
290 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
292 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
295 /* Cancel the command */
300 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
301 ((o_ptr->ident & IDENT_SENSE) &&
302 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
304 char dummy[MAX_NLEN+80];
306 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
307 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
309 if (!get_check(dummy)) return;
312 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
314 char dummy[MAX_NLEN+100];
316 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
318 sprintf(dummy, _("%sを装備すると吸血鬼になります。よろしいですか?",
319 "%s will transforms you into a vampire permanently when equiped. Do you become a vampire?"), o_name);
321 if (!get_check(dummy)) return;
324 if (need_switch_wielding && !object_is_cursed(&p_ptr->inventory_list[need_switch_wielding]))
326 object_type *slot_o_ptr = &p_ptr->inventory_list[slot];
327 object_type *switch_o_ptr = &p_ptr->inventory_list[need_switch_wielding];
328 object_type object_tmp;
329 object_type *otmp_ptr = &object_tmp;
330 GAME_TEXT switch_name[MAX_NLEN];
332 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
334 object_copy(otmp_ptr, switch_o_ptr);
335 object_copy(switch_o_ptr, slot_o_ptr);
336 object_copy(slot_o_ptr, otmp_ptr);
338 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
339 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
340 (left_hander ? _("右手", "right") : _("左手", "left")));
341 slot = need_switch_wielding;
344 check_find_art_quest_completion(o_ptr);
346 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
348 identify_item(o_ptr);
350 /* Auto-inscription */
351 autopick_alter_item(item, FALSE);
354 take_turn(p_ptr, 100);
357 /* Obtain local object */
358 object_copy(q_ptr, o_ptr);
360 /* Modify quantity */
363 /* Decrease the item (from the pack) */
366 inven_item_increase(item, -1);
367 inven_item_optimize(item);
370 /* Decrease the item (from the floor) */
373 floor_item_increase(0 - item, -1);
374 floor_item_optimize(0 - item);
377 /* Access the wield slot */
378 o_ptr = &p_ptr->inventory_list[slot];
380 /* Take off existing item */
383 /* Take off existing item */
384 (void)inven_takeoff(slot, 255);
387 /* Wear the new stuff */
388 object_copy(o_ptr, q_ptr);
390 o_ptr->marked |= OM_TOUCHED;
392 p_ptr->total_weight += q_ptr->weight;
394 /* Increment the equip counter by hand */
397 #define STR_WIELD_RARM _("%s(%c)を右手に装備した。", "You are wielding %s (%c) in your right hand.")
398 #define STR_WIELD_LARM _("%s(%c)を左手に装備した。", "You are wielding %s (%c) in your left hand.")
399 #define STR_WIELD_ARMS _("%s(%c)を両手で構えた。", "You are wielding %s (%c) with both hands.")
401 /* Where is the item now */
405 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
406 act = STR_WIELD_ARMS;
408 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
412 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
413 act = STR_WIELD_ARMS;
415 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
419 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
423 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
427 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
431 object_desc(o_name, o_ptr, 0);
432 msg_format(act, o_name, index_to_label(slot));
435 if (object_is_cursed(o_ptr))
437 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
438 chg_virtue(V_HARMONY, -1);
441 o_ptr->ident |= (IDENT_SENSE);
444 /* The Stone Mask make the player current_world_ptr->game_turn into a vampire! */
445 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
447 /* Turn into a vampire */
448 change_race(RACE_VAMPIRE, "");
451 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
452 p_ptr->redraw |= (PR_EQUIPPY);
453 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
460 * @param item 持ち替えを行いたい装備部位ID
463 void kamaenaoshi(INVENTORY_IDX item)
465 object_type *o_ptr, *new_o_ptr;
466 GAME_TEXT o_name[MAX_NLEN];
468 if (item == INVEN_RARM)
470 if (has_melee_weapon(INVEN_LARM))
472 o_ptr = &p_ptr->inventory_list[INVEN_LARM];
473 object_desc(o_name, o_ptr, 0);
475 if (!object_is_cursed(o_ptr))
477 new_o_ptr = &p_ptr->inventory_list[INVEN_RARM];
478 object_copy(new_o_ptr, o_ptr);
479 p_ptr->total_weight += o_ptr->weight;
480 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
481 inven_item_optimize(INVEN_LARM);
482 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
483 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
485 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
486 (left_hander ? _("左手", "left") : _("右手", "right")));
490 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
491 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
495 else if (item == INVEN_LARM)
497 o_ptr = &p_ptr->inventory_list[INVEN_RARM];
498 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
500 if (has_melee_weapon(INVEN_RARM))
502 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
503 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
505 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
507 new_o_ptr = &p_ptr->inventory_list[INVEN_LARM];
508 object_copy(new_o_ptr, o_ptr);
509 p_ptr->total_weight += o_ptr->weight;
510 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
511 inven_item_optimize(INVEN_RARM);
512 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
519 * @brief 装備を外すコマンドのメインルーチン / Take off an item
522 void do_cmd_takeoff(void)
528 if (p_ptr->special_defense & KATA_MUSOU)
530 set_action(ACTION_NONE);
533 q = _("どれを装備からはずしますか? ", "Take off which item? ");
534 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
536 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
540 if (object_is_cursed(o_ptr))
542 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
544 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
549 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
551 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
553 o_ptr->ident |= (IDENT_SENSE);
554 o_ptr->curse_flags = 0L;
555 o_ptr->feeling = FEEL_NONE;
557 p_ptr->update |= (PU_BONUS);
558 p_ptr->window |= (PW_EQUIP);
560 msg_print(_("呪いを打ち破った。", "You break the curse."));
564 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
565 take_turn(p_ptr, 50);
570 take_turn(p_ptr, 50);
572 /* Take off the item */
573 (void)inven_takeoff(item, 255);
576 p_ptr->redraw |= (PR_EQUIPPY);
581 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
584 void do_cmd_drop(void)
593 if (p_ptr->special_defense & KATA_MUSOU)
595 set_action(ACTION_NONE);
598 q = _("どのアイテムを落としますか? ", "Drop which item? ");
599 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
601 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
604 /* Hack -- Cannot remove cursed items */
605 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
607 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
611 if (o_ptr->number > 1)
613 amt = get_quantity(NULL, o_ptr->number);
614 if (amt <= 0) return;
617 take_turn(p_ptr, 50);
619 /* Drop (some of) the item */
620 inven_drop(item, amt);
622 if (item >= INVEN_RARM)
628 p_ptr->redraw |= (PR_EQUIPPY);
633 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
636 void do_cmd_destroy(void)
646 object_type *q_ptr = &forge;
648 GAME_TEXT o_name[MAX_NLEN];
649 char out_val[MAX_NLEN+40];
653 if (p_ptr->special_defense & KATA_MUSOU)
655 set_action(ACTION_NONE);
658 /* Hack -- force destruction */
659 if (command_arg > 0) force = TRUE;
661 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
662 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
664 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
667 /* Verify unless quantity given beforehand */
668 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
670 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
672 /* Make a verification */
673 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
676 /* HACK : Add the line to message buffer */
677 message_add(out_val);
678 p_ptr->window |= (PW_MESSAGE);
681 /* Get an acceptable answer */
691 /* Erase the prompt */
695 if (i == 'y' || i == 'Y')
699 if (i == ESCAPE || i == 'n' || i == 'N')
706 /* Add an auto-destroy preference line */
707 if (autopick_autoregister(o_ptr))
709 /* Auto-destroy it */
710 autopick_alter_item(item, TRUE);
713 /* The object is already destroyed. */
719 if (o_ptr->number > 1)
721 amt = get_quantity(NULL, o_ptr->number);
722 if (amt <= 0) return;
726 old_number = o_ptr->number;
728 object_desc(o_name, o_ptr, 0);
729 o_ptr->number = old_number;
731 take_turn(p_ptr, 100);
733 /* Artifacts cannot be destroyed */
734 if (!can_player_destroy_object(o_ptr))
738 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
742 object_copy(q_ptr, o_ptr);
744 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
745 sound(SOUND_DESTITEM);
747 /* Reduce the charges of rods/wands */
748 reduce_charges(o_ptr, amt);
750 /* Eliminate the item (from the pack) */
753 inven_item_increase(item, -amt);
754 inven_item_describe(item);
755 inven_item_optimize(item);
758 /* Eliminate the item (from the floor) */
761 floor_item_increase(0 - item, -amt);
762 floor_item_describe(0 - item);
763 floor_item_optimize(0 - item);
766 if (item_tester_high_level_book(q_ptr))
768 bool gain_expr = FALSE;
770 if (p_ptr->prace == RACE_ANDROID)
773 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
777 else if (p_ptr->pclass == CLASS_PALADIN)
779 if (is_good_realm(p_ptr->realm1))
781 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
785 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
789 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
791 s32b tester_exp = p_ptr->max_exp / 20;
792 if (tester_exp > 10000) tester_exp = 10000;
793 if (q_ptr->sval < 3) tester_exp /= 4;
794 if (tester_exp<1) tester_exp = 1;
796 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
797 gain_exp(tester_exp * amt);
799 if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
801 chg_virtue(V_UNLIFE, 1);
802 chg_virtue(V_VITALITY, -1);
804 else if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
806 chg_virtue(V_UNLIFE, -1);
807 chg_virtue(V_VITALITY, 1);
810 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
811 chg_virtue(V_ENCHANT, -1);
813 if (object_value_real(q_ptr) > 30000)
814 chg_virtue(V_SACRIFICE, 2);
816 else if (object_value_real(q_ptr) > 10000)
817 chg_virtue(V_SACRIFICE, 1);
820 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
821 chg_virtue(V_HARMONY, 1);
823 if (item >= INVEN_RARM) calc_android_exp();
828 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
831 void do_cmd_observe(void)
835 GAME_TEXT o_name[MAX_NLEN];
838 q = _("どのアイテムを調べますか? ", "Examine which item? ");
839 s = _("調べられるアイテムがない。", "You have nothing to examine.");
841 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
844 /* Require full knowledge */
845 if (!(o_ptr->ident & IDENT_MENTAL))
847 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
851 object_desc(o_name, o_ptr, 0);
852 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
853 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
859 * @brief アイテムの銘を消すコマンドのメインルーチン
860 * Remove the inscription from an object XXX Mention item (when done)?
863 void do_cmd_uninscribe(void)
869 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
870 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
872 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
875 /* Nothing to remove */
876 if (!o_ptr->inscription)
878 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
882 msg_print(_("銘を消した。", "Inscription removed."));
884 /* Remove the incription */
885 o_ptr->inscription = 0;
886 p_ptr->update |= (PU_COMBINE);
887 p_ptr->window |= (PW_INVEN | PW_EQUIP);
889 /* .や$の関係で, 再計算が必要なはず -- henkma */
890 p_ptr->update |= (PU_BONUS);
896 * @brief アイテムの銘を刻むコマンドのメインルーチン
897 * Inscribe an object with a comment
900 void do_cmd_inscribe(void)
904 GAME_TEXT o_name[MAX_NLEN];
908 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
909 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
911 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
914 /* Describe the activity */
915 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
917 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
920 /* Start with nothing */
923 /* Use old inscription */
924 if (o_ptr->inscription)
926 /* Start with the old inscription */
927 strcpy(out_val, quark_str(o_ptr->inscription));
930 /* Get a new inscription (possibly empty) */
931 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
933 /* Save the inscription */
934 o_ptr->inscription = quark_add(out_val);
935 p_ptr->update |= (PU_COMBINE);
936 p_ptr->window |= (PW_INVEN | PW_EQUIP);
938 /* .や$の関係で, 再計算が必要なはず -- henkma */
939 p_ptr->update |= (PU_BONUS);
945 * @brief ランタンに燃料を加えるコマンドのメインルーチン
946 * Refill the players lamp (from the pack or floor)
949 static void do_cmd_refill_lamp(void)
956 /* Restrict the choices */
957 item_tester_hook = item_tester_refill_lantern;
959 q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
960 s = _("油つぼがない。", "You have no flasks of oil.");
962 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
965 take_turn(p_ptr, 50);
967 /* Access the lantern */
968 j_ptr = &p_ptr->inventory_list[INVEN_LITE];
971 j_ptr->xtra4 += o_ptr->xtra4;
972 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
974 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
977 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
979 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
982 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
984 else if (j_ptr->xtra4 >= FUEL_LAMP)
986 j_ptr->xtra4 = FUEL_LAMP;
987 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
990 /* Decrease the item (from the pack) */
993 inven_item_increase(item, -1);
994 inven_item_describe(item);
995 inven_item_optimize(item);
998 /* Decrease the item (from the floor) */
1001 floor_item_increase(0 - item, -1);
1002 floor_item_describe(0 - item);
1003 floor_item_optimize(0 - item);
1006 p_ptr->update |= (PU_TORCH);
1010 * @brief 松明を束ねるコマンドのメインルーチン
1011 * Refuel the players torch (from the pack or floor)
1014 static void do_cmd_refill_torch(void)
1023 /* Restrict the choices */
1024 item_tester_hook = object_can_refill_torch;
1026 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1027 s = _("他に松明がない。", "You have no extra torches.");
1029 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1032 take_turn(p_ptr, 50);
1034 /* Access the primary torch */
1035 j_ptr = &p_ptr->inventory_list[INVEN_LITE];
1038 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1040 msg_print(_("松明を結合した。", "You combine the torches."));
1042 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1045 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1047 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1050 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1052 /* Over-fuel message */
1053 else if (j_ptr->xtra4 >= FUEL_TORCH)
1055 j_ptr->xtra4 = FUEL_TORCH;
1056 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1059 /* Refuel message */
1062 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1065 /* Decrease the item (from the pack) */
1068 inven_item_increase(item, -1);
1069 inven_item_describe(item);
1070 inven_item_optimize(item);
1073 /* Decrease the item (from the floor) */
1076 floor_item_increase(0 - item, -1);
1077 floor_item_describe(0 - item);
1078 floor_item_optimize(0 - item);
1081 p_ptr->update |= (PU_TORCH);
1086 * @brief 燃料を補充するコマンドのメインルーチン
1087 * Refill the players lamp, or restock his torches
1090 void do_cmd_refill(void)
1095 o_ptr = &p_ptr->inventory_list[INVEN_LITE];
1097 if (p_ptr->special_defense & KATA_MUSOU)
1099 set_action(ACTION_NONE);
1103 if (o_ptr->tval != TV_LITE)
1105 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1109 else if (o_ptr->sval == SV_LITE_LANTERN)
1111 do_cmd_refill_lamp();
1115 else if (o_ptr->sval == SV_LITE_TORCH)
1117 do_cmd_refill_torch();
1120 /* No torch to refill */
1123 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1129 * @brief ターゲットを設定するコマンドのメインルーチン
1133 void do_cmd_target(void)
1135 if (p_ptr->wild_mode) return;
1138 if (target_set(TARGET_KILL))
1140 msg_print(_("ターゲット決定。", "Target Selected."));
1143 /* Target aborted */
1146 msg_print(_("ターゲット解除。", "Target Aborted."));
1153 * @brief 周囲を見渡すコマンドのメインルーチン
1157 void do_cmd_look(void)
1159 p_ptr->window |= PW_MONSTER_LIST;
1163 if (target_set(TARGET_LOOK))
1165 msg_print(_("ターゲット決定。", "Target Selected."));
1171 * @brief 位置を確認するコマンドのメインルーチン
1172 * Allow the player to examine other sectors on the map
1175 void do_cmd_locate(void)
1178 POSITION y1, x1, y2, x2;
1179 GAME_TEXT tmp_val[80];
1180 GAME_TEXT out_val[160];
1183 get_screen_size(&wid, &hgt);
1185 /* Start at current panel */
1186 y2 = y1 = panel_row_min;
1187 x2 = x1 = panel_col_min;
1189 /* Show panels until done */
1192 /* Describe the location */
1193 if ((y2 == y1) && (x2 == x1))
1195 strcpy(tmp_val, _("真上", "\0"));
1199 sprintf(tmp_val, "%s%s",
1200 ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
1201 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
1204 /* Prepare to ask which way to look */
1205 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1206 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1207 y2 / (hgt / 2), y2 % (hgt / 2),
1208 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1210 /* Assume no direction */
1213 /* Get a direction */
1218 /* Get a command (or Cancel) */
1219 if (!get_com(out_val, &command, TRUE)) break;
1221 /* Extract the action (if any) */
1222 dir = get_keymap_dir(command);
1231 /* Apply the motion */
1232 if (change_panel(ddy[dir], ddx[dir]))
1240 /* Recenter the map around the player */
1243 p_ptr->update |= (PU_MONSTERS);
1244 p_ptr->redraw |= (PR_MAP);
1245 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1251 * @brief モンスターの思い出を見るコマンドのメインルーチン
1252 * Identify a character, allow recall of monsters
1256 * Several "special" responses recall "multiple" monsters:
1258 * ^U (all unique monsters)
1259 * ^N (all non-unique monsters)
1261 * The responses may be sorted in several ways, see below.
1263 * Note that the player ghosts are ignored.
1266 void do_cmd_query_symbol(void)
1280 bool recall = FALSE;
1285 /* Get a character, or abort */
1286 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1287 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1289 /* Find that character info, and describe it */
1290 for (i = 0; ident_info[i]; ++i)
1292 if (sym == ident_info[i][0]) break;
1294 if (sym == KTRL('A'))
1297 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1299 else if (sym == KTRL('U'))
1302 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1304 else if (sym == KTRL('N'))
1307 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1309 else if (sym == KTRL('R'))
1312 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1314 /* XTRA HACK WHATSEARCH */
1315 else if (sym == KTRL('M'))
1318 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1323 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1325 else if (ident_info[i])
1327 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1331 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1334 /* Display the result */
1337 /* Allocate the "who" array */
1338 C_MAKE(who, max_r_idx, MONRACE_IDX);
1340 /* Collect matching monsters */
1341 for (n = 0, i = 1; i < max_r_idx; i++)
1343 monster_race *r_ptr = &r_info[i];
1345 /* Nothing to recall */
1346 if (!cheat_know && !r_ptr->r_sights) continue;
1348 /* Require non-unique monsters if needed */
1349 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1351 /* Require unique monsters if needed */
1352 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1354 /* Require ridable monsters if needed */
1355 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1357 /* XTRA HACK WHATSEARCH */
1363 for (xx = 0; temp[xx] && xx < 80; xx++)
1366 if (iskanji(temp[xx])) { xx++; continue; }
1368 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1372 strcpy(temp2, r_name + r_ptr->E_name);
1374 strcpy(temp2, r_name + r_ptr->name);
1376 for (xx = 0; temp2[xx] && xx < 80; xx++)
1377 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1380 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1382 if (my_strstr(temp2, temp))
1387 /* Collect "appropriate" monsters */
1388 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1391 /* Nothing to recall */
1394 C_KILL(who, max_r_idx, MONRACE_IDX);
1399 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1407 /* Sort the array */
1408 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
1410 /* Sort by kills (and level) */
1417 /* Catch "escape" */
1420 C_KILL(who, max_r_idx, MONRACE_IDX);
1424 /* Sort if needed */
1427 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
1431 /* Start at the end */
1434 /* Scan the monster memory */
1437 /* Extract a race */
1440 /* Hack -- Auto-recall */
1441 monster_race_track(r_idx);
1452 /* Recall on screen */
1453 screen_roff(who[i], 0);
1456 /* Hack -- Begin the prompt */
1459 /* Hack -- Complete the prompt */
1460 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1470 /* Normal commands */
1471 if (query != 'r') break;
1478 if (query == ESCAPE) break;
1480 /* Move to "prev" monster */
1486 if (!expand_list) break;
1490 /* Move to "next" monster */
1496 if (!expand_list) break;
1501 /* Free the "who" array */
1502 C_KILL(who, max_r_idx, IDX);
1504 /* Re-display the identity */
1509 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1513 * XXX - Add actions for other item types
1515 void do_cmd_use(void)
1521 if (p_ptr->wild_mode)
1526 if (cmd_limit_arena(p_ptr)) return;
1528 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1530 set_action(ACTION_NONE);
1533 item_tester_hook = item_tester_hook_use;
1535 q = _("どれを使いますか?", "Use which item? ");
1536 s = _("使えるものがありません。", "You have nothing to use.");
1538 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1541 switch (o_ptr->tval)
1553 do_cmd_eat_food_aux(item);
1560 do_cmd_aim_wand_aux(item);
1567 do_cmd_use_staff_aux(item);
1574 do_cmd_zap_rod_aux(item);
1578 /* Quaff a potion */
1581 do_cmd_quaff_potion_aux(item);
1588 if (cmd_limit_blind(p_ptr)) return;
1589 if (cmd_limit_confused(p_ptr)) return;
1591 do_cmd_read_scroll_aux(item, TRUE);
1600 exe_fire(item, &p_ptr->inventory_list[INVEN_BOW], SP_NONE);
1604 /* Activate an artifact */
1607 do_cmd_activate_aux(item);