summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-12-07 15:25:03 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2009-12-07 15:25:03 +1000
commit1161d234624340e15f6f4ae03a93370d7f8e1913 (patch)
treeba813611bfcaef2f4395bcfc09dc0c817e3ceed0 /crawl-ref/source/dungeon.cc
parentb7cea23ab0edf2e10adbd2cdac0545ea765a0eaf (diff)
downloadcrawl-ref-1161d234624340e15f6f4ae03a93370d7f8e1913.tar.gz
crawl-ref-1161d234624340e15f6f4ae03a93370d7f8e1913.zip
Switch to dpeg's new unique placement system.
Requires overall weight chance in unique.des and new dummies per-branch.
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 9a22702dcc..bf7b6a756f 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -3603,8 +3603,27 @@ static int _place_uniques(int level_number, char level_type)
int num_placed = 0;
- while (coinflip())
+ // Magic numbers for dpeg's unique system.
+ int A = 3;
+ int B = 5;
+ while (one_chance_in(A))
{
+ // In dpeg's unique placement system, chances is always 1 in A of even
+ // starting to place a unique; reduced if there are less uniques to be
+ // placed or available. Then there is a chance of uniques_available /
+ // B; this only triggers on levels that have less than B uniques to be
+ // placed.
+ float this_chance = float(random2(100)) / 100.0;
+
+ std::vector<map_def> uniques_available =
+ find_maps_for_tag("place_unique", true, true);
+
+ float unique_chance = float(std::min(B,
+ int(uniques_available.size()))) / float(B);
+
+ if (this_chance >= unique_chance)
+ break;
+
const map_def *uniq_map = random_map_for_tag("place_unique", true);
if (!uniq_map)