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

Merge pull request #73 from muppet9010/Biter_Battle_Training_Mode

Biter Battles V2 - Training Mode
This commit is contained in:
MewMew 2019-11-05 17:05:35 +01:00 committed by GitHub
commit ec6f6aab01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 49 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,11 +278,17 @@ 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 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)
for _, f in pairs({"north_biters", "south_biters"}) 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

@ -20,6 +20,7 @@ local enemy_team_of = {
local minimum_modifier = 125
local maximum_modifier = 250
local player_amount_for_maximum_threat_gain = 20
@ -46,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
@ -63,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
@ -110,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

@ -19,7 +19,7 @@ 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}}
}
}
local map_gen_messages = {
"Map is still generating, please get comfy.",
@ -229,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 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

@ -40,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
@ -128,7 +107,7 @@ 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 t = frame.add({type = "table", name = "team_manager_root_table", column_count = 5})
local i2 = 1
@ -215,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
@ -303,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