Difference between revisions of "How to setup a local QuakeJS server under Windows 10"

From steamWiki
Jump to: navigation, search
(Install Git)
Line 40: Line 40:
 
##Click '''Next''' to skip the experimental features and wait for the install to complete
 
##Click '''Next''' to skip the experimental features and wait for the install to complete
 
##Click '''Finish'''
 
##Click '''Finish'''
#You can test this installation by opening a Command Prompt and running <pre>git --version</pr>
+
#You can test this installation by opening a Command Prompt and running <pre>git --version</pre>
  
 
==Install Extra Git Bash Packages==
 
==Install Extra Git Bash Packages==

Revision as of 10:56, 26 February 2020

TLDR: This How To will show you how to setup a local QuakeJS server, local Play page (for users to connect to the local server), and a local content server (to provide files to the clients) under Windows 10. It is based off of my original guide using Debian. If you'd like to setup your server under Linux then check out my guide on How to setup a local QuakeJS server under Debian 9 or Debian 10.

I found myself in a situation where I was going to be on a LAN without internet access for an extended period of time along with multiple people and multiple computers. I wanted a fun, fast paced, multiplayer game for us. The catch? I didn't want anyone to have to install anything since these computers didn't belong to us. That's a pretty tall order. What I found was QuakeJS. Quake 3 was open sourced at the beginning of 2012 and some awesome dudes based ioquake3 off of it. Another awesome dude created QuakeJS around 2013/2014. QuakeJS allows you to play Quake 3 entirely in a browser.

The source code has instructions for creating a dedicated server as well as building from source & generating assets for a content server (under Linux). Unfortunately the Emscripten tool used to build the project has changed the way it operates in since 2014 and the current version of the QuakeJS source doesn't build with modern versions of Emscripten. Luckily Inolen provided the precompile .js files for those of us just wanting to run a server. Between those .js files, the QuakeJS README, some helpful discussion on how to setup a local webpage to connect to the server (as well as providing the content necessary to play) and a bit of tinkering, I've been successful in creating a server environment that I'm happy with.

If you would prefer a video tutorial, Grabisoft created a video tutorial on YouTube. It also shows you how to add in your own custom content which my guide, below, doesn't cover.

NOTE: This guide assumes your local server's hostname is "quakejs"
NOTE: currently the content server address of content.quakejs.com is hard coded into some compiled code.  I'm working on being able to recompile but in the meantime there is a "hack" to redirect content.quakejs.com to your localhost address.  See the "Redirect content.quakejs.com" section

Setup the Environment

Install Node.js & NPM

  1. Visit https://nodejs.org and download the latest .msi installer for Node.js (v12.10.0 at the time of this writing)
  2. Run the .msi to install Node.js & NPM
    1. Click Next to start the install
    2. Click Accept & Next to accept the license
    3. Click Next to accept the default installation folder
    4. Click Next to accept the default options
    5. quakejs doesn't require any of the "extra tools" but you can install them if you want by checking the box on this screen. Click Next
    6. Accept the Windows pop-up and wait for the install to complete
    7. Click Finish
  3. You can test this installation by opening a Command Prompt and running
    node -v

Install Git

  1. Visit https://git-scm.com/download/win to automatically start the download of the latest Windows version of the Git client (v2.23.0 at the time of this writing)
  2. Run the downloaded .exe file to launch the installer
    1. Click Yes to start install
    2. Click Next to accept the license agreement
    3. Click Next to accept the default install location
    4. Click Next to accept the default options
    5. Click Next to allow the installer to create Start Menu links
    6. Select your preferred text editor (I like Notepad++ on Windows)
    7. Click Next to accept the default PATH option
    8. Click Next to use OpenSSL
    9. Click Next to use the default line ending option
    10. Click Next to use MinTTY
    11. Click Next to accept the default extra options
    12. Click Next to skip the experimental features and wait for the install to complete
    13. Click Finish
  3. You can test this installation by opening a Command Prompt and running
    git --version

Install Extra Git Bash Packages

  1. Visit https://stedolan.github.io/jq/download/ and download the latest jq executable for Windows (v1.6 at the time of this writing)
    • Make sure you get the correct 32-bit or 64-bit version for your OS
  2. Rename the downloaded file (either jq-win64.exe or jq-win32.exe) to jq.exe
  3. Visit https://eternallybored.org/misc/wget/ and download the latest wget executable for Windows (v1.20.3 at the time of this writing)
    • Make sure you get the correct 32-bit or 64-bit version for your OS
  4. copy jq.exe & wget.exe from your Downloads folder to C:\Program Files\Git\mingw64\bin\

