Posted July 15, 2010 by Vince Curley (Xbox LIVE & Platform Architect) – V
What is the happiest sound in the world? The roar of coins pouring into a metal tray when you hit a jackpot playing slots? The final school bell of the year, signaling the start of summer? The cheer of the crowd when your team wins a match?
Sure, all those things are great, but I think the happiest sound is one heard over 4 million times a day, all over the world: the notification beep that your Xbox makes when you earn an achievement.
(Yes, it’s the same sound you hear when getting a friend request or a game invitation, but those things just make the sound even happier.)
Did you know that the “Achievement unlocked” toast and the happy sound that goes with it were a last minute addition before we released the Xbox 360?
I had the great fortune of being the first developer on the achievements system, and I wrote a good chunk of the profile code that runs on the Xbox 360 today. In this post, I will share some other behind-the-scenes details of the creation of the Xbox 360 Achievement system and how it works.
Building on a Good Thing
One key benefit of Xbox LIVE is that you have an identity that carries across all games. In the early days, before Xbox 360 launched, your identity was just your gamertag. But with Xbox 360, we amped it up to include information about the games you play, what type of player you are (your Gamer Zone), your overall reputation (the stars on your gamercard), personal settings (such as your controller inversion preference), and, of course, your achievements.
I remember my first meeting on the Xbox team. A small group was gathered around a long table in a dimly lit conference room in a run-down office park. This wasn’t the polished and professional Microsoft I was used to. The meeting invitation claimed that we were going to go over plans for a “digital identity” system for the upcoming new console. That didn’t sound sexy, but once I sat down at that table, I was immediately drawn in by the passion the group had for the feature. I was just to the left of Major Nelson, who people were actually calling “Major” and I thought, “That’s a weird name.” Fortunately, I figured it out … eventually. (I hope he doesn’t read this or I’ll never hear the end of it.)
One hot topic that came up in that meeting was that profiles must be available offline. That meant that a player didn’t have to be connected to Xbox LIVE in order to access his or her achievements or profile settings. The impassioned statement was, “I have to be able to take my Xbox to Whistler for a ski weekend, and have all the achievements I earn there show up online when I plug in at home Monday morning!” Life would have been a lot easier if hotels in Whistler offered free Internet access but, instead, offline access became a big part of the profile story. Not only could you go away for the weekend, but you didn’t have to worry if you lost your Internet connection before reaching a critical milestone. Or you could play without ever connecting to Xbox LIVE, earn a pile of achievements, and have them show up in the cloud the first time you got connected. Offline access made for some late nights for the development team, but we knew it was the right thing to do and that was enough to justify the overtime.
That was just one of hundreds of design points that shaped the system. I could drone on and on about the project requirements, but let’s shift gears and look at how it all works.
At the Game Studio
When a designer is working on a game, he or she must tell the Xbox system several things about the game, such as details about the game’s achievements, its leaderboards, how it wants to do matchmaking, its presence strings (such as “Racing at Laguna Seca”), etc. This information helps the console and the Xbox LIVE service provide experiences specific to that game.
Since the launch of Xbox 360, game information has been defined using a Game Development Kit (GDK) tool called XLAST, the Xbox LIVE Authoring and Submission Tool. XLAST writes the game information to an XML file called an XLAST file. (We are very creative in our naming conventions, aren’t we?)
The XLAST file is then run through another tool that validates the XML and enforces things such as the number of achievements defined, how much Gamerscore the game awards, etc. For example, here are some of the current limits:
|Title Type||Base Title||Downloadable Content|
|Standard Retail (Single or Multi Disc)||5 to 50||1000||0 to 30||0 to 750|
|Arcade||12||200||0 to 9||0 to 150|
If all of the checks pass, then two files are output: a header file and a SPA file. Since the tool compiles the XLAST into a SPA it is known as the SPA Compiler, or SPAC (pronounced “Spock”) for short.
The header file is used in C and C++, the languages commonly used to write games. This file defines, amongst other things, unique identifiers that are used to refer to specific achievements. More on that below when we talk about how the game awards achievements.
The SPA file is a compact, binary representation of the XLAST file. “SPA” is an acronym for Statistics (leaderboards), Presence, and Achievements. There’s more in there, but those are the big pieces and “SPA” rolls off the tongue easier than “SPAPCXYZZY.” The SPA file is linked into a game’s binary executable so that when the game launches, the Xbox system software can pull the SPA data out of the executable and parse it into internal structures for later use.
Inside Your Xbox
When a game wants to award an achievement it calls the GDK function XUserWriteAchievements:
// Achievement ids are defined in spa.h, created by SPAC from the XLAST file
rgAchievements[dwNumAchievements].dwUserIndex = dwUserIndex;
rgAchievements[dwNumAchievements].dwAchievementId = ACHIEVEMENT_PLAYED10GAMES;
rgAchievements[dwNumAchievements].dwUserIndex = dwUserIndex;
rgAchievements[dwNumAchievements].dwAchievementId = ACHIEVEMENT_PONG_A_THON_I;
dwResult = XUserWriteAchievements(
dwNumAchievements, // Number of structs in pdwAchievements
pdwAchievements, // Achievement/user tuples to set
&xov); // Async status
The parameters passed indicate a list of achievements and which players should receive those achievements. Most games award one achievement at a time, but it’s possible to award up to every achievement in the game in one call. Of course, you’d have to be pretty good to make that happen. The unique identifiers passed inpdwAchievements were the ones specified in XLAST and output in the header file by the SPA Compiler.
Inside the XUserWriteAchievements function, the Xbox system looks at what achievements the player already has and if any of the passed ids are for new achievements it writes the award information to the player’s profile and pops up the “Achievement unlocked” message (along with the happiest sound in the world).
So far we’ve only looked at what happens on one console, but what about comparing achievements? Or account recovery? Or viewing profiles on xbox.com? For those things to work we need support from the Xbox LIVE service.
In The Cloud
Back when the game developer was creating and compiling the XLAST file, he was also sending that file to the Xbox LIVE service. The Xbox LIVE profile service parses the XLAST file for every game so it knows every detail about every achievement. This is how you can browse achievements on xbox.com or compare your profile against someone and see achievement details of games you’ve never played. Achievement names and descriptions can be localized into many different languages, and the service is smart enough to give you the text in your language, if it’s available. Those translations were also specified in the XLAST file by the game developer.
Now we have a console-based profile that can be written to at any time, and a cloud-based service that knows about every game and their achievements. We’re almost ready for that Whistler ski trip. The last piece of the puzzle is the synchronization of the local copy of your profile with the copy that is stored on the service. Any write to your profile, such as the award of an achievement, will mark the profile “dirty” so that the next time you connect to LIVE (or about 30 seconds after the write if you are already connected to LIVE) the changed data will be sent to the service and merged into your profile stored there. This means that you can take your console on that ski trip, earn as many achievements as you want, and when you plug it back in at home those achievements will automatically be sent to the service and marked as awarded for the world to see.
If you turn off your console before the profile sync has happened, you won’t see your new achievements on xbox.com. More importantly, your friends won’t see your new achievements when viewing your profile! The sync is pretty fast and totally automatic, as long as you’re connected to Xbox LIVE. Sometimes I lose my connection, so to make sure everyone can revel in my mastery, when I see the “Achievement unlocked” popup, I hit the Xbox button on the controller and pop up the guide. That takes me right to the achievements screen so I can see details about my latest conquest. In the guide I can also check to see if I’m still connected to LIVE and reconnect if I’m not. Then I go back to playing, feeling confident that when my friends view my profile they’ll see my new trophy. None of that is required, but when you absolutely, positively want to make sure that you’re in sync you can double check your connection before signing off for the night. But remember, the sync is completely automatic and manual syncing is not something we’d ever ask our most excellent customers to do.
Now let’s look at some behind-the-scenes stories that fill in some details about how the system works as a whole.
Achievements had a rough childhood, both in terms of technology as well as socially. On the technology side I'll just give one piece of advice to anyone working on a similar system: if you want to stay in good with your boss' boss' boss, make sure that all of his Need for Speed achievements show up online. Drop one little achievement and you'll hear about it. (“Sorry, Ben!”)
The bigger growing pains came on the adoption and best practices fronts. At first, achievements were not well understood by game designers, and we didn't provide early titles with good guidance on how to best use the system. Because of this, early implementations of achievements were inconsistent and not as good as they could have been. Some games did the minimum required: 5 achievements which were tossed out for basically just starting the game. Some games made the achievements way too hard or too easy. Our developer support team has done an amazing job of providing guidance, including creating a 21-page, 8,000 word whitepaper on best practices for achievements. These days most designers realize that achievements provide a great motivator for people to try out new areas of their game, or offer replay value that would be difficult to advertise without them.
The icons above are symbolic of the evolution of achievements. The first was the very first achievement icon ever. I created it for my test game before I wrote any of the actual system code. Fun fact: it was also one of the first custom gamer pictures, but that's a story for another post. Dev art rules! The second was an image that Project Gotham Racing 3 used for ALL of its 20 achievements. It’s nice, but even games created by Microsoft weren’t using the system to its full extent. The last was from Gears of War 2, which has beautifully drawn, custom icons for every one of its 50 achievements. We've come a long, long way.
The Toast That Almost Wasn’t
We are proud of the consistency you find across all games. You have one friends list, every game supports voice chat, etc. But we also like to give game designers room to come up with new and interesting ways to entertain. That trade-off was at the heart of the original decision we made to not give any indication that a new achievement had been awarded. Some people argued that games wouldn’t want toast popping up in the heat of battle and that game designers would want to use their own visual style to present achievements. Others argued for consistency and for reducing the work required of game developers. In the end we added the notification popup and its happy beep, which turned out to be the right decision, but for a long time it was anything but obvious.
When Complete Isn’t Complete
It often comes as a surprise to people that games can add new achievements after they launch. It’s common for big games like Halo or Gears of War to add new gameplay options through title updates or downloadable content and the designers often want to entice people to try this new goodness by offering new achievements.
When a game launches, the system looks not only in the game’s resources, but also in all of the game’s downloadable content packages for the latest, most complete list of achievements. The system copies that list into your profile, so you can browse the achievements any time, even if you take your profile to a friend’s house. Any achievements added since the last time you played are merged into your profile, so when you view your profile you’ll see the new, unearned, achievements.
You might also see new achievements if you are comparing games with someone online. Xbox LIVE always knows the latest list of achievements, so it will show you those, even if you haven’t played the updated game, or downloaded any additional content. Comparing games doesn’t copy the new achievements into your profile so you’ll see them when comparing with someone else, but not if you’re just viewing your own profile.
These new achievements are great because they give game designers a lot of flexibility in rolling out new content and making that content as full-featured as the original game. But as powerful as it is, it can also be surprising. You may have earned all of the possible achievements one day, but find that new ones were added the next day. You were at 100% complete, but now you’re not, and there’s no way to “forget” that those achievements exist. For a completionist like me this can be frustrating. But there’s an easy answer: I fire up the game and go get those new achievements. It’s hard work but somebody’s gotta do it.
Achievements have been a hugely popular part of the Xbox 360 experience. So much so that we’ve expanded their presence into PC games with Games for Windows LIVE and soon into mobile games on the upcoming Windows Phone 7.
Building the achievements system was a lot of fun and I still love seeing the notification popup and hearing that happy sound. And since you read this whole post, you deserve to hear it now: