1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-11 13:39:14 +02:00

biter_battles_v2/biter_battles_v2 > landfill restriction

This commit is contained in:
MewMew 2019-03-14 01:35:41 +01:00
parent 64ea71db6e
commit 1dc6b46cab
4 changed files with 27 additions and 29 deletions

View File

@ -40,8 +40,8 @@ require "tools.cheat_mode"
-----------------------------
---- enable maps here ----
--require "maps.biter_battles_v2.biter_battles_v2"
--require "maps.biter_battles"
require "maps.biter_battles_v2.biter_battles_v2"
--require "maps.biter_battles.biter_battles"
--require "maps.cave_miner"
--require "maps.labyrinth"
--require "maps.junkyard"

View File

@ -5,7 +5,7 @@ require "modules.explosive_biters"
require "modules.spawners_contain_biters"
require "modules.custom_death_messages"
local biter_battles_terrain = require 'biter_battles_terrain'
local biter_battles_terrain = require 'maps.biter_battles.biter_battles_terrain'
local event = require 'utils.event'
local math_random = math.random
local insert = table.insert
@ -1463,11 +1463,13 @@ 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})
if t.old_tile.name == "deepwater" and t.position.y <= global.horizontal_border_width*2 and t.position.y >= global.horizontal_border_width*-1*2 then
local str = "Team " .. event.robot.force.name
str = str .. "´s landfill vanished into the depths of the marianna trench."
game.print(str,{ r=0.98, g=0.66, b=0.22})
local tiles = {}
table.insert(tiles, {name = "deepwater", position = t.position})
surface.set_tiles(tiles,true)
end
end
end

View File

@ -33,7 +33,7 @@ local function on_player_joined_game(event)
--init_surface(event)
local player = game.players[event.player_index]
player.character.destructible = false
player.character.destroy()
--player.character.destroy()
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -71,6 +71,7 @@ end
local function generate_horizontal_river(surface, pos)
if pos.y < -32 then return false end
if pos.y > -2 and pos.y < 2 and pos.x > -2 and pos.x < 2 then return false end
if -14 < pos.y + (get_noise(1, pos) * 5) then return true end
return false
end
@ -82,8 +83,8 @@ local function generate_circle_spawn(surface)
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 distance_to_center < 8 then tile = "refined-concrete" end
if distance_to_center < 6 then tile = "sand-1" end
if tile then surface.set_tiles({{name = tile, position = pos}}, true) end
end
end
@ -120,28 +121,23 @@ local function on_chunk_generated(event)
end
--Landfill Prevention
local function restrict_landfill(surface, inventory, tiles)
for _, t in pairs(tiles) do
local distance_to_center = math.sqrt(t.position.x ^ 2 + t.position.y ^ 2)
local check_position = t.position
if check_position.y > 0 then check_position = {x = check_position.x * -1, y = (check_position.y * -1) - 1} end
if generate_horizontal_river(surface, check_position) or distance_to_center < spawn_circle_size then
surface.set_tiles({{name = t.old_tile.name, position = t.position}}, true)
inventory.insert({name = "landfill", count = 1})
end
end
end
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
restrict_landfill(player.surface, player, event.tiles)
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
restrict_landfill(event.robot.surface, event.robot.get_inventory(defines.inventory.robot_cargo), event.tiles)
end
event.add(defines.events.on_robot_built_tile, on_robot_built_tile)