Saturday, September 12, 2020

Classic Doom Unity Ports and Linux

This seems to be turning into a Linux gaming blog, and there's probably no stopping it, so I might as well not even try.

So, hey, the classic Doom games on Steam got updated to include those official Unity engine ports. That's cool. I mean, I guess it's cool. I'll defer to the video by GmanLives on YouTube for what's actually cool about it:

Update: It seems GmanLives has made the above video private, for some reason. Uh, okay...? Whatever. You don't need to watch this video before reading anything that follows. It was just a general overview of the Unity ports of the classic Doom games, and apparently some people disagreed with the opinions therein, but I don't remember any part of it being so controversial as to warrant removal.

It was thanks to GmanLives that I even found out about the updates to my Steam copies of these games. I go back to Doom and Doom II somewhat frequently, and in fact I do play the copies I bought from Steam, but I don't typically launch them through Steam. Last time I installed them, I immediately copied the WAD files out of the Steam folders to use them with GZDoom and then uninstalled the Steam copies. Therefore I don't often look at these games in my Steam library, and therefore didn't see the big "MAJOR UPDATE" notices, which I now see have been there since September 3rd.

So I was a bit excited when I heard that the Unity ports had come to Steam a week prior, because I thought I might be able to play the No Rest for the Living expansion for Doom II, which had previously been available on Steam only via Doom 3: BFG Edition, which I'm not going to buy because I already have regular old Doom 3. However, once I launched the game, I saw that the Unity version of Doom II includes only Hell on Earth and Master Levels by default. I think you can get No Rest for the Living as an official add-on, but that seems to require a Bethesda account. Maybe I'll create one. Maybe I'll download the WAD from elsewhere. I would rather play any add-on WADs in GZDoom anyway.

The real disappointment — and I'm fully aware that I'm nitpicking here — is that the inclusion of the Unity versions technically breaks the out-of-the-box Proton compatibility of Steam's The Ultimate Doom and Doom II: Hell on Earth on Linux. That's not a tragedy, because they can still be made to run on Linux quite easily. However, it's not a good look for Proton, because both games were whitelisted by Valve for Proton 3.7-8, and that whitelisting is now incorrectly applied to the Unity ports because they were added as updates to the existing games instead of showing up in users' libraries as separate items. Steam for Linux will launch the Unity ports with Proton 3.7-8 by default, and it won't work. Valve whitelisted these games only on the basis of their DOSBox-powered versions running well with that version of Proton.

Of course, using Proton to run the classic Doom games in the Windows version of DOSBox is a bit of a joke. You'll have a better experience running them in a natively Linux-compatible source port like GZDoom. If you really want to run them in DOSBox, there's a native Linux version of that too (and you can make Steam use it for DOS games by installing the compatibility tool Boxtron), so there's no good reason to run the Windows version of DOSBox in Proton. Nonetheless, Valve whitelisted the games for Proton 3.7-8 based on the fact that their old DOSBox-powered versions, in spite of themselves, did work perfectly in Proton 3.7-8 (and, in theory, still should). The new Unity versions don't run with Proton 3.7-8, nor do they work with the current version, Proton 5.0-9. They do seem to work perfectly with Proton 5.9-GE-5-ST, a fork of Proton which is not included in Steam by default but which is easy to install. So if you want to play the Unity ports on Linux, it requires only minimal effort.

The real problem here is that someone is bound to see "Proton 3.7-8 selected by Valve testing" on the newly updated classic Doom games and understandably assume the default versions of the games will run with Proton 3.7-8 out of the box. Now that the default versions are the Unity ports, that's not the case. When you launch either The Ultimate Doom or Doom II: Hell on Earth in Steam now, you will be presented with the option to run either the Unity version (which is the default) or the DOS version, and the default Proton version selected by Valve itself is good only for the DOS version which is now relegated to a secondary or extra option.

The other problem is that, because the Unity versions don't show up as separate games in the Steam library, you can't select different compatibility tools for the DOS and Unity versions. These versions being combined is good in general for those who don't want cluttered libraries, but preliminary testing on my own machine suggests that the DOSBox-powered version of The Ultimate Doom doesn't want to run using Proton 5.9-GE-5-ST which is the only way I know how to run the Unity version. If this is true and it's not just me, alternating between the two versions would require changing the game's compatibility settings each time. I suppose most people, upon deciding which version of the game they prefer, would just stick with it. Still, this bugs me.

Even if there is a Proton version which runs both DOSBox and the Unity ports, I still maintain that using Proton is sub-optimal for the DOSBox-powered versions anyway, and one should really be using Luxtorpeda as an alternative to Proton. Luxtorpeda runs the Steam versions of the classic Doom games in GZDoom automatically, and I probably would have used Luxtorpeda if I hadn't already set up GZDoom manually before I knew Luxtorpeda existed. However, selecting Luxtorpeda as a compatibility tool for The Ultimate Doom would work only for the classic DOS version; it wouldn't be able to run the Unity port. You can't select a single compatibility tool which runs both versions optimally, and you can't select separate compatibility tools for different modes of running a single entry in the Steam library.

