Achievements are a staple of modern gaming and an expected feature when you publish a game on Steam. Achievements are a way to encourage players to keep on playing or even replay your game multiple times. As such, Valve marks achievements as one of the features that will boost the sales of a title in their store. Luckily, Ren’Py supports achievements and adding them to your game is relatively simple.
First you should determine which goals you’d like a player to achieve. A mixture of easily obtained achievements and ones that are harder to get will satisfy most of your player base. As your game likely has a branching narrative with multiple choices along the way, you could for example reward a player for playing a specific branch. In my game, Sisterly Lust, people get rewarded for romancing each of the sisters, for example. Romancing a girl is an easy achievement in Sisterly Lust‘s case, but there are also ones that are harder to obtain, such as “Like a virgin” (don’t pursue any romances during a play-through) and “Two Soccer Teams” (every girl in the game gets pregnant). Make a list of achievement names, descriptions and artwork (256×256 pixel images, active and inactive versions) you want to use. It’s very important the names and artwork don’t contain any adult content, because achievements may appear anywhere on Steam.
This article deals with relatively simple achievements. Progress achievements (fuck a girl 100 times, for example) are also supported by Steam and Ren’Py through
achievement.progress(), but they function a little erratically based on my experience implementing them in Sisterly Lust.
First, register all of the achievements in Steamworks (App Admin > Your Game > Stats & Achievements):
- API Name Progress Stat is the name you’ll use in Ren’Py to call the achievement (the “Two Soccer Teams” achievement in my game has an API name of “TWOSOCCERTEAMS”, for example).
- Display Name is the name that appears on the achievement notification and on your profile.
- Description is a short text about what the player has achieved.
- Set By should be left as is (set to Client).
- Hidden? determines whether the achievement name and description are visible in the achievement overview. Set this to “Yes” this if you don’t want that information to spoil important details of your storyline.
- Achieved Icon is the version of your achievement icon when it has been obtained by the player.
- Unachieved Icon is the default state of the icon, when a players hasn’t obtained the achievement.
Once you’re done with adding achievements, be sure to note all the API names you’ve entered and publish the changes. Switch back to your game, because it’s time to add the Ren’Py code that will trigger the achievements via the Steam API.
Ren’Py has several helper functions for dealing with Steam achievements. The documentation seems to indicate that just calling
achievement.grant() would be enough, but for Sisterly Lust I stayed on the safe side and used the code snippet mentioned in this forum thread. So for granting the “Two Soccer Teams” achievement with the API name “TWOSOCCERTEAMS” you add the following code at the appropriate place in your Ren’Py script:
if not achievement.has("TWOSOCCERTEAMS"): $ achievement.grant("TWOSOCCERTEAMS") init: $ achievement.register("TWOSOCCERTEAMS") $ achievement.sync() $ achievement.sync()
Repeat the process for all of the achievements and that’s all there is to it.
Lastly, Ren’Py needs your Steam App ID, that the number that appears after your game’s name in Steamworks. Make a note of the number and add the following to your Ren’Py script (somewhere at the beginning of options.rpy seems like a good place):
define config.steam_appid = 1234567
Obviously 1234567 should be your App ID. Now you can test your Steam build and see if the achievements are correctly triggered.
Of course all of the above only applies to Steam. Players who download the game from another marketplace like itch.io or just from your own website will never see the achievements appear anywhere. If you want to implement achievements for all platforms, you’d have to look into rolling your own system and make it work alongside the Steam achievements you’ve set up. This article and this forum thread give some interesting pointers regarding the implementation of your own achievement system.
As with everything related to Steam, preparing copy and artwork for the feature can be quite a lot of work on your own, but a set of well-thought-out and well-placed achievements is one of the reasons a lot of players will keep coming back to your game.