mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
update
This commit is contained in:
parent
b02c117218
commit
de08d70dcf
@ -9,7 +9,7 @@ market.weapons = {
|
||||
["combat-shotgun"] = {value = 400, rarity = 5},
|
||||
["rocket-launcher"] = {value = 250, rarity = 4},
|
||||
["flamethrower"] = {value = 750, rarity = 6},
|
||||
["land-mine"] = {value = 3, rarity = 5},
|
||||
["land-mine"] = {value = 5, rarity = 5},
|
||||
}
|
||||
|
||||
market.ammo = {
|
||||
@ -221,9 +221,18 @@ function Public.mountain_market(surface, position, rarity)
|
||||
if not items then return end
|
||||
if #items > 0 then table.shuffle_table(items) end
|
||||
local market = surface.create_entity({name = "market", position = position, force="neutral"})
|
||||
|
||||
local blacklist = {
|
||||
["cargo-wagon"] = true,
|
||||
["locomotive"] = true,
|
||||
["artillery-wagon"] = true,
|
||||
["fluid-wagon"] = true,
|
||||
}
|
||||
|
||||
for i = 1, math.random(5, 10), 1 do
|
||||
if not items[i] then break end
|
||||
market.add_market_item(items[i])
|
||||
local item = items[i]
|
||||
if not item then break end
|
||||
if not blacklist[item.offer.item] then market.add_market_item(items[i]) end
|
||||
end
|
||||
|
||||
local sells = get_resource_market_sells()
|
||||
|
@ -51,6 +51,15 @@ local function game_over()
|
||||
end
|
||||
end
|
||||
|
||||
local function disable_recipes()
|
||||
local force = game.forces.player
|
||||
force.recipes["cargo-wagon"].enabled = false
|
||||
force.recipes["fluid-wagon"].enabled = false
|
||||
force.recipes["artillery-wagon"].enabled = false
|
||||
force.recipes["locomotive"].enabled = false
|
||||
force.recipes["pistol"].enabled = false
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = #game.connected_players
|
||||
@ -132,8 +141,10 @@ function Public.reset_map()
|
||||
|
||||
game.forces.player.technologies["land-mine"].enabled = false
|
||||
game.forces.player.technologies["landfill"].enabled = false
|
||||
game.forces.player.technologies["fluid-wagon"].enabled = false
|
||||
game.forces.player.technologies["railway"].researched = true
|
||||
game.forces.player.recipes["pistol"].enabled = false
|
||||
disable_recipes()
|
||||
|
||||
game.forces.player.set_spawn_position({-2, 16}, surface)
|
||||
game.forces.enemy.set_ammo_damage_modifier("bullet", 1)
|
||||
game.forces.enemy.set_turret_attack_modifier("gun-turret", 1)
|
||||
@ -323,6 +334,7 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
|
||||
local function on_research_finished(event)
|
||||
disable_recipes()
|
||||
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots / level
|
||||
local mining_speed_bonus = game.forces.player.mining_drill_productivity_bonus * 5 -- +50% speed / level
|
||||
if event.research.force.technologies["steel-axe"].researched then mining_speed_bonus = mining_speed_bonus + 0.5 end -- +50% speed for steel-axe research
|
||||
|
@ -1,4 +1,5 @@
|
||||
local Biters = require 'modules.wave_defense.biter_rolls'
|
||||
local Immersive_cargo_wagons = require "modules.immersive_cargo_wagons.main"
|
||||
local Treasure = require 'maps.mountain_fortress_v2.treasure'
|
||||
local Market = require 'functions.basic_markets'
|
||||
local math_random = math.random
|
||||
@ -6,6 +7,7 @@ local math_floor = math.floor
|
||||
local math_abs = math.abs
|
||||
local simplex_noise = require "utils.simplex_noise".d2
|
||||
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 wagon_raffle = {"cargo-wagon", "cargo-wagon", "cargo-wagon", "cargo-wagon", "cargo-wagon", "locomotive", "fluid-wagon"}
|
||||
local size_of_rock_raffle = #rock_raffle
|
||||
local spawner_raffle = {"biter-spawner", "biter-spawner", "biter-spawner", "spitter-spawner"}
|
||||
local noises = {
|
||||
@ -42,12 +44,41 @@ local function get_replacement_tile(surface, position)
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with("resource-layer") then return tile.name end
|
||||
if tile.valid and not tile.collides_with("resource-layer") then return tile.name end
|
||||
end
|
||||
end
|
||||
return "grass-1"
|
||||
end
|
||||
|
||||
local function place_wagon(surface, left_top)
|
||||
local position = {x = left_top.x + math_random(4, 12) * 2, y = left_top.y + math_random(4, 12) * 2}
|
||||
|
||||
local direction
|
||||
local tiles
|
||||
local r1 = math_random(2, 4) * 2
|
||||
local r2 = math_random(2, 4) * 2
|
||||
|
||||
if math_random(1, 2) == 1 then
|
||||
tiles = surface.find_tiles_filtered({area = {{position.x, position.y - r1}, {position.x + 2, position.y + r2}}})
|
||||
direction = 0
|
||||
else
|
||||
tiles = surface.find_tiles_filtered({area = {{position.x - r1, position.y}, {position.x + r2, position.y + 2}}})
|
||||
direction = 2
|
||||
end
|
||||
|
||||
for k, tile in pairs(tiles) do
|
||||
if tile.collides_with("resource-layer") then surface.set_tiles({{name = "landfill", position = tile.position}}, true) end
|
||||
for _, e in pairs(surface.find_entities_filtered({position = tile.position, force = {"neutral", "enemy"}})) do e.destroy() end
|
||||
if tile.position.y % 2 == 0 and tile.position.x % 2 == 0 then surface.create_entity({name = "straight-rail", position = tile.position, force = "player", direction = direction}) end
|
||||
end
|
||||
|
||||
local entity = surface.create_entity({name = wagon_raffle[math_random(1, #wagon_raffle)], position = position, force = "player"})
|
||||
entity.minable = false
|
||||
|
||||
local wagon = Immersive_cargo_wagons.register_wagon(entity, true)
|
||||
wagon.entity_count = 999
|
||||
end
|
||||
|
||||
local function get_oil_amount(p)
|
||||
return (math_abs(p.y) * 200 + 10000) * math_random(75, 125) * 0.01
|
||||
end
|
||||
@ -951,7 +982,11 @@ local function process_chunk(surface, left_top)
|
||||
local p = global.locomotive.position
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end
|
||||
end
|
||||
if left_top.y < 0 then rock_chunk(surface, left_top) return end
|
||||
if left_top.y < 0 then
|
||||
rock_chunk(surface, left_top)
|
||||
if math_random(1, 160) == 1 then place_wagon(surface, left_top) end
|
||||
return
|
||||
end
|
||||
if left_top.y > 96 then out_of_map(surface, left_top) return end
|
||||
if left_top.y > 64 then biter_chunk(surface, left_top) return end
|
||||
if left_top.y >= 0 then border_chunk(surface, left_top) return end
|
||||
|
@ -6,16 +6,23 @@ local math_abs = math.abs
|
||||
|
||||
local LootRaffle = require "functions.loot_raffle"
|
||||
|
||||
local blacklist = {
|
||||
["cargo-wagon"] = true,
|
||||
["locomotive"] = true,
|
||||
["artillery-wagon"] = true,
|
||||
["fluid-wagon"] = true,
|
||||
}
|
||||
|
||||
function Public.treasure_chest(surface, position, container_name)
|
||||
local budget = 32 + math_abs(position.y) * 2
|
||||
budget = budget * math_random(25, 175) * 0.01
|
||||
local budget = 64 + math_abs(position.y) * 1.75
|
||||
budget = budget * math_random(35, 165) * 0.01
|
||||
if math_random(1,200) == 1 then
|
||||
budget = budget * 10
|
||||
container_name = "crash-site-chest-" .. math_random(1, 2)
|
||||
end
|
||||
budget = math_floor(budget) + 1
|
||||
|
||||
local item_stacks = LootRaffle.roll(budget, 8)
|
||||
local item_stacks = LootRaffle.roll(budget, 8, blacklist)
|
||||
local container = surface.create_entity({name = container_name, position = position, force = "neutral"})
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
container.insert(item_stack)
|
||||
|
@ -349,22 +349,27 @@ function Public.create_wagon_room(icw, wagon)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.create_wagon(icw, created_entity)
|
||||
function Public.create_wagon(icw, created_entity, delay_surface)
|
||||
if not created_entity.unit_number then return end
|
||||
if icw.trains[tonumber(created_entity.surface.name)] or icw.wagons[tonumber(created_entity.surface.name)] then return end
|
||||
if not Constants.wagon_types[created_entity.type] then return end
|
||||
local wagon_area = Constants.wagon_areas[created_entity.type]
|
||||
|
||||
|
||||
icw.wagons[created_entity.unit_number] = {
|
||||
entity = created_entity,
|
||||
area = {left_top = {x = wagon_area.left_top.x, y = wagon_area.left_top.y}, right_bottom = {x = wagon_area.right_bottom.x, y = wagon_area.right_bottom.y}},
|
||||
surface = Public.create_room_surface(icw, created_entity.unit_number),
|
||||
doors = {},
|
||||
entity_count = 0,
|
||||
}
|
||||
Public.create_wagon_room(icw, icw.wagons[created_entity.unit_number])
|
||||
entity = created_entity,
|
||||
area = {left_top = {x = wagon_area.left_top.x, y = wagon_area.left_top.y}, right_bottom = {x = wagon_area.right_bottom.x, y = wagon_area.right_bottom.y}},
|
||||
doors = {},
|
||||
entity_count = 0,
|
||||
}
|
||||
local wagon = icw.wagons[created_entity.unit_number]
|
||||
|
||||
if not delay_surface then
|
||||
wagon.surface = Public.create_room_surface(icw, created_entity.unit_number)
|
||||
Public.create_wagon_room(icw, icw.wagons[created_entity.unit_number])
|
||||
end
|
||||
|
||||
Public.request_reconstruction(icw)
|
||||
return icw.wagons[created_entity.unit_number]
|
||||
return wagon
|
||||
end
|
||||
|
||||
function Public.add_wagon_entity_count(icw, added_entity)
|
||||
@ -516,6 +521,12 @@ function Public.reconstruct_all_trains(icw)
|
||||
Public.request_reconstruction(icw)
|
||||
return
|
||||
end
|
||||
|
||||
if not wagon.surface then
|
||||
wagon.surface = Public.create_room_surface(icw, unit_number)
|
||||
Public.create_wagon_room(icw, wagon)
|
||||
end
|
||||
|
||||
local carriages = wagon.entity.train.carriages
|
||||
Public.construct_train(icw, carriages)
|
||||
end
|
||||
|
@ -121,8 +121,9 @@ function Public.get_table()
|
||||
return icw
|
||||
end
|
||||
|
||||
function Public.register_wagon(wagon_entity)
|
||||
return Functions.create_wagon(icw, wagon_entity)
|
||||
--Set delay_surface to true when using on_chunk_generated event, to prevent issues.
|
||||
function Public.register_wagon(wagon_entity, delay_surface)
|
||||
return Functions.create_wagon(icw, wagon_entity, delay_surface)
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
Loading…
x
Reference in New Issue
Block a user