In short, I'm slightly annoyed. I'm still just going to keep using GZDoom to run the original WADs anyway, so I guess you could say I'm annoyed on behalf of anyone who hasn't already figured this out. But I guess it's reasonable to assume that anyone who can't figure it out probably lacks the patience for playing games on Linux in the first place.

Saturday, July 25, 2020

Pinstripe and Broken Achievements

I wanted to write this post at the end of December, but the winter holiday season is a busy time, so that didn't happen. Then, by the time the holidays were over, I was already back at work, and forgot about it. Later on, I had an idea about writing this as a follow-up to How to Cheat in Spec Ops: The Line, but that didn't happen either, mostly due to laziness. Now I have a moment and I can only hope that I remember accurately the details of what I had meant to document in December.

So anyway, there's this game called Pinstripe. I have a hefty collection of random indie stuff in my Steam library, mostly from Humble Bundle and from Fanatical (formerly Bundle Stars), so I probably wouldn't remember exactly where I got this one in particular if there weren't records of it. Cross-referencing my Steam account's history of product key activations with IsThereAnyDeal's list of bundles featuring the game, I see that I must have gotten it from the $1 tier of Humble Jumbo Bundle 12, in late November of 2018. My achievement history shows that this is around the time I first played the game as well, so it didn't languish in my backlog for an extended period of time as many indie games from bundles tend to do. Late November into early December was a nice time to play the game as well, given the snowy winter setting.

Overall, it's a cute game. In any mini-review of any kind of game, I feel morally obligated to judge the gameplay first and foremost; but, in this kind of indie game, it would probably be a lie to say that the game and its mechanics are much more than a vehicle for the developer's artistic expression, which could have been channeled into a short film instead if it could have survived becoming that much less engaging. I won't claim to know the developer's intentions but I suspect the goal was to tell a story in an interactive medium and not to get the player hooked on addictive gameplay. So I'll just say that the gameplay is all right; it gets the job done, and manages to be neither frustrating nor entirely boring. But if you don't care for the story or the music or the art direction, you won't care for the game itself.

What stands out to me in hindsight is the audio. The soundtrack is really nice. The voice acting is also pretty great by video game standards. By the end, the story is perhaps a bit clichéd — well, perhaps incredibly clichéd, if I'm being perfectly honest — but its presentation is not as unbearably pretentious as so many indie games are. In short, they did a good job. It's a nice game. I should feel bad for having paid so little for it.

After having played through the game once or twice, I had unlocked all but one achievement:


Beating Pinstripe in an hour is not a remarkable feat. It's a short game. So, I thought, I might as well try it. There's no visible in-game timer, so I took note of the clock on my computer when I started, and played through the game, already knowing where to go and the solutions to the puzzles. I finished in less than an hour. The achievement didn't unlock. I figured the problem was that I had essentially started a "New Game Plus" so I deleted my save and even reinstalled the game to ensure I was starting with a clean slate. I finished the game in less than an hour again. The achievement didn't unlock.

A trip to the game's discussion forum on the Steam Community site revealed that I wasn't the only one having trouble with unlocking the achievement. It was apparently bugged. I checked the forum again today and it's apparently still bugged. There are workarounds which have solved the problem for some players. At least one guy claimed to have done it just by reinstalling the game, but that hadn't worked for me. In mid-December of 2018, someone came up with another fix which seemingly solved the problem for a lot of other players.

This fix involved editing the Windows registry. Specifically, according to this Steam forum post, one must clear a TotalPlayTime entry from HKEY_CURRENT_USER\Software\Atmos Games, LLC\Pinstripe. Yes, the game apparently tracks total play time in the registry. That just boggles my mind. I don't understand it. Perhaps I just don't understand game development or Windows software development well enough to see why Atmos Games would do this, but it seems insane to me. In any case, for whatever reason, this workaround didn't work for me. I assume I must have done it incorrectly, because it had worked for others. However, having failed once with this attempted registry hack, I had already failed the speedrun achievement at least three times in total, and I was fed up. I uninstalled the game.

However, this was not before I had seen another post claiming to have a fix for the Linux version of the game. At the time, I wasn't using Linux on my personal computer yet, but I figured I might try it someday. Sure enough, I started using Linux the following year. Attempting again to get the last achievement in Pinstripe wasn't really my top priority as a new Linux user, but I was bound to come back to it eventually.

