My First Starcraft 2 Mod: Resource Rewards

Instead of writing a blog post over the last two days, I ended up publishing a Starcraft 2 Mod: Resource Rewards. Starcraft 2 is a real-time strategy / building game, and the mod rewards players resources for killing units and other players. (Normally, players must harvest resources from mineral and vespene patches.) The mod also recycles resources into patches, just to keep the game going longer.~

The programming possibilities of the Starcraft / Warcraft 3 / Starcraft 2 engines have always intrigued me, and I’ve worked on a few versions of this mod over the years. I can’t remember if I ever tried the mod on Starcraft. I’m pretty sure I started on the Warcraft 3 Mod/Map Engine, which was very limited. I had to enter all the unit resource values manually, in a huge lookup table. I didn’t like the quality, and I don’t ever think I published the mod online.

I re-did the mod for Starcraft 2, twice. The engine has a unit resource value lookup function, so that makes the basic implementation easy. I added the recycling feature, which is surprisingly complicated, and filled with nasty edge cases.+ I also included a feature which would spawn extra mineral patches while recycling, but it got cut from the final version, because adding new (stationary) units to a map is incredibly hard to do well.#

Despite all this programming (or, perhaps, because of it), I’m not a very good Starcraft 2 player. I just can’t click fast enough, and I haven’t invested the time to learn strategies by instinct. And it seems that it’s easy (for me) to lose online, and lose badly.* It makes it hard to start learning. And maybe I’ve learnt some really bad habits along the way. I used to play World of Warcraft with an external, 5-button mouse, linked to various shortcuts. Perhaps that would be the way to go, if I ever wanted to get better.

I had a moment of indecision when I deployed the mod publicly for the first time. Out of an over-abundance of caution, I uploaded a “Locked” version, which means that no-one could see how the mod works, or use the same logic in their own mods. But I’m generally against copyright, and there’s no value gained in keeping the source closed here. I didn’t really mind people re-using my code. So I made it Free Software (Open Source) ~~, under the GNU GPL Version 3, or any later version. This ensures that any mods based on my mod remain Unlocked, and licensed under the GNU GPL, or compatible licenses. The risk is, of course, that someone copies the code, Locks their mod, and redistributes it. It would be hard to tell if that happened.

Edit: I was in a hurry, and I forgot the post summary.

~The fact that the game ends soon after you get to play with all the fun units has always annoyed me about Starcraft.
+ How do you divide an arbitrary amount of minerals between several sites? What if it doesn’t divide evenly? What if the dead unit is worth 30, and there are 300 sites? I could have used the floating point resource amounts, but they’re displayed as integers in-game. (And I have no idea whether they are rounded internally or not). So I used integer amounts, and implemented an “unprocessed” accumulator with a minimum accumulation before recycling. It seems to work well.
# Do you put them randomly, near the existing patches, or away from everything else? There aren’t good enough distance, grouping, unit placement, and error handling functions, even in Starcraft 2.
* I don’t like losing. It feels too much like failure!
~~ There is a difference between Free Software and Open Source: in short, one is focused on ethics – the continuing freedom to use, modify, and redistribute software. The other is focused on development – getting the source code out there, even if there are restrictions. I recognise the difference, but I’m often pragmatic about choosing the software I use (I use closed-source OS X, after all…)


Updated: OS X Yosemite: Whole-System Lockups

Is Apple’s software quality declining?

I’ve been running OS X Yosemite for a few months. It regularly locks up – the mouse and UI freeze, and the sound loops.

This often happens when I’m watching videos*, or web browsing, but it’s happened even when my MacBook Air is idling. It seems to happen more often under load, but can strike at any time.

I’ve tried the typical troubleshooting processes:

  • quitting software that would otherwise be running all the time (it didn’t help),
  • checking for disk corruption,
  • and even eagerly installing each software update shortly after it comes out.§

Is it a hardware failure leading to a kernel panic?
Or a software problem that gets triggered infrequently?
I could probably find out. I have the skills. I could check the logs.
But my point is, I shouldn’t have to know. I shouldn’t have to care. Not in the Apple world.

The last time I had this much trouble with an Apple product was around 2003, with a faulty iBook logic board.~

And, while I won’t write in detail about them now, I regularly notice several other issues with the Apple ecosystem, from the irritating to the trivial:

I’d love to see some of these issues resolved in OS X Gala (10.11) and iOS 9. But I won’t be holding my breath.

* It happens more often when I’m watching multimedia, and it is much more noticeable. There’s nothing quite like a one-second sound loop to attract your instant attention.

Like compiling a large software project, or running multi-process testing. Anything that gets the fan running.

§ However, eagerly installing Apple software updates has recently become a risky game, too.

~ Well, several faulty iBook# logic boards, actually, but that’s another story – a bad lot, apparently. At least they were all under warranty.

# That’s the iBook laptop, not the iBooks app and iBookstore.

To be more precise, the iPad will quit background processes, then spin them straight back up again, filling the logs, cache, and RAM with useless garbage, right in the middle of a memory crisis. But somehow, Facebook always survives.

+ Just for fun, now I’m referring to the iBooks app, not the iBook laptop.

x I’m guessing that iOS 8 – iBooks – Night Mode – Extra Dim – iPad 2 – Landscape just didn’t quite make it into the testing matrix.