1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Merge pull request #69 from Valansch/develop_pacman_shape

Pacman
This commit is contained in:
Valansch 2017-09-28 18:02:33 +02:00 committed by GitHub
commit 8af647d7d9
6 changed files with 166 additions and 16 deletions

View File

@ -1,13 +1,15 @@
chunk_grid_module = {}
-- Drops a grid of concrete, hazard and brick along the chunk edges
local function run_terrain_module_setup()
grid = {}
-- Widths will always double, due to how we draw on the edge of the chunks
grid_widths = {
["concrete"] = 2,
["hazard-concrete-left"] = 1,
["stone-path"] = 1
}
grid_chunk_size = 3
grid_chunk_size = 8
grid_width = 0
-- Prime the array
@ -19,11 +21,17 @@ local function run_terrain_module_setup()
end
end
local no_grid = {}
no_grid["out-of-map"] = 1;
no_grid["water"] = 1;
no_grid["water-green"] = 1;
no_grid["deepwater"] = 1;
no_grid["deepwater-green"] = 1;
run_terrain_module_setup()
function run_terrain_module(event)
function chunk_grid_module.on_chunk_generated(event)
-- Draw the grid
-- concrete width - 3, hazard = 1, brick = 2
local surface = event.surface
local tiles = {}
local tile
@ -52,7 +60,7 @@ function run_terrain_module(event)
position = {rel_x + grid_width - pos, y}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position = position})
end
end
@ -65,7 +73,7 @@ function run_terrain_module(event)
position = {pos + rel_x + 31 - grid_width, y}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position = position})
end
end
@ -81,7 +89,7 @@ function run_terrain_module(event)
position = {x, rel_y + grid_width - pos}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position = position})
end
end
@ -93,7 +101,7 @@ function run_terrain_module(event)
tile_name = grid[grid_width+1 - pos]
position = {x, pos + rel_y + 31 - grid_width}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position = position})
end
end
@ -113,7 +121,7 @@ function run_terrain_module(event)
-- Top Left
position = {rel_x - 1 + pos_x, rel_y - 1 + pos_y}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position=position})
end
end
@ -122,7 +130,7 @@ function run_terrain_module(event)
-- Top Right
position = {rel_x + 32 - pos_x, rel_y - 1 + pos_y}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position=position})
end
end
@ -131,7 +139,7 @@ function run_terrain_module(event)
-- Bottom Left
position = {rel_x - 1 + pos_x, rel_y + 32 - pos_y}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position=position})
end
end
@ -140,7 +148,7 @@ function run_terrain_module(event)
-- Bottom right
position = {rel_x + 32 - pos_x, rel_y + 32 - pos_y}
tile = surface.get_tile( position )
if tile.name ~= "out-of-map" and tile.name ~= "water" then
if no_grid[tile.name] == nil then
table.insert(tiles, {name = tile_name, position=position})
end
end
@ -149,3 +157,5 @@ function run_terrain_module(event)
surface.set_tiles(tiles,true)
end
return chunk_grid_module

View File

