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);
46 /* Hack -- show empty slots */
47 item_tester_full = TRUE;
49 /* Display the inventory */
52 /* Hack -- hide empty slots */
53 item_tester_full = FALSE;
56 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
57 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
58 (long int)((p_ptr->total_weight * 100) / weight_limit()));
60 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
61 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
62 (p_ptr->total_weight * 100) / weight_limit());
69 /* Get a new command */
70 command_new = inkey();
76 /* Process "Escape" */
77 if (command_new == ESCAPE)
81 Term_get_size(&wid, &hgt);
85 command_gap = wid - 30;
88 /* Process normal keys */
91 /* Hack -- Use "display" mode */
98 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
101 void do_cmd_equip(void)
106 /* Note that we are in "equipment" mode */
109 /* Note that we are in "equipment" mode */
110 if (easy_floor) command_wrk = (USE_EQUIP);
112 /* Save the screen */
115 /* Hack -- show empty slots */
116 item_tester_full = TRUE;
118 /* Display the equipment */
121 /* Hack -- undo the hack above */
122 item_tester_full = FALSE;
126 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
127 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
128 (long int)((p_ptr->total_weight * 100) / weight_limit()));
130 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
131 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
132 (long int)((p_ptr->total_weight * 100) / weight_limit()));
139 /* Get a new command */
140 command_new = inkey();
142 /* Restore the screen */
146 /* Process "Escape" */
147 if (command_new == ESCAPE)
151 Term_get_size(&wid, &hgt);
155 command_gap = wid - 30;
158 /* Process normal keys */
161 /* Enter "display" mode */
169 bool select_ring_slot = FALSE;
172 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
175 void do_cmd_wield(void)
177 OBJECT_IDX item, slot;
186 char o_name[MAX_NLEN];
190 OBJECT_IDX need_switch_wielding = 0;
192 if (p_ptr->special_defense & KATA_MUSOU)
194 set_action(ACTION_NONE);
197 /* Restrict the choices */
198 item_tester_hook = item_tester_hook_wear;
200 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
201 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
203 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
205 /* Get the item (in the pack) */
208 o_ptr = &inventory[item];
211 /* Get the item (on the floor) */
214 o_ptr = &o_list[0 - item];
219 slot = wield_slot(o_ptr);
223 /* Shields and some misc. items */
228 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
230 /* Restrict the choices */
231 item_tester_hook = item_tester_hook_melee_weapon;
232 item_tester_no_ryoute = TRUE;
234 /* Choose a weapon from the equipment only */
235 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
236 s = _("おっと。", "Oops.");
237 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
238 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
241 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
243 /* Both arms are already used by non-weapon */
244 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
245 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
247 /* Restrict the choices */
248 item_tester_hook = item_tester_hook_mochikae;
251 q = _("どちらの手に装備しますか?", "Equip which hand? ");
252 s = _("おっと。", "Oops.");
253 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
262 /* Asking for dual wielding */
263 if (slot == INVEN_LARM)
265 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
268 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
270 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
273 /* Both arms are already used */
274 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
276 /* Restrict the choices */
277 item_tester_hook = item_tester_hook_mochikae;
280 q = _("どちらの手に装備しますか?", "Equip which hand? ");
281 s = _("おっと。", "Oops.");
283 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
284 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
285 need_switch_wielding = INVEN_RARM;
291 /* Choose a ring slot */
292 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
294 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
298 q = _("どちらの手に装備しますか?", "Equip which hand? ");
300 s = _("おっと。", "Oops.");
302 /* Restrict the choices */
303 select_ring_slot = TRUE;
304 item_tester_no_ryoute = TRUE;
306 if (!get_item(&slot, q, s, (USE_EQUIP)))
308 select_ring_slot = FALSE;
311 select_ring_slot = FALSE;
315 /* Prevent wielding into a cursed slot */
316 if (object_is_cursed(&inventory[slot]))
319 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
322 msg_format("%s%sは呪われているようだ。",
323 describe_use(slot) , o_name );
325 msg_format("The %s you are %s appears to be cursed.",
326 o_name, describe_use(slot));
329 /* Cancel the command */
334 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
335 ((o_ptr->ident & IDENT_SENSE) &&
336 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
338 char dummy[MAX_NLEN+80];
341 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
342 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
344 if (!get_check(dummy)) return;
347 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
349 char dummy[MAX_NLEN+80];
352 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
355 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
357 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
358 sprintf(dummy, "Do you become a vampire?");
361 if (!get_check(dummy)) return;
364 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
366 object_type *slot_o_ptr = &inventory[slot];
367 object_type *switch_o_ptr = &inventory[need_switch_wielding];
368 object_type object_tmp;
369 object_type *otmp_ptr = &object_tmp;
370 char switch_name[MAX_NLEN];
372 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
374 object_copy(otmp_ptr, switch_o_ptr);
375 object_copy(switch_o_ptr, slot_o_ptr);
376 object_copy(slot_o_ptr, otmp_ptr);
378 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
379 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
380 (left_hander ? _("右手", "right") : _("左手", "left")));
381 slot = need_switch_wielding;
384 check_find_art_quest_completion(o_ptr);
386 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
388 identify_item(o_ptr);
390 /* Auto-inscription */
391 autopick_alter_item(item, FALSE);
394 p_ptr->energy_use = 100;
396 /* Get local object */
399 /* Obtain local object */
400 object_copy(q_ptr, o_ptr);
402 /* Modify quantity */
405 /* Decrease the item (from the pack) */
408 inven_item_increase(item, -1);
409 inven_item_optimize(item);
412 /* Decrease the item (from the floor) */
415 floor_item_increase(0 - item, -1);
416 floor_item_optimize(0 - item);
419 /* Access the wield slot */
420 o_ptr = &inventory[slot];
422 /* Take off existing item */
425 /* Take off existing item */
426 (void)inven_takeoff(slot, 255);
429 /* Wear the new stuff */
430 object_copy(o_ptr, q_ptr);
432 /* Player touches it */
433 o_ptr->marked |= OM_TOUCHED;
435 /* Increase the weight */
436 p_ptr->total_weight += q_ptr->weight;
438 /* Increment the equip counter by hand */
442 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
443 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
444 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
446 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
447 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
448 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
451 /* Where is the item now */
455 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
456 act = STR_WIELD_ARMS;
458 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
462 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
463 act = STR_WIELD_ARMS;
465 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
469 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
473 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
477 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
481 /* Describe the result */
482 object_desc(o_name, o_ptr, 0);
483 msg_format(act, o_name, index_to_label(slot));
486 if (object_is_cursed(o_ptr))
488 /* Warn the player */
489 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
490 chg_virtue(V_HARMONY, -1);
493 o_ptr->ident |= (IDENT_SENSE);
496 /* The Stone Mask make the player turn into a vampire! */
497 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
499 /* Turn into a vampire */
500 change_race(RACE_VAMPIRE, "");
503 /* Recalculate bonuses */
504 p_ptr->update |= (PU_BONUS);
506 /* Recalculate torch */
507 p_ptr->update |= (PU_TORCH);
509 /* Recalculate mana */
510 p_ptr->update |= (PU_MANA);
512 p_ptr->redraw |= (PR_EQUIPPY);
514 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
521 * @param item 持ち替えを行いたい装備部位ID
524 void kamaenaoshi(INVENTORY_IDX item)
526 object_type *o_ptr, *new_o_ptr;
527 char o_name[MAX_NLEN];
529 if (item == INVEN_RARM)
531 if (buki_motteruka(INVEN_LARM))
533 o_ptr = &inventory[INVEN_LARM];
534 object_desc(o_name, o_ptr, 0);
536 if (!object_is_cursed(o_ptr))
538 new_o_ptr = &inventory[INVEN_RARM];
539 object_copy(new_o_ptr, o_ptr);
540 p_ptr->total_weight += o_ptr->weight;
541 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
542 inven_item_optimize(INVEN_LARM);
543 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
544 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
546 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
547 (left_hander ? _("左手", "left") : _("右手", "right")));
551 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
552 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
556 else if (item == INVEN_LARM)
558 o_ptr = &inventory[INVEN_RARM];
559 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
561 if (buki_motteruka(INVEN_RARM))
563 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
564 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
566 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
568 new_o_ptr = &inventory[INVEN_LARM];
569 object_copy(new_o_ptr, o_ptr);
570 p_ptr->total_weight += o_ptr->weight;
571 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
572 inven_item_optimize(INVEN_RARM);
573 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
580 * @brief 装備を外すコマンドのメインルーチン / Take off an item
583 void do_cmd_takeoff(void)
589 if (p_ptr->special_defense & KATA_MUSOU)
591 set_action(ACTION_NONE);
594 item_tester_no_ryoute = TRUE;
596 q = _("どれを装備からはずしますか? ", "Take off which item? ");
597 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
599 if (!get_item(&item, q, s, (USE_EQUIP))) return;
601 /* Get the item (in the pack) */
604 o_ptr = &inventory[item];
607 /* Get the item (on the floor) */
610 o_ptr = &o_list[0 - item];
615 if (object_is_cursed(o_ptr))
617 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
619 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
624 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
626 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
628 /* Hack -- Assume felt */
629 o_ptr->ident |= (IDENT_SENSE);
631 o_ptr->curse_flags = 0L;
634 o_ptr->feeling = FEEL_NONE;
636 /* Recalculate the bonuses */
637 p_ptr->update |= (PU_BONUS);
639 p_ptr->window |= (PW_EQUIP);
641 msg_print(_("呪いを打ち破った。", "You break the curse."));
645 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
646 p_ptr->energy_use = 50;
651 /* Take a partial turn */
652 p_ptr->energy_use = 50;
654 /* Take off the item */
655 (void)inven_takeoff(item, 255);
658 p_ptr->redraw |= (PR_EQUIPPY);
663 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
666 void do_cmd_drop(void)
675 if (p_ptr->special_defense & KATA_MUSOU)
677 set_action(ACTION_NONE);
680 item_tester_no_ryoute = TRUE;
681 q = _("どのアイテムを落としますか? ", "Drop which item? ");
682 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
684 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
686 /* Get the item (in the pack) */
689 o_ptr = &inventory[item];
692 /* Get the item (on the floor) */
695 o_ptr = &o_list[0 - item];
699 /* Hack -- Cannot remove cursed items */
700 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
702 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
707 /* See how many items */
708 if (o_ptr->number > 1)
711 amt = get_quantity(NULL, o_ptr->number);
713 /* Allow user abort */
714 if (amt <= 0) return;
718 /* Take a partial turn */
719 p_ptr->energy_use = 50;
721 /* Drop (some of) the item */
722 inven_drop(item, amt);
724 if (item >= INVEN_RARM)
730 p_ptr->redraw |= (PR_EQUIPPY);
734 * @brief オブジェクトが高位の魔法書かどうかを判定する
735 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
736 * @return オブジェクトが高位の魔法書ならばTRUEを返す
738 static bool high_level_book(object_type *o_ptr)
740 if ((o_ptr->tval == TV_LIFE_BOOK) ||
741 (o_ptr->tval == TV_SORCERY_BOOK) ||
742 (o_ptr->tval == TV_NATURE_BOOK) ||
743 (o_ptr->tval == TV_CHAOS_BOOK) ||
744 (o_ptr->tval == TV_DEATH_BOOK) ||
745 (o_ptr->tval == TV_TRUMP_BOOK) ||
746 (o_ptr->tval == TV_CRAFT_BOOK) ||
747 (o_ptr->tval == TV_DAEMON_BOOK) ||
748 (o_ptr->tval == TV_CRUSADE_BOOK) ||
749 (o_ptr->tval == TV_MUSIC_BOOK) ||
750 (o_ptr->tval == TV_HEX_BOOK))
763 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
766 void do_cmd_destroy(void)
776 object_type *q_ptr = &forge;
778 char o_name[MAX_NLEN];
779 char out_val[MAX_NLEN+40];
783 if (p_ptr->special_defense & KATA_MUSOU)
785 set_action(ACTION_NONE);
788 /* Hack -- force destruction */
789 if (command_arg > 0) force = TRUE;
791 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
792 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
794 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
796 /* Get the item (in the pack) */
799 o_ptr = &inventory[item];
802 /* Get the item (on the floor) */
805 o_ptr = &o_list[0 - item];
808 /* Verify unless quantity given beforehand */
809 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
811 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
813 /* Make a verification */
814 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
817 /* HACK : Add the line to message buffer */
818 message_add(out_val);
819 p_ptr->window |= (PW_MESSAGE);
822 /* Get an acceptable answer */
832 /* Erase the prompt */
836 if (i == 'y' || i == 'Y')
840 if (i == ESCAPE || i == 'n' || i == 'N')
847 /* Add an auto-destroy preference line */
848 if (autopick_autoregister(o_ptr))
850 /* Auto-destroy it */
851 autopick_alter_item(item, TRUE);
854 /* The object is already destroyed. */
860 /* See how many items */
861 if (o_ptr->number > 1)
864 amt = get_quantity(NULL, o_ptr->number);
866 /* Allow user abort */
867 if (amt <= 0) return;
871 old_number = o_ptr->number;
873 object_desc(o_name, o_ptr, 0);
874 o_ptr->number = old_number;
876 p_ptr->energy_use = 100;
878 /* Artifacts cannot be destroyed */
879 if (!can_player_destroy_object(o_ptr))
881 p_ptr->energy_use = 0;
883 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
887 object_copy(q_ptr, o_ptr);
889 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
890 sound(SOUND_DESTITEM);
892 /* Reduce the charges of rods/wands */
893 reduce_charges(o_ptr, amt);
895 /* Eliminate the item (from the pack) */
898 inven_item_increase(item, -amt);
899 inven_item_describe(item);
900 inven_item_optimize(item);
903 /* Eliminate the item (from the floor) */
906 floor_item_increase(0 - item, -amt);
907 floor_item_describe(0 - item);
908 floor_item_optimize(0 - item);
911 if (high_level_book(q_ptr))
913 bool gain_expr = FALSE;
915 if (p_ptr->prace == RACE_ANDROID)
918 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
922 else if (p_ptr->pclass == CLASS_PALADIN)
924 if (is_good_realm(p_ptr->realm1))
926 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
930 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
934 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
936 s32b tester_exp = p_ptr->max_exp / 20;
937 if (tester_exp > 10000) tester_exp = 10000;
938 if (q_ptr->sval < 3) tester_exp /= 4;
939 if (tester_exp<1) tester_exp = 1;
941 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
942 gain_exp(tester_exp * amt);
944 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
946 chg_virtue(V_UNLIFE, 1);
947 chg_virtue(V_VITALITY, -1);
949 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
951 chg_virtue(V_UNLIFE, -1);
952 chg_virtue(V_VITALITY, 1);
955 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
956 chg_virtue(V_ENCHANT, -1);
958 if (object_value_real(q_ptr) > 30000)
959 chg_virtue(V_SACRIFICE, 2);
961 else if (object_value_real(q_ptr) > 10000)
962 chg_virtue(V_SACRIFICE, 1);
965 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
966 chg_virtue(V_HARMONY, 1);
968 if (item >= INVEN_RARM) calc_android_exp();
973 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
976 void do_cmd_observe(void)
980 char o_name[MAX_NLEN];
984 item_tester_no_ryoute = TRUE;
986 q = _("どのアイテムを調べますか? ", "Examine which item? ");
987 s = _("調べられるアイテムがない。", "You have nothing to examine.");
989 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
991 /* Get the item (in the pack) */
994 o_ptr = &inventory[item];
997 /* Get the item (on the floor) */
1000 o_ptr = &o_list[0 - item];
1004 /* Require full knowledge */
1005 if (!(o_ptr->ident & IDENT_MENTAL))
1007 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1013 object_desc(o_name, o_ptr, 0);
1014 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1015 /* Describe it fully */
1016 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1022 * @brief アイテムの銘を消すコマンドのメインルーチン
1023 * Remove the inscription from an object XXX Mention item (when done)?
1026 void do_cmd_uninscribe(void)
1032 item_tester_no_ryoute = TRUE;
1033 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1034 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1036 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1038 /* Get the item (in the pack) */
1041 o_ptr = &inventory[item];
1044 /* Get the item (on the floor) */
1047 o_ptr = &o_list[0 - item];
1050 /* Nothing to remove */
1051 if (!o_ptr->inscription)
1053 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1057 msg_print(_("銘を消した。", "Inscription removed."));
1059 /* Remove the incription */
1060 o_ptr->inscription = 0;
1062 /* Combine the pack */
1063 p_ptr->notice |= (PN_COMBINE);
1065 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1067 /* .や$の関係で, 再計算が必要なはず -- henkma */
1068 p_ptr->update |= (PU_BONUS);
1074 * @brief アイテムの銘を刻むコマンドのメインルーチン
1075 * Inscribe an object with a comment
1078 void do_cmd_inscribe(void)
1082 char o_name[MAX_NLEN];
1086 item_tester_no_ryoute = TRUE;
1087 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1088 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1090 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1092 /* Get the item (in the pack) */
1095 o_ptr = &inventory[item];
1098 /* Get the item (on the floor) */
1101 o_ptr = &o_list[0 - item];
1104 /* Describe the activity */
1105 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1107 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1110 /* Start with nothing */
1111 strcpy(out_val, "");
1113 /* Use old inscription */
1114 if (o_ptr->inscription)
1116 /* Start with the old inscription */
1117 strcpy(out_val, quark_str(o_ptr->inscription));
1120 /* Get a new inscription (possibly empty) */
1121 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1123 /* Save the inscription */
1124 o_ptr->inscription = quark_add(out_val);
1126 /* Combine the pack */
1127 p_ptr->notice |= (PN_COMBINE);
1129 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1131 /* .や$の関係で, 再計算が必要なはず -- henkma */
1132 p_ptr->update |= (PU_BONUS);
1139 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1140 * An "item_tester_hook" for refilling lanterns
1141 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1142 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1144 static bool item_tester_refill_lantern(object_type *o_ptr)
1146 /* Flasks of oil are okay */
1147 if (o_ptr->tval == TV_FLASK) return (TRUE);
1149 /* Laterns are okay */
1150 if ((o_ptr->tval == TV_LITE) &&
1151 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1153 /* Assume not okay */
1159 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1160 * Refill the players lamp (from the pack or floor)
1163 static void do_cmd_refill_lamp(void)
1173 /* Restrict the choices */
1174 item_tester_hook = item_tester_refill_lantern;
1177 q = "どの油つぼから注ぎますか? ";
1180 q = "Refill with which flask? ";
1181 s = "You have no flasks of oil.";
1184 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1186 /* Get the item (in the pack) */
1189 o_ptr = &inventory[item];
1192 /* Get the item (on the floor) */
1195 o_ptr = &o_list[0 - item];
1198 /* Take a partial turn */
1199 p_ptr->energy_use = 50;
1201 /* Access the lantern */
1202 j_ptr = &inventory[INVEN_LITE];
1205 j_ptr->xtra4 += o_ptr->xtra4;
1206 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1208 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1211 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1213 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1216 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1218 else if (j_ptr->xtra4 >= FUEL_LAMP)
1220 j_ptr->xtra4 = FUEL_LAMP;
1221 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1224 /* Decrease the item (from the pack) */
1227 inven_item_increase(item, -1);
1228 inven_item_describe(item);
1229 inven_item_optimize(item);
1232 /* Decrease the item (from the floor) */
1235 floor_item_increase(0 - item, -1);
1236 floor_item_describe(0 - item);
1237 floor_item_optimize(0 - item);
1240 /* Recalculate torch */
1241 p_ptr->update |= (PU_TORCH);
1246 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1247 * An "item_tester_hook" for refilling torches
1248 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1249 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1251 static bool item_tester_refill_torch(object_type *o_ptr)
1253 /* Torches are okay */
1254 if ((o_ptr->tval == TV_LITE) &&
1255 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1257 /* Assume not okay */
1263 * @brief 松明を束ねるコマンドのメインルーチン
1264 * Refuel the players torch (from the pack or floor)
1267 static void do_cmd_refill_torch(void)
1276 /* Restrict the choices */
1277 item_tester_hook = item_tester_refill_torch;
1279 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1280 s = _("他に松明がない。", "You have no extra torches.");
1282 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1284 /* Get the item (in the pack) */
1287 o_ptr = &inventory[item];
1290 /* Get the item (on the floor) */
1293 o_ptr = &o_list[0 - item];
1297 /* Take a partial turn */
1298 p_ptr->energy_use = 50;
1300 /* Access the primary torch */
1301 j_ptr = &inventory[INVEN_LITE];
1304 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1306 msg_print(_("松明を結合した。", "You combine the torches."));
1308 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1311 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1313 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1316 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1318 /* Over-fuel message */
1319 else if (j_ptr->xtra4 >= FUEL_TORCH)
1321 j_ptr->xtra4 = FUEL_TORCH;
1322 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1325 /* Refuel message */
1328 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1331 /* Decrease the item (from the pack) */
1334 inven_item_increase(item, -1);
1335 inven_item_describe(item);
1336 inven_item_optimize(item);
1339 /* Decrease the item (from the floor) */
1342 floor_item_increase(0 - item, -1);
1343 floor_item_describe(0 - item);
1344 floor_item_optimize(0 - item);
1347 /* Recalculate torch */
1348 p_ptr->update |= (PU_TORCH);
1353 * @brief 燃料を補充するコマンドのメインルーチン
1354 * Refill the players lamp, or restock his torches
1357 void do_cmd_refill(void)
1362 o_ptr = &inventory[INVEN_LITE];
1364 if (p_ptr->special_defense & KATA_MUSOU)
1366 set_action(ACTION_NONE);
1370 if (o_ptr->tval != TV_LITE)
1372 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1376 else if (o_ptr->sval == SV_LITE_LANTERN)
1378 do_cmd_refill_lamp();
1382 else if (o_ptr->sval == SV_LITE_TORCH)
1384 do_cmd_refill_torch();
1387 /* No torch to refill */
1390 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1396 * @brief ターゲットを設定するコマンドのメインルーチン
1400 void do_cmd_target(void)
1403 if (target_set(TARGET_KILL))
1405 msg_print(_("ターゲット決定。", "Target Selected."));
1408 /* Target aborted */
1411 msg_print(_("ターゲット解除。", "Target Aborted."));
1418 * @brief 周囲を見渡すコマンドのメインルーチン
1422 void do_cmd_look(void)
1425 p_ptr->window |= PW_MONSTER_LIST;
1430 if (target_set(TARGET_LOOK))
1432 msg_print(_("ターゲット決定。", "Target Selected."));
1438 * @brief 位置を確認するコマンドのメインルーチン
1439 * Allow the player to examine other sectors on the map
1442 void do_cmd_locate(void)
1444 int dir, y1, x1, y2, x2;
1452 get_screen_size(&wid, &hgt);
1455 /* Start at current panel */
1456 y2 = y1 = panel_row_min;
1457 x2 = x1 = panel_col_min;
1459 /* Show panels until done */
1462 /* Describe the location */
1463 if ((y2 == y1) && (x2 == x1))
1466 strcpy(tmp_val, "真上");
1475 sprintf(tmp_val, "%s%s",
1476 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1477 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1479 sprintf(tmp_val, "%s%s of",
1480 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1481 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1486 /* Prepare to ask which way to look */
1487 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1488 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1489 y2 / (hgt / 2), y2 % (hgt / 2),
1490 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1492 /* Assume no direction */
1495 /* Get a direction */
1500 /* Get a command (or Cancel) */
1501 if (!get_com(out_val, &command, TRUE)) break;
1503 /* Extract the action (if any) */
1504 dir = get_keymap_dir(command);
1513 /* Apply the motion */
1514 if (change_panel(ddy[dir], ddx[dir]))
1522 /* Recenter the map around the player */
1525 p_ptr->update |= (PU_MONSTERS);
1528 p_ptr->redraw |= (PR_MAP);
1530 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1539 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1540 * Sorting hook -- Comp function -- see below
1541 * @param u モンスター種族情報の入れるポインタ
1543 * @param a 比較するモンスター種族のID1
1544 * @param b 比較するモンスター種族のID2
1545 * @return 2の方が大きければTRUEを返す
1546 * We use "u" to point to array of monster indexes,
1547 * and "v" to select the type of sorting to perform on "u".
1549 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1551 u16b *who = (u16b*)(u);
1553 u16b *why = (u16b*)(v);
1560 /* Sort by player kills */
1563 /* Extract player kills */
1564 z1 = r_info[w1].r_pkills;
1565 z2 = r_info[w2].r_pkills;
1567 /* Compare player kills */
1568 if (z1 < z2) return (TRUE);
1569 if (z1 > z2) return (FALSE);
1573 /* Sort by total kills */
1576 /* Extract total kills */
1577 z1 = r_info[w1].r_tkills;
1578 z2 = r_info[w2].r_tkills;
1580 /* Compare total kills */
1581 if (z1 < z2) return (TRUE);
1582 if (z1 > z2) return (FALSE);
1586 /* Sort by monster level */
1589 /* Extract levels */
1590 z1 = r_info[w1].level;
1591 z2 = r_info[w2].level;
1593 /* Compare levels */
1594 if (z1 < z2) return (TRUE);
1595 if (z1 > z2) return (FALSE);
1599 /* Sort by monster experience */
1602 /* Extract experience */
1603 z1 = r_info[w1].mexp;
1604 z2 = r_info[w2].mexp;
1606 /* Compare experience */
1607 if (z1 < z2) return (TRUE);
1608 if (z1 > z2) return (FALSE);
1612 /* Compare indexes */
1618 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1619 * Sorting hook -- Swap function -- see below
1620 * @param u モンスター種族情報の入れるポインタ
1622 * @param a スワップするモンスター種族のID1
1623 * @param b スワップするモンスター種族のID2
1626 * We use "u" to point to array of monster indexes,
1627 * and "v" to select the type of sorting to perform.
1629 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1631 u16b *who = (u16b*)(u);
1647 * @brief モンスターの思い出を見るコマンドのメインルーチン
1648 * Identify a character, allow recall of monsters
1652 * Several "special" responses recall "multiple" monsters:
1654 * ^U (all unique monsters)
1655 * ^N (all non-unique monsters)
1657 * The responses may be sorted in several ways, see below.
1659 * Note that the player ghosts are ignored.
1662 void do_cmd_query_symbol(void)
1676 bool recall = FALSE;
1681 /* Get a character, or abort */
1682 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1683 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1685 /* Find that character info, and describe it */
1686 for (i = 0; ident_info[i]; ++i)
1688 if (sym == ident_info[i][0]) break;
1690 if (sym == KTRL('A'))
1693 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1695 else if (sym == KTRL('U'))
1698 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1700 else if (sym == KTRL('N'))
1703 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1705 else if (sym == KTRL('R'))
1708 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1710 /* XTRA HACK WHATSEARCH */
1711 else if (sym == KTRL('M'))
1714 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1719 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1721 else if (ident_info[i])
1723 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1727 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1730 /* Display the result */
1733 /* Allocate the "who" array */
1734 C_MAKE(who, max_r_idx, IDX);
1736 /* Collect matching monsters */
1737 for (n = 0, i = 1; i < max_r_idx; i++)
1739 monster_race *r_ptr = &r_info[i];
1741 /* Nothing to recall */
1742 if (!cheat_know && !r_ptr->r_sights) continue;
1744 /* Require non-unique monsters if needed */
1745 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1747 /* Require unique monsters if needed */
1748 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1750 /* Require ridable monsters if needed */
1751 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1753 /* XTRA HACK WHATSEARCH */
1759 for (xx = 0; temp[xx] && xx < 80; xx++)
1762 if (iskanji(temp[xx])) { xx++; continue; }
1764 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1768 strcpy(temp2, r_name + r_ptr->E_name);
1770 strcpy(temp2, r_name + r_ptr->name);
1772 for (xx = 0; temp2[xx] && xx < 80; xx++)
1773 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1776 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1778 if (my_strstr(temp2, temp))
1783 /* Collect "appropriate" monsters */
1784 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1787 /* Nothing to recall */
1790 /* Free the "who" array */
1791 C_KILL(who, max_r_idx, IDX);
1798 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1809 /* Select the sort method */
1810 ang_sort_comp = ang_sort_comp_hook;
1811 ang_sort_swap = ang_sort_swap_hook;
1813 /* Sort the array */
1814 ang_sort(who, &why, n);
1816 /* Sort by kills (and level) */
1823 /* Catch "escape" */
1826 /* Free the "who" array */
1827 C_KILL(who, max_r_idx, IDX);
1832 /* Sort if needed */
1835 /* Select the sort method */
1836 ang_sort_comp = ang_sort_comp_hook;
1837 ang_sort_swap = ang_sort_swap_hook;
1839 /* Sort the array */
1840 ang_sort(who, &why, n);
1844 /* Start at the end */
1847 /* Scan the monster memory */
1850 /* Extract a race */
1853 /* Hack -- Auto-recall */
1854 monster_race_track(r_idx);
1856 /* Hack -- Handle stuff */
1865 /* Save the screen */
1868 /* Recall on screen */
1869 screen_roff(who[i], 0);
1872 /* Hack -- Begin the prompt */
1875 /* Hack -- Complete the prompt */
1876 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1888 /* Normal commands */
1889 if (query != 'r') break;
1896 if (query == ESCAPE) break;
1898 /* Move to "prev" monster */
1904 if (!expand_list) break;
1908 /* Move to "next" monster */
1914 if (!expand_list) break;
1919 /* Free the "who" array */
1920 C_KILL(who, max_r_idx, IDX);
1922 /* Re-display the identity */
1927 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1931 * XXX - Add actions for other item types
1933 void do_cmd_use(void)
1939 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1941 set_action(ACTION_NONE);
1944 item_tester_no_ryoute = TRUE;
1945 /* Prepare the hook */
1946 item_tester_hook = item_tester_hook_use;
1948 q = _("どれを使いますか?", "Use which item? ");
1949 s = _("使えるものがありません。", "You have nothing to use.");
1951 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1953 /* Get the item (in the pack) */
1956 o_ptr = &inventory[item];
1958 /* Get the item (on the floor) */
1961 o_ptr = &o_list[0 - item];
1964 switch (o_ptr->tval)
1976 do_cmd_eat_food_aux(item);
1983 do_cmd_aim_wand_aux(item);
1990 do_cmd_use_staff_aux(item);
1997 do_cmd_zap_rod_aux(item);
2001 /* Quaff a potion */
2004 do_cmd_quaff_potion_aux(item);
2011 /* Check some conditions */
2014 msg_print(_("目が見えない。", "You can't see anything."));
2019 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2022 if (p_ptr->confused)
2024 msg_print(_("混乱していて読めない!", "You are too confused!"));
2028 do_cmd_read_scroll_aux(item, TRUE);
2037 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2041 /* Activate an artifact */
2044 do_cmd_activate_aux(item);