1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-17 20:58:13 +02:00

undo the GUI blocking of joining team south made previously in this pull and all affects of Training mode will affect both north and south.

remove the ghost-spectate button from Team Manager and the functionaility it triggered
added Training Mode button to Team manager to toggle on/off behaviour.

When turned on:
Teams will feed themselves instead of the enemy while enabled (messages updated for this).
Empty teams will not get sent any attacking groups and won't get threat & evo increases (as it looks odd)
Team balance and Lobby minimum player counts not active
This commit is contained in:
muppet9010 2019-11-03 21:26:34 +00:00
parent d9fcda9b24
commit d5f92eb5bd
6 changed files with 71 additions and 66 deletions

View File

@ -256,15 +256,18 @@ end
ai.main_attack = function()
local surface = game.surfaces["biter_battles"]
local force_name = global.next_attack
local biter_force_name = force_name .. "_biters"
local wave_amount = math.ceil(get_threat_ratio(biter_force_name) * 7)
set_biter_raffle_table(surface, biter_force_name)
for c = 1, wave_amount, 1 do
create_attack_group(surface, force_name, biter_force_name)
if not global.training_mode or (global.training_mode and #game.forces[force_name].connected_players > 0) then
local biter_force_name = force_name .. "_biters"
local wave_amount = math.ceil(get_threat_ratio(biter_force_name) * 7)
set_biter_raffle_table(surface, biter_force_name)
for c = 1, wave_amount, 1 do
create_attack_group(surface, force_name, biter_force_name)
end
if global.bb_debug then game.print(wave_amount .. " unit groups designated for " .. force_name .. " biters.") end
end
if global.bb_debug then game.print(wave_amount .. " unit groups designated for " .. force_name .. " biters.") end
if global.next_attack == "north" then
global.next_attack = "south"
@ -275,15 +278,17 @@ end
ai.raise_evo = function()
if global.freeze_players 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
if not global.training_mode and (#game.forces.north.connected_players == 0 or #game.forces.south.connected_players == 0) then return end
local amount = math.ceil(global.difficulty_vote_value * global.evo_raise_counter)
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)
local biter_teams = {["north_biters"] = "north", ["south_biters"] = "south"}
local a_team_has_players = false
for bf, pf in pairs(biter_teams) do
if #game.forces[pf].connected_players > 0 then
set_evo_and_threat(amount, "automation-science-pack", bf)
a_team_has_players = true
end
end
if not a_team_has_players then return end
global.evo_raise_counter = global.evo_raise_counter + (1 * 0.50)
end

View File

@ -4,7 +4,6 @@ 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'] = false, --Designed for 1 or more players to train aginst themselves. Players must join north team and all feeding affects their own biters. Southern team is disabled.
--Optional custom team names, can also be modified via "Team Manager"
["north_side_team_name"] = "Team North",

View File

@ -17,9 +17,7 @@ local enemy_team_of = {
["north"] = "south",
["south"] = "north"
}
if bb_config.training_mode then
enemy_team_of["north"] = "north"
end
@ -49,8 +47,16 @@ local function set_biter_endgame_modifiers(force)
global.bb_evasion[force.name] = evasion_mod
end
local function get_enemy_team_of(team)
if global.training_mode then
return team
else
return enemy_team_of[team]
end
end
local function print_feeding_msg(player, food, flask_amount)
if not enemy_team_of[player.force.name] then return end
if not get_enemy_team_of(player.force.name) then return end
local n = bb_config.north_side_team_name
local s = bb_config.south_side_team_name
@ -66,12 +72,16 @@ local function print_feeding_msg(player, food, flask_amount)
local formatted_amount = table.concat({"[font=heading-1][color=255,255,255]" .. flask_amount .. "[/color][/font]"})
if flask_amount >= 20 then
game.print(colored_player_name .. " fed " .. formatted_amount .. " flasks of " .. formatted_food .. " to team " .. team_strings[enemy_team_of[player.force.name]] .. " biters!", {r = 0.9, g = 0.9, b = 0.9})
game.print(colored_player_name .. " fed " .. formatted_amount .. " flasks of " .. formatted_food .. " to team " .. team_strings[get_enemy_team_of(player.force.name)] .. " biters!", {r = 0.9, g = 0.9, b = 0.9})
else
local target_team_text = "the enemy"
if global.training_mode then
target_team_text = "your own"
end
if flask_amount == 1 then
player.print("You fed one flask of " .. formatted_food .. " to the enemy team's biters.", {r = 0.98, g = 0.66, b = 0.22})
player.print("You fed one flask of " .. formatted_food .. " to " .. target_team_text .. " team's biters.", {r = 0.98, g = 0.66, b = 0.22})
else
player.print("You fed " .. formatted_amount .. " flasks of " .. formatted_food .. " to the enemy team's biters.", {r = 0.98, g = 0.66, b = 0.22})
player.print("You fed " .. formatted_amount .. " flasks of " .. formatted_food .. " to " .. target_team_text .. " team's biters.", {r = 0.98, g = 0.66, b = 0.22})
end
end
end
@ -113,7 +123,7 @@ function set_evo_and_threat(flask_amount, food, biter_force_name)
end
local function feed_biters(player, food)
local enemy_force_name = enemy_team_of[player.force.name] ---------------
local enemy_force_name = get_enemy_team_of(player.force.name) ---------------
--enemy_force_name = player.force.name
local biter_force_name = enemy_force_name .. "_biters"

View File

@ -20,9 +20,6 @@ local gui_values = {
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.",
@ -232,7 +229,7 @@ function join_team(player, force_name, forced_join)
local enemy_team = "south"
if force_name == "south" then enemy_team = "north" end
if not bb_config.training_mode and bb_config.team_balancing then
if not global.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

View File

@ -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 = not bb_config.training_mode
global.game_lobby_active = true
end
local function on_player_joined_game(event)

View File

@ -3,9 +3,6 @@ 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 = {}
@ -43,27 +40,6 @@ local function unfreeze_players()
end
end
local function toggle_ghost_spectate(player)
if player.character then
player.character.destroy()
player.character = nil
player.set_controller({type=defines.controllers.spectator})
game.print(player.name .. " has turned into a spectator ghost.")
else
local spawn = player.force.get_spawn_position(player.surface)
player.character = nil
player.set_controller({type=defines.controllers.god})
local pos = player.surface.find_non_colliding_position("character", spawn, 3, 0.5)
if pos then
player.teleport(pos, player.surface)
else
player.teleport(spawn, player.surface)
end
player.create_character()
game.print(player.name .. " has stopped being a spectator ghost.")
end
end
local function leave_corpse(player)
if not player.character then return end
@ -131,9 +107,8 @@ local function draw_manager_gui(player)
if player.gui.center["team_manager_gui"] then player.gui.center["team_manager_gui"].destroy() end
local frame = player.gui.center.add({type = "frame", name = "team_manager_gui", caption = "Manage Teams", direction = "vertical"})
local column_count = (#forces * 2) - 1
local t = frame.add({type = "table", name = "team_manager_root_table", column_count = column_count})
local t = frame.add({type = "table", name = "team_manager_root_table", column_count = 5})
local i2 = 1
for i = 1, #forces * 2 - 1, 1 do
@ -156,7 +131,6 @@ 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})
@ -220,13 +194,23 @@ local function draw_manager_gui(player)
end
button.style.font = "heading-2"
button = t.add({
type = "button",
name = "team_manager_turn_ghost",
caption = "Ghost-Spectate",
tooltip = "Turn yourself into a spooky spectator ghost."
})
button.style.font_color = {r = 88, g = 88, b = 88}
if global.training_mode then
button = t.add({
type = "button",
name = "team_manager_activate_training",
caption = "Training Mode Activated",
tooltip = "Feed your own team's biters and only teams with players gain threat & evo."
})
button.style.font_color = {r = 222, g = 22, b = 22}
else
button = t.add({
type = "button",
name = "team_manager_activate_training",
caption = "Training Mode Disabled",
tooltip = "Feed your own team's biters and only teams with players gain threat & evo."
})
button.style.font_color = {r = 55, g = 55, b = 55}
end
button.style.font = "heading-2"
end
@ -308,9 +292,19 @@ local function team_manager_gui_click(event)
return
end
if name == "team_manager_turn_ghost" then
if not player.admin then player.print("Only admins can become spooky spectator ghosts.", {r = 175, g = 0, b = 0}) return end
toggle_ghost_spectate(player)
if name == "team_manager_activate_training" then
if not player.admin then player.print("Only admins can switch training mode.", {r = 175, g = 0, b = 0}) return end
if global.training_mode then
global.training_mode = false
global.game_lobby_active = true
draw_manager_gui(player)
game.print(">>> Training Mode has been disabled.", {r = 111, g = 111, b = 111})
return
end
global.training_mode = true
global.game_lobby_active = false
draw_manager_gui(player)
game.print(">>> Training Mode has been enabled!", {r = 225, g = 0, b = 0})
return
end