@ -0,0 +1,57 @@
wreck_items_module = {}
-- adds some wrecked items around the map, good for MP, reduces total resources pulled from factory, and adds incentive to push out
wreck_item_pool = {}
wreck_item_pool = {{name="iron-gear-wheel", count=32},{name="iron-plate", count=64},{name="rocket-control-unit", count=1},{name="rocket-fuel", count=7} ,{name="coal", count=8},{name="rocket-launcher", count=1},{name="rocket", count=32},{name="copper-cable", count=128},{name="land-mine", count=64},{name="railgun", count=1},{name="railgun-dart", count=128},{name="fast-inserter", count=8},{name="stack-filter-inserter", count=2},{name="belt-immunity-equipment", count=1},{name="fusion-reactor-equipment", count=1},{name="electric-engine-unit", count=8},{name="exoskeleton-equipment", count=1},{name="rocket-fuel", count=10},{name="used-up-uranium-fuel-cell", count=3},{name="uranium-fuel-cell", count=2},{name="power-armor", count=1},{name="modular-armor", count=1},{name="water-barrel", count=4},{name="sulfuric-acid-barrel", count=6},{name="crude-oil-barrel", count=8},{name="energy-shield-equipment", count=1},{name="explosive-rocket", count=32}}
local function place_entities(surface, entity_list)
local directions = {defines.direction.north, defines.direction.east, defines.direction.south, defines.direction.west}
for _, entity in pairs(entity_list) do
local r = math.random(1,entity.chance)
if r == 1 then
if not entity.force then entity.force = "player" end
local r = math.random(1,4)
if surface.can_place_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force} then
local e = surface.create_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force}
if entity.health then
if entity.health == "low" then e.health = ((e.health / 1000) * math.random(33,330)) end
if entity.health == "medium" then e.health = ((e.health / 1000) * math.random(333,666)) end
if entity.health == "high" then e.health = ((e.health / 1000) * math.random(666,999)) end
if entity.health == "random" then e.health = ((e.health / 1000) * math.random(1,1000)) end
end
return true, e
end
end
end
return false
end
function wreck_items_module.on_chunk_generated(event)
local surface = event.surface
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local pos_x = event.area.left_top.x + x
local pos_y = event.area.left_top.y + y
local pos = {x = pos_x,y = pos_y}
local entity_list = {}
table.insert(entity_list, {name="big-ship-wreck-1", pos={pos_x,pos_y},chance = 35000, health="random"})
table.insert(entity_list, {name="big-ship-wreck-2", pos={pos_x,pos_y},chance = 45000, health="random"})
table.insert(entity_list, {name="big-ship-wreck-3", pos={pos_x,pos_y},chance = 55000, health="random"})
local b, placed_entity = place_entities(surface, entity_list)
if b == true then
if placed_entity.name == "big-ship-wreck-1" or placed_entity.name == "big-ship-wreck-2" or placed_entity.name == "big-ship-wreck-3" then
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
end
end
end
end
end
return wreck_items_module

View File

@ -99,11 +99,11 @@ local function fillVanillaConfig()
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},
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=3, probability=1},

View File

@ -0,0 +1,80 @@
--Pacman void script by TWLTriston
local grid_width = 40
local grid_height = 40
local grid_scale = 32 -- 4/8/16/32 are good values here
local image_grid = {
-- { 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0 },
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
{ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
{ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
{ 0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0 },
{ 0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0 },
{ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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1,1,1,0,1,1,1,1,1,0 },
{ 0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0 },
{ 0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0 },
{ 0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0 },
{ 0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0 },
{ 0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0 },
{ 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0 },
{ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
{ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
}
function run_shape_module(event)
local area = event.area
local surface = event.surface
local tiles = {}
local top_left_x = area.left_top.x --make a more direct reference
local top_left_y = area.left_top.y --make a more direct reference
-- chunk_region = top_left_x / grid_scale
for x = top_left_x, top_left_x + 32, grid_scale do
image_grid_position_x = ( ( x / grid_scale ) + 20 ) % grid_width + 1
for y = top_left_y, top_left_y + 32, grid_scale do
image_grid_position_y = ( ( y / grid_scale ) + 19 ) % grid_height + 1
if image_grid[image_grid_position_y][image_grid_position_x] ~= nil then
if image_grid[image_grid_position_y][image_grid_position_x] == 0 then
for x_1 = x, x + grid_scale do
for y_1 = y, y + grid_scale do
table.insert(tiles, {name = "out-of-map", position = {x_1,y_1}})
end
end
end
end
end
end
surface.set_tiles(tiles)
return true
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

View File

@ -30,6 +30,7 @@ in this file and your run_*type*_module(event) function will be called.
--require "locale.gen_shape.lattice"
--require "locale.gen_shape.infinite_mazes"
--require "locale.gen_shape.x_shape"
--require "locale.gen_shape.pacman"
--terrain--
--require "locale.gen_terrain.neko_bridged_rivers"
@ -45,6 +46,8 @@ in this file and your run_*type*_module(event) function will be called.
miscs = {}
--miscs[1] = require "locale.gen_misc.rail_grid"
--require "locale.gen_misc.rusky_pvp"
--miscs[1] = require "locale.gen_misc.wreck_items"
--miscs[2] = require "locale.gen_misc.tris_chunk_grid"
local on_chunk_generated = function(event)
if run_combined_module == nil then