The game bug that almost got away with it

The game bug that almost got away with it

In the Monday Musings I try to talk about the stuff that’s happening in the world of Game Development, from interesting game releases, to interesting technology, and game business happenings.

Bugs in games are never wanted, but they are also very hard to completely annihilate! This last week I actually ran into a tough bug to hunt down and I eventually found it, but it kept lingering in my head for a bit and spawned todays Monday Musings article. All about bugs!

Case of the Dicey Dice

So let me first explain the bug, because it’s a fun one. I originally created Heroes of Loot 2 somewhere in 2016 and released it on PC, Android and iOS. Pushed updates to fix issues and patch things up here and there, and moved on to the next game as I always do.

Every now and then, like once a year maybe, someone would mail me that they ran into a crash in the game at the shop. Most of them would describe the two items available in the shop but not everyone has the same good memory, so it was a pretty random mix of items and things and nothing really common stood out.

Fixing a bug in a game that’s slowly aging can be difficult, some bugs are easy to figure out and work out, but over time it becomes not just increasingly harder to figure out which piece of the code causes it, but also do you dare to even change that code? and possibly make other things crash? There might have been a very good reason certain things were coded the way they were coded.. can we just change numbers of lines of code?

Procedural is not Random

Now the difficulty increases in a lot of my games due to the procedural nature of things. Levels are never the same, but generated by code and a long list of rules about what can and can not be generated based on other parts of the level that have already been generated.

Procedural, however, does not mean random! There is, or at least, should always be a clear control and ruleset and explanation behind why certain things are being generated. Of course.. Heroes of Loot 2 was one of my early attempts at doing such a game, and let’s just say that I would have done a MUCH better job at it these days than what I did back then!

In any case, the procedural generation made it hard to track down the bug. People would tell me the bug often happened around level 8-12 ish (every level is different at any given time)  or when they had a certain quest (procedurally calculated based on the players progress and loot and dungeon) or ran into certain creatures, etc.

And in this case, none of those things were useful to tracking a bug in a game like this!

The Atari Gamer

Heroes of Loot 2 got a release on Switch last year (or the year before that.. time is going fast these days!) and it also got a release on the Atari VCS last April. That’s when things started to become frustrating!

For some reason, no idea what reason, but the Atari gamers were running into this bug a lot more than players on all other platforms. Or at least that’s what I believe right now. It’s also very possible that most PC or mobile gamers just didn’t tell me? But it’s rare for gamers to not vent their annoyances.. so I kinda doubt that.

It did become very frustrating to me: not because of all the people saying the game had a bug, but more that I want to deliver fun experiences and it’s annoying if people are trying your game and REALLY want to dive into it, but they keep running into a bug!  So I actually couldn’t get myself to release another game on the Atari because of this problem in the last game I just dropped there.

The fun thing here is, from all devices that the game is now available on, the Atari VCS has the least options to debug or find crash reports or other issues in a game! That’s especially a big problem if the game is so very procedural that I never got that crash on my Atari, but many players ran into it and couldn’t send me a crash report or anything from that point in the game.

Now, no bad feelings towards Atari here, they did an amazing thing releasing the device, and I’m a fan of it! They are a tiny company, not remotely comparable to the likes of Nintendo, Microsoft or Sony/Playstation.  Also! having contact with them, they are working on adding crashlogs to the next update of the OS! So that’s pretty sweet (and none of the other console companies would even listen to me about such things)!

Hunting the bug

So I eventually set out to seriously hunt for the bug, I even made a video about it which will go live on the youtube channel on Thursday, so make sure to check that one out!

With the help and feedback from the Atari players we figured out it was something to do with buying the Dice at the shop. As a test we had already done some code that would spawn infinite amount of dice, you could buy them, and none of those spawns would ever crash the game!  We were struggling to figure this one out!

We needed to run into the crash in a more natural way. But to increase the difficulty of this, a shop doesn’t show up in all dungeons! Here we got with the procedural generation again, and IF it shows up, it is offering you two items.. and it’s of course very unlikely that either of those items is a Dice ! So I ran into a few shops here and there, without dice, I eventually ran into a shop with a Dice, and the game didn’t crash! .. back to square one, or level one.

The bug explained

Finally, after setting out a whole day just for play-testing, and again, watch Thursday’s video for my excitement on this one, I ran into a shop, it had a dice, and when I tried to buy it.. it CRASHED THE GAME!  I had my PC connected to the Atari VCS, so I saw a nice console dump of the cause of it, and we could finally figure out why or what was crashing!

The reason why all our earlier testing (with unlimited dice spawns for example) never crashed the game was now very obvious:

You have 2 characters that you can swap between, each character can carry 2 items in his/her backpack.
If you want to buy a new item at the shop, and your character has a full backpack, the game will ask the question “Swap your backpack item?” and in that piece of code it specifies the new item’s information and if it should be mounted to the back of the character (like a key, or sword) or the front (like a shield).

Every item in the game has a value of “1” (front) or “2” (Back) defining where the item needs a spot in the characters inventory.

However! The Dice.. does not get mounted at the front or the back.. the dice changes into a random consumable that doesn’t mount into your backpack at all! So once the game starts to ask “Swap your backpack item?” it has to decide based on the item specified if it should swap the Front(1) item or the Back(2) item, but all the Dice gives is a -1 !

So the only reason this game would crash on a Dice is if you had: both inventory slots of your character filled up, which doesn’t happen as often as you think, because it’s only for special Quest items. Most of the time you’re using those quest items in the same level/dungeon as you found them. So let’s say you picked up the golden idol that needs to be placed in the statue a few rooms down to open the gate, you’re only carrying that idol for a short while, with a small chance of running into a shop (IF that level even has a shop) and an even smaller chance of that shop having a dice that you want to purchase!

Fixed it!

Once we knew what was going on, we had a fix within minutes (side note: my first fix actually broke the game in another way, but that’s also fixed!) and I even pushed that fix to PC and mobile versions, because there is literally no reason why that crash bug would only happen on the Atari VCS.

I think, for whatever reason, that the Atari players just kept their inventory items around more? or maybe for weird reasons got more dice spawns in shops? That’s the only unknown thing I have right now: why did the bug happen and show up so much on the Atari and not so much on other devices. Or did it, and did those gamers just complain less?

We might never find out !  But if you haven’t played Heroes of Loot 2 yet, you better give it a go now, as the 3rd part is on the way!

 


Come live chat with the developer and other gamers, get exclusive information on new games, features, discounts and BETA access, join the Discord: https://discord.gg/orangepixel