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);
46 /* Hack -- show empty slots */
47 item_tester_full = TRUE;
49 /* Display the inventory */
52 /* Hack -- hide empty slots */
53 item_tester_full = FALSE;
56 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
57 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
58 (long int)((p_ptr->total_weight * 100) / weight_limit()));
60 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
61 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
62 (p_ptr->total_weight * 100) / weight_limit());
69 /* Get a new command */
70 command_new = inkey();
76 /* Process "Escape" */
77 if (command_new == ESCAPE)
82 Term_get_size(&wid, &hgt);
86 command_gap = wid - 30;
89 /* Process normal keys */
92 /* Hack -- Use "display" mode */
99 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
102 void do_cmd_equip(void)
107 /* Note that we are in "equipment" mode */
110 /* Note that we are in "equipment" mode */
111 if (easy_floor) command_wrk = (USE_EQUIP);
113 /* Save the screen */
116 /* Hack -- show empty slots */
117 item_tester_full = TRUE;
119 /* Display the equipment */
122 /* Hack -- undo the hack above */
123 item_tester_full = FALSE;
127 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
128 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
129 (long int)((p_ptr->total_weight * 100) / weight_limit()));
131 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
132 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
133 (long int)((p_ptr->total_weight * 100) / weight_limit()));
140 /* Get a new command */
141 command_new = inkey();
143 /* Restore the screen */
147 /* Process "Escape" */
148 if (command_new == ESCAPE)
153 Term_get_size(&wid, &hgt);
157 command_gap = wid - 30;
160 /* Process normal keys */
163 /* Enter "display" mode */
171 bool select_ring_slot = FALSE;
174 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
177 void do_cmd_wield(void)
179 OBJECT_IDX item, slot;
188 char o_name[MAX_NLEN];
192 OBJECT_IDX need_switch_wielding = 0;
194 if (p_ptr->special_defense & KATA_MUSOU)
196 set_action(ACTION_NONE);
199 /* Restrict the choices */
200 item_tester_hook = item_tester_hook_wear;
202 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
203 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
205 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
207 /* Get the item (in the pack) */
210 o_ptr = &inventory[item];
213 /* Get the item (on the floor) */
216 o_ptr = &o_list[0 - item];
221 slot = wield_slot(o_ptr);
225 /* Shields and some misc. items */
230 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
232 /* Restrict the choices */
233 item_tester_hook = item_tester_hook_melee_weapon;
234 item_tester_no_ryoute = TRUE;
236 /* Choose a weapon from the equipment only */
237 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
238 s = _("おっと。", "Oops.");
239 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
240 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
243 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
245 /* Both arms are already used by non-weapon */
246 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
247 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
249 /* Restrict the choices */
250 item_tester_hook = item_tester_hook_mochikae;
253 q = _("どちらの手に装備しますか?", "Equip which hand? ");
254 s = _("おっと。", "Oops.");
255 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
264 /* Asking for dual wielding */
265 if (slot == INVEN_LARM)
267 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
270 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
272 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
275 /* Both arms are already used */
276 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
278 /* Restrict the choices */
279 item_tester_hook = item_tester_hook_mochikae;
282 q = _("どちらの手に装備しますか?", "Equip which hand? ");
283 s = _("おっと。", "Oops.");
285 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
286 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
287 need_switch_wielding = INVEN_RARM;
293 /* Choose a ring slot */
294 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
296 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
300 q = _("どちらの手に装備しますか?", "Equip which hand? ");
302 s = _("おっと。", "Oops.");
304 /* Restrict the choices */
305 select_ring_slot = TRUE;
306 item_tester_no_ryoute = TRUE;
308 if (!get_item(&slot, q, s, (USE_EQUIP)))
310 select_ring_slot = FALSE;
313 select_ring_slot = FALSE;
317 /* Prevent wielding into a cursed slot */
318 if (object_is_cursed(&inventory[slot]))
321 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
324 msg_format("%s%sは呪われているようだ。",
325 describe_use(slot) , o_name );
327 msg_format("The %s you are %s appears to be cursed.",
328 o_name, describe_use(slot));
331 /* Cancel the command */
336 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
337 ((o_ptr->ident & IDENT_SENSE) &&
338 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
340 char dummy[MAX_NLEN+80];
343 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
344 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
346 if (!get_check(dummy)) return;
349 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
351 char dummy[MAX_NLEN+80];
354 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
357 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
359 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
360 sprintf(dummy, "Do you become a vampire?");
363 if (!get_check(dummy)) return;
366 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
368 object_type *slot_o_ptr = &inventory[slot];
369 object_type *switch_o_ptr = &inventory[need_switch_wielding];
370 object_type object_tmp;
371 object_type *otmp_ptr = &object_tmp;
372 char switch_name[MAX_NLEN];
374 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
376 object_copy(otmp_ptr, switch_o_ptr);
377 object_copy(switch_o_ptr, slot_o_ptr);
378 object_copy(slot_o_ptr, otmp_ptr);
380 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
381 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
382 (left_hander ? _("右手", "right") : _("左手", "left")));
383 slot = need_switch_wielding;
386 check_find_art_quest_completion(o_ptr);
388 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
390 identify_item(o_ptr);
392 /* Auto-inscription */
393 autopick_alter_item(item, FALSE);
396 p_ptr->energy_use = 100;
398 /* Get local object */
401 /* Obtain local object */
402 object_copy(q_ptr, o_ptr);
404 /* Modify quantity */
407 /* Decrease the item (from the pack) */
410 inven_item_increase(item, -1);
411 inven_item_optimize(item);
414 /* Decrease the item (from the floor) */
417 floor_item_increase(0 - item, -1);
418 floor_item_optimize(0 - item);
421 /* Access the wield slot */
422 o_ptr = &inventory[slot];
424 /* Take off existing item */
427 /* Take off existing item */
428 (void)inven_takeoff(slot, 255);
431 /* Wear the new stuff */
432 object_copy(o_ptr, q_ptr);
434 /* Player touches it */
435 o_ptr->marked |= OM_TOUCHED;
437 /* Increase the weight */
438 p_ptr->total_weight += q_ptr->weight;
440 /* Increment the equip counter by hand */
444 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
445 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
446 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
448 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
449 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
450 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
453 /* Where is the item now */
457 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
458 act = STR_WIELD_ARMS;
460 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
464 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
465 act = STR_WIELD_ARMS;
467 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
471 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
475 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
479 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
483 /* Describe the result */
484 object_desc(o_name, o_ptr, 0);
486 msg_format(act, o_name, index_to_label(slot));
490 if (object_is_cursed(o_ptr))
492 /* Warn the player */
493 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
494 chg_virtue(V_HARMONY, -1);
497 o_ptr->ident |= (IDENT_SENSE);
500 /* The Stone Mask make the player turn into a vampire! */
501 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
503 /* Turn into a vampire */
504 change_race(RACE_VAMPIRE, "");
507 /* Recalculate bonuses */
508 p_ptr->update |= (PU_BONUS);
510 /* Recalculate torch */
511 p_ptr->update |= (PU_TORCH);
513 /* Recalculate mana */
514 p_ptr->update |= (PU_MANA);
516 p_ptr->redraw |= (PR_EQUIPPY);
518 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
525 * @param item 持ち替えを行いたい装備部位ID
528 void kamaenaoshi(INVENTORY_IDX item)
530 object_type *o_ptr, *new_o_ptr;
531 char o_name[MAX_NLEN];
533 if (item == INVEN_RARM)
535 if (buki_motteruka(INVEN_LARM))
537 o_ptr = &inventory[INVEN_LARM];
538 object_desc(o_name, o_ptr, 0);
540 if (!object_is_cursed(o_ptr))
542 new_o_ptr = &inventory[INVEN_RARM];
543 object_copy(new_o_ptr, o_ptr);
544 p_ptr->total_weight += o_ptr->weight;
545 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
546 inven_item_optimize(INVEN_LARM);
547 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
548 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
550 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
551 (left_hander ? _("左手", "left") : _("右手", "right")));
555 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
556 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
560 else if (item == INVEN_LARM)
562 o_ptr = &inventory[INVEN_RARM];
563 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
565 if (buki_motteruka(INVEN_RARM))
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);
570 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
572 new_o_ptr = &inventory[INVEN_LARM];
573 object_copy(new_o_ptr, o_ptr);
574 p_ptr->total_weight += o_ptr->weight;
575 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
576 inven_item_optimize(INVEN_RARM);
577 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
584 * @brief 装備を外すコマンドのメインルーチン / Take off an item
587 void do_cmd_takeoff(void)
593 if (p_ptr->special_defense & KATA_MUSOU)
595 set_action(ACTION_NONE);
598 item_tester_no_ryoute = TRUE;
600 q = _("どれを装備からはずしますか? ", "Take off which item? ");
601 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
603 if (!get_item(&item, q, s, (USE_EQUIP))) return;
605 /* Get the item (in the pack) */
608 o_ptr = &inventory[item];
611 /* Get the item (on the floor) */
614 o_ptr = &o_list[0 - item];
619 if (object_is_cursed(o_ptr))
621 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
623 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
628 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
630 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
632 /* Hack -- Assume felt */
633 o_ptr->ident |= (IDENT_SENSE);
635 o_ptr->curse_flags = 0L;
638 o_ptr->feeling = FEEL_NONE;
640 /* Recalculate the bonuses */
641 p_ptr->update |= (PU_BONUS);
643 p_ptr->window |= (PW_EQUIP);
645 msg_print(_("呪いを打ち破った。", "You break the curse."));
649 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
650 p_ptr->energy_use = 50;
655 /* Take a partial turn */
656 p_ptr->energy_use = 50;
658 /* Take off the item */
659 (void)inven_takeoff(item, 255);
662 p_ptr->redraw |= (PR_EQUIPPY);
667 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
670 void do_cmd_drop(void)
679 if (p_ptr->special_defense & KATA_MUSOU)
681 set_action(ACTION_NONE);
684 item_tester_no_ryoute = TRUE;
685 q = _("どのアイテムを落としますか? ", "Drop which item? ");
686 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
688 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
690 /* Get the item (in the pack) */
693 o_ptr = &inventory[item];
696 /* Get the item (on the floor) */
699 o_ptr = &o_list[0 - item];
703 /* Hack -- Cannot remove cursed items */
704 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
706 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
711 /* See how many items */
712 if (o_ptr->number > 1)
715 amt = get_quantity(NULL, o_ptr->number);
717 /* Allow user abort */
718 if (amt <= 0) return;
722 /* Take a partial turn */
723 p_ptr->energy_use = 50;
725 /* Drop (some of) the item */
726 inven_drop(item, amt);
728 if (item >= INVEN_RARM)
734 p_ptr->redraw |= (PR_EQUIPPY);
738 * @brief オブジェクトが高位の魔法書かどうかを判定する
739 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
740 * @return オブジェクトが高位の魔法書ならばTRUEを返す
742 static bool high_level_book(object_type *o_ptr)
744 if ((o_ptr->tval == TV_LIFE_BOOK) ||
745 (o_ptr->tval == TV_SORCERY_BOOK) ||
746 (o_ptr->tval == TV_NATURE_BOOK) ||
747 (o_ptr->tval == TV_CHAOS_BOOK) ||
748 (o_ptr->tval == TV_DEATH_BOOK) ||
749 (o_ptr->tval == TV_TRUMP_BOOK) ||
750 (o_ptr->tval == TV_CRAFT_BOOK) ||
751 (o_ptr->tval == TV_DAEMON_BOOK) ||
752 (o_ptr->tval == TV_CRUSADE_BOOK) ||
753 (o_ptr->tval == TV_MUSIC_BOOK) ||
754 (o_ptr->tval == TV_HEX_BOOK))
767 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
770 void do_cmd_destroy(void)
780 object_type *q_ptr = &forge;
782 char o_name[MAX_NLEN];
783 char out_val[MAX_NLEN+40];
787 if (p_ptr->special_defense & KATA_MUSOU)
789 set_action(ACTION_NONE);
792 /* Hack -- force destruction */
793 if (command_arg > 0) force = TRUE;
795 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
796 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
798 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
800 /* Get the item (in the pack) */
803 o_ptr = &inventory[item];
806 /* Get the item (on the floor) */
809 o_ptr = &o_list[0 - item];
812 /* Verify unless quantity given beforehand */
813 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
815 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
817 /* Make a verification */
818 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
821 /* HACK : Add the line to message buffer */
822 message_add(out_val);
823 p_ptr->window |= (PW_MESSAGE);
826 /* Get an acceptable answer */
836 /* Erase the prompt */
840 if (i == 'y' || i == 'Y')
844 if (i == ESCAPE || i == 'n' || i == 'N')
851 /* Add an auto-destroy preference line */
852 if (autopick_autoregister(o_ptr))
854 /* Auto-destroy it */
855 autopick_alter_item(item, TRUE);
858 /* The object is already destroyed. */
864 /* See how many items */
865 if (o_ptr->number > 1)
868 amt = get_quantity(NULL, o_ptr->number);
870 /* Allow user abort */
871 if (amt <= 0) return;
875 /* Describe the object */
876 old_number = o_ptr->number;
878 object_desc(o_name, o_ptr, 0);
879 o_ptr->number = old_number;
881 p_ptr->energy_use = 100;
883 /* Artifacts cannot be destroyed */
884 if (!can_player_destroy_object(o_ptr))
886 p_ptr->energy_use = 0;
888 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
892 object_copy(q_ptr, o_ptr);
894 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
895 sound(SOUND_DESTITEM);
897 /* Reduce the charges of rods/wands */
898 reduce_charges(o_ptr, amt);
900 /* Eliminate the item (from the pack) */
903 inven_item_increase(item, -amt);
904 inven_item_describe(item);
905 inven_item_optimize(item);
908 /* Eliminate the item (from the floor) */
911 floor_item_increase(0 - item, -amt);
912 floor_item_describe(0 - item);
913 floor_item_optimize(0 - item);
916 if (high_level_book(q_ptr))
918 bool gain_expr = FALSE;
920 if (p_ptr->prace == RACE_ANDROID)
923 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
927 else if (p_ptr->pclass == CLASS_PALADIN)
929 if (is_good_realm(p_ptr->realm1))
931 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
935 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
939 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
941 s32b tester_exp = p_ptr->max_exp / 20;
942 if (tester_exp > 10000) tester_exp = 10000;
943 if (q_ptr->sval < 3) tester_exp /= 4;
944 if (tester_exp<1) tester_exp = 1;
946 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
947 gain_exp(tester_exp * amt);
949 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
951 chg_virtue(V_UNLIFE, 1);
952 chg_virtue(V_VITALITY, -1);
954 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
956 chg_virtue(V_UNLIFE, -1);
957 chg_virtue(V_VITALITY, 1);
960 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
961 chg_virtue(V_ENCHANT, -1);
963 if (object_value_real(q_ptr) > 30000)
964 chg_virtue(V_SACRIFICE, 2);
966 else if (object_value_real(q_ptr) > 10000)
967 chg_virtue(V_SACRIFICE, 1);
970 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
971 chg_virtue(V_HARMONY, 1);
973 if (item >= INVEN_RARM) calc_android_exp();
978 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
981 void do_cmd_observe(void)
985 char o_name[MAX_NLEN];
989 item_tester_no_ryoute = TRUE;
991 q = _("どのアイテムを調べますか? ", "Examine which item? ");
992 s = _("調べられるアイテムがない。", "You have nothing to examine.");
994 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
996 /* Get the item (in the pack) */
999 o_ptr = &inventory[item];
1002 /* Get the item (on the floor) */
1005 o_ptr = &o_list[0 - item];
1009 /* Require full knowledge */
1010 if (!(o_ptr->ident & IDENT_MENTAL))
1012 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1018 object_desc(o_name, o_ptr, 0);
1021 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1022 /* Describe it fully */
1023 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1029 * @brief アイテムの銘を消すコマンドのメインルーチン
1030 * Remove the inscription from an object XXX Mention item (when done)?
1033 void do_cmd_uninscribe(void)
1039 item_tester_no_ryoute = TRUE;
1040 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1041 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1043 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1045 /* Get the item (in the pack) */
1048 o_ptr = &inventory[item];
1051 /* Get the item (on the floor) */
1054 o_ptr = &o_list[0 - item];
1057 /* Nothing to remove */
1058 if (!o_ptr->inscription)
1060 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1064 msg_print(_("銘を消した。", "Inscription removed."));
1066 /* Remove the incription */
1067 o_ptr->inscription = 0;
1069 /* Combine the pack */
1070 p_ptr->notice |= (PN_COMBINE);
1072 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1074 /* .や$の関係で, 再計算が必要なはず -- henkma */
1075 p_ptr->update |= (PU_BONUS);
1081 * @brief アイテムの銘を刻むコマンドのメインルーチン
1082 * Inscribe an object with a comment
1085 void do_cmd_inscribe(void)
1089 char o_name[MAX_NLEN];
1093 item_tester_no_ryoute = TRUE;
1094 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1095 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1097 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1099 /* Get the item (in the pack) */
1102 o_ptr = &inventory[item];
1105 /* Get the item (on the floor) */
1108 o_ptr = &o_list[0 - item];
1111 /* Describe the activity */
1112 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1114 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1117 /* Start with nothing */
1118 strcpy(out_val, "");
1120 /* Use old inscription */
1121 if (o_ptr->inscription)
1123 /* Start with the old inscription */
1124 strcpy(out_val, quark_str(o_ptr->inscription));
1127 /* Get a new inscription (possibly empty) */
1128 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1130 /* Save the inscription */
1131 o_ptr->inscription = quark_add(out_val);
1133 /* Combine the pack */
1134 p_ptr->notice |= (PN_COMBINE);
1136 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1138 /* .や$の関係で, 再計算が必要なはず -- henkma */
1139 p_ptr->update |= (PU_BONUS);
1146 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1147 * An "item_tester_hook" for refilling lanterns
1148 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1149 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1151 static bool item_tester_refill_lantern(object_type *o_ptr)
1153 /* Flasks of oil are okay */
1154 if (o_ptr->tval == TV_FLASK) return (TRUE);
1156 /* Laterns are okay */
1157 if ((o_ptr->tval == TV_LITE) &&
1158 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1160 /* Assume not okay */
1166 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1167 * Refill the players lamp (from the pack or floor)
1170 static void do_cmd_refill_lamp(void)
1180 /* Restrict the choices */
1181 item_tester_hook = item_tester_refill_lantern;
1184 q = "どの油つぼから注ぎますか? ";
1187 q = "Refill with which flask? ";
1188 s = "You have no flasks of oil.";
1191 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1193 /* Get the item (in the pack) */
1196 o_ptr = &inventory[item];
1199 /* Get the item (on the floor) */
1202 o_ptr = &o_list[0 - item];
1206 /* Take a partial turn */
1207 p_ptr->energy_use = 50;
1209 /* Access the lantern */
1210 j_ptr = &inventory[INVEN_LITE];
1213 j_ptr->xtra4 += o_ptr->xtra4;
1215 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1218 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1221 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1223 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1226 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1228 else if (j_ptr->xtra4 >= FUEL_LAMP)
1230 j_ptr->xtra4 = FUEL_LAMP;
1231 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1234 /* Decrease the item (from the pack) */
1237 inven_item_increase(item, -1);
1238 inven_item_describe(item);
1239 inven_item_optimize(item);
1242 /* Decrease the item (from the floor) */
1245 floor_item_increase(0 - item, -1);
1246 floor_item_describe(0 - item);
1247 floor_item_optimize(0 - item);
1250 /* Recalculate torch */
1251 p_ptr->update |= (PU_TORCH);
1256 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1257 * An "item_tester_hook" for refilling torches
1258 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1259 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1261 static bool item_tester_refill_torch(object_type *o_ptr)
1263 /* Torches are okay */
1264 if ((o_ptr->tval == TV_LITE) &&
1265 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1267 /* Assume not okay */
1273 * @brief 松明を束ねるコマンドのメインルーチン
1274 * Refuel the players torch (from the pack or floor)
1277 static void do_cmd_refill_torch(void)
1286 /* Restrict the choices */
1287 item_tester_hook = item_tester_refill_torch;
1289 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1290 s = _("他に松明がない。", "You have no extra torches.");
1292 if (get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1294 /* Get the item (in the pack) */
1297 o_ptr = &inventory[item];
1300 /* Get the item (on the floor) */
1303 o_ptr = &o_list[0 - item];
1307 /* Take a partial turn */
1308 p_ptr->energy_use = 50;
1310 /* Access the primary torch */
1311 j_ptr = &inventory[INVEN_LITE];
1314 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1316 msg_print(_("松明を結合した。", "You combine the torches."));
1319 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1322 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1324 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1327 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1329 /* Over-fuel message */
1330 else if (j_ptr->xtra4 >= FUEL_TORCH)
1332 j_ptr->xtra4 = FUEL_TORCH;
1333 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1336 /* Refuel message */
1339 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1342 /* Decrease the item (from the pack) */
1345 inven_item_increase(item, -1);
1346 inven_item_describe(item);
1347 inven_item_optimize(item);
1350 /* Decrease the item (from the floor) */
1353 floor_item_increase(0 - item, -1);
1354 floor_item_describe(0 - item);
1355 floor_item_optimize(0 - item);
1358 /* Recalculate torch */
1359 p_ptr->update |= (PU_TORCH);
1364 * @brief 燃料を補充するコマンドのメインルーチン
1365 * Refill the players lamp, or restock his torches
1368 void do_cmd_refill(void)
1373 o_ptr = &inventory[INVEN_LITE];
1375 if (p_ptr->special_defense & KATA_MUSOU)
1377 set_action(ACTION_NONE);
1381 if (o_ptr->tval != TV_LITE)
1383 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1387 else if (o_ptr->sval == SV_LITE_LANTERN)
1389 do_cmd_refill_lamp();
1393 else if (o_ptr->sval == SV_LITE_TORCH)
1395 do_cmd_refill_torch();
1398 /* No torch to refill */
1401 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1407 * @brief ターゲットを設定するコマンドのメインルーチン
1411 void do_cmd_target(void)
1414 if (target_set(TARGET_KILL))
1416 msg_print(_("ターゲット決定。", "Target Selected."));
1419 /* Target aborted */
1422 msg_print(_("ターゲット解除。", "Target Aborted."));
1429 * @brief 周囲を見渡すコマンドのメインルーチン
1433 void do_cmd_look(void)
1436 p_ptr->window |= PW_MONSTER_LIST;
1441 if (target_set(TARGET_LOOK))
1443 msg_print(_("ターゲット決定。", "Target Selected."));
1449 * @brief 位置を確認するコマンドのメインルーチン
1450 * Allow the player to examine other sectors on the map
1453 void do_cmd_locate(void)
1455 int dir, y1, x1, y2, x2;
1464 get_screen_size(&wid, &hgt);
1467 /* Start at current panel */
1468 y2 = y1 = panel_row_min;
1469 x2 = x1 = panel_col_min;
1471 /* Show panels until done */
1474 /* Describe the location */
1475 if ((y2 == y1) && (x2 == x1))
1478 strcpy(tmp_val, "真上");
1487 sprintf(tmp_val, "%s%s",
1488 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1489 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1491 sprintf(tmp_val, "%s%s of",
1492 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1493 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1498 /* Prepare to ask which way to look */
1499 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1500 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1501 y2 / (hgt / 2), y2 % (hgt / 2),
1502 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1504 /* Assume no direction */
1507 /* Get a direction */
1512 /* Get a command (or Cancel) */
1513 if (!get_com(out_val, &command, TRUE)) break;
1515 /* Extract the action (if any) */
1516 dir = get_keymap_dir(command);
1525 /* Apply the motion */
1526 if (change_panel(ddy[dir], ddx[dir]))
1534 /* Recenter the map around the player */
1537 p_ptr->update |= (PU_MONSTERS);
1540 p_ptr->redraw |= (PR_MAP);
1542 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1551 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1552 * Sorting hook -- Comp function -- see below
1553 * @param u モンスター種族情報の入れるポインタ
1555 * @param a 比較するモンスター種族のID1
1556 * @param b 比較するモンスター種族のID2
1557 * @return 2の方が大きければTRUEを返す
1558 * We use "u" to point to array of monster indexes,
1559 * and "v" to select the type of sorting to perform on "u".
1561 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1563 u16b *who = (u16b*)(u);
1565 u16b *why = (u16b*)(v);
1572 /* Sort by player kills */
1575 /* Extract player kills */
1576 z1 = r_info[w1].r_pkills;
1577 z2 = r_info[w2].r_pkills;
1579 /* Compare player kills */
1580 if (z1 < z2) return (TRUE);
1581 if (z1 > z2) return (FALSE);
1585 /* Sort by total kills */
1588 /* Extract total kills */
1589 z1 = r_info[w1].r_tkills;
1590 z2 = r_info[w2].r_tkills;
1592 /* Compare total kills */
1593 if (z1 < z2) return (TRUE);
1594 if (z1 > z2) return (FALSE);
1598 /* Sort by monster level */
1601 /* Extract levels */
1602 z1 = r_info[w1].level;
1603 z2 = r_info[w2].level;
1605 /* Compare levels */
1606 if (z1 < z2) return (TRUE);
1607 if (z1 > z2) return (FALSE);
1611 /* Sort by monster experience */
1614 /* Extract experience */
1615 z1 = r_info[w1].mexp;
1616 z2 = r_info[w2].mexp;
1618 /* Compare experience */
1619 if (z1 < z2) return (TRUE);
1620 if (z1 > z2) return (FALSE);
1624 /* Compare indexes */
1630 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1631 * Sorting hook -- Swap function -- see below
1632 * @param u モンスター種族情報の入れるポインタ
1634 * @param a スワップするモンスター種族のID1
1635 * @param b スワップするモンスター種族のID2
1638 * We use "u" to point to array of monster indexes,
1639 * and "v" to select the type of sorting to perform.
1641 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1643 u16b *who = (u16b*)(u);
1659 * @brief モンスターの思い出を見るコマンドのメインルーチン
1660 * Identify a character, allow recall of monsters
1664 * Several "special" responses recall "multiple" monsters:
1666 * ^U (all unique monsters)
1667 * ^N (all non-unique monsters)
1669 * The responses may be sorted in several ways, see below.
1671 * Note that the player ghosts are ignored.
1674 void do_cmd_query_symbol(void)
1688 bool recall = FALSE;
1693 /* Get a character, or abort */
1694 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1695 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1697 /* Find that character info, and describe it */
1698 for (i = 0; ident_info[i]; ++i)
1700 if (sym == ident_info[i][0]) break;
1704 if (sym == KTRL('A'))
1707 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1709 else if (sym == KTRL('U'))
1712 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1714 else if (sym == KTRL('N'))
1717 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1719 else if (sym == KTRL('R'))
1722 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1724 /* XTRA HACK WHATSEARCH */
1725 else if (sym == KTRL('M'))
1728 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1733 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1735 else if (ident_info[i])
1737 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1741 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1744 /* Display the result */
1747 /* Allocate the "who" array */
1748 C_MAKE(who, max_r_idx, IDX);
1750 /* Collect matching monsters */
1751 for (n = 0, i = 1; i < max_r_idx; i++)
1753 monster_race *r_ptr = &r_info[i];
1755 /* Nothing to recall */
1756 if (!cheat_know && !r_ptr->r_sights) continue;
1758 /* Require non-unique monsters if needed */
1759 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1761 /* Require unique monsters if needed */
1762 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1764 /* Require ridable monsters if needed */
1765 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1767 /* XTRA HACK WHATSEARCH */
1773 for (xx = 0; temp[xx] && xx < 80; xx++)
1776 if (iskanji(temp[xx])) { xx++; continue; }
1778 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1782 strcpy(temp2, r_name + r_ptr->E_name);
1784 strcpy(temp2, r_name + r_ptr->name);
1786 for (xx = 0; temp2[xx] && xx < 80; xx++)
1787 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1790 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1792 if (my_strstr(temp2, temp))
1797 /* Collect "appropriate" monsters */
1798 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1801 /* Nothing to recall */
1804 /* Free the "who" array */
1805 C_KILL(who, max_r_idx, IDX);
1812 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1823 /* Select the sort method */
1824 ang_sort_comp = ang_sort_comp_hook;
1825 ang_sort_swap = ang_sort_swap_hook;
1827 /* Sort the array */
1828 ang_sort(who, &why, n);
1830 /* Sort by kills (and level) */
1837 /* Catch "escape" */
1840 /* Free the "who" array */
1841 C_KILL(who, max_r_idx, IDX);
1846 /* Sort if needed */
1849 /* Select the sort method */
1850 ang_sort_comp = ang_sort_comp_hook;
1851 ang_sort_swap = ang_sort_swap_hook;
1853 /* Sort the array */
1854 ang_sort(who, &why, n);
1858 /* Start at the end */
1861 /* Scan the monster memory */
1864 /* Extract a race */
1867 /* Hack -- Auto-recall */
1868 monster_race_track(r_idx);
1870 /* Hack -- Handle stuff */
1879 /* Save the screen */
1882 /* Recall on screen */
1883 screen_roff(who[i], 0);
1886 /* Hack -- Begin the prompt */
1889 /* Hack -- Complete the prompt */
1890 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1902 /* Normal commands */
1903 if (query != 'r') break;
1910 if (query == ESCAPE) break;
1912 /* Move to "prev" monster */
1918 if (!expand_list) break;
1922 /* Move to "next" monster */
1928 if (!expand_list) break;
1933 /* Free the "who" array */
1934 C_KILL(who, max_r_idx, IDX);
1936 /* Re-display the identity */
1941 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1945 * XXX - Add actions for other item types
1947 void do_cmd_use(void)
1953 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1955 set_action(ACTION_NONE);
1958 item_tester_no_ryoute = TRUE;
1959 /* Prepare the hook */
1960 item_tester_hook = item_tester_hook_use;
1962 q = _("どれを使いますか?", "Use which item? ");
1963 s = _("使えるものがありません。", "You have nothing to use.");
1965 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1967 /* Get the item (in the pack) */
1970 o_ptr = &inventory[item];
1972 /* Get the item (on the floor) */
1975 o_ptr = &o_list[0 - item];
1978 switch (o_ptr->tval)
1990 do_cmd_eat_food_aux(item);
1997 do_cmd_aim_wand_aux(item);
2004 do_cmd_use_staff_aux(item);
2011 do_cmd_zap_rod_aux(item);
2015 /* Quaff a potion */
2018 do_cmd_quaff_potion_aux(item);
2025 /* Check some conditions */
2028 msg_print(_("目が見えない。", "You can't see anything."));
2033 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2036 if (p_ptr->confused)
2038 msg_print(_("混乱していて読めない!", "You are too confused!"));
2042 do_cmd_read_scroll_aux(item, TRUE);
2051 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2055 /* Activate an artifact */
2058 do_cmd_activate_aux(item);