Start in various fields Multiplayer

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
maisel16
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun Sep 06, 2015 4:52 pm
Contact:

Start in various fields Multiplayer

Post by maisel16 »

Hello guys,

i play this game in the most time Multiplayer.
What i want ist more Start Options. And friend is in game a Enemy not friendly in Coop Mode set up self a own factory. The Laser tower shoot him and enemy tower shoots to me.

Sorry for my bad english.
With best regards

Maisel16

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Start in various fields Multiplayer

Post by ratchetfreak »

maisel16 wrote:Hello guys,

i play this game in the most time Multiplayer.
What i want ist more Start Options. And friend is in game a Enemy not friendly in Coop Mode set up self a own factory. The Laser tower shoot him and enemy tower shoots to me.

Sorry for my bad english.
With best regards

Maisel16
a per force spawn point you mean?

seems like this should be modable

turns out it is: https://forums.factorio.com/wiki/inde ... n_position

the following will set your force's spawn position to your current location

Code: Select all

/c game.local_player.force.set_spawn_position(game.local_player.position, game.local_player.surface);

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Start in various fields Multiplayer

Post by ssilk »

Moved from Suggestions to Gameplay Help, cause I don't see this as suggestion (there is nothing specific suggested).
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

MrDoomah
Fast Inserter
Fast Inserter
Posts: 196
Joined: Mon Jun 01, 2015 1:11 pm
Contact:

Re: Start in various fields Multiplayer

Post by MrDoomah »

For an arbitrary number of players, this code will create spawnpoint on a 1000 diameter (500 range) circle evenly spread apart for every player in its own force. We used this for our 3 player "space race" type of game.

First you run this: (you can just open the lua console and write /c and then paste this code as it stands here (you can ignore all the spaces)

Code: Select all

game.peaceful_mode = true
r = 500
n_forces = 1

for index,player in pairs(game.players) do
  if index > 1 then 
    local force = game.create_force(player.name)
    player.force = force 
    n_forces = n_forces +1
  end
end


n = 0

for name,force in pairs(game.forces) do
  if name ~= "neutral" and name ~= "enemy" then
    local x = r * math.cos(n*2*math.pi/n_forces)
    local y = r * math.sin(n*2*math.pi/n_forces)
    force.set_spawn_position({x,y}, force.players[1].surface)
    for _,player in pairs(force.players) do
      player.teleport({x,y})
    end
	force.clear_chart()
    n = n +1
  end
end
You can paste this code into a text editor (notepad, word whatever) and edit the value for r to alter the distance between spawns.
Then after everyone is spawned and the map has generated (takes about 20 seconds) use this command:

Code: Select all

r = 100
for _,player in pairs(game.players) do
    local enemies = player.surface.find_entities_filtered{area={{player.position.x-r,player.position.y-r},{player.position.x+r,player.position.y+r}}, force = "enemy"}
    for _,enemy in pairs(enemies) do
      enemy.destroy()
    end
end
game.peaceful_mode = false
again, console /c and paste this code, and alter the value for r for the size of the starting area.

You might find one or more players spawning on water, but in our case it only took 2 restarts before we found a useful map.

l4m3r
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sat Jul 18, 2015 11:31 am
Contact:

Re: Start in various fields Multiplayer

Post by l4m3r »

maybe this code wont work with 0.16?

Post Reply

Return to “Gameplay Help”