#include "game-option/map-screen-options.h"
#include "grid/grid.h"
#include "grid/trap.h"
+#include "io/targeting.h"
#include "monster-floor/monster-generator.h"
#include "monster-floor/monster-remover.h"
#include "monster/monster-update.h"
bool projectable(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
{
u16b grid_g[512];
- int grid_n = project_path(player_ptr, grid_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, 0);
+ int grid_n = project_path(player_ptr, grid_g, (project_length ? project_length : get_max_range(player_ptr)), y1, x1, y2, x2, 0);
if (!grid_n) return TRUE;
POSITION y = GRID_Y(grid_g[grid_n - 1]);
return;
floor_type *floor_ptr = player_ptr->current_floor_ptr;
- int path_n = project_path(player_ptr, path_g, (project_length ? project_length : MAX_RANGE), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
+ int path_n = project_path(player_ptr, path_g, (project_length ? project_length : get_max_range(player_ptr)), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
player_ptr->redraw |= (PR_MAP);
handle_stuff(player_ptr);
for (int i = 0; i < path_n; i++) {
if (mode & TARGET_KILL)
{
/* Inner range */
- min_hgt = MAX((creature_ptr->y - MAX_RANGE), 0);
- max_hgt = MIN((creature_ptr->y + MAX_RANGE), creature_ptr->current_floor_ptr->height - 1);
- min_wid = MAX((creature_ptr->x - MAX_RANGE), 0);
- max_wid = MIN((creature_ptr->x + MAX_RANGE), creature_ptr->current_floor_ptr->width - 1);
+ min_hgt = MAX((creature_ptr->y - get_max_range(creature_ptr)), 0);
+ max_hgt = MIN((creature_ptr->y + get_max_range(creature_ptr)), creature_ptr->current_floor_ptr->height - 1);
+ min_wid = MAX((creature_ptr->x - get_max_range(creature_ptr)), 0);
+ max_wid = MIN((creature_ptr->x + get_max_range(creature_ptr)), creature_ptr->current_floor_ptr->width - 1);
}
else /* not targetting */
{
*dp = dir;
return TRUE;
}
+
+/*!
+ * @briefプレイヤーの攻撃射程(マス) / Maximum range (spells, etc)
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return 射程
+ */
+int get_max_range(player_type *creature_ptr) { return creature_ptr->phase_out ? 36 : 18; }
bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed);
bool get_rep_dir(player_type *creature_ptr, DIRECTION *dp, bool under);
bool tgt_pt(player_type *creature_ptr, POSITION *x, POSITION *y);
+int get_max_range(player_type *creature_ptr);
for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
- if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && distance(caster_ptr->y, caster_ptr->x, y, x) <= MAX_RANGE
+ if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && distance(caster_ptr->y, caster_ptr->x, y, x) <= get_max_range(caster_ptr)
&& distance(caster_ptr->y, caster_ptr->x, y, x) != 0 && player_has_los_bold(caster_ptr, y, x)
&& projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
mirror_y[mirror_num] = y;
#include "effect/effect-characteristics.h"
#include "game-option/birth-options.h"
#include "grid/grid.h"
+#include "io/targeting.h"
#include "monster-floor/monster-move.h"
#include "monster-race/monster-race.h"
#include "monster-race/race-flags-ability1.h"
{
floor_type *floor_ptr = target_ptr->current_floor_ptr;
u16b grid_g[512];
- int grid_n = project_path(target_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, 0);
+ int grid_n = project_path(target_ptr, grid_g, get_max_range(target_ptr), y1, x1, y2, x2, 0);
if (!grid_n)
return FALSE;
BIT_FLAGS f5 = r_ptr->a_ability_flags1;
BIT_FLAGS f6 = r_ptr->a_ability_flags2;
- if ((m_ptr->cdis > MAX_RANGE) && !m_ptr->target_y)
+ if ((m_ptr->cdis > get_max_range(target_ptr)) && !m_ptr->target_y)
return FALSE;
POSITION x = target_ptr->x;
}
} else {
bool success = FALSE;
- if ((f4 & RF4_BR_DISI) && (m_ptr->cdis < MAX_RANGE / 2) && in_disintegration_range(floor_ptr, m_ptr->fy, m_ptr->fx, y, x)
+ if ((f4 & RF4_BR_DISI) && (m_ptr->cdis < get_max_range(target_ptr) / 2) && in_disintegration_range(floor_ptr, m_ptr->fy, m_ptr->fx, y, x)
&& (one_in_(10) || (projectable(target_ptr, y, x, m_ptr->fy, m_ptr->fx) && one_in_(2)))) {
do_spell = DO_SPELL_BR_DISI;
success = TRUE;
- } else if ((f4 & RF4_BR_LITE) && (m_ptr->cdis < MAX_RANGE / 2) && los(target_ptr, m_ptr->fy, m_ptr->fx, y, x) && one_in_(5)) {
+ } else if ((f4 & RF4_BR_LITE) && (m_ptr->cdis < get_max_range(target_ptr) / 2) && los(target_ptr, m_ptr->fy, m_ptr->fx, y, x) && one_in_(5)) {
do_spell = DO_SPELL_BR_LITE;
success = TRUE;
- } else if ((f5 & RF5_BA_LITE) && (m_ptr->cdis <= MAX_RANGE)) {
+ } else if ((f5 & RF5_BA_LITE) && (m_ptr->cdis <= get_max_range(target_ptr))) {
POSITION by = y, bx = x;
get_project_point(target_ptr, m_ptr->fy, m_ptr->fx, &by, &bx, 0L);
if ((distance(by, bx, y, x) <= 3) && los(target_ptr, by, bx, y, x) && one_in_(5)) {
success = TRUE;
}
- if (y_br_lite && x_br_lite && (m_ptr->cdis < MAX_RANGE / 2) && one_in_(5)) {
+ if (y_br_lite && x_br_lite && (m_ptr->cdis < get_max_range(target_ptr) / 2) && one_in_(5)) {
if (!success) {
y = y_br_lite;
x = x_br_lite;
#include "effect/effect-characteristics.h"
#include "floor/floor.h"
#include "grid/grid.h"
+#include "io/targeting.h"
#include "main/sound-definitions-table.h"
#include "monster-floor/monster-move.h"
#include "monster-race/monster-race.h"
{
floor_type *floor_ptr = target_ptr->current_floor_ptr;
u16b grid_g[512];
- int grid_n = project_path(target_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, PROJECT_THRU);
+ int grid_n = project_path(target_ptr, grid_g, get_max_range(target_ptr), y1, x1, y2, x2, PROJECT_THRU);
if (!grid_n)
return FALSE;
}
u16b grid_g[512];
- int grid_n = project_path(master_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, flg);
+ int grid_n = project_path(master_ptr, grid_g, get_max_range(master_ptr), y1, x1, y2, x2, flg);
int i;
POSITION y = y1;
POSITION x = x1;
void get_project_point(player_type *target_ptr, POSITION sy, POSITION sx, POSITION *ty, POSITION *tx, BIT_FLAGS flg)
{
u16b path_g[128];
- int path_n = project_path(target_ptr, path_g, MAX_RANGE, sy, sx, *ty, *tx, flg);
+ int path_n = project_path(target_ptr, path_g, get_max_range(target_ptr), sy, sx, *ty, *tx, flg);
*ty = sy;
*tx = sx;
for (int i = 0; i < path_n; i++) {
#include "floor/floor.h"
#include "game-option/map-screen-options.h"
#include "grid/grid.h"
+#include "io/targeting.h"
#include "monster-race/monster-race.h"
#include "monster-race/race-flags2.h"
#include "monster/monster-describer.h"
#include "monster/monster-update.h"
#include "player/player-effects.h"
#include "player/special-defense-types.h"
-#include "spell/process-effect.h"
#include "spell-kind/spells-launcher.h"
+#include "spell/process-effect.h"
#include "spell/spell-types.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
return;
if (!in_bounds2(floor_ptr, y, x))
return;
- if (distance(caster_ptr->y, caster_ptr->x, y, x) > MAX_RANGE)
+ if (distance(caster_ptr->y, caster_ptr->x, y, x) > get_max_range(caster_ptr))
return;
/* Verify this grid */
ny = y;
nx = x;
mmove2(&ny, &nx, caster_ptr->y, caster_ptr->x, ty, tx);
- if (MAX_RANGE <= distance(caster_ptr->y, caster_ptr->x, ny, nx)) break;
+ if (get_max_range(caster_ptr) <= distance(caster_ptr->y, caster_ptr->x, ny, nx)) break;
if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, ny, nx, FF_PROJECT)) break;
if ((dir != 5) && caster_ptr->current_floor_ptr->grid_array[ny][nx].m_idx != 0) break;
#include "grid/feature.h"
#include "io/cursor.h"
#include "io/screen-util.h"
+#include "io/targeting.h"
#include "main/sound-definitions-table.h"
#include "main/sound-of-music.h"
#include "monster-race/monster-race.h"
}
/* Calculate the projection path */
- path_n = project_path(caster_ptr, path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flag);
+ path_n = project_path(caster_ptr, path_g, (project_length ? project_length : get_max_range(caster_ptr)), y1, x1, y2, x2, flag);
handle_stuff(caster_ptr);
if (typ == GF_SEEKER) {
monster_target_x = x;
remove_mirror(caster_ptr, y, x);
next_mirror(caster_ptr, &oy, &ox, y, x);
- path_n = i + project_path(caster_ptr, &(path_g[i + 1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flag);
+ path_n = i + project_path(caster_ptr, &(path_g[i + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, oy, ox, flag);
for (j = last_i; j <= i; j++) {
y = GRID_Y(path_g[j]);
x = GRID_X(path_g[j]);
path_n = i;
second_step = i + 1;
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x - 1, flag);
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x, flag);
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x + 1, flag);
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x - 1, flag);
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x + 1, flag);
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x - 1, flag);
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x, flag);
- path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x + 1, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y - 1, x - 1, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y - 1, x, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y - 1, x + 1, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y, x - 1, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y, x + 1, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y + 1, x - 1, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y + 1, x, flag);
+ path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : get_max_range(caster_ptr)), y, x, y + 1, x + 1, flag);
}
}
project_length = 0;
/* If we found a "target", explode there */
- if (dist <= MAX_RANGE) {
+ if (dist <= get_max_range(caster_ptr)) {
if ((flag & (PROJECT_BEAM)) && (grids > 0))
grids--;
tx = target_col;
ty = target_row;
- if (distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE) {
+ if (distance(caster_ptr->y, caster_ptr->x, ty, tx) > get_max_range(caster_ptr)) {
msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
return;
}
tx += ddx[dir];
g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
- if ((distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE) || !cave_have_flag_bold(caster_ptr->current_floor_ptr, ty, tx, FF_PROJECT))
+ if ((distance(caster_ptr->y, caster_ptr->x, ty, tx) > get_max_range(caster_ptr))
+ || !cave_have_flag_bold(caster_ptr->current_floor_ptr, ty, tx, FF_PROJECT))
return;
}
}
m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
monster_desc(caster_ptr, m_name, m_ptr, 0);
msg_format(_("%sを引き戻した。", "You pull back %s."), m_name);
- path_n = project_path(caster_ptr, path_g, MAX_RANGE, target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
+ path_n = project_path(caster_ptr, path_g, get_max_range(caster_ptr), target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
ty = target_row, tx = target_col;
for (i = 1; i < path_n; i++) {
POSITION ny = GRID_Y(path_g[i]);
*/
#define MAX_SIGHT 20 /*!< プレイヤーの最大視界範囲(マス) / Maximum view distance */
-/*!
- * todo この関数マクロをどこに置くべきか迷ったので保留
- * !< プレイヤーの攻撃射程(マス) / Maximum range (spells, etc)
- */
-#define MAX_RANGE (p_ptr->phase_out ? 36 : 18)
#define AAF_LIMIT 100 /*!< モンスターの限界感知範囲(マス) Limit of sensing radius */
#define MIN_M_ALLOC_TD 4 /*!< 街(昼間)の最低住人配置数 / The town starts out with 4 residents during the day */