OSDN Git Service

[Fix] #41316 get_mon_num() に最小生成階範囲追加. / Add min level range to get_mon_num().
authordeskull <deskull@users.sourceforge.jp>
Mon, 25 Jan 2021 22:43:37 +0000 (07:43 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Tue, 26 Jan 2021 09:12:25 +0000 (18:12 +0900)
 * 将来の拡張と、whileループでget_mon_num()の内容繰り返すのは問題と判断したため.

17 files changed:
src/birth/inventory-initializer.c
src/core/player-processor.c
src/dungeon/quest.c
src/market/arena.c
src/market/bounty.c
src/market/building-quest.c
src/monster-floor/monster-generator.c
src/monster-floor/monster-summon.c
src/monster-floor/one-monster-placer.c
src/monster-race/monster-race-hook.c
src/monster/monster-list.c
src/monster/monster-list.h
src/object-enchant/apply-magic-others.c
src/player/eldritch-horror.c
src/room/rooms-pit-nest.c
src/room/rooms-special.c
src/spell-kind/spells-polymorph.c

index 65aedcf..49f83be 100644 (file)
@@ -96,7 +96,7 @@ static void decide_initial_items(player_type *creature_ptr, object_type *q_ptr)
         get_mon_num_prep(creature_ptr, monster_hook_human, NULL);
         for (int i = rand_range(3, 4); i > 0; i--) {
             object_prep(creature_ptr, q_ptr, lookup_kind(TV_CORPSE, SV_CORPSE));
-            q_ptr->pval = get_mon_num(creature_ptr, 2, 0);
+            q_ptr->pval = get_mon_num(creature_ptr, 0, 2, 0);
             if (q_ptr->pval) {
                 q_ptr->number = 1;
                 add_outfit(creature_ptr, q_ptr);
index c1be1d5..c38bb69 100644 (file)
@@ -56,7 +56,7 @@ static void process_fishing(player_type *creature_ptr)
         MONRACE_IDX r_idx;
         bool success = FALSE;
         get_mon_num_prep(creature_ptr, monster_is_fishing_target, NULL);
-        r_idx = get_mon_num(creature_ptr,
+        r_idx = get_mon_num(creature_ptr, 0,
             creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level
                                                        : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level,
             0);
index 834b970..de13844 100644 (file)
@@ -67,7 +67,7 @@ void determine_random_questor(player_type *player_ptr, quest_type *q_ptr)
          * Random monster 5 - 10 levels out of depth
          * (depending on level)
          */
-        r_idx = get_mon_num(player_ptr, q_ptr->level + 5 + randint1(q_ptr->level / 10), GMN_ARENA);
+        r_idx = get_mon_num(player_ptr, 0, q_ptr->level + 5 + randint1(q_ptr->level / 10), GMN_ARENA);
         monster_race *r_ptr;
         r_ptr = &r_info[r_idx];
 
index 4daa4bf..16ef04c 100644 (file)
@@ -197,7 +197,7 @@ void update_gambling_monsters(player_type *player_ptr)
             int j;
             while (TRUE) {
                 get_mon_num_prep(player_ptr, monster_can_entry_arena, NULL);
-                r_idx = get_mon_num(player_ptr, mon_level, GMN_ARENA);
+                r_idx = get_mon_num(player_ptr, 0, mon_level, GMN_ARENA);
                 if (!r_idx)
                     continue;
 
index 31f58c7..1e19f1c 100644 (file)
@@ -283,7 +283,7 @@ void determine_daily_bounty(player_type *player_ptr, bool conv_old)
     get_mon_num_prep(player_ptr, NULL, NULL);
 
     while (TRUE) {
-        today_mon = get_mon_num(player_ptr, max_dl, GMN_ARENA);
+        today_mon = get_mon_num(player_ptr, MIN(max_dl / 2, 40), max_dl, GMN_ARENA);
         monster_race *r_ptr;
         r_ptr = &r_info[today_mon];
 
@@ -295,8 +295,6 @@ void determine_daily_bounty(player_type *player_ptr, bool conv_old)
             continue;
         if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON))
             continue;
-        if (r_ptr->level < MIN(max_dl / 2, 40))
-            continue;
         if (r_ptr->rarity > 10)
             continue;
         break;
@@ -313,7 +311,7 @@ void determine_bounty_uniques(player_type *player_ptr)
     get_mon_num_prep(player_ptr, NULL, NULL);
     for (int i = 0; i < MAX_BOUNTY; i++) {
         while (TRUE) {
-            current_world_ptr->bounty_r_idx[i] = get_mon_num(player_ptr, MAX_DEPTH - 1, GMN_ARENA);
+            current_world_ptr->bounty_r_idx[i] = get_mon_num(player_ptr, 0, MAX_DEPTH - 1, GMN_ARENA);
             monster_race *r_ptr;
             r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
 
index 72c9d87..744a0fd 100644 (file)
@@ -98,13 +98,13 @@ void castle_quest(player_type *player_ptr)
     }
 
     if (q_ptr->r_idx == 0) {
-        q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6), 0);
+        q_ptr->r_idx = get_mon_num(player_ptr, 0, q_ptr->level + 4 + randint1(6), 0);
     }
 
     monster_race *r_ptr;
     r_ptr = &r_info[q_ptr->r_idx];
     while ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->rarity != 1)) {
-        q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6), 0);
+        q_ptr->r_idx = get_mon_num(player_ptr, 0, q_ptr->level + 4 + randint1(6), 0);
         r_ptr = &r_info[q_ptr->r_idx];
     }
 
