1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-14 02:34:09 +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 ---------------- ---------------- MOSTLY TERRAIN LAYOUTS HERE ----------------
--require 'terrain_layouts.winter' --require 'utils.terrain_layouts.winter'
--require 'terrain_layouts.caves' --require 'utils.terrain_layouts.caves'
--require 'terrain_layouts.cone_to_east' --require 'utils.terrain_layouts.cone_to_east'
--require 'terrain_layouts.biters_and_resources_east' --require 'utils.terrain_layouts.biters_and_resources_east'
--require 'terrain_layouts.scrap_01' --require 'utils.terrain_layouts.scrap_01'
--require 'terrain_layouts.scrap_02' --require 'utils.terrain_layouts.scrap_02'
--require 'terrain_layouts.watery_world' --require 'utils.terrain_layouts.watery_world'
--require 'terrain_layouts.tree_01' --require 'utils.terrain_layouts.tree_01'
--------------------------------------------------------------- ---------------------------------------------------------------
--- this file exists only for the panel to sync and start from within the panel --- 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 Event = require 'utils.event'
local math_random = math.random 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 function on_player_joined_game(event)
local player = game.players[event.player_index] local player = game.players[event.player_index]

View File

@ -1,5 +1,5 @@
--luacheck:ignore --luacheck:ignore
local simplex_noise = require 'tools.simplex_noise' local simplex_noise = require 'utils.tools.simplex_noise'
local Event = require 'utils.event' local Event = require 'utils.event'
biter_battles_terrain = {} biter_battles_terrain = {}
@ -471,10 +471,7 @@ function biter_battles_terrain.generate_spawn_ores(ore_layout)
end end
end end
surface.set_tiles(tiles, true) surface.set_tiles(tiles, true)
local entities = 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}})
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 for _, entity in pairs(entities) do
if entity.type == 'simple-entity' or entity.type == 'tree' or entity.type == 'resource' then if entity.type == 'simple-entity' or entity.type == 'tree' or entity.type == 'resource' then
entity.destroy() entity.destroy()

View File

@ -1,7 +1,7 @@
--luacheck: ignore --luacheck: ignore
local Public = {} local Public = {}
local LootRaffle = require 'functions.loot_raffle' local LootRaffle = require 'utils.functions.loot_raffle'
local BiterRaffle = require 'functions.biter_raffle' local BiterRaffle = require 'utils.functions.biter_raffle'
local bb_config = require 'maps.biter_battles_v2.config' local bb_config = require 'maps.biter_battles_v2.config'
local table_insert = table.insert 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 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}}) surface.set_tiles({{name = get_replacement_tile(surface, t.position), position = t.position}})
end end
for _, t in pairs( 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.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}}) surface.set_tiles({{name = get_replacement_tile(surface, t.position), position = t.position}})
end end

View File

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

View File

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

View File

@ -3,7 +3,7 @@ local Public = {}
local Constants = require 'maps.cave_miner_v2.constants' local Constants = require 'maps.cave_miner_v2.constants'
local Functions = require 'maps.cave_miner_v2.functions' 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_floor = math.floor
local math_random = math.random local math_random = math.random

View File

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

View File

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

View File

@ -5,9 +5,9 @@ local Chrono = require 'maps.chronosphere.chrono'
local Upgrades = require 'maps.chronosphere.upgrades' local Upgrades = require 'maps.chronosphere.upgrades'
local Public = {} local Public = {}
local tick_tack_trap = require 'functions.tick_tack_trap' local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local unearthing_worm = require 'functions.unearthing_worm' local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters' local unearthing_biters = require 'utils.functions.unearthing_biters'
local math_random = math.random local math_random = math.random
local math_floor = math.floor local math_floor = math.floor
@ -162,10 +162,7 @@ function Public.shred_simple_entities(entity)
if game.forces.enemy.evolution_factor < 0.25 then if game.forces.enemy.evolution_factor < 0.25 then
return return
end end
local simple_entities = 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}}})
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 for _, simple_entity in pairs(simple_entities) do
if simple_entity.valid then if simple_entity.valid then
simple_entity.destroy() simple_entity.destroy()
@ -447,10 +444,7 @@ end
function Public.check_if_overstayed() function Public.check_if_overstayed()
local objective = Chrono_table.get_table() local objective = Chrono_table.get_table()
if 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.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 objective.overstaycount = objective.overstaycount + 1
end end
end end

View File

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

View File

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

View File

@ -1,6 +1,6 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Builder = require 'maps.crab_defender.b' 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 simplex_noise = require 'utils.simplex_noise'.d2
local FDT = require 'maps.crab_defender.table' local FDT = require 'maps.crab_defender.table'
local math_random = math.random local math_random = math.random

View File

@ -12,7 +12,7 @@ local math_floor = math.floor
local math_abs = math.abs local math_abs = math.abs
local math_sqrt = math.sqrt 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 function get_noise(name, pos)
local seed = game.surfaces[1].map_gen_settings.seed local seed = game.surfaces[1].map_gen_settings.seed

View File

@ -1,7 +1,7 @@
-- crossing -- by mewmew -- -- crossing -- by mewmew --
local Event = require 'utils.event' 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 simplex_noise = require 'utils.simplex_noise'.d2
local function on_player_joined_game(event) local function on_player_joined_game(event)

View File

@ -6,7 +6,7 @@ require 'modules.flashlight_toggle_button'
require 'maps.deep_jungle.generate' require 'maps.deep_jungle.generate'
local Event = require 'utils.event' 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 Task = require 'utils.task'
local DPT = require 'maps.deep_jungle.table' local DPT = require 'maps.deep_jungle.table'
local random = math.random local random = math.random

View File

@ -1,5 +1,5 @@
local Functions = require 'maps.dungeons.functions' 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 DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table local table_shuffle_table = table.shuffle_table

View File

