OSDN Git Service

[Refactor] #39963 Separated effect_monster_psi_drain() from switch_effects_monster()
authorHourier <hourier@users.sourceforge.jp>
Fri, 1 May 2020 03:35:41 +0000 (12:35 +0900)
committerHourier <hourier@users.sourceforge.jp>
Fri, 1 May 2020 03:35:41 +0000 (12:35 +0900)
src/effect/effect-monster-switcher.c

index 5f483c1..1a586b9 100644 (file)
@@ -160,6 +160,75 @@ gf_switch_result effect_monster_psi(player_type *caster_ptr, effect_monster_type
        return GF_SWITCH_CONTINUE;
 }
 
+
+gf_switch_result effect_monster_psi_drain(player_type *caster_ptr, effect_monster_type *em_ptr)
+{
+       if (em_ptr->seen) em_ptr->obvious = TRUE;
+
+       if (em_ptr->r_ptr->flags2 & RF2_EMPTY_MIND)
+       {
+               em_ptr->dam = 0;
+               em_ptr->note = _("には完全な耐性がある!", " is immune.");
+       }
+       else if ((em_ptr->r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
+               (em_ptr->r_ptr->flags3 & RF3_ANIMAL) ||
+               (em_ptr->r_ptr->level > randint1(3 * em_ptr->dam)))
+       {
+               em_ptr->note = _("には耐性がある!", " resists!");
+               em_ptr->dam /= 3;
+
+               /*
+                * Powerful demons & undead can turn a mindcrafter's
+                * attacks back on them
+                */
+               if ((em_ptr->r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
+                       (em_ptr->r_ptr->level > caster_ptr->lev / 2) &&
+                       (one_in_(2)))
+               {
+                       em_ptr->note = NULL;
+                       msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!",
+                               (em_ptr->seen ? "%^s's corrupted mind backlashes your attack!" :
+                                       "%^ss corrupted mind backlashes your attack!")), em_ptr->m_name);
+                       if ((randint0(100 + em_ptr->r_ptr->level / 2) < caster_ptr->skill_sav) && !CHECK_MULTISHADOW(caster_ptr))
+                       {
+                               msg_print(_("あなたは効力を跳ね返した!", "You resist the effects!"));
+                       }
+                       else
+                       {
+                               monster_desc(caster_ptr, em_ptr->killer, em_ptr->m_ptr, MD_WRONGDOER_NAME);
+                               if (!CHECK_MULTISHADOW(caster_ptr))
+                               {
+                                       msg_print(_("超能力パワーを吸いとられた!", "Your psychic energy is drained!"));
+                                       caster_ptr->csp -= damroll(5, em_ptr->dam) / 2;
+                                       if (caster_ptr->csp < 0) caster_ptr->csp = 0;
+                                       caster_ptr->redraw |= PR_MANA;
+                                       caster_ptr->window |= (PW_SPELL);
+                               }
+                               take_hit(caster_ptr, DAMAGE_ATTACK, em_ptr->dam, em_ptr->killer, -1);  /* has already been /3 */
+                       }
+
+                       em_ptr->dam = 0;
+               }
+       }
+       else if (em_ptr->dam > 0)
+       {
+               int b = damroll(5, em_ptr->dam) / 4;
+               concptr str = (caster_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
+               concptr msg = _("あなたは%sの苦痛を%sに変換した!",
+                       (em_ptr->seen ? "You convert %s's pain into %s!" :
+                               "You convert %ss pain into %s!"));
+               msg_format(msg, em_ptr->m_name, str);
+
+               b = MIN(caster_ptr->msp, caster_ptr->csp + b);
+               caster_ptr->csp = b;
+               caster_ptr->redraw |= PR_MANA;
+               caster_ptr->window |= (PW_SPELL);
+       }
+
+       em_ptr->note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
+}
+
+
 /*!
  * @brief 魔法の効果によって様々なメッセーを出力したり与えるダメージの増減を行ったりする
  * @param em_ptr モンスター効果構造体への参照ポインタ
@@ -228,71 +297,7 @@ gf_switch_result switch_effects_monster(player_type *caster_ptr, effect_monster_
        case GF_PSI:
                return effect_monster_psi(caster_ptr, em_ptr);
        case GF_PSI_DRAIN:
-       {
-               if (em_ptr->seen) em_ptr->obvious = TRUE;
-               if (em_ptr->r_ptr->flags2 & RF2_EMPTY_MIND)
-               {
-                       em_ptr->dam = 0;
-                       em_ptr->note = _("には完全な耐性がある!", " is immune.");
-               }
-               else if ((em_ptr->r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
-                       (em_ptr->r_ptr->flags3 & RF3_ANIMAL) ||
-                       (em_ptr->r_ptr->level > randint1(3 * em_ptr->dam)))
-               {
-                       em_ptr->note = _("には耐性がある!", " resists!");
-                       em_ptr->dam /= 3;
-
-                       /*
-                        * Powerful demons & undead can turn a mindcrafter's
-                        * attacks back on them
-                        */
-                       if ((em_ptr->r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
-                               (em_ptr->r_ptr->level > caster_ptr->lev / 2) &&
-                               (one_in_(2)))
-                       {
-                               em_ptr->note = NULL;
-                               msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!",
-                                       (em_ptr->seen ? "%^s's corrupted mind backlashes your attack!" :
-                                               "%^ss corrupted mind backlashes your attack!")), em_ptr->m_name);
-                               if ((randint0(100 + em_ptr->r_ptr->level / 2) < caster_ptr->skill_sav) && !CHECK_MULTISHADOW(caster_ptr))
-                               {
-                                       msg_print(_("あなたは効力を跳ね返した!", "You resist the effects!"));
-                               }
-                               else
-                               {
-                                       monster_desc(caster_ptr, em_ptr->killer, em_ptr->m_ptr, MD_WRONGDOER_NAME);
-                                       if (!CHECK_MULTISHADOW(caster_ptr))
-                                       {
-                                               msg_print(_("超能力パワーを吸いとられた!", "Your psychic energy is drained!"));
-                                               caster_ptr->csp -= damroll(5, em_ptr->dam) / 2;
-                                               if (caster_ptr->csp < 0) caster_ptr->csp = 0;
-                                               caster_ptr->redraw |= PR_MANA;
-                                               caster_ptr->window |= (PW_SPELL);
-                                       }
-                                       take_hit(caster_ptr, DAMAGE_ATTACK, em_ptr->dam, em_ptr->killer, -1);  /* has already been /3 */
-                               }
-
-                               em_ptr->dam = 0;
-                       }
-               }
-               else if (em_ptr->dam > 0)
-               {
-                       int b = damroll(5, em_ptr->dam) / 4;
-                       concptr str = (caster_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
-                       concptr msg = _("あなたは%sの苦痛を%sに変換した!",
-                               (em_ptr->seen ? "You convert %s's pain into %s!" :
-                                       "You convert %ss pain into %s!"));
-                       msg_format(msg, em_ptr->m_name, str);
-
-                       b = MIN(caster_ptr->msp, caster_ptr->csp + b);
-                       caster_ptr->csp = b;
-                       caster_ptr->redraw |= PR_MANA;
-                       caster_ptr->window |= (PW_SPELL);
-               }
-
-               em_ptr->note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
-               break;
-       }
+               return effect_monster_psi_drain(caster_ptr, em_ptr);
        case GF_TELEKINESIS:
        {
                if (em_ptr->seen) em_ptr->obvious = TRUE;