3 * @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory commands
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 #include "cmd-activate.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "player-item.h"
25 #include "object-hook.h"
29 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
32 void do_cmd_inven(void)
36 /* Note that we are in "inventory" mode */
39 /* Note that we are in "inventory" mode */
40 if (easy_floor) command_wrk = (USE_INVEN);
43 /* Display the inventory */
44 (void)show_inven(0, USE_FULL);
47 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
48 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
49 (long int)((p_ptr->total_weight * 100) / weight_limit()));
51 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
52 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
53 (p_ptr->total_weight * 100) / weight_limit());
60 /* Get a new command */
61 command_new = inkey();
65 /* Process "Escape" */
66 if (command_new == ESCAPE)
70 Term_get_size(&wid, &hgt);
74 command_gap = wid - 30;
77 /* Process normal keys */
80 /* Hack -- Use "display" mode */
87 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
90 void do_cmd_equip(void)
95 /* Note that we are in "equipment" mode */
98 /* Note that we are in "equipment" mode */
99 if (easy_floor) command_wrk = (USE_EQUIP);
102 (void)show_equip(0, USE_FULL);
106 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
107 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
108 (long int)((p_ptr->total_weight * 100) / weight_limit()));
110 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
111 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
112 (long int)((p_ptr->total_weight * 100) / weight_limit()));
119 /* Get a new command */
120 command_new = inkey();
124 /* Process "Escape" */
125 if (command_new == ESCAPE)
129 Term_get_size(&wid, &hgt);
133 command_gap = wid - 30;
136 /* Process normal keys */
139 /* Enter "display" mode */
147 bool select_ring_slot = FALSE;
150 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
153 void do_cmd_wield(void)
155 OBJECT_IDX item, slot;
163 GAME_TEXT o_name[MAX_NLEN];
166 OBJECT_IDX need_switch_wielding = 0;
168 if (p_ptr->special_defense & KATA_MUSOU)
170 set_action(ACTION_NONE);
173 /* Restrict the choices */
174 item_tester_hook = item_tester_hook_wear;
176 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
177 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
179 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
183 slot = wield_slot(o_ptr);
187 /* Shields and some misc. items */
192 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
194 /* Restrict the choices */
195 item_tester_hook = item_tester_hook_melee_weapon;
197 /* Choose a weapon from the equipment only */
198 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
199 s = _("おっと。", "Oops.");
200 if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
201 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
204 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
206 /* Both arms are already used by non-weapon */
207 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
208 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
210 /* Restrict the choices */
211 item_tester_hook = item_tester_hook_mochikae;
214 q = _("どちらの手に装備しますか?", "Equip which hand? ");
215 s = _("おっと。", "Oops.");
216 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
225 /* Asking for dual wielding */
226 if (slot == INVEN_LARM)
228 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
231 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
233 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
236 /* Both arms are already used */
237 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
239 /* Restrict the choices */
240 item_tester_hook = item_tester_hook_mochikae;
243 q = _("どちらの手に装備しますか?", "Equip which hand? ");
244 s = _("おっと。", "Oops.");
246 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
247 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
248 need_switch_wielding = INVEN_RARM;
254 /* Choose a ring slot */
255 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
257 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
261 q = _("どちらの手に装備しますか?", "Equip which hand? ");
263 s = _("おっと。", "Oops.");
265 /* Restrict the choices */
266 select_ring_slot = TRUE;
268 if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
270 select_ring_slot = FALSE;
273 select_ring_slot = FALSE;
277 /* Prevent wielding into a cursed slot */
278 if (object_is_cursed(&inventory[slot]))
280 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
283 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
285 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
288 /* Cancel the command */
293 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
294 ((o_ptr->ident & IDENT_SENSE) &&
295 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
297 char dummy[MAX_NLEN+80];
299 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
300 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
302 if (!get_check(dummy)) return;
305 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
307 char dummy[MAX_NLEN+80];
309 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
312 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
314 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
315 sprintf(dummy, "Do you become a vampire?");
318 if (!get_check(dummy)) return;
321 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
323 object_type *slot_o_ptr = &inventory[slot];
324 object_type *switch_o_ptr = &inventory[need_switch_wielding];
325 object_type object_tmp;
326 object_type *otmp_ptr = &object_tmp;
327 GAME_TEXT switch_name[MAX_NLEN];
329 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
331 object_copy(otmp_ptr, switch_o_ptr);
332 object_copy(switch_o_ptr, slot_o_ptr);
333 object_copy(slot_o_ptr, otmp_ptr);
335 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
336 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
337 (left_hander ? _("右手", "right") : _("左手", "left")));
338 slot = need_switch_wielding;
341 check_find_art_quest_completion(o_ptr);
343 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
345 identify_item(o_ptr);
347 /* Auto-inscription */
348 autopick_alter_item(item, FALSE);
351 p_ptr->energy_use = 100;
354 /* Obtain local object */
355 object_copy(q_ptr, o_ptr);
357 /* Modify quantity */
360 /* Decrease the item (from the pack) */
363 inven_item_increase(item, -1);
364 inven_item_optimize(item);
367 /* Decrease the item (from the floor) */
370 floor_item_increase(0 - item, -1);
371 floor_item_optimize(0 - item);
374 /* Access the wield slot */
375 o_ptr = &inventory[slot];
377 /* Take off existing item */
380 /* Take off existing item */
381 (void)inven_takeoff(slot, 255);
384 /* Wear the new stuff */
385 object_copy(o_ptr, q_ptr);
387 /* Player touches it */
388 o_ptr->marked |= OM_TOUCHED;
390 /* Increase the weight */
391 p_ptr->total_weight += q_ptr->weight;
393 /* Increment the equip counter by hand */
397 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
398 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
399 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
401 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
402 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
403 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
406 /* Where is the item now */
410 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
411 act = STR_WIELD_ARMS;
413 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
417 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
418 act = STR_WIELD_ARMS;
420 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
424 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
428 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
432 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
436 object_desc(o_name, o_ptr, 0);
437 msg_format(act, o_name, index_to_label(slot));
440 if (object_is_cursed(o_ptr))
442 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
443 chg_virtue(V_HARMONY, -1);
446 o_ptr->ident |= (IDENT_SENSE);
449 /* The Stone Mask make the player turn into a vampire! */
450 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
452 /* Turn into a vampire */
453 change_race(RACE_VAMPIRE, "");
456 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
457 p_ptr->redraw |= (PR_EQUIPPY);
458 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
465 * @param item 持ち替えを行いたい装備部位ID
468 void kamaenaoshi(INVENTORY_IDX item)
470 object_type *o_ptr, *new_o_ptr;
471 GAME_TEXT o_name[MAX_NLEN];
473 if (item == INVEN_RARM)
475 if (buki_motteruka(INVEN_LARM))
477 o_ptr = &inventory[INVEN_LARM];
478 object_desc(o_name, o_ptr, 0);
480 if (!object_is_cursed(o_ptr))
482 new_o_ptr = &inventory[INVEN_RARM];
483 object_copy(new_o_ptr, o_ptr);
484 p_ptr->total_weight += o_ptr->weight;
485 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
486 inven_item_optimize(INVEN_LARM);
487 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
488 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
490 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
491 (left_hander ? _("左手", "left") : _("右手", "right")));
495 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
496 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
500 else if (item == INVEN_LARM)
502 o_ptr = &inventory[INVEN_RARM];
503 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
505 if (buki_motteruka(INVEN_RARM))
507 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
508 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
510 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
512 new_o_ptr = &inventory[INVEN_LARM];
513 object_copy(new_o_ptr, o_ptr);
514 p_ptr->total_weight += o_ptr->weight;
515 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
516 inven_item_optimize(INVEN_RARM);
517 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
524 * @brief 装備を外すコマンドのメインルーチン / Take off an item
527 void do_cmd_takeoff(void)
533 if (p_ptr->special_defense & KATA_MUSOU)
535 set_action(ACTION_NONE);
538 q = _("どれを装備からはずしますか? ", "Take off which item? ");
539 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
541 if (!get_item(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
543 /* Get the item (in the pack) */
546 o_ptr = &inventory[item];
549 /* Get the item (on the floor) */
552 o_ptr = &o_list[0 - item];
557 if (object_is_cursed(o_ptr))
559 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
561 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
566 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
568 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
570 o_ptr->ident |= (IDENT_SENSE);
571 o_ptr->curse_flags = 0L;
572 o_ptr->feeling = FEEL_NONE;
574 p_ptr->update |= (PU_BONUS);
575 p_ptr->window |= (PW_EQUIP);
577 msg_print(_("呪いを打ち破った。", "You break the curse."));
581 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
582 p_ptr->energy_use = 50;
587 /* Take a partial turn */
588 p_ptr->energy_use = 50;
590 /* Take off the item */
591 (void)inven_takeoff(item, 255);
594 p_ptr->redraw |= (PR_EQUIPPY);
599 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
602 void do_cmd_drop(void)
611 if (p_ptr->special_defense & KATA_MUSOU)
613 set_action(ACTION_NONE);
616 q = _("どのアイテムを落としますか? ", "Drop which item? ");
617 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
619 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT))) return;
621 /* Get the item (in the pack) */
624 o_ptr = &inventory[item];
627 /* Get the item (on the floor) */
630 o_ptr = &o_list[0 - item];
634 /* Hack -- Cannot remove cursed items */
635 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
637 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
642 /* See how many items */
643 if (o_ptr->number > 1)
646 amt = get_quantity(NULL, o_ptr->number);
648 /* Allow user abort */
649 if (amt <= 0) return;
653 /* Take a partial turn */
654 p_ptr->energy_use = 50;
656 /* Drop (some of) the item */
657 inven_drop(item, amt);
659 if (item >= INVEN_RARM)
665 p_ptr->redraw |= (PR_EQUIPPY);
669 * @brief オブジェクトが高位の魔法書かどうかを判定する
670 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
671 * @return オブジェクトが高位の魔法書ならばTRUEを返す
673 static bool high_level_book(object_type *o_ptr)
675 if ((o_ptr->tval == TV_LIFE_BOOK) ||
676 (o_ptr->tval == TV_SORCERY_BOOK) ||
677 (o_ptr->tval == TV_NATURE_BOOK) ||
678 (o_ptr->tval == TV_CHAOS_BOOK) ||
679 (o_ptr->tval == TV_DEATH_BOOK) ||
680 (o_ptr->tval == TV_TRUMP_BOOK) ||
681 (o_ptr->tval == TV_CRAFT_BOOK) ||
682 (o_ptr->tval == TV_DAEMON_BOOK) ||
683 (o_ptr->tval == TV_CRUSADE_BOOK) ||
684 (o_ptr->tval == TV_MUSIC_BOOK) ||
685 (o_ptr->tval == TV_HEX_BOOK))
698 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
701 void do_cmd_destroy(void)
711 object_type *q_ptr = &forge;
713 GAME_TEXT o_name[MAX_NLEN];
714 char out_val[MAX_NLEN+40];
718 if (p_ptr->special_defense & KATA_MUSOU)
720 set_action(ACTION_NONE);
723 /* Hack -- force destruction */
724 if (command_arg > 0) force = TRUE;
726 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
727 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
729 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
731 /* Get the item (in the pack) */
734 o_ptr = &inventory[item];
737 /* Get the item (on the floor) */
740 o_ptr = &o_list[0 - item];
743 /* Verify unless quantity given beforehand */
744 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
746 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
748 /* Make a verification */
749 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
752 /* HACK : Add the line to message buffer */
753 message_add(out_val);
754 p_ptr->window |= (PW_MESSAGE);
757 /* Get an acceptable answer */
767 /* Erase the prompt */
771 if (i == 'y' || i == 'Y')
775 if (i == ESCAPE || i == 'n' || i == 'N')
782 /* Add an auto-destroy preference line */
783 if (autopick_autoregister(o_ptr))
785 /* Auto-destroy it */
786 autopick_alter_item(item, TRUE);
789 /* The object is already destroyed. */
795 /* See how many items */
796 if (o_ptr->number > 1)
799 amt = get_quantity(NULL, o_ptr->number);
801 /* Allow user abort */
802 if (amt <= 0) return;
806 old_number = o_ptr->number;
808 object_desc(o_name, o_ptr, 0);
809 o_ptr->number = old_number;
811 p_ptr->energy_use = 100;
813 /* Artifacts cannot be destroyed */
814 if (!can_player_destroy_object(o_ptr))
816 p_ptr->energy_use = 0;
818 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
822 object_copy(q_ptr, o_ptr);
824 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
825 sound(SOUND_DESTITEM);
827 /* Reduce the charges of rods/wands */
828 reduce_charges(o_ptr, amt);
830 /* Eliminate the item (from the pack) */
833 inven_item_increase(item, -amt);
834 inven_item_describe(item);
835 inven_item_optimize(item);
838 /* Eliminate the item (from the floor) */
841 floor_item_increase(0 - item, -amt);
842 floor_item_describe(0 - item);
843 floor_item_optimize(0 - item);
846 if (high_level_book(q_ptr))
848 bool gain_expr = FALSE;
850 if (p_ptr->prace == RACE_ANDROID)
853 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
857 else if (p_ptr->pclass == CLASS_PALADIN)
859 if (is_good_realm(p_ptr->realm1))
861 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
865 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
869 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
871 s32b tester_exp = p_ptr->max_exp / 20;
872 if (tester_exp > 10000) tester_exp = 10000;
873 if (q_ptr->sval < 3) tester_exp /= 4;
874 if (tester_exp<1) tester_exp = 1;
876 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
877 gain_exp(tester_exp * amt);
879 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
881 chg_virtue(V_UNLIFE, 1);
882 chg_virtue(V_VITALITY, -1);
884 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
886 chg_virtue(V_UNLIFE, -1);
887 chg_virtue(V_VITALITY, 1);
890 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
891 chg_virtue(V_ENCHANT, -1);
893 if (object_value_real(q_ptr) > 30000)
894 chg_virtue(V_SACRIFICE, 2);
896 else if (object_value_real(q_ptr) > 10000)
897 chg_virtue(V_SACRIFICE, 1);
900 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
901 chg_virtue(V_HARMONY, 1);
903 if (item >= INVEN_RARM) calc_android_exp();
908 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
911 void do_cmd_observe(void)
915 GAME_TEXT o_name[MAX_NLEN];
919 q = _("どのアイテムを調べますか? ", "Examine which item? ");
920 s = _("調べられるアイテムがない。", "You have nothing to examine.");
922 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
924 /* Get the item (in the pack) */
927 o_ptr = &inventory[item];
930 /* Get the item (on the floor) */
933 o_ptr = &o_list[0 - item];
937 /* Require full knowledge */
938 if (!(o_ptr->ident & IDENT_MENTAL))
940 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
946 object_desc(o_name, o_ptr, 0);
947 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
948 /* Describe it fully */
949 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
955 * @brief アイテムの銘を消すコマンドのメインルーチン
956 * Remove the inscription from an object XXX Mention item (when done)?
959 void do_cmd_uninscribe(void)
965 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
966 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
968 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
970 /* Get the item (in the pack) */
973 o_ptr = &inventory[item];
976 /* Get the item (on the floor) */
979 o_ptr = &o_list[0 - item];
982 /* Nothing to remove */
983 if (!o_ptr->inscription)
985 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
989 msg_print(_("銘を消した。", "Inscription removed."));
991 /* Remove the incription */
992 o_ptr->inscription = 0;
994 /* Combine the pack */
995 p_ptr->notice |= (PN_COMBINE);
997 p_ptr->window |= (PW_INVEN | PW_EQUIP);
999 /* .や$の関係で, 再計算が必要なはず -- henkma */
1000 p_ptr->update |= (PU_BONUS);
1006 * @brief アイテムの銘を刻むコマンドのメインルーチン
1007 * Inscribe an object with a comment
1010 void do_cmd_inscribe(void)
1014 GAME_TEXT o_name[MAX_NLEN];
1018 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1019 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1021 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1023 /* Get the item (in the pack) */
1026 o_ptr = &inventory[item];
1029 /* Get the item (on the floor) */
1032 o_ptr = &o_list[0 - item];
1035 /* Describe the activity */
1036 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1038 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1041 /* Start with nothing */
1042 strcpy(out_val, "");
1044 /* Use old inscription */
1045 if (o_ptr->inscription)
1047 /* Start with the old inscription */
1048 strcpy(out_val, quark_str(o_ptr->inscription));
1051 /* Get a new inscription (possibly empty) */
1052 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1054 /* Save the inscription */
1055 o_ptr->inscription = quark_add(out_val);
1057 /* Combine the pack */
1058 p_ptr->notice |= (PN_COMBINE);
1060 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1062 /* .や$の関係で, 再計算が必要なはず -- henkma */
1063 p_ptr->update |= (PU_BONUS);
1070 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1071 * An "item_tester_hook" for refilling lanterns
1072 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1073 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1075 static bool item_tester_refill_lantern(object_type *o_ptr)
1077 /* Flasks of oil are okay */
1078 if (o_ptr->tval == TV_FLASK) return (TRUE);
1080 /* Laterns are okay */
1081 if ((o_ptr->tval == TV_LITE) &&
1082 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1084 /* Assume not okay */
1090 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1091 * Refill the players lamp (from the pack or floor)
1094 static void do_cmd_refill_lamp(void)
1104 /* Restrict the choices */
1105 item_tester_hook = item_tester_refill_lantern;
1108 q = "どの油つぼから注ぎますか? ";
1111 q = "Refill with which flask? ";
1112 s = "You have no flasks of oil.";
1115 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1117 /* Get the item (in the pack) */
1120 o_ptr = &inventory[item];
1123 /* Get the item (on the floor) */
1126 o_ptr = &o_list[0 - item];
1129 /* Take a partial turn */
1130 p_ptr->energy_use = 50;
1132 /* Access the lantern */
1133 j_ptr = &inventory[INVEN_LITE];
1136 j_ptr->xtra4 += o_ptr->xtra4;
1137 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1139 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1142 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1144 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1147 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1149 else if (j_ptr->xtra4 >= FUEL_LAMP)
1151 j_ptr->xtra4 = FUEL_LAMP;
1152 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1155 /* Decrease the item (from the pack) */
1158 inven_item_increase(item, -1);
1159 inven_item_describe(item);
1160 inven_item_optimize(item);
1163 /* Decrease the item (from the floor) */
1166 floor_item_increase(0 - item, -1);
1167 floor_item_describe(0 - item);
1168 floor_item_optimize(0 - item);
1171 /* Recalculate torch */
1172 p_ptr->update |= (PU_TORCH);
1177 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1178 * An "item_tester_hook" for refilling torches
1179 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1180 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1182 static bool item_tester_refill_torch(object_type *o_ptr)
1184 /* Torches are okay */
1185 if ((o_ptr->tval == TV_LITE) &&
1186 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1188 /* Assume not okay */
1194 * @brief 松明を束ねるコマンドのメインルーチン
1195 * Refuel the players torch (from the pack or floor)
1198 static void do_cmd_refill_torch(void)
1207 /* Restrict the choices */
1208 item_tester_hook = item_tester_refill_torch;
1210 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1211 s = _("他に松明がない。", "You have no extra torches.");
1213 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1215 /* Get the item (in the pack) */
1218 o_ptr = &inventory[item];
1221 /* Get the item (on the floor) */
1224 o_ptr = &o_list[0 - item];
1228 /* Take a partial turn */
1229 p_ptr->energy_use = 50;
1231 /* Access the primary torch */
1232 j_ptr = &inventory[INVEN_LITE];
1235 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1237 msg_print(_("松明を結合した。", "You combine the torches."));
1239 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1242 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1244 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1247 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1249 /* Over-fuel message */
1250 else if (j_ptr->xtra4 >= FUEL_TORCH)
1252 j_ptr->xtra4 = FUEL_TORCH;
1253 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1256 /* Refuel message */
1259 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1262 /* Decrease the item (from the pack) */
1265 inven_item_increase(item, -1);
1266 inven_item_describe(item);
1267 inven_item_optimize(item);
1270 /* Decrease the item (from the floor) */
1273 floor_item_increase(0 - item, -1);
1274 floor_item_describe(0 - item);
1275 floor_item_optimize(0 - item);
1278 /* Recalculate torch */
1279 p_ptr->update |= (PU_TORCH);
1284 * @brief 燃料を補充するコマンドのメインルーチン
1285 * Refill the players lamp, or restock his torches
1288 void do_cmd_refill(void)
1293 o_ptr = &inventory[INVEN_LITE];
1295 if (p_ptr->special_defense & KATA_MUSOU)
1297 set_action(ACTION_NONE);
1301 if (o_ptr->tval != TV_LITE)
1303 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1307 else if (o_ptr->sval == SV_LITE_LANTERN)
1309 do_cmd_refill_lamp();
1313 else if (o_ptr->sval == SV_LITE_TORCH)
1315 do_cmd_refill_torch();
1318 /* No torch to refill */
1321 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1327 * @brief ターゲットを設定するコマンドのメインルーチン
1331 void do_cmd_target(void)
1334 if (target_set(TARGET_KILL))
1336 msg_print(_("ターゲット決定。", "Target Selected."));
1339 /* Target aborted */
1342 msg_print(_("ターゲット解除。", "Target Aborted."));
1349 * @brief 周囲を見渡すコマンドのメインルーチン
1353 void do_cmd_look(void)
1355 p_ptr->window |= PW_MONSTER_LIST;
1359 if (target_set(TARGET_LOOK))
1361 msg_print(_("ターゲット決定。", "Target Selected."));
1367 * @brief 位置を確認するコマンドのメインルーチン
1368 * Allow the player to examine other sectors on the map
1371 void do_cmd_locate(void)
1373 int dir, y1, x1, y2, x2;
1381 get_screen_size(&wid, &hgt);
1384 /* Start at current panel */
1385 y2 = y1 = panel_row_min;
1386 x2 = x1 = panel_col_min;
1388 /* Show panels until done */
1391 /* Describe the location */
1392 if ((y2 == y1) && (x2 == x1))
1395 strcpy(tmp_val, "真上");
1404 sprintf(tmp_val, "%s%s",
1405 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1406 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1408 sprintf(tmp_val, "%s%s of",
1409 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1410 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1415 /* Prepare to ask which way to look */
1416 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1417 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1418 y2 / (hgt / 2), y2 % (hgt / 2),
1419 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1421 /* Assume no direction */
1424 /* Get a direction */
1429 /* Get a command (or Cancel) */
1430 if (!get_com(out_val, &command, TRUE)) break;
1432 /* Extract the action (if any) */
1433 dir = get_keymap_dir(command);
1442 /* Apply the motion */
1443 if (change_panel(ddy[dir], ddx[dir]))
1451 /* Recenter the map around the player */
1454 p_ptr->update |= (PU_MONSTERS);
1456 p_ptr->redraw |= (PR_MAP);
1458 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1465 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1466 * Sorting hook -- Comp function -- see below
1467 * @param u モンスター種族情報の入れるポインタ
1469 * @param a 比較するモンスター種族のID1
1470 * @param b 比較するモンスター種族のID2
1471 * @return 2の方が大きければTRUEを返す
1472 * We use "u" to point to array of monster indexes,
1473 * and "v" to select the type of sorting to perform on "u".
1475 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1477 u16b *who = (u16b*)(u);
1479 u16b *why = (u16b*)(v);
1486 /* Sort by player kills */
1489 /* Extract player kills */
1490 z1 = r_info[w1].r_pkills;
1491 z2 = r_info[w2].r_pkills;
1493 /* Compare player kills */
1494 if (z1 < z2) return (TRUE);
1495 if (z1 > z2) return (FALSE);
1499 /* Sort by total kills */
1502 /* Extract total kills */
1503 z1 = r_info[w1].r_tkills;
1504 z2 = r_info[w2].r_tkills;
1506 /* Compare total kills */
1507 if (z1 < z2) return (TRUE);
1508 if (z1 > z2) return (FALSE);
1512 /* Sort by monster level */
1515 /* Extract levels */
1516 z1 = r_info[w1].level;
1517 z2 = r_info[w2].level;
1519 /* Compare levels */
1520 if (z1 < z2) return (TRUE);
1521 if (z1 > z2) return (FALSE);
1525 /* Sort by monster experience */
1528 /* Extract experience */
1529 z1 = r_info[w1].mexp;
1530 z2 = r_info[w2].mexp;
1532 /* Compare experience */
1533 if (z1 < z2) return (TRUE);
1534 if (z1 > z2) return (FALSE);
1538 /* Compare indexes */
1544 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1545 * Sorting hook -- Swap function -- see below
1546 * @param u モンスター種族情報の入れるポインタ
1548 * @param a スワップするモンスター種族のID1
1549 * @param b スワップするモンスター種族のID2
1552 * We use "u" to point to array of monster indexes,
1553 * and "v" to select the type of sorting to perform.
1555 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1557 u16b *who = (u16b*)(u);
1573 * @brief モンスターの思い出を見るコマンドのメインルーチン
1574 * Identify a character, allow recall of monsters
1578 * Several "special" responses recall "multiple" monsters:
1580 * ^U (all unique monsters)
1581 * ^N (all non-unique monsters)
1583 * The responses may be sorted in several ways, see below.
1585 * Note that the player ghosts are ignored.
1588 void do_cmd_query_symbol(void)
1602 bool recall = FALSE;
1607 /* Get a character, or abort */
1608 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1609 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1611 /* Find that character info, and describe it */
1612 for (i = 0; ident_info[i]; ++i)
1614 if (sym == ident_info[i][0]) break;
1616 if (sym == KTRL('A'))
1619 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1621 else if (sym == KTRL('U'))
1624 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1626 else if (sym == KTRL('N'))
1629 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1631 else if (sym == KTRL('R'))
1634 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1636 /* XTRA HACK WHATSEARCH */
1637 else if (sym == KTRL('M'))
1640 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1645 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1647 else if (ident_info[i])
1649 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1653 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1656 /* Display the result */
1659 /* Allocate the "who" array */
1660 C_MAKE(who, max_r_idx, IDX);
1662 /* Collect matching monsters */
1663 for (n = 0, i = 1; i < max_r_idx; i++)
1665 monster_race *r_ptr = &r_info[i];
1667 /* Nothing to recall */
1668 if (!cheat_know && !r_ptr->r_sights) continue;
1670 /* Require non-unique monsters if needed */
1671 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1673 /* Require unique monsters if needed */
1674 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1676 /* Require ridable monsters if needed */
1677 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1679 /* XTRA HACK WHATSEARCH */
1685 for (xx = 0; temp[xx] && xx < 80; xx++)
1688 if (iskanji(temp[xx])) { xx++; continue; }
1690 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1694 strcpy(temp2, r_name + r_ptr->E_name);
1696 strcpy(temp2, r_name + r_ptr->name);
1698 for (xx = 0; temp2[xx] && xx < 80; xx++)
1699 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1702 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1704 if (my_strstr(temp2, temp))
1709 /* Collect "appropriate" monsters */
1710 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1713 /* Nothing to recall */
1716 /* Free the "who" array */
1717 C_KILL(who, max_r_idx, IDX);
1723 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1733 /* Select the sort method */
1734 ang_sort_comp = ang_sort_comp_hook;
1735 ang_sort_swap = ang_sort_swap_hook;
1737 /* Sort the array */
1738 ang_sort(who, &why, n);
1740 /* Sort by kills (and level) */
1747 /* Catch "escape" */
1750 /* Free the "who" array */
1751 C_KILL(who, max_r_idx, IDX);
1756 /* Sort if needed */
1759 /* Select the sort method */
1760 ang_sort_comp = ang_sort_comp_hook;
1761 ang_sort_swap = ang_sort_swap_hook;
1763 /* Sort the array */
1764 ang_sort(who, &why, n);
1768 /* Start at the end */
1771 /* Scan the monster memory */
1774 /* Extract a race */
1777 /* Hack -- Auto-recall */
1778 monster_race_track(r_idx);
1789 /* Recall on screen */
1790 screen_roff(who[i], 0);
1793 /* Hack -- Begin the prompt */
1796 /* Hack -- Complete the prompt */
1797 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1809 /* Normal commands */
1810 if (query != 'r') break;
1817 if (query == ESCAPE) break;
1819 /* Move to "prev" monster */
1825 if (!expand_list) break;
1829 /* Move to "next" monster */
1835 if (!expand_list) break;
1840 /* Free the "who" array */
1841 C_KILL(who, max_r_idx, IDX);
1843 /* Re-display the identity */
1848 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1852 * XXX - Add actions for other item types
1854 void do_cmd_use(void)
1860 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1862 set_action(ACTION_NONE);
1865 item_tester_hook = item_tester_hook_use;
1867 q = _("どれを使いますか?", "Use which item? ");
1868 s = _("使えるものがありません。", "You have nothing to use.");
1870 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1872 /* Get the item (in the pack) */
1875 o_ptr = &inventory[item];
1877 /* Get the item (on the floor) */
1880 o_ptr = &o_list[0 - item];
1883 switch (o_ptr->tval)
1895 do_cmd_eat_food_aux(item);
1902 do_cmd_aim_wand_aux(item);
1909 do_cmd_use_staff_aux(item);
1916 do_cmd_zap_rod_aux(item);
1920 /* Quaff a potion */
1923 do_cmd_quaff_potion_aux(item);
1930 /* Check some conditions */
1933 msg_print(_("目が見えない。", "You can't see anything."));
1938 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
1941 if (p_ptr->confused)
1943 msg_print(_("混乱していて読めない!", "You are too confused!"));
1947 do_cmd_read_scroll_aux(item, TRUE);
1956 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
1960 /* Activate an artifact */
1963 do_cmd_activate_aux(item);