Introducing: Nuclear Throne Together

Perhaps you've already heard that I've been recently developing a mod for the current version of Nuclear Throne. And not "just" a mod, but quite an impressing one:

  • Adds Steam-based online multiplayer support to the game.
    That means invitations, public game list, and no port forwarding.
  • Replays
    Easily record and review your runs to learn from mistakes.
    Or even attempt to correct them by dropping into the game at any point of a replay.
  • Better coop
    Nuclear Throne never was a coop-centric game, and thus coop mode didn't receive enough attention, remaining ridden with various small bugs. This mod changes that, fixing pretty much every known issue, and giving coop some much-needed polish.
  • Bugfixes
    While fixing coop-related bugs is an obvious choice given the scope of the mod, I didn't stick to just that, and also fixed a handful of other issues with the game. Bugged "crown vaults"? Fixed. Game hanging in certain areas? Fixed. Occasional crashes during an intro to an important boss fight? Also fixed. The full list is long (200+ items) and available in the "readme" document.

So it works, it's nice, and you can download it right now.

Or continue reading on process and potential questions.

A bit of prehistory

In general, this mod's development followed a pattern commonly seen in my works:

  • 1. Pick a goal that is considered somewhat impossible, but does look possible to me.
  • 2. Slightly underestimate amount of effort required to accomplish the goal.
  • 3. Get it done anyway.

In this case, the following happened:

  • Needless to say, I do like Nuclear Throne a lot. I've sunk well over a hundred hours into the game over the course of it's development, watched the development closely, and was interested in the game's cooperative mode since it's introduction.
  • Last autumn, Wasteland Kings' (jam version of Nuclear Throne) source code became available through GameMaker-themed Humble Bundle deal together with a bunch of other nice games.
  • Overwhelmed by curiosity, I've decided to get the bundle and mess with coop games included for a little. This resulted in Super Crate Box Together and Wasteland Kings Together mods.
  • WKT being well-received and working nicely for vast majority of players, numerous people suggested that Vlambeer should hire me to do online multiplayer for the actual game.
    In a brief chat following, Vlambeer's Rami Ismail voiced largely-reasonable concerns about whether the approaches used would be viable for NT.
    At the time I didn't feel like arguing about the fact that lack of online multiplayer means that many people won't get to play the game in coop at all, so I did not continue the conversation.
  • Sometime since the end of 2015, I was also looking at different bytecode implementations with intentions of looking for good tricks to use in my own bytecode interpreter.
    In part this also involve staring at GameMaker's bytecode format, partially for research, and partially for understanding how things work better. So I made a little tool (shown below) to display tweaked bytecode in the most readable format possible, did some tests, and sometime through this I've thought "well, this doesn't look that terrifying. If I were to tweak some things, could I hack some new code into a game?". And thus...

Deconstructing Nuclear Throne

The next thing that happens is me staring at a 9.5MB \ 233 000 line long bytecode dump of Nuclear Throne, trying to make any sense of what's going on, questioning my intentions.

Should you have an impression that reverse-engineering an existing large game to poke few thousand new lines worth of code into it isn't a bad idea – it very well is.

While for my purposes I would rarely need to actually decrypt snippets of bytecode (either adding new code or replacing snippets with something that would work with netplay), looking for anything in such a giant pile is, to say at least, not very fast.

So for the next long while I was poking this in spare time, concluding in a test mod release on May 21, 2016, and finally being able to get to the actual online multiplayer on May 26, 2016.

Small-scale netplay for a large-scale game

As you may know, Nuclear Throne gets pretty chaotic in late game.

While the game starts with singular enemies and a few projectiles here and there, in mere 10-15 minutes you can already have decades of enemies and hundreds of projectiles (many of which your own) at screen at once.

Obviously, you can't just send that much information on an average internet connection easily.

In this case, a feasible workaround is a "synchronous" \ "lockstep" - like system, where the game is modified to behave completely deterministically (as in, not depending on external factors), therefore reducing the volume of data to be sent to player actions.

Similar approaches are commonly used in emulation software, as well as most fighting games.

However, "synchronous" multiplayer also means input delay, which can hurt a little, particularly with mouse controls (ever tried playing something via TeamViewer\Nvidia GameStream? It hurts).

So the latency is divided between players, critical things (camera, aiming) are handled without delay, and there are additional tricks used to improve the situation where appropriate.

On the technical side, the mod uses Steam API via a native extension that I've made, which is how there are Steam invitations, lobby list, and other things that you'd expect to see in larger games;
As per usual, I made use of code from my existing projects, so certain menus and systems may appear very familiar.

