2 * @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory and equipment commands
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
12 #include "cmd-item/cmd-item.h"
13 #include "action/action-limited.h"
14 #include "art-definition/art-protector-types.h"
15 #include "autopick/autopick-registry.h"
16 #include "autopick/autopick.h"
17 #include "cmd-action/cmd-pet.h"
18 #include "cmd-item/cmd-activate.h"
19 #include "cmd-item/cmd-eat.h"
20 #include "cmd-item/cmd-quaff.h"
21 #include "cmd-item/cmd-read.h"
22 #include "cmd-item/cmd-usestaff.h"
23 #include "cmd-item/cmd-zaprod.h"
24 #include "cmd-item/cmd-zapwand.h"
25 #include "cmd/cmd-basic.h"
26 #include "core/asking-player.h"
27 #include "core/player-redraw-types.h"
28 #include "core/player-update-types.h"
29 #include "core/stuff-handler.h"
30 #include "core/window-redrawer.h"
31 #include "dungeon/quest.h"
32 #include "flavor/flavor-describer.h"
33 #include "flavor/object-flavor-types.h"
34 #include "floor/floor-object.h"
35 #include "game-option/birth-options.h"
36 #include "game-option/input-options.h"
37 #include "game-option/keymap-directory-getter.h"
38 #include "inventory/inventory-describer.h"
39 #include "inventory/inventory-object.h"
40 #include "inventory/inventory-slot-types.h"
41 #include "io/cursor.h"
42 #include "io/input-key-acceptor.h"
43 #include "io/input-key-requester.h"
44 #include "io/screen-util.h"
45 #include "io/targeting.h"
46 #include "main/sound-definitions-table.h"
47 #include "main/sound-of-music.h"
48 #include "mind/racial-android.h"
49 #include "mind/snipe-types.h"
50 #include "object-enchant/item-feeling.h"
51 #include "object-enchant/object-ego.h"
52 #include "object-enchant/special-object-flags.h"
53 #include "object-enchant/trc-types.h"
54 #include "object-hook/hook-armor.h"
55 #include "object-hook/hook-checker.h"
56 #include "object-hook/hook-expendable.h"
57 #include "object-hook/hook-magic.h"
58 #include "object-hook/hook-weapon.h"
59 #include "object-use/quaff-execution.h"
60 #include "object/item-tester-hooker.h"
61 #include "object/item-use-flags.h"
62 #include "object/object-generator.h"
63 #include "object/object-info.h"
64 #include "object/object-mark-types.h"
65 #include "object/object-stack.h"
66 #include "object/object-value.h"
67 #include "perception/identification.h"
68 #include "perception/object-perception.h"
69 #include "player/attack-defense-types.h"
70 #include "player/avatar.h"
71 #include "player/player-class.h"
72 #include "player/player-personalities-types.h"
73 #include "player/player-race-types.h"
74 #include "player/player-status.h"
75 #include "player/selfinfo.h"
76 #include "player/special-defense-types.h"
77 #include "realm/realm-hex-numbers.h"
78 #include "realm/realm-names-table.h"
79 #include "realm/realm-types.h"
80 #include "spell-kind/spells-perception.h"
81 #include "status/action-setter.h"
82 #include "status/experience.h"
83 #include "status/shape-changer.h"
84 #include "sv-definition/sv-lite-types.h"
85 #include "term/screen-processor.h"
86 #include "util/int-char-converter.h"
87 #include "util/quarks.h"
88 #include "view/display-inventory.h"
89 #include "view/display-messages.h"
90 #include "view/main-window-util.h"
93 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory_list
96 void do_cmd_inven(player_type *creature_ptr)
101 command_wrk = (USE_INVEN);
103 (void)show_inventory(creature_ptr, 0, USE_FULL, 0);
106 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ", (int)lbtokg1(creature_ptr->total_weight), (int)lbtokg2(creature_ptr->total_weight),
108 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ", (int)(creature_ptr->total_weight / 10),
109 (int)(creature_ptr->total_weight % 10),
111 (long int)(creature_ptr->total_weight * 100) / weight_limit(creature_ptr));
114 command_new = inkey();
117 if (command_new == ESCAPE) {
119 Term_get_size(&wid, &hgt);
121 command_gap = wid - 30;
128 * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
131 void do_cmd_equip(player_type *creature_ptr)
136 command_wrk = (USE_EQUIP);
139 (void)show_equipment(creature_ptr, 0, USE_FULL, 0);
142 sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ", (int)lbtokg1(creature_ptr->total_weight), (int)lbtokg2(creature_ptr->total_weight),
143 (long int)((creature_ptr->total_weight * 100) / weight_limit(creature_ptr)));
145 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ", (int)(creature_ptr->total_weight / 10),
146 (int)(creature_ptr->total_weight % 10), (long int)((creature_ptr->total_weight * 100) / weight_limit(creature_ptr)));
150 command_new = inkey();
153 if (command_new == ESCAPE) {
155 Term_get_size(&wid, &hgt);
157 command_gap = wid - 30;
165 bool select_ring_slot = FALSE;
168 * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
169 * @param creature_ptr プレーヤーへの参照ポインタ
172 void do_cmd_wield(player_type *creature_ptr)
174 OBJECT_IDX item, slot;
182 GAME_TEXT o_name[MAX_NLEN];
184 OBJECT_IDX need_switch_wielding = 0;
186 if (creature_ptr->special_defense & KATA_MUSOU) {
187 set_action(creature_ptr, ACTION_NONE);
190 /* Restrict the choices */
191 item_tester_hook = item_tester_hook_wear;
193 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
194 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
196 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
201 slot = wield_slot(creature_ptr, o_ptr);
203 switch (o_ptr->tval) {
204 /* Shields and some misc. items */
209 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
210 /* Restrict the choices */
211 item_tester_hook = item_tester_hook_melee_weapon;
213 /* Choose a weapon from the equipment only */
214 q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
215 s = _("おっと。", "Oops.");
216 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0))
218 if (slot == INVEN_RARM)
219 need_switch_wielding = INVEN_LARM;
222 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
225 /* Both arms are already used by non-weapon */
226 else if (creature_ptr->inventory_list[INVEN_RARM].k_idx && !object_is_melee_weapon(&creature_ptr->inventory_list[INVEN_RARM])
227 && creature_ptr->inventory_list[INVEN_LARM].k_idx && !object_is_melee_weapon(&creature_ptr->inventory_list[INVEN_LARM])) {
228 /* Restrict the choices */
229 item_tester_hook = item_tester_hook_mochikae;
232 q = _("どちらの手に装備しますか?", "Equip which hand? ");
233 s = _("おっと。", "Oops.");
234 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP), 0))
244 /* Asking for dual wielding */
245 if (slot == INVEN_LARM) {
246 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? ")))
250 else if (!creature_ptr->inventory_list[INVEN_RARM].k_idx && has_melee_weapon(creature_ptr, INVEN_LARM)) {
251 if (!get_check(_("二刀流で戦いますか?", "Dual wielding? ")))
255 /* Both arms are already used */
256 else if (creature_ptr->inventory_list[INVEN_LARM].k_idx && creature_ptr->inventory_list[INVEN_RARM].k_idx) {
257 /* Restrict the choices */
258 item_tester_hook = item_tester_hook_mochikae;
261 q = _("どちらの手に装備しますか?", "Equip which hand? ");
262 s = _("おっと。", "Oops.");
264 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP), 0))
266 if ((slot == INVEN_LARM) && !has_melee_weapon(creature_ptr, INVEN_RARM))
267 need_switch_wielding = INVEN_RARM;
273 /* Choose a ring slot */
274 if (creature_ptr->inventory_list[INVEN_LEFT].k_idx && creature_ptr->inventory_list[INVEN_RIGHT].k_idx) {
275 q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
277 q = _("どちらの手に装備しますか?", "Equip which hand? ");
279 s = _("おっと。", "Oops.");
281 /* Restrict the choices */
282 select_ring_slot = TRUE;
284 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0)) {
285 select_ring_slot = FALSE;
288 select_ring_slot = FALSE;
292 /* Prevent wielding into a cursed slot */
293 if (object_is_cursed(&creature_ptr->inventory_list[slot])) {
294 describe_flavor(creature_ptr, o_name, &creature_ptr->inventory_list[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
296 msg_format("%s%sは呪われているようだ。", describe_use(creature_ptr, slot), o_name);
298 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(creature_ptr, slot));
304 && ((object_is_cursed(o_ptr) && object_is_known(o_ptr))
305 || ((o_ptr->ident & IDENT_SENSE) && (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED)))) {
306 char dummy[MAX_NLEN + 80];
308 describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
309 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
311 if (!get_check(dummy))
315 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (creature_ptr->prace != RACE_VAMPIRE) && (creature_ptr->prace != RACE_ANDROID)) {
316 char dummy[MAX_NLEN + 100];
318 describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
321 _("%sを装備すると吸血鬼になります。よろしいですか?", "%s will transforms you into a vampire permanently when equiped. Do you become a vampire?"),
324 if (!get_check(dummy))
328 if (need_switch_wielding && !object_is_cursed(&creature_ptr->inventory_list[need_switch_wielding])) {
329 object_type *slot_o_ptr = &creature_ptr->inventory_list[slot];
330 object_type *switch_o_ptr = &creature_ptr->inventory_list[need_switch_wielding];
331 object_type object_tmp;
332 object_type *otmp_ptr = &object_tmp;
333 GAME_TEXT switch_name[MAX_NLEN];
335 describe_flavor(creature_ptr, switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
337 object_copy(otmp_ptr, switch_o_ptr);
338 object_copy(switch_o_ptr, slot_o_ptr);
339 object_copy(slot_o_ptr, otmp_ptr);
341 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name,
342 (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) : (left_hander ? _("右手", "right") : _("左手", "left")));
343 slot = need_switch_wielding;
346 check_find_art_quest_completion(creature_ptr, o_ptr);
348 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
349 identify_item(creature_ptr, o_ptr);
351 /* Auto-inscription */
352 autopick_alter_item(creature_ptr, item, FALSE);
355 take_turn(creature_ptr, 100);
358 /* Obtain local object */
359 object_copy(q_ptr, o_ptr);
361 /* Modify quantity */
364 /* Decrease the item (from the pack) */
366 inven_item_increase(creature_ptr, item, -1);
367 inven_item_optimize(creature_ptr, item);
369 /* Decrease the item (from the floor) */
371 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
372 floor_item_optimize(creature_ptr, 0 - item);
375 /* Access the wield slot */
376 o_ptr = &creature_ptr->inventory_list[slot];
378 /* Take off existing item */
380 /* Take off existing item */
381 (void)inven_takeoff(creature_ptr, slot, 255);
384 /* Wear the new stuff */
385 object_copy(o_ptr, q_ptr);
387 o_ptr->marked |= OM_TOUCHED;
389 creature_ptr->total_weight += q_ptr->weight;
391 /* Increment the equip counter by hand */
392 creature_ptr->equip_cnt++;
394 #define STR_WIELD_RARM _("%s(%c)を右手に装備した。", "You are wielding %s (%c) in your right hand.")
395 #define STR_WIELD_LARM _("%s(%c)を左手に装備した。", "You are wielding %s (%c) in your left hand.")
396 #define STR_WIELD_ARMS _("%s(%c)を両手で構えた。", "You are wielding %s (%c) with both hands.")
398 /* Where is the item now */
401 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) && can_two_hands_wielding(creature_ptr))
402 act = STR_WIELD_ARMS;
404 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
408 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) && can_two_hands_wielding(creature_ptr))
409 act = STR_WIELD_ARMS;
411 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
415 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
419 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
423 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
427 describe_flavor(creature_ptr, o_name, o_ptr, 0);
428 msg_format(act, o_name, index_to_label(slot));
431 if (object_is_cursed(o_ptr)) {
432 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
433 chg_virtue(creature_ptr, V_HARMONY, -1);
436 o_ptr->ident |= (IDENT_SENSE);
439 /* The Stone Mask make the player turn into a vampire! */
440 if ((o_ptr->name1 == ART_STONEMASK) && (creature_ptr->prace != RACE_VAMPIRE) && (creature_ptr->prace != RACE_ANDROID)) {
441 /* Turn into a vampire */
442 change_race(creature_ptr, RACE_VAMPIRE, "");
445 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
446 creature_ptr->redraw |= (PR_EQUIPPY);
447 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
449 calc_android_exp(creature_ptr);
454 * @param owner_ptr プレーヤーへの参照ポインタ
455 * @param item 持ち替えを行いたい装備部位ID
458 void verify_equip_slot(player_type *owner_ptr, INVENTORY_IDX item)
460 object_type *o_ptr, *new_o_ptr;
461 GAME_TEXT o_name[MAX_NLEN];
463 if (item == INVEN_RARM) {
464 if (!has_melee_weapon(owner_ptr, INVEN_LARM))
467 o_ptr = &owner_ptr->inventory_list[INVEN_LARM];
468 describe_flavor(owner_ptr, o_name, o_ptr, 0);
470 if (object_is_cursed(o_ptr)) {
471 if (object_allow_two_hands_wielding(o_ptr) && can_two_hands_wielding(owner_ptr))
472 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
476 new_o_ptr = &owner_ptr->inventory_list[INVEN_RARM];
477 object_copy(new_o_ptr, o_ptr);
478 owner_ptr->total_weight += o_ptr->weight;
479 inven_item_increase(owner_ptr, INVEN_LARM, -((int)o_ptr->number));
480 inven_item_optimize(owner_ptr, INVEN_LARM);
481 if (object_allow_two_hands_wielding(o_ptr) && can_two_hands_wielding(owner_ptr))
482 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
484 msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name, (left_hander ? _("左手", "left") : _("右手", "right")));
488 if (item != INVEN_LARM)
491 o_ptr = &owner_ptr->inventory_list[INVEN_RARM];
493 describe_flavor(owner_ptr, o_name, o_ptr, 0);
495 if (has_melee_weapon(owner_ptr, INVEN_RARM)) {
496 if (object_allow_two_hands_wielding(o_ptr) && can_two_hands_wielding(owner_ptr))
497 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
501 if ((empty_hands(owner_ptr, FALSE) & EMPTY_HAND_RARM) || object_is_cursed(o_ptr))
504 new_o_ptr = &owner_ptr->inventory_list[INVEN_LARM];
505 object_copy(new_o_ptr, o_ptr);
506 owner_ptr->total_weight += o_ptr->weight;
507 inven_item_increase(owner_ptr, INVEN_RARM, -((int)o_ptr->number));
508 inven_item_optimize(owner_ptr, INVEN_RARM);
509 msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
513 * @brief 装備を外すコマンドのメインルーチン / Take off an item
516 void do_cmd_takeoff(player_type *creature_ptr)
522 if (creature_ptr->special_defense & KATA_MUSOU) {
523 set_action(creature_ptr, ACTION_NONE);
526 q = _("どれを装備からはずしますか? ", "Take off which item? ");
527 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
529 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
534 if (object_is_cursed(o_ptr)) {
535 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (creature_ptr->pclass != CLASS_BERSERKER)) {
536 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
541 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4)) {
542 msg_print(_("呪われた装備を力づくで剥がした!", "You tore off a piece of cursed equipment by sheer strength!"));
544 o_ptr->ident |= (IDENT_SENSE);
545 o_ptr->curse_flags = 0L;
546 o_ptr->feeling = FEEL_NONE;
548 creature_ptr->update |= (PU_BONUS);
549 creature_ptr->window |= (PW_EQUIP);
551 msg_print(_("呪いを打ち破った。", "You break the curse."));
553 msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
554 take_turn(creature_ptr, 50);
559 take_turn(creature_ptr, 50);
561 /* Take off the item */
562 (void)inven_takeoff(creature_ptr, item, 255);
563 verify_equip_slot(creature_ptr, item);
564 calc_android_exp(creature_ptr);
565 creature_ptr->redraw |= (PR_EQUIPPY);
569 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
572 void do_cmd_drop(player_type *creature_ptr)
581 if (creature_ptr->special_defense & KATA_MUSOU) {
582 set_action(creature_ptr, ACTION_NONE);
585 q = _("どのアイテムを落としますか? ", "Drop which item? ");
586 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
588 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
592 /* Hack -- Cannot remove cursed items */
593 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr)) {
594 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
598 if (o_ptr->number > 1) {
599 amt = get_quantity(NULL, o_ptr->number);
604 take_turn(creature_ptr, 50);
606 /* Drop (some of) the item */
607 drop_from_inventory(creature_ptr, item, amt);
609 if (item >= INVEN_RARM) {
610 verify_equip_slot(creature_ptr, item);
611 calc_android_exp(creature_ptr);
614 creature_ptr->redraw |= (PR_EQUIPPY);
618 * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
619 * @param creature_ptr プレーヤーへの参照ポインタ
622 void do_cmd_destroy(player_type *creature_ptr)
632 object_type *q_ptr = &forge;
634 GAME_TEXT o_name[MAX_NLEN];
635 char out_val[MAX_NLEN + 40];
639 if (creature_ptr->special_defense & KATA_MUSOU) {
640 set_action(creature_ptr, ACTION_NONE);
643 /* Hack -- force destruction */
647 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
648 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
650 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
654 /* Verify unless quantity given beforehand */
655 if (!force && (confirm_destroy || (object_value(creature_ptr, o_ptr) > 0))) {
656 describe_flavor(creature_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
658 /* Make a verification */
659 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
662 /* HACK : Add the line to message buffer */
663 message_add(out_val);
664 creature_ptr->window |= (PW_MESSAGE);
665 handle_stuff(creature_ptr);
667 /* Get an acceptable answer */
676 /* Erase the prompt */
679 if (i == 'y' || i == 'Y') {
682 if (i == ESCAPE || i == 'n' || i == 'N') {
687 /* Add an auto-destroy preference line */
688 if (autopick_autoregister(creature_ptr, o_ptr)) {
689 /* Auto-destroy it */
690 autopick_alter_item(creature_ptr, item, TRUE);
693 /* The object is already destroyed. */
699 if (o_ptr->number > 1) {
700 amt = get_quantity(NULL, o_ptr->number);
705 old_number = o_ptr->number;
707 describe_flavor(creature_ptr, o_name, o_ptr, 0);
708 o_ptr->number = old_number;
710 take_turn(creature_ptr, 100);
712 /* Artifacts cannot be destroyed */
713 if (!can_player_destroy_object(creature_ptr, o_ptr)) {
714 free_turn(creature_ptr);
716 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
720 object_copy(q_ptr, o_ptr);
722 msg_format(_("%sを壊した。", "You destroy %s."), o_name);
723 sound(SOUND_DESTITEM);
725 /* Reduce the charges of rods/wands */
726 reduce_charges(o_ptr, amt);
728 vary_item(creature_ptr, item, -amt);
730 if (item_tester_high_level_book(q_ptr)) {
731 bool gain_expr = FALSE;
733 if (creature_ptr->prace == RACE_ANDROID) {
734 } else if ((creature_ptr->pclass == CLASS_WARRIOR) || (creature_ptr->pclass == CLASS_BERSERKER)) {
736 } else if (creature_ptr->pclass == CLASS_PALADIN) {
737 if (is_good_realm(creature_ptr->realm1)) {
738 if (!is_good_realm(tval2realm(q_ptr->tval)))
741 if (is_good_realm(tval2realm(q_ptr->tval)))
746 if (gain_expr && (creature_ptr->exp < PY_MAX_EXP)) {
747 s32b tester_exp = creature_ptr->max_exp / 20;
748 if (tester_exp > 10000)
755 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
756 gain_exp(creature_ptr, tester_exp * amt);
758 if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK) {
759 chg_virtue(creature_ptr, V_UNLIFE, 1);
760 chg_virtue(creature_ptr, V_VITALITY, -1);
761 } else if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK) {
762 chg_virtue(creature_ptr, V_UNLIFE, -1);
763 chg_virtue(creature_ptr, V_VITALITY, 1);
766 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
767 chg_virtue(creature_ptr, V_ENCHANT, -1);
769 if (object_value_real(creature_ptr, q_ptr) > 30000)
770 chg_virtue(creature_ptr, V_SACRIFICE, 2);
772 else if (object_value_real(creature_ptr, q_ptr) > 10000)
773 chg_virtue(creature_ptr, V_SACRIFICE, 1);
776 if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
777 chg_virtue(creature_ptr, V_HARMONY, 1);
779 if (item >= INVEN_RARM)
780 calc_android_exp(creature_ptr);
784 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
787 void do_cmd_observe(player_type *creature_ptr)
791 GAME_TEXT o_name[MAX_NLEN];
794 q = _("どのアイテムを調べますか? ", "Examine which item? ");
795 s = _("調べられるアイテムがない。", "You have nothing to examine.");
797 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
801 /* Require full knowledge */
802 if (!object_is_fully_known(o_ptr)) {
803 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
807 describe_flavor(creature_ptr, o_name, o_ptr, 0);
808 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
809 if (!screen_object(creature_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
810 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
814 * @brief アイテムの銘を消すコマンドのメインルーチン
815 * Remove the inscription from an object XXX Mention item (when done)?
818 void do_cmd_uninscribe(player_type *creature_ptr)
824 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
825 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
827 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
831 /* Nothing to remove */
832 if (!o_ptr->inscription) {
833 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
837 msg_print(_("銘を消した。", "Inscription removed."));
839 /* Remove the incription */
840 o_ptr->inscription = 0;
841 creature_ptr->update |= (PU_COMBINE);
842 creature_ptr->window |= (PW_INVEN | PW_EQUIP);
844 /* .や$の関係で, 再計算が必要なはず -- henkma */
845 creature_ptr->update |= (PU_BONUS);
849 * @brief アイテムの銘を刻むコマンドのメインルーチン
850 * Inscribe an object with a comment
853 void do_cmd_inscribe(player_type *creature_ptr)
857 GAME_TEXT o_name[MAX_NLEN];
861 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
862 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
864 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
868 /* Describe the activity */
869 describe_flavor(creature_ptr, o_name, o_ptr, OD_OMIT_INSCRIPTION);
871 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
874 /* Start with nothing */
877 /* Use old inscription */
878 if (o_ptr->inscription) {
879 /* Start with the old inscription */
880 strcpy(out_val, quark_str(o_ptr->inscription));
883 /* Get a new inscription (possibly empty) */
884 if (get_string(_("銘: ", "Inscription: "), out_val, 80)) {
885 /* Save the inscription */
886 o_ptr->inscription = quark_add(out_val);
887 creature_ptr->update |= (PU_COMBINE);
888 creature_ptr->window |= (PW_INVEN | PW_EQUIP);
890 /* .や$の関係で, 再計算が必要なはず -- henkma */
891 creature_ptr->update |= (PU_BONUS);
896 * @brief ランタンに燃料を加えるコマンドのメインルーチン
897 * Refill the players lamp (from the pack or floor)
900 static void do_cmd_refill_lamp(player_type *user_ptr)
907 /* Restrict the choices */
908 item_tester_hook = item_tester_refill_lantern;
910 q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
911 s = _("油つぼがない。", "You have no flasks of oil.");
913 o_ptr = choose_object(user_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
917 take_turn(user_ptr, 50);
919 /* Access the lantern */
920 j_ptr = &user_ptr->inventory_list[INVEN_LITE];
923 j_ptr->xtra4 += o_ptr->xtra4;
924 msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
926 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) {
928 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
929 } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) {
931 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
932 } else if (j_ptr->xtra4 >= FUEL_LAMP) {
933 j_ptr->xtra4 = FUEL_LAMP;
934 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
937 vary_item(user_ptr, item, -1);
939 user_ptr->update |= (PU_TORCH);
943 * @brief 松明を束ねるコマンドのメインルーチン
944 * Refuel the players torch (from the pack or floor)
947 static void do_cmd_refill_torch(player_type *creature_ptr)
956 /* Restrict the choices */
957 item_tester_hook = object_can_refill_torch;
959 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
960 s = _("他に松明がない。", "You have no extra torches.");
962 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
966 take_turn(creature_ptr, 50);
968 /* Access the primary torch */
969 j_ptr = &creature_ptr->inventory_list[INVEN_LITE];
972 j_ptr->xtra4 += o_ptr->xtra4 + 5;
974 msg_print(_("松明を結合した。", "You combine the torches."));
976 if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) {
978 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
979 } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) {
981 msg_print(_("しかし松明は全く光らない。", "Curiously, your torch doesn't light."));
983 /* Over-fuel message */
984 else if (j_ptr->xtra4 >= FUEL_TORCH) {
985 j_ptr->xtra4 = FUEL_TORCH;
986 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
991 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
994 vary_item(creature_ptr, item, -1);
996 creature_ptr->update |= (PU_TORCH);
1000 * @brief 燃料を補充するコマンドのメインルーチン
1001 * Refill the players lamp, or restock his torches
1004 void do_cmd_refill(player_type *creature_ptr)
1009 o_ptr = &creature_ptr->inventory_list[INVEN_LITE];
1011 if (creature_ptr->special_defense & KATA_MUSOU) {
1012 set_action(creature_ptr, ACTION_NONE);
1016 if (o_ptr->tval != TV_LITE) {
1017 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1021 else if (o_ptr->sval == SV_LITE_LANTERN) {
1022 do_cmd_refill_lamp(creature_ptr);
1026 else if (o_ptr->sval == SV_LITE_TORCH) {
1027 do_cmd_refill_torch(creature_ptr);
1030 /* No torch to refill */
1032 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1037 * @brief ターゲットを設定するコマンドのメインルーチン
1041 void do_cmd_target(player_type *creature_ptr)
1043 if (creature_ptr->wild_mode)
1047 if (target_set(creature_ptr, TARGET_KILL)) {
1048 msg_print(_("ターゲット決定。", "Target Selected."));
1051 /* Target aborted */
1053 msg_print(_("ターゲット解除。", "Target Aborted."));
1058 * @brief 周囲を見渡すコマンドのメインルーチン
1062 void do_cmd_look(player_type *creature_ptr)
1064 creature_ptr->window |= PW_MONSTER_LIST;
1065 handle_stuff(creature_ptr);
1068 if (target_set(creature_ptr, TARGET_LOOK)) {
1069 msg_print(_("ターゲット決定。", "Target Selected."));
1074 * @brief 位置を確認するコマンドのメインルーチン
1075 * Allow the player to examine other sectors on the map
1078 void do_cmd_locate(player_type *creature_ptr)
1081 POSITION y1, x1, y2, x2;
1082 GAME_TEXT tmp_val[80];
1083 GAME_TEXT out_val[160];
1086 get_screen_size(&wid, &hgt);
1088 /* Start at current panel */
1089 y2 = y1 = panel_row_min;
1090 x2 = x1 = panel_col_min;
1092 /* Show panels until done */
1094 /* Describe the location */
1095 if ((y2 == y1) && (x2 == x1)) {
1096 strcpy(tmp_val, _("真上", "\0"));
1098 sprintf(tmp_val, "%s%s", ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
1099 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
1102 /* Prepare to ask which way to look */
1103 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s) 方向?", "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?"),
1104 y2 / (hgt / 2), y2 % (hgt / 2), x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1106 /* Assume no direction */
1109 /* Get a direction */
1113 /* Get a command (or Cancel) */
1114 if (!get_com(out_val, &command, TRUE))
1117 /* Extract the action (if any) */
1118 dir = get_keymap_dir(command);
1129 /* Apply the motion */
1130 if (change_panel(creature_ptr, ddy[dir], ddx[dir])) {
1136 /* Recenter the map around the player */
1137 verify_panel(creature_ptr);
1139 creature_ptr->update |= (PU_MONSTERS);
1140 creature_ptr->redraw |= (PR_MAP);
1141 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1142 handle_stuff(creature_ptr);
1146 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1150 * XXX - Add actions for other item types
1152 void do_cmd_use(player_type *creature_ptr)
1158 if (creature_ptr->wild_mode) {
1162 if (cmd_limit_arena(creature_ptr))
1165 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) {
1166 set_action(creature_ptr, ACTION_NONE);
1169 item_tester_hook = item_tester_hook_use;
1171 q = _("どれを使いますか?", "Use which item? ");
1172 s = _("使えるものがありません。", "You have nothing to use.");
1174 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1178 switch (o_ptr->tval) {
1180 do_cmd_spike(creature_ptr);
1184 exe_eat_food(creature_ptr, item);
1188 exe_aim_wand(creature_ptr, item);
1192 exe_use_staff(creature_ptr, item);
1196 exe_zap_rod(creature_ptr, item);
1200 exe_quaff_potion(creature_ptr, item);
1204 if (cmd_limit_blind(creature_ptr))
1206 if (cmd_limit_confused(creature_ptr))
1208 exe_read(creature_ptr, item, TRUE);
1214 exe_fire(creature_ptr, item, &creature_ptr->inventory_list[INVEN_BOW], SP_NONE);
1218 exe_activate(creature_ptr, item);