1 #include "target/projection-path-calculator.h"
2 #include "effect/effect-characteristics.h"
3 #include "floor/cave.h"
4 #include "grid/feature-flag-types.h"
6 #include "system/floor-type-definition.h"
9 * @brief Convert a "location" (Y, X) into a "grid" (G)
12 * return
\8co
\98H
\8dÀ
\95W
14 static u16b location_to_grid(POSITION y, POSITION x) { return 256 * y + x; }
17 * @brief
\8en
\93_
\82©
\82ç
\8fI
\93_
\82Ö
\82Ì
\92¼
\90ü
\8co
\98H
\82ð
\95Ô
\82· /
18 * Determine the path taken by a projection.
19 * @param player_ptr
\83v
\83\8c\81[
\83\84\81[
\82Ö
\82Ì
\8eQ
\8fÆ
\83|
\83C
\83\93\83^
20 * @param gp
\8co
\98H
\8dÀ
\95W
\83\8a\83X
\83g
\82ð
\95Ô
\82·
\8eQ
\8fÆ
\83|
\83C
\83\93\83^
21 * @param range
\8b\97\97£
22 * @param y1
\8en
\93_Y
\8dÀ
\95W
23 * @param x1
\8en
\93_X
\8dÀ
\95W
24 * @param y2
\8fI
\93_Y
\8dÀ
\95W
25 * @param x2
\8fI
\93_X
\8dÀ
\95W
26 * @param flg
\83t
\83\89\83OID
27 * @return
\83\8a\83X
\83g
\82Ì
\92·
\82³
29 int projection_path(player_type *player_ptr, u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg)
31 if ((x1 == x2) && (y1 == y2))
58 floor_type *floor_ptr = player_ptr->current_floor_ptr;
75 gp[n++] = location_to_grid(y, x);
76 if ((n + (k >> 1)) >= range)
79 if (!(flg & PROJECT_THRU)) {
80 if ((x == x2) && (y == y2))
84 if (flg & PROJECT_DISI) {
85 if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
87 } else if (flg & PROJECT_LOS) {
88 if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
90 } else if (!(flg & PROJECT_PATH)) {
91 if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
95 if (flg & PROJECT_STOP) {
96 if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
100 if (!in_bounds(floor_ptr, y, x))
131 gp[n++] = location_to_grid(y, x);
132 if ((n + (k >> 1)) >= range)
135 if (!(flg & (PROJECT_THRU))) {
136 if ((x == x2) && (y == y2))
140 if (flg & (PROJECT_DISI)) {
141 if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
143 } else if (flg & (PROJECT_LOS)) {
144 if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
146 } else if (!(flg & (PROJECT_PATH))) {
147 if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
151 if (flg & (PROJECT_STOP)) {
152 if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
156 if (!in_bounds(floor_ptr, y, x))
178 gp[n++] = location_to_grid(y, x);
179 if ((n + (n >> 1)) >= range)
182 if (!(flg & PROJECT_THRU)) {
183 if ((x == x2) && (y == y2))
187 if (flg & PROJECT_DISI) {
188 if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
190 } else if (flg & PROJECT_LOS) {
191 if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
193 } else if (!(flg & PROJECT_PATH)) {
194 if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
198 if (flg & PROJECT_STOP) {
199 if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
203 if (!in_bounds(floor_ptr, y, x))