OSDN Git Service

[Refactor] #38997 confuse_monsters()、charm_monsters()、charm_animals()、stun_monsters...
[hengband/hengband.git] / src / realm-death.c
index 8a6a908..0a14fc1 100644 (file)
@@ -1,26 +1,34 @@
 #include "angband.h"
 #include "cmd-spell.h"
-
-
+#include "spells.h"
+#include "spells-summon.h"
+#include "spells-status.h"
+#include "spells-object.h"
+#include "spells-diceroll.h"
+#include "avatar.h"
+#include "player-status.h"
+#include "player-effects.h"
+#include "targeting.h"
+#include "player-class.h"
+#include "player-damage.h"
+#include "player-race.h"
 
 /*!
 * @brief 暗黒領域魔法の各処理を行う
+* @param caster_ptr プレーヤーへの参照ポインタ
 * @param spell 魔法ID
 * @param mode 処理内容 (SPELL_NAME / SPELL_DESC / SPELL_INFO / SPELL_CAST)
 * @return SPELL_NAME / SPELL_DESC / SPELL_INFO 時には文字列ポインタを返す。SPELL_CAST時はNULL文字列を返す。
 */
-cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
+concptr do_death_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode)
 {
        bool name = (mode == SPELL_NAME) ? TRUE : FALSE;
        bool desc = (mode == SPELL_DESC) ? TRUE : FALSE;
        bool info = (mode == SPELL_INFO) ? TRUE : FALSE;
        bool cast = (mode == SPELL_CAST) ? TRUE : FALSE;
 
-       static const char s_dam[] = _("損傷:", "dam ");
-       static const char s_random[] = _("ランダム", "random");
-
        DIRECTION dir;
-       int plev = p_ptr->lev;
+       PLAYER_LEVEL plev = caster_ptr->lev;
 
        switch (spell)
        {
@@ -35,7 +43,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               detect_monsters_nonliving(rad);
+                               detect_monsters_nonliving(caster_ptr, rad);
                        }
                }
                break;
@@ -46,8 +54,8 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        "Fires a tiny ball of evil power which hurts good monsters greatly.");
 
                {
-                       int dice = 3 + (plev - 1) / 5;
-                       int sides = 4;
+                       DICE_NUMBER dice = 3 + (plev - 1) / 5;
+                       DICE_SID sides = 4;
                        POSITION rad = 0;
 
                        if (info) return info_damage(dice, sides, 0);
@@ -64,7 +72,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                * travel to the monster.
                                */
 
-                               fire_ball(GF_HELL_FIRE, dir, damroll(dice, sides), rad);
+                               fire_ball(caster_ptr, GF_HELL_FIRE, dir, damroll(dice, sides), rad);
 
                                if (one_in_(5))
                                {
@@ -72,13 +80,13 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                        int effect = randint1(1000);
 
                                        if (effect == 666)
-                                               fire_ball_hide(GF_DEATH_RAY, dir, plev * 200, 0);
+                                               fire_ball_hide(caster_ptr, GF_DEATH_RAY, dir, plev * 200, 0);
                                        else if (effect < 500)
-                                               fire_ball_hide(GF_TURN_ALL, dir, plev, 0);
+                                               fire_ball_hide(caster_ptr, GF_TURN_ALL, dir, plev, 0);
                                        else if (effect < 800)
-                                               fire_ball_hide(GF_OLD_CONF, dir, plev, 0);
+                                               fire_ball_hide(caster_ptr, GF_OLD_CONF, dir, plev, 0);
                                        else
-                                               fire_ball_hide(GF_STUN, dir, plev, 0);
+                                               fire_ball_hide(caster_ptr, GF_STUN, dir, plev, 0);
                                }
                        }
                }
@@ -95,7 +103,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               detect_monsters_evil(rad);
+                               detect_monsters_evil(caster_ptr, rad);
                        }
                }
                break;
@@ -114,7 +122,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fire_ball(GF_POIS, dir, dam, rad);
+                               fire_ball(caster_ptr, GF_POIS, dir, dam, rad);
                        }
                }
                break;
@@ -149,7 +157,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               set_oppose_pois(randint1(base) + base, FALSE);
+                               set_oppose_pois(caster_ptr, randint1(base) + base, FALSE);
                        }
                }
                break;
@@ -167,8 +175,8 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fear_monster(dir, power);
-                               stun_monster(dir, power);
+                               fear_monster(dir, plev);
+                               stun_monster(dir, plev);
                        }
                }
                break;
@@ -186,7 +194,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               control_one_undead(dir, power);
+                               control_one_undead(caster_ptr, dir, plev);
                        }
                }
                break;
@@ -196,12 +204,12 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("生命のある者のHPと最大HP双方にダメージを与える効果のある球を放つ。", "Fires a ball which damages to both HP and MaxHP of living monsters.");
 
                {
-                       int dice = 3;
-                       int sides = 6;
+                       DICE_NUMBER dice = 3;
+                       DICE_SID sides = 6;
                        POSITION rad = (plev < 30) ? 2 : 3;
                        int base;
 
-                       if (IS_WIZARD_CLASS())
+                       if (IS_WIZARD_CLASS(caster_ptr))
                                base = plev + plev / 2;
                        else
                                base = plev + plev / 4;
@@ -213,7 +221,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fire_ball(GF_HYPODYNAMIA, dir, damroll(dice, sides) + base, rad);
+                               fire_ball(caster_ptr, GF_HYPODYNAMIA, dir, damroll(dice, sides) + base, rad);
                        }
                }
                break;