index 3b04cd1..5021a2f 100644 (file)
@@ -298,7 +298,7 @@ bool place_monster_aux(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
             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, 0);
+        z = get_mon_num(player_ptr, 0, r_ptr->level, 0);
         if (!z)
             break;
 
@@ -322,7 +322,7 @@ bool place_monster_aux(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
 bool place_monster(player_type *player_ptr, POSITION y, POSITION x, BIT_FLAGS mode)
 {
     get_mon_num_prep(player_ptr, get_monster_hook(player_ptr), get_monster_hook2(player_ptr, y, x));
-    MONRACE_IDX r_idx = get_mon_num(player_ptr, player_ptr->current_floor_ptr->monster_level, 0);
+    MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, player_ptr->current_floor_ptr->monster_level, 0);
     if (r_idx == 0)
         return FALSE;
 
@@ -350,7 +350,7 @@ bool alloc_horde(player_type *player_ptr, POSITION y, POSITION x, summon_specifi
     int attempts = 1000;
     monster_race *r_ptr = NULL;
     while (--attempts) {
-        r_idx = get_mon_num(player_ptr, floor_ptr->monster_level, 0);
+        r_idx = get_mon_num(player_ptr, 0, floor_ptr->monster_level, 0);
         if (!r_idx)
             return FALSE;
 
index d33afac..06eb662 100644 (file)
@@ -106,7 +106,7 @@ bool summon_specific(player_type *player_ptr, MONSTER_IDX who, POSITION y1, POSI
     summon_unique_okay = (mode & PM_ALLOW_UNIQUE) != 0;
     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, 0);
+    MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, (floor_ptr->dun_level + lev) / 2 + 5, 0);
     if (!r_idx) {
         summon_specific_type = 0;
         return FALSE;
index ddf4a7f..11c2638 100644 (file)
@@ -85,7 +85,7 @@ static MONRACE_IDX initial_r_appearance(player_type *player_ptr, MONRACE_IDX r_i
     int attempts = 1000;
     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, 0);
+        MONRACE_IDX ap_r_idx = get_mon_num(player_ptr, 0, floor_ptr->base_level + 10, 0);
         if (r_info[ap_r_idx].level >= min)
             return ap_r_idx;
     }
index 9148c24..16d552b 100644 (file)
@@ -36,7 +36,7 @@ BIT_FLAGS vault_aux_dragon_mask4;
 void vault_prep_clone(player_type *player_ptr)
 {
     get_mon_num_prep(player_ptr, vault_aux_simple, NULL);
-    vault_aux_race = get_mon_num(player_ptr, player_ptr->current_floor_ptr->dun_level + 10, 0);
+    vault_aux_race = get_mon_num(player_ptr, 0, player_ptr->current_floor_ptr->dun_level + 10, 0);
     get_mon_num_prep(player_ptr, NULL, NULL);
 }
 
@@ -48,7 +48,7 @@ void vault_prep_clone(player_type *player_ptr)
 void vault_prep_symbol(player_type *player_ptr)
 {
     get_mon_num_prep(player_ptr, vault_aux_simple, NULL);
-    MONRACE_IDX r_idx = get_mon_num(player_ptr, player_ptr->current_floor_ptr->dun_level + 10, 0);
+    MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, player_ptr->current_floor_ptr->dun_level + 10, 0);
     get_mon_num_prep(player_ptr, NULL, NULL);
     vault_aux_char = r_info[r_idx].d_char;
 }
index 60ce8c2..3edca7b 100644 (file)
@@ -74,10 +74,11 @@ MONSTER_IDX m_pop(floor_type *floor_ptr)
 /*!
  * @brief 生成モンスター種族を1種生成テーブルから選択する
  * @param player_ptr プレーヤーへの参照ポインタ
- * @param level 生成階
+ * @param min_level 最小生成階
+ * @param max_level 最大生成階
  * @return 選択されたモンスター生成種族
  */
-MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option)
+MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH min_level, DEPTH max_level, BIT_FLAGS option)
 {
     int i, j, p;
     int r_idx;
@@ -85,44 +86,44 @@ MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option)
     monster_race *r_ptr;
     alloc_entry *table = alloc_race_table;
 
