In other languages: Deutsch English Русский 中文

Multiplayer

From Official Factorio Wiki
Jump to: navigation, search


Factorioはシングルプレーヤーキャンペーンおよびシナリオに加えマルチプレーヤをサポートしています。デフォルトではマルチプレーヤーゲームは全プレーヤーが協力し衛星をロケットで宇宙へ打ち上げるフリープレイシナリオになります。PvPを含めた他のシナリオは Maps and Scenarios forum からダウンロードできます。

現在、マルチプレーヤーゲームに参加するには、全員が同じLANにいるか、ホストが公開IPアドレスである必要があります。0.13では公開マルチサーバーゲームロビーがサポートされ、IPアドレス不要でシームレスに接続できます。

History

Because of the potentially immense amount of activity on a map, the game engine utilizes a lock step architecture. All instances of the game run full simulations of the entire world and only player actions are transferred across the network.

Multiplayer games were introduced to Factorio with version 0.11.0. The only connection method available was peer-to-peer mode which meant every player had to be able to directly communicate with every other player. In version 0.12.4, a client-server mode of communication was introduced in which the server (either a dedicated one or the player who hosted the game) relays messages to all peers. This means that direct connection between all players is no longer necessary. The client-server mode will be the only available in 0.13.

As of version 0.12.0, the game features "latency hiding" mechanics where the game simulates some of the player's actions locally to make some common interactions (such as moving the player's character) more fluid. Latency hiding is enabled by default, but it can be enabled or disabled in Options → Other → Enable multiplayer latency hiding. Not every action is a part of latency hiding – most notably, car or train driving and shooting are not a part of it.

マルチプレーヤーゲーム設定ガイド

ゲームメニューからマルチプレイヤーボタンを使って始められます。1プレイヤーでのゲームとホストが開始されます。そのプレーヤーは自身のIPアドレスを提示します。そしてそのIPアドレスのホストに他のプレーヤが参加することができます。

その他のnotesとtips:

  • 全てのゲームのインスタンスは同じゲームバージョンと同じMODのインストールが必要です。
  • Factorio は ポート番号34197を使います。これはconfigで変更できます。
  • Factorio は UDPのみ利用します。(ゲーム自身がUDP上でパケットロスや再リクエストを扱う"信頼できる配信"レイヤーで構築されています。
    • UDPパケットをブロックするファイアーウォールやアンチウイルスがないことを確認してください。
  • ネットワークのセットアップの設定のヘルプはsection belowを御覧ください。
  • プレイヤー人数の固定の上限は65535です:)

Voice Chat

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

Finding Other Players

  • Use the multiplayer board in the forum.
  • Many players use other software like Evolve to meet other players. This also has the "advantage" of creating a virtual LAN among the players. See down under software.
  • Some also use Steam to find other players.
  • There is an external server browser with various search options.
  • Tell your friends to buy Factorio, then play with them!

Connecting to a Server Behind NAT

Factorio requires that the server (in client-server mode) or all peers (in peer-to-peer mode) have a publicly accessible IP address or that all players are on the same LAN. If you are behind NAT, you must set up port forwarding (see above for port number) or use virtual LAN software such as Hamachi or Evolve.

By default, multiplayer games will be launched in client-server mode (also multiplayer forwarding mode). In this mode, all clients send their network traffic to the server and the server forwards the traffic to the other clients. The advantage of this is that it allows games where some players are inside a LAN and others are outside. The disadvantage may be slightly more lag as packets must travel an extra hop (through the server). Multiplayer games may be launched in peer-to-peer mode to disable this forwarding behavior by checking the Use peer-to-peer communication box when starting the game as the host. Using peer-to-peer is no longer recommended and will be removed entirely in 0.13.

Game Types

Co-op

In co-op mode, all players are on the same force which means all players share the same research progression, any player can access items stored in a container built by any other player, and defensive structures built by any player will not target any other player.

To start a co-op game:

  1. Launch Factorio
  2. Click Play
  3. Click Multiplayer
  4. Click New game
  5. Select map generator options, then click Generate
  6. Choose latency and other settings, then click Play
  7. Other players can now join the game

PvP

In PvP mode, players can be on different forces. Each force can have one (free-for-all) or more players (teams). Each force has its own independent research progression. Additionally, each force's turrets and combat bots will attack other players as enemies, unless a cease fire is set. Note that, depending on the scenario, cease fires may be unidirectional — setting a cease fire with an opposing force does not guarantee a cease fire from them in return.

To start a PvP game, you must have a PvP-compatible scenario downloaded (or use the console commands to manually assign players to different forces, see below). PvP scenarios can be found in the Maps and Scenarios forum.

Example PvP scenarios:

After downloading a PvP scenario, you need to start the scenario as a single player custom scenario, save it, then load it as a multiplayer game. Otherwise, Factorio will launch the default freeplay scenario in co-op mode. In detail:

  1. Download the scenario and place the scenario directory in the scenarios directory within your user data directory.
  2. Launch Factorio
  3. Click Play
  4. Click Custom scenario
  5. Choose the PvP scenario you want under User scenarios and click Create
  6. (Depending on the scenario, you may need to set the map generation settings and click Generate)
  7. Hit Escape and click Save game
  8. Type a save game name and click Save
  9. Click Quit game
  10. Click Play
  11. Click Multiplayer
  12. Click Load game
  13. Choose the save game you just created and click Load
  14. Choose latency and other settings, then click Play
  15. Other players can now join the game

