1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00

Merge pull request #20 from ComfyFactory/various_fixes

Minor tweaks to biter battles and prison planet
This commit is contained in:
Gerkiz 2021-03-30 16:13:34 +02:00 committed by GitHub
commit e22fe4316a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 24 deletions

View File

@ -5,6 +5,7 @@ local bb_config = {
['north_side_team_name'] = 'Team North',
['south_side_team_name'] = 'Team South',
--TERRAIN OPTIONS--
['match_mirror'] = false, --If both sides should match in terrain generation
['border_river_width'] = 36, --Approximate width of the horizontal impassable river seperating the teams. (values up to 100)
['builders_area'] = true, --Grant each side a peaceful direction with no nests and biters?
['random_scrap'] = true, --Generate harvestable scrap around worms randomly?
@ -12,7 +13,10 @@ local bb_config = {
['max_active_biters'] = 1280, --Maximum total amount of attacking units per side.
['max_group_size'] = 288, --Maximum unit group size.
['biter_timeout'] = 162000, --Time it takes in ticks for an attacking unit to be deleted. This prevents perma stuck units.
['bitera_area_distance'] = 512 --Distance to the biter area.
['bitera_area_distance'] = 512, --Distance to the biter area.
--CHEATY STARTS
['spawn_turrets_at_silo'] = false, --This spawns two turrets near the silo of each team.
['additional_starting_resources'] = false --This gives each starting player 10 burner-mining-drill to skip the start.
}
return bb_config

View File

@ -381,6 +381,9 @@ function join_team(player, force_name, forced_join)
player.insert {name = 'firearm-magazine', count = 32}
player.insert {name = 'iron-gear-wheel', count = 8}
player.insert {name = 'iron-plate', count = 16}
if bb_config.additional_starting_resources then
player.insert {name = 'burner-mining-drill', count = 10}
end
global.chosen_team[player.name] = force_name
player.spectator = false
Public.refresh()

View File

@ -1,7 +1,7 @@
--luacheck:ignore
local Public = {}
local Functions = require 'maps.biter_battles_v2.functions'
local bb_config = require 'maps.biter_battles_v2.config'
local table_remove = table.remove
local table_insert = table.insert
@ -40,21 +40,21 @@ local cliff_orientation_translation = {
}
local entity_copy_functions = {
['tree'] = function(surface, entity, target_position, force_name)
['tree'] = function(surface, entity, target_position)
if not surface.can_place_entity({name = entity.name, position = target_position}) then
return
end
entity.clone({position = target_position, surface = surface, force = 'neutral'})
end,
['simple-entity'] = function(surface, entity, target_position, force_name)
['simple-entity'] = function(surface, entity, target_position)
local mirror_entity = {name = entity.name, position = target_position, direction = direction_translation[entity.direction]}
if not surface.can_place_entity(mirror_entity) then
return
end
local mirror_entity = surface.create_entity(mirror_entity)
mirror_entity.graphics_variation = entity.graphics_variation
local mirror_entity2 = surface.create_entity(mirror_entity)
mirror_entity2.graphics_variation = entity.graphics_variation
end,
['cliff'] = function(surface, entity, target_position, force_name)
['cliff'] = function(surface, entity, target_position)
local mirror_entity = {name = entity.name, position = target_position, cliff_orientation = cliff_orientation_translation[entity.cliff_orientation]}
if not surface.can_place_entity(mirror_entity) then
return
@ -62,10 +62,10 @@ local entity_copy_functions = {
surface.create_entity(mirror_entity)
return
end,
['resource'] = function(surface, entity, target_position, force_name)
['resource'] = function(surface, entity, target_position)
surface.create_entity({name = entity.name, position = target_position, amount = entity.amount})
end,
['corpse'] = function(surface, entity, target_position, force_name)
['corpse'] = function(surface, entity, target_position)
surface.create_entity({name = entity.name, position = target_position})
end,
['unit-spawner'] = function(surface, entity, target_position, force_name)
@ -118,12 +118,12 @@ local entity_copy_functions = {
local e = entity.clone({position = target_position, surface = surface, force = force_name})
e.active = true
end,
['fish'] = function(surface, entity, target_position, force_name)
['fish'] = function(surface, entity, target_position)
local mirror_entity = {name = entity.name, position = target_position}
if not surface.can_place_entity(mirror_entity) then
return
end
local e = surface.create_entity(mirror_entity)
surface.create_entity(mirror_entity)
end
}
@ -135,11 +135,17 @@ local function process_entity(surface, entity, force_name)
return
end
local match_mirror = bb_config.match_mirror
local target_position
if force_name == 'north' then
target_position = entity.position
else
target_position = {x = entity.position.x * -1, y = entity.position.y * -1}
if match_mirror then
target_position = {x = entity.position.x, y = entity.position.y * -1}
else
target_position = {x = entity.position.x * -1, y = entity.position.y * -1}
end
end
entity_copy_functions[entity.type](surface, entity, target_position, force_name)
@ -162,6 +168,8 @@ local function copy_chunk(chunk)
return
end
local match_mirror = bb_config.match_mirror
if chunk[2] == 1 then
source_surface.clone_area(
{
@ -190,8 +198,14 @@ local function copy_chunk(chunk)
end
local decoratives = {}
for k, decorative in pairs(source_surface.find_decoratives_filtered {area = source_area}) do
decoratives[k] = {name = decorative.decorative.name, position = {decorative.position.x, decorative.position.y}, amount = decorative.amount}
if match_mirror then
for k, decorative in pairs(source_surface.find_decoratives_filtered {area = source_area}) do
decoratives[k] = {name = decorative.decorative.name, position = {decorative.position.x, decorative.position.y}, amount = decorative.amount}
end
else
for k, decorative in pairs(source_surface.find_decoratives_filtered {area = source_area}) do
decoratives[k] = {name = decorative.decorative.name, position = {(decorative.position.x * -1) - 1, (decorative.position.y * -1) - 1}, amount = decorative.amount}
end
end
target_surface.create_decoratives({check_collision = false, decoratives = decoratives})
@ -200,9 +214,15 @@ end
local function mirror_chunk(chunk)
local target_surface = game.surfaces.biter_battles
local match_mirror = bb_config.match_mirror
local source_surface = game.surfaces.bb_source
local source_chunk_position = {chunk[1][1] * -1 - 1, chunk[1][2] * -1 - 1}
local source_chunk_position
if match_mirror then
source_chunk_position = {chunk[1][1], chunk[1][2] * -1 - 1}
else
source_chunk_position = {chunk[1][1] * -1 - 1, chunk[1][2] * -1 - 1}
end
local source_left_top = {x = source_chunk_position[1] * 32, y = source_chunk_position[2] * 32}
local source_area = {{source_left_top.x, source_left_top.y}, {source_left_top.x + 32, source_left_top.y + 32}}
@ -213,8 +233,14 @@ local function mirror_chunk(chunk)
if chunk[2] == 1 then
local tiles = {}
for k, tile in pairs(source_surface.find_tiles_filtered({area = source_area})) do
tiles[k] = {name = tile.name, position = {tile.position.x * -1 - 1, tile.position.y * -1 - 1}}
if match_mirror then
for k, tile in pairs(source_surface.find_tiles_filtered({area = source_area})) do
tiles[k] = {name = tile.name, position = {tile.position.x, tile.position.y * -1 - 1}}
end
else
for k, tile in pairs(source_surface.find_tiles_filtered({area = source_area})) do
tiles[k] = {name = tile.name, position = {tile.position.x * -1 - 1, tile.position.y * -1 - 1}}
end
end
target_surface.set_tiles(tiles, true)
chunk[2] = chunk[2] + 1
@ -231,7 +257,7 @@ local function mirror_chunk(chunk)
local decoratives = {}
for k, decorative in pairs(source_surface.find_decoratives_filtered {area = source_area}) do
decoratives[k] = {name = decorative.decorative.name, position = {(decorative.position.x * -1) - 1, (decorative.position.y * -1) - 1}, amount = decorative.amount}
decoratives[k] = {name = decorative.decorative.name, position = {decorative.position.x, decorative.position.y * -1}, amount = decorative.amount}
end
target_surface.create_decoratives({check_collision = false, decoratives = decoratives})
@ -281,6 +307,7 @@ end
local function north_work()
local terrain_gen = global.terrain_gen
--luacheck: ignore 512
for k, chunk in pairs(terrain_gen.chunk_copy) do
if copy_chunk(chunk) then
reveal_chunk(chunk)
@ -295,6 +322,7 @@ end
local function south_work()
local terrain_gen = global.terrain_gen
--luacheck: ignore 512
for k, chunk in pairs(terrain_gen.chunk_mirror) do
if mirror_chunk(chunk) then
reveal_chunk(chunk)

View File

@ -247,7 +247,7 @@ local function generate_starting_area(pos, distance_to_center, surface)
-- if noise_2 > -0.5:
-- -1.75 0 => wall
-- else:
-- -6 -3 => 1/16 chance of turrent or turret-remnants
-- -6 -3 => 1/16 chance of turret or turret-remnants
-- -1.95 0 => wall
-- 0 4.5 => chest-remnants with 1/3, chest with 1/(distance_from_spawn_wall+2)
--
@ -655,6 +655,15 @@ function Public.generate_silo(surface)
entity.destroy()
end
end
if bb_config.spawn_turrets_at_silo then
local turret1 = surface.create_entity({name = 'gun-turret', position = {x = pos.x, y = pos.y - 5}, force = 'neutral'})
turret1.insert({name = 'firearm-magazine', count = 10})
turret1.active = false
local turret2 = surface.create_entity({name = 'gun-turret', position = {x = pos.x + 2, y = pos.y - 5}, force = 'neutral'})
turret2.insert({name = 'firearm-magazine', count = 10})
turret2.active = false
end
end
--[[
function Public.generate_spawn_goodies(surface)

View File

@ -669,7 +669,7 @@ local function print_merchant_position(player)
perks = assign_perks(player)
end
if perks and perks.minimap then
player.print(string.format('>> You received a broadcast with [gps=%d,%d,%d] coordinates', position.x, position.y, player.surface))
player.print(string.format('>> You received a broadcast with [gps=%d,%d,%d] coordinates', position.x, position.y, player.surface.name))
else
player.print(string.format('>> You were able to spot him %s from your location', CommonFunctions.get_readable_direction(player.position, position)))
end

View File

@ -181,9 +181,11 @@ Public.clear_player_base = function(player)
for i = 1, #entities do
local e = entities[i]
if e and e.valid then
e.health = e.health - random(30, 180)
if e.health <= 0 then
e.die('enemy')
if e.health then
e.health = e.health - random(30, 180)
if e.health <= 0 then
e.die('enemy')
end
end
end
end