Changes

Created page with "'''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 fi..."
'''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.

I found myself in a situation where I was going to be on a [https://en.wikipedia.org/wiki/Local_area_network 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 [http://www.quakejs.com/ QuakeJS]. [https://en.wikipedia.org/wiki/Quake_III_Arena Quake 3] was [https://github.com/id-Software/Quake-III-Arena open sourced] at the beginning of 2012 and some awesome dudes based [https://github.com/ioquake/ioq3 ioquake3] off of it. Another [https://github.com/inolen awesome dude] created QuakeJS around 2013/2014. QuakeJS allows you to play Quake 3 entirely in a browser.

The [https://github.com/inolen/quakejs source code] has instructions for creating a dedicated server as well as building from source & generating assets for a content server. Unfortunately the [https://emscripten.org/ Emscripten] tool used to build the project has changed the way it operates in since 2014 and the current version of the QuakeJS source [https://github.com/inolen/quakejs/issues/44 doesn't build] with modern versions of Emscripten. I've found some work-arounds. Some helpful discussion on how to setup a local webpage to connect to the server (as well as providing the content necessary to play) can be found [https://github.com/inolen/quakejs/issues/19 here].

The theory is pretty simple
#Follow Inolen's [https://github.com/inolen/quakejs/blob/master/README.md original instructions] for setting up a QuakeJS server
#Download everything we might need from the content server http://content.quakejs.com and rehost it locally
#Download the source code (and referenced CSS & JS files) from http://www.quakejs.com/play, modify them for local use, and rehost them locally
#Frag

Below I'm going to break it down step by step

'''<pre style="color: red">NOTE: This guide assumes your local server's hostname is "quakejs"</pre>'''

=Setup a Local QuakeJS Server=
#Install curl by running <pre>sudo apt install curl</pre>
#Add the repo for [https://nodejs.org/en/ node.js] by running <pre>curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -</pre>
#Install the tools we need to setup our server by running <pre>sudo apt install git build-essential nodejs</pre>
#Move into our home directory by running <pre>cd ~</pre>
#Clone the original QuakeJS git repository (along with the ioq3 repository sub-module) by running <pre>git clone --recurse-submodules https://github.com/inolen/quakejs.git</pre>
#Move into the newly created ''quakejs'' directory by running <pre>cd quakejs</pre>
#Install the necessary node.js packages by running <pre>npm install</pre>
#Run the server for the 1st time by executing the following command. Continue to hit '''enter''' a lot to get through the EULA, agree to the EULA by hitting '''y''' and game files will be downloaded. Once all files have been downloaded quit the server by hitting '''Ctrl+C'''<pre>node build/ioq3ded.js +set fs_game baseq3 +set dedicated 1</pre>
#Create a baseq3 server config file by running the following command <pre>nano /base/baseq3/server.cfg</pre> and fill in the body with the following <pre>seta sv_hostname "quakejs"&#10;seta sv_maxclients 12&#10;seta g_motd "Welcome to the Local baseq3 QuakeJS Server"&#10;seta g_quadfactor 3&#10;seta g_gametype 0&#10;seta timelimit 15&#10;seta fraglimit 25&#10;seta g_weaponrespawn 3&#10;seta g_inactivity 3000&#10;seta g_forcerespawn 0&#10;seta rconpassword "quakejs"&#10;set d1 "map q3dm7 ; set nextmap vstr d2"&#10;set d2 "map q3dm17 ; set nextmap vstr d1"&#10;vstr d1</pre>
#Run your server with the following command <pre>node build/ioq3ded.js +set fs_game baseq3 set dedicated 1 +exec server.cfg</pre>
Make sure you change the password in '''seta rconpassword'''
=Setup a Local Content Server=
#Setup a webserver to host our content buy running <pre>sudo apt install apache2</pre>
#Download a script that I wrote to simplify getting the assets from http://content.quakejs.com by Running <pre>sudo wget -O /var/www/html/get_assets.sh https://raw.githubusercontent.com/begleysm/quakejs/master/assets/get_assets.sh</pre>
#Run the script and grab all of the assets from http://content.quakejs.com and put them where they can be accessed by clients by running <pre>sudo /var/www/html/get_assets.sh</pre>
#Optionally remove get_assets.sh by running <pre>sudo rm /var/www/html/get_assets.sh</pre>
=Setup a Local Play Page=
#If you didn't already install Apache2 for the content server, do it now by running <pre>sudo apt install apache2</pre>
#Delete the default index.html that comes with Apache2 by running <pre>sudo rm /var/www/html/index.html</pre>
#Download a copy of the Play Page from the QuakeJS website and put it where it can be accessed locally by running <pre>sudo wget -O /var/www/html/index.html http://www.quakejs.com/play</pre>
#Download a copy of the [https://en.wikipedia.org/wiki/Cascading_Style_Sheets CSS] used to format the Play Page and it where it goes by running <pre>sudo wget -O /var/www/html/game.css http://www.quakejs.com/css/ff3bfe05fa66a6c5418f2f02b0e55e36-game.css</pre>
#Download a copy of the [https://en.wikipedia.org/wiki/JavaScript JS] and put it where it goes by running <pre>sudo wget -O /var/www/html/ioquake3.js http://www.quakejs.com/js/38cbed8aa9a0bda4736d1aede69b4867-ioquake3.js</pre>
#Modify the Play Page you downloaded to make it suitable for running locally by running the following command and making the change specified below <pre>nano /var/www/html/index.html</pre>
##Change Line 4 to say whatever you want, something like <pre><title>QuakeJS Local</title></pre>
##Change Line 5 to <pre><link rel="stylesheet" href="/game.css"></link></pre>
##Change Line 6 to <pre><script type="text/javascript" src="/ioquake3.js"></script></pre>
##Comment out Lines 7 through 16 to disable Google Analytics
###Change Line 7 to <pre><!-- <script type="text/javascript"></pre>
###Change Line 16 to <pre></script> --></pre>
##Change Line 75 to <pre>var args = ['+set', 'fs_cdn', 'quakejs:80', '+connect', 'quakejs:27960'];</pre>