Forces

Forces can be manually created via the console. This allows any map/scenario to be used for PvP. This may not be as convenient as a pre-made PvP scenario, as there will be no way for players to turn on/off cease fires other than through the console.

Each created force has its own research progression and different forces may attack each other.

The console commands for setting up and controlling forces are below:

game.create_force('force 1')
Creates a force with name "force 1". Default forces are "player", "enemy", and "neutral".
"player" is the default force for players
"enemy" is alien force
"neutral" is special: it is not attacked and can use all / be used by all other forces (e.g., neutral storage containers can be accessed by all)
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" cease fire against "force 2". The reverse has to be done separately.
game.forces['force 1'].set_spawn_position({x=10, y=20}, game.get_surface(1))
Sets the spawn/respawn point for a particular force to x = 10, y = 20. By default, all players from all forces will spawn at {x = 0, y = 0}.
for v in pairs(game.forces) do game.local_player.print(v) end
list all existing forces

Dedicated/Headless server

As of Factorio version 0.12.0 onwards, a dedicated (or headless) server can be started using the --start-server command line option. You can run factorio --help to get a list of all command-line arguments that Factorio accepts.

In the headless 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 (though this can be overridden using the --no-auto-pause option)
  • Saves the game on exit (and autosaves normally)

Please note that there has been a slight change between 0.12, 0.13 and 0.14 in how --start-server (and others) interpret the given parameter. Version 0.12 expected --start-server to be followed by a save name, that was to be found in the saves directory. 0.13 instead expects --start-server to be followed by a path to a save file. I.e. if you did factorio --start-server foo in 0.12, you probably want to use factorio --start-server saves/foo.zip in 0.13.

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 using the --create command-line argument. For example:

./bin/x64/factorio --create ./saves/my-save.zip       # This creates a new save, as if by clicking the New Game button in the GUI
./bin/x64/factorio --start-server ./saves/my-save.zip # This starts a server that will host the file created on the previous line

Starting with version 0.13, --create also accepts --map-gen-settings if you want to use non-default map generation. To use it, create a file with the desired map settings (see the file data/map-gen-settings.example.json for an example), and run:

factorio --create saves/my-save.zip --map-gen-settings path-to-file-with-desired-map-generation-settings.json

Starting with version 0.14.12, factorio has moved some command-line options into the server-settings.json file. Starting factorio server requires you to specify the location of the server-settings.json file. By default this is in the factorio data folder. For example to start factorio using the most recent saved map, you would run:

./factorio  --start-server-load-latest --server-settings ./data/server-settings.json

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.

Note that there are two distinct packages for Linux that can be used to run a headless server. First is the usual Linux download, that contains the full game. The other is the special headless package. The headless package does not contain any files irrelevant for a pure server, such as graphics and sounds. It is also not linked against libraries that may not be present on a server machine, such as Xlib, libGL or libasound.

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 selected package -- either full game or the headless package -- and upload the linux tar.gz package to your server /tmp
  • Extract the package in /tmp to /opt/factorio
#cd /opt/
#tar -xzf /tmp/factorio.tar.gz # Use the correct filename. It includes the factorio version number
  • 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, or use the --create ./saves/newgame.zip argument

How to List Your Server-Hosted Game on the Matching Server

In order to publish the game to the matching server, Factorio needs to be given some more information than just the save file location. These information are provided in a server settings file.

To create a server settings file, look at the example file located in data/server-settings.example.json in the Factorio Application directory. The recommended way is to make a copy of this example file and edit the copy.

The following values can be changed:

  • Name: This will be the name under which the server will be listed in the server browser
  • Description: A brief description of your server
  • Tags: A list of game tags
  • Max Players: Allows you to limit the number of players that can be connected to the server at the same time. If you want no limit, just set max_players to 0.
  • Visibility for server browser: May be either public, lan or hidden.
    • Public: The server will appear in the public server list. This requires the login credentials below to be filled in.
    • LAN: The server will not appear in the public server list, but will be available through the Play On LAN button
    • Hidden: Clients will have to connect using the server's IP address
  • User credentials using a username and password or authentication token: These are necessary if you wish to make the server public. Otherwise, they can be left empty.
    • For security reasons it is recommended to use authentication token as this document is stored as plaintext. Though it should be noted that an authentication token is a sensitive piece of information as well, and you are well-advised to keep it secret.
  • Server Password
    • Field name is game_password
  • Whether to verify user identity

(There are additional values in v0.14 of factorio.)

Technical Implementation Details

Notes about some technical details surrounding multiplayer have been published by the development team in several Friday Facts blog posts:

More Guides

Miscellaneous Tips

  • The key for Console commands is also used initiate chat in multiplayer. To execute a command instead of chatting, you need to type /c before the command. Commands executed are visible to all players. Additionally, the multiplayer game must have been started with commands allowable for commands to work.
  • Set the player's color using the command
/c game.get_player("x").color = {r=0.7, g=0.5, b=0.1, a=0.9}

Where x is the player's name. 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 to convert colors to rgb numbers). a is alpha channel aka Transparency of the color to the base texture. For single player, replace get_player("x") with player to set the color.