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)
94 /* Note that we are in "equipment" mode */
97 /* Note that we are in "equipment" mode */
98 if (easy_floor) command_wrk = (USE_EQUIP);
101 (void)show_equip(0, USE_FULL);
105 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
106 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
107 (long int)((p_ptr->total_weight * 100) / weight_limit()));
109 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
110 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
111 (long int)((p_ptr->total_weight * 100) / weight_limit()));
115 command_new = inkey();
118 /* Process "Escape" */
119 if (command_new == ESCAPE)
123 Term_get_size(&wid, &hgt);
127 command_gap = wid - 30;
130 /* Process normal keys */
133 /* Enter "display" mode */
141 bool select_ring_slot = FALSE;
144 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
147 void do_cmd_wield(void)
149 OBJECT_IDX item, slot;
157 GAME_TEXT o_name[MAX_NLEN];
160 OBJECT_IDX need_switch_wielding = 0;
162 if (p_ptr->special_defense & KATA_MUSOU)
164 set_action(ACTION_NONE);
167 /* Restrict the choices */
168 item_tester_hook = item_tester_hook_wear;
170 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
171 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
173 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
177 slot = wield_slot(o_ptr);
181 /* Shields and some misc. items */
186 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
188 /* Restrict the choices */
189 item_tester_hook = item_tester_hook_melee_weapon;
191 /* Choose a weapon from the equipment only */
192 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
193 s = _("おっと。", "Oops.");
194 if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
195 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
198 else if (has_melee_weapon(INVEN_LARM)) slot = INVEN_RARM;
200 /* Both arms are already used by non-weapon */
201 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
202 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
204 /* Restrict the choices */
205 item_tester_hook = item_tester_hook_mochikae;
208 q = _("どちらの手に装備しますか?", "Equip which hand? ");
209 s = _("おっと。", "Oops.");
210 if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
219 /* Asking for dual wielding */
220 if (slot == INVEN_LARM)
222 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
225 else if (!inventory[INVEN_RARM].k_idx && has_melee_weapon(INVEN_LARM))
227 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
230 /* Both arms are already used */
231 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
233 /* Restrict the choices */
234 item_tester_hook = item_tester_hook_mochikae;
237 q = _("どちらの手に装備しますか?", "Equip which hand? ");
238 s = _("おっと。", "Oops.");
240 if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
241 if ((slot == INVEN_LARM) && !has_melee_weapon(INVEN_RARM))
242 need_switch_wielding = INVEN_RARM;
248 /* Choose a ring slot */
249 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
251 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
255 q = _("どちらの手に装備しますか?", "Equip which hand? ");
257 s = _("おっと。", "Oops.");
259 /* Restrict the choices */
260 select_ring_slot = TRUE;
262 if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
264 select_ring_slot = FALSE;
267 select_ring_slot = FALSE;
271 /* Prevent wielding into a cursed slot */
272 if (object_is_cursed(&inventory[slot]))
274 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
277 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
279 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
282 /* Cancel the command */
287 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
288 ((o_ptr->ident & IDENT_SENSE) &&
289 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
291 char dummy[MAX_NLEN+80];
293 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
294 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
296 if (!get_check(dummy)) return;
299 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
301 char dummy[MAX_NLEN+80];
303 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
306 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
308 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
309 sprintf(dummy, "Do you become a vampire?");
312 if (!get_check(dummy)) return;
315 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
317 object_type *slot_o_ptr = &inventory[slot];
318 object_type *switch_o_ptr = &inventory[need_switch_wielding];
319 object_type object_tmp;
320 object_type *otmp_ptr = &object_tmp;
321 GAME_TEXT switch_name[MAX_NLEN];
323 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
325 object_copy(otmp_ptr, switch_o_ptr);
326 object_copy(switch_o_ptr, slot_o_ptr);
327 object_copy(slot_o_ptr, otmp_ptr);
329 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
330 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
331 (left_hander ? _("右手", "right") : _("左手", "left")));
332 slot = need_switch_wielding;
335 check_find_art_quest_completion(o_ptr);
337 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
339 identify_item(o_ptr);
341 /* Auto-inscription */
342 autopick_alter_item(item, FALSE);
345 p_ptr->energy_use = 100;
348 /* Obtain local object */
349 object_copy(q_ptr, o_ptr);
351 /* Modify quantity */
354 /* Decrease the item (from the pack) */
357 inven_item_increase(item, -1);
358 inven_item_optimize(item);
361 /* Decrease the item (from the floor) */
364 floor_item_increase(0 - item, -1);
365 floor_item_optimize(0 - item);
368 /* Access the wield slot */
369 o_ptr = &inventory[slot];
371 /* Take off existing item */
374 /* Take off existing item */
375 (void)inven_takeoff(slot, 255);
378 /* Wear the new stuff */
379 object_copy(o_ptr, q_ptr);
381 o_ptr->marked |= OM_TOUCHED;
383 p_ptr->total_weight += q_ptr->weight;
385 /* Increment the equip counter by hand */
388 #define STR_WIELD_RARM _("%s(%c)を右手に装備した。", "You are wielding %s (%c) in your right hand.")
389 #define STR_WIELD_LARM _("%s(%c)を左手に装備した。", "You are wielding %s (%c) in your left hand.")
390 #define STR_WIELD_ARMS _("%s(%c)を両手で構えた。", "You are wielding %s (%c) with both hands.")
392 /* Where is the item now */
396 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
397 act = STR_WIELD_ARMS;
399 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
403 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
404 act = STR_WIELD_ARMS;
406 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
410 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
414 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
418 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
422 object_desc(o_name, o_ptr, 0);
423 msg_format(act, o_name, index_to_label(slot));
426 if (object_is_cursed(o_ptr))
428 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
429 chg_virtue(V_HARMONY, -1);
432 o_ptr->ident |= (IDENT_SENSE);
435 /* The Stone Mask make the player turn into a vampire! */
436 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
438 /* Turn into a vampire */
439 change_race(RACE_VAMPIRE, "");
442 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
443 p_ptr->redraw |= (PR_EQUIPPY);
444 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
451 * @param item 持ち替えを行いたい装備部位ID
454 void kamaenaoshi(INVENTORY_IDX item)
456 object_type *o_ptr, *new_o_ptr;
457 GAME_TEXT o_name[MAX_NLEN];
459 if (item == INVEN_RARM)
461 if (has_melee_weapon(INVEN_LARM))
463 o_ptr = &inventory[INVEN_LARM];
464 object_desc(o_name, o_ptr, 0);
466 if (!object_is_cursed(o_ptr))
468 new_o_ptr = &inventory[INVEN_RARM];
469 object_copy(new_o_ptr, o_ptr);
470 p_ptr->total_weight += o_ptr->weight;
471 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
472 inven_item_optimize(INVEN_LARM);
473 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
474 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
476 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
477 (left_hander ? _("左手", "left") : _("右手", "right")));
481 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
482 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
486 else if (item == INVEN_LARM)
488 o_ptr = &inventory[INVEN_RARM];
489 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
491 if (has_melee_weapon(INVEN_RARM))
493 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
494 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
496 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
498 new_o_ptr = &inventory[INVEN_LARM];
499 object_copy(new_o_ptr, o_ptr);
500 p_ptr->total_weight += o_ptr->weight;
501 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
502 inven_item_optimize(INVEN_RARM);
503 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
510 * @brief 装備を外すコマンドのメインルーチン / Take off an item
513 void do_cmd_takeoff(void)
519 if (p_ptr->special_defense & KATA_MUSOU)
521 set_action(ACTION_NONE);
524 q = _("どれを装備からはずしますか? ", "Take off which item? ");
525 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
527 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
531 if (object_is_cursed(o_ptr))
533 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
535 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
540 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
542 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
544 o_ptr->ident |= (IDENT_SENSE);
545 o_ptr->curse_flags = 0L;
546 o_ptr->feeling = FEEL_NONE;
548 p_ptr->update |= (PU_BONUS);
549 p_ptr->window |= (PW_EQUIP);
551 msg_print(_("呪いを打ち破った。", "You break the curse."));
555 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
556 p_ptr->energy_use = 50;
561 /* Take a partial turn */
562 p_ptr->energy_use = 50;
564 /* Take off the item */
565 (void)inven_takeoff(item, 255);
568 p_ptr->redraw |= (PR_EQUIPPY);
573 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
576 void do_cmd_drop(void)
585 if (p_ptr->special_defense & KATA_MUSOU)
587 set_action(ACTION_NONE);
590 q = _("どのアイテムを落としますか? ", "Drop which item? ");
591 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
593 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
596 /* Hack -- Cannot remove cursed items */
597 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
599 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
604 /* See how many items */
605 if (o_ptr->number > 1)
608 amt = get_quantity(NULL, o_ptr->number);
610 /* Allow user abort */
611 if (amt <= 0) return;
615 /* Take a partial turn */
616 p_ptr->energy_use = 50;
618 /* Drop (some of) the item */
619 inven_drop(item, amt);
621 if (item >= INVEN_RARM)
627 p_ptr->redraw |= (PR_EQUIPPY);
631 * @brief オブジェクトが高位の魔法書かどうかを判定する
632 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
633 * @return オブジェクトが高位の魔法書ならばTRUEを返す
635 static bool high_level_book(object_type *o_ptr)
637 if ((o_ptr->tval == TV_LIFE_BOOK) ||
638 (o_ptr->tval == TV_SORCERY_BOOK) ||
639 (o_ptr->tval == TV_NATURE_BOOK) ||
640 (o_ptr->tval == TV_CHAOS_BOOK) ||
641 (o_ptr->tval == TV_DEATH_BOOK) ||
642 (o_ptr->tval == TV_TRUMP_BOOK) ||
643 (o_ptr->tval == TV_CRAFT_BOOK) ||
644 (o_ptr->tval == TV_DAEMON_BOOK) ||
645 (o_ptr->tval == TV_CRUSADE_BOOK) ||
646 (o_ptr->tval == TV_MUSIC_BOOK) ||
647 (o_ptr->tval == TV_HEX_BOOK))
660 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
663 void do_cmd_destroy(void)
673 object_type *q_ptr = &forge;
675 GAME_TEXT o_name[MAX_NLEN];
676 char out_val[MAX_NLEN+40];
680 if (p_ptr->special_defense & KATA_MUSOU)
682 set_action(ACTION_NONE);
685 /* Hack -- force destruction */
686 if (command_arg > 0) force = TRUE;
688 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
689 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
691 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
694 /* Verify unless quantity given beforehand */
695 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
697 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
699 /* Make a verification */
700 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
703 /* HACK : Add the line to message buffer */
704 message_add(out_val);
705 p_ptr->window |= (PW_MESSAGE);
708 /* Get an acceptable answer */
718 /* Erase the prompt */
722 if (i == 'y' || i == 'Y')
726 if (i == ESCAPE || i == 'n' || i == 'N')
733 /* Add an auto-destroy preference line */
734 if (autopick_autoregister(o_ptr))
736 /* Auto-destroy it */
737 autopick_alter_item(item, TRUE);
740 /* The object is already destroyed. */
746 /* See how many items */
747 if (o_ptr->number > 1)
750 amt = get_quantity(NULL, o_ptr->number);
752 /* Allow user abort */
753 if (amt <= 0) return;
757 old_number = o_ptr->number;
759 object_desc(o_name, o_ptr, 0);
760 o_ptr->number = old_number;
762 p_ptr->energy_use = 100;
764 /* Artifacts cannot be destroyed */
765 if (!can_player_destroy_object(o_ptr))
767 p_ptr->energy_use = 0;
769 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
773 object_copy(q_ptr, o_ptr);
775 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
776 sound(SOUND_DESTITEM);
778 /* Reduce the charges of rods/wands */
779 reduce_charges(o_ptr, amt);
781 /* Eliminate the item (from the pack) */
784 inven_item_increase(item, -amt);
785 inven_item_describe(item);
786 inven_item_optimize(item);
789 /* Eliminate the item (from the floor) */
792 floor_item_increase(0 - item, -amt);
793 floor_item_describe(0 - item);
794 floor_item_optimize(0 - item);
797 if (high_level_book(q_ptr))
799 bool gain_expr = FALSE;
801 if (p_ptr->prace == RACE_ANDROID)
804 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
808 else if (p_ptr->pclass == CLASS_PALADIN)
810 if (is_good_realm(p_ptr->realm1))
812 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
816 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
820 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
822 s32b tester_exp = p_ptr->max_exp / 20;
823 if (tester_exp > 10000) tester_exp = 10000;
824 if (q_ptr->sval < 3) tester_exp /= 4;
825 if (tester_exp<1) tester_exp = 1;
827 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
828 gain_exp(tester_exp * amt);
830 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
832 chg_virtue(V_UNLIFE, 1);
833 chg_virtue(V_VITALITY, -1);
835 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
837 chg_virtue(V_UNLIFE, -1);
838 chg_virtue(V_VITALITY, 1);
841 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
842 chg_virtue(V_ENCHANT, -1);
844 if (object_value_real(q_ptr) > 30000)
845 chg_virtue(V_SACRIFICE, 2);
847 else if (object_value_real(q_ptr) > 10000)
848 chg_virtue(V_SACRIFICE, 1);
851 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
852 chg_virtue(V_HARMONY, 1);
854 if (item >= INVEN_RARM) calc_android_exp();
859 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
862 void do_cmd_observe(void)
866 GAME_TEXT o_name[MAX_NLEN];
869 q = _("どのアイテムを調べますか? ", "Examine which item? ");
870 s = _("調べられるアイテムがない。", "You have nothing to examine.");
872 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
875 /* Require full knowledge */
876 if (!(o_ptr->ident & IDENT_MENTAL))
878 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
882 object_desc(o_name, o_ptr, 0);
883 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
884 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
890 * @brief アイテムの銘を消すコマンドのメインルーチン
891 * Remove the inscription from an object XXX Mention item (when done)?
894 void do_cmd_uninscribe(void)
900 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
901 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
903 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
906 /* Nothing to remove */
907 if (!o_ptr->inscription)
909 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
913 msg_print(_("銘を消した。", "Inscription removed."));
915 /* Remove the incription */
916 o_ptr->inscription = 0;
918 /* Combine the pack */
919 p_ptr->update |= (PU_COMBINE);
921 p_ptr->window |= (PW_INVEN | PW_EQUIP);
923 /* .や$の関係で, 再計算が必要なはず -- henkma */
924 p_ptr->update |= (PU_BONUS);
930 * @brief アイテムの銘を刻むコマンドのメインルーチン
931 * Inscribe an object with a comment
934 void do_cmd_inscribe(void)
938 GAME_TEXT o_name[MAX_NLEN];
942 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
943 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
945 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
948 /* Describe the activity */
949 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
951 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
954 /* Start with nothing */
957 /* Use old inscription */
958 if (o_ptr->inscription)
960 /* Start with the old inscription */
961 strcpy(out_val, quark_str(o_ptr->inscription));
964 /* Get a new inscription (possibly empty) */
965 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
967 /* Save the inscription */
968 o_ptr->inscription = quark_add(out_val);
970 /* Combine the pack */
971 p_ptr->update |= (PU_COMBINE);
973 p_ptr->window |= (PW_INVEN | PW_EQUIP);
975 /* .や$の関係で, 再計算が必要なはず -- henkma */
976 p_ptr->update |= (PU_BONUS);
983 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
984 * An "item_tester_hook" for refilling lanterns
985 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
986 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
988 static bool item_tester_refill_lantern(object_type *o_ptr)
990 /* Flasks of oil are okay */
991 if (o_ptr->tval == TV_FLASK) return (TRUE);
993 /* Laterns are okay */
994 if ((o_ptr->tval == TV_LITE) &&
995 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
997 /* Assume not okay */
1003 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1004 * Refill the players lamp (from the pack or floor)
1007 static void do_cmd_refill_lamp(void)
1016 /* Restrict the choices */
1017 item_tester_hook = item_tester_refill_lantern;
1019 q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
1020 s = _("油つぼがない。", "You have no flasks of oil.");
1022 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1025 /* Take a partial turn */
1026 p_ptr->energy_use = 50;
1028 /* Access the lantern */
1029 j_ptr = &inventory[INVEN_LITE];
1032 j_ptr->xtra4 += o_ptr->xtra4;
1033 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1035 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1038 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1040 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1043 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1045 else if (j_ptr->xtra4 >= FUEL_LAMP)
1047 j_ptr->xtra4 = FUEL_LAMP;
1048 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
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 /* Recalculate torch */
1068 p_ptr->update |= (PU_TORCH);
1073 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1074 * An "item_tester_hook" for refilling torches
1075 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1076 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1078 static bool item_tester_refill_torch(object_type *o_ptr)
1080 /* Torches are okay */
1081 if ((o_ptr->tval == TV_LITE) &&
1082 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1084 /* Assume not okay */
1090 * @brief 松明を束ねるコマンドのメインルーチン
1091 * Refuel the players torch (from the pack or floor)
1094 static void do_cmd_refill_torch(void)
1103 /* Restrict the choices */
1104 item_tester_hook = item_tester_refill_torch;
1106 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1107 s = _("他に松明がない。", "You have no extra torches.");
1109 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1112 /* Take a partial turn */
1113 p_ptr->energy_use = 50;
1115 /* Access the primary torch */
1116 j_ptr = &inventory[INVEN_LITE];
1119 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1121 msg_print(_("松明を結合した。", "You combine the torches."));
1123 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1126 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1128 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1131 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1133 /* Over-fuel message */
1134 else if (j_ptr->xtra4 >= FUEL_TORCH)
1136 j_ptr->xtra4 = FUEL_TORCH;
1137 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1140 /* Refuel message */
1143 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1146 /* Decrease the item (from the pack) */
1149 inven_item_increase(item, -1);
1150 inven_item_describe(item);
1151 inven_item_optimize(item);
1154 /* Decrease the item (from the floor) */
1157 floor_item_increase(0 - item, -1);
1158 floor_item_describe(0 - item);
1159 floor_item_optimize(0 - item);
1162 /* Recalculate torch */
1163 p_ptr->update |= (PU_TORCH);
1168 * @brief 燃料を補充するコマンドのメインルーチン
1169 * Refill the players lamp, or restock his torches
1172 void do_cmd_refill(void)
1177 o_ptr = &inventory[INVEN_LITE];
1179 if (p_ptr->special_defense & KATA_MUSOU)
1181 set_action(ACTION_NONE);
1185 if (o_ptr->tval != TV_LITE)
1187 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1191 else if (o_ptr->sval == SV_LITE_LANTERN)
1193 do_cmd_refill_lamp();
1197 else if (o_ptr->sval == SV_LITE_TORCH)
1199 do_cmd_refill_torch();
1202 /* No torch to refill */
1205 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1211 * @brief ターゲットを設定するコマンドのメインルーチン
1215 void do_cmd_target(void)
1217 if (p_ptr->wild_mode) return;
1220 if (target_set(TARGET_KILL))
1222 msg_print(_("ターゲット決定。", "Target Selected."));
1225 /* Target aborted */
1228 msg_print(_("ターゲット解除。", "Target Aborted."));
1235 * @brief 周囲を見渡すコマンドのメインルーチン
1239 void do_cmd_look(void)
1241 p_ptr->window |= PW_MONSTER_LIST;
1245 if (target_set(TARGET_LOOK))
1247 msg_print(_("ターゲット決定。", "Target Selected."));
1253 * @brief 位置を確認するコマンドのメインルーチン
1254 * Allow the player to examine other sectors on the map
1257 void do_cmd_locate(void)
1260 POSITION y1, x1, y2, x2;
1261 GAME_TEXT tmp_val[80];
1262 GAME_TEXT out_val[160];
1265 get_screen_size(&wid, &hgt);
1267 /* Start at current panel */
1268 y2 = y1 = panel_row_min;
1269 x2 = x1 = panel_col_min;
1271 /* Show panels until done */
1274 /* Describe the location */
1275 if ((y2 == y1) && (x2 == x1))
1278 strcpy(tmp_val, "真上");
1287 sprintf(tmp_val, "%s%s",
1288 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1289 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1291 sprintf(tmp_val, "%s%s of",
1292 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1293 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1298 /* Prepare to ask which way to look */
1299 sprintf(out_val, _("マップ位置 [%ld(%02ld),%ld(%02ld)] (プレイヤーの%s) 方向?",
1300 "Map sector [%ld(%02ld),%ld(%02ld)], which is%s your sector. Direction?"),
1301 y2 / (hgt / 2), y2 % (hgt / 2),
1302 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1304 /* Assume no direction */
1307 /* Get a direction */
1312 /* Get a command (or Cancel) */
1313 if (!get_com(out_val, &command, TRUE)) break;
1315 /* Extract the action (if any) */
1316 dir = get_keymap_dir(command);
1325 /* Apply the motion */
1326 if (change_panel(ddy[dir], ddx[dir]))
1334 /* Recenter the map around the player */
1337 p_ptr->update |= (PU_MONSTERS);
1338 p_ptr->redraw |= (PR_MAP);
1339 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1346 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1347 * Sorting hook -- Comp function -- see below
1348 * @param u モンスター種族情報の入れるポインタ
1350 * @param a 比較するモンスター種族のID1
1351 * @param b 比較するモンスター種族のID2
1352 * @return 2の方が大きければTRUEを返す
1353 * We use "u" to point to array of monster indexes,
1354 * and "v" to select the type of sorting to perform on "u".
1356 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1358 u16b *who = (u16b*)(u);
1359 u16b *why = (u16b*)(v);
1366 /* Sort by player kills */
1369 /* Extract player kills */
1370 z1 = r_info[w1].r_pkills;
1371 z2 = r_info[w2].r_pkills;
1373 /* Compare player kills */
1374 if (z1 < z2) return (TRUE);
1375 if (z1 > z2) return (FALSE);
1379 /* Sort by total kills */
1382 /* Extract total kills */
1383 z1 = r_info[w1].r_tkills;
1384 z2 = r_info[w2].r_tkills;
1386 /* Compare total kills */
1387 if (z1 < z2) return (TRUE);
1388 if (z1 > z2) return (FALSE);
1392 /* Sort by monster level */
1395 /* Extract levels */
1396 z1 = r_info[w1].level;
1397 z2 = r_info[w2].level;
1399 /* Compare levels */
1400 if (z1 < z2) return (TRUE);
1401 if (z1 > z2) return (FALSE);
1405 /* Sort by monster experience */
1408 /* Extract experience */
1409 z1 = r_info[w1].mexp;
1410 z2 = r_info[w2].mexp;
1412 /* Compare experience */
1413 if (z1 < z2) return (TRUE);
1414 if (z1 > z2) return (FALSE);
1418 /* Compare indexes */
1424 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1425 * Sorting hook -- Swap function -- see below
1426 * @param u モンスター種族情報の入れるポインタ
1428 * @param a スワップするモンスター種族のID1
1429 * @param b スワップするモンスター種族のID2
1432 * We use "u" to point to array of monster indexes,
1433 * and "v" to select the type of sorting to perform.
1435 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1437 u16b *who = (u16b*)(u);
1453 * @brief モンスターの思い出を見るコマンドのメインルーチン
1454 * Identify a character, allow recall of monsters
1458 * Several "special" responses recall "multiple" monsters:
1460 * ^U (all unique monsters)
1461 * ^N (all non-unique monsters)
1463 * The responses may be sorted in several ways, see below.
1465 * Note that the player ghosts are ignored.
1468 void do_cmd_query_symbol(void)
1482 bool recall = FALSE;
1487 /* Get a character, or abort */
1488 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1489 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1491 /* Find that character info, and describe it */
1492 for (i = 0; ident_info[i]; ++i)
1494 if (sym == ident_info[i][0]) break;
1496 if (sym == KTRL('A'))
1499 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1501 else if (sym == KTRL('U'))
1504 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1506 else if (sym == KTRL('N'))
1509 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1511 else if (sym == KTRL('R'))
1514 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1516 /* XTRA HACK WHATSEARCH */
1517 else if (sym == KTRL('M'))
1520 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1525 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1527 else if (ident_info[i])
1529 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1533 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1536 /* Display the result */
1539 /* Allocate the "who" array */
1540 C_MAKE(who, max_r_idx, MONRACE_IDX);
1542 /* Collect matching monsters */
1543 for (n = 0, i = 1; i < max_r_idx; i++)
1545 monster_race *r_ptr = &r_info[i];
1547 /* Nothing to recall */
1548 if (!cheat_know && !r_ptr->r_sights) continue;
1550 /* Require non-unique monsters if needed */
1551 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1553 /* Require unique monsters if needed */
1554 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1556 /* Require ridable monsters if needed */
1557 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1559 /* XTRA HACK WHATSEARCH */
1565 for (xx = 0; temp[xx] && xx < 80; xx++)
1568 if (iskanji(temp[xx])) { xx++; continue; }
1570 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1574 strcpy(temp2, r_name + r_ptr->E_name);
1576 strcpy(temp2, r_name + r_ptr->name);
1578 for (xx = 0; temp2[xx] && xx < 80; xx++)
1579 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1582 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1584 if (my_strstr(temp2, temp))
1589 /* Collect "appropriate" monsters */
1590 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1593 /* Nothing to recall */
1596 /* Free the "who" array */
1597 C_KILL(who, max_r_idx, IDX);
1603 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1611 /* Select the sort method */
1612 ang_sort_comp = ang_sort_comp_hook;
1613 ang_sort_swap = ang_sort_swap_hook;
1615 /* Sort the array */
1616 ang_sort(who, &why, n);
1618 /* Sort by kills (and level) */
1625 /* Catch "escape" */
1628 /* Free the "who" array */
1629 C_KILL(who, max_r_idx, IDX);
1634 /* Sort if needed */
1637 /* Select the sort method */
1638 ang_sort_comp = ang_sort_comp_hook;
1639 ang_sort_swap = ang_sort_swap_hook;
1641 /* Sort the array */
1642 ang_sort(who, &why, n);
1646 /* Start at the end */
1649 /* Scan the monster memory */
1652 /* Extract a race */
1655 /* Hack -- Auto-recall */
1656 monster_race_track(r_idx);
1667 /* Recall on screen */
1668 screen_roff(who[i], 0);
1671 /* Hack -- Begin the prompt */
1674 /* Hack -- Complete the prompt */
1675 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1686 /* Normal commands */
1687 if (query != 'r') break;
1694 if (query == ESCAPE) break;
1696 /* Move to "prev" monster */
1702 if (!expand_list) break;
1706 /* Move to "next" monster */
1712 if (!expand_list) break;
1717 /* Free the "who" array */
1718 C_KILL(who, max_r_idx, IDX);
1720 /* Re-display the identity */
1725 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1729 * XXX - Add actions for other item types
1731 void do_cmd_use(void)
1737 if (p_ptr->wild_mode)
1742 if (p_ptr->inside_arena)
1744 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
1749 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1751 set_action(ACTION_NONE);
1754 item_tester_hook = item_tester_hook_use;
1756 q = _("どれを使いますか?", "Use which item? ");
1757 s = _("使えるものがありません。", "You have nothing to use.");
1759 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1762 switch (o_ptr->tval)
1774 do_cmd_eat_food_aux(item);
1781 do_cmd_aim_wand_aux(item);
1788 do_cmd_use_staff_aux(item);
1795 do_cmd_zap_rod_aux(item);
1799 /* Quaff a potion */
1802 do_cmd_quaff_potion_aux(item);
1809 /* Check some conditions */
1812 msg_print(_("目が見えない。", "You can't see anything."));
1817 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
1820 if (p_ptr->confused)
1822 msg_print(_("混乱していて読めない!", "You are too confused!"));
1826 do_cmd_read_scroll_aux(item, TRUE);
1835 exe_fire(item, &inventory[INVEN_BOW]);
1839 /* Activate an artifact */
1842 do_cmd_activate_aux(item);