1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Order of operations on Misc vs ores in map layout to allow glitter to take effect. Also implemented the poisson RNG

This commit is contained in:
TWLTriston 2017-11-15 05:53:49 -05:00
parent e998051e7b
commit 11c7382607
4 changed files with 36 additions and 7 deletions

View File

@ -1,4 +1,6 @@
require("locale.gen_combined.grilledham_map_gen.builders")
require("locale.gen_shared.poisson")
local Thread = require "locale.utils.Thread"
@ -214,7 +216,7 @@ function check_decorative(tile, x, y)
for _,e in ipairs(options) do
name = e[1]
high_roll = e[2]
if math.random(1, high_roll) == 1 then
if poison_rng_next(high_roll / 2 ) == 1 then
table.insert(tile_decoratives, {name=name, amount=1, position={x,y}})
end
end
@ -321,7 +323,7 @@ function check_entities(tile, x, y)
for _,e in ipairs(options) do
name = e[1]
high_roll = e[2]
if math.random(1, high_roll) == 1 then
if poison_rng_next( high_roll / 2 ) == 1 then
table.insert(tile_entity_list, {name=name, position={x,y}})
end
end

View File

@ -16,7 +16,7 @@ function run_ores_module_setup()
["stone"] = 0.25
}
-- 1-100% chance of sprinkling any individual ore
sprinkle_factor = 10
sprinkle_factor = 20
-- Sets the buffer distance before ores are scrambled
starting_buffer = 125

View File

@ -0,0 +1,27 @@
local function generate_pmf_chart(l)
chart = {[0] = math.exp(-l)}
for k=1,(l*2 + 1) do
chart[k] = (chart[k - 1] * l / k)
end
return chart
end
local function generate_poisson_set(l, n) --n defines the resolution
local chart = generate_pmf_chart(l)
local set = {}
for x,y in pairs(chart) do
local m = math.floor(y * n + 0.5)
for i=0,m do
table.insert(set,x)
end
end
return set
end
global.poisson_set = {}
function poison_rng_next(l)
if not global.poisson_set[l] then
global.poisson_set[l] = generate_poisson_set(l, 1000)
end
return global.poisson_set[l][math.random(1000)]
end

View File

@ -52,7 +52,7 @@ MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.GoT"
--ores--
--require "locale.gen_ores.neko_crazy_ores"
--require "locale.gen_ores.fluffy_rainbows"
--require "locale.gen_ores.rso.rso_control"
require "locale.gen_ores.rso.rso_control"
--require "locale.gen_ores.harmonic_gen"
--everything else. You may use more than one of these, but beware they might not be compatible
@ -87,12 +87,12 @@ local on_chunk_generated = function(event)
end
else
run_combined_module(event)
for _,v in pairs(miscs) do
v.on_chunk_generated(event)
end
if run_ores_module ~= nil then
run_ores_module(event)
end
for _,v in pairs(miscs) do
v.on_chunk_generated(event)
end
end
end