*/
#include "angband.h"
+#include "util.h"
+
#include "cmd-pet.h"
-#include "monsterrace-hook.h"
#include "melee.h"
-#include "projection.h"
+#include "spells.h"
#include "spells-summon.h"
#include "quest.h"
#include "avatar.h"
+#include "realm-hex.h"
+#include "object-flavor.h"
+#include "object-hook.h"
+#include "feature.h"
+#include "grid.h"
+#include "player-move.h"
+#include "monster-status.h"
+#include "monster-spell.h"
+#include "monster-process.h"
+#include "monsterrace-hook.h"
+#include "dungeon.h"
+#include "floor.h"
+#include "files.h"
/*!
{
int i;
POSITION x = 0, y = 0;
- IDX t_idx;
+ MONSTER_IDX t_idx;
int start;
int plus = 1;
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
monster_type *t_ptr;
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;
+ y = current_floor_ptr->m_list[riding_t_m_idx].fy;
+ x = current_floor_ptr->m_list[riding_t_m_idx].fx;
}
else if (is_pet(m_ptr) && pet_t_m_idx)
{
- y = m_list[pet_t_m_idx].fy;
- x = m_list[pet_t_m_idx].fx;
+ y = current_floor_ptr->m_list[pet_t_m_idx].fy;
+ x = current_floor_ptr->m_list[pet_t_m_idx].fx;
}
else
{
if (p_ptr->inside_battle)
{
- start = randint1(m_max-1)+m_max;
+ start = randint1(current_floor_ptr->m_max-1)+current_floor_ptr->m_max;
if(randint0(2)) plus = -1;
}
- else start = m_max + 1;
+ else start = current_floor_ptr->m_max + 1;
/* Scan thru all monsters */
- for (i = start; ((i < start + m_max) && (i > start - m_max)); i+=plus)
+ for (i = start; ((i < start + current_floor_ptr->m_max) && (i > start - current_floor_ptr->m_max)); i+=plus)
{
- IDX dummy = (i % m_max);
+ MONSTER_IDX dummy = (i % current_floor_ptr->m_max);
if (!dummy) continue;
t_idx = dummy;
- t_ptr = &m_list[t_idx];
+ t_ptr = ¤t_floor_ptr->m_list[t_idx];
/* The monster itself isn't a target */
if (t_ptr == m_ptr) continue;
- /* Paranoia -- Skip dead monsters */
- if (!t_ptr->r_idx) continue;
+ if (!monster_is_valid(t_ptr)) continue;
if (is_pet(m_ptr))
{
return TRUE;
}
-
-/*!
- * @brief モンスターが敵モンスターに行う打撃処理 /
- * Hack, based on mon_take_hit... perhaps all monster attacks on other monsters should use this?
- * @param m_idx 目標となるモンスターの参照ID
- * @param dam ダメージ量
- * @param dead 目標となったモンスターの死亡状態を返す参照ポインタ
- * @param fear 目標となったモンスターの恐慌状態を返す参照ポインタ
- * @param note 目標モンスターが死亡した場合の特別メッセージ(NULLならば標準表示を行う)
- * @param who 打撃を行ったモンスターの参照ID
- * @return なし
- */
-void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *dead, bool *fear, concptr note, IDX who)
-{
- monster_type *m_ptr = &m_list[m_idx];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
- GAME_TEXT m_name[160];
- bool seen = is_seen(m_ptr);
-
- /* Can the player be aware of this attack? */
- bool known = (m_ptr->cdis <= MAX_SIGHT);
-
- /* Extract monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Redraw (later) if needed */
- if (m_ptr->ml)
- {
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
-
- (void)set_monster_csleep(m_idx, 0);
-
- if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
-
- if (MON_INVULNER(m_ptr) && randint0(PENETRATE_INVULNERABILITY))
- {
- if (seen)
- {
- msg_format(_("%^sはダメージを受けない。", "%^s is unharmed."), m_name);
- }
- return;
- }
-
- if (r_ptr->flagsr & RFR_RES_ALL)
- {
- if(dam > 0)
- {
- dam /= 100;
- if((dam == 0) && one_in_(3)) dam = 1;
- }
- if(dam == 0)
- {
- if (seen)
- {
- msg_format(_("%^sはダメージを受けない。", "%^s is unharmed."), m_name);
- }
- return;
- }
- }
-
- /* Hurt it */
- m_ptr->hp -= dam;
-
- /* It is dead now... or is it? */
- if (m_ptr->hp < 0)
- {
- if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) ||
- (r_ptr->flags7 & RF7_NAZGUL)) &&
- !p_ptr->inside_battle)
- {
- m_ptr->hp = 1;
- }
- else
- {
- /* Make a sound */
- if (!monster_living(m_ptr->r_idx))
- {
- sound(SOUND_N_KILL);
- }
- else
- {
- sound(SOUND_KILL);
- }
-
- *dead = TRUE;
-
- if (known)
- {
- monster_desc(m_name, m_ptr, MD_TRUE_NAME);
- /* Unseen death by normal attack */
- if (!seen)
- {
- mon_fight = TRUE;
- }
- /* Death by special attack */
- else if (note)
- {
- msg_format(_("%^s%s", "%^s%s"), m_name, note);
- }
- /* Death by normal attack -- nonliving monster */
- else if (!monster_living(m_ptr->r_idx))
- {
- msg_format(_("%^sは破壊された。", "%^s is destroyed."), m_name);
- }
- /* Death by normal attack -- living monster */
- else
- {
- msg_format(_("%^sは殺された。", "%^s is killed."), m_name);
- }
- }
-
- monster_gain_exp(who, m_ptr->r_idx);
- monster_death(m_idx, FALSE);
- delete_monster_idx(m_idx);
-
- /* Not afraid */
- (*fear) = FALSE;
-
- /* Monster is dead */
- return;
- }
- }
-
- *dead = FALSE;
-
-#ifdef ALLOW_FEAR
-
- /* Mega-Hack -- Pain cancels fear */
- if (MON_MONFEAR(m_ptr) && (dam > 0))
- {
- /* Cure fear */
- if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam / 4)))
- {
- /* No more fear */
- (*fear) = FALSE;
- }
- }
-
- /* Sometimes a monster gets scared by damage */
- if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & RF3_NO_FEAR))
- {
- /* Percentage of fully healthy */
- int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
-
- /*
- * Run (sometimes) if at 10% or less of max hit points,
- * or (usually) when hit for half its current hit points
- */
- if (((percentage <= 10) && (randint0(10) < percentage)) ||
- ((dam >= m_ptr->hp) && (randint0(100) < 80)))
- {
- /* Hack -- note fear */
- (*fear) = TRUE;
-
- /* Hack -- Add some timed fear */
- (void)set_monster_monfear(m_idx, (randint1(10) +
- (((dam >= m_ptr->hp) && (percentage > 7)) ?
- 20 : ((11 - percentage) * 5))));
- }
- }
-
-#endif /* ALLOW_FEAR */
-
- if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr) && (who != m_idx))
- {
- 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 (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
- {
- /* Extract monster name */
- monster_desc(m_name, m_ptr, 0);
-
- if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
- if (rakuba((dam > 200) ? 200 : dam, FALSE))
- {
- msg_format(_("%^sに振り落とされた!", "You have thrown off from %s!"), m_name);
- }
- }
-
- /* Not dead yet */
- return;
-}
-
-
/*!
* @brief モンスターがプレイヤーから逃走するかどうかを返す /
* Returns whether a given monster will try to run from the player.
*/
static bool mon_will_run(MONSTER_IDX m_idx)
{
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
#ifdef ALLOW_TERROR
int i, best = 999;
POSITION y, x, y1, x1;
- cave_type *c_ptr;
+ grid_type *g_ptr;
bool can_open_door = FALSE;
int now_cost;
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
/* Monster location */
if (projectable(y1, x1, p_ptr->y, p_ptr->x)) return (FALSE);
/* Set current grid cost */
- now_cost = cave[y1][x1].cost;
+ now_cost = current_floor_ptr->grid_array[y1][x1].cost;
if (now_cost == 0) now_cost = 999;
/* Can monster bash or open doors? */
/* Simply move to player */
if (player_bold(y, x)) return (FALSE);
- c_ptr = &cave[y][x];
+ g_ptr = ¤t_floor_ptr->grid_array[y][x];
- cost = c_ptr->cost;
+ cost = g_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) && (m_idx != p_ptr->riding))))
{
if (cost == 0) continue;
- if (!can_open_door && is_closed_door(c_ptr->feat)) continue;
+ if (!can_open_door && is_closed_door(g_ptr->feat)) continue;
}
/* Hack -- for kill or pass wall monster.. */
int i, best;
POSITION y, x, y1, x1;
- cave_type *c_ptr;
+ grid_type *g_ptr;
bool use_scent = FALSE;
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
/* Can monster cast attack spell? */
if (player_has_los_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)) return (FALSE);
/* Monster grid */
- c_ptr = &cave[y1][x1];
+ g_ptr = ¤t_floor_ptr->grid_array[y1][x1];
/* If we can hear noises, advance towards them */
- if (c_ptr->cost)
+ if (g_ptr->cost)
{
best = 999;
}
/* Otherwise, try to follow a scent trail */
- else if (c_ptr->when)
+ else if (g_ptr->when)
{
/* Too old smell */
- if (cave[p_ptr->y][p_ptr->x].when - c_ptr->when > 127) return (FALSE);
+ if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when - g_ptr->when > 127) return (FALSE);
use_scent = TRUE;
best = 0;
/* Ignore locations off of edge */
if (!in_bounds2(y, x)) continue;
- c_ptr = &cave[y][x];
+ g_ptr = ¤t_floor_ptr->grid_array[y][x];
/* We're following a scent trail */
if (use_scent)
{
- int when = c_ptr->when;
+ int when = g_ptr->when;
/* Accept younger scent */
if (best > when) continue;
int cost;
if (r_ptr->flags2 & (RF2_BASH_DOOR | RF2_OPEN_DOOR))
- cost = c_ptr->dist;
- else cost = c_ptr->cost;
+ cost = g_ptr->dist;
+ else cost = g_ptr->cost;
/* Accept louder sounds */
if ((cost == 0) || (best < cost)) continue;
int score = -1;
int i;
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
/* Monster location */
fy = m_ptr->fy;
if (!in_bounds2(y, x)) continue;
/* Don't move toward player */
- /* if (cave[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
+ /* if (current_floor_ptr->grid_array[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
/* Calculate distance of this grid from our destination */
dis = distance(y, x, y1, x1);
/* Score this grid */
- s = 5000 / (dis + 3) - 500 / (cave[y][x].dist + 1);
+ s = 5000 / (dis + 3) - 500 / (current_floor_ptr->grid_array[y][x].dist + 1);
/* No negative scores */
if (s < 0) s = 0;
*/
static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
{
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
POSITION fy = m_ptr->fy;
POSITION fx = m_ptr->fx;
POSITION *y_offsets;
POSITION *x_offsets;
- cave_type *c_ptr;
+ grid_type *g_ptr;
/* Start with adjacent locations, spread further */
for (d = 1; d < 10; d++)
/* Skip illegal locations */
if (!in_bounds(y, x)) continue;
- c_ptr = &cave[y][x];
+ g_ptr = ¤t_floor_ptr->grid_array[y][x];
/* Skip locations in a wall */
- if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == p_ptr->riding) ? CEM_RIDING : 0)) continue;
+ if (!monster_can_cross_terrain(g_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == p_ptr->riding) ? CEM_RIDING : 0)) continue;
/* Check for "availability" (if monsters can flow) */
if (!(m_ptr->mflag2 & MFLAG2_NOFLOW))
{
/* Ignore grids very far from the player */
- if (c_ptr->dist == 0) continue;
+ if (g_ptr->dist == 0) continue;
/* Ignore too-distant grids */
- if (c_ptr->dist > cave[fy][fx].dist + 2 * d) continue;
+ if (g_ptr->dist > current_floor_ptr->grid_array[fy][fx].dist + 2 * d) continue;
}
/* Check for absence of shot (more or less) */
*/
static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
{
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
POSITION fy = m_ptr->fy;
*/
static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
{
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
POSITION y = 0, ay, x = 0, ax;
int move_val = 0;
POSITION x2 = p_ptr->x;
bool done = FALSE;
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));
+ grid_type *g_ptr;
+ bool no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (current_floor_ptr->grid_array[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));
/* Counter attack to an enemy monster */
if (!will_run && m_ptr->target_y)
{
- int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+ int t_m_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
/* The monster must be an enemy, and in LOS */
if (t_m_idx &&
- are_enemies(m_ptr, &m_list[t_m_idx]) &&
+ are_enemies(m_ptr, ¤t_floor_ptr->m_list[t_m_idx]) &&
los(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x) &&
projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
{
if (!done && !will_run && is_hostile(m_ptr) &&
(r_ptr->flags1 & RF1_FRIENDS) &&
((los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) ||
- (cave[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
+ (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
{
/*
* Animal packs try to get the player out of corridors
if (!in_bounds2(yy, xx)) continue;
- c_ptr = &cave[yy][xx];
+ g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
/* Check grid */
- if (monster_can_cross_terrain(c_ptr->feat, r_ptr, 0))
+ if (monster_can_cross_terrain(g_ptr->feat, r_ptr, 0))
{
/* One more room grid */
room++;
}
}
- if (cave[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
+ if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
if (!r_ptr->flags4 && !r_ptr->a_ability_flags1 && !r_ptr->a_ability_flags2) room -= 2;
/* Not in a room and strong player */
}
/* Monster groups try to surround the player */
- if (!done && (cave[m_ptr->fy][m_ptr->fx].dist < 3))
+ if (!done && (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < 3))
{
int i;
*/
static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
{
- monster_type *m_ptr = &m_list[m_idx];
- monster_type *t_ptr = &m_list[t_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
+ monster_type *t_ptr = ¤t_floor_ptr->m_list[t_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
monster_race *tr_ptr = &r_info[t_ptr->r_idx];
/* Not allowed to attack */
if (r_ptr->flags1 & RF1_NEVER_BLOW) return FALSE;
- if (d_info[dungeon_type].flags1 & DF1_NO_MELEE) return (FALSE);
+ if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE) return (FALSE);
/* Total armor */
ac = tr_ptr->ac;
int d_dice = r_ptr->blow[ap_cnt].d_dice;
int d_side = r_ptr->blow[ap_cnt].d_side;
- if (!m_ptr->r_idx) break;
+ if (!monster_is_valid(m_ptr)) break;
/* Stop attacking if the target dies! */
if (t_ptr->fx != x_saver || t_ptr->fy != y_saver)
*/
void process_monster(MONSTER_IDX m_idx)
{
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_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];
DIRECTION mm[8];
- cave_type *c_ptr;
+ grid_type *g_ptr;
feature_type *f_ptr;
monster_type *y_ptr;
msg_print("地面に落とされた。");
#else
GAME_TEXT m_name[MAX_NLEN];
- monster_desc(m_name, &m_list[p_ptr->riding], 0);
+ monster_desc(m_name, ¤t_floor_ptr->m_list[p_ptr->riding], 0);
msg_format("You have fallen from %s.", m_name);
#endif
}
}
/* Are there its parent? */
- if (m_ptr->parent_m_idx && !m_list[m_ptr->parent_m_idx].r_idx)
+ if (m_ptr->parent_m_idx && !current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
{
/* Its parent have gone, it also goes away. */
msg_print(_("地面に落とされた。", "You have fallen from riding pet."));
}
- /* Check for quest completion */
check_quest_completion(m_ptr);
-
delete_monster_idx(m_idx);
-
return;
}
}
/* Handle non-aggravation - Still sleeping */
if (!(p_ptr->cursed & TRC_AGGRAVATE)) return;
- /* Reset sleep counter */
(void)set_monster_csleep(m_idx, 0);
/* Notice the "waking up" */
/* Paranoia... no pet uniques outside wizard mode -- TY */
if (is_pet(m_ptr) && ((((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)))
+ monster_has_hostile_align(NULL, 10, -10, r_ptr)) || (r_ptr->flagsr & RFR_RES_ALL)))
{
gets_angry = TRUE;
}
ox = m_ptr->fx;
/* Attempt to "multiply" if able and allowed */
- if ((r_ptr->flags2 & RF2_MULTIPLY) && (num_repro < MAX_REPRO))
+ if ((r_ptr->flags2 & RF2_MULTIPLY) && (current_floor_ptr->num_repro < MAX_REPRO))
{
int k;
POSITION y, x;
{
/* Ignore locations off of edge */
if (!in_bounds2(y, x)) continue;
- if (cave[y][x].m_idx) k++;
+ if (current_floor_ptr->grid_array[y][x].m_idx) k++;
}
}
if (multiply_monster(m_idx, FALSE, (is_pet(m_ptr) ? PM_FORCE_PET : 0)))
{
/* Take note if visible */
- if (m_list[hack_m_idx_ii].ml && is_original_ap_and_seen(m_ptr))
+ if (current_floor_ptr->m_list[hack_m_idx_ii].ml && is_original_ap_and_seen(m_ptr))
{
r_ptr->r_flags2 |= (RF2_MULTIPLY);
}
{
if (summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_MOLD, (PM_ALLOW_GROUP | p_mode), '\0'))
{
- if (m_list[hack_m_idx_ii].ml) count++;
+ if (current_floor_ptr->m_list[hack_m_idx_ii].ml) count++;
}
}
/* Give priority to counter attack? */
if (m_ptr->target_y)
{
- MONSTER_IDX t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+ MONSTER_IDX t_m_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
/* The monster must be an enemy, and projectable */
- if (t_m_idx && are_enemies(m_ptr, &m_list[t_m_idx]) &&
+ if (t_m_idx && are_enemies(m_ptr, ¤t_floor_ptr->m_list[t_m_idx]) &&
projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
{
counterattack = TRUE;
/* Ignore locations off of edge */
if (!in_bounds2(ny, nx)) continue;
- /* 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 grid */
+ g_ptr = ¤t_floor_ptr->grid_array[ny][nx];
+ f_ptr = &f_info[g_ptr->feat];
+ can_cross = monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
- /* Access that cave grid's contents */
- y_ptr = &m_list[c_ptr->m_idx];
+ /* Access that grid's contents */
+ y_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
/* Hack -- player 'in' wall */
if (player_bold(ny, nx))
}
/* Possibly a monster to attack */
- else if (c_ptr->m_idx)
+ else if (g_ptr->m_idx)
{
do_move = TRUE;
}
}
/* Handle doors and secret doors */
- else if (is_closed_door(c_ptr->feat))
+ else if (is_closed_door(g_ptr->feat))
{
bool may_bash = TRUE;
if (did_open_door || did_bash_door)
{
/* Break down the door */
- if (did_bash_door && ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS)))
+ if (did_bash_door && ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS)))
{
cave_alter_feat(ny, nx, FF_BASH);
- if (!m_ptr->r_idx) /* Killed by shards of glass, etc. */
+ if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
{
- /* Update some things */
p_ptr->update |= (PU_FLOW);
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_BASH_DOOR);
cave_alter_feat(ny, nx, FF_OPEN);
}
- f_ptr = &f_info[c_ptr->feat];
+ f_ptr = &f_info[g_ptr->feat];
/* Handle viewable doors */
do_view = TRUE;
}
/* Hack -- check for Glyph of Warding */
- if (do_move && is_glyph_grid(c_ptr) &&
+ if (do_move && is_glyph_grid(g_ptr) &&
!((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
{
/* Assume no move allowed */
if (!is_pet(m_ptr) && (randint1(BREAK_GLYPH) < r_ptr->level))
{
/* Describe observable breakage */
- if (c_ptr->info & CAVE_MARK)
+ if (g_ptr->info & CAVE_MARK)
{
msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
}
/* Forget the rune */
- c_ptr->info &= ~(CAVE_MARK);
+ g_ptr->info &= ~(CAVE_MARK);
/* Break the rune */
- c_ptr->info &= ~(CAVE_OBJECT);
- c_ptr->mimic = 0;
+ g_ptr->info &= ~(CAVE_OBJECT);
+ g_ptr->mimic = 0;
/* Allow movement */
do_move = TRUE;
note_spot(ny, nx);
}
}
- else if (do_move && is_explosive_rune_grid(c_ptr) &&
+ else if (do_move && is_explosive_rune_grid(g_ptr) &&
!((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
{
/* Assume no move allowed */
if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
{
/* Describe observable breakage */
- if (c_ptr->info & CAVE_MARK)
+ if (g_ptr->info & CAVE_MARK)
{
msg_print(_("ルーンが爆発した!", "The rune explodes!"));
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);
}
/* Forget the rune */
- c_ptr->info &= ~(CAVE_MARK);
+ g_ptr->info &= ~(CAVE_MARK);
/* Break the rune */
- c_ptr->info &= ~(CAVE_OBJECT);
- c_ptr->mimic = 0;
+ g_ptr->info &= ~(CAVE_OBJECT);
+ g_ptr->mimic = 0;
note_spot(ny, nx);
lite_spot(ny, nx);
- if (!m_ptr->r_idx) return;
+ if (!monster_is_valid(m_ptr)) return;
/* Allow movement */
do_move = TRUE;
}
do_move = FALSE;
}
- /* In anti-melee dungeon, stupid or confused monster takes useless turn */
- if (do_move && (d_info[dungeon_type].flags1 & DF1_NO_MELEE))
+ /* In anti-melee dungeon, stupid or confused monster takes useless current_world_ptr->game_turn */
+ if (do_move && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
{
if (!MON_CONFUSED(m_ptr))
{
/* Do not move */
do_move = FALSE;
- /* Took a turn */
+ /* Took a current_world_ptr->game_turn */
do_turn = TRUE;
}
}
}
/* A monster is in the way */
- if (do_move && c_ptr->m_idx)
+ if (do_move && g_ptr->m_idx)
{
monster_race *z_ptr = &r_info[y_ptr->r_idx];
/* 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) &&
- can_cross && (c_ptr->m_idx != p_ptr->riding)) ||
+ can_cross && (g_ptr->m_idx != p_ptr->riding)) ||
are_enemies(m_ptr, y_ptr) || MON_CONFUSED(m_ptr))
{
if (!(r_ptr->flags1 & RF1_NEVER_BLOW))
/* attack */
if (y_ptr->r_idx && (y_ptr->hp >= 0))
{
- if (monst_attack_monst(m_idx, c_ptr->m_idx)) return;
+ if (monst_attack_monst(m_idx, g_ptr->m_idx)) return;
- /* In anti-melee dungeon, stupid or confused monster takes useless turn */
- else if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
+ /* In anti-melee dungeon, stupid or confused monster takes useless current_world_ptr->game_turn */
+ else if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE)
{
if (MON_CONFUSED(m_ptr)) return;
else if (r_ptr->flags2 & RF2_STUPID)
/* Push past weaker monsters (unless leaving a wall) */
else if ((r_ptr->flags2 & RF2_MOVE_BODY) && !(r_ptr->flags1 & RF1_NEVER_MOVE) &&
(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))
+ can_cross && (g_ptr->m_idx != p_ptr->riding) &&
+ monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
{
/* Allow movement */
do_move = TRUE;
did_move_body = TRUE;
/* Wake up the moved monster */
- (void)set_monster_csleep(c_ptr->m_idx, 0);
+ (void)set_monster_csleep(g_ptr->m_idx, 0);
/* Message */
}
if (is_riding_mon)
{
- if (!p_ptr->riding_ryoute && !MON_MONFEAR(&m_list[p_ptr->riding])) do_move = FALSE;
+ if (!p_ptr->riding_ryoute && !MON_MONFEAR(¤t_floor_ptr->m_list[p_ptr->riding])) do_move = FALSE;
}
if (did_kill_wall && do_move)
cave_alter_feat(ny, nx, FF_HURT_DISI);
- if (!m_ptr->r_idx) /* Killed by shards of glass, etc. */
+ if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
{
- /* Update some things */
p_ptr->update |= (PU_FLOW);
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_KILL_WALL);
return;
}
- f_ptr = &f_info[c_ptr->feat];
+ f_ptr = &f_info[g_ptr->feat];
/* Note changes to viewable region */
do_view = TRUE;
if (must_alter_to_move && (r_ptr->flags7 & RF7_AQUATIC))
{
- if (!monster_can_cross_terrain(c_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
+ if (!monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
{
/* Assume no move allowed */
do_move = FALSE;
if (!is_riding_mon)
{
/* Hack -- Update the old location */
- cave[oy][ox].m_idx = c_ptr->m_idx;
+ current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
/* Mega-Hack -- move the old monster, if any */
- if (c_ptr->m_idx)
+ if (g_ptr->m_idx)
{
/* Move the old monster */
y_ptr->fy = oy;
y_ptr->fx = ox;
/* Update the old monster */
- update_monster(c_ptr->m_idx, TRUE);
+ update_monster(g_ptr->m_idx, TRUE);
}
/* Hack -- Update the new location */
- c_ptr->m_idx = m_idx;
+ g_ptr->m_idx = m_idx;
/* Move the monster */
m_ptr->fy = ny;
}
/* Take or Kill objects on the floor */
- if (c_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
+ if (g_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
(!is_pet(m_ptr) || ((p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) && (r_ptr->flags2 & RF2_TAKE_ITEM))))
{
OBJECT_IDX this_o_idx, next_o_idx;
bool do_take = (r_ptr->flags2 & RF2_TAKE_ITEM) ? TRUE : FALSE;
/* Scan all objects in the grid */
- for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
{
BIT_FLAGS flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L;
GAME_TEXT m_name[MAX_NLEN], o_name[MAX_NLEN];
- object_type *o_ptr = &o_list[this_o_idx];
-
- /* Acquire next object */
+ object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
next_o_idx = o_ptr->next_o_idx;
if (do_take)
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);
}
/*!
* @brief 全モンスターのターン管理メインルーチン /
- * Process all the "live" monsters, once per game turn.
+ * Process all the "live" monsters, once per game current_world_ptr->game_turn.
* @return なし
* @details
- * During each game turn, we scan through the list of all the "live" monsters,\n
+ * During each game current_world_ptr->game_turn, we scan through the list of all the "live" monsters,\n
* (backwards, so we can excise any "freshly dead" monsters), energizing each\n
* monster, and allowing fully energized monsters to move, attack, pass, etc.\n
*\n
*\n
* Note the special "MFLAG_BORN" flag, which allows us to ignore "fresh"\n
* monsters while they are still being "born". A monster is "fresh" only\n
- * during the turn in which it is created, and we use the "hack_m_idx" to\n
- * determine if the monster is yet to be processed during the current turn.\n
+ * during the current_world_ptr->game_turn in which it is created, and we use the "hack_m_idx" to\n
+ * determine if the monster is yet to be processed during the current current_world_ptr->game_turn.\n
*\n
* Note the special "MFLAG_NICE" flag, which allows the player to get one\n
* move before any "nasty" monsters get to use their spell attacks.\n
*/
void process_monsters(void)
{
- IDX i;
+ MONSTER_IDX i;
POSITION fx, fy;
bool test;
/* Process the monsters (backwards) */
- for (i = m_max - 1; i >= 1; i--)
+ for (i = current_floor_ptr->m_max - 1; i >= 1; i--)
{
/* Access the monster */
- m_ptr = &m_list[i];
+ m_ptr = ¤t_floor_ptr->m_list[i];
r_ptr = &r_info[m_ptr->r_idx];
/* Handle "leaving" */
if (p_ptr->leaving) break;
/* Ignore "dead" monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (p_ptr->wild_mode) continue;
/* Hack -- Require proximity */
if (m_ptr->cdis >= AAF_LIMIT) continue;
-
- /* Access the location */
fx = m_ptr->fx;
fy = m_ptr->fy;
test = TRUE;
}
-#if 0 /* (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) is always FALSE... */
+#if 0 /* (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when == current_floor_ptr->grid_array[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 (!(m_ptr->mflag2 & MFLAG2_NOFLOW) &&
cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_MOVE) &&
- (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) &&
- (cave[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
- (cave[fy][fx].dist < r_ptr->aaf))
+ (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when == current_floor_ptr->grid_array[fy][fx].when) &&
+ (current_floor_ptr->grid_array[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
+ (current_floor_ptr->grid_array[fy][fx].dist < r_ptr->aaf))
{
/* We can "smell" the player */
test = TRUE;