mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-18 03:21:36 +02:00
spectator spawn, border beams
This commit is contained in:
parent
ed8aefc867
commit
f76398370a
@ -65,9 +65,9 @@ function Public.reset_map()
|
||||
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
|
||||
surface.request_to_generate_chunks({0,0}, 10)
|
||||
surface.request_to_generate_chunks({0,0}, 8)
|
||||
surface.force_generate_chunk_requests()
|
||||
game.forces.spectator.set_spawn_position({0, 128}, surface)
|
||||
game.forces.spectator.set_spawn_position({0, -128}, surface)
|
||||
game.forces.west.set_spawn_position({-200, 0}, surface)
|
||||
game.forces.east.set_spawn_position({200, 0}, surface)
|
||||
|
||||
@ -210,15 +210,15 @@ local function send_unit_groups()
|
||||
end
|
||||
|
||||
local border_teleport = {
|
||||
["east"] = 2,
|
||||
["west"] = -2,
|
||||
["east"] = 1,
|
||||
["west"] = -1,
|
||||
}
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not player.character then return end
|
||||
if not player.character.valid then return end
|
||||
if player.position.x >= -4 and player.position.x <= 4 then
|
||||
if player.position.x > -4 and player.position.x < 4 then
|
||||
if not border_teleport[player.force.name] then return end
|
||||
if player.character.driving then player.character.driving = false end
|
||||
player.teleport({player.position.x + border_teleport[player.force.name], player.position.y}, game.surfaces[global.active_surface_index])
|
||||
@ -305,9 +305,12 @@ end
|
||||
local function tick()
|
||||
local game_tick = game.tick
|
||||
if game_tick % 240 == 0 then
|
||||
local area = {{-320, -161}, {319, 160}}
|
||||
game.forces.west.chart(game.surfaces[global.active_surface_index], area)
|
||||
game.forces.east.chart(game.surfaces[global.active_surface_index], area)
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
--if surface.is_chunk_generated({10, 0}) then
|
||||
local area = {{-320, -161}, {319, 160}}
|
||||
game.forces.west.chart(surface, area)
|
||||
game.forces.east.chart(surface, area)
|
||||
--end
|
||||
end
|
||||
if game_tick % 1200 == 0 then send_unit_groups() end
|
||||
if global.game_reset_tick then
|
||||
|
@ -70,7 +70,15 @@ end
|
||||
|
||||
function Public.teleport_player_to_active_surface(player)
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
player.teleport(surface.find_non_colliding_position("character", player.force.get_spawn_position(surface), 32, 0.5), surface)
|
||||
local position
|
||||
if player.force.name == "spectator" then
|
||||
position = player.force.get_spawn_position(surface)
|
||||
position = {x = (position.x - 160) + math_random(0, 320), y = (position.y - 16) + math_random(0, 32)}
|
||||
else
|
||||
position = surface.find_non_colliding_position("character", player.force.get_spawn_position(surface), 48, 1)
|
||||
if not position then position = player.force.get_spawn_position(surface) end
|
||||
end
|
||||
player.teleport(position, surface)
|
||||
end
|
||||
|
||||
function Public.put_player_into_random_team(player)
|
||||
|
@ -33,6 +33,12 @@ local function create_nests(surface)
|
||||
global.map_forces.west.target = e
|
||||
end
|
||||
|
||||
local function create_border_beams(surface)
|
||||
surface.create_entity({name = "electric-beam", position = {4, -96}, source = {4, -96}, target = {4,96}})
|
||||
surface.create_entity({name = "electric-beam", position = {-4, -96}, source = {-4, -96}, target = {-4,96}})
|
||||
end
|
||||
|
||||
|
||||
function Public.create_mirror_surface()
|
||||
if game.surfaces["mirror_terrain"] then return end
|
||||
|
||||
@ -173,7 +179,10 @@ local function on_chunk_generated(event)
|
||||
|
||||
if left_top.x >= -192 and left_top.x < 192 then combat_area(event) end
|
||||
|
||||
if left_top.x == 256 and left_top.y == 256 then create_nests(event.surface) end
|
||||
if left_top.x == 256 and left_top.y == 256 then
|
||||
create_nests(event.surface)
|
||||
create_border_beams(event.surface)
|
||||
end
|
||||
|
||||
if left_top.x > 320 then return end
|
||||
if left_top.x < -320 then return end
|
||||
|
Loading…
x
Reference in New Issue
Block a user