OSDN Git Service

[Refactor] #37353 構造体 dungeon_info_type を他の慣例に従い dungeon_type に改名。 / Rename dungeon_i...
[hengband/hengband.git] / src / monster2.c
index 6707d22..6f4e2dd 100644 (file)
 #include "cmd-pet.h"
 #include "monsterrace-hook.h"
 #include "monster-status.h"
+#include "projection.h"
+#include "monster.h"
+#include "spells-summon.h"
+#include "quest.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
@@ -23,7 +27,7 @@
  * @var horror_desc
  * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
  */
-cptr horror_desc[MAX_SAN_HORROR] =
+concptr horror_desc[MAX_SAN_HORROR] =
 {
 #ifdef JP
        "忌まわしい",
@@ -81,7 +85,7 @@ cptr horror_desc[MAX_SAN_HORROR] =
  * @var funny_desc
  * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
  */
-cptr funny_desc[MAX_SAN_FUNNY] =
+concptr funny_desc[MAX_SAN_FUNNY] =
 {
 #ifdef JP
        "間抜けな",
@@ -145,7 +149,7 @@ cptr funny_desc[MAX_SAN_FUNNY] =
  * @var funny_comments
  * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
  */
-cptr funny_comments[MAX_SAN_COMMENT] =
+concptr funny_comments[MAX_SAN_COMMENT] =
 {
 #ifdef JP
   /* nuke me */
@@ -264,8 +268,6 @@ void delete_monster_idx(MONSTER_IDX i)
        /* Monster is gone */
        cave[y][x].m_idx = 0;
 
-
-       /* Delete objects */
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
@@ -965,7 +967,7 @@ static int chameleon_change_m_idx = 0;
  */
 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
 {
-       dungeon_info_type *d_ptr = &d_info[dungeon_type];
+       dungeon_type *d_ptr = &d_info[p_ptr->dungeon_idx];
        monster_race *r_ptr = &r_info[r_idx];
        byte a;
 
@@ -1169,7 +1171,7 @@ errr get_mon_num_prep(monsterrace_hook_type monster_hook,
        /* Scan the allocation table */
        for (i = 0; i < alloc_race_size; i++)
        {
-               monster_race    *r_ptr;
+               monster_race *r_ptr;
                
                /* Get the entry */
                alloc_entry *entry = &alloc_race_table[i];
@@ -1203,7 +1205,7 @@ errr get_mon_num_prep(monsterrace_hook_type monster_hook,
 
                if (dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
                {
-                       int hoge = entry->prob2 * d_info[dungeon_type].special_div;
+                       int hoge = entry->prob2 * d_info[p_ptr->dungeon_idx].special_div;
                        entry->prob2 = hoge / 64;
                        if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
                }
@@ -1254,7 +1256,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
        pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
        pls_level    = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
 
-       if (d_info[dungeon_type].flags1 & DF1_MAZE)
+       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
        {
                pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
                if (pls_kakuritu < 2) pls_kakuritu = 2;
@@ -1263,7 +1265,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
        }
 
        /* Boost the level */
-       if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
+       if (!p_ptr->inside_battle && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
        {
                /* Nightmare mode allows more out-of depth monsters */
                if (ironman_nightmare && !randint0(pls_kakuritu))
@@ -1456,10 +1458,10 @@ MONRACE_IDX get_mon_num(DEPTH level)
  */
 void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
 {
-       cptr            res;
+       concptr            res;
        monster_race    *r_ptr;
 
-       cptr            name;
+       concptr            name;
        char            buf[128];
        GAME_TEXT silly_name[1024];
        bool            seen, pron;
@@ -1983,7 +1985,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
        {
                monster_race *r_ptr;
                GAME_TEXT m_name[MAX_NLEN];
-               cptr desc;
+               concptr desc;
 
                get_mon_num_prep(get_nightmare, NULL);
 
@@ -2260,7 +2262,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
        bool easy = FALSE;
 
        /* Non-Ninja player in the darkness */
-       bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
+       bool in_darkness = (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
 
        /* Do disturb? */
        if (disturb_high)
@@ -2759,7 +2761,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
                else
                        level = dun_level;
 
-               if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
+               if (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
 
                r_idx = get_mon_num(level);
                r_ptr = &r_info[r_idx];
@@ -2863,10 +2865,14 @@ static bool monster_hook_tanuki(MONRACE_IDX r_idx)
 static IDX initial_r_appearance(MONRACE_IDX r_idx)
 {
        int attempts = 1000;
-
        IDX ap_r_idx;
        DEPTH min = MIN(base_level-5, 50);
 
+       if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
+       {
+               if (base_level == 0 || one_in_(5)) return MON_ALIEN_JURAL;
+       }
+
        if (!(r_info[r_idx].flags7 & RF7_TANUKI))
                return r_idx;
 
@@ -2937,7 +2943,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
        cave_type               *c_ptr = &cave[y][x];
        monster_type    *m_ptr;
        monster_race    *r_ptr = &r_info[r_idx];
-       cptr            name = (r_name + r_ptr->name);
+       concptr         name = (r_name + r_ptr->name);
 
        int cmi;
 
@@ -3248,7 +3254,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
        {
                if (r_ptr->flags1 & RF1_UNIQUE)
                {
-                       cptr color;
+                       concptr color;
                        object_type *o_ptr;
                        GAME_TEXT o_name[MAX_NLEN];
 
@@ -3315,7 +3321,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
 
 /*!
- * @brief モンスター1体を目標地点に可能なり近い位置に生成する / improved version of scatter() for place monster
+ * @brief モンスター1体を目標地点に可能なり近い位置に生成する / improved version of scatter() for place monster
  * @param r_idx 生成モンスター種族
  * @param yp 結果生成位置y座標
  * @param xp 結果生成位置x座標
@@ -3327,11 +3333,11 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
  */
 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
 {
-       int place_x[MON_SCAT_MAXD];
-       int place_y[MON_SCAT_MAXD];
+       POSITION place_x[MON_SCAT_MAXD];
+       POSITION place_y[MON_SCAT_MAXD];
        int num[MON_SCAT_MAXD];
        int i;
-       int nx, ny;
+       POSITION nx, ny;
 
        if (max_dist >= MON_SCAT_MAXD)
                return FALSE;
@@ -3581,7 +3587,7 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
        place_monster_m_idx = hack_m_idx_ii;
 
        /* Reinforcement */
-       for(i = 0; i < 6; i++)
+       for(i = 0; i < A_MAX; i++)
        {
                if(!r_ptr->reinforce_id[i]) break;
                n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
@@ -3617,8 +3623,6 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
 
                        /* Require empty grids */
                        if (!cave_empty_bold2(ny, nx)) continue;
-
-                       /* Prepare allocation table */
                        get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
 
                        /* Pick a random race */
@@ -3654,8 +3658,6 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
 {
        MONRACE_IDX r_idx;
-
-       /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
 
        /* Pick a monster */
@@ -3684,8 +3686,6 @@ bool alloc_horde(POSITION y, POSITION x)
        int attempts = 1000;
        POSITION cy = y;
        POSITION cx = x;
-
-       /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
 
        while (--attempts)
@@ -3740,9 +3740,9 @@ bool alloc_horde(POSITION y, POSITION x)
  */
 bool alloc_guardian(bool def_val)
 {
-       MONRACE_IDX guardian = d_info[dungeon_type].final_guardian;
+       MONRACE_IDX guardian = d_info[p_ptr->dungeon_idx].final_guardian;
 
-       if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
+       if (guardian && (d_info[p_ptr->dungeon_idx].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
        {
                int oy;
                int ox;
@@ -3882,7 +3882,7 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
            monster_has_hostile_align(NULL, 10, -10, r_ptr))
                return FALSE;
 
-       if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
+       if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
 
        return (summon_specific_aux(r_idx));
 }
@@ -3937,8 +3937,6 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
        summon_kin_type = symbol;
 
        summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
-
-       /* Prepare allocation table */
        get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
 
        /* Pick a monster, using the level calculation */
@@ -3976,7 +3974,7 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
  * @param mode 生成オプション 
  * @return 召喚できたらtrueを返す
  */
-bool summon_named_creature (MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
+bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        POSITION x, y;
 
@@ -4041,15 +4039,15 @@ bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
  */
 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
 {
-       long oldhp, newhp, tmp;
-       int percentage;
+       HIT_POINT oldhp, newhp;
+       HIT_POINT tmp;
+       PERCENTAGE percentage;
 
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        GAME_TEXT m_name[MAX_NLEN];
 
-       /* Get the monster name */
        monster_desc(m_name, m_ptr, 0);
 
        if(dam == 0) // Notice non-damage
@@ -4059,10 +4057,10 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
        }
 
        /* Note -- subtle fix -CFT */
-       newhp = (long)(m_ptr->hp);
-       oldhp = newhp + (long)(dam);
+       newhp = m_ptr->hp;
+       oldhp = newhp + dam;
        tmp = (newhp * 100L) / oldhp;
-       percentage = (int)(tmp);
+       percentage = tmp;
 
        if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
        {
@@ -4370,10 +4368,8 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
 void update_smart_learn(MONSTER_IDX m_idx, int what)
 {
        monster_type *m_ptr = &m_list[m_idx];
-
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-
        /* Not allowed to learn */
        if (!smart_learn) return;
 
@@ -4383,8 +4379,6 @@ void update_smart_learn(MONSTER_IDX m_idx, int what)
        /* Not intelligent, only learn sometimes */
        if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
 
-
-
        /* Analyze the knowledge */
        switch (what)
        {