From 412035e4c131ebbda03a434b3216210bcbdf582e Mon Sep 17 00:00:00 2001 From: MewMew <=> Date: Fri, 8 Mar 2019 23:47:38 +0100 Subject: [PATCH] junkyard > dangerous_nights module --- functions/unearthing_biters.lua | 6 ++-- functions/unearthing_worm.lua | 2 +- maps/junkyard.lua | 6 +++- maps/modules/dangerous_nights.lua | 48 +++++++++++++++++++++++++++++++ maps/tools/cheat_mode.lua | 4 +-- 5 files changed, 59 insertions(+), 7 deletions(-) diff --git a/functions/unearthing_biters.lua b/functions/unearthing_biters.lua index a92d1c29..82168058 100644 --- a/functions/unearthing_biters.lua +++ b/functions/unearthing_biters.lua @@ -55,16 +55,16 @@ local function unearthing_biters(surface, position, amount) if evolution_index < 1 then evolution_index = 1 end local ticks = amount * 30 - ticks = ticks + 120 + ticks = ticks + 90 for t = 1, ticks, 1 do if not global.on_tick_schedule[game.tick + t] then global.on_tick_schedule[game.tick + t] = {} end global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = { func = create_particles, - args = {surface, {x = position.x, y = position.y}, 5} + args = {surface, {x = position.x, y = position.y}, 4} } - if t > 120 then + if t > 90 then if t % 30 == 29 then global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = { func = spawn_biter, diff --git a/functions/unearthing_worm.lua b/functions/unearthing_worm.lua index 186f873f..320ddcf7 100644 --- a/functions/unearthing_worm.lua +++ b/functions/unearthing_worm.lua @@ -47,7 +47,7 @@ local function unearthing_worm(surface, position) global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = { func = create_particles, - args = {surface, {x = position.x, y = position.y}, math.ceil(t * 0.07)} + args = {surface, {x = position.x, y = position.y}, math.ceil(t * 0.05)} } if t == 330 then diff --git a/maps/junkyard.lua b/maps/junkyard.lua index 557309c1..a5fe0996 100644 --- a/maps/junkyard.lua +++ b/maps/junkyard.lua @@ -7,6 +7,7 @@ require "maps.modules.spawners_contain_biters" require "maps.modules.biters_yield_coins" require "maps.modules.fluids_are_explosive" require "maps.modules.explosives_are_explosive" +require "maps.modules.dangerous_nights" local unearthing_worm = require "functions.unearthing_worm" local unearthing_biters = require "functions.unearthing_biters" @@ -406,7 +407,10 @@ local function on_player_joined_game(event) player.insert({name = "firearm-magazine", count = 16}) end - if global.map_init_done then return end + if global.map_init_done then return end + + game.forces["player"].technologies["optics"].researched = true + game.surfaces["nauvis"].ticks_per_day = game.surfaces["nauvis"].ticks_per_day * 2 game.create_force("scrap") diff --git a/maps/modules/dangerous_nights.lua b/maps/modules/dangerous_nights.lua index e69de29b..9b3e484d 100644 --- a/maps/modules/dangerous_nights.lua +++ b/maps/modules/dangerous_nights.lua @@ -0,0 +1,48 @@ +-- nighttime is dangerous, stay near your lamps -- by mewmew + +local event = require 'utils.event' + +local unearthing_worm = require "functions.unearthing_worm" +local unearthing_biters = require "functions.unearthing_biters" + +local function on_player_changed_position(event) + local player = game.players[event.player_index] + if player.character.driving == true then return end + if player.surface.daytime < 0.33 then return end + if player.surface.daytime > 0.66 then return end + if math.random(1,32) ~= 1 then return end + + for _, lamp in pairs(player.surface.find_entities_filtered({area={{player.position.x - 18, player.position.y - 18},{player.position.x + 18, player.position.y + 18}}, name="small-lamp"})) do + local circuit = lamp.get_or_create_control_behavior() + if circuit then + if lamp.energy > 40 and circuit.disabled == false then + return + end + else + if lamp.energy > 40 then + return + end + end + end + + local positions = {} + local r = 8 + for x = r * -1, r, 1 do + for y = r * -1, r, 1 do + local distance_to_center = math.sqrt(x^2 + x^2) + if distance_to_center > 2 and distance_to_center < 7 then + if player.surface.can_place_entity({name = "stone-furnace", position = {x = player.position.x + x, y = player.position.y + y}}) then + positions[#positions + 1] = {x = player.position.x + x, y = player.position.y + y} + end + end + end + end + + if math.random(1,3) == 1 then + unearthing_biters(player.surface, positions[math.random(1, #positions)], math.random(3,9)) + else + unearthing_worm(player.surface, positions[math.random(1, #positions)]) + end +end + +event.add(defines.events.on_player_changed_position, on_player_changed_position) diff --git a/maps/tools/cheat_mode.lua b/maps/tools/cheat_mode.lua index 43644654..a5c65d7d 100644 --- a/maps/tools/cheat_mode.lua +++ b/maps/tools/cheat_mode.lua @@ -22,9 +22,9 @@ function cheat_mode() game.forces.player.character_reach_distance_bonus = 1000 game.speed = 1.5 surface.daytime = 1 - surface.freeze_daytime = 1 + --surface.freeze_daytime = 1 game.player.force.research_all_technologies() - game.forces["enemy"].evolution_factor = 0.9 + game.forces["enemy"].evolution_factor = 0.1 local chart = 200 game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}}) end \ No newline at end of file