1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-07-15 01:04:17 +02:00

Move folders to utils

This commit is contained in:
Gerkiz
2024-01-28 20:42:28 +01:00
parent 4de16c2bab
commit a8538ebd67
105 changed files with 4052 additions and 3770 deletions

View File

@ -251,14 +251,14 @@ require 'utils.remote_chunks'
---------------------------------------------------------------
---------------- MOSTLY TERRAIN LAYOUTS HERE ----------------
--require 'terrain_layouts.winter'
--require 'terrain_layouts.caves'
--require 'terrain_layouts.cone_to_east'
--require 'terrain_layouts.biters_and_resources_east'
--require 'terrain_layouts.scrap_01'
--require 'terrain_layouts.scrap_02'
--require 'terrain_layouts.watery_world'
--require 'terrain_layouts.tree_01'
--require 'utils.terrain_layouts.winter'
--require 'utils.terrain_layouts.caves'
--require 'utils.terrain_layouts.cone_to_east'
--require 'utils.terrain_layouts.biters_and_resources_east'
--require 'utils.terrain_layouts.scrap_01'
--require 'utils.terrain_layouts.scrap_02'
--require 'utils.terrain_layouts.watery_world'
--require 'utils.terrain_layouts.tree_01'
---------------------------------------------------------------
--- this file exists only for the panel to sync and start from within the panel

View File

@ -6,7 +6,7 @@ require 'modules.dynamic_player_spawn'
local Event = require 'utils.event'
local math_random = math.random
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local function on_player_joined_game(event)
local player = game.players[event.player_index]

View File

@ -1,5 +1,5 @@
--luacheck:ignore
local simplex_noise = require 'tools.simplex_noise'
local simplex_noise = require 'utils.tools.simplex_noise'
local Event = require 'utils.event'
biter_battles_terrain = {}
@ -471,10 +471,7 @@ function biter_battles_terrain.generate_spawn_ores(ore_layout)
end
end
surface.set_tiles(tiles, true)
local entities =
surface.find_entities(
{{(rocket_silo.position.x - 4) - size / 2, (rocket_silo.position.y - 5) - size / 2}, {rocket_silo.position.x + 4 + size / 2, rocket_silo.position.y + 5 + size / 2}}
)
local entities = surface.find_entities({{(rocket_silo.position.x - 4) - size / 2, (rocket_silo.position.y - 5) - size / 2}, {rocket_silo.position.x + 4 + size / 2, rocket_silo.position.y + 5 + size / 2}})
for _, entity in pairs(entities) do
if entity.type == 'simple-entity' or entity.type == 'tree' or entity.type == 'resource' then
entity.destroy()

View File

@ -1,7 +1,7 @@
--luacheck: ignore
local Public = {}
local LootRaffle = require 'functions.loot_raffle'
local BiterRaffle = require 'functions.biter_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local bb_config = require 'maps.biter_battles_v2.config'
local table_insert = table.insert
@ -646,9 +646,7 @@ function Public.generate_silo(surface)
for _, t in pairs(surface.find_tiles_filtered({area = {{pos.x - 6, pos.y - 6}, {pos.x + 6, pos.y + 6}}, name = {'water', 'deepwater'}})) do
surface.set_tiles({{name = get_replacement_tile(surface, t.position), position = t.position}})
end
for _, t in pairs(
surface.find_tiles_filtered({area = {{mirror_position.x - 6, mirror_position.y - 6}, {mirror_position.x + 6, mirror_position.y + 6}}, name = {'water', 'deepwater'}})
) do
for _, t in pairs(surface.find_tiles_filtered({area = {{mirror_position.x - 6, mirror_position.y - 6}, {mirror_position.x + 6, mirror_position.y + 6}}, name = {'water', 'deepwater'}})) do
surface.set_tiles({{name = get_replacement_tile(surface, t.position), position = t.position}})
end

View File

@ -4,12 +4,12 @@
require 'modules.dynamic_landfill'
require 'modules.satellite_score'
require 'modules.spawners_contain_biters'
require 'functions.create_entity_chain'
require 'functions.create_tile_chain'
require 'utils.functions.create_entity_chain'
require 'utils.functions.create_tile_chain'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local tick_tack_trap = require 'functions.tick_tack_trap'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local Module = require 'infinity_chest'
local Simplex = require 'utils.simplex_noise'.d2
local Event = require 'utils.event'

View File

@ -3,8 +3,8 @@ local Public = {}
local GetNoise = require 'utils.get_noise'
local Constants = require 'maps.cave_miner_v2.constants'
local BiterRaffle = require 'functions.biter_raffle'
local LootRaffle = require 'functions.loot_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local Esq = require 'modules.entity_spawn_queue'
local Pets = require 'modules.biter_pets'

View File

@ -3,7 +3,7 @@ local Public = {}
local Constants = require 'maps.cave_miner_v2.constants'
local Functions = require 'maps.cave_miner_v2.functions'
local LootRaffle = require 'functions.loot_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local math_floor = math.floor
local math_random = math.random

View File

@ -5,17 +5,17 @@ require 'modules.dynamic_landfill'
require 'modules.satellite_score'
require 'modules.spawners_contain_biters'
local Map = require 'modules.map_info'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local tick_tack_trap = require 'functions.tick_tack_trap'
local create_entity_chain = require 'functions.create_entity_chain'
local create_tile_chain = require 'functions.create_tile_chain'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local create_entity_chain = require 'utils.functions.create_entity_chain'
local create_tile_chain = require 'utils.functions.create_tile_chain'
local simplex_noise = require 'utils.simplex_noise'.d2
local event = require 'utils.event'
local table_insert = table.insert
local math_random = math.random
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local disabled_for_deconstruction = {
['fish'] = true,
@ -164,9 +164,7 @@ local function process_tile(surface, pos, tile, seed)
surface.create_entity({name = 'tree-01', position = pos})
end
end
surface.create_decoratives(
{check_collision = false, decoratives = {{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}}
)
surface.create_decoratives({check_collision = false, decoratives = {{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}})
return
end
@ -180,9 +178,7 @@ local function process_tile(surface, pos, tile, seed)
surface.create_entity({name = 'tree-02-red', position = pos})
end
end
surface.create_decoratives(
{check_collision = false, decoratives = {{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}}
)
surface.create_decoratives({check_collision = false, decoratives = {{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}})
return
end
@ -387,11 +383,7 @@ local function on_entity_died(event)
return
end
if event.entity.type == 'tree' then
for _, entity in pairs(
event.entity.surface.find_entities_filtered(
{area = {{event.entity.position.x - 4, event.entity.position.y - 4}, {event.entity.position.x + 4, event.entity.position.y + 4}}, name = 'fire-flame-on-tree'}
)
) do
for _, entity in pairs(event.entity.surface.find_entities_filtered({area = {{event.entity.position.x - 4, event.entity.position.y - 4}, {event.entity.position.x + 4, event.entity.position.y + 4}}, name = 'fire-flame-on-tree'})) do
if entity.valid then
entity.destroy()
end

View File

@ -4,17 +4,17 @@
require 'modules.satellite_score'
require 'modules.spawners_contain_biters'
require 'functions.create_entity_chain'
require 'functions.create_tile_chain'
require 'tools.map_functions'
require 'utils.functions.create_entity_chain'
require 'utils.functions.create_tile_chain'
require 'utils.tools.map_functions'
require 'modules.surrounded_by_worms'
require 'modules.biter_noms_you'
local Map = require 'modules.map_info'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local tick_tack_trap = require 'functions.tick_tack_trap'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local simplex_noise = require 'utils.simplex_noise'.d2
local Event = require 'utils.event'

View File

@ -5,9 +5,9 @@ local Chrono = require 'maps.chronosphere.chrono'
local Upgrades = require 'maps.chronosphere.upgrades'
local Public = {}
local tick_tack_trap = require 'functions.tick_tack_trap'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local math_random = math.random
local math_floor = math.floor
@ -162,10 +162,7 @@ function Public.shred_simple_entities(entity)
if game.forces.enemy.evolution_factor < 0.25 then
return
end
local simple_entities =
entity.surface.find_entities_filtered(
{type = {'simple-entity', 'tree'}, area = {{entity.position.x - 3, entity.position.y - 3}, {entity.position.x + 3, entity.position.y + 3}}}
)
local simple_entities = entity.surface.find_entities_filtered({type = {'simple-entity', 'tree'}, area = {{entity.position.x - 3, entity.position.y - 3}, {entity.position.x + 3, entity.position.y + 3}}})
for _, simple_entity in pairs(simple_entities) do
if simple_entity.valid then
simple_entity.destroy()
@ -447,10 +444,7 @@ end
function Public.check_if_overstayed()
local objective = Chrono_table.get_table()
if
objective.passivetimer * objective.passive_chronocharge_rate > (objective.chronochargesneeded * 0.75) and
objective.chronojumps >= Balance.jumps_until_overstay_is_on(Difficulty.get().difficulty_vote_value)
then
if objective.passivetimer * objective.passive_chronocharge_rate > (objective.chronochargesneeded * 0.75) and objective.chronojumps >= Balance.jumps_until_overstay_is_on(Difficulty.get().difficulty_vote_value) then
objective.overstaycount = objective.overstaycount + 1
end
end

View File

@ -19,7 +19,7 @@ local Locomotive = require 'maps.chronosphere.locomotive'
local Map = require 'modules.map_info'
local Minimap = require 'maps.chronosphere.minimap'
local On_Event = require 'maps.chronosphere.on_event'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Tick_functions = require 'maps.chronosphere.tick_functions'
local Upgrades = require 'maps.chronosphere.upgrades'
local Worlds = require 'maps.chronosphere.world_list'
@ -92,12 +92,7 @@ local function chronojump(choice)
end
if objective.chronojumps <= 24 then
Locomotive.award_coins(
Balance.coin_reward_per_second_jumped_early(
objective.chronochargesneeded / objective.passive_chronocharge_rate + 180 - objective.passivetimer,
Difficulty.get().difficulty_vote_value
)
)
Locomotive.award_coins(Balance.coin_reward_per_second_jumped_early(objective.chronochargesneeded / objective.passive_chronocharge_rate + 180 - objective.passivetimer, Difficulty.get().difficulty_vote_value))
end
Chrono.process_jump()

View File

@ -14,7 +14,7 @@ local Session = require 'utils.datastore.session_data'
local Difficulty = require 'modules.difficulty_vote'
local Map = require 'modules.map_info'
local Event = require 'utils.event'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Server = require 'utils.server'
local Poll = require 'utils.gui.poll'
local boss_biter = require 'maps.crab_defender.boss_biters'

View File

@ -1,6 +1,6 @@
local Event = require 'utils.event'
local Builder = require 'maps.crab_defender.b'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local FDT = require 'maps.crab_defender.table'
local math_random = math.random

View File

@ -12,7 +12,7 @@ local math_floor = math.floor
local math_abs = math.abs
local math_sqrt = math.sqrt
local LootRaffle = require 'functions.loot_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local function get_noise(name, pos)
local seed = game.surfaces[1].map_gen_settings.seed

View File

@ -1,7 +1,7 @@
-- crossing -- by mewmew --
local Event = require 'utils.event'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local function on_player_joined_game(event)

View File

@ -6,7 +6,7 @@ require 'modules.flashlight_toggle_button'
require 'maps.deep_jungle.generate'
local Event = require 'utils.event'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local Task = require 'utils.task'
local DPT = require 'maps.deep_jungle.table'
local random = math.random

View File

@ -1,5 +1,5 @@
local Functions = require 'maps.dungeons.functions'
local BiterRaffle = require 'functions.biter_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table

View File

@ -1,5 +1,5 @@
local Functions = require 'maps.dungeons.functions'
local BiterRaffle = require 'functions.biter_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table

View File

@ -7,8 +7,8 @@ local LOOT_EVOLUTION_SCALE_FACTOR = 0.9
local LOOT_MULTIPLIER = 3000
local EVOLUTION_PER_FLOOR = 0.06
local BiterRaffle = require 'functions.biter_raffle'
local LootRaffle = require 'functions.loot_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local Get_noise = require 'utils.get_noise'
local DungeonsTable = require 'maps.dungeons.table'
@ -22,7 +22,8 @@ local math_floor = math.floor
-- floor 4 = 8512 .. 9024
-- floor 9 = 16512 .. 17024
-- floor 19 = 32512 .. 33024
LootRaffle.TweakItemWorth({
LootRaffle.TweakItemWorth(
{
['modular-armor'] = 512, -- floors 1-5 from research.lua
['power-armor'] = 4096, -- floors 8-13 from research.lua
['personal-laser-defense-equipment'] = 1536, -- floors 10-14 from research.lua
@ -42,8 +43,9 @@ LootRaffle.TweakItemWorth({
['slowdown-capsule'] = 32,
['defender-capsule'] = 96,
['distractor-capsule'] = 512,
['destroyer-capsule'] = 2048,
})
['destroyer-capsule'] = 2048
}
)
function Public.get_dungeon_evolution_factor(surface_index)
local dungeontable = DungeonsTable.get_dungeontable()
@ -146,7 +148,7 @@ function Public.get_common_resource_amount(surface_index)
local floor = surface_index - dungeontable.original_surface_index
-- rocks stop going up here, so more than make up for it in resources on ground
if floor > FLOOR_FOR_MAX_ROCK_ORE then
amount = amount * (1+(floor - FLOOR_FOR_MAX_ROCK_ORE)/10)
amount = amount * (1 + (floor - FLOOR_FOR_MAX_ROCK_ORE) / 10)
end
end
return amount
@ -470,7 +472,7 @@ function Public.rocky_loot(event)
local player = game.players[event.player_index]
local amount = math.ceil(get_ore_amount(player.surface.index))
local rock_mining
local floor = player.surface.index - DungeonsTable.get_dungeontable().original_surface_index;
local floor = player.surface.index - DungeonsTable.get_dungeontable().original_surface_index
if floor < 10 then
-- early game science uses less copper and more iron/stone
rock_mining = {'iron-ore', 'iron-ore', 'iron-ore', 'iron-ore', 'copper-ore', 'copper-ore', 'stone', 'stone', 'coal', 'coal', 'coal'}

View File

@ -4,10 +4,10 @@ require 'modules.mineable_wreckage_yields_scrap'
require 'modules.satellite_score'
local MapInfo = require 'modules.map_info'
local Room_generator = require 'functions.room_generator'
local Room_generator = require 'utils.functions.room_generator'
require 'modules.rpg'
local BiterHealthBooster = require 'modules.biter_health_booster'
local BiterRaffle = require 'functions.biter_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local Functions = require 'maps.dungeons.functions'
local Get_noise = require 'utils.get_noise'
local DungeonsTable = require 'maps.dungeons.table'

View File

@ -8,10 +8,10 @@ require 'modules.charging_station'
local MIN_ROOMS_TO_DESCEND = 100
local MapInfo = require 'modules.map_info'
local Room_generator = require 'functions.room_generator'
local Room_generator = require 'utils.functions.room_generator'
local RPG = require 'modules.rpg.main'
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
local BiterRaffle = require 'functions.biter_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local Functions = require 'maps.dungeons.functions'
local Get_noise = require 'utils.get_noise'
local Alert = require 'utils.alert'
@ -53,7 +53,7 @@ local function enable_hard_rooms(position, surface_index)
if floor_mindist < 80 then -- all dirtlands within this
return true
end
return position.x ^ 2 + position.y ^ 2 > floor_mindist^2
return position.x ^ 2 + position.y ^ 2 > floor_mindist ^ 2
end
local function get_biome(position, surface_index)
@ -558,7 +558,7 @@ local function descend(player, button, shift)
end
local surface = game.surfaces[player.surface.index + 1]
if not surface then
if dungeontable.surface_size[player.surface.index] < 200 + MIN_ROOMS_TO_DESCEND/4 then
if dungeontable.surface_size[player.surface.index] < 200 + MIN_ROOMS_TO_DESCEND / 4 then
player.print({'dungeons_tiered.floor_size_required', MIN_ROOMS_TO_DESCEND})
return
end
@ -850,9 +850,13 @@ Event.add(defines.events.on_gui_click, on_gui_click)
Event.add(defines.events.on_player_changed_surface, on_player_changed_surface)
Event.add(defines.events.on_player_respawned, on_player_respawned)
Changelog.SetVersions({
{ ver = 'next', date = 'the future', desc = 'Make suggestions in the comfy #dungeons discord channel' },
{ ver = '1.1.1', date = '2022-04-10', desc = [[
Changelog.SetVersions(
{
{ver = 'next', date = 'the future', desc = 'Make suggestions in the comfy #dungeons discord channel'},
{
ver = '1.1.1',
date = '2022-04-10',
desc = [[
Balancing patch
* Evolution goes up faster with floor level 0.05/level -> 0.06/level; e.g. floor 20 now like floor 24 before
* Now require 100 open rooms to descend
@ -869,8 +873,12 @@ Balancing patch
* Require getting to room 100 before you can descend
* Science from rooms 40-160+2.5*floor to 60-300+2.5*floor
* Atomic bomb research moved to 40-50
]]},
{ ver = '1.1', date = '2022-03-13', desc = [[
]]
},
{
ver = '1.1',
date = '2022-03-13',
desc = [[
* All research is now found at random.
* Red science floors 0-1
* Green on floors 1-5
@ -891,6 +899,8 @@ Balancing patch
* Autostash and corpse clearing from Mountain Fortress enabled
* Harder rooms will occur somewhat farther out on the early floors.
* Spawners and worm counts bounded in early rooms.
]]},
{ ver = '1.0', date = 'past', desc = "Pre-changelog version of multi-floor dungeons" },
})
]]
},
{ver = '1.0', date = 'past', desc = 'Pre-changelog version of multi-floor dungeons'}
}
)

View File

@ -1,5 +1,5 @@
local Price_raffle = require 'maps.expanse.price_raffle'
local BiterRaffle = require 'functions.biter_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local Task = require 'utils.task'
local Token = require 'utils.token'
local Public = {}
@ -142,7 +142,8 @@ local function is_container_position_valid(expanse, position)
end
local function create_costs_render(entity, name, offset)
local id = rendering.draw_sprite{
local id =
rendering.draw_sprite {
sprite = 'virtual-signal/signal-grey',
surface = entity.surface,
target = entity,
@ -152,8 +153,9 @@ local function create_costs_render(entity, name, offset)
target_offset = {offset, -1.5},
only_in_alt_mode = true
}
local id2 = rendering.draw_sprite{
sprite = 'item/' ..name,
local id2 =
rendering.draw_sprite {
sprite = 'item/' .. name,
surface = entity.surface,
target = entity,
x_scale = 0.75,
@ -185,7 +187,7 @@ function Public.spawn_units(spawner)
local position = spawner.position
for i = 1, 4 + math.floor(8 * evolution), 1 do
local biter_roll = BiterRaffle.roll('mixed', evolution)
local free_pos = spawner.surface.find_non_colliding_position(biter_roll, {x = position.x + math.random(-8,8), y = position.y + math.random(-8,8)}, 12, 0.05)
local free_pos = spawner.surface.find_non_colliding_position(biter_roll, {x = position.x + math.random(-8, 8), y = position.y + math.random(-8, 8)}, 12, 0.05)
spawner.surface.create_entity({name = biter_roll, position = free_pos or position, force = 'enemy'})
end
end
@ -207,13 +209,13 @@ end
function Public.invasion_detonate(event)
local surface = event.surface
local position = event.position
local entities_close = surface.find_entities_filtered{position = position, radius = 8}
local entities_close = surface.find_entities_filtered {position = position, radius = 8}
for _, entity in pairs(entities_close) do
if entity.valid then
entity.die('enemy')
end
end
local entities_nearby = surface.find_entities_filtered{position = position, radius = 16}
local entities_nearby = surface.find_entities_filtered {position = position, radius = 16}
for _, entity in pairs(entities_nearby) do
if entity.valid and entity.is_entity_with_health then
entity.damage(entity.prototype.max_health * 0.75, 'enemy')
@ -230,10 +232,10 @@ function Public.invasion_trigger(event)
local biters = {}
for i = 1, 5 + math.floor(30 * evolution) + round * 5, 1 do
local biter_roll = BiterRaffle.roll('mixed', evolution)
local free_pos = surface.find_non_colliding_position(biter_roll, {x = position.x + math.random(-8,8), y = position.y + math.random(-8,8)}, 12, 0.05)
local free_pos = surface.find_non_colliding_position(biter_roll, {x = position.x + math.random(-8, 8), y = position.y + math.random(-8, 8)}, 12, 0.05)
biters[#biters + 1] = surface.create_entity({name = biter_roll, position = free_pos or position, force = 'enemy'})
end
local group = surface.create_unit_group{position = position, force = 'enemy'}
local group = surface.create_unit_group {position = position, force = 'enemy'}
for _, biter in pairs(biters) do
group.add_member(biter)
end
@ -241,7 +243,7 @@ function Public.invasion_trigger(event)
group.start_moving()
local worm_roll = BiterRaffle.roll('worm', evolution)
for i = 1, 3 + math.floor(7 * evolution), 1 do
local worm_pos = surface.find_non_colliding_position(worm_roll, {x = position.x + math.random(-12,12), y = position.y + math.random(-12,12)}, 12, 0.1)
local worm_pos = surface.find_non_colliding_position(worm_roll, {x = position.x + math.random(-12, 12), y = position.y + math.random(-12, 12)}, 12, 0.1)
if worm_pos then
surface.create_entity({name = worm_roll, position = worm_pos, force = 'enemy'})
end

View File

@ -19,7 +19,7 @@ local Session = require 'utils.datastore.session_data'
local Difficulty = require 'modules.difficulty_vote'
local Map = require 'modules.map_info'
local Event = require 'utils.event'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Server = require 'utils.server'
local Poll = require 'utils.gui.poll'
local boss_biter = require 'maps.fish_defender.boss_biters'

View File

@ -1,6 +1,6 @@
--luacheck: ignore
local Event = require 'utils.event'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local FDT = require 'maps.fish_defender.table'
local math_random = math.random

View File

@ -18,8 +18,8 @@ local event = require 'utils.event'
local Server = require 'utils.server'
local boss_biter = require 'maps.fish_defender.boss_biters'
local Score = require 'utils.gui.score'
require 'functions.boss_unit'
local map_functions = require 'tools.map_functions'
require 'utils.functions.boss_unit'
local map_functions = require 'utils.tools.map_functions'
local Difficulty = require 'modules.difficulty_vote'
local math_random = math.random
local insert = table.insert

View File

@ -12,7 +12,7 @@ local Unit_health_booster = require 'modules.biter_health_booster_v2'
local Difficulty = require 'modules.difficulty_vote'
local Map = require 'modules.map_info'
local Event = require 'utils.event'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Server = require 'utils.server'
local Session = require 'utils.datastore.session_data'
local Poll = require 'utils.gui.poll'

View File

@ -1,5 +1,5 @@
local Event = require 'utils.event'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local Public = require 'maps.fish_defender_v2.table'
local Task = require 'utils.task'

View File

@ -7,7 +7,7 @@ require 'modules.no_deconstruction_of_neutral_entities'
require 'modules.spawners_contain_biters'
local event = require 'utils.event'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local math_random = math.random
@ -358,12 +358,7 @@ local function draw_ores(surface, position)
end
local function draw_water(surface, position)
map_functions.draw_noise_tile_circle(
{x = position.x + labyrinth_cell_size * 0.5, y = position.y + labyrinth_cell_size * 0.5},
'water',
surface,
math.floor(labyrinth_cell_size * 0.3)
)
map_functions.draw_noise_tile_circle({x = position.x + labyrinth_cell_size * 0.5, y = position.y + labyrinth_cell_size * 0.5}, 'water', surface, math.floor(labyrinth_cell_size * 0.3))
for _, tile in pairs(surface.find_tiles_filtered({name = 'water', area = {{position.x, position.y}, {position.x + labyrinth_cell_size, position.y + labyrinth_cell_size}}})) do
if math_random(1, 12) == 1 then
surface.create_entity({name = 'fish', position = tile.position})
@ -406,21 +401,13 @@ end
local function draw_rocks(surface, position)
local r = math_random(0, 100)
if r < 50 then
surface.create_entity(
{name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.5, y = position.y + labyrinth_cell_size * 0.5}}
)
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.5, y = position.y + labyrinth_cell_size * 0.5}})
return
end
if r <= 100 then
surface.create_entity(
{name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.5, y = position.y + labyrinth_cell_size * 0.25}}
)
surface.create_entity(
{name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.75, y = position.y + labyrinth_cell_size * 0.75}}
)
surface.create_entity(
{name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.25, y = position.y + labyrinth_cell_size * 0.75}}
)
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.5, y = position.y + labyrinth_cell_size * 0.25}})
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.75, y = position.y + labyrinth_cell_size * 0.75}})
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = {x = position.x + labyrinth_cell_size * 0.25, y = position.y + labyrinth_cell_size * 0.75}})
return
end
end
@ -545,11 +532,7 @@ local function on_entity_died(event)
return
end
if event.entity.type == 'tree' then
for _, entity in pairs(
event.entity.surface.find_entities_filtered(
{area = {{event.entity.position.x - 4, event.entity.position.y - 4}, {event.entity.position.x + 4, event.entity.position.y + 4}}, name = 'fire-flame-on-tree'}
)
) do
for _, entity in pairs(event.entity.surface.find_entities_filtered({area = {{event.entity.position.x - 4, event.entity.position.y - 4}, {event.entity.position.x + 4, event.entity.position.y + 4}}, name = 'fire-flame-on-tree'})) do
if entity.valid then
entity.destroy()
end

