Last week I managed to complete the saving and loading stuff. I also figured out how to use zlib compression, so map files are only about 10 kB in size (compared to more than 1 MB uncompressed) and save files just over a kilobyte. Right now, the entirety of Hostile Takeover is under 20 MB in size, in case you’re wondering. But that will of course grow as more maps and assets get added.
After the saving and loading stuff, I was planning on doing the last big optimization, but plans are made to be broken, so I instead added a ‘current objective’ button (that also provides tutorial hints), as well as a ‘mission restart’ button (won’t yet be fully implemented in the first pre-alpha release) and a timer.
Currently, there’s only one use for the timer: If your stealth level drops all the way down to zero, you’ll have a few minutes to complete your assassination and escape the map or you’ll fail the mission. In the finished game, I’d like for the mission to not just fail automatically when the timer runs out, but instead have extra police/security guards drive onto the map and surround the building. So you’ll still have a chance of completing your mission – getting out alive will just be very hard.
I’m now diving into that optimization thing. For real this time!
Last week was off to a crazy start when I suddenly found Hostile Takeover adorning the front page of Rock, Paper, Shotgun. As you can probably imagine, this brought in a whole bunch of traffic, so a quick welcome to the game’s many new followers is in order! It was also quite the motivational boost – not that my motivation to work on the game really needed boosting, though, but it’s always nice when people seem excited about the thing you’re working on.
Anyway, I’ve mostly been working on saving and loading during the past week. Until now, everything would just be saved in the map file itself (and some stuff, like your inventory, wouldn’t be saved at all) whenever I quit the game. This was fine for developing and testing maps and such, but of course wouldn’t at all be suitable for the actual game. So I’ve had to decide which information should go in the map file and which should be saved in the savegame file. It’s basically boiled down to all static information (such as tiles, walls and most world objects) being in the map file, and everything else being in the savegame file.
This means, however, that the map files are 1+ MB in size, while the savegame files are only 10+ kB. The latter is fine, the former really isn’t. So I’m reading up on the Free Pascal zlib unit to be able to compress the map files with libz – with WinZip, a 1+ MB map file gets shrunk to about the same size as a savegame file. I’m not sure if libz can get the same results, but the more important side effect of compressing the map and savegame files is that they won’t just be plain text that’ll be easy to mess up or screw around with.
I also changed the load/save menu ever so slightly. When you save a game, it’s now optional if you want to type in a savegame description. If you don’t, it’ll just state the location you’re at in the game as well as the real-word time at which the savegame was created.
When I’m done with the save/load stuff, I’ll probably be moving on to an important optimization that I’ve been putting off for some time now. It has to do with how the x-ray effect is created. But I’ll save that for a later post. And after that, it’ll probably be all about AI and level building.
This past week I successfully expanded the line-of-sight code to support covers. Objects in the game now have height, meaning that you can hide behind high enough objects – but so can NPCs, so your line-of-sight to a target can be partially obscured when aiming.
It’s of course a lot easier to hide behind cover if you can crouch, so that’s now in as well. Kind of. I haven’t made the animations and sprites for the crouching player character yet, so it’s just a stand-in sprite for now. Look at that creepy naked guy hiding behind a wall (he actually kinda looks like a Terminator that’s just arrived from the future!):
I won’t be making the proper sprites for crouching until after the pre-alpha v0.1 release, meaning that this is also what your crouching guy will look like when you actually get to try it out. Hopefully suddenly being in your underwear won’t be all too immersive breaking…
The reason for this is that the crouching animation is a special animation that only the player character will do. The randomly generated NPCs won’t have this animation. For these kind of special player animations (as well as NPCs with unique looks), I’ll be using a spriting system that’s a bit different from the one used for the randomly generated NPCs. As those are randomly generated by combining various clothing sprites, all the various body and clothing parts have to be in separate sprites. But when I’m making the sprites for a character with a fixed look, I don’t have to separate them quite as much as they don’t have to be combined randomly. Whereas each frame of a randomly generated character currently requires about 40 separate sprites, I only need about 5 for the unique characters. However, as I haven’t decided on the final look of the player character, I won’t be making his special sprites quite yet. That’ll probably be in the second pre-alpha release.
I’ve also been adding tooltips, shortcut keys, finishing the female hit and die animations, and working a bit more on the map editor in the past week. But I’ve definitely been most excited about covers and crouching, as that immediately added some fun gameplay elements – even as bare bones as the actual game part of the game is as the moment. It feels like it’s really starting to become a game now, as I’m able to crouch behind a wall to avoid being seen by a guard, and the second I stand up, he spots me. The AI still needs a bunch of work, though, as he can’t yet shoot at me or otherwise react except for “SPOTTED!” appearing above his head.
I’ll have a new development video up next Monday showing all the stuff that’s been added since the last video.