So at the end of 2019, I reinstalled Pinstripe on Linux Mint. Now there was no longer a Windows registry claiming I had played for hours, so if I had still remembered how to finish the game quickly, I probably could have just unlocked the achievement fair and square in one attempt. Unfortunately, I hadn't played the game in about a year. I would most likely have had to play through the game once to remember what to do, and then a second time for the speedrun achievement. I had already messed around with this game enough, and I had already beaten the game in under an hour multiple times as verified by my own clock, so I didn't feel like playing fair. If this Linux workaround documented on Steam could be used to unbreak the achievement, it could also be used to cheat. So I decided to remove any chance of failure, and cheat.

I mean, in my defense, it was barely cheating. The game had already cheated me.

I played through most of the game, and sure enough, as I neared the end, I was not on track to beat the game in under 60 minutes. So I closed the game and, following the advice found in the Steam forum, I opened up the file ~/.config/unity3d/Atmos\ Games\,\ LLC/Pinstripe/prefs. It's a plaintext file in some XML-like format with a handful of tags specifying various preferences such as screen resolution height and width. As promised, there's also a line of the form
<pref name="TotalPlayTime" type="float">xxx</pref>
where xxx is the elapsed play time in seconds. Note that, for the sake of verifying what units are used here (for it could have been milliseconds for all I remember of December 2019), I just reinstalled the game and played it for about a minute, and this line in my current copy of this file now reads as follows:
<pref name="TotalPlayTime" type="float">62.1948</pref>
At the time I first found this file, I suppose it must have read something closer to 3600, as I was approaching the one-hour mark with not enough time to spare. So I opened up the file in vim, decreased the value by a few hundred seconds, opened the game back up, and played to the end. The achievement finally unlocked.

Now I've got my 100% completion in Pinstripe. Was it worth it? Well, no and yes. The time I spent trying to unlock the achievement on Windows was a waste of time. However, I still liked the game and wanted to play through it again last December; I also wanted to test drive the Linux version; and, while I was doing that, I figured I might as well get the achievement I was owed. Editing a text file, by the way, was a lot easier than playing around with the Windows registry. Linux wins again, I guess.

There are people who pay absolutely no attention to achievements. For the sake of my mental health, perhaps I should try to be one of them. For the most part, I guess I am. I have far too many games to be caring about unlocking all of the achievements in all of them, considering how many games have achievements which are just arbitrarily time-consuming, seemingly for no reason other than to decrease the number of players willing and able to unlock them and thus to increase their perceived value among self-proclaimed achievement hunters.

If I've already unlocked over 90% of a game's achievements, though, it's hard not to go for 100%. If there's only one achievement left, it's almost impossible not to try, or to be annoyed by it forever if I know it's unattainable. I have other games which, like Pinstripe, have some broken achievements, but there are not always easy workarounds to unbreak them. Do achievements really matter? Not really. But they're a part of the game, and you shouldn't sell broken stuff.

Dear game developers,
Stop selling broken stuff.

Thursday, April 16, 2020

Decoding the Level Passwords in Pushover

Pushover is a puzzle game about an ant pushing over dominos. I played it when I was a kid, and more recently I got a Steam copy of it from a cheap bundle of old games. I didn't really start playing this Steam copy until this week, at which point I remembered that, like many games of the time, Pushover has no save system. Each time the player reaches a new level, the game provides a password which can be used to return to that point.

As I played the first few levels, I noticed something interesting. The first four level passwords were as follows:

Level   Password
01      00512
02      01536
03      01024
04      03072

Two of the passwords being powers of two immediately caught my attention. If we convert each password to binary (using sixteen bits just because bits usually come in groups of eight), we get this:

Level   Password   Binary
01      00512      0000001000000000
02      01536      0000011000000000
03      01024      0000010000000000
04      03072      0000110000000000

Following this pattern, I expected the password for level 05 to be 0000100000000000, or 02048, but using this password brought me to level 07 instead. Going back to level 04, I played up to level 08 and found that, while there was still clearly some kind of pattern, it was a bit more complicated than I had thought. Converting the first eight level passwords to binary, we have:

Level   Password   Binary
01      00512      0000001000000000
02      01536      0000011000000000
03      01024      0000010000000000
04      03072      0000110000000000
05      03584      0000111000000000
06      02560      0000101000000000
07      02048      0000100000000000
08      06144      0001100000000000

At this point, we can already start to see what's going on, if we look at the binary in columns. There seems to be a pattern emerging:

  • The 29 bit column (10th from the right) has 2 ones, 2 zeros, 2 ones, and 2 zeros; we might expect this to continue indefinitely.
  • The 210 bit column (11th from the right), after a single zero, has 4 ones in a row, followed by some zeros; we might expect this column to have a pattern of 4 ones, 4 zeros, and so on, albeit offset by a single zero at the beginning.

However, I didn't really see it until I had played through another eight levels. Converting the first sixteen level passwords to binary, we have:

