summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-01-10 13:50:07 -0600
committerJesse Luehrs <doy@tozt.net>2010-01-10 13:54:23 -0600
commitc5f8606a36bad92d01f0672ccdf7b647e4ddde02 (patch)
tree36dd816fa08117e22e781d138b1f6c596fac0204 /crawl-ref/source/dungeon.cc
parent67cbd7ec7637054540c4f8a547c92790a6a5ba9c (diff)
downloadcrawl-ref-c5f8606a36bad92d01f0672ccdf7b647e4ddde02.tar.gz
crawl-ref-c5f8606a36bad92d01f0672ccdf7b647e4ddde02.zip
better plant clumping algorithm
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc62
1 files changed, 53 insertions, 9 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 09949dca20..168cb760d0 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -7792,21 +7792,65 @@ static void _add_plant_clumps()
{
for (rectangle_iterator ri(1); ri; ++ri)
{
- if (grd(*ri) != DNGN_FLOOR || !one_chance_in(500))
+ mgen_data mg;
+ if (mgrd(*ri) != NON_MONSTER)
{
+ /* clump plants around things that already exist */
+ monster_type type = menv[mgrd(*ri)].type;
+ if ((type == MONS_PLANT || type == MONS_FUNGUS) &&
+ one_chance_in(10)) {
+ mg.cls = type;
+ }
+ else {
+ continue;
+ }
+ }
+ else {
continue;
}
- mgen_data mg;
- mg.cls = coinflip() ? MONS_PLANT : MONS_FUNGUS;
- mg.pos = *ri;
- mons_place(mgen_data(mg));
- for (adjacent_iterator ai(*ri); ai; ++ai)
+
+ std::vector<coord_def> to_place;
+ to_place.push_back(*ri);
+ for (int i = 1; i < 4; ++i)
+ {
+ for (radius_iterator rad(*ri, i, C_SQUARE); rad; ++rad)
+ {
+ if (grd(*rad) != DNGN_FLOOR)
+ {
+ continue;
+ }
+
+ /* make sure the iterator stays valid */
+ to_place.reserve((2 * i + 1) * (2 * i + 1));
+ for (std::vector<coord_def>::const_iterator it = to_place.begin();
+ it != to_place.end();
+ ++it)
+ {
+ if (*rad == *it)
+ {
+ continue;
+ }
+ /* only place plants next to previously placed plants */
+ if (abs(rad->x - it->x) <= 1 && abs(rad->y - it->y) <= 1)
+ {
+ if (one_chance_in(12)) {
+ to_place.push_back(*rad);
+ }
+ }
+ }
+ }
+ }
+
+ for (std::vector<coord_def>::const_iterator it = to_place.begin();
+ it != to_place.end();
+ ++it)
{
- if (grd(*ai) == DNGN_FLOOR && coinflip())
+ if (*it == *ri)
{
- mg.pos = *ai;
- mons_place(mgen_data(mg));
+ continue;
}
+ mg.pos = *it;
+ mons_place(mgen_data(mg));
}
}
}