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.
19 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
22 void do_cmd_inven(void)
27 /* Note that we are in "inventory" mode */
30 #ifdef ALLOW_EASY_FLOOR
32 /* Note that we are in "inventory" mode */
33 if (easy_floor) command_wrk = (USE_INVEN);
35 #endif /* ALLOW_EASY_FLOOR */
40 /* Hack -- show empty slots */
41 item_tester_full = TRUE;
43 /* Display the inventory */
46 /* Hack -- hide empty slots */
47 item_tester_full = FALSE;
50 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
51 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
52 (long int)((p_ptr->total_weight * 100) / weight_limit()));
54 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
55 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
56 (p_ptr->total_weight * 100) / weight_limit());
63 /* Get a new command */
64 command_new = inkey();
70 /* Process "Escape" */
71 if (command_new == ESCAPE)
76 Term_get_size(&wid, &hgt);
80 command_gap = wid - 30;
83 /* Process normal keys */
86 /* Hack -- Use "display" mode */
93 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
96 void do_cmd_equip(void)
101 /* Note that we are in "equipment" mode */
104 #ifdef ALLOW_EASY_FLOOR
106 /* Note that we are in "equipment" mode */
107 if (easy_floor) command_wrk = (USE_EQUIP);
109 #endif /* ALLOW_EASY_FLOOR */
111 /* Save the screen */
114 /* Hack -- show empty slots */
115 item_tester_full = TRUE;
117 /* Display the equipment */
120 /* Hack -- undo the hack above */
121 item_tester_full = FALSE;
125 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
126 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
127 (long int)((p_ptr->total_weight * 100) / weight_limit()));
129 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
130 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
131 (long int)((p_ptr->total_weight * 100) / weight_limit()));
138 /* Get a new command */
139 command_new = inkey();
141 /* Restore the screen */
145 /* Process "Escape" */
146 if (command_new == ESCAPE)
151 Term_get_size(&wid, &hgt);
155 command_gap = wid - 30;
158 /* Process normal keys */
161 /* Enter "display" mode */
168 * @brief オブジェクトを防具として装備できるかの判定 / The "wearable" tester
169 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
170 * @return オブジェクトが防具として装備できるならTRUEを返す。
172 static bool item_tester_hook_wear(object_type *o_ptr)
174 if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI))
175 if (p_ptr->psex == SEX_MALE) return FALSE;
177 /* Check for a usable slot */
178 if (wield_slot(o_ptr) >= INVEN_RARM) return (TRUE);
180 /* Assume not wearable */
186 * @brief オブジェクトがどちらの手にも装備できる武器かどうかの判定
187 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
188 * @return 左右両方の手で装備できるならばTRUEを返す。
190 static bool item_tester_hook_mochikae(object_type *o_ptr)
192 /* Check for a usable slot */
193 if (((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD)) ||
194 (o_ptr->tval == TV_SHIELD) || (o_ptr->tval == TV_CAPTURE) ||
195 (o_ptr->tval == TV_CARD)) return (TRUE);
197 /* Assume not wearable */
202 * @brief オブジェクトが右手か左手に装備できる武器かどうかの判定
203 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
204 * @return 右手か左手の武器として装備できるならばTRUEを返す。
206 static bool item_tester_hook_melee_weapon(object_type *o_ptr)
208 /* Check for a usable slot */
209 if ((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD))return (TRUE);
211 /* Assume not wearable */
216 bool select_ring_slot = FALSE;
219 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
222 void do_cmd_wield(void)
224 OBJECT_IDX item, slot;
233 char o_name[MAX_NLEN];
237 int need_switch_wielding = 0;
239 if (p_ptr->special_defense & KATA_MUSOU)
241 set_action(ACTION_NONE);
244 /* Restrict the choices */
245 item_tester_hook = item_tester_hook_wear;
248 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
249 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
251 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
253 /* Get the item (in the pack) */
256 o_ptr = &inventory[item];
259 /* Get the item (on the floor) */
262 o_ptr = &o_list[0 - item];
267 slot = wield_slot(o_ptr);
271 /* Shields and some misc. items */
276 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
278 /* Restrict the choices */
279 item_tester_hook = item_tester_hook_melee_weapon;
280 item_tester_no_ryoute = TRUE;
282 /* Choose a weapon from the equipment only */
283 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
284 s = _("おっと。", "Oops.");
285 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
286 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
289 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
291 /* Both arms are already used by non-weapon */
292 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
293 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
295 /* Restrict the choices */
296 item_tester_hook = item_tester_hook_mochikae;
299 q = _("どちらの手に装備しますか?", "Equip which hand? ");
300 s = _("おっと。", "Oops.");
301 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
310 /* Asking for dual wielding */
311 if (slot == INVEN_LARM)
313 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
316 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
318 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
321 /* Both arms are already used */
322 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
324 /* Restrict the choices */
325 item_tester_hook = item_tester_hook_mochikae;
328 q = _("どちらの手に装備しますか?", "Equip which hand? ");
329 s = _("おっと。", "Oops.");
331 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
332 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
333 need_switch_wielding = INVEN_RARM;
339 /* Choose a ring slot */
340 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
342 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
346 q = _("どちらの手に装備しますか?", "Equip which hand? ");
348 s = _("おっと。", "Oops.");
350 /* Restrict the choices */
351 select_ring_slot = TRUE;
352 item_tester_no_ryoute = TRUE;
354 if (!get_item(&slot, q, s, (USE_EQUIP)))
356 select_ring_slot = FALSE;
359 select_ring_slot = FALSE;
363 /* Prevent wielding into a cursed slot */
364 if (object_is_cursed(&inventory[slot]))
367 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
371 msg_format("%s%sは呪われているようだ。",
372 describe_use(slot) , o_name );
374 msg_format("The %s you are %s appears to be cursed.",
375 o_name, describe_use(slot));
378 /* Cancel the command */
383 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
384 ((o_ptr->ident & IDENT_SENSE) &&
385 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
387 char dummy[MAX_NLEN+80];
390 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
391 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
393 if (!get_check(dummy)) return;
396 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
398 char dummy[MAX_NLEN+80];
401 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
404 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
406 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
407 sprintf(dummy, "Do you become a vampire?");
410 if (!get_check(dummy)) return;
413 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
415 object_type *slot_o_ptr = &inventory[slot];
416 object_type *switch_o_ptr = &inventory[need_switch_wielding];
417 object_type object_tmp;
418 object_type *otmp_ptr = &object_tmp;
419 char switch_name[MAX_NLEN];
421 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
423 object_copy(otmp_ptr, switch_o_ptr);
424 object_copy(switch_o_ptr, slot_o_ptr);
425 object_copy(slot_o_ptr, otmp_ptr);
427 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
428 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
429 (left_hander ? _("右手", "right") : _("左手", "left")));
430 slot = need_switch_wielding;
433 check_find_art_quest_completion(o_ptr);
435 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
437 identify_item(o_ptr);
439 /* Auto-inscription */
440 autopick_alter_item(item, FALSE);
444 p_ptr->energy_use = 100;
446 /* Get local object */
449 /* Obtain local object */
450 object_copy(q_ptr, o_ptr);
452 /* Modify quantity */
455 /* Decrease the item (from the pack) */
458 inven_item_increase(item, -1);
459 inven_item_optimize(item);
462 /* Decrease the item (from the floor) */
465 floor_item_increase(0 - item, -1);
466 floor_item_optimize(0 - item);
469 /* Access the wield slot */
470 o_ptr = &inventory[slot];
472 /* Take off existing item */
475 /* Take off existing item */
476 (void)inven_takeoff(slot, 255);
479 /* Wear the new stuff */
480 object_copy(o_ptr, q_ptr);
482 /* Player touches it */
483 o_ptr->marked |= OM_TOUCHED;
485 /* Increase the weight */
486 p_ptr->total_weight += q_ptr->weight;
488 /* Increment the equip counter by hand */
492 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
493 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
494 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
496 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
497 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
498 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
501 /* Where is the item now */
505 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
506 act = STR_WIELD_ARMS;
508 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
512 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
513 act = STR_WIELD_ARMS;
515 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
519 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
523 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
527 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
531 /* Describe the result */
532 object_desc(o_name, o_ptr, 0);
535 msg_format(act, o_name, index_to_label(slot));
539 if (object_is_cursed(o_ptr))
541 /* Warn the player */
542 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
543 chg_virtue(V_HARMONY, -1);
546 o_ptr->ident |= (IDENT_SENSE);
549 /* The Stone Mask make the player turn into a vampire! */
550 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
552 /* Turn into a vampire */
553 change_race(RACE_VAMPIRE, "");
556 /* Recalculate bonuses */
557 p_ptr->update |= (PU_BONUS);
559 /* Recalculate torch */
560 p_ptr->update |= (PU_TORCH);
562 /* Recalculate mana */
563 p_ptr->update |= (PU_MANA);
565 p_ptr->redraw |= (PR_EQUIPPY);
568 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
575 * @param item 持ち替えを行いたい装備部位ID
578 void kamaenaoshi(int item)
580 object_type *o_ptr, *new_o_ptr;
581 char o_name[MAX_NLEN];
583 if (item == INVEN_RARM)
585 if (buki_motteruka(INVEN_LARM))
587 o_ptr = &inventory[INVEN_LARM];
588 object_desc(o_name, o_ptr, 0);
590 if (!object_is_cursed(o_ptr))
592 new_o_ptr = &inventory[INVEN_RARM];
593 object_copy(new_o_ptr, o_ptr);
594 p_ptr->total_weight += o_ptr->weight;
595 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
596 inven_item_optimize(INVEN_LARM);
597 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
598 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
600 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
601 (left_hander ? _("左手", "left") : _("右手", "right")));
605 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
606 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
610 else if (item == INVEN_LARM)
612 o_ptr = &inventory[INVEN_RARM];
613 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
615 if (buki_motteruka(INVEN_RARM))
617 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
618 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
620 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
622 new_o_ptr = &inventory[INVEN_LARM];
623 object_copy(new_o_ptr, o_ptr);
624 p_ptr->total_weight += o_ptr->weight;
625 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
626 inven_item_optimize(INVEN_RARM);
627 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
634 * @brief 装備を外すコマンドのメインルーチン / Take off an item
637 void do_cmd_takeoff(void)
645 if (p_ptr->special_defense & KATA_MUSOU)
647 set_action(ACTION_NONE);
650 item_tester_no_ryoute = TRUE;
653 q = "どれを装備からはずしますか? ";
656 q = "Take off which item? ";
657 s = "You are not wearing anything to take off.";
660 if (!get_item(&item, q, s, (USE_EQUIP))) return;
662 /* Get the item (in the pack) */
665 o_ptr = &inventory[item];
668 /* Get the item (on the floor) */
671 o_ptr = &o_list[0 - item];
676 if (object_is_cursed(o_ptr))
678 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
681 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
687 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
689 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
691 /* Hack -- Assume felt */
692 o_ptr->ident |= (IDENT_SENSE);
694 o_ptr->curse_flags = 0L;
697 o_ptr->feeling = FEEL_NONE;
699 /* Recalculate the bonuses */
700 p_ptr->update |= (PU_BONUS);
703 p_ptr->window |= (PW_EQUIP);
705 msg_print(_("呪いを打ち破った。", "You break the curse."));
709 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
710 p_ptr->energy_use = 50;
715 /* Take a partial turn */
716 p_ptr->energy_use = 50;
718 /* Take off the item */
719 (void)inven_takeoff(item, 255);
725 p_ptr->redraw |= (PR_EQUIPPY);
730 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
733 void do_cmd_drop(void)
742 if (p_ptr->special_defense & KATA_MUSOU)
744 set_action(ACTION_NONE);
747 item_tester_no_ryoute = TRUE;
750 q = "どのアイテムを落としますか? ";
751 s = "落とせるアイテムを持っていない。";
753 q = "Drop which item? ";
754 s = "You have nothing to drop.";
757 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
759 /* Get the item (in the pack) */
762 o_ptr = &inventory[item];
765 /* Get the item (on the floor) */
768 o_ptr = &o_list[0 - item];
772 /* Hack -- Cannot remove cursed items */
773 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
776 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
782 /* See how many items */
783 if (o_ptr->number > 1)
786 amt = get_quantity(NULL, o_ptr->number);
788 /* Allow user abort */
789 if (amt <= 0) return;
793 /* Take a partial turn */
794 p_ptr->energy_use = 50;
796 /* Drop (some of) the item */
797 inven_drop(item, amt);
799 if (item >= INVEN_RARM)
805 p_ptr->redraw |= (PR_EQUIPPY);
809 * @brief オブジェクトが高位の魔法書かどうかを判定する
810 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
811 * @return オブジェクトが高位の魔法書ならばTRUEを返す
813 static bool high_level_book(object_type *o_ptr)
815 if ((o_ptr->tval == TV_LIFE_BOOK) ||
816 (o_ptr->tval == TV_SORCERY_BOOK) ||
817 (o_ptr->tval == TV_NATURE_BOOK) ||
818 (o_ptr->tval == TV_CHAOS_BOOK) ||
819 (o_ptr->tval == TV_DEATH_BOOK) ||
820 (o_ptr->tval == TV_TRUMP_BOOK) ||
821 (o_ptr->tval == TV_CRAFT_BOOK) ||
822 (o_ptr->tval == TV_DAEMON_BOOK) ||
823 (o_ptr->tval == TV_CRUSADE_BOOK) ||
824 (o_ptr->tval == TV_MUSIC_BOOK) ||
825 (o_ptr->tval == TV_HEX_BOOK))
838 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
841 void do_cmd_destroy(void)
843 OBJECT_IDX item, amt = 1;
850 object_type *q_ptr = &forge;
852 char o_name[MAX_NLEN];
854 char out_val[MAX_NLEN+40];
858 if (p_ptr->special_defense & KATA_MUSOU)
860 set_action(ACTION_NONE);
863 /* Hack -- force destruction */
864 if (command_arg > 0) force = TRUE;
869 q = "どのアイテムを壊しますか? ";
870 s = "壊せるアイテムを持っていない。";
872 q = "Destroy which item? ";
873 s = "You have nothing to destroy.";
876 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
878 /* Get the item (in the pack) */
881 o_ptr = &inventory[item];
884 /* Get the item (on the floor) */
887 o_ptr = &o_list[0 - item];
890 /* Verify unless quantity given beforehand */
891 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
893 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
895 /* Make a verification */
896 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
899 /* HACK : Add the line to message buffer */
900 message_add(out_val);
901 p_ptr->window |= (PW_MESSAGE);
904 /* Get an acceptable answer */
914 /* Erase the prompt */
918 if (i == 'y' || i == 'Y')
922 if (i == ESCAPE || i == 'n' || i == 'N')
929 /* Add an auto-destroy preference line */
930 if (autopick_autoregister(o_ptr))
932 /* Auto-destroy it */
933 autopick_alter_item(item, TRUE);
936 /* The object is already destroyed. */
942 /* See how many items */
943 if (o_ptr->number > 1)
946 amt = get_quantity(NULL, o_ptr->number);
948 /* Allow user abort */
949 if (amt <= 0) return;
953 /* Describe the object */
954 old_number = o_ptr->number;
956 object_desc(o_name, o_ptr, 0);
957 o_ptr->number = old_number;
960 p_ptr->energy_use = 100;
962 /* Artifacts cannot be destroyed */
963 if (!can_player_destroy_object(o_ptr))
965 p_ptr->energy_use = 0;
968 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
973 object_copy(q_ptr, o_ptr);
976 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
977 sound(SOUND_DESTITEM);
979 /* Reduce the charges of rods/wands */
980 reduce_charges(o_ptr, amt);
982 /* Eliminate the item (from the pack) */
985 inven_item_increase(item, -amt);
986 inven_item_describe(item);
987 inven_item_optimize(item);
990 /* Eliminate the item (from the floor) */
993 floor_item_increase(0 - item, -amt);
994 floor_item_describe(0 - item);
995 floor_item_optimize(0 - item);
998 if (high_level_book(q_ptr))
1000 bool gain_expr = FALSE;
1002 if (p_ptr->prace == RACE_ANDROID)
1005 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
1009 else if (p_ptr->pclass == CLASS_PALADIN)
1011 if (is_good_realm(p_ptr->realm1))
1013 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1017 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1021 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
1023 s32b tester_exp = p_ptr->max_exp / 20;
1024 if (tester_exp > 10000) tester_exp = 10000;
1025 if (q_ptr->sval < 3) tester_exp /= 4;
1026 if (tester_exp<1) tester_exp = 1;
1028 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
1029 gain_exp(tester_exp * amt);
1031 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
1033 chg_virtue(V_UNLIFE, 1);
1034 chg_virtue(V_VITALITY, -1);
1036 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
1038 chg_virtue(V_UNLIFE, -1);
1039 chg_virtue(V_VITALITY, 1);
1042 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
1043 chg_virtue(V_ENCHANT, -1);
1045 if (object_value_real(q_ptr) > 30000)
1046 chg_virtue(V_SACRIFICE, 2);
1048 else if (object_value_real(q_ptr) > 10000)
1049 chg_virtue(V_SACRIFICE, 1);
1052 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
1053 chg_virtue(V_HARMONY, 1);
1055 if (item >= INVEN_RARM) calc_android_exp();
1060 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
1063 void do_cmd_observe(void)
1067 char o_name[MAX_NLEN];
1071 item_tester_no_ryoute = TRUE;
1074 q = "どのアイテムを調べますか? ";
1075 s = "調べられるアイテムがない。";
1077 q = "Examine which item? ";
1078 s = "You have nothing to examine.";
1081 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1083 /* Get the item (in the pack) */
1086 o_ptr = &inventory[item];
1089 /* Get the item (on the floor) */
1092 o_ptr = &o_list[0 - item];
1096 /* Require full knowledge */
1097 if (!(o_ptr->ident & IDENT_MENTAL))
1099 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1105 object_desc(o_name, o_ptr, 0);
1108 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1109 /* Describe it fully */
1110 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1116 * @brief アイテムの銘を消すコマンドのメインルーチン
1117 * Remove the inscription from an object XXX Mention item (when done)?
1120 void do_cmd_uninscribe(void)
1126 item_tester_no_ryoute = TRUE;
1129 q = "どのアイテムの銘を消しますか? ";
1130 s = "銘を消せるアイテムがない。";
1132 q = "Un-inscribe which item? ";
1133 s = "You have nothing to un-inscribe.";
1136 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1138 /* Get the item (in the pack) */
1141 o_ptr = &inventory[item];
1144 /* Get the item (on the floor) */
1147 o_ptr = &o_list[0 - item];
1150 /* Nothing to remove */
1151 if (!o_ptr->inscription)
1153 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1158 msg_print(_("銘を消した。", "Inscription removed."));
1160 /* Remove the incription */
1161 o_ptr->inscription = 0;
1163 /* Combine the pack */
1164 p_ptr->notice |= (PN_COMBINE);
1167 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1169 /* .や$の関係で, 再計算が必要なはず -- henkma */
1170 p_ptr->update |= (PU_BONUS);
1176 * @brief アイテムの銘を刻むコマンドのメインルーチン
1177 * Inscribe an object with a comment
1180 void do_cmd_inscribe(void)
1184 char o_name[MAX_NLEN];
1188 item_tester_no_ryoute = TRUE;
1191 q = "どのアイテムに銘を刻みますか? ";
1192 s = "銘を刻めるアイテムがない。";
1194 q = "Inscribe which item? ";
1195 s = "You have nothing to inscribe.";
1198 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1200 /* Get the item (in the pack) */
1203 o_ptr = &inventory[item];
1206 /* Get the item (on the floor) */
1209 o_ptr = &o_list[0 - item];
1212 /* Describe the activity */
1213 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1216 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1219 /* Start with nothing */
1220 strcpy(out_val, "");
1222 /* Use old inscription */
1223 if (o_ptr->inscription)
1225 /* Start with the old inscription */
1226 strcpy(out_val, quark_str(o_ptr->inscription));
1229 /* Get a new inscription (possibly empty) */
1230 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1232 /* Save the inscription */
1233 o_ptr->inscription = quark_add(out_val);
1235 /* Combine the pack */
1236 p_ptr->notice |= (PN_COMBINE);
1239 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1241 /* .や$の関係で, 再計算が必要なはず -- henkma */
1242 p_ptr->update |= (PU_BONUS);
1249 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1250 * An "item_tester_hook" for refilling lanterns
1251 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1252 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1254 static bool item_tester_refill_lantern(object_type *o_ptr)
1256 /* Flasks of oil are okay */
1257 if (o_ptr->tval == TV_FLASK) return (TRUE);
1259 /* Laterns are okay */
1260 if ((o_ptr->tval == TV_LITE) &&
1261 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1263 /* Assume not okay */
1269 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1270 * Refill the players lamp (from the pack or floor)
1273 static void do_cmd_refill_lamp(void)
1283 /* Restrict the choices */
1284 item_tester_hook = item_tester_refill_lantern;
1288 q = "どの油つぼから注ぎますか? ";
1291 q = "Refill with which flask? ";
1292 s = "You have no flasks of oil.";
1295 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1297 /* Get the item (in the pack) */
1300 o_ptr = &inventory[item];
1303 /* Get the item (on the floor) */
1306 o_ptr = &o_list[0 - item];
1310 /* Take a partial turn */
1311 p_ptr->energy_use = 50;
1313 /* Access the lantern */
1314 j_ptr = &inventory[INVEN_LITE];
1317 j_ptr->xtra4 += o_ptr->xtra4;
1320 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1323 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1326 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1328 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1331 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1333 else if (j_ptr->xtra4 >= FUEL_LAMP)
1335 j_ptr->xtra4 = FUEL_LAMP;
1336 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1339 /* Decrease the item (from the pack) */
1342 inven_item_increase(item, -1);
1343 inven_item_describe(item);
1344 inven_item_optimize(item);
1347 /* Decrease the item (from the floor) */
1350 floor_item_increase(0 - item, -1);
1351 floor_item_describe(0 - item);
1352 floor_item_optimize(0 - item);
1355 /* Recalculate torch */
1356 p_ptr->update |= (PU_TORCH);
1361 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1362 * An "item_tester_hook" for refilling torches
1363 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1364 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1366 static bool item_tester_refill_torch(object_type *o_ptr)
1368 /* Torches are okay */
1369 if ((o_ptr->tval == TV_LITE) &&
1370 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1372 /* Assume not okay */
1378 * @brief 松明を束ねるコマンドのメインルーチン
1379 * Refuel the players torch (from the pack or floor)
1382 static void do_cmd_refill_torch(void)
1392 /* Restrict the choices */
1393 item_tester_hook = item_tester_refill_torch;
1397 q = "どの松明で明かりを強めますか? ";
1400 q = "Refuel with which torch? ";
1401 s = "You have no extra torches.";
1404 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1406 /* Get the item (in the pack) */
1409 o_ptr = &inventory[item];
1412 /* Get the item (on the floor) */
1415 o_ptr = &o_list[0 - item];
1419 /* Take a partial turn */
1420 p_ptr->energy_use = 50;
1422 /* Access the primary torch */
1423 j_ptr = &inventory[INVEN_LITE];
1426 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1429 msg_print(_("松明を結合した。", "You combine the torches."));
1432 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1435 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1437 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1440 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1442 /* Over-fuel message */
1443 else if (j_ptr->xtra4 >= FUEL_TORCH)
1445 j_ptr->xtra4 = FUEL_TORCH;
1446 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1449 /* Refuel message */
1452 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1455 /* Decrease the item (from the pack) */
1458 inven_item_increase(item, -1);
1459 inven_item_describe(item);
1460 inven_item_optimize(item);
1463 /* Decrease the item (from the floor) */
1466 floor_item_increase(0 - item, -1);
1467 floor_item_describe(0 - item);
1468 floor_item_optimize(0 - item);
1471 /* Recalculate torch */
1472 p_ptr->update |= (PU_TORCH);
1477 * @brief 燃料を補充するコマンドのメインルーチン
1478 * Refill the players lamp, or restock his torches
1481 void do_cmd_refill(void)
1486 o_ptr = &inventory[INVEN_LITE];
1488 if (p_ptr->special_defense & KATA_MUSOU)
1490 set_action(ACTION_NONE);
1494 if (o_ptr->tval != TV_LITE)
1496 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1500 else if (o_ptr->sval == SV_LITE_LANTERN)
1502 do_cmd_refill_lamp();
1506 else if (o_ptr->sval == SV_LITE_TORCH)
1508 do_cmd_refill_torch();
1511 /* No torch to refill */
1514 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1520 * @brief ターゲットを設定するコマンドのメインルーチン
1524 void do_cmd_target(void)
1527 if (target_set(TARGET_KILL))
1529 msg_print(_("ターゲット決定。", "Target Selected."));
1532 /* Target aborted */
1535 msg_print(_("ターゲット解除。", "Target Aborted."));
1542 * @brief 周囲を見渡すコマンドのメインルーチン
1546 void do_cmd_look(void)
1549 p_ptr->window |= PW_MONSTER_LIST;
1554 if (target_set(TARGET_LOOK))
1556 msg_print(_("ターゲット決定。", "Target Selected."));
1562 * @brief 位置を確認するコマンドのメインルーチン
1563 * Allow the player to examine other sectors on the map
1566 void do_cmd_locate(void)
1568 int dir, y1, x1, y2, x2;
1577 get_screen_size(&wid, &hgt);
1580 /* Start at current panel */
1581 y2 = y1 = panel_row_min;
1582 x2 = x1 = panel_col_min;
1584 /* Show panels until done */
1587 /* Describe the location */
1588 if ((y2 == y1) && (x2 == x1))
1591 strcpy(tmp_val, "真上");
1600 sprintf(tmp_val, "%s%s",
1601 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1602 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1604 sprintf(tmp_val, "%s%s of",
1605 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1606 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1611 /* Prepare to ask which way to look */
1612 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1613 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1614 y2 / (hgt / 2), y2 % (hgt / 2),
1615 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1617 /* Assume no direction */
1620 /* Get a direction */
1625 /* Get a command (or Cancel) */
1626 if (!get_com(out_val, &command, TRUE)) break;
1628 /* Extract the action (if any) */
1629 dir = get_keymap_dir(command);
1638 /* Apply the motion */
1639 if (change_panel(ddy[dir], ddx[dir]))
1647 /* Recenter the map around the player */
1651 p_ptr->update |= (PU_MONSTERS);
1654 p_ptr->redraw |= (PR_MAP);
1657 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1666 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1667 * Sorting hook -- Comp function -- see below
1668 * @param u モンスター種族情報の入れるポインタ
1670 * @param a 比較するモンスター種族のID1
1671 * @param b 比較するモンスター種族のID2
1672 * @return 2の方が大きければTRUEを返す
1673 * We use "u" to point to array of monster indexes,
1674 * and "v" to select the type of sorting to perform on "u".
1676 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1678 u16b *who = (u16b*)(u);
1680 u16b *why = (u16b*)(v);
1687 /* Sort by player kills */
1690 /* Extract player kills */
1691 z1 = r_info[w1].r_pkills;
1692 z2 = r_info[w2].r_pkills;
1694 /* Compare player kills */
1695 if (z1 < z2) return (TRUE);
1696 if (z1 > z2) return (FALSE);
1700 /* Sort by total kills */
1703 /* Extract total kills */
1704 z1 = r_info[w1].r_tkills;
1705 z2 = r_info[w2].r_tkills;
1707 /* Compare total kills */
1708 if (z1 < z2) return (TRUE);
1709 if (z1 > z2) return (FALSE);
1713 /* Sort by monster level */
1716 /* Extract levels */
1717 z1 = r_info[w1].level;
1718 z2 = r_info[w2].level;
1720 /* Compare levels */
1721 if (z1 < z2) return (TRUE);
1722 if (z1 > z2) return (FALSE);
1726 /* Sort by monster experience */
1729 /* Extract experience */
1730 z1 = r_info[w1].mexp;
1731 z2 = r_info[w2].mexp;
1733 /* Compare experience */
1734 if (z1 < z2) return (TRUE);
1735 if (z1 > z2) return (FALSE);
1739 /* Compare indexes */
1745 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1746 * Sorting hook -- Swap function -- see below
1747 * @param u モンスター種族情報の入れるポインタ
1749 * @param a スワップするモンスター種族のID1
1750 * @param b スワップするモンスター種族のID2
1753 * We use "u" to point to array of monster indexes,
1754 * and "v" to select the type of sorting to perform.
1756 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1758 u16b *who = (u16b*)(u);
1774 * @brief モンスターの思い出を見るコマンドのメインルーチン
1775 * Identify a character, allow recall of monsters
1779 * Several "special" responses recall "multiple" monsters:
1781 * ^U (all unique monsters)
1782 * ^N (all non-unique monsters)
1784 * The responses may be sorted in several ways, see below.
1786 * Note that the player ghosts are ignored. XXX XXX XXX
1789 void do_cmd_query_symbol(void)
1803 bool recall = FALSE;
1808 /* Get a character, or abort */
1809 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1810 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1812 /* Find that character info, and describe it */
1813 for (i = 0; ident_info[i]; ++i)
1815 if (sym == ident_info[i][0]) break;
1819 if (sym == KTRL('A'))
1822 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1824 else if (sym == KTRL('U'))
1827 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1829 else if (sym == KTRL('N'))
1832 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1834 else if (sym == KTRL('R'))
1837 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1839 /* XTRA HACK WHATSEARCH */
1840 else if (sym == KTRL('M'))
1843 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1848 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1850 else if (ident_info[i])
1852 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1856 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1859 /* Display the result */
1862 /* Allocate the "who" array */
1863 C_MAKE(who, max_r_idx, IDX);
1865 /* Collect matching monsters */
1866 for (n = 0, i = 1; i < max_r_idx; i++)
1868 monster_race *r_ptr = &r_info[i];
1870 /* Nothing to recall */
1871 if (!cheat_know && !r_ptr->r_sights) continue;
1873 /* Require non-unique monsters if needed */
1874 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1876 /* Require unique monsters if needed */
1877 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1879 /* Require ridable monsters if needed */
1880 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1882 /* XTRA HACK WHATSEARCH */
1888 for (xx=0; temp[xx] && xx<80; xx++)
1891 if (iskanji( temp[xx])) { xx++; continue; }
1893 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1897 strcpy(temp2, r_name+r_ptr->E_name);
1899 strcpy(temp2, r_name+r_ptr->name);
1901 for (xx=0; temp2[xx] && xx<80; xx++)
1902 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1905 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) )
1907 if (my_strstr(temp2, temp))
1912 /* Collect "appropriate" monsters */
1913 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1916 /* Nothing to recall */
1919 /* Free the "who" array */
1920 C_KILL(who, max_r_idx, IDX);
1926 /* Prompt XXX XXX XXX */
1927 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1938 /* Select the sort method */
1939 ang_sort_comp = ang_sort_comp_hook;
1940 ang_sort_swap = ang_sort_swap_hook;
1942 /* Sort the array */
1943 ang_sort(who, &why, n);
1945 /* Sort by kills (and level) */
1952 /* Catch "escape" */
1955 /* Free the "who" array */
1956 C_KILL(who, max_r_idx, IDX);
1961 /* Sort if needed */
1964 /* Select the sort method */
1965 ang_sort_comp = ang_sort_comp_hook;
1966 ang_sort_swap = ang_sort_swap_hook;
1968 /* Sort the array */
1969 ang_sort(who, &why, n);
1973 /* Start at the end */
1976 /* Scan the monster memory */
1979 /* Extract a race */
1982 /* Hack -- Auto-recall */
1983 monster_race_track(r_idx);
1985 /* Hack -- Handle stuff */
1994 /* Save the screen */
1997 /* Recall on screen */
1998 screen_roff(who[i], 0);
2001 /* Hack -- Begin the prompt */
2004 /* Hack -- Complete the prompt */
2005 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
2017 /* Normal commands */
2018 if (query != 'r') break;
2025 if (query == ESCAPE) break;
2027 /* Move to "prev" monster */
2033 if (!expand_list) break;
2037 /* Move to "next" monster */
2043 if (!expand_list) break;
2048 /* Free the "who" array */
2049 C_KILL(who, max_r_idx, IDX);
2051 /* Re-display the identity */