Level   Password   Binary
01      00512      0000001000000000
02      01536      0000011000000000
03      01024      0000010000000000
04      03072      0000110000000000
05      03584      0000111000000000
06      02560      0000101000000000
07      02048      0000100000000000
08      06144      0001100000000000
09      06656      0001101000000000
10      07680      0001111000000000
11      07168      0001110000000000
12      05122      0001010000000010
13      05634      0001011000000010
14      04610      0001001000000010
15      04098      0001000000000010
16      12290      0011000000000010

Focusing only on the higher-order (leftmost) bits, we can now clearly see that:

  • The 29 bit, starting at level 01, has a pattern of 2 ones, 2 zeros, and so on.
  • The 210 bit, starting at level 02, seems to have a pattern of 4 ones, 4 zeros, and so on.
  • The 211 bit, starting at level 04, has 8 ones in a row, and has presumably started a pattern of 8 ones, 8 zeros, and so on.
  • The 212 bit, starting at level 08, is all ones all the way through level 16, and may have started a pattern of 16 ones, 16 zeros, and so on.
  • The 213 bit first becomes one at level 16.

But something is also happening in the 21 bit (second from the right), where a one suddenly appears starting at level 12. This doesn't seem related to the rest of the pattern, and I think I know why.

It was after completing level 11 that the little ant protagonist found... a bag of Quavers...? (Did I mention that Pushover was sponsored by a snack food company? I've never had Quavers; apparently they're British.) On the menu screen which appears between levels, I could see after completing level 11 that a little sprite representing a bag of Quavers had been added to the bottom of the screen where there appear to be nine spaces available. So it's probably safe to assume that nine virtual bags of Quavers are pointlessly awarded throughout the game.

The fact that the 21 bit changed after level 11 suggests that some of the lower-order bits are used for tracking the bags collected, independently of the higher-order bits which indicate the level number. As an experiment, I took the password for level 12 and flipped the 21 bit to zero, resulting in 0001010000000000 or 05120. Sure enough, entering the password 05120 took me to level 12, and upon completing the level, the inter-level menu screen did not show the bag that was there when I had beaten levels 11 through 15 before. Moreover, the password it gave me for level 13 this time was 05632, which is the previously obtained level 13 password with the 21 bit flipped to zero. However, taking the level 02 password and flipping the 21 bit to one did not result in a valid password. So I cannot cheat my way into already having a bag prior to level 12, but it seems I can enter levels 12 or later without one.

If some bits are only for tracking bags collected, and if any level can be entered without any bags, then we should be able to get a complete set of level passwords just by predicting the pattern of the bits indicating level number. The passwords of levels 01 through 16 suggested that only the higher-order bits (starting with 29) encoded the level number. So at this point, I predicted that the full pattern (if it continued indefinitely) would be as follows:

  • The 29 bit will start with one at level 01 and then change every 2 levels.
  • The 210 bit will become one at level 02 and then change every 4 levels.
  • The 211 bit will become one at level 04 and then change every 8 levels.
  • The 212 bit will become one at level 08 and then change every 16 levels.
  • The 213 bit will become one at level 16 and then change every 32 levels.
  • The 214 bit will become one at level 32 and then change every 64 levels.
  • The 215 bit will become one at level 64 and then change every 128 levels.

This algorithm does predicts the values of the seven highest-order bits for the first sixteen level passwords. Unfortunately, I realized later that it's not quite correct. While looking around in the game's files for goodies, I found that the Steam version of Pushover comes with a file called PUSHCODE.TXT — which, bizarrely, contains most but not all level passwords, and seems to have been written not by the developer or publisher but by someone from a demogroup known as Tristar & Red Sector Incorporated. The file begins:

                            TRISTAR & RED SECTOR
                                              
                                  PRESENTS

                            PUSHOVER (LEVELCODES)


LEVEL 1    00512
LEVEL 2    01536
LEVEL 3    01024
...

It continues all the way through level 67:

...
LEVEL 65   17023
LEVEL 66   18047
LEVEL 67   17535

NOTE: THERE ARE MISSING A FEW CODES!!!!

TIME BANDIT/TRSI

Pushover apparently has 100 levels, so I guess the player who wrote this file gave up about two-thirds of the way through the game. However, they got far enough to show me that the 215 bit does not get flipped to one at level 64. Any number with a one in the 215 place would be at least 32768, and none of the passwords in PUSHCODE.TXT are that high!

So I wrote a few lines of Python to convert all the passwords in PUSHCODE.TXT to binary. The results are as follows:

