1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-26 03:52:22 +02:00
This commit is contained in:
MewMew 2020-10-10 16:52:51 +02:00
parent d51348fe1a
commit 17b9dbd8ba
4 changed files with 63 additions and 27 deletions

View File

@ -7,6 +7,12 @@ Public.starting_items = {
["raw-fish"] = 8,
}
Public.reveal_chain_brush_sizes = {
["unit"] = 7,
["unit-spawner"] = 15,
["turret"] = 9,
}
Public.spawn_market_items = {
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail', count = 4}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail-signal', count = 2}},

View File

@ -46,6 +46,7 @@ function Public.spawn_random_biter(surface, position, multiplier)
end
unit.ai_settings.allow_try_return_to_spawner = true
unit.ai_settings.allow_destroy_when_commands_fail = false
return unit
end
function Public.loot_crate(surface, position, multiplier, slots, container_name)

View File

@ -6,7 +6,10 @@ local Global = require 'utils.global'
local Market = require 'maps.cave_miner_v2.market'
local Server = require 'utils.server'
local Terrain = require 'maps.cave_miner_v2.terrain'
local Pets = require "modules.biter_pets"
require "modules.satellite_score"
require "modules.hunger"
require 'modules.no_deconstruction_of_neutral_entities'
require "modules.rocks_broken_paint_tiles"
require "modules.rocks_heal_over_time"
@ -45,7 +48,7 @@ local function on_player_changed_position(event)
local player = game.players[event.player_index]
if not player.character then return end
if not player.character.valid then return end
Terrain.reveal(game.surfaces.nauvis, game.surfaces.cave_miner_source, {x = math_floor(player.position.x), y = math_floor(player.position.y)}, 8)
Terrain.reveal(cave_miner, game.surfaces.nauvis, game.surfaces.cave_miner_source, {x = math_floor(player.position.x), y = math_floor(player.position.y)}, 8)
end
local function on_chunk_generated(event)
@ -73,7 +76,10 @@ local function on_player_mined_entity(event)
if entity.type == "simple-entity" then
cave_miner.rocks_broken = cave_miner.rocks_broken + 1
if math.random(1, 16) == 1 then
Functions.spawn_random_biter(surface, position, 1)
local unit = Functions.spawn_random_biter(surface, position, 1)
if math.random(1, 64) == 1 then
Pets.biter_pets_tame_unit(game.players[event.player_index], unit, true)
end
end
end
end
@ -89,6 +95,17 @@ local function on_entity_died(event)
if math.random(1, 2) == 1 then
Functions.spawn_random_biter(surface, position, 1)
end
return
end
if entity.type == "unit-spawner" then
local a = 64 * 0.0001
local b = math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2)
local c = math_floor(a * b) + 1
for _ = 1, c, 1 do
Functions.spawn_random_biter(surface, position, 1)
end
return
end
end
@ -112,6 +129,7 @@ local function init(cave_miner)
surface.freeze_daytime = true
surface.solar_power_multiplier = 999
cave_miner.reveal_queue = {}
cave_miner.rocks_broken = 0
cave_miner.pickaxe_tier = 1
@ -128,7 +146,7 @@ end
local function spawn_players(cave_miner)
local tick = game.ticks_played
if tick % 60 ~= 0 then return end
Terrain.reveal(game.surfaces.nauvis, game.surfaces.cave_miner_source, {x = 0, y = 0}, 8)
Terrain.reveal(cave_miner, game.surfaces.nauvis, game.surfaces.cave_miner_source, {x = 0, y = 0}, 8)
Market.spawn(cave_miner)
for _, player in pairs(game.connected_players) do
Functions.spawn_player(player)
@ -140,6 +158,19 @@ local function game_in_progress(cave_miner)
local tick = game.ticks_played
if tick % 60 ~= 0 then return end
Functions.update_top_gui(cave_miner)
local reveal = cave_miner.reveal_queue[1]
if not reveal then return end
local brush_size = 3
if Constants.reveal_chain_brush_sizes[reveal[1]] then brush_size = Constants.reveal_chain_brush_sizes[reveal[1]] end
Terrain.reveal(
cave_miner,
game.surfaces.nauvis,
game.surfaces.cave_miner_source,
{x = reveal[2], y = reveal[3]},
brush_size
)
table.remove(cave_miner.reveal_queue, 1)
end
local gamestates = {
@ -158,6 +189,7 @@ local function on_init()
cave_miner.mining_speed_bonus = 100
cave_miner.pickaxe_tier = 1
cave_miner.rocks_broken = 0
cave_miner.reveal_queue = {}
global.rocks_yield_ore_maximum_amount = 256
global.rocks_yield_ore_base_amount = 32

View File

@ -6,6 +6,9 @@ local Functions = require 'maps.cave_miner_v2.functions'
local math_abs = math.abs
local math_random = math.random
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 loot_blacklist = {
["landfill"] = true,
}
@ -51,7 +54,7 @@ function Public.out_of_map(event)
event.surface.set_tiles(tiles, false)
end
function Public.reveal(surface, source_surface, position, brushsize)
function Public.reveal(cave_miner, surface, source_surface, position, brushsize)
local tile = source_surface.get_tile(position)
if tile.name == "lab-dark-1" then return end
local tiles = {}
@ -70,6 +73,9 @@ function Public.reveal(surface, source_surface, position, brushsize)
local entity_position = entity.position
if (position.x - entity_position.x) ^ 2 + (position.y - entity_position.y) ^ 2 < brushsize_square then
entity.clone({position = entity_position, surface = surface})
if entity.force.index == 2 then
table.insert(cave_miner.reveal_queue, {entity.type, entity.position.x, entity.position.y})
end
entity.destroy()
end
end
@ -82,26 +88,15 @@ local function get_biome(surface, seed, position)
local d = position.x ^ 2 + position.y ^ 2
if d < 32 then return "spawn" end
if d < 1024 then return "cave" end
local noise = GetNoise("smol_areas", position, seed)
if noise > 0.75 then return "worms" end
if noise < -0.75 then return "nests" end
local noise = GetNoise("cave_rivers", position, seed)
if noise > 0.72 then return "green", noise end
if noise < -0.5 then return "void", noise end
if noise < -0.4 then return "void", noise end
return "cave"
end
local biomes = {}
function biomes.worms(surface, seed, position)
if math_random(1, 16) == 1 then Functions.place_worm(surface, position, 1) end
end
function biomes.nests(surface, seed, position)
if math_random(1, 32) == 1 then surface.create_entity({name = "biter-spawner", position = position, force = "enemy"}) end
end
function biomes.green(surface, seed, position, noise)
if noise < 0.8 then
@ -129,23 +124,25 @@ function biomes.cave(surface, seed, position)
local noise_cave_rivers2 = GetNoise("cave_rivers_3", position, seed + 100000)
if math_abs(noise_cave_rivers2) < 0.05 then surface.set_tiles({{name = "out-of-map", position = position}}, true) return end
if math_abs(noise_cave_rivers1) < 0.025 then
if math_abs(noise_cave_rivers1) < 0.025 and noise_cave_rivers2 > -0.5 then
surface.set_tiles({{name = "water", position = position}}, true)
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = position}) end
return
end
local noise_rock = GetNoise("decoratives", position, seed)
if noise_rock > 0 then
if math_random(1, 3) > 1 then surface.create_entity({name = "rock-big", position = position}) end
local noise_rock = GetNoise("small_caves", position, seed)
if math_abs(noise_rock) > 0.10 then
if math_random(1, 3) > 1 then surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = position}) end
if math_random(1, 512) == 1 then Functions.loot_crate(surface, position, 1, 8, "wooden-chest") return end
if math_random(1, 2048) == 2 then Functions.loot_crate(surface, position, 2, 8, "iron-chest") return end
if math_random(1, 4096) == 4 then Functions.loot_crate(surface, position, 3, 8, "steel-chest") return end
else
local noise_rock_2 = GetNoise("decoratives", position, seed + 50000)
if math_random(1, 3) > 1 and math_abs(noise_rock_2) > 0.15 then surface.create_entity({name = "rock-big", position = position}) end
local d = position.x ^ 2 + position.y ^ 2
if d < 16000 then return end
if math_random(1, 48) == 1 then surface.create_entity({name = "biter-spawner", position = position, force = "enemy"}) end
if math_random(1, 48) == 1 then Functions.place_worm(surface, position, 1) end
end
if math_random(1, 512) == 1 then Functions.loot_crate(surface, position, 1, 8, "wooden-chest") end
if math_random(1, 2048) == 2 then Functions.loot_crate(surface, position, 2, 8, "iron-chest") end
if math_random(1, 4096) == 4 then Functions.loot_crate(surface, position, 3, 8, "steel-chest") end
end
function Public.generate_cave(event)
@ -159,7 +156,7 @@ function Public.generate_cave(event)
for x = 0, 31, 1 do
for y = 0, 31, 1 do
i = i + 1
tiles[i] = {name = "nuclear-ground", position = {left_top_x + x, left_top_y + y}}
tiles[i] = {name = "dirt-7", position = {left_top_x + x, left_top_y + y}}
end
end
surface.set_tiles(tiles, true)