OSDN Git Service

[Refactor] #38997 teleport_player() に player_type * 引数を追加. / Add player_type * argume...
[hengband/hengband.git] / src / realm-trump.c
index 35d4299..c41dcc0 100644 (file)
@@ -1,5 +1,15 @@
 #include "angband.h"
+#include "util.h"
+
 #include "cmd-spell.h"
+#include "mutation.h"
+#include "spells.h"
+#include "spells-summon.h"
+#include "spells-status.h"
+#include "spells-object.h"
+#include "player-effects.h"
+#include "player-class.h"
+#include "targeting.h"
 
 
 /*!
 * @param mode 処理内容 (SPELL_NAME / SPELL_DESC / SPELL_INFO / SPELL_CAST)
 * @return SPELL_NAME / SPELL_DESC / SPELL_INFO 時には文字列ポインタを返す。SPELL_CAST時はNULL文字列を返す。
 */
-cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
+concptr do_trump_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;
        bool fail = (mode == SPELL_FAIL) ? TRUE : FALSE;
-       static const char s_random[] = _("ランダム", "random");
 
        DIRECTION dir;
-       int plev = p_ptr->lev;
+       PLAYER_LEVEL plev = caster_ptr->lev;
 
        switch (spell)
        {
@@ -33,7 +42,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               teleport_player(range, 0L);
+                               teleport_player(caster_ptr, range, 0L);
                        }
                }
                break;
@@ -46,7 +55,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast || fail)
                        {
                                msg_print(_("あなたは蜘蛛のカードに集中する...", "You concentrate on the trump of an spider..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_SPIDER, PM_ALLOW_GROUP))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_SPIDER, PM_ALLOW_GROUP))
                                {
                                        if (fail)
                                        {
@@ -62,11 +71,11 @@ cptr do_trump_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)
                        {
-                               cast_shuffle();
+                               cast_shuffle(caster_ptr);
                        }
                }
                break;
@@ -94,7 +103,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (cast)
                        {
-                               teleport_player(range, 0L);
+                               teleport_player(caster_ptr, range, 0L);
                        }
                }
                break;
@@ -105,13 +114,13 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                {
                        int base = 25;
-                       int sides = 30;
+                       DICE_SID sides = 30;
 
                        if (info) return info_duration(base, sides);
 
                        if (cast)
                        {
-                               set_tim_esp(randint1(sides) + base, FALSE);
+                               set_tim_esp(caster_ptr, randint1(sides) + base, FALSE);
                        }
                }
                break;
@@ -143,7 +152,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                int type = (!fail ? SUMMON_ANIMAL_RANGER : SUMMON_ANIMAL);
                                msg_print(_("あなたは動物のカードに集中する...", "You concentrate on the trump of an animal..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, type, 0L))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, type, 0L))
                                {
                                        if (fail)
                                        {
@@ -159,7 +168,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("アイテムを自分の足元へ移動させる。", "Pulls a distant item close to you.");
 
                {
-                       int weight = plev * 15;
+                       WEIGHT weight = plev * 15;
 
                        if (info) return info_weight(weight);
 
@@ -167,7 +176,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                if (!get_aim_dir(&dir)) return NULL;
 
-                               fetch(dir, weight, FALSE);
+                               fetch(caster_ptr, dir, weight, FALSE);
                        }
                }
                break;
@@ -191,11 +200,11 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                else
                                {
                                        /* Summons near player when failed */
-                                       x = p_ptr->x;
-                                       y = p_ptr->y;
+                                       x = caster_ptr->x;
+                                       y = caster_ptr->y;
                                }
 
-                               if (p_ptr->pclass == CLASS_BEASTMASTER)
+                               if (caster_ptr->pclass == CLASS_BEASTMASTER)
                                        type = SUMMON_KAMIKAZE_LIVING;
                                else
                                        type = SUMMON_KAMIKAZE;
@@ -222,7 +231,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                int summon_lev = plev * 2 / 3 + randint1(plev / 2);
 
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, (summon_lev * 3 / 2), SUMMON_PHANTOM, 0L))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, (summon_lev * 3 / 2), SUMMON_PHANTOM, 0L))
                                {
                                        msg_print(_("御用でございますか、御主人様?", "'Your wish, master?'"));
                                }
@@ -263,7 +272,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast)
                        {
                                if (!get_check(_("本当に他の階にテレポートしますか?", "Are you sure? (Teleport Level)"))) return NULL;
-                               teleport_level(0);
+                               teleport_level(caster_ptr, 0);
                        }
                }
                break;
@@ -292,13 +301,13 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                {
                        int base = 15;
-                       int sides = 20;
+                       DICE_SID sides = 20;
 
                        if (info) return info_delay(base, sides);
 
                        if (cast)
                        {
-                               if (!word_of_recall()) return NULL;
+                               if (!recall_player(caster_ptr, randint0(21) + 15)) return NULL;
                        }
                }
                break;
