mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-09 13:37:02 +02:00
optimizations and tweaks
This commit is contained in:
parent
07516cb0f6
commit
cb269780b5
@ -339,7 +339,8 @@ local function on_entity_died(event)
|
||||
if event.entity.type == "unit" then
|
||||
global.active_biters[event.entity.force.name][event.entity.unit_number] = nil
|
||||
end
|
||||
global.bb_threat[event.entity.force.name] = global.bb_threat[event.entity.force.name] - threat_values[event.entity.name]
|
||||
global.bb_threat[event.entity.force.name] = global.bb_threat[event.entity.force.name] - threat_values[event.entity.name]
|
||||
refresh_gui_threat()
|
||||
end
|
||||
|
||||
--Flamethrower Turret Nerf
|
||||
|
@ -187,10 +187,9 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
|
||||
local function on_init(surface)
|
||||
if game.surfaces["biter_battles"] then return end
|
||||
init_surface()
|
||||
init_forces()
|
||||
|
||||
global.gui_refresh_delay = 0
|
||||
global.bb_debug = false
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- biters will landfill a tile on death within a certain radius
|
||||
|
||||
local r = 6
|
||||
local r = 3
|
||||
local vectors = {{0,0}, {1,0}, {0,1}, {-1,0}, {0,-1}}
|
||||
local math_random = math.random
|
||||
|
||||
|
@ -21,6 +21,9 @@ local function on_console_chat(event)
|
||||
game.forces.spectator.print(player.name .. " (south): ".. event.message, color)
|
||||
game.forces.player.print(player.name .. " (south): ".. event.message, color)
|
||||
end
|
||||
|
||||
if global.tournament_mode then return end
|
||||
|
||||
if player.force.name == "player" then
|
||||
game.forces.north.print(player.name .. " (spawn): ".. event.message, color)
|
||||
game.forces.south.print(player.name .. " (spawn): ".. event.message, color)
|
||||
|
@ -14,7 +14,7 @@ bb_config = {
|
||||
["blueprint_string_importing"] = false, --Allow the importing of blueprints via blueprint strings?
|
||||
|
||||
--MAP PREGENERATION--
|
||||
["map_pregeneration_radius"] = 38, --Radius in chunks to pregenerate at the start of the map.
|
||||
["map_pregeneration_radius"] = 28, --Radius in chunks to pregenerate at the start of the map.
|
||||
["fast_pregen"] = false, --Force fast pregeneration.
|
||||
|
||||
--TERRAIN OPTIONS--
|
||||
|
@ -149,7 +149,7 @@ local function create_main_gui(player)
|
||||
end
|
||||
end
|
||||
|
||||
local t = frame.add { type = "table", column_count = 4 }
|
||||
local t = frame.add { type = "table", name = "stats_" .. gui_value.force, column_count = 4 }
|
||||
local l = t.add { type = "label", caption = "Evo:"}
|
||||
--l.style.minimal_width = 25
|
||||
l.tooltip = gui_value.t1
|
||||
@ -163,7 +163,7 @@ local function create_main_gui(player)
|
||||
local l = t.add {type = "label", caption = "Threat: "}
|
||||
l.style.minimal_width = 25
|
||||
l.tooltip = gui_value.t2
|
||||
local l = t.add {type = "label", caption = math.floor(global.bb_threat[gui_value.biter_force])}
|
||||
local l = t.add {type = "label", name = "threat_" .. gui_value.force, caption = math.floor(global.bb_threat[gui_value.biter_force])}
|
||||
l.style.font_color = gui_value.color2
|
||||
l.style.font = "default-bold"
|
||||
l.style.minimal_width = 25
|
||||
@ -202,6 +202,20 @@ local function refresh_gui()
|
||||
create_main_gui(player)
|
||||
end
|
||||
end
|
||||
global.gui_refresh_delay = game.tick + 5
|
||||
end
|
||||
|
||||
function refresh_gui_threat()
|
||||
if global.gui_refresh_delay > game.tick then return end
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.gui.left["bb_main_gui"] then
|
||||
if player.gui.left["bb_main_gui"].stats_north then
|
||||
player.gui.left["bb_main_gui"].stats_north.threat_north.caption = math.floor(global.bb_threat["north_biters"])
|
||||
player.gui.left["bb_main_gui"].stats_south.threat_south.caption = math.floor(global.bb_threat["south_biters"])
|
||||
end
|
||||
end
|
||||
end
|
||||
global.gui_refresh_delay = game.tick + 5
|
||||
end
|
||||
|
||||
function join_team(player, force_name, forced_join)
|
||||
|
@ -66,10 +66,7 @@ local function on_tick(event)
|
||||
return
|
||||
end
|
||||
|
||||
--if game.tick % 1800 ~= 0 then return end
|
||||
|
||||
if game.tick % 3600 ~= 0 then return end
|
||||
--if game.tick % 7200 ~= 0 then return end
|
||||
ai.raise_evo()
|
||||
ai.destroy_inactive_biters()
|
||||
ai.main_attack()
|
||||
|
@ -1,6 +1,6 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local function set_chunk_coords(radius)
|
||||
local function set_chunk_coords_old(radius)
|
||||
global.chunk_gen_coords = {}
|
||||
for r = radius, 1, -1 do
|
||||
for x = r * -1, r - 1, 1 do
|
||||
@ -22,6 +22,37 @@ local function set_chunk_coords(radius)
|
||||
end
|
||||
end
|
||||
|
||||
local function shrink_table()
|
||||
local t = {}
|
||||
for k, chunk in pairs(global.chunk_gen_coords) do
|
||||
t[chunk.x .. "_" .. chunk.y] = {key = k, chunk = {x = chunk.x, y = chunk.y}}
|
||||
end
|
||||
global.chunk_gen_coords = {}
|
||||
for k, chunk in pairs(t) do
|
||||
global.chunk_gen_coords[#global.chunk_gen_coords + 1] = {x = chunk.x, y = chunk.y}
|
||||
end
|
||||
game.print(global.chunk_gen_coords[#global.chunk_gen_coords])
|
||||
end
|
||||
|
||||
local vectors = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}
|
||||
function set_chunk_coords(position, radius)
|
||||
if not global.chunk_gen_coords then global.chunk_gen_coords = {} end
|
||||
position.x = position.x - radius
|
||||
position.y = position.y - radius
|
||||
for r = radius, 1, -1 do
|
||||
for _, v in pairs(vectors) do
|
||||
for a = 1, r * 2 - 1, 1 do
|
||||
position.x = position.x + v[1]
|
||||
position.y = position.y + v[2]
|
||||
global.chunk_gen_coords[#global.chunk_gen_coords + 1] = {x = position.x, y = position.y}
|
||||
end
|
||||
end
|
||||
position.x = position.x + 1
|
||||
position.y = position.y + 1
|
||||
end
|
||||
global.chunk_gen_coords[#global.chunk_gen_coords + 1] = {x = position.x, y = position.y}
|
||||
end
|
||||
|
||||
local function draw_gui()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if global.map_generation_complete then
|
||||
@ -48,7 +79,11 @@ local function process_chunk(surface)
|
||||
if global.map_generation_complete then return end
|
||||
if game.tick < 300 then return end
|
||||
if not global.chunk_gen_coords then
|
||||
set_chunk_coords(bb_config.map_pregeneration_radius)
|
||||
set_chunk_coords({x = bb_config.map_pregeneration_radius * 2, y = 0}, bb_config.map_pregeneration_radius)
|
||||
set_chunk_coords({x = bb_config.map_pregeneration_radius * -2, y = 0}, bb_config.map_pregeneration_radius)
|
||||
set_chunk_coords({x = 0, y = 0}, bb_config.map_pregeneration_radius)
|
||||
--shrink_table()
|
||||
--set_chunk_coords()
|
||||
--table.shuffle_table(global.chunk_gen_coords)
|
||||
end
|
||||
if #global.chunk_gen_coords == 0 then
|
||||
@ -64,7 +99,7 @@ local function process_chunk(surface)
|
||||
local surface = game.surfaces["biter_battles"]
|
||||
if not surface then return end
|
||||
|
||||
local force_chunk_requests = 2
|
||||
local force_chunk_requests = 3
|
||||
if bb_config.fast_pregen then force_chunk_requests = 16 end
|
||||
|
||||
for i = #global.chunk_gen_coords, 1, -1 do
|
||||
|
@ -125,19 +125,28 @@ function is_within_spawn_circle(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
local river_y_1 = bb_config.border_river_width * -1.5
|
||||
local river_y_2 = bb_config.border_river_width * 1.5
|
||||
function is_horizontal_border_river(pos)
|
||||
if pos.y < river_y_1 then return false end
|
||||
if pos.y > river_y_2 then return false end
|
||||
if pos.y > -5 and pos.x > -5 and pos.x < 5 then return false end
|
||||
if math.floor(bb_config.border_river_width * -0.5) < pos.y + (get_noise(1, pos) * 5) then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
local function generate_circle_spawn(event)
|
||||
if global.bb_circle_spawn_generated then return end
|
||||
if global.bb_spawn_generated then return end
|
||||
|
||||
local surface = event.surface
|
||||
if surface.is_chunk_generated({-8, -8}) then global.bb_circle_spawn_generated = true end
|
||||
|
||||
local left_top_x = event.area.left_top.x
|
||||
local left_top_y = event.area.left_top.y
|
||||
|
||||
if left_top_x < -320 then return end
|
||||
if left_top_x > 320 then return end
|
||||
if left_top_y < -320 then return end
|
||||
|
||||
local r = 101
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
@ -205,14 +214,7 @@ local function generate_circle_spawn(event)
|
||||
regenerate_decoratives(surface, event.area.left_top)
|
||||
end
|
||||
|
||||
local function generate_silos(event)
|
||||
if global.bb_silos_generated then return end
|
||||
if event.area.left_top.x ~= -128 then return end
|
||||
if event.area.left_top.y ~= -128 then return end
|
||||
global.bb_silos_generated = true
|
||||
|
||||
local surface = event.surface
|
||||
|
||||
local function generate_north_silo(surface)
|
||||
local pos = {x = -12 + math.random(0, 24), y = -64 + math.random(0, 16)}
|
||||
|
||||
for _, t in pairs(surface.find_tiles_filtered({area = {{pos.x - 6, pos.y - 6},{pos.x + 6, pos.y + 6}}, name = {"water", "deepwater"}})) do
|
||||
@ -248,36 +250,6 @@ local function generate_river(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function rainbow_ore_and_ponds(event)
|
||||
local surface = event.surface
|
||||
local left_top_x = event.area.left_top.x
|
||||
local left_top_y = event.area.left_top.y
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top_x + x, y = left_top_y + y}
|
||||
if surface.can_place_entity({name = "iron-ore", position = pos}) then
|
||||
local noise = get_noise(1, pos)
|
||||
if noise > 0.85 then
|
||||
local amount = math_random(750, 1500) + math.sqrt(pos.x ^ 2 + pos.y ^ 2) * 1.1
|
||||
local m = (noise - 0.82) * 40
|
||||
amount = amount * m
|
||||
local i = math.ceil(math.abs(noise * 75)) % 4
|
||||
if i == 0 then i = 4 end
|
||||
surface.create_entity({name = ores[i], position = pos, amount = amount})
|
||||
end
|
||||
--if noise < -0.79 then
|
||||
-- if noise < -0.85 then
|
||||
-- surface.set_tiles({{name = "deepwater", position = pos}})
|
||||
-- else
|
||||
-- surface.set_tiles({{name = "water", position = pos}})
|
||||
-- end
|
||||
-- if math_random(1, 48) == 1 then surface.create_entity({name = "fish", position = pos}) end
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_potential_spawn_ore(surface)
|
||||
local r = 130
|
||||
local area = {{r * -1, r * -1}, {r, 0}}
|
||||
@ -418,6 +390,28 @@ local function builders_area_process_tile(t, surface)
|
||||
end
|
||||
end
|
||||
|
||||
local function mixed_ore(event)
|
||||
local surface = event.surface
|
||||
local left_top_x = event.area.left_top.x
|
||||
local left_top_y = event.area.left_top.y
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top_x + x, y = left_top_y + y}
|
||||
if surface.can_place_entity({name = "iron-ore", position = pos}) then
|
||||
local noise = get_noise(1, pos)
|
||||
if noise > 0.85 then
|
||||
local amount = math_random(750, 1500) + math.sqrt(pos.x ^ 2 + pos.y ^ 2) * 1.1
|
||||
local m = (noise - 0.82) * 40
|
||||
amount = amount * m
|
||||
local i = math.ceil(math.abs(noise * 75)) % 4
|
||||
if i == 0 then i = 4 end
|
||||
surface.create_entity({name = ores[i], position = pos, amount = amount})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
if event.area.left_top.y >= 0 then return end
|
||||
local surface = event.surface
|
||||
@ -428,10 +422,9 @@ local function on_chunk_generated(event)
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
rainbow_ore_and_ponds(event)
|
||||
mixed_ore(event)
|
||||
generate_river(event)
|
||||
generate_circle_spawn(event)
|
||||
generate_silos(event)
|
||||
generate_circle_spawn(event)
|
||||
|
||||
if bb_config.builders_area then
|
||||
for _, t in pairs(surface.find_tiles_filtered({area = event.area, name = {"water", "deepwater"}})) do
|
||||
@ -448,7 +441,8 @@ local function on_chunk_generated(event)
|
||||
generate_scrap(event)
|
||||
end
|
||||
|
||||
if event.area.left_top.y == -320 and event.area.left_top.x == -320 then
|
||||
if global.bb_spawn_generated then return end
|
||||
if game.tick > 0 then
|
||||
generate_potential_spawn_ore(surface)
|
||||
|
||||
local area = {{-10,-10},{10,10}}
|
||||
@ -464,6 +458,8 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
global.bb_spawn_generated = true
|
||||
end
|
||||
end
|
||||
|
||||
@ -512,6 +508,21 @@ local function on_marked_for_deconstruction(event)
|
||||
if event.entity.name == "fish" then event.entity.cancel_deconstruction(game.players[event.player_index].force.name) end
|
||||
end
|
||||
|
||||
local function on_init(surface)
|
||||
server_commands.to_discord_embed("Generating chunks...")
|
||||
print("Generating chunks...")
|
||||
|
||||
local surface = game.surfaces["biter_battles"]
|
||||
surface.request_to_generate_chunks({x = 0, y = -512}, 16)
|
||||
surface.request_to_generate_chunks({x = 1024, y = -512}, 16)
|
||||
surface.request_to_generate_chunks({x = -1024, y = -512}, 16)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
generate_north_silo(surface)
|
||||
end
|
||||
|
||||
event.on_init(on_init)
|
||||
|
||||
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
|
||||
|
Loading…
x
Reference in New Issue
Block a user