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."));
1215 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1218 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1220 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1223 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1225 else if (j_ptr->xtra4 >= FUEL_LAMP)
1227 j_ptr->xtra4 = FUEL_LAMP;
1228 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1231 /* Decrease the item (from the pack) */
1234 inven_item_increase(item, -1);
1235 inven_item_describe(item);
1236 inven_item_optimize(item);
1239 /* Decrease the item (from the floor) */
1242 floor_item_increase(0 - item, -1);
1243 floor_item_describe(0 - item);
1244 floor_item_optimize(0 - item);
1247 /* Recalculate torch */
1248 p_ptr->update |= (PU_TORCH);
1253 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1254 * An "item_tester_hook" for refilling torches
1255 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1256 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1258 static bool item_tester_refill_torch(object_type *o_ptr)
1260 /* Torches are okay */
1261 if ((o_ptr->tval == TV_LITE) &&
1262 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1264 /* Assume not okay */
1270 * @brief 松明を束ねるコマンドのメインルーチン
1271 * Refuel the players torch (from the pack or floor)
1274 static void do_cmd_refill_torch(void)
1283 /* Restrict the choices */
1284 item_tester_hook = item_tester_refill_torch;
1286 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1287 s = _("他に松明がない。", "You have no extra torches.");
1289 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1291 /* Get the item (in the pack) */
1294 o_ptr = &inventory[item];
1297 /* Get the item (on the floor) */
1300 o_ptr = &o_list[0 - item];
1304 /* Take a partial turn */
1305 p_ptr->energy_use = 50;
1307 /* Access the primary torch */
1308 j_ptr = &inventory[INVEN_LITE];
1311 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1313 msg_print(_("松明を結合した。", "You combine the torches."));
1316 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1319 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1321 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1324 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1326 /* Over-fuel message */
1327 else if (j_ptr->xtra4 >= FUEL_TORCH)
1329 j_ptr->xtra4 = FUEL_TORCH;
1330 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1333 /* Refuel message */
1336 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1339 /* Decrease the item (from the pack) */
1342 inven_item_increase(item, -1);
1343 inven_item_describe(item);
1344 inven_item_optimize(item);
1347 /* Decrease the item (from the floor) */
1350 floor_item_increase(0 - item, -1);
1351 floor_item_describe(0 - item);
1352 floor_item_optimize(0 - item);
1355 /* Recalculate torch */
1356 p_ptr->update |= (PU_TORCH);
1361 * @brief 燃料を補充するコマンドのメインルーチン
1362 * Refill the players lamp, or restock his torches
1365 void do_cmd_refill(void)
1370 o_ptr = &inventory[INVEN_LITE];
1372 if (p_ptr->special_defense & KATA_MUSOU)
1374 set_action(ACTION_NONE);
1378 if (o_ptr->tval != TV_LITE)
1380 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1384 else if (o_ptr->sval == SV_LITE_LANTERN)
1386 do_cmd_refill_lamp();
1390 else if (o_ptr->sval == SV_LITE_TORCH)
1392 do_cmd_refill_torch();
1395 /* No torch to refill */
1398 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1404 * @brief ターゲットを設定するコマンドのメインルーチン
1408 void do_cmd_target(void)
1411 if (target_set(TARGET_KILL))
1413 msg_print(_("ターゲット決定。", "Target Selected."));
1416 /* Target aborted */
1419 msg_print(_("ターゲット解除。", "Target Aborted."));
1426 * @brief 周囲を見渡すコマンドのメインルーチン
1430 void do_cmd_look(void)
1433 p_ptr->window |= PW_MONSTER_LIST;
1438 if (target_set(TARGET_LOOK))
1440 msg_print(_("ターゲット決定。", "Target Selected."));
1446 * @brief 位置を確認するコマンドのメインルーチン
1447 * Allow the player to examine other sectors on the map
1450 void do_cmd_locate(void)
1452 int dir, y1, x1, y2, x2;
1460 get_screen_size(&wid, &hgt);
1463 /* Start at current panel */
1464 y2 = y1 = panel_row_min;
1465 x2 = x1 = panel_col_min;
1467 /* Show panels until done */
1470 /* Describe the location */
1471 if ((y2 == y1) && (x2 == x1))
1474 strcpy(tmp_val, "真上");
1483 sprintf(tmp_val, "%s%s",
1484 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1485 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1487 sprintf(tmp_val, "%s%s of",
1488 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1489 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1494 /* Prepare to ask which way to look */
1495 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1496 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1497 y2 / (hgt / 2), y2 % (hgt / 2),
1498 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1500 /* Assume no direction */
1503 /* Get a direction */
1508 /* Get a command (or Cancel) */
1509 if (!get_com(out_val, &command, TRUE)) break;
1511 /* Extract the action (if any) */
1512 dir = get_keymap_dir(command);
1521 /* Apply the motion */
1522 if (change_panel(ddy[dir], ddx[dir]))
1530 /* Recenter the map around the player */
1533 p_ptr->update |= (PU_MONSTERS);
1536 p_ptr->redraw |= (PR_MAP);
1538 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1547 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1548 * Sorting hook -- Comp function -- see below
1549 * @param u モンスター種族情報の入れるポインタ
1551 * @param a 比較するモンスター種族のID1
1552 * @param b 比較するモンスター種族のID2
1553 * @return 2の方が大きければTRUEを返す
1554 * We use "u" to point to array of monster indexes,
1555 * and "v" to select the type of sorting to perform on "u".
1557 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1559 u16b *who = (u16b*)(u);
1561 u16b *why = (u16b*)(v);
1568 /* Sort by player kills */
1571 /* Extract player kills */
1572 z1 = r_info[w1].r_pkills;
1573 z2 = r_info[w2].r_pkills;
1575 /* Compare player kills */
1576 if (z1 < z2) return (TRUE);
1577 if (z1 > z2) return (FALSE);
1581 /* Sort by total kills */
1584 /* Extract total kills */
1585 z1 = r_info[w1].r_tkills;
1586 z2 = r_info[w2].r_tkills;
1588 /* Compare total kills */
1589 if (z1 < z2) return (TRUE);
1590 if (z1 > z2) return (FALSE);
1594 /* Sort by monster level */
1597 /* Extract levels */
1598 z1 = r_info[w1].level;
1599 z2 = r_info[w2].level;
1601 /* Compare levels */
1602 if (z1 < z2) return (TRUE);
1603 if (z1 > z2) return (FALSE);
1607 /* Sort by monster experience */
1610 /* Extract experience */
1611 z1 = r_info[w1].mexp;
1612 z2 = r_info[w2].mexp;
1614 /* Compare experience */
1615 if (z1 < z2) return (TRUE);
1616 if (z1 > z2) return (FALSE);
1620 /* Compare indexes */
1626 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1627 * Sorting hook -- Swap function -- see below
1628 * @param u モンスター種族情報の入れるポインタ
1630 * @param a スワップするモンスター種族のID1
1631 * @param b スワップするモンスター種族のID2
1634 * We use "u" to point to array of monster indexes,
1635 * and "v" to select the type of sorting to perform.
1637 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1639 u16b *who = (u16b*)(u);
1655 * @brief モンスターの思い出を見るコマンドのメインルーチン
1656 * Identify a character, allow recall of monsters
1660 * Several "special" responses recall "multiple" monsters:
1662 * ^U (all unique monsters)
1663 * ^N (all non-unique monsters)
1665 * The responses may be sorted in several ways, see below.
1667 * Note that the player ghosts are ignored.
1670 void do_cmd_query_symbol(void)
1684 bool recall = FALSE;
1689 /* Get a character, or abort */
1690 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1691 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1693 /* Find that character info, and describe it */
1694 for (i = 0; ident_info[i]; ++i)
1696 if (sym == ident_info[i][0]) break;
1700 if (sym == KTRL('A'))
1703 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1705 else if (sym == KTRL('U'))
1708 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1710 else if (sym == KTRL('N'))
1713 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1715 else if (sym == KTRL('R'))
1718 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1720 /* XTRA HACK WHATSEARCH */
1721 else if (sym == KTRL('M'))
1724 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1729 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1731 else if (ident_info[i])
1733 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1737 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1740 /* Display the result */
1743 /* Allocate the "who" array */
1744 C_MAKE(who, max_r_idx, IDX);
1746 /* Collect matching monsters */
1747 for (n = 0, i = 1; i < max_r_idx; i++)
1749 monster_race *r_ptr = &r_info[i];
1751 /* Nothing to recall */
1752 if (!cheat_know && !r_ptr->r_sights) continue;
1754 /* Require non-unique monsters if needed */
1755 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1757 /* Require unique monsters if needed */
1758 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1760 /* Require ridable monsters if needed */
1761 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1763 /* XTRA HACK WHATSEARCH */
1769 for (xx = 0; temp[xx] && xx < 80; xx++)
1772 if (iskanji(temp[xx])) { xx++; continue; }
1774 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1778 strcpy(temp2, r_name + r_ptr->E_name);
1780 strcpy(temp2, r_name + r_ptr->name);
1782 for (xx = 0; temp2[xx] && xx < 80; xx++)
1783 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1786 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1788 if (my_strstr(temp2, temp))
1793 /* Collect "appropriate" monsters */
1794 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1797 /* Nothing to recall */
1800 /* Free the "who" array */
1801 C_KILL(who, max_r_idx, IDX);
1808 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1819 /* Select the sort method */
1820 ang_sort_comp = ang_sort_comp_hook;
1821 ang_sort_swap = ang_sort_swap_hook;
1823 /* Sort the array */
1824 ang_sort(who, &why, n);
1826 /* Sort by kills (and level) */
1833 /* Catch "escape" */
1836 /* Free the "who" array */
1837 C_KILL(who, max_r_idx, IDX);
1842 /* Sort if needed */
1845 /* Select the sort method */
1846 ang_sort_comp = ang_sort_comp_hook;
1847 ang_sort_swap = ang_sort_swap_hook;
1849 /* Sort the array */
1850 ang_sort(who, &why, n);
1854 /* Start at the end */
1857 /* Scan the monster memory */
1860 /* Extract a race */
1863 /* Hack -- Auto-recall */
1864 monster_race_track(r_idx);
1866 /* Hack -- Handle stuff */
1875 /* Save the screen */
1878 /* Recall on screen */
1879 screen_roff(who[i], 0);
1882 /* Hack -- Begin the prompt */
1885 /* Hack -- Complete the prompt */
1886 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1898 /* Normal commands */
1899 if (query != 'r') break;
1906 if (query == ESCAPE) break;
1908 /* Move to "prev" monster */
1914 if (!expand_list) break;
1918 /* Move to "next" monster */
1924 if (!expand_list) break;
1929 /* Free the "who" array */
1930 C_KILL(who, max_r_idx, IDX);
1932 /* Re-display the identity */
1937 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1941 * XXX - Add actions for other item types
1943 void do_cmd_use(void)
1949 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1951 set_action(ACTION_NONE);
1954 item_tester_no_ryoute = TRUE;
1955 /* Prepare the hook */
1956 item_tester_hook = item_tester_hook_use;
1958 q = _("どれを使いますか?", "Use which item? ");
1959 s = _("使えるものがありません。", "You have nothing to use.");
1961 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1963 /* Get the item (in the pack) */
1966 o_ptr = &inventory[item];
1968 /* Get the item (on the floor) */
1971 o_ptr = &o_list[0 - item];
1974 switch (o_ptr->tval)
1986 do_cmd_eat_food_aux(item);
1993 do_cmd_aim_wand_aux(item);
2000 do_cmd_use_staff_aux(item);
2007 do_cmd_zap_rod_aux(item);
2011 /* Quaff a potion */
2014 do_cmd_quaff_potion_aux(item);
2021 /* Check some conditions */
2024 msg_print(_("目が見えない。", "You can't see anything."));
2029 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2032 if (p_ptr->confused)
2034 msg_print(_("混乱していて読めない!", "You are too confused!"));
2038 do_cmd_read_scroll_aux(item, TRUE);
2047 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2051 /* Activate an artifact */
2054 do_cmd_activate_aux(item);