1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00

biter_battles_v2 update

This commit is contained in:
MewMew 2019-03-14 01:00:20 +01:00
parent ceba7c619d
commit 64ea71db6e
4 changed files with 72 additions and 27 deletions

View File

@ -19,7 +19,7 @@ require "score"
require "on_tick_schedule"
---- enable modules here ----
--require "tools.cheat_mode"
require "tools.cheat_mode"
--require "modules.hunger"
--require "modules.area_unlocked_on_rotated_entity"
--require "modules.fish_respawner"
@ -40,7 +40,7 @@ require "on_tick_schedule"
-----------------------------
---- enable maps here ----
require "maps.biter_battles_v2.biter_battles_v2"
--require "maps.biter_battles_v2.biter_battles_v2"
--require "maps.biter_battles"
--require "maps.cave_miner"
--require "maps.labyrinth"

View File

@ -1460,11 +1460,24 @@ local function on_player_built_tile(event)
end
end
local function on_robot_built_tile(event)
local surface = event.robot.surface
for _, t in pairs(event.tiles) do
local distance_to_center = math.sqrt(t.position.x ^ 2 + t.position.y ^ 2)
if generate_horizontal_river(surface, t.position) or distance_to_center < spawn_circle_size then
surface.set_tiles({{name = t.old_tile, position = t.position}}, true)
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
inventory.insert({name = "landfill", count = 1})
end
end
end
local function on_research_finished(event)
--game.forces.north.recipes["flamethrower-turret"].enabled = false
--game.forces.south.recipes["flamethrower-turret"].enabled = false
end
event.add(defines.events.on_robot_built_tile, on_robot_built_tile)
event.add(defines.events.on_chunk_generated, on_chunk_generated)
event.add(defines.events.on_research_finished, on_research_finished)
event.add(defines.events.on_built_entity, on_built_entity)

View File

@ -25,7 +25,8 @@ local function init_surface(event)
["trees"] = {frequency = "0.8", size = "0.5", richness = "0.3"},
["enemy-base"] = {frequency = "0.8", size = "1", richness = "0.4"}
}
game.create_surface("biter_battles", map_gen_settings)
--game.create_surface("biter_battles", map_gen_settings)
end
local function on_player_joined_game(event)

View File

@ -2,7 +2,8 @@
local event = require 'utils.event'
local math_random = math.random
local simplex_noise = require 'utils.simplex_noise'.d2
local biter_territory_starting_radius = 160
local biter_territory_starting_radius = 256
local spawn_circle_size = 30
local worms = {
[1] = {"small-worm-turret"},
@ -68,29 +69,28 @@ local function generate_biters(surface, pos, distance_to_center)
end
end
local function generate_horizontal_river(surface, pos, distance_to_center)
if pos.y < -32 then return end
if -14 > pos.y + (get_noise(1, pos) * 5) then return true end
local function generate_horizontal_river(surface, pos)
if pos.y < -32 then return false end
if -14 < pos.y + (get_noise(1, pos) * 5) then return true end
return false
end
local function generate_circle_spawn(surface, pos, distance_to_center)
local function generate_circle_spawn(surface)
for x = -33, 33, 1 do
for y = -33, 33, 1 do
local distance_to_center = math.sqrt(x ^ 2 + y ^ 2)
local pos = {x = x, y = y}
local tile = false
if distance_to_center < spawn_circle_size then tile = "deepwater" end
if distance_to_center < 10 then tile = "refined-concrete" end
if distance_to_center < 7 then tile = "sand-1" end
if tile then surface.set_tiles({{name = tile, position = pos}}, true) end
end
end
end
if pos.y < -64 then return end
if pos.x > 64 then return end
if pos.x < -64 then return end
local function generate_silos()
if distance_to_center < 8 then
surface.set_tiles({{name = "sand-1", position = pos}})
return
end
if distance_to_center < 12 then
surface.set_tiles({{name = "refined-concrete", position = pos}})
return
end
if distance_to_center < 32 then
surface.set_tiles({{name = "deepwater", position = pos}})
return
end
end
local function on_chunk_generated(event)
@ -108,11 +108,42 @@ local function on_chunk_generated(event)
local pos = {x = left_top_x + x, y = left_top_y + y}
local distance_to_center = math.sqrt(pos.x ^ 2 + pos.y ^ 2)
if generate_horizontal_river(surface, pos) then surface.set_tiles({{name = "deepwater", position = pos}}) end
generate_circle_spawn(surface, pos, distance_to_center)
generate_biters(surface, pos, distance_to_center)
end
end
if event.area.left_top.y == -256 and event.area.left_top.x == -256 then
generate_circle_spawn(surface)
generate_silos(surface)
global.terrain_generation_complete = true
end
end
--Landfill Prevention
local function on_player_built_tile(event)
local player = game.players[event.player_index]
local surface = player.surface
for _, t in pairs(event.tiles) do
local distance_to_center = math.sqrt(t.position.x ^ 2 + t.position.y ^ 2)
if generate_horizontal_river(surface, t.position) or distance_to_center < spawn_circle_size then
surface.set_tiles({{name = t.old_tile, position = t.position}}, true)
player.insert({name = "landfill", count = 1})
end
end
end
local function on_robot_built_tile(event)
local surface = event.robot.surface
for _, t in pairs(event.tiles) do
local distance_to_center = math.sqrt(t.position.x ^ 2 + t.position.y ^ 2)
if generate_horizontal_river(surface, t.position) or distance_to_center < spawn_circle_size then
surface.set_tiles({{name = t.old_tile, position = t.position}}, true)
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
inventory.insert({name = "landfill", count = 1})
end
end
end
event.add(defines.events.on_robot_built_tile, on_robot_built_tile)
event.add(defines.events.on_player_built_tile, on_player_built_tile)
event.add(defines.events.on_chunk_generated, on_chunk_generated)