C# Part II

Galaxy Generated and Rendered in Unity 3D
Galaxy Generated and Rendered in Unity 3D

In the end, it took me four evenings to replicate the functionality in my Javascript prototype. I’d have to point out that I was able to do some really nice UI stuff (e.g. drag to rotate, mousewheel to zoom) in Unity that I hesitated to mess with in Javascript (the galaxy was rendered to a canvas in Javascript).

On the whole, I have some impressions.

First, C# is very strict about types, and while I can see some benefits, I think a lot of it is utterly wasted. E.g. having to constantly cast from one numeric type to another is simply a pain in the butt (I routinely expect to have to tease apart a bunch of cryptic type-related errors every time I compile a few lines of new code).

// given an array of weights, pick an index with corresponding weighted probability,
// e.g. [1,2,3] -> 1/6 chance of 0, 2/6 chance of 2, 3/6 chance of 3
public uint Pick( uint[] weights ){
    int s = 0;
    uint idx;
    foreach( uint w in weights ){
        s += (int)w;
    }
    s = Range (1, s); // returns a random int from 1 to s, inclusive
    for( idx = 0; idx < weights.Length; idx++ ){
        s -= (int)weights[idx];
        if(s <= 0){
            break;
        }
    }
    return idx;
}

And all of this rigor didn’t actually prevent or even help debug an error I ran into with overflowing a uint (I have a utility that picks weighted random numbers, but I overflowed the weights leading to an out-of-bounds error. (A simple fix is to change idx < weights.Length to idx < weights.Length – 1.) On the whole it would be nice if you could simply live in a world of “numbers” (as in Javascript) and only convert explicitly to a specific representation when doing something low level.

Second, there’s this weird restriction on naming classes within a namespace such that the namespace and class sometimes may not match and the class you want is often not in the namespace you expect. (E.g. I wanted to create the namespace LNM.PRNG and define the class PRNG in it, but this confuses the compiler, so I ended up calling the namespace LNM.Random — so code referring to this is “using LNM.Random” which mysteriously causes a class called PRNG to become available.) I don’t see why namespaces and class names can’t be the same.

Oddly enough in some cases I am allowed to name the class the same as the namespace, and I don’t know why. So LNM.Astrophysics implements the Astrophysics class, but I had to rename Badwords to BadwordFilter at some point because the compiler started complaining.

I’ve been using Monodevelop, which is an editor produced by the Mono folk and lightly customized to work with Unity. It’s a bit of a slug (if it’s developed using Mono, then it’s not a terrific advertisement for Mono). In particular, its autocomplete is great when it works, but utterly frustrating far more often. It fails to match obvious words (e.g. local variable names) and often makes it impossible to type something short (which matches something longer) on the first attempt. The autocomplete is darn useful, or I’d simply switch back to Sublime.

Flying my untextured spaceship around an undecorated, partially implemented solar system
Flying my untextured spaceship around an undecorated, partially implemented solar system

So the current reckoning is that I ended up producing the following:

  • Astrophysics.cs — defines the LNM.Astrophysics namespace and implements the Astrophysics utility class, some useful enumerations, and the Galaxy, Star, and Planet classes.
  • PRNG.cs — defines the LNM.Random namespace and implements the PRNG class which provides convenience functions for the Meisui.Random Mersenne Twister implementation I’m using.
  • Badwords.cs — defines the LNM.Badwords namespace and implements the BadwordFilter class which checks to see if any of a pretty comprehensive list of nasty words is present in a given string. (Used to prevent obscene star names from being generated.)
  • Billboard.cs — a Monobehavior that keeps a sprite facing the camera. It’s a little cute in that it tries to save CPU time by only updating a given star every 10 physics updates. There’s probably a better way.
  • FixedCamera.cs — a Monobehavior that implements a mouse/touch controlled camera that keeps a fixed view of a specified target unless explicitly moved. I’m planning on using this as my main view control throughout the game.
  • NewtonianScoutship.cs — a Monobehavior implementing an Asteroids-style player ship. I’ve also experimented with a “Delta Vee” style abstracted Newtonian ship controller but good old rotate and accelerate just feels better, and makes movement a pleasant challenge in and of itself. (It also makes becoming “stationary” in space almost impossible, which I think is a Good Thing.)
  • GalaxyGenerator.cs — a Monobehavior that instantiates a galaxy and renders it with sprites. (Right now every single star is a Draw Call, so I’m going to need to do some optimization at some point.)
  • Starsystem.cs — a Monobehavior that instantiates a Star (and its planets) and renders them, a navigation grid (to provide a sense of movement when passing through empty space) and orbits using a bunch of Prefabs.

So, while I continue to find C# quite tedious to develop with, I am making significant progress for the first time in over a year, and while C# feels much less productive than real Javascript, I do think it’s very competitive with Unityscript, and it’s been quite easy to get over the hump.

LA Noire

Fingerprints? We don't need no stinking fingerprints.

Despite being an all-round Rockstar fan, LA Noire and Bully are two of the more interesting Rockstar titles I never got around to playing. (I did play a bit of Red Dead Redemption, without really getting into it — I’m thinking of revisiting it once I finish LA Noire.)

This isn’t a review, and LA Noire has been out for quite some time (two years or so) so this is hardly timely, instead this is a discussion of a very interesting piece of game design that was built on top of Rockstar;s GTA Engine. As such I’m not going to discuss the content of the game (there’s a serial killer mystery which is pretty disturbing, although cleverly tucked into history) — I’m discussing LA Noire gameplay design, specifically the way mysteries are solved.

The signature feature of LA Noire is the very impressive facial capture / animation and the interrogation system built on top of it. It somewhat resembles what I considered one of the most brilliant game mechanics I’ve ever seen — unfortunately, not in a game but in a very expensive piece of multimedia computer-based training Andersen Consulting created for GE Capital back in the 90s — but I’d say the training product actually had a better thought out mechanic (more on this later).

Here’s how LA Noire works in a nutshell:

You visit a crime scene or other place of interest (e.g. the dwelling of a suspect or victim) and walk around. When you’re close to a piece of evidence, the controller vibrates. If you press “x” (often after walking around to try to get the vibration to recur) you’ll discover either one or several pieces of evidence. If one, you can pick it up, rotate it (sometimes), zoom in on it (sometimes), and it will sometimes cause a piece of evidence to appear in your notebook. There’s a subtle mechanic to tell you when you’ve found all the evidence at a crime scene (a musical swell).

Somewhat oddly, you manhandle every piece of evidence you see, despite the fact that fingerprints were used to obtain a conviction in the US as early as 1902, and you’re investigating very high profile murders (“red ball whodunits” in Homicide terms). Perhaps the typical LAPD detective in 1947 was lax with evidence (although in LA Confidential and its sister novels, set in the 50s, the LAPD is surprisingly high-tech), but the character you’re playing is educated, ambitious, and a stickler for procedure.

This is, in essence, an even more annoying variation of the Fallout / Bioware “cursor as a white stick” mechanic for finding loot in 2d adventure games and I despise it, but it’s not so annoying that I won’t play the game.

You also interview / interrogate POIs (persons of interest). Usually you gather evidence first, but the game steers you towards interviewing a witness before — for example — gather evidence at another scene.

Once you start an interview, your character will say something (over which you have zero control) then the POI will say something, then you’ll look at your notebook and some questions will be there. You select a question and the subject responds, at which point you have to pick one of three options: Truth, Doubt, or Lie. You’re told that “Truth” means you believe them, “Doubt” means you think they’re lying, but have no specific evidence, and “Lie” means you think you’re lying and can provide it. Before deciding you can examine their face and body-language (the facial expressions are pretty amazing, although almost everyone looks like they’re lying, and the few people with direct gazes are often lying in one or two of their responses and I for one have no clue how to tell which one).

Truth, Doubt, or Lie? Or would you like a life line?

You can examine your notes before choosing one of the three options, but once you pick an option you can’t go back. (E.g. you can’t decide you doubt them after having decided they were telling the truth, or change your mind and decide they were truthful after assuming they were lying. Even if you later find evidence contradicting a previous piece of testimony, you can’t go and put the question to the POI a second time. It’s quite infuriating. And you absolutely can’t do what detectives actually do, and that is ask open-ended questions. (If I recall correctly, in Homicide: A Year on the Killing Streets, David Simon says the most powerful question in a detective’s arsenal is “And…?”)

Sometimes a response will cause a follow-up question to appear.

When you’ve exhausted all your questions the interview is over and you’re told (usually) how many times you picked the “correct” response. You don’t know which specific responses were correct (which is especially infuriating when, for example, you’ve picked “lie” and gotten a highly unsatisfactory response despite having what looked like perfectly good evidence that you were being lied to, so were you wrong? Or was some other response wrong?)

Finally — worst of all — at the end of an investigation you don’t really get to pick your suspect (indeed, based on what I’ve read, you can apparently pretty much screw up every aspect of an investigation and the same person will be charged at the end). This may be necessary for some of the story arcs to work, but if so it’s a case of the need for story arc defeating the core gameplay.

Problems

"sadness" expression from Lie to Me

Perhaps the most egregious problem with the execution of all this comes to a single point I came across in this article on GameRant (which I found while googling for ideas on how to interrogate better, without resorting to a walkthrough):

A lot of people say that Aaron [Staton, who played Phelps] goes a little bit psycho with some of the questions you ask in the game. When we originally wrote it, the questions you asked were Coax, Force and Lie. So Force was a more aggressive answer, and that’s where we actually recorded it…But when the game came out, it was Truth, Doubt and Lie, so everyone says that Aaron on the second question goes psycho, but that’s just the way we wrote it from before.

This  is from Brendan McNamara (described as a former member of Team Bondi, the original development team of LA Noire.

Note that Coax and Force are tactics, not assessments of the preceding response (and Lie would actually be better described as Challenge). Also note that the actors were quite possibly not told that they were lying, but that they were holding back. If you’re a fan of Lie to Me (or a social psychologist) you might know that the micro-expressions of a liar are very different from those of someone holding back. Good actors (and many of the actors in the game are excellent) will also know this. So when I take a glance up and to the right to indicate fabrication and pick “Doubt” I am picking the “Force” tactic instead. This is just awful, and combined with the terrible feedback system it’s near-fatal. Given that L.A. Noire places almost all its eggs in the “read the NPCs’ facial expressions” basket, this is an utter disaster.

Even so, the real problem with the mechanics is that it gives the player detailed control over stuff that often doesn’t matter (e.g. the order in which bits of evidence are discovered) but not over the actual outcome of a case. This is pretty much like those games where all the important stuff is in the cut scenes. “Hey player, go do a bunch of legwork so that the game engine can tell you whom to arrest.” Surely the basic task of a detective ought to be (a) gather evidence, (b) form a theory of the crime based on (a), (c) accuse your suspect. The way I would suggest it work is something like, every time you accuse a suspect with insufficient evidence your potential score drops (and possibly your ultimate score suffers if you successfully convict the wrong person).

Given the whole Dragnet/Untouchables visual feel of the game, having something like a voice description of the outcome: “Frederick Ronald Bloggs was convicted of first degree murder and sentenced to death in the gas chamber.” or “Frederick Ronald Bloggs pleaded to manslaughter in the second degree and with a good behavior bond.” depending on how well you conducted the investigation, along with a game breakdown of how well you did would be much better than telling you stuff like how many times you guessed which response to use over the course of the investigation.

I have left one thing out of my description of the game mechanics: “intuition”. This is basically a “lifeline” mechanism (you get a fixed number of intuition points — I’m not sure when your pool is restored, it’s possible that it’s simply buggy — and each point lets you “ask the audience” or “50/50” one response to one interview response: it’s a near useless bandaid on a broken mechanic).

Making Allowances

Now, I believe what happened with LA Noire is that Team Bondi worked on it for a long time and went way over-time and way over-budget. Rockstar assigned some kind of A-team to rescue the production and basically triage the content and get something out the door. (So, think healthcare.gov.) So, a lot of the problems with the game are at least in part a consequence of an overly ambitious design being cut down to a (barely) functional core in sudden death overtime, but it seems to me that the overall structure of the game is actually as intended, and changing Truth, Doubt, Lie to Coax, Force, Challenge wouldn’t really help significantly because it’s a fundamentally flawed design.

The basic problem is the structure of the detective game.

(It’s pretty clear that the designers were aware of the shortcomings of the mystery content, because most of the mysteries and incidental street crimes devolve into gratuitous car chases and shootouts. So you get half-assed mysteries mixed with half-assed action.)

How to do it right

Here’s how the training program I mentioned earlier worked.

You (an investment banker) are asked to assess a company as an investment opportunity. You wander around gathering evidence (by walking around the company’s premises, making observations, interviewing its employees and customers, and reviewing documents) and then make a decision (“yes — loan money to the company” or “no — deny loan”). You need to cite evidence for and against whatever decision you make (compile a list of pros and cons) because your goal is to make a thorough assessment, including a  realistic risk assessment.

Is this not obviously a superior mechanic to the LA Noire game design I’ve described? You could even easily add mechanics for concealing evidence from the defense (i.e. concealing evidence that weakens your case), framing suspects, and so forth. Of course, that would be less Dragnet and more L.A. Confidential or Chinatown. I don’t want to go into the content of LA Noire — I haven’t finished it yet; so far it’s not terribly good — but it seems to me that L.A. Confidential was the obvious touchstone for this project. Unfortunately, the actual game seems instead to draw more from The Untouchables (both the movie and TV series) and Dragnet.

Finally

There’s clearly a market for mystery-solving games: there are games based on all kinds of TV mystery shows — my wife bought me an unplayable Law & Order game for Christmas some years back; I would love a good game based on Law & Order. It’s sad to see Rockstar, which I believe has the all-round best adventure game engine on the market, try and conspicuously fail to tackle this genre, because I doubt there will be another serious foray into the genre for some time to come.

GTAV

rappelling

I don’t spend much time playing hardcore games these days, but there’s a special place in my heart for the Grand Theft Auto franchise (even though I never finished any of the PS2 versions — there was always some mission where I simply couldn’t finish owing to my incompetence or the horrible controls, depending on how you look at it).

Here, in a nutshell, is what I love about GTA games:

  • driving a halfway decent car (or motorbike) simulator around a halfway decent virtual city at insane speeds is just fun
  • always breathtaking (by the standards of the time) rendition of the real world
  • cheap but often hilarious cynicism and dark humor pervading the world
  • more-or-less free-roaming world with at least somewhat interesting stuff to do
  • quasi-emergent behavior in the form of the way other drivers work, people on the street, and so on
  • constant pushing-of-the-envelope in terms of game mechanics
  • totally organic and usually not annoying cut scenes

GTAIV added to this mix:

  • the best implementation of cover mechanics I’ve seen in computer game

Indeed, missions involving a lot of gunplay went from being horrific (in Vice City) to usually a lot of fun (in San Andreas, which had improved aiming but no cover mechanics) to perhaps the most fun part of the game (in GTAIV). The designers of GTAV clearly consider the gun fight mechanics to be a sufficiently positive feature to make huge set piece running gun battles a central piece of every major mission in GTAV.

Incremental Improvements

Los Santos View

GTAV represents perhaps the least significant improvement in the game engine and scope over a predecessor in the series. Although many have commented on the less realistic (and thus better or worse depending on your point of view) car controls (and I assume that they’re right, which may be generous, but I haven’t gone back and played GTAIV to check), I didn’t notice a change. I could drive around Liberty City at insane speeds in GTAIV, and I can drive around Los Santos at insane speeds in GTAV. That said, was able to pretty effortlessly drive a stolen car out of a multilevel carpark (if you’ve finished the game you probably know exactly which car I’m talking about) in GTAV — an impossibility in San Andreas, but I can’t remember how tough it would have been in GTAIV.

You can switch between characters, which is interesting (and I guess lets you decide for yourself who the main character is — but if you don’t think it’s Franklin you’re wrong).

There’s underwater stuff (including a submarine and SCUBA sequences), more minigames, skydiving (is that new? can’t remember) and — my favorite — interactive hallucinations. The setting is bigger, but not overwhelmingly (not like say San Andreas vs. Vice City). I think (but haven’t checked) they’ve made the missions finer-grained with respect to recovering from failures (so you generally don’t lose much progress when you screw up). But, nothing much else.

As with previous installments — it’s very well written, great voice acting, good motion capture (including facial expressions and eyes in some cut scenes). One thing I did find was that the radio stations weren’t as funny as I remember (especially compared with the PS2 games — I was just replaying San Andreas on my Mac and the original GTA3 on my iPad).

Characters

helicopter approaching FIB

The main characters are two middle-aged former bank robbers and their young protege, a former gang-banger who is trying to better himself — legitimately or otherwise. Twenty years ago, the two older guys would have been Vietnam vets, ten years ago they’d have been Iraq vets, but today they’re just sociopaths. What does that say?

Of the three characters, the most entertaining is the disgusting and reprehensible Trevor, a slouching, crazy, drug-fueled, murderous, Meth-distributing, gun-running, unwashed thug. Trevor’s endearing qualities come down to his yelling frequently hilarious epithets and taunts during combat, and — reminiscent of Vyvyan in The Young Ones (for those few of you who might remember that BBC sitcom) — his bouts of ethical lucidity. The problem is that he is just as likely to enthusiastically torture someone as to help them escape execution at the hands of their torturers.

More interesting to me is that this is a series of games that tends to deal with older characters (CJ, in San Andreas, is the youngest protagonist I can recall, and he is returning to the ‘hood after spending time in Liberty City) — GTAV has a younger character in Franklin (the ex gang-banger) but he is something of a blank slate. The dominant personalities are Michael — an ex bank-robber, now living the high life under corrupt government agency protection, with teenage kids and a wife who pretty much hates him (a bit like Tony Soprano) — and Trevor — an ex bank-robber turned meth-dealer and wannabe arms dealer with major mommy issues (think Walter from Breaking Bad, with a bit of Tony Soprano mixed in, played by Jack Nicholson).

Gameplay

skydive

Gameplay is great, but far from perfect. People tell me that the car controls are more forgiving than GTAIV (which I had no big issues with at the time) — it’s probably true. (Landing planes on Trevor’s runway is another matter entirely.) It’s very easy to do things that I’m pretty sure were hard or impossible in GTAIV, and on top of that the specialist driver has a “bullet time” ability that gives you totally superhuman abilities in a pinch. (I didn’t find Michael’s combat bullet time ability one terribly useful, but Trevor’s rampage mode could easily turn a fight around.)

The Cover Button

The biggest flaw in gameplay is the way cover works. I don’t know if it could be much better, because the cover system seems to be dynamic rather than manually set up — almost any nook or cranny in the landscape that looks like it might work as cover pretty much does, versus — say — Mass Effect where cover objects are quite clearly manually placed by level designers. The problem is that hitting the cover button can send you running across an open field to the wrong spot and gets you killed a lot. I’d say that about half of my ~30 deaths in the game came from the cover button doing something annoying. (That said, I didn’t die very often.)

On-the-job training

The second biggest flaw in the gameplay is the “just-too-late” instructions. Probably my second biggest source of mission failure after the cover button was being told how something works just as I got shot to death or failed the mission owing to lack of time. It’s funny how some critical controls are gently introduced before the fact while others are on the screen for the first time as everything goes tilted and grey (signifying a mission failure). Again, I don’t know if this could be much better. Introducing mechanics a little bit earlier every time would spoil a lot of storiees, and introducing them much earlier would probably just lead to greater consternation as they’d be forgotten before the critical moment.

Interactive Hallucinations

Spoilers!

Probably the single standout feature of GTAV is the playable hallucinations. It’s a shame these mainly occur early in the game (as far as I can tell). Mike’s drug trip (infinite psychedelic freefall) is visually amazing as is his alien invasion. Trevor’s rampages and clown attack likewise. The pro-legalization-of-weed guy giving out spiked joints is involved in a series of missions that appear to just taper out — I’m not sure if I missed something.

Rampages

Spoilers!

Speaking of hallucinations, instead of just randomly inserting rampages into the landscape, as in previous instalments, they’re now missions specific to Trevor, which makes more sense and doesn’t defile the other characters. (It’s hard to create sympathy for a person who randomly goes on killing sprees.) Perhaps my favorite example is when Trevor is set off by someone he interprets as making fun of his “slightly Canadian” accent. (Trevor being a Canadian is one of the game’s running jokes.)

Utter Lack of Resource Constraints

One fairly big difference between GTAV and any previous GTA instalment as far as I can recall is that you don’t spend very much time being poor. To begin with, each character starts with their own car that magically follows them around, and it’s a pretty damn good car. (In fact, it didn’t occur to me to buy any car mods until I was forced to by a mission, despite having plenty of money and having had the car mod shop rubbed in my face by an earlier mission.)

Similarly, Los Santos features three high end shopping malls, and top-of-the-line vehicles are there for the taking at any time. And soon two of the three characters are living in upscale neighborhoods and can literally steal a neighbor’s Ferrari or Range Rover surrogate without a thought. Incidentally, I don’t know how realistic this is, but my opinion of Range Rovers is greatly enhanced by GTAV! (I recally being quite happy to find an upscale neighborhood in GTAIV and making special trips to it to score nice cars before driving missions.)

After the first heist, you’re floating in cash with all three characters and never really have to stint on anything (you basically just walk into Ammunation and buy the works for every character after the first heist, and still have plenty of money left to play the stock market and do some insider trading). This undermines a lot of potential game play because, for example, Trevor’s rather difficult weapon drop missions (at $7000 a pop) don’t really seem worth bothering with when you can make a quick $200,000 on the stock market and have $450,000 in the bank, or, for that matter, score $5000+ from an opportunistic armored car robbery that is over in a matter of 30s. Indeed there was an early mission where Trevor makes a big score but then needs to spend most of it almost immediately that made me think resource constraint would be part of the game, but no, money is never an issue.

Heist Missions

Speaking of heists, when I read the Ars Technica review of GTAV, I assumed that you’d do a lot of heists and that setting them up might be tedious. In fact there are not very many heists and setting them up is no more tedious than any other kind of mission in other other GTA game. (Why do you do anything in GTA?). Heists seem like a great mechanic, and it would be awesome if smaller heists were generated randomly as part of the sandbox rather than simply being a fixed set of missions. Perhaps something along this line was planned but abandoned due to time constraints (since I imagine it would be technically difficult).

Minigames

The depth and breadth of minigames in GTAV is something I’ve yet to fully explore. The tennis simulation is impressive, and I assume golf is too. Darts was OK in GTAIV, no reason to assume it wouldn’t be at least as good in V. Sky diving is awesome, mountain biking is kind of horrible, and the triathlon is likely to cause repetition strain injury. Unlike earlier GTA instalments street racing is pretty much sidelined (I won one race early on with Franklin, who has super powers when it comes to racing, and then simply saw icons on the map if I wanted to do more races, which I didn’t).

Story

Warning: slight spoilers.

The basic arc of the story is that a gang-banger-turned-repo-man who is trying to either go straight or at least be a smarter criminal hooks up with an aging former bank-robber with major impulse-control issues and a serious mid-life crisis. As a result of losing it one-too-many-times, the robber suddenly needs to raise a ton of money, and gets back together with a former colleague to plan a major heist. This leads to uncontrollable and violent former friend figuring out that he’s still alive and tracking him down.

You play the three characters — aging ex-bank robber, aging meth-fueled maniacal ex-bank robber, and talented newb as they proceed to engage in higher and higher stakes heists each intended to solve problems created by earlier heists and/or the older characters’ tendency to piss people off with little or no provocation.

The fact that any single one of the crimes the characters commit (and quite a few random incidents) would lead to an unrelenting international manhunt and quite possibly the formation of new federal agencies is par for the course for GTA.

Sandbox

Organic Encounters

There’s an interesting mechanic that sets up interesting encounters on-the-fly (I think there are similar things in earlier games, but it’s not as explicit). Your sat nav flashes and a blue or blue/red flashing dot indicates something you can intervene in. Armored Cars are one of my favorites, since you can let off a little steam by killing a couple of guys, blowing up an armored car, and then fleeing the police for a couple of minutes. The most elaborate one I saw (and the game tells me I’ve seen them all) is the No Country for Old Men scene where you find the aftermath of drug deal gone bad, with a bunch of money sitting in the middle. Pick it up (of course!) and chaos ensues.

Most of the encounters are simply annoying. E.g. man or woman is robbied, you pursue the thief (who usually turns out to be heavily armed — the first time I chased on I got killed), run over them repeatedly (or shoot them once you master shooting while driving, but that tends to attract a lot of police attention, and I feel a little bad shooting innocent bystanders while returning a wallet to someone — $100,000 in property damage is fine, of course). More annoying still are the people pleading for help who’re trying to ambush you. It would have been nice for at least some of the organic missions to not be totally stupid (if only to make you more likely to not simply ignore them or shoot the person).

E.g. after being ambushed a couple of times, I’d simply pull out a pistol when asked for help, and when their reaction revealed they’d actually planned to kill me I’d shoot them dead and walk away.

Not quite in the organic encounter moment, but the owners of gun stores say pretty sarcastic things to your characters when you pop in for a purchase. I had a serious laugh-out-loud moment when I visited a store with Trevor after his first big score (the filthy, meth-addled, often semi-naked psychopath) and as I left (carrying a huge supply of weapons, explosives, and kevlar) the store owner said “And I bet you’ll be using that stuff right away” as I walked out. Sadly, it turns out the store owners turn out to be equally likely to say the same thing to the other characters, who look perfectly reputable.

Dating & Guys’ Nights Out

Unlike GTAIV, there’s not only no pressure to go play darts with your pals or date women, it seems to be quite difficult to do. (I didn’t go on a single date or mandate — towards the end (as Franklin) I tried the “Hang Out” menu option on Trevor (since I had just been told I had to kill him) and he replied “And you call me a creepy stalker!” and hung up.

Similarly, the constantly enraged Mike accidentally ended up jogging with an equally enraged and age-appropriate woman, who I thought would be a perfect fuck buddy for him, but while she appeared in his contact list afterwards, I could never get through to her, despite entering and winning a triathlon. I’m not quite sure what went wrong there.

Social Commentary

Midlife Crisis

Midlife crises are a bit passé today, but they’re fairly unusual in computer games. Michael’s family situation at the beginning of the game seems reminiscent of Tony Soprano’s at the outset of The Sopranos. His midlife crisis drives some fairly important plot elements, but it’s one of the weakest elements of the game, and isn’t funny. His wife and children are so repellant, that his desire to keep his family together stretches credulity, and the whole Hollywood movie producer subplot is neither funny nor biting.

Psychotherapy

Like Tony Soprano, Michael is in therapy, but his therapist is a guy (played by some fairly well-known actor whose voice I recognized — I think maybe the guy who played Monk’s psychiatrist). I think this is also supposed to be funny, but pretty much falls flat, with the main joke being how greedy the psychiatrist is. (I did amuse myself though — playing Michael, I left my second visit to him in his Porsche-analog.)

Sexism — definitely an issue

It’s easy to complain about sexism in the GTA series. Of course, there’s scarcely single positive female character in the story (There is in fact one good female character in the story.) — but then there’s no positive male characters either. At best Franklin, say, is not a murderous sociopath and stands up for his friends. But the portrayal of women is both shallow and often mean — Michael’s wife seems like a flat-out bitch, and his daughter is even more shallow and useless than his son, who is at least self-aware and ambitious enough to have a stab at starting up his own pot-dealing business. (Spoiler Alert: wait until you see Trevor’s mom!)

On the one hand, the other pop culture sources on which GTAV feeds (and which in turn feed on it) are just as bad — where are the positive female characters in The Sopranos or Breaking Bad? But the fact is that GTA could easily have strong and complex female characters (indeed, the best computer hacker among your heist crew options is a woman who all but doesn’t appear on screen or say a word). Yes, GTAV is ultra-macho, but I think they could pull it off and still have a strong female character or two. Even the incidental female characters, such as the loser who sends Franklin on towing missions to fill in for her drug addict boyfriend and his ex-girlfriend are simply pathetic and loathsome.

Perhaps Rock Star is to be praised for not inserting positive female characters just to check off an item that critics complain about, but I think it’s just lazy. Oddly enough, there’s a tough female cop arresting someone in the loading graphics, but as far as I can tell, she never appears in the story. I seem to recall that Rockstar foreshadowed the Liberty City Stories expansion content in the credits of GTAIV; perhaps there’s an expansion with a tough female cop character in the wings.

Racism — not an issue

You can’t really accuse GTAV of being racist. (Plenty of the characters in the story are racist, of course.) It’s definitely not color-blind, but the portrayal of race in the game seems completely organic and reflective of society. The black-on-black dialog seems, to my ear, to be completely authentic (but what would I know?)

Homophobia — not an issue

There’s a great line where Michael’s son is telling his father off and says he’d call something “gay” but he has gay friends and it’s uncool now so he’ll settle for lame. Homosexuality doesn’t really come up aside from this comment (and Trevor’s tendency to snuggle up with men he shares beds with and — spoiler a nasty comment made by his mother).

Drugs

The treatment of drugs in the game is so casual as to probably cause great alarm to anti-drug moralists. The fact that drugs are illegal or that meth labs are prone to explode is simply treated as being a logistical issue. There is no portrayal of drugs as being a moral hazard or even having real health impacts, but merely that trading in drugs and using drugs presents practical problems. I think this is correct, but I suggest it should be very alarming to anyone who would like prohibition to continue. It seems clear that as a cultural artifact showing gen-X/Y/Z talking amongst itself, the whole drug debate is over.

Torture

There’s a torture scene in GTAV (in which you, as Trevor, actively participate). It seems somewhat poorly integrated into the overall story, and then ham-fistedly used to insert actual social commentary (from Trevor, no less) into what is generally an apolitical and amoral story. I’m not sure what the writers were trying to achieve, and I’m pretty sure they didn’t achieve it.

The War on Terror

Aside from one of the major villain groups being Merry Weather, an obvious Black Water surrogate, frequent references are made to the government starting unnecessary wars, and the War on Terror merely being a pretext for federal agencies to pad their budgets. (Indeed, this is a major component of the arc plot, and at one point seems to be the arc plot.)

Obamacare

If I recall correctly, Trevor makes a comment (in one of his lucid tirades) in favor of socialized medicine, and then someone says he sounds like a Canadian. Then again, Trevor wryly suggests that hunting liberals might be a fun pastime for his “friend” Cletus.

Summing Up

GTAV is a fantastic game. It’s extraordinarily ambitious and manages to do everything it sets out to with aplomb. If I have any criticisms they would be some weak plot elements (e.g. Michael’s family life, midlife crisis, and Hollywood storyline), and lack of interesting dynamic content (gratuitous missions removed, and nothing much has replaced them — I was hoping for a random heist engine).

Creating UI Atlases in Photoshop Automagically

A little over a year ago I was working on a game engine for a successful toy company. The project never ended up being finished (long, nasty story which I’ll happily tell over beers), but one of the interesting things I did for this project was build a Photoshop-to-Unity automatic UI workflow. The basic idea was:

  1. Create UI layout in Photoshop, with one “root level” layer or layer group corresponding to a control.
  2. Name the groups according to a fairly complicated naming convention (which encapsulated both behavior and functionality, e.g. how a button might change its appearance when hovered or clicked and what clicking it would do).
  3. Press a button.
  4. Select a target folder (which could be inside a Unity project’s “Resources” folder, of course).
  5. And point a script at the folder.

This worked amazingly well and allowed me to adjust to changing client requirements (e.g. random UI redesigns) very rapidly. But along the way I decided there were significant design issues with the concept, one of them being that the images needed to be texture-atlases (b) for performance reasons, but more importantly (a) because you needed to adjust import settings for each image (you can’t even select multiple images and change their import settings all at once — maybe this is fixed in Unity 4).

Another obvious problem was the embedding of behavior in names — it was convenient if you got it right the first time, but a serious pain in the ass for iterative development (either change the name in Photoshop and re-export everything or change the name in Photoshop and then edit the metadata file, and… yuck).

Anyway, I’ve had the “perfect” successor bouncing around in my head for a while and then the other day it struck me that someone probably has written a Photoshop image atlas tool already, and I might be able to rip that off and integrate it with my script.

Turns out that (a) someone has written an image atlas tool for Photoshop and (b) that the key component of that tool was a rectangle packer someone else (sadly the link is defunct) had written, implementing an algorithm documented here.

So that’s what I spent New Year’s Eve doing, and the result — Layer Group Atlas — is now availble on github.

Screen Shot 2013-01-01 at 7.00.46 PM

For the more visually-minded, you start with a UI design in Photoshop. (Stuff can overlap, you can have multiple states set up for controls, etc.) The key thing is each “root level” group/layer corresponds to an image in the final atlas (and yes, transparency/alpha will be supported, if a group/layer’s name starts with a period then it is ignored (as per UNIX “invisible files”) while a group/layer with an underscore will only have its metadata exported.

Screen Shot 2013-01-01 at 7.02.47 PM

For every layer (other than those which were ignored) metadata about the layer is stored in a JSON file. (One of the reasons I didn’t take this approach with my original tool was the lack of solid JSON support in Unity. I — cough — addressed that with another little project over the holiday break.) The JSON data is intended to be sufficient to rebuild the original Photoshop layout from the atlas, so it includes both the information as to where each element is in the atlas, but where it was in the original layout.

Screen Shot 2013-01-01 at 7.01.36 PM

Finally, the script creates and saves the atlas itself (as a PNG file, of course).

Aside from the CSS sprite support I mention in the comments in a TODO — an obvious thing for this tool to be able to do would be to export a bunch of CSS styles allowing the images in the atlas to be used as CSS sprites — there’s one more missing thing: a Unity UI library that consumes the JSON/atlas combination and produces a UI.

That’s my project for tonight.

Skylanders — Unfulfilled Potential

Skylanders — Sonic Boom, Stealth Elf, and Trigger Happy
Skylanders — Sonic Boom, Stealth Elf, and Trigger Happy

A couple of months before Christmas last year, when I was working on a number of game projects aimed at children, I scoured my local stores looking for similarly targeted games, and ended up buying a copy of Skylanders for XBox 360. I didn’t have time to play it, so it ended up as a kind of bonus Christmas gift for the girls — but they had so many new toys it pretty much was forgotten. We finally ended up playing the game in earnest about two weeks ago.

It’s a pretty good game, but it so easily could have been great. The game play is essentially late-model Gauntlet but with a few puzzle mini games thrown in — one or two players running around a 2d maze rendered in 3d with a camera controlled by Satan. The figures are beautiful and the characters they activate are fun and surprisingly different to play (we’ve tried ten different figures so far — it was the smallest set of figures I could buy in a hurry that covered all eight “elements” in the game, thus allowing all the bonus areas to be unlocked).

Our girls (who are nearly 4, which is to say a couple of years younger than the low end of the game’s target age group) actually love the game and can pretty much play it, but are handicapped by several shortcomings:

XBox 360 controllers, even small ones, are horribly designed for kids’ hands. (They’re not great for adult hands — the Playstation controller form-factor continues to reign supreme ergonomically in my opinion.)

The game varies widely (and randomly) in difficulty, and I suspect many younger players will find it horribly frustrating. E.g. the boss fights can be ridiculously difficult — especially if you’re perversely attached to a lame character — have no originality, and are annoying compared to the rest of the game. They seem like a cheap afterthought and the game would probably have been better without them altogether. The final boss fight (not including anything in expansions) is horrible, difficult, repetitive, and takes what seems like hours to finish. (I finished the final boss fight solo on my third attempt mainly playing the Stealth Elf, who is a gigantic exploit — horrendous lack of balance between characters is almost inevitable in a game like this so I haven’t listed it as a major flaw).

The game is full of lazy coding. To begin with there’s an excellent mechanism for skipping cut scenes, but it’s often not available. This is particularly galling for early levels with tutorial content built into them which can’t be skipped on replay. The game is implemented — somewhat like Super Mario Galaxy — as a hub island with an increasing number of portals to other worlds, but once you’ve completed a level you do not (and cannot) return to it by using the 3d portal, and instead simply use a poorly designed menu. Even so, the NPC who took you to the level is still present (most of the time) but does nothing but lock you into a modal cut scene (ugh).

There’s replayability built into the game design — but it’s half-assed — you can try to get three “stars” for each level, which involves finishing it (for one star), completing it without losing any lives, in a set time, etc. for a second star, and finding all the goodies hidden in it for a third star, but the game is lousy about telling you what you still need to do for a given level until after you finish it, provides no timer (for achieving the timed completion), and — worst of all — once you’ve found a secret goody the area basically becomes a giant empty area you get stuck in when you come back.

Similarly there are “heroic challenges” which are timed mini-levels with permanent stat bonuses as rewards. I suspect that many of these would be pretty much impossible for kids to complete.

The content gets “grim” (in terms of look) way too quickly, so there aren’t many brightly colored levels, which means the girls only like the first few levels which, not coincidentally, are the levels most beset by unstoppable modal cut scenes.

It’s possible that these issues have been fixed by a patch available from XBox Live, but since I refuse to pay Microsoft $80 for a WiFi adapter (let alone a recurring XBox Live subscription) and the XBox is inconveniently located for hard network access, I simply don’t know. The errors I mention would have been relatively simple to fix and are pretty egregious.

It’s also quite clear that the game is a huge commercial success. One can attribute this to the fact that it is very well-presented, actually a pretty good game, family friendly, and it allows two player co-op on a single console, meaning it has virtually no competition. Four or five months after its release, stores are still having trouble keeping the figures in stock (and they sell for $8-10 each, or $18-20 in three packs). I’ve only ever seen one of the content packs on sale, and immediately bought it.

So, I hope that the success of the game doesn’t mean that Activision (ugh again) won’t address the games significant flaws. Would I recommend this game to friends with small children? I think so, but be warned that the basic set (for one console) costs $50-70, and that the 29 extra (so far) figures cost a minimum of $8 each (and you’ll need at least five just to open all the content in the basic game), and there are three content packs that cost about $20 each. At $350 or so for the complete set, that’s ridiculously expensive.

Final Note: if you’re wondering about my choice of figures for the photo — of the characters I’ve tried, these are by far the most ridiculously overpowered.