Setup QuakeJS Server

  1. Hit Windows Key + R and type "cmd" to launch the Command Prompt.
  2. Run the following command to ensure we're in our Home Directory
    %HOMEPATH%
  3. Run the following command to clone my updated quakejs repo to your Home Directory
    git clone --recurse-submodules https://github.com/begleysm/quakejs.git
  4. Run the following command to switch into the, newly created, quakejs directory
    cd quakejs
  5. Run the following command to install the necessary Node.js modules
    npm install
  6. To download BASE3Q files, run the server for the 1st time by executing the following command. Hold down enter to get through the EULA, agree to the EULA by hitting y and game files will be downloaded. Once all files have been downloaded (you'll see the line ignoring setsockopt command) quit the server by hitting Ctrl+C
    node build/ioq3ded.js +set fs_game baseq3 +set dedicated 1
  7. Optionally run the following command to download additional CPMA files. Again hit Ctrl+C to quit the server once all files have been downloaded (you'll see the line ignoring setsockopt command)
    node build/ioq3ded.js +set fs_game cpma +set dedicated 1
  8. Edit the baseq3 server config file (C:\Users\USERNAME\quakejs\base\baseq3\server.cfg). Pay special attention to seta sv_hostname, seta g_motd, and especially seta rconpassword
  9. Optionally edit the cpma server config file (C:\Users\USERNAME\quakejs\base\cpma\server.cfg). Pay special attention to seta sv_hostname, seta g_motd, and especially seta rconpassword
  10. You can test (or run) your server with the following command, but there isn't much point until we setup the Content Server and Play Page.
    node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg

Setup the UwAmp Web Server, Play Page, & Content Server

If you want to setup a permanent installation you will probably want to install UwAmp as a program on your machine. If you are planning on using it intermittently or just want to test it out, you may want to download the stand-alone ZIP version of UwAmp. Follow either #Permanent Install or #Standalone Install based on your preference.

Permanent Install

  1. Visit https://www.uwamp.com/en/?page=download and download the exe installer
    • You might need to download and install the Visual C++ Redistributable as described at the top of the UwAmp download page. If in doubt, download and install it
  2. Run UwAmp.exe to install the program
  3. Launch UwAmp by running the UwAmp program from the Start Menu. When Windows asks, you'll want to allow the Apache HTTP Server (and optionally mysql.d although quakejs doesn't use it) through the firewall on Private & Public networks.
  4. Ensure that the drop-down under Configuration -> Apache: is set to Online Mode if you want other computers to be able to connect to your web server (Offline Mode will only allow the computer running UwAmp to connect).
  5. You can now test the UwAmp Web Server by visiting http://COMPUTER-NAME (or http://localhost or http://127.0.0.1). You should some something that looks like this
    UwAmp welcome.png
  6. Now delete the contents of C:\UwAmp\www\
  7. Copy the contents of C:\Users\USERNAME\quakejs\html\ to C:\UwAmp\www\
  8. If your computer name isn't quakejs you'll need to change your hostname
  9. Run the Git Bash program as Administrator by finding Git Bash in the Start Menu, right clicking on it, and selecting Run as administrator
    1. run the following command to move to the web root directory
      cd C:/UwAmp/www/
  10. run the following command to download all of the Content Server files
    ./get_assets.sh
  11. run the following command to close Git Bash
    exit

Standalone Install

  1. Visit https://www.uwamp.com/en/?page=download and download the zip installer
    • You might need to download and install the Visual C++ Redistributable as described at the top of the UwAmp download page. If in doubt, download and install it
  2. Extract the contents of the ZIP (UwAmp folder) to C:\Users\USERNAME\
  3. Launch UwAmp by running C:\Users\USERNAME\UwAmp\UwAmp.exe. When Windows asks, you'll want to allow the Apache HTTP Server (and optionally mysql.d although quakejs doesn't use it) through the firewall on Private & Public networks.
  4. Ensure that the drop-down under Configuration -> Apache: is set to Online Mode if you want other computers to be able to connect to your web server (Offline Mode will only allow the computer running UwAmp to connect).
  5. You can now test the UwAmp Web Server by visiting http://COMPUTER-NAME (or http://localhost or http://127.0.0.1). You should some something that looks like this
    UwAmp welcome.png
  6. Now delete the contents of C:\Users\USERNAME\UwAmp\www\
  7. Copy the contents of C:\Users\USERNAME\quakejs\html\ to C:\Users\USERNAME\UwAmp\www\
  8. If your computer name isn't quakejs you'll need to change your hostname
  9. Run the Git Bash program as Administrator by finding Git Bash in the Start Menu, right clicking on it, and selecting Run as administrator
    1. run the following command to move to the web root directory
      cd C:/Users/USERNAME/UwAmp/www/
  10. run the following command to download all of the Content Server files
    ./get_assets.sh
  11. run the following command to close Git Bash
    exit

Redirect content.quakejs.com

