OSDN Git Service

[Refactor] #38997 confuse_monsters()、charm_monsters()、charm_animals()、stun_monsters...
[hengband/hengband.git] / src / realm-death.c
index 1bdddb1..0a14fc1 100644 (file)
@@ -3,20 +3,24 @@
 #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文字列を返す。
 */
-concptr 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;
@@ -24,7 +28,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
        bool cast = (mode == SPELL_CAST) ? TRUE : FALSE;
 
        DIRECTION dir;
-       PLAYER_LEVEL plev = p_ptr->lev;
+       PLAYER_LEVEL plev = caster_ptr->lev;
 
        switch (spell)
        {
@@ -39,7 +43,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               detect_monsters_nonliving(rad);
+                               detect_monsters_nonliving(caster_ptr, rad);
                        }
                }
                break;
@@ -68,7 +72,7 @@ concptr 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))
                                {
@@ -76,13 +80,13 @@ concptr 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);
                                }
                        }
                }
@@ -99,7 +103,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               detect_monsters_evil(rad);
+                               detect_monsters_evil(caster_ptr, rad);
                        }
                }
                break;
@@ -118,7 +122,7 @@ concptr 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;
@@ -153,7 +157,7 @@ concptr 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;
@@ -190,7 +194,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               control_one_undead(dir, plev);
+                               control_one_undead(caster_ptr, dir, plev);
                        }
                }
                break;
@@ -205,7 +209,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        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;
@@ -217,7 +221,7 @@ concptr 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;
@@ -236,7 +240,7 @@ concptr 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;
@@ -253,7 +257,7 @@ concptr 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;
@@ -271,7 +275,7 @@ concptr 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;
@@ -283,7 +287,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               brand_weapon(3);
+                               brand_weapon(caster_ptr, 3);
                        }
                }
                break;
@@ -306,12 +310,12 @@ concptr 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:
@@ -324,11 +328,11 @@ concptr 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);
                                }
                        }
                }
@@ -341,7 +345,7 @@ concptr 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;
@@ -358,7 +362,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               symbol_genocide(power, TRUE);
+                               symbol_genocide(caster_ptr, power, TRUE);
                        }
                }
                break;
@@ -374,7 +378,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               (void)berserk(base + randint1(base));
+                               (void)berserk(caster_ptr, base + randint1(base));
                        }
                }
                break;
@@ -390,7 +394,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               cast_invoke_spirits(dir);
+                               cast_invoke_spirits(caster_ptr, dir);
                        }
                }
                break;
@@ -409,7 +413,7 @@ concptr 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;
@@ -428,8 +432,8 @@ concptr 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;
@@ -441,7 +445,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               brand_weapon(4);
+                               brand_weapon(caster_ptr, 4);
                        }
                }
                break;
@@ -461,13 +465,13 @@ concptr 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);
                                }
                        }
                }
@@ -484,7 +488,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               dispel_living(randint1(sides));
+                               dispel_living(caster_ptr, randint1(sides));
                        }
                }
                break;
@@ -503,7 +507,7 @@ concptr 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;
@@ -517,7 +521,7 @@ concptr 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;
@@ -525,7 +529,7 @@ concptr 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) cast_summon_undead(p_ptr, (plev * 3) / 2);
+               if (cast) cast_summon_undead(caster_ptr, (plev * 3) / 2);
                break;
 
        case 26:
@@ -538,7 +542,7 @@ concptr 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
                                {
@@ -560,7 +564,7 @@ concptr 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;
@@ -572,7 +576,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               restore_level();
+                               restore_level(caster_ptr);
                        }
                }
                break;
@@ -589,7 +593,7 @@ concptr do_death_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               mass_genocide(power, TRUE);
+                               mass_genocide(caster_ptr, power, TRUE);
                        }
                }
                break;
@@ -609,8 +613,8 @@ concptr 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;
@@ -627,7 +631,7 @@ concptr 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;