From 162d1e1e9a48b3e68aecd403a98c1a80f2630bc5 Mon Sep 17 00:00:00 2001 From: MewMew Date: Wed, 22 Jul 2020 05:59:32 +0200 Subject: [PATCH] update --- maps/expanse/functions.lua | 61 +++++++++++++++++++++++------------ maps/expanse/main.lua | 24 ++++++++++++-- maps/expanse/price_raffle.lua | 2 +- 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/maps/expanse/functions.lua b/maps/expanse/functions.lua index 24c52d56..f18a741e 100644 --- a/maps/expanse/functions.lua +++ b/maps/expanse/functions.lua @@ -2,16 +2,16 @@ local Price_raffle = require 'maps.expanse.price_raffle' local Public = {} local price_modifiers = { - ["unit-spawner"] = -128, + ["unit-spawner"] = -256, ["unit"] = -16, ["turret"] = -128, ["tree"] = -8, - ["simple-entity"] = -12, - ["cliff"] = -32, - ["water"] = -4, - ["water-green"] = -4, - ["deepwater"] = -4, - ["deepwater-green"] = -4, + ["simple-entity"] = 2, + ["cliff"] = -128, + ["water"] = -5, + ["water-green"] = -5, + ["deepwater"] = -5, + ["deepwater-green"] = -5, ["water-mud"] = -6, ["water-shallow"] = -6, } @@ -30,18 +30,19 @@ local function get_cell_value(expanse, left_top) if price_modifiers[tile.name] then value = value + price_modifiers[tile.name] end - end - - local distance = math.sqrt(left_top.x ^ 2 + left_top.y ^ 2) - local value = value * (distance * 0.005) - - local ore_modifier = distance * 0.00025 - if ore_modifier > 0.5 then ore_modifier = 0.5 end - + end for _, entity in pairs(entities) do if price_modifiers[entity.type] then value = value + price_modifiers[entity.type] end + end + + local distance = math.sqrt(left_top.x ^ 2 + left_top.y ^ 2) + local value = value * (distance * 0.005) + local ore_modifier = distance * 0.00025 + if ore_modifier > 0.33 then ore_modifier = 0.33 end + + for _, entity in pairs(entities) do if entity.type == "resource" then if entity.name == "crude-oil" then value = value + (entity.amount * ore_modifier * 0.01) @@ -96,7 +97,7 @@ end function Public.expand(expanse, left_top) local source_surface = game.surfaces[expanse.source_surface] if not source_surface then return end - source_surface.request_to_generate_chunks({x = 0, y = 0}, 3) + source_surface.request_to_generate_chunks(left_top, 3) source_surface.force_generate_chunk_requests() local square_size = expanse.square_size @@ -134,12 +135,17 @@ function Public.expand(expanse, left_top) if game.tick == 0 then local a = math.floor(expanse.square_size * 0.5) - surface.create_entity({name = "crude-oil", position = {a - 3, a}, amount = 300000}) - local e = surface.create_entity({name = "offshore-pump", force = "player", position = {a + 1, a}}) - e.destructible = false - e.minable = false + for x = 1, 3, 1 do + for y = 1, 3, 1 do + surface.set_tiles({{name = "water", position = {a + x, a + y - 2}}}, true) + end + end + surface.create_entity({name = "crude-oil", position = {a - 3, a}, amount = 1500000}) surface.create_entity({name = "rock-big", position = {a, a}}) surface.create_entity({name = "tree-0" .. math.random(1,9), position = {a, a - 1}}) + surface.spill_item_stack({a, a + 2}, {name = "small-plane", count = 1}, false, nil, false) + surface.spill_item_stack({a + 0.5, a + 2.5}, {name = "small-plane", count = 1}, false, nil, false) + surface.spill_item_stack({a - 0.5, a + 2.5}, {name = "small-plane", count = 1}, false, nil, false) end end @@ -176,6 +182,16 @@ function Public.set_container(expanse, entity) local inventory = container.entity.get_inventory(defines.inventory.chest) + if not inventory.is_empty() then + local contents = inventory.get_contents() + if contents["small-plane"] then + local count_removed = inventory.remove({name = "small-plane", count = 1}) + if count_removed > 0 then + init_container(expanse, entity) + end + end + end + for key, item_stack in pairs(container.price) do local count_removed = inventory.remove(item_stack) container.price[key].count = container.price[key].count - count_removed @@ -191,7 +207,10 @@ function Public.set_container(expanse, entity) for name, count in pairs(inventory.get_contents()) do entity.surface.spill_item_stack(entity.position, {name = name, count = count}, true, nil, false) end - end + end + if math.random(1, 3) == 1 then + entity.surface.spill_item_stack(entity.position, {name = "small-plane", count = 1}, true, nil, false) + end entity.destructible = true entity.die() return diff --git a/maps/expanse/main.lua b/maps/expanse/main.lua index 81a12742..0c324d9b 100644 --- a/maps/expanse/main.lua +++ b/maps/expanse/main.lua @@ -16,7 +16,7 @@ Global.register( local function reset() expanse.containers = {} - expanse.source_surface = 1 + if not expanse.source_surface then expanse.source_surface = "nauvis" end expanse.square_size = 15 local map_gen_settings = { @@ -42,6 +42,26 @@ local function reset() } game.create_surface("expanse", map_gen_settings) + if expanse.source_surface == "nauvis" then + local surface = game.surfaces[1] + local map_gen_settings = surface.map_gen_settings + map_gen_settings.autoplace_controls = { + ["coal"] = {frequency = 10, size = 0.7, richness = 0.5,}, + ["stone"] = {frequency = 10, size = 0.7, richness = 0.5,}, + ["copper-ore"] = {frequency = 10, size = 0.7, richness = 0.75,}, + ["iron-ore"] = {frequency = 10, size = 0.7, richness = 1,}, + ["uranium-ore"] = {frequency = 10, size = 0.5, richness = 1,}, + ["crude-oil"] = {frequency = 25, size = 1.5, richness = 1.5,}, + ["trees"] = {frequency = 1.5, size = 1, richness = 1}, + ["enemy-base"] = {frequency = 10, size = 2, richness = 1}, + } + map_gen_settings.starting_area = 0.25 + surface.map_gen_settings = map_gen_settings + for chunk in surface.get_chunks() do + surface.delete_chunk({chunk.x, chunk.y}) + end + end + local source_surface = game.surfaces[expanse.source_surface] source_surface.request_to_generate_chunks({x = 0, y = 0}, 4) source_surface.force_generate_chunk_requests() @@ -111,7 +131,7 @@ local function infini_rock(entity) local a = math.floor(expanse.square_size * 0.5) if entity.position.x == a and entity.position.y == a then entity.surface.create_entity({name = "rock-big", position = {a, a}}) - entity.surface.spill_item_stack(entity.position, {name = ores[math.random(1,4)], count = math.random(125, 250)}, true, nil, true) + entity.surface.spill_item_stack(entity.position, {name = ores[math.random(1,4)], count = math.random(100, 200)}, true, nil, true) end end diff --git a/maps/expanse/price_raffle.lua b/maps/expanse/price_raffle.lua index 99696941..b979ef35 100644 --- a/maps/expanse/price_raffle.lua +++ b/maps/expanse/price_raffle.lua @@ -227,7 +227,7 @@ function Public.roll_item_stack(remaining_budget, blacklist) if not blacklist[item_name] and item_worth <= remaining_budget then break end end - local stack_size = game.item_prototypes[item_name].stack_size * 16 + local stack_size = game.item_prototypes[item_name].stack_size * 32 local item_count = 1