3 * @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory commands
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 #include "cmd-activate.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "player-item.h"
25 #include "object-hook.h"
29 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
32 void do_cmd_inven(void)
37 /* Note that we are in "inventory" mode */
40 /* Note that we are in "inventory" mode */
41 if (easy_floor) command_wrk = (USE_INVEN);
44 /* Hack -- show empty slots */
45 item_tester_full = TRUE;
47 /* Display the inventory */
50 /* Hack -- hide empty slots */
51 item_tester_full = FALSE;
54 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
55 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
56 (long int)((p_ptr->total_weight * 100) / weight_limit()));
58 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
59 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
60 (p_ptr->total_weight * 100) / weight_limit());
67 /* Get a new command */
68 command_new = inkey();
72 /* Process "Escape" */
73 if (command_new == ESCAPE)
77 Term_get_size(&wid, &hgt);
81 command_gap = wid - 30;
84 /* Process normal keys */
87 /* Hack -- Use "display" mode */
94 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
97 void do_cmd_equip(void)
102 /* Note that we are in "equipment" mode */
105 /* Note that we are in "equipment" mode */
106 if (easy_floor) command_wrk = (USE_EQUIP);
109 /* Hack -- show empty slots */
110 item_tester_full = TRUE;
112 (void)show_equip(0, 0L);
114 /* Hack -- undo the hack above */
115 item_tester_full = FALSE;
119 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
120 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
121 (long int)((p_ptr->total_weight * 100) / weight_limit()));
123 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
124 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
125 (long int)((p_ptr->total_weight * 100) / weight_limit()));
132 /* Get a new command */
133 command_new = inkey();
137 /* Process "Escape" */
138 if (command_new == ESCAPE)
142 Term_get_size(&wid, &hgt);
146 command_gap = wid - 30;
149 /* Process normal keys */
152 /* Enter "display" mode */
160 bool select_ring_slot = FALSE;
163 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
166 void do_cmd_wield(void)
168 OBJECT_IDX item, slot;
176 char o_name[MAX_NLEN];
179 OBJECT_IDX need_switch_wielding = 0;
181 if (p_ptr->special_defense & KATA_MUSOU)
183 set_action(ACTION_NONE);
186 /* Restrict the choices */
187 item_tester_hook = item_tester_hook_wear;
189 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
190 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
192 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
196 slot = wield_slot(o_ptr);
200 /* Shields and some misc. items */
205 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
207 /* Restrict the choices */
208 item_tester_hook = item_tester_hook_melee_weapon;
210 /* Choose a weapon from the equipment only */
211 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
212 s = _("おっと。", "Oops.");
213 if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
214 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
217 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
219 /* Both arms are already used by non-weapon */
220 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
221 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
223 /* Restrict the choices */
224 item_tester_hook = item_tester_hook_mochikae;
227 q = _("どちらの手に装備しますか?", "Equip which hand? ");
228 s = _("おっと。", "Oops.");
229 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
238 /* Asking for dual wielding */
239 if (slot == INVEN_LARM)
241 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
244 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
246 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
249 /* Both arms are already used */
250 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
252 /* Restrict the choices */
253 item_tester_hook = item_tester_hook_mochikae;
256 q = _("どちらの手に装備しますか?", "Equip which hand? ");
257 s = _("おっと。", "Oops.");
259 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
260 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
261 need_switch_wielding = INVEN_RARM;
267 /* Choose a ring slot */
268 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
270 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
274 q = _("どちらの手に装備しますか?", "Equip which hand? ");
276 s = _("おっと。", "Oops.");
278 /* Restrict the choices */
279 select_ring_slot = TRUE;
281 if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
283 select_ring_slot = FALSE;
286 select_ring_slot = FALSE;
290 /* Prevent wielding into a cursed slot */
291 if (object_is_cursed(&inventory[slot]))
293 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
296 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
298 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
301 /* Cancel the command */
306 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
307 ((o_ptr->ident & IDENT_SENSE) &&
308 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
310 char dummy[MAX_NLEN+80];
312 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
313 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
315 if (!get_check(dummy)) return;
318 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
320 char dummy[MAX_NLEN+80];
322 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
325 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
327 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
328 sprintf(dummy, "Do you become a vampire?");
331 if (!get_check(dummy)) return;
334 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
336 object_type *slot_o_ptr = &inventory[slot];
337 object_type *switch_o_ptr = &inventory[need_switch_wielding];
338 object_type object_tmp;
339 object_type *otmp_ptr = &object_tmp;
340 char switch_name[MAX_NLEN];
342 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
344 object_copy(otmp_ptr, switch_o_ptr);
345 object_copy(switch_o_ptr, slot_o_ptr);
346 object_copy(slot_o_ptr, otmp_ptr);
348 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
349 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
350 (left_hander ? _("右手", "right") : _("左手", "left")));
351 slot = need_switch_wielding;
354 check_find_art_quest_completion(o_ptr);
356 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
358 identify_item(o_ptr);
360 /* Auto-inscription */
361 autopick_alter_item(item, FALSE);
364 p_ptr->energy_use = 100;
367 /* Obtain local object */
368 object_copy(q_ptr, o_ptr);
370 /* Modify quantity */
373 /* Decrease the item (from the pack) */
376 inven_item_increase(item, -1);
377 inven_item_optimize(item);
380 /* Decrease the item (from the floor) */
383 floor_item_increase(0 - item, -1);
384 floor_item_optimize(0 - item);
387 /* Access the wield slot */
388 o_ptr = &inventory[slot];
390 /* Take off existing item */
393 /* Take off existing item */
394 (void)inven_takeoff(slot, 255);
397 /* Wear the new stuff */
398 object_copy(o_ptr, q_ptr);
400 /* Player touches it */
401 o_ptr->marked |= OM_TOUCHED;
403 /* Increase the weight */
404 p_ptr->total_weight += q_ptr->weight;
406 /* Increment the equip counter by hand */
410 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
411 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
412 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
414 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
415 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
416 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
419 /* Where is the item now */
423 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
424 act = STR_WIELD_ARMS;
426 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
430 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
431 act = STR_WIELD_ARMS;
433 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
437 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
441 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
445 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
449 object_desc(o_name, o_ptr, 0);
450 msg_format(act, o_name, index_to_label(slot));
453 if (object_is_cursed(o_ptr))
455 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
456 chg_virtue(V_HARMONY, -1);
459 o_ptr->ident |= (IDENT_SENSE);
462 /* The Stone Mask make the player turn into a vampire! */
463 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
465 /* Turn into a vampire */
466 change_race(RACE_VAMPIRE, "");
469 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
470 p_ptr->redraw |= (PR_EQUIPPY);
471 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
478 * @param item 持ち替えを行いたい装備部位ID
481 void kamaenaoshi(INVENTORY_IDX item)
483 object_type *o_ptr, *new_o_ptr;
484 char o_name[MAX_NLEN];
486 if (item == INVEN_RARM)
488 if (buki_motteruka(INVEN_LARM))
490 o_ptr = &inventory[INVEN_LARM];
491 object_desc(o_name, o_ptr, 0);
493 if (!object_is_cursed(o_ptr))
495 new_o_ptr = &inventory[INVEN_RARM];
496 object_copy(new_o_ptr, o_ptr);
497 p_ptr->total_weight += o_ptr->weight;
498 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
499 inven_item_optimize(INVEN_LARM);
500 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
501 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
503 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
504 (left_hander ? _("左手", "left") : _("右手", "right")));
508 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
509 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
513 else if (item == INVEN_LARM)
515 o_ptr = &inventory[INVEN_RARM];
516 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
518 if (buki_motteruka(INVEN_RARM))
520 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
521 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
523 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
525 new_o_ptr = &inventory[INVEN_LARM];
526 object_copy(new_o_ptr, o_ptr);
527 p_ptr->total_weight += o_ptr->weight;
528 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
529 inven_item_optimize(INVEN_RARM);
530 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
537 * @brief 装備を外すコマンドのメインルーチン / Take off an item
540 void do_cmd_takeoff(void)
546 if (p_ptr->special_defense & KATA_MUSOU)
548 set_action(ACTION_NONE);
551 q = _("どれを装備からはずしますか? ", "Take off which item? ");
552 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
554 if (!get_item(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
556 /* Get the item (in the pack) */
559 o_ptr = &inventory[item];
562 /* Get the item (on the floor) */
565 o_ptr = &o_list[0 - item];
570 if (object_is_cursed(o_ptr))
572 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
574 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
579 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
581 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
583 o_ptr->ident |= (IDENT_SENSE);
584 o_ptr->curse_flags = 0L;
585 o_ptr->feeling = FEEL_NONE;
587 p_ptr->update |= (PU_BONUS);
588 p_ptr->window |= (PW_EQUIP);
590 msg_print(_("呪いを打ち破った。", "You break the curse."));
594 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
595 p_ptr->energy_use = 50;
600 /* Take a partial turn */
601 p_ptr->energy_use = 50;
603 /* Take off the item */
604 (void)inven_takeoff(item, 255);
607 p_ptr->redraw |= (PR_EQUIPPY);
612 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
615 void do_cmd_drop(void)
624 if (p_ptr->special_defense & KATA_MUSOU)
626 set_action(ACTION_NONE);
629 q = _("どのアイテムを落としますか? ", "Drop which item? ");
630 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
632 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT))) return;
634 /* Get the item (in the pack) */
637 o_ptr = &inventory[item];
640 /* Get the item (on the floor) */
643 o_ptr = &o_list[0 - item];
647 /* Hack -- Cannot remove cursed items */
648 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
650 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
655 /* See how many items */
656 if (o_ptr->number > 1)
659 amt = get_quantity(NULL, o_ptr->number);
661 /* Allow user abort */
662 if (amt <= 0) return;
666 /* Take a partial turn */
667 p_ptr->energy_use = 50;
669 /* Drop (some of) the item */
670 inven_drop(item, amt);
672 if (item >= INVEN_RARM)
678 p_ptr->redraw |= (PR_EQUIPPY);
682 * @brief オブジェクトが高位の魔法書かどうかを判定する
683 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
684 * @return オブジェクトが高位の魔法書ならばTRUEを返す
686 static bool high_level_book(object_type *o_ptr)
688 if ((o_ptr->tval == TV_LIFE_BOOK) ||
689 (o_ptr->tval == TV_SORCERY_BOOK) ||
690 (o_ptr->tval == TV_NATURE_BOOK) ||
691 (o_ptr->tval == TV_CHAOS_BOOK) ||
692 (o_ptr->tval == TV_DEATH_BOOK) ||
693 (o_ptr->tval == TV_TRUMP_BOOK) ||
694 (o_ptr->tval == TV_CRAFT_BOOK) ||
695 (o_ptr->tval == TV_DAEMON_BOOK) ||
696 (o_ptr->tval == TV_CRUSADE_BOOK) ||
697 (o_ptr->tval == TV_MUSIC_BOOK) ||
698 (o_ptr->tval == TV_HEX_BOOK))
711 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
714 void do_cmd_destroy(void)
724 object_type *q_ptr = &forge;
726 char o_name[MAX_NLEN];
727 char out_val[MAX_NLEN+40];
731 if (p_ptr->special_defense & KATA_MUSOU)
733 set_action(ACTION_NONE);
736 /* Hack -- force destruction */
737 if (command_arg > 0) force = TRUE;
739 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
740 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
742 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
744 /* Get the item (in the pack) */
747 o_ptr = &inventory[item];
750 /* Get the item (on the floor) */
753 o_ptr = &o_list[0 - item];
756 /* Verify unless quantity given beforehand */
757 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
759 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
761 /* Make a verification */
762 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
765 /* HACK : Add the line to message buffer */
766 message_add(out_val);
767 p_ptr->window |= (PW_MESSAGE);
770 /* Get an acceptable answer */
780 /* Erase the prompt */
784 if (i == 'y' || i == 'Y')
788 if (i == ESCAPE || i == 'n' || i == 'N')
795 /* Add an auto-destroy preference line */
796 if (autopick_autoregister(o_ptr))
798 /* Auto-destroy it */
799 autopick_alter_item(item, TRUE);
802 /* The object is already destroyed. */
808 /* See how many items */
809 if (o_ptr->number > 1)
812 amt = get_quantity(NULL, o_ptr->number);
814 /* Allow user abort */
815 if (amt <= 0) return;
819 old_number = o_ptr->number;
821 object_desc(o_name, o_ptr, 0);
822 o_ptr->number = old_number;
824 p_ptr->energy_use = 100;
826 /* Artifacts cannot be destroyed */
827 if (!can_player_destroy_object(o_ptr))
829 p_ptr->energy_use = 0;
831 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
835 object_copy(q_ptr, o_ptr);
837 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
838 sound(SOUND_DESTITEM);
840 /* Reduce the charges of rods/wands */
841 reduce_charges(o_ptr, amt);
843 /* Eliminate the item (from the pack) */
846 inven_item_increase(item, -amt);
847 inven_item_describe(item);
848 inven_item_optimize(item);
851 /* Eliminate the item (from the floor) */
854 floor_item_increase(0 - item, -amt);
855 floor_item_describe(0 - item);
856 floor_item_optimize(0 - item);
859 if (high_level_book(q_ptr))
861 bool gain_expr = FALSE;
863 if (p_ptr->prace == RACE_ANDROID)
866 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
870 else if (p_ptr->pclass == CLASS_PALADIN)
872 if (is_good_realm(p_ptr->realm1))
874 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
878 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
882 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
884 s32b tester_exp = p_ptr->max_exp / 20;
885 if (tester_exp > 10000) tester_exp = 10000;
886 if (q_ptr->sval < 3) tester_exp /= 4;
887 if (tester_exp<1) tester_exp = 1;
889 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
890 gain_exp(tester_exp * amt);
892 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
894 chg_virtue(V_UNLIFE, 1);
895 chg_virtue(V_VITALITY, -1);
897 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
899 chg_virtue(V_UNLIFE, -1);
900 chg_virtue(V_VITALITY, 1);
903 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
904 chg_virtue(V_ENCHANT, -1);
906 if (object_value_real(q_ptr) > 30000)
907 chg_virtue(V_SACRIFICE, 2);
909 else if (object_value_real(q_ptr) > 10000)
910 chg_virtue(V_SACRIFICE, 1);
913 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
914 chg_virtue(V_HARMONY, 1);
916 if (item >= INVEN_RARM) calc_android_exp();
921 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
924 void do_cmd_observe(void)
928 char o_name[MAX_NLEN];
932 q = _("どのアイテムを調べますか? ", "Examine which item? ");
933 s = _("調べられるアイテムがない。", "You have nothing to examine.");
935 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
937 /* Get the item (in the pack) */
940 o_ptr = &inventory[item];
943 /* Get the item (on the floor) */
946 o_ptr = &o_list[0 - item];
950 /* Require full knowledge */
951 if (!(o_ptr->ident & IDENT_MENTAL))
953 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
959 object_desc(o_name, o_ptr, 0);
960 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
961 /* Describe it fully */
962 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
968 * @brief アイテムの銘を消すコマンドのメインルーチン
969 * Remove the inscription from an object XXX Mention item (when done)?
972 void do_cmd_uninscribe(void)
978 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
979 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
981 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
983 /* Get the item (in the pack) */
986 o_ptr = &inventory[item];
989 /* Get the item (on the floor) */
992 o_ptr = &o_list[0 - item];
995 /* Nothing to remove */
996 if (!o_ptr->inscription)
998 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1002 msg_print(_("銘を消した。", "Inscription removed."));
1004 /* Remove the incription */
1005 o_ptr->inscription = 0;
1007 /* Combine the pack */
1008 p_ptr->notice |= (PN_COMBINE);
1010 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1012 /* .や$の関係で, 再計算が必要なはず -- henkma */
1013 p_ptr->update |= (PU_BONUS);
1019 * @brief アイテムの銘を刻むコマンドのメインルーチン
1020 * Inscribe an object with a comment
1023 void do_cmd_inscribe(void)
1027 char o_name[MAX_NLEN];
1031 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1032 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1034 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1036 /* Get the item (in the pack) */
1039 o_ptr = &inventory[item];
1042 /* Get the item (on the floor) */
1045 o_ptr = &o_list[0 - item];
1048 /* Describe the activity */
1049 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1051 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1054 /* Start with nothing */
1055 strcpy(out_val, "");
1057 /* Use old inscription */
1058 if (o_ptr->inscription)
1060 /* Start with the old inscription */
1061 strcpy(out_val, quark_str(o_ptr->inscription));
1064 /* Get a new inscription (possibly empty) */
1065 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1067 /* Save the inscription */
1068 o_ptr->inscription = quark_add(out_val);
1070 /* Combine the pack */
1071 p_ptr->notice |= (PN_COMBINE);
1073 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1075 /* .や$の関係で, 再計算が必要なはず -- henkma */
1076 p_ptr->update |= (PU_BONUS);
1083 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1084 * An "item_tester_hook" for refilling lanterns
1085 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1086 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1088 static bool item_tester_refill_lantern(object_type *o_ptr)
1090 /* Flasks of oil are okay */
1091 if (o_ptr->tval == TV_FLASK) return (TRUE);
1093 /* Laterns are okay */
1094 if ((o_ptr->tval == TV_LITE) &&
1095 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1097 /* Assume not okay */
1103 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1104 * Refill the players lamp (from the pack or floor)
1107 static void do_cmd_refill_lamp(void)
1117 /* Restrict the choices */
1118 item_tester_hook = item_tester_refill_lantern;
1121 q = "どの油つぼから注ぎますか? ";
1124 q = "Refill with which flask? ";
1125 s = "You have no flasks of oil.";
1128 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1130 /* Get the item (in the pack) */
1133 o_ptr = &inventory[item];
1136 /* Get the item (on the floor) */
1139 o_ptr = &o_list[0 - item];
1142 /* Take a partial turn */
1143 p_ptr->energy_use = 50;
1145 /* Access the lantern */
1146 j_ptr = &inventory[INVEN_LITE];
1149 j_ptr->xtra4 += o_ptr->xtra4;
1150 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1152 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1155 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1157 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1160 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1162 else if (j_ptr->xtra4 >= FUEL_LAMP)
1164 j_ptr->xtra4 = FUEL_LAMP;
1165 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1168 /* Decrease the item (from the pack) */
1171 inven_item_increase(item, -1);
1172 inven_item_describe(item);
1173 inven_item_optimize(item);
1176 /* Decrease the item (from the floor) */
1179 floor_item_increase(0 - item, -1);
1180 floor_item_describe(0 - item);
1181 floor_item_optimize(0 - item);
1184 /* Recalculate torch */
1185 p_ptr->update |= (PU_TORCH);
1190 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1191 * An "item_tester_hook" for refilling torches
1192 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1193 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1195 static bool item_tester_refill_torch(object_type *o_ptr)
1197 /* Torches are okay */
1198 if ((o_ptr->tval == TV_LITE) &&
1199 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1201 /* Assume not okay */
1207 * @brief 松明を束ねるコマンドのメインルーチン
1208 * Refuel the players torch (from the pack or floor)
1211 static void do_cmd_refill_torch(void)
1220 /* Restrict the choices */
1221 item_tester_hook = item_tester_refill_torch;
1223 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1224 s = _("他に松明がない。", "You have no extra torches.");
1226 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1228 /* Get the item (in the pack) */
1231 o_ptr = &inventory[item];
1234 /* Get the item (on the floor) */
1237 o_ptr = &o_list[0 - item];
1241 /* Take a partial turn */
1242 p_ptr->energy_use = 50;
1244 /* Access the primary torch */
1245 j_ptr = &inventory[INVEN_LITE];
1248 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1250 msg_print(_("松明を結合した。", "You combine the torches."));
1252 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1255 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1257 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1260 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1262 /* Over-fuel message */
1263 else if (j_ptr->xtra4 >= FUEL_TORCH)
1265 j_ptr->xtra4 = FUEL_TORCH;
1266 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1269 /* Refuel message */
1272 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1275 /* Decrease the item (from the pack) */
1278 inven_item_increase(item, -1);
1279 inven_item_describe(item);
1280 inven_item_optimize(item);
1283 /* Decrease the item (from the floor) */
1286 floor_item_increase(0 - item, -1);
1287 floor_item_describe(0 - item);
1288 floor_item_optimize(0 - item);
1291 /* Recalculate torch */
1292 p_ptr->update |= (PU_TORCH);
1297 * @brief 燃料を補充するコマンドのメインルーチン
1298 * Refill the players lamp, or restock his torches
1301 void do_cmd_refill(void)
1306 o_ptr = &inventory[INVEN_LITE];
1308 if (p_ptr->special_defense & KATA_MUSOU)
1310 set_action(ACTION_NONE);
1314 if (o_ptr->tval != TV_LITE)
1316 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1320 else if (o_ptr->sval == SV_LITE_LANTERN)
1322 do_cmd_refill_lamp();
1326 else if (o_ptr->sval == SV_LITE_TORCH)
1328 do_cmd_refill_torch();
1331 /* No torch to refill */
1334 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1340 * @brief ターゲットを設定するコマンドのメインルーチン
1344 void do_cmd_target(void)
1347 if (target_set(TARGET_KILL))
1349 msg_print(_("ターゲット決定。", "Target Selected."));
1352 /* Target aborted */
1355 msg_print(_("ターゲット解除。", "Target Aborted."));
1362 * @brief 周囲を見渡すコマンドのメインルーチン
1366 void do_cmd_look(void)
1368 p_ptr->window |= PW_MONSTER_LIST;
1372 if (target_set(TARGET_LOOK))
1374 msg_print(_("ターゲット決定。", "Target Selected."));
1380 * @brief 位置を確認するコマンドのメインルーチン
1381 * Allow the player to examine other sectors on the map
1384 void do_cmd_locate(void)
1386 int dir, y1, x1, y2, x2;
1394 get_screen_size(&wid, &hgt);
1397 /* Start at current panel */
1398 y2 = y1 = panel_row_min;
1399 x2 = x1 = panel_col_min;
1401 /* Show panels until done */
1404 /* Describe the location */
1405 if ((y2 == y1) && (x2 == x1))
1408 strcpy(tmp_val, "真上");
1417 sprintf(tmp_val, "%s%s",
1418 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1419 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1421 sprintf(tmp_val, "%s%s of",
1422 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1423 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1428 /* Prepare to ask which way to look */
1429 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1430 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1431 y2 / (hgt / 2), y2 % (hgt / 2),
1432 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1434 /* Assume no direction */
1437 /* Get a direction */
1442 /* Get a command (or Cancel) */
1443 if (!get_com(out_val, &command, TRUE)) break;
1445 /* Extract the action (if any) */
1446 dir = get_keymap_dir(command);
1455 /* Apply the motion */
1456 if (change_panel(ddy[dir], ddx[dir]))
1464 /* Recenter the map around the player */
1467 p_ptr->update |= (PU_MONSTERS);
1469 p_ptr->redraw |= (PR_MAP);
1471 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1478 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1479 * Sorting hook -- Comp function -- see below
1480 * @param u モンスター種族情報の入れるポインタ
1482 * @param a 比較するモンスター種族のID1
1483 * @param b 比較するモンスター種族のID2
1484 * @return 2の方が大きければTRUEを返す
1485 * We use "u" to point to array of monster indexes,
1486 * and "v" to select the type of sorting to perform on "u".
1488 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1490 u16b *who = (u16b*)(u);
1492 u16b *why = (u16b*)(v);
1499 /* Sort by player kills */
1502 /* Extract player kills */
1503 z1 = r_info[w1].r_pkills;
1504 z2 = r_info[w2].r_pkills;
1506 /* Compare player kills */
1507 if (z1 < z2) return (TRUE);
1508 if (z1 > z2) return (FALSE);
1512 /* Sort by total kills */
1515 /* Extract total kills */
1516 z1 = r_info[w1].r_tkills;
1517 z2 = r_info[w2].r_tkills;
1519 /* Compare total kills */
1520 if (z1 < z2) return (TRUE);
1521 if (z1 > z2) return (FALSE);
1525 /* Sort by monster level */
1528 /* Extract levels */
1529 z1 = r_info[w1].level;
1530 z2 = r_info[w2].level;
1532 /* Compare levels */
1533 if (z1 < z2) return (TRUE);
1534 if (z1 > z2) return (FALSE);
1538 /* Sort by monster experience */
1541 /* Extract experience */
1542 z1 = r_info[w1].mexp;
1543 z2 = r_info[w2].mexp;
1545 /* Compare experience */
1546 if (z1 < z2) return (TRUE);
1547 if (z1 > z2) return (FALSE);
1551 /* Compare indexes */
1557 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1558 * Sorting hook -- Swap function -- see below
1559 * @param u モンスター種族情報の入れるポインタ
1561 * @param a スワップするモンスター種族のID1
1562 * @param b スワップするモンスター種族のID2
1565 * We use "u" to point to array of monster indexes,
1566 * and "v" to select the type of sorting to perform.
1568 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1570 u16b *who = (u16b*)(u);
1586 * @brief モンスターの思い出を見るコマンドのメインルーチン
1587 * Identify a character, allow recall of monsters
1591 * Several "special" responses recall "multiple" monsters:
1593 * ^U (all unique monsters)
1594 * ^N (all non-unique monsters)
1596 * The responses may be sorted in several ways, see below.
1598 * Note that the player ghosts are ignored.
1601 void do_cmd_query_symbol(void)
1615 bool recall = FALSE;
1620 /* Get a character, or abort */
1621 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1622 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1624 /* Find that character info, and describe it */
1625 for (i = 0; ident_info[i]; ++i)
1627 if (sym == ident_info[i][0]) break;
1629 if (sym == KTRL('A'))
1632 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1634 else if (sym == KTRL('U'))
1637 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1639 else if (sym == KTRL('N'))
1642 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1644 else if (sym == KTRL('R'))
1647 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1649 /* XTRA HACK WHATSEARCH */
1650 else if (sym == KTRL('M'))
1653 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1658 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1660 else if (ident_info[i])
1662 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1666 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1669 /* Display the result */
1672 /* Allocate the "who" array */
1673 C_MAKE(who, max_r_idx, IDX);
1675 /* Collect matching monsters */
1676 for (n = 0, i = 1; i < max_r_idx; i++)
1678 monster_race *r_ptr = &r_info[i];
1680 /* Nothing to recall */
1681 if (!cheat_know && !r_ptr->r_sights) continue;
1683 /* Require non-unique monsters if needed */
1684 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1686 /* Require unique monsters if needed */
1687 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1689 /* Require ridable monsters if needed */
1690 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1692 /* XTRA HACK WHATSEARCH */
1698 for (xx = 0; temp[xx] && xx < 80; xx++)
1701 if (iskanji(temp[xx])) { xx++; continue; }
1703 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1707 strcpy(temp2, r_name + r_ptr->E_name);
1709 strcpy(temp2, r_name + r_ptr->name);
1711 for (xx = 0; temp2[xx] && xx < 80; xx++)
1712 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1715 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1717 if (my_strstr(temp2, temp))
1722 /* Collect "appropriate" monsters */
1723 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1726 /* Nothing to recall */
1729 /* Free the "who" array */
1730 C_KILL(who, max_r_idx, IDX);
1736 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1746 /* Select the sort method */
1747 ang_sort_comp = ang_sort_comp_hook;
1748 ang_sort_swap = ang_sort_swap_hook;
1750 /* Sort the array */
1751 ang_sort(who, &why, n);
1753 /* Sort by kills (and level) */
1760 /* Catch "escape" */
1763 /* Free the "who" array */
1764 C_KILL(who, max_r_idx, IDX);
1769 /* Sort if needed */
1772 /* Select the sort method */
1773 ang_sort_comp = ang_sort_comp_hook;
1774 ang_sort_swap = ang_sort_swap_hook;
1776 /* Sort the array */
1777 ang_sort(who, &why, n);
1781 /* Start at the end */
1784 /* Scan the monster memory */
1787 /* Extract a race */
1790 /* Hack -- Auto-recall */
1791 monster_race_track(r_idx);
1802 /* Recall on screen */
1803 screen_roff(who[i], 0);
1806 /* Hack -- Begin the prompt */
1809 /* Hack -- Complete the prompt */
1810 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1822 /* Normal commands */
1823 if (query != 'r') break;
1830 if (query == ESCAPE) break;
1832 /* Move to "prev" monster */
1838 if (!expand_list) break;
1842 /* Move to "next" monster */
1848 if (!expand_list) break;
1853 /* Free the "who" array */
1854 C_KILL(who, max_r_idx, IDX);
1856 /* Re-display the identity */
1861 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1865 * XXX - Add actions for other item types
1867 void do_cmd_use(void)
1873 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1875 set_action(ACTION_NONE);
1878 item_tester_hook = item_tester_hook_use;
1880 q = _("どれを使いますか?", "Use which item? ");
1881 s = _("使えるものがありません。", "You have nothing to use.");
1883 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1885 /* Get the item (in the pack) */
1888 o_ptr = &inventory[item];
1890 /* Get the item (on the floor) */
1893 o_ptr = &o_list[0 - item];
1896 switch (o_ptr->tval)
1908 do_cmd_eat_food_aux(item);
1915 do_cmd_aim_wand_aux(item);
1922 do_cmd_use_staff_aux(item);
1929 do_cmd_zap_rod_aux(item);
1933 /* Quaff a potion */
1936 do_cmd_quaff_potion_aux(item);
1943 /* Check some conditions */
1946 msg_print(_("目が見えない。", "You can't see anything."));
1951 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
1954 if (p_ptr->confused)
1956 msg_print(_("混乱していて読めない!", "You are too confused!"));
1960 do_cmd_read_scroll_aux(item, TRUE);
1969 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
1973 /* Activate an artifact */
1976 do_cmd_activate_aux(item);