1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-28 23:06:38 +02:00

Biter hatchery - fix bugs and remove overflow of text

This commit is contained in:
Gerkiz 2023-01-11 18:54:39 +01:00
parent 74e87a4a29
commit 0d0e27770a
3 changed files with 21 additions and 16 deletions

View File

@ -1,12 +1,12 @@
--luacheck: ignore
require 'modules.no_turrets'
require 'modules.no_acid_puddles'
local Gui = require 'utils.gui'
local CoreGui = require 'utils.gui'
require 'maps.biter_hatchery.share_chat'
local Map_score = require 'utils.gui.map_score'
local unit_raffle = require 'maps.biter_hatchery.raffle_tables'
local Terrain = require 'maps.biter_hatchery.terrain'
local Gui = require 'maps.biter_hatchery.gui'
require 'maps.biter_hatchery.share_chat'
local Team = require 'maps.biter_hatchery.team'
local Unit_health_booster = require 'modules.biter_health_booster'
local Map = require 'modules.map_info'
@ -95,7 +95,7 @@ local function spawn_units(belt, food_item, removed_item_count)
end
end
if math_random(1, 8) == 1 then
spawn_worm_turret(belt.surface, belt.force.name, food_item)
spawn_worm_turret(belt.surface, belt.force.name)
end
end
@ -117,7 +117,7 @@ local function feed_floaty_text(entity)
entity.surface.create_entity({name = 'flying-text', position = entity.position, text = nom_msg[math_random(1, 4)], color = {math_random(50, 100), 0, 255}})
local position = {x = entity.position.x - 0.75, y = entity.position.y - 1}
local b = 1.35
for a = 1, math_random(0, 2), 1 do
for _ = 1, math_random(0, 2), 1 do
local p = {(position.x + 0.4) + (b * -1 + math_random(0, b * 20) * 0.1), position.y + (b * -1 + math_random(0, b * 20) * 0.1)}
entity.surface.create_entity({name = 'flying-text', position = p, text = '', color = {math_random(150, 255), 0, 255}})
end
@ -126,7 +126,7 @@ end
local function eat_food_from_belt(belt)
for i = 1, 2, 1 do
local line = belt.get_transport_line(i)
for food_item, raffle in pairs(unit_raffle) do
for food_item, _ in pairs(unit_raffle) do
if global.map_forces[belt.force.name].unit_count > global.map_forces[belt.force.name].max_unit_count then
return
end
@ -140,8 +140,7 @@ local function eat_food_from_belt(belt)
end
local function nom()
local surface = game.surfaces.nauvis
for key, force in pairs(global.map_forces) do
for _, force in pairs(global.map_forces) do
if not force.hatchery then
return
end
@ -310,7 +309,7 @@ local function on_entity_died(event)
for _, child in pairs(player.gui.left.children) do
child.destroy()
end
Gui.call_existing_tab(player, 'Map Scores')
CoreGui.call_existing_tab(player, 'Map Scores')
end
for _, e in pairs(entity.surface.find_entities_filtered({type = 'unit'})) do
@ -320,7 +319,6 @@ end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
local surface = game.surfaces.nauvis
Gui.unit_health_buttons(player)
Gui.spectate_button(player)

View File

@ -119,8 +119,7 @@ function Public.spawn_players(hatchery)
if game.tick % 90 ~= 0 then
return
end
game.print('spawning characters', {150, 150, 150})
local surface = game.surfaces.nauvis
-- game.print('spawning characters', {150, 150, 150})
for _, player in pairs(game.connected_players) do
if player.force.name ~= 'spectator' then
Public.assign_force_to_player(player)

View File

@ -10,7 +10,7 @@ local function get_replacement_tile(surface, position)
for i = 1, 128, 1 do
local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}}
table.shuffle_table(vectors)
for k, v in pairs(vectors) do
for _, v in pairs(vectors) do
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
if not tile.collides_with('resource-layer') then
return tile.name
@ -58,6 +58,7 @@ end
function Public.reset_nauvis(hatchery)
local surface = game.surfaces.nauvis
local mgs = surface.map_gen_settings
---@diagnostic disable-next-line: assign-type-mismatch
mgs.seed = math_random(1, 99999999)
mgs.water = 1
mgs.starting_area = 1
@ -70,6 +71,7 @@ function Public.reset_nauvis(hatchery)
['iron-ore'] = {frequency = 8, size = 0.7, richness = 1},
['uranium-ore'] = {frequency = 5, size = 0.5, richness = 0.5},
['crude-oil'] = {frequency = 5, size = 1, richness = 1},
---@diagnostic disable-next-line: assign-type-mismatch
['trees'] = {frequency = math.random(4, 32) * 0.1, size = math.random(4, 16) * 0.1, richness = math.random(1, 10) * 0.1},
['enemy-base'] = {frequency = 0, size = 0, richness = 0}
}
@ -79,7 +81,7 @@ function Public.reset_nauvis(hatchery)
surface.delete_chunk({chunk.x, chunk.y})
end
hatchery.gamestate = 'prepare_east'
game.print('preparing east', {150, 150, 150})
-- game.print('preparing east', {150, 150, 150})
print(hatchery.gamestate)
end
@ -109,7 +111,7 @@ function Public.prepare_east(hatchery)
end
draw_spawn_ore(surface, {x = 240, y = 0})
hatchery.gamestate = 'clear_west'
game.print('clearing west chunks', {150, 150, 150})
-- game.print('clearing west chunks', {150, 150, 150})
print(hatchery.gamestate)
end
@ -125,7 +127,7 @@ function Public.clear_west(hatchery)
end
hatchery.mirror_queue = {}
hatchery.gamestate = 'prepare_west'
game.print('preparing west chunks', {150, 150, 150})
-- game.print('preparing west chunks', {150, 150, 150})
print(hatchery.gamestate)
end
@ -147,11 +149,14 @@ function Public.draw_team_nests(hatchery)
if game.tick % 90 ~= 0 then
return
end
game.print('placing nests', {150, 150, 150})
-- game.print('placing nests', {150, 150, 150})
local surface = game.surfaces.nauvis
local x = hatchery_position.x
local e = surface.create_entity({name = 'biter-spawner', position = {x * -1, 0}, force = 'west'})
if not e or not e.valid then
return
end
for _, p in pairs({{x * -1 + 6, 0}, {x * -1 + 3, 6}, {x * -1 + 3, -5}}) do
surface.create_entity({name = 'small-worm-turret', position = p, force = 'west'})
surface.create_decoratives {check_collision = false, decoratives = {{name = 'enemy-decal', position = p, amount = 1}}}
@ -162,6 +167,9 @@ function Public.draw_team_nests(hatchery)
surface.create_decoratives {check_collision = false, decoratives = {{name = 'enemy-decal', position = e.position, amount = 3}}}
local e = surface.create_entity({name = 'biter-spawner', position = {x, 0}, force = 'east'})
if not e or not e.valid then
return
end
for _, p in pairs({{x - 6, 0}, {x - 3, 6}, {x - 3, -5}}) do
surface.create_entity({name = 'small-worm-turret', position = p, force = 'east'})
surface.create_decoratives {check_collision = false, decoratives = {{name = 'enemy-decal', position = p, amount = 1}}}