/*! * @brief モンスターにとって所定の地点が召還に相応しい地点かどうかを返す。 / * Determine if there is a space near the player in which a summoned creature can appear * @param y1 判定を行いたいマスのY座標 * @param x1 判定を行いたいマスのX座標 * @return 召還に相応しいならばTRUEを返す */ bool summon_possible(int y1, int x1) { int y, x; /* Start at the player's location, and check 2 grids in each dir */ for (y = y1 - 2; y <= y1 + 2; y++) { for (x = x1 - 2; x <= x1 + 2; x++) { /* Ignore illegal locations */ if (!in_bounds(y, x)) continue; /* Only check a circular area */ if (distance(y1, x1, y, x)>2) continue; /* ...nor on the Pattern */ if (pattern_tile(y, x)) continue; /* Require empty floor grid in line of projection */ if (cave_empty_bold(y, x) && projectable(y1, x1, y, x) && projectable(y, x, y1, x1)) return (TRUE); } } return FALSE; }
/* * Helper function for alloc_stairs(). * * Is this a good location for stairs? */ static bool alloc_stairs_aux(int y, int x, int walls) { /* Access the grid */ cave_type *c_ptr = &cave[y][x]; /* Require "naked" floor grid */ if (!is_floor_grid(c_ptr)) return FALSE; if (pattern_tile(y, x)) return FALSE; if (c_ptr->o_idx || c_ptr->m_idx) return FALSE; /* Require a certain number of adjacent walls */ if (next_to_walls(y, x) < walls) return FALSE; return TRUE; }
/*! * @brief フロア移動時、プレイヤーの移動先モンスターが既にいた場合ランダムな近隣に移動させる / When a monster is at a place where player will return, * @return なし */ static void get_out_monster(void) { int tries = 0; int dis = 1; int oy = p_ptr->y; int ox = p_ptr->x; MONSTER_IDX m_idx = cave[oy][ox].m_idx; /* Nothing to do if no monster */ if (!m_idx) return; /* Look until done */ while (TRUE) { monster_type *m_ptr; /* Pick a (possibly illegal) location */ int ny = rand_spread(oy, dis); int nx = rand_spread(ox, dis); tries++; /* Stop after 1000 tries */ if (tries > 10000) return; /* * Increase distance after doing enough tries * compared to area of possible space */ if (tries > 20 * dis * dis) dis++; /* Ignore illegal locations */ if (!in_bounds(ny, nx)) continue; /* Require "empty" floor space */ if (!cave_empty_bold(ny, nx)) continue; /* Hack -- no teleport onto glyph of warding */ if (is_glyph_grid(&cave[ny][nx])) continue; if (is_explosive_rune_grid(&cave[ny][nx])) continue; /* ...nor onto the Pattern */ if (pattern_tile(ny, nx)) continue; /*** It's a good place ***/ m_ptr = &m_list[m_idx]; /* Update the old location */ cave[oy][ox].m_idx = 0; /* Update the new location */ cave[ny][nx].m_idx = m_idx; /* Move the monster */ m_ptr->fy = ny; m_ptr->fx = nx; /* No need to do update_mon() */ /* Success */ return; } }