3 * @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory commands
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 #include "cmd-activate.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "player-item.h"
25 #include "object-hook.h"
29 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
32 void do_cmd_inven(void)
37 /* Note that we are in "inventory" mode */
40 /* Note that we are in "inventory" mode */
41 if (easy_floor) command_wrk = (USE_INVEN);
44 /* Hack -- show empty slots */
45 item_tester_full = TRUE;
47 /* Display the inventory */
50 /* Hack -- hide empty slots */
51 item_tester_full = FALSE;
54 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
55 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
56 (long int)((p_ptr->total_weight * 100) / weight_limit()));
58 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
59 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
60 (p_ptr->total_weight * 100) / weight_limit());
67 /* Get a new command */
68 command_new = inkey();
72 /* Process "Escape" */
73 if (command_new == ESCAPE)
77 Term_get_size(&wid, &hgt);
81 command_gap = wid - 30;
84 /* Process normal keys */
87 /* Hack -- Use "display" mode */
94 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
97 void do_cmd_equip(void)
102 /* Note that we are in "equipment" mode */
105 /* Note that we are in "equipment" mode */
106 if (easy_floor) command_wrk = (USE_EQUIP);
109 /* Hack -- show empty slots */
110 item_tester_full = TRUE;
112 /* Display the equipment */
115 /* Hack -- undo the hack above */
116 item_tester_full = FALSE;
120 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
121 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
122 (long int)((p_ptr->total_weight * 100) / weight_limit()));
124 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
125 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
126 (long int)((p_ptr->total_weight * 100) / weight_limit()));
133 /* Get a new command */
134 command_new = inkey();
138 /* Process "Escape" */
139 if (command_new == ESCAPE)
143 Term_get_size(&wid, &hgt);
147 command_gap = wid - 30;
150 /* Process normal keys */
153 /* Enter "display" mode */
161 bool select_ring_slot = FALSE;
164 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
167 void do_cmd_wield(void)
169 OBJECT_IDX item, slot;
177 char o_name[MAX_NLEN];
180 OBJECT_IDX need_switch_wielding = 0;
182 if (p_ptr->special_defense & KATA_MUSOU)
184 set_action(ACTION_NONE);
187 /* Restrict the choices */
188 item_tester_hook = item_tester_hook_wear;
190 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
191 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
193 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
197 slot = wield_slot(o_ptr);
201 /* Shields and some misc. items */
206 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
208 /* Restrict the choices */
209 item_tester_hook = item_tester_hook_melee_weapon;
210 item_tester_no_ryoute = TRUE;
212 /* Choose a weapon from the equipment only */
213 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
214 s = _("おっと。", "Oops.");
215 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
216 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
219 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
221 /* Both arms are already used by non-weapon */
222 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
223 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
225 /* Restrict the choices */
226 item_tester_hook = item_tester_hook_mochikae;
229 q = _("どちらの手に装備しますか?", "Equip which hand? ");
230 s = _("おっと。", "Oops.");
231 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
240 /* Asking for dual wielding */
241 if (slot == INVEN_LARM)
243 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
246 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
248 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
251 /* Both arms are already used */
252 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
254 /* Restrict the choices */
255 item_tester_hook = item_tester_hook_mochikae;
258 q = _("どちらの手に装備しますか?", "Equip which hand? ");
259 s = _("おっと。", "Oops.");
261 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
262 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
263 need_switch_wielding = INVEN_RARM;
269 /* Choose a ring slot */
270 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
272 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
276 q = _("どちらの手に装備しますか?", "Equip which hand? ");
278 s = _("おっと。", "Oops.");
280 /* Restrict the choices */
281 select_ring_slot = TRUE;
282 item_tester_no_ryoute = TRUE;
284 if (!get_item(&slot, q, s, (USE_EQUIP)))
286 select_ring_slot = FALSE;
289 select_ring_slot = FALSE;
293 /* Prevent wielding into a cursed slot */
294 if (object_is_cursed(&inventory[slot]))
296 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
299 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
301 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
304 /* Cancel the command */
309 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
310 ((o_ptr->ident & IDENT_SENSE) &&
311 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
313 char dummy[MAX_NLEN+80];
315 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
316 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
318 if (!get_check(dummy)) return;
321 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
323 char dummy[MAX_NLEN+80];
325 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
328 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
330 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
331 sprintf(dummy, "Do you become a vampire?");
334 if (!get_check(dummy)) return;
337 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
339 object_type *slot_o_ptr = &inventory[slot];
340 object_type *switch_o_ptr = &inventory[need_switch_wielding];
341 object_type object_tmp;
342 object_type *otmp_ptr = &object_tmp;
343 char switch_name[MAX_NLEN];
345 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
347 object_copy(otmp_ptr, switch_o_ptr);
348 object_copy(switch_o_ptr, slot_o_ptr);
349 object_copy(slot_o_ptr, otmp_ptr);
351 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
352 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
353 (left_hander ? _("右手", "right") : _("左手", "left")));
354 slot = need_switch_wielding;
357 check_find_art_quest_completion(o_ptr);
359 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
361 identify_item(o_ptr);
363 /* Auto-inscription */
364 autopick_alter_item(item, FALSE);
367 p_ptr->energy_use = 100;
370 /* Obtain local object */
371 object_copy(q_ptr, o_ptr);
373 /* Modify quantity */
376 /* Decrease the item (from the pack) */
379 inven_item_increase(item, -1);
380 inven_item_optimize(item);
383 /* Decrease the item (from the floor) */
386 floor_item_increase(0 - item, -1);
387 floor_item_optimize(0 - item);
390 /* Access the wield slot */
391 o_ptr = &inventory[slot];
393 /* Take off existing item */
396 /* Take off existing item */
397 (void)inven_takeoff(slot, 255);
400 /* Wear the new stuff */
401 object_copy(o_ptr, q_ptr);
403 /* Player touches it */
404 o_ptr->marked |= OM_TOUCHED;
406 /* Increase the weight */
407 p_ptr->total_weight += q_ptr->weight;
409 /* Increment the equip counter by hand */
413 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
414 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
415 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
417 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
418 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
419 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
422 /* Where is the item now */
426 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
427 act = STR_WIELD_ARMS;
429 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
433 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
434 act = STR_WIELD_ARMS;
436 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
440 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
444 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
448 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
452 /* Describe the result */
453 object_desc(o_name, o_ptr, 0);
454 msg_format(act, o_name, index_to_label(slot));
457 if (object_is_cursed(o_ptr))
459 /* Warn the player */
460 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
461 chg_virtue(V_HARMONY, -1);
464 o_ptr->ident |= (IDENT_SENSE);
467 /* The Stone Mask make the player turn into a vampire! */
468 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
470 /* Turn into a vampire */
471 change_race(RACE_VAMPIRE, "");
474 /* Recalculate bonuses */
475 p_ptr->update |= (PU_BONUS);
477 /* Recalculate torch */
478 p_ptr->update |= (PU_TORCH);
480 /* Recalculate mana */
481 p_ptr->update |= (PU_MANA);
483 p_ptr->redraw |= (PR_EQUIPPY);
485 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
492 * @param item 持ち替えを行いたい装備部位ID
495 void kamaenaoshi(INVENTORY_IDX item)
497 object_type *o_ptr, *new_o_ptr;
498 char o_name[MAX_NLEN];
500 if (item == INVEN_RARM)
502 if (buki_motteruka(INVEN_LARM))
504 o_ptr = &inventory[INVEN_LARM];
505 object_desc(o_name, o_ptr, 0);
507 if (!object_is_cursed(o_ptr))
509 new_o_ptr = &inventory[INVEN_RARM];
510 object_copy(new_o_ptr, o_ptr);
511 p_ptr->total_weight += o_ptr->weight;
512 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
513 inven_item_optimize(INVEN_LARM);
514 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
515 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
517 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
518 (left_hander ? _("左手", "left") : _("右手", "right")));
522 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
523 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
527 else if (item == INVEN_LARM)
529 o_ptr = &inventory[INVEN_RARM];
530 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
532 if (buki_motteruka(INVEN_RARM))
534 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
535 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
537 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
539 new_o_ptr = &inventory[INVEN_LARM];
540 object_copy(new_o_ptr, o_ptr);
541 p_ptr->total_weight += o_ptr->weight;
542 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
543 inven_item_optimize(INVEN_RARM);
544 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
551 * @brief 装備を外すコマンドのメインルーチン / Take off an item
554 void do_cmd_takeoff(void)
560 if (p_ptr->special_defense & KATA_MUSOU)
562 set_action(ACTION_NONE);
565 item_tester_no_ryoute = TRUE;
567 q = _("どれを装備からはずしますか? ", "Take off which item? ");
568 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
570 if (!get_item(&item, q, s, (USE_EQUIP))) return;
572 /* Get the item (in the pack) */
575 o_ptr = &inventory[item];
578 /* Get the item (on the floor) */
581 o_ptr = &o_list[0 - item];
586 if (object_is_cursed(o_ptr))
588 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
590 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
595 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
597 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
599 /* Hack -- Assume felt */
600 o_ptr->ident |= (IDENT_SENSE);
602 o_ptr->curse_flags = 0L;
605 o_ptr->feeling = FEEL_NONE;
607 /* Recalculate the bonuses */
608 p_ptr->update |= (PU_BONUS);
610 p_ptr->window |= (PW_EQUIP);
612 msg_print(_("呪いを打ち破った。", "You break the curse."));
616 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
617 p_ptr->energy_use = 50;
622 /* Take a partial turn */
623 p_ptr->energy_use = 50;
625 /* Take off the item */
626 (void)inven_takeoff(item, 255);
629 p_ptr->redraw |= (PR_EQUIPPY);
634 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
637 void do_cmd_drop(void)
646 if (p_ptr->special_defense & KATA_MUSOU)
648 set_action(ACTION_NONE);
651 item_tester_no_ryoute = TRUE;
652 q = _("どのアイテムを落としますか? ", "Drop which item? ");
653 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
655 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
657 /* Get the item (in the pack) */
660 o_ptr = &inventory[item];
663 /* Get the item (on the floor) */
666 o_ptr = &o_list[0 - item];
670 /* Hack -- Cannot remove cursed items */
671 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
673 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
678 /* See how many items */
679 if (o_ptr->number > 1)
682 amt = get_quantity(NULL, o_ptr->number);
684 /* Allow user abort */
685 if (amt <= 0) return;
689 /* Take a partial turn */
690 p_ptr->energy_use = 50;
692 /* Drop (some of) the item */
693 inven_drop(item, amt);
695 if (item >= INVEN_RARM)
701 p_ptr->redraw |= (PR_EQUIPPY);
705 * @brief オブジェクトが高位の魔法書かどうかを判定する
706 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
707 * @return オブジェクトが高位の魔法書ならばTRUEを返す
709 static bool high_level_book(object_type *o_ptr)
711 if ((o_ptr->tval == TV_LIFE_BOOK) ||
712 (o_ptr->tval == TV_SORCERY_BOOK) ||
713 (o_ptr->tval == TV_NATURE_BOOK) ||
714 (o_ptr->tval == TV_CHAOS_BOOK) ||
715 (o_ptr->tval == TV_DEATH_BOOK) ||
716 (o_ptr->tval == TV_TRUMP_BOOK) ||
717 (o_ptr->tval == TV_CRAFT_BOOK) ||
718 (o_ptr->tval == TV_DAEMON_BOOK) ||
719 (o_ptr->tval == TV_CRUSADE_BOOK) ||
720 (o_ptr->tval == TV_MUSIC_BOOK) ||
721 (o_ptr->tval == TV_HEX_BOOK))
734 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
737 void do_cmd_destroy(void)
747 object_type *q_ptr = &forge;
749 char o_name[MAX_NLEN];
750 char out_val[MAX_NLEN+40];
754 if (p_ptr->special_defense & KATA_MUSOU)
756 set_action(ACTION_NONE);
759 /* Hack -- force destruction */
760 if (command_arg > 0) force = TRUE;
762 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
763 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
765 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
767 /* Get the item (in the pack) */
770 o_ptr = &inventory[item];
773 /* Get the item (on the floor) */
776 o_ptr = &o_list[0 - item];
779 /* Verify unless quantity given beforehand */
780 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
782 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
784 /* Make a verification */
785 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
788 /* HACK : Add the line to message buffer */
789 message_add(out_val);
790 p_ptr->window |= (PW_MESSAGE);
793 /* Get an acceptable answer */
803 /* Erase the prompt */
807 if (i == 'y' || i == 'Y')
811 if (i == ESCAPE || i == 'n' || i == 'N')
818 /* Add an auto-destroy preference line */
819 if (autopick_autoregister(o_ptr))
821 /* Auto-destroy it */
822 autopick_alter_item(item, TRUE);
825 /* The object is already destroyed. */
831 /* See how many items */
832 if (o_ptr->number > 1)
835 amt = get_quantity(NULL, o_ptr->number);
837 /* Allow user abort */
838 if (amt <= 0) return;
842 old_number = o_ptr->number;
844 object_desc(o_name, o_ptr, 0);
845 o_ptr->number = old_number;
847 p_ptr->energy_use = 100;
849 /* Artifacts cannot be destroyed */
850 if (!can_player_destroy_object(o_ptr))
852 p_ptr->energy_use = 0;
854 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
858 object_copy(q_ptr, o_ptr);
860 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
861 sound(SOUND_DESTITEM);
863 /* Reduce the charges of rods/wands */
864 reduce_charges(o_ptr, amt);
866 /* Eliminate the item (from the pack) */
869 inven_item_increase(item, -amt);
870 inven_item_describe(item);
871 inven_item_optimize(item);
874 /* Eliminate the item (from the floor) */
877 floor_item_increase(0 - item, -amt);
878 floor_item_describe(0 - item);
879 floor_item_optimize(0 - item);
882 if (high_level_book(q_ptr))
884 bool gain_expr = FALSE;
886 if (p_ptr->prace == RACE_ANDROID)
889 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
893 else if (p_ptr->pclass == CLASS_PALADIN)
895 if (is_good_realm(p_ptr->realm1))
897 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
901 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
905 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
907 s32b tester_exp = p_ptr->max_exp / 20;
908 if (tester_exp > 10000) tester_exp = 10000;
909 if (q_ptr->sval < 3) tester_exp /= 4;
910 if (tester_exp<1) tester_exp = 1;
912 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
913 gain_exp(tester_exp * amt);
915 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
917 chg_virtue(V_UNLIFE, 1);
918 chg_virtue(V_VITALITY, -1);
920 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
922 chg_virtue(V_UNLIFE, -1);
923 chg_virtue(V_VITALITY, 1);
926 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
927 chg_virtue(V_ENCHANT, -1);
929 if (object_value_real(q_ptr) > 30000)
930 chg_virtue(V_SACRIFICE, 2);
932 else if (object_value_real(q_ptr) > 10000)
933 chg_virtue(V_SACRIFICE, 1);
936 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
937 chg_virtue(V_HARMONY, 1);
939 if (item >= INVEN_RARM) calc_android_exp();
944 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
947 void do_cmd_observe(void)
951 char o_name[MAX_NLEN];
955 item_tester_no_ryoute = TRUE;
957 q = _("どのアイテムを調べますか? ", "Examine which item? ");
958 s = _("調べられるアイテムがない。", "You have nothing to examine.");
960 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
962 /* Get the item (in the pack) */
965 o_ptr = &inventory[item];
968 /* Get the item (on the floor) */
971 o_ptr = &o_list[0 - item];
975 /* Require full knowledge */
976 if (!(o_ptr->ident & IDENT_MENTAL))
978 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
984 object_desc(o_name, o_ptr, 0);
985 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
986 /* Describe it fully */
987 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
993 * @brief アイテムの銘を消すコマンドのメインルーチン
994 * Remove the inscription from an object XXX Mention item (when done)?
997 void do_cmd_uninscribe(void)
1003 item_tester_no_ryoute = TRUE;
1004 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1005 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1007 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1009 /* Get the item (in the pack) */
1012 o_ptr = &inventory[item];
1015 /* Get the item (on the floor) */
1018 o_ptr = &o_list[0 - item];
1021 /* Nothing to remove */
1022 if (!o_ptr->inscription)
1024 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1028 msg_print(_("銘を消した。", "Inscription removed."));
1030 /* Remove the incription */
1031 o_ptr->inscription = 0;
1033 /* Combine the pack */
1034 p_ptr->notice |= (PN_COMBINE);
1036 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1038 /* .や$の関係で, 再計算が必要なはず -- henkma */
1039 p_ptr->update |= (PU_BONUS);
1045 * @brief アイテムの銘を刻むコマンドのメインルーチン
1046 * Inscribe an object with a comment
1049 void do_cmd_inscribe(void)
1053 char o_name[MAX_NLEN];
1057 item_tester_no_ryoute = TRUE;
1058 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1059 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1061 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1063 /* Get the item (in the pack) */
1066 o_ptr = &inventory[item];
1069 /* Get the item (on the floor) */
1072 o_ptr = &o_list[0 - item];
1075 /* Describe the activity */
1076 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1078 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1081 /* Start with nothing */
1082 strcpy(out_val, "");
1084 /* Use old inscription */
1085 if (o_ptr->inscription)
1087 /* Start with the old inscription */
1088 strcpy(out_val, quark_str(o_ptr->inscription));
1091 /* Get a new inscription (possibly empty) */
1092 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1094 /* Save the inscription */
1095 o_ptr->inscription = quark_add(out_val);
1097 /* Combine the pack */
1098 p_ptr->notice |= (PN_COMBINE);
1100 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1102 /* .や$の関係で, 再計算が必要なはず -- henkma */
1103 p_ptr->update |= (PU_BONUS);
1110 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1111 * An "item_tester_hook" for refilling lanterns
1112 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1113 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1115 static bool item_tester_refill_lantern(object_type *o_ptr)
1117 /* Flasks of oil are okay */
1118 if (o_ptr->tval == TV_FLASK) return (TRUE);
1120 /* Laterns are okay */
1121 if ((o_ptr->tval == TV_LITE) &&
1122 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1124 /* Assume not okay */
1130 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1131 * Refill the players lamp (from the pack or floor)
1134 static void do_cmd_refill_lamp(void)
1144 /* Restrict the choices */
1145 item_tester_hook = item_tester_refill_lantern;
1148 q = "どの油つぼから注ぎますか? ";
1151 q = "Refill with which flask? ";
1152 s = "You have no flasks of oil.";
1155 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1157 /* Get the item (in the pack) */
1160 o_ptr = &inventory[item];
1163 /* Get the item (on the floor) */
1166 o_ptr = &o_list[0 - item];
1169 /* Take a partial turn */
1170 p_ptr->energy_use = 50;
1172 /* Access the lantern */
1173 j_ptr = &inventory[INVEN_LITE];
1176 j_ptr->xtra4 += o_ptr->xtra4;
1177 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1179 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1182 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1184 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1187 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1189 else if (j_ptr->xtra4 >= FUEL_LAMP)
1191 j_ptr->xtra4 = FUEL_LAMP;
1192 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1195 /* Decrease the item (from the pack) */
1198 inven_item_increase(item, -1);
1199 inven_item_describe(item);
1200 inven_item_optimize(item);
1203 /* Decrease the item (from the floor) */
1206 floor_item_increase(0 - item, -1);
1207 floor_item_describe(0 - item);
1208 floor_item_optimize(0 - item);
1211 /* Recalculate torch */
1212 p_ptr->update |= (PU_TORCH);
1217 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1218 * An "item_tester_hook" for refilling torches
1219 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1220 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1222 static bool item_tester_refill_torch(object_type *o_ptr)
1224 /* Torches are okay */
1225 if ((o_ptr->tval == TV_LITE) &&
1226 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1228 /* Assume not okay */
1234 * @brief 松明を束ねるコマンドのメインルーチン
1235 * Refuel the players torch (from the pack or floor)
1238 static void do_cmd_refill_torch(void)
1247 /* Restrict the choices */
1248 item_tester_hook = item_tester_refill_torch;
1250 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1251 s = _("他に松明がない。", "You have no extra torches.");
1253 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1255 /* Get the item (in the pack) */
1258 o_ptr = &inventory[item];
1261 /* Get the item (on the floor) */
1264 o_ptr = &o_list[0 - item];
1268 /* Take a partial turn */
1269 p_ptr->energy_use = 50;
1271 /* Access the primary torch */
1272 j_ptr = &inventory[INVEN_LITE];
1275 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1277 msg_print(_("松明を結合した。", "You combine the torches."));
1279 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1282 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1284 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1287 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1289 /* Over-fuel message */
1290 else if (j_ptr->xtra4 >= FUEL_TORCH)
1292 j_ptr->xtra4 = FUEL_TORCH;
1293 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1296 /* Refuel message */
1299 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1302 /* Decrease the item (from the pack) */
1305 inven_item_increase(item, -1);
1306 inven_item_describe(item);
1307 inven_item_optimize(item);
1310 /* Decrease the item (from the floor) */
1313 floor_item_increase(0 - item, -1);
1314 floor_item_describe(0 - item);
1315 floor_item_optimize(0 - item);
1318 /* Recalculate torch */
1319 p_ptr->update |= (PU_TORCH);
1324 * @brief 燃料を補充するコマンドのメインルーチン
1325 * Refill the players lamp, or restock his torches
1328 void do_cmd_refill(void)
1333 o_ptr = &inventory[INVEN_LITE];
1335 if (p_ptr->special_defense & KATA_MUSOU)
1337 set_action(ACTION_NONE);
1341 if (o_ptr->tval != TV_LITE)
1343 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1347 else if (o_ptr->sval == SV_LITE_LANTERN)
1349 do_cmd_refill_lamp();
1353 else if (o_ptr->sval == SV_LITE_TORCH)
1355 do_cmd_refill_torch();
1358 /* No torch to refill */
1361 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1367 * @brief ターゲットを設定するコマンドのメインルーチン
1371 void do_cmd_target(void)
1374 if (target_set(TARGET_KILL))
1376 msg_print(_("ターゲット決定。", "Target Selected."));
1379 /* Target aborted */
1382 msg_print(_("ターゲット解除。", "Target Aborted."));
1389 * @brief 周囲を見渡すコマンドのメインルーチン
1393 void do_cmd_look(void)
1395 p_ptr->window |= PW_MONSTER_LIST;
1399 if (target_set(TARGET_LOOK))
1401 msg_print(_("ターゲット決定。", "Target Selected."));
1407 * @brief 位置を確認するコマンドのメインルーチン
1408 * Allow the player to examine other sectors on the map
1411 void do_cmd_locate(void)
1413 int dir, y1, x1, y2, x2;
1421 get_screen_size(&wid, &hgt);
1424 /* Start at current panel */
1425 y2 = y1 = panel_row_min;
1426 x2 = x1 = panel_col_min;
1428 /* Show panels until done */
1431 /* Describe the location */
1432 if ((y2 == y1) && (x2 == x1))
1435 strcpy(tmp_val, "真上");
1444 sprintf(tmp_val, "%s%s",
1445 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1446 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1448 sprintf(tmp_val, "%s%s of",
1449 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1450 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1455 /* Prepare to ask which way to look */
1456 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1457 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1458 y2 / (hgt / 2), y2 % (hgt / 2),
1459 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1461 /* Assume no direction */
1464 /* Get a direction */
1469 /* Get a command (or Cancel) */
1470 if (!get_com(out_val, &command, TRUE)) break;
1472 /* Extract the action (if any) */
1473 dir = get_keymap_dir(command);
1482 /* Apply the motion */
1483 if (change_panel(ddy[dir], ddx[dir]))
1491 /* Recenter the map around the player */
1494 p_ptr->update |= (PU_MONSTERS);
1496 p_ptr->redraw |= (PR_MAP);
1498 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1505 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1506 * Sorting hook -- Comp function -- see below
1507 * @param u モンスター種族情報の入れるポインタ
1509 * @param a 比較するモンスター種族のID1
1510 * @param b 比較するモンスター種族のID2
1511 * @return 2の方が大きければTRUEを返す
1512 * We use "u" to point to array of monster indexes,
1513 * and "v" to select the type of sorting to perform on "u".
1515 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1517 u16b *who = (u16b*)(u);
1519 u16b *why = (u16b*)(v);
1526 /* Sort by player kills */
1529 /* Extract player kills */
1530 z1 = r_info[w1].r_pkills;
1531 z2 = r_info[w2].r_pkills;
1533 /* Compare player kills */
1534 if (z1 < z2) return (TRUE);
1535 if (z1 > z2) return (FALSE);
1539 /* Sort by total kills */
1542 /* Extract total kills */
1543 z1 = r_info[w1].r_tkills;
1544 z2 = r_info[w2].r_tkills;
1546 /* Compare total kills */
1547 if (z1 < z2) return (TRUE);
1548 if (z1 > z2) return (FALSE);
1552 /* Sort by monster level */
1555 /* Extract levels */
1556 z1 = r_info[w1].level;
1557 z2 = r_info[w2].level;
1559 /* Compare levels */
1560 if (z1 < z2) return (TRUE);
1561 if (z1 > z2) return (FALSE);
1565 /* Sort by monster experience */
1568 /* Extract experience */
1569 z1 = r_info[w1].mexp;
1570 z2 = r_info[w2].mexp;
1572 /* Compare experience */
1573 if (z1 < z2) return (TRUE);
1574 if (z1 > z2) return (FALSE);
1578 /* Compare indexes */
1584 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1585 * Sorting hook -- Swap function -- see below
1586 * @param u モンスター種族情報の入れるポインタ
1588 * @param a スワップするモンスター種族のID1
1589 * @param b スワップするモンスター種族のID2
1592 * We use "u" to point to array of monster indexes,
1593 * and "v" to select the type of sorting to perform.
1595 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1597 u16b *who = (u16b*)(u);
1613 * @brief モンスターの思い出を見るコマンドのメインルーチン
1614 * Identify a character, allow recall of monsters
1618 * Several "special" responses recall "multiple" monsters:
1620 * ^U (all unique monsters)
1621 * ^N (all non-unique monsters)
1623 * The responses may be sorted in several ways, see below.
1625 * Note that the player ghosts are ignored.
1628 void do_cmd_query_symbol(void)
1642 bool recall = FALSE;
1647 /* Get a character, or abort */
1648 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1649 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1651 /* Find that character info, and describe it */
1652 for (i = 0; ident_info[i]; ++i)
1654 if (sym == ident_info[i][0]) break;
1656 if (sym == KTRL('A'))
1659 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1661 else if (sym == KTRL('U'))
1664 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1666 else if (sym == KTRL('N'))
1669 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1671 else if (sym == KTRL('R'))
1674 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1676 /* XTRA HACK WHATSEARCH */
1677 else if (sym == KTRL('M'))
1680 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1685 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1687 else if (ident_info[i])
1689 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1693 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1696 /* Display the result */
1699 /* Allocate the "who" array */
1700 C_MAKE(who, max_r_idx, IDX);
1702 /* Collect matching monsters */
1703 for (n = 0, i = 1; i < max_r_idx; i++)
1705 monster_race *r_ptr = &r_info[i];
1707 /* Nothing to recall */
1708 if (!cheat_know && !r_ptr->r_sights) continue;
1710 /* Require non-unique monsters if needed */
1711 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1713 /* Require unique monsters if needed */
1714 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1716 /* Require ridable monsters if needed */
1717 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1719 /* XTRA HACK WHATSEARCH */
1725 for (xx = 0; temp[xx] && xx < 80; xx++)
1728 if (iskanji(temp[xx])) { xx++; continue; }
1730 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1734 strcpy(temp2, r_name + r_ptr->E_name);
1736 strcpy(temp2, r_name + r_ptr->name);
1738 for (xx = 0; temp2[xx] && xx < 80; xx++)
1739 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1742 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1744 if (my_strstr(temp2, temp))
1749 /* Collect "appropriate" monsters */
1750 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1753 /* Nothing to recall */
1756 /* Free the "who" array */
1757 C_KILL(who, max_r_idx, IDX);
1763 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1773 /* Select the sort method */
1774 ang_sort_comp = ang_sort_comp_hook;
1775 ang_sort_swap = ang_sort_swap_hook;
1777 /* Sort the array */
1778 ang_sort(who, &why, n);
1780 /* Sort by kills (and level) */
1787 /* Catch "escape" */
1790 /* Free the "who" array */
1791 C_KILL(who, max_r_idx, IDX);
1796 /* Sort if needed */
1799 /* Select the sort method */
1800 ang_sort_comp = ang_sort_comp_hook;
1801 ang_sort_swap = ang_sort_swap_hook;
1803 /* Sort the array */
1804 ang_sort(who, &why, n);
1808 /* Start at the end */
1811 /* Scan the monster memory */
1814 /* Extract a race */
1817 /* Hack -- Auto-recall */
1818 monster_race_track(r_idx);
1829 /* Recall on screen */
1830 screen_roff(who[i], 0);
1833 /* Hack -- Begin the prompt */
1836 /* Hack -- Complete the prompt */
1837 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1849 /* Normal commands */
1850 if (query != 'r') break;
1857 if (query == ESCAPE) break;
1859 /* Move to "prev" monster */
1865 if (!expand_list) break;
1869 /* Move to "next" monster */
1875 if (!expand_list) break;
1880 /* Free the "who" array */
1881 C_KILL(who, max_r_idx, IDX);
1883 /* Re-display the identity */
1888 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1892 * XXX - Add actions for other item types
1894 void do_cmd_use(void)
1900 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1902 set_action(ACTION_NONE);
1905 item_tester_no_ryoute = TRUE;
1906 item_tester_hook = item_tester_hook_use;
1908 q = _("どれを使いますか?", "Use which item? ");
1909 s = _("使えるものがありません。", "You have nothing to use.");
1911 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1913 /* Get the item (in the pack) */
1916 o_ptr = &inventory[item];
1918 /* Get the item (on the floor) */
1921 o_ptr = &o_list[0 - item];
1924 switch (o_ptr->tval)
1936 do_cmd_eat_food_aux(item);
1943 do_cmd_aim_wand_aux(item);
1950 do_cmd_use_staff_aux(item);
1957 do_cmd_zap_rod_aux(item);
1961 /* Quaff a potion */
1964 do_cmd_quaff_potion_aux(item);
1971 /* Check some conditions */
1974 msg_print(_("目が見えない。", "You can't see anything."));
1979 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
1982 if (p_ptr->confused)
1984 msg_print(_("混乱していて読めない!", "You are too confused!"));
1988 do_cmd_read_scroll_aux(item, TRUE);
1997 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2001 /* Activate an artifact */
2004 do_cmd_activate_aux(item);