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));
332 msg_format("%s%sは呪われているようだ。",
333 describe_use(slot) , o_name );
335 msg_format("The %s you are %s appears to be cursed.",
336 o_name, describe_use(slot));
339 /* Cancel the command */
344 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
345 ((o_ptr->ident & IDENT_SENSE) &&
346 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
348 char dummy[MAX_NLEN+80];
351 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
352 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
354 if (!get_check(dummy)) return;
357 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
359 char dummy[MAX_NLEN+80];
362 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
365 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
367 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
368 sprintf(dummy, "Do you become a vampire?");
371 if (!get_check(dummy)) return;
374 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
376 object_type *slot_o_ptr = &inventory[slot];
377 object_type *switch_o_ptr = &inventory[need_switch_wielding];
378 object_type object_tmp;
379 object_type *otmp_ptr = &object_tmp;
380 char switch_name[MAX_NLEN];
382 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
384 object_copy(otmp_ptr, switch_o_ptr);
385 object_copy(switch_o_ptr, slot_o_ptr);
386 object_copy(slot_o_ptr, otmp_ptr);
388 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
389 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
390 (left_hander ? _("右手", "right") : _("左手", "left")));
391 slot = need_switch_wielding;
394 check_find_art_quest_completion(o_ptr);
396 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
398 identify_item(o_ptr);
400 /* Auto-inscription */
401 autopick_alter_item(item, FALSE);
404 p_ptr->energy_use = 100;
406 /* Get local object */
409 /* Obtain local object */
410 object_copy(q_ptr, o_ptr);
412 /* Modify quantity */
415 /* Decrease the item (from the pack) */
418 inven_item_increase(item, -1);
419 inven_item_optimize(item);
422 /* Decrease the item (from the floor) */
425 floor_item_increase(0 - item, -1);
426 floor_item_optimize(0 - item);
429 /* Access the wield slot */
430 o_ptr = &inventory[slot];
432 /* Take off existing item */
435 /* Take off existing item */
436 (void)inven_takeoff(slot, 255);
439 /* Wear the new stuff */
440 object_copy(o_ptr, q_ptr);
442 /* Player touches it */
443 o_ptr->marked |= OM_TOUCHED;
445 /* Increase the weight */
446 p_ptr->total_weight += q_ptr->weight;
448 /* Increment the equip counter by hand */
452 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
453 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
454 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
456 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
457 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
458 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
461 /* Where is the item now */
465 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
466 act = STR_WIELD_ARMS;
468 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
472 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
473 act = STR_WIELD_ARMS;
475 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
479 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
483 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
487 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
491 /* Describe the result */
492 object_desc(o_name, o_ptr, 0);
494 msg_format(act, o_name, index_to_label(slot));
498 if (object_is_cursed(o_ptr))
500 /* Warn the player */
501 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
502 chg_virtue(V_HARMONY, -1);
505 o_ptr->ident |= (IDENT_SENSE);
508 /* The Stone Mask make the player turn into a vampire! */
509 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
511 /* Turn into a vampire */
512 change_race(RACE_VAMPIRE, "");
515 /* Recalculate bonuses */
516 p_ptr->update |= (PU_BONUS);
518 /* Recalculate torch */
519 p_ptr->update |= (PU_TORCH);
521 /* Recalculate mana */
522 p_ptr->update |= (PU_MANA);
524 p_ptr->redraw |= (PR_EQUIPPY);
527 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
534 * @param item 持ち替えを行いたい装備部位ID
537 void kamaenaoshi(INVENTORY_IDX item)
539 object_type *o_ptr, *new_o_ptr;
540 char o_name[MAX_NLEN];
542 if (item == INVEN_RARM)
544 if (buki_motteruka(INVEN_LARM))
546 o_ptr = &inventory[INVEN_LARM];
547 object_desc(o_name, o_ptr, 0);
549 if (!object_is_cursed(o_ptr))
551 new_o_ptr = &inventory[INVEN_RARM];
552 object_copy(new_o_ptr, o_ptr);
553 p_ptr->total_weight += o_ptr->weight;
554 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
555 inven_item_optimize(INVEN_LARM);
556 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
557 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
559 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
560 (left_hander ? _("左手", "left") : _("右手", "right")));
564 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
565 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
569 else if (item == INVEN_LARM)
571 o_ptr = &inventory[INVEN_RARM];
572 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
574 if (buki_motteruka(INVEN_RARM))
576 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
577 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
579 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
581 new_o_ptr = &inventory[INVEN_LARM];
582 object_copy(new_o_ptr, o_ptr);
583 p_ptr->total_weight += o_ptr->weight;
584 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
585 inven_item_optimize(INVEN_RARM);
586 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
593 * @brief 装備を外すコマンドのメインルーチン / Take off an item
596 void do_cmd_takeoff(void)
602 if (p_ptr->special_defense & KATA_MUSOU)
604 set_action(ACTION_NONE);
607 item_tester_no_ryoute = TRUE;
610 q = _("どれを装備からはずしますか? ", "Take off which item? ");
611 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
613 if (!get_item(&item, q, s, (USE_EQUIP))) return;
615 /* Get the item (in the pack) */
618 o_ptr = &inventory[item];
621 /* Get the item (on the floor) */
624 o_ptr = &o_list[0 - item];
629 if (object_is_cursed(o_ptr))
631 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
634 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
640 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
642 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
644 /* Hack -- Assume felt */
645 o_ptr->ident |= (IDENT_SENSE);
647 o_ptr->curse_flags = 0L;
650 o_ptr->feeling = FEEL_NONE;
652 /* Recalculate the bonuses */
653 p_ptr->update |= (PU_BONUS);
656 p_ptr->window |= (PW_EQUIP);
658 msg_print(_("呪いを打ち破った。", "You break the curse."));
662 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
663 p_ptr->energy_use = 50;
668 /* Take a partial turn */
669 p_ptr->energy_use = 50;
671 /* Take off the item */
672 (void)inven_takeoff(item, 255);
675 p_ptr->redraw |= (PR_EQUIPPY);
680 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
683 void do_cmd_drop(void)
692 if (p_ptr->special_defense & KATA_MUSOU)
694 set_action(ACTION_NONE);
697 item_tester_no_ryoute = TRUE;
699 q = _("どのアイテムを落としますか? ", "Drop which item? ");
700 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
702 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
704 /* Get the item (in the pack) */
707 o_ptr = &inventory[item];
710 /* Get the item (on the floor) */
713 o_ptr = &o_list[0 - item];
717 /* Hack -- Cannot remove cursed items */
718 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
721 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
727 /* See how many items */
728 if (o_ptr->number > 1)
731 amt = get_quantity(NULL, o_ptr->number);
733 /* Allow user abort */
734 if (amt <= 0) return;
738 /* Take a partial turn */
739 p_ptr->energy_use = 50;
741 /* Drop (some of) the item */
742 inven_drop(item, amt);
744 if (item >= INVEN_RARM)
750 p_ptr->redraw |= (PR_EQUIPPY);
754 * @brief オブジェクトが高位の魔法書かどうかを判定する
755 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
756 * @return オブジェクトが高位の魔法書ならばTRUEを返す
758 static bool high_level_book(object_type *o_ptr)
760 if ((o_ptr->tval == TV_LIFE_BOOK) ||
761 (o_ptr->tval == TV_SORCERY_BOOK) ||
762 (o_ptr->tval == TV_NATURE_BOOK) ||
763 (o_ptr->tval == TV_CHAOS_BOOK) ||
764 (o_ptr->tval == TV_DEATH_BOOK) ||
765 (o_ptr->tval == TV_TRUMP_BOOK) ||
766 (o_ptr->tval == TV_CRAFT_BOOK) ||
767 (o_ptr->tval == TV_DAEMON_BOOK) ||
768 (o_ptr->tval == TV_CRUSADE_BOOK) ||
769 (o_ptr->tval == TV_MUSIC_BOOK) ||
770 (o_ptr->tval == TV_HEX_BOOK))
783 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
786 void do_cmd_destroy(void)
796 object_type *q_ptr = &forge;
798 char o_name[MAX_NLEN];
799 char out_val[MAX_NLEN+40];
803 if (p_ptr->special_defense & KATA_MUSOU)
805 set_action(ACTION_NONE);
808 /* Hack -- force destruction */
809 if (command_arg > 0) force = TRUE;
812 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
813 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
815 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
817 /* Get the item (in the pack) */
820 o_ptr = &inventory[item];
823 /* Get the item (on the floor) */
826 o_ptr = &o_list[0 - item];
829 /* Verify unless quantity given beforehand */
830 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
832 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
834 /* Make a verification */
835 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
838 /* HACK : Add the line to message buffer */
839 message_add(out_val);
840 p_ptr->window |= (PW_MESSAGE);
843 /* Get an acceptable answer */
853 /* Erase the prompt */
857 if (i == 'y' || i == 'Y')
861 if (i == ESCAPE || i == 'n' || i == 'N')
868 /* Add an auto-destroy preference line */
869 if (autopick_autoregister(o_ptr))
871 /* Auto-destroy it */
872 autopick_alter_item(item, TRUE);
875 /* The object is already destroyed. */
881 /* See how many items */
882 if (o_ptr->number > 1)
885 amt = get_quantity(NULL, o_ptr->number);
887 /* Allow user abort */
888 if (amt <= 0) return;
892 /* Describe the object */
893 old_number = o_ptr->number;
895 object_desc(o_name, o_ptr, 0);
896 o_ptr->number = old_number;
898 p_ptr->energy_use = 100;
900 /* Artifacts cannot be destroyed */
901 if (!can_player_destroy_object(o_ptr))
903 p_ptr->energy_use = 0;
905 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
909 object_copy(q_ptr, o_ptr);
911 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
912 sound(SOUND_DESTITEM);
914 /* Reduce the charges of rods/wands */
915 reduce_charges(o_ptr, amt);
917 /* Eliminate the item (from the pack) */
920 inven_item_increase(item, -amt);
921 inven_item_describe(item);
922 inven_item_optimize(item);
925 /* Eliminate the item (from the floor) */
928 floor_item_increase(0 - item, -amt);
929 floor_item_describe(0 - item);
930 floor_item_optimize(0 - item);
933 if (high_level_book(q_ptr))
935 bool gain_expr = FALSE;
937 if (p_ptr->prace == RACE_ANDROID)
940 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
944 else if (p_ptr->pclass == CLASS_PALADIN)
946 if (is_good_realm(p_ptr->realm1))
948 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
952 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
956 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
958 s32b tester_exp = p_ptr->max_exp / 20;
959 if (tester_exp > 10000) tester_exp = 10000;
960 if (q_ptr->sval < 3) tester_exp /= 4;
961 if (tester_exp<1) tester_exp = 1;
963 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
964 gain_exp(tester_exp * amt);
966 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
968 chg_virtue(V_UNLIFE, 1);
969 chg_virtue(V_VITALITY, -1);
971 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
973 chg_virtue(V_UNLIFE, -1);
974 chg_virtue(V_VITALITY, 1);
977 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
978 chg_virtue(V_ENCHANT, -1);
980 if (object_value_real(q_ptr) > 30000)
981 chg_virtue(V_SACRIFICE, 2);
983 else if (object_value_real(q_ptr) > 10000)
984 chg_virtue(V_SACRIFICE, 1);
987 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
988 chg_virtue(V_HARMONY, 1);
990 if (item >= INVEN_RARM) calc_android_exp();
995 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
998 void do_cmd_observe(void)
1002 char o_name[MAX_NLEN];
1006 item_tester_no_ryoute = TRUE;
1009 q = _("どのアイテムを調べますか? ", "Examine which item? ");
1010 s = _("調べられるアイテムがない。", "You have nothing to examine.");
1012 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1014 /* Get the item (in the pack) */
1017 o_ptr = &inventory[item];
1020 /* Get the item (on the floor) */
1023 o_ptr = &o_list[0 - item];
1027 /* Require full knowledge */
1028 if (!(o_ptr->ident & IDENT_MENTAL))
1030 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1036 object_desc(o_name, o_ptr, 0);
1039 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1040 /* Describe it fully */
1041 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1047 * @brief アイテムの銘を消すコマンドのメインルーチン
1048 * Remove the inscription from an object XXX Mention item (when done)?
1051 void do_cmd_uninscribe(void)
1057 item_tester_no_ryoute = TRUE;
1059 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1060 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1062 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1064 /* Get the item (in the pack) */
1067 o_ptr = &inventory[item];
1070 /* Get the item (on the floor) */
1073 o_ptr = &o_list[0 - item];
1076 /* Nothing to remove */
1077 if (!o_ptr->inscription)
1079 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1083 msg_print(_("銘を消した。", "Inscription removed."));
1085 /* Remove the incription */
1086 o_ptr->inscription = 0;
1088 /* Combine the pack */
1089 p_ptr->notice |= (PN_COMBINE);
1092 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1094 /* .や$の関係で, 再計算が必要なはず -- henkma */
1095 p_ptr->update |= (PU_BONUS);
1101 * @brief アイテムの銘を刻むコマンドのメインルーチン
1102 * Inscribe an object with a comment
1105 void do_cmd_inscribe(void)
1109 char o_name[MAX_NLEN];
1113 item_tester_no_ryoute = TRUE;
1115 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1116 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1118 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1120 /* Get the item (in the pack) */
1123 o_ptr = &inventory[item];
1126 /* Get the item (on the floor) */
1129 o_ptr = &o_list[0 - item];
1132 /* Describe the activity */
1133 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1135 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1138 /* Start with nothing */
1139 strcpy(out_val, "");
1141 /* Use old inscription */
1142 if (o_ptr->inscription)
1144 /* Start with the old inscription */
1145 strcpy(out_val, quark_str(o_ptr->inscription));
1148 /* Get a new inscription (possibly empty) */
1149 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1151 /* Save the inscription */
1152 o_ptr->inscription = quark_add(out_val);
1154 /* Combine the pack */
1155 p_ptr->notice |= (PN_COMBINE);
1158 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1160 /* .や$の関係で, 再計算が必要なはず -- henkma */
1161 p_ptr->update |= (PU_BONUS);
1168 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1169 * An "item_tester_hook" for refilling lanterns
1170 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1171 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1173 static bool item_tester_refill_lantern(object_type *o_ptr)
1175 /* Flasks of oil are okay */
1176 if (o_ptr->tval == TV_FLASK) return (TRUE);
1178 /* Laterns are okay */
1179 if ((o_ptr->tval == TV_LITE) &&
1180 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1182 /* Assume not okay */
1188 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1189 * Refill the players lamp (from the pack or floor)
1192 static void do_cmd_refill_lamp(void)
1202 /* Restrict the choices */
1203 item_tester_hook = item_tester_refill_lantern;
1207 q = "どの油つぼから注ぎますか? ";
1210 q = "Refill with which flask? ";
1211 s = "You have no flasks of oil.";
1214 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1216 /* Get the item (in the pack) */
1219 o_ptr = &inventory[item];
1222 /* Get the item (on the floor) */
1225 o_ptr = &o_list[0 - item];
1229 /* Take a partial turn */
1230 p_ptr->energy_use = 50;
1232 /* Access the lantern */
1233 j_ptr = &inventory[INVEN_LITE];
1236 j_ptr->xtra4 += o_ptr->xtra4;
1238 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1241 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1244 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1246 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1249 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1251 else if (j_ptr->xtra4 >= FUEL_LAMP)
1253 j_ptr->xtra4 = FUEL_LAMP;
1254 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1257 /* Decrease the item (from the pack) */
1260 inven_item_increase(item, -1);
1261 inven_item_describe(item);
1262 inven_item_optimize(item);
1265 /* Decrease the item (from the floor) */
1268 floor_item_increase(0 - item, -1);
1269 floor_item_describe(0 - item);
1270 floor_item_optimize(0 - item);
1273 /* Recalculate torch */
1274 p_ptr->update |= (PU_TORCH);
1279 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1280 * An "item_tester_hook" for refilling torches
1281 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1282 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1284 static bool item_tester_refill_torch(object_type *o_ptr)
1286 /* Torches are okay */
1287 if ((o_ptr->tval == TV_LITE) &&
1288 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1290 /* Assume not okay */
1296 * @brief 松明を束ねるコマンドのメインルーチン
1297 * Refuel the players torch (from the pack or floor)
1300 static void do_cmd_refill_torch(void)
1310 /* Restrict the choices */
1311 item_tester_hook = item_tester_refill_torch;
1315 q = "どの松明で明かりを強めますか? ";
1318 q = "Refuel with which torch? ";
1319 s = "You have no extra torches.";
1322 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1324 /* Get the item (in the pack) */
1327 o_ptr = &inventory[item];
1330 /* Get the item (on the floor) */
1333 o_ptr = &o_list[0 - item];
1337 /* Take a partial turn */
1338 p_ptr->energy_use = 50;
1340 /* Access the primary torch */
1341 j_ptr = &inventory[INVEN_LITE];
1344 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1346 msg_print(_("松明を結合した。", "You combine the torches."));
1349 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1352 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1354 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1357 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1359 /* Over-fuel message */
1360 else if (j_ptr->xtra4 >= FUEL_TORCH)
1362 j_ptr->xtra4 = FUEL_TORCH;
1363 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1366 /* Refuel message */
1369 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1372 /* Decrease the item (from the pack) */
1375 inven_item_increase(item, -1);
1376 inven_item_describe(item);
1377 inven_item_optimize(item);
1380 /* Decrease the item (from the floor) */
1383 floor_item_increase(0 - item, -1);
1384 floor_item_describe(0 - item);
1385 floor_item_optimize(0 - item);
1388 /* Recalculate torch */
1389 p_ptr->update |= (PU_TORCH);
1394 * @brief 燃料を補充するコマンドのメインルーチン
1395 * Refill the players lamp, or restock his torches
1398 void do_cmd_refill(void)
1403 o_ptr = &inventory[INVEN_LITE];
1405 if (p_ptr->special_defense & KATA_MUSOU)
1407 set_action(ACTION_NONE);
1411 if (o_ptr->tval != TV_LITE)
1413 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1417 else if (o_ptr->sval == SV_LITE_LANTERN)
1419 do_cmd_refill_lamp();
1423 else if (o_ptr->sval == SV_LITE_TORCH)
1425 do_cmd_refill_torch();
1428 /* No torch to refill */
1431 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1437 * @brief ターゲットを設定するコマンドのメインルーチン
1441 void do_cmd_target(void)
1444 if (target_set(TARGET_KILL))
1446 msg_print(_("ターゲット決定。", "Target Selected."));
1449 /* Target aborted */
1452 msg_print(_("ターゲット解除。", "Target Aborted."));
1459 * @brief 周囲を見渡すコマンドのメインルーチン
1463 void do_cmd_look(void)
1466 p_ptr->window |= PW_MONSTER_LIST;
1471 if (target_set(TARGET_LOOK))
1473 msg_print(_("ターゲット決定。", "Target Selected."));
1479 * @brief 位置を確認するコマンドのメインルーチン
1480 * Allow the player to examine other sectors on the map
1483 void do_cmd_locate(void)
1485 int dir, y1, x1, y2, x2;
1494 get_screen_size(&wid, &hgt);
1497 /* Start at current panel */
1498 y2 = y1 = panel_row_min;
1499 x2 = x1 = panel_col_min;
1501 /* Show panels until done */
1504 /* Describe the location */
1505 if ((y2 == y1) && (x2 == x1))
1508 strcpy(tmp_val, "真上");
1517 sprintf(tmp_val, "%s%s",
1518 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1519 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1521 sprintf(tmp_val, "%s%s of",
1522 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1523 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1528 /* Prepare to ask which way to look */
1529 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1530 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1531 y2 / (hgt / 2), y2 % (hgt / 2),
1532 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1534 /* Assume no direction */
1537 /* Get a direction */
1542 /* Get a command (or Cancel) */
1543 if (!get_com(out_val, &command, TRUE)) break;
1545 /* Extract the action (if any) */
1546 dir = get_keymap_dir(command);
1555 /* Apply the motion */
1556 if (change_panel(ddy[dir], ddx[dir]))
1564 /* Recenter the map around the player */
1568 p_ptr->update |= (PU_MONSTERS);
1571 p_ptr->redraw |= (PR_MAP);
1574 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1583 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1584 * Sorting hook -- Comp function -- see below
1585 * @param u モンスター種族情報の入れるポインタ
1587 * @param a 比較するモンスター種族のID1
1588 * @param b 比較するモンスター種族のID2
1589 * @return 2の方が大きければTRUEを返す
1590 * We use "u" to point to array of monster indexes,
1591 * and "v" to select the type of sorting to perform on "u".
1593 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1595 u16b *who = (u16b*)(u);
1597 u16b *why = (u16b*)(v);
1604 /* Sort by player kills */
1607 /* Extract player kills */
1608 z1 = r_info[w1].r_pkills;
1609 z2 = r_info[w2].r_pkills;
1611 /* Compare player kills */
1612 if (z1 < z2) return (TRUE);
1613 if (z1 > z2) return (FALSE);
1617 /* Sort by total kills */
1620 /* Extract total kills */
1621 z1 = r_info[w1].r_tkills;
1622 z2 = r_info[w2].r_tkills;
1624 /* Compare total kills */
1625 if (z1 < z2) return (TRUE);
1626 if (z1 > z2) return (FALSE);
1630 /* Sort by monster level */
1633 /* Extract levels */
1634 z1 = r_info[w1].level;
1635 z2 = r_info[w2].level;
1637 /* Compare levels */
1638 if (z1 < z2) return (TRUE);
1639 if (z1 > z2) return (FALSE);
1643 /* Sort by monster experience */
1646 /* Extract experience */
1647 z1 = r_info[w1].mexp;
1648 z2 = r_info[w2].mexp;
1650 /* Compare experience */
1651 if (z1 < z2) return (TRUE);
1652 if (z1 > z2) return (FALSE);
1656 /* Compare indexes */
1662 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1663 * Sorting hook -- Swap function -- see below
1664 * @param u モンスター種族情報の入れるポインタ
1666 * @param a スワップするモンスター種族のID1
1667 * @param b スワップするモンスター種族のID2
1670 * We use "u" to point to array of monster indexes,
1671 * and "v" to select the type of sorting to perform.
1673 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1675 u16b *who = (u16b*)(u);
1691 * @brief モンスターの思い出を見るコマンドのメインルーチン
1692 * Identify a character, allow recall of monsters
1696 * Several "special" responses recall "multiple" monsters:
1698 * ^U (all unique monsters)
1699 * ^N (all non-unique monsters)
1701 * The responses may be sorted in several ways, see below.
1703 * Note that the player ghosts are ignored. XXX XXX XXX
1706 void do_cmd_query_symbol(void)
1720 bool recall = FALSE;
1725 /* Get a character, or abort */
1726 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1727 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1729 /* Find that character info, and describe it */
1730 for (i = 0; ident_info[i]; ++i)
1732 if (sym == ident_info[i][0]) break;
1736 if (sym == KTRL('A'))
1739 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1741 else if (sym == KTRL('U'))
1744 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1746 else if (sym == KTRL('N'))
1749 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1751 else if (sym == KTRL('R'))
1754 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1756 /* XTRA HACK WHATSEARCH */
1757 else if (sym == KTRL('M'))
1760 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1765 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1767 else if (ident_info[i])
1769 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1773 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1776 /* Display the result */
1779 /* Allocate the "who" array */
1780 C_MAKE(who, max_r_idx, IDX);
1782 /* Collect matching monsters */
1783 for (n = 0, i = 1; i < max_r_idx; i++)
1785 monster_race *r_ptr = &r_info[i];
1787 /* Nothing to recall */
1788 if (!cheat_know && !r_ptr->r_sights) continue;
1790 /* Require non-unique monsters if needed */
1791 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1793 /* Require unique monsters if needed */
1794 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1796 /* Require ridable monsters if needed */
1797 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1799 /* XTRA HACK WHATSEARCH */
1805 for (xx = 0; temp[xx] && xx < 80; xx++)
1808 if (iskanji(temp[xx])) { xx++; continue; }
1810 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1814 strcpy(temp2, r_name + r_ptr->E_name);
1816 strcpy(temp2, r_name + r_ptr->name);
1818 for (xx = 0; temp2[xx] && xx < 80; xx++)
1819 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1822 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1824 if (my_strstr(temp2, temp))
1829 /* Collect "appropriate" monsters */
1830 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1833 /* Nothing to recall */
1836 /* Free the "who" array */
1837 C_KILL(who, max_r_idx, IDX);
1843 /* Prompt XXX XXX XXX */
1844 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1855 /* Select the sort method */
1856 ang_sort_comp = ang_sort_comp_hook;
1857 ang_sort_swap = ang_sort_swap_hook;
1859 /* Sort the array */
1860 ang_sort(who, &why, n);
1862 /* Sort by kills (and level) */
1869 /* Catch "escape" */
1872 /* Free the "who" array */
1873 C_KILL(who, max_r_idx, IDX);
1878 /* Sort if needed */
1881 /* Select the sort method */
1882 ang_sort_comp = ang_sort_comp_hook;
1883 ang_sort_swap = ang_sort_swap_hook;
1885 /* Sort the array */
1886 ang_sort(who, &why, n);
1890 /* Start at the end */
1893 /* Scan the monster memory */
1896 /* Extract a race */
1899 /* Hack -- Auto-recall */
1900 monster_race_track(r_idx);
1902 /* Hack -- Handle stuff */
1911 /* Save the screen */
1914 /* Recall on screen */
1915 screen_roff(who[i], 0);
1918 /* Hack -- Begin the prompt */
1921 /* Hack -- Complete the prompt */
1922 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1934 /* Normal commands */
1935 if (query != 'r') break;
1942 if (query == ESCAPE) break;
1944 /* Move to "prev" monster */
1950 if (!expand_list) break;
1954 /* Move to "next" monster */
1960 if (!expand_list) break;
1965 /* Free the "who" array */
1966 C_KILL(who, max_r_idx, IDX);
1968 /* Re-display the identity */
1973 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1977 * XXX - Add actions for other item types
1979 void do_cmd_use(void)
1985 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1987 set_action(ACTION_NONE);
1990 item_tester_no_ryoute = TRUE;
1991 /* Prepare the hook */
1992 item_tester_hook = item_tester_hook_use;
1995 q = _("どれを使いますか?", "Use which item? ");
1996 s = _("使えるものがありません。", "You have nothing to use.");
1998 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
2000 /* Get the item (in the pack) */
2003 o_ptr = &inventory[item];
2005 /* Get the item (on the floor) */
2008 o_ptr = &o_list[0 - item];
2011 switch (o_ptr->tval)
2023 do_cmd_eat_food_aux(item);
2030 do_cmd_aim_wand_aux(item);
2037 do_cmd_use_staff_aux(item);
2044 do_cmd_zap_rod_aux(item);
2048 /* Quaff a potion */
2051 do_cmd_quaff_potion_aux(item);
2058 /* Check some conditions */
2061 msg_print(_("目が見えない。", "You can't see anything."));
2066 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2069 if (p_ptr->confused)
2071 msg_print(_("混乱していて読めない!", "You are too confused!"));
2075 do_cmd_read_scroll_aux(item, TRUE);
2084 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2088 /* Activate an artifact */
2091 do_cmd_activate_aux(item);