Level   Password   Binary
01      00512      0000001000000000
02      01536      0000011000000000
03      01024      0000010000000000
04      03072      0000110000000000
05      03584      0000111000000000
06      02560      0000101000000000
07      02048      0000100000000000
08      06144      0001100000000000
09      06656      0001101000000000
10      07680      0001111000000000
11      07168      0001110000000000
12      05122      0001010000000010
13      05634      0001011000000010
14      04610      0001001000000010
15      04098      0001000000000010
16      12290      0011000000000010
17      12802      0011001000000010
18      13826      0011011000000010
19      13314      0011010000000010
20      15362      0011110000000010
21      15878      0011111000000110
22      14854      0011101000000110
23      14342      0011100000000110
24      10246      0010100000000110
25      10758      0010101000000110
26      11782      0010111000000110
27      11270      0010110000000110
28      09222      0010010000000110
29      09734      0010011000000110
30      08718      0010001000001110
31      08206      0010000000001110
32      24590      0110000000001110
33      25102      0110001000001110
34      26126      0110011000001110
35      25614      0110010000001110
36      27662      0110110000001110
37      28174      0110111000001110
38      27150      0110101000001110
39      26638      0110100000001110
40      30734      0111100000001110
41      31246      0111101000001110
42      32270      0111111000001110
43      31758      0111110000001110
44      29726      0111010000011110
45      30238      0111011000011110
46      29214      0111001000011110
47      28702      0111000000011110
48      20510      0101000000011110
49      21022      0101001000011110
50      22046      0101011000011110
51      21534      0101010000011110
52      23582      0101110000011110
53      24094      0101111000011110
54      23070      0101101000011110
55      22558      0101100000011110
56      18494      0100100000111110
57      19006      0100101000111110
58      20030      0100111000111110
59      19518      0100110000111110
60      17470      0100010000111110
61      17982      0100011000111110
62      16958      0100001000111110
63      16510      0100000001111110
64      16511      0100000001111111
65      17023      0100001001111111
66      18047      0100011001111111
67      17535      0100010001111111

This is all consistent with my predictions about bits 29 through 214, but it's the 20 bit — not the 215 bit — which gets flipped to one at level 64. So we can revise the earlier prediction:

  • The 29 bit starts with one at level 01 and then changes every 2 levels.
  • The 210 bit becomes one at level 02 and then changes every 4 levels.
  • The 211 bit becomes one at level 04 and then changes every 8 levels.
  • The 212 bit becomes one at level 08 and then changes every 16 levels.
  • The 213 bit becomes one at level 16 and then changes every 32 levels.
  • The 214 bit becomes one at level 32 and then changes every 64 levels.
  • The 20 bit becomes one at level 64 and then changes every 128 levels.

This isn't quite as elegant as what I had initially predicted, because the "level bits" are no longer contiguous, but it appears to be correct. The last rule is already unlike the others anyway, in that we would never actually see the 20 bit change from one back to zero after 128 levels because there are only 100 levels in the game. I predicted that bit to flip at a frequency of once per 128 levels to continue the power-of-two pattern. So that last rule could just be written as:

  • The 20 bit is one at level 64 and up.

The passwords in PUSHCODE.TXT also give us a hint about how bags are tracked. It seems that each one has its own dedicated bit. If we enter the level 67 password above (17535 or 0100010001111111) and then quit back to the menu screen, we see that we have the first six bags. But if we flip a few bits to get 0100010001010101, and enter the corresponding decimal password 17493, quitting back to the menu shows that we have only the second, fourth, and sixth bags.

If there are nine bags, and if each bag has its own bit, then we need nine bits to represent them all. Meanwhile, if bits 20 and 29 through 214 and are used to determine the level, then the nine bits remaining to represent bags are 21 through 28 and 215.

From another source (the description on this YouTube video), I've found that level 100 is actually a bonus level, and that its password is 44543 (or, in binary, 1010110111111111). This is is still consistent with the above rules regarding bits 29, 210, 211, 212, 213, 214, and 20; additionally, bits 21, 22, 23, 24, 25, 26, 27, 28, and 215 are all flipped to one.

By starting with the level 100 password, individually setting the 21, 22, 23, 24, 25, 26, 27, 28, and 215 bits back to zero, entering the resulting passwords to start level 100, and then quitting to the menu to see which bags are shown, I've confirmed that each of these bits corresponds to a particular bag. Interestingly, setting 215 to zero in particular, resulting in the password 11775, has the effect of making level 100 easier by revealing the special domino types which are normally hidden on this bonus level. More importantly, though, I'm pretty sure we have now fully decoded the game's level passwords.

  • The 20 bit is one at level 64 and up.
  • The 21 bit is one after the first bag is collected (level ≥ 12).
  • The 22 bit is one after the second bag is collected (level ≥ 21).
  • The 23 bit is one after the third bag is collected (level ≥ 30).
  • The 24 bit is one after the fourth bag is collected (level ≥ 44).
  • The 25 bit is one after the fifth bag is collected (level ≥ 56).
  • The 26 bit is one after the sixth bag is collected (level ≥ 63).
  • The 27 bit is one after the seventh bag is collected (level ≥ 78).
  • The 28 bit is one after the eighth bag is collected (level ≥ 89).
  • The 29 bit starts with one at level 01 and then changes every 2 levels.
  • The 210 bit becomes one at level 02 and then changes every 4 levels.
  • The 211 bit becomes one at level 04 and then changes every 8 levels.
  • The 212 bit becomes one at level 08 and then changes every 16 levels.
  • The 213 bit becomes one at level 16 and then changes every 32 levels.
  • The 214 bit becomes one at level 32 and then changes every 64 levels.
  • The 215 bit is one after the ninth bag is collected (level = 100).

