1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-30 04:30:58 +02:00

Tweaked stress values and fixed a bug regarding tile placement

This commit is contained in:
Lynn 2018-10-07 19:40:30 +02:00
parent 36168771dd
commit 4d0a3b9e7f
5 changed files with 70 additions and 43 deletions

View File

@ -49,25 +49,25 @@ local Config = {
mask_relative_ring_weights = {2,3,4},
-- delay in seconds before the cave collapses
collapse_delay_min = 1.5,
collapse_delay_max = 3,
collapse_delay = 2.5,
-- the threshold that will be applied to all neighbors on a collapse via a mask
collapse_threshold_total_strength = 15,
support_beam_entities = {
['stone-wall'] = 1,
['sand-rock-big'] = 1,
['market'] = 9,
['stone-wall'] = 2.5,
['sand-rock-big'] = 2,
['out-of-map'] = 1,
['stone-brick'] = 0.05,
['stone-path'] = 0.05,
['concrete'] = 0.1,
['hazard-concrete-left'] = 0.1,
['hazard-concrete-right'] = 0.1,
['refined-concrete'] = 0.1,
['stone-brick'] = 0.07,
['stone-path'] = 0.07,
['concrete'] = 0.11,
['hazard-concrete-left'] = 0.11,
['hazard-concrete-right'] = 0.11,
['refined-concrete'] = 0.15,
['refined-hazard-concrete-left'] = 0.15,
['refined-hazard-concrete-right'] = 0.15,
['deepwater-green'] = 0.2,
['deepwater-green'] = 0.7,
},
cracking_sounds = {
'CRACK',

View File

@ -32,10 +32,10 @@ local disc_value = 0
local ring_value = 0
local enable_stress_grid = 0
local stress_map_blur_add = nil
local mask_disc_blur = nil
local stress_map_check_stress_in_threshold = nil
local support_beam_entities = nil
local stress_map_blur_add
local mask_disc_blur
local stress_map_check_stress_in_threshold
local support_beam_entities
DiggyCaveCollapse.events = {
--[[--
@ -142,19 +142,23 @@ end
local function on_collapse_triggered(event)
spawn_cracking_sound_text(event.surface, event.position)
Task.set_timeout(
math.random(config.collapse_delay_min * 10, config.collapse_delay_max * 10) / 10,
config.collapse_delay,
on_collapse_timeout_finished,
{surface = event.surface, position = event.position}
)
end
local function on_built_tile(event)
local strength = support_beam_entities[event.item.name]
local function on_built_tile(surface, new_tile, tiles)
local new_tile_strength = support_beam_entities[new_tile.name]
if strength then
local surface = game.surfaces[event.surface_index]
for _, tile in pairs(event.tiles) do
stress_map_blur_add(surface, tile.position, -1 * strength, 'on_built_tile')
for _, tile in pairs(tiles) do
if new_tile_strength then
stress_map_blur_add(surface, tile.position, -1 * new_tile_strength, 'on_built_tile')
end
local old_tile_strength = support_beam_entities[tile.old_tile.name]
if (old_tile_strength) then
stress_map_blur_add(surface, tile.position, old_tile_strength, 'on_built_tile')
end
end
end
@ -234,8 +238,12 @@ function DiggyCaveCollapse.register(cfg)
Event.add(DiggyCaveCollapse.events.on_collapse_triggered, on_collapse_triggered)
Event.add(defines.events.on_robot_built_entity, on_built_entity)
Event.add(defines.events.on_robot_built_tile, on_built_tile)
Event.add(defines.events.on_player_built_tile, on_built_tile)
Event.add(defines.events.on_robot_built_tile, function (event)
on_built_tile(event.robot.surface, event.item, event.tiles)
end)
Event.add(defines.events.on_player_built_tile, function (event)
on_built_tile(game.surfaces[event.surface_index], event.item, event.tiles)
end)
Event.add(defines.events.on_robot_mined_tile, on_robot_mined_tile)
Event.add(defines.events.on_player_mined_tile, on_player_mined_tile)
Event.add(defines.events.on_robot_mined_entity, on_mined_entity)
@ -265,7 +273,7 @@ end
--
--STRESS MAP
--
local stress_threshold_causing_collapse = 0.9
local stress_threshold_causing_collapse = 0.91
-- main block
global.stress_map_storage = {}

View File

@ -49,6 +49,31 @@ local artificial_tiles = {
['deepwater-green'] = true,
}
local function on_mined_tile(surface, tiles)
local new_tiles = {}
for _, tile in pairs(tiles) do
if (artificial_tiles[tile.old_tile.name]) then
table.insert(new_tiles, { name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
end
Template.insert(surface, new_tiles, {})
end
local function on_built_tile(surface, item, old_tile_and_positions)
if ('landfill' ~= item.name) then
return
end
local tiles = {}
for _, tile in pairs(old_tile_and_positions) do
table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
Template.insert(surface, tiles)
end
--[[--
Registers all event handlers.
]]
@ -68,27 +93,19 @@ function DiggyHole.register(config)
end)
Event.add(defines.events.on_robot_mined_tile, function(event)
local tiles = {}
for _, tile in pairs(event.tiles) do
if (artificial_tiles[tile.old_tile.name]) then
table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
end
Template.insert(event.robot.surface, tiles, {})
on_mined_tile(event.robot.surface, event.tiles)
end)
Event.add(defines.events.on_player_mined_tile, function(event)
local tiles = {}
on_mined_tile(game.surfaces[event.surface_index], event.tiles)
end)
for _, tile in pairs(event.tiles) do
if (artificial_tiles[tile.old_tile.name]) then
table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
end
Event.add(defines.events.on_robot_built_tile, function (event)
on_built_tile(event.robot.surface, item, tiles)
end)
Template.insert(game.surfaces[event.surface_index], tiles, {})
Event.add(defines.events.on_player_built_tile, function (event)
on_built_tile(game.surfaces[event.surface_index], event.item, event.tiles)
end)
end

View File

@ -34,8 +34,8 @@ local function handle_noise(name, surface, position)
Task.set_timeout_in_ticks(1, do_mine, {surface = surface, position = position})
if ('water' == name) then
-- water is lower because for some odd reason it doesn't always want to mine it properly
Task.set_timeout_in_ticks(5, do_spawn_tile, { surface = surface, tile = { name = 'deepwater-green', position = position}})
-- water is slower because for some odd reason it doesn't always want to mine it properly
Task.set_timeout_in_ticks(3, do_spawn_tile, { surface = surface, tile = { name = 'deepwater-green', position = position}})
return
end

View File

@ -215,6 +215,8 @@ function Template.market(surface, position, force, currency_item, market_invento
text = ' Market',
position = position,
})
script.raise_event(Template.events.on_placed_entity, {entity = market})
end
return Template