(Last updated: July 10, 2018)
Borderlands 2 + TPS UCP Logos

This is a page which details some deprecated information about how to go about enabling modding on Linux for Borderlands 2 and Borderlands: The Pre-Sequel. This information is still technically valid, but the recommended methods for accomplishing all of this is catalogued out on the main page.

The Short Version

This page is pretty wordy and probably doesn't need to be. Here's a barebones version of what you'll want to do. The overly-verbose stuff will follow, if you want more details!

  1. Edit your ~/.local/share/aspyr-media/<game>/willowgame/config/willowinput.ini to include a keybinding like ConsoleKey=Tilde
  2. Patch the game's steamassets/willowgame/cookedpcconsole/engine.upk in one of two ways:

    1. Download a pre-patched engine.upk:

    2. Hex-edit the engine.upk yourself:

      1. Decompress the game's steamassets/willowgame/cookedpcconsole/engine.upk using Unreal Package Decompressor (using Wine)
      2. Hex-edit the decompressed file, replacing these hex strings (there will be two instances in the file which need replacing):
        • Borderlands 2: 1B E9 471B A5 14
        • Pre-Sequel: 1B 0A 491B A2 14
  3. Replace engine.upk with your patched version
  4. Rename/move engine.upk.uncompressed_size out of the way
  5. Place the UCP patch inside the game's steamassets/binaries directory, with an all-lowercase filename
  6. Load the patch every time you start the game, using the following technique:
    1. Start the game, click any key to get to the main menu
    2. At the main menu, hit escape and say Yes to get back to the loading screen.
    3. Bring down the console, run: exec patch.txt (Or whatever filename you used)
  7. Optional: If you want full mod/patch compatibility, you will then need to ensure that the game's steamassets/dlc directory natively sorts itself in alphabetical order, which would almost certainly require setting up a custom mountpoint just for DLC data. See the main page for details. Note that the vast majority of mods/patches are unlikely to require this, though some UCP statements will fail without.
  8. Optional: Disable "sanity checks" by hex-editing the main game binary. See c0dycode's BL Mac/Linux github project for information and a little Python script to automate that.

As promised, the much wordier version follows:

Step 1: Configure a Console Hotkey

This is the easiest of the steps. Simply open up your willowinput.ini file, which will be found here:

~/.local/share/aspyr-media/borderlands 2/willowgame/config/willowinput.ini
~/.local/share/aspyr-media/borderlands the pre-sequel/willowgame/config/willowinput.ini

Then locate the [Engine.Console] section and set the following line:

ConsoleKey=Tilde

You could also use F6 or some other key, though for console access in FPSes, using the tilde/backtick key is customary.

At this point, you'll be able to bring up the console, but the actually-useful console commands won't be active: the game will pretend you wanted to "say" that command in the ingame chat and just send it out there, rather than actually running anything. So the next step is to get rid of that behavior.

Step 2 (option A): Enable the Fully-Featured Console (by Downloading a Pre-Patched File)