@@ -223,8 +231,8 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("地獄のボルトもしくはビームを放つ。", "Fires a bolt or beam of nether.");
 
                {
-                       int dice = 8 + (plev - 5) / 4;
-                       int sides = 8;
+                       DICE_NUMBER dice = 8 + (plev - 5) / 4;
+                       DICE_SID sides = 8;
 
                        if (info) return info_damage(dice, sides, 0);
 
@@ -232,7 +240,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fire_bolt_or_beam(beam_chance(), GF_NETHER, dir, damroll(dice, sides));
+                               fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_NETHER, dir, damroll(dice, sides));
                        }
                }
                break;
@@ -249,7 +257,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               project(0, rad, p_ptr->y, p_ptr->x, dam, GF_POIS, PROJECT_KILL | PROJECT_ITEM, -1);
+                               project(caster_ptr, 0, rad, caster_ptr->y, caster_ptr->x, dam, GF_POIS, PROJECT_KILL | PROJECT_ITEM, -1);
                        }
                }
                break;
@@ -267,7 +275,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fire_ball_hide(GF_GENOCIDE, dir, power, 0);
+                               fire_ball_hide(caster_ptr, GF_GENOCIDE, dir, power, 0);
                        }
                }
                break;
@@ -279,7 +287,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               brand_weapon(3);
+                               brand_weapon(caster_ptr, 3);
                        }
                }
                break;
@@ -290,8 +298,8 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        "Absorbs some HP from a monster and gives them to you by bolt. You will also gain nutritional sustenance from this.");
 
                {
-                       int dice = 1;
-                       int sides = plev * 2;
+                       DICE_NUMBER dice = 1;
+                       DICE_SID sides = plev * 2;
                        int base = plev * 2;
 
                        if (info) return info_damage(dice, sides, base);
@@ -302,12 +310,12 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               if (hypodynamic_bolt(dir, dam))
+                               if (hypodynamic_bolt(caster_ptr, dir, dam))
                                {
-                                       chg_virtue(V_SACRIFICE, -1);
-                                       chg_virtue(V_VITALITY, -1);
+                                       chg_virtue(caster_ptr, V_SACRIFICE, -1);
+                                       chg_virtue(caster_ptr, V_VITALITY, -1);
 
-                                       hp_player(dam);
+                                       hp_player(caster_ptr, dam);
 
                                        /*
                                        * Gain nutritional sustenance:
@@ -320,11 +328,11 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                        * ARE Gorged, it won't cure
                                        * us
                                        */
-                                       dam = p_ptr->food + MIN(5000, 100 * dam);
+                                       dam = caster_ptr->food + MIN(5000, 100 * dam);
 
                                        /* Not gorged already */
-                                       if (p_ptr->food < PY_FOOD_MAX)
-                                               set_food(dam >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dam);
+                                       if (caster_ptr->food < PY_FOOD_MAX)
+                                               set_food(caster_ptr, dam >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dam);
                                }
                        }
                }
@@ -337,7 +345,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               animate_dead(0, p_ptr->y, p_ptr->x);
+                               animate_dead(caster_ptr, 0, caster_ptr->y, caster_ptr->x);
                        }
                }
                break;
@@ -354,7 +362,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               symbol_genocide(power, TRUE);
+                               symbol_genocide(caster_ptr, power, TRUE);
                        }
                }
                break;
@@ -370,7 +378,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               (void)berserk(base + randint1(base));
+                               (void)berserk(caster_ptr, base + randint1(base));
                        }
                }
                break;
@@ -380,13 +388,13 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("ランダムで様々な効果が起こる。", "Causes random effects.");
 
                {
-                       if (info) return s_random;
+                       if (info) return KWD_RANDOM;
 
                        if (cast)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               cast_invoke_spirits(dir);
+                               cast_invoke_spirits(caster_ptr, dir);
                        }
                }
                break;
@@ -396,8 +404,8 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("暗黒のボルトもしくはビームを放つ。", "Fires a bolt or beam of darkness.");
 
                {
-                       int dice = 4 + (plev - 5) / 4;
-                       int sides = 8;
+                       DICE_NUMBER dice = 4 + (plev - 5) / 4;
+                       DICE_SID sides = 8;
 
                        if (info) return info_damage(dice, sides, 0);
 
@@ -405,7 +413,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fire_bolt_or_beam(beam_chance(), GF_DARK, dir, damroll(dice, sides));
+                               fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_DARK, dir, damroll(dice, sides));
                        }
                }
                break;
@@ -424,8 +432,8 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               (void)berserk(b_base + randint1(b_base));
-                               set_fast(randint1(sp_sides) + sp_base, FALSE);
+                               (void)berserk(caster_ptr, b_base + randint1(b_base));
+                               set_fast(caster_ptr, randint1(sp_sides) + sp_base, FALSE);
                        }
                }
                break;
@@ -437,7 +445,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               brand_weapon(4);
+                               brand_weapon(caster_ptr, 4);
                        }
                }
                break;
@@ -449,7 +457,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        HIT_POINT dam = 100;
 
-                       if (info) return format("%s3*%d", s_dam, dam);
+                       if (info) return format("%s3*%d", KWD_DAM, dam);
 
                        if (cast)
                        {
@@ -457,13 +465,13 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               chg_virtue(V_SACRIFICE, -1);
-                               chg_virtue(V_VITALITY, -1);
+                               chg_virtue(caster_ptr, V_SACRIFICE, -1);
+                               chg_virtue(caster_ptr, V_VITALITY, -1);
 
                                for (i = 0; i < 3; i++)
                                {
-                                       if (hypodynamic_bolt(dir, dam))
-                                               hp_player(dam);
+                                       if (hypodynamic_bolt(caster_ptr, dir, dam))
+                                               hp_player(caster_ptr, dam);
                                }
                        }
                }
@@ -474,13 +482,13 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("視界内の生命のあるモンスターにダメージを与える。", "Damages all living monsters in sight.");
 
                {
-                       int sides = plev * 3;
+                       DICE_SID sides = plev * 3;
 
                        if (info) return info_damage(1, sides, 0);
 
                        if (cast)
                        {
-                               dispel_living(randint1(sides));
+                               dispel_living(caster_ptr, randint1(sides));
                        }
                }
                break;
@@ -499,7 +507,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fire_ball(GF_DARK, dir, dam, rad);
+                               fire_ball(caster_ptr, GF_DARK, dir, dam, rad);
                        }
                }
                break;
@@ -513,7 +521,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               death_ray(dir, plev);
+                               death_ray(caster_ptr, dir, plev);
                        }
                }
                break;
@@ -521,43 +529,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
        case 25:
                if (name) return _("死者召喚", "Raise the Dead");
                if (desc) return _("1体のアンデッドを召喚する。", "Summons an undead monster.");
-
-               {
-                       if (cast)
-                       {
-                               int type;
-                               bool pet = one_in_(3);
-                               u32b flg = 0L;
-
-                               type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
-
-                               if (!pet || (pet && (plev > 24) && one_in_(3)))
-                                       flg |= PM_ALLOW_GROUP;
-
-                               if (pet) flg |= PM_FORCE_PET;
-                               else flg |= (PM_ALLOW_UNIQUE | PM_NO_PET);
-
-                               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (plev * 3) / 2, type, flg))
-                               {
-                                       msg_print(_("冷たい風があなたの周りに吹き始めた。それは腐敗臭を運んでいる...",
-                                               "Cold winds begin to blow around you, carrying with them the stench of decay..."));
-
-
-                                       if (pet)
-                                       {
-                                               msg_print(_("古えの死せる者共があなたに仕えるため土から甦った!",
-                                                       "Ancient, long-dead forms arise from the ground to serve you!"));
-                                       }
-                                       else
-                                       {
-                                               msg_print(_("死者が甦った。眠りを妨げるあなたを罰するために!",
-                                                       "'The dead arise... to punish you for disturbing them!'"));
-                                       }
-
-                                       chg_virtue(V_UNLIFE, 1);
-                               }
-                       }
-               }
+               if (cast) cast_summon_undead(caster_ptr, (plev * 3) / 2);
                break;
 
        case 26:
@@ -570,7 +542,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (randint1(50) > plev)
                                {
-                                       if (!ident_spell(FALSE)) return NULL;
+                                       if (!ident_spell(caster_ptr, FALSE)) return NULL;
                                }
                                else
                                {
@@ -592,7 +564,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               set_mimic(base + randint1(base), MIMIC_VAMPIRE, FALSE);
+                               set_mimic(caster_ptr, base + randint1(base), MIMIC_VAMPIRE, FALSE);
                        }
                }
                break;
@@ -604,7 +576,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               restore_level();
+                               restore_level(caster_ptr);
                        }
                }
                break;
@@ -621,7 +593,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               mass_genocide(power, TRUE);
+                               mass_genocide(caster_ptr, power, TRUE);
                        }
                }
                break;
@@ -641,8 +613,8 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fire_ball(GF_HELL_FIRE, dir, dam, rad);
-                               take_hit(DAMAGE_USELIFE, 20 + randint1(30), _("地獄の劫火の呪文を唱えた疲労", "the strain of casting Hellfire"), -1);
+                               fire_ball(caster_ptr, GF_HELL_FIRE, dir, dam, rad);
+                               take_hit(caster_ptr, DAMAGE_USELIFE, 20 + randint1(30), _("地獄の劫火の呪文を唱えた疲労", "the strain of casting Hellfire"), -1);
                        }
                }
                break;
@@ -659,7 +631,7 @@ cptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               set_wraith_form(randint1(base) + base, FALSE);
+                               set_wraith_form(caster_ptr, randint1(base) + base, FALSE);
                        }
                }
                break;