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 "object-hook.h"
28 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
31 void do_cmd_inven(void)
36 /* Note that we are in "inventory" mode */
39 #ifdef ALLOW_EASY_FLOOR
41 /* Note that we are in "inventory" mode */
42 if (easy_floor) command_wrk = (USE_INVEN);
44 #endif /* ALLOW_EASY_FLOOR */
49 /* Hack -- show empty slots */
50 item_tester_full = TRUE;
52 /* Display the inventory */
55 /* Hack -- hide empty slots */
56 item_tester_full = FALSE;
59 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
60 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
61 (long int)((p_ptr->total_weight * 100) / weight_limit()));
63 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
64 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
65 (p_ptr->total_weight * 100) / weight_limit());
72 /* Get a new command */
73 command_new = inkey();
79 /* Process "Escape" */
80 if (command_new == ESCAPE)
85 Term_get_size(&wid, &hgt);
89 command_gap = wid - 30;
92 /* Process normal keys */
95 /* Hack -- Use "display" mode */
102 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
105 void do_cmd_equip(void)
110 /* Note that we are in "equipment" mode */
113 #ifdef ALLOW_EASY_FLOOR
115 /* Note that we are in "equipment" mode */
116 if (easy_floor) command_wrk = (USE_EQUIP);
118 #endif /* ALLOW_EASY_FLOOR */
120 /* Save the screen */
123 /* Hack -- show empty slots */
124 item_tester_full = TRUE;
126 /* Display the equipment */
129 /* Hack -- undo the hack above */
130 item_tester_full = FALSE;
134 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
135 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
136 (long int)((p_ptr->total_weight * 100) / weight_limit()));
138 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
139 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
140 (long int)((p_ptr->total_weight * 100) / weight_limit()));
147 /* Get a new command */
148 command_new = inkey();
150 /* Restore the screen */
154 /* Process "Escape" */
155 if (command_new == ESCAPE)
160 Term_get_size(&wid, &hgt);
164 command_gap = wid - 30;
167 /* Process normal keys */
170 /* Enter "display" mode */
178 bool select_ring_slot = FALSE;
181 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
184 void do_cmd_wield(void)
186 OBJECT_IDX item, slot;
195 char o_name[MAX_NLEN];
199 OBJECT_IDX need_switch_wielding = 0;
201 if (p_ptr->special_defense & KATA_MUSOU)
203 set_action(ACTION_NONE);
206 /* Restrict the choices */
207 item_tester_hook = item_tester_hook_wear;
210 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
211 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
213 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
215 /* Get the item (in the pack) */
218 o_ptr = &inventory[item];
221 /* Get the item (on the floor) */
224 o_ptr = &o_list[0 - item];
229 slot = wield_slot(o_ptr);
233 /* Shields and some misc. items */
238 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
240 /* Restrict the choices */
241 item_tester_hook = item_tester_hook_melee_weapon;
242 item_tester_no_ryoute = TRUE;
244 /* Choose a weapon from the equipment only */
245 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
246 s = _("おっと。", "Oops.");
247 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
248 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
251 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
253 /* Both arms are already used by non-weapon */
254 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
255 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
257 /* Restrict the choices */
258 item_tester_hook = item_tester_hook_mochikae;
261 q = _("どちらの手に装備しますか?", "Equip which hand? ");
262 s = _("おっと。", "Oops.");
263 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
272 /* Asking for dual wielding */
273 if (slot == INVEN_LARM)
275 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
278 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
280 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
283 /* Both arms are already used */
284 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
286 /* Restrict the choices */
287 item_tester_hook = item_tester_hook_mochikae;
290 q = _("どちらの手に装備しますか?", "Equip which hand? ");
291 s = _("おっと。", "Oops.");
293 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
294 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
295 need_switch_wielding = INVEN_RARM;
301 /* Choose a ring slot */
302 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
304 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
308 q = _("どちらの手に装備しますか?", "Equip which hand? ");
310 s = _("おっと。", "Oops.");
312 /* Restrict the choices */
313 select_ring_slot = TRUE;
314 item_tester_no_ryoute = TRUE;
316 if (!get_item(&slot, q, s, (USE_EQUIP)))
318 select_ring_slot = FALSE;
321 select_ring_slot = FALSE;
325 /* Prevent wielding into a cursed slot */
326 if (object_is_cursed(&inventory[slot]))
329 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
333 msg_format("%s%sは呪われているようだ。",
334 describe_use(slot) , o_name );
336 msg_format("The %s you are %s appears to be cursed.",
337 o_name, describe_use(slot));
340 /* Cancel the command */
345 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
346 ((o_ptr->ident & IDENT_SENSE) &&
347 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
349 char dummy[MAX_NLEN+80];
352 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
353 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
355 if (!get_check(dummy)) return;
358 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
360 char dummy[MAX_NLEN+80];
363 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
366 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
368 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
369 sprintf(dummy, "Do you become a vampire?");
372 if (!get_check(dummy)) return;
375 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
377 object_type *slot_o_ptr = &inventory[slot];
378 object_type *switch_o_ptr = &inventory[need_switch_wielding];
379 object_type object_tmp;
380 object_type *otmp_ptr = &object_tmp;
381 char switch_name[MAX_NLEN];
383 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
385 object_copy(otmp_ptr, switch_o_ptr);
386 object_copy(switch_o_ptr, slot_o_ptr);
387 object_copy(slot_o_ptr, otmp_ptr);
389 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
390 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
391 (left_hander ? _("右手", "right") : _("左手", "left")));
392 slot = need_switch_wielding;
395 check_find_art_quest_completion(o_ptr);
397 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
399 identify_item(o_ptr);
401 /* Auto-inscription */
402 autopick_alter_item(item, FALSE);
406 p_ptr->energy_use = 100;
408 /* Get local object */
411 /* Obtain local object */
412 object_copy(q_ptr, o_ptr);
414 /* Modify quantity */
417 /* Decrease the item (from the pack) */
420 inven_item_increase(item, -1);
421 inven_item_optimize(item);
424 /* Decrease the item (from the floor) */
427 floor_item_increase(0 - item, -1);
428 floor_item_optimize(0 - item);
431 /* Access the wield slot */
432 o_ptr = &inventory[slot];
434 /* Take off existing item */
437 /* Take off existing item */
438 (void)inven_takeoff(slot, 255);
441 /* Wear the new stuff */
442 object_copy(o_ptr, q_ptr);
444 /* Player touches it */
445 o_ptr->marked |= OM_TOUCHED;
447 /* Increase the weight */
448 p_ptr->total_weight += q_ptr->weight;
450 /* Increment the equip counter by hand */
454 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
455 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
456 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
458 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
459 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
460 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
463 /* Where is the item now */
467 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
468 act = STR_WIELD_ARMS;
470 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
474 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
475 act = STR_WIELD_ARMS;
477 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
481 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
485 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
489 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
493 /* Describe the result */
494 object_desc(o_name, o_ptr, 0);
497 msg_format(act, o_name, index_to_label(slot));
501 if (object_is_cursed(o_ptr))
503 /* Warn the player */
504 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
505 chg_virtue(V_HARMONY, -1);
508 o_ptr->ident |= (IDENT_SENSE);
511 /* The Stone Mask make the player turn into a vampire! */
512 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
514 /* Turn into a vampire */
515 change_race(RACE_VAMPIRE, "");
518 /* Recalculate bonuses */
519 p_ptr->update |= (PU_BONUS);
521 /* Recalculate torch */
522 p_ptr->update |= (PU_TORCH);
524 /* Recalculate mana */
525 p_ptr->update |= (PU_MANA);
527 p_ptr->redraw |= (PR_EQUIPPY);
530 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
537 * @param item 持ち替えを行いたい装備部位ID
540 void kamaenaoshi(int item)
542 object_type *o_ptr, *new_o_ptr;
543 char o_name[MAX_NLEN];
545 if (item == INVEN_RARM)
547 if (buki_motteruka(INVEN_LARM))
549 o_ptr = &inventory[INVEN_LARM];
550 object_desc(o_name, o_ptr, 0);
552 if (!object_is_cursed(o_ptr))
554 new_o_ptr = &inventory[INVEN_RARM];
555 object_copy(new_o_ptr, o_ptr);
556 p_ptr->total_weight += o_ptr->weight;
557 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
558 inven_item_optimize(INVEN_LARM);
559 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
560 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
562 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
563 (left_hander ? _("左手", "left") : _("右手", "right")));
567 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
568 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
572 else if (item == INVEN_LARM)
574 o_ptr = &inventory[INVEN_RARM];
575 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
577 if (buki_motteruka(INVEN_RARM))
579 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
580 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
582 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
584 new_o_ptr = &inventory[INVEN_LARM];
585 object_copy(new_o_ptr, o_ptr);
586 p_ptr->total_weight += o_ptr->weight;
587 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
588 inven_item_optimize(INVEN_RARM);
589 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
596 * @brief 装備を外すコマンドのメインルーチン / Take off an item
599 void do_cmd_takeoff(void)
605 if (p_ptr->special_defense & KATA_MUSOU)
607 set_action(ACTION_NONE);
610 item_tester_no_ryoute = TRUE;
613 q = _("どれを装備からはずしますか? ", "Take off which item? ");
614 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
616 if (!get_item(&item, q, s, (USE_EQUIP))) return;
618 /* Get the item (in the pack) */
621 o_ptr = &inventory[item];
624 /* Get the item (on the floor) */
627 o_ptr = &o_list[0 - item];
632 if (object_is_cursed(o_ptr))
634 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
637 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
643 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
645 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
647 /* Hack -- Assume felt */
648 o_ptr->ident |= (IDENT_SENSE);
650 o_ptr->curse_flags = 0L;
653 o_ptr->feeling = FEEL_NONE;
655 /* Recalculate the bonuses */
656 p_ptr->update |= (PU_BONUS);
659 p_ptr->window |= (PW_EQUIP);
661 msg_print(_("呪いを打ち破った。", "You break the curse."));
665 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
666 p_ptr->energy_use = 50;
671 /* Take a partial turn */
672 p_ptr->energy_use = 50;
674 /* Take off the item */
675 (void)inven_takeoff(item, 255);
678 p_ptr->redraw |= (PR_EQUIPPY);
683 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
686 void do_cmd_drop(void)
695 if (p_ptr->special_defense & KATA_MUSOU)
697 set_action(ACTION_NONE);
700 item_tester_no_ryoute = TRUE;
702 q = _("どのアイテムを落としますか? ", "Drop which item? ");
703 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
705 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
707 /* Get the item (in the pack) */
710 o_ptr = &inventory[item];
713 /* Get the item (on the floor) */
716 o_ptr = &o_list[0 - item];
720 /* Hack -- Cannot remove cursed items */
721 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
724 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
730 /* See how many items */
731 if (o_ptr->number > 1)
734 amt = get_quantity(NULL, o_ptr->number);
736 /* Allow user abort */
737 if (amt <= 0) return;
741 /* Take a partial turn */
742 p_ptr->energy_use = 50;
744 /* Drop (some of) the item */
745 inven_drop(item, amt);
747 if (item >= INVEN_RARM)
753 p_ptr->redraw |= (PR_EQUIPPY);
757 * @brief オブジェクトが高位の魔法書かどうかを判定する
758 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
759 * @return オブジェクトが高位の魔法書ならばTRUEを返す
761 static bool high_level_book(object_type *o_ptr)
763 if ((o_ptr->tval == TV_LIFE_BOOK) ||
764 (o_ptr->tval == TV_SORCERY_BOOK) ||
765 (o_ptr->tval == TV_NATURE_BOOK) ||
766 (o_ptr->tval == TV_CHAOS_BOOK) ||
767 (o_ptr->tval == TV_DEATH_BOOK) ||
768 (o_ptr->tval == TV_TRUMP_BOOK) ||
769 (o_ptr->tval == TV_CRAFT_BOOK) ||
770 (o_ptr->tval == TV_DAEMON_BOOK) ||
771 (o_ptr->tval == TV_CRUSADE_BOOK) ||
772 (o_ptr->tval == TV_MUSIC_BOOK) ||
773 (o_ptr->tval == TV_HEX_BOOK))
786 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
789 void do_cmd_destroy(void)
799 object_type *q_ptr = &forge;
801 char o_name[MAX_NLEN];
802 char out_val[MAX_NLEN+40];
806 if (p_ptr->special_defense & KATA_MUSOU)
808 set_action(ACTION_NONE);
811 /* Hack -- force destruction */
812 if (command_arg > 0) force = TRUE;
815 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
816 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
818 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
820 /* Get the item (in the pack) */
823 o_ptr = &inventory[item];
826 /* Get the item (on the floor) */
829 o_ptr = &o_list[0 - item];
832 /* Verify unless quantity given beforehand */
833 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
835 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
837 /* Make a verification */
838 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
841 /* HACK : Add the line to message buffer */
842 message_add(out_val);
843 p_ptr->window |= (PW_MESSAGE);
846 /* Get an acceptable answer */
856 /* Erase the prompt */
860 if (i == 'y' || i == 'Y')
864 if (i == ESCAPE || i == 'n' || i == 'N')
871 /* Add an auto-destroy preference line */
872 if (autopick_autoregister(o_ptr))
874 /* Auto-destroy it */
875 autopick_alter_item(item, TRUE);
878 /* The object is already destroyed. */
884 /* See how many items */
885 if (o_ptr->number > 1)
888 amt = get_quantity(NULL, o_ptr->number);
890 /* Allow user abort */
891 if (amt <= 0) return;
895 /* Describe the object */
896 old_number = o_ptr->number;
898 object_desc(o_name, o_ptr, 0);
899 o_ptr->number = old_number;
902 p_ptr->energy_use = 100;
904 /* Artifacts cannot be destroyed */
905 if (!can_player_destroy_object(o_ptr))
907 p_ptr->energy_use = 0;
910 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
915 object_copy(q_ptr, o_ptr);
918 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
919 sound(SOUND_DESTITEM);
921 /* Reduce the charges of rods/wands */
922 reduce_charges(o_ptr, amt);
924 /* Eliminate the item (from the pack) */
927 inven_item_increase(item, -amt);
928 inven_item_describe(item);
929 inven_item_optimize(item);
932 /* Eliminate the item (from the floor) */
935 floor_item_increase(0 - item, -amt);
936 floor_item_describe(0 - item);
937 floor_item_optimize(0 - item);
940 if (high_level_book(q_ptr))
942 bool gain_expr = FALSE;
944 if (p_ptr->prace == RACE_ANDROID)
947 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
951 else if (p_ptr->pclass == CLASS_PALADIN)
953 if (is_good_realm(p_ptr->realm1))
955 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
959 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
963 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
965 s32b tester_exp = p_ptr->max_exp / 20;
966 if (tester_exp > 10000) tester_exp = 10000;
967 if (q_ptr->sval < 3) tester_exp /= 4;
968 if (tester_exp<1) tester_exp = 1;
970 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
971 gain_exp(tester_exp * amt);
973 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
975 chg_virtue(V_UNLIFE, 1);
976 chg_virtue(V_VITALITY, -1);
978 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
980 chg_virtue(V_UNLIFE, -1);
981 chg_virtue(V_VITALITY, 1);
984 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
985 chg_virtue(V_ENCHANT, -1);
987 if (object_value_real(q_ptr) > 30000)
988 chg_virtue(V_SACRIFICE, 2);
990 else if (object_value_real(q_ptr) > 10000)
991 chg_virtue(V_SACRIFICE, 1);
994 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
995 chg_virtue(V_HARMONY, 1);
997 if (item >= INVEN_RARM) calc_android_exp();
1002 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
1005 void do_cmd_observe(void)
1009 char o_name[MAX_NLEN];
1013 item_tester_no_ryoute = TRUE;
1016 q = _("どのアイテムを調べますか? ", "Examine which item? ");
1017 s = _("調べられるアイテムがない。", "You have nothing to examine.");
1019 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1021 /* Get the item (in the pack) */
1024 o_ptr = &inventory[item];
1027 /* Get the item (on the floor) */
1030 o_ptr = &o_list[0 - item];
1034 /* Require full knowledge */
1035 if (!(o_ptr->ident & IDENT_MENTAL))
1037 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1043 object_desc(o_name, o_ptr, 0);
1046 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1047 /* Describe it fully */
1048 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1054 * @brief アイテムの銘を消すコマンドのメインルーチン
1055 * Remove the inscription from an object XXX Mention item (when done)?
1058 void do_cmd_uninscribe(void)
1064 item_tester_no_ryoute = TRUE;
1066 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1067 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1069 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1071 /* Get the item (in the pack) */
1074 o_ptr = &inventory[item];
1077 /* Get the item (on the floor) */
1080 o_ptr = &o_list[0 - item];
1083 /* Nothing to remove */
1084 if (!o_ptr->inscription)
1086 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1091 msg_print(_("銘を消した。", "Inscription removed."));
1093 /* Remove the incription */
1094 o_ptr->inscription = 0;
1096 /* Combine the pack */
1097 p_ptr->notice |= (PN_COMBINE);
1100 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1102 /* .や$の関係で, 再計算が必要なはず -- henkma */
1103 p_ptr->update |= (PU_BONUS);
1109 * @brief アイテムの銘を刻むコマンドのメインルーチン
1110 * Inscribe an object with a comment
1113 void do_cmd_inscribe(void)
1117 char o_name[MAX_NLEN];
1121 item_tester_no_ryoute = TRUE;
1123 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1124 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1126 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1128 /* Get the item (in the pack) */
1131 o_ptr = &inventory[item];
1134 /* Get the item (on the floor) */
1137 o_ptr = &o_list[0 - item];
1140 /* Describe the activity */
1141 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1144 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1147 /* Start with nothing */
1148 strcpy(out_val, "");
1150 /* Use old inscription */
1151 if (o_ptr->inscription)
1153 /* Start with the old inscription */
1154 strcpy(out_val, quark_str(o_ptr->inscription));
1157 /* Get a new inscription (possibly empty) */
1158 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1160 /* Save the inscription */
1161 o_ptr->inscription = quark_add(out_val);
1163 /* Combine the pack */
1164 p_ptr->notice |= (PN_COMBINE);
1167 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1169 /* .や$の関係で, 再計算が必要なはず -- henkma */
1170 p_ptr->update |= (PU_BONUS);
1177 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1178 * An "item_tester_hook" for refilling lanterns
1179 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1180 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1182 static bool item_tester_refill_lantern(object_type *o_ptr)
1184 /* Flasks of oil are okay */
1185 if (o_ptr->tval == TV_FLASK) return (TRUE);
1187 /* Laterns are okay */
1188 if ((o_ptr->tval == TV_LITE) &&
1189 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1191 /* Assume not okay */
1197 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1198 * Refill the players lamp (from the pack or floor)
1201 static void do_cmd_refill_lamp(void)
1211 /* Restrict the choices */
1212 item_tester_hook = item_tester_refill_lantern;
1216 q = "どの油つぼから注ぎますか? ";
1219 q = "Refill with which flask? ";
1220 s = "You have no flasks of oil.";
1223 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1225 /* Get the item (in the pack) */
1228 o_ptr = &inventory[item];
1231 /* Get the item (on the floor) */
1234 o_ptr = &o_list[0 - item];
1238 /* Take a partial turn */
1239 p_ptr->energy_use = 50;
1241 /* Access the lantern */
1242 j_ptr = &inventory[INVEN_LITE];
1245 j_ptr->xtra4 += o_ptr->xtra4;
1248 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1251 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1254 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1256 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1259 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1261 else if (j_ptr->xtra4 >= FUEL_LAMP)
1263 j_ptr->xtra4 = FUEL_LAMP;
1264 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1267 /* Decrease the item (from the pack) */
1270 inven_item_increase(item, -1);
1271 inven_item_describe(item);
1272 inven_item_optimize(item);
1275 /* Decrease the item (from the floor) */
1278 floor_item_increase(0 - item, -1);
1279 floor_item_describe(0 - item);
1280 floor_item_optimize(0 - item);
1283 /* Recalculate torch */
1284 p_ptr->update |= (PU_TORCH);
1289 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1290 * An "item_tester_hook" for refilling torches
1291 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1292 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1294 static bool item_tester_refill_torch(object_type *o_ptr)
1296 /* Torches are okay */
1297 if ((o_ptr->tval == TV_LITE) &&
1298 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1300 /* Assume not okay */
1306 * @brief 松明を束ねるコマンドのメインルーチン
1307 * Refuel the players torch (from the pack or floor)
1310 static void do_cmd_refill_torch(void)
1320 /* Restrict the choices */
1321 item_tester_hook = item_tester_refill_torch;
1325 q = "どの松明で明かりを強めますか? ";
1328 q = "Refuel with which torch? ";
1329 s = "You have no extra torches.";
1332 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1334 /* Get the item (in the pack) */
1337 o_ptr = &inventory[item];
1340 /* Get the item (on the floor) */
1343 o_ptr = &o_list[0 - item];
1347 /* Take a partial turn */
1348 p_ptr->energy_use = 50;
1350 /* Access the primary torch */
1351 j_ptr = &inventory[INVEN_LITE];
1354 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1357 msg_print(_("松明を結合した。", "You combine the torches."));
1360 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1363 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1365 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1368 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1370 /* Over-fuel message */
1371 else if (j_ptr->xtra4 >= FUEL_TORCH)
1373 j_ptr->xtra4 = FUEL_TORCH;
1374 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1377 /* Refuel message */
1380 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1383 /* Decrease the item (from the pack) */
1386 inven_item_increase(item, -1);
1387 inven_item_describe(item);
1388 inven_item_optimize(item);
1391 /* Decrease the item (from the floor) */
1394 floor_item_increase(0 - item, -1);
1395 floor_item_describe(0 - item);
1396 floor_item_optimize(0 - item);
1399 /* Recalculate torch */
1400 p_ptr->update |= (PU_TORCH);
1405 * @brief 燃料を補充するコマンドのメインルーチン
1406 * Refill the players lamp, or restock his torches
1409 void do_cmd_refill(void)
1414 o_ptr = &inventory[INVEN_LITE];
1416 if (p_ptr->special_defense & KATA_MUSOU)
1418 set_action(ACTION_NONE);
1422 if (o_ptr->tval != TV_LITE)
1424 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1428 else if (o_ptr->sval == SV_LITE_LANTERN)
1430 do_cmd_refill_lamp();
1434 else if (o_ptr->sval == SV_LITE_TORCH)
1436 do_cmd_refill_torch();
1439 /* No torch to refill */
1442 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1448 * @brief ターゲットを設定するコマンドのメインルーチン
1452 void do_cmd_target(void)
1455 if (target_set(TARGET_KILL))
1457 msg_print(_("ターゲット決定。", "Target Selected."));
1460 /* Target aborted */
1463 msg_print(_("ターゲット解除。", "Target Aborted."));
1470 * @brief 周囲を見渡すコマンドのメインルーチン
1474 void do_cmd_look(void)
1477 p_ptr->window |= PW_MONSTER_LIST;
1482 if (target_set(TARGET_LOOK))
1484 msg_print(_("ターゲット決定。", "Target Selected."));
1490 * @brief 位置を確認するコマンドのメインルーチン
1491 * Allow the player to examine other sectors on the map
1494 void do_cmd_locate(void)
1496 int dir, y1, x1, y2, x2;
1505 get_screen_size(&wid, &hgt);
1508 /* Start at current panel */
1509 y2 = y1 = panel_row_min;
1510 x2 = x1 = panel_col_min;
1512 /* Show panels until done */
1515 /* Describe the location */
1516 if ((y2 == y1) && (x2 == x1))
1519 strcpy(tmp_val, "真上");
1528 sprintf(tmp_val, "%s%s",
1529 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1530 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1532 sprintf(tmp_val, "%s%s of",
1533 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1534 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1539 /* Prepare to ask which way to look */
1540 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1541 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1542 y2 / (hgt / 2), y2 % (hgt / 2),
1543 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1545 /* Assume no direction */
1548 /* Get a direction */
1553 /* Get a command (or Cancel) */
1554 if (!get_com(out_val, &command, TRUE)) break;
1556 /* Extract the action (if any) */
1557 dir = get_keymap_dir(command);
1566 /* Apply the motion */
1567 if (change_panel(ddy[dir], ddx[dir]))
1575 /* Recenter the map around the player */
1579 p_ptr->update |= (PU_MONSTERS);
1582 p_ptr->redraw |= (PR_MAP);
1585 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1594 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1595 * Sorting hook -- Comp function -- see below
1596 * @param u モンスター種族情報の入れるポインタ
1598 * @param a 比較するモンスター種族のID1
1599 * @param b 比較するモンスター種族のID2
1600 * @return 2の方が大きければTRUEを返す
1601 * We use "u" to point to array of monster indexes,
1602 * and "v" to select the type of sorting to perform on "u".
1604 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1606 u16b *who = (u16b*)(u);
1608 u16b *why = (u16b*)(v);
1615 /* Sort by player kills */
1618 /* Extract player kills */
1619 z1 = r_info[w1].r_pkills;
1620 z2 = r_info[w2].r_pkills;
1622 /* Compare player kills */
1623 if (z1 < z2) return (TRUE);
1624 if (z1 > z2) return (FALSE);
1628 /* Sort by total kills */
1631 /* Extract total kills */
1632 z1 = r_info[w1].r_tkills;
1633 z2 = r_info[w2].r_tkills;
1635 /* Compare total kills */
1636 if (z1 < z2) return (TRUE);
1637 if (z1 > z2) return (FALSE);
1641 /* Sort by monster level */
1644 /* Extract levels */
1645 z1 = r_info[w1].level;
1646 z2 = r_info[w2].level;
1648 /* Compare levels */
1649 if (z1 < z2) return (TRUE);
1650 if (z1 > z2) return (FALSE);
1654 /* Sort by monster experience */
1657 /* Extract experience */
1658 z1 = r_info[w1].mexp;
1659 z2 = r_info[w2].mexp;
1661 /* Compare experience */
1662 if (z1 < z2) return (TRUE);
1663 if (z1 > z2) return (FALSE);
1667 /* Compare indexes */
1673 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1674 * Sorting hook -- Swap function -- see below
1675 * @param u モンスター種族情報の入れるポインタ
1677 * @param a スワップするモンスター種族のID1
1678 * @param b スワップするモンスター種族のID2
1681 * We use "u" to point to array of monster indexes,
1682 * and "v" to select the type of sorting to perform.
1684 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1686 u16b *who = (u16b*)(u);
1702 * @brief モンスターの思い出を見るコマンドのメインルーチン
1703 * Identify a character, allow recall of monsters
1707 * Several "special" responses recall "multiple" monsters:
1709 * ^U (all unique monsters)
1710 * ^N (all non-unique monsters)
1712 * The responses may be sorted in several ways, see below.
1714 * Note that the player ghosts are ignored. XXX XXX XXX
1717 void do_cmd_query_symbol(void)
1731 bool recall = FALSE;
1736 /* Get a character, or abort */
1737 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1738 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1740 /* Find that character info, and describe it */
1741 for (i = 0; ident_info[i]; ++i)
1743 if (sym == ident_info[i][0]) break;
1747 if (sym == KTRL('A'))
1750 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1752 else if (sym == KTRL('U'))
1755 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1757 else if (sym == KTRL('N'))
1760 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1762 else if (sym == KTRL('R'))
1765 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1767 /* XTRA HACK WHATSEARCH */
1768 else if (sym == KTRL('M'))
1771 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1776 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1778 else if (ident_info[i])
1780 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1784 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1787 /* Display the result */
1790 /* Allocate the "who" array */
1791 C_MAKE(who, max_r_idx, IDX);
1793 /* Collect matching monsters */
1794 for (n = 0, i = 1; i < max_r_idx; i++)
1796 monster_race *r_ptr = &r_info[i];
1798 /* Nothing to recall */
1799 if (!cheat_know && !r_ptr->r_sights) continue;
1801 /* Require non-unique monsters if needed */
1802 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1804 /* Require unique monsters if needed */
1805 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1807 /* Require ridable monsters if needed */
1808 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1810 /* XTRA HACK WHATSEARCH */
1816 for (xx=0; temp[xx] && xx<80; xx++)
1819 if (iskanji( temp[xx])) { xx++; continue; }
1821 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1825 strcpy(temp2, r_name+r_ptr->E_name);
1827 strcpy(temp2, r_name+r_ptr->name);
1829 for (xx=0; temp2[xx] && xx<80; xx++)
1830 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1833 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) )
1835 if (my_strstr(temp2, temp))
1840 /* Collect "appropriate" monsters */
1841 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1844 /* Nothing to recall */
1847 /* Free the "who" array */
1848 C_KILL(who, max_r_idx, IDX);
1854 /* Prompt XXX XXX XXX */
1855 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1866 /* Select the sort method */
1867 ang_sort_comp = ang_sort_comp_hook;
1868 ang_sort_swap = ang_sort_swap_hook;
1870 /* Sort the array */
1871 ang_sort(who, &why, n);
1873 /* Sort by kills (and level) */
1880 /* Catch "escape" */
1883 /* Free the "who" array */
1884 C_KILL(who, max_r_idx, IDX);
1889 /* Sort if needed */
1892 /* Select the sort method */
1893 ang_sort_comp = ang_sort_comp_hook;
1894 ang_sort_swap = ang_sort_swap_hook;
1896 /* Sort the array */
1897 ang_sort(who, &why, n);
1901 /* Start at the end */
1904 /* Scan the monster memory */
1907 /* Extract a race */
1910 /* Hack -- Auto-recall */
1911 monster_race_track(r_idx);
1913 /* Hack -- Handle stuff */
1922 /* Save the screen */
1925 /* Recall on screen */
1926 screen_roff(who[i], 0);
1929 /* Hack -- Begin the prompt */
1932 /* Hack -- Complete the prompt */
1933 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1945 /* Normal commands */
1946 if (query != 'r') break;
1953 if (query == ESCAPE) break;
1955 /* Move to "prev" monster */
1961 if (!expand_list) break;
1965 /* Move to "next" monster */
1971 if (!expand_list) break;
1976 /* Free the "who" array */
1977 C_KILL(who, max_r_idx, IDX);
1979 /* Re-display the identity */
1984 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1988 * XXX - Add actions for other item types
1990 void do_cmd_use(void)
1996 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1998 set_action(ACTION_NONE);
2001 item_tester_no_ryoute = TRUE;
2002 /* Prepare the hook */
2003 item_tester_hook = item_tester_hook_use;
2006 q = _("どれを使いますか?", "Use which item? ");
2007 s = _("使えるものがありません。", "You have nothing to use.");
2009 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
2011 /* Get the item (in the pack) */
2014 o_ptr = &inventory[item];
2016 /* Get the item (on the floor) */
2019 o_ptr = &o_list[0 - item];
2022 switch (o_ptr->tval)
2034 do_cmd_eat_food_aux(item);
2041 do_cmd_aim_wand_aux(item);
2048 do_cmd_use_staff_aux(item);
2055 do_cmd_zap_rod_aux(item);
2059 /* Quaff a potion */
2062 do_cmd_quaff_potion_aux(item);
2069 /* Check some conditions */
2072 msg_print(_("目が見えない。", "You can't see anything."));
2077 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2080 if (p_ptr->confused)
2082 msg_print(_("混乱していて読めない!", "You are too confused!"));
2086 do_cmd_read_scroll_aux(item, TRUE);
2095 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2099 /* Activate an artifact */
2102 do_cmd_activate_aux(item);