The above assumes that bags are awarded for completion of levels 11, 20, 29, 43, 55, 62, 77, and 88, based on the binary representations of the first 67 passwords passwords found in PUSHCODE.TXT and of the remaining passwords found on this page. I don't feel inclined to play through the entire game to confirm it myself before publishing this post. Given that we can enter any level just by setting the "level bits" (29, 210, 211, 212, 213, 214, and 20) — without turning on any of the "bag bits" — there's actually more than enough information here to allow me to amuse myself by writing a little Python script that gives me a valid password for any level I want to play:

import sys


def get_level_bit(frequency, level):
    offset = frequency // 2
    return (level + offset) // frequency % 2


def generate_password(level):
    bits = 0
    for index in reversed(range(16)):
        bits = bits << 1
        if 9 <= index <= 14:
            bits += get_level_bit(2 ** (index - 8), level)
        if index == 0:
            bits += get_level_bit(128, level)
    return bits


if __name__ == "__main__":
    print(generate_password(int(sys.argv[1])))

Is this really useful when I could just look up the passwords on the internet? Not really. But reverse engineering the game's passwords was more fun.

Thursday, February 6, 2020

How to Cheat in Spec Ops: The Line

Why Cheat?: A Quick Review of My Experience with a Not-Completely-Awful Game


I don't usually play military first-person shooters, let alone cover-based shooters like Spec Ops: The Line. But I got it for $1.00 (along with Duke Nukem Forever and The Darkness II) from Humble 2K Bundle 2, and... it wasn't that bad, at least on the default difficulty setting. I suppose it's precisely because I don't usually play this type of game that I didn't just see Spec Ops: The Line's cover-based shooting mechanics as an inferior version of what you would find in, say, a Gears of War game. For me, it was something different, and I enjoyed it, even though it was occasionally frustrating. Having gotten to the end of my first play-through, I could see myself playing it more, and none of the achievements seemed particularly hard to unlock, so I decided to play through the game a couple more times to go for 100% completion.

It was only at the point where I had unlocked all but one of the game's achievements — the one for beating the game on the hardest difficulty setting, FUBAR — that I realized how anti-fun the game could be. So I dropped it for a while. But after a few years of seeing 49/50 on the game's achievement tracker, it began to bother me.

The thing about me and achievements is that, while I'll make some effort to unlock them if they actually happen to be fun to unlock, I don't really care a whole lot about them otherwise... except in that they annoy me when they serve as a reminder of what's almost finished. In other words, while I don't normally treat a game with achievements as a tedious "to-do" list, 98% complete is just irritating.

So eventually, I did go back to the game and try to beat FUBAR mode, thinking it just couldn't be as bad as I remembered. But it was worse than I remembered. It was an enjoyable challenge for a while, and I actually got all the way to chapter 11 out of 15, but after a certain point, I couldn't play for more than 30 minutes at a time without getting annoyed. I wasn't enjoying it anymore, and while there were occasional moments of satisfaction in which I was able to pass a checkpoint by figuring out some optimal strategy and executing it perfectly, these moments were outnumbered by all the times when having gotten through a tough fight seemed like blind luck. The game's FUBAR difficulty setting isn't just unreasonable at times; it's also where the inherent flaws in the game's design really shine.