-    int pls_kakuritu, pls_level, over_days;
-    int delay = mysqrt(level * 10000L) + (level * 5);
+    int pls_kakuritu, pls_max_level, over_days;
+    int delay = mysqrt(max_level * 10000L) + (max_level * 5);
 
-    /* town level : same delay as 10F, no nasty mons till day18 */
-    if (!level)
+    /* town max_level : same delay as 10F, no nasty mons till day18 */
+    if (!max_level)
         delay = 360;
 
-    if (level > MAX_DEPTH - 1)
-        level = MAX_DEPTH - 1;
+    if (max_level > MAX_DEPTH - 1)
+        max_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 */
+    /* starts from 1/25, reaches 1/3 after 44days from a max_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);
+    /* starts from 0, reaches +25lv after 75days from a max_level dependent base date */
+    pls_max_level = MIN(NASTY_MON_PLUS_MAX, over_days / 3);
 
     if (d_info[player_ptr->dungeon_idx].flags1 & DF1_MAZE) {
         pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
         if (pls_kakuritu < 2)
             pls_kakuritu = 2;
-        pls_level += 2;
-        level += 3;
+        pls_max_level += 2;
+        max_level += 3;
     }
 
-    /* Boost the level */
-    if (!player_ptr->phase_out && !(d_info[player_ptr->dungeon_idx].flags1 & DF1_BEGINNER)) {
+    /* Boost the max_level */
+    if ((option & GMN_ARENA) || !(d_info[player_ptr->dungeon_idx].flags1 & DF1_BEGINNER)) {
         /* 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));
+            max_level = 1 + (max_level * MAX_DEPTH / randint1(MAX_DEPTH));
         } else {
             /* Occasional "nasty" monster */
             if (!randint0(pls_kakuritu)) {
-                /* Pick a level bonus */
-                level += pls_level;
+                /* Pick a max_level bonus */
+                max_level += pls_max_level;
             }
         }
     }
@@ -131,7 +132,7 @@ MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option)
 
     /* Process probabilities */
     for (i = 0; i < alloc_race_size; i++) {
-        if (table[i].level level)
+        if (table[i].level < min_level || max_level < table[i].level)
             break;
         table[i].prob3 = 0;
         r_idx = table[i].index;
@@ -328,7 +329,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, 0);
+        r_idx = get_mon_num(player_ptr, 0, level, 0);
         r_ptr = &r_info[r_idx];
 
         chameleon_change_m_idx = 0;
index 1cbc0b1..00f9e0c 100644 (file)
@@ -6,7 +6,7 @@
 MONSTER_IDX m_pop(floor_type *floor_ptr);
 
 #define GMN_ARENA 0x00000001 //!< 賭け闘技場向け生成
-MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option);
+MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH min_level, DEPTH max_level, BIT_FLAGS option);
 void choose_new_monster(player_type *player_ptr, MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx);
 SPEED get_mspeed(floor_type *player_ptr, monster_race *r_ptr);
 int get_monster_crowd_number(floor_type *floor_ptr, MONSTER_IDX m_idx);
