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 object_desc(o_name, o_ptr, 0);
453 msg_format(act, o_name, index_to_label(slot));
456 if (object_is_cursed(o_ptr))
458 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
459 chg_virtue(V_HARMONY, -1);
462 o_ptr->ident |= (IDENT_SENSE);
465 /* The Stone Mask make the player turn into a vampire! */
466 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
468 /* Turn into a vampire */
469 change_race(RACE_VAMPIRE, "");
472 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
473 p_ptr->redraw |= (PR_EQUIPPY);
474 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
481 * @param item 持ち替えを行いたい装備部位ID
484 void kamaenaoshi(INVENTORY_IDX item)
486 object_type *o_ptr, *new_o_ptr;
487 char o_name[MAX_NLEN];
489 if (item == INVEN_RARM)
491 if (buki_motteruka(INVEN_LARM))
493 o_ptr = &inventory[INVEN_LARM];
494 object_desc(o_name, o_ptr, 0);
496 if (!object_is_cursed(o_ptr))
498 new_o_ptr = &inventory[INVEN_RARM];
499 object_copy(new_o_ptr, o_ptr);
500 p_ptr->total_weight += o_ptr->weight;
501 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
502 inven_item_optimize(INVEN_LARM);
503 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
504 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
506 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
507 (left_hander ? _("左手", "left") : _("右手", "right")));
511 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
512 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
516 else if (item == INVEN_LARM)
518 o_ptr = &inventory[INVEN_RARM];
519 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
521 if (buki_motteruka(INVEN_RARM))
523 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
524 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
526 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
528 new_o_ptr = &inventory[INVEN_LARM];
529 object_copy(new_o_ptr, o_ptr);
530 p_ptr->total_weight += o_ptr->weight;
531 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
532 inven_item_optimize(INVEN_RARM);
533 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
540 * @brief 装備を外すコマンドのメインルーチン / Take off an item
543 void do_cmd_takeoff(void)
549 if (p_ptr->special_defense & KATA_MUSOU)
551 set_action(ACTION_NONE);
554 item_tester_no_ryoute = TRUE;
556 q = _("どれを装備からはずしますか? ", "Take off which item? ");
557 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
559 if (!get_item(&item, q, s, (USE_EQUIP))) return;
561 /* Get the item (in the pack) */
564 o_ptr = &inventory[item];
567 /* Get the item (on the floor) */
570 o_ptr = &o_list[0 - item];
575 if (object_is_cursed(o_ptr))
577 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
579 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
584 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
586 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
588 o_ptr->ident |= (IDENT_SENSE);
589 o_ptr->curse_flags = 0L;
590 o_ptr->feeling = FEEL_NONE;
592 p_ptr->update |= (PU_BONUS);
593 p_ptr->window |= (PW_EQUIP);
595 msg_print(_("呪いを打ち破った。", "You break the curse."));
599 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
600 p_ptr->energy_use = 50;
605 /* Take a partial turn */
606 p_ptr->energy_use = 50;
608 /* Take off the item */
609 (void)inven_takeoff(item, 255);
612 p_ptr->redraw |= (PR_EQUIPPY);
617 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
620 void do_cmd_drop(void)
629 if (p_ptr->special_defense & KATA_MUSOU)
631 set_action(ACTION_NONE);
634 item_tester_no_ryoute = TRUE;
635 q = _("どのアイテムを落としますか? ", "Drop which item? ");
636 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
638 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
640 /* Get the item (in the pack) */
643 o_ptr = &inventory[item];
646 /* Get the item (on the floor) */
649 o_ptr = &o_list[0 - item];
653 /* Hack -- Cannot remove cursed items */
654 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
656 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
661 /* See how many items */
662 if (o_ptr->number > 1)
665 amt = get_quantity(NULL, o_ptr->number);
667 /* Allow user abort */
668 if (amt <= 0) return;
672 /* Take a partial turn */
673 p_ptr->energy_use = 50;
675 /* Drop (some of) the item */
676 inven_drop(item, amt);
678 if (item >= INVEN_RARM)
684 p_ptr->redraw |= (PR_EQUIPPY);
688 * @brief オブジェクトが高位の魔法書かどうかを判定する
689 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
690 * @return オブジェクトが高位の魔法書ならばTRUEを返す
692 static bool high_level_book(object_type *o_ptr)
694 if ((o_ptr->tval == TV_LIFE_BOOK) ||
695 (o_ptr->tval == TV_SORCERY_BOOK) ||
696 (o_ptr->tval == TV_NATURE_BOOK) ||
697 (o_ptr->tval == TV_CHAOS_BOOK) ||
698 (o_ptr->tval == TV_DEATH_BOOK) ||
699 (o_ptr->tval == TV_TRUMP_BOOK) ||
700 (o_ptr->tval == TV_CRAFT_BOOK) ||
701 (o_ptr->tval == TV_DAEMON_BOOK) ||
702 (o_ptr->tval == TV_CRUSADE_BOOK) ||
703 (o_ptr->tval == TV_MUSIC_BOOK) ||
704 (o_ptr->tval == TV_HEX_BOOK))
717 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
720 void do_cmd_destroy(void)
730 object_type *q_ptr = &forge;
732 char o_name[MAX_NLEN];
733 char out_val[MAX_NLEN+40];
737 if (p_ptr->special_defense & KATA_MUSOU)
739 set_action(ACTION_NONE);
742 /* Hack -- force destruction */
743 if (command_arg > 0) force = TRUE;
745 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
746 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
748 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
750 /* Get the item (in the pack) */
753 o_ptr = &inventory[item];
756 /* Get the item (on the floor) */
759 o_ptr = &o_list[0 - item];
762 /* Verify unless quantity given beforehand */
763 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
765 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
767 /* Make a verification */
768 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
771 /* HACK : Add the line to message buffer */
772 message_add(out_val);
773 p_ptr->window |= (PW_MESSAGE);
776 /* Get an acceptable answer */
786 /* Erase the prompt */
790 if (i == 'y' || i == 'Y')
794 if (i == ESCAPE || i == 'n' || i == 'N')
801 /* Add an auto-destroy preference line */
802 if (autopick_autoregister(o_ptr))
804 /* Auto-destroy it */
805 autopick_alter_item(item, TRUE);
808 /* The object is already destroyed. */
814 /* See how many items */
815 if (o_ptr->number > 1)
818 amt = get_quantity(NULL, o_ptr->number);
820 /* Allow user abort */
821 if (amt <= 0) return;
825 old_number = o_ptr->number;
827 object_desc(o_name, o_ptr, 0);
828 o_ptr->number = old_number;
830 p_ptr->energy_use = 100;
832 /* Artifacts cannot be destroyed */
833 if (!can_player_destroy_object(o_ptr))
835 p_ptr->energy_use = 0;
837 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
841 object_copy(q_ptr, o_ptr);
843 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
844 sound(SOUND_DESTITEM);
846 /* Reduce the charges of rods/wands */
847 reduce_charges(o_ptr, amt);
849 /* Eliminate the item (from the pack) */
852 inven_item_increase(item, -amt);
853 inven_item_describe(item);
854 inven_item_optimize(item);
857 /* Eliminate the item (from the floor) */
860 floor_item_increase(0 - item, -amt);
861 floor_item_describe(0 - item);
862 floor_item_optimize(0 - item);
865 if (high_level_book(q_ptr))
867 bool gain_expr = FALSE;
869 if (p_ptr->prace == RACE_ANDROID)
872 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
876 else if (p_ptr->pclass == CLASS_PALADIN)
878 if (is_good_realm(p_ptr->realm1))
880 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
884 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
888 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
890 s32b tester_exp = p_ptr->max_exp / 20;
891 if (tester_exp > 10000) tester_exp = 10000;
892 if (q_ptr->sval < 3) tester_exp /= 4;
893 if (tester_exp<1) tester_exp = 1;
895 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
896 gain_exp(tester_exp * amt);
898 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
900 chg_virtue(V_UNLIFE, 1);
901 chg_virtue(V_VITALITY, -1);
903 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
905 chg_virtue(V_UNLIFE, -1);
906 chg_virtue(V_VITALITY, 1);
909 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
910 chg_virtue(V_ENCHANT, -1);
912 if (object_value_real(q_ptr) > 30000)
913 chg_virtue(V_SACRIFICE, 2);
915 else if (object_value_real(q_ptr) > 10000)
916 chg_virtue(V_SACRIFICE, 1);
919 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
920 chg_virtue(V_HARMONY, 1);
922 if (item >= INVEN_RARM) calc_android_exp();
927 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
930 void do_cmd_observe(void)
934 char o_name[MAX_NLEN];
938 item_tester_no_ryoute = TRUE;
940 q = _("どのアイテムを調べますか? ", "Examine which item? ");
941 s = _("調べられるアイテムがない。", "You have nothing to examine.");
943 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
945 /* Get the item (in the pack) */
948 o_ptr = &inventory[item];
951 /* Get the item (on the floor) */
954 o_ptr = &o_list[0 - item];
958 /* Require full knowledge */
959 if (!(o_ptr->ident & IDENT_MENTAL))
961 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
967 object_desc(o_name, o_ptr, 0);
968 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
969 /* Describe it fully */
970 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
976 * @brief アイテムの銘を消すコマンドのメインルーチン
977 * Remove the inscription from an object XXX Mention item (when done)?
980 void do_cmd_uninscribe(void)
986 item_tester_no_ryoute = TRUE;
987 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
988 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
990 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
992 /* Get the item (in the pack) */
995 o_ptr = &inventory[item];
998 /* Get the item (on the floor) */
1001 o_ptr = &o_list[0 - item];
1004 /* Nothing to remove */
1005 if (!o_ptr->inscription)
1007 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1011 msg_print(_("銘を消した。", "Inscription removed."));
1013 /* Remove the incription */
1014 o_ptr->inscription = 0;
1016 /* Combine the pack */
1017 p_ptr->notice |= (PN_COMBINE);
1019 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1021 /* .や$の関係で, 再計算が必要なはず -- henkma */
1022 p_ptr->update |= (PU_BONUS);
1028 * @brief アイテムの銘を刻むコマンドのメインルーチン
1029 * Inscribe an object with a comment
1032 void do_cmd_inscribe(void)
1036 char o_name[MAX_NLEN];
1040 item_tester_no_ryoute = TRUE;
1041 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1042 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1044 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1046 /* Get the item (in the pack) */
1049 o_ptr = &inventory[item];
1052 /* Get the item (on the floor) */
1055 o_ptr = &o_list[0 - item];
1058 /* Describe the activity */
1059 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1061 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1064 /* Start with nothing */
1065 strcpy(out_val, "");
1067 /* Use old inscription */
1068 if (o_ptr->inscription)
1070 /* Start with the old inscription */
1071 strcpy(out_val, quark_str(o_ptr->inscription));
1074 /* Get a new inscription (possibly empty) */
1075 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1077 /* Save the inscription */
1078 o_ptr->inscription = quark_add(out_val);
1080 /* Combine the pack */
1081 p_ptr->notice |= (PN_COMBINE);
1083 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1085 /* .や$の関係で, 再計算が必要なはず -- henkma */
1086 p_ptr->update |= (PU_BONUS);
1093 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1094 * An "item_tester_hook" for refilling lanterns
1095 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1096 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1098 static bool item_tester_refill_lantern(object_type *o_ptr)
1100 /* Flasks of oil are okay */
1101 if (o_ptr->tval == TV_FLASK) return (TRUE);
1103 /* Laterns are okay */
1104 if ((o_ptr->tval == TV_LITE) &&
1105 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1107 /* Assume not okay */
1113 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1114 * Refill the players lamp (from the pack or floor)
1117 static void do_cmd_refill_lamp(void)
1127 /* Restrict the choices */
1128 item_tester_hook = item_tester_refill_lantern;
1131 q = "どの油つぼから注ぎますか? ";
1134 q = "Refill with which flask? ";
1135 s = "You have no flasks of oil.";
1138 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1140 /* Get the item (in the pack) */
1143 o_ptr = &inventory[item];
1146 /* Get the item (on the floor) */
1149 o_ptr = &o_list[0 - item];
1152 /* Take a partial turn */
1153 p_ptr->energy_use = 50;
1155 /* Access the lantern */
1156 j_ptr = &inventory[INVEN_LITE];
1159 j_ptr->xtra4 += o_ptr->xtra4;
1160 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1162 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1165 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1167 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1170 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1172 else if (j_ptr->xtra4 >= FUEL_LAMP)
1174 j_ptr->xtra4 = FUEL_LAMP;
1175 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1178 /* Decrease the item (from the pack) */
1181 inven_item_increase(item, -1);
1182 inven_item_describe(item);
1183 inven_item_optimize(item);
1186 /* Decrease the item (from the floor) */
1189 floor_item_increase(0 - item, -1);
1190 floor_item_describe(0 - item);
1191 floor_item_optimize(0 - item);
1194 /* Recalculate torch */
1195 p_ptr->update |= (PU_TORCH);
1200 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1201 * An "item_tester_hook" for refilling torches
1202 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1203 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1205 static bool item_tester_refill_torch(object_type *o_ptr)
1207 /* Torches are okay */
1208 if ((o_ptr->tval == TV_LITE) &&
1209 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1211 /* Assume not okay */
1217 * @brief 松明を束ねるコマンドのメインルーチン
1218 * Refuel the players torch (from the pack or floor)
1221 static void do_cmd_refill_torch(void)
1230 /* Restrict the choices */
1231 item_tester_hook = item_tester_refill_torch;
1233 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1234 s = _("他に松明がない。", "You have no extra torches.");
1236 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1238 /* Get the item (in the pack) */
1241 o_ptr = &inventory[item];
1244 /* Get the item (on the floor) */
1247 o_ptr = &o_list[0 - item];
1251 /* Take a partial turn */
1252 p_ptr->energy_use = 50;
1254 /* Access the primary torch */
1255 j_ptr = &inventory[INVEN_LITE];
1258 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1260 msg_print(_("松明を結合した。", "You combine the torches."));
1262 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1265 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1267 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1270 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1272 /* Over-fuel message */
1273 else if (j_ptr->xtra4 >= FUEL_TORCH)
1275 j_ptr->xtra4 = FUEL_TORCH;
1276 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1279 /* Refuel message */
1282 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1285 /* Decrease the item (from the pack) */
1288 inven_item_increase(item, -1);
1289 inven_item_describe(item);
1290 inven_item_optimize(item);
1293 /* Decrease the item (from the floor) */
1296 floor_item_increase(0 - item, -1);
1297 floor_item_describe(0 - item);
1298 floor_item_optimize(0 - item);
1301 /* Recalculate torch */
1302 p_ptr->update |= (PU_TORCH);
1307 * @brief 燃料を補充するコマンドのメインルーチン
1308 * Refill the players lamp, or restock his torches
1311 void do_cmd_refill(void)
1316 o_ptr = &inventory[INVEN_LITE];
1318 if (p_ptr->special_defense & KATA_MUSOU)
1320 set_action(ACTION_NONE);
1324 if (o_ptr->tval != TV_LITE)
1326 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1330 else if (o_ptr->sval == SV_LITE_LANTERN)
1332 do_cmd_refill_lamp();
1336 else if (o_ptr->sval == SV_LITE_TORCH)
1338 do_cmd_refill_torch();
1341 /* No torch to refill */
1344 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1350 * @brief ターゲットを設定するコマンドのメインルーチン
1354 void do_cmd_target(void)
1357 if (target_set(TARGET_KILL))
1359 msg_print(_("ターゲット決定。", "Target Selected."));
1362 /* Target aborted */
1365 msg_print(_("ターゲット解除。", "Target Aborted."));
1372 * @brief 周囲を見渡すコマンドのメインルーチン
1376 void do_cmd_look(void)
1378 p_ptr->window |= PW_MONSTER_LIST;
1382 if (target_set(TARGET_LOOK))
1384 msg_print(_("ターゲット決定。", "Target Selected."));
1390 * @brief 位置を確認するコマンドのメインルーチン
1391 * Allow the player to examine other sectors on the map
1394 void do_cmd_locate(void)
1396 int dir, y1, x1, y2, x2;
1404 get_screen_size(&wid, &hgt);
1407 /* Start at current panel */
1408 y2 = y1 = panel_row_min;
1409 x2 = x1 = panel_col_min;
1411 /* Show panels until done */
1414 /* Describe the location */
1415 if ((y2 == y1) && (x2 == x1))
1418 strcpy(tmp_val, "真上");
1427 sprintf(tmp_val, "%s%s",
1428 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1429 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1431 sprintf(tmp_val, "%s%s of",
1432 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1433 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1438 /* Prepare to ask which way to look */
1439 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1440 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1441 y2 / (hgt / 2), y2 % (hgt / 2),
1442 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1444 /* Assume no direction */
1447 /* Get a direction */
1452 /* Get a command (or Cancel) */
1453 if (!get_com(out_val, &command, TRUE)) break;
1455 /* Extract the action (if any) */
1456 dir = get_keymap_dir(command);
1465 /* Apply the motion */
1466 if (change_panel(ddy[dir], ddx[dir]))
1474 /* Recenter the map around the player */
1477 p_ptr->update |= (PU_MONSTERS);
1479 p_ptr->redraw |= (PR_MAP);
1481 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1488 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1489 * Sorting hook -- Comp function -- see below
1490 * @param u モンスター種族情報の入れるポインタ
1492 * @param a 比較するモンスター種族のID1
1493 * @param b 比較するモンスター種族のID2
1494 * @return 2の方が大きければTRUEを返す
1495 * We use "u" to point to array of monster indexes,
1496 * and "v" to select the type of sorting to perform on "u".
1498 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1500 u16b *who = (u16b*)(u);
1502 u16b *why = (u16b*)(v);
1509 /* Sort by player kills */
1512 /* Extract player kills */
1513 z1 = r_info[w1].r_pkills;
1514 z2 = r_info[w2].r_pkills;
1516 /* Compare player kills */
1517 if (z1 < z2) return (TRUE);
1518 if (z1 > z2) return (FALSE);
1522 /* Sort by total kills */
1525 /* Extract total kills */
1526 z1 = r_info[w1].r_tkills;
1527 z2 = r_info[w2].r_tkills;
1529 /* Compare total kills */
1530 if (z1 < z2) return (TRUE);
1531 if (z1 > z2) return (FALSE);
1535 /* Sort by monster level */
1538 /* Extract levels */
1539 z1 = r_info[w1].level;
1540 z2 = r_info[w2].level;
1542 /* Compare levels */
1543 if (z1 < z2) return (TRUE);
1544 if (z1 > z2) return (FALSE);
1548 /* Sort by monster experience */
1551 /* Extract experience */
1552 z1 = r_info[w1].mexp;
1553 z2 = r_info[w2].mexp;
1555 /* Compare experience */
1556 if (z1 < z2) return (TRUE);
1557 if (z1 > z2) return (FALSE);
1561 /* Compare indexes */
1567 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1568 * Sorting hook -- Swap function -- see below
1569 * @param u モンスター種族情報の入れるポインタ
1571 * @param a スワップするモンスター種族のID1
1572 * @param b スワップするモンスター種族のID2
1575 * We use "u" to point to array of monster indexes,
1576 * and "v" to select the type of sorting to perform.
1578 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1580 u16b *who = (u16b*)(u);
1596 * @brief モンスターの思い出を見るコマンドのメインルーチン
1597 * Identify a character, allow recall of monsters
1601 * Several "special" responses recall "multiple" monsters:
1603 * ^U (all unique monsters)
1604 * ^N (all non-unique monsters)
1606 * The responses may be sorted in several ways, see below.
1608 * Note that the player ghosts are ignored.
1611 void do_cmd_query_symbol(void)
1625 bool recall = FALSE;
1630 /* Get a character, or abort */
1631 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1632 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1634 /* Find that character info, and describe it */
1635 for (i = 0; ident_info[i]; ++i)
1637 if (sym == ident_info[i][0]) break;
1639 if (sym == KTRL('A'))
1642 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1644 else if (sym == KTRL('U'))
1647 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1649 else if (sym == KTRL('N'))
1652 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1654 else if (sym == KTRL('R'))
1657 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1659 /* XTRA HACK WHATSEARCH */
1660 else if (sym == KTRL('M'))
1663 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1668 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1670 else if (ident_info[i])
1672 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1676 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1679 /* Display the result */
1682 /* Allocate the "who" array */
1683 C_MAKE(who, max_r_idx, IDX);
1685 /* Collect matching monsters */
1686 for (n = 0, i = 1; i < max_r_idx; i++)
1688 monster_race *r_ptr = &r_info[i];
1690 /* Nothing to recall */
1691 if (!cheat_know && !r_ptr->r_sights) continue;
1693 /* Require non-unique monsters if needed */
1694 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1696 /* Require unique monsters if needed */
1697 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1699 /* Require ridable monsters if needed */
1700 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1702 /* XTRA HACK WHATSEARCH */
1708 for (xx = 0; temp[xx] && xx < 80; xx++)
1711 if (iskanji(temp[xx])) { xx++; continue; }
1713 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1717 strcpy(temp2, r_name + r_ptr->E_name);
1719 strcpy(temp2, r_name + r_ptr->name);
1721 for (xx = 0; temp2[xx] && xx < 80; xx++)
1722 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1725 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1727 if (my_strstr(temp2, temp))
1732 /* Collect "appropriate" monsters */
1733 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1736 /* Nothing to recall */
1739 /* Free the "who" array */
1740 C_KILL(who, max_r_idx, IDX);
1746 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1756 /* Select the sort method */
1757 ang_sort_comp = ang_sort_comp_hook;
1758 ang_sort_swap = ang_sort_swap_hook;
1760 /* Sort the array */
1761 ang_sort(who, &why, n);
1763 /* Sort by kills (and level) */
1770 /* Catch "escape" */
1773 /* Free the "who" array */
1774 C_KILL(who, max_r_idx, IDX);
1779 /* Sort if needed */
1782 /* Select the sort method */
1783 ang_sort_comp = ang_sort_comp_hook;
1784 ang_sort_swap = ang_sort_swap_hook;
1786 /* Sort the array */
1787 ang_sort(who, &why, n);
1791 /* Start at the end */
1794 /* Scan the monster memory */
1797 /* Extract a race */
1800 /* Hack -- Auto-recall */
1801 monster_race_track(r_idx);
1812 /* Recall on screen */
1813 screen_roff(who[i], 0);
1816 /* Hack -- Begin the prompt */
1819 /* Hack -- Complete the prompt */
1820 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1832 /* Normal commands */
1833 if (query != 'r') break;
1840 if (query == ESCAPE) break;
1842 /* Move to "prev" monster */
1848 if (!expand_list) break;
1852 /* Move to "next" monster */
1858 if (!expand_list) break;
1863 /* Free the "who" array */
1864 C_KILL(who, max_r_idx, IDX);
1866 /* Re-display the identity */
1871 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1875 * XXX - Add actions for other item types
1877 void do_cmd_use(void)
1883 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1885 set_action(ACTION_NONE);
1888 item_tester_no_ryoute = TRUE;
1889 item_tester_hook = item_tester_hook_use;
1891 q = _("どれを使いますか?", "Use which item? ");
1892 s = _("使えるものがありません。", "You have nothing to use.");
1894 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1896 /* Get the item (in the pack) */
1899 o_ptr = &inventory[item];
1901 /* Get the item (on the floor) */
1904 o_ptr = &o_list[0 - item];
1907 switch (o_ptr->tval)
1919 do_cmd_eat_food_aux(item);
1926 do_cmd_aim_wand_aux(item);
1933 do_cmd_use_staff_aux(item);
1940 do_cmd_zap_rod_aux(item);
1944 /* Quaff a potion */
1947 do_cmd_quaff_potion_aux(item);
1954 /* Check some conditions */
1957 msg_print(_("目が見えない。", "You can't see anything."));
1962 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
1965 if (p_ptr->confused)
1967 msg_print(_("混乱していて読めない!", "You are too confused!"));
1971 do_cmd_read_scroll_aux(item, TRUE);
1980 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
1984 /* Activate an artifact */
1987 do_cmd_activate_aux(item);