OSDN Git Service

[Refactor] #37353 monster_living() の引数修正。 / Type replacement of monster_living()...
[hengband/hengband.git] / src / spells1.c
index f6f136c..9832e6a 100644 (file)
@@ -15,6 +15,8 @@
 #include "cmd-pet.h"
 #include "trap.h"
 #include "object-curse.h"
+#include "player-damage.h"
+#include "monster-hook.h"
 
 
 static int rakubadam_m; /*!< 振り落とされた際のダメージ量 */
@@ -143,7 +145,7 @@ static void next_mirror(int* next_y, int* next_x, int cury, int curx)
  * @param max 色IDの最大値
  * @return 選択した色ID
  */
-static byte mh_attr(int max)
+static TERM_COLOR mh_attr(int max)
 {
        switch (randint1(max))
        {
@@ -174,7 +176,7 @@ static byte mh_attr(int max)
  * @param type 魔法属性
  * @return 対応する色ID
  */
-static byte spell_color(int type)
+static TERM_COLOR spell_color(int type)
 {
        /* Check if A.B.'s new graphics should be used (rr9) */
        if (streq(ANGBAND_GRAF, "new") || streq(ANGBAND_GRAF, "ne2"))
@@ -242,8 +244,8 @@ static byte spell_color(int type)
        /* Normal tiles or ASCII */
        else
        {
-               byte a;
-               char c;
+               TERM_COLOR a;
+               SYMBOL_CODE c;
 
                /* Lookup the default colors for this type */
                cptr s = quark_str(gf_color[type]);
@@ -291,7 +293,7 @@ u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ)
        byte k;
 
        TERM_COLOR a;
-       char c;
+       SYMBOL_CODE c;
 
        /* No motion (*) */
        if ((ny == y) && (nx == x)) base = 0x30;
@@ -376,16 +378,16 @@ u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ)
  */
 sint project_path(u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg)
 {
-       int y, x;
+       POSITION y, x;
 
        int n = 0;
        int k = 0;
 
        /* Absolute */
-       int ay, ax;
+       POSITION ay, ax;
 
        /* Offsets */
-       int sy, sx;
+       POSITION sy, sx;
 
        /* Fractions */
        int frac;
@@ -752,7 +754,7 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                case GF_GRAVITY:
                        message = _("粉砕された", "was crushed."); break;
                default:
-                       message = NULL;break;
+                       message = NULL; break;
                }
                if (message)
                {
@@ -852,10 +854,7 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        if (!p_ptr->blind && player_has_los_bold(y, x))
                        {
                                c_ptr->info &= ~(CAVE_UNSAFE);
-
-                               /* Redraw */
                                lite_spot(y, x);
-
                                obvious = TRUE;
                        }
 
@@ -883,10 +882,7 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        if (!p_ptr->blind && player_has_los_bold(y, x))
                        {
                                c_ptr->info &= ~(CAVE_UNSAFE);
-
-                               /* Redraw */
                                lite_spot(y, x);
-
                                obvious = TRUE;
                        }
 
@@ -901,12 +897,9 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                feature_type *mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
 
                                cave_alter_feat(y, x, FF_SPIKE);
-
                                c_ptr->mimic = old_mimic;
 
                                note_spot(y, x);
-
-                               /* Redraw */
                                lite_spot(y, x);
 
                                /* Check line of sight */
@@ -997,7 +990,6 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                        note_spot(y, x);
 
-                       /* Redraw */
                        lite_spot(y, x);
 
                        break;
@@ -1072,12 +1064,8 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
                        {
                                c_ptr->info |= (CAVE_GLOW);
-
                                note_spot(y, x);
-
-                               /* Redraw */
                                lite_spot(y, x);
-
                                update_local_illumination(y, x);
 
                                /* Observe */
@@ -1085,7 +1073,7 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                                /* Mega-Hack -- Update the monster in the affected grid */
                                /* This allows "spear of light" (etc) to work "correctly" */
-                               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+                               if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
 
                                if (p_ptr->special_defense & NINJA_S_STEALTH)
                                {
@@ -1139,7 +1127,6 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                        note_spot(y, x);
                                }
 
-                               /* Redraw */
                                lite_spot(y, x);
 
                                update_local_illumination(y, x);
@@ -1148,7 +1135,7 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                                /* Mega-Hack -- Update the monster in the affected grid */
                                /* This allows "spear of light" (etc) to work "correctly" */
-                               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+                               if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
                        }
 
                        /* All done */
@@ -1289,7 +1276,6 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
        /* Scan all objects in the grid */
        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
-               /* Acquire object */
                object_type *o_ptr = &o_list[this_o_idx];
 
                bool is_art = FALSE;
@@ -1558,9 +1544,6 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                                k_idx = o_ptr->k_idx;
                                is_potion = object_is_potion(o_ptr);
-
-
-                               /* Delete the object */
                                delete_object_idx(this_o_idx);
 
                                /* Potions produce effects when 'shattered' */
@@ -1569,7 +1552,6 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                        (void)potion_smash_effect(who, y, x, k_idx);
                                }
 
-                               /* Redraw */
                                lite_spot(y, x);
                        }
                }
@@ -1712,12 +1694,12 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
        cptr note = NULL;
 
        /* Assume a default death */
-       cptr note_dies = extract_note_dies(real_r_ptr(m_ptr));
+       cptr note_dies = extract_note_dies(real_r_idx(m_ptr));
 
-       int ty = m_ptr->fy;
-       int tx = m_ptr->fx;
+       POSITION ty = m_ptr->fy;
+       POSITION tx = m_ptr->fx;
 
