OSDN Git Service

[Refactor] #39963 Separated effect-characteristics.h from floor.h
[hengband/hengband.git] / src / monster2.c
index 18b3a12..cb6f6bd 100644 (file)
 
 #include "angband.h"
 #include "util.h"
+#include "main/sound-definitions-table.h"
 #include "core.h"
 
-#include "cmd-dump.h"
+#include "io/write-diary.h"
+#include "cmd/cmd-dump.h"
 #include "cmd-pet.h"
 #include "dungeon.h"
-#include "floor.h"
+#include "effect/effect-characteristics.h"
 #include "object-flavor.h"
 #include "monsterrace-hook.h"
 #include "monster-status.h"
 #include "monster.h"
-#include "spells.h"
+#include "spell/spells-type.h"
 #include "spells-summon.h"
 #include "quest.h"
 #include "grid.h"
 #include "warning.h"
 #include "monster-spell.h"
 #include "files.h"
-#include "view-mainwindow.h"
+#include "view/display-main-window.h"
 #include "world.h"
 #include "monsterrace.h"
 #include "creature.h"
 #include "targeting.h"
-#include "realm-song.h"
 #include "melee.h"
+#include "spell/process-effect.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
@@ -989,50 +991,69 @@ errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hoo
  * Note that if no monsters are "appropriate", then this function will
  * fail, and return zero, but this should *almost* never happen.
  */
-MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level)
+MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option)
 {
-       int delay = mysqrt(level * 10000L) + 400L;
-       int reinforcement_possibility = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
-       int reinforcement_level = MIN(NASTY_MON_PLUS_MAX, 3 + current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10));
+       int                     i, j, p;
+       int                     r_idx;
+       long            value, total;
+       monster_race    *r_ptr;
+       alloc_entry             *table = alloc_race_table;
+
+       int pls_kakuritu, pls_level, over_days;
+       int delay = mysqrt(level * 10000L) + (level * 5);
+
+       /* town level : same delay as 10F, no nasty mons till day18 */
+       if (!level) delay = 360;
+
+       if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
+
+       /* +1 per day after the base date */
+       /* base dates : day5(1F), day18(10F,0F), day34(30F), day53(60F), day69(90F) */
+       over_days = MAX(0, current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 10000L) - delay / 20);
+
+       /* starts from 1/25, reaches 1/3 after 44days from a level dependent base date */
+       pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - over_days / 2);
+       /* starts from 0, reaches +25lv after 75days from a level dependent base date */
+       pls_level = MIN(NASTY_MON_PLUS_MAX, over_days / 3);
 
        if (d_info[player_ptr->dungeon_idx].flags1 & DF1_MAZE)
        {
-               reinforcement_possibility = MIN(reinforcement_possibility / 2, reinforcement_possibility - 10);
-               if (reinforcement_possibility < 2) reinforcement_possibility = 2;
-               reinforcement_level += 2;
+               pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
+               if (pls_kakuritu < 2) pls_kakuritu = 2;
+               pls_level += 2;
                level += 3;
        }
 
