OSDN Git Service

To match English message for adding an essence to an object, swapped the format argum...
[hengbandforosx/hengbandosx.git] / src / mspells2.c
index f860f07..7298ad0 100644 (file)
 #include "projection.h"
 #include "quest.h"
 #include "realm-hex.h"
+#include "player-move.h"
+#include "monster.h"
+#include "monster-status.h"
+#include "monster-spell.h"
 
 /*!
  * @brief モンスターが敵対モンスターにビームを当てること可能かを判定する /
  * @param m_ptr 使用するモンスターの構造体参照ポインタ
  * @return ビームが到達可能ならばTRUEを返す
  */
-static bool direct_beam(int y1, int x1, int y2, int x2, monster_type *m_ptr)
+static bool direct_beam(POSITION y1, POSITION x1, POSITION y2, POSITION x2, monster_type *m_ptr)
 {
        bool hit2 = FALSE;
-       int i, y, x;
+       int i;
+       POSITION y, x;
 
        int grid_n = 0;
        u16b grid_g[512];
@@ -49,8 +54,8 @@ static bool direct_beam(int y1, int x1, int y2, int x2, monster_type *m_ptr)
 
                if (y == y2 && x == x2)
                        hit2 = TRUE;
-               else if (is_friend && grid_array[y][x].m_idx > 0 &&
-                        !are_enemies(m_ptr, &m_list[grid_array[y][x].m_idx]))
+               else if (is_friend && current_floor_ptr->grid_array[y][x].m_idx > 0 &&
+                        !are_enemies(m_ptr, &current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]))
                {
                        /* Friends don't shoot friends */
                        return FALSE;
@@ -227,12 +232,10 @@ void get_project_point(POSITION sy, POSITION sx, POSITION *ty, POSITION *tx, BIT
  */
 static bool dispel_check_monster(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 {
-       monster_type *t_ptr = &m_list[t_idx];
+       monster_type *t_ptr = &current_floor_ptr->m_list[t_idx];
 
-       /* Invulnabilty */
        if (MON_INVULNER(t_ptr)) return TRUE;
 
-       /* Speed */
        if (t_ptr->mspeed < 135)
        {
                if (MON_FAST(t_ptr)) return TRUE;
@@ -275,7 +278,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        char m_poss[160];
 #endif
 
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_type *t_ptr = NULL;
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -286,7 +289,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        bool maneable = player_has_los_bold(m_ptr->fy, m_ptr->fx);
        bool pet = is_pet(m_ptr);
 
-       bool in_no_magic_dungeon = (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && dun_level
+       bool in_no_magic_dungeon = (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && current_floor_ptr->dun_level
                && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest));
 
        bool can_use_lite_area = FALSE;
@@ -304,7 +307,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        if (pet_t_m_idx && pet)
        {
                target_idx = pet_t_m_idx;
-               t_ptr = &m_list[target_idx];
+               t_ptr = &current_floor_ptr->m_list[target_idx];
 
                /* Cancel if not projectable (for now) */
                if ((m_idx == target_idx) || !projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
@@ -316,11 +319,11 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        /* Is there counter attack target? */
        if (!target_idx && m_ptr->target_y)
        {
-               target_idx = grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
+               target_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
 
                if (target_idx)
                {
-                       t_ptr = &m_list[target_idx];
+                       t_ptr = &current_floor_ptr->m_list[target_idx];
 
                        /* Cancel if neither enemy nor a given target */
                        if ((m_idx == target_idx) ||
@@ -358,10 +361,9 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
                        if (!dummy) continue;
 
                        target_idx = dummy;
-                       t_ptr = &m_list[target_idx];
+                       t_ptr = &current_floor_ptr->m_list[target_idx];
 
-                       /* Skip dead monsters */
-                       if (!t_ptr->r_idx) continue;
+                       if (!monster_is_valid(t_ptr)) continue;
 
                        /* Monster must be 'an enemy' */
                        if ((m_idx == target_idx) || !are_enemies(m_ptr, t_ptr)) continue;
@@ -704,7 +706,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        dam = monspell_to_monster(thrown_spell, y, x, m_idx, target_idx);
        if (dam < 0) return FALSE;
 
-       if (m_ptr->ml && maneable && !world_monster && !p_ptr->blind && (p_ptr->pclass == CLASS_IMITATOR))
+       if (m_ptr->ml && maneable && !current_world_ptr->timewalk_m_idx && !p_ptr->blind && (p_ptr->pclass == CLASS_IMITATOR))
        {
                if (thrown_spell != 167) /* Not RF6_SPECIAL */
                {