When one isn't having fun with a game anymore, does it make sense to keep playing just for an achievement? Not really. Not when nobody else is ever going to see or care about that achievement. When a game isn't fun anymore, the rational choice is either to drop it or to make it fun. I had begun to wonder if there was a way to cheat my way through the last bit of the game, as venting my frustration by breaking the game in some amusing way might make up for what felt like a waste of time so far. Turning that 49/50 into a 50/50 (so that even my undiagnosed OCD could accept that I'm done with the game) without having to subject myself to any more of this sadistic FUBAR nonsense would be nice too.

That's when I realized that the game's configuration files, which are encrypted in the Windows version on which I did the first half of my FUBAR play-through, are human-readable plaintext in the Linux version on which I continued the game after the termination of Windows 7 support gave me the final push towards using Linux for almost everything.

How To Cheat, The Easy Way: Step One Is To Install Linux (Which You Should Do Anyway Unless You Really Love Windows 10)


Install the Linux version of the game using the Linux version of the Steam client, and go to
~/.steam/steam/steamapps/common/SpecOps_TheLine/SRGame/Config
and you'll find a bunch of .ini files — 94 of them, by my count — and a single .txt file. I haven't fully explored the contents of these configuration files, because some of them are rather large, and there are too many of them to summarize here even if I had looked at them all. However, a quick browse through a few of them suggests that they contain variables for almost all the numerical and Boolean values one might want to alter, such as: player health, health regeneration rate, enemy health, the amount of damage required to explode enemies' heads, weapon damage, amount of ammo each weapon gets from ammo boxes, et cetera.

Some files have multiple variations. For example, the files
SRPawnEasy.ini
SRPawnEasy_Coop.ini
SRPawn.ini
SRPawn_Coop.ini
SRPawnHard.ini
SRPawnHard_Coop.ini
SRPawnInsane.ini
SRPawnInsane_Coop.ini
all contain values like character health. The ones with the "Coop" suffix obviously apply to the game's cooperative multiplayer mode, while the files marked "Easy", "Hard", and "Insane" presumably apply to the the game's "Walk on the Beach", "Suicide Mission", and "FUBAR" difficulty modes, respectively. I assume the "Combat Op" difficulty (which lies between "Walk on the Beach" and "Suicide Mission") is considered the default setting, so it probably just uses the values from SRPawn.ini (or SRPawn_Coop.ini for cooperative mode). Furthermore, I assume other difficulty modes will also fall back on SRPawn.ini for values which don't appear in their specific files, as SRPawn.ini has many more lines than the other variations.

I'm making some educated guesses here, because I haven't actually tried editing each of these files individually to confirm that the effects are what we might reasonably expect based on their names and contents. However, I did try editing the file SRPawnInsane.ini with the intent of modifying FUBAR mode. I started by modifying the health values of the player character, Walker, and his two squad mates, Lugo and Adams. This is just a matter of finding the right m_defaultHealth values. There are several m_defaultHealth lines, each appearing in a separate section indicating which character's default health level is being modified. Here's a snippet of SRPawnInsane.ini:
[SRGame.YPawn_Walker]
m_defaultHealth=60.0

[SRGame.YGamePawn_Player]
m_damageModifierExecuting=0.3
m_damageModifierReviving=0.3

[SRGame.YPawn_Lugo]
m_defaultHealth=220.0

[SRGame.YPawn_Adams]
m_defaultHealth=220.0

[SRGame.YPawn_AdamsAlone]

[SRGame.YPawn_Enemy]
m_defaultHealth=155.0
m_chanceToGrantGrenadeToExecutor=0.2
m_vaporizeModifier=3.56
m_headExplodeModifier=1.52
When I found this, I vastly increased the m_defaultHealth values found under [SRGame.YPawn_Walker], [SRGame.YPawn_Lugo], and [SRGame.YPawn_Adams]. I was unsure if it would actually work, but when I started up the game and continued my FUBAR mode campaign, it was clear that the player character and his squad mates were all practically invincible. It seemed too easy but it actually worked.

There are a few other things to note in the snippet above:
  • The [SRGame.YGamePawn_Player] section has a couple of damage modifier values; based on the names, I assume these will alter the amount of damage which the player will take while performing execution moves on enemies and reviving squad mates. However, I haven't tried changing these yet, so I don't know whether they are positive or negative modifiers. Does setting them to 0.0 mean the player takes full damage or that the player takes no damage? Presumably it's one or the other. Either way, setting them to 1.0 probably does the opposite of whatever setting them to 0.0 does, because the fact that each value is currently set to 0.3 suggests that these are fractions of the normal amount of damage.
  • The [SRGame.YPawn_AdamsAlone] section in SRPawnInsane.ini is, in fact, empty. However, it's not empty in SRPawn.ini or SRPawnEasy.ini. In each of those files, this section contains another m_defaultHealth line, so it's safe to assume that we can add one here as well, if we want to. When placed in this section, m_defaultHealth probably modifies the amount of health that Adams has during a sequence in which he is separated from the player.
  • The [SRGame.YPawn_Enemy] section contains some very specific modifiers; you can probably guess what they do based on the names. The file SRPawn.ini has even more values, any of which could most likely be modified here in SRPawnInsane.ini as well. The section name might be a bit misleading, though, as it seems to pertain only to one type of enemy. There are other sections called [SRGame.YPawn_MediumEnemy], [SRGame.YPawn_EnemyMarauder], [SRGame.YPawn_EnemyElite], and so on.
I'm just trying to give you an idea of what can be done with these configuration files. As noted above, some of the .ini files are rather large, so I'm probably just scratching the surface of what can be modified here. I haven't tried making substantial modifications myself — but it looks like you could, in theory, fine-tune many aspects of the game to be exactly how you want them. If you don't like the fact that the player can take damage while reviving squad mates, change it. If you don't like the amount of health that a particular enemy has, change it. If you want enemies' heads to explode with every headshot from any weapon, you can probably make it happen. Whether anyone cares enough about this game to do any of this, however, is another matter entirely.

I only went as far as modifying the health of Walker, Lugo, and Adams — adding a few zeroes to each number, before the decimal of course — and the rest of the FUBAR campaign was a hilarious joke. I got to the end in a tiny fraction of the time it would have taken if I had played the game fairly, and it's probably the only way I would have been willing to get to the end, as my patience had run out. And, for the record, this did unlock the achievement for finishing the game on FUBAR difficulty. Modifying these configuration files does not disable achievements.

Therefore, those of you who actually take achievements seriously as an indicator of your skill level, or something, might want to avoid playing with these configuration files while doing anything which might unlock an achievement. Personally, as noted above, I don't really care — but I can understand how others might regret unlocking a tough achievement by cheating. If you're the kind of person who takes pride in achievements, unlocking one by modifying the game might leave a bad taste in your mouth.

The Case For More Games Being This Easy To Exploit


The encrypted configuration files used by the Windows version of the game actually can be decrypted, but I can't personally vouch for the tool used to do so. I didn't bother with it when I played the Windows version of the game, because I didn't want to cheat at this game badly enough to put up with the extra steps, let alone the mysterious executable. (I trust it a bit more now that I've found it on PC Gaming Wiki, but when I first became aware of the decryption tool, it was through a link on some random forum.)

