OSDN Git Service

[Refactor] #39963 Made substitute_effect_monster() in effect_monster()
authorHourier <hourier@users.sourceforge.jp>
Wed, 29 Apr 2020 07:23:31 +0000 (16:23 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 29 Apr 2020 07:23:31 +0000 (16:23 +0900)
src/effect/effect-monster.c

index 86e7b3a..3116417 100644 (file)
@@ -52,8 +52,31 @@ typedef struct
        concptr note;
        concptr note_dies;
        DEPTH caster_lev;
+
+       MONSTER_IDX who;
+       POSITION r;
+       POSITION y;
+       POSITION x;
+       HIT_POINT dam;
+       EFFECT_ID effect_type;
+       BIT_FLAGS flag;
+       bool see_s_msg;
 } effect_monster;
 
+
+void substitute_effect_monster(effect_monster *effect_monster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag, bool see_s_msg)
+{
+       effect_monster_ptr->who = who;
+       effect_monster_ptr->r = r;
+       effect_monster_ptr->y = y;
+       effect_monster_ptr->x = x;
+       effect_monster_ptr->dam = dam;
+       effect_monster_ptr->effect_type = effect_type;
+       effect_monster_ptr->flag = flag;
+       effect_monster_ptr->see_s_msg = see_s_msg;
+}
+
+
 /*!
  * @brief effect_monster構造体を初期化する
  * @param caster_ptr プレーヤーへの参照ポインタ
@@ -100,23 +123,24 @@ void initialize_effect_monster(player_type *caster_ptr, effect_monster *effect_m
  * @param y 目標Y座標 / Target y location (or location to travel "towards")
  * @param x 目標X座標 / Target x location (or location to travel "towards")
  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
- * @param type 効果属性 / Type of damage to apply to monsters (and objects)
+ * @param effect_type 効果属性 / Type of damage to apply to monsters (and objects)
  * @param flag 効果フラグ
  * @param see_s_msg TRUEならばメッセージを表示する
  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
  */
-bool affect_monster(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID type, BIT_FLAGS flag, bool see_s_msg)
+bool affect_monster(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag, bool see_s_msg)
 {
        floor_type *floor_ptr = caster_ptr->current_floor_ptr;
        effect_monster tmp_effect;
        effect_monster *effect_monster_ptr = &tmp_effect;
+       substitute_effect_monster(effect_monster_ptr, who, r, y, x, dam, effect_type, flag, see_s_msg);
        initialize_effect_monster(caster_ptr, effect_monster_ptr, who, y, x);
 
        if (!effect_monster_ptr->g_ptr->m_idx) return FALSE;
 
        /* Never affect projector */
        if (who && (effect_monster_ptr->g_ptr->m_idx == who)) return FALSE;
-       if ((effect_monster_ptr->g_ptr->m_idx == caster_ptr->riding) && !who && !(type == GF_OLD_HEAL) && !(type == GF_OLD_SPEED) && !(type == GF_STAR_HEAL)) return FALSE;
+       if ((effect_monster_ptr->g_ptr->m_idx == caster_ptr->riding) && !who && !(effect_type == GF_OLD_HEAL) && !(effect_type == GF_OLD_SPEED) && !(effect_type == GF_STAR_HEAL)) return FALSE;
        if (sukekaku && ((effect_monster_ptr->m_ptr->r_idx == MON_SUKE) || (effect_monster_ptr->m_ptr->r_idx == MON_KAKU))) return FALSE;
 
        /* Don't affect already death monsters */
@@ -134,17 +158,17 @@ bool affect_monster(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITI
        if (caster_ptr->riding && (effect_monster_ptr->g_ptr->m_idx == caster_ptr->riding)) disturb(caster_ptr, TRUE, TRUE);
 
        if (effect_monster_ptr->r_ptr->flagsr & RFR_RES_ALL &&
-               type != GF_OLD_CLONE && type != GF_STAR_HEAL && type != GF_OLD_HEAL
-               && type != GF_OLD_SPEED && type != GF_CAPTURE && type != GF_PHOTO)
+               effect_type != GF_OLD_CLONE && effect_type != GF_STAR_HEAL && effect_type != GF_OLD_HEAL
+               && effect_type != GF_OLD_SPEED && effect_type != GF_CAPTURE && effect_type != GF_PHOTO)
        {
                effect_monster_ptr->note = _("には完全な耐性がある!", " is immune.");
                dam = 0;
                if (is_original_ap_and_seen(caster_ptr, effect_monster_ptr->m_ptr)) effect_monster_ptr->r_ptr->r_flagsr |= (RFR_RES_ALL);
-               if (type == GF_LITE_WEAK || type == GF_KILL_WALL) effect_monster_ptr->skipped = TRUE;
+               if (effect_type == GF_LITE_WEAK || effect_type == GF_KILL_WALL) effect_monster_ptr->skipped = TRUE;
        }
        else
        {
-               switch (type)
+               switch (effect_type)
                {
                case GF_MISSILE:
                {
@@ -1624,7 +1648,7 @@ bool affect_monster(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITI
                        {
                                if (effect_monster_ptr->seen) effect_monster_ptr->obvious = TRUE;
 
-                               /* Learn about type */
+                               /* Learn about effect_type */
                                if (is_original_ap_and_seen(caster_ptr, effect_monster_ptr->m_ptr)) effect_monster_ptr->r_ptr->r_flags3 |= (RF3_UNDEAD);
 
                                effect_monster_ptr->note = _("は身震いした。", " shudders.");
@@ -2187,7 +2211,7 @@ bool affect_monster(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITI
        }
 
        int tmp = dam;
-       dam = mon_damage_mod(caster_ptr, effect_monster_ptr->m_ptr, dam, (bool)(type == GF_PSY_SPEAR));
+       dam = mon_damage_mod(caster_ptr, effect_monster_ptr->m_ptr, dam, (bool)(effect_type == GF_PSY_SPEAR));
        if ((tmp > 0) && (dam == 0)) effect_monster_ptr->note = _("はダメージを受けていない。", " is unharmed.");
 
        if (dam > effect_monster_ptr->m_ptr->hp)
@@ -2291,7 +2315,7 @@ bool affect_monster(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITI
                }
        }
 
-       if (type == GF_DRAIN_MANA)
+       if (effect_type == GF_DRAIN_MANA)
        {
                /* Drain mana does nothing */
        }
@@ -2397,7 +2421,7 @@ bool affect_monster(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITI
                }
        }
 
-       if ((type == GF_BLOOD_CURSE) && one_in_(4))
+       if ((effect_type == GF_BLOOD_CURSE) && one_in_(4))
        {
                blood_curse_to_enemy(caster_ptr, who);
        }