1 #include "inventory/player-inventory.h"
2 #include "autopick/autopick.h"
3 #include "core/asking-player.h"
4 #include "core/disturbance.h"
5 #include "core/player-redraw-types.h"
6 #include "core/player-update-types.h"
7 #include "core/stuff-handler.h"
8 #include "core/window-redrawer.h"
9 #include "dungeon/quest.h"
10 #include "flavor/flavor-describer.h"
11 #include "flavor/object-flavor-types.h"
12 #include "floor/floor-object.h"
13 #include "floor/object-scanner.h"
14 #include "game-option/auto-destruction-options.h"
15 #include "game-option/birth-options.h"
16 #include "game-option/input-options.h"
17 #include "game-option/play-record-options.h"
18 #include "game-option/text-display-options.h"
19 #include "grid/grid.h"
20 #include "inventory/inventory-object.h"
21 #include "inventory/inventory-slot-types.h"
22 #include "main/sound-definitions-table.h"
23 #include "main/sound-of-music.h"
24 #include "object/item-tester-hooker.h"
25 #include "object/item-use-flags.h"
26 #include "object/object-info.h"
27 #include "object/object-mark-types.h"
28 #include "player/player-move.h"
29 #include "spell-kind/spells-perception.h"
30 #include "system/floor-type-definition.h"
31 #include "target/target-checker.h"
32 #include "view/display-messages.h"
33 #include "world/world.h"
35 #include "artifact/fixed-art-types.h"
36 #include "flavor/flavor-util.h"
40 * @brief 規定の処理にできるアイテムがプレイヤーの利用可能範囲内にあるかどうかを返す /
41 * Determine whether get_item() can get some item or not
42 * @return アイテムを拾えるならばTRUEを返す。
43 * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
45 bool can_get_item(player_type *owner_ptr, tval_type tval)
47 for (int j = 0; j < INVEN_TOTAL; j++)
48 if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], tval))
51 OBJECT_IDX floor_list[23];
52 ITEM_NUMBER floor_num = scan_floor_items(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval);
53 return floor_num != 0;
57 * @brief 床上のアイテムを拾う選択用サブルーチン
58 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
60 static bool py_pickup_floor_aux(player_type *owner_ptr)
62 OBJECT_IDX this_o_idx;
64 item_tester_hook = check_store_item_to_inventory;
65 concptr q = _("どれを拾いますか?", "Get which item? ");
66 concptr s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
67 if (choose_object(owner_ptr, &item, q, s, (USE_FLOOR), 0))
68 this_o_idx = 0 - item;
72 describe_pickup_item(owner_ptr, this_o_idx);
77 * @brief 床上のアイテムを拾うメイン処理
78 * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
81 * This is called by py_pickup() when easy_floor is TRUE.
83 void py_pickup_floor(player_type *owner_ptr, bool pickup)
85 OBJECT_IDX this_o_idx, next_o_idx = 0;
86 GAME_TEXT o_name[MAX_NLEN];
89 OBJECT_IDX floor_o_idx = 0;
91 for (this_o_idx = owner_ptr->current_floor_ptr->grid_array[owner_ptr->y][owner_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx) {
92 o_ptr = &owner_ptr->current_floor_ptr->o_list[this_o_idx];
93 describe_flavor(owner_ptr, o_name, o_ptr, 0);
94 next_o_idx = o_ptr->next_o_idx;
95 disturb(owner_ptr, FALSE, FALSE);
96 if (o_ptr->tval == TV_GOLD) {
97 msg_format(_(" $%ld の価値がある%sを見つけた。", "You have found %ld gold pieces worth of %s."), (long)o_ptr->pval, o_name);
98 owner_ptr->au += o_ptr->pval;
99 owner_ptr->redraw |= (PR_GOLD);
100 owner_ptr->window |= (PW_PLAYER);
101 delete_object_idx(owner_ptr, this_o_idx);
103 } else if (o_ptr->marked & OM_NOMSG) {
104 o_ptr->marked &= ~(OM_NOMSG);
108 if (check_store_item_to_inventory(owner_ptr, o_ptr))
112 floor_o_idx = this_o_idx;
119 if (floor_num == 1) {
120 o_ptr = &owner_ptr->current_floor_ptr->o_list[floor_o_idx];
121 describe_flavor(owner_ptr, o_name, o_ptr, 0);
122 msg_format(_("%sがある。", "You see %s."), o_name);
124 msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
130 if (floor_num == 1) {
131 o_ptr = &owner_ptr->current_floor_ptr->o_list[floor_o_idx];
132 describe_flavor(owner_ptr, o_name, o_ptr, 0);
133 msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
135 msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
140 if (floor_num != 1) {
142 if (!py_pickup_floor_aux(owner_ptr))
148 if (carry_query_flag) {
149 char out_val[MAX_NLEN + 20];
150 o_ptr = &owner_ptr->current_floor_ptr->o_list[floor_o_idx];
151 describe_flavor(owner_ptr, o_name, o_ptr, 0);
152 (void)sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
153 if (!get_check(out_val))
157 o_ptr = &owner_ptr->current_floor_ptr->o_list[floor_o_idx];
158 describe_pickup_item(owner_ptr, floor_o_idx);
162 * @brief プレイヤーがオブジェクトを拾った際のメッセージ表示処理 /
163 * Helper routine for py_pickup() and py_pickup_floor().
164 * @param creature_ptr プレーヤーへの参照ポインタ
165 * @param o_idx 取得したオブジェクトの参照ID
168 * アイテムを拾った際に「2つのケーキを持っている」
169 * "You have two cakes." とアイテムを拾った後の合計のみの表示がオリジナルだが、
170 * 違和感があるという指摘をうけたので、「~を拾った、~を持っている」という表示にかえてある。
172 * Add the given dungeon object to the character's inventory.\n
173 * Delete the object afterwards.\n
175 void describe_pickup_item(player_type *owner_ptr, OBJECT_IDX o_idx)
178 GAME_TEXT o_name[MAX_NLEN];
179 GAME_TEXT old_name[MAX_NLEN];
183 GAME_TEXT o_name[MAX_NLEN];
187 o_ptr = &owner_ptr->current_floor_ptr->o_list[o_idx];
190 describe_flavor(owner_ptr, old_name, o_ptr, OD_NAME_ONLY);
191 object_desc_count_japanese(kazu_str, o_ptr);
192 hirottakazu = o_ptr->number;
195 INVENTORY_IDX slot = store_item_to_inventory(owner_ptr, o_ptr);
196 o_ptr = &owner_ptr->inventory_list[slot];
197 delete_object_idx(owner_ptr, o_idx);
198 if (owner_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
199 bool old_known = identify_item(owner_ptr, o_ptr);
200 autopick_alter_item(owner_ptr, slot, (bool)(destroy_identify && !old_known));
201 if (o_ptr->marked & OM_AUTODESTROY)
205 describe_flavor(owner_ptr, o_name, o_ptr, 0);
208 if ((o_ptr->name1 == ART_CRIMSON) && (owner_ptr->pseikaku == PERSONALITY_COMBAT)) {
209 msg_format("こうして、%sは『クリムゾン』を手に入れた。", owner_ptr->name);
210 msg_print("しかし今、『混沌のサーペント』の放ったモンスターが、");
211 msg_format("%sに襲いかかる...", owner_ptr->name);
214 msg_format("%s(%c)を持っている。", o_name, index_to_label(slot));
216 if (o_ptr->number > hirottakazu) {
217 msg_format("%s拾って、%s(%c)を持っている。", kazu_str, o_name, index_to_label(slot));
219 msg_format("%s(%c)を拾った。", o_name, index_to_label(slot));
224 strcpy(record_o_name, old_name);
226 msg_format("You have %s (%c).", o_name, index_to_label(slot));
227 strcpy(record_o_name, o_name);
229 record_turn = current_world_ptr->game_turn;
230 check_find_art_quest_completion(owner_ptr, o_ptr);
234 * @brief プレイヤーがオブジェクト上に乗った際の表示処理 / Player "wants" to pick up an object or gold.
235 * @param creature_ptr プレーヤーへの参照ポインタ
236 * @param pickup 自動拾い処理を行うならばTRUEとする
239 void carry(player_type *creature_ptr, bool pickup)
241 verify_panel(creature_ptr);
242 creature_ptr->update |= PU_MONSTERS;
243 creature_ptr->redraw |= PR_MAP;
244 creature_ptr->window |= PW_OVERHEAD;
245 handle_stuff(creature_ptr);
246 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
247 autopick_pickup_items(creature_ptr, g_ptr);
249 py_pickup_floor(creature_ptr, pickup);
253 OBJECT_IDX next_o_idx = 0;
254 for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) {
256 o_ptr = &creature_ptr->current_floor_ptr->o_list[this_o_idx];
257 GAME_TEXT o_name[MAX_NLEN];
258 describe_flavor(creature_ptr, o_name, o_ptr, 0);
259 next_o_idx = o_ptr->next_o_idx;
260 disturb(creature_ptr, FALSE, FALSE);
261 if (o_ptr->tval == TV_GOLD) {
262 int value = (long)o_ptr->pval;
263 delete_object_idx(creature_ptr, this_o_idx);
264 msg_format(_(" $%ld の価値がある%sを見つけた。", "You collect %ld gold pieces worth of %s."), (long)value, o_name);
266 creature_ptr->au += value;
267 creature_ptr->redraw |= (PR_GOLD);
268 creature_ptr->window |= (PW_PLAYER);
272 if (o_ptr->marked & OM_NOMSG) {
273 o_ptr->marked &= ~OM_NOMSG;
278 msg_format(_("%sがある。", "You see %s."), o_name);
282 if (!check_store_item_to_inventory(creature_ptr, o_ptr)) {
283 msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
287 int is_pickup_successful = TRUE;
288 if (carry_query_flag) {
289 char out_val[MAX_NLEN + 20];
290 sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
291 is_pickup_successful = get_check(out_val);
294 if (is_pickup_successful) {
295 describe_pickup_item(creature_ptr, this_o_idx);