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);
108 /* Save the screen */
111 /* Hack -- show empty slots */
112 item_tester_full = TRUE;
114 /* Display the equipment */
117 /* Hack -- undo the hack above */
118 item_tester_full = FALSE;
122 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
123 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
124 (long int)((p_ptr->total_weight * 100) / weight_limit()));
126 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
127 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
128 (long int)((p_ptr->total_weight * 100) / weight_limit()));
135 /* Get a new command */
136 command_new = inkey();
138 /* Restore the screen */
142 /* Process "Escape" */
143 if (command_new == ESCAPE)
147 Term_get_size(&wid, &hgt);
151 command_gap = wid - 30;
154 /* Process normal keys */
157 /* Enter "display" mode */
165 bool select_ring_slot = FALSE;
168 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
171 void do_cmd_wield(void)
173 OBJECT_IDX item, slot;
182 char o_name[MAX_NLEN];
186 OBJECT_IDX need_switch_wielding = 0;
188 if (p_ptr->special_defense & KATA_MUSOU)
190 set_action(ACTION_NONE);
193 /* Restrict the choices */
194 item_tester_hook = item_tester_hook_wear;
196 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
197 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
199 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
201 /* Get the item (in the pack) */
204 o_ptr = &inventory[item];
207 /* Get the item (on the floor) */
210 o_ptr = &o_list[0 - item];
215 slot = wield_slot(o_ptr);
219 /* Shields and some misc. items */
224 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
226 /* Restrict the choices */
227 item_tester_hook = item_tester_hook_melee_weapon;
228 item_tester_no_ryoute = TRUE;
230 /* Choose a weapon from the equipment only */
231 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
232 s = _("おっと。", "Oops.");
233 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
234 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
237 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
239 /* Both arms are already used by non-weapon */
240 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
241 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
243 /* Restrict the choices */
244 item_tester_hook = item_tester_hook_mochikae;
247 q = _("どちらの手に装備しますか?", "Equip which hand? ");
248 s = _("おっと。", "Oops.");
249 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
258 /* Asking for dual wielding */
259 if (slot == INVEN_LARM)
261 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
264 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
266 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
269 /* Both arms are already used */
270 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
272 /* Restrict the choices */
273 item_tester_hook = item_tester_hook_mochikae;
276 q = _("どちらの手に装備しますか?", "Equip which hand? ");
277 s = _("おっと。", "Oops.");
279 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
280 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
281 need_switch_wielding = INVEN_RARM;
287 /* Choose a ring slot */
288 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
290 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
294 q = _("どちらの手に装備しますか?", "Equip which hand? ");
296 s = _("おっと。", "Oops.");
298 /* Restrict the choices */
299 select_ring_slot = TRUE;
300 item_tester_no_ryoute = TRUE;
302 if (!get_item(&slot, q, s, (USE_EQUIP)))
304 select_ring_slot = FALSE;
307 select_ring_slot = FALSE;
311 /* Prevent wielding into a cursed slot */
312 if (object_is_cursed(&inventory[slot]))
315 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
318 msg_format("%s%sは呪われているようだ。",
319 describe_use(slot) , o_name );
321 msg_format("The %s you are %s appears to be cursed.",
322 o_name, describe_use(slot));
325 /* Cancel the command */
330 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
331 ((o_ptr->ident & IDENT_SENSE) &&
332 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
334 char dummy[MAX_NLEN+80];
337 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
338 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
340 if (!get_check(dummy)) return;
343 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
345 char dummy[MAX_NLEN+80];
348 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
351 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
353 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
354 sprintf(dummy, "Do you become a vampire?");
357 if (!get_check(dummy)) return;
360 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
362 object_type *slot_o_ptr = &inventory[slot];
363 object_type *switch_o_ptr = &inventory[need_switch_wielding];
364 object_type object_tmp;
365 object_type *otmp_ptr = &object_tmp;
366 char switch_name[MAX_NLEN];
368 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
370 object_copy(otmp_ptr, switch_o_ptr);
371 object_copy(switch_o_ptr, slot_o_ptr);
372 object_copy(slot_o_ptr, otmp_ptr);
374 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
375 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
376 (left_hander ? _("右手", "right") : _("左手", "left")));
377 slot = need_switch_wielding;
380 check_find_art_quest_completion(o_ptr);
382 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
384 identify_item(o_ptr);
386 /* Auto-inscription */
387 autopick_alter_item(item, FALSE);
390 p_ptr->energy_use = 100;
393 /* Obtain local object */
394 object_copy(q_ptr, o_ptr);
396 /* Modify quantity */
399 /* Decrease the item (from the pack) */
402 inven_item_increase(item, -1);
403 inven_item_optimize(item);
406 /* Decrease the item (from the floor) */
409 floor_item_increase(0 - item, -1);
410 floor_item_optimize(0 - item);
413 /* Access the wield slot */
414 o_ptr = &inventory[slot];
416 /* Take off existing item */
419 /* Take off existing item */
420 (void)inven_takeoff(slot, 255);
423 /* Wear the new stuff */
424 object_copy(o_ptr, q_ptr);
426 /* Player touches it */
427 o_ptr->marked |= OM_TOUCHED;
429 /* Increase the weight */
430 p_ptr->total_weight += q_ptr->weight;
432 /* Increment the equip counter by hand */
436 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
437 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
438 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
440 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
441 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
442 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
445 /* Where is the item now */
449 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
450 act = STR_WIELD_ARMS;
452 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
456 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
457 act = STR_WIELD_ARMS;
459 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
463 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
467 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
471 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
475 /* Describe the result */
476 object_desc(o_name, o_ptr, 0);
477 msg_format(act, o_name, index_to_label(slot));
480 if (object_is_cursed(o_ptr))
482 /* Warn the player */
483 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
484 chg_virtue(V_HARMONY, -1);
487 o_ptr->ident |= (IDENT_SENSE);
490 /* The Stone Mask make the player turn into a vampire! */
491 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
493 /* Turn into a vampire */
494 change_race(RACE_VAMPIRE, "");
497 /* Recalculate bonuses */
498 p_ptr->update |= (PU_BONUS);
500 /* Recalculate torch */
501 p_ptr->update |= (PU_TORCH);
503 /* Recalculate mana */
504 p_ptr->update |= (PU_MANA);
506 p_ptr->redraw |= (PR_EQUIPPY);
508 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
515 * @param item 持ち替えを行いたい装備部位ID
518 void kamaenaoshi(INVENTORY_IDX item)
520 object_type *o_ptr, *new_o_ptr;
521 char o_name[MAX_NLEN];
523 if (item == INVEN_RARM)
525 if (buki_motteruka(INVEN_LARM))
527 o_ptr = &inventory[INVEN_LARM];
528 object_desc(o_name, o_ptr, 0);
530 if (!object_is_cursed(o_ptr))
532 new_o_ptr = &inventory[INVEN_RARM];
533 object_copy(new_o_ptr, o_ptr);
534 p_ptr->total_weight += o_ptr->weight;
535 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
536 inven_item_optimize(INVEN_LARM);
537 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
538 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
540 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
541 (left_hander ? _("左手", "left") : _("右手", "right")));
545 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
546 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
550 else if (item == INVEN_LARM)
552 o_ptr = &inventory[INVEN_RARM];
553 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
555 if (buki_motteruka(INVEN_RARM))
557 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
558 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
560 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
562 new_o_ptr = &inventory[INVEN_LARM];
563 object_copy(new_o_ptr, o_ptr);
564 p_ptr->total_weight += o_ptr->weight;
565 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
566 inven_item_optimize(INVEN_RARM);
567 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
574 * @brief 装備を外すコマンドのメインルーチン / Take off an item
577 void do_cmd_takeoff(void)
583 if (p_ptr->special_defense & KATA_MUSOU)
585 set_action(ACTION_NONE);
588 item_tester_no_ryoute = TRUE;
590 q = _("どれを装備からはずしますか? ", "Take off which item? ");
591 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
593 if (!get_item(&item, q, s, (USE_EQUIP))) return;
595 /* Get the item (in the pack) */
598 o_ptr = &inventory[item];
601 /* Get the item (on the floor) */
604 o_ptr = &o_list[0 - item];
609 if (object_is_cursed(o_ptr))
611 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
613 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
618 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
620 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
622 /* Hack -- Assume felt */
623 o_ptr->ident |= (IDENT_SENSE);
625 o_ptr->curse_flags = 0L;
628 o_ptr->feeling = FEEL_NONE;
630 /* Recalculate the bonuses */
631 p_ptr->update |= (PU_BONUS);
633 p_ptr->window |= (PW_EQUIP);
635 msg_print(_("呪いを打ち破った。", "You break the curse."));
639 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
640 p_ptr->energy_use = 50;
645 /* Take a partial turn */
646 p_ptr->energy_use = 50;
648 /* Take off the item */
649 (void)inven_takeoff(item, 255);
652 p_ptr->redraw |= (PR_EQUIPPY);
657 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
660 void do_cmd_drop(void)
669 if (p_ptr->special_defense & KATA_MUSOU)
671 set_action(ACTION_NONE);
674 item_tester_no_ryoute = TRUE;
675 q = _("どのアイテムを落としますか? ", "Drop which item? ");
676 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
678 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
680 /* Get the item (in the pack) */
683 o_ptr = &inventory[item];
686 /* Get the item (on the floor) */
689 o_ptr = &o_list[0 - item];
693 /* Hack -- Cannot remove cursed items */
694 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
696 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
701 /* See how many items */
702 if (o_ptr->number > 1)
705 amt = get_quantity(NULL, o_ptr->number);
707 /* Allow user abort */
708 if (amt <= 0) return;
712 /* Take a partial turn */
713 p_ptr->energy_use = 50;
715 /* Drop (some of) the item */
716 inven_drop(item, amt);
718 if (item >= INVEN_RARM)
724 p_ptr->redraw |= (PR_EQUIPPY);
728 * @brief オブジェクトが高位の魔法書かどうかを判定する
729 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
730 * @return オブジェクトが高位の魔法書ならばTRUEを返す
732 static bool high_level_book(object_type *o_ptr)
734 if ((o_ptr->tval == TV_LIFE_BOOK) ||
735 (o_ptr->tval == TV_SORCERY_BOOK) ||
736 (o_ptr->tval == TV_NATURE_BOOK) ||
737 (o_ptr->tval == TV_CHAOS_BOOK) ||
738 (o_ptr->tval == TV_DEATH_BOOK) ||
739 (o_ptr->tval == TV_TRUMP_BOOK) ||
740 (o_ptr->tval == TV_CRAFT_BOOK) ||
741 (o_ptr->tval == TV_DAEMON_BOOK) ||
742 (o_ptr->tval == TV_CRUSADE_BOOK) ||
743 (o_ptr->tval == TV_MUSIC_BOOK) ||
744 (o_ptr->tval == TV_HEX_BOOK))
757 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
760 void do_cmd_destroy(void)
770 object_type *q_ptr = &forge;
772 char o_name[MAX_NLEN];
773 char out_val[MAX_NLEN+40];
777 if (p_ptr->special_defense & KATA_MUSOU)
779 set_action(ACTION_NONE);
782 /* Hack -- force destruction */
783 if (command_arg > 0) force = TRUE;
785 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
786 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
788 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
790 /* Get the item (in the pack) */
793 o_ptr = &inventory[item];
796 /* Get the item (on the floor) */
799 o_ptr = &o_list[0 - item];
802 /* Verify unless quantity given beforehand */
803 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
805 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
807 /* Make a verification */
808 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
811 /* HACK : Add the line to message buffer */
812 message_add(out_val);
813 p_ptr->window |= (PW_MESSAGE);
816 /* Get an acceptable answer */
826 /* Erase the prompt */
830 if (i == 'y' || i == 'Y')
834 if (i == ESCAPE || i == 'n' || i == 'N')
841 /* Add an auto-destroy preference line */
842 if (autopick_autoregister(o_ptr))
844 /* Auto-destroy it */
845 autopick_alter_item(item, TRUE);
848 /* The object is already destroyed. */
854 /* See how many items */
855 if (o_ptr->number > 1)
858 amt = get_quantity(NULL, o_ptr->number);
860 /* Allow user abort */
861 if (amt <= 0) return;
865 old_number = o_ptr->number;
867 object_desc(o_name, o_ptr, 0);
868 o_ptr->number = old_number;
870 p_ptr->energy_use = 100;
872 /* Artifacts cannot be destroyed */
873 if (!can_player_destroy_object(o_ptr))
875 p_ptr->energy_use = 0;
877 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
881 object_copy(q_ptr, o_ptr);
883 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
884 sound(SOUND_DESTITEM);
886 /* Reduce the charges of rods/wands */
887 reduce_charges(o_ptr, amt);
889 /* Eliminate the item (from the pack) */
892 inven_item_increase(item, -amt);
893 inven_item_describe(item);
894 inven_item_optimize(item);
897 /* Eliminate the item (from the floor) */
900 floor_item_increase(0 - item, -amt);
901 floor_item_describe(0 - item);
902 floor_item_optimize(0 - item);
905 if (high_level_book(q_ptr))
907 bool gain_expr = FALSE;
909 if (p_ptr->prace == RACE_ANDROID)
912 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
916 else if (p_ptr->pclass == CLASS_PALADIN)
918 if (is_good_realm(p_ptr->realm1))
920 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
924 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
928 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
930 s32b tester_exp = p_ptr->max_exp / 20;
931 if (tester_exp > 10000) tester_exp = 10000;
932 if (q_ptr->sval < 3) tester_exp /= 4;
933 if (tester_exp<1) tester_exp = 1;
935 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
936 gain_exp(tester_exp * amt);
938 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
940 chg_virtue(V_UNLIFE, 1);
941 chg_virtue(V_VITALITY, -1);
943 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
945 chg_virtue(V_UNLIFE, -1);
946 chg_virtue(V_VITALITY, 1);
949 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
950 chg_virtue(V_ENCHANT, -1);
952 if (object_value_real(q_ptr) > 30000)
953 chg_virtue(V_SACRIFICE, 2);
955 else if (object_value_real(q_ptr) > 10000)
956 chg_virtue(V_SACRIFICE, 1);
959 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
960 chg_virtue(V_HARMONY, 1);
962 if (item >= INVEN_RARM) calc_android_exp();
967 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
970 void do_cmd_observe(void)
974 char o_name[MAX_NLEN];
978 item_tester_no_ryoute = TRUE;
980 q = _("どのアイテムを調べますか? ", "Examine which item? ");
981 s = _("調べられるアイテムがない。", "You have nothing to examine.");
983 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
985 /* Get the item (in the pack) */
988 o_ptr = &inventory[item];
991 /* Get the item (on the floor) */
994 o_ptr = &o_list[0 - item];
998 /* Require full knowledge */
999 if (!(o_ptr->ident & IDENT_MENTAL))
1001 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1007 object_desc(o_name, o_ptr, 0);
1008 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1009 /* Describe it fully */
1010 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1016 * @brief アイテムの銘を消すコマンドのメインルーチン
1017 * Remove the inscription from an object XXX Mention item (when done)?
1020 void do_cmd_uninscribe(void)
1026 item_tester_no_ryoute = TRUE;
1027 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1028 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1030 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1032 /* Get the item (in the pack) */
1035 o_ptr = &inventory[item];
1038 /* Get the item (on the floor) */
1041 o_ptr = &o_list[0 - item];
1044 /* Nothing to remove */
1045 if (!o_ptr->inscription)
1047 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1051 msg_print(_("銘を消した。", "Inscription removed."));
1053 /* Remove the incription */
1054 o_ptr->inscription = 0;
1056 /* Combine the pack */
1057 p_ptr->notice |= (PN_COMBINE);
1059 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1061 /* .や$の関係で, 再計算が必要なはず -- henkma */
1062 p_ptr->update |= (PU_BONUS);
1068 * @brief アイテムの銘を刻むコマンドのメインルーチン
1069 * Inscribe an object with a comment
1072 void do_cmd_inscribe(void)
1076 char o_name[MAX_NLEN];
1080 item_tester_no_ryoute = TRUE;
1081 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1082 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1084 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1086 /* Get the item (in the pack) */
1089 o_ptr = &inventory[item];
1092 /* Get the item (on the floor) */
1095 o_ptr = &o_list[0 - item];
1098 /* Describe the activity */
1099 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1101 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1104 /* Start with nothing */
1105 strcpy(out_val, "");
1107 /* Use old inscription */
1108 if (o_ptr->inscription)
1110 /* Start with the old inscription */
1111 strcpy(out_val, quark_str(o_ptr->inscription));
1114 /* Get a new inscription (possibly empty) */
1115 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1117 /* Save the inscription */
1118 o_ptr->inscription = quark_add(out_val);
1120 /* Combine the pack */
1121 p_ptr->notice |= (PN_COMBINE);
1123 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1125 /* .や$の関係で, 再計算が必要なはず -- henkma */
1126 p_ptr->update |= (PU_BONUS);
1133 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1134 * An "item_tester_hook" for refilling lanterns
1135 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1136 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1138 static bool item_tester_refill_lantern(object_type *o_ptr)
1140 /* Flasks of oil are okay */
1141 if (o_ptr->tval == TV_FLASK) return (TRUE);
1143 /* Laterns are okay */
1144 if ((o_ptr->tval == TV_LITE) &&
1145 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1147 /* Assume not okay */
1153 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1154 * Refill the players lamp (from the pack or floor)
1157 static void do_cmd_refill_lamp(void)
1167 /* Restrict the choices */
1168 item_tester_hook = item_tester_refill_lantern;
1171 q = "どの油つぼから注ぎますか? ";
1174 q = "Refill with which flask? ";
1175 s = "You have no flasks of oil.";
1178 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1180 /* Get the item (in the pack) */
1183 o_ptr = &inventory[item];
1186 /* Get the item (on the floor) */
1189 o_ptr = &o_list[0 - item];
1192 /* Take a partial turn */
1193 p_ptr->energy_use = 50;
1195 /* Access the lantern */
1196 j_ptr = &inventory[INVEN_LITE];
1199 j_ptr->xtra4 += o_ptr->xtra4;
1200 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1202 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1205 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1207 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1210 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1212 else if (j_ptr->xtra4 >= FUEL_LAMP)
1214 j_ptr->xtra4 = FUEL_LAMP;
1215 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1218 /* Decrease the item (from the pack) */
1221 inven_item_increase(item, -1);
1222 inven_item_describe(item);
1223 inven_item_optimize(item);
1226 /* Decrease the item (from the floor) */
1229 floor_item_increase(0 - item, -1);
1230 floor_item_describe(0 - item);
1231 floor_item_optimize(0 - item);
1234 /* Recalculate torch */
1235 p_ptr->update |= (PU_TORCH);
1240 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1241 * An "item_tester_hook" for refilling torches
1242 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1243 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1245 static bool item_tester_refill_torch(object_type *o_ptr)
1247 /* Torches are okay */
1248 if ((o_ptr->tval == TV_LITE) &&
1249 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1251 /* Assume not okay */
1257 * @brief 松明を束ねるコマンドのメインルーチン
1258 * Refuel the players torch (from the pack or floor)
1261 static void do_cmd_refill_torch(void)
1270 /* Restrict the choices */
1271 item_tester_hook = item_tester_refill_torch;
1273 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1274 s = _("他に松明がない。", "You have no extra torches.");
1276 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1278 /* Get the item (in the pack) */
1281 o_ptr = &inventory[item];
1284 /* Get the item (on the floor) */
1287 o_ptr = &o_list[0 - item];
1291 /* Take a partial turn */
1292 p_ptr->energy_use = 50;
1294 /* Access the primary torch */
1295 j_ptr = &inventory[INVEN_LITE];
1298 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1300 msg_print(_("松明を結合した。", "You combine the torches."));
1302 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1305 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1307 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1310 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1312 /* Over-fuel message */
1313 else if (j_ptr->xtra4 >= FUEL_TORCH)
1315 j_ptr->xtra4 = FUEL_TORCH;
1316 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1319 /* Refuel message */
1322 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1325 /* Decrease the item (from the pack) */
1328 inven_item_increase(item, -1);
1329 inven_item_describe(item);
1330 inven_item_optimize(item);
1333 /* Decrease the item (from the floor) */
1336 floor_item_increase(0 - item, -1);
1337 floor_item_describe(0 - item);
1338 floor_item_optimize(0 - item);
1341 /* Recalculate torch */
1342 p_ptr->update |= (PU_TORCH);
1347 * @brief 燃料を補充するコマンドのメインルーチン
1348 * Refill the players lamp, or restock his torches
1351 void do_cmd_refill(void)
1356 o_ptr = &inventory[INVEN_LITE];
1358 if (p_ptr->special_defense & KATA_MUSOU)
1360 set_action(ACTION_NONE);
1364 if (o_ptr->tval != TV_LITE)
1366 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1370 else if (o_ptr->sval == SV_LITE_LANTERN)
1372 do_cmd_refill_lamp();
1376 else if (o_ptr->sval == SV_LITE_TORCH)
1378 do_cmd_refill_torch();
1381 /* No torch to refill */
1384 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1390 * @brief ターゲットを設定するコマンドのメインルーチン
1394 void do_cmd_target(void)
1397 if (target_set(TARGET_KILL))
1399 msg_print(_("ターゲット決定。", "Target Selected."));
1402 /* Target aborted */
1405 msg_print(_("ターゲット解除。", "Target Aborted."));
1412 * @brief 周囲を見渡すコマンドのメインルーチン
1416 void do_cmd_look(void)
1419 p_ptr->window |= PW_MONSTER_LIST;
1424 if (target_set(TARGET_LOOK))
1426 msg_print(_("ターゲット決定。", "Target Selected."));
1432 * @brief 位置を確認するコマンドのメインルーチン
1433 * Allow the player to examine other sectors on the map
1436 void do_cmd_locate(void)
1438 int dir, y1, x1, y2, x2;
1446 get_screen_size(&wid, &hgt);
1449 /* Start at current panel */
1450 y2 = y1 = panel_row_min;
1451 x2 = x1 = panel_col_min;
1453 /* Show panels until done */
1456 /* Describe the location */
1457 if ((y2 == y1) && (x2 == x1))
1460 strcpy(tmp_val, "真上");
1469 sprintf(tmp_val, "%s%s",
1470 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1471 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1473 sprintf(tmp_val, "%s%s of",
1474 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1475 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1480 /* Prepare to ask which way to look */
1481 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1482 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1483 y2 / (hgt / 2), y2 % (hgt / 2),
1484 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1486 /* Assume no direction */
1489 /* Get a direction */
1494 /* Get a command (or Cancel) */
1495 if (!get_com(out_val, &command, TRUE)) break;
1497 /* Extract the action (if any) */
1498 dir = get_keymap_dir(command);
1507 /* Apply the motion */
1508 if (change_panel(ddy[dir], ddx[dir]))
1516 /* Recenter the map around the player */
1519 p_ptr->update |= (PU_MONSTERS);
1521 p_ptr->redraw |= (PR_MAP);
1523 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1530 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1531 * Sorting hook -- Comp function -- see below
1532 * @param u モンスター種族情報の入れるポインタ
1534 * @param a 比較するモンスター種族のID1
1535 * @param b 比較するモンスター種族のID2
1536 * @return 2の方が大きければTRUEを返す
1537 * We use "u" to point to array of monster indexes,
1538 * and "v" to select the type of sorting to perform on "u".
1540 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1542 u16b *who = (u16b*)(u);
1544 u16b *why = (u16b*)(v);
1551 /* Sort by player kills */
1554 /* Extract player kills */
1555 z1 = r_info[w1].r_pkills;
1556 z2 = r_info[w2].r_pkills;
1558 /* Compare player kills */
1559 if (z1 < z2) return (TRUE);
1560 if (z1 > z2) return (FALSE);
1564 /* Sort by total kills */
1567 /* Extract total kills */
1568 z1 = r_info[w1].r_tkills;
1569 z2 = r_info[w2].r_tkills;
1571 /* Compare total kills */
1572 if (z1 < z2) return (TRUE);
1573 if (z1 > z2) return (FALSE);
1577 /* Sort by monster level */
1580 /* Extract levels */
1581 z1 = r_info[w1].level;
1582 z2 = r_info[w2].level;
1584 /* Compare levels */
1585 if (z1 < z2) return (TRUE);
1586 if (z1 > z2) return (FALSE);
1590 /* Sort by monster experience */
1593 /* Extract experience */
1594 z1 = r_info[w1].mexp;
1595 z2 = r_info[w2].mexp;
1597 /* Compare experience */
1598 if (z1 < z2) return (TRUE);
1599 if (z1 > z2) return (FALSE);
1603 /* Compare indexes */
1609 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1610 * Sorting hook -- Swap function -- see below
1611 * @param u モンスター種族情報の入れるポインタ
1613 * @param a スワップするモンスター種族のID1
1614 * @param b スワップするモンスター種族のID2
1617 * We use "u" to point to array of monster indexes,
1618 * and "v" to select the type of sorting to perform.
1620 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1622 u16b *who = (u16b*)(u);
1638 * @brief モンスターの思い出を見るコマンドのメインルーチン
1639 * Identify a character, allow recall of monsters
1643 * Several "special" responses recall "multiple" monsters:
1645 * ^U (all unique monsters)
1646 * ^N (all non-unique monsters)
1648 * The responses may be sorted in several ways, see below.
1650 * Note that the player ghosts are ignored.
1653 void do_cmd_query_symbol(void)
1667 bool recall = FALSE;
1672 /* Get a character, or abort */
1673 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1674 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1676 /* Find that character info, and describe it */
1677 for (i = 0; ident_info[i]; ++i)
1679 if (sym == ident_info[i][0]) break;
1681 if (sym == KTRL('A'))
1684 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1686 else if (sym == KTRL('U'))
1689 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1691 else if (sym == KTRL('N'))
1694 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1696 else if (sym == KTRL('R'))
1699 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1701 /* XTRA HACK WHATSEARCH */
1702 else if (sym == KTRL('M'))
1705 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1710 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1712 else if (ident_info[i])
1714 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1718 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1721 /* Display the result */
1724 /* Allocate the "who" array */
1725 C_MAKE(who, max_r_idx, IDX);
1727 /* Collect matching monsters */
1728 for (n = 0, i = 1; i < max_r_idx; i++)
1730 monster_race *r_ptr = &r_info[i];
1732 /* Nothing to recall */
1733 if (!cheat_know && !r_ptr->r_sights) continue;
1735 /* Require non-unique monsters if needed */
1736 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1738 /* Require unique monsters if needed */
1739 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1741 /* Require ridable monsters if needed */
1742 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1744 /* XTRA HACK WHATSEARCH */
1750 for (xx = 0; temp[xx] && xx < 80; xx++)
1753 if (iskanji(temp[xx])) { xx++; continue; }
1755 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1759 strcpy(temp2, r_name + r_ptr->E_name);
1761 strcpy(temp2, r_name + r_ptr->name);
1763 for (xx = 0; temp2[xx] && xx < 80; xx++)
1764 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1767 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1769 if (my_strstr(temp2, temp))
1774 /* Collect "appropriate" monsters */
1775 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1778 /* Nothing to recall */
1781 /* Free the "who" array */
1782 C_KILL(who, max_r_idx, IDX);
1788 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1798 /* Select the sort method */
1799 ang_sort_comp = ang_sort_comp_hook;
1800 ang_sort_swap = ang_sort_swap_hook;
1802 /* Sort the array */
1803 ang_sort(who, &why, n);
1805 /* Sort by kills (and level) */
1812 /* Catch "escape" */
1815 /* Free the "who" array */
1816 C_KILL(who, max_r_idx, IDX);
1821 /* Sort if needed */
1824 /* Select the sort method */
1825 ang_sort_comp = ang_sort_comp_hook;
1826 ang_sort_swap = ang_sort_swap_hook;
1828 /* Sort the array */
1829 ang_sort(who, &why, n);
1833 /* Start at the end */
1836 /* Scan the monster memory */
1839 /* Extract a race */
1842 /* Hack -- Auto-recall */
1843 monster_race_track(r_idx);
1845 /* Hack -- Handle stuff */
1854 /* Save the screen */
1857 /* Recall on screen */
1858 screen_roff(who[i], 0);
1861 /* Hack -- Begin the prompt */
1864 /* Hack -- Complete the prompt */
1865 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1877 /* Normal commands */
1878 if (query != 'r') break;
1885 if (query == ESCAPE) break;
1887 /* Move to "prev" monster */
1893 if (!expand_list) break;
1897 /* Move to "next" monster */
1903 if (!expand_list) break;
1908 /* Free the "who" array */
1909 C_KILL(who, max_r_idx, IDX);
1911 /* Re-display the identity */
1916 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1920 * XXX - Add actions for other item types
1922 void do_cmd_use(void)
1928 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1930 set_action(ACTION_NONE);
1933 item_tester_no_ryoute = TRUE;
1934 item_tester_hook = item_tester_hook_use;
1936 q = _("どれを使いますか?", "Use which item? ");
1937 s = _("使えるものがありません。", "You have nothing to use.");
1939 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1941 /* Get the item (in the pack) */
1944 o_ptr = &inventory[item];
1946 /* Get the item (on the floor) */
1949 o_ptr = &o_list[0 - item];
1952 switch (o_ptr->tval)
1964 do_cmd_eat_food_aux(item);
1971 do_cmd_aim_wand_aux(item);
1978 do_cmd_use_staff_aux(item);
1985 do_cmd_zap_rod_aux(item);
1989 /* Quaff a potion */
1992 do_cmd_quaff_potion_aux(item);
1999 /* Check some conditions */
2002 msg_print(_("目が見えない。", "You can't see anything."));
2007 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2010 if (p_ptr->confused)
2012 msg_print(_("混乱していて読めない!", "You are too confused!"));
2016 do_cmd_read_scroll_aux(item, TRUE);
2025 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2029 /* Activate an artifact */
2032 do_cmd_activate_aux(item);