/*
- * Teleport monster next to the player
+ * Teleport monster next to a grid near the given location
*/
-void teleport_to_player(int m_idx, int power)
+void teleport_monster_to(int m_idx, int ty, int tx, int power)
{
int ny, nx, oy, ox, d, i, min;
int attempts = 500;
/* Try several locations */
for (i = 0; i < 500; i++)
{
+ cave_type *c_ptr;
+
/* Pick a (possibly illegal) location */
while (1)
{
- ny = rand_spread(py, dis);
- nx = rand_spread(px, dis);
- d = distance(py, px, ny, nx);
+ ny = rand_spread(ty, dis);
+ nx = rand_spread(tx, dis);
+ d = distance(ty, tx, ny, nx);
if ((d >= min) && (d <= dis)) break;
}
/* Require "empty" floor space */
if (!cave_empty_bold(ny, nx)) continue;
+ c_ptr = &cave[ny][nx];
+
/* Hack -- no teleport onto glyph of warding */
- if (is_glyph_grid(&cave[ny][nx])) continue;
- if (is_explosive_rune_grid(&cave[ny][nx])) continue;
+ if (is_glyph_grid(c_ptr)) continue;
+ if (is_explosive_rune_grid(c_ptr)) continue;
/* ...nor onto the Pattern */
- if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
- (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
+ if ((c_ptr->feat >= FEAT_PATTERN_START) &&
+ (c_ptr->feat <= FEAT_PATTERN_XTRA2)) continue;
/* No teleporting into vaults and such */
- /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
+ /* if (c_ptr->info & (CAVE_ICKY)) continue; */
/* This grid looks good */
look = FALSE;
if ((r_ptr->flags6 & RF6_TPORT) &&
!(r_ptr->flagsr & RFR_RES_TELE))
{
- if (!m_ptr->csleep) teleport_to_player(tmp_m_idx, r_ptr->level);
+ if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
}
}
}
void teleport_level(int m_idx)
{
bool go_up;
- monster_type *m_ptr;
char m_name[160];
bool see_m = TRUE;
}
else /* To monster */
{
- m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = &m_list[m_idx];
/* Get the monster name (or "it") */
monster_desc(m_name, m_ptr, 0);
see_m = m_ptr->ml;
}
- /* No effect in arena or quest */
- if (p_ptr->inside_arena || p_ptr->inside_battle || (p_ptr->inside_quest && !random_quest_number(dun_level)) ||
- ((quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth)) && (dun_level > 1) && ironman_downward && (m_idx <= 0)))
+ /* No effect in some case */
+ if (TELE_LEVEL_IS_INEFF(m_idx))
{
#ifdef JP
if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
/* Monster level teleportation is simple deleting now */
if (m_idx > 0)
{
+ monster_type *m_ptr = &m_list[m_idx];
+
/* Check for quest completion */
check_quest_completion(m_ptr);
/* Reset sleep counter */
m_ptr->csleep = 0;
+ if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+
/* Notice the "waking up" */
if (m_ptr->ml)
{
c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
/* Set boundary mimic if needed */
- if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
+ if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = f_info[floor_type[randint0(100)]].mimic;
c_ptr = &cave[cur_hgt - 1][x];
c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
/* Set boundary mimic if needed */
- if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
+ if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = f_info[floor_type[randint0(100)]].mimic;
}
/* Special boundary walls -- Left and right */
c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
/* Set boundary mimic if needed */
- if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
+ if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = f_info[floor_type[randint0(100)]].mimic;
c_ptr = &cave[y][cur_wid - 1];
c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
/* Set boundary mimic if needed */
- if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
+ if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = f_info[floor_type[randint0(100)]].mimic;
}
/* Mega-Hack -- Forget the view and lite */
/* Create a glyph */
cave[py][px].info |= CAVE_OBJECT;
- cave[py][px].mimic = FEAT_GLYPH;
+ cave[py][px].mimic = f_info[FEAT_GLYPH].mimic;
/* Notice */
note_spot(py, px);
/* Create a mirror */
cave[py][px].info |= CAVE_OBJECT;
- cave[py][px].mimic = FEAT_MIRROR;
+ cave[py][px].mimic = f_info[FEAT_MIRROR].mimic;
/* Turn on the light */
cave[py][px].info |= CAVE_GLOW;
/* Create a glyph */
cave[py][px].info |= CAVE_OBJECT;
- cave[py][px].mimic = FEAT_MINOR_GLYPH;
+ cave[py][px].mimic = f_info[FEAT_MINOR_GLYPH].mimic;
/* Notice */
note_spot(py, px);
p_ptr->csp = p_ptr->msp;
}
+ /* Redraw mana and hp */
+ p_ptr->redraw |= (PR_MANA);
+
p_ptr->notice |= (PN_COMBINE | PN_REORDER);
p_ptr->window |= (PW_INVEN);