From 69f122147a240521e34d0ed17206cfcc596dd16a Mon Sep 17 00:00:00 2001 From: muppet9010 <40836017+muppet9010@users.noreply.github.com> Date: Sun, 27 Oct 2019 15:06:30 +0000 Subject: [PATCH] Initial training mode to allow 1 or more players to train against their own biter feeding. Disabled South team from options and GUIs to avoid confusion. --- maps/biter_battles_v2/ai.lua | 8 ++++++-- maps/biter_battles_v2/config.lua | 1 + maps/biter_battles_v2/feeding.lua | 3 +++ maps/biter_battles_v2/gui.lua | 7 +++++-- maps/biter_battles_v2/main.lua | 2 +- maps/biter_battles_v2/team_manager.lua | 7 ++++++- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/maps/biter_battles_v2/ai.lua b/maps/biter_battles_v2/ai.lua index de65ea00..2f343d26 100644 --- a/maps/biter_battles_v2/ai.lua +++ b/maps/biter_battles_v2/ai.lua @@ -275,9 +275,13 @@ end ai.raise_evo = function() if global.freeze_players then return end - if #game.forces.north.connected_players == 0 or #game.forces.south.connected_players == 0 then return end + if #game.forces.north.connected_players == 0 or (not bb_config.training_mode and #game.forces.south.connected_players == 0) then return end local amount = math.ceil(global.difficulty_vote_value * global.evo_raise_counter) - for _, f in pairs({"north_biters", "south_biters"}) do + local biter_teams = {["north_biters"] = true, ["south_biters"] = true} + if bb_config.training_mode then + biter_teams["south_biters"] = nil + end + for f in pairs(biter_teams) do set_evo_and_threat(amount, "automation-science-pack", f) end global.evo_raise_counter = global.evo_raise_counter + (1 * 0.50) diff --git a/maps/biter_battles_v2/config.lua b/maps/biter_battles_v2/config.lua index de225ce8..cf1d4fda 100644 --- a/maps/biter_battles_v2/config.lua +++ b/maps/biter_battles_v2/config.lua @@ -4,6 +4,7 @@ bb_config = { --TEAM SETTINGS-- ["team_balancing"] = true, --Should players only be able to join a team that has less or equal members than the opposing team? ["only_admins_vote"] = false, --Are only admins able to vote on the global difficulty? + ['training_mode'] = true, --Players must join north team and all feeding affects their own biters. Southern team is disabled. Designed for 1 or more players to train aginst themselves. --Optional custom team names, can also be modified via "Team Manager" ["north_side_team_name"] = "Team North", diff --git a/maps/biter_battles_v2/feeding.lua b/maps/biter_battles_v2/feeding.lua index 9b392b6b..2e098214 100644 --- a/maps/biter_battles_v2/feeding.lua +++ b/maps/biter_battles_v2/feeding.lua @@ -17,6 +17,9 @@ local enemy_team_of = { ["north"] = "south", ["south"] = "north" } +if bb_config.training_mode then + enemy_team_of["north"] = "north" +end diff --git a/maps/biter_battles_v2/gui.lua b/maps/biter_battles_v2/gui.lua index 8c8aa9d5..586b8aff 100644 --- a/maps/biter_battles_v2/gui.lua +++ b/maps/biter_battles_v2/gui.lua @@ -19,7 +19,10 @@ local gui_values = { ["south"] = {force = "south", biter_force = "south_biters", c1 = bb_config.south_side_team_name, c2 = "JOIN ", 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}} - } +} +if bb_config.training_mode then + gui_values["south"] = nil +end local map_gen_messages = { "Map is still generating, please get comfy.", @@ -229,7 +232,7 @@ function join_team(player, force_name, forced_join) local enemy_team = "south" if force_name == "south" then enemy_team = "north" end - if bb_config.team_balancing then + if not bb_config.training_mode and bb_config.team_balancing then if not forced_join then if #game.forces[force_name].connected_players > #game.forces[enemy_team].connected_players then if not global.chosen_team[player.name] then diff --git a/maps/biter_battles_v2/main.lua b/maps/biter_battles_v2/main.lua index 99d45e64..66eb6dd2 100644 --- a/maps/biter_battles_v2/main.lua +++ b/maps/biter_battles_v2/main.lua @@ -164,7 +164,7 @@ local function init_forces() global.bb_threat_income[force.name] = 0 global.bb_threat[force.name] = 0 end - global.game_lobby_active = true + global.game_lobby_active = not bb_config.training_mode end local function on_player_joined_game(event) diff --git a/maps/biter_battles_v2/team_manager.lua b/maps/biter_battles_v2/team_manager.lua index 87e84dc3..5183325a 100644 --- a/maps/biter_battles_v2/team_manager.lua +++ b/maps/biter_battles_v2/team_manager.lua @@ -3,6 +3,9 @@ local forces = { {name = "spectator", color = {r = 111, g = 111, b = 111}}, {name = "south", color = {r = 200, g = 0, b = 0}}, } +if bb_config.training_mode then + forces[3] = nil +end local function get_player_array(force_name) local a = {} @@ -129,7 +132,8 @@ local function draw_manager_gui(player) local frame = player.gui.center.add({type = "frame", name = "team_manager_gui", caption = "Manage Teams", direction = "vertical"}) - local t = frame.add({type = "table", name = "team_manager_root_table", column_count = 5}) + local column_count = (#forces * 2) - 1 + local t = frame.add({type = "table", name = "team_manager_root_table", column_count = column_count}) local i2 = 1 for i = 1, #forces * 2 - 1, 1 do @@ -152,6 +156,7 @@ local function draw_manager_gui(player) list_box.style.minimal_height = 360 list_box.style.minimal_width = 160 list_box.style.maximal_height = 480 + list_box.style.maximal_width = 160 i2 = i2 + 1 else local tt = t.add({type = "table", column_count = 1})