2021-03-24 21:14:55 +02:00
|
|
|
--luacheck: ignore
|
2018-12-31 02:55:18 +02:00
|
|
|
-- nightfall -- by mewmew --
|
|
|
|
|
|
|
|
local event = require 'utils.event'
|
|
|
|
local math_random = math.random
|
|
|
|
local insert = table.insert
|
2024-01-28 21:42:28 +02:00
|
|
|
local map_functions = require 'utils.tools.map_functions'
|
2024-10-01 16:46:06 +02:00
|
|
|
local simplex_noise = require 'utils.math.simplex_noise'
|
2018-12-31 02:55:18 +02:00
|
|
|
local simplex_noise = simplex_noise.d2
|
2021-03-24 17:46:00 +02:00
|
|
|
require 'maps.nightfall_map_intro'
|
|
|
|
require 'modules.splice_double'
|
|
|
|
require 'modules.spitters_spit_biters'
|
|
|
|
require 'modules.biters_double_damage'
|
|
|
|
require 'modules.explosive_biters'
|
|
|
|
require 'modules.spawners_contain_biters'
|
|
|
|
require 'modules.railgun_enhancer'
|
|
|
|
require 'modules.dynamic_landfill'
|
|
|
|
require 'modules.satellite_score'
|
2018-12-31 02:55:18 +02:00
|
|
|
|
|
|
|
local spawn_turret_amount = 8
|
|
|
|
|
|
|
|
local function shuffle(tbl)
|
2021-03-24 17:46:00 +02:00
|
|
|
local size = #tbl
|
|
|
|
for i = size, 1, -1 do
|
|
|
|
local rand = math_random(size)
|
|
|
|
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
|
|
|
end
|
|
|
|
return tbl
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function create_time_gui(player)
|
2021-03-24 17:46:00 +02:00
|
|
|
if player.gui.top['time_gui'] then
|
|
|
|
player.gui.top['time_gui'].destroy()
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
local frame = player.gui.top.add({ type = 'frame', name = 'time_gui' })
|
2021-03-24 17:46:00 +02:00
|
|
|
frame.style.maximal_height = 38
|
|
|
|
|
|
|
|
local night_count = 0
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.night_count then
|
|
|
|
night_count = storage.night_count
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local label = frame.add({ type = 'label', caption = 'Night: ' .. night_count })
|
|
|
|
label.style.font_color = { r = 0.75, g = 0.0, b = 0.25 }
|
2021-03-24 17:46:00 +02:00
|
|
|
label.style.font = 'default-listbox'
|
|
|
|
label.style.left_padding = 4
|
|
|
|
label.style.right_padding = 4
|
|
|
|
label.style.minimal_width = 50
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
2018-12-31 16:39:09 +02:00
|
|
|
local function spawn_shipwreck(surface, position)
|
2021-03-24 17:46:00 +02:00
|
|
|
local raffle = {}
|
|
|
|
local loot = {
|
2024-10-25 16:15:09 +02:00
|
|
|
{ { name = 'submachine-gun', count = math_random(1, 3) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 },
|
|
|
|
{ { name = 'slowdown-capsule', count = math_random(16, 32) }, weight = 1, evolution_min = 0.0, evolution_max = 1 },
|
|
|
|
{ { name = 'poison-capsule', count = math_random(16, 32) }, weight = 3, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'uranium-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.6, evolution_max = 1 },
|
|
|
|
{ { name = 'cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 0.7 },
|
|
|
|
{ { name = 'explosive-uranium-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.6, evolution_max = 1 },
|
|
|
|
{ { name = 'explosive-cannon-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 0.8 },
|
|
|
|
{ { name = 'shotgun', count = 1 }, weight = 2, evolution_min = 0.0, evolution_max = 0.2 },
|
|
|
|
{ { name = 'shotgun-shell', count = math_random(16, 32) }, weight = 5, evolution_min = 0.0, evolution_max = 0.2 },
|
|
|
|
{ { name = 'combat-shotgun', count = 1 }, weight = 10, evolution_min = 0.3, evolution_max = 0.8 },
|
|
|
|
{ { name = 'piercing-shotgun-shell', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 1 },
|
|
|
|
{ { name = 'flamethrower', count = 1 }, weight = 3, evolution_min = 0.3, evolution_max = 0.6 },
|
|
|
|
{ { name = 'flamethrower-ammo', count = math_random(16, 32) }, weight = 5, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'rocket-launcher', count = 1 }, weight = 5, evolution_min = 0.2, evolution_max = 0.6 },
|
|
|
|
{ { name = 'rocket', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'explosive-rocket', count = math_random(16, 32) }, weight = 10, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'land-mine', count = math_random(16, 32) }, weight = 10, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'grenade', count = math_random(16, 32) }, weight = 10, evolution_min = 0.0, evolution_max = 0.5 },
|
|
|
|
{ { name = 'cluster-grenade', count = math_random(16, 32) }, weight = 5, evolution_min = 0.4, evolution_max = 1 },
|
|
|
|
{ { name = 'firearm-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'piercing-rounds-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0.1, evolution_max = 0.8 },
|
|
|
|
{ { name = 'uranium-rounds-magazine', count = math_random(32, 128) }, weight = 10, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'railgun', count = 1 }, weight = 1, evolution_min = 0.2, evolution_max = 1 },
|
|
|
|
{ { name = 'railgun-dart', count = math_random(16, 32) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'defender-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.0, evolution_max = 0.7 },
|
|
|
|
{ { name = 'distractor-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.2, evolution_max = 1 },
|
|
|
|
{ { name = 'destroyer-capsule', count = math_random(8, 16) }, weight = 10, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'atomic-bomb', count = math_random(8, 16) }, weight = 1, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'light-armor', count = 1 }, weight = 3, evolution_min = 0, evolution_max = 0.1 },
|
|
|
|
{ { name = 'heavy-armor', count = 1 }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 },
|
|
|
|
{ { name = 'modular-armor', count = 1 }, weight = 2, evolution_min = 0.2, evolution_max = 0.6 },
|
|
|
|
{ { name = 'power-armor', count = 1 }, weight = 2, evolution_min = 0.4, evolution_max = 1 },
|
|
|
|
{ { name = 'power-armor-mk2', count = 1 }, weight = 1, evolution_min = 0.8, evolution_max = 1 },
|
|
|
|
{ { name = 'battery-equipment', count = 1 }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 },
|
|
|
|
{ { name = 'battery-mk2-equipment', count = 1 }, weight = 2, evolution_min = 0.6, evolution_max = 1 },
|
|
|
|
{ { name = 'belt-immunity-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'solar-panel-equipment', count = math_random(1, 4) }, weight = 5, evolution_min = 0.3, evolution_max = 0.8 },
|
|
|
|
{ { name = 'discharge-defense-equipment', count = 1 }, weight = 1, evolution_min = 0.5, evolution_max = 0.8 },
|
|
|
|
{ { name = 'energy-shield-equipment', count = math_random(1, 2) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 },
|
|
|
|
{ { name = 'energy-shield-mk2-equipment', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 },
|
|
|
|
{ { name = 'exoskeleton-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'fusion-reactor-equipment', count = 1 }, weight = 1, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'night-vision-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 },
|
|
|
|
{ { name = 'personal-laser-defense-equipment', count = 1 }, weight = 2, evolution_min = 0.4, evolution_max = 1 },
|
|
|
|
{ { name = 'exoskeleton-equipment', count = 1 }, weight = 1, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'iron-gear-wheel', count = math_random(80, 100) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'copper-cable', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.1, evolution_max = 0.5 },
|
|
|
|
{ { name = 'electric-engine-unit', count = math_random(16, 32) }, weight = 2, evolution_min = 0.4, evolution_max = 0.8 },
|
|
|
|
{ { name = 'battery', count = math_random(100, 200) }, weight = 2, evolution_min = 0.3, evolution_max = 0.8 },
|
|
|
|
{ { name = 'advanced-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.4, evolution_max = 1 },
|
|
|
|
{ { name = 'electronic-circuit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 },
|
|
|
|
{ { name = 'processing-unit', count = math_random(100, 200) }, weight = 3, evolution_min = 0.7, evolution_max = 1 },
|
|
|
|
{ { name = 'explosives', count = math_random(25, 50) }, weight = 1, evolution_min = 0.2, evolution_max = 0.6 },
|
|
|
|
{ { name = 'lubricant-barrel', count = math_random(4, 10) }, weight = 1, evolution_min = 0.3, evolution_max = 0.5 },
|
|
|
|
{ { name = 'rocket-fuel', count = math_random(4, 10) }, weight = 2, evolution_min = 0.3, evolution_max = 0.7 },
|
|
|
|
{ { name = 'steel-plate', count = math_random(50, 100) }, weight = 2, evolution_min = 0.1, evolution_max = 0.3 },
|
|
|
|
{ { name = 'nuclear-fuel', count = 1 }, weight = 2, evolution_min = 0.7, evolution_max = 1 },
|
|
|
|
{ { name = 'burner-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 },
|
|
|
|
{ { name = 'inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 },
|
|
|
|
{ { name = 'long-handed-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.4 },
|
|
|
|
{ { name = 'fast-inserter', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 1 },
|
|
|
|
{ { name = 'bulk-inserter', count = math_random(4, 8) }, weight = 1, evolution_min = 0.4, evolution_max = 1 },
|
|
|
|
{ { name = 'bulk-inserter', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'small-electric-pole', count = math_random(16, 32) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'medium-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.2, evolution_max = 1 },
|
|
|
|
{ { name = 'big-electric-pole', count = math_random(8, 16) }, weight = 3, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'substation', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'wooden-chest', count = math_random(25, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 },
|
|
|
|
{ { name = 'iron-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.1, evolution_max = 0.4 },
|
|
|
|
{ { name = 'steel-chest', count = math_random(4, 8) }, weight = 3, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'small-lamp', count = math_random(8, 16) }, weight = 3, evolution_min = 0.1, evolution_max = 0.3 },
|
|
|
|
{ { name = 'rail', count = math_random(50, 75) }, weight = 3, evolution_min = 0.1, evolution_max = 0.6 },
|
|
|
|
{ { name = 'assembling-machine-1', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'assembling-machine-2', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.8 },
|
|
|
|
{ { name = 'assembling-machine-3', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'accumulator', count = math_random(4, 8) }, weight = 3, evolution_min = 0.4, evolution_max = 1 },
|
|
|
|
{ { name = 'offshore-pump', count = math_random(1, 2) }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 },
|
|
|
|
{ { name = 'beacon', count = math_random(1, 2) }, weight = 3, evolution_min = 0.7, evolution_max = 1 },
|
|
|
|
{ { name = 'boiler', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'steam-engine', count = math_random(2, 4) }, weight = 3, evolution_min = 0.0, evolution_max = 0.5 },
|
|
|
|
{ { name = 'steam-turbine', count = math_random(1, 2) }, weight = 2, evolution_min = 0.5, evolution_max = 1 },
|
2021-03-24 17:46:00 +02:00
|
|
|
--{{name = "nuclear-reactor", count = 1}, weight = 2, evolution_min = 0.5, evolution_max = 1},
|
2024-10-25 16:15:09 +02:00
|
|
|
{ { name = 'centrifuge', count = math_random(1, 2) }, weight = 2, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'heat-pipe', count = math_random(8, 12) }, weight = 2, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'heat-exchanger', count = math_random(2, 4) }, weight = 2, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'arithmetic-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 },
|
|
|
|
{ { name = 'constant-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 },
|
|
|
|
{ { name = 'decider-combinator', count = math_random(8, 16) }, weight = 1, evolution_min = 0.1, evolution_max = 1 },
|
|
|
|
{ { name = 'power-switch', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 },
|
|
|
|
{ { name = 'programmable-speaker', count = math_random(2, 4) }, weight = 1, evolution_min = 0.1, evolution_max = 1 },
|
|
|
|
{ { name = 'chemical-plant', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'burner-mining-drill', count = math_random(4, 8) }, weight = 3, evolution_min = 0.0, evolution_max = 0.2 },
|
|
|
|
{ { name = 'electric-mining-drill', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.6 },
|
|
|
|
{ { name = 'express-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'express-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'express-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'fast-transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'fast-underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'fast-splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.3 },
|
|
|
|
{ { name = 'transport-belt', count = math_random(25, 75) }, weight = 3, evolution_min = 0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'underground-belt', count = math_random(4, 8) }, weight = 3, evolution_min = 0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'splitter', count = math_random(2, 4) }, weight = 3, evolution_min = 0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'oil-refinery', count = math_random(1, 2) }, weight = 2, evolution_min = 0.3, evolution_max = 1 },
|
|
|
|
{ { name = 'pipe', count = math_random(40, 50) }, weight = 3, evolution_min = 0.0, evolution_max = 0.3 },
|
|
|
|
{ { name = 'pipe-to-ground', count = math_random(8, 16) }, weight = 1, evolution_min = 0.2, evolution_max = 0.5 },
|
|
|
|
{ { name = 'pumpjack', count = math_random(1, 2) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 },
|
|
|
|
{ { name = 'pump', count = math_random(1, 4) }, weight = 1, evolution_min = 0.3, evolution_max = 0.8 },
|
|
|
|
{ { name = 'solar-panel', count = math_random(4, 8) }, weight = 3, evolution_min = 0.4, evolution_max = 0.9 },
|
|
|
|
{ { name = 'electric-furnace', count = math_random(2, 4) }, weight = 3, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'steel-furnace', count = math_random(4, 8) }, weight = 3, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'stone-furnace', count = math_random(8, 16) }, weight = 3, evolution_min = 0.0, evolution_max = 0.1 },
|
|
|
|
{ { name = 'radar', count = math_random(1, 2) }, weight = 1, evolution_min = 0.1, evolution_max = 0.3 },
|
|
|
|
{ { name = 'rail-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 },
|
|
|
|
{ { name = 'rail-chain-signal', count = math_random(8, 16) }, weight = 2, evolution_min = 0.2, evolution_max = 0.8 },
|
|
|
|
{ { name = 'stone-wall', count = math_random(25, 75) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 },
|
|
|
|
{ { name = 'gate', count = math_random(4, 8) }, weight = 1, evolution_min = 0.1, evolution_max = 0.5 },
|
|
|
|
{ { name = 'storage-tank', count = math_random(2, 4) }, weight = 3, evolution_min = 0.3, evolution_max = 0.6 },
|
|
|
|
{ { name = 'train-stop', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'express-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.5, evolution_max = 1 },
|
|
|
|
{ { name = 'fast-loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.2, evolution_max = 0.7 },
|
|
|
|
{ { name = 'loader', count = math_random(1, 2) }, weight = 1, evolution_min = 0.0, evolution_max = 0.5 },
|
|
|
|
{ { name = 'lab', count = math_random(2, 4) }, weight = 2, evolution_min = 0.0, evolution_max = 0.1 },
|
2021-03-24 17:46:00 +02:00
|
|
|
--{{name = "roboport", count = math_random(2,4)}, weight = 2, evolution_min = 0.6, evolution_max = 1},
|
|
|
|
--{{name = "flamethrower-turret", count = math_random(4,8)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
|
|
|
--{{name = "laser-turret", count = math_random(4,8)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
2024-10-25 16:15:09 +02:00
|
|
|
{ { name = 'gun-turret', count = math_random(2, 4) }, weight = 3, evolution_min = 0.2, evolution_max = 0.9 }
|
2021-03-24 17:46:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local distance_to_center = math.sqrt(position.x ^ 2 + position.y ^ 2)
|
|
|
|
if distance_to_center < 1 then
|
|
|
|
distance_to_center = 0.1
|
|
|
|
else
|
|
|
|
distance_to_center = distance_to_center / 5000
|
|
|
|
end
|
|
|
|
if distance_to_center > 1 then
|
|
|
|
distance_to_center = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, t in pairs(loot) do
|
|
|
|
for x = 1, t.weight, 1 do
|
|
|
|
if t.evolution_min <= distance_to_center and t.evolution_max >= distance_to_center then
|
|
|
|
table.insert(raffle, t[1])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
local name_raffle = { 'big-ship-wreck-1', 'big-ship-wreck-2', 'big-ship-wreck-3' }
|
|
|
|
local e = surface.create_entity { name = name_raffle[math_random(1, #name_raffle)], position = position, force = 'player' }
|
2021-03-24 17:46:00 +02:00
|
|
|
for x = 1, math_random(2, 3), 1 do
|
|
|
|
local loot = raffle[math_random(1, #raffle)]
|
|
|
|
e.insert(loot)
|
|
|
|
end
|
2018-12-31 16:39:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function clear_corpses(surface)
|
2024-09-24 19:37:11 +02:00
|
|
|
for _, entity in pairs(surface.find_entities_filtered { type = 'corpse' }) do
|
2021-03-24 17:46:00 +02:00
|
|
|
if math_random(1, 2) == 1 then
|
|
|
|
entity.destroy()
|
|
|
|
end
|
|
|
|
end
|
2018-12-31 16:39:09 +02:00
|
|
|
end
|
|
|
|
|
2019-01-03 22:50:31 +02:00
|
|
|
local function get_spawner(surface)
|
2021-03-24 17:46:00 +02:00
|
|
|
local spawners = {}
|
|
|
|
for r = 512, 51200, 512 do
|
2024-09-24 19:37:11 +02:00
|
|
|
spawners = surface.find_entities_filtered({ type = 'unit-spawner', area = { { 0 - r, 0 - r }, { 0 + r, 0 + r } } })
|
2021-03-24 17:46:00 +02:00
|
|
|
if #spawners > 16 then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if not spawners[1] then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
spawners = shuffle(spawners)
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
if not storage.last_spawners then
|
|
|
|
storage.last_spawners = { { x = spawners[1].position.x, y = spawners[1].position.y } }
|
2021-03-24 17:46:00 +02:00
|
|
|
return spawners[1]
|
|
|
|
end
|
|
|
|
|
|
|
|
for i = 1, #spawners, 1 do
|
|
|
|
local spawner_valid = true
|
2024-09-24 19:37:11 +02:00
|
|
|
for i2 = #storage.last_spawners, #storage.last_spawners - 4, -1 do
|
2021-03-24 17:46:00 +02:00
|
|
|
if i2 < 1 then
|
|
|
|
break
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
local distance = math.sqrt((spawners[i].position.x - storage.last_spawners[i2].x) ^ 2 + (spawners[i].position.y - storage.last_spawners[i2].y) ^ 2)
|
2021-03-24 17:46:00 +02:00
|
|
|
if distance < 200 then
|
|
|
|
spawner_valid = false
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if spawner_valid then
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.last_spawners[#storage.last_spawners + 1] = { x = spawners[i].position.x, y = spawners[i].position.y }
|
|
|
|
if #storage.last_spawners > 8 then
|
|
|
|
storage.last_spawners[#storage.last_spawners - 8] = nil
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
return spawners[i]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
2019-01-03 22:50:31 +02:00
|
|
|
end
|
2020-11-23 23:10:32 +02:00
|
|
|
|
|
|
|
local function send_attack_group(surface)
|
2021-03-24 17:46:00 +02:00
|
|
|
local spawner = get_spawner(surface)
|
|
|
|
if not spawner then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local biters = surface.find_enemy_units(spawner.position, 128, 'player')
|
|
|
|
if not biters[1] then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
biters = shuffle(biters)
|
|
|
|
|
|
|
|
local pos = surface.find_non_colliding_position('rocket-silo', spawner.position, 64, 1)
|
|
|
|
if not pos then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local unit_group = surface.create_unit_group({ position = pos, force = 'enemy' })
|
2021-03-24 17:46:00 +02:00
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local group_size = 6 + (storage.night_count * 6)
|
2021-03-24 17:46:00 +02:00
|
|
|
if group_size > 200 then
|
|
|
|
group_size = 200
|
|
|
|
end
|
|
|
|
|
|
|
|
for i = 1, group_size, 1 do
|
|
|
|
if not biters[i] then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
unit_group.add_member(biters[i])
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.rocket_silo.valid then
|
2021-03-24 17:46:00 +02:00
|
|
|
unit_group.set_command(
|
|
|
|
{
|
|
|
|
type = defines.command.compound,
|
|
|
|
structure_type = defines.compound_command.return_last,
|
|
|
|
commands = {
|
|
|
|
{
|
|
|
|
type = defines.command.attack_area,
|
2024-09-24 19:37:11 +02:00
|
|
|
destination = { x = 0, y = 0 },
|
2021-03-24 17:46:00 +02:00
|
|
|
radius = 48,
|
|
|
|
distraction = defines.distraction.by_anything
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type = defines.command.attack,
|
2024-09-24 19:37:11 +02:00
|
|
|
target = storage.rocket_silo,
|
2021-03-24 17:46:00 +02:00
|
|
|
distraction = defines.distraction.by_enemy
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
else
|
|
|
|
unit_group.set_command(
|
|
|
|
{
|
|
|
|
type = defines.command.compound,
|
|
|
|
structure_type = defines.compound_command.return_last,
|
|
|
|
commands = {
|
|
|
|
{
|
|
|
|
type = defines.command.attack_area,
|
2024-09-24 19:37:11 +02:00
|
|
|
destination = { x = 0, y = 0 },
|
2021-03-24 17:46:00 +02:00
|
|
|
radius = 48,
|
|
|
|
distraction = defines.distraction.by_anything
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
2019-01-01 18:17:18 +02:00
|
|
|
local daytime_messages = {
|
2021-03-24 17:46:00 +02:00
|
|
|
'It´s daytime!',
|
|
|
|
'The sun is rising, they are calming down.'
|
2019-01-01 18:17:18 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 02:55:18 +02:00
|
|
|
local function set_daytime_modifiers(surface)
|
2021-03-24 17:46:00 +02:00
|
|
|
if game.map_settings.enemy_expansion.enabled == false then
|
|
|
|
return
|
|
|
|
end
|
2020-11-23 23:10:32 +02:00
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
game.map_settings.enemy_expansion.enabled = false
|
|
|
|
--surface.peaceful_mode = true
|
2020-11-23 23:10:32 +02:00
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
--game.print(daytime_messages[math_random(1, #daytime_messages)], {r = 255, g = 255, b = 50})
|
2020-11-23 23:10:32 +02:00
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
clear_corpses(surface)
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
2019-01-01 18:17:18 +02:00
|
|
|
local nightfall_messages = {
|
2021-03-24 17:46:00 +02:00
|
|
|
'Night is falling.',
|
|
|
|
'It is getting dark.',
|
|
|
|
'They are becoming restless.'
|
2019-01-01 18:17:18 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 02:55:18 +02:00
|
|
|
local function set_nighttime_modifiers(surface)
|
2021-03-24 17:46:00 +02:00
|
|
|
if game.map_settings.enemy_expansion.enabled == true then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
if not storage.night_count then
|
|
|
|
--storage.splice_modifier = 1
|
|
|
|
storage.night_count = 1
|
2021-03-24 17:46:00 +02:00
|
|
|
else
|
|
|
|
--if game.forces["enemy"].evolution_factor > 0.25 then
|
2024-09-24 19:37:11 +02:00
|
|
|
--storage.splice_modifier = storage.splice_modifier + 0.05
|
|
|
|
--if storage.splice_modifier > 4 then storage.splice_modifier = 4 end
|
2021-03-24 17:46:00 +02:00
|
|
|
--end
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.night_count = storage.night_count + 1
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
for _, player in pairs(game.connected_players) do
|
|
|
|
create_time_gui(player)
|
|
|
|
end
|
|
|
|
|
|
|
|
surface.peaceful_mode = false
|
|
|
|
game.map_settings.enemy_expansion.enabled = true
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local max_expansion_distance = math.ceil(storage.night_count / 3)
|
2021-03-24 17:46:00 +02:00
|
|
|
if max_expansion_distance > 20 then
|
|
|
|
max_expansion_distance = 20
|
|
|
|
end
|
|
|
|
game.map_settings.enemy_expansion.max_expansion_distance = max_expansion_distance
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local settler_group_min_size = math.ceil(storage.night_count / 6)
|
2021-03-24 17:46:00 +02:00
|
|
|
if settler_group_min_size > 20 then
|
|
|
|
settler_group_min_size = 20
|
|
|
|
end
|
|
|
|
game.map_settings.enemy_expansion.settler_group_min_size = settler_group_min_size
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local settler_group_max_size = math.ceil(storage.night_count / 3)
|
2021-03-24 17:46:00 +02:00
|
|
|
if settler_group_max_size > 50 then
|
|
|
|
settler_group_max_size = 50
|
|
|
|
end
|
|
|
|
game.map_settings.enemy_expansion.settler_group_max_size = settler_group_max_size
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local min_expansion_cooldown = 54000 - storage.night_count * 540
|
2021-03-24 17:46:00 +02:00
|
|
|
if min_expansion_cooldown < 3600 then
|
|
|
|
min_expansion_cooldown = 3600
|
|
|
|
end
|
|
|
|
game.map_settings.enemy_expansion.min_expansion_cooldown = min_expansion_cooldown
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local max_expansion_cooldown = 108000 - storage.night_count * 1080
|
2021-03-24 17:46:00 +02:00
|
|
|
if max_expansion_cooldown < 3600 then
|
|
|
|
max_expansion_cooldown = 3600
|
|
|
|
end
|
|
|
|
game.map_settings.enemy_expansion.max_expansion_cooldown = max_expansion_cooldown
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
game.print(nightfall_messages[math_random(1, #nightfall_messages)], { r = 150, g = 0, b = 0 })
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
2020-11-23 23:10:32 +02:00
|
|
|
local function generate_spawn_area(surface)
|
2021-03-24 17:46:00 +02:00
|
|
|
local entities = {}
|
|
|
|
local tiles = {}
|
|
|
|
local fort_size = 64
|
|
|
|
local fort_wall_width = 4
|
|
|
|
local turrets = {}
|
|
|
|
|
|
|
|
for x = -160, 160, 1 do
|
|
|
|
for y = -160, 160, 1 do
|
2024-09-24 19:37:11 +02:00
|
|
|
local pos = { x = x, y = y }
|
2021-03-24 17:46:00 +02:00
|
|
|
if pos.x > fort_size * -1 and pos.x < fort_size and pos.y > fort_size * -1 and pos.y < fort_size then
|
2024-01-28 21:42:28 +02:00
|
|
|
if pos.x > (fort_size - fort_wall_width) * -1 and pos.x < fort_size - fort_wall_width and pos.y > (fort_size - fort_wall_width) * -1 and pos.y < fort_size - fort_wall_width then
|
|
|
|
if pos.x <= (fort_size - fort_wall_width * 2) * -1 or pos.x >= (fort_size - fort_wall_width * 2) or pos.y <= (fort_size - fort_wall_width * 2) * -1 or pos.y >= (fort_size - fort_wall_width * 2) then
|
2024-09-24 19:37:11 +02:00
|
|
|
table.insert(turrets, { name = 'gun-turret', position = { x = pos.x, y = pos.y }, force = 'player' })
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
for _, entity in pairs(surface.find_entities_filtered({ area = { { pos.x, pos.y }, { pos.x + 0.99, pos.y + 0.99 } } })) do
|
2021-03-24 17:46:00 +02:00
|
|
|
if entity.name ~= 'character' then
|
|
|
|
entity.destroy()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
table.insert(tiles, { name = 'stone-path', position = { x = pos.x, y = pos.y } })
|
2021-03-24 17:46:00 +02:00
|
|
|
|
2024-01-28 21:42:28 +02:00
|
|
|
if pos.x <= (fort_size - fort_wall_width) * -1 or pos.x >= (fort_size - fort_wall_width) or pos.y <= (fort_size - fort_wall_width) * -1 or pos.y >= (fort_size - fort_wall_width) then
|
2021-03-24 17:46:00 +02:00
|
|
|
if math_random(1, 3) ~= 1 then
|
2024-09-24 19:37:11 +02:00
|
|
|
table.insert(entities, { name = 'stone-wall', position = { x = pos.x, y = pos.y }, force = 'player' })
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
surface.set_tiles(tiles, true)
|
|
|
|
|
|
|
|
for _, entity in pairs(entities) do
|
|
|
|
surface.create_entity(entity)
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local ore_positions = { { x = -16, y = -16 }, { x = 16, y = -16 }, { x = -16, y = 16 }, { x = 16, y = 16 } }
|
2021-03-24 17:46:00 +02:00
|
|
|
ore_positions = shuffle(ore_positions)
|
|
|
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[1], 'copper-ore', surface, 18, 2500)
|
|
|
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[2], 'iron-ore', surface, 18, 2500)
|
|
|
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[3], 'coal', surface, 18, 2500)
|
|
|
|
map_functions.draw_smoothed_out_ore_circle(ore_positions[4], 'stone', surface, 18, 2500)
|
|
|
|
|
|
|
|
local lake_size = 14
|
|
|
|
local lake_distance = fort_size - (lake_size + fort_wall_width)
|
|
|
|
local lake_positions = {
|
2024-09-24 19:37:11 +02:00
|
|
|
{ x = lake_distance * -1, y = lake_distance * -1 },
|
|
|
|
{ x = lake_distance, y = lake_distance * -1 },
|
|
|
|
{ x = lake_distance, y = lake_distance },
|
|
|
|
{ x = lake_distance * -1, y = lake_distance }
|
2021-03-24 17:46:00 +02:00
|
|
|
}
|
|
|
|
lake_positions = shuffle(lake_positions)
|
|
|
|
map_functions.draw_noise_tile_circle(lake_positions[1], 'water-green', surface, lake_size)
|
|
|
|
map_functions.draw_oil_circle(lake_positions[2], 'crude-oil', surface, 8, 200000)
|
|
|
|
|
|
|
|
turrets = shuffle(turrets)
|
|
|
|
local x = spawn_turret_amount
|
|
|
|
for _, entity in pairs(turrets) do
|
|
|
|
if surface.can_place_entity(entity) then
|
|
|
|
local turret = surface.create_entity(entity)
|
|
|
|
if math_random(1, 3) ~= 1 then
|
|
|
|
turret.health = turret.health - math_random(1, 250)
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
turret.insert({ name = 'firearm-magazine', count = math_random(4, 16) })
|
2021-03-24 17:46:00 +02:00
|
|
|
x = x - 1
|
|
|
|
if x == 0 then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.rocket_silo = surface.create_entity({ name = 'rocket-silo', position = { 0, 0 }, force = 'player' })
|
|
|
|
storage.rocket_silo.minable = false
|
2021-03-24 17:46:00 +02:00
|
|
|
|
|
|
|
local p = game.permissions.get_group('Default')
|
|
|
|
p.set_allows_action(defines.input_action.start_walking, true)
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
2020-11-23 23:10:32 +02:00
|
|
|
|
2018-12-31 02:55:18 +02:00
|
|
|
local function on_chunk_generated(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
local surface = game.surfaces['nightfall']
|
|
|
|
if event.surface.name ~= surface.name then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local left_top = event.area.left_top
|
|
|
|
local tiles = {}
|
|
|
|
|
|
|
|
if left_top.x > 160 then
|
2024-09-24 19:37:11 +02:00
|
|
|
if not storage.nightfall_spawn_generated then
|
2021-03-24 17:46:00 +02:00
|
|
|
generate_spawn_area(surface)
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.nightfall_spawn_generated = true
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local out_of_map_start = 63
|
|
|
|
|
|
|
|
for x = 0, 31, 1 do
|
|
|
|
for y = 0, 31, 1 do
|
2024-09-24 19:37:11 +02:00
|
|
|
local pos = { x = left_top.x + x, y = left_top.y + y }
|
2021-03-24 17:46:00 +02:00
|
|
|
|
|
|
|
local tile_to_insert = false
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.out_of_map_position == 1 then
|
2021-03-24 17:46:00 +02:00
|
|
|
if pos.x > out_of_map_start then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
if pos.y > out_of_map_start then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.out_of_map_position == 2 then
|
2021-03-24 17:46:00 +02:00
|
|
|
if pos.x < out_of_map_start * -1 then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
if pos.y < out_of_map_start * -1 then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.out_of_map_position == 3 then
|
2021-03-24 17:46:00 +02:00
|
|
|
if pos.x > out_of_map_start then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
if pos.y < out_of_map_start * -1 then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.out_of_map_position == 4 then
|
2021-03-24 17:46:00 +02:00
|
|
|
if pos.y > out_of_map_start then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
if pos.x < out_of_map_start * -1 then
|
|
|
|
tile_to_insert = 'out-of-map'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if tile_to_insert then
|
2024-09-24 19:37:11 +02:00
|
|
|
insert(tiles, { name = 'out-of-map', position = pos })
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if math_random(1, 2500) == 1 and tile_to_insert == false then
|
|
|
|
--if surface.can_place_entity({name = "big-ship-wreck-1", position = pos}) then
|
|
|
|
spawn_shipwreck(surface, pos)
|
2024-09-24 19:37:11 +02:00
|
|
|
--end
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if #tiles == 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
surface.set_tiles(tiles, true)
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
2020-11-23 23:10:32 +02:00
|
|
|
local function on_entity_damaged(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
if event.cause then
|
|
|
|
if event.cause.force.name == 'enemy' then
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.night_count then
|
|
|
|
event.entity.health = event.entity.health - (event.final_damage_amount * storage.night_count * 0.05)
|
2021-03-24 17:46:00 +02:00
|
|
|
if event.entity.health <= 0 then
|
|
|
|
event.entity.die()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if event.cause.force.name == 'enemy' then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if event.entity.valid then
|
2024-09-24 19:37:11 +02:00
|
|
|
if event.entity == storage.rocket_silo then
|
2021-03-24 17:46:00 +02:00
|
|
|
event.entity.health = event.entity.health + event.final_damage_amount
|
|
|
|
end
|
|
|
|
end
|
2018-12-31 04:47:53 +02:00
|
|
|
end
|
|
|
|
|
2018-12-31 02:55:18 +02:00
|
|
|
local function on_tick(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
if game.tick % 600 ~= 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local surface = game.surfaces['nightfall']
|
|
|
|
if surface.daytime > 0.25 and surface.daytime < 0.75 then
|
|
|
|
set_nighttime_modifiers(surface)
|
|
|
|
if surface.daytime < 0.65 then
|
|
|
|
send_attack_group(surface)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
set_daytime_modifiers(surface)
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.rocket_silo then
|
|
|
|
if storage.rocket_silo.valid then
|
2021-03-24 17:46:00 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if game.tick < 3600 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
if not storage.game_restart_timer then
|
|
|
|
storage.game_restart_timer = 7200
|
|
|
|
game.print('The Rocket Silo has fallen!', { r = 0.22, g = 0.88, b = 0.22 })
|
2021-03-24 17:46:00 +02:00
|
|
|
else
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.game_restart_timer < 0 then
|
2021-03-24 17:46:00 +02:00
|
|
|
return
|
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.game_restart_timer = storage.game_restart_timer - 600
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.game_restart_timer % 1800 == 0 then
|
|
|
|
if storage.game_restart_timer > 0 then
|
|
|
|
game.print('Map will restart in ' .. storage.game_restart_timer / 60 .. ' seconds!', { r = 0.22, g = 0.88, b = 0.22 })
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
2024-09-24 19:37:11 +02:00
|
|
|
if storage.game_restart_timer == 0 then
|
|
|
|
game.print('Map is restarting!', { r = 0.22, g = 0.88, b = 0.22 })
|
2021-03-24 17:46:00 +02:00
|
|
|
game.write_file('commandPipe', ':loadscenario --force', false, 0)
|
|
|
|
end
|
|
|
|
end
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function on_player_joined_game(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
local player = game.players[event.player_index]
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
if not storage.fish_defense_init_done then
|
2021-03-24 17:46:00 +02:00
|
|
|
local map_gen_settings = {}
|
|
|
|
map_gen_settings.water = 'small'
|
|
|
|
map_gen_settings.starting_area = 'very-small'
|
2024-09-24 19:37:11 +02:00
|
|
|
map_gen_settings.cliff_settings = { cliff_elevation_interval = 35, cliff_elevation_0 = 35 }
|
2021-03-24 17:46:00 +02:00
|
|
|
map_gen_settings.autoplace_controls = {
|
2024-09-24 19:37:11 +02:00
|
|
|
['coal'] = { frequency = 'high', size = 'very-big', richness = 'normal' },
|
|
|
|
['stone'] = { frequency = 'high', size = 'very-big', richness = 'normal' },
|
|
|
|
['copper-ore'] = { frequency = 'high', size = 'very-big', richness = 'normal' },
|
|
|
|
['iron-ore'] = { frequency = 'high', size = 'very-big', richness = 'normal' },
|
|
|
|
['crude-oil'] = { frequency = 'very-high', size = 'very-big', richness = 'normal' },
|
|
|
|
['trees'] = { frequency = 'normal', size = 'normal', richness = 'normal' },
|
|
|
|
['enemy-base'] = { frequency = 'very-high', size = 'big', richness = 'very-good' }
|
2021-03-24 17:46:00 +02:00
|
|
|
}
|
|
|
|
game.create_surface('nightfall', map_gen_settings)
|
|
|
|
local surface = game.surfaces['nightfall']
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.out_of_map_position = math_random(1, 4)
|
2021-03-24 17:46:00 +02:00
|
|
|
|
|
|
|
surface.ticks_per_day = surface.ticks_per_day * 2
|
|
|
|
|
|
|
|
local radius = 512
|
2024-09-24 19:37:11 +02:00
|
|
|
game.forces.player.chart(surface, { { x = -1 * radius, y = -1 * radius }, { x = radius, y = radius } })
|
2021-03-24 17:46:00 +02:00
|
|
|
|
|
|
|
game.map_settings.pollution.enabled = true
|
|
|
|
game.map_settings.enemy_evolution.enabled = true
|
|
|
|
game.map_settings.enemy_evolution.destroy_factor = 0.006
|
|
|
|
game.map_settings.enemy_evolution.time_factor = 0.00001
|
|
|
|
game.map_settings.enemy_evolution.pollution_factor = 0.00004
|
|
|
|
|
|
|
|
game.forces.player.set_ammo_damage_modifier('shotgun-shell', 1)
|
|
|
|
|
|
|
|
local p = game.permissions.get_group('Default')
|
|
|
|
p.set_allows_action(defines.input_action.start_walking, false)
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.fish_defense_init_done = true
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if player.online_time < 1 then
|
2024-09-24 19:37:11 +02:00
|
|
|
player.insert({ name = 'pistol', count = 1 })
|
|
|
|
player.insert({ name = 'raw-fish', count = 3 })
|
|
|
|
player.insert({ name = 'firearm-magazine', count = 32 })
|
|
|
|
player.insert({ name = 'iron-plate', count = 64 })
|
|
|
|
player.insert({ name = 'stone', count = 32 })
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local surface = game.surfaces['nightfall']
|
2024-09-24 19:37:11 +02:00
|
|
|
if player.online_time < 2 and surface.is_chunk_generated({ 0, 0 }) then
|
|
|
|
player.teleport(surface.find_non_colliding_position('character', { 0, 16 }, 50, 1), 'nightfall')
|
2021-03-24 17:46:00 +02:00
|
|
|
else
|
|
|
|
if player.online_time < 2 then
|
2024-09-24 19:37:11 +02:00
|
|
|
player.teleport({ 0, 16 }, 'nightfall')
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
create_time_gui(player)
|
2018-12-31 02:55:18 +02:00
|
|
|
end
|
|
|
|
|
2020-11-23 23:10:32 +02:00
|
|
|
local function on_research_finished(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
game.forces.player.recipes['flamethrower-turret'].enabled = false
|
2019-01-03 22:50:31 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
event.add(defines.events.on_research_finished, on_research_finished)
|
2018-12-31 04:47:53 +02:00
|
|
|
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
2018-12-31 02:55:18 +02:00
|
|
|
event.add(defines.events.on_tick, on_tick)
|
|
|
|
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
2020-11-23 23:10:32 +02:00
|
|
|
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|