1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

new map wip

This commit is contained in:
MewMew 2019-10-06 18:16:32 +02:00
parent 2db22dc92e
commit cc29e4b885
3 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,38 @@
function locomotive_spawn(surface, position)
for y = -6, 6, 2 do
surface.create_entity({name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0})
end
global.locomotive = surface.create_entity({name = "locomotive", position = {position.x, position.y + -3}, force = "player"})
global.locomotive.get_inventory(defines.inventory.fuel).insert({name = "coal", count = 50})
global.locomotive_cargo = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 3}, force = "player"})
global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 4000})
global.locomotive.color = {0, 255, 0}
global.locomotive.minable = false
global.locomotive_cargo.minable = false
global.locomotive_cargo.operable = false
end
local function accelerate()
local driver = global.locomotive.get_driver()
if driver then return end
global.locomotive_driver = game.surfaces["cave_defender"].create_entity({name = "character", position = global.locomotive.position, force = "player"})
global.locomotive_driver.driving = true
global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight}
end
local function remove_acceleration()
if global.locomotive_driver then global.locomotive_driver.destroy() end
end
local function tick()
if game.tick % 30 == 0 then
accelerate()
else
remove_acceleration()
end
end
local event = require 'utils.event'
event.on_nth_tick(5, tick)

View File

@ -0,0 +1,53 @@
-- Cave Defender, protect the locomotive! -- by MewMew
require "maps.cave_defender.terrain"
require "maps.cave_defender.locomotive"
local function init_surface()
local map = {
["seed"] = math.random(1, 1000000),
["water"] = 0,
["starting_area"] = 1,
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
["autoplace_settings"] = {
["entity"] = {treat_missing_as_default = false},
["tile"] = {treat_missing_as_default = false},
["decorative"] = {treat_missing_as_default = false},
},
["default_enable_all_autoplace_controls"] = false,
}
game.create_surface("cave_defender", map)
end
local function on_player_joined_game(event)
local surface = game.surfaces["cave_defender"]
local player = game.players[event.player_index]
if player.online_time == 0 then
player.teleport(surface.find_non_colliding_position("character", {0,0}, 3, 0.5), surface)
end
end
local function on_init(surface)
init_surface()
local surface = game.surfaces["cave_defender"]
surface.request_to_generate_chunks({0,0}, 6)
surface.force_generate_chunk_requests()
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
game.map_settings.enemy_expansion.enabled = true
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
game.map_settings.enemy_expansion.settler_group_max_size = 32
game.map_settings.enemy_expansion.settler_group_min_size = 16
game.map_settings.pollution.enabled = false
locomotive_spawn(surface, {x = 0, y = -10})
end
local event = require 'utils.event'
event.on_init(on_init)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -0,0 +1,29 @@
local function process_position(surface, p)
local distance_to_center = math.sqrt(p.x^2 + p.y^2)
local index = math.floor((distance_to_center / 16) % 18) + 1
--if index == 7 then surface.create_entity({name = "rock-big", position = p}) return end
if index % 2 == 1 then
if math.random(1, 3) == 1 then
surface.create_entity({name = "rock-big", position = p})
else
surface.create_entity({name = "tree-0" .. math.ceil(index * 0.5), position = p})
end
return
end
end
local function on_chunk_generated(event)
local left_top = event.area.left_top
local surface = event.surface
for x = 0.5, 31.5, 1 do
for y = 0.5, 31.5, 1 do
p = {x = left_top.x + x, y = left_top.y + y}
--process_position(surface, p)
end
end
end
local event = require 'utils.event'
event.add(defines.events.on_chunk_generated, on_chunk_generated)