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();
74 /* Process "Escape" */
75 if (command_new == ESCAPE)
79 Term_get_size(&wid, &hgt);
83 command_gap = wid - 30;
86 /* Process normal keys */
89 /* Hack -- Use "display" mode */
96 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
99 void do_cmd_equip(void)
104 /* Note that we are in "equipment" mode */
107 /* Note that we are in "equipment" mode */
108 if (easy_floor) command_wrk = (USE_EQUIP);
110 /* Save the screen */
113 /* Hack -- show empty slots */
114 item_tester_full = TRUE;
116 /* Display the equipment */
119 /* Hack -- undo the hack above */
120 item_tester_full = FALSE;
124 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
125 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
126 (long int)((p_ptr->total_weight * 100) / weight_limit()));
128 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
129 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
130 (long int)((p_ptr->total_weight * 100) / weight_limit()));
137 /* Get a new command */
138 command_new = inkey();
140 /* Restore the screen */
144 /* Process "Escape" */
145 if (command_new == ESCAPE)
149 Term_get_size(&wid, &hgt);
153 command_gap = wid - 30;
156 /* Process normal keys */
159 /* Enter "display" mode */
167 bool select_ring_slot = FALSE;
170 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
173 void do_cmd_wield(void)
175 OBJECT_IDX item, slot;
184 char o_name[MAX_NLEN];
188 OBJECT_IDX need_switch_wielding = 0;
190 if (p_ptr->special_defense & KATA_MUSOU)
192 set_action(ACTION_NONE);
195 /* Restrict the choices */
196 item_tester_hook = item_tester_hook_wear;
198 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
199 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
201 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
203 /* Get the item (in the pack) */
206 o_ptr = &inventory[item];
209 /* Get the item (on the floor) */
212 o_ptr = &o_list[0 - item];
217 slot = wield_slot(o_ptr);
221 /* Shields and some misc. items */
226 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
228 /* Restrict the choices */
229 item_tester_hook = item_tester_hook_melee_weapon;
230 item_tester_no_ryoute = TRUE;
232 /* Choose a weapon from the equipment only */
233 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
234 s = _("おっと。", "Oops.");
235 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
236 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
239 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
241 /* Both arms are already used by non-weapon */
242 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
243 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
245 /* Restrict the choices */
246 item_tester_hook = item_tester_hook_mochikae;
249 q = _("どちらの手に装備しますか?", "Equip which hand? ");
250 s = _("おっと。", "Oops.");
251 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
260 /* Asking for dual wielding */
261 if (slot == INVEN_LARM)
263 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
266 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
268 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
271 /* Both arms are already used */
272 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
274 /* Restrict the choices */
275 item_tester_hook = item_tester_hook_mochikae;
278 q = _("どちらの手に装備しますか?", "Equip which hand? ");
279 s = _("おっと。", "Oops.");
281 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
282 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
283 need_switch_wielding = INVEN_RARM;
289 /* Choose a ring slot */
290 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
292 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
296 q = _("どちらの手に装備しますか?", "Equip which hand? ");
298 s = _("おっと。", "Oops.");
300 /* Restrict the choices */
301 select_ring_slot = TRUE;
302 item_tester_no_ryoute = TRUE;
304 if (!get_item(&slot, q, s, (USE_EQUIP)))
306 select_ring_slot = FALSE;
309 select_ring_slot = FALSE;
313 /* Prevent wielding into a cursed slot */
314 if (object_is_cursed(&inventory[slot]))
317 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
320 msg_format("%s%sは呪われているようだ。",
321 describe_use(slot) , o_name );
323 msg_format("The %s you are %s appears to be cursed.",
324 o_name, describe_use(slot));
327 /* Cancel the command */
332 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
333 ((o_ptr->ident & IDENT_SENSE) &&
334 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
336 char dummy[MAX_NLEN+80];
339 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
340 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
342 if (!get_check(dummy)) return;
345 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
347 char dummy[MAX_NLEN+80];
350 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
353 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
355 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
356 sprintf(dummy, "Do you become a vampire?");
359 if (!get_check(dummy)) return;
362 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
364 object_type *slot_o_ptr = &inventory[slot];
365 object_type *switch_o_ptr = &inventory[need_switch_wielding];
366 object_type object_tmp;
367 object_type *otmp_ptr = &object_tmp;
368 char switch_name[MAX_NLEN];
370 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
372 object_copy(otmp_ptr, switch_o_ptr);
373 object_copy(switch_o_ptr, slot_o_ptr);
374 object_copy(slot_o_ptr, otmp_ptr);
376 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
377 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
378 (left_hander ? _("右手", "right") : _("左手", "left")));
379 slot = need_switch_wielding;
382 check_find_art_quest_completion(o_ptr);
384 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
386 identify_item(o_ptr);
388 /* Auto-inscription */
389 autopick_alter_item(item, FALSE);
392 p_ptr->energy_use = 100;
394 /* Get local object */
397 /* Obtain local object */
398 object_copy(q_ptr, o_ptr);
400 /* Modify quantity */
403 /* Decrease the item (from the pack) */
406 inven_item_increase(item, -1);
407 inven_item_optimize(item);
410 /* Decrease the item (from the floor) */
413 floor_item_increase(0 - item, -1);
414 floor_item_optimize(0 - item);
417 /* Access the wield slot */
418 o_ptr = &inventory[slot];
420 /* Take off existing item */
423 /* Take off existing item */
424 (void)inven_takeoff(slot, 255);
427 /* Wear the new stuff */
428 object_copy(o_ptr, q_ptr);
430 /* Player touches it */
431 o_ptr->marked |= OM_TOUCHED;
433 /* Increase the weight */
434 p_ptr->total_weight += q_ptr->weight;
436 /* Increment the equip counter by hand */
440 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
441 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
442 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
444 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
445 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
446 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
449 /* Where is the item now */
453 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
454 act = STR_WIELD_ARMS;
456 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
460 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
461 act = STR_WIELD_ARMS;
463 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
467 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
471 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
475 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
479 /* Describe the result */
480 object_desc(o_name, o_ptr, 0);
481 msg_format(act, o_name, index_to_label(slot));
484 if (object_is_cursed(o_ptr))
486 /* Warn the player */
487 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
488 chg_virtue(V_HARMONY, -1);
491 o_ptr->ident |= (IDENT_SENSE);
494 /* The Stone Mask make the player turn into a vampire! */
495 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
497 /* Turn into a vampire */
498 change_race(RACE_VAMPIRE, "");
501 /* Recalculate bonuses */
502 p_ptr->update |= (PU_BONUS);
504 /* Recalculate torch */
505 p_ptr->update |= (PU_TORCH);
507 /* Recalculate mana */
508 p_ptr->update |= (PU_MANA);
510 p_ptr->redraw |= (PR_EQUIPPY);
512 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
519 * @param item 持ち替えを行いたい装備部位ID
522 void kamaenaoshi(INVENTORY_IDX item)
524 object_type *o_ptr, *new_o_ptr;
525 char o_name[MAX_NLEN];
527 if (item == INVEN_RARM)
529 if (buki_motteruka(INVEN_LARM))
531 o_ptr = &inventory[INVEN_LARM];
532 object_desc(o_name, o_ptr, 0);
534 if (!object_is_cursed(o_ptr))
536 new_o_ptr = &inventory[INVEN_RARM];
537 object_copy(new_o_ptr, o_ptr);
538 p_ptr->total_weight += o_ptr->weight;
539 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
540 inven_item_optimize(INVEN_LARM);
541 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
542 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
544 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
545 (left_hander ? _("左手", "left") : _("右手", "right")));
549 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
550 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
554 else if (item == INVEN_LARM)
556 o_ptr = &inventory[INVEN_RARM];
557 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
559 if (buki_motteruka(INVEN_RARM))
561 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
562 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
564 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
566 new_o_ptr = &inventory[INVEN_LARM];
567 object_copy(new_o_ptr, o_ptr);
568 p_ptr->total_weight += o_ptr->weight;
569 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
570 inven_item_optimize(INVEN_RARM);
571 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
578 * @brief 装備を外すコマンドのメインルーチン / Take off an item
581 void do_cmd_takeoff(void)
587 if (p_ptr->special_defense & KATA_MUSOU)
589 set_action(ACTION_NONE);
592 item_tester_no_ryoute = TRUE;
594 q = _("どれを装備からはずしますか? ", "Take off which item? ");
595 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
597 if (!get_item(&item, q, s, (USE_EQUIP))) return;
599 /* Get the item (in the pack) */
602 o_ptr = &inventory[item];
605 /* Get the item (on the floor) */
608 o_ptr = &o_list[0 - item];
613 if (object_is_cursed(o_ptr))
615 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
617 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
622 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
624 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
626 /* Hack -- Assume felt */
627 o_ptr->ident |= (IDENT_SENSE);
629 o_ptr->curse_flags = 0L;
632 o_ptr->feeling = FEEL_NONE;
634 /* Recalculate the bonuses */
635 p_ptr->update |= (PU_BONUS);
637 p_ptr->window |= (PW_EQUIP);
639 msg_print(_("呪いを打ち破った。", "You break the curse."));
643 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
644 p_ptr->energy_use = 50;
649 /* Take a partial turn */
650 p_ptr->energy_use = 50;
652 /* Take off the item */
653 (void)inven_takeoff(item, 255);
656 p_ptr->redraw |= (PR_EQUIPPY);
661 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
664 void do_cmd_drop(void)
673 if (p_ptr->special_defense & KATA_MUSOU)
675 set_action(ACTION_NONE);
678 item_tester_no_ryoute = TRUE;
679 q = _("どのアイテムを落としますか? ", "Drop which item? ");
680 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
682 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
684 /* Get the item (in the pack) */
687 o_ptr = &inventory[item];
690 /* Get the item (on the floor) */
693 o_ptr = &o_list[0 - item];
697 /* Hack -- Cannot remove cursed items */
698 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
700 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
705 /* See how many items */
706 if (o_ptr->number > 1)
709 amt = get_quantity(NULL, o_ptr->number);
711 /* Allow user abort */
712 if (amt <= 0) return;
716 /* Take a partial turn */
717 p_ptr->energy_use = 50;
719 /* Drop (some of) the item */
720 inven_drop(item, amt);
722 if (item >= INVEN_RARM)
728 p_ptr->redraw |= (PR_EQUIPPY);
732 * @brief オブジェクトが高位の魔法書かどうかを判定する
733 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
734 * @return オブジェクトが高位の魔法書ならばTRUEを返す
736 static bool high_level_book(object_type *o_ptr)
738 if ((o_ptr->tval == TV_LIFE_BOOK) ||
739 (o_ptr->tval == TV_SORCERY_BOOK) ||
740 (o_ptr->tval == TV_NATURE_BOOK) ||
741 (o_ptr->tval == TV_CHAOS_BOOK) ||
742 (o_ptr->tval == TV_DEATH_BOOK) ||
743 (o_ptr->tval == TV_TRUMP_BOOK) ||
744 (o_ptr->tval == TV_CRAFT_BOOK) ||
745 (o_ptr->tval == TV_DAEMON_BOOK) ||
746 (o_ptr->tval == TV_CRUSADE_BOOK) ||
747 (o_ptr->tval == TV_MUSIC_BOOK) ||
748 (o_ptr->tval == TV_HEX_BOOK))
761 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
764 void do_cmd_destroy(void)
774 object_type *q_ptr = &forge;
776 char o_name[MAX_NLEN];
777 char out_val[MAX_NLEN+40];
781 if (p_ptr->special_defense & KATA_MUSOU)
783 set_action(ACTION_NONE);
786 /* Hack -- force destruction */
787 if (command_arg > 0) force = TRUE;
789 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
790 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
792 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
794 /* Get the item (in the pack) */
797 o_ptr = &inventory[item];
800 /* Get the item (on the floor) */
803 o_ptr = &o_list[0 - item];
806 /* Verify unless quantity given beforehand */
807 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
809 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
811 /* Make a verification */
812 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
815 /* HACK : Add the line to message buffer */
816 message_add(out_val);
817 p_ptr->window |= (PW_MESSAGE);
820 /* Get an acceptable answer */
830 /* Erase the prompt */
834 if (i == 'y' || i == 'Y')
838 if (i == ESCAPE || i == 'n' || i == 'N')
845 /* Add an auto-destroy preference line */
846 if (autopick_autoregister(o_ptr))
848 /* Auto-destroy it */
849 autopick_alter_item(item, TRUE);
852 /* The object is already destroyed. */
858 /* See how many items */
859 if (o_ptr->number > 1)
862 amt = get_quantity(NULL, o_ptr->number);
864 /* Allow user abort */
865 if (amt <= 0) return;
869 old_number = o_ptr->number;
871 object_desc(o_name, o_ptr, 0);
872 o_ptr->number = old_number;
874 p_ptr->energy_use = 100;
876 /* Artifacts cannot be destroyed */
877 if (!can_player_destroy_object(o_ptr))
879 p_ptr->energy_use = 0;
881 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
885 object_copy(q_ptr, o_ptr);
887 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
888 sound(SOUND_DESTITEM);
890 /* Reduce the charges of rods/wands */
891 reduce_charges(o_ptr, amt);
893 /* Eliminate the item (from the pack) */
896 inven_item_increase(item, -amt);
897 inven_item_describe(item);
898 inven_item_optimize(item);
901 /* Eliminate the item (from the floor) */
904 floor_item_increase(0 - item, -amt);
905 floor_item_describe(0 - item);
906 floor_item_optimize(0 - item);
909 if (high_level_book(q_ptr))
911 bool gain_expr = FALSE;
913 if (p_ptr->prace == RACE_ANDROID)
916 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
920 else if (p_ptr->pclass == CLASS_PALADIN)
922 if (is_good_realm(p_ptr->realm1))
924 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
928 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
932 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
934 s32b tester_exp = p_ptr->max_exp / 20;
935 if (tester_exp > 10000) tester_exp = 10000;
936 if (q_ptr->sval < 3) tester_exp /= 4;
937 if (tester_exp<1) tester_exp = 1;
939 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
940 gain_exp(tester_exp * amt);
942 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
944 chg_virtue(V_UNLIFE, 1);
945 chg_virtue(V_VITALITY, -1);
947 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
949 chg_virtue(V_UNLIFE, -1);
950 chg_virtue(V_VITALITY, 1);
953 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
954 chg_virtue(V_ENCHANT, -1);
956 if (object_value_real(q_ptr) > 30000)
957 chg_virtue(V_SACRIFICE, 2);
959 else if (object_value_real(q_ptr) > 10000)
960 chg_virtue(V_SACRIFICE, 1);
963 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
964 chg_virtue(V_HARMONY, 1);
966 if (item >= INVEN_RARM) calc_android_exp();
971 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
974 void do_cmd_observe(void)
978 char o_name[MAX_NLEN];
982 item_tester_no_ryoute = TRUE;
984 q = _("どのアイテムを調べますか? ", "Examine which item? ");
985 s = _("調べられるアイテムがない。", "You have nothing to examine.");
987 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
989 /* Get the item (in the pack) */
992 o_ptr = &inventory[item];
995 /* Get the item (on the floor) */
998 o_ptr = &o_list[0 - item];
1002 /* Require full knowledge */
1003 if (!(o_ptr->ident & IDENT_MENTAL))
1005 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1011 object_desc(o_name, o_ptr, 0);
1012 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1013 /* Describe it fully */
1014 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1020 * @brief アイテムの銘を消すコマンドのメインルーチン
1021 * Remove the inscription from an object XXX Mention item (when done)?
1024 void do_cmd_uninscribe(void)
1030 item_tester_no_ryoute = TRUE;
1031 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1032 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1034 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1036 /* Get the item (in the pack) */
1039 o_ptr = &inventory[item];
1042 /* Get the item (on the floor) */
1045 o_ptr = &o_list[0 - item];
1048 /* Nothing to remove */
1049 if (!o_ptr->inscription)
1051 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1055 msg_print(_("銘を消した。", "Inscription removed."));
1057 /* Remove the incription */
1058 o_ptr->inscription = 0;
1060 /* Combine the pack */
1061 p_ptr->notice |= (PN_COMBINE);
1063 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1065 /* .や$の関係で, 再計算が必要なはず -- henkma */
1066 p_ptr->update |= (PU_BONUS);
1072 * @brief アイテムの銘を刻むコマンドのメインルーチン
1073 * Inscribe an object with a comment
1076 void do_cmd_inscribe(void)
1080 char o_name[MAX_NLEN];
1084 item_tester_no_ryoute = TRUE;
1085 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1086 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1088 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1090 /* Get the item (in the pack) */
1093 o_ptr = &inventory[item];
1096 /* Get the item (on the floor) */
1099 o_ptr = &o_list[0 - item];
1102 /* Describe the activity */
1103 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1105 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1108 /* Start with nothing */
1109 strcpy(out_val, "");
1111 /* Use old inscription */
1112 if (o_ptr->inscription)
1114 /* Start with the old inscription */
1115 strcpy(out_val, quark_str(o_ptr->inscription));
1118 /* Get a new inscription (possibly empty) */
1119 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1121 /* Save the inscription */
1122 o_ptr->inscription = quark_add(out_val);
1124 /* Combine the pack */
1125 p_ptr->notice |= (PN_COMBINE);
1127 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1129 /* .や$の関係で, 再計算が必要なはず -- henkma */
1130 p_ptr->update |= (PU_BONUS);
1137 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1138 * An "item_tester_hook" for refilling lanterns
1139 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1140 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1142 static bool item_tester_refill_lantern(object_type *o_ptr)
1144 /* Flasks of oil are okay */
1145 if (o_ptr->tval == TV_FLASK) return (TRUE);
1147 /* Laterns are okay */
1148 if ((o_ptr->tval == TV_LITE) &&
1149 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1151 /* Assume not okay */
1157 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1158 * Refill the players lamp (from the pack or floor)
1161 static void do_cmd_refill_lamp(void)
1171 /* Restrict the choices */
1172 item_tester_hook = item_tester_refill_lantern;
1175 q = "どの油つぼから注ぎますか? ";
1178 q = "Refill with which flask? ";
1179 s = "You have no flasks of oil.";
1182 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1184 /* Get the item (in the pack) */
1187 o_ptr = &inventory[item];
1190 /* Get the item (on the floor) */
1193 o_ptr = &o_list[0 - item];
1196 /* Take a partial turn */
1197 p_ptr->energy_use = 50;
1199 /* Access the lantern */
1200 j_ptr = &inventory[INVEN_LITE];
1203 j_ptr->xtra4 += o_ptr->xtra4;
1204 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1206 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1209 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1211 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1214 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1216 else if (j_ptr->xtra4 >= FUEL_LAMP)
1218 j_ptr->xtra4 = FUEL_LAMP;
1219 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1222 /* Decrease the item (from the pack) */
1225 inven_item_increase(item, -1);
1226 inven_item_describe(item);
1227 inven_item_optimize(item);
1230 /* Decrease the item (from the floor) */
1233 floor_item_increase(0 - item, -1);
1234 floor_item_describe(0 - item);
1235 floor_item_optimize(0 - item);
1238 /* Recalculate torch */
1239 p_ptr->update |= (PU_TORCH);
1244 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1245 * An "item_tester_hook" for refilling torches
1246 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1247 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1249 static bool item_tester_refill_torch(object_type *o_ptr)
1251 /* Torches are okay */
1252 if ((o_ptr->tval == TV_LITE) &&
1253 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1255 /* Assume not okay */
1261 * @brief 松明を束ねるコマンドのメインルーチン
1262 * Refuel the players torch (from the pack or floor)
1265 static void do_cmd_refill_torch(void)
1274 /* Restrict the choices */
1275 item_tester_hook = item_tester_refill_torch;
1277 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1278 s = _("他に松明がない。", "You have no extra torches.");
1280 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1282 /* Get the item (in the pack) */
1285 o_ptr = &inventory[item];
1288 /* Get the item (on the floor) */
1291 o_ptr = &o_list[0 - item];
1295 /* Take a partial turn */
1296 p_ptr->energy_use = 50;
1298 /* Access the primary torch */
1299 j_ptr = &inventory[INVEN_LITE];
1302 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1304 msg_print(_("松明を結合した。", "You combine the torches."));
1306 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1309 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1311 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1314 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1316 /* Over-fuel message */
1317 else if (j_ptr->xtra4 >= FUEL_TORCH)
1319 j_ptr->xtra4 = FUEL_TORCH;
1320 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1323 /* Refuel message */
1326 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1329 /* Decrease the item (from the pack) */
1332 inven_item_increase(item, -1);
1333 inven_item_describe(item);
1334 inven_item_optimize(item);
1337 /* Decrease the item (from the floor) */
1340 floor_item_increase(0 - item, -1);
1341 floor_item_describe(0 - item);
1342 floor_item_optimize(0 - item);
1345 /* Recalculate torch */
1346 p_ptr->update |= (PU_TORCH);
1351 * @brief 燃料を補充するコマンドのメインルーチン
1352 * Refill the players lamp, or restock his torches
1355 void do_cmd_refill(void)
1360 o_ptr = &inventory[INVEN_LITE];
1362 if (p_ptr->special_defense & KATA_MUSOU)
1364 set_action(ACTION_NONE);
1368 if (o_ptr->tval != TV_LITE)
1370 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1374 else if (o_ptr->sval == SV_LITE_LANTERN)
1376 do_cmd_refill_lamp();
1380 else if (o_ptr->sval == SV_LITE_TORCH)
1382 do_cmd_refill_torch();
1385 /* No torch to refill */
1388 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1394 * @brief ターゲットを設定するコマンドのメインルーチン
1398 void do_cmd_target(void)
1401 if (target_set(TARGET_KILL))
1403 msg_print(_("ターゲット決定。", "Target Selected."));
1406 /* Target aborted */
1409 msg_print(_("ターゲット解除。", "Target Aborted."));
1416 * @brief 周囲を見渡すコマンドのメインルーチン
1420 void do_cmd_look(void)
1423 p_ptr->window |= PW_MONSTER_LIST;
1428 if (target_set(TARGET_LOOK))
1430 msg_print(_("ターゲット決定。", "Target Selected."));
1436 * @brief 位置を確認するコマンドのメインルーチン
1437 * Allow the player to examine other sectors on the map
1440 void do_cmd_locate(void)
1442 int dir, y1, x1, y2, x2;
1450 get_screen_size(&wid, &hgt);
1453 /* Start at current panel */
1454 y2 = y1 = panel_row_min;
1455 x2 = x1 = panel_col_min;
1457 /* Show panels until done */
1460 /* Describe the location */
1461 if ((y2 == y1) && (x2 == x1))
1464 strcpy(tmp_val, "真上");
1473 sprintf(tmp_val, "%s%s",
1474 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1475 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1477 sprintf(tmp_val, "%s%s of",
1478 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1479 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1484 /* Prepare to ask which way to look */
1485 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1486 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1487 y2 / (hgt / 2), y2 % (hgt / 2),
1488 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1490 /* Assume no direction */
1493 /* Get a direction */
1498 /* Get a command (or Cancel) */
1499 if (!get_com(out_val, &command, TRUE)) break;
1501 /* Extract the action (if any) */
1502 dir = get_keymap_dir(command);
1511 /* Apply the motion */
1512 if (change_panel(ddy[dir], ddx[dir]))
1520 /* Recenter the map around the player */
1523 p_ptr->update |= (PU_MONSTERS);
1525 p_ptr->redraw |= (PR_MAP);
1527 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1536 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1537 * Sorting hook -- Comp function -- see below
1538 * @param u モンスター種族情報の入れるポインタ
1540 * @param a 比較するモンスター種族のID1
1541 * @param b 比較するモンスター種族のID2
1542 * @return 2の方が大きければTRUEを返す
1543 * We use "u" to point to array of monster indexes,
1544 * and "v" to select the type of sorting to perform on "u".
1546 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1548 u16b *who = (u16b*)(u);
1550 u16b *why = (u16b*)(v);
1557 /* Sort by player kills */
1560 /* Extract player kills */
1561 z1 = r_info[w1].r_pkills;
1562 z2 = r_info[w2].r_pkills;
1564 /* Compare player kills */
1565 if (z1 < z2) return (TRUE);
1566 if (z1 > z2) return (FALSE);
1570 /* Sort by total kills */
1573 /* Extract total kills */
1574 z1 = r_info[w1].r_tkills;
1575 z2 = r_info[w2].r_tkills;
1577 /* Compare total kills */
1578 if (z1 < z2) return (TRUE);
1579 if (z1 > z2) return (FALSE);
1583 /* Sort by monster level */
1586 /* Extract levels */
1587 z1 = r_info[w1].level;
1588 z2 = r_info[w2].level;
1590 /* Compare levels */
1591 if (z1 < z2) return (TRUE);
1592 if (z1 > z2) return (FALSE);
1596 /* Sort by monster experience */
1599 /* Extract experience */
1600 z1 = r_info[w1].mexp;
1601 z2 = r_info[w2].mexp;
1603 /* Compare experience */
1604 if (z1 < z2) return (TRUE);
1605 if (z1 > z2) return (FALSE);
1609 /* Compare indexes */
1615 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1616 * Sorting hook -- Swap function -- see below
1617 * @param u モンスター種族情報の入れるポインタ
1619 * @param a スワップするモンスター種族のID1
1620 * @param b スワップするモンスター種族のID2
1623 * We use "u" to point to array of monster indexes,
1624 * and "v" to select the type of sorting to perform.
1626 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1628 u16b *who = (u16b*)(u);
1644 * @brief モンスターの思い出を見るコマンドのメインルーチン
1645 * Identify a character, allow recall of monsters
1649 * Several "special" responses recall "multiple" monsters:
1651 * ^U (all unique monsters)
1652 * ^N (all non-unique monsters)
1654 * The responses may be sorted in several ways, see below.
1656 * Note that the player ghosts are ignored.
1659 void do_cmd_query_symbol(void)
1673 bool recall = FALSE;
1678 /* Get a character, or abort */
1679 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1680 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1682 /* Find that character info, and describe it */
1683 for (i = 0; ident_info[i]; ++i)
1685 if (sym == ident_info[i][0]) break;
1687 if (sym == KTRL('A'))
1690 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1692 else if (sym == KTRL('U'))
1695 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1697 else if (sym == KTRL('N'))
1700 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1702 else if (sym == KTRL('R'))
1705 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1707 /* XTRA HACK WHATSEARCH */
1708 else if (sym == KTRL('M'))
1711 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1716 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1718 else if (ident_info[i])
1720 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1724 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1727 /* Display the result */
1730 /* Allocate the "who" array */
1731 C_MAKE(who, max_r_idx, IDX);
1733 /* Collect matching monsters */
1734 for (n = 0, i = 1; i < max_r_idx; i++)
1736 monster_race *r_ptr = &r_info[i];
1738 /* Nothing to recall */
1739 if (!cheat_know && !r_ptr->r_sights) continue;
1741 /* Require non-unique monsters if needed */
1742 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1744 /* Require unique monsters if needed */
1745 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1747 /* Require ridable monsters if needed */
1748 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1750 /* XTRA HACK WHATSEARCH */
1756 for (xx = 0; temp[xx] && xx < 80; xx++)
1759 if (iskanji(temp[xx])) { xx++; continue; }
1761 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1765 strcpy(temp2, r_name + r_ptr->E_name);
1767 strcpy(temp2, r_name + r_ptr->name);
1769 for (xx = 0; temp2[xx] && xx < 80; xx++)
1770 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1773 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1775 if (my_strstr(temp2, temp))
1780 /* Collect "appropriate" monsters */
1781 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1784 /* Nothing to recall */
1787 /* Free the "who" array */
1788 C_KILL(who, max_r_idx, IDX);
1794 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1804 /* Select the sort method */
1805 ang_sort_comp = ang_sort_comp_hook;
1806 ang_sort_swap = ang_sort_swap_hook;
1808 /* Sort the array */
1809 ang_sort(who, &why, n);
1811 /* Sort by kills (and level) */
1818 /* Catch "escape" */
1821 /* Free the "who" array */
1822 C_KILL(who, max_r_idx, IDX);
1827 /* Sort if needed */
1830 /* Select the sort method */
1831 ang_sort_comp = ang_sort_comp_hook;
1832 ang_sort_swap = ang_sort_swap_hook;
1834 /* Sort the array */
1835 ang_sort(who, &why, n);
1839 /* Start at the end */
1842 /* Scan the monster memory */
1845 /* Extract a race */
1848 /* Hack -- Auto-recall */
1849 monster_race_track(r_idx);
1851 /* Hack -- Handle stuff */
1860 /* Save the screen */
1863 /* Recall on screen */
1864 screen_roff(who[i], 0);
1867 /* Hack -- Begin the prompt */
1870 /* Hack -- Complete the prompt */
1871 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1883 /* Normal commands */
1884 if (query != 'r') break;
1891 if (query == ESCAPE) break;
1893 /* Move to "prev" monster */
1899 if (!expand_list) break;
1903 /* Move to "next" monster */
1909 if (!expand_list) break;
1914 /* Free the "who" array */
1915 C_KILL(who, max_r_idx, IDX);
1917 /* Re-display the identity */
1922 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1926 * XXX - Add actions for other item types
1928 void do_cmd_use(void)
1934 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1936 set_action(ACTION_NONE);
1939 item_tester_no_ryoute = TRUE;
1940 item_tester_hook = item_tester_hook_use;
1942 q = _("どれを使いますか?", "Use which item? ");
1943 s = _("使えるものがありません。", "You have nothing to use.");
1945 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1947 /* Get the item (in the pack) */
1950 o_ptr = &inventory[item];
1952 /* Get the item (on the floor) */
1955 o_ptr = &o_list[0 - item];
1958 switch (o_ptr->tval)
1970 do_cmd_eat_food_aux(item);
1977 do_cmd_aim_wand_aux(item);
1984 do_cmd_use_staff_aux(item);
1991 do_cmd_zap_rod_aux(item);
1995 /* Quaff a potion */
1998 do_cmd_quaff_potion_aux(item);
2005 /* Check some conditions */
2008 msg_print(_("目が見えない。", "You can't see anything."));
2013 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2016 if (p_ptr->confused)
2018 msg_print(_("混乱していて読めない!", "You are too confused!"));
2022 do_cmd_read_scroll_aux(item, TRUE);
2031 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2035 /* Activate an artifact */
2038 do_cmd_activate_aux(item);