-       int caster_lev = (who > 0) ? r_info[caster_ptr->r_idx].level : (p_ptr->lev * 2);
+       DEPTH caster_lev = (who > 0) ? r_info[caster_ptr->r_idx].level : (p_ptr->lev * 2);
 
        /* Nobody here */
        if (!c_ptr->m_idx) return (FALSE);
@@ -1741,7 +1723,7 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
        /* Get the monster possessive ("his"/"her"/"its") */
        monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
 
-       if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) disturb(1, 1);
+       if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
 
        /* Analyze the damage type */
        switch (typ)
@@ -2804,7 +2786,7 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
                                break;
                        }
-                       if (!monster_living(r_ptr))
+                       if (!monster_living(m_ptr->r_idx))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
@@ -2833,7 +2815,7 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
                                break;
                        }
-                       if (!monster_living(r_ptr))
+                       if (!monster_living(m_ptr->r_idx))
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
@@ -3376,7 +3358,7 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                        /* Attempt a saving throw */
                        if (common_saving_throw_charm(p_ptr, dam, m_ptr) ||
-                               !monster_living(r_ptr))
+                               !monster_living(m_ptr->r_idx))
                        {
                                /* Resist */
                                /* No obvious effect */
@@ -3709,7 +3691,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                        if (!resists_tele)
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Prepare to teleport */
@@ -3733,7 +3714,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        /* Only affect undead */
                        if (r_ptr->flags3 & (RF3_UNDEAD))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Learn about type */
@@ -3776,7 +3756,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        /* Only affect evil */
                        if (r_ptr->flags3 & (RF3_EVIL))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Learn about type */
@@ -3816,7 +3795,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                skipped = TRUE;
                                break;
                        }
-                       /* Obvious */
                        if (seen) obvious = TRUE;
 
                        /* Apply some fear */
@@ -3851,7 +3829,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        /* Only affect undead */
                        if (r_ptr->flags3 & (RF3_UNDEAD))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Learn about type */
@@ -3887,7 +3864,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        /* Only affect evil */
                        if (r_ptr->flags3 & (RF3_EVIL))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Learn about type */
@@ -3922,7 +3898,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        /* Only affect good */
                        if (r_ptr->flags3 & (RF3_GOOD))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Learn about type */
@@ -3955,9 +3930,8 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                break;
                        }
                        /* Only affect non-undead */
-                       if (monster_living(r_ptr))
+                       if (monster_living(m_ptr->r_idx))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                note = _("は身震いした。", " shudders.");
@@ -3989,7 +3963,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        /* Only affect demons */
                        if (r_ptr->flags3 & (RF3_DEMON))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Learn about type */
@@ -4021,7 +3994,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                dam = 0;
                                break;
                        }
-                       /* Obvious */
                        if (seen) obvious = TRUE;
 
                        note = _("は身震いした。", " shudders.");
@@ -4332,7 +4304,7 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        }
 
                        if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp * 4L;
-                       else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(r_ptr))
+                       else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(m_ptr->r_idx))
                                nokori_hp = m_ptr->maxhp * 3 / 10;
                        else
                                nokori_hp = m_ptr->maxhp * 3 / 20;
@@ -4685,7 +4657,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        !(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
                        !(r_ptr->flags3 & RF3_NO_STUN))
                {
-                       /* Obvious */
                        if (seen) obvious = TRUE;
 
                        /* Get stunned */
@@ -4712,7 +4683,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                         !(r_ptr->flags3 & RF3_NO_CONF) &&
                         !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
                {
-                       /* Obvious */
                        if (seen) obvious = TRUE;
 
                        /* Already partially confused */
@@ -4738,7 +4708,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                if (do_time)
                {
-                       /* Obvious */
                        if (seen) obvious = TRUE;
 
                        if (do_time >= m_ptr->maxhp) do_time = m_ptr->maxhp - 1;
@@ -4757,7 +4726,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                {
                        if (polymorph_monster(y, x))
                        {
-                               /* Obvious */
                                if (seen) obvious = TRUE;
 
                                /* Monster polymorphs */
@@ -4782,7 +4750,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                /* Handle "teleport" */
                if (do_dist)
                {
-                       /* Obvious */
                        if (seen) obvious = TRUE;
 
                        note = _("が消え去った!", " disappears!");
@@ -5042,9 +5009,7 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
        }
 
        /* Verify this code */
-
-       /* Update the monster */
-       if (m_ptr->r_idx) update_mon(c_ptr->m_idx, FALSE);
+       if (m_ptr->r_idx) update_monster(c_ptr->m_idx, FALSE);
 
        /* Redraw the monster grid */
        lite_spot(y, x);
@@ -5082,8 +5047,6 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
        {
                object_type *q_ptr;
                object_type forge;
-
-               /* Get local object */
                q_ptr = &forge;
 
                /* Prepare to make a Blade of Chaos */
@@ -5211,7 +5174,7 @@ static bool project_p(MONSTER_IDX who, cptr who_name, int r, POSITION y, POSITIO
 
                project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP|PROJECT_KILL|PROJECT_REFLECTABLE), monspell);
 
-               disturb(1, 1);
+               disturb(TRUE, TRUE);
                return TRUE;
        }
 
@@ -6227,7 +6190,7 @@ static bool project_p(MONSTER_IDX who, cptr who_name, int r, POSITION y, POSITIO
        }
 
 
-       disturb(1, 1);
+       disturb(TRUE, TRUE);
 
 
        if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != p_ptr->riding))
@@ -6887,8 +6850,6 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
        /* Calculate the projection path */
 
        path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
-
-       /* Hack -- Handle stuff */
        handle_stuff();
 
        /* Giga-Hack SEEKER & SUPER_RAY */