1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/maps/biter_battles_v2/on_tick.lua

68 lines
2.2 KiB
Lua
Raw Normal View History

2019-03-14 19:06:39 +02:00
local event = require 'utils.event'
local gui = require "maps.biter_battles_v2.gui"
local ai = require "maps.biter_battles_v2.ai"
2019-03-17 03:35:58 +02:00
local chunk_pregen = require "maps.biter_battles_v2.pregenerate_chunks"
2019-03-17 19:19:40 +02:00
local mirror_map = require "maps.biter_battles_v2.mirror_terrain"
2019-03-18 02:30:41 +02:00
local server_restart = require "maps.biter_battles_v2.game_won"
2019-03-14 19:06:39 +02:00
2019-03-18 02:30:41 +02:00
local spy_forces = {{"north", "south"},{"south", "north"}}
local function spy_fish()
for _, f in pairs(spy_forces) do
if global.spy_fish_timeout[f[1]] - game.tick > 0 then
local r = 96
local surface = game.surfaces["biter_battles"]
for _, player in pairs(game.forces[f[2]].connected_players) do
game.forces[f[1]].chart(surface, {{player.position.x - r, player.position.y - r}, {player.position.x + r, player.position.y + r}})
end
else
global.spy_fish_timeout[f[1]] = 0
end
end
2019-03-17 22:39:05 +02:00
end
2019-04-12 02:57:25 +02:00
local function clear_corpses()
for _, e in pairs(game.surfaces["biter_battles"].find_entities_filtered({type = "corpse"})) do
if math.random(1, 3) == 1 then
e.destroy()
end
end
2019-03-15 04:59:43 +02:00
end
local function restart_idle_map()
if game.tick < 432000 then return end
if #game.connected_players ~= 0 then global.restart_idle_map_countdown = 2 return end
if not global.restart_idle_map_countdown then global.restart_idle_map_countdown = 2 end
global.restart_idle_map_countdown = global.restart_idle_map_countdown - 1
if global.restart_idle_map_countdown ~= 0 then return end
server_commands.start_scenario('Biter_Battles')
end
2019-03-14 19:06:39 +02:00
local function on_tick(event)
2019-03-17 22:39:05 +02:00
if game.tick % 30 ~= 0 then return end
2019-03-17 03:35:58 +02:00
chunk_pregen()
2019-03-17 19:19:40 +02:00
mirror_map()
2019-03-17 03:35:58 +02:00
2019-03-17 22:39:05 +02:00
if game.tick % 60 ~= 0 then return end
2019-03-16 08:31:34 +02:00
global.bb_threat["north_biters"] = global.bb_threat["north_biters"] + global.bb_threat_income["north_biters"]
2019-03-17 22:39:05 +02:00
global.bb_threat["south_biters"] = global.bb_threat["south_biters"] + global.bb_threat_income["south_biters"]
2019-03-18 02:30:41 +02:00
if game.tick % 120 == 0 then gui() end
if game.tick % 300 ~= 0 then return end
spy_fish()
if global.bb_game_won_by_team then server_restart() return end
2019-03-16 08:31:34 +02:00
2019-03-18 02:30:41 +02:00
if game.tick % 1800 ~= 0 then return end
ai.destroy_inactive_biters()
2019-03-16 08:31:34 +02:00
ai.main_attack()
2019-04-12 02:57:25 +02:00
ai.send_near_biters_to_silo()
if game.tick % 3600 ~= 0 then return end
clear_corpses()
restart_idle_map()
2019-03-14 19:06:39 +02:00
end
event.add(defines.events.on_tick, on_tick)