1 #include "spell-kind/spells-fetcher.h"
2 #include "core/player-redraw-types.h"
3 #include "core/player-update-types.h"
4 #include "core/stuff-handler.h"
5 #include "flavor/flavor-describer.h"
6 #include "flavor/object-flavor-types.h"
7 #include "floor/cave.h"
8 #include "grid/feature-flag-types.h"
10 #include "monster-race/monster-race.h"
11 #include "monster-race/race-flags7.h"
12 #include "monster/monster-describer.h"
13 #include "monster/monster-status-setter.h"
14 #include "monster/monster-update.h"
15 #include "system/floor-type-definition.h"
16 #include "system/object-type-definition.h"
17 #include "target/projection-path-calculator.h"
18 #include "target/target-checker.h"
19 #include "target/target-setter.h"
20 #include "target/target-types.h"
21 #include "util/bit-flags-calculator.h"
22 #include "view/display-messages.h"
26 * Fetch an item (teleport it right underneath the caster)
27 * @param caster_ptr プレーヤーへの参照ポインタ
30 * @param require_los 射線の通りを要求するならばTRUE
33 void fetch_item(player_type *caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los)
37 GAME_TEXT o_name[MAX_NLEN];
39 if (caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].o_idx) {
40 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
45 if (dir == 5 && target_okay(caster_ptr)) {
49 if (distance(caster_ptr->y, caster_ptr->x, ty, tx) > get_max_range(caster_ptr)) {
50 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
54 g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
56 msg_print(_("そこには何もありません。", "There is no object there."));
60 if (g_ptr->info & CAVE_ICKY) {
61 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
66 if (!player_has_los_bold(caster_ptr, ty, tx)) {
67 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
69 } else if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, ty, tx)) {
70 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
77 bool is_first_loop = TRUE;
78 g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
79 while (is_first_loop || !g_ptr->o_idx) {
80 is_first_loop = FALSE;
83 g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
85 if ((distance(caster_ptr->y, caster_ptr->x, ty, tx) > get_max_range(caster_ptr))
86 || !cave_has_flag_bold(caster_ptr->current_floor_ptr, ty, tx, FF_PROJECT))
91 o_ptr = &caster_ptr->current_floor_ptr->o_list[g_ptr->o_idx];
92 if (o_ptr->weight > wgt) {
93 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
97 OBJECT_IDX i = g_ptr->o_idx;
98 g_ptr->o_idx = o_ptr->next_o_idx;
99 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].o_idx = i; /* 'move' it */
101 o_ptr->next_o_idx = 0;
102 o_ptr->iy = caster_ptr->y;
103 o_ptr->ix = caster_ptr->x;
105 describe_flavor(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
106 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
108 note_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
109 caster_ptr->redraw |= PR_MAP;
112 bool fetch_monster(player_type *caster_ptr)
116 GAME_TEXT m_name[MAX_NLEN];
122 if (!target_set(caster_ptr, TARGET_KILL))
125 m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
128 if (m_idx == caster_ptr->riding)
130 if (!player_has_los_bold(caster_ptr, target_row, target_col))
132 if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
135 m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
136 monster_desc(caster_ptr, m_name, m_ptr, 0);
137 msg_format(_("%sを引き戻した。", "You pull back %s."), m_name);
138 path_n = projection_path(caster_ptr, path_g, get_max_range(caster_ptr), target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
139 ty = target_row, tx = target_col;
140 for (i = 1; i < path_n; i++) {
141 POSITION ny = get_grid_y(path_g[i]);
142 POSITION nx = get_grid_x(path_g[i]);
143 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[ny][nx];
145 if (in_bounds(caster_ptr->current_floor_ptr, ny, nx) && is_cave_empty_bold(caster_ptr, ny, nx) && !(g_ptr->info & CAVE_OBJECT)
146 && !pattern_tile(caster_ptr->current_floor_ptr, ny, nx)) {
152 caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx = 0;
153 caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
156 (void)set_monster_csleep(caster_ptr, m_idx, 0);
157 update_monster(caster_ptr, m_idx, TRUE);
158 lite_spot(caster_ptr, target_row, target_col);
159 lite_spot(caster_ptr, ty, tx);
160 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
161 caster_ptr->update |= (PU_MON_LITE);
164 if (!caster_ptr->image)
165 monster_race_track(caster_ptr, m_ptr->ap_r_idx);
167 health_track(caster_ptr, m_idx);