git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5099 c06c8d41-db1a-0410-9941-cceddc491573
QTAXF435XPFZWNFZHMUKPQ7UVNLUK6TG5ER4MKDY25BZF5PZ4JLAC 2C6B6QRTOK2ZMK2ZOF3EPSFUZTKG5B3IZXWBWIUYC4ZOVGQ2OV2QC W52PCSHX72WAMWKG6L4BPUBVMO6E72KYYBNKAA7554KNOTY6V7WQC RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC B7MSPF6X2RLGWN4M6ZZF3WSOPKGYPTTD7LIJVST7DXN27DG6JHNAC K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC W45PMU4HNPSAMMEBJ4XH4MTHLPVIASZT4FXTBPID5LFXKIMNUBKAC NVSFIV2ZKP44XHCSCXG6OZVGL67OIFINC34J2EMKTA4KULCERUEAC 45EMD3KLQPMERNMIKU5G76H6556XOMIW352TSBP7VLWJX2YYGS7AC KCHX2F3JFEWOZT3WMJVZAAQUU2QSZ5Q7RDCD7WUJ7VE65J52JFUQC ILOED4VB4I6VPAUTR75ZWX6MXDYXB5DO2EDK2UH67O3HNKWV23RQC int temp_rand = 0; // probability determination {dlb}unsigned char width = (10 - random2(7)); // value range of [4,10] {dlb}_replace_area(10, 10, (GXM - 10), (10 + width), DNGN_ROCK_WALL, DNGN_FLOOR);_replace_area(10, (60 - width), (GXM - 10), (GYM - 10),DNGN_ROCK_WALL, DNGN_FLOOR);_replace_area(10, 10, (10 + width), (GYM - 10), DNGN_ROCK_WALL, DNGN_FLOOR);_replace_area((60 - width), 10, (GXM - 10), (GYM - 10),DNGN_ROCK_WALL, DNGN_FLOOR);// possible early returns {dlb}:temp_rand = random2(4);if (temp_rand > 2) // 25% chance {dlb}return 3;else if (temp_rand > 1) // 25% chance {dlb}return 2;else // 50% chance {dlb}{unsigned char width2 = (coinflip()? (1 + random2(5)) : 5);_replace_area(10, (35 - width2), (GXM - 10), (35 + width2),DNGN_ROCK_WALL, DNGN_FLOOR);_replace_area((40 - width2), 10, (40 + width2), (GYM - 10),DNGN_ROCK_WALL, DNGN_FLOOR);}// possible early returns {dlb}:temp_rand = random2(4);if (temp_rand > 2) // 25% chance {dlb}return 3;else if (temp_rand > 1) // 25% chance {dlb}return 2;else // 50% chance {dlb}{temp_rand = random2(15);if (temp_rand > 7) // 7 in 15 odds {dlb}{spec_room sr;sr.x1 = 25;sr.y1 = 25;sr.x2 = (GXM - 25);sr.y2 = (GYM - 25);int oblique_max = 0;if (coinflip())oblique_max = 5 + random2(20);
dungeon_feature_type floor_type =((temp_rand > 1) ? DNGN_FLOOR : // 5/7(temp_rand > 0) ? DNGN_DEEP_WATER// 1/7: DNGN_LAVA); // 1/7_octa_room(sr, oblique_max, floor_type);}}
bool success = _build_vaults(level_number, vault);_ensure_vault_placed(success);
function spotty_level(boxy, x1, y1, x2, y2)local iterations-- boxy levels have more clearing, so they get fewer iterationsif boxy theniterations = 200 + crawl.random2(750)elseiterations = 200 + crawl.random2(1500)endmake_spotty(iterations, boxy, x1, y1, x2, y2)end-- randomly turns walls into floorsfunction make_spotty(iterations, boxy, x1, y1, x2, y2)if x2 - x1 - 8 <= 0 or y2 - y1 - 8 <= 0 thenreturnendlocal wall = dgn.feature_number("rock_wall")local floor = dgn.feature_number("floor")for i = 1, iterations dolocal x, yrepeatx = crawl.random2(x2 - x1 - 7) + x1 + 4y = crawl.random2(y2 - y1 - 7) + y1 + 4until dgn.grid(x, y) ~= wall ordgn.grid(x-1, y) ~= wall ordgn.grid(x+1, y) ~= wall ordgn.grid(x, y-1) ~= wall ordgn.grid(x, y+1) ~= wall ordgn.grid(x-2, y) ~= wall ordgn.grid(x+2, y) ~= wall ordgn.grid(x, y-2) ~= wall ordgn.grid(x, y+2) ~= wall-- convenience functionfunction replace_grid(x, y, search, replace)if dgn.grid(x, y) == search thendgn.grid(x, y, replace)endendreplace_grid(x, y, wall, floor)replace_grid(x, y-1, wall, floor)replace_grid(x, y+1, wall, floor)replace_grid(x-1, y, wall, floor)replace_grid(x+1, y, wall, floor)if boxy thenreplace_grid(x-1, y-1, wall, floor)replace_grid(x+1, y+1, wall, floor)replace_grid(x-1, y+1, wall, floor)replace_grid(x+1, y-1, wall, floor)endendend-- randomly extends walls onto floorsfunction smear_feature(iterations, boxy, feature, x1, y1, x2, y2)for i = 1, iterations dolocal x, yfunction check_box(x, y, feature)return dgn.grid(x+1, y) == feature ordgn.grid(x-1, y) == feature ordgn.grid(x, y+1) == feature ordgn.grid(x, y-1) == featureendfunction check_diagonal(x, y, feature)return dgn.grid(x+1, y+1) == feature ordgn.grid(x-1, y+1) == feature ordgn.grid(x-1, y-1) == feature ordgn.grid(x+1, y-1) == featureendrepeatx = crawl.random2(x2 - x1 - 2) + x1 + 1y = crawl.random2(y2 - y1 - 2) + y1 + 1until dgn.grid(x, y) ~= feature and(check_box(x, y, feature) ornot boxy and check_diagonal(x, y, feature))dgn.grid(x, y, feature)endend}}############################################################### layout_forbidden_doughnut## This replaces dungeon.cc:_plan_1(). It usually creates a# room with a large hole in the middle.#NAME: layout_forbidden_donutORIENT: encompassTAGS: layout allow_dup{{local gxm, gym = dgn.max_bounds()local wall = dgn.feature_number("rock_wall")local floor = dgn.feature_number("floor")fill_area(0, 0, gxm - 1, gym - 1, wall)local width = (10 - crawl.random2(7))-- construct donutfill_area(10, 10, gxm - 10, 10 + width, floor)fill_area(10, 60 - width, gxm - 10, gym - 10, floor)fill_area(10, 10, 10 + width, gym - 10, floor)fill_area(60 - width, 10, gxm - 10, gym - 10, floor)local spotty = crawl.coinflip()local smears = crawl.random2(300)-- sometimes add a hallway cross through centerif crawl.coinflip() thenlocal width2 = 1 + crawl.random2(5)fill_area(10, gym/2 - width2, gxm - 10, gym/2 + width2, floor)fill_area(gxm/2 - width2, 10, gxm/2 + width2, gym - 10, floor)-- sometimes add a small octagon roomif crawl.coinflip() and crawl.random2(15) > 7 thenlocal oblique = 0if crawl.coinflip() thenoblique = 5 + crawl.random2(20)endlocal feature_name = select_from_weighted_table({["floor"] = 5,["deep_water"] = 1,["lava"] = 1,})local feature_idx = dgn.feature_number(feature_name)octa_room(25, 25, gxm - 25, gym - 25, oblique, feature_idx)-- decrease spotty chancespotty = crawl.one_chance_in(5)endendlocal spotty_boxy = crawl.coinflip()local smear_boxy = crawl.coinflip()if spotty thenspotty_level(spotty_boxy, 0, 0, gxm - 1, gym - 1)endif not spotty and crawl.one_chance_in(4) or spotty thensmear_feature(smears, smear_boxy, wall, 0, 0, gxm - 1, gym - 1)end