mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-06 00:23:49 +02:00
updates
This commit is contained in:
parent
4b8488ec1f
commit
7c346e7070
@ -273,6 +273,15 @@ ai.main_attack = function()
|
||||
end
|
||||
end
|
||||
|
||||
ai.raise_evo = function()
|
||||
if #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, "logistic-science-pack", f)
|
||||
end
|
||||
global.evo_raise_counter = global.evo_raise_counter + 1
|
||||
end
|
||||
|
||||
--Prevent Players from damaging Rocket Silos
|
||||
local function protect_silo(event)
|
||||
if event.cause then
|
||||
|
@ -55,7 +55,7 @@ local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
create_map_intro_button(player)
|
||||
if player.online_time == 0 then
|
||||
create_map_intro(player)
|
||||
--create_map_intro(player)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -140,6 +140,7 @@ local function init_forces()
|
||||
global.force_area = {}
|
||||
global.active_biters = {}
|
||||
global.biter_raffle = {}
|
||||
global.evo_raise_counter = 1
|
||||
global.next_attack = "north"
|
||||
if math.random(1,2) == 1 then global.next_attack = "south" end
|
||||
global.bb_evolution = {}
|
||||
@ -200,4 +201,5 @@ require "maps.biter_battles_v2.terrain"
|
||||
require "maps.biter_battles_v2.no_turret_creep"
|
||||
require "maps.biter_battles_v2.chat"
|
||||
require "maps.biter_battles_v2.bb_map_intro"
|
||||
require "maps.biter_battles_v2.difficulty_vote"
|
||||
require "modules.custom_death_messages"
|
@ -6,13 +6,14 @@ bb_config = {
|
||||
["blueprint_string_importing"] = false, --Allow the importing of blueprints via blueprint strings?
|
||||
|
||||
--MAP PREGENERATION
|
||||
["map_pregeneration_radius"] = 32, --Radius in chunks to pregenerate at the start of the map.
|
||||
["map_pregeneration_radius"] = 31, --Radius in chunks to pregenerate at the start of the map.
|
||||
["fast_pregen"] = false, --Force fast pregeneration.
|
||||
|
||||
--TEAM SETTINGS
|
||||
["north_side_team_name"] = "North", --Name in the GUI of Team North.
|
||||
["south_side_team_name"] = "South", --Name in the GUI of Team South.
|
||||
["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?
|
||||
|
||||
--TERRAIN OPTIONS
|
||||
["border_river_width"] = 29, --Approximate width of the horizontal impassable river seperating the teams. (values up to 100)
|
||||
@ -23,5 +24,5 @@ bb_config = {
|
||||
["max_active_biters"] = 2500, --Maximum total amount of attacking units per side.
|
||||
["max_group_size"] = 256, --Maximum unit group size.
|
||||
["biter_timeout"] = 54000, --Time it takes in ticks for an attacking unit to be deleted. This prevents perma stuck units.
|
||||
["bitera_area_distance"] = 416, --Distance to the biter area.
|
||||
["bitera_area_distance"] = 416 --Distance to the biter area.
|
||||
}
|
97
maps/biter_battles_v2/difficulty_vote.lua
Normal file
97
maps/biter_battles_v2/difficulty_vote.lua
Normal file
@ -0,0 +1,97 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local difficulties = {
|
||||
[1] = {name = "Peaceful", str = "25%", value = 0.25, color = {r=0.00, g=0.45, b=0.00}, print_color = {r=0.00, g=0.9, b=0.00}},
|
||||
[2] = {name = "Easy", str = "50%", value = 0.5, color = {r=0.00, g=0.35, b=0.00}, print_color = {r=0.00, g=0.7, b=0.00}},
|
||||
[3] = {name = "Piece of cake", str = "75%", value = 0.75, color = {r=0.00, g=0.25, b=0.00}, print_color = {r=0.00, g=0.5, b=0.00}},
|
||||
[4] = {name = "Normal", str = "100%", value = 1, color = {r=0.00, g=0.00, b=0.25}, print_color = {r=0.0, g=0.0, b=0.7}},
|
||||
[5] = {name = "Hard", str = "150%", value = 1.5, color = {r=0.25, g=0.00, b=0.00}, print_color = {r=0.5, g=0.0, b=0.00}},
|
||||
[6] = {name = "Nightmare", str = "200%", value = 2, color = {r=0.35, g=0.00, b=0.00}, print_color = {r=0.7, g=0.0, b=0.00}},
|
||||
[7] = {name = "Insane", str = "300%", value = 3, color = {r=0.45, g=0.00, b=0.00}, print_color = {r=0.9, g=0.0, b=0.00}}
|
||||
}
|
||||
|
||||
local function difficulty_gui()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.gui.top["difficulty_gui"] then player.gui.top["difficulty_gui"].destroy() end
|
||||
local str = table.concat({"Global map difficulty is ", difficulties[global.difficulty_vote_index].name, ". Mutagen has ", difficulties[global.difficulty_vote_index].str, " effectiveness."})
|
||||
local b = player.gui.top.add { type = "sprite-button", caption = difficulties[global.difficulty_vote_index].name, tooltip = str, name = "difficulty_gui" }
|
||||
b.style.font = "heading-2"
|
||||
b.style.font_color = difficulties[global.difficulty_vote_index].print_color
|
||||
b.style.minimal_height = 38
|
||||
b.style.minimal_width = 96
|
||||
end
|
||||
end
|
||||
|
||||
local function poll_difficulty(player)
|
||||
if player.gui.center["difficulty_poll"] then player.gui.center["difficulty_poll"].destroy() return end
|
||||
if game.tick > 54000 then
|
||||
local frame = player.gui.center.add { type = "frame", caption = "Voting is over.", name = "difficulty_poll", direction = "vertical" }
|
||||
return
|
||||
end
|
||||
|
||||
local frame = player.gui.center.add { type = "frame", caption = "Vote global difficulty:", name = "difficulty_poll", direction = "vertical" }
|
||||
for i = 1, 7, 1 do
|
||||
local b = frame.add({type = "button", name = tostring(i), caption = difficulties[i].name .. " (" .. difficulties[i].str .. ")"})
|
||||
b.style.font_color = difficulties[i].color
|
||||
b.style.font = "heading-2"
|
||||
b.style.minimal_width = 180
|
||||
end
|
||||
local b = frame.add({type = "label", caption = "- - - - - - - - - - - - - - - - - - - -"})
|
||||
local b = frame.add({type = "button", name = "skip", caption = "Close (" .. math.floor((54000 - game.tick) / 3600) .. " minutes left)"})
|
||||
b.style.font_color = {r=0.66, g=0.0, b=0.66}
|
||||
b.style.font = "heading-3"
|
||||
b.style.minimal_width = 96
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
local a = 0
|
||||
local vote_count = 0
|
||||
for _, d in pairs(global.difficulty_player_votes) do
|
||||
a = a + d
|
||||
vote_count = vote_count + 1
|
||||
end
|
||||
a = a / vote_count
|
||||
local new_index = math.round(a, 0)
|
||||
if global.difficulty_vote_index ~= new_index then
|
||||
game.print(">>> Map difficulty has changed to " .. difficulties[new_index].name .. " difficulty!", difficulties[new_index].print_color)
|
||||
end
|
||||
global.difficulty_vote_index = new_index
|
||||
global.difficulty_vote_value = difficulties[new_index].value
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 then
|
||||
if bb_config.only_admins_vote then
|
||||
if player.admin then poll_difficulty(player) end
|
||||
else
|
||||
poll_difficulty(player)
|
||||
end
|
||||
end
|
||||
if not global.difficulty_vote_value then global.difficulty_vote_value = 1 end
|
||||
if not global.difficulty_vote_index then global.difficulty_vote_index = 4 end
|
||||
if not global.difficulty_player_votes then global.difficulty_player_votes = {} end
|
||||
difficulty_gui()
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then return end
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "difficulty_gui" then
|
||||
poll_difficulty(player)
|
||||
return
|
||||
end
|
||||
if event.element.parent.name ~= "difficulty_poll" then return end
|
||||
if event.element.name == "skip" then event.element.parent.destroy() end
|
||||
local i = tonumber(event.element.name)
|
||||
game.print(player.name .. " has voted for " .. difficulties[i].name .. " difficulty!", difficulties[i].print_color)
|
||||
global.difficulty_player_votes[player.name] = i
|
||||
set_difficulty()
|
||||
difficulty_gui()
|
||||
event.element.parent.destroy()
|
||||
end
|
||||
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
@ -49,41 +49,13 @@ local function set_biter_endgame_modifiers(force)
|
||||
global.bb_evasion[force.name] = evasion_mod
|
||||
end
|
||||
|
||||
local function feed_biters(player, food)
|
||||
local enemy_force_name = enemy_team_of[player.force.name] ---------------
|
||||
--enemy_force_name = player.force.name
|
||||
|
||||
local biter_force_name = enemy_force_name .. "_biters"
|
||||
|
||||
local i = player.get_main_inventory()
|
||||
local flask_amount = i.get_item_count(food)
|
||||
if flask_amount == 0 then
|
||||
player.print("You have no " .. food_values[food].name .. " flask in your inventory.", {r = 0.98, g = 0.66, b = 0.22})
|
||||
return
|
||||
end
|
||||
|
||||
i.remove({name = food, count = flask_amount})
|
||||
|
||||
local colored_player_name = table.concat({"[color=", player.color.r * 0.6 + 0.35, ",", player.color.g * 0.6 + 0.35, ",", player.color.b * 0.6 + 0.35, "]", player.name, "[/color]"})
|
||||
local formatted_food = table.concat({"[color=", food_values[food].color, "]", food_values[food].name, " juice[/color]", "[img=item/", food, "]"})
|
||||
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_force_name] .. " biters!", {r = 0.9, g = 0.9, b = 0.9})
|
||||
else
|
||||
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})
|
||||
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})
|
||||
end
|
||||
end
|
||||
|
||||
function set_evo_and_threat(flask_amount, food, biter_force_name)
|
||||
local decimals = 12
|
||||
local math_round = math.round
|
||||
|
||||
local instant_threat_player_count_modifier = get_instant_threat_player_count_modifier()
|
||||
|
||||
local food_value = food_values[food].value * 0.5
|
||||
local food_value = food_values[food].value * global.difficulty_vote_value
|
||||
|
||||
for a = 1, flask_amount, 1 do
|
||||
--SET THREAT INCOME
|
||||
@ -113,4 +85,36 @@ local function feed_biters(player, food)
|
||||
set_biter_endgame_modifiers(game.forces[biter_force_name])
|
||||
end
|
||||
|
||||
local function feed_biters(player, food)
|
||||
local enemy_force_name = enemy_team_of[player.force.name] ---------------
|
||||
--enemy_force_name = player.force.name
|
||||
|
||||
local biter_force_name = enemy_force_name .. "_biters"
|
||||
|
||||
local i = player.get_main_inventory()
|
||||
local flask_amount = i.get_item_count(food)
|
||||
if flask_amount == 0 then
|
||||
player.print("You have no " .. food_values[food].name .. " flask in your inventory.", {r = 0.98, g = 0.66, b = 0.22})
|
||||
return
|
||||
end
|
||||
|
||||
i.remove({name = food, count = flask_amount})
|
||||
|
||||
local colored_player_name = table.concat({"[color=", player.color.r * 0.6 + 0.35, ",", player.color.g * 0.6 + 0.35, ",", player.color.b * 0.6 + 0.35, "]", player.name, "[/color]"})
|
||||
local formatted_food = table.concat({"[color=", food_values[food].color, "]", food_values[food].name, " juice[/color]", "[img=item/", food, "]"})
|
||||
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_force_name] .. " biters!", {r = 0.9, g = 0.9, b = 0.9})
|
||||
else
|
||||
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})
|
||||
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})
|
||||
end
|
||||
end
|
||||
|
||||
set_evo_and_threat(flask_amount, food, biter_force_name)
|
||||
end
|
||||
|
||||
return feed_biters
|
@ -70,7 +70,7 @@ local function on_tick(event)
|
||||
|
||||
if game.tick % 3600 ~= 0 then return end
|
||||
--if game.tick % 7200 ~= 0 then return end
|
||||
|
||||
ai.raise_evo()
|
||||
ai.destroy_inactive_biters()
|
||||
ai.main_attack()
|
||||
ai.send_near_biters_to_silo()
|
||||
|
@ -4,25 +4,27 @@ local difficulties = {
|
||||
[1] = {name = "Peaceful", value = 0.25, color = {r=0.00, g=0.45, b=0.00}, print_color = {r=0.00, g=0.8, b=0.00}},
|
||||
[2] = {name = "Easy", value = 0.5, color = {r=0.00, g=0.35, b=0.00}, print_color = {r=0.00, g=0.6, b=0.00}},
|
||||
[3] = {name = "Piece of cake", value = 0.75, color = {r=0.00, g=0.25, b=0.00}, print_color = {r=0.00, g=0.4, b=0.00}},
|
||||
[4] = {name = "Normal", value = 1, color = {r=0.00, g=0.00, b=0.25}, print_color = {r=0.3, g=0.3, b=0.3}},
|
||||
[4] = {name = "Normal", value = 1, color = {r=0.00, g=0.00, b=0.25}, print_color = {r=0.0, g=0.0, b=0.5}},
|
||||
[5] = {name = "Hard", value = 1.5, color = {r=0.25, g=0.00, b=0.00}, print_color = {r=0.4, g=0.0, b=0.00}},
|
||||
[6] = {name = "Nightmare", value = 3, color = {r=0.35, g=0.00, b=0.00}, print_color = {r=0.6, g=0.0, b=0.00}},
|
||||
[7] = {name = "Impossible", value = 5, color = {r=0.45, g=0.00, b=0.00}, print_color = {r=0.8, g=0.0, b=0.00}}
|
||||
}
|
||||
|
||||
local poll_closing_timeout = 108000
|
||||
|
||||
local function difficulty_gui()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.gui.top["difficulty_gui"] then player.gui.top["difficulty_gui"].destroy() end
|
||||
local b = player.gui.top.add { type = "button", caption = difficulties[global.difficulty_vote_index].name, tooltip = "Current difficulty of the map is " .. difficulties[global.difficulty_vote_index].name .. ".", name = "difficulty_gui" }
|
||||
b.style.font = "heading-2"
|
||||
b.style.font_color = difficulties[global.difficulty_vote_index].color
|
||||
b.style.font_color = difficulties[global.difficulty_vote_index].print_color
|
||||
b.style.minimal_height = 38
|
||||
end
|
||||
end
|
||||
|
||||
local function poll_difficulty(player)
|
||||
if player.gui.center["difficulty_poll"] then player.gui.center["difficulty_poll"].destroy() end
|
||||
if game.tick > 108000 then return end
|
||||
if player.gui.center["difficulty_poll"] then player.gui.center["difficulty_poll"].destroy() return end
|
||||
if game.tick > poll_closing_timeout then return end
|
||||
|
||||
local frame = player.gui.center.add { type = "frame", caption = "Vote difficulty:", name = "difficulty_poll", direction = "vertical" }
|
||||
for i = 1, 7, 1 do
|
||||
@ -32,7 +34,7 @@ local function poll_difficulty(player)
|
||||
b.style.minimal_width = 160
|
||||
end
|
||||
local b = frame.add({type = "label", caption = "- - - - - - - - - - - - - - - - - -"})
|
||||
local b = frame.add({type = "button", name = "skip", caption = "skip voting"})
|
||||
local b = frame.add({type = "button", name = "skip", caption = "Close (" .. math.floor((poll_closing_timeout - game.tick) / 3600) .. " minutes left)"})
|
||||
b.style.font_color = {r=0.66, g=0.0, b=0.66}
|
||||
b.style.font = "heading-3"
|
||||
b.style.minimal_width = 96
|
||||
@ -40,16 +42,18 @@ end
|
||||
|
||||
local function set_difficulty()
|
||||
local a = 0
|
||||
local vote_count = 0
|
||||
for _, d in pairs(global.difficulty_player_votes) do
|
||||
a = a + d
|
||||
vote_count = vote_count + 1
|
||||
end
|
||||
a = a / #global.difficulty_player_votes
|
||||
a = a / vote_count
|
||||
local new_index = math.round(a, 0)
|
||||
if global.difficulty_vote_index ~= new_index then
|
||||
game.print(">>> Map difficulty has changed to " .. difficulties[new_index].name .. " difficulty!", difficulties[new_index].print_color)
|
||||
end
|
||||
global.difficulty_vote_index = new_index
|
||||
global.difficulty_vote_value = difficulties[a].value
|
||||
global.difficulty_vote_value = difficulties[new_index].value
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
@ -67,12 +71,16 @@ local function on_gui_click(event)
|
||||
if not event then return end
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "difficulty_gui" then
|
||||
poll_difficulty(player)
|
||||
return
|
||||
end
|
||||
if event.element.parent.name ~= "difficulty_poll" then return end
|
||||
if event.element.name == "skip" then event.element.parent.destroy() end
|
||||
local player = game.players[event.element.player_index]
|
||||
local i = tonumber(event.element.name)
|
||||
game.print(player.name .. " has voted for " .. difficulties[i].name .. " difficulty!", difficulties[i].print_color)
|
||||
global.difficulty_player_votes[player.index] = i
|
||||
global.difficulty_player_votes[player.name] = i
|
||||
set_difficulty()
|
||||
difficulty_gui()
|
||||
event.element.parent.destroy()
|
||||
|
Loading…
Reference in New Issue
Block a user