git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7675 c06c8d41-db1a-0410-9941-cceddc491573
6IHRQWBU55WYBVB7K5HDJSBISE3J3VILUCMQ6WYOBUZ43DLOQ6VQC
YZU6Y4JJYKMEHFDR23YLVSGOFSKZZRERISOVR6RKQV3FHI2SOKOQC
FG7PALO63I4PMK3AFWUOXQX3WM5ECQHYGFGSM2FRSKZNUYBYVDIAC
CM2YC5KBTUB4JFT3CL3NRS7V5X76M7RI7SNT4XK6IOVBZA2URRKAC
X7MFMKQTNZ2IWBFVGS6WQV7NRNKJ3DWQAW2X7IQMFQQXW24AHPZQC
NKONHW4JNY6HP2M63MNPM3H64ZWSUNUT5FX2STW4KTS4AMXJXXVQC
5DECJIOSMFWX7DMDTGVNPNV6QQP6O34F3XHFHRXGCTJUZMVIXT7QC
DUFJKFM5KBCM4272ZKLBPGKHLMDLK6RABUNTDEWRZULTKDTHHSBAC
QUBF42IFKP3BUZWT4I4VKFCOK43GAADT7A2FNNFZQZ7YBZDY2ZWAC
ZBPIF2QM5SLTOSDD65YJQFUPY2LRBRFROVU6C2KLQK474JJRBGBAC
IHV7JHD4E67NEGLZEO3FPQGJPJF3IAV6QV5A63FPG4SU2VRFV47QC
NCKCO6W5HW7C6OPJG4EVHKQCDX6AL7S4ACORY45STKQTNPMAJ7IQC
GLDM7OPM3D2DFU5QFKOSZY36EWJJJEV6CH6GPQLDZO35X7CWAIRQC
local function depth_ge(lev, spec)
return depth_if(spec, function ()
return zig().depth >= lev
end)
local function depth_ge(lev)
return function ()
return zig().depth >= lev
end
end
local function depth_range(low, high)
return function ()
local depth = zig().depth
return depth >= low and depth <= high
end
local mons_populations = {
-- Dress up monster sets a bit.
"place:Elf:$ w:300 / deep elf blademaster / deep elf master archer / " ..
"deep elf annihilator / deep elf sorcerer / deep elf demonologist",
"place:Orc:$ w:120 / orc warlord / orc knight / stone giant",
"place:Vault:$",
with_props("place:Slime:$", { jelly_protect = true }),
"place:Snake:$",
"place:Lair:$",
"place:Tomb:$ w:200 / greater mummy",
"place:Crypt:$",
"place:Abyss",
"place:Shoal:$",
"place:Coc:$",
"place:Geh:$",
"place:Dis:$",
"place:Tar:$",
"daeva / angel",
depth_ge(6, "place:Pan w:400 / w:15 pandemonium lord"),
depth_lt(6, "place:Pan")
}
local mons_populations = { }
local function mset(...)
util.foreach({ ... }, function (spec)
table.insert(mons_populations, spec)
end)
end
local function mons_random_gen(x, y, nth)
set_random_floor_colour()
local mgen = nil
while not mgen do
mgen = monster_creator_fn(util.random_from(mons_populations))
if mgen then
mgen = mgen.fn
end
end
return mgen(x, y, nth)
local function mset_if(condition, ...)
mset(unpack(util.map(util.curry(spec_if, condition), { ... })))
mset("place:Elf:$ w:300 / deep elf blademaster / deep elf master archer / " ..
"deep elf annihilator / deep elf sorcerer / deep elf demonologist",
"place:Orc:$ w:120 / orc warlord / orc knight / stone giant",
"place:Vault:$",
with_props("place:Slime:$", { jelly_protect = true }),
"place:Snake:$",
with_props("place:Lair:$", { weight = 5 }),
"place:Tomb:$ w:200 / greater mummy",
"place:Crypt:$",
"place:Abyss",
"place:Shoal:$",
"place:Coc:$",
"place:Geh:$",
"place:Dis:$",
"place:Tar:$",
"daeva / angel")
mset_if(depth_ge(6), "place:Pan w:400 / w:15 pandemonium lord")
mset_if(depth_lt(6), "place:Pan")
local mons_generators = {
mons_random_gen,
depth_ge(6, mons_drac_gen),
depth_ge(8, mons_panlord_gen)
}
mset_if(depth_ge(6), mons_drac_gen)
mset_if(depth_ge(8), mons_panlord_gen)
end
function util.random_weighted_from(weightfn, list)
if type(weightfn) ~= "function" then
weightfn = function (table)
return table[weightfn]
end
end
local cweight = 0
local chosen = nil
util.foreach(list,
function (e)
local wt = weightfn(e) or 10
cweight = cweight + wt
if crawl.random2(cweight) < wt then
chosen = e
end
end)
return chosen