mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
config setting for maximum active biters
This commit is contained in:
parent
ad03423025
commit
b57ac944df
@ -13,6 +13,26 @@ local threat_values = {
|
||||
["behemoth-biter"] = 24
|
||||
}
|
||||
|
||||
local function get_active_biter_count(biter_force_name)
|
||||
local count = 0
|
||||
for _, biter in pairs(global.active_biters[biter_force_name]) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
ai.destroy_inactive_biters = function()
|
||||
for _, biter_force_name in pairs({"north_biters", "south_biters"}) do
|
||||
for unit_number, biter in pairs(global.active_biters[biter_force_name]) do
|
||||
if game.tick - biter.active_since > bb_config.biter_timeout then
|
||||
--game.print(biter_force_name .. " unit " .. unit_number .. " timed out at tick age " .. game.tick - biter.active_since)
|
||||
biter.entity.destroy()
|
||||
global.active_biters[biter_force_name][unit_number] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ai.send_near_biters_to_silo = function()
|
||||
if game.tick < 108000 then return end
|
||||
if not global.rocket_silo["north"] then return end
|
||||
@ -58,15 +78,23 @@ local function select_units_around_spawner(spawner, force_name, biter_force_name
|
||||
local biters = spawner.surface.find_enemy_units(spawner.position, 160, force_name)
|
||||
if not biters[1] then return false end
|
||||
local valid_biters = {}
|
||||
local size = math_random(2, 3) * 0.1
|
||||
local size = math_random(3, 6) * 0.1
|
||||
local threat = global.bb_threat[biter_force_name] * size
|
||||
local active_biter_count = get_active_biter_count(biter_force_name)
|
||||
|
||||
for _, biter in pairs(biters) do
|
||||
if active_biter_count >= bb_config.max_active_biters then break end
|
||||
if biter.force.name == biter_force_name then
|
||||
valid_biters[#valid_biters + 1] = biter
|
||||
valid_biters[#valid_biters + 1] = biter
|
||||
global.active_biters[biter.force.name][biter.unit_number] = {entity = biter, active_since = game.tick}
|
||||
active_biter_count = active_biter_count + 1
|
||||
threat = threat - threat_values[biter.name]
|
||||
end
|
||||
end
|
||||
if threat < 0 then break end
|
||||
end
|
||||
|
||||
--game.print(active_biter_count .. " active units for " .. biter_force_name)
|
||||
|
||||
return valid_biters
|
||||
end
|
||||
|
||||
@ -110,10 +138,12 @@ local function create_attack_group(surface, force_name, biter_force_name)
|
||||
send_group(unit_group, force_name, nearest_player_unit)
|
||||
end
|
||||
|
||||
ai.main_attack = function()
|
||||
ai.main_attack = function()
|
||||
local surface = game.surfaces["biter_battles"]
|
||||
for _, force_name in pairs({"north", "south"}) do
|
||||
create_attack_group(surface, force_name, force_name .. "_biters")
|
||||
for c = 1, math_random(1, 2), 1 do
|
||||
for _, force_name in pairs({"north", "south"}) do
|
||||
create_attack_group(surface, force_name, force_name .. "_biters")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -169,10 +199,9 @@ end
|
||||
--Biter Threat Value Substraction
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
if threat_values[event.entity.name] then
|
||||
global.bb_threat[event.entity.force.name] = global.bb_threat[event.entity.force.name] - threat_values[event.entity.name]
|
||||
return
|
||||
end
|
||||
if event.entity.type ~= "unit" then return end
|
||||
global.bb_threat[event.entity.force.name] = global.bb_threat[event.entity.force.name] - threat_values[event.entity.name]
|
||||
global.active_biters[event.entity.force.name][event.entity.unit_number] = nil
|
||||
end
|
||||
|
||||
--Flamethrower Turret Nerf
|
||||
|
@ -1,6 +1,7 @@
|
||||
-- Biter Battles v2 -- by MewMew
|
||||
|
||||
require "on_tick_schedule"
|
||||
require "maps.biter_battles_v2.config"
|
||||
require "modules.dynamic_landfill"
|
||||
require "modules.spawners_contain_biters"
|
||||
|
||||
@ -8,9 +9,10 @@ local event = require 'utils.event'
|
||||
|
||||
local function init_surface()
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.water = "0.35"
|
||||
map_gen_settings.water = "0.25"
|
||||
map_gen_settings.starting_area = "5"
|
||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = 12, cliff_elevation_0 = 32}
|
||||
--map_gen_settings.cliff_settings = {cliff_elevation_interval = 12, cliff_elevation_0 = 32}
|
||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = 48, cliff_elevation_0 = 48}
|
||||
map_gen_settings.autoplace_controls = {
|
||||
["coal"] = {frequency = "3", size = "1.2", richness = "1"},
|
||||
["stone"] = {frequency = "3", size = "1.2", richness = "1"},
|
||||
@ -122,6 +124,7 @@ local function init_forces()
|
||||
global.spectator_rejoin_delay = {}
|
||||
global.spy_fish_timeout = {}
|
||||
global.force_area = {}
|
||||
global.active_biters = {}
|
||||
global.bb_evolution = {}
|
||||
global.bb_evasion = {}
|
||||
global.bb_threat_income = {}
|
||||
@ -137,6 +140,7 @@ local function init_forces()
|
||||
game.forces[force.name].set_ammo_damage_modifier("shotgun-shell", 1)
|
||||
game.forces[force.name].research_queue_enabled = true
|
||||
global.spy_fish_timeout[force.name] = 0
|
||||
global.active_biters[force.name] = {}
|
||||
global.bb_evolution[force.name] = 0
|
||||
global.bb_evasion[force.name] = false
|
||||
global.bb_threat_income[force.name] = 0
|
||||
|
@ -1,9 +1,9 @@
|
||||
--BITER BATTLES CONFIG FILE--
|
||||
|
||||
local config = {
|
||||
bb_config = {
|
||||
--MAP PREGENERATION
|
||||
["map_pregeneration_radius"] = 32, --Radius in chunks to pregenerate at the start of the map.
|
||||
["fast_pregen"] = false, --Force fast pregeneration.
|
||||
["fast_pregen"] = false, --Force fast pregeneration.
|
||||
|
||||
--TEAM SETTINGS
|
||||
["north_side_team_name"] = "North", --Name in the GUI of Team North.
|
||||
@ -11,7 +11,9 @@ local config = {
|
||||
["team_balancing"] = true, --Should players only be able to join a team that has less or equal members than the opposing team?
|
||||
|
||||
--TERRAIN OPTIONS
|
||||
["border_river_width"] = 32 --Approximate width of the horizontal impassable river seperating the teams. (values up to 100)
|
||||
}
|
||||
|
||||
return config
|
||||
["border_river_width"] = 32, --Approximate width of the horizontal impassable river seperating the teams. (values up to 100)
|
||||
|
||||
--BITER SETTINGS
|
||||
["max_active_biters"] = 1250, --Maximum total amount of attacking units per side.
|
||||
["biter_timeout"] = 54000 --Time it takes in ticks for an attacking unit to be deleted. This prevents perma stuck units.
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
local event = require 'utils.event'
|
||||
local config = require "maps.biter_battles_v2.config"
|
||||
local spy_fish = require "maps.biter_battles_v2.spy_fish"
|
||||
local feed_the_biters = require "maps.biter_battles_v2.feeding"
|
||||
|
||||
@ -14,10 +13,10 @@ local food_names = {
|
||||
}
|
||||
|
||||
local gui_values = {
|
||||
["north"] = {force = "north", biter_force = "north_biters", c1 = "Team " .. config.north_side_team_name, c2 = "JOIN " .. string.upper(config.north_side_team_name), n1 = "join_north_button",
|
||||
["north"] = {force = "north", biter_force = "north_biters", c1 = "Team " .. bb_config.north_side_team_name, c2 = "JOIN " .. string.upper(bb_config.north_side_team_name), n1 = "join_north_button",
|
||||
t1 = "Evolution of the North side biters. Can go beyond 100% for endgame modifiers.",
|
||||
t2 = "Threat causes biters to attack. Reduces when biters are slain.", color1 = {r = 0.55, g = 0.55, b = 0.99}, color2 = {r = 0.66, g = 0.66, b = 0.99}},
|
||||
["south"] = {force = "south", biter_force = "south_biters", c1 = "Team " .. config.south_side_team_name, c2 = "JOIN " .. string.upper(config.south_side_team_name), n1 = "join_south_button",
|
||||
["south"] = {force = "south", biter_force = "south_biters", c1 = "Team " .. bb_config.south_side_team_name, c2 = "JOIN " .. string.upper(bb_config.south_side_team_name), n1 = "join_south_button",
|
||||
t1 = "Evolution of the South side biters. Can go beyond 100% for endgame modifiers.",
|
||||
t2 = "Threat causes biters to attack. Reduces when biters are slain.", color1 = {r = 0.99, g = 0.33, b = 0.33}, color2 = {r = 0.99, g = 0.44, b = 0.44}}
|
||||
}
|
||||
@ -222,7 +221,7 @@ local function join_team(player, force_name)
|
||||
local enemy_team = "south"
|
||||
if force_name == "south" then enemy_team = "north" end
|
||||
|
||||
if config.team_balancing then
|
||||
if bb_config.team_balancing then
|
||||
if #game.forces[force_name].connected_players > #game.forces[enemy_team].connected_players then
|
||||
if not global.chosen_team[player.name] then
|
||||
player.print("Team " .. force_name .. " has too many players currently.", {r = 0.98, g = 0.66, b = 0.22})
|
||||
|
@ -54,7 +54,8 @@ local function on_tick(event)
|
||||
if global.bb_game_won_by_team then server_restart() return end
|
||||
|
||||
if game.tick % 1800 ~= 0 then return end
|
||||
|
||||
|
||||
ai.destroy_inactive_biters()
|
||||
ai.main_attack()
|
||||
ai.send_near_biters_to_silo()
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
local event = require 'utils.event'
|
||||
local config = require "maps.biter_battles_v2.config"
|
||||
|
||||
local function set_chunk_coords(radius)
|
||||
global.chunk_gen_coords = {}
|
||||
@ -48,7 +47,7 @@ end
|
||||
local function process_chunk(surface)
|
||||
if global.map_generation_complete then return end
|
||||
if game.tick < 300 then return end
|
||||
if not global.chunk_gen_coords then set_chunk_coords(config.map_pregeneration_radius) end
|
||||
if not global.chunk_gen_coords then set_chunk_coords(bb_config.map_pregeneration_radius) end
|
||||
if #global.chunk_gen_coords == 0 then
|
||||
global.map_generation_complete = true
|
||||
draw_gui()
|
||||
@ -63,7 +62,7 @@ local function process_chunk(surface)
|
||||
if not surface then return end
|
||||
|
||||
local force_chunk_requests = 2
|
||||
if config.fast_pregen then force_chunk_requests = 16 end
|
||||
if bb_config.fast_pregen then force_chunk_requests = 16 end
|
||||
|
||||
for i = #global.chunk_gen_coords, 1, -1 do
|
||||
if surface.is_chunk_generated(global.chunk_gen_coords[i]) then
|
||||
|
@ -1,5 +1,4 @@
|
||||
local event = require 'utils.event'
|
||||
local config = require "maps.biter_battles_v2.config"
|
||||
local math_random = math.random
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local create_tile_chain = require "functions.create_tile_chain"
|
||||
@ -79,7 +78,7 @@ end
|
||||
|
||||
local function is_horizontal_border_river(surface, pos)
|
||||
if pos.y > -5 and pos.x > -5 and pos.x < 5 then return false end
|
||||
if math.floor(config.border_river_width * -0.5) < pos.y + (get_noise(1, pos) * 5) then return true end
|
||||
if math.floor(bb_config.border_river_width * -0.5) < pos.y + (get_noise(1, pos) * 5) then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user