/*!
* @brief モンスターが隠れ潜める地点を返す /
* Choose a good hiding place near a monster for it to run toward.
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param m_idx モンスターの参照ID
* @param yp 移動先のマスのY座標を返す参照ポインタ
* @param xp 移動先のマスのX座標を返す参照ポインタ
*\n
* Return TRUE if a good location is available.\n
*/
-static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
+static bool find_hiding(player_type *target_ptr, MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
{
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+ floor_type *floor_ptr = target_ptr->current_floor_ptr;
+ monster_type *m_ptr = &floor_ptr->m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
POSITION fy = m_ptr->fy;
x = fx + dx;
/* Skip illegal locations */
- if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue;
+ if (!in_bounds(floor_ptr, y, x)) continue;
/* Skip occupied locations */
if (!monster_can_enter(y, x, r_ptr, 0)) continue;
/* Check for hidden, available grid */
- if (!projectable(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, y, x) && clean_shot(fy, fx, y, x, FALSE))
+ if (!projectable(floor_ptr, target_ptr->y, target_ptr->x, y, x) && clean_shot(target_ptr, fy, fx, y, x, FALSE))
{
/* Calculate distance from player */
- dis = distance(y, x, p_ptr->y, p_ptr->x);
+ dis = distance(y, x, target_ptr->y, target_ptr->x);
/* Remember if closer than previous */
if (dis < gdis && dis >= 2)
/*!
* @brief モンスターの移動方向を返す /
* Choose "logical" directions for monster movement
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param m_idx モンスターの参照ID
* @param mm 移動方向を返す方向IDの参照ポインタ
* @return 有効方向があった場合TRUEを返す
*/
-static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
+static bool get_moves(player_type *target_ptr, MONSTER_IDX m_idx, DIRECTION *mm)
{
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+ floor_type *floor_ptr = target_ptr->current_floor_ptr;
+ monster_type *m_ptr = &floor_ptr->m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
POSITION y = 0, ay, x = 0, ax;
int move_val = 0;
- POSITION y2 = p_ptr->y;
- POSITION x2 = p_ptr->x;
+ POSITION y2 = target_ptr->y;
+ POSITION x2 = target_ptr->x;
bool done = FALSE;
bool will_run = mon_will_run(m_idx);
grid_type *g_ptr;
- bool no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].cost > 2));
- bool can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall));
+ bool no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].cost > 2));
+ bool can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != target_ptr->riding) || target_ptr->pass_wall));
/* Counter attack to an enemy monster */
if (!will_run && m_ptr->target_y)
{
- int t_m_idx = p_ptr->current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
+ int t_m_idx = floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
/* The monster must be an enemy, and in LOS */
if (t_m_idx &&
- are_enemies(m_ptr, &p_ptr->current_floor_ptr->m_list[t_m_idx]) &&
- los(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x) &&
- projectable(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
+ are_enemies(m_ptr, &floor_ptr->m_list[t_m_idx]) &&
+ los(floor_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x) &&
+ projectable(floor_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
{
/* Extract the "pseudo-direction" */
y = m_ptr->fy - m_ptr->target_y;
if (!done && !will_run && is_hostile(m_ptr) &&
(r_ptr->flags1 & RF1_FRIENDS) &&
- ((los(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) ||
- (p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
+ ((los(floor_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x) && projectable(floor_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x)) ||
+ (floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
{
/*
* Animal packs try to get the player out of corridors
/* Count room grids next to player */
for (i = 0; i < 8; i++)
{
- int xx = p_ptr->x + ddx_ddd[i];
- int yy = p_ptr->y + ddy_ddd[i];
+ int xx = target_ptr->x + ddx_ddd[i];
+ int yy = target_ptr->y + ddy_ddd[i];
- if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue;
+ if (!in_bounds2(floor_ptr, yy, xx)) continue;
- g_ptr = &p_ptr->current_floor_ptr->grid_array[yy][xx];
+ g_ptr = &floor_ptr->grid_array[yy][xx];
/* Check grid */
if (monster_can_cross_terrain(g_ptr->feat, r_ptr, 0))
room++;
}
}
- if (p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
+ if (floor_ptr->grid_array[target_ptr->y][target_ptr->x].info & CAVE_ROOM) room -= 2;
if (!r_ptr->flags4 && !r_ptr->a_ability_flags1 && !r_ptr->a_ability_flags2) room -= 2;
/* Not in a room and strong player */
- if (room < (8 * (p_ptr->chp + p_ptr->csp)) /
- (p_ptr->mhp + p_ptr->msp))
+ if (room < (8 * (target_ptr->chp + target_ptr->csp)) /
+ (target_ptr->mhp + target_ptr->msp))
{
/* Find hiding place */
- if (find_hiding(m_idx, &y, &x)) done = TRUE;
+ if (find_hiding(target_ptr, m_idx, &y, &x)) done = TRUE;
}
}
/* Monster groups try to surround the player */
- if (!done && (p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < 3))
+ if (!done && (floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < 3))
{
int i;
for (i = 0; i < 8; i++)
{
/* Pick squares near player (semi-randomly) */
- y2 = p_ptr->y + ddy_ddd[(m_idx + i) & 7];
- x2 = p_ptr->x + ddx_ddd[(m_idx + i) & 7];
+ y2 = target_ptr->y + ddy_ddd[(m_idx + i) & 7];
+ x2 = target_ptr->x + ddx_ddd[(m_idx + i) & 7];
/* Already there? */
if ((m_ptr->fy == y2) && (m_ptr->fx == x2))
{
/* Attack the player */
- y2 = p_ptr->y;
- x2 = p_ptr->x;
+ y2 = target_ptr->y;
+ x2 = target_ptr->x;
break;
}
- if (!in_bounds2(p_ptr->current_floor_ptr, y2, x2)) continue;
+ if (!in_bounds2(floor_ptr, y2, x2)) continue;
/* Ignore filled grids */
if (!monster_can_enter(y2, x2, r_ptr, 0)) continue;
}
/* Find the player */
- (void)get_moves(m_idx, mm);
+ (void)get_moves(target_ptr, m_idx, mm);
/* Restore the leash */
target_ptr->pet_follow_distance = (s16b)dis;
else
{
/* Logical moves, may do nothing */
- if (!get_moves(m_idx, mm)) return;
+ if (!get_moves(target_ptr, m_idx, mm)) return;
}
/* Assume nothing */
/*!
* @brief モンスターにとってボルト型魔法が有効な状態かを返す /
* Determine if a bolt spell will hit the player.
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param y1 ボルト魔法発射地点のY座標
* @param x1 ボルト魔法発射地点のX座標
* @param y2 ボルト魔法目標地点のY座標
* no equally friendly monster is\n
* between the attacker and target.\n
*/
-bool clean_shot(POSITION y1, POSITION x1, POSITION y2, POSITION x2, bool is_friend)
+bool clean_shot(player_type *target_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, bool is_friend)
{
/* Must be the same as projectable() */
u16b grid_g[512];
/* Check the projection path */
- grid_n = project_path(p_ptr->current_floor_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, 0);
+ floor_type *floor_ptr = target_ptr->current_floor_ptr;
+ grid_n = project_path(floor_ptr, grid_g, MAX_RANGE, y1, x1, y2, x2, 0);
/* No grid is ever projectable from itself */
if (!grid_n) return FALSE;
y = GRID_Y(grid_g[i]);
x = GRID_X(grid_g[i]);
- if ((p_ptr->current_floor_ptr->grid_array[y][x].m_idx > 0) && !((y == y2) && (x == x2)))
+ if ((floor_ptr->grid_array[y][x].m_idx > 0) && !((y == y2) && (x == x2)))
{
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->current_floor_ptr->grid_array[y][x].m_idx];
+ monster_type *m_ptr = &floor_ptr->m_list[floor_ptr->grid_array[y][x].m_idx];
if (is_friend == is_pet(m_ptr))
{
return FALSE;
}
}
+
/* Pets may not shoot through the character - TNB */
- if (player_bold(p_ptr, y, x))
+ if (player_bold(target_ptr, y, x))
{
if (is_friend) return FALSE;
}
/*!
* @brief モンスターのボルト型魔法処理 /
* Cast a bolt at the player Stop if we hit a monster Affect monsters and the player
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param m_idx モンスターのID
* @param y 目標のY座標
* @param x 目標のX座標
/*!
* @brief モンスターのビーム型魔法処理 /
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param m_idx モンスターのID
* @param y 目標のY座標
* @param x 目標のX座標
/*!
* @brief モンスターのボール型&ブレス型魔法処理 /
* Cast a breath (or ball) attack at the player Pass over any monsters that may be in the way Affect grids, objects, monsters, and the player
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param y 目標地点のY座標
* @param x 目標地点のX座標
* @param m_idx モンスターのID
/*!
* @brief ID値が特別効果のモンスター魔法IDかどうかを返す /
* Return TRUE if a spell special.
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param spell 判定対象のID
* @return 特別効果魔法のIDならばTRUEを返す。
*/
/*!
* @brief モンスターの魔法選択ルーチン
* Have a monster choose a spell from a list of "useful" spells.
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param m_idx モンスターの構造体配列ID
* @param spells 候補魔法IDをまとめた配列
* @param num spellsの長さ
/*!
* @brief モンスターがプレイヤーにダメージを与えるための最適な座標を算出する /
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param m_ptr 技能を使用するモンスター構造体の参照ポインタ
* @param yp 最適な目標地点のY座標を返す参照ポインタ
* @param xp 最適な目標地点のX座標を返す参照ポインタ
* todo メインルーチンの割に長過ぎる。要分割
* @brief モンスターの特殊技能メインルーチン /
* Creatures can cast spells, shoot missiles, and breathe.
- * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param target_ptr プレーヤーへの参照ポインタ
* @param m_idx モンスター構造体配列のID
* @return 実際に特殊技能を利用したらTRUEを返す
* @details
if (((f4 & RF4_BOLT_MASK) ||
(f5 & RF5_BOLT_MASK) ||
(f6 & RF6_BOLT_MASK)) &&
- !clean_shot(m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x, FALSE))
+ !clean_shot(target_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x, FALSE))
{
/* Remove spells that will only hurt friends */
f4 &= ~(RF4_BOLT_MASK);