View File

@ -2,7 +2,7 @@
--map by mewmew and kyte
require 'maps.island_troopers.map_intro'
require 'functions.noise_vector_path'
require 'utils.functions.noise_vector_path'
require 'modules.shopping_chests'
require 'modules.no_turrets'
require 'modules.dangerous_goods'
@ -327,4 +327,4 @@ event.add(defines.events.on_tick, on_tick)
event.add(defines.events.on_entity_died, on_entity_died)
event.add(defines.events.on_player_joined_game, on_player_joined_game)
require 'functions.boss_unit'
require 'utils.functions.boss_unit'

View File

@ -1,5 +1,5 @@
--luacheck: ignore
local Map_functions = require 'tools.map_functions'
local Map_functions = require 'utils.tools.map_functions'
local Server = require 'utils.server'
local Get_noise = require 'utils.get_noise'
local Autostash = require 'modules.autostash'
@ -38,7 +38,9 @@ local function protect(entity, operable)
end
function Public.place_mixed_ore(event, journey)
if math_random(1, 192) ~= 1 then return end
if math_random(1, 192) ~= 1 then
return
end
local surface = event.surface
local x = event.area.left_top.x + math_random(0, 31)
local y = event.area.left_top.y + math_random(0, 31)
@ -78,7 +80,8 @@ local function place_teleporter(journey, surface, position, build_beacon)
alignment = 'center',
scale_with_zoom = false
}
local hp = rendering.draw_text {
local hp =
rendering.draw_text {
text = {'journey.beacon_hp', journey.beacon_objective_health},
surface = surface,
target = beacon,
@ -110,19 +113,23 @@ end
local function drop_player_items(journey, player)
local character = player.character
if not character then return end
if not character.valid then return end
if not character then
return
end
if not character.valid then
return
end
player.clear_cursor()
for i = 1, player.crafting_queue_size, 1 do
if player.crafting_queue_size > 0 then
player.cancel_crafting{index = 1, count = 99999999}
player.cancel_crafting {index = 1, count = 99999999}
end
end
local surface = player.surface
local spill_blockage = surface.create_entity{name = 'oil-refinery', position = journey.beacon_objective.position or player.position}
local spill_blockage = surface.create_entity {name = 'oil-refinery', position = journey.beacon_objective.position or player.position}
for _, define in pairs({defines.inventory.character_main, defines.inventory.character_guns, defines.inventory.character_ammo, defines.inventory.character_armor, defines.inventory.character_vehicle, defines.inventory.character_trash}) do
local inventory = character.get_inventory(define)
@ -142,8 +149,12 @@ end
function Public.clear_player(player)
local character = player.character
if not character then return end
if not character.valid then return end
if not character then
return
end
if not character.valid then
return
end
player.character.destroy()
player.set_controller({type = defines.controllers.god})
player.create_character()
@ -153,7 +164,9 @@ end
local function remove_offline_players(maximum_age_in_hours)
local maximum_age_in_ticks = maximum_age_in_hours * 216000
local t = game.tick - maximum_age_in_ticks
if t < 0 then return end
if t < 0 then
return
end
local players_to_remove = {}
for _, player in pairs(game.players) do
if player.last_online < t then
@ -216,9 +229,13 @@ local function delete_nauvis_chunks(journey)
local surface = game.surfaces.nauvis
if not journey.nauvis_chunk_positions then
journey.nauvis_chunk_positions = {}
for chunk in surface.get_chunks() do table.insert(journey.nauvis_chunk_positions, {chunk.x, chunk.y}) end
for chunk in surface.get_chunks() do
table.insert(journey.nauvis_chunk_positions, {chunk.x, chunk.y})
end
journey.size_of_nauvis_chunk_positions = #journey.nauvis_chunk_positions
for _, e in pairs(surface.find_entities_filtered{type = 'radar'}) do e.destroy() end
for _, e in pairs(surface.find_entities_filtered {type = 'radar'}) do
e.destroy()
end
for _, player in pairs(game.players) do
local button = player.gui.top.add({type = 'sprite-button', name = 'chunk_progress', caption = ''})
button.style.font = 'heading-1'
@ -230,7 +247,9 @@ local function delete_nauvis_chunks(journey)
end
end
if journey.size_of_nauvis_chunk_positions == 0 then return end
if journey.size_of_nauvis_chunk_positions == 0 then
return
end
for c = 1, 12, 1 do
local chunk_position = journey.nauvis_chunk_positions[journey.size_of_nauvis_chunk_positions]
@ -244,14 +263,18 @@ local function delete_nauvis_chunks(journey)
local caption = {'journey.chunks_delete', journey.size_of_nauvis_chunk_positions}
for _, player in pairs(game.connected_players) do
if player.gui.top.chunk_progress then player.gui.top.chunk_progress.caption = caption end
if player.gui.top.chunk_progress then
player.gui.top.chunk_progress.caption = caption
end
end
return true
end
function Public.mothership_message_queue(journey)
local text = journey.mothership_messages[1]
if not text then return end
if not text then
return
end
if text ~= '' then
game.print({'journey.mothership_format', text})
end
@ -260,8 +283,12 @@ end
function Public.deny_building(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.name ~= 'mothership' then return end
if not entity.valid then
return
end
if entity.surface.name ~= 'mothership' then
return
end
if Constants.build_type_whitelist[entity.type] then
entity.destructible = false
return
@ -271,9 +298,15 @@ end
function Public.register_built_silo(event, journey)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if entity.type ~= 'rocket-silo' then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type ~= 'rocket-silo' then
return
end
entity.auto_launch = false
table.insert(journey.rocket_silos, entity)
end
@ -387,11 +420,19 @@ function Public.draw_gui(journey)
end
local function is_mothership(position)
if math.abs(position.x) > Constants.mothership_radius then return false end
if math.abs(position.y) > Constants.mothership_radius then return false end
if math.abs(position.x) > Constants.mothership_radius then
return false
end
if math.abs(position.y) > Constants.mothership_radius then
return false
end
local p = {x = position.x, y = position.y}
if p.x > 0 then p.x = p.x + 1 end
if p.y > 0 then p.y = p.y + 1 end
if p.x > 0 then
p.x = p.x + 1
end
if p.y > 0 then
p.y = p.y + 1
end
local d = math.sqrt(p.x ^ 2 + p.y ^ 2)
if d < Constants.mothership_radius then
return true
@ -423,7 +464,7 @@ function Public.export_journey(journey, import_flag)
bonus_goods = journey.bonus_goods,
world_selectors = journey.world_selectors,
mothership_cargo = journey.mothership_cargo,
mothership_cargo_space = journey.mothership_cargo_space,
mothership_cargo_space = journey.mothership_cargo_space
}
local secs = Server.get_current_time()
if not secs then
@ -522,7 +563,9 @@ function Public.hard_reset(journey)
journey.world_selectors = {}
journey.reroll_selector = {activation_level = 0}
for i = 1, 3, 1 do journey.world_selectors[i] = {activation_level = 0, texts = {}} end
for i = 1, 3, 1 do
journey.world_selectors[i] = {activation_level = 0, texts = {}}
end
journey.mothership_speed = 0.5
journey.characters_in_mothership = 0
journey.world_color_filters = {}
@ -575,7 +618,9 @@ function Public.draw_mothership(journey)
for x = Constants.mothership_radius * -1, Constants.mothership_radius, 1 do
for y = Constants.mothership_radius * -1, Constants.mothership_radius, 1 do
local position = {x = x, y = y}
if is_mothership(position) then table.insert(positions, position) end
if is_mothership(position) then
table.insert(positions, position)
end
end
end
@ -591,16 +636,19 @@ function Public.draw_mothership(journey)
end
end
for _, tile in pairs(surface.find_tiles_filtered({area = {{Constants.mothership_teleporter_position.x - 2, Constants.mothership_teleporter_position.y - 2}, {Constants.mothership_teleporter_position.x + 2, Constants.mothership_teleporter_position.y + 2}}})) do
for _, tile in pairs(
surface.find_tiles_filtered({area = {{Constants.mothership_teleporter_position.x - 2, Constants.mothership_teleporter_position.y - 2}, {Constants.mothership_teleporter_position.x + 2, Constants.mothership_teleporter_position.y + 2}}})
) do
surface.set_tiles({{name = 'lab-dark-1', position = tile.position}}, true)
end
for k, area in pairs(Constants.world_selector_areas) do
journey.world_selectors[k].rectangles = {}
local position = area.left_top
local rectangle = rendering.draw_rectangle {
local rectangle =
rendering.draw_rectangle {
width = 1,
filled=true,
filled = true,
surface = surface,
left_top = position,
right_bottom = {position.x + Constants.world_selector_width, position.y + Constants.world_selector_height},
@ -609,9 +657,10 @@ function Public.draw_mothership(journey)
only_in_alt_mode = false
}
table.insert(journey.world_selectors[k].rectangles, rectangle)
journey.world_selectors[k].border = rendering.draw_rectangle {
journey.world_selectors[k].border =
rendering.draw_rectangle {
width = 8,
filled=false,
filled = false,
surface = surface,
left_top = position,
right_bottom = {position.x + Constants.world_selector_width, position.y + Constants.world_selector_height},
@ -621,9 +670,10 @@ function Public.draw_mothership(journey)
}
end
journey.reroll_selector.rectangle = rendering.draw_rectangle {
journey.reroll_selector.rectangle =
rendering.draw_rectangle {
width = 8,
filled=true,
filled = true,
surface = surface,
left_top = Constants.reroll_selector_area.left_top,
right_bottom = Constants.reroll_selector_area.right_bottom,
@ -631,9 +681,10 @@ function Public.draw_mothership(journey)
draw_on_ground = true,
only_in_alt_mode = false
}
journey.reroll_selector.border = rendering.draw_rectangle {
journey.reroll_selector.border =
rendering.draw_rectangle {
width = 8,
filled=false,
filled = false,
surface = surface,
left_top = Constants.reroll_selector_area.left_top,
right_bottom = Constants.reroll_selector_area.right_bottom,
@ -660,7 +711,9 @@ function Public.draw_mothership(journey)
for m = -1, 1, 2 do
local x = Constants.mothership_radius - 3
if m > 0 then x = x - 1 end
if m > 0 then
x = x - 1
end
local y = Constants.mothership_radius * 0.5 - 7
local turret = surface.create_entity({name = 'artillery-turret', position = {x * m, y}, force = 'player'})
turret.direction = 4
@ -690,7 +743,7 @@ function Public.teleport_players_to_mothership(journey)
for _, player in pairs(game.connected_players) do
if player.surface.name ~= 'mothership' then
Public.clear_player(player)
player.teleport(surface.find_non_colliding_position('character', {0,0}, 32, 0.5), surface)
player.teleport(surface.find_non_colliding_position('character', {0, 0}, 32, 0.5), surface)
journey.characters_in_mothership = journey.characters_in_mothership + 1
table.insert(journey.mothership_messages, 'Welcome home ' .. player.name .. '!')
return
@ -720,7 +773,7 @@ end
local function get_activation_level(journey, surface, area)
local player_count_in_area = surface.count_entities_filtered({area = area, name = 'character'})
local player_count_for_max_activation = math.max(#game.connected_players, journey.vote_minimum) * (2/3)
local player_count_for_max_activation = math.max(#game.connected_players, journey.vote_minimum) * (2 / 3)
local level = player_count_in_area / player_count_for_max_activation
level = math.round(level, 2)
return level
@ -729,22 +782,32 @@ end
local function animate_selectors(journey)
for k, world_selector in pairs(journey.world_selectors) do
local activation_level = journey.world_selectors[k].activation_level
if activation_level < 0.2 then activation_level = 0.2 end
if activation_level > 1 then activation_level = 1 end
if activation_level < 0.2 then
activation_level = 0.2
end
if activation_level > 1 then
activation_level = 1
end
for _, rectangle in pairs(world_selector.rectangles) do
local color = Constants.world_selector_colors[k]
rendering.set_color(rectangle, {r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255})
end
end
local activation_level = journey.reroll_selector.activation_level
if activation_level < 0.2 then activation_level = 0.2 end
if activation_level > 1 then activation_level = 1 end
if activation_level < 0.2 then
activation_level = 0.2
end
if activation_level > 1 then
activation_level = 1
end
local color = Constants.reroll_selector_area_color
rendering.set_color(journey.reroll_selector.rectangle, {r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255})
end
local function draw_background(journey, surface)
if journey.characters_in_mothership == 0 then return end
if journey.characters_in_mothership == 0 then
return
end
local speed = journey.mothership_speed
for c = 1, 16 * speed, 1 do
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
@ -769,8 +832,12 @@ local function draw_background(journey, surface)
if math.random(1, 90) == 1 then
local position_x = math.random(64, 160)
local position_y = math.random(64, 160)
if math.random(1, 2) == 1 then position_x = position_x * -1 end
if math.random(1, 2) == 1 then position_y = position_y * -1 end
if math.random(1, 2) == 1 then
position_x = position_x * -1
end
if math.random(1, 2) == 1 then
position_y = position_y * -1
end
surface.create_entity({name = 'big-worm-turret', position = {position_x, position_y}, force = 'enemy'})
end
end
@ -782,7 +849,6 @@ local function roll_bonus_goods(journey, trait, amount)
for key, numbers in pairs(loot) do
local loot_table = Constants.starter_goods_pool[key]
if #bonus_goods < (amount or 3) and math.random(numbers[1], numbers[2]) >= 1 then
local item = loot_table[math.random(1, #loot_table)]
bonus_goods[#bonus_goods + 1] = {item[1], math.random(item[2], item[3])}
end
@ -795,7 +861,7 @@ function Public.set_world_selectors(journey)
local surface = game.surfaces.mothership
local x = Constants.reroll_selector_area.left_top.x + 3.2
journey.reroll_selector.texts = {
rendering.draw_text{
rendering.draw_text {
text = journey.mothership_cargo.satellite .. ' x ',
surface = surface,
target = {x, Constants.reroll_selector_area.left_top.y - 1.5},
@ -803,15 +869,15 @@ function Public.set_world_selectors(journey)
scale = 1.5,
font = 'default-large-bold',
alignment = 'center',
scale_with_zoom = false,
scale_with_zoom = false
},
rendering.draw_sprite{
rendering.draw_sprite {
sprite = 'item/satellite',
surface = surface,
y_scale = 1.5,
x_scale = 1.5,
target = {x + 1.6, Constants.reroll_selector_area.left_top.y - 1},
},
target = {x + 1.6, Constants.reroll_selector_area.left_top.y - 1}
}
}
local modifier_names = {}
@ -842,7 +908,9 @@ function Public.set_world_selectors(journey)
local limits = {6, Constants.unique_world_traits[world_selector.world_trait].mods}
local counts = {0, 0}
local i = 1
if journey.importing then goto skip_reroll end
if journey.importing then
goto skip_reroll
end
while (limits[1] + limits[2] > counts[1] + counts[2]) and i < #modifier_names do
local modifier = modifier_names[i]
local data = Constants.modifiers[modifier]
@ -888,7 +956,9 @@ function Public.set_world_selectors(journey)
world_selector.bonus_goods = roll_bonus_goods(journey, world_selector.world_trait)
::skip_reroll::
table.insert(texts, rendering.draw_text{
table.insert(
texts,
rendering.draw_text {
text = Constants.unique_world_traits[world_selector.world_trait].name,
surface = surface,
target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier},
@ -897,12 +967,15 @@ function Public.set_world_selectors(journey)
font = 'default-large-bold',
alignment = 'center',
scale_with_zoom = false
})
}
)
for k2, modifier in pairs(modifiers) do
y_modifier = y_modifier + 0.8
local text = ''
if modifier.value > 0 then text = text .. '+' end
if modifier.value > 0 then
text = text .. '+'
end
text = text .. modifier.value .. '% '
text = text .. Constants.modifiers[modifier.name].name
@ -913,7 +986,9 @@ function Public.set_world_selectors(journey)
color = {0, 200, 0, 255}
end
table.insert(texts, rendering.draw_text{
table.insert(
texts,
rendering.draw_text {
text = text,
surface = surface,
target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier},
@ -922,11 +997,14 @@ function Public.set_world_selectors(journey)
font = 'default-large',
alignment = 'center',
scale_with_zoom = false
})
}
)
end
y_modifier = y_modifier + 0.85
table.insert(texts, rendering.draw_text{
table.insert(
texts,
rendering.draw_text {
text = 'Fuel requirement +' .. world_selector.fuel_requirement,
surface = surface,
target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier},
@ -935,18 +1013,23 @@ function Public.set_world_selectors(journey)
font = 'default-large',
alignment = 'center',
scale_with_zoom = false
})
table.insert(texts, rendering.draw_sprite{
}
)
table.insert(
texts,
rendering.draw_sprite {
sprite = 'item/uranium-fuel-cell',
surface = surface,
target = {position.x + Constants.world_selector_width * 0.5 + 3.7, position.y + y_modifier + 0.5},
})
target = {position.x + Constants.world_selector_width * 0.5 + 3.7, position.y + y_modifier + 0.5}
}
)
y_modifier = y_modifier + 1.1
local x_modifier = -0.5
for k2, good in pairs(world_selector.bonus_goods) do
local render_id = rendering.draw_text{
local render_id =
rendering.draw_text {
text = '+' .. good[2],
surface = surface,
target = {position.x + x_modifier, position.y + y_modifier},
@ -959,13 +1042,18 @@ function Public.set_world_selectors(journey)
table.insert(texts, render_id)
x_modifier = x_modifier + 0.95
if good[2] >= 10 then x_modifier = x_modifier + 0.18 end
if good[2] >= 100 then x_modifier = x_modifier + 0.18 end
if good[2] >= 10 then
x_modifier = x_modifier + 0.18
end
if good[2] >= 100 then
x_modifier = x_modifier + 0.18
end
local render_id = rendering.draw_sprite{
local render_id =
rendering.draw_sprite {
sprite = 'item/' .. good[1],
surface = surface,
target = {position.x + x_modifier, position.y + 0.5 + y_modifier},
target = {position.x + x_modifier, position.y + 0.5 + y_modifier}
}
table.insert(texts, render_id)
@ -990,9 +1078,13 @@ function Public.delete_nauvis_chunks(journey)
local surface = game.surfaces.mothership
Public.teleport_players_to_mothership(journey)
draw_background(journey, surface)
if delete_nauvis_chunks(journey) then return end
if delete_nauvis_chunks(journey) then
return
end
for _, player in pairs(game.players) do
if player.gui.top.chunk_progress then player.gui.top.chunk_progress.destroy() end
if player.gui.top.chunk_progress then
player.gui.top.chunk_progress.destroy()
end
end
journey.game_state = 'mothership_world_selection'
@ -1047,7 +1139,9 @@ function Public.mothership_world_selection(journey)
local surface = game.surfaces.mothership
local daytime = surface.daytime
daytime = daytime - 0.025
if daytime < 0 then daytime = 0 end
if daytime < 0 then
daytime = 0
end
surface.daytime = daytime
local reroll_selector_activation_level = get_activation_level(journey, surface, Constants.reroll_selector_area)
@ -1087,18 +1181,24 @@ function Public.mothership_world_selection(journey)
journey.game_state = 'mothership_arrives_at_world'
return
end
if seconds_left % 15 == 0 then table.insert(journey.mothership_messages, 'Estimated arrival in ' .. seconds_left .. ' seconds.') end
if seconds_left % 15 == 0 then
table.insert(journey.mothership_messages, 'Estimated arrival in ' .. seconds_left .. ' seconds.')
end
end
journey.mothership_speed = journey.mothership_speed + 0.1
if journey.mothership_speed > 4 then journey.mothership_speed = 4 end
if journey.mothership_speed > 4 then
journey.mothership_speed = 4
end
else
if journey.mothership_advancing_to_world then
table.insert(journey.mothership_messages, 'Aborting travelling sequence.')
journey.mothership_advancing_to_world = false
end
journey.mothership_speed = journey.mothership_speed - 0.25
if journey.mothership_speed < 0.35 then journey.mothership_speed = 0.35 end
if journey.mothership_speed < 0.35 then
journey.mothership_speed = 0.35
end
end
draw_background(journey, surface)
@ -1112,9 +1212,13 @@ function Public.mothership_arrives_at_world(journey)
Public.teleport_players_to_mothership(journey)
if journey.mothership_speed == 0.15 then
for _ = 1, 16, 1 do table.insert(journey.mothership_messages, '') end
for _ = 1, 16, 1 do
table.insert(journey.mothership_messages, '')
end
table.insert(journey.mothership_messages, '[img=item/uranium-fuel-cell] Fuel cells depleted ;_;')
for _ = 1, 16, 1 do table.insert(journey.mothership_messages, '') end
for _ = 1, 16, 1 do
table.insert(journey.mothership_messages, '')
end
table.insert(journey.mothership_messages, 'Refuel via supply rocket required!')
for i = 1, 3, 1 do
@ -1141,13 +1245,17 @@ end
function Public.clear_modifiers(journey)
local unique_modifier = Unique_modifiers[journey.world_trait]
local clear = unique_modifier.clear
if clear then clear(journey) end
if clear then
clear(journey)
end
journey.world_specials = {}
local force = game.forces.player
force.reset()
force.reset_technologies()
force.reset_technology_effects()
for a = 1, 7, 1 do force.technologies['refined-flammables-' .. a].enabled = false end
for a = 1, 7, 1 do
force.technologies['refined-flammables-' .. a].enabled = false
end
journey.game_state = 'create_the_world'
Public.update_tooltips(journey)
end
@ -1171,11 +1279,12 @@ function Public.create_the_world(journey)
local unique_modifier = Unique_modifiers[journey.world_trait]
local set_specials = unique_modifier.set_specials
if set_specials then set_specials(journey) end
if set_specials then
set_specials(journey)
end
set_map_modifiers(journey)
surface.clear(false)
journey.nauvis_chunk_positions = nil
journey.rocket_silos = {}
journey.mothership_cargo['uranium-fuel-cell'] = 0
@ -1197,7 +1306,9 @@ function Public.create_the_world(journey)
end
end
journey.goods_to_dispatch = {}
for k, v in pairs(journey.bonus_goods) do table.insert(journey.goods_to_dispatch, {k, v}) end
for k, v in pairs(journey.bonus_goods) do
table.insert(journey.goods_to_dispatch, {k, v})
end
table.shuffle_table(journey.goods_to_dispatch)
Public.update_tooltips(journey)
journey.game_state = 'wipe_offline_players'
@ -1221,7 +1332,9 @@ function Public.notify_discord(journey)
local modifier_message = ''
for _, mod in pairs(journey.world_selectors[journey.selected_world].modifiers) do
local sign = ''
if mod.value > 0 then sign = '+' end
if mod.value > 0 then
sign = '+'
end
modifier_message = modifier_message .. sign .. mod.value .. '% ' .. mod.name .. '\n'
end
local capsules = ''
@ -1261,11 +1374,12 @@ function Public.notify_discord(journey)
Server.to_discord_embed_parsed(message)
end
function Public.set_unique_modifiers(journey)
local unique_modifier = Unique_modifiers[journey.world_trait]
local on_world_start = unique_modifier.on_world_start
if on_world_start then on_world_start(journey) end
if on_world_start then
on_world_start(journey)
end
Public.update_tooltips(journey)
Public.draw_gui(journey)
Public.notify_discord(journey)
@ -1298,20 +1412,28 @@ end
function Public.dispatch_goods(journey)
draw_background(journey, game.surfaces.mothership)
if journey.characters_in_mothership == #game.connected_players then return end
if journey.characters_in_mothership == #game.connected_players then
return
end
local goods_to_dispatch = journey.goods_to_dispatch
local size_of_goods_to_dispatch = #goods_to_dispatch
if size_of_goods_to_dispatch == 0 then
for _ = 1, 30, 1 do table.insert(journey.mothership_messages, '') end
for _ = 1, 30, 1 do
table.insert(journey.mothership_messages, '')
end
table.insert(journey.mothership_messages, 'Capsule storage depleted.')
for _ = 1, 30, 1 do table.insert(journey.mothership_messages, '') end
for _ = 1, 30, 1 do
table.insert(journey.mothership_messages, '')
end
table.insert(journey.mothership_messages, 'Good luck on your adventure! ^.^')
journey.game_state = 'world'
return
end
if journey.dispatch_beacon and journey.dispatch_beacon.valid then return end
if journey.dispatch_beacon and journey.dispatch_beacon.valid then
return
end
local surface = game.surfaces.nauvis
@ -1326,11 +1448,15 @@ function Public.dispatch_goods(journey)
end
local chunk = surface.get_random_chunk()
if math.abs(chunk.x) > 4 or math.abs(chunk.y) > 4 then return end
if math.abs(chunk.x) > 4 or math.abs(chunk.y) > 4 then
return
end
local position = {x = chunk.x * 32 + math.random(0, 31), y = chunk.y * 32 + math.random(0, 31)}
position = surface.find_non_colliding_position('rocket-silo', position, 32, 1)
if not position then return end
if not position then
return
end
journey.dispatch_beacon = surface.create_entity({name = 'stone-wall', position = position, force = 'neutral'})
journey.dispatch_beacon.minable = false
@ -1393,7 +1519,9 @@ function Public.world(journey)
end
end
if game.tick % 1800 ~= 0 then return end
if game.tick % 1800 ~= 0 then
return
end
for k, silo in pairs(journey.rocket_silos) do
if not silo or not silo.valid then
table.remove(journey.rocket_silos, k)
@ -1421,7 +1549,9 @@ function Public.mothership_waiting_for_players(journey)
return
end
if math.random(1, 2) == 1 then return end
if math.random(1, 2) == 1 then
return
end
local tick = game.tick % 3600
if tick == 0 then
local messages = Constants.mothership_messages.waiting
@ -1430,12 +1560,18 @@ function Public.mothership_waiting_for_players(journey)
end
function Public.teleporters(journey, player)
if not player.character then return end
if not player.character.valid then return end
if not player.character then
return
end
if not player.character.valid then
return
end
local surface = player.surface
local tile = surface.get_tile(player.position)
if tile.name ~= Constants.teleporter_tile and tile.hidden_tile ~= Constants.teleporter_tile then return end
local base_position = {0,0}
if tile.name ~= Constants.teleporter_tile and tile.hidden_tile ~= Constants.teleporter_tile then
return
end
local base_position = {0, 0}
if surface.index == 1 then
drop_player_items(journey, player)
local position = game.surfaces.mothership.find_non_colliding_position('character', base_position, 32, 0.5)
@ -1462,7 +1598,9 @@ function Public.teleporters(journey, player)
end
function Public.deal_damage_to_beacon(journey, incoming_damage)
if journey.game_state ~= 'world' then return end
if journey.game_state ~= 'world' then
return
end
local resistance = journey.beacon_objective_resistance
journey.beacon_objective_health = math.floor(journey.beacon_objective_health - (incoming_damage * (1 - resistance)))
rendering.set_text(journey.beacon_objective_hp_label, {'journey.beacon_hp', journey.beacon_objective_health})
@ -1490,10 +1628,12 @@ function Public.deal_damage_to_beacon(journey, incoming_damage)
end
function Public.lure_biters(journey, position)
if journey.game_state ~= 'world' or not journey.beacon_objective.valid then return end
if journey.game_state ~= 'world' or not journey.beacon_objective.valid then
return
end
local beacon = journey.beacon_objective
local surface = beacon.surface
local biters = surface.find_entities_filtered{position = position or beacon.position, radius = 80, force = 'enemy', type = 'unit'}
local biters = surface.find_entities_filtered {position = position or beacon.position, radius = 80, force = 'enemy', type = 'unit'}
if #biters > 0 then
for _, biter in pairs(biters) do
biter.set_command({type = defines.command.attack_area, destination = beacon.position, radius = 10, distraction = defines.distraction.by_anything})

View File

@ -1,7 +1,7 @@
--luacheck: ignore 212/journey
local Get_noise = require 'utils.get_noise'
local BiterRaffle = require 'functions.biter_raffle'
local LootRaffle = require 'functions.loot_raffle'
local BiterRaffle = require 'utils.functions.biter_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local math_random = math.random
local math_abs = math.abs
local math_floor = math.floor
@ -9,15 +9,29 @@ local math_sqrt = math.sqrt
local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
local size_of_rock_raffle = #rock_raffle
local ore_raffle = {}
for i = 1, 25, 1 do table.insert(ore_raffle, 'iron-ore') end
for i = 1, 17, 1 do table.insert(ore_raffle, 'copper-ore') end
for i = 1, 15, 1 do table.insert(ore_raffle, 'coal') end
for i = 1, 25, 1 do
table.insert(ore_raffle, 'iron-ore')
end
for i = 1, 17, 1 do
table.insert(ore_raffle, 'copper-ore')
end
for i = 1, 15, 1 do
table.insert(ore_raffle, 'coal')
end
local size_of_ore_raffle = #ore_raffle
local ore_raffle_2 = {}
for i = 1, 15, 1 do table.insert(ore_raffle_2, 'iron-ore') end
for i = 1, 9, 1 do table.insert(ore_raffle_2, 'copper-ore') end
for i = 1, 7, 1 do table.insert(ore_raffle_2, 'coal') end
for i = 1, 5, 1 do table.insert(ore_raffle_2, 'stone') end
for i = 1, 15, 1 do
table.insert(ore_raffle_2, 'iron-ore')
end
for i = 1, 9, 1 do
table.insert(ore_raffle_2, 'copper-ore')
end
for i = 1, 7, 1 do
table.insert(ore_raffle_2, 'coal')
end
for i = 1, 5, 1 do
table.insert(ore_raffle_2, 'stone')
end
local size_of_ore_raffle_2 = #ore_raffle_2
local rock_yield = {
['rock-big'] = 1,
@ -33,14 +47,14 @@ local solid_tiles = {
['refined-hazard-concrete-right'] = true,
['stone-path'] = true,
['lab-dark-1'] = true,
['lab-dark-2'] = true,
['lab-dark-2'] = true
}
local wrecks = {
'crash-site-spaceship-wreck-big-1',
'crash-site-spaceship-wreck-big-2',
'crash-site-spaceship-wreck-medium-1',
'crash-site-spaceship-wreck-medium-2',
'crash-site-spaceship-wreck-medium-3',
'crash-site-spaceship-wreck-medium-3'
}
local size_of_wrecks = #wrecks
@ -66,7 +80,7 @@ Public.eternal_day = {
clear = function(journey)
local surface = game.surfaces.nauvis
surface.freeze_daytime = false
end,
end
}
Public.eternal_night = {
@ -80,7 +94,7 @@ Public.eternal_night = {
local surface = game.surfaces.nauvis
surface.freeze_daytime = false
surface.solar_power_multiplier = 1
end,
end
}
Public.pitch_black = {
@ -98,35 +112,53 @@ Public.pitch_black = {
surface.solar_power_multiplier = 1
surface.min_brightness = 0.15
surface.brightness_visual_weights = {0, 0, 0, 1}
end,
end
}
Public.matter_anomaly = {
on_world_start = function(journey)
local force = game.forces.player
for i = 1, 4, 1 do force.technologies['mining-productivity-' .. i].researched = true end
for i = 1, 6, 1 do force.technologies['mining-productivity-4'].researched = true end
for i = 1, 4, 1 do
force.technologies['mining-productivity-' .. i].researched = true
end
for i = 1, 6, 1 do
force.technologies['mining-productivity-4'].researched = true
end
end,
on_robot_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if entity.type == 'electric-turret' then entity.die() end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'electric-turret' then
entity.die()
end
end,
on_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if entity.type == 'electric-turret' then entity.die() end
end,
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'electric-turret' then
entity.die()
end
end
}
Public.quantum_anomaly = {
on_world_start = function(journey)
local force = game.forces.player
for i = 1, 6, 1 do force.technologies['research-speed-' .. i].researched = true end
for i = 1, 6, 1 do
force.technologies['research-speed-' .. i].researched = true
end
journey.world_specials['technology_price_multiplier'] = 0.5
end,
end
}
Public.mountainous = {
@ -136,8 +168,12 @@ Public.mountainous = {
end,
on_player_mined_entity = function(event)
local entity = event.entity
if not entity.valid then return end
if not rock_yield[entity.name] then return end
if not entity.valid then
return
end
if not rock_yield[entity.name] then
return
end
local surface = entity.surface
event.buffer.clear()
local ore = ore_raffle[math_random(1, size_of_ore_raffle)]
@ -167,37 +203,59 @@ Public.mountainous = {
end
end
end
end,
end
}
Public.replicant_fauna = {
on_entity_died = function(event)
local entity = event.entity
if not entity.valid then return end
if not entity.valid then
return
end
local cause = event.cause
if not cause then return end
if not cause.valid then return end
if cause.force.index == 2 then cause.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor), position = entity.position, force = 'enemy'}) end
end,
if not cause then
return
end
if not cause.valid then
return
end
if cause.force.index == 2 then
cause.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor), position = entity.position, force = 'enemy'})
end
end
}
Public.tarball = {
on_robot_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if tarball_minable[entity.type] then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if tarball_minable[entity.type] then
return
end
entity.minable = false
end,
on_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if tarball_minable[entity.type] then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if tarball_minable[entity.type] then
return
end
entity.minable = false
end,
on_chunk_generated = function(event, journey)
table.insert(journey.world_color_filters, rendering.draw_sprite(
table.insert(
journey.world_color_filters,
rendering.draw_sprite(
{
sprite = 'tile/lab-dark-1',
x_scale = 32,
@ -207,12 +265,15 @@ Public.tarball = {
tint = {r = 0.0, g = 0.0, b = 0.0, a = 0.45},
render_layer = 'ground'
}
))
end,
clear = function(journey)
for _, id in pairs(journey.world_color_filters) do rendering.destroy(id) end
)
)
end,
clear = function(journey)
for _, id in pairs(journey.world_color_filters) do
rendering.destroy(id)
end
journey.world_color_filters = {}
end,
end
}
Public.swamps = {
@ -234,7 +295,9 @@ Public.swamps = {
for y = 0, 31, 1 do
local position = {x = left_top_x + x, y = left_top_y + y}
local noise = Get_noise('journey_swamps', position, seed)
if noise > 0.45 or noise < -0.65 then table.insert(tiles, {name = 'water-shallow', position = {x = position.x, y = position.y}}) end
if noise > 0.45 or noise < -0.65 then
table.insert(tiles, {name = 'water-shallow', position = {x = position.x, y = position.y}})
end
end
end
surface.set_tiles(tiles, true, false, false, false)
@ -244,7 +307,7 @@ Public.swamps = {
surface.create_entity({name = 'fish', position = tile.position})
end
end
end,
end
}
Public.wasteland = {
@ -260,7 +323,9 @@ Public.wasteland = {
table.insert(tiles, {name = 'deepwater-green', position = tile.position})
end
surface.set_tiles(tiles, true, false, false, false)
if math_random(1, 3) ~= 1 then return end
if math_random(1, 3) ~= 1 then
return
end
for _ = 1, math_random(0, 5), 1 do
local name = wrecks[math_random(1, size_of_wrecks)]
local position = surface.find_non_colliding_position(name, {left_top_x + math_random(0, 31), left_top_y + math_random(0, 31)}, 16, 1)
@ -270,7 +335,9 @@ Public.wasteland = {
local slots = game.entity_prototypes[e.name].get_inventory_size(defines.inventory.chest)
local blacklist = LootRaffle.get_tech_blacklist(0.2)
local item_stacks = LootRaffle.roll(math_random(16, 64), slots, blacklist)
for _, item_stack in pairs(item_stacks) do e.insert(item_stack) end
for _, item_stack in pairs(item_stacks) do
e.insert(item_stack)
end
end
end
end
@ -288,7 +355,7 @@ Public.wasteland = {
local mgs = surface.map_gen_settings
mgs.water = mgs.water - 1
surface.map_gen_settings = mgs
end,
end
}
Public.oceanic = {
@ -302,27 +369,42 @@ Public.oceanic = {
end,
on_robot_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if entity.type == 'fluid-turret' then entity.die() end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'fluid-turret' then
entity.die()
end
end,
on_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if entity.type == 'fluid-turret' then entity.die() end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'fluid-turret' then
entity.die()
end
end,
clear = function(journey)
local surface = game.surfaces.nauvis
local mgs = surface.map_gen_settings
mgs.water = mgs.water - 6
surface.map_gen_settings = mgs
end,
end
}
Public.volcanic = {
on_chunk_generated = function(event, journey)
table.insert(journey.world_color_filters, rendering.draw_sprite({
table.insert(
journey.world_color_filters,
rendering.draw_sprite(
{
sprite = 'tile/lab-dark-2',
x_scale = 32,
y_scale = 32,
@ -330,14 +412,22 @@ Public.volcanic = {
surface = event.surface,
tint = {r = 0.55, g = 0.0, b = 0.0, a = 0.25},
render_layer = 'ground'
}))
}
)
)
end,
on_player_changed_position = function(event)
local player = game.players[event.player_index]
if player.driving then return end
if player.driving then
return
end
local surface = player.surface
if surface.index ~= 1 then return end
if solid_tiles[surface.get_tile(player.position).name] then return end
if surface.index ~= 1 then
return
end
if solid_tiles[surface.get_tile(player.position).name] then
return
end
surface.create_entity({name = 'fire-flame', position = player.position})
end,
on_world_start = function(journey)
@ -354,9 +444,11 @@ Public.volcanic = {
end
end,
clear = function(journey)
for _, id in pairs(journey.world_color_filters) do rendering.destroy(id) end
for _, id in pairs(journey.world_color_filters) do
rendering.destroy(id)
end
journey.world_color_filters = {}
end,
end
}
Public.chaotic_resources = {
@ -366,12 +458,15 @@ Public.chaotic_resources = {
surface.create_entity({name = ore_raffle_2[math_random(1, size_of_ore_raffle_2)], position = ore.position, amount = ore.amount})
ore.destroy()
end
end,
end
}
Public.infested = {
on_chunk_generated = function(event, journey)
table.insert(journey.world_color_filters, rendering.draw_sprite({
table.insert(
journey.world_color_filters,
rendering.draw_sprite(
{
sprite = 'tile/lab-dark-2',
x_scale = 32,
y_scale = 32,
@ -379,7 +474,9 @@ Public.infested = {
surface = event.surface,
tint = {r = 0.8, g = 0.0, b = 0.8, a = 0.25},
render_layer = 'ground'
}))
}
)
)
end,
set_specials = function(journey)
journey.world_specials['trees_size'] = 4
@ -387,111 +484,177 @@ Public.infested = {
journey.world_specials['trees_frequency'] = 2
end,
clear = function(journey)
for _, id in pairs(journey.world_color_filters) do rendering.destroy(id) end
for _, id in pairs(journey.world_color_filters) do
rendering.destroy(id)
end
journey.world_color_filters = {}
end,
on_entity_died = function(event)
local entity = event.entity
if not entity.valid then return end
if entity.force.index ~= 3 then return end
if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end
if not entity.valid then
return
end
if entity.force.index ~= 3 then
return
end
if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then
return
end
entity.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy'})
end,
on_player_mined_entity = function(event)
if math_random(1,2) == 1 then return end
if math_random(1, 2) == 1 then
return
end
local entity = event.entity
if not entity.valid then return end
if entity.force.index ~= 3 then return end
if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end
if not entity.valid then
return
end
if entity.force.index ~= 3 then
return
end
if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then
return
end
entity.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy'})
end,
on_robot_mined_entity = function(event)
local entity = event.entity
if not entity.valid then return end
if entity.force.index ~= 3 then return end
if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end
if not entity.valid then
return
end
if entity.force.index ~= 3 then
return
end
if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then
return
end
entity.surface.create_entity({name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy'})
end,
end
}
Public.undead_plague = {
on_entity_died = function(event)
local entity = event.entity
if not entity.valid then return end
if entity.force.index ~= 2 then return end
if math_random(1,2) == 1 then return end
if entity.type ~= 'unit' then return end
if not entity.valid then
return
end
if entity.force.index ~= 2 then
return
end
if math_random(1, 2) == 1 then
return
end
if entity.type ~= 'unit' then
return
end
entity.surface.create_entity({name = entity.name, position = entity.position, force = 'enemy'})
end,
end
}
Public.low_mass = {
on_world_start = function(journey)
local force = game.forces.player
force.character_running_speed_modifier = 0.5
for i = 1, 6, 1 do force.technologies['worker-robots-speed-' .. i].researched = true end
end,
for i = 1, 6, 1 do
force.technologies['worker-robots-speed-' .. i].researched = true
end
end
}
Public.dense_atmosphere = {
on_robot_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if entity.type == 'roboport' then entity.die() end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'roboport' then
entity.die()
end
end,
on_built_entity = function(event)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if entity.type == 'roboport' then entity.die() end
end,
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'roboport' then
entity.die()
end
end
}
local function update_lazy_bastard(journey, count)
journey.lazy_bastard_machines = journey.lazy_bastard_machines + count
local speed = journey.lazy_bastard_machines * -0.1
if speed < -1 then speed = -1 end
if speed < -1 then
speed = -1
end
game.forces.player.manual_crafting_speed_modifier = speed
end
Public.lazy_bastard = {
on_robot_built_entity = function(event, journey)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'assembling-machine' then
update_lazy_bastard(journey, 1)
end
end,
on_built_entity = function(event, journey)
local entity = event.created_entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'assembling-machine' then
update_lazy_bastard(journey, 1)
end
end,
on_entity_died = function(event, journey)
local entity = event.entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'assembling-machine' then
update_lazy_bastard(journey, -1)
end
end,
on_player_mined_entity = function(event, journey)
local entity = event.entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'assembling-machine' then
update_lazy_bastard(journey, -1)
end
end,
on_robot_mined_entity = function(event, journey)
local entity = event.entity
if not entity.valid then return end
if entity.surface.index ~= 1 then return end
if not entity.valid then
return
end
if entity.surface.index ~= 1 then
return
end
if entity.type == 'assembling-machine' then
update_lazy_bastard(journey, -1)
end
@ -501,7 +664,7 @@ Public.lazy_bastard = {
end,
clear = function(journey)
game.forces.player.manual_crafting_speed_modifier = 0
end,
end
}
Public.ribbon = {
@ -509,8 +672,8 @@ Public.ribbon = {
local surface = event.surface
local left_top_x = event.area.left_top.x
local left_top_y = event.area.left_top.y
if (left_top_x + left_top_y)^2 <= 256 then
local oils = surface.count_entities_filtered{name = 'crude-oil', position = {x = 0,y =0}, radius = 256}
if (left_top_x + left_top_y) ^ 2 <= 256 then
local oils = surface.count_entities_filtered {name = 'crude-oil', position = {x = 0, y = 0}, radius = 256}
if math.random(1, 10 + oils * 10) == 1 then
local pos = surface.find_non_colliding_position_in_box('oil-refinery', event.area, 0.1, true)
if pos then
@ -531,7 +694,7 @@ Public.ribbon = {
local mgs = surface.map_gen_settings
mgs.height = nil
surface.map_gen_settings = mgs
end,
end
}
Public.abandoned_library = {
@ -542,7 +705,7 @@ Public.abandoned_library = {
clear = function(journey)
game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, true)
game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, true)
end,
end
}
Public.railworld = {
@ -560,7 +723,7 @@ Public.railworld = {
journey.world_specials['enemy_base_richness'] = 2
journey.world_specials['water'] = 1.5
journey.world_specials['starting_area'] = 3
end,
end
}
local delivery_options = {
@ -584,7 +747,7 @@ Public.resupply_station = {
journey.mothership_cargo_space[journey.speedrun.item] = nil
journey.mothership_cargo[journey.speedrun.item] = 0
journey.speedrun.enabled = false
end,
end
}
Public.crazy_science = {
@ -604,8 +767,7 @@ Public.crazy_science = {
journey.world_specials[name] = math.max(0.1, journey.world_specials[name] * 0.95)
game.difficulty_settings.technology_price_multiplier = journey.world_modifiers[name] * (journey.world_specials[name] or 1)
force.laboratory_productivity_bonus = math.max(0.1, force.laboratory_productivity_bonus * 0.95)
end,
end
}
return Public

View File

@ -1,107 +1,106 @@
--luacheck: ignore
--junkyard-- mewmew made this --
require "modules.dynamic_landfill"
require "modules.satellite_score"
require "modules.mineable_wreckage_yields_scrap"
require "modules.rocks_heal_over_time"
require "modules.spawners_contain_biters"
require "modules.biters_yield_coins"
require 'modules.dynamic_landfill'
require 'modules.satellite_score'
require 'modules.mineable_wreckage_yields_scrap'
require 'modules.rocks_heal_over_time'
require 'modules.spawners_contain_biters'
require 'modules.biters_yield_coins'
--require "maps.modules.fluids_are_explosive"
--require "maps.modules.explosives_are_explosive"
require "modules.dangerous_nights"
require "modules.dangerous_goods"
require 'modules.dangerous_nights'
require 'modules.dangerous_goods'
local Map = require 'modules.map_info'
local unearthing_worm = require "functions.unearthing_worm"
local unearthing_biters = require "functions.unearthing_biters"
local tick_tack_trap = require "functions.tick_tack_trap"
local create_entity_chain = require "functions.create_entity_chain"
local create_tile_chain = require "functions.create_tile_chain"
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local create_entity_chain = require 'utils.functions.create_entity_chain'
local create_tile_chain = require 'utils.functions.create_tile_chain'
local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2
local event = require 'utils.event'
local table_insert = table.insert
local math_random = math.random
local map_functions = require "tools.map_functions"
local scrap = require "tools.scrap"
local map_functions = require 'utils.tools.map_functions'
local scrap = require 'utils.tools.scrap'
local disabled_for_deconstruction = {
["fish"] = true,
["rock-huge"] = true,
["rock-big"] = true,
["sand-rock-big"] = true,
["crash-site-spaceship-wreck-small-1"] = true,
["crash-site-spaceship-wreck-small-2"] = true,
["crash-site-spaceship-wreck-small-3"] = true,
["crash-site-spaceship-wreck-small-4"] = true,
["crash-site-spaceship-wreck-small-5"] = true,
["crash-site-spaceship-wreck-small-6"] = true,
}
['fish'] = true,
['rock-huge'] = true,
['rock-big'] = true,
['sand-rock-big'] = true,
['crash-site-spaceship-wreck-small-1'] = true,
['crash-site-spaceship-wreck-small-2'] = true,
['crash-site-spaceship-wreck-small-3'] = true,
['crash-site-spaceship-wreck-small-4'] = true,
['crash-site-spaceship-wreck-small-5'] = true,
['crash-site-spaceship-wreck-small-6'] = true
}
local tile_replacements = {
["grass-1"] = "dirt-7",
["grass-2"] = "dirt-6",
["grass-3"] = "dirt-5",
["grass-4"] = "dirt-4" ,
["water"] = "water-green",
["deepwater"] = "deepwater-green",
["sand-1"] = "dirt-7",
["sand-2"] = "dirt-6",
["sand-3"] = "dirt-5"
['grass-1'] = 'dirt-7',
['grass-2'] = 'dirt-6',
['grass-3'] = 'dirt-5',
['grass-4'] = 'dirt-4',
['water'] = 'water-green',
['deepwater'] = 'deepwater-green',
['sand-1'] = 'dirt-7',
['sand-2'] = 'dirt-6',
['sand-3'] = 'dirt-5'
}
local entity_replacements = {
["tree-01"] = "dead-grey-trunk",
["tree-02"] = "tree-06-brown",
["tree-03"] = "dead-grey-trunk",
["tree-04"] = "dry-hairy-tree",
["tree-05"] = "dead-grey-trunk",
["tree-06"] = "tree-06-brown",
["tree-07"] = "dry-hairy-tree",
["tree-08"] = "dead-grey-trunk",
["tree-09"] = "tree-06-brown",
["tree-02-red"] = "dry-tree",
['tree-01'] = 'dead-grey-trunk',
['tree-02'] = 'tree-06-brown',
['tree-03'] = 'dead-grey-trunk',
['tree-04'] = 'dry-hairy-tree',
['tree-05'] = 'dead-grey-trunk',
['tree-06'] = 'tree-06-brown',
['tree-07'] = 'dry-hairy-tree',
['tree-08'] = 'dead-grey-trunk',
['tree-09'] = 'tree-06-brown',
['tree-02-red'] = 'dry-tree',
--["tree-06-brown"] = "dirt",
["tree-08-brown"] = "tree-06-brown",
["tree-09-brown"] = "tree-06-brown",
["tree-09-red"] = "tree-06-brown",
["iron-ore"] = scrap.get_scrap_name(1),
["copper-ore"] = scrap.get_scrap_name(2),
["coal"] = scrap.get_scrap_name(3),
["stone"] = scrap.get_scrap_name(4)
['tree-08-brown'] = 'tree-06-brown',
['tree-09-brown'] = 'tree-06-brown',
['tree-09-red'] = 'tree-06-brown',
['iron-ore'] = scrap.get_scrap_name(1),
['copper-ore'] = scrap.get_scrap_name(2),
['coal'] = scrap.get_scrap_name(3),
['stone'] = scrap.get_scrap_name(4)
}
local wrecks = {"big-ship-wreck-1", "big-ship-wreck-2", "big-ship-wreck-3"}
local wrecks = {'big-ship-wreck-1', 'big-ship-wreck-2', 'big-ship-wreck-3'}
local scrap_buildings = {
"nuclear-reactor",
"centrifuge",
"beacon",
"chemical-plant",
"assembling-machine-1",
"assembling-machine-2",
"assembling-machine-3",
"oil-refinery",
"arithmetic-combinator",
"constant-combinator",
"decider-combinator",
"programmable-speaker",
"steam-turbine",
"steam-engine",
"chemical-plant",
"assembling-machine-1",
"assembling-machine-2",
"assembling-machine-3",
"oil-refinery",
"arithmetic-combinator",
"constant-combinator",
"decider-combinator",
"programmable-speaker",
"steam-turbine",
"steam-engine"
'nuclear-reactor',
'centrifuge',
'beacon',
'chemical-plant',
'assembling-machine-1',
'assembling-machine-2',
'assembling-machine-3',
'oil-refinery',
'arithmetic-combinator',
'constant-combinator',
'decider-combinator',
'programmable-speaker',
'steam-turbine',
'steam-engine',
'chemical-plant',
'assembling-machine-1',
'assembling-machine-2',
'assembling-machine-3',
'oil-refinery',
'arithmetic-combinator',
'constant-combinator',
'decider-combinator',
'programmable-speaker',
'steam-turbine',
'steam-engine'
}
local function shuffle(tbl)
@ -134,139 +133,137 @@ end
local function create_shipwreck(surface, position)
local raffle = {}
local loot = {
{{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(40,80)}, weight = 2, evolution_min = 0.3, evolution_max = 0.8},
{{name = "advanced-circuit", count = math_random(40,80)}, 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(30,60)}, 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(4,8)}, weight = 3, evolution_min = 0.0, evolution_max = 0.1},
{{name = "inserter", count = math_random(4,8)}, weight = 3, evolution_min = 0.0, evolution_max = 0.4},
{{name = "long-handed-inserter", count = math_random(4,8)}, weight = 3, evolution_min = 0.0, evolution_max = 0.4},
{{name = "fast-inserter", count = math_random(4,8)}, weight = 3, evolution_min = 0.1, evolution_max = 1},
{{name = "filter-inserter", count = math_random(4,8)}, weight = 1, evolution_min = 0.2, evolution_max = 1},
{{name = "stack-filter-inserter", count = math_random(2,4)}, weight = 1, evolution_min = 0.4, evolution_max = 1},
{{name = "stack-inserter", count = math_random(2,4)}, weight = 3, evolution_min = 0.3, evolution_max = 1},
{{name = "small-electric-pole", count = math_random(8,16)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
{{name = "medium-electric-pole", count = math_random(4,8)}, weight = 3, evolution_min = 0.2, evolution_max = 1},
{{name = "wooden-chest", count = math_random(16,24)}, 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(1,2)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
{{name = "assembling-machine-2", count = math_random(1,2)}, weight = 3, evolution_min = 0.2, evolution_max = 0.8},
{{name = "offshore-pump", count = 1}, weight = 2, evolution_min = 0.0, evolution_max = 0.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(40, 80)}, weight = 2, evolution_min = 0.3, evolution_max = 0.8},
{{name = 'advanced-circuit', count = math_random(40, 80)}, 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(30, 60)}, 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(4, 8)}, weight = 3, evolution_min = 0.0, evolution_max = 0.1},
{{name = 'inserter', count = math_random(4, 8)}, weight = 3, evolution_min = 0.0, evolution_max = 0.4},
{{name = 'long-handed-inserter', count = math_random(4, 8)}, weight = 3, evolution_min = 0.0, evolution_max = 0.4},
{{name = 'fast-inserter', count = math_random(4, 8)}, weight = 3, evolution_min = 0.1, evolution_max = 1},
{{name = 'filter-inserter', count = math_random(4, 8)}, weight = 1, evolution_min = 0.2, evolution_max = 1},
{{name = 'stack-filter-inserter', count = math_random(2, 4)}, weight = 1, evolution_min = 0.4, evolution_max = 1},
{{name = 'stack-inserter', count = math_random(2, 4)}, weight = 3, evolution_min = 0.3, evolution_max = 1},
{{name = 'small-electric-pole', count = math_random(8, 16)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
{{name = 'medium-electric-pole', count = math_random(4, 8)}, weight = 3, evolution_min = 0.2, evolution_max = 1},
{{name = 'wooden-chest', count = math_random(16, 24)}, 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(1, 2)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
{{name = 'assembling-machine-2', count = math_random(1, 2)}, weight = 3, evolution_min = 0.2, evolution_max = 0.8},
{{name = 'offshore-pump', count = 1}, weight = 2, evolution_min = 0.0, evolution_max = 0.1},
--{{name = "beacon", count = 1}, 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(1,2)}, 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-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 = '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(2,4)}, weight = 3, evolution_min = 0.0, evolution_max = 0.2},
{{name = "electric-mining-drill", count = math_random(2,4)}, 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 = "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 = 'burner-mining-drill', count = math_random(2, 4)}, weight = 3, evolution_min = 0.0, evolution_max = 0.2},
{{name = 'electric-mining-drill', count = math_random(2, 4)}, 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 = '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 = 'pump', count = math_random(1, 4)}, weight = 1, evolution_min = 0.3, evolution_max = 0.8},
--{{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 = '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 = '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}
}
local distance_to_center = math.sqrt(position.x^2 + position.y^2)
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 / 2500
end
if distance_to_center > 1 then distance_to_center = 1 end
if distance_to_center > 1 then
distance_to_center = 1
end
for _, t in pairs (loot) do
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 e = surface.create_entity{name = wrecks[math_random(1,#wrecks)], position = position, force = "scrap"}
for x = 1, math_random(2,3), 1 do
local loot = raffle[math_random(1,#raffle)]
local e = surface.create_entity {name = wrecks[math_random(1, #wrecks)], position = position, force = 'scrap'}
for x = 1, math_random(2, 3), 1 do
local loot = raffle[math_random(1, #raffle)]
e.insert(loot)
end
end
local function secret_shop(pos, surface)
local secret_market_items = {
{price = {{"coin", math_random(30,60)}}, offer = {type = 'give-item', item = 'construction-robot'}},
{price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'loader'}},
{price = {{"coin", math_random(200,300)}}, offer = {type = 'give-item', item = 'fast-loader'}},
{price = {{"coin", math_random(300,500)}}, offer = {type = 'give-item', item = 'express-loader'}},
{price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'locomotive'}},
{price = {{"coin", math_random(75,150)}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{"coin", math_random(2,3)}}, offer = {type = 'give-item', item = 'rail'}},
{price = {{"coin", math_random(4,12)}}, offer = {type = 'give-item', item = 'small-lamp'}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'car'}},
{price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = 'electric-furnace'}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'effectivity-module'}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'productivity-module'}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'speed-module'}},
{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'wood', count = 50}},
{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'stone', count = 50}},
{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'coal', count = 50}},
{price = {{"coin", math_random(8,16)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
{price = {{'wood', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'iron-ore', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'copper-ore', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'stone', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'coal', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'uranium-ore', math_random(8,10)}}, offer = {type = 'give-item', item = "coin"}}
{price = {{'coin', math_random(30, 60)}}, offer = {type = 'give-item', item = 'construction-robot'}},
{price = {{'coin', math_random(100, 200)}}, offer = {type = 'give-item', item = 'loader'}},
{price = {{'coin', math_random(200, 300)}}, offer = {type = 'give-item', item = 'fast-loader'}},
{price = {{'coin', math_random(300, 500)}}, offer = {type = 'give-item', item = 'express-loader'}},
{price = {{'coin', math_random(100, 200)}}, offer = {type = 'give-item', item = 'locomotive'}},
{price = {{'coin', math_random(75, 150)}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{'coin', math_random(2, 3)}}, offer = {type = 'give-item', item = 'rail'}},
{price = {{'coin', math_random(4, 12)}}, offer = {type = 'give-item', item = 'small-lamp'}},
{price = {{'coin', math_random(80, 160)}}, offer = {type = 'give-item', item = 'car'}},
{price = {{'coin', math_random(300, 600)}}, offer = {type = 'give-item', item = 'electric-furnace'}},
{price = {{'coin', math_random(80, 160)}}, offer = {type = 'give-item', item = 'effectivity-module'}},
{price = {{'coin', math_random(80, 160)}}, offer = {type = 'give-item', item = 'productivity-module'}},
{price = {{'coin', math_random(80, 160)}}, offer = {type = 'give-item', item = 'speed-module'}},
{price = {{'coin', math_random(5, 10)}}, offer = {type = 'give-item', item = 'wood', count = 50}},
{price = {{'coin', math_random(5, 10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
{price = {{'coin', math_random(5, 10)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
{price = {{'coin', math_random(5, 10)}}, offer = {type = 'give-item', item = 'stone', count = 50}},
{price = {{'coin', math_random(5, 10)}}, offer = {type = 'give-item', item = 'coal', count = 50}},
{price = {{'coin', math_random(8, 16)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
{price = {{'wood', math_random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
{price = {{'iron-ore', math_random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
{price = {{'copper-ore', math_random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
{price = {{'stone', math_random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
{price = {{'coal', math_random(10, 12)}}, offer = {type = 'give-item', item = 'coin'}},
{price = {{'uranium-ore', math_random(8, 10)}}, offer = {type = 'give-item', item = 'coin'}}
}
secret_market_items = shuffle(secret_market_items)
local market = surface.create_entity {name = "market", position = pos, force = "neutral"}
local market = surface.create_entity {name = 'market', position = pos, force = 'neutral'}
market.destructible = false
for i = 1, math.random(6, 8), 1 do
@ -277,12 +274,12 @@ end
local function place_random_scrap_entity(surface, position)
local r = math.random(1, 100)
if r < 15 then
local e = surface.create_entity({name = scrap_buildings[math.random(1, #scrap_buildings)], position = position, force = "scrap"})
if e.name == "nuclear-reactor" then
create_entity_chain(surface, {name = "heat-pipe", position = position, force = "player"}, math_random(16,32), 25)
local e = surface.create_entity({name = scrap_buildings[math.random(1, #scrap_buildings)], position = position, force = 'scrap'})
if e.name == 'nuclear-reactor' then
create_entity_chain(surface, {name = 'heat-pipe', position = position, force = 'player'}, math_random(16, 32), 25)
end
if e.name == "chemical-plant" or e.name == "steam-turbine" or e.name == "steam-engine" or e.name == "oil-refinery" then
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(8,16), 25)
if e.name == 'chemical-plant' or e.name == 'steam-turbine' or e.name == 'steam-engine' or e.name == 'oil-refinery' then
create_entity_chain(surface, {name = 'pipe', position = position, force = 'player'}, math_random(8, 16), 25)
end
e.active = false
return
@ -298,33 +295,36 @@ local function place_random_scrap_entity(surface, position)
-- return
--end
if r < 100 then
local e = surface.create_entity({name = "gun-turret", position = position, force = "scrap_defense"})
e.insert({name = "piercing-rounds-magazine", count = math.random(8, 128)})
local e = surface.create_entity({name = 'gun-turret', position = position, force = 'scrap_defense'})
e.insert({name = 'piercing-rounds-magazine', count = math.random(8, 128)})
return
end
local e = surface.create_entity({name = "storage-tank", position = position, force = "scrap", direction = math.random(0, 3)})
local fluids = {"crude-oil", "lubricant", "heavy-oil", "light-oil", "petroleum-gas", "sulfuric-acid", "water"}
local e = surface.create_entity({name = 'storage-tank', position = position, force = 'scrap', direction = math.random(0, 3)})
local fluids = {'crude-oil', 'lubricant', 'heavy-oil', 'light-oil', 'petroleum-gas', 'sulfuric-acid', 'water'}
e.fluidbox[1] = {name = fluids[math.random(1, #fluids)], amount = math.random(15000, 25000)}
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(6,8), 1)
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(6,8), 1)
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(15,30), 80)
create_entity_chain(surface, {name = 'pipe', position = position, force = 'player'}, math_random(6, 8), 1)
create_entity_chain(surface, {name = 'pipe', position = position, force = 'player'}, math_random(6, 8), 1)
create_entity_chain(surface, {name = 'pipe', position = position, force = 'player'}, math_random(15, 30), 80)
end
local function create_inner_content(surface, pos, noise)
if math_random(1, 90000) == 1 then secret_shop(pos, surface) return end
if math_random(1, 90000) == 1 then
secret_shop(pos, surface)
return
end
if math_random(1, 102400) == 1 then
if noise < 0.3 or noise > -0.3 then
map_functions.draw_noise_entity_ring(surface, pos, "laser-turret", "scrap_defense", 0, 2)
map_functions.draw_noise_entity_ring(surface, pos, "accumulator", "scrap_defense", 2, 3)
map_functions.draw_noise_entity_ring(surface, pos, "substation", "scrap_defense", 3, 4)
map_functions.draw_noise_entity_ring(surface, pos, "solar-panel", "scrap_defense", 4, 6)
map_functions.draw_noise_entity_ring(surface, pos, "stone-wall", "scrap_defense", 6, 7)
map_functions.draw_noise_entity_ring(surface, pos, 'laser-turret', 'scrap_defense', 0, 2)
map_functions.draw_noise_entity_ring(surface, pos, 'accumulator', 'scrap_defense', 2, 3)
map_functions.draw_noise_entity_ring(surface, pos, 'substation', 'scrap_defense', 3, 4)
map_functions.draw_noise_entity_ring(surface, pos, 'solar-panel', 'scrap_defense', 4, 6)
map_functions.draw_noise_entity_ring(surface, pos, 'stone-wall', 'scrap_defense', 6, 7)
create_tile_chain(surface, {name = "concrete", position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = "concrete", position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = 'concrete', position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = 'concrete', position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = 'stone-path', position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = 'stone-path', position = pos}, math_random(16, 32), 50)
--create_entity_chain(surface, {name = "laser-turret", position = pos, force = "scrap_defense"}, 1, 25)
--create_entity_chain(surface, {name = "accumulator", position = pos, force = "scrap_defense"}, math_random(2, 4), 1)
--create_entity_chain(surface, {name = "substation", position = pos, force = "scrap_defense"}, math_random(6, 8), 1)
@ -333,10 +333,10 @@ local function create_inner_content(surface, pos, noise)
return
end
if math_random(1, 650) == 1 then
if surface.can_place_entity({name = "biter-spawner", position = pos}) then
if surface.can_place_entity({name = 'biter-spawner', position = pos}) then
local distance_to_center = pos.x ^ 2 + pos.y ^ 2
if distance_to_center > 35000 then
surface.create_entity({name = "biter-spawner", position = pos})
surface.create_entity({name = 'biter-spawner', position = pos})
end
end
return
@ -344,23 +344,27 @@ local function create_inner_content(surface, pos, noise)
end
local function process_entity(e)
if not e.valid then return end
if not e.valid then
return
end
if entity_replacements[e.name] then
if e.type == "tree" then
if math_random(1,2) == 1 then
if e.type == 'tree' then
if math_random(1, 2) == 1 then
e.surface.create_entity({name = entity_replacements[e.name], position = e.position})
end
else
e.surface.create_entity({name = entity_replacements[e.name], position = e.position, force = "scrap"})
e.surface.create_entity({name = entity_replacements[e.name], position = e.position, force = 'scrap'})
end
e.destroy()
return
end
if e.type == "unit-spawner" then
if e.type == 'unit-spawner' then
local scraps = scrap.get_scraps()
for _, wreck in pairs (e.surface.find_entities_filtered({area = {{e.position.x - 4, e.position.y - 4},{e.position.x + 4, e.position.y + 4}}, name = scraps})) do
if wreck.valid then wreck.destroy() end
for _, wreck in pairs(e.surface.find_entities_filtered({area = {{e.position.x - 4, e.position.y - 4}, {e.position.x + 4, e.position.y + 4}}, name = scraps})) do
if wreck.valid then
wreck.destroy()
end
end
return
end
@ -382,16 +386,16 @@ local function on_chunk_generated(event)
table_insert(tiles, {name = tile_replacements[tile.name], position = pos})
end
if not tile.collides_with("player-layer") then
if not tile.collides_with('player-layer') then
local noise = get_noise(1, pos)
if noise > 0.43 or noise < -0.43 then
if math_random(1,3) ~= 1 then
if math_random(1, 3) ~= 1 then
scrap.create_scrap(surface, pos)
else
if math_random(1,512) == 1 then
if math_random(1, 512) == 1 then
create_shipwreck(surface, pos)
else
if math_random(1,512) == 1 then
if math_random(1, 512) == 1 then
--luacheck: ignore(surface, pos)
end
end
@ -400,7 +404,6 @@ local function on_chunk_generated(event)
create_inner_content(surface, pos, noise)
end
end
end
end
surface.set_tiles(tiles, true)
@ -409,22 +412,26 @@ local function on_chunk_generated(event)
process_entity(e)
end
if global.spawn_generated then return end
if left_top.x < 96 then return end
if global.spawn_generated then
return
end
if left_top.x < 96 then
return
end
map_functions.draw_rainbow_patch_v2({x = 0, y = 0}, surface, 12, 2500)
local p = surface.find_non_colliding_position("character-corpse", {2,-2}, 32, 2)
local e = surface.create_entity({name = "character-corpse", position = p})
local p = surface.find_non_colliding_position('character-corpse', {2, -2}, 32, 2)
local e = surface.create_entity({name = 'character-corpse', position = p})
local scraps = scrap.get_scrap_true_array()
for _, e in pairs (surface.find_entities_filtered({area = {{-50, -50},{50, 50}}})) do
local distance_to_center = math.sqrt(e.position.x^2 + e.position.y^2)
for _, e in pairs(surface.find_entities_filtered({area = {{-50, -50}, {50, 50}}})) do
local distance_to_center = math.sqrt(e.position.x ^ 2 + e.position.y ^ 2)
if e.valid then
if distance_to_center < 8 and scraps[e.name] and math_random(1,5) ~= 1 then
if distance_to_center < 8 and scraps[e.name] and math_random(1, 5) ~= 1 then
e.destroy()
end
end
if e.valid then
if distance_to_center < 30 and e.name == "gun-turret" then
if distance_to_center < 30 and e.name == 'gun-turret' then
e.destroy()
end
end
@ -433,16 +440,20 @@ local function on_chunk_generated(event)
end
local function on_chunk_charted(event)
if not global.chunks_charted then global.chunks_charted = {} end
if not global.chunks_charted then
global.chunks_charted = {}
end
local surface = game.surfaces[event.surface_index]
local position = event.position
if global.chunks_charted[tostring(position.x) .. tostring(position.y)] then return end
if global.chunks_charted[tostring(position.x) .. tostring(position.y)] then
return
end
global.chunks_charted[tostring(position.x) .. tostring(position.y)] = true
local decorative_names = {}
for k,v in pairs(game.decorative_prototypes) do
for k, v in pairs(game.decorative_prototypes) do
if v.autoplace_specification then
decorative_names[#decorative_names+1] = k
decorative_names[#decorative_names + 1] = k
end
end
surface.regenerate_decorative(decorative_names, {position})
@ -450,12 +461,12 @@ local function on_chunk_charted(event)
if math_random(1, 16) ~= 1 then
return
end
local pos = {x = position.x * 32 + math_random(1,32), y = position.y * 32 + math_random(1,32)}
local pos = {x = position.x * 32 + math_random(1, 32), y = position.y * 32 + math_random(1, 32)}
local noise = get_noise(1, pos)
if noise > 0.4 or noise < -0.4 then
return
end
local distance_to_center = math.sqrt(pos.x^2 + pos.y^2)
local distance_to_center = math.sqrt(pos.x ^ 2 + pos.y ^ 2)
local size = 7 + math.floor(distance_to_center * 0.0075)
if size > 20 then
size = 20
@ -473,28 +484,30 @@ end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
if player.online_time == 0 then
player.insert({name = "pistol", count = 1})
player.insert({name = "firearm-magazine", count = 16})
player.insert({name = 'pistol', count = 1})
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.forces['player'].technologies['optics'].researched = true
game.surfaces["nauvis"].ticks_per_day = game.surfaces["nauvis"].ticks_per_day * 2
game.surfaces["nauvis"].min_brightness = 0.08
game.surfaces["nauvis"].daytime = 0.7
game.surfaces['nauvis'].ticks_per_day = game.surfaces['nauvis'].ticks_per_day * 2
game.surfaces['nauvis'].min_brightness = 0.08
game.surfaces['nauvis'].daytime = 0.7
game.create_force("scrap")
game.create_force("scrap_defense")
game.create_force('scrap')
game.create_force('scrap_defense')
game.forces.player.set_friend('scrap', true)
game.forces.enemy.set_friend('scrap', true)
game.forces.scrap.set_friend('player', true)
game.forces.scrap.set_friend('enemy', true)
game.forces.scrap.share_chart = false
game.forces.scrap_defense.set_friend("enemy",true)
game.forces.enemy.set_friend("scrap_defense", true)
game.forces.scrap_defense.set_friend('enemy', true)
game.forces.enemy.set_friend('scrap_defense', true)
global.map_init_done = true
end
@ -502,29 +515,39 @@ end
local function on_force_created(event)
event.force.set_friend(game.forces.scrap, true)
game.forces.scrap.set_friend(event.force, true)
event.force.technologies["optics"].researched = true
event.force.technologies['optics'].researched = true
end
local function on_player_mined_entity(event)
local entity = event.entity
if not entity.valid then return end
if not entity.valid then
return
end
local scraps = {
["crash-site-spaceship-wreck-small-1"] = true,
["crash-site-spaceship-wreck-small-2"] = true,
["crash-site-spaceship-wreck-small-3"] = true,
["crash-site-spaceship-wreck-small-4"] = true,
["crash-site-spaceship-wreck-small-5"] = true,
["crash-site-spaceship-wreck-small-6"] = true
['crash-site-spaceship-wreck-small-1'] = true,
['crash-site-spaceship-wreck-small-2'] = true,
['crash-site-spaceship-wreck-small-3'] = true,
['crash-site-spaceship-wreck-small-4'] = true,
['crash-site-spaceship-wreck-small-5'] = true,
['crash-site-spaceship-wreck-small-6'] = true
}
if scraps[entity.name] then
if math_random(1,40) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,12)) end
if math_random(1,80) == 1 then unearthing_worm(entity.surface, entity.position) end
if math_random(1,160) == 1 then tick_tack_trap(entity.surface, entity.position) end
if math_random(1, 40) == 1 then
unearthing_biters(entity.surface, entity.position, math_random(4, 12))
end
if math_random(1, 80) == 1 then
unearthing_worm(entity.surface, entity.position)
end
if math_random(1, 160) == 1 then
tick_tack_trap(entity.surface, entity.position)
end
end
if entity.force.name ~= "scrap" then return end
if entity.force.name ~= 'scrap' then
return
end
local positions = {}
local r = math.ceil(entity.prototype.max_health / 32)
for x = r * -1, r, 1 do
@ -537,8 +560,8 @@ local function on_player_mined_entity(event)
if not positions[i] then
return
end
if math_random(1,3) ~= 1 then
unearthing_biters(entity.surface, positions[i], math_random(5,10))
if math_random(1, 3) ~= 1 then
unearthing_biters(entity.surface, positions[i], math_random(5, 10))
else
unearthing_worm(entity.surface, positions[i])
end
@ -554,32 +577,35 @@ local function on_research_finished(event)
end
local on_init = function()
local T = Map.Pop_info()
T.main_caption = "J u n k y a r d"
T.sub_caption = " ..the scrap is your friend.."
T.text = table.concat({
"Citizen Log #468-2A-3287, Freelancer Cole\n",
"\n",
"To whoever is reading this message,\n",
"i have most likely already left this doomed place, or... well..\n",
"\n",
"I am stranded on this foreign world since months and i have given up on fixing my ships transceiver.\n",
local T = Map.Pop_info()
T.main_caption = 'J u n k y a r d'
T.sub_caption = ' ..the scrap is your friend..'
T.text =
table.concat(
{
'Citizen Log #468-2A-3287, Freelancer Cole\n',
'\n',
'To whoever is reading this message,\n',
'i have most likely already left this doomed place, or... well..\n',
'\n',
'I am stranded on this foreign world since months and i have given up on fixing my ships transceiver.\n',
"Things aren't looking too good, i must admit.\n",
"The rust and devastation tells a story of an advanced civilization,\n",
"which seems to have evacuated their home long time ago.\n",
"\n",
"Any natural resources are rare and the ones worth while are too hard for me to reach.\n",
"Luckily, the wrecks yield all kinds of useful scraps, but also various dangers.\n",
"Almost lost half a leg some days ago while digging out a crate.\n",
"\n",
"The wildlife is extremely aggressive, especially at the time of night.\n",
"Most of these insect appearing like creatures seem to live underground.\n",
"Stay near your light sources, if you want to have a chance of surviving here!!\n",
"\n",
"I must make a move now, hopefully will find those missing parts.\n",
"\n",
"###Log End###"
})
'The rust and devastation tells a story of an advanced civilization,\n',
'which seems to have evacuated their home long time ago.\n',
'\n',
'Any natural resources are rare and the ones worth while are too hard for me to reach.\n',
'Luckily, the wrecks yield all kinds of useful scraps, but also various dangers.\n',
'Almost lost half a leg some days ago while digging out a crate.\n',
'\n',
'The wildlife is extremely aggressive, especially at the time of night.\n',
'Most of these insect appearing like creatures seem to live underground.\n',
'Stay near your light sources, if you want to have a chance of surviving here!!\n',
'\n',
'I must make a move now, hopefully will find those missing parts.\n',
'\n',
'###Log End###'
}
)
T.main_caption_color = {r = 150, g = 150, b = 0}
T.sub_caption_color = {r = 0, g = 150, b = 0}
end

View File

@ -9,7 +9,7 @@ require 'modules.rocks_heal_over_time'
require 'maps.junkyard_pvp.share_chat'
require 'modules.mineable_wreckage_yields_scrap'
local Team = require 'maps.junkyard_pvp.team'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Map = require 'modules.map_info'
local math_random = math.random
local Public = {}

View File

@ -3,7 +3,7 @@ local math_abs = math.abs
local math_random = math.random
local math_floor = math.floor
local Treasure = require 'maps.junkyard_pvp.treasure'
local Map_functions = require 'tools.map_functions'
local Map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
local spawner_raffle = {'biter-spawner', 'biter-spawner', 'biter-spawner', 'spitter-spawner'}
@ -96,11 +96,7 @@ function Public.create_mirror_surface()
end
end
end
for _, e in pairs(
surface.find_entities_filtered(
{area = {{cargo_wagon_position.x - r, cargo_wagon_position.y - r}, {cargo_wagon_position.x + r, cargo_wagon_position.y + r}}, force = {'neutral', 'enemy'}}
)
) do
for _, e in pairs(surface.find_entities_filtered({area = {{cargo_wagon_position.x - r, cargo_wagon_position.y - r}, {cargo_wagon_position.x + r, cargo_wagon_position.y + r}}, force = {'neutral', 'enemy'}})) do
if math.sqrt(e.position.x ^ 2 + e.position.y ^ 2) < r then
e.destroy()
end

View File

@ -8,11 +8,11 @@ require 'modules.satellite_score'
local Event = require 'utils.event'
local Server = require 'utils.server'
local Global = require 'utils.global'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local Score = require 'utils.gui.score'
local unique_rooms = require 'maps.labyrinth_unique_rooms'
local SoftReset = require 'functions.soft_reset'
local SoftReset = require 'utils.functions.soft_reset'
local Autostash = require 'modules.autostash'
local BottomFrame = require 'utils.gui.bottom_frame'
local this = {
@ -1022,7 +1022,9 @@ end
local function on_entity_died(event)
local entity = event.entity
if not entity or not entity.valid then return end
if not entity or not entity.valid then
return
end
local name = entity.name
local position = entity.position
local evolution = game.forces.enemy.evolution_factor
@ -1045,7 +1047,7 @@ local function on_entity_died(event)
for _ = 1, math.random(t[2], t[3]), 1 do
local p = surface.find_non_colliding_position(t[1], position, 6, 1)
if p then
surface.create_entity{name = t[1], position = p}
surface.create_entity {name = t[1], position = p}
end
end
end
@ -1235,7 +1237,9 @@ local loaders = {
['express-loader'] = true
}
local function on_built_entity(event)
if not event.created_entity or not event.created_entity.valid then return end
if not event.created_entity or not event.created_entity.valid then
return
end
local get_score = Score.get_table().score_table
local name = event.created_entity.name
if inserters[name] then

View File

@ -12,7 +12,7 @@ require 'modules.flashlight_toggle_button'
local simplex_noise = require 'utils.simplex_noise'.d2
local event = require 'utils.event'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local math_random = math.random
require 'utils.table'

View File

@ -1,5 +1,5 @@
--luacheck: ignore
require 'functions.maze'
require 'utils.functions.maze'
local event = require 'utils.event'

View File

@ -1,7 +1,7 @@
--luacheck: ignore
local Public = {}
local LootRaffle = require "functions.loot_raffle"
local LootRaffle = require "utils.functions.loot_raffle"
local Get_noise = require "utils.get_noise"
local safe_zone_radius = 16

View File

@ -18,7 +18,7 @@ local difficulty_factor = 4
local event = require 'utils.event'
local math_random = math.random
local insert = table.insert
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'
local simplex_noise = simplex_noise.d2

View File

@ -4,8 +4,8 @@
global.offline_loot = true
local darkness = false
require 'functions.soft_reset'
require 'functions.basic_markets'
require 'utils.functions.soft_reset'
require 'utils.functions.basic_markets'
local Gui = require 'utils.gui'
local Map_score = require 'utils.gui.map_score'
@ -25,7 +25,7 @@ local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
require 'maps.mountain_fortress_v2.flamethrower_nerf'
local BiterRolls = require 'modules.wave_defense.biter_rolls'
local BiterHealthBooster = require 'modules.biter_health_booster'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Pets = require 'modules.biter_pets'
local Map = require 'modules.map_info'
local WD = require 'modules.wave_defense.table'

View File

@ -2,7 +2,7 @@
local Biters = require 'modules.wave_defense.biter_rolls'
local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
local Treasure = require 'maps.mountain_fortress_v2.treasure'
local Market = require 'functions.basic_markets'
local Market = require 'utils.functions.basic_markets'
local math_random = math.random
local math_floor = math.floor
local math_abs = math.abs

View File

@ -5,7 +5,7 @@ local math_random = math.random
local math_floor = math.floor
local math_abs = math.abs
local LootRaffle = require 'functions.loot_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local blacklist = {
['cargo-wagon'] = true,

View File

@ -1,7 +1,7 @@
local Public = require 'maps.mountain_fortress_v3.table'
local ICW = require 'maps.mountain_fortress_v3.icw.main'
local Task = require 'utils.task_token'
local MapFunctions = require 'tools.map_functions'
local MapFunctions = require 'utils.tools.map_functions'
local random = math.random
local floor = math.floor

View File

@ -1,4 +1,4 @@
local LootRaffle = require 'functions.loot_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local Public = require 'maps.mountain_fortress_v3.table'
local random = math.random
local abs = math.abs

View File

@ -3,7 +3,7 @@ local Public = {}
local math_random = math.random
local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
local GetNoise = require 'utils.get_noise'
local LootRaffle = require 'functions.loot_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local wagon_raffle = {'cargo-wagon', 'cargo-wagon', 'cargo-wagon', 'locomotive', 'fluid-wagon'}
local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}

View File

@ -10,7 +10,7 @@ local Team = require 'maps.native_war.team'
local Terrain = require 'maps.native_war.terrain'
local Init = require 'maps.native_war.init'
local Settings = require 'maps.native_war.settings'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Map = require 'maps.native_war.map_info'
local Team_manager = require 'maps.native_war.team_manager'
local math_random = math.random

View File

@ -1,7 +1,7 @@
--luacheck: ignore
local math_abs = math.abs
local math_random = math.random
local Map_functions = require 'tools.map_functions'
local Map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local Public = {}
@ -86,8 +86,7 @@ local function create_markets(surface)
global.market1 = e
local energy_source = {type = 'electric', buffer_capacity = '10GJ', usage_priority = 'tertiary', input_flow_limit = '1GW', output_flow_limit = '0W', drain = '0W'}
local eei =
surface.create_entity({type = 'electric-energy-interface', name = 'electric-energy-interface', energy_source = energy_source, position = {-200, -2}, force = 'west'})
local eei = surface.create_entity({type = 'electric-energy-interface', name = 'electric-energy-interface', energy_source = energy_source, position = {-200, -2}, force = 'west'})
local ep = surface.create_entity({name = 'small-electric-pole', position = {-200, -5}, force = 'west'})
ep.destructible = false
@ -109,8 +108,7 @@ local function create_markets(surface)
global.market = f
local energy_source = {type = 'electric', buffer_capacity = '10GJ', usage_priority = 'tertiary', input_flow_limit = '1GW', output_flow_limit = '0W', drain = '0W'}
local eei2 =
surface.create_entity({type = 'electric-energy-interface', name = 'electric-energy-interface', energy_source = energy_source, position = {201, -2}, force = 'east'})
local eei2 = surface.create_entity({type = 'electric-energy-interface', name = 'electric-energy-interface', energy_source = energy_source, position = {201, -2}, force = 'east'})
local ep2 = surface.create_entity({name = 'small-electric-pole', position = {200, -5}, force = 'east'})
ep2.destructible = false
@ -346,12 +344,7 @@ local function out_of_map_area(event)
local p = {x = left_top.x + x, y = left_top.y + y}
if is_out_of_map(p) then
if
(p.x == -137 or p.x == -138 or p.x == -102 or p.x == -103 or p.x == -78 or p.x == -77 or p.x == -42 or p.x == -43 or p.x == -17 or p.x == -18 or p.x == 17 or
p.x == 18 or
p.x == 42 or
p.x == 43 or
p.x == 77 or
p.x == 78) and
(p.x == -137 or p.x == -138 or p.x == -102 or p.x == -103 or p.x == -78 or p.x == -77 or p.x == -42 or p.x == -43 or p.x == -17 or p.x == -18 or p.x == 17 or p.x == 18 or p.x == 42 or p.x == 43 or p.x == 77 or p.x == 78) and
(p.y == -32 or p.y == -33 or p.y == -95 or p.y == -96)
then
surface.set_tiles({{name = 'hazard-concrete-right', position = p}}, true)
@ -436,11 +429,7 @@ local function out_of_map_area(event)
e.minable = false
end
elseif
(p.x == 137 or p.x == 138 or p.x == 102 or p.x == 103 or p.x == 78 or p.x == 77 or p.x == 42 or p.x == 43 or p.x == 17 or p.x == 18 or p.x == -17 or p.x == -18 or
p.x == -42 or
p.x == -43 or
p.x == -77 or
p.x == -78) and
(p.x == 137 or p.x == 138 or p.x == 102 or p.x == 103 or p.x == 78 or p.x == 77 or p.x == 42 or p.x == 43 or p.x == 17 or p.x == 18 or p.x == -17 or p.x == -18 or p.x == -42 or p.x == -43 or p.x == -77 or p.x == -78) and
(p.y == 32 or p.y == 33 or p.y == 95 or p.y == 96)
then
surface.set_tiles({{name = 'hazard-concrete-right', position = p}}, true)

View File

@ -4,7 +4,7 @@
local event = require 'utils.event'
local math_random = math.random
local insert = table.insert
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'
local simplex_noise = simplex_noise.d2
require 'maps.nightfall_map_intro'
@ -420,14 +420,8 @@ local function generate_spawn_area(surface)
for y = -160, 160, 1 do
local pos = {x = x, y = y}
if pos.x > fort_size * -1 and pos.x < fort_size and pos.y > fort_size * -1 and pos.y < fort_size then
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
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
table.insert(turrets, {name = 'gun-turret', position = {x = pos.x, y = pos.y}, force = 'player'})
end
end
@ -440,10 +434,7 @@ local function generate_spawn_area(surface)
table.insert(tiles, {name = 'stone-path', position = {x = pos.x, y = pos.y}})
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
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
if math_random(1, 3) ~= 1 then
table.insert(entities, {name = 'stone-wall', position = {x = pos.x, y = pos.y}, force = 'player'})
end

View File

@ -16,11 +16,11 @@ require 'modules.trees_randomly_die'
require 'maps.overgrowth_map_info'
local Reset = require 'functions.soft_reset'
local kaboom = require 'functions.omegakaboom'
local Reset = require 'utils.functions.soft_reset'
local kaboom = require 'utils.functions.omegakaboom'
local Difficulty = require 'modules.difficulty_vote'
local unearthing_biters = require 'functions.unearthing_biters'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local event = require 'utils.event'
local math_random = math.random

View File

@ -13,7 +13,7 @@ local Session = require 'utils.datastore.session_data'
local Difficulty = require 'modules.difficulty_vote'
local Map = require 'modules.map_info'
local Event = require 'utils.event'
local Reset = require 'functions.soft_reset'
local Reset = require 'utils.functions.soft_reset'
local Server = require 'utils.server'
local Poll = require 'utils.gui.poll'
local boss_biter = require 'maps.pidgeotto.boss_biters'

View File

@ -1,6 +1,6 @@
local Event = require 'utils.event'
local Builder = require 'maps.pidgeotto.b'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'.d2
local FDT = require 'maps.pidgeotto.table'
local math_random = math.random

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ local Session = require 'utils.datastore.session_data'
local Event = require 'utils.event'
local Freeplay = require 'utils.freeplay'
local Server = require 'utils.server'
local MapFuntions = require 'tools.map_functions'
local MapFuntions = require 'utils.tools.map_functions'
local CommonFunctions = require 'utils.common'
local LayersFunctions = require 'maps.planet_prison.mod.layers'
local AIFunctions = require 'maps.planet_prison.ai'

View File

@ -14,7 +14,7 @@ local difficulties_votes = {
local Get_noise = require 'utils.get_noise'
local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
local LootRaffle = require 'functions.loot_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local map_height = 64

View File

@ -1,8 +1,8 @@
--luacheck: ignore
local event = require 'utils.event'
local simplex_noise = require 'utils.simplex_noise'.d2
local rainbow_colors = require 'tools.rainbow_colors'
local map_functions = require 'tools.map_functions'
local rainbow_colors = require 'utils.tools.rainbow_colors'
local map_functions = require 'utils.tools.map_functions'
require 'modules.satellite_score'
local ore_spawn_raffle = {'iron-ore', 'iron-ore', 'iron-ore', 'iron-ore', 'copper-ore', 'copper-ore', 'copper-ore', 'coal', 'coal', 'coal', 'stone', 'uranium-ore', 'crude-oil'}

View File

@ -10,7 +10,7 @@ local event = require 'utils.event'
local table_insert = table.insert
local math_random = math.random
local simplex_noise = require 'utils.simplex_noise'.d2
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local disabled_for_deconstruction = {
['fish'] = true

View File

@ -163,8 +163,8 @@ local function on_player_joined_game(event)
end
end
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local function on_player_mined_entity(event)
local entity = event.entity

View File

@ -2,7 +2,7 @@ require 'modules.no_deconstruction_of_neutral_entities'
require 'modules.satellite_score'
require 'modules.mineable_wreckage_yields_scrap'
local LootRaffle = require 'functions.loot_raffle'
local LootRaffle = require 'utils.functions.loot_raffle'
local Get_noise = require 'utils.get_noise'
local math_random = math.random
local math_floor = math.floor

View File

@ -1,7 +1,7 @@
local Event = require 'utils.event'
local Server = require 'utils.server'
local ScenarioTable = require 'maps.scrap_towny_ffa.table'
local SoftReset = require 'functions.soft_reset'
local SoftReset = require 'utils.functions.soft_reset'
local Token = require 'utils.token'
local math_random = math.random

View File

@ -2,9 +2,9 @@ local Event = require 'utils.event'
local Evolution = require 'maps.scrap_towny_ffa.evolution'
local Town_center = require 'maps.scrap_towny_ffa.town_center'
local Scrap = require 'maps.scrap_towny_ffa.scrap'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local tick_tack_trap = require 'functions.tick_tack_trap'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local math_random = math.random

View File

@ -6,7 +6,7 @@ require 'modules.dynamic_landfill'
require 'modules.spawners_contain_biters'
require 'modules.satellite_score'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
--require "rewards"
local function shuffle(tbl)
@ -627,8 +627,7 @@ local function on_entity_died(event)
end
if entity_drop_amount[event.entity.name] then
if game.forces.enemy.evolution_factor < 0.5 then
local amount =
math.ceil(math.random(entity_drop_amount[event.entity.name].low, entity_drop_amount[event.entity.name].high) * (0.5 - game.forces.enemy.evolution_factor) * 2, 0)
local amount = math.ceil(math.random(entity_drop_amount[event.entity.name].low, entity_drop_amount[event.entity.name].high) * (0.5 - game.forces.enemy.evolution_factor) * 2, 0)
event.entity.surface.spill_item_stack(event.entity.position, {name = ore_spill_raffle[math.random(1, #ore_spill_raffle)], count = amount}, true)
end
end

View File

@ -18,9 +18,9 @@ require 'modules.rocks_broken_paint_tiles'
require 'modules.rpg'
require 'modules.hunger'
local shapes = require 'tools.shapes'
local shapes = require 'utils.tools.shapes'
local event = require 'utils.event'
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2

View File

@ -1,5 +1,5 @@
--luacheck: ignore
local Basic_markets = require 'functions.basic_markets'
local Basic_markets = require 'utils.functions.basic_markets'
local Biter_pets = require 'modules.biter_pets'
local get_noise = require 'maps.stone_maze.noise'

View File

@ -1,5 +1,5 @@
--luacheck: ignore
local Basic_markets = require 'functions.basic_markets'
local Basic_markets = require 'utils.functions.basic_markets'
local get_noise = require 'maps.stone_maze.noise'
local room = {}

View File

@ -9,7 +9,7 @@ require 'modules.hunger'
require 'modules.no_turrets'
--essentials
require 'functions.maze'
require 'utils.functions.maze'
require 'modules.biters_yield_coins'
require 'modules.rocks_yield_ore'
require 'modules.mineable_wreckage_yields_scrap'
@ -35,7 +35,7 @@ local multirooms = {}
multirooms['2x2'] = require 'maps.stone_maze.2x2_rooms'
multirooms['3x3'] = require 'maps.stone_maze.3x3_rooms'
map_functions = require 'tools.map_functions'
map_functions = require 'utils.tools.map_functions'
grid_size = 24
--manual_mining_speed_modifier = 1
main_ground_tile = 'dirt-3'
@ -76,8 +76,7 @@ local function draw_depth_gui()
if player.gui.top.evolution_gui then
player.gui.top.evolution_gui.destroy()
end
local element =
player.gui.top.add({type = 'sprite-button', name = 'evolution_gui', caption = 'Depth: ' .. global.maze_depth, tooltip = 'Delve deep and face increased dangers.'})
local element = player.gui.top.add({type = 'sprite-button', name = 'evolution_gui', caption = 'Depth: ' .. global.maze_depth, tooltip = 'Delve deep and face increased dangers.'})
local style = element.style
style.minimal_height = 38
style.maximal_height = 38

View File

@ -20,7 +20,7 @@ require 'modules.evolution_extended'
local event = require 'utils.event'
local math_random = math.random
local insert = table.insert
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'
local simplex_noise = simplex_noise.d2

View File

@ -4,7 +4,7 @@
local event = require 'utils.event'
local table_insert = table.insert
local math_random = math.random
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local arena_size = 160
local function shuffle(tbl)

View File

@ -118,7 +118,7 @@ local table_of_slots = {
local table_of_ores = {'iron-ore', 'copper-ore', 'stone', 'coal'}
local map_functions = require 'tools.map_functions'
local map_functions = require 'utils.tools.map_functions'
local event = require 'utils.event'
@ -457,8 +457,7 @@ function draw_gui_status(player)
element_label.style.font_color = table_of_colors.white
local element_label =
element_frame.add({type = 'label', caption = math.floor(global.table_of_properties[global.table_of_properties[player.force.name].enemy].available_tickets)})
local element_label = element_frame.add({type = 'label', caption = math.floor(global.table_of_properties[global.table_of_properties[player.force.name].enemy].available_tickets)})
element_label.style.left_padding = 20
@ -836,10 +835,7 @@ function create_a_base(force_name, base_position)
end
if
object.name == 'infinity-chest' or object.name == 'substation' or object.name == 'big-electric-pole' or object.name == 'medium-electric-pole' or
object.name == 'inserter' or
object.name == 'accumulator' or
object.name == 'solar-panel' or
object.name == 'infinity-chest' or object.name == 'substation' or object.name == 'big-electric-pole' or object.name == 'medium-electric-pole' or object.name == 'inserter' or object.name == 'accumulator' or object.name == 'solar-panel' or
object.name == 'gun-turret'
then
entity.destructible = false
@ -896,14 +892,11 @@ function create_a_spot(spot_name, spot_position, spot_blueprint)
}
)
local draw_spot_force =
rendering.draw_text({text = spot.force.name, surface = surface, target = {spot.position.x, spot.position.y + 0.5}, color = spot.color, scale = 5, alignment = 'center'})
local draw_spot_force = rendering.draw_text({text = spot.force.name, surface = surface, target = {spot.position.x, spot.position.y + 0.5}, color = spot.color, scale = 5, alignment = 'center'})
local draw_spot_value =
rendering.draw_text({text = spot.value, surface = surface, target = {spot.position.x, spot.position.y - 4}, color = spot.color, scale = 5, alignment = 'center'})
local draw_spot_value = rendering.draw_text({text = spot.value, surface = surface, target = {spot.position.x, spot.position.y - 4}, color = spot.color, scale = 5, alignment = 'center'})
local draw_spot_name =
rendering.draw_text({text = spot.name, surface = surface, target = {spot.position.x, spot.position.y - 2}, color = spot.color, scale = 5, alignment = 'center'})
local draw_spot_name = rendering.draw_text({text = spot.name, surface = surface, target = {spot.position.x, spot.position.y - 2}, color = spot.color, scale = 5, alignment = 'center'})
local table_of_drawings = {name = draw_spot_name, value = draw_spot_value, force = draw_spot_force, border = draw_spot_border}
@ -957,10 +950,7 @@ function create_a_spot(spot_name, spot_position, spot_blueprint)
table.insert(table_of_entities, entity)
end
table.insert(
global.table_of_spots,
{properties = table_of_properties, drawings = table_of_drawings, players = table_of_players, positions = table_of_positions, entities = table_of_entities}
)
table.insert(global.table_of_spots, {properties = table_of_properties, drawings = table_of_drawings, players = table_of_players, positions = table_of_positions, entities = table_of_entities})
end
function create_a_point_of_interest(poi_blueprint, poi_position)
@ -1139,10 +1129,7 @@ function event_on_click_join(player)
-- draw_gui_spawn( player ) -- only for tests
for _, spot in pairs(global.table_of_spots) do
player.force.chart(
game.surfaces.tank_conquest,
{{x = spot.properties.position.x - 10, y = spot.properties.position.y - 10}, {x = spot.properties.position.x + 10, y = spot.properties.position.y + 10}}
)
player.force.chart(game.surfaces.tank_conquest, {{x = spot.properties.position.x - 10, y = spot.properties.position.y - 10}, {x = spot.properties.position.x + 10, y = spot.properties.position.y + 10}})
end
game.print(player.name .. ' joined ' .. global.table_of_properties[player.force.name].icon)
@ -1240,10 +1227,7 @@ local function on_tick(event)
for _, player in pairs(game.connected_players) do
if player.force.name == spot.properties.force.name and spot.properties.value > 0 then
player.force.chart(
game.surfaces.tank_conquest,
{{x = spot.properties.position.x - 10, y = spot.properties.position.y - 10}, {x = spot.properties.position.x + 10, y = spot.properties.position.y + 10}}
)
player.force.chart(game.surfaces.tank_conquest, {{x = spot.properties.position.x - 10, y = spot.properties.position.y - 10}, {x = spot.properties.position.x + 10, y = spot.properties.position.y + 10}})
end
end
@ -1294,10 +1278,7 @@ local function on_tick(event)
global.table_of_properties.countdown_in_seconds = global.table_of_properties.countdown_in_seconds - 1
end
if
global.table_of_properties.countdown_in_seconds < 0 or global.table_of_properties.force_player_one.available_tickets < 0 or
global.table_of_properties.force_player_two.available_tickets < 0
then
if global.table_of_properties.countdown_in_seconds < 0 or global.table_of_properties.force_player_one.available_tickets < 0 or global.table_of_properties.force_player_two.available_tickets < 0 then
if global.table_of_properties.force_player_one.available_tickets == global.table_of_properties.force_player_two.available_tickets then
game.print('The battle is over. The round ended in a draw.')
elseif global.table_of_properties.force_player_one.available_tickets > global.table_of_properties.force_player_two.available_tickets then
@ -1493,23 +1474,11 @@ local function on_tick(event)
if game.surfaces.tank_conquest ~= nil and #game.connected_players and #global.table_of_spots then
for _, player in pairs(game.connected_players) do
for _, spot in pairs(global.table_of_spots) do
if
player.force.is_chunk_charted(
game.surfaces.tank_conquest,
{x = math.floor(spot.properties.position.x / 32), y = math.floor(spot.properties.position.y / 32)}
)
then
local chart_tags =
player.force.find_chart_tags(
game.surfaces.tank_conquest,
{{spot.properties.position.x - 1, spot.properties.position.y - 1}, {spot.properties.position.x + 1, spot.properties.position.y + 1}}
)
if player.force.is_chunk_charted(game.surfaces.tank_conquest, {x = math.floor(spot.properties.position.x / 32), y = math.floor(spot.properties.position.y / 32)}) then
local chart_tags = player.force.find_chart_tags(game.surfaces.tank_conquest, {{spot.properties.position.x - 1, spot.properties.position.y - 1}, {spot.properties.position.x + 1, spot.properties.position.y + 1}})
if #chart_tags == 0 then
player.force.add_chart_tag(
game.surfaces.tank_conquest,
{icon = {type = 'virtual', name = 'signal-' .. spot.properties.name}, position = spot.properties.position}
)
player.force.add_chart_tag(game.surfaces.tank_conquest, {icon = {type = 'virtual', name = 'signal-' .. spot.properties.name}, position = spot.properties.position})
end
end
end
@ -1712,10 +1681,7 @@ local function on_player_changed_position(event)
end
for _, position in pairs(spot_item.positions) do
if
math.floor(player.position.x) == position.x and math.floor(player.position.y) == position.y or
math.ceil(player.position.x) == position.x and math.ceil(player.position.y) == position.y
then
if math.floor(player.position.x) == position.x and math.floor(player.position.y) == position.y or math.ceil(player.position.x) == position.x and math.ceil(player.position.y) == position.y then
if global.table_of_spots[spot_index].players[player.index] == nil then
global.table_of_spots[spot_index].players[player.index] = player
@ -1805,16 +1771,12 @@ local function on_player_died(event)
if event.cause and event.cause.valid then
if event.cause.name == 'character' then
player_death_message =
global.table_of_properties[player.force.name].icon ..
' ' .. player.name .. ' was killed by ' .. global.table_of_properties[event.cause.player.force.name].icon .. ' ' .. event.cause.player.name .. '.'
player_death_message = global.table_of_properties[player.force.name].icon .. ' ' .. player.name .. ' was killed by ' .. global.table_of_properties[event.cause.player.force.name].icon .. ' ' .. event.cause.player.name .. '.'
elseif event.cause.name == 'car' or event.cause.name == 'tank' or event.cause.name == 'train' then
local driver = event.cause.get_driver()
if driver.player then
player_death_message =
global.table_of_properties[player.force.name].icon ..
' ' .. player.name .. ' was killed with a vehicle by ' .. global.table_of_properties[driver.player.force.name].icon .. ' ' .. driver.player.name .. '.'
player_death_message = global.table_of_properties[player.force.name].icon .. ' ' .. player.name .. ' was killed with a vehicle by ' .. global.table_of_properties[driver.player.force.name].icon .. ' ' .. driver.player.name .. '.'
else
player_death_message = global.table_of_properties[player.force.name].icon .. ' ' .. player.name .. ' was killed by run over.'
end

View File

@ -15,12 +15,12 @@ require 'modules.rocks_yield_ore'
require 'modules.biters_yield_coins'
require 'modules.mineable_wreckage_yields_scrap'
local shapes = require 'tools.shapes'
local shapes = require 'utils.tools.shapes'
local Event = require 'utils.event'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local tick_tack_trap = require 'functions.tick_tack_trap'
local map_functions = require 'tools.map_functions'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local map_functions = require 'utils.tools.map_functions'
local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2

View File

@ -5,7 +5,7 @@
local event = require 'utils.event'
local bricks = require 'maps.tetris.bricks'
local connect_belts = require 'functions.connect_belts'
local connect_belts = require 'utils.functions.connect_belts'
local playfield_left_top = {x = -17, y = -18}
local playfield_width = 12
@ -219,10 +219,7 @@ local function add_score_points(amount)
end
local function move_lines_down(surface, y)
local entities =
surface.find_entities_filtered(
{area = {{playfield_area.left_top.x, playfield_area.left_top.y}, {playfield_area.left_top.x + playfield_width + 1, playfield_area.left_top.y + y + 1}}, force = 'enemy'}
)
local entities = surface.find_entities_filtered({area = {{playfield_area.left_top.x, playfield_area.left_top.y}, {playfield_area.left_top.x + playfield_width + 1, playfield_area.left_top.y + y + 1}}, force = 'enemy'})
for _, e in pairs(entities) do
if e.valid then
e.clone {position = {e.position.x, e.position.y + 1}, surface = surface, force = 'enemy'}
@ -419,14 +416,7 @@ local function move(surface, item)
return
end
for k, p in pairs(global.active_brick.positions) do
if
not global.tetris_grid[
coord_string(
math.floor(global.active_brick.positions[k].x + move_translations[item][1]),
math.floor(global.active_brick.positions[k].y + move_translations[item][2])
)
]
then
if not global.tetris_grid[coord_string(math.floor(global.active_brick.positions[k].x + move_translations[item][1]), math.floor(global.active_brick.positions[k].y + move_translations[item][2]))] then
return
end
end

View File

@ -2,8 +2,8 @@
local Event = require 'utils.event'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'utils.functions.unearthing_biters'
local immune_tiles = {
['concrete'] = true,
@ -33,9 +33,7 @@ local function on_player_changed_position(event)
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
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 > 25 and circuit.disabled == false then

View File

@ -2,7 +2,7 @@
--[[
Exchange Strings:
for "terrain_layouts.scrap_01"
for "utils.terrain_layouts.scrap_01"
>>>eNpjYBBiEGQAgwYHBgYHBw6W5PzEHAaGA0Begz2I5krOLyhIL
dLNL0pFFuZMLipNSdXNz0RVnJqXmlupm5RYnAoRgmCOzKL8PHQTW
ItL8vNQRUqKUlOLQazVq1bZgUS5S4sS8zJLc9H1MjCeOHC8uKFFj

View File

@ -9,7 +9,7 @@ local Utils = require 'utils.core'
local Color = require 'utils.color_presets'
local Server = require 'utils.server'
local Jail = require 'utils.datastore.jail_data'
local FancyTime = require 'tools.fancy_time'
local FancyTime = require 'utils.tools.fancy_time'
local Task = require 'utils.task'
local Token = require 'utils.token'
local Discord = require 'utils.discord_handler'

View File

@ -498,6 +498,7 @@ local function create_admin_panel(data)
end
end
local listable_players = frame.add({type = 'checkbox', name = 'admin_listable_players', caption = 'Toggle between all players or connected players.', state = false})
local drop_down = frame.add({type = 'drop-down', name = 'admin_player_select', items = player_names, selected_index = selected_index})
drop_down.style.minimal_width = 326
drop_down.style.right_padding = 12

View File

@ -3,7 +3,7 @@ local math_random = math.random
local table_insert = table.insert
local table_remove = table.remove
local NoiseVector = require 'functions.noise_vector_path'
local NoiseVector = require 'utils.functions.noise_vector_path'
local function get_vector()
local x = 1000 - math_random(0, 2000)

Some files were not shown because too many files have changed in this diff Show More