mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
Merge pull request #21 from ComfyFactory/planet_prison_and_biter_battles
minor fixes to planet prison and biter battles
This commit is contained in:
commit
3bd965ce3b
@ -1,11 +1,18 @@
|
||||
--luacheck:ignore
|
||||
--luacheck: ignore
|
||||
local Functions = require 'maps.biter_battles_v2.functions'
|
||||
local Gui = require 'maps.biter_battles_v2.gui'
|
||||
local Init = require 'maps.biter_battles_v2.init'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Server = require 'utils.server'
|
||||
local Discord = require 'utils.discord'
|
||||
|
||||
local math_random = math.random
|
||||
-- Use these settings for live
|
||||
local send_ping_to_channel = Discord.channel_names.bb_channel
|
||||
local role_to_mention = Discord.role_mentions.biter_battles
|
||||
-- Use these settings for testing
|
||||
-- bot-lounge
|
||||
-- local send_ping_to_channel = Discord.channel_names.bot_quarters
|
||||
-- local role_to_mention = Discord.role_mentions.test_role
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -14,15 +21,6 @@ local gui_values = {
|
||||
['south'] = {c1 = 'Team South', color1 = {r = 0.99, g = 0.33, b = 0.33}}
|
||||
}
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = math.random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
function Public.reveal_map()
|
||||
for _, f in pairs({'north', 'south', 'player', 'spectator'}) do
|
||||
local r = 768
|
||||
@ -80,7 +78,7 @@ local function silo_kaboom(entity)
|
||||
end
|
||||
|
||||
local function get_sorted_list(column_name, score_list)
|
||||
for x = 1, #score_list, 1 do
|
||||
for _ = 1, #score_list, 1 do
|
||||
for y = 1, #score_list, 1 do
|
||||
if not score_list[y + 1] then
|
||||
break
|
||||
@ -280,6 +278,8 @@ function Public.server_restart()
|
||||
local message = 'Map is restarting! '
|
||||
Server.to_discord_bold(table.concat {'*** ', message, ' ***'})
|
||||
|
||||
Server.to_discord_named_raw(send_ping_to_channel, role_to_mention .. ' ** Biter Battles was just reset! **')
|
||||
|
||||
Init.tables()
|
||||
Init.forces()
|
||||
Init.load_spawn()
|
||||
|
@ -125,6 +125,7 @@ function Public.source_surface()
|
||||
surface.request_to_generate_chunks({x = 0, y = -256}, 8)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
Terrain.fill_water_tiles(surface)
|
||||
Terrain.draw_spawn_area(surface)
|
||||
Terrain.generate_additional_spawn_ore(surface)
|
||||
Terrain.generate_additional_rocks(surface)
|
||||
|
@ -1,4 +1,3 @@
|
||||
--luacheck:ignore
|
||||
-- Biter Battles v2 -- by MewMew
|
||||
|
||||
local Ai = require 'maps.biter_battles_v2.ai'
|
||||
@ -16,7 +15,6 @@ require 'maps.biter_battles_v2.commands'
|
||||
require 'modules.spawners_contain_biters'
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local surface = game.surfaces['biter_battles']
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 or player.force.name == 'player' then
|
||||
Functions.init_player(player)
|
||||
@ -136,11 +134,6 @@ local function on_player_built_tile(event)
|
||||
Terrain.restrict_landfill(player.surface, player, event.tiles)
|
||||
end
|
||||
|
||||
local function on_player_built_tile(event)
|
||||
local player = game.players[event.player_index]
|
||||
Terrain.restrict_landfill(player.surface, player, event.tiles)
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
Terrain.minable_wrecks(event)
|
||||
end
|
||||
@ -170,7 +163,6 @@ Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
Event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
|
||||
Event.add(defines.events.on_robot_built_tile, on_robot_built_tile)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
Event.on_init(on_init)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
--luacheck:ignore
|
||||
--luacheck: ignore
|
||||
local Public = {}
|
||||
local LootRaffle = require 'functions.loot_raffle'
|
||||
local BiterRaffle = require 'functions.biter_raffle'
|
||||
@ -567,6 +567,24 @@ function Public.draw_spawn_circle(surface)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.fill_water_tiles(surface)
|
||||
local chunk_r = 8
|
||||
local r = chunk_r * 32
|
||||
|
||||
for x = r * -1, r, 1 do
|
||||
for y = r * -1, -4, 1 do
|
||||
local pos = {x = x, y = y}
|
||||
local distance_to_center = math_sqrt(pos.x ^ 2 + pos.y ^ 2)
|
||||
if distance_to_center < 550 and not is_horizontal_border_river(pos) then
|
||||
local tile_name = surface.get_tile(pos).name
|
||||
if tile_name == 'water' or tile_name == 'deepwater' then
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, pos), position = pos}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.draw_spawn_area(surface)
|
||||
local chunk_r = 4
|
||||
local r = chunk_r * 32
|
||||
|
@ -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.name))
|
||||
player.print(string.format('>> You received a broadcast with [gps=%d,%d,%s] 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
|
||||
@ -1237,6 +1237,10 @@ local function on_tick()
|
||||
local tick = game.tick
|
||||
|
||||
local surf = this.surface
|
||||
if not surf or not surf.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if tick % 4 == 0 then
|
||||
AIFunctions.do_job(surf, AIFunctions.command.seek_and_destroy_player)
|
||||
end
|
||||
@ -1248,7 +1252,7 @@ local function on_tick()
|
||||
Timers.do_job()
|
||||
end
|
||||
if (tick + 1) % 100 == 0 then
|
||||
AfkFunctions.on_inactive_players(5)
|
||||
AfkFunctions.on_inactive_players(15)
|
||||
end
|
||||
if (tick + 1) % 500 == 0 then
|
||||
remove_offline_players()
|
||||
@ -1787,7 +1791,6 @@ setmetatable(
|
||||
{
|
||||
__newindex = function(_, n, v)
|
||||
log('Desync warning: attempt to write to undeclared var ' .. n)
|
||||
--game.print ("Attempt to write to undeclared var " .. n)
|
||||
global[n] = v
|
||||
end,
|
||||
__index = function(_, n)
|
||||
|
@ -38,15 +38,14 @@ local function claim_new_claim(ent)
|
||||
}
|
||||
}
|
||||
|
||||
local claims = this._claims_info
|
||||
if claims[ent.force.name] == nil then
|
||||
claims[ent.force.name] = {}
|
||||
claims[ent.force.name].polygons = {}
|
||||
claims[ent.force.name].claims = {}
|
||||
claims[ent.force.name].collections = {}
|
||||
if this._claims_info[ent.force.name] == nil then
|
||||
this._claims_info[ent.force.name] = {}
|
||||
this._claims_info[ent.force.name].polygons = {}
|
||||
this._claims_info[ent.force.name].claims = {}
|
||||
this._claims_info[ent.force.name].collections = {}
|
||||
end
|
||||
|
||||
insert(claims[ent.force.name].collections, point)
|
||||
insert(this._claims_info[ent.force.name].collections, point)
|
||||
end
|
||||
|
||||
local function claim_on_build_entity(ent)
|
||||
@ -60,27 +59,27 @@ local function claim_on_build_entity(ent)
|
||||
end
|
||||
|
||||
local in_range = false
|
||||
local collections = data.collections
|
||||
for i = 1, #collections do
|
||||
local points = collections[i]
|
||||
for i = 1, #data.collections do
|
||||
if data.collections[i] then
|
||||
for _, point in pairs(data.collections[i]) do
|
||||
if point then
|
||||
local dist = CommonFunctions.get_distance(point, ent.position)
|
||||
if max_dist < dist then
|
||||
goto continue
|
||||
end
|
||||
|
||||
for _, point in pairs(points) do
|
||||
point = point
|
||||
local dist = CommonFunctions.get_distance(point, ent.position)
|
||||
if max_dist < dist then
|
||||
goto continue
|
||||
in_range = true
|
||||
point = {
|
||||
x = CommonFunctions.get_axis(ent.position, 'x'),
|
||||
y = CommonFunctions.get_axis(ent.position, 'y')
|
||||
}
|
||||
insert(data.collections[i], point)
|
||||
data.claims[i] = CommonFunctions.get_convex_hull(data.collections[i])
|
||||
|
||||
break
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
in_range = true
|
||||
point = {
|
||||
x = CommonFunctions.get_axis(ent.position, 'x'),
|
||||
y = CommonFunctions.get_axis(ent.position, 'y')
|
||||
}
|
||||
insert(points, point)
|
||||
data.claims[i] = CommonFunctions.get_convex_hull(points)
|
||||
|
||||
break
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
@ -118,19 +117,17 @@ local function claim_on_entity_died(ent)
|
||||
end
|
||||
|
||||
for i = 1, #data.collections do
|
||||
local points = data.collections[i]
|
||||
|
||||
for j = 1, #points do
|
||||
local point = points[j]
|
||||
for j = 1, #data.collections[i] do
|
||||
local point = data.collections[i][j]
|
||||
if CommonFunctions.positions_equal(point, ent.position) then
|
||||
remove(points, j)
|
||||
remove(data.collections[i], j)
|
||||
|
||||
data.claims[i] = CommonFunctions.get_convex_hull(points)
|
||||
data.claims[i] = CommonFunctions.get_convex_hull(data.collections[i])
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if #points == 0 then
|
||||
if #data.collections[i] == 0 then
|
||||
remove(data.claims, i)
|
||||
remove(data.collections, i)
|
||||
break
|
||||
|
@ -4,6 +4,7 @@ return {
|
||||
-- See features.server.to_discord_named
|
||||
channel_names = {
|
||||
mtn_channel = 'mount-fortress',
|
||||
bb_channel = 'biter_battles',
|
||||
bot_quarters = 'bot-quarters',
|
||||
announcements = 'announcements',
|
||||
mod_lounge = 'mods-lounge',
|
||||
|
Loading…
x
Reference in New Issue
Block a user