3 * @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory commands
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 #include "cmd-activate.h"
18 #include "cmd-quaff.h"
20 #include "cmd-usestaff.h"
21 #include "cmd-zaprod.h"
22 #include "cmd-zapwand.h"
24 #include "object-hook.h"
28 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory
31 void do_cmd_inven(void)
36 /* Note that we are in "inventory" mode */
39 #ifdef ALLOW_EASY_FLOOR
41 /* Note that we are in "inventory" mode */
42 if (easy_floor) command_wrk = (USE_INVEN);
44 #endif /* ALLOW_EASY_FLOOR */
49 /* Hack -- show empty slots */
50 item_tester_full = TRUE;
52 /* Display the inventory */
55 /* Hack -- hide empty slots */
56 item_tester_full = FALSE;
59 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
60 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
61 (long int)((p_ptr->total_weight * 100) / weight_limit()));
63 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
64 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
65 (p_ptr->total_weight * 100) / weight_limit());
72 /* Get a new command */
73 command_new = inkey();
79 /* Process "Escape" */
80 if (command_new == ESCAPE)
85 Term_get_size(&wid, &hgt);
89 command_gap = wid - 30;
92 /* Process normal keys */
95 /* Hack -- Use "display" mode */
102 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
105 void do_cmd_equip(void)
110 /* Note that we are in "equipment" mode */
113 #ifdef ALLOW_EASY_FLOOR
115 /* Note that we are in "equipment" mode */
116 if (easy_floor) command_wrk = (USE_EQUIP);
118 #endif /* ALLOW_EASY_FLOOR */
120 /* Save the screen */
123 /* Hack -- show empty slots */
124 item_tester_full = TRUE;
126 /* Display the equipment */
129 /* Hack -- undo the hack above */
130 item_tester_full = FALSE;
134 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
135 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
136 (long int)((p_ptr->total_weight * 100) / weight_limit()));
138 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
139 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
140 (long int)((p_ptr->total_weight * 100) / weight_limit()));
147 /* Get a new command */
148 command_new = inkey();
150 /* Restore the screen */
154 /* Process "Escape" */
155 if (command_new == ESCAPE)
160 Term_get_size(&wid, &hgt);
164 command_gap = wid - 30;
167 /* Process normal keys */
170 /* Enter "display" mode */
178 bool select_ring_slot = FALSE;
181 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
184 void do_cmd_wield(void)
186 OBJECT_IDX item, slot;
195 char o_name[MAX_NLEN];
199 OBJECT_IDX need_switch_wielding = 0;
201 if (p_ptr->special_defense & KATA_MUSOU)
203 set_action(ACTION_NONE);
206 /* Restrict the choices */
207 item_tester_hook = item_tester_hook_wear;
209 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
210 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
212 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
214 /* Get the item (in the pack) */
217 o_ptr = &inventory[item];
220 /* Get the item (on the floor) */
223 o_ptr = &o_list[0 - item];
228 slot = wield_slot(o_ptr);
232 /* Shields and some misc. items */
237 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
239 /* Restrict the choices */
240 item_tester_hook = item_tester_hook_melee_weapon;
241 item_tester_no_ryoute = TRUE;
243 /* Choose a weapon from the equipment only */
244 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
245 s = _("おっと。", "Oops.");
246 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
247 if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
250 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
252 /* Both arms are already used by non-weapon */
253 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
254 inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
256 /* Restrict the choices */
257 item_tester_hook = item_tester_hook_mochikae;
260 q = _("どちらの手に装備しますか?", "Equip which hand? ");
261 s = _("おっと。", "Oops.");
262 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
271 /* Asking for dual wielding */
272 if (slot == INVEN_LARM)
274 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
277 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
279 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
282 /* Both arms are already used */
283 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
285 /* Restrict the choices */
286 item_tester_hook = item_tester_hook_mochikae;
289 q = _("どちらの手に装備しますか?", "Equip which hand? ");
290 s = _("おっと。", "Oops.");
292 if (!get_item(&slot, q, s, (USE_EQUIP))) return;
293 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
294 need_switch_wielding = INVEN_RARM;
300 /* Choose a ring slot */
301 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
303 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
307 q = _("どちらの手に装備しますか?", "Equip which hand? ");
309 s = _("おっと。", "Oops.");
311 /* Restrict the choices */
312 select_ring_slot = TRUE;
313 item_tester_no_ryoute = TRUE;
315 if (!get_item(&slot, q, s, (USE_EQUIP)))
317 select_ring_slot = FALSE;
320 select_ring_slot = FALSE;
324 /* Prevent wielding into a cursed slot */
325 if (object_is_cursed(&inventory[slot]))
328 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
331 msg_format("%s%sは呪われているようだ。",
332 describe_use(slot) , o_name );
334 msg_format("The %s you are %s appears to be cursed.",
335 o_name, describe_use(slot));
338 /* Cancel the command */
343 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
344 ((o_ptr->ident & IDENT_SENSE) &&
345 (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
347 char dummy[MAX_NLEN+80];
350 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
351 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
353 if (!get_check(dummy)) return;
356 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
358 char dummy[MAX_NLEN+80];
361 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
364 sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name);
366 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
367 sprintf(dummy, "Do you become a vampire?");
370 if (!get_check(dummy)) return;
373 if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
375 object_type *slot_o_ptr = &inventory[slot];
376 object_type *switch_o_ptr = &inventory[need_switch_wielding];
377 object_type object_tmp;
378 object_type *otmp_ptr = &object_tmp;
379 char switch_name[MAX_NLEN];
381 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
383 object_copy(otmp_ptr, switch_o_ptr);
384 object_copy(switch_o_ptr, slot_o_ptr);
385 object_copy(slot_o_ptr, otmp_ptr);
387 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
388 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) :
389 (left_hander ? _("右手", "right") : _("左手", "left")));
390 slot = need_switch_wielding;
393 check_find_art_quest_completion(o_ptr);
395 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
397 identify_item(o_ptr);
399 /* Auto-inscription */
400 autopick_alter_item(item, FALSE);
403 p_ptr->energy_use = 100;
405 /* Get local object */
408 /* Obtain local object */
409 object_copy(q_ptr, o_ptr);
411 /* Modify quantity */
414 /* Decrease the item (from the pack) */
417 inven_item_increase(item, -1);
418 inven_item_optimize(item);
421 /* Decrease the item (from the floor) */
424 floor_item_increase(0 - item, -1);
425 floor_item_optimize(0 - item);
428 /* Access the wield slot */
429 o_ptr = &inventory[slot];
431 /* Take off existing item */
434 /* Take off existing item */
435 (void)inven_takeoff(slot, 255);
438 /* Wear the new stuff */
439 object_copy(o_ptr, q_ptr);
441 /* Player touches it */
442 o_ptr->marked |= OM_TOUCHED;
444 /* Increase the weight */
445 p_ptr->total_weight += q_ptr->weight;
447 /* Increment the equip counter by hand */
451 #define STR_WIELD_RARM "%s(%c)を右手に装備した。"
452 #define STR_WIELD_LARM "%s(%c)を左手に装備した。"
453 #define STR_WIELD_ARMS "%s(%c)を両手で構えた。"
455 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
456 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
457 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
460 /* Where is the item now */
464 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
465 act = STR_WIELD_ARMS;
467 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
471 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
472 act = STR_WIELD_ARMS;
474 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
478 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
482 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
486 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
490 /* Describe the result */
491 object_desc(o_name, o_ptr, 0);
493 msg_format(act, o_name, index_to_label(slot));
497 if (object_is_cursed(o_ptr))
499 /* Warn the player */
500 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
501 chg_virtue(V_HARMONY, -1);
504 o_ptr->ident |= (IDENT_SENSE);
507 /* The Stone Mask make the player turn into a vampire! */
508 if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
510 /* Turn into a vampire */
511 change_race(RACE_VAMPIRE, "");
514 /* Recalculate bonuses */
515 p_ptr->update |= (PU_BONUS);
517 /* Recalculate torch */
518 p_ptr->update |= (PU_TORCH);
520 /* Recalculate mana */
521 p_ptr->update |= (PU_MANA);
523 p_ptr->redraw |= (PR_EQUIPPY);
525 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
532 * @param item 持ち替えを行いたい装備部位ID
535 void kamaenaoshi(INVENTORY_IDX item)
537 object_type *o_ptr, *new_o_ptr;
538 char o_name[MAX_NLEN];
540 if (item == INVEN_RARM)
542 if (buki_motteruka(INVEN_LARM))
544 o_ptr = &inventory[INVEN_LARM];
545 object_desc(o_name, o_ptr, 0);
547 if (!object_is_cursed(o_ptr))
549 new_o_ptr = &inventory[INVEN_RARM];
550 object_copy(new_o_ptr, o_ptr);
551 p_ptr->total_weight += o_ptr->weight;
552 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
553 inven_item_optimize(INVEN_LARM);
554 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
555 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
557 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name,
558 (left_hander ? _("左手", "left") : _("右手", "right")));
562 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
563 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
567 else if (item == INVEN_LARM)
569 o_ptr = &inventory[INVEN_RARM];
570 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
572 if (buki_motteruka(INVEN_RARM))
574 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
575 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
577 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
579 new_o_ptr = &inventory[INVEN_LARM];
580 object_copy(new_o_ptr, o_ptr);
581 p_ptr->total_weight += o_ptr->weight;
582 inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
583 inven_item_optimize(INVEN_RARM);
584 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
591 * @brief 装備を外すコマンドのメインルーチン / Take off an item
594 void do_cmd_takeoff(void)
600 if (p_ptr->special_defense & KATA_MUSOU)
602 set_action(ACTION_NONE);
605 item_tester_no_ryoute = TRUE;
607 q = _("どれを装備からはずしますか? ", "Take off which item? ");
608 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
610 if (!get_item(&item, q, s, (USE_EQUIP))) return;
612 /* Get the item (in the pack) */
615 o_ptr = &inventory[item];
618 /* Get the item (on the floor) */
621 o_ptr = &o_list[0 - item];
626 if (object_is_cursed(o_ptr))
628 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
630 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
636 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
638 msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
640 /* Hack -- Assume felt */
641 o_ptr->ident |= (IDENT_SENSE);
643 o_ptr->curse_flags = 0L;
646 o_ptr->feeling = FEEL_NONE;
648 /* Recalculate the bonuses */
649 p_ptr->update |= (PU_BONUS);
651 p_ptr->window |= (PW_EQUIP);
653 msg_print(_("呪いを打ち破った。", "You break the curse."));
657 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
658 p_ptr->energy_use = 50;
663 /* Take a partial turn */
664 p_ptr->energy_use = 50;
666 /* Take off the item */
667 (void)inven_takeoff(item, 255);
670 p_ptr->redraw |= (PR_EQUIPPY);
675 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
678 void do_cmd_drop(void)
687 if (p_ptr->special_defense & KATA_MUSOU)
689 set_action(ACTION_NONE);
692 item_tester_no_ryoute = TRUE;
693 q = _("どのアイテムを落としますか? ", "Drop which item? ");
694 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
696 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
698 /* Get the item (in the pack) */
701 o_ptr = &inventory[item];
704 /* Get the item (on the floor) */
707 o_ptr = &o_list[0 - item];
711 /* Hack -- Cannot remove cursed items */
712 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
714 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
720 /* See how many items */
721 if (o_ptr->number > 1)
724 amt = get_quantity(NULL, o_ptr->number);
726 /* Allow user abort */
727 if (amt <= 0) return;
731 /* Take a partial turn */
732 p_ptr->energy_use = 50;
734 /* Drop (some of) the item */
735 inven_drop(item, amt);
737 if (item >= INVEN_RARM)
743 p_ptr->redraw |= (PR_EQUIPPY);
747 * @brief オブジェクトが高位の魔法書かどうかを判定する
748 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
749 * @return オブジェクトが高位の魔法書ならばTRUEを返す
751 static bool high_level_book(object_type *o_ptr)
753 if ((o_ptr->tval == TV_LIFE_BOOK) ||
754 (o_ptr->tval == TV_SORCERY_BOOK) ||
755 (o_ptr->tval == TV_NATURE_BOOK) ||
756 (o_ptr->tval == TV_CHAOS_BOOK) ||
757 (o_ptr->tval == TV_DEATH_BOOK) ||
758 (o_ptr->tval == TV_TRUMP_BOOK) ||
759 (o_ptr->tval == TV_CRAFT_BOOK) ||
760 (o_ptr->tval == TV_DAEMON_BOOK) ||
761 (o_ptr->tval == TV_CRUSADE_BOOK) ||
762 (o_ptr->tval == TV_MUSIC_BOOK) ||
763 (o_ptr->tval == TV_HEX_BOOK))
776 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
779 void do_cmd_destroy(void)
789 object_type *q_ptr = &forge;
791 char o_name[MAX_NLEN];
792 char out_val[MAX_NLEN+40];
796 if (p_ptr->special_defense & KATA_MUSOU)
798 set_action(ACTION_NONE);
801 /* Hack -- force destruction */
802 if (command_arg > 0) force = TRUE;
804 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
805 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
807 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
809 /* Get the item (in the pack) */
812 o_ptr = &inventory[item];
815 /* Get the item (on the floor) */
818 o_ptr = &o_list[0 - item];
821 /* Verify unless quantity given beforehand */
822 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
824 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
826 /* Make a verification */
827 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
830 /* HACK : Add the line to message buffer */
831 message_add(out_val);
832 p_ptr->window |= (PW_MESSAGE);
835 /* Get an acceptable answer */
845 /* Erase the prompt */
849 if (i == 'y' || i == 'Y')
853 if (i == ESCAPE || i == 'n' || i == 'N')
860 /* Add an auto-destroy preference line */
861 if (autopick_autoregister(o_ptr))
863 /* Auto-destroy it */
864 autopick_alter_item(item, TRUE);
867 /* The object is already destroyed. */
873 /* See how many items */
874 if (o_ptr->number > 1)
877 amt = get_quantity(NULL, o_ptr->number);
879 /* Allow user abort */
880 if (amt <= 0) return;
884 /* Describe the object */
885 old_number = o_ptr->number;
887 object_desc(o_name, o_ptr, 0);
888 o_ptr->number = old_number;
890 p_ptr->energy_use = 100;
892 /* Artifacts cannot be destroyed */
893 if (!can_player_destroy_object(o_ptr))
895 p_ptr->energy_use = 0;
897 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
901 object_copy(q_ptr, o_ptr);
903 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
904 sound(SOUND_DESTITEM);
906 /* Reduce the charges of rods/wands */
907 reduce_charges(o_ptr, amt);
909 /* Eliminate the item (from the pack) */
912 inven_item_increase(item, -amt);
913 inven_item_describe(item);
914 inven_item_optimize(item);
917 /* Eliminate the item (from the floor) */
920 floor_item_increase(0 - item, -amt);
921 floor_item_describe(0 - item);
922 floor_item_optimize(0 - item);
925 if (high_level_book(q_ptr))
927 bool gain_expr = FALSE;
929 if (p_ptr->prace == RACE_ANDROID)
932 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
936 else if (p_ptr->pclass == CLASS_PALADIN)
938 if (is_good_realm(p_ptr->realm1))
940 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
944 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
948 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
950 s32b tester_exp = p_ptr->max_exp / 20;
951 if (tester_exp > 10000) tester_exp = 10000;
952 if (q_ptr->sval < 3) tester_exp /= 4;
953 if (tester_exp<1) tester_exp = 1;
955 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
956 gain_exp(tester_exp * amt);
958 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
960 chg_virtue(V_UNLIFE, 1);
961 chg_virtue(V_VITALITY, -1);
963 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
965 chg_virtue(V_UNLIFE, -1);
966 chg_virtue(V_VITALITY, 1);
969 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
970 chg_virtue(V_ENCHANT, -1);
972 if (object_value_real(q_ptr) > 30000)
973 chg_virtue(V_SACRIFICE, 2);
975 else if (object_value_real(q_ptr) > 10000)
976 chg_virtue(V_SACRIFICE, 1);
979 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
980 chg_virtue(V_HARMONY, 1);
982 if (item >= INVEN_RARM) calc_android_exp();
987 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
990 void do_cmd_observe(void)
994 char o_name[MAX_NLEN];
998 item_tester_no_ryoute = TRUE;
1000 q = _("どのアイテムを調べますか? ", "Examine which item? ");
1001 s = _("調べられるアイテムがない。", "You have nothing to examine.");
1003 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1005 /* Get the item (in the pack) */
1008 o_ptr = &inventory[item];
1011 /* Get the item (on the floor) */
1014 o_ptr = &o_list[0 - item];
1018 /* Require full knowledge */
1019 if (!(o_ptr->ident & IDENT_MENTAL))
1021 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
1027 object_desc(o_name, o_ptr, 0);
1030 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
1031 /* Describe it fully */
1032 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
1038 * @brief アイテムの銘を消すコマンドのメインルーチン
1039 * Remove the inscription from an object XXX Mention item (when done)?
1042 void do_cmd_uninscribe(void)
1048 item_tester_no_ryoute = TRUE;
1049 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
1050 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
1052 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1054 /* Get the item (in the pack) */
1057 o_ptr = &inventory[item];
1060 /* Get the item (on the floor) */
1063 o_ptr = &o_list[0 - item];
1066 /* Nothing to remove */
1067 if (!o_ptr->inscription)
1069 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
1073 msg_print(_("銘を消した。", "Inscription removed."));
1075 /* Remove the incription */
1076 o_ptr->inscription = 0;
1078 /* Combine the pack */
1079 p_ptr->notice |= (PN_COMBINE);
1081 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1083 /* .や$の関係で, 再計算が必要なはず -- henkma */
1084 p_ptr->update |= (PU_BONUS);
1090 * @brief アイテムの銘を刻むコマンドのメインルーチン
1091 * Inscribe an object with a comment
1094 void do_cmd_inscribe(void)
1098 char o_name[MAX_NLEN];
1102 item_tester_no_ryoute = TRUE;
1103 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1104 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1106 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1108 /* Get the item (in the pack) */
1111 o_ptr = &inventory[item];
1114 /* Get the item (on the floor) */
1117 o_ptr = &o_list[0 - item];
1120 /* Describe the activity */
1121 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1123 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
1126 /* Start with nothing */
1127 strcpy(out_val, "");
1129 /* Use old inscription */
1130 if (o_ptr->inscription)
1132 /* Start with the old inscription */
1133 strcpy(out_val, quark_str(o_ptr->inscription));
1136 /* Get a new inscription (possibly empty) */
1137 if (get_string(_("銘: ", "Inscription: "), out_val, 80))
1139 /* Save the inscription */
1140 o_ptr->inscription = quark_add(out_val);
1142 /* Combine the pack */
1143 p_ptr->notice |= (PN_COMBINE);
1145 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1147 /* .や$の関係で, 再計算が必要なはず -- henkma */
1148 p_ptr->update |= (PU_BONUS);
1155 * @brief オブジェクトがランタンの燃料になるかどうかを判定する
1156 * An "item_tester_hook" for refilling lanterns
1157 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1158 * @return オブジェクトがランタンの燃料になるならばTRUEを返す
1160 static bool item_tester_refill_lantern(object_type *o_ptr)
1162 /* Flasks of oil are okay */
1163 if (o_ptr->tval == TV_FLASK) return (TRUE);
1165 /* Laterns are okay */
1166 if ((o_ptr->tval == TV_LITE) &&
1167 (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1169 /* Assume not okay */
1175 * @brief ランタンに燃料を加えるコマンドのメインルーチン
1176 * Refill the players lamp (from the pack or floor)
1179 static void do_cmd_refill_lamp(void)
1189 /* Restrict the choices */
1190 item_tester_hook = item_tester_refill_lantern;
1193 q = "どの油つぼから注ぎますか? ";
1196 q = "Refill with which flask? ";
1197 s = "You have no flasks of oil.";
1200 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1202 /* Get the item (in the pack) */
1205 o_ptr = &inventory[item];
1208 /* Get the item (on the floor) */
1211 o_ptr = &o_list[0 - item];
1215 /* Take a partial turn */
1216 p_ptr->energy_use = 50;
1218 /* Access the lantern */
1219 j_ptr = &inventory[INVEN_LITE];
1222 j_ptr->xtra4 += o_ptr->xtra4;
1224 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
1227 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1230 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
1232 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1235 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
1237 else if (j_ptr->xtra4 >= FUEL_LAMP)
1239 j_ptr->xtra4 = FUEL_LAMP;
1240 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
1243 /* Decrease the item (from the pack) */
1246 inven_item_increase(item, -1);
1247 inven_item_describe(item);
1248 inven_item_optimize(item);
1251 /* Decrease the item (from the floor) */
1254 floor_item_increase(0 - item, -1);
1255 floor_item_describe(0 - item);
1256 floor_item_optimize(0 - item);
1259 /* Recalculate torch */
1260 p_ptr->update |= (PU_TORCH);
1265 * @brief オブジェクトが松明に束ねられるかどうかを判定する
1266 * An "item_tester_hook" for refilling torches
1267 * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1268 * @return オブジェクトが松明に束ねられるならばTRUEを返す
1270 static bool item_tester_refill_torch(object_type *o_ptr)
1272 /* Torches are okay */
1273 if ((o_ptr->tval == TV_LITE) &&
1274 (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1276 /* Assume not okay */
1282 * @brief 松明を束ねるコマンドのメインルーチン
1283 * Refuel the players torch (from the pack or floor)
1286 static void do_cmd_refill_torch(void)
1296 /* Restrict the choices */
1297 item_tester_hook = item_tester_refill_torch;
1300 q = "どの松明で明かりを強めますか? ";
1303 q = "Refuel with which torch? ";
1304 s = "You have no extra torches.";
1307 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1309 /* Get the item (in the pack) */
1312 o_ptr = &inventory[item];
1315 /* Get the item (on the floor) */
1318 o_ptr = &o_list[0 - item];
1322 /* Take a partial turn */
1323 p_ptr->energy_use = 50;
1325 /* Access the primary torch */
1326 j_ptr = &inventory[INVEN_LITE];
1329 j_ptr->xtra4 += o_ptr->xtra4 + 5;
1331 msg_print(_("松明を結合した。", "You combine the torches."));
1334 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1337 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1339 else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1342 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1344 /* Over-fuel message */
1345 else if (j_ptr->xtra4 >= FUEL_TORCH)
1347 j_ptr->xtra4 = FUEL_TORCH;
1348 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1351 /* Refuel message */
1354 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1357 /* Decrease the item (from the pack) */
1360 inven_item_increase(item, -1);
1361 inven_item_describe(item);
1362 inven_item_optimize(item);
1365 /* Decrease the item (from the floor) */
1368 floor_item_increase(0 - item, -1);
1369 floor_item_describe(0 - item);
1370 floor_item_optimize(0 - item);
1373 /* Recalculate torch */
1374 p_ptr->update |= (PU_TORCH);
1379 * @brief 燃料を補充するコマンドのメインルーチン
1380 * Refill the players lamp, or restock his torches
1383 void do_cmd_refill(void)
1388 o_ptr = &inventory[INVEN_LITE];
1390 if (p_ptr->special_defense & KATA_MUSOU)
1392 set_action(ACTION_NONE);
1396 if (o_ptr->tval != TV_LITE)
1398 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1402 else if (o_ptr->sval == SV_LITE_LANTERN)
1404 do_cmd_refill_lamp();
1408 else if (o_ptr->sval == SV_LITE_TORCH)
1410 do_cmd_refill_torch();
1413 /* No torch to refill */
1416 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1422 * @brief ターゲットを設定するコマンドのメインルーチン
1426 void do_cmd_target(void)
1429 if (target_set(TARGET_KILL))
1431 msg_print(_("ターゲット決定。", "Target Selected."));
1434 /* Target aborted */
1437 msg_print(_("ターゲット解除。", "Target Aborted."));
1444 * @brief 周囲を見渡すコマンドのメインルーチン
1448 void do_cmd_look(void)
1451 p_ptr->window |= PW_MONSTER_LIST;
1456 if (target_set(TARGET_LOOK))
1458 msg_print(_("ターゲット決定。", "Target Selected."));
1464 * @brief 位置を確認するコマンドのメインルーチン
1465 * Allow the player to examine other sectors on the map
1468 void do_cmd_locate(void)
1470 int dir, y1, x1, y2, x2;
1479 get_screen_size(&wid, &hgt);
1482 /* Start at current panel */
1483 y2 = y1 = panel_row_min;
1484 x2 = x1 = panel_col_min;
1486 /* Show panels until done */
1489 /* Describe the location */
1490 if ((y2 == y1) && (x2 == x1))
1493 strcpy(tmp_val, "真上");
1502 sprintf(tmp_val, "%s%s",
1503 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1504 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1506 sprintf(tmp_val, "%s%s of",
1507 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1508 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1513 /* Prepare to ask which way to look */
1514 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?",
1515 "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1516 y2 / (hgt / 2), y2 % (hgt / 2),
1517 x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1519 /* Assume no direction */
1522 /* Get a direction */
1527 /* Get a command (or Cancel) */
1528 if (!get_com(out_val, &command, TRUE)) break;
1530 /* Extract the action (if any) */
1531 dir = get_keymap_dir(command);
1540 /* Apply the motion */
1541 if (change_panel(ddy[dir], ddx[dir]))
1549 /* Recenter the map around the player */
1552 p_ptr->update |= (PU_MONSTERS);
1555 p_ptr->redraw |= (PR_MAP);
1557 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1566 * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1567 * Sorting hook -- Comp function -- see below
1568 * @param u モンスター種族情報の入れるポインタ
1570 * @param a 比較するモンスター種族のID1
1571 * @param b 比較するモンスター種族のID2
1572 * @return 2の方が大きければTRUEを返す
1573 * We use "u" to point to array of monster indexes,
1574 * and "v" to select the type of sorting to perform on "u".
1576 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1578 u16b *who = (u16b*)(u);
1580 u16b *why = (u16b*)(v);
1587 /* Sort by player kills */
1590 /* Extract player kills */
1591 z1 = r_info[w1].r_pkills;
1592 z2 = r_info[w2].r_pkills;
1594 /* Compare player kills */
1595 if (z1 < z2) return (TRUE);
1596 if (z1 > z2) return (FALSE);
1600 /* Sort by total kills */
1603 /* Extract total kills */
1604 z1 = r_info[w1].r_tkills;
1605 z2 = r_info[w2].r_tkills;
1607 /* Compare total kills */
1608 if (z1 < z2) return (TRUE);
1609 if (z1 > z2) return (FALSE);
1613 /* Sort by monster level */
1616 /* Extract levels */
1617 z1 = r_info[w1].level;
1618 z2 = r_info[w2].level;
1620 /* Compare levels */
1621 if (z1 < z2) return (TRUE);
1622 if (z1 > z2) return (FALSE);
1626 /* Sort by monster experience */
1629 /* Extract experience */
1630 z1 = r_info[w1].mexp;
1631 z2 = r_info[w2].mexp;
1633 /* Compare experience */
1634 if (z1 < z2) return (TRUE);
1635 if (z1 > z2) return (FALSE);
1639 /* Compare indexes */
1645 * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1646 * Sorting hook -- Swap function -- see below
1647 * @param u モンスター種族情報の入れるポインタ
1649 * @param a スワップするモンスター種族のID1
1650 * @param b スワップするモンスター種族のID2
1653 * We use "u" to point to array of monster indexes,
1654 * and "v" to select the type of sorting to perform.
1656 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1658 u16b *who = (u16b*)(u);
1674 * @brief モンスターの思い出を見るコマンドのメインルーチン
1675 * Identify a character, allow recall of monsters
1679 * Several "special" responses recall "multiple" monsters:
1681 * ^U (all unique monsters)
1682 * ^N (all non-unique monsters)
1684 * The responses may be sorted in several ways, see below.
1686 * Note that the player ghosts are ignored.
1689 void do_cmd_query_symbol(void)
1703 bool recall = FALSE;
1708 /* Get a character, or abort */
1709 if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
1710 "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1712 /* Find that character info, and describe it */
1713 for (i = 0; ident_info[i]; ++i)
1715 if (sym == ident_info[i][0]) break;
1719 if (sym == KTRL('A'))
1722 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1724 else if (sym == KTRL('U'))
1727 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1729 else if (sym == KTRL('N'))
1732 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1734 else if (sym == KTRL('R'))
1737 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1739 /* XTRA HACK WHATSEARCH */
1740 else if (sym == KTRL('M'))
1743 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1748 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1750 else if (ident_info[i])
1752 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1756 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1759 /* Display the result */
1762 /* Allocate the "who" array */
1763 C_MAKE(who, max_r_idx, IDX);
1765 /* Collect matching monsters */
1766 for (n = 0, i = 1; i < max_r_idx; i++)
1768 monster_race *r_ptr = &r_info[i];
1770 /* Nothing to recall */
1771 if (!cheat_know && !r_ptr->r_sights) continue;
1773 /* Require non-unique monsters if needed */
1774 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1776 /* Require unique monsters if needed */
1777 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1779 /* Require ridable monsters if needed */
1780 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1782 /* XTRA HACK WHATSEARCH */
1788 for (xx = 0; temp[xx] && xx < 80; xx++)
1791 if (iskanji(temp[xx])) { xx++; continue; }
1793 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1797 strcpy(temp2, r_name + r_ptr->E_name);
1799 strcpy(temp2, r_name + r_ptr->name);
1801 for (xx = 0; temp2[xx] && xx < 80; xx++)
1802 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1805 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1807 if (my_strstr(temp2, temp))
1812 /* Collect "appropriate" monsters */
1813 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1816 /* Nothing to recall */
1819 /* Free the "who" array */
1820 C_KILL(who, max_r_idx, IDX);
1827 put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1838 /* Select the sort method */
1839 ang_sort_comp = ang_sort_comp_hook;
1840 ang_sort_swap = ang_sort_swap_hook;
1842 /* Sort the array */
1843 ang_sort(who, &why, n);
1845 /* Sort by kills (and level) */
1852 /* Catch "escape" */
1855 /* Free the "who" array */
1856 C_KILL(who, max_r_idx, IDX);
1861 /* Sort if needed */
1864 /* Select the sort method */
1865 ang_sort_comp = ang_sort_comp_hook;
1866 ang_sort_swap = ang_sort_swap_hook;
1868 /* Sort the array */
1869 ang_sort(who, &why, n);
1873 /* Start at the end */
1876 /* Scan the monster memory */
1879 /* Extract a race */
1882 /* Hack -- Auto-recall */
1883 monster_race_track(r_idx);
1885 /* Hack -- Handle stuff */
1894 /* Save the screen */
1897 /* Recall on screen */
1898 screen_roff(who[i], 0);
1901 /* Hack -- Begin the prompt */
1904 /* Hack -- Complete the prompt */
1905 Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1917 /* Normal commands */
1918 if (query != 'r') break;
1925 if (query == ESCAPE) break;
1927 /* Move to "prev" monster */
1933 if (!expand_list) break;
1937 /* Move to "next" monster */
1943 if (!expand_list) break;
1948 /* Free the "who" array */
1949 C_KILL(who, max_r_idx, IDX);
1951 /* Re-display the identity */
1956 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1960 * XXX - Add actions for other item types
1962 void do_cmd_use(void)
1968 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1970 set_action(ACTION_NONE);
1973 item_tester_no_ryoute = TRUE;
1974 /* Prepare the hook */
1975 item_tester_hook = item_tester_hook_use;
1977 q = _("どれを使いますか?", "Use which item? ");
1978 s = _("使えるものがありません。", "You have nothing to use.");
1980 if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1982 /* Get the item (in the pack) */
1985 o_ptr = &inventory[item];
1987 /* Get the item (on the floor) */
1990 o_ptr = &o_list[0 - item];
1993 switch (o_ptr->tval)
2005 do_cmd_eat_food_aux(item);
2012 do_cmd_aim_wand_aux(item);
2019 do_cmd_use_staff_aux(item);
2026 do_cmd_zap_rod_aux(item);
2030 /* Quaff a potion */
2033 do_cmd_quaff_potion_aux(item);
2040 /* Check some conditions */
2043 msg_print(_("目が見えない。", "You can't see anything."));
2048 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2051 if (p_ptr->confused)
2053 msg_print(_("混乱していて読めない!", "You are too confused!"));
2057 do_cmd_read_scroll_aux(item, TRUE);
2066 do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2070 /* Activate an artifact */
2073 do_cmd_activate_aux(item);