OSDN Git Service

[Refactor] #39068 エンバグを修正しつつ,add_essence() の item_tester_tval グローバル参照をローカル引数に収める.
[hengband/hengband.git] / src / spells-summon.c
index d7217d3..d6d4b20 100644 (file)
@@ -1,5 +1,10 @@
 #include "angband.h"
+#include "util.h"
+
+#include "spells.h"
 #include "spells-summon.h"
+#include "monster-status.h"
+#include "floor.h"
 
 /*!
 * @brief トランプ魔法独自の召喚処理を行う / Handle summoning and failure of trump spells
@@ -50,7 +55,7 @@ bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int t
 
        for (i = 0; i < num; i++)
        {
-               if (summon_specific(who, y, x, lev, type, mode, '\0'))
+               if (summon_specific(who, y, x, lev, type, mode))
                        success = TRUE;
        }
 
@@ -72,7 +77,7 @@ bool cast_summon_demon(int power)
        else flg |= PM_NO_PET;
        if (!(pet && (p_ptr->lev < 50))) flg |= PM_ALLOW_GROUP;
 
-       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, power, SUMMON_DEMON, flg, '\0'))
+       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, power, SUMMON_DEMON, flg))
        {
                msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));
                if (pet)
@@ -100,7 +105,7 @@ bool cast_summon_undead(player_type *creature_ptr, int power)
        if (pet) mode |= PM_FORCE_PET;
        else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
 
-       if (summon_specific((pet ? -1 : 0), creature_ptr->y, creature_ptr->x, power, type, mode, '\0'))
+       if (summon_specific((pet ? -1 : 0), creature_ptr->y, creature_ptr->x, power, type, mode))
        {
                msg_print(_("冷たい風があなたの周りに吹き始めた。それは腐敗臭を運んでいる...",
                        "Cold winds begin to blow around you, carrying with them the stench of decay..."));
@@ -114,6 +119,46 @@ bool cast_summon_undead(player_type *creature_ptr, int power)
        return TRUE;
 }
 
+
+bool cast_summon_hound(player_type *creature_ptr, int power)
+{
+       BIT_FLAGS mode = PM_ALLOW_GROUP;
+       bool pet = !one_in_(5);
+       if (pet) mode |= PM_FORCE_PET;
+       else mode |= PM_NO_PET;
+
+       if (summon_specific((pet ? -1 : 0), creature_ptr->y, creature_ptr->x, power, SUMMON_HOUND, mode))
+       {
+               if (pet)
+                       msg_print(_("ハウンドがあなたの下僕として出現した。", "A group of hounds appear as your servant."));
+               else
+                       msg_print(_("ハウンドはあなたに牙を向けている!", "A group of hounds appear as your enemy!"));
+       }
+       return TRUE;
+}
+
+bool cast_summon_elemental(player_type *creature_ptr, int power)
+{
+       bool pet = one_in_(3);
+       BIT_FLAGS mode = 0L;
+
+       if (!(pet && (creature_ptr->lev < 50))) mode |= PM_ALLOW_GROUP;
+       if (pet) mode |= PM_FORCE_PET;
+       else mode |= PM_NO_PET;
+
+       if (summon_specific((pet ? -1 : 0), creature_ptr->y, creature_ptr->x, power, SUMMON_ELEMENTAL, mode))
+       {
+               msg_print(_("エレメンタルが現れた...", "An elemental materializes..."));
+               if (pet)
+                       msg_print(_("あなたに服従しているようだ。", "It seems obedient to you."));
+               else
+                       msg_print(_("それをコントロールできなかった!", "You fail to control it!"));
+       }
+
+       return TRUE;
+}
+
+
 bool cast_summon_octopus(player_type *creature_ptr)
 {
        BIT_FLAGS mode = PM_ALLOW_GROUP;
@@ -163,12 +208,12 @@ bool cast_summon_greater_demon(void)
        item_tester_hook = item_tester_offer;
        q = _("どの死体を捧げますか? ", "Sacrifice which corpse? ");
        s = _("捧げられる死体を持っていない。", "You have nothing to scrifice.");
-       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), 0);
        if (!o_ptr) return FALSE;
 
        summon_lev = plev * 2 / 3 + r_info[o_ptr->pval].level;
 
-       if (summon_specific(-1, p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET), '\0'))
+       if (summon_specific(-1, p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET)))
        {
                msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));
                msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'"));
@@ -208,110 +253,8 @@ bool cast_summon_greater_demon(void)
 bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
 {
        bool pet = (bool)(mode & PM_FORCE_PET);
-       SYMBOL_CODE symbol = '\0';
        if (!pet) mode |= PM_NO_PET;
-
-       switch (p_ptr->mimic_form)
-       {
-       case MIMIC_NONE:
-               switch (p_ptr->prace)
-               {
-               case RACE_HUMAN:
-               case RACE_AMBERITE:
-               case RACE_BARBARIAN:
-               case RACE_BEASTMAN:
-               case RACE_DUNADAN:
-                       symbol = 'p';
-                       break;
-               case RACE_HALF_ELF:
-               case RACE_ELF:
-               case RACE_HOBBIT:
-               case RACE_GNOME:
-               case RACE_DWARF:
-               case RACE_HIGH_ELF:
-               case RACE_NIBELUNG:
-               case RACE_DARK_ELF:
-               case RACE_MIND_FLAYER:
-               case RACE_KUTAR:
-               case RACE_S_FAIRY:
-                       symbol = 'h';
-                       break;
-               case RACE_HALF_ORC:
-                       symbol = 'o';
-                       break;
-               case RACE_HALF_TROLL:
-                       symbol = 'T';
-                       break;
-               case RACE_HALF_OGRE:
-                       symbol = 'O';
-                       break;
-               case RACE_HALF_GIANT:
-               case RACE_HALF_TITAN:
-               case RACE_CYCLOPS:
-                       symbol = 'P';
-                       break;
-               case RACE_YEEK:
-                       symbol = 'y';
-                       break;
-               case RACE_KLACKON:
-                       symbol = 'K';
-                       break;
-               case RACE_KOBOLD:
-                       symbol = 'k';
-                       break;
-               case RACE_IMP:
-                       if (one_in_(13)) symbol = 'U';
-                       else symbol = 'u';
-                       break;
-               case RACE_DRACONIAN:
-                       symbol = 'd';
-                       break;
-               case RACE_GOLEM:
-               case RACE_ANDROID:
-                       symbol = 'g';
-                       break;
-               case RACE_SKELETON:
-                       if (one_in_(13)) symbol = 'L';
-                       else symbol = 's';
-                       break;
-               case RACE_ZOMBIE:
-                       symbol = 'z';
-                       break;
-               case RACE_VAMPIRE:
-                       symbol = 'V';
-                       break;
-               case RACE_SPECTRE:
-                       symbol = 'G';
-                       break;
-               case RACE_SPRITE:
-                       symbol = 'I';
-                       break;
-               case RACE_ENT:
-                       symbol = '#';
-                       break;
-               case RACE_ANGEL:
-                       symbol = 'A';
-                       break;
-               case RACE_DEMON:
-                       symbol = 'U';
-                       break;
-               default:
-                       symbol = 'p';
-                       break;
-               }
-               break;
-       case MIMIC_DEMON:
-               if (one_in_(13)) symbol = 'U';
-               else symbol = 'u';
-               break;
-       case MIMIC_DEMON_LORD:
-               symbol = 'U';
-               break;
-       case MIMIC_VAMPIRE:
-               symbol = 'V';
-               break;
-       }
-       return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode, symbol);
+       return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
 }
 
 /*!
@@ -324,14 +267,14 @@ bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
 int summon_cyber(MONSTER_IDX who, POSITION y, POSITION x)
 {
        int i;
-       int max_cyber = (easy_band ? 1 : (dun_level / 50) + randint1(2));
+       int max_cyber = (easy_band ? 1 : (current_floor_ptr->dun_level / 50) + randint1(2));
        int count = 0;
        BIT_FLAGS mode = PM_ALLOW_GROUP;
 
        /* Summoned by a monster */
        if (who > 0)
        {
-               monster_type *m_ptr = &m_list[who];
+               monster_type *m_ptr = &current_floor_ptr->m_list[who];
                if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
        }
 
@@ -339,7 +282,7 @@ int summon_cyber(MONSTER_IDX who, POSITION y, POSITION x)
 
        for (i = 0; i < max_cyber; i++)
        {
-               count += summon_specific(who, y, x, 100, SUMMON_CYBER, mode, '\0');
+               count += summon_specific(who, y, x, 100, SUMMON_CYBER, mode);
        }
 
        return count;
@@ -366,10 +309,10 @@ void mitokohmon(void)
        }
        if (!count)
        {
-               for (i = m_max - 1; i > 0; i--)
+               for (i = current_floor_ptr->m_max - 1; i > 0; i--)
                {
-                       m_ptr = &m_list[i];
-                       if (!m_ptr->r_idx) continue;
+                       m_ptr = &current_floor_ptr->m_list[i];
+                       if (!monster_is_valid(m_ptr)) continue;
                        if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
                        if (!los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) continue;
                        if (!projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) continue;