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 "action/activation-execution.h"
15 #include "action/weapon-shield.h"
16 #include "cmd-action/cmd-open-close.h"
17 #include "cmd-action/cmd-pet.h"
18 #include "cmd-item/cmd-eat.h"
19 #include "cmd-item/cmd-quaff.h"
20 #include "cmd-item/cmd-read.h"
21 #include "cmd-item/cmd-usestaff.h"
22 #include "cmd-item/cmd-zaprod.h"
23 #include "cmd-item/cmd-zapwand.h"
24 #include "combat/shoot.h"
25 #include "core/asking-player.h"
26 #include "core/player-redraw-types.h"
27 #include "core/player-update-types.h"
28 #include "core/window-redrawer.h"
29 #include "flavor/flavor-describer.h"
30 #include "flavor/object-flavor-types.h"
31 #include "floor/floor-object.h"
32 #include "game-option/input-options.h"
33 #include "inventory/inventory-object.h"
34 #include "inventory/inventory-slot-types.h"
35 #include "io/input-key-acceptor.h"
36 #include "io/input-key-requester.h"
37 #include "mind/snipe-types.h"
38 #include "object-activation/activation-switcher.h"
39 #include "object-hook/hook-checker.h"
40 #include "object-hook/hook-magic.h"
41 #include "object-use/quaff-execution.h"
42 #include "object-use/read-execution.h"
43 #include "object/item-tester-hooker.h"
44 #include "object/item-use-flags.h"
45 #include "perception/identification.h"
46 #include "perception/object-perception.h"
47 #include "player-info/self-info.h"
48 #include "player/attack-defense-types.h"
49 #include "player/player-class.h"
50 #include "player/player-personalities-types.h"
51 #include "player/player-race-types.h"
52 #include "player/player-status.h"
53 #include "player/special-defense-types.h"
54 #include "racial/racial-android.h"
55 #include "realm/realm-hex-numbers.h"
56 #include "realm/realm-types.h"
57 #include "status/action-setter.h"
58 #include "term/screen-processor.h"
59 #include "util/int-char-converter.h"
60 #include "util/quarks.h"
61 #include "view/display-inventory.h"
62 #include "view/display-messages.h"
65 * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory_list
68 void do_cmd_inven(player_type *creature_ptr)
73 command_wrk = USE_INVEN;
76 (void)show_inventory(creature_ptr, 0, USE_FULL, 0);
77 WEIGHT weight = calc_inventory_weight(creature_ptr);
78 WEIGHT weight_lim = calc_weight_limit(creature_ptr);
80 sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ", (int)lbtokg1(weight), (int)lbtokg2(weight),
82 sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ", (int)(weight / 10),
85 (long int)(weight * 100) / weight_lim);
88 command_new = inkey();
90 if (command_new != ESCAPE) {
96 term_get_size(&wid, &hgt);
98 command_gap = wid - 30;
102 * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
105 void do_cmd_drop(player_type *creature_ptr)
110 if (creature_ptr->special_defense & KATA_MUSOU)
111 set_action(creature_ptr, ACTION_NONE);
113 concptr q = _("どのアイテムを落としますか? ", "Drop which item? ");
114 concptr s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
115 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT), 0);
119 if ((item >= INVEN_MAIN_HAND) && object_is_cursed(o_ptr)) {
120 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
124 if (o_ptr->number > 1) {
125 amt = get_quantity(NULL, o_ptr->number);
130 take_turn(creature_ptr, 50);
131 drop_from_inventory(creature_ptr, item, amt);
132 if (item >= INVEN_MAIN_HAND) {
133 verify_equip_slot(creature_ptr, item);
134 calc_android_exp(creature_ptr);
137 creature_ptr->redraw |= (PR_EQUIPPY);
141 * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
144 void do_cmd_observe(player_type *creature_ptr)
148 GAME_TEXT o_name[MAX_NLEN];
149 concptr q = _("どのアイテムを調べますか? ", "Examine which item? ");
150 concptr s = _("調べられるアイテムがない。", "You have nothing to examine.");
151 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
155 if (!object_is_fully_known(o_ptr)) {
156 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
160 describe_flavor(creature_ptr, o_name, o_ptr, 0);
161 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
162 if (!screen_object(creature_ptr, o_ptr, SCROBJ_FORCE_DETAIL))
163 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
167 * @brief アイテムの銘を消すコマンドのメインルーチン
168 * Remove the inscription from an object XXX Mention item (when done)?
171 void do_cmd_uninscribe(player_type *creature_ptr)
175 concptr q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
176 concptr s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
177 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
181 if (!o_ptr->inscription) {
182 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
186 msg_print(_("銘を消した。", "Inscription removed."));
187 o_ptr->inscription = 0;
188 creature_ptr->update |= (PU_COMBINE);
189 creature_ptr->window |= (PW_INVEN | PW_EQUIP);
190 creature_ptr->update |= (PU_BONUS);
194 * @brief アイテムの銘を刻むコマンドのメインルーチン
195 * Inscribe an object with a comment
198 void do_cmd_inscribe(player_type *creature_ptr)
202 GAME_TEXT o_name[MAX_NLEN];
204 concptr q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
205 concptr s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
206 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
210 describe_flavor(creature_ptr, o_name, o_ptr, OD_OMIT_INSCRIPTION);
211 msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
214 if (o_ptr->inscription)
215 strcpy(out_val, quark_str(o_ptr->inscription));
217 if (get_string(_("銘: ", "Inscription: "), out_val, 80)) {
218 o_ptr->inscription = quark_add(out_val);
219 creature_ptr->update |= (PU_COMBINE);
220 creature_ptr->window |= (PW_INVEN | PW_EQUIP);
221 creature_ptr->update |= (PU_BONUS);
226 * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
230 * XXX - Add actions for other item types
232 void do_cmd_use(player_type *creature_ptr)
236 if (creature_ptr->wild_mode || cmd_limit_arena(creature_ptr))
239 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
240 set_action(creature_ptr, ACTION_NONE);
242 item_tester_hook = item_tester_hook_use;
243 concptr q = _("どれを使いますか?", "Use which item? ");
244 concptr s = _("使えるものがありません。", "You have nothing to use.");
245 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
249 switch (o_ptr->tval) {
251 do_cmd_spike(creature_ptr);
254 exe_eat_food(creature_ptr, item);
257 exe_aim_wand(creature_ptr, item);
260 exe_use_staff(creature_ptr, item);
263 exe_zap_rod(creature_ptr, item);
266 exe_quaff_potion(creature_ptr, item);
269 if (cmd_limit_blind(creature_ptr) || cmd_limit_confused(creature_ptr))
272 exe_read(creature_ptr, item, TRUE);
277 exe_fire(creature_ptr, item, &creature_ptr->inventory_list[INVEN_BOW], SP_NONE);
280 exe_activate(creature_ptr, item);
286 * @brief 装備を発動するコマンドのメインルーチン /
287 * @param user_ptr プレーヤーへの参照ポインタ
290 void do_cmd_activate(player_type *user_ptr)
293 if (user_ptr->wild_mode || cmd_limit_arena(user_ptr))
296 if (user_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
297 set_action(user_ptr, ACTION_NONE);
299 item_tester_hook = item_tester_hook_activate;
301 concptr q = _("どのアイテムを始動させますか? ", "Activate which item? ");
302 concptr s = _("始動できるアイテムを装備していない。", "You have nothing to activate.");
303 if (!choose_object(user_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0))
306 exe_activate(user_ptr, item);