AGS Games With Achievements For Steam

Started by Ghostlady, Fri 05/09/2025 04:34:37

Previous topic - Next topic

Ghostlady

Does anyone have a step by step method on how to add achievements to a Steam game?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Danvzare

As someone who's in the process of doing the same thing, I completely understand the confusion.
Hopefully someone will correct me if I get any of the steps wrong, but this is what I've personally done so far:

Step 1: Sign up for Steamworks (there's no point in putting in Steam achievements if you can't get your game on Steam)
Step 2: In the "Edit Steamworks Settings" for your app, is a "Stats & Achievements" tab where you can define new achievements. Create a new achievement and make a note of the API name you give it.
Step 3: Download AGSteam.
Step 4: Put the AGSteam.dll and steam_api.dll into the AGS directory, the place where the editor is stored.
Step 5: Open your game in the editor and activate the AGSteam plugin, then compile your game. (I also had to copy the steam_api.dll into the compiled folder for my game, but apparently it's supposed to do that automatically. So maybe I just jumped the gun by doing that.)
Step 6: Include the following code into your game for when the achievement should be achieved, with "API_NAME" being replaced with the API name your achievement has set up in Steamworks: AGS2Client.SetAchievementAchieved("API_NAME");

And that should be it.
There's more you can do, such as wrapping the code in a function that lets you easily disable achievements for a non-Steam release. But for the most part, that should be everything.

Crimson Wizard

Quote from: Danvzare on Fri 05/09/2025 14:50:06(I also had to copy the steam_api.dll into the compiled folder for my game, but apparently it's supposed to do that automatically. So maybe I just jumped the gun by doing that.)

The Editor cannot do that automatically simply because it has no idea one is necessary. It knows about the plugin, but does not check the plugin's dependencies.

We had an issue opened for this, but it was not fixed yet:
https://github.com/adventuregamestudio/ags/issues/2239

Ghostlady

Thank you, Danvzare!  This is perfect and fantastic.  I am very appreciative to you for putting this together!
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Ghostlady

#4
For step 5 do I copy the steam_api.dll right under the Compiled folder or under the Data or Windows folder?

Update: I believe I got this working.  I put the .dll in the Windows folder.

My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Crimson Wizard

Quote from: Ghostlady on Yesterday at 03:59:02For step 5 do I copy the steam_api.dll right under the Compiled folder or under the Data or Windows folder?

Update: I believe I got this working.  I put the .dll in the Windows folder.

Probably you should also have a second copy in your game project's root, in case you want to test Steam plugin when running the game from the editor.

Ghostlady

Quote from: Crimson Wizard on Yesterday at 11:02:38Probably you should also have a second copy in your game project's root, in case you want to test Steam plugin when running the game from the editor.

Where would I see the test results in the editor?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Crimson Wizard

Quote from: Ghostlady on Yesterday at 16:59:18Where would I see the test results in the editor?

I meant, when you are running the game from the Editor with F5.

Ghostlady

Quote from: Crimson Wizard on Yesterday at 17:02:04
Quote from: Ghostlady on Yesterday at 16:59:18Where would I see the test results in the editor?

I meant, when you are running the game from the Editor with F5.
Do you mean in Debug mode?

A different question.  Is there a way to lock the achievements after they have been unlocked?  Is there a reverse to AGS2Client.SetAchievementAchieved("API_NAME") like a "Not Achieved"?  Could I use some code when the game is started asking the player if they would like all the achievements locked again and then based on their answer, lock them back up?

On my first test run I unlocked two achievements. I had to change some code and would like to test these two but they are unlocked and now I can't test.  So if not for the above at least for this.



My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Crimson Wizard

#9
Quote from: Ghostlady on Today at 04:23:54Do you mean in Debug mode?

I mean a game run from the Editor, which you do with F5. It can be done with either "Debug Mode" option on or off, it does not matter in this case.
Also I was wrong, the dll has to be copied to _Debug folder, not to the project root.


Quote from: Ghostlady on Today at 04:23:54A different question.  Is there a way to lock the achievements after they have been unlocked?

AGS2Client.ResetAchievement
AGS2Client.ResetStatsAndAchievements

You may type "AGS2Client." in your script and editor will show you "autocomplete" window with the list of functions that it provides.

Ghostlady

Ok, thanks.

Can you give me more info about typing AGS2Client in your script? Do you mean the room script where the achievement is being placed? Can you show me an example?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Crimson Wizard

#11
Quote from: Ghostlady on Today at 05:12:41Can you give me more info about typing AGS2Client in your script? Do you mean the room script where the achievement is being placed? Can you show me an example?

When you type a name of a class, such as "AGS2Client", anywhere in AGS script, and type a "dot", Editor will display a list of functions from that class. That's how you may explore which functions are available there. Often it is possible to guess what they do by their names.


SMF spam blocked by CleanTalk