Skip to content

A Game Modification boilerplate for Node.js of Urban Terror (UrT) version 4 game

License

Notifications You must be signed in to change notification settings

tarquas/node-urt4

Repository files navigation

NodeUrt4

This is a Game Modification boilerplate for Node.js of Urban Terror (UrT) version 4 game, based on ioQuake3 (ioq3) game engine.

We inject our hook declarations to functions of Mickael9's UrT engine code via compiler extensions, and link modified UrT objects with our hook implementations and our TCP API implementation to an executable. It interacts via API with our Game Mod's business-logic code in Javascript.

How to use?

Dependencies

Quick set we have success with

As of we, you also most likely to be lucky building and locally running this project if you get the following installed and available from your PATH:

  • Unix-like OS.
  • Latest stable GNU Make tool (check make -v in terminal).
  • Latest stable GCC or Clang in PATH (check cc -v, gcc -v, and clang -v in terminal).
  • Latest stable official Node.js with NPM bundled (check node -v and npm -v in terminal).
  • Latest stable official MongoDB (Community Server is enough) running on localhost at default TCP port 27017 (check netstat -ntlp | grep :27017 in terminal).
  • GNU Wget for downloading of external files (check wget -V in terminal). As you get this all, go to repo directory and type:
make run

This will automatically clone latest code of Mickael9's repository to ioq3 directory and download minified UrT game directory q3ut4 from cloud (128 MiB), extract the files, perform build, install NPM packages and locally run of UrT server.

Example installation as a service on Debian 10 (Buster)

Below steps will set up 2 UrT servers: one for shooting modes (on default port) and one for jump mode (on port 1337).

  1. Prepare APT resources for MongoDB:
sudo apt update
sudo apt -y install gnupg2
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get install mongodb-org
  1. Prepare APT resources for Node.js:
wget -qO- https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install nodejs
  1. Install other dependencies:
sudo apt-get install build-essential gcc git libcap2-bin make screen unzip
  1. Add user urt.
sudo useradd -s /bin/bash -m urt
  1. Login to user urt, clone this repo, compile the binary, and install NPM dependencies:
sudo login -f urt

then:

git clone --depth=1 "https://github.com/tarquas/node-urt4.git" ~/node-urt4
cd ~/node-urt4
make lib-release
make run-prepare

finally, exit from urt shell:

exit
  1. Install and run the services:
cp /home/urt/node-urt4/init.d/* /etc/init.d
systemctl enable urt-mod
systemctl enable urt-game-guns
systemctl enable urt-game-jump
service urt-mod start
service urt-game-guns start
service urt-game-jump start

Consoles of service processes are available via screen:

  • for a mod: screen -x urt/urt-mod
  • for UrT server: screen -x urt/urt-game-guns
  • for UrT jump server: screen -x urt/urt-game-jump

To take advantage of mousewheel and Shift+PgUp/PgDn scrolling inside the screen, use once:

echo "termcapinfo xterm* ti@:te@" | sudo tee -a /etc/screenrc
  1. Run the game and connect to your server. Go to mod console:
screen -x urt/urt-mod

Find your name in list of players and grant yourself administrator privileges (in example below your player is #2):

list
setlevel 2 admin
  1. Press CTRL+A,D to detach from mod console screen.

  2. In game console type !help (any of .!@&/ may be used instead of !, but note that when using / some commands may be shadowed by client game engine f.x. /map).

Details

  • A C/C++ compiler and linker collection must be chosen to support alias and weak function attributes (this is used to organize our hooks). Latest GCC or Clang must most likely be fine.
  • We use Node.js as execution environment of our business logic written in Javascript. Latest stable version is recommended.
  • We use NPM package manager to manage our Node.js' third-party modules we use in our Javascript code. Since it's bundled with Node.js, it's not needed to install it separately.

Minification

Patched game engine (with hooks) supports the minified PK3 files (files which are not related to serverside engine are removed or truncated to zero). It allows to save resources on your server.

Compare the sizes of some bundled PK3 files to sizes of their original versions:

Minified 3.2M ut4_beijing_b3.pk3 4.4M ut4_facade_b5.pk3 1.7M ut4_orbital_sl.pk3 4.6M ut4_tohunga_b8.pk3 14M total

Original 25M ut4_beijing_b3.pk3 31M ut4_facade_b5.pk3 15M ut4_orbital_sl.pk3 18M ut4_tohunga_b8.pk3 88M total

Extended map packs

We also provide 2 packs of maps, which may be quickly installed after all basic installation (after make run succeeded):

  • fun pack for gun mode:
make installmaps-fun-1
  • jump pack for jump mode:
make installmaps-jump-1

Apply changes for newly installed maps

After you install new PK3 or alter list of maps in config, you can apply the changes by:

  • For PK3 either restart the engine or issue command fs as an admin (from game or server console);
  • For map config restart the mod by issuing command ~q from server console.

Development notes

Mod and game engine are free to run alone without each other. This allows you to make changes in mod code (in /src/app) and restart the mod without restarting the game engine. However, modification of ioq3 hooks (in /src/hooks and /include) requires recompilation and restart of game engine.

The game engine alone will temporarily lose all mod features until the mod gets started again and catches API connection from engine. Also, mod can handle multiple game engines (f.x. shooting and jump server in default setup).

Copyleft

All dev bros are free to do with this stuff anything they want without any legal limitations if they keep this software free. Also you're free to collaborate here, make proposals, features, bugfixes, pull requests etc. etc.

Have fun!

About

A Game Modification boilerplate for Node.js of Urban Terror (UrT) version 4 game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published