summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilepick.cc
diff options
context:
space:
mode:
authorJohanna Ploog <j-p-e-g@users.sourceforge.net>2010-01-11 20:46:21 +0100
committerJohanna Ploog <j-p-e-g@users.sourceforge.net>2010-01-11 21:33:48 +0100
commitbd7a961334fbcc180bfb39501bd7948dc961868c (patch)
treea6bc822837eb555e4a1ff34327af47cd8389f327 /crawl-ref/source/tilepick.cc
parent04163afa8a2c64c15323834a89e2425cc7f4b126 (diff)
downloadcrawl-ref-bd7a961334fbcc180bfb39501bd7948dc961868c.tar.gz
crawl-ref-bd7a961334fbcc180bfb39501bd7948dc961868c.zip
Implement rltiles %weight command and skewed dngn tile probabilities.
In dc-dngn.txt you can now use the %weight command to specify the probability of a given tile whenever a variant is chosen randomly from a set of variant tiles. Example: %weight 5 floor/floor_sand_stone0 FLOOR_SAND_STONE floor/floor_sand_stone1 floor/floor_sand_stone2 floor/floor_sand_stone3 %weight 2 floor/floor_sand_stone4 floor/floor_sand_stone5 floor/floor_sand_stone7 %weight 1 floor/floor_sand_stone6 ... will make plain sand more likely than the rocky versions and the big rock rarer than the smaller ones. This is not visible from the dngn.png but you can check the (cumulative) weights in tiledef-dngn.cc. Aside from the above, this is also used for the brick wall in all its colorations. (The repeat command also repeats the weight settings.)
Diffstat (limited to 'crawl-ref/source/tilepick.cc')
-rw-r--r--crawl-ref/source/tilepick.cc26
1 files changed, 22 insertions, 4 deletions
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index d56139759a..999a8d38ca 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -4510,6 +4510,26 @@ void tile_init_flavour()
tile_init_flavour(*ri);
}
+static int _pick_random_dngn_tile(unsigned int idx)
+{
+ ASSERT(idx >= 0 && idx < TILE_DNGN_MAX);
+ const int count = tile_dngn_count(idx);
+ if (count == 1)
+ return (idx);
+
+ const int total = tile_dngn_probs(idx + count - 1);
+ const int rand = random2(total);
+
+ for (int i = 0; i < count; ++i)
+ {
+ int curr = idx + i;
+ if (rand < tile_dngn_probs(curr))
+ return (curr);
+ }
+
+ return (idx);
+}
+
void tile_init_flavour(const coord_def &gc)
{
if (!map_bounds(gc))
@@ -4521,8 +4541,7 @@ void tile_init_flavour(const coord_def &gc)
int colour = env.grid_colours(gc);
if (colour)
floor_base = tile_dngn_coloured(floor_base, colour);
- int floor_rnd = random2(tile_dngn_count(floor_base));
- env.tile_flv(gc).floor = floor_base + floor_rnd;
+ env.tile_flv(gc).floor = _pick_random_dngn_tile(floor_base);
}
if (!env.tile_flv(gc).wall)
@@ -4531,8 +4550,7 @@ void tile_init_flavour(const coord_def &gc)
int colour = env.grid_colours(gc);
if (colour)
wall_base = tile_dngn_coloured(wall_base, colour);
- int wall_rnd = random2(tile_dngn_count(wall_base));
- env.tile_flv(gc).wall = wall_base + wall_rnd;
+ env.tile_flv(gc).wall = _pick_random_dngn_tile(wall_base);
}
if (feat_is_door(grd(gc)))