Currently the content server address (content.quakejs.com) is hard coded into the compile ioq3 code. Because QuakeJS is so old, the version of Empscripten used to compile it is no longer available. I'm working on figuring out how to recompile the program. In the meantime, the easiest hack (and it is a hack) I've found to be able to run a local QuakeJS server, without an internet connection, is to edit your hosts file to redirect content.quakejs.com to your localhost. The below instructions will explain how to do this.

  1. Open your favorite text editor as Administrator (I prefer notepad++)
  2. Open C:\Windows\System32\drivers\etc\hosts
  3. Add the following line to the bottom of the file
    127.0.0.1		content.quakejs.com		# quakejs local content server redirect
  4. Save the file and close the editor

Extras

Make the QuakeJS Game Server run at Boot

In a permanent install you may want to make the QuakeJS Game Server run when you boot the machine and log in. Follow these steps to create a Schedule Task to run the server any time your user logs in

  1. Run Task Scheduler from the Start Menu
  2. click Create Task... on the right
    1. On the General tab fill in the following information
      • Name: QuakeJS Server
      • Description: Task to start QuakeJS server in DM mode
      • check Run with highest privileges
      • Configure For: Windows 10
    2. On the Triggers tab click New..., fill in the following information, and click OK
      • begin the task: At log on
      • click Specific user and select your user
    3. On the Actions tab click New..., fill in the following, and click OK
      • Program/script: "C:\Program Files\nodejs\node.exe"
      • Add arguments (optional): build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg
      • Start in (optional): C:\Users\USERNAME\quakejs
    4. On the Conditions' tab optionally uncheck Start the task only if the computer is on AC power
    5. On the Settings tab uncheck Stop the task if it runs longer than:
    6. click OK

Create a Game Server Shortcut

If you are going to run your server intermittently you may want to create a shortcut to launch it. Follow these steps to put a shortcut on your desktop that will launch the game server.

  1. Right click on the desktop (or in any folder you want the shortcut to live in) and click New and then Shortcut
  2. In the Type the location of this item: enter
    %comspec% /k cd C:\Users\USERNAME\quakejs && node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg
  3. click Next
  4. enter a name like QuakeJS Game Server
  5. click Finish

Turning on and off the UwAmp Serve

Simply run C:\Users\USERNAME\UwAmp\UwAmp.exe, or UwAmp program in the Start Menu, to start the server and close it to stop it (you can also start stop with the buttons on the UwAmp GUI once it's running)

Turning on and off the Game Server

Run the shortcut you created on the desktop or go into Task Scheduler and run the QuakeJS Sever task manually to start the server. Close the window that pops up to stop it.

Notes on Customization

Changing the Hostname

If you want to use a hostname other than "quakejs" you'll need to update the line
var args = ['+set', 'fs_cdn', 'quakejs:80', '+connect', 'quakejs:27960']; //custom args list targeting a local content server and local game server both at the address 'quakejs'
in
/var/www/html/index.html
to your new hostname (instead of quakejs).

Understanding Server Settings in server.cfg

Parameter Description
seta sv_hostname "DM Server All Maps" What players will see on the join server window
seta sv_maxclients 16 Maximum number of players on the server
seta g_motd "Welcome to our Quake3 server" Message players will see while joining the server
seta g_quadfactor 3 Quad Damage strength. 3 is normal
seta g_gametype 0 Sets the type of game:
0 - Free for all
1 - Tournament
2 - Free for all(again)
3 - Team Deathmatch
4 - Capture the Flag
seta timelimit 15 Sets the timelimit
seta fraglimit 25
seta g_weaponrespawn 3 Number of seconds before weapons respawn
seta g_inactivity 3000 Number of seconds before an inactive player is kicked
seta g_forcerespawn 0 Forces players to respawn:
0 - off
1 - on
seta rconpassword "password" Sets the password to allow client control of the server
set d1 "map q3dm1 ; set nextmap vstr d2"
set d2 "map q3dm2 ; set nextmap vstr d3"
set d3 "map q3dm3 ; set nextmap vstr d1"
vstr d1
These last few lines of this example set up a simple map rotation

Visit https://www.quake3world.com/q3guide/servers.html for details on these settings.

Using the Full Quake 3 Game

This guide (and Inolen's original project) targets the Demo version of Quake 3. If you'd like to try your hand at hosting a node.js version of the full Quake 3 game ronfar623 over at reddit figured out how to do it. You can read his instructions at the link below. Note that he starts by following my instructions above to set up a working Demo version so you'll need to do that first.
https://www.reddit.com/r/quake/comments/cpn4rp/how_to_setup_your_own_local_quakejs_server/ezr8m3c?utm_source=share&utm_medium=web2x

Adding your own Maps

Check out this video by Grabisoft https://www.youtube.com/watch?v=m57rMXASWms

and this GitHub Issue https://github.com/inolen/quakejs/issues/19#issuecomment-570895962