mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-08 00:39:30 +02:00
commit
7cbbe1b6e5
@ -91,11 +91,9 @@ 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(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)
|
||||
if position then game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface) end
|
||||
return true
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -40,6 +40,17 @@ local treasure_chest_messages = {
|
||||
"We has found the precious!",
|
||||
}
|
||||
|
||||
local function game_over()
|
||||
game.print("The Fish Wagon was destroyed!!")
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
global.game_reset_tick = game.tick + 1800
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound{path="utility/game_lost", volume_modifier=0.80}
|
||||
end
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = #game.connected_players
|
||||
@ -274,17 +285,10 @@ local function on_pre_player_left_game(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not event.entity.valid then return end
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
if event.entity == global.locomotive_cargo then
|
||||
game.print("The cargo was destroyed!")
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
global.game_reset_tick = game.tick + 1800
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound{path="utility/game_lost", volume_modifier=0.75}
|
||||
end
|
||||
game_over()
|
||||
event.entity.surface.spill_item_stack(event.entity.position,{name = "raw-fish", count = 512}, false)
|
||||
return
|
||||
end
|
||||
@ -435,7 +439,7 @@ local function tick()
|
||||
local tick = game.tick
|
||||
if tick % 30 == 0 then
|
||||
if tick % 1800 == 0 then
|
||||
Locomotive.set_player_spawn_and_refill_fish()
|
||||
if not Locomotive.set_player_spawn_and_refill_fish() and not global.game_reset_tick then game_over() end
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
local position = surface.find_non_colliding_position("stone-furnace", Collapse.get_position(), 128, 1)
|
||||
if position then
|
||||
|
@ -47,9 +47,9 @@ local function print_debug(a)
|
||||
print("Collapse error #" .. a)
|
||||
end
|
||||
|
||||
local function set_collapse_tiles()
|
||||
game.forces.player.chart(collapse.surface, collapse.area)
|
||||
collapse.tiles = collapse.surface.find_tiles_filtered({area = collapse.area})
|
||||
local function set_collapse_tiles(surface)
|
||||
game.forces.player.chart(surface, collapse.area)
|
||||
collapse.tiles = surface.find_tiles_filtered({area = collapse.area})
|
||||
if not collapse.tiles then return end
|
||||
collapse.size_of_tiles = #collapse.tiles
|
||||
if collapse.size_of_tiles > 0 then table_shuffle_table(collapse.tiles) end
|
||||
@ -57,21 +57,24 @@ local function set_collapse_tiles()
|
||||
local v = collapse.vector
|
||||
local area = collapse.area
|
||||
collapse.area = {{area[1][1] + v[1], area[1][2] + v[2]}, {area[2][1] + v[1], area[2][2] + v[2]}}
|
||||
game.forces.player.chart(surface, collapse.area)
|
||||
end
|
||||
|
||||
local function progress()
|
||||
local surface = collapse.surface
|
||||
|
||||
local tiles = collapse.tiles
|
||||
if not tiles then
|
||||
set_collapse_tiles()
|
||||
set_collapse_tiles(surface)
|
||||
tiles = collapse.tiles
|
||||
end
|
||||
if not tiles then return end
|
||||
|
||||
local surface = collapse.surface
|
||||
for _ = 1, collapse.amount, 1 do
|
||||
local tile = tiles[collapse.size_of_tiles]
|
||||
if not tile then collapse.tiles = nil return end
|
||||
collapse.size_of_tiles = collapse.size_of_tiles - 1
|
||||
if not tile.valid then return end
|
||||
if collapse.kill then
|
||||
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}})) do
|
||||
|
@ -511,10 +511,13 @@ end
|
||||
function Public.reconstruct_all_trains(icw)
|
||||
icw.trains = {}
|
||||
for unit_number, wagon in pairs(icw.wagons) do
|
||||
if wagon.entity and wagon.entity.valid then
|
||||
local carriages = wagon.entity.train.carriages
|
||||
Public.construct_train(icw, carriages)
|
||||
if not wagon.entity or not wagon.entity.valid then
|
||||
icw.wagons[unit_number] = nil
|
||||
Public.request_reconstruction(icw)
|
||||
return
|
||||
end
|
||||
local carriages = wagon.entity.train.carriages
|
||||
Public.construct_train(icw, carriages)
|
||||
end
|
||||
delete_empty_surfaces(icw)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user