OSDN Git Service

[Refactor] #37353 未使用構造体 dun_type 削除。 / Delete dun_type, unused structure.
[hengband/hengband.git] / src / mspells1.c
index ae1fb48..9c9f565 100644 (file)
  */
 
 #include "angband.h"
+#include "object-curse.h"
+#include "projection.h"
+#include "quest.h"
+#include "realm-hex.h"
 
 
 /*!
@@ -345,7 +349,7 @@ static void remove_bad_spells(MONSTER_IDX m_idx, u32b *f4p, u32b *f5p, u32b *f6p
                f5 &= ~(RF5_DRAIN_MANA);
        }
 
-       /* XXX XXX XXX No spells left? */
+       /* No spells left? */
        /* if (!f4 && !f5 && !f6) ... */
 
        (*f4p) = f4;
@@ -414,7 +418,6 @@ bool raise_possible(monster_type *m_ptr)
                        /* Scan the pile of objects */
                        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                        {
-                               /* Acquire object */
                                object_type *o_ptr = &o_list[this_o_idx];
 
                                /* Acquire next object */
@@ -619,106 +622,7 @@ void breath(POSITION y, POSITION x, MONSTER_IDX m_idx, EFFECT_ID typ, int dam_hp
        (void)project(m_idx, rad, y, x, dam_hp, typ, flg, (learnable ? monspell : -1));
 }
 
-/*!
- * @brief アイテムに付加される可能性のある呪いを指定する。
- * @param power 呪いの段階
- * @param o_ptr 呪いをかけられる装備オブジェクトの構造体参照ポインタ
- * @return 与える呪いのID
- */
-BIT_FLAGS get_curse(int power, object_type *o_ptr)
-{
-       BIT_FLAGS new_curse;
-
-       while(1)
-       {
-               new_curse = (1 << (randint0(MAX_CURSE)+4));
-               if (power == 2)
-               {
-                       if (!(new_curse & TRC_HEAVY_MASK)) continue;
-               }
-               else if (power == 1)
-               {
-                       if (new_curse & TRC_SPECIAL_MASK) continue;
-               }
-               else if (power == 0)
-               {
-                       if (new_curse & TRC_HEAVY_MASK) continue;
-               }
-               if (new_curse == TRC_LOW_MELEE && !object_is_weapon(o_ptr)) continue;
-               if (new_curse == TRC_LOW_AC && !object_is_armour(o_ptr)) continue;
-               break;
-       }
-       return new_curse;
-}
-
-/*!
- * @brief 装備への呪い付加判定と付加処理
- * @param chance 呪いの基本確率
- * @param heavy_chance さらに重い呪いとなる確率
- * @return なし
- */
-void curse_equipment(PERCENTAGE chance, PERCENTAGE heavy_chance)
-{
-       bool        changed = FALSE;
-       int         curse_power = 0;
-       u32b        new_curse;
-       u32b oflgs[TR_FLAG_SIZE];
-       object_type *o_ptr = &inventory[INVEN_RARM + randint0(12)];
-       char o_name[MAX_NLEN];
-
-       if (randint1(100) > chance) return;
 
-       if (!o_ptr->k_idx) return;
-
-       object_flags(o_ptr, oflgs);
-
-       object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-
-       /* Extra, biased saving throw for blessed items */
-       if (have_flag(oflgs, TR_BLESSED))
-       {
-#ifdef JP
-               msg_format("祝福された%sは呪いを跳ね返した!", o_name,
-#else
-               msg_format("Your blessed %s resist%s cursing!", o_name,
-#endif
-
-                       ((o_ptr->number > 1) ? "" : "s"));
-               /* Hmmm -- can we wear multiple items? If not, this is unnecessary */
-               return;
-       }
-
-       if ((randint1(100) <= heavy_chance) &&
-           (object_is_artifact(o_ptr) || object_is_ego(o_ptr)))
-       {
-               if (!(o_ptr->curse_flags & TRC_HEAVY_CURSE))
-                       changed = TRUE;
-               o_ptr->curse_flags |= TRC_HEAVY_CURSE;
-               o_ptr->curse_flags |= TRC_CURSED;
-               curse_power++;
-       }
-       else
-       {
-               if (!object_is_cursed(o_ptr))
-                       changed = TRUE;
-               o_ptr->curse_flags |= TRC_CURSED;
-       }
-       if (heavy_chance >= 50) curse_power++;
-
-       new_curse = get_curse(curse_power, o_ptr);
-       if (!(o_ptr->curse_flags & new_curse))
-       {
-               changed = TRUE;
-               o_ptr->curse_flags |= new_curse;
-       }
-
-       if (changed)
-       {
-               msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding %s..."), o_name);
-               o_ptr->feeling = FEEL_NONE;
-       }
-       p_ptr->update |= (PU_BONUS);
-}
 
 
 /*!
@@ -1385,12 +1289,12 @@ static bool adjacent_grid_check(monster_type *m_ptr, POSITION *yp, POSITION *xp,
  * @details
  * Returns "TRUE" if a spell (or whatever) was (successfully) cast.\n
  *\n
- * XXX XXX XXX This function could use some work, but remember to\n
+ * This function could use some work, but remember to\n
  * keep it as optimized as possible, while retaining generic code.\n
  *\n
  * Verify the various "blind-ness" checks in the code.\n
  *\n
- * XXX XXX XXX Note that several effects should really not be "seen"\n
+ * Note that several effects should really not be "seen"\n
  * if the player is blind.  See also "effects.c" for other "mistakes".\n
  *\n
  * Perhaps monsters should breathe at locations *near* the player,\n
@@ -1441,11 +1345,11 @@ bool make_attack_spell(MONSTER_IDX m_idx)
        SPELL_IDX thrown_spell = 0;
        DEPTH rlev;
        PERCENTAGE failrate;
-       byte            spell[96], num = 0;
+       byte spell[96], num = 0;
        BIT_FLAGS f4, f5, f6;
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       char m_name[80];
+       GAME_TEXT m_name[MAX_NLEN];
 #ifndef JP
        char m_poss[80];
 #endif
@@ -1453,7 +1357,6 @@ bool make_attack_spell(MONSTER_IDX m_idx)
        bool            do_spell = DO_SPELL_NONE;
        int             dam = 0;
 
-       /* Target location */
        POSITION x = p_ptr->x;
        POSITION y = p_ptr->y;
 
@@ -1468,7 +1371,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
        /* Check "projectable" */
        bool direct;
 
-       bool in_no_magic_dungeon = (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && dun_level
+       bool in_no_magic_dungeon = (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && dun_level
                && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest));
 
        bool can_use_lite_area = FALSE;
@@ -1490,7 +1393,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
        /* Sometimes forbid inate attacks (breaths) */
        if (randint0(100) >= (r_ptr->freq_spell * 2)) no_inate = TRUE;
 
-       /* XXX XXX XXX Handle "track_target" option (?) */
+       /* Handle "track_target" option (?) */
 
 
        /* Extract the racial spell flags */
@@ -1565,7 +1468,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
                }
                else if ((f5 & RF5_BA_LITE) && (m_ptr->cdis <= MAX_RANGE))
                {
-                       int by = y, bx = x;
+                       POSITION by = y, bx = x;
                        get_project_point(m_ptr->fy, m_ptr->fx, &by, &bx, 0L);
                        if ((distance(by, bx, y, x) <= 3) && los(by, bx, y, x) && one_in_(5))
                        {
@@ -1607,7 +1510,6 @@ bool make_attack_spell(MONSTER_IDX m_idx)
 
        reset_target(m_ptr);
 
-       /* Extract the monster level */
        rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
 
        /* Forbid inate attacks sometimes */
@@ -1627,7 +1529,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
 
                if (!(r_ptr->flags2 & RF2_STUPID))
                {
-                       if (d_info[dungeon_type].flags1 & DF1_DARKNESS) f6 &= ~(RF6_DARKNESS);
+                       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) f6 &= ~(RF6_DARKNESS);
                        else if ((p_ptr->pclass == CLASS_NINJA) && !can_use_lite_area) f6 &= ~(RF6_DARKNESS);
                }
        }
@@ -1801,7 +1703,7 @@ bool make_attack_spell(MONSTER_IDX m_idx)
        if (!spell_is_inate(thrown_spell)
            && (in_no_magic_dungeon || (MON_STUNNED(m_ptr) && one_in_(2)) || (randint0(100) < failrate)))
        {
-               disturb(1, 1);
+               disturb(TRUE, TRUE);
                msg_format(_("%^sは呪文を唱えようとしたが失敗した。", "%^s tries to cast a spell, but fails."), m_name);
 
                return (TRUE);