RecWars

Recreational Warfare .rs
A multiplayer top-down tank shooter - Rust/WASM port of an old Windows game called RecWar.


CI Dependency status Discord Total lines Lines of comments

Gameplay

Play in the Browser | Older version | Join Discord

RecWars is a free and open source clone of RecWar - you control a vehicle and fight other vehicles in a variety of game modes using an arsenal of several distinct weapons. You can play against bots, in splitscreen and over the network.

RecWars aims to have gameplay similar, but not identical, to RecWar. I suspect RecWar was balanced for playing against bots and might result in annoying strats being the most effective when people start playing to win. However, almost everything in RecWars is configurable and you can switch to the original RecWar balance to compare.

Currently this is very much a work-in-progress: the driving physics don't feel right, there are no collisions between vehicles, bots move randomly ...

The ultimate goal is to create a moddable multiplayer game playable in the browser and natively on Linux, Windows and macOS. This might be tricky since WASM in the browser doesn't allow UDP. I have some ideas how to solve that.

(Planned) Features

See TODO.md for details.

Build Dependencies

The first RecWars prototype drew to an HTML canvas directly, later I switched to the macroquad engine which can run both natively and in the browser. I am keeping both versions for now but new development (especially sound and UI) is gonna happen in macroquad. The benefit of the raw canvas version is that you can change any cvars at runtime using the browser console. Eventually the macroquad version is gonna get a console too.

Macroquad versions (native and WASM)

Install Macroquad's dependencies.

Raw canvas version

Install wasm-pack - use the installer.

Compiling and running

Native version (macroquad)

How to run: - cargo run

See cargo run -- --help for more options (splitscreen, map, ...)

Browser version (macroquad + WASM)

This version is hosted here.

Might have performance issues in firefox on linux - making the window smaller might help.

How to run locally:

Browser version (raw canvas + WASM)

This version is hosted here.

Might have performance issues in firefox on linux - making the canvas element smaller might help.

How to run locally: - Build with wasm-pack build --target web --dev -- --no-default-features --features raw_canvas - You can replace --dev with --profiling or --release if perf is an issue (see Cargo.toml for more info) - Host with python3 -m http.server (or any other web server, simply opening index.html will not work though) - Open http://localhost:8000/web/

Contributing

You can always find me on the RecWars Discord server if you have any questions or suggestions.

Issues and Pull Requests are welcome, I am open to anyone wanting to help improve RecWars.

I want to make RecWars highly configurable with many different gamemodes and balance settings votable by players and anybody will be able to host their own server (if technically possible, then even from the browser). If you have a gameplay idea and don't suffer from the NIH syndrome, I'd be very happy to help you test it in RecWars.

Optionally enable extra checks before every commit with git config core.hooksPath git-hooks.

Architecture Overview

Most of the code is commented to be understandable to anyone with a vague idea of how a game works. If it's not clear why a particular piece of code exists or why it needs to be written the way it is, I consider that a bug which should be fixed by either rewriting the code more clearly or adding comments explaining it.

RecWars consists of a library which contains most of the code and two rendering frontends behind optional features. The raw_canvas version also lives in the library, the macroquad version uses main.rs.

Currently, most game state is managed by generational arenas from the thunderdome crate to make the code type-safe and readable. Previously, RecWars used the legion ECS. However it was cumbersome to use and WASM didn't get any benefits from parallelism. The only reason I was using ECS was so I could have references between entities and for this I was paying by having all entities dynamicly typed which lead to bugs. It's a Rust tradition to start writing a game and end up writing a game engine or ECS so I am considering creating an ECS crate that would satisfy my standards of clean API and static typing. For now arenas seem to be close enough.

Cvars

Cvars are console variables - configuration settings which control everything in the game like physics, weapon behavior, AI, HUD layout, etc.

There are two ways to change them: - Edit the cvars object using the browser console - e.g. cvars.g_armor = 100. - Set them using URL parameters - e.g. https://martin-t.gitlab.io/gitlab-pages/rec-wars/web/?g_armor=100

The entire list of cvars is in src/cvars.rs.

The Original Game

RecWar by Willem Janssen: - homepage: http://recreationalwarfare.atspace.com/indexwillem.html (the game's download is broken but still hosts extra maps) - unofficial homepage: http://www.recwar.50webs.com/ - archive.org download: https://archive.org/details/recwar201903 - archive.org download with extra maps: https://archive.org/details/RecWar

The original RecWar only contains a Windows .exe but runs ok-ish wine (sometimes freezes on map load). It includes a map editor. The binaries in both archive.org links are identical to what I got on an old CD so should be safe.

RecWars vs RecWar differences

RecWar would probably be impossible to replicate exactly without decompiling the binary (which doesn't even contain debug symbols), though if a fan of the original finds this project, I am not gonna stop them from trying.

Additionally, when playing against people instead of bots, I suspect RecWar's original balance would lead to annoying and boring strats like making the cow inaccessible with mines or just simple camping. For example, experience from poorly designed games shows large areas will be dominated by instant-hit weapons (in RecWar the railgun) and there might simply be no way to get across the map alive. Therefore I made the railgun a very fast projectile in RecWars. I might make more balance changes based on how the online gameplay evolves.

For those reasons, RecWars will have a slightly different balance than RecWar. I will try to keep them as similar as possible but some things like physics will never be exact and I will make changes where I see fit to make the gameplay more interesting.

The two balance presets are available here: - https://martin-t.gitlab.io/gitlab-pages/rec-wars/web/?balance=recwars (default) - https://martin-t.gitlab.io/gitlab-pages/rec-wars/web/?balance=recwar

Intentional differences (can be toggled by switching the balance): - Railgun - RecWar railgun hits instantly, RecWars uses a very fast projectile because hitscan weapons ruin large maps

Other unintentional differences - I will make best effort here but some things won't be exact: - Speeds, accelerations, turning, inertia of vehicles and weapons - Push force of mines and railguns - Tank in RecWar turned around turret swivel point, not center of chassis - this is for simplicity for now - Weapons - Damage - Cluster bomb and BFG beam are hard to measure exactly - Spreads - Cluster bombs and MG are hard to measure exactly - Self destruct damage and range - it appears to be the only explosion in RecWar with damage decreasing by distance and it's really hard to measure exactly.

Maps

Currently the map is picked randomly by default, however, you can select one manually by using the map URL parameter, for example https://martin-t.gitlab.io/gitlab-pages/rec-wars/web/?map=Castle Islands (4).

Lessons Learned

Read this to learn from other people's mistakes and save yourself some time.

License

All code is available under AGPL-v3 or newer.

All assets (maps, textures, sounds, etc.) are taken from the original RecWar by Willem Janssen which is freely available online.