/* Monster must be 'an enemy' */
if (!are_enemies(m_ptr, t_ptr)) continue;
- can_pass_wall = (((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || (p_ptr->pass_wall))) || ((r_ptr->flags2 & RF2_KILL_WALL) && (m_idx != p_ptr->riding)));
+ can_pass_wall = (((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall)) || ((r_ptr->flags2 & RF2_KILL_WALL) && (m_idx != p_ptr->riding)));
/* Monster must be projectable if we can't pass through walls */
if (!can_pass_wall &&
cost = c_ptr->cost;
/* Monster cannot kill or pass walls */
- if (!(((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall)) || (r_ptr->flags2 & RF2_KILL_WALL)))
+ if (!(((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall)) || ((r_ptr->flags2 & RF2_KILL_WALL) && (m_idx != p_ptr->riding))))
{
if (cost == 0) continue;
if (!can_open_door && is_closed_door(c_ptr->feat)) continue;
if (no_flow) return (FALSE);
/* Monster can go through rocks */
- if ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || (p_ptr->pass_wall))) return (FALSE);
- if (r_ptr->flags2 & RF2_KILL_WALL) return (FALSE);
- if (!cave_floor_bold(py, px) && (cave[py][px].feat != FEAT_TREES)) return (FALSE);
+ if ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall)) return (FALSE);
+ if ((r_ptr->flags2 & RF2_KILL_WALL) && (m_idx != p_ptr->riding)) return (FALSE);
/* Monster location */
y1 = m_ptr->fy;
bool will_run = mon_will_run(m_idx);
cave_type *c_ptr;
bool no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (cave[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 can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall));
/* Counter attack to an enemy monster */
if (!will_run && m_ptr->target_y)
c_ptr = &cave[yy][xx];
/* Check grid */
- if (((cave_floor_grid(c_ptr)) || ((c_ptr->feat & 0x60) == 0x60)) &&
- monster_can_cross_terrain(c_ptr->feat, r_ptr))
+ if (monster_can_cross_terrain(c_ptr->feat, r_ptr, 0))
{
/* One more room grid */
room++;
int mm[8];
cave_type *c_ptr;
+ feature_type *f_ptr;
monster_type *y_ptr;
bool did_pass_wall;
bool did_kill_wall;
bool gets_angry = FALSE;
- bool can_pass_wall;
+ bool can_cross;
bool aware = TRUE;
bool fear;
- if ((m_idx == p_ptr->riding) && !(r_ptr->flags7 & RF7_RIDING))
+ bool is_riding_mon = (m_idx == p_ptr->riding);
+
+ if (is_riding_mon && !(r_ptr->flags7 & RF7_RIDING))
{
if (rakuba(0, TRUE))
{
char m_name[80];
monster_desc(m_name, m_ptr, 0);
- if (m_idx == p_ptr->riding && riding_pinch < 2)
+ if (is_riding_mon && riding_pinch < 2)
{
#ifdef JP
msg_format("%s¤Ï½ý¤ÎÄˤµ¤Î;¤ê¤¢¤Ê¤¿¤Î«Çû¤«¤éƨ¤ì¤è¤¦¤È¤·¤Æ¤¤¤ë¡£", m_name);
}
else
{
- if (m_idx == p_ptr->riding)
+ if (is_riding_mon)
{
#ifdef JP
msg_format("%s¤Ï¤¢¤Ê¤¿¤Î«Çû¤«¤éæ½Ð¤·¤¿¡£", m_name);
#endif
}
- if (m_idx == p_ptr->riding && rakuba(-1, FALSE))
+ if (is_riding_mon && rakuba(-1, FALSE))
{
#ifdef JP
msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
else
{
/* Reset the counter */
- if (m_idx == p_ptr->riding) riding_pinch = 0;
+ if (is_riding_mon) riding_pinch = 0;
}
}
/* Redraw the health bar */
if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
+ if (is_riding_mon) p_ptr->redraw |= (PR_UHEALTH);
/* Hack -- Count the wakings */
if (r_ptr->r_wake < MAX_UCHAR)
if (one_in_(2)) return;
}
- if (p_ptr->riding == m_idx)
+ if (is_riding_mon)
{
p_ptr->update |= (PU_BONUS);
}
}
}
- can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || (p_ptr->pass_wall)));
-
/* Hack -- Assume no movement */
mm[0] = mm[1] = mm[2] = mm[3] = 0;
mm[4] = mm[5] = mm[6] = mm[7] = 0;
/* Access that cave grid */
c_ptr = &cave[ny][nx];
+ f_ptr = &f_info[c_ptr->feat];
+ can_cross = monster_can_cross_terrain(c_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
/* Access that cave grid's contents */
y_ptr = &m_list[c_ptr->m_idx];
- /* Floor is open? */
- if (cave_floor_grid(c_ptr))
- {
- /* Go ahead and move */
- do_move = TRUE;
- }
-
/* Hack -- player 'in' wall */
- else if (player_bold(ny, nx))
+ if (player_bold(ny, nx))
{
do_move = TRUE;
}
do_move = TRUE;
}
- /* Permanent wall */
- else if ((c_ptr->feat >= FEAT_PERM_EXTRA) &&
- (c_ptr->feat <= FEAT_PERM_SOLID))
- {
- do_move = FALSE;
- }
-
- /* Hack -- semi-transparent terrains are no obstacle */
- else if (c_ptr->feat == FEAT_TREES)
- {
- do_move = TRUE;
- }
-
- /* Hack -- semi-transparent terrains are no obstacle */
- else if ((c_ptr->feat == FEAT_MOUNTAIN) && ((r_ptr->flags2 & RF2_KILL_WALL) || (!dun_level && ((r_ptr->flags7 & RF7_CAN_FLY) || (r_ptr->flags8 & RF8_WILD_MOUNTAIN)))))
+ /* Floor is open? */
+ else if (can_cross)
{
+ /* Go ahead and move */
do_move = TRUE;
- }
+ /* Monster moves through walls (and doors) */
+ if ((r_ptr->flags2 & RF2_PASS_WALL) && (!is_riding_mon || p_ptr->pass_wall) &&
+ !have_flag(f_ptr->flags, FF_MOVE))
+ {
+ /* Monster went through a wall */
+ did_pass_wall = TRUE;
+ }
- /* Monster moves through walls (and doors) */
- else if (can_pass_wall)
- {
- /* Pass through walls/doors/rubble */
- do_move = TRUE;
-
- /* Monster went through a wall */
- did_pass_wall = TRUE;
+ if ((r_ptr->flags2 & RF2_KILL_WALL) && have_flag(f_ptr->flags, FF_TUNNEL) &&
+ !have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_PERMANENT))
+ {
+ /* Monster destroyed a wall (later) */
+ did_kill_wall = TRUE;
+ }
}
/* Monster destroys walls (and doors) */
- else if ((r_ptr->flags2 & RF2_KILL_WALL) && (m_idx != p_ptr->riding))
+ else if ((r_ptr->flags2 & RF2_KILL_WALL) && !is_riding_mon &&
+ have_flag(f_ptr->flags, FF_TUNNEL) && !have_flag(f_ptr->flags, FF_PERMANENT))
{
/* Eat through walls/doors/rubble */
do_move = TRUE;
- /* Monster destroyed a wall */
+ /* Monster destroyed a wall (later) */
did_kill_wall = TRUE;
-
- if (one_in_(GRINDNOISE))
- {
-#ifdef JP
-msg_print("¥®¥·¥®¥·¤¤¤¦²»¤¬Ê¹¤³¤¨¤ë¡£");
-#else
- msg_print("There is a grinding sound.");
-#endif
-
- }
-
- /* Forget the wall */
- c_ptr->info &= ~(CAVE_MARK);
-
- /* Notice */
- cave_set_feat(ny, nx, floor_type[randint0(100)]);
-
- /* Note changes to viewable region */
- if (player_has_los_bold(ny, nx)) do_view = TRUE;
}
/* Handle doors and secret doors */
else if (is_closed_door(c_ptr->feat))
{
bool may_bash = TRUE;
+ feature_type *f_ptr = &f_info[c_ptr->feat];
/* Assume no move allowed */
do_move = FALSE;
/* Creature can open doors. */
- if ((r_ptr->flags2 & RF2_OPEN_DOOR) &&
+ if ((r_ptr->flags2 & RF2_OPEN_DOOR) && have_flag(f_ptr->flags, FF_OPEN) &&
(!is_pet(m_ptr) || (p_ptr->pet_extra_flags & PF_OPEN_DOORS)))
{
/* Closed doors */
- if (c_ptr->feat == FEAT_DOOR_HEAD)
+ if (!f_ptr->power)
{
/* The door is open */
did_open_door = TRUE;
}
/* Locked doors (not jammed) */
- else if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08)
+ else
{
- int k;
-
- /* Door power */
- k = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
-
/* Try to unlock it XXX XXX XXX */
- if (randint0(m_ptr->hp / 10) > k)
+ if (randint0(m_ptr->hp / 10) > f_ptr->power)
{
/* Unlock the door */
- cave_set_feat(ny, nx, FEAT_DOOR_HEAD + 0x00);
+ cave_alter_feat(ny, nx, FF_OPEN);
/* Do not bash the door */
may_bash = FALSE;
}
/* Stuck doors -- attempt to bash them down if allowed */
- if (may_bash && (r_ptr->flags2 & RF2_BASH_DOOR) &&
+ if (may_bash && (r_ptr->flags2 & RF2_BASH_DOOR) && have_flag(f_ptr->flags, FF_BASH) &&
(!is_pet(m_ptr) || (p_ptr->pet_extra_flags & PF_OPEN_DOORS)))
{
- int k;
-
- /* Door power */
- k = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
-
/* Attempt to Bash XXX XXX XXX */
- if (randint0(m_ptr->hp / 10) > k)
+ if (randint0(m_ptr->hp / 10) > f_ptr->power)
{
/* Message */
#ifdef JP
-msg_print("¥É¥¢¤òᤳ«¤±¤ë²»¤¬¤·¤¿¡ª");
+ msg_print("¥É¥¢¤òᤳ«¤±¤ë²»¤¬¤·¤¿¡ª");
#else
msg_print("You hear a door burst open!");
#endif
-
/* Disturb (sometimes) */
if (disturb_minor) disturb(0, 0);
/* Break down the door */
if (did_bash_door && (randint0(100) < 50))
{
- cave_set_feat(ny, nx, FEAT_BROKEN);
+ cave_alter_feat(ny, nx, FF_BASH);
}
/* Open the door */
else
{
- cave_set_feat(ny, nx, FEAT_OPEN);
+ cave_alter_feat(ny, nx, FF_OPEN);
}
/* Handle viewable doors */
if (c_ptr->info & CAVE_MARK)
{
#ifdef JP
-msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
+ msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
#else
msg_print("The rune of protection is broken!");
#endif
-
}
/* Forget the rune */
if (c_ptr->info & CAVE_MARK)
{
#ifdef JP
-msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
+ msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
#else
msg_print("The rune explodes!");
#endif
else
{
#ifdef JP
-msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
+ msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
#else
msg_print("An explosive rune was disarmed.");
#endif
do_turn = TRUE;
}
}
-
- if ((c_ptr->feat >= FEAT_PATTERN_START) &&
- (c_ptr->feat <= FEAT_PATTERN_XTRA2) &&
- !do_turn && !(r_ptr->flags7 & RF7_CAN_FLY))
- {
- do_move = FALSE;
- }
}
/* A monster is in the way */
/* Attack 'enemies' */
if (((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW) &&
(r_ptr->mexp * r_ptr->level > z_ptr->mexp * z_ptr->level) &&
- cave_floor_grid(c_ptr) &&
- (c_ptr->m_idx != p_ptr->riding)) ||
+ can_cross && (c_ptr->m_idx != p_ptr->riding)) ||
are_enemies(m_ptr, y_ptr) || m_ptr->confused)
{
- do_move = FALSE;
-
if (!(r_ptr->flags1 & RF1_NEVER_BLOW))
{
if (r_ptr->flags2 & RF2_KILL_BODY)
/* Push past weaker monsters (unless leaving a wall) */
else if ((r_ptr->flags2 & RF2_MOVE_BODY) &&
- (r_ptr->mexp > z_ptr->mexp) && cave_floor_grid(c_ptr) &&
- (cave_floor_grid(&cave[m_ptr->fy][m_ptr->fx])) &&
- (c_ptr->m_idx != p_ptr->riding))
+ (r_ptr->mexp > z_ptr->mexp) &&
+ can_cross && (c_ptr->m_idx != p_ptr->riding) &&
+ monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
{
/* Allow movement */
do_move = TRUE;
* to allow monsters to attack an enemy,
* even if it can't enter the terrain.
*/
- if (do_move && !monster_can_cross_terrain(c_ptr->feat, r_ptr))
+ if (do_move && !can_cross && !did_kill_wall)
{
/* Assume no move allowed */
do_move = FALSE;
do_move = FALSE;
}
- if (m_idx == p_ptr->riding)
+ if (is_riding_mon)
{
if (!p_ptr->riding_ryoute && !(m_list[p_ptr->riding].monfear)) do_move = FALSE;
}
/* Hack -- Update the old location */
cave[oy][ox].m_idx = c_ptr->m_idx;
- if (c_ptr->feat == FEAT_TREES)
+ if (did_kill_wall)
{
- if (r_ptr->flags2 & RF2_KILL_WALL)
+ if (one_in_(GRINDNOISE))
{
- cave_set_feat(ny, nx, FEAT_GRASS);
-
+#ifdef JP
+ msg_print("¥®¥·¥®¥·¤¤¤¦²»¤¬Ê¹¤³¤¨¤ë¡£");
+#else
+ msg_print("There is a grinding sound.");
+#endif
}
- if (!(r_ptr->flags7 & RF7_CAN_FLY) && !(r_ptr->flags8 & RF8_WILD_WOOD))
+
+ cave_alter_feat(ny, nx, FF_HURT_DISI);
+
+ /* Note changes to viewable region */
+ if (player_has_los_bold(ny, nx)) do_view = TRUE;
+ }
+ else if (have_flag(f_ptr->flags, FF_TREE))
+ {
+ if (!(r_ptr->flags7 & RF7_CAN_FLY) && (!is_riding_mon || !p_ptr->ffall) && !(r_ptr->flags8 & RF8_WILD_WOOD))
{
m_ptr->energy_need += ENERGY_NEED();
}
/* Update the monster */
update_mon(m_idx, TRUE);
- if (p_ptr->riding == m_idx)
+ if (is_riding_mon)
{
py = ny;
px = nx;
/* Redraw the new grid */
lite_spot(ny, nx);
- if (p_ptr->riding == m_idx)
+ if (is_riding_mon)
{
verify_panel();
{
/* Dump a message */
#ifdef JP
-msg_format("%^s¤Ï%s¤ò½¦¤ª¤¦¤È¤·¤¿¤¬¡¢¤À¤á¤À¤Ã¤¿¡£", m_name, o_name);
+ msg_format("%^s¤Ï%s¤ò½¦¤ª¤¦¤È¤·¤¿¤¬¡¢¤À¤á¤À¤Ã¤¿¡£", m_name, o_name);
#else
-msg_format("%^s tries to pick up %s, but fails.", m_name, o_name);
+ msg_format("%^s tries to pick up %s, but fails.", m_name, o_name);
#endif
}
}
{
/* Dump a message */
#ifdef JP
-msg_format("%^s¤¬%s¤ò½¦¤Ã¤¿¡£", m_name, o_name);
+ msg_format("%^s¤¬%s¤ò½¦¤Ã¤¿¡£", m_name, o_name);
#else
msg_format("%^s picks up %s.", m_name, o_name);
#endif
-
}
/* Excise the object */
{
/* Dump a message */
#ifdef JP
-msg_format("%^s¤¬%s¤òÇ˲õ¤·¤¿¡£", m_name, o_name);
+ msg_format("%^s¤¬%s¤òÇ˲õ¤·¤¿¡£", m_name, o_name);
#else
msg_format("%^s destroys %s.", m_name, o_name);
#endif
-
}
/* Delete the object */
m_ptr->mflag2 &= ~MFLAG2_NOFLOW;
/* If we haven't done anything, try casting a spell again */
- if (!do_turn && !do_move && !m_ptr->monfear && !(p_ptr->riding == m_idx) && aware)
+ if (!do_turn && !do_move && !m_ptr->monfear && !is_riding_mon && aware)
{
/* Try to cast spell again */
if (r_ptr->freq_spell && randint1(100) <= r_ptr->freq_spell)
/* Hack -- Monsters can "smell" the player from far away */
/* Note that most monsters have "aaf" of "20" or so */
else if (!(m_ptr->mflag2 & MFLAG2_NOFLOW) &&
- (cave_floor_bold(py, px) || (cave[py][px].feat == FEAT_TREES)) &&
+ have_flag(f_flags_bold(py, px), FF_MOVE) &&
(cave[py][px].when == cave[fy][fx].when) &&
(cave[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
(cave[fy][fx].dist < r_ptr->aaf))