/* File: melee2.c */
-/* Purpose: Monster spells and movement */
-
/*
-* Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
-*
-* This software may be copied and distributed for educational, research, and
-* not for profit purposes provided that this copyright and statement are
-* included in all such copies.
-*/
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
+ *
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies. Other copyrights may also apply.
+ */
+
+/* Purpose: Monster spells and movement */
/*
* This file has several additions to it by Keldon Jones (keldon@umr.edu)
#define GRINDNOISE 20
#define CYBERNOISE 20
-extern cptr silly_attacks[MAX_SILLY_ATTACK];
-
/*
* Calculate the direction to the next enemy
*/
monster_type *t_ptr;
- if (riding_t_m_idx && (m_ptr->fx == px) && (m_ptr->fy == py))
+ if (riding_t_m_idx && player_bold(m_ptr->fy, m_ptr->fx))
{
y = m_list[riding_t_m_idx].fy;
x = m_list[riding_t_m_idx].fx;
/* 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 &&
* Hack, based on mon_take_hit... perhaps all monster attacks on
* other monsters should use this?
*/
-void mon_take_hit_mon(bool is_psy_spear, int m_idx, int dam, bool *fear, cptr note, int who)
+void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
{
monster_type *m_ptr = &m_list[m_idx];
/* Wake it up */
m_ptr->csleep = 0;
+ if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+
if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 0);
if (m_ptr->invulner && randint0(PENETRATE_INVULNERABILITY))
return;
}
- if (r_ptr->flags3 & RF3_RES_ALL)
+ if (r_ptr->flagsr & RFR_RES_ALL)
{
if(dam > 0)
{
/* It is dead now... or is it? */
if (m_ptr->hp < 0)
{
- if (((r_ptr->flags1 & RF1_UNIQUE) ||
- (r_ptr->flags7 & RF7_UNIQUE_7) ||
- (r_ptr->flags1 & RF1_QUESTOR)) &&
+ if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) ||
+ (r_ptr->flags7 & RF7_NAZGUL)) &&
!p_ptr->inside_battle)
{
m_ptr->hp = 1;
if (known)
{
- monster_desc(m_name, m_ptr, 0x100);
+ monster_desc(m_name, m_ptr, MD_TRUE_NAME);
/* Unseen death by normal attack */
if (!seen)
{
if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr) && (who != m_idx))
{
- if (is_pet(&m_list[who]) && (m_ptr->target_y != py) && (m_ptr->target_x != px))
+ if (is_pet(&m_list[who]) && !player_bold(m_ptr->target_y, m_ptr->target_x))
{
set_target(m_ptr, m_list[who].fy, m_list[who].fx);
}
if (!in_bounds2(y, x)) continue;
/* Simply move to player */
- if ((y == py) && (x == px)) return (FALSE);
+ if (player_bold(y, x)) return (FALSE);
c_ptr = &cave[y][x];
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 && (c_ptr->feat >= FEAT_DOOR_HEAD && c_ptr->feat <= FEAT_SECRET)) continue;
+ if (!can_open_door && is_closed_door(c_ptr->feat)) continue;
}
/* Hack -- for kill or pass wall monster.. */
* being close enough to chase directly. I have no idea what will
* happen if you combine "smell" with low "aaf" values.
*/
-static bool get_moves_aux(int m_idx, int *yp, int *xp)
+static bool get_moves_aux(int m_idx, int *yp, int *xp, bool no_flow)
{
int i, y, x, y1, x1, best;
cave_type *c_ptr;
- bool use_sound = FALSE;
bool use_scent = FALSE;
monster_type *m_ptr = &m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
- /* Monster flowing disabled */
- if (stupid_monsters) return (FALSE);
-
/* Can monster cast attack spell? */
if (r_ptr->flags4 & (RF4_ATTACK_MASK) ||
r_ptr->flags5 & (RF5_ATTACK_MASK) ||
if (get_moves_aux2(m_idx, yp, xp)) return (TRUE);
}
+ /* Monster can't flow */
+ 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;
/* If we can hear noises, advance towards them */
if (c_ptr->cost)
{
- use_sound = TRUE;
best = 999;
}
static bool get_fear_moves_aux(int m_idx, int *yp, int *xp)
{
int y, x, y1, x1, fy, fx, gy = 0, gx = 0;
- int dist = 0, score = -1;
+ int score = -1;
int i;
monster_type *m_ptr = &m_list[m_idx];
- /* Monster flowing disabled */
- if (stupid_monsters) return (FALSE);
-
/* Monster location */
fy = m_ptr->fy;
fx = m_ptr->fx;
/* Ignore locations off of edge */
if (!in_bounds2(y, x)) continue;
- if (cave[y][x].dist < dist) continue;
+ /* Don't move toward player */
+ /* if (cave[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
/* Calculate distance of this grid from our destination */
dis = distance(y, x, y1, x1);
if (s < score) continue;
/* Save the score and time */
- dist = cave[y][x].dist;
score = s;
/* Save the location */
sint *y_offsets;
sint *x_offsets;
-
+
cave_type *c_ptr;
/* Start with adjacent locations, spread further */
/* Get the lists of points with a distance d from (fx, fy) */
y_offsets = dist_offsets_y[d];
x_offsets = dist_offsets_x[d];
-
+
/* Check the locations */
for (i = 0, dx = x_offsets[0], dy = y_offsets[0];
dx != 0 || dy != 0;
{
y = fy + dy;
x = fx + dx;
-
+
/* Skip illegal locations */
if (!in_bounds(y, x)) continue;
if (!cave_floor_grid(c_ptr)) continue;
/* Check for "availability" (if monsters can flow) */
- if (!stupid_monsters && !(m_ptr->mflag2 & MFLAG_NOFLOW))
+ if (!(m_ptr->mflag2 & MFLAG2_NOFLOW))
{
/* Ignore grids very far from the player */
- if (c_ptr->when < cave[py][px].when) continue;
+ if (c_ptr->dist == 0) continue;
/* Ignore too-distant grids */
if (c_ptr->dist > cave[fy][fx].dist + 2 * d) continue;
}
/* Check for absence of shot (more or less) */
- if (clean_shot(fy, fx, y, x, FALSE))
+ if (!player_has_los_grid(c_ptr))
{
-
+
/* Calculate distance from player */
dis = distance(y, x, py, px);
{
gy = y;
gx = x;
- if (!player_has_los_grid(c_ptr))
- {
- gdis = dis * 5;
- }
- else
- {
- gdis = dis;
- }
+ gdis = dis;
}
}
}
/* Check for success */
- if (gdis > d + m_ptr->cdis)
+ if (gdis > 0)
{
/* Good location */
(*yp) = fy - gy;
}
/* No safe place */
-
- /* Save farthest location from player in LOS of monster */
- (*yp) = fy - gy;
- (*xp) = fx - gx;
-
- /* Hack - return TRUE anyway. */
- return (TRUE);
+ return (FALSE);
}
int x2 = px;
bool done = FALSE;
bool will_run = mon_will_run(m_idx);
- cave_type *c_ptr;
- bool no_flow = ((m_ptr->mflag2 & MFLAG_NOFLOW) && (cave[m_ptr->fy][m_ptr->fx].cost > 2));
- bool can_pass_wall;
+ 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));
- /* Flow towards the player */
- if (!stupid_monsters && !no_flow)
+ /* Counter attack to an enemy monster */
+ if (!will_run && m_ptr->target_y)
{
- /* Flow towards the player */
- (void)get_moves_aux(m_idx, &y2, &x2);
- }
-
- can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || (p_ptr->pass_wall)));
+ int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
- /* Extract the "pseudo-direction" */
- y = m_ptr->fy - y2;
- x = m_ptr->fx - x2;
+ /* The monster must be an enemy, and in LOS */
+ if (t_m_idx &&
+ are_enemies(m_ptr, &m_list[t_m_idx]) &&
+ los(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;
+ x = m_ptr->fx - m_ptr->target_x;
+ done = TRUE;
+ }
+ }
- if (!stupid_monsters && !will_run && is_hostile(m_ptr) &&
+ if (!done && !will_run && is_hostile(m_ptr) &&
(r_ptr->flags1 & RF1_FRIENDS) &&
(los(m_ptr->fy, m_ptr->fx, py, px) ||
(cave[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
/* Count room grids next to player */
for (i = 0; i < 8; i++)
{
- int x = px + ddx_ddd[i];
- int y = py + ddy_ddd[i];
-
- cave_type *c_ptr;
+ int xx = px + ddx_ddd[i];
+ int yy = py + ddy_ddd[i];
- if (!in_bounds2(y, x)) continue;
-
- c_ptr = &cave[y][x];
+ if (!in_bounds2(yy, xx)) continue;
+
+ 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++;
}
}
+ if (!done)
+ {
+ /* Flow towards the player */
+ (void)get_moves_aux(m_idx, &y2, &x2, no_flow);
+
+ /* Extract the "pseudo-direction" */
+ y = m_ptr->fy - y2;
+ x = m_ptr->fx - x2;
+
+ /* Not done */
+ }
+
/* Apply fear if possible and necessary */
- if ((stupid_monsters || is_pet(m_ptr)) && will_run)
+ if (is_pet(m_ptr) && will_run)
{
/* XXX XXX Not very "smart" */
y = (-y), x = (-x);
{
if (!done && will_run)
{
+ int tmp_x = (-x);
+ int tmp_y = (-y);
+
/* Try to find safe place */
- if (!find_safety(m_idx, &y, &x))
- {
- /* This is not a very "smart" method XXX XXX */
- y = (-y);
- x = (-x);
- }
- else
+ if (find_safety(m_idx, &y, &x))
{
/* Attempt to avoid the player */
- if (!stupid_monsters && !no_flow)
+ if (!no_flow)
{
/* Adjust movement */
- (void)get_fear_moves_aux(m_idx, &y, &x);
+ if (get_fear_moves_aux(m_idx, &y, &x)) done = TRUE;
}
}
+
+ if (!done)
+ {
+ /* This is not a very "smart" method XXX XXX */
+ y = tmp_y;
+ x = tmp_x;
+ }
}
}
- if (!stupid_monsters)
- {
- /* Check for no move */
- if (!x && !y) return (FALSE);
- }
+ /* Check for no move */
+ if (!x && !y) return (FALSE);
/* Extract the "absolute distances" */
if (x > 0) move_val += 4;
/* Prevent the diamond maneuvre */
- if (ay > (ax << 1))
- {
- move_val++;
- move_val++;
- }
- else if (ax > (ay << 1))
- {
- move_val++;
- }
+ if (ay > (ax << 1)) move_val += 2;
+ else if (ax > (ay << 1)) move_val++;
/* Extract some directions */
switch (move_val)
int ap_cnt;
int ac, rlev, pt;
char m_name[80], t_name[80];
- char ddesc[80], temp[80];
+ char temp[80];
bool blinked, heal_effect;
bool explode = FALSE, touched = FALSE, fear = FALSE;
int y_saver = t_ptr->fy;
if (d_info[dungeon_type].flags1 & DF1_NO_MELEE) return (FALSE);
- /* Wake it up */
- t_ptr->csleep = 0;
-
/* Total armor */
ac = tr_ptr->ac;
/* Get the monster name (or "it") */
monster_desc(t_name, t_ptr, 0);
- /* Get the "died from" information (i.e. "a kobold") */
- monster_desc(ddesc, m_ptr, 0x88);
-
/* Assume no blink */
blinked = FALSE;
/* break; */
}
- /* Extract the attack "power" */
- switch (effect)
- {
- case RBE_HURT: power = 60; break;
- case RBE_POISON: power = 5; break;
- case RBE_UN_BONUS: power = 20; break;
- case RBE_UN_POWER: power = 15; break;
- case RBE_EAT_GOLD: power = 5; break;
- case RBE_EAT_ITEM: power = 5; break;
- case RBE_EAT_FOOD: power = 5; break;
- case RBE_EAT_LITE: power = 5; break;
- case RBE_ACID: power = 0; break;
- case RBE_ELEC: power = 10; break;
- case RBE_FIRE: power = 10; break;
- case RBE_COLD: power = 10; break;
- case RBE_BLIND: power = 2; break;
- case RBE_CONFUSE: power = 10; break;
- case RBE_TERRIFY: power = 10; break;
- case RBE_PARALYZE: power = 2; break;
- case RBE_LOSE_STR: power = 0; break;
- case RBE_LOSE_DEX: power = 0; break;
- case RBE_LOSE_CON: power = 0; break;
- case RBE_LOSE_INT: power = 0; break;
- case RBE_LOSE_WIS: power = 0; break;
- case RBE_LOSE_CHR: power = 0; break;
- case RBE_LOSE_ALL: power = 2; break;
- case RBE_SHATTER: power = 60; break;
- case RBE_EXP_10: power = 5; break;
- case RBE_EXP_20: power = 5; break;
- case RBE_EXP_40: power = 5; break;
- case RBE_EXP_80: power = 5; break;
- case RBE_DISEASE: power = 5; break;
- case RBE_TIME: power = 5; break;
- case RBE_EXP_VAMP: power = 5; break;
- case RBE_DR_MANA: power = 5; break;
- case RBE_SUPERHURT: power = 60; break;
- }
+ if (method == RBM_SHOOT) continue;
+ /* Extract the attack "power" */
+ power = mbe_info[effect].power;
/* Monster hits */
if (!effect || check_hit2(power, rlev, ac, m_ptr->stunned))
{
+ /* Wake it up */
+ t_ptr->csleep = 0;
+
+ if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+
/* Describe the attack method */
switch (method)
{
/* Message */
if (act && see_either)
{
+#ifdef JP
+ if (do_silly_attack) act = silly_attacks2[randint0(MAX_SILLY_ATTACK)];
+ strfmt(temp, act, t_name);
+ msg_format("%^s¤Ï%s", m_name, temp);
+#else
if (do_silly_attack)
{
act = silly_attacks[randint0(MAX_SILLY_ATTACK)];
+ strfmt(temp, "%s %s.", act, t_name);
}
- strfmt(temp, act, t_name);
-#ifdef JP
- msg_format("%^s¤Ï%s", m_name, temp);
-#else
+ else strfmt(temp, act, t_name);
msg_format("%^s %s", m_name, temp);
#endif
-
}
/* Hack -- assume all attacks are obvious */
}
case RBE_SHATTER:
{
+ damage -= (damage * ((ac < 150) ? ac : 150) / 250);
if (damage > 23)
{
earthquake(m_ptr->fy, m_ptr->fx, 8);
if (!explode)
{
project(m_idx, 0, t_ptr->fy, t_ptr->fx,
- (pt == GF_OLD_SLEEP ? r_ptr->level : damage), pt, PROJECT_KILL | PROJECT_STOP | PROJECT_MONSTER | PROJECT_NO_REF, -1);
+ (pt == GF_OLD_SLEEP ? r_ptr->level : damage), pt, PROJECT_KILL | PROJECT_STOP | PROJECT_AIMED, -1);
}
if (heal_effect)
if (touched)
{
/* Aura fire */
- if ((tr_ptr->flags2 & RF2_AURA_FIRE) &&
- !(r_ptr->flags3 & RF3_IM_FIRE) &&
- !(r_ptr->flags3 & RF3_RES_ALL) && m_ptr->r_idx)
+ if ((tr_ptr->flags2 & RF2_AURA_FIRE) && m_ptr->r_idx)
{
- if (see_either)
+ if (!(r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
{
- blinked = FALSE;
+ if (see_either)
+ {
+ blinked = FALSE;
#ifdef JP
-msg_format("%^s¤ÏÆÍÁ³Ç®¤¯¤Ê¤Ã¤¿¡ª", m_name);
+ msg_format("%^s¤ÏÆÍÁ³Ç®¤¯¤Ê¤Ã¤¿¡ª", m_name);
#else
- msg_format("%^s is suddenly very hot!", m_name);
+ msg_format("%^s is suddenly very hot!", m_name);
#endif
- if (t_ptr->ml)
- tr_ptr->r_flags2 |= RF2_AURA_FIRE;
+ if (see_t && is_original_ap(t_ptr)) tr_ptr->r_flags2 |= RF2_AURA_FIRE;
+ }
+ project(t_idx, 0, m_ptr->fy, m_ptr->fx,
+ damroll (1 + ((tr_ptr->level) / 26),
+ 1 + ((tr_ptr->level) / 17)),
+ GF_FIRE, PROJECT_KILL | PROJECT_STOP | PROJECT_AIMED, -1);
+ }
+ else
+ {
+ if (see_m && is_original_ap(m_ptr)) r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
}
- project(t_idx, 0, m_ptr->fy, m_ptr->fx,
- damroll (1 + ((tr_ptr->level) / 26),
- 1 + ((tr_ptr->level) / 17)),
- GF_FIRE, PROJECT_KILL | PROJECT_STOP | PROJECT_MONSTER | PROJECT_NO_REF, -1);
}
/* Aura cold */
- if ((tr_ptr->flags3 & RF3_AURA_COLD) &&
- !(r_ptr->flags3 & RF3_IM_COLD) &&
- !(r_ptr->flags3 & RF3_RES_ALL) && m_ptr->r_idx)
+ if ((tr_ptr->flags3 & RF3_AURA_COLD) && m_ptr->r_idx)
{
- if (see_either)
+ if (!(r_ptr->flagsr & RFR_EFF_IM_COLD_MASK))
{
- blinked = FALSE;
+ if (see_either)
+ {
+ blinked = FALSE;
#ifdef JP
-msg_format("%^s¤ÏÆÍÁ³´¨¤¯¤Ê¤Ã¤¿¡ª", m_name);
+ msg_format("%^s¤ÏÆÍÁ³´¨¤¯¤Ê¤Ã¤¿¡ª", m_name);
#else
- msg_format("%^s is suddenly very cold!", m_name);
+ msg_format("%^s is suddenly very cold!", m_name);
#endif
- if (t_ptr->ml)
- tr_ptr->r_flags3 |= RF3_AURA_COLD;
+ if (see_t && is_original_ap(t_ptr)) tr_ptr->r_flags3 |= RF3_AURA_COLD;
+ }
+ project(t_idx, 0, m_ptr->fy, m_ptr->fx,
+ damroll (1 + ((tr_ptr->level) / 26),
+ 1 + ((tr_ptr->level) / 17)),
+ GF_COLD, PROJECT_KILL | PROJECT_STOP | PROJECT_AIMED, -1);
+ }
+ else
+ {
+ if (see_m && is_original_ap(m_ptr)) r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
}
- project(t_idx, 0, m_ptr->fy, m_ptr->fx,
- damroll (1 + ((tr_ptr->level) / 26),
- 1 + ((tr_ptr->level) / 17)),
- GF_COLD, PROJECT_KILL | PROJECT_STOP | PROJECT_MONSTER | PROJECT_NO_REF, -1);
}
/* Aura elec */
- if ((tr_ptr->flags2 & (RF2_AURA_ELEC)) &&
- !(r_ptr->flags3 & (RF3_IM_ELEC)) &&
- !(r_ptr->flags3 & RF3_RES_ALL) && m_ptr->r_idx)
+ if ((tr_ptr->flags2 & RF2_AURA_ELEC) && m_ptr->r_idx)
{
- if (see_either)
+ if (!(r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK))
{
- blinked = FALSE;
+ if (see_either)
+ {
+ blinked = FALSE;
#ifdef JP
-msg_format("%^s¤ÏÅÅ·â¤ò¿©¤é¤Ã¤¿¡ª", m_name);
+ msg_format("%^s¤ÏÅÅ·â¤ò¿©¤é¤Ã¤¿¡ª", m_name);
#else
- msg_format("%^s gets zapped!", m_name);
+ msg_format("%^s gets zapped!", m_name);
#endif
- if (t_ptr->ml)
- tr_ptr->r_flags2 |= RF2_AURA_ELEC;
+ if (see_t && is_original_ap(t_ptr)) tr_ptr->r_flags2 |= RF2_AURA_ELEC;
+ }
+ project(t_idx, 0, m_ptr->fy, m_ptr->fx,
+ damroll (1 + ((tr_ptr->level) / 26),
+ 1 + ((tr_ptr->level) / 17)),
+ GF_ELEC, PROJECT_KILL | PROJECT_STOP | PROJECT_AIMED, -1);
+ }
+ else
+ {
+ if (see_m && is_original_ap(m_ptr)) r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
}
- project(t_idx, 0, m_ptr->fy, m_ptr->fx,
- damroll (1 + ((tr_ptr->level) / 26),
- 1 + ((tr_ptr->level) / 17)),
- GF_ELEC, PROJECT_KILL | PROJECT_STOP | PROJECT_MONSTER | PROJECT_NO_REF, -1);
}
-
}
}
}
case RBM_ENGULF:
case RBM_CHARGE:
{
+ /* Wake it up */
+ t_ptr->csleep = 0;
+
+ if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+
/* Visible monsters */
if (see_m)
{
if (m_ptr->invulner) m_ptr->invulner = 0;
#ifdef JP
-mon_take_hit_mon(FALSE, m_idx, m_ptr->hp + 1, &fear, "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_idx);
+mon_take_hit_mon(m_idx, m_ptr->hp + 1, &fear, "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_idx);
#else
- mon_take_hit_mon(FALSE, m_idx, m_ptr->hp + 1, &fear, " explodes into tiny shreds.", m_idx);
+ mon_take_hit_mon(m_idx, m_ptr->hp + 1, &fear, " explodes into tiny shreds.", m_idx);
#endif
/*
- * Hack -- local "player stealth" value (see below)
- */
-static u32b noise = 0L;
-
-
-/*
* Process a monster
*
* The monster is known to be within 100 grids of the player
{
monster_type *m_ptr = &m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
+ monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
int i, d, oy, ox, ny, nx;
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))
{
}
}
- if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && one_in_(13) && !m_ptr->csleep)
+ if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && one_in_(13) && !m_ptr->csleep)
{
choose_new_monster(m_idx, FALSE, 0);
r_ptr = &r_info[m_ptr->r_idx];
{
int tmp = p_ptr->lev*6+(p_ptr->skill_stl+10)*4;
if (p_ptr->monlite) tmp /= 3;
- if (p_ptr->aggravate) tmp /= 2;
+ if (p_ptr->cursed & TRC_AGGRAVATE) tmp /= 2;
if (r_ptr->level > (p_ptr->lev*p_ptr->lev/20+10)) tmp /= 3;
/* Low-level monsters will find it difficult to locate the player. */
if (randint0(tmp) > (r_ptr->level+20)) aware = FALSE;
}
+ /* Are there its parent? */
+ if (m_ptr->parent_m_idx && !m_list[m_ptr->parent_m_idx].r_idx)
+ {
+ /* Its parent have gone, it also goes away. */
+
+ if (m_ptr->ml)
+ {
+ char m_name[80];
+
+ /* Acquire the monster name */
+ monster_desc(m_name, m_ptr, 0);
+
+#ifdef JP
+ msg_format("%s¤Ï¾Ã¤¨µî¤Ã¤¿¡ª", m_name);
+#else
+ msg_format("%^s disappears!", m_name);
+#endif
+ }
+
+ /* Delete the monster */
+ delete_monster_idx(m_idx);
+
+ return;
+ }
+
/* Quantum monsters are odd */
if (r_ptr->flags2 & (RF2_QUANTUM))
{
if (m_ptr->r_idx == MON_SHURYUUDAN)
#ifdef JP
- mon_take_hit_mon(FALSE, m_idx, 1, &fear, "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_idx);
+ mon_take_hit_mon(m_idx, 1, &fear, "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_idx);
#else
- mon_take_hit_mon(FALSE, m_idx, 1, &fear, " explodes into tiny shreds.", m_idx);
+ mon_take_hit_mon(m_idx, 1, &fear, " explodes into tiny shreds.", m_idx);
#endif
- if ((is_pet(m_ptr) || is_friendly(m_ptr)) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) && !p_ptr->inside_battle)
+ if ((is_pet(m_ptr) || is_friendly(m_ptr)) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->inside_battle)
{
static int riding_pinch = 0;
if (m_ptr->hp < m_ptr->maxhp/3)
{
- bool level_teleport = 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);
+ msg_format("%s¤Ï½ý¤ÎÄˤµ¤Î;¤ê¤¢¤Ê¤¿¤Î«Çû¤«¤éƨ¤ì¤è¤¦¤È¤·¤Æ¤¤¤ë¡£", m_name);
#else
- msg_format("%^s seems to be in so much pain, and trying to escape from your restriction.", m_name);
+ msg_format("%^s seems to be in so much pain, and trying to escape from your restriction.", m_name);
#endif
riding_pinch++;
- level_teleport = FALSE;
disturb(1, 0);
}
- else if (m_ptr->ml)
+ else
{
- if (m_idx == p_ptr->riding)
+ if (is_riding_mon)
{
#ifdef JP
-msg_format("%s¤Ï¤¢¤Ê¤¿¤Î«Çû¤«¤éæ½Ð¤·¤¿¡£", m_name);
+ msg_format("%s¤Ï¤¢¤Ê¤¿¤Î«Çû¤«¤éæ½Ð¤·¤¿¡£", m_name);
#else
msg_format("%^s succeeded to escape from your restriction!", m_name);
#endif
- }
- if ((r_ptr->flags2 & RF2_CAN_SPEAK) && (m_ptr->r_idx != MON_GRIP) && (m_ptr->r_idx != MON_WOLF) && (m_ptr->r_idx != MON_FANG))
- {
-#ifdef JP
-msg_format("%^s¡Ö¥Ô¥ó¥Á¤À¡ªÂàµÑ¤µ¤»¤Æ¤â¤é¤¦¡ª¡×", m_name);
-#else
- msg_format("%^s says 'It is the pinch! I will retreat'.", m_name);
-#endif
- }
-#ifdef JP
-msg_format("%^s¤¬¥Æ¥ì¥Ý¡¼¥È¡¦¥ì¥Ù¥ë¤Î´¬Êª¤òÆɤó¤À¡£", m_name);
-#else
- msg_format("%^s read a scroll of teleport level.", m_name);
-#endif
-#ifdef JP
-msg_format("%^s¤¬¾Ã¤¨µî¤Ã¤¿¡£", m_name);
-#else
- msg_format("%^s disappears.", m_name);
-#endif
- }
-
- if (level_teleport)
- {
- delete_monster_idx(m_idx);
-
- if (m_idx == p_ptr->riding)
- {
if (rakuba(-1, FALSE))
{
#ifdef JP
-msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
+ msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
#else
- msg_print("You have fallen from riding pet.");
+ msg_print("You have fallen from riding pet.");
#endif
}
}
- return;
- }
- }
- else
- if (m_idx == p_ptr->riding) riding_pinch = 0;
-
- }
- /* Handle "sleep" */
- if (m_ptr->csleep)
- {
- u32b notice = 0;
-
- /* Hack -- handle non-aggravation */
- if (!p_ptr->aggravate) notice = randint0(1024);
-
- /* Nightmare monsters are more alert */
- if (ironman_nightmare) notice /= 2;
-
- /* Hack -- See if monster "notices" player */
- if ((notice * notice * notice) <= noise)
- {
- /* Hack -- amount of "waking" */
- int d = 1;
-
- /* Wake up faster near the player */
- if (m_ptr->cdis < 50) d = (100 / m_ptr->cdis);
-
- /* Hack -- handle aggravation */
- if (p_ptr->aggravate) d = m_ptr->csleep;
-
- /* Still asleep */
- if (m_ptr->csleep > d)
- {
- /* Monster wakes up "a little bit" */
- m_ptr->csleep -= d;
-
- /* Notice the "not waking up" */
if (m_ptr->ml)
{
- /* Hack -- Count the ignores */
- if (r_ptr->r_ignore < MAX_UCHAR)
+ if ((r_ptr->flags2 & RF2_CAN_SPEAK) && (m_ptr->r_idx != MON_GRIP) && (m_ptr->r_idx != MON_WOLF) && (m_ptr->r_idx != MON_FANG))
{
- r_ptr->r_ignore++;
- }
- }
- }
-
- /* Just woke up */
- else
- {
- /* Reset sleep counter */
- m_ptr->csleep = 0;
-
- /* Notice the "waking up" */
- if (m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
#ifdef JP
-msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
+ msg_format("%^s¡Ö¥Ô¥ó¥Á¤À¡ªÂàµÑ¤µ¤»¤Æ¤â¤é¤¦¡ª¡×", m_name);
#else
- msg_format("%^s wakes up.", m_name);
+ msg_format("%^s says 'It is the pinch! I will retreat'.", m_name);
#endif
-
-
- /* 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 (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2))
- p_ptr->update |= (PU_MON_LITE);
-
- /* Hack -- Count the wakings */
- if (r_ptr->r_wake < MAX_UCHAR)
- {
- r_ptr->r_wake++;
}
+#ifdef JP
+ msg_format("%^s¤¬¥Æ¥ì¥Ý¡¼¥È¡¦¥ì¥Ù¥ë¤Î´¬Êª¤òÆɤó¤À¡£", m_name);
+ msg_format("%^s¤¬¾Ã¤¨µî¤Ã¤¿¡£", m_name);
+#else
+ msg_format("%^s read a scroll of teleport level.", m_name);
+ msg_format("%^s disappears.", m_name);
+#endif
}
- }
- }
-
- /* Still sleeping */
- if (m_ptr->csleep) return;
- }
-
-
- /* Handle "stun" */
- if (m_ptr->stunned)
- {
- int d = 1;
-
- /* Make a "saving throw" against stun */
- if (randint0(10000) <= r_ptr->level * r_ptr->level)
- {
- /* Recover fully */
- d = m_ptr->stunned;
- }
-
- /* Hack -- Recover from stun */
- if (m_ptr->stunned > d)
- {
- /* Recover somewhat */
- m_ptr->stunned -= d;
- }
-
- /* Fully recover */
- else
- {
- /* Recover fully */
- m_ptr->stunned = 0;
-
- /* Message if visible */
- if (m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
- /* Dump a message */
+ if (is_riding_mon && rakuba(-1, FALSE))
+ {
#ifdef JP
-msg_format("%^s¤ÏÛ¯Û°¾õÂÖ¤«¤éΩ¤Áľ¤Ã¤¿¡£", m_name);
+ msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
#else
- msg_format("%^s is no longer stunned.", m_name);
+ msg_print("You have fallen from riding pet.");
#endif
+ }
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
- }
-
- /* Still stunned */
- if (m_ptr->stunned && one_in_(2)) return;
- }
-
+ /* Check for quest completion */
+ check_quest_completion(m_ptr);
- /* Handle confusion */
- if (m_ptr->confused)
- {
- /* Amount of "boldness" */
- int d = randint1(r_ptr->level / 20 + 1);
+ delete_monster_idx(m_idx);
- /* Still confused */
- if (m_ptr->confused > d)
- {
- /* Reduce the confusion */
- m_ptr->confused -= d;
+ return;
+ }
}
-
- /* Recovered */
else
{
- /* No longer confused */
- m_ptr->confused = 0;
-
- /* Message if visible */
- if (m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
-msg_format("%^s¤Ïº®Í𤫤éΩ¤Áľ¤Ã¤¿¡£", m_name);
-#else
- msg_format("%^s is no longer confused.", m_name);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
+ /* Reset the counter */
+ if (is_riding_mon) riding_pinch = 0;
}
}
- /* Handle Invulnerability */
- if (m_ptr->invulner)
+ /* Handle "sleep" */
+ if (m_ptr->csleep)
{
- /* Reduce by one, note if expires */
- m_ptr->invulner--;
-
- if (!(m_ptr->invulner) && m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
+ /* Handle non-aggravation - Still sleeping */
+ if (!(p_ptr->cursed & TRC_AGGRAVATE)) return;
- /* Dump a message */
-#ifdef JP
-msg_format("%^s¤Ï¤â¤¦ÌµÅ¨¤Ç¤Ê¤¤¡£", m_name);
-#else
- msg_format("%^s is no longer invulnerable.", m_name);
-#endif
+ /* Handle aggravation */
- m_ptr->energy -= 100;
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
- }
+ /* Reset sleep counter */
+ m_ptr->csleep = 0;
- /* Handle fast */
- if (m_ptr->fast)
- {
- /* Reduce by one, note if expires */
- m_ptr->fast--;
+ if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
- if (!(m_ptr->fast) && m_ptr->ml)
+ /* Notice the "waking up" */
+ if (m_ptr->ml)
{
char m_name[80];
/* Dump a message */
#ifdef JP
-msg_format("%^s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
+ msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
#else
- msg_format("%^s is no longer fast.", m_name);
+ msg_format("%^s wakes up.", m_name);
#endif
+ /* 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)
+ {
+ r_ptr->r_wake++;
+ }
}
}
- /* Handle slow */
- if (m_ptr->slow)
+ /* Handle "stun" */
+ if (m_ptr->stunned)
{
- /* Reduce by one, note if expires */
- m_ptr->slow--;
-
- if (!(m_ptr->slow) && m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
-msg_format("%^s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
-#else
- msg_format("%^s is no longer slow.", m_name);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
+ /* Sometimes skip move */
+ if (one_in_(2)) return;
}
- if (p_ptr->riding == m_idx)
+ if (is_riding_mon)
{
p_ptr->update |= (PU_BONUS);
}
/* No one wants to be your friend if you're aggravating */
- if (is_friendly(m_ptr) && p_ptr->aggravate)
+ if (is_friendly(m_ptr) && (p_ptr->cursed & TRC_AGGRAVATE))
gets_angry = TRUE;
/* Paranoia... no pet uniques outside wizard mode -- TY */
if (is_pet(m_ptr) &&
- ((((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
- ((p_ptr->align > 9 && (r_ptr->flags3 & RF3_EVIL)) ||
- (p_ptr->align < -9 && (r_ptr->flags3 & RF3_GOOD))))
- || (r_ptr->flags3 & RF3_RES_ALL)))
+ ((((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
+ monster_has_hostile_align(NULL, 10, -10, r_ptr))
+ || (r_ptr->flagsr & RFR_RES_ALL)))
{
- gets_angry = TRUE;
+ gets_angry = TRUE;
}
if (p_ptr->inside_battle) gets_angry = FALSE;
set_hostile(m_ptr);
}
- /* Handle "fear" */
- if (m_ptr->monfear)
- {
- /* Amount of "boldness" */
- int d = randint1(r_ptr->level / 20 + 1);
-
- /* Still afraid */
- if (m_ptr->monfear > d)
- {
- /* Reduce the fear */
- m_ptr->monfear -= d;
- }
-
- /* Recover from fear, take note if seen */
- else
- {
- /* No longer afraid */
- m_ptr->monfear = 0;
-
- /* Visual note */
- if (m_ptr->ml)
- {
- char m_name[80];
- char m_poss[80];
-
- /* Acquire the monster name/poss */
- monster_desc(m_name, m_ptr, 0);
- monster_desc(m_poss, m_ptr, 0x22);
-
- /* Dump a message */
-#ifdef JP
-msg_format("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", m_name);
-#else
- msg_format("%^s recovers %s courage.", m_name, m_poss);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- }
- }
- }
-
/* Get the origin */
oy = m_ptr->fy;
ox = m_ptr->fx;
if ((k < 4) && (!k || !randint0(k * MON_MULT_ADJ)))
{
/* Try to multiply */
- if (multiply_monster(m_idx, FALSE, is_friendly(m_ptr), is_pet(m_ptr)))
+ if (multiply_monster(m_idx, FALSE, (is_pet(m_ptr) ? PM_FORCE_PET : 0)))
{
/* Take note if visible */
- if (m_ptr->ml)
+ if (m_ptr->ml && m_list[hack_m_idx_ii].ml && is_original_ap(m_ptr))
{
r_ptr->r_flags2 |= (RF2_MULTIPLY);
}
}
+ if (r_ptr->flags6 & RF6_SPECIAL)
+ {
+ /* Hack -- Ohmu scatters molds! */
+ if (m_ptr->r_idx == MON_OHMU)
+ {
+ if (!p_ptr->inside_arena && !p_ptr->inside_battle)
+ {
+ if (r_ptr->freq_spell && (randint1(100) <= r_ptr->freq_spell))
+ {
+ int k, count = 0;
+ int rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
+ u32b p_mode = is_pet(m_ptr) ? PM_FORCE_PET : 0L;
+
+ for (k = 0; k < 6; k++)
+ {
+ if (summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_BIZARRE1, (PM_ALLOW_GROUP | p_mode)))
+ {
+ if (m_list[hack_m_idx_ii].ml) count++;
+ }
+ }
+
+ if (count && m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags6 |= (RF6_SPECIAL);
+ }
+ }
+ }
+ }
+
+
if (!p_ptr->inside_battle)
{
/* Hack! "Cyber" monster makes noise... */
- if (m_ptr->r_idx == MON_CYBER &&
+ if (m_ptr->ap_r_idx == MON_CYBER &&
one_in_(CYBERNOISE) &&
!m_ptr->ml && (m_ptr->cdis <= MAX_SIGHT))
{
}
/* Some monsters can speak */
- if ((r_ptr->flags2 & RF2_CAN_SPEAK) && aware &&
+ if ((ap_r_ptr->flags2 & RF2_CAN_SPEAK) && aware &&
one_in_(SPEAK_CHANCE) &&
player_has_los_bold(oy, ox))
{
/* Get the monster line */
- if (get_rnd_line(filename, m_ptr->r_idx, monmessage) == 0)
+ if (get_rnd_line(filename, m_ptr->ap_r_idx, monmessage) == 0)
{
/* Say something */
#ifdef JP
}
}
- /* Attempt to cast a spell */
- if (aware && make_attack_spell(m_idx)) return;
+ /* Try to cast spell occasionally */
+ if (r_ptr->freq_spell && randint1(100) <= r_ptr->freq_spell)
+ {
+ bool counterattack = FALSE;
- /*
- * Attempt to cast a spell at an enemy other than the player
- * (may slow the game a smidgeon, but I haven't noticed.)
- */
- if (monst_spell_monst(m_idx)) return;
+ /* Give priority to counter attack? */
+ if (m_ptr->target_y)
+ {
+ int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
- can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || (p_ptr->pass_wall)));
+ /* The monster must be an enemy, and projectable */
+ if (t_m_idx &&
+ are_enemies(m_ptr, &m_list[t_m_idx]) &&
+ projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
+ {
+ counterattack = TRUE;
+ }
+ }
+
+ if (!counterattack)
+ {
+ /* Attempt to cast a spell */
+ if (aware && make_attack_spell(m_idx)) return;
+
+ /*
+ * Attempt to cast a spell at an enemy other than the player
+ * (may slow the game a smidgeon, but I haven't noticed.)
+ */
+ if (monst_spell_monst(m_idx)) return;
+ }
+ else
+ {
+ /* Attempt to do counter attack at first */
+ if (monst_spell_monst(m_idx)) return;
+
+ if (aware && make_attack_spell(m_idx)) return;
+ }
+ }
/* Hack -- Assume no movement */
mm[0] = mm[1] = mm[2] = mm[3] = 0;
}
/* 75% random movement */
- else if ((r_ptr->flags1 & RF1_RAND_50) &&
- (r_ptr->flags1 & RF1_RAND_25) &&
- (randint0(100) < 75))
+ else if (((r_ptr->flags1 & (RF1_RAND_50 | RF1_RAND_25)) == (RF1_RAND_50 | RF1_RAND_25)) &&
+ (randint0(100) < 75))
{
/* Memorize flags */
- if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_RAND_50);
- if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_RAND_25);
+ if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags1 |= (RF1_RAND_50 | RF1_RAND_25);
/* Try four "random" directions */
mm[0] = mm[1] = mm[2] = mm[3] = 5;
(randint0(100) < 50))
{
/* Memorize flags */
- if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_RAND_50);
+ if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags1 |= (RF1_RAND_50);
/* Try four "random" directions */
mm[0] = mm[1] = mm[2] = mm[3] = 5;
(randint0(100) < 25))
{
/* Memorize flags */
- if (m_ptr->ml) r_ptr->r_flags1 |= RF1_RAND_25;
+ if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags1 |= RF1_RAND_25;
/* Try four "random" directions */
mm[0] = mm[1] = mm[2] = mm[3] = 5;
get_enemy_dir(m_idx, mm);
}
/* Normal movement */
- else if (stupid_monsters)
- {
- /* Logical moves */
- get_moves(m_idx, mm);
- }
else
{
/* Logical moves, may do nothing */
/* 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 ((ny == py) && (nx == px))
+ 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)
+ /* Floor is open? */
+ else if (can_cross)
{
+ /* Go ahead and move */
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)))))
- {
- do_move = TRUE;
- }
-
-
- /* Monster moves through walls (and doors) */
- else if (can_pass_wall)
- {
- /* Pass through walls/doors/rubble */
- 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 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 */
- c_ptr->feat = floor_type[randint0(100)];
- c_ptr->info &= ~(CAVE_MASK);
- c_ptr->info |= CAVE_FLOOR;
-
- /* Note changes to viewable region */
- if (player_has_los_bold(ny, nx)) do_view = TRUE;
}
/* Handle doors and secret doors */
- else if (((c_ptr->feat >= FEAT_DOOR_HEAD) &&
- (c_ptr->feat <= FEAT_DOOR_TAIL)) ||
- (c_ptr->feat == FEAT_SECRET))
+ 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 and secret doors */
- if ((c_ptr->feat == FEAT_DOOR_HEAD) ||
- (c_ptr->feat == FEAT_SECRET))
+ /* Closed doors */
+ 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 */
}
/* Hack -- check for Glyph of Warding */
- if (do_move && (c_ptr->feat == FEAT_GLYPH) &&
- !((r_ptr->flags1 & RF1_NEVER_BLOW) && (py == ny) && (px == nx)))
+ if (do_move && is_glyph_grid(c_ptr) &&
+ !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
{
/* Assume no move allowed */
do_move = FALSE;
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 */
c_ptr->info &= ~(CAVE_MARK);
/* Break the rune */
- c_ptr->feat = floor_type[randint0(100)];
- c_ptr->info &= ~(CAVE_MASK);
- c_ptr->info |= CAVE_FLOOR;
+ c_ptr->info &= ~(CAVE_OBJECT);
+ c_ptr->mimic = 0;
/* Allow movement */
do_move = TRUE;
note_spot(ny, nx);
}
}
- else if (do_move && (c_ptr->feat == FEAT_MINOR_GLYPH) &&
- !((r_ptr->flags1 & RF1_NEVER_BLOW) && (py == ny) && (px == nx)))
+ else if (do_move && is_explosive_rune_grid(c_ptr) &&
+ !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
{
/* Assume no move allowed */
do_move = FALSE;
if (c_ptr->info & CAVE_MARK)
{
#ifdef JP
-msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
+ msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
#else
msg_print("The rune explodes!");
#endif
- project(0, 2, ny, nx, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_REF | PROJECT_NO_HANGEKI), -1);
+ project(0, 2, ny, nx, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
}
}
else
{
#ifdef JP
-msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
+ msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
#else
msg_print("An explosive rune was disarmed.");
#endif
c_ptr->info &= ~(CAVE_MARK);
/* Break the rune */
- c_ptr->feat = floor_type[randint0(100)];
- c_ptr->info &= ~(CAVE_MASK);
- c_ptr->info |= CAVE_FLOOR;
+ c_ptr->info &= ~(CAVE_OBJECT);
+ c_ptr->mimic = 0;
+
note_spot(ny, nx);
lite_spot(ny, nx);
do_move = TRUE;
}
}
- if (do_move && (ny == py) && (nx == px) && (d_info[dungeon_type].flags1 & DF1_NO_MELEE))
- {
- do_move = FALSE;
- }
- /* Some monsters never attack */
- if (do_move && (ny == py) && (nx == px) &&
- (r_ptr->flags1 & RF1_NEVER_BLOW))
+ /* The player is in the way */
+ if (do_move && player_bold(ny, nx))
{
- /* Hack -- memorize lack of attacks */
- if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_NEVER_BLOW);
-
- /* Do not move */
- do_move = FALSE;
- }
-
- /* The player is in the way. Attack him. */
- if (do_move && (ny == py) && (nx == px))
- {
- if (!p_ptr->riding || one_in_(2))
+ /* Some monsters never attack */
+ if (r_ptr->flags1 & RF1_NEVER_BLOW)
{
- /* Do the attack */
- (void)make_attack_normal(m_idx);
+ /* Hack -- memorize lack of attacks */
+ if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags1 |= (RF1_NEVER_BLOW);
/* Do not move */
do_move = FALSE;
+ }
- /* Took a turn */
- do_turn = TRUE;
+ /* In anti-melee dungeon, stupid or confused monster takes useless turn */
+ if (do_move && (d_info[dungeon_type].flags1 & DF1_NO_MELEE))
+ {
+ if (!m_ptr->confused)
+ {
+ if (!(r_ptr->flags2 & RF2_STUPID)) do_move = FALSE;
+ else
+ {
+ if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_STUPID);
+ }
+ }
}
- }
- if ((c_ptr->feat >= FEAT_PATTERN_START) &&
- (c_ptr->feat <= FEAT_PATTERN_XTRA2) &&
- !do_turn && !(r_ptr->flags7 & RF7_CAN_FLY))
- {
- do_move = FALSE;
- }
+ /* The player is in the way. Attack him. */
+ if (do_move)
+ {
+ if (!p_ptr->riding || one_in_(2))
+ {
+ /* Do the attack */
+ (void)make_attack_normal(m_idx);
+ /* Do not move */
+ do_move = FALSE;
+
+ /* Took a turn */
+ do_turn = TRUE;
+ }
+ }
+ }
/* A monster is in the way */
if (do_move && c_ptr->m_idx)
{
monster_race *z_ptr = &r_info[y_ptr->r_idx];
- monster_type *m2_ptr = &m_list[c_ptr->m_idx];
/* Assume no movement */
do_move = FALSE;
/* Attack 'enemies' */
- if (((r_ptr->flags2 & (RF2_KILL_BODY)) &&
- (r_ptr->mexp * r_ptr->level > z_ptr->mexp * z_ptr->level) &&
- (cave_floor_grid(c_ptr)) &&
- (c_ptr->m_idx != p_ptr->riding)) ||
- are_enemies(m_ptr, m2_ptr) || m_ptr->confused)
+ 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) &&
+ 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)
+ {
+ if (is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_KILL_BODY);
+ }
- if (r_ptr->flags2 & RF2_KILL_BODY) r_ptr->r_flags2 |= (RF2_KILL_BODY);
+ /* attack */
+ if (y_ptr->r_idx && (y_ptr->hp >= 0))
+ {
+ if (monst_attack_monst(m_idx, c_ptr->m_idx)) return;
- /* attack */
- if ((m2_ptr->r_idx) && (m2_ptr->hp >= 0))
- {
- if (monst_attack_monst(m_idx, cave[ny][nx].m_idx))
- return;
+ /* In anti-melee dungeon, stupid or confused monster takes useless turn */
+ else if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
+ {
+ if (m_ptr->confused) return;
+ else if (r_ptr->flags2 & RF2_STUPID)
+ {
+ if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_STUPID);
+ return;
+ }
+ }
+ }
}
}
/* 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;
if (do_move && (r_ptr->flags1 & RF1_NEVER_MOVE))
{
/* Hack -- memorize lack of attacks */
- if (m_ptr->ml) r_ptr->r_flags1 |= (RF1_NEVER_MOVE);
+ if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags1 |= (RF1_NEVER_MOVE);
/* Do not move */
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 (cave[ny][nx].feat == FEAT_TREES)
+ if (did_kill_wall)
{
- if (r_ptr->flags2 & RF2_KILL_WALL)
+ if (one_in_(GRINDNOISE))
{
- c_ptr->feat = FEAT_GRASS;
- c_ptr->info &= ~(CAVE_MASK);
- c_ptr->info |= CAVE_FLOOR;
+#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 -= 100;
+ m_ptr->energy_need += ENERGY_NEED();
}
}
update_mon(c_ptr->m_idx, TRUE);
/* Wake up the moved monster */
- m_list[c_ptr->m_idx].csleep = 0;
+ y_ptr->csleep = 0;
+
+ if (r_info[y_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
+ p_ptr->update |= (PU_MON_LITE);
}
/* Hack -- Update the new location */
/* 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();
/* Update stuff */
- p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW);
+ p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
/* Update the monsters */
p_ptr->update |= (PU_DISTANCE);
- /* Window stuff */
+ /* Update sub-windows */
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
}
/* Possible disturb */
- if (m_ptr->ml && (disturb_move ||
- ((m_ptr->mflag & MFLAG_VIEW) &&
- disturb_near)))
+ if (m_ptr->ml &&
+ (disturb_move ||
+ (disturb_near && (m_ptr->mflag & MFLAG_VIEW)) ||
+ (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)))
{
/* Disturb */
if (is_hostile(m_ptr))
if ((r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
(!is_pet(m_ptr) || (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)))
{
- u32b f1, f2, f3;
+ u32b flgs[TR_FLAG_SIZE];
+ u32b flg2 = 0L;
u32b flg3 = 0L;
char m_name[80];
char o_name[MAX_NLEN];
/* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3);
+ object_flags(o_ptr, flgs);
/* Acquire the object name */
- object_desc(o_name, o_ptr, TRUE, 3);
+ object_desc(o_name, o_ptr, 0);
/* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0x04);
+ monster_desc(m_name, m_ptr, MD_INDEF_HIDDEN);
/* React to objects that hurt the monster */
- if (f1 & TR1_KILL_DRAGON) flg3 |= (RF3_DRAGON);
- if (f1 & TR1_SLAY_DRAGON) flg3 |= (RF3_DRAGON);
- if (f1 & TR1_SLAY_TROLL) flg3 |= (RF3_TROLL);
- if (f1 & TR1_SLAY_GIANT) flg3 |= (RF3_GIANT);
- if (f1 & TR1_SLAY_ORC) flg3 |= (RF3_ORC);
- if (f1 & TR1_SLAY_DEMON) flg3 |= (RF3_DEMON);
- if (f1 & TR1_SLAY_UNDEAD) flg3 |= (RF3_UNDEAD);
- if (f1 & TR1_SLAY_ANIMAL) flg3 |= (RF3_ANIMAL);
- if (f1 & TR1_SLAY_EVIL) flg3 |= (RF3_EVIL);
+ if (have_flag(flgs, TR_KILL_DRAGON)) flg3 |= (RF3_DRAGON);
+ if (have_flag(flgs, TR_SLAY_DRAGON)) flg3 |= (RF3_DRAGON);
+ if (have_flag(flgs, TR_SLAY_TROLL)) flg3 |= (RF3_TROLL);
+ if (have_flag(flgs, TR_KILL_TROLL)) flg3 |= (RF3_TROLL);
+ if (have_flag(flgs, TR_KILL_GIANT)) flg3 |= (RF3_GIANT);
+ if (have_flag(flgs, TR_SLAY_GIANT)) flg3 |= (RF3_GIANT);
+ if (have_flag(flgs, TR_SLAY_ORC)) flg3 |= (RF3_ORC);
+ if (have_flag(flgs, TR_KILL_ORC)) flg3 |= (RF3_ORC);
+ if (have_flag(flgs, TR_SLAY_DEMON)) flg3 |= (RF3_DEMON);
+ if (have_flag(flgs, TR_KILL_DEMON)) flg3 |= (RF3_DEMON);
+ if (have_flag(flgs, TR_SLAY_UNDEAD)) flg3 |= (RF3_UNDEAD);
+ if (have_flag(flgs, TR_KILL_UNDEAD)) flg3 |= (RF3_UNDEAD);
+ if (have_flag(flgs, TR_SLAY_ANIMAL)) flg3 |= (RF3_ANIMAL);
+ if (have_flag(flgs, TR_KILL_ANIMAL)) flg3 |= (RF3_ANIMAL);
+ if (have_flag(flgs, TR_SLAY_EVIL)) flg3 |= (RF3_EVIL);
+ if (have_flag(flgs, TR_KILL_EVIL)) flg3 |= (RF3_EVIL);
+ if (have_flag(flgs, TR_SLAY_HUMAN)) flg2 |= (RF2_HUMAN);
+ if (have_flag(flgs, TR_KILL_HUMAN)) flg2 |= (RF2_HUMAN);
/* The object cannot be picked up by the monster */
- if (artifact_p(o_ptr) || (r_ptr->flags3 & flg3) ||
+ if (artifact_p(o_ptr) || (r_ptr->flags3 & flg3) || (r_ptr->flags2 & flg2) ||
(o_ptr->art_name))
{
/* Only give a message for "take_item" */
{
/* 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 */
excise_object_idx(this_o_idx);
/* Forget mark */
- o_ptr->marked = FALSE;
+ o_ptr->marked = 0;
/* Forget location */
o_ptr->iy = o_ptr->ix = 0;
{
/* 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 */
}
/*
- * Forward movements failed, but now recieved LOS attack!
+ * Forward movements failed, but now received LOS attack!
* Try to flow by smell.
*/
if (p_ptr->no_flowed && i > 2 && m_ptr->target_y)
- m_ptr->mflag2 &= ~MFLAG_NOFLOW;
+ m_ptr->mflag2 &= ~MFLAG2_NOFLOW;
/* If we haven't done anything, try casting a spell again */
- if (!do_turn && !do_move && !m_ptr->monfear && !stupid_monsters && !(p_ptr->riding == m_idx) && aware)
+ if (!do_turn && !do_move && !m_ptr->monfear && !is_riding_mon && aware)
{
- /* Cast spell */
- if (make_attack_spell(m_idx)) return;
+ /* Try to cast spell again */
+ if (r_ptr->freq_spell && randint1(100) <= r_ptr->freq_spell)
+ {
+ if (make_attack_spell(m_idx)) return;
+ }
}
{
/* Update some things */
p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
+
+ /* Window stuff */
+ p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
}
/* Notice changes in view */
- if (do_move && ((r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) || ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !p_ptr->inside_battle)))
+ if (do_move && ((r_ptr->flags7 & (RF7_SELF_LD_MASK | RF7_HAS_DARK_1 | RF7_HAS_DARK_2))
+ || ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !p_ptr->inside_battle)))
{
/* Update some things */
p_ptr->update |= (PU_MON_LITE);
}
/* Learn things from observable monster */
- if (m_ptr->ml)
+ if (m_ptr->ml && is_original_ap(m_ptr))
{
/* Monster opened a door */
if (did_open_door) r_ptr->r_flags2 |= (RF2_OPEN_DOOR);
msg_format("%^s turns to fight!", m_name);
#endif
+ /* Redraw (later) if needed */
+ if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
+
chg_virtue(V_COMPASSION, -1);
}
*/
void process_monsters(void)
{
- int i, e;
+ int i;
int fx, fy;
bool test;
u32b old_r_flags4 = 0L;
u32b old_r_flags5 = 0L;
u32b old_r_flags6 = 0L;
+ u32b old_r_flagsr = 0L;
byte old_r_blows0 = 0;
byte old_r_blows1 = 0;
byte old_r_blows2 = 0;
byte old_r_blows3 = 0;
- byte old_r_cast_inate = 0;
byte old_r_cast_spell = 0;
int speed;
- /* Clear monster fighting indicator */
- mon_fight = FALSE;
+ /* Clear monster fighting indicator */
+ mon_fight = FALSE;
/* Memorize old race */
old_monster_race_idx = p_ptr->monster_race_idx;
old_r_flags4 = r_ptr->r_flags4;
old_r_flags5 = r_ptr->r_flags5;
old_r_flags6 = r_ptr->r_flags6;
+ old_r_flagsr = r_ptr->r_flagsr;
/* Memorize blows */
old_r_blows0 = r_ptr->r_blows[0];
old_r_blows3 = r_ptr->r_blows[3];
/* Memorize castings */
- old_r_cast_inate = r_ptr->r_cast_inate;
old_r_cast_spell = r_ptr->r_cast_spell;
}
- /* Hack -- calculate the "player noise" */
- noise = (1L << (30 - p_ptr->skill_stl));
-
-
/* Process the monsters (backwards) */
for (i = m_max - 1; i >= 1; i--)
{
}
/* Hack -- Require proximity */
- if (m_ptr->cdis >= 100) continue;
+ if (m_ptr->cdis >= AAF_LIMIT) continue;
/* Access the location */
fy = m_ptr->fy;
/* Flow by smell is allowed */
- if (!stupid_monsters && !p_ptr->no_flowed)
+ if (!p_ptr->no_flowed)
{
- m_ptr->mflag2 &= ~MFLAG_NOFLOW;
+ m_ptr->mflag2 &= ~MFLAG2_NOFLOW;
}
/* Assume no move */
test = FALSE;
/* Handle "sensing radius" */
- if (m_ptr->cdis <= (is_pet(m_ptr) ? (r_ptr->aaf > 20 ? 20 : r_ptr->aaf) : r_ptr->aaf))
+ if (m_ptr->cdis <= (is_pet(m_ptr) ? (r_ptr->aaf > MAX_SIGHT ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf))
{
/* We can "sense" the player */
test = TRUE;
/* Handle "sight" and "aggravation" */
else if ((m_ptr->cdis <= MAX_SIGHT) &&
- (player_has_los_bold(fy, fx) || p_ptr->aggravate))
+ (player_has_los_bold(fy, fx) || (p_ptr->cursed & TRC_AGGRAVATE)))
{
/* We can "see" or "feel" the player */
test = TRUE;
}
+#if 0 /* (cave[py][px].when == cave[fy][fx].when) is always FALSE... */
/* Hack -- Monsters can "smell" the player from far away */
/* Note that most monsters have "aaf" of "20" or so */
- else if (!stupid_monsters && !(m_ptr->mflag2 & MFLAG_NOFLOW) &&
- (cave_floor_bold(py, px) || (cave[py][px].feat == FEAT_TREES)) &&
+ else if (!(m_ptr->mflag2 & MFLAG2_NOFLOW) &&
+ 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))
/* We can "smell" the player */
test = TRUE;
}
+#endif
else if (m_ptr->target_y) test = TRUE;
/* Do nothing */
speed = p_ptr->pspeed;
else
{
- speed = MIN(199, m_ptr->mspeed);
+ speed = m_ptr->mspeed;
/* Monsters move quickly in Nightmare mode */
- if (ironman_nightmare)
- {
- speed = MIN(199, m_ptr->mspeed + 5);
- }
+ if (ironman_nightmare) speed += 5;
- if (m_ptr->fast) speed = MIN(199, speed + 10);
- if (m_ptr->slow) speed = MAX(0, speed - 10);
+ if (m_ptr->fast) speed += 10;
+ if (m_ptr->slow) speed -= 10;
}
- e = extract_energy[speed];
-
/* Give this monster some energy */
- if(randint0(60) < e)
- m_ptr->energy += gain_energy();
-
+ m_ptr->energy_need -= SPEED_TO_ENERGY(speed);
/* Not enough energy to move */
- if (m_ptr->energy < 100) continue;
+ if (m_ptr->energy_need > 0) continue;
/* Use up "some" energy */
- m_ptr->energy -= 100;
+ m_ptr->energy_need += ENERGY_NEED();
/* Save global index */
/* Give up flow_by_smell when it might useless */
if (p_ptr->no_flowed && one_in_(3))
- m_ptr->mflag2 |= MFLAG_NOFLOW;
+ m_ptr->mflag2 |= MFLAG2_NOFLOW;
/* Hack -- notice death or departure */
- if (!alive || death) break;
+ if (!p_ptr->playing || p_ptr->is_dead) break;
/* Notice leaving */
if (p_ptr->leaving) break;
(old_r_flags4 != r_ptr->r_flags4) ||
(old_r_flags5 != r_ptr->r_flags5) ||
(old_r_flags6 != r_ptr->r_flags6) ||
+ (old_r_flagsr != r_ptr->r_flagsr) ||
(old_r_blows0 != r_ptr->r_blows[0]) ||
(old_r_blows1 != r_ptr->r_blows[1]) ||
(old_r_blows2 != r_ptr->r_blows[2]) ||
(old_r_blows3 != r_ptr->r_blows[3]) ||
- (old_r_cast_inate != r_ptr->r_cast_inate) ||
(old_r_cast_spell != r_ptr->r_cast_spell))
{
/* Window stuff */
#ifdef JP
msg_print("¡Ö»þ¤è¡ª¡×");
#else
- msg_format("%s yells 'Time!'", m_name);
+ msg_format("%s yells 'Time!'", m_name);
#endif
else msg_print("hek!");
msg_print(NULL);
}
- world_monster = TRUE;
+ /* This monster cast spells */
+ world_monster = hack_m_idx;
if (vs_player) do_cmd_redraw();
while(num--)
{
- if(m_ptr->r_idx) return (TRUE);
- process_monster(hack_m_idx);
+ if(!m_ptr->r_idx) break;
+ process_monster(world_monster);
reset_target(m_ptr);
/* Window stuff */
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
- world_monster = FALSE;
+ world_monster = 0;
if (vs_player || los(py, px, m_ptr->fy, m_ptr->fx))
{
#ifdef JP
if (m_idx == p_ptr->riding) new_exp = (new_exp + 1) / 2;
if (!dun_level) new_exp /= 5;
m_ptr->exp += new_exp;
- if (m_ptr->mflag2 & MFLAG_CHAMELEON) return;
+ if (m_ptr->mflag2 & MFLAG2_CHAMELEON) return;
if (m_ptr->exp >= r_ptr->next_exp)
{
int old_hp = m_ptr->hp;
int old_maxhp = m_ptr->max_maxhp;
int old_r_idx = m_ptr->r_idx;
- int i;
+ byte old_sub_align = m_ptr->sub_align;
+
+ /* Hack -- Reduce the racial counter of previous monster */
+ real_r_ptr(m_ptr)->cur_num--;
monster_desc(m_name, m_ptr, 0);
m_ptr->r_idx = r_ptr->next_r_idx;
+
+ /* Count the monsters on the level */
+ real_r_ptr(m_ptr)->cur_num++;
+
+ m_ptr->ap_r_idx = m_ptr->r_idx;
r_ptr = &r_info[m_ptr->r_idx];
+
if (r_ptr->flags1 & RF1_FORCE_MAXHP)
{
m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
m_ptr->hp = old_hp * m_ptr->maxhp / old_maxhp;
/* Extract the monster base speed */
- m_ptr->mspeed = r_ptr->speed;
+ m_ptr->mspeed = get_mspeed(r_ptr);
- /* Hack -- small racial variety */
- if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
+ /* Sub-alignment of a monster */
+ if (!is_pet(m_ptr) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
+ m_ptr->sub_align = old_sub_align;
+ else
{
- /* Allow some small variation per monster */
- if(one_in_(4)){
- i = extract_energy[r_ptr->speed] / 3;
- if (i) m_ptr->mspeed += rand_spread(0, i);
- }
- else{
- i = extract_energy[r_ptr->speed] / 10;
- if (i) m_ptr->mspeed += rand_spread(0, i);
- }
+ m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
+ if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
+ if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
}
- if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
-
m_ptr->exp = 0;
if (is_pet(m_ptr) || m_ptr->ml)
msg_format("%^s evolved into %s.", m_name, r_name + r_ptr->name);
#endif
r_info[old_r_idx].r_xtra1 |= MR1_SINKA;
+
+ /* Now you feel very close to this pet. */
+ m_ptr->parent_m_idx = 0;
}
update_mon(m_idx, FALSE);
lite_spot(m_ptr->fy, m_ptr->fx);