index c0d8dbb..057d946 100644 (file)
@@ -163,7 +163,7 @@ void apply_magic_others(player_type *owner_ptr, object_type *o_ptr, int power)
 
         get_mon_num_prep(owner_ptr, item_monster_okay, NULL);
         while (TRUE) {
-            i = get_mon_num(owner_ptr, floor_ptr->dun_level, 0);
+            i = get_mon_num(owner_ptr, 0, floor_ptr->dun_level, 0);
             r_ptr = &r_info[i];
             check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
             if (!r_ptr->rarity)
index 6d497fa..cf97f23 100644 (file)
@@ -145,7 +145,7 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
         GAME_TEXT m_name[MAX_NLEN];
         concptr desc;
         get_mon_num_prep(creature_ptr, get_nightmare, NULL);
-        r_ptr = &r_info[get_mon_num(creature_ptr, MAX_DEPTH, 0)];
+        r_ptr = &r_info[get_mon_num(creature_ptr, 0, MAX_DEPTH, 0)];
         power = r_ptr->level + 10;
         desc = r_name + r_ptr->name;
         get_mon_num_prep(creature_ptr, NULL, NULL);
index 7b679c4..e1a293a 100644 (file)
@@ -250,7 +250,7 @@ bool build_type5(player_type *player_ptr, dun_data_type *dd_ptr)
 
         while (attempts--) {
             /* Get a (hard) monster type */
-            r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
+            r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level + 11, 0);
             r_ptr = &r_info[r_idx];
 
             /* Decline incorrect alignment */
@@ -462,7 +462,7 @@ bool build_type6(player_type *player_ptr, dun_data_type *dd_ptr)
 
         while (attempts--) {
             /* Get a (hard) monster type */
-            r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
+            r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level + 11, 0);
             r_ptr = &r_info[r_idx];
 
             /* Decline incorrect alignment */
@@ -743,7 +743,7 @@ bool build_type13(player_type *player_ptr, dun_data_type *dd_ptr)
 
         while (attempts--) {
             /* Get a (hard) monster type */
-            r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0, 0);
+            r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level + 0, 0);
             r_ptr = &r_info[r_idx];
 
             /* Decline incorrect alignment */
index 2cebfc5..c9b1d73 100644 (file)
@@ -93,7 +93,7 @@ bool build_type15(player_type *player_ptr, dun_data_type *dd_ptr)
                /* Place fixed lite berathers */
                for (dir1 = 4; dir1 < 8; dir1++)
                {
-                       MONRACE_IDX r_idx = get_mon_num(player_ptr, floor_ptr->dun_level, 0);
+                       MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
 
                        y = yval + 2 * ddy_ddd[dir1];
                        x = xval + 2 * ddx_ddd[dir1];
@@ -157,7 +157,7 @@ bool build_type15(player_type *player_ptr, dun_data_type *dd_ptr)
                g_ptr->feat = feat_glass_wall;
                get_mon_num_prep(player_ptr, vault_aux_lite, NULL);
 
-               r_idx = get_mon_num(player_ptr, floor_ptr->dun_level, 0);
+               r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
                if (r_idx) place_monster_aux(player_ptr, 0, yval, xval, r_idx, 0L);
 
                /* Walls around the breather */
@@ -224,7 +224,7 @@ bool build_type15(player_type *player_ptr, dun_data_type *dd_ptr)
                /* Place shard berathers */
                for (dir1 = 4; dir1 < 8; dir1++)
                {
-                       MONRACE_IDX r_idx = get_mon_num(player_ptr, floor_ptr->dun_level, 0);
+                       MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
 
                        y = yval + ddy_ddd[dir1];
                        x = xval + ddx_ddd[dir1];
index 0f87b22..a3b6d43 100644 (file)
@@ -35,7 +35,7 @@ static MONRACE_IDX poly_r_idx(player_type *caster_ptr, MONRACE_IDX r_idx)
     DEPTH lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
     MONRACE_IDX r;
     for (int i = 0; i < 1000; i++) {
-        r = get_mon_num(caster_ptr, (caster_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5, 0);
+        r = get_mon_num(caster_ptr, 0, (caster_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5, 0);
         if (!r)
             break;