diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index e4c4419e..b3f8165d 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -4,7 +4,7 @@ map_info= - - B I T E R B A T T L E S - -\n\n Your objective is to defend you [desert_oasis] map_info_main_caption=--Desert Oasis-- map_info_sub_caption=Survival in the dry sands. -map_info_text=This is a harsh world, the heat is unbearable and the sand is sharp like diamonds.\nWe shall not attempt to travel without a proper vehicle.\nMany building foundations are not possible to be set up outside of the oasis.\n\nLuckily the ship's moisture meter module did survive the crash.\nIt may come in handy! +map_info_text=This is a harsh world, the heat is unbearable and the sand is sharp like diamonds.\nWe shall not attempt to travel without a proper vehicle.\nMany building foundations are not possible to be set up outside of the oasis.\nRailways between them however should be possible.\n\nLuckily the ship's moisture meter module did survive the crash.\nIt may come in handy! [fish_defender] map_info_main_caption=--Fish Defender-- diff --git a/maps/desert_oasis.lua b/maps/desert_oasis.lua index de22268d..cce54a49 100644 --- a/maps/desert_oasis.lua +++ b/maps/desert_oasis.lua @@ -9,11 +9,28 @@ local math_floor = math.floor local math_abs = math.abs local string_sub = string.sub -local oasis_start = 0.5 -local water_start = 0.75 -local sand_damage = oasis_start * 100 + 20 +local oasis_start = 0.50 +local water_start = 0.78 +local sand_damage = oasis_start * 100 + 16 + +local trees = {"tree-01", "tree-04", "tree-06", "tree-08-red", "tree-08", "tree-09",} + +local tile_to_item = { + ["stone-path"] = "stone-brick", + ["hazard-concrete-left"] = "hazard-concrete", + ["hazard-concrete-right"] = "hazard-concrete", + ["refined-hazard-concrete-left"] = "refined-hazard-concrete", + ["refined-hazard-concrete-right"] = "refined-hazard-concrete", +} local save_tiles = { + ["stone-path"] = true, + ["hazard-concrete-left"] = true, + ["hazard-concrete-right"] = true, + ["refined-concrete"] = true, + ["refined-hazard-concrete-left"] = true, + ["refined-hazard-concrete-right"] = true, + ["water"] = true, ["grass-1"] = true, ["grass-2"] = true, ["grass-3"] = true, @@ -21,8 +38,6 @@ local save_tiles = { ["deepwater"] = true, } -local ores = {"iron-ore", "copper-ore", "coal", "stone"} - local function get_moisture(position) local moisture = get_noise("oasis", position, global.desert_oasis_seed) moisture = moisture * 128 @@ -48,31 +63,28 @@ local function moisture_meter(player, moisture) moisture_meter.children[2].caption = moisture end -local function on_chunk_generated(event) - local surface = event.surface - if surface.name ~= "desert_oasis" then return end - local seed = global.desert_oasis_seed - local left_top = event.area.left_top - +local function draw_oasis(surface, left_top, seed) local tiles = {} local size_of_tiles = 0 local entities = {} local size_of_entities = 0 - - local noise = get_noise("oasis", left_top, seed) - if noise < oasis_start - 0.25 then return end - - local left_top_x = event.area.left_top.x - local left_top_y = event.area.left_top.y + local left_top_x = left_top.x + local left_top_y = left_top.y for x = 0, 31, 1 do for y = 0, 31, 1 do local position = {x = left_top_x + x, y = left_top_y + y} local noise = get_noise("oasis", position, seed) - if noise > oasis_start then - if noise > water_start then + if noise >= oasis_start then + if noise > water_start or noise > oasis_start + 0.035 and get_noise("cave_ponds", position, seed) > 0.72 then size_of_tiles = size_of_tiles + 1 - tiles[size_of_tiles] = {name = "water", position = position} + + if noise > 0.85 then + tiles[size_of_tiles] = {name = "deepwater", position = position} + else + tiles[size_of_tiles] = {name = "water", position = position} + end + if math_random(1, 64) == 1 then size_of_entities = size_of_entities + 1 entities[size_of_entities] = {name = "fish", position = position} @@ -85,23 +97,10 @@ local function on_chunk_generated(event) cliff.destroy() end - if noise > water_start - 0.07 then + if math_random(1, 12) == 1 and surface.can_place_entity({name = "coal", position = position, amount = 1}) then size_of_entities = size_of_entities + 1 - local bonus = math_floor(math.sqrt(position.x ^ 2 + position.y ^ 2) * 0.35) - entities[size_of_entities] = {name = ores[math_floor(get_noise("small_caves", position, seed) * 4) % 4 + 1], position = position, amount = math_random(400 + bonus, 600 + bonus)} - else - if get_noise("n3", position, seed) > 0.68 then - if math_random(1, 128) == 1 then - size_of_entities = size_of_entities + 1 - entities[size_of_entities] = {name = "crude-oil", position = position, amount = math_random(250000, 500000)} - end - end - - if math_random(1, 12) == 1 then - size_of_entities = size_of_entities + 1 - if math_abs(get_noise("n3", position, seed)) > 0.30 then - entities[size_of_entities] = {name = "tree-0" .. math_floor(get_noise("n2", position, seed) * 9) % 9 + 1, position = position} - end + if math_abs(get_noise("n3", position, seed)) > 0.50 then + entities[size_of_entities] = {name = trees[math_floor(get_noise("n2", position, seed) * 9) % 6 + 1], position = position} end end end @@ -118,6 +117,33 @@ local function on_chunk_generated(event) end end +local function on_chunk_generated(event) + local surface = event.surface + if surface.name ~= "desert_oasis" then return end + local seed = global.desert_oasis_seed + local left_top = event.area.left_top + + for _, entity in pairs(surface.find_entities_filtered({area = event.area, type = "resource"})) do + if get_noise("oasis", entity.position, seed) <= oasis_start then + entity.destroy() + else + if game.item_prototypes[entity.name] then + surface.create_entity({name = entity.name, position = entity.position, amount = math_random(200, 300) + math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.65}) + entity.destroy() + end + end + end + + for _, entity in pairs(surface.find_entities_filtered({area = event.area, force = "enemy"})) do + if get_noise("oasis", entity.position, seed) > -0.25 then + entity.destroy() + end + end + + local noise = get_noise("oasis", left_top, seed) + if noise > oasis_start - 0.35 then draw_oasis(surface, left_top, seed) return end +end + local function on_init() if game.surfaces["desert_oasis"] then return end @@ -134,15 +160,16 @@ local function on_init() }, starting_area = 1, terrain_segmentation = 0.1, - cliff_settings = {cliff_elevation_interval = 4, cliff_elevation_0 = 4}, + cliff_settings = {cliff_elevation_interval = 8, cliff_elevation_0 = 8}, autoplace_controls = { - ["coal"] = {frequency = 0.5, size = 0.5, richness = 0.5}, - ["stone"] = {frequency = 0.5, size = 0.5, richness = 0.5}, - ["copper-ore"] = {frequency = 0.5, size = 0.5, richness = 0.5}, - ["iron-ore"] = {frequency = 0.5, size = 0.5, richness = 0.5}, - ["crude-oil"] = {frequency = 1, size = 0.5, richness = 0.5}, - ["trees"] = {frequency = 0.5, size = 0.5, richness = 0.15}, - ["enemy-base"] = {frequency = 0.5, size = 1.5, richness = 1}, + ["coal"] = {frequency = 23, size = 0.5, richness = 0.5}, + ["stone"] = {frequency = 20, size = 0.5, richness = 0.5}, + ["copper-ore"] = {frequency = 25, size = 0.5, richness = 0.5}, + ["iron-ore"] = {frequency = 35, size = 0.5, richness = 0.5}, + ["uranium-ore"] = {frequency = 20, size = 0.5, richness = 0.5}, + ["crude-oil"] = {frequency = 80, size = 0.55, richness = 1}, + ["trees"] = {frequency = 0.75, size = 0.75, richness = 0.1}, + ["enemy-base"] = {frequency = 15, size = 1, richness = 1}, }, } @@ -172,22 +199,19 @@ local function on_init() end local type_whitelist = { + ["artillery-wagon"] = true, ["car"] = true, - ["electric-pole"] = true, + ["cargo-wagon"] = true, + ["construction-robot"] = true, ["entity-ghost"] = true, + ["fluid-wagon"] = true, ["heat-pipe"] = true, - ["lamp"] = true, - ["loader"] = true, - ["mining-drill"] = true, - ["pipe"] = true, - ["pipe-to-ground"] = true, + ["locomotive"] = true, + ["logistic-robot"] = true, ["rail-chain-signal"] = true, ["rail-signal"] = true, - ["splitter"] = true, ["straight-rail"] = true, - ["train-stop"] = true, - ["transport-belt"] = true, - ["underground-belt"] = true, + ["train-stop"] = true, } local function deny_building(event) @@ -223,11 +247,45 @@ local function on_robot_built_entity(event) deny_building(event) end +local function deny_tile_building(surface, inventory, tiles, tile) + for _, t in pairs(tiles) do + if not save_tiles[t.old_tile.name] then + surface.set_tiles({{name = t.old_tile.name, position = t.position}}, true) + if game.item_prototypes[tile.name] then + inventory.insert({name = tile.name, count = 1}) + else + if tile_to_item[tile.name] then + inventory.insert({name = tile_to_item[tile.name], count = 1}) + else + inventory.insert({name = "stone-brick", count = 1}) + end + end + end + end +end + +local function on_player_built_tile(event) + local player = game.players[event.player_index] + deny_tile_building(player.surface, player, event.tiles, event.tile) +end + +local function on_robot_built_tile(event) + deny_tile_building(event.robot.surface, event.robot.get_inventory(defines.inventory.robot_cargo), event.tiles, event.tile) +end + local function on_player_joined_game(event) local player = game.players[event.player_index] if player.online_time == 0 then - player.insert({name = "iron-plate", count = 32}) - player.insert({name = "iron-gear-wheel", count = 16}) + player.insert({name = "raw-fish", count = 3}) + player.insert({name = "grenade", count = 1}) + player.insert({name = "computer", count = 1}) + player.insert({name = "iron-plate", count = 16}) + player.insert({name = "iron-gear-wheel", count = 8}) + player.insert({name = "stone", count = 5}) + player.insert({name = "pistol", count = 1}) + player.insert({name = "repair-pack", count = 2}) + player.insert({name = "firearm-magazine", count = 8}) + player.insert({name = "water-barrel", count = 1}) player.teleport(game.surfaces["desert_oasis"].find_non_colliding_position("character", {64, 64}, 50, 0.5), "desert_oasis") end end @@ -245,12 +303,18 @@ local function on_player_changed_position(event) if save_tiles[player.surface.get_tile(player.position).name] then return end - player.character.health = player.character.health - (sand_damage - moisture) * 0.5 + if math_random(1, 64) == 1 then + player.surface.create_entity({name = "fire-flame", position = player.position}) + end + + player.character.health = player.character.health - (sand_damage - moisture) * 0.60 if player.character.health == 0 then player.character.die() end end local Event = require 'utils.event' Event.on_init(on_init) +Event.add(defines.events.on_robot_built_tile, on_robot_built_tile) +Event.add(defines.events.on_player_built_tile, on_player_built_tile) Event.add(defines.events.on_robot_built_entity, on_robot_built_entity) Event.add(defines.events.on_built_entity, on_built_entity) Event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/utils/get_noise.lua b/utils/get_noise.lua index 4dbfd206..fc3d89a4 100644 --- a/utils/get_noise.lua +++ b/utils/get_noise.lua @@ -14,7 +14,7 @@ local noises = { ["n4"] = {{modifier = 0.1, weight = 1}}, ["no_rocks"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, ["no_rocks_2"] = {{modifier = 0.013, weight = 1}, {modifier = 0.1, weight = 0.1}}, - ["oasis"] = {{modifier = 0.0015, weight = 1}, {modifier = 0.0025, weight = 0.5}, {modifier = 0.01, weight = 0.09}, {modifier = 0.1, weight = 0.025}}, + ["oasis"] = {{modifier = 0.0015, weight = 1}, {modifier = 0.0025, weight = 0.5}, {modifier = 0.01, weight = 0.15}, {modifier = 0.1, weight = 0.017}}, ["scrapyard"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.35}, {modifier = 0.05, weight = 0.23}, {modifier = 0.1, weight = 0.11}}, ["small_caves"] = {{modifier = 0.008, weight = 1}, {modifier = 0.03, weight = 0.15}, {modifier = 0.25, weight = 0.05}}, ["small_caves_2"] = {{modifier = 0.009, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.25, weight = 0.05}},