In other languages: Deutsch Español 日本語 Русский Українська 简体中文

Multiplayer: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Added cookbook stuff to page)
Line 151: Line 151:
* use mods for planning. See [https://forums.factorio.com/viewtopic.php?f=14&t=6788 basic planner], [https://forums.factorio.com/viewtopic.php?f=14&t=4022 Planning-Tool-Mod]...
* use mods for planning. See [https://forums.factorio.com/viewtopic.php?f=14&t=6788 basic planner], [https://forums.factorio.com/viewtopic.php?f=14&t=4022 Planning-Tool-Mod]...
* look into [https://forums.factorio.com/viewforum.php?f=53 multiplayer forum], most other questions are answered there.
* look into [https://forums.factorio.com/viewforum.php?f=53 multiplayer forum], most other questions are answered there.
* [https://github.com/jjasghar/factorio-cookbook Cookbook] for setting up a headless server


''And always remember that Factorio in v0.11 isn't intended to work well on internet connections, so keep patient. ;)
''And always remember that Factorio in v0.11 isn't intended to work well on internet connections, so keep patient. ;)
Line 156: Line 157:
== More Guides ==
== More Guides ==


* [https://www.chef.io/blog/2016/03/21/building-a-factorio-multiplayer-server-on-digital-ocean/ How to set up Factorio server with cookbook]
* [http://youtube.com/watch?v=MqsqRWNsbPM How To set up a Factorio Multiplayer Server | Guide | Tutorial], by Teaspoon
* [http://youtube.com/watch?v=MqsqRWNsbPM How To set up a Factorio Multiplayer Server | Guide | Tutorial], by Teaspoon
* [https://forums.factorio.com/viewtopic.php?f=53&t=6720 Tips to connect in multiplayer], by Nondre
* [https://forums.factorio.com/viewtopic.php?f=53&t=6720 Tips to connect in multiplayer], by Nondre

Revision as of 15:12, 25 April 2016


The multiplayer feature was introduced with version 0.11.X and will be thought only for Lan-parties or Low-latency internet, as there was a noticeable lag between character actions and those actions happening. As of version 0.12.0 the game features "latency hiding" mechanics which make the lag less noticeable.

The game is technically a peer-to-peer game. Which means, there is no server needed, but there is support for a "dedicated" server.

Anybody can join an existing game, if he knows the IP of the game. He connects to the game, the game stops and the second players game downloads the current map. If the first host stops, the second player can continue to play and the first player can rejoin at any time. If the game desynchronizes, the map is re-downloaded automatically and the game can continue.

Playing over LAN / Internet

Playing over Internet was not thought to work properly with version 0.11. Noticeable lag could occur depending on connection speed/reaction time. This has become less of an issue with the latency hiding mechanics introduced in version 0.12, but can still cause issues if there is a significant latency between players.

  • Both game instances need the installation of exactly same game-versions and mods. (Tip: Maybe someone has the scenario pack mod off?)
  • For a more fluid game the "clients" can turn off autosave.
  • Factorio uses the port 34197. The port can be changed in the config.
  • Factorio uses UDP only, so make sure, you configured your router correctly. (The game builds it's own "reliable delivery" layer built on UDP to deal with packet loss and reordering issues.)
    • Make sure, that there is no firewall or anti-virus blocking the UDP-packets.
    • read further, look into "more guides", to configure your router set up.
    • It is necessary that all of the peers can communicate with each other. It is however in theory not necessary that all the peers have public IP address - this should work even behind a NAT. See Cube in Cannot Have 3+ Players connected at the same time.
  • The hard limit for the number of players is 65535. :)

Voice Chat

  • it is recommended to use voice chat (TeamSpeak, Skype), because you need to talk a lot (coordinate connection, building, handling attacks...). TeamSpeak servers are posted in the multiplayer forum.

Finding other Peers

  • use the multiplayer board in the forum.
  • many players use other software like Hamachi or Evolve to meet other players. This has the "advantage" of creating a virtual private network between the players. See down under software.
  • some use also Steam to find others.

Factorio servers or Why Peer-to-Peer?

There were some discussions about, why Factorio doesn't use the client+server-model, but instead uses the peer-to-peer priniciple.

As of version 0.12.X there is support for a Dedicated Server option, but this still functions with the same peer-to-peer networking.

Some links

Dedicated/Headless server

This article contains content on features that are included in 0.12.X, an "experimental release" of the game that is not considered as "stable release" by the developers yet.

As of Factorio version 0.12.0 onwards, a dedicated (or headless) server can be started using the '--start-server' command line option.

In this mode:

  • Graphics are not initialized (faster start up, less memory usage, works on completely headless servers)
  • Game starts immediately and loads a save given as a parameter to the command
  • The server has no character in game
  • Game is paused while there are no players connected
  • Saves the game on exit (and autosaves normally)

You will need to create your save file before you start the server, as the dedicated server REQUIRES a save file to be provided. This can easily be done by loading up a game in Single-Player and saving it right away.

Below are basic instructions for starting a dedicated server on Windows and Linux.

Windows

  • Go to your Factorio.exe folder (Probably 'C:\Program Files\Factorio\bin\x64\')
  • Create a text document and write into it 'Factorio.exe --start-server YOURSAVEGAME.zip'
    • If you haven't already done, replace YOURSAVEGAME with your savegame name
  • Save the file as server.bat. Important: At 'Save as type:' select 'All Files'
  • Use the server.bat to start your server.
  • The console log will be shown in the window.
  • To close the server, select the console window press Control+C. If you just close it without pressing this, it will not save your game.
  • Forward Ports: You will find detailed instructions for your specific router on the web


Linux

This step-by-step guide has been verified on fresh CentOS 7 and RHEL 7 installs but should be applicable with little to no changes on most distribution.

The guide assumes you will install the headless server under /opt/factorio, adjust paths according to your own setup. We will also suggest that you run the Factorio server as a separate user to harden security of your setup.

This guide does not handle firewall/port forwarding since this can be done in various ways on Linux (make sure to read up how this is done as a Linux admin on your particular distribution)

You can use the Linux factorio-init script to start/stop your headless server in a much better way. The script will ensure you only ever use the most recent save when your server starts (even if that was an auto-save) while also letting you set a number of other settings like Autosave frequency and Latency settings. This script will also simplify updating the server when combined with the Linux factorio-updater script.

  • Download the at least v 0.12.0 Experimental Version and upload the linux tar.gz package to your server /tmp
  • Extract the package to /opt/factorio
#cd /opt/
#tar -xzf /tmp/factorio.tar.gz
  • Check the binary to find if you need any libs installed
#ldd /opt/factorio/bin/x64/factorio
        libasound.so.2 => not found
        libX11.so.6 => not found
        truncated ....

  • Install each of the missing libs, i.e the ones labelled "not found" using your distro's package handler
    • It will ask to install graphics and audio libraries as well, but will not use them in headless mode.
# yum whatprovides libasound.so.2
alsa-lib-1.0.28-2.el7.i686 : The Advanced Linux Sound Architecture (ALSA) library
Repo        : base
Matched from:
Provides    : libasound.so.2

# yum install alsa-lib libX11 <and all other "not found" libs in your case
  • Add a new user to your system and assign ownership of the Factorio dir to it (please, do not run as the root user)
#useradd factorio
#chown -R factorio:factorio /opt/factorio
  • Try the binary
#su factorio
#/opt/factorio/bin/x64/factorio --start-server savename

As long as it fails saying it cannot find/open the savename.zip you are set! Just upload a save from your own computer and put it in the /opt/factorio/saves directory

Dedicated/Headless server in version 0.11.X

It was still possible to achieve a Dedicated server in version 0.11.X, but it required some workarounds.

Workarounds in version 0.11.x:


Game types

Coop

Coop-game runs without any further preparation ( https://forums.factorio.com/viewtopic.php?f=53&t=6501 )

PvP

Forces

You can now set up forces. See this https://forums.factorio.com/viewtopic.php?f=3&t=13512&start=80#p92087

game.create_force('force 1')
Creates a force with name "force 1", default forces are "player", "enemy", "neutral"
"player" is the default force for players
"enemy" is force of biters
"neutral" is special, its not attacked, can use all other forces, can be used by all other forces
game.get_player('friend 1').force = game.forces['force 1']
Changes the force of "friend 1" to "force 1"
game.forces['force 1'].set_cease_fire('force 2', true)
makes "force 1" to cease fire against "force 2", reverse has to be done separately
for v in pairs(game.forces) do game.local_player.print(v) end
list all existing forces

Technical Implementation

More Tools/Infos

And always remember that Factorio in v0.11 isn't intended to work well on internet connections, so keep patient. ;)

More Guides

Miscellaneous tips

  • the key for Console commands will now initiate a chat in MP. To execute commands you need to type '/c' before the command!
  • Set the player's color using the command
/c game.players[x].color = {r=0.7, g=0.5, b=0.1, a=0.9}

Where x is the player number. r, g and b are for red, green and blue respectively (possible values are between 0 and 1, use the right-most column on http://prideout.net/archive/colors.php). a is alpha channel aka Transparency of the color to the base texture. For single player, leave off the "[x]" to set the color.

Software for routing / establishing connection