@ -1,5 +1,5 @@
local Functions = require 'maps.dungeons.functions' 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 DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_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 LOOT_MULTIPLIER = 3000
local EVOLUTION_PER_FLOOR = 0.06 local EVOLUTION_PER_FLOOR = 0.06
local BiterRaffle = require 'functions.biter_raffle' local BiterRaffle = require 'utils.functions.biter_raffle'
local LootRaffle = require 'functions.loot_raffle' local LootRaffle = require 'utils.functions.loot_raffle'
local Get_noise = require 'utils.get_noise' local Get_noise = require 'utils.get_noise'
local DungeonsTable = require 'maps.dungeons.table' local DungeonsTable = require 'maps.dungeons.table'
@ -22,7 +22,8 @@ local math_floor = math.floor
-- floor 4 = 8512 .. 9024 -- floor 4 = 8512 .. 9024
-- floor 9 = 16512 .. 17024 -- floor 9 = 16512 .. 17024
-- floor 19 = 32512 .. 33024 -- floor 19 = 32512 .. 33024
LootRaffle.TweakItemWorth({ LootRaffle.TweakItemWorth(
{
['modular-armor'] = 512, -- floors 1-5 from research.lua ['modular-armor'] = 512, -- floors 1-5 from research.lua
['power-armor'] = 4096, -- floors 8-13 from research.lua ['power-armor'] = 4096, -- floors 8-13 from research.lua
['personal-laser-defense-equipment'] = 1536, -- floors 10-14 from research.lua ['personal-laser-defense-equipment'] = 1536, -- floors 10-14 from research.lua
@ -42,8 +43,9 @@ LootRaffle.TweakItemWorth({
['slowdown-capsule'] = 32, ['slowdown-capsule'] = 32,
['defender-capsule'] = 96, ['defender-capsule'] = 96,
['distractor-capsule'] = 512, ['distractor-capsule'] = 512,
['destroyer-capsule'] = 2048, ['destroyer-capsule'] = 2048
}) }
)
function Public.get_dungeon_evolution_factor(surface_index) function Public.get_dungeon_evolution_factor(surface_index)
local dungeontable = DungeonsTable.get_dungeontable() local dungeontable = DungeonsTable.get_dungeontable()
@ -470,7 +472,7 @@ function Public.rocky_loot(event)
local player = game.players[event.player_index] local player = game.players[event.player_index]
local amount = math.ceil(get_ore_amount(player.surface.index)) local amount = math.ceil(get_ore_amount(player.surface.index))
local rock_mining 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 if floor < 10 then
-- early game science uses less copper and more iron/stone -- 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'} 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' require 'modules.satellite_score'
local MapInfo = require 'modules.map_info' local MapInfo = require 'modules.map_info'
local Room_generator = require 'functions.room_generator' local Room_generator = require 'utils.functions.room_generator'
require 'modules.rpg' require 'modules.rpg'
local BiterHealthBooster = require 'modules.biter_health_booster' 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 Functions = require 'maps.dungeons.functions'
local Get_noise = require 'utils.get_noise' local Get_noise = require 'utils.get_noise'
local DungeonsTable = require 'maps.dungeons.table' local DungeonsTable = require 'maps.dungeons.table'

View File

@ -8,10 +8,10 @@ require 'modules.charging_station'
local MIN_ROOMS_TO_DESCEND = 100 local MIN_ROOMS_TO_DESCEND = 100
local MapInfo = require 'modules.map_info' 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 RPG = require 'modules.rpg.main'
local BiterHealthBooster = require 'modules.biter_health_booster_v2' 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 Functions = require 'maps.dungeons.functions'
local Get_noise = require 'utils.get_noise' local Get_noise = require 'utils.get_noise'
local Alert = require 'utils.alert' local Alert = require 'utils.alert'
@ -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_changed_surface, on_player_changed_surface)
Event.add(defines.events.on_player_respawned, on_player_respawned) Event.add(defines.events.on_player_respawned, on_player_respawned)
Changelog.SetVersions({ Changelog.SetVersions(
{
{ver = 'next', date = 'the future', desc = 'Make suggestions in the comfy #dungeons discord channel'}, {ver = 'next', date = 'the future', desc = 'Make suggestions in the comfy #dungeons discord channel'},
{ ver = '1.1.1', date = '2022-04-10', desc = [[ {
ver = '1.1.1',
date = '2022-04-10',
desc = [[
Balancing patch Balancing patch
* Evolution goes up faster with floor level 0.05/level -> 0.06/level; e.g. floor 20 now like floor 24 before * 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 * Now require 100 open rooms to descend
@ -869,8 +873,12 @@ Balancing patch
* Require getting to room 100 before you can descend * Require getting to room 100 before you can descend
* Science from rooms 40-160+2.5*floor to 60-300+2.5*floor * Science from rooms 40-160+2.5*floor to 60-300+2.5*floor
* Atomic bomb research moved to 40-50 * 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. * All research is now found at random.
* Red science floors 0-1 * Red science floors 0-1
* Green on floors 1-5 * Green on floors 1-5
@ -891,6 +899,8 @@ Balancing patch
* Autostash and corpse clearing from Mountain Fortress enabled * Autostash and corpse clearing from Mountain Fortress enabled
* Harder rooms will occur somewhat farther out on the early floors. * Harder rooms will occur somewhat farther out on the early floors.
* Spawners and worm counts bounded in early rooms. * 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 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 Task = require 'utils.task'
local Token = require 'utils.token' local Token = require 'utils.token'
local Public = {} local Public = {}
@ -142,7 +142,8 @@ local function is_container_position_valid(expanse, position)
end end
local function create_costs_render(entity, name, offset) local function create_costs_render(entity, name, offset)
local id = rendering.draw_sprite{ local id =
rendering.draw_sprite {
sprite = 'virtual-signal/signal-grey', sprite = 'virtual-signal/signal-grey',
surface = entity.surface, surface = entity.surface,
target = entity, target = entity,
@ -152,7 +153,8 @@ local function create_costs_render(entity, name, offset)
target_offset = {offset, -1.5}, target_offset = {offset, -1.5},
only_in_alt_mode = true only_in_alt_mode = true
} }
local id2 = rendering.draw_sprite{ local id2 =
rendering.draw_sprite {
sprite = 'item/' .. name, sprite = 'item/' .. name,
surface = entity.surface, surface = entity.surface,
target = entity, target = entity,

View File

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

View File

@ -1,6 +1,6 @@
--luacheck: ignore --luacheck: ignore
local Event = require 'utils.event' 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 simplex_noise = require 'utils.simplex_noise'.d2
local FDT = require 'maps.fish_defender.table' local FDT = require 'maps.fish_defender.table'
local math_random = math.random local math_random = math.random

View File

@ -18,8 +18,8 @@ local event = require 'utils.event'
local Server = require 'utils.server' local Server = require 'utils.server'
local boss_biter = require 'maps.fish_defender.boss_biters' local boss_biter = require 'maps.fish_defender.boss_biters'
local Score = require 'utils.gui.score' local Score = require 'utils.gui.score'
require 'functions.boss_unit' require 'utils.functions.boss_unit'
local map_functions = require 'tools.map_functions' local map_functions = require 'utils.tools.map_functions'
local Difficulty = require 'modules.difficulty_vote' local Difficulty = require 'modules.difficulty_vote'
local math_random = math.random local math_random = math.random
local insert = table.insert 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 Difficulty = require 'modules.difficulty_vote'
local Map = require 'modules.map_info' local Map = require 'modules.map_info'
local Event = require 'utils.event' local Event = require 'utils.event'
local Reset = require 'functions.soft_reset' local Reset = require 'utils.functions.soft_reset'
local Server = require 'utils.server' local Server = require 'utils.server'
local Session = require 'utils.datastore.session_data' local Session = require 'utils.datastore.session_data'
local Poll = require 'utils.gui.poll' local Poll = require 'utils.gui.poll'

View File

@ -1,5 +1,5 @@
local Event = require 'utils.event' 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 simplex_noise = require 'utils.simplex_noise'.d2
local Public = require 'maps.fish_defender_v2.table' local Public = require 'maps.fish_defender_v2.table'
local Task = require 'utils.task' local Task = require 'utils.task'

View File

@ -7,7 +7,7 @@ require 'modules.no_deconstruction_of_neutral_entities'
require 'modules.spawners_contain_biters' require 'modules.spawners_contain_biters'
local event = require 'utils.event' 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 simplex_noise = require 'utils.simplex_noise'.d2
local math_random = math.random local math_random = math.random
@ -358,12 +358,7 @@ local function draw_ores(surface, position)
end end
local function draw_water(surface, position) local function draw_water(surface, position)
map_functions.draw_noise_tile_circle( 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))
{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 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 if math_random(1, 12) == 1 then
surface.create_entity({name = 'fish', position = tile.position}) surface.create_entity({name = 'fish', position = tile.position})
@ -406,21 +401,13 @@ end
local function draw_rocks(surface, position) local function draw_rocks(surface, position)
local r = math_random(0, 100) local r = math_random(0, 100)
if r < 50 then if r < 50 then
surface.create_entity( 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}})
{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 return
end end
if r <= 100 then if r <= 100 then
surface.create_entity( 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}})
{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.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 return
end end
end end
@ -545,11 +532,7 @@ local function on_entity_died(event)
return return
end end
if event.entity.type == 'tree' then if event.entity.type == 'tree' then
for _, entity in pairs( 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
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 if entity.valid then
entity.destroy() entity.destroy()
end end

View File

@ -2,7 +2,7 @@
--map by mewmew and kyte --map by mewmew and kyte
require 'maps.island_troopers.map_intro' require 'maps.island_troopers.map_intro'
require 'functions.noise_vector_path' require 'utils.functions.noise_vector_path'
require 'modules.shopping_chests' require 'modules.shopping_chests'
require 'modules.no_turrets' require 'modules.no_turrets'
require 'modules.dangerous_goods' 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_entity_died, on_entity_died)
event.add(defines.events.on_player_joined_game, on_player_joined_game) 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 --luacheck: ignore
local Map_functions = require 'tools.map_functions' local Map_functions = require 'utils.tools.map_functions'
local Server = require 'utils.server' local Server = require 'utils.server'
local Get_noise = require 'utils.get_noise' local Get_noise = require 'utils.get_noise'
local Autostash = require 'modules.autostash' local Autostash = require 'modules.autostash'
@ -38,7 +38,9 @@ local function protect(entity, operable)
end end
function Public.place_mixed_ore(event, journey) 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 surface = event.surface
local x = event.area.left_top.x + math_random(0, 31) local x = event.area.left_top.x + math_random(0, 31)
local y = event.area.left_top.y + 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', alignment = 'center',
scale_with_zoom = false scale_with_zoom = false
} }
local hp = rendering.draw_text { local hp =
rendering.draw_text {
text = {'journey.beacon_hp', journey.beacon_objective_health}, text = {'journey.beacon_hp', journey.beacon_objective_health},
surface = surface, surface = surface,
target = beacon, target = beacon,
@ -110,8 +113,12 @@ end
local function drop_player_items(journey, player) local function drop_player_items(journey, player)
local character = player.character local character = player.character
if not character then return end if not character then
if not character.valid then return end return
end
if not character.valid then
return
end
player.clear_cursor() player.clear_cursor()
@ -142,8 +149,12 @@ end
function Public.clear_player(player) function Public.clear_player(player)
local character = player.character local character = player.character
if not character then return end if not character then
if not character.valid then return end return
end
if not character.valid then
return
end
player.character.destroy() player.character.destroy()
player.set_controller({type = defines.controllers.god}) player.set_controller({type = defines.controllers.god})
player.create_character() player.create_character()
@ -153,7 +164,9 @@ end
local function remove_offline_players(maximum_age_in_hours) local function remove_offline_players(maximum_age_in_hours)
local maximum_age_in_ticks = maximum_age_in_hours * 216000 local maximum_age_in_ticks = maximum_age_in_hours * 216000
local t = game.tick - maximum_age_in_ticks local t = game.tick - maximum_age_in_ticks
if t < 0 then return end if t < 0 then
return
end
local players_to_remove = {} local players_to_remove = {}
for _, player in pairs(game.players) do for _, player in pairs(game.players) do
if player.last_online < t then if player.last_online < t then
@ -216,9 +229,13 @@ local function delete_nauvis_chunks(journey)
local surface = game.surfaces.nauvis local surface = game.surfaces.nauvis
if not journey.nauvis_chunk_positions then if not journey.nauvis_chunk_positions then
journey.nauvis_chunk_positions = {} 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 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 for _, player in pairs(game.players) do
local button = player.gui.top.add({type = 'sprite-button', name = 'chunk_progress', caption = ''}) local button = player.gui.top.add({type = 'sprite-button', name = 'chunk_progress', caption = ''})
button.style.font = 'heading-1' button.style.font = 'heading-1'
@ -230,7 +247,9 @@ local function delete_nauvis_chunks(journey)
end end
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 for c = 1, 12, 1 do
local chunk_position = journey.nauvis_chunk_positions[journey.size_of_nauvis_chunk_positions] 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} local caption = {'journey.chunks_delete', journey.size_of_nauvis_chunk_positions}
for _, player in pairs(game.connected_players) do 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 end
return true return true
end end
function Public.mothership_message_queue(journey) function Public.mothership_message_queue(journey)
local text = journey.mothership_messages[1] local text = journey.mothership_messages[1]
if not text then return end if not text then
return
end
if text ~= '' then if text ~= '' then
game.print({'journey.mothership_format', text}) game.print({'journey.mothership_format', text})
end end
@ -260,8 +283,12 @@ end
function Public.deny_building(event) function Public.deny_building(event)
local entity = event.created_entity local entity = event.created_entity
if not entity.valid then return end if not entity.valid then
if entity.surface.name ~= 'mothership' then return end return
end
if entity.surface.name ~= 'mothership' then
return
end
if Constants.build_type_whitelist[entity.type] then if Constants.build_type_whitelist[entity.type] then
entity.destructible = false entity.destructible = false
return return
@ -271,9 +298,15 @@ end
function Public.register_built_silo(event, journey) function Public.register_built_silo(event, journey)
local entity = event.created_entity local entity = event.created_entity
if not entity.valid then return end if not entity.valid then
if entity.surface.index ~= 1 then return end return
if entity.type ~= 'rocket-silo' then return end end
if entity.surface.index ~= 1 then
return
end
if entity.type ~= 'rocket-silo' then
return
end
entity.auto_launch = false entity.auto_launch = false
table.insert(journey.rocket_silos, entity) table.insert(journey.rocket_silos, entity)
end end
@ -387,11 +420,19 @@ function Public.draw_gui(journey)
end end
local function is_mothership(position) local function is_mothership(position)
if math.abs(position.x) > Constants.mothership_radius then return false end if math.abs(position.x) > Constants.mothership_radius then
if math.abs(position.y) > Constants.mothership_radius then return false end return false
end
if math.abs(position.y) > Constants.mothership_radius then
return false
end
local p = {x = position.x, y = position.y} local p = {x = position.x, y = position.y}
if p.x > 0 then p.x = p.x + 1 end if p.x > 0 then
if p.y > 0 then p.y = p.y + 1 end 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) local d = math.sqrt(p.x ^ 2 + p.y ^ 2)
if d < Constants.mothership_radius then if d < Constants.mothership_radius then
return true return true
@ -423,7 +464,7 @@ function Public.export_journey(journey, import_flag)
bonus_goods = journey.bonus_goods, bonus_goods = journey.bonus_goods,
world_selectors = journey.world_selectors, world_selectors = journey.world_selectors,
mothership_cargo = journey.mothership_cargo, 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() local secs = Server.get_current_time()
if not secs then if not secs then
@ -522,7 +563,9 @@ function Public.hard_reset(journey)
journey.world_selectors = {} journey.world_selectors = {}
journey.reroll_selector = {activation_level = 0} 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.mothership_speed = 0.5
journey.characters_in_mothership = 0 journey.characters_in_mothership = 0
journey.world_color_filters = {} 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 x = Constants.mothership_radius * -1, Constants.mothership_radius, 1 do
for y = 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} 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
end end
@ -591,14 +636,17 @@ function Public.draw_mothership(journey)
end end
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) surface.set_tiles({{name = 'lab-dark-1', position = tile.position}}, true)
end end
for k, area in pairs(Constants.world_selector_areas) do for k, area in pairs(Constants.world_selector_areas) do
journey.world_selectors[k].rectangles = {} journey.world_selectors[k].rectangles = {}
local position = area.left_top local position = area.left_top
local rectangle = rendering.draw_rectangle { local rectangle =
rendering.draw_rectangle {
width = 1, width = 1,
filled = true, filled = true,
surface = surface, surface = surface,
@ -609,7 +657,8 @@ function Public.draw_mothership(journey)
only_in_alt_mode = false only_in_alt_mode = false
} }
table.insert(journey.world_selectors[k].rectangles, rectangle) 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, width = 8,
filled = false, filled = false,
surface = surface, surface = surface,
@ -621,7 +670,8 @@ function Public.draw_mothership(journey)
} }
end end
journey.reroll_selector.rectangle = rendering.draw_rectangle { journey.reroll_selector.rectangle =
rendering.draw_rectangle {
width = 8, width = 8,
filled = true, filled = true,
surface = surface, surface = surface,
@ -631,7 +681,8 @@ function Public.draw_mothership(journey)
draw_on_ground = true, draw_on_ground = true,
only_in_alt_mode = false only_in_alt_mode = false
} }
journey.reroll_selector.border = rendering.draw_rectangle { journey.reroll_selector.border =
rendering.draw_rectangle {
width = 8, width = 8,
filled = false, filled = false,
surface = surface, surface = surface,
@ -660,7 +711,9 @@ function Public.draw_mothership(journey)
for m = -1, 1, 2 do for m = -1, 1, 2 do
local x = Constants.mothership_radius - 3 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 y = Constants.mothership_radius * 0.5 - 7
local turret = surface.create_entity({name = 'artillery-turret', position = {x * m, y}, force = 'player'}) local turret = surface.create_entity({name = 'artillery-turret', position = {x * m, y}, force = 'player'})
turret.direction = 4 turret.direction = 4
@ -729,22 +782,32 @@ end
local function animate_selectors(journey) local function animate_selectors(journey)
for k, world_selector in pairs(journey.world_selectors) do for k, world_selector in pairs(journey.world_selectors) do
local activation_level = journey.world_selectors[k].activation_level local activation_level = journey.world_selectors[k].activation_level
if activation_level < 0.2 then activation_level = 0.2 end if activation_level < 0.2 then
if activation_level > 1 then activation_level = 1 end activation_level = 0.2
end
if activation_level > 1 then
activation_level = 1
end
for _, rectangle in pairs(world_selector.rectangles) do for _, rectangle in pairs(world_selector.rectangles) do
local color = Constants.world_selector_colors[k] 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}) rendering.set_color(rectangle, {r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255})
end end
end end
local activation_level = journey.reroll_selector.activation_level local activation_level = journey.reroll_selector.activation_level
if activation_level < 0.2 then activation_level = 0.2 end if activation_level < 0.2 then
if activation_level > 1 then activation_level = 1 end activation_level = 0.2
end
if activation_level > 1 then
activation_level = 1
end
local color = Constants.reroll_selector_area_color 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}) 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 end
local function draw_background(journey, surface) 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 local speed = journey.mothership_speed
for c = 1, 16 * speed, 1 do for c = 1, 16 * speed, 1 do
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)] 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 if math.random(1, 90) == 1 then
local position_x = math.random(64, 160) local position_x = math.random(64, 160)
local position_y = 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
if math.random(1, 2) == 1 then position_y = position_y * -1 end 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'}) surface.create_entity({name = 'big-worm-turret', position = {position_x, position_y}, force = 'enemy'})
end end
end end
@ -782,7 +849,6 @@ local function roll_bonus_goods(journey, trait, amount)
for key, numbers in pairs(loot) do for key, numbers in pairs(loot) do
local loot_table = Constants.starter_goods_pool[key] local loot_table = Constants.starter_goods_pool[key]
if #bonus_goods < (amount or 3) and math.random(numbers[1], numbers[2]) >= 1 then if #bonus_goods < (amount or 3) and math.random(numbers[1], numbers[2]) >= 1 then
local item = loot_table[math.random(1, #loot_table)] local item = loot_table[math.random(1, #loot_table)]
bonus_goods[#bonus_goods + 1] = {item[1], math.random(item[2], item[3])} bonus_goods[#bonus_goods + 1] = {item[1], math.random(item[2], item[3])}
end end
@ -803,15 +869,15 @@ function Public.set_world_selectors(journey)
scale = 1.5, scale = 1.5,
font = 'default-large-bold', font = 'default-large-bold',
alignment = 'center', alignment = 'center',
scale_with_zoom = false, scale_with_zoom = false
}, },
rendering.draw_sprite { rendering.draw_sprite {
sprite = 'item/satellite', sprite = 'item/satellite',
surface = surface, surface = surface,
y_scale = 1.5, y_scale = 1.5,
x_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 = {} 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 limits = {6, Constants.unique_world_traits[world_selector.world_trait].mods}
local counts = {0, 0} local counts = {0, 0}
local i = 1 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 while (limits[1] + limits[2] > counts[1] + counts[2]) and i < #modifier_names do
local modifier = modifier_names[i] local modifier = modifier_names[i]
local data = Constants.modifiers[modifier] 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) world_selector.bonus_goods = roll_bonus_goods(journey, world_selector.world_trait)
::skip_reroll:: ::skip_reroll::
table.insert(texts, rendering.draw_text{ table.insert(
texts,
rendering.draw_text {
text = Constants.unique_world_traits[world_selector.world_trait].name, text = Constants.unique_world_traits[world_selector.world_trait].name,
surface = surface, surface = surface,
target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier}, 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', font = 'default-large-bold',
alignment = 'center', alignment = 'center',
scale_with_zoom = false scale_with_zoom = false
}) }
)
for k2, modifier in pairs(modifiers) do for k2, modifier in pairs(modifiers) do
y_modifier = y_modifier + 0.8 y_modifier = y_modifier + 0.8
local text = '' local text = ''
if modifier.value > 0 then text = text .. '+' end if modifier.value > 0 then
text = text .. '+'
end
text = text .. modifier.value .. '% ' text = text .. modifier.value .. '% '
text = text .. Constants.modifiers[modifier.name].name text = text .. Constants.modifiers[modifier.name].name
@ -913,7 +986,9 @@ function Public.set_world_selectors(journey)
color = {0, 200, 0, 255} color = {0, 200, 0, 255}
end end
table.insert(texts, rendering.draw_text{ table.insert(
texts,
rendering.draw_text {
text = text, text = text,
surface = surface, surface = surface,
target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier}, 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', font = 'default-large',
alignment = 'center', alignment = 'center',
scale_with_zoom = false scale_with_zoom = false
}) }
)
end end
y_modifier = y_modifier + 0.85 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, text = 'Fuel requirement +' .. world_selector.fuel_requirement,
surface = surface, surface = surface,
target = {position.x + Constants.world_selector_width * 0.5, position.y + y_modifier}, 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', font = 'default-large',
alignment = 'center', alignment = 'center',
scale_with_zoom = false scale_with_zoom = false
}) }
table.insert(texts, rendering.draw_sprite{ )
table.insert(
texts,
rendering.draw_sprite {
sprite = 'item/uranium-fuel-cell', sprite = 'item/uranium-fuel-cell',
surface = surface, 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 y_modifier = y_modifier + 1.1
local x_modifier = -0.5 local x_modifier = -0.5
for k2, good in pairs(world_selector.bonus_goods) do 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], text = '+' .. good[2],
surface = surface, surface = surface,
target = {position.x + x_modifier, position.y + y_modifier}, target = {position.x + x_modifier, position.y + y_modifier},
@ -959,13 +1042,18 @@ function Public.set_world_selectors(journey)
table.insert(texts, render_id) table.insert(texts, render_id)
x_modifier = x_modifier + 0.95 x_modifier = x_modifier + 0.95
if good[2] >= 10 then x_modifier = x_modifier + 0.18 end if good[2] >= 10 then
if good[2] >= 100 then x_modifier = x_modifier + 0.18 end 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], sprite = 'item/' .. good[1],
surface = surface, 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) table.insert(texts, render_id)
@ -990,9 +1078,13 @@ function Public.delete_nauvis_chunks(journey)
local surface = game.surfaces.mothership local surface = game.surfaces.mothership
Public.teleport_players_to_mothership(journey) Public.teleport_players_to_mothership(journey)
draw_background(journey, surface) 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 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 end
journey.game_state = 'mothership_world_selection' journey.game_state = 'mothership_world_selection'
@ -1047,7 +1139,9 @@ function Public.mothership_world_selection(journey)
local surface = game.surfaces.mothership local surface = game.surfaces.mothership
local daytime = surface.daytime local daytime = surface.daytime
daytime = daytime - 0.025 daytime = daytime - 0.025
if daytime < 0 then daytime = 0 end if daytime < 0 then
daytime = 0
end
surface.daytime = daytime surface.daytime = daytime
local reroll_selector_activation_level = get_activation_level(journey, surface, Constants.reroll_selector_area) 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' journey.game_state = 'mothership_arrives_at_world'
return return
end 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 end
journey.mothership_speed = journey.mothership_speed + 0.1 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 else
if journey.mothership_advancing_to_world then if journey.mothership_advancing_to_world then
table.insert(journey.mothership_messages, 'Aborting travelling sequence.') table.insert(journey.mothership_messages, 'Aborting travelling sequence.')
journey.mothership_advancing_to_world = false journey.mothership_advancing_to_world = false
end end
journey.mothership_speed = journey.mothership_speed - 0.25 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 end
draw_background(journey, surface) draw_background(journey, surface)
@ -1112,9 +1212,13 @@ function Public.mothership_arrives_at_world(journey)
Public.teleport_players_to_mothership(journey) Public.teleport_players_to_mothership(journey)
if journey.mothership_speed == 0.15 then 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 ;_;') 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!') table.insert(journey.mothership_messages, 'Refuel via supply rocket required!')
for i = 1, 3, 1 do for i = 1, 3, 1 do
@ -1141,13 +1245,17 @@ end
function Public.clear_modifiers(journey) function Public.clear_modifiers(journey)
local unique_modifier = Unique_modifiers[journey.world_trait] local unique_modifier = Unique_modifiers[journey.world_trait]
local clear = unique_modifier.clear local clear = unique_modifier.clear
if clear then clear(journey) end if clear then
clear(journey)
end
journey.world_specials = {} journey.world_specials = {}
local force = game.forces.player local force = game.forces.player
force.reset() force.reset()
force.reset_technologies() force.reset_technologies()
force.reset_technology_effects() 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' journey.game_state = 'create_the_world'
Public.update_tooltips(journey) Public.update_tooltips(journey)
end end
@ -1171,11 +1279,12 @@ function Public.create_the_world(journey)
local unique_modifier = Unique_modifiers[journey.world_trait] local unique_modifier = Unique_modifiers[journey.world_trait]
local set_specials = unique_modifier.set_specials 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) set_map_modifiers(journey)
surface.clear(false) surface.clear(false)
journey.nauvis_chunk_positions = nil journey.nauvis_chunk_positions = nil
journey.rocket_silos = {} journey.rocket_silos = {}
journey.mothership_cargo['uranium-fuel-cell'] = 0 journey.mothership_cargo['uranium-fuel-cell'] = 0
@ -1197,7 +1306,9 @@ function Public.create_the_world(journey)
end end
end end
journey.goods_to_dispatch = {} 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) table.shuffle_table(journey.goods_to_dispatch)
Public.update_tooltips(journey) Public.update_tooltips(journey)
journey.game_state = 'wipe_offline_players' journey.game_state = 'wipe_offline_players'
@ -1221,7 +1332,9 @@ function Public.notify_discord(journey)
local modifier_message = '' local modifier_message = ''
for _, mod in pairs(journey.world_selectors[journey.selected_world].modifiers) do for _, mod in pairs(journey.world_selectors[journey.selected_world].modifiers) do
local sign = '' 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' modifier_message = modifier_message .. sign .. mod.value .. '% ' .. mod.name .. '\n'
end end
local capsules = '' local capsules = ''
@ -1261,11 +1374,12 @@ function Public.notify_discord(journey)
Server.to_discord_embed_parsed(message) Server.to_discord_embed_parsed(message)
end end
function Public.set_unique_modifiers(journey) function Public.set_unique_modifiers(journey)
local unique_modifier = Unique_modifiers[journey.world_trait] local unique_modifier = Unique_modifiers[journey.world_trait]
local on_world_start = unique_modifier.on_world_start 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.update_tooltips(journey)
Public.draw_gui(journey) Public.draw_gui(journey)
Public.notify_discord(journey) Public.notify_discord(journey)
@ -1298,20 +1412,28 @@ end
function Public.dispatch_goods(journey) function Public.dispatch_goods(journey)
draw_background(journey, game.surfaces.mothership) 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 goods_to_dispatch = journey.goods_to_dispatch
local size_of_goods_to_dispatch = #goods_to_dispatch local size_of_goods_to_dispatch = #goods_to_dispatch
if size_of_goods_to_dispatch == 0 then 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.') 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! ^.^') table.insert(journey.mothership_messages, 'Good luck on your adventure! ^.^')
journey.game_state = 'world' journey.game_state = 'world'
return return
end 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 local surface = game.surfaces.nauvis
@ -1326,11 +1448,15 @@ function Public.dispatch_goods(journey)
end end
local chunk = surface.get_random_chunk() 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)} 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) 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 = surface.create_entity({name = 'stone-wall', position = position, force = 'neutral'})
journey.dispatch_beacon.minable = false journey.dispatch_beacon.minable = false
@ -1393,7 +1519,9 @@ function Public.world(journey)
end end
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 for k, silo in pairs(journey.rocket_silos) do
if not silo or not silo.valid then if not silo or not silo.valid then
table.remove(journey.rocket_silos, k) table.remove(journey.rocket_silos, k)
@ -1421,7 +1549,9 @@ function Public.mothership_waiting_for_players(journey)
return return
end end
if math.random(1, 2) == 1 then return end if math.random(1, 2) == 1 then
return
end
local tick = game.tick % 3600 local tick = game.tick % 3600
if tick == 0 then if tick == 0 then
local messages = Constants.mothership_messages.waiting local messages = Constants.mothership_messages.waiting
@ -1430,11 +1560,17 @@ function Public.mothership_waiting_for_players(journey)
end end
function Public.teleporters(journey, player) function Public.teleporters(journey, player)
if not player.character then return end if not player.character then
if not player.character.valid then return end return
end
if not player.character.valid then
return
end
local surface = player.surface local surface = player.surface
local tile = surface.get_tile(player.position) local tile = surface.get_tile(player.position)
if tile.name ~= Constants.teleporter_tile and tile.hidden_tile ~= Constants.teleporter_tile then return end if tile.name ~= Constants.teleporter_tile and tile.hidden_tile ~= Constants.teleporter_tile then
return
end
local base_position = {0, 0} local base_position = {0, 0}
if surface.index == 1 then if surface.index == 1 then
drop_player_items(journey, player) drop_player_items(journey, player)
@ -1462,7 +1598,9 @@ function Public.teleporters(journey, player)
end end
function Public.deal_damage_to_beacon(journey, incoming_damage) 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 local resistance = journey.beacon_objective_resistance
journey.beacon_objective_health = math.floor(journey.beacon_objective_health - (incoming_damage * (1 - 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}) rendering.set_text(journey.beacon_objective_hp_label, {'journey.beacon_hp', journey.beacon_objective_health})
@ -1490,7 +1628,9 @@ function Public.deal_damage_to_beacon(journey, incoming_damage)
end end
function Public.lure_biters(journey, position) 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 beacon = journey.beacon_objective
local surface = beacon.surface 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'}

View File

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

View File

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

View File

@ -9,7 +9,7 @@ require 'modules.rocks_heal_over_time'
require 'maps.junkyard_pvp.share_chat' require 'maps.junkyard_pvp.share_chat'
require 'modules.mineable_wreckage_yields_scrap' require 'modules.mineable_wreckage_yields_scrap'
local Team = require 'maps.junkyard_pvp.team' 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 Map = require 'modules.map_info'
local math_random = math.random local math_random = math.random
local Public = {} local Public = {}

View File

@ -3,7 +3,7 @@ local math_abs = math.abs
local math_random = math.random local math_random = math.random
local math_floor = math.floor local math_floor = math.floor
local Treasure = require 'maps.junkyard_pvp.treasure' 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 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 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'} local spawner_raffle = {'biter-spawner', 'biter-spawner', 'biter-spawner', 'spitter-spawner'}
@ -96,11 +96,7 @@ function Public.create_mirror_surface()
end end
end end
end end
for _, e in pairs( 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
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 if math.sqrt(e.position.x ^ 2 + e.position.y ^ 2) < r then
e.destroy() e.destroy()
end end

View File

@ -8,11 +8,11 @@ require 'modules.satellite_score'
local Event = require 'utils.event' local Event = require 'utils.event'
local Server = require 'utils.server' local Server = require 'utils.server'
local Global = require 'utils.global' 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 simplex_noise = require 'utils.simplex_noise'.d2
local Score = require 'utils.gui.score' local Score = require 'utils.gui.score'
local unique_rooms = require 'maps.labyrinth_unique_rooms' 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 Autostash = require 'modules.autostash'
local BottomFrame = require 'utils.gui.bottom_frame' local BottomFrame = require 'utils.gui.bottom_frame'
local this = { local this = {
@ -1022,7 +1022,9 @@ end
local function on_entity_died(event) local function on_entity_died(event)
local entity = event.entity 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 name = entity.name
local position = entity.position local position = entity.position
local evolution = game.forces.enemy.evolution_factor local evolution = game.forces.enemy.evolution_factor
@ -1235,7 +1237,9 @@ local loaders = {
['express-loader'] = true ['express-loader'] = true
} }
local function on_built_entity(event) 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 get_score = Score.get_table().score_table
local name = event.created_entity.name local name = event.created_entity.name
if inserters[name] then if inserters[name] then

View File

@ -12,7 +12,7 @@ require 'modules.flashlight_toggle_button'
local simplex_noise = require 'utils.simplex_noise'.d2 local simplex_noise = require 'utils.simplex_noise'.d2
local event = require 'utils.event' 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 local math_random = math.random
require 'utils.table' require 'utils.table'

View File

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

View File

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

View File

@ -18,7 +18,7 @@ local difficulty_factor = 4
local event = require 'utils.event' local event = require 'utils.event'
local math_random = math.random local math_random = math.random
local insert = table.insert 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 = require 'utils.simplex_noise'
local simplex_noise = simplex_noise.d2 local simplex_noise = simplex_noise.d2

View File

@ -4,8 +4,8 @@
global.offline_loot = true global.offline_loot = true
local darkness = false local darkness = false
require 'functions.soft_reset' require 'utils.functions.soft_reset'
require 'functions.basic_markets' require 'utils.functions.basic_markets'
local Gui = require 'utils.gui' local Gui = require 'utils.gui'
local Map_score = require 'utils.gui.map_score' 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' require 'maps.mountain_fortress_v2.flamethrower_nerf'
local BiterRolls = require 'modules.wave_defense.biter_rolls' local BiterRolls = require 'modules.wave_defense.biter_rolls'
local BiterHealthBooster = require 'modules.biter_health_booster' 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 Pets = require 'modules.biter_pets'
local Map = require 'modules.map_info' local Map = require 'modules.map_info'
local WD = require 'modules.wave_defense.table' local WD = require 'modules.wave_defense.table'

View File

@ -2,7 +2,7 @@
local Biters = require 'modules.wave_defense.biter_rolls' local Biters = require 'modules.wave_defense.biter_rolls'
local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main' local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
local Treasure = require 'maps.mountain_fortress_v2.treasure' 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_random = math.random
local math_floor = math.floor local math_floor = math.floor
local math_abs = math.abs local math_abs = math.abs

View File

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

View File

@ -1,7 +1,7 @@
local Public = require 'maps.mountain_fortress_v3.table' local Public = require 'maps.mountain_fortress_v3.table'
local ICW = require 'maps.mountain_fortress_v3.icw.main' local ICW = require 'maps.mountain_fortress_v3.icw.main'
local Task = require 'utils.task_token' local Task = require 'utils.task_token'
local MapFunctions = require 'tools.map_functions' local MapFunctions = require 'utils.tools.map_functions'
local random = math.random local random = math.random
local floor = math.floor 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 Public = require 'maps.mountain_fortress_v3.table'
local random = math.random local random = math.random
local abs = math.abs local abs = math.abs

View File

@ -3,7 +3,7 @@ local Public = {}
local math_random = math.random local math_random = math.random
local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main' local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
local GetNoise = require 'utils.get_noise' 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 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'} 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 Terrain = require 'maps.native_war.terrain'
local Init = require 'maps.native_war.init' local Init = require 'maps.native_war.init'
local Settings = require 'maps.native_war.settings' 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 Map = require 'maps.native_war.map_info'
local Team_manager = require 'maps.native_war.team_manager' local Team_manager = require 'maps.native_war.team_manager'
local math_random = math.random local math_random = math.random

View File

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

View File

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

View File

@ -16,11 +16,11 @@ require 'modules.trees_randomly_die'
require 'maps.overgrowth_map_info' require 'maps.overgrowth_map_info'
local Reset = require 'functions.soft_reset' local Reset = require 'utils.functions.soft_reset'
local kaboom = require 'functions.omegakaboom' local kaboom = require 'utils.functions.omegakaboom'
local Difficulty = require 'modules.difficulty_vote' 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 event = require 'utils.event'
local math_random = math.random 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 Difficulty = require 'modules.difficulty_vote'
local Map = require 'modules.map_info' local Map = require 'modules.map_info'
local Event = require 'utils.event' local Event = require 'utils.event'
local Reset = require 'functions.soft_reset' local Reset = require 'utils.functions.soft_reset'
local Server = require 'utils.server' local Server = require 'utils.server'
local Poll = require 'utils.gui.poll' local Poll = require 'utils.gui.poll'
local boss_biter = require 'maps.pidgeotto.boss_biters' local boss_biter = require 'maps.pidgeotto.boss_biters'

View File

@ -1,6 +1,6 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Builder = require 'maps.pidgeotto.b' 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 simplex_noise = require 'utils.simplex_noise'.d2
local FDT = require 'maps.pidgeotto.table' local FDT = require 'maps.pidgeotto.table'
local math_random = math.random local math_random = math.random

View File

@ -1,6 +1,5 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates. -- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Math = require 'maps.pirates.math' local Math = require 'maps.pirates.math'
local Raffle = require 'maps.pirates.raffle' local Raffle = require 'maps.pirates.raffle'
local Server = require 'utils.server' local Server = require 'utils.server'
@ -11,14 +10,13 @@ local _inspect = require 'utils.inspect'.inspect
-- local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' -- local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local LootRaffle = require 'functions.loot_raffle' local LootRaffle = require 'utils.functions.loot_raffle'
-- local simplex_noise = require 'utils.simplex_noise'.d2 -- local simplex_noise = require 'utils.simplex_noise'.d2
-- local perlin_noise = require 'utils.perlin_noise' -- local perlin_noise = require 'utils.perlin_noise'
-- local Force_health_booster = require 'modules.force_health_booster' -- local Force_health_booster = require 'modules.force_health_booster'
-- == Common variables and functions used throughout pirate ship files -- == Common variables and functions used throughout pirate ship files
local Public = {} local Public = {}
Public.activeCrewsCap = 3 Public.activeCrewsCap = 3
@ -70,7 +68,6 @@ Public.lobby_force_name = 'player'
-- Public.mainshop_rate_limit_ticks = 11 -- Public.mainshop_rate_limit_ticks = 11
function Public.ore_real_to_abstract(amount) function Public.ore_real_to_abstract(amount)
return amount / 1800 return amount / 1800
end end
@ -94,11 +91,19 @@ function Public.difficulty_scale()
return 0.75 return 0.75
end end
end end
function Public.capacity() return Memory.get_crew_memory().capacity end function Public.capacity()
return Memory.get_crew_memory().capacity
end
-- function Public.mode() return Memory.get_crew_memory().mode end -- function Public.mode() return Memory.get_crew_memory().mode end
function Public.overworldx() return Memory.get_crew_memory().overworldx end function Public.overworldx()
function Public.game_completion_progress() return Public.overworldx()/CoreData.victory_x end return Memory.get_crew_memory().overworldx
function Public.game_completion_progress_capped() return Math.clamp(0, 1, Public.overworldx()/CoreData.victory_x) end end
function Public.game_completion_progress()
return Public.overworldx() / CoreData.victory_x
end
function Public.game_completion_progress_capped()
return Math.clamp(0, 1, Public.overworldx() / CoreData.victory_x)
end
function Public.capacity_scale() function Public.capacity_scale()
local capacity = Public.capacity() local capacity = Public.capacity()
if not capacity then --e.g. for EE wattage on boats not owned by a crew if not capacity then --e.g. for EE wattage on boats not owned by a crew
@ -119,7 +124,9 @@ end
function Public.activecrewcount() function Public.activecrewcount()
local global_memory = Memory.get_global_memory() local global_memory = Memory.get_global_memory()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
if not Public.is_id_valid(memory.id) then return 0 end if not Public.is_id_valid(memory.id) then
return 0
end
local count = 0 local count = 0
for _, id in pairs(memory.crewplayerindices) do for _, id in pairs(memory.crewplayerindices) do
@ -132,81 +139,76 @@ function Public.activecrewcount()
return count return count
end end
function Public.notify_game(message, color_override) function Public.notify_game(message, color_override)
color_override = color_override or CoreData.colors.notify_game color_override = color_override or CoreData.colors.notify_game
game.print({"", '>> ', message}, color_override) game.print({'', '>> ', message}, color_override)
end end
function Public.notify_lobby(message, color_override) function Public.notify_lobby(message, color_override)
color_override = color_override or CoreData.colors.notify_lobby color_override = color_override or CoreData.colors.notify_lobby
game.forces[Public.lobby_force_name].print({"", '>> ', message}, color_override) game.forces[Public.lobby_force_name].print({'', '>> ', message}, color_override)
end end
function Public.notify_force(force, message, color_override) function Public.notify_force(force, message, color_override)
color_override = color_override or CoreData.colors.notify_force color_override = color_override or CoreData.colors.notify_force
force.print({"", '>> ', message}, color_override) force.print({'', '>> ', message}, color_override)
end end
function Public.notify_force_light(force, message, color_override) function Public.notify_force_light(force, message, color_override)
color_override = color_override or CoreData.colors.notify_force_light color_override = color_override or CoreData.colors.notify_force_light
force.print({"", '>> ', message}, color_override) force.print({'', '>> ', message}, color_override)
end end
function Public.notify_force_error(force, message, color_override) function Public.notify_force_error(force, message, color_override)
color_override = color_override or CoreData.colors.notify_error color_override = color_override or CoreData.colors.notify_error
force.print({"", '>> ', message}, color_override) force.print({'', '>> ', message}, color_override)
force.play_sound{path = "utility/cannot_build"} force.play_sound {path = 'utility/cannot_build'}
end end
function Public.notify_player_error(player, message, color_override) function Public.notify_player_error(player, message, color_override)
color_override = color_override or CoreData.colors.notify_error color_override = color_override or CoreData.colors.notify_error
player.print({"", '## ', {'pirates.notify_whisper'}, ' ', message}, color_override) player.print({'', '## ', {'pirates.notify_whisper'}, ' ', message}, color_override)
player.play_sound{path = "utility/cannot_build"} player.play_sound {path = 'utility/cannot_build'}
end end
function Public.notify_player_expected(player, message, color_override) function Public.notify_player_expected(player, message, color_override)
color_override = color_override or CoreData.colors.notify_player_expected color_override = color_override or CoreData.colors.notify_player_expected
player.print({"", '## ', {'pirates.notify_whisper'}, ' ', message}, color_override) player.print({'', '## ', {'pirates.notify_whisper'}, ' ', message}, color_override)
end end
function Public.notify_player_announce(player, message, color_override) function Public.notify_player_announce(player, message, color_override)
color_override = color_override or CoreData.colors.notify_player_announce color_override = color_override or CoreData.colors.notify_player_announce
player.print({"", '## ', {'pirates.notify_whisper'}, ' ', message}, color_override) player.print({'', '## ', {'pirates.notify_whisper'}, ' ', message}, color_override)
end end
function Public.parrot_speak(force, message) function Public.parrot_speak(force, message)
force.print({"", {'pirates.notify_parrot'}, ' ', message}, CoreData.colors.parrot) force.print({'', {'pirates.notify_parrot'}, ' ', message}, CoreData.colors.parrot)
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
Server.to_discord_embed_raw({"", '[' .. memory.name .. '] ', {'pirates.notify_parrot'}, ' ', message}, true) Server.to_discord_embed_raw({'', '[' .. memory.name .. '] ', {'pirates.notify_parrot'}, ' ', message}, true)
end end
function Public.flying_text(surface, position, text) function Public.flying_text(surface, position, text)
surface.create_entity( surface.create_entity(
{ {
name = 'flying-text', name = 'flying-text',
position = {position.x - 0.7, position.y - 3.05}, position = {position.x - 0.7, position.y - 3.05},
text = text, text = text
} }
) )
end end
function Public.flying_text_small(surface, position, text) --differs just in the location of the text, more suitable for small things like '+' function Public.flying_text_small(surface, position, text) --differs just in the location of the text, more suitable for small things like '+'
surface.create_entity( surface.create_entity(
{ {
name = 'flying-text', name = 'flying-text',
position = {position.x - 0.08, position.y - 1.5}, position = {position.x - 0.08, position.y - 1.5},
-- position = {position.x - 0.06, position.y - 1.5}, -- position = {position.x - 0.06, position.y - 1.5},
text = text, text = text
} }
) )
end end
function Public.processed_loot_data(raw_data) function Public.processed_loot_data(raw_data)
local ret = {} local ret = {}
for i = 1, #raw_data do for i = 1, #raw_data do
@ -232,8 +234,6 @@ end
-- {20, 0, 1, false, 'flying-robot-frame', 20, 35}, -- {20, 0, 1, false, 'flying-robot-frame', 20, 35},
-- } -- }
--@TODO: Replace this old function with the newer code in raffle.lua --@TODO: Replace this old function with the newer code in raffle.lua
function Public.raffle_from_processed_loot_data(processed_loot_data, how_many, game_completion_progress) function Public.raffle_from_processed_loot_data(processed_loot_data, how_many, game_completion_progress)
local ret = {} local ret = {}
@ -279,10 +279,6 @@ function Public.raffle_from_processed_loot_data(processed_loot_data, how_many, g
return ret return ret
end end
function Public.give(player, stacks, spill_position, short_form, spill_surface, flying_text_position) function Public.give(player, stacks, spill_position, short_form, spill_surface, flying_text_position)
-- stack elements of form {name = '', count = '', color = {r = , g = , b = }} -- stack elements of form {name = '', count = '', color = {r = , g = , b = }}
-- to just spill on the ground, pass player and nill and give a position and surface directly -- to just spill on the ground, pass player and nill and give a position and surface directly
@ -294,14 +290,23 @@ function Public.give(player, stacks, spill_position, short_form, spill_surface,
local text2 = '' local text2 = ''
local stacks2 = stacks local stacks2 = stacks
table.sort(stacks2, function(a,b) return a.name < b.name end) table.sort(
stacks2,
function(a, b)
return a.name < b.name
end
)
if not (spill_surface and spill_surface.valid) then return end if not (spill_surface and spill_surface.valid) then
return
end
local inv local inv
if player then if player then
inv = player.get_inventory(defines.inventory.character_main) inv = player.get_inventory(defines.inventory.character_main)
if not (inv and inv.valid) then return end if not (inv and inv.valid) then
return
end
end end
for j = 1, #stacks2 do for j = 1, #stacks2 do
@ -309,7 +314,9 @@ function Public.give(player, stacks, spill_position, short_form, spill_surface,
local itemname, itemcount, flying_text_color = stack.name, stack.count or 1, stack.color or (CoreData.colors[stack.name] or {r = 1, g = 1, b = 1}) local itemname, itemcount, flying_text_color = stack.name, stack.count or 1, stack.color or (CoreData.colors[stack.name] or {r = 1, g = 1, b = 1})
local itemcount_remember = itemcount local itemcount_remember = itemcount
if not itemname then return end if not itemname then
return
end
if itemcount > 0 then if itemcount > 0 then
if player then if player then
@ -362,7 +369,6 @@ function Public.give(player, stacks, spill_position, short_form, spill_surface,
end end
end end
if player and (not short_form) then if player and (not short_form) then
-- count total of that item they have: -- count total of that item they have:
local new_total_count = 0 local new_total_count = 0
@ -400,8 +406,6 @@ function Public.give(player, stacks, spill_position, short_form, spill_surface,
end end
end end
function Public.is_captain(player) function Public.is_captain(player)
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
@ -412,7 +416,6 @@ function Public.is_captain(player)
end end
end end
function Public.is_officer(player_index) function Public.is_officer(player_index)
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
@ -432,7 +435,6 @@ end
-- -- return Math.floor(surplus_evo*3*1000)/1000 -- -- return Math.floor(surplus_evo*3*1000)/1000
-- end -- end
function Public.set_biter_surplus_evo_modifiers() function Public.set_biter_surplus_evo_modifiers()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local enemy_force = memory.enemy_force local enemy_force = memory.enemy_force
@ -446,11 +448,11 @@ function Public.set_biter_surplus_evo_modifiers()
-- local health_fractional_mod -- local health_fractional_mod
if surplus > 0 then if surplus > 0 then
damage_fractional_mod = Public.surplus_evo_biter_damage_modifier(surplus)
-- health_fractional_mod = Public.surplus_evo_biter_health_fractional_modifier(surplus) -- health_fractional_mod = Public.surplus_evo_biter_health_fractional_modifier(surplus)
damage_fractional_mod = Public.surplus_evo_biter_damage_modifier(surplus)
else else
damage_fractional_mod = 0
-- health_fractional_mod = 0 -- health_fractional_mod = 0
damage_fractional_mod = 0
end end
enemy_force.set_ammo_damage_modifier('melee', damage_fractional_mod) enemy_force.set_ammo_damage_modifier('melee', damage_fractional_mod)
enemy_force.set_ammo_damage_modifier('biological', damage_fractional_mod) enemy_force.set_ammo_damage_modifier('biological', damage_fractional_mod)
@ -485,8 +487,6 @@ function Public.increment_evo(evolution)
end end
end end
function Public.current_destination() function Public.current_destination()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
@ -497,7 +497,6 @@ function Public.current_destination()
end end
end end
function Public.time_adjusted_departure_cost(cost) function Public.time_adjusted_departure_cost(cost)
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
@ -517,9 +516,9 @@ function Public.time_adjusted_departure_cost(cost)
local new_cost = {} local new_cost = {}
for name, count in pairs(cost) do for name, count in pairs(cost) do
if type(count) == "number" then if type(count) == 'number' then
new_cost[name] = Math.floor(count * cost_fraction)
-- new_cost[name] = Math.ceil(count * cost_fraction) -- new_cost[name] = Math.ceil(count * cost_fraction)
new_cost[name] = Math.floor(count * cost_fraction)
else else
new_cost[name] = count new_cost[name] = count
end end
@ -565,22 +564,24 @@ function Public.time_adjusted_departure_cost(cost)
return ret return ret
end end
function Public.time_adjusted_departure_cost_resources_strings(memory) function Public.time_adjusted_departure_cost_resources_strings(memory)
-- written to be efficient... only called in the gui after Public.time_adjusted_departure_cost() -- written to be efficient... only called in the gui after Public.time_adjusted_departure_cost()
return memory.time_adjusted_departure_cost_memoized.resources_strings return memory.time_adjusted_departure_cost_memoized.resources_strings
end end
function Public.query_can_pay_cost_to_leave() function Public.query_can_pay_cost_to_leave()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local boat = memory.boat local boat = memory.boat
local destination = Public.current_destination() local destination = Public.current_destination()
if not (boat and destination) then return end if not (boat and destination) then
return
end
local cost = destination.static_params.base_cost_to_undock local cost = destination.static_params.base_cost_to_undock
if not cost then return true end if not cost then
return true
end
local adjusted_cost = Public.time_adjusted_departure_cost(cost) local adjusted_cost = Public.time_adjusted_departure_cost(cost)
@ -601,14 +602,14 @@ function Public.query_can_pay_cost_to_leave()
return can_leave return can_leave
end end
-- This function assumes you're placing obstacle boxes in the hold -- This function assumes you're placing obstacle boxes in the hold
function Public.surface_place_random_obstacle_boxes(surface, center, width, height, spacing_entity, box_size_table, contents) function Public.surface_place_random_obstacle_boxes(surface, center, width, height, spacing_entity, box_size_table, contents)
contents = contents or {} contents = contents or {}
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
if not surface then return end if not surface then
return
end
local function boxposition() local function boxposition()
local p1 = {x = center.x - width / 2 + Math.random(Math.ceil(width)), y = center.y - height / 2 + Math.random(Math.ceil(height))} local p1 = {x = center.x - width / 2 + Math.random(Math.ceil(width)), y = center.y - height / 2 + Math.random(Math.ceil(height))}
@ -641,15 +642,17 @@ function Public.surface_place_random_obstacle_boxes(surface, center, width, heig
end end
end end
function Public.update_boat_stored_resources() function Public.update_boat_stored_resources()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local boat = memory.boat local boat = memory.boat
if not boat.stored_resources then return end if not boat.stored_resources then
return
end
local input_chests = boat.input_chests local input_chests = boat.input_chests
if not input_chests then return end if not input_chests then
return
end
for i, chest in ipairs(input_chests) do for i, chest in ipairs(input_chests) do
if i > 1 and CoreData.cost_items[i - 1] then if i > 1 and CoreData.cost_items[i - 1] then
@ -664,16 +667,18 @@ function Public.update_boat_stored_resources()
end end
end end
function Public.spend_stored_resources(to_spend) function Public.spend_stored_resources(to_spend)
to_spend = to_spend or {} to_spend = to_spend or {}
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local boat = memory.boat local boat = memory.boat
if not memory.boat.stored_resources then return end if not memory.boat.stored_resources then
return
end
local input_chests = boat.input_chests local input_chests = boat.input_chests
if not input_chests then return end if not input_chests then
return
end
for i, chest in ipairs(input_chests) do for i, chest in ipairs(input_chests) do
if i > 1 then if i > 1 then
@ -708,7 +713,8 @@ function Public.new_healthbar(text, target_entity, max_health, optional_id, heal
extra_offset = extra_offset or 0 extra_offset = extra_offset or 0
location_override = location_override or Memory.get_crew_memory() location_override = location_override or Memory.get_crew_memory()
local render1 = rendering.draw_sprite( local render1 =
rendering.draw_sprite(
{ {
sprite = 'virtual-signal/signal-white', sprite = 'virtual-signal/signal-white',
tint = {0, 200, 0}, tint = {0, 200, 0},
@ -717,12 +723,13 @@ function Public.new_healthbar(text, target_entity, max_health, optional_id, heal
render_layer = 'light-effect', render_layer = 'light-effect',
target = target_entity, target = target_entity,
target_offset = {0, -2.5 + extra_offset}, target_offset = {0, -2.5 + extra_offset},
surface = target_entity.surface, surface = target_entity.surface
} }
) )
local render2 local render2
if text then if text then
render2 = rendering.draw_text( render2 =
rendering.draw_text(
{ {
color = {255, 255, 255}, color = {255, 255, 255},
scale = 1.2 + size * 2, scale = 1.2 + size * 2,
@ -730,7 +737,7 @@ function Public.new_healthbar(text, target_entity, max_health, optional_id, heal
target = target_entity, target = target_entity,
target_offset = {0, -3.6 - size * 0.6 + extra_offset}, target_offset = {0, -3.6 - size * 0.6 + extra_offset},
surface = target_entity.surface, surface = target_entity.surface,
alignment = 'center', alignment = 'center'
} }
) )
end end
@ -742,10 +749,12 @@ function Public.new_healthbar(text, target_entity, max_health, optional_id, heal
extra_offset = extra_offset, extra_offset = extra_offset,
render1 = render1, render1 = render1,
render2 = render2, render2 = render2,
id = optional_id, id = optional_id
} }
if not location_override.healthbars then location_override.healthbars = {} end if not location_override.healthbars then
location_override.healthbars = {}
end
location_override.healthbars[target_entity.unit_number] = new_healthbar location_override.healthbars[target_entity.unit_number] = new_healthbar
Public.update_healthbar_rendering(new_healthbar, health) Public.update_healthbar_rendering(new_healthbar, health)
@ -755,7 +764,9 @@ end
function Public.transfer_healthbar(old_unit_number, new_entity, location_override) function Public.transfer_healthbar(old_unit_number, new_entity, location_override)
location_override = location_override or Memory.get_crew_memory() location_override = location_override or Memory.get_crew_memory()
if not location_override.healthbars then return end if not location_override.healthbars then
return
end
local old_healthbar = location_override.healthbars[old_unit_number] local old_healthbar = location_override.healthbars[old_unit_number]
-- local new_unit_number = new_entity.unit_number -- local new_unit_number = new_entity.unit_number
@ -785,11 +796,15 @@ end
function Public.entity_damage_healthbar(entity, damage, location_override) function Public.entity_damage_healthbar(entity, damage, location_override)
location_override = location_override or Memory.get_crew_memory() location_override = location_override or Memory.get_crew_memory()
if not (location_override.healthbars) then return nil end if not (location_override.healthbars) then
return nil
end
local unit_number = entity.unit_number local unit_number = entity.unit_number
local healthbar = location_override.healthbars[unit_number] local healthbar = location_override.healthbars[unit_number]
if not healthbar then return nil end if not healthbar then
return nil
end
local new_health = healthbar.health - damage local new_health = healthbar.health - damage
healthbar.health = new_health healthbar.health = new_health
@ -841,10 +856,7 @@ function Public.spawner_count(surface)
return #spawners or 0 return #spawners or 0
end end
function Public.create_poison_clouds(surface, position) function Public.create_poison_clouds(surface, position)
local random_angles = {Math.rad(Math.random(359)), Math.rad(Math.random(359))} local random_angles = {Math.rad(Math.random(359)), Math.rad(Math.random(359))}
surface.create_entity({name = 'poison-cloud', position = {x = position.x, y = position.y}}) surface.create_entity({name = 'poison-cloud', position = {x = position.x, y = position.y}})
@ -852,20 +864,22 @@ function Public.create_poison_clouds(surface, position)
surface.create_entity({name = 'poison-cloud', position = {x = position.x + 12 * Math.cos(random_angles[2]), y = position.y + 12 * Math.sin(random_angles[2])}}) surface.create_entity({name = 'poison-cloud', position = {x = position.x + 12 * Math.cos(random_angles[2]), y = position.y + 12 * Math.sin(random_angles[2])}})
end end
function Public.crew_get_crew_members() function Public.crew_get_crew_members()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
if not Public.is_id_valid(memory.id) then return {} end if not Public.is_id_valid(memory.id) then
return {}
end
local playerlist = {} local playerlist = {}
for _, id in pairs(memory.crewplayerindices) do for _, id in pairs(memory.crewplayerindices) do
local player = game.players[id] local player = game.players[id]
if player and player.valid then playerlist[#playerlist + 1] = player end if player and player.valid then
playerlist[#playerlist + 1] = player
end
end end
return playerlist return playerlist
end end
function Public.crew_get_crew_members_and_spectators() function Public.crew_get_crew_members_and_spectators()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
if not Public.is_id_valid(memory.id) then if not Public.is_id_valid(memory.id) then
@ -875,11 +889,15 @@ function Public.crew_get_crew_members_and_spectators()
local playerlist = {} local playerlist = {}
for _, id in pairs(memory.crewplayerindices) do for _, id in pairs(memory.crewplayerindices) do
local player = game.players[id] local player = game.players[id]
if player and player.valid then playerlist[#playerlist + 1] = player end if player and player.valid then
playerlist[#playerlist + 1] = player
end
end end
for _, id in pairs(memory.spectatorplayerindices) do for _, id in pairs(memory.spectatorplayerindices) do
local player = game.players[id] local player = game.players[id]
if player and player.valid then playerlist[#playerlist + 1] = player end if player and player.valid then
playerlist[#playerlist + 1] = player
end
end end
return playerlist return playerlist
end end
@ -908,13 +926,12 @@ function Public.is_spectator(player)
return spectating return spectating
end end
function Public.crew_get_nonafk_crew_members() function Public.crew_get_nonafk_crew_members()
local global_memory = Memory.get_global_memory() local global_memory = Memory.get_global_memory()
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
if not Public.is_id_valid(memory.id) then return {} end if not Public.is_id_valid(memory.id) then
return {}
end
local playerlist = {} local playerlist = {}
for _, id in pairs(memory.crewplayerindices) do for _, id in pairs(memory.crewplayerindices) do
@ -940,7 +957,6 @@ function Public.crew_get_non_afk_officers()
return officers return officers
end end
function Public.destroy_decoratives_in_area(surface, area, offset) function Public.destroy_decoratives_in_area(surface, area, offset)
local area2 = {{area[1][1] + offset.x, area[1][2] + offset.y}, {area[2][1] + offset.x, area[2][2] + offset.y}} local area2 = {{area[1][1] + offset.x, area[1][2] + offset.y}, {area[2][1] + offset.x, area[2][2] + offset.y}}
@ -948,7 +964,6 @@ function Public.destroy_decoratives_in_area(surface, area, offset)
end end
function Public.can_place_silo_setup(surface, p, points_to_avoid, silo_count, generous, build_check_type_name) function Public.can_place_silo_setup(surface, p, points_to_avoid, silo_count, generous, build_check_type_name)
-- game.print('checking silo pos: ' .. p.x .. ', ' .. p.y) -- game.print('checking silo pos: ' .. p.x .. ', ' .. p.y)
points_to_avoid = points_to_avoid or {} points_to_avoid = points_to_avoid or {}
@ -980,11 +995,8 @@ function Public.ensure_chunks_at(surface, pos, radius) --WARNING: THIS DOES NOT
surface.request_to_generate_chunks(pos, radius) surface.request_to_generate_chunks(pos, radius)
surface.force_generate_chunk_requests() --WARNING: THIS DOES NOT PLAY NICELY WITH DELAYED TASKS. log(_inspect{global_memory.working_id}) was observed to vary before and after this function. surface.force_generate_chunk_requests() --WARNING: THIS DOES NOT PLAY NICELY WITH DELAYED TASKS. log(_inspect{global_memory.working_id}) was observed to vary before and after this function.
end end
end end
function Public.default_map_gen_settings(width, height, seed) function Public.default_map_gen_settings(width, height, seed)
width = width or 512 width = width or 512
height = height or 512 height = height or 512
@ -1002,15 +1014,14 @@ function Public.default_map_gen_settings(width, height, seed)
['autoplace_settings'] = { ['autoplace_settings'] = {
['entity'] = {treat_missing_as_default = false}, ['entity'] = {treat_missing_as_default = false},
['tile'] = {treat_missing_as_default = true}, ['tile'] = {treat_missing_as_default = true},
['decorative'] = {treat_missing_as_default = true}, ['decorative'] = {treat_missing_as_default = true}
}, },
['property_expression_names'] = {}, ['property_expression_names'] = {}
} }
return map_gen_settings return map_gen_settings
end end
function Public.build_from_blueprint(bp_string, surface, pos, force, flipped) function Public.build_from_blueprint(bp_string, surface, pos, force, flipped)
flipped = flipped or false flipped = flipped or false
@ -1072,7 +1083,6 @@ function Public.build_small_loco(surface, pos, force, color)
end end
function Public.add_tiles_from_blueprint(tilesTable, bp_string, tile_name, offset) function Public.add_tiles_from_blueprint(tilesTable, bp_string, tile_name, offset)
local bp_entity = game.surfaces['nauvis'].create_entity {name = 'item-on-ground', position = {x = 158.5, y = 158.5}, stack = 'blueprint'} local bp_entity = game.surfaces['nauvis'].create_entity {name = 'item-on-ground', position = {x = 158.5, y = 158.5}, stack = 'blueprint'}
bp_entity.stack.import_stack(bp_string) bp_entity.stack.import_stack(bp_string)
@ -1097,7 +1107,6 @@ function Public.tile_positions_from_blueprint(bp_string, offset)
local bp_tiles = bp_entity.stack.get_blueprint_tiles() local bp_tiles = bp_entity.stack.get_blueprint_tiles()
local min_x local min_x
local min_y local min_y
local max_x local max_x
@ -1147,7 +1156,9 @@ function Public.tile_positions_from_blueprint_arrayform(bp_string, offset)
for _, tile in pairs(bp_tiles) do for _, tile in pairs(bp_tiles) do
local x = tile.position.x + offset.x local x = tile.position.x + offset.x
local y = tile.position.y + offset.y local y = tile.position.y + offset.y
if not positions[x] then positions[x] = {} end if not positions[x] then
positions[x] = {}
end
positions[x][y] = true positions[x][y] = true
end end
end end
@ -1158,7 +1169,6 @@ function Public.tile_positions_from_blueprint_arrayform(bp_string, offset)
end end
function Public.entity_positions_from_blueprint(bp_string, offset) function Public.entity_positions_from_blueprint(bp_string, offset)
local bp_entity = game.surfaces['nauvis'].create_entity {name = 'item-on-ground', position = {x = 158.5, y = 158.5}, stack = 'blueprint'} local bp_entity = game.surfaces['nauvis'].create_entity {name = 'item-on-ground', position = {x = 158.5, y = 158.5}, stack = 'blueprint'}
bp_entity.stack.import_stack(bp_string) bp_entity.stack.import_stack(bp_string)
@ -1251,15 +1261,18 @@ function Public.get_random_worm_type(evolution)
end end
function Public.maximumUnitPollutionCost(evolution) function Public.maximumUnitPollutionCost(evolution)
if evolution < 0.2 then return 4 if evolution < 0.2 then
elseif evolution < 0.5 then return 20 return 4
elseif evolution < 0.9 then return 80 elseif evolution < 0.5 then
else return 400 return 20
elseif evolution < 0.9 then
return 80
else
return 400
end end
end end
function Public.averageUnitPollutionCost(evolution) function Public.averageUnitPollutionCost(evolution)
local sum_biters = 0 local sum_biters = 0
local f1 = Math.slopefromto(1 - 1 / 0.4 * (evolution - 0.2), 0, 1) local f1 = Math.slopefromto(1 - 1 / 0.4 * (evolution - 0.2), 0, 1)
local f2 = Math.slopefromto(1 - 0.8 / 0.5 * (evolution - 0.5), 0, 1) local f2 = Math.slopefromto(1 - 0.8 / 0.5 * (evolution - 0.5), 0, 1)
@ -1329,7 +1342,6 @@ function Public.tiles_horizontally_flipped(tiles, x_to_flip_about)
return tiles2 return tiles2
end end
function Public.validate_player(player) function Public.validate_player(player)
if player and player.valid and player.connected and game.players[player.name] then if player and player.valid and player.connected and game.players[player.name] then
return true return true
@ -1341,14 +1353,12 @@ function Public.validate_player(player)
end end
end end
function Public.validate_player_and_character(player) function Public.validate_player_and_character(player)
local ret = Public.validate_player(player) local ret = Public.validate_player(player)
ret = ret and player.character and player.character.valid ret = ret and player.character and player.character.valid
return ret return ret
end end
-- Players complained that when "all_items" is false, the items dissapear (perhaps code sending items from dead character to cabin is wrong?). -- Players complained that when "all_items" is false, the items dissapear (perhaps code sending items from dead character to cabin is wrong?).
function Public.send_important_items_from_player_to_crew(player, all_items) function Public.send_important_items_from_player_to_crew(player, all_items)
local player_inv = {} local player_inv = {}
@ -1440,29 +1450,45 @@ function Public.give_items_to_crew(items)
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local boat = memory.boat local boat = memory.boat
if not boat then return end if not boat then
return
end
local surface_name = boat.surface_name local surface_name = boat.surface_name
if not surface_name then return end if not surface_name then
return
end
local surface = game.surfaces[surface_name] local surface = game.surfaces[surface_name]
if not (surface and surface.valid) then return end if not (surface and surface.valid) then
return
end
local chest, chest2 local chest, chest2
if items.name and items.name == 'coin' then if items.name and items.name == 'coin' then
chest = boat.backup_output_chest chest = boat.backup_output_chest
if not (chest and chest.valid) then return end if not (chest and chest.valid) then
return
end
chest2 = boat.output_chest chest2 = boat.output_chest
if not (chest2 and chest2.valid) then return end if not (chest2 and chest2.valid) then
return
end
else else
chest = boat.output_chest chest = boat.output_chest
if not (chest and chest.valid) then return end if not (chest and chest.valid) then
return
end
chest2 = boat.backup_output_chest chest2 = boat.backup_output_chest
if not (chest2 and chest2.valid) then return end if not (chest2 and chest2.valid) then
return
end
end end
local inventory = chest.get_inventory(defines.inventory.chest) local inventory = chest.get_inventory(defines.inventory.chest)
if items.name then --1 item if items.name then --1 item
if not (items.count and items.count>0) then return end if not (items.count and items.count > 0) then
return
end
local inserted = inventory.insert(items) local inserted = inventory.insert(items)
if items.count - inserted > 0 then if items.count - inserted > 0 then
local inventory2 = chest2.get_inventory(defines.inventory.chest) local inventory2 = chest2.get_inventory(defines.inventory.chest)
@ -1472,8 +1498,10 @@ function Public.give_items_to_crew(items)
local inserted2 = inventory2.insert(i2) local inserted2 = inventory2.insert(i2)
if items.count - inserted - inserted2 > 0 then if items.count - inserted - inserted2 > 0 then
local force = memory.force local force = memory.force
if not (force and force.valid) then return end if not (force and force.valid) then
Public.notify_force(force, 'Warning: captain\'s cabin chests are full!') return
end
Public.notify_force(force, "Warning: captain's cabin chests are full!")
end end
else else
if _DEBUG then if _DEBUG then
@ -1485,7 +1513,9 @@ function Public.give_items_to_crew(items)
end end
else else
for _, i in pairs(items) do for _, i in pairs(items) do
if not (i.count and i.count>0) then return end if not (i.count and i.count > 0) then
return
end
local inserted = inventory.insert(i) local inserted = inventory.insert(i)
if i.count - inserted > 0 then if i.count - inserted > 0 then
local inventory2 = chest2.get_inventory(defines.inventory.chest) local inventory2 = chest2.get_inventory(defines.inventory.chest)
@ -1494,15 +1524,16 @@ function Public.give_items_to_crew(items)
local inserted2 = inventory2.insert(i2) local inserted2 = inventory2.insert(i2)
if i.count - inserted - inserted2 > 0 then if i.count - inserted - inserted2 > 0 then
local force = memory.force local force = memory.force
if not (force and force.valid) then return end if not (force and force.valid) then
Public.notify_force(force, 'Warning: captain\'s cabin chests are full!') return
end
Public.notify_force(force, "Warning: captain's cabin chests are full!")
end end
end end
end end
end end
end end
function Public.version_to_array(v) function Public.version_to_array(v)
local vArray = {} local vArray = {}
if type(v) == 'number' then --this is a legacy form if type(v) == 'number' then --this is a legacy form
@ -1525,7 +1556,6 @@ function Public.version_to_array(v)
return vArray return vArray
end end
function Public.version_greater_than(v1, v2) function Public.version_greater_than(v1, v2)
local v1Array = Public.version_to_array(v1) local v1Array = Public.version_to_array(v1)
local v2Array = Public.version_to_array(v2) local v2Array = Public.version_to_array(v2)
@ -1547,10 +1577,7 @@ function Public.version_greater_than(v1, v2)
end end
end end
function Public.init_game_settings(technology_price_multiplier) function Public.init_game_settings(technology_price_multiplier)
--== Tuned for Pirate Ship ==-- --== Tuned for Pirate Ship ==--
global.friendly_fire_history = {} global.friendly_fire_history = {}
@ -1578,7 +1605,6 @@ function Public.init_game_settings(technology_price_multiplier)
game.map_settings.path_finder.short_cache_min_algo_steps_to_cache = 100 game.map_settings.path_finder.short_cache_min_algo_steps_to_cache = 100
game.map_settings.path_finder.cache_accept_path_start_distance_ratio = 0.1 game.map_settings.path_finder.cache_accept_path_start_distance_ratio = 0.1
game.map_settings.enemy_expansion.enabled = true game.map_settings.enemy_expansion.enabled = true
-- faster expansion: -- faster expansion:
-- game.map_settings.enemy_expansion.min_expansion_cooldown = 4 * 3600 -- game.map_settings.enemy_expansion.min_expansion_cooldown = 4 * 3600
@ -1688,7 +1714,9 @@ end
-- scale: final result of formula with tier scaled -- scale: final result of formula with tier scaled
-- tech_tier: float in range [0; 1]; 1 = everything unlocked -- tech_tier: float in range [0; 1]; 1 = everything unlocked
function Public.pick_random_price(tier, scale, tech_tier) function Public.pick_random_price(tier, scale, tech_tier)
if tier < 0 or scale < 0 then return end if tier < 0 or scale < 0 then
return
end
local item_stacks = LootRaffle.roll(math.floor(scale * (tier ^ 2 + 10 * tier)), 20, Public.get_item_blacklist(tech_tier)) local item_stacks = LootRaffle.roll(math.floor(scale * (tier ^ 2 + 10 * tier)), 20, Public.get_item_blacklist(tech_tier))
local price = {} local price = {}
@ -1717,10 +1745,18 @@ end
-- Used to connect multi-surface poles -- Used to connect multi-surface poles
function Public.force_connect_poles(pole1, pole2) function Public.force_connect_poles(pole1, pole2)
if not pole1 then return end if not pole1 then
if not pole1.valid then return end return
if not pole2 then return end end
if not pole2.valid then return end if not pole1.valid then
return
end
if not pole2 then
return
end
if not pole2.valid then
return
end
-- force connections for testing (by placing many poles around the substations) -- force connections for testing (by placing many poles around the substations)
-- for _, e in pairs(pole1.surface.find_entities_filtered{type="electric-pole", position = pole1.position, radius = 10}) do -- for _, e in pairs(pole1.surface.find_entities_filtered{type="electric-pole", position = pole1.position, radius = 10}) do
@ -1734,7 +1770,9 @@ function Public.force_connect_poles(pole1, pole2)
-- NOTE: "connect_neighbour" returns false when the entities are already connected as well -- NOTE: "connect_neighbour" returns false when the entities are already connected as well
pole1.disconnect_neighbour(pole2) pole1.disconnect_neighbour(pole2)
local success = pole1.connect_neighbour(pole2) local success = pole1.connect_neighbour(pole2)
if success then return end if success then
return
end
local pole1_neighbours = pole1.neighbours['copper'] local pole1_neighbours = pole1.neighbours['copper']
local pole2_neighbours = pole2.neighbours['copper'] local pole2_neighbours = pole2.neighbours['copper']
@ -1782,13 +1820,14 @@ function Public.force_connect_poles(pole1, pole2)
end end
end end
-- position here refers to middle position -- position here refers to middle position
function Public.delete_entities(surface, position, width, height) function Public.delete_entities(surface, position, width, height)
local area = {left_top = {position.x - width / 2, position.y - height / 2}, right_bottom = {position.x + width / 2 + 0.5, position.y + height / 2 + 0.5}} local area = {left_top = {position.x - width / 2, position.y - height / 2}, right_bottom = {position.x + width / 2 + 0.5, position.y + height / 2 + 0.5}}
surface.destroy_decoratives {area = area} surface.destroy_decoratives {area = area}
local existing = surface.find_entities_filtered {area = area} local existing = surface.find_entities_filtered {area = area}
if not existing then return end if not existing then
return
end
for _, e in pairs(existing) do for _, e in pairs(existing) do
if not (e.name == 'iron-ore' or e.name == 'copper-ore' or e.name == 'stone' or e.name == 'uranium-ore' or e.name == 'crude-oil') then if not (e.name == 'iron-ore' or e.name == 'copper-ore' or e.name == 'stone' or e.name == 'uranium-ore' or e.name == 'crude-oil') then
@ -1801,13 +1840,15 @@ end
function Public.replace_unwalkable_tiles(surface, position, width, height) function Public.replace_unwalkable_tiles(surface, position, width, height)
local area = {left_top = {position.x - width / 2, position.y - height / 2}, right_bottom = {position.x + width / 2 + 0.5, position.y + height / 2 + 0.5}} local area = {left_top = {position.x - width / 2, position.y - height / 2}, right_bottom = {position.x + width / 2 + 0.5, position.y + height / 2 + 0.5}}
local existing = surface.find_tiles_filtered{area = area, collision_mask = "water-tile"} local existing = surface.find_tiles_filtered {area = area, collision_mask = 'water-tile'}
if not existing then return end if not existing then
return
end
local tiles = {} local tiles = {}
for _, t in pairs(existing) do for _, t in pairs(existing) do
tiles[#tiles + 1] = {name = "landfill", position = t.position} tiles[#tiles + 1] = {name = 'landfill', position = t.position}
end end
if #tiles > 0 then if #tiles > 0 then
@ -1852,27 +1893,36 @@ function Public.get_valid_spawners(surface)
end end
function Public.get_random_valid_spawner(surface) function Public.get_random_valid_spawner(surface)
local spawners = Public.get_valid_spawners(surface) local spawners = Public.get_valid_spawners(surface)
if #spawners == 0 then return end if #spawners == 0 then
return
end
return spawners[Math.random(#spawners)] return spawners[Math.random(#spawners)]
end end
-- @TODO move this somewhere else, so that health multiplier formula can be put to balance -- @TODO move this somewhere else, so that health multiplier formula can be put to balance
function Public.try_make_biter_elite(entity) function Public.try_make_biter_elite(entity)
if not (entity and entity.valid) then return end if not (entity and entity.valid) then
return
end
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local difficulty_index = CoreData.get_difficulty_option_from_value(memory.difficulty) local difficulty_index = CoreData.get_difficulty_option_from_value(memory.difficulty)
if difficulty_index < 3 and Public.overworldx() < 800 then return end if difficulty_index < 3 and Public.overworldx() < 800 then
return
end
if Public.overworldx() == 0 then return end if Public.overworldx() == 0 then
return
end
-- chance to turn biter elite -- chance to turn biter elite
if Math.random(1, 8) ~= 1 then return end if Math.random(1, 8) ~= 1 then
return
end
local health_multiplier local health_multiplier
@ -1903,7 +1953,9 @@ end
-- NOTE: This is only meant for hostile entities (for now at least), as friendly units with healthbars are more difficult to handle -- NOTE: This is only meant for hostile entities (for now at least), as friendly units with healthbars are more difficult to handle
-- NOTE: "damage" can also be negative, which will heal the entity (but not past maximum health) -- NOTE: "damage" can also be negative, which will heal the entity (but not past maximum health)
function Public.damage_hostile_entity(entity, damage) function Public.damage_hostile_entity(entity, damage)
if not (entity and entity.valid) then return end if not (entity and entity.valid) then
return
end
local remaining_health = Public.entity_damage_healthbar(entity, damage) local remaining_health = Public.entity_damage_healthbar(entity, damage)

View File

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

View File

@ -14,7 +14,7 @@ local difficulties_votes = {
local Get_noise = require 'utils.get_noise' local Get_noise = require 'utils.get_noise'
local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main' 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 local map_height = 64

View File

@ -1,8 +1,8 @@
--luacheck: ignore --luacheck: ignore
local event = require 'utils.event' local event = require 'utils.event'
local simplex_noise = require 'utils.simplex_noise'.d2 local simplex_noise = require 'utils.simplex_noise'.d2
local rainbow_colors = require 'tools.rainbow_colors' local rainbow_colors = require 'utils.tools.rainbow_colors'
local map_functions = require 'tools.map_functions' local map_functions = require 'utils.tools.map_functions'
require 'modules.satellite_score' 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'} 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 table_insert = table.insert
local math_random = math.random local math_random = math.random
local simplex_noise = require 'utils.simplex_noise'.d2 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 = { local disabled_for_deconstruction = {
['fish'] = true ['fish'] = true

View File

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

View File

@ -2,7 +2,7 @@ require 'modules.no_deconstruction_of_neutral_entities'
require 'modules.satellite_score' require 'modules.satellite_score'
require 'modules.mineable_wreckage_yields_scrap' 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 Get_noise = require 'utils.get_noise'
local math_random = math.random local math_random = math.random
local math_floor = math.floor local math_floor = math.floor

View File

@ -1,7 +1,7 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Server = require 'utils.server' local Server = require 'utils.server'
local ScenarioTable = require 'maps.scrap_towny_ffa.table' 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 Token = require 'utils.token'
local math_random = math.random 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 Evolution = require 'maps.scrap_towny_ffa.evolution'
local Town_center = require 'maps.scrap_towny_ffa.town_center' local Town_center = require 'maps.scrap_towny_ffa.town_center'
local Scrap = require 'maps.scrap_towny_ffa.scrap' local Scrap = require 'maps.scrap_towny_ffa.scrap'
local unearthing_worm = require 'functions.unearthing_worm' local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters' local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'functions.tick_tack_trap' local tick_tack_trap = require 'utils.functions.tick_tack_trap'
local math_random = math.random local math_random = math.random

View File

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

View File

@ -18,9 +18,9 @@ require 'modules.rocks_broken_paint_tiles'
require 'modules.rpg' require 'modules.rpg'
require 'modules.hunger' require 'modules.hunger'
local shapes = require 'tools.shapes' local shapes = require 'utils.tools.shapes'
local event = require 'utils.event' 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' local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2 simplex_noise = simplex_noise.d2

View File

@ -1,5 +1,5 @@
--luacheck: ignore --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 Biter_pets = require 'modules.biter_pets'
local get_noise = require 'maps.stone_maze.noise' local get_noise = require 'maps.stone_maze.noise'

View File

@ -1,5 +1,5 @@
--luacheck: ignore --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 get_noise = require 'maps.stone_maze.noise'
local room = {} local room = {}

View File

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

View File

@ -20,7 +20,7 @@ require 'modules.evolution_extended'
local event = require 'utils.event' local event = require 'utils.event'
local math_random = math.random local math_random = math.random
local insert = table.insert 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 = require 'utils.simplex_noise'
local simplex_noise = simplex_noise.d2 local simplex_noise = simplex_noise.d2

View File

@ -4,7 +4,7 @@
local event = require 'utils.event' local event = require 'utils.event'
local table_insert = table.insert local table_insert = table.insert
local math_random = math.random 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 arena_size = 160
local function shuffle(tbl) 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 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' local event = require 'utils.event'
@ -457,8 +457,7 @@ function draw_gui_status(player)
element_label.style.font_color = table_of_colors.white element_label.style.font_color = table_of_colors.white
local element_label = 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_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 element_label.style.left_padding = 20
@ -836,10 +835,7 @@ function create_a_base(force_name, base_position)
end end
if if
object.name == 'infinity-chest' or object.name == 'substation' or object.name == 'big-electric-pole' or object.name == 'medium-electric-pole' 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 == 'inserter' or
object.name == 'accumulator' or
object.name == 'solar-panel' or
object.name == 'gun-turret' object.name == 'gun-turret'
then then
entity.destructible = false entity.destructible = false
@ -896,14 +892,11 @@ function create_a_spot(spot_name, spot_position, spot_blueprint)
} }
) )
local draw_spot_force = 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'})
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 = 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'})
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 = 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'})
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} 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) table.insert(table_of_entities, entity)
end end
table.insert( 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})
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 end
function create_a_point_of_interest(poi_blueprint, poi_position) 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 -- draw_gui_spawn( player ) -- only for tests
for _, spot in pairs(global.table_of_spots) do for _, spot in pairs(global.table_of_spots) do
player.force.chart( 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}})
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
game.print(player.name .. ' joined ' .. global.table_of_properties[player.force.name].icon) 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 for _, player in pairs(game.connected_players) do
if player.force.name == spot.properties.force.name and spot.properties.value > 0 then if player.force.name == spot.properties.force.name and spot.properties.value > 0 then
player.force.chart( 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}})
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
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 global.table_of_properties.countdown_in_seconds = global.table_of_properties.countdown_in_seconds - 1
end end
if 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
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 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.') 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 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 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 _, player in pairs(game.connected_players) do
for _, spot in pairs(global.table_of_spots) do for _, spot in pairs(global.table_of_spots) do
if 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
player.force.is_chunk_charted( 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}})
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 if #chart_tags == 0 then
player.force.add_chart_tag( player.force.add_chart_tag(game.surfaces.tank_conquest, {icon = {type = 'virtual', name = 'signal-' .. spot.properties.name}, position = spot.properties.position})
game.surfaces.tank_conquest,
{icon = {type = 'virtual', name = 'signal-' .. spot.properties.name}, position = spot.properties.position}
)
end end
end end
end end
@ -1712,10 +1681,7 @@ local function on_player_changed_position(event)
end end
for _, position in pairs(spot_item.positions) do for _, position in pairs(spot_item.positions) do
if 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
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 if global.table_of_spots[spot_index].players[player.index] == nil then
global.table_of_spots[spot_index].players[player.index] = player 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 and event.cause.valid then
if event.cause.name == 'character' then if event.cause.name == 'character' then
player_death_message = 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 .. '.'
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 elseif event.cause.name == 'car' or event.cause.name == 'tank' or event.cause.name == 'train' then
local driver = event.cause.get_driver() local driver = event.cause.get_driver()
if driver.player then if driver.player then
player_death_message = 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 .. '.'
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 else
player_death_message = global.table_of_properties[player.force.name].icon .. ' ' .. player.name .. ' was killed by run over.' player_death_message = global.table_of_properties[player.force.name].icon .. ' ' .. player.name .. ' was killed by run over.'
end end

View File

@ -15,12 +15,12 @@ require 'modules.rocks_yield_ore'
require 'modules.biters_yield_coins' require 'modules.biters_yield_coins'
require 'modules.mineable_wreckage_yields_scrap' require 'modules.mineable_wreckage_yields_scrap'
local shapes = require 'tools.shapes' local shapes = require 'utils.tools.shapes'
local Event = require 'utils.event' local Event = require 'utils.event'
local unearthing_worm = require 'functions.unearthing_worm' local unearthing_worm = require 'utils.functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters' local unearthing_biters = require 'utils.functions.unearthing_biters'
local tick_tack_trap = require 'functions.tick_tack_trap' local tick_tack_trap = require 'utils.functions.tick_tack_trap'
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 = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2 simplex_noise = simplex_noise.d2

View File

@ -5,7 +5,7 @@
local event = require 'utils.event' local event = require 'utils.event'
local bricks = require 'maps.tetris.bricks' 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_left_top = {x = -17, y = -18}
local playfield_width = 12 local playfield_width = 12
@ -219,10 +219,7 @@ local function add_score_points(amount)
end end
local function move_lines_down(surface, y) local function move_lines_down(surface, y)
local entities = 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'})
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 for _, e in pairs(entities) do
if e.valid then if e.valid then
e.clone {position = {e.position.x, e.position.y + 1}, surface = surface, force = 'enemy'} e.clone {position = {e.position.x, e.position.y + 1}, surface = surface, force = 'enemy'}
@ -419,14 +416,7 @@ local function move(surface, item)
return return
end end
for k, p in pairs(global.active_brick.positions) do for k, p in pairs(global.active_brick.positions) do
if 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
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 return
end end
end end

View File

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

View File

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

View File

@ -9,7 +9,7 @@ local Utils = require 'utils.core'
local Color = require 'utils.color_presets' local Color = require 'utils.color_presets'
local Server = require 'utils.server' local Server = require 'utils.server'
local Jail = require 'utils.datastore.jail_data' 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 Task = require 'utils.task'
local Token = require 'utils.token' local Token = require 'utils.token'
local Discord = require 'utils.discord_handler' local Discord = require 'utils.discord_handler'

View File

@ -498,6 +498,7 @@ local function create_admin_panel(data)
end end
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}) 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.minimal_width = 326
drop_down.style.right_padding = 12 drop_down.style.right_padding = 12

View File

@ -3,7 +3,7 @@ local math_random = math.random
local table_insert = table.insert local table_insert = table.insert
local table_remove = table.remove 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 function get_vector()
local x = 1000 - math_random(0, 2000) local x = 1000 - math_random(0, 2000)

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