For example, for a multiplayer game, we would like to have patches not be generally bigger than 1 million by a significant quantity after exploring out a reasonable way. We don't want to disable any of the range growth settings, just apply an approximate cap.
I have made a hack to the mod to achieve this (won't publish), but I'm not great at maths so it contains some bodges to avoid the worst side effects.
Included below as a demonstration of the concept.
Changes to control.lua commented
Code: Select all
--[[ entity-field ]]--
--Muppet - modified constructor to add no_reduce (optional argument)
local function spawn_resource_ore(surface, rname, pos, size, richness, startingArea, restrictions, rng, no_reduce)
-- blob generator, centered at pos, size controls blob diameter
restrictions = restrictions or ''
debug("Entering spawn_resource_ore "..rname.." at:"..pos.x..","..pos.y.." size:"..size.." richness:"..richness.." isStart:"..tostring(startingArea).." restrictions:"..restrictions)
--Muppet - added to capture size at start of function
local orig_size = size
size = modify_resource_size(rname, size, startingArea)
local radius = size / 2 -- to radius
Code: Select all
if startingArea then
richnessMultiplier = settings.global["rso-starting-richness-mult"].value
end
-- if game.players[1] then
-- game.players[1].print("Spawning "..rname.." total amount "..(approxDepositSize + validCount * min_amount)*richnessMultiplier)
-- end
--Muppet - START
local function utillogging_log(text)
if game ~= nil then
game.write_file("RsoMuppet_logOutput.txt", tostring(text) .. "\r\n", true)
end
end
local simple_debug_logging = false
local detailed_debug_logging = false
local approxPatchSize = (approxDepositSize + validCount * min_amount)*richnessMultiplier
if detailed_debug_logging then utillogging_log("RSO stock ore: "..rname.." --- at:"..pos.x..","..pos.y.. " --- approxPatchSize: " .. approxPatchSize .. " --- orig_size: " .. orig_size .. " --- richness: " .. richness) end
local prefered_max_patch_size = 1000000 -- hard coded for test
--Only regenerate once if too large
if (no_reduce == nil or no_reduce == false) and approxPatchSize > prefered_max_patch_size then
local reduce_factor = math.min(((prefered_max_patch_size / approxPatchSize) * 1.5), 0.8)
local size_reduce_random = (rng(9, 11) / 10)*1.5
local richness_reduce_random = (rng(9, 11) / 10)/1.5
if detailed_debug_logging then utillogging_log("reducing to: " .. reduce_factor .. " --- size_reduce_random: " .. size_reduce_random .. " --- richness_reduce_random: " .. richness_reduce_random) end
orig_size = math.min((orig_size * (size_reduce_random * reduce_factor)), orig_size)
richness = richness * (richness_reduce_random * reduce_factor)
if detailed_debug_logging then utillogging_log("REDCUED ore request: "..rname.." --- at:"..pos.x..","..pos.y.. " --- orig_size: " .. orig_size .. " --- richness: " .. richness) end
return spawn_resource_ore(surface, rname, pos, orig_size, richness, startingArea, restrictions, rng, true)
else
if detailed_debug_logging then utillogging_log("") end
if simple_debug_logging then utillogging_log("ore generated: "..rname.." --- at:"..pos.x..","..pos.y.. " --- approxPatchSize: " .. approxPatchSize) end
end
--Muppet - END
-- infinite ore handling for Angels Ores mod
local infiniteOrePresent = false
local infiniteOreName = "infinite-"..rname
Initial patches generated by radar from outer left side inwards