+       /* Boost the level */
        if (!player_ptr->phase_out && !(d_info[player_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
        {
-               if (ironman_nightmare && !randint0(reinforcement_possibility))
+               /* Nightmare mode allows more out-of depth monsters */
+               if (ironman_nightmare && !randint0(pls_kakuritu))
                {
+                       /* What a bizarre calculation */
                        level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
                }
                else
                {
-                       if (!randint0(reinforcement_possibility))
+                       /* Occasional "nasty" monster */
+                       if (!randint0(pls_kakuritu))
                        {
-                               level += reinforcement_level;
+                               /* Pick a level bonus */
+                               level += pls_level;
                        }
                }
        }
 
-       if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
-       if (level < 0) level = 0;
-
-       long total = 0L;
+       total = 0L;
 
        /* Process probabilities */
-       alloc_entry *table = alloc_race_table;
-       for (int i = 0; i < alloc_race_size; i++)
+       for (i = 0; i < alloc_race_size; i++)
        {
                if (table[i].level > level) break;
                table[i].prob3 = 0;
-               MONRACE_IDX r_idx = table[i].index;
-               monster_race *r_ptr;
+               r_idx = table[i].index;
                r_ptr = &r_info[r_idx];
-               if (!player_ptr->phase_out && !chameleon_change_m_idx)
+               if (!(option & GMN_ARENA) && !chameleon_change_m_idx)
                {
                        if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
                                (r_ptr->flags7 & (RF7_NAZGUL))) &&
@@ -1060,21 +1081,21 @@ MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level)
 
        if (total <= 0) return 0;
 
-       long value = randint0(total);
+       value = randint0(total);
        int found_count = 0;
-       for (int i = 0; i < alloc_race_size; i++)
+       for (i = 0; i < alloc_race_size; i++)
        {
                if (value < table[i].prob3) break;
                value = value - table[i].prob3;
                found_count++;
        }
 
-       int p = randint0(100);
+       p = randint0(100);
 
        /* Try for a "harder" monster once (50%) or twice (10%) */
        if (p < 60)
        {
-               int j = found_count;
+               j = found_count;
                value = randint0(total);
                for (found_count = 0; found_count < alloc_race_size; found_count++)
                {
@@ -1090,7 +1111,7 @@ MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level)
        /* Try for a "harder" monster twice (10%) */
        if (p < 10)
        {
-               int j = found_count;
+               j = found_count;
                value = randint0(total);
                for (found_count = 0; found_count < alloc_race_size; found_count++)
                {
@@ -2007,7 +2028,7 @@ void choose_new_monster(player_type *player_ptr, MONSTER_IDX m_idx, bool born, M
 
                if (d_info[player_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level += 2 + randint1(3);
 
-               r_idx = get_mon_num(player_ptr, level);
+               r_idx = get_mon_num(player_ptr, level, 0);
                r_ptr = &r_info[r_idx];
 
                chameleon_change_m_idx = 0;
@@ -2102,10 +2123,9 @@ static bool monster_hook_tanuki(MONRACE_IDX r_idx)
 static MONRACE_IDX initial_r_appearance(player_type *player_ptr, MONRACE_IDX r_idx, BIT_FLAGS generate_mode)
 {
        floor_type *floor_ptr = player_ptr->current_floor_ptr;
-       if (player_ptr->pseikaku == SEIKAKU_CHARGEMAN && !(generate_mode & (PM_MULTIPLY | PM_KAGE)))
+       if (player_ptr->pseikaku == SEIKAKU_CHARGEMAN && (generate_mode & PM_JURAL) && !(generate_mode & (PM_MULTIPLY | PM_KAGE)))
        {
-               if (floor_ptr->base_level == 0 ||
-                       (one_in_(5) && my_strchr("hkoptuyAHOPTUVY", r_info[r_idx].d_char))) return MON_ALIEN_JURAL;
+               return MON_ALIEN_JURAL;
        }
 
        if (!(r_info[r_idx].flags7 & RF7_TANUKI))
@@ -2117,7 +2137,7 @@ static MONRACE_IDX initial_r_appearance(player_type *player_ptr, MONRACE_IDX r_i
        DEPTH min = MIN(floor_ptr->base_level - 5, 50);
        while (--attempts)
        {
-               MONRACE_IDX ap_r_idx = get_mon_num(player_ptr, floor_ptr->base_level + 10);
+               MONRACE_IDX ap_r_idx = get_mon_num(player_ptr, floor_ptr->base_level + 10, 0);
                if (r_info[ap_r_idx].level >= min) return ap_r_idx;
        }
 
@@ -2712,7 +2732,7 @@ bool place_monster_aux(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
                if (!is_cave_empty_bold2(player_ptr, ny, nx)) continue;
 
                get_mon_num_prep(player_ptr, place_monster_can_escort, get_monster_hook2(player_ptr, ny, nx));
-               z = get_mon_num(player_ptr, r_ptr->level);
+               z = get_mon_num(player_ptr, r_ptr->level, 0);
                if (!z) break;
 
                (void)place_monster_one(player_ptr, place_monster_m_idx, ny, nx, z, mode);
@@ -2739,9 +2759,15 @@ bool place_monster(player_type *player_ptr, POSITION y, POSITION x, BIT_FLAGS mo
 {
        MONRACE_IDX r_idx;
        get_mon_num_prep(player_ptr, get_monster_hook(player_ptr), get_monster_hook2(player_ptr, y, x));
-       r_idx = get_mon_num(player_ptr, player_ptr->current_floor_ptr->monster_level);
+       r_idx = get_mon_num(player_ptr, player_ptr->current_floor_ptr->monster_level, 0);
        if (!r_idx) return FALSE;
 
+       if ((one_in_(5) || (player_ptr->current_floor_ptr->base_level == 0)) &&
+               !(r_info[r_idx].flags1 & RF1_UNIQUE) && my_strchr("hkoptuyAHLOPTUVY", r_info[r_idx].d_char))
+       {
+               mode |= PM_JURAL;
+       }
+
        if (place_monster_aux(player_ptr, 0, y, x, r_idx, mode)) return TRUE;
 
        return FALSE;
@@ -2765,7 +2791,7 @@ bool alloc_horde(player_type *player_ptr, POSITION y, POSITION x)
        monster_race *r_ptr = NULL;
        while (--attempts)
        {
-               r_idx = get_mon_num(player_ptr, floor_ptr->monster_level);
+               r_idx = get_mon_num(player_ptr, floor_ptr->monster_level, 0);
                if (!r_idx) return FALSE;
 
                r_ptr = &r_info[r_idx];
@@ -2991,7 +3017,7 @@ bool summon_specific(player_type *player_ptr, MONSTER_IDX who, POSITION y1, POSI
        summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
        get_mon_num_prep(player_ptr, summon_specific_okay, get_monster_hook2(player_ptr, y, x));
 
-       MONRACE_IDX r_idx = get_mon_num(player_ptr, (floor_ptr->dun_level + lev) / 2 + 5);
+       MONRACE_IDX r_idx = get_mon_num(player_ptr, (floor_ptr->dun_level + lev) / 2 + 5, 0);
        if (!r_idx)
        {
                summon_specific_type = 0;