OSDN Git Service

[Refactor] #38844 new_mane を player_type 構造体に移動.
[hengband/hengband.git] / src / mspells1.c
index 1fb1a92..d59c82e 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+
+#include "floor.h"
+#include "dungeon.h"
+#include "grid.h"
 #include "object-curse.h"
-#include "projection.h"
 #include "quest.h"
 #include "realm-hex.h"
+#include "player-move.h"
+#include "player-status.h"
+#include "monster.h"
+#include "monster-spell.h"
+#include "spells.h"
+#include "world.h"
+#include "realm-song.h"
+#include "view-mainwindow.h"
+#include "player-race.h"
+#include "player-class.h"
 
 
 /*!
@@ -73,7 +87,7 @@ static bool int_outof(monster_race *r_ptr, PERCENTAGE prob)
  */
 static void remove_bad_spells(MONSTER_IDX m_idx, u32b *f4p, u32b *f5p, u32b *f6p)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        u32b f4 = (*f4p);
@@ -247,7 +261,7 @@ static void remove_bad_spells(MONSTER_IDX m_idx, u32b *f4p, u32b *f5p, u32b *f6p
 
        if (smart & (SM_RES_NETH))
        {
-               if (prace_is_(RACE_SPECTRE))
+               if (PRACE_IS_(RACE_SPECTRE))
                {
                        f4 &= ~(RF4_BR_NETH);
                        f5 &= ~(RF5_BA_NETH);
@@ -269,7 +283,7 @@ static void remove_bad_spells(MONSTER_IDX m_idx, u32b *f4p, u32b *f5p, u32b *f6p
 
        if (smart & (SM_RES_DARK))
        {
-               if (prace_is_(RACE_VAMPIRE))
+               if (PRACE_IS_(RACE_VAMPIRE))
                {
                        f4 &= ~(RF4_BR_DARK);
                        f5 &= ~(RF5_BA_DARK);
@@ -418,9 +432,7 @@ bool raise_possible(monster_type *m_ptr)
                        /* Scan the pile of objects */
                        for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                        {
-                               object_type *o_ptr = &o_list[this_o_idx];
-
-                               /* Acquire next object */
+                               object_type *o_ptr = &current_floor_ptr->o_list[this_o_idx];
                                next_o_idx = o_ptr->next_o_idx;
 
                                /* Known to be worthless? */
@@ -485,7 +497,7 @@ bool clean_shot(POSITION y1, POSITION x1, POSITION y2, POSITION x2, bool is_frie
 
                if ((current_floor_ptr->grid_array[y][x].m_idx > 0) && !((y == y2) && (x == x2)))
                {
-                       monster_type *m_ptr = &m_list[current_floor_ptr->grid_array[y][x].m_idx];
+                       monster_type *m_ptr = &current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
                        if (is_friend == is_pet(m_ptr))
                        {
                                return (FALSE);
@@ -580,7 +592,7 @@ void beam(MONSTER_IDX m_idx, POSITION y, POSITION x, EFFECT_ID typ, int dam_hp,
  */
 void breath(POSITION y, POSITION x, MONSTER_IDX m_idx, EFFECT_ID typ, int dam_hp, POSITION rad, bool breath, int monspell, int target_type)
 {
-    monster_type *m_ptr = &m_list[m_idx];
+    monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
     monster_race *r_ptr = &r_info[m_ptr->r_idx];
     bool learnable = spell_learnable(m_idx);
        BIT_FLAGS flg = 0x00;
@@ -861,7 +873,7 @@ static bool spell_dispel(byte spell)
  */
 bool dispel_check(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Invulnabilty (including the song) */
@@ -938,7 +950,6 @@ bool dispel_check(MONSTER_IDX m_idx)
        if ((p_ptr->special_attack & ATTACK_COLD) && !(r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)) return (TRUE);
        if ((p_ptr->special_attack & ATTACK_POIS) && !(r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)) return (TRUE);
 
-       /* Speed */
        if (p_ptr->pspeed < 145)
        {
                if (IS_FAST()) return (TRUE);
@@ -947,9 +958,9 @@ bool dispel_check(MONSTER_IDX m_idx)
        /* Light speed */
        if (p_ptr->lightspeed && (m_ptr->mspeed < 136)) return (TRUE);
 
-       if (p_ptr->riding && (m_list[p_ptr->riding].mspeed < 135))
+       if (p_ptr->riding && (current_floor_ptr->m_list[p_ptr->riding].mspeed < 135))
        {
-               if (MON_FAST(&m_list[p_ptr->riding])) return (TRUE);
+               if (MON_FAST(&current_floor_ptr->m_list[p_ptr->riding])) return (TRUE);
        }
 
        /* No need to cast dispel spell */
@@ -978,7 +989,7 @@ bool dispel_check(MONSTER_IDX m_idx)
  */
 static int choose_attack_spell(MONSTER_IDX m_idx, byte spells[], byte num)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        byte escape[96], escape_num = 0;
@@ -1050,7 +1061,7 @@ static int choose_attack_spell(MONSTER_IDX m_idx, byte spells[], byte num)
        /*** Try to pick an appropriate spell type ***/
 
        /* world */
-       if (world_num && (randint0(100) < 15) && !world_monster)
+       if (world_num && (randint0(100) < 15) && !current_world_ptr->timewalk_m_idx)
        {
                /* Choose haste spell */
                return (world[randint0(world_num)]);
@@ -1109,7 +1120,7 @@ static int choose_attack_spell(MONSTER_IDX m_idx, byte spells[], byte num)
        }
 
        /* Player is close and we have attack spells, blink away */
-       if ((distance(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx) < 4) && (attack_num || (r_ptr->a_ability_flags2 & RF6_TRAPS)) && (randint0(100) < 75) && !world_monster)
+       if ((distance(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx) < 4) && (attack_num || (r_ptr->a_ability_flags2 & RF6_TRAPS)) && (randint0(100) < 75) && !current_world_ptr->timewalk_m_idx)
        {
                /* Choose tactical spell */
                if (tactic_num) return (tactic[randint0(tactic_num)]);
@@ -1160,7 +1171,7 @@ static int choose_attack_spell(MONSTER_IDX m_idx, byte spells[], byte num)
        }
 
        /* Try another tactical spell (sometimes) */
-       if (tactic_num && (randint0(100) < 50) && !world_monster)
+       if (tactic_num && (randint0(100) < 50) && !current_world_ptr->timewalk_m_idx)
        {
                /* Choose tactic spell */
                return (tactic[randint0(tactic_num)]);
@@ -1347,7 +1358,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
        PERCENTAGE failrate;
        byte spell[96], num = 0;
        BIT_FLAGS f4, f5, f6;
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        GAME_TEXT m_name[MAX_NLEN];
 #ifndef JP
@@ -1687,7 +1698,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
                break;
 
        default:
-               return FALSE; /* Paranoia */
+               return FALSE;
        }
 
        /* Abort if no spell was chosen */
@@ -1769,7 +1780,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
                learn_spell(thrown_spell - 96);
        }
 
-       if (seen && maneable && !world_monster && (p_ptr->pclass == CLASS_IMITATOR))
+       if (seen && maneable && !current_world_ptr->timewalk_m_idx && (p_ptr->pclass == CLASS_IMITATOR))
        {
                if (thrown_spell != 167) /* Not RF6_SPECIAL */
                {
@@ -1786,7 +1797,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
                        p_ptr->mane_spell[p_ptr->mane_num] = thrown_spell - 96;
                        p_ptr->mane_dam[p_ptr->mane_num] = dam;
                        p_ptr->mane_num++;
-                       new_mane = TRUE;
+                       p_ptr->new_mane = TRUE;
 
                        p_ptr->redraw |= (PR_IMITATION);
                }