Merge pull request 'MAPGEN/tsm_railcorridors: Generate pig spawners in mineshafts' (#127) from mineshaft-pig-spawners into master

Reviewed-on: https://git.minetest.land/Mineclonia/Mineclonia/pulls/127
Reviewed-by: E <e@noreply.git.minetest.land>
This commit is contained in:
erlehmann 2021-07-23 02:24:17 +00:00
commit 45cdad7283
2 changed files with 20 additions and 5 deletions

View file

@ -51,9 +51,22 @@ function tsm_railcorridors.get_default_treasure(pr)
-- UNUSED IN MINECLONE 2!
end
-- All spawners spawn cave spiders
function tsm_railcorridors.on_construct_spawner(pos)
mcl_mobspawners.setup_spawner(pos, "mobs_mc:cave_spider", 0, 7)
-- Almost all spawners spawn cave spiders, but there is a 1 in 1000
-- chance to spawn a pig spawner instead, inspired by multiple bugs
-- in Minecraft that turn spawners in Mineshafts into pig spawners.
-- (Basically any spawner bug in Minecraft generates pig spawners.)
--
-- The Minecraft chance to get a pig spawner here is way lower than
-- 1 in 1000, but because of the small size of Minetest worlds, the
-- Minecraft chance would risk not having a pig spawner in a world.
--
-- The world with the seed “pigs” generates a pig spawner at 3,-8,7
function tsm_railcorridors.on_construct_spawner(pos, pr)
if pr:next(1,1000) == 900 then
mcl_mobspawners.setup_spawner(pos, "mobs_mc:pig", 0, 7)
else
mcl_mobspawners.setup_spawner(pos, "mobs_mc:cave_spider", 0, 7)
end
end
-- MineClone 2's treasure function. Gets all treasures for a single chest.

View file

@ -114,7 +114,7 @@ if not tsm_railcorridors.nodes.corridor_woods_function then
end
-- Random Perlin noise generators
local pr, pr_carts, pr_treasures, pr_deco, webperlin_major, webperlin_minor
local pr, pr_carts, pr_spawner, pr_treasures, pr_deco, webperlin_major, webperlin_minor
local function InitRandomizer(seed)
-- Mostly used for corridor gen.
@ -123,6 +123,8 @@ local function InitRandomizer(seed)
pr_deco = PseudoRandom(seed+25)
-- Separate randomizer for carts because spawning carts is very timing-dependent
pr_carts = PseudoRandom(seed-654)
-- Spawner type randomiser
pr_spawner = PseudoRandom(seed+345)
-- Chest contents randomizer
pr_treasures = PseudoRandom(seed+777)
-- Used for cobweb generation, both noises have to reach a high value for cobwebs to appear
@ -751,7 +753,7 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d
if place_cobwebs then
Cube(p, size, {name=tsm_railcorridors.nodes.cobweb}, true)
end
tsm_railcorridors.on_construct_spawner(p)
tsm_railcorridors.on_construct_spawner(p, pr_spawner)
no_spawner = true
end
end