From 45f4cbdfde715727c6600cadce505f1caaf5e235 Mon Sep 17 00:00:00 2001 From: deskull Date: Tue, 26 Jan 2021 07:43:37 +0900 Subject: [PATCH] =?utf8?q?[Fix]=20#41316=20get=5Fmon=5Fnum()=20=E3=81=AB?= =?utf8?q?=E6=9C=80=E5=B0=8F=E7=94=9F=E6=88=90=E9=9A=8E=E7=AF=84=E5=9B=B2?= =?utf8?q?=E8=BF=BD=E5=8A=A0=EF=BC=8E=20/=20Add=20min=20level=20range=20to?= =?utf8?q?=20get=5Fmon=5Fnum().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 将来の拡張と、whileループでget_mon_num()の内容繰り返すのは問題と判断したため. --- src/birth/inventory-initializer.c | 2 +- src/core/player-processor.c | 2 +- src/dungeon/quest.c | 2 +- src/market/arena.c | 2 +- src/market/bounty.c | 6 ++--- src/market/building-quest.c | 4 ++-- src/monster-floor/monster-generator.c | 6 ++--- src/monster-floor/monster-summon.c | 2 +- src/monster-floor/one-monster-placer.c | 2 +- src/monster-race/monster-race-hook.c | 4 ++-- src/monster/monster-list.c | 41 +++++++++++++++++---------------- src/monster/monster-list.h | 2 +- src/object-enchant/apply-magic-others.c | 2 +- src/player/eldritch-horror.c | 2 +- src/room/rooms-pit-nest.c | 6 ++--- src/room/rooms-special.c | 6 ++--- src/spell-kind/spells-polymorph.c | 2 +- 17 files changed, 46 insertions(+), 47 deletions(-) diff --git a/src/birth/inventory-initializer.c b/src/birth/inventory-initializer.c index 65aedcffe..49f83beca 100644 --- a/src/birth/inventory-initializer.c +++ b/src/birth/inventory-initializer.c @@ -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); diff --git a/src/core/player-processor.c b/src/core/player-processor.c index c1be1d5f4..c38bb697a 100644 --- a/src/core/player-processor.c +++ b/src/core/player-processor.c @@ -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); diff --git a/src/dungeon/quest.c b/src/dungeon/quest.c index 834b9701a..de138444e 100644 --- a/src/dungeon/quest.c +++ b/src/dungeon/quest.c @@ -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]; diff --git a/src/market/arena.c b/src/market/arena.c index 4daa4bf67..16ef04c54 100644 --- a/src/market/arena.c +++ b/src/market/arena.c @@ -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; diff --git a/src/market/bounty.c b/src/market/bounty.c index 31f58c7ef..1e19f1cf5 100644 --- a/src/market/bounty.c +++ b/src/market/bounty.c @@ -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]]; diff --git a/src/market/building-quest.c b/src/market/building-quest.c index 72c9d87db..744a0fd31 100644 --- a/src/market/building-quest.c +++ b/src/market/building-quest.c @@ -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]; } diff --git a/src/monster-floor/monster-generator.c b/src/monster-floor/monster-generator.c index 3b04cd19e..5021a2f14 100644 --- a/src/monster-floor/monster-generator.c +++ b/src/monster-floor/monster-generator.c @@ -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; diff --git a/src/monster-floor/monster-summon.c b/src/monster-floor/monster-summon.c index d33afacf0..06eb662dd 100644 --- a/src/monster-floor/monster-summon.c +++ b/src/monster-floor/monster-summon.c @@ -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; diff --git a/src/monster-floor/one-monster-placer.c b/src/monster-floor/one-monster-placer.c index ddf4a7f78..11c263826 100644 --- a/src/monster-floor/one-monster-placer.c +++ b/src/monster-floor/one-monster-placer.c @@ -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; } diff --git a/src/monster-race/monster-race-hook.c b/src/monster-race/monster-race-hook.c index 9148c24ed..16d552b5a 100644 --- a/src/monster-race/monster-race-hook.c +++ b/src/monster-race/monster-race-hook.c @@ -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; } diff --git a/src/monster/monster-list.c b/src/monster/monster-list.c index 60ce8c287..3edca7b92 100644 --- a/src/monster/monster-list.c +++ b/src/monster/monster-list.c @@ -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; diff --git a/src/monster/monster-list.h b/src/monster/monster-list.h index 1cbc0b175..00f9e0cef 100644 --- a/src/monster/monster-list.h +++ b/src/monster/monster-list.h @@ -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); diff --git a/src/object-enchant/apply-magic-others.c b/src/object-enchant/apply-magic-others.c index c0d8dbb00..057d94600 100644 --- a/src/object-enchant/apply-magic-others.c +++ b/src/object-enchant/apply-magic-others.c @@ -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) diff --git a/src/player/eldritch-horror.c b/src/player/eldritch-horror.c index 6d497faa9..cf97f23d5 100644 --- a/src/player/eldritch-horror.c +++ b/src/player/eldritch-horror.c @@ -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); diff --git a/src/room/rooms-pit-nest.c b/src/room/rooms-pit-nest.c index 7b679c41f..e1a293a63 100644 --- a/src/room/rooms-pit-nest.c +++ b/src/room/rooms-pit-nest.c @@ -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 */ diff --git a/src/room/rooms-special.c b/src/room/rooms-special.c index 2cebfc59d..c9b1d7306 100644 --- a/src/room/rooms-special.c +++ b/src/room/rooms-special.c @@ -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]; diff --git a/src/spell-kind/spells-polymorph.c b/src/spell-kind/spells-polymorph.c index 0f87b22ad..a3b6d43f8 100644 --- a/src/spell-kind/spells-polymorph.c +++ b/src/spell-kind/spells-polymorph.c @@ -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; -- 2.11.0