diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index d9ad0bfcf40..ac4d19756da 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -507,16 +507,6 @@ static void _handle_spectral_cloud(const cloud_struct& cloud) 100, RANDOM_MONSTER, 0); - if (basetype == RANDOM_MONSTER && one_chance_in(4)) - { - do - { - basetype = pick_random_zombie(); - } - while (mons_class_flag(basetype, M_NO_GEN_DERIVED) - || !monster_habitable_grid(basetype, grd(cloud.pos))); - } - monster* agent = monster_by_mid(cloud.source); create_monster(mgen_data(MONS_SPECTRAL_THING, (cloud.whose == KC_OTHER ? diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 2d7c58326c1..4b7c0f27d5a 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -3533,11 +3533,31 @@ static void _place_aquatic_monsters() false); } +static vector _zombifiables() +{ + vector z; + for (monster_type mcls = MONS_0; mcls < NUM_MONSTERS; ++mcls) + { + if (mons_species(mcls) != mcls + || !mons_zombie_size(mcls) + || mons_is_unique(mcls) + || mons_class_holiness(mcls) != MH_NATURAL + || mons_class_flag(mcls, M_NO_GEN_DERIVED)) + { + continue; + } + + z.push_back(mcls); + } + return z; +} + // For Crypt, adds a bunch of skeletons and zombies that do not respect // absdepth (and thus tend to be varied and include several types that // would not otherwise spawn there). static void _place_assorted_zombies() { + static const vector zombifiable = _zombifiables(); int num_zombies = random_range(6, 12, 3); for (int i = 0; i < num_zombies; ++i) { @@ -3545,16 +3565,15 @@ static void _place_assorted_zombies() monster_type z_base; do { - z_base = pick_random_zombie(); + z_base = zombifiable[random2(zombifiable.size())]; } - while (mons_class_flag(z_base, M_NO_GEN_DERIVED) - || !(skel ? mons_skeleton(z_base) : mons_zombifiable(z_base))); + while (skel && !mons_skeleton(z_base)); mgen_data mg; mg.cls = (skel ? MONS_SKELETON : MONS_ZOMBIE); mg.base_type = z_base; - mg.behaviour = BEH_SLEEP; - mg.map_mask |= MMT_NO_MONS; + mg.behaviour = BEH_SLEEP; + mg.map_mask |= MMT_NO_MONS; mg.preferred_grid_feature = DNGN_FLOOR; place_monster(mg); diff --git a/crawl-ref/source/mon-place.cc b/crawl-ref/source/mon-place.cc index efe64196905..2caccca5b46 100644 --- a/crawl-ref/source/mon-place.cc +++ b/crawl-ref/source/mon-place.cc @@ -1816,31 +1816,6 @@ static monster* _place_monster_aux(const mgen_data &mg, const monster *leader, return mon; } -monster_type pick_random_zombie() -{ - static vector zombifiable; - - if (zombifiable.empty()) - { - for (monster_type mcls = MONS_0; mcls < NUM_MONSTERS; ++mcls) - { - if (mons_species(mcls) != mcls || mcls == MONS_PROGRAM_BUG) - continue; - - if (!mons_zombie_size(mcls) || mons_is_unique(mcls)) - continue; - if (mons_class_holiness(mcls) != MH_NATURAL) - continue; - - zombifiable.push_back(mcls); - } - - ASSERT(!zombifiable.empty()); - } - - return zombifiable[random2(zombifiable.size())]; -} - // Check base monster class against zombie type and position if set. static bool _good_zombie(monster_type base, monster_type cs, const coord_def& pos) diff --git a/crawl-ref/source/mon-place.h b/crawl-ref/source/mon-place.h index 56866eee156..dcfd6a3bdbf 100644 --- a/crawl-ref/source/mon-place.h +++ b/crawl-ref/source/mon-place.h @@ -49,8 +49,6 @@ const monster_type fixup_zombie_type(const monster_type cls, * *********************************************************************** */ monster* place_monster(mgen_data mg, bool force_pos = false, bool dont_place = false); -monster_type pick_random_zombie(); - /* *********************************************************************** * Returns a monster class type of a zombie for generation * on the player's current level.