All in all, while the mod requires somewhat-low-latency (100ms delay / 200ms ping) connection for comfortable play, that's already substantially better than needing the second player to come over.

Legal & extras

After having a buggy-but-functional build done after a week of work or so, came the exciting part: waiting for an answer at whether it is legal to release this mod at all.

See, being a likely-first mod of such kind, neither me nor Vlambeer folks could know for sure as to what is right (in legal terms) and what isn't. So I wrote to Rami. And Rami wrote to legal. And, well, this took a little longer than intended, having received the final answer almost 3 weeks later.

But that's okay, since waiting for the response also meant that the mod went through substantially more testing, and got proportionally more bugfixes, and even a few new features.

Perhaps somewhat unsurprisingly, NT having local-only coop meant that fewer people were playing coop at all, and as the result there were much more bugs in that than I've expected.

So I'd look at anything that was reported and could be traced back to anything particular easily.

Not having access to the original source code anyway, anything found to be related to a problem would be tossed out and replaced with a snippet based on freshly written code.

While this isn't an optimal approach, over time I was able to fix pretty much every known issue related to coop, as well as number of bugs from the original game.

For example, the aforementioned infamous "cursed vault" bug, which is basically the game accidentally mashing up two unrelated levels together (not to your advantage), turned out to be caused by the game accidentally dropping a chest onto an "objective" prop, crushing it, and triggering the level index change before the area was even done generating, as result filling the area with enemies and props from the new level.

In the end, the mod is now more stable than the actual game in some aspects, which is pleasing.

Could this be done better?

Of course.

It would have been nice to support up to 4 players, but, unfortunately, Nuclear Throne was not coded for 4-player support originally, so the game is lacking support for this in UI, code, and balance alike. While this might be doable in future, it would take time to get right.
Update: After an amount of technical struggles, I was able to implement this in spring 2017.

It would have been nice to have Mac and Linux versions, but that requires additional testing (and making variants of patcher program for Mac and Linux, which hurts a lot), so shall probably come in future. Till then, NT seems to run unusually fine on Wine.

Ideally, the mod should also have had even more going on for lag compensation, to make the game playable even on higher latency connections. Unfortunately, that requires reworking the game's collision systems to an extent, which would be a lot of trouble to do with how this works.

In an even more ideal scenario, it would have been great to integrate a scripting system into it, which, combined with online multiplayer, could quite likely longen the game's lifespan by a lot, but – alas, that is even more work. In fact, a pretty absurd amount of work for something that you aren't a developer of in the first place.
Update: Over autumn and winter of 2016 I managed to implement a suitable scripting system, culminating in February 2017 release. Later I managed to get Lua scripting to work in GameMaker, which is something you can make use of if you are looking to add modding support to your own games.

So you've got to do what is practical to do.

Could Vlambeer do this themselves?

This is something that some people were asking me about a lot.

In theory, with enough time, they could do an online multiplayer implementation by themselves.

In practice, the reality is kind of harsh, and while you can try to do online multiplayer without prior experience, you are incredibly likely to mess it up on first try.

By which I mean – if you are considering getting into netcode, please do not start with your commercial game. Things are easier to break than fix.

If you can, consider hiring someone that is actually proficient with this kind of thing.
Or at least seek existing tools/libraries that can help you with not messing up.

So overall while Vlambeer could have tried to do online multiplayer by themselves, it would likely be regrettable for everyone.

In conclusion

So, in conclusion, this was tough, and interesting, and fun.

This post should have been a tad bit longer, but I'm sure that everyone very much want to play it already, so that's it for now.

itch.io page ThroneButt page

Related posts:

97 thoughts on “Introducing: Nuclear Throne Together

  1. I have not tried the current build in coop yet, but when playing solo, the loading screen “hangs” on 7-3, freezing for about 15 seconds before loading the level. It isn’t a crash, but is nonetheless annoying. Any idea what could be causing it?

    • 7-3 is by far the largest level, and always takes the longest to generate.

      Base version of the game relies on a particular conditional feature (generalized collision detection optimization) for this to not take forever, but that same feature is causing problems in multiplayer due to not acting entirely predictably (i.e. a bullet overlapping two enemies will not necessarily hit the same enemy with this on), and thus cannot be utilized.

      Time to time I’m looking into possible viable solutions to speeding up level generation, but so far this did not result in any particularly notable improvements.

  2. Is game saving working how it should? So far I didn’t manage to load a game in coop, it just shows ‘Loaded game.sav’ to both players but doesn’t change a thing. Doesn’t matter if we load it while alive or on death screen. Am I doing something wrong?

  3. After trying out the 9843 build, the original save was not compatible anymore. This is not an issue, but I wanted to unlock some cnaracters and golden weapons before i play coop with someone else but the unlocking seems broken. To unlock a new character I needed to unlock them at least twice for the game to save the unlock, golden weapons are not unlocked and saved, even if the unlock sound and notification pop up. The exclamation mark on characters won’t go away, as if I did not play them yet.

    • Also the screen shake is almost non existent, the setting in the menu does nothing anymore.

      • When playing coop, screenshake is set to the lower value between two players.
        I’m not sure what’s up with unlocks (I’ve only tried to bring them back in this update, to much expense), but golden weapons can be set via /cwep if needed anyway.
        If you use /loadgame, automatic saving is disabled for that session.

  4. Is there any chance of you creating an update that implements regular ultra mutations on top of the co-op mutations? Or something like a sandbox mode or mod menu?

  5. Hi, YAL! First, thank you for all your hard work. My friend and I are enjoying this mod a huge amount. It’s really ambitious, and you did some fantastic stuff here.

    I may have found a bug, though: if you get a Golden weapon in single player mod, it doesn’t show up in the online co-op. If you get a Golden weapon in online co-op, you keep it until the end of the game, then it disappears. AND, if you had a Golden weapon from solo, then go into a online co-op game, not only does it not show the golden guns, but it deletes the guns you’ve earned in solo!

    Not sure if you’re still monitoring this thread or not, and I don’t know if this is something you already know about. I tried to google it, but I didn’t have any luck. I hope you’re well and I hope this feedback is helpful. Thanks again for such a great mod!

    • Progress is not kept in multiplayer unless you explicitly load the game with commands (see readme). This is because both players have their own savegames and merging them together would be a mess of a task.

      On golden weapons in particular, there are commands for setting starting weapons (both primary and secondary, in fact), so you can use those (again, see readme). These were added because Nuclear Throne does not allow to open the “loadout” menu in coop, as you may have noticed.

  6. I know this is a bit of a necro, but when I use wine to play this mod (on mac) using the windows versions of Steam and Nuclear Throne, the mod installs properly and runs seemingly bug-free, except one that essentially makes the game unplayable. In the menu, everything seems to be running fine. However, any of the options in the menu make the game run at what seems like at most half the regular FPS. For each menu option selected further, the game gets even slower. Going back removes the lag that was caused by picking the option in the first place, but, unfortunately, it even applies to attempting to play the game, and gets even worse after a character is picked. While in-game, the game runs at about 2-8 FPS, but it’s not just that; all the functions happening in-game are also slower, so even if I had 60 FPS, it’d be like playing the game in slow-motion. I haven’t even attempted to play multiplayer yet, since, at best, it couldn’t be any more playable than single player. However, I’ve tried the mod on a friend’s computer, and I can say that the mod seems really good. It’s just a shame I can’t play it.

    • The upcoming update should make things a little better – I was able to eliminate an issue with level generator that had the game slow down on some Windows computers and on most Wine setups.

      The general thing’s with Wine is that games can lag in situations where they run perfectly fine on Windows (or via emulation-related solutions like Parallels), and debugging is quirky and time-consuming (making series of builds that display execution time for one or other part of game until source of problem is found).

      I wouldn’t be surprised if there are ways to configure Wine to run the game correctly as-is, but I personally lack experience with this, so cannot offer any better advice than experimenting with both Wine’ and game’ settings (resolution, window size, fullscreen mode).

  7. Pls if you have time make this: lock everything like the original NT and make it unlockable. Thanks for reading.

  8. Pingback: Nuclear Throne roguelike gets online co-op multiplayer mod

  9. Pingback: Introducing: Nuclear Throne Together v9877

  10. Hey everyone! im a little nervous modding my copy of throne, just wondering what kind of effect it will have on the game. will it disable achievements? will my daily scores still be put through? any sort of explanation would be welcome, thank you!

    • The mod uses a separate save file from the main game to avoid trouble (you can import your savefile via commands, however). Achievements cannot be earned in the mod (since the mod works differently enough from the game in some regards). Dailies/weeklies are disabled for the mod (since the seeding mechanism does not match up with “vanilla” game). The original executable gets backed up on install, and you can always run “vanilla” game via it or revert to vanilla by verifying game cache via Steam.

  11. Pingback: Nuclear Throne’ update 99

Leave a Reply

Your email address will not be published. Required fields are marked *