mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
updates
This commit is contained in:
parent
ccfd13dfad
commit
8e6a7f7e47
13
control.lua
13
control.lua
@ -10,7 +10,7 @@ require 'follow'
|
||||
require 'autodeconstruct'
|
||||
require 'corpse_util'
|
||||
--require 'infinite_storage_chest'
|
||||
require 'fish_market'
|
||||
--require 'fish_market'
|
||||
require 'reactor_meltdown'
|
||||
require 'map_layout'
|
||||
require 'bot'
|
||||
@ -180,14 +180,3 @@ Event.add(
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local direction_bit_mask = 0xc0000000
|
||||
local section_bit_mask = 0x30000000
|
||||
local level_bit_mask = 0x0fffffff
|
||||
local direction_bit_shift = 30
|
||||
local section_bit_shift = 28
|
||||
|
||||
function get_direction(part)
|
||||
local dir = bit32.band(part, direction_bit_mask)
|
||||
return bit32.rshift(dir, direction_bit_shift - 1)
|
||||
end
|
||||
|
@ -1,6 +1,9 @@
|
||||
require('map_gen.presets.crash_site.blueprint_extractor')
|
||||
require 'map_gen.presets.crash_site.blueprint_extractor'
|
||||
require 'map_gen.presets.crash_site.entity_died_events'
|
||||
require 'map_gen.presets.crash_site.weapon_balance'
|
||||
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Global = require('utils.global')
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local OutpostBuilder = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
@ -11,40 +14,75 @@ local outpost_variance = 3
|
||||
local outpost_min_step = 2
|
||||
local outpost_max_level = 4
|
||||
|
||||
local striaght_wall = OutpostBuilder.make_4_way(require('map_gen.presets.crash_site.outpost_data.gun_turrent_straight'))
|
||||
local outer_corner_wall =
|
||||
OutpostBuilder.make_4_way(require('map_gen.presets.crash_site.outpost_data.gun_turrent_outer_corner'))
|
||||
local inner_corner_wall =
|
||||
OutpostBuilder.make_4_way(require('map_gen.presets.crash_site.outpost_data.gun_turret_inner_corner'))
|
||||
|
||||
local templates = {
|
||||
{striaght_wall, outer_corner_wall, inner_corner_wall},
|
||||
{[22] = {entity = {name = 'stone-furnace'}}},
|
||||
{[22] = {entity = {name = 'assembling-machine-2'}}},
|
||||
{[22] = {entity = {name = 'oil-refinery'}}}
|
||||
}
|
||||
|
||||
local outpost_builder = OutpostBuilder.new(outpost_seed)
|
||||
local shape =
|
||||
outpost_builder:do_outpost(outpost_blocks, outpost_variance, outpost_min_step, outpost_max_level, templates)
|
||||
|
||||
local pattern = {}
|
||||
local walls = require 'map_gen.presets.crash_site.outpost_data.walls'
|
||||
local thin_walls = require 'map_gen.presets.crash_site.outpost_data.thin_walls'
|
||||
|
||||
local medium_gun_turrets = require 'map_gen.presets.crash_site.outpost_data.medium_gun_turrets'
|
||||
local light_flame_turrets = require 'map_gen.presets.crash_site.outpost_data.light_flame_turrets'
|
||||
local laser_turrets = require 'map_gen.presets.crash_site.outpost_data.light_laser_turrets'
|
||||
local small_worm_turrets = require 'map_gen.presets.crash_site.outpost_data.small_worm_turrets'
|
||||
|
||||
local medium_gun_turrets_player = OutpostBuilder.extend_walls(medium_gun_turrets, {force = 'player'})
|
||||
local laser_turrets_player =
|
||||
OutpostBuilder.extend_walls(
|
||||
laser_turrets,
|
||||
{
|
||||
force = 'player',
|
||||
turret = {callback = OutpostBuilder.power_source_callback, data = {buffer_size = 24, power_production = 4}}
|
||||
}
|
||||
)
|
||||
|
||||
local gear_factory = require 'map_gen.presets.crash_site.outpost_data.gear_factory'
|
||||
local iron_plate_factory = require 'map_gen.presets.crash_site.outpost_data.iron_plate_factory'
|
||||
local oil_refinery_factory = require 'map_gen.presets.crash_site.outpost_data.oil_refinery_factory'
|
||||
|
||||
local grid_size = (outpost_blocks + 2) * 6
|
||||
local half_grid_size = grid_size * 0.5
|
||||
|
||||
local et = OutpostBuilder.empty_template
|
||||
|
||||
local base_templates = {
|
||||
test = {
|
||||
{[22] = {entity = {name = 'stone-furnace'}}},
|
||||
{[22] = {entity = {name = 'assembling-machine-2'}}},
|
||||
{[22] = {entity = {name = 'oil-refinery'}}}
|
||||
}
|
||||
}
|
||||
|
||||
local templates = {
|
||||
{medium_gun_turrets, light_flame_turrets, laser_turrets, small_worm_turrets},
|
||||
{gear_factory[1]}
|
||||
--{base_templates.test[1]}
|
||||
}
|
||||
|
||||
local pattern = {}
|
||||
for r = 1, 100 do
|
||||
local row = {}
|
||||
pattern[r] = row
|
||||
for c = 1, 100 do
|
||||
local s =
|
||||
row[c] =
|
||||
outpost_builder:do_outpost(outpost_blocks, outpost_variance, outpost_min_step, outpost_max_level, templates)
|
||||
s = b.translate(s, -half_grid_size, -half_grid_size)
|
||||
row[c] = s
|
||||
end
|
||||
end
|
||||
|
||||
local outposts = b.grid_pattern(pattern, 100, 100, grid_size, grid_size)
|
||||
local map = b.if_else(outposts, b.full_shape)
|
||||
map = b.change_tile(map, true, 'grass-1')
|
||||
outposts = b.if_else(outposts, b.full_shape)
|
||||
|
||||
return map
|
||||
local thin_walls_player = OutpostBuilder.extend_walls(thin_walls, {force = 'player'})
|
||||
|
||||
local outpost =
|
||||
outpost_builder.to_shape(
|
||||
{
|
||||
size = 2,
|
||||
laser_turrets_player[1][1],
|
||||
iron_plate_factory[1]
|
||||
}
|
||||
)
|
||||
|
||||
local map = b.change_tile(outposts, true, 'grass-1')
|
||||
|
||||
--return b.full_shape
|
||||
--return map
|
||||
return outpost
|
||||
|
@ -28,9 +28,9 @@ local function get_mins(entities, tiles)
|
||||
return min_x, min_y
|
||||
end
|
||||
|
||||
local function output(result)
|
||||
local str = {}
|
||||
table.insert(str, 'return {\n')
|
||||
local function output(result, prepend)
|
||||
local str = {prepend}
|
||||
table.insert(str, '{\n')
|
||||
|
||||
for i, entry in pairs(result) do
|
||||
table.insert(str, '[')
|
||||
@ -130,7 +130,7 @@ function extract1(size)
|
||||
|
||||
entry.tile = e
|
||||
end
|
||||
output(result)
|
||||
output(result, 'return')
|
||||
end
|
||||
|
||||
function extract4(size)
|
||||
@ -193,5 +193,5 @@ function extract4(size)
|
||||
|
||||
entry.tile = e
|
||||
end
|
||||
output(result)
|
||||
output(result, 'ob.make_4_way')
|
||||
end
|
||||
|
151
map_gen/presets/crash_site/entity_died_events.lua
Normal file
151
map_gen/presets/crash_site/entity_died_events.lua
Normal file
@ -0,0 +1,151 @@
|
||||
local Event = require 'utils.event'
|
||||
local Task = require 'utils.Task'
|
||||
local Token = require 'utils.global_token'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local no_coin_entity = {}
|
||||
|
||||
Global.register(
|
||||
{no_coin_entity = no_coin_entity},
|
||||
function(tbl)
|
||||
no_coin_entity = tbl.no_coin_entity
|
||||
end
|
||||
)
|
||||
|
||||
local entity_drop_amount = {
|
||||
--[[['small-biter'] = {low = -62, high = 1},
|
||||
['small-spitter'] = {low = -62, high = 1},
|
||||
['medium-biter'] = {low = -14, high = 1},
|
||||
['medium-spitter'] = {low = -14, high = 1},
|
||||
['big-biter'] = {low = -2, high = 1},
|
||||
['big-spitter'] = {low = -2, high = 1},
|
||||
['behemoth-biter'] = {low = 1, high = 1},
|
||||
['behemoth-spitter'] = {low = 1, high = 1}, ]]
|
||||
['biter-spawner'] = {low = 5, high = 15},
|
||||
['spitter-spawner'] = {low = 5, high = 15},
|
||||
['small-worm-turret'] = {low = 2, high = 8},
|
||||
['medium-worm-turret'] = {low = 5, high = 15},
|
||||
['big-worm-turret'] = {low = 10, high = 20}
|
||||
}
|
||||
|
||||
local spill_items =
|
||||
Token.register(
|
||||
function(data)
|
||||
local stack = {name = 'coin', count = data.count}
|
||||
data.surface.spill_item_stack(data.position, stack, true)
|
||||
end
|
||||
)
|
||||
|
||||
local entity_spawn_map = {
|
||||
['medium-biter'] = 'small-worm-turret',
|
||||
['big-biter'] = 'medium-worm-turret',
|
||||
['behemoth-biter'] = 'big-worm-turret'
|
||||
}
|
||||
|
||||
local biters = {
|
||||
'small-biter',
|
||||
'medium-biter',
|
||||
'big-biter',
|
||||
'behemoth-biter'
|
||||
}
|
||||
|
||||
local spitters = {
|
||||
'small-spitter',
|
||||
'medium-spitter',
|
||||
'big-spitter',
|
||||
'behemoth-spitter'
|
||||
}
|
||||
|
||||
local spawn_worm =
|
||||
Token.register(
|
||||
function(data)
|
||||
local surface = data.surface
|
||||
local name = data.name
|
||||
local position = data.position
|
||||
|
||||
local p = surface.find_non_colliding_position(name, position, 8, 1)
|
||||
|
||||
if p then
|
||||
local entity = surface.create_entity({name = data.name, position = data.position})
|
||||
no_coin_entity[entity.unit_number] = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local function get_level()
|
||||
local ef = game.forces.player.evolution_factor
|
||||
return math.floor(ef * 4) + 1
|
||||
end
|
||||
|
||||
local spawn_units =
|
||||
Token.register(
|
||||
function(data)
|
||||
local surface = data.surface
|
||||
local name = data.name
|
||||
local position = data.position
|
||||
for _ = 1, 3 do
|
||||
local p = surface.find_non_colliding_position(name, position, 8, 1)
|
||||
if p then
|
||||
surface.create_entity {name = name, position = p}
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_entity_died,
|
||||
function(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local name = entity.name
|
||||
|
||||
local bounds = entity_drop_amount[name]
|
||||
if bounds then
|
||||
local unit_number = entity.unit_number
|
||||
if no_coin_entity[unit_number] then
|
||||
no_coin_entity[unit_number] = nil
|
||||
else
|
||||
local count = math.random(bounds.low, bounds.high)
|
||||
|
||||
if count > 0 then
|
||||
Task.set_timeout_in_ticks(
|
||||
1,
|
||||
spill_items,
|
||||
{count = count, surface = entity.surface, position = entity.position}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local spawn = entity_spawn_map[name]
|
||||
|
||||
if spawn then
|
||||
if math.random(5) == 1 then
|
||||
Task.set_timeout_in_ticks(
|
||||
1,
|
||||
spawn_worm,
|
||||
{surface = entity.surface, name = spawn, position = entity.position}
|
||||
)
|
||||
end
|
||||
else
|
||||
if name == 'biter-spawner' then
|
||||
local unit = biters[get_level()]
|
||||
Task.set_timeout_in_ticks(
|
||||
10,
|
||||
spawn_units,
|
||||
{surface = entity.surface, name = unit, position = entity.position}
|
||||
)
|
||||
elseif name == 'spitter-spawner' then
|
||||
local unit = spitters[get_level()]
|
||||
Task.set_timeout_in_ticks(
|
||||
10,
|
||||
spawn_units,
|
||||
{surface = entity.surface, name = unit, position = entity.position}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
@ -1,5 +1,9 @@
|
||||
local Random = require 'map_gen.shared.random'
|
||||
local Token = require 'utils.global_token'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local Task = require 'utils.Task'
|
||||
|
||||
local b = require 'map_gen.shared.builders'
|
||||
|
||||
local direction_bit_mask = 0xc0000000
|
||||
@ -29,6 +33,23 @@ local wall_west_inner = 0xe0000001
|
||||
local part_size = 6
|
||||
local inv_part_size = 1 / part_size
|
||||
|
||||
local refill_turrets = {index = 1}
|
||||
local power_sources = {}
|
||||
local magic_crafters = {index = 1}
|
||||
|
||||
Global.register(
|
||||
{
|
||||
refil_turrets = refill_turrets,
|
||||
power_sources = power_sources,
|
||||
magic_crafters = magic_crafters
|
||||
},
|
||||
function(tbl)
|
||||
refill_turrets = tbl.refil_turrets
|
||||
power_sources = tbl.power_sources
|
||||
magic_crafters = tbl.magic_crafters
|
||||
end
|
||||
)
|
||||
|
||||
local function get_direction(part)
|
||||
local dir = bit32.band(part, direction_bit_mask)
|
||||
return bit32.rshift(dir, direction_bit_shift - 1)
|
||||
@ -68,6 +89,8 @@ end
|
||||
local Public = {}
|
||||
Public.__index = Public
|
||||
|
||||
Public.empty_template = {}
|
||||
|
||||
function Public.new(seed)
|
||||
local obj = {random = Random.new(seed, seed * 2)}
|
||||
|
||||
@ -449,10 +472,12 @@ local function do_levels(blocks, max_level)
|
||||
end
|
||||
|
||||
local size = blocks.size
|
||||
|
||||
local level = 2
|
||||
|
||||
repeat
|
||||
local next_level = level + 1
|
||||
|
||||
for y = 1, size do
|
||||
local offset = (y - 1) * size
|
||||
for x = 1, size do
|
||||
@ -483,82 +508,136 @@ local function do_levels(blocks, max_level)
|
||||
|
||||
level = level + 1
|
||||
until level == max_level
|
||||
|
||||
local levels = {}
|
||||
blocks.levels = levels
|
||||
|
||||
for i = 1, max_level do
|
||||
levels[i] = {}
|
||||
end
|
||||
|
||||
for y = 1, size do
|
||||
local offset = (y - 1) * size
|
||||
for x = 1, size do
|
||||
local i = offset + x
|
||||
local block = blocks[i]
|
||||
if block then
|
||||
local l = get_level(block)
|
||||
table.insert(levels[l], i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local callback =
|
||||
Token.register(
|
||||
function(e)
|
||||
e.active = false
|
||||
end
|
||||
)
|
||||
local function make_blocks(self, blocks, templates)
|
||||
local random = self.random
|
||||
|
||||
local function outpost_shape(templates, blocks)
|
||||
local walls = templates[1] or {}
|
||||
local levels = blocks.levels
|
||||
local wall_level = levels[1]
|
||||
|
||||
local walls = templates[1]
|
||||
local wall_template_count = #walls
|
||||
for _, i in ipairs(wall_level) do
|
||||
local ti = random:next_int(1, wall_template_count)
|
||||
local template = walls[ti]
|
||||
|
||||
if template == Public.empty_template then
|
||||
blocks[i] = nil
|
||||
else
|
||||
local block = blocks[i]
|
||||
|
||||
local section = get_section(block)
|
||||
local dir = get_4_way_direction(block)
|
||||
|
||||
local new_block = template[section + 1][dir + 1]
|
||||
blocks[i] = new_block
|
||||
end
|
||||
end
|
||||
|
||||
for l = 2, #levels do
|
||||
local level = levels[l]
|
||||
local base_templates = templates[l]
|
||||
|
||||
if base_templates then
|
||||
local base_template_count = #base_templates
|
||||
|
||||
for _, i in ipairs(level) do
|
||||
local template
|
||||
if base_template_count == 0 then
|
||||
template = nil
|
||||
elseif base_template_count == 1 then
|
||||
template = base_templates[1]
|
||||
else
|
||||
local ti = random:next_int(1, base_template_count)
|
||||
template = base_templates[ti]
|
||||
end
|
||||
|
||||
if template == Public.empty_template then
|
||||
blocks[i] = nil
|
||||
else
|
||||
blocks[i] = template
|
||||
end
|
||||
end
|
||||
else
|
||||
for _, i in ipairs(level) do
|
||||
blocks[i] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function to_shape(blocks)
|
||||
local size = blocks.size
|
||||
local t_size = size * part_size
|
||||
local half_t_size = t_size * 0.5
|
||||
|
||||
return function(x, y)
|
||||
x, y = math.floor(x), math.floor(y)
|
||||
x, y = math.floor(x + half_t_size), math.floor(y + half_t_size)
|
||||
if x < 0 or y < 0 or x >= t_size or y >= t_size then
|
||||
return true
|
||||
end
|
||||
|
||||
local x2, y2 = math.floor(x * inv_part_size), math.floor(y * inv_part_size)
|
||||
if x2 < 1 or x2 > size or y2 < 1 or y2 > size then
|
||||
|
||||
local template = blocks[y2 * size + x2 + 1]
|
||||
if not template then
|
||||
return true
|
||||
end
|
||||
|
||||
local block = blocks[(y2 - 1) * size + x2]
|
||||
if not block then
|
||||
local x3, y3 = x - x2 * part_size, y - y2 * part_size
|
||||
|
||||
local i = y3 * part_size + x3 + 1
|
||||
|
||||
local entry = template[i]
|
||||
if not entry then
|
||||
return true
|
||||
end
|
||||
|
||||
local level = get_level(block)
|
||||
local entity = entry.entity
|
||||
local tile = entry.tile or true
|
||||
if entity then
|
||||
local data
|
||||
local callback = entity.callback
|
||||
if callback then
|
||||
local cd = template[callback]
|
||||
|
||||
local x3, y3 = x - x2 * part_size + 1, y - y2 * part_size + 1
|
||||
|
||||
local i = (y3 - 1) * part_size + x3
|
||||
|
||||
if level == 1 then
|
||||
local section = get_section(block)
|
||||
|
||||
local dir = get_4_way_direction(block)
|
||||
local lookup = dir + 1
|
||||
|
||||
local wall = walls[section + 1]
|
||||
|
||||
if not wall then
|
||||
return true
|
||||
callback = cd.callback
|
||||
data = cd.data
|
||||
end
|
||||
|
||||
local entry = wall[lookup][i]
|
||||
|
||||
if not entry then
|
||||
return true
|
||||
end
|
||||
|
||||
local tile = entry.tile or true
|
||||
local entity = entry.entity
|
||||
|
||||
if entity then
|
||||
local e_dir = (dir * 2 + (entry.direction or 0)) % 8
|
||||
return {tile = tile, entities = {{name = entity.name, direction = e_dir}}}
|
||||
end
|
||||
|
||||
return tile
|
||||
else
|
||||
local template = templates[level]
|
||||
if not template then
|
||||
return true
|
||||
end
|
||||
|
||||
local entry = template[i]
|
||||
if not entry then
|
||||
return
|
||||
end
|
||||
|
||||
local entity = entry.entity
|
||||
local tile = entry.tile or true
|
||||
if entity then
|
||||
return {tile = tile, entities = {{name = entity.name, direction = entity.direction}}}
|
||||
end
|
||||
return tile
|
||||
return {
|
||||
tile = tile,
|
||||
entities = {
|
||||
{
|
||||
name = entity.name,
|
||||
direction = entity.direction,
|
||||
force = template.force,
|
||||
callback = callback,
|
||||
data = data
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
return tile
|
||||
end
|
||||
end
|
||||
|
||||
@ -568,11 +647,43 @@ function Public:do_outpost(outpost_blocks, outpost_variance, outpost_min_step, m
|
||||
do_walls(self, blocks, outpost_variance, outpost_min_step)
|
||||
fill(blocks)
|
||||
do_levels(blocks, max_level)
|
||||
make_blocks(self, blocks, templates)
|
||||
|
||||
return outpost_shape(templates, blocks)
|
||||
return to_shape(blocks)
|
||||
end
|
||||
|
||||
function Public.to_shape(blocks)
|
||||
return to_shape(blocks)
|
||||
end
|
||||
|
||||
local function change_direction(entry, new_dir)
|
||||
local e = entry.entity
|
||||
if not e then
|
||||
return entry
|
||||
end
|
||||
|
||||
local copy = {}
|
||||
copy.tile = entry.tile
|
||||
|
||||
local ce = {}
|
||||
|
||||
copy.entity = ce
|
||||
for k, v in pairs(e) do
|
||||
ce[k] = v
|
||||
end
|
||||
ce.direction = new_dir
|
||||
|
||||
return copy
|
||||
end
|
||||
|
||||
function Public.make_1_way(data)
|
||||
data.__index = data
|
||||
return data
|
||||
end
|
||||
|
||||
function Public.make_4_way(data)
|
||||
local props = {}
|
||||
|
||||
local north = {}
|
||||
local east = {}
|
||||
local south = {}
|
||||
@ -580,44 +691,289 @@ function Public.make_4_way(data)
|
||||
local res = {north, east, south, west}
|
||||
|
||||
for i, entry in pairs(data) do
|
||||
local y = math.ceil(i * inv_part_size)
|
||||
local x = i - (y - 1) * part_size
|
||||
if type(i) == 'string' then
|
||||
props[i] = entry
|
||||
else
|
||||
local y = math.ceil(i * inv_part_size)
|
||||
local x = i - (y - 1) * part_size
|
||||
|
||||
local e = entry.entity
|
||||
local offset = e.offset
|
||||
local e = entry.entity or {}
|
||||
local offset = e.offset
|
||||
|
||||
local x2, x3, x4, y2, y3, y4
|
||||
local x2 = part_size - y + 1
|
||||
local y2 = x
|
||||
local x3 = part_size - x + 1
|
||||
local y3 = part_size - y + 1
|
||||
local x4 = y
|
||||
local y4 = part_size - x + 1
|
||||
|
||||
x2 = part_size - y + 1
|
||||
y2 = x
|
||||
x3 = part_size - x + 1
|
||||
y3 = part_size - y + 1
|
||||
x4 = y
|
||||
y4 = part_size - x + 1
|
||||
local i2 = (y2 - 1) * part_size + x2
|
||||
local i3 = (y3 - 1) * part_size + x3
|
||||
local i4 = (y4 - 1) * part_size + x4
|
||||
|
||||
local i2 = (y2 - 1) * part_size + x2
|
||||
local i3 = (y3 - 1) * part_size + x3
|
||||
local i4 = (y4 - 1) * part_size + x4
|
||||
if offset == 3 then
|
||||
i = i + 7
|
||||
i2 = i2 + 6
|
||||
i4 = i4 + 1
|
||||
elseif offset == 1 then
|
||||
i = i + 1
|
||||
i4 = i4 + 1
|
||||
elseif offset == 2 then
|
||||
i = i + 6
|
||||
i2 = i2 + 6
|
||||
end
|
||||
|
||||
if offset == 3 then
|
||||
i = i + 7
|
||||
i2 = i2 + 6
|
||||
i4 = i4 + 1
|
||||
elseif offset == 1 then
|
||||
i = i + 1
|
||||
i4 = i4 + 1
|
||||
elseif offset == 2 then
|
||||
i = i + 6
|
||||
i2 = i2 + 6
|
||||
local dir = e.direction or 0
|
||||
|
||||
north[i] = entry
|
||||
east[i2] = change_direction(entry, (dir + 2) % 8)
|
||||
south[i3] = change_direction(entry, (dir + 4) % 8)
|
||||
west[i4] = change_direction(entry, (dir + 6) % 8)
|
||||
end
|
||||
end
|
||||
|
||||
north[i] = entry
|
||||
east[i2] = entry
|
||||
south[i3] = entry
|
||||
west[i4] = entry
|
||||
north.__index = north
|
||||
east.__index = east
|
||||
south.__index = south
|
||||
west.__index = west
|
||||
|
||||
for k, v in pairs(props) do
|
||||
north[k] = v
|
||||
east[k] = v
|
||||
south[k] = v
|
||||
west[k] = v
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
local function shallow_copy(tbl)
|
||||
local copy = {}
|
||||
for k, v in pairs(tbl) do
|
||||
copy[k] = v
|
||||
end
|
||||
return copy
|
||||
end
|
||||
|
||||
function Public.extend_1_way(data, tbl)
|
||||
return setmetatable(shallow_copy(tbl), data)
|
||||
end
|
||||
|
||||
function Public.extend_4_way(data, tbl)
|
||||
return {
|
||||
setmetatable(shallow_copy(tbl), data[1]),
|
||||
setmetatable(shallow_copy(tbl), data[2]),
|
||||
setmetatable(shallow_copy(tbl), data[3]),
|
||||
setmetatable(shallow_copy(tbl), data[4])
|
||||
}
|
||||
end
|
||||
|
||||
function Public.extend_walls(data, tbl)
|
||||
return {
|
||||
Public.extend_4_way(data[1], tbl),
|
||||
Public.extend_4_way(data[2], tbl),
|
||||
Public.extend_4_way(data[3], tbl)
|
||||
}
|
||||
end
|
||||
|
||||
local function fast_remove(tbl, index)
|
||||
local count = #tbl
|
||||
if index > count then
|
||||
return
|
||||
elseif index < count then
|
||||
tbl[index] = tbl[count]
|
||||
end
|
||||
|
||||
tbl[count] = nil
|
||||
end
|
||||
|
||||
local function do_refill_turrets()
|
||||
local index = refill_turrets.index
|
||||
|
||||
if index > #refill_turrets then
|
||||
refill_turrets.index = 1
|
||||
return
|
||||
end
|
||||
|
||||
local data = refill_turrets[index]
|
||||
local turret = data.turret
|
||||
|
||||
if not turret.valid then
|
||||
fast_remove(refill_turrets, index)
|
||||
return
|
||||
end
|
||||
|
||||
refill_turrets.index = index + 1
|
||||
|
||||
local ammo = data.ammo
|
||||
if data.liquid then
|
||||
turret.fluidbox[1] = ammo
|
||||
elseif ammo then
|
||||
turret.insert(ammo)
|
||||
end
|
||||
end
|
||||
|
||||
local function do_magic_crafters()
|
||||
local index = magic_crafters.index
|
||||
|
||||
if index > #magic_crafters then
|
||||
magic_crafters.index = 1
|
||||
return
|
||||
end
|
||||
|
||||
local data = magic_crafters[index]
|
||||
|
||||
local entity = data.entity
|
||||
if not entity.valid then
|
||||
fast_remove(magic_crafters, index)
|
||||
return
|
||||
end
|
||||
|
||||
magic_crafters.index = index + 1
|
||||
|
||||
local tick = game.tick
|
||||
local last_tick = data.last_tick
|
||||
local rate = data.rate
|
||||
|
||||
local count = (tick - last_tick) * rate
|
||||
|
||||
local fcount = math.floor(count)
|
||||
|
||||
if fcount > 0 then
|
||||
local fluidbox_index = data.fluidbox_index
|
||||
if fluidbox_index then
|
||||
local fb = entity.fluidbox
|
||||
|
||||
local fb_data = fb[fluidbox_index] or {name = data.item, amount = 0}
|
||||
fb_data.amount = fb_data.amount + fcount
|
||||
fb[fluidbox_index] = fb_data
|
||||
else
|
||||
entity.get_output_inventory().insert {name = data.item, count = fcount}
|
||||
end
|
||||
data.last_tick = tick - (count - fcount) / rate
|
||||
end
|
||||
end
|
||||
|
||||
local function tick()
|
||||
do_refill_turrets()
|
||||
do_magic_crafters()
|
||||
end
|
||||
|
||||
Public.refill_turret_callback =
|
||||
Token.register(
|
||||
function(turret, ammo)
|
||||
table.insert(refill_turrets, {turret = turret, ammo = ammo})
|
||||
end
|
||||
)
|
||||
|
||||
Public.refill_liquid_turret_callback =
|
||||
Token.register(
|
||||
function(turret, ammo)
|
||||
table.insert(refill_turrets, {turret = turret, ammo = ammo, liquid = true})
|
||||
end
|
||||
)
|
||||
|
||||
Public.power_source_callback =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
local power_source =
|
||||
entity.surface.create_entity {name = 'hidden-electric-energy-interface', position = entity.position}
|
||||
power_source.electric_buffer_size = data.buffer_size
|
||||
power_source.power_production = data.power_production
|
||||
|
||||
power_sources[entity.unit_number] = power_source
|
||||
end
|
||||
)
|
||||
|
||||
local function add_magic_crafter_output(entity, output, distance)
|
||||
local rate = output.min_rate + output.distance_factor * distance
|
||||
table.insert(
|
||||
magic_crafters,
|
||||
{
|
||||
entity = entity,
|
||||
last_tick = game.tick,
|
||||
rate = rate,
|
||||
item = output.item,
|
||||
fluidbox_index = output.fluidbox_index
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local set_inactive_token =
|
||||
Token.register(
|
||||
function(entity)
|
||||
if entity.valid then
|
||||
entity.active = false
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.magic_item_crafting_callback =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
entity.minable = false
|
||||
entity.operable = false
|
||||
entity.destructible = false
|
||||
|
||||
local recipe = data.recipe
|
||||
if recipe then
|
||||
entity.set_recipe(recipe)
|
||||
else
|
||||
local furance_item = data.furance_item
|
||||
if furance_item then
|
||||
local inv = entity.get_inventory(2) -- defines.inventory.furnace_source
|
||||
inv.insert(furance_item)
|
||||
end
|
||||
end
|
||||
|
||||
local p = entity.position
|
||||
local distance = math.sqrt(p.x * p.x + p.y * p.y)
|
||||
|
||||
local output = data.output
|
||||
if #output == 0 then
|
||||
add_magic_crafter_output(entity, output, distance)
|
||||
else
|
||||
for _, o in ipairs(data.output) do
|
||||
add_magic_crafter_output(entity, o, distance)
|
||||
end
|
||||
end
|
||||
|
||||
Task.set_timeout_in_ticks(1, set_inactive_token, entity)
|
||||
end
|
||||
)
|
||||
|
||||
Public.deactivate_callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
entity.active = false
|
||||
entity.operable = false
|
||||
entity.destructible = false
|
||||
end
|
||||
)
|
||||
|
||||
local function remove_power_source(event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local number = entity.unit_number
|
||||
local ps = power_sources[number]
|
||||
power_sources[number] = nil
|
||||
|
||||
if ps and ps.valid then
|
||||
ps.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
Public.firearm_magazine_ammo = {name = 'firearm-magazine', count = 200}
|
||||
Public.piercing_rounds_magazine_ammo = {name = 'piercing-rounds-magazine', count = 200}
|
||||
Public.uranium_rounds_magazine_ammo = {name = 'uranium-rounds-magazine', count = 200}
|
||||
Public.light_oil_ammo = {name = 'light-oil', amount = 100}
|
||||
|
||||
Public.laser_turrent_power_source = {buffer_size = 2400000, power_production = 40000}
|
||||
|
||||
Event.add(defines.events.on_tick, tick)
|
||||
Event.add(defines.events.on_entity_died, remove_power_source)
|
||||
|
||||
return Public
|
||||
|
15
map_gen/presets/crash_site/outpost_data/gear_factory.lua
Normal file
15
map_gen/presets/crash_site/outpost_data/gear_factory.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_1_way {
|
||||
force = 'neutral',
|
||||
factory = {
|
||||
callback = ob.magic_item_crafting_callback,
|
||||
data = {
|
||||
recipe = 'iron-gear-wheel',
|
||||
output = {min_rate = 1 / 60, distance_factor = 1 / 60 / 100, item = 'iron-gear-wheel'}
|
||||
}
|
||||
},
|
||||
[15] = {entity = {name = 'assembling-machine-2', callback = 'factory'}}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
return {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[13] = {entity = {name = 'stone-wall'}},
|
||||
[14] = {entity = {name = 'stone-wall'}},
|
||||
[19] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'gun-turret', offset = 3}},
|
||||
[25] = {entity = {name = 'stone-wall'}},
|
||||
[26] = {entity = {name = 'stone-wall'}},
|
||||
[31] = {entity = {name = 'stone-wall'}},
|
||||
[32] = {entity = {name = 'stone-wall'}}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
return {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {entity = {name = 'gun-turret', offset = 3}},
|
||||
[22] = {entity = {name = 'gun-turret', offset = 3}}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
return {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'gun-turret', offset = 3}}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_1_way {
|
||||
force = 'neutral',
|
||||
factory = {
|
||||
callback = ob.magic_item_crafting_callback,
|
||||
data = {
|
||||
--furance_item = 'coin',
|
||||
output = {min_rate = 1 / 60, distance_factor = 1 / 60 / 100, item = 'coin'}
|
||||
}
|
||||
},
|
||||
[15] = {entity = {name = 'electric-furnace', callback = 'factory'}}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_4_way {
|
||||
turret = {callback = ob.refill_liquid_turret_callback, data = ob.light_oil_ammo},
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[27] = {
|
||||
entity = {
|
||||
name = 'flamethrower-turret',
|
||||
offset = 1,
|
||||
callback = 'turret'
|
||||
}
|
||||
}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[13] = {entity = {name = 'stone-wall'}},
|
||||
[14] = {entity = {name = 'stone-wall'}},
|
||||
[19] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {entity = {name = 'stone-wall'}},
|
||||
[23] = {entity = {name = 'flamethrower-turret', direction = 6, offset = 2}},
|
||||
[25] = {entity = {name = 'stone-wall'}},
|
||||
[26] = {entity = {name = 'stone-wall'}},
|
||||
[31] = {entity = {name = 'stone-wall'}},
|
||||
[32] = {entity = {name = 'stone-wall'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[23] = {entity = {name = 'flamethrower-turret', direction = 6, offset = 2}}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_4_way {
|
||||
turret = {callback = ob.power_source_callback, data = ob.laser_turrent_power_source},
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[21] = {
|
||||
entity = {
|
||||
name = 'laser-turret',
|
||||
offset = 3,
|
||||
callback = 'turret'
|
||||
}
|
||||
},
|
||||
[33] = {entity = {name = 'medium-electric-pole'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[13] = {entity = {name = 'stone-wall'}},
|
||||
[14] = {entity = {name = 'stone-wall'}},
|
||||
[19] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'laser-turret', offset = 3}},
|
||||
[25] = {entity = {name = 'stone-wall'}},
|
||||
[26] = {entity = {name = 'stone-wall'}},
|
||||
[31] = {entity = {name = 'stone-wall'}},
|
||||
[32] = {entity = {name = 'stone-wall'}},
|
||||
[36] = {entity = {name = 'medium-electric-pole'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'laser-turret', offset = 3}},
|
||||
[36] = {entity = {name = 'medium-electric-pole'}}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_4_way {
|
||||
turret = {callback = ob.refill_turret_callback, data = ob.piercing_rounds_magazine_ammo},
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {
|
||||
entity = {
|
||||
name = 'gun-turret',
|
||||
offset = 3,
|
||||
callback = 'turret'
|
||||
}
|
||||
},
|
||||
[22] = {entity = {name = 'gun-turret', offset = 3}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[13] = {entity = {name = 'stone-wall'}},
|
||||
[14] = {entity = {name = 'stone-wall'}},
|
||||
[19] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'gun-turret', offset = 3}},
|
||||
[25] = {entity = {name = 'stone-wall'}},
|
||||
[26] = {entity = {name = 'stone-wall'}},
|
||||
[31] = {entity = {name = 'stone-wall'}},
|
||||
[32] = {entity = {name = 'stone-wall'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'gun-turret', offset = 3}}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_1_way {
|
||||
force = 'neutral',
|
||||
factory = {
|
||||
callback = ob.magic_item_crafting_callback,
|
||||
data = {
|
||||
recipe = 'basic-oil-processing',
|
||||
output = {
|
||||
{item = 'petroleum-gas',fluidbox_index = 1, min_rate = 4 / 60, distance_factor = 4 / 60 / 100},
|
||||
{item = 'light-oil',fluidbox_index = 2, min_rate = 3 / 60, distance_factor = 3 / 60 / 100},
|
||||
{item = 'heavy-oil',fluidbox_index = 3, min_rate = 3 / 60, distance_factor = 3 / 60 / 100}
|
||||
}
|
||||
}
|
||||
},
|
||||
[15] = {entity = {name = 'oil-refinery', callback = 'factory'}}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[21] = {entity = {name = 'small-worm-turret', offset = 3}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[13] = {entity = {name = 'stone-wall'}},
|
||||
[14] = {entity = {name = 'stone-wall'}},
|
||||
[19] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'small-worm-turret', offset = 3}},
|
||||
[25] = {entity = {name = 'stone-wall'}},
|
||||
[26] = {entity = {name = 'stone-wall'}},
|
||||
[31] = {entity = {name = 'stone-wall'}},
|
||||
[32] = {entity = {name = 'stone-wall'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[22] = {entity = {name = 'small-worm-turret', offset = 3}}
|
||||
}
|
||||
}
|
29
map_gen/presets/crash_site/outpost_data/thin_walls.lua
Normal file
29
map_gen/presets/crash_site/outpost_data/thin_walls.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_4_way {
|
||||
force = 'player',
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[13] = {entity = {name = 'stone-wall'}},
|
||||
[19] = {entity = {name = 'stone-wall'}},
|
||||
[25] = {entity = {name = 'stone-wall'}},
|
||||
[31] = {entity = {name = 'stone-wall'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}}
|
||||
}
|
||||
}
|
46
map_gen/presets/crash_site/outpost_data/walls.lua
Normal file
46
map_gen/presets/crash_site/outpost_data/walls.lua
Normal file
@ -0,0 +1,46 @@
|
||||
local ob = require 'map_gen.presets.crash_site.outpost_builder'
|
||||
|
||||
return {
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[3] = {entity = {name = 'stone-wall'}},
|
||||
[4] = {entity = {name = 'stone-wall'}},
|
||||
[5] = {entity = {name = 'stone-wall'}},
|
||||
[6] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}},
|
||||
[9] = {entity = {name = 'stone-wall'}},
|
||||
[10] = {entity = {name = 'stone-wall'}},
|
||||
[11] = {entity = {name = 'stone-wall'}},
|
||||
[12] = {entity = {name = 'stone-wall'}},
|
||||
[13] = {entity = {name = 'stone-wall'}},
|
||||
[14] = {entity = {name = 'stone-wall'}},
|
||||
[19] = {entity = {name = 'stone-wall'}},
|
||||
[20] = {entity = {name = 'stone-wall'}},
|
||||
[25] = {entity = {name = 'stone-wall'}},
|
||||
[26] = {entity = {name = 'stone-wall'}},
|
||||
[31] = {entity = {name = 'stone-wall'}},
|
||||
[32] = {entity = {name = 'stone-wall'}}
|
||||
},
|
||||
ob.make_4_way {
|
||||
[1] = {entity = {name = 'stone-wall'}},
|
||||
[2] = {entity = {name = 'stone-wall'}},
|
||||
[7] = {entity = {name = 'stone-wall'}},
|
||||
[8] = {entity = {name = 'stone-wall'}}
|
||||
}
|
||||
}
|
47
map_gen/presets/crash_site/weapon_balance.lua
Normal file
47
map_gen/presets/crash_site/weapon_balance.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local ammos = {
|
||||
{name = 'artillery-shell', amount = -0.75},
|
||||
{name = 'biological', amount = 0},
|
||||
{name = 'bullet', amount = -0.5},
|
||||
{name = 'cannon-shell', amount = -0.5},
|
||||
{name = 'capsule', amount = -0.5},
|
||||
{name = 'combat-robot-beam', amount = -0.5},
|
||||
{name = 'combat-robot-laser', amount = -0.5},
|
||||
{name = 'electric', amount = -0.5},
|
||||
{name = 'flamethrower', amount = -0.75},
|
||||
{name = 'grenade', amount = -0.5},
|
||||
{name = 'landmine', amount = 0},
|
||||
{name = 'laser-turret', amount = -0.75},
|
||||
{name = 'melee', amount = 0},
|
||||
{name = 'railgun', amount = 0},
|
||||
{name = 'rocket', amount = -0.5},
|
||||
{name = 'shotgun-shell', amount = -0.5}
|
||||
}
|
||||
|
||||
local function init_weapon_damage()
|
||||
local forces = game.forces
|
||||
local p_force = forces.player
|
||||
|
||||
for _, a in ipairs(ammos) do
|
||||
p_force.set_ammo_damage_modifier(a.name, a.amount)
|
||||
end
|
||||
|
||||
--[[ local e_force = forces.enemy
|
||||
|
||||
e_force.artillery_range_modifier = -0.5 -- can't be negative :( ]]
|
||||
end
|
||||
|
||||
local function enemy_weapon_damage()
|
||||
local f = game.forces.enemy
|
||||
|
||||
local ef = game.forces.player.evolution_factor
|
||||
|
||||
f.set_ammo_damage_modifier('melee', ef)
|
||||
f.set_ammo_damage_modifier('biological', ef)
|
||||
end
|
||||
|
||||
Event.on_init(init_weapon_damage)
|
||||
|
||||
Event.on_nth_tick(18000, enemy_weapon_damage)
|
Loading…
Reference in New Issue
Block a user