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4CGYUPRJPDPAF6E65Y3MGAK45PNDPF2CNT276V7P37PPLX3AR5QC BUSA7O6EFBZVAG2RL5T7MD2WTWKOEKKIAAZ2VS4Y3L6ECT4HQR6QC bool set_target = false;for (int j = -LOS_RADIUS; j < LOS_RADIUS; j++)for (int k = -LOS_RADIUS; k < LOS_RADIUS; k++, set_target = false){pos_x = patrol_x + j;pos_y = patrol_y + k;
for (radius_iterator ri(mon->patrol_point, LOS_RADIUS, true, false);ri; ++ri){// Don't bother for the current position. If everything fails,// we'll stay here anyway.if ( *ri == mon->pos() )continue;
// Don't bother for the current position. If everything fails,// we'll stay here anyway.if (pos_x == mon->x && pos_y == mon->y)continue;
// Don't bother moving to squares (currently) occupied by a// monster. We'll usually be able to find other target squares// (and if we're not, we couldn't move anyway), and this avoids// monsters trying to move onto a grid occupied by a plant or// sleeping monster.if (mgrd(*ri) != NON_MONSTER)continue;
if (!mon->can_pass_through_feat(grd[pos_x][pos_y]))
if (patrol_seen){// If the patrol point can be easily (within LOS) reached// from the current position, it suffices if the target is// within reach of the patrol point OR the current position:// we can easily get there.// Only smart monsters will even attempt to move out of the// patrol area.// NOTE: Either of these can take us into a position where the// target cannot be easily reached (e.g. blocked by a wall)// and the patrol point is out of sight, too. Such a case// will be handled below, though it might take a while until// a monster gets out of a deadlock. (5% chance per turn.)if (!patrol.in_sight(*ri) && (!is_smart || !lm.in_sight(*ri)))
// Don't bother moving to squares (currently) occupied by a// monster. We'll usually be able to find other target squares// (and if we're not, we couldn't move anyway), and this avoids// monsters trying to move onto a grid occupied by a plant or// sleeping monster.if (mgrd[pos_x][pos_y] != NON_MONSTER)
}else{// If, however, the patrol point is out of reach, we have to// make sure the new target brings us into reach of it.// This means that the target must be reachable BOTH from// the patrol point AND the current position.if (!patrol.in_sight(*ri) || !lm.in_sight(*ri))
if (patrol_seen){// If the patrol point can be easily (within LOS) reached// from the current position, it suffices if the target is// within reach of the patrol point OR the current position:// we can easily get there.// Only smart monsters will even attempt to move out of the// patrol area.// NOTE: Either of these can take us into a position where the// target cannot be easily reached (e.g. blocked by a wall)// and the patrol point is out of sight, too. Such a case// will be handled below, though it might take a while until// a monster gets out of a deadlock. (5% chance per turn.)if (!patrol.in_sight(pos_x, pos_y)&& (!is_smart || !lm.in_sight(pos_x, pos_y))){continue;}}else{// If, however, the patrol point is out of reach, we have to// make sure the new target brings us into reach of it.// This means that the target must be reachable BOTH from// the patrol point AND the current position.if (!patrol.in_sight(pos_x, pos_y)|| !lm.in_sight(pos_x, pos_y)){continue;}// If this fails for all surrounding squares (probably because// we're too far away), we fall back to heading directly for// the patrol point.}
// If this fails for all surrounding squares (probably because// we're too far away), we fall back to heading directly for// the patrol point.}
if (intel == I_PLANT && pos_x == patrol_x && pos_y == patrol_y){// Slightly greater chance to simply head for the centre.count_grids += 3;if (x_chance_in_y(3, count_grids))set_target = true;}else if (one_chance_in(++count_grids))
bool set_target = false;if (intel == I_PLANT && *ri == mon->patrol_point){// Slightly greater chance to simply head for the centre.count_grids += 3;if (x_chance_in_y(3, count_grids))
coord_def gp;for (gp.y = (you.y_pos - 8); (gp.y <= you.y_pos + 8); gp.y++)for (gp.x = (you.x_pos - 8); (gp.x <= you.x_pos + 8); gp.x++)
for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri){const coord_def ep = *ri - you.pos() + coord_def(9, 9);if (env.show(ep))
dungeon_feature_type feat = grd[gp.x][gp.y];if (feat == DNGN_LAVA){you.lava_in_sight = 1;if (you.water_in_sight > 0)break;}else if (feat == DNGN_DEEP_WATER){you.water_in_sight = 1;if (you.lava_in_sight > 0)break;}
you.lava_in_sight = 1;if (you.water_in_sight > 0)break;}else if (feat == DNGN_DEEP_WATER){you.water_in_sight = 1;if (you.lava_in_sight > 0)break;
bool flies = mons_flies(mon);bool amphibious = mons_amphibious(mon);habitat_type habit = mons_habitat(mon);int x, y;monsters *m;for (int i = -2; i <= 2; ++i)for (int j = -2; j <= 2; ++j){if (i == 0 && j == 0)continue;
// Don't restrict smarter monsters as they might find a path// a dumber monster wouldn't.if (mons_intel(m->type) > intel)continue;
// Don't restrict smarter monsters as they might find a path// a dumber monster wouldn't.if (mons_intel(m->type) > intel)continue;
// Same for a swimming one, around water.if (you.water_in_sight > 0 && !amphibious && mons_amphibious(m))continue;
// Same for a swimming one, around water.if (you.water_in_sight > 0 && !amphibious && mons_amphibious(m))continue;