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);
484 msg_format(act, o_name, index_to_label(slot));
488 if (object_is_cursed(o_ptr))
490 /* Warn the player */
491 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
492 chg_virtue(V_HARMONY, -1);
495 o_ptr->ident |= (IDENT_SENSE);
498 /* The Stone Mask make the player turn into a vampire! */
499 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
501 /* Turn into a vampire */
502 change_race(RACE_VAMPIRE, "");
505 /* Recalculate bonuses */
506 p_ptr->update |= (PU_BONUS);
508 /* Recalculate torch */
509 p_ptr->update |= (PU_TORCH);
511 /* Recalculate mana */
512 p_ptr->update |= (PU_MANA);
514 p_ptr->redraw |= (PR_EQUIPPY);
516 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
523 * @param item 持ち替えを行いたい装備部位ID
526 void kamaenaoshi(INVENTORY_IDX item)
528 object_type *o_ptr, *new_o_ptr;
529 char o_name[MAX_NLEN];
531 if (item == INVEN_RARM)
533 if (buki_motteruka(INVEN_LARM))
535 o_ptr = &inventory[INVEN_LARM];
536 object_desc(o_name, o_ptr, 0);
538 if (!object_is_cursed(o_ptr))
540 new_o_ptr = &inventory[INVEN_RARM];
541 object_copy(new_o_ptr, o_ptr);
542 p_ptr->total_weight += o_ptr->weight;
543 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
544 inven_item_optimize(INVEN_LARM);
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);
548 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
549 (left_hander ? _("左手", "left") : _("右手", "right")));
553 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
554 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
558 else if (item == INVEN_LARM)
560 o_ptr = &inventory[INVEN_RARM];
561 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
563 if (buki_motteruka(INVEN_RARM))
565 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
566 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
568 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
570 new_o_ptr = &inventory[INVEN_LARM];
571 object_copy(new_o_ptr, o_ptr);
572 p_ptr->total_weight += o_ptr->weight;
573 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
574 inven_item_optimize(INVEN_RARM);
575 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
582 * @brief 装備を外すコマンドのメインルーチン / Take off an item
585 void do_cmd_takeoff(void)
591 if (p_ptr->special_defense & KATA_MUSOU)
593 set_action(ACTION_NONE);
596 item_tester_no_ryoute = TRUE;
598 q = _("どれを装備からはずしますか? ", "Take off which item? ");
599 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
601 if (!get_item(&item, q, s, (USE_EQUIP))) return;
603 /* Get the item (in the pack) */
606 o_ptr = &inventory[item];
609 /* Get the item (on the floor) */
612 o_ptr = &o_list[0 - item];
617 if (object_is_cursed(o_ptr))
619 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
621 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
626 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
628 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
630 /* Hack -- Assume felt */
631 o_ptr->ident |= (IDENT_SENSE);
633 o_ptr->curse_flags = 0L;
636 o_ptr->feeling = FEEL_NONE;
638 /* Recalculate the bonuses */
639 p_ptr->update |= (PU_BONUS);
641 p_ptr->window |= (PW_EQUIP);
643 msg_print(_("呪いを打ち破った。", "You break the curse."));
647 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
648 p_ptr->energy_use = 50;
653 /* Take a partial turn */
654 p_ptr->energy_use = 50;
656 /* Take off the item */
657 (void)inven_takeoff(item, 255);
660 p_ptr->redraw |= (PR_EQUIPPY);
665 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
668 void do_cmd_drop(void)
677 if (p_ptr->special_defense & KATA_MUSOU)
679 set_action(ACTION_NONE);
682 item_tester_no_ryoute = TRUE;
683 q = _("どのアイテムを落としますか? ", "Drop which item? ");
684 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
686 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
688 /* Get the item (in the pack) */
691 o_ptr = &inventory[item];
694 /* Get the item (on the floor) */
697 o_ptr = &o_list[0 - item];
701 /* Hack -- Cannot remove cursed items */
702 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
704 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
709 /* See how many items */
710 if (o_ptr->number > 1)
713 amt = get_quantity(NULL, o_ptr->number);
715 /* Allow user abort */
716 if (amt <= 0) return;
720 /* Take a partial turn */
721 p_ptr->energy_use = 50;
723 /* Drop (some of) the item */
724 inven_drop(item, amt);
726 if (item >= INVEN_RARM)
732 p_ptr->redraw |= (PR_EQUIPPY);
736 * @brief オブジェクトが高位の魔法書かどうかを判定する
737 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
738 * @return オブジェクトが高位の魔法書ならばTRUEを返す
740 static bool high_level_book(object_type *o_ptr)
742 if ((o_ptr->tval == TV_LIFE_BOOK) ||
743 (o_ptr->tval == TV_SORCERY_BOOK) ||
744 (o_ptr->tval == TV_NATURE_BOOK) ||
745 (o_ptr->tval == TV_CHAOS_BOOK) ||
746 (o_ptr->tval == TV_DEATH_BOOK) ||
747 (o_ptr->tval == TV_TRUMP_BOOK) ||
748 (o_ptr->tval == TV_CRAFT_BOOK) ||
749 (o_ptr->tval == TV_DAEMON_BOOK) ||
750 (o_ptr->tval == TV_CRUSADE_BOOK) ||
751 (o_ptr->tval == TV_MUSIC_BOOK) ||
752 (o_ptr->tval == TV_HEX_BOOK))
765 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
768 void do_cmd_destroy(void)
778 object_type *q_ptr = &forge;
780 char o_name[MAX_NLEN];
781 char out_val[MAX_NLEN+40];
785 if (p_ptr->special_defense & KATA_MUSOU)
787 set_action(ACTION_NONE);
790 /* Hack -- force destruction */
791 if (command_arg > 0) force = TRUE;
793 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
794 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
796 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
798 /* Get the item (in the pack) */
801 o_ptr = &inventory[item];
804 /* Get the item (on the floor) */
807 o_ptr = &o_list[0 - item];
810 /* Verify unless quantity given beforehand */
811 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
813 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
815 /* Make a verification */
816 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
819 /* HACK : Add the line to message buffer */
820 message_add(out_val);
821 p_ptr->window |= (PW_MESSAGE);
824 /* Get an acceptable answer */
834 /* Erase the prompt */
838 if (i == 'y' || i == 'Y')
842 if (i == ESCAPE || i == 'n' || i == 'N')
849 /* Add an auto-destroy preference line */
850 if (autopick_autoregister(o_ptr))
852 /* Auto-destroy it */
853 autopick_alter_item(item, TRUE);
856 /* The object is already destroyed. */
862 /* See how many items */
863 if (o_ptr->number > 1)
866 amt = get_quantity(NULL, o_ptr->number);
868 /* Allow user abort */
869 if (amt <= 0) return;
873 old_number = o_ptr->number;
875 object_desc(o_name, o_ptr, 0);
876 o_ptr->number = old_number;
878 p_ptr->energy_use = 100;
880 /* Artifacts cannot be destroyed */
881 if (!can_player_destroy_object(o_ptr))
883 p_ptr->energy_use = 0;
885 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
889 object_copy(q_ptr, o_ptr);
891 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
892 sound(SOUND_DESTITEM);
894 /* Reduce the charges of rods/wands */
895 reduce_charges(o_ptr, amt);
897 /* Eliminate the item (from the pack) */
900 inven_item_increase(item, -amt);
901 inven_item_describe(item);
902 inven_item_optimize(item);
905 /* Eliminate the item (from the floor) */
908 floor_item_increase(0 - item, -amt);
909 floor_item_describe(0 - item);
910 floor_item_optimize(0 - item);
913 if (high_level_book(q_ptr))
915 bool gain_expr = FALSE;
917 if (p_ptr->prace == RACE_ANDROID)
920 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
924 else if (p_ptr->pclass == CLASS_PALADIN)
926 if (is_good_realm(p_ptr->realm1))
928 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
932 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
936 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
938 s32b tester_exp = p_ptr->max_exp / 20;
939 if (tester_exp > 10000) tester_exp = 10000;
940 if (q_ptr->sval < 3) tester_exp /= 4;
941 if (tester_exp<1) tester_exp = 1;
943 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
944 gain_exp(tester_exp * amt);
946 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
948 chg_virtue(V_UNLIFE, 1);
949 chg_virtue(V_VITALITY, -1);
951 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
953 chg_virtue(V_UNLIFE, -1);
954 chg_virtue(V_VITALITY, 1);
957 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
958 chg_virtue(V_ENCHANT, -1);
960 if (object_value_real(q_ptr) > 30000)
961 chg_virtue(V_SACRIFICE, 2);
963 else if (object_value_real(q_ptr) > 10000)
964 chg_virtue(V_SACRIFICE, 1);
967 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
968 chg_virtue(V_HARMONY, 1);
970 if (item >= INVEN_RARM) calc_android_exp();
975 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
978 void do_cmd_observe(void)
982 char o_name[MAX_NLEN];
986 item_tester_no_ryoute = TRUE;
988 q = _("どのアイテムを調べますか? ", "Examine which item? ");
989 s = _("調べられるアイテムがない。", "You have nothing to examine.");
991 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
993 /* Get the item (in the pack) */
996 o_ptr = &inventory[item];
999 /* Get the item (on the floor) */
1002 o_ptr = &o_list[0 - item];
1006 /* Require full knowledge */
1007 if (!(o_ptr->ident & IDENT_MENTAL))
1009 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1015 object_desc(o_name, o_ptr, 0);
1018 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1019 /* Describe it fully */
1020 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1026 * @brief アイテムの銘を消すコマンドのメインルーチン
1027 * Remove the inscription from an object XXX Mention item (when done)?
1030 void do_cmd_uninscribe(void)
1036 item_tester_no_ryoute = TRUE;
1037 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1038 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1040 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1042 /* Get the item (in the pack) */
1045 o_ptr = &inventory[item];
1048 /* Get the item (on the floor) */
1051 o_ptr = &o_list[0 - item];
1054 /* Nothing to remove */
1055 if (!o_ptr->inscription)
1057 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1061 msg_print(_("銘を消した。", "Inscription removed."));
1063 /* Remove the incription */
1064 o_ptr->inscription = 0;
1066 /* Combine the pack */
1067 p_ptr->notice |= (PN_COMBINE);
1069 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1071 /* .や$の関係で, 再計算が必要なはず -- henkma */
1072 p_ptr->update |= (PU_BONUS);
1078 * @brief アイテムの銘を刻むコマンドのメインルーチン
1079 * Inscribe an object with a comment
1082 void do_cmd_inscribe(void)
1086 char o_name[MAX_NLEN];
1090 item_tester_no_ryoute = TRUE;
1091 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1092 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1094 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1096 /* Get the item (in the pack) */
1099 o_ptr = &inventory[item];
1102 /* Get the item (on the floor) */
1105 o_ptr = &o_list[0 - item];
1108 /* Describe the activity */
1109 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1111 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1114 /* Start with nothing */
1115 strcpy(out_val, "");
1117 /* Use old inscription */
1118 if (o_ptr->inscription)
1120 /* Start with the old inscription */
1121 strcpy(out_val, quark_str(o_ptr->inscription));
1124 /* Get a new inscription (possibly empty) */
1125 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1127 /* Save the inscription */
1128 o_ptr->inscription = quark_add(out_val);
1130 /* Combine the pack */
1131 p_ptr->notice |= (PN_COMBINE);
1133 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1135 /* .や$の関係で, 再計算が必要なはず -- henkma */
1136 p_ptr->update |= (PU_BONUS);
1143 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1144 * An "item_tester_hook" for refilling lanterns
1145 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1146 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1148 static bool item_tester_refill_lantern(object_type *o_ptr)
1150 /* Flasks of oil are okay */
1151 if (o_ptr->tval == TV_FLASK) return (TRUE);
1153 /* Laterns are okay */
1154 if ((o_ptr->tval == TV_LITE) &&
1155 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1157 /* Assume not okay */
1163 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1164 * Refill the players lamp (from the pack or floor)
1167 static void do_cmd_refill_lamp(void)
1177 /* Restrict the choices */
1178 item_tester_hook = item_tester_refill_lantern;
1181 q = "どの油つぼから注ぎますか? ";
1184 q = "Refill with which flask? ";
1185 s = "You have no flasks of oil.";
1188 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1190 /* Get the item (in the pack) */
1193 o_ptr = &inventory[item];
1196 /* Get the item (on the floor) */
1199 o_ptr = &o_list[0 - item];
1203 /* Take a partial turn */
1204 p_ptr->energy_use = 50;
1206 /* Access the lantern */
1207 j_ptr = &inventory[INVEN_LITE];
1210 j_ptr->xtra4 += o_ptr->xtra4;
1212 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1214 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1217 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1219 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1222 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1224 else if (j_ptr->xtra4 >= FUEL_LAMP)
1226 j_ptr->xtra4 = FUEL_LAMP;
1227 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1230 /* Decrease the item (from the pack) */
1233 inven_item_increase(item, -1);
1234 inven_item_describe(item);
1235 inven_item_optimize(item);
1238 /* Decrease the item (from the floor) */
1241 floor_item_increase(0 - item, -1);
1242 floor_item_describe(0 - item);
1243 floor_item_optimize(0 - item);
1246 /* Recalculate torch */
1247 p_ptr->update |= (PU_TORCH);
1252 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1253 * An "item_tester_hook" for refilling torches
1254 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1255 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1257 static bool item_tester_refill_torch(object_type *o_ptr)
1259 /* Torches are okay */
1260 if ((o_ptr->tval == TV_LITE) &&
1261 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1263 /* Assume not okay */
1269 * @brief 松明を束ねるコマンドのメインルーチン
1270 * Refuel the players torch (from the pack or floor)
1273 static void do_cmd_refill_torch(void)
1282 /* Restrict the choices */
1283 item_tester_hook = item_tester_refill_torch;
1285 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1286 s = _("他に松明がない。", "You have no extra torches.");
1288 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1290 /* Get the item (in the pack) */
1293 o_ptr = &inventory[item];
1296 /* Get the item (on the floor) */
1299 o_ptr = &o_list[0 - item];
1303 /* Take a partial turn */
1304 p_ptr->energy_use = 50;
1306 /* Access the primary torch */
1307 j_ptr = &inventory[INVEN_LITE];
1310 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1312 msg_print(_("松明を結合した。", "You combine the torches."));
1314 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1317 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1319 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1322 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1324 /* Over-fuel message */
1325 else if (j_ptr->xtra4 >= FUEL_TORCH)
1327 j_ptr->xtra4 = FUEL_TORCH;
1328 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1331 /* Refuel message */
1334 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1337 /* Decrease the item (from the pack) */
1340 inven_item_increase(item, -1);
1341 inven_item_describe(item);
1342 inven_item_optimize(item);
1345 /* Decrease the item (from the floor) */
1348 floor_item_increase(0 - item, -1);
1349 floor_item_describe(0 - item);
1350 floor_item_optimize(0 - item);
1353 /* Recalculate torch */
1354 p_ptr->update |= (PU_TORCH);
1359 * @brief 燃料を補充するコマンドのメインルーチン
1360 * Refill the players lamp, or restock his torches
1363 void do_cmd_refill(void)
1368 o_ptr = &inventory[INVEN_LITE];
1370 if (p_ptr->special_defense & KATA_MUSOU)
1372 set_action(ACTION_NONE);
1376 if (o_ptr->tval != TV_LITE)
1378 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1382 else if (o_ptr->sval == SV_LITE_LANTERN)
1384 do_cmd_refill_lamp();
1388 else if (o_ptr->sval == SV_LITE_TORCH)
1390 do_cmd_refill_torch();
1393 /* No torch to refill */
1396 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1402 * @brief ターゲットを設定するコマンドのメインルーチン
1406 void do_cmd_target(void)
1409 if (target_set(TARGET_KILL))
1411 msg_print(_("ターゲット決定。", "Target Selected."));
1414 /* Target aborted */
1417 msg_print(_("ターゲット解除。", "Target Aborted."));
1424 * @brief 周囲を見渡すコマンドのメインルーチン
1428 void do_cmd_look(void)
1431 p_ptr->window |= PW_MONSTER_LIST;
1436 if (target_set(TARGET_LOOK))
1438 msg_print(_("ターゲット決定。", "Target Selected."));
1444 * @brief 位置を確認するコマンドのメインルーチン
1445 * Allow the player to examine other sectors on the map
1448 void do_cmd_locate(void)
1450 int dir, y1, x1, y2, x2;
1458 get_screen_size(&wid, &hgt);
1461 /* Start at current panel */
1462 y2 = y1 = panel_row_min;
1463 x2 = x1 = panel_col_min;
1465 /* Show panels until done */
1468 /* Describe the location */
1469 if ((y2 == y1) && (x2 == x1))
1472 strcpy(tmp_val, "真上");
1481 sprintf(tmp_val, "%s%s",
1482 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1483 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1485 sprintf(tmp_val, "%s%s of",
1486 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1487 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1492 /* Prepare to ask which way to look */
1493 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1494 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1495 y2 / (hgt / 2), y2 % (hgt / 2),
1496 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1498 /* Assume no direction */
1501 /* Get a direction */
1506 /* Get a command (or Cancel) */
1507 if (!get_com(out_val, &command, TRUE)) break;
1509 /* Extract the action (if any) */
1510 dir = get_keymap_dir(command);
1519 /* Apply the motion */
1520 if (change_panel(ddy[dir], ddx[dir]))
1528 /* Recenter the map around the player */
1531 p_ptr->update |= (PU_MONSTERS);
1534 p_ptr->redraw |= (PR_MAP);
1536 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1545 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1546 * Sorting hook -- Comp function -- see below
1547 * @param u モンスター種族情報の入れるポインタ
1549 * @param a 比較するモンスター種族のID1
1550 * @param b 比較するモンスター種族のID2
1551 * @return 2の方が大きければTRUEを返す
1552 * We use "u" to point to array of monster indexes,
1553 * and "v" to select the type of sorting to perform on "u".
1555 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1557 u16b *who = (u16b*)(u);
1559 u16b *why = (u16b*)(v);
1566 /* Sort by player kills */
1569 /* Extract player kills */
1570 z1 = r_info[w1].r_pkills;
1571 z2 = r_info[w2].r_pkills;
1573 /* Compare player kills */
1574 if (z1 < z2) return (TRUE);
1575 if (z1 > z2) return (FALSE);
1579 /* Sort by total kills */
1582 /* Extract total kills */
1583 z1 = r_info[w1].r_tkills;
1584 z2 = r_info[w2].r_tkills;
1586 /* Compare total kills */
1587 if (z1 < z2) return (TRUE);
1588 if (z1 > z2) return (FALSE);
1592 /* Sort by monster level */
1595 /* Extract levels */
1596 z1 = r_info[w1].level;
1597 z2 = r_info[w2].level;
1599 /* Compare levels */
1600 if (z1 < z2) return (TRUE);
1601 if (z1 > z2) return (FALSE);
1605 /* Sort by monster experience */
1608 /* Extract experience */
1609 z1 = r_info[w1].mexp;
1610 z2 = r_info[w2].mexp;
1612 /* Compare experience */
1613 if (z1 < z2) return (TRUE);
1614 if (z1 > z2) return (FALSE);
1618 /* Compare indexes */
1624 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1625 * Sorting hook -- Swap function -- see below
1626 * @param u モンスター種族情報の入れるポインタ
1628 * @param a スワップするモンスター種族のID1
1629 * @param b スワップするモンスター種族のID2
1632 * We use "u" to point to array of monster indexes,
1633 * and "v" to select the type of sorting to perform.
1635 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1637 u16b *who = (u16b*)(u);
1653 * @brief モンスターの思い出を見るコマンドのメインルーチン
1654 * Identify a character, allow recall of monsters
1658 * Several "special" responses recall "multiple" monsters:
1660 * ^U (all unique monsters)
1661 * ^N (all non-unique monsters)
1663 * The responses may be sorted in several ways, see below.
1665 * Note that the player ghosts are ignored.
1668 void do_cmd_query_symbol(void)
1682 bool recall = FALSE;
1687 /* Get a character, or abort */
1688 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1689 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1691 /* Find that character info, and describe it */
1692 for (i = 0; ident_info[i]; ++i)
1694 if (sym == ident_info[i][0]) break;
1698 if (sym == KTRL('A'))
1701 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1703 else if (sym == KTRL('U'))
1706 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1708 else if (sym == KTRL('N'))
1711 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1713 else if (sym == KTRL('R'))
1716 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1718 /* XTRA HACK WHATSEARCH */
1719 else if (sym == KTRL('M'))
1722 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1727 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1729 else if (ident_info[i])
1731 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1735 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1738 /* Display the result */
1741 /* Allocate the "who" array */
1742 C_MAKE(who, max_r_idx, IDX);
1744 /* Collect matching monsters */
1745 for (n = 0, i = 1; i < max_r_idx; i++)
1747 monster_race *r_ptr = &r_info[i];
1749 /* Nothing to recall */
1750 if (!cheat_know && !r_ptr->r_sights) continue;
1752 /* Require non-unique monsters if needed */
1753 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1755 /* Require unique monsters if needed */
1756 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1758 /* Require ridable monsters if needed */
1759 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1761 /* XTRA HACK WHATSEARCH */
1767 for (xx = 0; temp[xx] && xx < 80; xx++)
1770 if (iskanji(temp[xx])) { xx++; continue; }
1772 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1776 strcpy(temp2, r_name + r_ptr->E_name);
1778 strcpy(temp2, r_name + r_ptr->name);
1780 for (xx = 0; temp2[xx] && xx < 80; xx++)
1781 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1784 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1786 if (my_strstr(temp2, temp))
1791 /* Collect "appropriate" monsters */
1792 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1795 /* Nothing to recall */
1798 /* Free the "who" array */
1799 C_KILL(who, max_r_idx, IDX);
1806 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1817 /* Select the sort method */
1818 ang_sort_comp = ang_sort_comp_hook;
1819 ang_sort_swap = ang_sort_swap_hook;
1821 /* Sort the array */
1822 ang_sort(who, &why, n);
1824 /* Sort by kills (and level) */
1831 /* Catch "escape" */
1834 /* Free the "who" array */
1835 C_KILL(who, max_r_idx, IDX);
1840 /* Sort if needed */
1843 /* Select the sort method */
1844 ang_sort_comp = ang_sort_comp_hook;
1845 ang_sort_swap = ang_sort_swap_hook;
1847 /* Sort the array */
1848 ang_sort(who, &why, n);
1852 /* Start at the end */
1855 /* Scan the monster memory */
1858 /* Extract a race */
1861 /* Hack -- Auto-recall */
1862 monster_race_track(r_idx);
1864 /* Hack -- Handle stuff */
1873 /* Save the screen */
1876 /* Recall on screen */
1877 screen_roff(who[i], 0);
1880 /* Hack -- Begin the prompt */
1883 /* Hack -- Complete the prompt */
1884 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1896 /* Normal commands */
1897 if (query != 'r') break;
1904 if (query == ESCAPE) break;
1906 /* Move to "prev" monster */
1912 if (!expand_list) break;
1916 /* Move to "next" monster */
1922 if (!expand_list) break;
1927 /* Free the "who" array */
1928 C_KILL(who, max_r_idx, IDX);
1930 /* Re-display the identity */
1935 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1939 * XXX - Add actions for other item types
1941 void do_cmd_use(void)
1947 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1949 set_action(ACTION_NONE);
1952 item_tester_no_ryoute = TRUE;
1953 /* Prepare the hook */
1954 item_tester_hook = item_tester_hook_use;
1956 q = _("どれを使いますか?", "Use which item? ");
1957 s = _("使えるものがありません。", "You have nothing to use.");
1959 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1961 /* Get the item (in the pack) */
1964 o_ptr = &inventory[item];
1966 /* Get the item (on the floor) */
1969 o_ptr = &o_list[0 - item];
1972 switch (o_ptr->tval)
1984 do_cmd_eat_food_aux(item);
1991 do_cmd_aim_wand_aux(item);
1998 do_cmd_use_staff_aux(item);
2005 do_cmd_zap_rod_aux(item);
2009 /* Quaff a potion */
2012 do_cmd_quaff_potion_aux(item);
2019 /* Check some conditions */
2022 msg_print(_("目が見えない。", "You can't see anything."));
2027 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2030 if (p_ptr->confused)
2032 msg_print(_("混乱していて読めない!", "You are too confused!"));
2036 do_cmd_read_scroll_aux(item, TRUE);
2045 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2049 /* Activate an artifact */
2052 do_cmd_activate_aux(item);