OSDN Git Service

[Refactor] #37353 PROJECT_* 定義を新規ファイル projection.h へ移動。 / Move PROJECT_* definition...
[hengband/hengband.git] / src / monster2.c
index 715ba51..7b6acb0 100644 (file)
@@ -14,6 +14,7 @@
 #include "cmd-pet.h"
 #include "monsterrace-hook.h"
 #include "monster-status.h"
+#include "projection.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
@@ -23,7 +24,7 @@
  * @var horror_desc
  * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
  */
-cptr horror_desc[MAX_SAN_HORROR] =
+concptr horror_desc[MAX_SAN_HORROR] =
 {
 #ifdef JP
        "忌まわしい",
@@ -81,7 +82,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 +146,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 */
@@ -234,7 +235,6 @@ void delete_monster_idx(MONSTER_IDX i)
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
-       /* Get location */
        y = m_ptr->fy;
        x = m_ptr->fx;
 
@@ -252,7 +252,6 @@ void delete_monster_idx(MONSTER_IDX i)
        if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
        if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
 
-
        /* Hack -- remove target monster */
        if (i == target_who) target_who = 0;
 
@@ -470,7 +469,7 @@ void compact_monsters(int size)
 
                        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
                        {
-                               char m_name[80];
+                               GAME_TEXT m_name[MAX_NLEN];
                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                                do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
                        }
@@ -795,7 +794,6 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
                        break;
                }
 
-
                case SUMMON_KIN:
                {
                        okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
@@ -1172,7 +1170,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];
@@ -1245,17 +1243,15 @@ errr get_mon_num_prep(monsterrace_hook_type monster_hook,
  */
 MONRACE_IDX get_mon_num(DEPTH level)
 {
-       int                     i, j, p;
-       int                     r_idx;
-       long            value, total;
-       monster_race    *r_ptr;
-       alloc_entry             *table = alloc_race_table;
+       int i, j, p;
+       MONRACE_IDX r_idx;
+       long value, total;
+       monster_race *r_ptr;
+       alloc_entry *table = alloc_race_table;
 
        int pls_kakuritu, pls_level;
        int delay = mysqrt(level * 10000L) + 400L;
 
-       if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
-
        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)) ;
 
@@ -1287,6 +1283,9 @@ MONRACE_IDX get_mon_num(DEPTH level)
                }
        }
 
+       if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
+       if (level < 0) level = 0;
+
        /* Reset total */
        total = 0L;
 
@@ -1458,12 +1457,12 @@ 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];
-       char            silly_name[1024];
+       GAME_TEXT silly_name[1024];
        bool            seen, pron;
        bool            named = FALSE;
 
@@ -1905,7 +1904,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
 
        if (!necro && m_ptr)
        {
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
 
                power = r_ptr->level / 2;
@@ -1984,8 +1983,8 @@ void sanity_blast(monster_type *m_ptr, bool necro)
        else if(!necro)
        {
                monster_race *r_ptr;
-               char m_name[80];
-               cptr desc;
+               GAME_TEXT m_name[MAX_NLEN];
+               concptr desc;
 
                get_mon_num_prep(get_nightmare, NULL);
 
@@ -1995,7 +1994,6 @@ void sanity_blast(monster_type *m_ptr, bool necro)
 
                get_mon_num_prep(NULL, NULL);
 
-               /* Describe it */
 #ifndef JP
                if (!(r_ptr->flags1 & RF1_UNIQUE))
                        sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
@@ -2475,7 +2473,6 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                /* Handle "cold blooded" monsters */
                                if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
                                {
-                                       /* Take note */
                                        do_cold_blood = TRUE;
                                }
 
@@ -2493,7 +2490,6 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                /* Handle "invisible" monsters */
                                if (r_ptr->flags2 & (RF2_INVISIBLE))
                                {
-                                       /* Take note */
                                        do_invisible = TRUE;
 
                                        /* See invisible */
@@ -2736,7 +2732,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
        int oldmaxhp;
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr;
-       char old_m_name[80];
+       char old_m_name[MAX_NLEN];
        bool old_unique = FALSE;
        int old_r_idx = m_ptr->r_idx;
 
@@ -2802,7 +2798,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
        if (m_idx == p_ptr->riding)
        {
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                monster_desc(m_name, m_ptr, 0);
                msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
                if (!(r_ptr->flags7 & RF7_RIDING))
@@ -2868,10 +2864,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;
 
@@ -2942,7 +2942,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;
 
@@ -3253,9 +3253,9 @@ 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;
-                       char o_name[MAX_NLEN];
+                       GAME_TEXT o_name[MAX_NLEN];
 
                        if (r_ptr->level > p_ptr->lev + 30)
                                color = _("黒く", "black");
@@ -3586,7 +3586,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]);
@@ -3723,18 +3723,18 @@ bool alloc_horde(POSITION y, POSITION x)
        m_idx = cave[y][x].m_idx;
 
        if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
-       summon_kin_type = r_ptr->d_char;
 
        for (attempts = randint1(10) + 5; attempts; attempts--)
        {
                scatter(&cy, &cx, y, x, 5, 0);
 
-               (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
+               (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
 
                y = cy;
                x = cx;
        }
 
+       if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
        return TRUE;
 }
 
@@ -3832,7 +3832,6 @@ bool alloc_monster(POSITION dis, BIT_FLAGS mode)
        {
                if (alloc_horde(y, x))
                {
-                       if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type);
                        return (TRUE);
                }
        }
@@ -3925,7 +3924,7 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
  *
  * Note that this function may not succeed, though this is very rare.
  */
-bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode)
+bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
 {
        POSITION x, y;
        MONRACE_IDX r_idx;
@@ -3940,6 +3939,8 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
        /* Save the "summon" type */
        summon_specific_type = type;
 
+       summon_kin_type = symbol;
+
        summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
 
        /* Prepare allocation table */
@@ -3980,7 +3981,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;
 
@@ -4045,15 +4046,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];
 
-       char m_name[80];
+       GAME_TEXT m_name[MAX_NLEN];
 
-       /* Get the monster name */
        monster_desc(m_name, m_ptr, 0);
 
        if(dam == 0) // Notice non-damage
@@ -4063,10 +4064,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
        {
@@ -4374,10 +4375,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;
 
@@ -4387,8 +4386,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)
        {