mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-18 03:21:36 +02:00
more updating
This commit is contained in:
parent
f5920adb9d
commit
83927c654e
@ -1,5 +1,6 @@
|
||||
local Public = {}
|
||||
local Team = require "maps.biter_hatchery.team"
|
||||
local Server = require 'utils.server'
|
||||
|
||||
function Public.spectate_button(player)
|
||||
if player.gui.top.spectate_button then return end
|
||||
@ -46,7 +47,7 @@ local function create_spectate_confirmation(player)
|
||||
end
|
||||
|
||||
function Public.rejoin_question(hatchery)
|
||||
if game.tick % 60 ~= 0 then return end
|
||||
if game.tick % 90 ~= 0 then return end
|
||||
for _, player in pairs(game.forces.spectator.players) do
|
||||
if not player.gui.center.rejoin_question_frame then
|
||||
local frame = player.gui.center.add({type = "frame", name = "rejoin_question_frame", caption = "Rejoin the game?"})
|
||||
@ -56,8 +57,13 @@ function Public.rejoin_question(hatchery)
|
||||
frame.add({type = "button", name = "cancel_rejoin", caption = "Cancel"})
|
||||
end
|
||||
end
|
||||
hatchery.reset_counter = hatchery.reset_counter + 1
|
||||
game.print("Biter Hatchery round #" .. hatchery.reset_counter .. " has begun!", {180, 0, 250})
|
||||
hatchery.reset_counter = hatchery.reset_counter + 1
|
||||
local message = "Biter Hatchery round #" .. hatchery.reset_counter .. " has begun!"
|
||||
game.print(message, {180, 0, 250})
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound{path="utility/new_objective", volume_modifier=0.85}
|
||||
end
|
||||
hatchery.gamestate = "game_in_progress"
|
||||
end
|
||||
|
||||
|
@ -10,6 +10,7 @@ local Team = require "maps.biter_hatchery.team"
|
||||
local Unit_health_booster = require "modules.biter_health_booster"
|
||||
local Map = require "modules.map_info"
|
||||
local Global = require 'utils.global'
|
||||
local Server = require 'utils.server'
|
||||
local Public = {}
|
||||
|
||||
local math_random = math.random
|
||||
@ -224,7 +225,10 @@ local function on_entity_died(event)
|
||||
game.print("East lost their Hatchery.", {100, 100, 100})
|
||||
game.forces.east.play_sound{path="utility/game_lost", volume_modifier=0.85}
|
||||
|
||||
game.print(">>>> WEST TEAM HAS WON THE GAME!!! <<<<", {250, 120, 0})
|
||||
local message = ">>>> WEST TEAM HAS WON THE GAME!!! <<<<"
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
game.print(message, {250, 120, 0})
|
||||
|
||||
game.forces.west.play_sound{path="utility/game_won", volume_modifier=0.85}
|
||||
|
||||
for _, player in pairs(game.forces.west.connected_players) do
|
||||
@ -235,8 +239,11 @@ local function on_entity_died(event)
|
||||
else
|
||||
game.print("West lost their Hatchery.", {100, 100, 100})
|
||||
game.forces.west.play_sound{path="utility/game_lost", volume_modifier=0.85}
|
||||
|
||||
game.print(">>>> EAST TEAM HAS WON THE GAME!!! <<<<", {250, 120, 0})
|
||||
|
||||
local message = ">>>> EAST TEAM HAS WON THE GAME!!! <<<<"
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
game.print(message, {250, 120, 0})
|
||||
|
||||
game.forces.east.play_sound{path="utility/game_won", volume_modifier=0.85}
|
||||
|
||||
for _, player in pairs(game.forces.east.connected_players) do
|
||||
@ -246,7 +253,7 @@ local function on_entity_died(event)
|
||||
end
|
||||
end
|
||||
|
||||
game.print("Map will restart in 2 minutes.", {150, 150, 150})
|
||||
game.print("Map rerolling in 2 minutes.", {150, 150, 150})
|
||||
|
||||
game.forces.spectator.play_sound{path="utility/game_won", volume_modifier=0.85}
|
||||
|
||||
@ -270,10 +277,16 @@ local function on_player_joined_game(event)
|
||||
Gui.spectate_button(player)
|
||||
Gui.update_health_boost_buttons(player)
|
||||
|
||||
if player.force.name == "player" then
|
||||
Team.assign_force_to_player(player)
|
||||
Team.add_player_to_team(player)
|
||||
Team.teleport_player_to_spawn(player)
|
||||
if player.force.name == "player" then
|
||||
if player.character and player.character.valid then player.character.destroy() end
|
||||
player.character = nil
|
||||
player.spectator = true
|
||||
player.set_controller({type=defines.controllers.spectator})
|
||||
if hatchery.gamestate == "game_in_progress" or hatchery.gamestate == "rejoin_question" then
|
||||
Team.assign_force_to_player(player)
|
||||
Team.add_player_to_team(player)
|
||||
Team.teleport_player_to_spawn(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -376,6 +389,7 @@ local gamestates = {
|
||||
["init"] = Team.init,
|
||||
["reset_nauvis"] = Terrain.reset_nauvis,
|
||||
["prepare_east"] = Terrain.prepare_east,
|
||||
["clear_west"] = Terrain.clear_west,
|
||||
["prepare_west"] = Terrain.prepare_west,
|
||||
["draw_team_nests"] = Terrain.draw_team_nests,
|
||||
["draw_border_beams"] = Terrain.draw_border_beams,
|
||||
|
@ -107,7 +107,7 @@ function Public.set_player_to_spectator(player)
|
||||
end
|
||||
|
||||
function Public.spawn_players(hatchery)
|
||||
if game.tick % 60 ~= 0 then return end
|
||||
if game.tick % 90 ~= 0 then return end
|
||||
game.print("spawning characters", {150, 150, 150})
|
||||
local surface = game.surfaces.nauvis
|
||||
for _, player in pairs(game.connected_players) do
|
||||
@ -123,36 +123,36 @@ end
|
||||
function Public.init(hatchery)
|
||||
game.reset_time_played()
|
||||
Public.reset_forces()
|
||||
|
||||
local players = {}
|
||||
for _, player in pairs(game.players) do table.insert(players, player.index) end
|
||||
|
||||
for k, player_index in pairs(players) do
|
||||
local player = game.players[player_index]
|
||||
if player.force.name == "spectator" then
|
||||
Public.teleport_player_to_spawn(player)
|
||||
table.remove(players, k)
|
||||
end
|
||||
end
|
||||
|
||||
for k, player_index in pairs(players) do
|
||||
local player = game.players[player_index]
|
||||
if not player.connected then
|
||||
player.force = game.forces.player
|
||||
table.remove(players, k)
|
||||
end
|
||||
end
|
||||
|
||||
for k, player_index in pairs(players) do
|
||||
local player = game.players[player_index]
|
||||
if player.character and player.character.valid then player.character.destroy() end
|
||||
player.character = nil
|
||||
player.spectator = true
|
||||
player.set_controller({type=defines.controllers.spectator})
|
||||
player.force = game.forces.player
|
||||
Public.teleport_player_to_spawn(player)
|
||||
end
|
||||
|
||||
for _, player in pairs(game.forces.spectator.players) do
|
||||
Public.teleport_player_to_spawn(player)
|
||||
end
|
||||
|
||||
for _, player in pairs(game.forces.west.players) do
|
||||
if player.connected then
|
||||
if player.character and player.character.valid then player.character.destroy() end
|
||||
player.character = nil
|
||||
player.spectator = true
|
||||
player.set_controller({type=defines.controllers.spectator})
|
||||
player.force = game.forces.player
|
||||
Public.teleport_player_to_spawn(player)
|
||||
else
|
||||
player.force = game.forces.player
|
||||
end
|
||||
end
|
||||
|
||||
for _, player in pairs(game.forces.east.players) do
|
||||
if player.connected then
|
||||
if player.character and player.character.valid then player.character.destroy() end
|
||||
player.character = nil
|
||||
player.spectator = true
|
||||
player.set_controller({type=defines.controllers.spectator})
|
||||
player.force = game.forces.player
|
||||
Public.teleport_player_to_spawn(player)
|
||||
else
|
||||
player.force = game.forces.player
|
||||
end
|
||||
end
|
||||
hatchery.gamestate = "reset_nauvis"
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ function Public.reset_nauvis(hatchery)
|
||||
end
|
||||
|
||||
function Public.prepare_east(hatchery)
|
||||
if game.tick % 60 ~= 0 then return end
|
||||
if game.tick % 90 ~= 0 then return end
|
||||
game.print("preparing east", {150, 150, 150})
|
||||
local surface = game.surfaces.nauvis
|
||||
surface.request_to_generate_chunks({hatchery_position.x, 0}, 7)
|
||||
@ -97,9 +97,14 @@ function Public.prepare_east(hatchery)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
draw_spawn_ore(surface, {x = 240, y = 0})
|
||||
hatchery.gamestate = "clear_west"
|
||||
end
|
||||
|
||||
function Public.clear_west(hatchery)
|
||||
if game.tick % 90 ~= 0 then return end
|
||||
game.print("clearing west chunks", {150, 150, 150})
|
||||
local surface = game.surfaces.nauvis
|
||||
for chunk in surface.get_chunks() do
|
||||
if chunk.x < 0 then surface.delete_chunk({chunk.x, chunk.y}) end
|
||||
end
|
||||
@ -108,17 +113,17 @@ function Public.prepare_east(hatchery)
|
||||
end
|
||||
|
||||
function Public.prepare_west(hatchery)
|
||||
if game.tick % 60 ~= 0 then return end
|
||||
game.print("preparing west " .. #hatchery.mirror_queue, {150, 150, 150})
|
||||
if game.tick % 90 ~= 0 then return end
|
||||
local surface = game.surfaces.nauvis
|
||||
surface.request_to_generate_chunks({hatchery_position.x * -1, 0}, 7)
|
||||
surface.force_generate_chunk_requests()
|
||||
game.print("preparing west chunks " .. #hatchery.mirror_queue, {150, 150, 150})
|
||||
if #hatchery.mirror_queue > 0 then return end
|
||||
hatchery.gamestate = "draw_team_nests"
|
||||
end
|
||||
|
||||
function Public.draw_team_nests(hatchery)
|
||||
if game.tick % 60 ~= 0 then return end
|
||||
if game.tick % 90 ~= 0 then return end
|
||||
game.print("placing nests", {150, 150, 150})
|
||||
local surface = game.surfaces.nauvis
|
||||
local x = hatchery_position.x
|
||||
@ -148,7 +153,7 @@ function Public.draw_team_nests(hatchery)
|
||||
end
|
||||
|
||||
function Public.draw_border_beams(hatchery)
|
||||
if game.tick % 60 ~= 0 then return end
|
||||
if game.tick % 90 ~= 0 then return end
|
||||
local surface = game.surfaces.nauvis
|
||||
surface.create_entity({name = "electric-beam", position = {4, -96}, source = {4, -96}, target = {4,96}})
|
||||
surface.create_entity({name = "electric-beam", position = {-4, -96}, source = {-4, -96}, target = {-4,96}})
|
||||
|
Loading…
x
Reference in New Issue
Block a user