mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
Modified OARC's RSO scenario code to genreate what we want. Removed biter logic and most of the non-RedMew specific stuff like infinite ores.
This commit is contained in:
parent
76f1abc216
commit
04a7829ea9
@ -1,25 +0,0 @@
|
||||
require("config")
|
||||
require("prototypes.prototype_utils")
|
||||
|
||||
for _, resource in pairs(data.raw.resource) do
|
||||
resetRichness(resource)
|
||||
end
|
||||
|
||||
if not settings.startup["rso-vanilla-biter-generation"].value then
|
||||
|
||||
for _, spawner in pairs(data.raw["unit-spawner"]) do
|
||||
removePeaks(spawner)
|
||||
end
|
||||
|
||||
for _, turret in pairs(data.raw.turret) do
|
||||
if turret.subgroup == "enemies" then
|
||||
removePeaks(turret)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if debug_items_enabled then
|
||||
data.raw["car"]["car"].max_health = 0x8000000
|
||||
data.raw["ammo"]["basic-bullet-magazine"].magazine_size = 1000
|
||||
data.raw["ammo"]["basic-bullet-magazine"].ammo_type.action[1].action_delivery[1].target_effects[2].damage.amount = 5000
|
||||
end
|
@ -1,4 +0,0 @@
|
||||
|
||||
if not RsoMod then
|
||||
RsoMod = {}
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
-- Keeping for reference of the mod extraction into local RedMew compatible softmod
|
||||
{
|
||||
"name": "rso-mod",
|
||||
"version": "3.4.2",
|
||||
"factorio_version": "0.15",
|
||||
"title": "Resource Spawner Overhaul",
|
||||
"author": "Dark, orzelek",
|
||||
"contact": "Message me on forums or use discussion board on mod portal",
|
||||
"homepage": "https://forums.factorio.com/viewforum.php?f=79",
|
||||
"description": "Overhauls resource spawning system.",
|
||||
"dependencies": [ "? bobenemies>=0.13.1", "? bobores", "? 5dim_ores"]
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
--[[--
|
||||
Simple logger by Dark
|
||||
--]]--
|
||||
|
||||
local _M = {}
|
||||
local Logger = {prefix='log_'}
|
||||
Logger.__index = Logger
|
||||
|
||||
function Logger:log(str)
|
||||
local run_time_s = math.floor(game.tick/60)
|
||||
local run_time_minutes = math.floor(run_time_s/60)
|
||||
local run_time_hours = math.floor(run_time_minutes/60)
|
||||
self.log_buffer[#self.log_buffer + 1] = string.format("%02d:%02d:%02d: %s\r\n", run_time_hours, run_time_minutes % 60, run_time_s % 60, str)
|
||||
end
|
||||
|
||||
function Logger:dump(file_name)
|
||||
if #self.log_buffer == 0 then return false end
|
||||
file_name = file_name or "logs/"..self.prefix..game.tick..".log"
|
||||
game.write_file(file_name, table.concat(self.log_buffer))
|
||||
self.log_buffer = {}
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function _M.new_logger()
|
||||
local temp = {log_buffer = {}}
|
||||
return setmetatable(temp, Logger)
|
||||
end
|
||||
return _M
|
@ -1,68 +0,0 @@
|
||||
|
||||
local blocksize=8
|
||||
local blocksizem1=blocksize-1
|
||||
local blocksized2=math.floor(blocksize/2)
|
||||
|
||||
local ti=table.insert
|
||||
|
||||
local function fill(surface, x0,y0,name,amount,step,shift)
|
||||
step=step or 1
|
||||
shift=shift or 0
|
||||
for y=y0+shift,y0+blocksize-1,step do
|
||||
for x=x0+shift,x0+blocksize-1,step do
|
||||
surface.create_entity{name=name,position={x,y},amount=amount}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function straightWorld(surface, leftTop, rightBottom)
|
||||
local lt = leftTop
|
||||
local rb = rightBottom
|
||||
for y0=lt.y,rb.y-1,blocksize do
|
||||
for x0=lt.x,rb.x-1,blocksize do
|
||||
local tile=surface.get_tile(x0,y0).name
|
||||
local tiles={}
|
||||
for y=y0,y0+blocksizem1 do
|
||||
for x=x0,x0+blocksizem1 do
|
||||
ti(tiles,{name=tile,position={x,y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
local ent=surface.find_entities{{x0,y0},{x0+blocksize,y0+blocksize}}
|
||||
local haveTree=false
|
||||
local amount=0
|
||||
local haveResource=false
|
||||
local haveDecor=false
|
||||
for _,e in ipairs(ent) do
|
||||
if e.position.x>=x0 and e.position.y>=y0 then
|
||||
if e.type=="resource" then
|
||||
haveResource=e.name
|
||||
amount=e.amount
|
||||
e.destroy()
|
||||
elseif e.type=="tree" then
|
||||
haveTree=e.name
|
||||
e.destroy()
|
||||
elseif e.type=="decorative" then
|
||||
haveDecor=e.name
|
||||
e.destroy()
|
||||
elseif e.type=="simple-entity" then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
if haveResource then
|
||||
if haveResource=="crude-oil" or string.sub(haveResource,1,4) == "lava" then
|
||||
surface.create_entity{name=haveResource,amount=amount,position={x0+blocksized2,y0+blocksized2}}
|
||||
else
|
||||
fill(surface, x0,y0,haveResource,amount)
|
||||
end
|
||||
end
|
||||
if not haveResource and haveTree then
|
||||
fill(surface, x0,y0,haveTree,nil,4)
|
||||
end
|
||||
if haveDecor then
|
||||
fill(surface, x0,y0,haveDecor,nil,2,1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,47 +0,0 @@
|
||||
require("config")
|
||||
|
||||
local blocksize=6
|
||||
local blockThreshold=straightWorldPlatformsThreshold
|
||||
local blocksizem1=blocksize-1
|
||||
local platformName = "building-platform"
|
||||
|
||||
function straightWorldPlatforms(surface, leftTop, rightBottom)
|
||||
local lt = leftTop
|
||||
local rb = rightBottom
|
||||
if surface == nil then
|
||||
return
|
||||
end
|
||||
for y0=lt.y,rb.y-1,blocksize do
|
||||
for x0=lt.x,rb.x-1,blocksize do
|
||||
--Check all blocks for platforms
|
||||
local replaceBlocks = false
|
||||
local blockCount = 0
|
||||
for y1=y0,y0+blocksizem1 do
|
||||
for x1=x0,x0+blocksizem1 do
|
||||
local tileObj = surface.get_tile(x1,y1)
|
||||
if tileObj ~= nil and tileObj.valid then
|
||||
local tile=tileObj.name
|
||||
if tile == platformName then
|
||||
blockCount = blockCount + 1
|
||||
end
|
||||
if blockCount > (blocksize * blocksize) * blockThreshold then
|
||||
replaceBlocks = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if replaceBlocks == true then break end
|
||||
end
|
||||
--if enough platforms are found, replace the blocks
|
||||
if replaceBlocks then
|
||||
local tiles={}
|
||||
for y=y0,y0+blocksizem1 do
|
||||
for x=x0,x0+blocksizem1 do
|
||||
table.insert(tiles,{name=platformName,position={x,y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,39 +0,0 @@
|
||||
[mod-setting-name]
|
||||
rso-vanilla-biter-generation=Use vanilla biter generation
|
||||
rso-biter-generation=Use RSO biter generation
|
||||
rso-use-donuts=Use donut shapes
|
||||
rso-starting-richness-mult=Starting richness multiplier
|
||||
rso-global-richness-mult=Global richness multiplier
|
||||
rso-global-size-mult=Resource patch size multiplier
|
||||
rso-resource-chance=Resource chance
|
||||
rso-region-size=Size of generation region
|
||||
rso-enemy-chance=Enemy base chance
|
||||
rso-enemy-base-size=Enemy base size
|
||||
rso-remove-trees=Remove trees
|
||||
rso-infinite-ores-in-start-area=Use Angel's infinite ores in start area
|
||||
rso-infinite-ore-threshold=Angel's infinite ore threshold
|
||||
rso-reveal-spawned-resources=Reveal spawned resources
|
||||
rso-distance-exponent=Distance ore richness exponent
|
||||
rso-fluid-distance-exponent=Distance fluid richness exponent
|
||||
rso-size-exponent=Distance size exponent
|
||||
rso-multi-resource-active=Multiple resources per spawn functionality
|
||||
|
||||
[mod-setting-description]
|
||||
rso-vanilla-biter-generation=When enabled RSO will use vanilla biter generation. Can be used along with RSO generation.
|
||||
rso-biter-generation=Controls RSO built in biter generator. It's more sparse then vanilla one to allow for resource scouting.
|
||||
rso-use-donuts=Enabling this settings will add donut as possible shape type for ore patches. It will make ore patch layouts more varied.
|
||||
rso-starting-richness-mult=Richness of all starting resource patches will be multiplied by this value. Replaces global multiplier for starting area.
|
||||
rso-global-richness-mult=Richness of all resource patches will be multiplied by this value.
|
||||
rso-resource-chance=Chance to spawn resource per region(0.1 - 1, 1 means always).
|
||||
rso-region-size=Defines size of region used for resource generation. It's defined in chunks - bigger values will make resource more sparse.\nChanging during running game can have unexpected effects.
|
||||
rso-enemy-chance=Chance to spawn enemies in region(0.1 - 1, 1 mean always).
|
||||
rso-enemy-base-size=Enemy bases size will be multiplied by this value(more spawners and turrets per base, larger bases).
|
||||
rso-global-size-mult=Size of resource patches will be multiplied by this value. Very big patches might get cut when generating.
|
||||
rso-remove-trees=When placing resource patches trees will be removed with this setting on.\nThis might not be 100% effective - some trees might remain.
|
||||
rso-infinite-ores-in-start-area=Angel's infinite ores integration - should infinite patches appear in starting area.
|
||||
rso-infinite-ore-threshold=Angel's infinite ores integration - threshold above which ore changes to infinite. Range is 0-1, with 0 making whole patches infinite and 1 making almost no infinite parts.
|
||||
rso-reveal-spawned-resources=When enabled each generated field will be revealed on map for all forces. It should prevent partially revealed ore patches on minimap.
|
||||
rso-distance-exponent=Advanced setting - can brake game balance and/or game.\n Exponent used to calculate ore richness increase with distance from center.
|
||||
rso-fluid-distance-exponent=Advanced setting - can brake game balance and/or game.\n Exponent used to calculate fluid richness increase with distance from center.
|
||||
rso-size-exponent=Advanced setting - can brake game balance and/or game.\n Exponent used to calculate size increase with distance from center.
|
||||
rso-multi-resource-active=When enabled additional resources can be generated along the primary rolled resource patch. It depends on configuration and it's used by vanilla and some big mods.
|
@ -1,49 +0,0 @@
|
||||
require("../rso_config")
|
||||
|
||||
function add_peak(ent, peak)
|
||||
if ent and ent.autoplace then
|
||||
ent.autoplace.peaks[#ent.autoplace.peaks+1] = peak
|
||||
end
|
||||
end
|
||||
|
||||
function change_ocataves(autoplace, octaves)
|
||||
for k,v in pairs(autoplace.peaks) do
|
||||
if v.noise_layer then
|
||||
v.noise_octaves_difference = (v.noise_octaves_difference or 0) + octaves
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function generate_basic_peaks(noise_layer)
|
||||
return {
|
||||
{
|
||||
influence = 0.1
|
||||
},
|
||||
{
|
||||
influence = 0.67,
|
||||
noise_layer = noise_layer,
|
||||
noise_octaves_difference = -2.7,
|
||||
noise_persistence = 0.3
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
function resetRichness(ent)
|
||||
if ent and ent.autoplace then
|
||||
ent.autoplace.richness_multiplier = 0
|
||||
ent.autoplace.richness_base = 0
|
||||
end
|
||||
end
|
||||
|
||||
function removeAutoplace(ent)
|
||||
if ent then
|
||||
ent.autoplace = nil
|
||||
end
|
||||
end
|
||||
|
||||
function removePeaks(ent)
|
||||
if ent and ent.autoplace then
|
||||
ent.autoplace.peaks = {}
|
||||
end
|
||||
end
|
@ -1,11 +0,0 @@
|
||||
require("vanilla") -- vanilla ore/liquids (no enemies)
|
||||
require("vanilla_enemies")
|
||||
|
||||
function loadResourceConfig()
|
||||
|
||||
config={}
|
||||
|
||||
fillVanillaConfig()
|
||||
|
||||
return config
|
||||
end
|
@ -1,115 +0,0 @@
|
||||
function fillVanillaConfig()
|
||||
|
||||
config["iron-ore"] = {
|
||||
type="resource-ore",
|
||||
|
||||
-- general spawn params
|
||||
allotment=100, -- how common resource is
|
||||
spawns_per_region={min=1, max=1}, --number of chunks
|
||||
richness=18000, -- resource_ore has only one richness value - resource-liquid has min/max
|
||||
|
||||
size={min=20, max=30}, -- rough radius of area, too high value can produce square shaped areas
|
||||
min_amount=500,
|
||||
|
||||
-- resource provided at starting location
|
||||
-- probability: 1 = 100% chance to be in starting area
|
||||
-- 0 = resource is not in starting area
|
||||
starting={richness=8000, size=25, probability=1},
|
||||
|
||||
multi_resource_chance=0.20, -- absolute value
|
||||
multi_resource={
|
||||
["iron-ore"] = 2, -- ["resource_name"] = allotment
|
||||
['copper-ore'] = 4,
|
||||
["coal"] = 4,
|
||||
["stone"] = 4,
|
||||
}
|
||||
}
|
||||
|
||||
config["copper-ore"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=100,
|
||||
spawns_per_region={min=1, max=1},
|
||||
richness=16000,
|
||||
size={min=20, max=30},
|
||||
min_amount=500,
|
||||
|
||||
starting={richness=6000, size=25, probability=1},
|
||||
|
||||
multi_resource_chance=0.20,
|
||||
multi_resource={
|
||||
["iron-ore"] = 4,
|
||||
['copper-ore'] = 2,
|
||||
["coal"] = 4,
|
||||
["stone"] = 4,
|
||||
}
|
||||
}
|
||||
|
||||
config["coal"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=80,
|
||||
|
||||
spawns_per_region={min=1, max=1},
|
||||
size={min=15, max=25},
|
||||
richness=13000,
|
||||
min_amount=500,
|
||||
|
||||
starting={richness=6000, size=20, probability=1},
|
||||
|
||||
multi_resource_chance=0.30,
|
||||
multi_resource={
|
||||
["crude-oil"] = 1,
|
||||
["iron-ore"] = 3,
|
||||
['copper-ore'] = 3,
|
||||
}
|
||||
}
|
||||
|
||||
config["stone"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=60,
|
||||
spawns_per_region={min=1, max=1},
|
||||
richness=11000,
|
||||
size={min=15, max=20},
|
||||
min_amount=250,
|
||||
|
||||
starting={richness=5000, size=16, probability=1},
|
||||
|
||||
multi_resource_chance=0.30,
|
||||
multi_resource={
|
||||
["coal"] = 4,
|
||||
["iron-ore"] = 3,
|
||||
['copper-ore'] = 3,
|
||||
}
|
||||
}
|
||||
|
||||
config["uranium-ore"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=40,
|
||||
spawns_per_region={min=1, max=1},
|
||||
richness=6000,
|
||||
size={min=10, max=15},
|
||||
min_amount=500,
|
||||
|
||||
starting={richness=2000, size=10, probability=1},
|
||||
}
|
||||
|
||||
config["crude-oil"] = {
|
||||
type="resource-liquid",
|
||||
minimum_amount=240000,
|
||||
allotment=70,
|
||||
spawns_per_region={min=1, max=2},
|
||||
richness={min=240000, max=400000}, -- richness per resource spawn
|
||||
size={min=2, max=5},
|
||||
|
||||
starting={richness=400000, size=2, probability=1},
|
||||
|
||||
multi_resource_chance=0.20,
|
||||
multi_resource={
|
||||
["coal"] = 4,
|
||||
["uranium-ore"] = 1,
|
||||
}
|
||||
}
|
||||
end
|
@ -1,45 +0,0 @@
|
||||
function fillEnemies()
|
||||
|
||||
config["enemy-base"] = {
|
||||
type="entity",
|
||||
force="enemy",
|
||||
clear_range = {6, 6},
|
||||
|
||||
spawns_per_region={min=2,max=4},
|
||||
size={min=2,max=4},
|
||||
size_per_region_factor=0.4,
|
||||
richness=1,
|
||||
|
||||
absolute_probability=rso_settings["rso-enemy-chance"], -- chance to spawn in region
|
||||
probability_distance_factor=1.15, -- relative increase per region
|
||||
max_probability_distance_factor=3.0, -- absolute value
|
||||
|
||||
along_resource_probability=0.20, -- chance to spawn in resource chunk anyway, absolute value. Can happen once per resource.
|
||||
|
||||
sub_spawn_probability=0.3, -- chance for this entity to spawn anything from sub_spawns table, absolute value
|
||||
sub_spawn_size={min=1, max=2}, -- in same chunk
|
||||
sub_spawn_distance_factor=1.04,
|
||||
sub_spawn_max_distance_factor=3,
|
||||
sub_spawns={
|
||||
["small-worm-turret"]={
|
||||
min_distance=2,
|
||||
allotment=200,
|
||||
allotment_distance_factor=0.8,
|
||||
clear_range = {2, 2},
|
||||
},
|
||||
["medium-worm-turret"]={
|
||||
min_distance=4,
|
||||
allotment=100,
|
||||
allotment_distance_factor=1.1,
|
||||
clear_range = {2, 2},
|
||||
},
|
||||
["big-worm-turret"]={
|
||||
min_distance=6,
|
||||
allotment=100,
|
||||
allotment_distance_factor=1.2,
|
||||
clear_range = {2, 2},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end
|
@ -1,39 +0,0 @@
|
||||
|
||||
debug_enabled = true
|
||||
config_log_enabled = false
|
||||
debug_items_enabled = false
|
||||
|
||||
--region_size = 7 -- alternative mean to control how further away resources would be, default - 256 tiles or 8 chunks
|
||||
-- each region is region_size*region_size chunks
|
||||
-- each chunk is 32*32 tiles
|
||||
|
||||
starting_area_size = 1 -- starting area in regions, safe from random nonsense
|
||||
|
||||
--multi_resource_active = true -- moved to settings
|
||||
multi_resource_richness_factor = 0.60 -- any additional resource is multiplied by this value times resources-1
|
||||
multi_resource_size_factor = 0.90
|
||||
multi_resource_chance_diminish = 0.6 -- diminishing effect factor on multi_resource_chance
|
||||
|
||||
min_amount=250 -- default value for minimum amount of resource in single pile
|
||||
|
||||
-- mode is no longer used by generation process - it autodetects endless resources
|
||||
-- endless_resource_mode = false -- if true, the size of each resource is modified by the following modifier. Use with the endless resources mod.
|
||||
endless_resource_mode_sizeModifier = 0.80
|
||||
|
||||
biter_ratio_segment=1 --the ratio components determining how many biters to spitters will be spawned
|
||||
spitter_ratio_segment=1 --eg. 1 and 1 -> equal number of biters and spitters, 10 and 1 -> 10 times as many biters to spitters
|
||||
|
||||
useEnemiesInPeaceMod = false -- additional override for peace mod detection - when set to true it will spawn enemies normally, needs to have enemies enabled in peace mod
|
||||
|
||||
useStraightWorldMod = false -- enables Straight World mod - actual mod code copied into RSO to make it compatible
|
||||
|
||||
-- special modification of straight world mod for platforms (thanks to Dreadicon)
|
||||
useStraightWorldPlatforms = true -- enables Straight World behavior but only for platforms
|
||||
straightWorldPlatformsThreshold = 0.25 -- determines how blocky/organic platforms are on a scale of 0 to 1: lower is more blocky.
|
||||
|
||||
ignoreMapGenSettings = false -- stops the default behaviour of reading map gen settings
|
||||
|
||||
useResourceCollisionDetection = true -- enables avoidace calculations to reduce ores overlaping of each other
|
||||
resourceCollisionDetectionRatio = 0.999 -- threshold to exit placement early
|
||||
resourceCollisionDetectionRatioFallback = 0.75 -- at least this much of ore field needs to be placable to spawn it
|
||||
resourceCollisionFieldSkip = true -- determines if ore field should be skipped completely if placement based on ratio failed
|
File diff suppressed because it is too large
Load Diff
269
locale/gen_ores/rso_server/drand.lua
Normal file
269
locale/gen_ores/rso_server/drand.lua
Normal file
@ -0,0 +1,269 @@
|
||||
--[[------------------------------------
|
||||
RandomLua v0.3.1
|
||||
Pure Lua Pseudo-Random Numbers Generator
|
||||
Under the MIT license.
|
||||
copyright(c) 2011 linux-man
|
||||
--]]------------------------------------
|
||||
|
||||
local _M = {}
|
||||
local mod = math.fmod
|
||||
local floor = math.floor
|
||||
local abs = math.abs
|
||||
|
||||
local function normalize(n) --keep numbers at (positive) 32 bits
|
||||
return n % 0x80000000
|
||||
end
|
||||
|
||||
local function bit_and(a, b)
|
||||
local r = 0
|
||||
local m = 0
|
||||
for m = 0, 31 do
|
||||
if (a % 2 == 1) and (b % 2 == 1) then r = r + 2^m end
|
||||
if a % 2 ~= 0 then a = a - 1 end
|
||||
if b % 2 ~= 0 then b = b - 1 end
|
||||
a = a / 2 b = b / 2
|
||||
end
|
||||
return normalize(r)
|
||||
end
|
||||
|
||||
local function bit_or(a, b)
|
||||
local r = 0
|
||||
local m = 0
|
||||
for m = 0, 31 do
|
||||
if (a % 2 == 1) or (b % 2 == 1) then r = r + 2^m end
|
||||
if a % 2 ~= 0 then a = a - 1 end
|
||||
if b % 2 ~= 0 then b = b - 1 end
|
||||
a = a / 2 b = b / 2
|
||||
end
|
||||
return normalize(r)
|
||||
end
|
||||
|
||||
local function bit_xor(a, b)
|
||||
local r = 0
|
||||
local m = 0
|
||||
for m = 0, 31 do
|
||||
if a % 2 ~= b % 2 then r = r + 2^m end
|
||||
if a % 2 ~= 0 then a = a - 1 end
|
||||
if b % 2 ~= 0 then b = b - 1 end
|
||||
a = a / 2 b = b / 2
|
||||
end
|
||||
return normalize(r)
|
||||
end
|
||||
|
||||
local function seed()
|
||||
--return normalize(tonumber(tostring(os.time()):reverse()))
|
||||
return normalize(os.time())
|
||||
end
|
||||
|
||||
--Mersenne twister
|
||||
mersenne_twister = {}
|
||||
mersenne_twister.__index = mersenne_twister
|
||||
|
||||
function mersenne_twister:randomseed(s)
|
||||
if not s then s = seed() end
|
||||
self.mt[0] = normalize(s)
|
||||
for i = 1, 623 do
|
||||
self.mt[i] = normalize(0x6c078965 * bit_xor(self.mt[i-1], floor(self.mt[i-1] / 0x40000000)) + i)
|
||||
end
|
||||
end
|
||||
|
||||
function mersenne_twister:random(a, b)
|
||||
local y
|
||||
if self.index == 0 then
|
||||
for i = 0, 623 do
|
||||
--y = bit_or(floor(self.mt[i] / 0x80000000) * 0x80000000, self.mt[(i + 1) % 624] % 0x80000000)
|
||||
y = self.mt[(i + 1) % 624] % 0x80000000
|
||||
self.mt[i] = bit_xor(self.mt[(i + 397) % 624], floor(y / 2))
|
||||
if y % 2 ~= 0 then self.mt[i] = bit_xor(self.mt[i], 0x9908b0df) end
|
||||
end
|
||||
end
|
||||
y = self.mt[self.index]
|
||||
y = bit_xor(y, floor(y / 0x800))
|
||||
y = bit_xor(y, bit_and(normalize(y * 0x80), 0x9d2c5680))
|
||||
y = bit_xor(y, bit_and(normalize(y * 0x8000), 0xefc60000))
|
||||
y = bit_xor(y, floor(y / 0x40000))
|
||||
self.index = (self.index + 1) % 624
|
||||
if not a then return y / 0x80000000
|
||||
elseif not b then
|
||||
if a == 0 then return y
|
||||
else return 1 + (y % a)
|
||||
end
|
||||
else
|
||||
return a + (y % (b - a + 1))
|
||||
end
|
||||
end
|
||||
|
||||
function _M.twister(s)
|
||||
local temp = {}
|
||||
setmetatable(temp, mersenne_twister)
|
||||
temp.mt = {}
|
||||
temp.index = 0
|
||||
temp:randomseed(s)
|
||||
return temp
|
||||
end
|
||||
|
||||
--Linear Congruential Generator
|
||||
linear_congruential_generator = {}
|
||||
linear_congruential_generator.__index = linear_congruential_generator
|
||||
|
||||
function linear_congruential_generator:random(a, b)
|
||||
local y = (self.a * self.x + self.c) % self.m
|
||||
self.x = y
|
||||
if not a then return y / 0x10000
|
||||
elseif not b then
|
||||
if a == 0 then return y
|
||||
else return 1 + (y % a) end
|
||||
else
|
||||
return a + (y % (b - a + 1))
|
||||
end
|
||||
end
|
||||
|
||||
function linear_congruential_generator:randomseed(s)
|
||||
if not s then s = seed() end
|
||||
self.x = normalize(s)
|
||||
end
|
||||
|
||||
function _M.lcg(s, r)
|
||||
local temp = {}
|
||||
setmetatable(temp, linear_congruential_generator)
|
||||
temp.a, temp.c, temp.m = 1103515245, 12345, 0x10000 --from Ansi C
|
||||
if r then
|
||||
if r == 'nr' then temp.a, temp.c, temp.m = 1664525, 1013904223, 0x10000 --from Numerical Recipes.
|
||||
elseif r == 'mvc' then temp.a, temp.c, temp.m = 214013, 2531011, 0x10000 end--from MVC
|
||||
end
|
||||
temp:randomseed(s)
|
||||
return temp
|
||||
end
|
||||
|
||||
-- Multiply-with-carry
|
||||
multiply_with_carry = {}
|
||||
multiply_with_carry.__index = multiply_with_carry
|
||||
|
||||
function multiply_with_carry:random(a, b)
|
||||
local m = self.m
|
||||
local t = self.a * self.x + self.c
|
||||
local y = t % m
|
||||
self.x = y
|
||||
self.c = floor(t / m)
|
||||
if not a then return y / 0x10000
|
||||
elseif not b then
|
||||
if a == 0 then return y
|
||||
else return 1 + (y % a) end
|
||||
else
|
||||
local diff = 0
|
||||
if a == b then return a end
|
||||
if a < 0 then
|
||||
diff = abs(a)
|
||||
a = a + diff
|
||||
b = b + diff
|
||||
end
|
||||
return a + (y % (b - a + 1)) - diff
|
||||
end
|
||||
end
|
||||
|
||||
function multiply_with_carry:randomseed(s)
|
||||
if not s then s = seed() end
|
||||
self.c = self.ic
|
||||
self.x = normalize(s)
|
||||
end
|
||||
|
||||
function _M.mwc(s, r)
|
||||
local temp = {}
|
||||
setmetatable(temp, multiply_with_carry)
|
||||
temp.a, temp.c, temp.m = 1103515245, 12345, 0x10000 --from Ansi C
|
||||
if r then
|
||||
if r == 'nr' then temp.a, temp.c, temp.m = 1664525, 1013904223, 0x10000 --from Numerical Recipes.
|
||||
elseif r == 'mvc' then temp.a, temp.c, temp.m = 214013, 2531011, 0x10000 end--from MVC
|
||||
end
|
||||
temp.ic = temp.c
|
||||
temp:randomseed(s)
|
||||
return temp
|
||||
end
|
||||
|
||||
function _M.mwvc(s)
|
||||
return _M.mwc(s, 'mvc')
|
||||
end
|
||||
|
||||
local B = 0x10000
|
||||
|
||||
-- rough adaptation of Knuth float generator
|
||||
function _M.krandom( seedobj, fVal1, fVal2 )
|
||||
local ma = seedobj.ma
|
||||
local seed = seedobj.seed
|
||||
local mj, mk
|
||||
if seed < 0 or not ma then
|
||||
ma = {}
|
||||
seedobj.ma = ma
|
||||
mj = normalize( seed )
|
||||
mj = mod( mj, B )
|
||||
ma[55] = mj
|
||||
mk = 1
|
||||
for i = 1, 54 do
|
||||
local ii = mod( 21 * i, 55 )
|
||||
ma[ii] = mk
|
||||
mk = mj - mk
|
||||
if mk < 0 then mk = mk + B end
|
||||
mj = ma[ii]
|
||||
end
|
||||
for k = 1, 4 do
|
||||
for i = 1, 55 do
|
||||
ma[i] = ma[i] - ma[ 1 + mod( i + 30, 55) ]
|
||||
if ma[i] < 0 then ma[i] = ma[i] + B end
|
||||
end
|
||||
end
|
||||
seedobj.inext = 0
|
||||
seedobj.inextp = 31
|
||||
seedobj.seed = 1
|
||||
end -- if
|
||||
local inext = seedobj.inext
|
||||
local inextp = seedobj.inextp
|
||||
inext = inext + 1
|
||||
if inext == 56 then inext = 1 end
|
||||
seedobj.inext = inext
|
||||
inextp = inextp + 1
|
||||
if inextp == 56 then inextp = 1 end
|
||||
seedobj.inextp = inextp
|
||||
mj = ma[ inext ] - ma[ inextp ]
|
||||
if mj < 0 then mj = mj + B end
|
||||
ma[ inext ] = mj
|
||||
local temp_rand = mj / B
|
||||
if fVal2 then
|
||||
return floor( fVal1 + 0.5 + temp_rand * ( fVal2 - fVal1 ) )
|
||||
elseif fVal1 then
|
||||
return floor( temp_rand * fVal1 ) + 1
|
||||
else
|
||||
return temp_rand
|
||||
end
|
||||
end
|
||||
|
||||
-- Sys rand
|
||||
sys_rand = {}
|
||||
sys_rand.__index = sys_rand
|
||||
function sys_rand:random(a, b)
|
||||
local diff = 0
|
||||
if a and b and a == b then math.random(); return a end
|
||||
if a and b then
|
||||
if a < 0 then
|
||||
diff = abs(a)
|
||||
a = a + diff
|
||||
b = b + diff
|
||||
end
|
||||
return math.random(a, b) - diff
|
||||
end
|
||||
if a and a == 0 then return floor(math.random() * 0x10000) end
|
||||
if a then return math.random(a) end
|
||||
return math.random()
|
||||
end
|
||||
|
||||
function sys_rand:randomseed(s)
|
||||
-- ignore
|
||||
return
|
||||
end
|
||||
|
||||
function _M.sys_rand(s)
|
||||
local temp = {}
|
||||
setmetatable(temp, sys_rand)
|
||||
return temp
|
||||
end
|
||||
|
||||
return _M
|
@ -1,6 +1,6 @@
|
||||
--[[--
|
||||
Metaball implementation for LUA by Dark
|
||||
For bruteforce usage, nor efficient nor fast
|
||||
For bruteforce usage, not efficient nor fast
|
||||
|
||||
Force scales to from inf to 1 at R
|
||||
--]]--
|
56
locale/gen_ores/rso_server/rso_config.lua
Normal file
56
locale/gen_ores/rso_server/rso_config.lua
Normal file
@ -0,0 +1,56 @@
|
||||
debug_enabled = false
|
||||
|
||||
region_size = 4 -- alternative mean to control how further away resources would be, default - 256 tiles or 8 chunks
|
||||
-- each region is region_size*region_size chunks
|
||||
-- each chunk is 32*32 tiles
|
||||
|
||||
use_donut_shapes = false -- setting this to false will remove donuts from possible resource layouts
|
||||
|
||||
starting_area_size = 1 -- starting area in regions, safe from random nonsense
|
||||
|
||||
absolute_resource_chance = 0.65 -- chance to spawn an resource in a region
|
||||
starting_richness_mult = 1 -- multiply starting area richness for resources
|
||||
global_richness_mult = 1 -- multiply richness for all resources except starting area
|
||||
global_size_mult = 1 -- multiply size for all ores, doesn't affect starting area
|
||||
|
||||
absolute_enemy_chance = 5 -- chance to spawn enemies per sector (can be more then one base if spawned)
|
||||
enemy_base_size_multiplier = 1 -- all base sizes will be multiplied by this - larger number means bigger bases
|
||||
|
||||
multi_resource_active = false -- global switch for multi resource chances
|
||||
multi_resource_richness_factor = 0.60 -- any additional resource is multiplied by this value times resources-1
|
||||
multi_resource_size_factor = 0.90
|
||||
multi_resource_chance_diminish = 0.6 -- diminishing effect factor on multi_resource_chance
|
||||
|
||||
min_amount=350 -- default value for minimum amount of resource in single pile
|
||||
|
||||
richness_distance_factor=1 -- exponent for richness distance factor calculation
|
||||
fluid_richness_distance_factor = 0.6 -- exponent for richness distance factor calculation for fluids
|
||||
size_distance_factor=0.05 -- exponent for size distance factor calculation
|
||||
|
||||
deterministic = true -- set to false to use system for all decisions math.random
|
||||
|
||||
-- mode is no longer used by generation process - it autodetects endless resources
|
||||
-- endless_resource_mode = false -- if true, the size of each resource is modified by the following modifier. Use with the endless resources mod.
|
||||
endless_resource_mode_sizeModifier = 0.80
|
||||
|
||||
-- This setting isn't used anywhere in the soft mod version of RSO -- OARC
|
||||
-- Just set it from Oarc's config.lua (look for ENEMY_EXPANSION)
|
||||
-- disableEnemyExpansion = false -- allows for disabling of in-game biter base building
|
||||
|
||||
-- Leaving these values present, they do nothing in the RedMew RSO
|
||||
-- use_RSO_biter_spawning = false -- enables spawning of biters controlled by RSO mod - less enemies around with more space between bases
|
||||
-- use_vanilla_biter_spawning = true -- enables using of vanilla spawning
|
||||
|
||||
-- biter_ratio_segment=3 --the ratio components determining how many biters to spitters will be spawned
|
||||
-- spitter_ratio_segment=1 --eg. 1 and 1 -> equal number of biters and spitters, 10 and 1 -> 10 times as many biters to spitters
|
||||
|
||||
useEnemiesInPeaceMod = false -- additional override for peace mod detection - when set to true it will spawn enemies normally, needs to have enemies enabled in peace mod
|
||||
|
||||
-- Leave as true, and instead modify the rso_resource_config instead
|
||||
ignoreMapGenSettings = true -- stops the default behaviour of reading map gen settings
|
||||
|
||||
fluidResourcesFactor = 20 -- temporary factor for calculation of resource %-ages for fluids
|
||||
|
||||
useResourceCollisionDetection = false -- enables avoidace calculations to reduce ores overlaping of each other
|
||||
resourceCollisionDetectionRatio = 0.8 -- at least this much of ore field needs to be placable to spawn it
|
||||
resourceCollisionFieldSkip = true -- determines if ore field should be skipped completely if placement based on ratio failed
|
1204
locale/gen_ores/rso_server/rso_control.lua
Normal file
1204
locale/gen_ores/rso_server/rso_control.lua
Normal file
File diff suppressed because it is too large
Load Diff
125
locale/gen_ores/rso_server/rso_resource_config.lua
Normal file
125
locale/gen_ores/rso_server/rso_resource_config.lua
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
local function fillVanillaConfig()
|
||||
|
||||
config["iron-ore"] = {
|
||||
type="resource-ore",
|
||||
|
||||
-- general spawn params
|
||||
allotment=100, -- how common resource is
|
||||
spawns_per_region={min=1, max=1}, --number of chunks
|
||||
richness=18000, -- resource_ore has only one richness value - resource-liquid has min/max
|
||||
|
||||
size={min=20, max=30}, -- rough radius of area, too high value can produce square shaped areas
|
||||
min_amount=500,
|
||||
|
||||
-- resource provided at starting location
|
||||
-- probability: 1 = 100% chance to be in starting area
|
||||
-- 0 = resource is not in starting area
|
||||
starting={richness=8000, size=25, probability=1},
|
||||
|
||||
multi_resource_chance=0.20, -- absolute value
|
||||
multi_resource={
|
||||
["iron-ore"] = 2, -- ["resource_name"] = allotment
|
||||
['copper-ore'] = 4,
|
||||
["coal"] = 4,
|
||||
["stone"] = 4,
|
||||
}
|
||||
}
|
||||
|
||||
config["copper-ore"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=100,
|
||||
spawns_per_region={min=1, max=1},
|
||||
richness=16000,
|
||||
size={min=20, max=30},
|
||||
min_amount=500,
|
||||
|
||||
starting={richness=6000, size=25, probability=1},
|
||||
|
||||
multi_resource_chance=0.20,
|
||||
multi_resource={
|
||||
["iron-ore"] = 4,
|
||||
['copper-ore'] = 2,
|
||||
["coal"] = 4,
|
||||
["stone"] = 4,
|
||||
}
|
||||
}
|
||||
|
||||
config["coal"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=80,
|
||||
|
||||
spawns_per_region={min=1, max=1},
|
||||
size={min=15, max=25},
|
||||
richness=1300,
|
||||
min_amount=500,
|
||||
|
||||
starting={richness=6000, size=20, probability=1},
|
||||
|
||||
multi_resource_chance=0.30,
|
||||
multi_resource={
|
||||
["crude-oil"] = 1,
|
||||
["iron-ore"] = 3,
|
||||
['copper-ore'] = 3,
|
||||
}
|
||||
}
|
||||
|
||||
config["stone"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=60,
|
||||
spawns_per_region={min=1, max=1},
|
||||
richness=11000,
|
||||
size={min=15, max=20},
|
||||
min_amount=250,
|
||||
|
||||
starting={richness=5000, size=16, probability=1},
|
||||
|
||||
multi_resource_chance=0.30,
|
||||
multi_resource={
|
||||
["coal"] = 4,
|
||||
["iron-ore"] = 3,
|
||||
['copper-ore'] = 3,
|
||||
}
|
||||
}
|
||||
|
||||
config["uranium-ore"] = {
|
||||
type="resource-ore",
|
||||
|
||||
allotment=40,
|
||||
spawns_per_region={min=1, max=1},
|
||||
richness=6000,
|
||||
size={min=10, max=15},
|
||||
min_amount=500,
|
||||
|
||||
starting={richness=2000, size=10, probability=1},
|
||||
}
|
||||
|
||||
config["crude-oil"] = {
|
||||
type="resource-liquid",
|
||||
minimum_amount=60000,
|
||||
allotment=80,
|
||||
spawns_per_region={min=1, max=1},
|
||||
richness={min=60000, max=70000}, -- richness per resource spawn
|
||||
size={min=4, max=20},
|
||||
|
||||
starting={richness=400000, size=3, probability=1},
|
||||
|
||||
multi_resource_chance=0.20,
|
||||
multi_resource={
|
||||
["coal"] = 4,
|
||||
["uranium-ore"] = 1,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function loadResourceConfig()
|
||||
|
||||
config={}
|
||||
|
||||
fillVanillaConfig()
|
||||
|
||||
return config
|
||||
end
|
@ -40,6 +40,7 @@ in this file and your run_*type*_module(event) function will be called.
|
||||
--require "locale.gen_ores.fluffy_rainbows"
|
||||
--require "locale.gen_ores.glitter_ores"
|
||||
--require "locale.gen_ores.rso.rso_control"
|
||||
require "locale.gen_ores.rso_server.rso_control"
|
||||
|
||||
--everything else. You may use more than one of these, but beware they might not be compatible
|
||||
miscs = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user