1
0
mirror of https://github.com/jvmguy/JvmguyScenario.git synced 2024-11-21 17:16:46 +02:00

Modified RiverWorld scenario to allow OctoTile2 geometric terrain.

This commit is contained in:
Kevin Morgan 2022-10-25 20:43:42 -07:00
parent 5ca7bf5120
commit 5cd6da434a
5 changed files with 152 additions and 44 deletions

View File

@ -96,7 +96,7 @@ scenario.config.regrow = {
}
scenario.config.bots = {
worker_robots_storage_bonus = 0,
worker_robots_storage_bonus = 1,
worker_robots_speed_modifier = 1.0,
}
@ -132,7 +132,8 @@ scenario.config.silo = {
prebuildBeacons = false,
prebuildPower = false,
-- Should be in the middle of a chunk
position = {x = SILO_DISTANCE_X, y = SILO_DISTANCE_Y}
position = {x = SILO_DISTANCE_X, y = SILO_DISTANCE_Y},
buildRadius = 20, -- silos cannot be further than this
}
scenario.config.startKitSmall = {
@ -215,7 +216,7 @@ scenario.config.startKit = scenario.config.startKitMedium
scenario.config.teleporter = {
enabled = true,
-- where in the spawn to place the teleporter
spawnPosition = { x=20, y=-47 },
spawnPosition = { x=10, y=10 },
-- where in the silo chunk to place the teleporter
-- this should not be 0,0 if there is the possibility that the default spawn will be used
@ -323,9 +324,9 @@ scenario.config.noResources = {
{name = "inserter", count=20},
{name = "assembling-machine-1", count=10},
}, },
}
RESOURCE_MULT = 2
scenario.config.vanillaResources = {
-- { shape="rect", name="steel-chest", x=42, y=-24, height=2, width=2, contents = { {name = "landfill", count=4800 } }, },
{ shape="rect", name="steel-chest", x=42, y=-18, height=2, width=2, contents = { {name = "iron-plate", count=1000 } }, },
@ -347,19 +348,56 @@ scenario.config.vanillaResources = {
{name = "small-electric-pole", count = 20},
{name = "gun-turret", count=20 },
{name = "piercing-rounds-magazine", count=200 },
{name = "raw-fish", count=100 },
-- {name = "inserter", count=20},
-- {name = "assembling-machine-1", count=10},
}, },
{ shape="rect", type="coal", x=32, y=-41, height=14, width=30, amount=3000, },
{ shape="rect", type="stone", x=32, y=-24, height=14, width=30, amount=1000, },
{ shape="rect", type="coal", x=32, y=-41, height=14, width=30, amount=RESOURCE_MULT*3000, },
{ shape="rect", type="stone", x=32, y=-24, height=14, width=30, amount=RESOURCE_MULT*1000, },
-- { shape="rect", type="uranium-ore", x=27, y=-24, height=14, width=12, amount=1800, },
{ shape="rect", type="copper-ore", x=32, y=-7, height=21, width=30, amount=2000, },
{ shape="rect", type="iron-ore", x=32, y =18, height=21, width=30, amount=2000, },
{ shape="rect", type="copper-ore", x=32, y=-7, height=21, width=30, amount=RESOURCE_MULT*2000, },
{ shape="rect", type="iron-ore", x=32, y =18, height=21, width=30, amount=RESOURCE_MULT*2000, },
{ shape="rect", type="crude-oil", x=72, y=-6, height=1, amount=200000, },
{ shape="rect", type="crude-oil", x=72, y= 0, height=1, amount=200000, },
{ shape="rect", type="crude-oil", x=72, y= 6, height=1, amount=200000, },
{ shape="rect", type="crude-oil", x=72, y=-6, height=1, amount=RESOURCE_MULT*2000000, },
{ shape="rect", type="crude-oil", x=72, y= 0, height=1, amount=RESOURCE_MULT*2000000, },
{ shape="rect", type="crude-oil", x=72, y= 6, height=1, amount=RESOURCE_MULT*2000000, },
}
scenario.config.vanillaGeoResources = {
-- { shape="rect", name="steel-chest", x=42, y=-24, height=2, width=2, contents = { {name = "landfill", count=4800 } }, },
{ shape="rect", name="steel-chest", x=8, y=-8, height=2, width=2, contents = { {name = "iron-plate", count=1000 } }, },
{ shape="rect", name="steel-chest", x=8, y=-6, height=2, width=2, contents = { {name = "copper-plate", count=1000 } }, },
{ shape="rect", name="steel-chest", x=8, y=-4, height=1, width=1, contents = {
{name = "coal", count=100 },
{name = "stone", count=100 },
{name = "steel-plate", count=100 },
-- {name = "uranium-235", count=100 },
-- {name = "uranium-238", count=500 },
} },
{ shape="rect", name="steel-chest", x=8, y=0, height=1, width=1, contents = {
-- we can simulate no-hand-crafting by making hand crafting really slow, and providing an asm2.
{name = "offshore-pump", count = 1},
{name = "boiler", count = 1},
{name = "steam-engine", count = 1},
{name = "pipe", count=2},
{name = "pipe-to-ground", count=2},
{name = "small-electric-pole", count = 20},
{name = "gun-turret", count=20 },
{name = "piercing-rounds-magazine", count=200 },
{name = "raw-fish", count=100 },
-- {name = "inserter", count=20},
-- {name = "assembling-machine-1", count=10},
}, },
{ shape="rect", type="coal", x=-15, y=-15, height=15, width=15, amount=RESOURCE_MULT*3000, },
{ shape="rect", type="stone", x=0, y=-15, height=15, width=15, amount=RESOURCE_MULT*1000, },
{ shape="rect", type="copper-ore", x=-15, y=0, height=15, width=15, amount=RESOURCE_MULT*2000, },
{ shape="rect", type="iron-ore", x=0, y =0, height=15, width=15, amount=RESOURCE_MULT*2000, },
{ shape="rect", type="crude-oil", x=14, y=-6, height=1, amount=RESOURCE_MULT*2000000, },
{ shape="rect", type="crude-oil", x=14, y= 0, height=1, amount=RESOURCE_MULT*2000000, },
{ shape="rect", type="crude-oil", x=14, y= 6, height=1, amount=RESOURCE_MULT*2000000, },
}
scenario.config.voidResources = {
@ -423,6 +461,7 @@ scenario.config.angelsResources = {
{name = "assembling-machine-3", count=1},
{name = "electric-mining-drill", count=10},
{name = "filter-inserter", count=4 },
{name = "raw-fish", count=100 },
}, },
{ shape="rect", type="coal", x=32, y=-47, height=14, width=24, amount=400000, },
@ -650,10 +689,29 @@ scenario.config.pyanodonResources = {
-- { shape="rect", type="crude-oil", x=72, y= 6, height=1, amount=10000000, },
}
scenario.config.deepMineResources = {
{ shape="rect", name="steel-chest", x=42, y=0, height=1, width=1, contents = {
{name = "solar-panel", count = 24},
{name = "accumulator", count = 20},
{name = "medium-electric-pole", count = 4},
{name = "small-electric-pole", count = 20},
{name = "deep-mine", count = 4},
{name = "inserter", count = 4},
-- {name = "assembling-machine-1", count=10},
}, },
{ shape="rect", type="crude-oil", x=72, y=-6, height=1, amount=2000000, },
{ shape="rect", type="crude-oil", x=72, y= 0, height=1, amount=2000000, },
{ shape="rect", type="crude-oil", x=72, y= 6, height=1, amount=2000000, },
}
scenario.config.recipesEnabled = {
-- "deep-mine",
-- "loader",
-- "fast-loader",
-- "express-loader",
-- "express-loader",
}
scenario.config.recipesDisabled = {
@ -918,7 +976,7 @@ scenario.config.riverworld = {
-- this is a vertical moat, not the usual one around the spawn.
moatWidth = 0, -- additional to land
startingEvolution=0.0,
startingEvolution=0.5,
resources = scenario.config.spawnResources,
-- freeze time of day
@ -966,4 +1024,42 @@ scenario.config.fermatSpiralSpawns = {
safe_area = scenario.config.safe_area,
}
-- For geometric terrain modified riverworld.
scenario.config.riverworld = {
-- variation for geometric config
enabled = false,
seablock = false, -- behavior a little like the seablock mod. (well, not really)
concrete = true, -- pave the spawn with concrete
stoneWalls = false, -- if true, makes a stone wall. if false, generate a void.
waterWalls = false,
firstSpawnPoint = 14,
numSpawnPoints = 27,
extraSpawn = 28, -- really far away, but not as far as you might think
spacing = 736, -- because of "no good reasons" this should be a multiple of 32 (chunk width)
barrier = 256, -- width of impenetrable barrier
rail = 3*640, -- generate a north-south railway starting here
rail2 = -3*640-32, -- generate a north-south railway starting here
freespace = 3*640 + 96, -- no voids after this
land = 23,
trees = 3, -- included in the land
moat = 7, -- additional to land
size = 15, -- should be land + moat
-- this is a vertical moat, not the usual one around the spawn.
moatWidth = 0, -- additional to land
startingEvolution=0.0,
resources = scenario.config.vanillaGeoResources,
-- freeze time of day
-- you might get night vision at the start, but you have to decide whether it's worth using it.
-- freezeTime = 0.35, -- see https://wiki.factorio.com/Game-day
-- 0 is day. 0.5 is night. 0.35 is twilight.
recipesEnabled = scenario.config.recipesEnabled,
recipesDisabled = scenario.config.recipesDisabled,
safe_area = scenario.config.safe_area,
}

View File

@ -60,9 +60,9 @@ toxicJungle = require("lib/ToxicJungle")
spawnGenerator = require("lib/RiverworldSpawns");
-- spawnGenerator = require("lib/BunkerSpawns");
local terrainGenerator = nil;
terrainGenerator = nil;
-- terrainGenerator = require("lib/GeometricTerrain");
-- terrainGenerator = require("lib/OctoTile");
terrainGenerator = require("lib/OctoTile2");
sharedSpawns = require("lib/shared_spawns");
@ -187,7 +187,6 @@ function jvm.on_chunk_generated(event)
if terrainGenerator ~= nil then
terrainGenerator.ChunkGenerated(event);
end
global.customChunk = false;
end
end

View File

@ -10,7 +10,17 @@ local function SpawnPoint(n)
-- degenerate spiral that just alternates on either side of the axis
local n = scenario.config.riverworld.firstSpawnPoint + n
local spacing = scenario.config.riverworld.spacing
return PolarToCartesian({ r=spacing * n / 2, theta= (n * math.pi ) })
local pos = PolarToCartesian({ r=spacing * n / 2, theta= (n * math.pi ) })
-- for terrain generator
if terrainGenerator ~= nil then
local lx = math.floor(pos.x/96)*96+48
local ly = math.floor(pos.y/96)*96+48
if (ly < 0) then
ly = ly - 32
end
end
pos = { x=lx, y=ly }
return pos
end
@ -354,9 +364,18 @@ end
function M.CreateSpawn(surface, spawnPos, chunkArea)
local config = M.GetConfig()
ClearNearbyEnemies(surface, chunkArea, spawnPos)
CreateCropOctagon(surface, spawnPos, chunkArea, config.land, config.trees, config.moat)
if config.concrete then
PaveWithConcrete( surface, chunkArea, spawnPos, config.land);
if (terrainGenerator == nil) then
CreateCropOctagon(surface, spawnPos, chunkArea, config.land, config.trees, config.moat)
if config.concrete then
PaveWithConcrete( surface, chunkArea, spawnPos, config.land);
end
else
local radius = 64
RemoveResources(surface, spawnPos, chunkArea, radius)
RemoveCliffs(surface, spawnPos, chunkArea, radius)
if config.concrete then
PaveWithConcrete( surface, chunkArea, spawnPos, radius);
end
end
end
@ -418,23 +437,6 @@ function M.ChunkGenerated(event)
end
end
--function M.CreateGameSurfaces()
-- local config = M.GetConfig()
-- local surfaces = config.surfaces;
-- for _,surf in pairs(surfaces) do
-- local mapSettings = {}
-- mapSettings = util.merge({
-- global.MapGenSettings.waterworld,
-- });
--
-- local surface = game.create_surface(surf.name,mapSettings)
-- if surf.freezeTime then
-- surface.freeze_daytime = true;
-- surface.daytime = surf.freezeTime;
-- end
-- end
--end
function M.ConfigureGameSurface()
local config = M.GetConfig()
if config.startingEvolution ~= nil then

View File

@ -6,6 +6,12 @@ require("oarc_utils")
local M = {}
function RocketSiloContains(chunkArea)
-- center of the chunk
local cpos = { x=chunkArea.left_top.x+16, y=chunkArea.left_top.y+16 }
return DistanceFromPoint( cpos, global.siloPosition) < 95;
end
local function ChunkContains( chunk, pt )
return pt.x >= chunk.left_top.x and pt.x < chunk.right_bottom.x and
pt.y >= chunk.left_top.y and pt.y < chunk.right_bottom.y;
@ -15,7 +21,7 @@ end
-- Create a rocket silo
local function CreateRocketSilo(surface, chunkArea)
if CheckIfInArea(global.siloPosition, chunkArea) then
-- Delete any entities beneat the silo?
for _, entity in pairs(surface.find_entities_filtered{area = {{global.siloPosition.x-50, global.siloPosition.y-50},{global.siloPosition.x+50, global.siloPosition.y+50}}}) do
entity.destroy()
@ -243,7 +249,7 @@ function BuildSiloAttempt(event)
-- end
-- end
if DistanceFromPoint( epos, global.siloPosition) < 5 then
if DistanceFromPoint( epos, global.siloPosition) < scenario.config.silo.buildRadius then
if (event.created_entity.name ~= "entity-ghost") then
SendBroadcastMsg("Rocket silo has been built!")
end

View File

@ -19,9 +19,7 @@ function PaveWithConcrete( surface, chunkArea, spawnPos, landRadius)
local tiles = {};
for y=chunkArea.left_top.y, chunkArea.right_bottom.y-1 do
for x = chunkArea.left_top.x, chunkArea.right_bottom.x-1 do
local distVar1 = math.floor(math.max(math.abs(spawnPos.x - x), math.abs(spawnPos.y - y)))
local distVar2 = math.floor(math.abs(spawnPos.x - x) + math.abs(spawnPos.y - y))
local distVar = math.max(distVar1, distVar2 * 0.707);
local distVar = distFunc( spawnPos.x, spawnPos.y, x, y)
if distVar < landRadius then
table.insert(tiles, {name = "concrete", position = {x,y}})
end
@ -117,22 +115,29 @@ function CreateCropOctagon(surface, centerPos, chunkArea, landRadius, treeWidth,
end
setTiles(surface, waterTiles, true);
end
RemoveResources(surface, centerPos, chunkArea, landRadius+moatWidth)
RemoveCliffs(surface, centerPos, chunkArea, landRadius+moatWidth)
end
function RemoveResources(surface, centerPos, chunkArea, radius)
-- remove resources in the immediate areas?
for key, entity in pairs(surface.find_entities_filtered({area=chunkArea, type= "resource"})) do
if entity and entity.valid then
local distVar = distFunc( centerPos.x, centerPos.y, entity.position.x, entity.position.y);
if distVar < landRadius+moatWidth then
if distVar < radius then
entity.destroy()
end
end
end
end
function RemoveCliffs(surface, centerPos, chunkArea, radius)
-- remove cliffs in the immediate areas?
for key, entity in pairs(surface.find_entities_filtered({area=chunkArea, type= "cliff"})) do
--Destroying some cliffs can cause a chain-reaction. Validate inputs.
if entity and entity.valid then
local distVar = distFunc( centerPos.x, centerPos.y, entity.position.x, entity.position.y);
if distVar < landRadius+moatWidth then
if distVar < radius then
entity.destroy()
end
end