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)
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)
741 if (p_ptr->special_defense & KATA_MUSOU)
743 set_action(ACTION_NONE);
746 item_tester_no_ryoute = TRUE;
749 q = "どのアイテムを落としますか? ";
750 s = "落とせるアイテムを持っていない。";
752 q = "Drop which item? ";
753 s = "You have nothing to drop.";
756 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
758 /* Get the item (in the pack) */
761 o_ptr = &inventory[item];
764 /* Get the item (on the floor) */
767 o_ptr = &o_list[0 - item];
771 /* Hack -- Cannot remove cursed items */
772 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
775 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
781 /* See how many items */
782 if (o_ptr->number > 1)
785 amt = get_quantity(NULL, o_ptr->number);
787 /* Allow user abort */
788 if (amt <= 0) return;
792 /* Take a partial turn */
793 p_ptr->energy_use = 50;
795 /* Drop (some of) the item */
796 inven_drop(item, amt);
798 if (item >= INVEN_RARM)
804 p_ptr->redraw |= (PR_EQUIPPY);
808 * @brief オブジェクトが高位の魔法書かどうかを判定する
809 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
810 * @return オブジェクトが高位の魔法書ならばTRUEを返す
812 static bool high_level_book(object_type *o_ptr)
814 if ((o_ptr->tval == TV_LIFE_BOOK) ||
815 (o_ptr->tval == TV_SORCERY_BOOK) ||
816 (o_ptr->tval == TV_NATURE_BOOK) ||
817 (o_ptr->tval == TV_CHAOS_BOOK) ||
818 (o_ptr->tval == TV_DEATH_BOOK) ||
819 (o_ptr->tval == TV_TRUMP_BOOK) ||
820 (o_ptr->tval == TV_CRAFT_BOOK) ||
821 (o_ptr->tval == TV_DAEMON_BOOK) ||
822 (o_ptr->tval == TV_CRUSADE_BOOK) ||
823 (o_ptr->tval == TV_MUSIC_BOOK) ||
824 (o_ptr->tval == TV_HEX_BOOK))
837 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
840 void do_cmd_destroy(void)
849 object_type *q_ptr = &forge;
851 char o_name[MAX_NLEN];
853 char out_val[MAX_NLEN+40];
857 if (p_ptr->special_defense & KATA_MUSOU)
859 set_action(ACTION_NONE);
862 /* Hack -- force destruction */
863 if (command_arg > 0) force = TRUE;
868 q = "どのアイテムを壊しますか? ";
869 s = "壊せるアイテムを持っていない。";
871 q = "Destroy which item? ";
872 s = "You have nothing to destroy.";
875 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
877 /* Get the item (in the pack) */
880 o_ptr = &inventory[item];
883 /* Get the item (on the floor) */
886 o_ptr = &o_list[0 - item];
889 /* Verify unless quantity given beforehand */
890 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
892 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
894 /* Make a verification */
895 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
898 /* HACK : Add the line to message buffer */
899 message_add(out_val);
900 p_ptr->window |= (PW_MESSAGE);
903 /* Get an acceptable answer */
913 /* Erase the prompt */
917 if (i == 'y' || i == 'Y')
921 if (i == ESCAPE || i == 'n' || i == 'N')
928 /* Add an auto-destroy preference line */
929 if (autopick_autoregister(o_ptr))
931 /* Auto-destroy it */
932 autopick_alter_item(item, TRUE);
935 /* The object is already destroyed. */
941 /* See how many items */
942 if (o_ptr->number > 1)
945 amt = get_quantity(NULL, o_ptr->number);
947 /* Allow user abort */
948 if (amt <= 0) return;
952 /* Describe the object */
953 old_number = o_ptr->number;
955 object_desc(o_name, o_ptr, 0);
956 o_ptr->number = old_number;
959 p_ptr->energy_use = 100;
961 /* Artifacts cannot be destroyed */
962 if (!can_player_destroy_object(o_ptr))
964 p_ptr->energy_use = 0;
967 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
972 object_copy(q_ptr, o_ptr);
975 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
976 sound(SOUND_DESTITEM);
978 /* Reduce the charges of rods/wands */
979 reduce_charges(o_ptr, amt);
981 /* Eliminate the item (from the pack) */
984 inven_item_increase(item, -amt);
985 inven_item_describe(item);
986 inven_item_optimize(item);
989 /* Eliminate the item (from the floor) */
992 floor_item_increase(0 - item, -amt);
993 floor_item_describe(0 - item);
994 floor_item_optimize(0 - item);
997 if (high_level_book(q_ptr))
999 bool gain_expr = FALSE;
1001 if (p_ptr->prace == RACE_ANDROID)
1004 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
1008 else if (p_ptr->pclass == CLASS_PALADIN)
1010 if (is_good_realm(p_ptr->realm1))
1012 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1016 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1020 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
1022 s32b tester_exp = p_ptr->max_exp / 20;
1023 if (tester_exp > 10000) tester_exp = 10000;
1024 if (q_ptr->sval < 3) tester_exp /= 4;
1025 if (tester_exp<1) tester_exp = 1;
1027 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
1028 gain_exp(tester_exp * amt);
1030 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
1032 chg_virtue(V_UNLIFE, 1);
1033 chg_virtue(V_VITALITY, -1);
1035 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
1037 chg_virtue(V_UNLIFE, -1);
1038 chg_virtue(V_VITALITY, 1);
1041 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
1042 chg_virtue(V_ENCHANT, -1);
1044 if (object_value_real(q_ptr) > 30000)
1045 chg_virtue(V_SACRIFICE, 2);
1047 else if (object_value_real(q_ptr) > 10000)
1048 chg_virtue(V_SACRIFICE, 1);
1051 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
1052 chg_virtue(V_HARMONY, 1);
1054 if (item >= INVEN_RARM) calc_android_exp();
1059 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
1062 void do_cmd_observe(void)
1068 char o_name[MAX_NLEN];
1072 item_tester_no_ryoute = TRUE;
1075 q = "どのアイテムを調べますか? ";
1076 s = "調べられるアイテムがない。";
1078 q = "Examine which item? ";
1079 s = "You have nothing to examine.";
1082 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1084 /* Get the item (in the pack) */
1087 o_ptr = &inventory[item];
1090 /* Get the item (on the floor) */
1093 o_ptr = &o_list[0 - item];
1097 /* Require full knowledge */
1098 if (!(o_ptr->ident & IDENT_MENTAL))
1100 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1106 object_desc(o_name, o_ptr, 0);
1109 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1110 /* Describe it fully */
1111 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1117 * @brief アイテムの銘を消すコマンドのメインルーチン
1118 * Remove the inscription from an object XXX Mention item (when done)?
1121 void do_cmd_uninscribe(void)
1129 item_tester_no_ryoute = TRUE;
1132 q = "どのアイテムの銘を消しますか? ";
1133 s = "銘を消せるアイテムがない。";
1135 q = "Un-inscribe which item? ";
1136 s = "You have nothing to un-inscribe.";
1139 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1141 /* Get the item (in the pack) */
1144 o_ptr = &inventory[item];
1147 /* Get the item (on the floor) */
1150 o_ptr = &o_list[0 - item];
1153 /* Nothing to remove */
1154 if (!o_ptr->inscription)
1156 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1161 msg_print(_("銘を消した。", "Inscription removed."));
1163 /* Remove the incription */
1164 o_ptr->inscription = 0;
1166 /* Combine the pack */
1167 p_ptr->notice |= (PN_COMBINE);
1170 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1172 /* .や$の関係で, 再計算が必要なはず -- henkma */
1173 p_ptr->update |= (PU_BONUS);
1179 * @brief アイテムの銘を刻むコマンドのメインルーチン
1180 * Inscribe an object with a comment
1183 void do_cmd_inscribe(void)
1189 char o_name[MAX_NLEN];
1195 item_tester_no_ryoute = TRUE;
1198 q = "どのアイテムに銘を刻みますか? ";
1199 s = "銘を刻めるアイテムがない。";
1201 q = "Inscribe which item? ";
1202 s = "You have nothing to inscribe.";
1205 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1207 /* Get the item (in the pack) */
1210 o_ptr = &inventory[item];
1213 /* Get the item (on the floor) */
1216 o_ptr = &o_list[0 - item];
1219 /* Describe the activity */
1220 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1223 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1226 /* Start with nothing */
1227 strcpy(out_val, "");
1229 /* Use old inscription */
1230 if (o_ptr->inscription)
1232 /* Start with the old inscription */
1233 strcpy(out_val, quark_str(o_ptr->inscription));
1236 /* Get a new inscription (possibly empty) */
1237 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1239 /* Save the inscription */
1240 o_ptr->inscription = quark_add(out_val);
1242 /* Combine the pack */
1243 p_ptr->notice |= (PN_COMBINE);
1246 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1248 /* .や$の関係で, 再計算が必要なはず -- henkma */
1249 p_ptr->update |= (PU_BONUS);
1256 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1257 * An "item_tester_hook" for refilling lanterns
1258 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1259 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1261 static bool item_tester_refill_lantern(object_type *o_ptr)
1263 /* Flasks of oil are okay */
1264 if (o_ptr->tval == TV_FLASK) return (TRUE);
1266 /* Laterns are okay */
1267 if ((o_ptr->tval == TV_LITE) &&
1268 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1270 /* Assume not okay */
1276 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1277 * Refill the players lamp (from the pack or floor)
1280 static void do_cmd_refill_lamp(void)
1290 /* Restrict the choices */
1291 item_tester_hook = item_tester_refill_lantern;
1295 q = "どの油つぼから注ぎますか? ";
1298 q = "Refill with which flask? ";
1299 s = "You have no flasks of oil.";
1302 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1304 /* Get the item (in the pack) */
1307 o_ptr = &inventory[item];
1310 /* Get the item (on the floor) */
1313 o_ptr = &o_list[0 - item];
1317 /* Take a partial turn */
1318 p_ptr->energy_use = 50;
1320 /* Access the lantern */
1321 j_ptr = &inventory[INVEN_LITE];
1324 j_ptr->xtra4 += o_ptr->xtra4;
1327 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1330 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1333 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1335 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1338 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1340 else if (j_ptr->xtra4 >= FUEL_LAMP)
1342 j_ptr->xtra4 = FUEL_LAMP;
1343 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1346 /* Decrease the item (from the pack) */
1349 inven_item_increase(item, -1);
1350 inven_item_describe(item);
1351 inven_item_optimize(item);
1354 /* Decrease the item (from the floor) */
1357 floor_item_increase(0 - item, -1);
1358 floor_item_describe(0 - item);
1359 floor_item_optimize(0 - item);
1362 /* Recalculate torch */
1363 p_ptr->update |= (PU_TORCH);
1368 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1369 * An "item_tester_hook" for refilling torches
1370 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1371 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1373 static bool item_tester_refill_torch(object_type *o_ptr)
1375 /* Torches are okay */
1376 if ((o_ptr->tval == TV_LITE) &&
1377 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1379 /* Assume not okay */
1385 * @brief 松明を束ねるコマンドのメインルーチン
1386 * Refuel the players torch (from the pack or floor)
1389 static void do_cmd_refill_torch(void)
1399 /* Restrict the choices */
1400 item_tester_hook = item_tester_refill_torch;
1404 q = "どの松明で明かりを強めますか? ";
1407 q = "Refuel with which torch? ";
1408 s = "You have no extra torches.";
1411 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1413 /* Get the item (in the pack) */
1416 o_ptr = &inventory[item];
1419 /* Get the item (on the floor) */
1422 o_ptr = &o_list[0 - item];
1426 /* Take a partial turn */
1427 p_ptr->energy_use = 50;
1429 /* Access the primary torch */
1430 j_ptr = &inventory[INVEN_LITE];
1433 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1436 msg_print(_("松明を結合した。", "You combine the torches."));
1439 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1442 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1444 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1447 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1449 /* Over-fuel message */
1450 else if (j_ptr->xtra4 >= FUEL_TORCH)
1452 j_ptr->xtra4 = FUEL_TORCH;
1453 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1456 /* Refuel message */
1459 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1462 /* Decrease the item (from the pack) */
1465 inven_item_increase(item, -1);
1466 inven_item_describe(item);
1467 inven_item_optimize(item);
1470 /* Decrease the item (from the floor) */
1473 floor_item_increase(0 - item, -1);
1474 floor_item_describe(0 - item);
1475 floor_item_optimize(0 - item);
1478 /* Recalculate torch */
1479 p_ptr->update |= (PU_TORCH);
1484 * @brief 燃料を補充するコマンドのメインルーチン
1485 * Refill the players lamp, or restock his torches
1488 void do_cmd_refill(void)
1493 o_ptr = &inventory[INVEN_LITE];
1495 if (p_ptr->special_defense & KATA_MUSOU)
1497 set_action(ACTION_NONE);
1501 if (o_ptr->tval != TV_LITE)
1503 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1507 else if (o_ptr->sval == SV_LITE_LANTERN)
1509 do_cmd_refill_lamp();
1513 else if (o_ptr->sval == SV_LITE_TORCH)
1515 do_cmd_refill_torch();
1518 /* No torch to refill */
1521 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1527 * @brief ターゲットを設定するコマンドのメインルーチン
1531 void do_cmd_target(void)
1534 if (target_set(TARGET_KILL))
1536 msg_print(_("ターゲット決定。", "Target Selected."));
1539 /* Target aborted */
1542 msg_print(_("ターゲット解除。", "Target Aborted."));
1549 * @brief 周囲を見渡すコマンドのメインルーチン
1553 void do_cmd_look(void)
1556 p_ptr->window |= PW_MONSTER_LIST;
1561 if (target_set(TARGET_LOOK))
1563 msg_print(_("ターゲット決定。", "Target Selected."));
1569 * @brief 位置を確認するコマンドのメインルーチン
1570 * Allow the player to examine other sectors on the map
1573 void do_cmd_locate(void)
1575 int dir, y1, x1, y2, x2;
1584 get_screen_size(&wid, &hgt);
1587 /* Start at current panel */
1588 y2 = y1 = panel_row_min;
1589 x2 = x1 = panel_col_min;
1591 /* Show panels until done */
1594 /* Describe the location */
1595 if ((y2 == y1) && (x2 == x1))
1598 strcpy(tmp_val, "真上");
1607 sprintf(tmp_val, "%s%s",
1608 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1609 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1611 sprintf(tmp_val, "%s%s of",
1612 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1613 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1618 /* Prepare to ask which way to look */
1619 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1620 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1621 y2 / (hgt / 2), y2 % (hgt / 2),
1622 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1624 /* Assume no direction */
1627 /* Get a direction */
1632 /* Get a command (or Cancel) */
1633 if (!get_com(out_val, &command, TRUE)) break;
1635 /* Extract the action (if any) */
1636 dir = get_keymap_dir(command);
1645 /* Apply the motion */
1646 if (change_panel(ddy[dir], ddx[dir]))
1654 /* Recenter the map around the player */
1658 p_ptr->update |= (PU_MONSTERS);
1661 p_ptr->redraw |= (PR_MAP);
1664 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1673 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1674 * Sorting hook -- Comp function -- see below
1675 * @param u モンスター種族情報の入れるポインタ
1677 * @param a 比較するモンスター種族のID1
1678 * @param b 比較するモンスター種族のID2
1679 * @return 2の方が大きければTRUEを返す
1680 * We use "u" to point to array of monster indexes,
1681 * and "v" to select the type of sorting to perform on "u".
1683 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1685 u16b *who = (u16b*)(u);
1687 u16b *why = (u16b*)(v);
1694 /* Sort by player kills */
1697 /* Extract player kills */
1698 z1 = r_info[w1].r_pkills;
1699 z2 = r_info[w2].r_pkills;
1701 /* Compare player kills */
1702 if (z1 < z2) return (TRUE);
1703 if (z1 > z2) return (FALSE);
1707 /* Sort by total kills */
1710 /* Extract total kills */
1711 z1 = r_info[w1].r_tkills;
1712 z2 = r_info[w2].r_tkills;
1714 /* Compare total kills */
1715 if (z1 < z2) return (TRUE);
1716 if (z1 > z2) return (FALSE);
1720 /* Sort by monster level */
1723 /* Extract levels */
1724 z1 = r_info[w1].level;
1725 z2 = r_info[w2].level;
1727 /* Compare levels */
1728 if (z1 < z2) return (TRUE);
1729 if (z1 > z2) return (FALSE);
1733 /* Sort by monster experience */
1736 /* Extract experience */
1737 z1 = r_info[w1].mexp;
1738 z2 = r_info[w2].mexp;
1740 /* Compare experience */
1741 if (z1 < z2) return (TRUE);
1742 if (z1 > z2) return (FALSE);
1746 /* Compare indexes */
1752 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1753 * Sorting hook -- Swap function -- see below
1754 * @param u モンスター種族情報の入れるポインタ
1756 * @param a スワップするモンスター種族のID1
1757 * @param b スワップするモンスター種族のID2
1760 * We use "u" to point to array of monster indexes,
1761 * and "v" to select the type of sorting to perform.
1763 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1765 u16b *who = (u16b*)(u);
1781 * @brief モンスターの思い出を見るコマンドのメインルーチン
1782 * Identify a character, allow recall of monsters
1786 * Several "special" responses recall "multiple" monsters:
1788 * ^U (all unique monsters)
1789 * ^N (all non-unique monsters)
1791 * The responses may be sorted in several ways, see below.
1793 * Note that the player ghosts are ignored. XXX XXX XXX
1796 void do_cmd_query_symbol(void)
1809 bool recall = FALSE;
1814 /* Get a character, or abort */
1815 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1816 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1818 /* Find that character info, and describe it */
1819 for (i = 0; ident_info[i]; ++i)
1821 if (sym == ident_info[i][0]) break;
1825 if (sym == KTRL('A'))
1828 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1830 else if (sym == KTRL('U'))
1833 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1835 else if (sym == KTRL('N'))
1838 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1840 else if (sym == KTRL('R'))
1843 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1845 /* XTRA HACK WHATSEARCH */
1846 else if (sym == KTRL('M'))
1849 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1854 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1856 else if (ident_info[i])
1858 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1862 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1865 /* Display the result */
1868 /* Allocate the "who" array */
1869 C_MAKE(who, max_r_idx, u16b);
1871 /* Collect matching monsters */
1872 for (n = 0, i = 1; i < max_r_idx; i++)
1874 monster_race *r_ptr = &r_info[i];
1876 /* Nothing to recall */
1877 if (!cheat_know && !r_ptr->r_sights) continue;
1879 /* Require non-unique monsters if needed */
1880 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1882 /* Require unique monsters if needed */
1883 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1885 /* Require ridable monsters if needed */
1886 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1888 /* XTRA HACK WHATSEARCH */
1894 for (xx=0; temp[xx] && xx<80; xx++)
1897 if (iskanji( temp[xx])) { xx++; continue; }
1899 if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]);
1903 strcpy(temp2, r_name+r_ptr->E_name);
1905 strcpy(temp2, r_name+r_ptr->name);
1907 for (xx=0; temp2[xx] && xx<80; xx++)
1908 if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
1911 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) )
1913 if (my_strstr(temp2, temp))
1918 /* Collect "appropriate" monsters */
1919 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1922 /* Nothing to recall */
1925 /* Free the "who" array */
1926 C_KILL(who, max_r_idx, u16b);
1932 /* Prompt XXX XXX XXX */
1933 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1944 /* Select the sort method */
1945 ang_sort_comp = ang_sort_comp_hook;
1946 ang_sort_swap = ang_sort_swap_hook;
1948 /* Sort the array */
1949 ang_sort(who, &why, n);
1951 /* Sort by kills (and level) */
1958 /* Catch "escape" */
1961 /* Free the "who" array */
1962 C_KILL(who, max_r_idx, u16b);
1967 /* Sort if needed */
1970 /* Select the sort method */
1971 ang_sort_comp = ang_sort_comp_hook;
1972 ang_sort_swap = ang_sort_swap_hook;
1974 /* Sort the array */
1975 ang_sort(who, &why, n);
1979 /* Start at the end */
1982 /* Scan the monster memory */
1985 /* Extract a race */
1988 /* Hack -- Auto-recall */
1989 monster_race_track(r_idx);
1991 /* Hack -- Handle stuff */
2000 /* Save the screen */
2003 /* Recall on screen */
2004 screen_roff(who[i], 0);
2007 /* Hack -- Begin the prompt */
2010 /* Hack -- Complete the prompt */
2011 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
2023 /* Normal commands */
2024 if (query != 'r') break;
2031 if (query == ESCAPE) break;
2033 /* Move to "prev" monster */
2039 if (!expand_list) break;
2043 /* Move to "next" monster */
2049 if (!expand_list) break;
2054 /* Free the "who" array */
2055 C_KILL(who, max_r_idx, u16b);
2057 /* Re-display the identity */