The fact that the files are not encrypted in the Linux version of the game is probably an oversight — or maybe they just didn't care, or maybe they figured Linux users would find out how to break into the files anyway, or maybe they already knew about the decryption tool for the Windows version by the time they made the Linux version so they decided decryption was pointless. In any case, the fact that the files are encrypted in the Windows version is a clear indication that players were not meant to mess with these files.

But why not?

Cheating in multiplayer games is not okay, because it spoils the experience for other players, hence the existence of anti-cheat measures in multiplayer games. When it comes to single-player games, though, I don't see why we shouldn't be able to do whatever we want with a game that we bought. Many single-player games are made to be (or just are) easily modifiable; Skyrim, for example, is famous for community-made mods. Other single-player games, however, are made to be (or just are) very difficult to modify, as the Windows version of Spec Ops: The Line would be if nobody had figured out how to decrypt its files.

It's almost a shame that a game like Spec Ops: The Line, which is considered by many to be thoroughly mediocre, happens to be one of the games in which so much of the configuration is exposed to players through plaintext or easily decrypted files. A lot of games expose graphical settings not found in-game via configuration files, but in my experience, the ability to change the gameplay this way is rare. I wish I could so easily make similar modifications to games like Alan Wake, not because they're hard and I need to cheat, but because it would be fun. I'd actually like to make Alan Wake harder. Unfortunately, it's not an easily modifiable game.

Achievements are a possible reason that a game's developers might not want players to have unmitigated access to configuration values like player health. Some people take achievements seriously, especially rare achievements which are difficult to unlock; the perceived value of such an achievement, for players able to unlock it through skill and perseverance, is lessened when someone like me unapologetically cheats to unlock it by modifying configuration values.

But just as developers can program a game to disable achievements when built-in cheat codes are activated, they could also program a game to disable achievements when some deliberately exposed configuration file differs from the intended defaults, as verified by a checksum or whatever. I guess I'm advocating for games to offer the same level of easy modification as Spec Ops: The Line, if not more, but on purpose instead of by accident.

Some developers release powerful tools for modding their games, which is great. Changing a configuration file is also great, though, especially for players who aren't going to bother learning how to use whatever modding tools exist. My philosophy as a software developer is that hard-coding arbitrary numbers is bad and everything which reasonably could be configurable should be configurable, and maybe that's far easier said than done when it comes to games — I'm a software developer, not a game developer — but I have a feeling that most games hide configuration from players on purpose, and doing this just to prevent a human from cheating against a computer is silly. The ability to cheat is not going to ruin a game for anyone with any self-control.

I'm also a big fan of games having plaintext save files, for similar reasons. I've played a few, and although I've rarely bothered to skip ahead or otherwise cheat by editing their save files, knowing that I had the option was nice. Save editing is probably hard to detect, so I don't expect it from games whose developers want achievements to mean something — but as with all forms of unintended cheating, my selfish take on the subject is that I should be able to cheat to unlock achievements, and also, deal with it.

Sorry for making the global achievement statistics for Spec Ops: The Line slightly less accurate though, I guess.