@@ -351,7 +360,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast || fail)
                        {
                                msg_print(_("あなたはアンデッドのカードに集中する...", "You concentrate on the trump of an undead creature..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_UNDEAD, 0L))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_UNDEAD, 0L))
                                {
                                        if (fail)
                                        {
@@ -370,7 +379,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast || fail)
                        {
                                msg_print(_("あなたは爬虫類のカードに集中する...", "You concentrate on the trump of a reptile..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_HYDRA, 0L))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_HYDRA, 0L))
                                {
                                        if (fail)
                                        {
@@ -390,12 +399,12 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                int type;
                                msg_print(_("あなたはモンスターのカードに集中する...", "You concentrate on several trumps at once..."));
-                               if (p_ptr->pclass == CLASS_BEASTMASTER)
+                               if (caster_ptr->pclass == CLASS_BEASTMASTER)
                                        type = SUMMON_LIVING;
                                else
                                        type = 0;
 
-                               if (trump_summoning((1 + (plev - 15) / 10), !fail, p_ptr->y, p_ptr->x, 0, type, 0L))
+                               if (trump_summoning((1 + (plev - 15) / 10), !fail, caster_ptr->y, caster_ptr->x, 0, type, 0L))
                                {
                                        if (fail)
                                        {
@@ -415,7 +424,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast || fail)
                        {
                                msg_print(_("あなたはハウンドのカードに集中する...", "You concentrate on the trump of a hound..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_HOUND, PM_ALLOW_GROUP))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_HOUND, PM_ALLOW_GROUP))
                                {
                                        if (fail)
                                        {
@@ -433,7 +442,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        if (cast)
                        {
-                               brand_weapon(5);
+                               brand_weapon(caster_ptr, 5);
                        }
                }
                break;
@@ -442,26 +451,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (name) return _("人間トランプ", "Living Trump");
                if (desc) return _("ランダムにテレポートする突然変異か、自分の意思でテレポートする突然変異が身につく。",
                        "Gives mutation which makes you teleport randomly or makes you able to teleport at will.");
-
-               {
-                       if (cast)
-                       {
-                               int mutation;
-
-                               if (one_in_(7))
-                                       /* Teleport control */
-                                       mutation = 12;
-                               else
-                                       /* Random teleportation (uncontrolled) */
-                                       mutation = 77;
-
-                               /* Gain the mutation */
-                               if (gain_random_mutation(mutation))
-                               {
-                                       msg_print(_("あなたは生きているカードに変わった。", "You have turned into a Living Trump."));
-                               }
-                       }
-               }
+               if (cast) become_living_trump(caster_ptr);
                break;
 
        case 23:
@@ -472,7 +462,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast || fail)
                        {
                                msg_print(_("あなたはサイバーデーモンのカードに集中する...", "You concentrate on the trump of a Cyberdemon..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_CYBER, 0L))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_CYBER, 0L))
                                {
                                        if (fail)
                                        {
@@ -549,7 +539,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast || fail)
                        {
                                msg_print(_("あなたはドラゴンのカードに集中する...", "You concentrate on the trump of a dragon..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_DRAGON, 0L))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_DRAGON, 0L))
                                {
                                        if (fail)
                                        {
@@ -585,7 +575,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        if (cast || fail)
                        {
                                msg_print(_("あなたはデーモンのカードに集中する...", "You concentrate on the trump of a demon..."));
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_DEMON, 0L))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_DEMON, 0L))
                                {
                                        if (fail)
                                        {
@@ -605,7 +595,7 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                msg_print(_("あなたは強力なアンデッドのカードに集中する...", "You concentrate on the trump of a greater undead being..."));
                                /* May allow unique depend on level and dice roll */
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, SUMMON_HI_UNDEAD, PM_ALLOW_UNIQUE))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_HI_UNDEAD, PM_ALLOW_UNIQUE))
                                {
                                        if (fail)
                                        {
@@ -625,14 +615,14 @@ cptr do_trump_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        {
                                int type;
 
-                               if (p_ptr->pclass == CLASS_BEASTMASTER)
+                               if (caster_ptr->pclass == CLASS_BEASTMASTER)
                                        type = SUMMON_HI_DRAGON_LIVING;
                                else
                                        type = SUMMON_HI_DRAGON;
 
                                msg_print(_("あなたは古代ドラゴンのカードに集中する...", "You concentrate on the trump of an ancient dragon..."));
                                /* May allow unique depend on level and dice roll */
-                               if (trump_summoning(1, !fail, p_ptr->y, p_ptr->x, 0, type, PM_ALLOW_UNIQUE))
+                               if (trump_summoning(1, !fail, caster_ptr->y, caster_ptr->x, 0, type, PM_ALLOW_UNIQUE))
                                {
                                        if (fail)
                                        {