ILDeathmatch: Monetize Your Quake Games

With Interledger and Web Monetization, developers and content creators are offered the ability to make many small real-time payments. In particular, this allows the monetization of high-frequency events where money will change hands often.

This opens up a number of payment-related use cases that were previously weren’t feasible. The gaming sector provides an excellent opportunity to apply these concepts, as there are a number of fast-paced games that have a high volume of events that can be monetized to reward certain aspects such as individual skill.

We’ll examine this application of Web Monetization with a project called ILDeathmatch. This will be lengthy, so strap in.

Recommended Reading

As ILDeathmatch is a rather specific use case for Interledger and Web Monetization, it draws heavily upon previously mentioned concepts on this blog. The necessary context will be provided throughout this post, but for the big picture, the following posts are recommended:

What is ILDeathmatch?

ILDeathmatch, or ILDM for short, uses Web Monetization to provide a different gaming experience delivered on the back of the classic First-Person Shooter Quake III Arena, entirely within the browser.

ILDeathmatch modifies Quake III gameplay in these ways:

  • Players connecting to the server must pay a server-defined amount in order to spawn or respawn.
  • Players who score kills on other players are paid a server-defined amount.

In cases where the player is unable to pay the server when prompted, the player is kicked from the server. Harsh, but then again, so is Quake.

How does it work?

There are three major components to hosting ILDM. A Quake Server, a Web Monetization server, and Moneyd. All three of these components are hosted together on a single Web server.

The Web Monetization Server

The Web Monetization Server is the component that actually exposes endpoints that send and receive payment. It handles API calls from the Quake Server as certain events in a game occur, and collects payment & payment pointers from users that join.

As described before with Web Monetization, users send payment to the server with any web extension that provides Web Monetization (such as Minute from the Chrome Web Store). Over time, it generates a balance tied to a single user that the server deducts from as they spawn or respawn into the game. They receive payments by creating an SPSP Server and sending the payment pointer that is generated to the Web Monetization Server via a form.

The Quake Server

The Quake Server is essentially no different from a typical Quake game server. It hosts a game session of Quake III Arena running Free-For-All as a game mode. The main difference is that the server is run as a child of a Node.js process, which monitors the server console and makes API calls as events such as connections, disconnections, kills, and deaths occur. It also handles the kicking of players who don’t have a high enough balance to spawn.

Moneyd

Moneyd has been discussed before on this blog, and in this context it does not deviate much from its previous descriptions. The Web Monetization Server runs this daemon in order to facilitate payments over Interledger.

Joining the live ILDeathmatch Demo

If you’ve got some time to kill (as well as some friends), you can join the live ILDeathmatch Server at ildeathmatch.com. It runs Moneyd on the testnet, so no real money is transferred or required.

Prerequisites

You will need to be running an instance of Moneyd on the testnet in order to send and receive “payments” from the demo site. Attempting to connect with Moneyd on the livenet will cause you to be kicked from the server. You can read about setting up Moneyd here. Make sure that you’re on Moneyd version 4 or higher.

Since Moneyd does not connect to the browser for payments by default, be sure it’s running with --unsafe-allow-extensions as seen below:

moneyd xrp:start --testnet --unsafe-allow-extensions

Replace xrp:start with your currency of preference if you aren’t using the XRP uplink.

You will also need to be using Google Chrome as a browser, as the current implementation of Web Monetization uses a Chrome extension to make payments.

The Chrome extension is called Minute, which connects to Moneyd to allow web pages to receive funds from it for monetized content. You can install Minute from the Chrome Web Store here.

Finally, you will need to set up a SPSP Server. It will create a local tunnel on your machine through which you can receive “payments” from the ILDeathmatch server. You can read about setting up a SPSP Server here.

Connecting to ILDeathmatch

Once you’ve completed all the prerequisites, connect to the demo at ildeathmatch.com. You’ll be greeted with a simple landing page with a form that looks like this:

In order to connect, all you have to do is enter a valid payment pointer. The site will ping your pointer, and if it is successful, you’ll connect to the Quake server. You’ll be asked to download the Quake 3 Demo binary into your browser. Read the EULA, then accept the terms. After that, you’ll load into the game. All that’s left to do now is get some frags.

Be sure to monitor the output of your SPSP Server process. You’ll notice that it’ll receive a 0-drop ping upon connecting, and then pay you in real time for the kills you score.

Further Reading

The source code for the Quake Server can be found here, as well as the source code for the Web Monetization Server. The Web Monetization server extends Koa Web Monetization with a module called DM Web Monetization. If you wish to run your own instance of ILDeathmatch, you can refer to the docs in these repositories.

Credits

The Javascript implementation of Quake III Arena is owed entirely to the work of “inolen” at inolen/quakejs.

If you have any questions, feel free to ask them in our Gitter!