From 1161d234624340e15f6f4ae03a93370d7f8e1913 Mon Sep 17 00:00:00 2001 From: Jude Brown Date: Mon, 7 Dec 2009 15:25:03 +1000 Subject: Switch to dpeg's new unique placement system. Requires overall weight chance in unique.des and new dummies per-branch. --- crawl-ref/source/dungeon.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/dungeon.cc') 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 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) -- cgit v1.2.3-54-g00ecf