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!
- Edit your ~/.local/share/aspyr-media/<game>/willowgame/config/willowinput.ini to include a keybinding like ConsoleKey=Tilde
- Patch the game's steamassets/willowgame/cookedpcconsole/engine.upk in one of two ways:
- Download a pre-patched engine.upk:
- Hex-edit the engine.upk yourself:
- Decompress the game's steamassets/willowgame/cookedpcconsole/engine.upk using Unreal Package Decompressor (using Wine)
- Hex-edit the decompressed file, replacing these hex strings (there will be two instances in the file which need replacing):
- Borderlands 2: 1B E9 47 → 1B A5 14
- Pre-Sequel: 1B 0A 49 → 1B A2 14
- Replace engine.upk with your patched version
- Rename/move engine.upk.uncompressed_size out of the way
- Place the UCP patch inside the game's steamassets/binaries directory, with an all-lowercase filename
- Load the patch every time you start the game, using the following technique:
- Start the game, click any key to get to the main menu
- At the main menu, hit escape and say Yes to get back to the loading screen.
- Bring down the console, run: exec patch.txt (Or whatever filename you used)
- 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.
- 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.iniThen locate the [Engine.Console] section and set the following line:
ConsoleKey=TildeYou 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.upkThe 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.
- Borderlands 2: https://github.com/bugworm/BorderlandsPatcher/blob/master/engine.upk
sha256sum: 2b781b3abfa3caf91adf7d30bac4b5de27c8323e84099d8dfd86f48a56a8f110- The Pre-Sequel: https://github.com/c0dycode/BLTPSModStuff/blob/master/TPS%20Set%20and%20Say-Patched%20UPKs.zip
sha256sum: 4153dd1f15ffc41ff1a1f86cbe5d21c491cc4a9738109acc3894753a5b54fafa
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.upkThat 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/binariesThen, 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.txtIf 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:
- 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.)
- 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:
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.)
- Start the game, click any key to get to the main menu
- At the main menu, hit escape and say Yes to get back to the loading screen.
- Then load the patch.
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
- The overall method for enabling these patches on Linux comes from this Reddit post: https://www.reddit.com/r/Borderlands/comments/5y35js/community_patch_for_linuxand_probably_mac/
- The details about the hex-editing required comes from this Reddit post: https://www.reddit.com/r/Borderlands2/comments/42vs9v/developer_console_commands/
- The particular information about what bytes to look for while hex-editing the Pre-Sequel data file I've so far only found in one place - the video description of this YouTube video: https://www.youtube.com/watch?v=pPm8OMK3WaE
- A rather amusing and relatable account of trying to find those Pre-Sequel hex values can be found in this blog post by Anna Harren. I'm thankful that those chronicled efforts saved me the trouble of going through the same routine myself!
- A trick to allow the "FilterTool" application to run on Linux was found in this bug report from the BLCM project. It turns out to be the same as the instructions for running FilterTool on Macs.
- c0dycode discovered the sanity check bypasses for Linux (well, and all the other platforms as well).
Changelog
- Moved this info from the main page to the legacy page