In online directions for Windows users, you'll see instructions to use a hex editor on Borderlands2.exe or the like, but the hex strings they specify don't actually exist in the Linux binaries for the game (which isn't really surprising).

Instead, you've got to patch the file engine.upk, which will be found in this location:

SteamApps/common/Borderlands 2/steamassets/willowgame/cookedpcconsole/engine.upk
SteamApps/common/BorderlandsPreSequel/steamassets/willowgame/cookedpcconsole/engine.upk

The quickest way to accomplish this will be to simply download a pre-patched file online, assuming you trust these sources. As of February 2018, I can confirm that both of these are valid and patch the file properly.

Step 2 (option B): Enable the Fully-Featured Console (by Hex-Editing Yourself)

Alternatively, it's not difficult to hex-edit that engine.upk file yourself:

The game's packaged engine.upk is compressed, and you have to hex-edit the uncompressed version of the file. At the moment, I only know of one way to do this: using the "Unreal Package Decompressor" found at http://www.gildor.org/downloads. That's a Windows program which must be run via Wine, but it works quite well.

So, download decompress.zip, unzip it to get decompress.exe, and then run it against engine.upk like so:

$ wine decompress.exe engine.upk

That will create a new directory named unpacked, and inside that directory will be the uncompressed engine.upk.

Now edit the uncompressed engine.upk inside a hex editor. I personally just use the bare-bones console hex editor named hexedit, which I assume is available on most distros. The value you want to change depends on whether you're editing the file for Borderlands 2 or The Pre-Sequel, though in either case there are two locations in the file where you need to change it:

  Change From   Change To
Borderlands 2: 1B E9 47 1B A5 14
The Pre-Sequel: 1B 0A 49 1B A2 14

Again, remember that there will be two locations in the file which require that change.

Now that you have a patched engine.upk, rename/move the original engine.upk out of the way, replace it with your edited engine.upk. Also rename/move the accompanying file, engine.upk.uncompressed_size (see Step 2.5, below).

Note: One of the Reddit posts I linked to also talks about hex-editing willowgame.upk. This is not actually necessary for the UCP, or for other mods found online. The edits to willowgame.upk just enable some special development commands like changing levels, setting player level/money, etc.

At this point, you should be able to launch BL2/TPS and find out if the patching worked. Pull down the console and type some nonsense like "foo". Without the patching, the game will just put "foo" into the ingame chat. If the patching was successful, you'll get a notice in the console saying "Command not recognized: foo".

Step 2.5: Move/Rename "engine.upk.uncompressed_size"

Once you have the updated engine.upk file in place, be sure to rename or move the file engine.upk.uncompressed_size so that it doesn't exist with that name anymore. Otherwise, Borderlands will think that your engine.upk is still compressed, and have problems starting.

Step 3: Install and run the patch!

Okay, we're through the tricky bits! All you've got to do at this point is put the patch file (using an all-lowercase filename) inside the game's binaries directory, which will be at:

SteamApps/common/Borderlands 2/steamassets/binaries
SteamApps/common/BorderlandsPreSequel/steamassets/binaries

Then, from the game's console, on the main loading screen, you can send it the following command, substituting the filename for whatever you used:

exec patch.txt

If it worked, there should be a brief pause while the game executes all the commands saved in the patch file. If you get about four errors on the console about "No objects found using command (foo)", you're running up against a crossplatform issue which is annoying to fix -- check Step 5, below, for ways around that. Note that the majority of the patch will continue to work just fine even with those errors, so you'll generally be all right without fixing it.

There are two gotchas which you'll want to keep in mind:

  1. The Linux version of B2/TPS requires that the filename be in all-lowercase. When you use the console to specify the filename, it'll silently convert what you typed into lowercase when trying to load, even if you type it in uppercase. (This will result in a confusing error message, since the error message will retain your uppercase characters.)
  2. The patches will only actually work if you load them from the main "loading" screen, which just has the big ol' Borderlands logo on it with "Press any Key" at the bottom, not from the main menu. You'll also want to only load the patch after the game has discovered all your DLC, so the whole loading procedure should be:

    1. Start the game, click any key to get to the main menu
    2. At the main menu, hit escape and say Yes to get back to the loading screen.
    3. Then load the patch.
    If you load the patch file from the main menu, there'll be no indication that anything failed, but the patch won't actually have taken effect. (The easiest way to verify is to observe that Eridium/Moonstone doesn't automatically get picked up like money.)

Note that you'll have to run the "exec patch.txt" command once every time you launch B2/TPS. I think I saw something about a technique to have it auto-execute, but I didn't look into it and don't currently care enough to dig around more.

Conclusion

So, that's it! Not a trivial amount of work to get going, really, though in the end it's pretty straightforward. The main hurdle that I had was that all the information to get this going on Linux was spread out over a number of different places online, and it took awhile to aggregate all the info and figure out what needed doing.

Sources

Changelog

July 10, 2018
  • Moved this info from the main page to the legacy page