1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00
This commit is contained in:
MewMew 2019-11-20 20:43:50 +01:00
parent e327d08280
commit 5cf46329c7
4 changed files with 80 additions and 9 deletions

View File

@ -8,7 +8,7 @@ function Public.locomotive_spawn(surface, position)
global.locomotive.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 100})
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 = 8})
global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1})
rendering.draw_light({
sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0,
@ -59,6 +59,17 @@ local function remove_acceleration()
end
]]
local market_offers = {
{price = {{'coin', 5}}, offer = {type = 'give-item', item = "raw-fish"}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'wood', count = 50}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'stone', count = 50}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'coal', count = 50}},
{price = {{"coin", 16}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
{price = {{"coin", 5}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}},
}
local function create_wagon_room()
local width = 15
local height = 35
@ -79,29 +90,86 @@ local function create_wagon_room()
surface.request_to_generate_chunks({0,0}, 1)
surface.force_generate_chunk_requests()
for x = width * -0.5, width * 0.5, 1 do
for x = width * -0.5 + 1, width * 0.5, 1 do
for y = height * -0.5, height * 0.5, 1 do
surface.set_tiles({{name = "tutorial-grid", position = {x,y}}})
if math.random(1, 5) == 1 then
if math.random(1, 5) == 1 and y < 4 then
surface.spill_item_stack({x + math.random(0, 9) * 0.1,y + math.random(0, 9) * 0.1},{name = "raw-fish", count = 1}, false)
end
end
end
for _, x in pairs({width * -0.5 - 1, width * 0.5 + 1}) do
local e = surface.create_entity({name = "car", position = {x, 0}, force = "player"})
for _, x in pairs({width * -0.5, width * 0.5 + 1}) do
local e = surface.create_entity({name = "car", position = {x, 0}, force = "player", create_build_effect_smoke = false})
e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16})
e.destructible = false
e.minable = false
e.operable = false
end
local market = surface.create_entity({name = "market", position = {0, height * -0.25}, force="neutral", create_build_effect_smoke = false})
market.minable = false
market.destructible = false
for _, offer in pairs(market_offers) do market.add_market_item(offer) end
local e = surface.create_entity({name = "behemoth-biter", position = {0, height * -0.4}, force = "player", create_build_effect_smoke = false})
e.ai_settings.allow_destroy_when_commands_fail = false
e.ai_settings.allow_try_return_to_spawner = false
local positions = {}
for x = width * -0.5 + 2, width * 0.5 - 1, 1 do
for y = 4, height * 0.5 - 1, 1 do
positions[#positions + 1] = {x = x, y = y}
end
end
table.shuffle_table(positions)
local cargo_boxes = {
{name = "grenade", count = math.random(2, 3)},
{name = "submachine-gun", count = 1},
{name = "land-mine", count = math.random(8, 12)},
{name = "explosives", count = math.random(57, 73)},
{name = "explosives", count = math.random(57, 73)},
{name = "iron-gear-wheel", count = math.random(7, 15)},
{name = "iron-plate", count = math.random(15, 23)},
{name = "copper-plate", count = math.random(15, 23)},
{name = "shotgun", count = 1},
{name = "shotgun-shell", count = math.random(5, 7)},
{name = "firearm-magazine", count = math.random(7, 15)},
{name = "rail", count = math.random(16, 24)},
{name = "rail", count = math.random(16, 24)},
{name = "rail", count = math.random(16, 24)},
}
local i = 1
for _ = 1, 10, 1 do
if not positions[i] then break end
local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false})
local inventory = e.get_inventory(defines.inventory.chest)
inventory.insert({name = "raw-fish", count = math.random(2, 5)})
i = i + 1
end
for _ = 1, 24, 1 do
if not positions[i] then break end
local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false})
i = i + 1
end
for loot_i = 1, #cargo_boxes, 1 do
if not positions[i] then break end
local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false})
local inventory = e.get_inventory(defines.inventory.chest)
inventory.insert(cargo_boxes[loot_i])
i = i + 1
end
end
function Public.set_player_spawn_and_refill_fish()
if not global.locomotive_cargo then return end
if not global.locomotive_cargo.valid then return end
global.locomotive_cargo.health = global.locomotive_cargo.health + 6
global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = math.random(2, 5)})
global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = math.random(1, 2)})
local position = global.locomotive_cargo.surface.find_non_colliding_position("stone-furnace", global.locomotive_cargo.position, 16, 2)
if not position then return end
game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface)

View File

@ -53,6 +53,8 @@ function Public.reset_map()
local wave_defense_table = WD.get_table()
global.chunk_queue = {}
if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end
local map_gen_settings = {
["seed"] = math_random(1, 1000000),
["width"] = level_depth,

View File

@ -924,8 +924,9 @@ local function process_chunk_queue()
end
]]
local function on_chunk_generated(event)
if event.surface.index ~= global.active_surface_index then return end
if string.sub(event.surface.name, 0, 8) ~= "mountain" then return end
process_chunk(event.surface, event.area.left_top)
--global.chunk_queue[#global.chunk_queue + 1] = {left_top = {x = event.area.left_top.x, y = event.area.left_top.y}, surface_index = event.surface.index}
end

View File

@ -169,7 +169,7 @@ function Public.treasure_chest(surface, position, container_name)
end
end
local e = surface.create_entity({name = container_name, position=position, force="neutral"})
local e = surface.create_entity({name = container_name, position=position, force="neutral", create_build_effect_smoke = false})
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(2,6), 1 do