1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-26 22:56:43 +02:00

nightfall

This commit is contained in:
MewMew 2018-12-31 15:39:09 +01:00
parent 75392deae4
commit e657fd9f9e
2 changed files with 278 additions and 55 deletions

View File

@ -6,48 +6,15 @@ local insert = table.insert
local map_functions = require "maps.tools.map_functions"
local simplex_noise = require 'utils.simplex_noise'
local simplex_noise = simplex_noise.d2
require "maps.nightfall_map_intro"
require "maps.modules.splice"
require "maps.modules.explosive_biters"
require "maps.modules.biters_yield_coins"
require "maps.modules.spawners_contain_biters"
require "maps.modules.railgun_enhancer"
require "maps.modules.dynamic_landfill"
local spawn_turret_amount = 8
local market_items = {
{price = {{"coin", 3}}, offer = {type = 'give-item', item = "raw-fish", count = 1}},
{price = {{"coin", 1}}, offer = {type = 'give-item', item = 'raw-wood', count = 4}},
{price = {{"coin", 8}}, offer = {type = 'give-item', item = 'grenade', count = 1}},
{price = {{"coin", 32}}, offer = {type = 'give-item', item = 'cluster-grenade', count = 1}},
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'land-mine', count = 1}},
{price = {{"coin", 80}}, offer = {type = 'give-item', item = 'car', count = 1}},
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'gun-turret', count = 1}},
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'firearm-magazine', count = 1}},
{price = {{"coin", 5}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine', count = 1}},
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'shotgun-shell', count = 1}},
{price = {{"coin", 6}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell', count = 1}},
{price = {{"coin", 35}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}},
{price = {{"coin", 250}}, offer = {type = 'give-item', item = 'combat-shotgun', count = 1}},
{price = {{"coin", 450}}, offer = {type = 'give-item', item = 'flamethrower', count = 1}},
{price = {{"coin", 25}}, offer = {type = 'give-item', item = 'flamethrower-ammo', count = 1}},
{price = {{"coin", 185}}, offer = {type = 'give-item', item = 'rocket-launcher', count = 1}},
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'rocket', count = 1}},
{price = {{"coin", 7}}, offer = {type = 'give-item', item = 'explosive-rocket', count = 1}},
{price = {{"coin", 7500}}, offer = {type = 'give-item', item = 'atomic-bomb', count = 1}},
{price = {{"coin", 325}}, offer = {type = 'give-item', item = 'railgun', count = 1}},
{price = {{"coin", 8}}, offer = {type = 'give-item', item = 'railgun-dart', count = 1}},
{price = {{"coin", 4}}, offer = {type = 'give-item', item = 'defender-capsule', count = 1}},
{price = {{"coin", 25}}, offer = {type = 'give-item', item = 'light-armor', count = 1}},
{price = {{"coin", 250}}, offer = {type = 'give-item', item = 'heavy-armor', count = 1}},
{price = {{"coin", 650}}, offer = {type = 'give-item', item = 'modular-armor', count = 1}},
{price = {{"coin", 2500}}, offer = {type = 'give-item', item = 'power-armor', count = 1}},
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'solar-panel-equipment', count = 1}},
{price = {{"coin", 275}}, offer = {type = 'give-item', item = 'belt-immunity-equipment', count = 1}},
{price = {{"coin", 250}}, offer = {type = 'give-item', item = 'personal-roboport-equipment', count = 1}},
{price = {{"coin", 20}}, offer = {type = 'give-item', item = 'construction-robot', count = 1}}
}
local function shuffle(tbl)
local size = #tbl
for i = size, 1, -1 do
@ -73,13 +40,185 @@ local function create_time_gui(player)
label.style.minimal_width = 50
end
local function spawn_shipwreck(surface, position)
local raffle = {}
local loot = {
{{name = "steel-axe", count = math_random(1,3)}, weight = 2, evolution_min = 0.0, evolution_max = 0.2},
{{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 = "computer", count = 1}, weight = 1, evolution_min = 0.2, evolution_max = 1},
{{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 = "filter-inserter", count = math_random(8,16)}, weight = 1, evolution_min = 0.2, evolution_max = 1},
{{name = "stack-filter-inserter", count = math_random(4,8)}, weight = 1, evolution_min = 0.4, evolution_max = 1},
{{name = "stack-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},
--{{name = "nuclear-reactor", count = 1}, weight = 2, evolution_min = 0.5, evolution_max = 1},
{{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 = "green-wire", count = math_random(50,100)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
{{name = "red-wire", count = math_random(50,100)}, 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},
--{{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},
{{name = "gun-turret", count = math_random(2,4)}, weight = 3, evolution_min = 0.2, evolution_max = 0.9}
}
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
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"}
for x = 1, math_random(2,3), 1 do
local loot = raffle[math_random(1,#raffle)]
e.insert(loot)
end
end
local function clear_corpses(surface)
for _, entity in pairs(surface.find_entities_filtered{type = "corpse"}) do
if math_random(1, 2) == 1 then
entity.destroy()
end
end
end
local function send_attack_group(surface)
local spawners = surface.find_entities_filtered({type = "unit-spawner"})
if not spawners[1] then return end
local spawner = spawners[math_random(1, #spawners)]
local biters = surface.find_enemy_units(spawner.position, 128, "player")
local biters = surface.find_enemy_units(spawner.position, 96, "player")
if not biters[1] then return end
biters = shuffle(biters)
@ -90,14 +229,14 @@ local function send_attack_group(surface)
local unit_group = surface.create_unit_group({position=pos, force="enemy"})
local group_size = 4 + (global.night_count * 4)
if group_size > 250 then group_size = 250 end
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
if global.market.valid then
if global.rocket_silo.valid then
unit_group.set_command({
type = defines.command.compound,
structure_type = defines.compound_command.return_last,
@ -110,7 +249,7 @@ local function send_attack_group(surface)
},
{
type = defines.command.attack,
target = global.market,
target = global.rocket_silo,
distraction = defines.distraction.by_enemy
}
}
@ -137,7 +276,9 @@ local function set_daytime_modifiers(surface)
game.map_settings.enemy_expansion.enabled = false
surface.peaceful_mode = true
game.print("Daytime!", {r = 255, g = 255, b = 50})
game.print("It´s daytime!", {r = 255, g = 255, b = 50})
clear_corpses(surface)
end
local function set_nighttime_modifiers(surface)
@ -148,9 +289,10 @@ local function set_nighttime_modifiers(surface)
global.splice_modifier = 1
else
global.night_count = global.night_count + 1
--if game.forces["enemy"].evolution_factor > 0.75 then
global.splice_modifier = global.splice_modifier + 0.25
--end
if game.forces["enemy"].evolution_factor > 0.25 then
global.splice_modifier = global.splice_modifier + 0.1
if global.splice_modifier > 16 then global.splice_modifier = 16 end
end
end
for _, player in pairs(game.connected_players) do
@ -234,7 +376,7 @@ local function generate_spawn_area(surface)
local lake_distance = fort_size - (lake_size + fort_wall_width)
local lake_positions = {{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}}
lake_positions = shuffle(lake_positions)
map_functions.draw_noise_tile_circle(lake_positions[1], "water", surface, lake_size)
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)
@ -251,11 +393,11 @@ local function generate_spawn_area(surface)
end
end
global.market = surface.create_entity({name = "market", position = {0, 0}, force = "player"})
global.market.minable = false
for _, item in pairs(market_items) do
global.market.add_market_item(item)
end
global.rocket_silo = surface.create_entity({name = "rocket-silo", position = {0, 0}, force = "player"})
global.rocket_silo.minable = false
local p = game.permissions.get_group("Default")
p.set_allows_action(defines.input_action.start_walking, true)
end
local function on_chunk_generated(event)
@ -268,6 +410,17 @@ local function on_chunk_generated(event)
if not global.nightfall_spawn_generated then
generate_spawn_area(surface)
global.nightfall_spawn_generated = true
end
end
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local pos = {x = left_top.x + x, y = left_top.y + y}
if math_random(1, 2048) == 1 then
--if surface.can_place_entity({name = "big-ship-wreck-1", position = pos}) then
spawn_shipwreck(surface, pos)
--end
end
end
end
end
@ -277,7 +430,7 @@ local function on_entity_damaged(event)
if event.cause.force.name == "enemy" then return end
end
if event.entity.valid then
if event.entity.name == "market" then
if event.entity == global.rocket_silo then
event.entity.health = event.entity.health + event.final_damage_amount
end
end
@ -295,15 +448,15 @@ local function on_tick(event)
set_daytime_modifiers(surface)
end
if global.market then
if global.market.valid then return end
if global.rocket_silo then
if global.rocket_silo.valid then return end
end
if game.tick < 3600 then return end
if not global.game_restart_timer then
global.game_restart_timer = 7200
game.print("The market has fallen!", {r=0.22, g=0.88, b=0.22})
game.print("The Rocket Silo was destroyed!", {r=0.22, g=0.88, b=0.22})
else
if global.game_restart_timer < 0 then return end
global.game_restart_timer = global.game_restart_timer - 600
@ -323,7 +476,7 @@ local function on_player_joined_game(event)
if not global.fish_defense_init_done then
local map_gen_settings = {}
map_gen_settings.water = "small"
map_gen_settings.starting_area = "small"
map_gen_settings.starting_area = "very-small"
map_gen_settings.cliff_settings = {cliff_elevation_interval = 35, cliff_elevation_0 = 35}
map_gen_settings.autoplace_controls = {
["coal"] = {frequency = "high", size = "very-big", richness = "normal"},
@ -332,7 +485,7 @@ local function on_player_joined_game(event)
["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 = "normal", size = "normal", richness = "very-good"},
["enemy-base"] = {frequency = "very-high", size = "big", richness = "very-good"},
["grass"] = {frequency = "normal", size = "normal", richness = "normal"},
["sand"] = {frequency = "normal", size = "normal", richness = "normal"},
["desert"] = {frequency = "normal", size = "normal", richness = "normal"},
@ -348,7 +501,10 @@ local function on_player_joined_game(event)
--game.map_settings.enemy_evolution.time_factor = 0
--game.map_settings.enemy_evolution.pollution_factor = 0
game.forces.player.set_ammo_damage_modifier("shotgun-shell", 1)
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)
global.fish_defense_init_done = true
end

View File

@ -0,0 +1,67 @@
local event = require 'utils.event'
local main_caption = " --Nightfall-- "
local sub_caption = "*something is lurking in the dark*"
local info = [[
They come out at night.
Trying to nom your rocket silo.
Maybe they just like the taste of the alloys, who knows.
Fend them off as long as possible!
There seem to be shipwrecks of misfortunate explorers all over this place.
It might be worth scavenging a few.
The wreck loot quality increases with distance.
]]
local function create_map_intro(player)
if player.gui.left["map_intro_frame"] then player.gui.left["map_intro_frame"].destroy() end
local frame = player.gui.left.add {type = "frame", name = "map_intro_frame", direction = "vertical"}
local t = frame.add {type = "table", column_count = 1}
local tt = t.add {type = "table", column_count = 3}
local l = tt.add {type = "label", caption = main_caption}
l.style.font = "default-frame"
l.style.font_color = {r=0.85, g=0.0, b=0.25}
l.style.top_padding = 6
l.style.bottom_padding = 6
local l = tt.add {type = "label", caption = sub_caption}
l.style.font = "default"
l.style.font_color = {r=0.1, g=0.65, b=0.1}
l.style.minimal_width = 280
local b = tt.add {type = "button", caption = "X", name = "close_map_intro_frame", align = "right"}
b.style.font = "default"
b.style.minimal_height = 30
b.style.minimal_width = 30
b.style.top_padding = 2
b.style.left_padding = 4
b.style.right_padding = 4
b.style.bottom_padding = 2
local tt = t.add {type = "table", column_count = 1}
local frame = t.add {type = "frame"}
local l = frame.add {type = "label", caption = info}
l.style.single_line = false
l.style.font_color = {r=0.95, g=0.95, b=0.95}
end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
if player.online_time < 36000 then
create_map_intro(player)
end
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 == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() end
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_gui_click, on_gui_click)